ci: GHCR docker build for Lite branch + compose updates
- .github/workflows/docker-lite.yml: build & push ghcr.io/lezi-fun/ forumlify-deploy:lite on Lite branch push (linux/amd64+arm64) - docker-compose.yml: pull :lite image from GHCR, add PORT / ENABLE_ CAPTCHA env, restart: unless-stopped on both services
This commit is contained in:
1 parent
8f88f803f5
commit
9e407d0a2d
1532 files changed
+645187
-1
No files matched your search
@@ -0,0 +1,91 @@
|
||||
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,8671,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(74080);let s=null;function i(e){s=e,e?localStorage.setItem("forumlify-token",e):localStorage.removeItem("forumlify-token")}async function o(e,t={}){let r={...t.headers||{}};t.body&&"string"==typeof t.body&&(r["Content-Type"]="application/json"),s&&(r.Authorization="Bearer "+s);let n=await fetch("/api"+e,{...t,headers:r}),i=await n.json().catch(()=>({}));if(!n.ok||i.error){let e=Error(i.error||"请求失败");throw e.status=n.status,e}return i}s=localStorage.getItem("forumlify-token")||null;let a={async login(e,t){let r=await o("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return r.token&&i(r.token),r},getCaptcha:()=>o("/captcha"),register:(e,t,r,n)=>o("/auth/register",{method:"POST",body:JSON.stringify({email:e,password:t,username:r,captcha_id:n?.id,captcha_answer:n?.answer,captcha_sig:n?.sig})}),logout(){i(null)},getMe:()=>o("/auth/me"),getPosts(e,t,r=1,n=20){let s="/posts?sort="+(e||"latest")+"&page="+r+"&limit="+n;return t&&(s+="&user_id="+t),o(s)},getPost:e=>o("/posts/"+e),createPost:(e,t,r,n)=>o("/posts",{method:"POST",body:JSON.stringify({title:e,content:t,images:r||[],captcha_id:n?.id,captcha_answer:n?.answer,captcha_sig:n?.sig})}),updatePost:(e,t,r,n)=>o("/posts/"+e,{method:"PUT",body:JSON.stringify({title:t,content:r,images:n})}),togglePinPost:e=>o("/posts/"+e+"/pin",{method:"PUT"}),deletePost:e=>o("/posts/"+e,{method:"DELETE"}),getReplies:e=>o("/posts/"+e+"/replies"),createReply:(e,t,r,n)=>o("/posts/"+e+"/replies",{method:"POST",body:JSON.stringify({content:t,captcha_id:r?.id,captcha_answer:r?.answer,captcha_sig:r?.sig,reply_to_id:n||null})}),deleteReply:e=>o("/replies/"+e,{method:"DELETE"}),getUsers:()=>o("/users"),getUsersByUsername:e=>o("/users?username="+encodeURIComponent(e)),getUserProfile:e=>o("/users/profile/"+encodeURIComponent(e)),updateUserRole:(e,t)=>o("/users/"+e+"/role",{method:"PUT",body:JSON.stringify({role:t})}),updateProfile:(e,t,r,n)=>o("/users/"+e,{method:"PUT",body:JSON.stringify({username:t,bio:r,signature:n})}),updateAvatar:(e,t)=>o("/users/"+e+"/avatar",{method:"PUT",body:JSON.stringify({avatar_url:t})}),updatePassword:(e,t,r)=>o("/users/"+e+"/password",{method:"PUT",body:JSON.stringify({oldPassword:t,newPassword:r})}),updateEmail:(e,t,r)=>o("/users/"+e+"/email",{method:"PUT",body:JSON.stringify({password:t,newEmail:r})}),getReports:()=>o("/reports"),createReport:(e,t)=>o("/reports",{method:"POST",body:JSON.stringify({post_id:e,reason:t})}),updateReport:(e,t,r)=>o("/reports/"+e,{method:"PUT",body:JSON.stringify({status:t,note:r})}),getStats:()=>o("/stats"),getSettings:()=>o("/settings"),updateSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({forum_name:e})}),getLinks:()=>o("/links"),addLink:(e,t)=>o("/links",{method:"POST",body:JSON.stringify({title:e,url:t})}),deleteLink:e=>o("/links/"+e,{method:"DELETE"}),getEventLogs:()=>o("/event-logs"),logEvent:e=>o("/event-logs",{method:"POST",body:JSON.stringify({action:e})}).catch(()=>{}),getConversations:()=>o("/conversations"),getOrCreateConversation:e=>o("/conversations",{method:"POST",body:JSON.stringify({other_user_id:e})}),getMessages:e=>o("/conversations/"+e+"/messages"),sendMessage:(e,t)=>o("/conversations/"+e+"/messages",{method:"POST",body:JSON.stringify({content:t})}),markMessageRead:e=>o("/messages/"+e+"/read",{method:"PUT"}),getCustomPages:()=>o("/custom-pages"),getCustomPage:e=>o("/custom-pages/"+e),adminGetCustomPages:()=>o("/admin/custom-pages"),adminCreateCustomPage:(e,t,r)=>o("/admin/custom-pages",{method:"POST",body:JSON.stringify({name:e,title:t,content:r})}),adminUpdateCustomPage:(e,t,r,n)=>o("/admin/custom-pages/"+e,{method:"PUT",body:JSON.stringify({title:t,content:r,enabled:n})}),adminDeleteCustomPage:e=>o("/admin/custom-pages/"+e,{method:"DELETE"}),uploadCustomCss(e){let t=new FormData;t.append("file",e);let r={};return s&&(r.Authorization="Bearer "+s),fetch("/api/admin/custom-css",{method:"POST",body:t,headers:r}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok||t.error)throw Error(t.error||"上传失败");return t})},deleteCustomCss:()=>o("/admin/custom-css",{method:"DELETE"}),getNotifications:()=>o("/notifications"),markNotificationRead:e=>o("/notifications/"+e+"/read",{method:"PUT"}),markAllNotificationsRead:()=>o("/notifications/read-all",{method:"PUT"}),generateRecoveryCodes:()=>o("/auth/recovery-codes/generate",{method:"POST"}),getRecoveryCodeCount:()=>o("/auth/recovery-codes/count"),resetPassword:(e,t,r)=>o("/auth/reset-password",{method:"POST",body:JSON.stringify({email:e,recoveryCode:t,newPassword:r})})};async function l(e){let t=new FormData;t.append("file",e);let r={};s&&(r.Authorization="Bearer "+s);let n=await fetch("/api/upload",{method:"POST",body:t,headers:r}),i=await n.json().catch(()=>({}));if(!n.ok||i.error)throw Error(i.error||"上传失败");return i.url}let c=(0,r.creLine truncated
|
||||
]`).replace("lheading",O).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},et=/^( {2,}|\\)\n(?!\s*$)/,er=/[\p{P}\p{S}]/u,en=/[\s\p{P}\p{S}]/u,es=/[^\s\p{P}\p{S}]/u,ei=F(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,en).getRegex(),eo=/(?!~)[\p{P}\p{S}]/u,ea=F(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Q?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),el=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ec=F(el,"u").replace(/punct/g,er).getRegex(),eh=F(el,"u").replace(/punct/g,eo).getRegex(),eA=F(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,"u").replace(/openQuote/g,/[\p{Pi}\p{Ps}"']/u).replace(/punct/g,er).getRegex(),ed="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",eu=F(ed,"gu").replace(/notPunctSpace/g,es).replace(/punctSpace/g,en).replace(/punct/g,er).getRegex(),ep=F(ed,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,eo).getRegex(),eg=F("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,es).replace(/punctSpace/g,en).replace(/punct/g,er).getRegex(),ef=F("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,es).replace(/punctSpace/g,en).replace(/punct/g,er).getRegex(),em=F("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,es).replace(/punctSpace/g,en).replace(/punct/g,er).getRegex(),ex=F(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,er).getRegex(),ey=F("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,es).replace(/punctSpace/g,en).replace(/punct/g,er).getRegex(),eb=F(/\\(punct)/,"gu").replace(/punct/g,er).getRegex(),ew=F(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),eI=F(L).replace("(?:-->|$)","-->").getRegex(),eC=F("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",eI).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ev=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ek=F(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ev).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),eS=F(/^!?\[(label)\]\[(ref)\]/).replace("label",ev).replace("ref",U).getRegex(),eB=F(/^!?\[(ref)\](?:\[\])?/).replace("ref",U).getRegex(),ej=F("reflink|nolink(?!\\()","g").replace("reflink",eS).replace("nolink",eB).getRegex(),eE=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,eD={_backpedal:N,anyPunctuation:eb,autolink:ew,blockSkip:ea,br:et,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:N,delLDelim:N,delRDelim:N,emStrongLDelim:ec,emStrongRDelimAst:eu,emStrongRDelimUnd:ef,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:ek,nolink:eB,punctuation:ei,reflink:eS,reflinkSearch:ej,tag:eC,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:N},eN={...eD,emStrongLDelim:eA,emStrongRDelimAst:eg,emStrongRDelimUnd:em,link:F(/^!?\[(label)\]\((.*?)\)/).replace("label",ev).getRegex(),reflink:F(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ev).getRegex()},eR={...eD,emStrongRDelimAst:ep,emStrongLDelim:eh,delLDelim:ex,delRDelim:ey,url:F(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",eE).replace("email",/Line truncated
|
||||
`),r=t.length-1;for(;r>=0&&T.blankLine.test(t[r]);)r--;return t.length-r<=2?e:t.slice(0,r+1).join(`
|
||||
`)}function eJ(e,t,r,n,s){let i=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");n.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:r,href:i,title:o,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,l}var ez=class{options;rules;lexer;constructor(e){this.options=e||D}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:eU(t[0]),r=e.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],r=function(e,t,r){let n=e.match(r.other.indentCodeCompensation);if(null===n)return t;let s=n[1];return t.split(`
|
||||
`).map(e=>{let t=e.match(r.other.beginningSpace);if(null===t)return e;let[n]=t;return n.length>=s.length?e.slice(s.length):e}).join(`
|
||||
`)}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=eY(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:eY(t[0],`
|
||||
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:eY(t[0],`
|
||||
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=eY(t[0],`
|
||||
`).split(`
|
||||
`),r="",n="",s=[];for(;e.length>0;){let t=!1,i=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))i.push(e[o]),t=!0;else if(t)break;else i.push(e[o]);e=e.slice(o);let a=i.join(`
|
||||
`),l=a.replace(this.rules.other.blockquoteSetextReplace,`
|
||||
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
||||
${a}`:a,n=n?`${n}
|
||||
${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let t=e.join(`
|
||||
`),i=h.raw+`
|
||||
`+t.replace(this.rules.other.blockquoteSetextReplace2,""),o=this.blockquote(i);s[s.length-1]=o,r=`${r}
|
||||
${t}`,n=n.substring(0,n.length-h.text.length)+o.text;break}if(h?.type==="list"){let t=h.raw+`
|
||||
`+e.join(`
|
||||
`),i=this.list(t);s[s.length-1]=i,r=r.substring(0,r.length-h.raw.length)+i.raw,n=n.substring(0,n.length-h.raw.length)+i.raw,e=t.substring(s.at(-1).raw.length).split(`
|
||||
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:n}}}list(e){let t=this.rules.block.list.exec(e);if(t){let r=t[1].trim(),n=r.length>1,s={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:!1,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let i=this.rules.other.listItemRegex(r),o=!1;for(;e;){let r=!1,n="",a="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;n=t[0],e=e.substring(n.length);let l=function(e,t=0){let r=t,n="";for(let t of e)if(" "===t){let e=4-r%4;n+=" ".repeat(e),r+=e}else n+=t,r++;return n}(t[2].split(`
|
||||
`,1)[0],t[1].length),c=e.split(`
|
||||
`,1)[0],h=!l.trim(),A=0;if(this.options.pedantic?(A=2,a=l.trimStart()):h?A=t[1].length+1:(A=(A=l.search(this.rules.other.nonSpaceChar))>4?1:A,a=l.slice(A),A+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(n+=c+`
|
||||
`,e=e.substring(c.length+1),r=!0),!r){let t=this.rules.other.nextBulletRegex(A),r=this.rules.other.hrRegex(A),s=this.rules.other.fencesBeginRegex(A),i=this.rules.other.headingBeginRegex(A),o=this.rules.other.htmlBeginRegex(A),d=this.rules.other.blockquoteBeginRegex(A);for(;e;){let u=e.split(`
|
||||
`,1)[0],p;if(c=u,p=this.options.pedantic?c=c.replace(this.rules.other.listReplaceNesting," "):c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||i.test(c)||o.test(c)||d.test(c)||t.test(c)||r.test(c))break;if(p.search(this.rules.other.nonSpaceChar)>=A||!c.trim())a+=`
|
||||
`+p.slice(A);else{if(h||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||i.test(l)||r.test(l))break;a+=`
|
||||
`+c}h=!c.trim(),n+=u+`
|
||||
`,e=e.substring(u.length+1),l=p.slice(A)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(n)&&(o=!0)),s.items.push({type:"list_item",raw:n,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=n}let a=s.items.at(-1);if(!a)return;for(let e of(a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd(),s.items)){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(e.task&&(t?.type==="text"||t?.type==="paragraph")){e.text=e.text.replace(this.rules.other.listReplaceTask,""),t.raw=t.raw.replace(this.rules.other.listReplaceTask,""),t.text=t.text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}let r=this.rules.other.listTaskCheckbox.exec(e.raw);if(r){let t={type:"checkbox",raw:r[0]+" ",checked:"[ ]"!==r[0]};e.checked=t.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&(e.task=!1);if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type);s.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(s.loose)for(let e of s.items)for(let t of(e.loose=!0,e.tokens))"text"===t.type&&(t.type="paragraph");return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=eU(t[0]);return{type:"html",block:!0,raw:e,pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:eY(t[0],`
|
||||
`),href:r,title:n}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let r=eM(t[1]),n=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
||||
`):[],i={type:"table",raw:eY(t[0],`
|
||||
`),header:[],align:[],rows:[]};if(r.length===n.length){for(let e of n)this.rules.other.tableAlignRight.test(e)?i.align.push("right"):this.rules.other.tableAlignCenter.test(e)?i.align.push("center"):this.rules.other.tableAlignLeft.test(e)?i.align.push("left"):i.align.push(null);for(let e=0;e<r.length;e++)i.header.push({text:r[e],tokens:this.lexer.inline(r[e]),header:!0,align:i.align[e]});for(let e of s)i.rows.push(eM(e,i.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:i.align[t]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:"heading",raw:eY(t[0],`
|
||||
`),depth:"="===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
||||
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=eY(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e){if(-1===e.indexOf(")"))return -1;let t=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if("("===e[r])t++;else if(")"===e[r]&&--t<0)return r;return t>0?-2:-1}(t[2]);if(-2===e)return;if(e>-1){let r=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,r).trim(),t[3]=""}}let r=t[2],n="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(r);e&&(r=e[1],n=e[3])}else n=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(r=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?r.slice(1):r.slice(1,-1)),eJ(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let e=t[(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=r[0].charAt(0);return{type:"text",raw:e,text:e}}return eJ(r,e,r[0],this.lexer,this.rules)}}emStrong(e,t,r=""){let n=this.rules.inline.emStrongLDelim.exec(e);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!r||this.rules.inline.punctuation.exec(r))){let s=[...n[0]].length-1,i,o,a=s,l=0,c=n[0][0],h=r===c,A="*"===c?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(A.lastIndex=0,t=t.slice(-1*e.length+s);null!==(n=A.exec(t));){if(!(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6]))continue;if(o=[...i].length,n[3]||n[4]){a+=o;continue}if(n[5]||n[6]){if(s%3&&!((s+o)%3)){l+=o;continue}if(h)break}if((a-=o)>0)continue;o=Math.min(o,o+a+l);let t=[...n[0]][0].length,r=e.slice(0,s+n.index+t+o);if(Math.min(s,o)%2){let e=r.slice(1,-1);return{type:"em",raw:r,text:e,tokens:this.lexer.inlineTokens(e)}}let c=r.slice(2,-2);return{type:"strong",raw:r,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(e),n=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return r&&n&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,r=""){let n=this.rules.inline.delLDelim.exec(e);if(n&&(!n[1]||!r||this.rules.inline.punctuation.exec(r))){let r=[...n[0]].length-1,s,i,o=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+r);null!==(n=a.exec(t));){if(!(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6])||(i=[...s].length)!==r)continue;if(n[3]||n[4]){o+=i;continue}if((o-=i)>0)continue;i=Math.min(i,i+o);let t=[...n[0]][0].length,a=e.slice(0,r+n.index+t+i),l=a.slice(r,-r);return{type:"del",raw:a,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,r;return r="@"===t[2]?"mailto:"+(e=t[1]):e=t[1],{type:"link",raw:t[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,r;if("@"===t[2])r="mailto:"+(e=t[0]);else{let n;do n=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(n!==t[0])e=t[0],r="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},eZ=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||D,this.options.tokenizer=this.options.tokenizer||new ez,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:T,block:eQ.norm
Line truncated
|
||||
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(T.tabCharGlobal," ").replace(T.spaceLine,""));let n=1/0;for(;e;){let s;if(e.length<n)n=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}if(this.options.extensions?.block?.some(r=>!!(s=r.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let r=t.at(-1);1===s.raw.length&&void 0!==r?r.raw+=`
|
||||
`:t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`
|
||||
`)?"":`
|
||||
`)+s.raw,r.text+=`
|
||||
`+s.text,this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if((s=this.tokenizer.fences(e))||(s=this.tokenizer.heading(e))||(s=this.tokenizer.hr(e))||(s=this.tokenizer.blockquote(e))||(s=this.tokenizer.list(e))||(s=this.tokenizer.html(e))){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`
|
||||
`)?"":`
|
||||
`)+s.raw,r.text+=`
|
||||
`+s.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},t.push(s));continue}if((s=this.tokenizer.table(e))||(s=this.tokenizer.lheading(e))){e=e.substring(s.raw.length),t.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,r=e.slice(1),n;this.options.extensions.startBlock.forEach(e=>{"number"==typeof(n=e.call({lexer:this},r))&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let n=t.at(-1);r&&n?.type==="paragraph"?(n.raw+=(n.raw.endsWith(`
|
||||
`)?"":`
|
||||
`)+s.raw,n.text+=`
|
||||
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(s),r=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="text"?(r.raw+=(r.raw.endsWith(`
|
||||
`)?"":`
|
||||
`)+s.raw,r.text+=`
|
||||
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf("[")+1,-1))?"["+"a".repeat(t.length-2)+"]":t))}r=(r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++")).replace(this.tokenizer.rules.inline.blockSkip,(e,t,r)=>{let n=r?r.length:0;return e.slice(0,n)+"["+"a".repeat(e.length-n-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let n=!1,s="",i=1/0;for(;e;){let o;if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}if(n||(s=""),n=!1,this.options.extensions?.inline?.some(r=>!!(o=r.call({lexer:this},e,t))&&(e=e.substring(o.raw.length),t.push(o),!0)))continue;if((o=this.tokenizer.escape(e))||(o=this.tokenizer.tag(e))||(o=this.tokenizer.link(e))){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let r=t.at(-1);"text"===o.type&&r?.type==="text"?(r.raw+=o.raw,r.text+=o.text):t.push(o);continue}if((o=this.tokenizer.emStrong(e,r,s))||(o=this.tokenizer.codespan(e))||(o=this.tokenizer.br(e))||(o=this.tokenizer.del(e,r,s))||(o=this.tokenizer.autolink(e))||!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let t=1/0,r=e.slice(1),n;this.options.extensions.startInline.forEach(e=>{"number"==typeof(n=e.call({lexer:this},r))&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),"_"!==o.raw.slice(-1)&&(s=o.raw.slice(-1)),n=!0;let r=t.at(-1);r?.type==="text"?(r.raw+=o.raw,r.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw Error(t)}},eL=class{options;parser;constructor(e){this.options=e||D}space(e){return""}code({text:e,lang:t,escaped:r}){let n=(t||"").match(T.notSpaceStart)?.[0],s=e.replace(T.endingNewline,"")+`
|
||||
`;return n?'<pre><code class="language-'+eG(n)+'">'+(r?s:eG(s,!0))+`</code></pre>
|
||||
`:"<pre><code>"+(r?s:eG(s,!0))+`</code></pre>
|
||||
`}blockquote({tokens:e}){return`<blockquote>
|
||||
${this.parser.parse(e)}</blockquote>
|
||||
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
||||
`}hr(e){return`<hr>
|
||||
`}list(e){let t=e.ordered,r=e.start,n="";for(let t=0;t<e.items.length;t++){let r=e.items[t];n+=this.listitem(r)}let s=t?"ol":"ul";return"<"+s+(t&&1!==r?' start="'+r+'"':"")+`>
|
||||
`+n+"</"+s+`>
|
||||
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
||||
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
||||
`}table(e){let t="",r="";for(let t=0;t<e.header.length;t++)r+=this.tablecell(e.header[t]);t+=this.tablerow({text:r});let n="";for(let t=0;t<e.rows.length;t++){let s=e.rows[t];r="";for(let e=0;e<s.length;e++)r+=this.tablecell(s[e]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
||||
<thead>
|
||||
`+t+`</thead>
|
||||
`+n+`</table>
|
||||
`}tablerow({text:e}){return`<tr>
|
||||
${e}</tr>
|
||||
`}tablecell(e){let t=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+t+`</${r}>
|
||||
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${eG(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:r}){let n=this.parser.parseInline(r),s=eO(e);if(null===s)return n;let i='<a href="'+(e=s)+'"';return t&&(i+=' title="'+eG(t)+'"'),i+=">"+n+"</a>"}image({href:e,title:t,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let s=eO(e);if(null===s)return eG(r);e=s;let i=`<img src="${e}" alt="${eG(r)}"`;return t&&(i+=` title="${eG(t)}"`),i+=">"}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:eG(e.text)}},eP=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},eH=class e{options;renderer;textRenderer;constructor(e){this.options=e||D,this.options.renderer=this.options.renderer||new eL,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new eP}static parse(t,r){return new e(r).parse(t)}static parseInline(t,r){return new e(r).parseInline(t)}parse(e){this.renderer.parser=this;let t="";for(let r=0;r<e.length;r++){let n=e[r];if(this.options.extensions?.renderers?.[n.type]){let e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(n.type)){t+=e||"";continue}}switch(n.type){case"space":t+=this.renderer.space(n);break;case"hr":t+=this.renderer.hr(n);break;case"heading":t+=this.renderer.heading(n);break;case"code":t+=this.renderer.code(n);break;case"table":t+=this.renderer.table(n);break;case"blockquote":t+=this.renderer.blockquote(n);break;case"list":t+=this.renderer.list(n);break;case"checkbox":t+=this.renderer.checkbox(n);break;case"html":t+=this.renderer.html(n);break;case"def":t+=this.renderer.def(n);break;case"paragraph":t+=this.renderer.paragraph(n);break;case"text":t+=this.renderer.text(n);break;default:{let e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let r="";for(let n=0;n<e.length;n++){let s=e[n];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(s.type)){r+=e||"";continue}}switch(s.type){case"escape":case"text":r+=t.text(s);break;case"html":r+=t.html(s);break;case"link":r+=t.link(s);break;case"image":r+=t.image(s);break;case"checkbox":r+=t.checkbox(s);break;case"strong":r+=t.strong(s);break;case"em":r+=t.em(s);break;case"codespan":r+=t.codespan(s);break;case"br":r+=t.br(s);break;case"del":r+=t.del(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw Error(e)}}}return r}},eV=class{options;block;constructor(e){this.options=e||D}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?eZ.lex:eZ.lexInline}provideParser(e=this.block){return e?eH.parse:eH.parseInline}},eX=new class{defaults=E();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=eH;Renderer=eL;TextRenderer=eP;Lexer=eZ;Tokenizer=ez;Hooks=eV;constructor(...e){this.use(...e)}walkTokens(e,t){let r=[];for(let n of e)switch(r=r.concat(t.call(this,n)),n.type){case"table":for(let e of n.header)r=r.concat(this.walkTokens(e.tokens,t));for(let e of n.rows)for(let n of e)r=r.concat(this.walkTokens(n.tokens,t));break;case"list":r=r.concat(this.walkTokens(n.items,t));break;default:{let e=n;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(n=>{let s=e[n].flat(1/0);r=r.concat(this.walkTokens(s,t))}):e.tokens&&(r=r.concat(this.walkTokens(e.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let r={...e};if(r.async=this.defaults.async||r.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error("extension name required");if("renderer"in e){let r=t.renderers[e.name];r?t.renderers[e.name]=function(...t){let n=e.renderer.apply(this,t);return!1===n&&(n=r.apply(this,t)),n}:t.renderers[e.name]=e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw Error("extension leveLine truncated
|
||||
Please report this to https://github.com/markedjs/marked.`,e){let e="<p>An error occurred:</p><pre>"+eG(r.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(r);throw r}}};function eq(e,t){return eX.parse(e,t)}eq.options=eq.setOptions=function(e){return eX.setOptions(e),eq.defaults=eX.defaults,D=eq.defaults,eq},eq.getDefaults=E,eq.defaults=D,eq.use=function(...e){return eX.use(...e),eq.defaults=eX.defaults,D=eq.defaults,eq},eq.walkTokens=function(e,t){return eX.walkTokens(e,t)},eq.parseInline=eX.parseInline,eq.Parser=eH,eq.parser=eH.parse,eq.Renderer=eL,eq.TextRenderer=eP,eq.Lexer=eZ,eq.lexer=eZ.lex,eq.Tokenizer=ez,eq.Hooks=eV,eq.parse=eq,eq.options,eq.setOptions,eq.walkTokens,eq.parseInline,eH.parse,eZ.lex;var e_=e.i(44821);let e$={allowedTags:["p","br","hr","strong","em","b","i","u","s","del","ins","a","img","code","pre","blockquote","ul","ol","li","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","th","td","span","div"],allowedAttributes:{a:["href","target","rel","title"],img:["src","alt","title","width","height"],code:["class"],pre:["class"],span:["class"],div:["class"],th:["align","colspan","rowspan"],td:["align","colspan","rowspan"],table:["align","border","cellpadding","cellspacing"]},allowedSchemes:["http","https","mailto"],allowedSchemesByTag:{img:["http","https"]},allowedSchemesAppliedToAttributes:["href","src","cite"],allowProtocolRelative:!1,disallowedTagsMode:"discard"};function e0(e){if(!e)return"";try{let t=eq.parse(e);return(0,e_.default)(t,e$)}catch{return(0,e_.default)(e.replace(/\n/g,"<br>"),e$)}}function e1({onOpenModal:e,onReport:n}){let{currentUser:s,sort:i,setSort:o,openPost:l,openUser:c,navigate:h,refreshKey:A}=p(),{t:d}=(0,f.useTranslation)(),{toast:u,confirmAction:g}=(0,y.useToast)(),[x,b]=(0,r.useState)(null),[w,I]=(0,r.useState)(null),[C,v]=(0,r.useState)(!0),[k,S]=(0,r.useState)(1),[B,E]=(0,r.useState)(1),[D,N]=(0,r.useState)(null),[R,F]=(0,r.useState)(i),[Q,T]=(0,r.useState)("idle"),W=(0,r.useRef)(null),K=(0,r.useRef)(null),G=(0,r.useRef)(null),O=(0,r.useCallback)(async e=>{I(null);try{let t=await a.getPosts(i,null,e,20);b(t.data||[]),E(t.pagination?.totalPages||1),S(t.pagination?.page||1)}catch(e){I(e.message),b([])}finally{G.current===i&&requestAnimationFrame(()=>{T("opening"),K.current=setTimeout(()=>{G.current=null,T("idle")},360)})}},[i,A]);(0,r.useEffect)(()=>{O(k)},[O]),(0,r.useEffect)(()=>{x&&0!==x.length&&W.current&&W.current.querySelectorAll(".post-content").forEach(e=>{e.scrollHeight>e.clientHeight+4?e.classList.add("has-fade"):e.classList.remove("has-fade")})},[x]),(0,r.useEffect)(()=>{S(1)},[i]),(0,r.useEffect)(()=>()=>clearTimeout(K.current),[]);let M=e=>{if(e!==R){if(F(e),clearTimeout(K.current),e===i){G.current=null,T("opening"),K.current=setTimeout(()=>T("idle"),360);return}T("closing"),K.current=setTimeout(()=>{G.current=e,T("closed"),o(e)},220)}},Y=async e=>{if(await g(d("feed.confirmDelete")))try{await a.deletePost(e),O(k)}catch(e){u(d("feed.deleteFailed",{msg:e.message}),"error")}};return(0,t.jsxs)("main",{id:"feed",children:[(0,t.jsxs)("div",{className:"feed-header",children:[(0,t.jsxs)("div",{className:"feed-header-left",children:[(0,t.jsx)("button",{className:"tab"+("latest"===R?" active":""),onClick:()=>M("latest"),children:d("feed.latest")}),(0,t.jsx)("button",{className:"tab"+("hot"===R?" active":""),onClick:()=>M("hot"),children:d("feed.hot")})]}),(0,t.jsxs)("button",{className:"btn-primary fab-btn",onClick:()=>{s?h("new"):u(d("newPost.pleaseLogin"),"warning")},children:[(0,t.jsx)(m.Icon,{name:"plus"})," ",d("feed.newPost")]})]}),(0,t.jsx)("div",{className:"feed-posts-drawer "+Q,children:(0,t.jsx)("div",{className:"feed-posts-drawer-inner",children:(0,t.jsx)("div",{id:"postList",ref:W,children:null===x?(0,t.jsxs)("div",{style:{textAlign:"center",color:"#94a3b8",padding:"40px 0"},children:[(0,t.jsx)("span",{className:"spinner-sm"}),d("feed.loading")]}):w?(0,t.jsx)("div",{style:{textAlign:"center",color:"#ef4444",padding:"40px 0"},children:d("feed.loadFailed",{msg:w})}):0===x.length?(0,t.jsx)("div",{style:{textAlign:"center",color:"#94a3b8",padding:"60px 0"},children:d("feed.empty")}):x.map(e=>{let r=e.created_at?new Date(e.created_at).toLocaleString("zh-CN"):"";return(0,t.jsxs)("div",{className:"post-card","data-post-id":e.id,style:{cursor:"pointer"},onClick:t=>l(e.id,t.currentTarget,e),children:[e.is_pinned&&(0,t.jsxs)("div",{className:"post-pin-state",style:{width:"fit-content",display:"flex",alignItems:"center",gap:3,fontSize:12,color:"var(--primary)",fontWeight:600,marginBottom:4},children:[(0,t.jsx)(m.Icon,{name:"pin",size:12})," ",d("feed.pinned")]}),(0,t.jsxs)("div",{className:"post-header",children:[(0,t.jsx)("img",{src:e.avatar_url||"https://ui-avatars.com/api/?name="+encodeURIComponent(e.username||"匿名用户")+"&background=6366f1&color=fff&size=64",className:"post-avatar",alt:""}),(0,t.jsx)("span",{className:"post-username",style:{cursor:"pointer",color:"var(--primary)"},onClick:t=>{t.stopPropagation
Line truncated
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
padding: 24px;
|
||||
background: var(--bg, #f6f8fc);
|
||||
color: var(--text, #0a0e1a);
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #0f1117; color: #e8edf5; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>${n}</body>
|
||||
</html>`;return(0,t.jsx)("div",{className:"custom-page-container",style:{padding:"84px 32px 40px",background:"var(--bg)",minHeight:"100vh"},children:(0,t.jsx)("iframe",{style:{width:"100%",minHeight:"70vh",border:"none",borderRadius:8,background:"var(--surface)"},sandbox:"allow-scripts allow-modals allow-same-origin",srcDoc:l,title:e})})}let tp={reply:"message",post_deleted:"trash",report_handled:"shield",system:"megaphone"};function tg(){let{currentUser:e}=p(),[n,s]=(0,r.useState)(null),[i,o]=(0,r.useState)(null);return((0,r.useEffect)(()=>{e&&a.getNotifications().then(e=>{s(e||[]),o(null),a.markAllNotificationsRead().catch(()=>{})}).catch(e=>{o(e.message),s([])})},[e]),e)?(0,t.jsxs)("div",{className:"page-slide active",children:[(0,t.jsx)("div",{className:"page-header",style:{maxWidth:700,margin:"0 auto",width:"100%"},children:(0,t.jsxs)("h2",{children:[(0,t.jsx)(m.Icon,{name:"message",size:20})," 消息"]})}),(0,t.jsx)("div",{style:{maxWidth:700,margin:"0 auto",width:"100%"},children:i?(0,t.jsxs)("div",{style:{textAlign:"center",color:"#ef4444",padding:20},children:["加载失败:",i]}):null===n?(0,t.jsx)("div",{style:{textAlign:"center",color:"#94a3b8",padding:"40px 0"},children:"加载中..."}):0===n.length?(0,t.jsxs)("div",{style:{textAlign:"center",color:"#94a3b8",padding:"60px 0"},children:[(0,t.jsx)(m.Icon,{name:"message",size:48}),(0,t.jsx)("p",{style:{fontSize:16},children:"暂无消息"}),(0,t.jsx)("p",{style:{fontSize:13},children:"当有人回复你的帖子或处理你的举报时,会在这里通知你"})]}):n.map(e=>{let r=tp[e.type]||"pin",n=e.created_at?new Date(e.created_at).toLocaleString("zh-CN"):"";return(0,t.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:"14px 16px",borderBottom:"1px solid var(--border-light)",background:"var(--surface)",borderRadius:6,marginBottom:6},children:[(0,t.jsx)("span",{style:{color:"var(--text-secondary)",paddingTop:2},children:(0,t.jsx)(m.Icon,{name:r,size:20})}),(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("div",{style:{fontWeight:600,fontSize:14},children:e.title}),(0,t.jsx)("div",{style:{color:"var(--text-secondary)",fontSize:13,marginTop:2},children:e.content}),e.link&&(0,t.jsx)("a",{href:e.link,style:{color:"var(--primary)",fontSize:13,textDecoration:"none",marginTop:4,display:"inline-block"},children:"查看详情 →"}),(0,t.jsx)("div",{style:{fontSize:12,color:"var(--text-light)",marginTop:4},children:n})]})]},e.id)})})]}):(0,t.jsx)("div",{className:"page-slide active",style:{textAlign:"center",color:"#94a3b8",padding:"40px 0"},children:"请先登录"})}function tf({modal:e,onClose:n,reportPostId:s}){let{login:i,register:o,currentUser:l,refresh:c}=p(),{t:h}=(0,f.useTranslation)(),{toast:A}=(0,y.useToast)(),[d,u]=(0,r.useState)(""),[g,x]=(0,r.useState)(""),[b,w]=(0,r.useState)(""),[I,C]=(0,r.useState)(""),[v,k]=(0,r.useState)(""),[S,B]=(0,r.useState)(null),[j,E]=(0,r.useState)(""),[D,N]=(0,r.useState)("spam");if((0,r.useEffect)(()=>{"register"===e&&a.getCaptcha().then(e=>B(e)).catch(()=>{})},[e]),!e)return null;let R=e=>{e&&e.target!==e.currentTarget||n()},F=async()=>{if(!d.trim()||!g)return void A("请填写完整信息","warning");try{(await i(d.trim(),g)).user&&(n(),u(""),x(""),c())}catch(e){A("登录失败:"+e.message,"error")}},Q=async()=>{if(!b.trim()||!I.trim()||!v)return void A("请填写完整信息","warning");if(v.length<6)return void A("密码至少6位","warning");if(!S||!j.trim())return void A("请填写验证码","warning");try{await o(I.trim(),v,b.trim(),{id:S.id,answer:j.trim(),sig:S.sig}),n(),w(""),C(""),k(""),E(""),A("注册成功!","success"),c()}catch(e){A("注册失败:"+e.message,"error"),a.getCaptcha().then(e=>B(e)).catch(()=>{}),E("")}},T=async()=>{if(s)try{await a.createReport(s,D),n(),A("举报已提交,管理员将尽快处理","success")}catch(e){A("举报失败:"+e.message,"error")}};return(0,t.jsxs)(t.Fragment,{children:["login"===e&&(0,t.jsx)("div",{className:"modal active",onClick:R,children:(0,t.jsxs)("div",{className:"modal-content",children:[(0,t.jsx)("span",{className:"close",onClick:n,children:(0,t.jsx)(m.Icon,{name:"close",size:20})}),(0,t.jsx)("h2",{style:{marginBottom:16},children:h("auth.login")}),(0,t.jsx)("input",{type:"email",placeholder:h("auth.email"),value:d,onChange:e=>u(e.target.value)}),(0,t.jsx)("input",{type:"password",placeholder:h("auth.password"),value:g,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key&&F()}}),(0,t.jsx)("button",{className:"btn-primary",style:{width:"100%"},onClick:F,children:h("auth.login")})]})}),"register"===e&&(0,t.jsx)("div",{className:"modal active",onClick:R,children:(0,t.jsxs)("div",{className:"modal-content",children:[(0,t.jsx)("span",{className:"close",onClick:n,children:(0,t.jsx)(m.Icon,{name:"close",size:20})}),(0,t.jsx)("h2",{style:{marginBottom:16},children:h("auth.register")}),(0,t.jsx)("input",{type:"text",placeholder:h("auth.username"),value:b,onChange:e=>w(e.target.value)}),(0,t.jsx)("inputLine truncated
|
||||
|
||||
⚠️ Your \`allowedTags\` option includes, \`${e}\`, which is inherently
|
||||
vulnerable to XSS attacks. Please remove it from \`allowedTags\`.
|
||||
Or, to disable this warning, add the \`allowVulnerableTags\` option
|
||||
and ensure you are accounting for this risk.
|
||||
|
||||
`)});let N=t.nonTextTags||["script","style","textarea","option","xmp"];t.allowedAttributes&&(x={},y={},d(t.allowedAttributes,function(e,t){x[t]=[];let r=[];e.forEach(function(e){"string"==typeof e&&e.indexOf("*")>=0?r.push(s(e).replace(/\\\*/g,".*")):x[t].push(e)}),r.length&&(y[t]=RegExp("^("+r.join("|")+")$"))}));let R={},F={},Q={};d(t.allowedClasses,function(e,t){if(x&&(u(x,t)||(x[t]=[]),x[t].push("class")),R[t]=e,Array.isArray(e)){let r=[];R[t]=[],Q[t]=[],e.forEach(function(e){"string"==typeof e&&e.indexOf("*")>=0?r.push(s(e).replace(/\\\*/g,".*")):e instanceof RegExp?Q[t].push(e):R[t].push(e)}),r.length&&(F[t]=RegExp("^("+r.join("|")+")$"))}});let T={};d(t.transformTags,function(e,t){let r;"function"==typeof e?r=e:"string"==typeof e&&(r=f.simpleTransform(e)),"*"===t?b=r:T[t]=r});let W=!1;G();let K=new n.Parser({onopentag:function(e,r){let n;if(t.onOpenTag&&t.onOpenTag(e,r),t.enforceHtmlBoundary&&"html"===e&&G(),k)return void S++;let s=new E(e,r);I.push(s);let c=!1,h=!!s.text;if(u(T,e)&&(s.attribs=r=(n=T[e](e,r)).attribs,void 0!==n.text&&(s.innerText=n.text),e!==n.tagName&&(s.name=e=n.tagName,v[w]=n.tagName)),b&&(s.attribs=r=(n=b(e,r)).attribs,e!==n.tagName&&(s.name=e=n.tagName,v[w]=n.tagName)),(!D(e)||"recursiveEscape"===t.disallowedTagsMode&&!function(e){for(let t in e)if(u(e,t))return!1;return!0}(C)||null!=t.nestingLimit&&w>=t.nestingLimit)&&(c=!0,C[w]=!0,("discard"===t.disallowedTagsMode||"completelyDiscard"===t.disallowedTagsMode)&&-1!==N.indexOf(e)&&(k=!0,S=1)),w++,c){if("discard"===t.disallowedTagsMode||"completelyDiscard"===t.disallowedTagsMode){if(s.innerText&&!h){let r=O(s.innerText);t.textFilter?B+=t.textFilter(r,e):B+=r,W=!0}return}j=B,B=""}if(B+="<"+e,"script"===e&&(t.allowedScriptHostnames||t.allowedScriptDomains)&&(s.innerText=""),c&&("escape"===t.disallowedTagsMode||"recursiveEscape"===t.disallowedTagsMode)&&t.preserveEscapedAttributes?d(r,function(e,t){B+=" "+t+'="'+O(e||"",!0)+'"'}):(!x||u(x,e)||x["*"])&&d(r,function(r,n){if(!g.test(n)||""===r&&!t.allowedEmptyAttributes.includes(n)&&(t.nonBooleanAttributes.includes(n)||t.nonBooleanAttributes.includes("*")))return void delete s.attribs[n];let c=!1;if(!x||u(x,e)&&-1!==x[e].indexOf(n)||x["*"]&&-1!==x["*"].indexOf(n)||u(y,e)&&y[e].test(n)||y["*"]&&y["*"].test(n))c=!0;else if(x&&x[e]){for(let t of x[e])if(i(t)&&t.name&&t.name===n){c=!0;let e="";if(!0===t.multiple)for(let n of r.split(" "))-1!==t.values.indexOf(n)&&(""===e?e=n:e+=" "+n);else t.values.indexOf(r)>=0&&(e=r);r=e}}if(c){if(-1!==t.allowedSchemesAppliedToAttributes.indexOf(n)&&M(e,r))return void delete s.attribs[n];if("script"===e&&"src"===n){let e=!0;try{let n=Y(r);if(t.allowedScriptHostnames||t.allowedScriptDomains){let r=(t.allowedScriptHostnames||[]).find(function(e){return e===n.url.hostname}),s=(t.allowedScriptDomains||[]).find(function(e){return n.url.hostname===e||n.url.hostname.endsWith(`.${e}`)});e=r||s}}catch(t){e=!1}if(!e)return void delete s.attribs[n]}if("iframe"===e&&"src"===n){let e=!0;try{let n=Y(r);if(n.isRelativeUrl)e=u(t,"allowIframeRelativeUrls")?t.allowIframeRelativeUrls:!t.allowedIframeHostnames&&!t.allowedIframeDomains;else if(t.allowedIframeHostnames||t.allowedIframeDomains){let r=(t.allowedIframeHostnames||[]).find(function(e){return e===n.url.hostname}),s=(t.allowedIframeDomains||[]).find(function(e){return n.url.hostname===e||n.url.hostname.endsWith(`.${e}`)});e=r||s}}catch(t){e=!1}if(!e)return void delete s.attribs[n]}if("srcset"===n||"imagesrcset"===n)try{let e=a(r);if(e.forEach(function(e){M(n,e.url)&&(e.evil=!0)}),!(e=p(e,function(e){return!e.evil})).length)return void delete s.attribs[n];r=p(e,function(e){return!e.evil}).map(function(e){if(!e.url)throw Error("URL missing");return e.url+(e.w?` ${e.w}w`:"")+(e.h?` ${e.h}h`:"")+(e.d?` ${e.d}x`:"")}).join(", "),s.attribs[n]=r}catch(e){delete s.attribs[n];return}if("class"===n){let t=R[e],i=R["*"],a=F[e],l=Q[e],c=Q["*"],h=[a,F["*"]].concat(l,c).filter(function(e){return e});if(!(r=t&&i?U(r,o(t,i),h):U(r,t||i,h)).length)return void delete s.attribs[n]}if("style"===n){if(t.parseStyleAttributes)try{let i=l(e+" {"+r+"}",{map:!1});if(r=(function(e,t){var r;let n;if(!t)return e;let s=e.nodes[0];return(n=t[s.selector]&&t["*"]?o(t[s.selector],t["*"]):t[s.selector]||t["*"])&&(e.nodes[0].nodes=s.nodes.reduce((r=n,function(e,t){return u(r,t.prop)&&r[t.prop].some(function(e){return e.test(t.value)})&&e.push(t),e}),[])),e})(i,t.allowedStyles).nodes[0].nodes.reduce(function(e,t){return e.push(`${t.prop}:${t.value}${t.important?" !important":""}`),e},[]).join(";"),0===r.length)return void delete s.attribs[n]}catch(t){"u">typeof window&&console.warn('Failed to parse "'+e+" {"+r+"}\", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547"),delete s.attribs[n];return}else if(t.allowedStyles)throw Error("allowedStyles option
Line truncated
|
||||
Reference in new issue
Block a user