UNPKG

sodesu-comment

Version:

Comment system with SolidJS

26 lines (21 loc) 71.1 kB
(function(Q,ae){typeof exports=="object"&&typeof module<"u"?ae(exports):typeof define=="function"&&define.amd?define(["exports"],ae):(Q=typeof globalThis<"u"?globalThis:Q||self,ae(Q.Sodesu={}))})(this,function(Q){"use strict";const ae=(e,t)=>e===t,Kt=Symbol("solid-proxy"),Xe=Symbol("solid-track"),me={equals:ae};let Ye=tt;const V=1,ge=2,Ze={owned:null,cleanups:null,context:null,owner:null},Ee={};var j=null;let Le=null,Jt=null,I=null,U=null,G=null,be=0;function F(e,t){const n=I,r=j,s=e.length===0,o=t===void 0?r:t,i=s?Ze:{owned:null,cleanups:null,context:o?o.context:null,owner:o},l=s?e:()=>e(()=>O(()=>ce(i)));j=i,I=null;try{return K(l,!0)}finally{I=n,j=r}}function C(e,t){t=t?Object.assign({},me,t):me;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},r=s=>(typeof s=="function"&&(s=s(n.value)),et(n,s));return[Qe.bind(n),r]}function Xt(e,t,n){const r=pe(e,t,!0,V);te(r)}function M(e,t,n){const r=pe(e,t,!1,V);te(r)}function W(e,t,n){Ye=ln;const r=pe(e,t,!1,V);(!n||!n.render)&&(r.user=!0),G?G.push(r):te(r)}function L(e,t,n){n=n?Object.assign({},me,n):me;const r=pe(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,te(r),Qe.bind(r)}function Yt(e){return e&&typeof e=="object"&&"then"in e}function Zt(e,t,n){let r,s,o;arguments.length===2&&typeof t=="object"||arguments.length===1?(r=!0,s=e,o=t||{}):(r=e,s=t,o={});let i=null,l=Ee,a=!1,u="initialValue"in o,c=typeof r=="function"&&L(r);const d=new Set,[f,g]=(o.storage||C)(o.initialValue),[b,y]=C(void 0),[h,w]=C(void 0,{equals:!1}),[$,k]=C(u?"ready":"unresolved");function m(A,_,E,z){return i===A&&(i=null,z!==void 0&&(u=!0),(A===l||_===l)&&o.onHydrated&&queueMicrotask(()=>o.onHydrated(z,{value:_})),l=Ee,x(_,E)),_}function x(A,_){K(()=>{_===void 0&&g(()=>A),k(_!==void 0?"errored":u?"ready":"unresolved"),y(_);for(const E of d.keys())E.decrement();d.clear()},!1)}function N(){const A=rn,_=f(),E=b();if(E!==void 0&&!i)throw E;return I&&I.user,_}function P(A=!0){if(A!==!1&&a)return;a=!1;const _=c?c():r;if(_==null||_===!1){m(i,O(f));return}const E=l!==Ee?l:O(()=>s(_,{value:f(),refetching:A}));return Yt(E)?(i=E,"value"in E?(E.status==="success"?m(i,E.value,void 0,_):m(i,void 0,_e(E.value),_),E):(a=!0,queueMicrotask(()=>a=!1),K(()=>{k(u?"refreshing":"pending"),w()},!1),E.then(z=>m(E,z,void 0,_),z=>m(E,void 0,_e(z),_)))):(m(i,E,void 0,_),E)}return Object.defineProperties(N,{state:{get:()=>$()},error:{get:()=>b()},loading:{get(){const A=$();return A==="pending"||A==="refreshing"}},latest:{get(){if(!u)return N();const A=b();if(A&&!i)throw A;return f()}}}),c?Xt(()=>P(!1)):P(!1),[N,{refetch:P,mutate:g}]}function O(e){if(I===null)return e();const t=I;I=null;try{return e()}finally{I=t}}function Qt(e){W(()=>O(e))}function ee(e){return j===null||(j.cleanups===null?j.cleanups=[e]:j.cleanups.push(e)),e}function en(){return j}function tn(e,t){const n=j,r=I;j=e,I=null;try{return K(t,!0)}catch(s){Ie(s)}finally{j=n,I=r}}const[Ho,Vo]=C(!1);function nn(e){const t=L(e),n=L(()=>Re(t()));return n.toArray=()=>{const r=n();return Array.isArray(r)?r:r!=null?[r]:[]},n}let rn;function Qe(){if(this.sources&&this.state)if(this.state===V)te(this);else{const e=U;U=null,K(()=>we(this),!1),U=e}if(I){const e=this.observers?this.observers.length:0;I.sources?(I.sources.push(this),I.sourceSlots.push(e)):(I.sources=[this],I.sourceSlots=[e]),this.observers?(this.observers.push(I),this.observerSlots.push(I.sources.length-1)):(this.observers=[I],this.observerSlots=[I.sources.length-1])}return this.value}function et(e,t,n){let r=e.value;return(!e.comparator||!e.comparator(r,t))&&(e.value=t,e.observers&&e.observers.length&&K(()=>{for(let s=0;s<e.observers.length;s+=1){const o=e.observers[s],i=Le&&Le.running;i&&Le.disposed.has(o),(i?!o.tState:!o.state)&&(o.pure?U.push(o):G.push(o),o.observers&&nt(o)),i||(o.state=V)}if(U.length>1e6)throw U=[],new Error},!1)),t}function te(e){if(!e.fn)return;ce(e);const t=be;on(e,e.value,t)}function on(e,t,n){let r;const s=j,o=I;I=j=e;try{r=e.fn(t)}catch(i){return e.pure&&(e.state=V,e.owned&&e.owned.forEach(ce),e.owned=null),e.updatedAt=n+1,Ie(i)}finally{I=o,j=s}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?et(e,r):e.value=r,e.updatedAt=n)}function pe(e,t,n,r=V,s){const o={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:j,context:j?j.context:null,pure:n};return j===null||j!==Ze&&(j.owned?j.owned.push(o):j.owned=[o]),o}function ve(e){if(e.state===0)return;if(e.state===ge)return we(e);if(e.suspense&&O(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<be);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===V)te(e);else if(e.state===ge){const r=U;U=null,K(()=>we(e,t[0]),!1),U=r}}function K(e,t){if(U)return e();let n=!1;t||(U=[]),G?n=!0:G=[],be++;try{const r=e();return sn(n),r}catch(r){n||(G=null),U=null,Ie(r)}}function sn(e){if(U&&(tt(U),U=null),e)return;const t=G;G=null,t.length&&K(()=>Ye(t),!1)}function tt(e){for(let t=0;t<e.length;t++)ve(e[t])}function ln(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:ve(r)}for(t=0;t<n;t++)ve(e[t])}function we(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const r=e.sources[n];if(r.sources){const s=r.state;s===V?r!==t&&(!r.updatedAt||r.updatedAt<be)&&ve(r):s===ge&&we(r,t)}}}function nt(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=ge,n.pure?U.push(n):G.push(n),n.observers&&nt(n))}}function ce(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),r=e.sourceSlots.pop(),s=n.observers;if(s&&s.length){const o=s.pop(),i=n.observerSlots.pop();r<s.length&&(o.sourceSlots[i]=r,s[r]=o,n.observerSlots[r]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)ce(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)ce(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function _e(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Ie(e,t=j){throw _e(e)}function Re(e){if(typeof e=="function"&&!e.length)return Re(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=Re(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}const Te=Symbol("fallback");function $e(e){for(let t=0;t<e.length;t++)e[t]()}function an(e,t,n={}){let r=[],s=[],o=[],i=0,l=t.length>1?[]:null;return ee(()=>$e(o)),()=>{let a=e()||[],u=a.length,c,d;return a[Xe],O(()=>{let g,b,y,h,w,$,k,m,x;if(u===0)i!==0&&($e(o),o=[],r=[],s=[],i=0,l&&(l=[])),n.fallback&&(r=[Te],s[0]=F(N=>(o[0]=N,n.fallback())),i=1);else if(i===0){for(s=new Array(u),d=0;d<u;d++)r[d]=a[d],s[d]=F(f);i=u}else{for(y=new Array(u),h=new Array(u),l&&(w=new Array(u)),$=0,k=Math.min(i,u);$<k&&r[$]===a[$];$++);for(k=i-1,m=u-1;k>=$&&m>=$&&r[k]===a[m];k--,m--)y[m]=s[k],h[m]=o[k],l&&(w[m]=l[k]);for(g=new Map,b=new Array(m+1),d=m;d>=$;d--)x=a[d],c=g.get(x),b[d]=c===void 0?-1:c,g.set(x,d);for(c=$;c<=k;c++)x=r[c],d=g.get(x),d!==void 0&&d!==-1?(y[d]=s[c],h[d]=o[c],l&&(w[d]=l[c]),d=b[d],g.set(x,d)):o[c]();for(d=$;d<u;d++)d in y?(s[d]=y[d],o[d]=h[d],l&&(l[d]=w[d],l[d](d))):s[d]=F(f);s=s.slice(0,i=u),r=a.slice(0)}return s});function f(g){if(o[d]=g,l){const[b,y]=C(d);return l[d]=y,t(a[d],b)}return t(a[d])}}}function cn(e,t,n={}){let r=[],s=[],o=[],i=[],l=0,a;return ee(()=>$e(o)),()=>{const u=e()||[],c=u.length;return u[Xe],O(()=>{if(c===0)return l!==0&&($e(o),o=[],r=[],s=[],l=0,i=[]),n.fallback&&(r=[Te],s[0]=F(f=>(o[0]=f,n.fallback())),l=1),s;for(r[0]===Te&&(o[0](),o=[],r=[],s=[],l=0),a=0;a<c;a++)a<r.length&&r[a]!==u[a]?i[a](()=>u[a]):a>=r.length&&(s[a]=F(d));for(;a<r.length;a++)o[a]();return l=i.length=o.length=c,r=u.slice(0),s=s.slice(0,l)});function d(f){o[a]=f;const[g,b]=C(u[a]);return i[a]=b,t(g,a)}}}function v(e,t){return O(()=>e(t||{}))}let un=0;function dn(){return`cl-${un++}`}const rt=e=>`Stale read from <${e}>.`;function ot(e){const t="fallback"in e&&{fallback:()=>e.fallback};return L(an(()=>e.each,e.children,t||void 0))}function st(e){const t="fallback"in e&&{fallback:()=>e.fallback};return L(cn(()=>e.each,e.children,t||void 0))}function R(e){const t=e.keyed,n=L(()=>e.when,void 0,{equals:(r,s)=>t?r===s:!r==!s});return L(()=>{const r=n();if(r){const s=e.children;return typeof s=="function"&&s.length>0?O(()=>s(t?r:()=>{if(!O(n))throw rt("Show");return e.when})):s}return e.fallback},void 0,void 0)}function fn(e){let t=!1;const n=(o,i)=>(t?o[1]===i[1]:!o[1]==!i[1])&&o[2]===i[2],r=nn(()=>e.children),s=L(()=>{let o=r();Array.isArray(o)||(o=[o]);for(let i=0;i<o.length;i++){const l=o[i].when;if(l)return t=!!o[i].keyed,[i,l,o[i]]}return[-1]},void 0,{equals:n});return L(()=>{const[o,i,l]=s();if(o<0)return e.fallback;const a=l.children;return typeof a=="function"&&a.length>0?O(()=>a(t?i:()=>{if(O(s)[0]!==o)throw rt("Match");return l.when})):a},void 0,void 0)}function je(e){return e}const hn=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],mn=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...hn]),gn=new Set(["innerHTML","textContent","innerText","children"]),bn=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),pn=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function vn(e,t){const n=pn[e];return typeof n=="object"?n[t]?n.$:void 0:n}const wn=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]);function $n(e,t,n){let r=n.length,s=t.length,o=r,i=0,l=0,a=t[s-1].nextSibling,u=null;for(;i<s||l<o;){if(t[i]===n[l]){i++,l++;continue}for(;t[s-1]===n[o-1];)s--,o--;if(s===i){const c=o<r?l?n[l-1].nextSibling:n[o-l]:a;for(;l<o;)e.insertBefore(n[l++],c)}else if(o===l)for(;i<s;)(!u||!u.has(t[i]))&&t[i].remove(),i++;else if(t[i]===n[o-1]&&n[l]===t[s-1]){const c=t[--s].nextSibling;e.insertBefore(n[l++],t[i++].nextSibling),e.insertBefore(n[--o],c),t[s]=n[o]}else{if(!u){u=new Map;let d=l;for(;d<o;)u.set(n[d],d++)}const c=u.get(t[i]);if(c!=null)if(l<c&&c<o){let d=i,f=1,g;for(;++d<s&&d<o&&!((g=u.get(t[d]))==null||g!==c+f);)f++;if(f>c-l){const b=t[i];for(;l<c;)e.insertBefore(n[l++],b)}else e.replaceChild(n[l++],t[i++])}else i++;else t[i++].remove()}}}const it="_$DX_DELEGATE";function yn(e,t,n,r={}){let s;return F(o=>{s=o,t===document?e():p(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{s(),t.textContent=""}}function S(e,t,n){let r;const s=()=>{const i=document.createElement("template");return i.innerHTML=e,i.content.firstChild},o=()=>(r||(r=s())).cloneNode(!0);return o.cloneNode=o,o}function ne(e,t=window.document){const n=t[it]||(t[it]=new Set);for(let r=0,s=e.length;r<s;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,Ln))}}function T(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function kn(e,t,n){n?e.setAttribute(t,""):e.removeAttribute(t)}function Me(e,t){t==null?e.removeAttribute("class"):e.className=t}function Cn(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const s=n[0];e.addEventListener(t,n[0]=o=>s.call(e,n[1],o))}else e.addEventListener(t,n,typeof n!="function"&&n)}function lt(e,t,n={}){const r=Object.keys(t||{}),s=Object.keys(n);let o,i;for(o=0,i=s.length;o<i;o++){const l=s[o];!l||l==="undefined"||t[l]||(at(e,l,!1),delete n[l])}for(o=0,i=r.length;o<i;o++){const l=r[o],a=!!t[l];!l||l==="undefined"||n[l]===a||!a||(at(e,l,!0),n[l]=a)}return n}function xn(e,t,n){if(!t)return n?T(e,"style"):t;const r=e.style;if(typeof t=="string")return r.cssText=t;typeof n=="string"&&(r.cssText=n=void 0),n||(n={}),t||(t={});let s,o;for(o in n)t[o]==null&&r.removeProperty(o),delete n[o];for(o in t)s=t[o],s!==n[o]&&(r.setProperty(o,s),n[o]=s);return n}function An(e,t={},n,r){const s={};return M(()=>typeof t.ref=="function"&&Ne(t.ref,e)),M(()=>Sn(e,t,n,!0,s,!0)),s}function Ne(e,t,n){return O(()=>e(t,n))}function p(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!="function")return ye(e,t,r,n);M(s=>ye(e,t(),s,n),r)}function Sn(e,t,n,r,s={},o=!1){t||(t={});for(const i in s)if(!(i in t)){if(i==="children")continue;s[i]=ct(e,i,null,s[i],n,o,t)}for(const i in t){if(i==="children")continue;const l=t[i];s[i]=ct(e,i,l,s[i],n,o,t)}}function En(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function at(e,t,n){const r=t.trim().split(/\s+/);for(let s=0,o=r.length;s<o;s++)e.classList.toggle(r[s],n)}function ct(e,t,n,r,s,o,i){let l,a,u,c,d;if(t==="style")return xn(e,n,r);if(t==="classList")return lt(e,n,r);if(n===r)return r;if(t==="ref")o||n(e);else if(t.slice(0,3)==="on:"){const f=t.slice(3);r&&e.removeEventListener(f,r,typeof r!="function"&&r),n&&e.addEventListener(f,n,typeof n!="function"&&n)}else if(t.slice(0,10)==="oncapture:"){const f=t.slice(10);r&&e.removeEventListener(f,r,!0),n&&e.addEventListener(f,n,!0)}else if(t.slice(0,2)==="on"){const f=t.slice(2).toLowerCase(),g=wn.has(f);if(!g&&r){const b=Array.isArray(r)?r[0]:r;e.removeEventListener(f,b)}(g||n)&&(Cn(e,f,n,g),g&&ne([f]))}else t.slice(0,5)==="attr:"?T(e,t.slice(5),n):t.slice(0,5)==="bool:"?kn(e,t.slice(5),n):(d=t.slice(0,5)==="prop:")||(u=gn.has(t))||(c=vn(t,e.tagName))||(a=mn.has(t))||(l=e.nodeName.includes("-")||"is"in i)?(d&&(t=t.slice(5),a=!0),t==="class"||t==="className"?Me(e,n):l&&!a&&!u?e[En(t)]=n:e[c||t]=n):T(e,bn[t]||t,n);return n}function Ln(e){let t=e.target;const n=`$$${e.type}`,r=e.target,s=e.currentTarget,o=a=>Object.defineProperty(e,"target",{configurable:!0,value:a}),i=()=>{const a=t[n];if(a&&!t.disabled){const u=t[`${n}Data`];if(u!==void 0?a.call(t,u,e):a.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),e.composedPath){const a=e.composedPath();o(a[0]);for(let u=0;u<a.length-2&&(t=a[u],!!i());u++){if(t._$host){t=t._$host,l();break}if(t.parentNode===s)break}}else l();o(r)}function ye(e,t,n,r,s){for(;typeof n=="function";)n=n();if(t===n)return n;const o=typeof t,i=r!==void 0;if(e=i&&n[0]&&n[0].parentNode||e,o==="string"||o==="number"){if(o==="number"&&(t=t.toString(),t===n))return n;if(i){let l=n[0];l&&l.nodeType===3?l.data!==t&&(l.data=t):l=document.createTextNode(t),n=re(e,n,r,l)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||o==="boolean")n=re(e,n,r);else{if(o==="function")return M(()=>{let l=t();for(;typeof l=="function";)l=l();n=ye(e,l,n,r)}),()=>n;if(Array.isArray(t)){const l=[],a=n&&Array.isArray(n);if(Pe(l,t,n,s))return M(()=>n=ye(e,l,n,r,!0)),()=>n;if(l.length===0){if(n=re(e,n,r),i)return n}else a?n.length===0?ut(e,l,r):$n(e,n,l):(n&&re(e),ut(e,l));n=l}else if(t.nodeType){if(Array.isArray(n)){if(i)return n=re(e,n,r,t);re(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function Pe(e,t,n,r){let s=!1;for(let o=0,i=t.length;o<i;o++){let l=t[o],a=n&&n[e.length],u;if(!(l==null||l===!0||l===!1))if((u=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))s=Pe(e,l,a)||s;else if(u==="function")if(r){for(;typeof l=="function";)l=l();s=Pe(e,Array.isArray(l)?l:[l],Array.isArray(a)?a:[a])||s}else e.push(l),s=!0;else{const c=String(l);a&&a.nodeType===3&&a.data===c?e.push(a):e.push(document.createTextNode(c))}}return s}function ut(e,t,n=null){for(let r=0,s=t.length;r<s;r++)e.insertBefore(t[r],n)}function re(e,t,n,r){if(n===void 0)return e.textContent="";const s=r||document.createTextNode("");if(t.length){let o=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(s!==l){const a=l.parentNode===e;!o&&!i?a?e.replaceChild(s,l):e.insertBefore(s,n):a&&l.remove()}else o=!0}}else e.insertBefore(s,n);return[s]}const _n="http://www.w3.org/2000/svg";function In(e,t=!1){return t?document.createElementNS(_n,e):document.createElement(e)}function Rn(e){const{useShadow:t}=e,n=document.createTextNode(""),r=()=>e.mount||document.body,s=en();let o;return W(()=>{o||(o=tn(s,()=>L(()=>e.children)));const i=r();if(i instanceof HTMLHeadElement){const[l,a]=C(!1),u=()=>a(!0);F(c=>p(i,()=>l()?c():o(),null)),ee(u)}else{const l=In(e.isSVG?"g":"div",e.isSVG),a=t&&l.attachShadow?l.attachShadow({mode:"open"}):l;Object.defineProperty(l,"_$host",{get(){return n.parentNode},configurable:!0}),p(a,o),i.appendChild(l),e.ref&&e.ref(l),ee(()=>i.removeChild(l))}},void 0,{render:!0}),n}const dt="0.5.0",ft={"Content-Type":"application/json"},Z=e=>`${e.replace(/\/?$/,"/")}api/`,oe=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},Tn=({serverURL:e,lang:t,paths:n,type:r,signal:s})=>fetch(`${Z(e)}article?path=${encodeURIComponent(n.join(","))}&type=${encodeURIComponent(r.join(","))}&lang=${t}`,{signal:s}).then(o=>o.json()).then(o=>oe(o,"Get counter").data),jn=({serverURL:e,lang:t,path:n,type:r,action:s})=>fetch(`${Z(e)}article?lang=${t}`,{method:"POST",headers:ft,body:JSON.stringify({path:n,type:r,action:s})}).then(o=>o.json()).then(o=>oe(o,"Update counter").data),Mn=({serverURL:e,lang:t,path:n,page:r,pageSize:s,sortBy:o,signal:i,token:l})=>{const a={};return l&&(a.Authorization=`Bearer ${l}`),fetch(`${Z(e)}comment?path=${encodeURIComponent(n)}&pageSize=${s}&page=${r}&lang=${t}&sortBy=${o}`,{signal:i,headers:a}).then(u=>u.json()).then(u=>oe(u,"Get comment data").data)},Nn=({serverURL:e,lang:t,token:n,comment:r})=>{const s={"Content-Type":"application/json"};return n&&(s.Authorization=`Bearer ${n}`),fetch(`${Z(e)}comment?lang=${t}`,{method:"POST",headers:s,body:JSON.stringify(r)}).then(o=>o.json())},Pn=({serverURL:e,lang:t,token:n,objectId:r})=>fetch(`${Z(e)}comment/${r}?lang=${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}}).then(s=>s.json()).then(s=>oe(s,"Delete comment")),ht=({serverURL:e,lang:t,token:n,objectId:r,comment:s})=>fetch(`${Z(e)}comment/${r}?lang=${t}`,{method:"PUT",headers:{...ft,Authorization:`Bearer ${n}`},body:JSON.stringify(s)}).then(o=>o.json()).then(o=>oe(o,"Update comment")),Un=({serverURL:e,lang:t,paths:n,signal:r})=>fetch(`${Z(e)}comment?type=count&url=${encodeURIComponent(n.join(","))}&lang=${t}`,{signal:r}).then(s=>s.json()).then(s=>oe(s,"Get comment count").data),On=({lang:e,serverURL:t})=>{const n=(window.innerWidth-450)/2,r=(window.innerHeight-450)/2,s=window.open(`${t.replace(/\/$/,"")}/ui/login?lng=${encodeURIComponent(e)}`,"_blank",`width=450,height=450,left=${n},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);return s?.postMessage({type:"TOKEN",data:null},"*"),new Promise(o=>{const i=({data:l})=>{!l||typeof l!="object"||l.type!=="userInfo"||l.data.token&&(s?.close(),window.removeEventListener("message",i),o(l.data))};window.addEventListener("message",i)})},Bn=({serverURL:e,lang:t,paths:n,signal:r})=>Tn({serverURL:e,lang:t,paths:n,type:["time"],signal:r}),Dn=e=>jn({...e,type:"time",action:"inc"}),zn=e=>e.match(/[\w\s,.\u00C0-\u024F\u0400-\u04FF]+/giu),Fn=e=>e.match(/[\u4E00-\u9FD5]/gu),Hn=e=>(zn(e)?.reduce((t,n)=>t+(["",",","."].includes(n.trim())?0:n.trim().split(/\s+/u).length),0)??0)+(Fn(e)?.length??0),ke=(e,t,n,r)=>r?[e,t,n,r]:[e,t,n];function mt(e,t){let n="";typeof t=="number"&&(n=" ".repeat(t)),typeof t=="string"?n=t:n=e.match(/^([\t ])+/)?.[0]??"";const r=new RegExp(`^${n}`,"gm");return e.replace(r,"")}function Ue(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function B(e,t,n){const r=n?Oe(n):"";return`<${e}${r}>${Array.isArray(t)?t.join(""):t}</${e}>`}function Vn(e=""){const t=[],n=[];let r="";for(const{groups:o}of e.matchAll(/(?<attr_name>\w+)="(?<attr_val>[^"]+)"|(?:\.(?<cls>[\w-]+))|(?:#(?<id>[\w-]+))/g))o?.id?r=o?.id:o?.cls?n.push(o?.cls):t.push(`${o?.attr_name}="${o?.attr_val}"`);const s=[t.join(" "),n.length?`class="${n.join(" ")}"`:"",r?`id="${r}"`:""].filter(Boolean).join(" ").trim();return s?` ${s}`:""}function Gn(e){const t=e.replace(/^<\/?([A-z]+)[> /][.\n\r\t\S\s]*/m,"$1");return/^(?:a|abbr|acronym|audio|b|bdi|bdo|big|br|button|canvas|cite|code|data|datalist|del|dfn|em|embed|i|iframe|img|input|ins|kbd|label|map|mark|meter|noscript|object|output|picture|progress|q|ruby|s|samp|script|select|slot|small|span|strong|sub|sup|svg|template|textarea|time|u|tt|var|video|wbr)$/.test(t)}function*gt(e,t){let n=0;for(const r of e){if(t(r,n++))break;yield r}}function Oe(e){const t=Object.entries(e).filter(([n,r])=>r!=null&&typeof n!="symbol").map(([n,r])=>typeof r=="boolean"?n:`${n}="${r}"`).join(" ").trim();return t&&` ${t}`}function Wn(e){const t=[];for(const[n,{regex:r}]of e)t.push(`(?:${r.source.replace(/\\k<([^>]+?)>/giu,`\\k<${n}__$1>`)})`.replace(/\(\?<((?:[^=!])[^>]*?)>/giu,`(?<${n}__$1>`));return new RegExp(t.join("|"),"guid")}function qn(e){const t=new Map(e.map(a=>[a.name,a])),n=Wn(t);function*r(a){let u=0;for(;u<a.length;){const c=s(a,u);c[1]!==u&&(yield ke(a.slice(u,c[1]),u,c[1])),u=c[2],yield c}}function s(a,u){n.lastIndex=-1;const c=n.exec(a.slice(u));if(!c)return[a.slice(u),u,a.length];const{groups:d,index:f,0:{length:g}}=c,b=Object.entries(d??{}).filter(m=>m[1]),y=Object.fromEntries(b.map(([m,x])=>[m.split("__")[1],x])),h=u+f+g,[w]=b[0]?.[0].split("__")??[],{handler:$}=t.get(w??""),k=$(y,{index:u+f,src:a,length:g,lastIndex:h,...l});return Array.isArray(k)?k:ke(k,u+f,h,y)}function o(a){return[...r(a)].map(([u])=>u).flat(1/0).join("")}function i(a){let u="";const c=/(?:\r?\n)+(```[^\n]*|::: ?[^\n]*|-{3,}|\* \* \*(?: \*)*)(?:\r?\n)+/gm,d=/(\r?\n[^\r\n >].*)(?:\r?\n)(>)/gm,f=/(\r?\n[>] .*)(?:\r?\n)([^\r\n >])/gm,g=` ${a} `.replace(c,` $1 `).replace(d,`$1 $2`).replace(f,`$1 $2`),b=/ *(?:\r?\n){2,}/gm,y=g.split(b);let h=!1;const w=y.reduce((k,m)=>h?(k[k.length-1]+=h===":::"?` ${m}`:` ${m}`,m===h&&(h=!1),k):((/```[^\n]*/.test(m)||/::: ?[^\n]*/.test(m))&&(h=m.trim().slice(0,3)),m&&k.push(m.replace(/(?:^\n+|\n+$)/g,"")),k),[]);let $=w.length;for(;$--;){const k=w[$]??"",m=o(k);u=(m&&(!m.startsWith("<")||Gn(m))?`<p>${m.trim()}</p>`:m)+u}return u.trim()}const l={parse:i,parseIter:r,parseNext:s,parseParagraph:o};return l}const Be=Symbol("isLinkEnd"),Kn={name:"anchor",regex:/(?<start>\[)|(?<end>\])(?:\((?<href>[^")]+?)(?: "(?<title>[^"]+)")?\))?(?:\{:(?<ial>.+?)\})?/,handler:({start:e,href:t,title:n,ial:r},{index:s,src:o,lastIndex:i,parseNext:l,parseIter:a})=>{if(!e)return["",s,i,{href:t,title:n,ial:r,[Be]:!0}];const u=[...gt(a(o.slice(s+1)),y=>y[3]?.[Be])],c=u.map(([y])=>y).join(""),d=u.at(-1)?.[2]??0,f=l(o,s+d+1),{ial:g,...b}=f[3]??{};return ke(`<a${Oe(b??{})}${Vn(g)}>${c}</a>`,s,f[2],{content:c,...f[3],[Be]:!1})}},Jn={name:"bis",regex:/(?<t>\*\*?|__?|~~)(?<content>.*?)(?<ns>[^\\\n])\k<t>/,handler:({t:e,content:t,ns:n},{parseParagraph:r})=>{const s=e==="~~"?"s":e?.length===1?"em":"strong";return B(s,r((t??"")+n))}},Xn={name:"codeblock",regex:/^```\s*(?<lang>\w*)\n(?<str>[\s\S]+)\n```(?:\n|$)/,handler:({lang:e,str:t})=>`<pre class="code ${e??""}"><code${e?` class="language-${e.toLowerCase()}"`:""}>${mt(Ue(t??"").replace(/(?:^\n+|\n+$)/g,""))}</code></pre>`},Yn={name:"escape",regex:/\\(?<c>.)/i,handler:({c:e})=>e??""},Zn={name:"fencedDiv",regex:/^::: ?(?<cls>[^\n]+)?\n(?<content>[\s\S]+?)\n:::(?:\n|$)/,handler:({cls:e,content:t},{parse:n})=>`<div class="${["fenced",e??""].join(" ").trim()}">${n(t??"")}</div>`},Qn={name:"hashHeading",regex:/^(?<level>#{1,6})\s*(?<txt>.+)(?:\n|$)/,handler:({level:e,txt:t},{parseParagraph:n})=>B(`h${e?.length}`,n(t??""))},er={name:"hr",regex:/(?<p>^|n\*)(?<l>-{3,}|\*(?: \*){2,})(?:$|\n+)/i,handler:()=>"<hr />"},tr={name:"html",regex:/<(?<tagContent>[^>]+)>/,handler:({tagContent:e})=>`<${e}>`},nr={name:"image",regex:/!\[(?<alt>[^\\)]*)\]\((?<src>[^" ]+?)(?: "(?<title>[^"]+)")?\)/,handler:({alt:e="",src:t,title:n})=>`<img${Oe({src:t,alt:e,title:n})} />`},rr={name:"inlineCode",regex:/`(?<c>[^`]*)?`/,handler:({c:e})=>B("code",Ue(e??""))},or={name:"newLine",regex:/(?<lb> {2}\n)/,handler:()=>"<br />"},bt=e=>e.replace(/^\d+[.)]\s+/,"").trim(),sr={name:"ol",regex:/^(?<all>(?:\n?\d+[.)]\s+)[.\n\r\t\S\s]+)/,handler:({all:e},{parseParagraph:t})=>{const n=e?.split(/\n(?=\d)/g),r=n?.some(a=>a.endsWith(` `)),[s,...o]=n??[],i=s?.match(/^\d+/)?.[0],l=r?a=>B("p",t(a)):a=>t(a);return B("ol",[B("li",l(bt(s??""))),...o.map(a=>B("li",l(bt(a))))],{start:i=="1"?null:i})}},ir={name:"poetry",regex:/(?:^|\n+)(?<tab>\t| {4})(?<content>[\s\S]+)(?:$|\n{2,})*/,handler:({content:e,tab:t})=>`<pre class="code poetry">${mt(B("code",Ue(e??"")),t)}</pre>`},lr={name:"quote",regex:/^(?<all>(?:>\s+[^$\n]+(?:\n|$))+)/,handler:({all:e},{parseParagraph:t})=>B("blockquote",t(e?.split(` `).map(n=>n.slice(1).trim()).join(` `)??""))},pt=Symbol("table"),ar=[Yn,er,Kn,Jn,Xn,Zn,Qn,tr,nr,rr,or,sr,ir,lr,{name:"table",regex:/^(?:(?<loose>^\| *[^$|\n]+(?:\|? *[^$|\n]+)+\|?)|(?<defined>(?:\| *[^$|\n]+)+ *\|))(?<heading>(?:\n)\|? *-{3,} *?(?:\| *-{3,} *)*\|?)?(?:\n|$)/,handler:({loose:e,defined:t,heading:n},{index:r,lastIndex:s,src:o,parseIter:i,parseParagraph:l})=>{const a=!!n,u=(e??t)?.match(/\s*([^|]+)\s*(?=\||$)/gmu),c=[...gt(i(o.slice(s)),([,,,g])=>!g?.[pt])],d=[u.map(g=>g.trim()),...c.flatMap(([,,,g])=>g?.cells)],f=d.map((g,b)=>B("tr",g.map(y=>B(b===0&&a?"th":"td",l(y)))));return ke(B("table",f),r,s+(c.at(-1)?.[2]??0),{cells:d,hasHeading:a,[pt]:!0})}},{name:"ul",regex:/^(?<all>(?:\n?[*+-]\s+[.\n\r\t\S\s]+)+)/,handler:({all:e},{parseParagraph:t})=>B("ul",e?.slice(1).split(/\n[*+-]/g).map(n=>B("li",t(n.trim())))??"")},{name:"underlineHeading",regex:/^(?<txt>[^\n]+)\n(?<line>-{3,}|={3,})(?:\n|$)/,handler:({txt:e,line:t},{parseParagraph:n})=>B(`h${t?.[0]==="="?"1":"2"}`,n(e??""))}];function cr(e,{plugins:t=[...ar]}={}){if(!e)return"<p></p>";const{parse:n}=qn(t);return n(e)}const ur=["nick","mail","link"],vt=e=>e.filter(t=>ur.includes(t)),wt=["//unpkg.com/@waline/emojis@1.1.0/weibo"],dr=["//unpkg.com/@waline/emojis/tieba/tieba_agree.png","//unpkg.com/@waline/emojis/tieba/tieba_look_down.png","//unpkg.com/@waline/emojis/tieba/tieba_sunglasses.png","//unpkg.com/@waline/emojis/tieba/tieba_pick_nose.png","//unpkg.com/@waline/emojis/tieba/tieba_awkward.png","//unpkg.com/@waline/emojis/tieba/tieba_sleep.png"],fr=e=>new Promise((t,n)=>{if(e.size>128*1e3)return n(new Error("File too large! File size limit 128KB"));const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result),r.onerror=n}),hr=e=>e?'<p class="wl-tex">TeX is not available in preview</p>':'<span class="wl-tex">TeX is not available in preview</span>',mr=e=>{const t=async(n,r={})=>fetch(`https://api.giphy.com/v1/gifs/${n}?${new URLSearchParams({lang:e,limit:"20",rating:"g",api_key:"6CIMLkNMMOhRcXPoMCPkFy4Ybk2XUiMp",...r}).toString()}`).then(s=>s.json()).then(({data:s})=>s.map(o=>({title:o.title,src:o.images.downsized_medium.url})));return{search:n=>t("search",{q:n,offset:"0"}),default:()=>t("trending",{}),more:(n,r=0)=>t("search",{q:n,offset:r.toString()})}},gr=/[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u3040-\u309F\uAC00-\uD7AF\u0400-\u04FF]+|\w+/,br=/</,pr=/(?:^|\s)\/\/(.+)$/gm,vr=/\/\*([\s\S]*?)\*\//g,wr=new RegExp(`(${gr.source}|${br.source})|((?:${pr.source})|(?:${vr.source}))`,"gim"),$t=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"],De={},$r=e=>{let t=0;return e.replace(wr,(n,r,s)=>{if(s)return`<span style="color: slategray">${s}</span>`;if(r==="<")return"&lt;";let o;De[r]?o=De[r]:(o=$t[t],De[r]=o);const i=`<span style="color: #${o}">${r}</span>`;return t=++t%$t.length,i})},yr=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","like","cancelLike","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous","level0","level1","level2","level3","level4","level5","gif","gifSearchPlaceholder","profile","approved","waiting","spam","unsticky","oldest","latest","hottest","reactionTitle"],H=e=>Object.fromEntries(e.map((t,n)=>[yr[n],t])),kr=H(["Benutzername","Der Benutzername darf nicht weniger als 3 Bytes umfassen.","E-Mail","Bitte bestätigen Sie Ihre E-Mail-Adresse.","Webseite","Optional","Kommentieren Sie hier...","Noch keine Kommentare.","Senden","Gefällt mir","Gefällt mir nicht mehr","Antworten","Antwort abbrechen","Kommentare","Aktualisieren","Mehr laden...","Vorschau","Emoji","Ein Bild hochladen","Vor einigen Sekunden","Vor einigen Minuten","Vor einigen Stunden","Vor einigen Tagen","Gerade eben","Hochladen läuft","Anmelden","Abmelden","Admin","Angeheftet","Wörter","Bitte geben Sie Kommentare zwischen $0 und $1 Wörtern ein! Aktuelle Anzahl der Wörter: $2","Anonym","Zwerge","Hobbits","Ents","Magier","Elfen","Maïar","GIF","Nach einem GIF suchen","Profil","Genehmigt","Ausstehend","Spam","Lösen","Älteste","Neueste","Am beliebtesten","Was denken Sie?"]),yt=H(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","Like","Cancel like","Reply","Cancel reply","Comments","Refresh","Load More...","Preview","Emoji","Upload Image","seconds ago","minutes ago","hours ago","days ago","just now","Uploading","Login","logout","Admin","Sticky","Words",`Please input comments between $0 and $1 words! Current word number: $2`,"Anonymous","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Search GIF","Profile","Approved","Waiting","Spam","Unsticky","Oldest","Latest","Hottest","What do you think?"]),kt=H(["Nombre de usuario","El nombre de usuario no puede tener menos de 3 bytes.","Correo electrónico","Por favor confirma tu dirección de correo electrónico.","Sitio web","Opcional","Comenta aquí...","Sin comentarios todavía.","Enviar","Like","Anular like","Responder","Anular respuesta","Comentarios","Recargar","Cargar Más...","Previsualizar","Emoji","Subir Imagen","segundos atrás","minutos atrás","horas atrás","días atrás","justo ahora","Subiendo","Iniciar sesión","cerrar sesión","Admin","Fijado","Palabras",`Por favor escriba entre $0 y $1 palabras! El número actual de palabras: $2`,"Anónimo","Enanos","Hobbits","Ents","Magos","Elfos","Maiar","GIF","Buscar GIF","Perfil","Aprobado","Esperando","Spam","Desfijar","Más antiguos","Más recientes","Más vistos","¿Qué piensas?"]),Ct=H(["Pseudo","Le pseudo ne peut pas faire moins de 3 octets.","E-mail","Veuillez confirmer votre adresse e-mail.","Site Web","Optionnel","Commentez ici...","Aucun commentaire pour l'instant.","Envoyer","J'aime","Annuler le j'aime","Répondre","Annuler la réponse","Commentaires","Actualiser","Charger plus...","Aperçu","Emoji","Télécharger une image","Il y a quelques secondes","Il y a quelques minutes","Il y a quelques heures","Il y a quelques jours","À l'instant","Téléchargement en cours","Connexion","Déconnexion","Admin","Épinglé","Mots",`Veuillez saisir des commentaires entre $0 et $1 mots ! Nombre actuel de mots : $2`,"Anonyme","Nains","Hobbits","Ents","Mages","Elfes","Maïar","GIF","Rechercher un GIF","Profil","Approuvé","En attente","Indésirable","Détacher","Le plus ancien","Dernier","Le plus populaire","Qu'en pensez-vous ?"]),xt=H(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","Like","Cancel like","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード",`コメントは $0 から $1 ワードの間でなければなりません! 現在の単語番号: $2`,"匿名","うえにん","なかにん","しもおし","特にしもおし","かげ","なぬし","GIF","探す GIF","個人情報","承認済み","待っている","スパム","べたつかない","逆順","正順","人気順","どう思いますか?"]),Cr=H(["Apelido","Apelido não pode ser menor que 3 bytes.","E-Mail","Por favor, confirme seu endereço de e-mail.","Website","Opcional","Comente aqui...","Nenhum comentário, ainda.","Enviar","Like","Cancel like","Responder","Cancelar resposta","Comentários","Refrescar","Carregar Mais...","Visualizar","Emoji","Enviar Imagem","segundos atrás","minutos atrás","horas atrás","dias atrás","agora mesmo","Enviando","Entrar","Sair","Admin","Sticky","Palavras",`Favor enviar comentário com $0 a $1 palavras! Número de palavras atuais: $2`,"Anônimo","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Pesquisar GIF","informação pessoal","Aprovado","Espera","Spam","Unsticky","Mais velho","Mais recentes","Mais quente","O que você acha?"]),At=H(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Like","Cancel like","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова",`Пожалуйста, введите комментарии от $0 до $1 слов! Номер текущего слова: $2`,"Анонимный","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Поиск GIF","Персональные данные","Одобренный","Ожидающий","Спам","Нелипкий","самый старый","последний","самый горячий","Что вы думаете?"]),St=H(["Tên","Tên không được nhỏ hơn 3 ký tự.","E-Mail","Vui lòng xác nhập địa chỉ email của bạn.","Website","Tùy chọn","Hãy bình luận có văn hoá!","Chưa có bình luận","Gửi","Thích","Bỏ thích","Trả lời","Hủy bỏ","bình luận","Làm mới","Tải thêm...","Xem trước","Emoji","Tải lên hình ảnh","giây trước","phút trước","giờ trước","ngày trước","Vừa xong","Đang tải lên","Đăng nhập","đăng xuất","Quản trị viên","Dính","từ",`Bình luận phải có độ dài giữa $0 và $1 từ! Số từ hiện tại: $2`,"Vô danh","Người lùn","Người tí hon","Thần rừng","Pháp sư","Tiên tộc","Maiar","Ảnh GIF","Tìm kiếm ảnh GIF","thông tin cá nhân","Đã được phê duyệt","Đang chờ đợi","Thư rác","Không dính","lâu đời nhất","muộn nhất","nóng nhất","What do you think?"]),Et=H(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","喜欢","取消喜欢","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字",`评论字数应在 $0 到 $1 字之间! 当前字数:$2`,"匿名","潜水","冒泡","吐槽","活跃","话痨","传说","表情包","搜索表情包","个人资料","通过","待审核","垃圾","取消置顶","按倒序","按正序","按热度","你认为这篇文章怎么样?"]),xr=H(["暱稱","暱稱不能少於3個字元","郵箱","請填寫正確的郵件地址","網址","可選","歡迎留言","來發留言吧~","送出","喜歡","取消喜歡","回覆","取消回覆","留言","重整","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登入","登出","管理者","置頂","字",`留言字數應在 $0 到 $1 字之間! 目前字數:$2`,"匿名","潛水","冒泡","吐槽","活躍","多話","傳說","表情包","搜尋表情包","個人資料","通過","待審核","垃圾","取消置頂","最早","最新","熱門","你認為這篇文章怎麼樣?"]),Lt="en-US",ze={zh:Et,"zh-cn":Et,"zh-tw":xr,en:yt,"en-us":yt,fr:Ct,"fr-fr":Ct,jp:xt,"jp-jp":xt,"pt-br":Cr,ru:At,"ru-ru":At,vi:St,"vi-vn":St,de:kr,es:kt,"es-mx":kt},Ar=e=>ze[e.toLowerCase()]||ze[Lt.toLowerCase()],_t=e=>Object.keys(ze).includes(e.toLowerCase())?e:Lt,It=e=>{try{e=decodeURI(e)}catch{}return e},Sr=(e="")=>e.replace(/\/$/u,""),Rt=e=>/^(https?:)?\/\//.test(e),Ce=e=>{const t=Sr(e);return Rt(t)?t:`https://${t}`},Er=e=>Array.isArray(e)?e:e?[0,e]:!1,ue=(e,t)=>e==null||e===!0?t:e===!1?null:e,Lr=({serverURL:e,path:t=location.pathname,lang:n=typeof navigator>"u"?"en-US":navigator.language,locale:r,meta:s=["nick","mail","link"],requiredMeta:o=[],dark:i=!1,pageSize:l=10,wordLimit:a,noCopyright:u=!1,login:c="enable",recaptchaV3Key:d="",turnstileKey:f="",commentSorting:g="latest",emoji:b=wt,imageUploader:y,highlighter:h,texRenderer:w,search:$,reaction:k,...m})=>({serverURL:Ce(e),path:It(t),lang:_t(n),locale:{...Ar(_t(n)),...typeof r=="object"?r:{}},wordLimit:Er(a),meta:vt(s),requiredMeta:vt(o),dark:i,pageSize:l,commentSorting:g,login:c,noCopyright:u,recaptchaV3Key:d,turnstileKey:f,...m,reaction:k===!0?dr:k||null,imageUploader:ue(y,fr),highlighter:ue(h,$r),texRenderer:ue(w,hr),emoji:ue(b,wt),search:ue($,mr(n))}),Tt=e=>typeof e=="string",Fe=(e,t)=>{let n=e.toString();for(;n.length<t;)n=`0${n}`;return n},_r=e=>{const t=Fe(e.getDate(),2),n=Fe(e.getMonth()+1,2);return`${Fe(e.getFullYear(),2)}-${n}-${t}`},Ir=(e,t,n)=>{if(!e)return"";const r=Tt(e)?new Date(e.includes(" ")?e.replace(/-/g,"/"):e):e,s=t.getTime()-r.getTime(),o=Math.floor(s/(24*3600*1e3));if(o===0){const i=s%864e5,l=Math.floor(i/(3600*1e3));if(l===0){const a=i%36e5,u=Math.floor(a/(60*1e3));if(u===0){const c=a%6e4;return`${Math.round(c/1e3)} ${n.seconds}`}return`${u} ${n.minutes}`}return`${l} ${n.hours}`}return o<0?n.now:o<8?`${o} ${n.days}`:_r(r)},jt=e=>{e.name!=="AbortError"&&console.error(e.message)},Rr=e=>e instanceof HTMLElement?e:Tt(e)?document.querySelector(e):null,He=e=>{const{path:t}=e.dataset;return t?.length?t:null},Tr=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-comment-count",lang:r=navigator.language})=>{const s=new AbortController,o=document.querySelectorAll(n);return o.length&&Un({serverURL:Ce(e),paths:Array.from(o).map(i=>It(He(i)??t)),lang:r,signal:s.signal}).then(i=>{o.forEach((l,a)=>{l.innerText=i[a].toString()})}).catch(jt),s.abort.bind(s)},Mt=(e,t)=>{t.forEach((n,r)=>{const s=e[r].time;typeof s=="number"&&(n.innerText=s.toString())})},jr=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-pageview-count",update:r=!0,lang:s=navigator.language})=>{const o=new AbortController,i=Array.from(document.querySelectorAll(n)),l=u=>{const c=He(u);return c!==null&&t!==c},a=u=>Bn({serverURL:Ce(e),paths:u.map(c=>He(c)??t),lang:s,signal:o.signal}).then(c=>Mt(c,u)).catch(jt);if(r){const u=i.filter(d=>!l(d)),c=i.filter(l);Dn({serverURL:Ce(e),path:t,lang:s}).then(d=>Mt(d,u)),c.length&&a(c)}else a(i);return o.abort.bind(o)},D=F(()=>{const[e,t]=C({serverURL:"",path:""}),[n,r]=C(""),s=L(()=>({...Lr(e()),commentClassName:n(),renderPreview:e().renderPreview||(async b=>cr(b))})),o=L(()=>s().locale),[i,l]=C(void 0),[a,u]=C(void 0),c=({el:b="#sodesu",path:y=window.location.pathname,...h})=>{const w=b?Rr(b):null;if(b&&!w)throw new Error("Option 'el' do not match any domElement!");if(!w)throw new Error("Cannot get root!");if(!h.serverURL)throw new Error("Option 'serverURL' is missing!");return t({...h,path:y}),r(h.commentClassName||""),l(h.pageview),u(h.comment),w},d=b=>{t(y=>({...y,...b})),b.commentClassName&&r(b.commentClassName)},f=()=>{i()&&jr({serverURL:s().serverURL,path:s().path,selector:typeof i()=="string"?i():void 0})},g=()=>{a()&&Tr({serverURL:s().serverURL,path:s().path,selector:typeof a()=="string"?a():void 0})};return W(()=>{f()}),W(()=>{g()}),{setProps:t,config:s,locale:o,init:c,update:d,commentClassName:n}}),Mr=Symbol("store-raw"),Nr=Symbol("store-node"),se=Symbol("store-has"),Pr=Symbol("store-self");function de(e){let t;return e!=null&&typeof e=="object"&&(e[Kt]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Ve(e,t=new Set){let n,r,s,o;if(n=e!=null&&e[Mr])return n;if(!de(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let i=0,l=e.length;i<l;i++)s=e[i],(r=Ve(s,t))!==s&&(e[i]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const i=Object.keys(e),l=Object.getOwnPropertyDescriptors(e);for(let a=0,u=i.length;a<u;a++)o=i[a],!l[o].get&&(s=e[o],(r=Ve(s,t))!==s&&(e[o]=r))}return e}function Ur(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Nt(e,t,n){if(e[t])return e[t];const[r,s]=C(n,{equals:!1,internal:!0});return r.$=s,e[t]=r}function J(e,t,n,r=!1){if(!r&&e[t]===n)return;const s=e[t],o=e.length;n===void 0?(delete e[t],e[se]&&e[se][t]&&s!==void 0&&e[se][t].$()):(e[t]=n,e[se]&&e[se][t]&&s===void 0&&e[se][t].$());let i=Ur(e,Nr),l;if((l=Nt(i,t,s))&&l.$(()=>n),Array.isArray(e)&&e.length!==o){for(let a=e.length;a<o;a++)(l=i[a])&&l.$();(l=Nt(i,"length",o))&&l.$(e.length)}(l=i[Pr])&&l.$()}const Ge=Symbol("store-root");function ie(e,t,n,r,s){const o=t[n];if(e===o)return;const i=Array.isArray(e);if(n!==Ge&&(!de(e)||!de(o)||i!==Array.isArray(o)||s&&e[s]!==o[s])){J(t,n,e);return}if(i){if(e.length&&o.length&&(!r||s&&e[0]&&e[0][s]!=null)){let u,c,d,f,g,b,y,h;for(d=0,f=Math.min(o.length,e.length);d<f&&(o[d]===e[d]||s&&o[d]&&e[d]&&o[d][s]===e[d][s]);d++)ie(e[d],o,d,r,s);const w=new Array(e.length),$=new Map;for(f=o.length-1,g=e.length-1;f>=d&&g>=d&&(o[f]===e[g]||s&&o[d]&&e[d]&&o[f][s]===e[g][s]);f--,g--)w[g]=o[f];if(d>g||d>f){for(c=d;c<=g;c++)J(o,c,e[c]);for(;c<e.length;c++)J(o,c,w[c]),ie(e[c],o,c,r,s);o.length>e.length&&J(o,"length",e.length);return}for(y=new Array(g+1),c=g;c>=d;c--)b=e[c],h=s&&b?b[s]:b,u=$.get(h),y[c]=u===void 0?-1:u,$.set(h,c);for(u=d;u<=f;u++)b=o[u],h=s&&b?b[s]:b,c=$.get(h),c!==void 0&&c!==-1&&(w[c]=o[u],c=y[c],$.set(h,c));for(c=d;c<e.length;c++)c in w?(J(o,c,w[c]),ie(e[c],o,c,r,s)):J(o,c,e[c])}else for(let u=0,c=e.length;u<c;u++)ie(e[u],o,u,r,s);o.length>e.length&&J(o,"length",e.length);return}const l=Object.keys(e);for(let u=0,c=l.length;u<c;u++)ie(e[l[u]],o,l[u],r,s);const a=Object.keys(o);for(let u=0,c=a.length;u<c;u++)e[a[u]]===void 0&&J(o,a[u],void 0)}function Or(e,t={}){const{merge:n,key:r="id"}=t,s=Ve(e);return o=>{if(!de(o)||!de(s))return s;const i=ie(s,{[Ge]:o},Ge,n,r);return i===void 0?o:i}}function Pt(e,t={}){const n=t.storage||globalThis.localStorage,r=t.name||`storage-${dn()}`;if(!n)return[e[0],e[1],null];const s=t.storageOptions,o=t.serialize||JSON.stringify.bind(JSON),i=t.deserialize||JSON.parse.bind(JSON),l=n.getItem(r,s),a=typeof e[0]=="function"?c=>{try{const d=i(c);e[1](()=>d)}catch{}}:c=>{try{const d=i(c);e[1](Or(d))}catch{}};let u=!0;if(l instanceof Promise?l.then(c=>u&&c&&a(c)):l&&a(l),typeof t.sync?.[0]=="function"){const c=typeof e[0]=="function"?e[0]:()=>e[0];t.sync[0](d=>{d.key!==r||(d.url||globalThis.location.href)!==globalThis.location.href||d.newValue===o(O(c))||a(d.newValue)})}return[e[0],typeof e[0]=="function"?c=>{const d=e[1](c),f=c!=null?o(d):c;return t.sync?.[1](r,f),f!=null?n.setItem(r,f,s):n.removeItem(r,s),u=!1,d}:(...c)=>{e[1](...c);const d=o(O(()=>e[0]));t.sync?.[1](r,d),n.setItem(r,d,s),u=!1},l]}const q=F(()=>{const[e,t]=Pt(C(null),{name:"WALINE_USER",deserialize:o=>{try{return JSON.parse(o)}catch{return null}},serialize:o=>JSON.stringify(o)}),n=L(()=>!!e()?.token),r=L(()=>e()?.type==="administrator"),s=({data:o})=>{!o||o.type!=="profile"||(t(i=>({...i,...o.data})),[localStorage,sessionStorage].filter(i=>i.getItem("WALINE_USER")).forEach(i=>i.setItem("WALINE_USER",JSON.stringify(e))))};return Qt(()=>{window.addEventListener("message",s)}),ee(()=>{window.removeEventListener("message",s)}),{userInfo:e,isLogin:n,setUserInfo:t,isAdmin:r}});async function Br(){const{config:e}=D,{setUserInfo:t}=q,n=await On({serverURL:e().serverURL,lang:e().lang}),{remember:r,...s}=n;t({...s})}async function Dr(){const{setUserInfo:e}=q;e(null),localStorage.removeItem("WALINE_USER"),sessionStorage.removeItem("WALINE_USER"),fe()}async function Ut(){const{config:e}=D,{userInfo:t}=q,{serverURL:n,lang:r}=e(),s=800,o=800,i=(window.innerWidth-s)/2,l=(window.innerHeight-o)/2,a=new URLSearchParams({lng:r,token:t().token});window.open(`${n}/ui/profile?${a.toString()}`,"_blank",`width=${s},height=${o},left=${i},top=${l},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`)?.postMessage({type:"TOKEN",data:t().token},"*")}const Ot={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},zr=Object.keys(Ot);function We(e){const[t,n]=C(Bt("children"in e?e.children:[])),[r,s]=C(e.like||0),[o,i]=C(e.comment),[l,a]=C(e.orig);return{...e,time:e.time,children:t,setChildren:n,like:r,setLike:s,comment:o,setComment:i,orig:l,setOrig:a}}function Bt(e){return e.map(t=>We(t))}const le=F(()=>{const{config:e}=D,[t,n]=C("loading"),[r,s]=C(e().commentSorting),[o,i]=C(1),[l,a]=C(1),[u,c]=C([]),[d,f]=C(0);return{status:t,sorting:r,page:o,count:l,data:u,totalPages:d,setStatus:n,setSorting:s,setPage:i,setCount:a,setData:c,setTotalPages:f}});let Dt;function zt(e){const{sorting:t,setStatus:n,setCount:r,setData:s,setPage:o,setTotalPages:i}=le,{config:l}=D,{userInfo:a}=q,u=new AbortController;n("loading"),Dt?.(),Mn({serverURL:l().serverURL,lang:l().lang,path:l().path,pageSize:l().pageSize,sortBy:Ot[t()],page:e,signal:u.signal,token:a()?.token}).then(c=>{n("success"),r(c.count),s(d=>d.concat(...Bt(c.data))),o(e),i(c.totalPages)}).catch(c=>{c.name!=="AbortError"&&(console.error(c.message),n("error"))}),Dt=u.abort.bind(u)}function Fr(){const{page:e}=le;zt(e()+1)}function fe(){const{setCount:e,setData:t}=le;e(0),t([]),zt(1)}function Hr(e){const{setData:t}=le;t(n=>n.filter(r=>(r.setChildren(s=>s.filter(o=>o.objectId!==e)),r.objectId!==e)))}const X=F(()=>{const[e,t]=C(null),[n,r]=C(),[s,o]=C(),[i,l]=C(),[a,u]=C(""),[c,d]=C(0),[f,g]=C(!1),[b,y]=C(0),[h,w]=C(!1),[$,k]=C(!1),{config:m}=D,x=L(()=>({showPreview:$(),content:a()})),[N,{mutate:P}]=Zt(x,async E=>E.showPreview?m().renderPreview(E.content):""),A=L(()=>m().wordLimit);let _;return W(()=>{d(Hn(a()))}),W(()=>{if(A()){const E=A();c()<E[0]&&E[0]!==0?(y(E[0]),g(!1)):c()>E[1]?(y(E[1]),g(!1)):(y(E[1]),g(!0))}else y(0),g(!0)}),W(()=>{e()&&u(e().orig()||"")}),{edit:e,rootId:n,replyId:s,replyUser:i,content:a,wordCount:c,isWordCountLegal:f,wordLimit:b,isSubmitting:h,previewText:N,editorRef:_,showPreview:$,setEdit:t,setReplyId:o,setReplyUser:l,setRootId:r,setContent:u,setWordCount:d,setIsSubmitting:w,setPreviewText:P,setShowPreview:k}}),Ft=F(()=>{const[e,t]=C({nick:"",mail:"",link:""});return{userMeta:e,setUserMeta:t,inputRefs:{nick:void 0,mail:void 0,link:void 0}}});function xe(){const{setReplyId:e,setReplyUser:t,setRootId:n}=X;e(void 0),t(void 0),n(void 0)}function Ht(){const{config:e,locale:t}=D,{edit:n,content:r,wordCount:s,isWordCountLegal:o,rootId:i,replyId:l,replyUser:a,editorRef:u,setIsSubmitting:c,setEdit:d,setContent:f,setPreviewText:g}=X,{userMeta:b,inputRefs:y}=Ft,{userInfo:h}=q,{serverURL:w,lang:$,login:k,wordLimit:m,requiredMeta:x}=e(),{data:N,setData:P}=le,A={comment:r(),nick:b().nick,mail:b().mail,link:b().link,ua:navigator.userAgent,url:e().path,recaptchaV3:""};if(h()?.token)A.nick=h().display_name,A.mail=h().email,A.link=h().url;else{if(k==="force")return null;if(x.includes("nick")&&!A.nick)return y.nick?.focus(),alert(t().nickError);if(x.includes("mail")&&!A.mail||A.mail&&!/^\w(?:[\w.\-]*\w)?@(?:\w(?:[\w-]*\w)?\.)*\w+$/.exec(A.mail))return y.mail?.focus(),alert(t().mailError);if(!A.comment)return u?.focus(),null;A.nick||(A.nick=t().anonymous)}if(!o())return alert(t().wordHint.replace("$0",m[0].toString()).replace("$1",m[1].toString()).replace("$2",s().toString()));l()&&i()&&(A.pid=l(),A.rid=i(),A.at=a()),c(!0);const _={serverURL:w,lang:$,token:h()?.token||"",comment:A};return(n()?ht({objectId:n().objectId,..._}):Nn(_)).then(E=>{if(c(!1),E.errmsg)return alert(E.errmsg);const z=E.data;if(n()){const Y=N().find(he=>he.objectId===n().objectId);if(!Y)return null;Y.setComment(z.comment),z.orig&&Y.setOrig(z.orig),d(null),xe()}else if("rid"in z){const Y=N().find(he=>he.objectId===z.rid);if(!Y)return null;Y.setChildren(he=>[...he,We(z)]),xe()}else P(Y=>[We(z),...Y]);return f(""),g(""),l()&&xe(),null}).catch(E=>{c(!1),alert(E.message)})}var Vr=S('<button class="mb-0 ms-3 inline-block min-w-10 cursor-pointer touch-manipulation select-none border border-sBorder rounded-lg border-solid bg-transparent px-4 py-2 text-center text-xs text-sColor transition duration-400 disabled:cursor-not-allowed disabled:cursor-not-allowed disabled:border-sBorder hover:border-sTheme disabled:bg-sDisableBg disabled:text-sDisable disabled:text-sDisable hover:text-sTheme disabled:hover:border-sBorder disabled:hover:bg-sDisableBg disabled:hover:text-sDisable">');const Ae=e=>(()=>{var t=Vr();return An(t,e,!1),p(t,()=>e.children),t})();var Gr=S('<svg viewBox="0 0 1024 1024"width=24 height=24><path>'),Wr=S('<svg viewBox="0 0 100 100"preserveAspectRatio=xMidYMid><circle cx=50 cy=50 fill=none stroke=currentColor stroke-width=4 r=40 stroke-dasharray="85 30"><animateTransform attributeName=transform type=rotate repeatCount=indefinite dur=1s values="0 50 50;360 50 50"keyTimes=0;1>'),qr=S('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"><path fill=currentColor d="M20.56 18H3.44C2.65 18 2 17.37 2 16.59V7.41C2 6.63 2.65 6 3.44 6h17.12c.79 0 1.44.63 1.44 1.41v9.18c0 .78-.65 1.41-1.44 1.41M6.81 15.19v-3.66l1.92 2.35l1.92-2.35v3.66h1.93V8.81h-1.93l-1.92 2.35l-1.92-2.35H4.89v6.38h1.92M19.69 12h-1.92V8.81h-1.92V12h-1.93l2.89 3.28L19.69 12Z">'),Kr=S('<svg viewBox="0 0 1024 1024"width=24 height=24><path fill=currentColor d="M810.667 213.333a64 64 0 0 1 64 64V704a64 64 0 0 1-64 64H478.336l-146.645 96.107a21.333 21.333 0 0 1-33.024-17.856V768h-85.334a64 64 0 0 1-64-64V277.333a64 64 0 0 1 64-64h597.334zm0 64H213.333V704h149.334v63.296L459.243 704h351.424V277.333zm-271.36 213.334v64h-176.64v-64h176.64zm122.026-128v64H362.667v-64h298.666z">'),Jr=S('<svg viewBox="0 0 1024 1024"width=24 height=24><path d="M813.039 318.772L480.53 651.278H360.718V531.463L693.227 198.961C697.904 194.284 704.027 192 710.157 192C716.302 192 722.436 194.284 727.114 198.961L813.039 284.88C817.72 289.561 820 295.684 820 301.825C820 307.95 817.72 314.093 813.039 318.772ZM710.172 261.888L420.624 551.431V591.376H460.561L750.109 301.825L710.172 261.888ZM490.517 291.845H240.906V771.09H720.156V521.479C720.156 504.947 733.559 491.529 750.109 491.529C766.653 491.529 780.063 504.947 780.063 521.479V791.059C780.063 813.118 762.18 831 740.125 831H220.937C198.882 831 181 813.118 181 791.059V271.872C181 249.817 198.882 231.935 220.937 231.935H490.517C507.06 231.935 520.47 245.352 520.47 261.888C520.47 278.424 507.06 291.845 490.517 291.845Z"fill=currentColor>'),Xr=S('<svg viewBox="0 0 1024 1024"width=14 height=14 class="absolute inset-inline-[calc(var(--sds-avatar-real-size)*3/4)