Project

General

Profile

1
/**
2
 * @license Angular v4.4.6
3
 * (c) 2010-2017 Google, Inc. https://angular.io/
4
 * License: MIT
5
 */
6
(function (global, factory) {
7
	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/observable/forkJoin'), require('rxjs/observable/fromPromise'), require('rxjs/operator/map'), require('@angular/platform-browser')) :
8
	typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/observable/forkJoin', 'rxjs/observable/fromPromise', 'rxjs/operator/map', '@angular/platform-browser'], factory) :
9
	(factory((global.ng = global.ng || {}, global.ng.forms = global.ng.forms || {}),global.ng.core,global.Rx.Observable,global.Rx.Observable,global.Rx.Observable.prototype,global.ng.platformBrowser));
10
}(this, (function (exports,_angular_core,rxjs_observable_forkJoin,rxjs_observable_fromPromise,rxjs_operator_map,_angular_platformBrowser) { 'use strict';
11

    
12
/*! *****************************************************************************
13
Copyright (c) Microsoft Corporation. All rights reserved.
14
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
15
this file except in compliance with the License. You may obtain a copy of the
16
License at http://www.apache.org/licenses/LICENSE-2.0
17

    
18
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
20
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
21
MERCHANTABLITY OR NON-INFRINGEMENT.
22

    
23
See the Apache Version 2.0 License for specific language governing permissions
24
and limitations under the License.
25
***************************************************************************** */
26
/* global Reflect, Promise */
27

    
28
var extendStatics = Object.setPrototypeOf ||
29
    ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30
    function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31

    
32
function __extends(d, b) {
33
    extendStatics(d, b);
34
    function __() { this.constructor = d; }
35
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
}
37

    
38
/**
39
 * @license Angular v4.4.6
40
 * (c) 2010-2017 Google, Inc. https://angular.io/
41
 * License: MIT
42
 */
43
/**
44
 * @license
45
 * Copyright Google Inc. All Rights Reserved.
46
 *
47
 * Use of this source code is governed by an MIT-style license that can be
48
 * found in the LICENSE file at https://angular.io/license
49
 */
50
/**
51
 * Base class for control directives.
52
 *
53
 * Only used internally in the forms module.
54
 *
55
 * \@stable
56
 * @abstract
57
 */
58
var AbstractControlDirective = (function () {
59
    function AbstractControlDirective() {
60
    }
61
    /**
62
     * The {\@link FormControl}, {\@link FormGroup}, or {\@link FormArray}
63
     * that backs this directive. Most properties fall through to that
64
     * instance.
65
     * @abstract
66
     * @return {?}
67
     */
68
    AbstractControlDirective.prototype.control = function () { };
69
    Object.defineProperty(AbstractControlDirective.prototype, "value", {
70
        /**
71
         * The value of the control.
72
         * @return {?}
73
         */
74
        get: function () { return this.control ? this.control.value : null; },
75
        enumerable: true,
76
        configurable: true
77
    });
78
    Object.defineProperty(AbstractControlDirective.prototype, "valid", {
79
        /**
80
         * A control is `valid` when its `status === VALID`.
81
         *
82
         * In order to have this status, the control must have passed all its
83
         * validation checks.
84
         * @return {?}
85
         */
86
        get: function () { return this.control ? this.control.valid : null; },
87
        enumerable: true,
88
        configurable: true
89
    });
90
    Object.defineProperty(AbstractControlDirective.prototype, "invalid", {
91
        /**
92
         * A control is `invalid` when its `status === INVALID`.
93
         *
94
         * In order to have this status, the control must have failed
95
         * at least one of its validation checks.
96
         * @return {?}
97
         */
98
        get: function () { return this.control ? this.control.invalid : null; },
99
        enumerable: true,
100
        configurable: true
101
    });
102
    Object.defineProperty(AbstractControlDirective.prototype, "pending", {
103
        /**
104
         * A control is `pending` when its `status === PENDING`.
105
         *
106
         * In order to have this status, the control must be in the
107
         * middle of conducting a validation check.
108
         * @return {?}
109
         */
110
        get: function () { return this.control ? this.control.pending : null; },
111
        enumerable: true,
112
        configurable: true
113
    });
114
    Object.defineProperty(AbstractControlDirective.prototype, "disabled", {
115
        /**
116
         * A control is `disabled` when its `status === DISABLED`.
117
         *
118
         * Disabled controls are exempt from validation checks and
119
         * are not included in the aggregate value of their ancestor
120
         * controls.
121
         * @return {?}
122
         */
123
        get: function () { return this.control ? this.control.disabled : null; },
124
        enumerable: true,
125
        configurable: true
126
    });
127
    Object.defineProperty(AbstractControlDirective.prototype, "enabled", {
128
        /**
129
         * A control is `enabled` as long as its `status !== DISABLED`.
130
         *
131
         * In other words, it has a status of `VALID`, `INVALID`, or
132
         * `PENDING`.
133
         * @return {?}
134
         */
135
        get: function () { return this.control ? this.control.enabled : null; },
136
        enumerable: true,
137
        configurable: true
138
    });
139
    Object.defineProperty(AbstractControlDirective.prototype, "errors", {
140
        /**
141
         * Returns any errors generated by failing validation. If there
142
         * are no errors, it will return null.
143
         * @return {?}
144
         */
145
        get: function () { return this.control ? this.control.errors : null; },
146
        enumerable: true,
147
        configurable: true
148
    });
149
    Object.defineProperty(AbstractControlDirective.prototype, "pristine", {
150
        /**
151
         * A control is `pristine` if the user has not yet changed
152
         * the value in the UI.
153
         *
154
         * Note that programmatic changes to a control's value will
155
         * *not* mark it dirty.
156
         * @return {?}
157
         */
158
        get: function () { return this.control ? this.control.pristine : null; },
159
        enumerable: true,
160
        configurable: true
161
    });
162
    Object.defineProperty(AbstractControlDirective.prototype, "dirty", {
163
        /**
164
         * A control is `dirty` if the user has changed the value
165
         * in the UI.
166
         *
167
         * Note that programmatic changes to a control's value will
168
         * *not* mark it dirty.
169
         * @return {?}
170
         */
171
        get: function () { return this.control ? this.control.dirty : null; },
172
        enumerable: true,
173
        configurable: true
174
    });
175
    Object.defineProperty(AbstractControlDirective.prototype, "touched", {
176
        /**
177
         * A control is marked `touched` once the user has triggered
178
         * a `blur` event on it.
179
         * @return {?}
180
         */
181
        get: function () { return this.control ? this.control.touched : null; },
182
        enumerable: true,
183
        configurable: true
184
    });
185
    Object.defineProperty(AbstractControlDirective.prototype, "untouched", {
186
        /**
187
         * A control is `untouched` if the user has not yet triggered
188
         * a `blur` event on it.
189
         * @return {?}
190
         */
191
        get: function () { return this.control ? this.control.untouched : null; },
192
        enumerable: true,
193
        configurable: true
194
    });
195
    Object.defineProperty(AbstractControlDirective.prototype, "statusChanges", {
196
        /**
197
         * Emits an event every time the validation status of the control
198
         * is re-calculated.
199
         * @return {?}
200
         */
201
        get: function () {
202
            return this.control ? this.control.statusChanges : null;
203
        },
204
        enumerable: true,
205
        configurable: true
206
    });
207
    Object.defineProperty(AbstractControlDirective.prototype, "valueChanges", {
208
        /**
209
         * Emits an event every time the value of the control changes, in
210
         * the UI or programmatically.
211
         * @return {?}
212
         */
213
        get: function () {
214
            return this.control ? this.control.valueChanges : null;
215
        },
216
        enumerable: true,
217
        configurable: true
218
    });
219
    Object.defineProperty(AbstractControlDirective.prototype, "path", {
220
        /**
221
         * Returns an array that represents the path from the top-level form
222
         * to this control. Each index is the string name of the control on
223
         * that level.
224
         * @return {?}
225
         */
226
        get: function () { return null; },
227
        enumerable: true,
228
        configurable: true
229
    });
230
    /**
231
     * Resets the form control. This means by default:
232
     *
233
     * * it is marked as `pristine`
234
     * * it is marked as `untouched`
235
     * * value is set to null
236
     *
237
     * For more information, see {\@link AbstractControl}.
238
     * @param {?=} value
239
     * @return {?}
240
     */
241
    AbstractControlDirective.prototype.reset = function (value) {
242
        if (value === void 0) { value = undefined; }
243
        if (this.control)
244
            this.control.reset(value);
245
    };
246
    /**
247
     * Returns true if the control with the given path has the error specified. Otherwise
248
     * returns false.
249
     *
250
     * If no path is given, it checks for the error on the present control.
251
     * @param {?} errorCode
252
     * @param {?=} path
253
     * @return {?}
254
     */
255
    AbstractControlDirective.prototype.hasError = function (errorCode, path) {
256
        return this.control ? this.control.hasError(errorCode, path) : false;
257
    };
258
    /**
259
     * Returns error data if the control with the given path has the error specified. Otherwise
260
     * returns null or undefined.
261
     *
262
     * If no path is given, it checks for the error on the present control.
263
     * @param {?} errorCode
264
     * @param {?=} path
265
     * @return {?}
266
     */
267
    AbstractControlDirective.prototype.getError = function (errorCode, path) {
268
        return this.control ? this.control.getError(errorCode, path) : null;
269
    };
270
    return AbstractControlDirective;
271
}());
272
/**
273
 * @license
274
 * Copyright Google Inc. All Rights Reserved.
275
 *
276
 * Use of this source code is governed by an MIT-style license that can be
277
 * found in the LICENSE file at https://angular.io/license
278
 */
279
/**
280
 * A directive that contains multiple {\@link NgControl}s.
281
 *
282
 * Only used by the forms module.
283
 *
284
 * \@stable
285
 * @abstract
286
 */
287
var ControlContainer = (function (_super) {
288
    __extends(ControlContainer, _super);
289
    function ControlContainer() {
290
        return _super !== null && _super.apply(this, arguments) || this;
291
    }
292
    Object.defineProperty(ControlContainer.prototype, "formDirective", {
293
        /**
294
         * Get the form to which this container belongs.
295
         * @return {?}
296
         */
297
        get: function () { return null; },
298
        enumerable: true,
299
        configurable: true
300
    });
301
    Object.defineProperty(ControlContainer.prototype, "path", {
302
        /**
303
         * Get the path to this container.
304
         * @return {?}
305
         */
306
        get: function () { return null; },
307
        enumerable: true,
308
        configurable: true
309
    });
310
    return ControlContainer;
311
}(AbstractControlDirective));
312
/**
313
 * @license
314
 * Copyright Google Inc. All Rights Reserved.
315
 *
316
 * Use of this source code is governed by an MIT-style license that can be
317
 * found in the LICENSE file at https://angular.io/license
318
 */
319
/**
320
 * @param {?} value
321
 * @return {?}
322
 */
323
function isEmptyInputValue(value) {
324
    // we don't check for string here so it also works with arrays
325
    return value == null || value.length === 0;
326
}
327
/**
328
 * Providers for validators to be used for {\@link FormControl}s in a form.
329
 *
330
 * Provide this using `multi: true` to add validators.
331
 *
332
 * \@stable
333
 */
334
var NG_VALIDATORS = new _angular_core.InjectionToken('NgValidators');
335
/**
336
 * Providers for asynchronous validators to be used for {\@link FormControl}s
337
 * in a form.
338
 *
339
 * Provide this using `multi: true` to add validators.
340
 *
341
 * See {\@link NG_VALIDATORS} for more details.
342
 *
343
 * \@stable
344
 */
345
var NG_ASYNC_VALIDATORS = new _angular_core.InjectionToken('NgAsyncValidators');
346
var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
347
/**
348
 * Provides a set of validators used by form controls.
349
 *
350
 * A validator is a function that processes a {\@link FormControl} or collection of
351
 * controls and returns a map of errors. A null map means that validation has passed.
352
 *
353
 * ### Example
354
 *
355
 * ```typescript
356
 * var loginControl = new FormControl("", Validators.required)
357
 * ```
358
 *
359
 * \@stable
360
 */
361
var Validators = (function () {
362
    function Validators() {
363
    }
364
    /**
365
     * Validator that requires controls to have a value greater than a number.
366
     * @param {?} min
367
     * @return {?}
368
     */
369
    Validators.min = function (min) {
370
        return function (control) {
371
            if (isEmptyInputValue(control.value) || isEmptyInputValue(min)) {
372
                return null; // don't validate empty values to allow optional controls
373
            }
374
            var /** @type {?} */ value = parseFloat(control.value);
375
            // Controls with NaN values after parsing should be treated as not having a
376
            // minimum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-min
377
            return !isNaN(value) && value < min ? { 'min': { 'min': min, 'actual': control.value } } : null;
378
        };
379
    };
380
    /**
381
     * Validator that requires controls to have a value less than a number.
382
     * @param {?} max
383
     * @return {?}
384
     */
385
    Validators.max = function (max) {
386
        return function (control) {
387
            if (isEmptyInputValue(control.value) || isEmptyInputValue(max)) {
388
                return null; // don't validate empty values to allow optional controls
389
            }
390
            var /** @type {?} */ value = parseFloat(control.value);
391
            // Controls with NaN values after parsing should be treated as not having a
392
            // maximum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-max
393
            return !isNaN(value) && value > max ? { 'max': { 'max': max, 'actual': control.value } } : null;
394
        };
395
    };
396
    /**
397
     * Validator that requires controls to have a non-empty value.
398
     * @param {?} control
399
     * @return {?}
400
     */
401
    Validators.required = function (control) {
402
        return isEmptyInputValue(control.value) ? { 'required': true } : null;
403
    };
404
    /**
405
     * Validator that requires control value to be true.
406
     * @param {?} control
407
     * @return {?}
408
     */
409
    Validators.requiredTrue = function (control) {
410
        return control.value === true ? null : { 'required': true };
411
    };
412
    /**
413
     * Validator that performs email validation.
414
     * @param {?} control
415
     * @return {?}
416
     */
417
    Validators.email = function (control) {
418
        return EMAIL_REGEXP.test(control.value) ? null : { 'email': true };
419
    };
420
    /**
421
     * Validator that requires controls to have a value of a minimum length.
422
     * @param {?} minLength
423
     * @return {?}
424
     */
425
    Validators.minLength = function (minLength) {
426
        return function (control) {
427
            if (isEmptyInputValue(control.value)) {
428
                return null; // don't validate empty values to allow optional controls
429
            }
430
            var /** @type {?} */ length = control.value ? control.value.length : 0;
431
            return length < minLength ?
432
                { 'minlength': { 'requiredLength': minLength, 'actualLength': length } } :
433
                null;
434
        };
435
    };
436
    /**
437
     * Validator that requires controls to have a value of a maximum length.
438
     * @param {?} maxLength
439
     * @return {?}
440
     */
441
    Validators.maxLength = function (maxLength) {
442
        return function (control) {
443
            var /** @type {?} */ length = control.value ? control.value.length : 0;
444
            return length > maxLength ?
445
                { 'maxlength': { 'requiredLength': maxLength, 'actualLength': length } } :
446
                null;
447
        };
448
    };
449
    /**
450
     * Validator that requires a control to match a regex to its value.
451
     * @param {?} pattern
452
     * @return {?}
453
     */
454
    Validators.pattern = function (pattern) {
455
        if (!pattern)
456
            return Validators.nullValidator;
457
        var /** @type {?} */ regex;
458
        var /** @type {?} */ regexStr;
459
        if (typeof pattern === 'string') {
460
            regexStr = "^" + pattern + "$";
461
            regex = new RegExp(regexStr);
462
        }
463
        else {
464
            regexStr = pattern.toString();
465
            regex = pattern;
466
        }
467
        return function (control) {
468
            if (isEmptyInputValue(control.value)) {
469
                return null; // don't validate empty values to allow optional controls
470
            }
471
            var /** @type {?} */ value = control.value;
472
            return regex.test(value) ? null :
473
                { 'pattern': { 'requiredPattern': regexStr, 'actualValue': value } };
474
        };
475
    };
476
    /**
477
     * No-op validator.
478
     * @param {?} c
479
     * @return {?}
480
     */
481
    Validators.nullValidator = function (c) { return null; };
482
    /**
483
     * @param {?} validators
484
     * @return {?}
485
     */
486
    Validators.compose = function (validators) {
487
        if (!validators)
488
            return null;
489
        var /** @type {?} */ presentValidators = (validators.filter(isPresent));
490
        if (presentValidators.length == 0)
491
            return null;
492
        return function (control) {
493
            return _mergeErrors(_executeValidators(control, presentValidators));
494
        };
495
    };
496
    /**
497
     * @param {?} validators
498
     * @return {?}
499
     */
500
    Validators.composeAsync = function (validators) {
501
        if (!validators)
502
            return null;
503
        var /** @type {?} */ presentValidators = (validators.filter(isPresent));
504
        if (presentValidators.length == 0)
505
            return null;
506
        return function (control) {
507
            var /** @type {?} */ observables = _executeAsyncValidators(control, presentValidators).map(toObservable);
508
            return rxjs_operator_map.map.call(rxjs_observable_forkJoin.forkJoin(observables), _mergeErrors);
509
        };
510
    };
511
    return Validators;
512
}());
513
/**
514
 * @param {?} o
515
 * @return {?}
516
 */
517
function isPresent(o) {
518
    return o != null;
519
}
520
/**
521
 * @param {?} r
522
 * @return {?}
523
 */
524
function toObservable(r) {
525
    var /** @type {?} */ obs = _angular_core.ɵisPromise(r) ? rxjs_observable_fromPromise.fromPromise(r) : r;
526
    if (!(_angular_core.ɵisObservable(obs))) {
527
        throw new Error("Expected validator to return Promise or Observable.");
528
    }
529
    return obs;
530
}
531
/**
532
 * @param {?} control
533
 * @param {?} validators
534
 * @return {?}
535
 */
536
function _executeValidators(control, validators) {
537
    return validators.map(function (v) { return v(control); });
538
}
539
/**
540
 * @param {?} control
541
 * @param {?} validators
542
 * @return {?}
543
 */
544
function _executeAsyncValidators(control, validators) {
545
    return validators.map(function (v) { return v(control); });
546
}
547
/**
548
 * @param {?} arrayOfErrors
549
 * @return {?}
550
 */
551
function _mergeErrors(arrayOfErrors) {
552
    var /** @type {?} */ res = arrayOfErrors.reduce(function (res, errors) {
553
        return errors != null ? Object.assign({}, /** @type {?} */ ((res)), errors) : ((res));
554
    }, {});
555
    return Object.keys(res).length === 0 ? null : res;
556
}
557
/**
558
 * @license
559
 * Copyright Google Inc. All Rights Reserved.
560
 *
561
 * Use of this source code is governed by an MIT-style license that can be
562
 * found in the LICENSE file at https://angular.io/license
563
 */
564
/**
565
 * Used to provide a {\@link ControlValueAccessor} for form controls.
566
 *
567
 * See {\@link DefaultValueAccessor} for how to implement one.
568
 * \@stable
569
 */
570
var NG_VALUE_ACCESSOR = new _angular_core.InjectionToken('NgValueAccessor');
571
/**
572
 * @license
573
 * Copyright Google Inc. All Rights Reserved.
574
 *
575
 * Use of this source code is governed by an MIT-style license that can be
576
 * found in the LICENSE file at https://angular.io/license
577
 */
578
var CHECKBOX_VALUE_ACCESSOR = {
579
    provide: NG_VALUE_ACCESSOR,
580
    useExisting: _angular_core.forwardRef(function () { return CheckboxControlValueAccessor; }),
581
    multi: true,
582
};
583
/**
584
 * The accessor for writing a value and listening to changes on a checkbox input element.
585
 *
586
 *  ### Example
587
 *  ```
588
 *  <input type="checkbox" name="rememberLogin" ngModel>
589
 *  ```
590
 *
591
 *  \@stable
592
 */
593
var CheckboxControlValueAccessor = (function () {
594
    /**
595
     * @param {?} _renderer
596
     * @param {?} _elementRef
597
     */
598
    function CheckboxControlValueAccessor(_renderer, _elementRef) {
599
        this._renderer = _renderer;
600
        this._elementRef = _elementRef;
601
        this.onChange = function (_) { };
602
        this.onTouched = function () { };
603
    }
604
    /**
605
     * @param {?} value
606
     * @return {?}
607
     */
608
    CheckboxControlValueAccessor.prototype.writeValue = function (value) {
609
        this._renderer.setProperty(this._elementRef.nativeElement, 'checked', value);
610
    };
611
    /**
612
     * @param {?} fn
613
     * @return {?}
614
     */
615
    CheckboxControlValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; };
616
    /**
617
     * @param {?} fn
618
     * @return {?}
619
     */
620
    CheckboxControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
621
    /**
622
     * @param {?} isDisabled
623
     * @return {?}
624
     */
625
    CheckboxControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
626
        this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
627
    };
628
    return CheckboxControlValueAccessor;
629
}());
630
CheckboxControlValueAccessor.decorators = [
631
    { type: _angular_core.Directive, args: [{
632
                selector: 'input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]',
633
                host: { '(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()' },
634
                providers: [CHECKBOX_VALUE_ACCESSOR]
635
            },] },
636
];
637
/**
638
 * @nocollapse
639
 */
640
CheckboxControlValueAccessor.ctorParameters = function () { return [
641
    { type: _angular_core.Renderer2, },
642
    { type: _angular_core.ElementRef, },
643
]; };
644
/**
645
 * @license
646
 * Copyright Google Inc. All Rights Reserved.
647
 *
648
 * Use of this source code is governed by an MIT-style license that can be
649
 * found in the LICENSE file at https://angular.io/license
650
 */
651
var DEFAULT_VALUE_ACCESSOR = {
652
    provide: NG_VALUE_ACCESSOR,
653
    useExisting: _angular_core.forwardRef(function () { return DefaultValueAccessor; }),
654
    multi: true
655
};
656
/**
657
 * We must check whether the agent is Android because composition events
658
 * behave differently between iOS and Android.
659
 * @return {?}
660
 */
661
function _isAndroid() {
662
    var /** @type {?} */ userAgent = _angular_platformBrowser.ɵgetDOM() ? _angular_platformBrowser.ɵgetDOM().getUserAgent() : '';
663
    return /android (\d+)/.test(userAgent.toLowerCase());
664
}
665
/**
666
 * Turn this mode on if you want form directives to buffer IME input until compositionend
667
 * \@experimental
668
 */
669
var COMPOSITION_BUFFER_MODE = new _angular_core.InjectionToken('CompositionEventMode');
670
/**
671
 * The default accessor for writing a value and listening to changes that is used by the
672
 * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
673
 *
674
 *  ### Example
675
 *  ```
676
 *  <input type="text" name="searchQuery" ngModel>
677
 *  ```
678
 *
679
 *  \@stable
680
 */
681
var DefaultValueAccessor = (function () {
682
    /**
683
     * @param {?} _renderer
684
     * @param {?} _elementRef
685
     * @param {?} _compositionMode
686
     */
687
    function DefaultValueAccessor(_renderer, _elementRef, _compositionMode) {
688
        this._renderer = _renderer;
689
        this._elementRef = _elementRef;
690
        this._compositionMode = _compositionMode;
691
        this.onChange = function (_) { };
692
        this.onTouched = function () { };
693
        /**
694
         * Whether the user is creating a composition string (IME events).
695
         */
696
        this._composing = false;
697
        if (this._compositionMode == null) {
698
            this._compositionMode = !_isAndroid();
699
        }
700
    }
701
    /**
702
     * @param {?} value
703
     * @return {?}
704
     */
705
    DefaultValueAccessor.prototype.writeValue = function (value) {
706
        var /** @type {?} */ normalizedValue = value == null ? '' : value;
707
        this._renderer.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
708
    };
709
    /**
710
     * @param {?} fn
711
     * @return {?}
712
     */
713
    DefaultValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; };
714
    /**
715
     * @param {?} fn
716
     * @return {?}
717
     */
718
    DefaultValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
719
    /**
720
     * @param {?} isDisabled
721
     * @return {?}
722
     */
723
    DefaultValueAccessor.prototype.setDisabledState = function (isDisabled) {
724
        this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
725
    };
726
    /**
727
     * \@internal
728
     * @param {?} value
729
     * @return {?}
730
     */
731
    DefaultValueAccessor.prototype._handleInput = function (value) {
732
        if (!this._compositionMode || (this._compositionMode && !this._composing)) {
733
            this.onChange(value);
734
        }
735
    };
736
    /**
737
     * \@internal
738
     * @return {?}
739
     */
740
    DefaultValueAccessor.prototype._compositionStart = function () { this._composing = true; };
741
    /**
742
     * \@internal
743
     * @param {?} value
744
     * @return {?}
745
     */
746
    DefaultValueAccessor.prototype._compositionEnd = function (value) {
747
        this._composing = false;
748
        this._compositionMode && this.onChange(value);
749
    };
750
    return DefaultValueAccessor;
751
}());
752
DefaultValueAccessor.decorators = [
753
    { type: _angular_core.Directive, args: [{
754
                selector: 'input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]',
755
                // TODO: vsavkin replace the above selector with the one below it once
756
                // https://github.com/angular/angular/issues/3011 is implemented
757
                // selector: '[ngModel],[formControl],[formControlName]',
758
                host: {
759
                    '(input)': '_handleInput($event.target.value)',
760
                    '(blur)': 'onTouched()',
761
                    '(compositionstart)': '_compositionStart()',
762
                    '(compositionend)': '_compositionEnd($event.target.value)'
763
                },
764
                providers: [DEFAULT_VALUE_ACCESSOR]
765
            },] },
766
];
767
/**
768
 * @nocollapse
769
 */
770
DefaultValueAccessor.ctorParameters = function () { return [
771
    { type: _angular_core.Renderer2, },
772
    { type: _angular_core.ElementRef, },
773
    { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [COMPOSITION_BUFFER_MODE,] },] },
774
]; };
775
/**
776
 * @license
777
 * Copyright Google Inc. All Rights Reserved.
778
 *
779
 * Use of this source code is governed by an MIT-style license that can be
780
 * found in the LICENSE file at https://angular.io/license
781
 */
782
/**
783
 * @param {?} validator
784
 * @return {?}
785
 */
786
function normalizeValidator(validator) {
787
    if (((validator)).validate) {
788
        return function (c) { return ((validator)).validate(c); };
789
    }
790
    else {
791
        return (validator);
792
    }
793
}
794
/**
795
 * @param {?} validator
796
 * @return {?}
797
 */
798
function normalizeAsyncValidator(validator) {
799
    if (((validator)).validate) {
800
        return function (c) { return ((validator)).validate(c); };
801
    }
802
    else {
803
        return (validator);
804
    }
805
}
806
/**
807
 * @license
808
 * Copyright Google Inc. All Rights Reserved.
809
 *
810
 * Use of this source code is governed by an MIT-style license that can be
811
 * found in the LICENSE file at https://angular.io/license
812
 */
813
var NUMBER_VALUE_ACCESSOR = {
814
    provide: NG_VALUE_ACCESSOR,
815
    useExisting: _angular_core.forwardRef(function () { return NumberValueAccessor; }),
816
    multi: true
817
};
818
/**
819
 * The accessor for writing a number value and listening to changes that is used by the
820
 * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
821
 *
822
 *  ### Example
823
 *  ```
824
 *  <input type="number" [(ngModel)]="age">
825
 *  ```
826
 */
827
var NumberValueAccessor = (function () {
828
    /**
829
     * @param {?} _renderer
830
     * @param {?} _elementRef
831
     */
832
    function NumberValueAccessor(_renderer, _elementRef) {
833
        this._renderer = _renderer;
834
        this._elementRef = _elementRef;
835
        this.onChange = function (_) { };
836
        this.onTouched = function () { };
837
    }
838
    /**
839
     * @param {?} value
840
     * @return {?}
841
     */
842
    NumberValueAccessor.prototype.writeValue = function (value) {
843
        // The value needs to be normalized for IE9, otherwise it is set to 'null' when null
844
        var /** @type {?} */ normalizedValue = value == null ? '' : value;
845
        this._renderer.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
846
    };
847
    /**
848
     * @param {?} fn
849
     * @return {?}
850
     */
851
    NumberValueAccessor.prototype.registerOnChange = function (fn) {
852
        this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
853
    };
854
    /**
855
     * @param {?} fn
856
     * @return {?}
857
     */
858
    NumberValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
859
    /**
860
     * @param {?} isDisabled
861
     * @return {?}
862
     */
863
    NumberValueAccessor.prototype.setDisabledState = function (isDisabled) {
864
        this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
865
    };
866
    return NumberValueAccessor;
867
}());
868
NumberValueAccessor.decorators = [
869
    { type: _angular_core.Directive, args: [{
870
                selector: 'input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]',
871
                host: {
872
                    '(change)': 'onChange($event.target.value)',
873
                    '(input)': 'onChange($event.target.value)',
874
                    '(blur)': 'onTouched()'
875
                },
876
                providers: [NUMBER_VALUE_ACCESSOR]
877
            },] },
878
];
879
/**
880
 * @nocollapse
881
 */
882
NumberValueAccessor.ctorParameters = function () { return [
883
    { type: _angular_core.Renderer2, },
884
    { type: _angular_core.ElementRef, },
885
]; };
886
/**
887
 * @license
888
 * Copyright Google Inc. All Rights Reserved.
889
 *
890
 * Use of this source code is governed by an MIT-style license that can be
891
 * found in the LICENSE file at https://angular.io/license
892
 */
893
/**
894
 * @return {?}
895
 */
896
function unimplemented() {
897
    throw new Error('unimplemented');
898
}
899
/**
900
 * A base class that all control directive extend.
901
 * It binds a {\@link FormControl} object to a DOM element.
902
 *
903
 * Used internally by Angular forms.
904
 *
905
 * \@stable
906
 * @abstract
907
 */
908
var NgControl = (function (_super) {
909
    __extends(NgControl, _super);
910
    function NgControl() {
911
        var _this = _super.apply(this, arguments) || this;
912
        /**
913
         * \@internal
914
         */
915
        _this._parent = null;
916
        _this.name = null;
917
        _this.valueAccessor = null;
918
        /**
919
         * \@internal
920
         */
921
        _this._rawValidators = [];
922
        /**
923
         * \@internal
924
         */
925
        _this._rawAsyncValidators = [];
926
        return _this;
927
    }
928
    Object.defineProperty(NgControl.prototype, "validator", {
929
        /**
930
         * @return {?}
931
         */
932
        get: function () { return (unimplemented()); },
933
        enumerable: true,
934
        configurable: true
935
    });
936
    Object.defineProperty(NgControl.prototype, "asyncValidator", {
937
        /**
938
         * @return {?}
939
         */
940
        get: function () { return (unimplemented()); },
941
        enumerable: true,
942
        configurable: true
943
    });
944
    /**
945
     * @abstract
946
     * @param {?} newValue
947
     * @return {?}
948
     */
949
    NgControl.prototype.viewToModelUpdate = function (newValue) { };
950
    return NgControl;
951
}(AbstractControlDirective));
952
/**
953
 * @license
954
 * Copyright Google Inc. All Rights Reserved.
955
 *
956
 * Use of this source code is governed by an MIT-style license that can be
957
 * found in the LICENSE file at https://angular.io/license
958
 */
959
var RADIO_VALUE_ACCESSOR = {
960
    provide: NG_VALUE_ACCESSOR,
961
    useExisting: _angular_core.forwardRef(function () { return RadioControlValueAccessor; }),
962
    multi: true
963
};
964
/**
965
 * Internal class used by Angular to uncheck radio buttons with the matching name.
966
 */
967
var RadioControlRegistry = (function () {
968
    function RadioControlRegistry() {
969
        this._accessors = [];
970
    }
971
    /**
972
     * @param {?} control
973
     * @param {?} accessor
974
     * @return {?}
975
     */
976
    RadioControlRegistry.prototype.add = function (control, accessor) {
977
        this._accessors.push([control, accessor]);
978
    };
979
    /**
980
     * @param {?} accessor
981
     * @return {?}
982
     */
983
    RadioControlRegistry.prototype.remove = function (accessor) {
984
        for (var /** @type {?} */ i = this._accessors.length - 1; i >= 0; --i) {
985
            if (this._accessors[i][1] === accessor) {
986
                this._accessors.splice(i, 1);
987
                return;
988
            }
989
        }
990
    };
991
    /**
992
     * @param {?} accessor
993
     * @return {?}
994
     */
995
    RadioControlRegistry.prototype.select = function (accessor) {
996
        var _this = this;
997
        this._accessors.forEach(function (c) {
998
            if (_this._isSameGroup(c, accessor) && c[1] !== accessor) {
999
                c[1].fireUncheck(accessor.value);
1000
            }
1001
        });
1002
    };
1003
    /**
1004
     * @param {?} controlPair
1005
     * @param {?} accessor
1006
     * @return {?}
1007
     */
1008
    RadioControlRegistry.prototype._isSameGroup = function (controlPair, accessor) {
1009
        if (!controlPair[0].control)
1010
            return false;
1011
        return controlPair[0]._parent === accessor._control._parent &&
1012
            controlPair[1].name === accessor.name;
1013
    };
1014
    return RadioControlRegistry;
1015
}());
1016
RadioControlRegistry.decorators = [
1017
    { type: _angular_core.Injectable },
1018
];
1019
/**
1020
 * @nocollapse
1021
 */
1022
RadioControlRegistry.ctorParameters = function () { return []; };
1023
/**
1024
 * \@whatItDoes Writes radio control values and listens to radio control changes.
1025
 *
1026
 * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName}
1027
 * to keep the view synced with the {\@link FormControl} model.
1028
 *
1029
 * \@howToUse
1030
 *
1031
 * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this
1032
 * value accessor will be active on any radio control that has a form directive. You do
1033
 * **not** need to add a special selector to activate it.
1034
 *
1035
 * ### How to use radio buttons with form directives
1036
 *
1037
 * To use radio buttons in a template-driven form, you'll want to ensure that radio buttons
1038
 * in the same group have the same `name` attribute.  Radio buttons with different `name`
1039
 * attributes do not affect each other.
1040
 *
1041
 * {\@example forms/ts/radioButtons/radio_button_example.ts region='TemplateDriven'}
1042
 *
1043
 * When using radio buttons in a reactive form, radio buttons in the same group should have the
1044
 * same `formControlName`. You can also add a `name` attribute, but it's optional.
1045
 *
1046
 * {\@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'}
1047
 *
1048
 *  * **npm package**: `\@angular/forms`
1049
 *
1050
 *  \@stable
1051
 */
1052
var RadioControlValueAccessor = (function () {
1053
    /**
1054
     * @param {?} _renderer
1055
     * @param {?} _elementRef
1056
     * @param {?} _registry
1057
     * @param {?} _injector
1058
     */
1059
    function RadioControlValueAccessor(_renderer, _elementRef, _registry, _injector) {
1060
        this._renderer = _renderer;
1061
        this._elementRef = _elementRef;
1062
        this._registry = _registry;
1063
        this._injector = _injector;
1064
        this.onChange = function () { };
1065
        this.onTouched = function () { };
1066
    }
1067
    /**
1068
     * @return {?}
1069
     */
1070
    RadioControlValueAccessor.prototype.ngOnInit = function () {
1071
        this._control = this._injector.get(NgControl);
1072
        this._checkName();
1073
        this._registry.add(this._control, this);
1074
    };
1075
    /**
1076
     * @return {?}
1077
     */
1078
    RadioControlValueAccessor.prototype.ngOnDestroy = function () { this._registry.remove(this); };
1079
    /**
1080
     * @param {?} value
1081
     * @return {?}
1082
     */
1083
    RadioControlValueAccessor.prototype.writeValue = function (value) {
1084
        this._state = value === this.value;
1085
        this._renderer.setProperty(this._elementRef.nativeElement, 'checked', this._state);
1086
    };
1087
    /**
1088
     * @param {?} fn
1089
     * @return {?}
1090
     */
1091
    RadioControlValueAccessor.prototype.registerOnChange = function (fn) {
1092
        var _this = this;
1093
        this._fn = fn;
1094
        this.onChange = function () {
1095
            fn(_this.value);
1096
            _this._registry.select(_this);
1097
        };
1098
    };
1099
    /**
1100
     * @param {?} value
1101
     * @return {?}
1102
     */
1103
    RadioControlValueAccessor.prototype.fireUncheck = function (value) { this.writeValue(value); };
1104
    /**
1105
     * @param {?} fn
1106
     * @return {?}
1107
     */
1108
    RadioControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
1109
    /**
1110
     * @param {?} isDisabled
1111
     * @return {?}
1112
     */
1113
    RadioControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
1114
        this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
1115
    };
1116
    /**
1117
     * @return {?}
1118
     */
1119
    RadioControlValueAccessor.prototype._checkName = function () {
1120
        if (this.name && this.formControlName && this.name !== this.formControlName) {
1121
            this._throwNameError();
1122
        }
1123
        if (!this.name && this.formControlName)
1124
            this.name = this.formControlName;
1125
    };
1126
    /**
1127
     * @return {?}
1128
     */
1129
    RadioControlValueAccessor.prototype._throwNameError = function () {
1130
        throw new Error("\n      If you define both a name and a formControlName attribute on your radio button, their values\n      must match. Ex: <input type=\"radio\" formControlName=\"food\" name=\"food\">\n    ");
1131
    };
1132
    return RadioControlValueAccessor;
1133
}());
1134
RadioControlValueAccessor.decorators = [
1135
    { type: _angular_core.Directive, args: [{
1136
                selector: 'input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]',
1137
                host: { '(change)': 'onChange()', '(blur)': 'onTouched()' },
1138
                providers: [RADIO_VALUE_ACCESSOR]
1139
            },] },
1140
];
1141
/**
1142
 * @nocollapse
1143
 */
1144
RadioControlValueAccessor.ctorParameters = function () { return [
1145
    { type: _angular_core.Renderer2, },
1146
    { type: _angular_core.ElementRef, },
1147
    { type: RadioControlRegistry, },
1148
    { type: _angular_core.Injector, },
1149
]; };
1150
RadioControlValueAccessor.propDecorators = {
1151
    'name': [{ type: _angular_core.Input },],
1152
    'formControlName': [{ type: _angular_core.Input },],
1153
    'value': [{ type: _angular_core.Input },],
1154
};
1155
/**
1156
 * @license
1157
 * Copyright Google Inc. All Rights Reserved.
1158
 *
1159
 * Use of this source code is governed by an MIT-style license that can be
1160
 * found in the LICENSE file at https://angular.io/license
1161
 */
1162
var RANGE_VALUE_ACCESSOR = {
1163
    provide: NG_VALUE_ACCESSOR,
1164
    useExisting: _angular_core.forwardRef(function () { return RangeValueAccessor; }),
1165
    multi: true
1166
};
1167
/**
1168
 * The accessor for writing a range value and listening to changes that is used by the
1169
 * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
1170
 *
1171
 *  ### Example
1172
 *  ```
1173
 *  <input type="range" [(ngModel)]="age" >
1174
 *  ```
1175
 */
1176
var RangeValueAccessor = (function () {
1177
    /**
1178
     * @param {?} _renderer
1179
     * @param {?} _elementRef
1180
     */
1181
    function RangeValueAccessor(_renderer, _elementRef) {
1182
        this._renderer = _renderer;
1183
        this._elementRef = _elementRef;
1184
        this.onChange = function (_) { };
1185
        this.onTouched = function () { };
1186
    }
1187
    /**
1188
     * @param {?} value
1189
     * @return {?}
1190
     */
1191
    RangeValueAccessor.prototype.writeValue = function (value) {
1192
        this._renderer.setProperty(this._elementRef.nativeElement, 'value', parseFloat(value));
1193
    };
1194
    /**
1195
     * @param {?} fn
1196
     * @return {?}
1197
     */
1198
    RangeValueAccessor.prototype.registerOnChange = function (fn) {
1199
        this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
1200
    };
1201
    /**
1202
     * @param {?} fn
1203
     * @return {?}
1204
     */
1205
    RangeValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
1206
    /**
1207
     * @param {?} isDisabled
1208
     * @return {?}
1209
     */
1210
    RangeValueAccessor.prototype.setDisabledState = function (isDisabled) {
1211
        this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
1212
    };
1213
    return RangeValueAccessor;
1214
}());
1215
RangeValueAccessor.decorators = [
1216
    { type: _angular_core.Directive, args: [{
1217
                selector: 'input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]',
1218
                host: {
1219
                    '(change)': 'onChange($event.target.value)',
1220
                    '(input)': 'onChange($event.target.value)',
1221
                    '(blur)': 'onTouched()'
1222
                },
1223
                providers: [RANGE_VALUE_ACCESSOR]
1224
            },] },
1225
];
1226
/**
1227
 * @nocollapse
1228
 */
1229
RangeValueAccessor.ctorParameters = function () { return [
1230
    { type: _angular_core.Renderer2, },
1231
    { type: _angular_core.ElementRef, },
1232
]; };
1233
/**
1234
 * @license
1235
 * Copyright Google Inc. All Rights Reserved.
1236
 *
1237
 * Use of this source code is governed by an MIT-style license that can be
1238
 * found in the LICENSE file at https://angular.io/license
1239
 */
1240
var SELECT_VALUE_ACCESSOR = {
1241
    provide: NG_VALUE_ACCESSOR,
1242
    useExisting: _angular_core.forwardRef(function () { return SelectControlValueAccessor; }),
1243
    multi: true
1244
};
1245
/**
1246
 * @param {?} id
1247
 * @param {?} value
1248
 * @return {?}
1249
 */
1250
function _buildValueString(id, value) {
1251
    if (id == null)
1252
        return "" + value;
1253
    if (value && typeof value === 'object')
1254
        value = 'Object';
1255
    return (id + ": " + value).slice(0, 50);
1256
}
1257
/**
1258
 * @param {?} valueString
1259
 * @return {?}
1260
 */
1261
function _extractId(valueString) {
1262
    return valueString.split(':')[0];
1263
}
1264
/**
1265
 * \@whatItDoes Writes values and listens to changes on a select element.
1266
 *
1267
 * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName}
1268
 * to keep the view synced with the {\@link FormControl} model.
1269
 *
1270
 * \@howToUse
1271
 *
1272
 * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this
1273
 * value accessor will be active on any select control that has a form directive. You do
1274
 * **not** need to add a special selector to activate it.
1275
 *
1276
 * ### How to use select controls with form directives
1277
 *
1278
 * To use a select in a template-driven form, simply add an `ngModel` and a `name`
1279
 * attribute to the main `<select>` tag.
1280
 *
1281
 * If your option values are simple strings, you can bind to the normal `value` property
1282
 * on the option.  If your option values happen to be objects (and you'd like to save the
1283
 * selection in your form as an object), use `ngValue` instead:
1284
 *
1285
 * {\@example forms/ts/selectControl/select_control_example.ts region='Component'}
1286
 *
1287
 * In reactive forms, you'll also want to add your form directive (`formControlName` or
1288
 * `formControl`) on the main `<select>` tag. Like in the former example, you have the
1289
 * choice of binding to the  `value` or `ngValue` property on the select's options.
1290
 *
1291
 * {\@example forms/ts/reactiveSelectControl/reactive_select_control_example.ts region='Component'}
1292
 *
1293
 * ### Caveat: Option selection
1294
 *
1295
 * Angular uses object identity to select option. It's possible for the identities of items
1296
 * to change while the data does not. This can happen, for example, if the items are produced
1297
 * from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the
1298
 * second response will produce objects with different identities.
1299
 *
1300
 * To customize the default option comparison algorithm, `<select>` supports `compareWith` input.
1301
 * `compareWith` takes a **function** which has two arguments: `option1` and `option2`.
1302
 * If `compareWith` is given, Angular selects option by the return value of the function.
1303
 *
1304
 * #### Syntax
1305
 *
1306
 * ```
1307
 * <select [compareWith]="compareFn"  [(ngModel)]="selectedCountries">
1308
 *     <option *ngFor="let country of countries" [ngValue]="country">
1309
 *         {{country.name}}
1310
 *     </option>
1311
 * </select>
1312
 *
1313
 * compareFn(c1: Country, c2: Country): boolean {
1314
 *     return c1 && c2 ? c1.id === c2.id : c1 === c2;
1315
 * }
1316
 * ```
1317
 *
1318
 * Note: We listen to the 'change' event because 'input' events aren't fired
1319
 * for selects in Firefox and IE:
1320
 * https://bugzilla.mozilla.org/show_bug.cgi?id=1024350
1321
 * https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4660045/
1322
 *
1323
 * * **npm package**: `\@angular/forms`
1324
 *
1325
 * \@stable
1326
 */
1327
var SelectControlValueAccessor = (function () {
1328
    /**
1329
     * @param {?} _renderer
1330
     * @param {?} _elementRef
1331
     */
1332
    function SelectControlValueAccessor(_renderer, _elementRef) {
1333
        this._renderer = _renderer;
1334
        this._elementRef = _elementRef;
1335
        /**
1336
         * \@internal
1337
         */
1338
        this._optionMap = new Map();
1339
        /**
1340
         * \@internal
1341
         */
1342
        this._idCounter = 0;
1343
        this.onChange = function (_) { };
1344
        this.onTouched = function () { };
1345
        this._compareWith = _angular_core.ɵlooseIdentical;
1346
    }
1347
    Object.defineProperty(SelectControlValueAccessor.prototype, "compareWith", {
1348
        /**
1349
         * @param {?} fn
1350
         * @return {?}
1351
         */
1352
        set: function (fn) {
1353
            if (typeof fn !== 'function') {
1354
                throw new Error("compareWith must be a function, but received " + JSON.stringify(fn));
1355
            }
1356
            this._compareWith = fn;
1357
        },
1358
        enumerable: true,
1359
        configurable: true
1360
    });
1361
    /**
1362
     * @param {?} value
1363
     * @return {?}
1364
     */
1365
    SelectControlValueAccessor.prototype.writeValue = function (value) {
1366
        this.value = value;
1367
        var /** @type {?} */ id = this._getOptionId(value);
1368
        if (id == null) {
1369
            this._renderer.setProperty(this._elementRef.nativeElement, 'selectedIndex', -1);
1370
        }
1371
        var /** @type {?} */ valueString = _buildValueString(id, value);
1372
        this._renderer.setProperty(this._elementRef.nativeElement, 'value', valueString);
1373
    };
1374
    /**
1375
     * @param {?} fn
1376
     * @return {?}
1377
     */
1378
    SelectControlValueAccessor.prototype.registerOnChange = function (fn) {
1379
        var _this = this;
1380
        this.onChange = function (valueString) {
1381
            _this.value = _this._getOptionValue(valueString);
1382
            fn(_this.value);
1383
        };
1384
    };
1385
    /**
1386
     * @param {?} fn
1387
     * @return {?}
1388
     */
1389
    SelectControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
1390
    /**
1391
     * @param {?} isDisabled
1392
     * @return {?}
1393
     */
1394
    SelectControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
1395
        this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
1396
    };
1397
    /**
1398
     * \@internal
1399
     * @return {?}
1400
     */
1401
    SelectControlValueAccessor.prototype._registerOption = function () { return (this._idCounter++).toString(); };
1402
    /**
1403
     * \@internal
1404
     * @param {?} value
1405
     * @return {?}
1406
     */
1407
    SelectControlValueAccessor.prototype._getOptionId = function (value) {
1408
        for (var _i = 0, _a = Array.from(this._optionMap.keys()); _i < _a.length; _i++) {
1409
            var id = _a[_i];
1410
            if (this._compareWith(this._optionMap.get(id), value))
1411
                return id;
1412
        }
1413
        return null;
1414
    };
1415
    /**
1416
     * \@internal
1417
     * @param {?} valueString
1418
     * @return {?}
1419
     */
1420
    SelectControlValueAccessor.prototype._getOptionValue = function (valueString) {
1421
        var /** @type {?} */ id = _extractId(valueString);
1422
        return this._optionMap.has(id) ? this._optionMap.get(id) : valueString;
1423
    };
1424
    return SelectControlValueAccessor;
1425
}());
1426
SelectControlValueAccessor.decorators = [
1427
    { type: _angular_core.Directive, args: [{
1428
                selector: 'select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]',
1429
                host: { '(change)': 'onChange($event.target.value)', '(blur)': 'onTouched()' },
1430
                providers: [SELECT_VALUE_ACCESSOR]
1431
            },] },
1432
];
1433
/**
1434
 * @nocollapse
1435
 */
1436
SelectControlValueAccessor.ctorParameters = function () { return [
1437
    { type: _angular_core.Renderer2, },
1438
    { type: _angular_core.ElementRef, },
1439
]; };
1440
SelectControlValueAccessor.propDecorators = {
1441
    'compareWith': [{ type: _angular_core.Input },],
1442
};
1443
/**
1444
 * \@whatItDoes Marks `<option>` as dynamic, so Angular can be notified when options change.
1445
 *
1446
 * \@howToUse
1447
 *
1448
 * See docs for {\@link SelectControlValueAccessor} for usage examples.
1449
 *
1450
 * \@stable
1451
 */
1452
var NgSelectOption = (function () {
1453
    /**
1454
     * @param {?} _element
1455
     * @param {?} _renderer
1456
     * @param {?} _select
1457
     */
1458
    function NgSelectOption(_element, _renderer, _select) {
1459
        this._element = _element;
1460
        this._renderer = _renderer;
1461
        this._select = _select;
1462
        if (this._select)
1463
            this.id = this._select._registerOption();
1464
    }
1465
    Object.defineProperty(NgSelectOption.prototype, "ngValue", {
1466
        /**
1467
         * @param {?} value
1468
         * @return {?}
1469
         */
1470
        set: function (value) {
1471
            if (this._select == null)
1472
                return;
1473
            this._select._optionMap.set(this.id, value);
1474
            this._setElementValue(_buildValueString(this.id, value));
1475
            this._select.writeValue(this._select.value);
1476
        },
1477
        enumerable: true,
1478
        configurable: true
1479
    });
1480
    Object.defineProperty(NgSelectOption.prototype, "value", {
1481
        /**
1482
         * @param {?} value
1483
         * @return {?}
1484
         */
1485
        set: function (value) {
1486
            this._setElementValue(value);
1487
            if (this._select)
1488
                this._select.writeValue(this._select.value);
1489
        },
1490
        enumerable: true,
1491
        configurable: true
1492
    });
1493
    /**
1494
     * \@internal
1495
     * @param {?} value
1496
     * @return {?}
1497
     */
1498
    NgSelectOption.prototype._setElementValue = function (value) {
1499
        this._renderer.setProperty(this._element.nativeElement, 'value', value);
1500
    };
1501
    /**
1502
     * @return {?}
1503
     */
1504
    NgSelectOption.prototype.ngOnDestroy = function () {
1505
        if (this._select) {
1506
            this._select._optionMap.delete(this.id);
1507
            this._select.writeValue(this._select.value);
1508
        }
1509
    };
1510
    return NgSelectOption;
1511
}());
1512
NgSelectOption.decorators = [
1513
    { type: _angular_core.Directive, args: [{ selector: 'option' },] },
1514
];
1515
/**
1516
 * @nocollapse
1517
 */
1518
NgSelectOption.ctorParameters = function () { return [
1519
    { type: _angular_core.ElementRef, },
1520
    { type: _angular_core.Renderer2, },
1521
    { type: SelectControlValueAccessor, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host },] },
1522
]; };
1523
NgSelectOption.propDecorators = {
1524
    'ngValue': [{ type: _angular_core.Input, args: ['ngValue',] },],
1525
    'value': [{ type: _angular_core.Input, args: ['value',] },],
1526
};
1527
/**
1528
 * @license
1529
 * Copyright Google Inc. All Rights Reserved.
1530
 *
1531
 * Use of this source code is governed by an MIT-style license that can be
1532
 * found in the LICENSE file at https://angular.io/license
1533
 */
1534
var SELECT_MULTIPLE_VALUE_ACCESSOR = {
1535
    provide: NG_VALUE_ACCESSOR,
1536
    useExisting: _angular_core.forwardRef(function () { return SelectMultipleControlValueAccessor; }),
1537
    multi: true
1538
};
1539
/**
1540
 * @param {?} id
1541
 * @param {?} value
1542
 * @return {?}
1543
 */
1544
function _buildValueString$1(id, value) {
1545
    if (id == null)
1546
        return "" + value;
1547
    if (typeof value === 'string')
1548
        value = "'" + value + "'";
1549
    if (value && typeof value === 'object')
1550
        value = 'Object';
1551
    return (id + ": " + value).slice(0, 50);
1552
}
1553
/**
1554
 * @param {?} valueString
1555
 * @return {?}
1556
 */
1557
function _extractId$1(valueString) {
1558
    return valueString.split(':')[0];
1559
}
1560
/**
1561
 * The accessor for writing a value and listening to changes on a select element.
1562
 *
1563
 *  ### Caveat: Options selection
1564
 *
1565
 * Angular uses object identity to select options. It's possible for the identities of items
1566
 * to change while the data does not. This can happen, for example, if the items are produced
1567
 * from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the
1568
 * second response will produce objects with different identities.
1569
 *
1570
 * To customize the default option comparison algorithm, `<select multiple>` supports `compareWith`
1571
 * input. `compareWith` takes a **function** which has two arguments: `option1` and `option2`.
1572
 * If `compareWith` is given, Angular selects options by the return value of the function.
1573
 *
1574
 * #### Syntax
1575
 *
1576
 * ```
1577
 * <select multiple [compareWith]="compareFn"  [(ngModel)]="selectedCountries">
1578
 *     <option *ngFor="let country of countries" [ngValue]="country">
1579
 *         {{country.name}}
1580
 *     </option>
1581
 * </select>
1582
 *
1583
 * compareFn(c1: Country, c2: Country): boolean {
1584
 *     return c1 && c2 ? c1.id === c2.id : c1 === c2;
1585
 * }
1586
 * ```
1587
 *
1588
 * \@stable
1589
 */
1590
var SelectMultipleControlValueAccessor = (function () {
1591
    /**
1592
     * @param {?} _renderer
1593
     * @param {?} _elementRef
1594
     */
1595
    function SelectMultipleControlValueAccessor(_renderer, _elementRef) {
1596
        this._renderer = _renderer;
1597
        this._elementRef = _elementRef;
1598
        /**
1599
         * \@internal
1600
         */
1601
        this._optionMap = new Map();
1602
        /**
1603
         * \@internal
1604
         */
1605
        this._idCounter = 0;
1606
        this.onChange = function (_) { };
1607
        this.onTouched = function () { };
1608
        this._compareWith = _angular_core.ɵlooseIdentical;
1609
    }
1610
    Object.defineProperty(SelectMultipleControlValueAccessor.prototype, "compareWith", {
1611
        /**
1612
         * @param {?} fn
1613
         * @return {?}
1614
         */
1615
        set: function (fn) {
1616
            if (typeof fn !== 'function') {
1617
                throw new Error("compareWith must be a function, but received " + JSON.stringify(fn));
1618
            }
1619
            this._compareWith = fn;
1620
        },
1621
        enumerable: true,
1622
        configurable: true
1623
    });
1624
    /**
1625
     * @param {?} value
1626
     * @return {?}
1627
     */
1628
    SelectMultipleControlValueAccessor.prototype.writeValue = function (value) {
1629
        var _this = this;
1630
        this.value = value;
1631
        var /** @type {?} */ optionSelectedStateSetter;
1632
        if (Array.isArray(value)) {
1633
            // convert values to ids
1634
            var /** @type {?} */ ids_1 = value.map(function (v) { return _this._getOptionId(v); });
1635
            optionSelectedStateSetter = function (opt, o) { opt._setSelected(ids_1.indexOf(o.toString()) > -1); };
1636
        }
1637
        else {
1638
            optionSelectedStateSetter = function (opt, o) { opt._setSelected(false); };
1639
        }
1640
        this._optionMap.forEach(optionSelectedStateSetter);
1641
    };
1642
    /**
1643
     * @param {?} fn
1644
     * @return {?}
1645
     */
1646
    SelectMultipleControlValueAccessor.prototype.registerOnChange = function (fn) {
1647
        var _this = this;
1648
        this.onChange = function (_) {
1649
            var /** @type {?} */ selected = [];
1650
            if (_.hasOwnProperty('selectedOptions')) {
1651
                var /** @type {?} */ options = _.selectedOptions;
1652
                for (var /** @type {?} */ i = 0; i < options.length; i++) {
1653
                    var /** @type {?} */ opt = options.item(i);
1654
                    var /** @type {?} */ val = _this._getOptionValue(opt.value);
1655
                    selected.push(val);
1656
                }
1657
            }
1658
            else {
1659
                var /** @type {?} */ options = (_.options);
1660
                for (var /** @type {?} */ i = 0; i < options.length; i++) {
1661
                    var /** @type {?} */ opt = options.item(i);
1662
                    if (opt.selected) {
1663
                        var /** @type {?} */ val = _this._getOptionValue(opt.value);
1664
                        selected.push(val);
1665
                    }
1666
                }
1667
            }
1668
            _this.value = selected;
1669
            fn(selected);
1670
        };
1671
    };
1672
    /**
1673
     * @param {?} fn
1674
     * @return {?}
1675
     */
1676
    SelectMultipleControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
1677
    /**
1678
     * @param {?} isDisabled
1679
     * @return {?}
1680
     */
1681
    SelectMultipleControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
1682
        this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
1683
    };
1684
    /**
1685
     * \@internal
1686
     * @param {?} value
1687
     * @return {?}
1688
     */
1689
    SelectMultipleControlValueAccessor.prototype._registerOption = function (value) {
1690
        var /** @type {?} */ id = (this._idCounter++).toString();
1691
        this._optionMap.set(id, value);
1692
        return id;
1693
    };
1694
    /**
1695
     * \@internal
1696
     * @param {?} value
1697
     * @return {?}
1698
     */
1699
    SelectMultipleControlValueAccessor.prototype._getOptionId = function (value) {
1700
        for (var _i = 0, _a = Array.from(this._optionMap.keys()); _i < _a.length; _i++) {
1701
            var id = _a[_i];
1702
            if (this._compareWith(/** @type {?} */ ((this._optionMap.get(id)))._value, value))
1703
                return id;
1704
        }
1705
        return null;
1706
    };
1707
    /**
1708
     * \@internal
1709
     * @param {?} valueString
1710
     * @return {?}
1711
     */
1712
    SelectMultipleControlValueAccessor.prototype._getOptionValue = function (valueString) {
1713
        var /** @type {?} */ id = _extractId$1(valueString);
1714
        return this._optionMap.has(id) ? ((this._optionMap.get(id)))._value : valueString;
1715
    };
1716
    return SelectMultipleControlValueAccessor;
1717
}());
1718
SelectMultipleControlValueAccessor.decorators = [
1719
    { type: _angular_core.Directive, args: [{
1720
                selector: 'select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]',
1721
                host: { '(change)': 'onChange($event.target)', '(blur)': 'onTouched()' },
1722
                providers: [SELECT_MULTIPLE_VALUE_ACCESSOR]
1723
            },] },
1724
];
1725
/**
1726
 * @nocollapse
1727
 */
1728
SelectMultipleControlValueAccessor.ctorParameters = function () { return [
1729
    { type: _angular_core.Renderer2, },
1730
    { type: _angular_core.ElementRef, },
1731
]; };
1732
SelectMultipleControlValueAccessor.propDecorators = {
1733
    'compareWith': [{ type: _angular_core.Input },],
1734
};
1735
/**
1736
 * Marks `<option>` as dynamic, so Angular can be notified when options change.
1737
 *
1738
 * ### Example
1739
 *
1740
 * ```
1741
 * <select multiple name="city" ngModel>
1742
 *   <option *ngFor="let c of cities" [value]="c"></option>
1743
 * </select>
1744
 * ```
1745
 */
1746
var NgSelectMultipleOption = (function () {
1747
    /**
1748
     * @param {?} _element
1749
     * @param {?} _renderer
1750
     * @param {?} _select
1751
     */
1752
    function NgSelectMultipleOption(_element, _renderer, _select) {
1753
        this._element = _element;
1754
        this._renderer = _renderer;
1755
        this._select = _select;
1756
        if (this._select) {
1757
            this.id = this._select._registerOption(this);
1758
        }
1759
    }
1760
    Object.defineProperty(NgSelectMultipleOption.prototype, "ngValue", {
1761
        /**
1762
         * @param {?} value
1763
         * @return {?}
1764
         */
1765
        set: function (value) {
1766
            if (this._select == null)
1767
                return;
1768
            this._value = value;
1769
            this._setElementValue(_buildValueString$1(this.id, value));
1770
            this._select.writeValue(this._select.value);
1771
        },
1772
        enumerable: true,
1773
        configurable: true
1774
    });
1775
    Object.defineProperty(NgSelectMultipleOption.prototype, "value", {
1776
        /**
1777
         * @param {?} value
1778
         * @return {?}
1779
         */
1780
        set: function (value) {
1781
            if (this._select) {
1782
                this._value = value;
1783
                this._setElementValue(_buildValueString$1(this.id, value));
1784
                this._select.writeValue(this._select.value);
1785
            }
1786
            else {
1787
                this._setElementValue(value);
1788
            }
1789
        },
1790
        enumerable: true,
1791
        configurable: true
1792
    });
1793
    /**
1794
     * \@internal
1795
     * @param {?} value
1796
     * @return {?}
1797
     */
1798
    NgSelectMultipleOption.prototype._setElementValue = function (value) {
1799
        this._renderer.setProperty(this._element.nativeElement, 'value', value);
1800
    };
1801
    /**
1802
     * \@internal
1803
     * @param {?} selected
1804
     * @return {?}
1805
     */
1806
    NgSelectMultipleOption.prototype._setSelected = function (selected) {
1807
        this._renderer.setProperty(this._element.nativeElement, 'selected', selected);
1808
    };
1809
    /**
1810
     * @return {?}
1811
     */
1812
    NgSelectMultipleOption.prototype.ngOnDestroy = function () {
1813
        if (this._select) {
1814
            this._select._optionMap.delete(this.id);
1815
            this._select.writeValue(this._select.value);
1816
        }
1817
    };
1818
    return NgSelectMultipleOption;
1819
}());
1820
NgSelectMultipleOption.decorators = [
1821
    { type: _angular_core.Directive, args: [{ selector: 'option' },] },
1822
];
1823
/**
1824
 * @nocollapse
1825
 */
1826
NgSelectMultipleOption.ctorParameters = function () { return [
1827
    { type: _angular_core.ElementRef, },
1828
    { type: _angular_core.Renderer2, },
1829
    { type: SelectMultipleControlValueAccessor, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host },] },
1830
]; };
1831
NgSelectMultipleOption.propDecorators = {
1832
    'ngValue': [{ type: _angular_core.Input, args: ['ngValue',] },],
1833
    'value': [{ type: _angular_core.Input, args: ['value',] },],
1834
};
1835
/**
1836
 * @license
1837
 * Copyright Google Inc. All Rights Reserved.
1838
 *
1839
 * Use of this source code is governed by an MIT-style license that can be
1840
 * found in the LICENSE file at https://angular.io/license
1841
 */
1842
/**
1843
 * @param {?} name
1844
 * @param {?} parent
1845
 * @return {?}
1846
 */
1847
function controlPath(name, parent) {
1848
    return ((parent.path)).concat([name]);
1849
}
1850
/**
1851
 * @param {?} control
1852
 * @param {?} dir
1853
 * @return {?}
1854
 */
1855
function setUpControl(control, dir) {
1856
    if (!control)
1857
        _throwError(dir, 'Cannot find control with');
1858
    if (!dir.valueAccessor)
1859
        _throwError(dir, 'No value accessor for form control with');
1860
    control.validator = Validators.compose([/** @type {?} */ ((control.validator)), dir.validator]);
1861
    control.asyncValidator = Validators.composeAsync([/** @type {?} */ ((control.asyncValidator)), dir.asyncValidator]); /** @type {?} */
1862
    ((dir.valueAccessor)).writeValue(control.value); /** @type {?} */
1863
    ((
1864
    // view -> model
1865
    dir.valueAccessor)).registerOnChange(function (newValue) {
1866
        dir.viewToModelUpdate(newValue);
1867
        control.markAsDirty();
1868
        control.setValue(newValue, { emitModelToViewChange: false });
1869
    }); /** @type {?} */
1870
    ((
1871
    // touched
1872
    dir.valueAccessor)).registerOnTouched(function () { return control.markAsTouched(); });
1873
    control.registerOnChange(function (newValue, emitModelEvent) {
1874
        ((
1875
        // control -> view
1876
        dir.valueAccessor)).writeValue(newValue);
1877
        // control -> ngModel
1878
        if (emitModelEvent)
1879
            dir.viewToModelUpdate(newValue);
1880
    });
1881
    if (((dir.valueAccessor)).setDisabledState) {
1882
        control.registerOnDisabledChange(function (isDisabled) { /** @type {?} */ ((((dir.valueAccessor)).setDisabledState))(isDisabled); });
1883
    }
1884
    // re-run validation when validator binding changes, e.g. minlength=3 -> minlength=4
1885
    dir._rawValidators.forEach(function (validator) {
1886
        if (((validator)).registerOnValidatorChange)
1887
            ((((validator)).registerOnValidatorChange))(function () { return control.updateValueAndValidity(); });
1888
    });
1889
    dir._rawAsyncValidators.forEach(function (validator) {
1890
        if (((validator)).registerOnValidatorChange)
1891
            ((((validator)).registerOnValidatorChange))(function () { return control.updateValueAndValidity(); });
1892
    });
1893
}
1894
/**
1895
 * @param {?} control
1896
 * @param {?} dir
1897
 * @return {?}
1898
 */
1899
function cleanUpControl(control, dir) {
1900
    ((dir.valueAccessor)).registerOnChange(function () { return _noControlError(dir); }); /** @type {?} */
1901
    ((dir.valueAccessor)).registerOnTouched(function () { return _noControlError(dir); });
1902
    dir._rawValidators.forEach(function (validator) {
1903
        if (validator.registerOnValidatorChange) {
1904
            validator.registerOnValidatorChange(null);
1905
        }
1906
    });
1907
    dir._rawAsyncValidators.forEach(function (validator) {
1908
        if (validator.registerOnValidatorChange) {
1909
            validator.registerOnValidatorChange(null);
1910
        }
1911
    });
1912
    if (control)
1913
        control._clearChangeFns();
1914
}
1915
/**
1916
 * @param {?} control
1917
 * @param {?} dir
1918
 * @return {?}
1919
 */
1920
function setUpFormContainer(control, dir) {
1921
    if (control == null)
1922
        _throwError(dir, 'Cannot find control with');
1923
    control.validator = Validators.compose([control.validator, dir.validator]);
1924
    control.asyncValidator = Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
1925
}
1926
/**
1927
 * @param {?} dir
1928
 * @return {?}
1929
 */
1930
function _noControlError(dir) {
1931
    return _throwError(dir, 'There is no FormControl instance attached to form control element with');
1932
}
1933
/**
1934
 * @param {?} dir
1935
 * @param {?} message
1936
 * @return {?}
1937
 */
1938
function _throwError(dir, message) {
1939
    var /** @type {?} */ messageEnd;
1940
    if (((dir.path)).length > 1) {
1941
        messageEnd = "path: '" + ((dir.path)).join(' -> ') + "'";
1942
    }
1943
    else if (((dir.path))[0]) {
1944
        messageEnd = "name: '" + dir.path + "'";
1945
    }
1946
    else {
1947
        messageEnd = 'unspecified name attribute';
1948
    }
1949
    throw new Error(message + " " + messageEnd);
1950
}
1951
/**
1952
 * @param {?} validators
1953
 * @return {?}
1954
 */
1955
function composeValidators(validators) {
1956
    return validators != null ? Validators.compose(validators.map(normalizeValidator)) : null;
1957
}
1958
/**
1959
 * @param {?} validators
1960
 * @return {?}
1961
 */
1962
function composeAsyncValidators(validators) {
1963
    return validators != null ? Validators.composeAsync(validators.map(normalizeAsyncValidator)) :
1964
        null;
1965
}
1966
/**
1967
 * @param {?} changes
1968
 * @param {?} viewModel
1969
 * @return {?}
1970
 */
1971
function isPropertyUpdated(changes, viewModel) {
1972
    if (!changes.hasOwnProperty('model'))
1973
        return false;
1974
    var /** @type {?} */ change = changes['model'];
1975
    if (change.isFirstChange())
1976
        return true;
1977
    return !_angular_core.ɵlooseIdentical(viewModel, change.currentValue);
1978
}
1979
var BUILTIN_ACCESSORS = [
1980
    CheckboxControlValueAccessor,
1981
    RangeValueAccessor,
1982
    NumberValueAccessor,
1983
    SelectControlValueAccessor,
1984
    SelectMultipleControlValueAccessor,
1985
    RadioControlValueAccessor,
1986
];
1987
/**
1988
 * @param {?} valueAccessor
1989
 * @return {?}
1990
 */
1991
function isBuiltInAccessor(valueAccessor) {
1992
    return BUILTIN_ACCESSORS.some(function (a) { return valueAccessor.constructor === a; });
1993
}
1994
/**
1995
 * @param {?} dir
1996
 * @param {?} valueAccessors
1997
 * @return {?}
1998
 */
1999
function selectValueAccessor(dir, valueAccessors) {
2000
    if (!valueAccessors)
2001
        return null;
2002
    var /** @type {?} */ defaultAccessor = undefined;
2003
    var /** @type {?} */ builtinAccessor = undefined;
2004
    var /** @type {?} */ customAccessor = undefined;
2005
    valueAccessors.forEach(function (v) {
2006
        if (v.constructor === DefaultValueAccessor) {
2007
            defaultAccessor = v;
2008
        }
2009
        else if (isBuiltInAccessor(v)) {
2010
            if (builtinAccessor)
2011
                _throwError(dir, 'More than one built-in value accessor matches form control with');
2012
            builtinAccessor = v;
2013
        }
2014
        else {
2015
            if (customAccessor)
2016
                _throwError(dir, 'More than one custom value accessor matches form control with');
2017
            customAccessor = v;
2018
        }
2019
    });
2020
    if (customAccessor)
2021
        return customAccessor;
2022
    if (builtinAccessor)
2023
        return builtinAccessor;
2024
    if (defaultAccessor)
2025
        return defaultAccessor;
2026
    _throwError(dir, 'No valid value accessor for form control with');
2027
    return null;
2028
}
2029
/**
2030
 * @license
2031
 * Copyright Google Inc. All Rights Reserved.
2032
 *
2033
 * Use of this source code is governed by an MIT-style license that can be
2034
 * found in the LICENSE file at https://angular.io/license
2035
 */
2036
/**
2037
 * This is a base class for code shared between {\@link NgModelGroup} and {\@link FormGroupName}.
2038
 *
2039
 * \@stable
2040
 */
2041
var AbstractFormGroupDirective = (function (_super) {
2042
    __extends(AbstractFormGroupDirective, _super);
2043
    function AbstractFormGroupDirective() {
2044
        return _super !== null && _super.apply(this, arguments) || this;
2045
    }
2046
    /**
2047
     * @return {?}
2048
     */
2049
    AbstractFormGroupDirective.prototype.ngOnInit = function () {
2050
        this._checkParentType(); /** @type {?} */
2051
        ((this.formDirective)).addFormGroup(this);
2052
    };
2053
    /**
2054
     * @return {?}
2055
     */
2056
    AbstractFormGroupDirective.prototype.ngOnDestroy = function () {
2057
        if (this.formDirective) {
2058
            this.formDirective.removeFormGroup(this);
2059
        }
2060
    };
2061
    Object.defineProperty(AbstractFormGroupDirective.prototype, "control", {
2062
        /**
2063
         * Get the {\@link FormGroup} backing this binding.
2064
         * @return {?}
2065
         */
2066
        get: function () { return ((this.formDirective)).getFormGroup(this); },
2067
        enumerable: true,
2068
        configurable: true
2069
    });
2070
    Object.defineProperty(AbstractFormGroupDirective.prototype, "path", {
2071
        /**
2072
         * Get the path to this control group.
2073
         * @return {?}
2074
         */
2075
        get: function () { return controlPath(this.name, this._parent); },
2076
        enumerable: true,
2077
        configurable: true
2078
    });
2079
    Object.defineProperty(AbstractFormGroupDirective.prototype, "formDirective", {
2080
        /**
2081
         * Get the {\@link Form} to which this group belongs.
2082
         * @return {?}
2083
         */
2084
        get: function () { return this._parent ? this._parent.formDirective : null; },
2085
        enumerable: true,
2086
        configurable: true
2087
    });
2088
    Object.defineProperty(AbstractFormGroupDirective.prototype, "validator", {
2089
        /**
2090
         * @return {?}
2091
         */
2092
        get: function () { return composeValidators(this._validators); },
2093
        enumerable: true,
2094
        configurable: true
2095
    });
2096
    Object.defineProperty(AbstractFormGroupDirective.prototype, "asyncValidator", {
2097
        /**
2098
         * @return {?}
2099
         */
2100
        get: function () {
2101
            return composeAsyncValidators(this._asyncValidators);
2102
        },
2103
        enumerable: true,
2104
        configurable: true
2105
    });
2106
    /**
2107
     * \@internal
2108
     * @return {?}
2109
     */
2110
    AbstractFormGroupDirective.prototype._checkParentType = function () { };
2111
    return AbstractFormGroupDirective;
2112
}(ControlContainer));
2113
/**
2114
 * @license
2115
 * Copyright Google Inc. All Rights Reserved.
2116
 *
2117
 * Use of this source code is governed by an MIT-style license that can be
2118
 * found in the LICENSE file at https://angular.io/license
2119
 */
2120
var AbstractControlStatus = (function () {
2121
    /**
2122
     * @param {?} cd
2123
     */
2124
    function AbstractControlStatus(cd) {
2125
        this._cd = cd;
2126
    }
2127
    Object.defineProperty(AbstractControlStatus.prototype, "ngClassUntouched", {
2128
        /**
2129
         * @return {?}
2130
         */
2131
        get: function () { return this._cd.control ? this._cd.control.untouched : false; },
2132
        enumerable: true,
2133
        configurable: true
2134
    });
2135
    Object.defineProperty(AbstractControlStatus.prototype, "ngClassTouched", {
2136
        /**
2137
         * @return {?}
2138
         */
2139
        get: function () { return this._cd.control ? this._cd.control.touched : false; },
2140
        enumerable: true,
2141
        configurable: true
2142
    });
2143
    Object.defineProperty(AbstractControlStatus.prototype, "ngClassPristine", {
2144
        /**
2145
         * @return {?}
2146
         */
2147
        get: function () { return this._cd.control ? this._cd.control.pristine : false; },
2148
        enumerable: true,
2149
        configurable: true
2150
    });
2151
    Object.defineProperty(AbstractControlStatus.prototype, "ngClassDirty", {
2152
        /**
2153
         * @return {?}
2154
         */
2155
        get: function () { return this._cd.control ? this._cd.control.dirty : false; },
2156
        enumerable: true,
2157
        configurable: true
2158
    });
2159
    Object.defineProperty(AbstractControlStatus.prototype, "ngClassValid", {
2160
        /**
2161
         * @return {?}
2162
         */
2163
        get: function () { return this._cd.control ? this._cd.control.valid : false; },
2164
        enumerable: true,
2165
        configurable: true
2166
    });
2167
    Object.defineProperty(AbstractControlStatus.prototype, "ngClassInvalid", {
2168
        /**
2169
         * @return {?}
2170
         */
2171
        get: function () { return this._cd.control ? this._cd.control.invalid : false; },
2172
        enumerable: true,
2173
        configurable: true
2174
    });
2175
    Object.defineProperty(AbstractControlStatus.prototype, "ngClassPending", {
2176
        /**
2177
         * @return {?}
2178
         */
2179
        get: function () { return this._cd.control ? this._cd.control.pending : false; },
2180
        enumerable: true,
2181
        configurable: true
2182
    });
2183
    return AbstractControlStatus;
2184
}());
2185
var ngControlStatusHost = {
2186
    '[class.ng-untouched]': 'ngClassUntouched',
2187
    '[class.ng-touched]': 'ngClassTouched',
2188
    '[class.ng-pristine]': 'ngClassPristine',
2189
    '[class.ng-dirty]': 'ngClassDirty',
2190
    '[class.ng-valid]': 'ngClassValid',
2191
    '[class.ng-invalid]': 'ngClassInvalid',
2192
    '[class.ng-pending]': 'ngClassPending',
2193
};
2194
/**
2195
 * Directive automatically applied to Angular form controls that sets CSS classes
2196
 * based on control status. The following classes are applied as the properties
2197
 * become true:
2198
 *
2199
 * * ng-valid
2200
 * * ng-invalid
2201
 * * ng-pending
2202
 * * ng-pristine
2203
 * * ng-dirty
2204
 * * ng-untouched
2205
 * * ng-touched
2206
 *
2207
 * \@stable
2208
 */
2209
var NgControlStatus = (function (_super) {
2210
    __extends(NgControlStatus, _super);
2211
    /**
2212
     * @param {?} cd
2213
     */
2214
    function NgControlStatus(cd) {
2215
        return _super.call(this, cd) || this;
2216
    }
2217
    return NgControlStatus;
2218
}(AbstractControlStatus));
2219
NgControlStatus.decorators = [
2220
    { type: _angular_core.Directive, args: [{ selector: '[formControlName],[ngModel],[formControl]', host: ngControlStatusHost },] },
2221
];
2222
/**
2223
 * @nocollapse
2224
 */
2225
NgControlStatus.ctorParameters = function () { return [
2226
    { type: NgControl, decorators: [{ type: _angular_core.Self },] },
2227
]; };
2228
/**
2229
 * Directive automatically applied to Angular form groups that sets CSS classes
2230
 * based on control status (valid/invalid/dirty/etc).
2231
 *
2232
 * \@stable
2233
 */
2234
var NgControlStatusGroup = (function (_super) {
2235
    __extends(NgControlStatusGroup, _super);
2236
    /**
2237
     * @param {?} cd
2238
     */
2239
    function NgControlStatusGroup(cd) {
2240
        return _super.call(this, cd) || this;
2241
    }
2242
    return NgControlStatusGroup;
2243
}(AbstractControlStatus));
2244
NgControlStatusGroup.decorators = [
2245
    { type: _angular_core.Directive, args: [{
2246
                selector: '[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]',
2247
                host: ngControlStatusHost
2248
            },] },
2249
];
2250
/**
2251
 * @nocollapse
2252
 */
2253
NgControlStatusGroup.ctorParameters = function () { return [
2254
    { type: ControlContainer, decorators: [{ type: _angular_core.Self },] },
2255
]; };
2256
/**
2257
 * @license
2258
 * Copyright Google Inc. All Rights Reserved.
2259
 *
2260
 * Use of this source code is governed by an MIT-style license that can be
2261
 * found in the LICENSE file at https://angular.io/license
2262
 */
2263
/**
2264
 * Indicates that a FormControl is valid, i.e. that no errors exist in the input value.
2265
 */
2266
var VALID = 'VALID';
2267
/**
2268
 * Indicates that a FormControl is invalid, i.e. that an error exists in the input value.
2269
 */
2270
var INVALID = 'INVALID';
2271
/**
2272
 * Indicates that a FormControl is pending, i.e. that async validation is occurring and
2273
 * errors are not yet available for the input value.
2274
 */
2275
var PENDING = 'PENDING';
2276
/**
2277
 * Indicates that a FormControl is disabled, i.e. that the control is exempt from ancestor
2278
 * calculations of validity or value.
2279
 */
2280
var DISABLED = 'DISABLED';
2281
/**
2282
 * @param {?} control
2283
 * @param {?} path
2284
 * @param {?} delimiter
2285
 * @return {?}
2286
 */
2287
function _find(control, path, delimiter) {
2288
    if (path == null)
2289
        return null;
2290
    if (!(path instanceof Array)) {
2291
        path = ((path)).split(delimiter);
2292
    }
2293
    if (path instanceof Array && (path.length === 0))
2294
        return null;
2295
    return ((path)).reduce(function (v, name) {
2296
        if (v instanceof FormGroup) {
2297
            return v.controls[name] || null;
2298
        }
2299
        if (v instanceof FormArray) {
2300
            return v.at(/** @type {?} */ (name)) || null;
2301
        }
2302
        return null;
2303
    }, control);
2304
}
2305
/**
2306
 * @param {?=} validator
2307
 * @return {?}
2308
 */
2309
function coerceToValidator(validator) {
2310
    return Array.isArray(validator) ? composeValidators(validator) : validator || null;
2311
}
2312
/**
2313
 * @param {?=} asyncValidator
2314
 * @return {?}
2315
 */
2316
function coerceToAsyncValidator(asyncValidator) {
2317
    return Array.isArray(asyncValidator) ? composeAsyncValidators(asyncValidator) :
2318
        asyncValidator || null;
2319
}
2320
/**
2321
 * \@whatItDoes This is the base class for {\@link FormControl}, {\@link FormGroup}, and
2322
 * {\@link FormArray}.
2323
 *
2324
 * It provides some of the shared behavior that all controls and groups of controls have, like
2325
 * running validators, calculating status, and resetting state. It also defines the properties
2326
 * that are shared between all sub-classes, like `value`, `valid`, and `dirty`. It shouldn't be
2327
 * instantiated directly.
2328
 *
2329
 * \@stable
2330
 * @abstract
2331
 */
2332
var AbstractControl = (function () {
2333
    /**
2334
     * @param {?} validator
2335
     * @param {?} asyncValidator
2336
     */
2337
    function AbstractControl(validator, asyncValidator) {
2338
        this.validator = validator;
2339
        this.asyncValidator = asyncValidator;
2340
        /**
2341
         * \@internal
2342
         */
2343
        this._onCollectionChange = function () { };
2344
        this._pristine = true;
2345
        this._touched = false;
2346
        /**
2347
         * \@internal
2348
         */
2349
        this._onDisabledChange = [];
2350
    }
2351
    Object.defineProperty(AbstractControl.prototype, "value", {
2352
        /**
2353
         * The value of the control.
2354
         * @return {?}
2355
         */
2356
        get: function () { return this._value; },
2357
        enumerable: true,
2358
        configurable: true
2359
    });
2360
    Object.defineProperty(AbstractControl.prototype, "parent", {
2361
        /**
2362
         * The parent control.
2363
         * @return {?}
2364
         */
2365
        get: function () { return this._parent; },
2366
        enumerable: true,
2367
        configurable: true
2368
    });
2369
    Object.defineProperty(AbstractControl.prototype, "status", {
2370
        /**
2371
         * The validation status of the control. There are four possible
2372
         * validation statuses:
2373
         *
2374
         * * **VALID**:  control has passed all validation checks
2375
         * * **INVALID**: control has failed at least one validation check
2376
         * * **PENDING**: control is in the midst of conducting a validation check
2377
         * * **DISABLED**: control is exempt from validation checks
2378
         *
2379
         * These statuses are mutually exclusive, so a control cannot be
2380
         * both valid AND invalid or invalid AND disabled.
2381
         * @return {?}
2382
         */
2383
        get: function () { return this._status; },
2384
        enumerable: true,
2385
        configurable: true
2386
    });
2387
    Object.defineProperty(AbstractControl.prototype, "valid", {
2388
        /**
2389
         * A control is `valid` when its `status === VALID`.
2390
         *
2391
         * In order to have this status, the control must have passed all its
2392
         * validation checks.
2393
         * @return {?}
2394
         */
2395
        get: function () { return this._status === VALID; },
2396
        enumerable: true,
2397
        configurable: true
2398
    });
2399
    Object.defineProperty(AbstractControl.prototype, "invalid", {
2400
        /**
2401
         * A control is `invalid` when its `status === INVALID`.
2402
         *
2403
         * In order to have this status, the control must have failed
2404
         * at least one of its validation checks.
2405
         * @return {?}
2406
         */
2407
        get: function () { return this._status === INVALID; },
2408
        enumerable: true,
2409
        configurable: true
2410
    });
2411
    Object.defineProperty(AbstractControl.prototype, "pending", {
2412
        /**
2413
         * A control is `pending` when its `status === PENDING`.
2414
         *
2415
         * In order to have this status, the control must be in the
2416
         * middle of conducting a validation check.
2417
         * @return {?}
2418
         */
2419
        get: function () { return this._status == PENDING; },
2420
        enumerable: true,
2421
        configurable: true
2422
    });
2423
    Object.defineProperty(AbstractControl.prototype, "disabled", {
2424
        /**
2425
         * A control is `disabled` when its `status === DISABLED`.
2426
         *
2427
         * Disabled controls are exempt from validation checks and
2428
         * are not included in the aggregate value of their ancestor
2429
         * controls.
2430
         * @return {?}
2431
         */
2432
        get: function () { return this._status === DISABLED; },
2433
        enumerable: true,
2434
        configurable: true
2435
    });
2436
    Object.defineProperty(AbstractControl.prototype, "enabled", {
2437
        /**
2438
         * A control is `enabled` as long as its `status !== DISABLED`.
2439
         *
2440
         * In other words, it has a status of `VALID`, `INVALID`, or
2441
         * `PENDING`.
2442
         * @return {?}
2443
         */
2444
        get: function () { return this._status !== DISABLED; },
2445
        enumerable: true,
2446
        configurable: true
2447
    });
2448
    Object.defineProperty(AbstractControl.prototype, "errors", {
2449
        /**
2450
         * Returns any errors generated by failing validation. If there
2451
         * are no errors, it will return null.
2452
         * @return {?}
2453
         */
2454
        get: function () { return this._errors; },
2455
        enumerable: true,
2456
        configurable: true
2457
    });
2458
    Object.defineProperty(AbstractControl.prototype, "pristine", {
2459
        /**
2460
         * A control is `pristine` if the user has not yet changed
2461
         * the value in the UI.
2462
         *
2463
         * Note that programmatic changes to a control's value will
2464
         * *not* mark it dirty.
2465
         * @return {?}
2466
         */
2467
        get: function () { return this._pristine; },
2468
        enumerable: true,
2469
        configurable: true
2470
    });
2471
    Object.defineProperty(AbstractControl.prototype, "dirty", {
2472
        /**
2473
         * A control is `dirty` if the user has changed the value
2474
         * in the UI.
2475
         *
2476
         * Note that programmatic changes to a control's value will
2477
         * *not* mark it dirty.
2478
         * @return {?}
2479
         */
2480
        get: function () { return !this.pristine; },
2481
        enumerable: true,
2482
        configurable: true
2483
    });
2484
    Object.defineProperty(AbstractControl.prototype, "touched", {
2485
        /**
2486
         * A control is marked `touched` once the user has triggered
2487
         * a `blur` event on it.
2488
         * @return {?}
2489
         */
2490
        get: function () { return this._touched; },
2491
        enumerable: true,
2492
        configurable: true
2493
    });
2494
    Object.defineProperty(AbstractControl.prototype, "untouched", {
2495
        /**
2496
         * A control is `untouched` if the user has not yet triggered
2497
         * a `blur` event on it.
2498
         * @return {?}
2499
         */
2500
        get: function () { return !this._touched; },
2501
        enumerable: true,
2502
        configurable: true
2503
    });
2504
    Object.defineProperty(AbstractControl.prototype, "valueChanges", {
2505
        /**
2506
         * Emits an event every time the value of the control changes, in
2507
         * the UI or programmatically.
2508
         * @return {?}
2509
         */
2510
        get: function () { return this._valueChanges; },
2511
        enumerable: true,
2512
        configurable: true
2513
    });
2514
    Object.defineProperty(AbstractControl.prototype, "statusChanges", {
2515
        /**
2516
         * Emits an event every time the validation status of the control
2517
         * is re-calculated.
2518
         * @return {?}
2519
         */
2520
        get: function () { return this._statusChanges; },
2521
        enumerable: true,
2522
        configurable: true
2523
    });
2524
    /**
2525
     * Sets the synchronous validators that are active on this control.  Calling
2526
     * this will overwrite any existing sync validators.
2527
     * @param {?} newValidator
2528
     * @return {?}
2529
     */
2530
    AbstractControl.prototype.setValidators = function (newValidator) {
2531
        this.validator = coerceToValidator(newValidator);
2532
    };
2533
    /**
2534
     * Sets the async validators that are active on this control. Calling this
2535
     * will overwrite any existing async validators.
2536
     * @param {?} newValidator
2537
     * @return {?}
2538
     */
2539
    AbstractControl.prototype.setAsyncValidators = function (newValidator) {
2540
        this.asyncValidator = coerceToAsyncValidator(newValidator);
2541
    };
2542
    /**
2543
     * Empties out the sync validator list.
2544
     * @return {?}
2545
     */
2546
    AbstractControl.prototype.clearValidators = function () { this.validator = null; };
2547
    /**
2548
     * Empties out the async validator list.
2549
     * @return {?}
2550
     */
2551
    AbstractControl.prototype.clearAsyncValidators = function () { this.asyncValidator = null; };
2552
    /**
2553
     * Marks the control as `touched`.
2554
     *
2555
     * This will also mark all direct ancestors as `touched` to maintain
2556
     * the model.
2557
     * @param {?=} opts
2558
     * @return {?}
2559
     */
2560
    AbstractControl.prototype.markAsTouched = function (opts) {
2561
        if (opts === void 0) { opts = {}; }
2562
        this._touched = true;
2563
        if (this._parent && !opts.onlySelf) {
2564
            this._parent.markAsTouched(opts);
2565
        }
2566
    };
2567
    /**
2568
     * Marks the control as `untouched`.
2569
     *
2570
     * If the control has any children, it will also mark all children as `untouched`
2571
     * to maintain the model, and re-calculate the `touched` status of all parent
2572
     * controls.
2573
     * @param {?=} opts
2574
     * @return {?}
2575
     */
2576
    AbstractControl.prototype.markAsUntouched = function (opts) {
2577
        if (opts === void 0) { opts = {}; }
2578
        this._touched = false;
2579
        this._forEachChild(function (control) { control.markAsUntouched({ onlySelf: true }); });
2580
        if (this._parent && !opts.onlySelf) {
2581
            this._parent._updateTouched(opts);
2582
        }
2583
    };
2584
    /**
2585
     * Marks the control as `dirty`.
2586
     *
2587
     * This will also mark all direct ancestors as `dirty` to maintain
2588
     * the model.
2589
     * @param {?=} opts
2590
     * @return {?}
2591
     */
2592
    AbstractControl.prototype.markAsDirty = function (opts) {
2593
        if (opts === void 0) { opts = {}; }
2594
        this._pristine = false;
2595
        if (this._parent && !opts.onlySelf) {
2596
            this._parent.markAsDirty(opts);
2597
        }
2598
    };
2599
    /**
2600
     * Marks the control as `pristine`.
2601
     *
2602
     * If the control has any children, it will also mark all children as `pristine`
2603
     * to maintain the model, and re-calculate the `pristine` status of all parent
2604
     * controls.
2605
     * @param {?=} opts
2606
     * @return {?}
2607
     */
2608
    AbstractControl.prototype.markAsPristine = function (opts) {
2609
        if (opts === void 0) { opts = {}; }
2610
        this._pristine = true;
2611
        this._forEachChild(function (control) { control.markAsPristine({ onlySelf: true }); });
2612
        if (this._parent && !opts.onlySelf) {
2613
            this._parent._updatePristine(opts);
2614
        }
2615
    };
2616
    /**
2617
     * Marks the control as `pending`.
2618
     * @param {?=} opts
2619
     * @return {?}
2620
     */
2621
    AbstractControl.prototype.markAsPending = function (opts) {
2622
        if (opts === void 0) { opts = {}; }
2623
        this._status = PENDING;
2624
        if (this._parent && !opts.onlySelf) {
2625
            this._parent.markAsPending(opts);
2626
        }
2627
    };
2628
    /**
2629
     * Disables the control. This means the control will be exempt from validation checks and
2630
     * excluded from the aggregate value of any parent. Its status is `DISABLED`.
2631
     *
2632
     * If the control has children, all children will be disabled to maintain the model.
2633
     * @param {?=} opts
2634
     * @return {?}
2635
     */
2636
    AbstractControl.prototype.disable = function (opts) {
2637
        if (opts === void 0) { opts = {}; }
2638
        this._status = DISABLED;
2639
        this._errors = null;
2640
        this._forEachChild(function (control) { control.disable({ onlySelf: true }); });
2641
        this._updateValue();
2642
        if (opts.emitEvent !== false) {
2643
            this._valueChanges.emit(this._value);
2644
            this._statusChanges.emit(this._status);
2645
        }
2646
        this._updateAncestors(!!opts.onlySelf);
2647
        this._onDisabledChange.forEach(function (changeFn) { return changeFn(true); });
2648
    };
2649
    /**
2650
     * Enables the control. This means the control will be included in validation checks and
2651
     * the aggregate value of its parent. Its status is re-calculated based on its value and
2652
     * its validators.
2653
     *
2654
     * If the control has children, all children will be enabled.
2655
     * @param {?=} opts
2656
     * @return {?}
2657
     */
2658
    AbstractControl.prototype.enable = function (opts) {
2659
        if (opts === void 0) { opts = {}; }
2660
        this._status = VALID;
2661
        this._forEachChild(function (control) { control.enable({ onlySelf: true }); });
2662
        this.updateValueAndValidity({ onlySelf: true, emitEvent: opts.emitEvent });
2663
        this._updateAncestors(!!opts.onlySelf);
2664
        this._onDisabledChange.forEach(function (changeFn) { return changeFn(false); });
2665
    };
2666
    /**
2667
     * @param {?} onlySelf
2668
     * @return {?}
2669
     */
2670
    AbstractControl.prototype._updateAncestors = function (onlySelf) {
2671
        if (this._parent && !onlySelf) {
2672
            this._parent.updateValueAndValidity();
2673
            this._parent._updatePristine();
2674
            this._parent._updateTouched();
2675
        }
2676
    };
2677
    /**
2678
     * @param {?} parent
2679
     * @return {?}
2680
     */
2681
    AbstractControl.prototype.setParent = function (parent) { this._parent = parent; };
2682
    /**
2683
     * Sets the value of the control. Abstract method (implemented in sub-classes).
2684
     * @abstract
2685
     * @param {?} value
2686
     * @param {?=} options
2687
     * @return {?}
2688
     */
2689
    AbstractControl.prototype.setValue = function (value, options) { };
2690
    /**
2691
     * Patches the value of the control. Abstract method (implemented in sub-classes).
2692
     * @abstract
2693
     * @param {?} value
2694
     * @param {?=} options
2695
     * @return {?}
2696
     */
2697
    AbstractControl.prototype.patchValue = function (value, options) { };
2698
    /**
2699
     * Resets the control. Abstract method (implemented in sub-classes).
2700
     * @abstract
2701
     * @param {?=} value
2702
     * @param {?=} options
2703
     * @return {?}
2704
     */
2705
    AbstractControl.prototype.reset = function (value, options) { };
2706
    /**
2707
     * Re-calculates the value and validation status of the control.
2708
     *
2709
     * By default, it will also update the value and validity of its ancestors.
2710
     * @param {?=} opts
2711
     * @return {?}
2712
     */
2713
    AbstractControl.prototype.updateValueAndValidity = function (opts) {
2714
        if (opts === void 0) { opts = {}; }
2715
        this._setInitialStatus();
2716
        this._updateValue();
2717
        if (this.enabled) {
2718
            this._cancelExistingSubscription();
2719
            this._errors = this._runValidator();
2720
            this._status = this._calculateStatus();
2721
            if (this._status === VALID || this._status === PENDING) {
2722
                this._runAsyncValidator(opts.emitEvent);
2723
            }
2724
        }
2725
        if (opts.emitEvent !== false) {
2726
            this._valueChanges.emit(this._value);
2727
            this._statusChanges.emit(this._status);
2728
        }
2729
        if (this._parent && !opts.onlySelf) {
2730
            this._parent.updateValueAndValidity(opts);
2731
        }
2732
    };
2733
    /**
2734
     * \@internal
2735
     * @param {?=} opts
2736
     * @return {?}
2737
     */
2738
    AbstractControl.prototype._updateTreeValidity = function (opts) {
2739
        if (opts === void 0) { opts = { emitEvent: true }; }
2740
        this._forEachChild(function (ctrl) { return ctrl._updateTreeValidity(opts); });
2741
        this.updateValueAndValidity({ onlySelf: true, emitEvent: opts.emitEvent });
2742
    };
2743
    /**
2744
     * @return {?}
2745
     */
2746
    AbstractControl.prototype._setInitialStatus = function () { this._status = this._allControlsDisabled() ? DISABLED : VALID; };
2747
    /**
2748
     * @return {?}
2749
     */
2750
    AbstractControl.prototype._runValidator = function () {
2751
        return this.validator ? this.validator(this) : null;
2752
    };
2753
    /**
2754
     * @param {?=} emitEvent
2755
     * @return {?}
2756
     */
2757
    AbstractControl.prototype._runAsyncValidator = function (emitEvent) {
2758
        var _this = this;
2759
        if (this.asyncValidator) {
2760
            this._status = PENDING;
2761
            var /** @type {?} */ obs = toObservable(this.asyncValidator(this));
2762
            this._asyncValidationSubscription =
2763
                obs.subscribe(function (errors) { return _this.setErrors(errors, { emitEvent: emitEvent }); });
2764
        }
2765
    };
2766
    /**
2767
     * @return {?}
2768
     */
2769
    AbstractControl.prototype._cancelExistingSubscription = function () {
2770
        if (this._asyncValidationSubscription) {
2771
            this._asyncValidationSubscription.unsubscribe();
2772
        }
2773
    };
2774
    /**
2775
     * Sets errors on a form control.
2776
     *
2777
     * This is used when validations are run manually by the user, rather than automatically.
2778
     *
2779
     * Calling `setErrors` will also update the validity of the parent control.
2780
     *
2781
     * ### Example
2782
     *
2783
     * ```
2784
     * const login = new FormControl("someLogin");
2785
     * login.setErrors({
2786
     *   "notUnique": true
2787
     * });
2788
     *
2789
     * expect(login.valid).toEqual(false);
2790
     * expect(login.errors).toEqual({"notUnique": true});
2791
     *
2792
     * login.setValue("someOtherLogin");
2793
     *
2794
     * expect(login.valid).toEqual(true);
2795
     * ```
2796
     * @param {?} errors
2797
     * @param {?=} opts
2798
     * @return {?}
2799
     */
2800
    AbstractControl.prototype.setErrors = function (errors, opts) {
2801
        if (opts === void 0) { opts = {}; }
2802
        this._errors = errors;
2803
        this._updateControlsErrors(opts.emitEvent !== false);
2804
    };
2805
    /**
2806
     * Retrieves a child control given the control's name or path.
2807
     *
2808
     * Paths can be passed in as an array or a string delimited by a dot.
2809
     *
2810
     * To get a control nested within a `person` sub-group:
2811
     *
2812
     * * `this.form.get('person.name');`
2813
     *
2814
     * -OR-
2815
     *
2816
     * * `this.form.get(['person', 'name']);`
2817
     * @param {?} path
2818
     * @return {?}
2819
     */
2820
    AbstractControl.prototype.get = function (path) { return _find(this, path, '.'); };
2821
    /**
2822
     * Returns error data if the control with the given path has the error specified. Otherwise
2823
     * returns null or undefined.
2824
     *
2825
     * If no path is given, it checks for the error on the present control.
2826
     * @param {?} errorCode
2827
     * @param {?=} path
2828
     * @return {?}
2829
     */
2830
    AbstractControl.prototype.getError = function (errorCode, path) {
2831
        var /** @type {?} */ control = path ? this.get(path) : this;
2832
        return control && control._errors ? control._errors[errorCode] : null;
2833
    };
2834
    /**
2835
     * Returns true if the control with the given path has the error specified. Otherwise
2836
     * returns false.
2837
     *
2838
     * If no path is given, it checks for the error on the present control.
2839
     * @param {?} errorCode
2840
     * @param {?=} path
2841
     * @return {?}
2842
     */
2843
    AbstractControl.prototype.hasError = function (errorCode, path) { return !!this.getError(errorCode, path); };
2844
    Object.defineProperty(AbstractControl.prototype, "root", {
2845
        /**
2846
         * Retrieves the top-level ancestor of this control.
2847
         * @return {?}
2848
         */
2849
        get: function () {
2850
            var /** @type {?} */ x = this;
2851
            while (x._parent) {
2852
                x = x._parent;
2853
            }
2854
            return x;
2855
        },
2856
        enumerable: true,
2857
        configurable: true
2858
    });
2859
    /**
2860
     * \@internal
2861
     * @param {?} emitEvent
2862
     * @return {?}
2863
     */
2864
    AbstractControl.prototype._updateControlsErrors = function (emitEvent) {
2865
        this._status = this._calculateStatus();
2866
        if (emitEvent) {
2867
            this._statusChanges.emit(this._status);
2868
        }
2869
        if (this._parent) {
2870
            this._parent._updateControlsErrors(emitEvent);
2871
        }
2872
    };
2873
    /**
2874
     * \@internal
2875
     * @return {?}
2876
     */
2877
    AbstractControl.prototype._initObservables = function () {
2878
        this._valueChanges = new _angular_core.EventEmitter();
2879
        this._statusChanges = new _angular_core.EventEmitter();
2880
    };
2881
    /**
2882
     * @return {?}
2883
     */
2884
    AbstractControl.prototype._calculateStatus = function () {
2885
        if (this._allControlsDisabled())
2886
            return DISABLED;
2887
        if (this._errors)
2888
            return INVALID;
2889
        if (this._anyControlsHaveStatus(PENDING))
2890
            return PENDING;
2891
        if (this._anyControlsHaveStatus(INVALID))
2892
            return INVALID;
2893
        return VALID;
2894
    };
2895
    /**
2896
     * \@internal
2897
     * @abstract
2898
     * @return {?}
2899
     */
2900
    AbstractControl.prototype._updateValue = function () { };
2901
    /**
2902
     * \@internal
2903
     * @abstract
2904
     * @param {?} cb
2905
     * @return {?}
2906
     */
2907
    AbstractControl.prototype._forEachChild = function (cb) { };
2908
    /**
2909
     * \@internal
2910
     * @abstract
2911
     * @param {?} condition
2912
     * @return {?}
2913
     */
2914
    AbstractControl.prototype._anyControls = function (condition) { };
2915
    /**
2916
     * \@internal
2917
     * @abstract
2918
     * @return {?}
2919
     */
2920
    AbstractControl.prototype._allControlsDisabled = function () { };
2921
    /**
2922
     * \@internal
2923
     * @param {?} status
2924
     * @return {?}
2925
     */
2926
    AbstractControl.prototype._anyControlsHaveStatus = function (status) {
2927
        return this._anyControls(function (control) { return control.status === status; });
2928
    };
2929
    /**
2930
     * \@internal
2931
     * @return {?}
2932
     */
2933
    AbstractControl.prototype._anyControlsDirty = function () {
2934
        return this._anyControls(function (control) { return control.dirty; });
2935
    };
2936
    /**
2937
     * \@internal
2938
     * @return {?}
2939
     */
2940
    AbstractControl.prototype._anyControlsTouched = function () {
2941
        return this._anyControls(function (control) { return control.touched; });
2942
    };
2943
    /**
2944
     * \@internal
2945
     * @param {?=} opts
2946
     * @return {?}
2947
     */
2948
    AbstractControl.prototype._updatePristine = function (opts) {
2949
        if (opts === void 0) { opts = {}; }
2950
        this._pristine = !this._anyControlsDirty();
2951
        if (this._parent && !opts.onlySelf) {
2952
            this._parent._updatePristine(opts);
2953
        }
2954
    };
2955
    /**
2956
     * \@internal
2957
     * @param {?=} opts
2958
     * @return {?}
2959
     */
2960
    AbstractControl.prototype._updateTouched = function (opts) {
2961
        if (opts === void 0) { opts = {}; }
2962
        this._touched = this._anyControlsTouched();
2963
        if (this._parent && !opts.onlySelf) {
2964
            this._parent._updateTouched(opts);
2965
        }
2966
    };
2967
    /**
2968
     * \@internal
2969
     * @param {?} formState
2970
     * @return {?}
2971
     */
2972
    AbstractControl.prototype._isBoxedValue = function (formState) {
2973
        return typeof formState === 'object' && formState !== null &&
2974
            Object.keys(formState).length === 2 && 'value' in formState && 'disabled' in formState;
2975
    };
2976
    /**
2977
     * \@internal
2978
     * @param {?} fn
2979
     * @return {?}
2980
     */
2981
    AbstractControl.prototype._registerOnCollectionChange = function (fn) { this._onCollectionChange = fn; };
2982
    return AbstractControl;
2983
}());
2984
/**
2985
 * \@whatItDoes Tracks the value and validation status of an individual form control.
2986
 *
2987
 * It is one of the three fundamental building blocks of Angular forms, along with
2988
 * {\@link FormGroup} and {\@link FormArray}.
2989
 *
2990
 * \@howToUse
2991
 *
2992
 * When instantiating a {\@link FormControl}, you can pass in an initial value as the
2993
 * first argument. Example:
2994
 *
2995
 * ```ts
2996
 * const ctrl = new FormControl('some value');
2997
 * console.log(ctrl.value);     // 'some value'
2998
 * ```
2999
 *
3000
 * You can also initialize the control with a form state object on instantiation,
3001
 * which includes both the value and whether or not the control is disabled.
3002
 * You can't use the value key without the disabled key; both are required
3003
 * to use this way of initialization.
3004
 *
3005
 * ```ts
3006
 * const ctrl = new FormControl({value: 'n/a', disabled: true});
3007
 * console.log(ctrl.value);     // 'n/a'
3008
 * console.log(ctrl.status);   // 'DISABLED'
3009
 * ```
3010
 *
3011
 * To include a sync validator (or an array of sync validators) with the control,
3012
 * pass it in as the second argument. Async validators are also supported, but
3013
 * have to be passed in separately as the third arg.
3014
 *
3015
 * ```ts
3016
 * const ctrl = new FormControl('', Validators.required);
3017
 * console.log(ctrl.value);     // ''
3018
 * console.log(ctrl.status);   // 'INVALID'
3019
 * ```
3020
 *
3021
 * See its superclass, {\@link AbstractControl}, for more properties and methods.
3022
 *
3023
 * * **npm package**: `\@angular/forms`
3024
 *
3025
 * \@stable
3026
 */
3027
var FormControl = (function (_super) {
3028
    __extends(FormControl, _super);
3029
    /**
3030
     * @param {?=} formState
3031
     * @param {?=} validator
3032
     * @param {?=} asyncValidator
3033
     */
3034
    function FormControl(formState, validator, asyncValidator) {
3035
        if (formState === void 0) { formState = null; }
3036
        var _this = _super.call(this, coerceToValidator(validator), coerceToAsyncValidator(asyncValidator)) || this;
3037
        /**
3038
         * \@internal
3039
         */
3040
        _this._onChange = [];
3041
        _this._applyFormState(formState);
3042
        _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
3043
        _this._initObservables();
3044
        return _this;
3045
    }
3046
    /**
3047
     * Set the value of the form control to `value`.
3048
     *
3049
     * If `onlySelf` is `true`, this change will only affect the validation of this `FormControl`
3050
     * and not its parent component. This defaults to false.
3051
     *
3052
     * If `emitEvent` is `true`, this
3053
     * change will cause a `valueChanges` event on the `FormControl` to be emitted. This defaults
3054
     * to true (as it falls through to `updateValueAndValidity`).
3055
     *
3056
     * If `emitModelToViewChange` is `true`, the view will be notified about the new value
3057
     * via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
3058
     * specified.
3059
     *
3060
     * If `emitViewToModelChange` is `true`, an ngModelChange event will be fired to update the
3061
     * model.  This is the default behavior if `emitViewToModelChange` is not specified.
3062
     * @param {?} value
3063
     * @param {?=} options
3064
     * @return {?}
3065
     */
3066
    FormControl.prototype.setValue = function (value, options) {
3067
        var _this = this;
3068
        if (options === void 0) { options = {}; }
3069
        this._value = value;
3070
        if (this._onChange.length && options.emitModelToViewChange !== false) {
3071
            this._onChange.forEach(function (changeFn) { return changeFn(_this._value, options.emitViewToModelChange !== false); });
3072
        }
3073
        this.updateValueAndValidity(options);
3074
    };
3075
    /**
3076
     * Patches the value of a control.
3077
     *
3078
     * This function is functionally the same as {\@link FormControl#setValue} at this level.
3079
     * It exists for symmetry with {\@link FormGroup#patchValue} on `FormGroups` and `FormArrays`,
3080
     * where it does behave differently.
3081
     * @param {?} value
3082
     * @param {?=} options
3083
     * @return {?}
3084
     */
3085
    FormControl.prototype.patchValue = function (value, options) {
3086
        if (options === void 0) { options = {}; }
3087
        this.setValue(value, options);
3088
    };
3089
    /**
3090
     * Resets the form control. This means by default:
3091
     *
3092
     * * it is marked as `pristine`
3093
     * * it is marked as `untouched`
3094
     * * value is set to null
3095
     *
3096
     * You can also reset to a specific form state by passing through a standalone
3097
     * value or a form state object that contains both a value and a disabled state
3098
     * (these are the only two properties that cannot be calculated).
3099
     *
3100
     * Ex:
3101
     *
3102
     * ```ts
3103
     * this.control.reset('Nancy');
3104
     *
3105
     * console.log(this.control.value);  // 'Nancy'
3106
     * ```
3107
     *
3108
     * OR
3109
     *
3110
     * ```
3111
     * this.control.reset({value: 'Nancy', disabled: true});
3112
     *
3113
     * console.log(this.control.value);  // 'Nancy'
3114
     * console.log(this.control.status);  // 'DISABLED'
3115
     * ```
3116
     * @param {?=} formState
3117
     * @param {?=} options
3118
     * @return {?}
3119
     */
3120
    FormControl.prototype.reset = function (formState, options) {
3121
        if (formState === void 0) { formState = null; }
3122
        if (options === void 0) { options = {}; }
3123
        this._applyFormState(formState);
3124
        this.markAsPristine(options);
3125
        this.markAsUntouched(options);
3126
        this.setValue(this._value, options);
3127
    };
3128
    /**
3129
     * \@internal
3130
     * @return {?}
3131
     */
3132
    FormControl.prototype._updateValue = function () { };
3133
    /**
3134
     * \@internal
3135
     * @param {?} condition
3136
     * @return {?}
3137
     */
3138
    FormControl.prototype._anyControls = function (condition) { return false; };
3139
    /**
3140
     * \@internal
3141
     * @return {?}
3142
     */
3143
    FormControl.prototype._allControlsDisabled = function () { return this.disabled; };
3144
    /**
3145
     * Register a listener for change events.
3146
     * @param {?} fn
3147
     * @return {?}
3148
     */
3149
    FormControl.prototype.registerOnChange = function (fn) { this._onChange.push(fn); };
3150
    /**
3151
     * \@internal
3152
     * @return {?}
3153
     */
3154
    FormControl.prototype._clearChangeFns = function () {
3155
        this._onChange = [];
3156
        this._onDisabledChange = [];
3157
        this._onCollectionChange = function () { };
3158
    };
3159
    /**
3160
     * Register a listener for disabled events.
3161
     * @param {?} fn
3162
     * @return {?}
3163
     */
3164
    FormControl.prototype.registerOnDisabledChange = function (fn) {
3165
        this._onDisabledChange.push(fn);
3166
    };
3167
    /**
3168
     * \@internal
3169
     * @param {?} cb
3170
     * @return {?}
3171
     */
3172
    FormControl.prototype._forEachChild = function (cb) { };
3173
    /**
3174
     * @param {?} formState
3175
     * @return {?}
3176
     */
3177
    FormControl.prototype._applyFormState = function (formState) {
3178
        if (this._isBoxedValue(formState)) {
3179
            this._value = formState.value;
3180
            formState.disabled ? this.disable({ onlySelf: true, emitEvent: false }) :
3181
                this.enable({ onlySelf: true, emitEvent: false });
3182
        }
3183
        else {
3184
            this._value = formState;
3185
        }
3186
    };
3187
    return FormControl;
3188
}(AbstractControl));
3189
/**
3190
 * \@whatItDoes Tracks the value and validity state of a group of {\@link FormControl}
3191
 * instances.
3192
 *
3193
 * A `FormGroup` aggregates the values of each child {\@link FormControl} into one object,
3194
 * with each control name as the key.  It calculates its status by reducing the statuses
3195
 * of its children. For example, if one of the controls in a group is invalid, the entire
3196
 * group becomes invalid.
3197
 *
3198
 * `FormGroup` is one of the three fundamental building blocks used to define forms in Angular,
3199
 * along with {\@link FormControl} and {\@link FormArray}.
3200
 *
3201
 * \@howToUse
3202
 *
3203
 * When instantiating a {\@link FormGroup}, pass in a collection of child controls as the first
3204
 * argument. The key for each child will be the name under which it is registered.
3205
 *
3206
 * ### Example
3207
 *
3208
 * ```
3209
 * const form = new FormGroup({
3210
 *   first: new FormControl('Nancy', Validators.minLength(2)),
3211
 *   last: new FormControl('Drew'),
3212
 * });
3213
 *
3214
 * console.log(form.value);   // {first: 'Nancy', last; 'Drew'}
3215
 * console.log(form.status);  // 'VALID'
3216
 * ```
3217
 *
3218
 * You can also include group-level validators as the second arg, or group-level async
3219
 * validators as the third arg. These come in handy when you want to perform validation
3220
 * that considers the value of more than one child control.
3221
 *
3222
 * ### Example
3223
 *
3224
 * ```
3225
 * const form = new FormGroup({
3226
 *   password: new FormControl('', Validators.minLength(2)),
3227
 *   passwordConfirm: new FormControl('', Validators.minLength(2)),
3228
 * }, passwordMatchValidator);
3229
 *
3230
 *
3231
 * function passwordMatchValidator(g: FormGroup) {
3232
 *    return g.get('password').value === g.get('passwordConfirm').value
3233
 *       ? null : {'mismatch': true};
3234
 * }
3235
 * ```
3236
 *
3237
 * * **npm package**: `\@angular/forms`
3238
 *
3239
 * \@stable
3240
 */
3241
var FormGroup = (function (_super) {
3242
    __extends(FormGroup, _super);
3243
    /**
3244
     * @param {?} controls
3245
     * @param {?=} validator
3246
     * @param {?=} asyncValidator
3247
     */
3248
    function FormGroup(controls, validator, asyncValidator) {
3249
        var _this = _super.call(this, validator || null, asyncValidator || null) || this;
3250
        _this.controls = controls;
3251
        _this._initObservables();
3252
        _this._setUpControls();
3253
        _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
3254
        return _this;
3255
    }
3256
    /**
3257
     * Registers a control with the group's list of controls.
3258
     *
3259
     * This method does not update value or validity of the control, so for
3260
     * most cases you'll want to use {\@link FormGroup#addControl} instead.
3261
     * @param {?} name
3262
     * @param {?} control
3263
     * @return {?}
3264
     */
3265
    FormGroup.prototype.registerControl = function (name, control) {
3266
        if (this.controls[name])
3267
            return this.controls[name];
3268
        this.controls[name] = control;
3269
        control.setParent(this);
3270
        control._registerOnCollectionChange(this._onCollectionChange);
3271
        return control;
3272
    };
3273
    /**
3274
     * Add a control to this group.
3275
     * @param {?} name
3276
     * @param {?} control
3277
     * @return {?}
3278
     */
3279
    FormGroup.prototype.addControl = function (name, control) {
3280
        this.registerControl(name, control);
3281
        this.updateValueAndValidity();
3282
        this._onCollectionChange();
3283
    };
3284
    /**
3285
     * Remove a control from this group.
3286
     * @param {?} name
3287
     * @return {?}
3288
     */
3289
    FormGroup.prototype.removeControl = function (name) {
3290
        if (this.controls[name])
3291
            this.controls[name]._registerOnCollectionChange(function () { });
3292
        delete (this.controls[name]);
3293
        this.updateValueAndValidity();
3294
        this._onCollectionChange();
3295
    };
3296
    /**
3297
     * Replace an existing control.
3298
     * @param {?} name
3299
     * @param {?} control
3300
     * @return {?}
3301
     */
3302
    FormGroup.prototype.setControl = function (name, control) {
3303
        if (this.controls[name])
3304
            this.controls[name]._registerOnCollectionChange(function () { });
3305
        delete (this.controls[name]);
3306
        if (control)
3307
            this.registerControl(name, control);
3308
        this.updateValueAndValidity();
3309
        this._onCollectionChange();
3310
    };
3311
    /**
3312
     * Check whether there is an enabled control with the given name in the group.
3313
     *
3314
     * It will return false for disabled controls. If you'd like to check for
3315
     * existence in the group only, use {\@link AbstractControl#get} instead.
3316
     * @param {?} controlName
3317
     * @return {?}
3318
     */
3319
    FormGroup.prototype.contains = function (controlName) {
3320
        return this.controls.hasOwnProperty(controlName) && this.controls[controlName].enabled;
3321
    };
3322
    /**
3323
     *  Sets the value of the {\@link FormGroup}. It accepts an object that matches
3324
     *  the structure of the group, with control names as keys.
3325
     *
3326
     * This method performs strict checks, so it will throw an error if you try
3327
     * to set the value of a control that doesn't exist or if you exclude the
3328
     * value of a control.
3329
     *
3330
     *  ### Example
3331
     *
3332
     *  ```
3333
     *  const form = new FormGroup({
3334
     *     first: new FormControl(),
3335
     *     last: new FormControl()
3336
     *  });
3337
     *  console.log(form.value);   // {first: null, last: null}
3338
     *
3339
     *  form.setValue({first: 'Nancy', last: 'Drew'});
3340
     *  console.log(form.value);   // {first: 'Nancy', last: 'Drew'}
3341
     *
3342
     *  ```
3343
     * @param {?} value
3344
     * @param {?=} options
3345
     * @return {?}
3346
     */
3347
    FormGroup.prototype.setValue = function (value, options) {
3348
        var _this = this;
3349
        if (options === void 0) { options = {}; }
3350
        this._checkAllValuesPresent(value);
3351
        Object.keys(value).forEach(function (name) {
3352
            _this._throwIfControlMissing(name);
3353
            _this.controls[name].setValue(value[name], { onlySelf: true, emitEvent: options.emitEvent });
3354
        });
3355
        this.updateValueAndValidity(options);
3356
    };
3357
    /**
3358
     *  Patches the value of the {\@link FormGroup}. It accepts an object with control
3359
     *  names as keys, and will do its best to match the values to the correct controls
3360
     *  in the group.
3361
     *
3362
     *  It accepts both super-sets and sub-sets of the group without throwing an error.
3363
     *
3364
     *  ### Example
3365
     *
3366
     *  ```
3367
     *  const form = new FormGroup({
3368
     *     first: new FormControl(),
3369
     *     last: new FormControl()
3370
     *  });
3371
     *  console.log(form.value);   // {first: null, last: null}
3372
     *
3373
     *  form.patchValue({first: 'Nancy'});
3374
     *  console.log(form.value);   // {first: 'Nancy', last: null}
3375
     *
3376
     *  ```
3377
     * @param {?} value
3378
     * @param {?=} options
3379
     * @return {?}
3380
     */
3381
    FormGroup.prototype.patchValue = function (value, options) {
3382
        var _this = this;
3383
        if (options === void 0) { options = {}; }
3384
        Object.keys(value).forEach(function (name) {
3385
            if (_this.controls[name]) {
3386
                _this.controls[name].patchValue(value[name], { onlySelf: true, emitEvent: options.emitEvent });
3387
            }
3388
        });
3389
        this.updateValueAndValidity(options);
3390
    };
3391
    /**
3392
     * Resets the {\@link FormGroup}. This means by default:
3393
     *
3394
     * * The group and all descendants are marked `pristine`
3395
     * * The group and all descendants are marked `untouched`
3396
     * * The value of all descendants will be null or null maps
3397
     *
3398
     * You can also reset to a specific form state by passing in a map of states
3399
     * that matches the structure of your form, with control names as keys. The state
3400
     * can be a standalone value or a form state object with both a value and a disabled
3401
     * status.
3402
     *
3403
     * ### Example
3404
     *
3405
     * ```ts
3406
     * this.form.reset({first: 'name', last: 'last name'});
3407
     *
3408
     * console.log(this.form.value);  // {first: 'name', last: 'last name'}
3409
     * ```
3410
     *
3411
     * - OR -
3412
     *
3413
     * ```
3414
     * this.form.reset({
3415
     *   first: {value: 'name', disabled: true},
3416
     *   last: 'last'
3417
     * });
3418
     *
3419
     * console.log(this.form.value);  // {first: 'name', last: 'last name'}
3420
     * console.log(this.form.get('first').status);  // 'DISABLED'
3421
     * ```
3422
     * @param {?=} value
3423
     * @param {?=} options
3424
     * @return {?}
3425
     */
3426
    FormGroup.prototype.reset = function (value, options) {
3427
        if (value === void 0) { value = {}; }
3428
        if (options === void 0) { options = {}; }
3429
        this._forEachChild(function (control, name) {
3430
            control.reset(value[name], { onlySelf: true, emitEvent: options.emitEvent });
3431
        });
3432
        this.updateValueAndValidity(options);
3433
        this._updatePristine(options);
3434
        this._updateTouched(options);
3435
    };
3436
    /**
3437
     * The aggregate value of the {\@link FormGroup}, including any disabled controls.
3438
     *
3439
     * If you'd like to include all values regardless of disabled status, use this method.
3440
     * Otherwise, the `value` property is the best way to get the value of the group.
3441
     * @return {?}
3442
     */
3443
    FormGroup.prototype.getRawValue = function () {
3444
        return this._reduceChildren({}, function (acc, control, name) {
3445
            acc[name] = control instanceof FormControl ? control.value : ((control)).getRawValue();
3446
            return acc;
3447
        });
3448
    };
3449
    /**
3450
     * \@internal
3451
     * @param {?} name
3452
     * @return {?}
3453
     */
3454
    FormGroup.prototype._throwIfControlMissing = function (name) {
3455
        if (!Object.keys(this.controls).length) {
3456
            throw new Error("\n        There are no form controls registered with this group yet.  If you're using ngModel,\n        you may want to check next tick (e.g. use setTimeout).\n      ");
3457
        }
3458
        if (!this.controls[name]) {
3459
            throw new Error("Cannot find form control with name: " + name + ".");
3460
        }
3461
    };
3462
    /**
3463
     * \@internal
3464
     * @param {?} cb
3465
     * @return {?}
3466
     */
3467
    FormGroup.prototype._forEachChild = function (cb) {
3468
        var _this = this;
3469
        Object.keys(this.controls).forEach(function (k) { return cb(_this.controls[k], k); });
3470
    };
3471
    /**
3472
     * \@internal
3473
     * @return {?}
3474
     */
3475
    FormGroup.prototype._setUpControls = function () {
3476
        var _this = this;
3477
        this._forEachChild(function (control) {
3478
            control.setParent(_this);
3479
            control._registerOnCollectionChange(_this._onCollectionChange);
3480
        });
3481
    };
3482
    /**
3483
     * \@internal
3484
     * @return {?}
3485
     */
3486
    FormGroup.prototype._updateValue = function () { this._value = this._reduceValue(); };
3487
    /**
3488
     * \@internal
3489
     * @param {?} condition
3490
     * @return {?}
3491
     */
3492
    FormGroup.prototype._anyControls = function (condition) {
3493
        var _this = this;
3494
        var /** @type {?} */ res = false;
3495
        this._forEachChild(function (control, name) {
3496
            res = res || (_this.contains(name) && condition(control));
3497
        });
3498
        return res;
3499
    };
3500
    /**
3501
     * \@internal
3502
     * @return {?}
3503
     */
3504
    FormGroup.prototype._reduceValue = function () {
3505
        var _this = this;
3506
        return this._reduceChildren({}, function (acc, control, name) {
3507
            if (control.enabled || _this.disabled) {
3508
                acc[name] = control.value;
3509
            }
3510
            return acc;
3511
        });
3512
    };
3513
    /**
3514
     * \@internal
3515
     * @param {?} initValue
3516
     * @param {?} fn
3517
     * @return {?}
3518
     */
3519
    FormGroup.prototype._reduceChildren = function (initValue, fn) {
3520
        var /** @type {?} */ res = initValue;
3521
        this._forEachChild(function (control, name) { res = fn(res, control, name); });
3522
        return res;
3523
    };
3524
    /**
3525
     * \@internal
3526
     * @return {?}
3527
     */
3528
    FormGroup.prototype._allControlsDisabled = function () {
3529
        for (var _i = 0, _a = Object.keys(this.controls); _i < _a.length; _i++) {
3530
            var controlName = _a[_i];
3531
            if (this.controls[controlName].enabled) {
3532
                return false;
3533
            }
3534
        }
3535
        return Object.keys(this.controls).length > 0 || this.disabled;
3536
    };
3537
    /**
3538
     * \@internal
3539
     * @param {?} value
3540
     * @return {?}
3541
     */
3542
    FormGroup.prototype._checkAllValuesPresent = function (value) {
3543
        this._forEachChild(function (control, name) {
3544
            if (value[name] === undefined) {
3545
                throw new Error("Must supply a value for form control with name: '" + name + "'.");
3546
            }
3547
        });
3548
    };
3549
    return FormGroup;
3550
}(AbstractControl));
3551
/**
3552
 * \@whatItDoes Tracks the value and validity state of an array of {\@link FormControl},
3553
 * {\@link FormGroup} or {\@link FormArray} instances.
3554
 *
3555
 * A `FormArray` aggregates the values of each child {\@link FormControl} into an array.
3556
 * It calculates its status by reducing the statuses of its children. For example, if one of
3557
 * the controls in a `FormArray` is invalid, the entire array becomes invalid.
3558
 *
3559
 * `FormArray` is one of the three fundamental building blocks used to define forms in Angular,
3560
 * along with {\@link FormControl} and {\@link FormGroup}.
3561
 *
3562
 * \@howToUse
3563
 *
3564
 * When instantiating a {\@link FormArray}, pass in an array of child controls as the first
3565
 * argument.
3566
 *
3567
 * ### Example
3568
 *
3569
 * ```
3570
 * const arr = new FormArray([
3571
 *   new FormControl('Nancy', Validators.minLength(2)),
3572
 *   new FormControl('Drew'),
3573
 * ]);
3574
 *
3575
 * console.log(arr.value);   // ['Nancy', 'Drew']
3576
 * console.log(arr.status);  // 'VALID'
3577
 * ```
3578
 *
3579
 * You can also include array-level validators as the second arg, or array-level async
3580
 * validators as the third arg. These come in handy when you want to perform validation
3581
 * that considers the value of more than one child control.
3582
 *
3583
 * ### Adding or removing controls
3584
 *
3585
 * To change the controls in the array, use the `push`, `insert`, or `removeAt` methods
3586
 * in `FormArray` itself. These methods ensure the controls are properly tracked in the
3587
 * form's hierarchy. Do not modify the array of `AbstractControl`s used to instantiate
3588
 * the `FormArray` directly, as that will result in strange and unexpected behavior such
3589
 * as broken change detection.
3590
 *
3591
 * * **npm package**: `\@angular/forms`
3592
 *
3593
 * \@stable
3594
 */
3595
var FormArray = (function (_super) {
3596
    __extends(FormArray, _super);
3597
    /**
3598
     * @param {?} controls
3599
     * @param {?=} validator
3600
     * @param {?=} asyncValidator
3601
     */
3602
    function FormArray(controls, validator, asyncValidator) {
3603
        var _this = _super.call(this, validator || null, asyncValidator || null) || this;
3604
        _this.controls = controls;
3605
        _this._initObservables();
3606
        _this._setUpControls();
3607
        _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
3608
        return _this;
3609
    }
3610
    /**
3611
     * Get the {\@link AbstractControl} at the given `index` in the array.
3612
     * @param {?} index
3613
     * @return {?}
3614
     */
3615
    FormArray.prototype.at = function (index) { return this.controls[index]; };
3616
    /**
3617
     * Insert a new {\@link AbstractControl} at the end of the array.
3618
     * @param {?} control
3619
     * @return {?}
3620
     */
3621
    FormArray.prototype.push = function (control) {
3622
        this.controls.push(control);
3623
        this._registerControl(control);
3624
        this.updateValueAndValidity();
3625
        this._onCollectionChange();
3626
    };
3627
    /**
3628
     * Insert a new {\@link AbstractControl} at the given `index` in the array.
3629
     * @param {?} index
3630
     * @param {?} control
3631
     * @return {?}
3632
     */
3633
    FormArray.prototype.insert = function (index, control) {
3634
        this.controls.splice(index, 0, control);
3635
        this._registerControl(control);
3636
        this.updateValueAndValidity();
3637
        this._onCollectionChange();
3638
    };
3639
    /**
3640
     * Remove the control at the given `index` in the array.
3641
     * @param {?} index
3642
     * @return {?}
3643
     */
3644
    FormArray.prototype.removeAt = function (index) {
3645
        if (this.controls[index])
3646
            this.controls[index]._registerOnCollectionChange(function () { });
3647
        this.controls.splice(index, 1);
3648
        this.updateValueAndValidity();
3649
        this._onCollectionChange();
3650
    };
3651
    /**
3652
     * Replace an existing control.
3653
     * @param {?} index
3654
     * @param {?} control
3655
     * @return {?}
3656
     */
3657
    FormArray.prototype.setControl = function (index, control) {
3658
        if (this.controls[index])
3659
            this.controls[index]._registerOnCollectionChange(function () { });
3660
        this.controls.splice(index, 1);
3661
        if (control) {
3662
            this.controls.splice(index, 0, control);
3663
            this._registerControl(control);
3664
        }
3665
        this.updateValueAndValidity();
3666
        this._onCollectionChange();
3667
    };
3668
    Object.defineProperty(FormArray.prototype, "length", {
3669
        /**
3670
         * Length of the control array.
3671
         * @return {?}
3672
         */
3673
        get: function () { return this.controls.length; },
3674
        enumerable: true,
3675
        configurable: true
3676
    });
3677
    /**
3678
     *  Sets the value of the {\@link FormArray}. It accepts an array that matches
3679
     *  the structure of the control.
3680
     *
3681
     * This method performs strict checks, so it will throw an error if you try
3682
     * to set the value of a control that doesn't exist or if you exclude the
3683
     * value of a control.
3684
     *
3685
     *  ### Example
3686
     *
3687
     *  ```
3688
     *  const arr = new FormArray([
3689
     *     new FormControl(),
3690
     *     new FormControl()
3691
     *  ]);
3692
     *  console.log(arr.value);   // [null, null]
3693
     *
3694
     *  arr.setValue(['Nancy', 'Drew']);
3695
     *  console.log(arr.value);   // ['Nancy', 'Drew']
3696
     *  ```
3697
     * @param {?} value
3698
     * @param {?=} options
3699
     * @return {?}
3700
     */
3701
    FormArray.prototype.setValue = function (value, options) {
3702
        var _this = this;
3703
        if (options === void 0) { options = {}; }
3704
        this._checkAllValuesPresent(value);
3705
        value.forEach(function (newValue, index) {
3706
            _this._throwIfControlMissing(index);
3707
            _this.at(index).setValue(newValue, { onlySelf: true, emitEvent: options.emitEvent });
3708
        });
3709
        this.updateValueAndValidity(options);
3710
    };
3711
    /**
3712
     *  Patches the value of the {\@link FormArray}. It accepts an array that matches the
3713
     *  structure of the control, and will do its best to match the values to the correct
3714
     *  controls in the group.
3715
     *
3716
     *  It accepts both super-sets and sub-sets of the array without throwing an error.
3717
     *
3718
     *  ### Example
3719
     *
3720
     *  ```
3721
     *  const arr = new FormArray([
3722
     *     new FormControl(),
3723
     *     new FormControl()
3724
     *  ]);
3725
     *  console.log(arr.value);   // [null, null]
3726
     *
3727
     *  arr.patchValue(['Nancy']);
3728
     *  console.log(arr.value);   // ['Nancy', null]
3729
     *  ```
3730
     * @param {?} value
3731
     * @param {?=} options
3732
     * @return {?}
3733
     */
3734
    FormArray.prototype.patchValue = function (value, options) {
3735
        var _this = this;
3736
        if (options === void 0) { options = {}; }
3737
        value.forEach(function (newValue, index) {
3738
            if (_this.at(index)) {
3739
                _this.at(index).patchValue(newValue, { onlySelf: true, emitEvent: options.emitEvent });
3740
            }
3741
        });
3742
        this.updateValueAndValidity(options);
3743
    };
3744
    /**
3745
     * Resets the {\@link FormArray}. This means by default:
3746
     *
3747
     * * The array and all descendants are marked `pristine`
3748
     * * The array and all descendants are marked `untouched`
3749
     * * The value of all descendants will be null or null maps
3750
     *
3751
     * You can also reset to a specific form state by passing in an array of states
3752
     * that matches the structure of the control. The state can be a standalone value
3753
     * or a form state object with both a value and a disabled status.
3754
     *
3755
     * ### Example
3756
     *
3757
     * ```ts
3758
     * this.arr.reset(['name', 'last name']);
3759
     *
3760
     * console.log(this.arr.value);  // ['name', 'last name']
3761
     * ```
3762
     *
3763
     * - OR -
3764
     *
3765
     * ```
3766
     * this.arr.reset([
3767
     *   {value: 'name', disabled: true},
3768
     *   'last'
3769
     * ]);
3770
     *
3771
     * console.log(this.arr.value);  // ['name', 'last name']
3772
     * console.log(this.arr.get(0).status);  // 'DISABLED'
3773
     * ```
3774
     * @param {?=} value
3775
     * @param {?=} options
3776
     * @return {?}
3777
     */
3778
    FormArray.prototype.reset = function (value, options) {
3779
        if (value === void 0) { value = []; }
3780
        if (options === void 0) { options = {}; }
3781
        this._forEachChild(function (control, index) {
3782
            control.reset(value[index], { onlySelf: true, emitEvent: options.emitEvent });
3783
        });
3784
        this.updateValueAndValidity(options);
3785
        this._updatePristine(options);
3786
        this._updateTouched(options);
3787
    };
3788
    /**
3789
     * The aggregate value of the array, including any disabled controls.
3790
     *
3791
     * If you'd like to include all values regardless of disabled status, use this method.
3792
     * Otherwise, the `value` property is the best way to get the value of the array.
3793
     * @return {?}
3794
     */
3795
    FormArray.prototype.getRawValue = function () {
3796
        return this.controls.map(function (control) {
3797
            return control instanceof FormControl ? control.value : ((control)).getRawValue();
3798
        });
3799
    };
3800
    /**
3801
     * \@internal
3802
     * @param {?} index
3803
     * @return {?}
3804
     */
3805
    FormArray.prototype._throwIfControlMissing = function (index) {
3806
        if (!this.controls.length) {
3807
            throw new Error("\n        There are no form controls registered with this array yet.  If you're using ngModel,\n        you may want to check next tick (e.g. use setTimeout).\n      ");
3808
        }
3809
        if (!this.at(index)) {
3810
            throw new Error("Cannot find form control at index " + index);
3811
        }
3812
    };
3813
    /**
3814
     * \@internal
3815
     * @param {?} cb
3816
     * @return {?}
3817
     */
3818
    FormArray.prototype._forEachChild = function (cb) {
3819
        this.controls.forEach(function (control, index) { cb(control, index); });
3820
    };
3821
    /**
3822
     * \@internal
3823
     * @return {?}
3824
     */
3825
    FormArray.prototype._updateValue = function () {
3826
        var _this = this;
3827
        this._value = this.controls.filter(function (control) { return control.enabled || _this.disabled; })
3828
            .map(function (control) { return control.value; });
3829
    };
3830
    /**
3831
     * \@internal
3832
     * @param {?} condition
3833
     * @return {?}
3834
     */
3835
    FormArray.prototype._anyControls = function (condition) {
3836
        return this.controls.some(function (control) { return control.enabled && condition(control); });
3837
    };
3838
    /**
3839
     * \@internal
3840
     * @return {?}
3841
     */
3842
    FormArray.prototype._setUpControls = function () {
3843
        var _this = this;
3844
        this._forEachChild(function (control) { return _this._registerControl(control); });
3845
    };
3846
    /**
3847
     * \@internal
3848
     * @param {?} value
3849
     * @return {?}
3850
     */
3851
    FormArray.prototype._checkAllValuesPresent = function (value) {
3852
        this._forEachChild(function (control, i) {
3853
            if (value[i] === undefined) {
3854
                throw new Error("Must supply a value for form control at index: " + i + ".");
3855
            }
3856
        });
3857
    };
3858
    /**
3859
     * \@internal
3860
     * @return {?}
3861
     */
3862
    FormArray.prototype._allControlsDisabled = function () {
3863
        for (var _i = 0, _a = this.controls; _i < _a.length; _i++) {
3864
            var control = _a[_i];
3865
            if (control.enabled)
3866
                return false;
3867
        }
3868
        return this.controls.length > 0 || this.disabled;
3869
    };
3870
    /**
3871
     * @param {?} control
3872
     * @return {?}
3873
     */
3874
    FormArray.prototype._registerControl = function (control) {
3875
        control.setParent(this);
3876
        control._registerOnCollectionChange(this._onCollectionChange);
3877
    };
3878
    return FormArray;
3879
}(AbstractControl));
3880
/**
3881
 * @license
3882
 * Copyright Google Inc. All Rights Reserved.
3883
 *
3884
 * Use of this source code is governed by an MIT-style license that can be
3885
 * found in the LICENSE file at https://angular.io/license
3886
 */
3887
var formDirectiveProvider = {
3888
    provide: ControlContainer,
3889
    useExisting: _angular_core.forwardRef(function () { return NgForm; })
3890
};
3891
var resolvedPromise = Promise.resolve(null);
3892
/**
3893
 * \@whatItDoes Creates a top-level {\@link FormGroup} instance and binds it to a form
3894
 * to track aggregate form value and validation status.
3895
 *
3896
 * \@howToUse
3897
 *
3898
 * As soon as you import the `FormsModule`, this directive becomes active by default on
3899
 * all `<form>` tags.  You don't need to add a special selector.
3900
 *
3901
 * You can export the directive into a local template variable using `ngForm` as the key
3902
 * (ex: `#myForm="ngForm"`). This is optional, but useful.  Many properties from the underlying
3903
 * {\@link FormGroup} instance are duplicated on the directive itself, so a reference to it
3904
 * will give you access to the aggregate value and validity status of the form, as well as
3905
 * user interaction properties like `dirty` and `touched`.
3906
 *
3907
 * To register child controls with the form, you'll want to use {\@link NgModel} with a
3908
 * `name` attribute.  You can also use {\@link NgModelGroup} if you'd like to create
3909
 * sub-groups within the form.
3910
 *
3911
 * You can listen to the directive's `ngSubmit` event to be notified when the user has
3912
 * triggered a form submission. The `ngSubmit` event will be emitted with the original form
3913
 * submission event.
3914
 *
3915
 * In template driven forms, all `<form>` tags are automatically tagged as `NgForm`.
3916
 * If you want to import the `FormsModule` but skip its usage in some forms,
3917
 * for example, to use native HTML5 validation, you can add `ngNoForm` and the `<form>`
3918
 * tags won't create an `NgForm` directive. In reactive forms, using `ngNoForm` is
3919
 * unnecessary because the `<form>` tags are inert. In that case, you would
3920
 * refrain from using the `formGroup` directive.
3921
 *
3922
 * {\@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
3923
 *
3924
 * * **npm package**: `\@angular/forms`
3925
 *
3926
 * * **NgModule**: `FormsModule`
3927
 *
3928
 *  \@stable
3929
 */
3930
var NgForm = (function (_super) {
3931
    __extends(NgForm, _super);
3932
    /**
3933
     * @param {?} validators
3934
     * @param {?} asyncValidators
3935
     */
3936
    function NgForm(validators, asyncValidators) {
3937
        var _this = _super.call(this) || this;
3938
        _this._submitted = false;
3939
        _this.ngSubmit = new _angular_core.EventEmitter();
3940
        _this.form =
3941
            new FormGroup({}, composeValidators(validators), composeAsyncValidators(asyncValidators));
3942
        return _this;
3943
    }
3944
    Object.defineProperty(NgForm.prototype, "submitted", {
3945
        /**
3946
         * @return {?}
3947
         */
3948
        get: function () { return this._submitted; },
3949
        enumerable: true,
3950
        configurable: true
3951
    });
3952
    Object.defineProperty(NgForm.prototype, "formDirective", {
3953
        /**
3954
         * @return {?}
3955
         */
3956
        get: function () { return this; },
3957
        enumerable: true,
3958
        configurable: true
3959
    });
3960
    Object.defineProperty(NgForm.prototype, "control", {
3961
        /**
3962
         * @return {?}
3963
         */
3964
        get: function () { return this.form; },
3965
        enumerable: true,
3966
        configurable: true
3967
    });
3968
    Object.defineProperty(NgForm.prototype, "path", {
3969
        /**
3970
         * @return {?}
3971
         */
3972
        get: function () { return []; },
3973
        enumerable: true,
3974
        configurable: true
3975
    });
3976
    Object.defineProperty(NgForm.prototype, "controls", {
3977
        /**
3978
         * @return {?}
3979
         */
3980
        get: function () { return this.form.controls; },
3981
        enumerable: true,
3982
        configurable: true
3983
    });
3984
    /**
3985
     * @param {?} dir
3986
     * @return {?}
3987
     */
3988
    NgForm.prototype.addControl = function (dir) {
3989
        var _this = this;
3990
        resolvedPromise.then(function () {
3991
            var /** @type {?} */ container = _this._findContainer(dir.path);
3992
            dir._control = (container.registerControl(dir.name, dir.control));
3993
            setUpControl(dir.control, dir);
3994
            dir.control.updateValueAndValidity({ emitEvent: false });
3995
        });
3996
    };
3997
    /**
3998
     * @param {?} dir
3999
     * @return {?}
4000
     */
4001
    NgForm.prototype.getControl = function (dir) { return (this.form.get(dir.path)); };
4002
    /**
4003
     * @param {?} dir
4004
     * @return {?}
4005
     */
4006
    NgForm.prototype.removeControl = function (dir) {
4007
        var _this = this;
4008
        resolvedPromise.then(function () {
4009
            var /** @type {?} */ container = _this._findContainer(dir.path);
4010
            if (container) {
4011
                container.removeControl(dir.name);
4012
            }
4013
        });
4014
    };
4015
    /**
4016
     * @param {?} dir
4017
     * @return {?}
4018
     */
4019
    NgForm.prototype.addFormGroup = function (dir) {
4020
        var _this = this;
4021
        resolvedPromise.then(function () {
4022
            var /** @type {?} */ container = _this._findContainer(dir.path);
4023
            var /** @type {?} */ group = new FormGroup({});
4024
            setUpFormContainer(group, dir);
4025
            container.registerControl(dir.name, group);
4026
            group.updateValueAndValidity({ emitEvent: false });
4027
        });
4028
    };
4029
    /**
4030
     * @param {?} dir
4031
     * @return {?}
4032
     */
4033
    NgForm.prototype.removeFormGroup = function (dir) {
4034
        var _this = this;
4035
        resolvedPromise.then(function () {
4036
            var /** @type {?} */ container = _this._findContainer(dir.path);
4037
            if (container) {
4038
                container.removeControl(dir.name);
4039
            }
4040
        });
4041
    };
4042
    /**
4043
     * @param {?} dir
4044
     * @return {?}
4045
     */
4046
    NgForm.prototype.getFormGroup = function (dir) { return (this.form.get(dir.path)); };
4047
    /**
4048
     * @param {?} dir
4049
     * @param {?} value
4050
     * @return {?}
4051
     */
4052
    NgForm.prototype.updateModel = function (dir, value) {
4053
        var _this = this;
4054
        resolvedPromise.then(function () {
4055
            var /** @type {?} */ ctrl = (_this.form.get(/** @type {?} */ ((dir.path))));
4056
            ctrl.setValue(value);
4057
        });
4058
    };
4059
    /**
4060
     * @param {?} value
4061
     * @return {?}
4062
     */
4063
    NgForm.prototype.setValue = function (value) { this.control.setValue(value); };
4064
    /**
4065
     * @param {?} $event
4066
     * @return {?}
4067
     */
4068
    NgForm.prototype.onSubmit = function ($event) {
4069
        this._submitted = true;
4070
        this.ngSubmit.emit($event);
4071
        return false;
4072
    };
4073
    /**
4074
     * @return {?}
4075
     */
4076
    NgForm.prototype.onReset = function () { this.resetForm(); };
4077
    /**
4078
     * @param {?=} value
4079
     * @return {?}
4080
     */
4081
    NgForm.prototype.resetForm = function (value) {
4082
        if (value === void 0) { value = undefined; }
4083
        this.form.reset(value);
4084
        this._submitted = false;
4085
    };
4086
    /**
4087
     * \@internal
4088
     * @param {?} path
4089
     * @return {?}
4090
     */
4091
    NgForm.prototype._findContainer = function (path) {
4092
        path.pop();
4093
        return path.length ? (this.form.get(path)) : this.form;
4094
    };
4095
    return NgForm;
4096
}(ControlContainer));
4097
NgForm.decorators = [
4098
    { type: _angular_core.Directive, args: [{
4099
                selector: 'form:not([ngNoForm]):not([formGroup]),ngForm,[ngForm]',
4100
                providers: [formDirectiveProvider],
4101
                host: { '(submit)': 'onSubmit($event)', '(reset)': 'onReset()' },
4102
                outputs: ['ngSubmit'],
4103
                exportAs: 'ngForm'
4104
            },] },
4105
];
4106
/**
4107
 * @nocollapse
4108
 */
4109
NgForm.ctorParameters = function () { return [
4110
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
4111
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
4112
]; };
4113
/**
4114
 * @license
4115
 * Copyright Google Inc. All Rights Reserved.
4116
 *
4117
 * Use of this source code is governed by an MIT-style license that can be
4118
 * found in the LICENSE file at https://angular.io/license
4119
 */
4120
var FormErrorExamples = {
4121
    formControlName: "\n    <div [formGroup]=\"myGroup\">\n      <input formControlName=\"firstName\">\n    </div>\n\n    In your class:\n\n    this.myGroup = new FormGroup({\n       firstName: new FormControl()\n    });",
4122
    formGroupName: "\n    <div [formGroup]=\"myGroup\">\n       <div formGroupName=\"person\">\n          <input formControlName=\"firstName\">\n       </div>\n    </div>\n\n    In your class:\n\n    this.myGroup = new FormGroup({\n       person: new FormGroup({ firstName: new FormControl() })\n    });",
4123
    formArrayName: "\n    <div [formGroup]=\"myGroup\">\n      <div formArrayName=\"cities\">\n        <div *ngFor=\"let city of cityArray.controls; index as i\">\n          <input [formControlName]=\"i\">\n        </div>\n      </div>\n    </div>\n\n    In your class:\n\n    this.cityArray = new FormArray([new FormControl('SF')]);\n    this.myGroup = new FormGroup({\n      cities: this.cityArray\n    });",
4124
    ngModelGroup: "\n    <form>\n       <div ngModelGroup=\"person\">\n          <input [(ngModel)]=\"person.name\" name=\"firstName\">\n       </div>\n    </form>",
4125
    ngModelWithFormGroup: "\n    <div [formGroup]=\"myGroup\">\n       <input formControlName=\"firstName\">\n       <input [(ngModel)]=\"showMoreControls\" [ngModelOptions]=\"{standalone: true}\">\n    </div>\n  "
4126
};
4127
/**
4128
 * @license
4129
 * Copyright Google Inc. All Rights Reserved.
4130
 *
4131
 * Use of this source code is governed by an MIT-style license that can be
4132
 * found in the LICENSE file at https://angular.io/license
4133
 */
4134
var TemplateDrivenErrors = (function () {
4135
    function TemplateDrivenErrors() {
4136
    }
4137
    /**
4138
     * @return {?}
4139
     */
4140
    TemplateDrivenErrors.modelParentException = function () {
4141
        throw new Error("\n      ngModel cannot be used to register form controls with a parent formGroup directive.  Try using\n      formGroup's partner directive \"formControlName\" instead.  Example:\n\n      " + FormErrorExamples.formControlName + "\n\n      Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:\n\n      Example:\n\n      " + FormErrorExamples.ngModelWithFormGroup);
4142
    };
4143
    /**
4144
     * @return {?}
4145
     */
4146
    TemplateDrivenErrors.formGroupNameException = function () {
4147
        throw new Error("\n      ngModel cannot be used to register form controls with a parent formGroupName or formArrayName directive.\n\n      Option 1: Use formControlName instead of ngModel (reactive strategy):\n\n      " + FormErrorExamples.formGroupName + "\n\n      Option 2:  Update ngModel's parent be ngModelGroup (template-driven strategy):\n\n      " + FormErrorExamples.ngModelGroup);
4148
    };
4149
    /**
4150
     * @return {?}
4151
     */
4152
    TemplateDrivenErrors.missingNameException = function () {
4153
        throw new Error("If ngModel is used within a form tag, either the name attribute must be set or the form\n      control must be defined as 'standalone' in ngModelOptions.\n\n      Example 1: <input [(ngModel)]=\"person.firstName\" name=\"first\">\n      Example 2: <input [(ngModel)]=\"person.firstName\" [ngModelOptions]=\"{standalone: true}\">");
4154
    };
4155
    /**
4156
     * @return {?}
4157
     */
4158
    TemplateDrivenErrors.modelGroupParentException = function () {
4159
        throw new Error("\n      ngModelGroup cannot be used with a parent formGroup directive.\n\n      Option 1: Use formGroupName instead of ngModelGroup (reactive strategy):\n\n      " + FormErrorExamples.formGroupName + "\n\n      Option 2:  Use a regular form tag instead of the formGroup directive (template-driven strategy):\n\n      " + FormErrorExamples.ngModelGroup);
4160
    };
4161
    return TemplateDrivenErrors;
4162
}());
4163
/**
4164
 * @license
4165
 * Copyright Google Inc. All Rights Reserved.
4166
 *
4167
 * Use of this source code is governed by an MIT-style license that can be
4168
 * found in the LICENSE file at https://angular.io/license
4169
 */
4170
var modelGroupProvider = {
4171
    provide: ControlContainer,
4172
    useExisting: _angular_core.forwardRef(function () { return NgModelGroup; })
4173
};
4174
/**
4175
 * \@whatItDoes Creates and binds a {\@link FormGroup} instance to a DOM element.
4176
 *
4177
 * \@howToUse
4178
 *
4179
 * This directive can only be used as a child of {\@link NgForm} (or in other words,
4180
 * within `<form>` tags).
4181
 *
4182
 * Use this directive if you'd like to create a sub-group within a form. This can
4183
 * come in handy if you want to validate a sub-group of your form separately from
4184
 * the rest of your form, or if some values in your domain model make more sense to
4185
 * consume together in a nested object.
4186
 *
4187
 * Pass in the name you'd like this sub-group to have and it will become the key
4188
 * for the sub-group in the form's full value. You can also export the directive into
4189
 * a local template variable using `ngModelGroup` (ex: `#myGroup="ngModelGroup"`).
4190
 *
4191
 * {\@example forms/ts/ngModelGroup/ng_model_group_example.ts region='Component'}
4192
 *
4193
 * * **npm package**: `\@angular/forms`
4194
 *
4195
 * * **NgModule**: `FormsModule`
4196
 *
4197
 * \@stable
4198
 */
4199
var NgModelGroup = (function (_super) {
4200
    __extends(NgModelGroup, _super);
4201
    /**
4202
     * @param {?} parent
4203
     * @param {?} validators
4204
     * @param {?} asyncValidators
4205
     */
4206
    function NgModelGroup(parent, validators, asyncValidators) {
4207
        var _this = _super.call(this) || this;
4208
        _this._parent = parent;
4209
        _this._validators = validators;
4210
        _this._asyncValidators = asyncValidators;
4211
        return _this;
4212
    }
4213
    /**
4214
     * \@internal
4215
     * @return {?}
4216
     */
4217
    NgModelGroup.prototype._checkParentType = function () {
4218
        if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm)) {
4219
            TemplateDrivenErrors.modelGroupParentException();
4220
        }
4221
    };
4222
    return NgModelGroup;
4223
}(AbstractFormGroupDirective));
4224
NgModelGroup.decorators = [
4225
    { type: _angular_core.Directive, args: [{ selector: '[ngModelGroup]', providers: [modelGroupProvider], exportAs: 'ngModelGroup' },] },
4226
];
4227
/**
4228
 * @nocollapse
4229
 */
4230
NgModelGroup.ctorParameters = function () { return [
4231
    { type: ControlContainer, decorators: [{ type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
4232
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
4233
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
4234
]; };
4235
NgModelGroup.propDecorators = {
4236
    'name': [{ type: _angular_core.Input, args: ['ngModelGroup',] },],
4237
};
4238
/**
4239
 * @license
4240
 * Copyright Google Inc. All Rights Reserved.
4241
 *
4242
 * Use of this source code is governed by an MIT-style license that can be
4243
 * found in the LICENSE file at https://angular.io/license
4244
 */
4245
var formControlBinding = {
4246
    provide: NgControl,
4247
    useExisting: _angular_core.forwardRef(function () { return NgModel; })
4248
};
4249
/**
4250
 * `ngModel` forces an additional change detection run when its inputs change:
4251
 * E.g.:
4252
 * ```
4253
 * <div>{{myModel.valid}}</div>
4254
 * <input [(ngModel)]="myValue" #myModel="ngModel">
4255
 * ```
4256
 * I.e. `ngModel` can export itself on the element and then be used in the template.
4257
 * Normally, this would result in expressions before the `input` that use the exported directive
4258
 * to have and old value as they have been
4259
 * dirty checked before. As this is a very common case for `ngModel`, we added this second change
4260
 * detection run.
4261
 *
4262
 * Notes:
4263
 * - this is just one extra run no matter how many `ngModel` have been changed.
4264
 * - this is a general problem when using `exportAs` for directives!
4265
 */
4266
var resolvedPromise$1 = Promise.resolve(null);
4267
/**
4268
 * \@whatItDoes Creates a {\@link FormControl} instance from a domain model and binds it
4269
 * to a form control element.
4270
 *
4271
 * The {\@link FormControl} instance will track the value, user interaction, and
4272
 * validation status of the control and keep the view synced with the model. If used
4273
 * within a parent form, the directive will also register itself with the form as a child
4274
 * control.
4275
 *
4276
 * \@howToUse
4277
 *
4278
 * This directive can be used by itself or as part of a larger form. All you need is the
4279
 * `ngModel` selector to activate it.
4280
 *
4281
 * It accepts a domain model as an optional {\@link Input}. If you have a one-way binding
4282
 * to `ngModel` with `[]` syntax, changing the value of the domain model in the component
4283
 * class will set the value in the view. If you have a two-way binding with `[()]` syntax
4284
 * (also known as 'banana-box syntax'), the value in the UI will always be synced back to
4285
 * the domain model in your class as well.
4286
 *
4287
 * If you wish to inspect the properties of the associated {\@link FormControl} (like
4288
 * validity state), you can also export the directive into a local template variable using
4289
 * `ngModel` as the key (ex: `#myVar="ngModel"`). You can then access the control using the
4290
 * directive's `control` property, but most properties you'll need (like `valid` and `dirty`)
4291
 * will fall through to the control anyway, so you can access them directly. You can see a
4292
 * full list of properties directly available in {\@link AbstractControlDirective}.
4293
 *
4294
 * The following is an example of a simple standalone control using `ngModel`:
4295
 *
4296
 * {\@example forms/ts/simpleNgModel/simple_ng_model_example.ts region='Component'}
4297
 *
4298
 * When using the `ngModel` within `<form>` tags, you'll also need to supply a `name` attribute
4299
 * so that the control can be registered with the parent form under that name.
4300
 *
4301
 * It's worth noting that in the context of a parent form, you often can skip one-way or
4302
 * two-way binding because the parent form will sync the value for you. You can access
4303
 * its properties by exporting it into a local template variable using `ngForm` (ex:
4304
 * `#f="ngForm"`). Then you can pass it where it needs to go on submit.
4305
 *
4306
 * If you do need to populate initial values into your form, using a one-way binding for
4307
 * `ngModel` tends to be sufficient as long as you use the exported form's value rather
4308
 * than the domain model's value on submit.
4309
 *
4310
 * Take a look at an example of using `ngModel` within a form:
4311
 *
4312
 * {\@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
4313
 *
4314
 * To see `ngModel` examples with different form control types, see:
4315
 *
4316
 * * Radio buttons: {\@link RadioControlValueAccessor}
4317
 * * Selects: {\@link SelectControlValueAccessor}
4318
 *
4319
 * **npm package**: `\@angular/forms`
4320
 *
4321
 * **NgModule**: `FormsModule`
4322
 *
4323
 *  \@stable
4324
 */
4325
var NgModel = (function (_super) {
4326
    __extends(NgModel, _super);
4327
    /**
4328
     * @param {?} parent
4329
     * @param {?} validators
4330
     * @param {?} asyncValidators
4331
     * @param {?} valueAccessors
4332
     */
4333
    function NgModel(parent, validators, asyncValidators, valueAccessors) {
4334
        var _this = _super.call(this) || this;
4335
        /**
4336
         * \@internal
4337
         */
4338
        _this._control = new FormControl();
4339
        /**
4340
         * \@internal
4341
         */
4342
        _this._registered = false;
4343
        _this.update = new _angular_core.EventEmitter();
4344
        _this._parent = parent;
4345
        _this._rawValidators = validators || [];
4346
        _this._rawAsyncValidators = asyncValidators || [];
4347
        _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
4348
        return _this;
4349
    }
4350
    /**
4351
     * @param {?} changes
4352
     * @return {?}
4353
     */
4354
    NgModel.prototype.ngOnChanges = function (changes) {
4355
        this._checkForErrors();
4356
        if (!this._registered)
4357
            this._setUpControl();
4358
        if ('isDisabled' in changes) {
4359
            this._updateDisabled(changes);
4360
        }
4361
        if (isPropertyUpdated(changes, this.viewModel)) {
4362
            this._updateValue(this.model);
4363
            this.viewModel = this.model;
4364
        }
4365
    };
4366
    /**
4367
     * @return {?}
4368
     */
4369
    NgModel.prototype.ngOnDestroy = function () { this.formDirective && this.formDirective.removeControl(this); };
4370
    Object.defineProperty(NgModel.prototype, "control", {
4371
        /**
4372
         * @return {?}
4373
         */
4374
        get: function () { return this._control; },
4375
        enumerable: true,
4376
        configurable: true
4377
    });
4378
    Object.defineProperty(NgModel.prototype, "path", {
4379
        /**
4380
         * @return {?}
4381
         */
4382
        get: function () {
4383
            return this._parent ? controlPath(this.name, this._parent) : [this.name];
4384
        },
4385
        enumerable: true,
4386
        configurable: true
4387
    });
4388
    Object.defineProperty(NgModel.prototype, "formDirective", {
4389
        /**
4390
         * @return {?}
4391
         */
4392
        get: function () { return this._parent ? this._parent.formDirective : null; },
4393
        enumerable: true,
4394
        configurable: true
4395
    });
4396
    Object.defineProperty(NgModel.prototype, "validator", {
4397
        /**
4398
         * @return {?}
4399
         */
4400
        get: function () { return composeValidators(this._rawValidators); },
4401
        enumerable: true,
4402
        configurable: true
4403
    });
4404
    Object.defineProperty(NgModel.prototype, "asyncValidator", {
4405
        /**
4406
         * @return {?}
4407
         */
4408
        get: function () {
4409
            return composeAsyncValidators(this._rawAsyncValidators);
4410
        },
4411
        enumerable: true,
4412
        configurable: true
4413
    });
4414
    /**
4415
     * @param {?} newValue
4416
     * @return {?}
4417
     */
4418
    NgModel.prototype.viewToModelUpdate = function (newValue) {
4419
        this.viewModel = newValue;
4420
        this.update.emit(newValue);
4421
    };
4422
    /**
4423
     * @return {?}
4424
     */
4425
    NgModel.prototype._setUpControl = function () {
4426
        this._isStandalone() ? this._setUpStandalone() :
4427
            this.formDirective.addControl(this);
4428
        this._registered = true;
4429
    };
4430
    /**
4431
     * @return {?}
4432
     */
4433
    NgModel.prototype._isStandalone = function () {
4434
        return !this._parent || !!(this.options && this.options.standalone);
4435
    };
4436
    /**
4437
     * @return {?}
4438
     */
4439
    NgModel.prototype._setUpStandalone = function () {
4440
        setUpControl(this._control, this);
4441
        this._control.updateValueAndValidity({ emitEvent: false });
4442
    };
4443
    /**
4444
     * @return {?}
4445
     */
4446
    NgModel.prototype._checkForErrors = function () {
4447
        if (!this._isStandalone()) {
4448
            this._checkParentType();
4449
        }
4450
        this._checkName();
4451
    };
4452
    /**
4453
     * @return {?}
4454
     */
4455
    NgModel.prototype._checkParentType = function () {
4456
        if (!(this._parent instanceof NgModelGroup) &&
4457
            this._parent instanceof AbstractFormGroupDirective) {
4458
            TemplateDrivenErrors.formGroupNameException();
4459
        }
4460
        else if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm)) {
4461
            TemplateDrivenErrors.modelParentException();
4462
        }
4463
    };
4464
    /**
4465
     * @return {?}
4466
     */
4467
    NgModel.prototype._checkName = function () {
4468
        if (this.options && this.options.name)
4469
            this.name = this.options.name;
4470
        if (!this._isStandalone() && !this.name) {
4471
            TemplateDrivenErrors.missingNameException();
4472
        }
4473
    };
4474
    /**
4475
     * @param {?} value
4476
     * @return {?}
4477
     */
4478
    NgModel.prototype._updateValue = function (value) {
4479
        var _this = this;
4480
        resolvedPromise$1.then(function () { _this.control.setValue(value, { emitViewToModelChange: false }); });
4481
    };
4482
    /**
4483
     * @param {?} changes
4484
     * @return {?}
4485
     */
4486
    NgModel.prototype._updateDisabled = function (changes) {
4487
        var _this = this;
4488
        var /** @type {?} */ disabledValue = changes['isDisabled'].currentValue;
4489
        var /** @type {?} */ isDisabled = disabledValue === '' || (disabledValue && disabledValue !== 'false');
4490
        resolvedPromise$1.then(function () {
4491
            if (isDisabled && !_this.control.disabled) {
4492
                _this.control.disable();
4493
            }
4494
            else if (!isDisabled && _this.control.disabled) {
4495
                _this.control.enable();
4496
            }
4497
        });
4498
    };
4499
    return NgModel;
4500
}(NgControl));
4501
NgModel.decorators = [
4502
    { type: _angular_core.Directive, args: [{
4503
                selector: '[ngModel]:not([formControlName]):not([formControl])',
4504
                providers: [formControlBinding],
4505
                exportAs: 'ngModel'
4506
            },] },
4507
];
4508
/**
4509
 * @nocollapse
4510
 */
4511
NgModel.ctorParameters = function () { return [
4512
    { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host },] },
4513
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
4514
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
4515
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALUE_ACCESSOR,] },] },
4516
]; };
4517
NgModel.propDecorators = {
4518
    'name': [{ type: _angular_core.Input },],
4519
    'isDisabled': [{ type: _angular_core.Input, args: ['disabled',] },],
4520
    'model': [{ type: _angular_core.Input, args: ['ngModel',] },],
4521
    'options': [{ type: _angular_core.Input, args: ['ngModelOptions',] },],
4522
    'update': [{ type: _angular_core.Output, args: ['ngModelChange',] },],
4523
};
4524
/**
4525
 * @license
4526
 * Copyright Google Inc. All Rights Reserved.
4527
 *
4528
 * Use of this source code is governed by an MIT-style license that can be
4529
 * found in the LICENSE file at https://angular.io/license
4530
 */
4531
var ReactiveErrors = (function () {
4532
    function ReactiveErrors() {
4533
    }
4534
    /**
4535
     * @return {?}
4536
     */
4537
    ReactiveErrors.controlParentException = function () {
4538
        throw new Error("formControlName must be used with a parent formGroup directive.  You'll want to add a formGroup\n       directive and pass it an existing FormGroup instance (you can create one in your class).\n\n      Example:\n\n      " + FormErrorExamples.formControlName);
4539
    };
4540
    /**
4541
     * @return {?}
4542
     */
4543
    ReactiveErrors.ngModelGroupException = function () {
4544
        throw new Error("formControlName cannot be used with an ngModelGroup parent. It is only compatible with parents\n       that also have a \"form\" prefix: formGroupName, formArrayName, or formGroup.\n\n       Option 1:  Update the parent to be formGroupName (reactive form strategy)\n\n        " + FormErrorExamples.formGroupName + "\n\n        Option 2: Use ngModel instead of formControlName (template-driven strategy)\n\n        " + FormErrorExamples.ngModelGroup);
4545
    };
4546
    /**
4547
     * @return {?}
4548
     */
4549
    ReactiveErrors.missingFormException = function () {
4550
        throw new Error("formGroup expects a FormGroup instance. Please pass one in.\n\n       Example:\n\n       " + FormErrorExamples.formControlName);
4551
    };
4552
    /**
4553
     * @return {?}
4554
     */
4555
    ReactiveErrors.groupParentException = function () {
4556
        throw new Error("formGroupName must be used with a parent formGroup directive.  You'll want to add a formGroup\n      directive and pass it an existing FormGroup instance (you can create one in your class).\n\n      Example:\n\n      " + FormErrorExamples.formGroupName);
4557
    };
4558
    /**
4559
     * @return {?}
4560
     */
4561
    ReactiveErrors.arrayParentException = function () {
4562
        throw new Error("formArrayName must be used with a parent formGroup directive.  You'll want to add a formGroup\n       directive and pass it an existing FormGroup instance (you can create one in your class).\n\n        Example:\n\n        " + FormErrorExamples.formArrayName);
4563
    };
4564
    /**
4565
     * @return {?}
4566
     */
4567
    ReactiveErrors.disabledAttrWarning = function () {
4568
        console.warn("\n      It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true\n      when you set up this control in your component class, the disabled attribute will actually be set in the DOM for\n      you. We recommend using this approach to avoid 'changed after checked' errors.\n       \n      Example: \n      form = new FormGroup({\n        first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),\n        last: new FormControl('Drew', Validators.required)\n      });\n    ");
4569
    };
4570
    return ReactiveErrors;
4571
}());
4572
/**
4573
 * @license
4574
 * Copyright Google Inc. All Rights Reserved.
4575
 *
4576
 * Use of this source code is governed by an MIT-style license that can be
4577
 * found in the LICENSE file at https://angular.io/license
4578
 */
4579
var formControlBinding$1 = {
4580
    provide: NgControl,
4581
    useExisting: _angular_core.forwardRef(function () { return FormControlDirective; })
4582
};
4583
/**
4584
 * \@whatItDoes Syncs a standalone {\@link FormControl} instance to a form control element.
4585
 *
4586
 * In other words, this directive ensures that any values written to the {\@link FormControl}
4587
 * instance programmatically will be written to the DOM element (model -> view). Conversely,
4588
 * any values written to the DOM element through user input will be reflected in the
4589
 * {\@link FormControl} instance (view -> model).
4590
 *
4591
 * \@howToUse
4592
 *
4593
 * Use this directive if you'd like to create and manage a {\@link FormControl} instance directly.
4594
 * Simply create a {\@link FormControl}, save it to your component class, and pass it into the
4595
 * {\@link FormControlDirective}.
4596
 *
4597
 * This directive is designed to be used as a standalone control.  Unlike {\@link FormControlName},
4598
 * it does not require that your {\@link FormControl} instance be part of any parent
4599
 * {\@link FormGroup}, and it won't be registered to any {\@link FormGroupDirective} that
4600
 * exists above it.
4601
 *
4602
 * **Get the value**: the `value` property is always synced and available on the
4603
 * {\@link FormControl} instance. See a full list of available properties in
4604
 * {\@link AbstractControl}.
4605
 *
4606
 * **Set the value**: You can pass in an initial value when instantiating the {\@link FormControl},
4607
 * or you can set it programmatically later using {\@link AbstractControl#setValue setValue} or
4608
 * {\@link AbstractControl#patchValue patchValue}.
4609
 *
4610
 * **Listen to value**: If you want to listen to changes in the value of the control, you can
4611
 * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event.  You can also listen to
4612
 * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
4613
 * re-calculated.
4614
 *
4615
 * ### Example
4616
 *
4617
 * {\@example forms/ts/simpleFormControl/simple_form_control_example.ts region='Component'}
4618
 *
4619
 * * **npm package**: `\@angular/forms`
4620
 *
4621
 * * **NgModule**: `ReactiveFormsModule`
4622
 *
4623
 *  \@stable
4624
 */
4625
var FormControlDirective = (function (_super) {
4626
    __extends(FormControlDirective, _super);
4627
    /**
4628
     * @param {?} validators
4629
     * @param {?} asyncValidators
4630
     * @param {?} valueAccessors
4631
     */
4632
    function FormControlDirective(validators, asyncValidators, valueAccessors) {
4633
        var _this = _super.call(this) || this;
4634
        _this.update = new _angular_core.EventEmitter();
4635
        _this._rawValidators = validators || [];
4636
        _this._rawAsyncValidators = asyncValidators || [];
4637
        _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
4638
        return _this;
4639
    }
4640
    Object.defineProperty(FormControlDirective.prototype, "isDisabled", {
4641
        /**
4642
         * @param {?} isDisabled
4643
         * @return {?}
4644
         */
4645
        set: function (isDisabled) { ReactiveErrors.disabledAttrWarning(); },
4646
        enumerable: true,
4647
        configurable: true
4648
    });
4649
    /**
4650
     * @param {?} changes
4651
     * @return {?}
4652
     */
4653
    FormControlDirective.prototype.ngOnChanges = function (changes) {
4654
        if (this._isControlChanged(changes)) {
4655
            setUpControl(this.form, this);
4656
            if (this.control.disabled && ((this.valueAccessor)).setDisabledState) {
4657
                ((((this.valueAccessor)).setDisabledState))(true);
4658
            }
4659
            this.form.updateValueAndValidity({ emitEvent: false });
4660
        }
4661
        if (isPropertyUpdated(changes, this.viewModel)) {
4662
            this.form.setValue(this.model);
4663
            this.viewModel = this.model;
4664
        }
4665
    };
4666
    Object.defineProperty(FormControlDirective.prototype, "path", {
4667
        /**
4668
         * @return {?}
4669
         */
4670
        get: function () { return []; },
4671
        enumerable: true,
4672
        configurable: true
4673
    });
4674
    Object.defineProperty(FormControlDirective.prototype, "validator", {
4675
        /**
4676
         * @return {?}
4677
         */
4678
        get: function () { return composeValidators(this._rawValidators); },
4679
        enumerable: true,
4680
        configurable: true
4681
    });
4682
    Object.defineProperty(FormControlDirective.prototype, "asyncValidator", {
4683
        /**
4684
         * @return {?}
4685
         */
4686
        get: function () {
4687
            return composeAsyncValidators(this._rawAsyncValidators);
4688
        },
4689
        enumerable: true,
4690
        configurable: true
4691
    });
4692
    Object.defineProperty(FormControlDirective.prototype, "control", {
4693
        /**
4694
         * @return {?}
4695
         */
4696
        get: function () { return this.form; },
4697
        enumerable: true,
4698
        configurable: true
4699
    });
4700
    /**
4701
     * @param {?} newValue
4702
     * @return {?}
4703
     */
4704
    FormControlDirective.prototype.viewToModelUpdate = function (newValue) {
4705
        this.viewModel = newValue;
4706
        this.update.emit(newValue);
4707
    };
4708
    /**
4709
     * @param {?} changes
4710
     * @return {?}
4711
     */
4712
    FormControlDirective.prototype._isControlChanged = function (changes) {
4713
        return changes.hasOwnProperty('form');
4714
    };
4715
    return FormControlDirective;
4716
}(NgControl));
4717
FormControlDirective.decorators = [
4718
    { type: _angular_core.Directive, args: [{ selector: '[formControl]', providers: [formControlBinding$1], exportAs: 'ngForm' },] },
4719
];
4720
/**
4721
 * @nocollapse
4722
 */
4723
FormControlDirective.ctorParameters = function () { return [
4724
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
4725
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
4726
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALUE_ACCESSOR,] },] },
4727
]; };
4728
FormControlDirective.propDecorators = {
4729
    'form': [{ type: _angular_core.Input, args: ['formControl',] },],
4730
    'model': [{ type: _angular_core.Input, args: ['ngModel',] },],
4731
    'update': [{ type: _angular_core.Output, args: ['ngModelChange',] },],
4732
    'isDisabled': [{ type: _angular_core.Input, args: ['disabled',] },],
4733
};
4734
/**
4735
 * @license
4736
 * Copyright Google Inc. All Rights Reserved.
4737
 *
4738
 * Use of this source code is governed by an MIT-style license that can be
4739
 * found in the LICENSE file at https://angular.io/license
4740
 */
4741
var formDirectiveProvider$1 = {
4742
    provide: ControlContainer,
4743
    useExisting: _angular_core.forwardRef(function () { return FormGroupDirective; })
4744
};
4745
/**
4746
 * \@whatItDoes Binds an existing {\@link FormGroup} to a DOM element.
4747
 *
4748
 * \@howToUse
4749
 *
4750
 * This directive accepts an existing {\@link FormGroup} instance. It will then use this
4751
 * {\@link FormGroup} instance to match any child {\@link FormControl}, {\@link FormGroup},
4752
 * and {\@link FormArray} instances to child {\@link FormControlName}, {\@link FormGroupName},
4753
 * and {\@link FormArrayName} directives.
4754
 *
4755
 * **Set value**: You can set the form's initial value when instantiating the
4756
 * {\@link FormGroup}, or you can set it programmatically later using the {\@link FormGroup}'s
4757
 * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}
4758
 * methods.
4759
 *
4760
 * **Listen to value**: If you want to listen to changes in the value of the form, you can subscribe
4761
 * to the {\@link FormGroup}'s {\@link AbstractControl#valueChanges valueChanges} event.  You can also
4762
 * listen to its {\@link AbstractControl#statusChanges statusChanges} event to be notified when the
4763
 * validation status is re-calculated.
4764
 *
4765
 * Furthermore, you can listen to the directive's `ngSubmit` event to be notified when the user has
4766
 * triggered a form submission. The `ngSubmit` event will be emitted with the original form
4767
 * submission event.
4768
 *
4769
 * ### Example
4770
 *
4771
 * In this example, we create form controls for first name and last name.
4772
 *
4773
 * {\@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
4774
 *
4775
 * **npm package**: `\@angular/forms`
4776
 *
4777
 * **NgModule**: {\@link ReactiveFormsModule}
4778
 *
4779
 *  \@stable
4780
 */
4781
var FormGroupDirective = (function (_super) {
4782
    __extends(FormGroupDirective, _super);
4783
    /**
4784
     * @param {?} _validators
4785
     * @param {?} _asyncValidators
4786
     */
4787
    function FormGroupDirective(_validators, _asyncValidators) {
4788
        var _this = _super.call(this) || this;
4789
        _this._validators = _validators;
4790
        _this._asyncValidators = _asyncValidators;
4791
        _this._submitted = false;
4792
        _this.directives = [];
4793
        _this.form = ((null));
4794
        _this.ngSubmit = new _angular_core.EventEmitter();
4795
        return _this;
4796
    }
4797
    /**
4798
     * @param {?} changes
4799
     * @return {?}
4800
     */
4801
    FormGroupDirective.prototype.ngOnChanges = function (changes) {
4802
        this._checkFormPresent();
4803
        if (changes.hasOwnProperty('form')) {
4804
            this._updateValidators();
4805
            this._updateDomValue();
4806
            this._updateRegistrations();
4807
        }
4808
    };
4809
    Object.defineProperty(FormGroupDirective.prototype, "submitted", {
4810
        /**
4811
         * @return {?}
4812
         */
4813
        get: function () { return this._submitted; },
4814
        enumerable: true,
4815
        configurable: true
4816
    });
4817
    Object.defineProperty(FormGroupDirective.prototype, "formDirective", {
4818
        /**
4819
         * @return {?}
4820
         */
4821
        get: function () { return this; },
4822
        enumerable: true,
4823
        configurable: true
4824
    });
4825
    Object.defineProperty(FormGroupDirective.prototype, "control", {
4826
        /**
4827
         * @return {?}
4828
         */
4829
        get: function () { return this.form; },
4830
        enumerable: true,
4831
        configurable: true
4832
    });
4833
    Object.defineProperty(FormGroupDirective.prototype, "path", {
4834
        /**
4835
         * @return {?}
4836
         */
4837
        get: function () { return []; },
4838
        enumerable: true,
4839
        configurable: true
4840
    });
4841
    /**
4842
     * @param {?} dir
4843
     * @return {?}
4844
     */
4845
    FormGroupDirective.prototype.addControl = function (dir) {
4846
        var /** @type {?} */ ctrl = this.form.get(dir.path);
4847
        setUpControl(ctrl, dir);
4848
        ctrl.updateValueAndValidity({ emitEvent: false });
4849
        this.directives.push(dir);
4850
        return ctrl;
4851
    };
4852
    /**
4853
     * @param {?} dir
4854
     * @return {?}
4855
     */
4856
    FormGroupDirective.prototype.getControl = function (dir) { return (this.form.get(dir.path)); };
4857
    /**
4858
     * @param {?} dir
4859
     * @return {?}
4860
     */
4861
    FormGroupDirective.prototype.removeControl = function (dir) { remove(this.directives, dir); };
4862
    /**
4863
     * @param {?} dir
4864
     * @return {?}
4865
     */
4866
    FormGroupDirective.prototype.addFormGroup = function (dir) {
4867
        var /** @type {?} */ ctrl = this.form.get(dir.path);
4868
        setUpFormContainer(ctrl, dir);
4869
        ctrl.updateValueAndValidity({ emitEvent: false });
4870
    };
4871
    /**
4872
     * @param {?} dir
4873
     * @return {?}
4874
     */
4875
    FormGroupDirective.prototype.removeFormGroup = function (dir) { };
4876
    /**
4877
     * @param {?} dir
4878
     * @return {?}
4879
     */
4880
    FormGroupDirective.prototype.getFormGroup = function (dir) { return (this.form.get(dir.path)); };
4881
    /**
4882
     * @param {?} dir
4883
     * @return {?}
4884
     */
4885
    FormGroupDirective.prototype.addFormArray = function (dir) {
4886
        var /** @type {?} */ ctrl = this.form.get(dir.path);
4887
        setUpFormContainer(ctrl, dir);
4888
        ctrl.updateValueAndValidity({ emitEvent: false });
4889
    };
4890
    /**
4891
     * @param {?} dir
4892
     * @return {?}
4893
     */
4894
    FormGroupDirective.prototype.removeFormArray = function (dir) { };
4895
    /**
4896
     * @param {?} dir
4897
     * @return {?}
4898
     */
4899
    FormGroupDirective.prototype.getFormArray = function (dir) { return (this.form.get(dir.path)); };
4900
    /**
4901
     * @param {?} dir
4902
     * @param {?} value
4903
     * @return {?}
4904
     */
4905
    FormGroupDirective.prototype.updateModel = function (dir, value) {
4906
        var /** @type {?} */ ctrl = (this.form.get(dir.path));
4907
        ctrl.setValue(value);
4908
    };
4909
    /**
4910
     * @param {?} $event
4911
     * @return {?}
4912
     */
4913
    FormGroupDirective.prototype.onSubmit = function ($event) {
4914
        this._submitted = true;
4915
        this.ngSubmit.emit($event);
4916
        return false;
4917
    };
4918
    /**
4919
     * @return {?}
4920
     */
4921
    FormGroupDirective.prototype.onReset = function () { this.resetForm(); };
4922
    /**
4923
     * @param {?=} value
4924
     * @return {?}
4925
     */
4926
    FormGroupDirective.prototype.resetForm = function (value) {
4927
        if (value === void 0) { value = undefined; }
4928
        this.form.reset(value);
4929
        this._submitted = false;
4930
    };
4931
    /**
4932
     * \@internal
4933
     * @return {?}
4934
     */
4935
    FormGroupDirective.prototype._updateDomValue = function () {
4936
        var _this = this;
4937
        this.directives.forEach(function (dir) {
4938
            var /** @type {?} */ newCtrl = _this.form.get(dir.path);
4939
            if (dir._control !== newCtrl) {
4940
                cleanUpControl(dir._control, dir);
4941
                if (newCtrl)
4942
                    setUpControl(newCtrl, dir);
4943
                dir._control = newCtrl;
4944
            }
4945
        });
4946
        this.form._updateTreeValidity({ emitEvent: false });
4947
    };
4948
    /**
4949
     * @return {?}
4950
     */
4951
    FormGroupDirective.prototype._updateRegistrations = function () {
4952
        var _this = this;
4953
        this.form._registerOnCollectionChange(function () { return _this._updateDomValue(); });
4954
        if (this._oldForm)
4955
            this._oldForm._registerOnCollectionChange(function () { });
4956
        this._oldForm = this.form;
4957
    };
4958
    /**
4959
     * @return {?}
4960
     */
4961
    FormGroupDirective.prototype._updateValidators = function () {
4962
        var /** @type {?} */ sync = composeValidators(this._validators);
4963
        this.form.validator = Validators.compose([/** @type {?} */ ((this.form.validator)), /** @type {?} */ ((sync))]);
4964
        var /** @type {?} */ async = composeAsyncValidators(this._asyncValidators);
4965
        this.form.asyncValidator = Validators.composeAsync([/** @type {?} */ ((this.form.asyncValidator)), /** @type {?} */ ((async))]);
4966
    };
4967
    /**
4968
     * @return {?}
4969
     */
4970
    FormGroupDirective.prototype._checkFormPresent = function () {
4971
        if (!this.form) {
4972
            ReactiveErrors.missingFormException();
4973
        }
4974
    };
4975
    return FormGroupDirective;
4976
}(ControlContainer));
4977
FormGroupDirective.decorators = [
4978
    { type: _angular_core.Directive, args: [{
4979
                selector: '[formGroup]',
4980
                providers: [formDirectiveProvider$1],
4981
                host: { '(submit)': 'onSubmit($event)', '(reset)': 'onReset()' },
4982
                exportAs: 'ngForm'
4983
            },] },
4984
];
4985
/**
4986
 * @nocollapse
4987
 */
4988
FormGroupDirective.ctorParameters = function () { return [
4989
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
4990
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
4991
]; };
4992
FormGroupDirective.propDecorators = {
4993
    'form': [{ type: _angular_core.Input, args: ['formGroup',] },],
4994
    'ngSubmit': [{ type: _angular_core.Output },],
4995
};
4996
/**
4997
 * @template T
4998
 * @param {?} list
4999
 * @param {?} el
5000
 * @return {?}
5001
 */
5002
function remove(list, el) {
5003
    var /** @type {?} */ index = list.indexOf(el);
5004
    if (index > -1) {
5005
        list.splice(index, 1);
5006
    }
5007
}
5008
/**
5009
 * @license
5010
 * Copyright Google Inc. All Rights Reserved.
5011
 *
5012
 * Use of this source code is governed by an MIT-style license that can be
5013
 * found in the LICENSE file at https://angular.io/license
5014
 */
5015
var formGroupNameProvider = {
5016
    provide: ControlContainer,
5017
    useExisting: _angular_core.forwardRef(function () { return FormGroupName; })
5018
};
5019
/**
5020
 * \@whatItDoes Syncs a nested {\@link FormGroup} to a DOM element.
5021
 *
5022
 * \@howToUse
5023
 *
5024
 * This directive can only be used with a parent {\@link FormGroupDirective} (selector:
5025
 * `[formGroup]`).
5026
 *
5027
 * It accepts the string name of the nested {\@link FormGroup} you want to link, and
5028
 * will look for a {\@link FormGroup} registered with that name in the parent
5029
 * {\@link FormGroup} instance you passed into {\@link FormGroupDirective}.
5030
 *
5031
 * Nested form groups can come in handy when you want to validate a sub-group of a
5032
 * form separately from the rest or when you'd like to group the values of certain
5033
 * controls into their own nested object.
5034
 *
5035
 * **Access the group**: You can access the associated {\@link FormGroup} using the
5036
 * {\@link AbstractControl#get} method. Ex: `this.form.get('name')`.
5037
 *
5038
 * You can also access individual controls within the group using dot syntax.
5039
 * Ex: `this.form.get('name.first')`
5040
 *
5041
 * **Get the value**: the `value` property is always synced and available on the
5042
 * {\@link FormGroup}. See a full list of available properties in {\@link AbstractControl}.
5043
 *
5044
 * **Set the value**: You can set an initial value for each child control when instantiating
5045
 * the {\@link FormGroup}, or you can set it programmatically later using
5046
 * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}.
5047
 *
5048
 * **Listen to value**: If you want to listen to changes in the value of the group, you can
5049
 * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event.  You can also listen to
5050
 * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
5051
 * re-calculated.
5052
 *
5053
 * ### Example
5054
 *
5055
 * {\@example forms/ts/nestedFormGroup/nested_form_group_example.ts region='Component'}
5056
 *
5057
 * * **npm package**: `\@angular/forms`
5058
 *
5059
 * * **NgModule**: `ReactiveFormsModule`
5060
 *
5061
 * \@stable
5062
 */
5063
var FormGroupName = (function (_super) {
5064
    __extends(FormGroupName, _super);
5065
    /**
5066
     * @param {?} parent
5067
     * @param {?} validators
5068
     * @param {?} asyncValidators
5069
     */
5070
    function FormGroupName(parent, validators, asyncValidators) {
5071
        var _this = _super.call(this) || this;
5072
        _this._parent = parent;
5073
        _this._validators = validators;
5074
        _this._asyncValidators = asyncValidators;
5075
        return _this;
5076
    }
5077
    /**
5078
     * \@internal
5079
     * @return {?}
5080
     */
5081
    FormGroupName.prototype._checkParentType = function () {
5082
        if (_hasInvalidParent(this._parent)) {
5083
            ReactiveErrors.groupParentException();
5084
        }
5085
    };
5086
    return FormGroupName;
5087
}(AbstractFormGroupDirective));
5088
FormGroupName.decorators = [
5089
    { type: _angular_core.Directive, args: [{ selector: '[formGroupName]', providers: [formGroupNameProvider] },] },
5090
];
5091
/**
5092
 * @nocollapse
5093
 */
5094
FormGroupName.ctorParameters = function () { return [
5095
    { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
5096
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
5097
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
5098
]; };
5099
FormGroupName.propDecorators = {
5100
    'name': [{ type: _angular_core.Input, args: ['formGroupName',] },],
5101
};
5102
var formArrayNameProvider = {
5103
    provide: ControlContainer,
5104
    useExisting: _angular_core.forwardRef(function () { return FormArrayName; })
5105
};
5106
/**
5107
 * \@whatItDoes Syncs a nested {\@link FormArray} to a DOM element.
5108
 *
5109
 * \@howToUse
5110
 *
5111
 * This directive is designed to be used with a parent {\@link FormGroupDirective} (selector:
5112
 * `[formGroup]`).
5113
 *
5114
 * It accepts the string name of the nested {\@link FormArray} you want to link, and
5115
 * will look for a {\@link FormArray} registered with that name in the parent
5116
 * {\@link FormGroup} instance you passed into {\@link FormGroupDirective}.
5117
 *
5118
 * Nested form arrays can come in handy when you have a group of form controls but
5119
 * you're not sure how many there will be. Form arrays allow you to create new
5120
 * form controls dynamically.
5121
 *
5122
 * **Access the array**: You can access the associated {\@link FormArray} using the
5123
 * {\@link AbstractControl#get} method on the parent {\@link FormGroup}.
5124
 * Ex: `this.form.get('cities')`.
5125
 *
5126
 * **Get the value**: the `value` property is always synced and available on the
5127
 * {\@link FormArray}. See a full list of available properties in {\@link AbstractControl}.
5128
 *
5129
 * **Set the value**: You can set an initial value for each child control when instantiating
5130
 * the {\@link FormArray}, or you can set the value programmatically later using the
5131
 * {\@link FormArray}'s {\@link AbstractControl#setValue} or {\@link AbstractControl#patchValue}
5132
 * methods.
5133
 *
5134
 * **Listen to value**: If you want to listen to changes in the value of the array, you can
5135
 * subscribe to the {\@link FormArray}'s {\@link AbstractControl#valueChanges} event.  You can also
5136
 * listen to its {\@link AbstractControl#statusChanges} event to be notified when the validation
5137
 * status is re-calculated.
5138
 *
5139
 * **Add new controls**: You can add new controls to the {\@link FormArray} dynamically by
5140
 * calling its {\@link FormArray#push} method.
5141
 *  Ex: `this.form.get('cities').push(new FormControl());`
5142
 *
5143
 * ### Example
5144
 *
5145
 * {\@example forms/ts/nestedFormArray/nested_form_array_example.ts region='Component'}
5146
 *
5147
 * * **npm package**: `\@angular/forms`
5148
 *
5149
 * * **NgModule**: `ReactiveFormsModule`
5150
 *
5151
 * \@stable
5152
 */
5153
var FormArrayName = (function (_super) {
5154
    __extends(FormArrayName, _super);
5155
    /**
5156
     * @param {?} parent
5157
     * @param {?} validators
5158
     * @param {?} asyncValidators
5159
     */
5160
    function FormArrayName(parent, validators, asyncValidators) {
5161
        var _this = _super.call(this) || this;
5162
        _this._parent = parent;
5163
        _this._validators = validators;
5164
        _this._asyncValidators = asyncValidators;
5165
        return _this;
5166
    }
5167
    /**
5168
     * @return {?}
5169
     */
5170
    FormArrayName.prototype.ngOnInit = function () {
5171
        this._checkParentType(); /** @type {?} */
5172
        ((this.formDirective)).addFormArray(this);
5173
    };
5174
    /**
5175
     * @return {?}
5176
     */
5177
    FormArrayName.prototype.ngOnDestroy = function () {
5178
        if (this.formDirective) {
5179
            this.formDirective.removeFormArray(this);
5180
        }
5181
    };
5182
    Object.defineProperty(FormArrayName.prototype, "control", {
5183
        /**
5184
         * @return {?}
5185
         */
5186
        get: function () { return ((this.formDirective)).getFormArray(this); },
5187
        enumerable: true,
5188
        configurable: true
5189
    });
5190
    Object.defineProperty(FormArrayName.prototype, "formDirective", {
5191
        /**
5192
         * @return {?}
5193
         */
5194
        get: function () {
5195
            return this._parent ? (this._parent.formDirective) : null;
5196
        },
5197
        enumerable: true,
5198
        configurable: true
5199
    });
5200
    Object.defineProperty(FormArrayName.prototype, "path", {
5201
        /**
5202
         * @return {?}
5203
         */
5204
        get: function () { return controlPath(this.name, this._parent); },
5205
        enumerable: true,
5206
        configurable: true
5207
    });
5208
    Object.defineProperty(FormArrayName.prototype, "validator", {
5209
        /**
5210
         * @return {?}
5211
         */
5212
        get: function () { return composeValidators(this._validators); },
5213
        enumerable: true,
5214
        configurable: true
5215
    });
5216
    Object.defineProperty(FormArrayName.prototype, "asyncValidator", {
5217
        /**
5218
         * @return {?}
5219
         */
5220
        get: function () {
5221
            return composeAsyncValidators(this._asyncValidators);
5222
        },
5223
        enumerable: true,
5224
        configurable: true
5225
    });
5226
    /**
5227
     * @return {?}
5228
     */
5229
    FormArrayName.prototype._checkParentType = function () {
5230
        if (_hasInvalidParent(this._parent)) {
5231
            ReactiveErrors.arrayParentException();
5232
        }
5233
    };
5234
    return FormArrayName;
5235
}(ControlContainer));
5236
FormArrayName.decorators = [
5237
    { type: _angular_core.Directive, args: [{ selector: '[formArrayName]', providers: [formArrayNameProvider] },] },
5238
];
5239
/**
5240
 * @nocollapse
5241
 */
5242
FormArrayName.ctorParameters = function () { return [
5243
    { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
5244
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
5245
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
5246
]; };
5247
FormArrayName.propDecorators = {
5248
    'name': [{ type: _angular_core.Input, args: ['formArrayName',] },],
5249
};
5250
/**
5251
 * @param {?} parent
5252
 * @return {?}
5253
 */
5254
function _hasInvalidParent(parent) {
5255
    return !(parent instanceof FormGroupName) && !(parent instanceof FormGroupDirective) &&
5256
        !(parent instanceof FormArrayName);
5257
}
5258
/**
5259
 * @license
5260
 * Copyright Google Inc. All Rights Reserved.
5261
 *
5262
 * Use of this source code is governed by an MIT-style license that can be
5263
 * found in the LICENSE file at https://angular.io/license
5264
 */
5265
var controlNameBinding = {
5266
    provide: NgControl,
5267
    useExisting: _angular_core.forwardRef(function () { return FormControlName; })
5268
};
5269
/**
5270
 * \@whatItDoes Syncs a {\@link FormControl} in an existing {\@link FormGroup} to a form control
5271
 * element by name.
5272
 *
5273
 * In other words, this directive ensures that any values written to the {\@link FormControl}
5274
 * instance programmatically will be written to the DOM element (model -> view). Conversely,
5275
 * any values written to the DOM element through user input will be reflected in the
5276
 * {\@link FormControl} instance (view -> model).
5277
 *
5278
 * \@howToUse
5279
 *
5280
 * This directive is designed to be used with a parent {\@link FormGroupDirective} (selector:
5281
 * `[formGroup]`).
5282
 *
5283
 * It accepts the string name of the {\@link FormControl} instance you want to
5284
 * link, and will look for a {\@link FormControl} registered with that name in the
5285
 * closest {\@link FormGroup} or {\@link FormArray} above it.
5286
 *
5287
 * **Access the control**: You can access the {\@link FormControl} associated with
5288
 * this directive by using the {\@link AbstractControl#get get} method.
5289
 * Ex: `this.form.get('first');`
5290
 *
5291
 * **Get value**: the `value` property is always synced and available on the {\@link FormControl}.
5292
 * See a full list of available properties in {\@link AbstractControl}.
5293
 *
5294
 *  **Set value**: You can set an initial value for the control when instantiating the
5295
 *  {\@link FormControl}, or you can set it programmatically later using
5296
 *  {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}.
5297
 *
5298
 * **Listen to value**: If you want to listen to changes in the value of the control, you can
5299
 * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event.  You can also listen to
5300
 * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
5301
 * re-calculated.
5302
 *
5303
 * ### Example
5304
 *
5305
 * In this example, we create form controls for first name and last name.
5306
 *
5307
 * {\@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
5308
 *
5309
 * To see `formControlName` examples with different form control types, see:
5310
 *
5311
 * * Radio buttons: {\@link RadioControlValueAccessor}
5312
 * * Selects: {\@link SelectControlValueAccessor}
5313
 *
5314
 * **npm package**: `\@angular/forms`
5315
 *
5316
 * **NgModule**: {\@link ReactiveFormsModule}
5317
 *
5318
 *  \@stable
5319
 */
5320
var FormControlName = (function (_super) {
5321
    __extends(FormControlName, _super);
5322
    /**
5323
     * @param {?} parent
5324
     * @param {?} validators
5325
     * @param {?} asyncValidators
5326
     * @param {?} valueAccessors
5327
     */
5328
    function FormControlName(parent, validators, asyncValidators, valueAccessors) {
5329
        var _this = _super.call(this) || this;
5330
        _this._added = false;
5331
        _this.update = new _angular_core.EventEmitter();
5332
        _this._parent = parent;
5333
        _this._rawValidators = validators || [];
5334
        _this._rawAsyncValidators = asyncValidators || [];
5335
        _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
5336
        return _this;
5337
    }
5338
    Object.defineProperty(FormControlName.prototype, "isDisabled", {
5339
        /**
5340
         * @param {?} isDisabled
5341
         * @return {?}
5342
         */
5343
        set: function (isDisabled) { ReactiveErrors.disabledAttrWarning(); },
5344
        enumerable: true,
5345
        configurable: true
5346
    });
5347
    /**
5348
     * @param {?} changes
5349
     * @return {?}
5350
     */
5351
    FormControlName.prototype.ngOnChanges = function (changes) {
5352
        if (!this._added)
5353
            this._setUpControl();
5354
        if (isPropertyUpdated(changes, this.viewModel)) {
5355
            this.viewModel = this.model;
5356
            this.formDirective.updateModel(this, this.model);
5357
        }
5358
    };
5359
    /**
5360
     * @return {?}
5361
     */
5362
    FormControlName.prototype.ngOnDestroy = function () {
5363
        if (this.formDirective) {
5364
            this.formDirective.removeControl(this);
5365
        }
5366
    };
5367
    /**
5368
     * @param {?} newValue
5369
     * @return {?}
5370
     */
5371
    FormControlName.prototype.viewToModelUpdate = function (newValue) {
5372
        this.viewModel = newValue;
5373
        this.update.emit(newValue);
5374
    };
5375
    Object.defineProperty(FormControlName.prototype, "path", {
5376
        /**
5377
         * @return {?}
5378
         */
5379
        get: function () { return controlPath(this.name, /** @type {?} */ ((this._parent))); },
5380
        enumerable: true,
5381
        configurable: true
5382
    });
5383
    Object.defineProperty(FormControlName.prototype, "formDirective", {
5384
        /**
5385
         * @return {?}
5386
         */
5387
        get: function () { return this._parent ? this._parent.formDirective : null; },
5388
        enumerable: true,
5389
        configurable: true
5390
    });
5391
    Object.defineProperty(FormControlName.prototype, "validator", {
5392
        /**
5393
         * @return {?}
5394
         */
5395
        get: function () { return composeValidators(this._rawValidators); },
5396
        enumerable: true,
5397
        configurable: true
5398
    });
5399
    Object.defineProperty(FormControlName.prototype, "asyncValidator", {
5400
        /**
5401
         * @return {?}
5402
         */
5403
        get: function () {
5404
            return ((composeAsyncValidators(this._rawAsyncValidators)));
5405
        },
5406
        enumerable: true,
5407
        configurable: true
5408
    });
5409
    Object.defineProperty(FormControlName.prototype, "control", {
5410
        /**
5411
         * @return {?}
5412
         */
5413
        get: function () { return this._control; },
5414
        enumerable: true,
5415
        configurable: true
5416
    });
5417
    /**
5418
     * @return {?}
5419
     */
5420
    FormControlName.prototype._checkParentType = function () {
5421
        if (!(this._parent instanceof FormGroupName) &&
5422
            this._parent instanceof AbstractFormGroupDirective) {
5423
            ReactiveErrors.ngModelGroupException();
5424
        }
5425
        else if (!(this._parent instanceof FormGroupName) && !(this._parent instanceof FormGroupDirective) &&
5426
            !(this._parent instanceof FormArrayName)) {
5427
            ReactiveErrors.controlParentException();
5428
        }
5429
    };
5430
    /**
5431
     * @return {?}
5432
     */
5433
    FormControlName.prototype._setUpControl = function () {
5434
        this._checkParentType();
5435
        this._control = this.formDirective.addControl(this);
5436
        if (this.control.disabled && ((this.valueAccessor)).setDisabledState) {
5437
            ((((this.valueAccessor)).setDisabledState))(true);
5438
        }
5439
        this._added = true;
5440
    };
5441
    return FormControlName;
5442
}(NgControl));
5443
FormControlName.decorators = [
5444
    { type: _angular_core.Directive, args: [{ selector: '[formControlName]', providers: [controlNameBinding] },] },
5445
];
5446
/**
5447
 * @nocollapse
5448
 */
5449
FormControlName.ctorParameters = function () { return [
5450
    { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
5451
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
5452
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
5453
    { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALUE_ACCESSOR,] },] },
5454
]; };
5455
FormControlName.propDecorators = {
5456
    'name': [{ type: _angular_core.Input, args: ['formControlName',] },],
5457
    'model': [{ type: _angular_core.Input, args: ['ngModel',] },],
5458
    'update': [{ type: _angular_core.Output, args: ['ngModelChange',] },],
5459
    'isDisabled': [{ type: _angular_core.Input, args: ['disabled',] },],
5460
};
5461
/**
5462
 * @license
5463
 * Copyright Google Inc. All Rights Reserved.
5464
 *
5465
 * Use of this source code is governed by an MIT-style license that can be
5466
 * found in the LICENSE file at https://angular.io/license
5467
 */
5468
var REQUIRED_VALIDATOR = {
5469
    provide: NG_VALIDATORS,
5470
    useExisting: _angular_core.forwardRef(function () { return RequiredValidator; }),
5471
    multi: true
5472
};
5473
var CHECKBOX_REQUIRED_VALIDATOR = {
5474
    provide: NG_VALIDATORS,
5475
    useExisting: _angular_core.forwardRef(function () { return CheckboxRequiredValidator; }),
5476
    multi: true
5477
};
5478
/**
5479
 * A Directive that adds the `required` validator to any controls marked with the
5480
 * `required` attribute, via the {\@link NG_VALIDATORS} binding.
5481
 *
5482
 * ### Example
5483
 *
5484
 * ```
5485
 * <input name="fullName" ngModel required>
5486
 * ```
5487
 *
5488
 * \@stable
5489
 */
5490
var RequiredValidator = (function () {
5491
    function RequiredValidator() {
5492
    }
5493
    Object.defineProperty(RequiredValidator.prototype, "required", {
5494
        /**
5495
         * @return {?}
5496
         */
5497
        get: function () { return this._required; },
5498
        /**
5499
         * @param {?} value
5500
         * @return {?}
5501
         */
5502
        set: function (value) {
5503
            this._required = value != null && value !== false && "" + value !== 'false';
5504
            if (this._onChange)
5505
                this._onChange();
5506
        },
5507
        enumerable: true,
5508
        configurable: true
5509
    });
5510
    /**
5511
     * @param {?} c
5512
     * @return {?}
5513
     */
5514
    RequiredValidator.prototype.validate = function (c) {
5515
        return this.required ? Validators.required(c) : null;
5516
    };
5517
    /**
5518
     * @param {?} fn
5519
     * @return {?}
5520
     */
5521
    RequiredValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
5522
    return RequiredValidator;
5523
}());
5524
RequiredValidator.decorators = [
5525
    { type: _angular_core.Directive, args: [{
5526
                selector: ':not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]',
5527
                providers: [REQUIRED_VALIDATOR],
5528
                host: { '[attr.required]': 'required ? "" : null' }
5529
            },] },
5530
];
5531
/**
5532
 * @nocollapse
5533
 */
5534
RequiredValidator.ctorParameters = function () { return []; };
5535
RequiredValidator.propDecorators = {
5536
    'required': [{ type: _angular_core.Input },],
5537
};
5538
/**
5539
 * A Directive that adds the `required` validator to checkbox controls marked with the
5540
 * `required` attribute, via the {\@link NG_VALIDATORS} binding.
5541
 *
5542
 * ### Example
5543
 *
5544
 * ```
5545
 * <input type="checkbox" name="active" ngModel required>
5546
 * ```
5547
 *
5548
 * \@experimental
5549
 */
5550
var CheckboxRequiredValidator = (function (_super) {
5551
    __extends(CheckboxRequiredValidator, _super);
5552
    function CheckboxRequiredValidator() {
5553
        return _super !== null && _super.apply(this, arguments) || this;
5554
    }
5555
    /**
5556
     * @param {?} c
5557
     * @return {?}
5558
     */
5559
    CheckboxRequiredValidator.prototype.validate = function (c) {
5560
        return this.required ? Validators.requiredTrue(c) : null;
5561
    };
5562
    return CheckboxRequiredValidator;
5563
}(RequiredValidator));
5564
CheckboxRequiredValidator.decorators = [
5565
    { type: _angular_core.Directive, args: [{
5566
                selector: 'input[type=checkbox][required][formControlName],input[type=checkbox][required][formControl],input[type=checkbox][required][ngModel]',
5567
                providers: [CHECKBOX_REQUIRED_VALIDATOR],
5568
                host: { '[attr.required]': 'required ? "" : null' }
5569
            },] },
5570
];
5571
/**
5572
 * @nocollapse
5573
 */
5574
CheckboxRequiredValidator.ctorParameters = function () { return []; };
5575
/**
5576
 * Provider which adds {\@link EmailValidator} to {\@link NG_VALIDATORS}.
5577
 */
5578
var EMAIL_VALIDATOR = {
5579
    provide: NG_VALIDATORS,
5580
    useExisting: _angular_core.forwardRef(function () { return EmailValidator; }),
5581
    multi: true
5582
};
5583
/**
5584
 * A Directive that adds the `email` validator to controls marked with the
5585
 * `email` attribute, via the {\@link NG_VALIDATORS} binding.
5586
 *
5587
 * ### Example
5588
 *
5589
 * ```
5590
 * <input type="email" name="email" ngModel email>
5591
 * <input type="email" name="email" ngModel email="true">
5592
 * <input type="email" name="email" ngModel [email]="true">
5593
 * ```
5594
 *
5595
 * \@experimental
5596
 */
5597
var EmailValidator = (function () {
5598
    function EmailValidator() {
5599
    }
5600
    Object.defineProperty(EmailValidator.prototype, "email", {
5601
        /**
5602
         * @param {?} value
5603
         * @return {?}
5604
         */
5605
        set: function (value) {
5606
            this._enabled = value === '' || value === true || value === 'true';
5607
            if (this._onChange)
5608
                this._onChange();
5609
        },
5610
        enumerable: true,
5611
        configurable: true
5612
    });
5613
    /**
5614
     * @param {?} c
5615
     * @return {?}
5616
     */
5617
    EmailValidator.prototype.validate = function (c) {
5618
        return this._enabled ? Validators.email(c) : null;
5619
    };
5620
    /**
5621
     * @param {?} fn
5622
     * @return {?}
5623
     */
5624
    EmailValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
5625
    return EmailValidator;
5626
}());
5627
EmailValidator.decorators = [
5628
    { type: _angular_core.Directive, args: [{
5629
                selector: '[email][formControlName],[email][formControl],[email][ngModel]',
5630
                providers: [EMAIL_VALIDATOR]
5631
            },] },
5632
];
5633
/**
5634
 * @nocollapse
5635
 */
5636
EmailValidator.ctorParameters = function () { return []; };
5637
EmailValidator.propDecorators = {
5638
    'email': [{ type: _angular_core.Input },],
5639
};
5640
/**
5641
 * Provider which adds {\@link MinLengthValidator} to {\@link NG_VALIDATORS}.
5642
 *
5643
 * ## Example:
5644
 *
5645
 * {\@example common/forms/ts/validators/validators.ts region='min'}
5646
 */
5647
var MIN_LENGTH_VALIDATOR = {
5648
    provide: NG_VALIDATORS,
5649
    useExisting: _angular_core.forwardRef(function () { return MinLengthValidator; }),
5650
    multi: true
5651
};
5652
/**
5653
 * A directive which installs the {\@link MinLengthValidator} for any `formControlName`,
5654
 * `formControl`, or control with `ngModel` that also has a `minlength` attribute.
5655
 *
5656
 * \@stable
5657
 */
5658
var MinLengthValidator = (function () {
5659
    function MinLengthValidator() {
5660
    }
5661
    /**
5662
     * @param {?} changes
5663
     * @return {?}
5664
     */
5665
    MinLengthValidator.prototype.ngOnChanges = function (changes) {
5666
        if ('minlength' in changes) {
5667
            this._createValidator();
5668
            if (this._onChange)
5669
                this._onChange();
5670
        }
5671
    };
5672
    /**
5673
     * @param {?} c
5674
     * @return {?}
5675
     */
5676
    MinLengthValidator.prototype.validate = function (c) {
5677
        return this.minlength == null ? null : this._validator(c);
5678
    };
5679
    /**
5680
     * @param {?} fn
5681
     * @return {?}
5682
     */
5683
    MinLengthValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
5684
    /**
5685
     * @return {?}
5686
     */
5687
    MinLengthValidator.prototype._createValidator = function () {
5688
        this._validator = Validators.minLength(parseInt(this.minlength, 10));
5689
    };
5690
    return MinLengthValidator;
5691
}());
5692
MinLengthValidator.decorators = [
5693
    { type: _angular_core.Directive, args: [{
5694
                selector: '[minlength][formControlName],[minlength][formControl],[minlength][ngModel]',
5695
                providers: [MIN_LENGTH_VALIDATOR],
5696
                host: { '[attr.minlength]': 'minlength ? minlength : null' }
5697
            },] },
5698
];
5699
/**
5700
 * @nocollapse
5701
 */
5702
MinLengthValidator.ctorParameters = function () { return []; };
5703
MinLengthValidator.propDecorators = {
5704
    'minlength': [{ type: _angular_core.Input },],
5705
};
5706
/**
5707
 * Provider which adds {\@link MaxLengthValidator} to {\@link NG_VALIDATORS}.
5708
 *
5709
 * ## Example:
5710
 *
5711
 * {\@example common/forms/ts/validators/validators.ts region='max'}
5712
 */
5713
var MAX_LENGTH_VALIDATOR = {
5714
    provide: NG_VALIDATORS,
5715
    useExisting: _angular_core.forwardRef(function () { return MaxLengthValidator; }),
5716
    multi: true
5717
};
5718
/**
5719
 * A directive which installs the {\@link MaxLengthValidator} for any `formControlName,
5720
 * `formControl`,
5721
 * or control with `ngModel` that also has a `maxlength` attribute.
5722
 *
5723
 * \@stable
5724
 */
5725
var MaxLengthValidator = (function () {
5726
    function MaxLengthValidator() {
5727
    }
5728
    /**
5729
     * @param {?} changes
5730
     * @return {?}
5731
     */
5732
    MaxLengthValidator.prototype.ngOnChanges = function (changes) {
5733
        if ('maxlength' in changes) {
5734
            this._createValidator();
5735
            if (this._onChange)
5736
                this._onChange();
5737
        }
5738
    };
5739
    /**
5740
     * @param {?} c
5741
     * @return {?}
5742
     */
5743
    MaxLengthValidator.prototype.validate = function (c) {
5744
        return this.maxlength != null ? this._validator(c) : null;
5745
    };
5746
    /**
5747
     * @param {?} fn
5748
     * @return {?}
5749
     */
5750
    MaxLengthValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
5751
    /**
5752
     * @return {?}
5753
     */
5754
    MaxLengthValidator.prototype._createValidator = function () {
5755
        this._validator = Validators.maxLength(parseInt(this.maxlength, 10));
5756
    };
5757
    return MaxLengthValidator;
5758
}());
5759
MaxLengthValidator.decorators = [
5760
    { type: _angular_core.Directive, args: [{
5761
                selector: '[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]',
5762
                providers: [MAX_LENGTH_VALIDATOR],
5763
                host: { '[attr.maxlength]': 'maxlength ? maxlength : null' }
5764
            },] },
5765
];
5766
/**
5767
 * @nocollapse
5768
 */
5769
MaxLengthValidator.ctorParameters = function () { return []; };
5770
MaxLengthValidator.propDecorators = {
5771
    'maxlength': [{ type: _angular_core.Input },],
5772
};
5773
var PATTERN_VALIDATOR = {
5774
    provide: NG_VALIDATORS,
5775
    useExisting: _angular_core.forwardRef(function () { return PatternValidator; }),
5776
    multi: true
5777
};
5778
/**
5779
 * A Directive that adds the `pattern` validator to any controls marked with the
5780
 * `pattern` attribute, via the {\@link NG_VALIDATORS} binding. Uses attribute value
5781
 * as the regex to validate Control value against.  Follows pattern attribute
5782
 * semantics; i.e. regex must match entire Control value.
5783
 *
5784
 * ### Example
5785
 *
5786
 * ```
5787
 * <input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>
5788
 * ```
5789
 * \@stable
5790
 */
5791
var PatternValidator = (function () {
5792
    function PatternValidator() {
5793
    }
5794
    /**
5795
     * @param {?} changes
5796
     * @return {?}
5797
     */
5798
    PatternValidator.prototype.ngOnChanges = function (changes) {
5799
        if ('pattern' in changes) {
5800
            this._createValidator();
5801
            if (this._onChange)
5802
                this._onChange();
5803
        }
5804
    };
5805
    /**
5806
     * @param {?} c
5807
     * @return {?}
5808
     */
5809
    PatternValidator.prototype.validate = function (c) { return this._validator(c); };
5810
    /**
5811
     * @param {?} fn
5812
     * @return {?}
5813
     */
5814
    PatternValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
5815
    /**
5816
     * @return {?}
5817
     */
5818
    PatternValidator.prototype._createValidator = function () { this._validator = Validators.pattern(this.pattern); };
5819
    return PatternValidator;
5820
}());
5821
PatternValidator.decorators = [
5822
    { type: _angular_core.Directive, args: [{
5823
                selector: '[pattern][formControlName],[pattern][formControl],[pattern][ngModel]',
5824
                providers: [PATTERN_VALIDATOR],
5825
                host: { '[attr.pattern]': 'pattern ? pattern : null' }
5826
            },] },
5827
];
5828
/**
5829
 * @nocollapse
5830
 */
5831
PatternValidator.ctorParameters = function () { return []; };
5832
PatternValidator.propDecorators = {
5833
    'pattern': [{ type: _angular_core.Input },],
5834
};
5835
/**
5836
 * @license
5837
 * Copyright Google Inc. All Rights Reserved.
5838
 *
5839
 * Use of this source code is governed by an MIT-style license that can be
5840
 * found in the LICENSE file at https://angular.io/license
5841
 */
5842
/**
5843
 * \@whatItDoes Creates an {\@link AbstractControl} from a user-specified configuration.
5844
 *
5845
 * It is essentially syntactic sugar that shortens the `new FormGroup()`,
5846
 * `new FormControl()`, and `new FormArray()` boilerplate that can build up in larger
5847
 * forms.
5848
 *
5849
 * \@howToUse
5850
 *
5851
 * To use, inject `FormBuilder` into your component class. You can then call its methods
5852
 * directly.
5853
 *
5854
 * {\@example forms/ts/formBuilder/form_builder_example.ts region='Component'}
5855
 *
5856
 *  * **npm package**: `\@angular/forms`
5857
 *
5858
 *  * **NgModule**: {\@link ReactiveFormsModule}
5859
 *
5860
 * \@stable
5861
 */
5862
var FormBuilder = (function () {
5863
    function FormBuilder() {
5864
    }
5865
    /**
5866
     * Construct a new {\@link FormGroup} with the given map of configuration.
5867
     * Valid keys for the `extra` parameter map are `validator` and `asyncValidator`.
5868
     *
5869
     * See the {\@link FormGroup} constructor for more details.
5870
     * @param {?} controlsConfig
5871
     * @param {?=} extra
5872
     * @return {?}
5873
     */
5874
    FormBuilder.prototype.group = function (controlsConfig, extra) {
5875
        if (extra === void 0) { extra = null; }
5876
        var /** @type {?} */ controls = this._reduceControls(controlsConfig);
5877
        var /** @type {?} */ validator = extra != null ? extra['validator'] : null;
5878
        var /** @type {?} */ asyncValidator = extra != null ? extra['asyncValidator'] : null;
5879
        return new FormGroup(controls, validator, asyncValidator);
5880
    };
5881
    /**
5882
     * Construct a new {\@link FormControl} with the given `formState`,`validator`, and
5883
     * `asyncValidator`.
5884
     *
5885
     * `formState` can either be a standalone value for the form control or an object
5886
     * that contains both a value and a disabled status.
5887
     *
5888
     * @param {?} formState
5889
     * @param {?=} validator
5890
     * @param {?=} asyncValidator
5891
     * @return {?}
5892
     */
5893
    FormBuilder.prototype.control = function (formState, validator, asyncValidator) {
5894
        return new FormControl(formState, validator, asyncValidator);
5895
    };
5896
    /**
5897
     * Construct a {\@link FormArray} from the given `controlsConfig` array of
5898
     * configuration, with the given optional `validator` and `asyncValidator`.
5899
     * @param {?} controlsConfig
5900
     * @param {?=} validator
5901
     * @param {?=} asyncValidator
5902
     * @return {?}
5903
     */
5904
    FormBuilder.prototype.array = function (controlsConfig, validator, asyncValidator) {
5905
        var _this = this;
5906
        var /** @type {?} */ controls = controlsConfig.map(function (c) { return _this._createControl(c); });
5907
        return new FormArray(controls, validator, asyncValidator);
5908
    };
5909
    /**
5910
     * \@internal
5911
     * @param {?} controlsConfig
5912
     * @return {?}
5913
     */
5914
    FormBuilder.prototype._reduceControls = function (controlsConfig) {
5915
        var _this = this;
5916
        var /** @type {?} */ controls = {};
5917
        Object.keys(controlsConfig).forEach(function (controlName) {
5918
            controls[controlName] = _this._createControl(controlsConfig[controlName]);
5919
        });
5920
        return controls;
5921
    };
5922
    /**
5923
     * \@internal
5924
     * @param {?} controlConfig
5925
     * @return {?}
5926
     */
5927
    FormBuilder.prototype._createControl = function (controlConfig) {
5928
        if (controlConfig instanceof FormControl || controlConfig instanceof FormGroup ||
5929
            controlConfig instanceof FormArray) {
5930
            return controlConfig;
5931
        }
5932
        else if (Array.isArray(controlConfig)) {
5933
            var /** @type {?} */ value = controlConfig[0];
5934
            var /** @type {?} */ validator = controlConfig.length > 1 ? controlConfig[1] : null;
5935
            var /** @type {?} */ asyncValidator = controlConfig.length > 2 ? controlConfig[2] : null;
5936
            return this.control(value, validator, asyncValidator);
5937
        }
5938
        else {
5939
            return this.control(controlConfig);
5940
        }
5941
    };
5942
    return FormBuilder;
5943
}());
5944
FormBuilder.decorators = [
5945
    { type: _angular_core.Injectable },
5946
];
5947
/**
5948
 * @nocollapse
5949
 */
5950
FormBuilder.ctorParameters = function () { return []; };
5951
/**
5952
 * @license
5953
 * Copyright Google Inc. All Rights Reserved.
5954
 *
5955
 * Use of this source code is governed by an MIT-style license that can be
5956
 * found in the LICENSE file at https://angular.io/license
5957
 */
5958
/**
5959
 * @module
5960
 * @description
5961
 * Entry point for all public APIs of the common package.
5962
 */
5963
/**
5964
 * \@stable
5965
 */
5966
var VERSION = new _angular_core.Version('4.4.6');
5967
/**
5968
 * @license
5969
 * Copyright Google Inc. All Rights Reserved.
5970
 *
5971
 * Use of this source code is governed by an MIT-style license that can be
5972
 * found in the LICENSE file at https://angular.io/license
5973
 */
5974
/**
5975
 * \@whatItDoes Adds `novalidate` attribute to all forms by default.
5976
 *
5977
 * `novalidate` is used to disable browser's native form validation.
5978
 *
5979
 * If you want to use native validation with Angular forms, just add `ngNativeValidate` attribute:
5980
 *
5981
 * ```
5982
 * <form ngNativeValidate></form>
5983
 * ```
5984
 *
5985
 * \@experimental
5986
 */
5987
var NgNoValidate = (function () {
5988
    function NgNoValidate() {
5989
    }
5990
    return NgNoValidate;
5991
}());
5992
NgNoValidate.decorators = [
5993
    { type: _angular_core.Directive, args: [{
5994
                selector: 'form:not([ngNoForm]):not([ngNativeValidate])',
5995
                host: { 'novalidate': '' },
5996
            },] },
5997
];
5998
/**
5999
 * @nocollapse
6000
 */
6001
NgNoValidate.ctorParameters = function () { return []; };
6002
/**
6003
 * @license
6004
 * Copyright Google Inc. All Rights Reserved.
6005
 *
6006
 * Use of this source code is governed by an MIT-style license that can be
6007
 * found in the LICENSE file at https://angular.io/license
6008
 */
6009
var SHARED_FORM_DIRECTIVES = [
6010
    NgNoValidate,
6011
    NgSelectOption,
6012
    NgSelectMultipleOption,
6013
    DefaultValueAccessor,
6014
    NumberValueAccessor,
6015
    RangeValueAccessor,
6016
    CheckboxControlValueAccessor,
6017
    SelectControlValueAccessor,
6018
    SelectMultipleControlValueAccessor,
6019
    RadioControlValueAccessor,
6020
    NgControlStatus,
6021
    NgControlStatusGroup,
6022
    RequiredValidator,
6023
    MinLengthValidator,
6024
    MaxLengthValidator,
6025
    PatternValidator,
6026
    CheckboxRequiredValidator,
6027
    EmailValidator,
6028
];
6029
var TEMPLATE_DRIVEN_DIRECTIVES = [NgModel, NgModelGroup, NgForm];
6030
var REACTIVE_DRIVEN_DIRECTIVES = [FormControlDirective, FormGroupDirective, FormControlName, FormGroupName, FormArrayName];
6031
/**
6032
 * Internal module used for sharing directives between FormsModule and ReactiveFormsModule
6033
 */
6034
var InternalFormsSharedModule = (function () {
6035
    function InternalFormsSharedModule() {
6036
    }
6037
    return InternalFormsSharedModule;
6038
}());
6039
InternalFormsSharedModule.decorators = [
6040
    { type: _angular_core.NgModule, args: [{
6041
                declarations: SHARED_FORM_DIRECTIVES,
6042
                exports: SHARED_FORM_DIRECTIVES,
6043
            },] },
6044
];
6045
/**
6046
 * @nocollapse
6047
 */
6048
InternalFormsSharedModule.ctorParameters = function () { return []; };
6049
/**
6050
 * @license
6051
 * Copyright Google Inc. All Rights Reserved.
6052
 *
6053
 * Use of this source code is governed by an MIT-style license that can be
6054
 * found in the LICENSE file at https://angular.io/license
6055
 */
6056
/**
6057
 * The ng module for forms.
6058
 * \@stable
6059
 */
6060
var FormsModule = (function () {
6061
    function FormsModule() {
6062
    }
6063
    return FormsModule;
6064
}());
6065
FormsModule.decorators = [
6066
    { type: _angular_core.NgModule, args: [{
6067
                declarations: TEMPLATE_DRIVEN_DIRECTIVES,
6068
                providers: [RadioControlRegistry],
6069
                exports: [InternalFormsSharedModule, TEMPLATE_DRIVEN_DIRECTIVES]
6070
            },] },
6071
];
6072
/**
6073
 * @nocollapse
6074
 */
6075
FormsModule.ctorParameters = function () { return []; };
6076
/**
6077
 * The ng module for reactive forms.
6078
 * \@stable
6079
 */
6080
var ReactiveFormsModule = (function () {
6081
    function ReactiveFormsModule() {
6082
    }
6083
    return ReactiveFormsModule;
6084
}());
6085
ReactiveFormsModule.decorators = [
6086
    { type: _angular_core.NgModule, args: [{
6087
                declarations: [REACTIVE_DRIVEN_DIRECTIVES],
6088
                providers: [FormBuilder, RadioControlRegistry],
6089
                exports: [InternalFormsSharedModule, REACTIVE_DRIVEN_DIRECTIVES]
6090
            },] },
6091
];
6092
/**
6093
 * @nocollapse
6094
 */
6095
ReactiveFormsModule.ctorParameters = function () { return []; };
6096

    
6097
exports.AbstractControlDirective = AbstractControlDirective;
6098
exports.AbstractFormGroupDirective = AbstractFormGroupDirective;
6099
exports.CheckboxControlValueAccessor = CheckboxControlValueAccessor;
6100
exports.ControlContainer = ControlContainer;
6101
exports.NG_VALUE_ACCESSOR = NG_VALUE_ACCESSOR;
6102
exports.COMPOSITION_BUFFER_MODE = COMPOSITION_BUFFER_MODE;
6103
exports.DefaultValueAccessor = DefaultValueAccessor;
6104
exports.NgControl = NgControl;
6105
exports.NgControlStatus = NgControlStatus;
6106
exports.NgControlStatusGroup = NgControlStatusGroup;
6107
exports.NgForm = NgForm;
6108
exports.NgModel = NgModel;
6109
exports.NgModelGroup = NgModelGroup;
6110
exports.RadioControlValueAccessor = RadioControlValueAccessor;
6111
exports.FormControlDirective = FormControlDirective;
6112
exports.FormControlName = FormControlName;
6113
exports.FormGroupDirective = FormGroupDirective;
6114
exports.FormArrayName = FormArrayName;
6115
exports.FormGroupName = FormGroupName;
6116
exports.NgSelectOption = NgSelectOption;
6117
exports.SelectControlValueAccessor = SelectControlValueAccessor;
6118
exports.SelectMultipleControlValueAccessor = SelectMultipleControlValueAccessor;
6119
exports.CheckboxRequiredValidator = CheckboxRequiredValidator;
6120
exports.EmailValidator = EmailValidator;
6121
exports.MaxLengthValidator = MaxLengthValidator;
6122
exports.MinLengthValidator = MinLengthValidator;
6123
exports.PatternValidator = PatternValidator;
6124
exports.RequiredValidator = RequiredValidator;
6125
exports.FormBuilder = FormBuilder;
6126
exports.AbstractControl = AbstractControl;
6127
exports.FormArray = FormArray;
6128
exports.FormControl = FormControl;
6129
exports.FormGroup = FormGroup;
6130
exports.NG_ASYNC_VALIDATORS = NG_ASYNC_VALIDATORS;
6131
exports.NG_VALIDATORS = NG_VALIDATORS;
6132
exports.Validators = Validators;
6133
exports.VERSION = VERSION;
6134
exports.FormsModule = FormsModule;
6135
exports.ReactiveFormsModule = ReactiveFormsModule;
6136
exports.ɵba = InternalFormsSharedModule;
6137
exports.ɵz = REACTIVE_DRIVEN_DIRECTIVES;
6138
exports.ɵx = SHARED_FORM_DIRECTIVES;
6139
exports.ɵy = TEMPLATE_DRIVEN_DIRECTIVES;
6140
exports.ɵa = CHECKBOX_VALUE_ACCESSOR;
6141
exports.ɵb = DEFAULT_VALUE_ACCESSOR;
6142
exports.ɵc = AbstractControlStatus;
6143
exports.ɵd = ngControlStatusHost;
6144
exports.ɵe = formDirectiveProvider;
6145
exports.ɵf = formControlBinding;
6146
exports.ɵg = modelGroupProvider;
6147
exports.ɵbf = NgNoValidate;
6148
exports.ɵbb = NUMBER_VALUE_ACCESSOR;
6149
exports.ɵbc = NumberValueAccessor;
6150
exports.ɵh = RADIO_VALUE_ACCESSOR;
6151
exports.ɵi = RadioControlRegistry;
6152
exports.ɵbd = RANGE_VALUE_ACCESSOR;
6153
exports.ɵbe = RangeValueAccessor;
6154
exports.ɵj = formControlBinding$1;
6155
exports.ɵk = controlNameBinding;
6156
exports.ɵl = formDirectiveProvider$1;
6157
exports.ɵn = formArrayNameProvider;
6158
exports.ɵm = formGroupNameProvider;
6159
exports.ɵo = SELECT_VALUE_ACCESSOR;
6160
exports.ɵq = NgSelectMultipleOption;
6161
exports.ɵp = SELECT_MULTIPLE_VALUE_ACCESSOR;
6162
exports.ɵs = CHECKBOX_REQUIRED_VALIDATOR;
6163
exports.ɵt = EMAIL_VALIDATOR;
6164
exports.ɵv = MAX_LENGTH_VALIDATOR;
6165
exports.ɵu = MIN_LENGTH_VALIDATOR;
6166
exports.ɵw = PATTERN_VALIDATOR;
6167
exports.ɵr = REQUIRED_VALIDATOR;
6168

    
6169
Object.defineProperty(exports, '__esModule', { value: true });
6170

    
6171
})));
6172
//# sourceMappingURL=forms.umd.js.map
(1-1/4)