@ng-select/ng-select 2.20.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +3 -3
  2. package/bundles/ng-select-ng-select.umd.js +4525 -0
  3. package/bundles/ng-select-ng-select.umd.js.map +1 -0
  4. package/bundles/ng-select-ng-select.umd.min.js +2 -0
  5. package/bundles/ng-select-ng-select.umd.min.js.map +1 -0
  6. package/esm2015/lib/config.service.js +40 -0
  7. package/esm2015/lib/console.service.js +20 -0
  8. package/esm2015/lib/id.js +21 -0
  9. package/esm2015/lib/items-list.js +661 -0
  10. package/esm2015/lib/ng-dropdown-panel.component.js +661 -0
  11. package/esm2015/lib/ng-dropdown-panel.service.js +127 -0
  12. package/esm2015/lib/ng-option.component.js +74 -0
  13. package/esm2015/lib/ng-select.component.js +1384 -0
  14. package/esm2015/lib/ng-select.module.js +57 -0
  15. package/esm2015/lib/ng-select.types.js +48 -0
  16. package/esm2015/{ng-select → lib}/ng-templates.directive.js +2 -3
  17. package/esm2015/lib/search-helper.js +862 -0
  18. package/esm2015/lib/selection-model.js +166 -0
  19. package/esm2015/lib/value-utils.js +33 -0
  20. package/esm2015/ng-select-ng-select.js +15 -0
  21. package/esm2015/public-api.js +11 -0
  22. package/esm5/lib/config.service.js +42 -0
  23. package/esm5/lib/console.service.js +28 -0
  24. package/esm5/lib/id.js +21 -0
  25. package/esm5/lib/items-list.js +888 -0
  26. package/esm5/lib/ng-dropdown-panel.component.js +770 -0
  27. package/esm5/lib/ng-dropdown-panel.service.js +150 -0
  28. package/esm5/lib/ng-option.component.js +86 -0
  29. package/esm5/lib/ng-select.component.js +1637 -0
  30. package/esm5/lib/ng-select.module.js +61 -0
  31. package/esm5/lib/ng-select.types.js +48 -0
  32. package/esm5/{ng-select → lib}/ng-templates.directive.js +2 -3
  33. package/esm5/lib/search-helper.js +862 -0
  34. package/esm5/{ng-select → lib}/selection-model.js +69 -22
  35. package/esm5/lib/value-utils.js +33 -0
  36. package/esm5/ng-select-ng-select.js +15 -0
  37. package/esm5/public-api.js +11 -0
  38. package/fesm2015/ng-select-ng-select.js +3804 -0
  39. package/fesm2015/ng-select-ng-select.js.map +1 -0
  40. package/fesm5/ng-select-ng-select.js +4442 -0
  41. package/fesm5/ng-select-ng-select.js.map +1 -0
  42. package/{ng-select → lib}/config.service.d.ts +0 -0
  43. package/{ng-select → lib}/console.service.d.ts +0 -0
  44. package/{ng-select → lib}/id.d.ts +0 -0
  45. package/{ng-select → lib}/items-list.d.ts +1 -1
  46. package/{ng-select → lib}/ng-dropdown-panel.component.d.ts +0 -0
  47. package/{ng-select → lib}/ng-dropdown-panel.service.d.ts +0 -0
  48. package/{ng-select → lib}/ng-option.component.d.ts +0 -0
  49. package/{ng-select → lib}/ng-select.component.d.ts +9 -9
  50. package/{ng-select → lib}/ng-select.module.d.ts +0 -0
  51. package/{ng-select → lib}/ng-select.types.d.ts +0 -0
  52. package/{ng-select → lib}/ng-templates.directive.d.ts +0 -0
  53. package/{ng-select → lib}/search-helper.d.ts +0 -0
  54. package/{ng-select → lib}/selection-model.d.ts +0 -0
  55. package/{ng-select → lib}/value-utils.d.ts +0 -0
  56. package/ng-select-ng-select.d.ts +10 -0
  57. package/ng-select-ng-select.metadata.json +1 -0
  58. package/package.json +13 -14
  59. package/public-api.d.ts +5 -0
  60. package/scss/material.theme.scss +1 -1
  61. package/themes/material.theme.css +1 -1
  62. package/bundles/ng-select.umd.js +0 -4283
  63. package/bundles/ng-select.umd.js.map +0 -1
  64. package/bundles/ng-select.umd.min.js +0 -2
  65. package/bundles/ng-select.umd.min.js.map +0 -1
  66. package/esm2015/index.js +0 -9
  67. package/esm2015/ng-select/config.service.js +0 -41
  68. package/esm2015/ng-select/console.service.js +0 -21
  69. package/esm2015/ng-select/id.js +0 -17
  70. package/esm2015/ng-select/items-list.js +0 -542
  71. package/esm2015/ng-select/ng-dropdown-panel.component.js +0 -562
  72. package/esm2015/ng-select/ng-dropdown-panel.service.js +0 -121
  73. package/esm2015/ng-select/ng-option-highlight.directive.js +0 -98
  74. package/esm2015/ng-select/ng-option.component.js +0 -71
  75. package/esm2015/ng-select/ng-select.component.js +0 -1214
  76. package/esm2015/ng-select/ng-select.module.js +0 -61
  77. package/esm2015/ng-select/ng-select.types.js +0 -49
  78. package/esm2015/ng-select/search-helper.js +0 -859
  79. package/esm2015/ng-select/selection-model.js +0 -122
  80. package/esm2015/ng-select/value-utils.js +0 -34
  81. package/esm2015/ng-select.js +0 -17
  82. package/esm5/index.js +0 -9
  83. package/esm5/ng-select/config.service.js +0 -43
  84. package/esm5/ng-select/console.service.js +0 -29
  85. package/esm5/ng-select/id.js +0 -17
  86. package/esm5/ng-select/items-list.js +0 -761
  87. package/esm5/ng-select/ng-dropdown-panel.component.js +0 -654
  88. package/esm5/ng-select/ng-dropdown-panel.service.js +0 -144
  89. package/esm5/ng-select/ng-option-highlight.directive.js +0 -113
  90. package/esm5/ng-select/ng-option.component.js +0 -82
  91. package/esm5/ng-select/ng-select.component.js +0 -1430
  92. package/esm5/ng-select/ng-select.module.js +0 -65
  93. package/esm5/ng-select/ng-select.types.js +0 -49
  94. package/esm5/ng-select/search-helper.js +0 -859
  95. package/esm5/ng-select/value-utils.js +0 -34
  96. package/esm5/ng-select.js +0 -17
  97. package/fesm2015/ng-select.js +0 -3559
  98. package/fesm2015/ng-select.js.map +0 -1
  99. package/fesm5/ng-select.js +0 -4145
  100. package/fesm5/ng-select.js.map +0 -1
  101. package/index.d.ts +0 -5
  102. package/ng-select/ng-option-highlight.directive.d.ts +0 -14
  103. package/ng-select.d.ts +0 -11
  104. package/ng-select.metadata.json +0 -1
@@ -0,0 +1,3804 @@
1
+ import { Directive, TemplateRef, Injectable, ɵɵdefineInjectable, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Renderer2, NgZone, ElementRef, Optional, Inject, Input, Output, ViewChild, HostListener, InjectionToken, forwardRef, Attribute, ChangeDetectorRef, HostBinding, ContentChild, ContentChildren, NgModule } from '@angular/core';
2
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
3
+ import { takeUntil, auditTime, startWith, tap, debounceTime, filter, map } from 'rxjs/operators';
4
+ import { Subject, fromEvent, merge, animationFrameScheduler, asapScheduler } from 'rxjs';
5
+ import { DOCUMENT, CommonModule } from '@angular/common';
6
+
7
+ /**
8
+ * @fileoverview added by tsickle
9
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
10
+ */
11
+ class NgOptionTemplateDirective {
12
+ /**
13
+ * @param {?} template
14
+ */
15
+ constructor(template) {
16
+ this.template = template;
17
+ }
18
+ }
19
+ NgOptionTemplateDirective.decorators = [
20
+ { type: Directive, args: [{ selector: '[ng-option-tmp]' },] }
21
+ ];
22
+ /** @nocollapse */
23
+ NgOptionTemplateDirective.ctorParameters = () => [
24
+ { type: TemplateRef }
25
+ ];
26
+ class NgOptgroupTemplateDirective {
27
+ /**
28
+ * @param {?} template
29
+ */
30
+ constructor(template) {
31
+ this.template = template;
32
+ }
33
+ }
34
+ NgOptgroupTemplateDirective.decorators = [
35
+ { type: Directive, args: [{ selector: '[ng-optgroup-tmp]' },] }
36
+ ];
37
+ /** @nocollapse */
38
+ NgOptgroupTemplateDirective.ctorParameters = () => [
39
+ { type: TemplateRef }
40
+ ];
41
+ class NgLabelTemplateDirective {
42
+ /**
43
+ * @param {?} template
44
+ */
45
+ constructor(template) {
46
+ this.template = template;
47
+ }
48
+ }
49
+ NgLabelTemplateDirective.decorators = [
50
+ { type: Directive, args: [{ selector: '[ng-label-tmp]' },] }
51
+ ];
52
+ /** @nocollapse */
53
+ NgLabelTemplateDirective.ctorParameters = () => [
54
+ { type: TemplateRef }
55
+ ];
56
+ class NgMultiLabelTemplateDirective {
57
+ /**
58
+ * @param {?} template
59
+ */
60
+ constructor(template) {
61
+ this.template = template;
62
+ }
63
+ }
64
+ NgMultiLabelTemplateDirective.decorators = [
65
+ { type: Directive, args: [{ selector: '[ng-multi-label-tmp]' },] }
66
+ ];
67
+ /** @nocollapse */
68
+ NgMultiLabelTemplateDirective.ctorParameters = () => [
69
+ { type: TemplateRef }
70
+ ];
71
+ class NgHeaderTemplateDirective {
72
+ /**
73
+ * @param {?} template
74
+ */
75
+ constructor(template) {
76
+ this.template = template;
77
+ }
78
+ }
79
+ NgHeaderTemplateDirective.decorators = [
80
+ { type: Directive, args: [{ selector: '[ng-header-tmp]' },] }
81
+ ];
82
+ /** @nocollapse */
83
+ NgHeaderTemplateDirective.ctorParameters = () => [
84
+ { type: TemplateRef }
85
+ ];
86
+ class NgFooterTemplateDirective {
87
+ /**
88
+ * @param {?} template
89
+ */
90
+ constructor(template) {
91
+ this.template = template;
92
+ }
93
+ }
94
+ NgFooterTemplateDirective.decorators = [
95
+ { type: Directive, args: [{ selector: '[ng-footer-tmp]' },] }
96
+ ];
97
+ /** @nocollapse */
98
+ NgFooterTemplateDirective.ctorParameters = () => [
99
+ { type: TemplateRef }
100
+ ];
101
+ class NgNotFoundTemplateDirective {
102
+ /**
103
+ * @param {?} template
104
+ */
105
+ constructor(template) {
106
+ this.template = template;
107
+ }
108
+ }
109
+ NgNotFoundTemplateDirective.decorators = [
110
+ { type: Directive, args: [{ selector: '[ng-notfound-tmp]' },] }
111
+ ];
112
+ /** @nocollapse */
113
+ NgNotFoundTemplateDirective.ctorParameters = () => [
114
+ { type: TemplateRef }
115
+ ];
116
+ class NgTypeToSearchTemplateDirective {
117
+ /**
118
+ * @param {?} template
119
+ */
120
+ constructor(template) {
121
+ this.template = template;
122
+ }
123
+ }
124
+ NgTypeToSearchTemplateDirective.decorators = [
125
+ { type: Directive, args: [{ selector: '[ng-typetosearch-tmp]' },] }
126
+ ];
127
+ /** @nocollapse */
128
+ NgTypeToSearchTemplateDirective.ctorParameters = () => [
129
+ { type: TemplateRef }
130
+ ];
131
+ class NgLoadingTextTemplateDirective {
132
+ /**
133
+ * @param {?} template
134
+ */
135
+ constructor(template) {
136
+ this.template = template;
137
+ }
138
+ }
139
+ NgLoadingTextTemplateDirective.decorators = [
140
+ { type: Directive, args: [{ selector: '[ng-loadingtext-tmp]' },] }
141
+ ];
142
+ /** @nocollapse */
143
+ NgLoadingTextTemplateDirective.ctorParameters = () => [
144
+ { type: TemplateRef }
145
+ ];
146
+ class NgTagTemplateDirective {
147
+ /**
148
+ * @param {?} template
149
+ */
150
+ constructor(template) {
151
+ this.template = template;
152
+ }
153
+ }
154
+ NgTagTemplateDirective.decorators = [
155
+ { type: Directive, args: [{ selector: '[ng-tag-tmp]' },] }
156
+ ];
157
+ /** @nocollapse */
158
+ NgTagTemplateDirective.ctorParameters = () => [
159
+ { type: TemplateRef }
160
+ ];
161
+ class NgLoadingSpinnerTemplateDirective {
162
+ /**
163
+ * @param {?} template
164
+ */
165
+ constructor(template) {
166
+ this.template = template;
167
+ }
168
+ }
169
+ NgLoadingSpinnerTemplateDirective.decorators = [
170
+ { type: Directive, args: [{ selector: '[ng-loadingspinner-tmp]' },] }
171
+ ];
172
+ /** @nocollapse */
173
+ NgLoadingSpinnerTemplateDirective.ctorParameters = () => [
174
+ { type: TemplateRef }
175
+ ];
176
+
177
+ /**
178
+ * @fileoverview added by tsickle
179
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
180
+ */
181
+ class ConsoleService {
182
+ /**
183
+ * @param {?} message
184
+ * @return {?}
185
+ */
186
+ warn(message) {
187
+ console.warn(message);
188
+ }
189
+ }
190
+ ConsoleService.decorators = [
191
+ { type: Injectable, args: [{ providedIn: 'root' },] }
192
+ ];
193
+ /** @nocollapse */ ConsoleService.ngInjectableDef = ɵɵdefineInjectable({ factory: function ConsoleService_Factory() { return new ConsoleService(); }, token: ConsoleService, providedIn: "root" });
194
+
195
+ /**
196
+ * @fileoverview added by tsickle
197
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
198
+ */
199
+ /**
200
+ * @param {?} value
201
+ * @return {?}
202
+ */
203
+ function isDefined(value) {
204
+ return value !== undefined && value !== null;
205
+ }
206
+ /**
207
+ * @param {?} value
208
+ * @return {?}
209
+ */
210
+ function isObject(value) {
211
+ return typeof value === 'object' && isDefined(value);
212
+ }
213
+ /**
214
+ * @param {?} value
215
+ * @return {?}
216
+ */
217
+ function isPromise(value) {
218
+ return value instanceof Promise;
219
+ }
220
+ /**
221
+ * @param {?} value
222
+ * @return {?}
223
+ */
224
+ function isFunction(value) {
225
+ return value instanceof Function;
226
+ }
227
+
228
+ /**
229
+ * @fileoverview added by tsickle
230
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
231
+ */
232
+ /**
233
+ * @return {?}
234
+ */
235
+ function newId() {
236
+ // First character is an 'a', it's good practice to tag id to begin with a letter
237
+ return 'axxxxxxxxxxx'.replace(/[x]/g, (/**
238
+ * @param {?} _
239
+ * @return {?}
240
+ */
241
+ function (_) {
242
+ // tslint:disable-next-line:no-bitwise
243
+ /** @type {?} */
244
+ const val = Math.random() * 16 | 0;
245
+ return val.toString(16);
246
+ }));
247
+ }
248
+
249
+ /**
250
+ * @fileoverview added by tsickle
251
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
252
+ */
253
+ /** @type {?} */
254
+ const diacritics = {
255
+ '\u24B6': 'A',
256
+ '\uFF21': 'A',
257
+ '\u00C0': 'A',
258
+ '\u00C1': 'A',
259
+ '\u00C2': 'A',
260
+ '\u1EA6': 'A',
261
+ '\u1EA4': 'A',
262
+ '\u1EAA': 'A',
263
+ '\u1EA8': 'A',
264
+ '\u00C3': 'A',
265
+ '\u0100': 'A',
266
+ '\u0102': 'A',
267
+ '\u1EB0': 'A',
268
+ '\u1EAE': 'A',
269
+ '\u1EB4': 'A',
270
+ '\u1EB2': 'A',
271
+ '\u0226': 'A',
272
+ '\u01E0': 'A',
273
+ '\u00C4': 'A',
274
+ '\u01DE': 'A',
275
+ '\u1EA2': 'A',
276
+ '\u00C5': 'A',
277
+ '\u01FA': 'A',
278
+ '\u01CD': 'A',
279
+ '\u0200': 'A',
280
+ '\u0202': 'A',
281
+ '\u1EA0': 'A',
282
+ '\u1EAC': 'A',
283
+ '\u1EB6': 'A',
284
+ '\u1E00': 'A',
285
+ '\u0104': 'A',
286
+ '\u023A': 'A',
287
+ '\u2C6F': 'A',
288
+ '\uA732': 'AA',
289
+ '\u00C6': 'AE',
290
+ '\u01FC': 'AE',
291
+ '\u01E2': 'AE',
292
+ '\uA734': 'AO',
293
+ '\uA736': 'AU',
294
+ '\uA738': 'AV',
295
+ '\uA73A': 'AV',
296
+ '\uA73C': 'AY',
297
+ '\u24B7': 'B',
298
+ '\uFF22': 'B',
299
+ '\u1E02': 'B',
300
+ '\u1E04': 'B',
301
+ '\u1E06': 'B',
302
+ '\u0243': 'B',
303
+ '\u0182': 'B',
304
+ '\u0181': 'B',
305
+ '\u24B8': 'C',
306
+ '\uFF23': 'C',
307
+ '\u0106': 'C',
308
+ '\u0108': 'C',
309
+ '\u010A': 'C',
310
+ '\u010C': 'C',
311
+ '\u00C7': 'C',
312
+ '\u1E08': 'C',
313
+ '\u0187': 'C',
314
+ '\u023B': 'C',
315
+ '\uA73E': 'C',
316
+ '\u24B9': 'D',
317
+ '\uFF24': 'D',
318
+ '\u1E0A': 'D',
319
+ '\u010E': 'D',
320
+ '\u1E0C': 'D',
321
+ '\u1E10': 'D',
322
+ '\u1E12': 'D',
323
+ '\u1E0E': 'D',
324
+ '\u0110': 'D',
325
+ '\u018B': 'D',
326
+ '\u018A': 'D',
327
+ '\u0189': 'D',
328
+ '\uA779': 'D',
329
+ '\u01F1': 'DZ',
330
+ '\u01C4': 'DZ',
331
+ '\u01F2': 'Dz',
332
+ '\u01C5': 'Dz',
333
+ '\u24BA': 'E',
334
+ '\uFF25': 'E',
335
+ '\u00C8': 'E',
336
+ '\u00C9': 'E',
337
+ '\u00CA': 'E',
338
+ '\u1EC0': 'E',
339
+ '\u1EBE': 'E',
340
+ '\u1EC4': 'E',
341
+ '\u1EC2': 'E',
342
+ '\u1EBC': 'E',
343
+ '\u0112': 'E',
344
+ '\u1E14': 'E',
345
+ '\u1E16': 'E',
346
+ '\u0114': 'E',
347
+ '\u0116': 'E',
348
+ '\u00CB': 'E',
349
+ '\u1EBA': 'E',
350
+ '\u011A': 'E',
351
+ '\u0204': 'E',
352
+ '\u0206': 'E',
353
+ '\u1EB8': 'E',
354
+ '\u1EC6': 'E',
355
+ '\u0228': 'E',
356
+ '\u1E1C': 'E',
357
+ '\u0118': 'E',
358
+ '\u1E18': 'E',
359
+ '\u1E1A': 'E',
360
+ '\u0190': 'E',
361
+ '\u018E': 'E',
362
+ '\u24BB': 'F',
363
+ '\uFF26': 'F',
364
+ '\u1E1E': 'F',
365
+ '\u0191': 'F',
366
+ '\uA77B': 'F',
367
+ '\u24BC': 'G',
368
+ '\uFF27': 'G',
369
+ '\u01F4': 'G',
370
+ '\u011C': 'G',
371
+ '\u1E20': 'G',
372
+ '\u011E': 'G',
373
+ '\u0120': 'G',
374
+ '\u01E6': 'G',
375
+ '\u0122': 'G',
376
+ '\u01E4': 'G',
377
+ '\u0193': 'G',
378
+ '\uA7A0': 'G',
379
+ '\uA77D': 'G',
380
+ '\uA77E': 'G',
381
+ '\u24BD': 'H',
382
+ '\uFF28': 'H',
383
+ '\u0124': 'H',
384
+ '\u1E22': 'H',
385
+ '\u1E26': 'H',
386
+ '\u021E': 'H',
387
+ '\u1E24': 'H',
388
+ '\u1E28': 'H',
389
+ '\u1E2A': 'H',
390
+ '\u0126': 'H',
391
+ '\u2C67': 'H',
392
+ '\u2C75': 'H',
393
+ '\uA78D': 'H',
394
+ '\u24BE': 'I',
395
+ '\uFF29': 'I',
396
+ '\u00CC': 'I',
397
+ '\u00CD': 'I',
398
+ '\u00CE': 'I',
399
+ '\u0128': 'I',
400
+ '\u012A': 'I',
401
+ '\u012C': 'I',
402
+ '\u0130': 'I',
403
+ '\u00CF': 'I',
404
+ '\u1E2E': 'I',
405
+ '\u1EC8': 'I',
406
+ '\u01CF': 'I',
407
+ '\u0208': 'I',
408
+ '\u020A': 'I',
409
+ '\u1ECA': 'I',
410
+ '\u012E': 'I',
411
+ '\u1E2C': 'I',
412
+ '\u0197': 'I',
413
+ '\u24BF': 'J',
414
+ '\uFF2A': 'J',
415
+ '\u0134': 'J',
416
+ '\u0248': 'J',
417
+ '\u24C0': 'K',
418
+ '\uFF2B': 'K',
419
+ '\u1E30': 'K',
420
+ '\u01E8': 'K',
421
+ '\u1E32': 'K',
422
+ '\u0136': 'K',
423
+ '\u1E34': 'K',
424
+ '\u0198': 'K',
425
+ '\u2C69': 'K',
426
+ '\uA740': 'K',
427
+ '\uA742': 'K',
428
+ '\uA744': 'K',
429
+ '\uA7A2': 'K',
430
+ '\u24C1': 'L',
431
+ '\uFF2C': 'L',
432
+ '\u013F': 'L',
433
+ '\u0139': 'L',
434
+ '\u013D': 'L',
435
+ '\u1E36': 'L',
436
+ '\u1E38': 'L',
437
+ '\u013B': 'L',
438
+ '\u1E3C': 'L',
439
+ '\u1E3A': 'L',
440
+ '\u0141': 'L',
441
+ '\u023D': 'L',
442
+ '\u2C62': 'L',
443
+ '\u2C60': 'L',
444
+ '\uA748': 'L',
445
+ '\uA746': 'L',
446
+ '\uA780': 'L',
447
+ '\u01C7': 'LJ',
448
+ '\u01C8': 'Lj',
449
+ '\u24C2': 'M',
450
+ '\uFF2D': 'M',
451
+ '\u1E3E': 'M',
452
+ '\u1E40': 'M',
453
+ '\u1E42': 'M',
454
+ '\u2C6E': 'M',
455
+ '\u019C': 'M',
456
+ '\u24C3': 'N',
457
+ '\uFF2E': 'N',
458
+ '\u01F8': 'N',
459
+ '\u0143': 'N',
460
+ '\u00D1': 'N',
461
+ '\u1E44': 'N',
462
+ '\u0147': 'N',
463
+ '\u1E46': 'N',
464
+ '\u0145': 'N',
465
+ '\u1E4A': 'N',
466
+ '\u1E48': 'N',
467
+ '\u0220': 'N',
468
+ '\u019D': 'N',
469
+ '\uA790': 'N',
470
+ '\uA7A4': 'N',
471
+ '\u01CA': 'NJ',
472
+ '\u01CB': 'Nj',
473
+ '\u24C4': 'O',
474
+ '\uFF2F': 'O',
475
+ '\u00D2': 'O',
476
+ '\u00D3': 'O',
477
+ '\u00D4': 'O',
478
+ '\u1ED2': 'O',
479
+ '\u1ED0': 'O',
480
+ '\u1ED6': 'O',
481
+ '\u1ED4': 'O',
482
+ '\u00D5': 'O',
483
+ '\u1E4C': 'O',
484
+ '\u022C': 'O',
485
+ '\u1E4E': 'O',
486
+ '\u014C': 'O',
487
+ '\u1E50': 'O',
488
+ '\u1E52': 'O',
489
+ '\u014E': 'O',
490
+ '\u022E': 'O',
491
+ '\u0230': 'O',
492
+ '\u00D6': 'O',
493
+ '\u022A': 'O',
494
+ '\u1ECE': 'O',
495
+ '\u0150': 'O',
496
+ '\u01D1': 'O',
497
+ '\u020C': 'O',
498
+ '\u020E': 'O',
499
+ '\u01A0': 'O',
500
+ '\u1EDC': 'O',
501
+ '\u1EDA': 'O',
502
+ '\u1EE0': 'O',
503
+ '\u1EDE': 'O',
504
+ '\u1EE2': 'O',
505
+ '\u1ECC': 'O',
506
+ '\u1ED8': 'O',
507
+ '\u01EA': 'O',
508
+ '\u01EC': 'O',
509
+ '\u00D8': 'O',
510
+ '\u01FE': 'O',
511
+ '\u0186': 'O',
512
+ '\u019F': 'O',
513
+ '\uA74A': 'O',
514
+ '\uA74C': 'O',
515
+ '\u01A2': 'OI',
516
+ '\uA74E': 'OO',
517
+ '\u0222': 'OU',
518
+ '\u24C5': 'P',
519
+ '\uFF30': 'P',
520
+ '\u1E54': 'P',
521
+ '\u1E56': 'P',
522
+ '\u01A4': 'P',
523
+ '\u2C63': 'P',
524
+ '\uA750': 'P',
525
+ '\uA752': 'P',
526
+ '\uA754': 'P',
527
+ '\u24C6': 'Q',
528
+ '\uFF31': 'Q',
529
+ '\uA756': 'Q',
530
+ '\uA758': 'Q',
531
+ '\u024A': 'Q',
532
+ '\u24C7': 'R',
533
+ '\uFF32': 'R',
534
+ '\u0154': 'R',
535
+ '\u1E58': 'R',
536
+ '\u0158': 'R',
537
+ '\u0210': 'R',
538
+ '\u0212': 'R',
539
+ '\u1E5A': 'R',
540
+ '\u1E5C': 'R',
541
+ '\u0156': 'R',
542
+ '\u1E5E': 'R',
543
+ '\u024C': 'R',
544
+ '\u2C64': 'R',
545
+ '\uA75A': 'R',
546
+ '\uA7A6': 'R',
547
+ '\uA782': 'R',
548
+ '\u24C8': 'S',
549
+ '\uFF33': 'S',
550
+ '\u1E9E': 'S',
551
+ '\u015A': 'S',
552
+ '\u1E64': 'S',
553
+ '\u015C': 'S',
554
+ '\u1E60': 'S',
555
+ '\u0160': 'S',
556
+ '\u1E66': 'S',
557
+ '\u1E62': 'S',
558
+ '\u1E68': 'S',
559
+ '\u0218': 'S',
560
+ '\u015E': 'S',
561
+ '\u2C7E': 'S',
562
+ '\uA7A8': 'S',
563
+ '\uA784': 'S',
564
+ '\u24C9': 'T',
565
+ '\uFF34': 'T',
566
+ '\u1E6A': 'T',
567
+ '\u0164': 'T',
568
+ '\u1E6C': 'T',
569
+ '\u021A': 'T',
570
+ '\u0162': 'T',
571
+ '\u1E70': 'T',
572
+ '\u1E6E': 'T',
573
+ '\u0166': 'T',
574
+ '\u01AC': 'T',
575
+ '\u01AE': 'T',
576
+ '\u023E': 'T',
577
+ '\uA786': 'T',
578
+ '\uA728': 'TZ',
579
+ '\u24CA': 'U',
580
+ '\uFF35': 'U',
581
+ '\u00D9': 'U',
582
+ '\u00DA': 'U',
583
+ '\u00DB': 'U',
584
+ '\u0168': 'U',
585
+ '\u1E78': 'U',
586
+ '\u016A': 'U',
587
+ '\u1E7A': 'U',
588
+ '\u016C': 'U',
589
+ '\u00DC': 'U',
590
+ '\u01DB': 'U',
591
+ '\u01D7': 'U',
592
+ '\u01D5': 'U',
593
+ '\u01D9': 'U',
594
+ '\u1EE6': 'U',
595
+ '\u016E': 'U',
596
+ '\u0170': 'U',
597
+ '\u01D3': 'U',
598
+ '\u0214': 'U',
599
+ '\u0216': 'U',
600
+ '\u01AF': 'U',
601
+ '\u1EEA': 'U',
602
+ '\u1EE8': 'U',
603
+ '\u1EEE': 'U',
604
+ '\u1EEC': 'U',
605
+ '\u1EF0': 'U',
606
+ '\u1EE4': 'U',
607
+ '\u1E72': 'U',
608
+ '\u0172': 'U',
609
+ '\u1E76': 'U',
610
+ '\u1E74': 'U',
611
+ '\u0244': 'U',
612
+ '\u24CB': 'V',
613
+ '\uFF36': 'V',
614
+ '\u1E7C': 'V',
615
+ '\u1E7E': 'V',
616
+ '\u01B2': 'V',
617
+ '\uA75E': 'V',
618
+ '\u0245': 'V',
619
+ '\uA760': 'VY',
620
+ '\u24CC': 'W',
621
+ '\uFF37': 'W',
622
+ '\u1E80': 'W',
623
+ '\u1E82': 'W',
624
+ '\u0174': 'W',
625
+ '\u1E86': 'W',
626
+ '\u1E84': 'W',
627
+ '\u1E88': 'W',
628
+ '\u2C72': 'W',
629
+ '\u24CD': 'X',
630
+ '\uFF38': 'X',
631
+ '\u1E8A': 'X',
632
+ '\u1E8C': 'X',
633
+ '\u24CE': 'Y',
634
+ '\uFF39': 'Y',
635
+ '\u1EF2': 'Y',
636
+ '\u00DD': 'Y',
637
+ '\u0176': 'Y',
638
+ '\u1EF8': 'Y',
639
+ '\u0232': 'Y',
640
+ '\u1E8E': 'Y',
641
+ '\u0178': 'Y',
642
+ '\u1EF6': 'Y',
643
+ '\u1EF4': 'Y',
644
+ '\u01B3': 'Y',
645
+ '\u024E': 'Y',
646
+ '\u1EFE': 'Y',
647
+ '\u24CF': 'Z',
648
+ '\uFF3A': 'Z',
649
+ '\u0179': 'Z',
650
+ '\u1E90': 'Z',
651
+ '\u017B': 'Z',
652
+ '\u017D': 'Z',
653
+ '\u1E92': 'Z',
654
+ '\u1E94': 'Z',
655
+ '\u01B5': 'Z',
656
+ '\u0224': 'Z',
657
+ '\u2C7F': 'Z',
658
+ '\u2C6B': 'Z',
659
+ '\uA762': 'Z',
660
+ '\u24D0': 'a',
661
+ '\uFF41': 'a',
662
+ '\u1E9A': 'a',
663
+ '\u00E0': 'a',
664
+ '\u00E1': 'a',
665
+ '\u00E2': 'a',
666
+ '\u1EA7': 'a',
667
+ '\u1EA5': 'a',
668
+ '\u1EAB': 'a',
669
+ '\u1EA9': 'a',
670
+ '\u00E3': 'a',
671
+ '\u0101': 'a',
672
+ '\u0103': 'a',
673
+ '\u1EB1': 'a',
674
+ '\u1EAF': 'a',
675
+ '\u1EB5': 'a',
676
+ '\u1EB3': 'a',
677
+ '\u0227': 'a',
678
+ '\u01E1': 'a',
679
+ '\u00E4': 'a',
680
+ '\u01DF': 'a',
681
+ '\u1EA3': 'a',
682
+ '\u00E5': 'a',
683
+ '\u01FB': 'a',
684
+ '\u01CE': 'a',
685
+ '\u0201': 'a',
686
+ '\u0203': 'a',
687
+ '\u1EA1': 'a',
688
+ '\u1EAD': 'a',
689
+ '\u1EB7': 'a',
690
+ '\u1E01': 'a',
691
+ '\u0105': 'a',
692
+ '\u2C65': 'a',
693
+ '\u0250': 'a',
694
+ '\uA733': 'aa',
695
+ '\u00E6': 'ae',
696
+ '\u01FD': 'ae',
697
+ '\u01E3': 'ae',
698
+ '\uA735': 'ao',
699
+ '\uA737': 'au',
700
+ '\uA739': 'av',
701
+ '\uA73B': 'av',
702
+ '\uA73D': 'ay',
703
+ '\u24D1': 'b',
704
+ '\uFF42': 'b',
705
+ '\u1E03': 'b',
706
+ '\u1E05': 'b',
707
+ '\u1E07': 'b',
708
+ '\u0180': 'b',
709
+ '\u0183': 'b',
710
+ '\u0253': 'b',
711
+ '\u24D2': 'c',
712
+ '\uFF43': 'c',
713
+ '\u0107': 'c',
714
+ '\u0109': 'c',
715
+ '\u010B': 'c',
716
+ '\u010D': 'c',
717
+ '\u00E7': 'c',
718
+ '\u1E09': 'c',
719
+ '\u0188': 'c',
720
+ '\u023C': 'c',
721
+ '\uA73F': 'c',
722
+ '\u2184': 'c',
723
+ '\u24D3': 'd',
724
+ '\uFF44': 'd',
725
+ '\u1E0B': 'd',
726
+ '\u010F': 'd',
727
+ '\u1E0D': 'd',
728
+ '\u1E11': 'd',
729
+ '\u1E13': 'd',
730
+ '\u1E0F': 'd',
731
+ '\u0111': 'd',
732
+ '\u018C': 'd',
733
+ '\u0256': 'd',
734
+ '\u0257': 'd',
735
+ '\uA77A': 'd',
736
+ '\u01F3': 'dz',
737
+ '\u01C6': 'dz',
738
+ '\u24D4': 'e',
739
+ '\uFF45': 'e',
740
+ '\u00E8': 'e',
741
+ '\u00E9': 'e',
742
+ '\u00EA': 'e',
743
+ '\u1EC1': 'e',
744
+ '\u1EBF': 'e',
745
+ '\u1EC5': 'e',
746
+ '\u1EC3': 'e',
747
+ '\u1EBD': 'e',
748
+ '\u0113': 'e',
749
+ '\u1E15': 'e',
750
+ '\u1E17': 'e',
751
+ '\u0115': 'e',
752
+ '\u0117': 'e',
753
+ '\u00EB': 'e',
754
+ '\u1EBB': 'e',
755
+ '\u011B': 'e',
756
+ '\u0205': 'e',
757
+ '\u0207': 'e',
758
+ '\u1EB9': 'e',
759
+ '\u1EC7': 'e',
760
+ '\u0229': 'e',
761
+ '\u1E1D': 'e',
762
+ '\u0119': 'e',
763
+ '\u1E19': 'e',
764
+ '\u1E1B': 'e',
765
+ '\u0247': 'e',
766
+ '\u025B': 'e',
767
+ '\u01DD': 'e',
768
+ '\u24D5': 'f',
769
+ '\uFF46': 'f',
770
+ '\u1E1F': 'f',
771
+ '\u0192': 'f',
772
+ '\uA77C': 'f',
773
+ '\u24D6': 'g',
774
+ '\uFF47': 'g',
775
+ '\u01F5': 'g',
776
+ '\u011D': 'g',
777
+ '\u1E21': 'g',
778
+ '\u011F': 'g',
779
+ '\u0121': 'g',
780
+ '\u01E7': 'g',
781
+ '\u0123': 'g',
782
+ '\u01E5': 'g',
783
+ '\u0260': 'g',
784
+ '\uA7A1': 'g',
785
+ '\u1D79': 'g',
786
+ '\uA77F': 'g',
787
+ '\u24D7': 'h',
788
+ '\uFF48': 'h',
789
+ '\u0125': 'h',
790
+ '\u1E23': 'h',
791
+ '\u1E27': 'h',
792
+ '\u021F': 'h',
793
+ '\u1E25': 'h',
794
+ '\u1E29': 'h',
795
+ '\u1E2B': 'h',
796
+ '\u1E96': 'h',
797
+ '\u0127': 'h',
798
+ '\u2C68': 'h',
799
+ '\u2C76': 'h',
800
+ '\u0265': 'h',
801
+ '\u0195': 'hv',
802
+ '\u24D8': 'i',
803
+ '\uFF49': 'i',
804
+ '\u00EC': 'i',
805
+ '\u00ED': 'i',
806
+ '\u00EE': 'i',
807
+ '\u0129': 'i',
808
+ '\u012B': 'i',
809
+ '\u012D': 'i',
810
+ '\u00EF': 'i',
811
+ '\u1E2F': 'i',
812
+ '\u1EC9': 'i',
813
+ '\u01D0': 'i',
814
+ '\u0209': 'i',
815
+ '\u020B': 'i',
816
+ '\u1ECB': 'i',
817
+ '\u012F': 'i',
818
+ '\u1E2D': 'i',
819
+ '\u0268': 'i',
820
+ '\u0131': 'i',
821
+ '\u24D9': 'j',
822
+ '\uFF4A': 'j',
823
+ '\u0135': 'j',
824
+ '\u01F0': 'j',
825
+ '\u0249': 'j',
826
+ '\u24DA': 'k',
827
+ '\uFF4B': 'k',
828
+ '\u1E31': 'k',
829
+ '\u01E9': 'k',
830
+ '\u1E33': 'k',
831
+ '\u0137': 'k',
832
+ '\u1E35': 'k',
833
+ '\u0199': 'k',
834
+ '\u2C6A': 'k',
835
+ '\uA741': 'k',
836
+ '\uA743': 'k',
837
+ '\uA745': 'k',
838
+ '\uA7A3': 'k',
839
+ '\u24DB': 'l',
840
+ '\uFF4C': 'l',
841
+ '\u0140': 'l',
842
+ '\u013A': 'l',
843
+ '\u013E': 'l',
844
+ '\u1E37': 'l',
845
+ '\u1E39': 'l',
846
+ '\u013C': 'l',
847
+ '\u1E3D': 'l',
848
+ '\u1E3B': 'l',
849
+ '\u017F': 'l',
850
+ '\u0142': 'l',
851
+ '\u019A': 'l',
852
+ '\u026B': 'l',
853
+ '\u2C61': 'l',
854
+ '\uA749': 'l',
855
+ '\uA781': 'l',
856
+ '\uA747': 'l',
857
+ '\u01C9': 'lj',
858
+ '\u24DC': 'm',
859
+ '\uFF4D': 'm',
860
+ '\u1E3F': 'm',
861
+ '\u1E41': 'm',
862
+ '\u1E43': 'm',
863
+ '\u0271': 'm',
864
+ '\u026F': 'm',
865
+ '\u24DD': 'n',
866
+ '\uFF4E': 'n',
867
+ '\u01F9': 'n',
868
+ '\u0144': 'n',
869
+ '\u00F1': 'n',
870
+ '\u1E45': 'n',
871
+ '\u0148': 'n',
872
+ '\u1E47': 'n',
873
+ '\u0146': 'n',
874
+ '\u1E4B': 'n',
875
+ '\u1E49': 'n',
876
+ '\u019E': 'n',
877
+ '\u0272': 'n',
878
+ '\u0149': 'n',
879
+ '\uA791': 'n',
880
+ '\uA7A5': 'n',
881
+ '\u01CC': 'nj',
882
+ '\u24DE': 'o',
883
+ '\uFF4F': 'o',
884
+ '\u00F2': 'o',
885
+ '\u00F3': 'o',
886
+ '\u00F4': 'o',
887
+ '\u1ED3': 'o',
888
+ '\u1ED1': 'o',
889
+ '\u1ED7': 'o',
890
+ '\u1ED5': 'o',
891
+ '\u00F5': 'o',
892
+ '\u1E4D': 'o',
893
+ '\u022D': 'o',
894
+ '\u1E4F': 'o',
895
+ '\u014D': 'o',
896
+ '\u1E51': 'o',
897
+ '\u1E53': 'o',
898
+ '\u014F': 'o',
899
+ '\u022F': 'o',
900
+ '\u0231': 'o',
901
+ '\u00F6': 'o',
902
+ '\u022B': 'o',
903
+ '\u1ECF': 'o',
904
+ '\u0151': 'o',
905
+ '\u01D2': 'o',
906
+ '\u020D': 'o',
907
+ '\u020F': 'o',
908
+ '\u01A1': 'o',
909
+ '\u1EDD': 'o',
910
+ '\u1EDB': 'o',
911
+ '\u1EE1': 'o',
912
+ '\u1EDF': 'o',
913
+ '\u1EE3': 'o',
914
+ '\u1ECD': 'o',
915
+ '\u1ED9': 'o',
916
+ '\u01EB': 'o',
917
+ '\u01ED': 'o',
918
+ '\u00F8': 'o',
919
+ '\u01FF': 'o',
920
+ '\u0254': 'o',
921
+ '\uA74B': 'o',
922
+ '\uA74D': 'o',
923
+ '\u0275': 'o',
924
+ '\u01A3': 'oi',
925
+ '\u0223': 'ou',
926
+ '\uA74F': 'oo',
927
+ '\u24DF': 'p',
928
+ '\uFF50': 'p',
929
+ '\u1E55': 'p',
930
+ '\u1E57': 'p',
931
+ '\u01A5': 'p',
932
+ '\u1D7D': 'p',
933
+ '\uA751': 'p',
934
+ '\uA753': 'p',
935
+ '\uA755': 'p',
936
+ '\u24E0': 'q',
937
+ '\uFF51': 'q',
938
+ '\u024B': 'q',
939
+ '\uA757': 'q',
940
+ '\uA759': 'q',
941
+ '\u24E1': 'r',
942
+ '\uFF52': 'r',
943
+ '\u0155': 'r',
944
+ '\u1E59': 'r',
945
+ '\u0159': 'r',
946
+ '\u0211': 'r',
947
+ '\u0213': 'r',
948
+ '\u1E5B': 'r',
949
+ '\u1E5D': 'r',
950
+ '\u0157': 'r',
951
+ '\u1E5F': 'r',
952
+ '\u024D': 'r',
953
+ '\u027D': 'r',
954
+ '\uA75B': 'r',
955
+ '\uA7A7': 'r',
956
+ '\uA783': 'r',
957
+ '\u24E2': 's',
958
+ '\uFF53': 's',
959
+ '\u00DF': 's',
960
+ '\u015B': 's',
961
+ '\u1E65': 's',
962
+ '\u015D': 's',
963
+ '\u1E61': 's',
964
+ '\u0161': 's',
965
+ '\u1E67': 's',
966
+ '\u1E63': 's',
967
+ '\u1E69': 's',
968
+ '\u0219': 's',
969
+ '\u015F': 's',
970
+ '\u023F': 's',
971
+ '\uA7A9': 's',
972
+ '\uA785': 's',
973
+ '\u1E9B': 's',
974
+ '\u24E3': 't',
975
+ '\uFF54': 't',
976
+ '\u1E6B': 't',
977
+ '\u1E97': 't',
978
+ '\u0165': 't',
979
+ '\u1E6D': 't',
980
+ '\u021B': 't',
981
+ '\u0163': 't',
982
+ '\u1E71': 't',
983
+ '\u1E6F': 't',
984
+ '\u0167': 't',
985
+ '\u01AD': 't',
986
+ '\u0288': 't',
987
+ '\u2C66': 't',
988
+ '\uA787': 't',
989
+ '\uA729': 'tz',
990
+ '\u24E4': 'u',
991
+ '\uFF55': 'u',
992
+ '\u00F9': 'u',
993
+ '\u00FA': 'u',
994
+ '\u00FB': 'u',
995
+ '\u0169': 'u',
996
+ '\u1E79': 'u',
997
+ '\u016B': 'u',
998
+ '\u1E7B': 'u',
999
+ '\u016D': 'u',
1000
+ '\u00FC': 'u',
1001
+ '\u01DC': 'u',
1002
+ '\u01D8': 'u',
1003
+ '\u01D6': 'u',
1004
+ '\u01DA': 'u',
1005
+ '\u1EE7': 'u',
1006
+ '\u016F': 'u',
1007
+ '\u0171': 'u',
1008
+ '\u01D4': 'u',
1009
+ '\u0215': 'u',
1010
+ '\u0217': 'u',
1011
+ '\u01B0': 'u',
1012
+ '\u1EEB': 'u',
1013
+ '\u1EE9': 'u',
1014
+ '\u1EEF': 'u',
1015
+ '\u1EED': 'u',
1016
+ '\u1EF1': 'u',
1017
+ '\u1EE5': 'u',
1018
+ '\u1E73': 'u',
1019
+ '\u0173': 'u',
1020
+ '\u1E77': 'u',
1021
+ '\u1E75': 'u',
1022
+ '\u0289': 'u',
1023
+ '\u24E5': 'v',
1024
+ '\uFF56': 'v',
1025
+ '\u1E7D': 'v',
1026
+ '\u1E7F': 'v',
1027
+ '\u028B': 'v',
1028
+ '\uA75F': 'v',
1029
+ '\u028C': 'v',
1030
+ '\uA761': 'vy',
1031
+ '\u24E6': 'w',
1032
+ '\uFF57': 'w',
1033
+ '\u1E81': 'w',
1034
+ '\u1E83': 'w',
1035
+ '\u0175': 'w',
1036
+ '\u1E87': 'w',
1037
+ '\u1E85': 'w',
1038
+ '\u1E98': 'w',
1039
+ '\u1E89': 'w',
1040
+ '\u2C73': 'w',
1041
+ '\u24E7': 'x',
1042
+ '\uFF58': 'x',
1043
+ '\u1E8B': 'x',
1044
+ '\u1E8D': 'x',
1045
+ '\u24E8': 'y',
1046
+ '\uFF59': 'y',
1047
+ '\u1EF3': 'y',
1048
+ '\u00FD': 'y',
1049
+ '\u0177': 'y',
1050
+ '\u1EF9': 'y',
1051
+ '\u0233': 'y',
1052
+ '\u1E8F': 'y',
1053
+ '\u00FF': 'y',
1054
+ '\u1EF7': 'y',
1055
+ '\u1E99': 'y',
1056
+ '\u1EF5': 'y',
1057
+ '\u01B4': 'y',
1058
+ '\u024F': 'y',
1059
+ '\u1EFF': 'y',
1060
+ '\u24E9': 'z',
1061
+ '\uFF5A': 'z',
1062
+ '\u017A': 'z',
1063
+ '\u1E91': 'z',
1064
+ '\u017C': 'z',
1065
+ '\u017E': 'z',
1066
+ '\u1E93': 'z',
1067
+ '\u1E95': 'z',
1068
+ '\u01B6': 'z',
1069
+ '\u0225': 'z',
1070
+ '\u0240': 'z',
1071
+ '\u2C6C': 'z',
1072
+ '\uA763': 'z',
1073
+ '\u0386': '\u0391',
1074
+ '\u0388': '\u0395',
1075
+ '\u0389': '\u0397',
1076
+ '\u038A': '\u0399',
1077
+ '\u03AA': '\u0399',
1078
+ '\u038C': '\u039F',
1079
+ '\u038E': '\u03A5',
1080
+ '\u03AB': '\u03A5',
1081
+ '\u038F': '\u03A9',
1082
+ '\u03AC': '\u03B1',
1083
+ '\u03AD': '\u03B5',
1084
+ '\u03AE': '\u03B7',
1085
+ '\u03AF': '\u03B9',
1086
+ '\u03CA': '\u03B9',
1087
+ '\u0390': '\u03B9',
1088
+ '\u03CC': '\u03BF',
1089
+ '\u03CD': '\u03C5',
1090
+ '\u03CB': '\u03C5',
1091
+ '\u03B0': '\u03C5',
1092
+ '\u03C9': '\u03C9',
1093
+ '\u03C2': '\u03C3'
1094
+ };
1095
+ /**
1096
+ * @param {?} text
1097
+ * @return {?}
1098
+ */
1099
+ function stripSpecialChars(text) {
1100
+ /** @type {?} */
1101
+ const match = (/**
1102
+ * @param {?} a
1103
+ * @return {?}
1104
+ */
1105
+ (a) => {
1106
+ return diacritics[a] || a;
1107
+ });
1108
+ return text.replace(/[^\u0000-\u007E]/g, match);
1109
+ }
1110
+
1111
+ /**
1112
+ * @fileoverview added by tsickle
1113
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1114
+ */
1115
+ class ItemsList {
1116
+ /**
1117
+ * @param {?} _ngSelect
1118
+ * @param {?} _selectionModel
1119
+ */
1120
+ constructor(_ngSelect, _selectionModel) {
1121
+ this._ngSelect = _ngSelect;
1122
+ this._selectionModel = _selectionModel;
1123
+ this._items = [];
1124
+ this._filteredItems = [];
1125
+ this._markedIndex = -1;
1126
+ }
1127
+ /**
1128
+ * @return {?}
1129
+ */
1130
+ get items() {
1131
+ return this._items;
1132
+ }
1133
+ /**
1134
+ * @return {?}
1135
+ */
1136
+ get filteredItems() {
1137
+ return this._filteredItems;
1138
+ }
1139
+ /**
1140
+ * @return {?}
1141
+ */
1142
+ get markedIndex() {
1143
+ return this._markedIndex;
1144
+ }
1145
+ /**
1146
+ * @return {?}
1147
+ */
1148
+ get selectedItems() {
1149
+ return this._selectionModel.value;
1150
+ }
1151
+ /**
1152
+ * @return {?}
1153
+ */
1154
+ get markedItem() {
1155
+ return this._filteredItems[this._markedIndex];
1156
+ }
1157
+ /**
1158
+ * @return {?}
1159
+ */
1160
+ get noItemsToSelect() {
1161
+ return this._ngSelect.hideSelected && this._items.length === this.selectedItems.length;
1162
+ }
1163
+ /**
1164
+ * @return {?}
1165
+ */
1166
+ get maxItemsSelected() {
1167
+ return this._ngSelect.multiple && this._ngSelect.maxSelectedItems <= this.selectedItems.length;
1168
+ }
1169
+ /**
1170
+ * @return {?}
1171
+ */
1172
+ get lastSelectedItem() {
1173
+ /** @type {?} */
1174
+ let i = this.selectedItems.length - 1;
1175
+ for (; i >= 0; i--) {
1176
+ /** @type {?} */
1177
+ let item = this.selectedItems[i];
1178
+ if (!item.disabled) {
1179
+ return item;
1180
+ }
1181
+ }
1182
+ return null;
1183
+ }
1184
+ /**
1185
+ * @param {?} items
1186
+ * @return {?}
1187
+ */
1188
+ setItems(items) {
1189
+ this._items = items.map((/**
1190
+ * @param {?} item
1191
+ * @param {?} index
1192
+ * @return {?}
1193
+ */
1194
+ (item, index) => this.mapItem(item, index)));
1195
+ if (this._ngSelect.groupBy) {
1196
+ this._groups = this._groupBy(this._items, this._ngSelect.groupBy);
1197
+ this._items = this._flatten(this._groups);
1198
+ }
1199
+ else {
1200
+ this._groups = new Map();
1201
+ this._groups.set(undefined, this._items);
1202
+ }
1203
+ this._filteredItems = [...this._items];
1204
+ }
1205
+ /**
1206
+ * @param {?} item
1207
+ * @return {?}
1208
+ */
1209
+ select(item) {
1210
+ if (item.selected || this.maxItemsSelected) {
1211
+ return;
1212
+ }
1213
+ /** @type {?} */
1214
+ const multiple = this._ngSelect.multiple;
1215
+ if (!multiple) {
1216
+ this.clearSelected();
1217
+ }
1218
+ this._selectionModel.select(item, multiple, this._ngSelect.selectableGroupAsModel);
1219
+ if (this._ngSelect.hideSelected) {
1220
+ this._hideSelected(item);
1221
+ }
1222
+ }
1223
+ /**
1224
+ * @param {?} item
1225
+ * @return {?}
1226
+ */
1227
+ unselect(item) {
1228
+ if (!item.selected) {
1229
+ return;
1230
+ }
1231
+ this._selectionModel.unselect(item, this._ngSelect.multiple);
1232
+ if (this._ngSelect.hideSelected && isDefined(item.index) && this._ngSelect.multiple) {
1233
+ this._showSelected(item);
1234
+ }
1235
+ }
1236
+ /**
1237
+ * @param {?} value
1238
+ * @return {?}
1239
+ */
1240
+ findItem(value) {
1241
+ /** @type {?} */
1242
+ let findBy;
1243
+ if (this._ngSelect.compareWith) {
1244
+ findBy = (/**
1245
+ * @param {?} item
1246
+ * @return {?}
1247
+ */
1248
+ item => this._ngSelect.compareWith(item.value, value));
1249
+ }
1250
+ else if (this._ngSelect.bindValue) {
1251
+ findBy = (/**
1252
+ * @param {?} item
1253
+ * @return {?}
1254
+ */
1255
+ item => !item.children && this.resolveNested(item.value, this._ngSelect.bindValue) === value);
1256
+ }
1257
+ else {
1258
+ findBy = (/**
1259
+ * @param {?} item
1260
+ * @return {?}
1261
+ */
1262
+ item => item.value === value ||
1263
+ !item.children && item.label && item.label === this.resolveNested(value, this._ngSelect.bindLabel));
1264
+ }
1265
+ return this._items.find((/**
1266
+ * @param {?} item
1267
+ * @return {?}
1268
+ */
1269
+ item => findBy(item)));
1270
+ }
1271
+ /**
1272
+ * @param {?} item
1273
+ * @return {?}
1274
+ */
1275
+ addItem(item) {
1276
+ /** @type {?} */
1277
+ const option = this.mapItem(item, this._items.length);
1278
+ this._items.push(option);
1279
+ this._filteredItems.push(option);
1280
+ return option;
1281
+ }
1282
+ /**
1283
+ * @param {?=} keepDisabled
1284
+ * @return {?}
1285
+ */
1286
+ clearSelected(keepDisabled = false) {
1287
+ this._selectionModel.clear(keepDisabled);
1288
+ this._items.forEach((/**
1289
+ * @param {?} item
1290
+ * @return {?}
1291
+ */
1292
+ item => {
1293
+ item.selected = keepDisabled && item.selected && item.disabled;
1294
+ item.marked = false;
1295
+ }));
1296
+ if (this._ngSelect.hideSelected) {
1297
+ this.resetFilteredItems();
1298
+ }
1299
+ }
1300
+ /**
1301
+ * @param {?} term
1302
+ * @return {?}
1303
+ */
1304
+ findByLabel(term) {
1305
+ term = stripSpecialChars(term).toLocaleLowerCase();
1306
+ return this.filteredItems.find((/**
1307
+ * @param {?} item
1308
+ * @return {?}
1309
+ */
1310
+ item => {
1311
+ /** @type {?} */
1312
+ const label = stripSpecialChars(item.label).toLocaleLowerCase();
1313
+ return label.substr(0, term.length) === term;
1314
+ }));
1315
+ }
1316
+ /**
1317
+ * @param {?} term
1318
+ * @return {?}
1319
+ */
1320
+ filter(term) {
1321
+ if (!term) {
1322
+ this.resetFilteredItems();
1323
+ return;
1324
+ }
1325
+ this._filteredItems = [];
1326
+ term = this._ngSelect.searchFn ? term : stripSpecialChars(term).toLocaleLowerCase();
1327
+ /** @type {?} */
1328
+ const match = this._ngSelect.searchFn || this._defaultSearchFn;
1329
+ /** @type {?} */
1330
+ const hideSelected = this._ngSelect.hideSelected;
1331
+ for (const key of Array.from(this._groups.keys())) {
1332
+ /** @type {?} */
1333
+ const matchedItems = [];
1334
+ for (const item of this._groups.get(key)) {
1335
+ if (hideSelected && (item.parent && item.parent.selected || item.selected)) {
1336
+ continue;
1337
+ }
1338
+ /** @type {?} */
1339
+ const searchItem = this._ngSelect.searchFn ? item.value : item;
1340
+ if (match(term, searchItem)) {
1341
+ matchedItems.push(item);
1342
+ }
1343
+ }
1344
+ if (matchedItems.length > 0) {
1345
+ const [last] = matchedItems.slice(-1);
1346
+ if (last.parent) {
1347
+ /** @type {?} */
1348
+ const head = this._items.find((/**
1349
+ * @param {?} x
1350
+ * @return {?}
1351
+ */
1352
+ x => x === last.parent));
1353
+ this._filteredItems.push(head);
1354
+ }
1355
+ this._filteredItems.push(...matchedItems);
1356
+ }
1357
+ }
1358
+ }
1359
+ /**
1360
+ * @return {?}
1361
+ */
1362
+ resetFilteredItems() {
1363
+ if (this._filteredItems.length === this._items.length) {
1364
+ return;
1365
+ }
1366
+ if (this._ngSelect.hideSelected && this.selectedItems.length > 0) {
1367
+ this._filteredItems = this._items.filter((/**
1368
+ * @param {?} x
1369
+ * @return {?}
1370
+ */
1371
+ x => !x.selected));
1372
+ }
1373
+ else {
1374
+ this._filteredItems = this._items;
1375
+ }
1376
+ }
1377
+ /**
1378
+ * @return {?}
1379
+ */
1380
+ unmarkItem() {
1381
+ this._markedIndex = -1;
1382
+ }
1383
+ /**
1384
+ * @return {?}
1385
+ */
1386
+ markNextItem() {
1387
+ this._stepToItem(+1);
1388
+ }
1389
+ /**
1390
+ * @return {?}
1391
+ */
1392
+ markPreviousItem() {
1393
+ this._stepToItem(-1);
1394
+ }
1395
+ /**
1396
+ * @param {?} item
1397
+ * @return {?}
1398
+ */
1399
+ markItem(item) {
1400
+ this._markedIndex = this._filteredItems.indexOf(item);
1401
+ }
1402
+ /**
1403
+ * @param {?=} markDefault
1404
+ * @return {?}
1405
+ */
1406
+ markSelectedOrDefault(markDefault) {
1407
+ if (this._filteredItems.length === 0) {
1408
+ return;
1409
+ }
1410
+ /** @type {?} */
1411
+ const lastMarkedIndex = this._getLastMarkedIndex();
1412
+ if (lastMarkedIndex > -1) {
1413
+ this._markedIndex = lastMarkedIndex;
1414
+ }
1415
+ else {
1416
+ this._markedIndex = markDefault ? this.filteredItems.findIndex((/**
1417
+ * @param {?} x
1418
+ * @return {?}
1419
+ */
1420
+ x => !x.disabled)) : -1;
1421
+ }
1422
+ }
1423
+ /**
1424
+ * @param {?} option
1425
+ * @param {?} key
1426
+ * @return {?}
1427
+ */
1428
+ resolveNested(option, key) {
1429
+ if (!isObject(option)) {
1430
+ return option;
1431
+ }
1432
+ if (key.indexOf('.') === -1) {
1433
+ return option[key];
1434
+ }
1435
+ else {
1436
+ /** @type {?} */
1437
+ let keys = key.split('.');
1438
+ /** @type {?} */
1439
+ let value = option;
1440
+ for (let i = 0, len = keys.length; i < len; ++i) {
1441
+ if (value == null) {
1442
+ return null;
1443
+ }
1444
+ value = value[keys[i]];
1445
+ }
1446
+ return value;
1447
+ }
1448
+ }
1449
+ /**
1450
+ * @param {?} item
1451
+ * @param {?} index
1452
+ * @return {?}
1453
+ */
1454
+ mapItem(item, index) {
1455
+ /** @type {?} */
1456
+ const label = isDefined(item.$ngOptionLabel) ? item.$ngOptionLabel : this.resolveNested(item, this._ngSelect.bindLabel);
1457
+ /** @type {?} */
1458
+ const value = isDefined(item.$ngOptionValue) ? item.$ngOptionValue : item;
1459
+ return {
1460
+ index: index,
1461
+ label: isDefined(label) ? label.toString() : '',
1462
+ value: value,
1463
+ disabled: item.disabled,
1464
+ htmlId: `${this._ngSelect.dropdownId}-${index}`,
1465
+ };
1466
+ }
1467
+ /**
1468
+ * @return {?}
1469
+ */
1470
+ mapSelectedItems() {
1471
+ /** @type {?} */
1472
+ const multiple = this._ngSelect.multiple;
1473
+ for (const selected of this.selectedItems) {
1474
+ /** @type {?} */
1475
+ const value = this._ngSelect.bindValue ? this.resolveNested(selected.value, this._ngSelect.bindValue) : selected.value;
1476
+ /** @type {?} */
1477
+ const item = isDefined(value) ? this.findItem(value) : null;
1478
+ this._selectionModel.unselect(selected, multiple);
1479
+ this._selectionModel.select(item || selected, multiple, this._ngSelect.selectableGroupAsModel);
1480
+ }
1481
+ if (this._ngSelect.hideSelected) {
1482
+ this._filteredItems = this.filteredItems.filter((/**
1483
+ * @param {?} x
1484
+ * @return {?}
1485
+ */
1486
+ x => this.selectedItems.indexOf(x) === -1));
1487
+ }
1488
+ }
1489
+ /**
1490
+ * @private
1491
+ * @param {?} item
1492
+ * @return {?}
1493
+ */
1494
+ _showSelected(item) {
1495
+ this._filteredItems.push(item);
1496
+ if (item.parent) {
1497
+ /** @type {?} */
1498
+ const parent = item.parent;
1499
+ /** @type {?} */
1500
+ const parentExists = this._filteredItems.find((/**
1501
+ * @param {?} x
1502
+ * @return {?}
1503
+ */
1504
+ x => x === parent));
1505
+ if (!parentExists) {
1506
+ this._filteredItems.push(parent);
1507
+ }
1508
+ }
1509
+ else if (item.children) {
1510
+ for (const child of item.children) {
1511
+ child.selected = false;
1512
+ this._filteredItems.push(child);
1513
+ }
1514
+ }
1515
+ this._filteredItems = [...this._filteredItems.sort((/**
1516
+ * @param {?} a
1517
+ * @param {?} b
1518
+ * @return {?}
1519
+ */
1520
+ (a, b) => (a.index - b.index)))];
1521
+ }
1522
+ /**
1523
+ * @private
1524
+ * @param {?} item
1525
+ * @return {?}
1526
+ */
1527
+ _hideSelected(item) {
1528
+ this._filteredItems = this._filteredItems.filter((/**
1529
+ * @param {?} x
1530
+ * @return {?}
1531
+ */
1532
+ x => x !== item));
1533
+ if (item.parent) {
1534
+ /** @type {?} */
1535
+ const children = item.parent.children;
1536
+ if (children.every((/**
1537
+ * @param {?} x
1538
+ * @return {?}
1539
+ */
1540
+ x => x.selected))) {
1541
+ this._filteredItems = this._filteredItems.filter((/**
1542
+ * @param {?} x
1543
+ * @return {?}
1544
+ */
1545
+ x => x !== item.parent));
1546
+ }
1547
+ }
1548
+ else if (item.children) {
1549
+ this._filteredItems = this.filteredItems.filter((/**
1550
+ * @param {?} x
1551
+ * @return {?}
1552
+ */
1553
+ x => x.parent !== item));
1554
+ }
1555
+ }
1556
+ /**
1557
+ * @private
1558
+ * @param {?} search
1559
+ * @param {?} opt
1560
+ * @return {?}
1561
+ */
1562
+ _defaultSearchFn(search, opt) {
1563
+ /** @type {?} */
1564
+ const label = stripSpecialChars(opt.label).toLocaleLowerCase();
1565
+ return label.indexOf(search) > -1;
1566
+ }
1567
+ /**
1568
+ * @private
1569
+ * @param {?} steps
1570
+ * @return {?}
1571
+ */
1572
+ _getNextItemIndex(steps) {
1573
+ if (steps > 0) {
1574
+ return (this._markedIndex === this._filteredItems.length - 1) ? 0 : (this._markedIndex + 1);
1575
+ }
1576
+ return (this._markedIndex <= 0) ? (this._filteredItems.length - 1) : (this._markedIndex - 1);
1577
+ }
1578
+ /**
1579
+ * @private
1580
+ * @param {?} steps
1581
+ * @return {?}
1582
+ */
1583
+ _stepToItem(steps) {
1584
+ if (this._filteredItems.length === 0 || this._filteredItems.every((/**
1585
+ * @param {?} x
1586
+ * @return {?}
1587
+ */
1588
+ x => x.disabled))) {
1589
+ return;
1590
+ }
1591
+ this._markedIndex = this._getNextItemIndex(steps);
1592
+ if (this.markedItem.disabled) {
1593
+ this._stepToItem(steps);
1594
+ }
1595
+ }
1596
+ /**
1597
+ * @private
1598
+ * @return {?}
1599
+ */
1600
+ _getLastMarkedIndex() {
1601
+ if (this._ngSelect.hideSelected) {
1602
+ return -1;
1603
+ }
1604
+ if (this._markedIndex > -1 && this.markedItem === undefined) {
1605
+ return -1;
1606
+ }
1607
+ /** @type {?} */
1608
+ const selectedIndex = this._filteredItems.indexOf(this.lastSelectedItem);
1609
+ if (this.lastSelectedItem && selectedIndex < 0) {
1610
+ return -1;
1611
+ }
1612
+ return Math.max(this.markedIndex, selectedIndex);
1613
+ }
1614
+ /**
1615
+ * @private
1616
+ * @param {?} items
1617
+ * @param {?} prop
1618
+ * @return {?}
1619
+ */
1620
+ _groupBy(items, prop) {
1621
+ /** @type {?} */
1622
+ const groups = new Map();
1623
+ if (items.length === 0) {
1624
+ return groups;
1625
+ }
1626
+ // Check if items are already grouped by given key.
1627
+ if (Array.isArray(items[0].value[(/** @type {?} */ (prop))])) {
1628
+ for (const item of items) {
1629
+ /** @type {?} */
1630
+ const children = (item.value[(/** @type {?} */ (prop))] || []).map((/**
1631
+ * @param {?} x
1632
+ * @param {?} index
1633
+ * @return {?}
1634
+ */
1635
+ (x, index) => this.mapItem(x, index)));
1636
+ groups.set(item, children);
1637
+ }
1638
+ return groups;
1639
+ }
1640
+ /** @type {?} */
1641
+ const isFnKey = isFunction(this._ngSelect.groupBy);
1642
+ /** @type {?} */
1643
+ const keyFn = (/**
1644
+ * @param {?} item
1645
+ * @return {?}
1646
+ */
1647
+ (item) => {
1648
+ /** @type {?} */
1649
+ let key = isFnKey ? ((/** @type {?} */ (prop)))(item.value) : item.value[(/** @type {?} */ (prop))];
1650
+ return isDefined(key) ? key : undefined;
1651
+ });
1652
+ // Group items by key.
1653
+ for (const item of items) {
1654
+ /** @type {?} */
1655
+ let key = keyFn(item);
1656
+ /** @type {?} */
1657
+ const group = groups.get(key);
1658
+ if (group) {
1659
+ group.push(item);
1660
+ }
1661
+ else {
1662
+ groups.set(key, [item]);
1663
+ }
1664
+ }
1665
+ return groups;
1666
+ }
1667
+ /**
1668
+ * @private
1669
+ * @param {?} groups
1670
+ * @return {?}
1671
+ */
1672
+ _flatten(groups) {
1673
+ /** @type {?} */
1674
+ const isGroupByFn = isFunction(this._ngSelect.groupBy);
1675
+ /** @type {?} */
1676
+ const items = [];
1677
+ for (const key of Array.from(groups.keys())) {
1678
+ /** @type {?} */
1679
+ let i = items.length;
1680
+ if (key === undefined) {
1681
+ /** @type {?} */
1682
+ const withoutGroup = groups.get(undefined) || [];
1683
+ items.push(...withoutGroup.map((/**
1684
+ * @param {?} x
1685
+ * @return {?}
1686
+ */
1687
+ x => (Object.assign({}, x, { index: i++ })))));
1688
+ continue;
1689
+ }
1690
+ /** @type {?} */
1691
+ const isObjectKey = isObject(key);
1692
+ /** @type {?} */
1693
+ const parent = {
1694
+ label: isObjectKey ? '' : String(key),
1695
+ children: undefined,
1696
+ parent: null,
1697
+ index: i++,
1698
+ disabled: !this._ngSelect.selectableGroup,
1699
+ htmlId: newId(),
1700
+ };
1701
+ /** @type {?} */
1702
+ const groupKey = isGroupByFn ? this._ngSelect.bindLabel : (/** @type {?} */ (this._ngSelect.groupBy));
1703
+ /** @type {?} */
1704
+ const groupValue = this._ngSelect.groupValue || ((/**
1705
+ * @return {?}
1706
+ */
1707
+ () => {
1708
+ if (isObjectKey) {
1709
+ return ((/** @type {?} */ (key))).value;
1710
+ }
1711
+ return { [groupKey]: key };
1712
+ }));
1713
+ /** @type {?} */
1714
+ const children = groups.get(key).map((/**
1715
+ * @param {?} x
1716
+ * @return {?}
1717
+ */
1718
+ x => {
1719
+ x.parent = parent;
1720
+ x.children = undefined;
1721
+ x.index = i++;
1722
+ return x;
1723
+ }));
1724
+ parent.children = children;
1725
+ parent.value = groupValue(key, children.map((/**
1726
+ * @param {?} x
1727
+ * @return {?}
1728
+ */
1729
+ x => x.value)));
1730
+ items.push(parent);
1731
+ items.push(...children);
1732
+ }
1733
+ return items;
1734
+ }
1735
+ }
1736
+
1737
+ /**
1738
+ * @fileoverview added by tsickle
1739
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1740
+ */
1741
+ /** @enum {number} */
1742
+ const KeyCode = {
1743
+ Tab: 9,
1744
+ Enter: 13,
1745
+ Esc: 27,
1746
+ Space: 32,
1747
+ ArrowUp: 38,
1748
+ ArrowDown: 40,
1749
+ Backspace: 8,
1750
+ };
1751
+ KeyCode[KeyCode.Tab] = 'Tab';
1752
+ KeyCode[KeyCode.Enter] = 'Enter';
1753
+ KeyCode[KeyCode.Esc] = 'Esc';
1754
+ KeyCode[KeyCode.Space] = 'Space';
1755
+ KeyCode[KeyCode.ArrowUp] = 'ArrowUp';
1756
+ KeyCode[KeyCode.ArrowDown] = 'ArrowDown';
1757
+ KeyCode[KeyCode.Backspace] = 'Backspace';
1758
+
1759
+ /**
1760
+ * @fileoverview added by tsickle
1761
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1762
+ */
1763
+ class NgDropdownPanelService {
1764
+ constructor() {
1765
+ this._dimensions = {
1766
+ itemHeight: 0,
1767
+ panelHeight: 0,
1768
+ itemsPerViewport: 0
1769
+ };
1770
+ }
1771
+ /**
1772
+ * @return {?}
1773
+ */
1774
+ get dimensions() {
1775
+ return this._dimensions;
1776
+ }
1777
+ /**
1778
+ * @param {?} scrollPos
1779
+ * @param {?} itemsLength
1780
+ * @param {?} buffer
1781
+ * @return {?}
1782
+ */
1783
+ calculateItems(scrollPos, itemsLength, buffer) {
1784
+ /** @type {?} */
1785
+ const d = this._dimensions;
1786
+ /** @type {?} */
1787
+ const scrollHeight = d.itemHeight * itemsLength;
1788
+ /** @type {?} */
1789
+ const scrollTop = Math.max(0, scrollPos);
1790
+ /** @type {?} */
1791
+ const indexByScrollTop = scrollTop / scrollHeight * itemsLength;
1792
+ /** @type {?} */
1793
+ let end = Math.min(itemsLength, Math.ceil(indexByScrollTop) + (d.itemsPerViewport + 1));
1794
+ /** @type {?} */
1795
+ const maxStartEnd = end;
1796
+ /** @type {?} */
1797
+ const maxStart = Math.max(0, maxStartEnd - d.itemsPerViewport);
1798
+ /** @type {?} */
1799
+ let start = Math.min(maxStart, Math.floor(indexByScrollTop));
1800
+ /** @type {?} */
1801
+ let topPadding = d.itemHeight * Math.ceil(start) - (d.itemHeight * Math.min(start, buffer));
1802
+ topPadding = !isNaN(topPadding) ? topPadding : 0;
1803
+ start = !isNaN(start) ? start : -1;
1804
+ end = !isNaN(end) ? end : -1;
1805
+ start -= buffer;
1806
+ start = Math.max(0, start);
1807
+ end += buffer;
1808
+ end = Math.min(itemsLength, end);
1809
+ return {
1810
+ topPadding,
1811
+ scrollHeight,
1812
+ start,
1813
+ end
1814
+ };
1815
+ }
1816
+ /**
1817
+ * @param {?} itemHeight
1818
+ * @param {?} panelHeight
1819
+ * @return {?}
1820
+ */
1821
+ setDimensions(itemHeight, panelHeight) {
1822
+ /** @type {?} */
1823
+ const itemsPerViewport = Math.max(1, Math.floor(panelHeight / itemHeight));
1824
+ this._dimensions = {
1825
+ itemHeight,
1826
+ panelHeight,
1827
+ itemsPerViewport
1828
+ };
1829
+ }
1830
+ /**
1831
+ * @param {?} itemTop
1832
+ * @param {?} itemHeight
1833
+ * @param {?} lastScroll
1834
+ * @return {?}
1835
+ */
1836
+ getScrollTo(itemTop, itemHeight, lastScroll) {
1837
+ /** @type {?} */
1838
+ const itemBottom = itemTop + itemHeight;
1839
+ /** @type {?} */
1840
+ const top = lastScroll;
1841
+ /** @type {?} */
1842
+ const bottom = top + this.dimensions.panelHeight;
1843
+ if (itemBottom > bottom) {
1844
+ return top + itemBottom - bottom;
1845
+ }
1846
+ else if (itemTop <= top) {
1847
+ return itemTop;
1848
+ }
1849
+ return null;
1850
+ }
1851
+ }
1852
+
1853
+ /**
1854
+ * @fileoverview added by tsickle
1855
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1856
+ */
1857
+ /** @type {?} */
1858
+ const TOP_CSS_CLASS = 'ng-select-top';
1859
+ /** @type {?} */
1860
+ const BOTTOM_CSS_CLASS = 'ng-select-bottom';
1861
+ /** @type {?} */
1862
+ const SCROLL_SCHEDULER = typeof requestAnimationFrame !== 'undefined' ? animationFrameScheduler : asapScheduler;
1863
+ class NgDropdownPanelComponent {
1864
+ /**
1865
+ * @param {?} _renderer
1866
+ * @param {?} _zone
1867
+ * @param {?} _panelService
1868
+ * @param {?} _elementRef
1869
+ * @param {?} _document
1870
+ */
1871
+ constructor(_renderer, _zone, _panelService, _elementRef, _document) {
1872
+ this._renderer = _renderer;
1873
+ this._zone = _zone;
1874
+ this._panelService = _panelService;
1875
+ this._document = _document;
1876
+ this.items = [];
1877
+ this.position = 'auto';
1878
+ this.virtualScroll = false;
1879
+ this.filterValue = null;
1880
+ this.update = new EventEmitter();
1881
+ this.scroll = new EventEmitter();
1882
+ this.scrollToEnd = new EventEmitter();
1883
+ this.outsideClick = new EventEmitter();
1884
+ this._destroy$ = new Subject();
1885
+ this._scrollToEndFired = false;
1886
+ this._updateScrollHeight = false;
1887
+ this._lastScrollPosition = 0;
1888
+ this._dropdown = _elementRef.nativeElement;
1889
+ }
1890
+ /**
1891
+ * @return {?}
1892
+ */
1893
+ get currentPosition() {
1894
+ return this._currentPosition;
1895
+ }
1896
+ /**
1897
+ * @private
1898
+ * @return {?}
1899
+ */
1900
+ get itemsLength() {
1901
+ return this._itemsLength;
1902
+ }
1903
+ /**
1904
+ * @private
1905
+ * @param {?} value
1906
+ * @return {?}
1907
+ */
1908
+ set itemsLength(value) {
1909
+ if (value !== this._itemsLength) {
1910
+ this._itemsLength = value;
1911
+ this._onItemsLengthChanged();
1912
+ }
1913
+ }
1914
+ /**
1915
+ * @param {?} $event
1916
+ * @return {?}
1917
+ */
1918
+ handleMousedown($event) {
1919
+ /** @type {?} */
1920
+ const target = (/** @type {?} */ ($event.target));
1921
+ if (target.tagName === 'INPUT') {
1922
+ return;
1923
+ }
1924
+ $event.preventDefault();
1925
+ }
1926
+ /**
1927
+ * @return {?}
1928
+ */
1929
+ ngOnInit() {
1930
+ this._select = this._dropdown.parentElement;
1931
+ this._virtualPadding = this.paddingElementRef.nativeElement;
1932
+ this._scrollablePanel = this.scrollElementRef.nativeElement;
1933
+ this._contentPanel = this.contentElementRef.nativeElement;
1934
+ this._handleScroll();
1935
+ this._handleOutsideClick();
1936
+ this._appendDropdown();
1937
+ }
1938
+ /**
1939
+ * @param {?} changes
1940
+ * @return {?}
1941
+ */
1942
+ ngOnChanges(changes) {
1943
+ if (changes.items) {
1944
+ /** @type {?} */
1945
+ const change = changes.items;
1946
+ this._onItemsChange(change.currentValue, change.firstChange);
1947
+ }
1948
+ }
1949
+ /**
1950
+ * @return {?}
1951
+ */
1952
+ ngOnDestroy() {
1953
+ this._destroy$.next();
1954
+ this._destroy$.complete();
1955
+ this._destroy$.unsubscribe();
1956
+ if (this.appendTo) {
1957
+ this._renderer.removeChild(this._dropdown.parentNode, this._dropdown);
1958
+ }
1959
+ }
1960
+ /**
1961
+ * @param {?} option
1962
+ * @param {?=} startFromOption
1963
+ * @return {?}
1964
+ */
1965
+ scrollTo(option, startFromOption = false) {
1966
+ if (!option) {
1967
+ return;
1968
+ }
1969
+ /** @type {?} */
1970
+ const index = this.items.indexOf(option);
1971
+ if (index < 0 || index >= this.itemsLength) {
1972
+ return;
1973
+ }
1974
+ /** @type {?} */
1975
+ let scrollTo;
1976
+ if (this.virtualScroll) {
1977
+ /** @type {?} */
1978
+ const itemHeight = this._panelService.dimensions.itemHeight;
1979
+ scrollTo = this._panelService.getScrollTo(index * itemHeight, itemHeight, this._lastScrollPosition);
1980
+ }
1981
+ else {
1982
+ /** @type {?} */
1983
+ const item = this._dropdown.querySelector(`#${option.htmlId}`);
1984
+ /** @type {?} */
1985
+ const lastScroll = startFromOption ? item.offsetTop : this._lastScrollPosition;
1986
+ scrollTo = this._panelService.getScrollTo(item.offsetTop, item.clientHeight, lastScroll);
1987
+ }
1988
+ if (isDefined(scrollTo)) {
1989
+ this._scrollablePanel.scrollTop = scrollTo;
1990
+ }
1991
+ }
1992
+ /**
1993
+ * @return {?}
1994
+ */
1995
+ scrollToTag() {
1996
+ /** @type {?} */
1997
+ const panel = this._scrollablePanel;
1998
+ panel.scrollTop = panel.scrollHeight - panel.clientHeight;
1999
+ }
2000
+ /**
2001
+ * @return {?}
2002
+ */
2003
+ adjustPosition() {
2004
+ /** @type {?} */
2005
+ const parent = this._parent.getBoundingClientRect();
2006
+ /** @type {?} */
2007
+ const select = this._select.getBoundingClientRect();
2008
+ this._setOffset(parent, select);
2009
+ }
2010
+ /**
2011
+ * @private
2012
+ * @return {?}
2013
+ */
2014
+ _handleDropdownPosition() {
2015
+ this._currentPosition = this._calculateCurrentPosition(this._dropdown);
2016
+ if (this._currentPosition === 'top') {
2017
+ this._renderer.addClass(this._dropdown, TOP_CSS_CLASS);
2018
+ this._renderer.removeClass(this._dropdown, BOTTOM_CSS_CLASS);
2019
+ this._renderer.addClass(this._select, TOP_CSS_CLASS);
2020
+ this._renderer.removeClass(this._select, BOTTOM_CSS_CLASS);
2021
+ }
2022
+ else {
2023
+ this._renderer.addClass(this._dropdown, BOTTOM_CSS_CLASS);
2024
+ this._renderer.removeClass(this._dropdown, TOP_CSS_CLASS);
2025
+ this._renderer.addClass(this._select, BOTTOM_CSS_CLASS);
2026
+ this._renderer.removeClass(this._select, TOP_CSS_CLASS);
2027
+ }
2028
+ if (this.appendTo) {
2029
+ this._updatePosition();
2030
+ }
2031
+ this._dropdown.style.opacity = '1';
2032
+ }
2033
+ /**
2034
+ * @private
2035
+ * @return {?}
2036
+ */
2037
+ _handleScroll() {
2038
+ this._zone.runOutsideAngular((/**
2039
+ * @return {?}
2040
+ */
2041
+ () => {
2042
+ fromEvent(this.scrollElementRef.nativeElement, 'scroll')
2043
+ .pipe(takeUntil(this._destroy$), auditTime(0, SCROLL_SCHEDULER))
2044
+ .subscribe((/**
2045
+ * @param {?} e
2046
+ * @return {?}
2047
+ */
2048
+ (e) => this._onContentScrolled(e.target.scrollTop)));
2049
+ }));
2050
+ }
2051
+ /**
2052
+ * @private
2053
+ * @return {?}
2054
+ */
2055
+ _handleOutsideClick() {
2056
+ if (!this._document) {
2057
+ return;
2058
+ }
2059
+ this._zone.runOutsideAngular((/**
2060
+ * @return {?}
2061
+ */
2062
+ () => {
2063
+ merge(fromEvent(this._document, 'touchstart', { capture: true }), fromEvent(this._document, 'mousedown', { capture: true })).pipe(takeUntil(this._destroy$))
2064
+ .subscribe((/**
2065
+ * @param {?} $event
2066
+ * @return {?}
2067
+ */
2068
+ $event => this._checkToClose($event)));
2069
+ }));
2070
+ }
2071
+ /**
2072
+ * @private
2073
+ * @param {?} $event
2074
+ * @return {?}
2075
+ */
2076
+ _checkToClose($event) {
2077
+ if (this._select.contains($event.target) || this._dropdown.contains($event.target)) {
2078
+ return;
2079
+ }
2080
+ /** @type {?} */
2081
+ const path = $event.path || ($event.composedPath && $event.composedPath());
2082
+ if ($event.target && $event.target.shadowRoot && path && path[0] && this._select.contains(path[0])) {
2083
+ return;
2084
+ }
2085
+ this.outsideClick.emit();
2086
+ }
2087
+ /**
2088
+ * @private
2089
+ * @param {?} items
2090
+ * @param {?} firstChange
2091
+ * @return {?}
2092
+ */
2093
+ _onItemsChange(items, firstChange) {
2094
+ this.items = items || [];
2095
+ this._scrollToEndFired = false;
2096
+ this.itemsLength = items.length;
2097
+ if (this.virtualScroll) {
2098
+ this._updateItemsRange(firstChange);
2099
+ }
2100
+ else {
2101
+ this._updateItems(firstChange);
2102
+ }
2103
+ }
2104
+ /**
2105
+ * @private
2106
+ * @param {?} firstChange
2107
+ * @return {?}
2108
+ */
2109
+ _updateItems(firstChange) {
2110
+ this.update.emit(this.items);
2111
+ if (firstChange === false) {
2112
+ return;
2113
+ }
2114
+ this._zone.runOutsideAngular((/**
2115
+ * @return {?}
2116
+ */
2117
+ () => {
2118
+ Promise.resolve().then((/**
2119
+ * @return {?}
2120
+ */
2121
+ () => {
2122
+ /** @type {?} */
2123
+ const panelHeight = this._scrollablePanel.clientHeight;
2124
+ this._panelService.setDimensions(0, panelHeight);
2125
+ this._handleDropdownPosition();
2126
+ this.scrollTo(this.markedItem, firstChange);
2127
+ }));
2128
+ }));
2129
+ }
2130
+ /**
2131
+ * @private
2132
+ * @param {?} firstChange
2133
+ * @return {?}
2134
+ */
2135
+ _updateItemsRange(firstChange) {
2136
+ this._zone.runOutsideAngular((/**
2137
+ * @return {?}
2138
+ */
2139
+ () => {
2140
+ this._measureDimensions().then((/**
2141
+ * @return {?}
2142
+ */
2143
+ () => {
2144
+ if (firstChange) {
2145
+ this._renderItemsRange(this._startOffset);
2146
+ this._handleDropdownPosition();
2147
+ }
2148
+ else {
2149
+ this._renderItemsRange();
2150
+ }
2151
+ }));
2152
+ }));
2153
+ }
2154
+ /**
2155
+ * @private
2156
+ * @param {?} scrollTop
2157
+ * @return {?}
2158
+ */
2159
+ _onContentScrolled(scrollTop) {
2160
+ if (this.virtualScroll) {
2161
+ this._renderItemsRange(scrollTop);
2162
+ }
2163
+ this._lastScrollPosition = scrollTop;
2164
+ this._fireScrollToEnd(scrollTop);
2165
+ }
2166
+ /**
2167
+ * @private
2168
+ * @param {?} height
2169
+ * @return {?}
2170
+ */
2171
+ _updateVirtualHeight(height) {
2172
+ if (this._updateScrollHeight) {
2173
+ this._virtualPadding.style.height = `${height}px`;
2174
+ this._updateScrollHeight = false;
2175
+ }
2176
+ }
2177
+ /**
2178
+ * @private
2179
+ * @return {?}
2180
+ */
2181
+ _onItemsLengthChanged() {
2182
+ this._updateScrollHeight = true;
2183
+ }
2184
+ /**
2185
+ * @private
2186
+ * @return {?}
2187
+ */
2188
+ get _startOffset() {
2189
+ if (this.markedItem) {
2190
+ return this.markedItem.index * this._panelService.dimensions.itemHeight;
2191
+ }
2192
+ return 0;
2193
+ }
2194
+ /**
2195
+ * @private
2196
+ * @param {?=} scrollTop
2197
+ * @return {?}
2198
+ */
2199
+ _renderItemsRange(scrollTop = null) {
2200
+ if (scrollTop && this._lastScrollPosition === scrollTop) {
2201
+ return;
2202
+ }
2203
+ scrollTop = scrollTop || this._scrollablePanel.scrollTop;
2204
+ /** @type {?} */
2205
+ const range = this._panelService.calculateItems(scrollTop, this.itemsLength, this.bufferAmount);
2206
+ this._updateVirtualHeight(range.scrollHeight);
2207
+ this._contentPanel.style.transform = `translateY(${range.topPadding}px)`;
2208
+ this._zone.run((/**
2209
+ * @return {?}
2210
+ */
2211
+ () => {
2212
+ this.update.emit(this.items.slice(range.start, range.end));
2213
+ this.scroll.emit({ start: range.start, end: range.end });
2214
+ }));
2215
+ if (isDefined(scrollTop) && this._lastScrollPosition === 0) {
2216
+ this._scrollablePanel.scrollTop = scrollTop;
2217
+ this._lastScrollPosition = scrollTop;
2218
+ }
2219
+ }
2220
+ /**
2221
+ * @private
2222
+ * @return {?}
2223
+ */
2224
+ _measureDimensions() {
2225
+ if (this._panelService.dimensions.itemHeight > 0 || this.itemsLength === 0) {
2226
+ return Promise.resolve(this._panelService.dimensions);
2227
+ }
2228
+ const [first] = this.items;
2229
+ this.update.emit([first]);
2230
+ return Promise.resolve().then((/**
2231
+ * @return {?}
2232
+ */
2233
+ () => {
2234
+ /** @type {?} */
2235
+ const option = this._dropdown.querySelector(`#${first.htmlId}`);
2236
+ /** @type {?} */
2237
+ const optionHeight = option.clientHeight;
2238
+ this._virtualPadding.style.height = `${optionHeight * this.itemsLength}px`;
2239
+ /** @type {?} */
2240
+ const panelHeight = this._scrollablePanel.clientHeight;
2241
+ this._panelService.setDimensions(optionHeight, panelHeight);
2242
+ return this._panelService.dimensions;
2243
+ }));
2244
+ }
2245
+ /**
2246
+ * @private
2247
+ * @param {?} scrollTop
2248
+ * @return {?}
2249
+ */
2250
+ _fireScrollToEnd(scrollTop) {
2251
+ if (this._scrollToEndFired || scrollTop === 0) {
2252
+ return;
2253
+ }
2254
+ /** @type {?} */
2255
+ const padding = this.virtualScroll ?
2256
+ this._virtualPadding :
2257
+ this._contentPanel;
2258
+ if (scrollTop + this._dropdown.clientHeight >= padding.clientHeight) {
2259
+ this._zone.run((/**
2260
+ * @return {?}
2261
+ */
2262
+ () => this.scrollToEnd.emit()));
2263
+ this._scrollToEndFired = true;
2264
+ }
2265
+ }
2266
+ /**
2267
+ * @private
2268
+ * @param {?} dropdownEl
2269
+ * @return {?}
2270
+ */
2271
+ _calculateCurrentPosition(dropdownEl) {
2272
+ if (this.position !== 'auto') {
2273
+ return this.position;
2274
+ }
2275
+ /** @type {?} */
2276
+ const selectRect = this._select.getBoundingClientRect();
2277
+ /** @type {?} */
2278
+ const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
2279
+ /** @type {?} */
2280
+ const offsetTop = selectRect.top + window.pageYOffset;
2281
+ /** @type {?} */
2282
+ const height = selectRect.height;
2283
+ /** @type {?} */
2284
+ const dropdownHeight = dropdownEl.getBoundingClientRect().height;
2285
+ if (offsetTop + height + dropdownHeight > scrollTop + document.documentElement.clientHeight) {
2286
+ return 'top';
2287
+ }
2288
+ else {
2289
+ return 'bottom';
2290
+ }
2291
+ }
2292
+ /**
2293
+ * @private
2294
+ * @return {?}
2295
+ */
2296
+ _appendDropdown() {
2297
+ if (!this.appendTo) {
2298
+ return;
2299
+ }
2300
+ this._parent = document.querySelector(this.appendTo);
2301
+ if (!parent) {
2302
+ throw new Error(`appendTo selector ${this.appendTo} did not found any parent element`);
2303
+ }
2304
+ this._parent.appendChild(this._dropdown);
2305
+ }
2306
+ /**
2307
+ * @private
2308
+ * @return {?}
2309
+ */
2310
+ _updatePosition() {
2311
+ /** @type {?} */
2312
+ const select = this._select.getBoundingClientRect();
2313
+ /** @type {?} */
2314
+ const parent = this._parent.getBoundingClientRect();
2315
+ /** @type {?} */
2316
+ const offsetLeft = select.left - parent.left;
2317
+ this._setOffset(parent, select);
2318
+ this._dropdown.style.left = offsetLeft + 'px';
2319
+ this._dropdown.style.width = select.width + 'px';
2320
+ this._dropdown.style.minWidth = select.width + 'px';
2321
+ }
2322
+ /**
2323
+ * @private
2324
+ * @param {?} parent
2325
+ * @param {?} select
2326
+ * @return {?}
2327
+ */
2328
+ _setOffset(parent, select) {
2329
+ /** @type {?} */
2330
+ const delta = select.height;
2331
+ if (this._currentPosition === 'top') {
2332
+ /** @type {?} */
2333
+ const offsetBottom = parent.bottom - select.bottom;
2334
+ this._dropdown.style.bottom = offsetBottom + delta + 'px';
2335
+ this._dropdown.style.top = 'auto';
2336
+ }
2337
+ else if (this._currentPosition === 'bottom') {
2338
+ /** @type {?} */
2339
+ const offsetTop = select.top - parent.top;
2340
+ this._dropdown.style.top = offsetTop + delta + 'px';
2341
+ this._dropdown.style.bottom = 'auto';
2342
+ }
2343
+ }
2344
+ }
2345
+ NgDropdownPanelComponent.decorators = [
2346
+ { type: Component, args: [{
2347
+ changeDetection: ChangeDetectionStrategy.OnPush,
2348
+ encapsulation: ViewEncapsulation.None,
2349
+ selector: 'ng-dropdown-panel',
2350
+ template: `
2351
+ <div *ngIf="headerTemplate" class="ng-dropdown-header">
2352
+ <ng-container [ngTemplateOutlet]="headerTemplate" [ngTemplateOutletContext]="{ searchTerm: filterValue }"></ng-container>
2353
+ </div>
2354
+ <div #scroll class="ng-dropdown-panel-items scroll-host">
2355
+ <div #padding [class.total-padding]="virtualScroll"></div>
2356
+ <div #content [class.scrollable-content]="virtualScroll && items.length">
2357
+ <ng-content></ng-content>
2358
+ </div>
2359
+ </div>
2360
+ <div *ngIf="footerTemplate" class="ng-dropdown-footer">
2361
+ <ng-container [ngTemplateOutlet]="footerTemplate" [ngTemplateOutletContext]="{ searchTerm: filterValue }"></ng-container>
2362
+ </div>
2363
+ `
2364
+ }] }
2365
+ ];
2366
+ /** @nocollapse */
2367
+ NgDropdownPanelComponent.ctorParameters = () => [
2368
+ { type: Renderer2 },
2369
+ { type: NgZone },
2370
+ { type: NgDropdownPanelService },
2371
+ { type: ElementRef },
2372
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
2373
+ ];
2374
+ NgDropdownPanelComponent.propDecorators = {
2375
+ items: [{ type: Input }],
2376
+ markedItem: [{ type: Input }],
2377
+ position: [{ type: Input }],
2378
+ appendTo: [{ type: Input }],
2379
+ bufferAmount: [{ type: Input }],
2380
+ virtualScroll: [{ type: Input }],
2381
+ headerTemplate: [{ type: Input }],
2382
+ footerTemplate: [{ type: Input }],
2383
+ filterValue: [{ type: Input }],
2384
+ update: [{ type: Output }],
2385
+ scroll: [{ type: Output }],
2386
+ scrollToEnd: [{ type: Output }],
2387
+ outsideClick: [{ type: Output }],
2388
+ contentElementRef: [{ type: ViewChild, args: ['content', { read: ElementRef, static: true },] }],
2389
+ scrollElementRef: [{ type: ViewChild, args: ['scroll', { read: ElementRef, static: true },] }],
2390
+ paddingElementRef: [{ type: ViewChild, args: ['padding', { read: ElementRef, static: true },] }],
2391
+ handleMousedown: [{ type: HostListener, args: ['mousedown', ['$event'],] }]
2392
+ };
2393
+
2394
+ /**
2395
+ * @fileoverview added by tsickle
2396
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2397
+ */
2398
+ class NgOptionComponent {
2399
+ /**
2400
+ * @param {?} elementRef
2401
+ */
2402
+ constructor(elementRef) {
2403
+ this.elementRef = elementRef;
2404
+ this.stateChange$ = new Subject();
2405
+ this._disabled = false;
2406
+ }
2407
+ /**
2408
+ * @return {?}
2409
+ */
2410
+ get disabled() { return this._disabled; }
2411
+ /**
2412
+ * @param {?} value
2413
+ * @return {?}
2414
+ */
2415
+ set disabled(value) { this._disabled = this._isDisabled(value); }
2416
+ /**
2417
+ * @param {?} changes
2418
+ * @return {?}
2419
+ */
2420
+ ngOnChanges(changes) {
2421
+ if (changes.disabled) {
2422
+ this.stateChange$.next({
2423
+ value: this.value,
2424
+ disabled: this._disabled
2425
+ });
2426
+ }
2427
+ }
2428
+ /**
2429
+ * @private
2430
+ * @param {?} value
2431
+ * @return {?}
2432
+ */
2433
+ _isDisabled(value) {
2434
+ return value != null && `${value}` !== 'false';
2435
+ }
2436
+ }
2437
+ NgOptionComponent.decorators = [
2438
+ { type: Component, args: [{
2439
+ selector: 'ng-option',
2440
+ changeDetection: ChangeDetectionStrategy.OnPush,
2441
+ template: `<ng-content></ng-content>`
2442
+ }] }
2443
+ ];
2444
+ /** @nocollapse */
2445
+ NgOptionComponent.ctorParameters = () => [
2446
+ { type: ElementRef }
2447
+ ];
2448
+ NgOptionComponent.propDecorators = {
2449
+ value: [{ type: Input }],
2450
+ disabled: [{ type: Input }]
2451
+ };
2452
+
2453
+ /**
2454
+ * @fileoverview added by tsickle
2455
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2456
+ */
2457
+ class NgSelectConfig {
2458
+ constructor() {
2459
+ this.notFoundText = 'No items found';
2460
+ this.typeToSearchText = 'Type to search';
2461
+ this.addTagText = 'Add item';
2462
+ this.loadingText = 'Loading...';
2463
+ this.clearAllText = 'Clear all';
2464
+ this.disableVirtualScroll = true;
2465
+ this.openOnEnter = true;
2466
+ }
2467
+ }
2468
+ NgSelectConfig.decorators = [
2469
+ { type: Injectable, args: [{ providedIn: 'root' },] }
2470
+ ];
2471
+ /** @nocollapse */ NgSelectConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgSelectConfig_Factory() { return new NgSelectConfig(); }, token: NgSelectConfig, providedIn: "root" });
2472
+
2473
+ /**
2474
+ * @fileoverview added by tsickle
2475
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2476
+ */
2477
+ /** @type {?} */
2478
+ const SELECTION_MODEL_FACTORY = new InjectionToken('ng-select-selection-model');
2479
+ class NgSelectComponent {
2480
+ /**
2481
+ * @param {?} classes
2482
+ * @param {?} autoFocus
2483
+ * @param {?} config
2484
+ * @param {?} newSelectionModel
2485
+ * @param {?} _elementRef
2486
+ * @param {?} _cd
2487
+ * @param {?} _console
2488
+ */
2489
+ constructor(classes, autoFocus, config, newSelectionModel, _elementRef, _cd, _console) {
2490
+ this.classes = classes;
2491
+ this.autoFocus = autoFocus;
2492
+ this._cd = _cd;
2493
+ this._console = _console;
2494
+ this.markFirst = true;
2495
+ this.dropdownPosition = 'auto';
2496
+ this.loading = false;
2497
+ this.closeOnSelect = true;
2498
+ this.hideSelected = false;
2499
+ this.selectOnTab = false;
2500
+ this.bufferAmount = 4;
2501
+ this.selectableGroup = false;
2502
+ this.selectableGroupAsModel = true;
2503
+ this.searchFn = null;
2504
+ this.trackByFn = null;
2505
+ this.clearOnBackspace = true;
2506
+ this.labelForId = null;
2507
+ this.inputAttrs = {};
2508
+ this.multiple = false;
2509
+ this.addTag = false;
2510
+ this.searchable = true;
2511
+ this.clearable = true;
2512
+ this.isOpen = false;
2513
+ // output events
2514
+ this.blurEvent = new EventEmitter();
2515
+ this.focusEvent = new EventEmitter();
2516
+ this.changeEvent = new EventEmitter();
2517
+ this.openEvent = new EventEmitter();
2518
+ this.closeEvent = new EventEmitter();
2519
+ this.searchEvent = new EventEmitter();
2520
+ this.clearEvent = new EventEmitter();
2521
+ this.addEvent = new EventEmitter();
2522
+ this.removeEvent = new EventEmitter();
2523
+ this.scroll = new EventEmitter();
2524
+ this.scrollToEnd = new EventEmitter();
2525
+ this.disabled = false;
2526
+ this.viewPortItems = [];
2527
+ this.searchTerm = null;
2528
+ this.dropdownId = newId();
2529
+ this._items = [];
2530
+ this._defaultLabel = 'label';
2531
+ this._pressedKeys = [];
2532
+ this._destroy$ = new Subject();
2533
+ this._keyPress$ = new Subject();
2534
+ this._onChange = (/**
2535
+ * @param {?} _
2536
+ * @return {?}
2537
+ */
2538
+ (_) => { });
2539
+ this._onTouched = (/**
2540
+ * @return {?}
2541
+ */
2542
+ () => { });
2543
+ this.clearItem = (/**
2544
+ * @param {?} item
2545
+ * @return {?}
2546
+ */
2547
+ (item) => {
2548
+ /** @type {?} */
2549
+ const option = this.selectedItems.find((/**
2550
+ * @param {?} x
2551
+ * @return {?}
2552
+ */
2553
+ x => x.value === item));
2554
+ this.unselect(option);
2555
+ });
2556
+ this.trackByOption = (/**
2557
+ * @param {?} _
2558
+ * @param {?} item
2559
+ * @return {?}
2560
+ */
2561
+ (_, item) => {
2562
+ if (this.trackByFn) {
2563
+ return this.trackByFn(item.value);
2564
+ }
2565
+ return item.htmlId;
2566
+ });
2567
+ this._mergeGlobalConfig(config);
2568
+ this.itemsList = new ItemsList(this, newSelectionModel());
2569
+ this.element = _elementRef.nativeElement;
2570
+ }
2571
+ /**
2572
+ * @return {?}
2573
+ */
2574
+ get items() { return this._items; }
2575
+ ;
2576
+ /**
2577
+ * @param {?} value
2578
+ * @return {?}
2579
+ */
2580
+ set items(value) {
2581
+ this._itemsAreUsed = true;
2582
+ this._items = value;
2583
+ }
2584
+ ;
2585
+ /**
2586
+ * @return {?}
2587
+ */
2588
+ get compareWith() { return this._compareWith; }
2589
+ /**
2590
+ * @param {?} fn
2591
+ * @return {?}
2592
+ */
2593
+ set compareWith(fn) {
2594
+ if (!isFunction(fn)) {
2595
+ throw Error('`compareWith` must be a function.');
2596
+ }
2597
+ this._compareWith = fn;
2598
+ }
2599
+ /**
2600
+ * @return {?}
2601
+ */
2602
+ get clearSearchOnAdd() { return isDefined(this._clearSearchOnAdd) ? this._clearSearchOnAdd : this.closeOnSelect; }
2603
+ ;
2604
+ /**
2605
+ * @param {?} value
2606
+ * @return {?}
2607
+ */
2608
+ set clearSearchOnAdd(value) {
2609
+ this._clearSearchOnAdd = value;
2610
+ }
2611
+ ;
2612
+ /**
2613
+ * @return {?}
2614
+ */
2615
+ get filtered() { return !!this.searchTerm && this.searchable; }
2616
+ ;
2617
+ /**
2618
+ * @return {?}
2619
+ */
2620
+ get selectedItems() {
2621
+ return this.itemsList.selectedItems;
2622
+ }
2623
+ /**
2624
+ * @return {?}
2625
+ */
2626
+ get selectedValues() {
2627
+ return this.selectedItems.map((/**
2628
+ * @param {?} x
2629
+ * @return {?}
2630
+ */
2631
+ x => x.value));
2632
+ }
2633
+ /**
2634
+ * @return {?}
2635
+ */
2636
+ get hasValue() {
2637
+ return this.selectedItems.length > 0;
2638
+ }
2639
+ /**
2640
+ * @return {?}
2641
+ */
2642
+ get currentPanelPosition() {
2643
+ if (this.dropdownPanel) {
2644
+ return this.dropdownPanel.currentPosition;
2645
+ }
2646
+ return undefined;
2647
+ }
2648
+ /**
2649
+ * @return {?}
2650
+ */
2651
+ ngOnInit() {
2652
+ this._handleKeyPresses();
2653
+ this._setInputAttributes();
2654
+ }
2655
+ /**
2656
+ * @param {?} changes
2657
+ * @return {?}
2658
+ */
2659
+ ngOnChanges(changes) {
2660
+ if (changes.multiple) {
2661
+ this.itemsList.clearSelected();
2662
+ }
2663
+ if (changes.items) {
2664
+ this._setItems(changes.items.currentValue || []);
2665
+ }
2666
+ if (changes.isOpen) {
2667
+ this._manualOpen = isDefined(changes.isOpen.currentValue);
2668
+ }
2669
+ }
2670
+ /**
2671
+ * @return {?}
2672
+ */
2673
+ ngAfterViewInit() {
2674
+ if (!this._itemsAreUsed) {
2675
+ this._setItemsFromNgOptions();
2676
+ }
2677
+ if (isDefined(this.autoFocus)) {
2678
+ this.focus();
2679
+ }
2680
+ }
2681
+ /**
2682
+ * @return {?}
2683
+ */
2684
+ ngOnDestroy() {
2685
+ this._destroy$.next();
2686
+ this._destroy$.complete();
2687
+ }
2688
+ /**
2689
+ * @param {?} $event
2690
+ * @return {?}
2691
+ */
2692
+ handleKeyDown($event) {
2693
+ if (KeyCode[$event.which]) {
2694
+ switch ($event.which) {
2695
+ case KeyCode.ArrowDown:
2696
+ this._handleArrowDown($event);
2697
+ break;
2698
+ case KeyCode.ArrowUp:
2699
+ this._handleArrowUp($event);
2700
+ break;
2701
+ case KeyCode.Space:
2702
+ this._handleSpace($event);
2703
+ break;
2704
+ case KeyCode.Enter:
2705
+ this._handleEnter($event);
2706
+ break;
2707
+ case KeyCode.Tab:
2708
+ this._handleTab($event);
2709
+ break;
2710
+ case KeyCode.Esc:
2711
+ this.close();
2712
+ $event.preventDefault();
2713
+ break;
2714
+ case KeyCode.Backspace:
2715
+ this._handleBackspace();
2716
+ break;
2717
+ }
2718
+ }
2719
+ else if ($event.key && $event.key.length === 1) {
2720
+ this._keyPress$.next($event.key.toLocaleLowerCase());
2721
+ }
2722
+ }
2723
+ /**
2724
+ * @param {?} $event
2725
+ * @return {?}
2726
+ */
2727
+ handleMousedown($event) {
2728
+ /** @type {?} */
2729
+ const target = (/** @type {?} */ ($event.target));
2730
+ if (target.tagName !== 'INPUT') {
2731
+ $event.preventDefault();
2732
+ }
2733
+ if (target.classList.contains('ng-clear-wrapper')) {
2734
+ this.handleClearClick();
2735
+ return;
2736
+ }
2737
+ if (target.classList.contains('ng-arrow-wrapper')) {
2738
+ this.handleArrowClick();
2739
+ return;
2740
+ }
2741
+ if (target.classList.contains('ng-value-icon')) {
2742
+ return;
2743
+ }
2744
+ if (!this.focused) {
2745
+ this.focus();
2746
+ }
2747
+ if (this.searchable) {
2748
+ this.open();
2749
+ }
2750
+ else {
2751
+ this.toggle();
2752
+ }
2753
+ }
2754
+ /**
2755
+ * @return {?}
2756
+ */
2757
+ handleArrowClick() {
2758
+ if (this.isOpen) {
2759
+ this.close();
2760
+ }
2761
+ else {
2762
+ this.open();
2763
+ }
2764
+ }
2765
+ /**
2766
+ * @return {?}
2767
+ */
2768
+ handleClearClick() {
2769
+ if (this.hasValue) {
2770
+ this.itemsList.clearSelected(true);
2771
+ this._updateNgModel();
2772
+ }
2773
+ this._clearSearch();
2774
+ this.focus();
2775
+ if (this._isTypeahead) {
2776
+ this.typeahead.next(null);
2777
+ }
2778
+ this.clearEvent.emit();
2779
+ this._onSelectionChanged();
2780
+ }
2781
+ /**
2782
+ * @return {?}
2783
+ */
2784
+ clearModel() {
2785
+ if (!this.clearable) {
2786
+ return;
2787
+ }
2788
+ this.itemsList.clearSelected();
2789
+ this._updateNgModel();
2790
+ }
2791
+ /**
2792
+ * @param {?} value
2793
+ * @return {?}
2794
+ */
2795
+ writeValue(value) {
2796
+ this.itemsList.clearSelected();
2797
+ this._handleWriteValue(value);
2798
+ this._cd.markForCheck();
2799
+ }
2800
+ /**
2801
+ * @param {?} fn
2802
+ * @return {?}
2803
+ */
2804
+ registerOnChange(fn) {
2805
+ this._onChange = fn;
2806
+ }
2807
+ /**
2808
+ * @param {?} fn
2809
+ * @return {?}
2810
+ */
2811
+ registerOnTouched(fn) {
2812
+ this._onTouched = fn;
2813
+ }
2814
+ /**
2815
+ * @param {?} isDisabled
2816
+ * @return {?}
2817
+ */
2818
+ setDisabledState(isDisabled) {
2819
+ this.disabled = isDisabled;
2820
+ this._cd.markForCheck();
2821
+ }
2822
+ /**
2823
+ * @return {?}
2824
+ */
2825
+ toggle() {
2826
+ if (!this.isOpen) {
2827
+ this.open();
2828
+ }
2829
+ else {
2830
+ this.close();
2831
+ }
2832
+ }
2833
+ /**
2834
+ * @return {?}
2835
+ */
2836
+ open() {
2837
+ if (this.disabled || this.isOpen || this.itemsList.maxItemsSelected || this._manualOpen) {
2838
+ return;
2839
+ }
2840
+ if (!this._isTypeahead && !this.addTag && this.itemsList.noItemsToSelect) {
2841
+ return;
2842
+ }
2843
+ this.isOpen = true;
2844
+ this.itemsList.markSelectedOrDefault(this.markFirst);
2845
+ this.openEvent.emit();
2846
+ if (!this.searchTerm) {
2847
+ this.focus();
2848
+ }
2849
+ this.detectChanges();
2850
+ }
2851
+ /**
2852
+ * @return {?}
2853
+ */
2854
+ close() {
2855
+ if (!this.isOpen || this._manualOpen) {
2856
+ return;
2857
+ }
2858
+ this.isOpen = false;
2859
+ this._clearSearch();
2860
+ this.itemsList.unmarkItem();
2861
+ this._onTouched();
2862
+ this.closeEvent.emit();
2863
+ this._cd.markForCheck();
2864
+ }
2865
+ /**
2866
+ * @param {?} item
2867
+ * @return {?}
2868
+ */
2869
+ toggleItem(item) {
2870
+ if (!item || item.disabled || this.disabled) {
2871
+ return;
2872
+ }
2873
+ if (this.multiple && item.selected) {
2874
+ this.unselect(item);
2875
+ }
2876
+ else {
2877
+ this.select(item);
2878
+ }
2879
+ this._onSelectionChanged();
2880
+ }
2881
+ /**
2882
+ * @param {?} item
2883
+ * @return {?}
2884
+ */
2885
+ select(item) {
2886
+ if (!item.selected) {
2887
+ this.itemsList.select(item);
2888
+ if (this.clearSearchOnAdd) {
2889
+ this._clearSearch();
2890
+ }
2891
+ this._updateNgModel();
2892
+ if (this.multiple) {
2893
+ this.addEvent.emit(item.value);
2894
+ }
2895
+ }
2896
+ if (this.closeOnSelect || this.itemsList.noItemsToSelect) {
2897
+ this.close();
2898
+ }
2899
+ }
2900
+ /**
2901
+ * @return {?}
2902
+ */
2903
+ focus() {
2904
+ this.searchInput.nativeElement.focus();
2905
+ }
2906
+ /**
2907
+ * @return {?}
2908
+ */
2909
+ blur() {
2910
+ this.searchInput.nativeElement.blur();
2911
+ }
2912
+ /**
2913
+ * @param {?} item
2914
+ * @return {?}
2915
+ */
2916
+ unselect(item) {
2917
+ if (!item) {
2918
+ return;
2919
+ }
2920
+ this.itemsList.unselect(item);
2921
+ this.focus();
2922
+ this._updateNgModel();
2923
+ this.removeEvent.emit(item);
2924
+ }
2925
+ /**
2926
+ * @return {?}
2927
+ */
2928
+ selectTag() {
2929
+ /** @type {?} */
2930
+ let tag;
2931
+ if (isFunction(this.addTag)) {
2932
+ tag = ((/** @type {?} */ (this.addTag)))(this.searchTerm);
2933
+ }
2934
+ else {
2935
+ tag = this._primitive ? this.searchTerm : { [this.bindLabel]: this.searchTerm };
2936
+ }
2937
+ /** @type {?} */
2938
+ const handleTag = (/**
2939
+ * @param {?} item
2940
+ * @return {?}
2941
+ */
2942
+ (item) => this._isTypeahead || !this.isOpen ? this.itemsList.mapItem(item, null) : this.itemsList.addItem(item));
2943
+ if (isPromise(tag)) {
2944
+ tag.then((/**
2945
+ * @param {?} item
2946
+ * @return {?}
2947
+ */
2948
+ item => this.select(handleTag(item)))).catch((/**
2949
+ * @return {?}
2950
+ */
2951
+ () => { }));
2952
+ }
2953
+ else if (tag) {
2954
+ this.select(handleTag(tag));
2955
+ }
2956
+ }
2957
+ /**
2958
+ * @return {?}
2959
+ */
2960
+ showClear() {
2961
+ return this.clearable && (this.hasValue || this.searchTerm) && !this.disabled;
2962
+ }
2963
+ /**
2964
+ * @return {?}
2965
+ */
2966
+ get showAddTag() {
2967
+ if (!this.searchTerm) {
2968
+ return false;
2969
+ }
2970
+ /** @type {?} */
2971
+ const term = this.searchTerm.toLowerCase();
2972
+ return this.addTag &&
2973
+ (!this.itemsList.filteredItems.some((/**
2974
+ * @param {?} x
2975
+ * @return {?}
2976
+ */
2977
+ x => x.label.toLowerCase() === term)) &&
2978
+ (!this.hideSelected && this.isOpen || !this.selectedItems.some((/**
2979
+ * @param {?} x
2980
+ * @return {?}
2981
+ */
2982
+ x => x.label.toLowerCase() === term)))) &&
2983
+ !this.loading;
2984
+ }
2985
+ /**
2986
+ * @return {?}
2987
+ */
2988
+ showNoItemsFound() {
2989
+ /** @type {?} */
2990
+ const empty = this.itemsList.filteredItems.length === 0;
2991
+ return ((empty && !this._isTypeahead && !this.loading) ||
2992
+ (empty && this._isTypeahead && this.searchTerm && !this.loading)) &&
2993
+ !this.showAddTag;
2994
+ }
2995
+ /**
2996
+ * @return {?}
2997
+ */
2998
+ showTypeToSearch() {
2999
+ /** @type {?} */
3000
+ const empty = this.itemsList.filteredItems.length === 0;
3001
+ return empty && this._isTypeahead && !this.searchTerm && !this.loading;
3002
+ }
3003
+ /**
3004
+ * @param {?} term
3005
+ * @return {?}
3006
+ */
3007
+ filter(term) {
3008
+ this.searchTerm = term;
3009
+ if (this._isTypeahead) {
3010
+ this.typeahead.next(this.searchTerm);
3011
+ }
3012
+ else {
3013
+ this.itemsList.filter(this.searchTerm);
3014
+ if (this.isOpen) {
3015
+ this.itemsList.markSelectedOrDefault(this.markFirst);
3016
+ }
3017
+ }
3018
+ this.searchEvent.emit({ term, items: this.itemsList.filteredItems.map((/**
3019
+ * @param {?} x
3020
+ * @return {?}
3021
+ */
3022
+ x => x.value)) });
3023
+ this.open();
3024
+ }
3025
+ /**
3026
+ * @param {?} $event
3027
+ * @return {?}
3028
+ */
3029
+ onInputFocus($event) {
3030
+ if (this.focused) {
3031
+ return;
3032
+ }
3033
+ this.element.classList.add('ng-select-focused');
3034
+ this.focusEvent.emit($event);
3035
+ this.focused = true;
3036
+ }
3037
+ /**
3038
+ * @param {?} $event
3039
+ * @return {?}
3040
+ */
3041
+ onInputBlur($event) {
3042
+ this.element.classList.remove('ng-select-focused');
3043
+ this.blurEvent.emit($event);
3044
+ if (!this.isOpen && !this.disabled) {
3045
+ this._onTouched();
3046
+ }
3047
+ this.focused = false;
3048
+ }
3049
+ /**
3050
+ * @param {?} item
3051
+ * @return {?}
3052
+ */
3053
+ onItemHover(item) {
3054
+ if (item.disabled) {
3055
+ return;
3056
+ }
3057
+ this.itemsList.markItem(item);
3058
+ }
3059
+ /**
3060
+ * @return {?}
3061
+ */
3062
+ detectChanges() {
3063
+ if (!((/** @type {?} */ (this._cd))).destroyed) {
3064
+ this._cd.detectChanges();
3065
+ }
3066
+ }
3067
+ /**
3068
+ * @private
3069
+ * @param {?} items
3070
+ * @return {?}
3071
+ */
3072
+ _setItems(items) {
3073
+ /** @type {?} */
3074
+ const firstItem = items[0];
3075
+ this.bindLabel = this.bindLabel || this._defaultLabel;
3076
+ this._primitive = isDefined(firstItem) ? !isObject(firstItem) : this._primitive || this.bindLabel === this._defaultLabel;
3077
+ this.itemsList.setItems(items);
3078
+ if (items.length > 0 && this.hasValue) {
3079
+ this.itemsList.mapSelectedItems();
3080
+ }
3081
+ if (this.isOpen && isDefined(this.searchTerm) && !this._isTypeahead) {
3082
+ this.itemsList.filter(this.searchTerm);
3083
+ }
3084
+ if (this._isTypeahead || this.isOpen) {
3085
+ this.itemsList.markSelectedOrDefault(this.markFirst);
3086
+ }
3087
+ }
3088
+ /**
3089
+ * @private
3090
+ * @return {?}
3091
+ */
3092
+ _setItemsFromNgOptions() {
3093
+ /** @type {?} */
3094
+ const handleNgOptions = (/**
3095
+ * @param {?} options
3096
+ * @return {?}
3097
+ */
3098
+ (options) => {
3099
+ this.items = options.map((/**
3100
+ * @param {?} option
3101
+ * @return {?}
3102
+ */
3103
+ option => ({
3104
+ $ngOptionValue: option.value,
3105
+ $ngOptionLabel: option.elementRef.nativeElement.innerHTML,
3106
+ disabled: option.disabled
3107
+ })));
3108
+ this.itemsList.setItems(this.items);
3109
+ if (this.hasValue) {
3110
+ this.itemsList.mapSelectedItems();
3111
+ }
3112
+ this.detectChanges();
3113
+ });
3114
+ /** @type {?} */
3115
+ const handleOptionChange = (/**
3116
+ * @return {?}
3117
+ */
3118
+ () => {
3119
+ /** @type {?} */
3120
+ const changedOrDestroyed = merge(this.ngOptions.changes, this._destroy$);
3121
+ merge(...this.ngOptions.map((/**
3122
+ * @param {?} option
3123
+ * @return {?}
3124
+ */
3125
+ option => option.stateChange$)))
3126
+ .pipe(takeUntil(changedOrDestroyed))
3127
+ .subscribe((/**
3128
+ * @param {?} option
3129
+ * @return {?}
3130
+ */
3131
+ option => {
3132
+ /** @type {?} */
3133
+ const item = this.itemsList.findItem(option.value);
3134
+ item.disabled = option.disabled;
3135
+ this._cd.markForCheck();
3136
+ }));
3137
+ });
3138
+ this.ngOptions.changes
3139
+ .pipe(startWith(this.ngOptions), takeUntil(this._destroy$))
3140
+ .subscribe((/**
3141
+ * @param {?} options
3142
+ * @return {?}
3143
+ */
3144
+ options => {
3145
+ this.bindLabel = this._defaultLabel;
3146
+ handleNgOptions(options);
3147
+ handleOptionChange();
3148
+ }));
3149
+ }
3150
+ /**
3151
+ * @private
3152
+ * @param {?} value
3153
+ * @return {?}
3154
+ */
3155
+ _isValidWriteValue(value) {
3156
+ if (!isDefined(value) || (this.multiple && value === '') || Array.isArray(value) && value.length === 0) {
3157
+ return false;
3158
+ }
3159
+ /** @type {?} */
3160
+ const validateBinding = (/**
3161
+ * @param {?} item
3162
+ * @return {?}
3163
+ */
3164
+ (item) => {
3165
+ if (!isDefined(this.compareWith) && isObject(item) && this.bindValue) {
3166
+ this._console.warn(`Binding object(${JSON.stringify(item)}) with bindValue is not allowed.`);
3167
+ return false;
3168
+ }
3169
+ return true;
3170
+ });
3171
+ if (this.multiple) {
3172
+ if (!Array.isArray(value)) {
3173
+ this._console.warn('Multiple select ngModel should be array.');
3174
+ return false;
3175
+ }
3176
+ return value.every((/**
3177
+ * @param {?} item
3178
+ * @return {?}
3179
+ */
3180
+ item => validateBinding(item)));
3181
+ }
3182
+ else {
3183
+ return validateBinding(value);
3184
+ }
3185
+ }
3186
+ /**
3187
+ * @private
3188
+ * @param {?} ngModel
3189
+ * @return {?}
3190
+ */
3191
+ _handleWriteValue(ngModel) {
3192
+ if (!this._isValidWriteValue(ngModel)) {
3193
+ return;
3194
+ }
3195
+ /** @type {?} */
3196
+ const select = (/**
3197
+ * @param {?} val
3198
+ * @return {?}
3199
+ */
3200
+ (val) => {
3201
+ /** @type {?} */
3202
+ let item = this.itemsList.findItem(val);
3203
+ if (item) {
3204
+ this.itemsList.select(item);
3205
+ }
3206
+ else {
3207
+ /** @type {?} */
3208
+ const isValObject = isObject(val);
3209
+ /** @type {?} */
3210
+ const isPrimitive = !isValObject && !this.bindValue;
3211
+ if ((isValObject || isPrimitive)) {
3212
+ this.itemsList.select(this.itemsList.mapItem(val, null));
3213
+ }
3214
+ else if (this.bindValue) {
3215
+ item = {
3216
+ [this.bindLabel]: null,
3217
+ [this.bindValue]: val
3218
+ };
3219
+ this.itemsList.select(this.itemsList.mapItem(item, null));
3220
+ }
3221
+ }
3222
+ });
3223
+ if (this.multiple) {
3224
+ ((/** @type {?} */ (ngModel))).forEach((/**
3225
+ * @param {?} item
3226
+ * @return {?}
3227
+ */
3228
+ item => select(item)));
3229
+ }
3230
+ else {
3231
+ select(ngModel);
3232
+ }
3233
+ }
3234
+ /**
3235
+ * @private
3236
+ * @return {?}
3237
+ */
3238
+ _handleKeyPresses() {
3239
+ if (this.searchable) {
3240
+ return;
3241
+ }
3242
+ this._keyPress$
3243
+ .pipe(takeUntil(this._destroy$), tap((/**
3244
+ * @param {?} letter
3245
+ * @return {?}
3246
+ */
3247
+ letter => this._pressedKeys.push(letter))), debounceTime(200), filter((/**
3248
+ * @return {?}
3249
+ */
3250
+ () => this._pressedKeys.length > 0)), map((/**
3251
+ * @return {?}
3252
+ */
3253
+ () => this._pressedKeys.join(''))))
3254
+ .subscribe((/**
3255
+ * @param {?} term
3256
+ * @return {?}
3257
+ */
3258
+ term => {
3259
+ /** @type {?} */
3260
+ const item = this.itemsList.findByLabel(term);
3261
+ if (item) {
3262
+ if (this.isOpen) {
3263
+ this.itemsList.markItem(item);
3264
+ this._cd.markForCheck();
3265
+ }
3266
+ else {
3267
+ this.select(item);
3268
+ }
3269
+ }
3270
+ this._pressedKeys = [];
3271
+ }));
3272
+ }
3273
+ /**
3274
+ * @private
3275
+ * @return {?}
3276
+ */
3277
+ _setInputAttributes() {
3278
+ /** @type {?} */
3279
+ const input = this.searchInput.nativeElement;
3280
+ /** @type {?} */
3281
+ const attributes = Object.assign({ type: 'text', autocorrect: 'off', autocapitalize: 'off', autocomplete: this.labelForId ? 'off' : this.dropdownId }, this.inputAttrs);
3282
+ for (const key of Object.keys(attributes)) {
3283
+ input.setAttribute(key, attributes[key]);
3284
+ }
3285
+ }
3286
+ /**
3287
+ * @private
3288
+ * @return {?}
3289
+ */
3290
+ _updateNgModel() {
3291
+ /** @type {?} */
3292
+ const model = [];
3293
+ for (const item of this.selectedItems) {
3294
+ if (this.bindValue) {
3295
+ /** @type {?} */
3296
+ let value = null;
3297
+ if (item.children) {
3298
+ /** @type {?} */
3299
+ const groupKey = this.groupValue ? this.bindValue : (/** @type {?} */ (this.groupBy));
3300
+ value = item.value[groupKey || (/** @type {?} */ (this.groupBy))];
3301
+ }
3302
+ else {
3303
+ value = this.itemsList.resolveNested(item.value, this.bindValue);
3304
+ }
3305
+ model.push(value);
3306
+ }
3307
+ else {
3308
+ model.push(item.value);
3309
+ }
3310
+ }
3311
+ /** @type {?} */
3312
+ const selected = this.selectedItems.map((/**
3313
+ * @param {?} x
3314
+ * @return {?}
3315
+ */
3316
+ x => x.value));
3317
+ if (this.multiple) {
3318
+ this._onChange(model);
3319
+ this.changeEvent.emit(selected);
3320
+ }
3321
+ else {
3322
+ this._onChange(isDefined(model[0]) ? model[0] : null);
3323
+ this.changeEvent.emit(selected[0]);
3324
+ }
3325
+ this._cd.markForCheck();
3326
+ }
3327
+ /**
3328
+ * @private
3329
+ * @return {?}
3330
+ */
3331
+ _clearSearch() {
3332
+ if (!this.searchTerm) {
3333
+ return;
3334
+ }
3335
+ this.searchTerm = null;
3336
+ this.itemsList.resetFilteredItems();
3337
+ }
3338
+ /**
3339
+ * @private
3340
+ * @return {?}
3341
+ */
3342
+ _scrollToMarked() {
3343
+ if (!this.isOpen || !this.dropdownPanel) {
3344
+ return;
3345
+ }
3346
+ this.dropdownPanel.scrollTo(this.itemsList.markedItem);
3347
+ }
3348
+ /**
3349
+ * @private
3350
+ * @return {?}
3351
+ */
3352
+ _scrollToTag() {
3353
+ if (!this.isOpen || !this.dropdownPanel) {
3354
+ return;
3355
+ }
3356
+ this.dropdownPanel.scrollToTag();
3357
+ }
3358
+ /**
3359
+ * @private
3360
+ * @return {?}
3361
+ */
3362
+ _onSelectionChanged() {
3363
+ if (this.isOpen && this.multiple && this.appendTo) {
3364
+ // Make sure items are rendered.
3365
+ this._cd.detectChanges();
3366
+ this.dropdownPanel.adjustPosition();
3367
+ }
3368
+ }
3369
+ /**
3370
+ * @private
3371
+ * @param {?} $event
3372
+ * @return {?}
3373
+ */
3374
+ _handleTab($event) {
3375
+ if (this.isOpen === false && !this.addTag) {
3376
+ return;
3377
+ }
3378
+ if (this.selectOnTab) {
3379
+ if (this.itemsList.markedItem) {
3380
+ this.toggleItem(this.itemsList.markedItem);
3381
+ $event.preventDefault();
3382
+ }
3383
+ else if (this.showAddTag) {
3384
+ this.selectTag();
3385
+ $event.preventDefault();
3386
+ }
3387
+ else {
3388
+ this.close();
3389
+ }
3390
+ }
3391
+ else {
3392
+ this.close();
3393
+ }
3394
+ }
3395
+ /**
3396
+ * @private
3397
+ * @param {?} $event
3398
+ * @return {?}
3399
+ */
3400
+ _handleEnter($event) {
3401
+ if (this.isOpen || this._manualOpen) {
3402
+ if (this.itemsList.markedItem) {
3403
+ this.toggleItem(this.itemsList.markedItem);
3404
+ }
3405
+ else if (this.showAddTag) {
3406
+ this.selectTag();
3407
+ }
3408
+ }
3409
+ else if (this.openOnEnter) {
3410
+ this.open();
3411
+ }
3412
+ else {
3413
+ return;
3414
+ }
3415
+ $event.preventDefault();
3416
+ }
3417
+ /**
3418
+ * @private
3419
+ * @param {?} $event
3420
+ * @return {?}
3421
+ */
3422
+ _handleSpace($event) {
3423
+ if (this.isOpen || this._manualOpen) {
3424
+ return;
3425
+ }
3426
+ this.open();
3427
+ $event.preventDefault();
3428
+ }
3429
+ /**
3430
+ * @private
3431
+ * @param {?} $event
3432
+ * @return {?}
3433
+ */
3434
+ _handleArrowDown($event) {
3435
+ if (this._nextItemIsTag(+1)) {
3436
+ this.itemsList.unmarkItem();
3437
+ this._scrollToTag();
3438
+ }
3439
+ else {
3440
+ this.itemsList.markNextItem();
3441
+ this._scrollToMarked();
3442
+ }
3443
+ this.open();
3444
+ $event.preventDefault();
3445
+ }
3446
+ /**
3447
+ * @private
3448
+ * @param {?} $event
3449
+ * @return {?}
3450
+ */
3451
+ _handleArrowUp($event) {
3452
+ if (!this.isOpen) {
3453
+ return;
3454
+ }
3455
+ if (this._nextItemIsTag(-1)) {
3456
+ this.itemsList.unmarkItem();
3457
+ this._scrollToTag();
3458
+ }
3459
+ else {
3460
+ this.itemsList.markPreviousItem();
3461
+ this._scrollToMarked();
3462
+ }
3463
+ $event.preventDefault();
3464
+ }
3465
+ /**
3466
+ * @private
3467
+ * @param {?} nextStep
3468
+ * @return {?}
3469
+ */
3470
+ _nextItemIsTag(nextStep) {
3471
+ /** @type {?} */
3472
+ const nextIndex = this.itemsList.markedIndex + nextStep;
3473
+ return this.addTag && this.searchTerm
3474
+ && this.itemsList.markedItem
3475
+ && (nextIndex < 0 || nextIndex === this.itemsList.filteredItems.length);
3476
+ }
3477
+ /**
3478
+ * @private
3479
+ * @return {?}
3480
+ */
3481
+ _handleBackspace() {
3482
+ if (this.searchTerm || !this.clearable || !this.clearOnBackspace || !this.hasValue) {
3483
+ return;
3484
+ }
3485
+ if (this.multiple) {
3486
+ this.unselect(this.itemsList.lastSelectedItem);
3487
+ }
3488
+ else {
3489
+ this.clearModel();
3490
+ }
3491
+ }
3492
+ /**
3493
+ * @private
3494
+ * @return {?}
3495
+ */
3496
+ get _isTypeahead() {
3497
+ return this.typeahead && this.typeahead.observers.length > 0;
3498
+ }
3499
+ /**
3500
+ * @private
3501
+ * @param {?} config
3502
+ * @return {?}
3503
+ */
3504
+ _mergeGlobalConfig(config) {
3505
+ this.placeholder = this.placeholder || config.placeholder;
3506
+ this.notFoundText = this.notFoundText || config.notFoundText;
3507
+ this.typeToSearchText = this.typeToSearchText || config.typeToSearchText;
3508
+ this.addTagText = this.addTagText || config.addTagText;
3509
+ this.loadingText = this.loadingText || config.loadingText;
3510
+ this.clearAllText = this.clearAllText || config.clearAllText;
3511
+ this.virtualScroll = isDefined(this.virtualScroll)
3512
+ ? this.virtualScroll
3513
+ : isDefined(config.disableVirtualScroll) ? !config.disableVirtualScroll : false;
3514
+ this.openOnEnter = isDefined(this.openOnEnter) ? this.openOnEnter : config.openOnEnter;
3515
+ }
3516
+ }
3517
+ NgSelectComponent.decorators = [
3518
+ { type: Component, args: [{
3519
+ selector: 'ng-select',
3520
+ template: "<div (mousedown)=\"handleMousedown($event)\" [class.ng-has-value]=\"hasValue\" class=\"ng-select-container\">\n <div class=\"ng-value-container\">\n <div class=\"ng-placeholder\">{{placeholder}}</div>\n\n <ng-container *ngIf=\"!multiLabelTemplate && selectedItems.length > 0\">\n <div [class.ng-value-disabled]=\"item.disabled\" class=\"ng-value\" *ngFor=\"let item of selectedItems; trackBy: trackByOption\">\n <ng-template #defaultLabelTemplate>\n <span class=\"ng-value-icon left\" (click)=\"unselect(item);\" aria-hidden=\"true\">\u00D7</span>\n <span class=\"ng-value-label\">{{item.label}}</span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"labelTemplate || defaultLabelTemplate\"\n [ngTemplateOutletContext]=\"{ item: item.value, clear: clearItem, label: item.label }\">\n </ng-template>\n </div>\n </ng-container>\n\n <ng-template *ngIf=\"multiLabelTemplate && selectedValues.length > 0\"\n [ngTemplateOutlet]=\"multiLabelTemplate\"\n [ngTemplateOutletContext]=\"{ items: selectedValues, clear: clearItem }\">\n </ng-template>\n\n <div class=\"ng-input\">\n <input #searchInput\n [attr.id]=\"labelForId\"\n [attr.tabindex]=\"tabIndex\"\n [readOnly]=\"!searchable || itemsList.maxItemsSelected\"\n [disabled]=\"disabled\"\n [value]=\"searchTerm ? searchTerm : ''\"\n (input)=\"filter(searchInput.value)\"\n (focus)=\"onInputFocus($event)\"\n (blur)=\"onInputBlur($event)\"\n (change)=\"$event.stopPropagation()\"\n role=\"combobox\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-owns]=\"isOpen ? dropdownId : null\"\n [attr.aria-activedescendant]=\"isOpen ? itemsList?.markedItem?.htmlId : null\">\n </div>\n </div>\n\n <ng-container *ngIf=\"loading\">\n <ng-template #defaultLoadingSpinnerTemplate>\n <div class=\"ng-spinner-loader\"></div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"loadingSpinnerTemplate || defaultLoadingSpinnerTemplate\">\n </ng-template>\n </ng-container>\n\n <span *ngIf=\"showClear()\" class=\"ng-clear-wrapper\" title=\"{{clearAllText}}\">\n <span class=\"ng-clear\" aria-hidden=\"true\">\u00D7</span>\n </span>\n\n <span class=\"ng-arrow-wrapper\">\n <span class=\"ng-arrow\"></span>\n </span>\n</div>\n\n<ng-dropdown-panel *ngIf=\"isOpen\"\n class=\"ng-dropdown-panel\"\n [virtualScroll]=\"virtualScroll\"\n [bufferAmount]=\"bufferAmount\"\n [appendTo]=\"appendTo\"\n [position]=\"dropdownPosition\"\n [headerTemplate]=\"headerTemplate\"\n [footerTemplate]=\"footerTemplate\"\n [filterValue]=\"searchTerm\"\n [items]=\"itemsList.filteredItems\"\n [markedItem]=\"itemsList.markedItem\"\n (update)=\"viewPortItems = $event\"\n (scroll)=\"scroll.emit($event)\"\n (scrollToEnd)=\"scrollToEnd.emit($event)\"\n (outsideClick)=\"close()\"\n [class.ng-select-multiple]=\"multiple\"\n [ngClass]=\"appendTo ? classes : null\"\n [id]=\"dropdownId\">\n\n <ng-container>\n <div class=\"ng-option\" [attr.role]=\"item.children ? 'group' : 'option'\" (click)=\"toggleItem(item)\" (mouseover)=\"onItemHover(item)\"\n *ngFor=\"let item of viewPortItems; trackBy: trackByOption\"\n [class.ng-option-disabled]=\"item.disabled\"\n [class.ng-option-selected]=\"item.selected\"\n [class.ng-optgroup]=\"item.children\"\n [class.ng-option]=\"!item.children\"\n [class.ng-option-child]=\"!!item.parent\"\n [class.ng-option-marked]=\"item === itemsList.markedItem\"\n [attr.aria-selected]=\"item.selected\"\n [attr.id]=\"item?.htmlId\">\n\n <ng-template #defaultOptionTemplate>\n <span class=\"ng-option-label\">{{item.label}}</span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"item.children ? (optgroupTemplate || defaultOptionTemplate) : (optionTemplate || defaultOptionTemplate)\"\n [ngTemplateOutletContext]=\"{ item: item.value, item$:item, index: item.index, searchTerm: searchTerm }\">\n </ng-template>\n </div>\n\n <div class=\"ng-option\" [class.ng-option-marked]=\"!itemsList.markedItem\" (mouseover)=\"itemsList.unmarkItem()\" role=\"option\" (click)=\"selectTag()\" *ngIf=\"showAddTag\">\n <ng-template #defaultTagTemplate>\n <span><span class=\"ng-tag-label\">{{addTagText}}</span>\"{{searchTerm}}\"</span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"tagTemplate || defaultTagTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </div>\n </ng-container>\n\n <ng-container *ngIf=\"showNoItemsFound()\">\n <ng-template #defaultNotFoundTemplate>\n <div class=\"ng-option ng-option-disabled\">{{notFoundText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"notFoundTemplate || defaultNotFoundTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"showTypeToSearch()\">\n <ng-template #defaultTypeToSearchTemplate>\n <div class=\"ng-option ng-option-disabled\">{{typeToSearchText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"typeToSearchTemplate || defaultTypeToSearchTemplate\">\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"loading && itemsList.filteredItems.length === 0\">\n <ng-template #defaultLoadingTextTemplate>\n <div class=\"ng-option ng-option-disabled\">{{loadingText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"loadingTextTemplate || defaultLoadingTextTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </ng-container>\n\n</ng-dropdown-panel>\n",
3521
+ providers: [{
3522
+ provide: NG_VALUE_ACCESSOR,
3523
+ useExisting: forwardRef((/**
3524
+ * @return {?}
3525
+ */
3526
+ () => NgSelectComponent)),
3527
+ multi: true
3528
+ }, NgDropdownPanelService],
3529
+ encapsulation: ViewEncapsulation.None,
3530
+ changeDetection: ChangeDetectionStrategy.OnPush,
3531
+ host: {
3532
+ 'role': 'listbox',
3533
+ 'class': 'ng-select',
3534
+ '[class.ng-select-single]': '!multiple',
3535
+ },
3536
+ styles: [".ng-select{position:relative;display:block;box-sizing:border-box}.ng-select div,.ng-select input,.ng-select span{box-sizing:border-box}.ng-select [hidden]{display:none}.ng-select.ng-select-searchable .ng-select-container .ng-value-container .ng-input{opacity:1}.ng-select.ng-select-opened .ng-select-container{z-index:1001}.ng-select.ng-select-disabled .ng-select-container .ng-value-container .ng-placeholder,.ng-select.ng-select-disabled .ng-select-container .ng-value-container .ng-value{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.ng-select.ng-select-disabled .ng-arrow-wrapper{cursor:default}.ng-select.ng-select-filtered .ng-placeholder{display:none}.ng-select .ng-select-container{color:#333;cursor:default;display:-webkit-box;display:flex;outline:0;overflow:hidden;position:relative;width:100%}.ng-select .ng-select-container .ng-value-container{display:-webkit-box;display:flex;-webkit-box-flex:1;flex:1}.ng-select .ng-select-container .ng-value-container .ng-input{opacity:0}.ng-select .ng-select-container .ng-value-container .ng-input>input{box-sizing:content-box;background:none;border:0;box-shadow:none;outline:0;cursor:default;width:100%}.ng-select .ng-select-container .ng-value-container .ng-input>input::-ms-clear{display:none}.ng-select .ng-select-container .ng-value-container .ng-input>input[readonly]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:0;padding:0}.ng-select.ng-select-single.ng-select-filtered .ng-select-container .ng-value-container .ng-value{visibility:hidden}.ng-select.ng-select-single .ng-select-container .ng-value-container,.ng-select.ng-select-single .ng-select-container .ng-value-container .ng-value{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ng-select.ng-select-single .ng-select-container .ng-value-container .ng-value .ng-value-icon{display:none}.ng-select.ng-select-single .ng-select-container .ng-value-container .ng-input{position:absolute;left:0;width:100%}.ng-select.ng-select-multiple.ng-select-disabled>.ng-select-container .ng-value-container .ng-value .ng-value-icon{display:none}.ng-select.ng-select-multiple .ng-select-container .ng-value-container{flex-wrap:wrap}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value{white-space:nowrap}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value.ng-value-disabled .ng-value-icon{display:none}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value .ng-value-icon{cursor:pointer}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-input{-webkit-box-flex:1;flex:1;z-index:2}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-placeholder{position:absolute;z-index:1}.ng-select .ng-clear-wrapper{cursor:pointer;position:relative;width:17px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ng-select .ng-clear-wrapper .ng-clear{display:inline-block;font-size:18px;line-height:1;pointer-events:none}.ng-select .ng-spinner-loader{border-radius:50%;width:17px;height:17px;margin-right:5px;font-size:10px;position:relative;text-indent:-9999em;border-top:2px solid rgba(66,66,66,.2);border-right:2px solid rgba(66,66,66,.2);border-bottom:2px solid rgba(66,66,66,.2);border-left:2px solid #424242;-webkit-transform:translateZ(0);transform:translateZ(0);-webkit-animation:.8s linear infinite load8;animation:.8s linear infinite load8}.ng-select .ng-spinner-loader:after{border-radius:50%;width:17px;height:17px}@-webkit-keyframes load8{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes load8{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.ng-select .ng-arrow-wrapper{cursor:pointer;position:relative;text-align:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ng-select .ng-arrow-wrapper .ng-arrow{pointer-events:none;display:inline-block;height:0;width:0;position:relative}.ng-dropdown-panel{box-sizing:border-box;position:absolute;opacity:0;width:100%;z-index:1050;-webkit-overflow-scrolling:touch}.ng-dropdown-panel .ng-dropdown-panel-items{display:block;height:auto;box-sizing:border-box;max-height:240px;overflow-y:auto}.ng-dropdown-panel .ng-dropdown-panel-items .ng-optgroup{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ng-dropdown-panel .ng-dropdown-panel-items .ng-option{box-sizing:border-box;cursor:pointer;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ng-dropdown-panel .ng-dropdown-panel-items .ng-option .highlighted{font-weight:700;text-decoration:underline}.ng-dropdown-panel .ng-dropdown-panel-items .ng-option.disabled{cursor:default}.ng-dropdown-panel .scroll-host{overflow:hidden;overflow-y:auto;position:relative;display:block;-webkit-overflow-scrolling:touch}.ng-dropdown-panel .scrollable-content{top:0;left:0;width:100%;height:100%;position:absolute}.ng-dropdown-panel .total-padding{width:1px;opacity:0}"]
3537
+ }] }
3538
+ ];
3539
+ /** @nocollapse */
3540
+ NgSelectComponent.ctorParameters = () => [
3541
+ { type: String, decorators: [{ type: Attribute, args: ['class',] }] },
3542
+ { type: undefined, decorators: [{ type: Attribute, args: ['autofocus',] }] },
3543
+ { type: NgSelectConfig },
3544
+ { type: undefined, decorators: [{ type: Inject, args: [SELECTION_MODEL_FACTORY,] }] },
3545
+ { type: ElementRef },
3546
+ { type: ChangeDetectorRef },
3547
+ { type: ConsoleService }
3548
+ ];
3549
+ NgSelectComponent.propDecorators = {
3550
+ bindLabel: [{ type: Input }],
3551
+ bindValue: [{ type: Input }],
3552
+ markFirst: [{ type: Input }],
3553
+ placeholder: [{ type: Input }],
3554
+ notFoundText: [{ type: Input }],
3555
+ typeToSearchText: [{ type: Input }],
3556
+ addTagText: [{ type: Input }],
3557
+ loadingText: [{ type: Input }],
3558
+ clearAllText: [{ type: Input }],
3559
+ dropdownPosition: [{ type: Input }],
3560
+ appendTo: [{ type: Input }],
3561
+ loading: [{ type: Input }],
3562
+ closeOnSelect: [{ type: Input }],
3563
+ hideSelected: [{ type: Input }],
3564
+ selectOnTab: [{ type: Input }],
3565
+ openOnEnter: [{ type: Input }],
3566
+ maxSelectedItems: [{ type: Input }],
3567
+ groupBy: [{ type: Input }],
3568
+ groupValue: [{ type: Input }],
3569
+ bufferAmount: [{ type: Input }],
3570
+ virtualScroll: [{ type: Input }],
3571
+ selectableGroup: [{ type: Input }],
3572
+ selectableGroupAsModel: [{ type: Input }],
3573
+ searchFn: [{ type: Input }],
3574
+ trackByFn: [{ type: Input }],
3575
+ clearOnBackspace: [{ type: Input }],
3576
+ labelForId: [{ type: Input }],
3577
+ inputAttrs: [{ type: Input }],
3578
+ tabIndex: [{ type: Input }],
3579
+ typeahead: [{ type: Input }, { type: HostBinding, args: ['class.ng-select-typeahead',] }],
3580
+ multiple: [{ type: Input }, { type: HostBinding, args: ['class.ng-select-multiple',] }],
3581
+ addTag: [{ type: Input }, { type: HostBinding, args: ['class.ng-select-taggable',] }],
3582
+ searchable: [{ type: Input }, { type: HostBinding, args: ['class.ng-select-searchable',] }],
3583
+ clearable: [{ type: Input }, { type: HostBinding, args: ['class.ng-select-clearable',] }],
3584
+ isOpen: [{ type: Input }, { type: HostBinding, args: ['class.ng-select-opened',] }],
3585
+ items: [{ type: Input }],
3586
+ compareWith: [{ type: Input }],
3587
+ clearSearchOnAdd: [{ type: Input }],
3588
+ blurEvent: [{ type: Output, args: ['blur',] }],
3589
+ focusEvent: [{ type: Output, args: ['focus',] }],
3590
+ changeEvent: [{ type: Output, args: ['change',] }],
3591
+ openEvent: [{ type: Output, args: ['open',] }],
3592
+ closeEvent: [{ type: Output, args: ['close',] }],
3593
+ searchEvent: [{ type: Output, args: ['search',] }],
3594
+ clearEvent: [{ type: Output, args: ['clear',] }],
3595
+ addEvent: [{ type: Output, args: ['add',] }],
3596
+ removeEvent: [{ type: Output, args: ['remove',] }],
3597
+ scroll: [{ type: Output, args: ['scroll',] }],
3598
+ scrollToEnd: [{ type: Output, args: ['scrollToEnd',] }],
3599
+ optionTemplate: [{ type: ContentChild, args: [NgOptionTemplateDirective, { read: TemplateRef, static: true },] }],
3600
+ optgroupTemplate: [{ type: ContentChild, args: [NgOptgroupTemplateDirective, { read: TemplateRef, static: true },] }],
3601
+ labelTemplate: [{ type: ContentChild, args: [NgLabelTemplateDirective, { read: TemplateRef, static: true },] }],
3602
+ multiLabelTemplate: [{ type: ContentChild, args: [NgMultiLabelTemplateDirective, { read: TemplateRef, static: true },] }],
3603
+ headerTemplate: [{ type: ContentChild, args: [NgHeaderTemplateDirective, { read: TemplateRef, static: true },] }],
3604
+ footerTemplate: [{ type: ContentChild, args: [NgFooterTemplateDirective, { read: TemplateRef, static: true },] }],
3605
+ notFoundTemplate: [{ type: ContentChild, args: [NgNotFoundTemplateDirective, { read: TemplateRef, static: true },] }],
3606
+ typeToSearchTemplate: [{ type: ContentChild, args: [NgTypeToSearchTemplateDirective, { read: TemplateRef, static: true },] }],
3607
+ loadingTextTemplate: [{ type: ContentChild, args: [NgLoadingTextTemplateDirective, { read: TemplateRef, static: true },] }],
3608
+ tagTemplate: [{ type: ContentChild, args: [NgTagTemplateDirective, { read: TemplateRef, static: true },] }],
3609
+ loadingSpinnerTemplate: [{ type: ContentChild, args: [NgLoadingSpinnerTemplateDirective, { read: TemplateRef, static: true },] }],
3610
+ dropdownPanel: [{ type: ViewChild, args: [forwardRef((/**
3611
+ * @return {?}
3612
+ */
3613
+ () => NgDropdownPanelComponent)), { static: false },] }],
3614
+ searchInput: [{ type: ViewChild, args: ['searchInput', { static: true },] }],
3615
+ ngOptions: [{ type: ContentChildren, args: [NgOptionComponent, { descendants: true },] }],
3616
+ disabled: [{ type: HostBinding, args: ['class.ng-select-disabled',] }],
3617
+ filtered: [{ type: HostBinding, args: ['class.ng-select-filtered',] }],
3618
+ handleKeyDown: [{ type: HostListener, args: ['keydown', ['$event'],] }]
3619
+ };
3620
+
3621
+ /**
3622
+ * @fileoverview added by tsickle
3623
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3624
+ */
3625
+ /**
3626
+ * @return {?}
3627
+ */
3628
+ function DefaultSelectionModelFactory() {
3629
+ return new DefaultSelectionModel();
3630
+ }
3631
+ class DefaultSelectionModel {
3632
+ constructor() {
3633
+ this._selected = [];
3634
+ }
3635
+ /**
3636
+ * @return {?}
3637
+ */
3638
+ get value() {
3639
+ return this._selected;
3640
+ }
3641
+ /**
3642
+ * @param {?} item
3643
+ * @param {?} multiple
3644
+ * @param {?} groupAsModel
3645
+ * @return {?}
3646
+ */
3647
+ select(item, multiple, groupAsModel) {
3648
+ item.selected = true;
3649
+ if (groupAsModel || !item.children) {
3650
+ this._selected.push(item);
3651
+ }
3652
+ if (multiple) {
3653
+ if (item.parent) {
3654
+ /** @type {?} */
3655
+ const childrenCount = item.parent.children.length;
3656
+ /** @type {?} */
3657
+ const selectedCount = item.parent.children.filter((/**
3658
+ * @param {?} x
3659
+ * @return {?}
3660
+ */
3661
+ x => x.selected)).length;
3662
+ item.parent.selected = childrenCount === selectedCount;
3663
+ }
3664
+ else if (item.children) {
3665
+ this._setChildrenSelectedState(item.children, true);
3666
+ this._removeChildren(item);
3667
+ if (!groupAsModel) {
3668
+ this._selected = [...this._selected, ...item.children];
3669
+ }
3670
+ }
3671
+ }
3672
+ }
3673
+ /**
3674
+ * @param {?} item
3675
+ * @param {?} multiple
3676
+ * @return {?}
3677
+ */
3678
+ unselect(item, multiple) {
3679
+ this._selected = this._selected.filter((/**
3680
+ * @param {?} x
3681
+ * @return {?}
3682
+ */
3683
+ x => x !== item));
3684
+ item.selected = false;
3685
+ if (multiple) {
3686
+ if (item.parent && item.parent.selected) {
3687
+ /** @type {?} */
3688
+ const children = item.parent.children;
3689
+ this._removeParent(item.parent);
3690
+ this._removeChildren(item.parent);
3691
+ this._selected.push(...children.filter((/**
3692
+ * @param {?} x
3693
+ * @return {?}
3694
+ */
3695
+ x => x !== item)));
3696
+ item.parent.selected = false;
3697
+ }
3698
+ else if (item.children) {
3699
+ this._setChildrenSelectedState(item.children, false);
3700
+ this._removeChildren(item);
3701
+ }
3702
+ }
3703
+ }
3704
+ /**
3705
+ * @param {?} keepDisabled
3706
+ * @return {?}
3707
+ */
3708
+ clear(keepDisabled) {
3709
+ this._selected = keepDisabled ? this._selected.filter((/**
3710
+ * @param {?} x
3711
+ * @return {?}
3712
+ */
3713
+ x => x.disabled)) : [];
3714
+ }
3715
+ /**
3716
+ * @private
3717
+ * @param {?} children
3718
+ * @param {?} selected
3719
+ * @return {?}
3720
+ */
3721
+ _setChildrenSelectedState(children, selected) {
3722
+ children.forEach((/**
3723
+ * @param {?} x
3724
+ * @return {?}
3725
+ */
3726
+ x => x.selected = selected));
3727
+ }
3728
+ /**
3729
+ * @private
3730
+ * @param {?} parent
3731
+ * @return {?}
3732
+ */
3733
+ _removeChildren(parent) {
3734
+ this._selected = this._selected.filter((/**
3735
+ * @param {?} x
3736
+ * @return {?}
3737
+ */
3738
+ x => x.parent !== parent));
3739
+ }
3740
+ /**
3741
+ * @private
3742
+ * @param {?} parent
3743
+ * @return {?}
3744
+ */
3745
+ _removeParent(parent) {
3746
+ this._selected = this._selected.filter((/**
3747
+ * @param {?} x
3748
+ * @return {?}
3749
+ */
3750
+ x => x !== parent));
3751
+ }
3752
+ }
3753
+
3754
+ /**
3755
+ * @fileoverview added by tsickle
3756
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3757
+ */
3758
+ const ɵ0 = DefaultSelectionModelFactory;
3759
+ class NgSelectModule {
3760
+ }
3761
+ NgSelectModule.decorators = [
3762
+ { type: NgModule, args: [{
3763
+ declarations: [
3764
+ NgDropdownPanelComponent,
3765
+ NgOptionComponent,
3766
+ NgSelectComponent,
3767
+ NgOptgroupTemplateDirective,
3768
+ NgOptionTemplateDirective,
3769
+ NgLabelTemplateDirective,
3770
+ NgMultiLabelTemplateDirective,
3771
+ NgHeaderTemplateDirective,
3772
+ NgFooterTemplateDirective,
3773
+ NgNotFoundTemplateDirective,
3774
+ NgTypeToSearchTemplateDirective,
3775
+ NgLoadingTextTemplateDirective,
3776
+ NgTagTemplateDirective,
3777
+ NgLoadingSpinnerTemplateDirective
3778
+ ],
3779
+ imports: [
3780
+ CommonModule
3781
+ ],
3782
+ exports: [
3783
+ NgSelectComponent,
3784
+ NgOptionComponent,
3785
+ NgOptgroupTemplateDirective,
3786
+ NgOptionTemplateDirective,
3787
+ NgLabelTemplateDirective,
3788
+ NgMultiLabelTemplateDirective,
3789
+ NgHeaderTemplateDirective,
3790
+ NgFooterTemplateDirective,
3791
+ NgNotFoundTemplateDirective,
3792
+ NgTypeToSearchTemplateDirective,
3793
+ NgLoadingTextTemplateDirective,
3794
+ NgTagTemplateDirective,
3795
+ NgLoadingSpinnerTemplateDirective
3796
+ ],
3797
+ providers: [
3798
+ { provide: SELECTION_MODEL_FACTORY, useValue: ɵ0 }
3799
+ ]
3800
+ },] }
3801
+ ];
3802
+
3803
+ export { NgSelectComponent, NgSelectConfig, NgSelectModule, SELECTION_MODEL_FACTORY, DefaultSelectionModelFactory as ɵb, DefaultSelectionModel as ɵc, NgDropdownPanelService as ɵd, NgOptionTemplateDirective as ɵe, NgOptgroupTemplateDirective as ɵf, NgLabelTemplateDirective as ɵg, NgMultiLabelTemplateDirective as ɵh, NgHeaderTemplateDirective as ɵi, NgFooterTemplateDirective as ɵj, NgNotFoundTemplateDirective as ɵk, NgTypeToSearchTemplateDirective as ɵl, NgLoadingTextTemplateDirective as ɵm, NgTagTemplateDirective as ɵn, NgLoadingSpinnerTemplateDirective as ɵo, NgDropdownPanelComponent as ɵp, NgOptionComponent as ɵq, ConsoleService as ɵr };
3804
+ //# sourceMappingURL=ng-select-ng-select.js.map