keshan commited on
Commit
0b6476c
·
verified ·
1 Parent(s): c3d704b

Upload folder using huggingface_hub

Browse files
.gitignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .eggs/
2
+ dist/
3
+ *.pyc
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ __tmp/*
8
+ *.pyi
9
+ .mypycache
10
+ .ruff_cache
11
+ node_modules
12
+ backend/**/templates/
.gradio/flagged/dataset1.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Input Analysis (Interactive - if it were input),Code Analysis Output,timestamp
2
+ ,,2025-06-10 00:16:38.620220
README.md CHANGED
@@ -1,12 +1,309 @@
1
  ---
2
- title: Gradio Codeanalysisviewer
3
- emoji: 🏃
4
- colorFrom: red
5
- colorTo: blue
 
6
  sdk: gradio
7
- sdk_version: 5.33.1
8
- app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ tags: [gradio-custom-component, SimpleTextbox, custom-component-track, agents, code-analysis, agents-mcp-hackathon]
3
+ title: gradio_codeanalysisviewer
4
+ short_description: A nicer view to show the Agentic code analyser outputs
5
+ colorFrom: blue
6
+ colorTo: yellow
7
  sdk: gradio
 
 
8
  pinned: false
9
+ app_file: space.py
10
  ---
11
 
12
+ # `gradio_codeanalysisviewer`
13
+ <a href="https://pypi.org/project/gradio_codeanalysisviewer/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_codeanalysisviewer"></a>
14
+
15
+ A nicer view to show the Agentic code analyser outputs
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install gradio_codeanalysisviewer
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```python
26
+
27
+ import gradio as gr
28
+ from gradio_codeanalysisviewer import CodeAnalysisViewer
29
+
30
+
31
+ # Prepare an example dictionary matching the OutputSchema structure
32
+ example_data = {
33
+ "code": "def greet(name):\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
34
+ "issue": "Security Risk: Use of f-string in print might be risky if 'name' is user-controlled and not sanitized.",
35
+ "reason": "Formatted string literals (f-strings) can be vulnerable to injection if they include unsanitized user input, though in this specific 'print' case, the direct risk is low unless the output is piped elsewhere or has special terminal interpretations.",
36
+ "fixed_code": "def greet(name):\n # Sanitize name if it comes from an external source, e.g., name = escape(name)\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
37
+ "feedback": "#### Security Feedback:\n* **Issue**: Potential for injection with f-string.\n* **Severity**: Low (in this context).\n* **Recommendation**: Always sanitize external inputs used in f-strings, especially if they are logged or displayed in sensitive contexts. For simple printing, the risk is minimal.\n\n#### Documentation Feedback:\n* The function `greet` is missing a docstring.\n* Consider adding type hints."
38
+ }
39
+
40
+ # Use the example_value from the component itself for the examples list
41
+ # This ensures we're using the structure defined within the component's backend
42
+ component_example = CodeAnalysisViewer().example_value()
43
+
44
+ demo = gr.Interface(
45
+ lambda data_dict: data_dict, # The function now expects and returns a dictionary
46
+ CodeAnalysisViewer(label="Input Analysis (Interactive - if it were input)"), # This would be for input, not our primary use case
47
+ CodeAnalysisViewer(label="Code Analysis Output"), # This is how we'll use it as an output display
48
+ examples=[[component_example], [example_data]] # Provide examples
49
+ )
50
+
51
+
52
+ if __name__ == "__main__":
53
+ demo.launch()
54
+
55
+ ```
56
+
57
+ ## `CodeAnalysisViewer`
58
+
59
+ ### Initialization
60
+
61
+ <table>
62
+ <thead>
63
+ <tr>
64
+ <th align="left">name</th>
65
+ <th align="left" style="width: 25%;">type</th>
66
+ <th align="left">default</th>
67
+ <th align="left">description</th>
68
+ </tr>
69
+ </thead>
70
+ <tbody>
71
+ <tr>
72
+ <td align="left"><code>value</code></td>
73
+ <td align="left" style="width: 25%;">
74
+
75
+ ```python
76
+ dict | Callable | None
77
+ ```
78
+
79
+ </td>
80
+ <td align="left"><code>None</code></td>
81
+ <td align="left">default text to provide in textbox. If a function is provided, the function will be called each time the app loads to set the initial value of this component.</td>
82
+ </tr>
83
+
84
+ <tr>
85
+ <td align="left"><code>placeholder</code></td>
86
+ <td align="left" style="width: 25%;">
87
+
88
+ ```python
89
+ str | None
90
+ ```
91
+
92
+ </td>
93
+ <td align="left"><code>None</code></td>
94
+ <td align="left">placeholder hint to provide behind textbox.</td>
95
+ </tr>
96
+
97
+ <tr>
98
+ <td align="left"><code>label</code></td>
99
+ <td align="left" style="width: 25%;">
100
+
101
+ ```python
102
+ str | I18nData | None
103
+ ```
104
+
105
+ </td>
106
+ <td align="left"><code>None</code></td>
107
+ <td align="left">the label for this component, displayed above the component if `show_label` is `True` and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component corresponds to.</td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <td align="left"><code>every</code></td>
112
+ <td align="left" style="width: 25%;">
113
+
114
+ ```python
115
+ Timer | float | None
116
+ ```
117
+
118
+ </td>
119
+ <td align="left"><code>None</code></td>
120
+ <td align="left">Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.</td>
121
+ </tr>
122
+
123
+ <tr>
124
+ <td align="left"><code>inputs</code></td>
125
+ <td align="left" style="width: 25%;">
126
+
127
+ ```python
128
+ Component | Sequence[Component] | set[Component] | None
129
+ ```
130
+
131
+ </td>
132
+ <td align="left"><code>None</code></td>
133
+ <td align="left">Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.</td>
134
+ </tr>
135
+
136
+ <tr>
137
+ <td align="left"><code>show_label</code></td>
138
+ <td align="left" style="width: 25%;">
139
+
140
+ ```python
141
+ bool | None
142
+ ```
143
+
144
+ </td>
145
+ <td align="left"><code>None</code></td>
146
+ <td align="left">if True, will display label.</td>
147
+ </tr>
148
+
149
+ <tr>
150
+ <td align="left"><code>scale</code></td>
151
+ <td align="left" style="width: 25%;">
152
+
153
+ ```python
154
+ int | None
155
+ ```
156
+
157
+ </td>
158
+ <td align="left"><code>None</code></td>
159
+ <td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
160
+ </tr>
161
+
162
+ <tr>
163
+ <td align="left"><code>min_width</code></td>
164
+ <td align="left" style="width: 25%;">
165
+
166
+ ```python
167
+ int
168
+ ```
169
+
170
+ </td>
171
+ <td align="left"><code>160</code></td>
172
+ <td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
173
+ </tr>
174
+
175
+ <tr>
176
+ <td align="left"><code>interactive</code></td>
177
+ <td align="left" style="width: 25%;">
178
+
179
+ ```python
180
+ bool | None
181
+ ```
182
+
183
+ </td>
184
+ <td align="left"><code>None</code></td>
185
+ <td align="left">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>
186
+ </tr>
187
+
188
+ <tr>
189
+ <td align="left"><code>visible</code></td>
190
+ <td align="left" style="width: 25%;">
191
+
192
+ ```python
193
+ bool
194
+ ```
195
+
196
+ </td>
197
+ <td align="left"><code>True</code></td>
198
+ <td align="left">If False, component will be hidden.</td>
199
+ </tr>
200
+
201
+ <tr>
202
+ <td align="left"><code>rtl</code></td>
203
+ <td align="left" style="width: 25%;">
204
+
205
+ ```python
206
+ bool
207
+ ```
208
+
209
+ </td>
210
+ <td align="left"><code>False</code></td>
211
+ <td align="left">If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.</td>
212
+ </tr>
213
+
214
+ <tr>
215
+ <td align="left"><code>elem_id</code></td>
216
+ <td align="left" style="width: 25%;">
217
+
218
+ ```python
219
+ str | None
220
+ ```
221
+
222
+ </td>
223
+ <td align="left"><code>None</code></td>
224
+ <td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
225
+ </tr>
226
+
227
+ <tr>
228
+ <td align="left"><code>elem_classes</code></td>
229
+ <td align="left" style="width: 25%;">
230
+
231
+ ```python
232
+ list[str] | str | None
233
+ ```
234
+
235
+ </td>
236
+ <td align="left"><code>None</code></td>
237
+ <td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
238
+ </tr>
239
+
240
+ <tr>
241
+ <td align="left"><code>render</code></td>
242
+ <td align="left" style="width: 25%;">
243
+
244
+ ```python
245
+ bool
246
+ ```
247
+
248
+ </td>
249
+ <td align="left"><code>True</code></td>
250
+ <td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
251
+ </tr>
252
+
253
+ <tr>
254
+ <td align="left"><code>key</code></td>
255
+ <td align="left" style="width: 25%;">
256
+
257
+ ```python
258
+ int | str | tuple[int | str, ...] | None
259
+ ```
260
+
261
+ </td>
262
+ <td align="left"><code>None</code></td>
263
+ <td align="left">in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render.</td>
264
+ </tr>
265
+
266
+ <tr>
267
+ <td align="left"><code>preserved_by_key</code></td>
268
+ <td align="left" style="width: 25%;">
269
+
270
+ ```python
271
+ list[str] | str | None
272
+ ```
273
+
274
+ </td>
275
+ <td align="left"><code>"value"</code></td>
276
+ <td align="left">A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor.</td>
277
+ </tr>
278
+ </tbody></table>
279
+
280
+
281
+ ### Events
282
+
283
+ | name | description |
284
+ |:-----|:------------|
285
+ | `change` | Triggered when the value of the CodeAnalysisViewer changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
286
+ | `input` | This listener is triggered when the user changes the value of the CodeAnalysisViewer. |
287
+ | `submit` | This listener is triggered when the user presses the Enter key while the CodeAnalysisViewer is focused. |
288
+
289
+
290
+
291
+ ### User function
292
+
293
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
294
+
295
+ - When used as an Input, the component only impacts the input signature of the user function.
296
+ - When used as an output, the component only impacts the return signature of the user function.
297
+
298
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
299
+
300
+ - **As output:** Is passed, the payload to be used in the backend function.
301
+ - **As input:** Should return, expects a dictionary (OutputSchema) from the backend function.
302
+
303
+ ```python
304
+ def predict(
305
+ value: dict | None
306
+ ) -> dict | None:
307
+ return value
308
+ ```
309
+
__init__.py ADDED
File without changes
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from gradio_codeanalysisviewer import CodeAnalysisViewer
4
+
5
+
6
+ # Prepare an example dictionary matching the OutputSchema structure
7
+ example_data = {
8
+ "code": "def greet(name):\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
9
+ "issue": "Security Risk: Use of f-string in print might be risky if 'name' is user-controlled and not sanitized.",
10
+ "reason": "Formatted string literals (f-strings) can be vulnerable to injection if they include unsanitized user input, though in this specific 'print' case, the direct risk is low unless the output is piped elsewhere or has special terminal interpretations.",
11
+ "fixed_code": "def greet(name):\n # Sanitize name if it comes from an external source, e.g., name = escape(name)\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
12
+ "feedback": "#### Security Feedback:\n* **Issue**: Potential for injection with f-string.\n* **Severity**: Low (in this context).\n* **Recommendation**: Always sanitize external inputs used in f-strings, especially if they are logged or displayed in sensitive contexts. For simple printing, the risk is minimal.\n\n#### Documentation Feedback:\n* The function `greet` is missing a docstring.\n* Consider adding type hints."
13
+ }
14
+
15
+ # Use the example_value from the component itself for the examples list
16
+ # This ensures we're using the structure defined within the component's backend
17
+ component_example = CodeAnalysisViewer().example_value()
18
+
19
+ demo = gr.Interface(
20
+ lambda data_dict: data_dict, # The function now expects and returns a dictionary
21
+ CodeAnalysisViewer(label="Input Analysis (Interactive - if it were input)"), # This would be for input, not our primary use case
22
+ CodeAnalysisViewer(label="Code Analysis Output"), # This is how we'll use it as an output display
23
+ examples=[[component_example], [example_data]] # Provide examples
24
+ )
25
+
26
+
27
+ if __name__ == "__main__":
28
+ demo.launch()
css.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ font-family: Inter;
3
+ font-size: 16px;
4
+ font-weight: 400;
5
+ line-height: 1.5;
6
+ -webkit-text-size-adjust: 100%;
7
+ background: #fff;
8
+ color: #323232;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ text-rendering: optimizeLegibility;
12
+ }
13
+
14
+ :root {
15
+ --space: 1;
16
+ --vspace: calc(var(--space) * 1rem);
17
+ --vspace-0: calc(3 * var(--space) * 1rem);
18
+ --vspace-1: calc(2 * var(--space) * 1rem);
19
+ --vspace-2: calc(1.5 * var(--space) * 1rem);
20
+ --vspace-3: calc(0.5 * var(--space) * 1rem);
21
+ }
22
+
23
+ .app {
24
+ max-width: 748px !important;
25
+ }
26
+
27
+ .prose p {
28
+ margin: var(--vspace) 0;
29
+ line-height: var(--vspace * 2);
30
+ font-size: 1rem;
31
+ }
32
+
33
+ code {
34
+ font-family: "Inconsolata", sans-serif;
35
+ font-size: 16px;
36
+ }
37
+
38
+ h1,
39
+ h1 code {
40
+ font-weight: 400;
41
+ line-height: calc(2.5 / var(--space) * var(--vspace));
42
+ }
43
+
44
+ h1 code {
45
+ background: none;
46
+ border: none;
47
+ letter-spacing: 0.05em;
48
+ padding-bottom: 5px;
49
+ position: relative;
50
+ padding: 0;
51
+ }
52
+
53
+ h2 {
54
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
55
+ line-height: 1em;
56
+ }
57
+
58
+ h3,
59
+ h3 code {
60
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
61
+ line-height: 1em;
62
+ }
63
+
64
+ h4,
65
+ h5,
66
+ h6 {
67
+ margin: var(--vspace-3) 0 var(--vspace-3) 0;
68
+ line-height: var(--vspace);
69
+ }
70
+
71
+ .bigtitle,
72
+ h1,
73
+ h1 code {
74
+ font-size: calc(8px * 4.5);
75
+ word-break: break-word;
76
+ }
77
+
78
+ .title,
79
+ h2,
80
+ h2 code {
81
+ font-size: calc(8px * 3.375);
82
+ font-weight: lighter;
83
+ word-break: break-word;
84
+ border: none;
85
+ background: none;
86
+ }
87
+
88
+ .subheading1,
89
+ h3,
90
+ h3 code {
91
+ font-size: calc(8px * 1.8);
92
+ font-weight: 600;
93
+ border: none;
94
+ background: none;
95
+ letter-spacing: 0.1em;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ h2 code {
100
+ padding: 0;
101
+ position: relative;
102
+ letter-spacing: 0.05em;
103
+ }
104
+
105
+ blockquote {
106
+ font-size: calc(8px * 1.1667);
107
+ font-style: italic;
108
+ line-height: calc(1.1667 * var(--vspace));
109
+ margin: var(--vspace-2) var(--vspace-2);
110
+ }
111
+
112
+ .subheading2,
113
+ h4 {
114
+ font-size: calc(8px * 1.4292);
115
+ text-transform: uppercase;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .subheading3,
120
+ h5 {
121
+ font-size: calc(8px * 1.2917);
122
+ line-height: calc(1.2917 * var(--vspace));
123
+
124
+ font-weight: lighter;
125
+ text-transform: uppercase;
126
+ letter-spacing: 0.15em;
127
+ }
128
+
129
+ h6 {
130
+ font-size: calc(8px * 1.1667);
131
+ font-size: 1.1667em;
132
+ font-weight: normal;
133
+ font-style: italic;
134
+ font-family: "le-monde-livre-classic-byol", serif !important;
135
+ letter-spacing: 0px !important;
136
+ }
137
+
138
+ #start .md > *:first-child {
139
+ margin-top: 0;
140
+ }
141
+
142
+ h2 + h3 {
143
+ margin-top: 0;
144
+ }
145
+
146
+ .md hr {
147
+ border: none;
148
+ border-top: 1px solid var(--block-border-color);
149
+ margin: var(--vspace-2) 0 var(--vspace-2) 0;
150
+ }
151
+ .prose ul {
152
+ margin: var(--vspace-2) 0 var(--vspace-1) 0;
153
+ }
154
+
155
+ .gap {
156
+ gap: 0;
157
+ }
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio_codeanalysisviewer
space.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from app import demo as app
4
+ import os
5
+
6
+ _docs = {'CodeAnalysisViewer': {'description': 'A custom Gradio component to display code analysis results in a structured format.\nIt expects a dictionary matching the OutputSchema structure as its value.', 'members': {'__init__': {'value': {'type': 'dict | Callable | None', 'default': 'None', 'description': 'default text to provide in textbox. If a function is provided, the function will be called each time the app loads to set the initial value of this component.'}, 'placeholder': {'type': 'str | None', 'default': 'None', 'description': 'placeholder hint to provide behind textbox.'}, 'label': {'type': 'str | I18nData | None', 'default': 'None', 'description': 'the label for this component, displayed above the component if `show_label` is `True` and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component corresponds to.'}, 'every': {'type': 'Timer | float | None', 'default': 'None', 'description': 'Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.'}, 'inputs': {'type': 'Component | Sequence[Component] | set[Component] | None', 'default': 'None', 'description': 'Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'key': {'type': 'int | str | tuple[int | str, ...] | None', 'default': 'None', 'description': "in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render."}, 'preserved_by_key': {'type': 'list[str] | str | None', 'default': '"value"', 'description': "A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor."}}, 'postprocess': {'value': {'type': 'dict | None', 'description': 'Expects a dictionary (OutputSchema) from the backend function.'}}, 'preprocess': {'return': {'type': 'dict | None', 'description': 'The payload to be used in the backend function.'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the CodeAnalysisViewer changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'input': {'type': None, 'default': None, 'description': 'This listener is triggered when the user changes the value of the CodeAnalysisViewer.'}, 'submit': {'type': None, 'default': None, 'description': 'This listener is triggered when the user presses the Enter key while the CodeAnalysisViewer is focused.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'CodeAnalysisViewer': []}}}
7
+
8
+ abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
+
10
+ with gr.Blocks(
11
+ css=abs_path,
12
+ theme=gr.themes.Default(
13
+ font_mono=[
14
+ gr.themes.GoogleFont("Inconsolata"),
15
+ "monospace",
16
+ ],
17
+ ),
18
+ ) as demo:
19
+ gr.Markdown(
20
+ """
21
+ # `gradio_codeanalysisviewer`
22
+
23
+ <div style="display: flex; gap: 7px;">
24
+ <a href="https://pypi.org/project/gradio_codeanalysisviewer/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_codeanalysisviewer"></a>
25
+ </div>
26
+
27
+ A nicer view to show the Agentic code analyser outputs
28
+ """, elem_classes=["md-custom"], header_links=True)
29
+ app.render()
30
+ gr.Markdown(
31
+ """
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gradio_codeanalysisviewer
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+
42
+ import gradio as gr
43
+ from gradio_codeanalysisviewer import CodeAnalysisViewer
44
+
45
+
46
+ # Prepare an example dictionary matching the OutputSchema structure
47
+ example_data = {
48
+ "code": "def greet(name):\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
49
+ "issue": "Security Risk: Use of f-string in print might be risky if 'name' is user-controlled and not sanitized.",
50
+ "reason": "Formatted string literals (f-strings) can be vulnerable to injection if they include unsanitized user input, though in this specific 'print' case, the direct risk is low unless the output is piped elsewhere or has special terminal interpretations.",
51
+ "fixed_code": "def greet(name):\n # Sanitize name if it comes from an external source, e.g., name = escape(name)\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
52
+ "feedback": "#### Security Feedback:\n* **Issue**: Potential for injection with f-string.\n* **Severity**: Low (in this context).\n* **Recommendation**: Always sanitize external inputs used in f-strings, especially if they are logged or displayed in sensitive contexts. For simple printing, the risk is minimal.\n\n#### Documentation Feedback:\n* The function `greet` is missing a docstring.\n* Consider adding type hints."
53
+ }
54
+
55
+ # Use the example_value from the component itself for the examples list
56
+ # This ensures we're using the structure defined within the component's backend
57
+ component_example = CodeAnalysisViewer().example_value()
58
+
59
+ demo = gr.Interface(
60
+ lambda data_dict: data_dict, # The function now expects and returns a dictionary
61
+ CodeAnalysisViewer(label="Input Analysis (Interactive - if it were input)"), # This would be for input, not our primary use case
62
+ CodeAnalysisViewer(label="Code Analysis Output"), # This is how we'll use it as an output display
63
+ examples=[[component_example], [example_data]] # Provide examples
64
+ )
65
+
66
+
67
+ if __name__ == "__main__":
68
+ demo.launch()
69
+
70
+ ```
71
+ """, elem_classes=["md-custom"], header_links=True)
72
+
73
+
74
+ gr.Markdown("""
75
+ ## `CodeAnalysisViewer`
76
+
77
+ ### Initialization
78
+ """, elem_classes=["md-custom"], header_links=True)
79
+
80
+ gr.ParamViewer(value=_docs["CodeAnalysisViewer"]["members"]["__init__"], linkify=[])
81
+
82
+
83
+ gr.Markdown("### Events")
84
+ gr.ParamViewer(value=_docs["CodeAnalysisViewer"]["events"], linkify=['Event'])
85
+
86
+
87
+
88
+
89
+ gr.Markdown("""
90
+
91
+ ### User function
92
+
93
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
94
+
95
+ - When used as an Input, the component only impacts the input signature of the user function.
96
+ - When used as an output, the component only impacts the return signature of the user function.
97
+
98
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
99
+
100
+ - **As input:** Is passed, the payload to be used in the backend function.
101
+ - **As output:** Should return, expects a dictionary (OutputSchema) from the backend function.
102
+
103
+ ```python
104
+ def predict(
105
+ value: dict | None
106
+ ) -> dict | None:
107
+ return value
108
+ ```
109
+ """, elem_classes=["md-custom", "CodeAnalysisViewer-user-fn"], header_links=True)
110
+
111
+
112
+
113
+
114
+ demo.load(None, js=r"""function() {
115
+ const refs = {};
116
+ const user_fn_refs = {
117
+ CodeAnalysisViewer: [], };
118
+ requestAnimationFrame(() => {
119
+
120
+ Object.entries(user_fn_refs).forEach(([key, refs]) => {
121
+ if (refs.length > 0) {
122
+ const el = document.querySelector(`.${key}-user-fn`);
123
+ if (!el) return;
124
+ refs.forEach(ref => {
125
+ el.innerHTML = el.innerHTML.replace(
126
+ new RegExp("\\b"+ref+"\\b", "g"),
127
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
128
+ );
129
+ })
130
+ }
131
+ })
132
+
133
+ Object.entries(refs).forEach(([key, refs]) => {
134
+ if (refs.length > 0) {
135
+ const el = document.querySelector(`.${key}`);
136
+ if (!el) return;
137
+ refs.forEach(ref => {
138
+ el.innerHTML = el.innerHTML.replace(
139
+ new RegExp("\\b"+ref+"\\b", "g"),
140
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
141
+ );
142
+ })
143
+ }
144
+ })
145
+ })
146
+ }
147
+
148
+ """)
149
+
150
+ demo.launch()
src/.DS_Store ADDED
Binary file (6.15 kB). View file
 
src/.gitignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .eggs/
2
+ dist/
3
+ *.pyc
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ __tmp/*
8
+ *.pyi
9
+ .mypycache
10
+ .ruff_cache
11
+ node_modules
12
+ backend/**/templates/
src/README.md ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags: [gradio-custom-component, SimpleTextbox, custom-component-track, agents, code-analysis, agents-mcp-hackathon]
3
+ title: gradio_codeanalysisviewer
4
+ short_description: A nicer view to show the Agentic code analyser outputs
5
+ colorFrom: blue
6
+ colorTo: yellow
7
+ sdk: gradio
8
+ pinned: false
9
+ app_file: space.py
10
+ ---
11
+
12
+ # `gradio_codeanalysisviewer`
13
+ <a href="https://pypi.org/project/gradio_codeanalysisviewer/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_codeanalysisviewer"></a>
14
+
15
+ A nicer view to show the Agentic code analyser outputs
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install gradio_codeanalysisviewer
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```python
26
+
27
+ import gradio as gr
28
+ from gradio_codeanalysisviewer import CodeAnalysisViewer
29
+
30
+
31
+ # Prepare an example dictionary matching the OutputSchema structure
32
+ example_data = {
33
+ "code": "def greet(name):\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
34
+ "issue": "Security Risk: Use of f-string in print might be risky if 'name' is user-controlled and not sanitized.",
35
+ "reason": "Formatted string literals (f-strings) can be vulnerable to injection if they include unsanitized user input, though in this specific 'print' case, the direct risk is low unless the output is piped elsewhere or has special terminal interpretations.",
36
+ "fixed_code": "def greet(name):\n # Sanitize name if it comes from an external source, e.g., name = escape(name)\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
37
+ "feedback": "#### Security Feedback:\n* **Issue**: Potential for injection with f-string.\n* **Severity**: Low (in this context).\n* **Recommendation**: Always sanitize external inputs used in f-strings, especially if they are logged or displayed in sensitive contexts. For simple printing, the risk is minimal.\n\n#### Documentation Feedback:\n* The function `greet` is missing a docstring.\n* Consider adding type hints."
38
+ }
39
+
40
+ # Use the example_value from the component itself for the examples list
41
+ # This ensures we're using the structure defined within the component's backend
42
+ component_example = CodeAnalysisViewer().example_value()
43
+
44
+ demo = gr.Interface(
45
+ lambda data_dict: data_dict, # The function now expects and returns a dictionary
46
+ CodeAnalysisViewer(label="Input Analysis (Interactive - if it were input)"), # This would be for input, not our primary use case
47
+ CodeAnalysisViewer(label="Code Analysis Output"), # This is how we'll use it as an output display
48
+ examples=[[component_example], [example_data]] # Provide examples
49
+ )
50
+
51
+
52
+ if __name__ == "__main__":
53
+ demo.launch()
54
+
55
+ ```
56
+
57
+ ## `CodeAnalysisViewer`
58
+
59
+ ### Initialization
60
+
61
+ <table>
62
+ <thead>
63
+ <tr>
64
+ <th align="left">name</th>
65
+ <th align="left" style="width: 25%;">type</th>
66
+ <th align="left">default</th>
67
+ <th align="left">description</th>
68
+ </tr>
69
+ </thead>
70
+ <tbody>
71
+ <tr>
72
+ <td align="left"><code>value</code></td>
73
+ <td align="left" style="width: 25%;">
74
+
75
+ ```python
76
+ dict | Callable | None
77
+ ```
78
+
79
+ </td>
80
+ <td align="left"><code>None</code></td>
81
+ <td align="left">default text to provide in textbox. If a function is provided, the function will be called each time the app loads to set the initial value of this component.</td>
82
+ </tr>
83
+
84
+ <tr>
85
+ <td align="left"><code>placeholder</code></td>
86
+ <td align="left" style="width: 25%;">
87
+
88
+ ```python
89
+ str | None
90
+ ```
91
+
92
+ </td>
93
+ <td align="left"><code>None</code></td>
94
+ <td align="left">placeholder hint to provide behind textbox.</td>
95
+ </tr>
96
+
97
+ <tr>
98
+ <td align="left"><code>label</code></td>
99
+ <td align="left" style="width: 25%;">
100
+
101
+ ```python
102
+ str | I18nData | None
103
+ ```
104
+
105
+ </td>
106
+ <td align="left"><code>None</code></td>
107
+ <td align="left">the label for this component, displayed above the component if `show_label` is `True` and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component corresponds to.</td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <td align="left"><code>every</code></td>
112
+ <td align="left" style="width: 25%;">
113
+
114
+ ```python
115
+ Timer | float | None
116
+ ```
117
+
118
+ </td>
119
+ <td align="left"><code>None</code></td>
120
+ <td align="left">Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.</td>
121
+ </tr>
122
+
123
+ <tr>
124
+ <td align="left"><code>inputs</code></td>
125
+ <td align="left" style="width: 25%;">
126
+
127
+ ```python
128
+ Component | Sequence[Component] | set[Component] | None
129
+ ```
130
+
131
+ </td>
132
+ <td align="left"><code>None</code></td>
133
+ <td align="left">Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.</td>
134
+ </tr>
135
+
136
+ <tr>
137
+ <td align="left"><code>show_label</code></td>
138
+ <td align="left" style="width: 25%;">
139
+
140
+ ```python
141
+ bool | None
142
+ ```
143
+
144
+ </td>
145
+ <td align="left"><code>None</code></td>
146
+ <td align="left">if True, will display label.</td>
147
+ </tr>
148
+
149
+ <tr>
150
+ <td align="left"><code>scale</code></td>
151
+ <td align="left" style="width: 25%;">
152
+
153
+ ```python
154
+ int | None
155
+ ```
156
+
157
+ </td>
158
+ <td align="left"><code>None</code></td>
159
+ <td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
160
+ </tr>
161
+
162
+ <tr>
163
+ <td align="left"><code>min_width</code></td>
164
+ <td align="left" style="width: 25%;">
165
+
166
+ ```python
167
+ int
168
+ ```
169
+
170
+ </td>
171
+ <td align="left"><code>160</code></td>
172
+ <td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
173
+ </tr>
174
+
175
+ <tr>
176
+ <td align="left"><code>interactive</code></td>
177
+ <td align="left" style="width: 25%;">
178
+
179
+ ```python
180
+ bool | None
181
+ ```
182
+
183
+ </td>
184
+ <td align="left"><code>None</code></td>
185
+ <td align="left">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>
186
+ </tr>
187
+
188
+ <tr>
189
+ <td align="left"><code>visible</code></td>
190
+ <td align="left" style="width: 25%;">
191
+
192
+ ```python
193
+ bool
194
+ ```
195
+
196
+ </td>
197
+ <td align="left"><code>True</code></td>
198
+ <td align="left">If False, component will be hidden.</td>
199
+ </tr>
200
+
201
+ <tr>
202
+ <td align="left"><code>rtl</code></td>
203
+ <td align="left" style="width: 25%;">
204
+
205
+ ```python
206
+ bool
207
+ ```
208
+
209
+ </td>
210
+ <td align="left"><code>False</code></td>
211
+ <td align="left">If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.</td>
212
+ </tr>
213
+
214
+ <tr>
215
+ <td align="left"><code>elem_id</code></td>
216
+ <td align="left" style="width: 25%;">
217
+
218
+ ```python
219
+ str | None
220
+ ```
221
+
222
+ </td>
223
+ <td align="left"><code>None</code></td>
224
+ <td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
225
+ </tr>
226
+
227
+ <tr>
228
+ <td align="left"><code>elem_classes</code></td>
229
+ <td align="left" style="width: 25%;">
230
+
231
+ ```python
232
+ list[str] | str | None
233
+ ```
234
+
235
+ </td>
236
+ <td align="left"><code>None</code></td>
237
+ <td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
238
+ </tr>
239
+
240
+ <tr>
241
+ <td align="left"><code>render</code></td>
242
+ <td align="left" style="width: 25%;">
243
+
244
+ ```python
245
+ bool
246
+ ```
247
+
248
+ </td>
249
+ <td align="left"><code>True</code></td>
250
+ <td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
251
+ </tr>
252
+
253
+ <tr>
254
+ <td align="left"><code>key</code></td>
255
+ <td align="left" style="width: 25%;">
256
+
257
+ ```python
258
+ int | str | tuple[int | str, ...] | None
259
+ ```
260
+
261
+ </td>
262
+ <td align="left"><code>None</code></td>
263
+ <td align="left">in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render.</td>
264
+ </tr>
265
+
266
+ <tr>
267
+ <td align="left"><code>preserved_by_key</code></td>
268
+ <td align="left" style="width: 25%;">
269
+
270
+ ```python
271
+ list[str] | str | None
272
+ ```
273
+
274
+ </td>
275
+ <td align="left"><code>"value"</code></td>
276
+ <td align="left">A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor.</td>
277
+ </tr>
278
+ </tbody></table>
279
+
280
+
281
+ ### Events
282
+
283
+ | name | description |
284
+ |:-----|:------------|
285
+ | `change` | Triggered when the value of the CodeAnalysisViewer changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
286
+ | `input` | This listener is triggered when the user changes the value of the CodeAnalysisViewer. |
287
+ | `submit` | This listener is triggered when the user presses the Enter key while the CodeAnalysisViewer is focused. |
288
+
289
+
290
+
291
+ ### User function
292
+
293
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
294
+
295
+ - When used as an Input, the component only impacts the input signature of the user function.
296
+ - When used as an output, the component only impacts the return signature of the user function.
297
+
298
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
299
+
300
+ - **As output:** Is passed, the payload to be used in the backend function.
301
+ - **As input:** Should return, expects a dictionary (OutputSchema) from the backend function.
302
+
303
+ ```python
304
+ def predict(
305
+ value: dict | None
306
+ ) -> dict | None:
307
+ return value
308
+ ```
309
+
src/backend/gradio_codeanalysisviewer/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ from .codeanalysisviewer import CodeAnalysisViewer
3
+
4
+ __all__ = ['CodeAnalysisViewer']
src/backend/gradio_codeanalysisviewer/codeanalysisviewer.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable, Sequence
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ from gradio.components.base import Component, FormComponent
7
+ from gradio.events import Events
8
+ from gradio.i18n import I18nData
9
+
10
+ if TYPE_CHECKING:
11
+ from gradio.components import Timer
12
+
13
+
14
+ class CodeAnalysisViewer(FormComponent):
15
+ """
16
+ A custom Gradio component to display code analysis results in a structured format.
17
+ It expects a dictionary matching the OutputSchema structure as its value.
18
+ """
19
+
20
+ EVENTS = [
21
+ Events.change,
22
+ Events.input,
23
+ Events.submit,
24
+ ]
25
+
26
+ def __init__(
27
+ self,
28
+ value: dict | Callable | None = None, # Expects a dict (OutputSchema)
29
+ *,
30
+ placeholder: str | None = None,
31
+ label: str | I18nData | None = None,
32
+ every: Timer | float | None = None,
33
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
34
+ show_label: bool | None = None,
35
+ scale: int | None = None,
36
+ min_width: int = 160,
37
+ interactive: bool | None = None,
38
+ visible: bool = True,
39
+ rtl: bool = False,
40
+ elem_id: str | None = None,
41
+ elem_classes: list[str] | str | None = None,
42
+ render: bool = True,
43
+ key: int | str | tuple[int | str, ...] | None = None,
44
+ preserved_by_key: list[str] | str | None = "value",
45
+ ):
46
+ """
47
+ Parameters:
48
+ value: default text to provide in textbox. If a function is provided, the function will be called each time the app loads to set the initial value of this component.
49
+ placeholder: placeholder hint to provide behind textbox.
50
+ label: the label for this component, displayed above the component if `show_label` is `True` and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component corresponds to.
51
+ every: Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
52
+ inputs: Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.
53
+ show_label: if True, will display label.
54
+ scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
55
+ min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
56
+ interactive: if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.
57
+ visible: If False, component will be hidden.
58
+ rtl: If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.
59
+ elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
60
+ elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
61
+ render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
62
+ key: in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render.
63
+ preserved_by_key: A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor.
64
+ """
65
+ self.placeholder = placeholder
66
+ self.rtl = rtl
67
+ super().__init__(
68
+ label=label,
69
+ every=every,
70
+ inputs=inputs,
71
+ show_label=show_label,
72
+ scale=scale,
73
+ min_width=min_width,
74
+ interactive=interactive,
75
+ visible=visible,
76
+ elem_id=elem_id,
77
+ elem_classes=elem_classes,
78
+ value=value,
79
+ render=render,
80
+ key=key,
81
+ preserved_by_key=preserved_by_key,
82
+ )
83
+
84
+ def preprocess(self, payload: dict | None) -> dict | None:
85
+ """
86
+ Parameters:
87
+ payload: The data received from the frontend (not typically used for an output-only component).
88
+ Returns:
89
+ The payload to be used in the backend function.
90
+ """
91
+ # For a display-only component, preprocess might not be critical
92
+ # but if it were interactive, it would convert frontend data to backend format.
93
+ return payload
94
+
95
+ def postprocess(self, value: dict | None) -> dict | None:
96
+ """
97
+ Parameters:
98
+ value: Expects a dictionary (OutputSchema) from the backend function.
99
+ Returns:
100
+ The dictionary to be passed to the Svelte frontend component.
101
+ """
102
+ # Gradio handles Python dict to JS object conversion automatically
103
+ return value
104
+
105
+ def api_info(self) -> dict[str, Any]:
106
+ # Describes the data structure for the API
107
+ return {
108
+ "type": "object",
109
+ "properties": {
110
+ "code": {"type": "string"},
111
+ "issue": {"type": "string"},
112
+ "reason": {"type": "string"},
113
+ "fixed_code": {"type": "string"},
114
+ "feedback": {"type": "string"}
115
+ }
116
+ }
117
+
118
+ def example_payload(self) -> Any:
119
+ # This would be relevant if the component was an input
120
+ return {
121
+ "code": "def example():\n pass",
122
+ "issue": "Sample Issue from Payload",
123
+ "reason": "This is a sample reason from payload.",
124
+ "fixed_code": "def example():\n # Fixed code\n pass",
125
+ "feedback": "Sample feedback from payload."
126
+ }
127
+
128
+ def example_value(self) -> Any:
129
+ # This is what's shown as an example in the Gradio UI
130
+ return {
131
+ "code": "def hello_world():\n print(\"Hello World\")\n\n# This is a comment",
132
+ "issue": "D100: Missing docstring in public module",
133
+ "reason": "All modules should normally have docstrings (PEP 257).",
134
+ "fixed_code": "\"\"\"This module demonstrates a simple function.\"\"\"\ndef hello_world():\n \"\"\"Prints a greeting.\"\"\"\n print(\"Hello World\")\n\n# This is a comment",
135
+ "feedback": "### Docstring Analysis\n- The module is missing a docstring.\n- The function `hello_world` is missing a docstring.\n\n**Recommendation:** Add appropriate docstrings to improve code maintainability and understanding. See [PEP 257](https://peps.python.org/pep-0257/) for guidelines."
136
+ }
src/backend/gradio_codeanalysisviewer/templates/component/index.js ADDED
@@ -0,0 +1,2274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var bt = Object.defineProperty;
2
+ var xt = (n, e, t) => e in n ? bt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var v = (n, e, t) => xt(n, typeof e != "symbol" ? e + "" : e, t);
4
+ function V() {
5
+ }
6
+ V.prototype = {
7
+ diff: function(e, t) {
8
+ var s, i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r = i.callback;
9
+ typeof i == "function" && (r = i, i = {}), this.options = i;
10
+ var c = this;
11
+ function l(R) {
12
+ return r ? (setTimeout(function() {
13
+ r(void 0, R);
14
+ }, 0), !0) : R;
15
+ }
16
+ e = this.castInput(e), t = this.castInput(t), e = this.removeEmpty(this.tokenize(e)), t = this.removeEmpty(this.tokenize(t));
17
+ var u = t.length, a = e.length, o = 1, p = u + a;
18
+ i.maxEditLength && (p = Math.min(p, i.maxEditLength));
19
+ var h = (s = i.timeout) !== null && s !== void 0 ? s : 1 / 0, d = Date.now() + h, f = [{
20
+ oldPos: -1,
21
+ lastComponent: void 0
22
+ }], k = this.extractCommon(f[0], t, e, 0);
23
+ if (f[0].oldPos + 1 >= a && k + 1 >= u)
24
+ return l([{
25
+ value: this.join(t),
26
+ count: t.length
27
+ }]);
28
+ var g = -1 / 0, I = 1 / 0;
29
+ function E() {
30
+ for (var R = Math.max(g, -o); R <= Math.min(I, o); R += 2) {
31
+ var q = void 0, $ = f[R - 1], z = f[R + 1];
32
+ $ && (f[R - 1] = void 0);
33
+ var j = !1;
34
+ if (z) {
35
+ var W = z.oldPos - R;
36
+ j = z && 0 <= W && W < u;
37
+ }
38
+ var H = $ && $.oldPos + 1 < a;
39
+ if (!j && !H) {
40
+ f[R] = void 0;
41
+ continue;
42
+ }
43
+ if (!H || j && $.oldPos + 1 < z.oldPos ? q = c.addToPath(z, !0, void 0, 0) : q = c.addToPath($, void 0, !0, 1), k = c.extractCommon(q, t, e, R), q.oldPos + 1 >= a && k + 1 >= u)
44
+ return l(wt(c, q.lastComponent, t, e, c.useLongestToken));
45
+ f[R] = q, q.oldPos + 1 >= a && (I = Math.min(I, R - 1)), k + 1 >= u && (g = Math.max(g, R + 1));
46
+ }
47
+ o++;
48
+ }
49
+ if (r)
50
+ (function R() {
51
+ setTimeout(function() {
52
+ if (o > p || Date.now() > d)
53
+ return r();
54
+ E() || R();
55
+ }, 0);
56
+ })();
57
+ else
58
+ for (; o <= p && Date.now() <= d; ) {
59
+ var B = E();
60
+ if (B)
61
+ return B;
62
+ }
63
+ },
64
+ addToPath: function(e, t, s, i) {
65
+ var r = e.lastComponent;
66
+ return r && r.added === t && r.removed === s ? {
67
+ oldPos: e.oldPos + i,
68
+ lastComponent: {
69
+ count: r.count + 1,
70
+ added: t,
71
+ removed: s,
72
+ previousComponent: r.previousComponent
73
+ }
74
+ } : {
75
+ oldPos: e.oldPos + i,
76
+ lastComponent: {
77
+ count: 1,
78
+ added: t,
79
+ removed: s,
80
+ previousComponent: r
81
+ }
82
+ };
83
+ },
84
+ extractCommon: function(e, t, s, i) {
85
+ for (var r = t.length, c = s.length, l = e.oldPos, u = l - i, a = 0; u + 1 < r && l + 1 < c && this.equals(t[u + 1], s[l + 1]); )
86
+ u++, l++, a++;
87
+ return a && (e.lastComponent = {
88
+ count: a,
89
+ previousComponent: e.lastComponent
90
+ }), e.oldPos = l, u;
91
+ },
92
+ equals: function(e, t) {
93
+ return this.options.comparator ? this.options.comparator(e, t) : e === t || this.options.ignoreCase && e.toLowerCase() === t.toLowerCase();
94
+ },
95
+ removeEmpty: function(e) {
96
+ for (var t = [], s = 0; s < e.length; s++)
97
+ e[s] && t.push(e[s]);
98
+ return t;
99
+ },
100
+ castInput: function(e) {
101
+ return e;
102
+ },
103
+ tokenize: function(e) {
104
+ return e.split("");
105
+ },
106
+ join: function(e) {
107
+ return e.join("");
108
+ }
109
+ };
110
+ function wt(n, e, t, s, i) {
111
+ for (var r = [], c; e; )
112
+ r.push(e), c = e.previousComponent, delete e.previousComponent, e = c;
113
+ r.reverse();
114
+ for (var l = 0, u = r.length, a = 0, o = 0; l < u; l++) {
115
+ var p = r[l];
116
+ if (p.removed) {
117
+ if (p.value = n.join(s.slice(o, o + p.count)), o += p.count, l && r[l - 1].added) {
118
+ var d = r[l - 1];
119
+ r[l - 1] = r[l], r[l] = d;
120
+ }
121
+ } else {
122
+ if (!p.added && i) {
123
+ var h = t.slice(a, a + p.count);
124
+ h = h.map(function(k, g) {
125
+ var I = s[o + g];
126
+ return I.length > k.length ? I : k;
127
+ }), p.value = n.join(h);
128
+ } else
129
+ p.value = n.join(t.slice(a, a + p.count));
130
+ a += p.count, p.added || (o += p.count);
131
+ }
132
+ }
133
+ var f = r[u - 1];
134
+ return u > 1 && typeof f.value == "string" && (f.added || f.removed) && n.equals("", f.value) && (r[u - 2].value += f.value, r.pop()), r;
135
+ }
136
+ var vt = new V();
137
+ function _t(n, e, t) {
138
+ return vt.diff(n, e, t);
139
+ }
140
+ var Ve = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/, je = /\S/, rt = new V();
141
+ rt.equals = function(n, e) {
142
+ return this.options.ignoreCase && (n = n.toLowerCase(), e = e.toLowerCase()), n === e || this.options.ignoreWhitespace && !je.test(n) && !je.test(e);
143
+ };
144
+ rt.tokenize = function(n) {
145
+ for (var e = n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/), t = 0; t < e.length - 1; t++)
146
+ !e[t + 1] && e[t + 2] && Ve.test(e[t]) && Ve.test(e[t + 2]) && (e[t] += e[t + 2], e.splice(t + 1, 2), t--);
147
+ return e;
148
+ };
149
+ var lt = new V();
150
+ lt.tokenize = function(n) {
151
+ this.options.stripTrailingCr && (n = n.replace(/\r\n/g, `
152
+ `));
153
+ var e = [], t = n.split(/(\n|\r\n)/);
154
+ t[t.length - 1] || t.pop();
155
+ for (var s = 0; s < t.length; s++) {
156
+ var i = t[s];
157
+ s % 2 && !this.options.newlineIsToken ? e[e.length - 1] += i : (this.options.ignoreWhitespace && (i = i.trim()), e.push(i));
158
+ }
159
+ return e;
160
+ };
161
+ var yt = new V();
162
+ yt.tokenize = function(n) {
163
+ return n.split(/(\S.+?[.!?])(?=\s+|$)/);
164
+ };
165
+ var Rt = new V();
166
+ Rt.tokenize = function(n) {
167
+ return n.split(/([{}:;,]|\s+)/);
168
+ };
169
+ function ke(n) {
170
+ "@babel/helpers - typeof";
171
+ return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? ke = function(e) {
172
+ return typeof e;
173
+ } : ke = function(e) {
174
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
175
+ }, ke(n);
176
+ }
177
+ var Ct = Object.prototype.toString, oe = new V();
178
+ oe.useLongestToken = !0;
179
+ oe.tokenize = lt.tokenize;
180
+ oe.castInput = function(n) {
181
+ var e = this.options, t = e.undefinedReplacement, s = e.stringifyReplacer, i = s === void 0 ? function(r, c) {
182
+ return typeof c > "u" ? t : c;
183
+ } : s;
184
+ return typeof n == "string" ? n : JSON.stringify(Ce(n, null, null, i), i, " ");
185
+ };
186
+ oe.equals = function(n, e) {
187
+ return V.prototype.equals.call(oe, n.replace(/,([\r\n])/g, "$1"), e.replace(/,([\r\n])/g, "$1"));
188
+ };
189
+ function Ce(n, e, t, s, i) {
190
+ e = e || [], t = t || [], s && (n = s(i, n));
191
+ var r;
192
+ for (r = 0; r < e.length; r += 1)
193
+ if (e[r] === n)
194
+ return t[r];
195
+ var c;
196
+ if (Ct.call(n) === "[object Array]") {
197
+ for (e.push(n), c = new Array(n.length), t.push(c), r = 0; r < n.length; r += 1)
198
+ c[r] = Ce(n[r], e, t, s, i);
199
+ return e.pop(), t.pop(), c;
200
+ }
201
+ if (n && n.toJSON && (n = n.toJSON()), ke(n) === "object" && n !== null) {
202
+ e.push(n), c = {}, t.push(c);
203
+ var l = [], u;
204
+ for (u in n)
205
+ n.hasOwnProperty(u) && l.push(u);
206
+ for (l.sort(), r = 0; r < l.length; r += 1)
207
+ u = l[r], c[u] = Ce(n[u], e, t, s, u);
208
+ e.pop(), t.pop();
209
+ } else
210
+ c = n;
211
+ return c;
212
+ }
213
+ var Te = new V();
214
+ Te.tokenize = function(n) {
215
+ return n.slice();
216
+ };
217
+ Te.join = Te.removeEmpty = function(n) {
218
+ return n;
219
+ };
220
+ function Le() {
221
+ return {
222
+ async: !1,
223
+ breaks: !1,
224
+ extensions: null,
225
+ gfm: !0,
226
+ hooks: null,
227
+ pedantic: !1,
228
+ renderer: null,
229
+ silent: !1,
230
+ tokenizer: null,
231
+ walkTokens: null
232
+ };
233
+ }
234
+ var X = Le();
235
+ function at(n) {
236
+ X = n;
237
+ }
238
+ var ae = { exec: () => null };
239
+ function w(n, e = "") {
240
+ let t = typeof n == "string" ? n : n.source;
241
+ const s = {
242
+ replace: (i, r) => {
243
+ let c = typeof r == "string" ? r : r.source;
244
+ return c = c.replace(P.caret, "$1"), t = t.replace(i, c), s;
245
+ },
246
+ getRegex: () => new RegExp(t, e)
247
+ };
248
+ return s;
249
+ }
250
+ var P = {
251
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
252
+ outputLinkReplace: /\\([\[\]])/g,
253
+ indentCodeCompensation: /^(\s+)(?:```)/,
254
+ beginningSpace: /^\s+/,
255
+ endingHash: /#$/,
256
+ startingSpaceChar: /^ /,
257
+ endingSpaceChar: / $/,
258
+ nonSpaceChar: /[^ ]/,
259
+ newLineCharGlobal: /\n/g,
260
+ tabCharGlobal: /\t/g,
261
+ multipleSpaceGlobal: /\s+/g,
262
+ blankLine: /^[ \t]*$/,
263
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
264
+ blockquoteStart: /^ {0,3}>/,
265
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
266
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
267
+ listReplaceTabs: /^\t+/,
268
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
269
+ listIsTask: /^\[[ xX]\] /,
270
+ listReplaceTask: /^\[[ xX]\] +/,
271
+ anyLine: /\n.*\n/,
272
+ hrefBrackets: /^<(.*)>$/,
273
+ tableDelimiter: /[:|]/,
274
+ tableAlignChars: /^\||\| *$/g,
275
+ tableRowBlankLine: /\n[ \t]*$/,
276
+ tableAlignRight: /^ *-+: *$/,
277
+ tableAlignCenter: /^ *:-+: *$/,
278
+ tableAlignLeft: /^ *:-+ *$/,
279
+ startATag: /^<a /i,
280
+ endATag: /^<\/a>/i,
281
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
282
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
283
+ startAngleBracket: /^</,
284
+ endAngleBracket: />$/,
285
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
286
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
287
+ escapeTest: /[&<>"']/,
288
+ escapeReplace: /[&<>"']/g,
289
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
290
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
291
+ unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
292
+ caret: /(^|[^\[])\^/g,
293
+ percentDecode: /%25/g,
294
+ findPipe: /\|/g,
295
+ splitPipe: / \|/,
296
+ slashPipe: /\\\|/g,
297
+ carriageReturn: /\r\n|\r/g,
298
+ spaceLine: /^ +$/gm,
299
+ notSpaceStart: /^\S*/,
300
+ endingNewline: /\n$/,
301
+ listItemRegex: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),
302
+ nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
303
+ hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
304
+ fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`),
305
+ headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`),
306
+ htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i")
307
+ }, Tt = /^(?:[ \t]*(?:\n|$))+/, St = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, zt = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, ce = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, $t = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Ie = /(?:[*+-]|\d{1,9}[.)])/, ot = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ct = w(ot).replace(/bull/g, Ie).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).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/).replace(/\|table/g, "").getRegex(), At = w(ot).replace(/bull/g, Ie).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).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/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), Ee = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Lt = /^[^\n]+/, Pe = /(?!\s*\])(?:\\.|[^\[\]\\])+/, It = w(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Pe).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Et = w(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Ie).getRegex(), ve = "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", De = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Pt = w(
308
+ "^ {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|$))",
309
+ "i"
310
+ ).replace("comment", De).replace("tag", ve).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), ut = w(Ee).replace("hr", ce).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", ve).getRegex(), Dt = w(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ut).getRegex(), Be = {
311
+ blockquote: Dt,
312
+ code: St,
313
+ def: It,
314
+ fences: zt,
315
+ heading: $t,
316
+ hr: ce,
317
+ html: Pt,
318
+ lheading: ct,
319
+ list: Et,
320
+ newline: Tt,
321
+ paragraph: ut,
322
+ table: ae,
323
+ text: Lt
324
+ }, We = w(
325
+ "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
326
+ ).replace("hr", ce).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\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", ve).getRegex(), Bt = {
327
+ ...Be,
328
+ lheading: At,
329
+ table: We,
330
+ paragraph: w(Ee).replace("hr", ce).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", We).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", ve).getRegex()
331
+ }, qt = {
332
+ ...Be,
333
+ html: w(
334
+ `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
335
+ ).replace("comment", De).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(),
336
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
337
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
338
+ fences: ae,
339
+ // fences not supported
340
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
341
+ paragraph: w(Ee).replace("hr", ce).replace("heading", ` *#{1,6} *[^
342
+ ]`).replace("lheading", ct).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
343
+ }, Nt = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ot = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ht = /^( {2,}|\\)\n(?!\s*$)/, Zt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, _e = /[\p{P}\p{S}]/u, qe = /[\s\p{P}\p{S}]/u, pt = /[^\s\p{P}\p{S}]/u, Mt = w(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, qe).getRegex(), ft = /(?!~)[\p{P}\p{S}]/u, Ht = /(?!~)[\s\p{P}\p{S}]/u, Gt = /(?:[^\s\p{P}\p{S}]|~)/u, Ft = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, dt = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Qt = w(dt, "u").replace(/punct/g, _e).getRegex(), Vt = w(dt, "u").replace(/punct/g, ft).getRegex(), gt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", jt = w(gt, "gu").replace(/notPunctSpace/g, pt).replace(/punctSpace/g, qe).replace(/punct/g, _e).getRegex(), Wt = w(gt, "gu").replace(/notPunctSpace/g, Gt).replace(/punctSpace/g, Ht).replace(/punct/g, ft).getRegex(), Ut = w(
344
+ "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
345
+ "gu"
346
+ ).replace(/notPunctSpace/g, pt).replace(/punctSpace/g, qe).replace(/punct/g, _e).getRegex(), Xt = w(/\\(punct)/, "gu").replace(/punct/g, _e).getRegex(), Jt = w(/^<(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(), Yt = w(De).replace("(?:-->|$)", "-->").getRegex(), Kt = w(
347
+ "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
348
+ ).replace("comment", Yt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), be = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, en = w(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", be).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), kt = w(/^!?\[(label)\]\[(ref)\]/).replace("label", be).replace("ref", Pe).getRegex(), mt = w(/^!?\[(ref)\](?:\[\])?/).replace("ref", Pe).getRegex(), tn = w("reflink|nolink(?!\\()", "g").replace("reflink", kt).replace("nolink", mt).getRegex(), Ne = {
349
+ _backpedal: ae,
350
+ // only used for GFM url
351
+ anyPunctuation: Xt,
352
+ autolink: Jt,
353
+ blockSkip: Ft,
354
+ br: ht,
355
+ code: Ot,
356
+ del: ae,
357
+ emStrongLDelim: Qt,
358
+ emStrongRDelimAst: jt,
359
+ emStrongRDelimUnd: Ut,
360
+ escape: Nt,
361
+ link: en,
362
+ nolink: mt,
363
+ punctuation: Mt,
364
+ reflink: kt,
365
+ reflinkSearch: tn,
366
+ tag: Kt,
367
+ text: Zt,
368
+ url: ae
369
+ }, nn = {
370
+ ...Ne,
371
+ link: w(/^!?\[(label)\]\((.*?)\)/).replace("label", be).getRegex(),
372
+ reflink: w(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", be).getRegex()
373
+ }, Se = {
374
+ ...Ne,
375
+ emStrongRDelimAst: Wt,
376
+ emStrongLDelim: Vt,
377
+ url: w(/^((?: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(),
378
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
379
+ del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
380
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
381
+ }, sn = {
382
+ ...Se,
383
+ br: w(ht).replace("{2,}", "*").getRegex(),
384
+ text: w(Se.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
385
+ }, de = {
386
+ normal: Be,
387
+ gfm: Bt,
388
+ pedantic: qt
389
+ }, re = {
390
+ normal: Ne,
391
+ gfm: Se,
392
+ breaks: sn,
393
+ pedantic: nn
394
+ }, rn = {
395
+ "&": "&amp;",
396
+ "<": "&lt;",
397
+ ">": "&gt;",
398
+ '"': "&quot;",
399
+ "'": "&#39;"
400
+ }, Ue = (n) => rn[n];
401
+ function M(n, e) {
402
+ if (e) {
403
+ if (P.escapeTest.test(n))
404
+ return n.replace(P.escapeReplace, Ue);
405
+ } else if (P.escapeTestNoEncode.test(n))
406
+ return n.replace(P.escapeReplaceNoEncode, Ue);
407
+ return n;
408
+ }
409
+ function Xe(n) {
410
+ try {
411
+ n = encodeURI(n).replace(P.percentDecode, "%");
412
+ } catch {
413
+ return null;
414
+ }
415
+ return n;
416
+ }
417
+ function Je(n, e) {
418
+ var r;
419
+ const t = n.replace(P.findPipe, (c, l, u) => {
420
+ let a = !1, o = l;
421
+ for (; --o >= 0 && u[o] === "\\"; ) a = !a;
422
+ return a ? "|" : " |";
423
+ }), s = t.split(P.splitPipe);
424
+ let i = 0;
425
+ if (s[0].trim() || s.shift(), s.length > 0 && !((r = s.at(-1)) != null && r.trim()) && s.pop(), e)
426
+ if (s.length > e)
427
+ s.splice(e);
428
+ else
429
+ for (; s.length < e; ) s.push("");
430
+ for (; i < s.length; i++)
431
+ s[i] = s[i].trim().replace(P.slashPipe, "|");
432
+ return s;
433
+ }
434
+ function le(n, e, t) {
435
+ const s = n.length;
436
+ if (s === 0)
437
+ return "";
438
+ let i = 0;
439
+ for (; i < s && n.charAt(s - i - 1) === e; )
440
+ i++;
441
+ return n.slice(0, s - i);
442
+ }
443
+ function ln(n, e) {
444
+ if (n.indexOf(e[1]) === -1)
445
+ return -1;
446
+ let t = 0;
447
+ for (let s = 0; s < n.length; s++)
448
+ if (n[s] === "\\")
449
+ s++;
450
+ else if (n[s] === e[0])
451
+ t++;
452
+ else if (n[s] === e[1] && (t--, t < 0))
453
+ return s;
454
+ return t > 0 ? -2 : -1;
455
+ }
456
+ function Ye(n, e, t, s, i) {
457
+ const r = e.href, c = e.title || null, l = n[1].replace(i.other.outputLinkReplace, "$1");
458
+ s.state.inLink = !0;
459
+ const u = {
460
+ type: n[0].charAt(0) === "!" ? "image" : "link",
461
+ raw: t,
462
+ href: r,
463
+ title: c,
464
+ text: l,
465
+ tokens: s.inlineTokens(l)
466
+ };
467
+ return s.state.inLink = !1, u;
468
+ }
469
+ function an(n, e, t) {
470
+ const s = n.match(t.other.indentCodeCompensation);
471
+ if (s === null)
472
+ return e;
473
+ const i = s[1];
474
+ return e.split(`
475
+ `).map((r) => {
476
+ const c = r.match(t.other.beginningSpace);
477
+ if (c === null)
478
+ return r;
479
+ const [l] = c;
480
+ return l.length >= i.length ? r.slice(i.length) : r;
481
+ }).join(`
482
+ `);
483
+ }
484
+ var xe = class {
485
+ // set by the lexer
486
+ constructor(n) {
487
+ v(this, "options");
488
+ v(this, "rules");
489
+ // set by the lexer
490
+ v(this, "lexer");
491
+ this.options = n || X;
492
+ }
493
+ space(n) {
494
+ const e = this.rules.block.newline.exec(n);
495
+ if (e && e[0].length > 0)
496
+ return {
497
+ type: "space",
498
+ raw: e[0]
499
+ };
500
+ }
501
+ code(n) {
502
+ const e = this.rules.block.code.exec(n);
503
+ if (e) {
504
+ const t = e[0].replace(this.rules.other.codeRemoveIndent, "");
505
+ return {
506
+ type: "code",
507
+ raw: e[0],
508
+ codeBlockStyle: "indented",
509
+ text: this.options.pedantic ? t : le(t, `
510
+ `)
511
+ };
512
+ }
513
+ }
514
+ fences(n) {
515
+ const e = this.rules.block.fences.exec(n);
516
+ if (e) {
517
+ const t = e[0], s = an(t, e[3] || "", this.rules);
518
+ return {
519
+ type: "code",
520
+ raw: t,
521
+ lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
522
+ text: s
523
+ };
524
+ }
525
+ }
526
+ heading(n) {
527
+ const e = this.rules.block.heading.exec(n);
528
+ if (e) {
529
+ let t = e[2].trim();
530
+ if (this.rules.other.endingHash.test(t)) {
531
+ const s = le(t, "#");
532
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (t = s.trim());
533
+ }
534
+ return {
535
+ type: "heading",
536
+ raw: e[0],
537
+ depth: e[1].length,
538
+ text: t,
539
+ tokens: this.lexer.inline(t)
540
+ };
541
+ }
542
+ }
543
+ hr(n) {
544
+ const e = this.rules.block.hr.exec(n);
545
+ if (e)
546
+ return {
547
+ type: "hr",
548
+ raw: le(e[0], `
549
+ `)
550
+ };
551
+ }
552
+ blockquote(n) {
553
+ const e = this.rules.block.blockquote.exec(n);
554
+ if (e) {
555
+ let t = le(e[0], `
556
+ `).split(`
557
+ `), s = "", i = "";
558
+ const r = [];
559
+ for (; t.length > 0; ) {
560
+ let c = !1;
561
+ const l = [];
562
+ let u;
563
+ for (u = 0; u < t.length; u++)
564
+ if (this.rules.other.blockquoteStart.test(t[u]))
565
+ l.push(t[u]), c = !0;
566
+ else if (!c)
567
+ l.push(t[u]);
568
+ else
569
+ break;
570
+ t = t.slice(u);
571
+ const a = l.join(`
572
+ `), o = a.replace(this.rules.other.blockquoteSetextReplace, `
573
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
574
+ s = s ? `${s}
575
+ ${a}` : a, i = i ? `${i}
576
+ ${o}` : o;
577
+ const p = this.lexer.state.top;
578
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(o, r, !0), this.lexer.state.top = p, t.length === 0)
579
+ break;
580
+ const h = r.at(-1);
581
+ if ((h == null ? void 0 : h.type) === "code")
582
+ break;
583
+ if ((h == null ? void 0 : h.type) === "blockquote") {
584
+ const d = h, f = d.raw + `
585
+ ` + t.join(`
586
+ `), k = this.blockquote(f);
587
+ r[r.length - 1] = k, s = s.substring(0, s.length - d.raw.length) + k.raw, i = i.substring(0, i.length - d.text.length) + k.text;
588
+ break;
589
+ } else if ((h == null ? void 0 : h.type) === "list") {
590
+ const d = h, f = d.raw + `
591
+ ` + t.join(`
592
+ `), k = this.list(f);
593
+ r[r.length - 1] = k, s = s.substring(0, s.length - h.raw.length) + k.raw, i = i.substring(0, i.length - d.raw.length) + k.raw, t = f.substring(r.at(-1).raw.length).split(`
594
+ `);
595
+ continue;
596
+ }
597
+ }
598
+ return {
599
+ type: "blockquote",
600
+ raw: s,
601
+ tokens: r,
602
+ text: i
603
+ };
604
+ }
605
+ }
606
+ list(n) {
607
+ let e = this.rules.block.list.exec(n);
608
+ if (e) {
609
+ let t = e[1].trim();
610
+ const s = t.length > 1, i = {
611
+ type: "list",
612
+ raw: "",
613
+ ordered: s,
614
+ start: s ? +t.slice(0, -1) : "",
615
+ loose: !1,
616
+ items: []
617
+ };
618
+ t = s ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = s ? t : "[*+-]");
619
+ const r = this.rules.other.listItemRegex(t);
620
+ let c = !1;
621
+ for (; n; ) {
622
+ let u = !1, a = "", o = "";
623
+ if (!(e = r.exec(n)) || this.rules.block.hr.test(n))
624
+ break;
625
+ a = e[0], n = n.substring(a.length);
626
+ let p = e[2].split(`
627
+ `, 1)[0].replace(this.rules.other.listReplaceTabs, (I) => " ".repeat(3 * I.length)), h = n.split(`
628
+ `, 1)[0], d = !p.trim(), f = 0;
629
+ if (this.options.pedantic ? (f = 2, o = p.trimStart()) : d ? f = e[1].length + 1 : (f = e[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, o = p.slice(f), f += e[1].length), d && this.rules.other.blankLine.test(h) && (a += h + `
630
+ `, n = n.substring(h.length + 1), u = !0), !u) {
631
+ const I = this.rules.other.nextBulletRegex(f), E = this.rules.other.hrRegex(f), B = this.rules.other.fencesBeginRegex(f), R = this.rules.other.headingBeginRegex(f), q = this.rules.other.htmlBeginRegex(f);
632
+ for (; n; ) {
633
+ const $ = n.split(`
634
+ `, 1)[0];
635
+ let z;
636
+ if (h = $, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), z = h) : z = h.replace(this.rules.other.tabCharGlobal, " "), B.test(h) || R.test(h) || q.test(h) || I.test(h) || E.test(h))
637
+ break;
638
+ if (z.search(this.rules.other.nonSpaceChar) >= f || !h.trim())
639
+ o += `
640
+ ` + z.slice(f);
641
+ else {
642
+ if (d || p.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || B.test(p) || R.test(p) || E.test(p))
643
+ break;
644
+ o += `
645
+ ` + h;
646
+ }
647
+ !d && !h.trim() && (d = !0), a += $ + `
648
+ `, n = n.substring($.length + 1), p = z.slice(f);
649
+ }
650
+ }
651
+ i.loose || (c ? i.loose = !0 : this.rules.other.doubleBlankLine.test(a) && (c = !0));
652
+ let k = null, g;
653
+ this.options.gfm && (k = this.rules.other.listIsTask.exec(o), k && (g = k[0] !== "[ ] ", o = o.replace(this.rules.other.listReplaceTask, ""))), i.items.push({
654
+ type: "list_item",
655
+ raw: a,
656
+ task: !!k,
657
+ checked: g,
658
+ loose: !1,
659
+ text: o,
660
+ tokens: []
661
+ }), i.raw += a;
662
+ }
663
+ const l = i.items.at(-1);
664
+ if (l)
665
+ l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
666
+ else
667
+ return;
668
+ i.raw = i.raw.trimEnd();
669
+ for (let u = 0; u < i.items.length; u++)
670
+ if (this.lexer.state.top = !1, i.items[u].tokens = this.lexer.blockTokens(i.items[u].text, []), !i.loose) {
671
+ const a = i.items[u].tokens.filter((p) => p.type === "space"), o = a.length > 0 && a.some((p) => this.rules.other.anyLine.test(p.raw));
672
+ i.loose = o;
673
+ }
674
+ if (i.loose)
675
+ for (let u = 0; u < i.items.length; u++)
676
+ i.items[u].loose = !0;
677
+ return i;
678
+ }
679
+ }
680
+ html(n) {
681
+ const e = this.rules.block.html.exec(n);
682
+ if (e)
683
+ return {
684
+ type: "html",
685
+ block: !0,
686
+ raw: e[0],
687
+ pre: e[1] === "pre" || e[1] === "script" || e[1] === "style",
688
+ text: e[0]
689
+ };
690
+ }
691
+ def(n) {
692
+ const e = this.rules.block.def.exec(n);
693
+ if (e) {
694
+ const t = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", i = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
695
+ return {
696
+ type: "def",
697
+ tag: t,
698
+ raw: e[0],
699
+ href: s,
700
+ title: i
701
+ };
702
+ }
703
+ }
704
+ table(n) {
705
+ var c;
706
+ const e = this.rules.block.table.exec(n);
707
+ if (!e || !this.rules.other.tableDelimiter.test(e[2]))
708
+ return;
709
+ const t = Je(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = (c = e[3]) != null && c.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
710
+ `) : [], r = {
711
+ type: "table",
712
+ raw: e[0],
713
+ header: [],
714
+ align: [],
715
+ rows: []
716
+ };
717
+ if (t.length === s.length) {
718
+ for (const l of s)
719
+ this.rules.other.tableAlignRight.test(l) ? r.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? r.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? r.align.push("left") : r.align.push(null);
720
+ for (let l = 0; l < t.length; l++)
721
+ r.header.push({
722
+ text: t[l],
723
+ tokens: this.lexer.inline(t[l]),
724
+ header: !0,
725
+ align: r.align[l]
726
+ });
727
+ for (const l of i)
728
+ r.rows.push(Je(l, r.header.length).map((u, a) => ({
729
+ text: u,
730
+ tokens: this.lexer.inline(u),
731
+ header: !1,
732
+ align: r.align[a]
733
+ })));
734
+ return r;
735
+ }
736
+ }
737
+ lheading(n) {
738
+ const e = this.rules.block.lheading.exec(n);
739
+ if (e)
740
+ return {
741
+ type: "heading",
742
+ raw: e[0],
743
+ depth: e[2].charAt(0) === "=" ? 1 : 2,
744
+ text: e[1],
745
+ tokens: this.lexer.inline(e[1])
746
+ };
747
+ }
748
+ paragraph(n) {
749
+ const e = this.rules.block.paragraph.exec(n);
750
+ if (e) {
751
+ const t = e[1].charAt(e[1].length - 1) === `
752
+ ` ? e[1].slice(0, -1) : e[1];
753
+ return {
754
+ type: "paragraph",
755
+ raw: e[0],
756
+ text: t,
757
+ tokens: this.lexer.inline(t)
758
+ };
759
+ }
760
+ }
761
+ text(n) {
762
+ const e = this.rules.block.text.exec(n);
763
+ if (e)
764
+ return {
765
+ type: "text",
766
+ raw: e[0],
767
+ text: e[0],
768
+ tokens: this.lexer.inline(e[0])
769
+ };
770
+ }
771
+ escape(n) {
772
+ const e = this.rules.inline.escape.exec(n);
773
+ if (e)
774
+ return {
775
+ type: "escape",
776
+ raw: e[0],
777
+ text: e[1]
778
+ };
779
+ }
780
+ tag(n) {
781
+ const e = this.rules.inline.tag.exec(n);
782
+ if (e)
783
+ return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), {
784
+ type: "html",
785
+ raw: e[0],
786
+ inLink: this.lexer.state.inLink,
787
+ inRawBlock: this.lexer.state.inRawBlock,
788
+ block: !1,
789
+ text: e[0]
790
+ };
791
+ }
792
+ link(n) {
793
+ const e = this.rules.inline.link.exec(n);
794
+ if (e) {
795
+ const t = e[2].trim();
796
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) {
797
+ if (!this.rules.other.endAngleBracket.test(t))
798
+ return;
799
+ const r = le(t.slice(0, -1), "\\");
800
+ if ((t.length - r.length) % 2 === 0)
801
+ return;
802
+ } else {
803
+ const r = ln(e[2], "()");
804
+ if (r === -2)
805
+ return;
806
+ if (r > -1) {
807
+ const l = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + r;
808
+ e[2] = e[2].substring(0, r), e[0] = e[0].substring(0, l).trim(), e[3] = "";
809
+ }
810
+ }
811
+ let s = e[2], i = "";
812
+ if (this.options.pedantic) {
813
+ const r = this.rules.other.pedanticHrefTitle.exec(s);
814
+ r && (s = r[1], i = r[3]);
815
+ } else
816
+ i = e[3] ? e[3].slice(1, -1) : "";
817
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? s = s.slice(1) : s = s.slice(1, -1)), Ye(e, {
818
+ href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
819
+ title: i && i.replace(this.rules.inline.anyPunctuation, "$1")
820
+ }, e[0], this.lexer, this.rules);
821
+ }
822
+ }
823
+ reflink(n, e) {
824
+ let t;
825
+ if ((t = this.rules.inline.reflink.exec(n)) || (t = this.rules.inline.nolink.exec(n))) {
826
+ const s = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = e[s.toLowerCase()];
827
+ if (!i) {
828
+ const r = t[0].charAt(0);
829
+ return {
830
+ type: "text",
831
+ raw: r,
832
+ text: r
833
+ };
834
+ }
835
+ return Ye(t, i, t[0], this.lexer, this.rules);
836
+ }
837
+ }
838
+ emStrong(n, e, t = "") {
839
+ let s = this.rules.inline.emStrongLDelim.exec(n);
840
+ if (!s || s[3] && t.match(this.rules.other.unicodeAlphaNumeric)) return;
841
+ if (!(s[1] || s[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
842
+ const r = [...s[0]].length - 1;
843
+ let c, l, u = r, a = 0;
844
+ const o = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
845
+ for (o.lastIndex = 0, e = e.slice(-1 * n.length + r); (s = o.exec(e)) != null; ) {
846
+ if (c = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !c) continue;
847
+ if (l = [...c].length, s[3] || s[4]) {
848
+ u += l;
849
+ continue;
850
+ } else if ((s[5] || s[6]) && r % 3 && !((r + l) % 3)) {
851
+ a += l;
852
+ continue;
853
+ }
854
+ if (u -= l, u > 0) continue;
855
+ l = Math.min(l, l + u + a);
856
+ const p = [...s[0]][0].length, h = n.slice(0, r + s.index + p + l);
857
+ if (Math.min(r, l) % 2) {
858
+ const f = h.slice(1, -1);
859
+ return {
860
+ type: "em",
861
+ raw: h,
862
+ text: f,
863
+ tokens: this.lexer.inlineTokens(f)
864
+ };
865
+ }
866
+ const d = h.slice(2, -2);
867
+ return {
868
+ type: "strong",
869
+ raw: h,
870
+ text: d,
871
+ tokens: this.lexer.inlineTokens(d)
872
+ };
873
+ }
874
+ }
875
+ }
876
+ codespan(n) {
877
+ const e = this.rules.inline.code.exec(n);
878
+ if (e) {
879
+ let t = e[2].replace(this.rules.other.newLineCharGlobal, " ");
880
+ const s = this.rules.other.nonSpaceChar.test(t), i = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t);
881
+ return s && i && (t = t.substring(1, t.length - 1)), {
882
+ type: "codespan",
883
+ raw: e[0],
884
+ text: t
885
+ };
886
+ }
887
+ }
888
+ br(n) {
889
+ const e = this.rules.inline.br.exec(n);
890
+ if (e)
891
+ return {
892
+ type: "br",
893
+ raw: e[0]
894
+ };
895
+ }
896
+ del(n) {
897
+ const e = this.rules.inline.del.exec(n);
898
+ if (e)
899
+ return {
900
+ type: "del",
901
+ raw: e[0],
902
+ text: e[2],
903
+ tokens: this.lexer.inlineTokens(e[2])
904
+ };
905
+ }
906
+ autolink(n) {
907
+ const e = this.rules.inline.autolink.exec(n);
908
+ if (e) {
909
+ let t, s;
910
+ return e[2] === "@" ? (t = e[1], s = "mailto:" + t) : (t = e[1], s = t), {
911
+ type: "link",
912
+ raw: e[0],
913
+ text: t,
914
+ href: s,
915
+ tokens: [
916
+ {
917
+ type: "text",
918
+ raw: t,
919
+ text: t
920
+ }
921
+ ]
922
+ };
923
+ }
924
+ }
925
+ url(n) {
926
+ var t;
927
+ let e;
928
+ if (e = this.rules.inline.url.exec(n)) {
929
+ let s, i;
930
+ if (e[2] === "@")
931
+ s = e[0], i = "mailto:" + s;
932
+ else {
933
+ let r;
934
+ do
935
+ r = e[0], e[0] = ((t = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : t[0]) ?? "";
936
+ while (r !== e[0]);
937
+ s = e[0], e[1] === "www." ? i = "http://" + e[0] : i = e[0];
938
+ }
939
+ return {
940
+ type: "link",
941
+ raw: e[0],
942
+ text: s,
943
+ href: i,
944
+ tokens: [
945
+ {
946
+ type: "text",
947
+ raw: s,
948
+ text: s
949
+ }
950
+ ]
951
+ };
952
+ }
953
+ }
954
+ inlineText(n) {
955
+ const e = this.rules.inline.text.exec(n);
956
+ if (e) {
957
+ const t = this.lexer.state.inRawBlock;
958
+ return {
959
+ type: "text",
960
+ raw: e[0],
961
+ text: e[0],
962
+ escaped: t
963
+ };
964
+ }
965
+ }
966
+ }, F = class ze {
967
+ constructor(e) {
968
+ v(this, "tokens");
969
+ v(this, "options");
970
+ v(this, "state");
971
+ v(this, "tokenizer");
972
+ v(this, "inlineQueue");
973
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || X, this.options.tokenizer = this.options.tokenizer || new xe(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
974
+ inLink: !1,
975
+ inRawBlock: !1,
976
+ top: !0
977
+ };
978
+ const t = {
979
+ other: P,
980
+ block: de.normal,
981
+ inline: re.normal
982
+ };
983
+ this.options.pedantic ? (t.block = de.pedantic, t.inline = re.pedantic) : this.options.gfm && (t.block = de.gfm, this.options.breaks ? t.inline = re.breaks : t.inline = re.gfm), this.tokenizer.rules = t;
984
+ }
985
+ /**
986
+ * Expose Rules
987
+ */
988
+ static get rules() {
989
+ return {
990
+ block: de,
991
+ inline: re
992
+ };
993
+ }
994
+ /**
995
+ * Static Lex Method
996
+ */
997
+ static lex(e, t) {
998
+ return new ze(t).lex(e);
999
+ }
1000
+ /**
1001
+ * Static Lex Inline Method
1002
+ */
1003
+ static lexInline(e, t) {
1004
+ return new ze(t).inlineTokens(e);
1005
+ }
1006
+ /**
1007
+ * Preprocessing
1008
+ */
1009
+ lex(e) {
1010
+ e = e.replace(P.carriageReturn, `
1011
+ `), this.blockTokens(e, this.tokens);
1012
+ for (let t = 0; t < this.inlineQueue.length; t++) {
1013
+ const s = this.inlineQueue[t];
1014
+ this.inlineTokens(s.src, s.tokens);
1015
+ }
1016
+ return this.inlineQueue = [], this.tokens;
1017
+ }
1018
+ blockTokens(e, t = [], s = !1) {
1019
+ var i, r, c;
1020
+ for (this.options.pedantic && (e = e.replace(P.tabCharGlobal, " ").replace(P.spaceLine, "")); e; ) {
1021
+ let l;
1022
+ if ((r = (i = this.options.extensions) == null ? void 0 : i.block) != null && r.some((a) => (l = a.call({ lexer: this }, e, t)) ? (e = e.substring(l.raw.length), t.push(l), !0) : !1))
1023
+ continue;
1024
+ if (l = this.tokenizer.space(e)) {
1025
+ e = e.substring(l.raw.length);
1026
+ const a = t.at(-1);
1027
+ l.raw.length === 1 && a !== void 0 ? a.raw += `
1028
+ ` : t.push(l);
1029
+ continue;
1030
+ }
1031
+ if (l = this.tokenizer.code(e)) {
1032
+ e = e.substring(l.raw.length);
1033
+ const a = t.at(-1);
1034
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += `
1035
+ ` + l.raw, a.text += `
1036
+ ` + l.text, this.inlineQueue.at(-1).src = a.text) : t.push(l);
1037
+ continue;
1038
+ }
1039
+ if (l = this.tokenizer.fences(e)) {
1040
+ e = e.substring(l.raw.length), t.push(l);
1041
+ continue;
1042
+ }
1043
+ if (l = this.tokenizer.heading(e)) {
1044
+ e = e.substring(l.raw.length), t.push(l);
1045
+ continue;
1046
+ }
1047
+ if (l = this.tokenizer.hr(e)) {
1048
+ e = e.substring(l.raw.length), t.push(l);
1049
+ continue;
1050
+ }
1051
+ if (l = this.tokenizer.blockquote(e)) {
1052
+ e = e.substring(l.raw.length), t.push(l);
1053
+ continue;
1054
+ }
1055
+ if (l = this.tokenizer.list(e)) {
1056
+ e = e.substring(l.raw.length), t.push(l);
1057
+ continue;
1058
+ }
1059
+ if (l = this.tokenizer.html(e)) {
1060
+ e = e.substring(l.raw.length), t.push(l);
1061
+ continue;
1062
+ }
1063
+ if (l = this.tokenizer.def(e)) {
1064
+ e = e.substring(l.raw.length);
1065
+ const a = t.at(-1);
1066
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += `
1067
+ ` + l.raw, a.text += `
1068
+ ` + l.raw, this.inlineQueue.at(-1).src = a.text) : this.tokens.links[l.tag] || (this.tokens.links[l.tag] = {
1069
+ href: l.href,
1070
+ title: l.title
1071
+ });
1072
+ continue;
1073
+ }
1074
+ if (l = this.tokenizer.table(e)) {
1075
+ e = e.substring(l.raw.length), t.push(l);
1076
+ continue;
1077
+ }
1078
+ if (l = this.tokenizer.lheading(e)) {
1079
+ e = e.substring(l.raw.length), t.push(l);
1080
+ continue;
1081
+ }
1082
+ let u = e;
1083
+ if ((c = this.options.extensions) != null && c.startBlock) {
1084
+ let a = 1 / 0;
1085
+ const o = e.slice(1);
1086
+ let p;
1087
+ this.options.extensions.startBlock.forEach((h) => {
1088
+ p = h.call({ lexer: this }, o), typeof p == "number" && p >= 0 && (a = Math.min(a, p));
1089
+ }), a < 1 / 0 && a >= 0 && (u = e.substring(0, a + 1));
1090
+ }
1091
+ if (this.state.top && (l = this.tokenizer.paragraph(u))) {
1092
+ const a = t.at(-1);
1093
+ s && (a == null ? void 0 : a.type) === "paragraph" ? (a.raw += `
1094
+ ` + l.raw, a.text += `
1095
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(l), s = u.length !== e.length, e = e.substring(l.raw.length);
1096
+ continue;
1097
+ }
1098
+ if (l = this.tokenizer.text(e)) {
1099
+ e = e.substring(l.raw.length);
1100
+ const a = t.at(-1);
1101
+ (a == null ? void 0 : a.type) === "text" ? (a.raw += `
1102
+ ` + l.raw, a.text += `
1103
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(l);
1104
+ continue;
1105
+ }
1106
+ if (e) {
1107
+ const a = "Infinite loop on byte: " + e.charCodeAt(0);
1108
+ if (this.options.silent) {
1109
+ console.error(a);
1110
+ break;
1111
+ } else
1112
+ throw new Error(a);
1113
+ }
1114
+ }
1115
+ return this.state.top = !0, t;
1116
+ }
1117
+ inline(e, t = []) {
1118
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
1119
+ }
1120
+ /**
1121
+ * Lexing/Compiling
1122
+ */
1123
+ inlineTokens(e, t = []) {
1124
+ var l, u, a;
1125
+ let s = e, i = null;
1126
+ if (this.tokens.links) {
1127
+ const o = Object.keys(this.tokens.links);
1128
+ if (o.length > 0)
1129
+ for (; (i = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; )
1130
+ o.includes(i[0].slice(i[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, i.index) + "[" + "a".repeat(i[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
1131
+ }
1132
+ for (; (i = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; )
1133
+ s = s.slice(0, i.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1134
+ for (; (i = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; )
1135
+ s = s.slice(0, i.index) + "[" + "a".repeat(i[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1136
+ let r = !1, c = "";
1137
+ for (; e; ) {
1138
+ r || (c = ""), r = !1;
1139
+ let o;
1140
+ if ((u = (l = this.options.extensions) == null ? void 0 : l.inline) != null && u.some((h) => (o = h.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), !0) : !1))
1141
+ continue;
1142
+ if (o = this.tokenizer.escape(e)) {
1143
+ e = e.substring(o.raw.length), t.push(o);
1144
+ continue;
1145
+ }
1146
+ if (o = this.tokenizer.tag(e)) {
1147
+ e = e.substring(o.raw.length), t.push(o);
1148
+ continue;
1149
+ }
1150
+ if (o = this.tokenizer.link(e)) {
1151
+ e = e.substring(o.raw.length), t.push(o);
1152
+ continue;
1153
+ }
1154
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
1155
+ e = e.substring(o.raw.length);
1156
+ const h = t.at(-1);
1157
+ o.type === "text" && (h == null ? void 0 : h.type) === "text" ? (h.raw += o.raw, h.text += o.text) : t.push(o);
1158
+ continue;
1159
+ }
1160
+ if (o = this.tokenizer.emStrong(e, s, c)) {
1161
+ e = e.substring(o.raw.length), t.push(o);
1162
+ continue;
1163
+ }
1164
+ if (o = this.tokenizer.codespan(e)) {
1165
+ e = e.substring(o.raw.length), t.push(o);
1166
+ continue;
1167
+ }
1168
+ if (o = this.tokenizer.br(e)) {
1169
+ e = e.substring(o.raw.length), t.push(o);
1170
+ continue;
1171
+ }
1172
+ if (o = this.tokenizer.del(e)) {
1173
+ e = e.substring(o.raw.length), t.push(o);
1174
+ continue;
1175
+ }
1176
+ if (o = this.tokenizer.autolink(e)) {
1177
+ e = e.substring(o.raw.length), t.push(o);
1178
+ continue;
1179
+ }
1180
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
1181
+ e = e.substring(o.raw.length), t.push(o);
1182
+ continue;
1183
+ }
1184
+ let p = e;
1185
+ if ((a = this.options.extensions) != null && a.startInline) {
1186
+ let h = 1 / 0;
1187
+ const d = e.slice(1);
1188
+ let f;
1189
+ this.options.extensions.startInline.forEach((k) => {
1190
+ f = k.call({ lexer: this }, d), typeof f == "number" && f >= 0 && (h = Math.min(h, f));
1191
+ }), h < 1 / 0 && h >= 0 && (p = e.substring(0, h + 1));
1192
+ }
1193
+ if (o = this.tokenizer.inlineText(p)) {
1194
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (c = o.raw.slice(-1)), r = !0;
1195
+ const h = t.at(-1);
1196
+ (h == null ? void 0 : h.type) === "text" ? (h.raw += o.raw, h.text += o.text) : t.push(o);
1197
+ continue;
1198
+ }
1199
+ if (e) {
1200
+ const h = "Infinite loop on byte: " + e.charCodeAt(0);
1201
+ if (this.options.silent) {
1202
+ console.error(h);
1203
+ break;
1204
+ } else
1205
+ throw new Error(h);
1206
+ }
1207
+ }
1208
+ return t;
1209
+ }
1210
+ }, we = class {
1211
+ // set by the parser
1212
+ constructor(n) {
1213
+ v(this, "options");
1214
+ v(this, "parser");
1215
+ this.options = n || X;
1216
+ }
1217
+ space(n) {
1218
+ return "";
1219
+ }
1220
+ code({ text: n, lang: e, escaped: t }) {
1221
+ var r;
1222
+ const s = (r = (e || "").match(P.notSpaceStart)) == null ? void 0 : r[0], i = n.replace(P.endingNewline, "") + `
1223
+ `;
1224
+ return s ? '<pre><code class="language-' + M(s) + '">' + (t ? i : M(i, !0)) + `</code></pre>
1225
+ ` : "<pre><code>" + (t ? i : M(i, !0)) + `</code></pre>
1226
+ `;
1227
+ }
1228
+ blockquote({ tokens: n }) {
1229
+ return `<blockquote>
1230
+ ${this.parser.parse(n)}</blockquote>
1231
+ `;
1232
+ }
1233
+ html({ text: n }) {
1234
+ return n;
1235
+ }
1236
+ heading({ tokens: n, depth: e }) {
1237
+ return `<h${e}>${this.parser.parseInline(n)}</h${e}>
1238
+ `;
1239
+ }
1240
+ hr(n) {
1241
+ return `<hr>
1242
+ `;
1243
+ }
1244
+ list(n) {
1245
+ const e = n.ordered, t = n.start;
1246
+ let s = "";
1247
+ for (let c = 0; c < n.items.length; c++) {
1248
+ const l = n.items[c];
1249
+ s += this.listitem(l);
1250
+ }
1251
+ const i = e ? "ol" : "ul", r = e && t !== 1 ? ' start="' + t + '"' : "";
1252
+ return "<" + i + r + `>
1253
+ ` + s + "</" + i + `>
1254
+ `;
1255
+ }
1256
+ listitem(n) {
1257
+ var t;
1258
+ let e = "";
1259
+ if (n.task) {
1260
+ const s = this.checkbox({ checked: !!n.checked });
1261
+ n.loose ? ((t = n.tokens[0]) == null ? void 0 : t.type) === "paragraph" ? (n.tokens[0].text = s + " " + n.tokens[0].text, n.tokens[0].tokens && n.tokens[0].tokens.length > 0 && n.tokens[0].tokens[0].type === "text" && (n.tokens[0].tokens[0].text = s + " " + M(n.tokens[0].tokens[0].text), n.tokens[0].tokens[0].escaped = !0)) : n.tokens.unshift({
1262
+ type: "text",
1263
+ raw: s + " ",
1264
+ text: s + " ",
1265
+ escaped: !0
1266
+ }) : e += s + " ";
1267
+ }
1268
+ return e += this.parser.parse(n.tokens, !!n.loose), `<li>${e}</li>
1269
+ `;
1270
+ }
1271
+ checkbox({ checked: n }) {
1272
+ return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1273
+ }
1274
+ paragraph({ tokens: n }) {
1275
+ return `<p>${this.parser.parseInline(n)}</p>
1276
+ `;
1277
+ }
1278
+ table(n) {
1279
+ let e = "", t = "";
1280
+ for (let i = 0; i < n.header.length; i++)
1281
+ t += this.tablecell(n.header[i]);
1282
+ e += this.tablerow({ text: t });
1283
+ let s = "";
1284
+ for (let i = 0; i < n.rows.length; i++) {
1285
+ const r = n.rows[i];
1286
+ t = "";
1287
+ for (let c = 0; c < r.length; c++)
1288
+ t += this.tablecell(r[c]);
1289
+ s += this.tablerow({ text: t });
1290
+ }
1291
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
1292
+ <thead>
1293
+ ` + e + `</thead>
1294
+ ` + s + `</table>
1295
+ `;
1296
+ }
1297
+ tablerow({ text: n }) {
1298
+ return `<tr>
1299
+ ${n}</tr>
1300
+ `;
1301
+ }
1302
+ tablecell(n) {
1303
+ const e = this.parser.parseInline(n.tokens), t = n.header ? "th" : "td";
1304
+ return (n.align ? `<${t} align="${n.align}">` : `<${t}>`) + e + `</${t}>
1305
+ `;
1306
+ }
1307
+ /**
1308
+ * span level renderer
1309
+ */
1310
+ strong({ tokens: n }) {
1311
+ return `<strong>${this.parser.parseInline(n)}</strong>`;
1312
+ }
1313
+ em({ tokens: n }) {
1314
+ return `<em>${this.parser.parseInline(n)}</em>`;
1315
+ }
1316
+ codespan({ text: n }) {
1317
+ return `<code>${M(n, !0)}</code>`;
1318
+ }
1319
+ br(n) {
1320
+ return "<br>";
1321
+ }
1322
+ del({ tokens: n }) {
1323
+ return `<del>${this.parser.parseInline(n)}</del>`;
1324
+ }
1325
+ link({ href: n, title: e, tokens: t }) {
1326
+ const s = this.parser.parseInline(t), i = Xe(n);
1327
+ if (i === null)
1328
+ return s;
1329
+ n = i;
1330
+ let r = '<a href="' + n + '"';
1331
+ return e && (r += ' title="' + M(e) + '"'), r += ">" + s + "</a>", r;
1332
+ }
1333
+ image({ href: n, title: e, text: t, tokens: s }) {
1334
+ s && (t = this.parser.parseInline(s, this.parser.textRenderer));
1335
+ const i = Xe(n);
1336
+ if (i === null)
1337
+ return M(t);
1338
+ n = i;
1339
+ let r = `<img src="${n}" alt="${t}"`;
1340
+ return e && (r += ` title="${M(e)}"`), r += ">", r;
1341
+ }
1342
+ text(n) {
1343
+ return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : M(n.text);
1344
+ }
1345
+ }, Oe = class {
1346
+ // no need for block level renderers
1347
+ strong({ text: n }) {
1348
+ return n;
1349
+ }
1350
+ em({ text: n }) {
1351
+ return n;
1352
+ }
1353
+ codespan({ text: n }) {
1354
+ return n;
1355
+ }
1356
+ del({ text: n }) {
1357
+ return n;
1358
+ }
1359
+ html({ text: n }) {
1360
+ return n;
1361
+ }
1362
+ text({ text: n }) {
1363
+ return n;
1364
+ }
1365
+ link({ text: n }) {
1366
+ return "" + n;
1367
+ }
1368
+ image({ text: n }) {
1369
+ return "" + n;
1370
+ }
1371
+ br() {
1372
+ return "";
1373
+ }
1374
+ }, Q = class $e {
1375
+ constructor(e) {
1376
+ v(this, "options");
1377
+ v(this, "renderer");
1378
+ v(this, "textRenderer");
1379
+ this.options = e || X, this.options.renderer = this.options.renderer || new we(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Oe();
1380
+ }
1381
+ /**
1382
+ * Static Parse Method
1383
+ */
1384
+ static parse(e, t) {
1385
+ return new $e(t).parse(e);
1386
+ }
1387
+ /**
1388
+ * Static Parse Inline Method
1389
+ */
1390
+ static parseInline(e, t) {
1391
+ return new $e(t).parseInline(e);
1392
+ }
1393
+ /**
1394
+ * Parse Loop
1395
+ */
1396
+ parse(e, t = !0) {
1397
+ var i, r;
1398
+ let s = "";
1399
+ for (let c = 0; c < e.length; c++) {
1400
+ const l = e[c];
1401
+ if ((r = (i = this.options.extensions) == null ? void 0 : i.renderers) != null && r[l.type]) {
1402
+ const a = l, o = this.options.extensions.renderers[a.type].call({ parser: this }, a);
1403
+ if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(a.type)) {
1404
+ s += o || "";
1405
+ continue;
1406
+ }
1407
+ }
1408
+ const u = l;
1409
+ switch (u.type) {
1410
+ case "space": {
1411
+ s += this.renderer.space(u);
1412
+ continue;
1413
+ }
1414
+ case "hr": {
1415
+ s += this.renderer.hr(u);
1416
+ continue;
1417
+ }
1418
+ case "heading": {
1419
+ s += this.renderer.heading(u);
1420
+ continue;
1421
+ }
1422
+ case "code": {
1423
+ s += this.renderer.code(u);
1424
+ continue;
1425
+ }
1426
+ case "table": {
1427
+ s += this.renderer.table(u);
1428
+ continue;
1429
+ }
1430
+ case "blockquote": {
1431
+ s += this.renderer.blockquote(u);
1432
+ continue;
1433
+ }
1434
+ case "list": {
1435
+ s += this.renderer.list(u);
1436
+ continue;
1437
+ }
1438
+ case "html": {
1439
+ s += this.renderer.html(u);
1440
+ continue;
1441
+ }
1442
+ case "paragraph": {
1443
+ s += this.renderer.paragraph(u);
1444
+ continue;
1445
+ }
1446
+ case "text": {
1447
+ let a = u, o = this.renderer.text(a);
1448
+ for (; c + 1 < e.length && e[c + 1].type === "text"; )
1449
+ a = e[++c], o += `
1450
+ ` + this.renderer.text(a);
1451
+ t ? s += this.renderer.paragraph({
1452
+ type: "paragraph",
1453
+ raw: o,
1454
+ text: o,
1455
+ tokens: [{ type: "text", raw: o, text: o, escaped: !0 }]
1456
+ }) : s += o;
1457
+ continue;
1458
+ }
1459
+ default: {
1460
+ const a = 'Token with "' + u.type + '" type was not found.';
1461
+ if (this.options.silent)
1462
+ return console.error(a), "";
1463
+ throw new Error(a);
1464
+ }
1465
+ }
1466
+ }
1467
+ return s;
1468
+ }
1469
+ /**
1470
+ * Parse Inline Tokens
1471
+ */
1472
+ parseInline(e, t = this.renderer) {
1473
+ var i, r;
1474
+ let s = "";
1475
+ for (let c = 0; c < e.length; c++) {
1476
+ const l = e[c];
1477
+ if ((r = (i = this.options.extensions) == null ? void 0 : i.renderers) != null && r[l.type]) {
1478
+ const a = this.options.extensions.renderers[l.type].call({ parser: this }, l);
1479
+ if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(l.type)) {
1480
+ s += a || "";
1481
+ continue;
1482
+ }
1483
+ }
1484
+ const u = l;
1485
+ switch (u.type) {
1486
+ case "escape": {
1487
+ s += t.text(u);
1488
+ break;
1489
+ }
1490
+ case "html": {
1491
+ s += t.html(u);
1492
+ break;
1493
+ }
1494
+ case "link": {
1495
+ s += t.link(u);
1496
+ break;
1497
+ }
1498
+ case "image": {
1499
+ s += t.image(u);
1500
+ break;
1501
+ }
1502
+ case "strong": {
1503
+ s += t.strong(u);
1504
+ break;
1505
+ }
1506
+ case "em": {
1507
+ s += t.em(u);
1508
+ break;
1509
+ }
1510
+ case "codespan": {
1511
+ s += t.codespan(u);
1512
+ break;
1513
+ }
1514
+ case "br": {
1515
+ s += t.br(u);
1516
+ break;
1517
+ }
1518
+ case "del": {
1519
+ s += t.del(u);
1520
+ break;
1521
+ }
1522
+ case "text": {
1523
+ s += t.text(u);
1524
+ break;
1525
+ }
1526
+ default: {
1527
+ const a = 'Token with "' + u.type + '" type was not found.';
1528
+ if (this.options.silent)
1529
+ return console.error(a), "";
1530
+ throw new Error(a);
1531
+ }
1532
+ }
1533
+ }
1534
+ return s;
1535
+ }
1536
+ }, Re, me = (Re = class {
1537
+ constructor(n) {
1538
+ v(this, "options");
1539
+ v(this, "block");
1540
+ this.options = n || X;
1541
+ }
1542
+ /**
1543
+ * Process markdown before marked
1544
+ */
1545
+ preprocess(n) {
1546
+ return n;
1547
+ }
1548
+ /**
1549
+ * Process HTML after marked is finished
1550
+ */
1551
+ postprocess(n) {
1552
+ return n;
1553
+ }
1554
+ /**
1555
+ * Process all tokens before walk tokens
1556
+ */
1557
+ processAllTokens(n) {
1558
+ return n;
1559
+ }
1560
+ /**
1561
+ * Provide function to tokenize markdown
1562
+ */
1563
+ provideLexer() {
1564
+ return this.block ? F.lex : F.lexInline;
1565
+ }
1566
+ /**
1567
+ * Provide function to parse tokens
1568
+ */
1569
+ provideParser() {
1570
+ return this.block ? Q.parse : Q.parseInline;
1571
+ }
1572
+ }, v(Re, "passThroughHooks", /* @__PURE__ */ new Set([
1573
+ "preprocess",
1574
+ "postprocess",
1575
+ "processAllTokens"
1576
+ ])), Re), on = class {
1577
+ constructor(...n) {
1578
+ v(this, "defaults", Le());
1579
+ v(this, "options", this.setOptions);
1580
+ v(this, "parse", this.parseMarkdown(!0));
1581
+ v(this, "parseInline", this.parseMarkdown(!1));
1582
+ v(this, "Parser", Q);
1583
+ v(this, "Renderer", we);
1584
+ v(this, "TextRenderer", Oe);
1585
+ v(this, "Lexer", F);
1586
+ v(this, "Tokenizer", xe);
1587
+ v(this, "Hooks", me);
1588
+ this.use(...n);
1589
+ }
1590
+ /**
1591
+ * Run callback for every token
1592
+ */
1593
+ walkTokens(n, e) {
1594
+ var s, i;
1595
+ let t = [];
1596
+ for (const r of n)
1597
+ switch (t = t.concat(e.call(this, r)), r.type) {
1598
+ case "table": {
1599
+ const c = r;
1600
+ for (const l of c.header)
1601
+ t = t.concat(this.walkTokens(l.tokens, e));
1602
+ for (const l of c.rows)
1603
+ for (const u of l)
1604
+ t = t.concat(this.walkTokens(u.tokens, e));
1605
+ break;
1606
+ }
1607
+ case "list": {
1608
+ const c = r;
1609
+ t = t.concat(this.walkTokens(c.items, e));
1610
+ break;
1611
+ }
1612
+ default: {
1613
+ const c = r;
1614
+ (i = (s = this.defaults.extensions) == null ? void 0 : s.childTokens) != null && i[c.type] ? this.defaults.extensions.childTokens[c.type].forEach((l) => {
1615
+ const u = c[l].flat(1 / 0);
1616
+ t = t.concat(this.walkTokens(u, e));
1617
+ }) : c.tokens && (t = t.concat(this.walkTokens(c.tokens, e)));
1618
+ }
1619
+ }
1620
+ return t;
1621
+ }
1622
+ use(...n) {
1623
+ const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1624
+ return n.forEach((t) => {
1625
+ const s = { ...t };
1626
+ if (s.async = this.defaults.async || s.async || !1, t.extensions && (t.extensions.forEach((i) => {
1627
+ if (!i.name)
1628
+ throw new Error("extension name required");
1629
+ if ("renderer" in i) {
1630
+ const r = e.renderers[i.name];
1631
+ r ? e.renderers[i.name] = function(...c) {
1632
+ let l = i.renderer.apply(this, c);
1633
+ return l === !1 && (l = r.apply(this, c)), l;
1634
+ } : e.renderers[i.name] = i.renderer;
1635
+ }
1636
+ if ("tokenizer" in i) {
1637
+ if (!i.level || i.level !== "block" && i.level !== "inline")
1638
+ throw new Error("extension level must be 'block' or 'inline'");
1639
+ const r = e[i.level];
1640
+ r ? r.unshift(i.tokenizer) : e[i.level] = [i.tokenizer], i.start && (i.level === "block" ? e.startBlock ? e.startBlock.push(i.start) : e.startBlock = [i.start] : i.level === "inline" && (e.startInline ? e.startInline.push(i.start) : e.startInline = [i.start]));
1641
+ }
1642
+ "childTokens" in i && i.childTokens && (e.childTokens[i.name] = i.childTokens);
1643
+ }), s.extensions = e), t.renderer) {
1644
+ const i = this.defaults.renderer || new we(this.defaults);
1645
+ for (const r in t.renderer) {
1646
+ if (!(r in i))
1647
+ throw new Error(`renderer '${r}' does not exist`);
1648
+ if (["options", "parser"].includes(r))
1649
+ continue;
1650
+ const c = r, l = t.renderer[c], u = i[c];
1651
+ i[c] = (...a) => {
1652
+ let o = l.apply(i, a);
1653
+ return o === !1 && (o = u.apply(i, a)), o || "";
1654
+ };
1655
+ }
1656
+ s.renderer = i;
1657
+ }
1658
+ if (t.tokenizer) {
1659
+ const i = this.defaults.tokenizer || new xe(this.defaults);
1660
+ for (const r in t.tokenizer) {
1661
+ if (!(r in i))
1662
+ throw new Error(`tokenizer '${r}' does not exist`);
1663
+ if (["options", "rules", "lexer"].includes(r))
1664
+ continue;
1665
+ const c = r, l = t.tokenizer[c], u = i[c];
1666
+ i[c] = (...a) => {
1667
+ let o = l.apply(i, a);
1668
+ return o === !1 && (o = u.apply(i, a)), o;
1669
+ };
1670
+ }
1671
+ s.tokenizer = i;
1672
+ }
1673
+ if (t.hooks) {
1674
+ const i = this.defaults.hooks || new me();
1675
+ for (const r in t.hooks) {
1676
+ if (!(r in i))
1677
+ throw new Error(`hook '${r}' does not exist`);
1678
+ if (["options", "block"].includes(r))
1679
+ continue;
1680
+ const c = r, l = t.hooks[c], u = i[c];
1681
+ me.passThroughHooks.has(r) ? i[c] = (a) => {
1682
+ if (this.defaults.async)
1683
+ return Promise.resolve(l.call(i, a)).then((p) => u.call(i, p));
1684
+ const o = l.call(i, a);
1685
+ return u.call(i, o);
1686
+ } : i[c] = (...a) => {
1687
+ let o = l.apply(i, a);
1688
+ return o === !1 && (o = u.apply(i, a)), o;
1689
+ };
1690
+ }
1691
+ s.hooks = i;
1692
+ }
1693
+ if (t.walkTokens) {
1694
+ const i = this.defaults.walkTokens, r = t.walkTokens;
1695
+ s.walkTokens = function(c) {
1696
+ let l = [];
1697
+ return l.push(r.call(this, c)), i && (l = l.concat(i.call(this, c))), l;
1698
+ };
1699
+ }
1700
+ this.defaults = { ...this.defaults, ...s };
1701
+ }), this;
1702
+ }
1703
+ setOptions(n) {
1704
+ return this.defaults = { ...this.defaults, ...n }, this;
1705
+ }
1706
+ lexer(n, e) {
1707
+ return F.lex(n, e ?? this.defaults);
1708
+ }
1709
+ parser(n, e) {
1710
+ return Q.parse(n, e ?? this.defaults);
1711
+ }
1712
+ parseMarkdown(n) {
1713
+ return (t, s) => {
1714
+ const i = { ...s }, r = { ...this.defaults, ...i }, c = this.onError(!!r.silent, !!r.async);
1715
+ if (this.defaults.async === !0 && i.async === !1)
1716
+ return c(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1717
+ if (typeof t > "u" || t === null)
1718
+ return c(new Error("marked(): input parameter is undefined or null"));
1719
+ if (typeof t != "string")
1720
+ return c(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
1721
+ r.hooks && (r.hooks.options = r, r.hooks.block = n);
1722
+ const l = r.hooks ? r.hooks.provideLexer() : n ? F.lex : F.lexInline, u = r.hooks ? r.hooks.provideParser() : n ? Q.parse : Q.parseInline;
1723
+ if (r.async)
1724
+ return Promise.resolve(r.hooks ? r.hooks.preprocess(t) : t).then((a) => l(a, r)).then((a) => r.hooks ? r.hooks.processAllTokens(a) : a).then((a) => r.walkTokens ? Promise.all(this.walkTokens(a, r.walkTokens)).then(() => a) : a).then((a) => u(a, r)).then((a) => r.hooks ? r.hooks.postprocess(a) : a).catch(c);
1725
+ try {
1726
+ r.hooks && (t = r.hooks.preprocess(t));
1727
+ let a = l(t, r);
1728
+ r.hooks && (a = r.hooks.processAllTokens(a)), r.walkTokens && this.walkTokens(a, r.walkTokens);
1729
+ let o = u(a, r);
1730
+ return r.hooks && (o = r.hooks.postprocess(o)), o;
1731
+ } catch (a) {
1732
+ return c(a);
1733
+ }
1734
+ };
1735
+ }
1736
+ onError(n, e) {
1737
+ return (t) => {
1738
+ if (t.message += `
1739
+ Please report this to https://github.com/markedjs/marked.`, n) {
1740
+ const s = "<p>An error occurred:</p><pre>" + M(t.message + "", !0) + "</pre>";
1741
+ return e ? Promise.resolve(s) : s;
1742
+ }
1743
+ if (e)
1744
+ return Promise.reject(t);
1745
+ throw t;
1746
+ };
1747
+ }
1748
+ }, U = new on();
1749
+ function m(n, e) {
1750
+ return U.parse(n, e);
1751
+ }
1752
+ m.options = m.setOptions = function(n) {
1753
+ return U.setOptions(n), m.defaults = U.defaults, at(m.defaults), m;
1754
+ };
1755
+ m.getDefaults = Le;
1756
+ m.defaults = X;
1757
+ m.use = function(...n) {
1758
+ return U.use(...n), m.defaults = U.defaults, at(m.defaults), m;
1759
+ };
1760
+ m.walkTokens = function(n, e) {
1761
+ return U.walkTokens(n, e);
1762
+ };
1763
+ m.parseInline = U.parseInline;
1764
+ m.Parser = Q;
1765
+ m.parser = Q.parse;
1766
+ m.Renderer = we;
1767
+ m.TextRenderer = Oe;
1768
+ m.Lexer = F;
1769
+ m.lexer = F.lex;
1770
+ m.Tokenizer = xe;
1771
+ m.Hooks = me;
1772
+ m.parse = m;
1773
+ m.options;
1774
+ m.setOptions;
1775
+ m.use;
1776
+ m.walkTokens;
1777
+ m.parseInline;
1778
+ Q.parse;
1779
+ F.lex;
1780
+ const {
1781
+ HtmlTagHydration: cn,
1782
+ SvelteComponent: un,
1783
+ append_hydration: _,
1784
+ attr: y,
1785
+ children: L,
1786
+ claim_element: C,
1787
+ claim_html_tag: hn,
1788
+ claim_space: N,
1789
+ claim_text: te,
1790
+ destroy_each: pn,
1791
+ detach: x,
1792
+ element: T,
1793
+ ensure_array_like: Ke,
1794
+ flush: Z,
1795
+ get_svelte_dataset: K,
1796
+ init: fn,
1797
+ insert_hydration: D,
1798
+ noop: Ae,
1799
+ safe_not_equal: dn,
1800
+ set_data: ne,
1801
+ set_style: ge,
1802
+ space: O,
1803
+ text: se,
1804
+ toggle_class: ee
1805
+ } = window.__gradio__svelte__internal;
1806
+ function et(n, e, t) {
1807
+ const s = n.slice();
1808
+ return s[13] = e[t], s;
1809
+ }
1810
+ function tt(n) {
1811
+ let e, t = (
1812
+ /*loading_status*/
1813
+ (n[7].status === "pending" ? "Loading..." : (
1814
+ /*loading_status*/
1815
+ n[7].message || ""
1816
+ )) + ""
1817
+ ), s;
1818
+ return {
1819
+ c() {
1820
+ e = T("div"), s = se(t), this.h();
1821
+ },
1822
+ l(i) {
1823
+ e = C(i, "DIV", { class: !0 });
1824
+ var r = L(e);
1825
+ s = te(r, t), r.forEach(x), this.h();
1826
+ },
1827
+ h() {
1828
+ y(e, "class", "status-message svelte-1stw26d"), ee(
1829
+ e,
1830
+ "error",
1831
+ /*loading_status*/
1832
+ n[7].status === "error"
1833
+ );
1834
+ },
1835
+ m(i, r) {
1836
+ D(i, e, r), _(e, s);
1837
+ },
1838
+ p(i, r) {
1839
+ r & /*loading_status*/
1840
+ 128 && t !== (t = /*loading_status*/
1841
+ (i[7].status === "pending" ? "Loading..." : (
1842
+ /*loading_status*/
1843
+ i[7].message || ""
1844
+ )) + "") && ne(s, t), r & /*loading_status*/
1845
+ 128 && ee(
1846
+ e,
1847
+ "error",
1848
+ /*loading_status*/
1849
+ i[7].status === "error"
1850
+ );
1851
+ },
1852
+ d(i) {
1853
+ i && x(e);
1854
+ }
1855
+ };
1856
+ }
1857
+ function nt(n) {
1858
+ let e, t;
1859
+ return {
1860
+ c() {
1861
+ e = T("div"), t = se(
1862
+ /*label*/
1863
+ n[0]
1864
+ ), this.h();
1865
+ },
1866
+ l(s) {
1867
+ e = C(s, "DIV", { class: !0 });
1868
+ var i = L(e);
1869
+ t = te(
1870
+ i,
1871
+ /*label*/
1872
+ n[0]
1873
+ ), i.forEach(x), this.h();
1874
+ },
1875
+ h() {
1876
+ y(e, "class", "gradio-label");
1877
+ },
1878
+ m(s, i) {
1879
+ D(s, e, i), _(e, t);
1880
+ },
1881
+ p(s, i) {
1882
+ i & /*label*/
1883
+ 1 && ne(
1884
+ t,
1885
+ /*label*/
1886
+ s[0]
1887
+ );
1888
+ },
1889
+ d(s) {
1890
+ s && x(e);
1891
+ }
1892
+ };
1893
+ }
1894
+ function gn(n) {
1895
+ let e, t = "No analysis data to display.";
1896
+ return {
1897
+ c() {
1898
+ e = T("p"), e.textContent = t, this.h();
1899
+ },
1900
+ l(s) {
1901
+ e = C(s, "P", { class: !0, "data-svelte-h": !0 }), K(e) !== "svelte-1q8w132" && (e.textContent = t), this.h();
1902
+ },
1903
+ h() {
1904
+ y(e, "class", "svelte-1stw26d");
1905
+ },
1906
+ m(s, i) {
1907
+ D(s, e, i);
1908
+ },
1909
+ p: Ae,
1910
+ d(s) {
1911
+ s && x(e);
1912
+ }
1913
+ };
1914
+ }
1915
+ function kn(n) {
1916
+ let e, t, s = "Original Code:", i, r, c, l = (
1917
+ /*display_value*/
1918
+ n[8].code + ""
1919
+ ), u, a, o, p, h = "Issue:", d, f, k = (
1920
+ /*display_value*/
1921
+ n[8].issue + ""
1922
+ ), g, I, E, B, R = "Reason:", q, $, z = (
1923
+ /*display_value*/
1924
+ n[8].reason + ""
1925
+ ), j, W, H, G, J, Ze = "Feedback", ye, Y, ie, ue = m.parse(
1926
+ /*display_value*/
1927
+ n[8].feedback || ""
1928
+ ) + "", A = (
1929
+ /*display_value*/
1930
+ n[8].fixed_code && st(n)
1931
+ );
1932
+ return {
1933
+ c() {
1934
+ e = T("div"), t = T("h4"), t.textContent = s, i = O(), r = T("pre"), c = T("code"), u = se(l), a = O(), o = T("div"), p = T("h4"), p.textContent = h, d = O(), f = T("p"), g = se(k), I = O(), E = T("div"), B = T("h4"), B.textContent = R, q = O(), $ = T("p"), j = se(z), W = O(), A && A.c(), H = O(), G = T("div"), J = T("h3"), J.textContent = Ze, ye = O(), Y = T("div"), ie = new cn(!1), this.h();
1935
+ },
1936
+ l(b) {
1937
+ e = C(b, "DIV", { class: !0 });
1938
+ var S = L(e);
1939
+ t = C(S, "H4", { class: !0, "data-svelte-h": !0 }), K(t) !== "svelte-1y38fdw" && (t.textContent = s), i = N(S), r = C(S, "PRE", { class: !0 });
1940
+ var Me = L(r);
1941
+ c = C(Me, "CODE", { class: !0 });
1942
+ var He = L(c);
1943
+ u = te(He, l), He.forEach(x), Me.forEach(x), S.forEach(x), a = N(b), o = C(b, "DIV", { class: !0 });
1944
+ var he = L(o);
1945
+ p = C(he, "H4", { class: !0, "data-svelte-h": !0 }), K(p) !== "svelte-1663oc9" && (p.textContent = h), d = N(he), f = C(he, "P", { class: !0 });
1946
+ var Ge = L(f);
1947
+ g = te(Ge, k), Ge.forEach(x), he.forEach(x), I = N(b), E = C(b, "DIV", { class: !0 });
1948
+ var pe = L(E);
1949
+ B = C(pe, "H4", { class: !0, "data-svelte-h": !0 }), K(B) !== "svelte-14axvnc" && (B.textContent = R), q = N(pe), $ = C(pe, "P", { class: !0 });
1950
+ var Fe = L($);
1951
+ j = te(Fe, z), Fe.forEach(x), pe.forEach(x), W = N(b), A && A.l(b), H = N(b), G = C(b, "DIV", { class: !0 });
1952
+ var fe = L(G);
1953
+ J = C(fe, "H3", { "data-svelte-h": !0 }), K(J) !== "svelte-76jzqn" && (J.textContent = Ze), ye = N(fe), Y = C(fe, "DIV", { class: !0 });
1954
+ var Qe = L(Y);
1955
+ ie = hn(Qe, !1), Qe.forEach(x), fe.forEach(x), this.h();
1956
+ },
1957
+ h() {
1958
+ y(t, "class", "svelte-1stw26d"), y(c, "class", "svelte-1stw26d"), y(r, "class", "svelte-1stw26d"), y(e, "class", "analysis-section svelte-1stw26d"), y(p, "class", "svelte-1stw26d"), y(f, "class", "svelte-1stw26d"), y(o, "class", "analysis-section svelte-1stw26d"), y(B, "class", "svelte-1stw26d"), y($, "class", "svelte-1stw26d"), y(E, "class", "analysis-section svelte-1stw26d"), ie.a = null, y(Y, "class", "markdown-content svelte-1stw26d"), y(G, "class", "feedback-section svelte-1stw26d");
1959
+ },
1960
+ m(b, S) {
1961
+ D(b, e, S), _(e, t), _(e, i), _(e, r), _(r, c), _(c, u), D(b, a, S), D(b, o, S), _(o, p), _(o, d), _(o, f), _(f, g), D(b, I, S), D(b, E, S), _(E, B), _(E, q), _(E, $), _($, j), D(b, W, S), A && A.m(b, S), D(b, H, S), D(b, G, S), _(G, J), _(G, ye), _(G, Y), ie.m(ue, Y);
1962
+ },
1963
+ p(b, S) {
1964
+ S & /*display_value*/
1965
+ 256 && l !== (l = /*display_value*/
1966
+ b[8].code + "") && ne(u, l), S & /*display_value*/
1967
+ 256 && k !== (k = /*display_value*/
1968
+ b[8].issue + "") && ne(g, k), S & /*display_value*/
1969
+ 256 && z !== (z = /*display_value*/
1970
+ b[8].reason + "") && ne(j, z), /*display_value*/
1971
+ b[8].fixed_code ? A ? A.p(b, S) : (A = st(b), A.c(), A.m(H.parentNode, H)) : A && (A.d(1), A = null), S & /*display_value*/
1972
+ 256 && ue !== (ue = m.parse(
1973
+ /*display_value*/
1974
+ b[8].feedback || ""
1975
+ ) + "") && ie.p(ue);
1976
+ },
1977
+ d(b) {
1978
+ b && (x(e), x(a), x(o), x(I), x(E), x(W), x(H), x(G)), A && A.d(b);
1979
+ }
1980
+ };
1981
+ }
1982
+ function st(n) {
1983
+ let e, t, s = "Suggested Fix (Diff):", i, r, c = Ke(
1984
+ /*codeDiff*/
1985
+ n[9]
1986
+ ), l = [];
1987
+ for (let u = 0; u < c.length; u += 1)
1988
+ l[u] = it(et(n, c, u));
1989
+ return {
1990
+ c() {
1991
+ e = T("div"), t = T("h4"), t.textContent = s, i = O(), r = T("pre");
1992
+ for (let u = 0; u < l.length; u += 1)
1993
+ l[u].c();
1994
+ this.h();
1995
+ },
1996
+ l(u) {
1997
+ e = C(u, "DIV", { class: !0 });
1998
+ var a = L(e);
1999
+ t = C(a, "H4", { class: !0, "data-svelte-h": !0 }), K(t) !== "svelte-18sigz6" && (t.textContent = s), i = N(a), r = C(a, "PRE", { class: !0 });
2000
+ var o = L(r);
2001
+ for (let p = 0; p < l.length; p += 1)
2002
+ l[p].l(o);
2003
+ o.forEach(x), a.forEach(x), this.h();
2004
+ },
2005
+ h() {
2006
+ y(t, "class", "svelte-1stw26d"), y(r, "class", "diff-view svelte-1stw26d"), y(e, "class", "analysis-section svelte-1stw26d");
2007
+ },
2008
+ m(u, a) {
2009
+ D(u, e, a), _(e, t), _(e, i), _(e, r);
2010
+ for (let o = 0; o < l.length; o += 1)
2011
+ l[o] && l[o].m(r, null);
2012
+ },
2013
+ p(u, a) {
2014
+ if (a & /*codeDiff*/
2015
+ 512) {
2016
+ c = Ke(
2017
+ /*codeDiff*/
2018
+ u[9]
2019
+ );
2020
+ let o;
2021
+ for (o = 0; o < c.length; o += 1) {
2022
+ const p = et(u, c, o);
2023
+ l[o] ? l[o].p(p, a) : (l[o] = it(p), l[o].c(), l[o].m(r, null));
2024
+ }
2025
+ for (; o < l.length; o += 1)
2026
+ l[o].d(1);
2027
+ l.length = c.length;
2028
+ }
2029
+ },
2030
+ d(u) {
2031
+ u && x(e), pn(l, u);
2032
+ }
2033
+ };
2034
+ }
2035
+ function it(n) {
2036
+ let e, t = (
2037
+ /*part*/
2038
+ n[13].value + ""
2039
+ ), s, i;
2040
+ return {
2041
+ c() {
2042
+ e = T("span"), s = se(t), this.h();
2043
+ },
2044
+ l(r) {
2045
+ e = C(r, "SPAN", { class: !0 });
2046
+ var c = L(e);
2047
+ s = te(c, t), c.forEach(x), this.h();
2048
+ },
2049
+ h() {
2050
+ y(e, "class", i = "diff-part " + /*part*/
2051
+ (n[13].added ? "added" : (
2052
+ /*part*/
2053
+ n[13].removed ? "removed" : "common"
2054
+ )) + " svelte-1stw26d");
2055
+ },
2056
+ m(r, c) {
2057
+ D(r, e, c), _(e, s);
2058
+ },
2059
+ p(r, c) {
2060
+ c & /*codeDiff*/
2061
+ 512 && t !== (t = /*part*/
2062
+ r[13].value + "") && ne(s, t), c & /*codeDiff*/
2063
+ 512 && i !== (i = "diff-part " + /*part*/
2064
+ (r[13].added ? "added" : (
2065
+ /*part*/
2066
+ r[13].removed ? "removed" : "common"
2067
+ )) + " svelte-1stw26d") && y(e, "class", i);
2068
+ },
2069
+ d(r) {
2070
+ r && x(e);
2071
+ }
2072
+ };
2073
+ }
2074
+ function mn(n) {
2075
+ let e, t, s, i, r, c = (
2076
+ /*loading_status*/
2077
+ n[7] && tt(n)
2078
+ ), l = (
2079
+ /*show_label*/
2080
+ n[4] && nt(n)
2081
+ );
2082
+ function u(p, h) {
2083
+ return (
2084
+ /*display_value*/
2085
+ p[8] ? kn : gn
2086
+ );
2087
+ }
2088
+ let a = u(n), o = a(n);
2089
+ return {
2090
+ c() {
2091
+ e = T("div"), c && c.c(), t = O(), s = T("div"), l && l.c(), i = O(), o.c(), this.h();
2092
+ },
2093
+ l(p) {
2094
+ e = C(p, "DIV", { class: !0, id: !0, style: !0 });
2095
+ var h = L(e);
2096
+ c && c.l(h), t = N(h), s = C(h, "DIV", { class: !0 });
2097
+ var d = L(s);
2098
+ l && l.l(d), i = N(d), o.l(d), d.forEach(x), h.forEach(x), this.h();
2099
+ },
2100
+ h() {
2101
+ y(s, "class", "code-analysis-viewer svelte-1stw26d"), y(e, "class", "gradio-container"), y(e, "id", r = /*elem_id*/
2102
+ n[1] || null), ge(
2103
+ e,
2104
+ "width",
2105
+ /*scale*/
2106
+ n[5] || "auto"
2107
+ ), ge(
2108
+ e,
2109
+ "min-width",
2110
+ /*min_width*/
2111
+ n[6] + "px"
2112
+ ), ee(e, "hidden", !/*visible*/
2113
+ n[3]), ee(
2114
+ e,
2115
+ "block",
2116
+ /*elem_classes*/
2117
+ n[2].includes("block")
2118
+ );
2119
+ },
2120
+ m(p, h) {
2121
+ D(p, e, h), c && c.m(e, null), _(e, t), _(e, s), l && l.m(s, null), _(s, i), o.m(s, null);
2122
+ },
2123
+ p(p, [h]) {
2124
+ /*loading_status*/
2125
+ p[7] ? c ? c.p(p, h) : (c = tt(p), c.c(), c.m(e, t)) : c && (c.d(1), c = null), /*show_label*/
2126
+ p[4] ? l ? l.p(p, h) : (l = nt(p), l.c(), l.m(s, i)) : l && (l.d(1), l = null), a === (a = u(p)) && o ? o.p(p, h) : (o.d(1), o = a(p), o && (o.c(), o.m(s, null))), h & /*elem_id*/
2127
+ 2 && r !== (r = /*elem_id*/
2128
+ p[1] || null) && y(e, "id", r), h & /*scale*/
2129
+ 32 && ge(
2130
+ e,
2131
+ "width",
2132
+ /*scale*/
2133
+ p[5] || "auto"
2134
+ ), h & /*min_width*/
2135
+ 64 && ge(
2136
+ e,
2137
+ "min-width",
2138
+ /*min_width*/
2139
+ p[6] + "px"
2140
+ ), h & /*visible*/
2141
+ 8 && ee(e, "hidden", !/*visible*/
2142
+ p[3]), h & /*elem_classes*/
2143
+ 4 && ee(
2144
+ e,
2145
+ "block",
2146
+ /*elem_classes*/
2147
+ p[2].includes("block")
2148
+ );
2149
+ },
2150
+ i: Ae,
2151
+ o: Ae,
2152
+ d(p) {
2153
+ p && x(e), c && c.d(), l && l.d(), o.d();
2154
+ }
2155
+ };
2156
+ }
2157
+ function bn(n, e, t) {
2158
+ let s;
2159
+ m.setOptions({
2160
+ breaks: !0,
2161
+ // Convert line breaks to <br>
2162
+ gfm: !0
2163
+ // Use GitHub Flavored Markdown
2164
+ });
2165
+ let { gradio: i } = e, { label: r = "Code Analysis" } = e, { elem_id: c = "" } = e, { elem_classes: l = [] } = e, { visible: u = !0 } = e, { value: a = null } = e, { show_label: o = !0 } = e, { scale: p = null } = e, { min_width: h = void 0 } = e, { loading_status: d = void 0 } = e;
2166
+ const f = {
2167
+ code: "// No code provided",
2168
+ issue: "No issues to display.",
2169
+ reason: "N/A",
2170
+ fixed_code: null,
2171
+ feedback: "No feedback available."
2172
+ };
2173
+ let k = [];
2174
+ return n.$$set = (g) => {
2175
+ "gradio" in g && t(10, i = g.gradio), "label" in g && t(0, r = g.label), "elem_id" in g && t(1, c = g.elem_id), "elem_classes" in g && t(2, l = g.elem_classes), "visible" in g && t(3, u = g.visible), "value" in g && t(11, a = g.value), "show_label" in g && t(4, o = g.show_label), "scale" in g && t(5, p = g.scale), "min_width" in g && t(6, h = g.min_width), "loading_status" in g && t(7, d = g.loading_status);
2176
+ }, n.$$.update = () => {
2177
+ n.$$.dirty & /*value, gradio*/
2178
+ 3072 && a && i.dispatch("change", a), n.$$.dirty & /*value*/
2179
+ 2048 && t(8, s = a || f), n.$$.dirty & /*display_value*/
2180
+ 256 && (s && s.code && s.fixed_code ? t(9, k = _t(s.code, s.fixed_code)) : t(9, k = []));
2181
+ }, [
2182
+ r,
2183
+ c,
2184
+ l,
2185
+ u,
2186
+ o,
2187
+ p,
2188
+ h,
2189
+ d,
2190
+ s,
2191
+ k,
2192
+ i,
2193
+ a
2194
+ ];
2195
+ }
2196
+ class wn extends un {
2197
+ constructor(e) {
2198
+ super(), fn(this, e, bn, mn, dn, {
2199
+ gradio: 10,
2200
+ label: 0,
2201
+ elem_id: 1,
2202
+ elem_classes: 2,
2203
+ visible: 3,
2204
+ value: 11,
2205
+ show_label: 4,
2206
+ scale: 5,
2207
+ min_width: 6,
2208
+ loading_status: 7
2209
+ });
2210
+ }
2211
+ get gradio() {
2212
+ return this.$$.ctx[10];
2213
+ }
2214
+ set gradio(e) {
2215
+ this.$$set({ gradio: e }), Z();
2216
+ }
2217
+ get label() {
2218
+ return this.$$.ctx[0];
2219
+ }
2220
+ set label(e) {
2221
+ this.$$set({ label: e }), Z();
2222
+ }
2223
+ get elem_id() {
2224
+ return this.$$.ctx[1];
2225
+ }
2226
+ set elem_id(e) {
2227
+ this.$$set({ elem_id: e }), Z();
2228
+ }
2229
+ get elem_classes() {
2230
+ return this.$$.ctx[2];
2231
+ }
2232
+ set elem_classes(e) {
2233
+ this.$$set({ elem_classes: e }), Z();
2234
+ }
2235
+ get visible() {
2236
+ return this.$$.ctx[3];
2237
+ }
2238
+ set visible(e) {
2239
+ this.$$set({ visible: e }), Z();
2240
+ }
2241
+ get value() {
2242
+ return this.$$.ctx[11];
2243
+ }
2244
+ set value(e) {
2245
+ this.$$set({ value: e }), Z();
2246
+ }
2247
+ get show_label() {
2248
+ return this.$$.ctx[4];
2249
+ }
2250
+ set show_label(e) {
2251
+ this.$$set({ show_label: e }), Z();
2252
+ }
2253
+ get scale() {
2254
+ return this.$$.ctx[5];
2255
+ }
2256
+ set scale(e) {
2257
+ this.$$set({ scale: e }), Z();
2258
+ }
2259
+ get min_width() {
2260
+ return this.$$.ctx[6];
2261
+ }
2262
+ set min_width(e) {
2263
+ this.$$set({ min_width: e }), Z();
2264
+ }
2265
+ get loading_status() {
2266
+ return this.$$.ctx[7];
2267
+ }
2268
+ set loading_status(e) {
2269
+ this.$$set({ loading_status: e }), Z();
2270
+ }
2271
+ }
2272
+ export {
2273
+ wn as default
2274
+ };
src/backend/gradio_codeanalysisviewer/templates/component/style.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .code-analysis-viewer.svelte-1stw26d.svelte-1stw26d{font-family:var(--font-mono, monospace);font-size:var(--text-sm, 14px);color:var(--body-text-color, #333);border:1px solid var(--border-color-primary, #e0e0e0);border-radius:var(--radius-lg, 8px);padding:var(--spacing-lg, 16px);background-color:var(--background-fill-primary, #f9f9f9)}.analysis-section.svelte-1stw26d.svelte-1stw26d{margin-bottom:var(--spacing-lg, 16px);padding-bottom:var(--spacing-md, 12px);border-bottom:1px solid var(--border-color-secondary, #eee)}.analysis-section.svelte-1stw26d.svelte-1stw26d:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.analysis-section.svelte-1stw26d h4.svelte-1stw26d{font-weight:var(--font-weight-semibold, 600);color:var(--text-color-strong, #222);margin-top:0;margin-bottom:var(--spacing-sm, 8px);font-size:var(--text-md, 16px)}pre.svelte-1stw26d.svelte-1stw26d{background-color:var(--background-fill-secondary, #f0f0f0);padding:var(--spacing-md, 12px);border-radius:var(--radius-md, 6px);overflow-x:auto;white-space:pre-wrap;word-wrap:break-word}code.svelte-1stw26d.svelte-1stw26d{font-family:var(--font-mono, monospace)}p.svelte-1stw26d.svelte-1stw26d{line-height:1.6;margin-top:0;margin-bottom:4px}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;line-height:1.6;color:#333;overflow-wrap:break-word;word-break:break-word;max-width:100%}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d p{margin-bottom:8px}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d ul,.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d ol{padding-left:20px;margin-bottom:8px}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d li{margin-bottom:4px}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d code{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;background-color:#e6f3ff;padding:2px 4px;border-radius:4px;font-size:.9em}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d pre{background-color:#f0f0f0;padding:12px;border-radius:6px;overflow-x:auto;margin-bottom:12px}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d pre code{background-color:transparent;padding:0;border-radius:0}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h1,.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h2,.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h3,.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h4,.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h5,.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h6{margin-top:16px;margin-bottom:12px;font-weight:600;line-height:1.25;color:#111}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h3{font-size:1.25rem}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d h4{font-size:1.1rem}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d a{color:#3b82f6;text-decoration:none}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d a:hover{text-decoration:underline}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d blockquote{padding:12px 16px;margin:12px 0;border-left:4px solid #3B82F6;background-color:#f5f5f5;color:#555}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d hr{height:1px;background-color:#e0e0e0;border:none;margin:16px 0}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d table{border-collapse:collapse;width:100%;margin:12px 0}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d th,.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d td{border:1px solid #eee;padding:8px;text-align:left}.feedback-section.svelte-1stw26d .markdown-content.svelte-1stw26d th{background-color:#f0f0f0;font-weight:600}.diff-view.svelte-1stw26d.svelte-1stw26d{white-space:pre-wrap;word-wrap:break-word;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;background-color:#f0f0f0;padding:12px;border-radius:6px;overflow-x:auto}.status-message.svelte-1stw26d.svelte-1stw26d{padding:12px;margin-bottom:12px;border-radius:6px;background-color:#f0f0f0}.status-message.error.svelte-1stw26d.svelte-1stw26d{background-color:#ffe6e6;color:#8b0000}.diff-part.added.svelte-1stw26d.svelte-1stw26d{background-color:#cbe1d1;color:#006400}.diff-part.removed.svelte-1stw26d.svelte-1stw26d{background-color:#ffebe9;color:#b30000;text-decoration:line-through}.diff-part.common.svelte-1stw26d.svelte-1stw26d{color:#333;background-color:#fcfcfc;padding:0 2px}
src/backend/gradio_codeanalysisviewer/templates/example/index.js ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const {
2
+ SvelteComponent: h,
3
+ add_iframe_resize_listener: g,
4
+ add_render_callback: v,
5
+ append_hydration: y,
6
+ attr: b,
7
+ binding_callbacks: m,
8
+ children: w,
9
+ claim_element: z,
10
+ claim_text: k,
11
+ detach: c,
12
+ element: p,
13
+ init: E,
14
+ insert_hydration: S,
15
+ noop: o,
16
+ safe_not_equal: q,
17
+ set_data: C,
18
+ text: D,
19
+ toggle_class: _
20
+ } = window.__gradio__svelte__internal, { onMount: I } = window.__gradio__svelte__internal;
21
+ function M(t) {
22
+ let e, i = (
23
+ /*value*/
24
+ (t[0] ? (
25
+ /*value*/
26
+ t[0]
27
+ ) : "") + ""
28
+ ), s, d;
29
+ return {
30
+ c() {
31
+ e = p("div"), s = D(i), this.h();
32
+ },
33
+ l(l) {
34
+ e = z(l, "DIV", { class: !0 });
35
+ var n = w(e);
36
+ s = k(n, i), n.forEach(c), this.h();
37
+ },
38
+ h() {
39
+ b(e, "class", "svelte-84cxb8"), v(() => (
40
+ /*div_elementresize_handler*/
41
+ t[5].call(e)
42
+ )), _(
43
+ e,
44
+ "table",
45
+ /*type*/
46
+ t[1] === "table"
47
+ ), _(
48
+ e,
49
+ "gallery",
50
+ /*type*/
51
+ t[1] === "gallery"
52
+ ), _(
53
+ e,
54
+ "selected",
55
+ /*selected*/
56
+ t[2]
57
+ );
58
+ },
59
+ m(l, n) {
60
+ S(l, e, n), y(e, s), d = g(
61
+ e,
62
+ /*div_elementresize_handler*/
63
+ t[5].bind(e)
64
+ ), t[6](e);
65
+ },
66
+ p(l, [n]) {
67
+ n & /*value*/
68
+ 1 && i !== (i = /*value*/
69
+ (l[0] ? (
70
+ /*value*/
71
+ l[0]
72
+ ) : "") + "") && C(s, i), n & /*type*/
73
+ 2 && _(
74
+ e,
75
+ "table",
76
+ /*type*/
77
+ l[1] === "table"
78
+ ), n & /*type*/
79
+ 2 && _(
80
+ e,
81
+ "gallery",
82
+ /*type*/
83
+ l[1] === "gallery"
84
+ ), n & /*selected*/
85
+ 4 && _(
86
+ e,
87
+ "selected",
88
+ /*selected*/
89
+ l[2]
90
+ );
91
+ },
92
+ i: o,
93
+ o,
94
+ d(l) {
95
+ l && c(e), d(), t[6](null);
96
+ }
97
+ };
98
+ }
99
+ function P(t, e) {
100
+ t.style.setProperty("--local-text-width", `${e && e < 150 ? e : 200}px`), t.style.whiteSpace = "unset";
101
+ }
102
+ function V(t, e, i) {
103
+ let { value: s } = e, { type: d } = e, { selected: l = !1 } = e, n, r;
104
+ I(() => {
105
+ P(r, n);
106
+ });
107
+ function u() {
108
+ n = this.clientWidth, i(3, n);
109
+ }
110
+ function f(a) {
111
+ m[a ? "unshift" : "push"](() => {
112
+ r = a, i(4, r);
113
+ });
114
+ }
115
+ return t.$$set = (a) => {
116
+ "value" in a && i(0, s = a.value), "type" in a && i(1, d = a.type), "selected" in a && i(2, l = a.selected);
117
+ }, [s, d, l, n, r, u, f];
118
+ }
119
+ class W extends h {
120
+ constructor(e) {
121
+ super(), E(this, e, V, M, q, { value: 0, type: 1, selected: 2 });
122
+ }
123
+ }
124
+ export {
125
+ W as default
126
+ };
src/backend/gradio_codeanalysisviewer/templates/example/style.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .gallery.svelte-84cxb8{padding:var(--size-1) var(--size-2)}div.svelte-84cxb8{overflow:hidden;min-width:var(--local-text-width);white-space:nowrap}
src/demo/.gradio/flagged/dataset1.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Input Analysis (Interactive - if it were input),Code Analysis Output,timestamp
2
+ ,,2025-06-10 00:16:38.620220
src/demo/__init__.py ADDED
File without changes
src/demo/app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from gradio_codeanalysisviewer import CodeAnalysisViewer
4
+
5
+
6
+ # Prepare an example dictionary matching the OutputSchema structure
7
+ example_data = {
8
+ "code": "def greet(name):\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
9
+ "issue": "Security Risk: Use of f-string in print might be risky if 'name' is user-controlled and not sanitized.",
10
+ "reason": "Formatted string literals (f-strings) can be vulnerable to injection if they include unsanitized user input, though in this specific 'print' case, the direct risk is low unless the output is piped elsewhere or has special terminal interpretations.",
11
+ "fixed_code": "def greet(name):\n # Sanitize name if it comes from an external source, e.g., name = escape(name)\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
12
+ "feedback": "#### Security Feedback:\n* **Issue**: Potential for injection with f-string.\n* **Severity**: Low (in this context).\n* **Recommendation**: Always sanitize external inputs used in f-strings, especially if they are logged or displayed in sensitive contexts. For simple printing, the risk is minimal.\n\n#### Documentation Feedback:\n* The function `greet` is missing a docstring.\n* Consider adding type hints."
13
+ }
14
+
15
+ # Use the example_value from the component itself for the examples list
16
+ # This ensures we're using the structure defined within the component's backend
17
+ component_example = CodeAnalysisViewer().example_value()
18
+
19
+ demo = gr.Interface(
20
+ lambda data_dict: data_dict, # The function now expects and returns a dictionary
21
+ CodeAnalysisViewer(label="Input Analysis (Interactive - if it were input)"), # This would be for input, not our primary use case
22
+ CodeAnalysisViewer(label="Code Analysis Output"), # This is how we'll use it as an output display
23
+ examples=[[component_example], [example_data]] # Provide examples
24
+ )
25
+
26
+
27
+ if __name__ == "__main__":
28
+ demo.launch()
src/demo/css.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ font-family: Inter;
3
+ font-size: 16px;
4
+ font-weight: 400;
5
+ line-height: 1.5;
6
+ -webkit-text-size-adjust: 100%;
7
+ background: #fff;
8
+ color: #323232;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ text-rendering: optimizeLegibility;
12
+ }
13
+
14
+ :root {
15
+ --space: 1;
16
+ --vspace: calc(var(--space) * 1rem);
17
+ --vspace-0: calc(3 * var(--space) * 1rem);
18
+ --vspace-1: calc(2 * var(--space) * 1rem);
19
+ --vspace-2: calc(1.5 * var(--space) * 1rem);
20
+ --vspace-3: calc(0.5 * var(--space) * 1rem);
21
+ }
22
+
23
+ .app {
24
+ max-width: 748px !important;
25
+ }
26
+
27
+ .prose p {
28
+ margin: var(--vspace) 0;
29
+ line-height: var(--vspace * 2);
30
+ font-size: 1rem;
31
+ }
32
+
33
+ code {
34
+ font-family: "Inconsolata", sans-serif;
35
+ font-size: 16px;
36
+ }
37
+
38
+ h1,
39
+ h1 code {
40
+ font-weight: 400;
41
+ line-height: calc(2.5 / var(--space) * var(--vspace));
42
+ }
43
+
44
+ h1 code {
45
+ background: none;
46
+ border: none;
47
+ letter-spacing: 0.05em;
48
+ padding-bottom: 5px;
49
+ position: relative;
50
+ padding: 0;
51
+ }
52
+
53
+ h2 {
54
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
55
+ line-height: 1em;
56
+ }
57
+
58
+ h3,
59
+ h3 code {
60
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
61
+ line-height: 1em;
62
+ }
63
+
64
+ h4,
65
+ h5,
66
+ h6 {
67
+ margin: var(--vspace-3) 0 var(--vspace-3) 0;
68
+ line-height: var(--vspace);
69
+ }
70
+
71
+ .bigtitle,
72
+ h1,
73
+ h1 code {
74
+ font-size: calc(8px * 4.5);
75
+ word-break: break-word;
76
+ }
77
+
78
+ .title,
79
+ h2,
80
+ h2 code {
81
+ font-size: calc(8px * 3.375);
82
+ font-weight: lighter;
83
+ word-break: break-word;
84
+ border: none;
85
+ background: none;
86
+ }
87
+
88
+ .subheading1,
89
+ h3,
90
+ h3 code {
91
+ font-size: calc(8px * 1.8);
92
+ font-weight: 600;
93
+ border: none;
94
+ background: none;
95
+ letter-spacing: 0.1em;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ h2 code {
100
+ padding: 0;
101
+ position: relative;
102
+ letter-spacing: 0.05em;
103
+ }
104
+
105
+ blockquote {
106
+ font-size: calc(8px * 1.1667);
107
+ font-style: italic;
108
+ line-height: calc(1.1667 * var(--vspace));
109
+ margin: var(--vspace-2) var(--vspace-2);
110
+ }
111
+
112
+ .subheading2,
113
+ h4 {
114
+ font-size: calc(8px * 1.4292);
115
+ text-transform: uppercase;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .subheading3,
120
+ h5 {
121
+ font-size: calc(8px * 1.2917);
122
+ line-height: calc(1.2917 * var(--vspace));
123
+
124
+ font-weight: lighter;
125
+ text-transform: uppercase;
126
+ letter-spacing: 0.15em;
127
+ }
128
+
129
+ h6 {
130
+ font-size: calc(8px * 1.1667);
131
+ font-size: 1.1667em;
132
+ font-weight: normal;
133
+ font-style: italic;
134
+ font-family: "le-monde-livre-classic-byol", serif !important;
135
+ letter-spacing: 0px !important;
136
+ }
137
+
138
+ #start .md > *:first-child {
139
+ margin-top: 0;
140
+ }
141
+
142
+ h2 + h3 {
143
+ margin-top: 0;
144
+ }
145
+
146
+ .md hr {
147
+ border: none;
148
+ border-top: 1px solid var(--block-border-color);
149
+ margin: var(--vspace-2) 0 var(--vspace-2) 0;
150
+ }
151
+ .prose ul {
152
+ margin: var(--vspace-2) 0 var(--vspace-1) 0;
153
+ }
154
+
155
+ .gap {
156
+ gap: 0;
157
+ }
src/demo/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio_codeanalysisviewer
src/demo/space.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from app import demo as app
4
+ import os
5
+
6
+ _docs = {'CodeAnalysisViewer': {'description': 'A custom Gradio component to display code analysis results in a structured format.\nIt expects a dictionary matching the OutputSchema structure as its value.', 'members': {'__init__': {'value': {'type': 'dict | Callable | None', 'default': 'None', 'description': 'default text to provide in textbox. If a function is provided, the function will be called each time the app loads to set the initial value of this component.'}, 'placeholder': {'type': 'str | None', 'default': 'None', 'description': 'placeholder hint to provide behind textbox.'}, 'label': {'type': 'str | I18nData | None', 'default': 'None', 'description': 'the label for this component, displayed above the component if `show_label` is `True` and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component corresponds to.'}, 'every': {'type': 'Timer | float | None', 'default': 'None', 'description': 'Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.'}, 'inputs': {'type': 'Component | Sequence[Component] | set[Component] | None', 'default': 'None', 'description': 'Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'key': {'type': 'int | str | tuple[int | str, ...] | None', 'default': 'None', 'description': "in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render."}, 'preserved_by_key': {'type': 'list[str] | str | None', 'default': '"value"', 'description': "A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor."}}, 'postprocess': {'value': {'type': 'dict | None', 'description': 'Expects a dictionary (OutputSchema) from the backend function.'}}, 'preprocess': {'return': {'type': 'dict | None', 'description': 'The payload to be used in the backend function.'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the CodeAnalysisViewer changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'input': {'type': None, 'default': None, 'description': 'This listener is triggered when the user changes the value of the CodeAnalysisViewer.'}, 'submit': {'type': None, 'default': None, 'description': 'This listener is triggered when the user presses the Enter key while the CodeAnalysisViewer is focused.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'CodeAnalysisViewer': []}}}
7
+
8
+ abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
+
10
+ with gr.Blocks(
11
+ css=abs_path,
12
+ theme=gr.themes.Default(
13
+ font_mono=[
14
+ gr.themes.GoogleFont("Inconsolata"),
15
+ "monospace",
16
+ ],
17
+ ),
18
+ ) as demo:
19
+ gr.Markdown(
20
+ """
21
+ # `gradio_codeanalysisviewer`
22
+
23
+ <div style="display: flex; gap: 7px;">
24
+ <a href="https://pypi.org/project/gradio_codeanalysisviewer/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_codeanalysisviewer"></a>
25
+ </div>
26
+
27
+ A nicer view to show the Agentic code analyser outputs
28
+ """, elem_classes=["md-custom"], header_links=True)
29
+ app.render()
30
+ gr.Markdown(
31
+ """
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gradio_codeanalysisviewer
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+
42
+ import gradio as gr
43
+ from gradio_codeanalysisviewer import CodeAnalysisViewer
44
+
45
+
46
+ # Prepare an example dictionary matching the OutputSchema structure
47
+ example_data = {
48
+ "code": "def greet(name):\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
49
+ "issue": "Security Risk: Use of f-string in print might be risky if 'name' is user-controlled and not sanitized.",
50
+ "reason": "Formatted string literals (f-strings) can be vulnerable to injection if they include unsanitized user input, though in this specific 'print' case, the direct risk is low unless the output is piped elsewhere or has special terminal interpretations.",
51
+ "fixed_code": "def greet(name):\n # Sanitize name if it comes from an external source, e.g., name = escape(name)\n print(f\"Hello, {name}!\")\n\ngreet(\"User\")",
52
+ "feedback": "#### Security Feedback:\n* **Issue**: Potential for injection with f-string.\n* **Severity**: Low (in this context).\n* **Recommendation**: Always sanitize external inputs used in f-strings, especially if they are logged or displayed in sensitive contexts. For simple printing, the risk is minimal.\n\n#### Documentation Feedback:\n* The function `greet` is missing a docstring.\n* Consider adding type hints."
53
+ }
54
+
55
+ # Use the example_value from the component itself for the examples list
56
+ # This ensures we're using the structure defined within the component's backend
57
+ component_example = CodeAnalysisViewer().example_value()
58
+
59
+ demo = gr.Interface(
60
+ lambda data_dict: data_dict, # The function now expects and returns a dictionary
61
+ CodeAnalysisViewer(label="Input Analysis (Interactive - if it were input)"), # This would be for input, not our primary use case
62
+ CodeAnalysisViewer(label="Code Analysis Output"), # This is how we'll use it as an output display
63
+ examples=[[component_example], [example_data]] # Provide examples
64
+ )
65
+
66
+
67
+ if __name__ == "__main__":
68
+ demo.launch()
69
+
70
+ ```
71
+ """, elem_classes=["md-custom"], header_links=True)
72
+
73
+
74
+ gr.Markdown("""
75
+ ## `CodeAnalysisViewer`
76
+
77
+ ### Initialization
78
+ """, elem_classes=["md-custom"], header_links=True)
79
+
80
+ gr.ParamViewer(value=_docs["CodeAnalysisViewer"]["members"]["__init__"], linkify=[])
81
+
82
+
83
+ gr.Markdown("### Events")
84
+ gr.ParamViewer(value=_docs["CodeAnalysisViewer"]["events"], linkify=['Event'])
85
+
86
+
87
+
88
+
89
+ gr.Markdown("""
90
+
91
+ ### User function
92
+
93
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
94
+
95
+ - When used as an Input, the component only impacts the input signature of the user function.
96
+ - When used as an output, the component only impacts the return signature of the user function.
97
+
98
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
99
+
100
+ - **As input:** Is passed, the payload to be used in the backend function.
101
+ - **As output:** Should return, expects a dictionary (OutputSchema) from the backend function.
102
+
103
+ ```python
104
+ def predict(
105
+ value: dict | None
106
+ ) -> dict | None:
107
+ return value
108
+ ```
109
+ """, elem_classes=["md-custom", "CodeAnalysisViewer-user-fn"], header_links=True)
110
+
111
+
112
+
113
+
114
+ demo.load(None, js=r"""function() {
115
+ const refs = {};
116
+ const user_fn_refs = {
117
+ CodeAnalysisViewer: [], };
118
+ requestAnimationFrame(() => {
119
+
120
+ Object.entries(user_fn_refs).forEach(([key, refs]) => {
121
+ if (refs.length > 0) {
122
+ const el = document.querySelector(`.${key}-user-fn`);
123
+ if (!el) return;
124
+ refs.forEach(ref => {
125
+ el.innerHTML = el.innerHTML.replace(
126
+ new RegExp("\\b"+ref+"\\b", "g"),
127
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
128
+ );
129
+ })
130
+ }
131
+ })
132
+
133
+ Object.entries(refs).forEach(([key, refs]) => {
134
+ if (refs.length > 0) {
135
+ const el = document.querySelector(`.${key}`);
136
+ if (!el) return;
137
+ refs.forEach(ref => {
138
+ el.innerHTML = el.innerHTML.replace(
139
+ new RegExp("\\b"+ref+"\\b", "g"),
140
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
141
+ );
142
+ })
143
+ }
144
+ })
145
+ })
146
+ }
147
+
148
+ """)
149
+
150
+ demo.launch()
src/frontend/.DS_Store ADDED
Binary file (6.15 kB). View file
 
src/frontend/Example.svelte ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { onMount } from "svelte";
3
+
4
+ export let value: string | null;
5
+ export let type: "gallery" | "table";
6
+ export let selected = false;
7
+
8
+ let size: number;
9
+ let el: HTMLDivElement;
10
+
11
+ function set_styles(element: HTMLElement, el_width: number): void {
12
+ element.style.setProperty(
13
+ "--local-text-width",
14
+ `${el_width && el_width < 150 ? el_width : 200}px`
15
+ );
16
+ element.style.whiteSpace = "unset";
17
+ }
18
+
19
+ onMount(() => {
20
+ set_styles(el, size);
21
+ });
22
+ </script>
23
+
24
+ <div
25
+ bind:clientWidth={size}
26
+ bind:this={el}
27
+ class:table={type === "table"}
28
+ class:gallery={type === "gallery"}
29
+ class:selected
30
+ >
31
+ {value ? value : ""}
32
+ </div>
33
+
34
+ <style>
35
+ .gallery {
36
+ padding: var(--size-1) var(--size-2);
37
+ }
38
+
39
+ div {
40
+ overflow: hidden;
41
+ min-width: var(--local-text-width);
42
+
43
+ white-space: nowrap;
44
+ }
45
+ </style>
src/frontend/Index.svelte ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svelte:options accessors={true} />
2
+
3
+ <script lang="ts">
4
+ import type { Gradio } from "@gradio/utils";
5
+ import type { LoadingStatus } from "@gradio/statustracker";
6
+ import { diffChars } from 'diff';
7
+ import { marked } from 'marked';
8
+
9
+ // Configure marked options for safe and proper rendering
10
+ marked.setOptions({
11
+ breaks: true, // Convert line breaks to <br>
12
+ gfm: true // Use GitHub Flavored Markdown
13
+ });
14
+
15
+ // Define the expected structure of the 'value' prop based on OutputSchema
16
+ interface OutputSchema {
17
+ code: string;
18
+ issue: string;
19
+ reason: string;
20
+ fixed_code?: string | null;
21
+ feedback: string;
22
+ }
23
+
24
+ export let gradio: Gradio<{
25
+ change: OutputSchema; // The component will dispatch the full object on change
26
+ clear_status: LoadingStatus;
27
+ }>;
28
+
29
+ export let label = "Code Analysis";
30
+ export let elem_id = "";
31
+ export let elem_classes: string[] = [];
32
+ export let visible = true;
33
+ export let value: OutputSchema | null = null; // This is the main data prop
34
+ export let show_label: boolean = true;
35
+ export let scale: number | null = null;
36
+ export let min_width: number | undefined = undefined;
37
+ export let loading_status: LoadingStatus | undefined = undefined;
38
+ // interactive property removed as unused
39
+
40
+ // Reactive statement to dispatch change when value updates
41
+ $: if (value) {
42
+ gradio.dispatch("change", value);
43
+ }
44
+
45
+ // Default empty state or placeholder if value is null
46
+ const default_value: OutputSchema = {
47
+ code: "// No code provided",
48
+ issue: "No issues to display.",
49
+ reason: "N/A",
50
+ fixed_code: null,
51
+ feedback: "No feedback available."
52
+ };
53
+
54
+ $: display_value = value || default_value;
55
+
56
+ // Reactive declaration for code diff
57
+ let codeDiff = [];
58
+ $: {
59
+ if (display_value && display_value.code && display_value.fixed_code) {
60
+ codeDiff = diffChars(display_value.code, display_value.fixed_code);
61
+ } else {
62
+ codeDiff = [];
63
+ }
64
+ }
65
+
66
+ </script>
67
+
68
+ <div
69
+ class="gradio-container"
70
+ class:hidden={!visible}
71
+ id={elem_id || null}
72
+ class:block={elem_classes.includes('block')}
73
+ style="width: {scale || 'auto'}; min-width: {min_width}px"
74
+ >
75
+ {#if loading_status}
76
+ <!-- StatusTracker component removed due to compatibility issues with Gradio 5.x -->
77
+ <div class="status-message" class:error={loading_status.status === "error"}>
78
+ {loading_status.status === "pending" ? "Loading..." : loading_status.message || ""}
79
+ </div>
80
+ {/if}
81
+
82
+ <div class="code-analysis-viewer">
83
+ {#if show_label}
84
+ <div class="gradio-label">{label}</div>
85
+ {/if}
86
+
87
+ {#if display_value}
88
+ <div class="analysis-section">
89
+ <h4>Original Code:</h4>
90
+ <pre><code>{display_value.code}</code></pre>
91
+ </div>
92
+
93
+ <div class="analysis-section">
94
+ <h4>Issue:</h4>
95
+ <p>{display_value.issue}</p>
96
+ </div>
97
+
98
+ <div class="analysis-section">
99
+ <h4>Reason:</h4>
100
+ <p>{display_value.reason}</p>
101
+ </div>
102
+
103
+ {#if display_value.fixed_code}
104
+ <div class="analysis-section">
105
+ <h4>Suggested Fix (Diff):</h4>
106
+ <pre class="diff-view">{#each codeDiff as part}<!--
107
+ --><span class="diff-part {part.added ? 'added' : (part.removed ? 'removed' : 'common')}">{part.value}</span><!--
108
+ -->{/each}</pre>
109
+ </div>
110
+ {/if}
111
+
112
+ <div class="feedback-section">
113
+ <h3>Feedback</h3>
114
+ <div class="markdown-content">
115
+ {@html marked.parse(display_value.feedback || '')}
116
+ </div>
117
+ </div>
118
+ {:else}
119
+ <p>No analysis data to display.</p>
120
+ {/if}
121
+ </div>
122
+ </div>
123
+
124
+ <style>
125
+ .code-analysis-viewer {
126
+ font-family: var(--font-mono, monospace);
127
+ font-size: var(--text-sm, 14px);
128
+ color: var(--body-text-color, #333);
129
+ border: 1px solid var(--border-color-primary, #e0e0e0);
130
+ border-radius: var(--radius-lg, 8px);
131
+ padding: var(--spacing-lg, 16px);
132
+ background-color: var(--background-fill-primary, #f9f9f9);
133
+ }
134
+
135
+ .analysis-section {
136
+ margin-bottom: var(--spacing-lg, 16px);
137
+ padding-bottom: var(--spacing-md, 12px);
138
+ border-bottom: 1px solid var(--border-color-secondary, #eee);
139
+ }
140
+ .analysis-section:last-child {
141
+ border-bottom: none;
142
+ margin-bottom: 0;
143
+ padding-bottom: 0;
144
+ }
145
+
146
+ .analysis-section h4 {
147
+ font-weight: var(--font-weight-semibold, 600);
148
+ color: var(--text-color-strong, #222);
149
+ margin-top: 0;
150
+ margin-bottom: var(--spacing-sm, 8px);
151
+ font-size: var(--text-md, 16px);
152
+ }
153
+
154
+ pre {
155
+ background-color: var(--background-fill-secondary, #f0f0f0);
156
+ padding: var(--spacing-md, 12px);
157
+ border-radius: var(--radius-md, 6px);
158
+ overflow-x: auto;
159
+ white-space: pre-wrap;
160
+ word-wrap: break-word;
161
+ }
162
+
163
+ code {
164
+ font-family: var(--font-mono, monospace);
165
+ }
166
+
167
+ p {
168
+ line-height: 1.6;
169
+ margin-top: 0;
170
+ margin-bottom: 4px;
171
+ }
172
+
173
+ .feedback-section .markdown-content {
174
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
175
+ line-height: 1.6;
176
+ color: #333;
177
+ overflow-wrap: break-word;
178
+ word-break: break-word;
179
+ max-width: 100%;
180
+ }
181
+ .feedback-section .markdown-content :global(p) {
182
+ margin-bottom: 8px;
183
+ }
184
+ .feedback-section .markdown-content :global(ul),
185
+ .feedback-section .markdown-content :global(ol) {
186
+ padding-left: 20px;
187
+ margin-bottom: 8px;
188
+ }
189
+ .feedback-section .markdown-content :global(li) {
190
+ margin-bottom: 4px;
191
+ }
192
+ .feedback-section .markdown-content :global(code) {
193
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
194
+ background-color: #e6f3ff;
195
+ padding: 2px 4px;
196
+ border-radius: 4px;
197
+ font-size: 0.9em;
198
+ }
199
+ .feedback-section .markdown-content :global(pre) {
200
+ background-color: #f0f0f0;
201
+ padding: 12px;
202
+ border-radius: 6px;
203
+ overflow-x: auto;
204
+ margin-bottom: 12px;
205
+ }
206
+ .feedback-section .markdown-content :global(pre code) {
207
+ background-color: transparent;
208
+ padding: 0;
209
+ border-radius: 0;
210
+ }
211
+
212
+ /* Additional markdown styling */
213
+ .feedback-section .markdown-content :global(h1),
214
+ .feedback-section .markdown-content :global(h2),
215
+ .feedback-section .markdown-content :global(h3),
216
+ .feedback-section .markdown-content :global(h4),
217
+ .feedback-section .markdown-content :global(h5),
218
+ .feedback-section .markdown-content :global(h6) {
219
+ margin-top: 16px;
220
+ margin-bottom: 12px;
221
+ font-weight: 600;
222
+ line-height: 1.25;
223
+ color: #111;
224
+ }
225
+
226
+ .feedback-section .markdown-content :global(h3) {
227
+ font-size: 1.25rem;
228
+ }
229
+
230
+ .feedback-section .markdown-content :global(h4) {
231
+ font-size: 1.1rem;
232
+ }
233
+
234
+ .feedback-section .markdown-content :global(a) {
235
+ color: #3B82F6;
236
+ text-decoration: none;
237
+ }
238
+
239
+ .feedback-section .markdown-content :global(a:hover) {
240
+ text-decoration: underline;
241
+ }
242
+
243
+ .feedback-section .markdown-content :global(blockquote) {
244
+ padding: 12px 16px;
245
+ margin: 12px 0;
246
+ border-left: 4px solid #3B82F6;
247
+ background-color: #f5f5f5;
248
+ color: #555;
249
+ }
250
+
251
+ .feedback-section .markdown-content :global(hr) {
252
+ height: 1px;
253
+ background-color: #e0e0e0;
254
+ border: none;
255
+ margin: 16px 0;
256
+ }
257
+
258
+ .feedback-section .markdown-content :global(table) {
259
+ border-collapse: collapse;
260
+ width: 100%;
261
+ margin: 12px 0;
262
+ }
263
+
264
+ .feedback-section .markdown-content :global(th),
265
+ .feedback-section .markdown-content :global(td) {
266
+ border: 1px solid #eee;
267
+ padding: 8px;
268
+ text-align: left;
269
+ }
270
+
271
+ .feedback-section .markdown-content :global(th) {
272
+ background-color: #f0f0f0;
273
+ font-weight: 600;
274
+ }
275
+
276
+ /* Styles for diff view */
277
+ .diff-view {
278
+ white-space: pre-wrap;
279
+ word-wrap: break-word;
280
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
281
+ background-color: #f0f0f0;
282
+ padding: 12px;
283
+ border-radius: 6px;
284
+ overflow-x: auto;
285
+ }
286
+
287
+ /* Status message styles */
288
+ .status-message {
289
+ padding: 12px;
290
+ margin-bottom: 12px;
291
+ border-radius: 6px;
292
+ background-color: #f0f0f0;
293
+ }
294
+
295
+ .status-message.error {
296
+ background-color: #ffe6e6;
297
+ color: #8b0000;
298
+ }
299
+ .diff-part.added {
300
+ background-color: #cbe1d1;
301
+ color: #006400;
302
+ }
303
+ .diff-part.removed {
304
+ background-color: #ffebe9;
305
+ color: #b30000;
306
+ text-decoration: line-through;
307
+ }
308
+ .diff-part.common {
309
+ color: #333;
310
+ background-color: #fcfcfc;
311
+ padding: 0 2px;
312
+ }
313
+ </style>
src/frontend/gradio.config.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ export default {
2
+ plugins: [],
3
+ svelte: {
4
+ preprocess: [],
5
+ },
6
+ build: {
7
+ target: "modules",
8
+ },
9
+ };
src/frontend/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
src/frontend/package.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_codeanalysisviewer",
3
+ "version": "0.3.22",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "main_changeset": true,
10
+ "exports": {
11
+ ".": {
12
+ "gradio": "./Index.svelte",
13
+ "svelte": "./dist/Index.svelte",
14
+ "types": "./dist/Index.svelte.d.ts"
15
+ },
16
+ "./example": {
17
+ "gradio": "./Example.svelte",
18
+ "svelte": "./dist/Example.svelte",
19
+ "types": "./dist/Example.svelte.d.ts"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "dependencies": {
24
+ "@gradio/atoms": "0.16.1",
25
+ "@gradio/icons": "0.12.0",
26
+ "@gradio/statustracker": "0.10.12",
27
+ "@gradio/upload": "^0.16.6",
28
+ "@gradio/utils": "^0.10.2",
29
+ "diff": "^5.1.0",
30
+ "marked": "^15.0.12"
31
+ },
32
+ "devDependencies": {
33
+ "@gradio/preview": "^0.13.1"
34
+ },
35
+ "peerDependencies": {
36
+ "svelte": "^4.0.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/gradio-app/gradio.git",
41
+ "directory": "js/simpletextbox"
42
+ }
43
+ }
src/frontend/tsconfig.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "checkJs": true,
5
+ "esModuleInterop": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "resolveJsonModule": true,
8
+ "skipLibCheck": true,
9
+ "sourceMap": true,
10
+ "moduleResolution": "node",
11
+ "target": "esnext",
12
+ "verbatimModuleSyntax": true,
13
+ "noEmit": true
14
+ },
15
+ "include": ["**/*.js"],
16
+ "exclude": ["node_modules", "dist", "gradio.config.js"]
17
+ }
src/package-lock.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_codeanalysisviewer",
3
+ "lockfileVersion": 3,
4
+ "requires": true,
5
+ "packages": {}
6
+ }
src/pyproject.toml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = [
3
+ "hatchling",
4
+ "hatch-requirements-txt",
5
+ "hatch-fancy-pypi-readme>=22.5.0",
6
+ ]
7
+ build-backend = "hatchling.build"
8
+
9
+ [project]
10
+ name = "gradio_codeanalysisviewer"
11
+ version = "0.0.2"
12
+ description = "A nicer view to show the Agentic code analyser outputs"
13
+ readme = "README.md"
14
+ license = "MIT"
15
+ requires-python = ">=3.10"
16
+ authors = [{ name = "Keshan", email = "[email protected]" }]
17
+ keywords = ["gradio-custom-component", "gradio-template-SimpleTextbox", "custom-component-track", "agents", "code-analysis", "agents-mcp-hackathon"]
18
+ # Add dependencies here
19
+ dependencies = ["gradio>=4.0,<6.0"]
20
+ classifiers = [
21
+ 'Development Status :: 3 - Alpha',
22
+ 'Operating System :: OS Independent',
23
+ 'Programming Language :: Python :: 3',
24
+ 'Programming Language :: Python :: 3 :: Only',
25
+ 'Programming Language :: Python :: 3.8',
26
+ 'Programming Language :: Python :: 3.9',
27
+ 'Programming Language :: Python :: 3.10',
28
+ 'Programming Language :: Python :: 3.11',
29
+ 'Topic :: Scientific/Engineering',
30
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
31
+ 'Topic :: Scientific/Engineering :: Visualization',
32
+ ]
33
+
34
+ # The repository and space URLs are optional, but recommended.
35
+ # Adding a repository URL will create a badge in the auto-generated README that links to the repository.
36
+ # Adding a space URL will create a badge in the auto-generated README that links to the space.
37
+ # This will make it easy for people to find your deployed demo or source code when they
38
+ # encounter your project in the wild.
39
+
40
+ # [project.urls]
41
+ # repository = "your github repository"
42
+ # space = "your space url"
43
+
44
+ [project.optional-dependencies]
45
+ dev = ["build", "twine"]
46
+
47
+ [tool.hatch.build]
48
+ artifacts = ["/backend/gradio_codeanalysisviewer/templates", "*.pyi"]
49
+
50
+ [tool.hatch.build.targets.wheel]
51
+ packages = ["/backend/gradio_codeanalysisviewer"]