@times-components/article-comments 0.31.0 → 0.32.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,25 @@
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.32.0](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.31.1...@times-components/article-comments@0.32.0) (2022-09-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * **TDP-000:** commenting pass cpn for reauthentication ([#3152](https://github.com/newsuk/times-components/issues/3152)) ([306428e](https://github.com/newsuk/times-components/commit/306428e88704b96f949bd45e42a74df879997231))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.31.1](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.31.0...@times-components/article-comments@0.31.1) (2022-09-13)
18
+
19
+ **Note:** Version bump only for package @times-components/article-comments
20
+
21
+
22
+
23
+
24
+
6
25
  # [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
26
 
8
27
 
@@ -7,51 +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);
11
10
  const xhr = new XMLHttpRequest();
12
- console.log("loginRequest", 2);
13
11
  xhr.addEventListener("load", () => {
14
- console.log("loginRequest", 6);
15
12
  const success = xhr.status === 200;
16
- console.log("loginRequest", 7);
17
13
 
18
14
  const _ref = success ? JSON.parse(xhr.response) : {},
19
15
  spotimCodeB = _ref.spotimCodeB;
20
16
 
21
- console.log("loginRequest", 8);
22
-
23
17
  if (spotimCodeB) {
24
- console.log("loginRequest", 9);
25
18
  completeSSOCallback(spotimCodeB);
26
19
  }
27
20
  });
28
- console.log("loginRequest", 3);
29
21
  xhr.open("GET", url);
30
- console.log("loginRequest", 4);
31
22
  xhr.send();
32
- console.log("loginRequest", 5);
33
23
  };
34
24
 
35
- const ssoCallback = (codeA, completeSSOCallback) => {
36
- console.log("ssoCallback");
37
- loginRequest("/api/comments/loginv2?codeA=".concat(encodeURIComponent(codeA)), completeSSOCallback);
38
- };
25
+ const ssoCallback = (codeA, completeSSOCallback) => loginRequest("/api/comments/loginv2?codeA=".concat(encodeURIComponent(codeA)), completeSSOCallback);
39
26
 
40
27
  exports.ssoCallback = ssoCallback;
41
28
 
42
- const setNewUserToken = () => {
43
- window.localStorage.setItem("isUsingRealNameCommenting", true);
44
- };
45
-
46
- const executeSSOtransaction = callback => {
29
+ const executeSSOtransaction = cpn => {
47
30
  if (window.SPOTIM && window.SPOTIM.startSSO) {
48
- window.SPOTIM.startSSO(ssoCallback);
49
- callback();
50
- const isRealNameReauthenticationEnabled = window.location.search.includes("enableRealNameReauthentication");
51
-
52
- if (isRealNameReauthenticationEnabled) {
53
- setNewUserToken();
31
+ if (window.location.search.includes("enableRealNameReauthentication")) {
32
+ window.localStorage.setItem("isUsingRealNameCommentingV2", true);
54
33
  }
34
+
35
+ window.SPOTIM.startSSO({
36
+ callback: ssoCallback,
37
+ userId: cpn
38
+ });
55
39
  }
56
40
  };
57
41
 
package/dist/comments.js CHANGED
@@ -112,13 +112,13 @@ class Comments extends _react.Component {
112
112
  }
113
113
  }
114
114
 
115
- const isRealNameCommentingEnabled = window.location.search.includes("enableRealNameCommenting");
116
- const isRealNameReauthenticationEnabled = window.location.search.includes("enableRealNameReauthentication");
115
+ const acsTnlCookie = window && window.nuk && window.nuk.getCookieValue && window.nuk.getCookieValue("acs_tnl");
116
+ const cpn = (0, _utils.getCpnId)(acsTnlCookie);
117
117
  document.addEventListener("spot-im-current-user-typing-start", /*#__PURE__*/function () {
118
118
  var _ref = _asyncToGenerator(function* (event) {
119
119
  onCommentStart(event);
120
120
 
121
- if (isRealNameCommentingEnabled) {
121
+ if (window.location.search.includes("enableRealNameCommenting")) {
122
122
  const displayName = (0, _utils.getDisplayNameFromLocalStorage)();
123
123
  if (!displayName) return;
124
124
  const shouldShowBanner = yield (0, _utils.userShouldUpdateName)(displayName);
@@ -145,24 +145,19 @@ class Comments extends _react.Component {
145
145
  document.addEventListener("spot-im-open-user-profile", onCommentUsernameClicked);
146
146
  document.addEventListener("spot-im-share-type", event => getShareEvent(event));
147
147
  document.addEventListener("spot-im-user-auth-success", () => {
148
- if (isRealNameReauthenticationEnabled) {
149
- if (!(0, _utils.hasRealNameCommentingToken)()) {
150
- window.localStorage.removeItem("SPOTIM_DEVICE_V2");
151
- window.localStorage.removeItem("SPOTIM_CURRENT_USER");
152
- window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN");
153
- window.localStorage.removeItem("SPOT_AB");
154
- window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2");
155
- (0, _commentLogin.default)(() => {});
148
+ if (window.location.search.includes("enableRealNameReauthentication")) {
149
+ if (!window.localStorage.getItem("isUsingRealNameCommentingV2")) {
150
+ (0, _commentLogin.default)("".concat(cpn, "_v2"));
156
151
  }
157
152
  }
158
153
  });
159
154
 
160
155
  if (!isReadOnly) {
161
156
  if (window.SPOTIM && window.SPOTIM.startSSO) {
162
- (0, _commentLogin.default)(() => {});
157
+ (0, _commentLogin.default)(cpn);
163
158
  } else {
164
159
  document.addEventListener("spot-im-api-ready", () => {
165
- (0, _commentLogin.default)(() => {});
160
+ (0, _commentLogin.default)(cpn);
166
161
  });
167
162
  }
168
163
  }
package/dist/utils.js CHANGED
@@ -3,7 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.getDisplayNameFromLocalStorage = exports.hasRealNameCommentingToken = exports.userShouldUpdateName = void 0;
6
+ exports.default = exports.getCpnId = exports.getDisplayNameFromLocalStorage = exports.userShouldUpdateName = void 0;
7
+
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
+
16
+ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
17
+
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
19
 
8
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
21
 
@@ -42,13 +54,6 @@ const userShouldUpdateName = /*#__PURE__*/function () {
42
54
 
43
55
  exports.userShouldUpdateName = userShouldUpdateName;
44
56
 
45
- const hasRealNameCommentingToken = () => {
46
- const getRealNameCommentingToken = window.localStorage.getItem("isUsingRealNameCommenting");
47
- return getRealNameCommentingToken;
48
- };
49
-
50
- exports.hasRealNameCommentingToken = hasRealNameCommentingToken;
51
-
52
57
  const getDisplayNameFromLocalStorage = () => {
53
58
  const spotimUserDetails = window.localStorage.getItem("SPOTIM_CURRENT_USER");
54
59
  if (!spotimUserDetails) return false;
@@ -59,6 +64,20 @@ const getDisplayNameFromLocalStorage = () => {
59
64
 
60
65
  exports.getDisplayNameFromLocalStorage = getDisplayNameFromLocalStorage;
61
66
 
67
+ const parseCookie = cookie => cookie.split("&").reduce((acc, param) => {
68
+ const _param$split = param.split("="),
69
+ _param$split2 = _slicedToArray(_param$split, 2),
70
+ key = _param$split2[0],
71
+ value = _param$split2[1];
72
+
73
+ acc[key] = value;
74
+ return acc;
75
+ }, {});
76
+
77
+ const getCpnId = cookie => cookie ? parseCookie(cookie).eid : undefined;
78
+
79
+ exports.getCpnId = getCpnId;
80
+
62
81
  var _default = () => {
63
82
  const region = // eslint-disable-next-line no-undef
64
83
  typeof window !== "undefined" && window.nuk && window.nuk.region;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@times-components/article-comments",
3
- "version": "0.31.0",
3
+ "version": "0.32.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": "a3cd34976e65a2322fb30811aae985317cccc663"
71
+ "gitHead": "00972be5bee492a7e0c18355876ce5e8edb5d973"
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 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}]);
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)=>((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=>{window.SPOTIM&&window.SPOTIM.startSSO&&(window.location.search.includes("enableRealNameReauthentication")&&window.localStorage.setItem("isUsingRealNameCommentingV2",!0),window.SPOTIM.startSSO({callback:f,userId:e}))},C=n(6);function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,m=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){m=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(m)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function v(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 y={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"},w=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){v(r,o,i,a,m,"next",e)}function m(e){v(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),k=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=b(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;function O(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 N 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,v=e.onCommentUsernameClicked,y=e.onCommentSettingsClicked;if(!this.container||!t||!i)return;let N=i.account.readOnly;if(i&&i.switchOver){o>i.switchOver&&(N=i.account.current)}const S=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),E=k(S);document.addEventListener("spot-im-current-user-typing-start",function(){var e,t=(e=function*(e){if(r(e),window.location.search.includes("enableRealNameCommenting")){const e=(()=>{const e=window.localStorage.getItem("SPOTIM_CURRENT_USER");return e&&(e&&JSON.parse(e)).data.displayName||!1})();if(!e)return;(yield w(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){O(r,o,i,a,m,"next",e)}function m(e){O(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",y),document.addEventListener("spot-im-user-notifications-click",h),document.addEventListener("spot-im-open-user-profile",v),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",()=>{window.location.search.includes("enableRealNameReauthentication")&&(window.localStorage.getItem("isUsingRealNameCommentingV2")||g("".concat(E,"_v2")))}),n||(window.SPOTIM&&window.SPOTIM.startSSO?g(E):document.addEventListener("spot-im-api-ready",()=>{g(E)}));const j=document.createElement("script");j.setAttribute("async","async"),j.setAttribute("src","https://launcher.spot.im/spot/".concat(N)),j.setAttribute("data-spotim-module","spotim-launcher"),j.setAttribute("data-post-id",t),j.setAttribute("data-post-url","https://www.thetimes.co.uk/article/".concat(t)),j.setAttribute("data-seo-enabled",!0),j.setAttribute("data-livefyre-url",t),this.container.appendChild(j)}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}}))}}N.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var S,E=(S=N,Object(C.withTrackEvents)(S,{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"}]})),j=n(7);function P(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?P(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function x(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={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:T(T({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:T(T({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function _(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 L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(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 F=L(L({},R),{},{link:L(L({},R.link),{},{fontFamily:l.fonts.supporting,fontSize:l.fontSizes.commentsGuidelines})});var M=()=>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(j.TextLink,{style:F.link,url:"https://www.thetimes.co.uk/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),"."));function A(){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 y[e]||y.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 U=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(A,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(E,{articleId:t,publishedTime:n,isReadOnly:r,commentingConfig:c}))):i.a.createElement(M,null)};U.defaultProps={isReadOnly:!1};t.default=U}]);