@mulmochat-plugin/summarize-pdf 0.1.0

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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # MulmoChat Plugin
2
+
3
+ A plugin for [MulmoChat](https://github.com/receptron/MulmoChat) - a multi-modal voice chat application with OpenAI's GPT-4 Realtime API.
4
+
5
+ ## What this plugin does
6
+
7
+ Displays and summarizes uploaded PDF documents.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ yarn add @mulmochat-plugin/summarize-pdf
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import Plugin from "@mulmochat-plugin/summarize-pdf";
19
+ import "@mulmochat-plugin/summarize-pdf/style.css";
20
+
21
+ // Add to pluginList
22
+ const pluginList = [
23
+ // ... other plugins
24
+ Plugin,
25
+ ];
26
+ ```
27
+
28
+ ## Development
29
+
30
+ ```bash
31
+ # Install dependencies
32
+ yarn install
33
+
34
+ # Start dev server (http://localhost:5173/)
35
+ yarn dev
36
+
37
+ # Build
38
+ yarn build
39
+
40
+ # Type check
41
+ yarn typecheck
42
+
43
+ # Lint
44
+ yarn lint
45
+ ```
46
+
47
+ ## License
48
+
49
+ MIT
@@ -0,0 +1,6 @@
1
+ /**
2
+ * MulmoChat Plugin Common
3
+ *
4
+ * Shared types and utilities for building MulmoChat plugins.
5
+ */
6
+ export type { ToolContext, ToolResult, ToolPlugin, ToolDefinition, JsonSchemaProperty, StartApiResponse, FileUploadConfig, ToolPluginConfig, ToolSample, } from "./types";
@@ -0,0 +1,130 @@
1
+ /**
2
+ * MulmoChat Plugin Common Types
3
+ *
4
+ * Core interfaces for building MulmoChat plugins.
5
+ * These types are plugin-agnostic and can be used by any plugin implementation.
6
+ */
7
+ import type { Component } from "vue";
8
+ /**
9
+ * Context passed to plugin execute function
10
+ */
11
+ export interface ToolContext {
12
+ currentResult?: ToolResult<unknown> | null;
13
+ userPreferences?: Record<string, unknown>;
14
+ getPluginConfig?: <T = unknown>(key: string) => T | undefined;
15
+ /** Backend API functions provided by the host app */
16
+ app?: Record<string, (...args: any[]) => any>;
17
+ }
18
+ /**
19
+ * Result returned from plugin execution
20
+ */
21
+ export interface ToolResult<T = unknown, J = unknown> {
22
+ toolName?: string;
23
+ uuid?: string;
24
+ message: string;
25
+ title?: string;
26
+ jsonData?: J;
27
+ instructions?: string;
28
+ instructionsRequired?: boolean;
29
+ updating?: boolean;
30
+ cancelled?: boolean;
31
+ data?: T;
32
+ viewState?: Record<string, unknown>;
33
+ }
34
+ /**
35
+ * JSON Schema property definition for tool parameters
36
+ */
37
+ export interface JsonSchemaProperty {
38
+ type?: string;
39
+ description?: string;
40
+ enum?: string[];
41
+ items?: JsonSchemaProperty;
42
+ minimum?: number;
43
+ maximum?: number;
44
+ minItems?: number;
45
+ maxItems?: number;
46
+ properties?: Record<string, JsonSchemaProperty>;
47
+ required?: string[];
48
+ additionalProperties?: boolean;
49
+ oneOf?: JsonSchemaProperty[];
50
+ [key: string]: unknown;
51
+ }
52
+ /**
53
+ * API response from server start endpoint
54
+ */
55
+ export interface StartApiResponse {
56
+ hasOpenAIApiKey?: boolean;
57
+ hasAnthropicApiKey?: boolean;
58
+ hasGoogleApiKey?: boolean;
59
+ [key: string]: unknown;
60
+ }
61
+ /**
62
+ * Tool definition for OpenAI-compatible function calling
63
+ */
64
+ export interface ToolDefinition {
65
+ type: "function";
66
+ name: string;
67
+ description: string;
68
+ parameters?: {
69
+ type: "object";
70
+ properties: Record<string, JsonSchemaProperty>;
71
+ required: string[];
72
+ additionalProperties?: boolean;
73
+ };
74
+ }
75
+ /**
76
+ * File upload configuration
77
+ */
78
+ export interface FileUploadConfig {
79
+ acceptedTypes: string[];
80
+ handleUpload: (fileData: string, fileName: string, ...args: unknown[]) => ToolResult<unknown, unknown>;
81
+ }
82
+ /**
83
+ * Plugin configuration
84
+ */
85
+ export interface ToolPluginConfig {
86
+ key: string;
87
+ defaultValue: unknown;
88
+ component: Component;
89
+ }
90
+ /**
91
+ * Sample arguments for testing
92
+ */
93
+ export interface ToolSample {
94
+ name: string;
95
+ args: Record<string, unknown>;
96
+ }
97
+ /**
98
+ * Main plugin interface
99
+ * @template T - Type of data stored in result.data
100
+ * @template J - Type of data stored in result.jsonData
101
+ * @template A - Type of arguments passed to execute
102
+ */
103
+ export interface ToolPlugin<T = unknown, J = unknown, A extends object = object> {
104
+ /** Tool definition for LLM function calling */
105
+ toolDefinition: ToolDefinition;
106
+ /** Execute the plugin with given context and arguments */
107
+ execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
108
+ /** Message shown while generating */
109
+ generatingMessage: string;
110
+ /** Message shown while waiting for user action */
111
+ waitingMessage?: string;
112
+ /** Message shown during file upload */
113
+ uploadMessage?: string;
114
+ /** Check if plugin is enabled based on server capabilities */
115
+ isEnabled: (startResponse?: StartApiResponse | null) => boolean;
116
+ /** Delay in ms after execution before proceeding */
117
+ delayAfterExecution?: number;
118
+ /** Vue component for full view */
119
+ viewComponent?: Component;
120
+ /** Vue component for preview/thumbnail */
121
+ previewComponent?: Component;
122
+ /** System prompt additions for this plugin */
123
+ systemPrompt?: string;
124
+ /** Optional file upload configuration */
125
+ fileUpload?: FileUploadConfig;
126
+ /** Optional plugin-specific configuration */
127
+ config?: ToolPluginConfig;
128
+ /** Optional sample arguments for testing */
129
+ samples?: ToolSample[];
130
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("vue"),q="summarizePDF",he={type:"function",name:q,description:"Summarize the content of a currently selected PDF file using Claude.",parameters:{type:"object",properties:{prompt:{type:"string",description:"Instructions for Claude on how to summarize or analyze the PDF"}},required:["prompt"]}};function Z(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let z=Z();function te(a){z=a}const ne=/[&<>"']/,fe=new RegExp(ne.source,"g"),se=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,de=new RegExp(se.source,"g"),ge={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},W=a=>ge[a];function m(a,n){if(n){if(ne.test(a))return a.replace(fe,W)}else if(se.test(a))return a.replace(de,W);return a}const ke=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function me(a){return a.replace(ke,(n,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const xe=/(^|[^\[])\^/g;function k(a,n){let t=typeof a=="string"?a:a.source;n=n||"";const e={replace:(i,r)=>{let s=typeof r=="string"?r:r.source;return s=s.replace(xe,"$1"),t=t.replace(i,s),e},getRegex:()=>new RegExp(t,n)};return e}function J(a){try{a=encodeURI(a).replace(/%25/g,"%")}catch{return null}return a}const R={exec:()=>null};function K(a,n){const t=a.replace(/\|/g,(r,s,l)=>{let o=!1,p=s;for(;--p>=0&&l[p]==="\\";)o=!o;return o?"|":" |"}),e=t.split(/ \|/);let i=0;if(e[0].trim()||e.shift(),e.length>0&&!e[e.length-1].trim()&&e.pop(),n)if(e.length>n)e.splice(n);else for(;e.length<n;)e.push("");for(;i<e.length;i++)e[i]=e[i].trim().replace(/\\\|/g,"|");return e}function P(a,n,t){const e=a.length;if(e===0)return"";let i=0;for(;i<e&&a.charAt(e-i-1)===n;)i++;return a.slice(0,e-i)}function be(a,n){if(a.indexOf(n[1])===-1)return-1;let t=0;for(let e=0;e<a.length;e++)if(a[e]==="\\")e++;else if(a[e]===n[0])t++;else if(a[e]===n[1]&&(t--,t<0))return e;return-1}function Y(a,n,t,e){const i=n.href,r=n.title?m(n.title):null,s=a[1].replace(/\\([\[\]])/g,"$1");if(a[0].charAt(0)!=="!"){e.state.inLink=!0;const l={type:"link",raw:t,href:i,title:r,text:s,tokens:e.inlineTokens(s)};return e.state.inLink=!1,l}return{type:"image",raw:t,href:i,title:r,text:m(s)}}function we(a,n){const t=a.match(/^(\s+)(?:```)/);if(t===null)return n;const e=t[1];return n.split(`
2
+ `).map(i=>{const r=i.match(/^\s+/);if(r===null)return i;const[s]=r;return s.length>=e.length?i.slice(e.length):i}).join(`
3
+ `)}class A{options;rules;lexer;constructor(n){this.options=n||z}space(n){const t=this.rules.block.newline.exec(n);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(n){const t=this.rules.block.code.exec(n);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:P(e,`
4
+ `)}}}fences(n){const t=this.rules.block.fences.exec(n);if(t){const e=t[0],i=we(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(n){const t=this.rules.block.heading.exec(n);if(t){let e=t[2].trim();if(/#$/.test(e)){const i=P(e,"#");(this.options.pedantic||!i||/ $/.test(i))&&(e=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(n){const t=this.rules.block.hr.exec(n);if(t)return{type:"hr",raw:t[0]}}blockquote(n){const t=this.rules.block.blockquote.exec(n);if(t){let e=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
5
+ $1`);e=P(e.replace(/^ *>[ \t]?/gm,""),`
6
+ `);const i=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(e);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:r,text:e}}}list(n){let t=this.rules.block.list.exec(n);if(t){let e=t[1].trim();const i=e.length>1,r={type:"list",raw:"",ordered:i,start:i?+e.slice(0,-1):"",loose:!1,items:[]};e=i?`\\d{1,9}\\${e.slice(-1)}`:`\\${e}`,this.options.pedantic&&(e=i?e:"[*+-]");const s=new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`);let l="",o="",p=!1;for(;n;){let c=!1;if(!(t=s.exec(n))||this.rules.block.hr.test(n))break;l=t[0],n=n.substring(l.length);let h=t[2].split(`
7
+ `,1)[0].replace(/^\t+/,B=>" ".repeat(3*B.length)),u=n.split(`
8
+ `,1)[0],g=0;this.options.pedantic?(g=2,o=h.trimStart()):(g=t[2].search(/[^ ]/),g=g>4?1:g,o=h.slice(g),g+=t[1].length);let y=!1;if(!h&&/^ *$/.test(u)&&(l+=u+`
9
+ `,n=n.substring(u.length+1),c=!0),!c){const B=new RegExp(`^ {0,${Math.min(3,g-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),H=new RegExp(`^ {0,${Math.min(3,g-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),G=new RegExp(`^ {0,${Math.min(3,g-1)}}(?:\`\`\`|~~~)`),X=new RegExp(`^ {0,${Math.min(3,g-1)}}#`);for(;n;){const N=n.split(`
10
+ `,1)[0];if(u=N,this.options.pedantic&&(u=u.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),G.test(u)||X.test(u)||B.test(u)||H.test(n))break;if(u.search(/[^ ]/)>=g||!u.trim())o+=`
11
+ `+u.slice(g);else{if(y||h.search(/[^ ]/)>=4||G.test(h)||X.test(h)||H.test(h))break;o+=`
12
+ `+u}!y&&!u.trim()&&(y=!0),l+=N+`
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
+ `):[],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|$)|$)/,S=/^ {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(),Se=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]*?(?:-->|$))/,ve=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",S).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:S,html:ve,lheading:re,list:Se,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",S).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",S).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",S).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)))/,v="\\p{P}\\p{S}",Ce=k(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,v).getRegex(),Le=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,Be=k(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,v).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,v).getRegex(),Fe=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,v).getRegex(),qe=k(/\\([punct])/,"gu").replace(/punct/g,v).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
+ `),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
+ `: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
+ `+e.raw,i.text+=`
20
+ `+e.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(e);continue}if(e=this.tokenizer.fences(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.heading(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.hr(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.blockquote(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.list(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.html(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.def(n)){n=n.substring(e.raw.length),i=t[t.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
21
+ `+e.raw,i.text+=`
22
+ `+e.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[e.tag]||(this.tokens.links[e.tag]={href:e.href,title:e.title});continue}if(e=this.tokenizer.table(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.lheading(n)){n=n.substring(e.raw.length),t.push(e);continue}if(r=n,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const o=n.slice(1);let p;this.options.extensions.startBlock.forEach(c=>{p=c.call({lexer:this},o),typeof p=="number"&&p>=0&&(l=Math.min(l,p))}),l<1/0&&l>=0&&(r=n.substring(0,l+1))}if(this.state.top&&(e=this.tokenizer.paragraph(r))){i=t[t.length-1],s&&i.type==="paragraph"?(i.raw+=`
23
+ `+e.raw,i.text+=`
24
+ `+e.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(e),s=r.length!==n.length,n=n.substring(e.raw.length);continue}if(e=this.tokenizer.text(n)){n=n.substring(e.raw.length),i=t[t.length-1],i&&i.type==="text"?(i.raw+=`
25
+ `+e.raw,i.text+=`
26
+ `+e.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(e);continue}if(n){const l="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,t}inline(n,t=[]){return this.inlineQueue.push({src:n,tokens:t}),t}inlineTokens(n,t=[]){let e,i,r,s=n,l,o,p;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,l.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;n;)if(o||(p=""),o=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(e=c.call({lexer:this},n,t))?(n=n.substring(e.raw.length),t.push(e),!0):!1))){if(e=this.tokenizer.escape(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.tag(n)){n=n.substring(e.raw.length),i=t[t.length-1],i&&e.type==="text"&&i.type==="text"?(i.raw+=e.raw,i.text+=e.text):t.push(e);continue}if(e=this.tokenizer.link(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.reflink(n,this.tokens.links)){n=n.substring(e.raw.length),i=t[t.length-1],i&&e.type==="text"&&i.type==="text"?(i.raw+=e.raw,i.text+=e.text):t.push(e);continue}if(e=this.tokenizer.emStrong(n,s,p)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.codespan(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.br(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.del(n)){n=n.substring(e.raw.length),t.push(e);continue}if(e=this.tokenizer.autolink(n)){n=n.substring(e.raw.length),t.push(e);continue}if(!this.state.inLink&&(e=this.tokenizer.url(n))){n=n.substring(e.raw.length),t.push(e);continue}if(r=n,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const h=n.slice(1);let u;this.options.extensions.startInline.forEach(g=>{u=g.call({lexer:this},h),typeof u=="number"&&u>=0&&(c=Math.min(c,u))}),c<1/0&&c>=0&&(r=n.substring(0,c+1))}if(e=this.tokenizer.inlineText(r)){n=n.substring(e.raw.length),e.raw.slice(-1)!=="_"&&(p=e.raw.slice(-1)),o=!0,i=t[t.length-1],i&&i.type==="text"?(i.raw+=e.raw,i.text+=e.text):t.push(e);continue}if(n){const c="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return t}}class C{options;constructor(n){this.options=n||z}code(n,t,e){const i=(t||"").match(/^\S*/)?.[0];return n=n.replace(/\n$/,"")+`
27
+ `,i?'<pre><code class="language-'+m(i)+'">'+(e?n:m(n,!0))+`</code></pre>
28
+ `:"<pre><code>"+(e?n:m(n,!0))+`</code></pre>
29
+ `}blockquote(n){return`<blockquote>
30
+ ${n}</blockquote>
31
+ `}html(n,t){return n}heading(n,t,e){return`<h${t}>${n}</h${t}>
32
+ `}hr(){return`<hr>
33
+ `}list(n,t,e){const i=t?"ol":"ul",r=t&&e!==1?' start="'+e+'"':"";return"<"+i+r+`>
34
+ `+n+"</"+i+`>
35
+ `}listitem(n,t,e){return`<li>${n}</li>
36
+ `}checkbox(n){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(n){return`<p>${n}</p>
37
+ `}table(n,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
38
+ <thead>
39
+ `+n+`</thead>
40
+ `+t+`</table>
41
+ `}tablerow(n){return`<tr>
42
+ ${n}</tr>
43
+ `}tablecell(n,t){const e=t.header?"th":"td";return(t.align?`<${e} align="${t.align}">`:`<${e}>`)+n+`</${e}>
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
+ `+(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?.fetchSummarizePdf)return{message:"fetchSummarizePdf function not available",instructions:"Tell the user that the PDF summarization failed."};try{const r=(await a.app.fetchSummarizePdf({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;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * MulmoChat Plugin
3
+ *
4
+ * See package.json for plugin details.
5
+ */
6
+ import "./style.css";
7
+ import { createUploadedPdfResult } from "./plugin";
8
+ import type { ToolPlugin } from "./common";
9
+ export { createUploadedPdfResult };
10
+ declare const _default: {
11
+ plugin: ToolPlugin;
12
+ };
13
+ export default _default;