disqusjs
Version:
Alternative DISQUS - Render comments components from Disqus API
2 lines (1 loc) • 33.8 kB
JavaScript
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n,t,r,o,l,_,i,s,u,c,a,d,f,h={},p=[],m=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,n){for(var t in n)e[t]=n[t];return e}function g(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(e,n,r){var o,l,_,i={};for(_ in n)"key"==_?o=n[_]:"ref"==_?l=n[_]:i[_]=n[_];if(arguments.length>2&&(i.children=arguments.length>3?t.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(_ in e.defaultProps)void 0===i[_]&&(i[_]=e.defaultProps[_]);return q(e,i,o,l,null)}function q(e,n,t,l,_){var i={type:e,props:n,key:t,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==_?++o:_,__i:-1,__u:0};return null==_&&null!=r.vnode&&r.vnode(i),i}function k(e){return e.children}function w(e,n){this.props=e,this.context=n}function j(e,n){if(null==n)return e.__?j(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e)return t.__e;return"function"==typeof e.type?j(e):null}function N(e){(!e.__d&&(e.__d=!0)&&l.push(e)&&!S.__r++||_!=r.debounceRendering)&&((_=r.debounceRendering)||i)(S)}function S(){for(var e,n,t,o,_,i,u=1;l.length;)l.length>u&&l.sort(s),e=l.shift(),u=l.length,e.__d&&(n=void 0,t=void 0,o=(t=e.__v).__e,_=[],i=[],e.__P&&((n=y({},t)).__v=t.__v+1,r.vnode&&r.vnode(n),D(e.__P,n,t,e.__n,e.__P.namespaceURI,32&t.__u?[o]:null,_,null==o?j(t):o,!!(32&t.__u),i),n.__v=t.__v,n.__.__k[n.__i]=n,A(_,n,i),t.__e=t.__=null,n.__e!=o&&function e(n){var t,r;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,t=0;t<n.__k.length;t++)if(null!=(r=n.__k[t])&&null!=r.__e){n.__e=n.__c.base=r.__e;break}return e(n)}}(n)));S.__r=0}function C(e,n,t,o,l,_,i,s,u,c,a){var d,f,m,y,b,w,N,S=o&&o.__k||p,C=n.length;for(u=function(e,n,t,o,l){var _,i,s,u,c,a=t.length,d=a,f=0;for(e.__k=Array(l),_=0;_<l;_++)null!=(i=n[_])&&"boolean"!=typeof i&&"function"!=typeof i?(u=_+f,(i=e.__k[_]="string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?q(null,i,null,null,null):v(i)?q(k,{children:i},null,null,null):null==i.constructor&&i.__b>0?q(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,s=null,-1!=(c=i.__i=function(e,n,t,r){var o,l,_,i=e.key,s=e.type,u=n[t],c=null!=u&&0==(2&u.__u);if(null===u&&null==e.key||c&&i==u.key&&s==u.type)return t;if(r>+!!c){for(o=t-1,l=t+1;o>=0||l<n.length;)if(null!=(u=n[_=o>=0?o--:l++])&&0==(2&u.__u)&&i==u.key&&s==u.type)return _}return -1}(i,t,u,d))&&(d--,(s=t[c])&&(s.__u|=2)),null==s||null==s.__v?(-1==c&&(l>a?f--:l<a&&f++),"function"!=typeof i.type&&(i.__u|=4)):c!=u&&(c==u-1?f--:c==u+1?f++:(c>u?f--:f++,i.__u|=4))):e.__k[_]=null;if(d)for(_=0;_<a;_++)null!=(s=t[_])&&0==(2&s.__u)&&(s.__e==o&&(o=j(s)),function e(n,t,o){var l,_;if(r.unmount&&r.unmount(n),(l=n.ref)&&(l.current&&l.current!=n.__e||T(l,null,t)),null!=(l=n.__c)){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(e){r.__e(e,t)}l.base=l.__P=null}if(l=n.__k)for(_=0;_<l.length;_++)l[_]&&e(l[_],t,o||"function"!=typeof n.type);o||g(n.__e),n.__c=n.__=n.__e=void 0}(s,s));return o}(t,n,S,u,C),d=0;d<C;d++)null!=(m=t.__k[d])&&(f=-1==m.__i?h:S[m.__i]||h,m.__i=d,w=D(e,m,f,l,_,i,s,u,c,a),y=m.__e,m.ref&&f.ref!=m.ref&&(f.ref&&T(f.ref,null,m),a.push(m.ref,m.__c||y,m)),null==b&&null!=y&&(b=y),(N=!!(4&m.__u))||f.__k===m.__k?u=function e(n,t,r,o){var l,_;if("function"==typeof n.type){for(l=n.__k,_=0;l&&_<l.length;_++)l[_]&&(l[_].__=n,t=e(l[_],t,r,o));return t}n.__e!=t&&(o&&(t&&n.type&&!t.parentNode&&(t=j(n)),r.insertBefore(n.__e,t||null)),t=n.__e);do t=t&&t.nextSibling;while(null!=t&&8==t.nodeType);return t}(m,u,e,N):"function"==typeof m.type&&void 0!==w?u=w:y&&(u=y.nextSibling),m.__u&=-7);return t.__e=b,u}function x(e,n){return n=n||[],null==e||"boolean"==typeof e||(v(e)?e.some(function(e){x(e,n)}):n.push(e)),n}function P(e,n,t){"-"==n[0]?e.setProperty(n,null==t?"":t):e[n]=null==t?"":"number"!=typeof t||m.test(n)?t:t+"px"}function E(e,n,t,r,o){var l,_;e:if("style"==n)if("string"==typeof t)e.style.cssText=t;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(n in r)t&&n in t||P(e.style,n,"");if(t)for(n in t)r&&t[n]==r[n]||P(e.style,n,t[n])}else if("o"==n[0]&&"n"==n[1])l=n!=(n=n.replace(u,"$1")),n=(_=n.toLowerCase())in e||"onFocusOut"==n||"onFocusIn"==n?_.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+l]=t,t?r?t.u=r.u:(t.u=c,e.addEventListener(n,l?d:a,l)):e.removeEventListener(n,l?d:a,l);else{if("http://www.w3.org/2000/svg"==o)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in e)try{e[n]=null==t?"":t;break e}catch(e){}"function"==typeof t||(null==t||!1===t&&"-"!=n[4]?e.removeAttribute(n):e.setAttribute(n,"popover"==n&&1==t?"":t))}}function U(e){return function(n){if(this.l){var t=this.l[n.type+e];if(null==n.t)n.t=c++;else if(n.t<t.u)return;return t(r.event?r.event(n):n)}}}function D(e,n,o,l,_,i,s,u,c,a){var d,f,p,m,b,q,N,S,x,P,U,D,A,T,I,M,R,W=n.type;if(null!=n.constructor)return null;128&o.__u&&(c=!!(32&o.__u),i=[u=n.__e=o.__e]),(d=r.__b)&&d(n);e:if("function"==typeof W)try{if(S=n.props,x="prototype"in W&&W.prototype.render,P=(d=W.contextType)&&l[d.__c],U=d?P?P.props.value:d.__:l,o.__c?N=(f=n.__c=o.__c).__=f.__E:(x?n.__c=f=new W(S,U):(n.__c=f=new w(S,U),f.constructor=W,f.render=$),P&&P.sub(f),f.props=S,f.state||(f.state={}),f.context=U,f.__n=l,p=f.__d=!0,f.__h=[],f._sb=[]),x&&null==f.__s&&(f.__s=f.state),x&&null!=W.getDerivedStateFromProps&&(f.__s==f.state&&(f.__s=y({},f.__s)),y(f.__s,W.getDerivedStateFromProps(S,f.__s))),m=f.props,b=f.state,f.__v=n,p)x&&null==W.getDerivedStateFromProps&&null!=f.componentWillMount&&f.componentWillMount(),x&&null!=f.componentDidMount&&f.__h.push(f.componentDidMount);else{if(x&&null==W.getDerivedStateFromProps&&S!==m&&null!=f.componentWillReceiveProps&&f.componentWillReceiveProps(S,U),!f.__e&&null!=f.shouldComponentUpdate&&!1===f.shouldComponentUpdate(S,f.__s,U)||n.__v==o.__v){for(n.__v!=o.__v&&(f.props=S,f.state=f.__s,f.__d=!1),n.__e=o.__e,n.__k=o.__k,n.__k.some(function(e){e&&(e.__=n)}),D=0;D<f._sb.length;D++)f.__h.push(f._sb[D]);f._sb=[],f.__h.length&&s.push(f);break e}null!=f.componentWillUpdate&&f.componentWillUpdate(S,f.__s,U),x&&null!=f.componentDidUpdate&&f.__h.push(function(){f.componentDidUpdate(m,b,q)})}if(f.context=U,f.props=S,f.__P=e,f.__e=!1,A=r.__r,T=0,x){for(f.state=f.__s,f.__d=!1,A&&A(n),d=f.render(f.props,f.state,f.context),I=0;I<f._sb.length;I++)f.__h.push(f._sb[I]);f._sb=[]}else do f.__d=!1,A&&A(n),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++T<25);f.state=f.__s,null!=f.getChildContext&&(l=y(y({},l),f.getChildContext())),x&&!p&&null!=f.getSnapshotBeforeUpdate&&(q=f.getSnapshotBeforeUpdate(m,b)),M=d,null!=d&&d.type===k&&null==d.key&&(M=function e(n){return"object"!=typeof n||null==n||n.__b&&n.__b>0?n:v(n)?n.map(e):y({},n)}(d.props.children)),u=C(e,v(M)?M:[M],n,o,l,_,i,s,u,c,a),f.base=n.__e,n.__u&=-161,f.__h.length&&s.push(f),N&&(f.__E=f.__=null)}catch(e){if(n.__v=null,c||null!=i)if(e.then){for(n.__u|=c?160:128;u&&8==u.nodeType&&u.nextSibling;)u=u.nextSibling;i[i.indexOf(u)]=null,n.__e=u}else{for(R=i.length;R--;)g(i[R]);H(n)}else n.__e=o.__e,n.__k=o.__k,e.then||H(n);r.__e(e,n,o)}else null==i&&n.__v==o.__v?(n.__k=o.__k,n.__e=o.__e):u=n.__e=function(e,n,o,l,_,i,s,u,c){var a,d,f,p,m,y,b,q=o.props,k=n.props,w=n.type;if("svg"==w?_="http://www.w3.org/2000/svg":"math"==w?_="http://www.w3.org/1998/Math/MathML":_||(_="http://www.w3.org/1999/xhtml"),null!=i){for(a=0;a<i.length;a++)if((m=i[a])&&"setAttribute"in m==!!w&&(w?m.localName==w:3==m.nodeType)){e=m,i[a]=null;break}}if(null==e){if(null==w)return document.createTextNode(k);e=document.createElementNS(_,w,k.is&&k),u&&(r.__m&&r.__m(n,i),u=!1),i=null}if(null==w)q===k||u&&e.data==k||(e.data=k);else{if(i=i&&t.call(e.childNodes),q=o.props||h,!u&&null!=i)for(q={},a=0;a<e.attributes.length;a++)q[(m=e.attributes[a]).name]=m.value;for(a in q)if(m=q[a],"children"==a);else if("dangerouslySetInnerHTML"==a)f=m;else if(!(a in k)){if("value"==a&&"defaultValue"in k||"checked"==a&&"defaultChecked"in k)continue;E(e,a,null,m,_)}for(a in k)m=k[a],"children"==a?p=m:"dangerouslySetInnerHTML"==a?d=m:"value"==a?y=m:"checked"==a?b=m:u&&"function"!=typeof m||q[a]===m||E(e,a,m,q[a],_);if(d)u||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),n.__k=[];else if(f&&(e.innerHTML=""),C("template"==n.type?e.content:e,v(p)?p:[p],n,o,l,"foreignObject"==w?"http://www.w3.org/1999/xhtml":_,i,s,i?i[0]:o.__k&&j(o,0),u,c),null!=i)for(a=i.length;a--;)g(i[a]);u||(a="value","progress"==w&&null==y?e.removeAttribute("value"):null==y||y===e[a]&&("progress"!=w||y)&&("option"!=w||y==q[a])||E(e,a,y,q[a],_),a="checked",null!=b&&b!=e[a]&&E(e,a,b,q[a],_))}return e}(o.__e,n,o,l,_,i,s,c,a);return(d=r.diffed)&&d(n),128&n.__u?void 0:u}function H(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(H)}function A(e,n,t){for(var o=0;o<t.length;o++)T(t[o],t[++o],t[++o]);r.__c&&r.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){r.__e(e,n.__v)}})}function T(e,n,t){try{if("function"==typeof e){var o="function"==typeof e.__u;o&&e.__u(),o&&null==n||(e.__u=e(n))}else e.current=n}catch(e){r.__e(e,t)}}function $(e,n,t){return this.constructor(e,t)}function I(e,n,o){var l,_,i;n==document&&(n=document.documentElement),r.__&&r.__(e,n),l=n.__k,_=[],i=[],D(n,e=n.__k=b(k,null,[e]),l||h,h,n.namespaceURI,l?null:n.firstChild?t.call(n.childNodes):null,_,l?l.__e:n.firstChild,!1,i),A(_,e,i)}function M(e,n,r){var o,l,_,i,s=y({},e.props);for(_ in e.type&&e.type.defaultProps&&(i=e.type.defaultProps),n)"key"==_?o=n[_]:"ref"==_?l=n[_]:s[_]=void 0===n[_]&&null!=i?i[_]:n[_];return arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),q(e.type,s,o||e.key,l||e.ref,null)}function R(e){function n(e){var t,r;return this.getChildContext||(t=new Set,(r={})[n.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){t=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&t.forEach(function(e){e.__e=!0,N(e)})},this.sub=function(e){t.add(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){t&&t.delete(e),n&&n.call(e)}}),e.children}return n.__c="__cC"+f++,n.__=e,n.Provider=n.__l=(n.Consumer=function(e,n){return e.children(n)}).contextType=n,n}t=p.slice,r={__e:function(e,n,t,r){for(var o,l,_;n=n.__;)if((o=n.__c)&&!o.__)try{if((l=o.constructor)&&null!=l.getDerivedStateFromError&&(o.setState(l.getDerivedStateFromError(e)),_=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,r||{}),_=o.__d),_)return o.__E=o}catch(n){e=n}throw e}},o=0,w.prototype.setState=function(e,n){var t;t=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=y({},this.state),"function"==typeof e&&(e=e(y({},t),this.props)),e&&y(t,e),null!=e&&this.__v&&(n&&this._sb.push(n),N(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),N(this))},w.prototype.render=k,l=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,n){return e.__v.__b-n.__v.__b},S.__r=0,u=/(PointerCapture)$|Capture$/i,c=0,a=U(!1),d=U(!0),f=0;var W,L,O,F,B=0,V=[],Q=r,z=Q.__b,J=Q.__r,Z=Q.diffed,Y=Q.__c,G=Q.unmount,K=Q.__;function X(e,n){Q.__h&&Q.__h(L,e,B||n),B=0;var t=L.__H||(L.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function ee(e){return B=1,function(e,n,t){var r=X(W++,2);if(r.t=e,!r.__c&&(r.__=[ea(void 0,n),function(e){var n=r.__N?r.__N[0]:r.__[0],t=r.t(n,e);n!==t&&(r.__N=[t,r.__[1]],r.__c.setState({}))}],r.__c=L,!L.__f)){var o=function(e,n,t){if(!r.__c.__H)return!0;var o=r.__c.__H.__.filter(function(e){return!!e.__c});if(o.every(function(e){return!e.__N}))return!l||l.call(this,e,n,t);var _=r.__c.props!==e;return o.forEach(function(e){if(e.__N){var n=e.__[0];e.__=e.__N,e.__N=void 0,n!==e.__[0]&&(_=!0)}}),l&&l.call(this,e,n,t)||_};L.__f=!0;var l=L.shouldComponentUpdate,_=L.componentWillUpdate;L.componentWillUpdate=function(e,n,t){if(this.__e){var r=l;l=void 0,o(e,n,t),l=r}_&&_.call(this,e,n,t)},L.shouldComponentUpdate=o}return r.__N||r.__}(ea,e)}function en(e,n){var t=X(W++,3);!Q.__s&&ec(t.__H,n)&&(t.__=e,t.u=n,L.__H.__h.push(t))}function et(e){return B=5,er(function(){return{current:e}},[])}function er(e,n){var t=X(W++,7);return ec(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function eo(e,n){return B=8,er(function(){return e},n)}function el(e){var n=L.context[e.__c],t=X(W++,9);return t.c=e,n?(null==t.__&&(t.__=!0,n.sub(L)),n.props.value):e.__}function e_(){for(var e;e=V.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(es),e.__H.__h.forEach(eu),e.__H.__h=[]}catch(n){e.__H.__h=[],Q.__e(n,e.__v)}}Q.__b=function(e){L=null,z&&z(e)},Q.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),K&&K(e,n)},Q.__r=function(e){J&&J(e),W=0;var n=(L=e.__c).__H;n&&(O===L?(n.__h=[],L.__h=[],n.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(n.__h.forEach(es),n.__h.forEach(eu),n.__h=[],W=0)),O=L},Q.diffed=function(e){Z&&Z(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==V.push(n)&&F===Q.requestAnimationFrame||((F=Q.requestAnimationFrame)||function(e){var n,t=function(){clearTimeout(r),ei&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(t,35);ei&&(n=requestAnimationFrame(t))})(e_)),n.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),O=L=null},Q.__c=function(e,n){n.some(function(e){try{e.__h.forEach(es),e.__h=e.__h.filter(function(e){return!e.__||eu(e)})}catch(t){n.some(function(e){e.__h&&(e.__h=[])}),n=[],Q.__e(t,e.__v)}}),Y&&Y(e,n)},Q.unmount=function(e){G&&G(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(e){try{es(e)}catch(e){n=e}}),t.__H=void 0,n&&Q.__e(n,t.__v))};var ei="function"==typeof requestAnimationFrame;function es(e){var n=L,t=e.__c;"function"==typeof t&&(e.__c=void 0,t()),L=n}function eu(e){var n=L;e.__c=e.__(),L=n}function ec(e,n){return!e||e.length!==n.length||n.some(function(n,t){return n!==e[t]})}function ea(e,n){return"function"==typeof n?n(e):n}function ed(e,n){for(var t in n)e[t]=n[t];return e}function ef(e,n){for(var t in e)if("__source"!==t&&!(t in n))return!0;for(var r in n)if("__source"!==r&&e[r]!==n[r])return!0;return!1}function eh(e,n){this.props=e,this.context=n}function ep(e,n){function t(e){var t=this.props.ref,r=t==e.ref;return!r&&t&&(t.call?t(null):t.current=null),n?!n(this.props,e)||!r:ef(this.props,e)}function r(n){return this.shouldComponentUpdate=t,b(e,n)}return r.displayName="Memo("+(e.displayName||e.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(eh.prototype=new w).isPureReactComponent=!0,eh.prototype.shouldComponentUpdate=function(e,n){return ef(this.props,e)||ef(this.state,n)};var em=r.__b;r.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),em&&em(e)};var ev="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911,ey=r.__e;r.__e=function(e,n,t,r){if(e.then){for(var o,l=n;l=l.__;)if((o=l.__c)&&o.__c)return null==n.__e&&(n.__e=t.__e,n.__k=t.__k),o.__c(e,n)}ey(e,n,t,r)};var eg=r.unmount;function eb(){this.__u=0,this.o=null,this.__b=null}function eq(e){var n=e.__.__c;return n&&n.__a&&n.__a(e)}function ek(){this.i=null,this.l=null}r.unmount=function(e){var n=e.__c;n&&n.__R&&n.__R(),n&&32&e.__u&&(e.type=null),eg&&eg(e)},(eb.prototype=new w).__c=function(e,n){var t=n.__c,r=this;null==r.o&&(r.o=[]),r.o.push(t);var o=eq(r.__v),l=!1,_=function(){l||(l=!0,t.__R=null,o?o(i):i())};t.__R=_;var i=function(){if(!--r.__u){if(r.state.__a){var e,n=r.state.__a;r.__v.__k[0]=function e(n,t,r){return n&&r&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(n){return e(n,t,r)}),n.__c&&n.__c.__P===t&&(n.__e&&r.appendChild(n.__e),n.__c.__e=!0,n.__c.__P=r)),n}(n,n.__c.__P,n.__c.__O)}for(r.setState({__a:r.__b=null});e=r.o.pop();)e.forceUpdate()}};r.__u++||32&n.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(_,_)},eb.prototype.componentWillUnmount=function(){this.o=[]},eb.prototype.render=function(e,n){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function e(n,t,r){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),n.__c.__H=null),null!=(n=ed({},n)).__c&&(n.__c.__P===r&&(n.__c.__P=t),n.__c.__e=!0,n.__c=null),n.__k=n.__k&&n.__k.map(function(n){return e(n,t,r)})),n}(this.__b,t,r.__O=r.__P)}this.__b=null}var o=n.__a&&b(k,null,e.fallback);return o&&(o.__u&=-33),[b(k,null,n.__a?null:e.children),o]};var ew=function(e,n,t){if(++t[1]===t[0]&&e.l.delete(n),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(t=e.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;e.i=t=t[2]}};(ek.prototype=new w).__a=function(e){var n=this,t=eq(n.__v),r=n.l.get(e);return r[0]++,function(o){var l=function(){n.props.revealOrder?(r.push(o),ew(n,e,r)):o()};t?t(l):l()}},ek.prototype.render=function(e){this.i=null,this.l=new Map;var n=x(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&n.reverse();for(var t=n.length;t--;)this.l.set(n[t],this.i=[1,0,this.i]);return e.children},ek.prototype.componentDidUpdate=ek.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(n,t){ew(e,t,n)})};var ej="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,eN=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,eS=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,eC=/[A-Z0-9]/g,ex="undefined"!=typeof document;w.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(w.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(n){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:n})}})});var eP=r.event;function eE(){}function eU(){return this.cancelBubble}function eD(){return this.defaultPrevented}r.event=function(e){return eP&&(e=eP(e)),e.persist=eE,e.isPropagationStopped=eU,e.isDefaultPrevented=eD,e.nativeEvent=e};var eH={enumerable:!1,configurable:!0,get:function(){return this.class}},eA=r.vnode;r.vnode=function(e){"string"==typeof e.type&&function(e){var n=e.props,t=e.type,r={},o=-1===t.indexOf("-");for(var l in n){var _=n[l];if(!("value"===l&&"defaultValue"in n&&null==_||ex&&"children"===l&&"noscript"===t||"class"===l||"className"===l)){var i,s=l.toLowerCase();"defaultValue"===l&&"value"in n&&null==n.value?l="value":"download"===l&&!0===_?_="":"translate"===s&&"no"===_?_=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?l="ondblclick":"onchange"!==s||"input"!==t&&"textarea"!==t||(i=n.type,("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(i))?"onfocus"===s?l="onfocusin":"onblur"===s?l="onfocusout":eS.test(l)&&(l=s):s=l="oninput":o&&eN.test(l)?l=l.replace(eC,"-$&").toLowerCase():null===_&&(_=void 0),"oninput"===s&&r[l=s]&&(l="oninputCapture"),r[l]=_}}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=x(n.children).forEach(function(e){e.props.selected=-1!=r.value.indexOf(e.props.value)})),"select"==t&&null!=r.defaultValue&&(r.value=x(n.children).forEach(function(e){e.props.selected=r.multiple?-1!=r.defaultValue.indexOf(e.props.value):r.defaultValue==e.props.value})),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",eH)):(n.className&&!n.class||n.class&&n.className)&&(r.class=r.className=n.className),e.props=r}(e),e.$$typeof=ej,eA&&eA(e)};var eT=r.__r;r.__r=function(e){eT&&eT(e)};var e$=r.diffed;r.diffed=function(e){e$&&e$(e);var n=e.props,t=e.__e;null!=t&&"textarea"===e.type&&"value"in n&&n.value!==t.value&&(t.value=null==n.value?"":n.value)};var eI=0;function eM(e,n,t,o,l,_){n||(n={});var i,s,u=n;if("ref"in u)for(s in u={},n)"ref"==s?i=n[s]:u[s]=n[s];var c={type:e,props:u,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--eI,__i:-1,__u:0,__source:l,__self:_};if("function"==typeof e&&(i=e.defaultProps))for(s in i)void 0===u[s]&&(u[s]=i[s]);return r.vnode&&r.vnode(c),c}let eR=ep(e=>{let{contexts:n,children:t}=e;return n.reduceRight((e,n)=>(function(e){return e&&e.$$typeof===ej?M.apply(null,arguments):e})(n,{children:e}),t)}),eW=ep(()=>eM("footer",{className:"dsqjs-footer-container",children:eM("p",{className:"dsqjs-footer",children:["Powered by ",eM("a",{className:"dsqjs-disqus-logo",href:"https://disqus.com",target:"_blank",rel:"external nofollow noopener noreferrer"})," ","&"," ",eM("a",{className:"dsqjs-dsqjs-logo",href:"https://disqusjs.skk.moe",target:"_blank",children:"DisqusJS"})]})})),eL=function(e,n){en(()=>{let n=new AbortController,t=e(n.signal);return()=>{n.abort(),null==t||t()}},n)},eO=()=>{};function eF(e){let n=R(e),t=R(eO);return[r=>{let{children:o,initialState:l}=r,[_,i]=ee(null!=l?l:e);return eM(n.Provider,{value:_,children:eM(t.Provider,{value:i,children:o})})},()=>el(n),()=>el(t),n]}let[eB,eV,eQ]=eF(function(){{let e=localStorage.getItem("dsqjs_mode");if("dsqjs"===e||"disqus"===e)return e}return null}());function ez(){let e=eQ();return eo(n=>{e(n),Promise.resolve().then(()=>{null===n?localStorage.removeItem("dsqjs_mode"):localStorage.setItem("dsqjs_mode",n)})},[e])}let[eJ,eZ,eY]=eF(!1),eG=ep(({isError:e,isLoading:n,...t})=>{let r=er(()=>e?"加载失败,请重试":n?"正在加载...":"加载更多评论",[e,n]);return eM("a",{...t,id:"dsqjs-load-more",className:"dsqjs-load-more "+(e?"is-error":""),role:"button",children:r})}),eK=ep(({children:e})=>{let n=ez();return eM("a",{id:"dsqjs-force-disqus",className:"dsqjs-msg-btn",onClick:()=>n("disqus"),children:e})}),eX=ep(({children:e})=>{let n=ez();return eM("a",{id:"dsqjs-test-disqus",className:"dsqjs-msg-btn",onClick:()=>n(null),role:"button",children:e})}),e0=ep(({children:e})=>{let n=ez();return eM("a",{id:"dsqjs-force-dsqjs",className:"dsqjs-msg-btn",onClick:()=>n("dsqjs"),role:"button",children:e})}),e1=ep(({children:e})=>{let n=eY();return eM("a",{id:"dsqjs-reload-dsqjs",className:"dsqjs-msg-btn",onClick:()=>n(!1),role:"button",children:e})}),[e3,e2,e9]=eF(null),e8=function(e,n){var t=X(W++,4);!Q.__s&&ec(t.__H,n)&&(t.__=e,t.u=n,L.__h.push(t))},e4="disqus_thread",e6="dsq-embed-scr",e5=ep(({shortname:e,identifier:n,url:t,title:r})=>{let o=e9(),[l,_]=ee(!1);return e8(()=>o(null)),en(()=>{let o=()=>{{var e;window.disqus_config=void 0;let n=document.getElementById(e6);n&&(document.head.removeChild(n),n.remove()),null==(e=window.DISQUS)||e.reset({});try{delete window.DISQUS}catch(e){window.DISQUS=void 0}let t=document.getElementById(e4);if(t)for(;t.hasChildNodes();)t.firstChild&&t.firstChild.remove();document.querySelectorAll('link[href*="disquscdn.com/next"], link[href*="disqus.com/next"], script[src*="disquscdn.com/next/embed"], script[src*="disqus.com/count-data.js"], iframe[title="Disqus"]').forEach(e=>e.remove())}};return window.disqus_shortname!==e&&o(),!function(e,n){if(window.DISQUS&&document.getElementById(e6))window.DISQUS.reset({reload:!0,config:function(){e.identifier&&(this.page.identifier=e.identifier),e.url&&(this.page.url=e.url),e.title&&(this.page.title=e.title),this.callbacks.onReady=[n]}});else{window.disqus_config=function(){e.identifier&&(this.page.identifier=e.identifier),e.identifier&&(this.page.url=e.identifier),e.identifier&&(this.page.title=e.identifier),this.callbacks.onReady=[n]},window.disqus_shortname=e.shortname;let t=document.createElement("script");t.id=e6,t.src=`https://${e.shortname}.disqus.com/embed.js`,t.async=!0,document.head.appendChild(t)}}({shortname:e,identifier:n,url:t,title:r},()=>_(!0)),o},[e,n,t,r]),eM(k,{children:[eM("div",{id:e4,children:["评论完整模式加载中... 如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或切换至"," ",eM(e0,{children:"评论基础模式"})]}),!l&&eM("div",{id:"dsqjs-msg",children:["评论完整模式加载中... 如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或切换至"," ",eM(e0,{children:"评论基础模式"})]})]})}),e7=ep(()=>eM("div",{id:"dsqjs-msg",children:["评论基础模式加载失败,请"," ",eM(e1,{children:"重载"})," ","或"," ",eM(eX,{children:"尝试完整 Disqus 模式"})]})),ne=ep(()=>eM("div",{id:"dsqjs-msg",children:["当前 Thread 尚未创建。是否切换至"," ",eM(eK,{children:"完整 Disqus 模式"}),"?"]})),nn=ep(({text:e})=>eM("p",{className:"dsqjs-no-comment",children:e}));function nt(e,n){let t=new URL(n);return t.searchParams.set("api_key",e),fetch(t.href).then(e=>e.json())}let nr=e=>new Date(e).getTime(),no=null;function nl(e){return e.replaceAll("a.disquscdn.com","c.disquscdn.com")}let n_=new Date().getTimezoneOffset(),ni=e=>(e+"").padStart(2,"0");function ns(e){return new Promise((n,t)=>{let r=new Image,o=setTimeout(()=>{i(),t()},3e3);function l(){clearTimeout(o),i(),n()}function _(){clearTimeout(o),i(),t()}function i(){r.removeEventListener("load",l),r.removeEventListener("error",_),r.remove()}r.addEventListener("error",_),r.addEventListener("load",l),r.src=`https://${e}/favicon.ico?${Date.now()}=${Date.now()}`})}let nu=R(null),nc=nu.Provider;function na(){return function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'[foxact/invariant] "value" is null or undefined';if(null==e)throw TypeError(n);return e}(el(nu),"<ConfigProvider /> is missing")}function nd(e){return e}function nf({comment:e,children:n,nesting:t}){let{admin:r,adminLabel:o,disqusJsModeAssetsUrlTransformer:l=nd}=na(),_=e.author.profileUrl,i=l(nl(e.author.avatar.cache)),s=eM("img",{alt:e.author.username,src:i});return eM("li",{id:"comment-"+e.id,children:[eM("div",{className:"dsqjs-post-item dsqjs-clearfix",children:[eM("div",{className:"dsqjs-post-avatar",children:_?eM("a",{href:_,target:"_blank",rel:"noreferrer noopenner nofollow external",children:s}):s}),eM("div",{className:"dsqjs-post-body",children:[eM("div",{className:"dsqjs-post-header",children:[_?eM("span",{className:"dsqjs-post-author",children:eM("a",{href:_,target:"_blank",rel:"noreferrer noopenner nofollow external",children:e.author.name})}):eM("span",{className:"dsqjs-post-author",children:e.author.name}),r===e.author.username&&eM("span",{className:"dsqjs-admin-badge",children:o})," ",eM("span",{className:"dsqjs-bullet"})," ",e.createdAt&&eM("span",{className:"dsqjs-meta",children:eM("time",{children:function(e){let n=new Date(nr(e)-60*n_*1e3);return`${n.getFullYear()}-${ni(n.getMonth()+1)}-${ni(n.getDate())} ${ni(n.getHours())}:${ni(n.getMinutes())}`}(e.createdAt)})})]}),e.isDeleted?eM("div",{className:"dsqjs-post-content",children:eM("small",{children:"此评论已被删除"})}):eM("div",{className:"dsqjs-post-content",dangerouslySetInnerHTML:{__html:function(e){let n=nl(e).replaceAll(/https?:\/\/disq.us\/url\?url=(.+)%3A[\w-]+&cuid=\d+/g,(e,n)=>decodeURIComponent(n));no||(no=new DOMParser);let t=no.parseFromString(n,"text/html");return t.querySelectorAll("script, iframe, object, embed, form, input, meta").forEach(e=>e.remove()),t.querySelectorAll("a").forEach(e=>{e.href.startsWith("javascript:")||e.href.startsWith("data:")?e.remove():(e.target="_blank",e.rel="external noopener nofollow noreferrer")}),t.querySelectorAll("*").forEach(e=>{for(let n=0,t=e.attributes.length;n<t;n++){let t=e.attributes[n];t.name.startsWith("on")&&e.removeAttribute(t.name)}e.hasAttribute("style")&&e.removeAttribute("style")}),t.body.innerHTML}(e.message)}})]})]}),eM(nh,{nesting:t,children:n}),e.hasMore&&eM("p",{className:"dsqjs-has-more",children:["切换至 ",eM(eK,{children:"完整 Disqus 模式"})," 显示更多回复"]})]})}function nh({children:e,nesting:n=1}){let{nesting:t=4}=na();return e&&0!==e.length?eM("ul",{className:"dsqjs-post-list "+(n<t?"dsqjs-children":""),children:e.map(e=>eM(nf,{...e},e.comment.id))}):null}function np({comments:e}){return eM("ul",{className:"dsqjs-post-list",id:"dsqjs-post-container",children:er(()=>{let n=[],t=[];return e.map((e,n)=>({i:n,p:e.parent,d:nr(e.createdAt)})).sort((e,n)=>e.p&&n.p?e.d-n.d:0).forEach(({i:r})=>{(e[r].parent?t:n).push(e[r])}),n.map(e=>(function e(n,t,r){return{comment:n,children:function(n,t,r){if(0===n.length)return null;let o=[];return n.forEach(l=>{l.parent===t&&o.unshift(e(l,n,r))}),o}(t,Number(n.id),r+1),nesting:r+1}})(e,t,0))},[e]).map(e=>eM(nf,{...e},e.comment.id))})}let nm=(n=Math.random,(e,t)=>Math.floor(n()*(t-e+1))+e),nv=function(e){return 1===e.length?e[0]:e[nm(0,e.length-1)]};function ny(e){return er(()=>Array.isArray(e)?nv(e):e,[e])}let[ng,nb,nq]=eF(function(){{let e=localStorage.getItem("dsqjs_sort");if("popular"===e||"asc"===e||"desc"===e)return e}return null}());function nk({sortType:e,onChange:n,checked:t,title:r,label:o}){return eM(k,{children:[eM("input",{className:"dsqjs-order-radio",id:"dsqjs-order-"+e,type:"radio",name:"comment-order",value:e,onChange:n,checked:t}),eM("label",{className:"dsqjs-order-label",htmlFor:"dsqjs-order-"+e,title:r,children:o})]})}let nw=ep(()=>{let e=nb(),n=nq();return eM("div",{className:"dsqjs-order",children:[eM(nk,{checked:"desc"===e||null===e,sortType:"desc",title:"按从新到旧",label:"最新",onChange:eo(()=>n("desc"),[n])}),eM(nk,{checked:"asc"===e,sortType:"asc",title:"按从旧到新",label:"最早",onChange:eo(()=>n("asc"),[n])}),eM(nk,{checked:"popular"===e,sortType:"popular",title:"按评分从高到低",label:"最佳",onChange:eo(()=>n("popular"),[n])})]})}),nj=ep(({totalComments:e,siteName:n})=>eM("header",{className:"dsqjs-header",id:"dsqjs-header",children:eM("nav",{className:"dsqjs-nav dsqjs-clearfix",children:[eM("ul",{children:[eM("li",{className:"dsqjs-nav-tab dsqjs-tab-active",children:eM("span",{children:[e," Comments"]})}),eM("li",{className:"dsqjs-nav-tab",children:n})]}),eM(nw,{})]})}));function nN({id:e}){let{apikey:n,shortname:t,api:r}=na(),o=et(ny(n)),[l,_]=ee([]),i=eY(),s=nb(),[u,c]=ee(!1),[a,d]=ee(!1),f=eo(async(n=!1)=>{if(!e)return;c(!0),d(!1);let u=n?null:l[l.length-1];if(u&&!u.cursor.hasNext)return;let a=`${r}3.0/threads/listPostsThreaded?forum=${t}&thread=${e}&order=${null!=s?s:"desc"}${0!==l.length&&(null==u?void 0:u.cursor.next)?"&cursor="+encodeURIComponent(u.cursor.next):""}`,f=()=>{n?i(!0):d(!0),c(!1)};try{let e=await nt(o.current,a);0===e.code?(_(t=>(n?[]:t).concat(e)),c(!1)):f()}catch(e){f()}},[e,l,r,t,s,i]),h=eo(()=>f(!0),[f]),p=eo(()=>f(!1),[f]);!function(e,n){let[t,r]=ee(n=[...n]),o=n.length!==t.length;for(let e=0;e<n.length&&!o;e+=1)t[e]!==n[e]&&(o=!0);o&&(r(n),e())}(h,[e,s]),function(e){let n=et();n.current||(n.current=e())}(h);let m=er(()=>l.filter(Boolean).flatMap(e=>e.response),[l]);if(l.length>0){var v;return eM(k,{children:[eM(np,{comments:m}),(null==(v=l[l.length-1])?void 0:v.cursor.hasNext)&&eM(eG,{isLoading:u,isError:a,onClick:u?void 0:p})]})}return null}function nS(){let{apikey:e,identifier:n,shortname:t,api:r,siteName:o,nocomment:l}=na(),_=et(ny(e)),[i,s]=ee(null),u=eY(),c=null!=n?n:document.location.origin+document.location.pathname+document.location.search,a=eo(async()=>{try{let e=await nt(_.current,`${r}3.0/threads/list.json?forum=${encodeURIComponent(t)}&thread=${encodeURIComponent("ident:"+c)}`);0===e.code?s(e):u(!0)}catch(e){u(!0)}},[r,_,c,u,s,t]),d=e9(),f=et(null);if(en(()=>{let e=eM(k,{children:[eM(eX,{children:"尝试完整 Disqus 模式"})," | ",eM(eK,{children:"强制完整 Disqus 模式"})]});f.current===c?d(eM(k,{children:["你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并"," ",e]})):(d(eM(k,{children:["评论基础模式加载中... 如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并"," ",e]})),f.current=c,a())},[i,a,c,d,t,r]),!i)return null;if(1!==i.response.length)return eM(ne,{});let h=i.response[0],p=h.posts;return eM(k,{children:[eM(nj,{totalComments:p,siteName:null!=o?o:""}),0===p?eM(nn,{text:null!=l?l:"这里空荡荡的,一个人都没有"}):eM(nN,{id:h.id})]})}function nC(){let e=e9(),n=eV(),t=ez(),{shortname:r,identifier:o,url:l,title:_}=na();eL(o=>{"disqus"!==n&&"dsqjs"!==n&&(e("正在检查 Disqus 能否访问..."),Promise.all(["disqus.com",`${r}.disqus.com`].map(ns)).then(()=>{o.aborted||t("disqus")}).catch(()=>{o.aborted||t("dsqjs")}))},[n,t,e,r]);let i=eZ(),s=e2();return i?eM(e7,{}):eM(k,{children:[null!=s&&eM("div",{id:"dsqjs-msg",children:s}),"disqus"===n&&eM(e5,{shortname:r,identifier:o,url:l,title:_}),"dsqjs"===n&&eM(nS,{})]})}let nx=function(e){function n(n){var t=ed({},n);return delete t.ref,e(t,n.ref||null)}return n.$$typeof=ev,n.render=e,n.prototype.isReactComponent=n.__f=!0,n.displayName="ForwardRef("+(e.displayName||e.name)+")",n}(({shortname:e,siteName:n,identifier:t,url:r,title:o,api:l,apikey:_,nesting:i,nocomment:s,admin:u,adminLabel:c,className:a,disqusJsModeAssetsUrlTransformer:d,...f},h)=>{let p=er(()=>[eM(nc,{value:{shortname:e,siteName:n,identifier:t,url:r,title:o,api:l,apikey:_,nesting:i,nocomment:s,admin:u,adminLabel:c,disqusJsModeAssetsUrlTransformer:d}},"config"),eM(eB,{},"mode"),eM(ng,{},"sortType"),eM(eJ,{},"hasError"),eM(e3,{},"msg")],[u,c,l,_,d,t,i,s,e,n,o,r]);return!function(){let[e,n]=ee(!1);return en(()=>{n(!0)},[]),e}()?null:eM("div",{ref:h,...f,className:"__dsqjs_15s36o "+(null!=a?a:""),children:eM(eR,{contexts:p,children:eM("section",{id:"dsqjs",children:[eM(nC,{}),eM(eW,{})]})})})});class nP{render(e){let n;(n=e?"string"==typeof e?document.querySelector(e):e:document.getElementById("disqusjs"))&&(this.container=n,I(eM(nx,{...this.config}),n))}destroy(){this.container&&I(null,this.container)}constructor(n){e(this,"config",void 0),e(this,"container",void 0),this.config=n}}export{nP as default};