define([
    'jquery',
    'mage/utils/wrapper',
    'Magento_Checkout/js/model/quote'
], function ($, wrapper, quote) {
    'use strict';

    return function (setShippingInformationAction) {
        return wrapper.wrap(setShippingInformationAction, function (originalAction) {
            var shippingAddress = quote.shippingAddress();

            if(shippingAddress && typeof shippingAddress['steet'] == 'object' && shippingAddress['street'].length > 2)
            {
            	//check if already combined
            	if(!shippingAddress['street'][0].trim().endsWith(shippingAddress['street'][2].trim()))
            	{
            		//combine street and "housenumber"
            		shippingAddress['street'][0] = shippingAddress['street'][0].trim() + ' ' + shippingAddress['street'][2].trim();
            	}
	            shippingAddress['street'].splice(2, 1);
            }
            
            // pass execution to original action ('Magento_Checkout/js/action/set-shipping-information')
            return originalAction();
        });
    };
});
