(function(FS) {
  var session = FS.getCurrentSession(), sessionUrl = FS.getCurrentSessionURL();
  function retryWithBackoff(condition, callback, maxWait, failureMsg, timeoutCallback) {
    var totalTimeExpired = 0;
    var wait = 64;
    var resultFn = function() {
      if (condition()) {
        callback();
        return;
      }
      wait = Math.min(wait * 2, 1024);
      if (totalTimeExpired > maxWait) {
        FS.log('warn', failureMsg);
        !!timeoutCallback && timeoutCallback(failureMsg);
        return;
      }
      totalTimeExpired += wait
      setTimeout(resultFn, wait);
    };
    return resultFn;
  }
  function loadSession(key) {
	var lastSession = window['localStorage'].getItem(key);
    if (!lastSession) {
      lastSession = FS._cookies()[key];
    }
    return lastSession
  }
  function saveSession(key, session) {
    window['localStorage'].setItem(key, session);
  }

	window['_dlo_appender'] = 'fullstory';
	window['_dlo_telemetryExporter'] = (function() {
		var fsNs = (document.currentScript && document.currentScript.getAttribute('data-fs-namespace')) || window['_fs_namespace'] || 'FS';
		const eventNameMap = {
			dlo_init_span: 'INIT_DURATION',
			dlo_rule_registration_span: 'RULE_REGISTRATION_DURATION',
			dlo_handle_event_span: 'HANDLE_EVENT_DURATION',
			dlo_client_error: 'CLIENT_ERROR_COUNT',
		};

		function sendEvent(evt, value) {
			const metricName = eventNameMap[evt.name];
			if (!metricName) {
				return;
			}
			var fs = window[fsNs];
			if (typeof fs !== 'function') {
				return;
			}
			var cfg = fs('getConfig');
			var orgId = (cfg && cfg.env && cfg.env.orgId) || window['_fs_org'];
			const eventStatus = evt.name === 'dlo_client_error' ? 'FAILURE' : 'SUCCESS';
			const metadata = evt.attributes || {};
			metadata.name = metricName;
			metadata.value = value;
			fs('stat', {
				eventType: 'INTEGRATION_METRIC',
				payload: {
					provider_id: 'dlo',
					org_id: orgId,
					event_status: eventStatus,
					metadata: metadata,
				},
			});
		}

		return {
			sendSpan: function(spanEvent) {
				sendEvent(spanEvent, spanEvent.duration.toString());
			},
			sendCount: function(countEvent) {
				sendEvent(countEvent, countEvent.value.toString());
			},
		};
	}());
	window['_dlo_logLevel'] = 0;
	window['_dlo_beforeDestination'] = Array.isArray(window['_dlo_beforeDestination']) ? window['_dlo_beforeDestination'] : [{ name: 'convert', enumerate: true, preserveArray: true, index: -1 },{ name: 'suffix' },{ name: 'insert', value: 'dlo', position: -1 }];
	window['_dlo_previewMode'] = false;
	window['_dlo_readOnLoad'] = true;
	window['_dlo_validateRules'] = false;
	window['_dlo_enable_restart'] = false;

	window['_dlo_rules_adobe_am'] = [];
	window['_dlo_rules_ceddl'] = [];
	window['_dlo_rules_google_ec'] = [];
	window['_dlo_rules_google_ec_ga4'] = [];
	window['_dlo_rules_google_em'] = [];
	window['_dlo_rules_google_em_ga4'] = [];
	window['_dlo_rules_tealium_retail'] = [];
	try {
		window['_dlo_rules_custom'] = [
{
  "source": "adobeDataLayer",
 "id": "identify",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[?(event=dataLayerLoaded)]"
    },
    {
      "name": "query",
      "select": "$.data"
    },
    {
      "name": "query",
      "select": "$[(altCustId)]"
    },
    {
      "name": "insert",
      "select": "altCustId"
    }
  ],
  "fsApi": "setIdentity"
},
{
  "source": "adobeDataLayer",
  "id": "pageProperties",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[?(event=dataLayerLoaded)]"
    },
    {
      "name": "query",
      "select": "$.data"
    },
    {
      "name": "query",
      "select": "$[(browser_akamai_loc_country,env_platform,env_server_id,env_site_id,mr_prof_authentication_state,mr_prof_points_balance,mr_prof_rewards_level,page_data_layer_ready,res_num_adults,sessionId,brwsrLang,isRewardRedemption,numRooms,res_num_children,res_room_nights_total,res_stay_length,search_advance_purchase_days,search_date_check_in,search_date_check_out,search_date_type,search_destination_city_state_country,search_destination_country,search_destination_type,search_fusionsearchid,search_keyword,search_list_records_total,search_results_view,search_sort_id,sessionId,search_cluster_code,res_booking_room_Count,search_list_setting_sort_order,prop_brand_code,prop_brand_name,prop_brand_tier,prop_is_ers,prop_marsha_code,res_rate_is_member_rate,res_rate_program,res_room_pool_code,res_rooms_per_night,mr_prof_stay_in_progress,mr_prof_upcoming_stay,prop_address_city,prop_address_city_state_country,prop_brand_code,prop_currency_type,res_confirmation_number,crsSystem, loginEventDetails)]"
    },
   {
      "name": "convert",
      "properties": "mr_prof_points_balance, mr_prof_rewards_level, res_num_adults, numRooms, res_num_children, res_room_nights_total, res_stay_length, search_advance_purchase_days, search_list_records_total, res_booking_room_Count, res_rooms_per_night",
    "type": "real"
   },
 {
      "name": "convert",
      "properties": "page_data_layer_ready",
    "type": "bool"
   },
{
      "name": "convert",
      "properties": "search_date_check_in,search_date_check_out",
    "type": "date"
   }
  ],
  "fsApi": "setPageProperties"
},
{
  "id": "cartId",
  "source": "dataLayer",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$.cart[0]"
    }
  ],
  "fsApi": "setPageProperties"
},
{
  "source": "adobeDataLayer",
  "id": "userProperties",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[?(event=dataLayerLoaded)]"
    },
    {
      "name": "query",
      "select": "$.data"
    },
    {
      "name": "query",
      "select": "$[(cookie_mi_visitor,mr_id,mr_id_alternate,mr_prof_address_city,mr_prof_address_country,mr_prof_address_country_abbr,mr_prof_address_state,mr_prof_rewards_level,mr_prof_cc_all)]"
    }
  ],
  "fsApi": "setUserProperties"
},
{
  "source": "dataLayer",
  "id": "userProperties-dataLayer",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[(cookie_mi_visitor,mr_id,mr_id_alternate,mr_prof_address_city,mr_prof_address_country,mr_prof_address_country_abbr,mr_prof_address_state,mr_prof_rewards_level,mr_prof_cc_all)]"
    }
  ],
  "fsApi": "setUserProperties"
},
{
  "id": "addToCart",
  "source": "dataLayer",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[(products)]"
    },
    {
      "name": "fan-out"
    },
    {
      "name": "insert",
      "value": "Add to Cart"
    }
  ],
  "fsApi": "trackEvent"
},
{
  "source": "dataLayer",
 "id": "identify-dataLayer",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[(altCustId)]"
    },
    {
      "name": "insert",
      "select": "altCustId"
    }
  ],
  "fsApi": "setIdentity"
},
{
  "source": "dataLayer",
  "id": "pageProperties-dataLayer",
"version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[(browser_akamai_loc_country,env_platform,env_server_id,env_site_id,mr_prof_authentication_state,mr_prof_points_balance,mr_prof_rewards_level,page_data_layer_ready,res_num_adults,sessionId,brwsrLang,isRewardRedemption,numRooms,res_num_children,res_room_nights_total,res_stay_length,search_advance_purchase_days,search_date_check_in,search_date_check_out,search_date_type,search_destination_city_state_country,search_destination_country,search_destination_type,search_fusionsearchid,search_keyword,search_list_records_total,search_results_view,search_sort_id,sessionId,search_cluster_code,res_booking_room_Count,search_list_setting_sort_order,prop_brand_code,prop_brand_name,prop_brand_tier,prop_is_ers,prop_marsha_code,res_rate_is_member_rate,res_rate_program,res_room_pool_code,res_rooms_per_night,mr_prof_stay_in_progress,mr_prof_upcoming_stay,prop_address_city,prop_address_city_state_country,prop_brand_code,prop_currency_type,res_confirmation_number,crsSystem,loginEventDetails,page_experience)]"
    },
 {
      "name": "convert",
      "properties": "mr_prof_points_balance, mr_prof_rewards_level, res_num_adults, numRooms, res_num_children, res_room_nights_total, res_stay_length, search_advance_purchase_days, search_list_records_total, res_booking_room_Count, res_rooms_per_night",
    "type": "real"
   },
{
      "name": "convert",
      "properties": "page_data_layer_ready",
    "type": "bool"
   },
{
      "name": "convert",
      "properties": "search_date_check_in,search_date_check_out",
    "type": "date"
   }
  ],
  "fsApi": "setPageProperties"
},
{
  "id": "cookieUserProperties",
  "cookieSource": ["OptanonConsent", "MI_Visitor", "mbox", "at_check", "demdex", "__dTCookie"],
"version": 2,
  "fsApi": "setUserProperties"
},
{
  "id": "cookiePageProperties",
  "cookieSource": ["PolarisHP" ],
"version": 2,
  "fsApi": "setPageProperties"
},
{
  "id": "ttMeta",
  "source": "ttMeta",
"version": 2,
  "operators": [
    {
      "name": "insert",
      "value": "ttMeta"
    }
  ],
  "fsApi": "trackEvent"
},
{
  "id": "m_int_sgnl",
  "source": "m_int_sgnl",
"version": 2,
  "fsApi": "setPageProperties"
},
{
  "id": "login-event",
  "source": "adobeDataLayer",
  "version": 2,
  "operators": [
    {
      "name": "query",
      "select": "$[?(event=LOGIN)]"
    },
    {
      "name": "insert",
      "value": "Login"
    }
  ],
  "fsApi": "trackEvent"
}
];
	} catch (err) {
		console.error('FullStory custom rules error; review DLO integration\'s custom rules.');
	}
	
	var dloScriptTag = document.createElement('script');
	dloScriptTag.type = 'text/javascript';
	dloScriptTag.async = true;
	var fsNs = (document.currentScript && document.currentScript.getAttribute('data-fs-namespace')) || window['_fs_namespace'] || 'FS';
	dloScriptTag.setAttribute('data-fs-namespace', fsNs);
	var fs = window[fsNs];
	var cfg = (typeof fs === 'function') ? fs('getConfig') : null;
	var recSettingsHost = (cfg && cfg.env && cfg.env.recSettingsHost) || window['_fs_rec_settings_host'];
	var host = (typeof recSettingsHost === 'string' && recSettingsHost) ? recSettingsHost : 'edge.fullstory.com';
	dloScriptTag.src = 'https://' + host + '/datalayer/v4/latest.js';
	var firstScriptTag = document.getElementsByTagName('script')[0];
	firstScriptTag.parentNode.insertBefore(dloScriptTag,firstScriptTag);
	
})(window[document.currentScript&&document.currentScript.getAttribute('data-fs-namespace')||window['_fs_namespace']||'FS'])