Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rxjs.umd.js 358KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241
  1. /**
  2. @license
  3. Apache License
  4. Version 2.0, January 2004
  5. http://www.apache.org/licenses/
  6. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  7. 1. Definitions.
  8. "License" shall mean the terms and conditions for use, reproduction,
  9. and distribution as defined by Sections 1 through 9 of this document.
  10. "Licensor" shall mean the copyright owner or entity authorized by
  11. the copyright owner that is granting the License.
  12. "Legal Entity" shall mean the union of the acting entity and all
  13. other entities that control, are controlled by, or are under common
  14. control with that entity. For the purposes of this definition,
  15. "control" means (i) the power, direct or indirect, to cause the
  16. direction or management of such entity, whether by contract or
  17. otherwise, or (ii) ownership of fifty percent (50%) or more of the
  18. outstanding shares, or (iii) beneficial ownership of such entity.
  19. "You" (or "Your") shall mean an individual or Legal Entity
  20. exercising permissions granted by this License.
  21. "Source" form shall mean the preferred form for making modifications,
  22. including but not limited to software source code, documentation
  23. source, and configuration files.
  24. "Object" form shall mean any form resulting from mechanical
  25. transformation or translation of a Source form, including but
  26. not limited to compiled object code, generated documentation,
  27. and conversions to other media types.
  28. "Work" shall mean the work of authorship, whether in Source or
  29. Object form, made available under the License, as indicated by a
  30. copyright notice that is included in or attached to the work
  31. (an example is provided in the Appendix below).
  32. "Derivative Works" shall mean any work, whether in Source or Object
  33. form, that is based on (or derived from) the Work and for which the
  34. editorial revisions, annotations, elaborations, or other modifications
  35. represent, as a whole, an original work of authorship. For the purposes
  36. of this License, Derivative Works shall not include works that remain
  37. separable from, or merely link (or bind by name) to the interfaces of,
  38. the Work and Derivative Works thereof.
  39. "Contribution" shall mean any work of authorship, including
  40. the original version of the Work and any modifications or additions
  41. to that Work or Derivative Works thereof, that is intentionally
  42. submitted to Licensor for inclusion in the Work by the copyright owner
  43. or by an individual or Legal Entity authorized to submit on behalf of
  44. the copyright owner. For the purposes of this definition, "submitted"
  45. means any form of electronic, verbal, or written communication sent
  46. to the Licensor or its representatives, including but not limited to
  47. communication on electronic mailing lists, source code control systems,
  48. and issue tracking systems that are managed by, or on behalf of, the
  49. Licensor for the purpose of discussing and improving the Work, but
  50. excluding communication that is conspicuously marked or otherwise
  51. designated in writing by the copyright owner as "Not a Contribution."
  52. "Contributor" shall mean Licensor and any individual or Legal Entity
  53. on behalf of whom a Contribution has been received by Licensor and
  54. subsequently incorporated within the Work.
  55. 2. Grant of Copyright License. Subject to the terms and conditions of
  56. this License, each Contributor hereby grants to You a perpetual,
  57. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  58. copyright license to reproduce, prepare Derivative Works of,
  59. publicly display, publicly perform, sublicense, and distribute the
  60. Work and such Derivative Works in Source or Object form.
  61. 3. Grant of Patent License. Subject to the terms and conditions of
  62. this License, each Contributor hereby grants to You a perpetual,
  63. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  64. (except as stated in this section) patent license to make, have made,
  65. use, offer to sell, sell, import, and otherwise transfer the Work,
  66. where such license applies only to those patent claims licensable
  67. by such Contributor that are necessarily infringed by their
  68. Contribution(s) alone or by combination of their Contribution(s)
  69. with the Work to which such Contribution(s) was submitted. If You
  70. institute patent litigation against any entity (including a
  71. cross-claim or counterclaim in a lawsuit) alleging that the Work
  72. or a Contribution incorporated within the Work constitutes direct
  73. or contributory patent infringement, then any patent licenses
  74. granted to You under this License for that Work shall terminate
  75. as of the date such litigation is filed.
  76. 4. Redistribution. You may reproduce and distribute copies of the
  77. Work or Derivative Works thereof in any medium, with or without
  78. modifications, and in Source or Object form, provided that You
  79. meet the following conditions:
  80. (a) You must give any other recipients of the Work or
  81. Derivative Works a copy of this License; and
  82. (b) You must cause any modified files to carry prominent notices
  83. stating that You changed the files; and
  84. (c) You must retain, in the Source form of any Derivative Works
  85. that You distribute, all copyright, patent, trademark, and
  86. attribution notices from the Source form of the Work,
  87. excluding those notices that do not pertain to any part of
  88. the Derivative Works; and
  89. (d) If the Work includes a "NOTICE" text file as part of its
  90. distribution, then any Derivative Works that You distribute must
  91. include a readable copy of the attribution notices contained
  92. within such NOTICE file, excluding those notices that do not
  93. pertain to any part of the Derivative Works, in at least one
  94. of the following places: within a NOTICE text file distributed
  95. as part of the Derivative Works; within the Source form or
  96. documentation, if provided along with the Derivative Works; or,
  97. within a display generated by the Derivative Works, if and
  98. wherever such third-party notices normally appear. The contents
  99. of the NOTICE file are for informational purposes only and
  100. do not modify the License. You may add Your own attribution
  101. notices within Derivative Works that You distribute, alongside
  102. or as an addendum to the NOTICE text from the Work, provided
  103. that such additional attribution notices cannot be construed
  104. as modifying the License.
  105. You may add Your own copyright statement to Your modifications and
  106. may provide additional or different license terms and conditions
  107. for use, reproduction, or distribution of Your modifications, or
  108. for any such Derivative Works as a whole, provided Your use,
  109. reproduction, and distribution of the Work otherwise complies with
  110. the conditions stated in this License.
  111. 5. Submission of Contributions. Unless You explicitly state otherwise,
  112. any Contribution intentionally submitted for inclusion in the Work
  113. by You to the Licensor shall be under the terms and conditions of
  114. this License, without any additional terms or conditions.
  115. Notwithstanding the above, nothing herein shall supersede or modify
  116. the terms of any separate license agreement you may have executed
  117. with Licensor regarding such Contributions.
  118. 6. Trademarks. This License does not grant permission to use the trade
  119. names, trademarks, service marks, or product names of the Licensor,
  120. except as required for reasonable and customary use in describing the
  121. origin of the Work and reproducing the content of the NOTICE file.
  122. 7. Disclaimer of Warranty. Unless required by applicable law or
  123. agreed to in writing, Licensor provides the Work (and each
  124. Contributor provides its Contributions) on an "AS IS" BASIS,
  125. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  126. implied, including, without limitation, any warranties or conditions
  127. of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  128. PARTICULAR PURPOSE. You are solely responsible for determining the
  129. appropriateness of using or redistributing the Work and assume any
  130. risks associated with Your exercise of permissions under this License.
  131. 8. Limitation of Liability. In no event and under no legal theory,
  132. whether in tort (including negligence), contract, or otherwise,
  133. unless required by applicable law (such as deliberate and grossly
  134. negligent acts) or agreed to in writing, shall any Contributor be
  135. liable to You for damages, including any direct, indirect, special,
  136. incidental, or consequential damages of any character arising as a
  137. result of this License or out of the use or inability to use the
  138. Work (including but not limited to damages for loss of goodwill,
  139. work stoppage, computer failure or malfunction, or any and all
  140. other commercial damages or losses), even if such Contributor
  141. has been advised of the possibility of such damages.
  142. 9. Accepting Warranty or Additional Liability. While redistributing
  143. the Work or Derivative Works thereof, You may choose to offer,
  144. and charge a fee for, acceptance of support, warranty, indemnity,
  145. or other liability obligations and/or rights consistent with this
  146. License. However, in accepting such obligations, You may act only
  147. on Your own behalf and on Your sole responsibility, not on behalf
  148. of any other Contributor, and only if You agree to indemnify,
  149. defend, and hold each Contributor harmless for any liability
  150. incurred by, or claims asserted against, such Contributor by reason
  151. of your accepting any such warranty or additional liability.
  152. END OF TERMS AND CONDITIONS
  153. APPENDIX: How to apply the Apache License to your work.
  154. To apply the Apache License to your work, attach the following
  155. boilerplate notice, with the fields enclosed by brackets "[]"
  156. replaced with your own identifying information. (Don't include
  157. the brackets!) The text should be enclosed in the appropriate
  158. comment syntax for the file format. We also recommend that a
  159. file or class name and description of purpose be included on the
  160. same "printed page" as the copyright notice for easier
  161. identification within third-party archives.
  162. Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
  163. Licensed under the Apache License, Version 2.0 (the "License");
  164. you may not use this file except in compliance with the License.
  165. You may obtain a copy of the License at
  166. http://www.apache.org/licenses/LICENSE-2.0
  167. Unless required by applicable law or agreed to in writing, software
  168. distributed under the License is distributed on an "AS IS" BASIS,
  169. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  170. See the License for the specific language governing permissions and
  171. limitations under the License.
  172. **/
  173. /**
  174. @license
  175. Apache License
  176. Version 2.0, January 2004
  177. http://www.apache.org/licenses/
  178. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  179. 1. Definitions.
  180. "License" shall mean the terms and conditions for use, reproduction,
  181. and distribution as defined by Sections 1 through 9 of this document.
  182. "Licensor" shall mean the copyright owner or entity authorized by
  183. the copyright owner that is granting the License.
  184. "Legal Entity" shall mean the union of the acting entity and all
  185. other entities that control, are controlled by, or are under common
  186. control with that entity. For the purposes of this definition,
  187. "control" means (i) the power, direct or indirect, to cause the
  188. direction or management of such entity, whether by contract or
  189. otherwise, or (ii) ownership of fifty percent (50%) or more of the
  190. outstanding shares, or (iii) beneficial ownership of such entity.
  191. "You" (or "Your") shall mean an individual or Legal Entity
  192. exercising permissions granted by this License.
  193. "Source" form shall mean the preferred form for making modifications,
  194. including but not limited to software source code, documentation
  195. source, and configuration files.
  196. "Object" form shall mean any form resulting from mechanical
  197. transformation or translation of a Source form, including but
  198. not limited to compiled object code, generated documentation,
  199. and conversions to other media types.
  200. "Work" shall mean the work of authorship, whether in Source or
  201. Object form, made available under the License, as indicated by a
  202. copyright notice that is included in or attached to the work
  203. (an example is provided in the Appendix below).
  204. "Derivative Works" shall mean any work, whether in Source or Object
  205. form, that is based on (or derived from) the Work and for which the
  206. editorial revisions, annotations, elaborations, or other modifications
  207. represent, as a whole, an original work of authorship. For the purposes
  208. of this License, Derivative Works shall not include works that remain
  209. separable from, or merely link (or bind by name) to the interfaces of,
  210. the Work and Derivative Works thereof.
  211. "Contribution" shall mean any work of authorship, including
  212. the original version of the Work and any modifications or additions
  213. to that Work or Derivative Works thereof, that is intentionally
  214. submitted to Licensor for inclusion in the Work by the copyright owner
  215. or by an individual or Legal Entity authorized to submit on behalf of
  216. the copyright owner. For the purposes of this definition, "submitted"
  217. means any form of electronic, verbal, or written communication sent
  218. to the Licensor or its representatives, including but not limited to
  219. communication on electronic mailing lists, source code control systems,
  220. and issue tracking systems that are managed by, or on behalf of, the
  221. Licensor for the purpose of discussing and improving the Work, but
  222. excluding communication that is conspicuously marked or otherwise
  223. designated in writing by the copyright owner as "Not a Contribution."
  224. "Contributor" shall mean Licensor and any individual or Legal Entity
  225. on behalf of whom a Contribution has been received by Licensor and
  226. subsequently incorporated within the Work.
  227. 2. Grant of Copyright License. Subject to the terms and conditions of
  228. this License, each Contributor hereby grants to You a perpetual,
  229. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  230. copyright license to reproduce, prepare Derivative Works of,
  231. publicly display, publicly perform, sublicense, and distribute the
  232. Work and such Derivative Works in Source or Object form.
  233. 3. Grant of Patent License. Subject to the terms and conditions of
  234. this License, each Contributor hereby grants to You a perpetual,
  235. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  236. (except as stated in this section) patent license to make, have made,
  237. use, offer to sell, sell, import, and otherwise transfer the Work,
  238. where such license applies only to those patent claims licensable
  239. by such Contributor that are necessarily infringed by their
  240. Contribution(s) alone or by combination of their Contribution(s)
  241. with the Work to which such Contribution(s) was submitted. If You
  242. institute patent litigation against any entity (including a
  243. cross-claim or counterclaim in a lawsuit) alleging that the Work
  244. or a Contribution incorporated within the Work constitutes direct
  245. or contributory patent infringement, then any patent licenses
  246. granted to You under this License for that Work shall terminate
  247. as of the date such litigation is filed.
  248. 4. Redistribution. You may reproduce and distribute copies of the
  249. Work or Derivative Works thereof in any medium, with or without
  250. modifications, and in Source or Object form, provided that You
  251. meet the following conditions:
  252. (a) You must give any other recipients of the Work or
  253. Derivative Works a copy of this License; and
  254. (b) You must cause any modified files to carry prominent notices
  255. stating that You changed the files; and
  256. (c) You must retain, in the Source form of any Derivative Works
  257. that You distribute, all copyright, patent, trademark, and
  258. attribution notices from the Source form of the Work,
  259. excluding those notices that do not pertain to any part of
  260. the Derivative Works; and
  261. (d) If the Work includes a "NOTICE" text file as part of its
  262. distribution, then any Derivative Works that You distribute must
  263. include a readable copy of the attribution notices contained
  264. within such NOTICE file, excluding those notices that do not
  265. pertain to any part of the Derivative Works, in at least one
  266. of the following places: within a NOTICE text file distributed
  267. as part of the Derivative Works; within the Source form or
  268. documentation, if provided along with the Derivative Works; or,
  269. within a display generated by the Derivative Works, if and
  270. wherever such third-party notices normally appear. The contents
  271. of the NOTICE file are for informational purposes only and
  272. do not modify the License. You may add Your own attribution
  273. notices within Derivative Works that You distribute, alongside
  274. or as an addendum to the NOTICE text from the Work, provided
  275. that such additional attribution notices cannot be construed
  276. as modifying the License.
  277. You may add Your own copyright statement to Your modifications and
  278. may provide additional or different license terms and conditions
  279. for use, reproduction, or distribution of Your modifications, or
  280. for any such Derivative Works as a whole, provided Your use,
  281. reproduction, and distribution of the Work otherwise complies with
  282. the conditions stated in this License.
  283. 5. Submission of Contributions. Unless You explicitly state otherwise,
  284. any Contribution intentionally submitted for inclusion in the Work
  285. by You to the Licensor shall be under the terms and conditions of
  286. this License, without any additional terms or conditions.
  287. Notwithstanding the above, nothing herein shall supersede or modify
  288. the terms of any separate license agreement you may have executed
  289. with Licensor regarding such Contributions.
  290. 6. Trademarks. This License does not grant permission to use the trade
  291. names, trademarks, service marks, or product names of the Licensor,
  292. except as required for reasonable and customary use in describing the
  293. origin of the Work and reproducing the content of the NOTICE file.
  294. 7. Disclaimer of Warranty. Unless required by applicable law or
  295. agreed to in writing, Licensor provides the Work (and each
  296. Contributor provides its Contributions) on an "AS IS" BASIS,
  297. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  298. implied, including, without limitation, any warranties or conditions
  299. of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  300. PARTICULAR PURPOSE. You are solely responsible for determining the
  301. appropriateness of using or redistributing the Work and assume any
  302. risks associated with Your exercise of permissions under this License.
  303. 8. Limitation of Liability. In no event and under no legal theory,
  304. whether in tort (including negligence), contract, or otherwise,
  305. unless required by applicable law (such as deliberate and grossly
  306. negligent acts) or agreed to in writing, shall any Contributor be
  307. liable to You for damages, including any direct, indirect, special,
  308. incidental, or consequential damages of any character arising as a
  309. result of this License or out of the use or inability to use the
  310. Work (including but not limited to damages for loss of goodwill,
  311. work stoppage, computer failure or malfunction, or any and all
  312. other commercial damages or losses), even if such Contributor
  313. has been advised of the possibility of such damages.
  314. 9. Accepting Warranty or Additional Liability. While redistributing
  315. the Work or Derivative Works thereof, You may choose to offer,
  316. and charge a fee for, acceptance of support, warranty, indemnity,
  317. or other liability obligations and/or rights consistent with this
  318. License. However, in accepting such obligations, You may act only
  319. on Your own behalf and on Your sole responsibility, not on behalf
  320. of any other Contributor, and only if You agree to indemnify,
  321. defend, and hold each Contributor harmless for any liability
  322. incurred by, or claims asserted against, such Contributor by reason
  323. of your accepting any such warranty or additional liability.
  324. END OF TERMS AND CONDITIONS
  325. APPENDIX: How to apply the Apache License to your work.
  326. To apply the Apache License to your work, attach the following
  327. boilerplate notice, with the fields enclosed by brackets "[]"
  328. replaced with your own identifying information. (Don't include
  329. the brackets!) The text should be enclosed in the appropriate
  330. comment syntax for the file format. We also recommend that a
  331. file or class name and description of purpose be included on the
  332. same "printed page" as the copyright notice for easier
  333. identification within third-party archives.
  334. Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
  335. Licensed under the Apache License, Version 2.0 (the "License");
  336. you may not use this file except in compliance with the License.
  337. You may obtain a copy of the License at
  338. http://www.apache.org/licenses/LICENSE-2.0
  339. Unless required by applicable law or agreed to in writing, software
  340. distributed under the License is distributed on an "AS IS" BASIS,
  341. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  342. See the License for the specific language governing permissions and
  343. limitations under the License.
  344. **/
  345. (function (global, factory) {
  346. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  347. typeof define === 'function' && define.amd ? define('rxjs', ['exports'], factory) :
  348. (factory((global.rxjs = {})));
  349. }(this, (function (exports) { 'use strict';
  350. /*! *****************************************************************************
  351. Copyright (c) Microsoft Corporation. All rights reserved.
  352. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  353. this file except in compliance with the License. You may obtain a copy of the
  354. License at http://www.apache.org/licenses/LICENSE-2.0
  355. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  356. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  357. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  358. MERCHANTABLITY OR NON-INFRINGEMENT.
  359. See the Apache Version 2.0 License for specific language governing permissions
  360. and limitations under the License.
  361. ***************************************************************************** */
  362. /* global Reflect, Promise */
  363. var extendStatics = Object.setPrototypeOf ||
  364. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  365. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  366. function __extends(d, b) {
  367. extendStatics(d, b);
  368. function __() { this.constructor = d; }
  369. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  370. }
  371. var __assign = Object.assign || function __assign(t) {
  372. for (var s, i = 1, n = arguments.length; i < n; i++) {
  373. s = arguments[i];
  374. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  375. }
  376. return t;
  377. };
  378. function isFunction(x) {
  379. return typeof x === 'function';
  380. }
  381. var _enable_super_gross_mode_that_will_cause_bad_things = false;
  382. var config = {
  383. Promise: undefined,
  384. set useDeprecatedSynchronousErrorHandling(value) {
  385. if (value) {
  386. var error = new Error();
  387. console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
  388. }
  389. else if (_enable_super_gross_mode_that_will_cause_bad_things) {
  390. console.log('RxJS: Back to a better error behavior. Thank you. <3');
  391. }
  392. _enable_super_gross_mode_that_will_cause_bad_things = value;
  393. },
  394. get useDeprecatedSynchronousErrorHandling() {
  395. return _enable_super_gross_mode_that_will_cause_bad_things;
  396. },
  397. };
  398. function hostReportError(err) {
  399. setTimeout(function () { throw err; }, 0);
  400. }
  401. var empty = {
  402. closed: true,
  403. next: function (value) { },
  404. error: function (err) {
  405. if (config.useDeprecatedSynchronousErrorHandling) {
  406. throw err;
  407. }
  408. else {
  409. hostReportError(err);
  410. }
  411. },
  412. complete: function () { }
  413. };
  414. var isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
  415. function isObject(x) {
  416. return x !== null && typeof x === 'object';
  417. }
  418. function UnsubscriptionErrorImpl(errors) {
  419. Error.call(this);
  420. this.message = errors ?
  421. errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
  422. this.name = 'UnsubscriptionError';
  423. this.errors = errors;
  424. return this;
  425. }
  426. UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
  427. var UnsubscriptionError = UnsubscriptionErrorImpl;
  428. var Subscription = (function () {
  429. function Subscription(unsubscribe) {
  430. this.closed = false;
  431. this._parentOrParents = null;
  432. this._subscriptions = null;
  433. if (unsubscribe) {
  434. this._unsubscribe = unsubscribe;
  435. }
  436. }
  437. Subscription.prototype.unsubscribe = function () {
  438. var errors;
  439. if (this.closed) {
  440. return;
  441. }
  442. var _a = this, _parentOrParents = _a._parentOrParents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
  443. this.closed = true;
  444. this._parentOrParents = null;
  445. this._subscriptions = null;
  446. if (_parentOrParents instanceof Subscription) {
  447. _parentOrParents.remove(this);
  448. }
  449. else if (_parentOrParents !== null) {
  450. for (var index = 0; index < _parentOrParents.length; ++index) {
  451. var parent_1 = _parentOrParents[index];
  452. parent_1.remove(this);
  453. }
  454. }
  455. if (isFunction(_unsubscribe)) {
  456. try {
  457. _unsubscribe.call(this);
  458. }
  459. catch (e) {
  460. errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
  461. }
  462. }
  463. if (isArray(_subscriptions)) {
  464. var index = -1;
  465. var len = _subscriptions.length;
  466. while (++index < len) {
  467. var sub = _subscriptions[index];
  468. if (isObject(sub)) {
  469. try {
  470. sub.unsubscribe();
  471. }
  472. catch (e) {
  473. errors = errors || [];
  474. if (e instanceof UnsubscriptionError) {
  475. errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
  476. }
  477. else {
  478. errors.push(e);
  479. }
  480. }
  481. }
  482. }
  483. }
  484. if (errors) {
  485. throw new UnsubscriptionError(errors);
  486. }
  487. };
  488. Subscription.prototype.add = function (teardown) {
  489. var subscription = teardown;
  490. if (!teardown) {
  491. return Subscription.EMPTY;
  492. }
  493. switch (typeof teardown) {
  494. case 'function':
  495. subscription = new Subscription(teardown);
  496. case 'object':
  497. if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
  498. return subscription;
  499. }
  500. else if (this.closed) {
  501. subscription.unsubscribe();
  502. return subscription;
  503. }
  504. else if (!(subscription instanceof Subscription)) {
  505. var tmp = subscription;
  506. subscription = new Subscription();
  507. subscription._subscriptions = [tmp];
  508. }
  509. break;
  510. default: {
  511. throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
  512. }
  513. }
  514. var _parentOrParents = subscription._parentOrParents;
  515. if (_parentOrParents === null) {
  516. subscription._parentOrParents = this;
  517. }
  518. else if (_parentOrParents instanceof Subscription) {
  519. if (_parentOrParents === this) {
  520. return subscription;
  521. }
  522. subscription._parentOrParents = [_parentOrParents, this];
  523. }
  524. else if (_parentOrParents.indexOf(this) === -1) {
  525. _parentOrParents.push(this);
  526. }
  527. else {
  528. return subscription;
  529. }
  530. var subscriptions = this._subscriptions;
  531. if (subscriptions === null) {
  532. this._subscriptions = [subscription];
  533. }
  534. else {
  535. subscriptions.push(subscription);
  536. }
  537. return subscription;
  538. };
  539. Subscription.prototype.remove = function (subscription) {
  540. var subscriptions = this._subscriptions;
  541. if (subscriptions) {
  542. var subscriptionIndex = subscriptions.indexOf(subscription);
  543. if (subscriptionIndex !== -1) {
  544. subscriptions.splice(subscriptionIndex, 1);
  545. }
  546. }
  547. };
  548. Subscription.EMPTY = (function (empty) {
  549. empty.closed = true;
  550. return empty;
  551. }(new Subscription()));
  552. return Subscription;
  553. }());
  554. function flattenUnsubscriptionErrors(errors) {
  555. return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
  556. }
  557. var rxSubscriber = typeof Symbol === 'function'
  558. ? Symbol('rxSubscriber')
  559. : '@@rxSubscriber_' + Math.random();
  560. var Subscriber = (function (_super) {
  561. __extends(Subscriber, _super);
  562. function Subscriber(destinationOrNext, error, complete) {
  563. var _this = _super.call(this) || this;
  564. _this.syncErrorValue = null;
  565. _this.syncErrorThrown = false;
  566. _this.syncErrorThrowable = false;
  567. _this.isStopped = false;
  568. switch (arguments.length) {
  569. case 0:
  570. _this.destination = empty;
  571. break;
  572. case 1:
  573. if (!destinationOrNext) {
  574. _this.destination = empty;
  575. break;
  576. }
  577. if (typeof destinationOrNext === 'object') {
  578. if (destinationOrNext instanceof Subscriber) {
  579. _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
  580. _this.destination = destinationOrNext;
  581. destinationOrNext.add(_this);
  582. }
  583. else {
  584. _this.syncErrorThrowable = true;
  585. _this.destination = new SafeSubscriber(_this, destinationOrNext);
  586. }
  587. break;
  588. }
  589. default:
  590. _this.syncErrorThrowable = true;
  591. _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
  592. break;
  593. }
  594. return _this;
  595. }
  596. Subscriber.prototype[rxSubscriber] = function () { return this; };
  597. Subscriber.create = function (next, error, complete) {
  598. var subscriber = new Subscriber(next, error, complete);
  599. subscriber.syncErrorThrowable = false;
  600. return subscriber;
  601. };
  602. Subscriber.prototype.next = function (value) {
  603. if (!this.isStopped) {
  604. this._next(value);
  605. }
  606. };
  607. Subscriber.prototype.error = function (err) {
  608. if (!this.isStopped) {
  609. this.isStopped = true;
  610. this._error(err);
  611. }
  612. };
  613. Subscriber.prototype.complete = function () {
  614. if (!this.isStopped) {
  615. this.isStopped = true;
  616. this._complete();
  617. }
  618. };
  619. Subscriber.prototype.unsubscribe = function () {
  620. if (this.closed) {
  621. return;
  622. }
  623. this.isStopped = true;
  624. _super.prototype.unsubscribe.call(this);
  625. };
  626. Subscriber.prototype._next = function (value) {
  627. this.destination.next(value);
  628. };
  629. Subscriber.prototype._error = function (err) {
  630. this.destination.error(err);
  631. this.unsubscribe();
  632. };
  633. Subscriber.prototype._complete = function () {
  634. this.destination.complete();
  635. this.unsubscribe();
  636. };
  637. Subscriber.prototype._unsubscribeAndRecycle = function () {
  638. var _parentOrParents = this._parentOrParents;
  639. this._parentOrParents = null;
  640. this.unsubscribe();
  641. this.closed = false;
  642. this.isStopped = false;
  643. this._parentOrParents = _parentOrParents;
  644. return this;
  645. };
  646. return Subscriber;
  647. }(Subscription));
  648. var SafeSubscriber = (function (_super) {
  649. __extends(SafeSubscriber, _super);
  650. function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
  651. var _this = _super.call(this) || this;
  652. _this._parentSubscriber = _parentSubscriber;
  653. var next;
  654. var context = _this;
  655. if (isFunction(observerOrNext)) {
  656. next = observerOrNext;
  657. }
  658. else if (observerOrNext) {
  659. next = observerOrNext.next;
  660. error = observerOrNext.error;
  661. complete = observerOrNext.complete;
  662. if (observerOrNext !== empty) {
  663. context = Object.create(observerOrNext);
  664. if (isFunction(context.unsubscribe)) {
  665. _this.add(context.unsubscribe.bind(context));
  666. }
  667. context.unsubscribe = _this.unsubscribe.bind(_this);
  668. }
  669. }
  670. _this._context = context;
  671. _this._next = next;
  672. _this._error = error;
  673. _this._complete = complete;
  674. return _this;
  675. }
  676. SafeSubscriber.prototype.next = function (value) {
  677. if (!this.isStopped && this._next) {
  678. var _parentSubscriber = this._parentSubscriber;
  679. if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
  680. this.__tryOrUnsub(this._next, value);
  681. }
  682. else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
  683. this.unsubscribe();
  684. }
  685. }
  686. };
  687. SafeSubscriber.prototype.error = function (err) {
  688. if (!this.isStopped) {
  689. var _parentSubscriber = this._parentSubscriber;
  690. var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
  691. if (this._error) {
  692. if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
  693. this.__tryOrUnsub(this._error, err);
  694. this.unsubscribe();
  695. }
  696. else {
  697. this.__tryOrSetError(_parentSubscriber, this._error, err);
  698. this.unsubscribe();
  699. }
  700. }
  701. else if (!_parentSubscriber.syncErrorThrowable) {
  702. this.unsubscribe();
  703. if (useDeprecatedSynchronousErrorHandling) {
  704. throw err;
  705. }
  706. hostReportError(err);
  707. }
  708. else {
  709. if (useDeprecatedSynchronousErrorHandling) {
  710. _parentSubscriber.syncErrorValue = err;
  711. _parentSubscriber.syncErrorThrown = true;
  712. }
  713. else {
  714. hostReportError(err);
  715. }
  716. this.unsubscribe();
  717. }
  718. }
  719. };
  720. SafeSubscriber.prototype.complete = function () {
  721. var _this = this;
  722. if (!this.isStopped) {
  723. var _parentSubscriber = this._parentSubscriber;
  724. if (this._complete) {
  725. var wrappedComplete = function () { return _this._complete.call(_this._context); };
  726. if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
  727. this.__tryOrUnsub(wrappedComplete);
  728. this.unsubscribe();
  729. }
  730. else {
  731. this.__tryOrSetError(_parentSubscriber, wrappedComplete);
  732. this.unsubscribe();
  733. }
  734. }
  735. else {
  736. this.unsubscribe();
  737. }
  738. }
  739. };
  740. SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
  741. try {
  742. fn.call(this._context, value);
  743. }
  744. catch (err) {
  745. this.unsubscribe();
  746. if (config.useDeprecatedSynchronousErrorHandling) {
  747. throw err;
  748. }
  749. else {
  750. hostReportError(err);
  751. }
  752. }
  753. };
  754. SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
  755. if (!config.useDeprecatedSynchronousErrorHandling) {
  756. throw new Error('bad call');
  757. }
  758. try {
  759. fn.call(this._context, value);
  760. }
  761. catch (err) {
  762. if (config.useDeprecatedSynchronousErrorHandling) {
  763. parent.syncErrorValue = err;
  764. parent.syncErrorThrown = true;
  765. return true;
  766. }
  767. else {
  768. hostReportError(err);
  769. return true;
  770. }
  771. }
  772. return false;
  773. };
  774. SafeSubscriber.prototype._unsubscribe = function () {
  775. var _parentSubscriber = this._parentSubscriber;
  776. this._context = null;
  777. this._parentSubscriber = null;
  778. _parentSubscriber.unsubscribe();
  779. };
  780. return SafeSubscriber;
  781. }(Subscriber));
  782. function canReportError(observer) {
  783. while (observer) {
  784. var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
  785. if (closed_1 || isStopped) {
  786. return false;
  787. }
  788. else if (destination && destination instanceof Subscriber) {
  789. observer = destination;
  790. }
  791. else {
  792. observer = null;
  793. }
  794. }
  795. return true;
  796. }
  797. function toSubscriber(nextOrObserver, error, complete) {
  798. if (nextOrObserver) {
  799. if (nextOrObserver instanceof Subscriber) {
  800. return nextOrObserver;
  801. }
  802. if (nextOrObserver[rxSubscriber]) {
  803. return nextOrObserver[rxSubscriber]();
  804. }
  805. }
  806. if (!nextOrObserver && !error && !complete) {
  807. return new Subscriber(empty);
  808. }
  809. return new Subscriber(nextOrObserver, error, complete);
  810. }
  811. var observable = typeof Symbol === 'function' && Symbol.observable || '@@observable';
  812. function noop() { }
  813. function pipe() {
  814. var fns = [];
  815. for (var _i = 0; _i < arguments.length; _i++) {
  816. fns[_i] = arguments[_i];
  817. }
  818. return pipeFromArray(fns);
  819. }
  820. function pipeFromArray(fns) {
  821. if (!fns) {
  822. return noop;
  823. }
  824. if (fns.length === 1) {
  825. return fns[0];
  826. }
  827. return function piped(input) {
  828. return fns.reduce(function (prev, fn) { return fn(prev); }, input);
  829. };
  830. }
  831. var Observable = (function () {
  832. function Observable(subscribe) {
  833. this._isScalar = false;
  834. if (subscribe) {
  835. this._subscribe = subscribe;
  836. }
  837. }
  838. Observable.prototype.lift = function (operator) {
  839. var observable$$1 = new Observable();
  840. observable$$1.source = this;
  841. observable$$1.operator = operator;
  842. return observable$$1;
  843. };
  844. Observable.prototype.subscribe = function (observerOrNext, error, complete) {
  845. var operator = this.operator;
  846. var sink = toSubscriber(observerOrNext, error, complete);
  847. if (operator) {
  848. sink.add(operator.call(sink, this.source));
  849. }
  850. else {
  851. sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
  852. this._subscribe(sink) :
  853. this._trySubscribe(sink));
  854. }
  855. if (config.useDeprecatedSynchronousErrorHandling) {
  856. if (sink.syncErrorThrowable) {
  857. sink.syncErrorThrowable = false;
  858. if (sink.syncErrorThrown) {
  859. throw sink.syncErrorValue;
  860. }
  861. }
  862. }
  863. return sink;
  864. };
  865. Observable.prototype._trySubscribe = function (sink) {
  866. try {
  867. return this._subscribe(sink);
  868. }
  869. catch (err) {
  870. if (config.useDeprecatedSynchronousErrorHandling) {
  871. sink.syncErrorThrown = true;
  872. sink.syncErrorValue = err;
  873. }
  874. if (canReportError(sink)) {
  875. sink.error(err);
  876. }
  877. else {
  878. console.warn(err);
  879. }
  880. }
  881. };
  882. Observable.prototype.forEach = function (next, promiseCtor) {
  883. var _this = this;
  884. promiseCtor = getPromiseCtor(promiseCtor);
  885. return new promiseCtor(function (resolve, reject) {
  886. var subscription;
  887. subscription = _this.subscribe(function (value) {
  888. try {
  889. next(value);
  890. }
  891. catch (err) {
  892. reject(err);
  893. if (subscription) {
  894. subscription.unsubscribe();
  895. }
  896. }
  897. }, reject, resolve);
  898. });
  899. };
  900. Observable.prototype._subscribe = function (subscriber) {
  901. var source = this.source;
  902. return source && source.subscribe(subscriber);
  903. };
  904. Observable.prototype[observable] = function () {
  905. return this;
  906. };
  907. Observable.prototype.pipe = function () {
  908. var operations = [];
  909. for (var _i = 0; _i < arguments.length; _i++) {
  910. operations[_i] = arguments[_i];
  911. }
  912. if (operations.length === 0) {
  913. return this;
  914. }
  915. return pipeFromArray(operations)(this);
  916. };
  917. Observable.prototype.toPromise = function (promiseCtor) {
  918. var _this = this;
  919. promiseCtor = getPromiseCtor(promiseCtor);
  920. return new promiseCtor(function (resolve, reject) {
  921. var value;
  922. _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
  923. });
  924. };
  925. Observable.create = function (subscribe) {
  926. return new Observable(subscribe);
  927. };
  928. return Observable;
  929. }());
  930. function getPromiseCtor(promiseCtor) {
  931. if (!promiseCtor) {
  932. promiseCtor = config.Promise || Promise;
  933. }
  934. if (!promiseCtor) {
  935. throw new Error('no Promise impl found');
  936. }
  937. return promiseCtor;
  938. }
  939. function ObjectUnsubscribedErrorImpl() {
  940. Error.call(this);
  941. this.message = 'object unsubscribed';
  942. this.name = 'ObjectUnsubscribedError';
  943. return this;
  944. }
  945. ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
  946. var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
  947. var SubjectSubscription = (function (_super) {
  948. __extends(SubjectSubscription, _super);
  949. function SubjectSubscription(subject, subscriber) {
  950. var _this = _super.call(this) || this;
  951. _this.subject = subject;
  952. _this.subscriber = subscriber;
  953. _this.closed = false;
  954. return _this;
  955. }
  956. SubjectSubscription.prototype.unsubscribe = function () {
  957. if (this.closed) {
  958. return;
  959. }
  960. this.closed = true;
  961. var subject = this.subject;
  962. var observers = subject.observers;
  963. this.subject = null;
  964. if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
  965. return;
  966. }
  967. var subscriberIndex = observers.indexOf(this.subscriber);
  968. if (subscriberIndex !== -1) {
  969. observers.splice(subscriberIndex, 1);
  970. }
  971. };
  972. return SubjectSubscription;
  973. }(Subscription));
  974. var SubjectSubscriber = (function (_super) {
  975. __extends(SubjectSubscriber, _super);
  976. function SubjectSubscriber(destination) {
  977. var _this = _super.call(this, destination) || this;
  978. _this.destination = destination;
  979. return _this;
  980. }
  981. return SubjectSubscriber;
  982. }(Subscriber));
  983. var Subject = (function (_super) {
  984. __extends(Subject, _super);
  985. function Subject() {
  986. var _this = _super.call(this) || this;
  987. _this.observers = [];
  988. _this.closed = false;
  989. _this.isStopped = false;
  990. _this.hasError = false;
  991. _this.thrownError = null;
  992. return _this;
  993. }
  994. Subject.prototype[rxSubscriber] = function () {
  995. return new SubjectSubscriber(this);
  996. };
  997. Subject.prototype.lift = function (operator) {
  998. var subject = new AnonymousSubject(this, this);
  999. subject.operator = operator;
  1000. return subject;
  1001. };
  1002. Subject.prototype.next = function (value) {
  1003. if (this.closed) {
  1004. throw new ObjectUnsubscribedError();
  1005. }
  1006. if (!this.isStopped) {
  1007. var observers = this.observers;
  1008. var len = observers.length;
  1009. var copy = observers.slice();
  1010. for (var i = 0; i < len; i++) {
  1011. copy[i].next(value);
  1012. }
  1013. }
  1014. };
  1015. Subject.prototype.error = function (err) {
  1016. if (this.closed) {
  1017. throw new ObjectUnsubscribedError();
  1018. }
  1019. this.hasError = true;
  1020. this.thrownError = err;
  1021. this.isStopped = true;
  1022. var observers = this.observers;
  1023. var len = observers.length;
  1024. var copy = observers.slice();
  1025. for (var i = 0; i < len; i++) {
  1026. copy[i].error(err);
  1027. }
  1028. this.observers.length = 0;
  1029. };
  1030. Subject.prototype.complete = function () {
  1031. if (this.closed) {
  1032. throw new ObjectUnsubscribedError();
  1033. }
  1034. this.isStopped = true;
  1035. var observers = this.observers;
  1036. var len = observers.length;
  1037. var copy = observers.slice();
  1038. for (var i = 0; i < len; i++) {
  1039. copy[i].complete();
  1040. }
  1041. this.observers.length = 0;
  1042. };
  1043. Subject.prototype.unsubscribe = function () {
  1044. this.isStopped = true;
  1045. this.closed = true;
  1046. this.observers = null;
  1047. };
  1048. Subject.prototype._trySubscribe = function (subscriber) {
  1049. if (this.closed) {
  1050. throw new ObjectUnsubscribedError();
  1051. }
  1052. else {
  1053. return _super.prototype._trySubscribe.call(this, subscriber);
  1054. }
  1055. };
  1056. Subject.prototype._subscribe = function (subscriber) {
  1057. if (this.closed) {
  1058. throw new ObjectUnsubscribedError();
  1059. }
  1060. else if (this.hasError) {
  1061. subscriber.error(this.thrownError);
  1062. return Subscription.EMPTY;
  1063. }
  1064. else if (this.isStopped) {
  1065. subscriber.complete();
  1066. return Subscription.EMPTY;
  1067. }
  1068. else {
  1069. this.observers.push(subscriber);
  1070. return new SubjectSubscription(this, subscriber);
  1071. }
  1072. };
  1073. Subject.prototype.asObservable = function () {
  1074. var observable = new Observable();
  1075. observable.source = this;
  1076. return observable;
  1077. };
  1078. Subject.create = function (destination, source) {
  1079. return new AnonymousSubject(destination, source);
  1080. };
  1081. return Subject;
  1082. }(Observable));
  1083. var AnonymousSubject = (function (_super) {
  1084. __extends(AnonymousSubject, _super);
  1085. function AnonymousSubject(destination, source) {
  1086. var _this = _super.call(this) || this;
  1087. _this.destination = destination;
  1088. _this.source = source;
  1089. return _this;
  1090. }
  1091. AnonymousSubject.prototype.next = function (value) {
  1092. var destination = this.destination;
  1093. if (destination && destination.next) {
  1094. destination.next(value);
  1095. }
  1096. };
  1097. AnonymousSubject.prototype.error = function (err) {
  1098. var destination = this.destination;
  1099. if (destination && destination.error) {
  1100. this.destination.error(err);
  1101. }
  1102. };
  1103. AnonymousSubject.prototype.complete = function () {
  1104. var destination = this.destination;
  1105. if (destination && destination.complete) {
  1106. this.destination.complete();
  1107. }
  1108. };
  1109. AnonymousSubject.prototype._subscribe = function (subscriber) {
  1110. var source = this.source;
  1111. if (source) {
  1112. return this.source.subscribe(subscriber);
  1113. }
  1114. else {
  1115. return Subscription.EMPTY;
  1116. }
  1117. };
  1118. return AnonymousSubject;
  1119. }(Subject));
  1120. function refCount() {
  1121. return function refCountOperatorFunction(source) {
  1122. return source.lift(new RefCountOperator(source));
  1123. };
  1124. }
  1125. var RefCountOperator = (function () {
  1126. function RefCountOperator(connectable) {
  1127. this.connectable = connectable;
  1128. }
  1129. RefCountOperator.prototype.call = function (subscriber, source) {
  1130. var connectable = this.connectable;
  1131. connectable._refCount++;
  1132. var refCounter = new RefCountSubscriber(subscriber, connectable);
  1133. var subscription = source.subscribe(refCounter);
  1134. if (!refCounter.closed) {
  1135. refCounter.connection = connectable.connect();
  1136. }
  1137. return subscription;
  1138. };
  1139. return RefCountOperator;
  1140. }());
  1141. var RefCountSubscriber = (function (_super) {
  1142. __extends(RefCountSubscriber, _super);
  1143. function RefCountSubscriber(destination, connectable) {
  1144. var _this = _super.call(this, destination) || this;
  1145. _this.connectable = connectable;
  1146. return _this;
  1147. }
  1148. RefCountSubscriber.prototype._unsubscribe = function () {
  1149. var connectable = this.connectable;
  1150. if (!connectable) {
  1151. this.connection = null;
  1152. return;
  1153. }
  1154. this.connectable = null;
  1155. var refCount = connectable._refCount;
  1156. if (refCount <= 0) {
  1157. this.connection = null;
  1158. return;
  1159. }
  1160. connectable._refCount = refCount - 1;
  1161. if (refCount > 1) {
  1162. this.connection = null;
  1163. return;
  1164. }
  1165. var connection = this.connection;
  1166. var sharedConnection = connectable._connection;
  1167. this.connection = null;
  1168. if (sharedConnection && (!connection || sharedConnection === connection)) {
  1169. sharedConnection.unsubscribe();
  1170. }
  1171. };
  1172. return RefCountSubscriber;
  1173. }(Subscriber));
  1174. var ConnectableObservable = (function (_super) {
  1175. __extends(ConnectableObservable, _super);
  1176. function ConnectableObservable(source, subjectFactory) {
  1177. var _this = _super.call(this) || this;
  1178. _this.source = source;
  1179. _this.subjectFactory = subjectFactory;
  1180. _this._refCount = 0;
  1181. _this._isComplete = false;
  1182. return _this;
  1183. }
  1184. ConnectableObservable.prototype._subscribe = function (subscriber) {
  1185. return this.getSubject().subscribe(subscriber);
  1186. };
  1187. ConnectableObservable.prototype.getSubject = function () {
  1188. var subject = this._subject;
  1189. if (!subject || subject.isStopped) {
  1190. this._subject = this.subjectFactory();
  1191. }
  1192. return this._subject;
  1193. };
  1194. ConnectableObservable.prototype.connect = function () {
  1195. var connection = this._connection;
  1196. if (!connection) {
  1197. this._isComplete = false;
  1198. connection = this._connection = new Subscription();
  1199. connection.add(this.source
  1200. .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
  1201. if (connection.closed) {
  1202. this._connection = null;
  1203. connection = Subscription.EMPTY;
  1204. }
  1205. }
  1206. return connection;
  1207. };
  1208. ConnectableObservable.prototype.refCount = function () {
  1209. return refCount()(this);
  1210. };
  1211. return ConnectableObservable;
  1212. }(Observable));
  1213. var connectableProto = ConnectableObservable.prototype;
  1214. var connectableObservableDescriptor = {
  1215. operator: { value: null },
  1216. _refCount: { value: 0, writable: true },
  1217. _subject: { value: null, writable: true },
  1218. _connection: { value: null, writable: true },
  1219. _subscribe: { value: connectableProto._subscribe },
  1220. _isComplete: { value: connectableProto._isComplete, writable: true },
  1221. getSubject: { value: connectableProto.getSubject },
  1222. connect: { value: connectableProto.connect },
  1223. refCount: { value: connectableProto.refCount }
  1224. };
  1225. var ConnectableSubscriber = (function (_super) {
  1226. __extends(ConnectableSubscriber, _super);
  1227. function ConnectableSubscriber(destination, connectable) {
  1228. var _this = _super.call(this, destination) || this;
  1229. _this.connectable = connectable;
  1230. return _this;
  1231. }
  1232. ConnectableSubscriber.prototype._error = function (err) {
  1233. this._unsubscribe();
  1234. _super.prototype._error.call(this, err);
  1235. };
  1236. ConnectableSubscriber.prototype._complete = function () {
  1237. this.connectable._isComplete = true;
  1238. this._unsubscribe();
  1239. _super.prototype._complete.call(this);
  1240. };
  1241. ConnectableSubscriber.prototype._unsubscribe = function () {
  1242. var connectable = this.connectable;
  1243. if (connectable) {
  1244. this.connectable = null;
  1245. var connection = connectable._connection;
  1246. connectable._refCount = 0;
  1247. connectable._subject = null;
  1248. connectable._connection = null;
  1249. if (connection) {
  1250. connection.unsubscribe();
  1251. }
  1252. }
  1253. };
  1254. return ConnectableSubscriber;
  1255. }(SubjectSubscriber));
  1256. var RefCountSubscriber$1 = (function (_super) {
  1257. __extends(RefCountSubscriber, _super);
  1258. function RefCountSubscriber(destination, connectable) {
  1259. var _this = _super.call(this, destination) || this;
  1260. _this.connectable = connectable;
  1261. return _this;
  1262. }
  1263. RefCountSubscriber.prototype._unsubscribe = function () {
  1264. var connectable = this.connectable;
  1265. if (!connectable) {
  1266. this.connection = null;
  1267. return;
  1268. }
  1269. this.connectable = null;
  1270. var refCount$$1 = connectable._refCount;
  1271. if (refCount$$1 <= 0) {
  1272. this.connection = null;
  1273. return;
  1274. }
  1275. connectable._refCount = refCount$$1 - 1;
  1276. if (refCount$$1 > 1) {
  1277. this.connection = null;
  1278. return;
  1279. }
  1280. var connection = this.connection;
  1281. var sharedConnection = connectable._connection;
  1282. this.connection = null;
  1283. if (sharedConnection && (!connection || sharedConnection === connection)) {
  1284. sharedConnection.unsubscribe();
  1285. }
  1286. };
  1287. return RefCountSubscriber;
  1288. }(Subscriber));
  1289. function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
  1290. return function (source) {
  1291. return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
  1292. };
  1293. }
  1294. var GroupByOperator = (function () {
  1295. function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
  1296. this.keySelector = keySelector;
  1297. this.elementSelector = elementSelector;
  1298. this.durationSelector = durationSelector;
  1299. this.subjectSelector = subjectSelector;
  1300. }
  1301. GroupByOperator.prototype.call = function (subscriber, source) {
  1302. return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
  1303. };
  1304. return GroupByOperator;
  1305. }());
  1306. var GroupBySubscriber = (function (_super) {
  1307. __extends(GroupBySubscriber, _super);
  1308. function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
  1309. var _this = _super.call(this, destination) || this;
  1310. _this.keySelector = keySelector;
  1311. _this.elementSelector = elementSelector;
  1312. _this.durationSelector = durationSelector;
  1313. _this.subjectSelector = subjectSelector;
  1314. _this.groups = null;
  1315. _this.attemptedToUnsubscribe = false;
  1316. _this.count = 0;
  1317. return _this;
  1318. }
  1319. GroupBySubscriber.prototype._next = function (value) {
  1320. var key;
  1321. try {
  1322. key = this.keySelector(value);
  1323. }
  1324. catch (err) {
  1325. this.error(err);
  1326. return;
  1327. }
  1328. this._group(value, key);
  1329. };
  1330. GroupBySubscriber.prototype._group = function (value, key) {
  1331. var groups = this.groups;
  1332. if (!groups) {
  1333. groups = this.groups = new Map();
  1334. }
  1335. var group = groups.get(key);
  1336. var element;
  1337. if (this.elementSelector) {
  1338. try {
  1339. element = this.elementSelector(value);
  1340. }
  1341. catch (err) {
  1342. this.error(err);
  1343. }
  1344. }
  1345. else {
  1346. element = value;
  1347. }
  1348. if (!group) {
  1349. group = (this.subjectSelector ? this.subjectSelector() : new Subject());
  1350. groups.set(key, group);
  1351. var groupedObservable = new GroupedObservable(key, group, this);
  1352. this.destination.next(groupedObservable);
  1353. if (this.durationSelector) {
  1354. var duration = void 0;
  1355. try {
  1356. duration = this.durationSelector(new GroupedObservable(key, group));
  1357. }
  1358. catch (err) {
  1359. this.error(err);
  1360. return;
  1361. }
  1362. this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
  1363. }
  1364. }
  1365. if (!group.closed) {
  1366. group.next(element);
  1367. }
  1368. };
  1369. GroupBySubscriber.prototype._error = function (err) {
  1370. var groups = this.groups;
  1371. if (groups) {
  1372. groups.forEach(function (group, key) {
  1373. group.error(err);
  1374. });
  1375. groups.clear();
  1376. }
  1377. this.destination.error(err);
  1378. };
  1379. GroupBySubscriber.prototype._complete = function () {
  1380. var groups = this.groups;
  1381. if (groups) {
  1382. groups.forEach(function (group, key) {
  1383. group.complete();
  1384. });
  1385. groups.clear();
  1386. }
  1387. this.destination.complete();
  1388. };
  1389. GroupBySubscriber.prototype.removeGroup = function (key) {
  1390. this.groups.delete(key);
  1391. };
  1392. GroupBySubscriber.prototype.unsubscribe = function () {
  1393. if (!this.closed) {
  1394. this.attemptedToUnsubscribe = true;
  1395. if (this.count === 0) {
  1396. _super.prototype.unsubscribe.call(this);
  1397. }
  1398. }
  1399. };
  1400. return GroupBySubscriber;
  1401. }(Subscriber));
  1402. var GroupDurationSubscriber = (function (_super) {
  1403. __extends(GroupDurationSubscriber, _super);
  1404. function GroupDurationSubscriber(key, group, parent) {
  1405. var _this = _super.call(this, group) || this;
  1406. _this.key = key;
  1407. _this.group = group;
  1408. _this.parent = parent;
  1409. return _this;
  1410. }
  1411. GroupDurationSubscriber.prototype._next = function (value) {
  1412. this.complete();
  1413. };
  1414. GroupDurationSubscriber.prototype._unsubscribe = function () {
  1415. var _a = this, parent = _a.parent, key = _a.key;
  1416. this.key = this.parent = null;
  1417. if (parent) {
  1418. parent.removeGroup(key);
  1419. }
  1420. };
  1421. return GroupDurationSubscriber;
  1422. }(Subscriber));
  1423. var GroupedObservable = (function (_super) {
  1424. __extends(GroupedObservable, _super);
  1425. function GroupedObservable(key, groupSubject, refCountSubscription) {
  1426. var _this = _super.call(this) || this;
  1427. _this.key = key;
  1428. _this.groupSubject = groupSubject;
  1429. _this.refCountSubscription = refCountSubscription;
  1430. return _this;
  1431. }
  1432. GroupedObservable.prototype._subscribe = function (subscriber) {
  1433. var subscription = new Subscription();
  1434. var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
  1435. if (refCountSubscription && !refCountSubscription.closed) {
  1436. subscription.add(new InnerRefCountSubscription(refCountSubscription));
  1437. }
  1438. subscription.add(groupSubject.subscribe(subscriber));
  1439. return subscription;
  1440. };
  1441. return GroupedObservable;
  1442. }(Observable));
  1443. var InnerRefCountSubscription = (function (_super) {
  1444. __extends(InnerRefCountSubscription, _super);
  1445. function InnerRefCountSubscription(parent) {
  1446. var _this = _super.call(this) || this;
  1447. _this.parent = parent;
  1448. parent.count++;
  1449. return _this;
  1450. }
  1451. InnerRefCountSubscription.prototype.unsubscribe = function () {
  1452. var parent = this.parent;
  1453. if (!parent.closed && !this.closed) {
  1454. _super.prototype.unsubscribe.call(this);
  1455. parent.count -= 1;
  1456. if (parent.count === 0 && parent.attemptedToUnsubscribe) {
  1457. parent.unsubscribe();
  1458. }
  1459. }
  1460. };
  1461. return InnerRefCountSubscription;
  1462. }(Subscription));
  1463. var BehaviorSubject = (function (_super) {
  1464. __extends(BehaviorSubject, _super);
  1465. function BehaviorSubject(_value) {
  1466. var _this = _super.call(this) || this;
  1467. _this._value = _value;
  1468. return _this;
  1469. }
  1470. Object.defineProperty(BehaviorSubject.prototype, "value", {
  1471. get: function () {
  1472. return this.getValue();
  1473. },
  1474. enumerable: true,
  1475. configurable: true
  1476. });
  1477. BehaviorSubject.prototype._subscribe = function (subscriber) {
  1478. var subscription = _super.prototype._subscribe.call(this, subscriber);
  1479. if (subscription && !subscription.closed) {
  1480. subscriber.next(this._value);
  1481. }
  1482. return subscription;
  1483. };
  1484. BehaviorSubject.prototype.getValue = function () {
  1485. if (this.hasError) {
  1486. throw this.thrownError;
  1487. }
  1488. else if (this.closed) {
  1489. throw new ObjectUnsubscribedError();
  1490. }
  1491. else {
  1492. return this._value;
  1493. }
  1494. };
  1495. BehaviorSubject.prototype.next = function (value) {
  1496. _super.prototype.next.call(this, this._value = value);
  1497. };
  1498. return BehaviorSubject;
  1499. }(Subject));
  1500. var Action = (function (_super) {
  1501. __extends(Action, _super);
  1502. function Action(scheduler, work) {
  1503. return _super.call(this) || this;
  1504. }
  1505. Action.prototype.schedule = function (state, delay) {
  1506. if (delay === void 0) { delay = 0; }
  1507. return this;
  1508. };
  1509. return Action;
  1510. }(Subscription));
  1511. var AsyncAction = (function (_super) {
  1512. __extends(AsyncAction, _super);
  1513. function AsyncAction(scheduler, work) {
  1514. var _this = _super.call(this, scheduler, work) || this;
  1515. _this.scheduler = scheduler;
  1516. _this.work = work;
  1517. _this.pending = false;
  1518. return _this;
  1519. }
  1520. AsyncAction.prototype.schedule = function (state, delay) {
  1521. if (delay === void 0) { delay = 0; }
  1522. if (this.closed) {
  1523. return this;
  1524. }
  1525. this.state = state;
  1526. var id = this.id;
  1527. var scheduler = this.scheduler;
  1528. if (id != null) {
  1529. this.id = this.recycleAsyncId(scheduler, id, delay);
  1530. }
  1531. this.pending = true;
  1532. this.delay = delay;
  1533. this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
  1534. return this;
  1535. };
  1536. AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  1537. if (delay === void 0) { delay = 0; }
  1538. return setInterval(scheduler.flush.bind(scheduler, this), delay);
  1539. };
  1540. AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  1541. if (delay === void 0) { delay = 0; }
  1542. if (delay !== null && this.delay === delay && this.pending === false) {
  1543. return id;
  1544. }
  1545. clearInterval(id);
  1546. return undefined;
  1547. };
  1548. AsyncAction.prototype.execute = function (state, delay) {
  1549. if (this.closed) {
  1550. return new Error('executing a cancelled action');
  1551. }
  1552. this.pending = false;
  1553. var error = this._execute(state, delay);
  1554. if (error) {
  1555. return error;
  1556. }
  1557. else if (this.pending === false && this.id != null) {
  1558. this.id = this.recycleAsyncId(this.scheduler, this.id, null);
  1559. }
  1560. };
  1561. AsyncAction.prototype._execute = function (state, delay) {
  1562. var errored = false;
  1563. var errorValue = undefined;
  1564. try {
  1565. this.work(state);
  1566. }
  1567. catch (e) {
  1568. errored = true;
  1569. errorValue = !!e && e || new Error(e);
  1570. }
  1571. if (errored) {
  1572. this.unsubscribe();
  1573. return errorValue;
  1574. }
  1575. };
  1576. AsyncAction.prototype._unsubscribe = function () {
  1577. var id = this.id;
  1578. var scheduler = this.scheduler;
  1579. var actions = scheduler.actions;
  1580. var index = actions.indexOf(this);
  1581. this.work = null;
  1582. this.state = null;
  1583. this.pending = false;
  1584. this.scheduler = null;
  1585. if (index !== -1) {
  1586. actions.splice(index, 1);
  1587. }
  1588. if (id != null) {
  1589. this.id = this.recycleAsyncId(scheduler, id, null);
  1590. }
  1591. this.delay = null;
  1592. };
  1593. return AsyncAction;
  1594. }(Action));
  1595. var QueueAction = (function (_super) {
  1596. __extends(QueueAction, _super);
  1597. function QueueAction(scheduler, work) {
  1598. var _this = _super.call(this, scheduler, work) || this;
  1599. _this.scheduler = scheduler;
  1600. _this.work = work;
  1601. return _this;
  1602. }
  1603. QueueAction.prototype.schedule = function (state, delay) {
  1604. if (delay === void 0) { delay = 0; }
  1605. if (delay > 0) {
  1606. return _super.prototype.schedule.call(this, state, delay);
  1607. }
  1608. this.delay = delay;
  1609. this.state = state;
  1610. this.scheduler.flush(this);
  1611. return this;
  1612. };
  1613. QueueAction.prototype.execute = function (state, delay) {
  1614. return (delay > 0 || this.closed) ?
  1615. _super.prototype.execute.call(this, state, delay) :
  1616. this._execute(state, delay);
  1617. };
  1618. QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  1619. if (delay === void 0) { delay = 0; }
  1620. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  1621. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  1622. }
  1623. return scheduler.flush(this);
  1624. };
  1625. return QueueAction;
  1626. }(AsyncAction));
  1627. var Scheduler = (function () {
  1628. function Scheduler(SchedulerAction, now) {
  1629. if (now === void 0) { now = Scheduler.now; }
  1630. this.SchedulerAction = SchedulerAction;
  1631. this.now = now;
  1632. }
  1633. Scheduler.prototype.schedule = function (work, delay, state) {
  1634. if (delay === void 0) { delay = 0; }
  1635. return new this.SchedulerAction(this, work).schedule(state, delay);
  1636. };
  1637. Scheduler.now = function () { return Date.now(); };
  1638. return Scheduler;
  1639. }());
  1640. var AsyncScheduler = (function (_super) {
  1641. __extends(AsyncScheduler, _super);
  1642. function AsyncScheduler(SchedulerAction, now) {
  1643. if (now === void 0) { now = Scheduler.now; }
  1644. var _this = _super.call(this, SchedulerAction, function () {
  1645. if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
  1646. return AsyncScheduler.delegate.now();
  1647. }
  1648. else {
  1649. return now();
  1650. }
  1651. }) || this;
  1652. _this.actions = [];
  1653. _this.active = false;
  1654. _this.scheduled = undefined;
  1655. return _this;
  1656. }
  1657. AsyncScheduler.prototype.schedule = function (work, delay, state) {
  1658. if (delay === void 0) { delay = 0; }
  1659. if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
  1660. return AsyncScheduler.delegate.schedule(work, delay, state);
  1661. }
  1662. else {
  1663. return _super.prototype.schedule.call(this, work, delay, state);
  1664. }
  1665. };
  1666. AsyncScheduler.prototype.flush = function (action) {
  1667. var actions = this.actions;
  1668. if (this.active) {
  1669. actions.push(action);
  1670. return;
  1671. }
  1672. var error;
  1673. this.active = true;
  1674. do {
  1675. if (error = action.execute(action.state, action.delay)) {
  1676. break;
  1677. }
  1678. } while (action = actions.shift());
  1679. this.active = false;
  1680. if (error) {
  1681. while (action = actions.shift()) {
  1682. action.unsubscribe();
  1683. }
  1684. throw error;
  1685. }
  1686. };
  1687. return AsyncScheduler;
  1688. }(Scheduler));
  1689. var QueueScheduler = (function (_super) {
  1690. __extends(QueueScheduler, _super);
  1691. function QueueScheduler() {
  1692. return _super !== null && _super.apply(this, arguments) || this;
  1693. }
  1694. return QueueScheduler;
  1695. }(AsyncScheduler));
  1696. var queue = new QueueScheduler(QueueAction);
  1697. var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
  1698. function empty$1(scheduler) {
  1699. return scheduler ? emptyScheduled(scheduler) : EMPTY;
  1700. }
  1701. function emptyScheduled(scheduler) {
  1702. return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
  1703. }
  1704. function isScheduler(value) {
  1705. return value && typeof value.schedule === 'function';
  1706. }
  1707. var subscribeToArray = function (array) { return function (subscriber) {
  1708. for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
  1709. subscriber.next(array[i]);
  1710. }
  1711. subscriber.complete();
  1712. }; };
  1713. function scheduleArray(input, scheduler) {
  1714. return new Observable(function (subscriber) {
  1715. var sub = new Subscription();
  1716. var i = 0;
  1717. sub.add(scheduler.schedule(function () {
  1718. if (i === input.length) {
  1719. subscriber.complete();
  1720. return;
  1721. }
  1722. subscriber.next(input[i++]);
  1723. if (!subscriber.closed) {
  1724. sub.add(this.schedule());
  1725. }
  1726. }));
  1727. return sub;
  1728. });
  1729. }
  1730. function fromArray(input, scheduler) {
  1731. if (!scheduler) {
  1732. return new Observable(subscribeToArray(input));
  1733. }
  1734. else {
  1735. return scheduleArray(input, scheduler);
  1736. }
  1737. }
  1738. function of() {
  1739. var args = [];
  1740. for (var _i = 0; _i < arguments.length; _i++) {
  1741. args[_i] = arguments[_i];
  1742. }
  1743. var scheduler = args[args.length - 1];
  1744. if (isScheduler(scheduler)) {
  1745. args.pop();
  1746. return scheduleArray(args, scheduler);
  1747. }
  1748. else {
  1749. return fromArray(args);
  1750. }
  1751. }
  1752. function throwError(error, scheduler) {
  1753. if (!scheduler) {
  1754. return new Observable(function (subscriber) { return subscriber.error(error); });
  1755. }
  1756. else {
  1757. return new Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
  1758. }
  1759. }
  1760. function dispatch(_a) {
  1761. var error = _a.error, subscriber = _a.subscriber;
  1762. subscriber.error(error);
  1763. }
  1764. (function (NotificationKind) {
  1765. NotificationKind["NEXT"] = "N";
  1766. NotificationKind["ERROR"] = "E";
  1767. NotificationKind["COMPLETE"] = "C";
  1768. })(exports.NotificationKind || (exports.NotificationKind = {}));
  1769. var Notification = (function () {
  1770. function Notification(kind, value, error) {
  1771. this.kind = kind;
  1772. this.value = value;
  1773. this.error = error;
  1774. this.hasValue = kind === 'N';
  1775. }
  1776. Notification.prototype.observe = function (observer) {
  1777. switch (this.kind) {
  1778. case 'N':
  1779. return observer.next && observer.next(this.value);
  1780. case 'E':
  1781. return observer.error && observer.error(this.error);
  1782. case 'C':
  1783. return observer.complete && observer.complete();
  1784. }
  1785. };
  1786. Notification.prototype.do = function (next, error, complete) {
  1787. var kind = this.kind;
  1788. switch (kind) {
  1789. case 'N':
  1790. return next && next(this.value);
  1791. case 'E':
  1792. return error && error(this.error);
  1793. case 'C':
  1794. return complete && complete();
  1795. }
  1796. };
  1797. Notification.prototype.accept = function (nextOrObserver, error, complete) {
  1798. if (nextOrObserver && typeof nextOrObserver.next === 'function') {
  1799. return this.observe(nextOrObserver);
  1800. }
  1801. else {
  1802. return this.do(nextOrObserver, error, complete);
  1803. }
  1804. };
  1805. Notification.prototype.toObservable = function () {
  1806. var kind = this.kind;
  1807. switch (kind) {
  1808. case 'N':
  1809. return of(this.value);
  1810. case 'E':
  1811. return throwError(this.error);
  1812. case 'C':
  1813. return empty$1();
  1814. }
  1815. throw new Error('unexpected notification kind value');
  1816. };
  1817. Notification.createNext = function (value) {
  1818. if (typeof value !== 'undefined') {
  1819. return new Notification('N', value);
  1820. }
  1821. return Notification.undefinedValueNotification;
  1822. };
  1823. Notification.createError = function (err) {
  1824. return new Notification('E', undefined, err);
  1825. };
  1826. Notification.createComplete = function () {
  1827. return Notification.completeNotification;
  1828. };
  1829. Notification.completeNotification = new Notification('C');
  1830. Notification.undefinedValueNotification = new Notification('N', undefined);
  1831. return Notification;
  1832. }());
  1833. function observeOn(scheduler, delay) {
  1834. if (delay === void 0) { delay = 0; }
  1835. return function observeOnOperatorFunction(source) {
  1836. return source.lift(new ObserveOnOperator(scheduler, delay));
  1837. };
  1838. }
  1839. var ObserveOnOperator = (function () {
  1840. function ObserveOnOperator(scheduler, delay) {
  1841. if (delay === void 0) { delay = 0; }
  1842. this.scheduler = scheduler;
  1843. this.delay = delay;
  1844. }
  1845. ObserveOnOperator.prototype.call = function (subscriber, source) {
  1846. return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
  1847. };
  1848. return ObserveOnOperator;
  1849. }());
  1850. var ObserveOnSubscriber = (function (_super) {
  1851. __extends(ObserveOnSubscriber, _super);
  1852. function ObserveOnSubscriber(destination, scheduler, delay) {
  1853. if (delay === void 0) { delay = 0; }
  1854. var _this = _super.call(this, destination) || this;
  1855. _this.scheduler = scheduler;
  1856. _this.delay = delay;
  1857. return _this;
  1858. }
  1859. ObserveOnSubscriber.dispatch = function (arg) {
  1860. var notification = arg.notification, destination = arg.destination;
  1861. notification.observe(destination);
  1862. this.unsubscribe();
  1863. };
  1864. ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
  1865. var destination = this.destination;
  1866. destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
  1867. };
  1868. ObserveOnSubscriber.prototype._next = function (value) {
  1869. this.scheduleMessage(Notification.createNext(value));
  1870. };
  1871. ObserveOnSubscriber.prototype._error = function (err) {
  1872. this.scheduleMessage(Notification.createError(err));
  1873. this.unsubscribe();
  1874. };
  1875. ObserveOnSubscriber.prototype._complete = function () {
  1876. this.scheduleMessage(Notification.createComplete());
  1877. this.unsubscribe();
  1878. };
  1879. return ObserveOnSubscriber;
  1880. }(Subscriber));
  1881. var ObserveOnMessage = (function () {
  1882. function ObserveOnMessage(notification, destination) {
  1883. this.notification = notification;
  1884. this.destination = destination;
  1885. }
  1886. return ObserveOnMessage;
  1887. }());
  1888. var ReplaySubject = (function (_super) {
  1889. __extends(ReplaySubject, _super);
  1890. function ReplaySubject(bufferSize, windowTime, scheduler) {
  1891. if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
  1892. if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
  1893. var _this = _super.call(this) || this;
  1894. _this.scheduler = scheduler;
  1895. _this._events = [];
  1896. _this._infiniteTimeWindow = false;
  1897. _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
  1898. _this._windowTime = windowTime < 1 ? 1 : windowTime;
  1899. if (windowTime === Number.POSITIVE_INFINITY) {
  1900. _this._infiniteTimeWindow = true;
  1901. _this.next = _this.nextInfiniteTimeWindow;
  1902. }
  1903. else {
  1904. _this.next = _this.nextTimeWindow;
  1905. }
  1906. return _this;
  1907. }
  1908. ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
  1909. var _events = this._events;
  1910. _events.push(value);
  1911. if (_events.length > this._bufferSize) {
  1912. _events.shift();
  1913. }
  1914. _super.prototype.next.call(this, value);
  1915. };
  1916. ReplaySubject.prototype.nextTimeWindow = function (value) {
  1917. this._events.push(new ReplayEvent(this._getNow(), value));
  1918. this._trimBufferThenGetEvents();
  1919. _super.prototype.next.call(this, value);
  1920. };
  1921. ReplaySubject.prototype._subscribe = function (subscriber) {
  1922. var _infiniteTimeWindow = this._infiniteTimeWindow;
  1923. var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
  1924. var scheduler = this.scheduler;
  1925. var len = _events.length;
  1926. var subscription;
  1927. if (this.closed) {
  1928. throw new ObjectUnsubscribedError();
  1929. }
  1930. else if (this.isStopped || this.hasError) {
  1931. subscription = Subscription.EMPTY;
  1932. }
  1933. else {
  1934. this.observers.push(subscriber);
  1935. subscription = new SubjectSubscription(this, subscriber);
  1936. }
  1937. if (scheduler) {
  1938. subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
  1939. }
  1940. if (_infiniteTimeWindow) {
  1941. for (var i = 0; i < len && !subscriber.closed; i++) {
  1942. subscriber.next(_events[i]);
  1943. }
  1944. }
  1945. else {
  1946. for (var i = 0; i < len && !subscriber.closed; i++) {
  1947. subscriber.next(_events[i].value);
  1948. }
  1949. }
  1950. if (this.hasError) {
  1951. subscriber.error(this.thrownError);
  1952. }
  1953. else if (this.isStopped) {
  1954. subscriber.complete();
  1955. }
  1956. return subscription;
  1957. };
  1958. ReplaySubject.prototype._getNow = function () {
  1959. return (this.scheduler || queue).now();
  1960. };
  1961. ReplaySubject.prototype._trimBufferThenGetEvents = function () {
  1962. var now = this._getNow();
  1963. var _bufferSize = this._bufferSize;
  1964. var _windowTime = this._windowTime;
  1965. var _events = this._events;
  1966. var eventsCount = _events.length;
  1967. var spliceCount = 0;
  1968. while (spliceCount < eventsCount) {
  1969. if ((now - _events[spliceCount].time) < _windowTime) {
  1970. break;
  1971. }
  1972. spliceCount++;
  1973. }
  1974. if (eventsCount > _bufferSize) {
  1975. spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
  1976. }
  1977. if (spliceCount > 0) {
  1978. _events.splice(0, spliceCount);
  1979. }
  1980. return _events;
  1981. };
  1982. return ReplaySubject;
  1983. }(Subject));
  1984. var ReplayEvent = (function () {
  1985. function ReplayEvent(time, value) {
  1986. this.time = time;
  1987. this.value = value;
  1988. }
  1989. return ReplayEvent;
  1990. }());
  1991. var AsyncSubject = (function (_super) {
  1992. __extends(AsyncSubject, _super);
  1993. function AsyncSubject() {
  1994. var _this = _super !== null && _super.apply(this, arguments) || this;
  1995. _this.value = null;
  1996. _this.hasNext = false;
  1997. _this.hasCompleted = false;
  1998. return _this;
  1999. }
  2000. AsyncSubject.prototype._subscribe = function (subscriber) {
  2001. if (this.hasError) {
  2002. subscriber.error(this.thrownError);
  2003. return Subscription.EMPTY;
  2004. }
  2005. else if (this.hasCompleted && this.hasNext) {
  2006. subscriber.next(this.value);
  2007. subscriber.complete();
  2008. return Subscription.EMPTY;
  2009. }
  2010. return _super.prototype._subscribe.call(this, subscriber);
  2011. };
  2012. AsyncSubject.prototype.next = function (value) {
  2013. if (!this.hasCompleted) {
  2014. this.value = value;
  2015. this.hasNext = true;
  2016. }
  2017. };
  2018. AsyncSubject.prototype.error = function (error) {
  2019. if (!this.hasCompleted) {
  2020. _super.prototype.error.call(this, error);
  2021. }
  2022. };
  2023. AsyncSubject.prototype.complete = function () {
  2024. this.hasCompleted = true;
  2025. if (this.hasNext) {
  2026. _super.prototype.next.call(this, this.value);
  2027. }
  2028. _super.prototype.complete.call(this);
  2029. };
  2030. return AsyncSubject;
  2031. }(Subject));
  2032. var nextHandle = 1;
  2033. var tasksByHandle = {};
  2034. function runIfPresent(handle) {
  2035. var cb = tasksByHandle[handle];
  2036. if (cb) {
  2037. cb();
  2038. }
  2039. }
  2040. var Immediate = {
  2041. setImmediate: function (cb) {
  2042. var handle = nextHandle++;
  2043. tasksByHandle[handle] = cb;
  2044. Promise.resolve().then(function () { return runIfPresent(handle); });
  2045. return handle;
  2046. },
  2047. clearImmediate: function (handle) {
  2048. delete tasksByHandle[handle];
  2049. },
  2050. };
  2051. var AsapAction = (function (_super) {
  2052. __extends(AsapAction, _super);
  2053. function AsapAction(scheduler, work) {
  2054. var _this = _super.call(this, scheduler, work) || this;
  2055. _this.scheduler = scheduler;
  2056. _this.work = work;
  2057. return _this;
  2058. }
  2059. AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  2060. if (delay === void 0) { delay = 0; }
  2061. if (delay !== null && delay > 0) {
  2062. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  2063. }
  2064. scheduler.actions.push(this);
  2065. return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
  2066. };
  2067. AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  2068. if (delay === void 0) { delay = 0; }
  2069. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  2070. return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
  2071. }
  2072. if (scheduler.actions.length === 0) {
  2073. Immediate.clearImmediate(id);
  2074. scheduler.scheduled = undefined;
  2075. }
  2076. return undefined;
  2077. };
  2078. return AsapAction;
  2079. }(AsyncAction));
  2080. var AsapScheduler = (function (_super) {
  2081. __extends(AsapScheduler, _super);
  2082. function AsapScheduler() {
  2083. return _super !== null && _super.apply(this, arguments) || this;
  2084. }
  2085. AsapScheduler.prototype.flush = function (action) {
  2086. this.active = true;
  2087. this.scheduled = undefined;
  2088. var actions = this.actions;
  2089. var error;
  2090. var index = -1;
  2091. var count = actions.length;
  2092. action = action || actions.shift();
  2093. do {
  2094. if (error = action.execute(action.state, action.delay)) {
  2095. break;
  2096. }
  2097. } while (++index < count && (action = actions.shift()));
  2098. this.active = false;
  2099. if (error) {
  2100. while (++index < count && (action = actions.shift())) {
  2101. action.unsubscribe();
  2102. }
  2103. throw error;
  2104. }
  2105. };
  2106. return AsapScheduler;
  2107. }(AsyncScheduler));
  2108. var asap = new AsapScheduler(AsapAction);
  2109. var async = new AsyncScheduler(AsyncAction);
  2110. var AnimationFrameAction = (function (_super) {
  2111. __extends(AnimationFrameAction, _super);
  2112. function AnimationFrameAction(scheduler, work) {
  2113. var _this = _super.call(this, scheduler, work) || this;
  2114. _this.scheduler = scheduler;
  2115. _this.work = work;
  2116. return _this;
  2117. }
  2118. AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  2119. if (delay === void 0) { delay = 0; }
  2120. if (delay !== null && delay > 0) {
  2121. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  2122. }
  2123. scheduler.actions.push(this);
  2124. return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
  2125. };
  2126. AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  2127. if (delay === void 0) { delay = 0; }
  2128. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  2129. return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
  2130. }
  2131. if (scheduler.actions.length === 0) {
  2132. cancelAnimationFrame(id);
  2133. scheduler.scheduled = undefined;
  2134. }
  2135. return undefined;
  2136. };
  2137. return AnimationFrameAction;
  2138. }(AsyncAction));
  2139. var AnimationFrameScheduler = (function (_super) {
  2140. __extends(AnimationFrameScheduler, _super);
  2141. function AnimationFrameScheduler() {
  2142. return _super !== null && _super.apply(this, arguments) || this;
  2143. }
  2144. AnimationFrameScheduler.prototype.flush = function (action) {
  2145. this.active = true;
  2146. this.scheduled = undefined;
  2147. var actions = this.actions;
  2148. var error;
  2149. var index = -1;
  2150. var count = actions.length;
  2151. action = action || actions.shift();
  2152. do {
  2153. if (error = action.execute(action.state, action.delay)) {
  2154. break;
  2155. }
  2156. } while (++index < count && (action = actions.shift()));
  2157. this.active = false;
  2158. if (error) {
  2159. while (++index < count && (action = actions.shift())) {
  2160. action.unsubscribe();
  2161. }
  2162. throw error;
  2163. }
  2164. };
  2165. return AnimationFrameScheduler;
  2166. }(AsyncScheduler));
  2167. var animationFrame = new AnimationFrameScheduler(AnimationFrameAction);
  2168. var VirtualTimeScheduler = (function (_super) {
  2169. __extends(VirtualTimeScheduler, _super);
  2170. function VirtualTimeScheduler(SchedulerAction, maxFrames) {
  2171. if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
  2172. if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
  2173. var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
  2174. _this.maxFrames = maxFrames;
  2175. _this.frame = 0;
  2176. _this.index = -1;
  2177. return _this;
  2178. }
  2179. VirtualTimeScheduler.prototype.flush = function () {
  2180. var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
  2181. var error, action;
  2182. while ((action = actions[0]) && action.delay <= maxFrames) {
  2183. actions.shift();
  2184. this.frame = action.delay;
  2185. if (error = action.execute(action.state, action.delay)) {
  2186. break;
  2187. }
  2188. }
  2189. if (error) {
  2190. while (action = actions.shift()) {
  2191. action.unsubscribe();
  2192. }
  2193. throw error;
  2194. }
  2195. };
  2196. VirtualTimeScheduler.frameTimeFactor = 10;
  2197. return VirtualTimeScheduler;
  2198. }(AsyncScheduler));
  2199. var VirtualAction = (function (_super) {
  2200. __extends(VirtualAction, _super);
  2201. function VirtualAction(scheduler, work, index) {
  2202. if (index === void 0) { index = scheduler.index += 1; }
  2203. var _this = _super.call(this, scheduler, work) || this;
  2204. _this.scheduler = scheduler;
  2205. _this.work = work;
  2206. _this.index = index;
  2207. _this.active = true;
  2208. _this.index = scheduler.index = index;
  2209. return _this;
  2210. }
  2211. VirtualAction.prototype.schedule = function (state, delay) {
  2212. if (delay === void 0) { delay = 0; }
  2213. if (!this.id) {
  2214. return _super.prototype.schedule.call(this, state, delay);
  2215. }
  2216. this.active = false;
  2217. var action = new VirtualAction(this.scheduler, this.work);
  2218. this.add(action);
  2219. return action.schedule(state, delay);
  2220. };
  2221. VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  2222. if (delay === void 0) { delay = 0; }
  2223. this.delay = scheduler.frame + delay;
  2224. var actions = scheduler.actions;
  2225. actions.push(this);
  2226. actions.sort(VirtualAction.sortActions);
  2227. return true;
  2228. };
  2229. VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  2230. if (delay === void 0) { delay = 0; }
  2231. return undefined;
  2232. };
  2233. VirtualAction.prototype._execute = function (state, delay) {
  2234. if (this.active === true) {
  2235. return _super.prototype._execute.call(this, state, delay);
  2236. }
  2237. };
  2238. VirtualAction.sortActions = function (a, b) {
  2239. if (a.delay === b.delay) {
  2240. if (a.index === b.index) {
  2241. return 0;
  2242. }
  2243. else if (a.index > b.index) {
  2244. return 1;
  2245. }
  2246. else {
  2247. return -1;
  2248. }
  2249. }
  2250. else if (a.delay > b.delay) {
  2251. return 1;
  2252. }
  2253. else {
  2254. return -1;
  2255. }
  2256. };
  2257. return VirtualAction;
  2258. }(AsyncAction));
  2259. function identity(x) {
  2260. return x;
  2261. }
  2262. function isObservable(obj) {
  2263. return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
  2264. }
  2265. function ArgumentOutOfRangeErrorImpl() {
  2266. Error.call(this);
  2267. this.message = 'argument out of range';
  2268. this.name = 'ArgumentOutOfRangeError';
  2269. return this;
  2270. }
  2271. ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
  2272. var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
  2273. function EmptyErrorImpl() {
  2274. Error.call(this);
  2275. this.message = 'no elements in sequence';
  2276. this.name = 'EmptyError';
  2277. return this;
  2278. }
  2279. EmptyErrorImpl.prototype = Object.create(Error.prototype);
  2280. var EmptyError = EmptyErrorImpl;
  2281. function TimeoutErrorImpl() {
  2282. Error.call(this);
  2283. this.message = 'Timeout has occurred';
  2284. this.name = 'TimeoutError';
  2285. return this;
  2286. }
  2287. TimeoutErrorImpl.prototype = Object.create(Error.prototype);
  2288. var TimeoutError = TimeoutErrorImpl;
  2289. function map(project, thisArg) {
  2290. return function mapOperation(source) {
  2291. if (typeof project !== 'function') {
  2292. throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
  2293. }
  2294. return source.lift(new MapOperator(project, thisArg));
  2295. };
  2296. }
  2297. var MapOperator = (function () {
  2298. function MapOperator(project, thisArg) {
  2299. this.project = project;
  2300. this.thisArg = thisArg;
  2301. }
  2302. MapOperator.prototype.call = function (subscriber, source) {
  2303. return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
  2304. };
  2305. return MapOperator;
  2306. }());
  2307. var MapSubscriber = (function (_super) {
  2308. __extends(MapSubscriber, _super);
  2309. function MapSubscriber(destination, project, thisArg) {
  2310. var _this = _super.call(this, destination) || this;
  2311. _this.project = project;
  2312. _this.count = 0;
  2313. _this.thisArg = thisArg || _this;
  2314. return _this;
  2315. }
  2316. MapSubscriber.prototype._next = function (value) {
  2317. var result;
  2318. try {
  2319. result = this.project.call(this.thisArg, value, this.count++);
  2320. }
  2321. catch (err) {
  2322. this.destination.error(err);
  2323. return;
  2324. }
  2325. this.destination.next(result);
  2326. };
  2327. return MapSubscriber;
  2328. }(Subscriber));
  2329. function bindCallback(callbackFunc, resultSelector, scheduler) {
  2330. if (resultSelector) {
  2331. if (isScheduler(resultSelector)) {
  2332. scheduler = resultSelector;
  2333. }
  2334. else {
  2335. return function () {
  2336. var args = [];
  2337. for (var _i = 0; _i < arguments.length; _i++) {
  2338. args[_i] = arguments[_i];
  2339. }
  2340. return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  2341. };
  2342. }
  2343. }
  2344. return function () {
  2345. var args = [];
  2346. for (var _i = 0; _i < arguments.length; _i++) {
  2347. args[_i] = arguments[_i];
  2348. }
  2349. var context = this;
  2350. var subject;
  2351. var params = {
  2352. context: context,
  2353. subject: subject,
  2354. callbackFunc: callbackFunc,
  2355. scheduler: scheduler,
  2356. };
  2357. return new Observable(function (subscriber) {
  2358. if (!scheduler) {
  2359. if (!subject) {
  2360. subject = new AsyncSubject();
  2361. var handler = function () {
  2362. var innerArgs = [];
  2363. for (var _i = 0; _i < arguments.length; _i++) {
  2364. innerArgs[_i] = arguments[_i];
  2365. }
  2366. subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
  2367. subject.complete();
  2368. };
  2369. try {
  2370. callbackFunc.apply(context, args.concat([handler]));
  2371. }
  2372. catch (err) {
  2373. if (canReportError(subject)) {
  2374. subject.error(err);
  2375. }
  2376. else {
  2377. console.warn(err);
  2378. }
  2379. }
  2380. }
  2381. return subject.subscribe(subscriber);
  2382. }
  2383. else {
  2384. var state = {
  2385. args: args, subscriber: subscriber, params: params,
  2386. };
  2387. return scheduler.schedule(dispatch$1, 0, state);
  2388. }
  2389. });
  2390. };
  2391. }
  2392. function dispatch$1(state) {
  2393. var _this = this;
  2394. var args = state.args, subscriber = state.subscriber, params = state.params;
  2395. var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
  2396. var subject = params.subject;
  2397. if (!subject) {
  2398. subject = params.subject = new AsyncSubject();
  2399. var handler = function () {
  2400. var innerArgs = [];
  2401. for (var _i = 0; _i < arguments.length; _i++) {
  2402. innerArgs[_i] = arguments[_i];
  2403. }
  2404. var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
  2405. _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
  2406. };
  2407. try {
  2408. callbackFunc.apply(context, args.concat([handler]));
  2409. }
  2410. catch (err) {
  2411. subject.error(err);
  2412. }
  2413. }
  2414. this.add(subject.subscribe(subscriber));
  2415. }
  2416. function dispatchNext(state) {
  2417. var value = state.value, subject = state.subject;
  2418. subject.next(value);
  2419. subject.complete();
  2420. }
  2421. function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
  2422. if (resultSelector) {
  2423. if (isScheduler(resultSelector)) {
  2424. scheduler = resultSelector;
  2425. }
  2426. else {
  2427. return function () {
  2428. var args = [];
  2429. for (var _i = 0; _i < arguments.length; _i++) {
  2430. args[_i] = arguments[_i];
  2431. }
  2432. return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  2433. };
  2434. }
  2435. }
  2436. return function () {
  2437. var args = [];
  2438. for (var _i = 0; _i < arguments.length; _i++) {
  2439. args[_i] = arguments[_i];
  2440. }
  2441. var params = {
  2442. subject: undefined,
  2443. args: args,
  2444. callbackFunc: callbackFunc,
  2445. scheduler: scheduler,
  2446. context: this,
  2447. };
  2448. return new Observable(function (subscriber) {
  2449. var context = params.context;
  2450. var subject = params.subject;
  2451. if (!scheduler) {
  2452. if (!subject) {
  2453. subject = params.subject = new AsyncSubject();
  2454. var handler = function () {
  2455. var innerArgs = [];
  2456. for (var _i = 0; _i < arguments.length; _i++) {
  2457. innerArgs[_i] = arguments[_i];
  2458. }
  2459. var err = innerArgs.shift();
  2460. if (err) {
  2461. subject.error(err);
  2462. return;
  2463. }
  2464. subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
  2465. subject.complete();
  2466. };
  2467. try {
  2468. callbackFunc.apply(context, args.concat([handler]));
  2469. }
  2470. catch (err) {
  2471. if (canReportError(subject)) {
  2472. subject.error(err);
  2473. }
  2474. else {
  2475. console.warn(err);
  2476. }
  2477. }
  2478. }
  2479. return subject.subscribe(subscriber);
  2480. }
  2481. else {
  2482. return scheduler.schedule(dispatch$2, 0, { params: params, subscriber: subscriber, context: context });
  2483. }
  2484. });
  2485. };
  2486. }
  2487. function dispatch$2(state) {
  2488. var _this = this;
  2489. var params = state.params, subscriber = state.subscriber, context = state.context;
  2490. var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
  2491. var subject = params.subject;
  2492. if (!subject) {
  2493. subject = params.subject = new AsyncSubject();
  2494. var handler = function () {
  2495. var innerArgs = [];
  2496. for (var _i = 0; _i < arguments.length; _i++) {
  2497. innerArgs[_i] = arguments[_i];
  2498. }
  2499. var err = innerArgs.shift();
  2500. if (err) {
  2501. _this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
  2502. }
  2503. else {
  2504. var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
  2505. _this.add(scheduler.schedule(dispatchNext$1, 0, { value: value, subject: subject }));
  2506. }
  2507. };
  2508. try {
  2509. callbackFunc.apply(context, args.concat([handler]));
  2510. }
  2511. catch (err) {
  2512. this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
  2513. }
  2514. }
  2515. this.add(subject.subscribe(subscriber));
  2516. }
  2517. function dispatchNext$1(arg) {
  2518. var value = arg.value, subject = arg.subject;
  2519. subject.next(value);
  2520. subject.complete();
  2521. }
  2522. function dispatchError$1(arg) {
  2523. var err = arg.err, subject = arg.subject;
  2524. subject.error(err);
  2525. }
  2526. var OuterSubscriber = (function (_super) {
  2527. __extends(OuterSubscriber, _super);
  2528. function OuterSubscriber() {
  2529. return _super !== null && _super.apply(this, arguments) || this;
  2530. }
  2531. OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  2532. this.destination.next(innerValue);
  2533. };
  2534. OuterSubscriber.prototype.notifyError = function (error, innerSub) {
  2535. this.destination.error(error);
  2536. };
  2537. OuterSubscriber.prototype.notifyComplete = function (innerSub) {
  2538. this.destination.complete();
  2539. };
  2540. return OuterSubscriber;
  2541. }(Subscriber));
  2542. var InnerSubscriber = (function (_super) {
  2543. __extends(InnerSubscriber, _super);
  2544. function InnerSubscriber(parent, outerValue, outerIndex) {
  2545. var _this = _super.call(this) || this;
  2546. _this.parent = parent;
  2547. _this.outerValue = outerValue;
  2548. _this.outerIndex = outerIndex;
  2549. _this.index = 0;
  2550. return _this;
  2551. }
  2552. InnerSubscriber.prototype._next = function (value) {
  2553. this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
  2554. };
  2555. InnerSubscriber.prototype._error = function (error) {
  2556. this.parent.notifyError(error, this);
  2557. this.unsubscribe();
  2558. };
  2559. InnerSubscriber.prototype._complete = function () {
  2560. this.parent.notifyComplete(this);
  2561. this.unsubscribe();
  2562. };
  2563. return InnerSubscriber;
  2564. }(Subscriber));
  2565. var subscribeToPromise = function (promise) { return function (subscriber) {
  2566. promise.then(function (value) {
  2567. if (!subscriber.closed) {
  2568. subscriber.next(value);
  2569. subscriber.complete();
  2570. }
  2571. }, function (err) { return subscriber.error(err); })
  2572. .then(null, hostReportError);
  2573. return subscriber;
  2574. }; };
  2575. function getSymbolIterator() {
  2576. if (typeof Symbol !== 'function' || !Symbol.iterator) {
  2577. return '@@iterator';
  2578. }
  2579. return Symbol.iterator;
  2580. }
  2581. var iterator = getSymbolIterator();
  2582. var subscribeToIterable = function (iterable) { return function (subscriber) {
  2583. var iterator$$1 = iterable[iterator]();
  2584. do {
  2585. var item = iterator$$1.next();
  2586. if (item.done) {
  2587. subscriber.complete();
  2588. break;
  2589. }
  2590. subscriber.next(item.value);
  2591. if (subscriber.closed) {
  2592. break;
  2593. }
  2594. } while (true);
  2595. if (typeof iterator$$1.return === 'function') {
  2596. subscriber.add(function () {
  2597. if (iterator$$1.return) {
  2598. iterator$$1.return();
  2599. }
  2600. });
  2601. }
  2602. return subscriber;
  2603. }; };
  2604. var subscribeToObservable = function (obj) { return function (subscriber) {
  2605. var obs = obj[observable]();
  2606. if (typeof obs.subscribe !== 'function') {
  2607. throw new TypeError('Provided object does not correctly implement Symbol.observable');
  2608. }
  2609. else {
  2610. return obs.subscribe(subscriber);
  2611. }
  2612. }; };
  2613. var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
  2614. function isPromise(value) {
  2615. return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
  2616. }
  2617. var subscribeTo = function (result) {
  2618. if (!!result && typeof result[observable] === 'function') {
  2619. return subscribeToObservable(result);
  2620. }
  2621. else if (isArrayLike(result)) {
  2622. return subscribeToArray(result);
  2623. }
  2624. else if (isPromise(result)) {
  2625. return subscribeToPromise(result);
  2626. }
  2627. else if (!!result && typeof result[iterator] === 'function') {
  2628. return subscribeToIterable(result);
  2629. }
  2630. else {
  2631. var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
  2632. var msg = "You provided " + value + " where a stream was expected."
  2633. + ' You can provide an Observable, Promise, Array, or Iterable.';
  2634. throw new TypeError(msg);
  2635. }
  2636. };
  2637. function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) {
  2638. if (destination === void 0) { destination = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
  2639. if (destination.closed) {
  2640. return undefined;
  2641. }
  2642. if (result instanceof Observable) {
  2643. return result.subscribe(destination);
  2644. }
  2645. return subscribeTo(result)(destination);
  2646. }
  2647. var NONE = {};
  2648. function combineLatest() {
  2649. var observables = [];
  2650. for (var _i = 0; _i < arguments.length; _i++) {
  2651. observables[_i] = arguments[_i];
  2652. }
  2653. var resultSelector = null;
  2654. var scheduler = null;
  2655. if (isScheduler(observables[observables.length - 1])) {
  2656. scheduler = observables.pop();
  2657. }
  2658. if (typeof observables[observables.length - 1] === 'function') {
  2659. resultSelector = observables.pop();
  2660. }
  2661. if (observables.length === 1 && isArray(observables[0])) {
  2662. observables = observables[0];
  2663. }
  2664. return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
  2665. }
  2666. var CombineLatestOperator = (function () {
  2667. function CombineLatestOperator(resultSelector) {
  2668. this.resultSelector = resultSelector;
  2669. }
  2670. CombineLatestOperator.prototype.call = function (subscriber, source) {
  2671. return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
  2672. };
  2673. return CombineLatestOperator;
  2674. }());
  2675. var CombineLatestSubscriber = (function (_super) {
  2676. __extends(CombineLatestSubscriber, _super);
  2677. function CombineLatestSubscriber(destination, resultSelector) {
  2678. var _this = _super.call(this, destination) || this;
  2679. _this.resultSelector = resultSelector;
  2680. _this.active = 0;
  2681. _this.values = [];
  2682. _this.observables = [];
  2683. return _this;
  2684. }
  2685. CombineLatestSubscriber.prototype._next = function (observable) {
  2686. this.values.push(NONE);
  2687. this.observables.push(observable);
  2688. };
  2689. CombineLatestSubscriber.prototype._complete = function () {
  2690. var observables = this.observables;
  2691. var len = observables.length;
  2692. if (len === 0) {
  2693. this.destination.complete();
  2694. }
  2695. else {
  2696. this.active = len;
  2697. this.toRespond = len;
  2698. for (var i = 0; i < len; i++) {
  2699. var observable = observables[i];
  2700. this.add(subscribeToResult(this, observable, observable, i));
  2701. }
  2702. }
  2703. };
  2704. CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
  2705. if ((this.active -= 1) === 0) {
  2706. this.destination.complete();
  2707. }
  2708. };
  2709. CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  2710. var values = this.values;
  2711. var oldVal = values[outerIndex];
  2712. var toRespond = !this.toRespond
  2713. ? 0
  2714. : oldVal === NONE ? --this.toRespond : this.toRespond;
  2715. values[outerIndex] = innerValue;
  2716. if (toRespond === 0) {
  2717. if (this.resultSelector) {
  2718. this._tryResultSelector(values);
  2719. }
  2720. else {
  2721. this.destination.next(values.slice());
  2722. }
  2723. }
  2724. };
  2725. CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
  2726. var result;
  2727. try {
  2728. result = this.resultSelector.apply(this, values);
  2729. }
  2730. catch (err) {
  2731. this.destination.error(err);
  2732. return;
  2733. }
  2734. this.destination.next(result);
  2735. };
  2736. return CombineLatestSubscriber;
  2737. }(OuterSubscriber));
  2738. function scheduleObservable(input, scheduler) {
  2739. return new Observable(function (subscriber) {
  2740. var sub = new Subscription();
  2741. sub.add(scheduler.schedule(function () {
  2742. var observable$$1 = input[observable]();
  2743. sub.add(observable$$1.subscribe({
  2744. next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
  2745. error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
  2746. complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
  2747. }));
  2748. }));
  2749. return sub;
  2750. });
  2751. }
  2752. function schedulePromise(input, scheduler) {
  2753. return new Observable(function (subscriber) {
  2754. var sub = new Subscription();
  2755. sub.add(scheduler.schedule(function () { return input.then(function (value) {
  2756. sub.add(scheduler.schedule(function () {
  2757. subscriber.next(value);
  2758. sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
  2759. }));
  2760. }, function (err) {
  2761. sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
  2762. }); }));
  2763. return sub;
  2764. });
  2765. }
  2766. function scheduleIterable(input, scheduler) {
  2767. if (!input) {
  2768. throw new Error('Iterable cannot be null');
  2769. }
  2770. return new Observable(function (subscriber) {
  2771. var sub = new Subscription();
  2772. var iterator$$1;
  2773. sub.add(function () {
  2774. if (iterator$$1 && typeof iterator$$1.return === 'function') {
  2775. iterator$$1.return();
  2776. }
  2777. });
  2778. sub.add(scheduler.schedule(function () {
  2779. iterator$$1 = input[iterator]();
  2780. sub.add(scheduler.schedule(function () {
  2781. if (subscriber.closed) {
  2782. return;
  2783. }
  2784. var value;
  2785. var done;
  2786. try {
  2787. var result = iterator$$1.next();
  2788. value = result.value;
  2789. done = result.done;
  2790. }
  2791. catch (err) {
  2792. subscriber.error(err);
  2793. return;
  2794. }
  2795. if (done) {
  2796. subscriber.complete();
  2797. }
  2798. else {
  2799. subscriber.next(value);
  2800. this.schedule();
  2801. }
  2802. }));
  2803. }));
  2804. return sub;
  2805. });
  2806. }
  2807. function isInteropObservable(input) {
  2808. return input && typeof input[observable] === 'function';
  2809. }
  2810. function isIterable(input) {
  2811. return input && typeof input[iterator] === 'function';
  2812. }
  2813. function scheduled(input, scheduler) {
  2814. if (input != null) {
  2815. if (isInteropObservable(input)) {
  2816. return scheduleObservable(input, scheduler);
  2817. }
  2818. else if (isPromise(input)) {
  2819. return schedulePromise(input, scheduler);
  2820. }
  2821. else if (isArrayLike(input)) {
  2822. return scheduleArray(input, scheduler);
  2823. }
  2824. else if (isIterable(input) || typeof input === 'string') {
  2825. return scheduleIterable(input, scheduler);
  2826. }
  2827. }
  2828. throw new TypeError((input !== null && typeof input || input) + ' is not observable');
  2829. }
  2830. function from(input, scheduler) {
  2831. if (!scheduler) {
  2832. if (input instanceof Observable) {
  2833. return input;
  2834. }
  2835. return new Observable(subscribeTo(input));
  2836. }
  2837. else {
  2838. return scheduled(input, scheduler);
  2839. }
  2840. }
  2841. function mergeMap(project, resultSelector, concurrent) {
  2842. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2843. if (typeof resultSelector === 'function') {
  2844. return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
  2845. }
  2846. else if (typeof resultSelector === 'number') {
  2847. concurrent = resultSelector;
  2848. }
  2849. return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
  2850. }
  2851. var MergeMapOperator = (function () {
  2852. function MergeMapOperator(project, concurrent) {
  2853. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2854. this.project = project;
  2855. this.concurrent = concurrent;
  2856. }
  2857. MergeMapOperator.prototype.call = function (observer, source) {
  2858. return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
  2859. };
  2860. return MergeMapOperator;
  2861. }());
  2862. var MergeMapSubscriber = (function (_super) {
  2863. __extends(MergeMapSubscriber, _super);
  2864. function MergeMapSubscriber(destination, project, concurrent) {
  2865. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2866. var _this = _super.call(this, destination) || this;
  2867. _this.project = project;
  2868. _this.concurrent = concurrent;
  2869. _this.hasCompleted = false;
  2870. _this.buffer = [];
  2871. _this.active = 0;
  2872. _this.index = 0;
  2873. return _this;
  2874. }
  2875. MergeMapSubscriber.prototype._next = function (value) {
  2876. if (this.active < this.concurrent) {
  2877. this._tryNext(value);
  2878. }
  2879. else {
  2880. this.buffer.push(value);
  2881. }
  2882. };
  2883. MergeMapSubscriber.prototype._tryNext = function (value) {
  2884. var result;
  2885. var index = this.index++;
  2886. try {
  2887. result = this.project(value, index);
  2888. }
  2889. catch (err) {
  2890. this.destination.error(err);
  2891. return;
  2892. }
  2893. this.active++;
  2894. this._innerSub(result, value, index);
  2895. };
  2896. MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
  2897. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  2898. var destination = this.destination;
  2899. destination.add(innerSubscriber);
  2900. subscribeToResult(this, ish, value, index, innerSubscriber);
  2901. };
  2902. MergeMapSubscriber.prototype._complete = function () {
  2903. this.hasCompleted = true;
  2904. if (this.active === 0 && this.buffer.length === 0) {
  2905. this.destination.complete();
  2906. }
  2907. this.unsubscribe();
  2908. };
  2909. MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  2910. this.destination.next(innerValue);
  2911. };
  2912. MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
  2913. var buffer = this.buffer;
  2914. this.remove(innerSub);
  2915. this.active--;
  2916. if (buffer.length > 0) {
  2917. this._next(buffer.shift());
  2918. }
  2919. else if (this.active === 0 && this.hasCompleted) {
  2920. this.destination.complete();
  2921. }
  2922. };
  2923. return MergeMapSubscriber;
  2924. }(OuterSubscriber));
  2925. function mergeAll(concurrent) {
  2926. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2927. return mergeMap(identity, concurrent);
  2928. }
  2929. function concatAll() {
  2930. return mergeAll(1);
  2931. }
  2932. function concat() {
  2933. var observables = [];
  2934. for (var _i = 0; _i < arguments.length; _i++) {
  2935. observables[_i] = arguments[_i];
  2936. }
  2937. return concatAll()(of.apply(void 0, observables));
  2938. }
  2939. function defer(observableFactory) {
  2940. return new Observable(function (subscriber) {
  2941. var input;
  2942. try {
  2943. input = observableFactory();
  2944. }
  2945. catch (err) {
  2946. subscriber.error(err);
  2947. return undefined;
  2948. }
  2949. var source = input ? from(input) : empty$1();
  2950. return source.subscribe(subscriber);
  2951. });
  2952. }
  2953. function forkJoin() {
  2954. var sources = [];
  2955. for (var _i = 0; _i < arguments.length; _i++) {
  2956. sources[_i] = arguments[_i];
  2957. }
  2958. if (sources.length === 1) {
  2959. var first_1 = sources[0];
  2960. if (isArray(first_1)) {
  2961. return forkJoinInternal(first_1, null);
  2962. }
  2963. if (isObject(first_1) && Object.getPrototypeOf(first_1) === Object.prototype) {
  2964. var keys = Object.keys(first_1);
  2965. return forkJoinInternal(keys.map(function (key) { return first_1[key]; }), keys);
  2966. }
  2967. }
  2968. if (typeof sources[sources.length - 1] === 'function') {
  2969. var resultSelector_1 = sources.pop();
  2970. sources = (sources.length === 1 && isArray(sources[0])) ? sources[0] : sources;
  2971. return forkJoinInternal(sources, null).pipe(map(function (args) { return resultSelector_1.apply(void 0, args); }));
  2972. }
  2973. return forkJoinInternal(sources, null);
  2974. }
  2975. function forkJoinInternal(sources, keys) {
  2976. return new Observable(function (subscriber) {
  2977. var len = sources.length;
  2978. if (len === 0) {
  2979. subscriber.complete();
  2980. return;
  2981. }
  2982. var values = new Array(len);
  2983. var completed = 0;
  2984. var emitted = 0;
  2985. var _loop_1 = function (i) {
  2986. var source = from(sources[i]);
  2987. var hasValue = false;
  2988. subscriber.add(source.subscribe({
  2989. next: function (value) {
  2990. if (!hasValue) {
  2991. hasValue = true;
  2992. emitted++;
  2993. }
  2994. values[i] = value;
  2995. },
  2996. error: function (err) { return subscriber.error(err); },
  2997. complete: function () {
  2998. completed++;
  2999. if (completed === len || !hasValue) {
  3000. if (emitted === len) {
  3001. subscriber.next(keys ?
  3002. keys.reduce(function (result, key, i) { return (result[key] = values[i], result); }, {}) :
  3003. values);
  3004. }
  3005. subscriber.complete();
  3006. }
  3007. }
  3008. }));
  3009. };
  3010. for (var i = 0; i < len; i++) {
  3011. _loop_1(i);
  3012. }
  3013. });
  3014. }
  3015. function fromEvent(target, eventName, options, resultSelector) {
  3016. if (isFunction(options)) {
  3017. resultSelector = options;
  3018. options = undefined;
  3019. }
  3020. if (resultSelector) {
  3021. return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  3022. }
  3023. return new Observable(function (subscriber) {
  3024. function handler(e) {
  3025. if (arguments.length > 1) {
  3026. subscriber.next(Array.prototype.slice.call(arguments));
  3027. }
  3028. else {
  3029. subscriber.next(e);
  3030. }
  3031. }
  3032. setupSubscription(target, eventName, handler, subscriber, options);
  3033. });
  3034. }
  3035. function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
  3036. var unsubscribe;
  3037. if (isEventTarget(sourceObj)) {
  3038. var source_1 = sourceObj;
  3039. sourceObj.addEventListener(eventName, handler, options);
  3040. unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
  3041. }
  3042. else if (isJQueryStyleEventEmitter(sourceObj)) {
  3043. var source_2 = sourceObj;
  3044. sourceObj.on(eventName, handler);
  3045. unsubscribe = function () { return source_2.off(eventName, handler); };
  3046. }
  3047. else if (isNodeStyleEventEmitter(sourceObj)) {
  3048. var source_3 = sourceObj;
  3049. sourceObj.addListener(eventName, handler);
  3050. unsubscribe = function () { return source_3.removeListener(eventName, handler); };
  3051. }
  3052. else if (sourceObj && sourceObj.length) {
  3053. for (var i = 0, len = sourceObj.length; i < len; i++) {
  3054. setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
  3055. }
  3056. }
  3057. else {
  3058. throw new TypeError('Invalid event target');
  3059. }
  3060. subscriber.add(unsubscribe);
  3061. }
  3062. function isNodeStyleEventEmitter(sourceObj) {
  3063. return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
  3064. }
  3065. function isJQueryStyleEventEmitter(sourceObj) {
  3066. return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
  3067. }
  3068. function isEventTarget(sourceObj) {
  3069. return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
  3070. }
  3071. function fromEventPattern(addHandler, removeHandler, resultSelector) {
  3072. if (resultSelector) {
  3073. return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  3074. }
  3075. return new Observable(function (subscriber) {
  3076. var handler = function () {
  3077. var e = [];
  3078. for (var _i = 0; _i < arguments.length; _i++) {
  3079. e[_i] = arguments[_i];
  3080. }
  3081. return subscriber.next(e.length === 1 ? e[0] : e);
  3082. };
  3083. var retValue;
  3084. try {
  3085. retValue = addHandler(handler);
  3086. }
  3087. catch (err) {
  3088. subscriber.error(err);
  3089. return undefined;
  3090. }
  3091. if (!isFunction(removeHandler)) {
  3092. return undefined;
  3093. }
  3094. return function () { return removeHandler(handler, retValue); };
  3095. });
  3096. }
  3097. function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
  3098. var resultSelector;
  3099. var initialState;
  3100. if (arguments.length == 1) {
  3101. var options = initialStateOrOptions;
  3102. initialState = options.initialState;
  3103. condition = options.condition;
  3104. iterate = options.iterate;
  3105. resultSelector = options.resultSelector || identity;
  3106. scheduler = options.scheduler;
  3107. }
  3108. else if (resultSelectorOrObservable === undefined || isScheduler(resultSelectorOrObservable)) {
  3109. initialState = initialStateOrOptions;
  3110. resultSelector = identity;
  3111. scheduler = resultSelectorOrObservable;
  3112. }
  3113. else {
  3114. initialState = initialStateOrOptions;
  3115. resultSelector = resultSelectorOrObservable;
  3116. }
  3117. return new Observable(function (subscriber) {
  3118. var state = initialState;
  3119. if (scheduler) {
  3120. return scheduler.schedule(dispatch$3, 0, {
  3121. subscriber: subscriber,
  3122. iterate: iterate,
  3123. condition: condition,
  3124. resultSelector: resultSelector,
  3125. state: state
  3126. });
  3127. }
  3128. do {
  3129. if (condition) {
  3130. var conditionResult = void 0;
  3131. try {
  3132. conditionResult = condition(state);
  3133. }
  3134. catch (err) {
  3135. subscriber.error(err);
  3136. return undefined;
  3137. }
  3138. if (!conditionResult) {
  3139. subscriber.complete();
  3140. break;
  3141. }
  3142. }
  3143. var value = void 0;
  3144. try {
  3145. value = resultSelector(state);
  3146. }
  3147. catch (err) {
  3148. subscriber.error(err);
  3149. return undefined;
  3150. }
  3151. subscriber.next(value);
  3152. if (subscriber.closed) {
  3153. break;
  3154. }
  3155. try {
  3156. state = iterate(state);
  3157. }
  3158. catch (err) {
  3159. subscriber.error(err);
  3160. return undefined;
  3161. }
  3162. } while (true);
  3163. return undefined;
  3164. });
  3165. }
  3166. function dispatch$3(state) {
  3167. var subscriber = state.subscriber, condition = state.condition;
  3168. if (subscriber.closed) {
  3169. return undefined;
  3170. }
  3171. if (state.needIterate) {
  3172. try {
  3173. state.state = state.iterate(state.state);
  3174. }
  3175. catch (err) {
  3176. subscriber.error(err);
  3177. return undefined;
  3178. }
  3179. }
  3180. else {
  3181. state.needIterate = true;
  3182. }
  3183. if (condition) {
  3184. var conditionResult = void 0;
  3185. try {
  3186. conditionResult = condition(state.state);
  3187. }
  3188. catch (err) {
  3189. subscriber.error(err);
  3190. return undefined;
  3191. }
  3192. if (!conditionResult) {
  3193. subscriber.complete();
  3194. return undefined;
  3195. }
  3196. if (subscriber.closed) {
  3197. return undefined;
  3198. }
  3199. }
  3200. var value;
  3201. try {
  3202. value = state.resultSelector(state.state);
  3203. }
  3204. catch (err) {
  3205. subscriber.error(err);
  3206. return undefined;
  3207. }
  3208. if (subscriber.closed) {
  3209. return undefined;
  3210. }
  3211. subscriber.next(value);
  3212. if (subscriber.closed) {
  3213. return undefined;
  3214. }
  3215. return this.schedule(state);
  3216. }
  3217. function iif(condition, trueResult, falseResult) {
  3218. if (trueResult === void 0) { trueResult = EMPTY; }
  3219. if (falseResult === void 0) { falseResult = EMPTY; }
  3220. return defer(function () { return condition() ? trueResult : falseResult; });
  3221. }
  3222. function isNumeric(val) {
  3223. return !isArray(val) && (val - parseFloat(val) + 1) >= 0;
  3224. }
  3225. function interval(period, scheduler) {
  3226. if (period === void 0) { period = 0; }
  3227. if (scheduler === void 0) { scheduler = async; }
  3228. if (!isNumeric(period) || period < 0) {
  3229. period = 0;
  3230. }
  3231. if (!scheduler || typeof scheduler.schedule !== 'function') {
  3232. scheduler = async;
  3233. }
  3234. return new Observable(function (subscriber) {
  3235. subscriber.add(scheduler.schedule(dispatch$4, period, { subscriber: subscriber, counter: 0, period: period }));
  3236. return subscriber;
  3237. });
  3238. }
  3239. function dispatch$4(state) {
  3240. var subscriber = state.subscriber, counter = state.counter, period = state.period;
  3241. subscriber.next(counter);
  3242. this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
  3243. }
  3244. function merge() {
  3245. var observables = [];
  3246. for (var _i = 0; _i < arguments.length; _i++) {
  3247. observables[_i] = arguments[_i];
  3248. }
  3249. var concurrent = Number.POSITIVE_INFINITY;
  3250. var scheduler = null;
  3251. var last = observables[observables.length - 1];
  3252. if (isScheduler(last)) {
  3253. scheduler = observables.pop();
  3254. if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
  3255. concurrent = observables.pop();
  3256. }
  3257. }
  3258. else if (typeof last === 'number') {
  3259. concurrent = observables.pop();
  3260. }
  3261. if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
  3262. return observables[0];
  3263. }
  3264. return mergeAll(concurrent)(fromArray(observables, scheduler));
  3265. }
  3266. var NEVER = new Observable(noop);
  3267. function never() {
  3268. return NEVER;
  3269. }
  3270. function onErrorResumeNext() {
  3271. var sources = [];
  3272. for (var _i = 0; _i < arguments.length; _i++) {
  3273. sources[_i] = arguments[_i];
  3274. }
  3275. if (sources.length === 0) {
  3276. return EMPTY;
  3277. }
  3278. var first = sources[0], remainder = sources.slice(1);
  3279. if (sources.length === 1 && isArray(first)) {
  3280. return onErrorResumeNext.apply(void 0, first);
  3281. }
  3282. return new Observable(function (subscriber) {
  3283. var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
  3284. return from(first).subscribe({
  3285. next: function (value) { subscriber.next(value); },
  3286. error: subNext,
  3287. complete: subNext,
  3288. });
  3289. });
  3290. }
  3291. function pairs(obj, scheduler) {
  3292. if (!scheduler) {
  3293. return new Observable(function (subscriber) {
  3294. var keys = Object.keys(obj);
  3295. for (var i = 0; i < keys.length && !subscriber.closed; i++) {
  3296. var key = keys[i];
  3297. if (obj.hasOwnProperty(key)) {
  3298. subscriber.next([key, obj[key]]);
  3299. }
  3300. }
  3301. subscriber.complete();
  3302. });
  3303. }
  3304. else {
  3305. return new Observable(function (subscriber) {
  3306. var keys = Object.keys(obj);
  3307. var subscription = new Subscription();
  3308. subscription.add(scheduler.schedule(dispatch$5, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
  3309. return subscription;
  3310. });
  3311. }
  3312. }
  3313. function dispatch$5(state) {
  3314. var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
  3315. if (!subscriber.closed) {
  3316. if (index < keys.length) {
  3317. var key = keys[index];
  3318. subscriber.next([key, obj[key]]);
  3319. subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
  3320. }
  3321. else {
  3322. subscriber.complete();
  3323. }
  3324. }
  3325. }
  3326. function not(pred, thisArg) {
  3327. function notPred() {
  3328. return !(notPred.pred.apply(notPred.thisArg, arguments));
  3329. }
  3330. notPred.pred = pred;
  3331. notPred.thisArg = thisArg;
  3332. return notPred;
  3333. }
  3334. function filter(predicate, thisArg) {
  3335. return function filterOperatorFunction(source) {
  3336. return source.lift(new FilterOperator(predicate, thisArg));
  3337. };
  3338. }
  3339. var FilterOperator = (function () {
  3340. function FilterOperator(predicate, thisArg) {
  3341. this.predicate = predicate;
  3342. this.thisArg = thisArg;
  3343. }
  3344. FilterOperator.prototype.call = function (subscriber, source) {
  3345. return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
  3346. };
  3347. return FilterOperator;
  3348. }());
  3349. var FilterSubscriber = (function (_super) {
  3350. __extends(FilterSubscriber, _super);
  3351. function FilterSubscriber(destination, predicate, thisArg) {
  3352. var _this = _super.call(this, destination) || this;
  3353. _this.predicate = predicate;
  3354. _this.thisArg = thisArg;
  3355. _this.count = 0;
  3356. return _this;
  3357. }
  3358. FilterSubscriber.prototype._next = function (value) {
  3359. var result;
  3360. try {
  3361. result = this.predicate.call(this.thisArg, value, this.count++);
  3362. }
  3363. catch (err) {
  3364. this.destination.error(err);
  3365. return;
  3366. }
  3367. if (result) {
  3368. this.destination.next(value);
  3369. }
  3370. };
  3371. return FilterSubscriber;
  3372. }(Subscriber));
  3373. function partition(source, predicate, thisArg) {
  3374. return [
  3375. filter(predicate, thisArg)(new Observable(subscribeTo(source))),
  3376. filter(not(predicate, thisArg))(new Observable(subscribeTo(source)))
  3377. ];
  3378. }
  3379. function race() {
  3380. var observables = [];
  3381. for (var _i = 0; _i < arguments.length; _i++) {
  3382. observables[_i] = arguments[_i];
  3383. }
  3384. if (observables.length === 1) {
  3385. if (isArray(observables[0])) {
  3386. observables = observables[0];
  3387. }
  3388. else {
  3389. return observables[0];
  3390. }
  3391. }
  3392. return fromArray(observables, undefined).lift(new RaceOperator());
  3393. }
  3394. var RaceOperator = (function () {
  3395. function RaceOperator() {
  3396. }
  3397. RaceOperator.prototype.call = function (subscriber, source) {
  3398. return source.subscribe(new RaceSubscriber(subscriber));
  3399. };
  3400. return RaceOperator;
  3401. }());
  3402. var RaceSubscriber = (function (_super) {
  3403. __extends(RaceSubscriber, _super);
  3404. function RaceSubscriber(destination) {
  3405. var _this = _super.call(this, destination) || this;
  3406. _this.hasFirst = false;
  3407. _this.observables = [];
  3408. _this.subscriptions = [];
  3409. return _this;
  3410. }
  3411. RaceSubscriber.prototype._next = function (observable) {
  3412. this.observables.push(observable);
  3413. };
  3414. RaceSubscriber.prototype._complete = function () {
  3415. var observables = this.observables;
  3416. var len = observables.length;
  3417. if (len === 0) {
  3418. this.destination.complete();
  3419. }
  3420. else {
  3421. for (var i = 0; i < len && !this.hasFirst; i++) {
  3422. var observable = observables[i];
  3423. var subscription = subscribeToResult(this, observable, observable, i);
  3424. if (this.subscriptions) {
  3425. this.subscriptions.push(subscription);
  3426. }
  3427. this.add(subscription);
  3428. }
  3429. this.observables = null;
  3430. }
  3431. };
  3432. RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3433. if (!this.hasFirst) {
  3434. this.hasFirst = true;
  3435. for (var i = 0; i < this.subscriptions.length; i++) {
  3436. if (i !== outerIndex) {
  3437. var subscription = this.subscriptions[i];
  3438. subscription.unsubscribe();
  3439. this.remove(subscription);
  3440. }
  3441. }
  3442. this.subscriptions = null;
  3443. }
  3444. this.destination.next(innerValue);
  3445. };
  3446. return RaceSubscriber;
  3447. }(OuterSubscriber));
  3448. function range(start, count, scheduler) {
  3449. if (start === void 0) { start = 0; }
  3450. return new Observable(function (subscriber) {
  3451. if (count === undefined) {
  3452. count = start;
  3453. start = 0;
  3454. }
  3455. var index = 0;
  3456. var current = start;
  3457. if (scheduler) {
  3458. return scheduler.schedule(dispatch$6, 0, {
  3459. index: index, count: count, start: start, subscriber: subscriber
  3460. });
  3461. }
  3462. else {
  3463. do {
  3464. if (index++ >= count) {
  3465. subscriber.complete();
  3466. break;
  3467. }
  3468. subscriber.next(current++);
  3469. if (subscriber.closed) {
  3470. break;
  3471. }
  3472. } while (true);
  3473. }
  3474. return undefined;
  3475. });
  3476. }
  3477. function dispatch$6(state) {
  3478. var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
  3479. if (index >= count) {
  3480. subscriber.complete();
  3481. return;
  3482. }
  3483. subscriber.next(start);
  3484. if (subscriber.closed) {
  3485. return;
  3486. }
  3487. state.index = index + 1;
  3488. state.start = start + 1;
  3489. this.schedule(state);
  3490. }
  3491. function timer(dueTime, periodOrScheduler, scheduler) {
  3492. if (dueTime === void 0) { dueTime = 0; }
  3493. var period = -1;
  3494. if (isNumeric(periodOrScheduler)) {
  3495. period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
  3496. }
  3497. else if (isScheduler(periodOrScheduler)) {
  3498. scheduler = periodOrScheduler;
  3499. }
  3500. if (!isScheduler(scheduler)) {
  3501. scheduler = async;
  3502. }
  3503. return new Observable(function (subscriber) {
  3504. var due = isNumeric(dueTime)
  3505. ? dueTime
  3506. : (+dueTime - scheduler.now());
  3507. return scheduler.schedule(dispatch$7, due, {
  3508. index: 0, period: period, subscriber: subscriber
  3509. });
  3510. });
  3511. }
  3512. function dispatch$7(state) {
  3513. var index = state.index, period = state.period, subscriber = state.subscriber;
  3514. subscriber.next(index);
  3515. if (subscriber.closed) {
  3516. return;
  3517. }
  3518. else if (period === -1) {
  3519. return subscriber.complete();
  3520. }
  3521. state.index = index + 1;
  3522. this.schedule(state, period);
  3523. }
  3524. function using(resourceFactory, observableFactory) {
  3525. return new Observable(function (subscriber) {
  3526. var resource;
  3527. try {
  3528. resource = resourceFactory();
  3529. }
  3530. catch (err) {
  3531. subscriber.error(err);
  3532. return undefined;
  3533. }
  3534. var result;
  3535. try {
  3536. result = observableFactory(resource);
  3537. }
  3538. catch (err) {
  3539. subscriber.error(err);
  3540. return undefined;
  3541. }
  3542. var source = result ? from(result) : EMPTY;
  3543. var subscription = source.subscribe(subscriber);
  3544. return function () {
  3545. subscription.unsubscribe();
  3546. if (resource) {
  3547. resource.unsubscribe();
  3548. }
  3549. };
  3550. });
  3551. }
  3552. function zip() {
  3553. var observables = [];
  3554. for (var _i = 0; _i < arguments.length; _i++) {
  3555. observables[_i] = arguments[_i];
  3556. }
  3557. var resultSelector = observables[observables.length - 1];
  3558. if (typeof resultSelector === 'function') {
  3559. observables.pop();
  3560. }
  3561. return fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
  3562. }
  3563. var ZipOperator = (function () {
  3564. function ZipOperator(resultSelector) {
  3565. this.resultSelector = resultSelector;
  3566. }
  3567. ZipOperator.prototype.call = function (subscriber, source) {
  3568. return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
  3569. };
  3570. return ZipOperator;
  3571. }());
  3572. var ZipSubscriber = (function (_super) {
  3573. __extends(ZipSubscriber, _super);
  3574. function ZipSubscriber(destination, resultSelector, values) {
  3575. if (values === void 0) { values = Object.create(null); }
  3576. var _this = _super.call(this, destination) || this;
  3577. _this.iterators = [];
  3578. _this.active = 0;
  3579. _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
  3580. _this.values = values;
  3581. return _this;
  3582. }
  3583. ZipSubscriber.prototype._next = function (value) {
  3584. var iterators = this.iterators;
  3585. if (isArray(value)) {
  3586. iterators.push(new StaticArrayIterator(value));
  3587. }
  3588. else if (typeof value[iterator] === 'function') {
  3589. iterators.push(new StaticIterator(value[iterator]()));
  3590. }
  3591. else {
  3592. iterators.push(new ZipBufferIterator(this.destination, this, value));
  3593. }
  3594. };
  3595. ZipSubscriber.prototype._complete = function () {
  3596. var iterators = this.iterators;
  3597. var len = iterators.length;
  3598. this.unsubscribe();
  3599. if (len === 0) {
  3600. this.destination.complete();
  3601. return;
  3602. }
  3603. this.active = len;
  3604. for (var i = 0; i < len; i++) {
  3605. var iterator$$1 = iterators[i];
  3606. if (iterator$$1.stillUnsubscribed) {
  3607. var destination = this.destination;
  3608. destination.add(iterator$$1.subscribe(iterator$$1, i));
  3609. }
  3610. else {
  3611. this.active--;
  3612. }
  3613. }
  3614. };
  3615. ZipSubscriber.prototype.notifyInactive = function () {
  3616. this.active--;
  3617. if (this.active === 0) {
  3618. this.destination.complete();
  3619. }
  3620. };
  3621. ZipSubscriber.prototype.checkIterators = function () {
  3622. var iterators = this.iterators;
  3623. var len = iterators.length;
  3624. var destination = this.destination;
  3625. for (var i = 0; i < len; i++) {
  3626. var iterator$$1 = iterators[i];
  3627. if (typeof iterator$$1.hasValue === 'function' && !iterator$$1.hasValue()) {
  3628. return;
  3629. }
  3630. }
  3631. var shouldComplete = false;
  3632. var args = [];
  3633. for (var i = 0; i < len; i++) {
  3634. var iterator$$1 = iterators[i];
  3635. var result = iterator$$1.next();
  3636. if (iterator$$1.hasCompleted()) {
  3637. shouldComplete = true;
  3638. }
  3639. if (result.done) {
  3640. destination.complete();
  3641. return;
  3642. }
  3643. args.push(result.value);
  3644. }
  3645. if (this.resultSelector) {
  3646. this._tryresultSelector(args);
  3647. }
  3648. else {
  3649. destination.next(args);
  3650. }
  3651. if (shouldComplete) {
  3652. destination.complete();
  3653. }
  3654. };
  3655. ZipSubscriber.prototype._tryresultSelector = function (args) {
  3656. var result;
  3657. try {
  3658. result = this.resultSelector.apply(this, args);
  3659. }
  3660. catch (err) {
  3661. this.destination.error(err);
  3662. return;
  3663. }
  3664. this.destination.next(result);
  3665. };
  3666. return ZipSubscriber;
  3667. }(Subscriber));
  3668. var StaticIterator = (function () {
  3669. function StaticIterator(iterator$$1) {
  3670. this.iterator = iterator$$1;
  3671. this.nextResult = iterator$$1.next();
  3672. }
  3673. StaticIterator.prototype.hasValue = function () {
  3674. return true;
  3675. };
  3676. StaticIterator.prototype.next = function () {
  3677. var result = this.nextResult;
  3678. this.nextResult = this.iterator.next();
  3679. return result;
  3680. };
  3681. StaticIterator.prototype.hasCompleted = function () {
  3682. var nextResult = this.nextResult;
  3683. return nextResult && nextResult.done;
  3684. };
  3685. return StaticIterator;
  3686. }());
  3687. var StaticArrayIterator = (function () {
  3688. function StaticArrayIterator(array) {
  3689. this.array = array;
  3690. this.index = 0;
  3691. this.length = 0;
  3692. this.length = array.length;
  3693. }
  3694. StaticArrayIterator.prototype[iterator] = function () {
  3695. return this;
  3696. };
  3697. StaticArrayIterator.prototype.next = function (value) {
  3698. var i = this.index++;
  3699. var array = this.array;
  3700. return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
  3701. };
  3702. StaticArrayIterator.prototype.hasValue = function () {
  3703. return this.array.length > this.index;
  3704. };
  3705. StaticArrayIterator.prototype.hasCompleted = function () {
  3706. return this.array.length === this.index;
  3707. };
  3708. return StaticArrayIterator;
  3709. }());
  3710. var ZipBufferIterator = (function (_super) {
  3711. __extends(ZipBufferIterator, _super);
  3712. function ZipBufferIterator(destination, parent, observable) {
  3713. var _this = _super.call(this, destination) || this;
  3714. _this.parent = parent;
  3715. _this.observable = observable;
  3716. _this.stillUnsubscribed = true;
  3717. _this.buffer = [];
  3718. _this.isComplete = false;
  3719. return _this;
  3720. }
  3721. ZipBufferIterator.prototype[iterator] = function () {
  3722. return this;
  3723. };
  3724. ZipBufferIterator.prototype.next = function () {
  3725. var buffer = this.buffer;
  3726. if (buffer.length === 0 && this.isComplete) {
  3727. return { value: null, done: true };
  3728. }
  3729. else {
  3730. return { value: buffer.shift(), done: false };
  3731. }
  3732. };
  3733. ZipBufferIterator.prototype.hasValue = function () {
  3734. return this.buffer.length > 0;
  3735. };
  3736. ZipBufferIterator.prototype.hasCompleted = function () {
  3737. return this.buffer.length === 0 && this.isComplete;
  3738. };
  3739. ZipBufferIterator.prototype.notifyComplete = function () {
  3740. if (this.buffer.length > 0) {
  3741. this.isComplete = true;
  3742. this.parent.notifyInactive();
  3743. }
  3744. else {
  3745. this.destination.complete();
  3746. }
  3747. };
  3748. ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3749. this.buffer.push(innerValue);
  3750. this.parent.checkIterators();
  3751. };
  3752. ZipBufferIterator.prototype.subscribe = function (value, index) {
  3753. return subscribeToResult(this, this.observable, this, index);
  3754. };
  3755. return ZipBufferIterator;
  3756. }(OuterSubscriber));
  3757. function audit(durationSelector) {
  3758. return function auditOperatorFunction(source) {
  3759. return source.lift(new AuditOperator(durationSelector));
  3760. };
  3761. }
  3762. var AuditOperator = (function () {
  3763. function AuditOperator(durationSelector) {
  3764. this.durationSelector = durationSelector;
  3765. }
  3766. AuditOperator.prototype.call = function (subscriber, source) {
  3767. return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
  3768. };
  3769. return AuditOperator;
  3770. }());
  3771. var AuditSubscriber = (function (_super) {
  3772. __extends(AuditSubscriber, _super);
  3773. function AuditSubscriber(destination, durationSelector) {
  3774. var _this = _super.call(this, destination) || this;
  3775. _this.durationSelector = durationSelector;
  3776. _this.hasValue = false;
  3777. return _this;
  3778. }
  3779. AuditSubscriber.prototype._next = function (value) {
  3780. this.value = value;
  3781. this.hasValue = true;
  3782. if (!this.throttled) {
  3783. var duration = void 0;
  3784. try {
  3785. var durationSelector = this.durationSelector;
  3786. duration = durationSelector(value);
  3787. }
  3788. catch (err) {
  3789. return this.destination.error(err);
  3790. }
  3791. var innerSubscription = subscribeToResult(this, duration);
  3792. if (!innerSubscription || innerSubscription.closed) {
  3793. this.clearThrottle();
  3794. }
  3795. else {
  3796. this.add(this.throttled = innerSubscription);
  3797. }
  3798. }
  3799. };
  3800. AuditSubscriber.prototype.clearThrottle = function () {
  3801. var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
  3802. if (throttled) {
  3803. this.remove(throttled);
  3804. this.throttled = null;
  3805. throttled.unsubscribe();
  3806. }
  3807. if (hasValue) {
  3808. this.value = null;
  3809. this.hasValue = false;
  3810. this.destination.next(value);
  3811. }
  3812. };
  3813. AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
  3814. this.clearThrottle();
  3815. };
  3816. AuditSubscriber.prototype.notifyComplete = function () {
  3817. this.clearThrottle();
  3818. };
  3819. return AuditSubscriber;
  3820. }(OuterSubscriber));
  3821. function auditTime(duration, scheduler) {
  3822. if (scheduler === void 0) { scheduler = async; }
  3823. return audit(function () { return timer(duration, scheduler); });
  3824. }
  3825. function buffer(closingNotifier) {
  3826. return function bufferOperatorFunction(source) {
  3827. return source.lift(new BufferOperator(closingNotifier));
  3828. };
  3829. }
  3830. var BufferOperator = (function () {
  3831. function BufferOperator(closingNotifier) {
  3832. this.closingNotifier = closingNotifier;
  3833. }
  3834. BufferOperator.prototype.call = function (subscriber, source) {
  3835. return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
  3836. };
  3837. return BufferOperator;
  3838. }());
  3839. var BufferSubscriber = (function (_super) {
  3840. __extends(BufferSubscriber, _super);
  3841. function BufferSubscriber(destination, closingNotifier) {
  3842. var _this = _super.call(this, destination) || this;
  3843. _this.buffer = [];
  3844. _this.add(subscribeToResult(_this, closingNotifier));
  3845. return _this;
  3846. }
  3847. BufferSubscriber.prototype._next = function (value) {
  3848. this.buffer.push(value);
  3849. };
  3850. BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3851. var buffer = this.buffer;
  3852. this.buffer = [];
  3853. this.destination.next(buffer);
  3854. };
  3855. return BufferSubscriber;
  3856. }(OuterSubscriber));
  3857. function bufferCount(bufferSize, startBufferEvery) {
  3858. if (startBufferEvery === void 0) { startBufferEvery = null; }
  3859. return function bufferCountOperatorFunction(source) {
  3860. return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
  3861. };
  3862. }
  3863. var BufferCountOperator = (function () {
  3864. function BufferCountOperator(bufferSize, startBufferEvery) {
  3865. this.bufferSize = bufferSize;
  3866. this.startBufferEvery = startBufferEvery;
  3867. if (!startBufferEvery || bufferSize === startBufferEvery) {
  3868. this.subscriberClass = BufferCountSubscriber;
  3869. }
  3870. else {
  3871. this.subscriberClass = BufferSkipCountSubscriber;
  3872. }
  3873. }
  3874. BufferCountOperator.prototype.call = function (subscriber, source) {
  3875. return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
  3876. };
  3877. return BufferCountOperator;
  3878. }());
  3879. var BufferCountSubscriber = (function (_super) {
  3880. __extends(BufferCountSubscriber, _super);
  3881. function BufferCountSubscriber(destination, bufferSize) {
  3882. var _this = _super.call(this, destination) || this;
  3883. _this.bufferSize = bufferSize;
  3884. _this.buffer = [];
  3885. return _this;
  3886. }
  3887. BufferCountSubscriber.prototype._next = function (value) {
  3888. var buffer = this.buffer;
  3889. buffer.push(value);
  3890. if (buffer.length == this.bufferSize) {
  3891. this.destination.next(buffer);
  3892. this.buffer = [];
  3893. }
  3894. };
  3895. BufferCountSubscriber.prototype._complete = function () {
  3896. var buffer = this.buffer;
  3897. if (buffer.length > 0) {
  3898. this.destination.next(buffer);
  3899. }
  3900. _super.prototype._complete.call(this);
  3901. };
  3902. return BufferCountSubscriber;
  3903. }(Subscriber));
  3904. var BufferSkipCountSubscriber = (function (_super) {
  3905. __extends(BufferSkipCountSubscriber, _super);
  3906. function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
  3907. var _this = _super.call(this, destination) || this;
  3908. _this.bufferSize = bufferSize;
  3909. _this.startBufferEvery = startBufferEvery;
  3910. _this.buffers = [];
  3911. _this.count = 0;
  3912. return _this;
  3913. }
  3914. BufferSkipCountSubscriber.prototype._next = function (value) {
  3915. var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
  3916. this.count++;
  3917. if (count % startBufferEvery === 0) {
  3918. buffers.push([]);
  3919. }
  3920. for (var i = buffers.length; i--;) {
  3921. var buffer = buffers[i];
  3922. buffer.push(value);
  3923. if (buffer.length === bufferSize) {
  3924. buffers.splice(i, 1);
  3925. this.destination.next(buffer);
  3926. }
  3927. }
  3928. };
  3929. BufferSkipCountSubscriber.prototype._complete = function () {
  3930. var _a = this, buffers = _a.buffers, destination = _a.destination;
  3931. while (buffers.length > 0) {
  3932. var buffer = buffers.shift();
  3933. if (buffer.length > 0) {
  3934. destination.next(buffer);
  3935. }
  3936. }
  3937. _super.prototype._complete.call(this);
  3938. };
  3939. return BufferSkipCountSubscriber;
  3940. }(Subscriber));
  3941. function bufferTime(bufferTimeSpan) {
  3942. var length = arguments.length;
  3943. var scheduler = async;
  3944. if (isScheduler(arguments[arguments.length - 1])) {
  3945. scheduler = arguments[arguments.length - 1];
  3946. length--;
  3947. }
  3948. var bufferCreationInterval = null;
  3949. if (length >= 2) {
  3950. bufferCreationInterval = arguments[1];
  3951. }
  3952. var maxBufferSize = Number.POSITIVE_INFINITY;
  3953. if (length >= 3) {
  3954. maxBufferSize = arguments[2];
  3955. }
  3956. return function bufferTimeOperatorFunction(source) {
  3957. return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
  3958. };
  3959. }
  3960. var BufferTimeOperator = (function () {
  3961. function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
  3962. this.bufferTimeSpan = bufferTimeSpan;
  3963. this.bufferCreationInterval = bufferCreationInterval;
  3964. this.maxBufferSize = maxBufferSize;
  3965. this.scheduler = scheduler;
  3966. }
  3967. BufferTimeOperator.prototype.call = function (subscriber, source) {
  3968. return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
  3969. };
  3970. return BufferTimeOperator;
  3971. }());
  3972. var Context = (function () {
  3973. function Context() {
  3974. this.buffer = [];
  3975. }
  3976. return Context;
  3977. }());
  3978. var BufferTimeSubscriber = (function (_super) {
  3979. __extends(BufferTimeSubscriber, _super);
  3980. function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
  3981. var _this = _super.call(this, destination) || this;
  3982. _this.bufferTimeSpan = bufferTimeSpan;
  3983. _this.bufferCreationInterval = bufferCreationInterval;
  3984. _this.maxBufferSize = maxBufferSize;
  3985. _this.scheduler = scheduler;
  3986. _this.contexts = [];
  3987. var context = _this.openContext();
  3988. _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
  3989. if (_this.timespanOnly) {
  3990. var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
  3991. _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
  3992. }
  3993. else {
  3994. var closeState = { subscriber: _this, context: context };
  3995. var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
  3996. _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
  3997. _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
  3998. }
  3999. return _this;
  4000. }
  4001. BufferTimeSubscriber.prototype._next = function (value) {
  4002. var contexts = this.contexts;
  4003. var len = contexts.length;
  4004. var filledBufferContext;
  4005. for (var i = 0; i < len; i++) {
  4006. var context_1 = contexts[i];
  4007. var buffer = context_1.buffer;
  4008. buffer.push(value);
  4009. if (buffer.length == this.maxBufferSize) {
  4010. filledBufferContext = context_1;
  4011. }
  4012. }
  4013. if (filledBufferContext) {
  4014. this.onBufferFull(filledBufferContext);
  4015. }
  4016. };
  4017. BufferTimeSubscriber.prototype._error = function (err) {
  4018. this.contexts.length = 0;
  4019. _super.prototype._error.call(this, err);
  4020. };
  4021. BufferTimeSubscriber.prototype._complete = function () {
  4022. var _a = this, contexts = _a.contexts, destination = _a.destination;
  4023. while (contexts.length > 0) {
  4024. var context_2 = contexts.shift();
  4025. destination.next(context_2.buffer);
  4026. }
  4027. _super.prototype._complete.call(this);
  4028. };
  4029. BufferTimeSubscriber.prototype._unsubscribe = function () {
  4030. this.contexts = null;
  4031. };
  4032. BufferTimeSubscriber.prototype.onBufferFull = function (context) {
  4033. this.closeContext(context);
  4034. var closeAction = context.closeAction;
  4035. closeAction.unsubscribe();
  4036. this.remove(closeAction);
  4037. if (!this.closed && this.timespanOnly) {
  4038. context = this.openContext();
  4039. var bufferTimeSpan = this.bufferTimeSpan;
  4040. var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
  4041. this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
  4042. }
  4043. };
  4044. BufferTimeSubscriber.prototype.openContext = function () {
  4045. var context = new Context();
  4046. this.contexts.push(context);
  4047. return context;
  4048. };
  4049. BufferTimeSubscriber.prototype.closeContext = function (context) {
  4050. this.destination.next(context.buffer);
  4051. var contexts = this.contexts;
  4052. var spliceIndex = contexts ? contexts.indexOf(context) : -1;
  4053. if (spliceIndex >= 0) {
  4054. contexts.splice(contexts.indexOf(context), 1);
  4055. }
  4056. };
  4057. return BufferTimeSubscriber;
  4058. }(Subscriber));
  4059. function dispatchBufferTimeSpanOnly(state) {
  4060. var subscriber = state.subscriber;
  4061. var prevContext = state.context;
  4062. if (prevContext) {
  4063. subscriber.closeContext(prevContext);
  4064. }
  4065. if (!subscriber.closed) {
  4066. state.context = subscriber.openContext();
  4067. state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
  4068. }
  4069. }
  4070. function dispatchBufferCreation(state) {
  4071. var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
  4072. var context = subscriber.openContext();
  4073. var action = this;
  4074. if (!subscriber.closed) {
  4075. subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
  4076. action.schedule(state, bufferCreationInterval);
  4077. }
  4078. }
  4079. function dispatchBufferClose(arg) {
  4080. var subscriber = arg.subscriber, context = arg.context;
  4081. subscriber.closeContext(context);
  4082. }
  4083. function bufferToggle(openings, closingSelector) {
  4084. return function bufferToggleOperatorFunction(source) {
  4085. return source.lift(new BufferToggleOperator(openings, closingSelector));
  4086. };
  4087. }
  4088. var BufferToggleOperator = (function () {
  4089. function BufferToggleOperator(openings, closingSelector) {
  4090. this.openings = openings;
  4091. this.closingSelector = closingSelector;
  4092. }
  4093. BufferToggleOperator.prototype.call = function (subscriber, source) {
  4094. return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
  4095. };
  4096. return BufferToggleOperator;
  4097. }());
  4098. var BufferToggleSubscriber = (function (_super) {
  4099. __extends(BufferToggleSubscriber, _super);
  4100. function BufferToggleSubscriber(destination, openings, closingSelector) {
  4101. var _this = _super.call(this, destination) || this;
  4102. _this.openings = openings;
  4103. _this.closingSelector = closingSelector;
  4104. _this.contexts = [];
  4105. _this.add(subscribeToResult(_this, openings));
  4106. return _this;
  4107. }
  4108. BufferToggleSubscriber.prototype._next = function (value) {
  4109. var contexts = this.contexts;
  4110. var len = contexts.length;
  4111. for (var i = 0; i < len; i++) {
  4112. contexts[i].buffer.push(value);
  4113. }
  4114. };
  4115. BufferToggleSubscriber.prototype._error = function (err) {
  4116. var contexts = this.contexts;
  4117. while (contexts.length > 0) {
  4118. var context_1 = contexts.shift();
  4119. context_1.subscription.unsubscribe();
  4120. context_1.buffer = null;
  4121. context_1.subscription = null;
  4122. }
  4123. this.contexts = null;
  4124. _super.prototype._error.call(this, err);
  4125. };
  4126. BufferToggleSubscriber.prototype._complete = function () {
  4127. var contexts = this.contexts;
  4128. while (contexts.length > 0) {
  4129. var context_2 = contexts.shift();
  4130. this.destination.next(context_2.buffer);
  4131. context_2.subscription.unsubscribe();
  4132. context_2.buffer = null;
  4133. context_2.subscription = null;
  4134. }
  4135. this.contexts = null;
  4136. _super.prototype._complete.call(this);
  4137. };
  4138. BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4139. outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
  4140. };
  4141. BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
  4142. this.closeBuffer(innerSub.context);
  4143. };
  4144. BufferToggleSubscriber.prototype.openBuffer = function (value) {
  4145. try {
  4146. var closingSelector = this.closingSelector;
  4147. var closingNotifier = closingSelector.call(this, value);
  4148. if (closingNotifier) {
  4149. this.trySubscribe(closingNotifier);
  4150. }
  4151. }
  4152. catch (err) {
  4153. this._error(err);
  4154. }
  4155. };
  4156. BufferToggleSubscriber.prototype.closeBuffer = function (context) {
  4157. var contexts = this.contexts;
  4158. if (contexts && context) {
  4159. var buffer = context.buffer, subscription = context.subscription;
  4160. this.destination.next(buffer);
  4161. contexts.splice(contexts.indexOf(context), 1);
  4162. this.remove(subscription);
  4163. subscription.unsubscribe();
  4164. }
  4165. };
  4166. BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
  4167. var contexts = this.contexts;
  4168. var buffer = [];
  4169. var subscription = new Subscription();
  4170. var context = { buffer: buffer, subscription: subscription };
  4171. contexts.push(context);
  4172. var innerSubscription = subscribeToResult(this, closingNotifier, context);
  4173. if (!innerSubscription || innerSubscription.closed) {
  4174. this.closeBuffer(context);
  4175. }
  4176. else {
  4177. innerSubscription.context = context;
  4178. this.add(innerSubscription);
  4179. subscription.add(innerSubscription);
  4180. }
  4181. };
  4182. return BufferToggleSubscriber;
  4183. }(OuterSubscriber));
  4184. function bufferWhen(closingSelector) {
  4185. return function (source) {
  4186. return source.lift(new BufferWhenOperator(closingSelector));
  4187. };
  4188. }
  4189. var BufferWhenOperator = (function () {
  4190. function BufferWhenOperator(closingSelector) {
  4191. this.closingSelector = closingSelector;
  4192. }
  4193. BufferWhenOperator.prototype.call = function (subscriber, source) {
  4194. return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
  4195. };
  4196. return BufferWhenOperator;
  4197. }());
  4198. var BufferWhenSubscriber = (function (_super) {
  4199. __extends(BufferWhenSubscriber, _super);
  4200. function BufferWhenSubscriber(destination, closingSelector) {
  4201. var _this = _super.call(this, destination) || this;
  4202. _this.closingSelector = closingSelector;
  4203. _this.subscribing = false;
  4204. _this.openBuffer();
  4205. return _this;
  4206. }
  4207. BufferWhenSubscriber.prototype._next = function (value) {
  4208. this.buffer.push(value);
  4209. };
  4210. BufferWhenSubscriber.prototype._complete = function () {
  4211. var buffer = this.buffer;
  4212. if (buffer) {
  4213. this.destination.next(buffer);
  4214. }
  4215. _super.prototype._complete.call(this);
  4216. };
  4217. BufferWhenSubscriber.prototype._unsubscribe = function () {
  4218. this.buffer = null;
  4219. this.subscribing = false;
  4220. };
  4221. BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4222. this.openBuffer();
  4223. };
  4224. BufferWhenSubscriber.prototype.notifyComplete = function () {
  4225. if (this.subscribing) {
  4226. this.complete();
  4227. }
  4228. else {
  4229. this.openBuffer();
  4230. }
  4231. };
  4232. BufferWhenSubscriber.prototype.openBuffer = function () {
  4233. var closingSubscription = this.closingSubscription;
  4234. if (closingSubscription) {
  4235. this.remove(closingSubscription);
  4236. closingSubscription.unsubscribe();
  4237. }
  4238. var buffer = this.buffer;
  4239. if (this.buffer) {
  4240. this.destination.next(buffer);
  4241. }
  4242. this.buffer = [];
  4243. var closingNotifier;
  4244. try {
  4245. var closingSelector = this.closingSelector;
  4246. closingNotifier = closingSelector();
  4247. }
  4248. catch (err) {
  4249. return this.error(err);
  4250. }
  4251. closingSubscription = new Subscription();
  4252. this.closingSubscription = closingSubscription;
  4253. this.add(closingSubscription);
  4254. this.subscribing = true;
  4255. closingSubscription.add(subscribeToResult(this, closingNotifier));
  4256. this.subscribing = false;
  4257. };
  4258. return BufferWhenSubscriber;
  4259. }(OuterSubscriber));
  4260. function catchError(selector) {
  4261. return function catchErrorOperatorFunction(source) {
  4262. var operator = new CatchOperator(selector);
  4263. var caught = source.lift(operator);
  4264. return (operator.caught = caught);
  4265. };
  4266. }
  4267. var CatchOperator = (function () {
  4268. function CatchOperator(selector) {
  4269. this.selector = selector;
  4270. }
  4271. CatchOperator.prototype.call = function (subscriber, source) {
  4272. return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
  4273. };
  4274. return CatchOperator;
  4275. }());
  4276. var CatchSubscriber = (function (_super) {
  4277. __extends(CatchSubscriber, _super);
  4278. function CatchSubscriber(destination, selector, caught) {
  4279. var _this = _super.call(this, destination) || this;
  4280. _this.selector = selector;
  4281. _this.caught = caught;
  4282. return _this;
  4283. }
  4284. CatchSubscriber.prototype.error = function (err) {
  4285. if (!this.isStopped) {
  4286. var result = void 0;
  4287. try {
  4288. result = this.selector(err, this.caught);
  4289. }
  4290. catch (err2) {
  4291. _super.prototype.error.call(this, err2);
  4292. return;
  4293. }
  4294. this._unsubscribeAndRecycle();
  4295. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  4296. this.add(innerSubscriber);
  4297. subscribeToResult(this, result, undefined, undefined, innerSubscriber);
  4298. }
  4299. };
  4300. return CatchSubscriber;
  4301. }(OuterSubscriber));
  4302. function combineAll(project) {
  4303. return function (source) { return source.lift(new CombineLatestOperator(project)); };
  4304. }
  4305. function combineLatest$1() {
  4306. var observables = [];
  4307. for (var _i = 0; _i < arguments.length; _i++) {
  4308. observables[_i] = arguments[_i];
  4309. }
  4310. var project = null;
  4311. if (typeof observables[observables.length - 1] === 'function') {
  4312. project = observables.pop();
  4313. }
  4314. if (observables.length === 1 && isArray(observables[0])) {
  4315. observables = observables[0].slice();
  4316. }
  4317. return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
  4318. }
  4319. function concat$1() {
  4320. var observables = [];
  4321. for (var _i = 0; _i < arguments.length; _i++) {
  4322. observables[_i] = arguments[_i];
  4323. }
  4324. return function (source) { return source.lift.call(concat.apply(void 0, [source].concat(observables))); };
  4325. }
  4326. function concatMap(project, resultSelector) {
  4327. return mergeMap(project, resultSelector, 1);
  4328. }
  4329. function concatMapTo(innerObservable, resultSelector) {
  4330. return concatMap(function () { return innerObservable; }, resultSelector);
  4331. }
  4332. function count(predicate) {
  4333. return function (source) { return source.lift(new CountOperator(predicate, source)); };
  4334. }
  4335. var CountOperator = (function () {
  4336. function CountOperator(predicate, source) {
  4337. this.predicate = predicate;
  4338. this.source = source;
  4339. }
  4340. CountOperator.prototype.call = function (subscriber, source) {
  4341. return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
  4342. };
  4343. return CountOperator;
  4344. }());
  4345. var CountSubscriber = (function (_super) {
  4346. __extends(CountSubscriber, _super);
  4347. function CountSubscriber(destination, predicate, source) {
  4348. var _this = _super.call(this, destination) || this;
  4349. _this.predicate = predicate;
  4350. _this.source = source;
  4351. _this.count = 0;
  4352. _this.index = 0;
  4353. return _this;
  4354. }
  4355. CountSubscriber.prototype._next = function (value) {
  4356. if (this.predicate) {
  4357. this._tryPredicate(value);
  4358. }
  4359. else {
  4360. this.count++;
  4361. }
  4362. };
  4363. CountSubscriber.prototype._tryPredicate = function (value) {
  4364. var result;
  4365. try {
  4366. result = this.predicate(value, this.index++, this.source);
  4367. }
  4368. catch (err) {
  4369. this.destination.error(err);
  4370. return;
  4371. }
  4372. if (result) {
  4373. this.count++;
  4374. }
  4375. };
  4376. CountSubscriber.prototype._complete = function () {
  4377. this.destination.next(this.count);
  4378. this.destination.complete();
  4379. };
  4380. return CountSubscriber;
  4381. }(Subscriber));
  4382. function debounce(durationSelector) {
  4383. return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
  4384. }
  4385. var DebounceOperator = (function () {
  4386. function DebounceOperator(durationSelector) {
  4387. this.durationSelector = durationSelector;
  4388. }
  4389. DebounceOperator.prototype.call = function (subscriber, source) {
  4390. return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
  4391. };
  4392. return DebounceOperator;
  4393. }());
  4394. var DebounceSubscriber = (function (_super) {
  4395. __extends(DebounceSubscriber, _super);
  4396. function DebounceSubscriber(destination, durationSelector) {
  4397. var _this = _super.call(this, destination) || this;
  4398. _this.durationSelector = durationSelector;
  4399. _this.hasValue = false;
  4400. _this.durationSubscription = null;
  4401. return _this;
  4402. }
  4403. DebounceSubscriber.prototype._next = function (value) {
  4404. try {
  4405. var result = this.durationSelector.call(this, value);
  4406. if (result) {
  4407. this._tryNext(value, result);
  4408. }
  4409. }
  4410. catch (err) {
  4411. this.destination.error(err);
  4412. }
  4413. };
  4414. DebounceSubscriber.prototype._complete = function () {
  4415. this.emitValue();
  4416. this.destination.complete();
  4417. };
  4418. DebounceSubscriber.prototype._tryNext = function (value, duration) {
  4419. var subscription = this.durationSubscription;
  4420. this.value = value;
  4421. this.hasValue = true;
  4422. if (subscription) {
  4423. subscription.unsubscribe();
  4424. this.remove(subscription);
  4425. }
  4426. subscription = subscribeToResult(this, duration);
  4427. if (subscription && !subscription.closed) {
  4428. this.add(this.durationSubscription = subscription);
  4429. }
  4430. };
  4431. DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4432. this.emitValue();
  4433. };
  4434. DebounceSubscriber.prototype.notifyComplete = function () {
  4435. this.emitValue();
  4436. };
  4437. DebounceSubscriber.prototype.emitValue = function () {
  4438. if (this.hasValue) {
  4439. var value = this.value;
  4440. var subscription = this.durationSubscription;
  4441. if (subscription) {
  4442. this.durationSubscription = null;
  4443. subscription.unsubscribe();
  4444. this.remove(subscription);
  4445. }
  4446. this.value = null;
  4447. this.hasValue = false;
  4448. _super.prototype._next.call(this, value);
  4449. }
  4450. };
  4451. return DebounceSubscriber;
  4452. }(OuterSubscriber));
  4453. function debounceTime(dueTime, scheduler) {
  4454. if (scheduler === void 0) { scheduler = async; }
  4455. return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
  4456. }
  4457. var DebounceTimeOperator = (function () {
  4458. function DebounceTimeOperator(dueTime, scheduler) {
  4459. this.dueTime = dueTime;
  4460. this.scheduler = scheduler;
  4461. }
  4462. DebounceTimeOperator.prototype.call = function (subscriber, source) {
  4463. return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
  4464. };
  4465. return DebounceTimeOperator;
  4466. }());
  4467. var DebounceTimeSubscriber = (function (_super) {
  4468. __extends(DebounceTimeSubscriber, _super);
  4469. function DebounceTimeSubscriber(destination, dueTime, scheduler) {
  4470. var _this = _super.call(this, destination) || this;
  4471. _this.dueTime = dueTime;
  4472. _this.scheduler = scheduler;
  4473. _this.debouncedSubscription = null;
  4474. _this.lastValue = null;
  4475. _this.hasValue = false;
  4476. return _this;
  4477. }
  4478. DebounceTimeSubscriber.prototype._next = function (value) {
  4479. this.clearDebounce();
  4480. this.lastValue = value;
  4481. this.hasValue = true;
  4482. this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$2, this.dueTime, this));
  4483. };
  4484. DebounceTimeSubscriber.prototype._complete = function () {
  4485. this.debouncedNext();
  4486. this.destination.complete();
  4487. };
  4488. DebounceTimeSubscriber.prototype.debouncedNext = function () {
  4489. this.clearDebounce();
  4490. if (this.hasValue) {
  4491. var lastValue = this.lastValue;
  4492. this.lastValue = null;
  4493. this.hasValue = false;
  4494. this.destination.next(lastValue);
  4495. }
  4496. };
  4497. DebounceTimeSubscriber.prototype.clearDebounce = function () {
  4498. var debouncedSubscription = this.debouncedSubscription;
  4499. if (debouncedSubscription !== null) {
  4500. this.remove(debouncedSubscription);
  4501. debouncedSubscription.unsubscribe();
  4502. this.debouncedSubscription = null;
  4503. }
  4504. };
  4505. return DebounceTimeSubscriber;
  4506. }(Subscriber));
  4507. function dispatchNext$2(subscriber) {
  4508. subscriber.debouncedNext();
  4509. }
  4510. function defaultIfEmpty(defaultValue) {
  4511. if (defaultValue === void 0) { defaultValue = null; }
  4512. return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
  4513. }
  4514. var DefaultIfEmptyOperator = (function () {
  4515. function DefaultIfEmptyOperator(defaultValue) {
  4516. this.defaultValue = defaultValue;
  4517. }
  4518. DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
  4519. return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
  4520. };
  4521. return DefaultIfEmptyOperator;
  4522. }());
  4523. var DefaultIfEmptySubscriber = (function (_super) {
  4524. __extends(DefaultIfEmptySubscriber, _super);
  4525. function DefaultIfEmptySubscriber(destination, defaultValue) {
  4526. var _this = _super.call(this, destination) || this;
  4527. _this.defaultValue = defaultValue;
  4528. _this.isEmpty = true;
  4529. return _this;
  4530. }
  4531. DefaultIfEmptySubscriber.prototype._next = function (value) {
  4532. this.isEmpty = false;
  4533. this.destination.next(value);
  4534. };
  4535. DefaultIfEmptySubscriber.prototype._complete = function () {
  4536. if (this.isEmpty) {
  4537. this.destination.next(this.defaultValue);
  4538. }
  4539. this.destination.complete();
  4540. };
  4541. return DefaultIfEmptySubscriber;
  4542. }(Subscriber));
  4543. function isDate(value) {
  4544. return value instanceof Date && !isNaN(+value);
  4545. }
  4546. function delay(delay, scheduler) {
  4547. if (scheduler === void 0) { scheduler = async; }
  4548. var absoluteDelay = isDate(delay);
  4549. var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
  4550. return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
  4551. }
  4552. var DelayOperator = (function () {
  4553. function DelayOperator(delay, scheduler) {
  4554. this.delay = delay;
  4555. this.scheduler = scheduler;
  4556. }
  4557. DelayOperator.prototype.call = function (subscriber, source) {
  4558. return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
  4559. };
  4560. return DelayOperator;
  4561. }());
  4562. var DelaySubscriber = (function (_super) {
  4563. __extends(DelaySubscriber, _super);
  4564. function DelaySubscriber(destination, delay, scheduler) {
  4565. var _this = _super.call(this, destination) || this;
  4566. _this.delay = delay;
  4567. _this.scheduler = scheduler;
  4568. _this.queue = [];
  4569. _this.active = false;
  4570. _this.errored = false;
  4571. return _this;
  4572. }
  4573. DelaySubscriber.dispatch = function (state) {
  4574. var source = state.source;
  4575. var queue = source.queue;
  4576. var scheduler = state.scheduler;
  4577. var destination = state.destination;
  4578. while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
  4579. queue.shift().notification.observe(destination);
  4580. }
  4581. if (queue.length > 0) {
  4582. var delay_1 = Math.max(0, queue[0].time - scheduler.now());
  4583. this.schedule(state, delay_1);
  4584. }
  4585. else {
  4586. this.unsubscribe();
  4587. source.active = false;
  4588. }
  4589. };
  4590. DelaySubscriber.prototype._schedule = function (scheduler) {
  4591. this.active = true;
  4592. var destination = this.destination;
  4593. destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
  4594. source: this, destination: this.destination, scheduler: scheduler
  4595. }));
  4596. };
  4597. DelaySubscriber.prototype.scheduleNotification = function (notification) {
  4598. if (this.errored === true) {
  4599. return;
  4600. }
  4601. var scheduler = this.scheduler;
  4602. var message = new DelayMessage(scheduler.now() + this.delay, notification);
  4603. this.queue.push(message);
  4604. if (this.active === false) {
  4605. this._schedule(scheduler);
  4606. }
  4607. };
  4608. DelaySubscriber.prototype._next = function (value) {
  4609. this.scheduleNotification(Notification.createNext(value));
  4610. };
  4611. DelaySubscriber.prototype._error = function (err) {
  4612. this.errored = true;
  4613. this.queue = [];
  4614. this.destination.error(err);
  4615. this.unsubscribe();
  4616. };
  4617. DelaySubscriber.prototype._complete = function () {
  4618. this.scheduleNotification(Notification.createComplete());
  4619. this.unsubscribe();
  4620. };
  4621. return DelaySubscriber;
  4622. }(Subscriber));
  4623. var DelayMessage = (function () {
  4624. function DelayMessage(time, notification) {
  4625. this.time = time;
  4626. this.notification = notification;
  4627. }
  4628. return DelayMessage;
  4629. }());
  4630. function delayWhen(delayDurationSelector, subscriptionDelay) {
  4631. if (subscriptionDelay) {
  4632. return function (source) {
  4633. return new SubscriptionDelayObservable(source, subscriptionDelay)
  4634. .lift(new DelayWhenOperator(delayDurationSelector));
  4635. };
  4636. }
  4637. return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
  4638. }
  4639. var DelayWhenOperator = (function () {
  4640. function DelayWhenOperator(delayDurationSelector) {
  4641. this.delayDurationSelector = delayDurationSelector;
  4642. }
  4643. DelayWhenOperator.prototype.call = function (subscriber, source) {
  4644. return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
  4645. };
  4646. return DelayWhenOperator;
  4647. }());
  4648. var DelayWhenSubscriber = (function (_super) {
  4649. __extends(DelayWhenSubscriber, _super);
  4650. function DelayWhenSubscriber(destination, delayDurationSelector) {
  4651. var _this = _super.call(this, destination) || this;
  4652. _this.delayDurationSelector = delayDurationSelector;
  4653. _this.completed = false;
  4654. _this.delayNotifierSubscriptions = [];
  4655. _this.index = 0;
  4656. return _this;
  4657. }
  4658. DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4659. this.destination.next(outerValue);
  4660. this.removeSubscription(innerSub);
  4661. this.tryComplete();
  4662. };
  4663. DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
  4664. this._error(error);
  4665. };
  4666. DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
  4667. var value = this.removeSubscription(innerSub);
  4668. if (value) {
  4669. this.destination.next(value);
  4670. }
  4671. this.tryComplete();
  4672. };
  4673. DelayWhenSubscriber.prototype._next = function (value) {
  4674. var index = this.index++;
  4675. try {
  4676. var delayNotifier = this.delayDurationSelector(value, index);
  4677. if (delayNotifier) {
  4678. this.tryDelay(delayNotifier, value);
  4679. }
  4680. }
  4681. catch (err) {
  4682. this.destination.error(err);
  4683. }
  4684. };
  4685. DelayWhenSubscriber.prototype._complete = function () {
  4686. this.completed = true;
  4687. this.tryComplete();
  4688. this.unsubscribe();
  4689. };
  4690. DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
  4691. subscription.unsubscribe();
  4692. var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
  4693. if (subscriptionIdx !== -1) {
  4694. this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
  4695. }
  4696. return subscription.outerValue;
  4697. };
  4698. DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
  4699. var notifierSubscription = subscribeToResult(this, delayNotifier, value);
  4700. if (notifierSubscription && !notifierSubscription.closed) {
  4701. var destination = this.destination;
  4702. destination.add(notifierSubscription);
  4703. this.delayNotifierSubscriptions.push(notifierSubscription);
  4704. }
  4705. };
  4706. DelayWhenSubscriber.prototype.tryComplete = function () {
  4707. if (this.completed && this.delayNotifierSubscriptions.length === 0) {
  4708. this.destination.complete();
  4709. }
  4710. };
  4711. return DelayWhenSubscriber;
  4712. }(OuterSubscriber));
  4713. var SubscriptionDelayObservable = (function (_super) {
  4714. __extends(SubscriptionDelayObservable, _super);
  4715. function SubscriptionDelayObservable(source, subscriptionDelay) {
  4716. var _this = _super.call(this) || this;
  4717. _this.source = source;
  4718. _this.subscriptionDelay = subscriptionDelay;
  4719. return _this;
  4720. }
  4721. SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
  4722. this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
  4723. };
  4724. return SubscriptionDelayObservable;
  4725. }(Observable));
  4726. var SubscriptionDelaySubscriber = (function (_super) {
  4727. __extends(SubscriptionDelaySubscriber, _super);
  4728. function SubscriptionDelaySubscriber(parent, source) {
  4729. var _this = _super.call(this) || this;
  4730. _this.parent = parent;
  4731. _this.source = source;
  4732. _this.sourceSubscribed = false;
  4733. return _this;
  4734. }
  4735. SubscriptionDelaySubscriber.prototype._next = function (unused) {
  4736. this.subscribeToSource();
  4737. };
  4738. SubscriptionDelaySubscriber.prototype._error = function (err) {
  4739. this.unsubscribe();
  4740. this.parent.error(err);
  4741. };
  4742. SubscriptionDelaySubscriber.prototype._complete = function () {
  4743. this.unsubscribe();
  4744. this.subscribeToSource();
  4745. };
  4746. SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
  4747. if (!this.sourceSubscribed) {
  4748. this.sourceSubscribed = true;
  4749. this.unsubscribe();
  4750. this.source.subscribe(this.parent);
  4751. }
  4752. };
  4753. return SubscriptionDelaySubscriber;
  4754. }(Subscriber));
  4755. function dematerialize() {
  4756. return function dematerializeOperatorFunction(source) {
  4757. return source.lift(new DeMaterializeOperator());
  4758. };
  4759. }
  4760. var DeMaterializeOperator = (function () {
  4761. function DeMaterializeOperator() {
  4762. }
  4763. DeMaterializeOperator.prototype.call = function (subscriber, source) {
  4764. return source.subscribe(new DeMaterializeSubscriber(subscriber));
  4765. };
  4766. return DeMaterializeOperator;
  4767. }());
  4768. var DeMaterializeSubscriber = (function (_super) {
  4769. __extends(DeMaterializeSubscriber, _super);
  4770. function DeMaterializeSubscriber(destination) {
  4771. return _super.call(this, destination) || this;
  4772. }
  4773. DeMaterializeSubscriber.prototype._next = function (value) {
  4774. value.observe(this.destination);
  4775. };
  4776. return DeMaterializeSubscriber;
  4777. }(Subscriber));
  4778. function distinct(keySelector, flushes) {
  4779. return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
  4780. }
  4781. var DistinctOperator = (function () {
  4782. function DistinctOperator(keySelector, flushes) {
  4783. this.keySelector = keySelector;
  4784. this.flushes = flushes;
  4785. }
  4786. DistinctOperator.prototype.call = function (subscriber, source) {
  4787. return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
  4788. };
  4789. return DistinctOperator;
  4790. }());
  4791. var DistinctSubscriber = (function (_super) {
  4792. __extends(DistinctSubscriber, _super);
  4793. function DistinctSubscriber(destination, keySelector, flushes) {
  4794. var _this = _super.call(this, destination) || this;
  4795. _this.keySelector = keySelector;
  4796. _this.values = new Set();
  4797. if (flushes) {
  4798. _this.add(subscribeToResult(_this, flushes));
  4799. }
  4800. return _this;
  4801. }
  4802. DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4803. this.values.clear();
  4804. };
  4805. DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
  4806. this._error(error);
  4807. };
  4808. DistinctSubscriber.prototype._next = function (value) {
  4809. if (this.keySelector) {
  4810. this._useKeySelector(value);
  4811. }
  4812. else {
  4813. this._finalizeNext(value, value);
  4814. }
  4815. };
  4816. DistinctSubscriber.prototype._useKeySelector = function (value) {
  4817. var key;
  4818. var destination = this.destination;
  4819. try {
  4820. key = this.keySelector(value);
  4821. }
  4822. catch (err) {
  4823. destination.error(err);
  4824. return;
  4825. }
  4826. this._finalizeNext(key, value);
  4827. };
  4828. DistinctSubscriber.prototype._finalizeNext = function (key, value) {
  4829. var values = this.values;
  4830. if (!values.has(key)) {
  4831. values.add(key);
  4832. this.destination.next(value);
  4833. }
  4834. };
  4835. return DistinctSubscriber;
  4836. }(OuterSubscriber));
  4837. function distinctUntilChanged(compare, keySelector) {
  4838. return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
  4839. }
  4840. var DistinctUntilChangedOperator = (function () {
  4841. function DistinctUntilChangedOperator(compare, keySelector) {
  4842. this.compare = compare;
  4843. this.keySelector = keySelector;
  4844. }
  4845. DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
  4846. return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
  4847. };
  4848. return DistinctUntilChangedOperator;
  4849. }());
  4850. var DistinctUntilChangedSubscriber = (function (_super) {
  4851. __extends(DistinctUntilChangedSubscriber, _super);
  4852. function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
  4853. var _this = _super.call(this, destination) || this;
  4854. _this.keySelector = keySelector;
  4855. _this.hasKey = false;
  4856. if (typeof compare === 'function') {
  4857. _this.compare = compare;
  4858. }
  4859. return _this;
  4860. }
  4861. DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
  4862. return x === y;
  4863. };
  4864. DistinctUntilChangedSubscriber.prototype._next = function (value) {
  4865. var key;
  4866. try {
  4867. var keySelector = this.keySelector;
  4868. key = keySelector ? keySelector(value) : value;
  4869. }
  4870. catch (err) {
  4871. return this.destination.error(err);
  4872. }
  4873. var result = false;
  4874. if (this.hasKey) {
  4875. try {
  4876. var compare = this.compare;
  4877. result = compare(this.key, key);
  4878. }
  4879. catch (err) {
  4880. return this.destination.error(err);
  4881. }
  4882. }
  4883. else {
  4884. this.hasKey = true;
  4885. }
  4886. if (!result) {
  4887. this.key = key;
  4888. this.destination.next(value);
  4889. }
  4890. };
  4891. return DistinctUntilChangedSubscriber;
  4892. }(Subscriber));
  4893. function distinctUntilKeyChanged(key, compare) {
  4894. return distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
  4895. }
  4896. function throwIfEmpty(errorFactory) {
  4897. if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
  4898. return function (source) {
  4899. return source.lift(new ThrowIfEmptyOperator(errorFactory));
  4900. };
  4901. }
  4902. var ThrowIfEmptyOperator = (function () {
  4903. function ThrowIfEmptyOperator(errorFactory) {
  4904. this.errorFactory = errorFactory;
  4905. }
  4906. ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
  4907. return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
  4908. };
  4909. return ThrowIfEmptyOperator;
  4910. }());
  4911. var ThrowIfEmptySubscriber = (function (_super) {
  4912. __extends(ThrowIfEmptySubscriber, _super);
  4913. function ThrowIfEmptySubscriber(destination, errorFactory) {
  4914. var _this = _super.call(this, destination) || this;
  4915. _this.errorFactory = errorFactory;
  4916. _this.hasValue = false;
  4917. return _this;
  4918. }
  4919. ThrowIfEmptySubscriber.prototype._next = function (value) {
  4920. this.hasValue = true;
  4921. this.destination.next(value);
  4922. };
  4923. ThrowIfEmptySubscriber.prototype._complete = function () {
  4924. if (!this.hasValue) {
  4925. var err = void 0;
  4926. try {
  4927. err = this.errorFactory();
  4928. }
  4929. catch (e) {
  4930. err = e;
  4931. }
  4932. this.destination.error(err);
  4933. }
  4934. else {
  4935. return this.destination.complete();
  4936. }
  4937. };
  4938. return ThrowIfEmptySubscriber;
  4939. }(Subscriber));
  4940. function defaultErrorFactory() {
  4941. return new EmptyError();
  4942. }
  4943. function take(count) {
  4944. return function (source) {
  4945. if (count === 0) {
  4946. return empty$1();
  4947. }
  4948. else {
  4949. return source.lift(new TakeOperator(count));
  4950. }
  4951. };
  4952. }
  4953. var TakeOperator = (function () {
  4954. function TakeOperator(total) {
  4955. this.total = total;
  4956. if (this.total < 0) {
  4957. throw new ArgumentOutOfRangeError;
  4958. }
  4959. }
  4960. TakeOperator.prototype.call = function (subscriber, source) {
  4961. return source.subscribe(new TakeSubscriber(subscriber, this.total));
  4962. };
  4963. return TakeOperator;
  4964. }());
  4965. var TakeSubscriber = (function (_super) {
  4966. __extends(TakeSubscriber, _super);
  4967. function TakeSubscriber(destination, total) {
  4968. var _this = _super.call(this, destination) || this;
  4969. _this.total = total;
  4970. _this.count = 0;
  4971. return _this;
  4972. }
  4973. TakeSubscriber.prototype._next = function (value) {
  4974. var total = this.total;
  4975. var count = ++this.count;
  4976. if (count <= total) {
  4977. this.destination.next(value);
  4978. if (count === total) {
  4979. this.destination.complete();
  4980. this.unsubscribe();
  4981. }
  4982. }
  4983. };
  4984. return TakeSubscriber;
  4985. }(Subscriber));
  4986. function elementAt(index, defaultValue) {
  4987. if (index < 0) {
  4988. throw new ArgumentOutOfRangeError();
  4989. }
  4990. var hasDefaultValue = arguments.length >= 2;
  4991. return function (source) { return source.pipe(filter(function (v, i) { return i === index; }), take(1), hasDefaultValue
  4992. ? defaultIfEmpty(defaultValue)
  4993. : throwIfEmpty(function () { return new ArgumentOutOfRangeError(); })); };
  4994. }
  4995. function endWith() {
  4996. var array = [];
  4997. for (var _i = 0; _i < arguments.length; _i++) {
  4998. array[_i] = arguments[_i];
  4999. }
  5000. return function (source) { return concat(source, of.apply(void 0, array)); };
  5001. }
  5002. function every(predicate, thisArg) {
  5003. return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
  5004. }
  5005. var EveryOperator = (function () {
  5006. function EveryOperator(predicate, thisArg, source) {
  5007. this.predicate = predicate;
  5008. this.thisArg = thisArg;
  5009. this.source = source;
  5010. }
  5011. EveryOperator.prototype.call = function (observer, source) {
  5012. return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
  5013. };
  5014. return EveryOperator;
  5015. }());
  5016. var EverySubscriber = (function (_super) {
  5017. __extends(EverySubscriber, _super);
  5018. function EverySubscriber(destination, predicate, thisArg, source) {
  5019. var _this = _super.call(this, destination) || this;
  5020. _this.predicate = predicate;
  5021. _this.thisArg = thisArg;
  5022. _this.source = source;
  5023. _this.index = 0;
  5024. _this.thisArg = thisArg || _this;
  5025. return _this;
  5026. }
  5027. EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
  5028. this.destination.next(everyValueMatch);
  5029. this.destination.complete();
  5030. };
  5031. EverySubscriber.prototype._next = function (value) {
  5032. var result = false;
  5033. try {
  5034. result = this.predicate.call(this.thisArg, value, this.index++, this.source);
  5035. }
  5036. catch (err) {
  5037. this.destination.error(err);
  5038. return;
  5039. }
  5040. if (!result) {
  5041. this.notifyComplete(false);
  5042. }
  5043. };
  5044. EverySubscriber.prototype._complete = function () {
  5045. this.notifyComplete(true);
  5046. };
  5047. return EverySubscriber;
  5048. }(Subscriber));
  5049. function exhaust() {
  5050. return function (source) { return source.lift(new SwitchFirstOperator()); };
  5051. }
  5052. var SwitchFirstOperator = (function () {
  5053. function SwitchFirstOperator() {
  5054. }
  5055. SwitchFirstOperator.prototype.call = function (subscriber, source) {
  5056. return source.subscribe(new SwitchFirstSubscriber(subscriber));
  5057. };
  5058. return SwitchFirstOperator;
  5059. }());
  5060. var SwitchFirstSubscriber = (function (_super) {
  5061. __extends(SwitchFirstSubscriber, _super);
  5062. function SwitchFirstSubscriber(destination) {
  5063. var _this = _super.call(this, destination) || this;
  5064. _this.hasCompleted = false;
  5065. _this.hasSubscription = false;
  5066. return _this;
  5067. }
  5068. SwitchFirstSubscriber.prototype._next = function (value) {
  5069. if (!this.hasSubscription) {
  5070. this.hasSubscription = true;
  5071. this.add(subscribeToResult(this, value));
  5072. }
  5073. };
  5074. SwitchFirstSubscriber.prototype._complete = function () {
  5075. this.hasCompleted = true;
  5076. if (!this.hasSubscription) {
  5077. this.destination.complete();
  5078. }
  5079. };
  5080. SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
  5081. this.remove(innerSub);
  5082. this.hasSubscription = false;
  5083. if (this.hasCompleted) {
  5084. this.destination.complete();
  5085. }
  5086. };
  5087. return SwitchFirstSubscriber;
  5088. }(OuterSubscriber));
  5089. function exhaustMap(project, resultSelector) {
  5090. if (resultSelector) {
  5091. return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
  5092. }
  5093. return function (source) {
  5094. return source.lift(new ExhaustMapOperator(project));
  5095. };
  5096. }
  5097. var ExhaustMapOperator = (function () {
  5098. function ExhaustMapOperator(project) {
  5099. this.project = project;
  5100. }
  5101. ExhaustMapOperator.prototype.call = function (subscriber, source) {
  5102. return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
  5103. };
  5104. return ExhaustMapOperator;
  5105. }());
  5106. var ExhaustMapSubscriber = (function (_super) {
  5107. __extends(ExhaustMapSubscriber, _super);
  5108. function ExhaustMapSubscriber(destination, project) {
  5109. var _this = _super.call(this, destination) || this;
  5110. _this.project = project;
  5111. _this.hasSubscription = false;
  5112. _this.hasCompleted = false;
  5113. _this.index = 0;
  5114. return _this;
  5115. }
  5116. ExhaustMapSubscriber.prototype._next = function (value) {
  5117. if (!this.hasSubscription) {
  5118. this.tryNext(value);
  5119. }
  5120. };
  5121. ExhaustMapSubscriber.prototype.tryNext = function (value) {
  5122. var result;
  5123. var index = this.index++;
  5124. try {
  5125. result = this.project(value, index);
  5126. }
  5127. catch (err) {
  5128. this.destination.error(err);
  5129. return;
  5130. }
  5131. this.hasSubscription = true;
  5132. this._innerSub(result, value, index);
  5133. };
  5134. ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
  5135. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  5136. var destination = this.destination;
  5137. destination.add(innerSubscriber);
  5138. subscribeToResult(this, result, value, index, innerSubscriber);
  5139. };
  5140. ExhaustMapSubscriber.prototype._complete = function () {
  5141. this.hasCompleted = true;
  5142. if (!this.hasSubscription) {
  5143. this.destination.complete();
  5144. }
  5145. this.unsubscribe();
  5146. };
  5147. ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  5148. this.destination.next(innerValue);
  5149. };
  5150. ExhaustMapSubscriber.prototype.notifyError = function (err) {
  5151. this.destination.error(err);
  5152. };
  5153. ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
  5154. var destination = this.destination;
  5155. destination.remove(innerSub);
  5156. this.hasSubscription = false;
  5157. if (this.hasCompleted) {
  5158. this.destination.complete();
  5159. }
  5160. };
  5161. return ExhaustMapSubscriber;
  5162. }(OuterSubscriber));
  5163. function expand(project, concurrent, scheduler) {
  5164. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  5165. if (scheduler === void 0) { scheduler = undefined; }
  5166. concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
  5167. return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
  5168. }
  5169. var ExpandOperator = (function () {
  5170. function ExpandOperator(project, concurrent, scheduler) {
  5171. this.project = project;
  5172. this.concurrent = concurrent;
  5173. this.scheduler = scheduler;
  5174. }
  5175. ExpandOperator.prototype.call = function (subscriber, source) {
  5176. return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
  5177. };
  5178. return ExpandOperator;
  5179. }());
  5180. var ExpandSubscriber = (function (_super) {
  5181. __extends(ExpandSubscriber, _super);
  5182. function ExpandSubscriber(destination, project, concurrent, scheduler) {
  5183. var _this = _super.call(this, destination) || this;
  5184. _this.project = project;
  5185. _this.concurrent = concurrent;
  5186. _this.scheduler = scheduler;
  5187. _this.index = 0;
  5188. _this.active = 0;
  5189. _this.hasCompleted = false;
  5190. if (concurrent < Number.POSITIVE_INFINITY) {
  5191. _this.buffer = [];
  5192. }
  5193. return _this;
  5194. }
  5195. ExpandSubscriber.dispatch = function (arg) {
  5196. var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
  5197. subscriber.subscribeToProjection(result, value, index);
  5198. };
  5199. ExpandSubscriber.prototype._next = function (value) {
  5200. var destination = this.destination;
  5201. if (destination.closed) {
  5202. this._complete();
  5203. return;
  5204. }
  5205. var index = this.index++;
  5206. if (this.active < this.concurrent) {
  5207. destination.next(value);
  5208. try {
  5209. var project = this.project;
  5210. var result = project(value, index);
  5211. if (!this.scheduler) {
  5212. this.subscribeToProjection(result, value, index);
  5213. }
  5214. else {
  5215. var state = { subscriber: this, result: result, value: value, index: index };
  5216. var destination_1 = this.destination;
  5217. destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
  5218. }
  5219. }
  5220. catch (e) {
  5221. destination.error(e);
  5222. }
  5223. }
  5224. else {
  5225. this.buffer.push(value);
  5226. }
  5227. };
  5228. ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
  5229. this.active++;
  5230. var destination = this.destination;
  5231. destination.add(subscribeToResult(this, result, value, index));
  5232. };
  5233. ExpandSubscriber.prototype._complete = function () {
  5234. this.hasCompleted = true;
  5235. if (this.hasCompleted && this.active === 0) {
  5236. this.destination.complete();
  5237. }
  5238. this.unsubscribe();
  5239. };
  5240. ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  5241. this._next(innerValue);
  5242. };
  5243. ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
  5244. var buffer = this.buffer;
  5245. var destination = this.destination;
  5246. destination.remove(innerSub);
  5247. this.active--;
  5248. if (buffer && buffer.length > 0) {
  5249. this._next(buffer.shift());
  5250. }
  5251. if (this.hasCompleted && this.active === 0) {
  5252. this.destination.complete();
  5253. }
  5254. };
  5255. return ExpandSubscriber;
  5256. }(OuterSubscriber));
  5257. function finalize(callback) {
  5258. return function (source) { return source.lift(new FinallyOperator(callback)); };
  5259. }
  5260. var FinallyOperator = (function () {
  5261. function FinallyOperator(callback) {
  5262. this.callback = callback;
  5263. }
  5264. FinallyOperator.prototype.call = function (subscriber, source) {
  5265. return source.subscribe(new FinallySubscriber(subscriber, this.callback));
  5266. };
  5267. return FinallyOperator;
  5268. }());
  5269. var FinallySubscriber = (function (_super) {
  5270. __extends(FinallySubscriber, _super);
  5271. function FinallySubscriber(destination, callback) {
  5272. var _this = _super.call(this, destination) || this;
  5273. _this.add(new Subscription(callback));
  5274. return _this;
  5275. }
  5276. return FinallySubscriber;
  5277. }(Subscriber));
  5278. function find(predicate, thisArg) {
  5279. if (typeof predicate !== 'function') {
  5280. throw new TypeError('predicate is not a function');
  5281. }
  5282. return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
  5283. }
  5284. var FindValueOperator = (function () {
  5285. function FindValueOperator(predicate, source, yieldIndex, thisArg) {
  5286. this.predicate = predicate;
  5287. this.source = source;
  5288. this.yieldIndex = yieldIndex;
  5289. this.thisArg = thisArg;
  5290. }
  5291. FindValueOperator.prototype.call = function (observer, source) {
  5292. return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
  5293. };
  5294. return FindValueOperator;
  5295. }());
  5296. var FindValueSubscriber = (function (_super) {
  5297. __extends(FindValueSubscriber, _super);
  5298. function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
  5299. var _this = _super.call(this, destination) || this;
  5300. _this.predicate = predicate;
  5301. _this.source = source;
  5302. _this.yieldIndex = yieldIndex;
  5303. _this.thisArg = thisArg;
  5304. _this.index = 0;
  5305. return _this;
  5306. }
  5307. FindValueSubscriber.prototype.notifyComplete = function (value) {
  5308. var destination = this.destination;
  5309. destination.next(value);
  5310. destination.complete();
  5311. this.unsubscribe();
  5312. };
  5313. FindValueSubscriber.prototype._next = function (value) {
  5314. var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
  5315. var index = this.index++;
  5316. try {
  5317. var result = predicate.call(thisArg || this, value, index, this.source);
  5318. if (result) {
  5319. this.notifyComplete(this.yieldIndex ? index : value);
  5320. }
  5321. }
  5322. catch (err) {
  5323. this.destination.error(err);
  5324. }
  5325. };
  5326. FindValueSubscriber.prototype._complete = function () {
  5327. this.notifyComplete(this.yieldIndex ? -1 : undefined);
  5328. };
  5329. return FindValueSubscriber;
  5330. }(Subscriber));
  5331. function findIndex(predicate, thisArg) {
  5332. return function (source) { return source.lift(new FindValueOperator(predicate, source, true, thisArg)); };
  5333. }
  5334. function first(predicate, defaultValue) {
  5335. var hasDefaultValue = arguments.length >= 2;
  5336. return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
  5337. }
  5338. function ignoreElements() {
  5339. return function ignoreElementsOperatorFunction(source) {
  5340. return source.lift(new IgnoreElementsOperator());
  5341. };
  5342. }
  5343. var IgnoreElementsOperator = (function () {
  5344. function IgnoreElementsOperator() {
  5345. }
  5346. IgnoreElementsOperator.prototype.call = function (subscriber, source) {
  5347. return source.subscribe(new IgnoreElementsSubscriber(subscriber));
  5348. };
  5349. return IgnoreElementsOperator;
  5350. }());
  5351. var IgnoreElementsSubscriber = (function (_super) {
  5352. __extends(IgnoreElementsSubscriber, _super);
  5353. function IgnoreElementsSubscriber() {
  5354. return _super !== null && _super.apply(this, arguments) || this;
  5355. }
  5356. IgnoreElementsSubscriber.prototype._next = function (unused) {
  5357. };
  5358. return IgnoreElementsSubscriber;
  5359. }(Subscriber));
  5360. function isEmpty() {
  5361. return function (source) { return source.lift(new IsEmptyOperator()); };
  5362. }
  5363. var IsEmptyOperator = (function () {
  5364. function IsEmptyOperator() {
  5365. }
  5366. IsEmptyOperator.prototype.call = function (observer, source) {
  5367. return source.subscribe(new IsEmptySubscriber(observer));
  5368. };
  5369. return IsEmptyOperator;
  5370. }());
  5371. var IsEmptySubscriber = (function (_super) {
  5372. __extends(IsEmptySubscriber, _super);
  5373. function IsEmptySubscriber(destination) {
  5374. return _super.call(this, destination) || this;
  5375. }
  5376. IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
  5377. var destination = this.destination;
  5378. destination.next(isEmpty);
  5379. destination.complete();
  5380. };
  5381. IsEmptySubscriber.prototype._next = function (value) {
  5382. this.notifyComplete(false);
  5383. };
  5384. IsEmptySubscriber.prototype._complete = function () {
  5385. this.notifyComplete(true);
  5386. };
  5387. return IsEmptySubscriber;
  5388. }(Subscriber));
  5389. function takeLast(count) {
  5390. return function takeLastOperatorFunction(source) {
  5391. if (count === 0) {
  5392. return empty$1();
  5393. }
  5394. else {
  5395. return source.lift(new TakeLastOperator(count));
  5396. }
  5397. };
  5398. }
  5399. var TakeLastOperator = (function () {
  5400. function TakeLastOperator(total) {
  5401. this.total = total;
  5402. if (this.total < 0) {
  5403. throw new ArgumentOutOfRangeError;
  5404. }
  5405. }
  5406. TakeLastOperator.prototype.call = function (subscriber, source) {
  5407. return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
  5408. };
  5409. return TakeLastOperator;
  5410. }());
  5411. var TakeLastSubscriber = (function (_super) {
  5412. __extends(TakeLastSubscriber, _super);
  5413. function TakeLastSubscriber(destination, total) {
  5414. var _this = _super.call(this, destination) || this;
  5415. _this.total = total;
  5416. _this.ring = new Array();
  5417. _this.count = 0;
  5418. return _this;
  5419. }
  5420. TakeLastSubscriber.prototype._next = function (value) {
  5421. var ring = this.ring;
  5422. var total = this.total;
  5423. var count = this.count++;
  5424. if (ring.length < total) {
  5425. ring.push(value);
  5426. }
  5427. else {
  5428. var index = count % total;
  5429. ring[index] = value;
  5430. }
  5431. };
  5432. TakeLastSubscriber.prototype._complete = function () {
  5433. var destination = this.destination;
  5434. var count = this.count;
  5435. if (count > 0) {
  5436. var total = this.count >= this.total ? this.total : this.count;
  5437. var ring = this.ring;
  5438. for (var i = 0; i < total; i++) {
  5439. var idx = (count++) % total;
  5440. destination.next(ring[idx]);
  5441. }
  5442. }
  5443. destination.complete();
  5444. };
  5445. return TakeLastSubscriber;
  5446. }(Subscriber));
  5447. function last(predicate, defaultValue) {
  5448. var hasDefaultValue = arguments.length >= 2;
  5449. return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
  5450. }
  5451. function mapTo(value) {
  5452. return function (source) { return source.lift(new MapToOperator(value)); };
  5453. }
  5454. var MapToOperator = (function () {
  5455. function MapToOperator(value) {
  5456. this.value = value;
  5457. }
  5458. MapToOperator.prototype.call = function (subscriber, source) {
  5459. return source.subscribe(new MapToSubscriber(subscriber, this.value));
  5460. };
  5461. return MapToOperator;
  5462. }());
  5463. var MapToSubscriber = (function (_super) {
  5464. __extends(MapToSubscriber, _super);
  5465. function MapToSubscriber(destination, value) {
  5466. var _this = _super.call(this, destination) || this;
  5467. _this.value = value;
  5468. return _this;
  5469. }
  5470. MapToSubscriber.prototype._next = function (x) {
  5471. this.destination.next(this.value);
  5472. };
  5473. return MapToSubscriber;
  5474. }(Subscriber));
  5475. function materialize() {
  5476. return function materializeOperatorFunction(source) {
  5477. return source.lift(new MaterializeOperator());
  5478. };
  5479. }
  5480. var MaterializeOperator = (function () {
  5481. function MaterializeOperator() {
  5482. }
  5483. MaterializeOperator.prototype.call = function (subscriber, source) {
  5484. return source.subscribe(new MaterializeSubscriber(subscriber));
  5485. };
  5486. return MaterializeOperator;
  5487. }());
  5488. var MaterializeSubscriber = (function (_super) {
  5489. __extends(MaterializeSubscriber, _super);
  5490. function MaterializeSubscriber(destination) {
  5491. return _super.call(this, destination) || this;
  5492. }
  5493. MaterializeSubscriber.prototype._next = function (value) {
  5494. this.destination.next(Notification.createNext(value));
  5495. };
  5496. MaterializeSubscriber.prototype._error = function (err) {
  5497. var destination = this.destination;
  5498. destination.next(Notification.createError(err));
  5499. destination.complete();
  5500. };
  5501. MaterializeSubscriber.prototype._complete = function () {
  5502. var destination = this.destination;
  5503. destination.next(Notification.createComplete());
  5504. destination.complete();
  5505. };
  5506. return MaterializeSubscriber;
  5507. }(Subscriber));
  5508. function scan(accumulator, seed) {
  5509. var hasSeed = false;
  5510. if (arguments.length >= 2) {
  5511. hasSeed = true;
  5512. }
  5513. return function scanOperatorFunction(source) {
  5514. return source.lift(new ScanOperator(accumulator, seed, hasSeed));
  5515. };
  5516. }
  5517. var ScanOperator = (function () {
  5518. function ScanOperator(accumulator, seed, hasSeed) {
  5519. if (hasSeed === void 0) { hasSeed = false; }
  5520. this.accumulator = accumulator;
  5521. this.seed = seed;
  5522. this.hasSeed = hasSeed;
  5523. }
  5524. ScanOperator.prototype.call = function (subscriber, source) {
  5525. return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
  5526. };
  5527. return ScanOperator;
  5528. }());
  5529. var ScanSubscriber = (function (_super) {
  5530. __extends(ScanSubscriber, _super);
  5531. function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
  5532. var _this = _super.call(this, destination) || this;
  5533. _this.accumulator = accumulator;
  5534. _this._seed = _seed;
  5535. _this.hasSeed = hasSeed;
  5536. _this.index = 0;
  5537. return _this;
  5538. }
  5539. Object.defineProperty(ScanSubscriber.prototype, "seed", {
  5540. get: function () {
  5541. return this._seed;
  5542. },
  5543. set: function (value) {
  5544. this.hasSeed = true;
  5545. this._seed = value;
  5546. },
  5547. enumerable: true,
  5548. configurable: true
  5549. });
  5550. ScanSubscriber.prototype._next = function (value) {
  5551. if (!this.hasSeed) {
  5552. this.seed = value;
  5553. this.destination.next(value);
  5554. }
  5555. else {
  5556. return this._tryNext(value);
  5557. }
  5558. };
  5559. ScanSubscriber.prototype._tryNext = function (value) {
  5560. var index = this.index++;
  5561. var result;
  5562. try {
  5563. result = this.accumulator(this.seed, value, index);
  5564. }
  5565. catch (err) {
  5566. this.destination.error(err);
  5567. }
  5568. this.seed = result;
  5569. this.destination.next(result);
  5570. };
  5571. return ScanSubscriber;
  5572. }(Subscriber));
  5573. function reduce(accumulator, seed) {
  5574. if (arguments.length >= 2) {
  5575. return function reduceOperatorFunctionWithSeed(source) {
  5576. return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
  5577. };
  5578. }
  5579. return function reduceOperatorFunction(source) {
  5580. return pipe(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);
  5581. };
  5582. }
  5583. function max(comparer) {
  5584. var max = (typeof comparer === 'function')
  5585. ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
  5586. : function (x, y) { return x > y ? x : y; };
  5587. return reduce(max);
  5588. }
  5589. function merge$1() {
  5590. var observables = [];
  5591. for (var _i = 0; _i < arguments.length; _i++) {
  5592. observables[_i] = arguments[_i];
  5593. }
  5594. return function (source) { return source.lift.call(merge.apply(void 0, [source].concat(observables))); };
  5595. }
  5596. function mergeMapTo(innerObservable, resultSelector, concurrent) {
  5597. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  5598. if (typeof resultSelector === 'function') {
  5599. return mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
  5600. }
  5601. if (typeof resultSelector === 'number') {
  5602. concurrent = resultSelector;
  5603. }
  5604. return mergeMap(function () { return innerObservable; }, concurrent);
  5605. }
  5606. function mergeScan(accumulator, seed, concurrent) {
  5607. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  5608. return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
  5609. }
  5610. var MergeScanOperator = (function () {
  5611. function MergeScanOperator(accumulator, seed, concurrent) {
  5612. this.accumulator = accumulator;
  5613. this.seed = seed;
  5614. this.concurrent = concurrent;
  5615. }
  5616. MergeScanOperator.prototype.call = function (subscriber, source) {
  5617. return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
  5618. };
  5619. return MergeScanOperator;
  5620. }());
  5621. var MergeScanSubscriber = (function (_super) {
  5622. __extends(MergeScanSubscriber, _super);
  5623. function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
  5624. var _this = _super.call(this, destination) || this;
  5625. _this.accumulator = accumulator;
  5626. _this.acc = acc;
  5627. _this.concurrent = concurrent;
  5628. _this.hasValue = false;
  5629. _this.hasCompleted = false;
  5630. _this.buffer = [];
  5631. _this.active = 0;
  5632. _this.index = 0;
  5633. return _this;
  5634. }
  5635. MergeScanSubscriber.prototype._next = function (value) {
  5636. if (this.active < this.concurrent) {
  5637. var index = this.index++;
  5638. var destination = this.destination;
  5639. var ish = void 0;
  5640. try {
  5641. var accumulator = this.accumulator;
  5642. ish = accumulator(this.acc, value, index);
  5643. }
  5644. catch (e) {
  5645. return destination.error(e);
  5646. }
  5647. this.active++;
  5648. this._innerSub(ish, value, index);
  5649. }
  5650. else {
  5651. this.buffer.push(value);
  5652. }
  5653. };
  5654. MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
  5655. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  5656. var destination = this.destination;
  5657. destination.add(innerSubscriber);
  5658. subscribeToResult(this, ish, value, index, innerSubscriber);
  5659. };
  5660. MergeScanSubscriber.prototype._complete = function () {
  5661. this.hasCompleted = true;
  5662. if (this.active === 0 && this.buffer.length === 0) {
  5663. if (this.hasValue === false) {
  5664. this.destination.next(this.acc);
  5665. }
  5666. this.destination.complete();
  5667. }
  5668. this.unsubscribe();
  5669. };
  5670. MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  5671. var destination = this.destination;
  5672. this.acc = innerValue;
  5673. this.hasValue = true;
  5674. destination.next(innerValue);
  5675. };
  5676. MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
  5677. var buffer = this.buffer;
  5678. var destination = this.destination;
  5679. destination.remove(innerSub);
  5680. this.active--;
  5681. if (buffer.length > 0) {
  5682. this._next(buffer.shift());
  5683. }
  5684. else if (this.active === 0 && this.hasCompleted) {
  5685. if (this.hasValue === false) {
  5686. this.destination.next(this.acc);
  5687. }
  5688. this.destination.complete();
  5689. }
  5690. };
  5691. return MergeScanSubscriber;
  5692. }(OuterSubscriber));
  5693. function min(comparer) {
  5694. var min = (typeof comparer === 'function')
  5695. ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
  5696. : function (x, y) { return x < y ? x : y; };
  5697. return reduce(min);
  5698. }
  5699. function multicast(subjectOrSubjectFactory, selector) {
  5700. return function multicastOperatorFunction(source) {
  5701. var subjectFactory;
  5702. if (typeof subjectOrSubjectFactory === 'function') {
  5703. subjectFactory = subjectOrSubjectFactory;
  5704. }
  5705. else {
  5706. subjectFactory = function subjectFactory() {
  5707. return subjectOrSubjectFactory;
  5708. };
  5709. }
  5710. if (typeof selector === 'function') {
  5711. return source.lift(new MulticastOperator(subjectFactory, selector));
  5712. }
  5713. var connectable = Object.create(source, connectableObservableDescriptor);
  5714. connectable.source = source;
  5715. connectable.subjectFactory = subjectFactory;
  5716. return connectable;
  5717. };
  5718. }
  5719. var MulticastOperator = (function () {
  5720. function MulticastOperator(subjectFactory, selector) {
  5721. this.subjectFactory = subjectFactory;
  5722. this.selector = selector;
  5723. }
  5724. MulticastOperator.prototype.call = function (subscriber, source) {
  5725. var selector = this.selector;
  5726. var subject = this.subjectFactory();
  5727. var subscription = selector(subject).subscribe(subscriber);
  5728. subscription.add(source.subscribe(subject));
  5729. return subscription;
  5730. };
  5731. return MulticastOperator;
  5732. }());
  5733. function onErrorResumeNext$1() {
  5734. var nextSources = [];
  5735. for (var _i = 0; _i < arguments.length; _i++) {
  5736. nextSources[_i] = arguments[_i];
  5737. }
  5738. if (nextSources.length === 1 && isArray(nextSources[0])) {
  5739. nextSources = nextSources[0];
  5740. }
  5741. return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
  5742. }
  5743. var OnErrorResumeNextOperator = (function () {
  5744. function OnErrorResumeNextOperator(nextSources) {
  5745. this.nextSources = nextSources;
  5746. }
  5747. OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
  5748. return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
  5749. };
  5750. return OnErrorResumeNextOperator;
  5751. }());
  5752. var OnErrorResumeNextSubscriber = (function (_super) {
  5753. __extends(OnErrorResumeNextSubscriber, _super);
  5754. function OnErrorResumeNextSubscriber(destination, nextSources) {
  5755. var _this = _super.call(this, destination) || this;
  5756. _this.destination = destination;
  5757. _this.nextSources = nextSources;
  5758. return _this;
  5759. }
  5760. OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
  5761. this.subscribeToNextSource();
  5762. };
  5763. OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
  5764. this.subscribeToNextSource();
  5765. };
  5766. OnErrorResumeNextSubscriber.prototype._error = function (err) {
  5767. this.subscribeToNextSource();
  5768. this.unsubscribe();
  5769. };
  5770. OnErrorResumeNextSubscriber.prototype._complete = function () {
  5771. this.subscribeToNextSource();
  5772. this.unsubscribe();
  5773. };
  5774. OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
  5775. var next = this.nextSources.shift();
  5776. if (!!next) {
  5777. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  5778. var destination = this.destination;
  5779. destination.add(innerSubscriber);
  5780. subscribeToResult(this, next, undefined, undefined, innerSubscriber);
  5781. }
  5782. else {
  5783. this.destination.complete();
  5784. }
  5785. };
  5786. return OnErrorResumeNextSubscriber;
  5787. }(OuterSubscriber));
  5788. function pairwise() {
  5789. return function (source) { return source.lift(new PairwiseOperator()); };
  5790. }
  5791. var PairwiseOperator = (function () {
  5792. function PairwiseOperator() {
  5793. }
  5794. PairwiseOperator.prototype.call = function (subscriber, source) {
  5795. return source.subscribe(new PairwiseSubscriber(subscriber));
  5796. };
  5797. return PairwiseOperator;
  5798. }());
  5799. var PairwiseSubscriber = (function (_super) {
  5800. __extends(PairwiseSubscriber, _super);
  5801. function PairwiseSubscriber(destination) {
  5802. var _this = _super.call(this, destination) || this;
  5803. _this.hasPrev = false;
  5804. return _this;
  5805. }
  5806. PairwiseSubscriber.prototype._next = function (value) {
  5807. var pair;
  5808. if (this.hasPrev) {
  5809. pair = [this.prev, value];
  5810. }
  5811. else {
  5812. this.hasPrev = true;
  5813. }
  5814. this.prev = value;
  5815. if (pair) {
  5816. this.destination.next(pair);
  5817. }
  5818. };
  5819. return PairwiseSubscriber;
  5820. }(Subscriber));
  5821. function partition$1(predicate, thisArg) {
  5822. return function (source) { return [
  5823. filter(predicate, thisArg)(source),
  5824. filter(not(predicate, thisArg))(source)
  5825. ]; };
  5826. }
  5827. function pluck() {
  5828. var properties = [];
  5829. for (var _i = 0; _i < arguments.length; _i++) {
  5830. properties[_i] = arguments[_i];
  5831. }
  5832. var length = properties.length;
  5833. if (length === 0) {
  5834. throw new Error('list of properties cannot be empty.');
  5835. }
  5836. return function (source) { return map(plucker(properties, length))(source); };
  5837. }
  5838. function plucker(props, length) {
  5839. var mapper = function (x) {
  5840. var currentProp = x;
  5841. for (var i = 0; i < length; i++) {
  5842. var p = currentProp[props[i]];
  5843. if (typeof p !== 'undefined') {
  5844. currentProp = p;
  5845. }
  5846. else {
  5847. return undefined;
  5848. }
  5849. }
  5850. return currentProp;
  5851. };
  5852. return mapper;
  5853. }
  5854. function publish(selector) {
  5855. return selector ?
  5856. multicast(function () { return new Subject(); }, selector) :
  5857. multicast(new Subject());
  5858. }
  5859. function publishBehavior(value) {
  5860. return function (source) { return multicast(new BehaviorSubject(value))(source); };
  5861. }
  5862. function publishLast() {
  5863. return function (source) { return multicast(new AsyncSubject())(source); };
  5864. }
  5865. function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
  5866. if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
  5867. scheduler = selectorOrScheduler;
  5868. }
  5869. var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
  5870. var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
  5871. return function (source) { return multicast(function () { return subject; }, selector)(source); };
  5872. }
  5873. function race$1() {
  5874. var observables = [];
  5875. for (var _i = 0; _i < arguments.length; _i++) {
  5876. observables[_i] = arguments[_i];
  5877. }
  5878. return function raceOperatorFunction(source) {
  5879. if (observables.length === 1 && isArray(observables[0])) {
  5880. observables = observables[0];
  5881. }
  5882. return source.lift.call(race.apply(void 0, [source].concat(observables)));
  5883. };
  5884. }
  5885. function repeat(count) {
  5886. if (count === void 0) { count = -1; }
  5887. return function (source) {
  5888. if (count === 0) {
  5889. return empty$1();
  5890. }
  5891. else if (count < 0) {
  5892. return source.lift(new RepeatOperator(-1, source));
  5893. }
  5894. else {
  5895. return source.lift(new RepeatOperator(count - 1, source));
  5896. }
  5897. };
  5898. }
  5899. var RepeatOperator = (function () {
  5900. function RepeatOperator(count, source) {
  5901. this.count = count;
  5902. this.source = source;
  5903. }
  5904. RepeatOperator.prototype.call = function (subscriber, source) {
  5905. return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
  5906. };
  5907. return RepeatOperator;
  5908. }());
  5909. var RepeatSubscriber = (function (_super) {
  5910. __extends(RepeatSubscriber, _super);
  5911. function RepeatSubscriber(destination, count, source) {
  5912. var _this = _super.call(this, destination) || this;
  5913. _this.count = count;
  5914. _this.source = source;
  5915. return _this;
  5916. }
  5917. RepeatSubscriber.prototype.complete = function () {
  5918. if (!this.isStopped) {
  5919. var _a = this, source = _a.source, count = _a.count;
  5920. if (count === 0) {
  5921. return _super.prototype.complete.call(this);
  5922. }
  5923. else if (count > -1) {
  5924. this.count = count - 1;
  5925. }
  5926. source.subscribe(this._unsubscribeAndRecycle());
  5927. }
  5928. };
  5929. return RepeatSubscriber;
  5930. }(Subscriber));
  5931. function repeatWhen(notifier) {
  5932. return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
  5933. }
  5934. var RepeatWhenOperator = (function () {
  5935. function RepeatWhenOperator(notifier) {
  5936. this.notifier = notifier;
  5937. }
  5938. RepeatWhenOperator.prototype.call = function (subscriber, source) {
  5939. return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
  5940. };
  5941. return RepeatWhenOperator;
  5942. }());
  5943. var RepeatWhenSubscriber = (function (_super) {
  5944. __extends(RepeatWhenSubscriber, _super);
  5945. function RepeatWhenSubscriber(destination, notifier, source) {
  5946. var _this = _super.call(this, destination) || this;
  5947. _this.notifier = notifier;
  5948. _this.source = source;
  5949. _this.sourceIsBeingSubscribedTo = true;
  5950. return _this;
  5951. }
  5952. RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  5953. this.sourceIsBeingSubscribedTo = true;
  5954. this.source.subscribe(this);
  5955. };
  5956. RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
  5957. if (this.sourceIsBeingSubscribedTo === false) {
  5958. return _super.prototype.complete.call(this);
  5959. }
  5960. };
  5961. RepeatWhenSubscriber.prototype.complete = function () {
  5962. this.sourceIsBeingSubscribedTo = false;
  5963. if (!this.isStopped) {
  5964. if (!this.retries) {
  5965. this.subscribeToRetries();
  5966. }
  5967. if (!this.retriesSubscription || this.retriesSubscription.closed) {
  5968. return _super.prototype.complete.call(this);
  5969. }
  5970. this._unsubscribeAndRecycle();
  5971. this.notifications.next();
  5972. }
  5973. };
  5974. RepeatWhenSubscriber.prototype._unsubscribe = function () {
  5975. var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
  5976. if (notifications) {
  5977. notifications.unsubscribe();
  5978. this.notifications = null;
  5979. }
  5980. if (retriesSubscription) {
  5981. retriesSubscription.unsubscribe();
  5982. this.retriesSubscription = null;
  5983. }
  5984. this.retries = null;
  5985. };
  5986. RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
  5987. var _unsubscribe = this._unsubscribe;
  5988. this._unsubscribe = null;
  5989. _super.prototype._unsubscribeAndRecycle.call(this);
  5990. this._unsubscribe = _unsubscribe;
  5991. return this;
  5992. };
  5993. RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
  5994. this.notifications = new Subject();
  5995. var retries;
  5996. try {
  5997. var notifier = this.notifier;
  5998. retries = notifier(this.notifications);
  5999. }
  6000. catch (e) {
  6001. return _super.prototype.complete.call(this);
  6002. }
  6003. this.retries = retries;
  6004. this.retriesSubscription = subscribeToResult(this, retries);
  6005. };
  6006. return RepeatWhenSubscriber;
  6007. }(OuterSubscriber));
  6008. function retry(count) {
  6009. if (count === void 0) { count = -1; }
  6010. return function (source) { return source.lift(new RetryOperator(count, source)); };
  6011. }
  6012. var RetryOperator = (function () {
  6013. function RetryOperator(count, source) {
  6014. this.count = count;
  6015. this.source = source;
  6016. }
  6017. RetryOperator.prototype.call = function (subscriber, source) {
  6018. return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
  6019. };
  6020. return RetryOperator;
  6021. }());
  6022. var RetrySubscriber = (function (_super) {
  6023. __extends(RetrySubscriber, _super);
  6024. function RetrySubscriber(destination, count, source) {
  6025. var _this = _super.call(this, destination) || this;
  6026. _this.count = count;
  6027. _this.source = source;
  6028. return _this;
  6029. }
  6030. RetrySubscriber.prototype.error = function (err) {
  6031. if (!this.isStopped) {
  6032. var _a = this, source = _a.source, count = _a.count;
  6033. if (count === 0) {
  6034. return _super.prototype.error.call(this, err);
  6035. }
  6036. else if (count > -1) {
  6037. this.count = count - 1;
  6038. }
  6039. source.subscribe(this._unsubscribeAndRecycle());
  6040. }
  6041. };
  6042. return RetrySubscriber;
  6043. }(Subscriber));
  6044. function retryWhen(notifier) {
  6045. return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
  6046. }
  6047. var RetryWhenOperator = (function () {
  6048. function RetryWhenOperator(notifier, source) {
  6049. this.notifier = notifier;
  6050. this.source = source;
  6051. }
  6052. RetryWhenOperator.prototype.call = function (subscriber, source) {
  6053. return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
  6054. };
  6055. return RetryWhenOperator;
  6056. }());
  6057. var RetryWhenSubscriber = (function (_super) {
  6058. __extends(RetryWhenSubscriber, _super);
  6059. function RetryWhenSubscriber(destination, notifier, source) {
  6060. var _this = _super.call(this, destination) || this;
  6061. _this.notifier = notifier;
  6062. _this.source = source;
  6063. return _this;
  6064. }
  6065. RetryWhenSubscriber.prototype.error = function (err) {
  6066. if (!this.isStopped) {
  6067. var errors = this.errors;
  6068. var retries = this.retries;
  6069. var retriesSubscription = this.retriesSubscription;
  6070. if (!retries) {
  6071. errors = new Subject();
  6072. try {
  6073. var notifier = this.notifier;
  6074. retries = notifier(errors);
  6075. }
  6076. catch (e) {
  6077. return _super.prototype.error.call(this, e);
  6078. }
  6079. retriesSubscription = subscribeToResult(this, retries);
  6080. }
  6081. else {
  6082. this.errors = null;
  6083. this.retriesSubscription = null;
  6084. }
  6085. this._unsubscribeAndRecycle();
  6086. this.errors = errors;
  6087. this.retries = retries;
  6088. this.retriesSubscription = retriesSubscription;
  6089. errors.next(err);
  6090. }
  6091. };
  6092. RetryWhenSubscriber.prototype._unsubscribe = function () {
  6093. var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
  6094. if (errors) {
  6095. errors.unsubscribe();
  6096. this.errors = null;
  6097. }
  6098. if (retriesSubscription) {
  6099. retriesSubscription.unsubscribe();
  6100. this.retriesSubscription = null;
  6101. }
  6102. this.retries = null;
  6103. };
  6104. RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6105. var _unsubscribe = this._unsubscribe;
  6106. this._unsubscribe = null;
  6107. this._unsubscribeAndRecycle();
  6108. this._unsubscribe = _unsubscribe;
  6109. this.source.subscribe(this);
  6110. };
  6111. return RetryWhenSubscriber;
  6112. }(OuterSubscriber));
  6113. function sample(notifier) {
  6114. return function (source) { return source.lift(new SampleOperator(notifier)); };
  6115. }
  6116. var SampleOperator = (function () {
  6117. function SampleOperator(notifier) {
  6118. this.notifier = notifier;
  6119. }
  6120. SampleOperator.prototype.call = function (subscriber, source) {
  6121. var sampleSubscriber = new SampleSubscriber(subscriber);
  6122. var subscription = source.subscribe(sampleSubscriber);
  6123. subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
  6124. return subscription;
  6125. };
  6126. return SampleOperator;
  6127. }());
  6128. var SampleSubscriber = (function (_super) {
  6129. __extends(SampleSubscriber, _super);
  6130. function SampleSubscriber() {
  6131. var _this = _super !== null && _super.apply(this, arguments) || this;
  6132. _this.hasValue = false;
  6133. return _this;
  6134. }
  6135. SampleSubscriber.prototype._next = function (value) {
  6136. this.value = value;
  6137. this.hasValue = true;
  6138. };
  6139. SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6140. this.emitValue();
  6141. };
  6142. SampleSubscriber.prototype.notifyComplete = function () {
  6143. this.emitValue();
  6144. };
  6145. SampleSubscriber.prototype.emitValue = function () {
  6146. if (this.hasValue) {
  6147. this.hasValue = false;
  6148. this.destination.next(this.value);
  6149. }
  6150. };
  6151. return SampleSubscriber;
  6152. }(OuterSubscriber));
  6153. function sampleTime(period, scheduler) {
  6154. if (scheduler === void 0) { scheduler = async; }
  6155. return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
  6156. }
  6157. var SampleTimeOperator = (function () {
  6158. function SampleTimeOperator(period, scheduler) {
  6159. this.period = period;
  6160. this.scheduler = scheduler;
  6161. }
  6162. SampleTimeOperator.prototype.call = function (subscriber, source) {
  6163. return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
  6164. };
  6165. return SampleTimeOperator;
  6166. }());
  6167. var SampleTimeSubscriber = (function (_super) {
  6168. __extends(SampleTimeSubscriber, _super);
  6169. function SampleTimeSubscriber(destination, period, scheduler) {
  6170. var _this = _super.call(this, destination) || this;
  6171. _this.period = period;
  6172. _this.scheduler = scheduler;
  6173. _this.hasValue = false;
  6174. _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
  6175. return _this;
  6176. }
  6177. SampleTimeSubscriber.prototype._next = function (value) {
  6178. this.lastValue = value;
  6179. this.hasValue = true;
  6180. };
  6181. SampleTimeSubscriber.prototype.notifyNext = function () {
  6182. if (this.hasValue) {
  6183. this.hasValue = false;
  6184. this.destination.next(this.lastValue);
  6185. }
  6186. };
  6187. return SampleTimeSubscriber;
  6188. }(Subscriber));
  6189. function dispatchNotification(state) {
  6190. var subscriber = state.subscriber, period = state.period;
  6191. subscriber.notifyNext();
  6192. this.schedule(state, period);
  6193. }
  6194. function sequenceEqual(compareTo, comparator) {
  6195. return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparator)); };
  6196. }
  6197. var SequenceEqualOperator = (function () {
  6198. function SequenceEqualOperator(compareTo, comparator) {
  6199. this.compareTo = compareTo;
  6200. this.comparator = comparator;
  6201. }
  6202. SequenceEqualOperator.prototype.call = function (subscriber, source) {
  6203. return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
  6204. };
  6205. return SequenceEqualOperator;
  6206. }());
  6207. var SequenceEqualSubscriber = (function (_super) {
  6208. __extends(SequenceEqualSubscriber, _super);
  6209. function SequenceEqualSubscriber(destination, compareTo, comparator) {
  6210. var _this = _super.call(this, destination) || this;
  6211. _this.compareTo = compareTo;
  6212. _this.comparator = comparator;
  6213. _this._a = [];
  6214. _this._b = [];
  6215. _this._oneComplete = false;
  6216. _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
  6217. return _this;
  6218. }
  6219. SequenceEqualSubscriber.prototype._next = function (value) {
  6220. if (this._oneComplete && this._b.length === 0) {
  6221. this.emit(false);
  6222. }
  6223. else {
  6224. this._a.push(value);
  6225. this.checkValues();
  6226. }
  6227. };
  6228. SequenceEqualSubscriber.prototype._complete = function () {
  6229. if (this._oneComplete) {
  6230. this.emit(this._a.length === 0 && this._b.length === 0);
  6231. }
  6232. else {
  6233. this._oneComplete = true;
  6234. }
  6235. this.unsubscribe();
  6236. };
  6237. SequenceEqualSubscriber.prototype.checkValues = function () {
  6238. var _c = this, _a = _c._a, _b = _c._b, comparator = _c.comparator;
  6239. while (_a.length > 0 && _b.length > 0) {
  6240. var a = _a.shift();
  6241. var b = _b.shift();
  6242. var areEqual = false;
  6243. try {
  6244. areEqual = comparator ? comparator(a, b) : a === b;
  6245. }
  6246. catch (e) {
  6247. this.destination.error(e);
  6248. }
  6249. if (!areEqual) {
  6250. this.emit(false);
  6251. }
  6252. }
  6253. };
  6254. SequenceEqualSubscriber.prototype.emit = function (value) {
  6255. var destination = this.destination;
  6256. destination.next(value);
  6257. destination.complete();
  6258. };
  6259. SequenceEqualSubscriber.prototype.nextB = function (value) {
  6260. if (this._oneComplete && this._a.length === 0) {
  6261. this.emit(false);
  6262. }
  6263. else {
  6264. this._b.push(value);
  6265. this.checkValues();
  6266. }
  6267. };
  6268. SequenceEqualSubscriber.prototype.completeB = function () {
  6269. if (this._oneComplete) {
  6270. this.emit(this._a.length === 0 && this._b.length === 0);
  6271. }
  6272. else {
  6273. this._oneComplete = true;
  6274. }
  6275. };
  6276. return SequenceEqualSubscriber;
  6277. }(Subscriber));
  6278. var SequenceEqualCompareToSubscriber = (function (_super) {
  6279. __extends(SequenceEqualCompareToSubscriber, _super);
  6280. function SequenceEqualCompareToSubscriber(destination, parent) {
  6281. var _this = _super.call(this, destination) || this;
  6282. _this.parent = parent;
  6283. return _this;
  6284. }
  6285. SequenceEqualCompareToSubscriber.prototype._next = function (value) {
  6286. this.parent.nextB(value);
  6287. };
  6288. SequenceEqualCompareToSubscriber.prototype._error = function (err) {
  6289. this.parent.error(err);
  6290. this.unsubscribe();
  6291. };
  6292. SequenceEqualCompareToSubscriber.prototype._complete = function () {
  6293. this.parent.completeB();
  6294. this.unsubscribe();
  6295. };
  6296. return SequenceEqualCompareToSubscriber;
  6297. }(Subscriber));
  6298. function shareSubjectFactory() {
  6299. return new Subject();
  6300. }
  6301. function share() {
  6302. return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };
  6303. }
  6304. function shareReplay(configOrBufferSize, windowTime, scheduler) {
  6305. var config;
  6306. if (configOrBufferSize && typeof configOrBufferSize === 'object') {
  6307. config = configOrBufferSize;
  6308. }
  6309. else {
  6310. config = {
  6311. bufferSize: configOrBufferSize,
  6312. windowTime: windowTime,
  6313. refCount: false,
  6314. scheduler: scheduler
  6315. };
  6316. }
  6317. return function (source) { return source.lift(shareReplayOperator(config)); };
  6318. }
  6319. function shareReplayOperator(_a) {
  6320. var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
  6321. var subject;
  6322. var refCount = 0;
  6323. var subscription;
  6324. var hasError = false;
  6325. var isComplete = false;
  6326. return function shareReplayOperation(source) {
  6327. refCount++;
  6328. if (!subject || hasError) {
  6329. hasError = false;
  6330. subject = new ReplaySubject(bufferSize, windowTime, scheduler);
  6331. subscription = source.subscribe({
  6332. next: function (value) { subject.next(value); },
  6333. error: function (err) {
  6334. hasError = true;
  6335. subject.error(err);
  6336. },
  6337. complete: function () {
  6338. isComplete = true;
  6339. subject.complete();
  6340. },
  6341. });
  6342. }
  6343. var innerSub = subject.subscribe(this);
  6344. this.add(function () {
  6345. refCount--;
  6346. innerSub.unsubscribe();
  6347. if (subscription && !isComplete && useRefCount && refCount === 0) {
  6348. subscription.unsubscribe();
  6349. subscription = undefined;
  6350. subject = undefined;
  6351. }
  6352. });
  6353. };
  6354. }
  6355. function single(predicate) {
  6356. return function (source) { return source.lift(new SingleOperator(predicate, source)); };
  6357. }
  6358. var SingleOperator = (function () {
  6359. function SingleOperator(predicate, source) {
  6360. this.predicate = predicate;
  6361. this.source = source;
  6362. }
  6363. SingleOperator.prototype.call = function (subscriber, source) {
  6364. return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
  6365. };
  6366. return SingleOperator;
  6367. }());
  6368. var SingleSubscriber = (function (_super) {
  6369. __extends(SingleSubscriber, _super);
  6370. function SingleSubscriber(destination, predicate, source) {
  6371. var _this = _super.call(this, destination) || this;
  6372. _this.predicate = predicate;
  6373. _this.source = source;
  6374. _this.seenValue = false;
  6375. _this.index = 0;
  6376. return _this;
  6377. }
  6378. SingleSubscriber.prototype.applySingleValue = function (value) {
  6379. if (this.seenValue) {
  6380. this.destination.error('Sequence contains more than one element');
  6381. }
  6382. else {
  6383. this.seenValue = true;
  6384. this.singleValue = value;
  6385. }
  6386. };
  6387. SingleSubscriber.prototype._next = function (value) {
  6388. var index = this.index++;
  6389. if (this.predicate) {
  6390. this.tryNext(value, index);
  6391. }
  6392. else {
  6393. this.applySingleValue(value);
  6394. }
  6395. };
  6396. SingleSubscriber.prototype.tryNext = function (value, index) {
  6397. try {
  6398. if (this.predicate(value, index, this.source)) {
  6399. this.applySingleValue(value);
  6400. }
  6401. }
  6402. catch (err) {
  6403. this.destination.error(err);
  6404. }
  6405. };
  6406. SingleSubscriber.prototype._complete = function () {
  6407. var destination = this.destination;
  6408. if (this.index > 0) {
  6409. destination.next(this.seenValue ? this.singleValue : undefined);
  6410. destination.complete();
  6411. }
  6412. else {
  6413. destination.error(new EmptyError);
  6414. }
  6415. };
  6416. return SingleSubscriber;
  6417. }(Subscriber));
  6418. function skip(count) {
  6419. return function (source) { return source.lift(new SkipOperator(count)); };
  6420. }
  6421. var SkipOperator = (function () {
  6422. function SkipOperator(total) {
  6423. this.total = total;
  6424. }
  6425. SkipOperator.prototype.call = function (subscriber, source) {
  6426. return source.subscribe(new SkipSubscriber(subscriber, this.total));
  6427. };
  6428. return SkipOperator;
  6429. }());
  6430. var SkipSubscriber = (function (_super) {
  6431. __extends(SkipSubscriber, _super);
  6432. function SkipSubscriber(destination, total) {
  6433. var _this = _super.call(this, destination) || this;
  6434. _this.total = total;
  6435. _this.count = 0;
  6436. return _this;
  6437. }
  6438. SkipSubscriber.prototype._next = function (x) {
  6439. if (++this.count > this.total) {
  6440. this.destination.next(x);
  6441. }
  6442. };
  6443. return SkipSubscriber;
  6444. }(Subscriber));
  6445. function skipLast(count) {
  6446. return function (source) { return source.lift(new SkipLastOperator(count)); };
  6447. }
  6448. var SkipLastOperator = (function () {
  6449. function SkipLastOperator(_skipCount) {
  6450. this._skipCount = _skipCount;
  6451. if (this._skipCount < 0) {
  6452. throw new ArgumentOutOfRangeError;
  6453. }
  6454. }
  6455. SkipLastOperator.prototype.call = function (subscriber, source) {
  6456. if (this._skipCount === 0) {
  6457. return source.subscribe(new Subscriber(subscriber));
  6458. }
  6459. else {
  6460. return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
  6461. }
  6462. };
  6463. return SkipLastOperator;
  6464. }());
  6465. var SkipLastSubscriber = (function (_super) {
  6466. __extends(SkipLastSubscriber, _super);
  6467. function SkipLastSubscriber(destination, _skipCount) {
  6468. var _this = _super.call(this, destination) || this;
  6469. _this._skipCount = _skipCount;
  6470. _this._count = 0;
  6471. _this._ring = new Array(_skipCount);
  6472. return _this;
  6473. }
  6474. SkipLastSubscriber.prototype._next = function (value) {
  6475. var skipCount = this._skipCount;
  6476. var count = this._count++;
  6477. if (count < skipCount) {
  6478. this._ring[count] = value;
  6479. }
  6480. else {
  6481. var currentIndex = count % skipCount;
  6482. var ring = this._ring;
  6483. var oldValue = ring[currentIndex];
  6484. ring[currentIndex] = value;
  6485. this.destination.next(oldValue);
  6486. }
  6487. };
  6488. return SkipLastSubscriber;
  6489. }(Subscriber));
  6490. function skipUntil(notifier) {
  6491. return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
  6492. }
  6493. var SkipUntilOperator = (function () {
  6494. function SkipUntilOperator(notifier) {
  6495. this.notifier = notifier;
  6496. }
  6497. SkipUntilOperator.prototype.call = function (destination, source) {
  6498. return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
  6499. };
  6500. return SkipUntilOperator;
  6501. }());
  6502. var SkipUntilSubscriber = (function (_super) {
  6503. __extends(SkipUntilSubscriber, _super);
  6504. function SkipUntilSubscriber(destination, notifier) {
  6505. var _this = _super.call(this, destination) || this;
  6506. _this.hasValue = false;
  6507. var innerSubscriber = new InnerSubscriber(_this, undefined, undefined);
  6508. _this.add(innerSubscriber);
  6509. _this.innerSubscription = innerSubscriber;
  6510. subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
  6511. return _this;
  6512. }
  6513. SkipUntilSubscriber.prototype._next = function (value) {
  6514. if (this.hasValue) {
  6515. _super.prototype._next.call(this, value);
  6516. }
  6517. };
  6518. SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6519. this.hasValue = true;
  6520. if (this.innerSubscription) {
  6521. this.innerSubscription.unsubscribe();
  6522. }
  6523. };
  6524. SkipUntilSubscriber.prototype.notifyComplete = function () {
  6525. };
  6526. return SkipUntilSubscriber;
  6527. }(OuterSubscriber));
  6528. function skipWhile(predicate) {
  6529. return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
  6530. }
  6531. var SkipWhileOperator = (function () {
  6532. function SkipWhileOperator(predicate) {
  6533. this.predicate = predicate;
  6534. }
  6535. SkipWhileOperator.prototype.call = function (subscriber, source) {
  6536. return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
  6537. };
  6538. return SkipWhileOperator;
  6539. }());
  6540. var SkipWhileSubscriber = (function (_super) {
  6541. __extends(SkipWhileSubscriber, _super);
  6542. function SkipWhileSubscriber(destination, predicate) {
  6543. var _this = _super.call(this, destination) || this;
  6544. _this.predicate = predicate;
  6545. _this.skipping = true;
  6546. _this.index = 0;
  6547. return _this;
  6548. }
  6549. SkipWhileSubscriber.prototype._next = function (value) {
  6550. var destination = this.destination;
  6551. if (this.skipping) {
  6552. this.tryCallPredicate(value);
  6553. }
  6554. if (!this.skipping) {
  6555. destination.next(value);
  6556. }
  6557. };
  6558. SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
  6559. try {
  6560. var result = this.predicate(value, this.index++);
  6561. this.skipping = Boolean(result);
  6562. }
  6563. catch (err) {
  6564. this.destination.error(err);
  6565. }
  6566. };
  6567. return SkipWhileSubscriber;
  6568. }(Subscriber));
  6569. function startWith() {
  6570. var array = [];
  6571. for (var _i = 0; _i < arguments.length; _i++) {
  6572. array[_i] = arguments[_i];
  6573. }
  6574. var scheduler = array[array.length - 1];
  6575. if (isScheduler(scheduler)) {
  6576. array.pop();
  6577. return function (source) { return concat(array, source, scheduler); };
  6578. }
  6579. else {
  6580. return function (source) { return concat(array, source); };
  6581. }
  6582. }
  6583. var SubscribeOnObservable = (function (_super) {
  6584. __extends(SubscribeOnObservable, _super);
  6585. function SubscribeOnObservable(source, delayTime, scheduler) {
  6586. if (delayTime === void 0) { delayTime = 0; }
  6587. if (scheduler === void 0) { scheduler = asap; }
  6588. var _this = _super.call(this) || this;
  6589. _this.source = source;
  6590. _this.delayTime = delayTime;
  6591. _this.scheduler = scheduler;
  6592. if (!isNumeric(delayTime) || delayTime < 0) {
  6593. _this.delayTime = 0;
  6594. }
  6595. if (!scheduler || typeof scheduler.schedule !== 'function') {
  6596. _this.scheduler = asap;
  6597. }
  6598. return _this;
  6599. }
  6600. SubscribeOnObservable.create = function (source, delay, scheduler) {
  6601. if (delay === void 0) { delay = 0; }
  6602. if (scheduler === void 0) { scheduler = asap; }
  6603. return new SubscribeOnObservable(source, delay, scheduler);
  6604. };
  6605. SubscribeOnObservable.dispatch = function (arg) {
  6606. var source = arg.source, subscriber = arg.subscriber;
  6607. return this.add(source.subscribe(subscriber));
  6608. };
  6609. SubscribeOnObservable.prototype._subscribe = function (subscriber) {
  6610. var delay = this.delayTime;
  6611. var source = this.source;
  6612. var scheduler = this.scheduler;
  6613. return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
  6614. source: source, subscriber: subscriber
  6615. });
  6616. };
  6617. return SubscribeOnObservable;
  6618. }(Observable));
  6619. function subscribeOn(scheduler, delay) {
  6620. if (delay === void 0) { delay = 0; }
  6621. return function subscribeOnOperatorFunction(source) {
  6622. return source.lift(new SubscribeOnOperator(scheduler, delay));
  6623. };
  6624. }
  6625. var SubscribeOnOperator = (function () {
  6626. function SubscribeOnOperator(scheduler, delay) {
  6627. this.scheduler = scheduler;
  6628. this.delay = delay;
  6629. }
  6630. SubscribeOnOperator.prototype.call = function (subscriber, source) {
  6631. return new SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
  6632. };
  6633. return SubscribeOnOperator;
  6634. }());
  6635. function switchMap(project, resultSelector) {
  6636. if (typeof resultSelector === 'function') {
  6637. return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
  6638. }
  6639. return function (source) { return source.lift(new SwitchMapOperator(project)); };
  6640. }
  6641. var SwitchMapOperator = (function () {
  6642. function SwitchMapOperator(project) {
  6643. this.project = project;
  6644. }
  6645. SwitchMapOperator.prototype.call = function (subscriber, source) {
  6646. return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
  6647. };
  6648. return SwitchMapOperator;
  6649. }());
  6650. var SwitchMapSubscriber = (function (_super) {
  6651. __extends(SwitchMapSubscriber, _super);
  6652. function SwitchMapSubscriber(destination, project) {
  6653. var _this = _super.call(this, destination) || this;
  6654. _this.project = project;
  6655. _this.index = 0;
  6656. return _this;
  6657. }
  6658. SwitchMapSubscriber.prototype._next = function (value) {
  6659. var result;
  6660. var index = this.index++;
  6661. try {
  6662. result = this.project(value, index);
  6663. }
  6664. catch (error) {
  6665. this.destination.error(error);
  6666. return;
  6667. }
  6668. this._innerSub(result, value, index);
  6669. };
  6670. SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
  6671. var innerSubscription = this.innerSubscription;
  6672. if (innerSubscription) {
  6673. innerSubscription.unsubscribe();
  6674. }
  6675. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  6676. var destination = this.destination;
  6677. destination.add(innerSubscriber);
  6678. this.innerSubscription = subscribeToResult(this, result, value, index, innerSubscriber);
  6679. };
  6680. SwitchMapSubscriber.prototype._complete = function () {
  6681. var innerSubscription = this.innerSubscription;
  6682. if (!innerSubscription || innerSubscription.closed) {
  6683. _super.prototype._complete.call(this);
  6684. }
  6685. this.unsubscribe();
  6686. };
  6687. SwitchMapSubscriber.prototype._unsubscribe = function () {
  6688. this.innerSubscription = null;
  6689. };
  6690. SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
  6691. var destination = this.destination;
  6692. destination.remove(innerSub);
  6693. this.innerSubscription = null;
  6694. if (this.isStopped) {
  6695. _super.prototype._complete.call(this);
  6696. }
  6697. };
  6698. SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6699. this.destination.next(innerValue);
  6700. };
  6701. return SwitchMapSubscriber;
  6702. }(OuterSubscriber));
  6703. function switchAll() {
  6704. return switchMap(identity);
  6705. }
  6706. function switchMapTo(innerObservable, resultSelector) {
  6707. return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });
  6708. }
  6709. function takeUntil(notifier) {
  6710. return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
  6711. }
  6712. var TakeUntilOperator = (function () {
  6713. function TakeUntilOperator(notifier) {
  6714. this.notifier = notifier;
  6715. }
  6716. TakeUntilOperator.prototype.call = function (subscriber, source) {
  6717. var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
  6718. var notifierSubscription = subscribeToResult(takeUntilSubscriber, this.notifier);
  6719. if (notifierSubscription && !takeUntilSubscriber.seenValue) {
  6720. takeUntilSubscriber.add(notifierSubscription);
  6721. return source.subscribe(takeUntilSubscriber);
  6722. }
  6723. return takeUntilSubscriber;
  6724. };
  6725. return TakeUntilOperator;
  6726. }());
  6727. var TakeUntilSubscriber = (function (_super) {
  6728. __extends(TakeUntilSubscriber, _super);
  6729. function TakeUntilSubscriber(destination) {
  6730. var _this = _super.call(this, destination) || this;
  6731. _this.seenValue = false;
  6732. return _this;
  6733. }
  6734. TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6735. this.seenValue = true;
  6736. this.complete();
  6737. };
  6738. TakeUntilSubscriber.prototype.notifyComplete = function () {
  6739. };
  6740. return TakeUntilSubscriber;
  6741. }(OuterSubscriber));
  6742. function takeWhile(predicate, inclusive) {
  6743. if (inclusive === void 0) { inclusive = false; }
  6744. return function (source) {
  6745. return source.lift(new TakeWhileOperator(predicate, inclusive));
  6746. };
  6747. }
  6748. var TakeWhileOperator = (function () {
  6749. function TakeWhileOperator(predicate, inclusive) {
  6750. this.predicate = predicate;
  6751. this.inclusive = inclusive;
  6752. }
  6753. TakeWhileOperator.prototype.call = function (subscriber, source) {
  6754. return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
  6755. };
  6756. return TakeWhileOperator;
  6757. }());
  6758. var TakeWhileSubscriber = (function (_super) {
  6759. __extends(TakeWhileSubscriber, _super);
  6760. function TakeWhileSubscriber(destination, predicate, inclusive) {
  6761. var _this = _super.call(this, destination) || this;
  6762. _this.predicate = predicate;
  6763. _this.inclusive = inclusive;
  6764. _this.index = 0;
  6765. return _this;
  6766. }
  6767. TakeWhileSubscriber.prototype._next = function (value) {
  6768. var destination = this.destination;
  6769. var result;
  6770. try {
  6771. result = this.predicate(value, this.index++);
  6772. }
  6773. catch (err) {
  6774. destination.error(err);
  6775. return;
  6776. }
  6777. this.nextOrComplete(value, result);
  6778. };
  6779. TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
  6780. var destination = this.destination;
  6781. if (Boolean(predicateResult)) {
  6782. destination.next(value);
  6783. }
  6784. else {
  6785. if (this.inclusive) {
  6786. destination.next(value);
  6787. }
  6788. destination.complete();
  6789. }
  6790. };
  6791. return TakeWhileSubscriber;
  6792. }(Subscriber));
  6793. function tap(nextOrObserver, error, complete) {
  6794. return function tapOperatorFunction(source) {
  6795. return source.lift(new DoOperator(nextOrObserver, error, complete));
  6796. };
  6797. }
  6798. var DoOperator = (function () {
  6799. function DoOperator(nextOrObserver, error, complete) {
  6800. this.nextOrObserver = nextOrObserver;
  6801. this.error = error;
  6802. this.complete = complete;
  6803. }
  6804. DoOperator.prototype.call = function (subscriber, source) {
  6805. return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
  6806. };
  6807. return DoOperator;
  6808. }());
  6809. var TapSubscriber = (function (_super) {
  6810. __extends(TapSubscriber, _super);
  6811. function TapSubscriber(destination, observerOrNext, error, complete) {
  6812. var _this = _super.call(this, destination) || this;
  6813. _this._tapNext = noop;
  6814. _this._tapError = noop;
  6815. _this._tapComplete = noop;
  6816. _this._tapError = error || noop;
  6817. _this._tapComplete = complete || noop;
  6818. if (isFunction(observerOrNext)) {
  6819. _this._context = _this;
  6820. _this._tapNext = observerOrNext;
  6821. }
  6822. else if (observerOrNext) {
  6823. _this._context = observerOrNext;
  6824. _this._tapNext = observerOrNext.next || noop;
  6825. _this._tapError = observerOrNext.error || noop;
  6826. _this._tapComplete = observerOrNext.complete || noop;
  6827. }
  6828. return _this;
  6829. }
  6830. TapSubscriber.prototype._next = function (value) {
  6831. try {
  6832. this._tapNext.call(this._context, value);
  6833. }
  6834. catch (err) {
  6835. this.destination.error(err);
  6836. return;
  6837. }
  6838. this.destination.next(value);
  6839. };
  6840. TapSubscriber.prototype._error = function (err) {
  6841. try {
  6842. this._tapError.call(this._context, err);
  6843. }
  6844. catch (err) {
  6845. this.destination.error(err);
  6846. return;
  6847. }
  6848. this.destination.error(err);
  6849. };
  6850. TapSubscriber.prototype._complete = function () {
  6851. try {
  6852. this._tapComplete.call(this._context);
  6853. }
  6854. catch (err) {
  6855. this.destination.error(err);
  6856. return;
  6857. }
  6858. return this.destination.complete();
  6859. };
  6860. return TapSubscriber;
  6861. }(Subscriber));
  6862. var defaultThrottleConfig = {
  6863. leading: true,
  6864. trailing: false
  6865. };
  6866. function throttle(durationSelector, config) {
  6867. if (config === void 0) { config = defaultThrottleConfig; }
  6868. return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
  6869. }
  6870. var ThrottleOperator = (function () {
  6871. function ThrottleOperator(durationSelector, leading, trailing) {
  6872. this.durationSelector = durationSelector;
  6873. this.leading = leading;
  6874. this.trailing = trailing;
  6875. }
  6876. ThrottleOperator.prototype.call = function (subscriber, source) {
  6877. return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
  6878. };
  6879. return ThrottleOperator;
  6880. }());
  6881. var ThrottleSubscriber = (function (_super) {
  6882. __extends(ThrottleSubscriber, _super);
  6883. function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
  6884. var _this = _super.call(this, destination) || this;
  6885. _this.destination = destination;
  6886. _this.durationSelector = durationSelector;
  6887. _this._leading = _leading;
  6888. _this._trailing = _trailing;
  6889. _this._hasValue = false;
  6890. return _this;
  6891. }
  6892. ThrottleSubscriber.prototype._next = function (value) {
  6893. this._hasValue = true;
  6894. this._sendValue = value;
  6895. if (!this._throttled) {
  6896. if (this._leading) {
  6897. this.send();
  6898. }
  6899. else {
  6900. this.throttle(value);
  6901. }
  6902. }
  6903. };
  6904. ThrottleSubscriber.prototype.send = function () {
  6905. var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
  6906. if (_hasValue) {
  6907. this.destination.next(_sendValue);
  6908. this.throttle(_sendValue);
  6909. }
  6910. this._hasValue = false;
  6911. this._sendValue = null;
  6912. };
  6913. ThrottleSubscriber.prototype.throttle = function (value) {
  6914. var duration = this.tryDurationSelector(value);
  6915. if (!!duration) {
  6916. this.add(this._throttled = subscribeToResult(this, duration));
  6917. }
  6918. };
  6919. ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
  6920. try {
  6921. return this.durationSelector(value);
  6922. }
  6923. catch (err) {
  6924. this.destination.error(err);
  6925. return null;
  6926. }
  6927. };
  6928. ThrottleSubscriber.prototype.throttlingDone = function () {
  6929. var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
  6930. if (_throttled) {
  6931. _throttled.unsubscribe();
  6932. }
  6933. this._throttled = null;
  6934. if (_trailing) {
  6935. this.send();
  6936. }
  6937. };
  6938. ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6939. this.throttlingDone();
  6940. };
  6941. ThrottleSubscriber.prototype.notifyComplete = function () {
  6942. this.throttlingDone();
  6943. };
  6944. return ThrottleSubscriber;
  6945. }(OuterSubscriber));
  6946. function throttleTime(duration, scheduler, config) {
  6947. if (scheduler === void 0) { scheduler = async; }
  6948. if (config === void 0) { config = defaultThrottleConfig; }
  6949. return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
  6950. }
  6951. var ThrottleTimeOperator = (function () {
  6952. function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
  6953. this.duration = duration;
  6954. this.scheduler = scheduler;
  6955. this.leading = leading;
  6956. this.trailing = trailing;
  6957. }
  6958. ThrottleTimeOperator.prototype.call = function (subscriber, source) {
  6959. return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
  6960. };
  6961. return ThrottleTimeOperator;
  6962. }());
  6963. var ThrottleTimeSubscriber = (function (_super) {
  6964. __extends(ThrottleTimeSubscriber, _super);
  6965. function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
  6966. var _this = _super.call(this, destination) || this;
  6967. _this.duration = duration;
  6968. _this.scheduler = scheduler;
  6969. _this.leading = leading;
  6970. _this.trailing = trailing;
  6971. _this._hasTrailingValue = false;
  6972. _this._trailingValue = null;
  6973. return _this;
  6974. }
  6975. ThrottleTimeSubscriber.prototype._next = function (value) {
  6976. if (this.throttled) {
  6977. if (this.trailing) {
  6978. this._trailingValue = value;
  6979. this._hasTrailingValue = true;
  6980. }
  6981. }
  6982. else {
  6983. this.add(this.throttled = this.scheduler.schedule(dispatchNext$3, this.duration, { subscriber: this }));
  6984. if (this.leading) {
  6985. this.destination.next(value);
  6986. }
  6987. else if (this.trailing) {
  6988. this._trailingValue = value;
  6989. this._hasTrailingValue = true;
  6990. }
  6991. }
  6992. };
  6993. ThrottleTimeSubscriber.prototype._complete = function () {
  6994. if (this._hasTrailingValue) {
  6995. this.destination.next(this._trailingValue);
  6996. this.destination.complete();
  6997. }
  6998. else {
  6999. this.destination.complete();
  7000. }
  7001. };
  7002. ThrottleTimeSubscriber.prototype.clearThrottle = function () {
  7003. var throttled = this.throttled;
  7004. if (throttled) {
  7005. if (this.trailing && this._hasTrailingValue) {
  7006. this.destination.next(this._trailingValue);
  7007. this._trailingValue = null;
  7008. this._hasTrailingValue = false;
  7009. }
  7010. throttled.unsubscribe();
  7011. this.remove(throttled);
  7012. this.throttled = null;
  7013. }
  7014. };
  7015. return ThrottleTimeSubscriber;
  7016. }(Subscriber));
  7017. function dispatchNext$3(arg) {
  7018. var subscriber = arg.subscriber;
  7019. subscriber.clearThrottle();
  7020. }
  7021. function timeInterval(scheduler) {
  7022. if (scheduler === void 0) { scheduler = async; }
  7023. return function (source) { return defer(function () {
  7024. return source.pipe(scan(function (_a, value) {
  7025. var current = _a.current;
  7026. return ({ value: value, current: scheduler.now(), last: current });
  7027. }, { current: scheduler.now(), value: undefined, last: undefined }), map(function (_a) {
  7028. var current = _a.current, last = _a.last, value = _a.value;
  7029. return new TimeInterval(value, current - last);
  7030. }));
  7031. }); };
  7032. }
  7033. var TimeInterval = (function () {
  7034. function TimeInterval(value, interval) {
  7035. this.value = value;
  7036. this.interval = interval;
  7037. }
  7038. return TimeInterval;
  7039. }());
  7040. function timeoutWith(due, withObservable, scheduler) {
  7041. if (scheduler === void 0) { scheduler = async; }
  7042. return function (source) {
  7043. var absoluteTimeout = isDate(due);
  7044. var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
  7045. return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
  7046. };
  7047. }
  7048. var TimeoutWithOperator = (function () {
  7049. function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
  7050. this.waitFor = waitFor;
  7051. this.absoluteTimeout = absoluteTimeout;
  7052. this.withObservable = withObservable;
  7053. this.scheduler = scheduler;
  7054. }
  7055. TimeoutWithOperator.prototype.call = function (subscriber, source) {
  7056. return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
  7057. };
  7058. return TimeoutWithOperator;
  7059. }());
  7060. var TimeoutWithSubscriber = (function (_super) {
  7061. __extends(TimeoutWithSubscriber, _super);
  7062. function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
  7063. var _this = _super.call(this, destination) || this;
  7064. _this.absoluteTimeout = absoluteTimeout;
  7065. _this.waitFor = waitFor;
  7066. _this.withObservable = withObservable;
  7067. _this.scheduler = scheduler;
  7068. _this.action = null;
  7069. _this.scheduleTimeout();
  7070. return _this;
  7071. }
  7072. TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
  7073. var withObservable = subscriber.withObservable;
  7074. subscriber._unsubscribeAndRecycle();
  7075. subscriber.add(subscribeToResult(subscriber, withObservable));
  7076. };
  7077. TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
  7078. var action = this.action;
  7079. if (action) {
  7080. this.action = action.schedule(this, this.waitFor);
  7081. }
  7082. else {
  7083. this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
  7084. }
  7085. };
  7086. TimeoutWithSubscriber.prototype._next = function (value) {
  7087. if (!this.absoluteTimeout) {
  7088. this.scheduleTimeout();
  7089. }
  7090. _super.prototype._next.call(this, value);
  7091. };
  7092. TimeoutWithSubscriber.prototype._unsubscribe = function () {
  7093. this.action = null;
  7094. this.scheduler = null;
  7095. this.withObservable = null;
  7096. };
  7097. return TimeoutWithSubscriber;
  7098. }(OuterSubscriber));
  7099. function timeout(due, scheduler) {
  7100. if (scheduler === void 0) { scheduler = async; }
  7101. return timeoutWith(due, throwError(new TimeoutError()), scheduler);
  7102. }
  7103. function timestamp(scheduler) {
  7104. if (scheduler === void 0) { scheduler = async; }
  7105. return map(function (value) { return new Timestamp(value, scheduler.now()); });
  7106. }
  7107. var Timestamp = (function () {
  7108. function Timestamp(value, timestamp) {
  7109. this.value = value;
  7110. this.timestamp = timestamp;
  7111. }
  7112. return Timestamp;
  7113. }());
  7114. function toArrayReducer(arr, item, index) {
  7115. if (index === 0) {
  7116. return [item];
  7117. }
  7118. arr.push(item);
  7119. return arr;
  7120. }
  7121. function toArray() {
  7122. return reduce(toArrayReducer, []);
  7123. }
  7124. function window$1(windowBoundaries) {
  7125. return function windowOperatorFunction(source) {
  7126. return source.lift(new WindowOperator(windowBoundaries));
  7127. };
  7128. }
  7129. var WindowOperator = (function () {
  7130. function WindowOperator(windowBoundaries) {
  7131. this.windowBoundaries = windowBoundaries;
  7132. }
  7133. WindowOperator.prototype.call = function (subscriber, source) {
  7134. var windowSubscriber = new WindowSubscriber(subscriber);
  7135. var sourceSubscription = source.subscribe(windowSubscriber);
  7136. if (!sourceSubscription.closed) {
  7137. windowSubscriber.add(subscribeToResult(windowSubscriber, this.windowBoundaries));
  7138. }
  7139. return sourceSubscription;
  7140. };
  7141. return WindowOperator;
  7142. }());
  7143. var WindowSubscriber = (function (_super) {
  7144. __extends(WindowSubscriber, _super);
  7145. function WindowSubscriber(destination) {
  7146. var _this = _super.call(this, destination) || this;
  7147. _this.window = new Subject();
  7148. destination.next(_this.window);
  7149. return _this;
  7150. }
  7151. WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7152. this.openWindow();
  7153. };
  7154. WindowSubscriber.prototype.notifyError = function (error, innerSub) {
  7155. this._error(error);
  7156. };
  7157. WindowSubscriber.prototype.notifyComplete = function (innerSub) {
  7158. this._complete();
  7159. };
  7160. WindowSubscriber.prototype._next = function (value) {
  7161. this.window.next(value);
  7162. };
  7163. WindowSubscriber.prototype._error = function (err) {
  7164. this.window.error(err);
  7165. this.destination.error(err);
  7166. };
  7167. WindowSubscriber.prototype._complete = function () {
  7168. this.window.complete();
  7169. this.destination.complete();
  7170. };
  7171. WindowSubscriber.prototype._unsubscribe = function () {
  7172. this.window = null;
  7173. };
  7174. WindowSubscriber.prototype.openWindow = function () {
  7175. var prevWindow = this.window;
  7176. if (prevWindow) {
  7177. prevWindow.complete();
  7178. }
  7179. var destination = this.destination;
  7180. var newWindow = this.window = new Subject();
  7181. destination.next(newWindow);
  7182. };
  7183. return WindowSubscriber;
  7184. }(OuterSubscriber));
  7185. function windowCount(windowSize, startWindowEvery) {
  7186. if (startWindowEvery === void 0) { startWindowEvery = 0; }
  7187. return function windowCountOperatorFunction(source) {
  7188. return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
  7189. };
  7190. }
  7191. var WindowCountOperator = (function () {
  7192. function WindowCountOperator(windowSize, startWindowEvery) {
  7193. this.windowSize = windowSize;
  7194. this.startWindowEvery = startWindowEvery;
  7195. }
  7196. WindowCountOperator.prototype.call = function (subscriber, source) {
  7197. return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
  7198. };
  7199. return WindowCountOperator;
  7200. }());
  7201. var WindowCountSubscriber = (function (_super) {
  7202. __extends(WindowCountSubscriber, _super);
  7203. function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
  7204. var _this = _super.call(this, destination) || this;
  7205. _this.destination = destination;
  7206. _this.windowSize = windowSize;
  7207. _this.startWindowEvery = startWindowEvery;
  7208. _this.windows = [new Subject()];
  7209. _this.count = 0;
  7210. destination.next(_this.windows[0]);
  7211. return _this;
  7212. }
  7213. WindowCountSubscriber.prototype._next = function (value) {
  7214. var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
  7215. var destination = this.destination;
  7216. var windowSize = this.windowSize;
  7217. var windows = this.windows;
  7218. var len = windows.length;
  7219. for (var i = 0; i < len && !this.closed; i++) {
  7220. windows[i].next(value);
  7221. }
  7222. var c = this.count - windowSize + 1;
  7223. if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
  7224. windows.shift().complete();
  7225. }
  7226. if (++this.count % startWindowEvery === 0 && !this.closed) {
  7227. var window_1 = new Subject();
  7228. windows.push(window_1);
  7229. destination.next(window_1);
  7230. }
  7231. };
  7232. WindowCountSubscriber.prototype._error = function (err) {
  7233. var windows = this.windows;
  7234. if (windows) {
  7235. while (windows.length > 0 && !this.closed) {
  7236. windows.shift().error(err);
  7237. }
  7238. }
  7239. this.destination.error(err);
  7240. };
  7241. WindowCountSubscriber.prototype._complete = function () {
  7242. var windows = this.windows;
  7243. if (windows) {
  7244. while (windows.length > 0 && !this.closed) {
  7245. windows.shift().complete();
  7246. }
  7247. }
  7248. this.destination.complete();
  7249. };
  7250. WindowCountSubscriber.prototype._unsubscribe = function () {
  7251. this.count = 0;
  7252. this.windows = null;
  7253. };
  7254. return WindowCountSubscriber;
  7255. }(Subscriber));
  7256. function windowTime(windowTimeSpan) {
  7257. var scheduler = async;
  7258. var windowCreationInterval = null;
  7259. var maxWindowSize = Number.POSITIVE_INFINITY;
  7260. if (isScheduler(arguments[3])) {
  7261. scheduler = arguments[3];
  7262. }
  7263. if (isScheduler(arguments[2])) {
  7264. scheduler = arguments[2];
  7265. }
  7266. else if (isNumeric(arguments[2])) {
  7267. maxWindowSize = arguments[2];
  7268. }
  7269. if (isScheduler(arguments[1])) {
  7270. scheduler = arguments[1];
  7271. }
  7272. else if (isNumeric(arguments[1])) {
  7273. windowCreationInterval = arguments[1];
  7274. }
  7275. return function windowTimeOperatorFunction(source) {
  7276. return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
  7277. };
  7278. }
  7279. var WindowTimeOperator = (function () {
  7280. function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
  7281. this.windowTimeSpan = windowTimeSpan;
  7282. this.windowCreationInterval = windowCreationInterval;
  7283. this.maxWindowSize = maxWindowSize;
  7284. this.scheduler = scheduler;
  7285. }
  7286. WindowTimeOperator.prototype.call = function (subscriber, source) {
  7287. return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
  7288. };
  7289. return WindowTimeOperator;
  7290. }());
  7291. var CountedSubject = (function (_super) {
  7292. __extends(CountedSubject, _super);
  7293. function CountedSubject() {
  7294. var _this = _super !== null && _super.apply(this, arguments) || this;
  7295. _this._numberOfNextedValues = 0;
  7296. return _this;
  7297. }
  7298. CountedSubject.prototype.next = function (value) {
  7299. this._numberOfNextedValues++;
  7300. _super.prototype.next.call(this, value);
  7301. };
  7302. Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
  7303. get: function () {
  7304. return this._numberOfNextedValues;
  7305. },
  7306. enumerable: true,
  7307. configurable: true
  7308. });
  7309. return CountedSubject;
  7310. }(Subject));
  7311. var WindowTimeSubscriber = (function (_super) {
  7312. __extends(WindowTimeSubscriber, _super);
  7313. function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
  7314. var _this = _super.call(this, destination) || this;
  7315. _this.destination = destination;
  7316. _this.windowTimeSpan = windowTimeSpan;
  7317. _this.windowCreationInterval = windowCreationInterval;
  7318. _this.maxWindowSize = maxWindowSize;
  7319. _this.scheduler = scheduler;
  7320. _this.windows = [];
  7321. var window = _this.openWindow();
  7322. if (windowCreationInterval !== null && windowCreationInterval >= 0) {
  7323. var closeState = { subscriber: _this, window: window, context: null };
  7324. var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
  7325. _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
  7326. _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
  7327. }
  7328. else {
  7329. var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
  7330. _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
  7331. }
  7332. return _this;
  7333. }
  7334. WindowTimeSubscriber.prototype._next = function (value) {
  7335. var windows = this.windows;
  7336. var len = windows.length;
  7337. for (var i = 0; i < len; i++) {
  7338. var window_1 = windows[i];
  7339. if (!window_1.closed) {
  7340. window_1.next(value);
  7341. if (window_1.numberOfNextedValues >= this.maxWindowSize) {
  7342. this.closeWindow(window_1);
  7343. }
  7344. }
  7345. }
  7346. };
  7347. WindowTimeSubscriber.prototype._error = function (err) {
  7348. var windows = this.windows;
  7349. while (windows.length > 0) {
  7350. windows.shift().error(err);
  7351. }
  7352. this.destination.error(err);
  7353. };
  7354. WindowTimeSubscriber.prototype._complete = function () {
  7355. var windows = this.windows;
  7356. while (windows.length > 0) {
  7357. var window_2 = windows.shift();
  7358. if (!window_2.closed) {
  7359. window_2.complete();
  7360. }
  7361. }
  7362. this.destination.complete();
  7363. };
  7364. WindowTimeSubscriber.prototype.openWindow = function () {
  7365. var window = new CountedSubject();
  7366. this.windows.push(window);
  7367. var destination = this.destination;
  7368. destination.next(window);
  7369. return window;
  7370. };
  7371. WindowTimeSubscriber.prototype.closeWindow = function (window) {
  7372. window.complete();
  7373. var windows = this.windows;
  7374. windows.splice(windows.indexOf(window), 1);
  7375. };
  7376. return WindowTimeSubscriber;
  7377. }(Subscriber));
  7378. function dispatchWindowTimeSpanOnly(state) {
  7379. var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
  7380. if (window) {
  7381. subscriber.closeWindow(window);
  7382. }
  7383. state.window = subscriber.openWindow();
  7384. this.schedule(state, windowTimeSpan);
  7385. }
  7386. function dispatchWindowCreation(state) {
  7387. var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
  7388. var window = subscriber.openWindow();
  7389. var action = this;
  7390. var context = { action: action, subscription: null };
  7391. var timeSpanState = { subscriber: subscriber, window: window, context: context };
  7392. context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
  7393. action.add(context.subscription);
  7394. action.schedule(state, windowCreationInterval);
  7395. }
  7396. function dispatchWindowClose(state) {
  7397. var subscriber = state.subscriber, window = state.window, context = state.context;
  7398. if (context && context.action && context.subscription) {
  7399. context.action.remove(context.subscription);
  7400. }
  7401. subscriber.closeWindow(window);
  7402. }
  7403. function windowToggle(openings, closingSelector) {
  7404. return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
  7405. }
  7406. var WindowToggleOperator = (function () {
  7407. function WindowToggleOperator(openings, closingSelector) {
  7408. this.openings = openings;
  7409. this.closingSelector = closingSelector;
  7410. }
  7411. WindowToggleOperator.prototype.call = function (subscriber, source) {
  7412. return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
  7413. };
  7414. return WindowToggleOperator;
  7415. }());
  7416. var WindowToggleSubscriber = (function (_super) {
  7417. __extends(WindowToggleSubscriber, _super);
  7418. function WindowToggleSubscriber(destination, openings, closingSelector) {
  7419. var _this = _super.call(this, destination) || this;
  7420. _this.openings = openings;
  7421. _this.closingSelector = closingSelector;
  7422. _this.contexts = [];
  7423. _this.add(_this.openSubscription = subscribeToResult(_this, openings, openings));
  7424. return _this;
  7425. }
  7426. WindowToggleSubscriber.prototype._next = function (value) {
  7427. var contexts = this.contexts;
  7428. if (contexts) {
  7429. var len = contexts.length;
  7430. for (var i = 0; i < len; i++) {
  7431. contexts[i].window.next(value);
  7432. }
  7433. }
  7434. };
  7435. WindowToggleSubscriber.prototype._error = function (err) {
  7436. var contexts = this.contexts;
  7437. this.contexts = null;
  7438. if (contexts) {
  7439. var len = contexts.length;
  7440. var index = -1;
  7441. while (++index < len) {
  7442. var context_1 = contexts[index];
  7443. context_1.window.error(err);
  7444. context_1.subscription.unsubscribe();
  7445. }
  7446. }
  7447. _super.prototype._error.call(this, err);
  7448. };
  7449. WindowToggleSubscriber.prototype._complete = function () {
  7450. var contexts = this.contexts;
  7451. this.contexts = null;
  7452. if (contexts) {
  7453. var len = contexts.length;
  7454. var index = -1;
  7455. while (++index < len) {
  7456. var context_2 = contexts[index];
  7457. context_2.window.complete();
  7458. context_2.subscription.unsubscribe();
  7459. }
  7460. }
  7461. _super.prototype._complete.call(this);
  7462. };
  7463. WindowToggleSubscriber.prototype._unsubscribe = function () {
  7464. var contexts = this.contexts;
  7465. this.contexts = null;
  7466. if (contexts) {
  7467. var len = contexts.length;
  7468. var index = -1;
  7469. while (++index < len) {
  7470. var context_3 = contexts[index];
  7471. context_3.window.unsubscribe();
  7472. context_3.subscription.unsubscribe();
  7473. }
  7474. }
  7475. };
  7476. WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7477. if (outerValue === this.openings) {
  7478. var closingNotifier = void 0;
  7479. try {
  7480. var closingSelector = this.closingSelector;
  7481. closingNotifier = closingSelector(innerValue);
  7482. }
  7483. catch (e) {
  7484. return this.error(e);
  7485. }
  7486. var window_1 = new Subject();
  7487. var subscription = new Subscription();
  7488. var context_4 = { window: window_1, subscription: subscription };
  7489. this.contexts.push(context_4);
  7490. var innerSubscription = subscribeToResult(this, closingNotifier, context_4);
  7491. if (innerSubscription.closed) {
  7492. this.closeWindow(this.contexts.length - 1);
  7493. }
  7494. else {
  7495. innerSubscription.context = context_4;
  7496. subscription.add(innerSubscription);
  7497. }
  7498. this.destination.next(window_1);
  7499. }
  7500. else {
  7501. this.closeWindow(this.contexts.indexOf(outerValue));
  7502. }
  7503. };
  7504. WindowToggleSubscriber.prototype.notifyError = function (err) {
  7505. this.error(err);
  7506. };
  7507. WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
  7508. if (inner !== this.openSubscription) {
  7509. this.closeWindow(this.contexts.indexOf(inner.context));
  7510. }
  7511. };
  7512. WindowToggleSubscriber.prototype.closeWindow = function (index) {
  7513. if (index === -1) {
  7514. return;
  7515. }
  7516. var contexts = this.contexts;
  7517. var context = contexts[index];
  7518. var window = context.window, subscription = context.subscription;
  7519. contexts.splice(index, 1);
  7520. window.complete();
  7521. subscription.unsubscribe();
  7522. };
  7523. return WindowToggleSubscriber;
  7524. }(OuterSubscriber));
  7525. function windowWhen(closingSelector) {
  7526. return function windowWhenOperatorFunction(source) {
  7527. return source.lift(new WindowOperator$1(closingSelector));
  7528. };
  7529. }
  7530. var WindowOperator$1 = (function () {
  7531. function WindowOperator(closingSelector) {
  7532. this.closingSelector = closingSelector;
  7533. }
  7534. WindowOperator.prototype.call = function (subscriber, source) {
  7535. return source.subscribe(new WindowSubscriber$1(subscriber, this.closingSelector));
  7536. };
  7537. return WindowOperator;
  7538. }());
  7539. var WindowSubscriber$1 = (function (_super) {
  7540. __extends(WindowSubscriber, _super);
  7541. function WindowSubscriber(destination, closingSelector) {
  7542. var _this = _super.call(this, destination) || this;
  7543. _this.destination = destination;
  7544. _this.closingSelector = closingSelector;
  7545. _this.openWindow();
  7546. return _this;
  7547. }
  7548. WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7549. this.openWindow(innerSub);
  7550. };
  7551. WindowSubscriber.prototype.notifyError = function (error, innerSub) {
  7552. this._error(error);
  7553. };
  7554. WindowSubscriber.prototype.notifyComplete = function (innerSub) {
  7555. this.openWindow(innerSub);
  7556. };
  7557. WindowSubscriber.prototype._next = function (value) {
  7558. this.window.next(value);
  7559. };
  7560. WindowSubscriber.prototype._error = function (err) {
  7561. this.window.error(err);
  7562. this.destination.error(err);
  7563. this.unsubscribeClosingNotification();
  7564. };
  7565. WindowSubscriber.prototype._complete = function () {
  7566. this.window.complete();
  7567. this.destination.complete();
  7568. this.unsubscribeClosingNotification();
  7569. };
  7570. WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
  7571. if (this.closingNotification) {
  7572. this.closingNotification.unsubscribe();
  7573. }
  7574. };
  7575. WindowSubscriber.prototype.openWindow = function (innerSub) {
  7576. if (innerSub === void 0) { innerSub = null; }
  7577. if (innerSub) {
  7578. this.remove(innerSub);
  7579. innerSub.unsubscribe();
  7580. }
  7581. var prevWindow = this.window;
  7582. if (prevWindow) {
  7583. prevWindow.complete();
  7584. }
  7585. var window = this.window = new Subject();
  7586. this.destination.next(window);
  7587. var closingNotifier;
  7588. try {
  7589. var closingSelector = this.closingSelector;
  7590. closingNotifier = closingSelector();
  7591. }
  7592. catch (e) {
  7593. this.destination.error(e);
  7594. this.window.error(e);
  7595. return;
  7596. }
  7597. this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
  7598. };
  7599. return WindowSubscriber;
  7600. }(OuterSubscriber));
  7601. function withLatestFrom() {
  7602. var args = [];
  7603. for (var _i = 0; _i < arguments.length; _i++) {
  7604. args[_i] = arguments[_i];
  7605. }
  7606. return function (source) {
  7607. var project;
  7608. if (typeof args[args.length - 1] === 'function') {
  7609. project = args.pop();
  7610. }
  7611. var observables = args;
  7612. return source.lift(new WithLatestFromOperator(observables, project));
  7613. };
  7614. }
  7615. var WithLatestFromOperator = (function () {
  7616. function WithLatestFromOperator(observables, project) {
  7617. this.observables = observables;
  7618. this.project = project;
  7619. }
  7620. WithLatestFromOperator.prototype.call = function (subscriber, source) {
  7621. return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
  7622. };
  7623. return WithLatestFromOperator;
  7624. }());
  7625. var WithLatestFromSubscriber = (function (_super) {
  7626. __extends(WithLatestFromSubscriber, _super);
  7627. function WithLatestFromSubscriber(destination, observables, project) {
  7628. var _this = _super.call(this, destination) || this;
  7629. _this.observables = observables;
  7630. _this.project = project;
  7631. _this.toRespond = [];
  7632. var len = observables.length;
  7633. _this.values = new Array(len);
  7634. for (var i = 0; i < len; i++) {
  7635. _this.toRespond.push(i);
  7636. }
  7637. for (var i = 0; i < len; i++) {
  7638. var observable = observables[i];
  7639. _this.add(subscribeToResult(_this, observable, observable, i));
  7640. }
  7641. return _this;
  7642. }
  7643. WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7644. this.values[outerIndex] = innerValue;
  7645. var toRespond = this.toRespond;
  7646. if (toRespond.length > 0) {
  7647. var found = toRespond.indexOf(outerIndex);
  7648. if (found !== -1) {
  7649. toRespond.splice(found, 1);
  7650. }
  7651. }
  7652. };
  7653. WithLatestFromSubscriber.prototype.notifyComplete = function () {
  7654. };
  7655. WithLatestFromSubscriber.prototype._next = function (value) {
  7656. if (this.toRespond.length === 0) {
  7657. var args = [value].concat(this.values);
  7658. if (this.project) {
  7659. this._tryProject(args);
  7660. }
  7661. else {
  7662. this.destination.next(args);
  7663. }
  7664. }
  7665. };
  7666. WithLatestFromSubscriber.prototype._tryProject = function (args) {
  7667. var result;
  7668. try {
  7669. result = this.project.apply(this, args);
  7670. }
  7671. catch (err) {
  7672. this.destination.error(err);
  7673. return;
  7674. }
  7675. this.destination.next(result);
  7676. };
  7677. return WithLatestFromSubscriber;
  7678. }(OuterSubscriber));
  7679. function zip$1() {
  7680. var observables = [];
  7681. for (var _i = 0; _i < arguments.length; _i++) {
  7682. observables[_i] = arguments[_i];
  7683. }
  7684. return function zipOperatorFunction(source) {
  7685. return source.lift.call(zip.apply(void 0, [source].concat(observables)));
  7686. };
  7687. }
  7688. function zipAll(project) {
  7689. return function (source) { return source.lift(new ZipOperator(project)); };
  7690. }
  7691. var _operators = /*#__PURE__*/Object.freeze({
  7692. audit: audit,
  7693. auditTime: auditTime,
  7694. buffer: buffer,
  7695. bufferCount: bufferCount,
  7696. bufferTime: bufferTime,
  7697. bufferToggle: bufferToggle,
  7698. bufferWhen: bufferWhen,
  7699. catchError: catchError,
  7700. combineAll: combineAll,
  7701. combineLatest: combineLatest$1,
  7702. concat: concat$1,
  7703. concatAll: concatAll,
  7704. concatMap: concatMap,
  7705. concatMapTo: concatMapTo,
  7706. count: count,
  7707. debounce: debounce,
  7708. debounceTime: debounceTime,
  7709. defaultIfEmpty: defaultIfEmpty,
  7710. delay: delay,
  7711. delayWhen: delayWhen,
  7712. dematerialize: dematerialize,
  7713. distinct: distinct,
  7714. distinctUntilChanged: distinctUntilChanged,
  7715. distinctUntilKeyChanged: distinctUntilKeyChanged,
  7716. elementAt: elementAt,
  7717. endWith: endWith,
  7718. every: every,
  7719. exhaust: exhaust,
  7720. exhaustMap: exhaustMap,
  7721. expand: expand,
  7722. filter: filter,
  7723. finalize: finalize,
  7724. find: find,
  7725. findIndex: findIndex,
  7726. first: first,
  7727. groupBy: groupBy,
  7728. ignoreElements: ignoreElements,
  7729. isEmpty: isEmpty,
  7730. last: last,
  7731. map: map,
  7732. mapTo: mapTo,
  7733. materialize: materialize,
  7734. max: max,
  7735. merge: merge$1,
  7736. mergeAll: mergeAll,
  7737. mergeMap: mergeMap,
  7738. flatMap: mergeMap,
  7739. mergeMapTo: mergeMapTo,
  7740. mergeScan: mergeScan,
  7741. min: min,
  7742. multicast: multicast,
  7743. observeOn: observeOn,
  7744. onErrorResumeNext: onErrorResumeNext$1,
  7745. pairwise: pairwise,
  7746. partition: partition$1,
  7747. pluck: pluck,
  7748. publish: publish,
  7749. publishBehavior: publishBehavior,
  7750. publishLast: publishLast,
  7751. publishReplay: publishReplay,
  7752. race: race$1,
  7753. reduce: reduce,
  7754. repeat: repeat,
  7755. repeatWhen: repeatWhen,
  7756. retry: retry,
  7757. retryWhen: retryWhen,
  7758. refCount: refCount,
  7759. sample: sample,
  7760. sampleTime: sampleTime,
  7761. scan: scan,
  7762. sequenceEqual: sequenceEqual,
  7763. share: share,
  7764. shareReplay: shareReplay,
  7765. single: single,
  7766. skip: skip,
  7767. skipLast: skipLast,
  7768. skipUntil: skipUntil,
  7769. skipWhile: skipWhile,
  7770. startWith: startWith,
  7771. subscribeOn: subscribeOn,
  7772. switchAll: switchAll,
  7773. switchMap: switchMap,
  7774. switchMapTo: switchMapTo,
  7775. take: take,
  7776. takeLast: takeLast,
  7777. takeUntil: takeUntil,
  7778. takeWhile: takeWhile,
  7779. tap: tap,
  7780. throttle: throttle,
  7781. throttleTime: throttleTime,
  7782. throwIfEmpty: throwIfEmpty,
  7783. timeInterval: timeInterval,
  7784. timeout: timeout,
  7785. timeoutWith: timeoutWith,
  7786. timestamp: timestamp,
  7787. toArray: toArray,
  7788. window: window$1,
  7789. windowCount: windowCount,
  7790. windowTime: windowTime,
  7791. windowToggle: windowToggle,
  7792. windowWhen: windowWhen,
  7793. withLatestFrom: withLatestFrom,
  7794. zip: zip$1,
  7795. zipAll: zipAll
  7796. });
  7797. var SubscriptionLog = (function () {
  7798. function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
  7799. if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
  7800. this.subscribedFrame = subscribedFrame;
  7801. this.unsubscribedFrame = unsubscribedFrame;
  7802. }
  7803. return SubscriptionLog;
  7804. }());
  7805. var SubscriptionLoggable = (function () {
  7806. function SubscriptionLoggable() {
  7807. this.subscriptions = [];
  7808. }
  7809. SubscriptionLoggable.prototype.logSubscribedFrame = function () {
  7810. this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
  7811. return this.subscriptions.length - 1;
  7812. };
  7813. SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
  7814. var subscriptionLogs = this.subscriptions;
  7815. var oldSubscriptionLog = subscriptionLogs[index];
  7816. subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
  7817. };
  7818. return SubscriptionLoggable;
  7819. }());
  7820. function applyMixins(derivedCtor, baseCtors) {
  7821. for (var i = 0, len = baseCtors.length; i < len; i++) {
  7822. var baseCtor = baseCtors[i];
  7823. var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype);
  7824. for (var j = 0, len2 = propertyKeys.length; j < len2; j++) {
  7825. var name_1 = propertyKeys[j];
  7826. derivedCtor.prototype[name_1] = baseCtor.prototype[name_1];
  7827. }
  7828. }
  7829. }
  7830. var ColdObservable = (function (_super) {
  7831. __extends(ColdObservable, _super);
  7832. function ColdObservable(messages, scheduler) {
  7833. var _this = _super.call(this, function (subscriber) {
  7834. var observable = this;
  7835. var index = observable.logSubscribedFrame();
  7836. var subscription = new Subscription();
  7837. subscription.add(new Subscription(function () {
  7838. observable.logUnsubscribedFrame(index);
  7839. }));
  7840. observable.scheduleMessages(subscriber);
  7841. return subscription;
  7842. }) || this;
  7843. _this.messages = messages;
  7844. _this.subscriptions = [];
  7845. _this.scheduler = scheduler;
  7846. return _this;
  7847. }
  7848. ColdObservable.prototype.scheduleMessages = function (subscriber) {
  7849. var messagesLength = this.messages.length;
  7850. for (var i = 0; i < messagesLength; i++) {
  7851. var message = this.messages[i];
  7852. subscriber.add(this.scheduler.schedule(function (_a) {
  7853. var message = _a.message, subscriber = _a.subscriber;
  7854. message.notification.observe(subscriber);
  7855. }, message.frame, { message: message, subscriber: subscriber }));
  7856. }
  7857. };
  7858. return ColdObservable;
  7859. }(Observable));
  7860. applyMixins(ColdObservable, [SubscriptionLoggable]);
  7861. var HotObservable = (function (_super) {
  7862. __extends(HotObservable, _super);
  7863. function HotObservable(messages, scheduler) {
  7864. var _this = _super.call(this) || this;
  7865. _this.messages = messages;
  7866. _this.subscriptions = [];
  7867. _this.scheduler = scheduler;
  7868. return _this;
  7869. }
  7870. HotObservable.prototype._subscribe = function (subscriber) {
  7871. var subject = this;
  7872. var index = subject.logSubscribedFrame();
  7873. var subscription = new Subscription();
  7874. subscription.add(new Subscription(function () {
  7875. subject.logUnsubscribedFrame(index);
  7876. }));
  7877. subscription.add(_super.prototype._subscribe.call(this, subscriber));
  7878. return subscription;
  7879. };
  7880. HotObservable.prototype.setup = function () {
  7881. var subject = this;
  7882. var messagesLength = subject.messages.length;
  7883. for (var i = 0; i < messagesLength; i++) {
  7884. (function () {
  7885. var message = subject.messages[i];
  7886. subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
  7887. })();
  7888. }
  7889. };
  7890. return HotObservable;
  7891. }(Subject));
  7892. applyMixins(HotObservable, [SubscriptionLoggable]);
  7893. var defaultMaxFrame = 750;
  7894. var TestScheduler = (function (_super) {
  7895. __extends(TestScheduler, _super);
  7896. function TestScheduler(assertDeepEqual) {
  7897. var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this;
  7898. _this.assertDeepEqual = assertDeepEqual;
  7899. _this.hotObservables = [];
  7900. _this.coldObservables = [];
  7901. _this.flushTests = [];
  7902. _this.runMode = false;
  7903. return _this;
  7904. }
  7905. TestScheduler.prototype.createTime = function (marbles) {
  7906. var indexOf = marbles.indexOf('|');
  7907. if (indexOf === -1) {
  7908. throw new Error('marble diagram for time should have a completion marker "|"');
  7909. }
  7910. return indexOf * TestScheduler.frameTimeFactor;
  7911. };
  7912. TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
  7913. if (marbles.indexOf('^') !== -1) {
  7914. throw new Error('cold observable cannot have subscription offset "^"');
  7915. }
  7916. if (marbles.indexOf('!') !== -1) {
  7917. throw new Error('cold observable cannot have unsubscription marker "!"');
  7918. }
  7919. var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
  7920. var cold = new ColdObservable(messages, this);
  7921. this.coldObservables.push(cold);
  7922. return cold;
  7923. };
  7924. TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
  7925. if (marbles.indexOf('!') !== -1) {
  7926. throw new Error('hot observable cannot have unsubscription marker "!"');
  7927. }
  7928. var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
  7929. var subject = new HotObservable(messages, this);
  7930. this.hotObservables.push(subject);
  7931. return subject;
  7932. };
  7933. TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
  7934. var _this = this;
  7935. var messages = [];
  7936. observable.subscribe(function (value) {
  7937. messages.push({ frame: _this.frame - outerFrame, notification: Notification.createNext(value) });
  7938. }, function (err) {
  7939. messages.push({ frame: _this.frame - outerFrame, notification: Notification.createError(err) });
  7940. }, function () {
  7941. messages.push({ frame: _this.frame - outerFrame, notification: Notification.createComplete() });
  7942. });
  7943. return messages;
  7944. };
  7945. TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
  7946. var _this = this;
  7947. if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
  7948. var actual = [];
  7949. var flushTest = { actual: actual, ready: false };
  7950. var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
  7951. var subscriptionFrame = subscriptionParsed.subscribedFrame === Number.POSITIVE_INFINITY ?
  7952. 0 : subscriptionParsed.subscribedFrame;
  7953. var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
  7954. var subscription;
  7955. this.schedule(function () {
  7956. subscription = observable.subscribe(function (x) {
  7957. var value = x;
  7958. if (x instanceof Observable) {
  7959. value = _this.materializeInnerObservable(value, _this.frame);
  7960. }
  7961. actual.push({ frame: _this.frame, notification: Notification.createNext(value) });
  7962. }, function (err) {
  7963. actual.push({ frame: _this.frame, notification: Notification.createError(err) });
  7964. }, function () {
  7965. actual.push({ frame: _this.frame, notification: Notification.createComplete() });
  7966. });
  7967. }, subscriptionFrame);
  7968. if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
  7969. this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
  7970. }
  7971. this.flushTests.push(flushTest);
  7972. var runMode = this.runMode;
  7973. return {
  7974. toBe: function (marbles, values, errorValue) {
  7975. flushTest.ready = true;
  7976. flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
  7977. }
  7978. };
  7979. };
  7980. TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
  7981. var flushTest = { actual: actualSubscriptionLogs, ready: false };
  7982. this.flushTests.push(flushTest);
  7983. var runMode = this.runMode;
  7984. return {
  7985. toBe: function (marbles) {
  7986. var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
  7987. flushTest.ready = true;
  7988. flushTest.expected = marblesArray.map(function (marbles) {
  7989. return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode);
  7990. });
  7991. }
  7992. };
  7993. };
  7994. TestScheduler.prototype.flush = function () {
  7995. var _this = this;
  7996. var hotObservables = this.hotObservables;
  7997. while (hotObservables.length > 0) {
  7998. hotObservables.shift().setup();
  7999. }
  8000. _super.prototype.flush.call(this);
  8001. this.flushTests = this.flushTests.filter(function (test) {
  8002. if (test.ready) {
  8003. _this.assertDeepEqual(test.actual, test.expected);
  8004. return false;
  8005. }
  8006. return true;
  8007. });
  8008. };
  8009. TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
  8010. var _this = this;
  8011. if (runMode === void 0) { runMode = false; }
  8012. if (typeof marbles !== 'string') {
  8013. return new SubscriptionLog(Number.POSITIVE_INFINITY);
  8014. }
  8015. var len = marbles.length;
  8016. var groupStart = -1;
  8017. var subscriptionFrame = Number.POSITIVE_INFINITY;
  8018. var unsubscriptionFrame = Number.POSITIVE_INFINITY;
  8019. var frame = 0;
  8020. var _loop_1 = function (i) {
  8021. var nextFrame = frame;
  8022. var advanceFrameBy = function (count) {
  8023. nextFrame += count * _this.frameTimeFactor;
  8024. };
  8025. var c = marbles[i];
  8026. switch (c) {
  8027. case ' ':
  8028. if (!runMode) {
  8029. advanceFrameBy(1);
  8030. }
  8031. break;
  8032. case '-':
  8033. advanceFrameBy(1);
  8034. break;
  8035. case '(':
  8036. groupStart = frame;
  8037. advanceFrameBy(1);
  8038. break;
  8039. case ')':
  8040. groupStart = -1;
  8041. advanceFrameBy(1);
  8042. break;
  8043. case '^':
  8044. if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
  8045. throw new Error('found a second subscription point \'^\' in a ' +
  8046. 'subscription marble diagram. There can only be one.');
  8047. }
  8048. subscriptionFrame = groupStart > -1 ? groupStart : frame;
  8049. advanceFrameBy(1);
  8050. break;
  8051. case '!':
  8052. if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
  8053. throw new Error('found a second subscription point \'^\' in a ' +
  8054. 'subscription marble diagram. There can only be one.');
  8055. }
  8056. unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
  8057. break;
  8058. default:
  8059. if (runMode && c.match(/^[0-9]$/)) {
  8060. if (i === 0 || marbles[i - 1] === ' ') {
  8061. var buffer = marbles.slice(i);
  8062. var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
  8063. if (match) {
  8064. i += match[0].length - 1;
  8065. var duration = parseFloat(match[1]);
  8066. var unit = match[2];
  8067. var durationInMs = void 0;
  8068. switch (unit) {
  8069. case 'ms':
  8070. durationInMs = duration;
  8071. break;
  8072. case 's':
  8073. durationInMs = duration * 1000;
  8074. break;
  8075. case 'm':
  8076. durationInMs = duration * 1000 * 60;
  8077. break;
  8078. default:
  8079. break;
  8080. }
  8081. advanceFrameBy(durationInMs / this_1.frameTimeFactor);
  8082. break;
  8083. }
  8084. }
  8085. }
  8086. throw new Error('there can only be \'^\' and \'!\' markers in a ' +
  8087. 'subscription marble diagram. Found instead \'' + c + '\'.');
  8088. }
  8089. frame = nextFrame;
  8090. out_i_1 = i;
  8091. };
  8092. var this_1 = this, out_i_1;
  8093. for (var i = 0; i < len; i++) {
  8094. _loop_1(i);
  8095. i = out_i_1;
  8096. }
  8097. if (unsubscriptionFrame < 0) {
  8098. return new SubscriptionLog(subscriptionFrame);
  8099. }
  8100. else {
  8101. return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
  8102. }
  8103. };
  8104. TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
  8105. var _this = this;
  8106. if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
  8107. if (runMode === void 0) { runMode = false; }
  8108. if (marbles.indexOf('!') !== -1) {
  8109. throw new Error('conventional marble diagrams cannot have the ' +
  8110. 'unsubscription marker "!"');
  8111. }
  8112. var len = marbles.length;
  8113. var testMessages = [];
  8114. var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
  8115. var frame = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
  8116. var getValue = typeof values !== 'object' ?
  8117. function (x) { return x; } :
  8118. function (x) {
  8119. if (materializeInnerObservables && values[x] instanceof ColdObservable) {
  8120. return values[x].messages;
  8121. }
  8122. return values[x];
  8123. };
  8124. var groupStart = -1;
  8125. var _loop_2 = function (i) {
  8126. var nextFrame = frame;
  8127. var advanceFrameBy = function (count) {
  8128. nextFrame += count * _this.frameTimeFactor;
  8129. };
  8130. var notification = void 0;
  8131. var c = marbles[i];
  8132. switch (c) {
  8133. case ' ':
  8134. if (!runMode) {
  8135. advanceFrameBy(1);
  8136. }
  8137. break;
  8138. case '-':
  8139. advanceFrameBy(1);
  8140. break;
  8141. case '(':
  8142. groupStart = frame;
  8143. advanceFrameBy(1);
  8144. break;
  8145. case ')':
  8146. groupStart = -1;
  8147. advanceFrameBy(1);
  8148. break;
  8149. case '|':
  8150. notification = Notification.createComplete();
  8151. advanceFrameBy(1);
  8152. break;
  8153. case '^':
  8154. advanceFrameBy(1);
  8155. break;
  8156. case '#':
  8157. notification = Notification.createError(errorValue || 'error');
  8158. advanceFrameBy(1);
  8159. break;
  8160. default:
  8161. if (runMode && c.match(/^[0-9]$/)) {
  8162. if (i === 0 || marbles[i - 1] === ' ') {
  8163. var buffer = marbles.slice(i);
  8164. var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
  8165. if (match) {
  8166. i += match[0].length - 1;
  8167. var duration = parseFloat(match[1]);
  8168. var unit = match[2];
  8169. var durationInMs = void 0;
  8170. switch (unit) {
  8171. case 'ms':
  8172. durationInMs = duration;
  8173. break;
  8174. case 's':
  8175. durationInMs = duration * 1000;
  8176. break;
  8177. case 'm':
  8178. durationInMs = duration * 1000 * 60;
  8179. break;
  8180. default:
  8181. break;
  8182. }
  8183. advanceFrameBy(durationInMs / this_2.frameTimeFactor);
  8184. break;
  8185. }
  8186. }
  8187. }
  8188. notification = Notification.createNext(getValue(c));
  8189. advanceFrameBy(1);
  8190. break;
  8191. }
  8192. if (notification) {
  8193. testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
  8194. }
  8195. frame = nextFrame;
  8196. out_i_2 = i;
  8197. };
  8198. var this_2 = this, out_i_2;
  8199. for (var i = 0; i < len; i++) {
  8200. _loop_2(i);
  8201. i = out_i_2;
  8202. }
  8203. return testMessages;
  8204. };
  8205. TestScheduler.prototype.run = function (callback) {
  8206. var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
  8207. var prevMaxFrames = this.maxFrames;
  8208. TestScheduler.frameTimeFactor = 1;
  8209. this.maxFrames = Number.POSITIVE_INFINITY;
  8210. this.runMode = true;
  8211. AsyncScheduler.delegate = this;
  8212. var helpers = {
  8213. cold: this.createColdObservable.bind(this),
  8214. hot: this.createHotObservable.bind(this),
  8215. flush: this.flush.bind(this),
  8216. expectObservable: this.expectObservable.bind(this),
  8217. expectSubscriptions: this.expectSubscriptions.bind(this),
  8218. };
  8219. try {
  8220. var ret = callback(helpers);
  8221. this.flush();
  8222. return ret;
  8223. }
  8224. finally {
  8225. TestScheduler.frameTimeFactor = prevFrameTimeFactor;
  8226. this.maxFrames = prevMaxFrames;
  8227. this.runMode = false;
  8228. AsyncScheduler.delegate = undefined;
  8229. }
  8230. };
  8231. return TestScheduler;
  8232. }(VirtualTimeScheduler));
  8233. var _testing = /*#__PURE__*/Object.freeze({
  8234. TestScheduler: TestScheduler
  8235. });
  8236. var __window = typeof window !== 'undefined' && window;
  8237. var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
  8238. self instanceof WorkerGlobalScope && self;
  8239. var __global = typeof global !== 'undefined' && global;
  8240. var _root = __window || __global || __self;
  8241. (function () {
  8242. if (!_root) {
  8243. throw new Error('RxJS could not find any global context (window, self, global)');
  8244. }
  8245. })();
  8246. function getCORSRequest() {
  8247. if (_root.XMLHttpRequest) {
  8248. return new _root.XMLHttpRequest();
  8249. }
  8250. else if (!!_root.XDomainRequest) {
  8251. return new _root.XDomainRequest();
  8252. }
  8253. else {
  8254. throw new Error('CORS is not supported by your browser');
  8255. }
  8256. }
  8257. function getXMLHttpRequest() {
  8258. if (_root.XMLHttpRequest) {
  8259. return new _root.XMLHttpRequest();
  8260. }
  8261. else {
  8262. var progId = void 0;
  8263. try {
  8264. var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
  8265. for (var i = 0; i < 3; i++) {
  8266. try {
  8267. progId = progIds[i];
  8268. if (new _root.ActiveXObject(progId)) {
  8269. break;
  8270. }
  8271. }
  8272. catch (e) {
  8273. }
  8274. }
  8275. return new _root.ActiveXObject(progId);
  8276. }
  8277. catch (e) {
  8278. throw new Error('XMLHttpRequest is not supported by your browser');
  8279. }
  8280. }
  8281. }
  8282. function ajaxGet(url, headers) {
  8283. if (headers === void 0) { headers = null; }
  8284. return new AjaxObservable({ method: 'GET', url: url, headers: headers });
  8285. }
  8286. function ajaxPost(url, body, headers) {
  8287. return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });
  8288. }
  8289. function ajaxDelete(url, headers) {
  8290. return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });
  8291. }
  8292. function ajaxPut(url, body, headers) {
  8293. return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });
  8294. }
  8295. function ajaxPatch(url, body, headers) {
  8296. return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers });
  8297. }
  8298. var mapResponse = map(function (x, index) { return x.response; });
  8299. function ajaxGetJSON(url, headers) {
  8300. return mapResponse(new AjaxObservable({
  8301. method: 'GET',
  8302. url: url,
  8303. responseType: 'json',
  8304. headers: headers
  8305. }));
  8306. }
  8307. var AjaxObservable = (function (_super) {
  8308. __extends(AjaxObservable, _super);
  8309. function AjaxObservable(urlOrRequest) {
  8310. var _this = _super.call(this) || this;
  8311. var request = {
  8312. async: true,
  8313. createXHR: function () {
  8314. return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();
  8315. },
  8316. crossDomain: true,
  8317. withCredentials: false,
  8318. headers: {},
  8319. method: 'GET',
  8320. responseType: 'json',
  8321. timeout: 0
  8322. };
  8323. if (typeof urlOrRequest === 'string') {
  8324. request.url = urlOrRequest;
  8325. }
  8326. else {
  8327. for (var prop in urlOrRequest) {
  8328. if (urlOrRequest.hasOwnProperty(prop)) {
  8329. request[prop] = urlOrRequest[prop];
  8330. }
  8331. }
  8332. }
  8333. _this.request = request;
  8334. return _this;
  8335. }
  8336. AjaxObservable.prototype._subscribe = function (subscriber) {
  8337. return new AjaxSubscriber(subscriber, this.request);
  8338. };
  8339. AjaxObservable.create = (function () {
  8340. var create = function (urlOrRequest) {
  8341. return new AjaxObservable(urlOrRequest);
  8342. };
  8343. create.get = ajaxGet;
  8344. create.post = ajaxPost;
  8345. create.delete = ajaxDelete;
  8346. create.put = ajaxPut;
  8347. create.patch = ajaxPatch;
  8348. create.getJSON = ajaxGetJSON;
  8349. return create;
  8350. })();
  8351. return AjaxObservable;
  8352. }(Observable));
  8353. var AjaxSubscriber = (function (_super) {
  8354. __extends(AjaxSubscriber, _super);
  8355. function AjaxSubscriber(destination, request) {
  8356. var _this = _super.call(this, destination) || this;
  8357. _this.request = request;
  8358. _this.done = false;
  8359. var headers = request.headers = request.headers || {};
  8360. if (!request.crossDomain && !_this.getHeader(headers, 'X-Requested-With')) {
  8361. headers['X-Requested-With'] = 'XMLHttpRequest';
  8362. }
  8363. var contentTypeHeader = _this.getHeader(headers, 'Content-Type');
  8364. if (!contentTypeHeader && !(_root.FormData && request.body instanceof _root.FormData) && typeof request.body !== 'undefined') {
  8365. headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
  8366. }
  8367. request.body = _this.serializeBody(request.body, _this.getHeader(request.headers, 'Content-Type'));
  8368. _this.send();
  8369. return _this;
  8370. }
  8371. AjaxSubscriber.prototype.next = function (e) {
  8372. this.done = true;
  8373. var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;
  8374. var result;
  8375. try {
  8376. result = new AjaxResponse(e, xhr, request);
  8377. }
  8378. catch (err) {
  8379. return destination.error(err);
  8380. }
  8381. destination.next(result);
  8382. };
  8383. AjaxSubscriber.prototype.send = function () {
  8384. var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;
  8385. try {
  8386. var xhr = this.xhr = request.createXHR();
  8387. this.setupEvents(xhr, request);
  8388. if (user) {
  8389. xhr.open(method, url, async, user, password);
  8390. }
  8391. else {
  8392. xhr.open(method, url, async);
  8393. }
  8394. if (async) {
  8395. xhr.timeout = request.timeout;
  8396. xhr.responseType = request.responseType;
  8397. }
  8398. if ('withCredentials' in xhr) {
  8399. xhr.withCredentials = !!request.withCredentials;
  8400. }
  8401. this.setHeaders(xhr, headers);
  8402. if (body) {
  8403. xhr.send(body);
  8404. }
  8405. else {
  8406. xhr.send();
  8407. }
  8408. }
  8409. catch (err) {
  8410. this.error(err);
  8411. }
  8412. };
  8413. AjaxSubscriber.prototype.serializeBody = function (body, contentType) {
  8414. if (!body || typeof body === 'string') {
  8415. return body;
  8416. }
  8417. else if (_root.FormData && body instanceof _root.FormData) {
  8418. return body;
  8419. }
  8420. if (contentType) {
  8421. var splitIndex = contentType.indexOf(';');
  8422. if (splitIndex !== -1) {
  8423. contentType = contentType.substring(0, splitIndex);
  8424. }
  8425. }
  8426. switch (contentType) {
  8427. case 'application/x-www-form-urlencoded':
  8428. return Object.keys(body).map(function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(body[key]); }).join('&');
  8429. case 'application/json':
  8430. return JSON.stringify(body);
  8431. default:
  8432. return body;
  8433. }
  8434. };
  8435. AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {
  8436. for (var key in headers) {
  8437. if (headers.hasOwnProperty(key)) {
  8438. xhr.setRequestHeader(key, headers[key]);
  8439. }
  8440. }
  8441. };
  8442. AjaxSubscriber.prototype.getHeader = function (headers, headerName) {
  8443. for (var key in headers) {
  8444. if (key.toLowerCase() === headerName.toLowerCase()) {
  8445. return headers[key];
  8446. }
  8447. }
  8448. return undefined;
  8449. };
  8450. AjaxSubscriber.prototype.setupEvents = function (xhr, request) {
  8451. var progressSubscriber = request.progressSubscriber;
  8452. function xhrTimeout(e) {
  8453. var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
  8454. if (progressSubscriber) {
  8455. progressSubscriber.error(e);
  8456. }
  8457. var error;
  8458. try {
  8459. error = new AjaxTimeoutError(this, request);
  8460. }
  8461. catch (err) {
  8462. error = err;
  8463. }
  8464. subscriber.error(error);
  8465. }
  8466. xhr.ontimeout = xhrTimeout;
  8467. xhrTimeout.request = request;
  8468. xhrTimeout.subscriber = this;
  8469. xhrTimeout.progressSubscriber = progressSubscriber;
  8470. if (xhr.upload && 'withCredentials' in xhr) {
  8471. if (progressSubscriber) {
  8472. var xhrProgress_1;
  8473. xhrProgress_1 = function (e) {
  8474. var progressSubscriber = xhrProgress_1.progressSubscriber;
  8475. progressSubscriber.next(e);
  8476. };
  8477. if (_root.XDomainRequest) {
  8478. xhr.onprogress = xhrProgress_1;
  8479. }
  8480. else {
  8481. xhr.upload.onprogress = xhrProgress_1;
  8482. }
  8483. xhrProgress_1.progressSubscriber = progressSubscriber;
  8484. }
  8485. var xhrError_1;
  8486. xhrError_1 = function (e) {
  8487. var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;
  8488. if (progressSubscriber) {
  8489. progressSubscriber.error(e);
  8490. }
  8491. var error;
  8492. try {
  8493. error = new AjaxError('ajax error', this, request);
  8494. }
  8495. catch (err) {
  8496. error = err;
  8497. }
  8498. subscriber.error(error);
  8499. };
  8500. xhr.onerror = xhrError_1;
  8501. xhrError_1.request = request;
  8502. xhrError_1.subscriber = this;
  8503. xhrError_1.progressSubscriber = progressSubscriber;
  8504. }
  8505. function xhrReadyStateChange(e) {
  8506. return;
  8507. }
  8508. xhr.onreadystatechange = xhrReadyStateChange;
  8509. xhrReadyStateChange.subscriber = this;
  8510. xhrReadyStateChange.progressSubscriber = progressSubscriber;
  8511. xhrReadyStateChange.request = request;
  8512. function xhrLoad(e) {
  8513. var _a = xhrLoad, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
  8514. if (this.readyState === 4) {
  8515. var status_1 = this.status === 1223 ? 204 : this.status;
  8516. var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);
  8517. if (status_1 === 0) {
  8518. status_1 = response ? 200 : 0;
  8519. }
  8520. if (status_1 < 400) {
  8521. if (progressSubscriber) {
  8522. progressSubscriber.complete();
  8523. }
  8524. subscriber.next(e);
  8525. subscriber.complete();
  8526. }
  8527. else {
  8528. if (progressSubscriber) {
  8529. progressSubscriber.error(e);
  8530. }
  8531. var error = void 0;
  8532. try {
  8533. error = new AjaxError('ajax error ' + status_1, this, request);
  8534. }
  8535. catch (err) {
  8536. error = err;
  8537. }
  8538. subscriber.error(error);
  8539. }
  8540. }
  8541. }
  8542. xhr.onload = xhrLoad;
  8543. xhrLoad.subscriber = this;
  8544. xhrLoad.progressSubscriber = progressSubscriber;
  8545. xhrLoad.request = request;
  8546. };
  8547. AjaxSubscriber.prototype.unsubscribe = function () {
  8548. var _a = this, done = _a.done, xhr = _a.xhr;
  8549. if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {
  8550. xhr.abort();
  8551. }
  8552. _super.prototype.unsubscribe.call(this);
  8553. };
  8554. return AjaxSubscriber;
  8555. }(Subscriber));
  8556. var AjaxResponse = (function () {
  8557. function AjaxResponse(originalEvent, xhr, request) {
  8558. this.originalEvent = originalEvent;
  8559. this.xhr = xhr;
  8560. this.request = request;
  8561. this.status = xhr.status;
  8562. this.responseType = xhr.responseType || request.responseType;
  8563. this.response = parseXhrResponse(this.responseType, xhr);
  8564. }
  8565. return AjaxResponse;
  8566. }());
  8567. function AjaxErrorImpl(message, xhr, request) {
  8568. Error.call(this);
  8569. this.message = message;
  8570. this.name = 'AjaxError';
  8571. this.xhr = xhr;
  8572. this.request = request;
  8573. this.status = xhr.status;
  8574. this.responseType = xhr.responseType || request.responseType;
  8575. this.response = parseXhrResponse(this.responseType, xhr);
  8576. return this;
  8577. }
  8578. AjaxErrorImpl.prototype = Object.create(Error.prototype);
  8579. var AjaxError = AjaxErrorImpl;
  8580. function parseJson(xhr) {
  8581. if ('response' in xhr) {
  8582. return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
  8583. }
  8584. else {
  8585. return JSON.parse(xhr.responseText || 'null');
  8586. }
  8587. }
  8588. function parseXhrResponse(responseType, xhr) {
  8589. switch (responseType) {
  8590. case 'json':
  8591. return parseJson(xhr);
  8592. case 'xml':
  8593. return xhr.responseXML;
  8594. case 'text':
  8595. default:
  8596. return ('response' in xhr) ? xhr.response : xhr.responseText;
  8597. }
  8598. }
  8599. function AjaxTimeoutErrorImpl(xhr, request) {
  8600. AjaxError.call(this, 'ajax timeout', xhr, request);
  8601. this.name = 'AjaxTimeoutError';
  8602. return this;
  8603. }
  8604. var AjaxTimeoutError = AjaxTimeoutErrorImpl;
  8605. var ajax = AjaxObservable.create;
  8606. var _ajax = /*#__PURE__*/Object.freeze({
  8607. ajax: ajax,
  8608. AjaxResponse: AjaxResponse,
  8609. AjaxError: AjaxError,
  8610. AjaxTimeoutError: AjaxTimeoutError
  8611. });
  8612. var DEFAULT_WEBSOCKET_CONFIG = {
  8613. url: '',
  8614. deserializer: function (e) { return JSON.parse(e.data); },
  8615. serializer: function (value) { return JSON.stringify(value); },
  8616. };
  8617. var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
  8618. var WebSocketSubject = (function (_super) {
  8619. __extends(WebSocketSubject, _super);
  8620. function WebSocketSubject(urlConfigOrSource, destination) {
  8621. var _this = _super.call(this) || this;
  8622. if (urlConfigOrSource instanceof Observable) {
  8623. _this.destination = destination;
  8624. _this.source = urlConfigOrSource;
  8625. }
  8626. else {
  8627. var config = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
  8628. _this._output = new Subject();
  8629. if (typeof urlConfigOrSource === 'string') {
  8630. config.url = urlConfigOrSource;
  8631. }
  8632. else {
  8633. for (var key in urlConfigOrSource) {
  8634. if (urlConfigOrSource.hasOwnProperty(key)) {
  8635. config[key] = urlConfigOrSource[key];
  8636. }
  8637. }
  8638. }
  8639. if (!config.WebSocketCtor && WebSocket) {
  8640. config.WebSocketCtor = WebSocket;
  8641. }
  8642. else if (!config.WebSocketCtor) {
  8643. throw new Error('no WebSocket constructor can be found');
  8644. }
  8645. _this.destination = new ReplaySubject();
  8646. }
  8647. return _this;
  8648. }
  8649. WebSocketSubject.prototype.lift = function (operator) {
  8650. var sock = new WebSocketSubject(this._config, this.destination);
  8651. sock.operator = operator;
  8652. sock.source = this;
  8653. return sock;
  8654. };
  8655. WebSocketSubject.prototype._resetState = function () {
  8656. this._socket = null;
  8657. if (!this.source) {
  8658. this.destination = new ReplaySubject();
  8659. }
  8660. this._output = new Subject();
  8661. };
  8662. WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
  8663. var self = this;
  8664. return new Observable(function (observer) {
  8665. try {
  8666. self.next(subMsg());
  8667. }
  8668. catch (err) {
  8669. observer.error(err);
  8670. }
  8671. var subscription = self.subscribe(function (x) {
  8672. try {
  8673. if (messageFilter(x)) {
  8674. observer.next(x);
  8675. }
  8676. }
  8677. catch (err) {
  8678. observer.error(err);
  8679. }
  8680. }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
  8681. return function () {
  8682. try {
  8683. self.next(unsubMsg());
  8684. }
  8685. catch (err) {
  8686. observer.error(err);
  8687. }
  8688. subscription.unsubscribe();
  8689. };
  8690. });
  8691. };
  8692. WebSocketSubject.prototype._connectSocket = function () {
  8693. var _this = this;
  8694. var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
  8695. var observer = this._output;
  8696. var socket = null;
  8697. try {
  8698. socket = protocol ?
  8699. new WebSocketCtor(url, protocol) :
  8700. new WebSocketCtor(url);
  8701. this._socket = socket;
  8702. if (binaryType) {
  8703. this._socket.binaryType = binaryType;
  8704. }
  8705. }
  8706. catch (e) {
  8707. observer.error(e);
  8708. return;
  8709. }
  8710. var subscription = new Subscription(function () {
  8711. _this._socket = null;
  8712. if (socket && socket.readyState === 1) {
  8713. socket.close();
  8714. }
  8715. });
  8716. socket.onopen = function (e) {
  8717. var _socket = _this._socket;
  8718. if (!_socket) {
  8719. socket.close();
  8720. _this._resetState();
  8721. return;
  8722. }
  8723. var openObserver = _this._config.openObserver;
  8724. if (openObserver) {
  8725. openObserver.next(e);
  8726. }
  8727. var queue = _this.destination;
  8728. _this.destination = Subscriber.create(function (x) {
  8729. if (socket.readyState === 1) {
  8730. try {
  8731. var serializer = _this._config.serializer;
  8732. socket.send(serializer(x));
  8733. }
  8734. catch (e) {
  8735. _this.destination.error(e);
  8736. }
  8737. }
  8738. }, function (e) {
  8739. var closingObserver = _this._config.closingObserver;
  8740. if (closingObserver) {
  8741. closingObserver.next(undefined);
  8742. }
  8743. if (e && e.code) {
  8744. socket.close(e.code, e.reason);
  8745. }
  8746. else {
  8747. observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
  8748. }
  8749. _this._resetState();
  8750. }, function () {
  8751. var closingObserver = _this._config.closingObserver;
  8752. if (closingObserver) {
  8753. closingObserver.next(undefined);
  8754. }
  8755. socket.close();
  8756. _this._resetState();
  8757. });
  8758. if (queue && queue instanceof ReplaySubject) {
  8759. subscription.add(queue.subscribe(_this.destination));
  8760. }
  8761. };
  8762. socket.onerror = function (e) {
  8763. _this._resetState();
  8764. observer.error(e);
  8765. };
  8766. socket.onclose = function (e) {
  8767. _this._resetState();
  8768. var closeObserver = _this._config.closeObserver;
  8769. if (closeObserver) {
  8770. closeObserver.next(e);
  8771. }
  8772. if (e.wasClean) {
  8773. observer.complete();
  8774. }
  8775. else {
  8776. observer.error(e);
  8777. }
  8778. };
  8779. socket.onmessage = function (e) {
  8780. try {
  8781. var deserializer = _this._config.deserializer;
  8782. observer.next(deserializer(e));
  8783. }
  8784. catch (err) {
  8785. observer.error(err);
  8786. }
  8787. };
  8788. };
  8789. WebSocketSubject.prototype._subscribe = function (subscriber) {
  8790. var _this = this;
  8791. var source = this.source;
  8792. if (source) {
  8793. return source.subscribe(subscriber);
  8794. }
  8795. if (!this._socket) {
  8796. this._connectSocket();
  8797. }
  8798. this._output.subscribe(subscriber);
  8799. subscriber.add(function () {
  8800. var _socket = _this._socket;
  8801. if (_this._output.observers.length === 0) {
  8802. if (_socket && _socket.readyState === 1) {
  8803. _socket.close();
  8804. }
  8805. _this._resetState();
  8806. }
  8807. });
  8808. return subscriber;
  8809. };
  8810. WebSocketSubject.prototype.unsubscribe = function () {
  8811. var _socket = this._socket;
  8812. if (_socket && _socket.readyState === 1) {
  8813. _socket.close();
  8814. }
  8815. this._resetState();
  8816. _super.prototype.unsubscribe.call(this);
  8817. };
  8818. return WebSocketSubject;
  8819. }(AnonymousSubject));
  8820. function webSocket(urlConfigOrSource) {
  8821. return new WebSocketSubject(urlConfigOrSource);
  8822. }
  8823. var _webSocket = /*#__PURE__*/Object.freeze({
  8824. webSocket: webSocket,
  8825. WebSocketSubject: WebSocketSubject
  8826. });
  8827. function fromFetch(input, init) {
  8828. return new Observable(function (subscriber) {
  8829. var controller = new AbortController();
  8830. var signal = controller.signal;
  8831. var outerSignalHandler;
  8832. var abortable = true;
  8833. var unsubscribed = false;
  8834. if (init) {
  8835. if (init.signal) {
  8836. outerSignalHandler = function () {
  8837. if (!signal.aborted) {
  8838. controller.abort();
  8839. }
  8840. };
  8841. init.signal.addEventListener('abort', outerSignalHandler);
  8842. }
  8843. init.signal = signal;
  8844. }
  8845. else {
  8846. init = { signal: signal };
  8847. }
  8848. fetch(input, init).then(function (response) {
  8849. abortable = false;
  8850. subscriber.next(response);
  8851. subscriber.complete();
  8852. }).catch(function (err) {
  8853. abortable = false;
  8854. if (!unsubscribed) {
  8855. subscriber.error(err);
  8856. }
  8857. });
  8858. return function () {
  8859. unsubscribed = true;
  8860. if (abortable) {
  8861. controller.abort();
  8862. }
  8863. };
  8864. });
  8865. }
  8866. var _fetch = /*#__PURE__*/Object.freeze({
  8867. fromFetch: fromFetch
  8868. });
  8869. var operators = _operators;
  8870. var testing = _testing;
  8871. var ajax$1 = _ajax;
  8872. var webSocket$1 = _webSocket;
  8873. var fetch$1 = _fetch;
  8874. exports.operators = operators;
  8875. exports.testing = testing;
  8876. exports.ajax = ajax$1;
  8877. exports.webSocket = webSocket$1;
  8878. exports.fetch = fetch$1;
  8879. exports.Observable = Observable;
  8880. exports.ConnectableObservable = ConnectableObservable;
  8881. exports.GroupedObservable = GroupedObservable;
  8882. exports.observable = observable;
  8883. exports.Subject = Subject;
  8884. exports.BehaviorSubject = BehaviorSubject;
  8885. exports.ReplaySubject = ReplaySubject;
  8886. exports.AsyncSubject = AsyncSubject;
  8887. exports.asapScheduler = asap;
  8888. exports.asyncScheduler = async;
  8889. exports.queueScheduler = queue;
  8890. exports.animationFrameScheduler = animationFrame;
  8891. exports.VirtualTimeScheduler = VirtualTimeScheduler;
  8892. exports.VirtualAction = VirtualAction;
  8893. exports.Scheduler = Scheduler;
  8894. exports.Subscription = Subscription;
  8895. exports.Subscriber = Subscriber;
  8896. exports.Notification = Notification;
  8897. exports.pipe = pipe;
  8898. exports.noop = noop;
  8899. exports.identity = identity;
  8900. exports.isObservable = isObservable;
  8901. exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
  8902. exports.EmptyError = EmptyError;
  8903. exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
  8904. exports.UnsubscriptionError = UnsubscriptionError;
  8905. exports.TimeoutError = TimeoutError;
  8906. exports.bindCallback = bindCallback;
  8907. exports.bindNodeCallback = bindNodeCallback;
  8908. exports.combineLatest = combineLatest;
  8909. exports.concat = concat;
  8910. exports.defer = defer;
  8911. exports.empty = empty$1;
  8912. exports.forkJoin = forkJoin;
  8913. exports.from = from;
  8914. exports.fromEvent = fromEvent;
  8915. exports.fromEventPattern = fromEventPattern;
  8916. exports.generate = generate;
  8917. exports.iif = iif;
  8918. exports.interval = interval;
  8919. exports.merge = merge;
  8920. exports.never = never;
  8921. exports.of = of;
  8922. exports.onErrorResumeNext = onErrorResumeNext;
  8923. exports.pairs = pairs;
  8924. exports.partition = partition;
  8925. exports.race = race;
  8926. exports.range = range;
  8927. exports.throwError = throwError;
  8928. exports.timer = timer;
  8929. exports.using = using;
  8930. exports.zip = zip;
  8931. exports.scheduled = scheduled;
  8932. exports.EMPTY = EMPTY;
  8933. exports.NEVER = NEVER;
  8934. exports.config = config;
  8935. Object.defineProperty(exports, '__esModule', { value: true });
  8936. })));
  8937. //# sourceMappingURL=rxjs.umd.js.map