datasette-libfec 0.0.1a4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: datasette-libfec
3
+ Version: 0.0.1a4
4
+ Author: Alex Garcia
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/datasette/datasette-libfec
7
+ Project-URL: Changelog, https://github.com/datasette/datasette-libfec/releases
8
+ Project-URL: Issues, https://github.com/datasette/datasette-libfec/issues
9
+ Project-URL: CI, https://github.com/datasette/datasette-libfec/actions
10
+ Classifier: Framework :: Datasette
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: datasette>=1a23
15
+ Requires-Dist: datasette-plugin-router>=0.0.1a2
16
+ Requires-Dist: libfec>=0.0.18
17
+ Dynamic: license-file
18
+
19
+ # datasette-libfec
20
+
21
+ [![PyPI](https://img.shields.io/pypi/v/datasette-libfec.svg)](https://pypi.org/project/datasette-libfec/)
22
+ [![Changelog](https://img.shields.io/github/v/release/datasette/datasette-libfec?include_prereleases&label=changelog)](https://github.com/datasette/datasette-libfec/releases)
23
+ [![Tests](https://github.com/datasette/datasette-libfec/actions/workflows/test.yml/badge.svg)](https://github.com/datasette/datasette-libfec/actions/workflows/test.yml)
24
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/datasette/datasette-libfec/blob/main/LICENSE)
25
+
26
+
27
+
28
+ ## Installation
29
+
30
+ Install this plugin in the same environment as Datasette.
31
+ ```bash
32
+ datasette install datasette-libfec
33
+ ```
34
+ ## Usage
35
+
36
+ Usage instructions go here.
37
+
38
+ ## Development
39
+
40
+ To set up this plugin locally, first checkout the code. You can confirm it is available like this:
41
+ ```bash
42
+ cd datasette-libfec
43
+ # Confirm the plugin is visible
44
+ uv run datasette plugins
45
+ ```
46
+ To run the tests:
47
+ ```bash
48
+ uv run pytest
49
+ ```
@@ -0,0 +1,31 @@
1
+ # datasette-libfec
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/datasette-libfec.svg)](https://pypi.org/project/datasette-libfec/)
4
+ [![Changelog](https://img.shields.io/github/v/release/datasette/datasette-libfec?include_prereleases&label=changelog)](https://github.com/datasette/datasette-libfec/releases)
5
+ [![Tests](https://github.com/datasette/datasette-libfec/actions/workflows/test.yml/badge.svg)](https://github.com/datasette/datasette-libfec/actions/workflows/test.yml)
6
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/datasette/datasette-libfec/blob/main/LICENSE)
7
+
8
+
9
+
10
+ ## Installation
11
+
12
+ Install this plugin in the same environment as Datasette.
13
+ ```bash
14
+ datasette install datasette-libfec
15
+ ```
16
+ ## Usage
17
+
18
+ Usage instructions go here.
19
+
20
+ ## Development
21
+
22
+ To set up this plugin locally, first checkout the code. You can confirm it is available like this:
23
+ ```bash
24
+ cd datasette-libfec
25
+ # Confirm the plugin is visible
26
+ uv run datasette plugins
27
+ ```
28
+ To run the tests:
29
+ ```bash
30
+ uv run pytest
31
+ ```
@@ -0,0 +1,80 @@
1
+ from pydantic import BaseModel
2
+ from datasette import hookimpl
3
+ from pathlib import Path
4
+ from textwrap import dedent
5
+ from typing import Optional
6
+ import json
7
+ import os
8
+
9
+ from .routes import router
10
+
11
+ # https://vite.dev/guide/backend-integration.html
12
+ class ManifestChunk(BaseModel):
13
+ """Vite manifest chunk."""
14
+ src: Optional[str] = None
15
+ file: str # The output file name of this chunk / asset
16
+ css: Optional[list[str]] = None # The list of CSS files imported by this chunk (JS chunks only)
17
+ assets: Optional[list[str]] = None # The list of asset files imported by this chunk, excluding CSS (JS chunks only)
18
+ isEntry: Optional[bool] = None # Whether this chunk or asset is an entry point
19
+ name: Optional[str] = None # The name of this chunk / asset if known
20
+ isDynamicEntry: Optional[bool] = None # Whether this chunk is a dynamic entry point (JS chunks only)
21
+ imports: Optional[list[str]] = None # The list of statically imported chunks (JS chunks only)
22
+ dynamicImports: Optional[list[str]] = None # The list of dynamically imported chunks (JS chunks only)
23
+
24
+ @hookimpl
25
+ def register_routes():
26
+ return router.routes()
27
+
28
+ @hookimpl
29
+ def extra_template_vars(datasette):
30
+ vite_path = os.environ.get("DATASETTE_LIBFEC_VITE_PATH")
31
+ if vite_path:
32
+ pass
33
+ else:
34
+ manifest_path = Path(__file__).parent / "manifest.json"
35
+ if not manifest_path.exists():
36
+ # Fallback if manifest doesn't exist yet
37
+ manifest = {}
38
+ else:
39
+ manifest_raw = json.loads(manifest_path.read_text())
40
+ manifest: dict[str, ManifestChunk] = {
41
+ k: ManifestChunk(**v) for k, v in manifest_raw.items()
42
+ }
43
+
44
+ async def datasette_libfec_vite_entry(entrypoint):
45
+ # https://vite.dev/guide/backend-integration.html
46
+
47
+ if vite_path:
48
+ return dedent(f"""
49
+
50
+ <script type="module" src="{vite_path}@vite/client"></script>
51
+ <script type="module" src="{vite_path}{entrypoint}"></script>
52
+
53
+ """
54
+ )
55
+ else:
56
+ chunk = manifest.get(entrypoint)
57
+ if not chunk:
58
+ raise ValueError(f"Entrypoint {entrypoint} not found in manifest")
59
+ parts = []
60
+
61
+ # part 1, css files
62
+ for css in chunk.css or []:
63
+ file = str(Path(css).relative_to("static"))
64
+ href = datasette.urls.static_plugins("datasette_libfec", file)
65
+ parts.append(f'<link rel="stylesheet" href="{href}">')
66
+
67
+ # part 2, import lists's chunks css files
68
+ # TODO
69
+
70
+ # part 3, entry point script
71
+ # pop first path part which is always "static/"
72
+ file = str(Path(chunk.file).relative_to("static"))
73
+ src = datasette.urls.static_plugins("datasette_libfec", file)
74
+ parts.append(f'<script type="module" src="{src}"></script>')
75
+
76
+ # skip part 4
77
+ return "\n".join(parts)
78
+
79
+
80
+ return {"datasette_libfec_vite_entry": datasette_libfec_vite_entry}
@@ -0,0 +1,69 @@
1
+ import os
2
+ import sys
3
+ import asyncio
4
+ import subprocess
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+
9
+ class LibfecClient:
10
+ def __init__(self):
11
+ bin_path = os.environ.get("DATASETTE_LIBFEC_BIN_PATH")
12
+ if bin_path:
13
+ self.libfec_path = Path(bin_path)
14
+ else:
15
+ self.libfec_path = Path(sys.executable).parent / 'libfec'
16
+
17
+ def _run_libfec_command(self, args):
18
+ """Synchronous command execution"""
19
+ print(args)
20
+ result = subprocess.run([str(self.libfec_path)] + args, capture_output=True, text=True)
21
+ if result.returncode != 0:
22
+ raise Exception(f"libfec error: {result.stderr}")
23
+ return result.stdout
24
+
25
+ async def _run_libfec_command_async(self, args):
26
+ """Async command execution - doesn't block event loop"""
27
+ print(f"Running async: {args}")
28
+ process = await asyncio.create_subprocess_exec(
29
+ str(self.libfec_path),
30
+ *args,
31
+ stdout=asyncio.subprocess.PIPE,
32
+ stderr=asyncio.subprocess.PIPE
33
+ )
34
+ stdout, stderr = await process.communicate()
35
+
36
+ if process.returncode != 0:
37
+ raise Exception(f"libfec error: {stderr.decode()}")
38
+ return stdout.decode()
39
+
40
+ async def export(self, committee_id: str, cycle: int, output_db: str) -> str:
41
+ """Export FEC data (async - won't block event loop)"""
42
+ return await self._run_libfec_command_async([
43
+ 'export', committee_id,
44
+ '--election', str(cycle),
45
+ '--form-type', 'F3',
46
+ #'--form-type', 'F1',
47
+ '-o', output_db
48
+ ])
49
+
50
+ async def rss_watch(self, output_db: str, state: Optional[str] = None, cover_only: bool = True):
51
+ """Run single RSS watch command (async - won't block event loop)"""
52
+ args = ['rss', '--since', '1 day']
53
+ if cover_only:
54
+ args.append('--cover-only')
55
+ args.extend(['-x', output_db])
56
+ if state:
57
+ args.extend(['--state', state])
58
+ return await self._run_libfec_command_async(args)
59
+
60
+
61
+ # RSS watcher state
62
+ class RssWatcherState:
63
+ def __init__(self):
64
+ self.task: Optional[asyncio.Task] = None
65
+ self.running = False
66
+ self.interval = 60
67
+ self.state: Optional[str] = None
68
+ self.cover_only = True
69
+ self.output_db: Optional[str] = None
@@ -0,0 +1,11 @@
1
+ {
2
+ "src/index_view.ts": {
3
+ "file": "static/gen/index-CaTQMY-X.js",
4
+ "name": "index",
5
+ "src": "src/index_view.ts",
6
+ "isEntry": true,
7
+ "css": [
8
+ "static/gen/index-6cjSv2YC.css"
9
+ ]
10
+ }
11
+ }
@@ -0,0 +1,189 @@
1
+ from pydantic import BaseModel
2
+ from datasette import Response
3
+ from datasette_plugin_router import Router, Body
4
+ from typing import Literal, Optional
5
+ import asyncio
6
+ from .libfec_client import LibfecClient, RssWatcherState
7
+
8
+ libfec_client = LibfecClient()
9
+ rss_watcher_state = RssWatcherState()
10
+ router = Router()
11
+
12
+
13
+ @router.GET("/-/libfec")
14
+ async def libfec_page(datasette):
15
+ return Response.html(
16
+ await datasette.render_template(
17
+ "libfec.html",
18
+ )
19
+ )
20
+
21
+
22
+ class ImportParams(BaseModel):
23
+ kind: Literal['committee'] | Literal['candidate'] | Literal['contest']
24
+ id: str
25
+ cycle: int = 2026
26
+
27
+ class ImportResponse(BaseModel):
28
+ status: str
29
+ message: str
30
+
31
+ # RSS Watcher models and endpoints (defined before general import endpoint)
32
+ async def rss_watch_loop(output_db: str, state: Optional[str], cover_only: bool, interval: int):
33
+ """Background task that runs RSS watch periodically"""
34
+ while rss_watcher_state.running:
35
+ try:
36
+ print(f"Running RSS watch: state={state}, cover_only={cover_only}, db={output_db}")
37
+ await libfec_client.rss_watch(output_db, state, cover_only)
38
+ print(f"RSS watch completed, sleeping {interval} seconds")
39
+ except Exception as e:
40
+ print(f"RSS watch error: {e}")
41
+ await asyncio.sleep(interval)
42
+
43
+
44
+ class RssStartParams(BaseModel):
45
+ state: Optional[str] = None
46
+ cover_only: bool = True
47
+ interval: int = 60
48
+
49
+
50
+ class RssResponse(BaseModel):
51
+ status: str
52
+ message: str
53
+ running: bool
54
+ config: Optional[dict] = None
55
+
56
+
57
+ @router.POST("/-/api/libfec/rss/start", output=RssResponse)
58
+ async def rss_start(datasette, params: Body[RssStartParams]):
59
+ if rss_watcher_state.running:
60
+ return Response.json({
61
+ "status": "error",
62
+ "message": "RSS watcher is already running",
63
+ "running": True
64
+ }, status=400)
65
+
66
+ # Get output database
67
+ output_db = None
68
+ for name, db in datasette.databases.items():
69
+ if not db.is_memory:
70
+ output_db = db
71
+ break
72
+ if output_db is None:
73
+ return Response.json({
74
+ "status": "error",
75
+ "message": "No writable database found.",
76
+ "running": False
77
+ }, status=500)
78
+
79
+ # Validate interval
80
+ if params.interval < 1:
81
+ return Response.json({
82
+ "status": "error",
83
+ "message": "Interval must be at least 1 second",
84
+ "running": False
85
+ }, status=400)
86
+
87
+ # Start the background task
88
+ rss_watcher_state.running = True
89
+ rss_watcher_state.state = params.state
90
+ rss_watcher_state.cover_only = params.cover_only
91
+ rss_watcher_state.interval = params.interval
92
+ rss_watcher_state.output_db = output_db.path
93
+ rss_watcher_state.task = asyncio.create_task(
94
+ rss_watch_loop(output_db.path, params.state, params.cover_only, params.interval)
95
+ )
96
+
97
+ return Response.json(
98
+ RssResponse(
99
+ status="success",
100
+ message="RSS watcher started",
101
+ running=True,
102
+ config={
103
+ "state": params.state,
104
+ "cover_only": params.cover_only,
105
+ "interval": params.interval
106
+ }
107
+ ).model_dump()
108
+ )
109
+
110
+
111
+ @router.POST("/-/api/libfec/rss/stop", output=RssResponse)
112
+ async def rss_stop(datasette):
113
+ if not rss_watcher_state.running:
114
+ return Response.json({
115
+ "status": "error",
116
+ "message": "RSS watcher is not running",
117
+ "running": False
118
+ }, status=400)
119
+
120
+ # Stop the background task
121
+ rss_watcher_state.running = False
122
+ if rss_watcher_state.task:
123
+ rss_watcher_state.task.cancel()
124
+ try:
125
+ await rss_watcher_state.task
126
+ except asyncio.CancelledError:
127
+ pass
128
+ rss_watcher_state.task = None
129
+
130
+ return Response.json(
131
+ RssResponse(
132
+ status="success",
133
+ message="RSS watcher stopped",
134
+ running=False
135
+ ).model_dump()
136
+ )
137
+
138
+
139
+ @router.GET("/-/api/libfec/rss/status", output=RssResponse)
140
+ async def rss_status(datasette):
141
+ config = None
142
+ if rss_watcher_state.running:
143
+ config = {
144
+ "state": rss_watcher_state.state,
145
+ "cover_only": rss_watcher_state.cover_only,
146
+ "interval": rss_watcher_state.interval,
147
+ "output_db": rss_watcher_state.output_db
148
+ }
149
+
150
+ return Response.json(
151
+ RssResponse(
152
+ status="success",
153
+ message="RSS watcher status",
154
+ running=rss_watcher_state.running,
155
+ config=config
156
+ ).model_dump()
157
+ )
158
+
159
+
160
+ # General import endpoint (defined after RSS endpoints to avoid route conflicts)
161
+ @router.POST("/-/api/libfec", output=ImportResponse)
162
+ async def libfec_import(datasette, params: Body[ImportParams]):
163
+ output_db = None
164
+ for name, db in datasette.databases.items():
165
+ if not db.is_memory:
166
+ output_db = db
167
+ break
168
+ if output_db is None:
169
+ return Response.json({
170
+ "status": "error",
171
+ "message": "No writable database found."
172
+ }, status=500)
173
+ # validate cycle: expected even cycles between 2022 and 2026 inclusive
174
+ if not (2022 <= params.cycle <= 2026) or (params.cycle % 2 != 0):
175
+ return Response.json({
176
+ "status": "error",
177
+ "message": "Invalid cycle: must be an even year between 2022 and 2026."
178
+ }, status=400)
179
+
180
+ await libfec_client.export(
181
+ committee_id=params.id,
182
+ cycle=params.cycle,
183
+ output_db=output_db.path)
184
+ return Response.json(
185
+ ImportResponse(
186
+ status="success",
187
+ message=f"Data for {params.kind} {params.id} imported successfully."
188
+ ).model_dump_json()
189
+ )
@@ -0,0 +1 @@
1
+ .import-section.svelte-g26r64{margin:2em 0}.form-group.svelte-g26r64{margin-bottom:1.5em}.form-group.svelte-g26r64 label:where(.svelte-g26r64){display:block;font-weight:700;margin-bottom:.5em}.form-group.svelte-g26r64 input[type=text]:where(.svelte-g26r64),.form-group.svelte-g26r64 select:where(.svelte-g26r64){width:100%;max-width:400px;padding:.5em;font-size:1em;border:1px solid #ccc;border-radius:4px}fieldset.svelte-g26r64{border:1px solid #ddd;border-radius:4px;padding:1em}legend.svelte-g26r64{font-weight:700;padding:0 .5em}.radio-group.svelte-g26r64{display:flex;gap:1.5em;flex-wrap:wrap}.radio-group.svelte-g26r64 div:where(.svelte-g26r64){display:flex;align-items:center;gap:.5em}.radio-group.svelte-g26r64 input[type=radio]:where(.svelte-g26r64){cursor:pointer}.radio-group.svelte-g26r64 label:where(.svelte-g26r64){cursor:pointer;margin:0}button.svelte-g26r64{padding:.75em 1.5em;font-size:1em;background:#06c;color:#fff;border:none;border-radius:4px;cursor:pointer}button.svelte-g26r64:hover:not(:disabled){background:#0052a3}button.svelte-g26r64:disabled{background:#999;cursor:not-allowed}.button-danger.svelte-g26r64{background:#dc3545;padding:.75em 1.5em;font-size:1em;color:#fff;border:none;border-radius:4px;cursor:pointer}.button-danger.svelte-g26r64:hover:not(:disabled){background:#c82333}.button-danger.svelte-g26r64:disabled{background:#999;cursor:not-allowed}.rss-section.svelte-g26r64{margin:3em 0;padding-top:2em;border-top:2px solid #ddd}.rss-status.svelte-g26r64{padding:1.5em;border-radius:4px;background:#f8f9fa;border:1px solid #dee2e6}.rss-status.running.svelte-g26r64{background:#d4edda;border-color:#c3e6cb}.rss-status.svelte-g26r64 strong:where(.svelte-g26r64){display:block;margin-bottom:1em;font-size:1.1em}.rss-config.svelte-g26r64{margin:1em 0;padding:1em;background:#fff;border-radius:4px;font-family:monospace}.rss-config.svelte-g26r64 div:where(.svelte-g26r64){margin:.5em 0}small.svelte-g26r64{display:block;color:#666;font-size:.85em;margin-top:.25em}input[type=checkbox].svelte-g26r64{margin-right:.5em}input[type=number].svelte-g26r64{width:100%;max-width:200px}
@@ -0,0 +1 @@
1
+ var rr=Array.isArray,Jr=Array.prototype.indexOf,De=Array.prototype.includes,Kr=Array.from,Qr=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Zr=Object.prototype,Xr=Array.prototype,en=Object.getPrototypeOf,zt=Object.isExtensible;function tn(e){for(var t=0;t<e.length;t++)e[t]()}function nr(){var e,t,r=new Promise((i,n)=>{e=i,t=n});return{promise:r,resolve:e,reject:t}}const C=2,at=4,dt=8,ir=1<<24,se=16,le=32,Se=64,Nt=128,W=512,j=1024,q=2048,ae=4096,Z=8192,fe=16384,Pt=32768,Ie=65536,Wt=1<<17,sr=1<<18,Pe=1<<19,rn=1<<20,we=32768,Ot=1<<21,qt=1<<22,ue=1<<23,Ye=Symbol("$state"),je=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function nn(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function sn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function ln(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function an(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function on(e){throw new Error("https://svelte.dev/e/effect_orphan")}function fn(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function un(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function cn(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function dn(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function vn(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const hn=2,A=Symbol();function _n(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function pn(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function lr(e){return e===this.v}let U=null;function Fe(e){U=e}function ar(e,t=!1,r){U={p:U,i:!1,c:null,e:null,s:e,x:null,l:null}}function or(e){var t=U,r=t.e;if(r!==null){t.e=null;for(var i of r)kr(i)}return t.i=!0,U=t.p,{}}function fr(){return!0}let me=[];function ur(){var e=me;me=[],tn(e)}function ne(e){if(me.length===0&&!Ge){var t=me;queueMicrotask(()=>{t===me&&ur()})}me.push(e)}function gn(){for(;me.length>0;)ur()}function cr(e){var t=b;if(t===null)return h.f|=ue,e;if((t.f&Pt)===0){if((t.f&Nt)===0)throw e;t.b.error(e)}else Ne(e,t)}function Ne(e,t){for(;t!==null;){if((t.f&Nt)!==0)try{t.b.error(e);return}catch(r){e=r}t=t.parent}throw e}const mn=-7169;function T(e,t){e.f=e.f&mn|t}function Mt(e){(e.f&W)!==0||e.deps===null?T(e,j):T(e,ae)}function dr(e){if(e!==null)for(const t of e)(t.f&C)===0||(t.f&we)===0||(t.f^=we,dr(t.deps))}function vr(e,t,r){(e.f&q)!==0?t.add(e):(e.f&ae)!==0&&r.add(e),dr(e.deps),T(e,j)}const nt=new Set;let y=null,ot=null,Y=null,$=[],vt=null,jt=!1,Ge=!1;class ce{committed=!1;current=new Map;previous=new Map;#t=new Set;#l=new Set;#e=0;#i=0;#s=null;#n=new Set;#r=new Set;skipped_effects=new Set;is_fork=!1;#a=!1;is_deferred(){return this.is_fork||this.#i>0}process(t){$=[],this.apply();var r=[],i=[];for(const n of t)this.#o(n,r,i);if(this.is_deferred())this.#f(i),this.#f(r);else{for(const n of this.#t)n();this.#t.clear(),this.#e===0&&this.#u(),ot=this,y=null,Bt(i),Bt(r),ot=null,this.#s?.resolve()}Y=null}#o(t,r,i){t.f^=j;for(var n=t.first,s=null;n!==null;){var l=n.f,a=(l&(le|Se))!==0,o=a&&(l&j)!==0,u=o||(l&Z)!==0||this.skipped_effects.has(n);if(!u&&n.fn!==null){a?n.f^=j:s!==null&&(l&(at|dt|ir))!==0?s.b.defer_effect(n):(l&at)!==0?r.push(n):Xe(n)&&((l&se)!==0&&this.#r.add(n),Ze(n));var d=n.first;if(d!==null){n=d;continue}}var c=n.parent;for(n=n.next;n===null&&c!==null;)c===s&&(s=null),n=c.next,c=c.parent}}#f(t){for(var r=0;r<t.length;r+=1)vr(t[r],this.#n,this.#r)}capture(t,r){r!==A&&!this.previous.has(t)&&this.previous.set(t,r),(t.f&ue)===0&&(this.current.set(t,t.v),Y?.set(t,t.v))}activate(){y=this,this.apply()}deactivate(){y===this&&(y=null,Y=null)}flush(){if(this.activate(),$.length>0){if(hr(),y!==null&&y!==this)return}else this.#e===0&&this.process([]);this.deactivate()}discard(){for(const t of this.#l)t(this);this.#l.clear()}#u(){if(nt.size>1){this.previous.clear();var t=Y,r=!0;for(const n of nt){if(n===this){r=!1;continue}const s=[];for(const[a,o]of this.current){if(n.current.has(a))if(r&&o!==n.current.get(a))n.current.set(a,o);else continue;s.push(a)}if(s.length===0)continue;const l=[...n.current.keys()].filter(a=>!this.current.has(a));if(l.length>0){var i=$;$=[];const a=new Set,o=new Map;for(const u of s)_r(u,l,a,o);if($.length>0){y=n,n.apply();for(const u of $)n.#o(u,[],[]);n.deactivate()}$=i}}y=null,Y=t}this.committed=!0,nt.delete(this)}increment(t){this.#e+=1,t&&(this.#i+=1)}decrement(t){this.#e-=1,t&&(this.#i-=1),!this.#a&&(this.#a=!0,ne(()=>{this.#a=!1,this.is_deferred()?$.length>0&&this.flush():this.revive()}))}revive(){for(const t of this.#n)this.#r.delete(t),T(t,q),ie(t);for(const t of this.#r)T(t,ae),ie(t);this.flush()}oncommit(t){this.#t.add(t)}ondiscard(t){this.#l.add(t)}settled(){return(this.#s??=nr()).promise}static ensure(){if(y===null){const t=y=new ce;nt.add(y),Ge||ne(()=>{y===t&&t.flush()})}return y}apply(){}}function yn(e){var t=Ge;Ge=!0;try{for(var r;;){if(gn(),$.length===0&&(y?.flush(),$.length===0))return vt=null,r;hr()}}finally{Ge=t}}function hr(){jt=!0;var e=null;try{for(var t=0;$.length>0;){var r=ce.ensure();if(t++>1e3){var i,n;bn()}r.process($),de.clear()}}finally{jt=!1,vt=null}}function bn(){try{fn()}catch(e){Ne(e,vt)}}let te=null;function Bt(e){var t=e.length;if(t!==0){for(var r=0;r<t;){var i=e[r++];if((i.f&(fe|Z))===0&&Xe(i)&&(te=new Set,Ze(i),i.deps===null&&i.first===null&&i.nodes===null&&(i.teardown===null&&i.ac===null?Or(i):i.fn=null),te?.size>0)){de.clear();for(const n of te){if((n.f&(fe|Z))!==0)continue;const s=[n];let l=n.parent;for(;l!==null;)te.has(l)&&(te.delete(l),s.push(l)),l=l.parent;for(let a=s.length-1;a>=0;a--){const o=s[a];(o.f&(fe|Z))===0&&Ze(o)}}te.clear()}}te=null}}function _r(e,t,r,i){if(!r.has(e)&&(r.add(e),e.reactions!==null))for(const n of e.reactions){const s=n.f;(s&C)!==0?_r(n,t,r,i):(s&(qt|se))!==0&&(s&q)===0&&pr(n,t,i)&&(T(n,q),ie(n))}}function pr(e,t,r){const i=r.get(e);if(i!==void 0)return i;if(e.deps!==null)for(const n of e.deps){if(De.call(t,n))return!0;if((n.f&C)!==0&&pr(n,t,r))return r.set(n,!0),!0}return r.set(e,!1),!1}function ie(e){for(var t=vt=e;t.parent!==null;){t=t.parent;var r=t.f;if(jt&&t===b&&(r&se)!==0&&(r&sr)===0)return;if((r&(Se|le))!==0){if((r&j)===0)return;t.f^=j}}$.push(t)}function wn(e){let t=0,r=ht(0),i;return()=>{Ut()&&(_(r),mt(()=>(t===0&&(i=yt(()=>e(()=>Je(r)))),t+=1,()=>{ne(()=>{t-=1,t===0&&(i?.(),i=void 0,Je(r))})})))}}var En=Ie|Pe|Nt;function Sn(e,t,r){new Rn(e,t,r)}class Rn{parent;is_pending=!1;#t;#l=null;#e;#i;#s;#n=null;#r=null;#a=null;#o=null;#f=null;#u=0;#d=0;#h=!1;#v=!1;#_=new Set;#p=new Set;#c=null;#w=wn(()=>(this.#c=ht(this.#u),()=>{this.#c=null}));constructor(t,r,i){this.#t=t,this.#e=r,this.#i=i,this.parent=b.b,this.is_pending=!!this.#e.pending,this.#s=Tr(()=>{b.b=this;{var n=this.#y();try{this.#n=re(()=>i(n))}catch(s){this.error(s)}this.#d>0?this.#m():this.is_pending=!1}return()=>{this.#f?.remove()}},En)}#E(){try{this.#n=re(()=>this.#i(this.#t))}catch(t){this.error(t)}}#S(){const t=this.#e.pending;t&&(this.#r=re(()=>t(this.#t)),ne(()=>{var r=this.#y();this.#n=this.#g(()=>(ce.ensure(),re(()=>this.#i(r)))),this.#d>0?this.#m():(Ke(this.#r,()=>{this.#r=null}),this.is_pending=!1)}))}#y(){var t=this.#t;return this.is_pending&&(this.#f=ut(),this.#t.before(this.#f),t=this.#f),t}defer_effect(t){vr(t,this.#_,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#e.pending}#g(t){var r=b,i=h,n=U;X(this.#s),P(this.#s),Fe(this.#s.ctx);try{return t()}catch(s){return cr(s),null}finally{X(r),P(i),Fe(n)}}#m(){const t=this.#e.pending;this.#n!==null&&(this.#o=document.createDocumentFragment(),this.#o.append(this.#f),Ir(this.#n,this.#o)),this.#r===null&&(this.#r=re(()=>t(this.#t)))}#b(t){if(!this.has_pending_snippet()){this.parent&&this.parent.#b(t);return}if(this.#d+=t,this.#d===0){this.is_pending=!1;for(const r of this.#_)T(r,q),ie(r);for(const r of this.#p)T(r,ae),ie(r);this.#_.clear(),this.#p.clear(),this.#r&&Ke(this.#r,()=>{this.#r=null}),this.#o&&(this.#t.before(this.#o),this.#o=null)}}update_pending_count(t){this.#b(t),this.#u+=t,!(!this.#c||this.#h)&&(this.#h=!0,ne(()=>{this.#h=!1,this.#c&&ft(this.#c,this.#u)}))}get_effect_pending(){return this.#w(),_(this.#c)}error(t){var r=this.#e.onerror;let i=this.#e.failed;if(this.#v||!r&&!i)throw t;this.#n&&(L(this.#n),this.#n=null),this.#r&&(L(this.#r),this.#r=null),this.#a&&(L(this.#a),this.#a=null);var n=!1,s=!1;const l=()=>{if(n){pn();return}n=!0,s&&vn(),ce.ensure(),this.#u=0,this.#a!==null&&Ke(this.#a,()=>{this.#a=null}),this.is_pending=this.has_pending_snippet(),this.#n=this.#g(()=>(this.#v=!1,re(()=>this.#i(this.#t)))),this.#d>0?this.#m():this.is_pending=!1};var a=h;try{P(null),s=!0,r?.(t,l),s=!1}catch(o){Ne(o,this.#s&&this.#s.parent)}finally{P(a)}i&&ne(()=>{this.#a=this.#g(()=>{ce.ensure(),this.#v=!0;try{return re(()=>{i(this.#t,()=>t,()=>l)})}catch(o){return Ne(o,this.#s.parent),null}finally{this.#v=!1}})})}}function xn(e,t,r,i){const n=Tn;var s=e.filter(f=>!f.settled);if(r.length===0&&s.length===0){i(t.map(n));return}var l=y,a=b,o=kn(),u=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(f=>f.promise)):null;function d(f){o();try{i(f)}catch(v){(a.f&fe)===0&&Ne(v,a)}l?.deactivate(),Dt()}if(r.length===0){u.then(()=>d(t.map(n)));return}function c(){o(),Promise.all(r.map(f=>An(f))).then(f=>d([...t.map(n),...f])).catch(f=>Ne(f,a))}u?u.then(c):c()}function kn(){var e=b,t=h,r=U,i=y;return function(s=!0){X(e),P(t),Fe(r),s&&i?.activate()}}function Dt(){X(null),P(null),Fe(null)}function Tn(e){var t=C|q,r=h!==null&&(h.f&C)!==0?h:null;return b!==null&&(b.f|=Pe),{ctx:U,deps:null,effects:null,equals:lr,f:t,fn:e,reactions:null,rv:0,v:A,wv:0,parent:r??b,ac:null}}function An(e,t,r){let i=b;i===null&&sn();var n=i.b,s=void 0,l=ht(A),a=!h,o=new Map;return $n(()=>{var u=nr();s=u.promise;try{Promise.resolve(e()).then(u.resolve,u.reject).then(()=>{d===y&&d.committed&&d.deactivate(),Dt()})}catch(v){u.reject(v),Dt()}var d=y;if(a){var c=n.is_rendered();n.update_pending_count(1),d.increment(c),o.get(d)?.reject(je),o.delete(d),o.set(d,u)}const f=(v,g=void 0)=>{if(d.activate(),g)g!==je&&(l.f|=ue,ft(l,g));else{(l.f&ue)!==0&&(l.f^=ue),ft(l,v);for(const[D,I]of o){if(o.delete(D),D===d)break;I.reject(je)}}a&&(n.update_pending_count(-1),d.decrement(c))};u.promise.then(f,v=>f(null,v||"unknown"))}),gt(()=>{for(const u of o.values())u.reject(je)}),new Promise(u=>{function d(c){function f(){c===s?u(l):d(s)}c.then(f,f)}d(s)})}function gr(e){var t=e.effects;if(t!==null){e.effects=null;for(var r=0;r<t.length;r+=1)L(t[r])}}function Cn(e){for(var t=e.parent;t!==null;){if((t.f&C)===0)return(t.f&fe)===0?t:null;t=t.parent}return null}function $t(e){var t,r=b;X(Cn(e));try{e.f&=~we,gr(e),t=qr(e)}finally{X(r)}return t}function mr(e){var t=$t(e);if(!e.equals(t)&&(e.wv=Nr(),(!y?.is_fork||e.deps===null)&&(e.v=t,e.deps===null))){T(e,j);return}Ee||(Y!==null?(Ut()||y?.is_fork)&&Y.set(e,t):Mt(e))}let It=new Set;const de=new Map;let yr=!1;function ht(e,t){var r={f:0,v:e,reactions:null,equals:lr,rv:0,wv:0};return r}function k(e,t){const r=ht(e);return Wn(r),r}function m(e,t,r=!1){h!==null&&(!G||(h.f&Wt)!==0)&&fr()&&(h.f&(C|se|qt|Wt))!==0&&(B===null||!De.call(B,e))&&dn();let i=r?Be(t):t;return ft(e,i)}function ft(e,t){if(!e.equals(t)){var r=e.v;Ee?de.set(e,t):de.set(e,r),e.v=t;var i=ce.ensure();if(i.capture(e,r),(e.f&C)!==0){const n=e;(e.f&q)!==0&&$t(n),Mt(n)}e.wv=Nr(),br(e,q),b!==null&&(b.f&j)!==0&&(b.f&(le|Se))===0&&(z===null?Bn([e]):z.push(e)),!i.is_fork&&It.size>0&&!yr&&On()}return t}function On(){yr=!1;for(const e of It)(e.f&j)!==0&&T(e,ae),Xe(e)&&Ze(e);It.clear()}function Je(e){m(e,e.v+1)}function br(e,t){var r=e.reactions;if(r!==null)for(var i=r.length,n=0;n<i;n++){var s=r[n],l=s.f,a=(l&q)===0;if(a&&T(s,t),(l&C)!==0){var o=s;Y?.delete(o),(l&we)===0&&(l&W&&(s.f|=we),br(o,ae))}else a&&((l&se)!==0&&te!==null&&te.add(s),ie(s))}}function Be(e){if(typeof e!="object"||e===null||Ye in e)return e;const t=en(e);if(t!==Zr&&t!==Xr)return e;var r=new Map,i=rr(e),n=k(0),s=be,l=a=>{if(be===s)return a();var o=h,u=be;P(null),Jt(s);var d=a();return P(o),Jt(u),d};return i&&r.set("length",k(e.length)),new Proxy(e,{defineProperty(a,o,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&un();var d=r.get(o);return d===void 0?d=l(()=>{var c=k(u.value);return r.set(o,c),c}):m(d,u.value,!0),!0},deleteProperty(a,o){var u=r.get(o);if(u===void 0){if(o in a){const d=l(()=>k(A));r.set(o,d),Je(n)}}else m(u,A),Je(n);return!0},get(a,o,u){if(o===Ye)return e;var d=r.get(o),c=o in a;if(d===void 0&&(!c||Ve(a,o)?.writable)&&(d=l(()=>{var v=Be(c?a[o]:A),g=k(v);return g}),r.set(o,d)),d!==void 0){var f=_(d);return f===A?void 0:f}return Reflect.get(a,o,u)},getOwnPropertyDescriptor(a,o){var u=Reflect.getOwnPropertyDescriptor(a,o);if(u&&"value"in u){var d=r.get(o);d&&(u.value=_(d))}else if(u===void 0){var c=r.get(o),f=c?.v;if(c!==void 0&&f!==A)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return u},has(a,o){if(o===Ye)return!0;var u=r.get(o),d=u!==void 0&&u.v!==A||Reflect.has(a,o);if(u!==void 0||b!==null&&(!d||Ve(a,o)?.writable)){u===void 0&&(u=l(()=>{var f=d?Be(a[o]):A,v=k(f);return v}),r.set(o,u));var c=_(u);if(c===A)return!1}return d},set(a,o,u,d){var c=r.get(o),f=o in a;if(i&&o==="length")for(var v=u;v<c.v;v+=1){var g=r.get(v+"");g!==void 0?m(g,A):v in a&&(g=l(()=>k(A)),r.set(v+"",g))}if(c===void 0)(!f||Ve(a,o)?.writable)&&(c=l(()=>k(void 0)),m(c,Be(u)),r.set(o,c));else{f=c.v!==A;var D=l(()=>Be(u));m(c,D)}var I=Reflect.getOwnPropertyDescriptor(a,o);if(I?.set&&I.set.call(d,u),!f){if(i&&typeof o=="string"){var H=r.get("length"),J=Number(o);Number.isInteger(J)&&J>=H.v&&m(H,J+1)}Je(n)}return!0},ownKeys(a){_(n);var o=Reflect.ownKeys(a).filter(c=>{var f=r.get(c);return f===void 0||f.v!==A});for(var[u,d]of r)d.v!==A&&!(u in a)&&o.push(u);return o},setPrototypeOf(){cn()}})}function Ht(e){try{if(e!==null&&typeof e=="object"&&Ye in e)return e[Ye]}catch{}return e}function wr(e,t){return Object.is(Ht(e),Ht(t))}var Vt,Er,Sr,Rr;function jn(){if(Vt===void 0){Vt=window,Er=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,r=Text.prototype;Sr=Ve(t,"firstChild").get,Rr=Ve(t,"nextSibling").get,zt(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),zt(r)&&(r.__t=void 0)}}function ut(e=""){return document.createTextNode(e)}function xr(e){return Sr.call(e)}function Lt(e){return Rr.call(e)}function w(e,t){return xr(e)}function E(e,t=1,r=!1){let i=e;for(;t--;)i=Lt(i);return i}function Dn(){return!1}let Yt=!1;function In(){Yt||(Yt=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(const t of e.target.elements)t.__on_r?.()})},{capture:!0}))}function _t(e){var t=h,r=b;P(null),X(null);try{return e()}finally{P(t),X(r)}}function pt(e,t,r,i=r){e.addEventListener(t,()=>_t(r));const n=e.__on_r;n?e.__on_r=()=>{n(),i(!0)}:e.__on_r=()=>i(!0),In()}function Fn(e){b===null&&(h===null&&on(),an()),Ee&&ln()}function Nn(e,t){var r=t.last;r===null?t.last=t.first=e:(r.next=e,e.prev=r,t.last=e)}function oe(e,t,r){var i=b;i!==null&&(i.f&Z)!==0&&(e|=Z);var n={ctx:U,deps:null,nodes:null,f:e|q|W,first:null,fn:t,last:null,next:null,parent:i,b:i&&i.b,prev:null,teardown:null,wv:0,ac:null};if(r)try{Ze(n),n.f|=Pt}catch(a){throw L(n),a}else t!==null&&ie(n);var s=n;if(r&&s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&(s.f&Pe)===0&&(s=s.first,(e&se)!==0&&(e&Ie)!==0&&s!==null&&(s.f|=Ie)),s!==null&&(s.parent=i,i!==null&&Nn(s,i),h!==null&&(h.f&C)!==0&&(e&Se)===0)){var l=h;(l.effects??=[]).push(s)}return n}function Ut(){return h!==null&&!G}function gt(e){const t=oe(dt,null,!1);return T(t,j),t.teardown=e,t}function Pn(e){Fn();var t=b.f,r=!h&&(t&le)!==0&&(t&Pt)===0;if(r){var i=U;(i.e??=[]).push(e)}else return kr(e)}function kr(e){return oe(at|rn,e,!1)}function qn(e){ce.ensure();const t=oe(Se|Pe,e,!0);return(r={})=>new Promise(i=>{r.outro?Ke(t,()=>{L(t),i(void 0)}):(L(t),i(void 0))})}function Mn(e){return oe(at,e,!1)}function $n(e){return oe(qt|Pe,e,!0)}function mt(e,t=0){return oe(dt|t,e,!0)}function it(e,t=[],r=[],i=[]){xn(i,t,r,n=>{oe(dt,()=>e(...n.map(_)),!0)})}function Tr(e,t=0){var r=oe(se|t,e,!0);return r}function re(e){return oe(le|Pe,e,!0)}function Ar(e){var t=e.teardown;if(t!==null){const r=Ee,i=h;Gt(!0),P(null);try{t.call(null)}finally{Gt(r),P(i)}}}function Cr(e,t=!1){var r=e.first;for(e.first=e.last=null;r!==null;){const n=r.ac;n!==null&&_t(()=>{n.abort(je)});var i=r.next;(r.f&Se)!==0?r.parent=null:L(r,t),r=i}}function Ln(e){for(var t=e.first;t!==null;){var r=t.next;(t.f&le)===0&&L(t),t=r}}function L(e,t=!0){var r=!1;(t||(e.f&sr)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Un(e.nodes.start,e.nodes.end),r=!0),Cr(e,t&&!r),ct(e,0),T(e,fe);var i=e.nodes&&e.nodes.t;if(i!==null)for(const s of i)s.stop();Ar(e);var n=e.parent;n!==null&&n.first!==null&&Or(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Un(e,t){for(;e!==null;){var r=e===t?null:Lt(e);e.remove(),e=r}}function Or(e){var t=e.parent,r=e.prev,i=e.next;r!==null&&(r.next=i),i!==null&&(i.prev=r),t!==null&&(t.first===e&&(t.first=i),t.last===e&&(t.last=r))}function Ke(e,t,r=!0){var i=[];jr(e,i,!0);var n=()=>{r&&L(e),t&&t()},s=i.length;if(s>0){var l=()=>--s||n();for(var a of i)a.out(l)}else n()}function jr(e,t,r){if((e.f&Z)===0){e.f^=Z;var i=e.nodes&&e.nodes.t;if(i!==null)for(const a of i)(a.is_global||r)&&t.push(a);for(var n=e.first;n!==null;){var s=n.next,l=(n.f&Ie)!==0||(n.f&le)!==0&&(e.f&se)!==0;jr(n,t,l?r:!1),n=s}}}function zn(e){Dr(e,!0)}function Dr(e,t){if((e.f&Z)!==0){e.f^=Z,(e.f&j)===0&&(T(e,q),ie(e));for(var r=e.first;r!==null;){var i=r.next,n=(r.f&Ie)!==0||(r.f&le)!==0;Dr(r,n?t:!1),r=i}var s=e.nodes&&e.nodes.t;if(s!==null)for(const l of s)(l.is_global||t)&&l.in()}}function Ir(e,t){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end;r!==null;){var n=r===i?null:Lt(r);t.append(r),r=n}}let lt=!1,Ee=!1;function Gt(e){Ee=e}let h=null,G=!1;function P(e){h=e}let b=null;function X(e){b=e}let B=null;function Wn(e){h!==null&&(B===null?B=[e]:B.push(e))}let N=null,M=0,z=null;function Bn(e){z=e}let Fr=1,ye=0,be=ye;function Jt(e){be=e}function Nr(){return++Fr}function Xe(e){var t=e.f;if((t&q)!==0)return!0;if(t&C&&(e.f&=~we),(t&ae)!==0){for(var r=e.deps,i=r.length,n=0;n<i;n++){var s=r[n];if(Xe(s)&&mr(s),s.wv>e.wv)return!0}(t&W)!==0&&Y===null&&T(e,j)}return!1}function Pr(e,t,r=!0){var i=e.reactions;if(i!==null&&!(B!==null&&De.call(B,e)))for(var n=0;n<i.length;n++){var s=i[n];(s.f&C)!==0?Pr(s,t,!1):t===s&&(r?T(s,q):(s.f&j)!==0&&T(s,ae),ie(s))}}function qr(e){var t=N,r=M,i=z,n=h,s=B,l=U,a=G,o=be,u=e.f;N=null,M=0,z=null,h=(u&(le|Se))===0?e:null,B=null,Fe(e.ctx),G=!1,be=++ye,e.ac!==null&&(_t(()=>{e.ac.abort(je)}),e.ac=null);try{e.f|=Ot;var d=e.fn,c=d(),f=e.deps;if(N!==null){var v;if(ct(e,M),f!==null&&M>0)for(f.length=M+N.length,v=0;v<N.length;v++)f[M+v]=N[v];else e.deps=f=N;if(Ut()&&(e.f&W)!==0)for(v=M;v<f.length;v++)(f[v].reactions??=[]).push(e)}else f!==null&&M<f.length&&(ct(e,M),f.length=M);if(fr()&&z!==null&&!G&&f!==null&&(e.f&(C|ae|q))===0)for(v=0;v<z.length;v++)Pr(z[v],e);if(n!==null&&n!==e){if(ye++,n.deps!==null)for(let g=0;g<r;g+=1)n.deps[g].rv=ye;if(t!==null)for(const g of t)g.rv=ye;z!==null&&(i===null?i=z:i.push(...z))}return(e.f&ue)!==0&&(e.f^=ue),c}catch(g){return cr(g)}finally{e.f^=Ot,N=t,M=r,z=i,h=n,B=s,Fe(l),G=a,be=o}}function Hn(e,t){let r=t.reactions;if(r!==null){var i=Jr.call(r,e);if(i!==-1){var n=r.length-1;n===0?r=t.reactions=null:(r[i]=r[n],r.pop())}}if(r===null&&(t.f&C)!==0&&(N===null||!De.call(N,t))){var s=t;(s.f&W)!==0&&(s.f^=W,s.f&=~we),Mt(s),gr(s),ct(s,0)}}function ct(e,t){var r=e.deps;if(r!==null)for(var i=t;i<r.length;i++)Hn(e,r[i])}function Ze(e){var t=e.f;if((t&fe)===0){T(e,j);var r=b,i=lt;b=e,lt=!0;try{(t&(se|ir))!==0?Ln(e):Cr(e),Ar(e);var n=qr(e);e.teardown=typeof n=="function"?n:null,e.wv=Fr;var s}finally{lt=i,b=r}}}async function Vn(){await Promise.resolve(),yn()}function _(e){var t=e.f,r=(t&C)!==0;if(h!==null&&!G){var i=b!==null&&(b.f&fe)!==0;if(!i&&(B===null||!De.call(B,e))){var n=h.deps;if((h.f&Ot)!==0)e.rv<ye&&(e.rv=ye,N===null&&n!==null&&n[M]===e?M++:N===null?N=[e]:N.push(e));else{(h.deps??=[]).push(e);var s=e.reactions;s===null?e.reactions=[h]:De.call(s,h)||s.push(h)}}}if(Ee&&de.has(e))return de.get(e);if(r){var l=e;if(Ee){var a=l.v;return((l.f&j)===0&&l.reactions!==null||$r(l))&&(a=$t(l)),de.set(l,a),a}var o=(l.f&W)===0&&!G&&h!==null&&(lt||(h.f&W)!==0),u=l.deps===null;Xe(l)&&(o&&(l.f|=W),mr(l)),o&&!u&&Mr(l)}if(Y?.has(e))return Y.get(e);if((e.f&ue)!==0)throw e.v;return e.v}function Mr(e){if(e.deps!==null){e.f|=W;for(const t of e.deps)(t.reactions??=[]).push(e),(t.f&C)!==0&&(t.f&W)===0&&Mr(t)}}function $r(e){if(e.v===A)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(de.has(t)||(t.f&C)!==0&&$r(t))return!0;return!1}function yt(e){var t=G;try{return G=!0,e()}finally{G=t}}const Yn=["touchstart","touchmove"];function Gn(e){return Yn.includes(e)}const Lr=new Set,Ft=new Set;function Jn(e,t,r,i={}){function n(s){if(i.capture||He.call(t,s),!s.cancelBubble)return _t(()=>r?.call(this,s))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?ne(()=>{t.addEventListener(e,n,i)}):t.addEventListener(e,n,i),n}function Kt(e,t,r,i,n){var s={capture:i,passive:n},l=Jn(e,t,r,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&gt(()=>{t.removeEventListener(e,l,s)})}function Kn(e){for(var t=0;t<e.length;t++)Lr.add(e[t]);for(var r of Ft)r(e)}let Qt=null;function He(e){var t=this,r=t.ownerDocument,i=e.type,n=e.composedPath?.()||[],s=n[0]||e.target;Qt=e;var l=0,a=Qt===e&&e.__root;if(a){var o=n.indexOf(a);if(o!==-1&&(t===document||t===window)){e.__root=t;return}var u=n.indexOf(t);if(u===-1)return;o<=u&&(l=o)}if(s=n[l]||e.target,s!==t){Qr(e,"currentTarget",{configurable:!0,get(){return s||r}});var d=h,c=b;P(null),X(null);try{for(var f,v=[];s!==null;){var g=s.assignedSlot||s.parentNode||s.host||null;try{var D=s["__"+i];D!=null&&(!s.disabled||e.target===s)&&D.call(s,e)}catch(I){f?v.push(I):f=I}if(e.cancelBubble||g===t||g===null)break;s=g}if(f){for(let I of v)queueMicrotask(()=>{throw I});throw f}}finally{e.__root=t,delete e.currentTarget,P(d),X(c)}}}function Qn(e){var t=document.createElement("template");return t.innerHTML=e.replaceAll("<!>","<!---->"),t.content}function Zn(e,t){var r=b;r.nodes===null&&(r.nodes={start:e,end:t,a:null,t:null})}function bt(e,t){var r=(t&hn)!==0,i,n=!e.startsWith("<!>");return()=>{i===void 0&&(i=Qn(n?e:"<!>"+e),i=xr(i));var s=r||Er?document.importNode(i,!0):i.cloneNode(!0);return Zn(s,s),s}}function st(e,t){e!==null&&e.before(t)}function Ce(e,t){var r=t==null?"":typeof t=="object"?t+"":t;r!==(e.__t??=e.nodeValue)&&(e.__t=r,e.nodeValue=r+"")}function Xn(e,t){return ei(e,t)}const Oe=new Map;function ei(e,{target:t,anchor:r,props:i={},events:n,context:s,intro:l=!0}){jn();var a=new Set,o=c=>{for(var f=0;f<c.length;f++){var v=c[f];if(!a.has(v)){a.add(v);var g=Gn(v);t.addEventListener(v,He,{passive:g});var D=Oe.get(v);D===void 0?(document.addEventListener(v,He,{passive:g}),Oe.set(v,1)):Oe.set(v,D+1)}}};o(Kr(Lr)),Ft.add(o);var u=void 0,d=qn(()=>{var c=r??t.appendChild(ut());return Sn(c,{pending:()=>{}},f=>{if(s){ar({});var v=U;v.c=s}n&&(i.$$events=n),u=e(f,i)||{},s&&or()}),()=>{for(var f of a){t.removeEventListener(f,He);var v=Oe.get(f);--v===0?(document.removeEventListener(f,He),Oe.delete(f)):Oe.set(f,v)}Ft.delete(o),c!==r&&c.parentNode?.removeChild(c)}});return ti.set(u,d),u}let ti=new WeakMap;class ri{anchor;#t=new Map;#l=new Map;#e=new Map;#i=new Set;#s=!0;constructor(t,r=!0){this.anchor=t,this.#s=r}#n=()=>{var t=y;if(this.#t.has(t)){var r=this.#t.get(t),i=this.#l.get(r);if(i)zn(i),this.#i.delete(r);else{var n=this.#e.get(r);n&&(this.#l.set(r,n.effect),this.#e.delete(r),n.fragment.lastChild.remove(),this.anchor.before(n.fragment),i=n.effect)}for(const[s,l]of this.#t){if(this.#t.delete(s),s===t)break;const a=this.#e.get(l);a&&(L(a.effect),this.#e.delete(l))}for(const[s,l]of this.#l){if(s===r||this.#i.has(s))continue;const a=()=>{if(Array.from(this.#t.values()).includes(s)){var u=document.createDocumentFragment();Ir(l,u),u.append(ut()),this.#e.set(s,{effect:l,fragment:u})}else L(l);this.#i.delete(s),this.#l.delete(s)};this.#s||!i?(this.#i.add(s),Ke(l,a,!1)):a()}}};#r=t=>{this.#t.delete(t);const r=Array.from(this.#t.values());for(const[i,n]of this.#e)r.includes(i)||(L(n.effect),this.#e.delete(i))};ensure(t,r){var i=y,n=Dn();if(r&&!this.#l.has(t)&&!this.#e.has(t))if(n){var s=document.createDocumentFragment(),l=ut();s.append(l),this.#e.set(t,{effect:re(()=>r(l)),fragment:s})}else this.#l.set(t,re(()=>r(this.anchor)));if(this.#t.set(i,t),n){for(const[a,o]of this.#l)a===t?i.skipped_effects.delete(o):i.skipped_effects.add(o);for(const[a,o]of this.#e)a===t?i.skipped_effects.delete(o.effect):i.skipped_effects.add(o.effect);i.oncommit(this.#n),i.ondiscard(this.#r)}else this.#n()}}function Zt(e,t,r=!1){var i=new ri(e),n=r?Ie:0;function s(l,a){i.ensure(l,a)}Tr(()=>{var l=!1;t((a,o=!0)=>{l=!0,s(o,a)}),l||s(!1,null)},n)}function Ur(e,t,r=!1){if(e.multiple){if(t==null)return;if(!rr(t))return _n();for(var i of e.options)i.selected=t.includes(Qe(i));return}for(i of e.options){var n=Qe(i);if(wr(n,t)){i.selected=!0;return}}(!r||t!==void 0)&&(e.selectedIndex=-1)}function ni(e){var t=new MutationObserver(()=>{Ur(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),gt(()=>{t.disconnect()})}function ii(e,t,r=t){var i=new WeakSet,n=!0;pt(e,"change",s=>{var l=s?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(l),Qe);else{var o=e.querySelector(l)??e.querySelector("option:not([disabled])");a=o&&Qe(o)}r(a),y!==null&&i.add(y)}),Mn(()=>{var s=t();if(e===document.activeElement){var l=ot??y;if(i.has(l))return}if(Ur(e,s,n),n&&s===void 0){var a=e.querySelector(":checked");a!==null&&(s=Qe(a),r(s))}e.__value=s,n=!1}),ni(e)}function Qe(e){return"__value"in e?e.__value:e.value}function xt(e,t,r=t){var i=new WeakSet;pt(e,"input",async n=>{var s=n?e.defaultValue:e.value;if(s=At(e)?Ct(s):s,r(s),y!==null&&i.add(y),await Vn(),s!==(s=t())){var l=e.selectionStart,a=e.selectionEnd,o=e.value.length;if(e.value=s??"",a!==null){var u=e.value.length;l===a&&a===o&&u>o?(e.selectionStart=u,e.selectionEnd=u):(e.selectionStart=l,e.selectionEnd=Math.min(a,u))}}}),yt(t)==null&&e.value&&(r(At(e)?Ct(e.value):e.value),y!==null&&i.add(y)),mt(()=>{var n=t();if(e===document.activeElement){var s=ot??y;if(i.has(s))return}At(e)&&n===Ct(e.value)||e.type==="date"&&!n&&!e.value||n!==e.value&&(e.value=n??"")})}const kt=new Set;function Tt(e,t,r,i,n=i){var s=r.getAttribute("type")==="checkbox",l=e;if(t!==null)for(var a of t)l=l[a]??=[];l.push(r),pt(r,"change",()=>{var o=r.__value;s&&(o=li(l,o,r.checked)),n(o)},()=>n(s?[]:null)),mt(()=>{var o=i();s?(o=o||[],r.checked=o.includes(r.__value)):r.checked=wr(r.__value,o)}),gt(()=>{var o=l.indexOf(r);o!==-1&&l.splice(o,1)}),kt.has(l)||(kt.add(l),ne(()=>{l.sort((o,u)=>o.compareDocumentPosition(u)===4?-1:1),kt.delete(l)})),ne(()=>{})}function si(e,t,r=t){pt(e,"change",i=>{var n=i?e.defaultChecked:e.checked;r(n)}),yt(t)==null&&r(e.checked),mt(()=>{var i=t();e.checked=!!i})}function li(e,t,r){for(var i=new Set,n=0;n<e.length;n+=1)e[n].checked&&i.add(e[n].__value);return r||i.delete(t),Array.from(i)}function At(e){var t=e.type;return t==="number"||t==="range"}function Ct(e){return e===""?null:+e}function ai(e){U===null&&nn(),Pn(()=>{const t=yt(e);if(typeof t=="function")return t})}const oi="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(oi);const fi=/\{[^{}]+\}/g,ui=()=>typeof process=="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function ci(){return Math.random().toString(36).slice(2,11)}function di(e){let{baseUrl:t="",Request:r=globalThis.Request,fetch:i=globalThis.fetch,querySerializer:n,bodySerializer:s,headers:l,requestInitExt:a=void 0,...o}={...e};a=ui()?a:void 0,t=tr(t);const u=[];async function d(c,f){const{baseUrl:v,fetch:g=i,Request:D=r,headers:I,params:H={},parseAs:J="json",querySerializer:ve,bodySerializer:qe=s??hi,body:Me,middleware:Et=[],...$e}=f||{};let Re=t;v&&(Re=tr(v)??t);let he=typeof n=="function"?n:Xt(n);ve&&(he=typeof ve=="function"?ve:Xt({...typeof n=="object"?n:{},...ve}));const xe=Me===void 0?void 0:qe(Me,er(l,I,H.header)),Le=er(xe===void 0||xe instanceof FormData?{}:{"Content-Type":"application/json"},l,I,H.header),K=[...u,...Et],Ue={redirect:"follow",...o,...$e,body:xe,headers:Le};let _e,ke,V=new D(_i(c,{baseUrl:Re,params:H,querySerializer:he}),Ue),S;for(const x in $e)x in V||(V[x]=$e[x]);if(K.length){_e=ci(),ke=Object.freeze({baseUrl:Re,fetch:g,parseAs:J,querySerializer:he,bodySerializer:qe});for(const x of K)if(x&&typeof x=="object"&&typeof x.onRequest=="function"){const R=await x.onRequest({request:V,schemaPath:c,params:H,options:ke,id:_e});if(R)if(R instanceof D)V=R;else if(R instanceof Response){S=R;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!S){try{S=await g(V,a)}catch(x){let R=x;if(K.length)for(let Q=K.length-1;Q>=0;Q--){const Te=K[Q];if(Te&&typeof Te=="object"&&typeof Te.onError=="function"){const ge=await Te.onError({request:V,error:R,schemaPath:c,params:H,options:ke,id:_e});if(ge){if(ge instanceof Response){R=void 0,S=ge;break}if(ge instanceof Error){R=ge;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(R)throw R}if(K.length)for(let x=K.length-1;x>=0;x--){const R=K[x];if(R&&typeof R=="object"&&typeof R.onResponse=="function"){const Q=await R.onResponse({request:V,response:S,schemaPath:c,params:H,options:ke,id:_e});if(Q){if(!(Q instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");S=Q}}}}if(S.status===204||V.method==="HEAD"||S.headers.get("Content-Length")==="0")return S.ok?{data:void 0,response:S}:{error:void 0,response:S};if(S.ok)return J==="stream"?{data:S.body,response:S}:{data:await S[J](),response:S};let pe=await S.text();try{pe=JSON.parse(pe)}catch{}return{error:pe,response:S}}return{request(c,f,v){return d(f,{...v,method:c.toUpperCase()})},GET(c,f){return d(c,{...f,method:"GET"})},PUT(c,f){return d(c,{...f,method:"PUT"})},POST(c,f){return d(c,{...f,method:"POST"})},DELETE(c,f){return d(c,{...f,method:"DELETE"})},OPTIONS(c,f){return d(c,{...f,method:"OPTIONS"})},HEAD(c,f){return d(c,{...f,method:"HEAD"})},PATCH(c,f){return d(c,{...f,method:"PATCH"})},TRACE(c,f){return d(c,{...f,method:"TRACE"})},use(...c){for(const f of c)if(f){if(typeof f!="object"||!("onRequest"in f||"onResponse"in f||"onError"in f))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(f)}},eject(...c){for(const f of c){const v=u.indexOf(f);v!==-1&&u.splice(v,1)}}}}function wt(e,t,r){if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${r?.allowReserved===!0?t:encodeURIComponent(t)}`}function zr(e,t,r){if(!t||typeof t!="object")return"";const i=[],n={simple:",",label:".",matrix:";"}[r.style]||"&";if(r.style!=="deepObject"&&r.explode===!1){for(const a in t)i.push(a,r.allowReserved===!0?t[a]:encodeURIComponent(t[a]));const l=i.join(",");switch(r.style){case"form":return`${e}=${l}`;case"label":return`.${l}`;case"matrix":return`;${e}=${l}`;default:return l}}for(const l in t){const a=r.style==="deepObject"?`${e}[${l}]`:l;i.push(wt(a,t[l],r))}const s=i.join(n);return r.style==="label"||r.style==="matrix"?`${n}${s}`:s}function Wr(e,t,r){if(!Array.isArray(t))return"";if(r.explode===!1){const s={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[r.style]||",",l=(r.allowReserved===!0?t:t.map(a=>encodeURIComponent(a))).join(s);switch(r.style){case"simple":return l;case"label":return`.${l}`;case"matrix":return`;${e}=${l}`;default:return`${e}=${l}`}}const i={simple:",",label:".",matrix:";"}[r.style]||"&",n=[];for(const s of t)r.style==="simple"||r.style==="label"?n.push(r.allowReserved===!0?s:encodeURIComponent(s)):n.push(wt(e,s,r));return r.style==="label"||r.style==="matrix"?`${i}${n.join(i)}`:n.join(i)}function Xt(e){return function(r){const i=[];if(r&&typeof r=="object")for(const n in r){const s=r[n];if(s!=null){if(Array.isArray(s)){if(s.length===0)continue;i.push(Wr(n,s,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof s=="object"){i.push(zr(n,s,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}i.push(wt(n,s,e))}}return i.join("&")}}function vi(e,t){let r=e;for(const i of e.match(fi)??[]){let n=i.substring(1,i.length-1),s=!1,l="simple";if(n.endsWith("*")&&(s=!0,n=n.substring(0,n.length-1)),n.startsWith(".")?(l="label",n=n.substring(1)):n.startsWith(";")&&(l="matrix",n=n.substring(1)),!t||t[n]===void 0||t[n]===null)continue;const a=t[n];if(Array.isArray(a)){r=r.replace(i,Wr(n,a,{style:l,explode:s}));continue}if(typeof a=="object"){r=r.replace(i,zr(n,a,{style:l,explode:s}));continue}if(l==="matrix"){r=r.replace(i,`;${wt(n,a)}`);continue}r=r.replace(i,l==="label"?`.${encodeURIComponent(a)}`:encodeURIComponent(a))}return r}function hi(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get("Content-Type")??t.get("content-type"):t["Content-Type"]??t["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(e).toString():JSON.stringify(e)}function _i(e,t){let r=`${t.baseUrl}${e}`;t.params?.path&&(r=vi(r,t.params.path));let i=t.querySerializer(t.params.query??{});return i.startsWith("?")&&(i=i.substring(1)),i&&(r+=`?${i}`),r}function er(...e){const t=new Headers;for(const r of e){if(!r||typeof r!="object")continue;const i=r instanceof Headers?r.entries():Object.entries(r);for(const[n,s]of i)if(s===null)t.delete(n);else if(Array.isArray(s))for(const l of s)t.append(n,l);else s!==void 0&&t.set(n,s)}return t}function tr(e){return e.endsWith("/")?e.substring(0,e.length-1):e}var pi=bt('<div class="rss-config svelte-g26r64"><div class="svelte-g26r64"> </div> <div class="svelte-g26r64"> </div> <div class="svelte-g26r64"> </div></div>'),gi=bt('<div class="rss-status running svelte-g26r64"><strong class="svelte-g26r64">RSS Watcher is Running</strong> <!> <button type="button" class="button-danger svelte-g26r64"> </button></div>'),mi=bt('<form><div class="form-group svelte-g26r64"><label for="rss-state" class="svelte-g26r64">State (optional)</label> <input type="text" id="rss-state" name="rss-state" placeholder="e.g. CA (leave empty for all states)" maxlength="2" class="svelte-g26r64"/> <small class="svelte-g26r64">Two-letter state code, or leave empty for all states</small></div> <div class="form-group svelte-g26r64"><label class="svelte-g26r64"><input type="checkbox" class="svelte-g26r64"/> Cover pages only</label> <small class="svelte-g26r64">Import only cover pages (faster)</small></div> <div class="form-group svelte-g26r64"><label for="rss-interval" class="svelte-g26r64">Check Interval (seconds)</label> <input type="number" id="rss-interval" name="rss-interval" min="1" max="3600" class="svelte-g26r64"/> <small class="svelte-g26r64">How often to check the RSS feed (default: 60 seconds)</small></div> <button type="submit" class="svelte-g26r64"> </button></form>'),yi=bt('<main><h1>FEC Data Import</h1> <p>Import Federal Election Commission data into your Datasette database.</p> <section class="import-section svelte-g26r64"><h2>Import Data</h2> <p>Select the type of FEC data you want to import, provide an ID, and choose an election cycle.</p> <form><div class="form-group svelte-g26r64"><fieldset class="svelte-g26r64"><legend class="svelte-g26r64">Import Type</legend> <div class="radio-group svelte-g26r64"><div class="svelte-g26r64"><input id="committee" name="kind" type="radio" class="svelte-g26r64"/> <label for="committee" class="svelte-g26r64">Committee</label></div> <div class="svelte-g26r64"><input id="candidate" name="kind" type="radio" class="svelte-g26r64"/> <label for="candidate" class="svelte-g26r64">Candidate</label></div> <div class="svelte-g26r64"><input id="contest" name="kind" type="radio" class="svelte-g26r64"/> <label for="contest" class="svelte-g26r64">Contest</label></div></div></fieldset></div> <div class="form-group svelte-g26r64"><label for="id" class="svelte-g26r64">ID</label> <input type="text" id="id" name="id" placeholder="e.g. C00498667" class="svelte-g26r64"/></div> <div class="form-group svelte-g26r64"><label for="cycle" class="svelte-g26r64">Election Cycle</label> <select id="cycle" name="cycle" class="svelte-g26r64"><option>2026</option><option>2024</option><option>2022</option></select></div> <button type="submit" class="svelte-g26r64"> </button></form></section> <section class="rss-section svelte-g26r64"><h2>Watch RSS Feed</h2> <p>Automatically watch and import new FEC filings from the RSS feed.</p> <!></section></main>');function bi(e,t){ar(t,!0);const r=[],i=di({baseUrl:"/"});let n=k(!1),s=k("committee"),l=k("C00498667"),a=k(2026),o=k(!1),u=k(!1),d=k("CA"),c=k(!0),f=k(60),v=k(null);ai(()=>{g()});async function g(){try{const{data:p,error:O}=await i.GET("/-/api/libfec/rss/status");if(p&&!O&&(m(o,p.running,!0),p.config)){const F=p.config;m(v,F,!0),F.state&&m(d,F.state,!0),m(c,F.cover_only,!0),m(f,F.interval,!0)}}catch(p){console.error("Error loading RSS status:",p)}}async function D(p){if(p.preventDefault(),!_(l)){alert("Please enter an ID.");return}m(n,!0);try{const{data:O,error:F}=await i.POST("/-/api/libfec",{body:{kind:_(s),id:_(l),cycle:_(a)}});if(F){alert(`Error starting import: ${JSON.stringify(F)}`);return}alert(`Import started successfully: ${JSON.stringify(O)}`)}finally{m(n,!1)}}async function I(){m(u,!0);try{const{data:p,error:O}=await i.POST("/-/api/libfec/rss/start",{body:{state:_(d)||null,cover_only:_(c),interval:_(f)}});if(O){alert(`Error starting RSS watcher: ${JSON.stringify(O)}`);return}p&&(m(o,p.running,!0),m(v,p.config,!0),alert("RSS watcher started successfully"))}finally{m(u,!1)}}async function H(){m(u,!0);try{const{data:p,error:O}=await i.POST("/-/api/libfec/rss/stop",{});if(O){alert(`Error stopping RSS watcher: ${JSON.stringify(O)}`);return}p&&(m(o,p.running,!0),m(v,null),alert("RSS watcher stopped"))}finally{m(u,!1)}}var J=yi(),ve=E(w(J),4),qe=E(w(ve),4),Me=w(qe),Et=w(Me),$e=E(w(Et),2),Re=w($e),he=w(Re);he.value=he.__value="committee";var xe=E(Re,2),Le=w(xe);Le.value=Le.__value="candidate";var K=E(xe,2),Ue=w(K);Ue.value=Ue.__value="contest";var _e=E(Me,2),ke=E(w(_e),2),V=E(_e,2),S=E(w(V),2),pe=w(S);pe.value=pe.__value=2026;var x=E(pe);x.value=x.__value=2024;var R=E(x);R.value=R.__value=2022;var Q=E(V,2),Te=w(Q),ge=E(ve,2),Br=E(w(ge),4);{var Hr=p=>{var O=gi(),F=E(w(O),2);{var St=ze=>{var We=pi(),et=w(We),tt=w(et),rt=E(et,2),ee=w(rt),Yr=E(rt,2),Gr=w(Yr);it(()=>{Ce(tt,`State: ${(_(v).state||"All states")??""}`),Ce(ee,`Cover Only: ${_(v).cover_only?"Yes":"No"}`),Ce(Gr,`Interval: ${_(v).interval??""} seconds`)}),st(ze,We)};Zt(F,ze=>{_(v)&&ze(St)})}var Ae=E(F,2);Ae.__click=H;var Rt=w(Ae);it(()=>{Ae.disabled=_(u),Ce(Rt,_(u)?"Stopping...":"Stop Watcher")}),st(p,O)},Vr=p=>{var O=mi(),F=w(O),St=E(w(F),2),Ae=E(F,2),Rt=w(Ae),ze=w(Rt),We=E(Ae,2),et=E(w(We),2),tt=E(We,2),rt=w(tt);it(()=>{tt.disabled=_(u),Ce(rt,_(u)?"Starting...":"Start RSS Watcher")}),Kt("submit",O,ee=>{ee.preventDefault(),I()}),xt(St,()=>_(d),ee=>m(d,ee)),si(ze,()=>_(c),ee=>m(c,ee)),xt(et,()=>_(f),ee=>m(f,ee)),st(p,O)};Zt(Br,p=>{_(o)?p(Hr):p(Vr,!1)})}it(()=>{Q.disabled=_(n),Ce(Te,_(n)?"Importing...":"Import Data")}),Kt("submit",qe,D),Tt(r,[],he,()=>_(s),p=>m(s,p)),Tt(r,[],Le,()=>_(s),p=>m(s,p)),Tt(r,[],Ue,()=>_(s),p=>m(s,p)),xt(ke,()=>_(l),p=>m(l,p)),ii(S,()=>_(a),p=>m(a,p)),st(e,J),or()}Kn(["click"]);Xn(bi,{target:document.getElementById("root")});
@@ -0,0 +1,14 @@
1
+
2
+ {% extends "base.html" %}
3
+
4
+ {% block title %}FEC Import{% endblock %}
5
+
6
+ {% block extra_head %}
7
+ {{ datasette_libfec_vite_entry("src/index_view.ts") | safe }}
8
+ {% endblock %}
9
+
10
+ {% block content %}
11
+
12
+ <div id="root"></div>
13
+
14
+ {% endblock %}
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: datasette-libfec
3
+ Version: 0.0.1a4
4
+ Author: Alex Garcia
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/datasette/datasette-libfec
7
+ Project-URL: Changelog, https://github.com/datasette/datasette-libfec/releases
8
+ Project-URL: Issues, https://github.com/datasette/datasette-libfec/issues
9
+ Project-URL: CI, https://github.com/datasette/datasette-libfec/actions
10
+ Classifier: Framework :: Datasette
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: datasette>=1a23
15
+ Requires-Dist: datasette-plugin-router>=0.0.1a2
16
+ Requires-Dist: libfec>=0.0.18
17
+ Dynamic: license-file
18
+
19
+ # datasette-libfec
20
+
21
+ [![PyPI](https://img.shields.io/pypi/v/datasette-libfec.svg)](https://pypi.org/project/datasette-libfec/)
22
+ [![Changelog](https://img.shields.io/github/v/release/datasette/datasette-libfec?include_prereleases&label=changelog)](https://github.com/datasette/datasette-libfec/releases)
23
+ [![Tests](https://github.com/datasette/datasette-libfec/actions/workflows/test.yml/badge.svg)](https://github.com/datasette/datasette-libfec/actions/workflows/test.yml)
24
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/datasette/datasette-libfec/blob/main/LICENSE)
25
+
26
+
27
+
28
+ ## Installation
29
+
30
+ Install this plugin in the same environment as Datasette.
31
+ ```bash
32
+ datasette install datasette-libfec
33
+ ```
34
+ ## Usage
35
+
36
+ Usage instructions go here.
37
+
38
+ ## Development
39
+
40
+ To set up this plugin locally, first checkout the code. You can confirm it is available like this:
41
+ ```bash
42
+ cd datasette-libfec
43
+ # Confirm the plugin is visible
44
+ uv run datasette plugins
45
+ ```
46
+ To run the tests:
47
+ ```bash
48
+ uv run pytest
49
+ ```
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ datasette_libfec/__init__.py
5
+ datasette_libfec/libfec_client.py
6
+ datasette_libfec/manifest.json
7
+ datasette_libfec/routes.py
8
+ datasette_libfec.egg-info/PKG-INFO
9
+ datasette_libfec.egg-info/SOURCES.txt
10
+ datasette_libfec.egg-info/dependency_links.txt
11
+ datasette_libfec.egg-info/entry_points.txt
12
+ datasette_libfec.egg-info/requires.txt
13
+ datasette_libfec.egg-info/top_level.txt
14
+ datasette_libfec/static/gen/index-6cjSv2YC.css
15
+ datasette_libfec/static/gen/index-CaTQMY-X.js
16
+ datasette_libfec/templates/libfec.html
17
+ tests/test_libfec.py
@@ -0,0 +1,2 @@
1
+ [datasette]
2
+ libfec = datasette_libfec
@@ -0,0 +1,3 @@
1
+ datasette>=1a23
2
+ datasette-plugin-router>=0.0.1a2
3
+ libfec>=0.0.18
@@ -0,0 +1,4 @@
1
+ datasette_libfec
2
+ dist
3
+ frontend
4
+ tests
@@ -0,0 +1,48 @@
1
+ [project]
2
+ name = "datasette-libfec"
3
+ version = "0.0.1a4"
4
+ description = ""
5
+ readme = "README.md"
6
+ authors = [{name = "Alex Garcia"}]
7
+ license = "Apache-2.0"
8
+ classifiers=[
9
+ "Framework :: Datasette"
10
+ ]
11
+ requires-python = ">=3.10"
12
+ dependencies = [
13
+ "datasette>=1a23",
14
+ "datasette-plugin-router>=0.0.1a2",
15
+ "libfec>=0.0.18",
16
+ ]
17
+
18
+ [dependency-groups]
19
+ dev = [
20
+ "pytest",
21
+ "pytest-asyncio"
22
+ ]
23
+
24
+ [build-system]
25
+ requires = ["setuptools"]
26
+ build-backend = "setuptools.build_meta"
27
+
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/datasette/datasette-libfec"
31
+ Changelog = "https://github.com/datasette/datasette-libfec/releases"
32
+ Issues = "https://github.com/datasette/datasette-libfec/issues"
33
+ CI = "https://github.com/datasette/datasette-libfec/actions"
34
+
35
+ [project.entry-points.datasette]
36
+ libfec = "datasette_libfec"
37
+
38
+ [tool.pytest.ini_options]
39
+ asyncio_mode = "strict"
40
+ asyncio_default_fixture_loop_scope = "function"
41
+
42
+ [tool.setuptools.package-data]
43
+ datasette_libfec = ["static/**/*", "templates/*", "manifest.json", "schema.sql"]
44
+
45
+ [tool.setuptools.packages.find]
46
+ exclude = [
47
+ "frontend",
48
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ from datasette.app import Datasette
2
+ import pytest
3
+
4
+
5
+ @pytest.mark.asyncio
6
+ async def test_plugin_is_installed():
7
+ datasette = Datasette(memory=True)
8
+ response = await datasette.client.get("/-/plugins.json")
9
+ assert response.status_code == 200
10
+ installed_plugins = {p["name"] for p in response.json()}
11
+ assert "datasette-libfec" in installed_plugins