{"version":3,"sources":["webpack://checkout/./src/app/ui/form/CheckboxInput.tsx","webpack://checkout/./src/app/ui/form/TextArea.tsx","webpack://checkout/./src/app/address/isEqualAddress.ts","webpack://checkout/./src/app/ui/form/CheckboxFormField.tsx","webpack://checkout/./src/app/shipping/getShippableItemsCount.ts","webpack://checkout/./src/app/formFields/mapCustomFormFieldsFromFormValues.ts","webpack://checkout/./src/app/address/getAddressFormFieldInputId.ts","webpack://checkout/./src/app/address/googleAutocomplete/AddressSelector.ts","webpack://checkout/./src/app/address/googleAutocomplete/AddressSelectorUk.ts","webpack://checkout/./src/app/address/googleAutocomplete/AddressSelectorFactory.ts","webpack://checkout/./src/app/ui/popover/Popover.tsx","webpack://checkout/./src/app/ui/popover/PopoverList.tsx","webpack://checkout/./src/app/address/googleAutocomplete/getGoogleAutocompleteScriptLoader.ts","webpack://checkout/./src/app/ui/autocomplete/Autocomplete.tsx","webpack://checkout/./src/app/address/googleAutocomplete/GoogleAutocompleteScriptLoader.ts","webpack://checkout/./src/app/address/googleAutocomplete/GoogleAutocompleteService.ts","webpack://checkout/./src/app/address/googleAutocomplete/GoogleAutocomplete.tsx","webpack://checkout/./src/app/address/googleAutocomplete/GoogleAutocompleteFormField.tsx","webpack://checkout/./src/app/address/AddressForm.tsx","webpack://checkout/./src/app/address/googleAutocomplete/mapToAddress.ts","webpack://checkout/./src/app/locale/withDate.tsx","webpack://checkout/./src/app/ui/form/RadioInput.tsx","webpack://checkout/./src/app/ui/form/DynamicInput.tsx","webpack://checkout/./src/app/ui/form/MultiCheckboxControl.tsx","webpack://checkout/./src/app/ui/form/CheckboxGroupFormField.tsx","webpack://checkout/./src/app/ui/form/DynamicFormField.tsx","webpack://checkout/./src/app/address/mapAddressFromFormValues.ts","webpack://checkout/./src/app/address/isValidCustomerAddress.ts","webpack://checkout/./src/app/orderComments/OrderComments.tsx","webpack://checkout/./src/app/payment/getPreselectedPayment.ts","webpack://checkout/./src/app/ui/dropdown/DropdownTrigger.tsx","webpack://checkout/./src/app/address/AddressSelect.tsx","webpack://checkout/./src/app/billing/getBillingMethodId.ts","webpack://checkout/./src/app/billing/BillingForm.tsx","webpack://checkout/./src/app/billing/Billing.tsx"],"names":["CheckboxInput","ref","additionalClassName","label","id","rest","className","type","htmlFor","TextArea","testId","isEqualAddress","address1","address2","normalizeAddress","stateOrProvince","stateOrProvinceCode","isSameState","address","customFields","filter","disabled","labelContent","onChange","name","renderField","field","checked","value","render","getShippableItemsCount","cart","lineItems","physicalItems","item","addedByPromotion","mapCustomFormFieldsFromFormValues","customFieldsObject","key","fieldValue","padMonth","getMonth","toString","padDay","getDate","getFullYear","push","fieldId","ADDRESS_FIELD_IDS","postalCode","getAddressFormFieldLegacyName","getAddressFormFieldInputId","googlePlace","address_components","this","_name","_address","getState","_get","getStreet","getStreet2","getCity","getCountry","getPostCode","access","element","find","types","indexOf","create","autocompleteData","addressSelector","children","getItemClassName","highlightedIndex","index","classes","join","instance","getItemProps","props","menuProps","items","length","map","content","stateReducer","state","changes","stateChangeTypes","blurInput","blurButton","mouseUp","touchEnd","inputValue","changeInput","isOpen","keyDownEnter","handleStateChange","onToggleOpen","undefined","inputProps","initialValue","initialHighlightedIndex","onSelect","listTestId","defaultHighlightedIndex","initialInputValue","itemToString","onStateChange","getInputProps","getMenuProps","toPopoverItem","highlightItem","highlightedSlices","lastIndex","reduce","node","slice","i","offset","notHighlightedLength","substr","_scriptLoader","loadMapsSdk","apiKey","_googleAutoComplete","Promise","resolve","reject","params","window","autocompleteWindow","Boolean","google","maps","places","isAutocompleteWindow","loadScript","catch","e","_apiKey","getAutocompleteService","_autocompletePromise","then","googleMapsSdk","AutocompleteService","Error","getPlacesServices","document","createElement","_placesPromise","PlacesService","fields","nextElement","googleAutocompleteService","service","getDetails","placeId","result","focus","input","isAutocompleteEnabled","resetAutocomplete","setAutocomplete","setItems","autoComplete","componentRestrictions","getPlacePredictions","results","setState","toAutocompleteItems","description","structured_formatting","main_text","matched_substrings","place_id","countryCode","supportedCountries","parentFieldName","fieldName","TranslatedString","renderInput","country","FormField","LABEL","city","company","firstName","lastName","phone","AUTOCOMPLETE","PLACEHOLDER","AUTOCOMPLETE_FIELD_NAME","containerRef","handleDynamicFormFieldChange","syncNonFormikValue","handleAutocompleteChange","handleAutocompleteSelect","place","autocompleteValue","countries","setFieldValue","accessor","c","code","street2","stateName","states","subdivisions","mapToAddress","formFields","dateFormFieldNames","custom","fieldType","DynamicFormFieldType","date","componentDidMount","current","querySelector","language","countriesWithAutocomplete","googleMapsApiKey","onAutocompleteToggle","shouldShowSaveAddress","Fieldset","addressFieldName","translatedPlaceholderId","DynamicFormField","autocomplete","extraClass","inputId","placeholder","translate","CheckboxFormField","withLanguage","createInjectHoc","LocaleContext","displayNamePrefix","pickProps","Input","Label","options","inputFormat","handleDateChange","dateValue","event","target","dropdown","optionValue","radio","checkbox","Array","isArray","includes","calendarClassName","dateFormat","maxDate","max","Date","minDate","min","placeholderText","toUpperCase","popperClassName","selected","multiline","TextInput","password","onSelectedAll","onSelectedNone","handleSelectAllClick","preventDefault","handleSelectNoneClick","href","onClick","MultiCheckboxFormField","form","values","errors","remove","handleSelectAll","checkedValues","forEach","val","handleSelectNone","handleInputChange","FormFieldContainer","hasError","FormFieldError","renderProps","secret","fieldLabel","required","maxLength","fieldInputId","labelComponent","dynamicFormFieldType","number","text","helperLabel","rows","mapAddressFromFormValues","formValues","shouldSaveAddress","isValidCustomerAddress","addresses","customerAddress","renderLabel","hidden","legend","getPreselectedPayment","checkout","payments","payment","providerId","shouldShow","handleClick","handleClose","nativeEvent","handleOpen","addEventListener","removeEventListener","componentWillUnmount","placement","modifiers","hide","enabled","flip","preventOverflow","style","width","zIndex","defaultProps","handleSelectAddress","newAddress","onSelectAddress","selectedAddress","handleUseNewAddress","onUseNewAddress","role","AddressSelectMenu","AddressSelectButton","StaticAddress","getBillingMethodId","preselectedPayment","isResettingAddress","addressFormRef","updateAddress","onUnhandledError","billingAddress","customer","isGuest","getFields","isUpdating","shouldShowOrderComments","shouldRenderStaticAddress","allFormFields","customFormFields","hasCustomFormFields","editableFormFields","hasAddresses","hasValidCustomerAddress","Form","StaticBillingAddress","LoadingOverlay","isLoading","AddressSelect","AddressForm","OrderComments","Button","variant","Primary","handleSubmit","onSubmit","mapPropsToValues","customerMessage","mapAddressToFormValues","orderComment","isInitialValid","getAddressFormFieldsValidationSchema","isValidSync","validationSchema","getCustomFormFieldsValidationSchema","enableReinitialize","addressValues","updateCheckout","navigateNextStep","promises","all","initialize","onReady","isInitializing","Legend","unmountContentWhenLoading","withCheckout","checkoutService","checkoutState","getCheckout","getConfig","getCart","getCustomer","getBillingAddress","getBillingAddressFields","getBillingCountries","isLoadingBillingCountries","isUpdatingBillingAddress","isUpdatingCheckout","config","checkoutSettings","enableOrderComments","loadBillingAddressFields","methodId","updateBillingAddress"],"mappings":"yKAaMA,EAAgB,sBAAW,SAC7B,EAMAC,GALI,IAAAC,EAAmB,sBACnBC,EAAK,QACLC,EAAE,KACCC,EAAI,mBAJX,sCAOC,OACD,oCACI,kBAAC,IAAK,sBACGA,EAAI,CACTC,UAAY,IACR,gBACA,kCACAJ,GAEJE,GAAKA,EACLH,IAAMA,EACNM,KAAK,cAET,kBAAC,IAAK,CAACC,QAAUJ,GACXD,OAKC,O,8EChCTM,EAAW,sBAAW,SACxB,EACAR,GADE,IAAAC,EAAmB,sBAAEQ,EAAM,SAAEJ,EAAS,YAAKD,EAAI,mBAAjD,8CAEC,OACD,mDACSA,EAAI,CACTC,UAAYA,GAAa,IACrB,aACA,+BACAJ,GACH,YACWQ,EACZT,IAAMA,QAIC,O,uFClBA,SAASU,EAAeC,EAA8BC,GACjE,SAAKD,IAAaC,KAIX,kBACHC,EAAiBF,GACjBE,EAAiBD,KAIzB,SAAqBD,EAA6BC,GAC9C,GAAID,EAASG,iBAAmBH,EAASG,kBAAoBF,EAASE,gBAClE,OAAO,EAGX,GAAIH,EAASI,qBAAuBJ,EAASI,sBAAwBH,EAASG,oBAC1E,OAAO,EAGX,OA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4BACzBC,EAAwB,2BACxBC,EAAkB,qBAIpBC,EAAST,IACThD,EAAWkD,IACXzF,EAAWsF,IACX/W,EAAOiX,IAEb,KAAKQ,GAAWzD,GAAavC,GAAazR,GACtC,OAAO,KAGL,MAIFyX,EAAOC,iBAHPC,EAAmB,sBACnB5L,EAAgB,mBAIdD,EAA4B,CAAC,KAAM,KAAM,KAAM,MAMrD,OATY,WAKC,0DACTA,EAA0B/K,KAAK,MAG5B,CACHgT,eAAgBoD,IAChBzM,UAAW2M,KAAyB,IACpCvL,0BAAyB,EACzBkI,SAAQ,EACRyB,gBAAiBhE,EAASgE,gBAC1BvB,UAAWkD,EACXrL,iBAAgB,EAChBwK,WAAYM,EAAgBe,yBAC5BnB,eAAgBa,IAChBnD,WAAYoD,KAA8BC,IAC1CK,SAAUpE,EAAmBhC,GAC7B2C,wBAAyBuD,GAAuB,OAAA5X,EAAA,GAAuBC,GAAQ,EAC/E6T,cAAegD,EAAgBiB,qBAC/B3B,eAAgBU,EAAgBV,kBAIzB,CAAgC","file":"billing-d9ad1867.js","sourcesContent":["import classNames from 'classnames';\nimport React, { forwardRef, ReactNode, Ref } from 'react';\n\nimport Input, { InputProps } from './Input';\nimport Label from './Label';\n\nexport interface CheckboxInputProps extends InputProps {\n    additionalClassName?: string;\n    label: ReactNode;\n    value: string;\n    checked: boolean;\n}\n\nconst CheckboxInput = forwardRef((\n    {\n        additionalClassName,\n        label,\n        id,\n        ...rest\n    }: CheckboxInputProps,\n    ref: Ref<HTMLInputElement>\n) => (\n    <>\n        <Input\n            { ...rest }\n            className={ classNames(\n                'form-checkbox',\n                'optimizedCheckout-form-checkbox',\n                additionalClassName\n            ) }\n            id={ id }\n            ref={ ref }\n            type=\"checkbox\"\n        />\n        <Label htmlFor={ id }>\n            { label }\n        </Label>\n    </>\n));\n\nexport default CheckboxInput;\n","import classNames from 'classnames';\nimport React, { forwardRef, Ref, TextareaHTMLAttributes } from 'react';\n\nexport interface TextAreaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n    additionalClassName?: string;\n    testId?: string;\n}\n\nconst TextArea = forwardRef((\n    { additionalClassName, testId, className, ...rest }: TextAreaProps,\n    ref: Ref<HTMLTextAreaElement>\n) => (\n    <textarea\n        { ...rest }\n        className={ className || classNames(\n            'form-input',\n            'optimizedCheckout-form-input',\n            additionalClassName\n        ) }\n        data-test={ testId }\n        ref={ ref }\n    />\n));\n\nexport default TextArea;\n","import { Address, AddressRequestBody, BillingAddress, CustomerAddress } from '@bigcommerce/checkout-sdk';\nimport { isEqual, omit } from 'lodash';\n\ntype ComparableAddress = CustomerAddress | Address | BillingAddress | AddressRequestBody;\ntype ComparableAddressFields = keyof CustomerAddress | keyof Address | keyof BillingAddress;\n\nexport default function isEqualAddress(address1?: ComparableAddress, address2?: ComparableAddress): boolean {\n    if (!address1 || !address2) {\n        return false;\n    }\n\n    return isEqual(\n        normalizeAddress(address1),\n        normalizeAddress(address2)\n    ) && isSameState(address1, address2);\n}\n\nfunction isSameState(address1: ComparableAddress, address2: ComparableAddress): boolean {\n    if (address1.stateOrProvince && address1.stateOrProvince === address2.stateOrProvince) {\n        return true;\n    }\n\n    if (address1.stateOrProvinceCode && address1.stateOrProvinceCode === address2.stateOrProvinceCode) {\n        return true;\n    }\n\n    return address1.stateOrProvince === address2.stateOrProvince &&\n        address1.stateOrProvinceCode === address2.stateOrProvinceCode;\n}\n\nfunction normalizeAddress(address: ComparableAddress) {\n    const ignoredFields: ComparableAddressFields[] = [\n        'id',\n        'shouldSaveAddress',\n        'stateOrProvince',\n        'stateOrProvinceCode',\n        'type',\n        'email',\n        'country',\n    ];\n\n    return omit(\n        {\n            ...address,\n            customFields: (address.customFields || []).filter(({ fieldValue }) => !!fieldValue),\n        },\n        ignoredFields\n    );\n}\n","import { FieldProps } from 'formik';\nimport { kebabCase } from 'lodash';\nimport React, { memo, useCallback, Fragment, FunctionComponent, ReactNode } from 'react';\n\nimport BasicFormField from './BasicFormField';\nimport CheckboxInput from './CheckboxInput';\nimport FormFieldError from './FormFieldError';\n\nexport interface CheckboxFormFieldProps {\n    additionalClassName?: string;\n    disabled?: boolean;\n    name: string;\n    id?: string;\n    labelContent: ReactNode;\n    onChange?(isChecked: boolean): void;\n}\n\nconst CheckboxFormField: FunctionComponent<CheckboxFormFieldProps> = ({\n    additionalClassName,\n    disabled = false,\n    labelContent,\n    onChange,\n    name,\n    id,\n}) => {\n    const renderField = useCallback(({ field }: FieldProps) => (\n        <Fragment>\n            { <CheckboxInput\n                { ...field }\n                checked={ !!field.value }\n                disabled={ disabled }\n                id={ id || field.name }\n                label={ labelContent }\n            /> }\n\n            <FormFieldError\n                name={ name }\n                testId={ `${kebabCase(name)}-field-error-message` }\n            />\n        </Fragment>\n    ), [\n        disabled,\n        id,\n        labelContent,\n        name,\n    ]);\n\n    return <BasicFormField\n        additionalClassName={ additionalClassName }\n        name={ name }\n        onChange={ onChange }\n        render={ renderField }\n    />;\n};\n\nexport default memo(CheckboxFormField);\n","import { Cart } from '@bigcommerce/checkout-sdk';\n\nimport getLineItemsCount from './getLineItemsCount';\n\nexport default function getShippableItemsCount(cart: Cart): number {\n    return getLineItemsCount(cart.lineItems.physicalItems.filter(item => !item.addedByPromotion));\n}\n","import { forIn, isDate, padStart } from 'lodash';\n\nexport default function mapCustomFormFieldsFromFormValues(\n    customFieldsObject: { [id: string]: any }\n): Array<{fieldId: string; fieldValue: string}> {\n    const customFields: Array<{fieldId: string; fieldValue: string}> = [];\n    forIn(customFieldsObject, (value, key) => {\n        let fieldValue: string;\n\n        if (isDate(value)) {\n            const padMonth = padStart((value.getMonth() + 1).toString(), 2, '0');\n            const padDay = padStart((value.getDate()).toString(), 2, '0');\n            fieldValue = `${value.getFullYear()}-${padMonth}-${padDay}`;\n        } else {\n            fieldValue = value;\n        }\n\n        customFields.push({\n            fieldId: key,\n            fieldValue,\n        });\n    });\n\n    return customFields;\n}\n","import { AddressKeyMap } from './address';\n\nexport const ADDRESS_FIELD_IDS: AddressKeyMap = {\n    address1: 'addressLine1',\n    address2: 'addressLine2',\n    postalCode: 'postCode',\n    stateOrProvince: 'province',\n    stateOrProvinceCode: 'provinceCode',\n};\n\nexport function getAddressFormFieldLegacyName(name: string): string {\n    return `${ADDRESS_FIELD_IDS[name] || name}`;\n}\n\nexport function getAddressFormFieldInputId(name: string): string {\n    return `${getAddressFormFieldLegacyName(name)}Input`;\n}\n","import { GoogleAddressFieldType } from './googleAutocompleteTypes';\n\nexport default class AddressSelector {\n    protected _address: google.maps.GeocoderAddressComponent[] | undefined;\n    protected _name: string;\n\n    constructor(\n        googlePlace: google.maps.places.PlaceResult\n    ) {\n        const { address_components, name } = googlePlace;\n\n        this._name = name;\n        this._address = address_components;\n    }\n\n    getState(): string {\n        return this._get('administrative_area_level_1', 'short_name');\n    }\n\n    getStreet(): string {\n        return this._name;\n    }\n\n    getStreet2(): string {\n        return '';\n    }\n\n    getCity(): string {\n        return this._get('postal_town', 'long_name') ||\n            this._get('locality', 'long_name') ||\n            this._get('neighborhood', 'short_name');\n    }\n\n    getCountry(): string {\n        return this._get('country', 'short_name');\n    }\n\n    getPostCode(): string {\n        return this._get('postal_code', 'short_name');\n    }\n\n    protected _get(\n        type: GoogleAddressFieldType,\n        access: Exclude<keyof google.maps.GeocoderAddressComponent, 'types'>\n    ): string {\n        const element = this._address && this._address.find(field => field.types.indexOf(type) !== -1);\n\n        if (element) {\n            return element[access];\n        }\n\n        return '';\n    }\n}\n","import AddressSelector from './AddressSelector';\n\nexport default class AddressSelectorUK extends AddressSelector {\n    getState(): string {\n        return this._get('administrative_area_level_2', 'long_name');\n    }\n\n    getStreet2(): string {\n        return this._get('locality', 'long_name');\n    }\n}\n","import AddressSelector from './AddressSelector';\nimport AddressSelectorUK from './AddressSelectorUk';\n\nexport default class AddressSelectorFactory {\n    static create(autocompleteData: google.maps.places.PlaceResult): AddressSelector {\n        const addressSelector = new AddressSelector(autocompleteData);\n\n        switch (addressSelector.getCountry()) {\n        case 'GB':\n            return new AddressSelectorUK(autocompleteData);\n        }\n\n        return addressSelector;\n    }\n}\n","import React, { FunctionComponent } from 'react';\n\nimport './Popover.scss';\n\nexport interface PopoverProps {\n    children: React.ReactNode;\n}\n\nconst Popover: FunctionComponent<PopoverProps> = ({ children }) => {\n    return (\n        <div className=\"popover\">\n            { children }\n        </div>\n    );\n};\n\nexport default Popover;\n","import React, { memo, FunctionComponent } from 'react';\n\nimport './PopoverList.scss';\n\nexport interface PopoverListProps {\n    menuProps?: any;\n    highlightedIndex?: number;\n    getItemProps?: any;\n    items: PopoverListItem[];\n    testId?: string;\n}\n\nexport interface PopoverListItem {\n    id: string;\n    content: React.ReactChild[] | React.ReactChild;\n}\n\nconst PopoverList: FunctionComponent<PopoverListProps> = ({\n    highlightedIndex = -1,\n    testId,\n    getItemProps = (props: any) => props,\n    menuProps = {},\n    items,\n}) => {\n    if (!items || !items.length) {\n        return null;\n    }\n\n    return (\n        <ul\n            className=\"popoverList\"\n            data-test={ testId } { ...menuProps }\n        >\n            { items\n                .map((item, index) => (\n                    <li\n                        className={ getItemClassName(highlightedIndex, index) }\n                        data-test={ testId && `${testId}-item` }\n                        { ...getItemProps({\n                            key: item.id,\n                            index,\n                            item,\n                        }) }\n                        key={ index }\n                    >\n                        { item.content }\n                    </li>\n                )) }\n        </ul>\n    );\n};\n\nfunction getItemClassName(highlightedIndex: number, index: number): string {\n    const classes = ['popoverList-item'];\n\n    if (highlightedIndex === index) {\n        classes.push('is-active');\n    }\n\n    return classes.join(' ');\n}\n\nexport default memo(PopoverList);\n","import GoogleAutocompleteScriptLoader from './GoogleAutocompleteScriptLoader';\n\nlet instance: GoogleAutocompleteScriptLoader;\n\nexport default function getGoogleAutocompleteScriptLoader(): GoogleAutocompleteScriptLoader {\n    if (!instance) {\n        instance = new GoogleAutocompleteScriptLoader();\n    }\n\n    return instance;\n}\n","import Downshift, { DownshiftState, StateChangeOptions } from 'downshift';\nimport { isNumber, noop } from 'lodash';\nimport React, { Fragment, PureComponent, ReactChild, ReactNode } from 'react';\n\nimport { Popover, PopoverList, PopoverListItem } from '../popover';\n\nimport AutocompleteItem from './autocomplete-item';\n\nexport interface AutocompleteProps {\n    initialValue?: string;\n    initialHighlightedIndex?: number;\n    children?: ReactNode;\n    items: AutocompleteItem[];\n    inputProps?: any;\n    listTestId?: string;\n    onToggleOpen?(state: { inputValue: string; isOpen: boolean }): void;\n    onSelect?(item: AutocompleteItem): void;\n    onChange?(value: string, isOpen: boolean): void;\n}\n\nclass Autocomplete extends PureComponent<AutocompleteProps> {\n    render(): ReactNode {\n        const {\n            inputProps,\n            initialValue,\n            initialHighlightedIndex,\n            items,\n            children,\n            onSelect,\n            listTestId,\n        } = this.props;\n\n        return (\n            <Downshift\n                defaultHighlightedIndex={ 0 }\n                initialHighlightedIndex={ initialHighlightedIndex }\n                initialInputValue={ initialValue }\n                itemToString={ this.itemToString }\n                onChange={ onSelect }\n                onStateChange={ this.handleStateChange }\n                stateReducer={ this.stateReducer }\n            >\n                { ({\n                    isOpen,\n                    getInputProps,\n                    getMenuProps,\n                    getItemProps,\n                    highlightedIndex,\n                }) => (\n                    <div>\n                        <input\n                            { ...getInputProps() }\n                            { ...inputProps }\n                        />\n                        { isOpen && !!items.length &&\n                            <Popover>\n                                <PopoverList\n                                    getItemProps={ getItemProps }\n                                    highlightedIndex={ isNumber(highlightedIndex) ? highlightedIndex : -1 }\n                                    items={ items.map(item => this.toPopoverItem(item)) }\n                                    menuProps={ getMenuProps() }\n                                    testId={ listTestId }\n                                />\n                                { children }\n                            </Popover> }\n                    </div>\n                ) }\n            </Downshift>\n        );\n    }\n\n    private toPopoverItem(item: AutocompleteItem): PopoverListItem {\n        return {\n            ...item,\n            content: this.highlightItem(item),\n        };\n    }\n\n    private highlightItem(item: AutocompleteItem): ReactChild[] | ReactChild {\n        if (!item.highlightedSlices || !item.highlightedSlices.length) {\n            return item.label;\n        }\n\n        let lastIndex: number = 0;\n        let key = 0;\n\n        return item.highlightedSlices.reduce((node, slice, i) => {\n            const { label } = item;\n            const { offset, length } = slice;\n            const notHighlightedLength = offset - lastIndex;\n\n            if (notHighlightedLength) {\n                node.push(<Fragment key={ key }>\n                    { label.substr(lastIndex, notHighlightedLength) }\n                </Fragment>);\n                key += 1;\n            }\n\n            lastIndex  = offset + length;\n\n            node.push(<strong key={ key }>{ label.substr(offset, length) }</strong>);\n            key += 1;\n\n            if (i === (item.highlightedSlices || []).length - 1) {\n                node.push(<Fragment key={ key }>\n                    { label.substr(lastIndex) }\n                </Fragment>);\n                key += 1;\n            }\n\n            return node;\n        }, [] as ReactChild[]);\n    }\n\n    private itemToString(item?: AutocompleteItem): string {\n        return item && item.value || '';\n    }\n\n    private stateReducer: (\n        state: DownshiftState<AutocompleteItem>,\n        changes: StateChangeOptions<AutocompleteItem>\n    ) => Partial<StateChangeOptions<AutocompleteItem>> = (state, changes) => {\n        const { onChange } = this.props;\n\n        switch (changes.type) {\n        case Downshift.stateChangeTypes.blurInput:\n        case Downshift.stateChangeTypes.blurButton:\n        case Downshift.stateChangeTypes.mouseUp:\n        case Downshift.stateChangeTypes.touchEnd:\n            return {\n                ...changes,\n                inputValue: state.inputValue,\n            };\n\n        case Downshift.stateChangeTypes.changeInput:\n            if (changes.inputValue !== state.inputValue && onChange) {\n                onChange(changes.inputValue || '', state.isOpen);\n            }\n\n            return changes;\n\n        case Downshift.stateChangeTypes.keyDownEnter:\n            return changes;\n\n        default:\n            return changes;\n        }\n        };\n\n    private handleStateChange = ({ isOpen, inputValue }: StateChangeOptions<string>) => {\n        const { onToggleOpen = noop } = this.props;\n\n        if (isOpen !== undefined) {\n            onToggleOpen({ isOpen, inputValue: inputValue || '' });\n        }\n    };\n}\n\nexport default Autocomplete;\n","import { getScriptLoader, ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { GoogleAutocompleteWindow, GoogleMapsSdk } from './googleAutocompleteTypes';\n\nexport default class GoogleAutocompleteScriptLoader {\n    private _scriptLoader: ScriptLoader;\n    private _googleAutoComplete?: Promise<GoogleMapsSdk>;\n\n    constructor() {\n        this._scriptLoader = getScriptLoader();\n    }\n\n    loadMapsSdk(apiKey: string): Promise<GoogleMapsSdk> {\n        if (this._googleAutoComplete) {\n            return this._googleAutoComplete;\n        }\n\n        this._googleAutoComplete = new Promise((resolve, reject) => {\n            const callbackName = 'initAutoComplete';\n            const params = [\n                'language=en',\n                `key=${apiKey}`,\n                'libraries=places',\n                `callback=${callbackName}`,\n            ].join('&');\n\n            (window as GoogleCallbackWindow)[callbackName] = () => {\n                if (isAutocompleteWindow(window)) {\n                    resolve(window.google.maps);\n                }\n\n                reject();\n            };\n\n            this._scriptLoader.loadScript(`//maps.googleapis.com/maps/api/js?${params}`)\n                .catch(e => {\n                    this._googleAutoComplete = undefined;\n                    throw e;\n                });\n        });\n\n        return this._googleAutoComplete;\n    }\n}\n\nfunction isAutocompleteWindow(window: Window): window is GoogleAutocompleteWindow {\n    const autocompleteWindow = window as GoogleAutocompleteWindow;\n\n    return Boolean(autocompleteWindow.google &&\n        autocompleteWindow.google.maps &&\n        autocompleteWindow.google.maps.places);\n}\n\nexport interface GoogleCallbackWindow extends Window {\n    initAutoComplete?(): void;\n}\n","import getGoogleAutocompleteScriptLoader from './getGoogleAutocompleteScriptLoader';\nimport GoogleAutocompleteScriptLoader from './GoogleAutocompleteScriptLoader';\n\nexport default class GoogleAutocompleteService {\n    private _autocompletePromise?: Promise<google.maps.places.AutocompleteService>;\n    private _placesPromise?: Promise<google.maps.places.PlacesService>;\n\n    constructor(\n        private _apiKey: string,\n        private _scriptLoader: GoogleAutocompleteScriptLoader = getGoogleAutocompleteScriptLoader()\n    ) {}\n\n    getAutocompleteService(): Promise<google.maps.places.AutocompleteService> {\n        if (!this._autocompletePromise) {\n            this._autocompletePromise = this._scriptLoader.loadMapsSdk(this._apiKey)\n                .then(googleMapsSdk => {\n                    if (!googleMapsSdk.places.AutocompleteService) {\n                        throw new Error('`AutocompleteService` is undefined');\n                    }\n\n                    return new googleMapsSdk.places.AutocompleteService();\n                });\n        }\n\n        return this._autocompletePromise;\n    }\n\n    getPlacesServices(): Promise<google.maps.places.PlacesService> {\n        const node = document.createElement('div');\n\n        if (!this._placesPromise) {\n            this._placesPromise = this._scriptLoader.loadMapsSdk(this._apiKey)\n                .then(googleMapsSdk => {\n                    if (!googleMapsSdk.places.PlacesService) {\n                        throw new Error('`PlacesService` is undefined');\n                    }\n\n                    return new googleMapsSdk.places.PlacesService(node);\n                });\n        }\n\n        return this._placesPromise;\n    }\n}\n","import { noop } from 'lodash';\nimport React, { PureComponent, ReactNode } from 'react';\n\nimport { Autocomplete, AutocompleteItem } from '../../ui/autocomplete';\n\nimport { GoogleAutocompleteOptionTypes } from './googleAutocompleteTypes';\nimport './GoogleAutocomplete.scss';\nimport GoogleAutocompleteService from './GoogleAutocompleteService';\n\ninterface GoogleAutocompleteProps {\n    initialValue?: string;\n    componentRestrictions?: google.maps.places.ComponentRestrictions;\n    fields?: string[];\n    apiKey: string;\n    nextElement?: HTMLElement;\n    inputProps?: any;\n    isAutocompleteEnabled?: boolean;\n    types?: GoogleAutocompleteOptionTypes[];\n    onSelect?(place: google.maps.places.PlaceResult, item: AutocompleteItem): void;\n    onToggleOpen?(state: { inputValue: string; isOpen: boolean }): void;\n    onChange?(value: string, isOpen: boolean): void;\n}\n\ninterface GoogleAutocompleteState {\n    items: AutocompleteItem[];\n    autoComplete: string;\n}\n\nclass GoogleAutocomplete extends PureComponent<GoogleAutocompleteProps, GoogleAutocompleteState> {\n    googleAutocompleteService: GoogleAutocompleteService;\n\n    constructor(props: GoogleAutocompleteProps) {\n        super(props);\n        this.googleAutocompleteService = new GoogleAutocompleteService(props.apiKey);\n        this.state = {\n            items: [],\n            autoComplete: 'off',\n        };\n    }\n\n    render(): ReactNode {\n        const {\n            initialValue,\n            onToggleOpen = noop,\n            inputProps = {},\n        } = this.props;\n\n        const {\n            autoComplete,\n            items,\n        } = this.state;\n\n        return (\n            <Autocomplete\n                initialHighlightedIndex={ 0 }\n                initialValue={ initialValue }\n                inputProps={ {\n                    ...inputProps,\n                    autoComplete,\n                } }\n                items={ items }\n                listTestId=\"address-autocomplete-suggestions\"\n                onChange={ this.onChange }\n                onSelect={ this.onSelect }\n                onToggleOpen={ onToggleOpen }\n            >\n                <div className=\"co-googleAutocomplete-footer\" />\n            </Autocomplete>\n        );\n    }\n\n    private onSelect: (item: AutocompleteItem) => void = item => {\n        const {\n            fields,\n            onSelect = noop,\n            nextElement,\n        } = this.props;\n\n        this.googleAutocompleteService.getPlacesServices().then(service => {\n            service.getDetails({\n                placeId: item.id,\n                fields: fields || ['address_components', 'name'],\n            }, result => {\n                if (nextElement) {\n                    nextElement.focus();\n                }\n\n                onSelect(result, item);\n            });\n        });\n    };\n\n    private onChange: (input: string) => void = input => {\n        const {\n            isAutocompleteEnabled,\n            onChange = noop,\n        } = this.props;\n\n        onChange(input, false);\n\n        if (!isAutocompleteEnabled) {\n            return this.resetAutocomplete();\n        }\n\n        this.setAutocomplete(input);\n        this.setItems(input);\n    };\n\n    private setItems(input: string): void {\n        if (!input) {\n            this.setState({ items: [] });\n\n            return;\n        }\n\n        const {\n            componentRestrictions,\n            types,\n        } = this.props;\n\n        this.googleAutocompleteService.getAutocompleteService().then(service => {\n            service.getPlacePredictions({\n                input,\n                types: types || ['geocode'],\n                componentRestrictions,\n            }, results =>\n                this.setState({ items: this.toAutocompleteItems(results) })\n            );\n        });\n    }\n\n    private resetAutocomplete(): void {\n        this.setState({\n            items: [],\n            autoComplete: 'off',\n        });\n    }\n\n    private setAutocomplete(input: string): void {\n        this.setState({\n            ...this.state,\n            autoComplete: input && input.length ? 'nope' : 'off',\n        });\n    }\n\n    private toAutocompleteItems(results?: google.maps.places.AutocompletePrediction[]): AutocompleteItem[] {\n        return (results || []).map(result => ({\n            label: result.description,\n            value: result.structured_formatting.main_text,\n            highlightedSlices: result.matched_substrings,\n            id: result.place_id,\n        }));\n    }\n}\n\nexport default GoogleAutocomplete;\n","import { FormField as FormFieldType } from '@bigcommerce/checkout-sdk';\nimport { FieldProps } from 'formik';\nimport React, { memo, useCallback, useMemo, FunctionComponent } from 'react';\n\nimport { TranslatedString } from '../../locale';\nimport { AutocompleteItem } from '../../ui/autocomplete';\nimport { FormField } from '../../ui/form';\nimport { getAddressFormFieldInputId } from '../getAddressFormFieldInputId';\n\nimport GoogleAutocomplete from './GoogleAutocomplete';\n\nexport interface GoogleAutocompleteFormFieldProps {\n    apiKey: string;\n    field: FormFieldType;\n    countryCode?: string;\n    supportedCountries: string[];\n    nextElement?: HTMLElement;\n    parentFieldName?: string;\n    onSelect(place: google.maps.places.PlaceResult, item: AutocompleteItem): void;\n    onToggleOpen?(state: { inputValue: string; isOpen: boolean }): void;\n    onChange(value: string, isOpen: boolean): void;\n}\n\nconst GoogleAutocompleteFormField: FunctionComponent<GoogleAutocompleteFormFieldProps>  = ({\n    field: {\n        name,\n    },\n    countryCode,\n    supportedCountries,\n    parentFieldName,\n    nextElement,\n    apiKey,\n    onSelect,\n    onChange,\n    onToggleOpen,\n}) => {\n    const fieldName = parentFieldName ? `${parentFieldName}.${name}` : name;\n\n    const labelContent = useMemo(() => (\n        <TranslatedString id=\"address.address_line_1_label\" />\n    ), []);\n\n    const inputProps = useMemo(() => ({\n        className: 'form-input optimizedCheckout-form-input',\n        id: getAddressFormFieldInputId(name),\n    }), [name]);\n\n    const renderInput = useCallback(({ field }: FieldProps) => (\n        <GoogleAutocomplete\n            apiKey={ apiKey }\n            componentRestrictions={ countryCode ?\n                { country: countryCode } :\n                undefined }\n            initialValue={ field.value }\n            inputProps={ inputProps }\n            isAutocompleteEnabled={ countryCode ?\n                supportedCountries.indexOf(countryCode) > -1 :\n                false }\n            nextElement={ nextElement }\n            onChange={ onChange }\n            onSelect={ onSelect }\n            onToggleOpen={ onToggleOpen }\n        />\n    ), [\n        apiKey,\n        countryCode,\n        inputProps,\n        nextElement,\n        onChange,\n        onSelect,\n        onToggleOpen,\n        supportedCountries,\n    ]);\n\n    return (\n        <div className={ `dynamic-form-field dynamic-form-field--addressLineAutocomplete` }>\n            <FormField\n                input={ renderInput }\n                labelContent={ labelContent }\n                name={ fieldName }\n            />\n        </div>\n    );\n};\n\nexport default memo(GoogleAutocompleteFormField);\n","import { Address, Country, FormField } from '@bigcommerce/checkout-sdk';\nimport { memoize } from '@bigcommerce/memoize';\nimport { forIn, noop } from 'lodash';\nimport React, { createRef, Component, ReactNode, RefObject } from 'react';\n\nimport { withLanguage, TranslatedString, WithLanguageProps } from '../locale';\nimport { AutocompleteItem } from '../ui/autocomplete';\nimport { CheckboxFormField, DynamicFormField, DynamicFormFieldType, Fieldset } from '../ui/form';\n\nimport { AddressKeyMap } from './address';\nimport { getAddressFormFieldInputId, getAddressFormFieldLegacyName } from './getAddressFormFieldInputId';\nimport { mapToAddress, GoogleAutocompleteFormField } from './googleAutocomplete';\nimport './AddressForm.scss';\n\nexport interface AddressFormProps {\n    fieldName?: string;\n    countryCode?: string;\n    countriesWithAutocomplete?: string[];\n    countries?: Country[];\n    formFields: FormField[];\n    googleMapsApiKey?: string;\n    shouldShowSaveAddress?: boolean;\n    onAutocompleteSelect?(address: Partial<Address>): void;\n    onAutocompleteToggle?(state: { inputValue: string; isOpen: boolean }): void;\n    onChange?(fieldName: string, value: string | string[]): void;\n    setFieldValue?(fieldName: string, value: string | string[]): void;\n}\n\nconst LABEL: AddressKeyMap = {\n    address1: 'address.address_line_1_label',\n    address2: 'address.address_line_2_label',\n    city: 'address.city_label',\n    company: 'address.company_name_label',\n    countryCode: 'address.country_label',\n    firstName: 'address.first_name_label',\n    lastName: 'address.last_name_label',\n    phone: 'address.phone_number_label',\n    postalCode: 'address.postal_code_label',\n    stateOrProvince: 'address.state_label',\n    stateOrProvinceCode: 'address.state_label',\n};\n\nconst AUTOCOMPLETE: AddressKeyMap = {\n    address1: 'address-line1',\n    address2: 'address-line2',\n    city: 'address-level2',\n    company: 'organization',\n    countryCode: 'country',\n    firstName: 'given-name',\n    lastName: 'family-name',\n    phone: 'tel',\n    postalCode: 'postal-code',\n    stateOrProvince: 'address-level1',\n    stateOrProvinceCode: 'address-level1',\n};\n\nconst PLACEHOLDER: AddressKeyMap = {\n    countryCode: 'address.select_country_action',\n    stateOrProvince: 'address.select_state_action',\n    stateOrProvinceCode: 'address.select_state_action',\n};\n\nconst AUTOCOMPLETE_FIELD_NAME = 'address1';\n\nclass AddressForm extends Component<AddressFormProps & WithLanguageProps> {\n    private containerRef: RefObject<HTMLElement> = createRef();\n    private nextElement?: HTMLElement | null;\n\n    private handleDynamicFormFieldChange: (name: string) => (value: string | string[]) => void = memoize(name => value => {\n        this.syncNonFormikValue(name, value);\n    });\n\n    componentDidMount(): void {\n        const { current } = this.containerRef;\n\n        if (current) {\n            this.nextElement = current.querySelector<HTMLElement>('[autocomplete=\"address-line2\"]');\n        }\n    }\n\n    render(): ReactNode {\n        const {\n            formFields,\n            fieldName,\n            language,\n            countriesWithAutocomplete,\n            countryCode,\n            googleMapsApiKey,\n            onAutocompleteToggle,\n            shouldShowSaveAddress,\n        } = this.props;\n\n        return (<>\n            <Fieldset>\n                <div className=\"checkout-address\" ref={ this.containerRef as RefObject<HTMLDivElement> }>\n                    { formFields.map(field => {\n                        const addressFieldName = field.name;\n                        const translatedPlaceholderId = PLACEHOLDER[addressFieldName];\n\n                        if (addressFieldName === 'address1' && googleMapsApiKey && countriesWithAutocomplete) {\n                            return (\n                                <GoogleAutocompleteFormField\n                                    apiKey={ googleMapsApiKey }\n                                    countryCode={ countryCode }\n                                    field={ field }\n                                    key={ field.id }\n                                    nextElement={ this.nextElement || undefined }\n                                    onChange={ this.handleAutocompleteChange }\n                                    onSelect={ this.handleAutocompleteSelect }\n                                    onToggleOpen={ onAutocompleteToggle }\n                                    parentFieldName={ fieldName }\n                                    supportedCountries={ countriesWithAutocomplete }\n                                />\n                            );\n                        }\n\n                        return (\n                            <DynamicFormField\n                                autocomplete={ AUTOCOMPLETE[field.name] }\n                                extraClass={ `dynamic-form-field--${getAddressFormFieldLegacyName(addressFieldName)}` }\n                                field={ field }\n                                inputId={ getAddressFormFieldInputId(addressFieldName) }\n                                // stateOrProvince can sometimes be a dropdown or input, so relying on id is not sufficient\n                                key={ `${field.id}-${field.name}` }\n                                label={ field.custom ? field.label : <TranslatedString id={ LABEL[field.name] } /> }\n                                onChange={ this.handleDynamicFormFieldChange(addressFieldName) }\n                                parentFieldName={ field.custom ?\n                                    (fieldName ? `${fieldName}.customFields` : 'customFields') :\n                                    fieldName }\n                                placeholder={ translatedPlaceholderId && language.translate(translatedPlaceholderId) }\n                            />\n                        );\n                    }) }\n                </div>\n            </Fieldset>\n            { shouldShowSaveAddress &&\n                <CheckboxFormField\n                    labelContent={ <TranslatedString id=\"address.save_in_addressbook\" /> }\n                    name={ fieldName ? `${fieldName}.shouldSaveAddress` : 'shouldSaveAddress' }\n                /> }\n        </>);\n    }\n\n    private handleAutocompleteChange: (value: string, isOpen: boolean) => void = (value, isOpen) => {\n        if (!isOpen) {\n            this.syncNonFormikValue(AUTOCOMPLETE_FIELD_NAME, value);\n        }\n    };\n\n    private handleAutocompleteSelect: (\n        place: google.maps.places.PlaceResult,\n        item: AutocompleteItem\n    ) => void = (place, { value: autocompleteValue }) => {\n        const {\n            countries,\n            setFieldValue = noop,\n            onChange = noop,\n        } = this.props;\n\n        const address = mapToAddress(place, countries);\n\n        forIn(address, (value, fieldName) => {\n            setFieldValue(fieldName, value as string);\n            onChange(fieldName, value as string);\n        });\n\n        if (autocompleteValue) {\n            this.syncNonFormikValue(AUTOCOMPLETE_FIELD_NAME, autocompleteValue);\n        }\n    };\n\n    // because autocomplete state is controlled by Downshift, we need to manually keep formik\n    // value in sync when autocomplete value changes\n    private syncNonFormikValue: (\n        fieldName: string,\n        value: string | string[]\n    ) => void = (fieldName, value) => {\n        const {\n            formFields,\n            setFieldValue = noop,\n            onChange = noop,\n        } = this.props;\n\n        const dateFormFieldNames = formFields\n            .filter(field => field.custom && field.fieldType === DynamicFormFieldType.date)\n            .map(field => field.name);\n\n        if (fieldName === AUTOCOMPLETE_FIELD_NAME || dateFormFieldNames.indexOf(fieldName) > -1) {\n            setFieldValue(fieldName, value);\n        }\n\n        onChange(fieldName, value);\n    };\n}\n\nexport default withLanguage(AddressForm);\n","import { Address, Country, Region } from '@bigcommerce/checkout-sdk';\n\nimport AddressSelectorFactory from './AddressSelectorFactory';\n\nexport default function mapToAddress(\n    autocompleteData: google.maps.places.PlaceResult,\n    countries: Country[] = []\n): Partial<Address> {\n    if (!autocompleteData || !autocompleteData.address_components) {\n        return {};\n    }\n\n    const accessor = AddressSelectorFactory.create(autocompleteData);\n    const state = accessor.getState();\n    const countryCode = accessor.getCountry();\n    const country = countries && countries.find(c => countryCode === c.code);\n    const street2 = accessor.getStreet2();\n\n    return {\n        address2: street2,\n        city: accessor.getCity(),\n        countryCode,\n        postalCode: accessor.getPostCode(),\n        ...state ? getState(state, country && country.subdivisions) : {},\n    };\n}\n\nfunction getState(\n    stateName: string,\n    states: Region[] = []\n): Partial<Address> {\n    const state = states.find(({ code, name }: Region) =>\n        code === stateName || name === stateName\n    );\n\n    if (!state) {\n        return {\n            stateOrProvince: !states.length ? stateName : '',\n            stateOrProvinceCode: '',\n        };\n    }\n\n    return {\n        stateOrProvince: state.name,\n        stateOrProvinceCode: state.code,\n    };\n}\n","import { createInjectHoc, InjectHoc } from '../common/hoc';\n\nimport LocaleContext from './LocaleContext';\n\nexport interface WithDateProps {\n    date: {\n        inputFormat: string;\n    };\n}\n\nconst withDate: InjectHoc<WithDateProps> = createInjectHoc(LocaleContext, {\n    displayNamePrefix: 'withDate',\n    pickProps: (value, key) => key === 'date' && !!value,\n});\n\nexport default withDate;\n","import classNames from 'classnames';\nimport React, { forwardRef, ReactNode, Ref } from 'react';\n\nimport Input, { InputProps } from './Input';\nimport Label from './Label';\n\nexport interface RadioInputProps extends InputProps {\n    additionalClassName?: string;\n    label: ReactNode;\n    value: string;\n    checked: boolean;\n}\n\nconst RadioInput = forwardRef((\n    {\n        additionalClassName,\n        label,\n        value,\n        checked,\n        id,\n        ...rest\n    }: RadioInputProps,\n    ref: Ref<HTMLInputElement>\n) => (\n    <>\n        <Input\n            { ...rest }\n            checked={ checked }\n            className={ classNames(\n                'form-radio',\n                'optimizedCheckout-form-radio',\n                additionalClassName\n            ) }\n            id={ id }\n            ref={ ref }\n            type=\"radio\"\n            value={ value }\n        />\n        <Label htmlFor={ id }>\n            { label }\n        </Label>\n    </>\n));\n\nexport default RadioInput;\n","import { FormFieldItem } from '@bigcommerce/checkout-sdk';\nimport { isDate, noop } from 'lodash';\nimport React, { memo, useCallback, FunctionComponent } from 'react';\nimport ReactDatePicker from 'react-datepicker';\n\nimport { withDate, WithDateProps } from '../../locale';\n\nimport CheckboxInput from './CheckboxInput';\nimport DynamicFormFieldType from './DynamicFormFieldType';\nimport { InputProps } from './Input';\nimport RadioInput from './RadioInput';\nimport TextArea from './TextArea';\nimport TextInput from './TextInput';\n\nexport interface DynamicInputProps extends InputProps {\n    id: string;\n    additionalClassName?: string;\n    value?: string | string[];\n    rows?: number;\n    fieldType?: DynamicFormFieldType;\n    options?: FormFieldItem[];\n}\n\nconst DynamicInput: FunctionComponent<DynamicInputProps & WithDateProps> = ({\n    additionalClassName,\n    date,\n    fieldType,\n    id,\n    name,\n    onChange = noop,\n    options,\n    placeholder,\n    value,\n    ...rest\n}) => {\n    const { inputFormat } = date;\n    const handleDateChange = useCallback((dateValue, event) => onChange({\n        ...event,\n        target: {\n            name,\n            value: dateValue,\n        },\n    }), [\n        onChange,\n        name,\n    ]);\n\n    switch (fieldType) {\n    case DynamicFormFieldType.dropdown:\n        return (\n            <select\n                { ...rest as any }\n                className=\"form-select optimizedCheckout-form-select\"\n                data-test={ `${id}-select` }\n                id={ id }\n                name={ name }\n                onChange={ onChange }\n                value={ value === null ? '' : value }\n            >\n                { placeholder &&\n                    <option value=\"\">\n                        { placeholder }\n                    </option> }\n                { options && options.map(({ label, value: optionValue }) =>\n                    <option\n                        key={ optionValue }\n                        value={ optionValue }\n                    >\n                        { label }\n                    </option>\n                ) }\n            </select>\n        );\n\n    case DynamicFormFieldType.radio:\n        if (!options || !options.length) {\n            return null;\n        }\n\n        return <>\n            { options.map(({ label, value: optionValue }) =>\n                <RadioInput\n                    { ...rest }\n                    checked={ optionValue === value }\n                    id={ `${id}-${optionValue}` }\n                    key={ optionValue }\n                    label={ label }\n                    name={ name }\n                    onChange={ onChange }\n                    testId={ `${id}-${optionValue}-radio` }\n                    value={ optionValue }\n                />) }\n        </>;\n\n    case DynamicFormFieldType.checkbox:\n        if (!options || !options.length) {\n            return null;\n        }\n\n        return <>\n            { options.map(({ label, value: optionValue }) =>\n                <CheckboxInput\n                    { ...rest }\n                    checked={ Array.isArray(value) ? value.includes(optionValue) : false }\n                    id={ `${id}-${optionValue}` }\n                    key={ optionValue }\n                    label={ label }\n                    name={ name }\n                    onChange={ onChange }\n                    testId={ `${id}-${optionValue}-checkbox` }\n                    value={ optionValue }\n                />) }\n        </>;\n\n    case DynamicFormFieldType.date:\n        return (\n            <ReactDatePicker\n                { ...rest as any }\n                autoComplete=\"off\"\n                // FIXME: we can avoid this by simply using onChangeRaw, but it's not being triggered properly\n                // https://github.com/Hacker0x01/react-datepicker/issues/1357\n                // onChangeRaw={ rest.onChange }\n                calendarClassName=\"optimizedCheckout-contentPrimary\"\n                className=\"form-input optimizedCheckout-form-input\"\n                dateFormat={ inputFormat }\n                maxDate={ rest.max ? new Date(`${rest.max}T00:00:00Z`) : undefined }\n                minDate={ rest.min ? new Date(`${rest.min}T00:00:00Z`) : undefined }\n                name={ name }\n                onChange={ handleDateChange }\n                placeholderText={ inputFormat.toUpperCase() }\n                popperClassName=\"optimizedCheckout-contentPrimary\"\n                selected={ isDate(value) ? value : undefined }\n            />\n        );\n\n    case DynamicFormFieldType.multiline:\n        return (\n            <TextArea\n                { ...rest as any }\n                id={ id }\n                name={ name }\n                onChange={ onChange }\n                testId={ `${id}-text` }\n                type={ fieldType }\n                value={ value }\n            />\n        );\n\n    default:\n        return (\n            <TextInput\n                { ...rest }\n                id={ id }\n                name={ name }\n                onChange={ onChange }\n                testId={ `${id}-${ fieldType === DynamicFormFieldType.password ?\n                    'password' :\n                    'text' }` }\n                type={ fieldType }\n                value={ value }\n            />\n        );\n    }\n};\n\nexport default memo(withDate(DynamicInput));\n","import React, { memo, useCallback, FunctionComponent, MouseEvent } from 'react';\n\nimport { TranslatedString } from '../../locale';\n\nimport './MultiCheckboxControl.scss';\n\nexport interface MultiCheckboxControlProps {\n    testId?: string;\n    onSelectedAll(): void;\n    onSelectedNone(): void;\n}\n\nconst MultiCheckboxControl: FunctionComponent<MultiCheckboxControlProps> = ({\n    testId,\n    onSelectedAll,\n    onSelectedNone,\n}) => {\n    const handleSelectAllClick = useCallback((event: MouseEvent) => {\n        event.preventDefault();\n        onSelectedAll();\n    }, [onSelectedAll]);\n\n    const handleSelectNoneClick = useCallback((event: MouseEvent) => {\n        event.preventDefault();\n        onSelectedNone();\n    }, [onSelectedNone]);\n\n    return <ul className=\"multiCheckbox--controls\">\n        <li className=\"multiCheckbox--control\">\n            <TranslatedString id=\"address.select\" />\n        </li>\n\n        <li className=\"multiCheckbox--control\">\n            <a\n                data-test={ `${testId}Checkbox-all-button` }\n                href=\"#\"\n                onClick={ handleSelectAllClick }\n            >\n                <TranslatedString id=\"address.select_all\" />\n            </a>\n        </li>\n\n        <li className=\"multiCheckbox--control\">\n            <a\n                data-test={ `${testId}Checkbox-none-button` }\n                href=\"#\"\n                onClick={ handleSelectNoneClick }\n            >\n                <TranslatedString id=\"address.select_none\" />\n            </a>\n        </li>\n    </ul>;\n};\n\nexport default memo(MultiCheckboxControl);\n","import { FormFieldItem } from '@bigcommerce/checkout-sdk';\nimport { getIn, FieldArray, FieldArrayRenderProps } from 'formik';\nimport { difference, kebabCase, noop, pick } from 'lodash';\nimport React, { memo, useCallback, ChangeEvent, FunctionComponent, ReactNode } from 'react';\n\nimport DynamicFormFieldType from './DynamicFormFieldType';\nimport DynamicInput from './DynamicInput';\nimport FormFieldContainer from './FormFieldContainer';\nimport FormFieldError from './FormFieldError';\nimport MultiCheckboxControl from './MultiCheckboxControl';\n\nexport interface CheckboxGroupFormFieldProps {\n    id: string;\n    label: ReactNode;\n    name: string;\n    options: FormFieldItem[];\n    onChange?(values: string[]): void;\n}\n\ntype MultiCheckboxFormFieldProps = (\n    CheckboxGroupFormFieldProps &\n    Pick<FieldArrayRenderProps, 'push' | 'remove' | 'pop' | 'form'>\n);\n\nconst MultiCheckboxFormField: FunctionComponent<MultiCheckboxFormFieldProps> = ({\n    form: { values, errors },\n    id,\n    label,\n    name,\n    onChange = noop,\n    options,\n    push,\n    remove,\n}) => {\n    const handleSelectAll = useCallback(() => {\n        const checkedValues: string[] = getIn(values, name) || [];\n\n        difference(options.map(({ value }) => value), checkedValues)\n            .forEach(val => push(val));\n\n        onChange(getIn(values, name));\n    }, [\n        name,\n        onChange,\n        options,\n        push,\n        values,\n    ]);\n\n    const handleSelectNone = useCallback(() => {\n        const checkedValues: string[] = getIn(values, name) || [];\n\n        checkedValues.forEach(() => remove(0));\n\n        onChange(getIn(values, name));\n    }, [\n        name,\n        onChange,\n        remove,\n        values,\n    ]);\n\n    const handleInputChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {\n        const checkedValues: string[] = getIn(values, name) || [];\n        const { value, checked } = event.target;\n\n        if (checked) {\n            push(value);\n        } else {\n            remove(checkedValues.indexOf(value));\n        }\n\n        onChange(getIn(values, name));\n    }, [\n        name,\n        onChange,\n        push,\n        remove,\n        values,\n    ]);\n\n    return <FormFieldContainer hasError={ getIn(errors, name) && getIn(errors, name).length }>\n        { label }\n\n        { options.length > 1 && <MultiCheckboxControl\n            onSelectedAll={ handleSelectAll }\n            onSelectedNone={ handleSelectNone }\n            testId={ id }\n        /> }\n\n        <DynamicInput\n            fieldType={ DynamicFormFieldType.checkbox }\n            id={ id }\n            name={ name }\n            onChange={ handleInputChange }\n            options={ options }\n            value={ getIn(values, name) || [] }\n        />\n\n        <FormFieldError\n            name={ name }\n            testId={ `${kebabCase(name)}-field-error-message` }\n        />\n    </FormFieldContainer>;\n};\n\nconst CheckboxGroupFormField: FunctionComponent<CheckboxGroupFormFieldProps> = ({\n    id,\n    label,\n    name,\n    onChange,\n    options,\n}) => {\n    const renderField = useCallback((renderProps: FieldArrayRenderProps) => (\n        <MultiCheckboxFormField\n            id={ id }\n            label={ label }\n            name={ name }\n            onChange={ onChange }\n            options={ options }\n            { ...pick(renderProps, [\n                'form',\n                'pop',\n                'push',\n                'remove',\n            ]) }\n        />\n    ), [\n        id,\n        label,\n        name,\n        onChange,\n        options,\n    ]);\n\n    return <FieldArray\n        name={ name }\n        render={ renderField }\n    />;\n};\n\nexport default memo(CheckboxGroupFormField);\n","import { FormField as FormFieldType } from '@bigcommerce/checkout-sdk';\nimport { FieldProps } from 'formik';\nimport React, { memo, useCallback, useMemo, FunctionComponent, ReactNode } from 'react';\n\nimport { TranslatedString } from '../../locale';\n\nimport CheckboxGroupFormField from './CheckboxGroupFormField';\nimport DynamicFormFieldType from './DynamicFormFieldType';\nimport DynamicInput from './DynamicInput';\nimport FormField from './FormField';\nimport Label from './Label';\n\nexport interface DynamicFormFieldOption {\n    code: string;\n    name: string;\n}\n\nexport interface DynamicFormFieldProps {\n    field: FormFieldType;\n    inputId?: string;\n    extraClass?: string;\n    autocomplete?: string;\n    parentFieldName?: string;\n    placeholder?: string;\n    label?: ReactNode;\n    onChange?(value: string | string[]): void;\n}\n\nconst DynamicFormField: FunctionComponent<DynamicFormFieldProps>  = ({\n    field: {\n        fieldType,\n        type,\n        secret,\n        name,\n        label: fieldLabel,\n        required,\n        options,\n        max,\n        min,\n        maxLength,\n    },\n    parentFieldName,\n    onChange,\n    placeholder,\n    inputId,\n    autocomplete,\n    label,\n    extraClass,\n}) => {\n    const fieldInputId = inputId || name;\n    const fieldName = parentFieldName ? `${parentFieldName}.${name}` : name;\n\n    const labelComponent = useMemo(() => (\n        <Label htmlFor={ fieldInputId }>\n            { label || fieldLabel }\n            { !required &&\n                <>\n                    { ' ' }\n                    <small className=\"optimizedCheckout-contentSecondary\">\n                        <TranslatedString id=\"common.optional_text\" />\n                    </small>\n                </> }\n        </Label>\n    ), [\n        fieldInputId,\n        fieldLabel,\n        required,\n        label,\n    ]);\n\n    const dynamicFormFieldType = useMemo((): DynamicFormFieldType => {\n        if (fieldType === 'text') {\n            if (type === 'integer') {\n                return DynamicFormFieldType.number;\n            }\n\n            return secret ?\n                DynamicFormFieldType.password :\n                DynamicFormFieldType.text;\n        }\n\n        return fieldType as DynamicFormFieldType;\n    }, [fieldType, type, secret]);\n\n    const renderInput = useCallback(({ field }: FieldProps<string>) => (\n        <DynamicInput\n            { ...field }\n            autoComplete={ autocomplete }\n            fieldType={ dynamicFormFieldType }\n            id={ fieldInputId }\n            max={ max }\n            maxLength={ maxLength || undefined }\n            min={ min }\n            options={ options && options.items }\n            placeholder={ placeholder || (options && options.helperLabel) }\n            rows={ options && (options as any).rows }\n        />\n    ), [\n        fieldInputId,\n        max,\n        maxLength,\n        min,\n        options,\n        placeholder,\n        dynamicFormFieldType,\n        autocomplete,\n    ]);\n\n    return (\n        <div className={ `dynamic-form-field ${extraClass}` }>\n            { fieldType === DynamicFormFieldType.checkbox ?\n                <CheckboxGroupFormField\n                    id={ fieldInputId }\n                    label={ labelComponent }\n                    name={ fieldName }\n                    onChange={ onChange }\n                    options={ (options && options.items) || [] }\n                /> :\n                <FormField\n                    input={ renderInput }\n                    label={ labelComponent }\n                    name={ fieldName }\n                    onChange={ onChange }\n                /> }\n        </div>\n    );\n};\n\nexport default memo(DynamicFormField);\n","import { Address } from '@bigcommerce/checkout-sdk';\n\nimport { mapCustomFormFieldsFromFormValues } from '../formFields';\n\nimport { AddressFormValues } from './mapAddressToFormValues';\n\nexport default function mapAddressFromFormValues(formValues: AddressFormValues): Address {\n    const { customFields, ...address } = formValues;\n    const shouldSaveAddress = formValues.shouldSaveAddress;\n\n    return {\n        ...address,\n        shouldSaveAddress,\n        customFields: mapCustomFormFieldsFromFormValues(customFields),\n    };\n}\n","import { Address, CustomerAddress, FormField } from '@bigcommerce/checkout-sdk';\nimport { some } from 'lodash';\n\nimport isEqualAddress from './isEqualAddress';\nimport isValidAddress from './isValidAddress';\n\nexport default function isValidCustomerAddress(\n    address: Address | undefined,\n    addresses: CustomerAddress[],\n    formFields: FormField[]\n): boolean {\n    if (!address || !isValidAddress(address, formFields)) {\n        return false;\n    }\n\n    return some(addresses, customerAddress => isEqualAddress(customerAddress, address));\n}\n","import { FieldProps } from 'formik';\nimport React, { useCallback, useMemo, FunctionComponent } from 'react';\n\nimport { TranslatedString } from '../locale';\nimport { Fieldset, FormField, Label, Legend, TextInput } from '../ui/form';\n\nconst OrderComments: FunctionComponent = () => {\n    const renderLabel = useCallback(name => (\n        <Label hidden htmlFor={ name }>\n            <TranslatedString id=\"shipping.order_comment_label\" />\n        </Label>\n    ), []);\n\n    const renderInput = useCallback(({ field }: FieldProps) => (\n        <TextInput\n            { ...field }\n            autoComplete={ 'off' }\n            maxLength={ 2000 }\n        />\n    ), []);\n\n    const legend = useMemo(() => (\n        <Legend>\n            <TranslatedString id=\"shipping.order_comment_label\" />\n        </Legend>\n    ), []);\n\n    return <Fieldset legend={ legend } testId=\"checkout-shipping-comments\">\n        <FormField\n            input={ renderInput }\n            label={ renderLabel }\n            name=\"orderComment\"\n        />\n    </Fieldset>;\n};\n\nexport default OrderComments;\n","import { Checkout, CheckoutPayment } from '@bigcommerce/checkout-sdk';\n\nimport { isGiftCertificatePayment } from '../giftCertificate';\n\nimport { isStoreCreditPayment } from './storeCredit';\n\nexport default function getPreselectedPayment(checkout: Checkout): CheckoutPayment | undefined {\n    const payments = checkout && checkout.payments ? checkout.payments : [];\n\n    return payments.find(payment =>\n        !isGiftCertificatePayment(payment)\n        && !isStoreCreditPayment(payment)\n        && !!payment.providerId\n    );\n}\n","import { Placement } from 'popper.js';\nimport React, { Component, MouseEventHandler, ReactNode } from 'react';\nimport { Manager, Popper, Reference } from 'react-popper';\n\nexport interface DropdownTriggerProps {\n    placement?: Placement;\n    dropdown: ReactNode;\n}\n\nexport interface DropdownTriggerState {\n    shouldShow: boolean;\n}\n\nexport default class DropdownTrigger extends Component<DropdownTriggerProps, DropdownTriggerState> {\n    static defaultProps = {\n        placement: 'bottom-start',\n    };\n\n    state: Readonly<DropdownTriggerState> = {\n        shouldShow: false,\n    };\n\n    componentWillUnmount(): void {\n        document.removeEventListener('click', this.handleClose);\n    }\n\n    render() {\n        const { children, placement, dropdown } = this.props;\n        const { shouldShow } = this.state;\n\n        return (\n            <Manager>\n                <Reference>\n                    { ({ ref }) => (\n                        <div\n                            className=\"dropdownTrigger\"\n                            onClick={ this.handleClick }\n                            ref={ ref }\n                        >\n                            { children }\n                        </div>\n                    ) }\n                </Reference>\n\n                <Popper\n                    modifiers={ {\n                        hide: { enabled: false },\n                        flip: { enabled: false },\n                        preventOverflow: { enabled: false },\n                    } }\n                    placement={ placement }\n                >\n                    { ({ ref, style }) => !shouldShow ? null : (\n                        <div\n                            className=\"dropdownMenu\"\n                            ref={ ref }\n                            style={ {\n                                ...style,\n                                width: '100%',\n                                zIndex: 1,\n                            } }\n                        >\n                            { dropdown }\n                        </div>\n                    ) }\n                </Popper>\n            </Manager>\n        );\n    }\n\n    private handleClick: MouseEventHandler<HTMLElement> = event => {\n        const { shouldShow } = this.state;\n\n        if (shouldShow) {\n            this.handleClose(event.nativeEvent);\n        } else {\n            this.handleOpen(event.nativeEvent);\n        }\n    };\n\n    private handleOpen: (event: MouseEvent) => void = () => {\n        const { shouldShow } = this.state;\n\n        if (shouldShow) {\n            return;\n        }\n\n        this.setState({ shouldShow: true }, () => {\n            document.addEventListener('click', this.handleClose);\n        });\n    };\n\n    private handleClose: (event: MouseEvent) => void = () => {\n        const { shouldShow } = this.state;\n\n        if (!shouldShow) {\n            return;\n        }\n\n        this.setState({ shouldShow: false }, () => {\n            document.removeEventListener('click', this.handleClose);\n        });\n    };\n}\n","import { Address, CustomerAddress } from '@bigcommerce/checkout-sdk';\nimport React, { memo, FunctionComponent, PureComponent, ReactNode } from 'react';\n\nimport { preventDefault } from '../common/dom';\nimport { TranslatedString } from '../locale';\nimport { DropdownTrigger } from '../ui/dropdown';\n\nimport isEqualAddress from './isEqualAddress';\nimport './AddressSelect.scss';\nimport StaticAddress from './StaticAddress';\n\nexport interface AddressSelectProps {\n    addresses: CustomerAddress[];\n    selectedAddress?: Address;\n    onSelectAddress(address: Address): void;\n    onUseNewAddress(currentAddress?: Address): void;\n}\n\nclass AddressSelect extends PureComponent<AddressSelectProps> {\n    render(): ReactNode {\n        const {\n            addresses,\n            selectedAddress,\n        } = this.props;\n\n        return (\n            <div className=\"form-field\">\n                <div className=\"dropdown--select\" role=\"combobox\">\n                    <DropdownTrigger\n                        dropdown={\n                            <AddressSelectMenu\n                                addresses={ addresses }\n                                onSelectAddress={ this.handleSelectAddress }\n                                onUseNewAddress={ this.handleUseNewAddress }\n                                selectedAddress={ selectedAddress }\n                            />\n                        }\n                    >\n                        <AddressSelectButton\n                            addresses={ addresses }\n                            selectedAddress={ selectedAddress }\n                        />\n                    </DropdownTrigger>\n                </div>\n            </div>\n        );\n    }\n\n    private handleSelectAddress: (newAddress: Address) => void = (newAddress: Address) => {\n        const {\n            onSelectAddress,\n            selectedAddress,\n        } = this.props;\n\n        if (!isEqualAddress(selectedAddress, newAddress)) {\n            onSelectAddress(newAddress);\n        }\n    };\n\n    private handleUseNewAddress: () => void = () => {\n        const {\n            selectedAddress,\n            onUseNewAddress,\n        } = this.props;\n\n        onUseNewAddress(selectedAddress);\n    };\n}\n\nconst AddressSelectMenu: FunctionComponent<AddressSelectProps> = ({\n    addresses,\n    onSelectAddress,\n    onUseNewAddress,\n    selectedAddress,\n}) => (\n    <ul\n        className=\"dropdown-menu instrumentSelect-dropdownMenu\"\n        id=\"addressDropdown\"\n    >\n        <li className=\"dropdown-menu-item dropdown-menu-item--select\">\n            <a\n                data-test=\"add-new-address\"\n                href=\"#\"\n                onClick={ preventDefault(() => onUseNewAddress(selectedAddress)) }\n            >\n                <TranslatedString id=\"address.enter_address_action\" />\n            </a>\n        </li>\n        { addresses.map(address => (\n            <li\n                className=\"dropdown-menu-item dropdown-menu-item--select\"\n                key={ address.id }\n            >\n                <a href=\"#\" onClick={ preventDefault(() => onSelectAddress(address)) }>\n                    <StaticAddress address={ address } />\n                </a>\n            </li>\n        )) }\n    </ul>\n);\n\ntype AddressSelectButtonProps = Pick<AddressSelectProps, 'selectedAddress' | 'addresses'>;\n\nconst AddressSelectButton: FunctionComponent<AddressSelectButtonProps> = ({\n    selectedAddress,\n}) => (\n    <a\n        className=\"button dropdown-button dropdown-toggle--select\"\n        href=\"#\"\n        id=\"addressToggle\"\n        onClick={ preventDefault() }\n    >\n        { selectedAddress ?\n            <StaticAddress address={ selectedAddress } /> :\n            <TranslatedString id=\"address.enter_address_action\" /> }\n    </a>\n);\n\nexport default memo(AddressSelect);\n","import { Checkout } from '@bigcommerce/checkout-sdk';\n\nimport { getPreselectedPayment } from '../payment';\n\nexport default function getBillingMethodId(checkout: Checkout): string | undefined {\n    const BILLING_METHOD_IDS = ['amazonpay'];\n    const preselectedPayment = getPreselectedPayment(checkout);\n\n    return preselectedPayment && BILLING_METHOD_IDS.indexOf(preselectedPayment.providerId) > -1 ?\n        preselectedPayment.providerId :\n        undefined;\n}\n","import { Address, CheckoutSelectors, Country, Customer, FormField } from '@bigcommerce/checkout-sdk';\nimport { withFormik, FormikProps } from 'formik';\nimport React, { createRef, PureComponent, ReactNode, RefObject } from 'react';\nimport { lazy } from 'yup';\n\nimport { getAddressFormFieldsValidationSchema, getTranslateAddressError, isValidCustomerAddress, mapAddressToFormValues, AddressForm, AddressFormValues, AddressSelect } from '../address';\nimport { getCustomFormFieldsValidationSchema } from '../formFields';\nimport { withLanguage, TranslatedString, WithLanguageProps } from '../locale';\nimport { OrderComments } from '../orderComments';\nimport { Button, ButtonVariant } from '../ui/button';\nimport { Fieldset, Form } from '../ui/form';\nimport { LoadingOverlay } from '../ui/loading';\n\nimport StaticBillingAddress from './StaticBillingAddress';\n\nexport type BillingFormValues = AddressFormValues & { orderComment: string };\n\nexport interface BillingFormProps {\n    billingAddress?: Address;\n    countries: Country[];\n    countriesWithAutocomplete: string[];\n    customer: Customer;\n    customerMessage: string;\n    googleMapsApiKey: string;\n    isUpdating: boolean;\n    methodId?: string;\n    shouldShowOrderComments: boolean;\n    getFields(countryCode?: string): FormField[];\n    onSubmit(values: BillingFormValues): void;\n    onUnhandledError(error: Error): void;\n    updateAddress(address: Partial<Address>): Promise<CheckoutSelectors>;\n}\n\ninterface BillingFormState {\n    isResettingAddress: boolean;\n}\n\nclass BillingForm extends PureComponent<BillingFormProps & WithLanguageProps & FormikProps<BillingFormValues>, BillingFormState> {\n    state: BillingFormState = {\n        isResettingAddress: false,\n    };\n\n    private addressFormRef: RefObject<HTMLFieldSetElement> = createRef();\n\n    render(): ReactNode {\n        const {\n            googleMapsApiKey,\n            billingAddress,\n            countriesWithAutocomplete,\n            customer: { addresses, isGuest },\n            getFields,\n            countries,\n            isUpdating,\n            setFieldValue,\n            shouldShowOrderComments,\n            values,\n            methodId,\n        } = this.props;\n\n        const shouldRenderStaticAddress = methodId === 'amazonpay';\n        const allFormFields = getFields(values.countryCode);\n        const customFormFields = allFormFields.filter(({ custom }) => custom);\n        const hasCustomFormFields = customFormFields.length > 0;\n        const editableFormFields = shouldRenderStaticAddress && hasCustomFormFields ? customFormFields : allFormFields;\n        const { isResettingAddress } = this.state;\n        const hasAddresses = addresses && addresses.length > 0;\n        const hasValidCustomerAddress = billingAddress &&\n            isValidCustomerAddress(billingAddress, addresses, getFields(billingAddress.countryCode));\n\n        return (\n            <Form autoComplete=\"on\">\n                { shouldRenderStaticAddress && billingAddress &&\n                    <div className={ 'form-fieldset' }>\n                        <StaticBillingAddress address={ billingAddress } />\n                    </div> }\n\n                <Fieldset id=\"checkoutBillingAddress\" ref={ this.addressFormRef }>\n                    { hasAddresses && !shouldRenderStaticAddress &&\n                        <Fieldset id=\"billingAddresses\">\n                            <LoadingOverlay isLoading={ isResettingAddress }>\n                                <AddressSelect\n                                    addresses={ addresses }\n                                    onSelectAddress={ this.handleSelectAddress }\n                                    onUseNewAddress={ this.handleUseNewAddress }\n                                    selectedAddress={ hasValidCustomerAddress ? billingAddress : undefined }\n                                />\n                            </LoadingOverlay>\n                        </Fieldset> }\n\n                    { !hasValidCustomerAddress &&\n                        <LoadingOverlay isLoading={ isResettingAddress }>\n                            <AddressForm\n                                countries={ countries }\n                                countriesWithAutocomplete={ countriesWithAutocomplete }\n                                countryCode={ values.countryCode }\n                                formFields={ editableFormFields }\n                                googleMapsApiKey={ googleMapsApiKey }\n                                setFieldValue={ setFieldValue }\n                                shouldShowSaveAddress={ !isGuest }\n                            />\n                        </LoadingOverlay> }\n                </Fieldset>\n\n                { shouldShowOrderComments &&\n                    <OrderComments /> }\n\n                <div className=\"form-actions\">\n                    <Button\n                        disabled={ isUpdating || isResettingAddress }\n                        id=\"checkout-billing-continue\"\n                        isLoading={ isUpdating || isResettingAddress }\n                        type=\"submit\"\n                        variant={ ButtonVariant.Primary }\n                    >\n                        <TranslatedString id=\"common.continue_action\" />\n                    </Button>\n                </div>\n            </Form>\n        );\n    }\n\n    private handleSelectAddress: (address: Partial<Address>) => void = async address => {\n        const {\n            updateAddress,\n            onUnhandledError,\n        } = this.props;\n\n        this.setState({ isResettingAddress: true });\n\n        try {\n            await updateAddress(address);\n        } catch (e) {\n            onUnhandledError(e);\n        } finally {\n            this.setState({ isResettingAddress: false });\n        }\n    };\n\n    private handleUseNewAddress: () => void = () => {\n        this.handleSelectAddress({});\n    };\n}\n\nexport default withLanguage(withFormik<BillingFormProps & WithLanguageProps, BillingFormValues>({\n    handleSubmit: (values, { props: { onSubmit } }) => {\n        onSubmit(values);\n    },\n    mapPropsToValues: ({ getFields, customerMessage, billingAddress }) => (\n        {\n        ...mapAddressToFormValues(\n            getFields(billingAddress && billingAddress.countryCode),\n            billingAddress\n        ),\n        orderComment: customerMessage,\n    }),\n    isInitialValid: ({\n        billingAddress,\n        getFields,\n        language,\n    }) => (\n        !!billingAddress && getAddressFormFieldsValidationSchema({\n            language,\n            formFields: getFields(billingAddress.countryCode),\n        }).isValidSync(billingAddress)\n    ),\n    validationSchema: ({\n        language,\n        getFields,\n        methodId,\n    }: BillingFormProps & WithLanguageProps) => methodId === 'amazonpay' ?\n        (lazy<Partial<AddressFormValues>>(values => getCustomFormFieldsValidationSchema({\n            translate: getTranslateAddressError(language),\n            formFields: getFields(values && values.countryCode),\n        }))) :\n        (lazy<Partial<AddressFormValues>>(values => getAddressFormFieldsValidationSchema({\n            language,\n            formFields: getFields(values && values.countryCode),\n        }))),\n    enableReinitialize: true,\n})(BillingForm));\n","import { Address, CheckoutRequestBody, CheckoutSelectors, Country, Customer, FormField } from '@bigcommerce/checkout-sdk';\nimport { noop } from 'lodash';\nimport React, { Component, ReactNode } from 'react';\n\nimport { isEqualAddress, mapAddressFromFormValues } from '../address';\nimport { withCheckout, CheckoutContextProps } from '../checkout';\nimport { EMPTY_ARRAY } from '../common/utility';\nimport { TranslatedString } from '../locale';\nimport { getShippableItemsCount } from '../shipping';\nimport { Legend } from '../ui/form';\nimport { LoadingOverlay } from '../ui/loading';\n\nimport getBillingMethodId from './getBillingMethodId';\nimport BillingForm, { BillingFormValues } from './BillingForm';\n\nexport interface BillingProps {\n    navigateNextStep(): void;\n    onReady?(): void;\n    onUnhandledError(error: Error): void;\n}\n\nexport interface WithCheckoutBillingProps {\n    countries: Country[];\n    countriesWithAutocomplete: string[];\n    customer: Customer;\n    customerMessage: string;\n    googleMapsApiKey: string;\n    isInitializing: boolean;\n    isUpdating: boolean;\n    shouldShowOrderComments: boolean;\n    billingAddress?: Address;\n    methodId?: string;\n    getFields(countryCode?: string): FormField[];\n    initialize(): Promise<CheckoutSelectors>;\n    updateAddress(address: Partial<Address>): Promise<CheckoutSelectors>;\n    updateCheckout(payload: CheckoutRequestBody): Promise<CheckoutSelectors>;\n}\n\nclass Billing extends Component<BillingProps & WithCheckoutBillingProps> {\n    async componentDidMount(): Promise<void> {\n        const {\n            initialize,\n            onReady = noop,\n            onUnhandledError,\n        } = this.props;\n\n        try {\n            await initialize();\n            onReady();\n        } catch (e) {\n            onUnhandledError(e);\n        }\n    }\n\n    render(): ReactNode {\n        const {\n            updateAddress,\n            isInitializing,\n            ...props\n        } = this.props;\n\n        return (\n            <div className=\"checkout-form\">\n                <div className=\"form-legend-container\">\n                    <Legend testId=\"billing-address-heading\">\n                        <TranslatedString id=\"billing.billing_address_heading\" />\n                    </Legend>\n                </div>\n\n                <LoadingOverlay\n                    isLoading={ isInitializing }\n                    unmountContentWhenLoading\n                >\n                    <BillingForm\n                        { ...props }\n                        onSubmit={ this.handleSubmit }\n                        updateAddress={ updateAddress }\n                    />\n                </LoadingOverlay>\n            </div>\n        );\n    }\n\n    private handleSubmit: (values: BillingFormValues) => void = async ({\n        orderComment,\n        ...addressValues\n    }) => {\n        const {\n            updateAddress,\n            updateCheckout,\n            customerMessage,\n            billingAddress,\n            navigateNextStep,\n            onUnhandledError,\n        } = this.props;\n\n        const promises: Array<Promise<CheckoutSelectors>> = [];\n        const address = mapAddressFromFormValues(addressValues);\n\n        if (address && !isEqualAddress(address, billingAddress)) {\n            promises.push(updateAddress(address));\n        }\n\n        if (customerMessage !== orderComment) {\n            promises.push(updateCheckout({ customerMessage: orderComment }));\n        }\n\n        try {\n            await Promise.all(promises);\n\n            navigateNextStep();\n        } catch (error) {\n            onUnhandledError(error);\n        }\n    };\n}\n\nfunction mapToBillingProps({\n    checkoutService,\n    checkoutState,\n}: CheckoutContextProps): WithCheckoutBillingProps | null {\n    const {\n        data: {\n            getCheckout,\n            getConfig,\n            getCart,\n            getCustomer,\n            getBillingAddress,\n            getBillingAddressFields,\n            getBillingCountries,\n        },\n        statuses: {\n            isLoadingBillingCountries,\n            isUpdatingBillingAddress,\n            isUpdatingCheckout,\n        },\n    } = checkoutState;\n\n    const config = getConfig();\n    const customer = getCustomer();\n    const checkout = getCheckout();\n    const cart = getCart();\n\n    if (!config || !customer || !checkout || !cart) {\n        return null;\n    }\n\n    const {\n        enableOrderComments,\n        googleMapsApiKey,\n        features,\n    } = config.checkoutSettings;\n\n    const countriesWithAutocomplete = ['US', 'CA', 'AU', 'NZ'];\n\n    if (features['CHECKOUT-4183.checkout_google_address_autocomplete_uk']) {\n        countriesWithAutocomplete.push('GB');\n    }\n\n    return {\n        billingAddress: getBillingAddress(),\n        countries: getBillingCountries() || EMPTY_ARRAY,\n        countriesWithAutocomplete,\n        customer,\n        customerMessage: checkout.customerMessage,\n        getFields: getBillingAddressFields,\n        googleMapsApiKey,\n        initialize: checkoutService.loadBillingAddressFields,\n        isInitializing: isLoadingBillingCountries(),\n        isUpdating: isUpdatingBillingAddress() || isUpdatingCheckout(),\n        methodId: getBillingMethodId(checkout),\n        shouldShowOrderComments: enableOrderComments && getShippableItemsCount(cart) < 1,\n        updateAddress: checkoutService.updateBillingAddress,\n        updateCheckout: checkoutService.updateCheckout,\n    };\n}\n\nexport default withCheckout(mapToBillingProps)(Billing);\n"],"sourceRoot":""}