writedock-mcp 0.4.4 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +21 -20
  2. package/extension/LICENSE-MULTIPOST.txt +201 -0
  3. package/extension/LICENSE.txt +674 -0
  4. package/extension/NOTICE.txt +13 -0
  5. package/extension/assets/editor-ClIT9WYa.js +76 -0
  6. package/extension/assets/editor-VBFqqvXW.css +1 -0
  7. package/extension/assets/icon-128.png +0 -0
  8. package/extension/assets/icon-16.png +0 -0
  9. package/extension/assets/icon-48.png +0 -0
  10. package/extension/assets/index.browser-Hs3ZYqOv.js +157 -0
  11. package/extension/assets/index.ts-BEVXnN62.js +42 -0
  12. package/extension/assets/logo.svg +5 -0
  13. package/extension/assets/offscreen-3BECPbQX.js +63 -0
  14. package/extension/assets/purify.es-1yEQDPgc.js +3 -0
  15. package/extension/assets/react-vendor-BrXlnJmF.js +40 -0
  16. package/extension/assets/task-utils-DwzGcJkm.js +1 -0
  17. package/extension/manifest.json +40 -0
  18. package/extension/service-worker-loader.js +1 -0
  19. package/extension/src/editor/index.html +16 -0
  20. package/extension/src/offscreen/index.html +6 -0
  21. package/extension/zhihu-publication-observer.js +1 -0
  22. package/extension//345/256/211/350/243/205/344/270/216/346/233/264/346/226/260.txt +19 -0
  23. package/index.cjs +290 -131
  24. package/package.json +3 -2
  25. package/source/package.json +1 -1
  26. package/source/src/__tests__/bridge.test.ts +22 -0
  27. package/source/src/__tests__/extension-update.test.ts +54 -0
  28. package/source/src/__tests__/setup.test.ts +50 -0
  29. package/source/src/bridge.ts +43 -61
  30. package/source/src/extension-id.ts +2 -0
  31. package/source/src/extension-update.ts +82 -0
  32. package/source/src/identity.ts +2 -2
  33. package/source/src/index.ts +3 -0
  34. package/source/src/release-info.ts +3 -0
  35. package/source/src/server.ts +2 -6
  36. package/source/src/setup.ts +88 -0
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
2
+ <rect width="128" height="128" rx="30" fill="#303640"/>
3
+ <path d="M29 39 40 88 64 48 77 88 100 32" fill="none" stroke="#ffffff" stroke-width="9" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <circle cx="100" cy="32" r="5" fill="#ffffff"/>
5
+ </svg>
@@ -0,0 +1,63 @@
1
+ import{p as j}from"./purify.es-1yEQDPgc.js";import{T as P,g as F,c as z}from"./index.browser-Hs3ZYqOv.js";import"./react-vendor-BrXlnJmF.js";const E=z("Turndown"),C=["zhida.zhihu.com"],A=[{domain:"link.zhihu.com",param:"target"}];function W(o){let e=o;for(let r=0;r<3;r++){const n=e;if(e=e.replace(/&amp;/g,"&"),n===e)break}e=e.replace(/&#[xX]([0-9a-fA-F]+);/g,(r,n)=>String.fromCharCode(parseInt(n,16))),e=e.replace(/&#(\d+);/g,(r,n)=>String.fromCharCode(parseInt(n,10)));const t={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&apos;":"'","&#039;":"'","&nbsp;":" ","&ndash;":"–","&mdash;":"—","&lsquo;":"‘","&rsquo;":"’","&ldquo;":"“","&rdquo;":"”","&copy;":"©","&reg;":"®","&trade;":"™","&hellip;":"…"};for(const[r,n]of Object.entries(t))e=e.split(r).join(n);return e}const G=["span","em","strong","b","i","u","s","strike","del","ins","mark","sub","sup","small","big","font","a","code","pre","kbd","samp","var","tt","div","p","section","article","header","footer","aside","nav","main","figure","figcaption","blockquote","address","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","br","hr","wbr","abbr","acronym","cite","dfn","q","time","ruby","rt","rp","bdi","bdo","data","meter","progress","output","details","summary","mpvoice","mpprofile","qqmusic","mpcps"];function U(o){const e="\0__CODE_LT__\0",t="\0__CODE_GT__\0";let r=o;r=r.replace(/&lt;/gi,e),r=r.replace(/&gt;/gi,t),r=r.replace(/&#0*60;/gi,e),r=r.replace(/&#0*62;/gi,t),r=r.replace(/&#x0*3[cC];/gi,e),r=r.replace(/&#x0*3[eE];/gi,t);const n=G.join("|");return r=r.replace(new RegExp(`<(${n})\\b[^>]*\\/?>`,"gi"),""),r=r.replace(new RegExp(`<\\/(${n})>`,"gi"),""),r=r.replace(new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"<"),r=r.replace(new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),">"),r=W(r),r}function X(o){let e=o.replace(/<br\s*\/?>/gi,`
2
+ `).replace(/<\/div>/gi,`
3
+ `).replace(/<\/p>/gi,`
4
+ `).replace(/<\/li>/gi,`
5
+ `).replace(/<\/?code[^>]*>/gi,"");return e=U(e),e.trim()}function V(o){let e=o.replace(/^\s+|\s+$/g,"");return e=e.replace(/\|/g,"\\|"),e=e.replace(/\s*\r?\n\s*/g,"<br>"),e=e.replace(/[ \t]{2,}/g," "),e}function x(o,e){const t=V(o),r=e.parentNode;if(!r)return"| "+t+" |";const n=r.querySelectorAll("th, td");return(Array.from(n).indexOf(e)===0?"| ":" ")+t+" |"}function _(o){return o.querySelector("tr")}function T(o){const e=o.parentNode;if(!e)return!1;const t=o.querySelectorAll("th, td");return e.nodeName==="THEAD"||e.firstChild===o&&(e.nodeName==="TABLE"||K(e))&&t.length>0&&Array.from(t).every(r=>r.nodeName==="TH")}function K(o){const e=o.previousSibling;return o.nodeName==="TBODY"&&(!e||e.nodeName==="THEAD"&&/^\s*$/i.test(e.textContent||""))}function Z(o){o.addRule("figure",{filter:"figure",replacement:function(e){return e}}),o.addRule("figcaption",{filter:"figcaption",replacement:function(e){return e?`
6
+ *`+e.trim()+`*
7
+ `:""}}),o.addRule("tableCell",{filter:["th","td"],replacement:function(e,t){return x(e,t)}}),o.addRule("tableRow",{filter:"tr",replacement:function(e,t){const r=t;let n="";const a={left:":--",right:"--:",center:":-:"};return T(r)&&r.querySelectorAll("th, td").forEach(i=>{var u;let c="---";const f=(((u=i.getAttribute)==null?void 0:u.call(i,"align"))||"").toLowerCase();f&&a[f]&&(c=a[f]),n+=x(c,i)}),`
8
+ `+e+(n?`
9
+ `+n:"")}}),o.addRule("table",{filter:function(e){try{if(e.nodeName!=="TABLE")return!1;const r=_(e);return r?T(r):!1}catch(t){return E.error("Table filter error:",t),!1}},replacement:function(e){return e=e.replace(/\n\n/g,`
10
+ `),`
11
+
12
+ `+e+`
13
+
14
+ `}}),o.addRule("tableSection",{filter:["thead","tbody","tfoot"],replacement:function(e){return e}}),o.addRule("preCode",{filter:["pre"],replacement:function(e,t){const r=t;let n="";const a=r.getAttribute("data-lang");if(a&&(n=a),!n){const u=r.querySelector("code");if(u){const p=(u.className||"").match(/language-(\w+)/);p&&(n=p[1])}}if(!n){const s=(r.className||"").match(/language-(\w+)/);s&&(n=s[1])}n||(n="bash");const l=r.querySelectorAll("code");let i;if(l.length>1){const u=[];l.forEach(s=>{u.push(s.innerText||s.textContent||"")}),i=u.join(`
15
+ `)}else i=r.innerText||"";if(i=i.replace(/\r\n/g,`
16
+ `).replace(/\r/g,`
17
+ `).replace(/^\n+/,"").replace(/\n+$/,""),!i.trim())return"";n=n.replace(/[^a-zA-Z0-9+#._-]/g,"").toLowerCase();let c="```";const f=i.match(/`+/g);if(f){const u=Math.max(...f.map(s=>s.length));u>=3&&(c="`".repeat(u+1))}return`
18
+ `+c+n+`
19
+ `+i+`
20
+ `+c+`
21
+ `}}),o.addRule("sourcePlatformLinks",{filter:function(e){if(e.nodeName!=="A")return!1;const t=e.getAttribute("href")||"";return C.some(r=>t.includes(r))||A.some(r=>t.includes(r.domain))},replacement:function(e,t){const r=t.getAttribute("href")||"";if(C.some(a=>r.includes(a)))return e;const n=A.find(a=>r.includes(a.domain));if(n)try{const l=new URL(r).searchParams.get(n.param);if(l)return"["+e+"]("+l+")"}catch{}return"["+e+"]("+r+")"}}),o.keep(function(e){try{if(e.nodeName!=="TABLE")return!1;const r=_(e);return r?!T(r):!0}catch(t){return E.error("Table keep filter error:",t),!1}})}function q(o){if(!o)return"";const e=[/language-(\w+)/i,/lang-(\w+)/i,/\bhljs\s+(\w+)/i,/\b(javascript|typescript|python|java|cpp|c|csharp|go|rust|ruby|php|swift|kotlin|scala|sql|html|css|json|xml|yaml|markdown|bash|shell|powershell)\b/i];for(const t of e){const r=o.match(t);if(r)return r[1].toLowerCase()}return""}function M(o){let e=o;return e=e.replace(/<ul[^>]*class=["'][^"']*code-snippet__line-index[^"']*["'][^>]*>[\s\S]*?<\/ul>/gi,""),e=Y(e),e=e.replace(/<h1[^>]*>([\s\S]*?)<\/h1>/gi,`
22
+ # $1
23
+ `),e=e.replace(/<h2[^>]*>([\s\S]*?)<\/h2>/gi,`
24
+ ## $1
25
+ `),e=e.replace(/<h3[^>]*>([\s\S]*?)<\/h3>/gi,`
26
+ ### $1
27
+ `),e=e.replace(/<h4[^>]*>([\s\S]*?)<\/h4>/gi,`
28
+ #### $1
29
+ `),e=e.replace(/<h5[^>]*>([\s\S]*?)<\/h5>/gi,`
30
+ ##### $1
31
+ `),e=e.replace(/<h6[^>]*>([\s\S]*?)<\/h6>/gi,`
32
+ ###### $1
33
+ `),e=e.replace(/<(strong|b)[^>]*>([\s\S]*?)<\/\1>/gi,"**$2**"),e=e.replace(/<(em|i)[^>]*>([\s\S]*?)<\/\1>/gi,"*$2*"),e=e.replace(/<a[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi,"[$2]($1)"),e=e.replace(/<img[^>]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*\/?>/gi,"![$2]($1)"),e=e.replace(/<img[^>]*src="([^"]*)"[^>]*\/?>/gi,"![]($1)"),e=e.replace(/<pre[^>]*>([\s\S]*?)<\/pre>/gi,(t,r)=>{let n="";const a=t.match(/<pre[^>]*data-lang(?:uage)?=["'](\w+)["']/),l=t.match(/<pre[^>]*class="([^"]*)"/);a?n=a[1]:l&&(n=q(l[1]));const i=r.match(/<code[^>]*data-lang(?:uage)?=["'](\w+)["']/),c=r.match(/<code[^>]*class="([^"]*)"/);n||(i?n=i[1]:c&&(n=q(c[1])));const f=X(r);return"\n```"+n+`
34
+ `+f+"\n```\n"}),e=e.replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`"),e=e.replace(/<ul[^>]*>([\s\S]*?)<\/ul>/gi,`$1
35
+ `),e=e.replace(/<ol[^>]*>([\s\S]*?)<\/ol>/gi,`$1
36
+ `),e=e.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi,`- $1
37
+ `),e=e.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi,`
38
+ $1
39
+ `),e=e.replace(/<br\s*\/?>/gi,`
40
+ `),e=e.replace(/<hr\s*\/?>/gi,`
41
+ ---
42
+ `),e=e.replace(/<blockquote[^>]*>([\s\S]*?)<\/blockquote>/gi,(t,r)=>`
43
+ `+r.trim().split(`
44
+ `).map(n=>"> "+n).join(`
45
+ `)+`
46
+ `),e=e.replace(/<script[^>]*type=["']math\/tex[^"']*display[^"']*["'][^>]*>([\s\S]*?)<\/script>/gi,`
47
+ $$$$
48
+ $1
49
+ $$$$
50
+ `),e=e.replace(/<script[^>]*type=["']math\/tex["'][^>]*>([\s\S]*?)<\/script>/gi," $$$$$1$$$$ "),e=e.replace(/<\/?[^>]+(>|$)/g,""),e=e.replace(/&amp;/g,"&"),e=e.replace(/&lt;/g,"<"),e=e.replace(/&gt;/g,">"),e=e.replace(/&quot;/g,'"'),e=e.replace(/&#039;/g,"'"),e=e.replace(/&nbsp;/g," "),e=e.replace(/\n{3,}/g,`
51
+
52
+ `),e=e.trim(),e}function Y(o){return o=o.replace(/<figure[^>]*>([\s\S]*?)<\/figure>/gi,(e,t)=>{if(/<table[^>]*>/i.test(t)){const r=t.match(/<table[^>]*>([\s\S]*?)<\/table>/i),n=t.match(/<figcaption[^>]*>([\s\S]*?)<\/figcaption>/i);if(r){let a=r[0];if(n){const l=n[1].replace(/<[^>]+>/g,"").trim();l&&(a+=`
53
+ *`+l+`*
54
+ `)}return a}}return e}),o.replace(/<table[^>]*>([\s\S]*?)<\/table>/gi,(e,t)=>{const r=t.match(/<thead[^>]*>([\s\S]*?)<\/thead>/i),n=[],a=[];let l=-1;const i=t.match(/<tr[^>]*>([\s\S]*?)<\/tr>/gi)||[];for(let s=0;s<i.length;s++){const p=i[s],m=[],d=[],h=p.match(/<t[hd][^>]*>([\s\S]*?)<\/t[hd]>/gi)||[],B=h.length>0&&h.every(b=>b.startsWith("<th"));for(const b of h){const S=b.match(/<t[hd]([^>]*)>([\s\S]*?)<\/t[hd]>/i);if(S){const L=S[1],H=S[2],w=L.match(/align=["']?(left|center|right)["']?/i)||L.match(/style=["'][^"']*text-align:\s*(left|center|right)/i),I=w?w[1].toLowerCase():"";d.push(I);let v=H.replace(/<br\s*\/?>/gi," ").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/\s+/g," ").trim();v=v.replace(/\|/g,"\\|"),m.push(v)}}m.length>0&&(n.push(m),a.push(d),r&&p.indexOf("<th")!==-1?l=s:s===0&&B&&(l=0))}if(n.length===0)return"";l===-1&&(l=0);const c=[],f=Math.max(...n.map(s=>s.length)),u=a[l]||[];for(let s=0;s<n.length;s++){const p=n[s];for(;p.length<f;)p.push("");if(c.push("| "+p.join(" | ")+" |"),s===l){const m=[];for(let d=0;d<f;d++){const h=u[d]||"";h==="left"?m.push(":---"):h==="center"?m.push(":---:"):h==="right"?m.push("---:"):m.push("---")}c.push("| "+m.join(" | ")+" |")}}return`
55
+
56
+ `+c.join(`
57
+ `)+`
58
+
59
+ `})}function $(o,e={}){if(typeof document>"u")return E.warn("No native DOM, falling back to regex conversion"),M(o);try{const t=new P({headingStyle:e.headingStyle||"atx",hr:e.hr||"---",bulletListMarker:e.bulletListMarker||"-",codeBlockStyle:e.codeBlockStyle||"fenced",fence:e.fence||"```",emDelimiter:e.emDelimiter||"*",strongDelimiter:e.strongDelimiter||"**",linkStyle:e.linkStyle||"inlined",linkReferenceStyle:e.linkReferenceStyle||"full"});Z(t);const r=document.createElement("div");return r.innerHTML=o,r.querySelectorAll('ul.code-snippet__line-index, ul[class*="code-snippet__line-index"]').forEach(n=>n.remove()),t.turndown(r)}catch(t){return E.error("Native DOM conversion failed:",t),M(o)}}function J(o){return F.parse(o,{async:!1})}const k={debug:0,info:1,warn:2,error:3};let y={enabled:!0,level:"warn"};async function Q(){try{const o=await chrome.storage.local.get("loggerConfig");o.loggerConfig&&(y={...y,...o.loggerConfig})}catch{}}Q();function ee(o){const e=t=>y.enabled?k[t]>=k[y.level]:!1;return{debug:(...t)=>{e("debug")&&console.log(`[${o}]`,...t)},info:(...t)=>{e("info")&&console.log(`[${o}]`,...t)},warn:(...t)=>{e("warn")&&console.warn(`[${o}]`,...t)},error:(...t)=>{e("error")&&console.error(`[${o}]`,...t)}}}const N=ee("ContentProcessor");function te(o,e){const t=document.createElement("div");if(t.innerHTML=o,e.processCodeBlocks&&pe(t),e.removeComments&&re(t),e.removeIframes&&g(t,["iframe"]),e.removeSpecialTags&&(e.removeSpecialTagsWithParent?(ne(t,["mpprofile","qqmusic"]),g(t,["mpvoice","mpcps","mp-miniprogram","mp-common-product"])):g(t,["mpprofile","qqmusic","mpvoice","mpcps","mp-miniprogram","mp-common-product"])),e.removeSvgImages&&oe(t),g(t,e.keepStyles?["script","noscript"]:["script","style","noscript"]),ae(t),e.removeLinks&&le(t,e.keepLinkDomains),e.processLazyImages&&ie(t),e.removeEmptyElements&&ge(t),e.removeEmptyImages&&he(t),e.removeDataAttributes&&Ee(t),(e.removeSrcset||e.removeSizes)&&ye(t,e),e.normalizeViaMarkdown){const a=$(t.innerHTML);t.innerHTML=J(a)}e.convertSectionToDiv?R(t,"div"):e.convertSectionToP&&R(t,"p"),e.removeTrailingBr&&be(t),e.unwrapNestedFigures&&Te(t),e.flattenNestedBold&&Se(t),e.unwrapSingleChildSpans&&ve(t),e.unwrapSingleChildContainers&&Ne(t),e.compactHtml&&Ce(t),e.convertTablesToText&&xe(t),e.removeEmptyLines&&Ae(t),e.removeEmptyDivs&&Le(t),e.removeNestedEmptyContainers&&we(t);const r=t.innerHTML,n=$(r);return{html:r,markdown:n}}function re(o){const e=document.createNodeIterator(o,NodeFilter.SHOW_COMMENT,null),t=[];let r;for(;r=e.nextNode();)t.push(r);t.forEach(n=>n.remove())}function g(o,e){const t=e.join(", ");o.querySelectorAll(t).forEach(r=>r.remove())}function ne(o,e){const t=e.join(", ");o.querySelectorAll(t).forEach(r=>{const n=r.parentElement;n&&n!==o?n.remove():r.remove()})}function oe(o){o.querySelectorAll('img[src^="data:image/svg"]').forEach(t=>{const r=t.getAttribute("data-src");r?t.setAttribute("src",r):t.remove()})}function ae(o){const e=Array.from(o.querySelectorAll("a"));for(const t of e){const r=t.getAttribute("href")||"";if(C.some(a=>r.includes(a))){const a=t.parentNode;if(!a)continue;for(;t.firstChild;)a.insertBefore(t.firstChild,t);a.removeChild(t);continue}const n=A.find(a=>r.includes(a.domain));if(n)try{const l=new URL(r).searchParams.get(n.param);l&&t.setAttribute("href",l)}catch{}}}function le(o,e){o.querySelectorAll("a").forEach(r=>{var l;const n=r.getAttribute("href");if(n&&(e!=null&&e.length)&&e.some(c=>n.includes(c)))return;const a=document.createElement("span");a.innerHTML=r.innerHTML,(l=r.parentNode)==null||l.replaceChild(a,r)})}function ie(o){const e=o.querySelectorAll("img"),t=["data-src","data-original","data-actualsrc","_src"];e.forEach(r=>{for(const n of t){const a=r.getAttribute(n);if(a&&!a.startsWith("data:image/svg")){(!r.src||r.src.startsWith("data:image/svg"))&&(r.src=a);break}}t.forEach(n=>r.removeAttribute(n))})}function ce(o,e){var n;if(o.tagName==="UL"||o.tagName==="OL"){const a=o.querySelectorAll("li");if(a.length>=2&&a.length===e&&Array.from(a).every(i=>{var c;return!((c=i.textContent)!=null&&c.trim())}))return!0;if(a.length>=2){let l=!0;if(a.forEach((i,c)=>{var u;parseInt(((u=i.textContent)==null?void 0:u.trim())||"",10)!==c+1&&(l=!1)}),l)return!0}}const r=(((n=o.textContent)==null?void 0:n.trim())||"").split(/[\n\r]+/).map(a=>a.trim()).filter(Boolean);return!!(r.length>=2&&r.every((l,i)=>parseInt(l,10)===i+1))}function se(o){var n;const e=o.parentElement;if(!e)return;const t=o.querySelectorAll("code"),r=t.length>1?t.length:((n=o.textContent)==null?void 0:n.split(`
60
+ `).length)||0;Array.from(e.children).forEach(a=>{a!==o&&ce(a,r)&&a.remove()})}const fe=new Set(["CODE","DIV","P","LI"]);function ue(o){var r;if(o.length<2)return!1;const e=o[0].tagName;if(e==="BR")return!1;if(fe.has(e)){if(!o.every(l=>l.tagName===e))return!1;const a=o[0].parentElement;if(a){for(const l of Array.from(a.childNodes))if(l.nodeType===Node.TEXT_NODE&&((r=l.textContent)!=null&&r.trim()))return!1}return!0}return o.every(n=>{const a=n.getAttribute("style")||"";return a.includes("display:block")||a.includes("display: block")})}function D(o,e){if(e>4)return null;const t=Array.from(o.children);return ue(t)?o:t.length===1?D(t[0],e+1):null}function me(o){return D(o,0)}function pe(o){g(o,["ul.code-snippet__line-index",".code-snippet__line-index",".line-numbers-rows",".hljs-ln-numbers",".gutter"]),o.querySelectorAll("pre").forEach(t=>{try{if(t.hasAttribute("data-code-simplified"))return;se(t);const r=me(t);N.debug("[processCodeBlocks] pre.innerHTML:",t.innerHTML.slice(0,200)),N.debug("[processCodeBlocks] linesContainer:",r==null?void 0:r.tagName,"children:",r==null?void 0:r.children.length);let n;if(r){const l=[];Array.from(r.children).forEach(i=>{const c=i.textContent||"";l.push(O(c))}),n=l.join(`
61
+ `)}else{const l=t.innerText||t.textContent||"";n=`<code>${O(l)}</code>`}if(n=n.replace(/\r\n/g,`
62
+ `).replace(/\r/g,`
63
+ `).replace(/^\n+/,"").replace(/\n+$/,""),!n.trim()){t.remove();return}const a=de(t);t.innerHTML=n,t.removeAttribute("class"),t.removeAttribute("style"),t.removeAttribute("data-lang"),a&&(t.setAttribute("data-lang",a),t.className=`language-${a}`)}catch(r){N.error("processCodeBlocks error:",r)}})}function de(o){const e=[o,o.querySelector("code")].filter(Boolean);for(const t of e){const r=t.getAttribute("data-lang");if(r)return r.trim().toLowerCase();const n=t.className.match(/(?:language|lang|highlight)-(\w+)/);if(n)return n[1].toLowerCase();const a=t.className.match(/code-snippet__(\w+)/);if(a)return a[1].toLowerCase()}return null}function he(o){o.querySelectorAll("img").forEach(e=>{(!e.src||e.src===window.location.href)&&e.remove()})}function ge(o){for(let e=0;e<3;e++){const t=o.querySelectorAll("p, div, section, span, figure");let r=0;if(t.forEach(n=>{var i;const a=(i=n.textContent)==null?void 0:i.trim(),l=n.querySelector("img, video, audio, iframe, canvas, svg");!a&&!l&&(n.remove(),r++)}),r===0)break}}function Ee(o){o.querySelectorAll("*").forEach(t=>{Array.from(t.attributes).forEach(n=>{n.name.startsWith("data-")&&n.name!=="data-src"&&t.removeAttribute(n.name)})})}function ye(o,e){o.querySelectorAll("img").forEach(r=>{e.removeSrcset&&r.removeAttribute("srcset"),e.removeSizes&&r.removeAttribute("sizes"),r.removeAttribute("loading"),r.removeAttribute("decoding")})}function R(o,e){o.querySelectorAll("section").forEach(r=>{var a;const n=document.createElement(e);n.innerHTML=r.innerHTML,Array.from(r.attributes).forEach(l=>{n.setAttribute(l.name,l.value)}),(a=r.parentNode)==null||a.replaceChild(n,r)})}function be(o){o.querySelectorAll("p, div, section").forEach(t=>{var r;for(;((r=t.lastElementChild)==null?void 0:r.tagName)==="BR";)t.lastElementChild.remove()})}function Se(o){const e=["b b","b strong","strong b","strong strong"];for(let t=0;t<5;t++){let r=0;for(const n of e)o.querySelectorAll(n).forEach(a=>{const l=a.parentNode;if(l){for(;a.firstChild;)l.insertBefore(a.firstChild,a);l.removeChild(a),r++}});if(r===0)break}}function ve(o){for(let e=0;e<10;e++){let t=0;const r=Array.from(o.querySelectorAll("span"));for(const n of r){if(!n.parentNode||n.childNodes.length===0||Array.from(n.childNodes).some(i=>{var c;return i.nodeType===Node.TEXT_NODE&&!!((c=i.textContent)!=null&&c.trim())}))continue;const l=n.parentNode;for(;n.firstChild;)l.insertBefore(n.firstChild,n);l.removeChild(n),t++}if(t===0)break}}function Te(o){for(let e=0;e<5;e++){const t=o.querySelectorAll("figure > figure");if(t.length===0)break;t.forEach(r=>{var a;const n=r.parentElement;(n==null?void 0:n.tagName)==="FIGURE"&&((a=n.parentNode)==null||a.replaceChild(r,n))})}}function Ne(o){for(let e=0;e<5;e++){let t=0;if(o.querySelectorAll("div").forEach(n=>{var l;const a=Array.from(n.childNodes).filter(i=>{var c;return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE&&((c=i.textContent)==null?void 0:c.trim())});if(a.length===1&&a[0].nodeType===Node.ELEMENT_NODE){const i=a[0];["DIV","ARTICLE","P","SECTION"].includes(i.tagName)&&((l=n.parentNode)==null||l.replaceChild(i,n),t++)}}),t===0)break}}function Ce(o){var n;const e=document.createTreeWalker(o,NodeFilter.SHOW_TEXT,null),t=[];let r;for(;r=e.nextNode();)if(r.textContent&&/^\s+$/.test(r.textContent)){const a=r.previousSibling,l=r.nextSibling,i=r.parentNode;i&&!((n=i.closest)!=null&&n.call(i,"pre, code"))&&(!a||a.nodeType===Node.ELEMENT_NODE)&&(!l||l.nodeType===Node.ELEMENT_NODE)&&t.push(r)}t.forEach(a=>a.remove())}function Ae(o){o.querySelectorAll("p, section").forEach(t=>{Array.from(t.childNodes).every(n=>{var a;return n.nodeType===Node.TEXT_NODE?!((a=n.textContent)!=null&&a.trim()):n.nodeType===Node.ELEMENT_NODE?n.tagName==="BR":!0})&&t.remove()})}function Le(o){o.querySelectorAll("div").forEach(t=>{if(t.querySelector("img, video, audio, canvas, svg, iframe"))return;Array.from(t.childNodes).every(n=>{var a;return n.nodeType===Node.TEXT_NODE?!((a=n.textContent)!=null&&a.trim()):n.nodeType===Node.ELEMENT_NODE?n.tagName==="BR":!0})&&t.remove()})}function we(o){for(let e=0;e<5;e++){let t=0;if(o.querySelectorAll("div, section, article, span").forEach(n=>{var i;if(n.querySelector("img, video, audio, canvas, svg, iframe"))return;const a=((i=n.textContent)==null?void 0:i.trim())||"",l=n.children.length>0;if(!a&&!l){n.remove(),t++;return}!a&&l&&Array.from(n.children).every(f=>f.tagName==="BR")&&(n.remove(),t++)}),t===0)break}}function xe(o){o.querySelectorAll("table").forEach(t=>{const r=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th, td").forEach(c=>{var f;r.push(((f=c.textContent)==null?void 0:f.trim())||"")});const a=[],l=t.querySelectorAll("tbody tr, tr");l.forEach(c=>{var s;if(((s=c.parentElement)==null?void 0:s.tagName)==="THEAD")return;const f=c.querySelectorAll("td, th");if(r.length===0&&c===l[0]&&Array.from(f).every(m=>m.tagName==="TH")){f.forEach(m=>{var d;return r.push(((d=m.textContent)==null?void 0:d.trim())||"")});return}const u=[];f.forEach(p=>{var m;u.push(((m=p.textContent)==null?void 0:m.trim())||"")}),u.length>0&&a.push(u)});const i=document.createDocumentFragment();r.length>0?a.forEach(c=>{const f=c.map((s,p)=>{const m=r[p]||"";return m?`${m}: ${s}`:s}),u=document.createElement("p");u.textContent=f.join(" | "),i.appendChild(u)}):a.forEach(c=>{const f=document.createElement("p");f.textContent=c.join(" | "),i.appendChild(f)}),t.replaceWith(i)})}function O(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}chrome.runtime.onMessage.addListener((o,e,t)=>{if(e.id!==chrome.runtime.id||o.target!=="offscreen")return!1;if(o.type==="OFFSCREEN_READY")return t({data:{ready:!0}}),!1;if(!["PREPROCESS_ARTICLE","NORMALIZE_AGENT_HTML"].includes(o.type))return!1;try{if(o.type==="NORMALIZE_AGENT_HTML"){const a=j.sanitize(o.payload.rawHtml,{FORBID_TAGS:["style","iframe","object","embed","form","video","audio"],FORBID_ATTR:["srcset"]}),l=new DOMParser().parseFromString(a,"text/html");for(const i of l.querySelectorAll("img"))if(!/^(https?:\/\/|data:image\/(png|jpeg|gif|webp);base64,)/i.test(i.getAttribute("src")||""))throw new Error("正文图片地址无效,请通过 MCP 提交稿件和本地图片");return t({data:l.body.innerHTML}),!1}const{rawHtml:r,config:n}=o.payload;t({data:te(r,n)})}catch(r){t({error:r instanceof Error?r.message:"排版处理失败"})}return!1});
@@ -0,0 +1,3 @@
1
+ (function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))u(c);new MutationObserver(c=>{for(const m of c)if(m.type==="childList")for(const A of m.addedNodes)A.tagName==="LINK"&&A.rel==="modulepreload"&&u(A)}).observe(document,{childList:!0,subtree:!0});function a(c){const m={};return c.integrity&&(m.integrity=c.integrity),c.referrerPolicy&&(m.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?m.credentials="include":c.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function u(c){if(c.ep)return;c.ep=!0;const m=a(c);fetch(c.href,m)}})();/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function on(i,s){(s==null||s>i.length)&&(s=i.length);for(var a=0,u=Array(s);a<s;a++)u[a]=i[a];return u}function io(i){if(Array.isArray(i))return i}function so(i,s){var a=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(a!=null){var u,c,m,A,mt=[],C=!0,Rt=!1;try{if(m=(a=a.call(i)).next,s!==0)for(;!(C=(u=m.call(a)).done)&&(mt.push(u.value),mt.length!==s);C=!0);}catch(tt){Rt=!0,c=tt}finally{try{if(!C&&a.return!=null&&(A=a.return(),Object(A)!==A))return}finally{if(Rt)throw c}}return mt}}function ao(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function lo(i,s){return io(i)||so(i,s)||co(i,s)||ao()}function co(i,s){if(i){if(typeof i=="string")return on(i,s);var a={}.toString.call(i).slice(8,-1);return a==="Object"&&i.constructor&&(a=i.constructor.name),a==="Map"||a==="Set"?Array.from(i):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?on(i,s):void 0}}const An=Object.entries,rn=Object.setPrototypeOf,uo=Object.isFrozen,En=Object.getPrototypeOf,yn=Object.getOwnPropertyDescriptor;let b=Object.freeze,R=Object.seal,ft=Object.create,Sn=typeof Reflect<"u"&&Reflect,ye=Sn.apply,Se=Sn.construct;b||(b=function(s){return s});R||(R=function(s){return s});ye||(ye=function(s,a){for(var u=arguments.length,c=new Array(u>2?u-2:0),m=2;m<u;m++)c[m-2]=arguments[m];return s.apply(a,c)});Se||(Se=function(s){for(var a=arguments.length,u=new Array(a>1?a-1:0),c=1;c<a;c++)u[c-1]=arguments[c];return new s(...u)});const G=g(Array.prototype.forEach),fo=g(Array.prototype.lastIndexOf),sn=g(Array.prototype.pop),yt=g(Array.prototype.push),po=g(Array.prototype.slice),mo=g(Array.prototype.splice),pt=Array.isArray,pe=bn(Set),me=g(Set.prototype.add),St=g(Set.prototype.has),Q=g(String.prototype.toLowerCase),de=g(String.prototype.toString),an=g(String.prototype.match),bt=g(String.prototype.replace),ln=g(String.prototype.indexOf),ho=g(String.prototype.trim),_o=g(Number.prototype.toString),To=g(Boolean.prototype.toString),cn=typeof BigInt>"u"?null:g(BigInt.prototype.toString),un=typeof Symbol>"u"?null:g(Symbol.prototype.toString),N=g(Object.prototype.hasOwnProperty),Ot=g(Object.prototype.toString),O=g(RegExp.prototype.test),W=bn(TypeError);function g(i){return function(s){s instanceof RegExp&&(s.lastIndex=0);for(var a=arguments.length,u=new Array(a>1?a-1:0),c=1;c<a;c++)u[c-1]=arguments[c];return ye(i,s,u)}}function bn(i){return function(){for(var s=arguments.length,a=new Array(s),u=0;u<s;u++)a[u]=arguments[u];return Se(i,a)}}function d(i,s){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Q;if(rn&&rn(i,null),!pt(s))return i;let u=s.length;for(;u--;){let c=s[u];if(typeof c=="string"){const m=a(c);m!==c&&(uo(s)||(s[u]=m),c=m)}i[c]=!0}return i}function go(i){for(let s=0;s<i.length;s++)N(i,s)||(i[s]=null);return i}function M(i){const s=ft(null);for(const u of An(i)){var a=lo(u,2);const c=a[0],m=a[1];N(i,c)&&(pt(m)?s[c]=go(m):m&&typeof m=="object"&&m.constructor===Object?s[c]=M(m):s[c]=m)}return s}function Ao(i){switch(typeof i){case"string":return i;case"number":return _o(i);case"boolean":return To(i);case"bigint":return cn?cn(i):"0";case"symbol":return un?un(i):"Symbol()";case"undefined":return Ot(i);case"function":case"object":{if(i===null)return Ot(i);const s=i,a=v(s,"toString");if(typeof a=="function"){const u=a(s);return typeof u=="string"?u:Ot(u)}return Ot(i)}default:return Ot(i)}}function v(i,s){for(;i!==null;){const u=yn(i,s);if(u){if(u.get)return g(u.get);if(typeof u.value=="function")return g(u.value)}i=En(i)}function a(){return null}return a}function Eo(i,s){for(;i!==null;){const a=yn(i,s);if(a)return a.get?g(a.get):null;i=En(i)}return null}function yo(i){try{return O(i,""),!0}catch{return!1}}const fn=b(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),he=b(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),_e=b(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),So=b(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Te=b(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),bo=b(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),pn=b(["#text"]),mn=b(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ge=b(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),dn=b(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ut=b(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Oo=R(/{{[\w\W]*|^[\w\W]*}}/g),Ro=R(/<%[\w\W]*|^[\w\W]*%>/g),Do=R(/\${[\w\W]*/g),wo=R(/^data-[\-\w.\u00B7-\uFFFF]+$/),Lo=R(/^aria-[\-\w]+$/),hn=R(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Io=R(/^(?:\w+script|data):/i),No=R(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Co=R(/^html$/i),Mo=R(/^[a-z][.\w]*(-[.\w]+)+$/i),Ae=R(/<[/\w!]/g),_n=R(/<[/\w]/g),Po=R(/<\/no(script|embed|frames)/i),Tn=R(/\/>/i),y={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vo=b(d({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),xo=function(){return typeof window>"u"?null:window},ko=function(s,a){if(typeof s!="object"||typeof s.createPolicy!="function")return null;let u=null;const c="data-tt-policy-suffix";a&&a.hasAttribute(c)&&(u=a.getAttribute(c));const m="dompurify"+(u?"#"+u:"");try{return s.createPolicy(m,{createHTML(A){return A},createScriptURL(A){return A}})}catch{return console.warn("TrustedTypes policy "+m+" could not be created."),null}},gn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},V=function(s,a,u,c){return N(s,a)&&pt(s[a])?d(c.base?M(c.base):{},s[a],c.transform):u},Ee=function(s,a,u){const c=N(s,a)?s[a]:void 0;return c&&typeof c=="object"?M(c):u()};function On(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xo();const s=r=>On(r);if(s.version="3.4.17",s.removed=[],!i||!i.document||i.document.nodeType!==y.document||!i.Element)return s.isSupported=!1,s;let a=i.document;const u=a,c=u.currentScript;i.DocumentFragment;const m=i.HTMLTemplateElement,A=i.Node,mt=i.Element,C=i.NodeFilter;i.NamedNodeMap===void 0&&(i.NamedNodeMap||i.MozNamedAttrMap),i.HTMLFormElement;const Rt=i.DOMParser,tt=i.trustedTypes,F=mt.prototype,Rn=v(F,"cloneNode"),zt=v(F,"remove"),be=v(F,"removeAttributeNode"),Dn=v(F,"nextSibling"),dt=v(F,"childNodes"),et=v(F,"parentNode"),Ft=v(F,"shadowRoot"),Ht=v(F,"attributes"),$=A&&A.prototype?v(A.prototype,"nodeType"):null,nt=A&&A.prototype?v(A.prototype,"nodeName"):null,Dt=A&&A.prototype?v(A.prototype,"ownerDocument"):null,P=function(t){return $?$(t):t.nodeType},ht=function(t){return nt?nt(t):t.nodeName},Oe=Eo(F,"namespaceURI"),Gt=function(t){return Oe?Oe(t):t.namespaceURI};if(typeof m=="function"){const r=a.createElement("template");r.content&&r.content.ownerDocument&&(a=r.content.ownerDocument)}let w,X="",Wt,Re=!1,_t=0;const De=function(){if(_t>0)throw W('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ot=function(t){De(),_t++;try{return w.createHTML(t)}finally{_t--}},wn=function(t){De(),_t++;try{return w.createScriptURL(t)}finally{_t--}},Ln=function(){return Re||(Wt=ko(tt,c),Re=!0),Wt},wt=a,Bt=wt.implementation,we=wt.createNodeIterator,In=wt.createDocumentFragment,Nn=wt.getElementsByTagName,Cn=u.importNode;let h=gn();s.isSupported=typeof An=="function"&&typeof et=="function"&&Bt&&Bt.createHTMLDocument!==void 0;const Mn=Oo,Pn=Ro,vn=Do,xn=wo,kn=Lo,Un=Io,Le=No,zn=Mo;let Ie=hn,_=null;const Yt=d({},[...fn,...he,..._e,...Te,...pn]);let T=null;const jt=d({},[...mn,...ge,...dn,...Ut]);let k=Object.seal(ft(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Tt=null,Ne=null;const B=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ce=!0,Vt=!0,Me=!1,$t=!0,H=!1,q=!0,K=!1,Xt=!1,Lt=null,It=null,qt=!1,rt=!1,Nt=!1,Ct=!1,Pe=!0,ve=!1;const xe="user-content-";let Kt=!0,Zt=!1,Z=null,it={},J=null;const ke=d({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Ue=null;const ze=d({},["audio","video","img","source","image","track"]);let Fe=null;const He=d({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mt="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",U="http://www.w3.org/1999/xhtml";let st=U,Jt=!1,Qt=null;const Fn=d({},[Mt,Pt,U],de),Ge=b(["mi","mo","mn","ms","mtext"]);let te=d({},Ge);const We=b(["annotation-xml"]);let ee=d({},We);const Hn=d({},["title","style","font","a","script"]);let gt=null;const Gn=["application/xhtml+xml","text/html"],Wn="text/html";let E=null,at=null;const Bn=a.createElement("form"),Be=function(t){return t instanceof RegExp||t instanceof Function},ne=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(at&&at===t)return;(!t||typeof t!="object")&&(t={}),t=M(t),gt=Gn.indexOf(t.PARSER_MEDIA_TYPE)===-1?Wn:t.PARSER_MEDIA_TYPE,E=gt==="application/xhtml+xml"?de:Q,_=V(t,"ALLOWED_TAGS",Yt,{transform:E}),T=V(t,"ALLOWED_ATTR",jt,{transform:E}),Qt=V(t,"ALLOWED_NAMESPACES",Fn,{transform:de}),Fe=V(t,"ADD_URI_SAFE_ATTR",He,{transform:E,base:He}),Ue=V(t,"ADD_DATA_URI_TAGS",ze,{transform:E,base:ze}),J=V(t,"FORBID_CONTENTS",ke,{transform:E}),Tt=V(t,"FORBID_TAGS",M({}),{transform:E}),Ne=V(t,"FORBID_ATTR",M({}),{transform:E}),it=N(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?M(t.USE_PROFILES):t.USE_PROFILES:!1,Ce=t.ALLOW_ARIA_ATTR!==!1,Vt=t.ALLOW_DATA_ATTR!==!1,Me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,$t=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=t.SAFE_FOR_TEMPLATES||!1,q=t.SAFE_FOR_XML!==!1,K=t.WHOLE_DOCUMENT||!1,rt=t.RETURN_DOM||!1,Nt=t.RETURN_DOM_FRAGMENT||!1,Ct=t.RETURN_TRUSTED_TYPE||!1,qt=t.FORCE_BODY||!1,Pe=t.SANITIZE_DOM!==!1,ve=t.SANITIZE_NAMED_PROPS||!1,Kt=t.KEEP_CONTENT!==!1,Zt=t.IN_PLACE||!1,Ie=yo(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:hn,st=typeof t.NAMESPACE=="string"?t.NAMESPACE:U,te=Ee(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>d({},Ge)),ee=Ee(t,"HTML_INTEGRATION_POINTS",()=>d({},We));const e=Ee(t,"CUSTOM_ELEMENT_HANDLING",()=>ft(null));if(k=ft(null),N(e,"tagNameCheck")&&Be(e.tagNameCheck)&&(k.tagNameCheck=e.tagNameCheck),N(e,"attributeNameCheck")&&Be(e.attributeNameCheck)&&(k.attributeNameCheck=e.attributeNameCheck),N(e,"allowCustomizedBuiltInElements")&&typeof e.allowCustomizedBuiltInElements=="boolean"&&(k.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),R(k),H&&(Vt=!1),Nt&&(rt=!0),it&&(_=d({},pn),T=ft(null),it.html===!0&&(d(_,fn),d(T,mn)),it.svg===!0&&(d(_,he),d(T,ge),d(T,Ut)),it.svgFilters===!0&&(d(_,_e),d(T,ge),d(T,Ut)),it.mathMl===!0&&(d(_,Te),d(T,dn),d(T,Ut))),B.tagCheck=null,B.attributeCheck=null,N(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?B.tagCheck=t.ADD_TAGS:pt(t.ADD_TAGS)&&(_===Yt&&(_=M(_)),d(_,t.ADD_TAGS,E))),N(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?B.attributeCheck=t.ADD_ATTR:pt(t.ADD_ATTR)&&(T===jt&&(T=M(T)),d(T,t.ADD_ATTR,E))),N(t,"ADD_FORBID_CONTENTS")&&pt(t.ADD_FORBID_CONTENTS)&&(J===ke&&(J=M(J)),d(J,t.ADD_FORBID_CONTENTS,E)),Kt&&(_["#text"]=!0),K&&d(_,["html","head","body"]),_.table&&(d(_,["tbody"]),delete Tt.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw W('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw W('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const n=w;w=t.TRUSTED_TYPES_POLICY;try{X=ot("")}catch(o){throw w=n,o}}else t.TRUSTED_TYPES_POLICY===null?(w=void 0,X=""):(w===void 0&&(w=Ln()),w&&typeof X=="string"&&(X=ot("")));b&&b(t),at=t},Ye=d({},[...he,..._e,...So]),je=d({},[...Te,...bo]),Yn=function(t,e,n){return e.namespaceURI===U?t==="svg":e.namespaceURI===Mt?t==="svg"&&(n==="annotation-xml"||te[n]):!!Ye[t]},jn=function(t,e,n){return e.namespaceURI===U?t==="math":e.namespaceURI===Pt?t==="math"&&ee[n]:!!je[t]},Vn=function(t,e,n){return e.namespaceURI===Pt&&!ee[n]||e.namespaceURI===Mt&&!te[n]?!1:!je[t]&&(Hn[t]||!Ye[t])},$n=function(t){const e=Gt(t),n=Q(ht(t)),o=et(t);let l,f;return o&&P(o)===y.element?(l={namespaceURI:Gt(o)},f=Q(ht(o))):(l={namespaceURI:st},f="template"),Qt[e]?e===Pt?Yn(n,l,f):e===Mt?jn(n,l,f):e===U?Vn(n,l,f):!!(gt==="application/xhtml+xml"&&Qt[e]):!1},Y=function(t){yt(s.removed,{element:t});try{et(t).removeChild(t)}catch{if(zt(t),!et(t))throw W("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ve=function(t,e,n){try{be(t,e)}catch{try{t.removeAttribute(n)}catch{}}},oe=function(t){ie(t);const e=dt(t);e&&G(po(e),o=>{try{zt(o)}catch{}});const n=P(t)===y.element?Ht(t):null;if(n)for(let o=n.length-1;o>=0;--o){const l=n[o],f=l&&l.name;typeof f=="string"&&Ve(t,l,f)}},lt=function(t,e,n){if(!n)try{n=e.getAttributeNode(t)}catch{n=null}yt(s.removed,{attribute:n||null,from:e});try{n?be(e,n):e.removeAttribute(t)}catch{try{e.removeAttribute(t)}catch{}}if(t==="is")if(rt||Nt)try{Y(e)}catch{}else try{e.setAttribute(t,"")}catch{}},$e=function(t){const e=Ht(t);if(e)for(let n=e.length-1;n>=0;--n){const o=e[n],l=o&&o.name;typeof l!="string"||T[E(l)]||Ve(t,o,l)}},re=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const o=[t];for(;o.length>0;){const l=o.pop();if(e(l)===!1)continue;if(n&&P(l)===y.element){const p=Ft(l);j(p)&&o.push(p)}const f=dt(l);if(f)for(let p=f.length-1;p>=0;--p)o.push(f[p])}},ie=function(t){re(t,e=>{P(e)===y.element&&$e(e)})},se=function(t){const e=[];return re(t,n=>{e.push(n)},!0),e},Xn=function(t,e){const n=pe();G(se(t),o=>{P(o)===y.element&&me(n,o)}),G(e,o=>{P(o)===y.element&&!St(n,o)&&$e(o)})},Xe=function(t,e){let n=!1;return G(s.removed,o=>{o.element&&(n=n||o.element===t,ie(o.element))}),Xn(t,e),n},qn=8,Kn=function(t,e){const n=Z;let o=null;const l=()=>(o||(o=pe(),G(e,f=>{me(o,f)})),o);for(let f=0;;f++){const p=se(t),S=[t];let z=!1;if(G(p,D=>{P(D)===y.documentFragment?yt(S,D):!z&&!St(n,D)&&(z=St(l(),D))}),!z)return;if(f>=qn)throw W("the tree kept changing during in-place sanitization; refusing to return it");G(S,(D,L)=>{Zn(D,L>0,t,l())})}},Zn=function(t,e,n,o){const l=ae(t);let f;for(;f=l.nextNode();)!St(o,f)||St(Z,f)||(e&&x(h.uponSanitizeShadowNode,f,null),ce(f,n),ue(f,n),j(f.content)&&Et(f.content))},Jn=function(t){Z&&me(Z,t)},qe=function(t,e){return q?t==="patchsrc"?!0:t==="for"&&e!=="label"&&e!=="output":!1},Qn=function(t){q&&re(t,e=>{const n=P(e);if(n===y.processingInstruction||n===y.comment&&O(_n,e.data)){try{zt(e)}catch{}return!1}if(n===y.element){const o=e,l=E(ht(e));try{o.hasAttribute&&o.hasAttribute("patchsrc")&&o.removeAttribute("patchsrc"),o.hasAttribute&&o.hasAttribute("for")&&qe("for",l)&&o.removeAttribute("for")}catch{}}return!0})},Ke=function(t){let e=null,n=null;if(qt)t="<remove></remove>"+t;else{const f=an(t,/^[\r\n\t ]+/);n=f&&f[0]}gt==="application/xhtml+xml"&&st===U&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const o=w?ot(t):t;if(st===U)try{e=new Rt().parseFromString(o,gt)}catch{}if(!e||!e.documentElement){e=Bt.createDocument(st,"template",null);try{e.documentElement.innerHTML=Jt?X:o}catch{}}const l=e.body||e.documentElement;return t&&n&&l.insertBefore(a.createTextNode(n),l.childNodes[0]||null),st===U?Nn.call(e,K?"html":"body")[0]:K?e.documentElement:l},ae=function(t){const e=Dt?Dt(t):t.ownerDocument;return we.call(e||t,t,C.SHOW_ELEMENT|C.SHOW_COMMENT|C.SHOW_TEXT|C.SHOW_PROCESSING_INSTRUCTION|C.SHOW_CDATA_SECTION,null)},vt=function(t){return t=bt(t,Mn," "),t=bt(t,Pn," "),t=bt(t,vn," "),t},le=function(t){var e;Ze(t);const n=(e=t.querySelectorAll)===null||e===void 0?void 0:e.call(t,"template");n&&G(n,o=>{j(o.content)&&le(o.content)})},Ze=function(t){t.normalize();const e=Dt?Dt(t):t.ownerDocument,n=we.call(e||t,t,C.SHOW_TEXT|C.SHOW_COMMENT|C.SHOW_CDATA_SECTION|C.SHOW_PROCESSING_INSTRUCTION,null);let o=n.nextNode();for(;o;)o.data=vt(o.data),o=n.nextNode()},xt=function(t){const e=nt?nt(t):null;return typeof e!="string"||E(e)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==Ht(t)||typeof t.removeAttribute!="function"||typeof t.removeAttributeNode!="function"||typeof t.getAttributeNode!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==$(t)||t.childNodes!==dt(t)},j=function(t){if(!$||typeof t!="object"||t===null)return!1;try{return $(t)===y.documentFragment}catch{return!1}},At=function(t){if(!$||typeof t!="object"||t===null)return!1;try{return typeof $(t)=="number"}catch{return!1}};function x(r,t,e){r.length!==0&&G(r,n=>{n.call(s,t,e,at)})}const to=function(t,e){return!!(q&&t.hasChildNodes()&&!At(t.firstElementChild)&&O(Ae,t.textContent)&&O(Ae,t.innerHTML)||q&&vo[e]&&P(t)===y.element&&Gt(t)===U&&(At(t.firstElementChild)||typeof t.textContent=="string"&&O(Ae,t.textContent))||t.nodeType===y.processingInstruction||q&&t.nodeType===y.comment&&O(_n,t.data))},kt=function(t,e){if(t instanceof RegExp)return O(t,e);if(t instanceof Function){for(var n=arguments.length,o=new Array(n>2?n-2:0),l=2;l<n;l++)o[l-2]=arguments[l];return!!t(e,...o)}return!1},eo=function(t,e,n){if(!Tt[e]&&tn(e)&&kt(k.tagNameCheck,e))return!1;if(Kt&&!J[e]&&!J[Q(e)]){const o=et(t),l=dt(t);if(l&&o){const f=l.length;for(let p=f-1;p>=0;--p){const S=t===n?Rn(l[p],!0):l[p];o.insertBefore(S,Dn(t))}}}return Y(t),!0},Je=function(t,e,n,o){return t.length===0?e:e===n||e===o?M(e):e},ct=function(t,e){return t===e||et(t)!==null?!1:(Zt&&ie(t),!0)},ce=function(t,e){if(Jn(t),x(h.beforeSanitizeElements,t,null),ct(t,e))return!0;if(xt(t))return Y(t),!0;const n=E(ht(t));if(_=Je(h.uponSanitizeElement,_,Yt,Lt),x(h.uponSanitizeElement,t,{tagName:n,allowedTags:_}),ct(t,e))return!0;if(to(t,n))return Y(t),!0;if(Tt[n]||!(B.tagCheck instanceof Function&&B.tagCheck(n))&&!_[n]){const o=eo(t,n,e);return o===!1&&(x(h.afterSanitizeElements,t,null),ct(t,e))?!0:o}if(P(t)===y.element&&!$n(t)||(n==="noscript"||n==="noembed"||n==="noframes")&&O(Po,t.innerHTML))return Y(t),!0;if(H&&t.nodeType===y.text){const o=vt(t.textContent);t.textContent!==o&&(yt(s.removed,{element:t.cloneNode()}),t.textContent=o)}return x(h.afterSanitizeElements,t,null),ct(t,e)},Qe=function(t,e,n){if(Ne[e]||qe(e,t)||Pe&&(e==="id"||e==="name")&&(n in a||n in Bn))return!1;const o=T[e]||B.attributeCheck instanceof Function&&B.attributeCheck(e,t);return Vt&&O(xn,e)||Ce&&O(kn,e)?!0:o?Fe[e]||O(Ie,bt(n,Le,""))||(e==="src"||e==="xlink:href"||e==="href")&&t!=="script"&&ln(n,"data:")===0&&Ue[t]||Me&&!O(Un,bt(n,Le,""))?!0:!n:tn(t)&&kt(k.tagNameCheck,t)&&kt(k.attributeNameCheck,e,t)||e==="is"&&k.allowCustomizedBuiltInElements&&kt(k.tagNameCheck,n)},no=d({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),tn=function(t){return!no[Q(t)]&&O(zn,t)},oo=function(t,e,n,o){if(w&&typeof tt=="object"&&typeof tt.getAttributeType=="function"&&!n)switch(tt.getAttributeType(t,e)){case"TrustedHTML":return ot(o);case"TrustedScriptURL":return wn(o)}return o},ro=function(t,e,n,o){try{return n?t.setAttributeNS(n,e,o):t.setAttribute(e,o),xt(t)?(Y(t),!1):!0}catch{return lt(e,t),!1}},en=function(t,e){return q&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,e)?!0:Q(t)==="attributename"&&an(e,"href")!==null},ue=function(t,e){if(x(h.beforeSanitizeAttributes,t,null),ct(t,e))return;const n=t.attributes;if(!n||xt(t))return;T=Je(h.uponSanitizeAttribute,T,jt,It);const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0};let l=n.length;const f=E(t.nodeName);for(;l--;){const p=n[l],S=p.name,z=p.namespaceURI,D=p.value,L=E(S),ut=D;let I=S==="value"?ut:ho(ut),nn=!1;if(o.attrName=L,o.attrValue=I,o.keepAttr=!0,o.forceKeepAttr=void 0,x(h.uponSanitizeAttribute,t,o),I=o.attrValue,ve&&(L==="id"||L==="name")&&ln(I,xe)!==0&&(lt(S,t,p),I=xe+I,nn=!0),en(S,I)){lt(S,t,p);continue}if(!o.forceKeepAttr){if(!o.keepAttr){lt(S,t,p);continue}if(!$t&&O(Tn,I)){lt(S,t,p);continue}if(H&&(I=vt(I)),!Qe(f,L,I)){lt(S,t,p);continue}I=oo(f,L,z,I),I!==ut&&ro(t,S,z,I)&&nn&&sn(s.removed)}}x(h.afterSanitizeAttributes,t,null),ct(t,e)},Et=function(t){let e=null;const n=ae(t);for(x(h.beforeSanitizeShadowDOM,t,null);e=n.nextNode();)if(x(h.uponSanitizeShadowNode,e,null),ce(e,t),ue(e,t),j(e.content)&&Et(e.content),P(e)===y.element){const o=Ft(e);j(o)&&(fe(o),Et(o))}H&&Ze(t),x(h.afterSanitizeShadowDOM,t,null)},fe=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const n=e.pop();if(n.shadow){Et(n.shadow);continue}const o=n.node,l=P(o)===y.element,f=dt(o);if(f)for(let p=f.length-1;p>=0;--p)e.push({node:f[p],shadow:null});if(l){const p=nt?nt(o):null;if(typeof p=="string"&&E(p)==="template"){const S=o.content;j(S)&&e.push({node:S,shadow:null})}}if(l){const p=Ft(o);j(p)&&e.push({node:null,shadow:p},{node:p,shadow:null})}}};return s.sanitize=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=null,n=null,o=null,l=null;if(Jt=!r,Jt&&(r="<!-->"),typeof r!="string"&&!At(r)&&(r=Ao(r),typeof r!="string"))throw W("dirty is not a string, aborting");if(!s.isSupported)return r;Xt?(_=Lt,T=It):ne(t),(h.uponSanitizeElement.length>0||h.uponSanitizeAttribute.length>0)&&(_=M(_)),h.uponSanitizeAttribute.length>0&&(T=M(T)),s.removed=[];const f=Zt&&typeof r!="string"&&At(r);let p=[];const S=Z;if(f){Qn(r);const L=ht(r);if(typeof L=="string"){const ut=E(L);if(!_[ut]||Tt[ut])throw oe(r),W("root node is forbidden and cannot be sanitized in-place")}if(xt(r))throw oe(r),W("root node is clobbered and cannot be sanitized in-place");p=se(r),Z=pe()}else if(At(r))e=Ke("<!---->"),n=e.ownerDocument.importNode(r,!0),n.nodeType===y.element&&n.nodeName==="BODY"||n.nodeName==="HTML"?e=n:e.appendChild(n),fe(e);else{if(!rt&&!H&&!K&&r.indexOf("<")===-1)return w&&Ct?ot(r):r;if(e=Ke(r),!e)return rt?null:Ct?X:""}e&&qt&&Y(e.firstChild);const z=f?r:e;try{f&&fe(r);const L=ae(z);for(;o=L.nextNode();)ce(o,z),ue(o,z),j(o.content)&&Et(o.content);f&&Kn(r,p)}catch(L){throw f&&(oe(r),Xe(r,p)),L}finally{Z=S}if(f){if(Xe(r,p))throw W("a node selected for removal could not be safely returned; refusing to sanitize in place");return H&&le(r),r}if(rt){if(H&&le(e),Nt)for(l=In.call(e.ownerDocument);e.firstChild;)l.appendChild(e.firstChild);else l=e;return(T.shadowroot||T.shadowrootmode)&&(l=Cn.call(u,l,!0)),l}let D=K?e.outerHTML:e.innerHTML;return K&&_["!doctype"]&&e.ownerDocument&&e.ownerDocument.doctype&&e.ownerDocument.doctype.name&&O(Co,e.ownerDocument.doctype.name)&&(D="<!DOCTYPE "+e.ownerDocument.doctype.name+`>
3
+ `+D),H&&(D=vt(D)),w&&Ct?ot(D):D},s.setConfig=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ne(r),Xt=!0,Lt=_,It=T},s.clearConfig=function(){at=null,Xt=!1,Lt=null,It=null,w=Wt,X=""},s.isValidAttribute=function(r,t,e){at||ne({});const n=E(r),o=E(t);return typeof e=="string"&&(en(t,e)||!$t&&O(Tn,e))?!1:Qe(n,o,e)},s.addHook=function(r,t){typeof t=="function"&&N(h,r)&&yt(h[r],t)},s.removeHook=function(r,t){if(N(h,r)){if(t!==void 0){const e=fo(h[r],t);return e===-1?void 0:mo(h[r],e,1)[0]}return sn(h[r])}},s.removeHooks=function(r){N(h,r)&&(h[r]=[])},s.removeAllHooks=function(){h=gn()},s}var Uo=On();export{Uo as p};