{"version":3,"file":"AudienceSessionRestoreDetection.js","names":["AudienceSessionRestoreDetection","location","hash","removeHash","pathname","search","document","referrer","indexOf","hostname","message","currentAudience","restoreMessage","replace","investorType","country","messageTemplate","message$","$","init","showMessage","history","replaceState","title","window","e","prependTo","getBoundingClientRect","addClass","setTimeout","removeClass","cleanUp","bind","remove","initDefault"],"sources":["components/AudienceSessionRestoreDetection.js"],"sourcesContent":["import $ from 'jquery';\r\n\r\nexport class AudienceSessionRestoreDetection {\r\n\r\n constructor(){\r\n //When audience session is restored, the redirect includes a '#sessionrestored'\r\n //hash parameter. If not present, bail out.\r\n if(location.hash !== '#sessionrestored'){\r\n return;\r\n }\r\n\r\n\r\n this.removeHash();\r\n\r\n //When visiting the root homepage (ie the path `/`) when you have already selected\r\n // and audience type, the system will automatically redirect to an audience specific\r\n // homepage (intentional). We need to filter out attempts to visit homepage\r\n // from local pages since the message 'previous audience session restored'\r\n // message will not make sense.\r\n if(location.pathname.search(/^\\/[a-z]{2}\\/[a-z]{3}\\/[a-zA-Z0-9\\-\\_]+\\/?$/) >= 0 && document.referrer.indexOf(location.hostname) >= 0){\r\n //User has arrived at an audience homepage (eg '/en/gbr/investor') from a\r\n // page on the site (hence the referrer check above). Hence, the session restoration\r\n // is a false positive\r\n return;\r\n }\r\n\r\n let message = currentAudience.restoreMessage.replace(\"**%investor_type%**\", \"\" + currentAudience.investorType + \"\").replace(\"**%country%**\", \"\" + currentAudience.country + \"\")\r\n this.messageTemplate = `\r\n
\r\n ${message}\r\n
\r\n `;\r\n this.message$ = $(this.messageTemplate);\r\n\r\n this.init();\r\n }\r\n\r\n init(){\r\n this.showMessage();\r\n }\r\n\r\n /**\r\n * Remove hash so URL is clean\r\n */\r\n removeHash () {\r\n try {\r\n history.replaceState('', document.title, window.location.pathname + window.location.search);\r\n } catch(e){\r\n location.hash = '';\r\n }\r\n }\r\n\r\n /**\r\n * Show toast message to user\r\n */\r\n showMessage(){\r\n //Add to header on top (CSS will have it hidden off screen)\r\n this.message$.prependTo(\".ar-header\");\r\n\r\n //Trigger browser paint\r\n this.message$[0].getBoundingClientRect();\r\n\r\n this.message$.addClass('active');\r\n\r\n setTimeout(()=>{\r\n this.message$.removeClass('active');\r\n\r\n setTimeout(this.cleanUp.bind(this), 400);\r\n }, 4000);\r\n }\r\n\r\n cleanUp(){\r\n this.message$.remove();\r\n }\r\n}\r\n\r\nAudienceSessionRestoreDetection.initDefault = function(){\r\n return new AudienceSessionRestoreDetection();\r\n}\r\n"],"mappings":";;;;;;AAAA;AAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAEVA,+BAA+B;EAE1C,2CAAa;IAAA;IACX;IACA;IACA,IAAGC,QAAQ,CAACC,IAAI,KAAK,kBAAkB,EAAC;MACtC;IACF;IAGA,IAAI,CAACC,UAAU,EAAE;;IAEjB;IACA;IACA;IACA;IACA;IACA,IAAGF,QAAQ,CAACG,QAAQ,CAACC,MAAM,CAAC,6CAA6C,CAAC,IAAI,CAAC,IAAIC,QAAQ,CAACC,QAAQ,CAACC,OAAO,CAACP,QAAQ,CAACQ,QAAQ,CAAC,IAAI,CAAC,EAAC;MACnI;MACA;MACA;MACA;IACF;IAEA,IAAIC,OAAO,GAAGC,eAAe,CAACC,cAAc,CAACC,OAAO,CAAC,qBAAqB,EAAE,MAAM,GAAGF,eAAe,CAACG,YAAY,GAAG,OAAO,CAAC,CAACD,OAAO,CAAC,eAAe,EAAE,MAAM,GAAGF,eAAe,CAACI,OAAO,GAAG,OAAO,CAAC;IACjM,IAAI,CAACC,eAAe,2EAEdN,OAAO,yBAEZ;IACD,IAAI,CAACO,QAAQ,GAAG,IAAAC,kBAAC,EAAC,IAAI,CAACF,eAAe,CAAC;IAEvC,IAAI,CAACG,IAAI,EAAE;EACb;EAAC;IAAA;IAAA,OAED,gBAAM;MACJ,IAAI,CAACC,WAAW,EAAE;IACpB;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,sBAAc;MACZ,IAAI;QACFC,OA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