{"version":3,"file":"loadComments.0.18.1.js","sources":["webpack:///loadComments.0.18.1.js"],"sourcesContent":["(window.mvtrellisJsonp=window.mvtrellisJsonp||[]).push([[6],{3:function(e,t,n){\"use strict\";n.d(t,\"a\",(function(){return r}));var r=function(e){var t={};e.root&&(t.root=e.root),e.headers&&(t.headers=e.headers);var n=function(e,n){var r,a=e,o=null!=t&&null!==(r=t.root)&&void 0!==r&&r.includes(\"?\")?e.replace(\"?\",\"&\"):e;t&&t.root&&(a=\"\".concat(t.root).concat(o));var c=n;if(t&&t.headers&&(c.headers=t.headers),!c.headers){var i=new Headers;i.append(\"Content-Type\",\"application/json\"),i.append(\"Accept\",\"application/json\"),c.headers=i}return fetch(a,c).then((function(e){return e.json().then((function(t){var n={};n.data=t,n.ok=e.ok;var r={};return e.headers.forEach((function(e,t){r[t]=e})),n.headers=r,n}))})).then((function(e){return e.ok?e:Promise.reject(e)})).catch((function(e){return Promise.reject(e)}))};return{get:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r={method:\"GET\"};if(t){var a=Object.keys(t).map((function(e){return\"\".concat(e,\"=\").concat(encodeURIComponent(t[e]))})).join(\"&\");e=\"\".concat(e,\"?\").concat(a)}return n(e,r)},post:function(e,t){var r={method:\"POST\",body:JSON.stringify(t)};return n(e,r)},put:function(e,t){var r={method:\"PUT\",body:JSON.stringify(t)};return n(e,r)},delete:function(e,t){var r={method:\"DELETE\",body:JSON.stringify(t)};return n(e,r)}}}},31:function(e,t,n){\"use strict\";var r=/%(?:\\d\\$)?s/,a=function(e){var t,n=window.mvt.i18n[e.toUpperCase().replace(\" \",\"_\")];return n?n.match(r)?(t=n,function(){for(var e=arguments.length,n=new Array(e),a=0;at.id?1:-1}))}},45:function(e,t,n){\"use strict\";(function(e){var r=n(40),a=n.n(r),o=n(1),c=n.n(o),i=n(34),u=n.n(i),s=n(35),l=n.n(s),m=n(32),d=n.n(m),f=n(36),p=n.n(f),h=n(37),v=n.n(h),g=n(38),b=n.n(g),E=n(33),C=n.n(E),O=n(0),w=n.n(O),y=n(30),_=n(43),j=n(54),S=n(31),R=(n(56),n(42));function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t2&&void 0!==s[2]?s[2]:1,e.next=3,I.get(\"wp/v2/comments?post=\".concat(t,\"&order=\").concat(n,\"&per_page=100&page=\").concat(a));case 3:if(o=e.sent,c=(null==o?void 0:o.data)||[],i=r.mergeComments(c),u=r.prepCommentState(i),r.timeout=setTimeout((function(){r.setState({comments:i,totalComments:u.totalComments,pagedComments:u.pagedComments,totalPages:u.totalPages,totalCommentsWithChildren:u.totalCommentsWithChildren,childComments:u.childComments})}),0),!(o.headers[\"x-wp-totalpages\"]>a)){e.next=11;break}return e.next=11,r.getAllComments(t,n,a+1);case 11:return e.abrupt(\"return\",i);case 12:case\"end\":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),C()(d()(r),\"getComments\",a()(w.a.mark((function e(){var t;return w.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=\"asc\"===window.mvt.comments.order?\"asc\":\"desc\",e.next=3,r.getAllComments(r.props.postId,t);case 3:e.sent,r.setState((function(e){return{currentPage:e.currentPage+1}}));case 5:case\"end\":return e.stop()}}),e)})))),C()(d()(r),\"mergeComments\",(function(e){var t=r.state.comments,n=r.props.postId,a=Object(x.c)(\"comments\"),o=a&&a.filter((function(e){return 0===e.parent&&e.post===n}))||[],i=o.filter((function(t){var n=t.id;return e.find((function(e){return e.id===n}))}));Object(x.b)(i);var u=[].concat(c()(t),c()(o.filter((function(t){var n=t.id;return!e.find((function(e){return e.id===n}))}))),c()(e));return Object(x.f)(u,window.mvt.comments.order)})),C()(d()(r),\"handleSubmit\",function(){var e=a()(w.a.mark((function e(t){var n,a;return w.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.meta={},new FormData(r.proxyForm).forEach((function(e,n){n.startsWith(\"_\")||(t.meta[n]=e)})),e.next=5,I.post(\"wp/v2/comments\",t);case 5:return n=e.sent,a=n.data,r.setState((function(e){return{comments:[a].concat(c()(e.comments)),totalComments:e.totalComments+1,pendingComments:[].concat(c()(e.pendingComments),[a])}})),e.abrupt(\"return\",a);case 9:case\"end\":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),C()(d()(r),\"handleLoadMore\",(function(){r.setState((function(e){return{currentPage:e.currentPage+1}}))})),r.proxyForm=r.props.form,r.proxyForm&&document.body.appendChild(r.proxyForm),r.state={comments:[],pagedComments:[[]],pendingComments:[],currentPage:0,totalComments:0,totalPages:0,totalCommentsWithChildren:0},r}return l()(n,[{key:\"componentWillUnmount\",value:function(){this.timeout&&clearTimeout(this.timeout)}},{key:\"render\",value:function(){var e=this,t=this.state,n=t.comments,r=t.totalComments,a=t.pagedComments,o=t.pendingComments,i=t.currentPage,u=t.totalPages,s=t.totalCommentsWithChildren,l=t.childComments,m=[].concat(c()(o||[]),c()((null==a?void 0:a.filter((function(e,t){return t0&&y.default.createElement(\"p\",{className:\"post-title\"},\"Comments are closed\"),m.map((function(t){var n=l.filter((function(e){return e.parent===t.id}));return y.default.createElement(P.a,{key:t.id,comment:t,postId:e.props.postId,parentComment:t.parent,children:n,childComments:l})})),0!==n.length&&u>1&&i+1<=u&&m.length