bim_gdpr-1.0.0-rc3/libraries/dist/bim-gdpr/bim-gdpr.js

libraries/dist/bim-gdpr/bim-gdpr.js
/*! For license information please see bim-gdpr.js.LICENSE.txt */
!function(e){var t={};function i(s){if(t[s])return t[s].exports;var r=t[s]={i:s,l:!1,exports:{}};return e[s].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(s,r,function(t){return e[t]}.bind(null,r));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i(i.s=1)}([function(e,t,i){"use strict";i.d(t,"b",(function(){return s})),i.d(t,"d",(function(){return r})),i.d(t,"a",(function(){return n})),i.d(t,"c",(function(){return a})),i.d(t,"f",(function(){return o})),i.d(t,"e",(function(){return l}));const s="bgdpr",r="data-"+s+"-",n="https://cdn.jsdelivr.net/gh/tsecher/bim-gdpr@master/",a="%",o=function(e,t){return(e=e.weight)>(t=t.weight)?1:e<t?-1:0},l=function(e,t,i=!0){const s=[];for(let i in e){const r=typeof e[i],n=typeof t[i];r!==n&&s.push({type:r,name:i,value:t[i],valueType:n})}if(s.length){if(i){const i="\r\n\t - ";throw`The object ${t} does not match interface ${e}. Here are missing or bad typed properties : ${i+s.map(e=>`waiting for ${e.name} (${e.type}) and got value ${e.value} (${e.valueType}) `).join(i)} \r\n Please check the doc to make your service valid`}return!1}return!0}},function(e,t,i){e.exports=i(9)},function(e,t,i){var s,r;!function(n){if(void 0===(r="function"==typeof(s=n)?s.call(t,i,t,e):s)||(e.exports=r),!0,e.exports=n(),!!0){var a=window.Cookies,o=window.Cookies=n();o.noConflict=function(){return window.Cookies=a,o}}}((function(){function e(){for(var e=0,t={};e<arguments.length;e++){var i=arguments[e];for(var s in i)t[s]=i[s]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(s){function r(){}function n(t,i,n){if("undefined"!=typeof document){"number"==typeof(n=e({path:"/"},r.defaults,n)).expires&&(n.expires=new Date(1*new Date+864e5*n.expires)),n.expires=n.expires?n.expires.toUTCString():"";try{var a=JSON.stringify(i);/^[\{\[]/.test(a)&&(i=a)}catch(e){}i=s.write?s.write(i,t):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var o="";for(var l in n)n[l]&&(o+="; "+l,!0!==n[l]&&(o+="="+n[l].split(";")[0]));return document.cookie=t+"="+i+o}}function a(e,i){if("undefined"!=typeof document){for(var r={},n=document.cookie?document.cookie.split("; "):[],a=0;a<n.length;a++){var o=n[a].split("="),l=o.slice(1).join("=");i||'"'!==l.charAt(0)||(l=l.slice(1,-1));try{var c=t(o[0]);if(l=(s.read||s)(l,c)||t(l),i)try{l=JSON.parse(l)}catch(e){}if(r[c]=l,e===c)break}catch(e){}}return e?r[e]:r}}return r.set=n,r.get=function(e){return a(e,!1)},r.getJSON=function(e){return a(e,!0)},r.remove=function(t,i){n(t,"",e(i,{expires:-1}))},r.defaults={},r.withConverter=i,r}((function(){}))}))},function(e,t,i){var s,r,n;n=function(){var e,t,i=document,s=i.getElementsByTagName("head")[0],r={},n={},a={},o={};function l(e,t){for(var i=0,s=e.length;i<s;++i)if(!t(e[i]))return!1;return 1}function c(e,t){l(e,(function(e){return t(e),1}))}function d(t,i,s){t=t.push?t:[t];var h=i&&i.call,g=h?i:s,p=h?t.join(""):i,v=t.length;function b(e){return e.call?e():r[e]}function f(){if(!--v)for(var e in r[p]=1,g&&g(),a)l(e.split("|"),b)&&!c(a[e],b)&&(a[e]=[])}return setTimeout((function(){c(t,(function t(i,s){return null===i?f():(s||/^https?:\/\//.test(i)||!e||(i=-1===i.indexOf(".js")?e+i+".js":e+i),o[i]?(p&&(n[p]=1),2==o[i]?f():setTimeout((function(){t(i,!0)}),0)):(o[i]=1,p&&(n[p]=1),void u(i,f)))}))}),0),d}function u(e,r){var n,a=i.createElement("script");a.onload=a.onerror=a.onreadystatechange=function(){a.readyState&&!/^c|loade/.test(a.readyState)||n||(a.onload=a.onreadystatechange=null,n=1,o[e]=2,r())},a.async=1,a.src=t?e+(-1===e.indexOf("?")?"?":"&")+t:e,s.insertBefore(a,s.lastChild)}return d.get=u,d.order=function(e,t,i){!function s(r){r=e.shift(),e.length?d(r,s):d(r,t,i)}()},d.path=function(t){e=t},d.urlArgs=function(e){t=e},d.ready=function(e,t,i){e=e.push?e:[e];var s,n=[];return!c(e,(function(e){r[e]||n.push(e)}))&&l(e,(function(e){return r[e]}))?t():(s=e.join("|"),a[s]=a[s]||[],a[s].push(t),i&&i(n)),d},d.done=function(e){d([null],e)},d},e.exports?e.exports=n():void 0===(r="function"==typeof(s=n)?s.call(t,i,t,e):s)||(e.exports=r)},,,,,,function(e,t,i){"use strict";i.r(t);var s=i(0);const r="group-list-has-changed",n="group-list-has-changed",a=i(2),o=1,l=-1,c=0;const d=new class{constructor(){this.useLocalStorage=!0}getServiceStatus(e,t=!0){const i=this.getData();return void 0!==i[e.id]?i[e.id]:t?(this.setServiceStatus(e,l),this.getServiceStatus(e,!1)):l}setServiceStatus(e,t){const i=this.getData();i[e.id]=t,this.useLocalStorage&&localStorage?localStorage.setItem(s.b,JSON.stringify(i)):a.set(s.b,i)}getData(){let e=null;this.useLocalStorage&&(e=localStorage.getItem(s.b));let t=e||a.get(s.b)||{};try{t=JSON.parse(t)}catch(e){}return t}};class u{constructor(e,t,i){this._id=e,this._name=t,this._description=i,this.services=[]}get id(){return this._id}get name(){return this._name}get description(){return this._description}get status(){const e=this.services.length;return this.services.filter(e=>e.isEnabled()).length===e?o:this.services.filter(e=>e.isDisabled()).length===e?c:l}set id(e){this._id=e,x.trigger(ServiceEvents.groupHasChanged,{group:this})}set name(e){this._name=e,x.trigger(n,{group:this})}set description(e){this._description=e,x.trigger(n,{group:this})}isMandatory(){return this.services.filter(e=>e.isMandatory()).length===this.services.length}addService(e){return e&&(Array.isArray(e)?e.map(e=>this._doAddService(e)):this._doAddService(e)),this}getServicesList(){return this.services}_doAddService(e){let t=x.getServiceManager().getServiceById(e.id);return t&&(this.services.push(t),this.services=this.services.sort((e,t)=>Object(s.f)(e,t)),x.trigger(n,{group:this})),this}enableAll(){return x.getServiceManager().enableService(this.services),this}disableAll(){return x.getServiceManager().disableService(this.services),this}toggleAll(){return this.status!==o?this.enableAll():this.disableAll(),this}setWeight(e){return this.weight=e,x.getGroupManager().getGroupById(this.id)&&x.trigger(n,{group:this}),this}}const h="needs-rebuild",g="has-rebuild",p="before-show-view",v="after-show-view",b="before-hide-view",f="after-hide-view";const m=new class{constructor(){this.groups=[]}init(){x.on(r).subscribe((e,t)=>this.sortGroups()),x.on(n).subscribe((e,t)=>this.sortGroups())}createGroup(e,t,i){if(!this.getGroupById(e)){const s=new u(e,t,i);return s.weight=void 0!==s.weight?s.weight:this.groups.length,this.groups.push(s),this.sortGroups(),x.trigger(r,{groupManager:this}),s}if(this.logs)throw`Group ${e} already exists`;return!1}getGroupsList(){return this.groups}getGroupById(e){return this.groups.filter(t=>t.id===e)[0]}sortGroups(){return this.groups=this.groups.sort((e,t)=>Object(s.f)(e,t)),x.trigger(h,{type:"all"}),this}getUnGroupedServices(){let e=[];this.groups.map(t=>{e=e.concat(t.getServicesList().map(e=>e.id))});try{e=[...new Set(e)]}catch(t){e.filter((e,t,i)=>{i.indexOf(e)})}return x.getServiceManager().getServicesList().map(e=>e.id).filter(t=>-1===e.indexOf(t)).map(e=>x.getServiceManager().getServiceById(e))}},S="service-list-has-changed",w="service-has-changed",y="service-status-has-changed",M="service-start",L="service-stop",T="service-has-been-added";class ${constructor(e){this.resolvers=[],this.rejecters=[],e&&e(this.onResolve,this.onReject)}then(e){return this.resolvers.push(e),this}subscribe(e){return this.then(e)}catch(e){return this.rejecters.push(e),this}callAll(e,...t){for(let i=0;i<e.length;i++)e[i](...t)}onResolve(...e){this.callAll(this.resolvers,...e)}onReject(...e){this.callAll(this.rejecters,...e)}}const E=new class{constructor(){this.enableCache=!0,this.tryRegionalisation=!1,this.setUserLanguage(),this.alreadyLoaded=[]}init(){}hasToLoadTranslation(e){const t=this.getUserLanguage();return this.tryRegionalisation&&e!==t||!this.tryRegionalisation&&e.split("-")[0]!==t.split("-")[0]}setDefaultLanguage(e){this.defaultLanguage=e}allowTryRegionalisation(){return this.tryRegionalisation=!0,this}setUserLanguage(e=null){this.userLanguage=e||(navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLang||null),this.translations=this.translations||{},this.translations[this.userLanguage]=this.translations[this.userLanguage]||{}}getUserLanguage(){return this.userLanguage||this.setUserLanguage(),this.userLanguage}addTranslation(e,t){if("string"==typeof t){if(t.indexOf(s.c)>-1)return this.loadFile(t),this;throw`The translation path does not have a "${s.c}" to replace`}this._doAddTranslation(e,this.getCleanLocalisationData(t),!0)}getCleanLocalisationData(e){const t={};return Object.keys(e).forEach(i=>{const s=e[i];"string"==typeof s?t[i]=s:s.value&&"string"==typeof s.value&&(t[i]=s.value)}),t}loadUserLanguageData(e=!1){this.addTranslation(this.languageBaseUrl)}loadFile(e){let t=this.getUserLanguage();t=this.tryRegionalisation?t:t.split("-")[0];const i=e.split(s.c).join(t);if(this.alreadyLoaded.indexOf(i)>-1)return;const r=this.getStoredTranslationByPath(i);r?this._doAddTranslation(i,r):this._doLoadFile(i,t)}_doLoadFile(e,t){const i=t=>{t.language.indexOf("-")>-1&&this.tryRegionalisation?this.loadFile(e):console.error("Cannot load translation file "+t.path)};let s=new XMLHttpRequest;const r={path:e,language:t};s.onload=()=>{s.status>=200&&s.status<300?(r.result=s.response,this.loadFileContent(r)):i(r)},s.onerror=()=>{i(r)},s.open("get",r.path),s.send()}loadFileContent(e){try{const t=JSON.parse(e.result);this.storeLanguage(e.path,t),this._doAddTranslation(e.path,t)}catch(t){console.error(`translation file is not correct (${e.path})`)}}_doAddTranslation(e,t,i=!1){this._appendTranslation(this.getUserLanguage(),t,i),this.alreadyLoaded.push(e),this.onLoadString()}_appendTranslation(e,t,i=!1){this.translations[e]||(this.translations[e]=t),this.translations[e]=i?{...this.translations[e],...t}:{...t,...this.translations[e]}}storeLanguage(e,t){if(!this.enableCache)return;const i=this.getStoredLanguages();i&&(i[e]=t,localStorage.setItem(s.b+"l",JSON.stringify(i)))}getStoredLanguages(){if(void 0!==typeof localStorage){let e={};try{e=JSON.parse(localStorage.getItem(s.b+"l"))}catch(e){}return e||{}}return null}getStoredTranslationByPath(e){const t=this.getStoredLanguages();return!!t&&t[e]}onLoadString(){const e=this.translations[this.getUserLanguage()];if(e)for(let t in e)this.replaceTranslationInDOM(t,e[t])}replaceTranslationInDOM(e,t){document.querySelectorAll(`[${s.d}l="${this.getTranslationId(e)}"]`).forEach(t=>{let i=null;try{i=JSON.parse(decodeURIComponent(t.getAttribute(s.d+"l-data")))}catch(e){i=null}t.innerHTML=this.translate(e,i)})}translate(e,t){let i=this.translations[this.getUserLanguage()][e]||e;return"object"==typeof i&&void 0!==i.value&&(i=i.value),t&&Object.keys(t).map(e=>{i=i.split(e).join(t[e])}),i}html(e,t){const i=encodeURIComponent(JSON.stringify(t));return`<span ${s.d}l="${this.getTranslationId(e)}" ${t?`${s.d}l-data="${i}"`:""}>${this.translate(e,t)}</span>`}getTranslationId(e){return e.replace(/(<([^>]+)>)/gi,"")}},D=function(e,t){return E.html(e,t)};class A{constructor(e){this.id=e,this.localManager=E,this.defaultLanguage="en",this.translations=this.getDefaultTranslations()}initTranslations(){return this.getTranslations().map((e,t)=>{let i=`${this.id}-${t}`;"string"==typeof e?this.localManager.hasToLoadTranslation(this.getDefaultLanguage())&&this.localManager.addTranslation(i,e):this.localManager.addTranslation(i,e)}),this}setDefaultLanguage(e){return this.defaultLanguage=e,this}getDefaultLanguage(){return this.defaultLanguage}getDefaultTranslations(){return[]}getTranslations(){return this.translations}setTranslations(e){return this.translations=e,this}addTranslation(e){return this.translations.push(e),this.initTranslations(),this}}class O extends A{constructor(e,t,i){super(e),this._id=e,this._name=t,this._description=i}get id(){return this._id}get name(){return this._name}get description(){return this._description}get status(){return d.getServiceStatus(this)}set id(e){this._id=e,x.trigger(w,{service:this})}set name(e){this._name=e,x.trigger(w,{service:this})}set description(e){this._description=e,x.trigger(w,{service:this})}init(){return super.initTranslations(),this}getCookiePatterns(){return[]}getLocalStoragePatterns(){return[]}getRelatedScripts(){return[]}getRelatedCss(){return[]}onEnable(){}onDisable(){}start(){x.logsAreEnabled()&&console.log(`Start ${this.name} (${this.id})`)}stop(){x.logsAreEnabled()&&console.log(`Stop ${this.name} (${this.id})`)}isMandatory(){return!1}isEnabled(){return this.status===o}isDisabled(){return this.status===c}isPending(){return this.status===l}setWeight(e){return this.weight=e,x.getServiceManager().getServiceById(this.id)&&x.trigger(S,{serviceManager:x.getServiceManager()}),this}}class _{init(){x.on(y).subscribe(e=>{e.data&&e.data.services&&e.data.services.map(e=>this.initServiceDOM(e))}),window.addEventListener("DOMContentLoaded",()=>this.onDomLoaded())}initServiceDOM(e){const t=`[${s.d}visible-if-enabled="${e.id}"]`,i=`[${s.d}hidden-if-enabled="${e.id}"]`;e.isEnabled()?(document.querySelectorAll(t).forEach(e=>this.showElement(e)),document.querySelectorAll(i).forEach(e=>this.hideElement(e))):(document.querySelectorAll(t).forEach(e=>this.hideElement(e)),document.querySelectorAll(i).forEach(e=>this.showElement(e)))}onDomLoaded(){const e=s.d+"visible-if-enabled";document.querySelectorAll(`[${e}]`).forEach(t=>{const i=this.getServiceFromElement(t,e);this.initDOMItem(t,i,this.showElement,this.hideElement)});const t=s.d+"hidden-if-enabled";document.querySelectorAll(`[${t}]`).forEach(e=>{const i=this.getServiceFromElement(e,t);this.initDefaultPlacehoder(e,i),this.initDOMItem(e,i,this.hideElement,this.showElement)})}initDOMItem(e,t,i,s){t&&t.isEnabled()?i(e):s(e)}getServiceFromElement(e,t){return x.getServiceById(e.getAttribute(t))}initDefaultPlacehoder(e,t){if(0==e.innerHTML.trim().length)try{const i=x.getTemplate().initDefaultPlaceholder(e,t);i&&(e.innerHTML=i)}catch(e){}}hideElement(e){e.outerHTML=e.outerHTML.replace(/div/g,"noscript")}showElement(e){e.outerHTML=e.outerHTML.replace(/noscript/g,"div").replace(/&lt;/g,"<").replace(/&gt;/g,">")}}const C={id:"id",name:"Name",description:"description",start:function(){}};const k=new class{constructor(){this.services=[],this.servicePlaceholder=new _}getServicesList(){return this.services}getEnabledServicesList(){return this.services.filter(e=>e.isEnabled())}getDisabledServicesList(){return this.services.filter(e=>e.isDisabled())}getPendingServices(){return this.services.filter(e=>e.isPending())}getMandatoryServicesList(){return this.services.filter(e=>e.isMandatory())}init(){this.servicePlaceholder.init(),x.on(S).subscribe(e=>this.sortServices())}createService(e){let t=e;if(!this.isService(e)&&(t=this.overrideService(e),!t))return null;if(this.getServiceById(t.id))throw`Service ${id} already exists`;return t.weight=void 0!==e.weight?t.weight:this.services.length,t.init(),this.services.push(t),t.isEnabled()&&this.startService(t),x.trigger(T,{service:t}),x.trigger(S,{services:this.services}),t}overrideService(e){let t=null;if(Object(s.e)(C,e,x.logsAreEnabled())){t=new O;for(let i in e)t[i]=e[i];Object.getOwnPropertyNames(Object.getPrototypeOf(e)).indexOf("start")>-1&&(Object.getOwnPropertyNames(Object.getPrototypeOf(e)).map(i=>{t[i]=e[i]}),"function"==typeof e.getDefaultTranslations&&t.setTranslations(e.getDefaultTranslations()))}return t}getServiceById(e){return this.services.filter(t=>t.id===e)[0]}sortServices(){return this.services.length>1&&(this.services=this.services.sort((e,t)=>Object(s.f)(e,t))),this}isService(e){return e instanceof O}enableAll(){this.enableService(this.services)}enableService(e,t=!0){if(Array.isArray(e)){const t=e.filter(e=>!e.isEnabled());t.length&&(t.map(e=>{this.enableService(e,!1)}),x.trigger(y,{services:t}))}else e&&!e.isEnabled()&&(d.setServiceStatus(e,o),e.onEnable(),this.startService(e),t&&x.trigger(y,{services:[e]}))}startService(e){e.isRuning||(e.isRuning=!0,e.getRelatedScripts().map(e=>{if("string"==typeof e)x.addScript(e);else try{e.path&&x.addScript(e.path,e.callback)}catch(e){console.error(e)}}),e.start(),x.trigger(M,{service:e}))}disableAll(){this.disableService(this.services)}disableService(e,t=!0){if(Array.isArray(e)){const t=e.filter(e=>!e.isDisabled());t.length>0&&(t.forEach(e=>{this.disableService(e,!1)}),x.trigger(y,{services:t}))}else if(e){!e.isEnabled()&&!e.isPending()||e.isMandatory()||(e.isEnabled()&&(this.stopService(e),e.onDisable()),d.setServiceStatus(e,c),t&&x.trigger(y,{services:[e]}))}}stopService(e){e.isRuning&&(e.isRuning=!1,e.stop(),this.deleteCookies(e),this.deleteLocalStorage(e),e.getRelatedScripts().map(e=>{"string"==typeof e?x.removeScript(e):e.path&&x.removeScript(e.path)}),x.trigger(L,{service:e}))}deleteCookies(e){try{const t=Object.keys(a.get()),i=e.getCookiePatterns();t.length&&i.length&&t.filter(e=>this.filterFromPatterns(e,i)).map(e=>a.remove(e))}catch(e){}}deleteLocalStorage(e){if(window.localStorage)try{const t=Object.keys(window.localStorage),i=e.getLocalStoragePatterns();t.length&&i.length&&t.filter(e=>this.filterFromPatterns(e,i)).map(e=>{window.localStorage.removeItem(e)})}catch(e){}}filterFromPatterns(e,t){for(let i in t)if(e.match(t[i]))return!0;return!1}toggleService(e){e.isEnabled()?this.disableService(e):this.enableService(e)}};class R extends A{constructor(e){super(e),this.css=this.getDefaultCssList()}initTemplate(){super.initTranslations(),this.getCssList().map(e=>x.addCss(e))}getDefaultCssList(){return[]}getCssList(){return this.css}setCssList(e){return this.css=e,this}wrapper(e){return`\n        <div class="${s.b}-view-wrapper">\n            <div class="${s.b}-view">\n                <span class="${s.b}-view-hide" ${s.d}view-hide>close</span>\n                <div class="${s.b}-view-content">\n                    ${e}\n                </div>\n            </div>\n        </div>`}getNoServiceMarkup(){const e=`\n            <div class="${s.b}-view-main">\n                <div class="title">${this.html("Vos données personnelles")}</div>\n                <div class="${s.b}-view-head">\n                    ${this.html("Ce site ne déclare pas de services qui pourraient recquérir et exploiter des données personnelles.")}\n                </div>\n            </div>`;return this.wrapper(e)}getContent(e){return`\n        <div class="${s.b}-view-main">\n            <div class="title">${D("Vos données personnelles")}</div>\n            <div class="${s.b}-view-head">        \n                ${D("Ce site utilise des services pour améliorer votre expérience utilisateur et vous proposer certains contenus externes. \n                Certains de ces services peuvent recquérir et exploiter des données personnelles. \n                Vous pouvez gérer leur activation via ce panneau accessible à tout moment.<br/>Vous pouvez également accéder et gérer en détail l'ensemble des services que le site propose.")}\n            </div>\n\n            <div class="${s.b}-view-quick">\n                <button ${s.d}all-enable="accept_all">${D("Tout accepter")}</button>\n                <button ${s.d}all-disable="deny_all">${D("Tout refuser")}</button>\n                <button ${s.d}view-toggle-detail>${D("Voir le détail")}</button>\n            </div>\n        </div>\n        <div class="${s.b}-view-detail">\n            ${e}\n        </div>`}getViewMarkup(e){let t="";switch(e.type){case"groups":t=e.groups.join("");break;case"services":t=e.services.join("")}return this.wrapper(this.getContent(t))}getServiceMarkup(e){return`\n            <div class="${s.b}-view-service line"  ${s.d}service="${e.id}" ${s.d}status="${e.status}">\n                <div>\n                    <div class="${s.b}-view-service-name">${D(e.name)}</div>\n                    <div class="${s.b}-view-service-description">${D(e.description)}</div>\n                </div>\n                <div>\n                    <button data-bgdpr-service-toggle="${e.id}">\n                        <span class="enable">${D("Activer")}</span>\n                        <span class="disable">${D("Désactiver")}</span>\n                    </button>  \n                </div>\n            </div>\n        `}getGroupMarkup(e,t){return`\n        <div class="${s.b}-view-group">\n            <div class="${s.b}-view-group-head line" ${s.d}group="${e.id}" ${s.d}status="${e.status}">\n                <div>\n                    <div class="${s.b}-view-group-name">${e.name} ${e.isMandatory()?`<span class='mandatory'>${D("(nécessaire au fonctionnement du site)")}</span>`:""}</div>\n                    <div class="${s.b}-view-group-description">${e.description}</div>\n                    <div class="${s.b}-view-group-detail">\n                        <a class="more" href="Javascript:void();" data-bgdpr-group-toggle-detail="${e.id}">Detail</a>  \n                    </div>\n                </div>\n                <div class="${s.b}-view-group-quick question">\n                    <button data-bgdpr-group-toggle="${e.id}">\n                        <span class="enable">${D("Tout activer")}</span>\n                        <span class="disable">${D("Tout désactiver")}</span>\n                    </button>\n                </div>\n            </div>\n\n            <div class="${s.b}-view-group-services">\n                ${t.join("")}\n            </div>\n        </div>\n        `}html(e,t){return D(e,t)}getUngroupedTitle(){return D("Other")}getShowPromise(){}getHidePromise(){}getParentElement(){return this.parent||(this.parent=document.querySelector("body")),this.parent}}const I={init:function(){}};const j=new class{constructor(){this.timeoutValue=200,this.rebuildTimeout=null,this.needsRebuild("all")}init(){if(!this.template)throw s.b+" :  No template defined";return x.on(h).subscribe(e=>{this.needsRebuild(e.data?e.data.type:"all",e.data?e.data.data:{})}),x.on(w).subscribe(e=>this.needsRebuild("service",e.data)),x.on(S).subscribe(e=>this.needsRebuild("all",{})),x.on(n).subscribe(e=>this.needsRebuild("group",e.data)),x.on(r).subscribe(e=>this.needsRebuild("all",{})),this.initTemplate(),this}needsRebuild(e,t){switch(this._needsRebuildData=this._needsRebuildData||[],e){case"all":this.hasToRebuildAll()||(this._needsRebuildData=[{type:"all"}]);break;case"group":this.hasToRebuildGroup(t.group)&&this._needsRebuildData.push({type:"group",element:t.group});break;case"service":this.hasToRebuildService(t.service)&&this._needsRebuildData.push({type:"service",element:t.service})}return window.clearTimeout(this.rebuildTimeout),this.rebuildTimeout=window.setTimeout(()=>this.rebuild(),this.timeoutValue),this}hasToRebuildAll(){return this._needsRebuildData&&this._needsRebuildData.filter(e=>"all"===e.type).length>0}hasToRebuildGroup(e){return!this.hasToRebuildAll()}hasToRebuildService(e){return!this.hasToRebuildAll()}getTemplate(){return this.template}setTemplate(e){let t=e;return this.isTemplate(e)||(t=this.overrideTemplate(e,x.logsAreEnabled()),t)?(this.template=t,this.view=null,this):(x.logsAreEnabled()&&console.error("Bad template"),this)}initTemplate(){return this.template&&(this.template.initTemplate(),this.template.init(),x.trigger(h,{type:"all"})),this}overrideTemplate(e,t=!1){let i=null;if(Object(s.e)(I,e,t)){i=new R;for(let t in e)i[t]=e[t];Object.getOwnPropertyNames(Object.getPrototypeOf(e)).indexOf("init")>-1&&(Object.getOwnPropertyNames(Object.getPrototypeOf(e)).map(t=>{i[t]=e[t]}),"function"==typeof e.getDefaultTranslations&&i.setTranslations(e.getDefaultTranslations()),"function"==typeof e.getDefaultCssList&&i.setCssList(e.getDefaultCssList()))}return i}isTemplate(e){return e instanceof R}rebuild(){return this._needsRebuildData&&this.view&&(this.hasToRebuildAll()?x.getServiceManager().getServicesList().length?this.view.innerHTML=this.getViewMarkup():this.view.innerHTML=this.template.getNoServiceMarkup():this._needsRebuildData.map(e=>{let t="";switch(e.type){case"service":t=this.template.getServiceMarkup(e.element);break;case"group":t=this.template.getGroupMarkup(e.element,this.getServicesMarkupList(e.element.getServicesList()))}const i=`[${s.d}view-${e.type}="${e.element.id}"]`;this.view.querySelectorAll(i).forEach(e=>{e.innerHTML=t})}),x.trigger(g),this._needsRebuildData=null),this}getViewElement(){return this.view||(this.view=document.createElement("div"),this.view.setAttribute(s.d+"view",""),this.view.classList.add(this.getTemplate().id),this.rebuild()),this.view}getViewMarkup(){const e=this.getContentMarkupFromData(this.getViewData());return this.template.getViewMarkup(e)}getViewData(){const e={},t=x.getGroupManager(),i=x.getServiceManager(),s=t.getGroupsList();return s.length&&(e.type="group",e.data={},e.data.groups=s,e.data.ungrouped_services=t.getUnGroupedServices(),e.data.ungrouped_services.length!==i.getServicesList().length)||(e.type="services",e.data={},e.data.services=x.getServiceManager().getServicesList()),e}getContentMarkupFromData(e){let t="";switch(e.type){case"group":t=this.getContentForGroupedView(e.data);break;case"services":t=this.getContentForServicesView(e.data);break;default:t=""}return t}getContentForGroupedView(e){let t={type:"groups",groups:[]};return e.groups.map(e=>{t.groups.push(this.getGroupMarkup(e))}),e.ungrouped_services.length&&t.groups.push(this.getUngroupedMarkup(e.ungrouped_services)),t}getContentForServicesView(e){return{type:"services",services:this.getServicesMarkupList(e.services)}}getServicesMarkupList(e){return e.map(e=>`<div ${s.d}view-service="${e.id}">${this.template.getServiceMarkup(e)}</div>`)}getUngroupedMarkup(e){const t=x.createGroup("default",this.template.getUngroupedTitle(),"");return e.map(e=>t.addService(e)),this.getGroupMarkup(t,this.getServicesMarkupList(e))}getGroupMarkup(e){const t=e.getServicesList();if(t.length){const i=this.getServicesMarkupList(t);return`<div ${s.d}view-group="${e.id}">${this.template.getGroupMarkup(e,i)}</div>`}return""}};const P=new class{constructor(){this.view=j}get parentElement(){return this.getView().getTemplate().getParentElement()}init(){this.view.init(),this.actions||(this.initBehaviors(),this.initActions())}initActions(){this.addAction("all-enable",()=>{x.getServiceManager().enableAll(),this.hide()}),this.addAction("all-disable",()=>{x.getServiceManager().disableAll(),this.hide()}),this.addAction("view-toggle-detail",()=>this.toggleDetailPanel()),this.addAction("view-hide",()=>this.hide()),this.addAction("view-show",()=>this.show()),this.addAction("group-toggle-detail",e=>{this.view.view.querySelector(`[${s.d}view-group="${e.elemId}"]`).classList.toggle(s.b+"-detail")}),this.addAction("group-toggle",e=>{e.group.toggleAll()}),this.addAction("service-enable",e=>{x.getServiceManager().enableService(e.service)}),this.addAction("service-disable",e=>{x.getServiceManager().disableService(e.service)}),this.addAction("service-toggle",e=>{x.getServiceManager().toggleService(e.service)})}getView(){return this.view}isDisplayed(){return document.querySelector(`[${s.d}view]`)}show(){if(!this.isDisplayed()){this.parentElement.appendChild(this.view.getViewElement()),x.trigger(p,{});try{this.getView().getTemplate().getShowPromise().then(()=>{this._doShow()})}catch(e){this._doShow()}}}_doShow(){this.parentElement.classList.add(s.b+"-on"),x.trigger(v,{})}hide(){if(this.isDisplayed()){x.testMode||(x.getServiceManager().enableService(x.getServiceManager().getMandatoryServicesList()),x.getServiceManager().disableService(x.getServiceManager().getPendingServices())),x.trigger(b,{}),this.parentElement.classList.remove(s.b+"-on"),this.parentElement.classList.remove(s.b+"-detail"),this.parentElement.querySelectorAll("."+s.b+"-detail").forEach(e=>{e.classList.remove(s.b+"-detail")});try{this.getView().getTemplate().getHidePromise().then(()=>{this._doHide()})}catch(e){this._doHide()}}}_doHide(){try{this.parentElement.removeChild(this.view.getViewElement())}catch(e){}x.trigger(f,{})}addAction(e,t){this.actions=this.actions||[],this.actions[e]=this.actions[e]||[],this.actions[e].push(t)}initBehaviors(e,t){t=i=>{this.initEventOnItem(i.target,e,t)},document.removeEventListener("click",t),document.addEventListener("click",t)}initEventOnItem(e,t,i){let r=!1;for(let t,i=0,n=e.attributes,a=n?n.length:0;i<a;i++)if(t=n[i],0===t.nodeName.indexOf(s.d)){let e=t.nodeName.split("-"),i=e.slice(2).join("-");switch(e[2]){case"service":const e=x.getServiceManager().getServiceById(t.nodeValue);this.callAction(i,{service:e,elemId:t.nodeValue}),r=!0;break;case"group":const s=x.getGroupManager().getGroupById(t.nodeValue);this.callAction(i,{group:s,elemId:t.nodeValue}),r=!0;break;case"view":case"all":this.callAction(i,{}),r=!0}}e.parentNode&&!r&&this.initEventOnItem(e.parentNode,t,i)}callAction(e,t){this.actions=this.actions||[],this.actions[e]=this.actions[e]||[],this.actions[e].map(e=>{e(t)})}toggleDetailPanel(){this.parentElement.classList.toggle(s.b+"-detail")}detailPanelIsOpen(){return this.parentElement.classList.contains(s.b+"-detail")}initDomData(){window.setTimeout(()=>{document.querySelectorAll(`[${s.d}service][${s.d}status]`).forEach(e=>{const t=x.getServiceManager().getServiceById(e.getAttribute(s.d+"service"));t&&e.setAttribute(s.d+"status",t.status)}),document.querySelectorAll(`[${s.d}group][${s.d}status]`).forEach(e=>{const t=x.getGroupManager().getGroupById(e.getAttribute(s.d+"group"));t&&e.setAttribute(s.d+"status",t.status)})},10)}},G=i(3);const x=new class{constructor(){this.logs=!1,this.testMode=!1,this.autoShow=!0,this.observables=[],this.viewManager=P,this.serviceManager=k,this.groupManager=m,this.localManager=E,this.autoShowCallback=()=>{(this.testMode||this.serviceManager.getPendingServices().length)&&this.showView()}}init(){return this.serviceManager.init(),this.groupManager.init(),this.viewManager.init(),this.localManager.init(),this.getServiceManager().getEnabledServicesList().map(e=>{this.getServiceManager().startService(e)}),this.autoShow&&(window.removeEventListener("DOMContentLoaded",this.autoShowCallback),window.addEventListener("DOMContentLoaded",this.autoShowCallback)),this.on(y).subscribe(e=>this.initDomData()),this}allowTryRegionalisation(){return this.localManager.allowTryRegionalisation(),this}disableLogs(){return this.logs=!1,this}logsAreEnabled(){return this.logs}getServiceManager(){return this.serviceManager}getServiceById(e){return this.getServiceManager().getServiceById(e)}getGroupManager(){return this.groupManager}getGroupById(e){return this.getGroupManager().getGroupById(e)}getViewManager(){return this.viewManager}getLocalManager(){return this.localManager}disableAutoShow(){return this.autoShow=!1,window.removeEventListener("DOMContentLoaded",this.autoShowCallback),this}trigger(e,t){return this.logs&&console.log("Trigger "+e,t),this._observableIsDefined(e)&&this.observables[e].onResolve({name:e,data:t}),this}on(e){return this._observableIsDefined(e)||(this.observables[e]=new $),this.observables[e]}_observableIsDefined(e){return this.observables&&this.observables[e]&&"function"==typeof this.observables[e].onResolve}createService(e){return this.serviceManager.createService(e)}addService(e){return this.serviceManager.createService(e),this}createGroup(e,t,i){return this.groupManager.createGroup(e,t,i)}showView(){return this.viewManager.show(),this}hideView(){return this.viewManager.hide(),this}setTemplate(e){return this.viewManager.getView().setTemplate(e),this}createTemplate(e){return this.viewManager.getView().setTemplate(e),this.getTemplate()}getTemplate(){return this.viewManager.getView().getTemplate()}addScript(e,t){return G(e,t),this}removeScript(e){return document.querySelectorAll('script[src="'+e+'"]').forEach(e=>e.parentNode.removeChild(e)),this}addCss(e,t){const i=document.querySelector("head"),s=document.createElement("link");return s.rel="stylesheet",s.type="text/css",s.href=e,s.media=t||"all",i.appendChild(s),this}removeCss(e){return document.querySelectorAll('link[href="'+e+'"]').forEach(e=>e.parentNode.removeChild(e)),this}initDomData(){return this.viewManager.initDomData(),this}addTranslation(e){return this.localManager.addTranslation("global",e),this}};var V=x;if(window[s.b]){const e=window[s.b];window[s.b]=x;for(let t in e)window[s.b][t]=e[t]}else window[s.b]=x;document.addEventListener("DOMContentLoaded",(function(){var e;drupalSettings.bim_gdpr&&(V.on(T).then((function(e){var t,i=e.data.service,s=drupalSettings.bim_gdpr.services_hierarchy.services.filter((function(e){return e.id==i.id}))[0];(null===(t=drupalSettings.bim_gdpr.services_hierarchy.groups)||void 0===t?void 0:t.length)&&s&&s.parent.length>0&&V.getGroupById(s.parent).addService(i),i.setWeight(s.weight)})),(null===(e=drupalSettings.bim_gdpr.services_hierarchy.groups)||void 0===e?void 0:e.length)&&drupalSettings.bim_gdpr.services_hierarchy.groups.forEach((function(e){(e=V.createGroup(e.id,e.label,e.description)).setWeight(e.weight)})))}))}]);

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc