@mulmochat-plugin/summarize-pdf 0.1.0 → 0.1.1
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.
- package/dist/index.cjs +3 -3
- package/dist/index.js +19 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
`+u}!y&&!u.trim()&&(y=!0),l+=N+`
|
|
13
13
|
`,n=n.substring(N.length+1),h=u.slice(g)}}r.loose||(p?r.loose=!0:/\n *\n *$/.test(l)&&(p=!0));let x=null,$;this.options.gfm&&(x=/^\[[ xX]\] /.exec(o),x&&($=x[0]!=="[ ] ",o=o.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:l,task:!!x,checked:$,loose:!1,text:o,tokens:[]}),r.raw+=l}r.items[r.items.length-1].raw=l.trimEnd(),r.items[r.items.length-1].text=o.trimEnd(),r.raw=r.raw.trimEnd();for(let c=0;c<r.items.length;c++)if(this.lexer.state.top=!1,r.items[c].tokens=this.lexer.blockTokens(r.items[c].text,[]),!r.loose){const h=r.items[c].tokens.filter(g=>g.type==="space"),u=h.length>0&&h.some(g=>/\n.*\n/.test(g.raw));r.loose=u}if(r.loose)for(let c=0;c<r.items.length;c++)r.items[c].loose=!0;return r}}html(n){const t=this.rules.block.html.exec(n);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(n){const t=this.rules.block.def.exec(n);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:i,title:r}}}table(n){const t=this.rules.block.table.exec(n);if(!t||!/[:|]/.test(t[2]))return;const e=K(t[1]),i=t[2].replace(/^\||\| *$/g,"").split("|"),r=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
|
14
14
|
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===i.length){for(const l of i)/^ *-+: *$/.test(l)?s.align.push("right"):/^ *:-+: *$/.test(l)?s.align.push("center"):/^ *:-+ *$/.test(l)?s.align.push("left"):s.align.push(null);for(const l of e)s.header.push({text:l,tokens:this.lexer.inline(l)});for(const l of r)s.rows.push(K(l,s.header.length).map(o=>({text:o,tokens:this.lexer.inline(o)})));return s}}lheading(n){const t=this.rules.block.lheading.exec(n);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(n){const t=this.rules.block.paragraph.exec(n);if(t){const e=t[1].charAt(t[1].length-1)===`
|
|
15
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(n){const t=this.rules.block.text.exec(n);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(n){const t=this.rules.inline.escape.exec(n);if(t)return{type:"escape",raw:t[0],text:m(t[1])}}tag(n){const t=this.rules.inline.tag.exec(n);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.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(n){const t=this.rules.inline.link.exec(n);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const s=P(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{const s=be(t[2],"()");if(s>-1){const o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let i=t[2],r="";if(this.options.pedantic){const s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);s&&(i=s[1],r=s[3])}else r=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(e)?i=i.slice(1):i=i.slice(1,-1)),Y(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(n,t){let e;if((e=this.rules.inline.reflink.exec(n))||(e=this.rules.inline.nolink.exec(n))){const i=(e[2]||e[1]).replace(/\s+/g," "),r=t[i.toLowerCase()];if(!r){const s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Y(e,r,e[0],this.lexer)}}emStrong(n,t,e=""){let i=this.rules.inline.emStrongLDelim.exec(n);if(!i||i[3]&&e.match(/[\p{L}\p{N}]/u))return;if(!(i[1]||i[2]||"")||!e||this.rules.inline.punctuation.exec(e)){const s=[...i[0]].length-1;let l,o,p=s,c=0;const h=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*n.length+s);(i=h.exec(t))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(o=[...l].length,i[3]||i[4]){p+=o;continue}else if((i[5]||i[6])&&s%3&&!((s+o)%3)){c+=o;continue}if(p-=o,p>0)continue;o=Math.min(o,o+p+c);const u=[...i[0]][0].length,g=n.slice(0,s+i.index+u+o);if(Math.min(s,o)%2){const x=g.slice(1,-1);return{type:"em",raw:g,text:x,tokens:this.lexer.inlineTokens(x)}}const y=g.slice(2,-2);return{type:"strong",raw:g,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(n){const t=this.rules.inline.code.exec(n);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return i&&r&&(e=e.substring(1,e.length-1)),e=m(e,!0),{type:"codespan",raw:t[0],text:e}}}br(n){const t=this.rules.inline.br.exec(n);if(t)return{type:"br",raw:t[0]}}del(n){const t=this.rules.inline.del.exec(n);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(n){const t=this.rules.inline.autolink.exec(n);if(t){let e,i;return t[2]==="@"?(e=m(t[1]),i="mailto:"+e):(e=m(t[1]),i=e),{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}url(n){let t;if(t=this.rules.inline.url.exec(n)){let e,i;if(t[2]==="@")e=m(t[0]),i="mailto:"+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);e=m(t[0]),t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(n){const t=this.rules.inline.text.exec(n);if(t){let e;return this.lexer.state.inRawBlock?e=t[0]:e=m(t[0]),{type:"text",raw:t[0],text:e}}}}const ye=/^(?: *(?:\n|$))+/,$e=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,Te=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
16
|
-
]`).replace("lheading",re).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},oe=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ae=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ae=/^( {2,}|\\)\n(?!\s*$)/,De=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
15
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(n){const t=this.rules.block.text.exec(n);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(n){const t=this.rules.inline.escape.exec(n);if(t)return{type:"escape",raw:t[0],text:m(t[1])}}tag(n){const t=this.rules.inline.tag.exec(n);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.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(n){const t=this.rules.inline.link.exec(n);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const s=P(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{const s=be(t[2],"()");if(s>-1){const o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let i=t[2],r="";if(this.options.pedantic){const s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);s&&(i=s[1],r=s[3])}else r=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(e)?i=i.slice(1):i=i.slice(1,-1)),Y(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(n,t){let e;if((e=this.rules.inline.reflink.exec(n))||(e=this.rules.inline.nolink.exec(n))){const i=(e[2]||e[1]).replace(/\s+/g," "),r=t[i.toLowerCase()];if(!r){const s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Y(e,r,e[0],this.lexer)}}emStrong(n,t,e=""){let i=this.rules.inline.emStrongLDelim.exec(n);if(!i||i[3]&&e.match(/[\p{L}\p{N}]/u))return;if(!(i[1]||i[2]||"")||!e||this.rules.inline.punctuation.exec(e)){const s=[...i[0]].length-1;let l,o,p=s,c=0;const h=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*n.length+s);(i=h.exec(t))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(o=[...l].length,i[3]||i[4]){p+=o;continue}else if((i[5]||i[6])&&s%3&&!((s+o)%3)){c+=o;continue}if(p-=o,p>0)continue;o=Math.min(o,o+p+c);const u=[...i[0]][0].length,g=n.slice(0,s+i.index+u+o);if(Math.min(s,o)%2){const x=g.slice(1,-1);return{type:"em",raw:g,text:x,tokens:this.lexer.inlineTokens(x)}}const y=g.slice(2,-2);return{type:"strong",raw:g,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(n){const t=this.rules.inline.code.exec(n);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return i&&r&&(e=e.substring(1,e.length-1)),e=m(e,!0),{type:"codespan",raw:t[0],text:e}}}br(n){const t=this.rules.inline.br.exec(n);if(t)return{type:"br",raw:t[0]}}del(n){const t=this.rules.inline.del.exec(n);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(n){const t=this.rules.inline.autolink.exec(n);if(t){let e,i;return t[2]==="@"?(e=m(t[1]),i="mailto:"+e):(e=m(t[1]),i=e),{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}url(n){let t;if(t=this.rules.inline.url.exec(n)){let e,i;if(t[2]==="@")e=m(t[0]),i="mailto:"+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);e=m(t[0]),t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(n){const t=this.rules.inline.text.exec(n);if(t){let e;return this.lexer.state.inRawBlock?e=t[0]:e=m(t[0]),{type:"text",raw:t[0],text:e}}}}const ye=/^(?: *(?:\n|$))+/,$e=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,Te=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,v=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ze=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ie=/(?:[*+-]|\d{1,9}[.)])/,re=k(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,ie).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),M=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_e=/^[^\n]+/,O=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Re=k(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",O).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ve=k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ie).getRegex(),L="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",V=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Se=k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",V).replace("tag",L).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),le=k(M).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",L).getRegex(),Pe=k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",le).getRegex(),j={blockquote:Pe,code:$e,def:Re,fences:Te,heading:ze,hr:v,html:Se,lheading:re,list:ve,newline:ye,paragraph:le,table:R,text:_e},ee=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",L).getRegex(),Ee={...j,table:ee,paragraph:k(M).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ee).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",L).getRegex()},Ie={...j,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",V).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:R,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(M).replace("hr",v).replace("heading",` *#{1,6} *[^
|
|
16
|
+
]`).replace("lheading",re).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},oe=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ae=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ae=/^( {2,}|\\)\n(?!\s*$)/,De=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,S="\\p{P}\\p{S}",Ce=k(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,S).getRegex(),Le=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,Be=k(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,S).getRegex(),Ne=k("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,S).getRegex(),Fe=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,S).getRegex(),qe=k(/\\([punct])/,"gu").replace(/punct/g,S).getRegex(),Ze=k(/^<(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(),Me=k(V).replace("(?:-->|$)","-->").getRegex(),Oe=k("^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",Me).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),D=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Ve=k(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",D).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ce=k(/^!?\[(label)\]\[(ref)\]/).replace("label",D).replace("ref",O).getRegex(),ue=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",O).getRegex(),je=k("reflink|nolink(?!\\()","g").replace("reflink",ce).replace("nolink",ue).getRegex(),Q={_backpedal:R,anyPunctuation:qe,autolink:Ze,blockSkip:Le,br:ae,code:Ae,del:R,emStrongLDelim:Be,emStrongRDelimAst:Ne,emStrongRDelimUnd:Fe,escape:oe,link:Ve,nolink:ue,punctuation:Ce,reflink:ce,reflinkSearch:je,tag:Oe,text:De,url:R},Qe={...Q,link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",D).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",D).getRegex()},F={...Q,escape:k(oe).replace("])","~|])").getRegex(),url:k(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ue={...F,br:k(ae).replace("{2,}","*").getRegex(),text:k(F.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},E={normal:j,gfm:Ee,pedantic:Ie},_={normal:Q,gfm:F,breaks:Ue,pedantic:Qe};class b{tokens;options;state;tokenizer;inlineQueue;constructor(n){this.tokens=[],this.tokens.links=Object.create(null),this.options=n||z,this.options.tokenizer=this.options.tokenizer||new A,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:E.normal,inline:_.normal};this.options.pedantic?(t.block=E.pedantic,t.inline=_.pedantic):this.options.gfm&&(t.block=E.gfm,this.options.breaks?t.inline=_.breaks:t.inline=_.gfm),this.tokenizer.rules=t}static get rules(){return{block:E,inline:_}}static lex(n,t){return new b(t).lex(n)}static lexInline(n,t){return new b(t).inlineTokens(n)}lex(n){n=n.replace(/\r\n|\r/g,`
|
|
17
17
|
`),this.blockTokens(n,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(n,t=[]){this.options.pedantic?n=n.replace(/\t/g," ").replace(/^ +$/gm,""):n=n.replace(/^( *)(\t+)/gm,(l,o,p)=>o+" ".repeat(p.length));let e,i,r,s;for(;n;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(e=l.call({lexer:this},n,t))?(n=n.substring(e.raw.length),t.push(e),!0):!1))){if(e=this.tokenizer.space(n)){n=n.substring(e.raw.length),e.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
|
18
18
|
`:t.push(e);continue}if(e=this.tokenizer.code(n)){n=n.substring(e.raw.length),i=t[t.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
|
|
19
19
|
`+e.raw,i.text+=`
|
|
@@ -43,4 +43,4 @@ ${n}</tr>
|
|
|
43
43
|
`}tablecell(n,t){const e=t.header?"th":"td";return(t.align?`<${e} align="${t.align}">`:`<${e}>`)+n+`</${e}>
|
|
44
44
|
`}strong(n){return`<strong>${n}</strong>`}em(n){return`<em>${n}</em>`}codespan(n){return`<code>${n}</code>`}br(){return"<br>"}del(n){return`<del>${n}</del>`}link(n,t,e){const i=J(n);if(i===null)return e;n=i;let r='<a href="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=">"+e+"</a>",r}image(n,t,e){const i=J(n);if(i===null)return e;n=i;let r=`<img src="${n}" alt="${e}"`;return t&&(r+=` title="${t}"`),r+=">",r}text(n){return n}}class U{strong(n){return n}em(n){return n}codespan(n){return n}del(n){return n}html(n){return n}text(n){return n}link(n,t,e){return""+e}image(n,t,e){return""+e}br(){return""}}class w{options;renderer;textRenderer;constructor(n){this.options=n||z,this.options.renderer=this.options.renderer||new C,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new U}static parse(n,t){return new w(t).parse(n)}static parseInline(n,t){return new w(t).parseInline(n)}parse(n,t=!0){let e="";for(let i=0;i<n.length;i++){const r=n[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const s=r,l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(s.type)){e+=l||"";continue}}switch(r.type){case"space":continue;case"hr":{e+=this.renderer.hr();continue}case"heading":{const s=r;e+=this.renderer.heading(this.parseInline(s.tokens),s.depth,me(this.parseInline(s.tokens,this.textRenderer)));continue}case"code":{const s=r;e+=this.renderer.code(s.text,s.lang,!!s.escaped);continue}case"table":{const s=r;let l="",o="";for(let c=0;c<s.header.length;c++)o+=this.renderer.tablecell(this.parseInline(s.header[c].tokens),{header:!0,align:s.align[c]});l+=this.renderer.tablerow(o);let p="";for(let c=0;c<s.rows.length;c++){const h=s.rows[c];o="";for(let u=0;u<h.length;u++)o+=this.renderer.tablecell(this.parseInline(h[u].tokens),{header:!1,align:s.align[u]});p+=this.renderer.tablerow(o)}e+=this.renderer.table(l,p);continue}case"blockquote":{const s=r,l=this.parse(s.tokens);e+=this.renderer.blockquote(l);continue}case"list":{const s=r,l=s.ordered,o=s.start,p=s.loose;let c="";for(let h=0;h<s.items.length;h++){const u=s.items[h],g=u.checked,y=u.task;let x="";if(u.task){const $=this.renderer.checkbox(!!g);p?u.tokens.length>0&&u.tokens[0].type==="paragraph"?(u.tokens[0].text=$+" "+u.tokens[0].text,u.tokens[0].tokens&&u.tokens[0].tokens.length>0&&u.tokens[0].tokens[0].type==="text"&&(u.tokens[0].tokens[0].text=$+" "+u.tokens[0].tokens[0].text)):u.tokens.unshift({type:"text",text:$+" "}):x+=$+" "}x+=this.parse(u.tokens,p),c+=this.renderer.listitem(x,y,!!g)}e+=this.renderer.list(c,l,o);continue}case"html":{const s=r;e+=this.renderer.html(s.text,s.block);continue}case"paragraph":{const s=r;e+=this.renderer.paragraph(this.parseInline(s.tokens));continue}case"text":{let s=r,l=s.tokens?this.parseInline(s.tokens):s.text;for(;i+1<n.length&&n[i+1].type==="text";)s=n[++i],l+=`
|
|
45
45
|
`+(s.tokens?this.parseInline(s.tokens):s.text);e+=t?this.renderer.paragraph(l):l;continue}default:{const s='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return e}parseInline(n,t){t=t||this.renderer;let e="";for(let i=0;i<n.length;i++){const r=n[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const s=this.options.extensions.renderers[r.type].call({parser:this},r);if(s!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){e+=s||"";continue}}switch(r.type){case"escape":{const s=r;e+=t.text(s.text);break}case"html":{const s=r;e+=t.html(s.text);break}case"link":{const s=r;e+=t.link(s.href,s.title,this.parseInline(s.tokens,t));break}case"image":{const s=r;e+=t.image(s.href,s.title,s.text);break}case"strong":{const s=r;e+=t.strong(this.parseInline(s.tokens,t));break}case"em":{const s=r;e+=t.em(this.parseInline(s.tokens,t));break}case"codespan":{const s=r;e+=t.codespan(s.text);break}case"br":{e+=t.br();break}case"del":{const s=r;e+=t.del(this.parseInline(s.tokens,t));break}case"text":{const s=r;e+=t.text(s.text);break}default:{const s='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return e}}class I{options;constructor(n){this.options=n||z}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}}class He{defaults=Z();options=this.setOptions;parse=this.#e(b.lex,w.parse);parseInline=this.#e(b.lexInline,w.parseInline);Parser=w;Renderer=C;TextRenderer=U;Lexer=b;Tokenizer=A;Hooks=I;constructor(...n){this.use(...n)}walkTokens(n,t){let e=[];for(const i of n)switch(e=e.concat(t.call(this,i)),i.type){case"table":{const r=i;for(const s of r.header)e=e.concat(this.walkTokens(s.tokens,t));for(const s of r.rows)for(const l of s)e=e.concat(this.walkTokens(l.tokens,t));break}case"list":{const r=i;e=e.concat(this.walkTokens(r.items,t));break}default:{const r=i;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(s=>{const l=r[s].flat(1/0);e=e.concat(this.walkTokens(l,t))}):r.tokens&&(e=e.concat(this.walkTokens(r.tokens,t)))}}return e}use(...n){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(e=>{const i={...e};if(i.async=this.defaults.async||i.async||!1,e.extensions&&(e.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){const s=t.renderers[r.name];s?t.renderers[r.name]=function(...l){let o=r.renderer.apply(this,l);return o===!1&&(o=s.apply(this,l)),o}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const s=t[r.level];s?s.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),i.extensions=t),e.renderer){const r=this.defaults.renderer||new C(this.defaults);for(const s in e.renderer){if(!(s in r))throw new Error(`renderer '${s}' does not exist`);if(s==="options")continue;const l=s,o=e.renderer[l],p=r[l];r[l]=(...c)=>{let h=o.apply(r,c);return h===!1&&(h=p.apply(r,c)),h||""}}i.renderer=r}if(e.tokenizer){const r=this.defaults.tokenizer||new A(this.defaults);for(const s in e.tokenizer){if(!(s in r))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;const l=s,o=e.tokenizer[l],p=r[l];r[l]=(...c)=>{let h=o.apply(r,c);return h===!1&&(h=p.apply(r,c)),h}}i.tokenizer=r}if(e.hooks){const r=this.defaults.hooks||new I;for(const s in e.hooks){if(!(s in r))throw new Error(`hook '${s}' does not exist`);if(s==="options")continue;const l=s,o=e.hooks[l],p=r[l];I.passThroughHooks.has(s)?r[l]=c=>{if(this.defaults.async)return Promise.resolve(o.call(r,c)).then(u=>p.call(r,u));const h=o.call(r,c);return p.call(r,h)}:r[l]=(...c)=>{let h=o.apply(r,c);return h===!1&&(h=p.apply(r,c)),h}}i.hooks=r}if(e.walkTokens){const r=this.defaults.walkTokens,s=e.walkTokens;i.walkTokens=function(l){let o=[];return o.push(s.call(this,l)),r&&(o=o.concat(r.call(this,l))),o}}this.defaults={...this.defaults,...i}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,t){return b.lex(n,t??this.defaults)}parser(n,t){return w.parse(n,t??this.defaults)}#e(n,t){return(e,i)=>{const r={...i},s={...this.defaults,...r};this.defaults.async===!0&&r.async===!1&&(s.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),s.async=!0);const l=this.#t(!!s.silent,!!s.async);if(typeof e>"u"||e===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s),s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(e):e).then(o=>n(o,s)).then(o=>s.hooks?s.hooks.processAllTokens(o):o).then(o=>s.walkTokens?Promise.all(this.walkTokens(o,s.walkTokens)).then(()=>o):o).then(o=>t(o,s)).then(o=>s.hooks?s.hooks.postprocess(o):o).catch(l);try{s.hooks&&(e=s.hooks.preprocess(e));let o=n(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let p=t(o,s);return s.hooks&&(p=s.hooks.postprocess(p)),p}catch(o){return l(o)}}}#t(n,t){return e=>{if(e.message+=`
|
|
46
|
-
Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An error occurred:</p><pre>"+m(e.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(e);throw e}}}const T=new He;function d(a,n){return T.parse(a,n)}d.options=d.setOptions=function(a){return T.setOptions(a),d.defaults=T.defaults,te(d.defaults),d};d.getDefaults=Z;d.defaults=z;d.use=function(...a){return T.use(...a),d.defaults=T.defaults,te(d.defaults),d};d.walkTokens=function(a,n){return T.walkTokens(a,n)};d.parseInline=T.parseInline;d.Parser=w;d.parser=w.parse;d.Renderer=C;d.TextRenderer=U;d.Lexer=b;d.lexer=b.lex;d.Tokenizer=A;d.Hooks=I;d.parse=d;d.options;d.setOptions;d.use;d.walkTokens;d.parseInline;w.parse;b.lex;const Ge={class:"w-full h-full flex flex-col p-4"},Xe={class:"flex-1 w-full min-h-0"},We=["src"],Je={key:0,class:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg flex-shrink-0"},Ke={class:"text-sm text-gray-700 dark:text-gray-300"},Ye={key:1,class:"mt-2 p-3 bg-white rounded-lg flex-shrink-0 max-h-64 overflow-y-auto border border-gray-200"},et=["innerHTML"],tt=f.defineComponent({__name:"View",props:{selectedResult:{}},setup(a){const n=a,t=f.ref(null),e=f.ref("");f.watch(()=>n.selectedResult,s=>{s?.toolName===q&&s.data&&(t.value=s.data,r(s))},{immediate:!0,deep:!0});const i=f.computed(()=>{const s=t.value?.summary;return s?d(s):""});async function r(s){const l=s.data,o=s.uuid;if(l?.pdfData){if(!o){e.value=l.pdfData;return}try{const p=await fetch("/api/save-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pdfData:l.pdfData,uuid:o,fileName:l.fileName||"document.pdf"})});if(!p.ok)throw new Error("Failed to save PDF");const c=await p.json();e.value=c.pdfUrl}catch(p){console.error("Failed to save PDF to output folder:",p),e.value=l.pdfData}}}return(s,l)=>(f.openBlock(),f.createElementBlock("div",Ge,[f.createElementVNode("div",Xe,[e.value?(f.openBlock(),f.createElementBlock("iframe",{key:0,src:e.value,class:"w-full h-full border-0 rounded",title:"PDF Viewer"},null,8,We)):f.createCommentVNode("",!0)]),t.value?.fileName?(f.openBlock(),f.createElementBlock("div",Je,[f.createElementVNode("p",Ke,[l[0]||(l[0]=f.createElementVNode("span",{class:"font-medium"},"File:",-1)),f.createTextVNode(" "+f.toDisplayString(t.value.fileName),1)])])):f.createCommentVNode("",!0),t.value?.summary?(f.openBlock(),f.createElementBlock("div",Ye,[l[1]||(l[1]=f.createElementVNode("p",{class:"text-sm font-medium text-gray-700 mb-2"},"Summary:",-1)),f.createElementVNode("div",{class:"markdown-content prose prose-sm prose-slate max-w-none",innerHTML:i.value},null,8,et)])):f.createCommentVNode("",!0)]))}}),nt={class:"w-full h-32 bg-gray-200 dark:bg-gray-700 rounded flex items-center justify-center"},st={class:"text-center"},it={class:"text-xs mt-2 text-gray-600 dark:text-gray-300"},rt=f.defineComponent({__name:"Preview",props:{result:{}},setup(a){const n=a,t=f.computed(()=>n.result.data);return(e,i)=>(f.openBlock(),f.createElementBlock("div",nt,[f.createElementVNode("div",st,[i[0]||(i[0]=f.createElementVNode("svg",{class:"w-12 h-12 mx-auto text-red-500",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},[f.createElementVNode("path",{"fill-rule":"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z","clip-rule":"evenodd"})],-1)),f.createElementVNode("p",it,f.toDisplayString(t.value?.fileName||"PDF"),1)])]))}});function pe(a,n){return{toolName:q,data:{pdfData:a,fileName:n},message:"",title:n}}const lt=async(a,n)=>{const{prompt:t}=n,e=a.currentResult?.data;if(!e?.pdfData)return{message:"No PDF file available to summarize. Please select a PDF file first.",instructions:"Tell the user that no PDF file is currently selected and they need to upload a PDF file first."};if(!a.app?.
|
|
46
|
+
Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An error occurred:</p><pre>"+m(e.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(e);throw e}}}const T=new He;function d(a,n){return T.parse(a,n)}d.options=d.setOptions=function(a){return T.setOptions(a),d.defaults=T.defaults,te(d.defaults),d};d.getDefaults=Z;d.defaults=z;d.use=function(...a){return T.use(...a),d.defaults=T.defaults,te(d.defaults),d};d.walkTokens=function(a,n){return T.walkTokens(a,n)};d.parseInline=T.parseInline;d.Parser=w;d.parser=w.parse;d.Renderer=C;d.TextRenderer=U;d.Lexer=b;d.lexer=b.lex;d.Tokenizer=A;d.Hooks=I;d.parse=d;d.options;d.setOptions;d.use;d.walkTokens;d.parseInline;w.parse;b.lex;const Ge={class:"w-full h-full flex flex-col p-4"},Xe={class:"flex-1 w-full min-h-0"},We=["src"],Je={key:0,class:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg flex-shrink-0"},Ke={class:"text-sm text-gray-700 dark:text-gray-300"},Ye={key:1,class:"mt-2 p-3 bg-white rounded-lg flex-shrink-0 max-h-64 overflow-y-auto border border-gray-200"},et=["innerHTML"],tt=f.defineComponent({__name:"View",props:{selectedResult:{}},setup(a){const n=a,t=f.ref(null),e=f.ref("");f.watch(()=>n.selectedResult,s=>{s?.toolName===q&&s.data&&(t.value=s.data,r(s))},{immediate:!0,deep:!0});const i=f.computed(()=>{const s=t.value?.summary;return s?d(s):""});async function r(s){const l=s.data,o=s.uuid;if(l?.pdfData){if(!o){e.value=l.pdfData;return}try{const p=await fetch("/api/save-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pdfData:l.pdfData,uuid:o,fileName:l.fileName||"document.pdf"})});if(!p.ok)throw new Error("Failed to save PDF");const c=await p.json();e.value=c.pdfUrl}catch(p){console.error("Failed to save PDF to output folder:",p),e.value=l.pdfData}}}return(s,l)=>(f.openBlock(),f.createElementBlock("div",Ge,[f.createElementVNode("div",Xe,[e.value?(f.openBlock(),f.createElementBlock("iframe",{key:0,src:e.value,class:"w-full h-full border-0 rounded",title:"PDF Viewer"},null,8,We)):f.createCommentVNode("",!0)]),t.value?.fileName?(f.openBlock(),f.createElementBlock("div",Je,[f.createElementVNode("p",Ke,[l[0]||(l[0]=f.createElementVNode("span",{class:"font-medium"},"File:",-1)),f.createTextVNode(" "+f.toDisplayString(t.value.fileName),1)])])):f.createCommentVNode("",!0),t.value?.summary?(f.openBlock(),f.createElementBlock("div",Ye,[l[1]||(l[1]=f.createElementVNode("p",{class:"text-sm font-medium text-gray-700 mb-2"},"Summary:",-1)),f.createElementVNode("div",{class:"markdown-content prose prose-sm prose-slate max-w-none",innerHTML:i.value},null,8,et)])):f.createCommentVNode("",!0)]))}}),nt={class:"w-full h-32 bg-gray-200 dark:bg-gray-700 rounded flex items-center justify-center"},st={class:"text-center"},it={class:"text-xs mt-2 text-gray-600 dark:text-gray-300"},rt=f.defineComponent({__name:"Preview",props:{result:{}},setup(a){const n=a,t=f.computed(()=>n.result.data);return(e,i)=>(f.openBlock(),f.createElementBlock("div",nt,[f.createElementVNode("div",st,[i[0]||(i[0]=f.createElementVNode("svg",{class:"w-12 h-12 mx-auto text-red-500",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},[f.createElementVNode("path",{"fill-rule":"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z","clip-rule":"evenodd"})],-1)),f.createElementVNode("p",it,f.toDisplayString(t.value?.fileName||"PDF"),1)])]))}});function pe(a,n){return{toolName:q,data:{pdfData:a,fileName:n},message:"",title:n}}const lt=async(a,n)=>{const{prompt:t}=n,e=a.currentResult?.data;if(!e?.pdfData)return{message:"No PDF file available to summarize. Please select a PDF file first.",instructions:"Tell the user that no PDF file is currently selected and they need to upload a PDF file first."};if(!a.app?.summarizePdf)return{message:"summarizePdf function not available",instructions:"Tell the user that the PDF summarization failed."};try{const r=(await a.app.summarizePdf({prompt:t,pdfData:e.pdfData})).summary||"";return{data:{...e,summary:r},jsonData:{fileName:e.fileName,summary:r},message:"PDF summarized successfully",instructions:"Give the user a brief summary of the PDF.",instructionsRequired:!0,updating:!0}}catch(i){console.error("PDF summarization failed",i);const r=i instanceof Error?i.message:"Unknown error";return{message:`PDF summarization failed: ${r}`,instructions:`Tell the user that the PDF summarization failed with error: ${r}`}}},ot={toolDefinition:he,execute:lt,generatingMessage:"Summarizing PDF...",uploadMessage:"PDF file is available. Call 'summarizePDF' to see its summary",isEnabled:a=>!!a?.hasAnthropicApiKey,viewComponent:tt,previewComponent:rt,fileUpload:{acceptedTypes:["application/pdf"],handleUpload:pe}},at={plugin:ot};exports.createUploadedPdfResult=pe;exports.default=at;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as re, ref as Y, watch as xe, computed as le, createElementBlock as R, openBlock as
|
|
1
|
+
import { defineComponent as re, ref as Y, watch as xe, computed as le, createElementBlock as R, openBlock as v, createElementVNode as w, createCommentVNode as N, createTextVNode as be, toDisplayString as oe } from "vue";
|
|
2
2
|
const O = "summarizePDF", we = {
|
|
3
3
|
type: "function",
|
|
4
4
|
name: O,
|
|
@@ -72,7 +72,7 @@ function te(a) {
|
|
|
72
72
|
}
|
|
73
73
|
return a;
|
|
74
74
|
}
|
|
75
|
-
const
|
|
75
|
+
const S = { exec: () => null };
|
|
76
76
|
function ne(a, n) {
|
|
77
77
|
const t = a.replace(/\|/g, (r, s, l) => {
|
|
78
78
|
let o = !1, p = s;
|
|
@@ -100,7 +100,7 @@ function A(a, n, t) {
|
|
|
100
100
|
i++;
|
|
101
101
|
return a.slice(0, e - i);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function ve(a, n) {
|
|
104
104
|
if (a.indexOf(n[1]) === -1)
|
|
105
105
|
return -1;
|
|
106
106
|
let t = 0;
|
|
@@ -135,7 +135,7 @@ function se(a, n, t, e) {
|
|
|
135
135
|
text: k(s)
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Se(a, n) {
|
|
139
139
|
const t = a.match(/^(\s+)(?:```)/);
|
|
140
140
|
if (t === null)
|
|
141
141
|
return n;
|
|
@@ -183,7 +183,7 @@ class E {
|
|
|
183
183
|
fences(n) {
|
|
184
184
|
const t = this.rules.block.fences.exec(n);
|
|
185
185
|
if (t) {
|
|
186
|
-
const e = t[0], i =
|
|
186
|
+
const e = t[0], i = Se(e, t[3] || "");
|
|
187
187
|
return {
|
|
188
188
|
type: "code",
|
|
189
189
|
raw: e,
|
|
@@ -423,7 +423,7 @@ class E {
|
|
|
423
423
|
if ((e.length - s.length) % 2 === 0)
|
|
424
424
|
return;
|
|
425
425
|
} else {
|
|
426
|
-
const s =
|
|
426
|
+
const s = ve(t[2], "()");
|
|
427
427
|
if (s > -1) {
|
|
428
428
|
const o = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
|
|
429
429
|
t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, o).trim(), t[3] = "";
|
|
@@ -598,7 +598,7 @@ const Pe = /^(?: *(?:\n|$))+/, Ie = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Ae =
|
|
|
598
598
|
list: Le,
|
|
599
599
|
newline: Pe,
|
|
600
600
|
paragraph: fe,
|
|
601
|
-
table:
|
|
601
|
+
table: S,
|
|
602
602
|
text: Ce
|
|
603
603
|
}, ie = g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", P).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", q).getRegex(), Be = {
|
|
604
604
|
...V,
|
|
@@ -609,20 +609,20 @@ const Pe = /^(?: *(?:\n|$))+/, Ie = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Ae =
|
|
|
609
609
|
html: g(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
610
610
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
611
611
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
612
|
-
fences:
|
|
612
|
+
fences: S,
|
|
613
613
|
// fences not supported
|
|
614
614
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
615
615
|
paragraph: g(j).replace("hr", P).replace("heading", ` *#{1,6} *[^
|
|
616
616
|
]`).replace("lheading", he).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
617
617
|
}, de = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ne = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ge = /^( {2,}|\\)\n(?!\s*$)/, Me = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, I = "\\p{P}\\p{S}", Oe = g(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, I).getRegex(), Qe = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, je = g(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, I).getRegex(), He = g("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, I).getRegex(), Ue = g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, I).getRegex(), Ve = g(/\\([punct])/, "gu").replace(/punct/g, I).getRegex(), Ge = g(/^<(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(), Xe = g(U).replace("(?:-->|$)", "-->").getRegex(), We = g("^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", Xe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), L = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, Je = g(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", L).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ke = g(/^!?\[(label)\]\[(ref)\]/).replace("label", L).replace("ref", H).getRegex(), me = g(/^!?\[(ref)\](?:\[\])?/).replace("ref", H).getRegex(), Ke = g("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", me).getRegex(), G = {
|
|
618
|
-
_backpedal:
|
|
618
|
+
_backpedal: S,
|
|
619
619
|
// only used for GFM url
|
|
620
620
|
anyPunctuation: Ve,
|
|
621
621
|
autolink: Ge,
|
|
622
622
|
blockSkip: Qe,
|
|
623
623
|
br: ge,
|
|
624
624
|
code: Ne,
|
|
625
|
-
del:
|
|
625
|
+
del: S,
|
|
626
626
|
emStrongLDelim: je,
|
|
627
627
|
emStrongRDelimAst: He,
|
|
628
628
|
emStrongRDelimUnd: Ue,
|
|
@@ -634,7 +634,7 @@ const Pe = /^(?: *(?:\n|$))+/, Ie = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Ae =
|
|
|
634
634
|
reflinkSearch: Ke,
|
|
635
635
|
tag: We,
|
|
636
636
|
text: Me,
|
|
637
|
-
url:
|
|
637
|
+
url: S
|
|
638
638
|
}, Ye = {
|
|
639
639
|
...G,
|
|
640
640
|
link: g(/^!?\[(label)\]\((.*?)\)/).replace("label", L).getRegex(),
|
|
@@ -1490,22 +1490,22 @@ const nt = { class: "w-full h-full flex flex-col p-4" }, st = { class: "flex-1 w
|
|
|
1490
1490
|
}
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
1493
|
-
return (s, l) => (
|
|
1493
|
+
return (s, l) => (v(), R("div", nt, [
|
|
1494
1494
|
w("div", st, [
|
|
1495
|
-
e.value ? (
|
|
1495
|
+
e.value ? (v(), R("iframe", {
|
|
1496
1496
|
key: 0,
|
|
1497
1497
|
src: e.value,
|
|
1498
1498
|
class: "w-full h-full border-0 rounded",
|
|
1499
1499
|
title: "PDF Viewer"
|
|
1500
1500
|
}, null, 8, it)) : N("", !0)
|
|
1501
1501
|
]),
|
|
1502
|
-
t.value?.fileName ? (
|
|
1502
|
+
t.value?.fileName ? (v(), R("div", rt, [
|
|
1503
1503
|
w("p", lt, [
|
|
1504
1504
|
l[0] || (l[0] = w("span", { class: "font-medium" }, "File:", -1)),
|
|
1505
1505
|
be(" " + oe(t.value.fileName), 1)
|
|
1506
1506
|
])
|
|
1507
1507
|
])) : N("", !0),
|
|
1508
|
-
t.value?.summary ? (
|
|
1508
|
+
t.value?.summary ? (v(), R("div", ot, [
|
|
1509
1509
|
l[1] || (l[1] = w("p", { class: "text-sm font-medium text-gray-700 mb-2" }, "Summary:", -1)),
|
|
1510
1510
|
w("div", {
|
|
1511
1511
|
class: "markdown-content prose prose-sm prose-slate max-w-none",
|
|
@@ -1521,7 +1521,7 @@ const nt = { class: "w-full h-full flex flex-col p-4" }, st = { class: "flex-1 w
|
|
|
1521
1521
|
},
|
|
1522
1522
|
setup(a) {
|
|
1523
1523
|
const n = a, t = le(() => n.result.data);
|
|
1524
|
-
return (e, i) => (
|
|
1524
|
+
return (e, i) => (v(), R("div", ut, [
|
|
1525
1525
|
w("div", pt, [
|
|
1526
1526
|
i[0] || (i[0] = w("svg", {
|
|
1527
1527
|
class: "w-12 h-12 mx-auto text-red-500",
|
|
@@ -1555,13 +1555,13 @@ const gt = async (a, n) => {
|
|
|
1555
1555
|
message: "No PDF file available to summarize. Please select a PDF file first.",
|
|
1556
1556
|
instructions: "Tell the user that no PDF file is currently selected and they need to upload a PDF file first."
|
|
1557
1557
|
};
|
|
1558
|
-
if (!a.app?.
|
|
1558
|
+
if (!a.app?.summarizePdf)
|
|
1559
1559
|
return {
|
|
1560
|
-
message: "
|
|
1560
|
+
message: "summarizePdf function not available",
|
|
1561
1561
|
instructions: "Tell the user that the PDF summarization failed."
|
|
1562
1562
|
};
|
|
1563
1563
|
try {
|
|
1564
|
-
const r = (await a.app.
|
|
1564
|
+
const r = (await a.app.summarizePdf({
|
|
1565
1565
|
prompt: t,
|
|
1566
1566
|
pdfData: e.pdfData
|
|
1567
1567
|
})).summary || "";
|