UNPKG

@codegouvfr/react-dsfr

Version:

French State Design System React integration library

1,566 lines (1,276 loc) 194 kB
/*! DSFR v1.13.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */ (function () { 'use strict'; var config = { prefix: 'fr', namespace: 'dsfr', organisation: '@gouvfr', version: '1.13.2' }; var api = window[config.namespace]; var patch = { namespace: 'a4e35ba2a938ba9d007689dbf3f46acbb9807869' }; var Collection = { MANUAL: 'manual', LOAD: 'load', FULL: 'full', HASH: 'hash' }; var key = '_EA_'; var DISABLED = key + "disabled"; var TOGGLE = key + "toggle"; var Opt = function Opt () { this._configure(); }; var prototypeAccessors$e = { isDisabled: { configurable: true } }; Opt.prototype._configure = function _configure () { var scope = this; window[DISABLED] = function () { return scope.isDisabled; }; window[TOGGLE] = this.toggle.bind(this); }; prototypeAccessors$e.isDisabled.get = function () { return localStorage.getItem(key); }; Opt.prototype.toggle = function toggle () { if (this.isDisabled) { this.enable(); } else { this.disable(); } }; Opt.prototype.enable = function enable () { if (localStorage.getItem(key)) { localStorage.removeItem(key); } }; Opt.prototype.disable = function disable () { localStorage.setItem(key, '1'); }; Object.defineProperties( Opt.prototype, prototypeAccessors$e ); var opt = new Opt(); var PUSH = 'EA_push'; var Init = function Init (domain) { var this$1$1 = this; this._domain = domain; this._isLoaded = false; this._promise = new Promise(function (resolve, reject) { this$1$1._resolve = resolve; this$1$1._reject = reject; }); }; var prototypeAccessors$d = { id: { configurable: true },store: { configurable: true } }; prototypeAccessors$d.id.get = function () { return this._id; }; prototypeAccessors$d.store.get = function () { return this._store; }; Init.prototype.configure = function configure () { this.init(); return this._promise; }; Init.prototype.init = function init () { var this$1$1 = this; var bit = 5381; for (var i = this._domain.length - 1; i > 0; i--) { bit = (bit * 33) ^ this._domain.charCodeAt(i); } bit >>>= 0; this._id = "_EA_" + bit; this._store = []; this._store.eah = this._domain; window[this._id] = this._store; if (!window[PUSH]) { window[PUSH] = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; return this$1$1.store.push(args); }; } if (opt.isDisabled) { api.inspector.warn('User opted out, eulerian is disabled'); this._reject('User opted out, eulerian is disabled'); } else { this.load(); } }; Init.prototype.load = function load () { var stamp = new Date() / 1E7 | 0; var offset = stamp % 26; var key = String.fromCharCode(97 + offset, 122 - offset, 65 + offset) + (stamp % 1E3); this._script = document.createElement('script'); this._script.ea = this.id; this._script.async = true; this._script.addEventListener('load', this.loaded.bind(this)); this._script.addEventListener('error', this.error.bind(this)); this._script.src = "//" + (this._domain) + "/" + key + ".js?2"; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(this._script, node); }; Init.prototype.error = function error () { api.inspector.error('unable to load Eulerian script file. the domain declared in your configuration must match the domain provided by the Eulerian interface (tag creation)'); this._reject('eulerian script loading error'); }; Init.prototype.loaded = function loaded () { if (this._isLoaded) { return; } this._isLoaded = true; this._resolve(); }; Object.defineProperties( Init.prototype, prototypeAccessors$d ); /* (function(e, a) { var i = e.length, y = 5381, k = 'script', s = window, v = document, o = v.createElement(k); for (; i;) { i -= 1; y = (y * 33) ^ e.charCodeAt(i) } y = '_EA_' + (y >>>= 0); (function(e, a, s, y) { s[a] = s[a] || function() { (s[y] = s[y] || []).push(arguments); s[y].eah = e; }; }(e, a, s, y)); i = new Date / 1E7 | 0; o.ea = y; y = i % 26; o.async = 1; o.src = '//' + e + '/' + String.fromCharCode(97 + y, 122 - y, 65 + y) + (i % 1E3) + '.js?2'; s = v.getElementsByTagName(k)[0]; s.parentNode.insertBefore(o, s); }) ('mon.domainedetracking.com', 'EA_push'); */ /* (function(e, a) { var i = e.length, y = 5381, k = 'script', z = '_EA_', zd = z + 'disabled', s = window, v = document, o = v.createElement(k), l = s.localStorage; for (; i;) { i -= 1; y = (y * 33) ^ e.charCodeAt(i) } y = z + (y >>>= 0); (function(e, a, s, y, z, zd, l) { s[a] = s[a] || function() { (s[y] = s[y] || []).push(arguments); s[y].eah = e; }; s[zd] = function() { return l.getItem(z); }; s[z + 'toggle'] = function() { (s[zd]()) ? l.removeItem(z): l.setItem(z, 1); } }(e, a, s, y, z, zd, l)); if (!s[zd]()) { i = new Date / 1E7 | 0; o.ea = y; y = i % 26; o.async = 1; o.src = '//' + e + '/' + String.fromCharCode(97 + y, 122 - y, 65 + y) + (i % 1E3) + '.js?2'; s = v.getElementsByTagName(k)[0]; s.parentNode.insertBefore(o, s); } })('mon.domainedetracking.com', 'EA_push'); */ var State = { UNKNOWN: -1, CONFIGURING: 0, CONFIGURED: 1, INITIATED: 2, READY: 3 }; var TarteAuCitronIntegration = function TarteAuCitronIntegration (config) { var this$1$1 = this; this._config = config; this._state = State.UNKNOWN; this._promise = new Promise(function (resolve, reject) { this$1$1._resolve = resolve; this$1$1._reject = reject; }); }; TarteAuCitronIntegration.prototype.configure = function configure () { if (this._state >= State.CONFIGURED) { return this._promise; } if (this._state === State.UNKNOWN) { api.inspector.info('analytics configures tarteaucitron'); this._state = State.CONFIGURING; } var tarteaucitron = window.tarteaucitron; if (!tarteaucitron || !tarteaucitron.services) { window.requestAnimationFrame(this.configure.bind(this)); return; } this._state = State.CONFIGURED; var init = this.init.bind(this); var data = { key: 'eulerian', type: 'analytic', name: 'Eulerian Analytics', needConsent: true, cookies: ['etuix'], uri: 'https://eulerian.com/vie-privee', js: init, fallback: function () { tarteaucitron.services.eulerian.js(); } }; tarteaucitron.services.eulerian = data; if (!tarteaucitron.job) { tarteaucitron.job = []; } tarteaucitron.job.push('eulerian'); return this._promise; }; TarteAuCitronIntegration.prototype.init = function init () { if (this._state >= State.INITIATED) { return; } this._state = State.INITIATED; window.__eaGenericCmpApi = this.integrate.bind(this); var update = this.update.bind(this); window.addEventListener('tac.close_alert', update); window.addEventListener('tac.close_panel', update); }; TarteAuCitronIntegration.prototype.integrate = function integrate (cmpApi) { if (this._state >= State.READY) { return; } this._state = State.READY; this._cmpApi = cmpApi; api.inspector.info('analytics has integrated tarteaucitron'); this._resolve(); this.update(); }; TarteAuCitronIntegration.prototype.update = function update () { if (this._state < State.READY) { return; } this._cmpApi('tac', window.tarteaucitron, 1); }; var ConsentManagerPlatform = function ConsentManagerPlatform (config) { this._config = config; if (config) { switch (config.id) { case 'tarteaucitron': this.integrateTarteAuCitron(); break; } } }; ConsentManagerPlatform.prototype.integrateTarteAuCitron = function integrateTarteAuCitron () { this._tac = new TarteAuCitronIntegration(this._config); return this._tac.configure(); }; ConsentManagerPlatform.prototype.optin = function optin () { }; var push = function (type, layer) { if (typeof window.EA_push !== 'function') { api.inspector.warn('Analytics datalayer not sent, Eulerian API isn\'t yet avalaible'); return; } api.inspector.info('analytics', type, layer); window.EA_push(type, layer); }; var PushType = { COLLECTOR: 'collector', ACTION: 'action', ACTION_PARAMETER: 'actionparam' }; var Renderer = function Renderer () { this._renderables = []; this._rendering = this.render.bind(this); requestAnimationFrame(this._rendering); }; Renderer.prototype.add = function add (renderable) { var index = this._renderables.indexOf(renderable); if (index === -1) { this._renderables.push(renderable); } }; Renderer.prototype.remove = function remove (renderable) { var index = this._renderables.indexOf(renderable); if (index > -1) { this._renderables.splice(index, 1); } }; Renderer.prototype.render = function render () { this._renderables.forEach(function (renderable) { return renderable.render(); }); requestAnimationFrame(this._rendering); }; var renderer = new Renderer(); var ActionRegulation = { ENFORCE: 'enforce', PREVENT: 'prevent', NONE: 'none' }; var SLICE = 80; var Queue = function Queue () { this._startingActions = []; this._endingActions = []; this._handlingVisibilityChange = this._handleVisibilityChange.bind(this); this._handlingEnd = this._handleEnd.bind(this); this._isStarted = false; this._isListening = false; this.reset(); }; Queue.prototype.setCollector = function setCollector (collector) { this._collector = collector; }; Queue.prototype.reset = function reset (ending) { if ( ending === void 0 ) ending = false; this._type = PushType.ACTION; if (!ending) { this._startingActions.length = 0; } this._endingActions.length = 0; this._count = 0; this._delay = -1; this._isRequested = false; this._unlisten(); }; Queue.prototype.start = function start () { if (this._isStarted) { return; } this._isStarted = true; renderer.add(this); }; Queue.prototype.collect = function collect () { this._type = PushType.COLLECTOR; this._request(); }; Queue.prototype.regulate = function regulate (action, queue) { if (!action) { return false; } if (queue.some(function (queued) { return queued.test(action); })) { api.inspector.log('action exists in queue', action); return false; } switch (action.regulation) { case ActionRegulation.PREVENT: return false; case ActionRegulation.ENFORCE: return true; default: return this._collector.isActionEnabled === true; } }; Queue.prototype.appendStartingAction = function appendStartingAction (action, data) { if (!this.regulate(action, this._startingActions)) { return; } var queued = new QueuedAction(action, data); this._startingActions.push(queued); this._request(); }; Queue.prototype.appendEndingAction = function appendEndingAction (action, data) { if (!this.regulate(action, this._endingActions)) { return; } var queued = new QueuedAction(action, data); this._endingActions.push(queued); this._request(); }; Queue.prototype._request = function _request () { this._listen(); this._isRequested = true; this._delay = 4; }; Queue.prototype._listen = function _listen () { if (this._isListening) { return; } this._isListening = true; document.addEventListener('visibilitychange', this._handlingVisibilityChange); document.addEventListener('unload', this._handlingEnd); document.addEventListener('beforeunload', this._handlingEnd); document.addEventListener('pagehide', this._handlingEnd); }; Queue.prototype._unlisten = function _unlisten () { if (!this._isListening) { return; } this._isListening = false; document.removeEventListener('visibilitychange', this._handlingVisibilityChange); document.removeEventListener('unload', this._handlingEnd); document.removeEventListener('beforeunload', this._handlingEnd); document.removeEventListener('pagehide', this._handlingEnd); }; Queue.prototype._handleVisibilityChange = function _handleVisibilityChange (e) { if (document.visibilityState === 'hidden') { this.send(); } }; Queue.prototype._handleEnd = function _handleEnd () { this.send(); }; Queue.prototype.render = function render () { if (this._delay <= -1) { return; } this._delay--; this._count++; switch (true) { case this._count > 20: case this._delay === 0: this.send(); break; } }; Queue.prototype.send = function send (ending) { if ( ending === void 0 ) ending = false; if (!this._isRequested) { return; } var actionLayers = []; if (!ending) { actionLayers.push.apply(actionLayers, this._startingActions.map(function (queued) { return queued.start(); }).filter(function (layer) { return layer.length > 0; })); } actionLayers.push.apply(actionLayers, this._endingActions.map(function (queued) { return queued.end(); }).filter(function (layer) { return layer.length > 0; })); var length = ((actionLayers.length / SLICE) + 1) | 0; var slices = []; for (var i = 0; i < length; i++) { var slice = actionLayers.slice(i * SLICE, (i + 1) * SLICE); slices.push(slice.flat()); } if (this._type === PushType.COLLECTOR && this._collector.isCollecting) { var layer = this._collector.layer; if (slices.length > 0) { var slice$1 = slices.splice(0, 1)[0]; if (slice$1.length > 0) { layer.push.apply(layer, slice$1); } } layer.flat(); if (layer.length > 0) { push(PushType.COLLECTOR, layer); } } if (slices.length > 0) { for (var i$1 = 0; i$1 < slices.length; i$1++) { var slice$2 = slices[i$1]; if (slice$2.length > 0) { push(PushType.ACTION, slice$2); } } } this.reset(ending); }; var QueuedAction = function QueuedAction (action, data) { this._action = action; this._data = data; }; QueuedAction.prototype.test = function test (action) { return this._action === action; }; QueuedAction.prototype.start = function start () { return this._action.start(this._data); }; QueuedAction.prototype.end = function end () { return this._action.end(this._data); }; var queue = new Queue(); var Debug = function Debug () {}; var prototypeAccessors$c = { debugger: { configurable: true },isActive: { configurable: true } }; prototypeAccessors$c.debugger.get = function () { return window._oEa; }; prototypeAccessors$c.isActive.get = function () { if (!this.debugger) { return false; } return this.debugger._dbg === '1'; }; prototypeAccessors$c.isActive.set = function (value) { if (!this.debugger || this.isActive === value) { return; } this.debugger.debug(value ? 1 : 0); }; Object.defineProperties( Debug.prototype, prototypeAccessors$c ); var debug = new Debug(); var Status = { CONNECTED: { id: 'connected', value: 'connecté', isConnected: true, isDefault: true }, ANONYMOUS: { id: 'anonymous', value: 'anonyme', isConnected: false, isDefault: true }, GUEST: { id: 'guest', value: 'invité', isConnected: false } }; var Type$2 = { INDIVIDUAL: { id: 'individual', value: 'part' }, PROFESSIONNAL: { id: 'professionnal', value: 'pro' } }; /* '["\'<>*$&~`|\\\\?^~]'; */ var RESTRICTED = { '0x0022': '"', '0x0024': '$', '0x0026': '&', '0x0027': ''', '0x002a': '*', '0x002c': ',', '0x003c': '<', '0x003e': '>', '0x003f': '?', '0x005c': '\', '0x005e': '^', '0x0060': '`', '0x007c': '|', '0x007e': '~' }; // import TABLE from './unicode-table'; var charCodeHex = function (char) { var code = char.charCodeAt(0).toString(16); return '0x0000'.slice(0, -code.length) + code; }; var normalize = function (text) { if (!text) { return text; } // text = [...text].map(char => TABLE[charCodeHex(char)] || char).join(''); text = [].concat( text ).map(function (char) { return RESTRICTED[charCodeHex(char)] || char; }).join(''); text = text.replace(/\s+/g, ' ').replace(/\s/g, '_'); text = text.toLowerCase(); return text; }; var validateString = function (value, name, allowNull) { if ( allowNull === void 0 ) allowNull = true; switch (true) { case typeof value === 'number': return ("" + value); case typeof value === 'string': return value; case value === undefined && allowNull: case value === null && allowNull: return ''; } api.inspector.warn(("unexpected value '" + value + "' set at analytics." + name + ". Expecting a String")); return null; }; var validateNumber = function (value, name, allowNull) { if ( allowNull === void 0 ) allowNull = true; switch (true) { case !isNaN(value): return value; case typeof value === 'string' && !isNaN(Number(value)): return Number(value); case value === undefined && allowNull: case value === null && allowNull: return -1; } api.inspector.warn(("unexpected value '" + value + "' set at analytics." + name + ". Expecting a Number")); return null; }; var validateBoolean = function (value, name) { switch (true) { case typeof value === 'boolean': return value; case typeof value === 'string' && value.toLowerCase() === 'true': case value === '1': case value === 1: return true; case typeof value === 'string' && value.toLowerCase() === 'false': case value === '0': case value === 0: return false; case value === undefined: case value === null: return value; } api.inspector.warn(("unexpected value '" + value + "' set at analytics." + name + ". Expecting a Boolean")); return null; }; var validateLang = function (value, name, allowNull) { if ( allowNull === void 0 ) allowNull = true; switch (true) { case typeof value === 'string' && /^[A-Za-z]{2}$|^[A-Za-z]{2}[-_]/.test(value): return value.split(/[-_]/)[0].toLowerCase(); case value === undefined && allowNull: case value === null && allowNull: return ''; } api.inspector.warn(("unexpected value '" + value + "' set at analytics." + name + ". Expecting language as a String following ISO 639-1 format")); return null; }; var validateGeography = function (value, name, allowNull) { if ( allowNull === void 0 ) allowNull = true; switch (true) { case typeof value === 'string': if (!/^FR-[A-Z0-9]{2,3}$/.test(value)) { api.inspector.warn(("value '" + value + "' set at analytics." + name + " with wrong format. Geographic location should be a String following ISO 3166-2:FR format")); } return value; case value === undefined && allowNull: case value === null && allowNull: return ''; } api.inspector.warn(("unexpected value '" + value + "' set at analytics." + name + ". Expecting geographic location as a String following ISO 3166-2:FR format")); return null; }; var normaliseISODate = function (date) { return date.toISOString().split('T')[0]; }; var validateDate = function (value, name, allowNull) { if ( allowNull === void 0 ) allowNull = true; switch (true) { case value instanceof Date: return normaliseISODate(value); case typeof value === 'string': { var date = new Date(value); if (date.toString() !== 'Invalid Date') { return normaliseISODate(date); } break; } case value === undefined && allowNull: case value === null && allowNull: return null; } api.inspector.warn(("unexpected value '" + value + "' set at analytics." + name + ". Expecting a Date")); return null; }; var User = function User (config) { this._config = config || {}; }; var prototypeAccessors$b = { uid: { configurable: true },email: { configurable: true },isNew: { configurable: true },status: { configurable: true },profile: { configurable: true },language: { configurable: true },type: { configurable: true },layer: { configurable: true } }; User.prototype.reset = function reset (clear) { if ( clear === void 0 ) clear = false; this._isConnected = false; this.status = Status.ANONYMOUS; if (!clear && this._config.connect) { this.connect(this._config.connect.uid, this._config.connect.email, this._config.connect.isNew); } else { this._uid = undefined; this._email = undefined; this._isNew = false; } this.profile = clear ? undefined : this._config.profile; this.language = clear ? undefined : this._config.language; this.type = clear ? undefined : this._config.type; }; User.prototype.connect = function connect (uid, email, isNew) { if ( isNew === void 0 ) isNew = false; this._uid = validateString(uid, 'user.uid'); if (/^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]{2,}@[a-zA-Z0-9-]{2,}\.[a-zA-Z]{2,}$/.test(email)) { api.inspector.warn('Please check analytics.user.email is properly encrypted '); } this._email = validateString(email, 'user.email'); this._isNew = validateBoolean(isNew); this._isConnected = true; this.status = Status.CONNECTED; }; prototypeAccessors$b.uid.get = function () { return this._uid; }; prototypeAccessors$b.email.get = function () { return this._email; }; prototypeAccessors$b.isNew.get = function () { return this._isNew; }; prototypeAccessors$b.status.set = function (id) { var this$1$1 = this; var stati = Object.values(Status).filter(function (status) { return status.isConnected === this$1$1._isConnected; }); this._status = stati.filter(function (status) { return status.id === id || status.value === id; })[0] || stati.filter(function (status) { return status.isDefault; })[0]; }; prototypeAccessors$b.status.get = function () { return this._status.id; }; prototypeAccessors$b.profile.set = function (value) { var valid = validateString(value, 'user.profile'); if (valid !== null) { this._profile = valid; } }; prototypeAccessors$b.profile.get = function () { return this._profile.id; }; prototypeAccessors$b.language.set = function (value) { var valid = validateLang(value, 'user.language'); if (valid !== null) { this._language = valid; } }; prototypeAccessors$b.language.get = function () { return this._language || navigator.language; }; prototypeAccessors$b.type.set = function (id) { this._type = Object.values(Type$2).filter(function (type) { return type.id === id || type.value === id; })[0]; }; prototypeAccessors$b.type.get = function () { return this._type.id; }; prototypeAccessors$b.layer.get = function () { var layer = []; if (this.uid) { layer.push('uid', normalize(this.uid)); } if (this.email) { layer.push('email', normalize(this.email)); } if (this.isNew) { layer.push('newcustomer', '1'); } if (this.language) { layer.push('user_language', this.language); } layer.push('user_login_status', this._status.value); if (this._profile) { layer.push('profile', this._profile); } if (this._type) { layer.push('user_type', this._type.value); } return layer; }; Object.defineProperties( User.prototype, prototypeAccessors$b ); User.Status = Status; User.Type = Type$2; var Environment = { DEVELOPMENT: { id: 'development', value: 'dev' }, STAGE: { id: 'stage', value: 'stage' }, PRODUCTION: { id: 'production', value: 'prod' } }; var Site = function Site (config) { this._config = config || {}; }; var prototypeAccessors$a = { environment: { configurable: true },entity: { configurable: true },language: { configurable: true },target: { configurable: true },type: { configurable: true },region: { configurable: true },department: { configurable: true },version: { configurable: true },api: { configurable: true },layer: { configurable: true } }; Site.prototype.reset = function reset (clear) { if ( clear === void 0 ) clear = false; this.environment = clear ? Environment.DEVELOPMENT.id : this._config.environment; this.entity = clear ? undefined : this._config.entity; this.language = clear ? undefined : this._config.language; this.target = clear ? undefined : this._config.target; this.type = clear ? undefined : this._config.type; this.region = clear ? undefined : this._config.region; this.department = clear ? undefined : this._config.department; this.version = clear ? undefined : this._config.version; this._api = api.version; }; prototypeAccessors$a.environment.set = function (value) { switch (value) { case Environment.PRODUCTION.id: case Environment.PRODUCTION.value: this._environment = Environment.PRODUCTION; break; case Environment.STAGE.id: case Environment.STAGE.value: this._environment = Environment.STAGE; break; case Environment.DEVELOPMENT.id: case Environment.DEVELOPMENT.value: this._environment = Environment.DEVELOPMENT; break; default: this._environment = Environment.DEVELOPMENT; } }; prototypeAccessors$a.environment.get = function () { return this._environment ? this._environment.id : Environment.DEVELOPMENT.id; }; prototypeAccessors$a.entity.set = function (value) { var valid = validateString(value, 'site.entity'); if (valid !== null) { this._entity = valid; } }; prototypeAccessors$a.entity.get = function () { return this._entity; }; prototypeAccessors$a.language.set = function (value) { var valid = validateLang(value, 'site.language'); if (valid !== null) { this._language = valid; } }; prototypeAccessors$a.language.get = function () { return this._language || document.documentElement.lang; }; prototypeAccessors$a.target.set = function (value) { var valid = validateString(value, 'site.target'); if (valid !== null) { this._target = valid; } }; prototypeAccessors$a.target.get = function () { return this._target; }; prototypeAccessors$a.type.set = function (value) { var valid = validateString(value, 'site.type'); if (valid !== null) { this._type = valid; } }; prototypeAccessors$a.type.get = function () { return this._type; }; prototypeAccessors$a.region.set = function (value) { var valid = validateGeography(value, 'site.region'); if (valid !== null) { this._region = valid; } }; prototypeAccessors$a.region.get = function () { return this._region; }; prototypeAccessors$a.department.set = function (value) { var valid = validateGeography(value, 'site.department'); if (valid !== null) { this._department = valid; } }; prototypeAccessors$a.department.get = function () { return this._department; }; prototypeAccessors$a.version.set = function (value) { var valid = validateString(value, 'site.version'); if (valid !== null) { this._version = valid; } }; prototypeAccessors$a.version.get = function () { return this._version; }; prototypeAccessors$a.api.get = function () { return this._api; }; prototypeAccessors$a.layer.get = function () { var layer = []; layer.push('site_environment', this._environment.value); if (this.entity) { layer.push('site_entity', normalize(this.entity)); } else { api.inspector.warn('entity is required in analytics.site'); } if (this.language) { layer.push('site_language', this.language); } if (this.target) { layer.push('site_target', normalize(this.target)); } if (this.type) { layer.push('site_type', normalize(this.type)); } if (this.region) { layer.push('site_region', this.region); } if (this.department) { layer.push('site_department', this.department); } if (this.version) { layer.push('site_version', this.version); } if (this.api) { layer.push('api_version', this.api); } return layer; }; Object.defineProperties( Site.prototype, prototypeAccessors$a ); Site.Environment = Environment; var Inventory = { accordion: api.internals.ns.selector('accordion'), alert: api.internals.ns.selector('alert'), badge: api.internals.ns.selector('badge'), breadcrumb: api.internals.ns.selector('breadcrumb'), button: api.internals.ns.selector('btn'), callout: api.internals.ns.selector('callout'), card: api.internals.ns.selector('card'), checkbox: api.internals.ns.selector('checkbox-group'), connect: api.internals.ns.selector('connect'), consent: api.internals.ns.selector('consent-banner'), content: api.internals.ns.selector('content-media'), download: api.internals.ns.selector('download'), follow: api.internals.ns.selector('follow'), footer: api.internals.ns.selector('footer'), header: api.internals.ns.selector('header'), highlight: api.internals.ns.selector('highlight'), input: api.internals.ns.selector('input-group'), link: api.internals.ns.selector('link'), modal: api.internals.ns.selector('modal'), navigation: api.internals.ns.selector('nav'), notice: api.internals.ns.selector('notice'), pagination: api.internals.ns.selector('pagination'), quote: api.internals.ns.selector('quote'), radio: api.internals.ns.selector('radio-group'), search: api.internals.ns.selector('search-bar'), select: api.internals.ns.selector('select'), share: api.internals.ns.selector('share'), sidemenu: api.internals.ns.selector('sidemenu'), stepper: api.internals.ns.selector('stepper'), summary: api.internals.ns.selector('summary'), tab: api.internals.ns.selector('tabs'), table: api.internals.ns.selector('table'), tag: api.internals.ns.selector('tag'), tile: api.internals.ns.selector('tile'), toggle: api.internals.ns.selector('toggle'), tooltip: api.internals.ns.selector('tooltip'), transcription: api.internals.ns.selector('transcription'), translate: api.internals.ns.selector('translate'), upload: api.internals.ns.selector('upload-group') }; var CollectionState = { COLLECTABLE: 'collectable', COLLECTING: 'collecting', COLLECTED: 'collected' }; var Page = function Page (config) { this._config = config || {}; this._state = CollectionState.COLLECTABLE; }; var prototypeAccessors$9 = { isCollecting: { configurable: true },path: { configurable: true },referrer: { configurable: true },title: { configurable: true },id: { configurable: true },author: { configurable: true },date: { configurable: true },tags: { configurable: true },name: { configurable: true },labels: { configurable: true },categories: { configurable: true },isError: { configurable: true },template: { configurable: true },segment: { configurable: true },group: { configurable: true },subtemplate: { configurable: true },theme: { configurable: true },subtheme: { configurable: true },related: { configurable: true },depth: { configurable: true },current: { configurable: true },total: { configurable: true },filters: { configurable: true },layer: { configurable: true } }; Page.prototype.reset = function reset (clear) { if ( clear === void 0 ) clear = false; this.path = clear ? '' : this._config.path; this.referrer = clear ? '' : this._config.referrer; this.title = clear ? '' : this._config.title; this.name = clear ? '' : this._config.name; this.id = clear ? '' : this._config.id; this.author = clear ? '' : this._config.author; this.date = clear ? '' : this._config.date; this._labels = clear || !this._config.labels ? ['', '', '', '', ''] : this._config.labels; this._labels.length = 5; this._tags = clear || !this._config.tags ? [] : this._config.tags; this._categories = clear || !this._config.categories ? ['', '', ''] : this._config.categories; this.isError = !clear && this._config.isError; this.template = clear ? '' : this._config.template; this.group = clear ? '' : this._config.group; this.segment = clear ? '' : this._config.segment; this.subtemplate = clear ? '' : this._config.subtemplate; this.theme = clear ? '' : this._config.theme; this.subtheme = clear ? '' : this._config.subtheme; this.related = clear ? '' : this._config.related; this.depth = clear || isNaN(this._config.depth) ? 0 : this._config.depth; this.current = clear || isNaN(this._config.current) ? -1 : this._config.current; this.total = clear || isNaN(this._config.total) ? -1 : this._config.total; this._filters = clear || !this._config.filters ? [] : this._config.filters; }; Page.prototype.collecting = function collecting () { if (this._state !== CollectionState.COLLECTABLE) { api.inspector.warn(("current path '" + (this.path) + "' was already collected")); return false; } this._state = CollectionState.COLLECTING; return true; }; prototypeAccessors$9.isCollecting.get = function () { return this._state === CollectionState.COLLECTING; }; prototypeAccessors$9.path.set = function (value) { var valid = validateString(value, 'page.path'); if (valid !== null) { this._path = valid; this._state = CollectionState.COLLECTABLE; } }; prototypeAccessors$9.path.get = function () { return this._path || ("" + (document.location.pathname) + (document.location.search)); }; prototypeAccessors$9.referrer.set = function (value) { var valid = validateString(value, 'page.referrer'); if (valid !== null) { this._referrer = valid; } }; prototypeAccessors$9.referrer.get = function () { return this._referrer; }; prototypeAccessors$9.title.set = function (value) { var valid = validateString(value, 'page.title'); if (valid !== null) { this._title = valid; } }; prototypeAccessors$9.title.get = function () { return this._title || document.title; }; prototypeAccessors$9.id.set = function (value) { var valid = validateString(value, 'page.id'); if (valid !== null) { this._id = valid; } }; prototypeAccessors$9.id.get = function () { return this._id; }; prototypeAccessors$9.author.set = function (value) { var valid = validateString(value, 'page.author'); if (valid !== null) { this._author = valid; } }; prototypeAccessors$9.author.get = function () { return this._author; }; prototypeAccessors$9.date.set = function (value) { var valid = validateDate(value, 'page.date'); if (valid !== null) { this._date = valid; } }; prototypeAccessors$9.date.get = function () { return this._date; }; prototypeAccessors$9.tags.get = function () { return this._tags; }; prototypeAccessors$9.name.set = function (value) { var valid = validateString(value, 'page.name'); if (valid !== null) { this._name = valid; } }; prototypeAccessors$9.name.get = function () { return this._name || this.title; }; prototypeAccessors$9.labels.get = function () { return this._labels; }; prototypeAccessors$9.categories.get = function () { return this._categories; }; prototypeAccessors$9.isError.set = function (value) { var valid = validateBoolean(value, 'page.isError'); if (valid !== null) { this._isError = valid; } }; prototypeAccessors$9.isError.get = function () { return this._isError; }; prototypeAccessors$9.template.set = function (value) { var valid = validateString(value, 'page.template'); if (valid !== null) { this._template = valid; } }; prototypeAccessors$9.template.get = function () { return this._template || 'autres'; }; prototypeAccessors$9.segment.set = function (value) { var valid = validateString(value, 'page.segment'); if (valid !== null) { this._segment = valid; } }; prototypeAccessors$9.segment.get = function () { return this._segment || this.template; }; prototypeAccessors$9.group.set = function (value) { var valid = validateString(value, 'page.group'); if (valid !== null) { this._group = valid; } }; prototypeAccessors$9.group.get = function () { return this._group || this.template; }; prototypeAccessors$9.subtemplate.set = function (value) { var valid = validateString(value, 'page.subtemplate'); if (valid !== null) { this._subtemplate = valid; } }; prototypeAccessors$9.subtemplate.get = function () { return this._subtemplate; }; prototypeAccessors$9.theme.set = function (value) { var valid = validateString(value, 'page.theme'); if (valid !== null) { this._theme = valid; } }; prototypeAccessors$9.theme.get = function () { return this._theme; }; prototypeAccessors$9.subtheme.set = function (value) { var valid = validateString(value, 'page.subtheme'); if (valid !== null) { this._subtheme = valid; } }; prototypeAccessors$9.subtheme.get = function () { return this._subtheme; }; prototypeAccessors$9.related.set = function (value) { var valid = validateString(value, 'page.related'); if (valid !== null) { this._related = valid; } }; prototypeAccessors$9.related.get = function () { return this._related; }; prototypeAccessors$9.depth.set = function (value) { var valid = validateNumber(value, 'page.depth'); if (valid !== null) { this._depth = valid; } }; prototypeAccessors$9.depth.get = function () { return this._depth; }; prototypeAccessors$9.current.set = function (value) { var valid = validateNumber(value, 'page.current'); if (valid !== null) { this._current = valid; } }; prototypeAccessors$9.current.get = function () { return this._current; }; prototypeAccessors$9.total.set = function (value) { var valid = validateNumber(value, 'page.total'); if (valid !== null) { this._total = valid; } }; prototypeAccessors$9.total.get = function () { return this._total; }; prototypeAccessors$9.filters.get = function () { return this._filters; }; prototypeAccessors$9.layer.get = function () { this._state = CollectionState.COLLECTED; var layer = []; if (this.path) { layer.push('path', normalize(this.path)); } if (this.referrer) { layer.push('referrer', normalize(this.referrer)); } if (this.title) { layer.push('page_title', normalize(this.title)); } if (this.name) { layer.push('page_name', normalize(this.name)); } if (this.id) { layer.push('page_id', normalize(this.id)); } if (this.author) { layer.push('page_author', normalize(this.author)); } if (this.date) { layer.push('page_date', normalize(this.date)); } var components = Object.keys(Inventory).map(function (id) { return document.querySelector(Inventory[id]) !== null ? id : null; }).filter(function (id) { return id !== null; }).join(','); if (components) { layer.push('page_components', components); } var labels = this._labels.slice(0, 5); labels.length = 5; if (labels.some(function (label) { return label; })) { layer.push('pagelabel', labels.map(function (label) { return typeof label === 'string' ? normalize(label) : ''; }).join(',')); } var tags = this._tags; if (tags.some(function (tag) { return tag; })) { layer.push('pagetag', tags.map(function (tag) { return typeof tag === 'string' ? normalize(tag) : ''; }).join(',')); } this._categories.forEach(function (category, index) { if (category) { layer.push(("page_category" + (index + 1)), category); } }); if (this._isError) { layer.push('error', '1'); } layer.push('page_template', normalize(this.template)); layer.push('pagegroup', normalize(this.group)); layer.push('site-segment', normalize(this.segment)); if (this.subtemplate) { layer.push('page_subtemplate', normalize(this.subtemplate)); } if (this.theme) { layer.push('page_theme', normalize(this.theme)); } if (this.subtheme) { layer.push('page_subtheme', normalize(this.subtheme)); } if (this.related) { layer.push('page_related', normalize(this.related)); } if (!isNaN(this.depth)) { layer.push('page_depth', this.depth); } if (!isNaN(this.current) && this.current > -1) { var pagination = "" + (this.current); if (!isNaN(this.total) && this.total > -1) { pagination += "/" + (this.total); } layer.push('page_pagination', pagination); } if (this.filters.length && this.filters.some(function (label) { return label; })) { var filters = this.filters.map(function (filter) { return typeof filter === 'string' ? normalize(filter) : ''; }); layer.push('page_filters', filters.join(',')); } return layer; }; Object.defineProperties( Page.prototype, prototypeAccessors$9 ); var Method = { STANDARD: { id: 'standard', value: 'standard', isDefault: true }, AUTOCOMPLETE: { id: 'autocomplete', value: 'autocompletion' } }; var Search = function Search (config) { this._config = config || {}; }; var prototypeAccessors$8 = { engine: { configurable: true },results: { configurable: true },terms: { configurable: true },category: { configurable: true },theme: { configurable: true },type: { configurable: true },method: { configurable: true },layer: { configurable: true } }; Search.prototype.reset = function reset (clear) { if ( clear === void 0 ) clear = false; this.engine = clear ? undefined : this._config.engine; this.results = clear || isNaN(this._config.results) ? -1 : this._config.results; this.terms = clear ? undefined : this._config.terms; this.category = clear ? undefined : this._config.category; this.theme = clear ? undefined : this._config.theme; this.type = clear ? undefined : this._config.type; this.method = clear ? undefined : this._config.method; }; prototypeAccessors$8.engine.set = function (value) { var valid = validateString(value, 'search.engine'); if (valid !== null) { this._engine = valid; } }; prototypeAccessors$8.engine.get = function () { return this._engine; }; prototypeAccessors$8.results.set = function (value) { var valid = validateNumber(value, 'search.results'); if (valid !== null) { this._results = valid; } }; prototypeAccessors$8.results.get = function () { return this._results; }; prototypeAccessors$8.terms.set = function (value) { var valid = validateString(value, 'search.terms'); if (valid !== null) { this._terms = valid; } }; prototypeAccessors$8.terms.get = function () { return this._terms; }; prototypeAccessors$8.category.set = function (value) { var valid = validateString(value, 'search.category'); if (valid !== null) { this._category = valid; } }; prototypeAccessors$8.category.get = function () { return this._category; }; prototypeAccessors$8.theme.set = function (value) { var valid = validateString(value, 'search.theme'); if (valid !== null) { this._theme = valid; } }; prototypeAccessors$8.theme.get = function () { return this._theme; }; prototypeAccessors$8.type.set = function (value) { var valid = validateString(value, 'search.type'); if (valid !== null) { this._type = valid; } this._type = value; }; prototypeAccessors$8.type.get = function () { return this._type; }; prototypeAccessors$8.method.set = function (id) { var methods = Object.values(Method); this._method = methods.filter(function (method) { return method.id === id || method.value === id; })[0] || methods.filter(function (method) { return method.isDefault; })[0]; }; prototypeAccessors$8.method.get = function () { return this._method; }; prototypeAccessors$8.layer.get = function () { var layer = []; if (this.engine) { layer.push('isearchengine', normalize(this.engine)); } if (this.results > -1) { layer.push('isearchresults', this.results); } if (this.terms) { layer.push('isearchkey', 'search_terms', 'isearchdata', normalize(this.terms)); } if (this.category) { layer.push('isearchkey', 'search_category', 'isearchdata', normalize(this.category)); } if (this.theme) { layer.push('isearchkey', 'search_theme', 'isearchdata', normalize(this.theme)); } if (this.type) { layer.push('isearchkey', 'search_type', 'isearchdata', normalize(this.type)); } if (this._method && layer.length) { layer.push('isearchkey', 'search_method', 'isearchdata', this._method.value); } return layer; }; Object.defineProperties( Search.prototype, prototypeAccessors$8 ); Search.Method = Method; var Funnel = function Funnel (config) { this._config = config || {}; }; var prototypeAccessors$7 = { id: { configurable: true },type: { configurable: true },name: { configurable: true },step: { configurable: true },current: { configurable: true },total: { configurable: true },objective: { configurable: true },error: { configurable: true },layer: { configurable: true } }; Funnel.prototype.reset = function reset (clear) { if ( clear === void 0 ) clear = false; this.id = clear ? undefined : this._config.id; this.type = clear ? undefined : this._config.type; this.name = clear ? undefined : this._config.name; this.step = clear ? undefined : this._config.step; this.current = clear || isNaN(this._config.current) ? -1 : this._config.current; this.total = clear || isNaN(this._config.total) ? -1 : this._config.total; this.objective = clear ? undefined : this._config.objective; this.error = clear ? undefined : this._config.error; }; prototypeAccessors$7.id.set = function (value) { var valid = validateString(value, 'funnel.id'); if (valid !== null) { this._id = valid; } }; prototypeAccessors$7.id.get = function () { return this._id; }; prototypeAccessors$7.type.set = function (value) { var valid = validateString(value, 'funnel.type'); if (valid !== null) { this._type = valid; } }; prototypeAccessors$7.type.get = function () { return this._type; }; prototypeAccessors$7.name.set = function (value) { var valid = validateString(value, 'funnel.name'); if (valid !== null) { this._name = valid; } }; prototypeAccessors$7.name.get = function () { return this._name; }; prototypeAccessors$7.step.set = function (value) { var valid = validateString(value, 'funnel.step'); if (valid !== null) { this._step = valid; } }; prototypeAccessors$7.step.get = function () { return this._step; }; prototypeAccessors$7.current.set = function (value) { var valid = validateNumber(value, 'funnel.current'); if (valid !== null) { this._current = valid; } }; prototypeAccessors$7.current.get = function () { return this._current; }; prototypeAccessors$7.total.set = function (value) { var valid = validateNumber(value, 'funnel.total'); if (valid !== null) { this._total = valid; } }; prototypeAccessors$7.total.get = function () { return this._total; }; prototypeAccessors$7.objective.set = function (value) { var valid = validateString(value, 'funnel.objective'); if (valid !== null) { this._objective = valid; } this._objective = value; }; prototypeAccessors$7.objective.get = function () { return this._objective; }; prototypeAccessors$7.error.set = function (value) { var valid = validateString(value, 'funnel.error'); if (valid !== null) { this._error = valid; } this._error = value; }; prototypeAccessors$7.error.get = function () { return this._error; }; prototypeAccessors$7.layer.get = function () { var layer = []; if (this.id) { layer.push('funnel_id', normalize(this.id)); } if (this.type) { layer.push('funnel_type', normalize(this.type)); } if (this.name) { layer.push('funnel_name', normalize(this.name)); } if (this.step) { layer.push('funnel_step_name', normalize(this.step)); } if (!isNaN(this.current) && this.current > -1) { layer.push('funnel_step_number', this.current); } if (!isNaN(this.total) && this.total > -1) { layer.push('funnel_step_max', this.total); } if (this.objective) { layer.push('funnel_objective', normalize(this.objective)); } if (this.error) { layer.push('funnel_error', normalize(this.error)); } return layer; }; Object.defineProperties( Funnel.prototype, prototypeAccessors$7 ); var ActionMode = { IN: 'in', OUT: 'out', NONE: 'none' }; var ActionStatus = { UNSTARTED: { id: 'unstarted', value: -1 }, STARTED: { id: 'started', value: 1 }, SINGULAR: { id: 'singular', value: 2 }, ENDED: { id: 'ended', value: 3 } }; var getParametersLayer = function (data) { return Object.entries(data).map(function (ref) { var key = ref[0]; var value = ref[1]; return ['actionpname', normalize(key), 'actionpvalue', normalize(value)]; }).flat(); }; var Action = function Action (name) { this._isMuted = false; this._regulation = ActionRegulation.NONE; this._name = name; this._status = ActionStatus.UNSTARTED; this._labels = [];