text: (()=>{var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t);const n=flarum.core.compat["forum/app"];var r=e.n(n);const a=flarum.core.compat["common/extend"],i=flarum.core.compat["forum/components/CommentPost"];var o=e.n(i);r().initializers.add("ecnu-im/flarum-link-preview",(function(){(0,a.extend)(o().prototype,"oncreate",(function(){var e=r().forum.attribute("datlechin-link-preview.blacklist"),t=e?e.split(",").map((function(e){return e.trim()})):[];this.element.querySelectorAll(".Post-body a[rel]").forEach((function(e){var n=e.getAttribute("href");if(n.match(/^(http|https):\/\//)){var a=n.split("/")[2].replace("www.","");if(!(e.classList.contains("PostMention")&&e.classList.contains("UserMention")||n!==e.textContent||t.includes(a)||t.includes(n))){if(!r().forum.attribute("datlechin-link-preview.convertMediaURLs")&&n.match(/\.(jpe?g|png|gif|svg|webp|mp3|mp4|m4a|wav)$/))return;var i=document.createElement("div");i.classList.add("LinkPreview"),e.parentNode.insertBefore(i,e),i.appendChild(e);var o=document.createElement("div");o.classList.add("LinkPreview-image"),i.appendChild(o);var d=document.createElement("img");o.appendChild(d);var l=document.createElement("div");l.classList.add("LinkPreview-main"),i.appendChild(l);var c=document.createElement("div");c.classList.add("LinkPreview-title"),l.appendChild(c);var s=document.createElement("a");s.target="_blank",c.appendChild(s);var m=document.createElement("div");m.classList.add("LinkPreview-description"),l.appendChild(m);var p=document.createElement("div");p.classList.add("LinkPreview-domain"),l.appendChild(p);var u=document.createElement("a");u.href=n,u.target="_blank";var v=n.split("/")[0]+"//"+a,f=document.createElement("img");f.setAttribute("src","https://www.google.com/s2/favicons?sz=64&domain_url="+v),p.appendChild(f),u.textContent=a,p.appendChild(u),u.href=v;var h=document.createElement("i");h.classList.add("fa","fa-spinner","fa-spin"),o.appendChild(h),e.remove(),r().request({url:r().forum.attribute("apiUrl")+"/datlechin-link-preview?url="+encodeURIComponent(n),method:"GET"}).then((function(e){h.remove(),d.setAttribute("src",e.image?e.image:"https://www.google.com/s2/favicons?sz=64&domain_url="+v),s.href=e.url?e.url:n,s.textContent=e.title?e.title:a,m.textContent=e.description?e.description:"",u.textContent=e.site_name?e.site_name:a,e.error&&(s.textContent=r().translator.trans("datlechin-link-preview.forum.site_cannot_be_reached"),s.removeAttribute("href"),m.textContent="",u.removeAttribute("href"))}))}}}))}))}))})(),module.exports=t})();
  //# sourceMappingURL=forum.js.map