{ "version": 3, "sources": ["src/@omnial/_services/external/google.address.service.ts"], "sourcesContent": ["import { Country } from '../../_models/order/country.model';\r\nimport { Injectable } from '@angular/core';\r\nimport { GoogleAddress, Address } from 'src/@omnial/_models/customer/address.model';\r\n\r\nimport PlaceResult = google.maps.places.PlaceResult;\r\n\r\n@Injectable()\r\nexport class GoogleAddressService {\r\n\r\n constructor() { }\r\n\r\n public formatAddress(googleAddress: GoogleAddress, countryCode: string, countries: Country[]): Address {\r\n const address = new Address();\r\n const country = countries.find(c => c.twoLetterIsoCode === countryCode);\r\n if (country === undefined || country === null) {\r\n return null;\r\n }\r\n address.country = country;\r\n if (googleAddress.subpremise !== undefined && googleAddress.subpremise) {\r\n address.address1 = googleAddress.subpremise;\r\n }\r\n if (googleAddress.streetNumber !== undefined && googleAddress.streetNumber) {\r\n if (address.address1 !== undefined && address.address1) {\r\n address.address1 += ` ${googleAddress.streetNumber}`;\r\n } else {\r\n address.address1 = googleAddress.streetNumber;\r\n }\r\n }\r\n if (googleAddress.route !== undefined && googleAddress.route) {\r\n if (address.address1 !== undefined && address.address1) {\r\n address.address1 += ` ${googleAddress.route}`;\r\n } else {\r\n address.address1 = googleAddress.route;\r\n }\r\n }\r\n if (googleAddress.locality !== undefined && googleAddress.locality) {\r\n address.city = googleAddress.locality;\r\n }\r\n if (googleAddress.administrativeAreaLevel2 !== undefined && googleAddress.administrativeAreaLevel2) {\r\n address.state = country.states?.find(s => s.abbreviation === googleAddress.administrativeAreaLevel2Short);\r\n if (!address.state) {\r\n address.stateName = googleAddress.administrativeAreaLevel2;\r\n } else {\r\n address.stateName = '';\r\n }\r\n }\r\n if (googleAddress.administrativeAreaLevel1 !== undefined && googleAddress.administrativeAreaLevel1) {\r\n if (address.city !== undefined && address.city) {\r\n address.city += ` ${googleAddress.administrativeAreaLevel2}`;\r\n } else {\r\n address.city = googleAddress.administrativeAreaLevel2;\r\n }\r\n }\r\n if (googleAddress.postalCode !== undefined && googleAddress.postalCode) {\r\n address.zipPostalCode = googleAddress.postalCode;\r\n }\r\n return address;\r\n }\r\n\r\n public formatAustralianAddress(googleAddress: GoogleAddress, countries: Country[]): Address {\r\n const australia = countries.find(c => c.twoLetterIsoCode === 'AU');\r\n if (australia === undefined || australia === null) {\r\n return null;\r\n }\r\n const address = new Address();\r\n if (googleAddress.subpremise !== undefined && googleAddress.subpremise) {\r\n address.address1 = googleAddress.subpremise;\r\n }\r\n if (googleAddress.streetNumber !== undefined && googleAddress.streetNumber) {\r\n if (address.address1 !== undefined && address.address1) {\r\n address.address1 += ` ${googleAddress.streetNumber}`;\r\n } else {\r\n address.address1 = googleAddress.streetNumber;\r\n }\r\n }\r\n if (googleAddress.route !== undefined && googleAddress.route) {\r\n if (address.address1 !== undefined && address.address1) {\r\n address.address1 += ` ${googleAddress.route}`;\r\n } else {\r\n address.address1 = googleAddress.route;\r\n }\r\n }\r\n if (googleAddress.locality !== undefined && googleAddress.locality) {\r\n address.city = googleAddress.locality;\r\n }\r\n if (googleAddress.administrativeAreaLevel2 !== undefined && googleAddress.administrativeAreaLevel2) {\r\n address.stateName = googleAddress.administrativeAreaLevel2;\r\n address.state = australia.states.find(s => s.abbreviation === googleAddress.administrativeAreaLevel2Short);\r\n }\r\n if (googleAddress.administrativeAreaLevel1 !== undefined && googleAddress.administrativeAreaLevel1) {\r\n if (address.city !== undefined && address.city) {\r\n address.city += ` ${googleAddress.administrativeAreaLevel2}`;\r\n } else {\r\n address.city = googleAddress.administrativeAreaLevel2;\r\n }\r\n }\r\n if (googleAddress.postalCode !== undefined && googleAddress.postalCode) {\r\n address.zipPostalCode = googleAddress.postalCode;\r\n }\r\n address.country = australia;\r\n return address;\r\n }\r\n\r\n public getGoogleAddress(result: PlaceResult): GoogleAddress {\r\n const googleAddress = new GoogleAddress();\r\n if (result && result.address_components) {\r\n for (const component of result.address_components) {\r\n if (component.types) {\r\n for (const componentType of component.types) {\r\n switch (componentType) {\r\n case 'subpremise':\r\n googleAddress.subpremiseShort = component.short_name;\r\n googleAddress.subpremise = component.long_name;\r\n break;\r\n case 'street_number':\r\n googleAddress.streetNumberShort = component.short_name;\r\n googleAddress.streetNumber = component.long_name;\r\n break;\r\n case 'route':\r\n googleAddress.routeShort = component.short_name;\r\n googleAddress.route = component.long_name;\r\n break;\r\n case 'locality':\r\n googleAddress.localityShort = component.short_name;\r\n googleAddress.locality = component.long_name;\r\n break;\r\n case 'administrative_area_level_2':\r\n googleAddress.administrativeAreaLevel2Short = component.short_name;\r\n googleAddress.administrativeAreaLevel2 = component.long_name;\r\n break;\r\n case 'administrative_area_level_1':\r\n googleAddress.administrativeAreaLevel2Short = component.short_name;\r\n googleAddress.administrativeAreaLevel2 = component.long_name;\r\n break;\r\n case 'country':\r\n googleAddress.countryShort = component.short_name;\r\n googleAddress.country = component.long_name;\r\n break;\r\n case 'postal_code':\r\n googleAddress.postalCodeShort = component.short_name;\r\n googleAddress.postalCode = component.long_name;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return googleAddress;\r\n }\r\n}\r\n"], "mappings": "uFAOA,IAAaA,GAAoB,IAAA,CAA3B,MAAOA,CAAoB,CAE/BC,aAAA,CAAgB,CAETC,cAAcC,EAA8BC,EAAqBC,EAAoB,CAC1F,IAAMC,EAAU,IAAIC,EACdC,EAAUH,EAAUI,KAAKC,GAAKA,EAAEC,mBAAqBP,CAAW,EACtE,OAA6BI,GAAY,KAChC,MAETF,EAAQE,QAAUA,EACdL,EAAcS,aAAeC,QAAaV,EAAcS,aAC1DN,EAAQQ,SAAWX,EAAcS,YAE/BT,EAAcY,eAAiBF,QAAaV,EAAcY,eACxDT,EAAQQ,WAAaD,QAAaP,EAAQQ,SAC5CR,EAAQQ,UAAY,IAAIX,EAAcY,YAAY,GAElDT,EAAQQ,SAAWX,EAAcY,cAGjCZ,EAAca,QAAUH,QAAaV,EAAca,QACjDV,EAAQQ,WAAaD,QAAaP,EAAQQ,SAC5CR,EAAQQ,UAAY,IAAIX,EAAca,KAAK,GAE3CV,EAAQQ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ApBA,EAAoB8C,QAApB9C,EAAoB+C,SAAA,CAAA,CAAA,SAApB/C,CAAoB,GAAA", "names": ["GoogleAddressService", "constructor", "formatAddress", "googleAddress", "countryCode", "countries", "address", "Address", "country", "find", "c", "twoLetterIsoCode", "subpremise", "undefined", "address1", "streetNumber", "route", "locality", "city", "administrativeAreaLevel2", "state", "states", "s", "abbreviation", "administrativeAreaLevel2Short", "stateName", "administrativeAreaLevel1", "postalCode", "zipPostalCode", "formatAustralianAddress", "australia", "getGoogleAddress", "result", "GoogleAddress", "address_components", "component", "types", "componentType", "subpremiseShort", "short_name", "long_name", "streetNumberShort", "routeShort", "localityShort", "countryShort", "postalCodeShort", "factory", "\u0275fac"] }