import { Component } from '@angular/core';
import { prefixesForNumber } from '@aztrix/helpers';
import { Subject } from 'rxjs';
import { AutocompletionComponent } from '../autocompletion.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/material/legacy-autocomplete";
import * as i3 from "@angular/material/legacy-core";
import * as i4 from "@aztrix/icons";
import * as i5 from "@aztrix/helpers";
export class PhoneAutocompletionComponent extends AutocompletionComponent {
    constructor() {
        super(...arguments);
        this.results$ = new Subject();
    }
    autocomplete(value) {
        this.results$.next(this.searchCountriesWithPhonePrefix(value));
    }
    searchCountriesWithPhonePrefix(prefix) {
        return prefixesForNumber(prefix).sort((a, b) => a.phonePrefix.localeCompare(b.phonePrefix));
    }
}
PhoneAutocompletionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PhoneAutocompletionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
PhoneAutocompletionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: PhoneAutocompletionComponent, selector: "ax-phone-autocompletion", usesInheritance: true, ngImport: i0, template: "<mat-autocomplete #autocompletor=\"matAutocomplete\" (optionSelected)=\"selectedResult($event)\">\n  <ng-container *ngIf=\"!disabled\">\n    <mat-option *ngFor=\"let country of results$ | async\" [value]=\"country\">\n      <div class=\"c-select-option c-select-option--phone\">\n        <span class=\"c-select-option__text\">\n          {{ country['countryCode'] | countryCodeLabel }}\n          <span class=\"c-select-option--phone__prefix\">{{ country['phonePrefix'] }}</span>\n        </span>\n        <ax-icon class=\"icon\" [name]=\"country['countryCode']\"></ax-icon>\n      </div>\n    </mat-option>\n  </ng-container>\n</mat-autocomplete>\n", styles: [".c-select-option img{display:inline-block;width:20px;height:20px;position:relative}.c-select-option__text{padding:0 .25rem;flex:1 0 85%}.c-select-option__text .c-select-option--phone__prefix{color:#7a8692}.c-select-option--phone{display:flex;justify-content:space-between;align-items:center}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.MatLegacyAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { kind: "component", type: i3.MatLegacyOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i4.IconComponent, selector: "ax-icon", inputs: ["name", "inline"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.CountryCodeLabelPipe, name: "countryCodeLabel" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PhoneAutocompletionComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-phone-autocompletion', template: "<mat-autocomplete #autocompletor=\"matAutocomplete\" (optionSelected)=\"selectedResult($event)\">\n  <ng-container *ngIf=\"!disabled\">\n    <mat-option *ngFor=\"let country of results$ | async\" [value]=\"country\">\n      <div class=\"c-select-option c-select-option--phone\">\n        <span class=\"c-select-option__text\">\n          {{ country['countryCode'] | countryCodeLabel }}\n          <span class=\"c-select-option--phone__prefix\">{{ country['phonePrefix'] }}</span>\n        </span>\n        <ax-icon class=\"icon\" [name]=\"country['countryCode']\"></ax-icon>\n      </div>\n    </mat-option>\n  </ng-container>\n</mat-autocomplete>\n", styles: [".c-select-option img{display:inline-block;width:20px;height:20px;position:relative}.c-select-option__text{padding:0 .25rem;flex:1 0 85%}.c-select-option__text .c-select-option--phone__prefix{color:#7a8692}.c-select-option--phone{display:flex;justify-content:space-between;align-items:center}\n"] }]
        }] });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGhvbmUtYXV0b2NvbXBsZXRpb24uY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4v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