@times-components/article-comments 0.30.5 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.31.0](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.30.5...@times-components/article-comments@0.31.0) (2022-09-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * **TDP-000:** Commenting re-auth testing ([#3148](https://github.com/newsuk/times-components/issues/3148)) ([7e9c2db](https://github.com/newsuk/times-components/commit/7e9c2db20297fd512a0b9cd870112f2030c57853))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.30.5](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.30.4...@times-components/article-comments@0.30.5) (2022-09-07)
7
18
 
8
19
 
@@ -7,22 +7,35 @@ exports.default = exports.ssoCallback = void 0;
7
7
 
8
8
  /* eslint-env browser */
9
9
  const loginRequest = (url, completeSSOCallback) => {
10
+ console.log("loginRequest", 1);
10
11
  const xhr = new XMLHttpRequest();
12
+ console.log("loginRequest", 2);
11
13
  xhr.addEventListener("load", () => {
14
+ console.log("loginRequest", 6);
12
15
  const success = xhr.status === 200;
16
+ console.log("loginRequest", 7);
13
17
 
14
18
  const _ref = success ? JSON.parse(xhr.response) : {},
15
19
  spotimCodeB = _ref.spotimCodeB;
16
20
 
21
+ console.log("loginRequest", 8);
22
+
17
23
  if (spotimCodeB) {
24
+ console.log("loginRequest", 9);
18
25
  completeSSOCallback(spotimCodeB);
19
26
  }
20
27
  });
28
+ console.log("loginRequest", 3);
21
29
  xhr.open("GET", url);
30
+ console.log("loginRequest", 4);
22
31
  xhr.send();
32
+ console.log("loginRequest", 5);
23
33
  };
24
34
 
25
- const ssoCallback = (codeA, completeSSOCallback) => loginRequest("/api/comments/loginv2?codeA=".concat(encodeURIComponent(codeA)), completeSSOCallback);
35
+ const ssoCallback = (codeA, completeSSOCallback) => {
36
+ console.log("ssoCallback");
37
+ loginRequest("/api/comments/loginv2?codeA=".concat(encodeURIComponent(codeA)), completeSSOCallback);
38
+ };
26
39
 
27
40
  exports.ssoCallback = ssoCallback;
28
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@times-components/article-comments",
3
- "version": "0.30.5",
3
+ "version": "0.31.0",
4
4
  "description": "Article Comments",
5
5
  "main": "dist/article-comments",
6
6
  "dev": "src/article-comments",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "768c0d58bb01b55db27bc09c050d5520520db28f"
71
+ "gitHead": "a3cd34976e65a2322fb30811aae985317cccc663"
72
72
  }
package/rnw.js CHANGED
@@ -1 +1 @@
1
- module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(5),n(2)),a=n.n(r),m=n(4),c=n(3),s=n.n(c),l=n(0);const d=s.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],l.breakpoints.medium,l.breakpoints.wide),u=(s.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",';font-family:"','";font-size:',"px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.primary,l.fonts.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6)),f=(e,t)=>((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const e=(200===n.status?JSON.parse(n.response):{}).spotimCodeB;e&&t(e)}),n.open("GET",e),n.send()})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t);var g=e=>{if(window.SPOTIM&&window.SPOTIM.startSSO){window.SPOTIM.startSSO(f),e();window.location.search.includes("enableRealNameReauthentication")&&window.localStorage.setItem("isUsingRealNameCommenting",!0)}},C=n(6);function b(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}const h={gb:"https://thetimes.co.uk/subscribe/digital?ILC=GB-TNL_The_Times-Conversion_Page-Homepage-2020",ie:"https://store.thetimes.ie/?ILC=IE-TNL_The_Times-Conversion_Page-Homepage-2020",global:"https://globalstore.thetimes.co.uk/?ILC=INTL-TNL_The_Times-Conversion_Page-Homepage-2020"},v=function(){var e,t=(e=function*(e){if(!e)return!1;const t="/api/comments/display-names-pseudonyms?username=".concat(e),n=fetch(t).then(e=>e.json()).then(e=>e),o=(yield n).isPseudonym;return o||!1},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){b(r,o,i,a,m,"next",e)}function m(e){b(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}();function w(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}class y extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.publishedTime,i=e.commentingConfig,r=e.onCommentStart,a=e.onCommentPost,m=e.onCommentNotification,c=e.onCommentFilterNewest,s=e.onCommentFilterMostRecommended,l=e.onCommentFilterOldest,d=e.onCommentReplyClick,u=e.onCommentShareLink,p=e.onCommentShareTwitter,f=e.onCommentShareEmail,C=e.onCommentShareFacebook,b=e.onCommentRecommend,h=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,O=e.onCommentSettingsClicked;if(!this.container||!t||!i)return;let k=i.account.readOnly;if(i&&i.switchOver){o>i.switchOver&&(k=i.account.current)}const N=window.location.search.includes("enableRealNameCommenting"),S=window.location.search.includes("enableRealNameReauthentication");document.addEventListener("spot-im-current-user-typing-start",function(){var e,t=(e=function*(e){if(r(e),N){const e=(()=>{const e=window.localStorage.getItem("SPOTIM_CURRENT_USER");return e&&(e&&JSON.parse(e)).data.displayName||!1})();if(!e)return;(yield v(e))&&window.dispatchEvent(new CustomEvent("SHOW_REAL_NAME_COMMENTING_BANNER",{}))}},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){w(r,o,i,a,m,"next",e)}function m(e){w(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),{once:!0}),document.addEventListener("spot-im-current-user-sent-message",a),document.addEventListener("spot-im-notification-drop-down-link",m),document.addEventListener("spot-im-user-up-vote-click",b),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return s(e);case"oldest":return l(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",d),document.addEventListener("spot-im-clicked-settings",O),document.addEventListener("spot-im-user-notifications-click",h),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return u(e);case"email":return f(e);case"twitter":return p(e);case"facebook":return C(e);default:return null}})(e)),document.addEventListener("spot-im-user-auth-success",()=>{S&&(window.localStorage.getItem("isUsingRealNameCommenting")||(window.localStorage.removeItem("SPOTIM_DEVICE_V2"),window.localStorage.removeItem("SPOTIM_CURRENT_USER"),window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN"),window.localStorage.removeItem("SPOT_AB"),window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2"),g(()=>{})))}),n||(window.SPOTIM&&window.SPOTIM.startSSO?g(()=>{}):document.addEventListener("spot-im-api-ready",()=>{g(()=>{})}));const E=document.createElement("script");E.setAttribute("async","async"),E.setAttribute("src","https://launcher.spot.im/spot/".concat(k)),E.setAttribute("data-spotim-module","spotim-launcher"),E.setAttribute("data-post-id",t),E.setAttribute("data-post-url","https://www.thetimes.co.uk/article/".concat(t)),E.setAttribute("data-seo-enabled",!0),E.setAttribute("data-livefyre-url",t),this.container.appendChild(E)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,l=e.onCommentShareTwitter,u=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(d,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:u,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}y.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var O,k=(O=y,Object(C.withTrackEvents)(O,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]})),N=n(7);function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:E(E({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:E(E({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var R=_(_({},P),{},{link:_(_({},P.link),{},{fontFamily:l.fonts.supporting,fontSize:l.fontSizes.commentsGuidelines})});var x=()=>i.a.createElement(d,null,i.a.createElement(p,null,"Comments for this article have been turned off"),i.a.createElement(u,null,"Comments are subject to our community guidelines, which can be viewed"," ",i.a.createElement(N.TextLink,{style:R.link,url:"https://www.thetimes.co.uk/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),"."));function L(){const e=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,t=e?null:(()=>{const e="undefined"!=typeof window&&window.nuk&&window.nuk.region;return h[e]||h.gb})(),n=e?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(m.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:t,onClick:n},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")}const M=e=>{let t=e.articleId,n=e.publishedTime,o=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig;return o?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.metered},i.a.createElement(L,null)),i.a.createElement(a.a,{state:a.a.subscriber},i.a.createElement(d,null,i.a.createElement(m.HiddenDiv,{className:"comment-banner"})),i.a.createElement(k,{articleId:t,publishedTime:n,isReadOnly:r,commentingConfig:c}))):i.a.createElement(x,null)};M.defaultProps={isReadOnly:!1};t.default=M}]);
1
+ module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(5),n(2)),a=n.n(r),m=n(4),c=n(3),s=n.n(c),l=n(0);const u=s.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],l.breakpoints.medium,l.breakpoints.wide),d=(s.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",';font-family:"','";font-size:',"px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.primary,l.fonts.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6)),f=(e,t)=>{console.log("ssoCallback"),((e,t)=>{console.log("loginRequest",1);const n=new XMLHttpRequest;console.log("loginRequest",2),n.addEventListener("load",()=>{console.log("loginRequest",6);const e=200===n.status;console.log("loginRequest",7);const o=(e?JSON.parse(n.response):{}).spotimCodeB;console.log("loginRequest",8),o&&(console.log("loginRequest",9),t(o))}),console.log("loginRequest",3),n.open("GET",e),console.log("loginRequest",4),n.send(),console.log("loginRequest",5)})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t)};var g=e=>{if(window.SPOTIM&&window.SPOTIM.startSSO){window.SPOTIM.startSSO(f),e();window.location.search.includes("enableRealNameReauthentication")&&window.localStorage.setItem("isUsingRealNameCommenting",!0)}},C=n(6);function b(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}const h={gb:"https://thetimes.co.uk/subscribe/digital?ILC=GB-TNL_The_Times-Conversion_Page-Homepage-2020",ie:"https://store.thetimes.ie/?ILC=IE-TNL_The_Times-Conversion_Page-Homepage-2020",global:"https://globalstore.thetimes.co.uk/?ILC=INTL-TNL_The_Times-Conversion_Page-Homepage-2020"},v=function(){var e,t=(e=function*(e){if(!e)return!1;const t="/api/comments/display-names-pseudonyms?username=".concat(e),n=fetch(t).then(e=>e.json()).then(e=>e),o=(yield n).isPseudonym;return o||!1},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){b(r,o,i,a,m,"next",e)}function m(e){b(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}();function w(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}class y extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.publishedTime,i=e.commentingConfig,r=e.onCommentStart,a=e.onCommentPost,m=e.onCommentNotification,c=e.onCommentFilterNewest,s=e.onCommentFilterMostRecommended,l=e.onCommentFilterOldest,u=e.onCommentReplyClick,d=e.onCommentShareLink,p=e.onCommentShareTwitter,f=e.onCommentShareEmail,C=e.onCommentShareFacebook,b=e.onCommentRecommend,h=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,O=e.onCommentSettingsClicked;if(!this.container||!t||!i)return;let k=i.account.readOnly;if(i&&i.switchOver){o>i.switchOver&&(k=i.account.current)}const N=window.location.search.includes("enableRealNameCommenting"),S=window.location.search.includes("enableRealNameReauthentication");document.addEventListener("spot-im-current-user-typing-start",function(){var e,t=(e=function*(e){if(r(e),N){const e=(()=>{const e=window.localStorage.getItem("SPOTIM_CURRENT_USER");return e&&(e&&JSON.parse(e)).data.displayName||!1})();if(!e)return;(yield v(e))&&window.dispatchEvent(new CustomEvent("SHOW_REAL_NAME_COMMENTING_BANNER",{}))}},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){w(r,o,i,a,m,"next",e)}function m(e){w(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),{once:!0}),document.addEventListener("spot-im-current-user-sent-message",a),document.addEventListener("spot-im-notification-drop-down-link",m),document.addEventListener("spot-im-user-up-vote-click",b),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return s(e);case"oldest":return l(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",u),document.addEventListener("spot-im-clicked-settings",O),document.addEventListener("spot-im-user-notifications-click",h),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return d(e);case"email":return f(e);case"twitter":return p(e);case"facebook":return C(e);default:return null}})(e)),document.addEventListener("spot-im-user-auth-success",()=>{S&&(window.localStorage.getItem("isUsingRealNameCommenting")||(window.localStorage.removeItem("SPOTIM_DEVICE_V2"),window.localStorage.removeItem("SPOTIM_CURRENT_USER"),window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN"),window.localStorage.removeItem("SPOT_AB"),window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2"),g(()=>{})))}),n||(window.SPOTIM&&window.SPOTIM.startSSO?g(()=>{}):document.addEventListener("spot-im-api-ready",()=>{g(()=>{})}));const E=document.createElement("script");E.setAttribute("async","async"),E.setAttribute("src","https://launcher.spot.im/spot/".concat(k)),E.setAttribute("data-spotim-module","spotim-launcher"),E.setAttribute("data-post-id",t),E.setAttribute("data-post-url","https://www.thetimes.co.uk/article/".concat(t)),E.setAttribute("data-seo-enabled",!0),E.setAttribute("data-livefyre-url",t),this.container.appendChild(E)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,l=e.onCommentShareTwitter,d=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(u,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:d,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}y.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var O,k=(O=y,Object(C.withTrackEvents)(O,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]})),N=n(7);function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:E(E({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:E(E({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function R(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?R(Object(n),!0).forEach((function(t){_(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var I=T(T({},P),{},{link:T(T({},P.link),{},{fontFamily:l.fonts.supporting,fontSize:l.fontSizes.commentsGuidelines})});var x=()=>i.a.createElement(u,null,i.a.createElement(p,null,"Comments for this article have been turned off"),i.a.createElement(d,null,"Comments are subject to our community guidelines, which can be viewed"," ",i.a.createElement(N.TextLink,{style:I.link,url:"https://www.thetimes.co.uk/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),"."));function L(){const e=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,t=e?null:(()=>{const e="undefined"!=typeof window&&window.nuk&&window.nuk.region;return h[e]||h.gb})(),n=e?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(m.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:t,onClick:n},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")}const M=e=>{let t=e.articleId,n=e.publishedTime,o=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig;return o?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.metered},i.a.createElement(L,null)),i.a.createElement(a.a,{state:a.a.subscriber},i.a.createElement(u,null,i.a.createElement(m.HiddenDiv,{className:"comment-banner"})),i.a.createElement(k,{articleId:t,publishedTime:n,isReadOnly:r,commentingConfig:c}))):i.a.createElement(x,null)};M.defaultProps={isReadOnly:!1};t.default=M}]);