rails-angularjs2 2.0.0.pre.alpha.32 → 2.0.0.pre.beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/rails-angularjs2/version.rb +1 -1
  4. data/vendor/assets/javascripts/Rx.js +11615 -0
  5. data/vendor/assets/javascripts/Rx.min.js +417 -0
  6. data/vendor/assets/javascripts/Rx.min.js.map +1 -0
  7. data/vendor/assets/javascripts/Rx.umd.js +10274 -0
  8. data/vendor/assets/javascripts/Rx.umd.min.js +748 -0
  9. data/vendor/assets/javascripts/Rx.umd.min.js.map +8 -0
  10. data/vendor/assets/javascripts/angular2-all-testing.umd.dev.js +39335 -0
  11. data/vendor/assets/javascripts/angular2-all.umd.dev.js +37160 -0
  12. data/vendor/assets/javascripts/angular2-all.umd.js +37159 -0
  13. data/vendor/assets/javascripts/angular2-all.umd.min.js +19 -0
  14. data/vendor/assets/javascripts/angular2-polyfills.js +3324 -0
  15. data/vendor/assets/javascripts/angular2-polyfills.min.js +1 -0
  16. data/vendor/assets/javascripts/angular2.dev.js +23937 -29580
  17. data/vendor/assets/javascripts/angular2.js +24021 -29105
  18. data/vendor/assets/javascripts/angular2.min.js +18 -24
  19. data/vendor/assets/javascripts/http.dev.js +1091 -0
  20. data/vendor/assets/javascripts/http.js +1091 -0
  21. data/vendor/assets/javascripts/http.min.js +1 -0
  22. data/vendor/assets/javascripts/router.dev.js +2946 -1894
  23. data/vendor/assets/javascripts/router.js +3107 -0
  24. data/vendor/assets/javascripts/router.min.js +3 -0
  25. data/vendor/assets/javascripts/testing.dev.js +2105 -0
  26. data/vendor/assets/javascripts/testing.dev.js.map +1 -0
  27. data/vendor/assets/javascripts/upgrade.dev.js +777 -0
  28. data/vendor/assets/javascripts/upgrade.js +777 -0
  29. data/vendor/assets/javascripts/upgrade.min.js +1 -0
  30. metadata +25 -9
  31. data/vendor/assets/javascripts/angular2.sfx.dev.js +0 -36368
  32. data/vendor/assets/javascripts/mock.dev.js +0 -337
  33. data/vendor/assets/javascripts/mock.dev.js.map +0 -1
  34. data/vendor/assets/javascripts/router.dev.js.map +0 -1
  35. data/vendor/assets/javascripts/test_lib.dev.js +0 -1510
  36. data/vendor/assets/javascripts/test_lib.dev.js.map +0 -1
@@ -0,0 +1,3107 @@
1
+ "format register";
2
+ System.register("angular2/src/router/router_link_transform", ["angular2/compiler", "angular2/src/core/change_detection/parser/ast", "angular2/src/facade/exceptions", "angular2/core", "angular2/src/core/change_detection/parser/parser"], true, function(require, exports, module) {
3
+ var global = System.global,
4
+ __define = global.define;
5
+ global.define = undefined;
6
+ var __extends = (this && this.__extends) || function(d, b) {
7
+ for (var p in b)
8
+ if (b.hasOwnProperty(p))
9
+ d[p] = b[p];
10
+ function __() {
11
+ this.constructor = d;
12
+ }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
16
+ var c = arguments.length,
17
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
18
+ d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
20
+ r = Reflect.decorate(decorators, target, key, desc);
21
+ else
22
+ for (var i = decorators.length - 1; i >= 0; i--)
23
+ if (d = decorators[i])
24
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
25
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
26
+ };
27
+ var __metadata = (this && this.__metadata) || function(k, v) {
28
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
29
+ return Reflect.metadata(k, v);
30
+ };
31
+ var compiler_1 = require("angular2/compiler");
32
+ var ast_1 = require("angular2/src/core/change_detection/parser/ast");
33
+ var exceptions_1 = require("angular2/src/facade/exceptions");
34
+ var core_1 = require("angular2/core");
35
+ var parser_1 = require("angular2/src/core/change_detection/parser/parser");
36
+ var FixedPart = (function() {
37
+ function FixedPart(value) {
38
+ this.value = value;
39
+ }
40
+ return FixedPart;
41
+ })();
42
+ var AuxiliaryStart = (function() {
43
+ function AuxiliaryStart() {}
44
+ return AuxiliaryStart;
45
+ })();
46
+ var AuxiliaryEnd = (function() {
47
+ function AuxiliaryEnd() {}
48
+ return AuxiliaryEnd;
49
+ })();
50
+ var Params = (function() {
51
+ function Params(ast) {
52
+ this.ast = ast;
53
+ }
54
+ return Params;
55
+ })();
56
+ var RouterLinkLexer = (function() {
57
+ function RouterLinkLexer(parser, exp) {
58
+ this.parser = parser;
59
+ this.exp = exp;
60
+ this.index = 0;
61
+ }
62
+ RouterLinkLexer.prototype.tokenize = function() {
63
+ var tokens = [];
64
+ while (this.index < this.exp.length) {
65
+ tokens.push(this._parseToken());
66
+ }
67
+ return tokens;
68
+ };
69
+ RouterLinkLexer.prototype._parseToken = function() {
70
+ var c = this.exp[this.index];
71
+ if (c == '[') {
72
+ this.index++;
73
+ return new AuxiliaryStart();
74
+ } else if (c == ']') {
75
+ this.index++;
76
+ return new AuxiliaryEnd();
77
+ } else if (c == '(') {
78
+ return this._parseParams();
79
+ } else if (c == '/' && this.index !== 0) {
80
+ this.index++;
81
+ return this._parseFixedPart();
82
+ } else {
83
+ return this._parseFixedPart();
84
+ }
85
+ };
86
+ RouterLinkLexer.prototype._parseParams = function() {
87
+ var start = this.index;
88
+ for (; this.index < this.exp.length; ++this.index) {
89
+ var c = this.exp[this.index];
90
+ if (c == ')') {
91
+ var paramsContent = this.exp.substring(start + 1, this.index);
92
+ this.index++;
93
+ return new Params(this.parser.parseBinding("{" + paramsContent + "}", null).ast);
94
+ }
95
+ }
96
+ throw new exceptions_1.BaseException("Cannot find ')'");
97
+ };
98
+ RouterLinkLexer.prototype._parseFixedPart = function() {
99
+ var start = this.index;
100
+ var sawNonSlash = false;
101
+ for (; this.index < this.exp.length; ++this.index) {
102
+ var c = this.exp[this.index];
103
+ if (c == '(' || c == '[' || c == ']' || (c == '/' && sawNonSlash)) {
104
+ break;
105
+ }
106
+ if (c != '.' && c != '/') {
107
+ sawNonSlash = true;
108
+ }
109
+ }
110
+ var fixed = this.exp.substring(start, this.index);
111
+ if (start === this.index || !sawNonSlash || fixed.startsWith('//')) {
112
+ throw new exceptions_1.BaseException("Invalid router link");
113
+ }
114
+ return new FixedPart(fixed);
115
+ };
116
+ return RouterLinkLexer;
117
+ })();
118
+ var RouterLinkAstGenerator = (function() {
119
+ function RouterLinkAstGenerator(tokens) {
120
+ this.tokens = tokens;
121
+ this.index = 0;
122
+ }
123
+ RouterLinkAstGenerator.prototype.generate = function() {
124
+ return this._genAuxiliary();
125
+ };
126
+ RouterLinkAstGenerator.prototype._genAuxiliary = function() {
127
+ var arr = [];
128
+ for (; this.index < this.tokens.length; this.index++) {
129
+ var r = this.tokens[this.index];
130
+ if (r instanceof FixedPart) {
131
+ arr.push(new ast_1.LiteralPrimitive(r.value));
132
+ } else if (r instanceof Params) {
133
+ arr.push(r.ast);
134
+ } else if (r instanceof AuxiliaryEnd) {
135
+ break;
136
+ } else if (r instanceof AuxiliaryStart) {
137
+ this.index++;
138
+ arr.push(this._genAuxiliary());
139
+ }
140
+ }
141
+ return new ast_1.LiteralArray(arr);
142
+ };
143
+ return RouterLinkAstGenerator;
144
+ })();
145
+ var RouterLinkAstTransformer = (function(_super) {
146
+ __extends(RouterLinkAstTransformer, _super);
147
+ function RouterLinkAstTransformer(parser) {
148
+ _super.call(this);
149
+ this.parser = parser;
150
+ }
151
+ RouterLinkAstTransformer.prototype.visitQuote = function(ast) {
152
+ if (ast.prefix == "route") {
153
+ return parseRouterLinkExpression(this.parser, ast.uninterpretedExpression);
154
+ } else {
155
+ return _super.prototype.visitQuote.call(this, ast);
156
+ }
157
+ };
158
+ return RouterLinkAstTransformer;
159
+ })(ast_1.AstTransformer);
160
+ function parseRouterLinkExpression(parser, exp) {
161
+ var tokens = new RouterLinkLexer(parser, exp.trim()).tokenize();
162
+ return new RouterLinkAstGenerator(tokens).generate();
163
+ }
164
+ exports.parseRouterLinkExpression = parseRouterLinkExpression;
165
+ var RouterLinkTransform = (function() {
166
+ function RouterLinkTransform(parser) {
167
+ this.astTransformer = new RouterLinkAstTransformer(parser);
168
+ }
169
+ RouterLinkTransform.prototype.visitNgContent = function(ast, context) {
170
+ return ast;
171
+ };
172
+ RouterLinkTransform.prototype.visitEmbeddedTemplate = function(ast, context) {
173
+ return ast;
174
+ };
175
+ RouterLinkTransform.prototype.visitElement = function(ast, context) {
176
+ var _this = this;
177
+ var updatedChildren = ast.children.map(function(c) {
178
+ return c.visit(_this, context);
179
+ });
180
+ var updatedInputs = ast.inputs.map(function(c) {
181
+ return c.visit(_this, context);
182
+ });
183
+ var updatedDirectives = ast.directives.map(function(c) {
184
+ return c.visit(_this, context);
185
+ });
186
+ return new compiler_1.ElementAst(ast.name, ast.attrs, updatedInputs, ast.outputs, ast.exportAsVars, updatedDirectives, updatedChildren, ast.ngContentIndex, ast.sourceSpan);
187
+ };
188
+ RouterLinkTransform.prototype.visitVariable = function(ast, context) {
189
+ return ast;
190
+ };
191
+ RouterLinkTransform.prototype.visitEvent = function(ast, context) {
192
+ return ast;
193
+ };
194
+ RouterLinkTransform.prototype.visitElementProperty = function(ast, context) {
195
+ return ast;
196
+ };
197
+ RouterLinkTransform.prototype.visitAttr = function(ast, context) {
198
+ return ast;
199
+ };
200
+ RouterLinkTransform.prototype.visitBoundText = function(ast, context) {
201
+ return ast;
202
+ };
203
+ RouterLinkTransform.prototype.visitText = function(ast, context) {
204
+ return ast;
205
+ };
206
+ RouterLinkTransform.prototype.visitDirective = function(ast, context) {
207
+ var _this = this;
208
+ var updatedInputs = ast.inputs.map(function(c) {
209
+ return c.visit(_this, context);
210
+ });
211
+ return new compiler_1.DirectiveAst(ast.directive, updatedInputs, ast.hostProperties, ast.hostEvents, ast.exportAsVars, ast.sourceSpan);
212
+ };
213
+ RouterLinkTransform.prototype.visitDirectiveProperty = function(ast, context) {
214
+ var transformedValue = ast.value.visit(this.astTransformer);
215
+ return new compiler_1.BoundDirectivePropertyAst(ast.directiveName, ast.templateName, transformedValue, ast.sourceSpan);
216
+ };
217
+ RouterLinkTransform = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [parser_1.Parser])], RouterLinkTransform);
218
+ return RouterLinkTransform;
219
+ })();
220
+ exports.RouterLinkTransform = RouterLinkTransform;
221
+ global.define = __define;
222
+ return module.exports;
223
+ });
224
+
225
+ System.register("angular2/router/router_link_dsl", ["angular2/compiler", "angular2/core", "angular2/src/router/router_link_transform", "angular2/src/facade/lang", "angular2/src/router/router_link_transform"], true, function(require, exports, module) {
226
+ var global = System.global,
227
+ __define = global.define;
228
+ global.define = undefined;
229
+ var compiler_1 = require("angular2/compiler");
230
+ var core_1 = require("angular2/core");
231
+ var router_link_transform_1 = require("angular2/src/router/router_link_transform");
232
+ var lang_1 = require("angular2/src/facade/lang");
233
+ var router_link_transform_2 = require("angular2/src/router/router_link_transform");
234
+ exports.RouterLinkTransform = router_link_transform_2.RouterLinkTransform;
235
+ exports.ROUTER_LINK_DSL_PROVIDER = lang_1.CONST_EXPR(new core_1.Provider(compiler_1.TEMPLATE_TRANSFORMS, {
236
+ useClass: router_link_transform_1.RouterLinkTransform,
237
+ multi: true
238
+ }));
239
+ global.define = __define;
240
+ return module.exports;
241
+ });
242
+
243
+ System.register("angular2/src/router/route_config_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
244
+ var global = System.global,
245
+ __define = global.define;
246
+ global.define = undefined;
247
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
248
+ var c = arguments.length,
249
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
250
+ d;
251
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
252
+ r = Reflect.decorate(decorators, target, key, desc);
253
+ else
254
+ for (var i = decorators.length - 1; i >= 0; i--)
255
+ if (d = decorators[i])
256
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
257
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
258
+ };
259
+ var __metadata = (this && this.__metadata) || function(k, v) {
260
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
261
+ return Reflect.metadata(k, v);
262
+ };
263
+ var lang_1 = require("angular2/src/facade/lang");
264
+ var RouteConfig = (function() {
265
+ function RouteConfig(configs) {
266
+ this.configs = configs;
267
+ }
268
+ RouteConfig = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Array])], RouteConfig);
269
+ return RouteConfig;
270
+ })();
271
+ exports.RouteConfig = RouteConfig;
272
+ var Route = (function() {
273
+ function Route(_a) {
274
+ var path = _a.path,
275
+ component = _a.component,
276
+ name = _a.name,
277
+ data = _a.data,
278
+ useAsDefault = _a.useAsDefault;
279
+ this.aux = null;
280
+ this.loader = null;
281
+ this.redirectTo = null;
282
+ this.path = path;
283
+ this.component = component;
284
+ this.name = name;
285
+ this.data = data;
286
+ this.useAsDefault = useAsDefault;
287
+ }
288
+ Route = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Route);
289
+ return Route;
290
+ })();
291
+ exports.Route = Route;
292
+ var AuxRoute = (function() {
293
+ function AuxRoute(_a) {
294
+ var path = _a.path,
295
+ component = _a.component,
296
+ name = _a.name;
297
+ this.data = null;
298
+ this.aux = null;
299
+ this.loader = null;
300
+ this.redirectTo = null;
301
+ this.useAsDefault = false;
302
+ this.path = path;
303
+ this.component = component;
304
+ this.name = name;
305
+ }
306
+ AuxRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AuxRoute);
307
+ return AuxRoute;
308
+ })();
309
+ exports.AuxRoute = AuxRoute;
310
+ var AsyncRoute = (function() {
311
+ function AsyncRoute(_a) {
312
+ var path = _a.path,
313
+ loader = _a.loader,
314
+ name = _a.name,
315
+ data = _a.data,
316
+ useAsDefault = _a.useAsDefault;
317
+ this.aux = null;
318
+ this.path = path;
319
+ this.loader = loader;
320
+ this.name = name;
321
+ this.data = data;
322
+ this.useAsDefault = useAsDefault;
323
+ }
324
+ AsyncRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AsyncRoute);
325
+ return AsyncRoute;
326
+ })();
327
+ exports.AsyncRoute = AsyncRoute;
328
+ var Redirect = (function() {
329
+ function Redirect(_a) {
330
+ var path = _a.path,
331
+ redirectTo = _a.redirectTo;
332
+ this.name = null;
333
+ this.loader = null;
334
+ this.data = null;
335
+ this.aux = null;
336
+ this.useAsDefault = false;
337
+ this.path = path;
338
+ this.redirectTo = redirectTo;
339
+ }
340
+ Redirect = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Redirect);
341
+ return Redirect;
342
+ })();
343
+ exports.Redirect = Redirect;
344
+ global.define = __define;
345
+ return module.exports;
346
+ });
347
+
348
+ System.register("angular2/src/router/instruction", ["angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/async"], true, function(require, exports, module) {
349
+ var global = System.global,
350
+ __define = global.define;
351
+ global.define = undefined;
352
+ var __extends = (this && this.__extends) || function(d, b) {
353
+ for (var p in b)
354
+ if (b.hasOwnProperty(p))
355
+ d[p] = b[p];
356
+ function __() {
357
+ this.constructor = d;
358
+ }
359
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
360
+ };
361
+ var collection_1 = require("angular2/src/facade/collection");
362
+ var lang_1 = require("angular2/src/facade/lang");
363
+ var async_1 = require("angular2/src/facade/async");
364
+ var RouteParams = (function() {
365
+ function RouteParams(params) {
366
+ this.params = params;
367
+ }
368
+ RouteParams.prototype.get = function(param) {
369
+ return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.params, param));
370
+ };
371
+ return RouteParams;
372
+ })();
373
+ exports.RouteParams = RouteParams;
374
+ var RouteData = (function() {
375
+ function RouteData(data) {
376
+ if (data === void 0) {
377
+ data = lang_1.CONST_EXPR({});
378
+ }
379
+ this.data = data;
380
+ }
381
+ RouteData.prototype.get = function(key) {
382
+ return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.data, key));
383
+ };
384
+ return RouteData;
385
+ })();
386
+ exports.RouteData = RouteData;
387
+ exports.BLANK_ROUTE_DATA = new RouteData();
388
+ var Instruction = (function() {
389
+ function Instruction(component, child, auxInstruction) {
390
+ this.component = component;
391
+ this.child = child;
392
+ this.auxInstruction = auxInstruction;
393
+ }
394
+ Object.defineProperty(Instruction.prototype, "urlPath", {
395
+ get: function() {
396
+ return lang_1.isPresent(this.component) ? this.component.urlPath : '';
397
+ },
398
+ enumerable: true,
399
+ configurable: true
400
+ });
401
+ Object.defineProperty(Instruction.prototype, "urlParams", {
402
+ get: function() {
403
+ return lang_1.isPresent(this.component) ? this.component.urlParams : [];
404
+ },
405
+ enumerable: true,
406
+ configurable: true
407
+ });
408
+ Object.defineProperty(Instruction.prototype, "specificity", {
409
+ get: function() {
410
+ var total = '';
411
+ if (lang_1.isPresent(this.component)) {
412
+ total += this.component.specificity;
413
+ }
414
+ if (lang_1.isPresent(this.child)) {
415
+ total += this.child.specificity;
416
+ }
417
+ return total;
418
+ },
419
+ enumerable: true,
420
+ configurable: true
421
+ });
422
+ Instruction.prototype.toRootUrl = function() {
423
+ return this.toUrlPath() + this.toUrlQuery();
424
+ };
425
+ Instruction.prototype._toNonRootUrl = function() {
426
+ return this._stringifyPathMatrixAuxPrefixed() + (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
427
+ };
428
+ Instruction.prototype.toUrlQuery = function() {
429
+ return this.urlParams.length > 0 ? ('?' + this.urlParams.join('&')) : '';
430
+ };
431
+ Instruction.prototype.replaceChild = function(child) {
432
+ return new ResolvedInstruction(this.component, child, this.auxInstruction);
433
+ };
434
+ Instruction.prototype.toUrlPath = function() {
435
+ return this.urlPath + this._stringifyAux() + (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
436
+ };
437
+ Instruction.prototype.toLinkUrl = function() {
438
+ return this.urlPath + this._stringifyAux() + (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
439
+ };
440
+ Instruction.prototype._toLinkUrl = function() {
441
+ return this._stringifyPathMatrixAuxPrefixed() + (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
442
+ };
443
+ Instruction.prototype._stringifyPathMatrixAuxPrefixed = function() {
444
+ var primary = this._stringifyPathMatrixAux();
445
+ if (primary.length > 0) {
446
+ primary = '/' + primary;
447
+ }
448
+ return primary;
449
+ };
450
+ Instruction.prototype._stringifyMatrixParams = function() {
451
+ return this.urlParams.length > 0 ? (';' + this.urlParams.join(';')) : '';
452
+ };
453
+ Instruction.prototype._stringifyPathMatrixAux = function() {
454
+ if (lang_1.isBlank(this.component)) {
455
+ return '';
456
+ }
457
+ return this.urlPath + this._stringifyMatrixParams() + this._stringifyAux();
458
+ };
459
+ Instruction.prototype._stringifyAux = function() {
460
+ var routes = [];
461
+ collection_1.StringMapWrapper.forEach(this.auxInstruction, function(auxInstruction, _) {
462
+ routes.push(auxInstruction._stringifyPathMatrixAux());
463
+ });
464
+ if (routes.length > 0) {
465
+ return '(' + routes.join('//') + ')';
466
+ }
467
+ return '';
468
+ };
469
+ return Instruction;
470
+ })();
471
+ exports.Instruction = Instruction;
472
+ var ResolvedInstruction = (function(_super) {
473
+ __extends(ResolvedInstruction, _super);
474
+ function ResolvedInstruction(component, child, auxInstruction) {
475
+ _super.call(this, component, child, auxInstruction);
476
+ }
477
+ ResolvedInstruction.prototype.resolveComponent = function() {
478
+ return async_1.PromiseWrapper.resolve(this.component);
479
+ };
480
+ return ResolvedInstruction;
481
+ })(Instruction);
482
+ exports.ResolvedInstruction = ResolvedInstruction;
483
+ var DefaultInstruction = (function(_super) {
484
+ __extends(DefaultInstruction, _super);
485
+ function DefaultInstruction(component, child) {
486
+ _super.call(this, component, child, {});
487
+ }
488
+ DefaultInstruction.prototype.resolveComponent = function() {
489
+ return async_1.PromiseWrapper.resolve(this.component);
490
+ };
491
+ DefaultInstruction.prototype.toLinkUrl = function() {
492
+ return '';
493
+ };
494
+ DefaultInstruction.prototype._toLinkUrl = function() {
495
+ return '';
496
+ };
497
+ return DefaultInstruction;
498
+ })(Instruction);
499
+ exports.DefaultInstruction = DefaultInstruction;
500
+ var UnresolvedInstruction = (function(_super) {
501
+ __extends(UnresolvedInstruction, _super);
502
+ function UnresolvedInstruction(_resolver, _urlPath, _urlParams) {
503
+ if (_urlPath === void 0) {
504
+ _urlPath = '';
505
+ }
506
+ if (_urlParams === void 0) {
507
+ _urlParams = lang_1.CONST_EXPR([]);
508
+ }
509
+ _super.call(this, null, null, {});
510
+ this._resolver = _resolver;
511
+ this._urlPath = _urlPath;
512
+ this._urlParams = _urlParams;
513
+ }
514
+ Object.defineProperty(UnresolvedInstruction.prototype, "urlPath", {
515
+ get: function() {
516
+ if (lang_1.isPresent(this.component)) {
517
+ return this.component.urlPath;
518
+ }
519
+ if (lang_1.isPresent(this._urlPath)) {
520
+ return this._urlPath;
521
+ }
522
+ return '';
523
+ },
524
+ enumerable: true,
525
+ configurable: true
526
+ });
527
+ Object.defineProperty(UnresolvedInstruction.prototype, "urlParams", {
528
+ get: function() {
529
+ if (lang_1.isPresent(this.component)) {
530
+ return this.component.urlParams;
531
+ }
532
+ if (lang_1.isPresent(this._urlParams)) {
533
+ return this._urlParams;
534
+ }
535
+ return [];
536
+ },
537
+ enumerable: true,
538
+ configurable: true
539
+ });
540
+ UnresolvedInstruction.prototype.resolveComponent = function() {
541
+ var _this = this;
542
+ if (lang_1.isPresent(this.component)) {
543
+ return async_1.PromiseWrapper.resolve(this.component);
544
+ }
545
+ return this._resolver().then(function(resolution) {
546
+ _this.child = resolution.child;
547
+ return _this.component = resolution.component;
548
+ });
549
+ };
550
+ return UnresolvedInstruction;
551
+ })(Instruction);
552
+ exports.UnresolvedInstruction = UnresolvedInstruction;
553
+ var RedirectInstruction = (function(_super) {
554
+ __extends(RedirectInstruction, _super);
555
+ function RedirectInstruction(component, child, auxInstruction, _specificity) {
556
+ _super.call(this, component, child, auxInstruction);
557
+ this._specificity = _specificity;
558
+ }
559
+ Object.defineProperty(RedirectInstruction.prototype, "specificity", {
560
+ get: function() {
561
+ return this._specificity;
562
+ },
563
+ enumerable: true,
564
+ configurable: true
565
+ });
566
+ return RedirectInstruction;
567
+ })(ResolvedInstruction);
568
+ exports.RedirectInstruction = RedirectInstruction;
569
+ var ComponentInstruction = (function() {
570
+ function ComponentInstruction(urlPath, urlParams, data, componentType, terminal, specificity, params) {
571
+ if (params === void 0) {
572
+ params = null;
573
+ }
574
+ this.urlPath = urlPath;
575
+ this.urlParams = urlParams;
576
+ this.componentType = componentType;
577
+ this.terminal = terminal;
578
+ this.specificity = specificity;
579
+ this.params = params;
580
+ this.reuse = false;
581
+ this.routeData = lang_1.isPresent(data) ? data : exports.BLANK_ROUTE_DATA;
582
+ }
583
+ return ComponentInstruction;
584
+ })();
585
+ exports.ComponentInstruction = ComponentInstruction;
586
+ global.define = __define;
587
+ return module.exports;
588
+ });
589
+
590
+ System.register("angular2/src/router/url_parser", ["angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/exceptions"], true, function(require, exports, module) {
591
+ var global = System.global,
592
+ __define = global.define;
593
+ global.define = undefined;
594
+ var __extends = (this && this.__extends) || function(d, b) {
595
+ for (var p in b)
596
+ if (b.hasOwnProperty(p))
597
+ d[p] = b[p];
598
+ function __() {
599
+ this.constructor = d;
600
+ }
601
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
602
+ };
603
+ var collection_1 = require("angular2/src/facade/collection");
604
+ var lang_1 = require("angular2/src/facade/lang");
605
+ var exceptions_1 = require("angular2/src/facade/exceptions");
606
+ var Url = (function() {
607
+ function Url(path, child, auxiliary, params) {
608
+ if (child === void 0) {
609
+ child = null;
610
+ }
611
+ if (auxiliary === void 0) {
612
+ auxiliary = lang_1.CONST_EXPR([]);
613
+ }
614
+ if (params === void 0) {
615
+ params = null;
616
+ }
617
+ this.path = path;
618
+ this.child = child;
619
+ this.auxiliary = auxiliary;
620
+ this.params = params;
621
+ }
622
+ Url.prototype.toString = function() {
623
+ return this.path + this._matrixParamsToString() + this._auxToString() + this._childString();
624
+ };
625
+ Url.prototype.segmentToString = function() {
626
+ return this.path + this._matrixParamsToString();
627
+ };
628
+ Url.prototype._auxToString = function() {
629
+ return this.auxiliary.length > 0 ? ('(' + this.auxiliary.map(function(sibling) {
630
+ return sibling.toString();
631
+ }).join('//') + ')') : '';
632
+ };
633
+ Url.prototype._matrixParamsToString = function() {
634
+ if (lang_1.isBlank(this.params)) {
635
+ return '';
636
+ }
637
+ return ';' + serializeParams(this.params).join(';');
638
+ };
639
+ Url.prototype._childString = function() {
640
+ return lang_1.isPresent(this.child) ? ('/' + this.child.toString()) : '';
641
+ };
642
+ return Url;
643
+ })();
644
+ exports.Url = Url;
645
+ var RootUrl = (function(_super) {
646
+ __extends(RootUrl, _super);
647
+ function RootUrl(path, child, auxiliary, params) {
648
+ if (child === void 0) {
649
+ child = null;
650
+ }
651
+ if (auxiliary === void 0) {
652
+ auxiliary = lang_1.CONST_EXPR([]);
653
+ }
654
+ if (params === void 0) {
655
+ params = null;
656
+ }
657
+ _super.call(this, path, child, auxiliary, params);
658
+ }
659
+ RootUrl.prototype.toString = function() {
660
+ return this.path + this._auxToString() + this._childString() + this._queryParamsToString();
661
+ };
662
+ RootUrl.prototype.segmentToString = function() {
663
+ return this.path + this._queryParamsToString();
664
+ };
665
+ RootUrl.prototype._queryParamsToString = function() {
666
+ if (lang_1.isBlank(this.params)) {
667
+ return '';
668
+ }
669
+ return '?' + serializeParams(this.params).join('&');
670
+ };
671
+ return RootUrl;
672
+ })(Url);
673
+ exports.RootUrl = RootUrl;
674
+ function pathSegmentsToUrl(pathSegments) {
675
+ var url = new Url(pathSegments[pathSegments.length - 1]);
676
+ for (var i = pathSegments.length - 2; i >= 0; i -= 1) {
677
+ url = new Url(pathSegments[i], url);
678
+ }
679
+ return url;
680
+ }
681
+ exports.pathSegmentsToUrl = pathSegmentsToUrl;
682
+ var SEGMENT_RE = lang_1.RegExpWrapper.create('^[^\\/\\(\\)\\?;=&#]+');
683
+ function matchUrlSegment(str) {
684
+ var match = lang_1.RegExpWrapper.firstMatch(SEGMENT_RE, str);
685
+ return lang_1.isPresent(match) ? match[0] : '';
686
+ }
687
+ var UrlParser = (function() {
688
+ function UrlParser() {}
689
+ UrlParser.prototype.peekStartsWith = function(str) {
690
+ return this._remaining.startsWith(str);
691
+ };
692
+ UrlParser.prototype.capture = function(str) {
693
+ if (!this._remaining.startsWith(str)) {
694
+ throw new exceptions_1.BaseException("Expected \"" + str + "\".");
695
+ }
696
+ this._remaining = this._remaining.substring(str.length);
697
+ };
698
+ UrlParser.prototype.parse = function(url) {
699
+ this._remaining = url;
700
+ if (url == '' || url == '/') {
701
+ return new Url('');
702
+ }
703
+ return this.parseRoot();
704
+ };
705
+ UrlParser.prototype.parseRoot = function() {
706
+ if (this.peekStartsWith('/')) {
707
+ this.capture('/');
708
+ }
709
+ var path = matchUrlSegment(this._remaining);
710
+ this.capture(path);
711
+ var aux = [];
712
+ if (this.peekStartsWith('(')) {
713
+ aux = this.parseAuxiliaryRoutes();
714
+ }
715
+ if (this.peekStartsWith(';')) {
716
+ this.parseMatrixParams();
717
+ }
718
+ var child = null;
719
+ if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
720
+ this.capture('/');
721
+ child = this.parseSegment();
722
+ }
723
+ var queryParams = null;
724
+ if (this.peekStartsWith('?')) {
725
+ queryParams = this.parseQueryParams();
726
+ }
727
+ return new RootUrl(path, child, aux, queryParams);
728
+ };
729
+ UrlParser.prototype.parseSegment = function() {
730
+ if (this._remaining.length == 0) {
731
+ return null;
732
+ }
733
+ if (this.peekStartsWith('/')) {
734
+ this.capture('/');
735
+ }
736
+ var path = matchUrlSegment(this._remaining);
737
+ this.capture(path);
738
+ var matrixParams = null;
739
+ if (this.peekStartsWith(';')) {
740
+ matrixParams = this.parseMatrixParams();
741
+ }
742
+ var aux = [];
743
+ if (this.peekStartsWith('(')) {
744
+ aux = this.parseAuxiliaryRoutes();
745
+ }
746
+ var child = null;
747
+ if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
748
+ this.capture('/');
749
+ child = this.parseSegment();
750
+ }
751
+ return new Url(path, child, aux, matrixParams);
752
+ };
753
+ UrlParser.prototype.parseQueryParams = function() {
754
+ var params = {};
755
+ this.capture('?');
756
+ this.parseParam(params);
757
+ while (this._remaining.length > 0 && this.peekStartsWith('&')) {
758
+ this.capture('&');
759
+ this.parseParam(params);
760
+ }
761
+ return params;
762
+ };
763
+ UrlParser.prototype.parseMatrixParams = function() {
764
+ var params = {};
765
+ while (this._remaining.length > 0 && this.peekStartsWith(';')) {
766
+ this.capture(';');
767
+ this.parseParam(params);
768
+ }
769
+ return params;
770
+ };
771
+ UrlParser.prototype.parseParam = function(params) {
772
+ var key = matchUrlSegment(this._remaining);
773
+ if (lang_1.isBlank(key)) {
774
+ return ;
775
+ }
776
+ this.capture(key);
777
+ var value = true;
778
+ if (this.peekStartsWith('=')) {
779
+ this.capture('=');
780
+ var valueMatch = matchUrlSegment(this._remaining);
781
+ if (lang_1.isPresent(valueMatch)) {
782
+ value = valueMatch;
783
+ this.capture(value);
784
+ }
785
+ }
786
+ params[key] = value;
787
+ };
788
+ UrlParser.prototype.parseAuxiliaryRoutes = function() {
789
+ var routes = [];
790
+ this.capture('(');
791
+ while (!this.peekStartsWith(')') && this._remaining.length > 0) {
792
+ routes.push(this.parseSegment());
793
+ if (this.peekStartsWith('//')) {
794
+ this.capture('//');
795
+ }
796
+ }
797
+ this.capture(')');
798
+ return routes;
799
+ };
800
+ return UrlParser;
801
+ })();
802
+ exports.UrlParser = UrlParser;
803
+ exports.parser = new UrlParser();
804
+ function serializeParams(paramMap) {
805
+ var params = [];
806
+ if (lang_1.isPresent(paramMap)) {
807
+ collection_1.StringMapWrapper.forEach(paramMap, function(value, key) {
808
+ if (value === true) {
809
+ params.push(key);
810
+ } else {
811
+ params.push(key + '=' + value);
812
+ }
813
+ });
814
+ }
815
+ return params;
816
+ }
817
+ exports.serializeParams = serializeParams;
818
+ global.define = __define;
819
+ return module.exports;
820
+ });
821
+
822
+ System.register("angular2/src/router/async_route_handler", ["angular2/src/facade/lang", "angular2/src/router/instruction"], true, function(require, exports, module) {
823
+ var global = System.global,
824
+ __define = global.define;
825
+ global.define = undefined;
826
+ var lang_1 = require("angular2/src/facade/lang");
827
+ var instruction_1 = require("angular2/src/router/instruction");
828
+ var AsyncRouteHandler = (function() {
829
+ function AsyncRouteHandler(_loader, data) {
830
+ if (data === void 0) {
831
+ data = null;
832
+ }
833
+ this._loader = _loader;
834
+ this._resolvedComponent = null;
835
+ this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
836
+ }
837
+ AsyncRouteHandler.prototype.resolveComponentType = function() {
838
+ var _this = this;
839
+ if (lang_1.isPresent(this._resolvedComponent)) {
840
+ return this._resolvedComponent;
841
+ }
842
+ return this._resolvedComponent = this._loader().then(function(componentType) {
843
+ _this.componentType = componentType;
844
+ return componentType;
845
+ });
846
+ };
847
+ return AsyncRouteHandler;
848
+ })();
849
+ exports.AsyncRouteHandler = AsyncRouteHandler;
850
+ global.define = __define;
851
+ return module.exports;
852
+ });
853
+
854
+ System.register("angular2/src/router/sync_route_handler", ["angular2/src/facade/async", "angular2/src/facade/lang", "angular2/src/router/instruction"], true, function(require, exports, module) {
855
+ var global = System.global,
856
+ __define = global.define;
857
+ global.define = undefined;
858
+ var async_1 = require("angular2/src/facade/async");
859
+ var lang_1 = require("angular2/src/facade/lang");
860
+ var instruction_1 = require("angular2/src/router/instruction");
861
+ var SyncRouteHandler = (function() {
862
+ function SyncRouteHandler(componentType, data) {
863
+ this.componentType = componentType;
864
+ this._resolvedComponent = null;
865
+ this._resolvedComponent = async_1.PromiseWrapper.resolve(componentType);
866
+ this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
867
+ }
868
+ SyncRouteHandler.prototype.resolveComponentType = function() {
869
+ return this._resolvedComponent;
870
+ };
871
+ return SyncRouteHandler;
872
+ })();
873
+ exports.SyncRouteHandler = SyncRouteHandler;
874
+ global.define = __define;
875
+ return module.exports;
876
+ });
877
+
878
+ System.register("angular2/src/router/route_config_decorator", ["angular2/src/router/route_config_impl", "angular2/src/core/util/decorators", "angular2/src/router/route_config_impl"], true, function(require, exports, module) {
879
+ var global = System.global,
880
+ __define = global.define;
881
+ global.define = undefined;
882
+ var route_config_impl_1 = require("angular2/src/router/route_config_impl");
883
+ var decorators_1 = require("angular2/src/core/util/decorators");
884
+ var route_config_impl_2 = require("angular2/src/router/route_config_impl");
885
+ exports.Route = route_config_impl_2.Route;
886
+ exports.Redirect = route_config_impl_2.Redirect;
887
+ exports.AuxRoute = route_config_impl_2.AuxRoute;
888
+ exports.AsyncRoute = route_config_impl_2.AsyncRoute;
889
+ exports.RouteConfig = decorators_1.makeDecorator(route_config_impl_1.RouteConfig);
890
+ global.define = __define;
891
+ return module.exports;
892
+ });
893
+
894
+ System.register("angular2/src/router/location_strategy", ["angular2/src/facade/lang", "angular2/core"], true, function(require, exports, module) {
895
+ var global = System.global,
896
+ __define = global.define;
897
+ global.define = undefined;
898
+ var lang_1 = require("angular2/src/facade/lang");
899
+ var core_1 = require("angular2/core");
900
+ var LocationStrategy = (function() {
901
+ function LocationStrategy() {}
902
+ return LocationStrategy;
903
+ })();
904
+ exports.LocationStrategy = LocationStrategy;
905
+ exports.APP_BASE_HREF = lang_1.CONST_EXPR(new core_1.OpaqueToken('appBaseHref'));
906
+ function normalizeQueryParams(params) {
907
+ return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params;
908
+ }
909
+ exports.normalizeQueryParams = normalizeQueryParams;
910
+ function joinWithSlash(start, end) {
911
+ if (start.length == 0) {
912
+ return end;
913
+ }
914
+ if (end.length == 0) {
915
+ return start;
916
+ }
917
+ var slashes = 0;
918
+ if (start.endsWith('/')) {
919
+ slashes++;
920
+ }
921
+ if (end.startsWith('/')) {
922
+ slashes++;
923
+ }
924
+ if (slashes == 2) {
925
+ return start + end.substring(1);
926
+ }
927
+ if (slashes == 1) {
928
+ return start + end;
929
+ }
930
+ return start + '/' + end;
931
+ }
932
+ exports.joinWithSlash = joinWithSlash;
933
+ global.define = __define;
934
+ return module.exports;
935
+ });
936
+
937
+ System.register("angular2/src/router/lifecycle_annotations_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
938
+ var global = System.global,
939
+ __define = global.define;
940
+ global.define = undefined;
941
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
942
+ var c = arguments.length,
943
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
944
+ d;
945
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
946
+ r = Reflect.decorate(decorators, target, key, desc);
947
+ else
948
+ for (var i = decorators.length - 1; i >= 0; i--)
949
+ if (d = decorators[i])
950
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
951
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
952
+ };
953
+ var __metadata = (this && this.__metadata) || function(k, v) {
954
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
955
+ return Reflect.metadata(k, v);
956
+ };
957
+ var lang_1 = require("angular2/src/facade/lang");
958
+ var RouteLifecycleHook = (function() {
959
+ function RouteLifecycleHook(name) {
960
+ this.name = name;
961
+ }
962
+ RouteLifecycleHook = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], RouteLifecycleHook);
963
+ return RouteLifecycleHook;
964
+ })();
965
+ exports.RouteLifecycleHook = RouteLifecycleHook;
966
+ var CanActivate = (function() {
967
+ function CanActivate(fn) {
968
+ this.fn = fn;
969
+ }
970
+ CanActivate = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Function])], CanActivate);
971
+ return CanActivate;
972
+ })();
973
+ exports.CanActivate = CanActivate;
974
+ exports.routerCanReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanReuse"));
975
+ exports.routerCanDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanDeactivate"));
976
+ exports.routerOnActivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnActivate"));
977
+ exports.routerOnReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnReuse"));
978
+ exports.routerOnDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnDeactivate"));
979
+ global.define = __define;
980
+ return module.exports;
981
+ });
982
+
983
+ System.register("angular2/src/router/lifecycle_annotations", ["angular2/src/core/util/decorators", "angular2/src/router/lifecycle_annotations_impl", "angular2/src/router/lifecycle_annotations_impl"], true, function(require, exports, module) {
984
+ var global = System.global,
985
+ __define = global.define;
986
+ global.define = undefined;
987
+ var decorators_1 = require("angular2/src/core/util/decorators");
988
+ var lifecycle_annotations_impl_1 = require("angular2/src/router/lifecycle_annotations_impl");
989
+ var lifecycle_annotations_impl_2 = require("angular2/src/router/lifecycle_annotations_impl");
990
+ exports.routerCanReuse = lifecycle_annotations_impl_2.routerCanReuse;
991
+ exports.routerCanDeactivate = lifecycle_annotations_impl_2.routerCanDeactivate;
992
+ exports.routerOnActivate = lifecycle_annotations_impl_2.routerOnActivate;
993
+ exports.routerOnReuse = lifecycle_annotations_impl_2.routerOnReuse;
994
+ exports.routerOnDeactivate = lifecycle_annotations_impl_2.routerOnDeactivate;
995
+ exports.CanActivate = decorators_1.makeDecorator(lifecycle_annotations_impl_1.CanActivate);
996
+ global.define = __define;
997
+ return module.exports;
998
+ });
999
+
1000
+ System.register("angular2/src/router/router_link", ["angular2/core", "angular2/src/facade/lang", "angular2/src/router/router", "angular2/src/router/location"], true, function(require, exports, module) {
1001
+ var global = System.global,
1002
+ __define = global.define;
1003
+ global.define = undefined;
1004
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
1005
+ var c = arguments.length,
1006
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
1007
+ d;
1008
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1009
+ r = Reflect.decorate(decorators, target, key, desc);
1010
+ else
1011
+ for (var i = decorators.length - 1; i >= 0; i--)
1012
+ if (d = decorators[i])
1013
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1014
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1015
+ };
1016
+ var __metadata = (this && this.__metadata) || function(k, v) {
1017
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1018
+ return Reflect.metadata(k, v);
1019
+ };
1020
+ var core_1 = require("angular2/core");
1021
+ var lang_1 = require("angular2/src/facade/lang");
1022
+ var router_1 = require("angular2/src/router/router");
1023
+ var location_1 = require("angular2/src/router/location");
1024
+ var RouterLink = (function() {
1025
+ function RouterLink(_router, _location) {
1026
+ var _this = this;
1027
+ this._router = _router;
1028
+ this._location = _location;
1029
+ this._router.subscribe(function(_) {
1030
+ return _this._updateLink();
1031
+ });
1032
+ }
1033
+ RouterLink.prototype._updateLink = function() {
1034
+ this._navigationInstruction = this._router.generate(this._routeParams);
1035
+ var navigationHref = this._navigationInstruction.toLinkUrl();
1036
+ this.visibleHref = this._location.prepareExternalUrl(navigationHref);
1037
+ };
1038
+ Object.defineProperty(RouterLink.prototype, "isRouteActive", {
1039
+ get: function() {
1040
+ return this._router.isRouteActive(this._navigationInstruction);
1041
+ },
1042
+ enumerable: true,
1043
+ configurable: true
1044
+ });
1045
+ Object.defineProperty(RouterLink.prototype, "routeParams", {
1046
+ set: function(changes) {
1047
+ this._routeParams = changes;
1048
+ this._updateLink();
1049
+ },
1050
+ enumerable: true,
1051
+ configurable: true
1052
+ });
1053
+ RouterLink.prototype.onClick = function() {
1054
+ if (!lang_1.isString(this.target) || this.target == '_self') {
1055
+ this._router.navigateByInstruction(this._navigationInstruction);
1056
+ return false;
1057
+ }
1058
+ return true;
1059
+ };
1060
+ RouterLink = __decorate([core_1.Directive({
1061
+ selector: '[routerLink]',
1062
+ inputs: ['routeParams: routerLink', 'target: target'],
1063
+ host: {
1064
+ '(click)': 'onClick()',
1065
+ '[attr.href]': 'visibleHref',
1066
+ '[class.router-link-active]': 'isRouteActive'
1067
+ }
1068
+ }), __metadata('design:paramtypes', [router_1.Router, location_1.Location])], RouterLink);
1069
+ return RouterLink;
1070
+ })();
1071
+ exports.RouterLink = RouterLink;
1072
+ global.define = __define;
1073
+ return module.exports;
1074
+ });
1075
+
1076
+ System.register("angular2/src/router/platform_location", [], true, function(require, exports, module) {
1077
+ var global = System.global,
1078
+ __define = global.define;
1079
+ global.define = undefined;
1080
+ var PlatformLocation = (function() {
1081
+ function PlatformLocation() {}
1082
+ return PlatformLocation;
1083
+ })();
1084
+ exports.PlatformLocation = PlatformLocation;
1085
+ global.define = __define;
1086
+ return module.exports;
1087
+ });
1088
+
1089
+ System.register("angular2/src/router/hash_location_strategy", ["angular2/core", "angular2/src/router/location_strategy", "angular2/src/facade/lang", "angular2/src/router/platform_location"], true, function(require, exports, module) {
1090
+ var global = System.global,
1091
+ __define = global.define;
1092
+ global.define = undefined;
1093
+ var __extends = (this && this.__extends) || function(d, b) {
1094
+ for (var p in b)
1095
+ if (b.hasOwnProperty(p))
1096
+ d[p] = b[p];
1097
+ function __() {
1098
+ this.constructor = d;
1099
+ }
1100
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1101
+ };
1102
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
1103
+ var c = arguments.length,
1104
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
1105
+ d;
1106
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1107
+ r = Reflect.decorate(decorators, target, key, desc);
1108
+ else
1109
+ for (var i = decorators.length - 1; i >= 0; i--)
1110
+ if (d = decorators[i])
1111
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1112
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1113
+ };
1114
+ var __metadata = (this && this.__metadata) || function(k, v) {
1115
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1116
+ return Reflect.metadata(k, v);
1117
+ };
1118
+ var __param = (this && this.__param) || function(paramIndex, decorator) {
1119
+ return function(target, key) {
1120
+ decorator(target, key, paramIndex);
1121
+ };
1122
+ };
1123
+ var core_1 = require("angular2/core");
1124
+ var location_strategy_1 = require("angular2/src/router/location_strategy");
1125
+ var lang_1 = require("angular2/src/facade/lang");
1126
+ var platform_location_1 = require("angular2/src/router/platform_location");
1127
+ var HashLocationStrategy = (function(_super) {
1128
+ __extends(HashLocationStrategy, _super);
1129
+ function HashLocationStrategy(_platformLocation, _baseHref) {
1130
+ _super.call(this);
1131
+ this._platformLocation = _platformLocation;
1132
+ this._baseHref = '';
1133
+ if (lang_1.isPresent(_baseHref)) {
1134
+ this._baseHref = _baseHref;
1135
+ }
1136
+ }
1137
+ HashLocationStrategy.prototype.onPopState = function(fn) {
1138
+ this._platformLocation.onPopState(fn);
1139
+ this._platformLocation.onHashChange(fn);
1140
+ };
1141
+ HashLocationStrategy.prototype.getBaseHref = function() {
1142
+ return this._baseHref;
1143
+ };
1144
+ HashLocationStrategy.prototype.path = function() {
1145
+ var path = this._platformLocation.hash;
1146
+ return (path.length > 0 ? path.substring(1) : path) + location_strategy_1.normalizeQueryParams(this._platformLocation.search);
1147
+ };
1148
+ HashLocationStrategy.prototype.prepareExternalUrl = function(internal) {
1149
+ var url = location_strategy_1.joinWithSlash(this._baseHref, internal);
1150
+ return url.length > 0 ? ('#' + url) : url;
1151
+ };
1152
+ HashLocationStrategy.prototype.pushState = function(state, title, path, queryParams) {
1153
+ var url = this.prepareExternalUrl(path + location_strategy_1.normalizeQueryParams(queryParams));
1154
+ if (url.length == 0) {
1155
+ url = this._platformLocation.pathname;
1156
+ }
1157
+ this._platformLocation.pushState(state, title, url);
1158
+ };
1159
+ HashLocationStrategy.prototype.replaceState = function(state, title, path, queryParams) {
1160
+ var url = this.prepareExternalUrl(path + location_strategy_1.normalizeQueryParams(queryParams));
1161
+ if (url.length == 0) {
1162
+ url = this._platformLocation.pathname;
1163
+ }
1164
+ this._platformLocation.replaceState(state, title, url);
1165
+ };
1166
+ HashLocationStrategy.prototype.forward = function() {
1167
+ this._platformLocation.forward();
1168
+ };
1169
+ HashLocationStrategy.prototype.back = function() {
1170
+ this._platformLocation.back();
1171
+ };
1172
+ HashLocationStrategy = __decorate([core_1.Injectable(), __param(1, core_1.Optional()), __param(1, core_1.Inject(location_strategy_1.APP_BASE_HREF)), __metadata('design:paramtypes', [platform_location_1.PlatformLocation, String])], HashLocationStrategy);
1173
+ return HashLocationStrategy;
1174
+ })(location_strategy_1.LocationStrategy);
1175
+ exports.HashLocationStrategy = HashLocationStrategy;
1176
+ global.define = __define;
1177
+ return module.exports;
1178
+ });
1179
+
1180
+ System.register("angular2/src/router/path_location_strategy", ["angular2/core", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/router/location_strategy", "angular2/src/router/platform_location"], true, function(require, exports, module) {
1181
+ var global = System.global,
1182
+ __define = global.define;
1183
+ global.define = undefined;
1184
+ var __extends = (this && this.__extends) || function(d, b) {
1185
+ for (var p in b)
1186
+ if (b.hasOwnProperty(p))
1187
+ d[p] = b[p];
1188
+ function __() {
1189
+ this.constructor = d;
1190
+ }
1191
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1192
+ };
1193
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
1194
+ var c = arguments.length,
1195
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
1196
+ d;
1197
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1198
+ r = Reflect.decorate(decorators, target, key, desc);
1199
+ else
1200
+ for (var i = decorators.length - 1; i >= 0; i--)
1201
+ if (d = decorators[i])
1202
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1203
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1204
+ };
1205
+ var __metadata = (this && this.__metadata) || function(k, v) {
1206
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1207
+ return Reflect.metadata(k, v);
1208
+ };
1209
+ var __param = (this && this.__param) || function(paramIndex, decorator) {
1210
+ return function(target, key) {
1211
+ decorator(target, key, paramIndex);
1212
+ };
1213
+ };
1214
+ var core_1 = require("angular2/core");
1215
+ var lang_1 = require("angular2/src/facade/lang");
1216
+ var exceptions_1 = require("angular2/src/facade/exceptions");
1217
+ var location_strategy_1 = require("angular2/src/router/location_strategy");
1218
+ var platform_location_1 = require("angular2/src/router/platform_location");
1219
+ var PathLocationStrategy = (function(_super) {
1220
+ __extends(PathLocationStrategy, _super);
1221
+ function PathLocationStrategy(_platformLocation, href) {
1222
+ _super.call(this);
1223
+ this._platformLocation = _platformLocation;
1224
+ if (lang_1.isBlank(href)) {
1225
+ href = this._platformLocation.getBaseHrefFromDOM();
1226
+ }
1227
+ if (lang_1.isBlank(href)) {
1228
+ throw new exceptions_1.BaseException("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
1229
+ }
1230
+ this._baseHref = href;
1231
+ }
1232
+ PathLocationStrategy.prototype.onPopState = function(fn) {
1233
+ this._platformLocation.onPopState(fn);
1234
+ this._platformLocation.onHashChange(fn);
1235
+ };
1236
+ PathLocationStrategy.prototype.getBaseHref = function() {
1237
+ return this._baseHref;
1238
+ };
1239
+ PathLocationStrategy.prototype.prepareExternalUrl = function(internal) {
1240
+ return location_strategy_1.joinWithSlash(this._baseHref, internal);
1241
+ };
1242
+ PathLocationStrategy.prototype.path = function() {
1243
+ return this._platformLocation.pathname + location_strategy_1.normalizeQueryParams(this._platformLocation.search);
1244
+ };
1245
+ PathLocationStrategy.prototype.pushState = function(state, title, url, queryParams) {
1246
+ var externalUrl = this.prepareExternalUrl(url + location_strategy_1.normalizeQueryParams(queryParams));
1247
+ this._platformLocation.pushState(state, title, externalUrl);
1248
+ };
1249
+ PathLocationStrategy.prototype.replaceState = function(state, title, url, queryParams) {
1250
+ var externalUrl = this.prepareExternalUrl(url + location_strategy_1.normalizeQueryParams(queryParams));
1251
+ this._platformLocation.replaceState(state, title, externalUrl);
1252
+ };
1253
+ PathLocationStrategy.prototype.forward = function() {
1254
+ this._platformLocation.forward();
1255
+ };
1256
+ PathLocationStrategy.prototype.back = function() {
1257
+ this._platformLocation.back();
1258
+ };
1259
+ PathLocationStrategy = __decorate([core_1.Injectable(), __param(1, core_1.Optional()), __param(1, core_1.Inject(location_strategy_1.APP_BASE_HREF)), __metadata('design:paramtypes', [platform_location_1.PlatformLocation, String])], PathLocationStrategy);
1260
+ return PathLocationStrategy;
1261
+ })(location_strategy_1.LocationStrategy);
1262
+ exports.PathLocationStrategy = PathLocationStrategy;
1263
+ global.define = __define;
1264
+ return module.exports;
1265
+ });
1266
+
1267
+ System.register("angular2/src/router/route_definition", [], true, function(require, exports, module) {
1268
+ var global = System.global,
1269
+ __define = global.define;
1270
+ global.define = undefined;
1271
+ global.define = __define;
1272
+ return module.exports;
1273
+ });
1274
+
1275
+ System.register("angular2/src/router/router_providers_common", ["angular2/src/router/location_strategy", "angular2/src/router/path_location_strategy", "angular2/src/router/router", "angular2/src/router/route_registry", "angular2/src/router/location", "angular2/src/facade/lang", "angular2/core", "angular2/src/facade/exceptions"], true, function(require, exports, module) {
1276
+ var global = System.global,
1277
+ __define = global.define;
1278
+ global.define = undefined;
1279
+ var location_strategy_1 = require("angular2/src/router/location_strategy");
1280
+ var path_location_strategy_1 = require("angular2/src/router/path_location_strategy");
1281
+ var router_1 = require("angular2/src/router/router");
1282
+ var route_registry_1 = require("angular2/src/router/route_registry");
1283
+ var location_1 = require("angular2/src/router/location");
1284
+ var lang_1 = require("angular2/src/facade/lang");
1285
+ var core_1 = require("angular2/core");
1286
+ var exceptions_1 = require("angular2/src/facade/exceptions");
1287
+ exports.ROUTER_PROVIDERS_COMMON = lang_1.CONST_EXPR([route_registry_1.RouteRegistry, lang_1.CONST_EXPR(new core_1.Provider(location_strategy_1.LocationStrategy, {useClass: path_location_strategy_1.PathLocationStrategy})), location_1.Location, lang_1.CONST_EXPR(new core_1.Provider(router_1.Router, {
1288
+ useFactory: routerFactory,
1289
+ deps: lang_1.CONST_EXPR([route_registry_1.RouteRegistry, location_1.Location, route_registry_1.ROUTER_PRIMARY_COMPONENT, core_1.ApplicationRef])
1290
+ })), lang_1.CONST_EXPR(new core_1.Provider(route_registry_1.ROUTER_PRIMARY_COMPONENT, {
1291
+ useFactory: routerPrimaryComponentFactory,
1292
+ deps: lang_1.CONST_EXPR([core_1.ApplicationRef])
1293
+ }))]);
1294
+ function routerFactory(registry, location, primaryComponent, appRef) {
1295
+ var rootRouter = new router_1.RootRouter(registry, location, primaryComponent);
1296
+ appRef.registerDisposeListener(function() {
1297
+ return rootRouter.dispose();
1298
+ });
1299
+ return rootRouter;
1300
+ }
1301
+ function routerPrimaryComponentFactory(app) {
1302
+ if (app.componentTypes.length == 0) {
1303
+ throw new exceptions_1.BaseException("Bootstrap at least one component before injecting Router.");
1304
+ }
1305
+ return app.componentTypes[0];
1306
+ }
1307
+ global.define = __define;
1308
+ return module.exports;
1309
+ });
1310
+
1311
+ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/collection", "angular2/src/router/url_parser"], true, function(require, exports, module) {
1312
+ var global = System.global,
1313
+ __define = global.define;
1314
+ global.define = undefined;
1315
+ var lang_1 = require("angular2/src/facade/lang");
1316
+ var exceptions_1 = require("angular2/src/facade/exceptions");
1317
+ var collection_1 = require("angular2/src/facade/collection");
1318
+ var url_parser_1 = require("angular2/src/router/url_parser");
1319
+ var TouchMap = (function() {
1320
+ function TouchMap(map) {
1321
+ var _this = this;
1322
+ this.map = {};
1323
+ this.keys = {};
1324
+ if (lang_1.isPresent(map)) {
1325
+ collection_1.StringMapWrapper.forEach(map, function(value, key) {
1326
+ _this.map[key] = lang_1.isPresent(value) ? value.toString() : null;
1327
+ _this.keys[key] = true;
1328
+ });
1329
+ }
1330
+ }
1331
+ TouchMap.prototype.get = function(key) {
1332
+ collection_1.StringMapWrapper.delete(this.keys, key);
1333
+ return this.map[key];
1334
+ };
1335
+ TouchMap.prototype.getUnused = function() {
1336
+ var _this = this;
1337
+ var unused = {};
1338
+ var keys = collection_1.StringMapWrapper.keys(this.keys);
1339
+ keys.forEach(function(key) {
1340
+ return unused[key] = collection_1.StringMapWrapper.get(_this.map, key);
1341
+ });
1342
+ return unused;
1343
+ };
1344
+ return TouchMap;
1345
+ })();
1346
+ function normalizeString(obj) {
1347
+ if (lang_1.isBlank(obj)) {
1348
+ return null;
1349
+ } else {
1350
+ return obj.toString();
1351
+ }
1352
+ }
1353
+ var ContinuationSegment = (function() {
1354
+ function ContinuationSegment() {
1355
+ this.name = '';
1356
+ }
1357
+ ContinuationSegment.prototype.generate = function(params) {
1358
+ return '';
1359
+ };
1360
+ ContinuationSegment.prototype.match = function(path) {
1361
+ return true;
1362
+ };
1363
+ return ContinuationSegment;
1364
+ })();
1365
+ var StaticSegment = (function() {
1366
+ function StaticSegment(path) {
1367
+ this.path = path;
1368
+ this.name = '';
1369
+ }
1370
+ StaticSegment.prototype.match = function(path) {
1371
+ return path == this.path;
1372
+ };
1373
+ StaticSegment.prototype.generate = function(params) {
1374
+ return this.path;
1375
+ };
1376
+ return StaticSegment;
1377
+ })();
1378
+ var DynamicSegment = (function() {
1379
+ function DynamicSegment(name) {
1380
+ this.name = name;
1381
+ }
1382
+ DynamicSegment.prototype.match = function(path) {
1383
+ return path.length > 0;
1384
+ };
1385
+ DynamicSegment.prototype.generate = function(params) {
1386
+ if (!collection_1.StringMapWrapper.contains(params.map, this.name)) {
1387
+ throw new exceptions_1.BaseException("Route generator for '" + this.name + "' was not included in parameters passed.");
1388
+ }
1389
+ return normalizeString(params.get(this.name));
1390
+ };
1391
+ return DynamicSegment;
1392
+ })();
1393
+ var StarSegment = (function() {
1394
+ function StarSegment(name) {
1395
+ this.name = name;
1396
+ }
1397
+ StarSegment.prototype.match = function(path) {
1398
+ return true;
1399
+ };
1400
+ StarSegment.prototype.generate = function(params) {
1401
+ return normalizeString(params.get(this.name));
1402
+ };
1403
+ return StarSegment;
1404
+ })();
1405
+ var paramMatcher = /^:([^\/]+)$/g;
1406
+ var wildcardMatcher = /^\*([^\/]+)$/g;
1407
+ function parsePathString(route) {
1408
+ if (route.startsWith("/")) {
1409
+ route = route.substring(1);
1410
+ }
1411
+ var segments = splitBySlash(route);
1412
+ var results = [];
1413
+ var specificity = '';
1414
+ if (segments.length == 0) {
1415
+ specificity += '2';
1416
+ }
1417
+ var limit = segments.length - 1;
1418
+ for (var i = 0; i <= limit; i++) {
1419
+ var segment = segments[i],
1420
+ match;
1421
+ if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(paramMatcher, segment))) {
1422
+ results.push(new DynamicSegment(match[1]));
1423
+ specificity += '1';
1424
+ } else if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(wildcardMatcher, segment))) {
1425
+ results.push(new StarSegment(match[1]));
1426
+ specificity += '0';
1427
+ } else if (segment == '...') {
1428
+ if (i < limit) {
1429
+ throw new exceptions_1.BaseException("Unexpected \"...\" before the end of the path for \"" + route + "\".");
1430
+ }
1431
+ results.push(new ContinuationSegment());
1432
+ } else {
1433
+ results.push(new StaticSegment(segment));
1434
+ specificity += '2';
1435
+ }
1436
+ }
1437
+ return {
1438
+ 'segments': results,
1439
+ 'specificity': specificity
1440
+ };
1441
+ }
1442
+ function pathDslHash(segments) {
1443
+ return segments.map(function(segment) {
1444
+ if (segment instanceof StarSegment) {
1445
+ return '*';
1446
+ } else if (segment instanceof ContinuationSegment) {
1447
+ return '...';
1448
+ } else if (segment instanceof DynamicSegment) {
1449
+ return ':';
1450
+ } else if (segment instanceof StaticSegment) {
1451
+ return segment.path;
1452
+ }
1453
+ }).join('/');
1454
+ }
1455
+ function splitBySlash(url) {
1456
+ return url.split('/');
1457
+ }
1458
+ var RESERVED_CHARS = lang_1.RegExpWrapper.create('//|\\(|\\)|;|\\?|=');
1459
+ function assertPath(path) {
1460
+ if (lang_1.StringWrapper.contains(path, '#')) {
1461
+ throw new exceptions_1.BaseException("Path \"" + path + "\" should not include \"#\". Use \"HashLocationStrategy\" instead.");
1462
+ }
1463
+ var illegalCharacter = lang_1.RegExpWrapper.firstMatch(RESERVED_CHARS, path);
1464
+ if (lang_1.isPresent(illegalCharacter)) {
1465
+ throw new exceptions_1.BaseException("Path \"" + path + "\" contains \"" + illegalCharacter[0] + "\" which is not allowed in a route config.");
1466
+ }
1467
+ }
1468
+ var PathRecognizer = (function() {
1469
+ function PathRecognizer(path) {
1470
+ this.path = path;
1471
+ this.terminal = true;
1472
+ assertPath(path);
1473
+ var parsed = parsePathString(path);
1474
+ this._segments = parsed['segments'];
1475
+ this.specificity = parsed['specificity'];
1476
+ this.hash = pathDslHash(this._segments);
1477
+ var lastSegment = this._segments[this._segments.length - 1];
1478
+ this.terminal = !(lastSegment instanceof ContinuationSegment);
1479
+ }
1480
+ PathRecognizer.prototype.recognize = function(beginningSegment) {
1481
+ var nextSegment = beginningSegment;
1482
+ var currentSegment;
1483
+ var positionalParams = {};
1484
+ var captured = [];
1485
+ for (var i = 0; i < this._segments.length; i += 1) {
1486
+ var segment = this._segments[i];
1487
+ currentSegment = nextSegment;
1488
+ if (segment instanceof ContinuationSegment) {
1489
+ break;
1490
+ }
1491
+ if (lang_1.isPresent(currentSegment)) {
1492
+ if (segment instanceof StarSegment) {
1493
+ positionalParams[segment.name] = currentSegment.toString();
1494
+ captured.push(currentSegment.toString());
1495
+ nextSegment = null;
1496
+ break;
1497
+ }
1498
+ captured.push(currentSegment.path);
1499
+ if (segment instanceof DynamicSegment) {
1500
+ positionalParams[segment.name] = currentSegment.path;
1501
+ } else if (!segment.match(currentSegment.path)) {
1502
+ return null;
1503
+ }
1504
+ nextSegment = currentSegment.child;
1505
+ } else if (!segment.match('')) {
1506
+ return null;
1507
+ }
1508
+ }
1509
+ if (this.terminal && lang_1.isPresent(nextSegment)) {
1510
+ return null;
1511
+ }
1512
+ var urlPath = captured.join('/');
1513
+ var auxiliary;
1514
+ var urlParams;
1515
+ var allParams;
1516
+ if (lang_1.isPresent(currentSegment)) {
1517
+ var paramsSegment = beginningSegment instanceof url_parser_1.RootUrl ? beginningSegment : currentSegment;
1518
+ allParams = lang_1.isPresent(paramsSegment.params) ? collection_1.StringMapWrapper.merge(paramsSegment.params, positionalParams) : positionalParams;
1519
+ urlParams = url_parser_1.serializeParams(paramsSegment.params);
1520
+ auxiliary = currentSegment.auxiliary;
1521
+ } else {
1522
+ allParams = positionalParams;
1523
+ auxiliary = [];
1524
+ urlParams = [];
1525
+ }
1526
+ return {
1527
+ urlPath: urlPath,
1528
+ urlParams: urlParams,
1529
+ allParams: allParams,
1530
+ auxiliary: auxiliary,
1531
+ nextSegment: nextSegment
1532
+ };
1533
+ };
1534
+ PathRecognizer.prototype.generate = function(params) {
1535
+ var paramTokens = new TouchMap(params);
1536
+ var path = [];
1537
+ for (var i = 0; i < this._segments.length; i++) {
1538
+ var segment = this._segments[i];
1539
+ if (!(segment instanceof ContinuationSegment)) {
1540
+ path.push(segment.generate(paramTokens));
1541
+ }
1542
+ }
1543
+ var urlPath = path.join('/');
1544
+ var nonPositionalParams = paramTokens.getUnused();
1545
+ var urlParams = url_parser_1.serializeParams(nonPositionalParams);
1546
+ return {
1547
+ urlPath: urlPath,
1548
+ urlParams: urlParams
1549
+ };
1550
+ };
1551
+ return PathRecognizer;
1552
+ })();
1553
+ exports.PathRecognizer = PathRecognizer;
1554
+ global.define = __define;
1555
+ return module.exports;
1556
+ });
1557
+
1558
+ System.register("angular2/src/router/component_recognizer", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/collection", "angular2/src/facade/async", "angular2/src/router/route_recognizer", "angular2/src/router/route_config_impl", "angular2/src/router/async_route_handler", "angular2/src/router/sync_route_handler"], true, function(require, exports, module) {
1559
+ var global = System.global,
1560
+ __define = global.define;
1561
+ global.define = undefined;
1562
+ var lang_1 = require("angular2/src/facade/lang");
1563
+ var exceptions_1 = require("angular2/src/facade/exceptions");
1564
+ var collection_1 = require("angular2/src/facade/collection");
1565
+ var async_1 = require("angular2/src/facade/async");
1566
+ var route_recognizer_1 = require("angular2/src/router/route_recognizer");
1567
+ var route_config_impl_1 = require("angular2/src/router/route_config_impl");
1568
+ var async_route_handler_1 = require("angular2/src/router/async_route_handler");
1569
+ var sync_route_handler_1 = require("angular2/src/router/sync_route_handler");
1570
+ var ComponentRecognizer = (function() {
1571
+ function ComponentRecognizer() {
1572
+ this.names = new collection_1.Map();
1573
+ this.auxNames = new collection_1.Map();
1574
+ this.auxRoutes = new collection_1.Map();
1575
+ this.matchers = [];
1576
+ this.defaultRoute = null;
1577
+ }
1578
+ ComponentRecognizer.prototype.config = function(config) {
1579
+ var handler;
1580
+ if (lang_1.isPresent(config.name) && config.name[0].toUpperCase() != config.name[0]) {
1581
+ var suggestedName = config.name[0].toUpperCase() + config.name.substring(1);
1582
+ throw new exceptions_1.BaseException("Route \"" + config.path + "\" with name \"" + config.name + "\" does not begin with an uppercase letter. Route names should be CamelCase like \"" + suggestedName + "\".");
1583
+ }
1584
+ if (config instanceof route_config_impl_1.AuxRoute) {
1585
+ handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);
1586
+ var path = config.path.startsWith('/') ? config.path.substring(1) : config.path;
1587
+ var recognizer = new route_recognizer_1.RouteRecognizer(config.path, handler);
1588
+ this.auxRoutes.set(path, recognizer);
1589
+ if (lang_1.isPresent(config.name)) {
1590
+ this.auxNames.set(config.name, recognizer);
1591
+ }
1592
+ return recognizer.terminal;
1593
+ }
1594
+ var useAsDefault = false;
1595
+ if (config instanceof route_config_impl_1.Redirect) {
1596
+ var redirector = new route_recognizer_1.RedirectRecognizer(config.path, config.redirectTo);
1597
+ this._assertNoHashCollision(redirector.hash, config.path);
1598
+ this.matchers.push(redirector);
1599
+ return true;
1600
+ }
1601
+ if (config instanceof route_config_impl_1.Route) {
1602
+ handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);
1603
+ useAsDefault = lang_1.isPresent(config.useAsDefault) && config.useAsDefault;
1604
+ } else if (config instanceof route_config_impl_1.AsyncRoute) {
1605
+ handler = new async_route_handler_1.AsyncRouteHandler(config.loader, config.data);
1606
+ useAsDefault = lang_1.isPresent(config.useAsDefault) && config.useAsDefault;
1607
+ }
1608
+ var recognizer = new route_recognizer_1.RouteRecognizer(config.path, handler);
1609
+ this._assertNoHashCollision(recognizer.hash, config.path);
1610
+ if (useAsDefault) {
1611
+ if (lang_1.isPresent(this.defaultRoute)) {
1612
+ throw new exceptions_1.BaseException("Only one route can be default");
1613
+ }
1614
+ this.defaultRoute = recognizer;
1615
+ }
1616
+ this.matchers.push(recognizer);
1617
+ if (lang_1.isPresent(config.name)) {
1618
+ this.names.set(config.name, recognizer);
1619
+ }
1620
+ return recognizer.terminal;
1621
+ };
1622
+ ComponentRecognizer.prototype._assertNoHashCollision = function(hash, path) {
1623
+ this.matchers.forEach(function(matcher) {
1624
+ if (hash == matcher.hash) {
1625
+ throw new exceptions_1.BaseException("Configuration '" + path + "' conflicts with existing route '" + matcher.path + "'");
1626
+ }
1627
+ });
1628
+ };
1629
+ ComponentRecognizer.prototype.recognize = function(urlParse) {
1630
+ var solutions = [];
1631
+ this.matchers.forEach(function(routeRecognizer) {
1632
+ var pathMatch = routeRecognizer.recognize(urlParse);
1633
+ if (lang_1.isPresent(pathMatch)) {
1634
+ solutions.push(pathMatch);
1635
+ }
1636
+ });
1637
+ if (solutions.length == 0 && lang_1.isPresent(urlParse) && urlParse.auxiliary.length > 0) {
1638
+ return [async_1.PromiseWrapper.resolve(new route_recognizer_1.PathMatch(null, null, urlParse.auxiliary))];
1639
+ }
1640
+ return solutions;
1641
+ };
1642
+ ComponentRecognizer.prototype.recognizeAuxiliary = function(urlParse) {
1643
+ var routeRecognizer = this.auxRoutes.get(urlParse.path);
1644
+ if (lang_1.isPresent(routeRecognizer)) {
1645
+ return [routeRecognizer.recognize(urlParse)];
1646
+ }
1647
+ return [async_1.PromiseWrapper.resolve(null)];
1648
+ };
1649
+ ComponentRecognizer.prototype.hasRoute = function(name) {
1650
+ return this.names.has(name);
1651
+ };
1652
+ ComponentRecognizer.prototype.componentLoaded = function(name) {
1653
+ return this.hasRoute(name) && lang_1.isPresent(this.names.get(name).handler.componentType);
1654
+ };
1655
+ ComponentRecognizer.prototype.loadComponent = function(name) {
1656
+ return this.names.get(name).handler.resolveComponentType();
1657
+ };
1658
+ ComponentRecognizer.prototype.generate = function(name, params) {
1659
+ var pathRecognizer = this.names.get(name);
1660
+ if (lang_1.isBlank(pathRecognizer)) {
1661
+ return null;
1662
+ }
1663
+ return pathRecognizer.generate(params);
1664
+ };
1665
+ ComponentRecognizer.prototype.generateAuxiliary = function(name, params) {
1666
+ var pathRecognizer = this.auxNames.get(name);
1667
+ if (lang_1.isBlank(pathRecognizer)) {
1668
+ return null;
1669
+ }
1670
+ return pathRecognizer.generate(params);
1671
+ };
1672
+ return ComponentRecognizer;
1673
+ })();
1674
+ exports.ComponentRecognizer = ComponentRecognizer;
1675
+ global.define = __define;
1676
+ return module.exports;
1677
+ });
1678
+
1679
+ System.register("angular2/src/router/route_config_nomalizer", ["angular2/src/router/route_config_decorator", "angular2/src/facade/lang", "angular2/src/facade/exceptions"], true, function(require, exports, module) {
1680
+ var global = System.global,
1681
+ __define = global.define;
1682
+ global.define = undefined;
1683
+ var route_config_decorator_1 = require("angular2/src/router/route_config_decorator");
1684
+ var lang_1 = require("angular2/src/facade/lang");
1685
+ var exceptions_1 = require("angular2/src/facade/exceptions");
1686
+ function normalizeRouteConfig(config, registry) {
1687
+ if (config instanceof route_config_decorator_1.AsyncRoute) {
1688
+ var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
1689
+ return new route_config_decorator_1.AsyncRoute({
1690
+ path: config.path,
1691
+ loader: wrappedLoader,
1692
+ name: config.name,
1693
+ data: config.data,
1694
+ useAsDefault: config.useAsDefault
1695
+ });
1696
+ }
1697
+ if (config instanceof route_config_decorator_1.Route || config instanceof route_config_decorator_1.Redirect || config instanceof route_config_decorator_1.AuxRoute) {
1698
+ return config;
1699
+ }
1700
+ if ((+!!config.component) + (+!!config.redirectTo) + (+!!config.loader) != 1) {
1701
+ throw new exceptions_1.BaseException("Route config should contain exactly one \"component\", \"loader\", or \"redirectTo\" property.");
1702
+ }
1703
+ if (config.as && config.name) {
1704
+ throw new exceptions_1.BaseException("Route config should contain exactly one \"as\" or \"name\" property.");
1705
+ }
1706
+ if (config.as) {
1707
+ config.name = config.as;
1708
+ }
1709
+ if (config.loader) {
1710
+ var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
1711
+ return new route_config_decorator_1.AsyncRoute({
1712
+ path: config.path,
1713
+ loader: wrappedLoader,
1714
+ name: config.name,
1715
+ data: config.data,
1716
+ useAsDefault: config.useAsDefault
1717
+ });
1718
+ }
1719
+ if (config.aux) {
1720
+ return new route_config_decorator_1.AuxRoute({
1721
+ path: config.aux,
1722
+ component: config.component,
1723
+ name: config.name
1724
+ });
1725
+ }
1726
+ if (config.component) {
1727
+ if (typeof config.component == 'object') {
1728
+ var componentDefinitionObject = config.component;
1729
+ if (componentDefinitionObject.type == 'constructor') {
1730
+ return new route_config_decorator_1.Route({
1731
+ path: config.path,
1732
+ component: componentDefinitionObject.constructor,
1733
+ name: config.name,
1734
+ data: config.data,
1735
+ useAsDefault: config.useAsDefault
1736
+ });
1737
+ } else if (componentDefinitionObject.type == 'loader') {
1738
+ return new route_config_decorator_1.AsyncRoute({
1739
+ path: config.path,
1740
+ loader: componentDefinitionObject.loader,
1741
+ name: config.name,
1742
+ data: config.data,
1743
+ useAsDefault: config.useAsDefault
1744
+ });
1745
+ } else {
1746
+ throw new exceptions_1.BaseException("Invalid component type \"" + componentDefinitionObject.type + "\". Valid types are \"constructor\" and \"loader\".");
1747
+ }
1748
+ }
1749
+ return new route_config_decorator_1.Route(config);
1750
+ }
1751
+ if (config.redirectTo) {
1752
+ return new route_config_decorator_1.Redirect({
1753
+ path: config.path,
1754
+ redirectTo: config.redirectTo
1755
+ });
1756
+ }
1757
+ return config;
1758
+ }
1759
+ exports.normalizeRouteConfig = normalizeRouteConfig;
1760
+ function wrapLoaderToReconfigureRegistry(loader, registry) {
1761
+ return function() {
1762
+ return loader().then(function(componentType) {
1763
+ registry.configFromComponent(componentType);
1764
+ return componentType;
1765
+ });
1766
+ };
1767
+ }
1768
+ function assertComponentExists(component, path) {
1769
+ if (!lang_1.isType(component)) {
1770
+ throw new exceptions_1.BaseException("Component for route \"" + path + "\" is not defined, or is not a class.");
1771
+ }
1772
+ }
1773
+ exports.assertComponentExists = assertComponentExists;
1774
+ global.define = __define;
1775
+ return module.exports;
1776
+ });
1777
+
1778
+ System.register("angular2/src/router/location", ["angular2/src/router/location_strategy", "angular2/src/facade/async", "angular2/core"], true, function(require, exports, module) {
1779
+ var global = System.global,
1780
+ __define = global.define;
1781
+ global.define = undefined;
1782
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
1783
+ var c = arguments.length,
1784
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
1785
+ d;
1786
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1787
+ r = Reflect.decorate(decorators, target, key, desc);
1788
+ else
1789
+ for (var i = decorators.length - 1; i >= 0; i--)
1790
+ if (d = decorators[i])
1791
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1792
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1793
+ };
1794
+ var __metadata = (this && this.__metadata) || function(k, v) {
1795
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1796
+ return Reflect.metadata(k, v);
1797
+ };
1798
+ var location_strategy_1 = require("angular2/src/router/location_strategy");
1799
+ var async_1 = require("angular2/src/facade/async");
1800
+ var core_1 = require("angular2/core");
1801
+ var Location = (function() {
1802
+ function Location(platformStrategy) {
1803
+ var _this = this;
1804
+ this.platformStrategy = platformStrategy;
1805
+ this._subject = new async_1.EventEmitter();
1806
+ var browserBaseHref = this.platformStrategy.getBaseHref();
1807
+ this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
1808
+ this.platformStrategy.onPopState(function(ev) {
1809
+ async_1.ObservableWrapper.callEmit(_this._subject, {
1810
+ 'url': _this.path(),
1811
+ 'pop': true,
1812
+ 'type': ev.type
1813
+ });
1814
+ });
1815
+ }
1816
+ Location.prototype.path = function() {
1817
+ return this.normalize(this.platformStrategy.path());
1818
+ };
1819
+ Location.prototype.normalize = function(url) {
1820
+ return stripTrailingSlash(_stripBaseHref(this._baseHref, stripIndexHtml(url)));
1821
+ };
1822
+ Location.prototype.prepareExternalUrl = function(url) {
1823
+ if (url.length > 0 && !url.startsWith('/')) {
1824
+ url = '/' + url;
1825
+ }
1826
+ return this.platformStrategy.prepareExternalUrl(url);
1827
+ };
1828
+ Location.prototype.go = function(path, query) {
1829
+ if (query === void 0) {
1830
+ query = '';
1831
+ }
1832
+ this.platformStrategy.pushState(null, '', path, query);
1833
+ };
1834
+ Location.prototype.replaceState = function(path, query) {
1835
+ if (query === void 0) {
1836
+ query = '';
1837
+ }
1838
+ this.platformStrategy.replaceState(null, '', path, query);
1839
+ };
1840
+ Location.prototype.forward = function() {
1841
+ this.platformStrategy.forward();
1842
+ };
1843
+ Location.prototype.back = function() {
1844
+ this.platformStrategy.back();
1845
+ };
1846
+ Location.prototype.subscribe = function(onNext, onThrow, onReturn) {
1847
+ if (onThrow === void 0) {
1848
+ onThrow = null;
1849
+ }
1850
+ if (onReturn === void 0) {
1851
+ onReturn = null;
1852
+ }
1853
+ return async_1.ObservableWrapper.subscribe(this._subject, onNext, onThrow, onReturn);
1854
+ };
1855
+ Location = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [location_strategy_1.LocationStrategy])], Location);
1856
+ return Location;
1857
+ })();
1858
+ exports.Location = Location;
1859
+ function _stripBaseHref(baseHref, url) {
1860
+ if (baseHref.length > 0 && url.startsWith(baseHref)) {
1861
+ return url.substring(baseHref.length);
1862
+ }
1863
+ return url;
1864
+ }
1865
+ function stripIndexHtml(url) {
1866
+ if (/\/index.html$/g.test(url)) {
1867
+ return url.substring(0, url.length - 11);
1868
+ }
1869
+ return url;
1870
+ }
1871
+ function stripTrailingSlash(url) {
1872
+ if (/\/$/g.test(url)) {
1873
+ url = url.substring(0, url.length - 1);
1874
+ }
1875
+ return url;
1876
+ }
1877
+ global.define = __define;
1878
+ return module.exports;
1879
+ });
1880
+
1881
+ System.register("angular2/src/router/route_lifecycle_reflector", ["angular2/src/facade/lang", "angular2/src/router/lifecycle_annotations_impl", "angular2/src/core/reflection/reflection"], true, function(require, exports, module) {
1882
+ var global = System.global,
1883
+ __define = global.define;
1884
+ global.define = undefined;
1885
+ var lang_1 = require("angular2/src/facade/lang");
1886
+ var lifecycle_annotations_impl_1 = require("angular2/src/router/lifecycle_annotations_impl");
1887
+ var reflection_1 = require("angular2/src/core/reflection/reflection");
1888
+ function hasLifecycleHook(e, type) {
1889
+ if (!(type instanceof lang_1.Type))
1890
+ return false;
1891
+ return e.name in type.prototype;
1892
+ }
1893
+ exports.hasLifecycleHook = hasLifecycleHook;
1894
+ function getCanActivateHook(type) {
1895
+ var annotations = reflection_1.reflector.annotations(type);
1896
+ for (var i = 0; i < annotations.length; i += 1) {
1897
+ var annotation = annotations[i];
1898
+ if (annotation instanceof lifecycle_annotations_impl_1.CanActivate) {
1899
+ return annotation.fn;
1900
+ }
1901
+ }
1902
+ return null;
1903
+ }
1904
+ exports.getCanActivateHook = getCanActivateHook;
1905
+ global.define = __define;
1906
+ return module.exports;
1907
+ });
1908
+
1909
+ System.register("angular2/src/router/router_outlet", ["angular2/src/facade/async", "angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/core", "angular2/src/router/router", "angular2/src/router/instruction", "angular2/src/router/lifecycle_annotations", "angular2/src/router/route_lifecycle_reflector"], true, function(require, exports, module) {
1910
+ var global = System.global,
1911
+ __define = global.define;
1912
+ global.define = undefined;
1913
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
1914
+ var c = arguments.length,
1915
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
1916
+ d;
1917
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1918
+ r = Reflect.decorate(decorators, target, key, desc);
1919
+ else
1920
+ for (var i = decorators.length - 1; i >= 0; i--)
1921
+ if (d = decorators[i])
1922
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1923
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1924
+ };
1925
+ var __metadata = (this && this.__metadata) || function(k, v) {
1926
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1927
+ return Reflect.metadata(k, v);
1928
+ };
1929
+ var __param = (this && this.__param) || function(paramIndex, decorator) {
1930
+ return function(target, key) {
1931
+ decorator(target, key, paramIndex);
1932
+ };
1933
+ };
1934
+ var async_1 = require("angular2/src/facade/async");
1935
+ var collection_1 = require("angular2/src/facade/collection");
1936
+ var lang_1 = require("angular2/src/facade/lang");
1937
+ var exceptions_1 = require("angular2/src/facade/exceptions");
1938
+ var core_1 = require("angular2/core");
1939
+ var routerMod = require("angular2/src/router/router");
1940
+ var instruction_1 = require("angular2/src/router/instruction");
1941
+ var hookMod = require("angular2/src/router/lifecycle_annotations");
1942
+ var route_lifecycle_reflector_1 = require("angular2/src/router/route_lifecycle_reflector");
1943
+ var _resolveToTrue = async_1.PromiseWrapper.resolve(true);
1944
+ var RouterOutlet = (function() {
1945
+ function RouterOutlet(_elementRef, _loader, _parentRouter, nameAttr) {
1946
+ this._elementRef = _elementRef;
1947
+ this._loader = _loader;
1948
+ this._parentRouter = _parentRouter;
1949
+ this.name = null;
1950
+ this._componentRef = null;
1951
+ this._currentInstruction = null;
1952
+ if (lang_1.isPresent(nameAttr)) {
1953
+ this.name = nameAttr;
1954
+ this._parentRouter.registerAuxOutlet(this);
1955
+ } else {
1956
+ this._parentRouter.registerPrimaryOutlet(this);
1957
+ }
1958
+ }
1959
+ RouterOutlet.prototype.activate = function(nextInstruction) {
1960
+ var _this = this;
1961
+ var previousInstruction = this._currentInstruction;
1962
+ this._currentInstruction = nextInstruction;
1963
+ var componentType = nextInstruction.componentType;
1964
+ var childRouter = this._parentRouter.childRouter(componentType);
1965
+ var providers = core_1.Injector.resolve([core_1.provide(instruction_1.RouteData, {useValue: nextInstruction.routeData}), core_1.provide(instruction_1.RouteParams, {useValue: new instruction_1.RouteParams(nextInstruction.params)}), core_1.provide(routerMod.Router, {useValue: childRouter})]);
1966
+ return this._loader.loadNextToLocation(componentType, this._elementRef, providers).then(function(componentRef) {
1967
+ _this._componentRef = componentRef;
1968
+ if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnActivate, componentType)) {
1969
+ return _this._componentRef.instance.routerOnActivate(nextInstruction, previousInstruction);
1970
+ }
1971
+ });
1972
+ };
1973
+ RouterOutlet.prototype.reuse = function(nextInstruction) {
1974
+ var previousInstruction = this._currentInstruction;
1975
+ this._currentInstruction = nextInstruction;
1976
+ if (lang_1.isBlank(this._componentRef)) {
1977
+ throw new exceptions_1.BaseException("Cannot reuse an outlet that does not contain a component.");
1978
+ }
1979
+ return async_1.PromiseWrapper.resolve(route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnReuse, this._currentInstruction.componentType) ? this._componentRef.instance.routerOnReuse(nextInstruction, previousInstruction) : true);
1980
+ };
1981
+ RouterOutlet.prototype.deactivate = function(nextInstruction) {
1982
+ var _this = this;
1983
+ var next = _resolveToTrue;
1984
+ if (lang_1.isPresent(this._componentRef) && lang_1.isPresent(this._currentInstruction) && route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnDeactivate, this._currentInstruction.componentType)) {
1985
+ next = async_1.PromiseWrapper.resolve(this._componentRef.instance.routerOnDeactivate(nextInstruction, this._currentInstruction));
1986
+ }
1987
+ return next.then(function(_) {
1988
+ if (lang_1.isPresent(_this._componentRef)) {
1989
+ _this._componentRef.dispose();
1990
+ _this._componentRef = null;
1991
+ }
1992
+ });
1993
+ };
1994
+ RouterOutlet.prototype.routerCanDeactivate = function(nextInstruction) {
1995
+ if (lang_1.isBlank(this._currentInstruction)) {
1996
+ return _resolveToTrue;
1997
+ }
1998
+ if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerCanDeactivate, this._currentInstruction.componentType)) {
1999
+ return async_1.PromiseWrapper.resolve(this._componentRef.instance.routerCanDeactivate(nextInstruction, this._currentInstruction));
2000
+ }
2001
+ return _resolveToTrue;
2002
+ };
2003
+ RouterOutlet.prototype.routerCanReuse = function(nextInstruction) {
2004
+ var result;
2005
+ if (lang_1.isBlank(this._currentInstruction) || this._currentInstruction.componentType != nextInstruction.componentType) {
2006
+ result = false;
2007
+ } else if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerCanReuse, this._currentInstruction.componentType)) {
2008
+ result = this._componentRef.instance.routerCanReuse(nextInstruction, this._currentInstruction);
2009
+ } else {
2010
+ result = nextInstruction == this._currentInstruction || (lang_1.isPresent(nextInstruction.params) && lang_1.isPresent(this._currentInstruction.params) && collection_1.StringMapWrapper.equals(nextInstruction.params, this._currentInstruction.params));
2011
+ }
2012
+ return async_1.PromiseWrapper.resolve(result);
2013
+ };
2014
+ RouterOutlet = __decorate([core_1.Directive({selector: 'router-outlet'}), __param(3, core_1.Attribute('name')), __metadata('design:paramtypes', [core_1.ElementRef, core_1.DynamicComponentLoader, routerMod.Router, String])], RouterOutlet);
2015
+ return RouterOutlet;
2016
+ })();
2017
+ exports.RouterOutlet = RouterOutlet;
2018
+ global.define = __define;
2019
+ return module.exports;
2020
+ });
2021
+
2022
+ System.register("angular2/src/router/browser_platform_location", ["angular2/core", "angular2/src/router/platform_location", "angular2/src/platform/dom/dom_adapter"], true, function(require, exports, module) {
2023
+ var global = System.global,
2024
+ __define = global.define;
2025
+ global.define = undefined;
2026
+ var __extends = (this && this.__extends) || function(d, b) {
2027
+ for (var p in b)
2028
+ if (b.hasOwnProperty(p))
2029
+ d[p] = b[p];
2030
+ function __() {
2031
+ this.constructor = d;
2032
+ }
2033
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2034
+ };
2035
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
2036
+ var c = arguments.length,
2037
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
2038
+ d;
2039
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2040
+ r = Reflect.decorate(decorators, target, key, desc);
2041
+ else
2042
+ for (var i = decorators.length - 1; i >= 0; i--)
2043
+ if (d = decorators[i])
2044
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2045
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2046
+ };
2047
+ var __metadata = (this && this.__metadata) || function(k, v) {
2048
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2049
+ return Reflect.metadata(k, v);
2050
+ };
2051
+ var core_1 = require("angular2/core");
2052
+ var platform_location_1 = require("angular2/src/router/platform_location");
2053
+ var dom_adapter_1 = require("angular2/src/platform/dom/dom_adapter");
2054
+ var BrowserPlatformLocation = (function(_super) {
2055
+ __extends(BrowserPlatformLocation, _super);
2056
+ function BrowserPlatformLocation() {
2057
+ _super.call(this);
2058
+ this._init();
2059
+ }
2060
+ BrowserPlatformLocation.prototype._init = function() {
2061
+ this._location = dom_adapter_1.DOM.getLocation();
2062
+ this._history = dom_adapter_1.DOM.getHistory();
2063
+ };
2064
+ Object.defineProperty(BrowserPlatformLocation.prototype, "location", {
2065
+ get: function() {
2066
+ return this._location;
2067
+ },
2068
+ enumerable: true,
2069
+ configurable: true
2070
+ });
2071
+ BrowserPlatformLocation.prototype.getBaseHrefFromDOM = function() {
2072
+ return dom_adapter_1.DOM.getBaseHref();
2073
+ };
2074
+ BrowserPlatformLocation.prototype.onPopState = function(fn) {
2075
+ dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('popstate', fn, false);
2076
+ };
2077
+ BrowserPlatformLocation.prototype.onHashChange = function(fn) {
2078
+ dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('hashchange', fn, false);
2079
+ };
2080
+ Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
2081
+ get: function() {
2082
+ return this._location.pathname;
2083
+ },
2084
+ set: function(newPath) {
2085
+ this._location.pathname = newPath;
2086
+ },
2087
+ enumerable: true,
2088
+ configurable: true
2089
+ });
2090
+ Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
2091
+ get: function() {
2092
+ return this._location.search;
2093
+ },
2094
+ enumerable: true,
2095
+ configurable: true
2096
+ });
2097
+ Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
2098
+ get: function() {
2099
+ return this._location.hash;
2100
+ },
2101
+ enumerable: true,
2102
+ configurable: true
2103
+ });
2104
+ BrowserPlatformLocation.prototype.pushState = function(state, title, url) {
2105
+ this._history.pushState(state, title, url);
2106
+ };
2107
+ BrowserPlatformLocation.prototype.replaceState = function(state, title, url) {
2108
+ this._history.replaceState(state, title, url);
2109
+ };
2110
+ BrowserPlatformLocation.prototype.forward = function() {
2111
+ this._history.forward();
2112
+ };
2113
+ BrowserPlatformLocation.prototype.back = function() {
2114
+ this._history.back();
2115
+ };
2116
+ BrowserPlatformLocation = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [])], BrowserPlatformLocation);
2117
+ return BrowserPlatformLocation;
2118
+ })(platform_location_1.PlatformLocation);
2119
+ exports.BrowserPlatformLocation = BrowserPlatformLocation;
2120
+ global.define = __define;
2121
+ return module.exports;
2122
+ });
2123
+
2124
+ System.register("angular2/src/router/route_recognizer", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/promise", "angular2/src/facade/collection", "angular2/src/router/instruction", "angular2/src/router/path_recognizer"], true, function(require, exports, module) {
2125
+ var global = System.global,
2126
+ __define = global.define;
2127
+ global.define = undefined;
2128
+ var __extends = (this && this.__extends) || function(d, b) {
2129
+ for (var p in b)
2130
+ if (b.hasOwnProperty(p))
2131
+ d[p] = b[p];
2132
+ function __() {
2133
+ this.constructor = d;
2134
+ }
2135
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2136
+ };
2137
+ var lang_1 = require("angular2/src/facade/lang");
2138
+ var exceptions_1 = require("angular2/src/facade/exceptions");
2139
+ var promise_1 = require("angular2/src/facade/promise");
2140
+ var collection_1 = require("angular2/src/facade/collection");
2141
+ var instruction_1 = require("angular2/src/router/instruction");
2142
+ var path_recognizer_1 = require("angular2/src/router/path_recognizer");
2143
+ var RouteMatch = (function() {
2144
+ function RouteMatch() {}
2145
+ return RouteMatch;
2146
+ })();
2147
+ exports.RouteMatch = RouteMatch;
2148
+ var PathMatch = (function(_super) {
2149
+ __extends(PathMatch, _super);
2150
+ function PathMatch(instruction, remaining, remainingAux) {
2151
+ _super.call(this);
2152
+ this.instruction = instruction;
2153
+ this.remaining = remaining;
2154
+ this.remainingAux = remainingAux;
2155
+ }
2156
+ return PathMatch;
2157
+ })(RouteMatch);
2158
+ exports.PathMatch = PathMatch;
2159
+ var RedirectMatch = (function(_super) {
2160
+ __extends(RedirectMatch, _super);
2161
+ function RedirectMatch(redirectTo, specificity) {
2162
+ _super.call(this);
2163
+ this.redirectTo = redirectTo;
2164
+ this.specificity = specificity;
2165
+ }
2166
+ return RedirectMatch;
2167
+ })(RouteMatch);
2168
+ exports.RedirectMatch = RedirectMatch;
2169
+ var RedirectRecognizer = (function() {
2170
+ function RedirectRecognizer(path, redirectTo) {
2171
+ this.path = path;
2172
+ this.redirectTo = redirectTo;
2173
+ this._pathRecognizer = new path_recognizer_1.PathRecognizer(path);
2174
+ this.hash = this._pathRecognizer.hash;
2175
+ }
2176
+ RedirectRecognizer.prototype.recognize = function(beginningSegment) {
2177
+ var match = null;
2178
+ if (lang_1.isPresent(this._pathRecognizer.recognize(beginningSegment))) {
2179
+ match = new RedirectMatch(this.redirectTo, this._pathRecognizer.specificity);
2180
+ }
2181
+ return promise_1.PromiseWrapper.resolve(match);
2182
+ };
2183
+ RedirectRecognizer.prototype.generate = function(params) {
2184
+ throw new exceptions_1.BaseException("Tried to generate a redirect.");
2185
+ };
2186
+ return RedirectRecognizer;
2187
+ })();
2188
+ exports.RedirectRecognizer = RedirectRecognizer;
2189
+ var RouteRecognizer = (function() {
2190
+ function RouteRecognizer(path, handler) {
2191
+ this.path = path;
2192
+ this.handler = handler;
2193
+ this.terminal = true;
2194
+ this._cache = new collection_1.Map();
2195
+ this._pathRecognizer = new path_recognizer_1.PathRecognizer(path);
2196
+ this.specificity = this._pathRecognizer.specificity;
2197
+ this.hash = this._pathRecognizer.hash;
2198
+ this.terminal = this._pathRecognizer.terminal;
2199
+ }
2200
+ RouteRecognizer.prototype.recognize = function(beginningSegment) {
2201
+ var _this = this;
2202
+ var res = this._pathRecognizer.recognize(beginningSegment);
2203
+ if (lang_1.isBlank(res)) {
2204
+ return null;
2205
+ }
2206
+ return this.handler.resolveComponentType().then(function(_) {
2207
+ var componentInstruction = _this._getInstruction(res['urlPath'], res['urlParams'], res['allParams']);
2208
+ return new PathMatch(componentInstruction, res['nextSegment'], res['auxiliary']);
2209
+ });
2210
+ };
2211
+ RouteRecognizer.prototype.generate = function(params) {
2212
+ var generated = this._pathRecognizer.generate(params);
2213
+ var urlPath = generated['urlPath'];
2214
+ var urlParams = generated['urlParams'];
2215
+ return this._getInstruction(urlPath, urlParams, params);
2216
+ };
2217
+ RouteRecognizer.prototype.generateComponentPathValues = function(params) {
2218
+ return this._pathRecognizer.generate(params);
2219
+ };
2220
+ RouteRecognizer.prototype._getInstruction = function(urlPath, urlParams, params) {
2221
+ if (lang_1.isBlank(this.handler.componentType)) {
2222
+ throw new exceptions_1.BaseException("Tried to get instruction before the type was loaded.");
2223
+ }
2224
+ var hashKey = urlPath + '?' + urlParams.join('?');
2225
+ if (this._cache.has(hashKey)) {
2226
+ return this._cache.get(hashKey);
2227
+ }
2228
+ var instruction = new instruction_1.ComponentInstruction(urlPath, urlParams, this.handler.data, this.handler.componentType, this.terminal, this.specificity, params);
2229
+ this._cache.set(hashKey, instruction);
2230
+ return instruction;
2231
+ };
2232
+ return RouteRecognizer;
2233
+ })();
2234
+ exports.RouteRecognizer = RouteRecognizer;
2235
+ global.define = __define;
2236
+ return module.exports;
2237
+ });
2238
+
2239
+ System.register("angular2/src/router/router_providers", ["angular2/router", "angular2/core", "angular2/src/facade/lang", "angular2/src/router/browser_platform_location", "angular2/src/router/platform_location"], true, function(require, exports, module) {
2240
+ var global = System.global,
2241
+ __define = global.define;
2242
+ global.define = undefined;
2243
+ var router_1 = require("angular2/router");
2244
+ var core_1 = require("angular2/core");
2245
+ var lang_1 = require("angular2/src/facade/lang");
2246
+ var browser_platform_location_1 = require("angular2/src/router/browser_platform_location");
2247
+ var platform_location_1 = require("angular2/src/router/platform_location");
2248
+ exports.ROUTER_PROVIDERS = lang_1.CONST_EXPR([router_1.ROUTER_PROVIDERS_COMMON, lang_1.CONST_EXPR(new core_1.Provider(platform_location_1.PlatformLocation, {useClass: browser_platform_location_1.BrowserPlatformLocation}))]);
2249
+ exports.ROUTER_BINDINGS = exports.ROUTER_PROVIDERS;
2250
+ global.define = __define;
2251
+ return module.exports;
2252
+ });
2253
+
2254
+ System.register("angular2/src/router/route_registry", ["angular2/src/facade/collection", "angular2/src/facade/async", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/core/reflection/reflection", "angular2/core", "angular2/src/router/route_config_impl", "angular2/src/router/route_recognizer", "angular2/src/router/component_recognizer", "angular2/src/router/instruction", "angular2/src/router/route_config_nomalizer", "angular2/src/router/url_parser"], true, function(require, exports, module) {
2255
+ var global = System.global,
2256
+ __define = global.define;
2257
+ global.define = undefined;
2258
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
2259
+ var c = arguments.length,
2260
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
2261
+ d;
2262
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2263
+ r = Reflect.decorate(decorators, target, key, desc);
2264
+ else
2265
+ for (var i = decorators.length - 1; i >= 0; i--)
2266
+ if (d = decorators[i])
2267
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2268
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2269
+ };
2270
+ var __metadata = (this && this.__metadata) || function(k, v) {
2271
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2272
+ return Reflect.metadata(k, v);
2273
+ };
2274
+ var __param = (this && this.__param) || function(paramIndex, decorator) {
2275
+ return function(target, key) {
2276
+ decorator(target, key, paramIndex);
2277
+ };
2278
+ };
2279
+ var collection_1 = require("angular2/src/facade/collection");
2280
+ var async_1 = require("angular2/src/facade/async");
2281
+ var lang_1 = require("angular2/src/facade/lang");
2282
+ var exceptions_1 = require("angular2/src/facade/exceptions");
2283
+ var reflection_1 = require("angular2/src/core/reflection/reflection");
2284
+ var core_1 = require("angular2/core");
2285
+ var route_config_impl_1 = require("angular2/src/router/route_config_impl");
2286
+ var route_recognizer_1 = require("angular2/src/router/route_recognizer");
2287
+ var component_recognizer_1 = require("angular2/src/router/component_recognizer");
2288
+ var instruction_1 = require("angular2/src/router/instruction");
2289
+ var route_config_nomalizer_1 = require("angular2/src/router/route_config_nomalizer");
2290
+ var url_parser_1 = require("angular2/src/router/url_parser");
2291
+ var _resolveToNull = async_1.PromiseWrapper.resolve(null);
2292
+ exports.ROUTER_PRIMARY_COMPONENT = lang_1.CONST_EXPR(new core_1.OpaqueToken('RouterPrimaryComponent'));
2293
+ var RouteRegistry = (function() {
2294
+ function RouteRegistry(_rootComponent) {
2295
+ this._rootComponent = _rootComponent;
2296
+ this._rules = new collection_1.Map();
2297
+ }
2298
+ RouteRegistry.prototype.config = function(parentComponent, config) {
2299
+ config = route_config_nomalizer_1.normalizeRouteConfig(config, this);
2300
+ if (config instanceof route_config_impl_1.Route) {
2301
+ route_config_nomalizer_1.assertComponentExists(config.component, config.path);
2302
+ } else if (config instanceof route_config_impl_1.AuxRoute) {
2303
+ route_config_nomalizer_1.assertComponentExists(config.component, config.path);
2304
+ }
2305
+ var recognizer = this._rules.get(parentComponent);
2306
+ if (lang_1.isBlank(recognizer)) {
2307
+ recognizer = new component_recognizer_1.ComponentRecognizer();
2308
+ this._rules.set(parentComponent, recognizer);
2309
+ }
2310
+ var terminal = recognizer.config(config);
2311
+ if (config instanceof route_config_impl_1.Route) {
2312
+ if (terminal) {
2313
+ assertTerminalComponent(config.component, config.path);
2314
+ } else {
2315
+ this.configFromComponent(config.component);
2316
+ }
2317
+ }
2318
+ };
2319
+ RouteRegistry.prototype.configFromComponent = function(component) {
2320
+ var _this = this;
2321
+ if (!lang_1.isType(component)) {
2322
+ return ;
2323
+ }
2324
+ if (this._rules.has(component)) {
2325
+ return ;
2326
+ }
2327
+ var annotations = reflection_1.reflector.annotations(component);
2328
+ if (lang_1.isPresent(annotations)) {
2329
+ for (var i = 0; i < annotations.length; i++) {
2330
+ var annotation = annotations[i];
2331
+ if (annotation instanceof route_config_impl_1.RouteConfig) {
2332
+ var routeCfgs = annotation.configs;
2333
+ routeCfgs.forEach(function(config) {
2334
+ return _this.config(component, config);
2335
+ });
2336
+ }
2337
+ }
2338
+ }
2339
+ };
2340
+ RouteRegistry.prototype.recognize = function(url, ancestorInstructions) {
2341
+ var parsedUrl = url_parser_1.parser.parse(url);
2342
+ return this._recognize(parsedUrl, []);
2343
+ };
2344
+ RouteRegistry.prototype._recognize = function(parsedUrl, ancestorInstructions, _aux) {
2345
+ var _this = this;
2346
+ if (_aux === void 0) {
2347
+ _aux = false;
2348
+ }
2349
+ var parentInstruction = collection_1.ListWrapper.last(ancestorInstructions);
2350
+ var parentComponent = lang_1.isPresent(parentInstruction) ? parentInstruction.component.componentType : this._rootComponent;
2351
+ var componentRecognizer = this._rules.get(parentComponent);
2352
+ if (lang_1.isBlank(componentRecognizer)) {
2353
+ return _resolveToNull;
2354
+ }
2355
+ var possibleMatches = _aux ? componentRecognizer.recognizeAuxiliary(parsedUrl) : componentRecognizer.recognize(parsedUrl);
2356
+ var matchPromises = possibleMatches.map(function(candidate) {
2357
+ return candidate.then(function(candidate) {
2358
+ if (candidate instanceof route_recognizer_1.PathMatch) {
2359
+ var auxParentInstructions = ancestorInstructions.length > 0 ? [collection_1.ListWrapper.last(ancestorInstructions)] : [];
2360
+ var auxInstructions = _this._auxRoutesToUnresolved(candidate.remainingAux, auxParentInstructions);
2361
+ var instruction = new instruction_1.ResolvedInstruction(candidate.instruction, null, auxInstructions);
2362
+ if (lang_1.isBlank(candidate.instruction) || candidate.instruction.terminal) {
2363
+ return instruction;
2364
+ }
2365
+ var newAncestorComponents = ancestorInstructions.concat([instruction]);
2366
+ return _this._recognize(candidate.remaining, newAncestorComponents).then(function(childInstruction) {
2367
+ if (lang_1.isBlank(childInstruction)) {
2368
+ return null;
2369
+ }
2370
+ if (childInstruction instanceof instruction_1.RedirectInstruction) {
2371
+ return childInstruction;
2372
+ }
2373
+ instruction.child = childInstruction;
2374
+ return instruction;
2375
+ });
2376
+ }
2377
+ if (candidate instanceof route_recognizer_1.RedirectMatch) {
2378
+ var instruction = _this.generate(candidate.redirectTo, ancestorInstructions.concat([null]));
2379
+ return new instruction_1.RedirectInstruction(instruction.component, instruction.child, instruction.auxInstruction, candidate.specificity);
2380
+ }
2381
+ });
2382
+ });
2383
+ if ((lang_1.isBlank(parsedUrl) || parsedUrl.path == '') && possibleMatches.length == 0) {
2384
+ return async_1.PromiseWrapper.resolve(this.generateDefault(parentComponent));
2385
+ }
2386
+ return async_1.PromiseWrapper.all(matchPromises).then(mostSpecific);
2387
+ };
2388
+ RouteRegistry.prototype._auxRoutesToUnresolved = function(auxRoutes, parentInstructions) {
2389
+ var _this = this;
2390
+ var unresolvedAuxInstructions = {};
2391
+ auxRoutes.forEach(function(auxUrl) {
2392
+ unresolvedAuxInstructions[auxUrl.path] = new instruction_1.UnresolvedInstruction(function() {
2393
+ return _this._recognize(auxUrl, parentInstructions, true);
2394
+ });
2395
+ });
2396
+ return unresolvedAuxInstructions;
2397
+ };
2398
+ RouteRegistry.prototype.generate = function(linkParams, ancestorInstructions, _aux) {
2399
+ if (_aux === void 0) {
2400
+ _aux = false;
2401
+ }
2402
+ var params = splitAndFlattenLinkParams(linkParams);
2403
+ var prevInstruction;
2404
+ if (collection_1.ListWrapper.first(params) == '') {
2405
+ params.shift();
2406
+ prevInstruction = collection_1.ListWrapper.first(ancestorInstructions);
2407
+ ancestorInstructions = [];
2408
+ } else {
2409
+ prevInstruction = ancestorInstructions.length > 0 ? ancestorInstructions.pop() : null;
2410
+ if (collection_1.ListWrapper.first(params) == '.') {
2411
+ params.shift();
2412
+ } else if (collection_1.ListWrapper.first(params) == '..') {
2413
+ while (collection_1.ListWrapper.first(params) == '..') {
2414
+ if (ancestorInstructions.length <= 0) {
2415
+ throw new exceptions_1.BaseException("Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" has too many \"../\" segments.");
2416
+ }
2417
+ prevInstruction = ancestorInstructions.pop();
2418
+ params = collection_1.ListWrapper.slice(params, 1);
2419
+ }
2420
+ } else {
2421
+ var routeName = collection_1.ListWrapper.first(params);
2422
+ var parentComponentType = this._rootComponent;
2423
+ var grandparentComponentType = null;
2424
+ if (ancestorInstructions.length > 1) {
2425
+ var parentComponentInstruction = ancestorInstructions[ancestorInstructions.length - 1];
2426
+ var grandComponentInstruction = ancestorInstructions[ancestorInstructions.length - 2];
2427
+ parentComponentType = parentComponentInstruction.component.componentType;
2428
+ grandparentComponentType = grandComponentInstruction.component.componentType;
2429
+ } else if (ancestorInstructions.length == 1) {
2430
+ parentComponentType = ancestorInstructions[0].component.componentType;
2431
+ grandparentComponentType = this._rootComponent;
2432
+ }
2433
+ var childRouteExists = this.hasRoute(routeName, parentComponentType);
2434
+ var parentRouteExists = lang_1.isPresent(grandparentComponentType) && this.hasRoute(routeName, grandparentComponentType);
2435
+ if (parentRouteExists && childRouteExists) {
2436
+ var msg = "Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" is ambiguous, use \"./\" or \"../\" to disambiguate.";
2437
+ throw new exceptions_1.BaseException(msg);
2438
+ }
2439
+ if (parentRouteExists) {
2440
+ prevInstruction = ancestorInstructions.pop();
2441
+ }
2442
+ }
2443
+ }
2444
+ if (params[params.length - 1] == '') {
2445
+ params.pop();
2446
+ }
2447
+ if (params.length > 0 && params[0] == '') {
2448
+ params.shift();
2449
+ }
2450
+ if (params.length < 1) {
2451
+ var msg = "Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" must include a route name.";
2452
+ throw new exceptions_1.BaseException(msg);
2453
+ }
2454
+ var generatedInstruction = this._generate(params, ancestorInstructions, prevInstruction, _aux, linkParams);
2455
+ for (var i = ancestorInstructions.length - 1; i >= 0; i--) {
2456
+ var ancestorInstruction = ancestorInstructions[i];
2457
+ if (lang_1.isBlank(ancestorInstruction)) {
2458
+ break;
2459
+ }
2460
+ generatedInstruction = ancestorInstruction.replaceChild(generatedInstruction);
2461
+ }
2462
+ return generatedInstruction;
2463
+ };
2464
+ RouteRegistry.prototype._generate = function(linkParams, ancestorInstructions, prevInstruction, _aux, _originalLink) {
2465
+ var _this = this;
2466
+ if (_aux === void 0) {
2467
+ _aux = false;
2468
+ }
2469
+ var parentComponentType = this._rootComponent;
2470
+ var componentInstruction = null;
2471
+ var auxInstructions = {};
2472
+ var parentInstruction = collection_1.ListWrapper.last(ancestorInstructions);
2473
+ if (lang_1.isPresent(parentInstruction) && lang_1.isPresent(parentInstruction.component)) {
2474
+ parentComponentType = parentInstruction.component.componentType;
2475
+ }
2476
+ if (linkParams.length == 0) {
2477
+ var defaultInstruction = this.generateDefault(parentComponentType);
2478
+ if (lang_1.isBlank(defaultInstruction)) {
2479
+ throw new exceptions_1.BaseException("Link \"" + collection_1.ListWrapper.toJSON(_originalLink) + "\" does not resolve to a terminal instruction.");
2480
+ }
2481
+ return defaultInstruction;
2482
+ }
2483
+ if (lang_1.isPresent(prevInstruction) && !_aux) {
2484
+ auxInstructions = collection_1.StringMapWrapper.merge(prevInstruction.auxInstruction, auxInstructions);
2485
+ componentInstruction = prevInstruction.component;
2486
+ }
2487
+ var componentRecognizer = this._rules.get(parentComponentType);
2488
+ if (lang_1.isBlank(componentRecognizer)) {
2489
+ throw new exceptions_1.BaseException("Component \"" + lang_1.getTypeNameForDebugging(parentComponentType) + "\" has no route config.");
2490
+ }
2491
+ var linkParamIndex = 0;
2492
+ var routeParams = {};
2493
+ if (linkParamIndex < linkParams.length && lang_1.isString(linkParams[linkParamIndex])) {
2494
+ var routeName = linkParams[linkParamIndex];
2495
+ if (routeName == '' || routeName == '.' || routeName == '..') {
2496
+ throw new exceptions_1.BaseException("\"" + routeName + "/\" is only allowed at the beginning of a link DSL.");
2497
+ }
2498
+ linkParamIndex += 1;
2499
+ if (linkParamIndex < linkParams.length) {
2500
+ var linkParam = linkParams[linkParamIndex];
2501
+ if (lang_1.isStringMap(linkParam) && !lang_1.isArray(linkParam)) {
2502
+ routeParams = linkParam;
2503
+ linkParamIndex += 1;
2504
+ }
2505
+ }
2506
+ var routeRecognizer = (_aux ? componentRecognizer.auxNames : componentRecognizer.names).get(routeName);
2507
+ if (lang_1.isBlank(routeRecognizer)) {
2508
+ throw new exceptions_1.BaseException("Component \"" + lang_1.getTypeNameForDebugging(parentComponentType) + "\" has no route named \"" + routeName + "\".");
2509
+ }
2510
+ if (lang_1.isBlank(routeRecognizer.handler.componentType)) {
2511
+ var compInstruction = routeRecognizer.generateComponentPathValues(routeParams);
2512
+ return new instruction_1.UnresolvedInstruction(function() {
2513
+ return routeRecognizer.handler.resolveComponentType().then(function(_) {
2514
+ return _this._generate(linkParams, ancestorInstructions, prevInstruction, _aux, _originalLink);
2515
+ });
2516
+ }, compInstruction['urlPath'], compInstruction['urlParams']);
2517
+ }
2518
+ componentInstruction = _aux ? componentRecognizer.generateAuxiliary(routeName, routeParams) : componentRecognizer.generate(routeName, routeParams);
2519
+ }
2520
+ while (linkParamIndex < linkParams.length && lang_1.isArray(linkParams[linkParamIndex])) {
2521
+ var auxParentInstruction = [parentInstruction];
2522
+ var auxInstruction = this._generate(linkParams[linkParamIndex], auxParentInstruction, null, true, _originalLink);
2523
+ auxInstructions[auxInstruction.component.urlPath] = auxInstruction;
2524
+ linkParamIndex += 1;
2525
+ }
2526
+ var instruction = new instruction_1.ResolvedInstruction(componentInstruction, null, auxInstructions);
2527
+ if (lang_1.isPresent(componentInstruction) && lang_1.isPresent(componentInstruction.componentType)) {
2528
+ var childInstruction = null;
2529
+ if (componentInstruction.terminal) {
2530
+ if (linkParamIndex >= linkParams.length) {}
2531
+ } else {
2532
+ var childAncestorComponents = ancestorInstructions.concat([instruction]);
2533
+ var remainingLinkParams = linkParams.slice(linkParamIndex);
2534
+ childInstruction = this._generate(remainingLinkParams, childAncestorComponents, null, false, _originalLink);
2535
+ }
2536
+ instruction.child = childInstruction;
2537
+ }
2538
+ return instruction;
2539
+ };
2540
+ RouteRegistry.prototype.hasRoute = function(name, parentComponent) {
2541
+ var componentRecognizer = this._rules.get(parentComponent);
2542
+ if (lang_1.isBlank(componentRecognizer)) {
2543
+ return false;
2544
+ }
2545
+ return componentRecognizer.hasRoute(name);
2546
+ };
2547
+ RouteRegistry.prototype.generateDefault = function(componentCursor) {
2548
+ var _this = this;
2549
+ if (lang_1.isBlank(componentCursor)) {
2550
+ return null;
2551
+ }
2552
+ var componentRecognizer = this._rules.get(componentCursor);
2553
+ if (lang_1.isBlank(componentRecognizer) || lang_1.isBlank(componentRecognizer.defaultRoute)) {
2554
+ return null;
2555
+ }
2556
+ var defaultChild = null;
2557
+ if (lang_1.isPresent(componentRecognizer.defaultRoute.handler.componentType)) {
2558
+ var componentInstruction = componentRecognizer.defaultRoute.generate({});
2559
+ if (!componentRecognizer.defaultRoute.terminal) {
2560
+ defaultChild = this.generateDefault(componentRecognizer.defaultRoute.handler.componentType);
2561
+ }
2562
+ return new instruction_1.DefaultInstruction(componentInstruction, defaultChild);
2563
+ }
2564
+ return new instruction_1.UnresolvedInstruction(function() {
2565
+ return componentRecognizer.defaultRoute.handler.resolveComponentType().then(function(_) {
2566
+ return _this.generateDefault(componentCursor);
2567
+ });
2568
+ });
2569
+ };
2570
+ RouteRegistry = __decorate([core_1.Injectable(), __param(0, core_1.Inject(exports.ROUTER_PRIMARY_COMPONENT)), __metadata('design:paramtypes', [lang_1.Type])], RouteRegistry);
2571
+ return RouteRegistry;
2572
+ })();
2573
+ exports.RouteRegistry = RouteRegistry;
2574
+ function splitAndFlattenLinkParams(linkParams) {
2575
+ return linkParams.reduce(function(accumulation, item) {
2576
+ if (lang_1.isString(item)) {
2577
+ var strItem = item;
2578
+ return accumulation.concat(strItem.split('/'));
2579
+ }
2580
+ accumulation.push(item);
2581
+ return accumulation;
2582
+ }, []);
2583
+ }
2584
+ function mostSpecific(instructions) {
2585
+ instructions = instructions.filter(function(instruction) {
2586
+ return lang_1.isPresent(instruction);
2587
+ });
2588
+ if (instructions.length == 0) {
2589
+ return null;
2590
+ }
2591
+ if (instructions.length == 1) {
2592
+ return instructions[0];
2593
+ }
2594
+ var first = instructions[0];
2595
+ var rest = instructions.slice(1);
2596
+ return rest.reduce(function(instruction, contender) {
2597
+ if (compareSpecificityStrings(contender.specificity, instruction.specificity) == -1) {
2598
+ return contender;
2599
+ }
2600
+ return instruction;
2601
+ }, first);
2602
+ }
2603
+ function compareSpecificityStrings(a, b) {
2604
+ var l = lang_1.Math.min(a.length, b.length);
2605
+ for (var i = 0; i < l; i += 1) {
2606
+ var ai = lang_1.StringWrapper.charCodeAt(a, i);
2607
+ var bi = lang_1.StringWrapper.charCodeAt(b, i);
2608
+ var difference = bi - ai;
2609
+ if (difference != 0) {
2610
+ return difference;
2611
+ }
2612
+ }
2613
+ return a.length - b.length;
2614
+ }
2615
+ function assertTerminalComponent(component, path) {
2616
+ if (!lang_1.isType(component)) {
2617
+ return ;
2618
+ }
2619
+ var annotations = reflection_1.reflector.annotations(component);
2620
+ if (lang_1.isPresent(annotations)) {
2621
+ for (var i = 0; i < annotations.length; i++) {
2622
+ var annotation = annotations[i];
2623
+ if (annotation instanceof route_config_impl_1.RouteConfig) {
2624
+ throw new exceptions_1.BaseException("Child routes are not allowed for \"" + path + "\". Use \"...\" on the parent's route path.");
2625
+ }
2626
+ }
2627
+ }
2628
+ }
2629
+ global.define = __define;
2630
+ return module.exports;
2631
+ });
2632
+
2633
+ System.register("angular2/src/router/router", ["angular2/src/facade/async", "angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/core", "angular2/src/router/route_registry", "angular2/src/router/location", "angular2/src/router/route_lifecycle_reflector"], true, function(require, exports, module) {
2634
+ var global = System.global,
2635
+ __define = global.define;
2636
+ global.define = undefined;
2637
+ var __extends = (this && this.__extends) || function(d, b) {
2638
+ for (var p in b)
2639
+ if (b.hasOwnProperty(p))
2640
+ d[p] = b[p];
2641
+ function __() {
2642
+ this.constructor = d;
2643
+ }
2644
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2645
+ };
2646
+ var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
2647
+ var c = arguments.length,
2648
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
2649
+ d;
2650
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2651
+ r = Reflect.decorate(decorators, target, key, desc);
2652
+ else
2653
+ for (var i = decorators.length - 1; i >= 0; i--)
2654
+ if (d = decorators[i])
2655
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2656
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2657
+ };
2658
+ var __metadata = (this && this.__metadata) || function(k, v) {
2659
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2660
+ return Reflect.metadata(k, v);
2661
+ };
2662
+ var __param = (this && this.__param) || function(paramIndex, decorator) {
2663
+ return function(target, key) {
2664
+ decorator(target, key, paramIndex);
2665
+ };
2666
+ };
2667
+ var async_1 = require("angular2/src/facade/async");
2668
+ var collection_1 = require("angular2/src/facade/collection");
2669
+ var lang_1 = require("angular2/src/facade/lang");
2670
+ var exceptions_1 = require("angular2/src/facade/exceptions");
2671
+ var core_1 = require("angular2/core");
2672
+ var route_registry_1 = require("angular2/src/router/route_registry");
2673
+ var location_1 = require("angular2/src/router/location");
2674
+ var route_lifecycle_reflector_1 = require("angular2/src/router/route_lifecycle_reflector");
2675
+ var _resolveToTrue = async_1.PromiseWrapper.resolve(true);
2676
+ var _resolveToFalse = async_1.PromiseWrapper.resolve(false);
2677
+ var Router = (function() {
2678
+ function Router(registry, parent, hostComponent) {
2679
+ this.registry = registry;
2680
+ this.parent = parent;
2681
+ this.hostComponent = hostComponent;
2682
+ this.navigating = false;
2683
+ this._currentInstruction = null;
2684
+ this._currentNavigation = _resolveToTrue;
2685
+ this._outlet = null;
2686
+ this._auxRouters = new collection_1.Map();
2687
+ this._subject = new async_1.EventEmitter();
2688
+ }
2689
+ Router.prototype.childRouter = function(hostComponent) {
2690
+ return this._childRouter = new ChildRouter(this, hostComponent);
2691
+ };
2692
+ Router.prototype.auxRouter = function(hostComponent) {
2693
+ return new ChildRouter(this, hostComponent);
2694
+ };
2695
+ Router.prototype.registerPrimaryOutlet = function(outlet) {
2696
+ if (lang_1.isPresent(outlet.name)) {
2697
+ throw new exceptions_1.BaseException("registerPrimaryOutlet expects to be called with an unnamed outlet.");
2698
+ }
2699
+ this._outlet = outlet;
2700
+ if (lang_1.isPresent(this._currentInstruction)) {
2701
+ return this.commit(this._currentInstruction, false);
2702
+ }
2703
+ return _resolveToTrue;
2704
+ };
2705
+ Router.prototype.registerAuxOutlet = function(outlet) {
2706
+ var outletName = outlet.name;
2707
+ if (lang_1.isBlank(outletName)) {
2708
+ throw new exceptions_1.BaseException("registerAuxOutlet expects to be called with an outlet with a name.");
2709
+ }
2710
+ var router = this.auxRouter(this.hostComponent);
2711
+ this._auxRouters.set(outletName, router);
2712
+ router._outlet = outlet;
2713
+ var auxInstruction;
2714
+ if (lang_1.isPresent(this._currentInstruction) && lang_1.isPresent(auxInstruction = this._currentInstruction.auxInstruction[outletName])) {
2715
+ return router.commit(auxInstruction);
2716
+ }
2717
+ return _resolveToTrue;
2718
+ };
2719
+ Router.prototype.isRouteActive = function(instruction) {
2720
+ var router = this;
2721
+ while (lang_1.isPresent(router.parent) && lang_1.isPresent(instruction.child)) {
2722
+ router = router.parent;
2723
+ instruction = instruction.child;
2724
+ }
2725
+ return lang_1.isPresent(this._currentInstruction) && this._currentInstruction.component == instruction.component;
2726
+ };
2727
+ Router.prototype.config = function(definitions) {
2728
+ var _this = this;
2729
+ definitions.forEach(function(routeDefinition) {
2730
+ _this.registry.config(_this.hostComponent, routeDefinition);
2731
+ });
2732
+ return this.renavigate();
2733
+ };
2734
+ Router.prototype.navigate = function(linkParams) {
2735
+ var instruction = this.generate(linkParams);
2736
+ return this.navigateByInstruction(instruction, false);
2737
+ };
2738
+ Router.prototype.navigateByUrl = function(url, _skipLocationChange) {
2739
+ var _this = this;
2740
+ if (_skipLocationChange === void 0) {
2741
+ _skipLocationChange = false;
2742
+ }
2743
+ return this._currentNavigation = this._currentNavigation.then(function(_) {
2744
+ _this.lastNavigationAttempt = url;
2745
+ _this._startNavigating();
2746
+ return _this._afterPromiseFinishNavigating(_this.recognize(url).then(function(instruction) {
2747
+ if (lang_1.isBlank(instruction)) {
2748
+ return false;
2749
+ }
2750
+ return _this._navigate(instruction, _skipLocationChange);
2751
+ }));
2752
+ });
2753
+ };
2754
+ Router.prototype.navigateByInstruction = function(instruction, _skipLocationChange) {
2755
+ var _this = this;
2756
+ if (_skipLocationChange === void 0) {
2757
+ _skipLocationChange = false;
2758
+ }
2759
+ if (lang_1.isBlank(instruction)) {
2760
+ return _resolveToFalse;
2761
+ }
2762
+ return this._currentNavigation = this._currentNavigation.then(function(_) {
2763
+ _this._startNavigating();
2764
+ return _this._afterPromiseFinishNavigating(_this._navigate(instruction, _skipLocationChange));
2765
+ });
2766
+ };
2767
+ Router.prototype._navigate = function(instruction, _skipLocationChange) {
2768
+ var _this = this;
2769
+ return this._settleInstruction(instruction).then(function(_) {
2770
+ return _this._routerCanReuse(instruction);
2771
+ }).then(function(_) {
2772
+ return _this._canActivate(instruction);
2773
+ }).then(function(result) {
2774
+ if (!result) {
2775
+ return false;
2776
+ }
2777
+ return _this._routerCanDeactivate(instruction).then(function(result) {
2778
+ if (result) {
2779
+ return _this.commit(instruction, _skipLocationChange).then(function(_) {
2780
+ _this._emitNavigationFinish(instruction.toRootUrl());
2781
+ return true;
2782
+ });
2783
+ }
2784
+ });
2785
+ });
2786
+ };
2787
+ Router.prototype._settleInstruction = function(instruction) {
2788
+ var _this = this;
2789
+ return instruction.resolveComponent().then(function(_) {
2790
+ var unsettledInstructions = [];
2791
+ if (lang_1.isPresent(instruction.component)) {
2792
+ instruction.component.reuse = false;
2793
+ }
2794
+ if (lang_1.isPresent(instruction.child)) {
2795
+ unsettledInstructions.push(_this._settleInstruction(instruction.child));
2796
+ }
2797
+ collection_1.StringMapWrapper.forEach(instruction.auxInstruction, function(instruction, _) {
2798
+ unsettledInstructions.push(_this._settleInstruction(instruction));
2799
+ });
2800
+ return async_1.PromiseWrapper.all(unsettledInstructions);
2801
+ });
2802
+ };
2803
+ Router.prototype._emitNavigationFinish = function(url) {
2804
+ async_1.ObservableWrapper.callEmit(this._subject, url);
2805
+ };
2806
+ Router.prototype._afterPromiseFinishNavigating = function(promise) {
2807
+ var _this = this;
2808
+ return async_1.PromiseWrapper.catchError(promise.then(function(_) {
2809
+ return _this._finishNavigating();
2810
+ }), function(err) {
2811
+ _this._finishNavigating();
2812
+ throw err;
2813
+ });
2814
+ };
2815
+ Router.prototype._routerCanReuse = function(instruction) {
2816
+ var _this = this;
2817
+ if (lang_1.isBlank(this._outlet)) {
2818
+ return _resolveToFalse;
2819
+ }
2820
+ if (lang_1.isBlank(instruction.component)) {
2821
+ return _resolveToTrue;
2822
+ }
2823
+ return this._outlet.routerCanReuse(instruction.component).then(function(result) {
2824
+ instruction.component.reuse = result;
2825
+ if (result && lang_1.isPresent(_this._childRouter) && lang_1.isPresent(instruction.child)) {
2826
+ return _this._childRouter._routerCanReuse(instruction.child);
2827
+ }
2828
+ });
2829
+ };
2830
+ Router.prototype._canActivate = function(nextInstruction) {
2831
+ return canActivateOne(nextInstruction, this._currentInstruction);
2832
+ };
2833
+ Router.prototype._routerCanDeactivate = function(instruction) {
2834
+ var _this = this;
2835
+ if (lang_1.isBlank(this._outlet)) {
2836
+ return _resolveToTrue;
2837
+ }
2838
+ var next;
2839
+ var childInstruction = null;
2840
+ var reuse = false;
2841
+ var componentInstruction = null;
2842
+ if (lang_1.isPresent(instruction)) {
2843
+ childInstruction = instruction.child;
2844
+ componentInstruction = instruction.component;
2845
+ reuse = lang_1.isBlank(instruction.component) || instruction.component.reuse;
2846
+ }
2847
+ if (reuse) {
2848
+ next = _resolveToTrue;
2849
+ } else {
2850
+ next = this._outlet.routerCanDeactivate(componentInstruction);
2851
+ }
2852
+ return next.then(function(result) {
2853
+ if (result == false) {
2854
+ return false;
2855
+ }
2856
+ if (lang_1.isPresent(_this._childRouter)) {
2857
+ return _this._childRouter._routerCanDeactivate(childInstruction);
2858
+ }
2859
+ return true;
2860
+ });
2861
+ };
2862
+ Router.prototype.commit = function(instruction, _skipLocationChange) {
2863
+ var _this = this;
2864
+ if (_skipLocationChange === void 0) {
2865
+ _skipLocationChange = false;
2866
+ }
2867
+ this._currentInstruction = instruction;
2868
+ var next = _resolveToTrue;
2869
+ if (lang_1.isPresent(this._outlet) && lang_1.isPresent(instruction.component)) {
2870
+ var componentInstruction = instruction.component;
2871
+ if (componentInstruction.reuse) {
2872
+ next = this._outlet.reuse(componentInstruction);
2873
+ } else {
2874
+ next = this.deactivate(instruction).then(function(_) {
2875
+ return _this._outlet.activate(componentInstruction);
2876
+ });
2877
+ }
2878
+ if (lang_1.isPresent(instruction.child)) {
2879
+ next = next.then(function(_) {
2880
+ if (lang_1.isPresent(_this._childRouter)) {
2881
+ return _this._childRouter.commit(instruction.child);
2882
+ }
2883
+ });
2884
+ }
2885
+ }
2886
+ var promises = [];
2887
+ this._auxRouters.forEach(function(router, name) {
2888
+ if (lang_1.isPresent(instruction.auxInstruction[name])) {
2889
+ promises.push(router.commit(instruction.auxInstruction[name]));
2890
+ }
2891
+ });
2892
+ return next.then(function(_) {
2893
+ return async_1.PromiseWrapper.all(promises);
2894
+ });
2895
+ };
2896
+ Router.prototype._startNavigating = function() {
2897
+ this.navigating = true;
2898
+ };
2899
+ Router.prototype._finishNavigating = function() {
2900
+ this.navigating = false;
2901
+ };
2902
+ Router.prototype.subscribe = function(onNext) {
2903
+ return async_1.ObservableWrapper.subscribe(this._subject, onNext);
2904
+ };
2905
+ Router.prototype.deactivate = function(instruction) {
2906
+ var _this = this;
2907
+ var childInstruction = null;
2908
+ var componentInstruction = null;
2909
+ if (lang_1.isPresent(instruction)) {
2910
+ childInstruction = instruction.child;
2911
+ componentInstruction = instruction.component;
2912
+ }
2913
+ var next = _resolveToTrue;
2914
+ if (lang_1.isPresent(this._childRouter)) {
2915
+ next = this._childRouter.deactivate(childInstruction);
2916
+ }
2917
+ if (lang_1.isPresent(this._outlet)) {
2918
+ next = next.then(function(_) {
2919
+ return _this._outlet.deactivate(componentInstruction);
2920
+ });
2921
+ }
2922
+ return next;
2923
+ };
2924
+ Router.prototype.recognize = function(url) {
2925
+ var ancestorComponents = this._getAncestorInstructions();
2926
+ return this.registry.recognize(url, ancestorComponents);
2927
+ };
2928
+ Router.prototype._getAncestorInstructions = function() {
2929
+ var ancestorInstructions = [this._currentInstruction];
2930
+ var ancestorRouter = this;
2931
+ while (lang_1.isPresent(ancestorRouter = ancestorRouter.parent)) {
2932
+ ancestorInstructions.unshift(ancestorRouter._currentInstruction);
2933
+ }
2934
+ return ancestorInstructions;
2935
+ };
2936
+ Router.prototype.renavigate = function() {
2937
+ if (lang_1.isBlank(this.lastNavigationAttempt)) {
2938
+ return this._currentNavigation;
2939
+ }
2940
+ return this.navigateByUrl(this.lastNavigationAttempt);
2941
+ };
2942
+ Router.prototype.generate = function(linkParams) {
2943
+ var ancestorInstructions = this._getAncestorInstructions();
2944
+ return this.registry.generate(linkParams, ancestorInstructions);
2945
+ };
2946
+ return Router;
2947
+ })();
2948
+ exports.Router = Router;
2949
+ var RootRouter = (function(_super) {
2950
+ __extends(RootRouter, _super);
2951
+ function RootRouter(registry, location, primaryComponent) {
2952
+ var _this = this;
2953
+ _super.call(this, registry, null, primaryComponent);
2954
+ this._location = location;
2955
+ this._locationSub = this._location.subscribe(function(change) {
2956
+ _this.recognize(change['url']).then(function(instruction) {
2957
+ _this.navigateByInstruction(instruction, lang_1.isPresent(change['pop'])).then(function(_) {
2958
+ if (lang_1.isPresent(change['pop']) && change['type'] != 'hashchange') {
2959
+ return ;
2960
+ }
2961
+ var emitPath = instruction.toUrlPath();
2962
+ var emitQuery = instruction.toUrlQuery();
2963
+ if (emitPath.length > 0 && emitPath[0] != '/') {
2964
+ emitPath = '/' + emitPath;
2965
+ }
2966
+ if (change['type'] == 'hashchange') {
2967
+ if (instruction.toRootUrl() != _this._location.path()) {
2968
+ _this._location.replaceState(emitPath, emitQuery);
2969
+ }
2970
+ } else {
2971
+ _this._location.go(emitPath, emitQuery);
2972
+ }
2973
+ });
2974
+ });
2975
+ });
2976
+ this.registry.configFromComponent(primaryComponent);
2977
+ this.navigateByUrl(location.path());
2978
+ }
2979
+ RootRouter.prototype.commit = function(instruction, _skipLocationChange) {
2980
+ var _this = this;
2981
+ if (_skipLocationChange === void 0) {
2982
+ _skipLocationChange = false;
2983
+ }
2984
+ var emitPath = instruction.toUrlPath();
2985
+ var emitQuery = instruction.toUrlQuery();
2986
+ if (emitPath.length > 0 && emitPath[0] != '/') {
2987
+ emitPath = '/' + emitPath;
2988
+ }
2989
+ var promise = _super.prototype.commit.call(this, instruction);
2990
+ if (!_skipLocationChange) {
2991
+ promise = promise.then(function(_) {
2992
+ _this._location.go(emitPath, emitQuery);
2993
+ });
2994
+ }
2995
+ return promise;
2996
+ };
2997
+ RootRouter.prototype.dispose = function() {
2998
+ if (lang_1.isPresent(this._locationSub)) {
2999
+ async_1.ObservableWrapper.dispose(this._locationSub);
3000
+ this._locationSub = null;
3001
+ }
3002
+ };
3003
+ RootRouter = __decorate([core_1.Injectable(), __param(2, core_1.Inject(route_registry_1.ROUTER_PRIMARY_COMPONENT)), __metadata('design:paramtypes', [route_registry_1.RouteRegistry, location_1.Location, lang_1.Type])], RootRouter);
3004
+ return RootRouter;
3005
+ })(Router);
3006
+ exports.RootRouter = RootRouter;
3007
+ var ChildRouter = (function(_super) {
3008
+ __extends(ChildRouter, _super);
3009
+ function ChildRouter(parent, hostComponent) {
3010
+ _super.call(this, parent.registry, parent, hostComponent);
3011
+ this.parent = parent;
3012
+ }
3013
+ ChildRouter.prototype.navigateByUrl = function(url, _skipLocationChange) {
3014
+ if (_skipLocationChange === void 0) {
3015
+ _skipLocationChange = false;
3016
+ }
3017
+ return this.parent.navigateByUrl(url, _skipLocationChange);
3018
+ };
3019
+ ChildRouter.prototype.navigateByInstruction = function(instruction, _skipLocationChange) {
3020
+ if (_skipLocationChange === void 0) {
3021
+ _skipLocationChange = false;
3022
+ }
3023
+ return this.parent.navigateByInstruction(instruction, _skipLocationChange);
3024
+ };
3025
+ return ChildRouter;
3026
+ })(Router);
3027
+ function canActivateOne(nextInstruction, prevInstruction) {
3028
+ var next = _resolveToTrue;
3029
+ if (lang_1.isBlank(nextInstruction.component)) {
3030
+ return next;
3031
+ }
3032
+ if (lang_1.isPresent(nextInstruction.child)) {
3033
+ next = canActivateOne(nextInstruction.child, lang_1.isPresent(prevInstruction) ? prevInstruction.child : null);
3034
+ }
3035
+ return next.then(function(result) {
3036
+ if (result == false) {
3037
+ return false;
3038
+ }
3039
+ if (nextInstruction.component.reuse) {
3040
+ return true;
3041
+ }
3042
+ var hook = route_lifecycle_reflector_1.getCanActivateHook(nextInstruction.component.componentType);
3043
+ if (lang_1.isPresent(hook)) {
3044
+ return hook(nextInstruction.component, lang_1.isPresent(prevInstruction) ? prevInstruction.component : null);
3045
+ }
3046
+ return true;
3047
+ });
3048
+ }
3049
+ global.define = __define;
3050
+ return module.exports;
3051
+ });
3052
+
3053
+ System.register("angular2/router", ["angular2/src/router/router", "angular2/src/router/router_outlet", "angular2/src/router/router_link", "angular2/src/router/instruction", "angular2/src/router/platform_location", "angular2/src/router/route_registry", "angular2/src/router/location_strategy", "angular2/src/router/hash_location_strategy", "angular2/src/router/path_location_strategy", "angular2/src/router/location", "angular2/src/router/route_config_decorator", "angular2/src/router/route_definition", "angular2/src/router/lifecycle_annotations", "angular2/src/router/instruction", "angular2/core", "angular2/src/router/router_providers_common", "angular2/src/router/router_providers", "angular2/src/router/router_outlet", "angular2/src/router/router_link", "angular2/src/facade/lang"], true, function(require, exports, module) {
3054
+ var global = System.global,
3055
+ __define = global.define;
3056
+ global.define = undefined;
3057
+ function __export(m) {
3058
+ for (var p in m)
3059
+ if (!exports.hasOwnProperty(p))
3060
+ exports[p] = m[p];
3061
+ }
3062
+ var router_1 = require("angular2/src/router/router");
3063
+ exports.Router = router_1.Router;
3064
+ var router_outlet_1 = require("angular2/src/router/router_outlet");
3065
+ exports.RouterOutlet = router_outlet_1.RouterOutlet;
3066
+ var router_link_1 = require("angular2/src/router/router_link");
3067
+ exports.RouterLink = router_link_1.RouterLink;
3068
+ var instruction_1 = require("angular2/src/router/instruction");
3069
+ exports.RouteParams = instruction_1.RouteParams;
3070
+ exports.RouteData = instruction_1.RouteData;
3071
+ var platform_location_1 = require("angular2/src/router/platform_location");
3072
+ exports.PlatformLocation = platform_location_1.PlatformLocation;
3073
+ var route_registry_1 = require("angular2/src/router/route_registry");
3074
+ exports.RouteRegistry = route_registry_1.RouteRegistry;
3075
+ exports.ROUTER_PRIMARY_COMPONENT = route_registry_1.ROUTER_PRIMARY_COMPONENT;
3076
+ var location_strategy_1 = require("angular2/src/router/location_strategy");
3077
+ exports.LocationStrategy = location_strategy_1.LocationStrategy;
3078
+ exports.APP_BASE_HREF = location_strategy_1.APP_BASE_HREF;
3079
+ var hash_location_strategy_1 = require("angular2/src/router/hash_location_strategy");
3080
+ exports.HashLocationStrategy = hash_location_strategy_1.HashLocationStrategy;
3081
+ var path_location_strategy_1 = require("angular2/src/router/path_location_strategy");
3082
+ exports.PathLocationStrategy = path_location_strategy_1.PathLocationStrategy;
3083
+ var location_1 = require("angular2/src/router/location");
3084
+ exports.Location = location_1.Location;
3085
+ __export(require("angular2/src/router/route_config_decorator"));
3086
+ __export(require("angular2/src/router/route_definition"));
3087
+ var lifecycle_annotations_1 = require("angular2/src/router/lifecycle_annotations");
3088
+ exports.CanActivate = lifecycle_annotations_1.CanActivate;
3089
+ var instruction_2 = require("angular2/src/router/instruction");
3090
+ exports.Instruction = instruction_2.Instruction;
3091
+ exports.ComponentInstruction = instruction_2.ComponentInstruction;
3092
+ var core_1 = require("angular2/core");
3093
+ exports.OpaqueToken = core_1.OpaqueToken;
3094
+ var router_providers_common_1 = require("angular2/src/router/router_providers_common");
3095
+ exports.ROUTER_PROVIDERS_COMMON = router_providers_common_1.ROUTER_PROVIDERS_COMMON;
3096
+ var router_providers_1 = require("angular2/src/router/router_providers");
3097
+ exports.ROUTER_PROVIDERS = router_providers_1.ROUTER_PROVIDERS;
3098
+ exports.ROUTER_BINDINGS = router_providers_1.ROUTER_BINDINGS;
3099
+ var router_outlet_2 = require("angular2/src/router/router_outlet");
3100
+ var router_link_2 = require("angular2/src/router/router_link");
3101
+ var lang_1 = require("angular2/src/facade/lang");
3102
+ exports.ROUTER_DIRECTIVES = lang_1.CONST_EXPR([router_outlet_2.RouterOutlet, router_link_2.RouterLink]);
3103
+ global.define = __define;
3104
+ return module.exports;
3105
+ });
3106
+
3107
+ //# sourceMappingURLDisabled=router.js.map