Spaces:
Runtime error
Runtime error
Ruben Gres
commited on
Commit
•
ec3efd7
1
Parent(s):
c76c726
first commit
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes copy +34 -0
- .gitignore +1 -0
- Dockerfile +14 -0
- Makefile +24 -0
- README copy.md +10 -0
- app.py +55 -0
- frontend/.svelte-kit/build/hooks.js +0 -0
- frontend/.svelte-kit/build/index.js +81 -0
- frontend/.svelte-kit/generated/client-manifest.js +11 -0
- frontend/.svelte-kit/generated/client-matchers.js +1 -0
- frontend/.svelte-kit/generated/root.svelte +56 -0
- frontend/.svelte-kit/output/client/_app/immutable/assets/pages/__layout.svelte-dcfcba4b.css +1 -0
- frontend/.svelte-kit/output/client/_app/immutable/assets/pages/index.svelte-65a37285.css +1 -0
- frontend/.svelte-kit/output/client/_app/immutable/chunks/index-bcf2726a.js +1 -0
- frontend/.svelte-kit/output/client/_app/immutable/chunks/paths-d3bcbd10.js +1 -0
- frontend/.svelte-kit/output/client/_app/immutable/error.svelte-d9523301.js +1 -0
- frontend/.svelte-kit/output/client/_app/immutable/manifest.json +59 -0
- frontend/.svelte-kit/output/client/_app/immutable/pages/__layout.svelte-0c386344.js +1 -0
- frontend/.svelte-kit/output/client/_app/immutable/pages/index.svelte-6350336a.js +1 -0
- frontend/.svelte-kit/output/client/_app/immutable/start-a60c2789.js +1 -0
- frontend/.svelte-kit/output/client/_app/version.json +1 -0
- frontend/.svelte-kit/output/prerendered/fallback.html +28 -0
- frontend/.svelte-kit/output/prerendered/pages/index.html +151 -0
- frontend/.svelte-kit/output/server/chunks/hooks-1c45ba0b.js +1 -0
- frontend/.svelte-kit/output/server/chunks/index-445fd704.js +112 -0
- frontend/.svelte-kit/output/server/chunks/paths-396f020f.js +7 -0
- frontend/.svelte-kit/output/server/entries/fallbacks/error.svelte.js +21 -0
- frontend/.svelte-kit/output/server/entries/pages/__layout.svelte.js +6 -0
- frontend/.svelte-kit/output/server/entries/pages/index.svelte.js +340 -0
- frontend/.svelte-kit/output/server/index.js +2291 -0
- frontend/.svelte-kit/output/server/manifest.js +30 -0
- frontend/.svelte-kit/output/server/manifest.json +56 -0
- frontend/.svelte-kit/output/server/nodes/0.js +7 -0
- frontend/.svelte-kit/output/server/nodes/1.js +7 -0
- frontend/.svelte-kit/output/server/nodes/2.js +7 -0
- frontend/.svelte-kit/runtime/app/env.js +28 -0
- frontend/.svelte-kit/runtime/app/navigation.js +24 -0
- frontend/.svelte-kit/runtime/app/paths.js +1 -0
- frontend/.svelte-kit/runtime/app/stores.js +97 -0
- frontend/.svelte-kit/runtime/client/singletons.js +13 -0
- frontend/.svelte-kit/runtime/client/start.js +1789 -0
- frontend/.svelte-kit/runtime/components/error.svelte +29 -0
- frontend/.svelte-kit/runtime/components/layout.svelte +1 -0
- frontend/.svelte-kit/runtime/env.js +8 -0
- frontend/.svelte-kit/runtime/paths.js +13 -0
- frontend/.svelte-kit/runtime/server/index.js +3395 -0
- frontend/.svelte-kit/tsconfig.json +36 -0
- frontend/.svelte-kit/types/src/routes/__types/__layout.d.ts +7 -0
- frontend/.svelte-kit/types/src/routes/__types/index.d.ts +7 -0
- frontend/README.md +38 -0
.gitattributes copy
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
input_image.jpg
|
Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
WORKDIR /app
|
3 |
+
|
4 |
+
COPY ./requirements.txt /app/requirements.txt
|
5 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
6 |
+
|
7 |
+
ENV HOME=/home/user \
|
8 |
+
PATH=/home/user/.local/bin:$PATH \
|
9 |
+
PORT=7860 \
|
10 |
+
URL_GRADIO=https://rgres-drawing2map.hf.space/
|
11 |
+
|
12 |
+
COPY ./static/ ./
|
13 |
+
|
14 |
+
CMD ["python", "app.py"]
|
Makefile
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
install-node:
|
2 |
+
./install-node.sh
|
3 |
+
|
4 |
+
build-client:
|
5 |
+
cd frontend && npm install && npm run build && rm -rf ../static && cp -r build/ ../static/
|
6 |
+
|
7 |
+
build-dev:
|
8 |
+
cd frontend && npm install && NODE_ENV=development npm run build && rm -rf ../static 2>&1 && cp -rv build/ ../static/
|
9 |
+
|
10 |
+
run-dev:
|
11 |
+
FLASK_DEBUG=development python app.py
|
12 |
+
|
13 |
+
run-prod:
|
14 |
+
python app.py & python gradio-app.py
|
15 |
+
|
16 |
+
run-mock:
|
17 |
+
python app.py & python gradio-mock-app.py
|
18 |
+
|
19 |
+
stop-server:
|
20 |
+
killall python
|
21 |
+
|
22 |
+
all: run-prod
|
23 |
+
|
24 |
+
mock: run-mock
|
README copy.md
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Drawing2Map
|
3 |
+
emoji: 🌍
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: red
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
---
|
9 |
+
|
10 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from flask import Flask, request
|
3 |
+
import requests
|
4 |
+
from gradio_client import Client
|
5 |
+
import base64
|
6 |
+
|
7 |
+
|
8 |
+
base_gradio_url = os.getenv('URL_GRADIO', 'http://localhost:7860')
|
9 |
+
client = None
|
10 |
+
|
11 |
+
app = Flask(__name__, static_url_path='/static')
|
12 |
+
|
13 |
+
@app.route('/')
|
14 |
+
def index():
|
15 |
+
return app.send_static_file('index.html')
|
16 |
+
|
17 |
+
def save_base64_image(base64Image):
|
18 |
+
image_data = base64.b64decode(base64Image)
|
19 |
+
path = "input_image.jpg"
|
20 |
+
with open(path, 'wb') as f:
|
21 |
+
f.write(image_data)
|
22 |
+
return path
|
23 |
+
|
24 |
+
def encode_image_to_base64(filepath):
|
25 |
+
with open(filepath, "rb") as image_file:
|
26 |
+
encoded_image = base64.b64encode(image_file.read()).decode("utf-8")
|
27 |
+
return encoded_image
|
28 |
+
|
29 |
+
@app.route('/predict', methods=['POST'])
|
30 |
+
def predict():
|
31 |
+
global client
|
32 |
+
if not client:
|
33 |
+
client = Client(base_gradio_url)
|
34 |
+
|
35 |
+
data = request.get_json()
|
36 |
+
|
37 |
+
base64Image = data['data'][0]
|
38 |
+
prompt = data['data'][1]
|
39 |
+
steps = data['data'][2]
|
40 |
+
seed = data['data'][3]
|
41 |
+
|
42 |
+
b64meta, b64_data = base64Image.split(',')
|
43 |
+
|
44 |
+
image_path = save_base64_image(b64_data)
|
45 |
+
|
46 |
+
result = client.predict(
|
47 |
+
image_path, prompt, steps, seed, fn_index=0
|
48 |
+
)
|
49 |
+
|
50 |
+
return b64meta + ',' + encode_image_to_base64(result)
|
51 |
+
|
52 |
+
|
53 |
+
if __name__ == '__main__':
|
54 |
+
app.run(host='0.0.0.0', port=int(
|
55 |
+
os.environ.get('PORT', 8000)), debug=True)
|
frontend/.svelte-kit/build/hooks.js
ADDED
File without changes
|
frontend/.svelte-kit/build/index.js
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import root from '__GENERATED__/root.svelte';
|
3 |
+
import { respond } from '/workspaces/Drawing2Map-hfspace/frontend/.svelte-kit/runtime/server/index.js';
|
4 |
+
import { set_paths, assets, base } from '/workspaces/Drawing2Map-hfspace/frontend/.svelte-kit/runtime/paths.js';
|
5 |
+
import { set_prerendering } from '/workspaces/Drawing2Map-hfspace/frontend/.svelte-kit/runtime/env.js';
|
6 |
+
|
7 |
+
const template = ({ head, body, assets, nonce }) => "<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"" + assets + "/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<script src=\"https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js\"></script>\n\t\t" + head + "\n\t</head>\n\t<body class=\"light:bg-white bg-[rgb(11,15,25)] light:text-black text-white\">\n\t\t" + body + "\n\t</body>\t\n</html>\n";
|
8 |
+
|
9 |
+
let read = null;
|
10 |
+
|
11 |
+
set_paths({"base":"/static","assets":""});
|
12 |
+
|
13 |
+
let default_protocol = 'https';
|
14 |
+
|
15 |
+
// allow paths to be globally overridden
|
16 |
+
// in svelte-kit preview and in prerendering
|
17 |
+
export function override(settings) {
|
18 |
+
default_protocol = settings.protocol || default_protocol;
|
19 |
+
set_paths(settings.paths);
|
20 |
+
set_prerendering(settings.prerendering);
|
21 |
+
read = settings.read;
|
22 |
+
}
|
23 |
+
|
24 |
+
export class Server {
|
25 |
+
constructor(manifest) {
|
26 |
+
this.options = {
|
27 |
+
csp: {"mode":"auto","directives":{"upgrade-insecure-requests":false,"block-all-mixed-content":false}},
|
28 |
+
dev: false,
|
29 |
+
floc: false,
|
30 |
+
get_stack: error => String(error), // for security
|
31 |
+
handle_error: (error, event) => {
|
32 |
+
this.options.hooks.handleError({
|
33 |
+
error,
|
34 |
+
event,
|
35 |
+
|
36 |
+
// TODO remove for 1.0
|
37 |
+
// @ts-expect-error
|
38 |
+
get request() {
|
39 |
+
throw new Error('request in handleError has been replaced with event. See https://github.com/sveltejs/kit/pull/3384 for details');
|
40 |
+
}
|
41 |
+
});
|
42 |
+
error.stack = this.options.get_stack(error);
|
43 |
+
},
|
44 |
+
hooks: null,
|
45 |
+
hydrate: true,
|
46 |
+
manifest,
|
47 |
+
method_override: {"parameter":"_method","allowed":[]},
|
48 |
+
paths: { base, assets },
|
49 |
+
prefix: assets + '/_app/immutable/',
|
50 |
+
prerender: {
|
51 |
+
default: true,
|
52 |
+
enabled: true
|
53 |
+
},
|
54 |
+
read,
|
55 |
+
root,
|
56 |
+
service_worker: null,
|
57 |
+
router: true,
|
58 |
+
template,
|
59 |
+
template_contains_nonce: false,
|
60 |
+
trailing_slash: "never"
|
61 |
+
};
|
62 |
+
}
|
63 |
+
|
64 |
+
async respond(request, options = {}) {
|
65 |
+
if (!(request instanceof Request)) {
|
66 |
+
throw new Error('The first argument to server.respond must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details');
|
67 |
+
}
|
68 |
+
|
69 |
+
if (!this.options.hooks) {
|
70 |
+
const module = await import("./hooks.js");
|
71 |
+
this.options.hooks = {
|
72 |
+
getSession: module.getSession || (() => ({})),
|
73 |
+
handle: module.handle || (({ event, resolve }) => resolve(event)),
|
74 |
+
handleError: module.handleError || (({ error }) => console.error(error.stack)),
|
75 |
+
externalFetch: module.externalFetch || fetch
|
76 |
+
};
|
77 |
+
}
|
78 |
+
|
79 |
+
return respond(request, this.options, options);
|
80 |
+
}
|
81 |
+
}
|
frontend/.svelte-kit/generated/client-manifest.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export { matchers } from './client-matchers.js';
|
2 |
+
|
3 |
+
export const components = [
|
4 |
+
() => import("../../src/routes/__layout.svelte"),
|
5 |
+
() => import("../runtime/components/error.svelte"),
|
6 |
+
() => import("../../src/routes/index.svelte")
|
7 |
+
];
|
8 |
+
|
9 |
+
export const dictionary = {
|
10 |
+
"": [[0, 2], [1]]
|
11 |
+
};
|
frontend/.svelte-kit/generated/client-matchers.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export const matchers = {};
|
frontend/.svelte-kit/generated/root.svelte
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- This file is generated by @sveltejs/kit — do not edit it! -->
|
2 |
+
<script>
|
3 |
+
import { setContext, afterUpdate, onMount } from 'svelte';
|
4 |
+
|
5 |
+
// stores
|
6 |
+
export let stores;
|
7 |
+
export let page;
|
8 |
+
|
9 |
+
export let components;
|
10 |
+
export let props_0 = null;
|
11 |
+
export let props_1 = null;
|
12 |
+
export let props_2 = null;
|
13 |
+
|
14 |
+
setContext('__svelte__', stores);
|
15 |
+
|
16 |
+
$: stores.page.set(page);
|
17 |
+
afterUpdate(stores.page.notify);
|
18 |
+
|
19 |
+
let mounted = false;
|
20 |
+
let navigated = false;
|
21 |
+
let title = null;
|
22 |
+
|
23 |
+
onMount(() => {
|
24 |
+
const unsubscribe = stores.page.subscribe(() => {
|
25 |
+
if (mounted) {
|
26 |
+
navigated = true;
|
27 |
+
title = document.title || 'untitled page';
|
28 |
+
}
|
29 |
+
});
|
30 |
+
|
31 |
+
mounted = true;
|
32 |
+
return unsubscribe;
|
33 |
+
});
|
34 |
+
</script>
|
35 |
+
|
36 |
+
{#if components[1]}
|
37 |
+
<svelte:component this={components[0]} {...(props_0 || {})}>
|
38 |
+
{#if components[2]}
|
39 |
+
<svelte:component this={components[1]} {...(props_1 || {})}>
|
40 |
+
<svelte:component this={components[2]} {...(props_2 || {})}/>
|
41 |
+
</svelte:component>
|
42 |
+
{:else}
|
43 |
+
<svelte:component this={components[1]} {...(props_1 || {})} />
|
44 |
+
{/if}
|
45 |
+
</svelte:component>
|
46 |
+
{:else}
|
47 |
+
<svelte:component this={components[0]} {...(props_0 || {})} />
|
48 |
+
{/if}
|
49 |
+
|
50 |
+
{#if mounted}
|
51 |
+
<div id="svelte-announcer" aria-live="assertive" aria-atomic="true" style="position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px">
|
52 |
+
{#if navigated}
|
53 |
+
{title}
|
54 |
+
{/if}
|
55 |
+
</div>
|
56 |
+
{/if}
|
frontend/.svelte-kit/output/client/_app/immutable/assets/pages/__layout.svelte-dcfcba4b.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
@import"https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;500;600;700;800&display=swap";*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}html{font-family:Open Sans,sans-serif}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::-webkit-backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where([class~="lead"]):not(:where([class~="not-prose"] *)){color:var(--tw-prose-lead);font-size:1.25em;line-height:1.6;margin-top:1.2em;margin-bottom:1.2em}.prose :where(a):not(:where([class~="not-prose"] *)){color:var(--tw-prose-links);text-decoration:underline;font-weight:500}.prose :where(strong):not(:where([class~="not-prose"] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(ol):not(:where([class~="not-prose"] *)){list-style-type:decimal;padding-left:1.625em}.prose :where(ol[type="A"]):not(:where([class~="not-prose"] *)){list-style-type:upper-alpha}.prose :where(ol[type="a"]):not(:where([class~="not-prose"] *)){list-style-type:lower-alpha}.prose :where(ol[type="A" s]):not(:where([class~="not-prose"] *)){list-style-type:upper-alpha}.prose :where(ol[type="a" s]):not(:where([class~="not-prose"] *)){list-style-type:lower-alpha}.prose :where(ol[type="I"]):not(:where([class~="not-prose"] *)){list-style-type:upper-roman}.prose :where(ol[type="i"]):not(:where([class~="not-prose"] *)){list-style-type:lower-roman}.prose :where(ol[type="I" s]):not(:where([class~="not-prose"] *)){list-style-type:upper-roman}.prose :where(ol[type="i" s]):not(:where([class~="not-prose"] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~="not-prose"] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~="not-prose"] *)){list-style-type:disc;padding-left:1.625em}.prose :where(ol > li):not(:where([class~="not-prose"] *))::marker{font-weight:400;color:var(--tw-prose-counters)}.prose :where(ul > li):not(:where([class~="not-prose"] *))::marker{color:var(--tw-prose-bullets)}.prose :where(hr):not(:where([class~="not-prose"] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~="not-prose"] *)){font-weight:500;font-style:italic;color:var(--tw-prose-quotes);border-left-width:.25rem;border-left-color:var(--tw-prose-quote-borders);quotes:"\201c""\201d""\2018""\2019";margin-top:1.6em;margin-bottom:1.6em;padding-left:1em}.prose :where(h1):not(:where([class~="not-prose"] *)){color:var(--tw-prose-headings);font-weight:800;font-size:2.25em;margin-top:0;margin-bottom:.8888889em;line-height:1.1111111}.prose :where(h1 strong):not(:where([class~="not-prose"] *)){font-weight:900}.prose :where(h2):not(:where([class~="not-prose"] *)){color:var(--tw-prose-headings);font-weight:700;font-size:1.5em;margin-top:2em;margin-bottom:1em;line-height:1.3333333}.prose :where(h2 strong):not(:where([class~="not-prose"] *)){font-weight:800}.prose :where(h3):not(:where([class~="not-prose"] *)){color:var(--tw-prose-headings);font-weight:600;font-size:1.25em;margin-top:1.6em;margin-bottom:.6em;line-height:1.6}.prose :where(h3 strong):not(:where([class~="not-prose"] *)){font-weight:700}.prose :where(h4):not(:where([class~="not-prose"] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.5em;margin-bottom:.5em;line-height:1.5}.prose :where(h4 strong):not(:where([class~="not-prose"] *)){font-weight:700}.prose :where(figure > *):not(:where([class~="not-prose"] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~="not-prose"] *)){color:var(--tw-prose-captions);font-size:.875em;line-height:1.4285714;margin-top:.8571429em}.prose :where(a code):not(:where([class~="not-prose"] *)){color:var(--tw-prose-links)}.prose :where(pre code):not(:where([class~="not-prose"] *)):before{content:none}.prose :where(pre code):not(:where([class~="not-prose"] *)):after{content:none}.prose :where(table):not(:where([class~="not-prose"] *)){width:100%;table-layout:auto;text-align:left;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.7142857}.prose :where(thead):not(:where([class~="not-prose"] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~="not-prose"] *)){color:var(--tw-prose-headings);font-weight:600;vertical-align:bottom;padding-right:.5714286em;padding-bottom:.5714286em;padding-left:.5714286em}.prose :where(tbody tr):not(:where([class~="not-prose"] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~="not-prose"] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~="not-prose"] *)){vertical-align:baseline;padding:.5714286em}.prose{--tw-prose-body: #374151;--tw-prose-headings: #111827;--tw-prose-lead: #4b5563;--tw-prose-links: #111827;--tw-prose-bold: #111827;--tw-prose-counters: #6b7280;--tw-prose-bullets: #d1d5db;--tw-prose-hr: #e5e7eb;--tw-prose-quotes: #111827;--tw-prose-quote-borders: #e5e7eb;--tw-prose-captions: #6b7280;--tw-prose-code: #111827;--tw-prose-pre-code: #e5e7eb;--tw-prose-pre-bg: #1f2937;--tw-prose-th-borders: #d1d5db;--tw-prose-td-borders: #e5e7eb;--tw-prose-invert-body: #d1d5db;--tw-prose-invert-headings: #fff;--tw-prose-invert-lead: #9ca3af;--tw-prose-invert-links: #fff;--tw-prose-invert-bold: #fff;--tw-prose-invert-counters: #9ca3af;--tw-prose-invert-bullets: #4b5563;--tw-prose-invert-hr: #374151;--tw-prose-invert-quotes: #f3f4f6;--tw-prose-invert-quote-borders: #374151;--tw-prose-invert-captions: #9ca3af;--tw-prose-invert-code: #fff;--tw-prose-invert-pre-code: #d1d5db;--tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);--tw-prose-invert-th-borders: #4b5563;--tw-prose-invert-td-borders: #374151;font-size:1rem;line-height:1.75}.prose :where(p):not(:where([class~="not-prose"] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(img):not(:where([class~="not-prose"] *)){margin-top:2em;margin-bottom:2em}.prose :where(video):not(:where([class~="not-prose"] *)){margin-top:2em;margin-bottom:2em}.prose :where(figure):not(:where([class~="not-prose"] *)){margin-top:2em;margin-bottom:2em}.prose :where(h2 code):not(:where([class~="not-prose"] *)){font-size:.875em}.prose :where(h3 code):not(:where([class~="not-prose"] *)){font-size:.9em}.prose :where(li):not(:where([class~="not-prose"] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol > li):not(:where([class~="not-prose"] *)){padding-left:.375em}.prose :where(ul > li):not(:where([class~="not-prose"] *)){padding-left:.375em}.prose>:where(ul > li p):not(:where([class~="not-prose"] *)){margin-top:.75em;margin-bottom:.75em}.prose>:where(ul > li > *:first-child):not(:where([class~="not-prose"] *)){margin-top:1.25em}.prose>:where(ul > li > *:last-child):not(:where([class~="not-prose"] *)){margin-bottom:1.25em}.prose>:where(ol > li > *:first-child):not(:where([class~="not-prose"] *)){margin-top:1.25em}.prose>:where(ol > li > *:last-child):not(:where([class~="not-prose"] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~="not-prose"] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(hr + *):not(:where([class~="not-prose"] *)){margin-top:0}.prose :where(h2 + *):not(:where([class~="not-prose"] *)){margin-top:0}.prose :where(h3 + *):not(:where([class~="not-prose"] *)){margin-top:0}.prose :where(h4 + *):not(:where([class~="not-prose"] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~="not-prose"] *)){padding-left:0}.prose :where(thead th:last-child):not(:where([class~="not-prose"] *)){padding-right:0}.prose :where(tbody td:first-child):not(:where([class~="not-prose"] *)){padding-left:0}.prose :where(tbody td:last-child):not(:where([class~="not-prose"] *)){padding-right:0}.prose>:where(:first-child):not(:where([class~="not-prose"] *)){margin-top:0}.prose>:where(:last-child):not(:where([class~="not-prose"] *)){margin-bottom:0}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.bottom-0{bottom:0px}.left-0{left:0px}.top-0{top:0px}.right-0{right:0px}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.my-3{margin-top:.75rem;margin-bottom:.75rem}.my-6{margin-top:1.5rem;margin-bottom:1.5rem}.mx-auto{margin-left:auto;margin-right:auto}.-mx-3{margin-left:-.75rem;margin-right:-.75rem}.mt-6{margin-top:1.5rem}.mb-2{margin-bottom:.5rem}.box-border{box-sizing:border-box}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.aspect-\[512\/512\]{aspect-ratio:512/512}.h-0{height:0px}.h-full{height:100%}.max-h-\[9rem\]{max-height:9rem}.max-h-24{max-height:6rem}.w-0{width:0px}.w-full{width:100%}.max-w-full{max-width:100%}.max-w-\[3rem\]{max-width:3rem}.max-w-screen-md{max-width:768px}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.snap-x{scroll-snap-type:x var(--tw-scroll-snap-strictness)}.snap-y{scroll-snap-type:y var(--tw-scroll-snap-strictness)}.snap-mandatory{--tw-scroll-snap-strictness: mandatory}.snap-start{scroll-snap-align:start}.snap-always{scroll-snap-stop:always}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[2fr_1\.5fr\]{grid-template-columns:2fr 1.5fr}.flex-col{flex-direction:column}.flex-nowrap{flex-wrap:nowrap}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.gap-1{gap:.25rem}.overflow-hidden{overflow:hidden}.overflow-clip{overflow:clip}.overflow-scroll{overflow:scroll}.overflow-x-scroll{overflow-x:scroll}.whitespace-nowrap{white-space:nowrap}.rounded-lg{border-radius:.5rem}.border{border-width:1px}.border-gray-500{--tw-border-opacity: 1;border-color:rgb(107 114 128 / var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.bg-\[rgb\(11\,15\,25\)\]{--tw-bg-opacity: 1;background-color:rgb(11 15 25 / var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity))}.p-3{padding:.75rem}.p-1{padding:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.pl-2{padding-left:.5rem}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.leading-6{line-height:1.5rem}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity))}.opacity-0{opacity:0}.opacity-30{opacity:.3}.outline{outline-style:solid}.outline-2{outline-width:2px}.outline-offset-\[-2px\]{outline-offset:-2px}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\:outline:hover{outline-style:solid}.focus\:border-blue-500:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity))}.focus\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity))}.disabled\:opacity-50:disabled{opacity:.5}@media (prefers-color-scheme: dark){.dark\:prose-invert{--tw-prose-body: var(--tw-prose-invert-body);--tw-prose-headings: var(--tw-prose-invert-headings);--tw-prose-lead: var(--tw-prose-invert-lead);--tw-prose-links: var(--tw-prose-invert-links);--tw-prose-bold: var(--tw-prose-invert-bold);--tw-prose-counters: var(--tw-prose-invert-counters);--tw-prose-bullets: var(--tw-prose-invert-bullets);--tw-prose-hr: var(--tw-prose-invert-hr);--tw-prose-quotes: var(--tw-prose-invert-quotes);--tw-prose-quote-borders: var(--tw-prose-invert-quote-borders);--tw-prose-captions: var(--tw-prose-invert-captions);--tw-prose-code: var(--tw-prose-invert-code);--tw-prose-pre-code: var(--tw-prose-invert-pre-code);--tw-prose-pre-bg: var(--tw-prose-invert-pre-bg);--tw-prose-th-borders: var(--tw-prose-invert-th-borders);--tw-prose-td-borders: var(--tw-prose-invert-td-borders)}.dark\:border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.dark\:border-gray-600{--tw-border-opacity: 1;border-color:rgb(75 85 99 / var(--tw-border-opacity))}.dark\:bg-gray-700{--tw-bg-opacity: 1;background-color:rgb(55 65 81 / var(--tw-bg-opacity))}.dark\:text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.dark\:placeholder-gray-400::-moz-placeholder{--tw-placeholder-opacity: 1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))}.dark\:placeholder-gray-400::placeholder{--tw-placeholder-opacity: 1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))}.dark\:focus\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity))}}@media (min-width: 530px){.sm\:max-h-\[none\]{max-height:none}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}}
|
frontend/.svelte-kit/output/client/_app/immutable/assets/pages/index.svelte-65a37285.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
form.svelte-1gwcbp.svelte-1gwcbp{width:100%;overflow:hidden}.samples.svelte-1gwcbp.svelte-1gwcbp{display:flex;scroll-snap-type:x var(--tw-scroll-snap-strictness);--tw-scroll-snap-strictness:mandatory;flex-wrap:nowrap;gap:.25rem;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none}.samples.svelte-1gwcbp.svelte-1gwcbp::-webkit-scrollbar{display:none}input[type=radio].svelte-1gwcbp.svelte-1gwcbp{position:absolute;display:none;height:0px;width:0px;opacity:0}input[type=radio].svelte-1gwcbp.svelte-1gwcbp:disabled{opacity:.5}input[type=radio].svelte-1gwcbp:checked~label.svelte-1gwcbp{outline-style:solid;outline-width:2px;outline-color:#eab308}input[type=radio].svelte-1gwcbp:disabled+label.svelte-1gwcbp{opacity:.5}label.svelte-1gwcbp.svelte-1gwcbp{display:flex;cursor:pointer;outline-width:2px;outline-offset:-2px;outline-color:#eab308;transition-property:all;transition-duration:.2s;transition-timing-function:cubic-bezier(.4,0,.2,1)}label.svelte-1gwcbp.svelte-1gwcbp:hover{outline-style:solid}img.svelte-1gwcbp.svelte-1gwcbp{max-height:6rem;max-width:none}.colors.svelte-1oy4poo.svelte-1oy4poo{display:grid;max-height:9rem;scroll-snap-type:y var(--tw-scroll-snap-strictness);--tw-scroll-snap-strictness:mandatory;grid-template-columns:repeat(2,minmax(0,1fr));gap:.5rem;overflow:scroll}@media (min-width: 530px){.colors.svelte-1oy4poo.svelte-1oy4poo{max-height:none;grid-template-columns:repeat(3,minmax(0,1fr))}}.colors.svelte-1oy4poo span.svelte-1oy4poo{margin-left:.5rem}.colors.svelte-1oy4poo svg.svelte-1oy4poo{display:block}input[type=radio].svelte-1oy4poo.svelte-1oy4poo{position:absolute;display:none;height:0px;width:0px;opacity:0}input[type=radio].svelte-1oy4poo:checked~label.svelte-1oy4poo{outline-style:solid;outline-width:2px;outline-color:#eab308}label.svelte-1oy4poo.svelte-1oy4poo{display:flex;cursor:pointer;white-space:nowrap;outline-width:2px;outline-offset:-2px;outline-color:#eab308;transition-property:all;transition-duration:.2s;transition-timing-function:cubic-bezier(.4,0,.2,1)}label.svelte-1oy4poo.svelte-1oy4poo:hover{outline-style:solid}.brush.svelte-1oy4poo.svelte-1oy4poo{display:flex}select.svelte-uoay71.svelte-uoay71,button.svelte-uoay71.svelte-uoay71,input.svelte-uoay71.svelte-uoay71{border-radius:.5rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity));padding:.25rem;font-size:.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity))}select.svelte-uoay71.svelte-uoay71:focus,button.svelte-uoay71.svelte-uoay71:focus,input.svelte-uoay71.svelte-uoay71:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity)) }select.svelte-uoay71.svelte-uoay71:disabled,button.svelte-uoay71.svelte-uoay71:disabled,input.svelte-uoay71.svelte-uoay71:disabled{opacity:.5}@media (prefers-color-scheme: dark){select.svelte-uoay71.svelte-uoay71,button.svelte-uoay71.svelte-uoay71,input.svelte-uoay71.svelte-uoay71{--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(55 65 81 / var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))}select.svelte-uoay71.svelte-uoay71::-moz-placeholder,button.svelte-uoay71.svelte-uoay71::-moz-placeholder,input.svelte-uoay71.svelte-uoay71::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))}select.svelte-uoay71.svelte-uoay71::placeholder,button.svelte-uoay71.svelte-uoay71::placeholder,input.svelte-uoay71.svelte-uoay71::placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))}select.svelte-uoay71.svelte-uoay71:focus,button.svelte-uoay71.svelte-uoay71:focus,input.svelte-uoay71.svelte-uoay71:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity)) }}input.svelte-uoay71:disabled+label.svelte-uoay71{opacity:.5}input.svelte-uoay71.svelte-uoay71{padding-left:.75rem}.canvas.svelte-pr47cz{z-index:0;aspect-ratio:512/512;width:100%;max-width:100%;border-width:1px;--tw-border-opacity:1;border-color:rgb(107 114 128 / var(--tw-border-opacity))}@media (prefers-color-scheme: dark){.canvas.svelte-pr47cz{--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}}.brush.svelte-pr47cz{pointer-events:none;position:absolute;z-index:10;--tw-translate-x:-50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.label.svelte-pr47cz{pointer-events:none;position:absolute;top:0px;left:0px;z-index:20;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding-left:.5rem;padding-right:.5rem;font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity));color:#fff;font-weight:bolder;-webkit-text-stroke:1px black;-webkit-text-fill-color:white}.image.svelte-1t0h0rs{z-index:0;box-sizing:border-box;aspect-ratio:512/512;border-width:1px;--tw-border-opacity:1;border-color:rgb(107 114 128 / var(--tw-border-opacity))}@media (prefers-color-scheme: dark){.image.svelte-1t0h0rs{--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}}.loading.svelte-1t0h0rs{position:absolute;top:0px;left:0px;right:0px;bottom:0px;display:flex;flex-direction:column;align-items:center;justify-content:center}.drawings.svelte-237ry5{display:grid;grid-template-columns:2fr 1.5fr;place-items:center}@media (min-width: 530px){.drawings.svelte-237ry5{grid-template-columns:repeat(2,minmax(0,1fr))}}button.svelte-237ry5{border-radius:.5rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity));padding:.25rem;font-size:.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity))}button.svelte-237ry5:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity)) }button.svelte-237ry5:disabled{opacity:.5}@media (prefers-color-scheme: dark){button.svelte-237ry5{--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(55 65 81 / var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))}button.svelte-237ry5::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))}button.svelte-237ry5::placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))}button.svelte-237ry5:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity)) }}
|
frontend/.svelte-kit/output/client/_app/immutable/chunks/index-bcf2726a.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
function N(){}function H(t,n){for(const e in n)t[e]=n[e];return t}function B(t){return t()}function M(){return Object.create(null)}function p(t){t.forEach(B)}function I(t){return typeof t=="function"}function lt(t,n){return t!=t?n==n:t!==n||t&&typeof t=="object"||typeof t=="function"}let g;function ot(t,n){return g||(g=document.createElement("a")),g.href=n,t===g.href}function W(t){return Object.keys(t).length===0}function G(t,...n){if(t==null)return N;const e=t.subscribe(...n);return e.unsubscribe?()=>e.unsubscribe():e}function st(t,n,e){t.$$.on_destroy.push(G(n,e))}function at(t,n,e,i){if(t){const c=L(t,n,e,i);return t[0](c)}}function L(t,n,e,i){return t[1]&&i?H(e.ctx.slice(),t[1](i(n))):e.ctx}function ft(t,n,e,i){if(t[2]&&i){const c=t[2](i(e));if(n.dirty===void 0)return c;if(typeof c=="object"){const s=[],u=Math.max(n.dirty.length,c.length);for(let l=0;l<u;l+=1)s[l]=n.dirty[l]|c[l];return s}return n.dirty|c}return n.dirty}function _t(t,n,e,i,c,s){if(c){const u=L(n,e,i,s);t.p(u,c)}}function dt(t){if(t.ctx.length>32){const n=[],e=t.ctx.length/32;for(let i=0;i<e;i++)n[i]=-1;return n}return-1}function ht(t,n,e){return t.set(e),n}let w=!1;function J(){w=!0}function K(){w=!1}function Q(t,n,e,i){for(;t<n;){const c=t+(n-t>>1);e(c)<=i?t=c+1:n=c}return t}function R(t){if(t.hydrate_init)return;t.hydrate_init=!0;let n=t.childNodes;if(t.nodeName==="HEAD"){const r=[];for(let o=0;o<n.length;o++){const f=n[o];f.claim_order!==void 0&&r.push(f)}n=r}const e=new Int32Array(n.length+1),i=new Int32Array(n.length);e[0]=-1;let c=0;for(let r=0;r<n.length;r++){const o=n[r].claim_order,f=(c>0&&n[e[c]].claim_order<=o?c+1:Q(1,c,y=>n[e[y]].claim_order,o))-1;i[r]=e[f]+1;const a=f+1;e[a]=r,c=Math.max(a,c)}const s=[],u=[];let l=n.length-1;for(let r=e[c]+1;r!=0;r=i[r-1]){for(s.push(n[r-1]);l>=r;l--)u.push(n[l]);l--}for(;l>=0;l--)u.push(n[l]);s.reverse(),u.sort((r,o)=>r.claim_order-o.claim_order);for(let r=0,o=0;r<u.length;r++){for(;o<s.length&&u[r].claim_order>=s[o].claim_order;)o++;const f=o<s.length?s[o]:null;t.insertBefore(u[r],f)}}function U(t,n){if(w){for(R(t),(t.actual_end_child===void 0||t.actual_end_child!==null&&t.actual_end_child.parentElement!==t)&&(t.actual_end_child=t.firstChild);t.actual_end_child!==null&&t.actual_end_child.claim_order===void 0;)t.actual_end_child=t.actual_end_child.nextSibling;n!==t.actual_end_child?(n.claim_order!==void 0||n.parentNode!==t)&&t.insertBefore(n,t.actual_end_child):t.actual_end_child=n.nextSibling}else(n.parentNode!==t||n.nextSibling!==null)&&t.appendChild(n)}function mt(t,n,e){w&&!e?U(t,n):(n.parentNode!==t||n.nextSibling!=e)&&t.insertBefore(n,e||null)}function V(t){t.parentNode.removeChild(t)}function pt(t,n){for(let e=0;e<t.length;e+=1)t[e]&&t[e].d(n)}function X(t){return document.createElement(t)}function Y(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function j(t){return document.createTextNode(t)}function yt(){return j(" ")}function gt(){return j("")}function bt(t,n,e,i){return t.addEventListener(n,e,i),()=>t.removeEventListener(n,e,i)}function xt(t){return function(n){return n.preventDefault(),t.call(this,n)}}function $t(t,n,e){e==null?t.removeAttribute(n):t.getAttribute(n)!==e&&t.setAttribute(n,e)}function wt(t){return t===""?null:+t}function Z(t){return Array.from(t.childNodes)}function tt(t){t.claim_info===void 0&&(t.claim_info={last_index:0,total_claimed:0})}function O(t,n,e,i,c=!1){tt(t);const s=(()=>{for(let u=t.claim_info.last_index;u<t.length;u++){const l=t[u];if(n(l)){const r=e(l);return r===void 0?t.splice(u,1):t[u]=r,c||(t.claim_info.last_index=u),l}}for(let u=t.claim_info.last_index-1;u>=0;u--){const l=t[u];if(n(l)){const r=e(l);return r===void 0?t.splice(u,1):t[u]=r,c?r===void 0&&t.claim_info.last_index--:t.claim_info.last_index=u,l}}return i()})();return s.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1,s}function P(t,n,e,i){return O(t,c=>c.nodeName===n,c=>{const s=[];for(let u=0;u<c.attributes.length;u++){const l=c.attributes[u];e[l.name]||s.push(l.name)}s.forEach(u=>c.removeAttribute(u))},()=>i(n))}function vt(t,n,e){return P(t,n,e,X)}function Et(t,n,e){return P(t,n,e,Y)}function nt(t,n){return O(t,e=>e.nodeType===3,e=>{const i=""+n;if(e.data.startsWith(i)){if(e.data.length!==i.length)return e.splitText(i.length)}else e.data=i},()=>j(n),!0)}function kt(t){return nt(t," ")}function Nt(t,n){n=""+n,t.wholeText!==n&&(t.data=n)}function jt(t,n){t.value=n==null?"":n}function St(t,n,e,i){e===null?t.style.removeProperty(n):t.style.setProperty(n,e,i?"important":"")}let m;function h(t){m=t}function S(){if(!m)throw new Error("Function called outside component initialization");return m}function At(t){S().$$.on_mount.push(t)}function Ct(t){S().$$.after_update.push(t)}function Mt(t,n){return S().$$.context.set(t,n),n}const d=[],T=[],x=[],q=[],D=Promise.resolve();let E=!1;function z(){E||(E=!0,D.then(F))}function Tt(){return z(),D}function k(t){x.push(t)}const v=new Set;let b=0;function F(){const t=m;do{for(;b<d.length;){const n=d[b];b++,h(n),et(n.$$)}for(h(null),d.length=0,b=0;T.length;)T.pop()();for(let n=0;n<x.length;n+=1){const e=x[n];v.has(e)||(v.add(e),e())}x.length=0}while(d.length);for(;q.length;)q.pop()();E=!1,v.clear(),h(t)}function et(t){if(t.fragment!==null){t.update(),p(t.before_update);const n=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,n),t.after_update.forEach(k)}}const $=new Set;let _;function qt(){_={r:0,c:[],p:_}}function Bt(){_.r||p(_.c),_=_.p}function it(t,n){t&&t.i&&($.delete(t),t.i(n))}function Lt(t,n,e,i){if(t&&t.o){if($.has(t))return;$.add(t),_.c.push(()=>{$.delete(t),i&&(e&&t.d(1),i())}),t.o(n)}}function Ot(t,n){const e={},i={},c={$$scope:1};let s=t.length;for(;s--;){const u=t[s],l=n[s];if(l){for(const r in u)r in l||(i[r]=1);for(const r in l)c[r]||(e[r]=l[r],c[r]=1);t[s]=l}else for(const r in u)c[r]=1}for(const u in i)u in e||(e[u]=void 0);return e}function Pt(t){return typeof t=="object"&&t!==null?t:{}}function Dt(t){t&&t.c()}function zt(t,n){t&&t.l(n)}function rt(t,n,e,i){const{fragment:c,on_mount:s,on_destroy:u,after_update:l}=t.$$;c&&c.m(n,e),i||k(()=>{const r=s.map(B).filter(I);u?u.push(...r):p(r),t.$$.on_mount=[]}),l.forEach(k)}function ct(t,n){const e=t.$$;e.fragment!==null&&(p(e.on_destroy),e.fragment&&e.fragment.d(n),e.on_destroy=e.fragment=null,e.ctx=[])}function ut(t,n){t.$$.dirty[0]===-1&&(d.push(t),z(),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<<n%31}function Ft(t,n,e,i,c,s,u,l=[-1]){const r=m;h(t);const o=t.$$={fragment:null,ctx:null,props:s,update:N,not_equal:c,bound:M(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(n.context||(r?r.$$.context:[])),callbacks:M(),dirty:l,skip_bound:!1,root:n.target||r.$$.root};u&&u(o.root);let f=!1;if(o.ctx=e?e(t,n.props||{},(a,y,...A)=>{const C=A.length?A[0]:y;return o.ctx&&c(o.ctx[a],o.ctx[a]=C)&&(!o.skip_bound&&o.bound[a]&&o.bound[a](C),f&&ut(t,a)),y}):[],o.update(),f=!0,p(o.before_update),o.fragment=i?i(o.ctx):!1,n.target){if(n.hydrate){J();const a=Z(n.target);o.fragment&&o.fragment.l(a),a.forEach(V)}else o.fragment&&o.fragment.c();n.intro&&it(t.$$.fragment),rt(t,n.target,n.anchor,n.customElement),K(),F()}h(r)}class Ht{$destroy(){ct(this,1),this.$destroy=N}$on(n,e){const i=this.$$.callbacks[n]||(this.$$.callbacks[n]=[]);return i.push(e),()=>{const c=i.indexOf(e);c!==-1&&i.splice(c,1)}}$set(n){this.$$set&&!W(n)&&(this.$$.skip_bound=!0,this.$$set(n),this.$$.skip_bound=!1)}}export{Pt as A,ct as B,H as C,Tt as D,N as E,at as F,_t as G,dt as H,ft as I,U as J,ot as K,bt as L,pt as M,st as N,ht as O,Y as P,Et as Q,jt as R,Ht as S,xt as T,p as U,wt as V,T as W,Z as a,$t as b,vt as c,V as d,X as e,St as f,mt as g,nt as h,Ft as i,Nt as j,yt as k,gt as l,kt as m,qt as n,Lt as o,Bt as p,it as q,Mt as r,lt as s,j as t,Ct as u,At as v,Dt as w,zt as x,rt as y,Ot as z};
|
frontend/.svelte-kit/output/client/_app/immutable/chunks/paths-d3bcbd10.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{E as f,s as p}from"./index-bcf2726a.js";const n=[];function _(t,b=f){let o;const i=new Set;function r(e){if(p(t,e)&&(t=e,o)){const c=!n.length;for(const s of i)s[1](),n.push(s,t);if(c){for(let s=0;s<n.length;s+=2)n[s][0](n[s+1]);n.length=0}}}function a(e){r(e(t))}function l(e,c=f){const s=[e,c];return i.add(s),i.size===1&&(o=b(r)||f),e(t),()=>{i.delete(s),i.size===0&&(o(),o=null)}}return{set:r,update:a,subscribe:l}}let u="",d="";function g(t){u=t.base,d=t.assets||u}export{d as a,u as b,g as s,_ as w};
|
frontend/.svelte-kit/output/client/_app/immutable/error.svelte-d9523301.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{S as w,i as y,s as z,e as E,t as v,c as d,a as b,h as P,d as o,g as u,J as R,j as N,k as S,l as C,m as j,E as H}from"./chunks/index-bcf2726a.js";function J(r){let l,t=r[1].frame+"",a;return{c(){l=E("pre"),a=v(t)},l(f){l=d(f,"PRE",{});var s=b(l);a=P(s,t),s.forEach(o)},m(f,s){u(f,l,s),R(l,a)},p(f,s){s&2&&t!==(t=f[1].frame+"")&&N(a,t)},d(f){f&&o(l)}}}function h(r){let l,t=r[1].stack+"",a;return{c(){l=E("pre"),a=v(t)},l(f){l=d(f,"PRE",{});var s=b(l);a=P(s,t),s.forEach(o)},m(f,s){u(f,l,s),R(l,a)},p(f,s){s&2&&t!==(t=f[1].stack+"")&&N(a,t)},d(f){f&&o(l)}}}function A(r){let l,t,a,f,s=r[1].message+"",c,k,n,p,i=r[1].frame&&J(r),_=r[1].stack&&h(r);return{c(){l=E("h1"),t=v(r[0]),a=S(),f=E("pre"),c=v(s),k=S(),i&&i.c(),n=S(),_&&_.c(),p=C()},l(e){l=d(e,"H1",{});var m=b(l);t=P(m,r[0]),m.forEach(o),a=j(e),f=d(e,"PRE",{});var q=b(f);c=P(q,s),q.forEach(o),k=j(e),i&&i.l(e),n=j(e),_&&_.l(e),p=C()},m(e,m){u(e,l,m),R(l,t),u(e,a,m),u(e,f,m),R(f,c),u(e,k,m),i&&i.m(e,m),u(e,n,m),_&&_.m(e,m),u(e,p,m)},p(e,[m]){m&1&&N(t,e[0]),m&2&&s!==(s=e[1].message+"")&&N(c,s),e[1].frame?i?i.p(e,m):(i=J(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null),e[1].stack?_?_.p(e,m):(_=h(e),_.c(),_.m(p.parentNode,p)):_&&(_.d(1),_=null)},i:H,o:H,d(e){e&&o(l),e&&o(a),e&&o(f),e&&o(k),i&&i.d(e),e&&o(n),_&&_.d(e),e&&o(p)}}}function F({error:r,status:l}){return{props:{error:r,status:l}}}function B(r,l,t){let{status:a}=l,{error:f}=l;return r.$$set=s=>{"status"in s&&t(0,a=s.status),"error"in s&&t(1,f=s.error)},[a,f]}class G extends w{constructor(l){super(),y(this,l,B,A,z,{status:0,error:1})}}export{G as default,F as load};
|
frontend/.svelte-kit/output/client/_app/immutable/manifest.json
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
".svelte-kit/runtime/client/start.js": {
|
3 |
+
"file": "start-a60c2789.js",
|
4 |
+
"src": ".svelte-kit/runtime/client/start.js",
|
5 |
+
"isEntry": true,
|
6 |
+
"imports": [
|
7 |
+
"_index-bcf2726a.js",
|
8 |
+
"_paths-d3bcbd10.js"
|
9 |
+
],
|
10 |
+
"dynamicImports": [
|
11 |
+
"src/routes/__layout.svelte",
|
12 |
+
".svelte-kit/runtime/components/error.svelte",
|
13 |
+
"src/routes/index.svelte"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
"src/routes/__layout.svelte": {
|
17 |
+
"file": "pages/__layout.svelte-0c386344.js",
|
18 |
+
"src": "src/routes/__layout.svelte",
|
19 |
+
"isEntry": true,
|
20 |
+
"isDynamicEntry": true,
|
21 |
+
"imports": [
|
22 |
+
"_index-bcf2726a.js"
|
23 |
+
],
|
24 |
+
"css": [
|
25 |
+
"assets/pages/__layout.svelte-dcfcba4b.css"
|
26 |
+
]
|
27 |
+
},
|
28 |
+
".svelte-kit/runtime/components/error.svelte": {
|
29 |
+
"file": "error.svelte-d9523301.js",
|
30 |
+
"src": ".svelte-kit/runtime/components/error.svelte",
|
31 |
+
"isEntry": true,
|
32 |
+
"isDynamicEntry": true,
|
33 |
+
"imports": [
|
34 |
+
"_index-bcf2726a.js"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
"src/routes/index.svelte": {
|
38 |
+
"file": "pages/index.svelte-6350336a.js",
|
39 |
+
"src": "src/routes/index.svelte",
|
40 |
+
"isEntry": true,
|
41 |
+
"isDynamicEntry": true,
|
42 |
+
"imports": [
|
43 |
+
"_index-bcf2726a.js",
|
44 |
+
"_paths-d3bcbd10.js"
|
45 |
+
],
|
46 |
+
"css": [
|
47 |
+
"assets/pages/index.svelte-65a37285.css"
|
48 |
+
]
|
49 |
+
},
|
50 |
+
"_index-bcf2726a.js": {
|
51 |
+
"file": "chunks/index-bcf2726a.js"
|
52 |
+
},
|
53 |
+
"_paths-d3bcbd10.js": {
|
54 |
+
"file": "chunks/paths-d3bcbd10.js",
|
55 |
+
"imports": [
|
56 |
+
"_index-bcf2726a.js"
|
57 |
+
]
|
58 |
+
}
|
59 |
+
}
|
frontend/.svelte-kit/output/client/_app/immutable/pages/__layout.svelte-0c386344.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{S as n,i,s as p,F as l,G as w,H as c,I as d,q as h,o as m}from"../chunks/index-bcf2726a.js";function g(s){let r;const a=s[1].default,t=l(a,s,s[0],null);return{c(){t&&t.c()},l(e){t&&t.l(e)},m(e,o){t&&t.m(e,o),r=!0},p(e,[o]){t&&t.p&&(!r||o&1)&&w(t,a,e,e[0],r?d(a,e[0],o,null):c(e[0]),null)},i(e){r||(h(t,e),r=!0)},o(e){m(t,e),r=!1},d(e){t&&t.d(e)}}}function b(s,r,a){let{$$slots:t={},$$scope:e}=r;return s.$$set=o=>{"$$scope"in o&&a(0,e=o.$$scope)},[e,t]}class u extends n{constructor(r){super(),i(this,r,b,g,p,{})}}export{u as default};
|
frontend/.svelte-kit/output/client/_app/immutable/pages/index.svelte-6350336a.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{S as W,i as ee,s as te,e as M,k as D,c as O,a as T,m as j,d as E,b as c,K as ke,g as $,J as d,t as V,h as F,L as N,E as Y,M as Oe,N as G,O as J,P as pe,Q as de,j as Te,f as tt,R as ae,T as ge,U as Be,V as rt,W as Ee,w as oe,x as se,y as ne,q as ie,o as ce,B as ue,v as lt}from"../chunks/index-bcf2726a.js";import{w as Q,b as Ze}from"../chunks/paths-d3bcbd10.js";const ye=[{color:[219,14,154],label:"building"},{color:[147,142,123],label:"pervious surface"},{color:[248,12,0],label:"impervious surface"},{color:[169,113,1],label:"bare soil"},{color:[21,83,174],label:"water"},{color:[25,74,38],label:"coniferous"},{color:[70,228,131],label:"deciduous"},{color:[243,166,13],label:"brushwood"},{color:[102,0,130],label:"vineyard"},{color:[85,255,0],label:"herbaceous vegetation"},{color:[255,243,13],label:"agricultural land"},{color:[228,223,124],label:"plowed land"},{color:[61,230,235],label:"swimming pool"},{color:[255,255,255],label:"snow"},{color:[138,179,160],label:"clear cut"},{color:[107,113,79],label:"mixed"},{color:[197,220,66],label:"ligneous"},{color:[153,153,255],label:"greenhouse"},{color:[0,0,0],label:"other"}],Ie=["/samples/example0.png","/samples/example1.png","/samples/example2.png","/samples/example3.png","/samples/example4.png","/samples/example5.png"],Se=[["Aerial view, France. High resolution image, 4K, ultra detailed","Realistic"],["Aerial view, France. Colorful lego bricks","Lego brick"],["Aerial view, France. Black and white paper pencil drawing","Pencil"],["Aerial view, France. Oil on canvas painting","Painting"]];function Qe(){return BigInt(0xb7dd73e137d20800&((1<<63)-1)*Math.random())}const ve=Q(new Map),ze=Q(),Pe=Q(),Ce=Q(),me=Q(),Me=Q({prompt:Se[0][0],seed:Qe(),steps:20}),he=Q(!1),we=Q(!1);function Ne(l,e,t){const r=l.slice();return r[3]=e[t],r[5]=t,r}function Ue(l){let e,t,r,s,a,i,p,n,m,k,g,C;return{c(){e=M("div"),t=M("input"),i=D(),p=M("label"),n=M("img"),C=D(),this.h()},l(h){e=O(h,"DIV",{class:!0});var w=T(e);t=O(w,"INPUT",{type:!0,name:!0,id:!0,class:!0}),i=j(w),p=O(w,"LABEL",{for:!0,class:!0});var S=T(p);n=O(S,"IMG",{src:!0,alt:!0,class:!0}),S.forEach(E),C=j(w),w.forEach(E),this.h()},h(){c(t,"type","radio"),c(t,"name","samples"),c(t,"id",r="sample-"+l[5]),t.value=s=l[5],t.disabled=a=l[0]===!0,c(t,"class","svelte-1gwcbp"),ke(n.src,m=Ze+l[3])||c(n,"src",m),c(n,"alt",k=l[3]),c(n,"class","svelte-1gwcbp"),c(p,"for",g="sample-"+l[5]),c(p,"class","svelte-1gwcbp"),c(e,"class","snap-always snap-start")},m(h,w){$(h,e,w),d(e,t),d(e,i),d(e,p),d(p,n),d(e,C)},p(h,w){w&1&&a!==(a=h[0]===!0)&&(t.disabled=a)},d(h){h&&E(e)}}}function at(l){let e,t,r,s,a,i,p,n,m=Ie,k=[];for(let g=0;g<m.length;g+=1)k[g]=Ue(Ne(l,m,g));return{c(){e=M("div"),t=M("h4"),r=V("Select a Template"),s=D(),a=M("form"),i=M("div");for(let g=0;g<k.length;g+=1)k[g].c();this.h()},l(g){e=O(g,"DIV",{});var C=T(e);t=O(C,"H4",{class:!0});var h=T(t);r=F(h,"Select a Template"),h.forEach(E),s=j(C),a=O(C,"FORM",{class:!0});var w=T(a);i=O(w,"DIV",{class:!0});var S=T(i);for(let o=0;o<k.length;o+=1)k[o].l(S);S.forEach(E),w.forEach(E),C.forEach(E),this.h()},h(){c(t,"class","font-bold mt-6 mb-2 my-6 leading-6"),c(i,"class","samples svelte-1gwcbp"),c(a,"class","svelte-1gwcbp")},m(g,C){$(g,e,C),d(e,t),d(t,r),d(e,s),d(e,a),d(a,i);for(let h=0;h<k.length;h+=1)k[h].m(i,null);p||(n=N(a,"input",l[1]),p=!0)},p(g,[C]){if(C&1){m=Ie;let h;for(h=0;h<m.length;h+=1){const w=Ne(g,m,h);k[h]?k[h].p(w,C):(k[h]=Ue(w),k[h].c(),k[h].m(i,null))}for(;h<k.length;h+=1)k[h].d(1);k.length=m.length}},i:Y,o:Y,d(g){g&&E(e),Oe(k,g),p=!1,n()}}}async function ot(l){return new Promise((e,t)=>{const r=new Image;r.onload=()=>{URL.revokeObjectURL(r.src),e(r)},r.onerror=s=>{t(s)},r.src=URL.createObjectURL(l)})}function st(l,e,t){let r,s;return G(l,Ce,i=>t(2,r=i)),G(l,he,i=>t(0,s=i)),[s,async i=>{i.preventDefault();const p=Ie[parseInt(i.target.value)];if(p){const n=await fetch(Ze+p).then(k=>k.blob()),m=await ot(n);J(Ce,r=m,r)}}]}class nt extends W{constructor(e){super(),ee(this,e,st,at,te,{})}}function Ve(l,e,t){const r=l.slice();return r[2]=e[t],r[7]=t,r}function Fe(l){let e,t,r,s,a,i,p,n,m,k,g,C,h=l[2].label+"",w,S,o;return{c(){e=M("div"),t=M("input"),i=D(),p=M("label"),n=pe("svg"),m=pe("rect"),g=D(),C=M("span"),w=V(h),o=D(),this.h()},l(f){e=O(f,"DIV",{class:!0});var b=T(e);t=O(b,"INPUT",{name:!0,type:!0,id:!0,class:!0}),i=j(b),p=O(b,"LABEL",{for:!0,class:!0});var u=T(p);n=de(u,"svg",{width:!0,height:!0,viewBox:!0,class:!0});var v=T(n);m=de(v,"rect",{x:!0,y:!0,width:!0,height:!0,fill:!0}),T(m).forEach(E),v.forEach(E),g=j(u),C=O(u,"SPAN",{class:!0});var y=T(C);w=F(y,h),y.forEach(E),u.forEach(E),o=j(b),b.forEach(E),this.h()},h(){c(t,"name","color"),t.checked=r=l[7]==We,c(t,"type","radio"),c(t,"id",s="color-"+l[7]),t.value=a=l[7],c(t,"class","svelte-1oy4poo"),c(m,"x","0"),c(m,"y","0"),c(m,"width","20"),c(m,"height","20"),c(m,"fill",k="rgb("+l[2].color.join(",")+")"),c(n,"width","20"),c(n,"height","20"),c(n,"viewBox","0 0 20 20"),c(n,"class","svelte-1oy4poo"),c(C,"class","svelte-1oy4poo"),c(p,"for",S="color-"+l[7]),c(p,"class","svelte-1oy4poo"),c(e,"class","snap-always snap-start")},m(f,b){$(f,e,b),d(e,t),d(e,i),d(e,p),d(p,n),d(n,m),d(p,g),d(p,C),d(C,w),d(e,o)},p:Y,d(f){f&&E(e)}}}function it(l){let e,t,r,s,a,i,p,n,m,k,g,C,h,w=l[0].size+"",S,o,f,b=ye,u=[];for(let v=0;v<b.length;v+=1)u[v]=Fe(Ve(l,b,v));return{c(){e=M("form"),t=M("h4"),r=V("Brush Type"),s=D(),a=M("div");for(let v=0;v<u.length;v+=1)u[v].c();i=D(),p=M("h4"),n=V("Brush Size"),m=D(),k=M("div"),g=M("input"),C=D(),h=M("label"),S=V(w),this.h()},l(v){e=O(v,"FORM",{});var y=T(e);t=O(y,"H4",{class:!0});var x=T(t);r=F(x,"Brush Type"),x.forEach(E),s=j(y),a=O(y,"DIV",{class:!0,name:!0});var z=T(a);for(let I=0;I<u.length;I+=1)u[I].l(z);z.forEach(E),i=j(y),p=O(y,"H4",{class:!0});var _=T(p);n=F(_,"Brush Size"),_.forEach(E),m=j(y),k=O(y,"DIV",{class:!0});var P=T(k);g=O(P,"INPUT",{min:!0,max:!0,step:!0,name:!0,type:!0}),C=j(P),h=O(P,"LABEL",{class:!0,for:!0});var B=T(h);S=F(B,w),B.forEach(E),P.forEach(E),y.forEach(E),this.h()},h(){c(t,"class","font-bold mt-6 mb-2 leading-6 my-3"),c(a,"class","colors svelte-1oy4poo"),c(a,"name","colors"),c(p,"class","font-bold mt-6 mb-2 my-6 leading-6"),g.value="10",c(g,"min","1"),c(g,"max","150"),c(g,"step","1"),c(g,"name","brush"),c(g,"type","range"),c(h,"class","pl-2 svelte-1oy4poo"),c(h,"for","brush"),c(k,"class","brush svelte-1oy4poo")},m(v,y){$(v,e,y),d(e,t),d(t,r),d(e,s),d(e,a);for(let x=0;x<u.length;x+=1)u[x].m(a,null);d(e,i),d(e,p),d(p,n),d(e,m),d(e,k),d(k,g),d(k,C),d(k,h),d(h,S),o||(f=N(e,"input",l[1]),o=!0)},p(v,[y]){if(y&0){b=ye;let x;for(x=0;x<b.length;x+=1){const z=Ve(v,b,x);u[x]?u[x].p(z,y):(u[x]=Fe(z),u[x].c(),u[x].m(a,null))}for(;x<u.length;x+=1)u[x].d(1);u.length=b.length}y&1&&w!==(w=v[0].size+"")&&Te(S,w)},i:Y,o:Y,d(v){v&&E(e),Oe(u,v),o=!1,f()}}}const We=6;function ct(l,e,t){let r;G(l,me,m=>t(0,r=m));const{color:s,label:a}=ye[We];let i=`rgb(${s.join(",")})`,p=40;return J(me,r={color:i,size:p,label:a},r),[r,async m=>{const k=m.target;if(k.name==="color"){const g=parseInt(k.value),{color:C,label:h}=ye[g];i=`rgb(${C.join(",")})`,J(me,r={color:i,size:p,label:h},r)}else k.name==="brush"&&(p=parseInt(k.value),J(me,r={color:i,size:p,label:a},r))},s]}class ut extends W{constructor(e){super(),ee(this,e,ct,it,te,{})}}function Ge(l,e,t){const r=l.slice();return r[13]=e[t],r}function qe(l){let e,t=l[13][1]+"",r,s,a;return{c(){e=M("option"),r=V(t),a=V("`"),this.h()},l(i){e=O(i,"OPTION",{});var p=T(e);r=F(p,t),p.forEach(E),a=F(i,"`"),this.h()},h(){e.__value=s=l[13][0],e.value=e.__value},m(i,p){$(i,e,p),d(e,r),$(i,a,p)},p:Y,d(i){i&&E(e),i&&E(a)}}}function pt(l){let e,t,r,s,a,i,p,n,m,k,g,C,h,w,S,o,f,b,u,v,y,x,z,_,P,B,I,R,K,H,X,Z,fe,re=Se,q=[];for(let L=0;L<re.length;L+=1)q[L]=qe(Ge(l,re,L));return{c(){e=M("form"),t=M("h4"),r=V("Prompt"),s=D(),a=M("input"),p=D(),n=M("select"),m=M("option"),k=V("preset");for(let L=0;L<q.length;L+=1)q[L].c();C=D(),h=M("h4"),w=V("Random Seed"),S=D(),o=M("input"),b=D(),u=M("button"),v=V("Random"),x=D(),z=M("h4"),_=V("Sample Steps"),P=D(),B=M("div"),I=M("input"),K=D(),H=M("label"),X=V(l[2]),this.h()},l(L){e=O(L,"FORM",{});var A=T(e);t=O(A,"H4",{class:!0});var U=T(t);r=F(U,"Prompt"),U.forEach(E),s=j(A),a=O(A,"INPUT",{name:!0,placeholder:!0,style:!0,class:!0}),p=j(A),n=O(A,"SELECT",{name:!0,class:!0});var le=T(n);m=O(le,"OPTION",{});var Re=T(m);k=F(Re,"preset"),Re.forEach(E);for(let _e=0;_e<q.length;_e+=1)q[_e].l(le);le.forEach(E),C=j(A),h=O(A,"H4",{class:!0});var Ae=T(h);w=F(Ae,"Random Seed"),Ae.forEach(E),S=j(A),o=O(A,"INPUT",{type:!0,name:!0,placeholder:!0,class:!0}),b=j(A),u=O(A,"BUTTON",{class:!0});var De=T(u);v=F(De,"Random"),De.forEach(E),x=j(A),z=O(A,"H4",{class:!0});var je=T(z);_=F(je,"Sample Steps"),je.forEach(E),P=j(A),B=O(A,"DIV",{class:!0});var be=T(B);I=O(be,"INPUT",{type:!0,name:!0,min:!0,max:!0,step:!0,class:!0}),K=j(be),H=O(be,"LABEL",{class:!0,for:!0});var Le=T(H);X=F(Le,l[2]),Le.forEach(E),be.forEach(E),A.forEach(E),this.h()},h(){c(t,"class","font-bold mt-6 mb-2 my-6 leading-6"),c(a,"name","prompt"),c(a,"placeholder","Aerial view of ..., France."),a.disabled=i=l[4]===!0,tt(a,"width","500px"),c(a,"class","svelte-uoay71"),m.disabled=!0,m.selected=!0,m.__value="preset",m.value=m.__value,c(n,"name","presets"),n.disabled=g=l[4]===!0,c(n,"class","svelte-uoay71"),c(h,"class","font-bold mt-6 mb-2 my-6 leading-6"),c(o,"type","Number"),c(o,"name","seed"),c(o,"placeholder","Integer Seed"),o.disabled=f=l[4]===!0,c(o,"class","svelte-uoay71"),u.disabled=y=l[4]===!0,c(u,"class","svelte-uoay71"),c(z,"class","font-bold mt-6 mb-2 my-6 leading-6"),c(I,"type","range"),c(I,"name","steps"),c(I,"min","10"),c(I,"max","30"),c(I,"step","1"),I.disabled=R=l[4]===!0,c(I,"class","svelte-uoay71"),c(H,"class","pl-2 svelte-uoay71"),c(H,"for","steps"),c(B,"class","flex")},m(L,A){$(L,e,A),d(e,t),d(t,r),d(e,s),d(e,a),ae(a,l[3]),d(e,p),d(e,n),d(n,m),d(m,k);for(let U=0;U<q.length;U+=1)q[U].m(n,null);d(e,C),d(e,h),d(h,w),d(e,S),d(e,o),ae(o,l[1]),d(e,b),d(e,u),d(u,v),d(e,x),d(e,z),d(z,_),d(e,P),d(e,B),d(B,I),ae(I,l[2]),d(B,K),d(B,H),d(H,X),l[11](e),Z||(fe=[N(a,"input",l[6]),N(n,"change",l[7]),N(o,"input",l[8]),N(u,"click",ge(l[9])),N(I,"change",l[10]),N(I,"input",l[10]),N(e,"input",l[5])],Z=!0)},p(L,[A]){if(A&16&&i!==(i=L[4]===!0)&&(a.disabled=i),A&8&&a.value!==L[3]&&ae(a,L[3]),A&0){re=Se;let U;for(U=0;U<re.length;U+=1){const le=Ge(L,re,U);q[U]?q[U].p(le,A):(q[U]=qe(le),q[U].c(),q[U].m(n,null))}for(;U<q.length;U+=1)q[U].d(1);q.length=re.length}A&16&&g!==(g=L[4]===!0)&&(n.disabled=g),A&16&&f!==(f=L[4]===!0)&&(o.disabled=f),A&2&&ae(o,L[1]),A&16&&y!==(y=L[4]===!0)&&(u.disabled=y),A&16&&R!==(R=L[4]===!0)&&(I.disabled=R),A&4&&ae(I,L[2]),A&4&&Te(X,L[2])},i:Y,o:Y,d(L){L&&E(e),Oe(q,L),l[11](null),Z=!1,Be(fe)}}}function dt(l,e,t){let r,s;G(l,Me,o=>t(12,r=o)),G(l,he,o=>t(4,s=o));function a(){const o=i.elements;J(Me,r={prompt:o.prompt.value,seed:BigInt(o.seed.value),steps:parseInt(o.steps.value)},r)}let i,p=r.seed,n=r.steps,m=r.prompt;function k(){m=this.value,t(3,m)}const g=o=>{t(3,m=o.currentTarget.value)};function C(){p=this.value,t(1,p)}const h=()=>{t(1,p=Qe()),a()};function w(){n=rt(this.value),t(2,n)}function S(o){Ee[o?"unshift":"push"](()=>{i=o,t(0,i)})}return[i,p,n,m,s,a,k,g,C,h,w,S]}class ht extends W{constructor(e){super(),ee(this,e,dt,pt,te,{})}}let ft=(l=21)=>crypto.getRandomValues(new Uint8Array(l)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");var vt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function mt(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var et={exports:{}};(function(l,e){(function(t,r){l.exports=r()})(typeof self!="undefined"?self:vt,function(){return function(t){var r={};function s(a){if(r[a])return r[a].exports;var i=r[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=t,s.c=r,s.d=function(a,i,p){s.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:p})},s.r=function(a){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},s.t=function(a,i){if(1&i&&(a=s(a)),8&i||4&i&&typeof a=="object"&&a&&a.__esModule)return a;var p=Object.create(null);if(s.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:a}),2&i&&typeof a!="string")for(var n in a)s.d(p,n,function(m){return a[m]}.bind(null,n));return p},s.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return s.d(i,"a",i),i},s.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},s.p="",s(s.s=0)}([function(t,r,s){function a(h,w){return function(S){if(Array.isArray(S))return S}(h)||function(S,o){if(Symbol.iterator in Object(S)||Object.prototype.toString.call(S)==="[object Arguments]"){var f=[],b=!0,u=!1,v=void 0;try{for(var y,x=S[Symbol.iterator]();!(b=(y=x.next()).done)&&(f.push(y.value),!o||f.length!==o);b=!0);}catch(z){u=!0,v=z}finally{try{b||x.return==null||x.return()}finally{if(u)throw v}}return f}}(h,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(h){return function(w){if(Array.isArray(w)){for(var S=0,o=new Array(w.length);S<w.length;S++)o[S]=w[S];return o}}(h)||function(w){if(Symbol.iterator in Object(w)||Object.prototype.toString.call(w)==="[object Arguments]")return Array.from(w)}(h)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function p(h,w){for(var S=0;S<w.length;S++){var o=w[S];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(h,o.key,o)}}s.r(r);var n=/^#?[0-9A-Fa-f]{1,2}[0-9A-Fa-f]{1,2}[0-9A-Fa-f]{1,2}$/,m=/^rgb\((\s+)?[0-9]{1,3},(\s+)?[0-9]{1,3},(\s+)?[0-9]{1,3}(\s+)?\)$/,k=function(){function h(){(function(o,f){if(!(o instanceof f))throw new TypeError("Cannot call a class as a function")})(this,h),this.canvases={}}var w,S;return w=h,(S=[{key:"parseColor",value:function(o){var f=n.test(o),b=m.test(o);if(!f&&!b)throw new Error("Color is not correct format. #123123 or rgb(123, 123, 123) format required.");if(f){var u=o[0]==="#"?o.slice(1):o;return u=u.length===3?u.split("").reduce(function(_,P){return[].concat(i(_),[P,P])},[]).join(""):u,{r:parseInt(u.slice(0,2),16),g:parseInt(u.slice(2,4),16),b:parseInt(u.slice(4,6),16)}}if(b){var v=a(o.replace(/rgb|\s+|\(|\)/g,"").split(",").map(function(_){return parseInt(_)}),3),y=v[0],x=v[1],z=v[2];return{r:y=y>255?255:y,g:x=x>255?255:x,b:z=z>255?255:z}}}},{key:"make",value:function(o){var f=o.size,b=o.color;try{f*=window.devicePixelRatio;var u=this.parseColor(b),v=JSON.stringify(u);if(this.canvases[v]=this.canvases[v]||{},this.canvases[v][f]!=null)return this.canvases[v][f];var y=document.createElement("canvas");f+=f%2,y.width=f,y.height=f;for(var x=y.getContext("2d"),z=x.createImageData(f,f),_=0;_<z.data.length;_+=4)z.data[_]=255,z.data[_+1]=255,z.data[_+2]=255,z.data[_+3]=0;return this.plotCircle(2*f,4*f*(f/2),f/2,z,f,u),this.fillCircle(z,u),x.putImageData(z,0,0),this.canvases[v][f]=y,y}catch(P){console.error(P)}}},{key:"plotCircle",value:function(o,f,b,u,v,y){var x=-b,z=0,_=2-2*b;do{var P=o-4*(x+1)+(f+4*v*(z-1));u.data[P+0]=y.r,u.data[P+1]=y.g,u.data[P+2]=y.b,u.data[P+3]=255;var B=o-z*(4*v)+(f-4*(x+1));u.data[B+0]=y.r,u.data[B+1]=y.g,u.data[B+2]=y.b,u.data[B+3]=255;var I=o+4*x+(f-z*(4*v));u.data[I+0]=y.r,u.data[I+1]=y.g,u.data[I+2]=y.b,u.data[I+3]=255;var R=o+4*v*(z-1)+(f+4*x);u.data[R+0]=y.r,u.data[R+1]=y.g,u.data[R+2]=y.b,u.data[R+3]=255,(b=_)<=z&&(_+=2*++z+1),(b>x||_>z)&&(_+=2*++x+1)}while(x<0)}},{key:"fillCircle",value:function(o,f){for(var b=4*o.width,u=1;u<o.height-1;u+=1)for(var v=!1,y=!1,x=!1,z=0;z<b;z+=4){var _=b*u+z,P=o.data[_+3],B=P===255;B&&!v?v=!0:P===0&&v?y=!0:B&&v&&y&&(x=!0),v&&y&&!x&&(o.data[_]=f.r,o.data[_+1]=f.g,o.data[_+2]=f.b,o.data[_+3]=255)}}}])&&p(w.prototype,S),h}();function g(h,w){for(var S=0;S<w.length;S++){var o=w[S];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(h,o.key,o)}}var C=function(){function h(o){(function(f,b){if(!(f instanceof b))throw new TypeError("Cannot call a class as a function")})(this,h),this.canvas=o,this.context=o.getContext("2d"),this.stampMaker=new k,this.configPixelRatio()}var w,S;return w=h,(S=[{key:"configPixelRatio",value:function(){var o=this.canvas,f=o.width,b=o.height;this.canvas.width=f*this.dpr,this.canvas.height=b*this.dpr,this.canvas.style.width="".concat(f,"px"),this.canvas.style.height="".concat(b,"px"),this.context.scale(this.dpr,this.dpr),this.context.imageSmoothingEnabled=!1}},{key:"exportAsPNG",value:function(o){var f=this;return new Promise(function(b){var u=document.createElement("canvas"),v=u.getContext("2d"),y=f.canvas,x=y.width,z=y.height,_=x/f.dpr,P=z/f.dpr;u.width=_,u.height=P,v.imageSmoothingEnabled=!1,v.drawImage(f.canvas,0,0,x,z,0,0,_,P),u.toBlob(function(B){B.lastModifedDate=new Date,B.name=o,b(B)})})}},{key:"distanceBetween",value:function(o,f){return Math.sqrt(Math.pow(f.x-o.x,2)+Math.pow(f.y-o.y,2))}},{key:"angleBetween",value:function(o,f){return Math.atan2(f.x-o.x,f.y-o.y)}},{key:"draw",value:function(o){var f=o.from,b=o.to,u=o.size,v=o.color;this.context.globalCompositeOperation="source-over",this.brush({from:f,to:b,size:u,color:v})}},{key:"erase",value:function(o){var f=o.from,b=o.to,u=o.size;this.context.globalCompositeOperation="destination-out",this.brush({from:f,to:b,size:u,color:"#000000"})}},{key:"brush",value:function(o){var f=this,b=o.from,u=o.to,v=o.size,y=o.color,x=(v-v%2)/2,z=this.stampMaker.make({size:v,color:y});if(b.x!==u.x||b.y!==u.y)for(var _=this.distanceBetween(b,u),P=this.angleBetween(b,u),B=function(H){var X=b.x+Math.sin(P)*H-x,Z=b.y+Math.cos(P)*H-x;window.requestAnimationFrame(function(){f.context.drawImage(z,Math.round(X),Math.round(Z),v,v)})},I=0;I<_;I+=1)B(I);else{var R=b.x-x,K=b.y-x;this.context.drawImage(z,Math.round(R),Math.round(K),v,v)}}},{key:"dpr",get:function(){return window.devicePixelRatio||1}}])&&g(w.prototype,S),h}();r.default=C}])})})(et);var He=mt(et.exports);function bt(l){let e,t;return{c(){e=pe("svg"),t=pe("path"),this.h()},l(r){e=de(r,"svg",{xmlns:!0,width:!0,viewBox:!0,class:!0});var s=T(e);t=de(s,"path",{fill:!0,stroke:!0,"stroke-width":!0,d:!0}),T(t).forEach(E),s.forEach(E),this.h()},h(){c(t,"fill","white"),c(t,"stroke","black"),c(t,"stroke-width","30"),c(t,"d","M480 256c0 123.4-100.5 223.9-223.9 223.9c-48.84 0-95.17-15.58-134.2-44.86c-14.12-10.59-16.97-30.66-6.375-44.81c10.59-14.12 30.62-16.94 44.81-6.375c27.84 20.91 61 31.94 95.88 31.94C344.3 415.8 416 344.1 416 256s-71.69-159.8-159.8-159.8c-37.46 0-73.09 13.49-101.3 36.64l45.12 45.14c17.01 17.02 4.955 46.1-19.1 46.1H35.17C24.58 224.1 16 215.5 16 204.9V59.04c0-24.04 29.07-36.08 46.07-19.07l47.6 47.63C149.9 52.71 201.5 32.11 256.1 32.11C379.5 32.11 480 132.6 480 256z"),c(e,"xmlns","http://www.w3.org/2000/svg"),c(e,"width","20"),c(e,"viewBox","0 0 512 512"),c(e,"class",l[0])},m(r,s){$(r,e,s),d(e,t)},p(r,[s]){s&1&&c(e,"class",r[0])},i:Y,o:Y,d(r){r&&E(e)}}}function gt(l,e,t){let{classNames:r=""}=e;return l.$$set=s=>{"classNames"in s&&t(0,r=s.classNames)},[r]}class yt extends W{constructor(e){super(),ee(this,e,gt,bt,te,{classNames:0})}}function wt(l){var f;let e,t,r,s,a,i,p,n=((f=l[0])==null?void 0:f.label)+"",m,k,g,C,h,w,S,o;return C=new yt({}),{c(){e=M("div"),t=M("div"),r=M("canvas"),s=D(),a=M("canvas"),i=D(),p=M("span"),m=V(n),k=D(),g=M("button"),oe(C.$$.fragment),this.h()},l(b){e=O(b,"DIV",{});var u=T(e);t=O(u,"DIV",{class:!0});var v=T(t);r=O(v,"CANVAS",{class:!0,width:!0,height:!0}),T(r).forEach(E),s=j(v),a=O(v,"CANVAS",{class:!0,width:!0,height:!0}),T(a).forEach(E),i=j(v),p=O(v,"SPAN",{class:!0});var y=T(p);m=F(y,n),y.forEach(E),k=j(v),g=O(v,"BUTTON",{class:!0});var x=T(g);se(C.$$.fragment,x),x.forEach(E),v.forEach(E),u.forEach(E),this.h()},h(){c(r,"class","canvas svelte-pr47cz"),c(r,"width","512"),c(r,"height","512"),c(a,"class","brush svelte-pr47cz"),c(a,"width","10"),c(a,"height","10"),c(p,"class","label svelte-pr47cz"),c(g,"class","absolute bottom-0 left-0 p-3"),g.disabled=h=l[3].size<=0,c(t,"class","relative overflow-clip")},m(b,u){$(b,e,u),d(e,t),d(t,r),l[11](r),d(t,s),d(t,a),l[12](a),d(t,i),d(t,p),d(p,m),d(t,k),d(t,g),ne(C,g,null),w=!0,S||(o=[N(r,"touchmove",xt),N(r,"pointerenter",_t),N(r,"pointerup",l[4]),N(r,"pointerleave",l[4]),N(r,"pointercancel",l[4]),N(r,"pointerout",l[4]),N(r,"pointermove",l[6]),N(r,"pointerdown",l[5]),N(g,"click",ge(l[13]))],S=!0)},p(b,[u]){var v;(!w||u&1)&&n!==(n=((v=b[0])==null?void 0:v.label)+"")&&Te(m,n),(!w||u&8&&h!==(h=b[3].size<=0))&&(g.disabled=h)},i(b){w||(ie(C.$$.fragment,b),w=!0)},o(b){ce(C.$$.fragment,b),w=!1},d(b){b&&E(e),l[11](null),l[12](null),ue(C),S=!1,Be(o)}}}function _t(){}function $e(l,e){const t=l.getBoundingClientRect();return{x:(e.clientX-t.left)*(l.width/t.width),y:(e.clientY-t.top)*(l.height/t.height)}}function Ye(l){l.fillStyle="#000000",l.fillRect(0,0,l.canvas.width,l.canvas.height)}function xe(l,e){l.drawImage(e,0,0,l.canvas.width,l.canvas.height)}const xt=l=>l.preventDefault();function kt(l,e,t){let r,s,a,i;G(l,ve,_=>t(3,r=_)),G(l,Ce,_=>t(10,s=_)),G(l,me,_=>t(0,a=_)),G(l,Pe,_=>t(18,i=_));let p,n,m,k,g={x:0,y:0},C;lt(()=>{t(9,k=p.getContext("2d")),t(8,m=n.getContext("2d")),window.devicePixelRatio=1,C=new He(p),t(1,p.style.height="unset",p),t(1,p.style.width="unset",p),J(Pe,i=p,i),Ye(k)});let h=!1,w;function S(){t(2,n.style.top=`${10+a.size/2}px`,n),t(2,n.style.left=`${10+a.size/2}px`,n),h=!1}function o(_){h=!0,g=$e(p,_),C.draw({from:g,to:g,size:a.size,color:a.color}),w=ft(),ve.update(P=>(P.set(w,{brush:a,points:[{from:g,to:g}]}),P))}function f(_){const P=$e(p,_);t(2,n.style.top=`${_.offsetY}px`,n),t(2,n.style.left=`${_.offsetX}px`,n),h&&(C.draw({from:g,to:P,size:a.size,color:a.color}),ve.update(B=>{const I=B.get(w);return I==null||I.points.push({from:g,to:P}),B}),g=P)}function b(_){const{size:P,color:B}=_;t(2,n.width=P,n),t(2,n.height=P,n),t(8,m.fillStyle=B,m),m.arc(P/2,P/2,P/2,0,2*Math.PI),m.fill()}function u(){if(r.size<=0)return;const _=Array.from(r.keys());ve.update(P=>(P.delete(_[_.length-1]),P)),v(k)}function v(_){const P=document.createElement("canvas");P.width=512,P.height=512,window.devicePixelRatio=1;const B=new He(P);Ye(_),s&&xe(_,s),Array.from(r.values()).forEach(I=>{I.points.forEach((R,K)=>{B.draw({from:R.from,to:R.to,size:I.brush.size,color:I.brush.color})})}),requestAnimationFrame(()=>{xe(_,P)})}function y(_){Ee[_?"unshift":"push"](()=>{p=_,t(1,p)})}function x(_){Ee[_?"unshift":"push"](()=>{n=_,t(2,n),t(8,m),t(0,a)})}const z=()=>u();return l.$$.update=()=>{l.$$.dirty&257&&m&&a&&(b(a),t(2,n.style.top=`${10+a.size/2}px`,n),t(2,n.style.left=`${10+a.size/2}px`,n)),l.$$.dirty&1536&&s&&(xe(k,s),J(ve,r=new Map,r))},[a,p,n,r,S,o,f,u,m,k,s,y,x,z]}class Et extends W{constructor(e){super(),ee(this,e,kt,wt,te,{})}}function Je(l){let e,t,r;return{c(){e=M("img"),this.h()},l(s){e=O(s,"IMG",{class:!0,alt:!0,src:!0,width:!0,height:!0}),this.h()},h(){c(e,"class",t="image "+(l[1]?"opacity-30":"")+" svelte-1t0h0rs"),c(e,"alt","Generative Map Result"),ke(e.src,r=l[0])||c(e,"src",r),c(e,"width","512"),c(e,"height","512")},m(s,a){$(s,e,a)},p(s,a){a&2&&t!==(t="image "+(s[1]?"opacity-30":"")+" svelte-1t0h0rs")&&c(e,"class",t),a&1&&!ke(e.src,r=s[0])&&c(e,"src",r)},d(s){s&&E(e)}}}function Xe(l){let e,t,r,s,a,i;return{c(){e=M("div"),t=pe("svg"),r=pe("path"),s=D(),a=M("span"),i=V(Ke),this.h()},l(p){e=O(p,"DIV",{class:!0});var n=T(e);t=de(n,"svg",{xmlns:!0,fill:!0,viewBox:!0,class:!0});var m=T(t);r=de(m,"path",{fill:!0,d:!0}),T(r).forEach(E),m.forEach(E),s=j(n),a=O(n,"SPAN",{class:!0});var k=T(a);i=F(k,Ke),k.forEach(E),n.forEach(E),this.h()},h(){c(r,"fill","currentColor"),c(r,"d","M20 12a8 8 0 0 1-8 8v4a12 12 0 0 0 12-12h-4Zm-2-5.3a8 8 0 0 1 2 5.3h4c0-3-1.1-5.8-3-8l-3 2.7Z"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"class","animate-spin max-w-[3rem]"),c(a,"class","text-xs"),c(e,"class","loading svelte-1t0h0rs")},m(p,n){$(p,e,n),d(e,t),d(t,r),d(e,s),d(e,a),d(a,i)},p:Y,d(p){p&&E(e)}}}function It(l){let e,t,r=l[0]&&Je(l),s=l[1]&&Xe();return{c(){e=M("div"),r&&r.c(),t=D(),s&&s.c(),this.h()},l(a){e=O(a,"DIV",{class:!0});var i=T(e);r&&r.l(i),t=j(i),s&&s.l(i),i.forEach(E),this.h()},h(){c(e,"class","relative overflow-clip flex flex-col justify-center items-center w-full h-full")},m(a,i){$(a,e,i),r&&r.m(e,null),d(e,t),s&&s.m(e,null)},p(a,[i]){a[0]?r?r.p(a,i):(r=Je(a),r.c(),r.m(e,t)):r&&(r.d(1),r=null),a[1]?s?s.p(a,i):(s=Xe(),s.c(),s.m(e,null)):s&&(s.d(1),s=null)},i:Y,o:Y,d(a){a&&E(e),r&&r.d(),s&&s.d()}}}let Ke="";async function St(l){return new Promise((e,t)=>{try{const r=document.createElement("a");r.download=`sucess-${Date.now()}.png`,r.target="_self",r.onclick=async s=>{r.href&&URL.revokeObjectURL(r.href),r.href=l},requestAnimationFrame(()=>{console.log("Downloading image."),r.click(),e(null)})}catch{t()}})}async function zt(l,{prompt:e,steps:t,seed:r}){const s=await fetch("/predict",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:[l,e,t,r.toString()]})});if(!s.ok)throw new Error("Prediction request failed.");return await s.text()}function Pt(l,e,t){let r,s,a,i,p;return G(l,we,n=>t(2,r=n)),G(l,ze,n=>t(0,s=n)),G(l,he,n=>t(1,a=n)),G(l,Me,n=>t(3,i=n)),G(l,Pe,n=>t(4,p=n)),l.$$.update=()=>{l.$$.dirty&26&&(async()=>{if(a){const n=await zt(p.toDataURL(),i);J(ze,s=n,s),J(he,a=!1,a)}})(),l.$$.dirty&5&&(async()=>r&&(await St(s),J(we,r=!1,r)))()},[s,a,r,i,p]}class Ct extends W{constructor(e){super(),ee(this,e,Pt,It,te,{})}}function Mt(l){let e,t,r,s,a,i,p,n,m,k,g,C,h,w,S,o,f,b,u,v,y,x,z,_,P,B;return i=new ut({}),m=new Et({}),g=new Ct({}),y=new nt({}),z=new ht({}),{c(){e=M("div"),t=M("article"),r=M("h1"),s=V("Drawing to Map"),a=D(),oe(i.$$.fragment),p=D(),n=M("div"),oe(m.$$.fragment),k=D(),oe(g.$$.fragment),C=D(),h=M("button"),w=V("Generate Map"),o=D(),f=M("button"),b=V("Save Result"),v=D(),oe(y.$$.fragment),x=D(),oe(z.$$.fragment),this.h()},l(I){e=O(I,"DIV",{class:!0});var R=T(e);t=O(R,"ARTICLE",{class:!0});var K=T(t);r=O(K,"H1",{});var H=T(r);s=F(H,"Drawing to Map"),H.forEach(E),K.forEach(E),a=j(R),se(i.$$.fragment,R),p=j(R),n=O(R,"DIV",{class:!0});var X=T(n);se(m.$$.fragment,X),k=j(X),se(g.$$.fragment,X),X.forEach(E),C=j(R),h=O(R,"BUTTON",{class:!0});var Z=T(h);w=F(Z,"Generate Map"),Z.forEach(E),o=j(R),f=O(R,"BUTTON",{class:!0});var fe=T(f);b=F(fe,"Save Result"),fe.forEach(E),v=j(R),se(y.$$.fragment,R),x=j(R),se(z.$$.fragment,R),R.forEach(E),this.h()},h(){c(t,"class","prose dark:prose-invert"),c(n,"class","drawings py-3 -mx-3 svelte-237ry5"),h.disabled=S=l[0]===!0,c(h,"class","svelte-237ry5"),f.disabled=u=l[1]===!0||!l[2],c(f,"class","svelte-237ry5"),c(e,"class","max-w-screen-md mx-auto px-3 py-5 relative z-0")},m(I,R){$(I,e,R),d(e,t),d(t,r),d(r,s),d(e,a),ne(i,e,null),d(e,p),d(e,n),ne(m,n,null),d(n,k),ne(g,n,null),d(e,C),d(e,h),d(h,w),d(e,o),d(e,f),d(f,b),d(e,v),ne(y,e,null),d(e,x),ne(z,e,null),_=!0,P||(B=[N(h,"click",ge(l[3])),N(f,"click",ge(l[4]))],P=!0)},p(I,[R]){(!_||R&1&&S!==(S=I[0]===!0))&&(h.disabled=S),(!_||R&6&&u!==(u=I[1]===!0||!I[2]))&&(f.disabled=u)},i(I){_||(ie(i.$$.fragment,I),ie(m.$$.fragment,I),ie(g.$$.fragment,I),ie(y.$$.fragment,I),ie(z.$$.fragment,I),_=!0)},o(I){ce(i.$$.fragment,I),ce(m.$$.fragment,I),ce(g.$$.fragment,I),ce(y.$$.fragment,I),ce(z.$$.fragment,I),_=!1},d(I){I&&E(e),ue(i),ue(m),ue(g),ue(y),ue(z),P=!1,Be(B)}}}function Ot(l,e,t){let r,s,a;return G(l,he,n=>t(0,r=n)),G(l,we,n=>t(1,s=n)),G(l,ze,n=>t(2,a=n)),[r,s,a,()=>J(he,r=!0,r),()=>J(we,s=!0,s)]}class Rt extends W{constructor(e){super(),ee(this,e,Ot,Mt,te,{})}}export{Rt as default};
|
frontend/.svelte-kit/output/client/_app/immutable/start-a60c2789.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{S as Ye,i as Ge,s as Me,e as Fe,c as Xe,a as He,d as D,b as me,f as K,g as V,t as Ze,h as Qe,j as et,k as tt,l as P,m as nt,n as Y,o as C,p as G,q as T,r as st,u as rt,v as ye,w as z,x as ne,y as q,z as se,A as re,B as J,C as ie,D as Ce}from"./chunks/index-bcf2726a.js";import{s as it,w as ce,a as at}from"./chunks/paths-d3bcbd10.js";function ot(s){let e,t,i;const l=[s[1]||{}];var c=s[0][0];function f(n){let r={};for(let a=0;a<l.length;a+=1)r=ie(r,l[a]);return{props:r}}return c&&(e=new c(f())),{c(){e&&z(e.$$.fragment),t=P()},l(n){e&&ne(e.$$.fragment,n),t=P()},m(n,r){e&&q(e,n,r),V(n,t,r),i=!0},p(n,r){const a=r&2?se(l,[re(n[1]||{})]):{};if(c!==(c=n[0][0])){if(e){Y();const d=e;C(d.$$.fragment,1,0,()=>{J(d,1)}),G()}c?(e=new c(f()),z(e.$$.fragment),T(e.$$.fragment,1),q(e,t.parentNode,t)):e=null}else c&&e.$set(a)},i(n){i||(e&&T(e.$$.fragment,n),i=!0)},o(n){e&&C(e.$$.fragment,n),i=!1},d(n){n&&D(t),e&&J(e,n)}}}function ct(s){let e,t,i;const l=[s[1]||{}];var c=s[0][0];function f(n){let r={$$slots:{default:[dt]},$$scope:{ctx:n}};for(let a=0;a<l.length;a+=1)r=ie(r,l[a]);return{props:r}}return c&&(e=new c(f(s))),{c(){e&&z(e.$$.fragment),t=P()},l(n){e&&ne(e.$$.fragment,n),t=P()},m(n,r){e&&q(e,n,r),V(n,t,r),i=!0},p(n,r){const a=r&2?se(l,[re(n[1]||{})]):{};if(r&525&&(a.$$scope={dirty:r,ctx:n}),c!==(c=n[0][0])){if(e){Y();const d=e;C(d.$$.fragment,1,0,()=>{J(d,1)}),G()}c?(e=new c(f(n)),z(e.$$.fragment),T(e.$$.fragment,1),q(e,t.parentNode,t)):e=null}else c&&e.$set(a)},i(n){i||(e&&T(e.$$.fragment,n),i=!0)},o(n){e&&C(e.$$.fragment,n),i=!1},d(n){n&&D(t),e&&J(e,n)}}}function lt(s){let e,t,i;const l=[s[2]||{}];var c=s[0][1];function f(n){let r={};for(let a=0;a<l.length;a+=1)r=ie(r,l[a]);return{props:r}}return c&&(e=new c(f())),{c(){e&&z(e.$$.fragment),t=P()},l(n){e&&ne(e.$$.fragment,n),t=P()},m(n,r){e&&q(e,n,r),V(n,t,r),i=!0},p(n,r){const a=r&4?se(l,[re(n[2]||{})]):{};if(c!==(c=n[0][1])){if(e){Y();const d=e;C(d.$$.fragment,1,0,()=>{J(d,1)}),G()}c?(e=new c(f()),z(e.$$.fragment),T(e.$$.fragment,1),q(e,t.parentNode,t)):e=null}else c&&e.$set(a)},i(n){i||(e&&T(e.$$.fragment,n),i=!0)},o(n){e&&C(e.$$.fragment,n),i=!1},d(n){n&&D(t),e&&J(e,n)}}}function ft(s){let e,t,i;const l=[s[2]||{}];var c=s[0][1];function f(n){let r={$$slots:{default:[ut]},$$scope:{ctx:n}};for(let a=0;a<l.length;a+=1)r=ie(r,l[a]);return{props:r}}return c&&(e=new c(f(s))),{c(){e&&z(e.$$.fragment),t=P()},l(n){e&&ne(e.$$.fragment,n),t=P()},m(n,r){e&&q(e,n,r),V(n,t,r),i=!0},p(n,r){const a=r&4?se(l,[re(n[2]||{})]):{};if(r&521&&(a.$$scope={dirty:r,ctx:n}),c!==(c=n[0][1])){if(e){Y();const d=e;C(d.$$.fragment,1,0,()=>{J(d,1)}),G()}c?(e=new c(f(n)),z(e.$$.fragment),T(e.$$.fragment,1),q(e,t.parentNode,t)):e=null}else c&&e.$set(a)},i(n){i||(e&&T(e.$$.fragment,n),i=!0)},o(n){e&&C(e.$$.fragment,n),i=!1},d(n){n&&D(t),e&&J(e,n)}}}function ut(s){let e,t,i;const l=[s[3]||{}];var c=s[0][2];function f(n){let r={};for(let a=0;a<l.length;a+=1)r=ie(r,l[a]);return{props:r}}return c&&(e=new c(f())),{c(){e&&z(e.$$.fragment),t=P()},l(n){e&&ne(e.$$.fragment,n),t=P()},m(n,r){e&&q(e,n,r),V(n,t,r),i=!0},p(n,r){const a=r&8?se(l,[re(n[3]||{})]):{};if(c!==(c=n[0][2])){if(e){Y();const d=e;C(d.$$.fragment,1,0,()=>{J(d,1)}),G()}c?(e=new c(f()),z(e.$$.fragment),T(e.$$.fragment,1),q(e,t.parentNode,t)):e=null}else c&&e.$set(a)},i(n){i||(e&&T(e.$$.fragment,n),i=!0)},o(n){e&&C(e.$$.fragment,n),i=!1},d(n){n&&D(t),e&&J(e,n)}}}function dt(s){let e,t,i,l;const c=[ft,lt],f=[];function n(r,a){return r[0][2]?0:1}return e=n(s),t=f[e]=c[e](s),{c(){t.c(),i=P()},l(r){t.l(r),i=P()},m(r,a){f[e].m(r,a),V(r,i,a),l=!0},p(r,a){let d=e;e=n(r),e===d?f[e].p(r,a):(Y(),C(f[d],1,1,()=>{f[d]=null}),G(),t=f[e],t?t.p(r,a):(t=f[e]=c[e](r),t.c()),T(t,1),t.m(i.parentNode,i))},i(r){l||(T(t),l=!0)},o(r){C(t),l=!1},d(r){f[e].d(r),r&&D(i)}}}function Te(s){let e,t=s[5]&&je(s);return{c(){e=Fe("div"),t&&t.c(),this.h()},l(i){e=Xe(i,"DIV",{id:!0,"aria-live":!0,"aria-atomic":!0,style:!0});var l=He(e);t&&t.l(l),l.forEach(D),this.h()},h(){me(e,"id","svelte-announcer"),me(e,"aria-live","assertive"),me(e,"aria-atomic","true"),K(e,"position","absolute"),K(e,"left","0"),K(e,"top","0"),K(e,"clip","rect(0 0 0 0)"),K(e,"clip-path","inset(50%)"),K(e,"overflow","hidden"),K(e,"white-space","nowrap"),K(e,"width","1px"),K(e,"height","1px")},m(i,l){V(i,e,l),t&&t.m(e,null)},p(i,l){i[5]?t?t.p(i,l):(t=je(i),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},d(i){i&&D(e),t&&t.d()}}}function je(s){let e;return{c(){e=Ze(s[6])},l(t){e=Qe(t,s[6])},m(t,i){V(t,e,i)},p(t,i){i&64&&et(e,t[6])},d(t){t&&D(e)}}}function pt(s){let e,t,i,l,c;const f=[ct,ot],n=[];function r(d,L){return d[0][1]?0:1}e=r(s),t=n[e]=f[e](s);let a=s[4]&&Te(s);return{c(){t.c(),i=tt(),a&&a.c(),l=P()},l(d){t.l(d),i=nt(d),a&&a.l(d),l=P()},m(d,L){n[e].m(d,L),V(d,i,L),a&&a.m(d,L),V(d,l,L),c=!0},p(d,[L]){let E=e;e=r(d),e===E?n[e].p(d,L):(Y(),C(n[E],1,1,()=>{n[E]=null}),G(),t=n[e],t?t.p(d,L):(t=n[e]=f[e](d),t.c()),T(t,1),t.m(i.parentNode,i)),d[4]?a?a.p(d,L):(a=Te(d),a.c(),a.m(l.parentNode,l)):a&&(a.d(1),a=null)},i(d){c||(T(t),c=!0)},o(d){C(t),c=!1},d(d){n[e].d(d),d&&D(i),a&&a.d(d),d&&D(l)}}}function ht(s,e,t){let{stores:i}=e,{page:l}=e,{components:c}=e,{props_0:f=null}=e,{props_1:n=null}=e,{props_2:r=null}=e;st("__svelte__",i),rt(i.page.notify);let a=!1,d=!1,L=null;return ye(()=>{const E=i.page.subscribe(()=>{a&&(t(5,d=!0),t(6,L=document.title||"untitled page"))});return t(4,a=!0),E}),s.$$set=E=>{"stores"in E&&t(7,i=E.stores),"page"in E&&t(8,l=E.page),"components"in E&&t(0,c=E.components),"props_0"in E&&t(1,f=E.props_0),"props_1"in E&&t(2,n=E.props_1),"props_2"in E&&t(3,r=E.props_2)},s.$$.update=()=>{s.$$.dirty&384&&i.page.set(l)},[c,f,n,r,a,d,L,i,l]}class _t extends Ye{constructor(e){super(),Ge(this,e,ht,pt,Me,{stores:7,page:8,components:0,props_0:1,props_1:2,props_2:3})}}const mt="modulepreload",Ie={},gt="/static/_app/immutable/",ge=function(e,t){return!t||t.length===0?e():Promise.all(t.map(i=>{if(i=`${gt}${i}`,i in Ie)return;Ie[i]=!0;const l=i.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${c}`))return;const f=document.createElement("link");if(f.rel=l?"stylesheet":mt,l||(f.as="script",f.crossOrigin=""),f.href=i,document.head.appendChild(f),l)return new Promise((n,r)=>{f.addEventListener("load",n),f.addEventListener("error",()=>r(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>e())},wt={},le=[()=>ge(()=>import("./pages/__layout.svelte-0c386344.js"),["pages/__layout.svelte-0c386344.js","assets/pages/__layout.svelte-dcfcba4b.css","chunks/index-bcf2726a.js"]),()=>ge(()=>import("./error.svelte-d9523301.js"),["error.svelte-d9523301.js","chunks/index-bcf2726a.js"]),()=>ge(()=>import("./pages/index.svelte-6350336a.js"),["pages/index.svelte-6350336a.js","assets/pages/index.svelte-65a37285.css","chunks/index-bcf2726a.js","chunks/paths-d3bcbd10.js"])],bt={"":[[0,2],[1]]};function yt(s){s.client}function De(s){return s instanceof Error||s&&s.name&&s.message?s:new Error(JSON.stringify(s))}function Ve(s){if(s.fallthrough)throw new Error("fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching");if("maxage"in s)throw new Error("maxage should be replaced with cache: { maxage }");const e=s.status&&s.status>=400&&s.status<=599&&!s.redirect;if(s.error||e){const t=s.status;if(!s.error&&e)return{status:t||500,error:new Error};const i=typeof s.error=="string"?new Error(s.error):s.error;return i instanceof Error?!t||t<400||t>599?(console.warn('"error" returned from load() without a valid status code \u2014 defaulting to 500'),{status:500,error:i}):{status:t,error:i}:{status:500,error:new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof i}"`)}}if(s.redirect){if(!s.status||Math.floor(s.status/100)!==3)throw new Error('"redirect" property returned from load() must be accompanied by a 3xx status code');if(typeof s.redirect!="string")throw new Error('"redirect" property returned from load() must be a string')}if(s.dependencies&&(!Array.isArray(s.dependencies)||s.dependencies.some(t=>typeof t!="string")))throw new Error('"dependencies" property returned from load() must be of type string[]');if(s.context)throw new Error('You are returning "context" from a load function. "context" was renamed to "stuff", please adjust your code accordingly.');return s}function vt(s,e){return s==="/"||e==="ignore"?s:e==="never"?s.endsWith("/")?s.slice(0,-1):s:e==="always"&&!s.endsWith("/")?s+"/":s}class $t extends URL{get hash(){throw new Error("url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component.")}}function ze(s){let e=s.baseURI;if(!e){const t=s.getElementsByTagName("base");e=t.length?t[0].href:s.URL}return e}function ve(){return{x:pageXOffset,y:pageYOffset}}function qe(s){return s.composedPath().find(t=>t instanceof Node&&t.nodeName.toUpperCase()==="A")}function Je(s){return s instanceof SVGAElement?new URL(s.href.baseVal,document.baseURI):new URL(s.href)}function Ke(s){const e=ce(s);let t=!0;function i(){t=!0,e.update(f=>f)}function l(f){t=!1,e.set(f)}function c(f){let n;return e.subscribe(r=>{(n===void 0||t&&r!==n)&&f(n=r)})}return{notify:i,set:l,subscribe:c}}function kt(){const{set:s,subscribe:e}=ce(!1),t="1684956620534";let i;async function l(){clearTimeout(i);const f=await fetch(`${at}/_app/version.json`,{headers:{pragma:"no-cache","cache-control":"no-cache"}});if(f.ok){const{version:n}=await f.json(),r=n!==t;return r&&(s(!0),clearTimeout(i)),r}else throw new Error(`Version check failed: ${f.status}`)}return{subscribe:e,check:l}}function Et(s){let e=5381,t=s.length;if(typeof s=="string")for(;t;)e=e*33^s.charCodeAt(--t);else for(;t;)e=e*33^s[--t];return(e>>>0).toString(36)}const $e=window.fetch;function Rt(s,e){let i=`script[sveltekit\\:data-type="data"][sveltekit\\:data-url=${JSON.stringify(typeof s=="string"?s:s.url)}]`;e&&typeof e.body=="string"&&(i+=`[sveltekit\\:data-body="${Et(e.body)}"]`);const l=document.querySelector(i);if(l&&l.textContent){const{body:c,...f}=JSON.parse(l.textContent);return Promise.resolve(new Response(c,f))}return $e(s,e)}const Lt=/^(\.\.\.)?(\w+)(?:=(\w+))?$/;function St(s){const e=[],t=[];let i=!0;return{pattern:s===""?/^\/$/:new RegExp(`^${decodeURIComponent(s).split(/(?:@[a-zA-Z0-9_-]+)?(?:\/|$)/).map((c,f,n)=>{const r=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(c);if(r)return e.push(r[1]),t.push(r[2]),"(?:/(.*))?";const a=f===n.length-1;return c&&"/"+c.split(/\[(.+?)\]/).map((d,L)=>{if(L%2){const[,E,X,M]=Lt.exec(d);return e.push(X),t.push(M),E?"(.*?)":"([^/]+?)"}return a&&d.includes(".")&&(i=!1),d.normalize().replace(/%5[Bb]/g,"[").replace(/%5[Dd]/g,"]").replace(/#/g,"%23").replace(/\?/g,"%3F").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}).join("")}).join("")}${i?"/?":""}$`),names:e,types:t}}function Ut(s,e,t,i){const l={};for(let c=0;c<e.length;c+=1){const f=e[c],n=t[c],r=s[c+1]||"";if(n){const a=i[n];if(!a)throw new Error(`Missing "${n}" param matcher`);if(!a(r))return}l[f]=r}return l}function At(s,e,t){return Object.entries(e).map(([l,[c,f,n]])=>{const{pattern:r,names:a,types:d}=St(l);return{id:l,exec:L=>{const E=r.exec(L);if(E)return Ut(E,a,d,t)},a:c.map(L=>s[L]),b:f.map(L=>s[L]),has_shadow:!!n}})}const We="sveltekit:scroll",B="sveltekit:index",we=At(le,bt,wt),Nt=le[0](),Ot=le[1](),Be={};let te={};try{te=JSON.parse(sessionStorage[We])}catch{}function be(s){te[s]=ve()}function xt({target:s,session:e,base:t,trailing_slash:i}){var xe;const l=new Map,c=[],f={url:Ke({}),page:Ke({}),navigating:ce(null),session:ce(e),updated:kt()},n={id:null,promise:null},r={before_navigate:[],after_navigate:[]};let a={branch:[],error:null,session_id:0,stuff:Be,url:null},d=!1,L=!0,E=!1,X=1,M=null,ke,Ee,Re=!1;f.session.subscribe(async o=>{Ee=o,Re&&(X+=1,pe(new URL(location.href),[],!0))}),Re=!0;let F=!0,j=(xe=history.state)==null?void 0:xe[B];j||(j=Date.now(),history.replaceState({...history.state,[B]:j},"",location.href));const fe=te[j];fe&&(history.scrollRestoration="manual",scrollTo(fe.x,fe.y));let ue=!1,de,Le;async function Se(o,{noscroll:p=!1,replaceState:w=!1,keepfocus:u=!1,state:h={}},b){if(typeof o=="string"&&(o=new URL(o,ze(document))),F)return _e({url:o,scroll:p?ve():null,keepfocus:u,redirect_chain:b,details:{state:h,replaceState:w},accepted:()=>{},blocked:()=>{}});await Q(o)}async function Ue(o){const p=Oe(o);if(!p)throw new Error("Attempted to prefetch a URL that does not belong to this app");return n.promise=Ne(p,!1),n.id=p.id,n.promise}async function pe(o,p,w,u,h){var R,S,N;const b=Oe(o),v=Le={};let _=b&&await Ne(b,w);if(!_&&o.origin===location.origin&&o.pathname===location.pathname&&(_=await Z({status:404,error:new Error(`Not found: ${o.pathname}`),url:o,routeId:null})),!_)return await Q(o),!1;if(Le!==v)return!1;if(c.length=0,_.redirect)if(p.length>10||p.includes(o.pathname))_=await Z({status:500,error:new Error("Redirect loop"),url:o,routeId:null});else return F?Se(new URL(_.redirect,o).href,{},[...p,o.pathname]):await Q(new URL(_.redirect,location.href)),!1;else((S=(R=_.props)==null?void 0:R.page)==null?void 0:S.status)>=400&&await f.updated.check()&&await Q(o);if(E=!0,u&&u.details){const{details:$}=u,y=$.replaceState?0:1;$.state[B]=j+=y,history[$.replaceState?"replaceState":"pushState"]($.state,"",o)}if(d?(a=_.state,_.props.page&&(_.props.page.url=o),ke.$set(_.props)):Ae(_),u){const{scroll:$,keepfocus:y}=u;if(!y){const U=document.body,g=U.getAttribute("tabindex");(N=getSelection())==null||N.removeAllRanges(),U.tabIndex=-1,U.focus({preventScroll:!0}),g!==null?U.setAttribute("tabindex",g):U.removeAttribute("tabindex")}if(await Ce(),L){const U=o.hash&&document.getElementById(o.hash.slice(1));$?scrollTo($.x,$.y):U?U.scrollIntoView():scrollTo(0,0)}}else await Ce();n.promise=null,n.id=null,L=!0,_.props.page&&(de=_.props.page);const m=_.state.branch[_.state.branch.length-1];F=(m==null?void 0:m.module.router)!==!1,h&&h(),E=!1}function Ae(o){a=o.state;const p=document.querySelector("style[data-sveltekit]");if(p&&p.remove(),de=o.props.page,ke=new _t({target:s,props:{...o.props,stores:f},hydrate:!0}),F){const w={from:null,to:new URL(location.href)};r.after_navigate.forEach(u=>u(w))}d=!0}async function he({url:o,params:p,stuff:w,branch:u,status:h,error:b,routeId:v}){var y,U;const _=u.filter(Boolean),m=_.find(g=>{var O;return(O=g.loaded)==null?void 0:O.redirect}),R={redirect:(y=m==null?void 0:m.loaded)==null?void 0:y.redirect,state:{url:o,params:p,branch:u,error:b,stuff:w,session_id:X},props:{components:_.map(g=>g.module.default)}};for(let g=0;g<_.length;g+=1){const O=_[g].loaded;R.props[`props_${g}`]=O?await O.props:null}if(!a.url||o.href!==a.url.href||a.error!==b||a.stuff!==w){R.props.page={error:b,params:p,routeId:v,status:h,stuff:w,url:o};const g=(O,k)=>{Object.defineProperty(R.props.page,O,{get:()=>{throw new Error(`$page.${O} has been replaced by $page.url.${k}`)}})};g("origin","origin"),g("path","pathname"),g("query","searchParams")}const N=_[_.length-1],$=(U=N==null?void 0:N.loaded)==null?void 0:U.cache;if($){const g=o.pathname+o.search;let O=!1;const k=()=>{l.get(g)===R&&l.delete(g),x(),clearTimeout(A)},A=setTimeout(k,$.maxage*1e3),x=f.session.subscribe(()=>{O&&k()});O=!0,l.set(g,R)}return R}async function H({status:o,error:p,module:w,url:u,params:h,stuff:b,props:v,routeId:_}){const m={module:w,uses:{params:new Set,url:!1,session:!1,stuff:!1,dependencies:new Set},loaded:null,stuff:b};function R(y){const{href:U}=new URL(y,u);m.uses.dependencies.add(U)}v&&m.uses.dependencies.add(u.href);const S={};for(const y in h)Object.defineProperty(S,y,{get(){return m.uses.params.add(y),h[y]},enumerable:!0});const N=Ee,$=new $t(u);if(w.load){const y={routeId:_,params:S,props:v||{},get url(){return m.uses.url=!0,$},get session(){return m.uses.session=!0,N},get stuff(){return m.uses.stuff=!0,{...b}},async fetch(g,O){let k;typeof g=="string"?k=g:(k=g.url,O={body:g.method==="GET"||g.method==="HEAD"?void 0:await g.blob(),cache:g.cache,credentials:g.credentials,headers:g.headers,integrity:g.integrity,keepalive:g.keepalive,method:g.method,mode:g.mode,redirect:g.redirect,referrer:g.referrer,referrerPolicy:g.referrerPolicy,signal:g.signal,...O});const A=new URL(k,u).href;return R(A),d?$e(A,O):Rt(k,O)},status:o!=null?o:null,error:p!=null?p:null};let U;if(U=await w.load.call(null,y),!U)throw new Error("load function must return a value");m.loaded=Ve(U),m.loaded.stuff&&(m.stuff=m.loaded.stuff),m.loaded.dependencies&&m.loaded.dependencies.forEach(R)}else v&&(m.loaded=Ve({props:v}));return m}async function Ne({id:o,url:p,params:w,route:u},h){var U,g,O;if(n.id===o&&n.promise)return n.promise;if(!h){const k=l.get(o);if(k)return k}const{a:b,b:v,has_shadow:_}=u,m=a.url&&{url:o!==a.url.pathname+a.url.search,params:Object.keys(w).filter(k=>a.params[k]!==w[k]),session:X!==a.session_id};let R=[],S=Be,N=!1,$=200,y=null;b.forEach(k=>k().catch(()=>{}));e:for(let k=0;k<b.length;k+=1){let A;try{if(!b[k])continue;const x=await b[k](),I=a.branch[k];if(!I||x!==I.module||m.url&&I.uses.url||m.params.some(W=>I.uses.params.has(W))||m.session&&I.uses.session||Array.from(I.uses.dependencies).some(W=>c.some(oe=>oe(W)))||N&&I.uses.stuff){let W={};const oe=_&&k===b.length-1;if(oe){const ee=await $e(`${p.pathname}${p.pathname.endsWith("/")?"":"/"}__data.json${p.search}`,{headers:{"x-sveltekit-load":"true"}});if(ee.ok){const Pe=ee.headers.get("x-sveltekit-location");if(Pe)return{redirect:Pe,props:{},state:a};W=ee.status===204?{}:await ee.json()}else $=ee.status,y=new Error("Failed to load data")}if(y||(A=await H({module:x,url:p,params:w,props:W,stuff:S,routeId:u.id})),A&&(oe&&(A.uses.url=!0),A.loaded)){if(A.loaded.error&&($=A.loaded.status,y=A.loaded.error),A.loaded.redirect)return{redirect:A.loaded.redirect,props:{},state:a};A.loaded.stuff&&(N=!0)}}else A=I}catch(x){$=500,y=De(x)}if(y){for(;k--;)if(v[k]){let x,I,ae=k;for(;!(I=R[ae]);)ae-=1;try{if(x=await H({status:$,error:y,module:await v[k](),url:p,params:w,stuff:I.stuff,routeId:u.id}),(U=x==null?void 0:x.loaded)!=null&&U.error)continue;(g=x==null?void 0:x.loaded)!=null&&g.stuff&&(S={...S,...x.loaded.stuff}),R=R.slice(0,ae+1).concat(x);break e}catch{continue}}return await Z({status:$,error:y,url:p,routeId:u.id})}else(O=A==null?void 0:A.loaded)!=null&&O.stuff&&(S={...S,...A.loaded.stuff}),R.push(A)}return await he({url:p,params:w,stuff:S,branch:R,status:$,error:y,routeId:u.id})}async function Z({status:o,error:p,url:w,routeId:u}){var _,m;const h={},b=await H({module:await Nt,url:w,params:h,stuff:{},routeId:u}),v=await H({status:o,error:p,module:await Ot,url:w,params:h,stuff:b&&b.loaded&&b.loaded.stuff||{},routeId:u});return await he({url:w,params:h,stuff:{...(_=b==null?void 0:b.loaded)==null?void 0:_.stuff,...(m=v==null?void 0:v.loaded)==null?void 0:m.stuff},branch:[b,v],status:o,error:p,routeId:u})}function Oe(o){if(o.origin!==location.origin||!o.pathname.startsWith(t))return;const p=decodeURI(o.pathname.slice(t.length)||"/");for(const w of we){const u=w.exec(p);if(u)return{id:o.pathname+o.search,route:w,params:u,url:o}}}async function _e({url:o,scroll:p,keepfocus:w,redirect_chain:u,details:h,accepted:b,blocked:v}){const _=a.url;let m=!1;const R={from:_,to:o,cancel:()=>m=!0};if(r.before_navigate.forEach($=>$(R)),m){v();return}const S=vt(o.pathname,i),N=new URL(o.origin+S+o.search+o.hash);be(j),b(),d&&f.navigating.set({from:a.url,to:N}),await pe(N,u,!1,{scroll:p,keepfocus:w,details:h},()=>{const $={from:_,to:N};r.after_navigate.forEach(y=>y($)),f.navigating.set(null)})}function Q(o){return location.href=o.href,new Promise(()=>{})}return{after_navigate:o=>{ye(()=>(r.after_navigate.push(o),()=>{const p=r.after_navigate.indexOf(o);r.after_navigate.splice(p,1)}))},before_navigate:o=>{ye(()=>(r.before_navigate.push(o),()=>{const p=r.before_navigate.indexOf(o);r.before_navigate.splice(p,1)}))},disable_scroll_handling:()=>{(E||!d)&&(L=!1)},goto:(o,p={})=>Se(o,p,[]),invalidate:o=>{if(typeof o=="function")c.push(o);else{const{href:p}=new URL(o,location.href);c.push(w=>w===p)}return M||(M=Promise.resolve().then(async()=>{await pe(new URL(location.href),[],!0),M=null})),M},prefetch:async o=>{const p=new URL(o,ze(document));await Ue(p)},prefetch_routes:async o=>{const w=(o?we.filter(u=>o.some(h=>u.exec(h))):we).map(u=>Promise.all(u.a.map(h=>h())));await Promise.all(w)},_start_router:()=>{history.scrollRestoration="manual",addEventListener("beforeunload",u=>{let h=!1;const b={from:a.url,to:null,cancel:()=>h=!0};r.before_navigate.forEach(v=>v(b)),h?(u.preventDefault(),u.returnValue=""):history.scrollRestoration="auto"}),addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"){be(j);try{sessionStorage[We]=JSON.stringify(te)}catch{}}});const o=u=>{const h=qe(u);h&&h.href&&h.hasAttribute("sveltekit:prefetch")&&Ue(Je(h))};let p;const w=u=>{clearTimeout(p),p=setTimeout(()=>{var h;(h=u.target)==null||h.dispatchEvent(new CustomEvent("sveltekit:trigger_prefetch",{bubbles:!0}))},20)};addEventListener("touchstart",o),addEventListener("mousemove",w),addEventListener("sveltekit:trigger_prefetch",o),addEventListener("click",u=>{if(!F||u.button||u.which!==1||u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||u.defaultPrevented)return;const h=qe(u);if(!h||!h.href)return;const b=h instanceof SVGAElement,v=Je(h);if(!b&&v.origin==="null")return;const _=(h.getAttribute("rel")||"").split(/\s+/);if(h.hasAttribute("download")||_.includes("external")||h.hasAttribute("sveltekit:reload")||(b?h.target.baseVal:h.target))return;const[m,R]=v.href.split("#");if(R!==void 0&&m===location.href.split("#")[0]){ue=!0,be(j),f.page.set({...de,url:v}),f.page.notify();return}_e({url:v,scroll:h.hasAttribute("sveltekit:noscroll")?ve():null,keepfocus:!1,redirect_chain:[],details:{state:{},replaceState:v.href===location.href},accepted:()=>u.preventDefault(),blocked:()=>u.preventDefault()})}),addEventListener("popstate",u=>{if(u.state&&F){if(u.state[B]===j)return;_e({url:new URL(location.href),scroll:te[u.state[B]],keepfocus:!1,redirect_chain:[],details:null,accepted:()=>{j=u.state[B]},blocked:()=>{const h=j-u.state[B];history.go(h)}})}}),addEventListener("hashchange",()=>{ue&&(ue=!1,history.replaceState({...history.state,[B]:++j},"",location.href))})},_hydrate:async({status:o,error:p,nodes:w,params:u,routeId:h})=>{const b=new URL(location.href),v=[];let _={},m,R;try{for(let S=0;S<w.length;S+=1){const N=S===w.length-1;let $;if(N){const U=document.querySelector('script[sveltekit\\:data-type="props"]');U&&($=JSON.parse(U.textContent))}const y=await H({module:await le[w[S]](),url:b,params:u,stuff:_,status:N?o:void 0,error:N?p:void 0,props:$,routeId:h});if($&&(y.uses.dependencies.add(b.href),y.uses.url=!0),v.push(y),y&&y.loaded)if(y.loaded.error){if(p)throw y.loaded.error;R={status:y.loaded.status,error:y.loaded.error,url:b,routeId:h}}else y.loaded.stuff&&(_={..._,...y.loaded.stuff})}m=R?await Z(R):await he({url:b,params:u,stuff:_,branch:v,status:o,error:p,routeId:h})}catch(S){if(p)throw S;m=await Z({status:500,error:De(S),url:b,routeId:h})}m.redirect&&await Q(new URL(m.redirect,location.href)),Ae(m)}}}async function Tt({paths:s,target:e,session:t,route:i,spa:l,trailing_slash:c,hydrate:f}){const n=xt({target:e,session:t,base:s.base,trailing_slash:c});yt({client:n}),it(s),f&&await n._hydrate(f),i&&(l&&n.goto(location.href,{replaceState:!0}),n._start_router()),dispatchEvent(new CustomEvent("sveltekit:start"))}export{Tt as start};
|
frontend/.svelte-kit/output/client/_app/version.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":"1684956620534"}
|
frontend/.svelte-kit/output/prerendered/fallback.html
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8" />
|
5 |
+
<link rel="icon" href="/static/favicon.png" />
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
7 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
8 |
+
<meta http-equiv="content-security-policy" content="">
|
9 |
+
<link rel="modulepreload" href="/static/_app/immutable/start-a60c2789.js">
|
10 |
+
<link rel="modulepreload" href="/static/_app/immutable/chunks/index-bcf2726a.js">
|
11 |
+
<link rel="modulepreload" href="/static/_app/immutable/chunks/paths-d3bcbd10.js">
|
12 |
+
</head>
|
13 |
+
<body class="light:bg-white bg-[rgb(11,15,25)] light:text-black text-white">
|
14 |
+
|
15 |
+
<script type="module" data-sveltekit-hydrate="45h">
|
16 |
+
import { start } from "/static/_app/immutable/start-a60c2789.js";
|
17 |
+
start({
|
18 |
+
target: document.querySelector('[data-sveltekit-hydrate="45h"]').parentNode,
|
19 |
+
paths: {"base":"/static","assets":"/static"},
|
20 |
+
session: {},
|
21 |
+
route: true,
|
22 |
+
spa: true,
|
23 |
+
trailing_slash: "never",
|
24 |
+
hydrate: null
|
25 |
+
});
|
26 |
+
</script>
|
27 |
+
</body>
|
28 |
+
</html>
|
frontend/.svelte-kit/output/prerendered/pages/index.html
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8" />
|
5 |
+
<link rel="icon" href="/static/favicon.png" />
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
7 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
8 |
+
<meta http-equiv="content-security-policy" content="">
|
9 |
+
<link rel="stylesheet" href="/static/_app/immutable/assets/pages/__layout.svelte-dcfcba4b.css">
|
10 |
+
<link rel="stylesheet" href="/static/_app/immutable/assets/pages/index.svelte-65a37285.css">
|
11 |
+
<link rel="modulepreload" href="/static/_app/immutable/start-a60c2789.js">
|
12 |
+
<link rel="modulepreload" href="/static/_app/immutable/chunks/index-bcf2726a.js">
|
13 |
+
<link rel="modulepreload" href="/static/_app/immutable/chunks/paths-d3bcbd10.js">
|
14 |
+
<link rel="modulepreload" href="/static/_app/immutable/pages/__layout.svelte-0c386344.js">
|
15 |
+
<link rel="modulepreload" href="/static/_app/immutable/pages/index.svelte-6350336a.js">
|
16 |
+
</head>
|
17 |
+
<body class="light:bg-white bg-[rgb(11,15,25)] light:text-black text-white">
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
<div class="max-w-screen-md mx-auto px-3 py-5 relative z-0"><article class="prose dark:prose-invert"><h1>Drawing to Map</h1></article>
|
22 |
+
<form><h4 class="font-bold mt-6 mb-2 leading-6 my-3">Brush Type</h4>
|
23 |
+
<div class="colors svelte-1oy4poo" name="colors"><div class="snap-always snap-start"><input name="color" type="radio" id="color-0" value="0" class="svelte-1oy4poo">
|
24 |
+
<label for="color-0" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(219,14,154)"></rect></svg>
|
25 |
+
<span class="svelte-1oy4poo">building</span></label>
|
26 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-1" value="1" class="svelte-1oy4poo">
|
27 |
+
<label for="color-1" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(147,142,123)"></rect></svg>
|
28 |
+
<span class="svelte-1oy4poo">pervious surface</span></label>
|
29 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-2" value="2" class="svelte-1oy4poo">
|
30 |
+
<label for="color-2" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(248,12,0)"></rect></svg>
|
31 |
+
<span class="svelte-1oy4poo">impervious surface</span></label>
|
32 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-3" value="3" class="svelte-1oy4poo">
|
33 |
+
<label for="color-3" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(169,113,1)"></rect></svg>
|
34 |
+
<span class="svelte-1oy4poo">bare soil</span></label>
|
35 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-4" value="4" class="svelte-1oy4poo">
|
36 |
+
<label for="color-4" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(21,83,174)"></rect></svg>
|
37 |
+
<span class="svelte-1oy4poo">water</span></label>
|
38 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-5" value="5" class="svelte-1oy4poo">
|
39 |
+
<label for="color-5" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(25,74,38)"></rect></svg>
|
40 |
+
<span class="svelte-1oy4poo">coniferous</span></label>
|
41 |
+
</div><div class="snap-always snap-start"><input name="color" checked type="radio" id="color-6" value="6" class="svelte-1oy4poo">
|
42 |
+
<label for="color-6" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(70,228,131)"></rect></svg>
|
43 |
+
<span class="svelte-1oy4poo">deciduous</span></label>
|
44 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-7" value="7" class="svelte-1oy4poo">
|
45 |
+
<label for="color-7" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(243,166,13)"></rect></svg>
|
46 |
+
<span class="svelte-1oy4poo">brushwood</span></label>
|
47 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-8" value="8" class="svelte-1oy4poo">
|
48 |
+
<label for="color-8" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(102,0,130)"></rect></svg>
|
49 |
+
<span class="svelte-1oy4poo">vineyard</span></label>
|
50 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-9" value="9" class="svelte-1oy4poo">
|
51 |
+
<label for="color-9" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(85,255,0)"></rect></svg>
|
52 |
+
<span class="svelte-1oy4poo">herbaceous vegetation</span></label>
|
53 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-10" value="10" class="svelte-1oy4poo">
|
54 |
+
<label for="color-10" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(255,243,13)"></rect></svg>
|
55 |
+
<span class="svelte-1oy4poo">agricultural land</span></label>
|
56 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-11" value="11" class="svelte-1oy4poo">
|
57 |
+
<label for="color-11" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(228,223,124)"></rect></svg>
|
58 |
+
<span class="svelte-1oy4poo">plowed land</span></label>
|
59 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-12" value="12" class="svelte-1oy4poo">
|
60 |
+
<label for="color-12" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(61,230,235)"></rect></svg>
|
61 |
+
<span class="svelte-1oy4poo">swimming pool</span></label>
|
62 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-13" value="13" class="svelte-1oy4poo">
|
63 |
+
<label for="color-13" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(255,255,255)"></rect></svg>
|
64 |
+
<span class="svelte-1oy4poo">snow</span></label>
|
65 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-14" value="14" class="svelte-1oy4poo">
|
66 |
+
<label for="color-14" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(138,179,160)"></rect></svg>
|
67 |
+
<span class="svelte-1oy4poo">clear cut</span></label>
|
68 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-15" value="15" class="svelte-1oy4poo">
|
69 |
+
<label for="color-15" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(107,113,79)"></rect></svg>
|
70 |
+
<span class="svelte-1oy4poo">mixed</span></label>
|
71 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-16" value="16" class="svelte-1oy4poo">
|
72 |
+
<label for="color-16" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(197,220,66)"></rect></svg>
|
73 |
+
<span class="svelte-1oy4poo">ligneous</span></label>
|
74 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-17" value="17" class="svelte-1oy4poo">
|
75 |
+
<label for="color-17" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(153,153,255)"></rect></svg>
|
76 |
+
<span class="svelte-1oy4poo">greenhouse</span></label>
|
77 |
+
</div><div class="snap-always snap-start"><input name="color" type="radio" id="color-18" value="18" class="svelte-1oy4poo">
|
78 |
+
<label for="color-18" class="svelte-1oy4poo"><svg width="20" height="20" viewBox="0 0 20 20" class="svelte-1oy4poo"><rect x="0" y="0" width="20" height="20" fill="rgb(0,0,0)"></rect></svg>
|
79 |
+
<span class="svelte-1oy4poo">other</span></label>
|
80 |
+
</div></div>
|
81 |
+
<h4 class="font-bold mt-6 mb-2 my-6 leading-6">Brush Size</h4>
|
82 |
+
<div class="brush svelte-1oy4poo"><input value="10" min="1" max="150" step="1" name="brush" type="range">
|
83 |
+
<label class="pl-2 svelte-1oy4poo" for="brush">40</label></div>
|
84 |
+
</form>
|
85 |
+
<div class="drawings py-3 -mx-3 svelte-237ry5"><div><div class="relative overflow-clip"><canvas class="canvas svelte-pr47cz" width="512" height="512"></canvas>
|
86 |
+
<canvas class="brush svelte-pr47cz" width="10" height="10"></canvas>
|
87 |
+
<span class="label svelte-pr47cz">deciduous</span>
|
88 |
+
<button class="absolute bottom-0 left-0 p-3" disabled><svg xmlns="http://www.w3.org/2000/svg" width="20" viewBox="0 0 512 512" class=""><path fill="white" stroke="black" stroke-width="30" d="M480 256c0 123.4-100.5 223.9-223.9 223.9c-48.84 0-95.17-15.58-134.2-44.86c-14.12-10.59-16.97-30.66-6.375-44.81c10.59-14.12 30.62-16.94 44.81-6.375c27.84 20.91 61 31.94 95.88 31.94C344.3 415.8 416 344.1 416 256s-71.69-159.8-159.8-159.8c-37.46 0-73.09 13.49-101.3 36.64l45.12 45.14c17.01 17.02 4.955 46.1-19.1 46.1H35.17C24.58 224.1 16 215.5 16 204.9V59.04c0-24.04 29.07-36.08 46.07-19.07l47.6 47.63C149.9 52.71 201.5 32.11 256.1 32.11C379.5 32.11 480 132.6 480 256z"></path></svg></button></div>
|
89 |
+
</div>
|
90 |
+
<div class="relative overflow-clip flex flex-col justify-center items-center w-full h-full">
|
91 |
+
</div>
|
92 |
+
|
93 |
+
</div>
|
94 |
+
|
95 |
+
<button class="svelte-237ry5">Generate Map
|
96 |
+
</button>
|
97 |
+
|
98 |
+
<button disabled class="svelte-237ry5">Save Result
|
99 |
+
</button>
|
100 |
+
|
101 |
+
<div><h4 class="font-bold mt-6 mb-2 my-6 leading-6">Select a Template</h4>
|
102 |
+
<form class="svelte-1gwcbp"><div class="samples svelte-1gwcbp"><div class="snap-always snap-start"><input type="radio" name="samples" id="sample-0" value="0" class="svelte-1gwcbp">
|
103 |
+
<label for="sample-0" class="svelte-1gwcbp"><img src="/static/samples/example0.png" alt="/samples/example0.png" class="svelte-1gwcbp"></label>
|
104 |
+
</div><div class="snap-always snap-start"><input type="radio" name="samples" id="sample-1" value="1" class="svelte-1gwcbp">
|
105 |
+
<label for="sample-1" class="svelte-1gwcbp"><img src="/static/samples/example1.png" alt="/samples/example1.png" class="svelte-1gwcbp"></label>
|
106 |
+
</div><div class="snap-always snap-start"><input type="radio" name="samples" id="sample-2" value="2" class="svelte-1gwcbp">
|
107 |
+
<label for="sample-2" class="svelte-1gwcbp"><img src="/static/samples/example2.png" alt="/samples/example2.png" class="svelte-1gwcbp"></label>
|
108 |
+
</div><div class="snap-always snap-start"><input type="radio" name="samples" id="sample-3" value="3" class="svelte-1gwcbp">
|
109 |
+
<label for="sample-3" class="svelte-1gwcbp"><img src="/static/samples/example3.png" alt="/samples/example3.png" class="svelte-1gwcbp"></label>
|
110 |
+
</div><div class="snap-always snap-start"><input type="radio" name="samples" id="sample-4" value="4" class="svelte-1gwcbp">
|
111 |
+
<label for="sample-4" class="svelte-1gwcbp"><img src="/static/samples/example4.png" alt="/samples/example4.png" class="svelte-1gwcbp"></label>
|
112 |
+
</div><div class="snap-always snap-start"><input type="radio" name="samples" id="sample-5" value="5" class="svelte-1gwcbp">
|
113 |
+
<label for="sample-5" class="svelte-1gwcbp"><img src="/static/samples/example5.png" alt="/samples/example5.png" class="svelte-1gwcbp"></label>
|
114 |
+
</div></div></form>
|
115 |
+
</div>
|
116 |
+
|
117 |
+
<form><h4 class="font-bold mt-6 mb-2 my-6 leading-6">Prompt</h4>
|
118 |
+
<input name="prompt" placeholder="Aerial view of ..., France." style="width: 500px;" class="svelte-uoay71" value="Aerial view, France. High resolution image, 4K, ultra detailed">
|
119 |
+
<select name="presets" class="svelte-uoay71"><option disabled selected value="preset">preset</option><option value="Aerial view, France. High resolution image, 4K, ultra detailed">Realistic</option>`<option value="Aerial view, France. Colorful lego bricks">Lego brick</option>`<option value="Aerial view, France. Black and white paper pencil drawing">Pencil</option>`<option value="Aerial view, France. Oil on canvas painting">Painting</option>`</select>
|
120 |
+
|
121 |
+
<h4 class="font-bold mt-6 mb-2 my-6 leading-6">Random Seed</h4>
|
122 |
+
<input type="Number" name="seed" placeholder="Integer Seed" class="svelte-uoay71" value="58722304">
|
123 |
+
<button class="svelte-uoay71">Random
|
124 |
+
</button>
|
125 |
+
<h4 class="font-bold mt-6 mb-2 my-6 leading-6">Sample Steps</h4>
|
126 |
+
<div class="flex"><input type="range" name="steps" min="10" max="30" step="1" class="svelte-uoay71" value="20">
|
127 |
+
<label class="pl-2 svelte-uoay71" for="steps">20</label></div>
|
128 |
+
</form>
|
129 |
+
</div>
|
130 |
+
|
131 |
+
|
132 |
+
<script type="module" data-sveltekit-hydrate="r7bv48">
|
133 |
+
import { start } from "/static/_app/immutable/start-a60c2789.js";
|
134 |
+
start({
|
135 |
+
target: document.querySelector('[data-sveltekit-hydrate="r7bv48"]').parentNode,
|
136 |
+
paths: {"base":"/static","assets":"/static"},
|
137 |
+
session: {},
|
138 |
+
route: true,
|
139 |
+
spa: false,
|
140 |
+
trailing_slash: "never",
|
141 |
+
hydrate: {
|
142 |
+
status: 200,
|
143 |
+
error: null,
|
144 |
+
nodes: [0, 2],
|
145 |
+
params: {},
|
146 |
+
routeId: ""
|
147 |
+
}
|
148 |
+
});
|
149 |
+
</script>
|
150 |
+
</body>
|
151 |
+
</html>
|
frontend/.svelte-kit/output/server/chunks/hooks-1c45ba0b.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
|
frontend/.svelte-kit/output/server/chunks/index-445fd704.js
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function noop() {
|
2 |
+
}
|
3 |
+
function run(fn) {
|
4 |
+
return fn();
|
5 |
+
}
|
6 |
+
function blank_object() {
|
7 |
+
return /* @__PURE__ */ Object.create(null);
|
8 |
+
}
|
9 |
+
function run_all(fns) {
|
10 |
+
fns.forEach(run);
|
11 |
+
}
|
12 |
+
function safe_not_equal(a, b) {
|
13 |
+
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
|
14 |
+
}
|
15 |
+
function subscribe(store, ...callbacks) {
|
16 |
+
if (store == null) {
|
17 |
+
return noop;
|
18 |
+
}
|
19 |
+
const unsub = store.subscribe(...callbacks);
|
20 |
+
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
|
21 |
+
}
|
22 |
+
function set_store_value(store, ret, value) {
|
23 |
+
store.set(value);
|
24 |
+
return ret;
|
25 |
+
}
|
26 |
+
let current_component;
|
27 |
+
function set_current_component(component) {
|
28 |
+
current_component = component;
|
29 |
+
}
|
30 |
+
function get_current_component() {
|
31 |
+
if (!current_component)
|
32 |
+
throw new Error("Function called outside component initialization");
|
33 |
+
return current_component;
|
34 |
+
}
|
35 |
+
function setContext(key, context) {
|
36 |
+
get_current_component().$$.context.set(key, context);
|
37 |
+
return context;
|
38 |
+
}
|
39 |
+
Promise.resolve();
|
40 |
+
const escaped = {
|
41 |
+
'"': """,
|
42 |
+
"'": "'",
|
43 |
+
"&": "&",
|
44 |
+
"<": "<",
|
45 |
+
">": ">"
|
46 |
+
};
|
47 |
+
function escape(html) {
|
48 |
+
return String(html).replace(/["'&<>]/g, (match) => escaped[match]);
|
49 |
+
}
|
50 |
+
function escape_attribute_value(value) {
|
51 |
+
return typeof value === "string" ? escape(value) : value;
|
52 |
+
}
|
53 |
+
function each(items, fn) {
|
54 |
+
let str = "";
|
55 |
+
for (let i = 0; i < items.length; i += 1) {
|
56 |
+
str += fn(items[i], i);
|
57 |
+
}
|
58 |
+
return str;
|
59 |
+
}
|
60 |
+
const missing_component = {
|
61 |
+
$$render: () => ""
|
62 |
+
};
|
63 |
+
function validate_component(component, name) {
|
64 |
+
if (!component || !component.$$render) {
|
65 |
+
if (name === "svelte:component")
|
66 |
+
name += " this={...}";
|
67 |
+
throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);
|
68 |
+
}
|
69 |
+
return component;
|
70 |
+
}
|
71 |
+
let on_destroy;
|
72 |
+
function create_ssr_component(fn) {
|
73 |
+
function $$render(result, props, bindings, slots, context) {
|
74 |
+
const parent_component = current_component;
|
75 |
+
const $$ = {
|
76 |
+
on_destroy,
|
77 |
+
context: new Map(context || (parent_component ? parent_component.$$.context : [])),
|
78 |
+
on_mount: [],
|
79 |
+
before_update: [],
|
80 |
+
after_update: [],
|
81 |
+
callbacks: blank_object()
|
82 |
+
};
|
83 |
+
set_current_component({ $$ });
|
84 |
+
const html = fn(result, props, bindings, slots);
|
85 |
+
set_current_component(parent_component);
|
86 |
+
return html;
|
87 |
+
}
|
88 |
+
return {
|
89 |
+
render: (props = {}, { $$slots = {}, context = /* @__PURE__ */ new Map() } = {}) => {
|
90 |
+
on_destroy = [];
|
91 |
+
const result = { title: "", head: "", css: /* @__PURE__ */ new Set() };
|
92 |
+
const html = $$render(result, props, {}, $$slots, context);
|
93 |
+
run_all(on_destroy);
|
94 |
+
return {
|
95 |
+
html,
|
96 |
+
css: {
|
97 |
+
code: Array.from(result.css).map((css) => css.code).join("\n"),
|
98 |
+
map: null
|
99 |
+
},
|
100 |
+
head: result.title + result.head
|
101 |
+
};
|
102 |
+
},
|
103 |
+
$$render
|
104 |
+
};
|
105 |
+
}
|
106 |
+
function add_attribute(name, value, boolean) {
|
107 |
+
if (value == null || boolean && !value)
|
108 |
+
return "";
|
109 |
+
const assignment = boolean && value === true ? "" : `="${escape_attribute_value(value.toString())}"`;
|
110 |
+
return ` ${name}${assignment}`;
|
111 |
+
}
|
112 |
+
export { safe_not_equal as a, subscribe as b, create_ssr_component as c, each as d, escape as e, add_attribute as f, set_store_value as g, missing_component as m, noop as n, setContext as s, validate_component as v };
|
frontend/.svelte-kit/output/server/chunks/paths-396f020f.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
let base = "";
|
2 |
+
let assets = "";
|
3 |
+
function set_paths(paths) {
|
4 |
+
base = paths.base;
|
5 |
+
assets = paths.assets || base;
|
6 |
+
}
|
7 |
+
export { assets as a, base as b, set_paths as s };
|
frontend/.svelte-kit/output/server/entries/fallbacks/error.svelte.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { c as create_ssr_component, e as escape } from "../../chunks/index-445fd704.js";
|
2 |
+
function load({ error, status }) {
|
3 |
+
return { props: { error, status } };
|
4 |
+
}
|
5 |
+
const Error = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
6 |
+
let { status } = $$props;
|
7 |
+
let { error } = $$props;
|
8 |
+
if ($$props.status === void 0 && $$bindings.status && status !== void 0)
|
9 |
+
$$bindings.status(status);
|
10 |
+
if ($$props.error === void 0 && $$bindings.error && error !== void 0)
|
11 |
+
$$bindings.error(error);
|
12 |
+
return `<h1>${escape(status)}</h1>
|
13 |
+
|
14 |
+
<pre>${escape(error.message)}</pre>
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
${error.frame ? `<pre>${escape(error.frame)}</pre>` : ``}
|
19 |
+
${error.stack ? `<pre>${escape(error.stack)}</pre>` : ``}`;
|
20 |
+
});
|
21 |
+
export { Error as default, load };
|
frontend/.svelte-kit/output/server/entries/pages/__layout.svelte.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { c as create_ssr_component } from "../../chunks/index-445fd704.js";
|
2 |
+
var app = /* @__PURE__ */ (() => '@import url(\'https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;500;600;700;800&display=swap\');\n/*\n! tailwindcss v3.1.4 | MIT License | https://tailwindcss.com\n*/\n/*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n::before,\n::after {\n --tw-content: \'\';\n}\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user\'s configured `sans` font-family by default.\n*/\nhtml {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */\n}\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n/*\nRemove the default font size and weight for headings.\n*/\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\na {\n color: inherit;\n text-decoration: inherit;\n}\n/*\nAdd the correct font weight in Edge and Safari.\n*/\nb,\nstrong {\n font-weight: bolder;\n}\n/*\n1. Use the user\'s configured `mono` font family by default.\n2. Correct the odd `em` font sizing in all browsers.\n*/\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n/*\nAdd the correct font size in all browsers.\n*/\nsmall {\n font-size: 80%;\n}\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\nsub {\n bottom: -0.25em;\n}\nsup {\n top: -0.5em;\n}\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\nbutton,\nselect {\n text-transform: none;\n}\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\nbutton,\n[type=\'button\'],\n[type=\'reset\'],\n[type=\'submit\'] {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n:-moz-focusring {\n outline: auto;\n}\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n:-moz-ui-invalid {\n box-shadow: none;\n}\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\nprogress {\n vertical-align: baseline;\n}\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n[type=\'search\'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n/*\nAdd the correct display in Chrome and Safari.\n*/\nsummary {\n display: list-item;\n}\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\nfieldset {\n margin: 0;\n padding: 0;\n}\nlegend {\n padding: 0;\n}\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n/*\nPrevent resizing textareas horizontally by default.\n*/\ntextarea {\n resize: vertical;\n}\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user\'s configured gray 400 color.\n*/\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n/*\nSet the default cursor for buttons.\n*/\nbutton,\n[role="button"] {\n cursor: pointer;\n}\n/*\nMake sure disabled buttons don\'t get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\nhtml {\n font-family: \'Open Sans\', sans-serif;\n }\n*, ::before, ::after{\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n::-webkit-backdrop{\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n::backdrop{\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n.prose{\n color: var(--tw-prose-body);\n max-width: 65ch;\n}\n.prose :where([class~="lead"]):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-lead);\n font-size: 1.25em;\n line-height: 1.6;\n margin-top: 1.2em;\n margin-bottom: 1.2em;\n}\n.prose :where(a):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-links);\n text-decoration: underline;\n font-weight: 500;\n}\n.prose :where(strong):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-bold);\n font-weight: 600;\n}\n.prose :where(ol):not(:where([class~="not-prose"] *)){\n list-style-type: decimal;\n padding-left: 1.625em;\n}\n.prose :where(ol[type="A"]):not(:where([class~="not-prose"] *)){\n list-style-type: upper-alpha;\n}\n.prose :where(ol[type="a"]):not(:where([class~="not-prose"] *)){\n list-style-type: lower-alpha;\n}\n.prose :where(ol[type="A" s]):not(:where([class~="not-prose"] *)){\n list-style-type: upper-alpha;\n}\n.prose :where(ol[type="a" s]):not(:where([class~="not-prose"] *)){\n list-style-type: lower-alpha;\n}\n.prose :where(ol[type="I"]):not(:where([class~="not-prose"] *)){\n list-style-type: upper-roman;\n}\n.prose :where(ol[type="i"]):not(:where([class~="not-prose"] *)){\n list-style-type: lower-roman;\n}\n.prose :where(ol[type="I" s]):not(:where([class~="not-prose"] *)){\n list-style-type: upper-roman;\n}\n.prose :where(ol[type="i" s]):not(:where([class~="not-prose"] *)){\n list-style-type: lower-roman;\n}\n.prose :where(ol[type="1"]):not(:where([class~="not-prose"] *)){\n list-style-type: decimal;\n}\n.prose :where(ul):not(:where([class~="not-prose"] *)){\n list-style-type: disc;\n padding-left: 1.625em;\n}\n.prose :where(ol > li):not(:where([class~="not-prose"] *))::marker{\n font-weight: 400;\n color: var(--tw-prose-counters);\n}\n.prose :where(ul > li):not(:where([class~="not-prose"] *))::marker{\n color: var(--tw-prose-bullets);\n}\n.prose :where(hr):not(:where([class~="not-prose"] *)){\n border-color: var(--tw-prose-hr);\n border-top-width: 1px;\n margin-top: 3em;\n margin-bottom: 3em;\n}\n.prose :where(blockquote):not(:where([class~="not-prose"] *)){\n font-weight: 500;\n font-style: italic;\n color: var(--tw-prose-quotes);\n border-left-width: 0.25rem;\n border-left-color: var(--tw-prose-quote-borders);\n quotes: "\\201C""\\201D""\\2018""\\2019";\n margin-top: 1.6em;\n margin-bottom: 1.6em;\n padding-left: 1em;\n}\n.prose :where(h1):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-headings);\n font-weight: 800;\n font-size: 2.25em;\n margin-top: 0;\n margin-bottom: 0.8888889em;\n line-height: 1.1111111;\n}\n.prose :where(h1 strong):not(:where([class~="not-prose"] *)){\n font-weight: 900;\n}\n.prose :where(h2):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-headings);\n font-weight: 700;\n font-size: 1.5em;\n margin-top: 2em;\n margin-bottom: 1em;\n line-height: 1.3333333;\n}\n.prose :where(h2 strong):not(:where([class~="not-prose"] *)){\n font-weight: 800;\n}\n.prose :where(h3):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-headings);\n font-weight: 600;\n font-size: 1.25em;\n margin-top: 1.6em;\n margin-bottom: 0.6em;\n line-height: 1.6;\n}\n.prose :where(h3 strong):not(:where([class~="not-prose"] *)){\n font-weight: 700;\n}\n.prose :where(h4):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-headings);\n font-weight: 600;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n line-height: 1.5;\n}\n.prose :where(h4 strong):not(:where([class~="not-prose"] *)){\n font-weight: 700;\n}\n.prose :where(figure > *):not(:where([class~="not-prose"] *)){\n margin-top: 0;\n margin-bottom: 0;\n}\n.prose :where(figcaption):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-captions);\n font-size: 0.875em;\n line-height: 1.4285714;\n margin-top: 0.8571429em;\n}\n.prose :where(a code):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-links);\n}\n.prose :where(pre code):not(:where([class~="not-prose"] *))::before{\n content: none;\n}\n.prose :where(pre code):not(:where([class~="not-prose"] *))::after{\n content: none;\n}\n.prose :where(table):not(:where([class~="not-prose"] *)){\n width: 100%;\n table-layout: auto;\n text-align: left;\n margin-top: 2em;\n margin-bottom: 2em;\n font-size: 0.875em;\n line-height: 1.7142857;\n}\n.prose :where(thead):not(:where([class~="not-prose"] *)){\n border-bottom-width: 1px;\n border-bottom-color: var(--tw-prose-th-borders);\n}\n.prose :where(thead th):not(:where([class~="not-prose"] *)){\n color: var(--tw-prose-headings);\n font-weight: 600;\n vertical-align: bottom;\n padding-right: 0.5714286em;\n padding-bottom: 0.5714286em;\n padding-left: 0.5714286em;\n}\n.prose :where(tbody tr):not(:where([class~="not-prose"] *)){\n border-bottom-width: 1px;\n border-bottom-color: var(--tw-prose-td-borders);\n}\n.prose :where(tbody tr:last-child):not(:where([class~="not-prose"] *)){\n border-bottom-width: 0;\n}\n.prose :where(tbody td):not(:where([class~="not-prose"] *)){\n vertical-align: baseline;\n padding-top: 0.5714286em;\n padding-right: 0.5714286em;\n padding-bottom: 0.5714286em;\n padding-left: 0.5714286em;\n}\n.prose{\n --tw-prose-body: #374151;\n --tw-prose-headings: #111827;\n --tw-prose-lead: #4b5563;\n --tw-prose-links: #111827;\n --tw-prose-bold: #111827;\n --tw-prose-counters: #6b7280;\n --tw-prose-bullets: #d1d5db;\n --tw-prose-hr: #e5e7eb;\n --tw-prose-quotes: #111827;\n --tw-prose-quote-borders: #e5e7eb;\n --tw-prose-captions: #6b7280;\n --tw-prose-code: #111827;\n --tw-prose-pre-code: #e5e7eb;\n --tw-prose-pre-bg: #1f2937;\n --tw-prose-th-borders: #d1d5db;\n --tw-prose-td-borders: #e5e7eb;\n --tw-prose-invert-body: #d1d5db;\n --tw-prose-invert-headings: #fff;\n --tw-prose-invert-lead: #9ca3af;\n --tw-prose-invert-links: #fff;\n --tw-prose-invert-bold: #fff;\n --tw-prose-invert-counters: #9ca3af;\n --tw-prose-invert-bullets: #4b5563;\n --tw-prose-invert-hr: #374151;\n --tw-prose-invert-quotes: #f3f4f6;\n --tw-prose-invert-quote-borders: #374151;\n --tw-prose-invert-captions: #9ca3af;\n --tw-prose-invert-code: #fff;\n --tw-prose-invert-pre-code: #d1d5db;\n --tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);\n --tw-prose-invert-th-borders: #4b5563;\n --tw-prose-invert-td-borders: #374151;\n font-size: 1rem;\n line-height: 1.75;\n}\n.prose :where(p):not(:where([class~="not-prose"] *)){\n margin-top: 1.25em;\n margin-bottom: 1.25em;\n}\n.prose :where(img):not(:where([class~="not-prose"] *)){\n margin-top: 2em;\n margin-bottom: 2em;\n}\n.prose :where(video):not(:where([class~="not-prose"] *)){\n margin-top: 2em;\n margin-bottom: 2em;\n}\n.prose :where(figure):not(:where([class~="not-prose"] *)){\n margin-top: 2em;\n margin-bottom: 2em;\n}\n.prose :where(h2 code):not(:where([class~="not-prose"] *)){\n font-size: 0.875em;\n}\n.prose :where(h3 code):not(:where([class~="not-prose"] *)){\n font-size: 0.9em;\n}\n.prose :where(li):not(:where([class~="not-prose"] *)){\n margin-top: 0.5em;\n margin-bottom: 0.5em;\n}\n.prose :where(ol > li):not(:where([class~="not-prose"] *)){\n padding-left: 0.375em;\n}\n.prose :where(ul > li):not(:where([class~="not-prose"] *)){\n padding-left: 0.375em;\n}\n.prose > :where(ul > li p):not(:where([class~="not-prose"] *)){\n margin-top: 0.75em;\n margin-bottom: 0.75em;\n}\n.prose > :where(ul > li > *:first-child):not(:where([class~="not-prose"] *)){\n margin-top: 1.25em;\n}\n.prose > :where(ul > li > *:last-child):not(:where([class~="not-prose"] *)){\n margin-bottom: 1.25em;\n}\n.prose > :where(ol > li > *:first-child):not(:where([class~="not-prose"] *)){\n margin-top: 1.25em;\n}\n.prose > :where(ol > li > *:last-child):not(:where([class~="not-prose"] *)){\n margin-bottom: 1.25em;\n}\n.prose :where(ul ul, ul ol, ol ul, ol ol):not(:where([class~="not-prose"] *)){\n margin-top: 0.75em;\n margin-bottom: 0.75em;\n}\n.prose :where(hr + *):not(:where([class~="not-prose"] *)){\n margin-top: 0;\n}\n.prose :where(h2 + *):not(:where([class~="not-prose"] *)){\n margin-top: 0;\n}\n.prose :where(h3 + *):not(:where([class~="not-prose"] *)){\n margin-top: 0;\n}\n.prose :where(h4 + *):not(:where([class~="not-prose"] *)){\n margin-top: 0;\n}\n.prose :where(thead th:first-child):not(:where([class~="not-prose"] *)){\n padding-left: 0;\n}\n.prose :where(thead th:last-child):not(:where([class~="not-prose"] *)){\n padding-right: 0;\n}\n.prose :where(tbody td:first-child):not(:where([class~="not-prose"] *)){\n padding-left: 0;\n}\n.prose :where(tbody td:last-child):not(:where([class~="not-prose"] *)){\n padding-right: 0;\n}\n.prose > :where(:first-child):not(:where([class~="not-prose"] *)){\n margin-top: 0;\n}\n.prose > :where(:last-child):not(:where([class~="not-prose"] *)){\n margin-bottom: 0;\n}\n.pointer-events-none{\n pointer-events: none;\n}\n.absolute{\n position: absolute;\n}\n.relative{\n position: relative;\n}\n.bottom-0{\n bottom: 0px;\n}\n.left-0{\n left: 0px;\n}\n.top-0{\n top: 0px;\n}\n.right-0{\n right: 0px;\n}\n.z-0{\n z-index: 0;\n}\n.z-10{\n z-index: 10;\n}\n.z-20{\n z-index: 20;\n}\n.my-3{\n margin-top: 0.75rem;\n margin-bottom: 0.75rem;\n}\n.my-6{\n margin-top: 1.5rem;\n margin-bottom: 1.5rem;\n}\n.mx-auto{\n margin-left: auto;\n margin-right: auto;\n}\n.-mx-3{\n margin-left: -0.75rem;\n margin-right: -0.75rem;\n}\n.mt-6{\n margin-top: 1.5rem;\n}\n.mb-2{\n margin-bottom: 0.5rem;\n}\n.box-border{\n box-sizing: border-box;\n}\n.block{\n display: block;\n}\n.flex{\n display: flex;\n}\n.grid{\n display: grid;\n}\n.hidden{\n display: none;\n}\n.aspect-\\[512\\/512\\]{\n aspect-ratio: 512/512;\n}\n.h-0{\n height: 0px;\n}\n.h-full{\n height: 100%;\n}\n.max-h-\\[9rem\\]{\n max-height: 9rem;\n}\n.max-h-24{\n max-height: 6rem;\n}\n.w-0{\n width: 0px;\n}\n.w-full{\n width: 100%;\n}\n.max-w-full{\n max-width: 100%;\n}\n.max-w-\\[3rem\\]{\n max-width: 3rem;\n}\n.max-w-screen-md{\n max-width: 768px;\n}\n.-translate-x-1\\/2{\n --tw-translate-x: -50%;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n@-webkit-keyframes spin{\n to{\n transform: rotate(360deg);\n }\n}\n@keyframes spin{\n to{\n transform: rotate(360deg);\n }\n}\n.animate-spin{\n -webkit-animation: spin 1s linear infinite;\n animation: spin 1s linear infinite;\n}\n.cursor-pointer{\n cursor: pointer;\n}\n.snap-x{\n scroll-snap-type: x var(--tw-scroll-snap-strictness);\n}\n.snap-y{\n scroll-snap-type: y var(--tw-scroll-snap-strictness);\n}\n.snap-mandatory{\n --tw-scroll-snap-strictness: mandatory;\n}\n.snap-start{\n scroll-snap-align: start;\n}\n.snap-always{\n scroll-snap-stop: always;\n}\n.grid-cols-2{\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.grid-cols-\\[2fr_1\\.5fr\\]{\n grid-template-columns: 2fr 1.5fr;\n}\n.flex-col{\n flex-direction: column;\n}\n.flex-nowrap{\n flex-wrap: nowrap;\n}\n.items-center{\n align-items: center;\n}\n.justify-center{\n justify-content: center;\n}\n.gap-2{\n gap: 0.5rem;\n}\n.gap-1{\n gap: 0.25rem;\n}\n.overflow-hidden{\n overflow: hidden;\n}\n.overflow-clip{\n overflow: clip;\n}\n.overflow-scroll{\n overflow: scroll;\n}\n.overflow-x-scroll{\n overflow-x: scroll;\n}\n.whitespace-nowrap{\n white-space: nowrap;\n}\n.rounded-lg{\n border-radius: 0.5rem;\n}\n.border{\n border-width: 1px;\n}\n.border-gray-500{\n --tw-border-opacity: 1;\n border-color: rgb(107 114 128 / var(--tw-border-opacity));\n}\n.border-gray-300{\n --tw-border-opacity: 1;\n border-color: rgb(209 213 219 / var(--tw-border-opacity));\n}\n.bg-\\[rgb\\(11\\2c 15\\2c 25\\)\\]{\n --tw-bg-opacity: 1;\n background-color: rgb(11 15 25 / var(--tw-bg-opacity));\n}\n.bg-gray-50{\n --tw-bg-opacity: 1;\n background-color: rgb(249 250 251 / var(--tw-bg-opacity));\n}\n.p-3{\n padding: 0.75rem;\n}\n.p-1{\n padding: 0.25rem;\n}\n.px-2{\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-3{\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n.py-5{\n padding-top: 1.25rem;\n padding-bottom: 1.25rem;\n}\n.py-3{\n padding-top: 0.75rem;\n padding-bottom: 0.75rem;\n}\n.pl-2{\n padding-left: 0.5rem;\n}\n.text-base{\n font-size: 1rem;\n line-height: 1.5rem;\n}\n.text-sm{\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xs{\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.font-bold{\n font-weight: 700;\n}\n.leading-6{\n line-height: 1.5rem;\n}\n.text-white{\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n.text-gray-900{\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity));\n}\n.opacity-0{\n opacity: 0;\n}\n.opacity-30{\n opacity: 0.3;\n}\n.outline{\n outline-style: solid;\n}\n.outline-2{\n outline-width: 2px;\n}\n.outline-offset-\\[-2px\\]{\n outline-offset: -2px;\n}\n.transition-all{\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.duration-200{\n transition-duration: 200ms;\n}\n.ease-in-out{\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n}\n.hover\\:outline:hover{\n outline-style: solid;\n}\n.focus\\:border-blue-500:focus{\n --tw-border-opacity: 1;\n border-color: rgb(59 130 246 / var(--tw-border-opacity));\n}\n.focus\\:ring-blue-500:focus{\n --tw-ring-opacity: 1;\n --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity));\n}\n.disabled\\:opacity-50:disabled{\n opacity: 0.5;\n}\n@media (prefers-color-scheme: dark){\n .dark\\:prose-invert{\n --tw-prose-body: var(--tw-prose-invert-body);\n --tw-prose-headings: var(--tw-prose-invert-headings);\n --tw-prose-lead: var(--tw-prose-invert-lead);\n --tw-prose-links: var(--tw-prose-invert-links);\n --tw-prose-bold: var(--tw-prose-invert-bold);\n --tw-prose-counters: var(--tw-prose-invert-counters);\n --tw-prose-bullets: var(--tw-prose-invert-bullets);\n --tw-prose-hr: var(--tw-prose-invert-hr);\n --tw-prose-quotes: var(--tw-prose-invert-quotes);\n --tw-prose-quote-borders: var(--tw-prose-invert-quote-borders);\n --tw-prose-captions: var(--tw-prose-invert-captions);\n --tw-prose-code: var(--tw-prose-invert-code);\n --tw-prose-pre-code: var(--tw-prose-invert-pre-code);\n --tw-prose-pre-bg: var(--tw-prose-invert-pre-bg);\n --tw-prose-th-borders: var(--tw-prose-invert-th-borders);\n --tw-prose-td-borders: var(--tw-prose-invert-td-borders);\n }\n .dark\\:border-gray-300{\n --tw-border-opacity: 1;\n border-color: rgb(209 213 219 / var(--tw-border-opacity));\n }\n .dark\\:border-gray-600{\n --tw-border-opacity: 1;\n border-color: rgb(75 85 99 / var(--tw-border-opacity));\n }\n .dark\\:bg-gray-700{\n --tw-bg-opacity: 1;\n background-color: rgb(55 65 81 / var(--tw-bg-opacity));\n }\n .dark\\:text-white{\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n }\n .dark\\:placeholder-gray-400::-moz-placeholder{\n --tw-placeholder-opacity: 1;\n color: rgb(156 163 175 / var(--tw-placeholder-opacity));\n }\n .dark\\:placeholder-gray-400::placeholder{\n --tw-placeholder-opacity: 1;\n color: rgb(156 163 175 / var(--tw-placeholder-opacity));\n }\n .dark\\:focus\\:ring-blue-500:focus{\n --tw-ring-opacity: 1;\n --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity));\n }\n}\n@media (min-width: 530px){\n .sm\\:max-h-\\[none\\]{\n max-height: none;\n }\n .sm\\:grid-cols-3{\n grid-template-columns: repeat(3, minmax(0, 1fr));\n }\n .sm\\:grid-cols-2{\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .sm\\:flex-row{\n flex-direction: row;\n }\n}\n')();
|
3 |
+
const _layout = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
4 |
+
return `${slots.default ? slots.default({}) : ``}`;
|
5 |
+
});
|
6 |
+
export { _layout as default };
|
frontend/.svelte-kit/output/server/entries/pages/index.svelte.js
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { n as noop, a as safe_not_equal, c as create_ssr_component, b as subscribe, d as each, e as escape, f as add_attribute, g as set_store_value, v as validate_component } from "../../chunks/index-445fd704.js";
|
2 |
+
import { b as base } from "../../chunks/paths-396f020f.js";
|
3 |
+
import "nanoid";
|
4 |
+
import "px-brush";
|
5 |
+
const COLOR_LIST = [
|
6 |
+
{ color: [219, 14, 154], label: "building" },
|
7 |
+
{ color: [147, 142, 123], label: "pervious surface" },
|
8 |
+
{ color: [248, 12, 0], label: "impervious surface" },
|
9 |
+
{ color: [169, 113, 1], label: "bare soil" },
|
10 |
+
{ color: [21, 83, 174], label: "water" },
|
11 |
+
{ color: [25, 74, 38], label: "coniferous" },
|
12 |
+
{ color: [70, 228, 131], label: "deciduous" },
|
13 |
+
{ color: [243, 166, 13], label: "brushwood" },
|
14 |
+
{ color: [102, 0, 130], label: "vineyard" },
|
15 |
+
{ color: [85, 255, 0], label: "herbaceous vegetation" },
|
16 |
+
{ color: [255, 243, 13], label: "agricultural land" },
|
17 |
+
{ color: [228, 223, 124], label: "plowed land" },
|
18 |
+
{ color: [61, 230, 235], label: "swimming pool" },
|
19 |
+
{ color: [255, 255, 255], label: "snow" },
|
20 |
+
{ color: [138, 179, 160], label: "clear cut" },
|
21 |
+
{ color: [107, 113, 79], label: "mixed" },
|
22 |
+
{ color: [197, 220, 66], label: "ligneous" },
|
23 |
+
{ color: [153, 153, 255], label: "greenhouse" },
|
24 |
+
{ color: [0, 0, 0], label: "other" }
|
25 |
+
];
|
26 |
+
const IMAGES_LIST = [
|
27 |
+
"/samples/example0.png",
|
28 |
+
"/samples/example1.png",
|
29 |
+
"/samples/example2.png",
|
30 |
+
"/samples/example3.png",
|
31 |
+
"/samples/example4.png",
|
32 |
+
"/samples/example5.png"
|
33 |
+
];
|
34 |
+
const PRESETS = [
|
35 |
+
["Aerial view, France. High resolution image, 4K, ultra detailed", "Realistic"],
|
36 |
+
["Aerial view, France. Colorful lego bricks", "Lego brick"],
|
37 |
+
["Aerial view, France. Black and white paper pencil drawing", "Pencil"],
|
38 |
+
["Aerial view, France. Oil on canvas painting", "Painting"]
|
39 |
+
];
|
40 |
+
const subscriber_queue = [];
|
41 |
+
function writable(value, start = noop) {
|
42 |
+
let stop;
|
43 |
+
const subscribers = /* @__PURE__ */ new Set();
|
44 |
+
function set(new_value) {
|
45 |
+
if (safe_not_equal(value, new_value)) {
|
46 |
+
value = new_value;
|
47 |
+
if (stop) {
|
48 |
+
const run_queue = !subscriber_queue.length;
|
49 |
+
for (const subscriber of subscribers) {
|
50 |
+
subscriber[1]();
|
51 |
+
subscriber_queue.push(subscriber, value);
|
52 |
+
}
|
53 |
+
if (run_queue) {
|
54 |
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
55 |
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
56 |
+
}
|
57 |
+
subscriber_queue.length = 0;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
function update(fn) {
|
63 |
+
set(fn(value));
|
64 |
+
}
|
65 |
+
function subscribe2(run, invalidate = noop) {
|
66 |
+
const subscriber = [run, invalidate];
|
67 |
+
subscribers.add(subscriber);
|
68 |
+
if (subscribers.size === 1) {
|
69 |
+
stop = start(set) || noop;
|
70 |
+
}
|
71 |
+
run(value);
|
72 |
+
return () => {
|
73 |
+
subscribers.delete(subscriber);
|
74 |
+
if (subscribers.size === 0) {
|
75 |
+
stop();
|
76 |
+
stop = null;
|
77 |
+
}
|
78 |
+
};
|
79 |
+
}
|
80 |
+
return { set, update, subscribe: subscribe2 };
|
81 |
+
}
|
82 |
+
function randomSeed() {
|
83 |
+
return BigInt(13248873089935215e3 & ((1 << 63) - 1) * Math.random());
|
84 |
+
}
|
85 |
+
const drawingLayers = writable(/* @__PURE__ */ new Map());
|
86 |
+
const resultImage = writable();
|
87 |
+
const currentCanvas = writable();
|
88 |
+
const selectedImage = writable();
|
89 |
+
const selectedBrush = writable();
|
90 |
+
const selectedParams = writable({
|
91 |
+
prompt: PRESETS[0][0],
|
92 |
+
seed: randomSeed(),
|
93 |
+
steps: 20
|
94 |
+
});
|
95 |
+
const generateMap = writable(false);
|
96 |
+
const saveResult = writable(false);
|
97 |
+
var TemplateGallery_svelte_svelte_type_style_lang = /* @__PURE__ */ (() => "form.svelte-1gwcbp.svelte-1gwcbp{width:100%;overflow:hidden\n}.samples.svelte-1gwcbp.svelte-1gwcbp{display:flex;scroll-snap-type:x var(--tw-scroll-snap-strictness);--tw-scroll-snap-strictness:mandatory;flex-wrap:nowrap;gap:0.25rem;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none\n}.samples.svelte-1gwcbp.svelte-1gwcbp::-webkit-scrollbar{display:none\n}input[type='radio'].svelte-1gwcbp.svelte-1gwcbp{position:absolute;display:none;height:0px;width:0px;opacity:0\n}input[type='radio'].svelte-1gwcbp.svelte-1gwcbp:disabled{opacity:0.5\n}input[type='radio'].svelte-1gwcbp:checked~label.svelte-1gwcbp{outline-style:solid;outline-width:2px;outline-color:#eab308\n}input[type='radio'].svelte-1gwcbp:disabled+label.svelte-1gwcbp{opacity:0.5\n}label.svelte-1gwcbp.svelte-1gwcbp{display:flex;cursor:pointer;outline-width:2px;outline-offset:-2px;outline-color:#eab308;transition-property:all;transition-duration:200ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)\n}label.svelte-1gwcbp.svelte-1gwcbp:hover{outline-style:solid\n}img.svelte-1gwcbp.svelte-1gwcbp{max-height:6rem;max-width:none\n}")();
|
98 |
+
const css$5 = {
|
99 |
+
code: "form.svelte-1gwcbp.svelte-1gwcbp{width:100%;overflow:hidden\n}.samples.svelte-1gwcbp.svelte-1gwcbp{display:flex;scroll-snap-type:x var(--tw-scroll-snap-strictness);--tw-scroll-snap-strictness:mandatory;flex-wrap:nowrap;gap:0.25rem;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none\n}.samples.svelte-1gwcbp.svelte-1gwcbp::-webkit-scrollbar{display:none\n}input[type='radio'].svelte-1gwcbp.svelte-1gwcbp{position:absolute;display:none;height:0px;width:0px;opacity:0\n}input[type='radio'].svelte-1gwcbp.svelte-1gwcbp:disabled{opacity:0.5\n}input[type='radio'].svelte-1gwcbp:checked~label.svelte-1gwcbp{outline-style:solid;outline-width:2px;outline-color:#eab308\n}input[type='radio'].svelte-1gwcbp:disabled+label.svelte-1gwcbp{opacity:0.5\n}label.svelte-1gwcbp.svelte-1gwcbp{display:flex;cursor:pointer;outline-width:2px;outline-offset:-2px;outline-color:#eab308;transition-property:all;transition-duration:200ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)\n}label.svelte-1gwcbp.svelte-1gwcbp:hover{outline-style:solid\n}img.svelte-1gwcbp.svelte-1gwcbp{max-height:6rem;max-width:none\n}",
|
100 |
+
map: null
|
101 |
+
};
|
102 |
+
const TemplateGallery = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
103 |
+
let $$unsubscribe_selectedImage;
|
104 |
+
let $generateMap, $$unsubscribe_generateMap;
|
105 |
+
$$unsubscribe_selectedImage = subscribe(selectedImage, (value) => value);
|
106 |
+
$$unsubscribe_generateMap = subscribe(generateMap, (value) => $generateMap = value);
|
107 |
+
$$result.css.add(css$5);
|
108 |
+
$$unsubscribe_selectedImage();
|
109 |
+
$$unsubscribe_generateMap();
|
110 |
+
return `<div><h4 class="${"font-bold mt-6 mb-2 my-6 leading-6"}">Select a Template</h4>
|
111 |
+
<form class="${"svelte-1gwcbp"}"><div class="${"samples svelte-1gwcbp"}">${each(IMAGES_LIST, (file_name, id) => {
|
112 |
+
return `<div class="${"snap-always snap-start"}"><input type="${"radio"}" name="${"samples"}" id="${"sample-" + escape(id)}"${add_attribute("value", id, 0)} ${$generateMap === true ? "disabled" : ""} class="${"svelte-1gwcbp"}">
|
113 |
+
<label for="${"sample-" + escape(id)}" class="${"svelte-1gwcbp"}"><img${add_attribute("src", base + file_name, 0)}${add_attribute("alt", file_name, 0)} class="${"svelte-1gwcbp"}"></label>
|
114 |
+
</div>`;
|
115 |
+
})}</div></form>
|
116 |
+
</div>`;
|
117 |
+
});
|
118 |
+
var BrushSelector_svelte_svelte_type_style_lang = /* @__PURE__ */ (() => ".colors.svelte-1oy4poo.svelte-1oy4poo{display:grid;max-height:9rem;scroll-snap-type:y var(--tw-scroll-snap-strictness);--tw-scroll-snap-strictness:mandatory;grid-template-columns:repeat(2, minmax(0, 1fr));gap:0.5rem;overflow:scroll\n}@media(min-width: 530px){.colors.svelte-1oy4poo.svelte-1oy4poo{max-height:none;grid-template-columns:repeat(3, minmax(0, 1fr))\n }}.colors.svelte-1oy4poo span.svelte-1oy4poo{margin-left:0.5rem\n}.colors.svelte-1oy4poo svg.svelte-1oy4poo{display:block\n}input[type='radio'].svelte-1oy4poo.svelte-1oy4poo{position:absolute;display:none;height:0px;width:0px;opacity:0\n}input[type='radio'].svelte-1oy4poo:checked~label.svelte-1oy4poo{outline-style:solid;outline-width:2px;outline-color:#eab308\n}label.svelte-1oy4poo.svelte-1oy4poo{display:flex;cursor:pointer;white-space:nowrap;outline-width:2px;outline-offset:-2px;outline-color:#eab308;transition-property:all;transition-duration:200ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)\n}label.svelte-1oy4poo.svelte-1oy4poo:hover{outline-style:solid\n}.brush.svelte-1oy4poo.svelte-1oy4poo{display:flex\n}")();
|
119 |
+
const css$4 = {
|
120 |
+
code: ".colors.svelte-1oy4poo.svelte-1oy4poo{display:grid;max-height:9rem;scroll-snap-type:y var(--tw-scroll-snap-strictness);--tw-scroll-snap-strictness:mandatory;grid-template-columns:repeat(2, minmax(0, 1fr));gap:0.5rem;overflow:scroll\n}@media(min-width: 530px){.colors.svelte-1oy4poo.svelte-1oy4poo{max-height:none;grid-template-columns:repeat(3, minmax(0, 1fr))\n }}.colors.svelte-1oy4poo span.svelte-1oy4poo{margin-left:0.5rem\n}.colors.svelte-1oy4poo svg.svelte-1oy4poo{display:block\n}input[type='radio'].svelte-1oy4poo.svelte-1oy4poo{position:absolute;display:none;height:0px;width:0px;opacity:0\n}input[type='radio'].svelte-1oy4poo:checked~label.svelte-1oy4poo{outline-style:solid;outline-width:2px;outline-color:#eab308\n}label.svelte-1oy4poo.svelte-1oy4poo{display:flex;cursor:pointer;white-space:nowrap;outline-width:2px;outline-offset:-2px;outline-color:#eab308;transition-property:all;transition-duration:200ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)\n}label.svelte-1oy4poo.svelte-1oy4poo:hover{outline-style:solid\n}.brush.svelte-1oy4poo.svelte-1oy4poo{display:flex\n}",
|
121 |
+
map: null
|
122 |
+
};
|
123 |
+
const STARTCOLORID = 6;
|
124 |
+
const BrushSelector = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
125 |
+
let $selectedBrush, $$unsubscribe_selectedBrush;
|
126 |
+
$$unsubscribe_selectedBrush = subscribe(selectedBrush, (value) => $selectedBrush = value);
|
127 |
+
const { color, label } = COLOR_LIST[STARTCOLORID];
|
128 |
+
let brushColor = `rgb(${color.join(",")})`;
|
129 |
+
let brushSize = 40;
|
130 |
+
set_store_value(selectedBrush, $selectedBrush = {
|
131 |
+
color: brushColor,
|
132 |
+
size: brushSize,
|
133 |
+
label
|
134 |
+
}, $selectedBrush);
|
135 |
+
$$result.css.add(css$4);
|
136 |
+
$$unsubscribe_selectedBrush();
|
137 |
+
return `<form><h4 class="${"font-bold mt-6 mb-2 leading-6 my-3"}">Brush Type</h4>
|
138 |
+
<div class="${"colors svelte-1oy4poo"}" name="${"colors"}">${each(COLOR_LIST, (color2, id) => {
|
139 |
+
return `<div class="${"snap-always snap-start"}"><input name="${"color"}" ${id == STARTCOLORID ? "checked" : ""} type="${"radio"}" id="${"color-" + escape(id)}"${add_attribute("value", id, 0)} class="${"svelte-1oy4poo"}">
|
140 |
+
<label for="${"color-" + escape(id)}" class="${"svelte-1oy4poo"}"><svg width="${"20"}" height="${"20"}" viewBox="${"0 0 20 20"}" class="${"svelte-1oy4poo"}"><rect x="${"0"}" y="${"0"}" width="${"20"}" height="${"20"}" fill="${"rgb(" + escape(color2.color.join(",")) + ")"}"></rect></svg>
|
141 |
+
<span class="${"svelte-1oy4poo"}">${escape(color2.label)}</span></label>
|
142 |
+
</div>`;
|
143 |
+
})}</div>
|
144 |
+
<h4 class="${"font-bold mt-6 mb-2 my-6 leading-6"}">Brush Size</h4>
|
145 |
+
<div class="${"brush svelte-1oy4poo"}"><input value="${"10"}" min="${"1"}" max="${"150"}" step="${"1"}" name="${"brush"}" type="${"range"}">
|
146 |
+
<label class="${"pl-2 svelte-1oy4poo"}" for="${"brush"}">${escape($selectedBrush.size)}</label></div>
|
147 |
+
</form>`;
|
148 |
+
});
|
149 |
+
var ParamsSelector_svelte_svelte_type_style_lang = /* @__PURE__ */ (() => "@media(min-width: 530px){}select.svelte-uoay71.svelte-uoay71,button.svelte-uoay71.svelte-uoay71,input.svelte-uoay71.svelte-uoay71{border-radius:0.5rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity));padding:0.25rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity))\n}select.svelte-uoay71.svelte-uoay71:focus,button.svelte-uoay71.svelte-uoay71:focus,input.svelte-uoay71.svelte-uoay71:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n}select.svelte-uoay71.svelte-uoay71:disabled,button.svelte-uoay71.svelte-uoay71:disabled,input.svelte-uoay71.svelte-uoay71:disabled{opacity:0.5\n}@media(prefers-color-scheme: dark){select.svelte-uoay71.svelte-uoay71,button.svelte-uoay71.svelte-uoay71,input.svelte-uoay71.svelte-uoay71{--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(55 65 81 / var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))\n }select.svelte-uoay71.svelte-uoay71::-moz-placeholder,button.svelte-uoay71.svelte-uoay71::-moz-placeholder,input.svelte-uoay71.svelte-uoay71::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }select.svelte-uoay71.svelte-uoay71::-moz-placeholder, button.svelte-uoay71.svelte-uoay71::-moz-placeholder, input.svelte-uoay71.svelte-uoay71::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }select.svelte-uoay71.svelte-uoay71::placeholder,button.svelte-uoay71.svelte-uoay71::placeholder,input.svelte-uoay71.svelte-uoay71::placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }select.svelte-uoay71.svelte-uoay71:focus,button.svelte-uoay71.svelte-uoay71:focus,input.svelte-uoay71.svelte-uoay71:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n }}input.svelte-uoay71:disabled+label.svelte-uoay71{opacity:0.5\n}input.svelte-uoay71.svelte-uoay71{padding-left:0.75rem\n}")();
|
150 |
+
const css$3 = {
|
151 |
+
code: "@media(min-width: 530px){}select.svelte-uoay71.svelte-uoay71,button.svelte-uoay71.svelte-uoay71,input.svelte-uoay71.svelte-uoay71{border-radius:0.5rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity));padding:0.25rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity))\n}select.svelte-uoay71.svelte-uoay71:focus,button.svelte-uoay71.svelte-uoay71:focus,input.svelte-uoay71.svelte-uoay71:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n}select.svelte-uoay71.svelte-uoay71:disabled,button.svelte-uoay71.svelte-uoay71:disabled,input.svelte-uoay71.svelte-uoay71:disabled{opacity:0.5\n}@media(prefers-color-scheme: dark){select.svelte-uoay71.svelte-uoay71,button.svelte-uoay71.svelte-uoay71,input.svelte-uoay71.svelte-uoay71{--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(55 65 81 / var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))\n }select.svelte-uoay71.svelte-uoay71::-moz-placeholder,button.svelte-uoay71.svelte-uoay71::-moz-placeholder,input.svelte-uoay71.svelte-uoay71::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }select.svelte-uoay71.svelte-uoay71::placeholder,button.svelte-uoay71.svelte-uoay71::placeholder,input.svelte-uoay71.svelte-uoay71::placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }select.svelte-uoay71.svelte-uoay71:focus,button.svelte-uoay71.svelte-uoay71:focus,input.svelte-uoay71.svelte-uoay71:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n }}input.svelte-uoay71:disabled+label.svelte-uoay71{opacity:0.5\n}input.svelte-uoay71.svelte-uoay71{padding-left:0.75rem\n}",
|
152 |
+
map: null
|
153 |
+
};
|
154 |
+
const ParamsSelector = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
155 |
+
let $selectedParams, $$unsubscribe_selectedParams;
|
156 |
+
let $generateMap, $$unsubscribe_generateMap;
|
157 |
+
$$unsubscribe_selectedParams = subscribe(selectedParams, (value) => $selectedParams = value);
|
158 |
+
$$unsubscribe_generateMap = subscribe(generateMap, (value) => $generateMap = value);
|
159 |
+
let form;
|
160 |
+
let seed = $selectedParams.seed;
|
161 |
+
let sampleSteps = $selectedParams.steps;
|
162 |
+
let prompt = $selectedParams.prompt;
|
163 |
+
$$result.css.add(css$3);
|
164 |
+
$$unsubscribe_selectedParams();
|
165 |
+
$$unsubscribe_generateMap();
|
166 |
+
return `<form${add_attribute("this", form, 0)}><h4 class="${"font-bold mt-6 mb-2 my-6 leading-6"}">Prompt</h4>
|
167 |
+
<input name="${"prompt"}" placeholder="${"Aerial view of ..., France."}" ${$generateMap === true ? "disabled" : ""} style="${"width: 500px;"}" class="${"svelte-uoay71"}"${add_attribute("value", prompt, 0)}>
|
168 |
+
<select name="${"presets"}" ${$generateMap === true ? "disabled" : ""} class="${"svelte-uoay71"}"><option disabled selected value="${"preset"}">preset</option>${each(PRESETS, (preset) => {
|
169 |
+
return `<option${add_attribute("value", preset[0], 0)}>${escape(preset[1])}</option>\``;
|
170 |
+
})}</select>
|
171 |
+
|
172 |
+
<h4 class="${"font-bold mt-6 mb-2 my-6 leading-6"}">Random Seed</h4>
|
173 |
+
<input type="${"Number"}" name="${"seed"}" placeholder="${"Integer Seed"}" ${$generateMap === true ? "disabled" : ""} class="${"svelte-uoay71"}"${add_attribute("value", seed, 0)}>
|
174 |
+
<button ${$generateMap === true ? "disabled" : ""} class="${"svelte-uoay71"}">Random
|
175 |
+
</button>
|
176 |
+
<h4 class="${"font-bold mt-6 mb-2 my-6 leading-6"}">Sample Steps</h4>
|
177 |
+
<div class="${"flex"}"><input type="${"range"}" name="${"steps"}" min="${"10"}" max="${"30"}" step="${"1"}" ${$generateMap === true ? "disabled" : ""} class="${"svelte-uoay71"}"${add_attribute("value", sampleSteps, 0)}>
|
178 |
+
<label class="${"pl-2 svelte-uoay71"}" for="${"steps"}">${escape(sampleSteps)}</label></div>
|
179 |
+
</form>`;
|
180 |
+
});
|
181 |
+
const Undo = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
182 |
+
let { classNames = "" } = $$props;
|
183 |
+
if ($$props.classNames === void 0 && $$bindings.classNames && classNames !== void 0)
|
184 |
+
$$bindings.classNames(classNames);
|
185 |
+
return `<svg xmlns="${"http://www.w3.org/2000/svg"}" width="${"20"}" viewBox="${"0 0 512 512"}"${add_attribute("class", classNames, 0)}><path fill="${"white"}" stroke="${"black"}" stroke-width="${"30"}" d="${"M480 256c0 123.4-100.5 223.9-223.9 223.9c-48.84 0-95.17-15.58-134.2-44.86c-14.12-10.59-16.97-30.66-6.375-44.81c10.59-14.12 30.62-16.94 44.81-6.375c27.84 20.91 61 31.94 95.88 31.94C344.3 415.8 416 344.1 416 256s-71.69-159.8-159.8-159.8c-37.46 0-73.09 13.49-101.3 36.64l45.12 45.14c17.01 17.02 4.955 46.1-19.1 46.1H35.17C24.58 224.1 16 215.5 16 204.9V59.04c0-24.04 29.07-36.08 46.07-19.07l47.6 47.63C149.9 52.71 201.5 32.11 256.1 32.11C379.5 32.11 480 132.6 480 256z"}"></path></svg>`;
|
186 |
+
});
|
187 |
+
var DrawingCanvas_svelte_svelte_type_style_lang = /* @__PURE__ */ (() => ".canvas.svelte-pr47cz{z-index:0;aspect-ratio:512/512;width:100%;max-width:100%;border-width:1px;--tw-border-opacity:1;border-color:rgb(107 114 128 / var(--tw-border-opacity))\n}@media(prefers-color-scheme: dark){.canvas.svelte-pr47cz{--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity))\n }}.brush.svelte-pr47cz{pointer-events:none;position:absolute;z-index:10;--tw-translate-x:-50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))\n}.label.svelte-pr47cz{pointer-events:none;position:absolute;top:0px;left:0px;z-index:20;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding-left:0.5rem;padding-right:0.5rem;font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity));color:white;font-weight:bolder;-webkit-text-stroke:1px black;-webkit-text-fill-color:white\n}")();
|
188 |
+
const css$2 = {
|
189 |
+
code: ".canvas.svelte-pr47cz{z-index:0;aspect-ratio:512/512;width:100%;max-width:100%;border-width:1px;--tw-border-opacity:1;border-color:rgb(107 114 128 / var(--tw-border-opacity))\n}@media(prefers-color-scheme: dark){.canvas.svelte-pr47cz{--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity))\n }}.brush.svelte-pr47cz{pointer-events:none;position:absolute;z-index:10;--tw-translate-x:-50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))\n}.label.svelte-pr47cz{pointer-events:none;position:absolute;top:0px;left:0px;z-index:20;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding-left:0.5rem;padding-right:0.5rem;font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity));color:white;font-weight:bolder;-webkit-text-stroke:1px black;-webkit-text-fill-color:white\n}",
|
190 |
+
map: null
|
191 |
+
};
|
192 |
+
function drawImage(ctx, img) {
|
193 |
+
ctx.drawImage(img, 0, 0, ctx.canvas.width, ctx.canvas.height);
|
194 |
+
}
|
195 |
+
const DrawingCanvas = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
196 |
+
let $drawingLayers, $$unsubscribe_drawingLayers;
|
197 |
+
let $selectedImage, $$unsubscribe_selectedImage;
|
198 |
+
let $selectedBrush, $$unsubscribe_selectedBrush;
|
199 |
+
let $$unsubscribe_currentCanvas;
|
200 |
+
$$unsubscribe_drawingLayers = subscribe(drawingLayers, (value) => $drawingLayers = value);
|
201 |
+
$$unsubscribe_selectedImage = subscribe(selectedImage, (value) => $selectedImage = value);
|
202 |
+
$$unsubscribe_selectedBrush = subscribe(selectedBrush, (value) => $selectedBrush = value);
|
203 |
+
$$unsubscribe_currentCanvas = subscribe(currentCanvas, (value) => value);
|
204 |
+
let canvas;
|
205 |
+
let brush;
|
206 |
+
let ctx;
|
207 |
+
$$result.css.add(css$2);
|
208 |
+
{
|
209 |
+
{
|
210 |
+
if ($selectedImage) {
|
211 |
+
drawImage(ctx, $selectedImage);
|
212 |
+
set_store_value(drawingLayers, $drawingLayers = /* @__PURE__ */ new Map(), $drawingLayers);
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
$$unsubscribe_drawingLayers();
|
217 |
+
$$unsubscribe_selectedImage();
|
218 |
+
$$unsubscribe_selectedBrush();
|
219 |
+
$$unsubscribe_currentCanvas();
|
220 |
+
return `<div><div class="${"relative overflow-clip"}"><canvas class="${"canvas svelte-pr47cz"}" width="${"512"}" height="${"512"}"${add_attribute("this", canvas, 0)}></canvas>
|
221 |
+
<canvas class="${"brush svelte-pr47cz"}" width="${"10"}" height="${"10"}"${add_attribute("this", brush, 0)}></canvas>
|
222 |
+
<span class="${"label svelte-pr47cz"}">${escape($selectedBrush == null ? void 0 : $selectedBrush.label)}</span>
|
223 |
+
<button class="${"absolute bottom-0 left-0 p-3"}" ${$drawingLayers.size <= 0 ? "disabled" : ""}>${validate_component(Undo, "UndoIcon").$$render($$result, {}, {}, {})}</button></div>
|
224 |
+
</div>`;
|
225 |
+
});
|
226 |
+
var ResultCanvas_svelte_svelte_type_style_lang = /* @__PURE__ */ (() => ".image.svelte-1t0h0rs{z-index:0;box-sizing:border-box;aspect-ratio:512/512;border-width:1px;--tw-border-opacity:1;border-color:rgb(107 114 128 / var(--tw-border-opacity))\n}@media(prefers-color-scheme: dark){.image.svelte-1t0h0rs{--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity))\n }}.loading.svelte-1t0h0rs{position:absolute;top:0px;left:0px;right:0px;bottom:0px;display:flex;flex-direction:column;align-items:center;justify-content:center\n}")();
|
227 |
+
const css$1 = {
|
228 |
+
code: ".image.svelte-1t0h0rs{z-index:0;box-sizing:border-box;aspect-ratio:512/512;border-width:1px;--tw-border-opacity:1;border-color:rgb(107 114 128 / var(--tw-border-opacity))\n}@media(prefers-color-scheme: dark){.image.svelte-1t0h0rs{--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity))\n }}.loading.svelte-1t0h0rs{position:absolute;top:0px;left:0px;right:0px;bottom:0px;display:flex;flex-direction:column;align-items:center;justify-content:center\n}",
|
229 |
+
map: null
|
230 |
+
};
|
231 |
+
let predictStatus = "";
|
232 |
+
async function saveImage(base64Image) {
|
233 |
+
return new Promise((resolve, reject) => {
|
234 |
+
try {
|
235 |
+
const a = document.createElement("a");
|
236 |
+
a.download = `sucess-${Date.now()}.png`;
|
237 |
+
a.target = "_self";
|
238 |
+
a.onclick = async (e) => {
|
239 |
+
if (a.href) {
|
240 |
+
URL.revokeObjectURL(a.href);
|
241 |
+
}
|
242 |
+
a.href = base64Image;
|
243 |
+
};
|
244 |
+
requestAnimationFrame(() => {
|
245 |
+
console.log("Downloading image.");
|
246 |
+
a.click();
|
247 |
+
resolve(null);
|
248 |
+
});
|
249 |
+
} catch (err) {
|
250 |
+
reject();
|
251 |
+
}
|
252 |
+
});
|
253 |
+
}
|
254 |
+
async function predict(base64Image, { prompt, steps, seed }) {
|
255 |
+
const response = await fetch("/predict", {
|
256 |
+
method: "POST",
|
257 |
+
headers: { "Content-Type": "application/json" },
|
258 |
+
body: JSON.stringify({
|
259 |
+
data: [base64Image, prompt, steps, seed.toString()]
|
260 |
+
})
|
261 |
+
});
|
262 |
+
if (!response.ok) {
|
263 |
+
throw new Error("Prediction request failed.");
|
264 |
+
}
|
265 |
+
const result = await response.text();
|
266 |
+
return result;
|
267 |
+
}
|
268 |
+
const ResultCanvas = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
269 |
+
let $saveResult, $$unsubscribe_saveResult;
|
270 |
+
let $resultImage, $$unsubscribe_resultImage;
|
271 |
+
let $generateMap, $$unsubscribe_generateMap;
|
272 |
+
let $selectedParams, $$unsubscribe_selectedParams;
|
273 |
+
let $currentCanvas, $$unsubscribe_currentCanvas;
|
274 |
+
$$unsubscribe_saveResult = subscribe(saveResult, (value) => $saveResult = value);
|
275 |
+
$$unsubscribe_resultImage = subscribe(resultImage, (value) => $resultImage = value);
|
276 |
+
$$unsubscribe_generateMap = subscribe(generateMap, (value) => $generateMap = value);
|
277 |
+
$$unsubscribe_selectedParams = subscribe(selectedParams, (value) => $selectedParams = value);
|
278 |
+
$$unsubscribe_currentCanvas = subscribe(currentCanvas, (value) => $currentCanvas = value);
|
279 |
+
$$result.css.add(css$1);
|
280 |
+
{
|
281 |
+
(async () => {
|
282 |
+
if ($generateMap) {
|
283 |
+
const results = await predict($currentCanvas.toDataURL(), $selectedParams);
|
284 |
+
set_store_value(resultImage, $resultImage = results, $resultImage);
|
285 |
+
set_store_value(generateMap, $generateMap = false, $generateMap);
|
286 |
+
}
|
287 |
+
})();
|
288 |
+
}
|
289 |
+
{
|
290 |
+
(async () => {
|
291 |
+
if ($saveResult) {
|
292 |
+
await saveImage($resultImage);
|
293 |
+
set_store_value(saveResult, $saveResult = false, $saveResult);
|
294 |
+
}
|
295 |
+
})();
|
296 |
+
}
|
297 |
+
$$unsubscribe_saveResult();
|
298 |
+
$$unsubscribe_resultImage();
|
299 |
+
$$unsubscribe_generateMap();
|
300 |
+
$$unsubscribe_selectedParams();
|
301 |
+
$$unsubscribe_currentCanvas();
|
302 |
+
return `<div class="${"relative overflow-clip flex flex-col justify-center items-center w-full h-full"}">${$resultImage ? `<img class="${"image " + escape($generateMap ? "opacity-30" : "") + " svelte-1t0h0rs"}" alt="${"Generative Map Result"}"${add_attribute("src", $resultImage, 0)} width="${"512"}" height="${"512"}">` : ``}
|
303 |
+
${$generateMap ? `<div class="${"loading svelte-1t0h0rs"}"><svg xmlns="${"http://www.w3.org/2000/svg"}" fill="${"none"}" viewBox="${"0 0 24 24"}" class="${"animate-spin max-w-[3rem]"}"><path fill="${"currentColor"}" d="${"M20 12a8 8 0 0 1-8 8v4a12 12 0 0 0 12-12h-4Zm-2-5.3a8 8 0 0 1 2 5.3h4c0-3-1.1-5.8-3-8l-3 2.7Z"}"></path></svg>
|
304 |
+
<span class="${"text-xs"}">${escape(predictStatus)}</span></div>` : ``}</div>
|
305 |
+
|
306 |
+
`;
|
307 |
+
});
|
308 |
+
var index_svelte_svelte_type_style_lang = /* @__PURE__ */ (() => ".drawings.svelte-237ry5{display:grid;grid-template-columns:2fr 1.5fr;place-items:center\n}@media(min-width: 530px){.drawings.svelte-237ry5{grid-template-columns:repeat(2, minmax(0, 1fr))\n }}button.svelte-237ry5{border-radius:0.5rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity));padding:0.25rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity))\n}button.svelte-237ry5:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n}button.svelte-237ry5:disabled{opacity:0.5\n}@media(prefers-color-scheme: dark){button.svelte-237ry5{--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(55 65 81 / var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))\n }button.svelte-237ry5::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }button.svelte-237ry5::placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }button.svelte-237ry5:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n }}")();
|
309 |
+
const css = {
|
310 |
+
code: ".drawings.svelte-237ry5{display:grid;grid-template-columns:2fr 1.5fr;place-items:center\n}@media(min-width: 530px){.drawings.svelte-237ry5{grid-template-columns:repeat(2, minmax(0, 1fr))\n }}button.svelte-237ry5{border-radius:0.5rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity));padding:0.25rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity))\n}button.svelte-237ry5:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n}button.svelte-237ry5:disabled{opacity:0.5\n}@media(prefers-color-scheme: dark){button.svelte-237ry5{--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(55 65 81 / var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity))\n }button.svelte-237ry5::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }button.svelte-237ry5::placeholder{--tw-placeholder-opacity:1;color:rgb(156 163 175 / var(--tw-placeholder-opacity))\n }button.svelte-237ry5:focus{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity));--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246 / var(--tw-ring-opacity))\n }}",
|
311 |
+
map: null
|
312 |
+
};
|
313 |
+
const Routes = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
314 |
+
let $generateMap, $$unsubscribe_generateMap;
|
315 |
+
let $saveResult, $$unsubscribe_saveResult;
|
316 |
+
let $resultImage, $$unsubscribe_resultImage;
|
317 |
+
$$unsubscribe_generateMap = subscribe(generateMap, (value) => $generateMap = value);
|
318 |
+
$$unsubscribe_saveResult = subscribe(saveResult, (value) => $saveResult = value);
|
319 |
+
$$unsubscribe_resultImage = subscribe(resultImage, (value) => $resultImage = value);
|
320 |
+
$$result.css.add(css);
|
321 |
+
$$unsubscribe_generateMap();
|
322 |
+
$$unsubscribe_saveResult();
|
323 |
+
$$unsubscribe_resultImage();
|
324 |
+
return `<div class="${"max-w-screen-md mx-auto px-3 py-5 relative z-0"}"><article class="${"prose dark:prose-invert"}"><h1>Drawing to Map</h1></article>
|
325 |
+
${validate_component(BrushSelector, "BrushSelector").$$render($$result, {}, {}, {})}
|
326 |
+
<div class="${"drawings py-3 -mx-3 svelte-237ry5"}">${validate_component(DrawingCanvas, "DrawingCanvas").$$render($$result, {}, {}, {})}
|
327 |
+
${validate_component(ResultCanvas, "ResultCanvas").$$render($$result, {}, {}, {})}</div>
|
328 |
+
|
329 |
+
<button ${$generateMap === true ? "disabled" : ""} class="${"svelte-237ry5"}">Generate Map
|
330 |
+
</button>
|
331 |
+
|
332 |
+
<button ${$saveResult === true || !$resultImage ? "disabled" : ""} class="${"svelte-237ry5"}">Save Result
|
333 |
+
</button>
|
334 |
+
|
335 |
+
${validate_component(TemplateGallery, "TemplateGallery").$$render($$result, {}, {}, {})}
|
336 |
+
|
337 |
+
${validate_component(ParamsSelector, "ParamSelector").$$render($$result, {}, {}, {})}
|
338 |
+
</div>`;
|
339 |
+
});
|
340 |
+
export { Routes as default };
|
frontend/.svelte-kit/output/server/index.js
ADDED
@@ -0,0 +1,2291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { c as create_ssr_component, s as setContext, v as validate_component, m as missing_component } from "./chunks/index-445fd704.js";
|
2 |
+
import { s as set_paths, b as base, a as assets } from "./chunks/paths-396f020f.js";
|
3 |
+
function afterUpdate() {
|
4 |
+
}
|
5 |
+
const Root = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
6 |
+
let { stores } = $$props;
|
7 |
+
let { page } = $$props;
|
8 |
+
let { components } = $$props;
|
9 |
+
let { props_0 = null } = $$props;
|
10 |
+
let { props_1 = null } = $$props;
|
11 |
+
let { props_2 = null } = $$props;
|
12 |
+
setContext("__svelte__", stores);
|
13 |
+
afterUpdate(stores.page.notify);
|
14 |
+
if ($$props.stores === void 0 && $$bindings.stores && stores !== void 0)
|
15 |
+
$$bindings.stores(stores);
|
16 |
+
if ($$props.page === void 0 && $$bindings.page && page !== void 0)
|
17 |
+
$$bindings.page(page);
|
18 |
+
if ($$props.components === void 0 && $$bindings.components && components !== void 0)
|
19 |
+
$$bindings.components(components);
|
20 |
+
if ($$props.props_0 === void 0 && $$bindings.props_0 && props_0 !== void 0)
|
21 |
+
$$bindings.props_0(props_0);
|
22 |
+
if ($$props.props_1 === void 0 && $$bindings.props_1 && props_1 !== void 0)
|
23 |
+
$$bindings.props_1(props_1);
|
24 |
+
if ($$props.props_2 === void 0 && $$bindings.props_2 && props_2 !== void 0)
|
25 |
+
$$bindings.props_2(props_2);
|
26 |
+
{
|
27 |
+
stores.page.set(page);
|
28 |
+
}
|
29 |
+
return `
|
30 |
+
|
31 |
+
|
32 |
+
${components[1] ? `${validate_component(components[0] || missing_component, "svelte:component").$$render($$result, Object.assign(props_0 || {}), {}, {
|
33 |
+
default: () => {
|
34 |
+
return `${components[2] ? `${validate_component(components[1] || missing_component, "svelte:component").$$render($$result, Object.assign(props_1 || {}), {}, {
|
35 |
+
default: () => {
|
36 |
+
return `${validate_component(components[2] || missing_component, "svelte:component").$$render($$result, Object.assign(props_2 || {}), {}, {})}`;
|
37 |
+
}
|
38 |
+
})}` : `${validate_component(components[1] || missing_component, "svelte:component").$$render($$result, Object.assign(props_1 || {}), {}, {})}`}`;
|
39 |
+
}
|
40 |
+
})}` : `${validate_component(components[0] || missing_component, "svelte:component").$$render($$result, Object.assign(props_0 || {}), {}, {})}`}
|
41 |
+
|
42 |
+
${``}`;
|
43 |
+
});
|
44 |
+
function to_headers(object) {
|
45 |
+
const headers = new Headers();
|
46 |
+
if (object) {
|
47 |
+
for (const key2 in object) {
|
48 |
+
const value = object[key2];
|
49 |
+
if (!value)
|
50 |
+
continue;
|
51 |
+
if (Array.isArray(value)) {
|
52 |
+
value.forEach((value2) => {
|
53 |
+
headers.append(key2, value2);
|
54 |
+
});
|
55 |
+
} else {
|
56 |
+
headers.set(key2, value);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
return headers;
|
61 |
+
}
|
62 |
+
function hash(value) {
|
63 |
+
let hash2 = 5381;
|
64 |
+
let i = value.length;
|
65 |
+
if (typeof value === "string") {
|
66 |
+
while (i)
|
67 |
+
hash2 = hash2 * 33 ^ value.charCodeAt(--i);
|
68 |
+
} else {
|
69 |
+
while (i)
|
70 |
+
hash2 = hash2 * 33 ^ value[--i];
|
71 |
+
}
|
72 |
+
return (hash2 >>> 0).toString(36);
|
73 |
+
}
|
74 |
+
function lowercase_keys(obj) {
|
75 |
+
const clone = {};
|
76 |
+
for (const key2 in obj) {
|
77 |
+
clone[key2.toLowerCase()] = obj[key2];
|
78 |
+
}
|
79 |
+
return clone;
|
80 |
+
}
|
81 |
+
function decode_params(params) {
|
82 |
+
for (const key2 in params) {
|
83 |
+
params[key2] = params[key2].replace(/%23/g, "#").replace(/%3[Bb]/g, ";").replace(/%2[Cc]/g, ",").replace(/%2[Ff]/g, "/").replace(/%3[Ff]/g, "?").replace(/%3[Aa]/g, ":").replace(/%40/g, "@").replace(/%26/g, "&").replace(/%3[Dd]/g, "=").replace(/%2[Bb]/g, "+").replace(/%24/g, "$");
|
84 |
+
}
|
85 |
+
return params;
|
86 |
+
}
|
87 |
+
function is_pojo(body) {
|
88 |
+
if (typeof body !== "object")
|
89 |
+
return false;
|
90 |
+
if (body) {
|
91 |
+
if (body instanceof Uint8Array)
|
92 |
+
return false;
|
93 |
+
if (body instanceof ReadableStream)
|
94 |
+
return false;
|
95 |
+
if (body._readableState && typeof body.pipe === "function") {
|
96 |
+
throw new Error("Node streams are no longer supported \u2014 use a ReadableStream instead");
|
97 |
+
}
|
98 |
+
}
|
99 |
+
return true;
|
100 |
+
}
|
101 |
+
function normalize_request_method(event) {
|
102 |
+
const method = event.request.method.toLowerCase();
|
103 |
+
return method === "delete" ? "del" : method;
|
104 |
+
}
|
105 |
+
function error(body) {
|
106 |
+
return new Response(body, {
|
107 |
+
status: 500
|
108 |
+
});
|
109 |
+
}
|
110 |
+
function is_string(s2) {
|
111 |
+
return typeof s2 === "string" || s2 instanceof String;
|
112 |
+
}
|
113 |
+
const text_types = /* @__PURE__ */ new Set([
|
114 |
+
"application/xml",
|
115 |
+
"application/json",
|
116 |
+
"application/x-www-form-urlencoded",
|
117 |
+
"multipart/form-data"
|
118 |
+
]);
|
119 |
+
const bodyless_status_codes = /* @__PURE__ */ new Set([101, 204, 205, 304]);
|
120 |
+
function is_text(content_type) {
|
121 |
+
if (!content_type)
|
122 |
+
return true;
|
123 |
+
const type = content_type.split(";")[0].toLowerCase();
|
124 |
+
return type.startsWith("text/") || type.endsWith("+xml") || text_types.has(type);
|
125 |
+
}
|
126 |
+
async function render_endpoint(event, mod) {
|
127 |
+
const method = normalize_request_method(event);
|
128 |
+
let handler = mod[method];
|
129 |
+
if (!handler && method === "head") {
|
130 |
+
handler = mod.get;
|
131 |
+
}
|
132 |
+
if (!handler) {
|
133 |
+
const allowed = [];
|
134 |
+
for (const method2 in ["get", "post", "put", "patch"]) {
|
135 |
+
if (mod[method2])
|
136 |
+
allowed.push(method2.toUpperCase());
|
137 |
+
}
|
138 |
+
if (mod.del)
|
139 |
+
allowed.push("DELETE");
|
140 |
+
if (mod.get || mod.head)
|
141 |
+
allowed.push("HEAD");
|
142 |
+
return event.request.headers.get("x-sveltekit-load") ? new Response(void 0, {
|
143 |
+
status: 204
|
144 |
+
}) : new Response(`${event.request.method} method not allowed`, {
|
145 |
+
status: 405,
|
146 |
+
headers: {
|
147 |
+
allow: allowed.join(", ")
|
148 |
+
}
|
149 |
+
});
|
150 |
+
}
|
151 |
+
const response = await handler(event);
|
152 |
+
const preface = `Invalid response from route ${event.url.pathname}`;
|
153 |
+
if (typeof response !== "object") {
|
154 |
+
return error(`${preface}: expected an object, got ${typeof response}`);
|
155 |
+
}
|
156 |
+
if (response.fallthrough) {
|
157 |
+
throw new Error("fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching");
|
158 |
+
}
|
159 |
+
const { status = 200, body = {} } = response;
|
160 |
+
const headers = response.headers instanceof Headers ? new Headers(response.headers) : to_headers(response.headers);
|
161 |
+
const type = headers.get("content-type");
|
162 |
+
if (!is_text(type) && !(body instanceof Uint8Array || is_string(body))) {
|
163 |
+
return error(`${preface}: body must be an instance of string or Uint8Array if content-type is not a supported textual content-type`);
|
164 |
+
}
|
165 |
+
let normalized_body;
|
166 |
+
if (is_pojo(body) && (!type || type.startsWith("application/json"))) {
|
167 |
+
headers.set("content-type", "application/json; charset=utf-8");
|
168 |
+
normalized_body = JSON.stringify(body);
|
169 |
+
} else {
|
170 |
+
normalized_body = body;
|
171 |
+
}
|
172 |
+
if ((typeof normalized_body === "string" || normalized_body instanceof Uint8Array) && !headers.has("etag")) {
|
173 |
+
const cache_control = headers.get("cache-control");
|
174 |
+
if (!cache_control || !/(no-store|immutable)/.test(cache_control)) {
|
175 |
+
headers.set("etag", `"${hash(normalized_body)}"`);
|
176 |
+
}
|
177 |
+
}
|
178 |
+
return new Response(method !== "head" && !bodyless_status_codes.has(status) ? normalized_body : void 0, {
|
179 |
+
status,
|
180 |
+
headers
|
181 |
+
});
|
182 |
+
}
|
183 |
+
var chars$1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
|
184 |
+
var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g;
|
185 |
+
var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
|
186 |
+
var escaped = {
|
187 |
+
"<": "\\u003C",
|
188 |
+
">": "\\u003E",
|
189 |
+
"/": "\\u002F",
|
190 |
+
"\\": "\\\\",
|
191 |
+
"\b": "\\b",
|
192 |
+
"\f": "\\f",
|
193 |
+
"\n": "\\n",
|
194 |
+
"\r": "\\r",
|
195 |
+
" ": "\\t",
|
196 |
+
"\0": "\\0",
|
197 |
+
"\u2028": "\\u2028",
|
198 |
+
"\u2029": "\\u2029"
|
199 |
+
};
|
200 |
+
var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
201 |
+
function devalue(value) {
|
202 |
+
var counts = /* @__PURE__ */ new Map();
|
203 |
+
function walk(thing) {
|
204 |
+
if (typeof thing === "function") {
|
205 |
+
throw new Error("Cannot stringify a function");
|
206 |
+
}
|
207 |
+
if (counts.has(thing)) {
|
208 |
+
counts.set(thing, counts.get(thing) + 1);
|
209 |
+
return;
|
210 |
+
}
|
211 |
+
counts.set(thing, 1);
|
212 |
+
if (!isPrimitive(thing)) {
|
213 |
+
var type = getType(thing);
|
214 |
+
switch (type) {
|
215 |
+
case "Number":
|
216 |
+
case "String":
|
217 |
+
case "Boolean":
|
218 |
+
case "Date":
|
219 |
+
case "RegExp":
|
220 |
+
return;
|
221 |
+
case "Array":
|
222 |
+
thing.forEach(walk);
|
223 |
+
break;
|
224 |
+
case "Set":
|
225 |
+
case "Map":
|
226 |
+
Array.from(thing).forEach(walk);
|
227 |
+
break;
|
228 |
+
default:
|
229 |
+
var proto = Object.getPrototypeOf(thing);
|
230 |
+
if (proto !== Object.prototype && proto !== null && Object.getOwnPropertyNames(proto).sort().join("\0") !== objectProtoOwnPropertyNames) {
|
231 |
+
throw new Error("Cannot stringify arbitrary non-POJOs");
|
232 |
+
}
|
233 |
+
if (Object.getOwnPropertySymbols(thing).length > 0) {
|
234 |
+
throw new Error("Cannot stringify POJOs with symbolic keys");
|
235 |
+
}
|
236 |
+
Object.keys(thing).forEach(function(key2) {
|
237 |
+
return walk(thing[key2]);
|
238 |
+
});
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
walk(value);
|
243 |
+
var names = /* @__PURE__ */ new Map();
|
244 |
+
Array.from(counts).filter(function(entry) {
|
245 |
+
return entry[1] > 1;
|
246 |
+
}).sort(function(a, b) {
|
247 |
+
return b[1] - a[1];
|
248 |
+
}).forEach(function(entry, i) {
|
249 |
+
names.set(entry[0], getName(i));
|
250 |
+
});
|
251 |
+
function stringify(thing) {
|
252 |
+
if (names.has(thing)) {
|
253 |
+
return names.get(thing);
|
254 |
+
}
|
255 |
+
if (isPrimitive(thing)) {
|
256 |
+
return stringifyPrimitive(thing);
|
257 |
+
}
|
258 |
+
var type = getType(thing);
|
259 |
+
switch (type) {
|
260 |
+
case "Number":
|
261 |
+
case "String":
|
262 |
+
case "Boolean":
|
263 |
+
return "Object(" + stringify(thing.valueOf()) + ")";
|
264 |
+
case "RegExp":
|
265 |
+
return "new RegExp(" + stringifyString(thing.source) + ', "' + thing.flags + '")';
|
266 |
+
case "Date":
|
267 |
+
return "new Date(" + thing.getTime() + ")";
|
268 |
+
case "Array":
|
269 |
+
var members = thing.map(function(v, i) {
|
270 |
+
return i in thing ? stringify(v) : "";
|
271 |
+
});
|
272 |
+
var tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
|
273 |
+
return "[" + members.join(",") + tail + "]";
|
274 |
+
case "Set":
|
275 |
+
case "Map":
|
276 |
+
return "new " + type + "([" + Array.from(thing).map(stringify).join(",") + "])";
|
277 |
+
default:
|
278 |
+
var obj = "{" + Object.keys(thing).map(function(key2) {
|
279 |
+
return safeKey(key2) + ":" + stringify(thing[key2]);
|
280 |
+
}).join(",") + "}";
|
281 |
+
var proto = Object.getPrototypeOf(thing);
|
282 |
+
if (proto === null) {
|
283 |
+
return Object.keys(thing).length > 0 ? "Object.assign(Object.create(null)," + obj + ")" : "Object.create(null)";
|
284 |
+
}
|
285 |
+
return obj;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
var str = stringify(value);
|
289 |
+
if (names.size) {
|
290 |
+
var params_1 = [];
|
291 |
+
var statements_1 = [];
|
292 |
+
var values_1 = [];
|
293 |
+
names.forEach(function(name, thing) {
|
294 |
+
params_1.push(name);
|
295 |
+
if (isPrimitive(thing)) {
|
296 |
+
values_1.push(stringifyPrimitive(thing));
|
297 |
+
return;
|
298 |
+
}
|
299 |
+
var type = getType(thing);
|
300 |
+
switch (type) {
|
301 |
+
case "Number":
|
302 |
+
case "String":
|
303 |
+
case "Boolean":
|
304 |
+
values_1.push("Object(" + stringify(thing.valueOf()) + ")");
|
305 |
+
break;
|
306 |
+
case "RegExp":
|
307 |
+
values_1.push(thing.toString());
|
308 |
+
break;
|
309 |
+
case "Date":
|
310 |
+
values_1.push("new Date(" + thing.getTime() + ")");
|
311 |
+
break;
|
312 |
+
case "Array":
|
313 |
+
values_1.push("Array(" + thing.length + ")");
|
314 |
+
thing.forEach(function(v, i) {
|
315 |
+
statements_1.push(name + "[" + i + "]=" + stringify(v));
|
316 |
+
});
|
317 |
+
break;
|
318 |
+
case "Set":
|
319 |
+
values_1.push("new Set");
|
320 |
+
statements_1.push(name + "." + Array.from(thing).map(function(v) {
|
321 |
+
return "add(" + stringify(v) + ")";
|
322 |
+
}).join("."));
|
323 |
+
break;
|
324 |
+
case "Map":
|
325 |
+
values_1.push("new Map");
|
326 |
+
statements_1.push(name + "." + Array.from(thing).map(function(_a) {
|
327 |
+
var k = _a[0], v = _a[1];
|
328 |
+
return "set(" + stringify(k) + ", " + stringify(v) + ")";
|
329 |
+
}).join("."));
|
330 |
+
break;
|
331 |
+
default:
|
332 |
+
values_1.push(Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}");
|
333 |
+
Object.keys(thing).forEach(function(key2) {
|
334 |
+
statements_1.push("" + name + safeProp(key2) + "=" + stringify(thing[key2]));
|
335 |
+
});
|
336 |
+
}
|
337 |
+
});
|
338 |
+
statements_1.push("return " + str);
|
339 |
+
return "(function(" + params_1.join(",") + "){" + statements_1.join(";") + "}(" + values_1.join(",") + "))";
|
340 |
+
} else {
|
341 |
+
return str;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
function getName(num) {
|
345 |
+
var name = "";
|
346 |
+
do {
|
347 |
+
name = chars$1[num % chars$1.length] + name;
|
348 |
+
num = ~~(num / chars$1.length) - 1;
|
349 |
+
} while (num >= 0);
|
350 |
+
return reserved.test(name) ? name + "_" : name;
|
351 |
+
}
|
352 |
+
function isPrimitive(thing) {
|
353 |
+
return Object(thing) !== thing;
|
354 |
+
}
|
355 |
+
function stringifyPrimitive(thing) {
|
356 |
+
if (typeof thing === "string")
|
357 |
+
return stringifyString(thing);
|
358 |
+
if (thing === void 0)
|
359 |
+
return "void 0";
|
360 |
+
if (thing === 0 && 1 / thing < 0)
|
361 |
+
return "-0";
|
362 |
+
var str = String(thing);
|
363 |
+
if (typeof thing === "number")
|
364 |
+
return str.replace(/^(-)?0\./, "$1.");
|
365 |
+
return str;
|
366 |
+
}
|
367 |
+
function getType(thing) {
|
368 |
+
return Object.prototype.toString.call(thing).slice(8, -1);
|
369 |
+
}
|
370 |
+
function escapeUnsafeChar(c) {
|
371 |
+
return escaped[c] || c;
|
372 |
+
}
|
373 |
+
function escapeUnsafeChars(str) {
|
374 |
+
return str.replace(unsafeChars, escapeUnsafeChar);
|
375 |
+
}
|
376 |
+
function safeKey(key2) {
|
377 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key2) ? key2 : escapeUnsafeChars(JSON.stringify(key2));
|
378 |
+
}
|
379 |
+
function safeProp(key2) {
|
380 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key2) ? "." + key2 : "[" + escapeUnsafeChars(JSON.stringify(key2)) + "]";
|
381 |
+
}
|
382 |
+
function stringifyString(str) {
|
383 |
+
var result = '"';
|
384 |
+
for (var i = 0; i < str.length; i += 1) {
|
385 |
+
var char = str.charAt(i);
|
386 |
+
var code = char.charCodeAt(0);
|
387 |
+
if (char === '"') {
|
388 |
+
result += '\\"';
|
389 |
+
} else if (char in escaped) {
|
390 |
+
result += escaped[char];
|
391 |
+
} else if (code >= 55296 && code <= 57343) {
|
392 |
+
var next = str.charCodeAt(i + 1);
|
393 |
+
if (code <= 56319 && (next >= 56320 && next <= 57343)) {
|
394 |
+
result += char + str[++i];
|
395 |
+
} else {
|
396 |
+
result += "\\u" + code.toString(16).toUpperCase();
|
397 |
+
}
|
398 |
+
} else {
|
399 |
+
result += char;
|
400 |
+
}
|
401 |
+
}
|
402 |
+
result += '"';
|
403 |
+
return result;
|
404 |
+
}
|
405 |
+
function noop() {
|
406 |
+
}
|
407 |
+
function safe_not_equal(a, b) {
|
408 |
+
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
|
409 |
+
}
|
410 |
+
Promise.resolve();
|
411 |
+
const subscriber_queue = [];
|
412 |
+
function readable(value, start) {
|
413 |
+
return {
|
414 |
+
subscribe: writable(value, start).subscribe
|
415 |
+
};
|
416 |
+
}
|
417 |
+
function writable(value, start = noop) {
|
418 |
+
let stop;
|
419 |
+
const subscribers = /* @__PURE__ */ new Set();
|
420 |
+
function set(new_value) {
|
421 |
+
if (safe_not_equal(value, new_value)) {
|
422 |
+
value = new_value;
|
423 |
+
if (stop) {
|
424 |
+
const run_queue = !subscriber_queue.length;
|
425 |
+
for (const subscriber of subscribers) {
|
426 |
+
subscriber[1]();
|
427 |
+
subscriber_queue.push(subscriber, value);
|
428 |
+
}
|
429 |
+
if (run_queue) {
|
430 |
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
431 |
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
432 |
+
}
|
433 |
+
subscriber_queue.length = 0;
|
434 |
+
}
|
435 |
+
}
|
436 |
+
}
|
437 |
+
}
|
438 |
+
function update(fn) {
|
439 |
+
set(fn(value));
|
440 |
+
}
|
441 |
+
function subscribe(run, invalidate = noop) {
|
442 |
+
const subscriber = [run, invalidate];
|
443 |
+
subscribers.add(subscriber);
|
444 |
+
if (subscribers.size === 1) {
|
445 |
+
stop = start(set) || noop;
|
446 |
+
}
|
447 |
+
run(value);
|
448 |
+
return () => {
|
449 |
+
subscribers.delete(subscriber);
|
450 |
+
if (subscribers.size === 0) {
|
451 |
+
stop();
|
452 |
+
stop = null;
|
453 |
+
}
|
454 |
+
};
|
455 |
+
}
|
456 |
+
return { set, update, subscribe };
|
457 |
+
}
|
458 |
+
function coalesce_to_error(err) {
|
459 |
+
return err instanceof Error || err && err.name && err.message ? err : new Error(JSON.stringify(err));
|
460 |
+
}
|
461 |
+
const render_json_payload_script_dict = {
|
462 |
+
"<": "\\u003C",
|
463 |
+
"\u2028": "\\u2028",
|
464 |
+
"\u2029": "\\u2029"
|
465 |
+
};
|
466 |
+
const render_json_payload_script_regex = new RegExp(`[${Object.keys(render_json_payload_script_dict).join("")}]`, "g");
|
467 |
+
function render_json_payload_script(attrs, payload) {
|
468 |
+
const safe_payload = JSON.stringify(payload).replace(render_json_payload_script_regex, (match) => render_json_payload_script_dict[match]);
|
469 |
+
let safe_attrs = "";
|
470 |
+
for (const [key2, value] of Object.entries(attrs)) {
|
471 |
+
if (value === void 0)
|
472 |
+
continue;
|
473 |
+
safe_attrs += ` sveltekit:data-${key2}=${escape_html_attr(value)}`;
|
474 |
+
}
|
475 |
+
return `<script type="application/json"${safe_attrs}>${safe_payload}<\/script>`;
|
476 |
+
}
|
477 |
+
const escape_html_attr_dict = {
|
478 |
+
"&": "&",
|
479 |
+
'"': """
|
480 |
+
};
|
481 |
+
const escape_html_attr_regex = new RegExp(`[${Object.keys(escape_html_attr_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g");
|
482 |
+
function escape_html_attr(str) {
|
483 |
+
const escaped_str = str.replace(escape_html_attr_regex, (match) => {
|
484 |
+
if (match.length === 2) {
|
485 |
+
return match;
|
486 |
+
}
|
487 |
+
return escape_html_attr_dict[match] ?? `&#${match.charCodeAt(0)};`;
|
488 |
+
});
|
489 |
+
return `"${escaped_str}"`;
|
490 |
+
}
|
491 |
+
const s = JSON.stringify;
|
492 |
+
const encoder = new TextEncoder();
|
493 |
+
function sha256(data) {
|
494 |
+
if (!key[0])
|
495 |
+
precompute();
|
496 |
+
const out = init.slice(0);
|
497 |
+
const array2 = encode$1(data);
|
498 |
+
for (let i = 0; i < array2.length; i += 16) {
|
499 |
+
const w = array2.subarray(i, i + 16);
|
500 |
+
let tmp;
|
501 |
+
let a;
|
502 |
+
let b;
|
503 |
+
let out0 = out[0];
|
504 |
+
let out1 = out[1];
|
505 |
+
let out2 = out[2];
|
506 |
+
let out3 = out[3];
|
507 |
+
let out4 = out[4];
|
508 |
+
let out5 = out[5];
|
509 |
+
let out6 = out[6];
|
510 |
+
let out7 = out[7];
|
511 |
+
for (let i2 = 0; i2 < 64; i2++) {
|
512 |
+
if (i2 < 16) {
|
513 |
+
tmp = w[i2];
|
514 |
+
} else {
|
515 |
+
a = w[i2 + 1 & 15];
|
516 |
+
b = w[i2 + 14 & 15];
|
517 |
+
tmp = w[i2 & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i2 & 15] + w[i2 + 9 & 15] | 0;
|
518 |
+
}
|
519 |
+
tmp = tmp + out7 + (out4 >>> 6 ^ out4 >>> 11 ^ out4 >>> 25 ^ out4 << 26 ^ out4 << 21 ^ out4 << 7) + (out6 ^ out4 & (out5 ^ out6)) + key[i2];
|
520 |
+
out7 = out6;
|
521 |
+
out6 = out5;
|
522 |
+
out5 = out4;
|
523 |
+
out4 = out3 + tmp | 0;
|
524 |
+
out3 = out2;
|
525 |
+
out2 = out1;
|
526 |
+
out1 = out0;
|
527 |
+
out0 = tmp + (out1 & out2 ^ out3 & (out1 ^ out2)) + (out1 >>> 2 ^ out1 >>> 13 ^ out1 >>> 22 ^ out1 << 30 ^ out1 << 19 ^ out1 << 10) | 0;
|
528 |
+
}
|
529 |
+
out[0] = out[0] + out0 | 0;
|
530 |
+
out[1] = out[1] + out1 | 0;
|
531 |
+
out[2] = out[2] + out2 | 0;
|
532 |
+
out[3] = out[3] + out3 | 0;
|
533 |
+
out[4] = out[4] + out4 | 0;
|
534 |
+
out[5] = out[5] + out5 | 0;
|
535 |
+
out[6] = out[6] + out6 | 0;
|
536 |
+
out[7] = out[7] + out7 | 0;
|
537 |
+
}
|
538 |
+
const bytes = new Uint8Array(out.buffer);
|
539 |
+
reverse_endianness(bytes);
|
540 |
+
return base64(bytes);
|
541 |
+
}
|
542 |
+
const init = new Uint32Array(8);
|
543 |
+
const key = new Uint32Array(64);
|
544 |
+
function precompute() {
|
545 |
+
function frac(x) {
|
546 |
+
return (x - Math.floor(x)) * 4294967296;
|
547 |
+
}
|
548 |
+
let prime = 2;
|
549 |
+
for (let i = 0; i < 64; prime++) {
|
550 |
+
let is_prime = true;
|
551 |
+
for (let factor = 2; factor * factor <= prime; factor++) {
|
552 |
+
if (prime % factor === 0) {
|
553 |
+
is_prime = false;
|
554 |
+
break;
|
555 |
+
}
|
556 |
+
}
|
557 |
+
if (is_prime) {
|
558 |
+
if (i < 8) {
|
559 |
+
init[i] = frac(prime ** (1 / 2));
|
560 |
+
}
|
561 |
+
key[i] = frac(prime ** (1 / 3));
|
562 |
+
i++;
|
563 |
+
}
|
564 |
+
}
|
565 |
+
}
|
566 |
+
function reverse_endianness(bytes) {
|
567 |
+
for (let i = 0; i < bytes.length; i += 4) {
|
568 |
+
const a = bytes[i + 0];
|
569 |
+
const b = bytes[i + 1];
|
570 |
+
const c = bytes[i + 2];
|
571 |
+
const d = bytes[i + 3];
|
572 |
+
bytes[i + 0] = d;
|
573 |
+
bytes[i + 1] = c;
|
574 |
+
bytes[i + 2] = b;
|
575 |
+
bytes[i + 3] = a;
|
576 |
+
}
|
577 |
+
}
|
578 |
+
function encode$1(str) {
|
579 |
+
const encoded = encoder.encode(str);
|
580 |
+
const length = encoded.length * 8;
|
581 |
+
const size = 512 * Math.ceil((length + 65) / 512);
|
582 |
+
const bytes = new Uint8Array(size / 8);
|
583 |
+
bytes.set(encoded);
|
584 |
+
bytes[encoded.length] = 128;
|
585 |
+
reverse_endianness(bytes);
|
586 |
+
const words = new Uint32Array(bytes.buffer);
|
587 |
+
words[words.length - 2] = Math.floor(length / 4294967296);
|
588 |
+
words[words.length - 1] = length;
|
589 |
+
return words;
|
590 |
+
}
|
591 |
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
592 |
+
function base64(bytes) {
|
593 |
+
const l = bytes.length;
|
594 |
+
let result = "";
|
595 |
+
let i;
|
596 |
+
for (i = 2; i < l; i += 3) {
|
597 |
+
result += chars[bytes[i - 2] >> 2];
|
598 |
+
result += chars[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
599 |
+
result += chars[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
|
600 |
+
result += chars[bytes[i] & 63];
|
601 |
+
}
|
602 |
+
if (i === l + 1) {
|
603 |
+
result += chars[bytes[i - 2] >> 2];
|
604 |
+
result += chars[(bytes[i - 2] & 3) << 4];
|
605 |
+
result += "==";
|
606 |
+
}
|
607 |
+
if (i === l) {
|
608 |
+
result += chars[bytes[i - 2] >> 2];
|
609 |
+
result += chars[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
610 |
+
result += chars[(bytes[i - 1] & 15) << 2];
|
611 |
+
result += "=";
|
612 |
+
}
|
613 |
+
return result;
|
614 |
+
}
|
615 |
+
let csp_ready;
|
616 |
+
const array = new Uint8Array(16);
|
617 |
+
function generate_nonce() {
|
618 |
+
crypto.getRandomValues(array);
|
619 |
+
return base64(array);
|
620 |
+
}
|
621 |
+
const quoted = /* @__PURE__ */ new Set([
|
622 |
+
"self",
|
623 |
+
"unsafe-eval",
|
624 |
+
"unsafe-hashes",
|
625 |
+
"unsafe-inline",
|
626 |
+
"none",
|
627 |
+
"strict-dynamic",
|
628 |
+
"report-sample"
|
629 |
+
]);
|
630 |
+
const crypto_pattern = /^(nonce|sha\d\d\d)-/;
|
631 |
+
class Csp {
|
632 |
+
#use_hashes;
|
633 |
+
#dev;
|
634 |
+
#script_needs_csp;
|
635 |
+
#style_needs_csp;
|
636 |
+
#directives;
|
637 |
+
#script_src;
|
638 |
+
#style_src;
|
639 |
+
constructor({ mode, directives }, { dev, prerender, needs_nonce }) {
|
640 |
+
this.#use_hashes = mode === "hash" || mode === "auto" && prerender;
|
641 |
+
this.#directives = dev ? { ...directives } : directives;
|
642 |
+
this.#dev = dev;
|
643 |
+
const d = this.#directives;
|
644 |
+
if (dev) {
|
645 |
+
const effective_style_src2 = d["style-src"] || d["default-src"];
|
646 |
+
if (effective_style_src2 && !effective_style_src2.includes("unsafe-inline")) {
|
647 |
+
d["style-src"] = [...effective_style_src2, "unsafe-inline"];
|
648 |
+
}
|
649 |
+
}
|
650 |
+
this.#script_src = [];
|
651 |
+
this.#style_src = [];
|
652 |
+
const effective_script_src = d["script-src"] || d["default-src"];
|
653 |
+
const effective_style_src = d["style-src"] || d["default-src"];
|
654 |
+
this.#script_needs_csp = !!effective_script_src && effective_script_src.filter((value) => value !== "unsafe-inline").length > 0;
|
655 |
+
this.#style_needs_csp = !dev && !!effective_style_src && effective_style_src.filter((value) => value !== "unsafe-inline").length > 0;
|
656 |
+
this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
|
657 |
+
this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
|
658 |
+
if (this.script_needs_nonce || this.style_needs_nonce || needs_nonce) {
|
659 |
+
this.nonce = generate_nonce();
|
660 |
+
}
|
661 |
+
}
|
662 |
+
add_script(content) {
|
663 |
+
if (this.#script_needs_csp) {
|
664 |
+
if (this.#use_hashes) {
|
665 |
+
this.#script_src.push(`sha256-${sha256(content)}`);
|
666 |
+
} else if (this.#script_src.length === 0) {
|
667 |
+
this.#script_src.push(`nonce-${this.nonce}`);
|
668 |
+
}
|
669 |
+
}
|
670 |
+
}
|
671 |
+
add_style(content) {
|
672 |
+
if (this.#style_needs_csp) {
|
673 |
+
if (this.#use_hashes) {
|
674 |
+
this.#style_src.push(`sha256-${sha256(content)}`);
|
675 |
+
} else if (this.#style_src.length === 0) {
|
676 |
+
this.#style_src.push(`nonce-${this.nonce}`);
|
677 |
+
}
|
678 |
+
}
|
679 |
+
}
|
680 |
+
get_header(is_meta = false) {
|
681 |
+
const header = [];
|
682 |
+
const directives = { ...this.#directives };
|
683 |
+
if (this.#style_src.length > 0) {
|
684 |
+
directives["style-src"] = [
|
685 |
+
...directives["style-src"] || directives["default-src"] || [],
|
686 |
+
...this.#style_src
|
687 |
+
];
|
688 |
+
}
|
689 |
+
if (this.#script_src.length > 0) {
|
690 |
+
directives["script-src"] = [
|
691 |
+
...directives["script-src"] || directives["default-src"] || [],
|
692 |
+
...this.#script_src
|
693 |
+
];
|
694 |
+
}
|
695 |
+
for (const key2 in directives) {
|
696 |
+
if (is_meta && (key2 === "frame-ancestors" || key2 === "report-uri" || key2 === "sandbox")) {
|
697 |
+
continue;
|
698 |
+
}
|
699 |
+
const value = directives[key2];
|
700 |
+
if (!value)
|
701 |
+
continue;
|
702 |
+
const directive = [key2];
|
703 |
+
if (Array.isArray(value)) {
|
704 |
+
value.forEach((value2) => {
|
705 |
+
if (quoted.has(value2) || crypto_pattern.test(value2)) {
|
706 |
+
directive.push(`'${value2}'`);
|
707 |
+
} else {
|
708 |
+
directive.push(value2);
|
709 |
+
}
|
710 |
+
});
|
711 |
+
}
|
712 |
+
header.push(directive.join(" "));
|
713 |
+
}
|
714 |
+
return header.join("; ");
|
715 |
+
}
|
716 |
+
get_meta() {
|
717 |
+
const content = escape_html_attr(this.get_header(true));
|
718 |
+
return `<meta http-equiv="content-security-policy" content=${content}>`;
|
719 |
+
}
|
720 |
+
}
|
721 |
+
const absolute = /^([a-z]+:)?\/?\//;
|
722 |
+
const scheme = /^[a-z]+:/;
|
723 |
+
function resolve(base2, path) {
|
724 |
+
if (scheme.test(path))
|
725 |
+
return path;
|
726 |
+
const base_match = absolute.exec(base2);
|
727 |
+
const path_match = absolute.exec(path);
|
728 |
+
if (!base_match) {
|
729 |
+
throw new Error(`bad base path: "${base2}"`);
|
730 |
+
}
|
731 |
+
const baseparts = path_match ? [] : base2.slice(base_match[0].length).split("/");
|
732 |
+
const pathparts = path_match ? path.slice(path_match[0].length).split("/") : path.split("/");
|
733 |
+
baseparts.pop();
|
734 |
+
for (let i = 0; i < pathparts.length; i += 1) {
|
735 |
+
const part = pathparts[i];
|
736 |
+
if (part === ".")
|
737 |
+
continue;
|
738 |
+
else if (part === "..")
|
739 |
+
baseparts.pop();
|
740 |
+
else
|
741 |
+
baseparts.push(part);
|
742 |
+
}
|
743 |
+
const prefix = path_match && path_match[0] || base_match && base_match[0] || "";
|
744 |
+
return `${prefix}${baseparts.join("/")}`;
|
745 |
+
}
|
746 |
+
function is_root_relative(path) {
|
747 |
+
return path[0] === "/" && path[1] !== "/";
|
748 |
+
}
|
749 |
+
function normalize_path(path, trailing_slash) {
|
750 |
+
if (path === "/" || trailing_slash === "ignore")
|
751 |
+
return path;
|
752 |
+
if (trailing_slash === "never") {
|
753 |
+
return path.endsWith("/") ? path.slice(0, -1) : path;
|
754 |
+
} else if (trailing_slash === "always" && !path.endsWith("/")) {
|
755 |
+
return path + "/";
|
756 |
+
}
|
757 |
+
return path;
|
758 |
+
}
|
759 |
+
class LoadURL extends URL {
|
760 |
+
get hash() {
|
761 |
+
throw new Error("url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component.");
|
762 |
+
}
|
763 |
+
}
|
764 |
+
class PrerenderingURL extends URL {
|
765 |
+
get search() {
|
766 |
+
throw new Error("Cannot access url.search on a page with prerendering enabled");
|
767 |
+
}
|
768 |
+
get searchParams() {
|
769 |
+
throw new Error("Cannot access url.searchParams on a page with prerendering enabled");
|
770 |
+
}
|
771 |
+
}
|
772 |
+
const updated = {
|
773 |
+
...readable(false),
|
774 |
+
check: () => false
|
775 |
+
};
|
776 |
+
async function render_response({
|
777 |
+
branch,
|
778 |
+
options,
|
779 |
+
state,
|
780 |
+
$session,
|
781 |
+
page_config,
|
782 |
+
status,
|
783 |
+
error: error2 = null,
|
784 |
+
event,
|
785 |
+
resolve_opts,
|
786 |
+
stuff
|
787 |
+
}) {
|
788 |
+
if (state.prerendering) {
|
789 |
+
if (options.csp.mode === "nonce") {
|
790 |
+
throw new Error('Cannot use prerendering if config.kit.csp.mode === "nonce"');
|
791 |
+
}
|
792 |
+
if (options.template_contains_nonce) {
|
793 |
+
throw new Error("Cannot use prerendering if page template contains %sveltekit.nonce%");
|
794 |
+
}
|
795 |
+
}
|
796 |
+
const stylesheets = new Set(options.manifest._.entry.css);
|
797 |
+
const modulepreloads = new Set(options.manifest._.entry.js);
|
798 |
+
const styles = /* @__PURE__ */ new Map();
|
799 |
+
const serialized_data = [];
|
800 |
+
let shadow_props;
|
801 |
+
let rendered;
|
802 |
+
let is_private = false;
|
803 |
+
let cache;
|
804 |
+
if (error2) {
|
805 |
+
error2.stack = options.get_stack(error2);
|
806 |
+
}
|
807 |
+
if (resolve_opts.ssr) {
|
808 |
+
branch.forEach(({ node, props: props2, loaded, fetched, uses_credentials }) => {
|
809 |
+
if (node.css)
|
810 |
+
node.css.forEach((url) => stylesheets.add(url));
|
811 |
+
if (node.js)
|
812 |
+
node.js.forEach((url) => modulepreloads.add(url));
|
813 |
+
if (node.styles)
|
814 |
+
Object.entries(node.styles).forEach(([k, v]) => styles.set(k, v));
|
815 |
+
if (fetched && page_config.hydrate)
|
816 |
+
serialized_data.push(...fetched);
|
817 |
+
if (props2)
|
818 |
+
shadow_props = props2;
|
819 |
+
cache = loaded == null ? void 0 : loaded.cache;
|
820 |
+
is_private = (cache == null ? void 0 : cache.private) ?? uses_credentials;
|
821 |
+
});
|
822 |
+
const session = writable($session);
|
823 |
+
const props = {
|
824 |
+
stores: {
|
825 |
+
page: writable(null),
|
826 |
+
navigating: writable(null),
|
827 |
+
session: {
|
828 |
+
...session,
|
829 |
+
subscribe: (fn) => {
|
830 |
+
is_private = (cache == null ? void 0 : cache.private) ?? true;
|
831 |
+
return session.subscribe(fn);
|
832 |
+
}
|
833 |
+
},
|
834 |
+
updated
|
835 |
+
},
|
836 |
+
page: {
|
837 |
+
error: error2,
|
838 |
+
params: event.params,
|
839 |
+
routeId: event.routeId,
|
840 |
+
status,
|
841 |
+
stuff,
|
842 |
+
url: state.prerendering ? new PrerenderingURL(event.url) : event.url
|
843 |
+
},
|
844 |
+
components: branch.map(({ node }) => node.module.default)
|
845 |
+
};
|
846 |
+
const print_error = (property, replacement) => {
|
847 |
+
Object.defineProperty(props.page, property, {
|
848 |
+
get: () => {
|
849 |
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
850 |
+
}
|
851 |
+
});
|
852 |
+
};
|
853 |
+
print_error("origin", "origin");
|
854 |
+
print_error("path", "pathname");
|
855 |
+
print_error("query", "searchParams");
|
856 |
+
for (let i = 0; i < branch.length; i += 1) {
|
857 |
+
props[`props_${i}`] = await branch[i].loaded.props;
|
858 |
+
}
|
859 |
+
rendered = options.root.render(props);
|
860 |
+
} else {
|
861 |
+
rendered = { head: "", html: "", css: { code: "", map: null } };
|
862 |
+
}
|
863 |
+
let { head, html: body } = rendered;
|
864 |
+
const inlined_style = Array.from(styles.values()).join("\n");
|
865 |
+
await csp_ready;
|
866 |
+
const csp = new Csp(options.csp, {
|
867 |
+
dev: options.dev,
|
868 |
+
prerender: !!state.prerendering,
|
869 |
+
needs_nonce: options.template_contains_nonce
|
870 |
+
});
|
871 |
+
const target = hash(body);
|
872 |
+
const init_app = `
|
873 |
+
import { start } from ${s(options.prefix + options.manifest._.entry.file)};
|
874 |
+
start({
|
875 |
+
target: document.querySelector('[data-sveltekit-hydrate="${target}"]').parentNode,
|
876 |
+
paths: ${s(options.paths)},
|
877 |
+
session: ${try_serialize($session, (error3) => {
|
878 |
+
throw new Error(`Failed to serialize session data: ${error3.message}`);
|
879 |
+
})},
|
880 |
+
route: ${!!page_config.router},
|
881 |
+
spa: ${!resolve_opts.ssr},
|
882 |
+
trailing_slash: ${s(options.trailing_slash)},
|
883 |
+
hydrate: ${resolve_opts.ssr && page_config.hydrate ? `{
|
884 |
+
status: ${status},
|
885 |
+
error: ${serialize_error(error2)},
|
886 |
+
nodes: [${branch.map(({ node }) => node.index).join(", ")}],
|
887 |
+
params: ${devalue(event.params)},
|
888 |
+
routeId: ${s(event.routeId)}
|
889 |
+
}` : "null"}
|
890 |
+
});
|
891 |
+
`;
|
892 |
+
const init_service_worker = `
|
893 |
+
if ('serviceWorker' in navigator) {
|
894 |
+
addEventListener('load', () => {
|
895 |
+
navigator.serviceWorker.register('${options.service_worker}');
|
896 |
+
});
|
897 |
+
}
|
898 |
+
`;
|
899 |
+
if (inlined_style) {
|
900 |
+
const attributes = [];
|
901 |
+
if (options.dev)
|
902 |
+
attributes.push(" data-sveltekit");
|
903 |
+
if (csp.style_needs_nonce)
|
904 |
+
attributes.push(` nonce="${csp.nonce}"`);
|
905 |
+
csp.add_style(inlined_style);
|
906 |
+
head += `
|
907 |
+
<style${attributes.join("")}>${inlined_style}</style>`;
|
908 |
+
}
|
909 |
+
head += Array.from(stylesheets).map((dep) => {
|
910 |
+
const attributes = [
|
911 |
+
'rel="stylesheet"',
|
912 |
+
`href="${options.prefix + dep}"`
|
913 |
+
];
|
914 |
+
if (csp.style_needs_nonce) {
|
915 |
+
attributes.push(`nonce="${csp.nonce}"`);
|
916 |
+
}
|
917 |
+
if (styles.has(dep)) {
|
918 |
+
attributes.push("disabled", 'media="(max-width: 0)"');
|
919 |
+
}
|
920 |
+
return `
|
921 |
+
<link ${attributes.join(" ")}>`;
|
922 |
+
}).join("");
|
923 |
+
if (page_config.router || page_config.hydrate) {
|
924 |
+
head += Array.from(modulepreloads).map((dep) => `
|
925 |
+
<link rel="modulepreload" href="${options.prefix + dep}">`).join("");
|
926 |
+
const attributes = ['type="module"', `data-sveltekit-hydrate="${target}"`];
|
927 |
+
csp.add_script(init_app);
|
928 |
+
if (csp.script_needs_nonce) {
|
929 |
+
attributes.push(`nonce="${csp.nonce}"`);
|
930 |
+
}
|
931 |
+
body += `
|
932 |
+
<script ${attributes.join(" ")}>${init_app}<\/script>`;
|
933 |
+
body += serialized_data.map(({ url, body: body2, response }) => render_json_payload_script({ type: "data", url, body: typeof body2 === "string" ? hash(body2) : void 0 }, response)).join("\n ");
|
934 |
+
if (shadow_props) {
|
935 |
+
body += render_json_payload_script({ type: "props" }, shadow_props);
|
936 |
+
}
|
937 |
+
}
|
938 |
+
if (options.service_worker) {
|
939 |
+
csp.add_script(init_service_worker);
|
940 |
+
head += `
|
941 |
+
<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>${init_service_worker}<\/script>`;
|
942 |
+
}
|
943 |
+
if (state.prerendering) {
|
944 |
+
const http_equiv = [];
|
945 |
+
const csp_headers = csp.get_meta();
|
946 |
+
if (csp_headers) {
|
947 |
+
http_equiv.push(csp_headers);
|
948 |
+
}
|
949 |
+
if (cache) {
|
950 |
+
http_equiv.push(`<meta http-equiv="cache-control" content="max-age=${cache.maxage}">`);
|
951 |
+
}
|
952 |
+
if (http_equiv.length > 0) {
|
953 |
+
head = http_equiv.join("\n") + head;
|
954 |
+
}
|
955 |
+
}
|
956 |
+
const segments = event.url.pathname.slice(options.paths.base.length).split("/").slice(2);
|
957 |
+
const assets2 = options.paths.assets || (segments.length > 0 ? segments.map(() => "..").join("/") : ".");
|
958 |
+
const html = await resolve_opts.transformPage({
|
959 |
+
html: options.template({ head, body, assets: assets2, nonce: csp.nonce })
|
960 |
+
});
|
961 |
+
const headers = new Headers({
|
962 |
+
"content-type": "text/html",
|
963 |
+
etag: `"${hash(html)}"`
|
964 |
+
});
|
965 |
+
if (cache) {
|
966 |
+
headers.set("cache-control", `${is_private ? "private" : "public"}, max-age=${cache.maxage}`);
|
967 |
+
}
|
968 |
+
if (!options.floc) {
|
969 |
+
headers.set("permissions-policy", "interest-cohort=()");
|
970 |
+
}
|
971 |
+
if (!state.prerendering) {
|
972 |
+
const csp_header = csp.get_header();
|
973 |
+
if (csp_header) {
|
974 |
+
headers.set("content-security-policy", csp_header);
|
975 |
+
}
|
976 |
+
}
|
977 |
+
return new Response(html, {
|
978 |
+
status,
|
979 |
+
headers
|
980 |
+
});
|
981 |
+
}
|
982 |
+
function try_serialize(data, fail) {
|
983 |
+
try {
|
984 |
+
return devalue(data);
|
985 |
+
} catch (err) {
|
986 |
+
if (fail)
|
987 |
+
fail(coalesce_to_error(err));
|
988 |
+
return null;
|
989 |
+
}
|
990 |
+
}
|
991 |
+
function serialize_error(error2) {
|
992 |
+
if (!error2)
|
993 |
+
return null;
|
994 |
+
let serialized = try_serialize(error2);
|
995 |
+
if (!serialized) {
|
996 |
+
const { name, message, stack } = error2;
|
997 |
+
serialized = try_serialize({ ...error2, name, message, stack });
|
998 |
+
}
|
999 |
+
if (!serialized) {
|
1000 |
+
serialized = "{}";
|
1001 |
+
}
|
1002 |
+
return serialized;
|
1003 |
+
}
|
1004 |
+
/*!
|
1005 |
+
* cookie
|
1006 |
+
* Copyright(c) 2012-2014 Roman Shtylman
|
1007 |
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
1008 |
+
* MIT Licensed
|
1009 |
+
*/
|
1010 |
+
var parse_1 = parse$1;
|
1011 |
+
var serialize_1 = serialize;
|
1012 |
+
var __toString = Object.prototype.toString;
|
1013 |
+
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
1014 |
+
function parse$1(str, options) {
|
1015 |
+
if (typeof str !== "string") {
|
1016 |
+
throw new TypeError("argument str must be a string");
|
1017 |
+
}
|
1018 |
+
var obj = {};
|
1019 |
+
var opt = options || {};
|
1020 |
+
var dec = opt.decode || decode;
|
1021 |
+
var index = 0;
|
1022 |
+
while (index < str.length) {
|
1023 |
+
var eqIdx = str.indexOf("=", index);
|
1024 |
+
if (eqIdx === -1) {
|
1025 |
+
break;
|
1026 |
+
}
|
1027 |
+
var endIdx = str.indexOf(";", index);
|
1028 |
+
if (endIdx === -1) {
|
1029 |
+
endIdx = str.length;
|
1030 |
+
} else if (endIdx < eqIdx) {
|
1031 |
+
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
1032 |
+
continue;
|
1033 |
+
}
|
1034 |
+
var key2 = str.slice(index, eqIdx).trim();
|
1035 |
+
if (obj[key2] === void 0) {
|
1036 |
+
var val = str.slice(eqIdx + 1, endIdx).trim();
|
1037 |
+
if (val.charCodeAt(0) === 34) {
|
1038 |
+
val = val.slice(1, -1);
|
1039 |
+
}
|
1040 |
+
obj[key2] = tryDecode(val, dec);
|
1041 |
+
}
|
1042 |
+
index = endIdx + 1;
|
1043 |
+
}
|
1044 |
+
return obj;
|
1045 |
+
}
|
1046 |
+
function serialize(name, val, options) {
|
1047 |
+
var opt = options || {};
|
1048 |
+
var enc = opt.encode || encode;
|
1049 |
+
if (typeof enc !== "function") {
|
1050 |
+
throw new TypeError("option encode is invalid");
|
1051 |
+
}
|
1052 |
+
if (!fieldContentRegExp.test(name)) {
|
1053 |
+
throw new TypeError("argument name is invalid");
|
1054 |
+
}
|
1055 |
+
var value = enc(val);
|
1056 |
+
if (value && !fieldContentRegExp.test(value)) {
|
1057 |
+
throw new TypeError("argument val is invalid");
|
1058 |
+
}
|
1059 |
+
var str = name + "=" + value;
|
1060 |
+
if (opt.maxAge != null) {
|
1061 |
+
var maxAge = opt.maxAge - 0;
|
1062 |
+
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
1063 |
+
throw new TypeError("option maxAge is invalid");
|
1064 |
+
}
|
1065 |
+
str += "; Max-Age=" + Math.floor(maxAge);
|
1066 |
+
}
|
1067 |
+
if (opt.domain) {
|
1068 |
+
if (!fieldContentRegExp.test(opt.domain)) {
|
1069 |
+
throw new TypeError("option domain is invalid");
|
1070 |
+
}
|
1071 |
+
str += "; Domain=" + opt.domain;
|
1072 |
+
}
|
1073 |
+
if (opt.path) {
|
1074 |
+
if (!fieldContentRegExp.test(opt.path)) {
|
1075 |
+
throw new TypeError("option path is invalid");
|
1076 |
+
}
|
1077 |
+
str += "; Path=" + opt.path;
|
1078 |
+
}
|
1079 |
+
if (opt.expires) {
|
1080 |
+
var expires = opt.expires;
|
1081 |
+
if (!isDate(expires) || isNaN(expires.valueOf())) {
|
1082 |
+
throw new TypeError("option expires is invalid");
|
1083 |
+
}
|
1084 |
+
str += "; Expires=" + expires.toUTCString();
|
1085 |
+
}
|
1086 |
+
if (opt.httpOnly) {
|
1087 |
+
str += "; HttpOnly";
|
1088 |
+
}
|
1089 |
+
if (opt.secure) {
|
1090 |
+
str += "; Secure";
|
1091 |
+
}
|
1092 |
+
if (opt.priority) {
|
1093 |
+
var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
|
1094 |
+
switch (priority) {
|
1095 |
+
case "low":
|
1096 |
+
str += "; Priority=Low";
|
1097 |
+
break;
|
1098 |
+
case "medium":
|
1099 |
+
str += "; Priority=Medium";
|
1100 |
+
break;
|
1101 |
+
case "high":
|
1102 |
+
str += "; Priority=High";
|
1103 |
+
break;
|
1104 |
+
default:
|
1105 |
+
throw new TypeError("option priority is invalid");
|
1106 |
+
}
|
1107 |
+
}
|
1108 |
+
if (opt.sameSite) {
|
1109 |
+
var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
|
1110 |
+
switch (sameSite) {
|
1111 |
+
case true:
|
1112 |
+
str += "; SameSite=Strict";
|
1113 |
+
break;
|
1114 |
+
case "lax":
|
1115 |
+
str += "; SameSite=Lax";
|
1116 |
+
break;
|
1117 |
+
case "strict":
|
1118 |
+
str += "; SameSite=Strict";
|
1119 |
+
break;
|
1120 |
+
case "none":
|
1121 |
+
str += "; SameSite=None";
|
1122 |
+
break;
|
1123 |
+
default:
|
1124 |
+
throw new TypeError("option sameSite is invalid");
|
1125 |
+
}
|
1126 |
+
}
|
1127 |
+
return str;
|
1128 |
+
}
|
1129 |
+
function decode(str) {
|
1130 |
+
return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
|
1131 |
+
}
|
1132 |
+
function encode(val) {
|
1133 |
+
return encodeURIComponent(val);
|
1134 |
+
}
|
1135 |
+
function isDate(val) {
|
1136 |
+
return __toString.call(val) === "[object Date]" || val instanceof Date;
|
1137 |
+
}
|
1138 |
+
function tryDecode(str, decode2) {
|
1139 |
+
try {
|
1140 |
+
return decode2(str);
|
1141 |
+
} catch (e) {
|
1142 |
+
return str;
|
1143 |
+
}
|
1144 |
+
}
|
1145 |
+
var setCookie = { exports: {} };
|
1146 |
+
var defaultParseOptions = {
|
1147 |
+
decodeValues: true,
|
1148 |
+
map: false,
|
1149 |
+
silent: false
|
1150 |
+
};
|
1151 |
+
function isNonEmptyString(str) {
|
1152 |
+
return typeof str === "string" && !!str.trim();
|
1153 |
+
}
|
1154 |
+
function parseString(setCookieValue, options) {
|
1155 |
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
1156 |
+
var nameValue = parts.shift().split("=");
|
1157 |
+
var name = nameValue.shift();
|
1158 |
+
var value = nameValue.join("=");
|
1159 |
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
1160 |
+
try {
|
1161 |
+
value = options.decodeValues ? decodeURIComponent(value) : value;
|
1162 |
+
} catch (e) {
|
1163 |
+
console.error("set-cookie-parser encountered an error while decoding a cookie with value '" + value + "'. Set options.decodeValues to false to disable this feature.", e);
|
1164 |
+
}
|
1165 |
+
var cookie = {
|
1166 |
+
name,
|
1167 |
+
value
|
1168 |
+
};
|
1169 |
+
parts.forEach(function(part) {
|
1170 |
+
var sides = part.split("=");
|
1171 |
+
var key2 = sides.shift().trimLeft().toLowerCase();
|
1172 |
+
var value2 = sides.join("=");
|
1173 |
+
if (key2 === "expires") {
|
1174 |
+
cookie.expires = new Date(value2);
|
1175 |
+
} else if (key2 === "max-age") {
|
1176 |
+
cookie.maxAge = parseInt(value2, 10);
|
1177 |
+
} else if (key2 === "secure") {
|
1178 |
+
cookie.secure = true;
|
1179 |
+
} else if (key2 === "httponly") {
|
1180 |
+
cookie.httpOnly = true;
|
1181 |
+
} else if (key2 === "samesite") {
|
1182 |
+
cookie.sameSite = value2;
|
1183 |
+
} else {
|
1184 |
+
cookie[key2] = value2;
|
1185 |
+
}
|
1186 |
+
});
|
1187 |
+
return cookie;
|
1188 |
+
}
|
1189 |
+
function parse(input, options) {
|
1190 |
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
1191 |
+
if (!input) {
|
1192 |
+
if (!options.map) {
|
1193 |
+
return [];
|
1194 |
+
} else {
|
1195 |
+
return {};
|
1196 |
+
}
|
1197 |
+
}
|
1198 |
+
if (input.headers && input.headers["set-cookie"]) {
|
1199 |
+
input = input.headers["set-cookie"];
|
1200 |
+
} else if (input.headers) {
|
1201 |
+
var sch = input.headers[Object.keys(input.headers).find(function(key2) {
|
1202 |
+
return key2.toLowerCase() === "set-cookie";
|
1203 |
+
})];
|
1204 |
+
if (!sch && input.headers.cookie && !options.silent) {
|
1205 |
+
console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning.");
|
1206 |
+
}
|
1207 |
+
input = sch;
|
1208 |
+
}
|
1209 |
+
if (!Array.isArray(input)) {
|
1210 |
+
input = [input];
|
1211 |
+
}
|
1212 |
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
1213 |
+
if (!options.map) {
|
1214 |
+
return input.filter(isNonEmptyString).map(function(str) {
|
1215 |
+
return parseString(str, options);
|
1216 |
+
});
|
1217 |
+
} else {
|
1218 |
+
var cookies = {};
|
1219 |
+
return input.filter(isNonEmptyString).reduce(function(cookies2, str) {
|
1220 |
+
var cookie = parseString(str, options);
|
1221 |
+
cookies2[cookie.name] = cookie;
|
1222 |
+
return cookies2;
|
1223 |
+
}, cookies);
|
1224 |
+
}
|
1225 |
+
}
|
1226 |
+
function splitCookiesString(cookiesString) {
|
1227 |
+
if (Array.isArray(cookiesString)) {
|
1228 |
+
return cookiesString;
|
1229 |
+
}
|
1230 |
+
if (typeof cookiesString !== "string") {
|
1231 |
+
return [];
|
1232 |
+
}
|
1233 |
+
var cookiesStrings = [];
|
1234 |
+
var pos = 0;
|
1235 |
+
var start;
|
1236 |
+
var ch;
|
1237 |
+
var lastComma;
|
1238 |
+
var nextStart;
|
1239 |
+
var cookiesSeparatorFound;
|
1240 |
+
function skipWhitespace() {
|
1241 |
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
1242 |
+
pos += 1;
|
1243 |
+
}
|
1244 |
+
return pos < cookiesString.length;
|
1245 |
+
}
|
1246 |
+
function notSpecialChar() {
|
1247 |
+
ch = cookiesString.charAt(pos);
|
1248 |
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
1249 |
+
}
|
1250 |
+
while (pos < cookiesString.length) {
|
1251 |
+
start = pos;
|
1252 |
+
cookiesSeparatorFound = false;
|
1253 |
+
while (skipWhitespace()) {
|
1254 |
+
ch = cookiesString.charAt(pos);
|
1255 |
+
if (ch === ",") {
|
1256 |
+
lastComma = pos;
|
1257 |
+
pos += 1;
|
1258 |
+
skipWhitespace();
|
1259 |
+
nextStart = pos;
|
1260 |
+
while (pos < cookiesString.length && notSpecialChar()) {
|
1261 |
+
pos += 1;
|
1262 |
+
}
|
1263 |
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
1264 |
+
cookiesSeparatorFound = true;
|
1265 |
+
pos = nextStart;
|
1266 |
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
1267 |
+
start = pos;
|
1268 |
+
} else {
|
1269 |
+
pos = lastComma + 1;
|
1270 |
+
}
|
1271 |
+
} else {
|
1272 |
+
pos += 1;
|
1273 |
+
}
|
1274 |
+
}
|
1275 |
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
1276 |
+
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
1277 |
+
}
|
1278 |
+
}
|
1279 |
+
return cookiesStrings;
|
1280 |
+
}
|
1281 |
+
setCookie.exports = parse;
|
1282 |
+
setCookie.exports.parse = parse;
|
1283 |
+
var parseString_1 = setCookie.exports.parseString = parseString;
|
1284 |
+
var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
|
1285 |
+
function normalize(loaded) {
|
1286 |
+
if (loaded.fallthrough) {
|
1287 |
+
throw new Error("fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching");
|
1288 |
+
}
|
1289 |
+
if ("maxage" in loaded) {
|
1290 |
+
throw new Error("maxage should be replaced with cache: { maxage }");
|
1291 |
+
}
|
1292 |
+
const has_error_status = loaded.status && loaded.status >= 400 && loaded.status <= 599 && !loaded.redirect;
|
1293 |
+
if (loaded.error || has_error_status) {
|
1294 |
+
const status = loaded.status;
|
1295 |
+
if (!loaded.error && has_error_status) {
|
1296 |
+
return { status: status || 500, error: new Error() };
|
1297 |
+
}
|
1298 |
+
const error2 = typeof loaded.error === "string" ? new Error(loaded.error) : loaded.error;
|
1299 |
+
if (!(error2 instanceof Error)) {
|
1300 |
+
return {
|
1301 |
+
status: 500,
|
1302 |
+
error: new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof error2}"`)
|
1303 |
+
};
|
1304 |
+
}
|
1305 |
+
if (!status || status < 400 || status > 599) {
|
1306 |
+
console.warn('"error" returned from load() without a valid status code \u2014 defaulting to 500');
|
1307 |
+
return { status: 500, error: error2 };
|
1308 |
+
}
|
1309 |
+
return { status, error: error2 };
|
1310 |
+
}
|
1311 |
+
if (loaded.redirect) {
|
1312 |
+
if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
|
1313 |
+
throw new Error('"redirect" property returned from load() must be accompanied by a 3xx status code');
|
1314 |
+
}
|
1315 |
+
if (typeof loaded.redirect !== "string") {
|
1316 |
+
throw new Error('"redirect" property returned from load() must be a string');
|
1317 |
+
}
|
1318 |
+
}
|
1319 |
+
if (loaded.dependencies) {
|
1320 |
+
if (!Array.isArray(loaded.dependencies) || loaded.dependencies.some((dep) => typeof dep !== "string")) {
|
1321 |
+
throw new Error('"dependencies" property returned from load() must be of type string[]');
|
1322 |
+
}
|
1323 |
+
}
|
1324 |
+
if (loaded.context) {
|
1325 |
+
throw new Error('You are returning "context" from a load function. "context" was renamed to "stuff", please adjust your code accordingly.');
|
1326 |
+
}
|
1327 |
+
return loaded;
|
1328 |
+
}
|
1329 |
+
function domain_matches(hostname, constraint) {
|
1330 |
+
if (!constraint)
|
1331 |
+
return true;
|
1332 |
+
const normalized = constraint[0] === "." ? constraint.slice(1) : constraint;
|
1333 |
+
if (hostname === normalized)
|
1334 |
+
return true;
|
1335 |
+
return hostname.endsWith("." + normalized);
|
1336 |
+
}
|
1337 |
+
function path_matches(path, constraint) {
|
1338 |
+
if (!constraint)
|
1339 |
+
return true;
|
1340 |
+
const normalized = constraint.endsWith("/") ? constraint.slice(0, -1) : constraint;
|
1341 |
+
if (path === normalized)
|
1342 |
+
return true;
|
1343 |
+
return path.startsWith(normalized + "/");
|
1344 |
+
}
|
1345 |
+
async function load_node({
|
1346 |
+
event,
|
1347 |
+
options,
|
1348 |
+
state,
|
1349 |
+
route,
|
1350 |
+
node,
|
1351 |
+
$session,
|
1352 |
+
stuff,
|
1353 |
+
is_error,
|
1354 |
+
is_leaf,
|
1355 |
+
status,
|
1356 |
+
error: error2
|
1357 |
+
}) {
|
1358 |
+
const { module } = node;
|
1359 |
+
let uses_credentials = false;
|
1360 |
+
const fetched = [];
|
1361 |
+
const cookies = parse_1(event.request.headers.get("cookie") || "");
|
1362 |
+
const new_cookies = [];
|
1363 |
+
let loaded;
|
1364 |
+
const should_prerender = node.module.prerender ?? options.prerender.default;
|
1365 |
+
const shadow = is_leaf ? await load_shadow_data(route, event, options, should_prerender) : {};
|
1366 |
+
if (shadow.cookies) {
|
1367 |
+
shadow.cookies.forEach((header) => {
|
1368 |
+
new_cookies.push(parseString_1(header));
|
1369 |
+
});
|
1370 |
+
}
|
1371 |
+
if (shadow.error) {
|
1372 |
+
loaded = {
|
1373 |
+
status: shadow.status,
|
1374 |
+
error: shadow.error
|
1375 |
+
};
|
1376 |
+
} else if (shadow.redirect) {
|
1377 |
+
loaded = {
|
1378 |
+
status: shadow.status,
|
1379 |
+
redirect: shadow.redirect
|
1380 |
+
};
|
1381 |
+
} else if (module.load) {
|
1382 |
+
const load_input = {
|
1383 |
+
url: state.prerendering ? new PrerenderingURL(event.url) : new LoadURL(event.url),
|
1384 |
+
params: event.params,
|
1385 |
+
props: shadow.body || {},
|
1386 |
+
routeId: event.routeId,
|
1387 |
+
get session() {
|
1388 |
+
if (node.module.prerender ?? options.prerender.default) {
|
1389 |
+
throw Error("Attempted to access session from a prerendered page. Session would never be populated.");
|
1390 |
+
}
|
1391 |
+
uses_credentials = true;
|
1392 |
+
return $session;
|
1393 |
+
},
|
1394 |
+
fetch: async (resource, opts = {}) => {
|
1395 |
+
let requested;
|
1396 |
+
if (typeof resource === "string") {
|
1397 |
+
requested = resource;
|
1398 |
+
} else {
|
1399 |
+
requested = resource.url;
|
1400 |
+
opts = {
|
1401 |
+
method: resource.method,
|
1402 |
+
headers: resource.headers,
|
1403 |
+
body: resource.body,
|
1404 |
+
mode: resource.mode,
|
1405 |
+
credentials: resource.credentials,
|
1406 |
+
cache: resource.cache,
|
1407 |
+
redirect: resource.redirect,
|
1408 |
+
referrer: resource.referrer,
|
1409 |
+
integrity: resource.integrity,
|
1410 |
+
...opts
|
1411 |
+
};
|
1412 |
+
}
|
1413 |
+
opts.headers = new Headers(opts.headers);
|
1414 |
+
for (const [key2, value] of event.request.headers) {
|
1415 |
+
if (key2 !== "authorization" && key2 !== "cookie" && key2 !== "host" && key2 !== "if-none-match" && !opts.headers.has(key2)) {
|
1416 |
+
opts.headers.set(key2, value);
|
1417 |
+
}
|
1418 |
+
}
|
1419 |
+
const resolved = resolve(event.url.pathname, requested.split("?")[0]);
|
1420 |
+
let response;
|
1421 |
+
let dependency;
|
1422 |
+
const prefix = options.paths.assets || options.paths.base;
|
1423 |
+
const filename = decodeURIComponent(resolved.startsWith(prefix) ? resolved.slice(prefix.length) : resolved).slice(1);
|
1424 |
+
const filename_html = `${filename}/index.html`;
|
1425 |
+
const is_asset = options.manifest.assets.has(filename);
|
1426 |
+
const is_asset_html = options.manifest.assets.has(filename_html);
|
1427 |
+
if (is_asset || is_asset_html) {
|
1428 |
+
const file = is_asset ? filename : filename_html;
|
1429 |
+
if (options.read) {
|
1430 |
+
const type = is_asset ? options.manifest.mimeTypes[filename.slice(filename.lastIndexOf("."))] : "text/html";
|
1431 |
+
response = new Response(options.read(file), {
|
1432 |
+
headers: type ? { "content-type": type } : {}
|
1433 |
+
});
|
1434 |
+
} else {
|
1435 |
+
response = await fetch(`${event.url.origin}/${file}`, opts);
|
1436 |
+
}
|
1437 |
+
} else if (is_root_relative(resolved)) {
|
1438 |
+
if (opts.credentials !== "omit") {
|
1439 |
+
uses_credentials = true;
|
1440 |
+
const authorization = event.request.headers.get("authorization");
|
1441 |
+
const combined_cookies = { ...cookies };
|
1442 |
+
for (const cookie2 of new_cookies) {
|
1443 |
+
if (!domain_matches(event.url.hostname, cookie2.domain))
|
1444 |
+
continue;
|
1445 |
+
if (!path_matches(resolved, cookie2.path))
|
1446 |
+
continue;
|
1447 |
+
combined_cookies[cookie2.name] = cookie2.value;
|
1448 |
+
}
|
1449 |
+
const cookie = Object.entries(combined_cookies).map(([name, value]) => `${name}=${value}`).join("; ");
|
1450 |
+
if (cookie) {
|
1451 |
+
opts.headers.set("cookie", cookie);
|
1452 |
+
}
|
1453 |
+
if (authorization && !opts.headers.has("authorization")) {
|
1454 |
+
opts.headers.set("authorization", authorization);
|
1455 |
+
}
|
1456 |
+
}
|
1457 |
+
if (opts.body && typeof opts.body !== "string") {
|
1458 |
+
throw new Error("Request body must be a string");
|
1459 |
+
}
|
1460 |
+
response = await respond(new Request(new URL(requested, event.url).href, { ...opts }), options, {
|
1461 |
+
...state,
|
1462 |
+
initiator: route
|
1463 |
+
});
|
1464 |
+
if (state.prerendering) {
|
1465 |
+
dependency = { response, body: null };
|
1466 |
+
state.prerendering.dependencies.set(resolved, dependency);
|
1467 |
+
}
|
1468 |
+
} else {
|
1469 |
+
if (resolved.startsWith("//")) {
|
1470 |
+
requested = event.url.protocol + requested;
|
1471 |
+
}
|
1472 |
+
if (`.${new URL(requested).hostname}`.endsWith(`.${event.url.hostname}`) && opts.credentials !== "omit") {
|
1473 |
+
uses_credentials = true;
|
1474 |
+
const cookie = event.request.headers.get("cookie");
|
1475 |
+
if (cookie)
|
1476 |
+
opts.headers.set("cookie", cookie);
|
1477 |
+
}
|
1478 |
+
opts.headers.delete("connection");
|
1479 |
+
const external_request = new Request(requested, opts);
|
1480 |
+
response = await options.hooks.externalFetch.call(null, external_request);
|
1481 |
+
}
|
1482 |
+
const set_cookie = response.headers.get("set-cookie");
|
1483 |
+
if (set_cookie) {
|
1484 |
+
new_cookies.push(...splitCookiesString_1(set_cookie).map((str) => parseString_1(str)));
|
1485 |
+
}
|
1486 |
+
const proxy = new Proxy(response, {
|
1487 |
+
get(response2, key2, _receiver) {
|
1488 |
+
async function text() {
|
1489 |
+
const body = await response2.text();
|
1490 |
+
const headers = {};
|
1491 |
+
for (const [key3, value] of response2.headers) {
|
1492 |
+
if (key3 !== "set-cookie" && key3 !== "etag") {
|
1493 |
+
headers[key3] = value;
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
if (!opts.body || typeof opts.body === "string") {
|
1497 |
+
const status_number = Number(response2.status);
|
1498 |
+
if (isNaN(status_number)) {
|
1499 |
+
throw new Error(`response.status is not a number. value: "${response2.status}" type: ${typeof response2.status}`);
|
1500 |
+
}
|
1501 |
+
fetched.push({
|
1502 |
+
url: requested,
|
1503 |
+
body: opts.body,
|
1504 |
+
response: {
|
1505 |
+
status: status_number,
|
1506 |
+
statusText: response2.statusText,
|
1507 |
+
headers,
|
1508 |
+
body
|
1509 |
+
}
|
1510 |
+
});
|
1511 |
+
}
|
1512 |
+
if (dependency) {
|
1513 |
+
dependency.body = body;
|
1514 |
+
}
|
1515 |
+
return body;
|
1516 |
+
}
|
1517 |
+
if (key2 === "arrayBuffer") {
|
1518 |
+
return async () => {
|
1519 |
+
const buffer = await response2.arrayBuffer();
|
1520 |
+
if (dependency) {
|
1521 |
+
dependency.body = new Uint8Array(buffer);
|
1522 |
+
}
|
1523 |
+
return buffer;
|
1524 |
+
};
|
1525 |
+
}
|
1526 |
+
if (key2 === "text") {
|
1527 |
+
return text;
|
1528 |
+
}
|
1529 |
+
if (key2 === "json") {
|
1530 |
+
return async () => {
|
1531 |
+
return JSON.parse(await text());
|
1532 |
+
};
|
1533 |
+
}
|
1534 |
+
return Reflect.get(response2, key2, response2);
|
1535 |
+
}
|
1536 |
+
});
|
1537 |
+
return proxy;
|
1538 |
+
},
|
1539 |
+
stuff: { ...stuff },
|
1540 |
+
status: is_error ? status ?? null : null,
|
1541 |
+
error: is_error ? error2 ?? null : null
|
1542 |
+
};
|
1543 |
+
if (options.dev) {
|
1544 |
+
Object.defineProperty(load_input, "page", {
|
1545 |
+
get: () => {
|
1546 |
+
throw new Error("`page` in `load` functions has been replaced by `url` and `params`");
|
1547 |
+
}
|
1548 |
+
});
|
1549 |
+
}
|
1550 |
+
loaded = await module.load.call(null, load_input);
|
1551 |
+
if (!loaded) {
|
1552 |
+
throw new Error(`load function must return a value${options.dev ? ` (${node.entry})` : ""}`);
|
1553 |
+
}
|
1554 |
+
} else if (shadow.body) {
|
1555 |
+
loaded = {
|
1556 |
+
props: shadow.body
|
1557 |
+
};
|
1558 |
+
} else {
|
1559 |
+
loaded = {};
|
1560 |
+
}
|
1561 |
+
if (shadow.body && state.prerendering) {
|
1562 |
+
const pathname = `${event.url.pathname.replace(/\/$/, "")}/__data.json`;
|
1563 |
+
const dependency = {
|
1564 |
+
response: new Response(void 0),
|
1565 |
+
body: JSON.stringify(shadow.body)
|
1566 |
+
};
|
1567 |
+
state.prerendering.dependencies.set(pathname, dependency);
|
1568 |
+
}
|
1569 |
+
return {
|
1570 |
+
node,
|
1571 |
+
props: shadow.body,
|
1572 |
+
loaded: normalize(loaded),
|
1573 |
+
stuff: loaded.stuff || stuff,
|
1574 |
+
fetched,
|
1575 |
+
set_cookie_headers: new_cookies.map((new_cookie) => {
|
1576 |
+
const { name, value, ...options2 } = new_cookie;
|
1577 |
+
return serialize_1(name, value, options2);
|
1578 |
+
}),
|
1579 |
+
uses_credentials
|
1580 |
+
};
|
1581 |
+
}
|
1582 |
+
async function load_shadow_data(route, event, options, prerender) {
|
1583 |
+
if (!route.shadow)
|
1584 |
+
return {};
|
1585 |
+
try {
|
1586 |
+
const mod = await route.shadow();
|
1587 |
+
if (prerender && (mod.post || mod.put || mod.del || mod.patch)) {
|
1588 |
+
throw new Error("Cannot prerender pages that have endpoints with mutative methods");
|
1589 |
+
}
|
1590 |
+
const method = normalize_request_method(event);
|
1591 |
+
const is_get = method === "head" || method === "get";
|
1592 |
+
const handler = method === "head" ? mod.head || mod.get : mod[method];
|
1593 |
+
if (!handler && !is_get) {
|
1594 |
+
return {
|
1595 |
+
status: 405,
|
1596 |
+
error: new Error(`${method} method not allowed`)
|
1597 |
+
};
|
1598 |
+
}
|
1599 |
+
const data = {
|
1600 |
+
status: 200,
|
1601 |
+
cookies: [],
|
1602 |
+
body: {}
|
1603 |
+
};
|
1604 |
+
if (!is_get) {
|
1605 |
+
const result = await handler(event);
|
1606 |
+
if (result.fallthrough) {
|
1607 |
+
throw new Error("fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching");
|
1608 |
+
}
|
1609 |
+
const { status, headers, body } = validate_shadow_output(result);
|
1610 |
+
data.status = status;
|
1611 |
+
add_cookies(data.cookies, headers);
|
1612 |
+
if (status >= 300 && status < 400) {
|
1613 |
+
data.redirect = headers instanceof Headers ? headers.get("location") : headers.location;
|
1614 |
+
return data;
|
1615 |
+
}
|
1616 |
+
data.body = body;
|
1617 |
+
}
|
1618 |
+
const get = method === "head" && mod.head || mod.get;
|
1619 |
+
if (get) {
|
1620 |
+
const result = await get(event);
|
1621 |
+
if (result.fallthrough) {
|
1622 |
+
throw new Error("fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching");
|
1623 |
+
}
|
1624 |
+
const { status, headers, body } = validate_shadow_output(result);
|
1625 |
+
add_cookies(data.cookies, headers);
|
1626 |
+
data.status = status;
|
1627 |
+
if (status >= 400) {
|
1628 |
+
data.error = new Error("Failed to load data");
|
1629 |
+
return data;
|
1630 |
+
}
|
1631 |
+
if (status >= 300) {
|
1632 |
+
data.redirect = headers instanceof Headers ? headers.get("location") : headers.location;
|
1633 |
+
return data;
|
1634 |
+
}
|
1635 |
+
data.body = { ...body, ...data.body };
|
1636 |
+
}
|
1637 |
+
return data;
|
1638 |
+
} catch (e) {
|
1639 |
+
const error2 = coalesce_to_error(e);
|
1640 |
+
options.handle_error(error2, event);
|
1641 |
+
return {
|
1642 |
+
status: 500,
|
1643 |
+
error: error2
|
1644 |
+
};
|
1645 |
+
}
|
1646 |
+
}
|
1647 |
+
function add_cookies(target, headers) {
|
1648 |
+
const cookies = headers["set-cookie"];
|
1649 |
+
if (cookies) {
|
1650 |
+
if (Array.isArray(cookies)) {
|
1651 |
+
target.push(...cookies);
|
1652 |
+
} else {
|
1653 |
+
target.push(cookies);
|
1654 |
+
}
|
1655 |
+
}
|
1656 |
+
}
|
1657 |
+
function validate_shadow_output(result) {
|
1658 |
+
const { status = 200, body = {} } = result;
|
1659 |
+
let headers = result.headers || {};
|
1660 |
+
if (headers instanceof Headers) {
|
1661 |
+
if (headers.has("set-cookie")) {
|
1662 |
+
throw new Error("Endpoint request handler cannot use Headers interface with Set-Cookie headers");
|
1663 |
+
}
|
1664 |
+
} else {
|
1665 |
+
headers = lowercase_keys(headers);
|
1666 |
+
}
|
1667 |
+
if (!is_pojo(body)) {
|
1668 |
+
throw new Error("Body returned from endpoint request handler must be a plain object");
|
1669 |
+
}
|
1670 |
+
return { status, headers, body };
|
1671 |
+
}
|
1672 |
+
async function respond_with_error({
|
1673 |
+
event,
|
1674 |
+
options,
|
1675 |
+
state,
|
1676 |
+
$session,
|
1677 |
+
status,
|
1678 |
+
error: error2,
|
1679 |
+
resolve_opts
|
1680 |
+
}) {
|
1681 |
+
try {
|
1682 |
+
const branch = [];
|
1683 |
+
let stuff = {};
|
1684 |
+
if (resolve_opts.ssr) {
|
1685 |
+
const default_layout = await options.manifest._.nodes[0]();
|
1686 |
+
const default_error = await options.manifest._.nodes[1]();
|
1687 |
+
const layout_loaded = await load_node({
|
1688 |
+
event,
|
1689 |
+
options,
|
1690 |
+
state,
|
1691 |
+
route: null,
|
1692 |
+
node: default_layout,
|
1693 |
+
$session,
|
1694 |
+
stuff: {},
|
1695 |
+
is_error: false,
|
1696 |
+
is_leaf: false
|
1697 |
+
});
|
1698 |
+
const error_loaded = await load_node({
|
1699 |
+
event,
|
1700 |
+
options,
|
1701 |
+
state,
|
1702 |
+
route: null,
|
1703 |
+
node: default_error,
|
1704 |
+
$session,
|
1705 |
+
stuff: layout_loaded ? layout_loaded.stuff : {},
|
1706 |
+
is_error: true,
|
1707 |
+
is_leaf: false,
|
1708 |
+
status,
|
1709 |
+
error: error2
|
1710 |
+
});
|
1711 |
+
branch.push(layout_loaded, error_loaded);
|
1712 |
+
stuff = error_loaded.stuff;
|
1713 |
+
}
|
1714 |
+
return await render_response({
|
1715 |
+
options,
|
1716 |
+
state,
|
1717 |
+
$session,
|
1718 |
+
page_config: {
|
1719 |
+
hydrate: options.hydrate,
|
1720 |
+
router: options.router
|
1721 |
+
},
|
1722 |
+
stuff,
|
1723 |
+
status,
|
1724 |
+
error: error2,
|
1725 |
+
branch,
|
1726 |
+
event,
|
1727 |
+
resolve_opts
|
1728 |
+
});
|
1729 |
+
} catch (err) {
|
1730 |
+
const error3 = coalesce_to_error(err);
|
1731 |
+
options.handle_error(error3, event);
|
1732 |
+
return new Response(error3.stack, {
|
1733 |
+
status: 500
|
1734 |
+
});
|
1735 |
+
}
|
1736 |
+
}
|
1737 |
+
async function respond$1(opts) {
|
1738 |
+
const { event, options, state, $session, route, resolve_opts } = opts;
|
1739 |
+
let nodes;
|
1740 |
+
if (!resolve_opts.ssr) {
|
1741 |
+
return await render_response({
|
1742 |
+
...opts,
|
1743 |
+
branch: [],
|
1744 |
+
page_config: {
|
1745 |
+
hydrate: true,
|
1746 |
+
router: true
|
1747 |
+
},
|
1748 |
+
status: 200,
|
1749 |
+
error: null,
|
1750 |
+
event,
|
1751 |
+
stuff: {}
|
1752 |
+
});
|
1753 |
+
}
|
1754 |
+
try {
|
1755 |
+
nodes = await Promise.all(route.a.map((n) => n == void 0 ? n : options.manifest._.nodes[n]()));
|
1756 |
+
} catch (err) {
|
1757 |
+
const error3 = coalesce_to_error(err);
|
1758 |
+
options.handle_error(error3, event);
|
1759 |
+
return await respond_with_error({
|
1760 |
+
event,
|
1761 |
+
options,
|
1762 |
+
state,
|
1763 |
+
$session,
|
1764 |
+
status: 500,
|
1765 |
+
error: error3,
|
1766 |
+
resolve_opts
|
1767 |
+
});
|
1768 |
+
}
|
1769 |
+
const leaf = nodes[nodes.length - 1].module;
|
1770 |
+
let page_config = get_page_config(leaf, options);
|
1771 |
+
if (state.prerendering) {
|
1772 |
+
const should_prerender = leaf.prerender ?? options.prerender.default;
|
1773 |
+
if (!should_prerender) {
|
1774 |
+
return new Response(void 0, {
|
1775 |
+
status: 204
|
1776 |
+
});
|
1777 |
+
}
|
1778 |
+
}
|
1779 |
+
let branch = [];
|
1780 |
+
let status = 200;
|
1781 |
+
let error2 = null;
|
1782 |
+
let set_cookie_headers = [];
|
1783 |
+
let stuff = {};
|
1784 |
+
ssr: {
|
1785 |
+
for (let i = 0; i < nodes.length; i += 1) {
|
1786 |
+
const node = nodes[i];
|
1787 |
+
let loaded;
|
1788 |
+
if (node) {
|
1789 |
+
try {
|
1790 |
+
loaded = await load_node({
|
1791 |
+
...opts,
|
1792 |
+
node,
|
1793 |
+
stuff,
|
1794 |
+
is_error: false,
|
1795 |
+
is_leaf: i === nodes.length - 1
|
1796 |
+
});
|
1797 |
+
set_cookie_headers = set_cookie_headers.concat(loaded.set_cookie_headers);
|
1798 |
+
if (loaded.loaded.redirect) {
|
1799 |
+
return with_cookies(new Response(void 0, {
|
1800 |
+
status: loaded.loaded.status,
|
1801 |
+
headers: {
|
1802 |
+
location: loaded.loaded.redirect
|
1803 |
+
}
|
1804 |
+
}), set_cookie_headers);
|
1805 |
+
}
|
1806 |
+
if (loaded.loaded.error) {
|
1807 |
+
({ status, error: error2 } = loaded.loaded);
|
1808 |
+
}
|
1809 |
+
} catch (err) {
|
1810 |
+
const e = coalesce_to_error(err);
|
1811 |
+
options.handle_error(e, event);
|
1812 |
+
status = 500;
|
1813 |
+
error2 = e;
|
1814 |
+
}
|
1815 |
+
if (loaded && !error2) {
|
1816 |
+
branch.push(loaded);
|
1817 |
+
}
|
1818 |
+
if (error2) {
|
1819 |
+
while (i--) {
|
1820 |
+
if (route.b[i]) {
|
1821 |
+
const index = route.b[i];
|
1822 |
+
const error_node = await options.manifest._.nodes[index]();
|
1823 |
+
let node_loaded;
|
1824 |
+
let j = i;
|
1825 |
+
while (!(node_loaded = branch[j])) {
|
1826 |
+
j -= 1;
|
1827 |
+
}
|
1828 |
+
try {
|
1829 |
+
const error_loaded = await load_node({
|
1830 |
+
...opts,
|
1831 |
+
node: error_node,
|
1832 |
+
stuff: node_loaded.stuff,
|
1833 |
+
is_error: true,
|
1834 |
+
is_leaf: false,
|
1835 |
+
status,
|
1836 |
+
error: error2
|
1837 |
+
});
|
1838 |
+
if (error_loaded.loaded.error) {
|
1839 |
+
continue;
|
1840 |
+
}
|
1841 |
+
page_config = get_page_config(error_node.module, options);
|
1842 |
+
branch = branch.slice(0, j + 1).concat(error_loaded);
|
1843 |
+
stuff = { ...node_loaded.stuff, ...error_loaded.stuff };
|
1844 |
+
break ssr;
|
1845 |
+
} catch (err) {
|
1846 |
+
const e = coalesce_to_error(err);
|
1847 |
+
options.handle_error(e, event);
|
1848 |
+
continue;
|
1849 |
+
}
|
1850 |
+
}
|
1851 |
+
}
|
1852 |
+
return with_cookies(await respond_with_error({
|
1853 |
+
event,
|
1854 |
+
options,
|
1855 |
+
state,
|
1856 |
+
$session,
|
1857 |
+
status,
|
1858 |
+
error: error2,
|
1859 |
+
resolve_opts
|
1860 |
+
}), set_cookie_headers);
|
1861 |
+
}
|
1862 |
+
}
|
1863 |
+
if (loaded && loaded.loaded.stuff) {
|
1864 |
+
stuff = {
|
1865 |
+
...stuff,
|
1866 |
+
...loaded.loaded.stuff
|
1867 |
+
};
|
1868 |
+
}
|
1869 |
+
}
|
1870 |
+
}
|
1871 |
+
try {
|
1872 |
+
return with_cookies(await render_response({
|
1873 |
+
...opts,
|
1874 |
+
stuff,
|
1875 |
+
event,
|
1876 |
+
page_config,
|
1877 |
+
status,
|
1878 |
+
error: error2,
|
1879 |
+
branch: branch.filter(Boolean)
|
1880 |
+
}), set_cookie_headers);
|
1881 |
+
} catch (err) {
|
1882 |
+
const error3 = coalesce_to_error(err);
|
1883 |
+
options.handle_error(error3, event);
|
1884 |
+
return with_cookies(await respond_with_error({
|
1885 |
+
...opts,
|
1886 |
+
status: 500,
|
1887 |
+
error: error3
|
1888 |
+
}), set_cookie_headers);
|
1889 |
+
}
|
1890 |
+
}
|
1891 |
+
function get_page_config(leaf, options) {
|
1892 |
+
if ("ssr" in leaf) {
|
1893 |
+
throw new Error("`export const ssr` has been removed \u2014 use the handle hook instead: https://kit.svelte.dev/docs/hooks#handle");
|
1894 |
+
}
|
1895 |
+
return {
|
1896 |
+
router: "router" in leaf ? !!leaf.router : options.router,
|
1897 |
+
hydrate: "hydrate" in leaf ? !!leaf.hydrate : options.hydrate
|
1898 |
+
};
|
1899 |
+
}
|
1900 |
+
function with_cookies(response, set_cookie_headers) {
|
1901 |
+
if (set_cookie_headers.length) {
|
1902 |
+
set_cookie_headers.forEach((value) => {
|
1903 |
+
response.headers.append("set-cookie", value);
|
1904 |
+
});
|
1905 |
+
}
|
1906 |
+
return response;
|
1907 |
+
}
|
1908 |
+
async function render_page(event, route, options, state, resolve_opts) {
|
1909 |
+
if (state.initiator === route) {
|
1910 |
+
return new Response(`Not found: ${event.url.pathname}`, {
|
1911 |
+
status: 404
|
1912 |
+
});
|
1913 |
+
}
|
1914 |
+
if (route.shadow) {
|
1915 |
+
const type = negotiate(event.request.headers.get("accept") || "text/html", [
|
1916 |
+
"text/html",
|
1917 |
+
"application/json"
|
1918 |
+
]);
|
1919 |
+
if (type === "application/json") {
|
1920 |
+
return render_endpoint(event, await route.shadow());
|
1921 |
+
}
|
1922 |
+
}
|
1923 |
+
const $session = await options.hooks.getSession(event);
|
1924 |
+
return respond$1({
|
1925 |
+
event,
|
1926 |
+
options,
|
1927 |
+
state,
|
1928 |
+
$session,
|
1929 |
+
resolve_opts,
|
1930 |
+
route
|
1931 |
+
});
|
1932 |
+
}
|
1933 |
+
function negotiate(accept, types) {
|
1934 |
+
const parts = accept.split(",").map((str, i) => {
|
1935 |
+
const match = /([^/]+)\/([^;]+)(?:;q=([0-9.]+))?/.exec(str);
|
1936 |
+
if (match) {
|
1937 |
+
const [, type, subtype, q = "1"] = match;
|
1938 |
+
return { type, subtype, q: +q, i };
|
1939 |
+
}
|
1940 |
+
throw new Error(`Invalid Accept header: ${accept}`);
|
1941 |
+
}).sort((a, b) => {
|
1942 |
+
if (a.q !== b.q) {
|
1943 |
+
return b.q - a.q;
|
1944 |
+
}
|
1945 |
+
if (a.subtype === "*" !== (b.subtype === "*")) {
|
1946 |
+
return a.subtype === "*" ? 1 : -1;
|
1947 |
+
}
|
1948 |
+
if (a.type === "*" !== (b.type === "*")) {
|
1949 |
+
return a.type === "*" ? 1 : -1;
|
1950 |
+
}
|
1951 |
+
return a.i - b.i;
|
1952 |
+
});
|
1953 |
+
let accepted;
|
1954 |
+
let min_priority = Infinity;
|
1955 |
+
for (const mimetype of types) {
|
1956 |
+
const [type, subtype] = mimetype.split("/");
|
1957 |
+
const priority = parts.findIndex((part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*"));
|
1958 |
+
if (priority !== -1 && priority < min_priority) {
|
1959 |
+
accepted = mimetype;
|
1960 |
+
min_priority = priority;
|
1961 |
+
}
|
1962 |
+
}
|
1963 |
+
return accepted;
|
1964 |
+
}
|
1965 |
+
function exec(match, names, types, matchers) {
|
1966 |
+
const params = {};
|
1967 |
+
for (let i = 0; i < names.length; i += 1) {
|
1968 |
+
const name = names[i];
|
1969 |
+
const type = types[i];
|
1970 |
+
const value = match[i + 1] || "";
|
1971 |
+
if (type) {
|
1972 |
+
const matcher = matchers[type];
|
1973 |
+
if (!matcher)
|
1974 |
+
throw new Error(`Missing "${type}" param matcher`);
|
1975 |
+
if (!matcher(value))
|
1976 |
+
return;
|
1977 |
+
}
|
1978 |
+
params[name] = value;
|
1979 |
+
}
|
1980 |
+
return params;
|
1981 |
+
}
|
1982 |
+
const DATA_SUFFIX = "/__data.json";
|
1983 |
+
const default_transform = ({ html }) => html;
|
1984 |
+
async function respond(request, options, state) {
|
1985 |
+
var _a, _b, _c, _d;
|
1986 |
+
let url = new URL(request.url);
|
1987 |
+
const { parameter, allowed } = options.method_override;
|
1988 |
+
const method_override = (_a = url.searchParams.get(parameter)) == null ? void 0 : _a.toUpperCase();
|
1989 |
+
if (method_override) {
|
1990 |
+
if (request.method === "POST") {
|
1991 |
+
if (allowed.includes(method_override)) {
|
1992 |
+
request = new Proxy(request, {
|
1993 |
+
get: (target, property, _receiver) => {
|
1994 |
+
if (property === "method")
|
1995 |
+
return method_override;
|
1996 |
+
return Reflect.get(target, property, target);
|
1997 |
+
}
|
1998 |
+
});
|
1999 |
+
} else {
|
2000 |
+
const verb = allowed.length === 0 ? "enabled" : "allowed";
|
2001 |
+
const body = `${parameter}=${method_override} is not ${verb}. See https://kit.svelte.dev/docs/configuration#methodoverride`;
|
2002 |
+
return new Response(body, {
|
2003 |
+
status: 400
|
2004 |
+
});
|
2005 |
+
}
|
2006 |
+
} else {
|
2007 |
+
throw new Error(`${parameter}=${method_override} is only allowed with POST requests`);
|
2008 |
+
}
|
2009 |
+
}
|
2010 |
+
let decoded;
|
2011 |
+
try {
|
2012 |
+
decoded = decodeURI(url.pathname);
|
2013 |
+
} catch {
|
2014 |
+
return new Response("Malformed URI", { status: 400 });
|
2015 |
+
}
|
2016 |
+
let route = null;
|
2017 |
+
let params = {};
|
2018 |
+
if (options.paths.base && !((_b = state.prerendering) == null ? void 0 : _b.fallback)) {
|
2019 |
+
if (!decoded.startsWith(options.paths.base)) {
|
2020 |
+
return new Response("Not found", { status: 404 });
|
2021 |
+
}
|
2022 |
+
decoded = decoded.slice(options.paths.base.length) || "/";
|
2023 |
+
}
|
2024 |
+
const is_data_request = decoded.endsWith(DATA_SUFFIX);
|
2025 |
+
if (is_data_request) {
|
2026 |
+
const data_suffix_length = DATA_SUFFIX.length - (options.trailing_slash === "always" ? 1 : 0);
|
2027 |
+
decoded = decoded.slice(0, -data_suffix_length) || "/";
|
2028 |
+
url = new URL(url.origin + url.pathname.slice(0, -data_suffix_length) + url.search);
|
2029 |
+
}
|
2030 |
+
if (!((_c = state.prerendering) == null ? void 0 : _c.fallback)) {
|
2031 |
+
const matchers = await options.manifest._.matchers();
|
2032 |
+
for (const candidate of options.manifest._.routes) {
|
2033 |
+
const match = candidate.pattern.exec(decoded);
|
2034 |
+
if (!match)
|
2035 |
+
continue;
|
2036 |
+
const matched = exec(match, candidate.names, candidate.types, matchers);
|
2037 |
+
if (matched) {
|
2038 |
+
route = candidate;
|
2039 |
+
params = decode_params(matched);
|
2040 |
+
break;
|
2041 |
+
}
|
2042 |
+
}
|
2043 |
+
}
|
2044 |
+
if (route) {
|
2045 |
+
if (route.type === "page") {
|
2046 |
+
const normalized = normalize_path(url.pathname, options.trailing_slash);
|
2047 |
+
if (normalized !== url.pathname && !((_d = state.prerendering) == null ? void 0 : _d.fallback)) {
|
2048 |
+
return new Response(void 0, {
|
2049 |
+
status: 301,
|
2050 |
+
headers: {
|
2051 |
+
"x-sveltekit-normalize": "1",
|
2052 |
+
location: (normalized.startsWith("//") ? url.origin + normalized : normalized) + (url.search === "?" ? "" : url.search)
|
2053 |
+
}
|
2054 |
+
});
|
2055 |
+
}
|
2056 |
+
} else if (is_data_request) {
|
2057 |
+
return new Response(void 0, {
|
2058 |
+
status: 404
|
2059 |
+
});
|
2060 |
+
}
|
2061 |
+
}
|
2062 |
+
const event = {
|
2063 |
+
get clientAddress() {
|
2064 |
+
if (!state.getClientAddress) {
|
2065 |
+
throw new Error(`${"@sveltejs/adapter-static"} does not specify getClientAddress. Please raise an issue`);
|
2066 |
+
}
|
2067 |
+
Object.defineProperty(event, "clientAddress", {
|
2068 |
+
value: state.getClientAddress()
|
2069 |
+
});
|
2070 |
+
return event.clientAddress;
|
2071 |
+
},
|
2072 |
+
locals: {},
|
2073 |
+
params,
|
2074 |
+
platform: state.platform,
|
2075 |
+
request,
|
2076 |
+
routeId: route && route.id,
|
2077 |
+
url
|
2078 |
+
};
|
2079 |
+
const removed = (property, replacement, suffix = "") => ({
|
2080 |
+
get: () => {
|
2081 |
+
throw new Error(`event.${property} has been replaced by event.${replacement}` + suffix);
|
2082 |
+
}
|
2083 |
+
});
|
2084 |
+
const details = ". See https://github.com/sveltejs/kit/pull/3384 for details";
|
2085 |
+
const body_getter = {
|
2086 |
+
get: () => {
|
2087 |
+
throw new Error("To access the request body use the text/json/arrayBuffer/formData methods, e.g. `body = await request.json()`" + details);
|
2088 |
+
}
|
2089 |
+
};
|
2090 |
+
Object.defineProperties(event, {
|
2091 |
+
method: removed("method", "request.method", details),
|
2092 |
+
headers: removed("headers", "request.headers", details),
|
2093 |
+
origin: removed("origin", "url.origin"),
|
2094 |
+
path: removed("path", "url.pathname"),
|
2095 |
+
query: removed("query", "url.searchParams"),
|
2096 |
+
body: body_getter,
|
2097 |
+
rawBody: body_getter
|
2098 |
+
});
|
2099 |
+
let resolve_opts = {
|
2100 |
+
ssr: true,
|
2101 |
+
transformPage: default_transform
|
2102 |
+
};
|
2103 |
+
try {
|
2104 |
+
const response = await options.hooks.handle({
|
2105 |
+
event,
|
2106 |
+
resolve: async (event2, opts) => {
|
2107 |
+
var _a2;
|
2108 |
+
if (opts) {
|
2109 |
+
resolve_opts = {
|
2110 |
+
ssr: opts.ssr !== false,
|
2111 |
+
transformPage: opts.transformPage || default_transform
|
2112 |
+
};
|
2113 |
+
}
|
2114 |
+
if ((_a2 = state.prerendering) == null ? void 0 : _a2.fallback) {
|
2115 |
+
return await render_response({
|
2116 |
+
event: event2,
|
2117 |
+
options,
|
2118 |
+
state,
|
2119 |
+
$session: await options.hooks.getSession(event2),
|
2120 |
+
page_config: { router: true, hydrate: true },
|
2121 |
+
stuff: {},
|
2122 |
+
status: 200,
|
2123 |
+
error: null,
|
2124 |
+
branch: [],
|
2125 |
+
resolve_opts: {
|
2126 |
+
...resolve_opts,
|
2127 |
+
ssr: false
|
2128 |
+
}
|
2129 |
+
});
|
2130 |
+
}
|
2131 |
+
if (route) {
|
2132 |
+
let response2;
|
2133 |
+
if (is_data_request && route.type === "page" && route.shadow) {
|
2134 |
+
response2 = await render_endpoint(event2, await route.shadow());
|
2135 |
+
if (request.headers.has("x-sveltekit-load")) {
|
2136 |
+
if (response2.status >= 300 && response2.status < 400) {
|
2137 |
+
const location = response2.headers.get("location");
|
2138 |
+
if (location) {
|
2139 |
+
const headers = new Headers(response2.headers);
|
2140 |
+
headers.set("x-sveltekit-location", location);
|
2141 |
+
response2 = new Response(void 0, {
|
2142 |
+
status: 204,
|
2143 |
+
headers
|
2144 |
+
});
|
2145 |
+
}
|
2146 |
+
}
|
2147 |
+
}
|
2148 |
+
} else {
|
2149 |
+
response2 = route.type === "endpoint" ? await render_endpoint(event2, await route.load()) : await render_page(event2, route, options, state, resolve_opts);
|
2150 |
+
}
|
2151 |
+
if (response2) {
|
2152 |
+
if (response2.status === 200 && response2.headers.has("etag")) {
|
2153 |
+
let if_none_match_value = request.headers.get("if-none-match");
|
2154 |
+
if (if_none_match_value == null ? void 0 : if_none_match_value.startsWith('W/"')) {
|
2155 |
+
if_none_match_value = if_none_match_value.substring(2);
|
2156 |
+
}
|
2157 |
+
const etag = response2.headers.get("etag");
|
2158 |
+
if (if_none_match_value === etag) {
|
2159 |
+
const headers = new Headers({ etag });
|
2160 |
+
for (const key2 of [
|
2161 |
+
"cache-control",
|
2162 |
+
"content-location",
|
2163 |
+
"date",
|
2164 |
+
"expires",
|
2165 |
+
"vary"
|
2166 |
+
]) {
|
2167 |
+
const value = response2.headers.get(key2);
|
2168 |
+
if (value)
|
2169 |
+
headers.set(key2, value);
|
2170 |
+
}
|
2171 |
+
return new Response(void 0, {
|
2172 |
+
status: 304,
|
2173 |
+
headers
|
2174 |
+
});
|
2175 |
+
}
|
2176 |
+
}
|
2177 |
+
return response2;
|
2178 |
+
}
|
2179 |
+
}
|
2180 |
+
if (!state.initiator) {
|
2181 |
+
const $session = await options.hooks.getSession(event2);
|
2182 |
+
return await respond_with_error({
|
2183 |
+
event: event2,
|
2184 |
+
options,
|
2185 |
+
state,
|
2186 |
+
$session,
|
2187 |
+
status: 404,
|
2188 |
+
error: new Error(`Not found: ${event2.url.pathname}`),
|
2189 |
+
resolve_opts
|
2190 |
+
});
|
2191 |
+
}
|
2192 |
+
if (state.prerendering) {
|
2193 |
+
return new Response("not found", { status: 404 });
|
2194 |
+
}
|
2195 |
+
return await fetch(request);
|
2196 |
+
},
|
2197 |
+
get request() {
|
2198 |
+
throw new Error("request in handle has been replaced with event" + details);
|
2199 |
+
}
|
2200 |
+
});
|
2201 |
+
if (response && !(response instanceof Response)) {
|
2202 |
+
throw new Error("handle must return a Response object" + details);
|
2203 |
+
}
|
2204 |
+
return response;
|
2205 |
+
} catch (e) {
|
2206 |
+
const error2 = coalesce_to_error(e);
|
2207 |
+
options.handle_error(error2, event);
|
2208 |
+
try {
|
2209 |
+
const $session = await options.hooks.getSession(event);
|
2210 |
+
return await respond_with_error({
|
2211 |
+
event,
|
2212 |
+
options,
|
2213 |
+
state,
|
2214 |
+
$session,
|
2215 |
+
status: 500,
|
2216 |
+
error: error2,
|
2217 |
+
resolve_opts
|
2218 |
+
});
|
2219 |
+
} catch (e2) {
|
2220 |
+
const error3 = coalesce_to_error(e2);
|
2221 |
+
return new Response(options.dev ? error3.stack : error3.message, {
|
2222 |
+
status: 500
|
2223 |
+
});
|
2224 |
+
}
|
2225 |
+
}
|
2226 |
+
}
|
2227 |
+
function set_prerendering(value) {
|
2228 |
+
}
|
2229 |
+
const template = ({ head, body, assets: assets2, nonce }) => '<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" href="' + assets2 + '/favicon.png" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"><\/script>\n ' + head + '\n </head>\n <body class="light:bg-white bg-[rgb(11,15,25)] light:text-black text-white">\n ' + body + "\n </body> \n</html>\n";
|
2230 |
+
let read = null;
|
2231 |
+
set_paths({ "base": "/static", "assets": "" });
|
2232 |
+
let default_protocol = "https";
|
2233 |
+
function override(settings) {
|
2234 |
+
default_protocol = settings.protocol || default_protocol;
|
2235 |
+
set_paths(settings.paths);
|
2236 |
+
set_prerendering(settings.prerendering);
|
2237 |
+
read = settings.read;
|
2238 |
+
}
|
2239 |
+
class Server {
|
2240 |
+
constructor(manifest) {
|
2241 |
+
this.options = {
|
2242 |
+
csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } },
|
2243 |
+
dev: false,
|
2244 |
+
floc: false,
|
2245 |
+
get_stack: (error2) => String(error2),
|
2246 |
+
handle_error: (error2, event) => {
|
2247 |
+
this.options.hooks.handleError({
|
2248 |
+
error: error2,
|
2249 |
+
event,
|
2250 |
+
get request() {
|
2251 |
+
throw new Error("request in handleError has been replaced with event. See https://github.com/sveltejs/kit/pull/3384 for details");
|
2252 |
+
}
|
2253 |
+
});
|
2254 |
+
error2.stack = this.options.get_stack(error2);
|
2255 |
+
},
|
2256 |
+
hooks: null,
|
2257 |
+
hydrate: true,
|
2258 |
+
manifest,
|
2259 |
+
method_override: { "parameter": "_method", "allowed": [] },
|
2260 |
+
paths: { base, assets },
|
2261 |
+
prefix: assets + "/_app/immutable/",
|
2262 |
+
prerender: {
|
2263 |
+
default: true,
|
2264 |
+
enabled: true
|
2265 |
+
},
|
2266 |
+
read,
|
2267 |
+
root: Root,
|
2268 |
+
service_worker: null,
|
2269 |
+
router: true,
|
2270 |
+
template,
|
2271 |
+
template_contains_nonce: false,
|
2272 |
+
trailing_slash: "never"
|
2273 |
+
};
|
2274 |
+
}
|
2275 |
+
async respond(request, options = {}) {
|
2276 |
+
if (!(request instanceof Request)) {
|
2277 |
+
throw new Error("The first argument to server.respond must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details");
|
2278 |
+
}
|
2279 |
+
if (!this.options.hooks) {
|
2280 |
+
const module = await import("./chunks/hooks-1c45ba0b.js");
|
2281 |
+
this.options.hooks = {
|
2282 |
+
getSession: module.getSession || (() => ({})),
|
2283 |
+
handle: module.handle || (({ event, resolve: resolve2 }) => resolve2(event)),
|
2284 |
+
handleError: module.handleError || (({ error: error2 }) => console.error(error2.stack)),
|
2285 |
+
externalFetch: module.externalFetch || fetch
|
2286 |
+
};
|
2287 |
+
}
|
2288 |
+
return respond(request, this.options, options);
|
2289 |
+
}
|
2290 |
+
}
|
2291 |
+
export { Server, override };
|
frontend/.svelte-kit/output/server/manifest.js
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const manifest = {
|
2 |
+
appDir: "_app",
|
3 |
+
assets: new Set(["favicon.png","robots.txt","samples/example0.png","samples/example1.png","samples/example2.png","samples/example3.png","samples/example4.png","samples/example5.png","svelte-welcome.png","svelte-welcome.webp"]),
|
4 |
+
mimeTypes: {".png":"image/png",".txt":"text/plain",".webp":"image/webp"},
|
5 |
+
_: {
|
6 |
+
entry: {"file":"start-a60c2789.js","js":["start-a60c2789.js","chunks/index-bcf2726a.js","chunks/paths-d3bcbd10.js"],"css":[]},
|
7 |
+
nodes: [
|
8 |
+
() => import('./nodes/0.js'),
|
9 |
+
() => import('./nodes/1.js'),
|
10 |
+
() => import('./nodes/2.js')
|
11 |
+
],
|
12 |
+
routes: [
|
13 |
+
{
|
14 |
+
type: 'page',
|
15 |
+
id: "",
|
16 |
+
pattern: /^\/$/,
|
17 |
+
names: [],
|
18 |
+
types: [],
|
19 |
+
path: "/",
|
20 |
+
shadow: null,
|
21 |
+
a: [0,2],
|
22 |
+
b: [1]
|
23 |
+
}
|
24 |
+
],
|
25 |
+
matchers: async () => {
|
26 |
+
|
27 |
+
return { };
|
28 |
+
}
|
29 |
+
}
|
30 |
+
};
|
frontend/.svelte-kit/output/server/manifest.json
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
".svelte-kit/build/index.js": {
|
3 |
+
"file": "index.js",
|
4 |
+
"src": ".svelte-kit/build/index.js",
|
5 |
+
"isEntry": true,
|
6 |
+
"imports": [
|
7 |
+
"_index-445fd704.js",
|
8 |
+
"_paths-396f020f.js"
|
9 |
+
],
|
10 |
+
"dynamicImports": [
|
11 |
+
".svelte-kit/build/hooks.js"
|
12 |
+
]
|
13 |
+
},
|
14 |
+
"src/routes/__layout.svelte": {
|
15 |
+
"file": "entries/pages/__layout.svelte.js",
|
16 |
+
"src": "src/routes/__layout.svelte",
|
17 |
+
"isEntry": true,
|
18 |
+
"imports": [
|
19 |
+
"_index-445fd704.js"
|
20 |
+
],
|
21 |
+
"css": [
|
22 |
+
"assets/entries/pages/__layout.svelte-9d4a74c4.css"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
".svelte-kit/runtime/components/error.svelte": {
|
26 |
+
"file": "entries/fallbacks/error.svelte.js",
|
27 |
+
"src": ".svelte-kit/runtime/components/error.svelte",
|
28 |
+
"isEntry": true,
|
29 |
+
"imports": [
|
30 |
+
"_index-445fd704.js"
|
31 |
+
]
|
32 |
+
},
|
33 |
+
"src/routes/index.svelte": {
|
34 |
+
"file": "entries/pages/index.svelte.js",
|
35 |
+
"src": "src/routes/index.svelte",
|
36 |
+
"isEntry": true,
|
37 |
+
"imports": [
|
38 |
+
"_index-445fd704.js",
|
39 |
+
"_paths-396f020f.js"
|
40 |
+
],
|
41 |
+
"css": [
|
42 |
+
"assets/entries/pages/index.svelte-2db26221.css"
|
43 |
+
]
|
44 |
+
},
|
45 |
+
"_paths-396f020f.js": {
|
46 |
+
"file": "chunks/paths-396f020f.js"
|
47 |
+
},
|
48 |
+
"_index-445fd704.js": {
|
49 |
+
"file": "chunks/index-445fd704.js"
|
50 |
+
},
|
51 |
+
".svelte-kit/build/hooks.js": {
|
52 |
+
"file": "chunks/hooks-1c45ba0b.js",
|
53 |
+
"src": ".svelte-kit/build/hooks.js",
|
54 |
+
"isDynamicEntry": true
|
55 |
+
}
|
56 |
+
}
|
frontend/.svelte-kit/output/server/nodes/0.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as module from '../entries/pages/__layout.svelte.js';
|
2 |
+
|
3 |
+
export { module };
|
4 |
+
export const index = 0;
|
5 |
+
export const entry = 'pages/__layout.svelte-0c386344.js';
|
6 |
+
export const js = ["pages/__layout.svelte-0c386344.js","chunks/index-bcf2726a.js"];
|
7 |
+
export const css = ["assets/pages/__layout.svelte-dcfcba4b.css"];
|
frontend/.svelte-kit/output/server/nodes/1.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as module from '../entries/fallbacks/error.svelte.js';
|
2 |
+
|
3 |
+
export { module };
|
4 |
+
export const index = 1;
|
5 |
+
export const entry = 'error.svelte-d9523301.js';
|
6 |
+
export const js = ["error.svelte-d9523301.js","chunks/index-bcf2726a.js"];
|
7 |
+
export const css = [];
|
frontend/.svelte-kit/output/server/nodes/2.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as module from '../entries/pages/index.svelte.js';
|
2 |
+
|
3 |
+
export { module };
|
4 |
+
export const index = 2;
|
5 |
+
export const entry = 'pages/index.svelte-6350336a.js';
|
6 |
+
export const js = ["pages/index.svelte-6350336a.js","chunks/index-bcf2726a.js","chunks/paths-d3bcbd10.js"];
|
7 |
+
export const css = ["assets/pages/index.svelte-65a37285.css"];
|
frontend/.svelte-kit/runtime/app/env.js
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export { prerendering } from '../env.js';
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @type {import('$app/env').browser}
|
5 |
+
*/
|
6 |
+
const browser = !import.meta.env.SSR;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @type {import('$app/env').server}
|
10 |
+
*/
|
11 |
+
const server = !!import.meta.env.SSR;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @type {import('$app/env').dev}
|
15 |
+
*/
|
16 |
+
const dev = !!import.meta.env.DEV;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @type {import('$app/env').prod}
|
20 |
+
*/
|
21 |
+
const prod = !import.meta.env.DEV;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @type {import('$app/env').mode}
|
25 |
+
*/
|
26 |
+
const mode = import.meta.env.MODE;
|
27 |
+
|
28 |
+
export { browser, dev, mode, prod, server };
|
frontend/.svelte-kit/runtime/app/navigation.js
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { client } from '../client/singletons.js';
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @param {string} name
|
5 |
+
*/
|
6 |
+
function guard(name) {
|
7 |
+
return () => {
|
8 |
+
throw new Error(`Cannot call ${name}(...) on the server`);
|
9 |
+
};
|
10 |
+
}
|
11 |
+
|
12 |
+
const ssr = import.meta.env.SSR;
|
13 |
+
|
14 |
+
const disableScrollHandling = ssr
|
15 |
+
? guard('disableScrollHandling')
|
16 |
+
: client.disable_scroll_handling;
|
17 |
+
const goto = ssr ? guard('goto') : client.goto;
|
18 |
+
const invalidate = ssr ? guard('invalidate') : client.invalidate;
|
19 |
+
const prefetch = ssr ? guard('prefetch') : client.prefetch;
|
20 |
+
const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
|
21 |
+
const beforeNavigate = ssr ? () => {} : client.before_navigate;
|
22 |
+
const afterNavigate = ssr ? () => {} : client.after_navigate;
|
23 |
+
|
24 |
+
export { afterNavigate, beforeNavigate, disableScrollHandling, goto, invalidate, prefetch, prefetchRoutes };
|
frontend/.svelte-kit/runtime/app/paths.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export { assets, base } from '../paths.js';
|
frontend/.svelte-kit/runtime/app/stores.js
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { getContext } from 'svelte';
|
2 |
+
import { browser } from './env.js';
|
3 |
+
import '../env.js';
|
4 |
+
|
5 |
+
// TODO remove this (for 1.0? after 1.0?)
|
6 |
+
let warned = false;
|
7 |
+
function stores() {
|
8 |
+
if (!warned) {
|
9 |
+
console.error('stores() is deprecated; use getStores() instead');
|
10 |
+
warned = true;
|
11 |
+
}
|
12 |
+
return getStores();
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @type {import('$app/stores').getStores}
|
17 |
+
*/
|
18 |
+
const getStores = () => {
|
19 |
+
const stores = getContext('__svelte__');
|
20 |
+
|
21 |
+
return {
|
22 |
+
page: {
|
23 |
+
subscribe: stores.page.subscribe
|
24 |
+
},
|
25 |
+
navigating: {
|
26 |
+
subscribe: stores.navigating.subscribe
|
27 |
+
},
|
28 |
+
// TODO remove this (for 1.0? after 1.0?)
|
29 |
+
// @ts-expect-error - deprecated, not part of type definitions, but still callable
|
30 |
+
get preloading() {
|
31 |
+
console.error('stores.preloading is deprecated; use stores.navigating instead');
|
32 |
+
return {
|
33 |
+
subscribe: stores.navigating.subscribe
|
34 |
+
};
|
35 |
+
},
|
36 |
+
session: stores.session,
|
37 |
+
updated: stores.updated
|
38 |
+
};
|
39 |
+
};
|
40 |
+
|
41 |
+
/** @type {typeof import('$app/stores').page} */
|
42 |
+
const page = {
|
43 |
+
/** @param {(value: any) => void} fn */
|
44 |
+
subscribe(fn) {
|
45 |
+
const store = getStores().page;
|
46 |
+
return store.subscribe(fn);
|
47 |
+
}
|
48 |
+
};
|
49 |
+
|
50 |
+
/** @type {typeof import('$app/stores').navigating} */
|
51 |
+
const navigating = {
|
52 |
+
subscribe(fn) {
|
53 |
+
const store = getStores().navigating;
|
54 |
+
return store.subscribe(fn);
|
55 |
+
}
|
56 |
+
};
|
57 |
+
|
58 |
+
/** @param {string} verb */
|
59 |
+
const throw_error = (verb) => {
|
60 |
+
throw new Error(
|
61 |
+
browser
|
62 |
+
? `Cannot ${verb} session store before subscribing`
|
63 |
+
: `Can only ${verb} session store in browser`
|
64 |
+
);
|
65 |
+
};
|
66 |
+
|
67 |
+
/** @type {typeof import('$app/stores').session} */
|
68 |
+
const session = {
|
69 |
+
subscribe(fn) {
|
70 |
+
const store = getStores().session;
|
71 |
+
|
72 |
+
if (browser) {
|
73 |
+
session.set = store.set;
|
74 |
+
session.update = store.update;
|
75 |
+
}
|
76 |
+
|
77 |
+
return store.subscribe(fn);
|
78 |
+
},
|
79 |
+
set: () => throw_error('set'),
|
80 |
+
update: () => throw_error('update')
|
81 |
+
};
|
82 |
+
|
83 |
+
/** @type {typeof import('$app/stores').updated} */
|
84 |
+
const updated = {
|
85 |
+
subscribe(fn) {
|
86 |
+
const store = getStores().updated;
|
87 |
+
|
88 |
+
if (browser) {
|
89 |
+
updated.check = store.check;
|
90 |
+
}
|
91 |
+
|
92 |
+
return store.subscribe(fn);
|
93 |
+
},
|
94 |
+
check: () => throw_error('check')
|
95 |
+
};
|
96 |
+
|
97 |
+
export { getStores, navigating, page, session, stores, updated };
|
frontend/.svelte-kit/runtime/client/singletons.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @type {import('./types').Client} */
|
2 |
+
let client;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @param {{
|
6 |
+
* client: import('./types').Client;
|
7 |
+
* }} opts
|
8 |
+
*/
|
9 |
+
function init(opts) {
|
10 |
+
client = opts.client;
|
11 |
+
}
|
12 |
+
|
13 |
+
export { client, init };
|
frontend/.svelte-kit/runtime/client/start.js
ADDED
@@ -0,0 +1,1789 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { onMount, tick } from 'svelte';
|
2 |
+
import { writable } from 'svelte/store';
|
3 |
+
import { assets, set_paths } from '../paths.js';
|
4 |
+
import Root from '__GENERATED__/root.svelte';
|
5 |
+
import { components, dictionary, matchers } from '__GENERATED__/client-manifest.js';
|
6 |
+
import { init } from './singletons.js';
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @param {unknown} err
|
10 |
+
* @return {Error}
|
11 |
+
*/
|
12 |
+
function coalesce_to_error(err) {
|
13 |
+
return err instanceof Error ||
|
14 |
+
(err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)
|
15 |
+
? /** @type {Error} */ (err)
|
16 |
+
: new Error(JSON.stringify(err));
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param {import('types').LoadOutput} loaded
|
21 |
+
* @returns {import('types').NormalizedLoadOutput}
|
22 |
+
*/
|
23 |
+
function normalize(loaded) {
|
24 |
+
// TODO remove for 1.0
|
25 |
+
// @ts-expect-error
|
26 |
+
if (loaded.fallthrough) {
|
27 |
+
throw new Error(
|
28 |
+
'fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching'
|
29 |
+
);
|
30 |
+
}
|
31 |
+
|
32 |
+
// TODO remove for 1.0
|
33 |
+
if ('maxage' in loaded) {
|
34 |
+
throw new Error('maxage should be replaced with cache: { maxage }');
|
35 |
+
}
|
36 |
+
|
37 |
+
const has_error_status =
|
38 |
+
loaded.status && loaded.status >= 400 && loaded.status <= 599 && !loaded.redirect;
|
39 |
+
if (loaded.error || has_error_status) {
|
40 |
+
const status = loaded.status;
|
41 |
+
|
42 |
+
if (!loaded.error && has_error_status) {
|
43 |
+
return { status: status || 500, error: new Error() };
|
44 |
+
}
|
45 |
+
|
46 |
+
const error = typeof loaded.error === 'string' ? new Error(loaded.error) : loaded.error;
|
47 |
+
|
48 |
+
if (!(error instanceof Error)) {
|
49 |
+
return {
|
50 |
+
status: 500,
|
51 |
+
error: new Error(
|
52 |
+
`"error" property returned from load() must be a string or instance of Error, received type "${typeof error}"`
|
53 |
+
)
|
54 |
+
};
|
55 |
+
}
|
56 |
+
|
57 |
+
if (!status || status < 400 || status > 599) {
|
58 |
+
console.warn('"error" returned from load() without a valid status code — defaulting to 500');
|
59 |
+
return { status: 500, error };
|
60 |
+
}
|
61 |
+
|
62 |
+
return { status, error };
|
63 |
+
}
|
64 |
+
|
65 |
+
if (loaded.redirect) {
|
66 |
+
if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
|
67 |
+
throw new Error(
|
68 |
+
'"redirect" property returned from load() must be accompanied by a 3xx status code'
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
if (typeof loaded.redirect !== 'string') {
|
73 |
+
throw new Error('"redirect" property returned from load() must be a string');
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
if (loaded.dependencies) {
|
78 |
+
if (
|
79 |
+
!Array.isArray(loaded.dependencies) ||
|
80 |
+
loaded.dependencies.some((dep) => typeof dep !== 'string')
|
81 |
+
) {
|
82 |
+
throw new Error('"dependencies" property returned from load() must be of type string[]');
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
// TODO remove before 1.0
|
87 |
+
if (/** @type {any} */ (loaded).context) {
|
88 |
+
throw new Error(
|
89 |
+
'You are returning "context" from a load function. ' +
|
90 |
+
'"context" was renamed to "stuff", please adjust your code accordingly.'
|
91 |
+
);
|
92 |
+
}
|
93 |
+
|
94 |
+
return /** @type {import('types').NormalizedLoadOutput} */ (loaded);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @param {string} path
|
99 |
+
* @param {import('types').TrailingSlash} trailing_slash
|
100 |
+
*/
|
101 |
+
function normalize_path(path, trailing_slash) {
|
102 |
+
if (path === '/' || trailing_slash === 'ignore') return path;
|
103 |
+
|
104 |
+
if (trailing_slash === 'never') {
|
105 |
+
return path.endsWith('/') ? path.slice(0, -1) : path;
|
106 |
+
} else if (trailing_slash === 'always' && !path.endsWith('/')) {
|
107 |
+
return path + '/';
|
108 |
+
}
|
109 |
+
|
110 |
+
return path;
|
111 |
+
}
|
112 |
+
|
113 |
+
class LoadURL extends URL {
|
114 |
+
/** @returns {string} */
|
115 |
+
get hash() {
|
116 |
+
throw new Error(
|
117 |
+
'url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component.'
|
118 |
+
);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/** @param {HTMLDocument} doc */
|
123 |
+
function get_base_uri(doc) {
|
124 |
+
let baseURI = doc.baseURI;
|
125 |
+
|
126 |
+
if (!baseURI) {
|
127 |
+
const baseTags = doc.getElementsByTagName('base');
|
128 |
+
baseURI = baseTags.length ? baseTags[0].href : doc.URL;
|
129 |
+
}
|
130 |
+
|
131 |
+
return baseURI;
|
132 |
+
}
|
133 |
+
|
134 |
+
function scroll_state() {
|
135 |
+
return {
|
136 |
+
x: pageXOffset,
|
137 |
+
y: pageYOffset
|
138 |
+
};
|
139 |
+
}
|
140 |
+
|
141 |
+
/** @param {Event} event */
|
142 |
+
function find_anchor(event) {
|
143 |
+
const node = event
|
144 |
+
.composedPath()
|
145 |
+
.find((e) => e instanceof Node && e.nodeName.toUpperCase() === 'A'); // SVG <a> elements have a lowercase name
|
146 |
+
return /** @type {HTMLAnchorElement | SVGAElement | undefined} */ (node);
|
147 |
+
}
|
148 |
+
|
149 |
+
/** @param {HTMLAnchorElement | SVGAElement} node */
|
150 |
+
function get_href(node) {
|
151 |
+
return node instanceof SVGAElement
|
152 |
+
? new URL(node.href.baseVal, document.baseURI)
|
153 |
+
: new URL(node.href);
|
154 |
+
}
|
155 |
+
|
156 |
+
/** @param {any} value */
|
157 |
+
function notifiable_store(value) {
|
158 |
+
const store = writable(value);
|
159 |
+
let ready = true;
|
160 |
+
|
161 |
+
function notify() {
|
162 |
+
ready = true;
|
163 |
+
store.update((val) => val);
|
164 |
+
}
|
165 |
+
|
166 |
+
/** @param {any} new_value */
|
167 |
+
function set(new_value) {
|
168 |
+
ready = false;
|
169 |
+
store.set(new_value);
|
170 |
+
}
|
171 |
+
|
172 |
+
/** @param {(value: any) => void} run */
|
173 |
+
function subscribe(run) {
|
174 |
+
/** @type {any} */
|
175 |
+
let old_value;
|
176 |
+
return store.subscribe((new_value) => {
|
177 |
+
if (old_value === undefined || (ready && new_value !== old_value)) {
|
178 |
+
run((old_value = new_value));
|
179 |
+
}
|
180 |
+
});
|
181 |
+
}
|
182 |
+
|
183 |
+
return { notify, set, subscribe };
|
184 |
+
}
|
185 |
+
|
186 |
+
function create_updated_store() {
|
187 |
+
const { set, subscribe } = writable(false);
|
188 |
+
|
189 |
+
const interval = +(
|
190 |
+
/** @type {string} */ (import.meta.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL)
|
191 |
+
);
|
192 |
+
const initial = import.meta.env.VITE_SVELTEKIT_APP_VERSION;
|
193 |
+
|
194 |
+
/** @type {NodeJS.Timeout} */
|
195 |
+
let timeout;
|
196 |
+
|
197 |
+
async function check() {
|
198 |
+
if (import.meta.env.DEV || import.meta.env.SSR) return false;
|
199 |
+
|
200 |
+
clearTimeout(timeout);
|
201 |
+
|
202 |
+
if (interval) timeout = setTimeout(check, interval);
|
203 |
+
|
204 |
+
const file = import.meta.env.VITE_SVELTEKIT_APP_VERSION_FILE;
|
205 |
+
|
206 |
+
const res = await fetch(`${assets}/${file}`, {
|
207 |
+
headers: {
|
208 |
+
pragma: 'no-cache',
|
209 |
+
'cache-control': 'no-cache'
|
210 |
+
}
|
211 |
+
});
|
212 |
+
|
213 |
+
if (res.ok) {
|
214 |
+
const { version } = await res.json();
|
215 |
+
const updated = version !== initial;
|
216 |
+
|
217 |
+
if (updated) {
|
218 |
+
set(true);
|
219 |
+
clearTimeout(timeout);
|
220 |
+
}
|
221 |
+
|
222 |
+
return updated;
|
223 |
+
} else {
|
224 |
+
throw new Error(`Version check failed: ${res.status}`);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
if (interval) timeout = setTimeout(check, interval);
|
229 |
+
|
230 |
+
return {
|
231 |
+
subscribe,
|
232 |
+
check
|
233 |
+
};
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Hash using djb2
|
238 |
+
* @param {import('types').StrictBody} value
|
239 |
+
*/
|
240 |
+
function hash(value) {
|
241 |
+
let hash = 5381;
|
242 |
+
let i = value.length;
|
243 |
+
|
244 |
+
if (typeof value === 'string') {
|
245 |
+
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
246 |
+
} else {
|
247 |
+
while (i) hash = (hash * 33) ^ value[--i];
|
248 |
+
}
|
249 |
+
|
250 |
+
return (hash >>> 0).toString(36);
|
251 |
+
}
|
252 |
+
|
253 |
+
let loading = 0;
|
254 |
+
|
255 |
+
const native_fetch = window.fetch;
|
256 |
+
|
257 |
+
function lock_fetch() {
|
258 |
+
loading += 1;
|
259 |
+
}
|
260 |
+
|
261 |
+
function unlock_fetch() {
|
262 |
+
loading -= 1;
|
263 |
+
}
|
264 |
+
|
265 |
+
if (import.meta.env.DEV) {
|
266 |
+
let can_inspect_stack_trace = false;
|
267 |
+
|
268 |
+
const check_stack_trace = async () => {
|
269 |
+
const stack = /** @type {string} */ (new Error().stack);
|
270 |
+
can_inspect_stack_trace = stack.includes('check_stack_trace');
|
271 |
+
};
|
272 |
+
|
273 |
+
check_stack_trace();
|
274 |
+
|
275 |
+
window.fetch = (input, init) => {
|
276 |
+
const url = input instanceof Request ? input.url : input.toString();
|
277 |
+
const stack = /** @type {string} */ (new Error().stack);
|
278 |
+
|
279 |
+
const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
|
280 |
+
if (heuristic) {
|
281 |
+
console.warn(
|
282 |
+
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
|
283 |
+
);
|
284 |
+
}
|
285 |
+
|
286 |
+
return native_fetch(input, init);
|
287 |
+
};
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* @param {RequestInfo} resource
|
292 |
+
* @param {RequestInit} [opts]
|
293 |
+
*/
|
294 |
+
function initial_fetch(resource, opts) {
|
295 |
+
const url = JSON.stringify(typeof resource === 'string' ? resource : resource.url);
|
296 |
+
|
297 |
+
let selector = `script[sveltekit\\:data-type="data"][sveltekit\\:data-url=${url}]`;
|
298 |
+
|
299 |
+
if (opts && typeof opts.body === 'string') {
|
300 |
+
selector += `[sveltekit\\:data-body="${hash(opts.body)}"]`;
|
301 |
+
}
|
302 |
+
|
303 |
+
const script = document.querySelector(selector);
|
304 |
+
if (script && script.textContent) {
|
305 |
+
const { body, ...init } = JSON.parse(script.textContent);
|
306 |
+
return Promise.resolve(new Response(body, init));
|
307 |
+
}
|
308 |
+
|
309 |
+
return native_fetch(resource, opts);
|
310 |
+
}
|
311 |
+
|
312 |
+
const param_pattern = /^(\.\.\.)?(\w+)(?:=(\w+))?$/;
|
313 |
+
|
314 |
+
/** @param {string} id */
|
315 |
+
function parse_route_id(id) {
|
316 |
+
/** @type {string[]} */
|
317 |
+
const names = [];
|
318 |
+
|
319 |
+
/** @type {string[]} */
|
320 |
+
const types = [];
|
321 |
+
|
322 |
+
// `/foo` should get an optional trailing slash, `/foo.json` should not
|
323 |
+
// const add_trailing_slash = !/\.[a-z]+$/.test(key);
|
324 |
+
let add_trailing_slash = true;
|
325 |
+
|
326 |
+
const pattern =
|
327 |
+
id === ''
|
328 |
+
? /^\/$/
|
329 |
+
: new RegExp(
|
330 |
+
`^${decodeURIComponent(id)
|
331 |
+
.split(/(?:@[a-zA-Z0-9_-]+)?(?:\/|$)/)
|
332 |
+
.map((segment, i, segments) => {
|
333 |
+
// special case — /[...rest]/ could contain zero segments
|
334 |
+
const match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
335 |
+
if (match) {
|
336 |
+
names.push(match[1]);
|
337 |
+
types.push(match[2]);
|
338 |
+
return '(?:/(.*))?';
|
339 |
+
}
|
340 |
+
|
341 |
+
const is_last = i === segments.length - 1;
|
342 |
+
|
343 |
+
return (
|
344 |
+
segment &&
|
345 |
+
'/' +
|
346 |
+
segment
|
347 |
+
.split(/\[(.+?)\]/)
|
348 |
+
.map((content, i) => {
|
349 |
+
if (i % 2) {
|
350 |
+
const [, rest, name, type] = /** @type {RegExpMatchArray} */ (
|
351 |
+
param_pattern.exec(content)
|
352 |
+
);
|
353 |
+
names.push(name);
|
354 |
+
types.push(type);
|
355 |
+
return rest ? '(.*?)' : '([^/]+?)';
|
356 |
+
}
|
357 |
+
|
358 |
+
if (is_last && content.includes('.')) add_trailing_slash = false;
|
359 |
+
|
360 |
+
return (
|
361 |
+
content // allow users to specify characters on the file system in an encoded manner
|
362 |
+
.normalize()
|
363 |
+
// We use [ and ] to denote parameters, so users must encode these on the file
|
364 |
+
// system to match against them. We don't decode all characters since others
|
365 |
+
// can already be epressed and so that '%' can be easily used directly in filenames
|
366 |
+
.replace(/%5[Bb]/g, '[')
|
367 |
+
.replace(/%5[Dd]/g, ']')
|
368 |
+
// '#', '/', and '?' can only appear in URL path segments in an encoded manner.
|
369 |
+
// They will not be touched by decodeURI so need to be encoded here, so
|
370 |
+
// that we can match against them.
|
371 |
+
// We skip '/' since you can't create a file with it on any OS
|
372 |
+
.replace(/#/g, '%23')
|
373 |
+
.replace(/\?/g, '%3F')
|
374 |
+
// escape characters that have special meaning in regex
|
375 |
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
376 |
+
); // TODO handle encoding
|
377 |
+
})
|
378 |
+
.join('')
|
379 |
+
);
|
380 |
+
})
|
381 |
+
.join('')}${add_trailing_slash ? '/?' : ''}$`
|
382 |
+
);
|
383 |
+
|
384 |
+
return { pattern, names, types };
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* @param {RegExpMatchArray} match
|
389 |
+
* @param {string[]} names
|
390 |
+
* @param {string[]} types
|
391 |
+
* @param {Record<string, import('types').ParamMatcher>} matchers
|
392 |
+
*/
|
393 |
+
function exec(match, names, types, matchers) {
|
394 |
+
/** @type {Record<string, string>} */
|
395 |
+
const params = {};
|
396 |
+
|
397 |
+
for (let i = 0; i < names.length; i += 1) {
|
398 |
+
const name = names[i];
|
399 |
+
const type = types[i];
|
400 |
+
const value = match[i + 1] || '';
|
401 |
+
|
402 |
+
if (type) {
|
403 |
+
const matcher = matchers[type];
|
404 |
+
if (!matcher) throw new Error(`Missing "${type}" param matcher`); // TODO do this ahead of time?
|
405 |
+
|
406 |
+
if (!matcher(value)) return;
|
407 |
+
}
|
408 |
+
|
409 |
+
params[name] = value;
|
410 |
+
}
|
411 |
+
|
412 |
+
return params;
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* @param {import('types').CSRComponentLoader[]} components
|
417 |
+
* @param {Record<string, [number[], number[], 1?]>} dictionary
|
418 |
+
* @param {Record<string, (param: string) => boolean>} matchers
|
419 |
+
* @returns {import('types').CSRRoute[]}
|
420 |
+
*/
|
421 |
+
function parse(components, dictionary, matchers) {
|
422 |
+
const routes = Object.entries(dictionary).map(([id, [a, b, has_shadow]]) => {
|
423 |
+
const { pattern, names, types } = parse_route_id(id);
|
424 |
+
|
425 |
+
return {
|
426 |
+
id,
|
427 |
+
/** @param {string} path */
|
428 |
+
exec: (path) => {
|
429 |
+
const match = pattern.exec(path);
|
430 |
+
if (match) return exec(match, names, types, matchers);
|
431 |
+
},
|
432 |
+
a: a.map((n) => components[n]),
|
433 |
+
b: b.map((n) => components[n]),
|
434 |
+
has_shadow: !!has_shadow
|
435 |
+
};
|
436 |
+
});
|
437 |
+
|
438 |
+
return routes;
|
439 |
+
}
|
440 |
+
|
441 |
+
const SCROLL_KEY = 'sveltekit:scroll';
|
442 |
+
const INDEX_KEY = 'sveltekit:index';
|
443 |
+
|
444 |
+
const routes = parse(components, dictionary, matchers);
|
445 |
+
|
446 |
+
// we import the root layout/error components eagerly, so that
|
447 |
+
// connectivity errors after initialisation don't nuke the app
|
448 |
+
const default_layout = components[0]();
|
449 |
+
const default_error = components[1]();
|
450 |
+
|
451 |
+
const root_stuff = {};
|
452 |
+
|
453 |
+
// We track the scroll position associated with each history entry in sessionStorage,
|
454 |
+
// rather than on history.state itself, because when navigation is driven by
|
455 |
+
// popstate it's too late to update the scroll position associated with the
|
456 |
+
// state we're navigating from
|
457 |
+
|
458 |
+
/** @typedef {{ x: number, y: number }} ScrollPosition */
|
459 |
+
/** @type {Record<number, ScrollPosition>} */
|
460 |
+
let scroll_positions = {};
|
461 |
+
try {
|
462 |
+
scroll_positions = JSON.parse(sessionStorage[SCROLL_KEY]);
|
463 |
+
} catch {
|
464 |
+
// do nothing
|
465 |
+
}
|
466 |
+
|
467 |
+
/** @param {number} index */
|
468 |
+
function update_scroll_positions(index) {
|
469 |
+
scroll_positions[index] = scroll_state();
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* @param {{
|
474 |
+
* target: Element;
|
475 |
+
* session: App.Session;
|
476 |
+
* base: string;
|
477 |
+
* trailing_slash: import('types').TrailingSlash;
|
478 |
+
* }} opts
|
479 |
+
* @returns {import('./types').Client}
|
480 |
+
*/
|
481 |
+
function create_client({ target, session, base, trailing_slash }) {
|
482 |
+
/** @type {Map<string, import('./types').NavigationResult>} */
|
483 |
+
const cache = new Map();
|
484 |
+
|
485 |
+
/** @type {Array<((href: string) => boolean)>} */
|
486 |
+
const invalidated = [];
|
487 |
+
|
488 |
+
const stores = {
|
489 |
+
url: notifiable_store({}),
|
490 |
+
page: notifiable_store({}),
|
491 |
+
navigating: writable(/** @type {import('types').Navigation | null} */ (null)),
|
492 |
+
session: writable(session),
|
493 |
+
updated: create_updated_store()
|
494 |
+
};
|
495 |
+
|
496 |
+
/** @type {{id: string | null, promise: Promise<import('./types').NavigationResult | undefined> | null}} */
|
497 |
+
const load_cache = {
|
498 |
+
id: null,
|
499 |
+
promise: null
|
500 |
+
};
|
501 |
+
|
502 |
+
const callbacks = {
|
503 |
+
/** @type {Array<(opts: { from: URL, to: URL | null, cancel: () => void }) => void>} */
|
504 |
+
before_navigate: [],
|
505 |
+
|
506 |
+
/** @type {Array<(opts: { from: URL | null, to: URL }) => void>} */
|
507 |
+
after_navigate: []
|
508 |
+
};
|
509 |
+
|
510 |
+
/** @type {import('./types').NavigationState} */
|
511 |
+
let current = {
|
512 |
+
branch: [],
|
513 |
+
error: null,
|
514 |
+
session_id: 0,
|
515 |
+
stuff: root_stuff,
|
516 |
+
// @ts-ignore - we need the initial value to be null
|
517 |
+
url: null
|
518 |
+
};
|
519 |
+
|
520 |
+
let started = false;
|
521 |
+
let autoscroll = true;
|
522 |
+
let updating = false;
|
523 |
+
let session_id = 1;
|
524 |
+
|
525 |
+
/** @type {Promise<void> | null} */
|
526 |
+
let invalidating = null;
|
527 |
+
|
528 |
+
/** @type {import('svelte').SvelteComponent} */
|
529 |
+
let root;
|
530 |
+
|
531 |
+
/** @type {App.Session} */
|
532 |
+
let $session;
|
533 |
+
|
534 |
+
let ready = false;
|
535 |
+
stores.session.subscribe(async (value) => {
|
536 |
+
$session = value;
|
537 |
+
|
538 |
+
if (!ready) return;
|
539 |
+
session_id += 1;
|
540 |
+
|
541 |
+
update(new URL(location.href), [], true);
|
542 |
+
});
|
543 |
+
ready = true;
|
544 |
+
|
545 |
+
let router_enabled = true;
|
546 |
+
|
547 |
+
// keeping track of the history index in order to prevent popstate navigation events if needed
|
548 |
+
let current_history_index = history.state?.[INDEX_KEY];
|
549 |
+
|
550 |
+
if (!current_history_index) {
|
551 |
+
// we use Date.now() as an offset so that cross-document navigations
|
552 |
+
// within the app don't result in data loss
|
553 |
+
current_history_index = Date.now();
|
554 |
+
|
555 |
+
// create initial history entry, so we can return here
|
556 |
+
history.replaceState(
|
557 |
+
{ ...history.state, [INDEX_KEY]: current_history_index },
|
558 |
+
'',
|
559 |
+
location.href
|
560 |
+
);
|
561 |
+
}
|
562 |
+
|
563 |
+
// if we reload the page, or Cmd-Shift-T back to it,
|
564 |
+
// recover scroll position
|
565 |
+
const scroll = scroll_positions[current_history_index];
|
566 |
+
if (scroll) {
|
567 |
+
history.scrollRestoration = 'manual';
|
568 |
+
scrollTo(scroll.x, scroll.y);
|
569 |
+
}
|
570 |
+
|
571 |
+
let hash_navigating = false;
|
572 |
+
|
573 |
+
/** @type {import('types').Page} */
|
574 |
+
let page;
|
575 |
+
|
576 |
+
/** @type {{}} */
|
577 |
+
let token;
|
578 |
+
|
579 |
+
/**
|
580 |
+
* @param {string | URL} url
|
581 |
+
* @param {{ noscroll?: boolean; replaceState?: boolean; keepfocus?: boolean; state?: any }} opts
|
582 |
+
* @param {string[]} redirect_chain
|
583 |
+
*/
|
584 |
+
async function goto(
|
585 |
+
url,
|
586 |
+
{ noscroll = false, replaceState = false, keepfocus = false, state = {} },
|
587 |
+
redirect_chain
|
588 |
+
) {
|
589 |
+
if (typeof url === 'string') {
|
590 |
+
url = new URL(url, get_base_uri(document));
|
591 |
+
}
|
592 |
+
|
593 |
+
if (router_enabled) {
|
594 |
+
return navigate({
|
595 |
+
url,
|
596 |
+
scroll: noscroll ? scroll_state() : null,
|
597 |
+
keepfocus,
|
598 |
+
redirect_chain,
|
599 |
+
details: {
|
600 |
+
state,
|
601 |
+
replaceState
|
602 |
+
},
|
603 |
+
accepted: () => {},
|
604 |
+
blocked: () => {}
|
605 |
+
});
|
606 |
+
}
|
607 |
+
|
608 |
+
await native_navigation(url);
|
609 |
+
}
|
610 |
+
|
611 |
+
/** @param {URL} url */
|
612 |
+
async function prefetch(url) {
|
613 |
+
const intent = get_navigation_intent(url);
|
614 |
+
|
615 |
+
if (!intent) {
|
616 |
+
throw new Error('Attempted to prefetch a URL that does not belong to this app');
|
617 |
+
}
|
618 |
+
|
619 |
+
load_cache.promise = load_route(intent, false);
|
620 |
+
load_cache.id = intent.id;
|
621 |
+
|
622 |
+
return load_cache.promise;
|
623 |
+
}
|
624 |
+
|
625 |
+
/**
|
626 |
+
* Returns `true` if update completes, `false` if it is aborted
|
627 |
+
* @param {URL} url
|
628 |
+
* @param {string[]} redirect_chain
|
629 |
+
* @param {boolean} no_cache
|
630 |
+
* @param {{hash?: string, scroll: { x: number, y: number } | null, keepfocus: boolean, details: { replaceState: boolean, state: any } | null}} [opts]
|
631 |
+
* @param {() => void} [callback]
|
632 |
+
*/
|
633 |
+
async function update(url, redirect_chain, no_cache, opts, callback) {
|
634 |
+
const intent = get_navigation_intent(url);
|
635 |
+
|
636 |
+
const current_token = (token = {});
|
637 |
+
let navigation_result = intent && (await load_route(intent, no_cache));
|
638 |
+
|
639 |
+
if (
|
640 |
+
!navigation_result &&
|
641 |
+
url.origin === location.origin &&
|
642 |
+
url.pathname === location.pathname
|
643 |
+
) {
|
644 |
+
// this could happen in SPA fallback mode if the user navigated to
|
645 |
+
// `/non-existent-page`. if we fall back to reloading the page, it
|
646 |
+
// will create an infinite loop. so whereas we normally handle
|
647 |
+
// unknown routes by going to the server, in this special case
|
648 |
+
// we render a client-side error page instead
|
649 |
+
navigation_result = await load_root_error_page({
|
650 |
+
status: 404,
|
651 |
+
error: new Error(`Not found: ${url.pathname}`),
|
652 |
+
url,
|
653 |
+
routeId: null
|
654 |
+
});
|
655 |
+
}
|
656 |
+
|
657 |
+
if (!navigation_result) {
|
658 |
+
await native_navigation(url);
|
659 |
+
return false; // unnecessary, but TypeScript prefers it this way
|
660 |
+
}
|
661 |
+
|
662 |
+
// abort if user navigated during update
|
663 |
+
if (token !== current_token) return false;
|
664 |
+
|
665 |
+
invalidated.length = 0;
|
666 |
+
|
667 |
+
if (navigation_result.redirect) {
|
668 |
+
if (redirect_chain.length > 10 || redirect_chain.includes(url.pathname)) {
|
669 |
+
navigation_result = await load_root_error_page({
|
670 |
+
status: 500,
|
671 |
+
error: new Error('Redirect loop'),
|
672 |
+
url,
|
673 |
+
routeId: null
|
674 |
+
});
|
675 |
+
} else {
|
676 |
+
if (router_enabled) {
|
677 |
+
goto(new URL(navigation_result.redirect, url).href, {}, [
|
678 |
+
...redirect_chain,
|
679 |
+
url.pathname
|
680 |
+
]);
|
681 |
+
} else {
|
682 |
+
await native_navigation(new URL(navigation_result.redirect, location.href));
|
683 |
+
}
|
684 |
+
|
685 |
+
return false;
|
686 |
+
}
|
687 |
+
} else if (navigation_result.props?.page?.status >= 400) {
|
688 |
+
const updated = await stores.updated.check();
|
689 |
+
if (updated) {
|
690 |
+
await native_navigation(url);
|
691 |
+
}
|
692 |
+
}
|
693 |
+
|
694 |
+
updating = true;
|
695 |
+
|
696 |
+
if (opts && opts.details) {
|
697 |
+
const { details } = opts;
|
698 |
+
const change = details.replaceState ? 0 : 1;
|
699 |
+
details.state[INDEX_KEY] = current_history_index += change;
|
700 |
+
history[details.replaceState ? 'replaceState' : 'pushState'](details.state, '', url);
|
701 |
+
}
|
702 |
+
|
703 |
+
if (started) {
|
704 |
+
current = navigation_result.state;
|
705 |
+
|
706 |
+
if (navigation_result.props.page) {
|
707 |
+
navigation_result.props.page.url = url;
|
708 |
+
}
|
709 |
+
|
710 |
+
root.$set(navigation_result.props);
|
711 |
+
} else {
|
712 |
+
initialize(navigation_result);
|
713 |
+
}
|
714 |
+
|
715 |
+
// opts must be passed if we're navigating
|
716 |
+
if (opts) {
|
717 |
+
const { scroll, keepfocus } = opts;
|
718 |
+
|
719 |
+
if (!keepfocus) {
|
720 |
+
// Reset page selection and focus
|
721 |
+
// We try to mimic browsers' behaviour as closely as possible by targeting the
|
722 |
+
// first scrollable region, but unfortunately it's not a perfect match — e.g.
|
723 |
+
// shift-tabbing won't immediately cycle up from the end of the page on Chromium
|
724 |
+
// See https://html.spec.whatwg.org/multipage/interaction.html#get-the-focusable-area
|
725 |
+
const root = document.body;
|
726 |
+
const tabindex = root.getAttribute('tabindex');
|
727 |
+
|
728 |
+
getSelection()?.removeAllRanges();
|
729 |
+
root.tabIndex = -1;
|
730 |
+
root.focus({ preventScroll: true });
|
731 |
+
|
732 |
+
// restore `tabindex` as to prevent `root` from stealing input from elements
|
733 |
+
if (tabindex !== null) {
|
734 |
+
root.setAttribute('tabindex', tabindex);
|
735 |
+
} else {
|
736 |
+
root.removeAttribute('tabindex');
|
737 |
+
}
|
738 |
+
}
|
739 |
+
|
740 |
+
// need to render the DOM before we can scroll to the rendered elements
|
741 |
+
await tick();
|
742 |
+
|
743 |
+
if (autoscroll) {
|
744 |
+
const deep_linked = url.hash && document.getElementById(url.hash.slice(1));
|
745 |
+
if (scroll) {
|
746 |
+
scrollTo(scroll.x, scroll.y);
|
747 |
+
} else if (deep_linked) {
|
748 |
+
// Here we use `scrollIntoView` on the element instead of `scrollTo`
|
749 |
+
// because it natively supports the `scroll-margin` and `scroll-behavior`
|
750 |
+
// CSS properties.
|
751 |
+
deep_linked.scrollIntoView();
|
752 |
+
} else {
|
753 |
+
scrollTo(0, 0);
|
754 |
+
}
|
755 |
+
}
|
756 |
+
} else {
|
757 |
+
// in this case we're simply invalidating
|
758 |
+
await tick();
|
759 |
+
}
|
760 |
+
|
761 |
+
load_cache.promise = null;
|
762 |
+
load_cache.id = null;
|
763 |
+
autoscroll = true;
|
764 |
+
|
765 |
+
if (navigation_result.props.page) {
|
766 |
+
page = navigation_result.props.page;
|
767 |
+
}
|
768 |
+
|
769 |
+
const leaf_node = navigation_result.state.branch[navigation_result.state.branch.length - 1];
|
770 |
+
router_enabled = leaf_node?.module.router !== false;
|
771 |
+
|
772 |
+
if (callback) callback();
|
773 |
+
|
774 |
+
updating = false;
|
775 |
+
}
|
776 |
+
|
777 |
+
/** @param {import('./types').NavigationResult} result */
|
778 |
+
function initialize(result) {
|
779 |
+
current = result.state;
|
780 |
+
|
781 |
+
const style = document.querySelector('style[data-sveltekit]');
|
782 |
+
if (style) style.remove();
|
783 |
+
|
784 |
+
page = result.props.page;
|
785 |
+
|
786 |
+
root = new Root({
|
787 |
+
target,
|
788 |
+
props: { ...result.props, stores },
|
789 |
+
hydrate: true
|
790 |
+
});
|
791 |
+
|
792 |
+
if (router_enabled) {
|
793 |
+
const navigation = { from: null, to: new URL(location.href) };
|
794 |
+
callbacks.after_navigate.forEach((fn) => fn(navigation));
|
795 |
+
}
|
796 |
+
|
797 |
+
started = true;
|
798 |
+
}
|
799 |
+
|
800 |
+
/**
|
801 |
+
*
|
802 |
+
* @param {{
|
803 |
+
* url: URL;
|
804 |
+
* params: Record<string, string>;
|
805 |
+
* stuff: Record<string, any>;
|
806 |
+
* branch: Array<import('./types').BranchNode | undefined>;
|
807 |
+
* status: number;
|
808 |
+
* error: Error | null;
|
809 |
+
* routeId: string | null;
|
810 |
+
* }} opts
|
811 |
+
*/
|
812 |
+
async function get_navigation_result_from_branch({
|
813 |
+
url,
|
814 |
+
params,
|
815 |
+
stuff,
|
816 |
+
branch,
|
817 |
+
status,
|
818 |
+
error,
|
819 |
+
routeId
|
820 |
+
}) {
|
821 |
+
const filtered = /** @type {import('./types').BranchNode[] } */ (branch.filter(Boolean));
|
822 |
+
const redirect = filtered.find((f) => f.loaded?.redirect);
|
823 |
+
|
824 |
+
/** @type {import('./types').NavigationResult} */
|
825 |
+
const result = {
|
826 |
+
redirect: redirect?.loaded?.redirect,
|
827 |
+
state: {
|
828 |
+
url,
|
829 |
+
params,
|
830 |
+
branch,
|
831 |
+
error,
|
832 |
+
stuff,
|
833 |
+
session_id
|
834 |
+
},
|
835 |
+
props: {
|
836 |
+
components: filtered.map((node) => node.module.default)
|
837 |
+
}
|
838 |
+
};
|
839 |
+
|
840 |
+
for (let i = 0; i < filtered.length; i += 1) {
|
841 |
+
const loaded = filtered[i].loaded;
|
842 |
+
result.props[`props_${i}`] = loaded ? await loaded.props : null;
|
843 |
+
}
|
844 |
+
|
845 |
+
const page_changed =
|
846 |
+
!current.url ||
|
847 |
+
url.href !== current.url.href ||
|
848 |
+
current.error !== error ||
|
849 |
+
current.stuff !== stuff;
|
850 |
+
|
851 |
+
if (page_changed) {
|
852 |
+
result.props.page = { error, params, routeId, status, stuff, url };
|
853 |
+
|
854 |
+
// TODO remove this for 1.0
|
855 |
+
/**
|
856 |
+
* @param {string} property
|
857 |
+
* @param {string} replacement
|
858 |
+
*/
|
859 |
+
const print_error = (property, replacement) => {
|
860 |
+
Object.defineProperty(result.props.page, property, {
|
861 |
+
get: () => {
|
862 |
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
863 |
+
}
|
864 |
+
});
|
865 |
+
};
|
866 |
+
|
867 |
+
print_error('origin', 'origin');
|
868 |
+
print_error('path', 'pathname');
|
869 |
+
print_error('query', 'searchParams');
|
870 |
+
}
|
871 |
+
|
872 |
+
const leaf = filtered[filtered.length - 1];
|
873 |
+
const load_cache = leaf?.loaded?.cache;
|
874 |
+
|
875 |
+
if (load_cache) {
|
876 |
+
const key = url.pathname + url.search; // omit hash
|
877 |
+
let ready = false;
|
878 |
+
|
879 |
+
const clear = () => {
|
880 |
+
if (cache.get(key) === result) {
|
881 |
+
cache.delete(key);
|
882 |
+
}
|
883 |
+
|
884 |
+
unsubscribe();
|
885 |
+
clearTimeout(timeout);
|
886 |
+
};
|
887 |
+
|
888 |
+
const timeout = setTimeout(clear, load_cache.maxage * 1000);
|
889 |
+
|
890 |
+
const unsubscribe = stores.session.subscribe(() => {
|
891 |
+
if (ready) clear();
|
892 |
+
});
|
893 |
+
|
894 |
+
ready = true;
|
895 |
+
|
896 |
+
cache.set(key, result);
|
897 |
+
}
|
898 |
+
|
899 |
+
return result;
|
900 |
+
}
|
901 |
+
|
902 |
+
/**
|
903 |
+
* @param {{
|
904 |
+
* status?: number;
|
905 |
+
* error?: Error;
|
906 |
+
* module: import('types').CSRComponent;
|
907 |
+
* url: URL;
|
908 |
+
* params: Record<string, string>;
|
909 |
+
* stuff: Record<string, any>;
|
910 |
+
* props?: Record<string, any>;
|
911 |
+
* routeId: string | null;
|
912 |
+
* }} options
|
913 |
+
*/
|
914 |
+
async function load_node({ status, error, module, url, params, stuff, props, routeId }) {
|
915 |
+
/** @type {import('./types').BranchNode} */
|
916 |
+
const node = {
|
917 |
+
module,
|
918 |
+
uses: {
|
919 |
+
params: new Set(),
|
920 |
+
url: false,
|
921 |
+
session: false,
|
922 |
+
stuff: false,
|
923 |
+
dependencies: new Set()
|
924 |
+
},
|
925 |
+
loaded: null,
|
926 |
+
stuff
|
927 |
+
};
|
928 |
+
|
929 |
+
/** @param dep {string} */
|
930 |
+
function add_dependency(dep) {
|
931 |
+
const { href } = new URL(dep, url);
|
932 |
+
node.uses.dependencies.add(href);
|
933 |
+
}
|
934 |
+
|
935 |
+
if (props) {
|
936 |
+
// shadow endpoint props means we need to mark this URL as a dependency of itself
|
937 |
+
node.uses.dependencies.add(url.href);
|
938 |
+
}
|
939 |
+
|
940 |
+
/** @type {Record<string, string>} */
|
941 |
+
const uses_params = {};
|
942 |
+
for (const key in params) {
|
943 |
+
Object.defineProperty(uses_params, key, {
|
944 |
+
get() {
|
945 |
+
node.uses.params.add(key);
|
946 |
+
return params[key];
|
947 |
+
},
|
948 |
+
enumerable: true
|
949 |
+
});
|
950 |
+
}
|
951 |
+
|
952 |
+
const session = $session;
|
953 |
+
const load_url = new LoadURL(url);
|
954 |
+
|
955 |
+
if (module.load) {
|
956 |
+
/** @type {import('types').LoadEvent} */
|
957 |
+
const load_input = {
|
958 |
+
routeId,
|
959 |
+
params: uses_params,
|
960 |
+
props: props || {},
|
961 |
+
get url() {
|
962 |
+
node.uses.url = true;
|
963 |
+
return load_url;
|
964 |
+
},
|
965 |
+
get session() {
|
966 |
+
node.uses.session = true;
|
967 |
+
return session;
|
968 |
+
},
|
969 |
+
get stuff() {
|
970 |
+
node.uses.stuff = true;
|
971 |
+
return { ...stuff };
|
972 |
+
},
|
973 |
+
async fetch(resource, init) {
|
974 |
+
let requested;
|
975 |
+
|
976 |
+
if (typeof resource === 'string') {
|
977 |
+
requested = resource;
|
978 |
+
} else {
|
979 |
+
requested = resource.url;
|
980 |
+
|
981 |
+
// we're not allowed to modify the received `Request` object, so in order
|
982 |
+
// to fixup relative urls we create a new equivalent `init` object instead
|
983 |
+
init = {
|
984 |
+
// the request body must be consumed in memory until browsers
|
985 |
+
// implement streaming request bodies and/or the body getter
|
986 |
+
body:
|
987 |
+
resource.method === 'GET' || resource.method === 'HEAD'
|
988 |
+
? undefined
|
989 |
+
: await resource.blob(),
|
990 |
+
cache: resource.cache,
|
991 |
+
credentials: resource.credentials,
|
992 |
+
headers: resource.headers,
|
993 |
+
integrity: resource.integrity,
|
994 |
+
keepalive: resource.keepalive,
|
995 |
+
method: resource.method,
|
996 |
+
mode: resource.mode,
|
997 |
+
redirect: resource.redirect,
|
998 |
+
referrer: resource.referrer,
|
999 |
+
referrerPolicy: resource.referrerPolicy,
|
1000 |
+
signal: resource.signal,
|
1001 |
+
...init
|
1002 |
+
};
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
// we must fixup relative urls so they are resolved from the target page
|
1006 |
+
const normalized = new URL(requested, url).href;
|
1007 |
+
add_dependency(normalized);
|
1008 |
+
|
1009 |
+
// prerendered pages may be served from any origin, so `initial_fetch` urls shouldn't be normalized
|
1010 |
+
return started ? native_fetch(normalized, init) : initial_fetch(requested, init);
|
1011 |
+
},
|
1012 |
+
status: status ?? null,
|
1013 |
+
error: error ?? null
|
1014 |
+
};
|
1015 |
+
|
1016 |
+
if (import.meta.env.DEV) {
|
1017 |
+
// TODO remove this for 1.0
|
1018 |
+
Object.defineProperty(load_input, 'page', {
|
1019 |
+
get: () => {
|
1020 |
+
throw new Error('`page` in `load` functions has been replaced by `url` and `params`');
|
1021 |
+
}
|
1022 |
+
});
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
let loaded;
|
1026 |
+
|
1027 |
+
if (import.meta.env.DEV) {
|
1028 |
+
try {
|
1029 |
+
lock_fetch();
|
1030 |
+
loaded = await module.load.call(null, load_input);
|
1031 |
+
} finally {
|
1032 |
+
unlock_fetch();
|
1033 |
+
}
|
1034 |
+
} else {
|
1035 |
+
loaded = await module.load.call(null, load_input);
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
if (!loaded) {
|
1039 |
+
throw new Error('load function must return a value');
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
node.loaded = normalize(loaded);
|
1043 |
+
if (node.loaded.stuff) node.stuff = node.loaded.stuff;
|
1044 |
+
if (node.loaded.dependencies) {
|
1045 |
+
node.loaded.dependencies.forEach(add_dependency);
|
1046 |
+
}
|
1047 |
+
} else if (props) {
|
1048 |
+
node.loaded = normalize({ props });
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
return node;
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
/**
|
1055 |
+
* @param {import('./types').NavigationIntent} intent
|
1056 |
+
* @param {boolean} no_cache
|
1057 |
+
*/
|
1058 |
+
async function load_route({ id, url, params, route }, no_cache) {
|
1059 |
+
if (load_cache.id === id && load_cache.promise) {
|
1060 |
+
return load_cache.promise;
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
if (!no_cache) {
|
1064 |
+
const cached = cache.get(id);
|
1065 |
+
if (cached) return cached;
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
const { a, b, has_shadow } = route;
|
1069 |
+
|
1070 |
+
const changed = current.url && {
|
1071 |
+
url: id !== current.url.pathname + current.url.search,
|
1072 |
+
params: Object.keys(params).filter((key) => current.params[key] !== params[key]),
|
1073 |
+
session: session_id !== current.session_id
|
1074 |
+
};
|
1075 |
+
|
1076 |
+
/** @type {Array<import('./types').BranchNode | undefined>} */
|
1077 |
+
let branch = [];
|
1078 |
+
|
1079 |
+
/** @type {Record<string, any>} */
|
1080 |
+
let stuff = root_stuff;
|
1081 |
+
let stuff_changed = false;
|
1082 |
+
|
1083 |
+
/** @type {number | undefined} */
|
1084 |
+
let status = 200;
|
1085 |
+
|
1086 |
+
/** @type {Error | null} */
|
1087 |
+
let error = null;
|
1088 |
+
|
1089 |
+
// preload modules to avoid waterfall, but handle rejections
|
1090 |
+
// so they don't get reported to Sentry et al (we don't need
|
1091 |
+
// to act on the failures at this point)
|
1092 |
+
a.forEach((loader) => loader().catch(() => {}));
|
1093 |
+
|
1094 |
+
load: for (let i = 0; i < a.length; i += 1) {
|
1095 |
+
/** @type {import('./types').BranchNode | undefined} */
|
1096 |
+
let node;
|
1097 |
+
|
1098 |
+
try {
|
1099 |
+
if (!a[i]) continue;
|
1100 |
+
|
1101 |
+
const module = await a[i]();
|
1102 |
+
const previous = current.branch[i];
|
1103 |
+
|
1104 |
+
const changed_since_last_render =
|
1105 |
+
!previous ||
|
1106 |
+
module !== previous.module ||
|
1107 |
+
(changed.url && previous.uses.url) ||
|
1108 |
+
changed.params.some((param) => previous.uses.params.has(param)) ||
|
1109 |
+
(changed.session && previous.uses.session) ||
|
1110 |
+
Array.from(previous.uses.dependencies).some((dep) => invalidated.some((fn) => fn(dep))) ||
|
1111 |
+
(stuff_changed && previous.uses.stuff);
|
1112 |
+
|
1113 |
+
if (changed_since_last_render) {
|
1114 |
+
/** @type {Record<string, any>} */
|
1115 |
+
let props = {};
|
1116 |
+
|
1117 |
+
const is_shadow_page = has_shadow && i === a.length - 1;
|
1118 |
+
|
1119 |
+
if (is_shadow_page) {
|
1120 |
+
const res = await native_fetch(
|
1121 |
+
`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
|
1122 |
+
{
|
1123 |
+
headers: {
|
1124 |
+
'x-sveltekit-load': 'true'
|
1125 |
+
}
|
1126 |
+
}
|
1127 |
+
);
|
1128 |
+
|
1129 |
+
if (res.ok) {
|
1130 |
+
const redirect = res.headers.get('x-sveltekit-location');
|
1131 |
+
|
1132 |
+
if (redirect) {
|
1133 |
+
return {
|
1134 |
+
redirect,
|
1135 |
+
props: {},
|
1136 |
+
state: current
|
1137 |
+
};
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
props = res.status === 204 ? {} : await res.json();
|
1141 |
+
} else {
|
1142 |
+
status = res.status;
|
1143 |
+
error = new Error('Failed to load data');
|
1144 |
+
}
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
if (!error) {
|
1148 |
+
node = await load_node({
|
1149 |
+
module,
|
1150 |
+
url,
|
1151 |
+
params,
|
1152 |
+
props,
|
1153 |
+
stuff,
|
1154 |
+
routeId: route.id
|
1155 |
+
});
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
if (node) {
|
1159 |
+
if (is_shadow_page) {
|
1160 |
+
node.uses.url = true;
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
if (node.loaded) {
|
1164 |
+
if (node.loaded.error) {
|
1165 |
+
status = node.loaded.status;
|
1166 |
+
error = node.loaded.error;
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
if (node.loaded.redirect) {
|
1170 |
+
return {
|
1171 |
+
redirect: node.loaded.redirect,
|
1172 |
+
props: {},
|
1173 |
+
state: current
|
1174 |
+
};
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
if (node.loaded.stuff) {
|
1178 |
+
stuff_changed = true;
|
1179 |
+
}
|
1180 |
+
}
|
1181 |
+
}
|
1182 |
+
} else {
|
1183 |
+
node = previous;
|
1184 |
+
}
|
1185 |
+
} catch (e) {
|
1186 |
+
status = 500;
|
1187 |
+
error = coalesce_to_error(e);
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
if (error) {
|
1191 |
+
while (i--) {
|
1192 |
+
if (b[i]) {
|
1193 |
+
let error_loaded;
|
1194 |
+
|
1195 |
+
/** @type {import('./types').BranchNode | undefined} */
|
1196 |
+
let node_loaded;
|
1197 |
+
let j = i;
|
1198 |
+
while (!(node_loaded = branch[j])) {
|
1199 |
+
j -= 1;
|
1200 |
+
}
|
1201 |
+
|
1202 |
+
try {
|
1203 |
+
error_loaded = await load_node({
|
1204 |
+
status,
|
1205 |
+
error,
|
1206 |
+
module: await b[i](),
|
1207 |
+
url,
|
1208 |
+
params,
|
1209 |
+
stuff: node_loaded.stuff,
|
1210 |
+
routeId: route.id
|
1211 |
+
});
|
1212 |
+
|
1213 |
+
if (error_loaded?.loaded?.error) {
|
1214 |
+
continue;
|
1215 |
+
}
|
1216 |
+
|
1217 |
+
if (error_loaded?.loaded?.stuff) {
|
1218 |
+
stuff = {
|
1219 |
+
...stuff,
|
1220 |
+
...error_loaded.loaded.stuff
|
1221 |
+
};
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
branch = branch.slice(0, j + 1).concat(error_loaded);
|
1225 |
+
break load;
|
1226 |
+
} catch (e) {
|
1227 |
+
continue;
|
1228 |
+
}
|
1229 |
+
}
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
return await load_root_error_page({
|
1233 |
+
status,
|
1234 |
+
error,
|
1235 |
+
url,
|
1236 |
+
routeId: route.id
|
1237 |
+
});
|
1238 |
+
} else {
|
1239 |
+
if (node?.loaded?.stuff) {
|
1240 |
+
stuff = {
|
1241 |
+
...stuff,
|
1242 |
+
...node.loaded.stuff
|
1243 |
+
};
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
branch.push(node);
|
1247 |
+
}
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
return await get_navigation_result_from_branch({
|
1251 |
+
url,
|
1252 |
+
params,
|
1253 |
+
stuff,
|
1254 |
+
branch,
|
1255 |
+
status,
|
1256 |
+
error,
|
1257 |
+
routeId: route.id
|
1258 |
+
});
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
/**
|
1262 |
+
* @param {{
|
1263 |
+
* status: number;
|
1264 |
+
* error: Error;
|
1265 |
+
* url: URL;
|
1266 |
+
* routeId: string | null
|
1267 |
+
* }} opts
|
1268 |
+
*/
|
1269 |
+
async function load_root_error_page({ status, error, url, routeId }) {
|
1270 |
+
/** @type {Record<string, string>} */
|
1271 |
+
const params = {}; // error page does not have params
|
1272 |
+
|
1273 |
+
const root_layout = await load_node({
|
1274 |
+
module: await default_layout,
|
1275 |
+
url,
|
1276 |
+
params,
|
1277 |
+
stuff: {},
|
1278 |
+
routeId
|
1279 |
+
});
|
1280 |
+
|
1281 |
+
const root_error = await load_node({
|
1282 |
+
status,
|
1283 |
+
error,
|
1284 |
+
module: await default_error,
|
1285 |
+
url,
|
1286 |
+
params,
|
1287 |
+
stuff: (root_layout && root_layout.loaded && root_layout.loaded.stuff) || {},
|
1288 |
+
routeId
|
1289 |
+
});
|
1290 |
+
|
1291 |
+
return await get_navigation_result_from_branch({
|
1292 |
+
url,
|
1293 |
+
params,
|
1294 |
+
stuff: {
|
1295 |
+
...root_layout?.loaded?.stuff,
|
1296 |
+
...root_error?.loaded?.stuff
|
1297 |
+
},
|
1298 |
+
branch: [root_layout, root_error],
|
1299 |
+
status,
|
1300 |
+
error,
|
1301 |
+
routeId
|
1302 |
+
});
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
/** @param {URL} url */
|
1306 |
+
function get_navigation_intent(url) {
|
1307 |
+
if (url.origin !== location.origin || !url.pathname.startsWith(base)) return;
|
1308 |
+
|
1309 |
+
const path = decodeURI(url.pathname.slice(base.length) || '/');
|
1310 |
+
|
1311 |
+
for (const route of routes) {
|
1312 |
+
const params = route.exec(path);
|
1313 |
+
|
1314 |
+
if (params) {
|
1315 |
+
/** @type {import('./types').NavigationIntent} */
|
1316 |
+
const intent = {
|
1317 |
+
id: url.pathname + url.search,
|
1318 |
+
route,
|
1319 |
+
params,
|
1320 |
+
url
|
1321 |
+
};
|
1322 |
+
|
1323 |
+
return intent;
|
1324 |
+
}
|
1325 |
+
}
|
1326 |
+
}
|
1327 |
+
|
1328 |
+
/**
|
1329 |
+
* @param {{
|
1330 |
+
* url: URL;
|
1331 |
+
* scroll: { x: number, y: number } | null;
|
1332 |
+
* keepfocus: boolean;
|
1333 |
+
* redirect_chain: string[];
|
1334 |
+
* details: {
|
1335 |
+
* replaceState: boolean;
|
1336 |
+
* state: any;
|
1337 |
+
* } | null;
|
1338 |
+
* accepted: () => void;
|
1339 |
+
* blocked: () => void;
|
1340 |
+
* }} opts
|
1341 |
+
*/
|
1342 |
+
async function navigate({ url, scroll, keepfocus, redirect_chain, details, accepted, blocked }) {
|
1343 |
+
const from = current.url;
|
1344 |
+
let should_block = false;
|
1345 |
+
|
1346 |
+
const navigation = {
|
1347 |
+
from,
|
1348 |
+
to: url,
|
1349 |
+
cancel: () => (should_block = true)
|
1350 |
+
};
|
1351 |
+
|
1352 |
+
callbacks.before_navigate.forEach((fn) => fn(navigation));
|
1353 |
+
|
1354 |
+
if (should_block) {
|
1355 |
+
blocked();
|
1356 |
+
return;
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
const pathname = normalize_path(url.pathname, trailing_slash);
|
1360 |
+
const normalized = new URL(url.origin + pathname + url.search + url.hash);
|
1361 |
+
|
1362 |
+
update_scroll_positions(current_history_index);
|
1363 |
+
|
1364 |
+
accepted();
|
1365 |
+
|
1366 |
+
if (started) {
|
1367 |
+
stores.navigating.set({
|
1368 |
+
from: current.url,
|
1369 |
+
to: normalized
|
1370 |
+
});
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
await update(
|
1374 |
+
normalized,
|
1375 |
+
redirect_chain,
|
1376 |
+
false,
|
1377 |
+
{
|
1378 |
+
scroll,
|
1379 |
+
keepfocus,
|
1380 |
+
details
|
1381 |
+
},
|
1382 |
+
() => {
|
1383 |
+
const navigation = { from, to: normalized };
|
1384 |
+
callbacks.after_navigate.forEach((fn) => fn(navigation));
|
1385 |
+
|
1386 |
+
stores.navigating.set(null);
|
1387 |
+
}
|
1388 |
+
);
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
/**
|
1392 |
+
* Loads `href` the old-fashioned way, with a full page reload.
|
1393 |
+
* Returns a `Promise` that never resolves (to prevent any
|
1394 |
+
* subsequent work, e.g. history manipulation, from happening)
|
1395 |
+
* @param {URL} url
|
1396 |
+
*/
|
1397 |
+
function native_navigation(url) {
|
1398 |
+
location.href = url.href;
|
1399 |
+
return new Promise(() => {});
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
if (import.meta.hot) {
|
1403 |
+
import.meta.hot.on('vite:beforeUpdate', () => {
|
1404 |
+
if (current.error) location.reload();
|
1405 |
+
});
|
1406 |
+
}
|
1407 |
+
|
1408 |
+
return {
|
1409 |
+
after_navigate: (fn) => {
|
1410 |
+
onMount(() => {
|
1411 |
+
callbacks.after_navigate.push(fn);
|
1412 |
+
|
1413 |
+
return () => {
|
1414 |
+
const i = callbacks.after_navigate.indexOf(fn);
|
1415 |
+
callbacks.after_navigate.splice(i, 1);
|
1416 |
+
};
|
1417 |
+
});
|
1418 |
+
},
|
1419 |
+
|
1420 |
+
before_navigate: (fn) => {
|
1421 |
+
onMount(() => {
|
1422 |
+
callbacks.before_navigate.push(fn);
|
1423 |
+
|
1424 |
+
return () => {
|
1425 |
+
const i = callbacks.before_navigate.indexOf(fn);
|
1426 |
+
callbacks.before_navigate.splice(i, 1);
|
1427 |
+
};
|
1428 |
+
});
|
1429 |
+
},
|
1430 |
+
|
1431 |
+
disable_scroll_handling: () => {
|
1432 |
+
if (import.meta.env.DEV && started && !updating) {
|
1433 |
+
throw new Error('Can only disable scroll handling during navigation');
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
if (updating || !started) {
|
1437 |
+
autoscroll = false;
|
1438 |
+
}
|
1439 |
+
},
|
1440 |
+
|
1441 |
+
goto: (href, opts = {}) => goto(href, opts, []),
|
1442 |
+
|
1443 |
+
invalidate: (resource) => {
|
1444 |
+
if (typeof resource === 'function') {
|
1445 |
+
invalidated.push(resource);
|
1446 |
+
} else {
|
1447 |
+
const { href } = new URL(resource, location.href);
|
1448 |
+
invalidated.push((dep) => dep === href);
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
if (!invalidating) {
|
1452 |
+
invalidating = Promise.resolve().then(async () => {
|
1453 |
+
await update(new URL(location.href), [], true);
|
1454 |
+
|
1455 |
+
invalidating = null;
|
1456 |
+
});
|
1457 |
+
}
|
1458 |
+
|
1459 |
+
return invalidating;
|
1460 |
+
},
|
1461 |
+
|
1462 |
+
prefetch: async (href) => {
|
1463 |
+
const url = new URL(href, get_base_uri(document));
|
1464 |
+
await prefetch(url);
|
1465 |
+
},
|
1466 |
+
|
1467 |
+
// TODO rethink this API
|
1468 |
+
prefetch_routes: async (pathnames) => {
|
1469 |
+
const matching = pathnames
|
1470 |
+
? routes.filter((route) => pathnames.some((pathname) => route.exec(pathname)))
|
1471 |
+
: routes;
|
1472 |
+
|
1473 |
+
const promises = matching.map((r) => Promise.all(r.a.map((load) => load())));
|
1474 |
+
|
1475 |
+
await Promise.all(promises);
|
1476 |
+
},
|
1477 |
+
|
1478 |
+
_start_router: () => {
|
1479 |
+
history.scrollRestoration = 'manual';
|
1480 |
+
|
1481 |
+
// Adopted from Nuxt.js
|
1482 |
+
// Reset scrollRestoration to auto when leaving page, allowing page reload
|
1483 |
+
// and back-navigation from other pages to use the browser to restore the
|
1484 |
+
// scrolling position.
|
1485 |
+
addEventListener('beforeunload', (e) => {
|
1486 |
+
let should_block = false;
|
1487 |
+
|
1488 |
+
const navigation = {
|
1489 |
+
from: current.url,
|
1490 |
+
to: null,
|
1491 |
+
cancel: () => (should_block = true)
|
1492 |
+
};
|
1493 |
+
|
1494 |
+
callbacks.before_navigate.forEach((fn) => fn(navigation));
|
1495 |
+
|
1496 |
+
if (should_block) {
|
1497 |
+
e.preventDefault();
|
1498 |
+
e.returnValue = '';
|
1499 |
+
} else {
|
1500 |
+
history.scrollRestoration = 'auto';
|
1501 |
+
}
|
1502 |
+
});
|
1503 |
+
|
1504 |
+
addEventListener('visibilitychange', () => {
|
1505 |
+
if (document.visibilityState === 'hidden') {
|
1506 |
+
update_scroll_positions(current_history_index);
|
1507 |
+
|
1508 |
+
try {
|
1509 |
+
sessionStorage[SCROLL_KEY] = JSON.stringify(scroll_positions);
|
1510 |
+
} catch {
|
1511 |
+
// do nothing
|
1512 |
+
}
|
1513 |
+
}
|
1514 |
+
});
|
1515 |
+
|
1516 |
+
/** @param {Event} event */
|
1517 |
+
const trigger_prefetch = (event) => {
|
1518 |
+
const a = find_anchor(event);
|
1519 |
+
if (a && a.href && a.hasAttribute('sveltekit:prefetch')) {
|
1520 |
+
prefetch(get_href(a));
|
1521 |
+
}
|
1522 |
+
};
|
1523 |
+
|
1524 |
+
/** @type {NodeJS.Timeout} */
|
1525 |
+
let mousemove_timeout;
|
1526 |
+
|
1527 |
+
/** @param {MouseEvent|TouchEvent} event */
|
1528 |
+
const handle_mousemove = (event) => {
|
1529 |
+
clearTimeout(mousemove_timeout);
|
1530 |
+
mousemove_timeout = setTimeout(() => {
|
1531 |
+
// event.composedPath(), which is used in find_anchor, will be empty if the event is read in a timeout
|
1532 |
+
// add a layer of indirection to address that
|
1533 |
+
event.target?.dispatchEvent(
|
1534 |
+
new CustomEvent('sveltekit:trigger_prefetch', { bubbles: true })
|
1535 |
+
);
|
1536 |
+
}, 20);
|
1537 |
+
};
|
1538 |
+
|
1539 |
+
addEventListener('touchstart', trigger_prefetch);
|
1540 |
+
addEventListener('mousemove', handle_mousemove);
|
1541 |
+
addEventListener('sveltekit:trigger_prefetch', trigger_prefetch);
|
1542 |
+
|
1543 |
+
/** @param {MouseEvent} event */
|
1544 |
+
addEventListener('click', (event) => {
|
1545 |
+
if (!router_enabled) return;
|
1546 |
+
|
1547 |
+
// Adapted from https://github.com/visionmedia/page.js
|
1548 |
+
// MIT license https://github.com/visionmedia/page.js#license
|
1549 |
+
if (event.button || event.which !== 1) return;
|
1550 |
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
1551 |
+
if (event.defaultPrevented) return;
|
1552 |
+
|
1553 |
+
const a = find_anchor(event);
|
1554 |
+
if (!a) return;
|
1555 |
+
|
1556 |
+
if (!a.href) return;
|
1557 |
+
|
1558 |
+
const is_svg_a_element = a instanceof SVGAElement;
|
1559 |
+
const url = get_href(a);
|
1560 |
+
|
1561 |
+
// Ignore if url does not have origin (e.g. `mailto:`, `tel:`.)
|
1562 |
+
// MEMO: Without this condition, firefox will open mailer twice.
|
1563 |
+
// See: https://github.com/sveltejs/kit/issues/4045
|
1564 |
+
if (!is_svg_a_element && url.origin === 'null') return;
|
1565 |
+
|
1566 |
+
// Ignore if tag has
|
1567 |
+
// 1. 'download' attribute
|
1568 |
+
// 2. 'rel' attribute includes external
|
1569 |
+
const rel = (a.getAttribute('rel') || '').split(/\s+/);
|
1570 |
+
|
1571 |
+
if (
|
1572 |
+
a.hasAttribute('download') ||
|
1573 |
+
rel.includes('external') ||
|
1574 |
+
a.hasAttribute('sveltekit:reload')
|
1575 |
+
) {
|
1576 |
+
return;
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
// Ignore if <a> has a target
|
1580 |
+
if (is_svg_a_element ? a.target.baseVal : a.target) return;
|
1581 |
+
|
1582 |
+
// Check if new url only differs by hash and use the browser default behavior in that case
|
1583 |
+
// This will ensure the `hashchange` event is fired
|
1584 |
+
// Removing the hash does a full page navigation in the browser, so make sure a hash is present
|
1585 |
+
const [base, hash] = url.href.split('#');
|
1586 |
+
if (hash !== undefined && base === location.href.split('#')[0]) {
|
1587 |
+
// set this flag to distinguish between navigations triggered by
|
1588 |
+
// clicking a hash link and those triggered by popstate
|
1589 |
+
hash_navigating = true;
|
1590 |
+
|
1591 |
+
update_scroll_positions(current_history_index);
|
1592 |
+
|
1593 |
+
stores.page.set({ ...page, url });
|
1594 |
+
stores.page.notify();
|
1595 |
+
|
1596 |
+
return;
|
1597 |
+
}
|
1598 |
+
|
1599 |
+
navigate({
|
1600 |
+
url,
|
1601 |
+
scroll: a.hasAttribute('sveltekit:noscroll') ? scroll_state() : null,
|
1602 |
+
keepfocus: false,
|
1603 |
+
redirect_chain: [],
|
1604 |
+
details: {
|
1605 |
+
state: {},
|
1606 |
+
replaceState: url.href === location.href
|
1607 |
+
},
|
1608 |
+
accepted: () => event.preventDefault(),
|
1609 |
+
blocked: () => event.preventDefault()
|
1610 |
+
});
|
1611 |
+
});
|
1612 |
+
|
1613 |
+
addEventListener('popstate', (event) => {
|
1614 |
+
if (event.state && router_enabled) {
|
1615 |
+
// if a popstate-driven navigation is cancelled, we need to counteract it
|
1616 |
+
// with history.go, which means we end up back here, hence this check
|
1617 |
+
if (event.state[INDEX_KEY] === current_history_index) return;
|
1618 |
+
|
1619 |
+
navigate({
|
1620 |
+
url: new URL(location.href),
|
1621 |
+
scroll: scroll_positions[event.state[INDEX_KEY]],
|
1622 |
+
keepfocus: false,
|
1623 |
+
redirect_chain: [],
|
1624 |
+
details: null,
|
1625 |
+
accepted: () => {
|
1626 |
+
current_history_index = event.state[INDEX_KEY];
|
1627 |
+
},
|
1628 |
+
blocked: () => {
|
1629 |
+
const delta = current_history_index - event.state[INDEX_KEY];
|
1630 |
+
history.go(delta);
|
1631 |
+
}
|
1632 |
+
});
|
1633 |
+
}
|
1634 |
+
});
|
1635 |
+
|
1636 |
+
addEventListener('hashchange', () => {
|
1637 |
+
// if the hashchange happened as a result of clicking on a link,
|
1638 |
+
// we need to update history, otherwise we have to leave it alone
|
1639 |
+
if (hash_navigating) {
|
1640 |
+
hash_navigating = false;
|
1641 |
+
history.replaceState(
|
1642 |
+
{ ...history.state, [INDEX_KEY]: ++current_history_index },
|
1643 |
+
'',
|
1644 |
+
location.href
|
1645 |
+
);
|
1646 |
+
}
|
1647 |
+
});
|
1648 |
+
},
|
1649 |
+
|
1650 |
+
_hydrate: async ({ status, error, nodes, params, routeId }) => {
|
1651 |
+
const url = new URL(location.href);
|
1652 |
+
|
1653 |
+
/** @type {Array<import('./types').BranchNode | undefined>} */
|
1654 |
+
const branch = [];
|
1655 |
+
|
1656 |
+
/** @type {Record<string, any>} */
|
1657 |
+
let stuff = {};
|
1658 |
+
|
1659 |
+
/** @type {import('./types').NavigationResult | undefined} */
|
1660 |
+
let result;
|
1661 |
+
|
1662 |
+
let error_args;
|
1663 |
+
|
1664 |
+
try {
|
1665 |
+
for (let i = 0; i < nodes.length; i += 1) {
|
1666 |
+
const is_leaf = i === nodes.length - 1;
|
1667 |
+
|
1668 |
+
let props;
|
1669 |
+
|
1670 |
+
if (is_leaf) {
|
1671 |
+
const serialized = document.querySelector('script[sveltekit\\:data-type="props"]');
|
1672 |
+
if (serialized) {
|
1673 |
+
props = JSON.parse(/** @type {string} */ (serialized.textContent));
|
1674 |
+
}
|
1675 |
+
}
|
1676 |
+
|
1677 |
+
const node = await load_node({
|
1678 |
+
module: await components[nodes[i]](),
|
1679 |
+
url,
|
1680 |
+
params,
|
1681 |
+
stuff,
|
1682 |
+
status: is_leaf ? status : undefined,
|
1683 |
+
error: is_leaf ? error : undefined,
|
1684 |
+
props,
|
1685 |
+
routeId
|
1686 |
+
});
|
1687 |
+
|
1688 |
+
if (props) {
|
1689 |
+
node.uses.dependencies.add(url.href);
|
1690 |
+
node.uses.url = true;
|
1691 |
+
}
|
1692 |
+
|
1693 |
+
branch.push(node);
|
1694 |
+
|
1695 |
+
if (node && node.loaded) {
|
1696 |
+
if (node.loaded.error) {
|
1697 |
+
if (error) throw node.loaded.error;
|
1698 |
+
error_args = {
|
1699 |
+
status: node.loaded.status,
|
1700 |
+
error: node.loaded.error,
|
1701 |
+
url,
|
1702 |
+
routeId
|
1703 |
+
};
|
1704 |
+
} else if (node.loaded.stuff) {
|
1705 |
+
stuff = {
|
1706 |
+
...stuff,
|
1707 |
+
...node.loaded.stuff
|
1708 |
+
};
|
1709 |
+
}
|
1710 |
+
}
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
result = error_args
|
1714 |
+
? await load_root_error_page(error_args)
|
1715 |
+
: await get_navigation_result_from_branch({
|
1716 |
+
url,
|
1717 |
+
params,
|
1718 |
+
stuff,
|
1719 |
+
branch,
|
1720 |
+
status,
|
1721 |
+
error,
|
1722 |
+
routeId
|
1723 |
+
});
|
1724 |
+
} catch (e) {
|
1725 |
+
if (error) throw e;
|
1726 |
+
|
1727 |
+
result = await load_root_error_page({
|
1728 |
+
status: 500,
|
1729 |
+
error: coalesce_to_error(e),
|
1730 |
+
url,
|
1731 |
+
routeId
|
1732 |
+
});
|
1733 |
+
}
|
1734 |
+
|
1735 |
+
if (result.redirect) {
|
1736 |
+
// this is a real edge case — `load` would need to return
|
1737 |
+
// a redirect but only in the browser
|
1738 |
+
await native_navigation(new URL(result.redirect, location.href));
|
1739 |
+
}
|
1740 |
+
|
1741 |
+
initialize(result);
|
1742 |
+
}
|
1743 |
+
};
|
1744 |
+
}
|
1745 |
+
|
1746 |
+
/**
|
1747 |
+
* @param {{
|
1748 |
+
* paths: {
|
1749 |
+
* assets: string;
|
1750 |
+
* base: string;
|
1751 |
+
* },
|
1752 |
+
* target: Element;
|
1753 |
+
* session: any;
|
1754 |
+
* route: boolean;
|
1755 |
+
* spa: boolean;
|
1756 |
+
* trailing_slash: import('types').TrailingSlash;
|
1757 |
+
* hydrate: {
|
1758 |
+
* status: number;
|
1759 |
+
* error: Error;
|
1760 |
+
* nodes: number[];
|
1761 |
+
* params: Record<string, string>;
|
1762 |
+
* routeId: string | null;
|
1763 |
+
* };
|
1764 |
+
* }} opts
|
1765 |
+
*/
|
1766 |
+
async function start({ paths, target, session, route, spa, trailing_slash, hydrate }) {
|
1767 |
+
const client = create_client({
|
1768 |
+
target,
|
1769 |
+
session,
|
1770 |
+
base: paths.base,
|
1771 |
+
trailing_slash
|
1772 |
+
});
|
1773 |
+
|
1774 |
+
init({ client });
|
1775 |
+
set_paths(paths);
|
1776 |
+
|
1777 |
+
if (hydrate) {
|
1778 |
+
await client._hydrate(hydrate);
|
1779 |
+
}
|
1780 |
+
|
1781 |
+
if (route) {
|
1782 |
+
if (spa) client.goto(location.href, { replaceState: true });
|
1783 |
+
client._start_router();
|
1784 |
+
}
|
1785 |
+
|
1786 |
+
dispatchEvent(new CustomEvent('sveltekit:start'));
|
1787 |
+
}
|
1788 |
+
|
1789 |
+
export { start };
|
frontend/.svelte-kit/runtime/components/error.svelte
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script context="module">
|
2 |
+
/** @type {import('@sveltejs/kit').Load} */
|
3 |
+
export function load({ error, status }) {
|
4 |
+
return {
|
5 |
+
props: { error, status }
|
6 |
+
};
|
7 |
+
}
|
8 |
+
</script>
|
9 |
+
|
10 |
+
<script>
|
11 |
+
/** @type {number} */
|
12 |
+
export let status;
|
13 |
+
|
14 |
+
/** @type {Error & {frame?: string} & {loc?: object}} */
|
15 |
+
export let error;
|
16 |
+
</script>
|
17 |
+
|
18 |
+
<h1>{status}</h1>
|
19 |
+
|
20 |
+
<pre>{error.message}</pre>
|
21 |
+
|
22 |
+
<!-- TODO figure out what to do with frames/stacktraces in prod -->
|
23 |
+
<!-- frame is populated by Svelte in its CompileError and is a Rollup/Vite convention -->
|
24 |
+
{#if error.frame}
|
25 |
+
<pre>{error.frame}</pre>
|
26 |
+
{/if}
|
27 |
+
{#if error.stack}
|
28 |
+
<pre>{error.stack}</pre>
|
29 |
+
{/if}
|
frontend/.svelte-kit/runtime/components/layout.svelte
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
<slot></slot>
|
frontend/.svelte-kit/runtime/env.js
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
let prerendering = false;
|
2 |
+
|
3 |
+
/** @param {boolean} value */
|
4 |
+
function set_prerendering(value) {
|
5 |
+
prerendering = value;
|
6 |
+
}
|
7 |
+
|
8 |
+
export { prerendering, set_prerendering };
|
frontend/.svelte-kit/runtime/paths.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @type {string} */
|
2 |
+
let base = '';
|
3 |
+
|
4 |
+
/** @type {string} */
|
5 |
+
let assets = '';
|
6 |
+
|
7 |
+
/** @param {{ base: string, assets: string }} paths */
|
8 |
+
function set_paths(paths) {
|
9 |
+
base = paths.base;
|
10 |
+
assets = paths.assets || base;
|
11 |
+
}
|
12 |
+
|
13 |
+
export { assets, base, set_paths };
|
frontend/.svelte-kit/runtime/server/index.js
ADDED
@@ -0,0 +1,3395 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @param {Partial<import('types').ResponseHeaders> | undefined} object */
|
2 |
+
function to_headers(object) {
|
3 |
+
const headers = new Headers();
|
4 |
+
|
5 |
+
if (object) {
|
6 |
+
for (const key in object) {
|
7 |
+
const value = object[key];
|
8 |
+
if (!value) continue;
|
9 |
+
|
10 |
+
if (Array.isArray(value)) {
|
11 |
+
value.forEach((value) => {
|
12 |
+
headers.append(key, /** @type {string} */ (value));
|
13 |
+
});
|
14 |
+
} else {
|
15 |
+
headers.set(key, /** @type {string} */ (value));
|
16 |
+
}
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
return headers;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Hash using djb2
|
25 |
+
* @param {import('types').StrictBody} value
|
26 |
+
*/
|
27 |
+
function hash(value) {
|
28 |
+
let hash = 5381;
|
29 |
+
let i = value.length;
|
30 |
+
|
31 |
+
if (typeof value === 'string') {
|
32 |
+
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
33 |
+
} else {
|
34 |
+
while (i) hash = (hash * 33) ^ value[--i];
|
35 |
+
}
|
36 |
+
|
37 |
+
return (hash >>> 0).toString(36);
|
38 |
+
}
|
39 |
+
|
40 |
+
/** @param {Record<string, any>} obj */
|
41 |
+
function lowercase_keys(obj) {
|
42 |
+
/** @type {Record<string, any>} */
|
43 |
+
const clone = {};
|
44 |
+
|
45 |
+
for (const key in obj) {
|
46 |
+
clone[key.toLowerCase()] = obj[key];
|
47 |
+
}
|
48 |
+
|
49 |
+
return clone;
|
50 |
+
}
|
51 |
+
|
52 |
+
/** @param {Record<string, string>} params */
|
53 |
+
function decode_params(params) {
|
54 |
+
for (const key in params) {
|
55 |
+
// input has already been decoded by decodeURI
|
56 |
+
// now handle the rest that decodeURIComponent would do
|
57 |
+
params[key] = params[key]
|
58 |
+
.replace(/%23/g, '#')
|
59 |
+
.replace(/%3[Bb]/g, ';')
|
60 |
+
.replace(/%2[Cc]/g, ',')
|
61 |
+
.replace(/%2[Ff]/g, '/')
|
62 |
+
.replace(/%3[Ff]/g, '?')
|
63 |
+
.replace(/%3[Aa]/g, ':')
|
64 |
+
.replace(/%40/g, '@')
|
65 |
+
.replace(/%26/g, '&')
|
66 |
+
.replace(/%3[Dd]/g, '=')
|
67 |
+
.replace(/%2[Bb]/g, '+')
|
68 |
+
.replace(/%24/g, '$');
|
69 |
+
}
|
70 |
+
|
71 |
+
return params;
|
72 |
+
}
|
73 |
+
|
74 |
+
/** @param {any} body */
|
75 |
+
function is_pojo(body) {
|
76 |
+
if (typeof body !== 'object') return false;
|
77 |
+
|
78 |
+
if (body) {
|
79 |
+
if (body instanceof Uint8Array) return false;
|
80 |
+
if (body instanceof ReadableStream) return false;
|
81 |
+
|
82 |
+
// if body is a node Readable, throw an error
|
83 |
+
// TODO remove this for 1.0
|
84 |
+
if (body._readableState && typeof body.pipe === 'function') {
|
85 |
+
throw new Error('Node streams are no longer supported — use a ReadableStream instead');
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
return true;
|
90 |
+
}
|
91 |
+
|
92 |
+
/** @param {import('types').RequestEvent} event */
|
93 |
+
function normalize_request_method(event) {
|
94 |
+
const method = event.request.method.toLowerCase();
|
95 |
+
return method === 'delete' ? 'del' : method; // 'delete' is a reserved word
|
96 |
+
}
|
97 |
+
|
98 |
+
/** @param {string} body */
|
99 |
+
function error(body) {
|
100 |
+
return new Response(body, {
|
101 |
+
status: 500
|
102 |
+
});
|
103 |
+
}
|
104 |
+
|
105 |
+
/** @param {unknown} s */
|
106 |
+
function is_string(s) {
|
107 |
+
return typeof s === 'string' || s instanceof String;
|
108 |
+
}
|
109 |
+
|
110 |
+
const text_types = new Set([
|
111 |
+
'application/xml',
|
112 |
+
'application/json',
|
113 |
+
'application/x-www-form-urlencoded',
|
114 |
+
'multipart/form-data'
|
115 |
+
]);
|
116 |
+
|
117 |
+
const bodyless_status_codes = new Set([101, 204, 205, 304]);
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Decides how the body should be parsed based on its mime type
|
121 |
+
*
|
122 |
+
* @param {string | undefined | null} content_type The `content-type` header of a request/response.
|
123 |
+
* @returns {boolean}
|
124 |
+
*/
|
125 |
+
function is_text(content_type) {
|
126 |
+
if (!content_type) return true; // defaults to json
|
127 |
+
const type = content_type.split(';')[0].toLowerCase(); // get the mime type
|
128 |
+
|
129 |
+
return type.startsWith('text/') || type.endsWith('+xml') || text_types.has(type);
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @param {import('types').RequestEvent} event
|
134 |
+
* @param {{ [method: string]: import('types').RequestHandler }} mod
|
135 |
+
* @returns {Promise<Response>}
|
136 |
+
*/
|
137 |
+
async function render_endpoint(event, mod) {
|
138 |
+
const method = normalize_request_method(event);
|
139 |
+
|
140 |
+
/** @type {import('types').RequestHandler} */
|
141 |
+
let handler = mod[method];
|
142 |
+
|
143 |
+
if (!handler && method === 'head') {
|
144 |
+
handler = mod.get;
|
145 |
+
}
|
146 |
+
|
147 |
+
if (!handler) {
|
148 |
+
const allowed = [];
|
149 |
+
|
150 |
+
for (const method in ['get', 'post', 'put', 'patch']) {
|
151 |
+
if (mod[method]) allowed.push(method.toUpperCase());
|
152 |
+
}
|
153 |
+
|
154 |
+
if (mod.del) allowed.push('DELETE');
|
155 |
+
if (mod.get || mod.head) allowed.push('HEAD');
|
156 |
+
|
157 |
+
return event.request.headers.get('x-sveltekit-load')
|
158 |
+
? // TODO would be nice to avoid these requests altogether,
|
159 |
+
// by noting whether or not page endpoints export `get`
|
160 |
+
new Response(undefined, {
|
161 |
+
status: 204
|
162 |
+
})
|
163 |
+
: new Response(`${event.request.method} method not allowed`, {
|
164 |
+
status: 405,
|
165 |
+
headers: {
|
166 |
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
|
167 |
+
// "The server must generate an Allow header field in a 405 status code response"
|
168 |
+
allow: allowed.join(', ')
|
169 |
+
}
|
170 |
+
});
|
171 |
+
}
|
172 |
+
|
173 |
+
const response = await handler(event);
|
174 |
+
const preface = `Invalid response from route ${event.url.pathname}`;
|
175 |
+
|
176 |
+
if (typeof response !== 'object') {
|
177 |
+
return error(`${preface}: expected an object, got ${typeof response}`);
|
178 |
+
}
|
179 |
+
|
180 |
+
// TODO remove for 1.0
|
181 |
+
// @ts-expect-error
|
182 |
+
if (response.fallthrough) {
|
183 |
+
throw new Error(
|
184 |
+
'fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching'
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
const { status = 200, body = {} } = response;
|
189 |
+
const headers =
|
190 |
+
response.headers instanceof Headers
|
191 |
+
? new Headers(response.headers)
|
192 |
+
: to_headers(response.headers);
|
193 |
+
|
194 |
+
const type = headers.get('content-type');
|
195 |
+
|
196 |
+
if (!is_text(type) && !(body instanceof Uint8Array || is_string(body))) {
|
197 |
+
return error(
|
198 |
+
`${preface}: body must be an instance of string or Uint8Array if content-type is not a supported textual content-type`
|
199 |
+
);
|
200 |
+
}
|
201 |
+
|
202 |
+
/** @type {import('types').StrictBody} */
|
203 |
+
let normalized_body;
|
204 |
+
|
205 |
+
if (is_pojo(body) && (!type || type.startsWith('application/json'))) {
|
206 |
+
headers.set('content-type', 'application/json; charset=utf-8');
|
207 |
+
normalized_body = JSON.stringify(body);
|
208 |
+
} else {
|
209 |
+
normalized_body = /** @type {import('types').StrictBody} */ (body);
|
210 |
+
}
|
211 |
+
|
212 |
+
if (
|
213 |
+
(typeof normalized_body === 'string' || normalized_body instanceof Uint8Array) &&
|
214 |
+
!headers.has('etag')
|
215 |
+
) {
|
216 |
+
const cache_control = headers.get('cache-control');
|
217 |
+
if (!cache_control || !/(no-store|immutable)/.test(cache_control)) {
|
218 |
+
headers.set('etag', `"${hash(normalized_body)}"`);
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
return new Response(
|
223 |
+
method !== 'head' && !bodyless_status_codes.has(status) ? normalized_body : undefined,
|
224 |
+
{
|
225 |
+
status,
|
226 |
+
headers
|
227 |
+
}
|
228 |
+
);
|
229 |
+
}
|
230 |
+
|
231 |
+
var chars$1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
|
232 |
+
var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g;
|
233 |
+
var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
|
234 |
+
var escaped = {
|
235 |
+
'<': '\\u003C',
|
236 |
+
'>': '\\u003E',
|
237 |
+
'/': '\\u002F',
|
238 |
+
'\\': '\\\\',
|
239 |
+
'\b': '\\b',
|
240 |
+
'\f': '\\f',
|
241 |
+
'\n': '\\n',
|
242 |
+
'\r': '\\r',
|
243 |
+
'\t': '\\t',
|
244 |
+
'\0': '\\0',
|
245 |
+
'\u2028': '\\u2028',
|
246 |
+
'\u2029': '\\u2029'
|
247 |
+
};
|
248 |
+
var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\0');
|
249 |
+
function devalue(value) {
|
250 |
+
var counts = new Map();
|
251 |
+
function walk(thing) {
|
252 |
+
if (typeof thing === 'function') {
|
253 |
+
throw new Error("Cannot stringify a function");
|
254 |
+
}
|
255 |
+
if (counts.has(thing)) {
|
256 |
+
counts.set(thing, counts.get(thing) + 1);
|
257 |
+
return;
|
258 |
+
}
|
259 |
+
counts.set(thing, 1);
|
260 |
+
if (!isPrimitive(thing)) {
|
261 |
+
var type = getType(thing);
|
262 |
+
switch (type) {
|
263 |
+
case 'Number':
|
264 |
+
case 'String':
|
265 |
+
case 'Boolean':
|
266 |
+
case 'Date':
|
267 |
+
case 'RegExp':
|
268 |
+
return;
|
269 |
+
case 'Array':
|
270 |
+
thing.forEach(walk);
|
271 |
+
break;
|
272 |
+
case 'Set':
|
273 |
+
case 'Map':
|
274 |
+
Array.from(thing).forEach(walk);
|
275 |
+
break;
|
276 |
+
default:
|
277 |
+
var proto = Object.getPrototypeOf(thing);
|
278 |
+
if (proto !== Object.prototype &&
|
279 |
+
proto !== null &&
|
280 |
+
Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames) {
|
281 |
+
throw new Error("Cannot stringify arbitrary non-POJOs");
|
282 |
+
}
|
283 |
+
if (Object.getOwnPropertySymbols(thing).length > 0) {
|
284 |
+
throw new Error("Cannot stringify POJOs with symbolic keys");
|
285 |
+
}
|
286 |
+
Object.keys(thing).forEach(function (key) { return walk(thing[key]); });
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
walk(value);
|
291 |
+
var names = new Map();
|
292 |
+
Array.from(counts)
|
293 |
+
.filter(function (entry) { return entry[1] > 1; })
|
294 |
+
.sort(function (a, b) { return b[1] - a[1]; })
|
295 |
+
.forEach(function (entry, i) {
|
296 |
+
names.set(entry[0], getName(i));
|
297 |
+
});
|
298 |
+
function stringify(thing) {
|
299 |
+
if (names.has(thing)) {
|
300 |
+
return names.get(thing);
|
301 |
+
}
|
302 |
+
if (isPrimitive(thing)) {
|
303 |
+
return stringifyPrimitive(thing);
|
304 |
+
}
|
305 |
+
var type = getType(thing);
|
306 |
+
switch (type) {
|
307 |
+
case 'Number':
|
308 |
+
case 'String':
|
309 |
+
case 'Boolean':
|
310 |
+
return "Object(" + stringify(thing.valueOf()) + ")";
|
311 |
+
case 'RegExp':
|
312 |
+
return "new RegExp(" + stringifyString(thing.source) + ", \"" + thing.flags + "\")";
|
313 |
+
case 'Date':
|
314 |
+
return "new Date(" + thing.getTime() + ")";
|
315 |
+
case 'Array':
|
316 |
+
var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; });
|
317 |
+
var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ',';
|
318 |
+
return "[" + members.join(',') + tail + "]";
|
319 |
+
case 'Set':
|
320 |
+
case 'Map':
|
321 |
+
return "new " + type + "([" + Array.from(thing).map(stringify).join(',') + "])";
|
322 |
+
default:
|
323 |
+
var obj = "{" + Object.keys(thing).map(function (key) { return safeKey(key) + ":" + stringify(thing[key]); }).join(',') + "}";
|
324 |
+
var proto = Object.getPrototypeOf(thing);
|
325 |
+
if (proto === null) {
|
326 |
+
return Object.keys(thing).length > 0
|
327 |
+
? "Object.assign(Object.create(null)," + obj + ")"
|
328 |
+
: "Object.create(null)";
|
329 |
+
}
|
330 |
+
return obj;
|
331 |
+
}
|
332 |
+
}
|
333 |
+
var str = stringify(value);
|
334 |
+
if (names.size) {
|
335 |
+
var params_1 = [];
|
336 |
+
var statements_1 = [];
|
337 |
+
var values_1 = [];
|
338 |
+
names.forEach(function (name, thing) {
|
339 |
+
params_1.push(name);
|
340 |
+
if (isPrimitive(thing)) {
|
341 |
+
values_1.push(stringifyPrimitive(thing));
|
342 |
+
return;
|
343 |
+
}
|
344 |
+
var type = getType(thing);
|
345 |
+
switch (type) {
|
346 |
+
case 'Number':
|
347 |
+
case 'String':
|
348 |
+
case 'Boolean':
|
349 |
+
values_1.push("Object(" + stringify(thing.valueOf()) + ")");
|
350 |
+
break;
|
351 |
+
case 'RegExp':
|
352 |
+
values_1.push(thing.toString());
|
353 |
+
break;
|
354 |
+
case 'Date':
|
355 |
+
values_1.push("new Date(" + thing.getTime() + ")");
|
356 |
+
break;
|
357 |
+
case 'Array':
|
358 |
+
values_1.push("Array(" + thing.length + ")");
|
359 |
+
thing.forEach(function (v, i) {
|
360 |
+
statements_1.push(name + "[" + i + "]=" + stringify(v));
|
361 |
+
});
|
362 |
+
break;
|
363 |
+
case 'Set':
|
364 |
+
values_1.push("new Set");
|
365 |
+
statements_1.push(name + "." + Array.from(thing).map(function (v) { return "add(" + stringify(v) + ")"; }).join('.'));
|
366 |
+
break;
|
367 |
+
case 'Map':
|
368 |
+
values_1.push("new Map");
|
369 |
+
statements_1.push(name + "." + Array.from(thing).map(function (_a) {
|
370 |
+
var k = _a[0], v = _a[1];
|
371 |
+
return "set(" + stringify(k) + ", " + stringify(v) + ")";
|
372 |
+
}).join('.'));
|
373 |
+
break;
|
374 |
+
default:
|
375 |
+
values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}');
|
376 |
+
Object.keys(thing).forEach(function (key) {
|
377 |
+
statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key]));
|
378 |
+
});
|
379 |
+
}
|
380 |
+
});
|
381 |
+
statements_1.push("return " + str);
|
382 |
+
return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))";
|
383 |
+
}
|
384 |
+
else {
|
385 |
+
return str;
|
386 |
+
}
|
387 |
+
}
|
388 |
+
function getName(num) {
|
389 |
+
var name = '';
|
390 |
+
do {
|
391 |
+
name = chars$1[num % chars$1.length] + name;
|
392 |
+
num = ~~(num / chars$1.length) - 1;
|
393 |
+
} while (num >= 0);
|
394 |
+
return reserved.test(name) ? name + "_" : name;
|
395 |
+
}
|
396 |
+
function isPrimitive(thing) {
|
397 |
+
return Object(thing) !== thing;
|
398 |
+
}
|
399 |
+
function stringifyPrimitive(thing) {
|
400 |
+
if (typeof thing === 'string')
|
401 |
+
return stringifyString(thing);
|
402 |
+
if (thing === void 0)
|
403 |
+
return 'void 0';
|
404 |
+
if (thing === 0 && 1 / thing < 0)
|
405 |
+
return '-0';
|
406 |
+
var str = String(thing);
|
407 |
+
if (typeof thing === 'number')
|
408 |
+
return str.replace(/^(-)?0\./, '$1.');
|
409 |
+
return str;
|
410 |
+
}
|
411 |
+
function getType(thing) {
|
412 |
+
return Object.prototype.toString.call(thing).slice(8, -1);
|
413 |
+
}
|
414 |
+
function escapeUnsafeChar(c) {
|
415 |
+
return escaped[c] || c;
|
416 |
+
}
|
417 |
+
function escapeUnsafeChars(str) {
|
418 |
+
return str.replace(unsafeChars, escapeUnsafeChar);
|
419 |
+
}
|
420 |
+
function safeKey(key) {
|
421 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key));
|
422 |
+
}
|
423 |
+
function safeProp(key) {
|
424 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]";
|
425 |
+
}
|
426 |
+
function stringifyString(str) {
|
427 |
+
var result = '"';
|
428 |
+
for (var i = 0; i < str.length; i += 1) {
|
429 |
+
var char = str.charAt(i);
|
430 |
+
var code = char.charCodeAt(0);
|
431 |
+
if (char === '"') {
|
432 |
+
result += '\\"';
|
433 |
+
}
|
434 |
+
else if (char in escaped) {
|
435 |
+
result += escaped[char];
|
436 |
+
}
|
437 |
+
else if (code >= 0xd800 && code <= 0xdfff) {
|
438 |
+
var next = str.charCodeAt(i + 1);
|
439 |
+
// If this is the beginning of a [high, low] surrogate pair,
|
440 |
+
// add the next two characters, otherwise escape
|
441 |
+
if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) {
|
442 |
+
result += char + str[++i];
|
443 |
+
}
|
444 |
+
else {
|
445 |
+
result += "\\u" + code.toString(16).toUpperCase();
|
446 |
+
}
|
447 |
+
}
|
448 |
+
else {
|
449 |
+
result += char;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
result += '"';
|
453 |
+
return result;
|
454 |
+
}
|
455 |
+
|
456 |
+
function noop() { }
|
457 |
+
function safe_not_equal(a, b) {
|
458 |
+
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
459 |
+
}
|
460 |
+
Promise.resolve();
|
461 |
+
|
462 |
+
const subscriber_queue = [];
|
463 |
+
/**
|
464 |
+
* Creates a `Readable` store that allows reading by subscription.
|
465 |
+
* @param value initial value
|
466 |
+
* @param {StartStopNotifier}start start and stop notifications for subscriptions
|
467 |
+
*/
|
468 |
+
function readable(value, start) {
|
469 |
+
return {
|
470 |
+
subscribe: writable(value, start).subscribe
|
471 |
+
};
|
472 |
+
}
|
473 |
+
/**
|
474 |
+
* Create a `Writable` store that allows both updating and reading by subscription.
|
475 |
+
* @param {*=}value initial value
|
476 |
+
* @param {StartStopNotifier=}start start and stop notifications for subscriptions
|
477 |
+
*/
|
478 |
+
function writable(value, start = noop) {
|
479 |
+
let stop;
|
480 |
+
const subscribers = new Set();
|
481 |
+
function set(new_value) {
|
482 |
+
if (safe_not_equal(value, new_value)) {
|
483 |
+
value = new_value;
|
484 |
+
if (stop) { // store is ready
|
485 |
+
const run_queue = !subscriber_queue.length;
|
486 |
+
for (const subscriber of subscribers) {
|
487 |
+
subscriber[1]();
|
488 |
+
subscriber_queue.push(subscriber, value);
|
489 |
+
}
|
490 |
+
if (run_queue) {
|
491 |
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
492 |
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
493 |
+
}
|
494 |
+
subscriber_queue.length = 0;
|
495 |
+
}
|
496 |
+
}
|
497 |
+
}
|
498 |
+
}
|
499 |
+
function update(fn) {
|
500 |
+
set(fn(value));
|
501 |
+
}
|
502 |
+
function subscribe(run, invalidate = noop) {
|
503 |
+
const subscriber = [run, invalidate];
|
504 |
+
subscribers.add(subscriber);
|
505 |
+
if (subscribers.size === 1) {
|
506 |
+
stop = start(set) || noop;
|
507 |
+
}
|
508 |
+
run(value);
|
509 |
+
return () => {
|
510 |
+
subscribers.delete(subscriber);
|
511 |
+
if (subscribers.size === 0) {
|
512 |
+
stop();
|
513 |
+
stop = null;
|
514 |
+
}
|
515 |
+
};
|
516 |
+
}
|
517 |
+
return { set, update, subscribe };
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* @param {unknown} err
|
522 |
+
* @return {Error}
|
523 |
+
*/
|
524 |
+
function coalesce_to_error(err) {
|
525 |
+
return err instanceof Error ||
|
526 |
+
(err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)
|
527 |
+
? /** @type {Error} */ (err)
|
528 |
+
: new Error(JSON.stringify(err));
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Inside a script element, only `</script` and `<!--` hold special meaning to the HTML parser.
|
533 |
+
*
|
534 |
+
* The first closes the script element, so everything after is treated as raw HTML.
|
535 |
+
* The second disables further parsing until `-->`, so the script element might be unexpectedly
|
536 |
+
* kept open until until an unrelated HTML comment in the page.
|
537 |
+
*
|
538 |
+
* U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are escaped for the sake of pre-2018
|
539 |
+
* browsers.
|
540 |
+
*
|
541 |
+
* @see tests for unsafe parsing examples.
|
542 |
+
* @see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
543 |
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
|
544 |
+
* @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-state
|
545 |
+
* @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escaped-state
|
546 |
+
* @see https://github.com/tc39/proposal-json-superset
|
547 |
+
* @type {Record<string, string>}
|
548 |
+
*/
|
549 |
+
const render_json_payload_script_dict = {
|
550 |
+
'<': '\\u003C',
|
551 |
+
'\u2028': '\\u2028',
|
552 |
+
'\u2029': '\\u2029'
|
553 |
+
};
|
554 |
+
|
555 |
+
const render_json_payload_script_regex = new RegExp(
|
556 |
+
`[${Object.keys(render_json_payload_script_dict).join('')}]`,
|
557 |
+
'g'
|
558 |
+
);
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Generates a raw HTML string containing a safe script element carrying JSON data and associated attributes.
|
562 |
+
*
|
563 |
+
* It escapes all the special characters needed to guarantee the element is unbroken, but care must
|
564 |
+
* be taken to ensure it is inserted in the document at an acceptable position for a script element,
|
565 |
+
* and that the resulting string isn't further modified.
|
566 |
+
*
|
567 |
+
* Attribute names must be type-checked so we don't need to escape them.
|
568 |
+
*
|
569 |
+
* @param {import('types').PayloadScriptAttributes} attrs A list of attributes to be added to the element.
|
570 |
+
* @param {import('types').JSONValue} payload The data to be carried by the element. Must be serializable to JSON.
|
571 |
+
* @returns {string} The raw HTML of a script element carrying the JSON payload.
|
572 |
+
* @example const html = render_json_payload_script({ type: 'data', url: '/data.json' }, { foo: 'bar' });
|
573 |
+
*/
|
574 |
+
function render_json_payload_script(attrs, payload) {
|
575 |
+
const safe_payload = JSON.stringify(payload).replace(
|
576 |
+
render_json_payload_script_regex,
|
577 |
+
(match) => render_json_payload_script_dict[match]
|
578 |
+
);
|
579 |
+
|
580 |
+
let safe_attrs = '';
|
581 |
+
for (const [key, value] of Object.entries(attrs)) {
|
582 |
+
if (value === undefined) continue;
|
583 |
+
safe_attrs += ` sveltekit:data-${key}=${escape_html_attr(value)}`;
|
584 |
+
}
|
585 |
+
|
586 |
+
return `<script type="application/json"${safe_attrs}>${safe_payload}</script>`;
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* When inside a double-quoted attribute value, only `&` and `"` hold special meaning.
|
591 |
+
* @see https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state
|
592 |
+
* @type {Record<string, string>}
|
593 |
+
*/
|
594 |
+
const escape_html_attr_dict = {
|
595 |
+
'&': '&',
|
596 |
+
'"': '"'
|
597 |
+
};
|
598 |
+
|
599 |
+
const escape_html_attr_regex = new RegExp(
|
600 |
+
// special characters
|
601 |
+
`[${Object.keys(escape_html_attr_dict).join('')}]|` +
|
602 |
+
// high surrogate without paired low surrogate
|
603 |
+
'[\\ud800-\\udbff](?![\\udc00-\\udfff])|' +
|
604 |
+
// a valid surrogate pair, the only match with 2 code units
|
605 |
+
// we match it so that we can match unpaired low surrogates in the same pass
|
606 |
+
// TODO: use lookbehind assertions once they are widely supported: (?<![\ud800-udbff])[\udc00-\udfff]
|
607 |
+
'[\\ud800-\\udbff][\\udc00-\\udfff]|' +
|
608 |
+
// unpaired low surrogate (see previous match)
|
609 |
+
'[\\udc00-\\udfff]',
|
610 |
+
'g'
|
611 |
+
);
|
612 |
+
|
613 |
+
/**
|
614 |
+
* Formats a string to be used as an attribute's value in raw HTML.
|
615 |
+
*
|
616 |
+
* It escapes unpaired surrogates (which are allowed in js strings but invalid in HTML), escapes
|
617 |
+
* characters that are special in attributes, and surrounds the whole string in double-quotes.
|
618 |
+
*
|
619 |
+
* @param {string} str
|
620 |
+
* @returns {string} Escaped string surrounded by double-quotes.
|
621 |
+
* @example const html = `<tag data-value=${escape_html_attr('value')}>...</tag>`;
|
622 |
+
*/
|
623 |
+
function escape_html_attr(str) {
|
624 |
+
const escaped_str = str.replace(escape_html_attr_regex, (match) => {
|
625 |
+
if (match.length === 2) {
|
626 |
+
// valid surrogate pair
|
627 |
+
return match;
|
628 |
+
}
|
629 |
+
|
630 |
+
return escape_html_attr_dict[match] ?? `&#${match.charCodeAt(0)};`;
|
631 |
+
});
|
632 |
+
|
633 |
+
return `"${escaped_str}"`;
|
634 |
+
}
|
635 |
+
|
636 |
+
const s = JSON.stringify;
|
637 |
+
|
638 |
+
const encoder = new TextEncoder();
|
639 |
+
|
640 |
+
/**
|
641 |
+
* SHA-256 hashing function adapted from https://bitwiseshiftleft.github.io/sjcl
|
642 |
+
* modified and redistributed under BSD license
|
643 |
+
* @param {string} data
|
644 |
+
*/
|
645 |
+
function sha256(data) {
|
646 |
+
if (!key[0]) precompute();
|
647 |
+
|
648 |
+
const out = init.slice(0);
|
649 |
+
const array = encode$1(data);
|
650 |
+
|
651 |
+
for (let i = 0; i < array.length; i += 16) {
|
652 |
+
const w = array.subarray(i, i + 16);
|
653 |
+
|
654 |
+
let tmp;
|
655 |
+
let a;
|
656 |
+
let b;
|
657 |
+
|
658 |
+
let out0 = out[0];
|
659 |
+
let out1 = out[1];
|
660 |
+
let out2 = out[2];
|
661 |
+
let out3 = out[3];
|
662 |
+
let out4 = out[4];
|
663 |
+
let out5 = out[5];
|
664 |
+
let out6 = out[6];
|
665 |
+
let out7 = out[7];
|
666 |
+
|
667 |
+
/* Rationale for placement of |0 :
|
668 |
+
* If a value can overflow is original 32 bits by a factor of more than a few
|
669 |
+
* million (2^23 ish), there is a possibility that it might overflow the
|
670 |
+
* 53-bit mantissa and lose precision.
|
671 |
+
*
|
672 |
+
* To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that
|
673 |
+
* propagates around the loop, and on the hash state out[]. I don't believe
|
674 |
+
* that the clamps on out4 and on out0 are strictly necessary, but it's close
|
675 |
+
* (for out4 anyway), and better safe than sorry.
|
676 |
+
*
|
677 |
+
* The clamps on out[] are necessary for the output to be correct even in the
|
678 |
+
* common case and for short inputs.
|
679 |
+
*/
|
680 |
+
|
681 |
+
for (let i = 0; i < 64; i++) {
|
682 |
+
// load up the input word for this round
|
683 |
+
|
684 |
+
if (i < 16) {
|
685 |
+
tmp = w[i];
|
686 |
+
} else {
|
687 |
+
a = w[(i + 1) & 15];
|
688 |
+
|
689 |
+
b = w[(i + 14) & 15];
|
690 |
+
|
691 |
+
tmp = w[i & 15] =
|
692 |
+
(((a >>> 7) ^ (a >>> 18) ^ (a >>> 3) ^ (a << 25) ^ (a << 14)) +
|
693 |
+
((b >>> 17) ^ (b >>> 19) ^ (b >>> 10) ^ (b << 15) ^ (b << 13)) +
|
694 |
+
w[i & 15] +
|
695 |
+
w[(i + 9) & 15]) |
|
696 |
+
0;
|
697 |
+
}
|
698 |
+
|
699 |
+
tmp =
|
700 |
+
tmp +
|
701 |
+
out7 +
|
702 |
+
((out4 >>> 6) ^ (out4 >>> 11) ^ (out4 >>> 25) ^ (out4 << 26) ^ (out4 << 21) ^ (out4 << 7)) +
|
703 |
+
(out6 ^ (out4 & (out5 ^ out6))) +
|
704 |
+
key[i]; // | 0;
|
705 |
+
|
706 |
+
// shift register
|
707 |
+
out7 = out6;
|
708 |
+
out6 = out5;
|
709 |
+
out5 = out4;
|
710 |
+
|
711 |
+
out4 = (out3 + tmp) | 0;
|
712 |
+
|
713 |
+
out3 = out2;
|
714 |
+
out2 = out1;
|
715 |
+
out1 = out0;
|
716 |
+
|
717 |
+
out0 =
|
718 |
+
(tmp +
|
719 |
+
((out1 & out2) ^ (out3 & (out1 ^ out2))) +
|
720 |
+
((out1 >>> 2) ^
|
721 |
+
(out1 >>> 13) ^
|
722 |
+
(out1 >>> 22) ^
|
723 |
+
(out1 << 30) ^
|
724 |
+
(out1 << 19) ^
|
725 |
+
(out1 << 10))) |
|
726 |
+
0;
|
727 |
+
}
|
728 |
+
|
729 |
+
out[0] = (out[0] + out0) | 0;
|
730 |
+
out[1] = (out[1] + out1) | 0;
|
731 |
+
out[2] = (out[2] + out2) | 0;
|
732 |
+
out[3] = (out[3] + out3) | 0;
|
733 |
+
out[4] = (out[4] + out4) | 0;
|
734 |
+
out[5] = (out[5] + out5) | 0;
|
735 |
+
out[6] = (out[6] + out6) | 0;
|
736 |
+
out[7] = (out[7] + out7) | 0;
|
737 |
+
}
|
738 |
+
|
739 |
+
const bytes = new Uint8Array(out.buffer);
|
740 |
+
reverse_endianness(bytes);
|
741 |
+
|
742 |
+
return base64(bytes);
|
743 |
+
}
|
744 |
+
|
745 |
+
/** The SHA-256 initialization vector */
|
746 |
+
const init = new Uint32Array(8);
|
747 |
+
|
748 |
+
/** The SHA-256 hash key */
|
749 |
+
const key = new Uint32Array(64);
|
750 |
+
|
751 |
+
/** Function to precompute init and key. */
|
752 |
+
function precompute() {
|
753 |
+
/** @param {number} x */
|
754 |
+
function frac(x) {
|
755 |
+
return (x - Math.floor(x)) * 0x100000000;
|
756 |
+
}
|
757 |
+
|
758 |
+
let prime = 2;
|
759 |
+
|
760 |
+
for (let i = 0; i < 64; prime++) {
|
761 |
+
let is_prime = true;
|
762 |
+
|
763 |
+
for (let factor = 2; factor * factor <= prime; factor++) {
|
764 |
+
if (prime % factor === 0) {
|
765 |
+
is_prime = false;
|
766 |
+
|
767 |
+
break;
|
768 |
+
}
|
769 |
+
}
|
770 |
+
|
771 |
+
if (is_prime) {
|
772 |
+
if (i < 8) {
|
773 |
+
init[i] = frac(prime ** (1 / 2));
|
774 |
+
}
|
775 |
+
|
776 |
+
key[i] = frac(prime ** (1 / 3));
|
777 |
+
|
778 |
+
i++;
|
779 |
+
}
|
780 |
+
}
|
781 |
+
}
|
782 |
+
|
783 |
+
/** @param {Uint8Array} bytes */
|
784 |
+
function reverse_endianness(bytes) {
|
785 |
+
for (let i = 0; i < bytes.length; i += 4) {
|
786 |
+
const a = bytes[i + 0];
|
787 |
+
const b = bytes[i + 1];
|
788 |
+
const c = bytes[i + 2];
|
789 |
+
const d = bytes[i + 3];
|
790 |
+
|
791 |
+
bytes[i + 0] = d;
|
792 |
+
bytes[i + 1] = c;
|
793 |
+
bytes[i + 2] = b;
|
794 |
+
bytes[i + 3] = a;
|
795 |
+
}
|
796 |
+
}
|
797 |
+
|
798 |
+
/** @param {string} str */
|
799 |
+
function encode$1(str) {
|
800 |
+
const encoded = encoder.encode(str);
|
801 |
+
const length = encoded.length * 8;
|
802 |
+
|
803 |
+
// result should be a multiple of 512 bits in length,
|
804 |
+
// with room for a 1 (after the data) and two 32-bit
|
805 |
+
// words containing the original input bit length
|
806 |
+
const size = 512 * Math.ceil((length + 65) / 512);
|
807 |
+
const bytes = new Uint8Array(size / 8);
|
808 |
+
bytes.set(encoded);
|
809 |
+
|
810 |
+
// append a 1
|
811 |
+
bytes[encoded.length] = 0b10000000;
|
812 |
+
|
813 |
+
reverse_endianness(bytes);
|
814 |
+
|
815 |
+
// add the input bit length
|
816 |
+
const words = new Uint32Array(bytes.buffer);
|
817 |
+
words[words.length - 2] = Math.floor(length / 0x100000000); // this will always be zero for us
|
818 |
+
words[words.length - 1] = length;
|
819 |
+
|
820 |
+
return words;
|
821 |
+
}
|
822 |
+
|
823 |
+
/*
|
824 |
+
Based on https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
|
825 |
+
|
826 |
+
MIT License
|
827 |
+
Copyright (c) 2020 Egor Nepomnyaschih
|
828 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
829 |
+
of this software and associated documentation files (the "Software"), to deal
|
830 |
+
in the Software without restriction, including without limitation the rights
|
831 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
832 |
+
copies of the Software, and to permit persons to whom the Software is
|
833 |
+
furnished to do so, subject to the following conditions:
|
834 |
+
The above copyright notice and this permission notice shall be included in all
|
835 |
+
copies or substantial portions of the Software.
|
836 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
837 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
838 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
839 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
840 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
841 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
842 |
+
SOFTWARE.
|
843 |
+
*/
|
844 |
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
845 |
+
|
846 |
+
/** @param {Uint8Array} bytes */
|
847 |
+
function base64(bytes) {
|
848 |
+
const l = bytes.length;
|
849 |
+
|
850 |
+
let result = '';
|
851 |
+
let i;
|
852 |
+
|
853 |
+
for (i = 2; i < l; i += 3) {
|
854 |
+
result += chars[bytes[i - 2] >> 2];
|
855 |
+
result += chars[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)];
|
856 |
+
result += chars[((bytes[i - 1] & 0x0f) << 2) | (bytes[i] >> 6)];
|
857 |
+
result += chars[bytes[i] & 0x3f];
|
858 |
+
}
|
859 |
+
|
860 |
+
if (i === l + 1) {
|
861 |
+
// 1 octet yet to write
|
862 |
+
result += chars[bytes[i - 2] >> 2];
|
863 |
+
result += chars[(bytes[i - 2] & 0x03) << 4];
|
864 |
+
result += '==';
|
865 |
+
}
|
866 |
+
|
867 |
+
if (i === l) {
|
868 |
+
// 2 octets yet to write
|
869 |
+
result += chars[bytes[i - 2] >> 2];
|
870 |
+
result += chars[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)];
|
871 |
+
result += chars[(bytes[i - 1] & 0x0f) << 2];
|
872 |
+
result += '=';
|
873 |
+
}
|
874 |
+
|
875 |
+
return result;
|
876 |
+
}
|
877 |
+
|
878 |
+
/** @type {Promise<void>} */
|
879 |
+
let csp_ready;
|
880 |
+
|
881 |
+
const array = new Uint8Array(16);
|
882 |
+
|
883 |
+
function generate_nonce() {
|
884 |
+
crypto.getRandomValues(array);
|
885 |
+
return base64(array);
|
886 |
+
}
|
887 |
+
|
888 |
+
const quoted = new Set([
|
889 |
+
'self',
|
890 |
+
'unsafe-eval',
|
891 |
+
'unsafe-hashes',
|
892 |
+
'unsafe-inline',
|
893 |
+
'none',
|
894 |
+
'strict-dynamic',
|
895 |
+
'report-sample'
|
896 |
+
]);
|
897 |
+
|
898 |
+
const crypto_pattern = /^(nonce|sha\d\d\d)-/;
|
899 |
+
|
900 |
+
class Csp {
|
901 |
+
/** @type {boolean} */
|
902 |
+
#use_hashes;
|
903 |
+
|
904 |
+
/** @type {boolean} */
|
905 |
+
#dev;
|
906 |
+
|
907 |
+
/** @type {boolean} */
|
908 |
+
#script_needs_csp;
|
909 |
+
|
910 |
+
/** @type {boolean} */
|
911 |
+
#style_needs_csp;
|
912 |
+
|
913 |
+
/** @type {import('types').CspDirectives} */
|
914 |
+
#directives;
|
915 |
+
|
916 |
+
/** @type {import('types').Csp.Source[]} */
|
917 |
+
#script_src;
|
918 |
+
|
919 |
+
/** @type {import('types').Csp.Source[]} */
|
920 |
+
#style_src;
|
921 |
+
|
922 |
+
/**
|
923 |
+
* @param {{
|
924 |
+
* mode: string,
|
925 |
+
* directives: import('types').CspDirectives
|
926 |
+
* }} config
|
927 |
+
* @param {{
|
928 |
+
* dev: boolean;
|
929 |
+
* prerender: boolean;
|
930 |
+
* needs_nonce: boolean;
|
931 |
+
* }} opts
|
932 |
+
*/
|
933 |
+
constructor({ mode, directives }, { dev, prerender, needs_nonce }) {
|
934 |
+
this.#use_hashes = mode === 'hash' || (mode === 'auto' && prerender);
|
935 |
+
this.#directives = dev ? { ...directives } : directives; // clone in dev so we can safely mutate
|
936 |
+
this.#dev = dev;
|
937 |
+
|
938 |
+
const d = this.#directives;
|
939 |
+
|
940 |
+
if (dev) {
|
941 |
+
// remove strict-dynamic in dev...
|
942 |
+
// TODO reinstate this if we can figure out how to make strict-dynamic work
|
943 |
+
// if (d['default-src']) {
|
944 |
+
// d['default-src'] = d['default-src'].filter((name) => name !== 'strict-dynamic');
|
945 |
+
// if (d['default-src'].length === 0) delete d['default-src'];
|
946 |
+
// }
|
947 |
+
|
948 |
+
// if (d['script-src']) {
|
949 |
+
// d['script-src'] = d['script-src'].filter((name) => name !== 'strict-dynamic');
|
950 |
+
// if (d['script-src'].length === 0) delete d['script-src'];
|
951 |
+
// }
|
952 |
+
|
953 |
+
const effective_style_src = d['style-src'] || d['default-src'];
|
954 |
+
|
955 |
+
// ...and add unsafe-inline so we can inject <style> elements
|
956 |
+
if (effective_style_src && !effective_style_src.includes('unsafe-inline')) {
|
957 |
+
d['style-src'] = [...effective_style_src, 'unsafe-inline'];
|
958 |
+
}
|
959 |
+
}
|
960 |
+
|
961 |
+
this.#script_src = [];
|
962 |
+
this.#style_src = [];
|
963 |
+
|
964 |
+
const effective_script_src = d['script-src'] || d['default-src'];
|
965 |
+
const effective_style_src = d['style-src'] || d['default-src'];
|
966 |
+
|
967 |
+
this.#script_needs_csp =
|
968 |
+
!!effective_script_src &&
|
969 |
+
effective_script_src.filter((value) => value !== 'unsafe-inline').length > 0;
|
970 |
+
|
971 |
+
this.#style_needs_csp =
|
972 |
+
!dev &&
|
973 |
+
!!effective_style_src &&
|
974 |
+
effective_style_src.filter((value) => value !== 'unsafe-inline').length > 0;
|
975 |
+
|
976 |
+
this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
|
977 |
+
this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
|
978 |
+
|
979 |
+
if (this.script_needs_nonce || this.style_needs_nonce || needs_nonce) {
|
980 |
+
this.nonce = generate_nonce();
|
981 |
+
}
|
982 |
+
}
|
983 |
+
|
984 |
+
/** @param {string} content */
|
985 |
+
add_script(content) {
|
986 |
+
if (this.#script_needs_csp) {
|
987 |
+
if (this.#use_hashes) {
|
988 |
+
this.#script_src.push(`sha256-${sha256(content)}`);
|
989 |
+
} else if (this.#script_src.length === 0) {
|
990 |
+
this.#script_src.push(`nonce-${this.nonce}`);
|
991 |
+
}
|
992 |
+
}
|
993 |
+
}
|
994 |
+
|
995 |
+
/** @param {string} content */
|
996 |
+
add_style(content) {
|
997 |
+
if (this.#style_needs_csp) {
|
998 |
+
if (this.#use_hashes) {
|
999 |
+
this.#style_src.push(`sha256-${sha256(content)}`);
|
1000 |
+
} else if (this.#style_src.length === 0) {
|
1001 |
+
this.#style_src.push(`nonce-${this.nonce}`);
|
1002 |
+
}
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
/** @param {boolean} [is_meta] */
|
1007 |
+
get_header(is_meta = false) {
|
1008 |
+
const header = [];
|
1009 |
+
|
1010 |
+
// due to browser inconsistencies, we can't append sources to default-src
|
1011 |
+
// (specifically, Firefox appears to not ignore nonce-{nonce} directives
|
1012 |
+
// on default-src), so we ensure that script-src and style-src exist
|
1013 |
+
|
1014 |
+
const directives = { ...this.#directives };
|
1015 |
+
|
1016 |
+
if (this.#style_src.length > 0) {
|
1017 |
+
directives['style-src'] = [
|
1018 |
+
...(directives['style-src'] || directives['default-src'] || []),
|
1019 |
+
...this.#style_src
|
1020 |
+
];
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
if (this.#script_src.length > 0) {
|
1024 |
+
directives['script-src'] = [
|
1025 |
+
...(directives['script-src'] || directives['default-src'] || []),
|
1026 |
+
...this.#script_src
|
1027 |
+
];
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
for (const key in directives) {
|
1031 |
+
if (is_meta && (key === 'frame-ancestors' || key === 'report-uri' || key === 'sandbox')) {
|
1032 |
+
// these values cannot be used with a <meta> tag
|
1033 |
+
// TODO warn?
|
1034 |
+
continue;
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
// @ts-expect-error gimme a break typescript, `key` is obviously a member of directives
|
1038 |
+
const value = /** @type {string[] | true} */ (directives[key]);
|
1039 |
+
|
1040 |
+
if (!value) continue;
|
1041 |
+
|
1042 |
+
const directive = [key];
|
1043 |
+
if (Array.isArray(value)) {
|
1044 |
+
value.forEach((value) => {
|
1045 |
+
if (quoted.has(value) || crypto_pattern.test(value)) {
|
1046 |
+
directive.push(`'${value}'`);
|
1047 |
+
} else {
|
1048 |
+
directive.push(value);
|
1049 |
+
}
|
1050 |
+
});
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
header.push(directive.join(' '));
|
1054 |
+
}
|
1055 |
+
|
1056 |
+
return header.join('; ');
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
get_meta() {
|
1060 |
+
const content = escape_html_attr(this.get_header(true));
|
1061 |
+
return `<meta http-equiv="content-security-policy" content=${content}>`;
|
1062 |
+
}
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
const absolute = /^([a-z]+:)?\/?\//;
|
1066 |
+
const scheme = /^[a-z]+:/;
|
1067 |
+
|
1068 |
+
/**
|
1069 |
+
* @param {string} base
|
1070 |
+
* @param {string} path
|
1071 |
+
*/
|
1072 |
+
function resolve(base, path) {
|
1073 |
+
if (scheme.test(path)) return path;
|
1074 |
+
|
1075 |
+
const base_match = absolute.exec(base);
|
1076 |
+
const path_match = absolute.exec(path);
|
1077 |
+
|
1078 |
+
if (!base_match) {
|
1079 |
+
throw new Error(`bad base path: "${base}"`);
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
const baseparts = path_match ? [] : base.slice(base_match[0].length).split('/');
|
1083 |
+
const pathparts = path_match ? path.slice(path_match[0].length).split('/') : path.split('/');
|
1084 |
+
|
1085 |
+
baseparts.pop();
|
1086 |
+
|
1087 |
+
for (let i = 0; i < pathparts.length; i += 1) {
|
1088 |
+
const part = pathparts[i];
|
1089 |
+
if (part === '.') continue;
|
1090 |
+
else if (part === '..') baseparts.pop();
|
1091 |
+
else baseparts.push(part);
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
const prefix = (path_match && path_match[0]) || (base_match && base_match[0]) || '';
|
1095 |
+
|
1096 |
+
return `${prefix}${baseparts.join('/')}`;
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
/** @param {string} path */
|
1100 |
+
function is_root_relative(path) {
|
1101 |
+
return path[0] === '/' && path[1] !== '/';
|
1102 |
+
}
|
1103 |
+
|
1104 |
+
/**
|
1105 |
+
* @param {string} path
|
1106 |
+
* @param {import('types').TrailingSlash} trailing_slash
|
1107 |
+
*/
|
1108 |
+
function normalize_path(path, trailing_slash) {
|
1109 |
+
if (path === '/' || trailing_slash === 'ignore') return path;
|
1110 |
+
|
1111 |
+
if (trailing_slash === 'never') {
|
1112 |
+
return path.endsWith('/') ? path.slice(0, -1) : path;
|
1113 |
+
} else if (trailing_slash === 'always' && !path.endsWith('/')) {
|
1114 |
+
return path + '/';
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
return path;
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
class LoadURL extends URL {
|
1121 |
+
/** @returns {string} */
|
1122 |
+
get hash() {
|
1123 |
+
throw new Error(
|
1124 |
+
'url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component.'
|
1125 |
+
);
|
1126 |
+
}
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
class PrerenderingURL extends URL {
|
1130 |
+
/** @returns {string} */
|
1131 |
+
get search() {
|
1132 |
+
throw new Error('Cannot access url.search on a page with prerendering enabled');
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
/** @returns {URLSearchParams} */
|
1136 |
+
get searchParams() {
|
1137 |
+
throw new Error('Cannot access url.searchParams on a page with prerendering enabled');
|
1138 |
+
}
|
1139 |
+
}
|
1140 |
+
|
1141 |
+
// TODO rename this function/module
|
1142 |
+
|
1143 |
+
const updated = {
|
1144 |
+
...readable(false),
|
1145 |
+
check: () => false
|
1146 |
+
};
|
1147 |
+
|
1148 |
+
/**
|
1149 |
+
* Creates the HTML response.
|
1150 |
+
* @param {{
|
1151 |
+
* branch: Array<import('./types').Loaded>;
|
1152 |
+
* options: import('types').SSROptions;
|
1153 |
+
* state: import('types').SSRState;
|
1154 |
+
* $session: any;
|
1155 |
+
* page_config: { hydrate: boolean, router: boolean };
|
1156 |
+
* status: number;
|
1157 |
+
* error: Error | null;
|
1158 |
+
* event: import('types').RequestEvent;
|
1159 |
+
* resolve_opts: import('types').RequiredResolveOptions;
|
1160 |
+
* stuff: Record<string, any>;
|
1161 |
+
* }} opts
|
1162 |
+
*/
|
1163 |
+
async function render_response({
|
1164 |
+
branch,
|
1165 |
+
options,
|
1166 |
+
state,
|
1167 |
+
$session,
|
1168 |
+
page_config,
|
1169 |
+
status,
|
1170 |
+
error = null,
|
1171 |
+
event,
|
1172 |
+
resolve_opts,
|
1173 |
+
stuff
|
1174 |
+
}) {
|
1175 |
+
if (state.prerendering) {
|
1176 |
+
if (options.csp.mode === 'nonce') {
|
1177 |
+
throw new Error('Cannot use prerendering if config.kit.csp.mode === "nonce"');
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
if (options.template_contains_nonce) {
|
1181 |
+
throw new Error('Cannot use prerendering if page template contains %sveltekit.nonce%');
|
1182 |
+
}
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
const stylesheets = new Set(options.manifest._.entry.css);
|
1186 |
+
const modulepreloads = new Set(options.manifest._.entry.js);
|
1187 |
+
/** @type {Map<string, string>} */
|
1188 |
+
const styles = new Map();
|
1189 |
+
|
1190 |
+
/** @type {Array<import('./types').Fetched>} */
|
1191 |
+
const serialized_data = [];
|
1192 |
+
|
1193 |
+
let shadow_props;
|
1194 |
+
|
1195 |
+
let rendered;
|
1196 |
+
|
1197 |
+
let is_private = false;
|
1198 |
+
/** @type {import('types').NormalizedLoadOutputCache | undefined} */
|
1199 |
+
let cache;
|
1200 |
+
|
1201 |
+
if (error) {
|
1202 |
+
error.stack = options.get_stack(error);
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
if (resolve_opts.ssr) {
|
1206 |
+
branch.forEach(({ node, props, loaded, fetched, uses_credentials }) => {
|
1207 |
+
if (node.css) node.css.forEach((url) => stylesheets.add(url));
|
1208 |
+
if (node.js) node.js.forEach((url) => modulepreloads.add(url));
|
1209 |
+
if (node.styles) Object.entries(node.styles).forEach(([k, v]) => styles.set(k, v));
|
1210 |
+
|
1211 |
+
// TODO probably better if `fetched` wasn't populated unless `hydrate`
|
1212 |
+
if (fetched && page_config.hydrate) serialized_data.push(...fetched);
|
1213 |
+
if (props) shadow_props = props;
|
1214 |
+
|
1215 |
+
cache = loaded?.cache;
|
1216 |
+
is_private = cache?.private ?? uses_credentials;
|
1217 |
+
});
|
1218 |
+
|
1219 |
+
const session = writable($session);
|
1220 |
+
|
1221 |
+
/** @type {Record<string, any>} */
|
1222 |
+
const props = {
|
1223 |
+
stores: {
|
1224 |
+
page: writable(null),
|
1225 |
+
navigating: writable(null),
|
1226 |
+
/** @type {import('svelte/store').Writable<App.Session>} */
|
1227 |
+
session: {
|
1228 |
+
...session,
|
1229 |
+
subscribe: (fn) => {
|
1230 |
+
is_private = cache?.private ?? true;
|
1231 |
+
return session.subscribe(fn);
|
1232 |
+
}
|
1233 |
+
},
|
1234 |
+
updated
|
1235 |
+
},
|
1236 |
+
/** @type {import('types').Page} */
|
1237 |
+
page: {
|
1238 |
+
error,
|
1239 |
+
params: event.params,
|
1240 |
+
routeId: event.routeId,
|
1241 |
+
status,
|
1242 |
+
stuff,
|
1243 |
+
url: state.prerendering ? new PrerenderingURL(event.url) : event.url
|
1244 |
+
},
|
1245 |
+
components: branch.map(({ node }) => node.module.default)
|
1246 |
+
};
|
1247 |
+
|
1248 |
+
// TODO remove this for 1.0
|
1249 |
+
/**
|
1250 |
+
* @param {string} property
|
1251 |
+
* @param {string} replacement
|
1252 |
+
*/
|
1253 |
+
const print_error = (property, replacement) => {
|
1254 |
+
Object.defineProperty(props.page, property, {
|
1255 |
+
get: () => {
|
1256 |
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
1257 |
+
}
|
1258 |
+
});
|
1259 |
+
};
|
1260 |
+
|
1261 |
+
print_error('origin', 'origin');
|
1262 |
+
print_error('path', 'pathname');
|
1263 |
+
print_error('query', 'searchParams');
|
1264 |
+
|
1265 |
+
// props_n (instead of props[n]) makes it easy to avoid
|
1266 |
+
// unnecessary updates for layout components
|
1267 |
+
for (let i = 0; i < branch.length; i += 1) {
|
1268 |
+
props[`props_${i}`] = await branch[i].loaded.props;
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
rendered = options.root.render(props);
|
1272 |
+
} else {
|
1273 |
+
rendered = { head: '', html: '', css: { code: '', map: null } };
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
let { head, html: body } = rendered;
|
1277 |
+
|
1278 |
+
const inlined_style = Array.from(styles.values()).join('\n');
|
1279 |
+
|
1280 |
+
await csp_ready;
|
1281 |
+
const csp = new Csp(options.csp, {
|
1282 |
+
dev: options.dev,
|
1283 |
+
prerender: !!state.prerendering,
|
1284 |
+
needs_nonce: options.template_contains_nonce
|
1285 |
+
});
|
1286 |
+
|
1287 |
+
const target = hash(body);
|
1288 |
+
|
1289 |
+
// prettier-ignore
|
1290 |
+
const init_app = `
|
1291 |
+
import { start } from ${s(options.prefix + options.manifest._.entry.file)};
|
1292 |
+
start({
|
1293 |
+
target: document.querySelector('[data-sveltekit-hydrate="${target}"]').parentNode,
|
1294 |
+
paths: ${s(options.paths)},
|
1295 |
+
session: ${try_serialize($session, (error) => {
|
1296 |
+
throw new Error(`Failed to serialize session data: ${error.message}`);
|
1297 |
+
})},
|
1298 |
+
route: ${!!page_config.router},
|
1299 |
+
spa: ${!resolve_opts.ssr},
|
1300 |
+
trailing_slash: ${s(options.trailing_slash)},
|
1301 |
+
hydrate: ${resolve_opts.ssr && page_config.hydrate ? `{
|
1302 |
+
status: ${status},
|
1303 |
+
error: ${serialize_error(error)},
|
1304 |
+
nodes: [${branch.map(({ node }) => node.index).join(', ')}],
|
1305 |
+
params: ${devalue(event.params)},
|
1306 |
+
routeId: ${s(event.routeId)}
|
1307 |
+
}` : 'null'}
|
1308 |
+
});
|
1309 |
+
`;
|
1310 |
+
|
1311 |
+
const init_service_worker = `
|
1312 |
+
if ('serviceWorker' in navigator) {
|
1313 |
+
addEventListener('load', () => {
|
1314 |
+
navigator.serviceWorker.register('${options.service_worker}');
|
1315 |
+
});
|
1316 |
+
}
|
1317 |
+
`;
|
1318 |
+
|
1319 |
+
if (inlined_style) {
|
1320 |
+
const attributes = [];
|
1321 |
+
if (options.dev) attributes.push(' data-sveltekit');
|
1322 |
+
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
|
1323 |
+
|
1324 |
+
csp.add_style(inlined_style);
|
1325 |
+
|
1326 |
+
head += `\n\t<style${attributes.join('')}>${inlined_style}</style>`;
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
// prettier-ignore
|
1330 |
+
head += Array.from(stylesheets)
|
1331 |
+
.map((dep) => {
|
1332 |
+
const attributes = [
|
1333 |
+
'rel="stylesheet"',
|
1334 |
+
`href="${options.prefix + dep}"`
|
1335 |
+
];
|
1336 |
+
|
1337 |
+
if (csp.style_needs_nonce) {
|
1338 |
+
attributes.push(`nonce="${csp.nonce}"`);
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
if (styles.has(dep)) {
|
1342 |
+
// don't load stylesheets that are already inlined
|
1343 |
+
// include them in disabled state so that Vite can detect them and doesn't try to add them
|
1344 |
+
attributes.push('disabled', 'media="(max-width: 0)"');
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
return `\n\t<link ${attributes.join(' ')}>`;
|
1348 |
+
})
|
1349 |
+
.join('');
|
1350 |
+
|
1351 |
+
if (page_config.router || page_config.hydrate) {
|
1352 |
+
head += Array.from(modulepreloads)
|
1353 |
+
.map((dep) => `\n\t<link rel="modulepreload" href="${options.prefix + dep}">`)
|
1354 |
+
.join('');
|
1355 |
+
|
1356 |
+
const attributes = ['type="module"', `data-sveltekit-hydrate="${target}"`];
|
1357 |
+
|
1358 |
+
csp.add_script(init_app);
|
1359 |
+
|
1360 |
+
if (csp.script_needs_nonce) {
|
1361 |
+
attributes.push(`nonce="${csp.nonce}"`);
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
body += `\n\t\t<script ${attributes.join(' ')}>${init_app}</script>`;
|
1365 |
+
|
1366 |
+
body += serialized_data
|
1367 |
+
.map(({ url, body, response }) =>
|
1368 |
+
render_json_payload_script(
|
1369 |
+
{ type: 'data', url, body: typeof body === 'string' ? hash(body) : undefined },
|
1370 |
+
response
|
1371 |
+
)
|
1372 |
+
)
|
1373 |
+
.join('\n\t');
|
1374 |
+
|
1375 |
+
if (shadow_props) {
|
1376 |
+
body += render_json_payload_script({ type: 'props' }, shadow_props);
|
1377 |
+
}
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
if (options.service_worker) {
|
1381 |
+
// always include service worker unless it's turned off explicitly
|
1382 |
+
csp.add_script(init_service_worker);
|
1383 |
+
|
1384 |
+
head += `
|
1385 |
+
<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>${init_service_worker}</script>`;
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
if (state.prerendering) {
|
1389 |
+
const http_equiv = [];
|
1390 |
+
|
1391 |
+
const csp_headers = csp.get_meta();
|
1392 |
+
if (csp_headers) {
|
1393 |
+
http_equiv.push(csp_headers);
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
if (cache) {
|
1397 |
+
http_equiv.push(`<meta http-equiv="cache-control" content="max-age=${cache.maxage}">`);
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
if (http_equiv.length > 0) {
|
1401 |
+
head = http_equiv.join('\n') + head;
|
1402 |
+
}
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
const segments = event.url.pathname.slice(options.paths.base.length).split('/').slice(2);
|
1406 |
+
const assets =
|
1407 |
+
options.paths.assets || (segments.length > 0 ? segments.map(() => '..').join('/') : '.');
|
1408 |
+
|
1409 |
+
const html = await resolve_opts.transformPage({
|
1410 |
+
html: options.template({ head, body, assets, nonce: /** @type {string} */ (csp.nonce) })
|
1411 |
+
});
|
1412 |
+
|
1413 |
+
const headers = new Headers({
|
1414 |
+
'content-type': 'text/html',
|
1415 |
+
etag: `"${hash(html)}"`
|
1416 |
+
});
|
1417 |
+
|
1418 |
+
if (cache) {
|
1419 |
+
headers.set('cache-control', `${is_private ? 'private' : 'public'}, max-age=${cache.maxage}`);
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
if (!options.floc) {
|
1423 |
+
headers.set('permissions-policy', 'interest-cohort=()');
|
1424 |
+
}
|
1425 |
+
|
1426 |
+
if (!state.prerendering) {
|
1427 |
+
const csp_header = csp.get_header();
|
1428 |
+
if (csp_header) {
|
1429 |
+
headers.set('content-security-policy', csp_header);
|
1430 |
+
}
|
1431 |
+
}
|
1432 |
+
|
1433 |
+
return new Response(html, {
|
1434 |
+
status,
|
1435 |
+
headers
|
1436 |
+
});
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
/**
|
1440 |
+
* @param {any} data
|
1441 |
+
* @param {(error: Error) => void} [fail]
|
1442 |
+
*/
|
1443 |
+
function try_serialize(data, fail) {
|
1444 |
+
try {
|
1445 |
+
return devalue(data);
|
1446 |
+
} catch (err) {
|
1447 |
+
if (fail) fail(coalesce_to_error(err));
|
1448 |
+
return null;
|
1449 |
+
}
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
// Ensure we return something truthy so the client will not re-render the page over the error
|
1453 |
+
|
1454 |
+
/** @param {(Error & {frame?: string} & {loc?: object}) | undefined | null} error */
|
1455 |
+
function serialize_error(error) {
|
1456 |
+
if (!error) return null;
|
1457 |
+
let serialized = try_serialize(error);
|
1458 |
+
if (!serialized) {
|
1459 |
+
const { name, message, stack } = error;
|
1460 |
+
serialized = try_serialize({ ...error, name, message, stack });
|
1461 |
+
}
|
1462 |
+
if (!serialized) {
|
1463 |
+
serialized = '{}';
|
1464 |
+
}
|
1465 |
+
return serialized;
|
1466 |
+
}
|
1467 |
+
|
1468 |
+
/*!
|
1469 |
+
* cookie
|
1470 |
+
* Copyright(c) 2012-2014 Roman Shtylman
|
1471 |
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
1472 |
+
* MIT Licensed
|
1473 |
+
*/
|
1474 |
+
|
1475 |
+
/**
|
1476 |
+
* Module exports.
|
1477 |
+
* @public
|
1478 |
+
*/
|
1479 |
+
|
1480 |
+
var parse_1 = parse$1;
|
1481 |
+
var serialize_1 = serialize;
|
1482 |
+
|
1483 |
+
/**
|
1484 |
+
* Module variables.
|
1485 |
+
* @private
|
1486 |
+
*/
|
1487 |
+
|
1488 |
+
var __toString = Object.prototype.toString;
|
1489 |
+
|
1490 |
+
/**
|
1491 |
+
* RegExp to match field-content in RFC 7230 sec 3.2
|
1492 |
+
*
|
1493 |
+
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
1494 |
+
* field-vchar = VCHAR / obs-text
|
1495 |
+
* obs-text = %x80-FF
|
1496 |
+
*/
|
1497 |
+
|
1498 |
+
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
1499 |
+
|
1500 |
+
/**
|
1501 |
+
* Parse a cookie header.
|
1502 |
+
*
|
1503 |
+
* Parse the given cookie header string into an object
|
1504 |
+
* The object has the various cookies as keys(names) => values
|
1505 |
+
*
|
1506 |
+
* @param {string} str
|
1507 |
+
* @param {object} [options]
|
1508 |
+
* @return {object}
|
1509 |
+
* @public
|
1510 |
+
*/
|
1511 |
+
|
1512 |
+
function parse$1(str, options) {
|
1513 |
+
if (typeof str !== 'string') {
|
1514 |
+
throw new TypeError('argument str must be a string');
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
var obj = {};
|
1518 |
+
var opt = options || {};
|
1519 |
+
var dec = opt.decode || decode;
|
1520 |
+
|
1521 |
+
var index = 0;
|
1522 |
+
while (index < str.length) {
|
1523 |
+
var eqIdx = str.indexOf('=', index);
|
1524 |
+
|
1525 |
+
// no more cookie pairs
|
1526 |
+
if (eqIdx === -1) {
|
1527 |
+
break
|
1528 |
+
}
|
1529 |
+
|
1530 |
+
var endIdx = str.indexOf(';', index);
|
1531 |
+
|
1532 |
+
if (endIdx === -1) {
|
1533 |
+
endIdx = str.length;
|
1534 |
+
} else if (endIdx < eqIdx) {
|
1535 |
+
// backtrack on prior semicolon
|
1536 |
+
index = str.lastIndexOf(';', eqIdx - 1) + 1;
|
1537 |
+
continue
|
1538 |
+
}
|
1539 |
+
|
1540 |
+
var key = str.slice(index, eqIdx).trim();
|
1541 |
+
|
1542 |
+
// only assign once
|
1543 |
+
if (undefined === obj[key]) {
|
1544 |
+
var val = str.slice(eqIdx + 1, endIdx).trim();
|
1545 |
+
|
1546 |
+
// quoted values
|
1547 |
+
if (val.charCodeAt(0) === 0x22) {
|
1548 |
+
val = val.slice(1, -1);
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
obj[key] = tryDecode(val, dec);
|
1552 |
+
}
|
1553 |
+
|
1554 |
+
index = endIdx + 1;
|
1555 |
+
}
|
1556 |
+
|
1557 |
+
return obj;
|
1558 |
+
}
|
1559 |
+
|
1560 |
+
/**
|
1561 |
+
* Serialize data into a cookie header.
|
1562 |
+
*
|
1563 |
+
* Serialize the a name value pair into a cookie string suitable for
|
1564 |
+
* http headers. An optional options object specified cookie parameters.
|
1565 |
+
*
|
1566 |
+
* serialize('foo', 'bar', { httpOnly: true })
|
1567 |
+
* => "foo=bar; httpOnly"
|
1568 |
+
*
|
1569 |
+
* @param {string} name
|
1570 |
+
* @param {string} val
|
1571 |
+
* @param {object} [options]
|
1572 |
+
* @return {string}
|
1573 |
+
* @public
|
1574 |
+
*/
|
1575 |
+
|
1576 |
+
function serialize(name, val, options) {
|
1577 |
+
var opt = options || {};
|
1578 |
+
var enc = opt.encode || encode;
|
1579 |
+
|
1580 |
+
if (typeof enc !== 'function') {
|
1581 |
+
throw new TypeError('option encode is invalid');
|
1582 |
+
}
|
1583 |
+
|
1584 |
+
if (!fieldContentRegExp.test(name)) {
|
1585 |
+
throw new TypeError('argument name is invalid');
|
1586 |
+
}
|
1587 |
+
|
1588 |
+
var value = enc(val);
|
1589 |
+
|
1590 |
+
if (value && !fieldContentRegExp.test(value)) {
|
1591 |
+
throw new TypeError('argument val is invalid');
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
var str = name + '=' + value;
|
1595 |
+
|
1596 |
+
if (null != opt.maxAge) {
|
1597 |
+
var maxAge = opt.maxAge - 0;
|
1598 |
+
|
1599 |
+
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
1600 |
+
throw new TypeError('option maxAge is invalid')
|
1601 |
+
}
|
1602 |
+
|
1603 |
+
str += '; Max-Age=' + Math.floor(maxAge);
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
if (opt.domain) {
|
1607 |
+
if (!fieldContentRegExp.test(opt.domain)) {
|
1608 |
+
throw new TypeError('option domain is invalid');
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
str += '; Domain=' + opt.domain;
|
1612 |
+
}
|
1613 |
+
|
1614 |
+
if (opt.path) {
|
1615 |
+
if (!fieldContentRegExp.test(opt.path)) {
|
1616 |
+
throw new TypeError('option path is invalid');
|
1617 |
+
}
|
1618 |
+
|
1619 |
+
str += '; Path=' + opt.path;
|
1620 |
+
}
|
1621 |
+
|
1622 |
+
if (opt.expires) {
|
1623 |
+
var expires = opt.expires;
|
1624 |
+
|
1625 |
+
if (!isDate(expires) || isNaN(expires.valueOf())) {
|
1626 |
+
throw new TypeError('option expires is invalid');
|
1627 |
+
}
|
1628 |
+
|
1629 |
+
str += '; Expires=' + expires.toUTCString();
|
1630 |
+
}
|
1631 |
+
|
1632 |
+
if (opt.httpOnly) {
|
1633 |
+
str += '; HttpOnly';
|
1634 |
+
}
|
1635 |
+
|
1636 |
+
if (opt.secure) {
|
1637 |
+
str += '; Secure';
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
if (opt.priority) {
|
1641 |
+
var priority = typeof opt.priority === 'string'
|
1642 |
+
? opt.priority.toLowerCase()
|
1643 |
+
: opt.priority;
|
1644 |
+
|
1645 |
+
switch (priority) {
|
1646 |
+
case 'low':
|
1647 |
+
str += '; Priority=Low';
|
1648 |
+
break
|
1649 |
+
case 'medium':
|
1650 |
+
str += '; Priority=Medium';
|
1651 |
+
break
|
1652 |
+
case 'high':
|
1653 |
+
str += '; Priority=High';
|
1654 |
+
break
|
1655 |
+
default:
|
1656 |
+
throw new TypeError('option priority is invalid')
|
1657 |
+
}
|
1658 |
+
}
|
1659 |
+
|
1660 |
+
if (opt.sameSite) {
|
1661 |
+
var sameSite = typeof opt.sameSite === 'string'
|
1662 |
+
? opt.sameSite.toLowerCase() : opt.sameSite;
|
1663 |
+
|
1664 |
+
switch (sameSite) {
|
1665 |
+
case true:
|
1666 |
+
str += '; SameSite=Strict';
|
1667 |
+
break;
|
1668 |
+
case 'lax':
|
1669 |
+
str += '; SameSite=Lax';
|
1670 |
+
break;
|
1671 |
+
case 'strict':
|
1672 |
+
str += '; SameSite=Strict';
|
1673 |
+
break;
|
1674 |
+
case 'none':
|
1675 |
+
str += '; SameSite=None';
|
1676 |
+
break;
|
1677 |
+
default:
|
1678 |
+
throw new TypeError('option sameSite is invalid');
|
1679 |
+
}
|
1680 |
+
}
|
1681 |
+
|
1682 |
+
return str;
|
1683 |
+
}
|
1684 |
+
|
1685 |
+
/**
|
1686 |
+
* URL-decode string value. Optimized to skip native call when no %.
|
1687 |
+
*
|
1688 |
+
* @param {string} str
|
1689 |
+
* @returns {string}
|
1690 |
+
*/
|
1691 |
+
|
1692 |
+
function decode (str) {
|
1693 |
+
return str.indexOf('%') !== -1
|
1694 |
+
? decodeURIComponent(str)
|
1695 |
+
: str
|
1696 |
+
}
|
1697 |
+
|
1698 |
+
/**
|
1699 |
+
* URL-encode value.
|
1700 |
+
*
|
1701 |
+
* @param {string} str
|
1702 |
+
* @returns {string}
|
1703 |
+
*/
|
1704 |
+
|
1705 |
+
function encode (val) {
|
1706 |
+
return encodeURIComponent(val)
|
1707 |
+
}
|
1708 |
+
|
1709 |
+
/**
|
1710 |
+
* Determine if value is a Date.
|
1711 |
+
*
|
1712 |
+
* @param {*} val
|
1713 |
+
* @private
|
1714 |
+
*/
|
1715 |
+
|
1716 |
+
function isDate (val) {
|
1717 |
+
return __toString.call(val) === '[object Date]' ||
|
1718 |
+
val instanceof Date
|
1719 |
+
}
|
1720 |
+
|
1721 |
+
/**
|
1722 |
+
* Try decoding a string using a decoding function.
|
1723 |
+
*
|
1724 |
+
* @param {string} str
|
1725 |
+
* @param {function} decode
|
1726 |
+
* @private
|
1727 |
+
*/
|
1728 |
+
|
1729 |
+
function tryDecode(str, decode) {
|
1730 |
+
try {
|
1731 |
+
return decode(str);
|
1732 |
+
} catch (e) {
|
1733 |
+
return str;
|
1734 |
+
}
|
1735 |
+
}
|
1736 |
+
|
1737 |
+
var setCookie = {exports: {}};
|
1738 |
+
|
1739 |
+
var defaultParseOptions = {
|
1740 |
+
decodeValues: true,
|
1741 |
+
map: false,
|
1742 |
+
silent: false,
|
1743 |
+
};
|
1744 |
+
|
1745 |
+
function isNonEmptyString(str) {
|
1746 |
+
return typeof str === "string" && !!str.trim();
|
1747 |
+
}
|
1748 |
+
|
1749 |
+
function parseString(setCookieValue, options) {
|
1750 |
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
1751 |
+
var nameValue = parts.shift().split("=");
|
1752 |
+
var name = nameValue.shift();
|
1753 |
+
var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
|
1754 |
+
|
1755 |
+
options = options
|
1756 |
+
? Object.assign({}, defaultParseOptions, options)
|
1757 |
+
: defaultParseOptions;
|
1758 |
+
|
1759 |
+
try {
|
1760 |
+
value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
|
1761 |
+
} catch (e) {
|
1762 |
+
console.error(
|
1763 |
+
"set-cookie-parser encountered an error while decoding a cookie with value '" +
|
1764 |
+
value +
|
1765 |
+
"'. Set options.decodeValues to false to disable this feature.",
|
1766 |
+
e
|
1767 |
+
);
|
1768 |
+
}
|
1769 |
+
|
1770 |
+
var cookie = {
|
1771 |
+
name: name, // grab everything before the first =
|
1772 |
+
value: value,
|
1773 |
+
};
|
1774 |
+
|
1775 |
+
parts.forEach(function (part) {
|
1776 |
+
var sides = part.split("=");
|
1777 |
+
var key = sides.shift().trimLeft().toLowerCase();
|
1778 |
+
var value = sides.join("=");
|
1779 |
+
if (key === "expires") {
|
1780 |
+
cookie.expires = new Date(value);
|
1781 |
+
} else if (key === "max-age") {
|
1782 |
+
cookie.maxAge = parseInt(value, 10);
|
1783 |
+
} else if (key === "secure") {
|
1784 |
+
cookie.secure = true;
|
1785 |
+
} else if (key === "httponly") {
|
1786 |
+
cookie.httpOnly = true;
|
1787 |
+
} else if (key === "samesite") {
|
1788 |
+
cookie.sameSite = value;
|
1789 |
+
} else {
|
1790 |
+
cookie[key] = value;
|
1791 |
+
}
|
1792 |
+
});
|
1793 |
+
|
1794 |
+
return cookie;
|
1795 |
+
}
|
1796 |
+
|
1797 |
+
function parse(input, options) {
|
1798 |
+
options = options
|
1799 |
+
? Object.assign({}, defaultParseOptions, options)
|
1800 |
+
: defaultParseOptions;
|
1801 |
+
|
1802 |
+
if (!input) {
|
1803 |
+
if (!options.map) {
|
1804 |
+
return [];
|
1805 |
+
} else {
|
1806 |
+
return {};
|
1807 |
+
}
|
1808 |
+
}
|
1809 |
+
|
1810 |
+
if (input.headers && input.headers["set-cookie"]) {
|
1811 |
+
// fast-path for node.js (which automatically normalizes header names to lower-case
|
1812 |
+
input = input.headers["set-cookie"];
|
1813 |
+
} else if (input.headers) {
|
1814 |
+
// slow-path for other environments - see #25
|
1815 |
+
var sch =
|
1816 |
+
input.headers[
|
1817 |
+
Object.keys(input.headers).find(function (key) {
|
1818 |
+
return key.toLowerCase() === "set-cookie";
|
1819 |
+
})
|
1820 |
+
];
|
1821 |
+
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
|
1822 |
+
if (!sch && input.headers.cookie && !options.silent) {
|
1823 |
+
console.warn(
|
1824 |
+
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
1825 |
+
);
|
1826 |
+
}
|
1827 |
+
input = sch;
|
1828 |
+
}
|
1829 |
+
if (!Array.isArray(input)) {
|
1830 |
+
input = [input];
|
1831 |
+
}
|
1832 |
+
|
1833 |
+
options = options
|
1834 |
+
? Object.assign({}, defaultParseOptions, options)
|
1835 |
+
: defaultParseOptions;
|
1836 |
+
|
1837 |
+
if (!options.map) {
|
1838 |
+
return input.filter(isNonEmptyString).map(function (str) {
|
1839 |
+
return parseString(str, options);
|
1840 |
+
});
|
1841 |
+
} else {
|
1842 |
+
var cookies = {};
|
1843 |
+
return input.filter(isNonEmptyString).reduce(function (cookies, str) {
|
1844 |
+
var cookie = parseString(str, options);
|
1845 |
+
cookies[cookie.name] = cookie;
|
1846 |
+
return cookies;
|
1847 |
+
}, cookies);
|
1848 |
+
}
|
1849 |
+
}
|
1850 |
+
|
1851 |
+
/*
|
1852 |
+
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
1853 |
+
that are within a single set-cookie field-value, such as in the Expires portion.
|
1854 |
+
|
1855 |
+
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
1856 |
+
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
1857 |
+
React Native's fetch does this for *every* header, including set-cookie.
|
1858 |
+
|
1859 |
+
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
1860 |
+
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
1861 |
+
*/
|
1862 |
+
function splitCookiesString(cookiesString) {
|
1863 |
+
if (Array.isArray(cookiesString)) {
|
1864 |
+
return cookiesString;
|
1865 |
+
}
|
1866 |
+
if (typeof cookiesString !== "string") {
|
1867 |
+
return [];
|
1868 |
+
}
|
1869 |
+
|
1870 |
+
var cookiesStrings = [];
|
1871 |
+
var pos = 0;
|
1872 |
+
var start;
|
1873 |
+
var ch;
|
1874 |
+
var lastComma;
|
1875 |
+
var nextStart;
|
1876 |
+
var cookiesSeparatorFound;
|
1877 |
+
|
1878 |
+
function skipWhitespace() {
|
1879 |
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
1880 |
+
pos += 1;
|
1881 |
+
}
|
1882 |
+
return pos < cookiesString.length;
|
1883 |
+
}
|
1884 |
+
|
1885 |
+
function notSpecialChar() {
|
1886 |
+
ch = cookiesString.charAt(pos);
|
1887 |
+
|
1888 |
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
1889 |
+
}
|
1890 |
+
|
1891 |
+
while (pos < cookiesString.length) {
|
1892 |
+
start = pos;
|
1893 |
+
cookiesSeparatorFound = false;
|
1894 |
+
|
1895 |
+
while (skipWhitespace()) {
|
1896 |
+
ch = cookiesString.charAt(pos);
|
1897 |
+
if (ch === ",") {
|
1898 |
+
// ',' is a cookie separator if we have later first '=', not ';' or ','
|
1899 |
+
lastComma = pos;
|
1900 |
+
pos += 1;
|
1901 |
+
|
1902 |
+
skipWhitespace();
|
1903 |
+
nextStart = pos;
|
1904 |
+
|
1905 |
+
while (pos < cookiesString.length && notSpecialChar()) {
|
1906 |
+
pos += 1;
|
1907 |
+
}
|
1908 |
+
|
1909 |
+
// currently special character
|
1910 |
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
1911 |
+
// we found cookies separator
|
1912 |
+
cookiesSeparatorFound = true;
|
1913 |
+
// pos is inside the next cookie, so back up and return it.
|
1914 |
+
pos = nextStart;
|
1915 |
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
1916 |
+
start = pos;
|
1917 |
+
} else {
|
1918 |
+
// in param ',' or param separator ';',
|
1919 |
+
// we continue from that comma
|
1920 |
+
pos = lastComma + 1;
|
1921 |
+
}
|
1922 |
+
} else {
|
1923 |
+
pos += 1;
|
1924 |
+
}
|
1925 |
+
}
|
1926 |
+
|
1927 |
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
1928 |
+
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
1929 |
+
}
|
1930 |
+
}
|
1931 |
+
|
1932 |
+
return cookiesStrings;
|
1933 |
+
}
|
1934 |
+
|
1935 |
+
setCookie.exports = parse;
|
1936 |
+
setCookie.exports.parse = parse;
|
1937 |
+
var parseString_1 = setCookie.exports.parseString = parseString;
|
1938 |
+
var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
|
1939 |
+
|
1940 |
+
/**
|
1941 |
+
* @param {import('types').LoadOutput} loaded
|
1942 |
+
* @returns {import('types').NormalizedLoadOutput}
|
1943 |
+
*/
|
1944 |
+
function normalize(loaded) {
|
1945 |
+
// TODO remove for 1.0
|
1946 |
+
// @ts-expect-error
|
1947 |
+
if (loaded.fallthrough) {
|
1948 |
+
throw new Error(
|
1949 |
+
'fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching'
|
1950 |
+
);
|
1951 |
+
}
|
1952 |
+
|
1953 |
+
// TODO remove for 1.0
|
1954 |
+
if ('maxage' in loaded) {
|
1955 |
+
throw new Error('maxage should be replaced with cache: { maxage }');
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
const has_error_status =
|
1959 |
+
loaded.status && loaded.status >= 400 && loaded.status <= 599 && !loaded.redirect;
|
1960 |
+
if (loaded.error || has_error_status) {
|
1961 |
+
const status = loaded.status;
|
1962 |
+
|
1963 |
+
if (!loaded.error && has_error_status) {
|
1964 |
+
return { status: status || 500, error: new Error() };
|
1965 |
+
}
|
1966 |
+
|
1967 |
+
const error = typeof loaded.error === 'string' ? new Error(loaded.error) : loaded.error;
|
1968 |
+
|
1969 |
+
if (!(error instanceof Error)) {
|
1970 |
+
return {
|
1971 |
+
status: 500,
|
1972 |
+
error: new Error(
|
1973 |
+
`"error" property returned from load() must be a string or instance of Error, received type "${typeof error}"`
|
1974 |
+
)
|
1975 |
+
};
|
1976 |
+
}
|
1977 |
+
|
1978 |
+
if (!status || status < 400 || status > 599) {
|
1979 |
+
console.warn('"error" returned from load() without a valid status code — defaulting to 500');
|
1980 |
+
return { status: 500, error };
|
1981 |
+
}
|
1982 |
+
|
1983 |
+
return { status, error };
|
1984 |
+
}
|
1985 |
+
|
1986 |
+
if (loaded.redirect) {
|
1987 |
+
if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
|
1988 |
+
throw new Error(
|
1989 |
+
'"redirect" property returned from load() must be accompanied by a 3xx status code'
|
1990 |
+
);
|
1991 |
+
}
|
1992 |
+
|
1993 |
+
if (typeof loaded.redirect !== 'string') {
|
1994 |
+
throw new Error('"redirect" property returned from load() must be a string');
|
1995 |
+
}
|
1996 |
+
}
|
1997 |
+
|
1998 |
+
if (loaded.dependencies) {
|
1999 |
+
if (
|
2000 |
+
!Array.isArray(loaded.dependencies) ||
|
2001 |
+
loaded.dependencies.some((dep) => typeof dep !== 'string')
|
2002 |
+
) {
|
2003 |
+
throw new Error('"dependencies" property returned from load() must be of type string[]');
|
2004 |
+
}
|
2005 |
+
}
|
2006 |
+
|
2007 |
+
// TODO remove before 1.0
|
2008 |
+
if (/** @type {any} */ (loaded).context) {
|
2009 |
+
throw new Error(
|
2010 |
+
'You are returning "context" from a load function. ' +
|
2011 |
+
'"context" was renamed to "stuff", please adjust your code accordingly.'
|
2012 |
+
);
|
2013 |
+
}
|
2014 |
+
|
2015 |
+
return /** @type {import('types').NormalizedLoadOutput} */ (loaded);
|
2016 |
+
}
|
2017 |
+
|
2018 |
+
/**
|
2019 |
+
* @param {string} hostname
|
2020 |
+
* @param {string} [constraint]
|
2021 |
+
*/
|
2022 |
+
function domain_matches(hostname, constraint) {
|
2023 |
+
if (!constraint) return true;
|
2024 |
+
|
2025 |
+
const normalized = constraint[0] === '.' ? constraint.slice(1) : constraint;
|
2026 |
+
|
2027 |
+
if (hostname === normalized) return true;
|
2028 |
+
return hostname.endsWith('.' + normalized);
|
2029 |
+
}
|
2030 |
+
|
2031 |
+
/**
|
2032 |
+
* @param {string} path
|
2033 |
+
* @param {string} [constraint]
|
2034 |
+
*/
|
2035 |
+
function path_matches(path, constraint) {
|
2036 |
+
if (!constraint) return true;
|
2037 |
+
|
2038 |
+
const normalized = constraint.endsWith('/') ? constraint.slice(0, -1) : constraint;
|
2039 |
+
|
2040 |
+
if (path === normalized) return true;
|
2041 |
+
return path.startsWith(normalized + '/');
|
2042 |
+
}
|
2043 |
+
|
2044 |
+
/**
|
2045 |
+
* Calls the user's `load` function.
|
2046 |
+
* @param {{
|
2047 |
+
* event: import('types').RequestEvent;
|
2048 |
+
* options: import('types').SSROptions;
|
2049 |
+
* state: import('types').SSRState;
|
2050 |
+
* route: import('types').SSRPage | null;
|
2051 |
+
* node: import('types').SSRNode;
|
2052 |
+
* $session: any;
|
2053 |
+
* stuff: Record<string, any>;
|
2054 |
+
* is_error: boolean;
|
2055 |
+
* is_leaf: boolean;
|
2056 |
+
* status?: number;
|
2057 |
+
* error?: Error;
|
2058 |
+
* }} opts
|
2059 |
+
* @returns {Promise<import('./types').Loaded>}
|
2060 |
+
*/
|
2061 |
+
async function load_node({
|
2062 |
+
event,
|
2063 |
+
options,
|
2064 |
+
state,
|
2065 |
+
route,
|
2066 |
+
node,
|
2067 |
+
$session,
|
2068 |
+
stuff,
|
2069 |
+
is_error,
|
2070 |
+
is_leaf,
|
2071 |
+
status,
|
2072 |
+
error
|
2073 |
+
}) {
|
2074 |
+
const { module } = node;
|
2075 |
+
|
2076 |
+
let uses_credentials = false;
|
2077 |
+
|
2078 |
+
/** @type {Array<import('./types').Fetched>} */
|
2079 |
+
const fetched = [];
|
2080 |
+
|
2081 |
+
const cookies = parse_1(event.request.headers.get('cookie') || '');
|
2082 |
+
|
2083 |
+
/** @type {import('set-cookie-parser').Cookie[]} */
|
2084 |
+
const new_cookies = [];
|
2085 |
+
|
2086 |
+
/** @type {import('types').LoadOutput} */
|
2087 |
+
let loaded;
|
2088 |
+
|
2089 |
+
const should_prerender = node.module.prerender ?? options.prerender.default;
|
2090 |
+
|
2091 |
+
/** @type {import('types').ShadowData} */
|
2092 |
+
const shadow = is_leaf
|
2093 |
+
? await load_shadow_data(
|
2094 |
+
/** @type {import('types').SSRPage} */ (route),
|
2095 |
+
event,
|
2096 |
+
options,
|
2097 |
+
should_prerender
|
2098 |
+
)
|
2099 |
+
: {};
|
2100 |
+
|
2101 |
+
if (shadow.cookies) {
|
2102 |
+
shadow.cookies.forEach((header) => {
|
2103 |
+
new_cookies.push(parseString_1(header));
|
2104 |
+
});
|
2105 |
+
}
|
2106 |
+
|
2107 |
+
if (shadow.error) {
|
2108 |
+
loaded = {
|
2109 |
+
status: shadow.status,
|
2110 |
+
error: shadow.error
|
2111 |
+
};
|
2112 |
+
} else if (shadow.redirect) {
|
2113 |
+
loaded = {
|
2114 |
+
status: shadow.status,
|
2115 |
+
redirect: shadow.redirect
|
2116 |
+
};
|
2117 |
+
} else if (module.load) {
|
2118 |
+
/** @type {import('types').LoadEvent} */
|
2119 |
+
const load_input = {
|
2120 |
+
url: state.prerendering ? new PrerenderingURL(event.url) : new LoadURL(event.url),
|
2121 |
+
params: event.params,
|
2122 |
+
props: shadow.body || {},
|
2123 |
+
routeId: event.routeId,
|
2124 |
+
get session() {
|
2125 |
+
if (node.module.prerender ?? options.prerender.default) {
|
2126 |
+
throw Error(
|
2127 |
+
'Attempted to access session from a prerendered page. Session would never be populated.'
|
2128 |
+
);
|
2129 |
+
}
|
2130 |
+
uses_credentials = true;
|
2131 |
+
return $session;
|
2132 |
+
},
|
2133 |
+
/**
|
2134 |
+
* @param {RequestInfo} resource
|
2135 |
+
* @param {RequestInit} opts
|
2136 |
+
*/
|
2137 |
+
fetch: async (resource, opts = {}) => {
|
2138 |
+
/** @type {string} */
|
2139 |
+
let requested;
|
2140 |
+
|
2141 |
+
if (typeof resource === 'string') {
|
2142 |
+
requested = resource;
|
2143 |
+
} else {
|
2144 |
+
requested = resource.url;
|
2145 |
+
|
2146 |
+
opts = {
|
2147 |
+
method: resource.method,
|
2148 |
+
headers: resource.headers,
|
2149 |
+
body: resource.body,
|
2150 |
+
mode: resource.mode,
|
2151 |
+
credentials: resource.credentials,
|
2152 |
+
cache: resource.cache,
|
2153 |
+
redirect: resource.redirect,
|
2154 |
+
referrer: resource.referrer,
|
2155 |
+
integrity: resource.integrity,
|
2156 |
+
...opts
|
2157 |
+
};
|
2158 |
+
}
|
2159 |
+
|
2160 |
+
opts.headers = new Headers(opts.headers);
|
2161 |
+
|
2162 |
+
// merge headers from request
|
2163 |
+
for (const [key, value] of event.request.headers) {
|
2164 |
+
if (
|
2165 |
+
key !== 'authorization' &&
|
2166 |
+
key !== 'cookie' &&
|
2167 |
+
key !== 'host' &&
|
2168 |
+
key !== 'if-none-match' &&
|
2169 |
+
!opts.headers.has(key)
|
2170 |
+
) {
|
2171 |
+
opts.headers.set(key, value);
|
2172 |
+
}
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
const resolved = resolve(event.url.pathname, requested.split('?')[0]);
|
2176 |
+
|
2177 |
+
/** @type {Response} */
|
2178 |
+
let response;
|
2179 |
+
|
2180 |
+
/** @type {import('types').PrerenderDependency} */
|
2181 |
+
let dependency;
|
2182 |
+
|
2183 |
+
// handle fetch requests for static assets. e.g. prebaked data, etc.
|
2184 |
+
// we need to support everything the browser's fetch supports
|
2185 |
+
const prefix = options.paths.assets || options.paths.base;
|
2186 |
+
const filename = decodeURIComponent(
|
2187 |
+
resolved.startsWith(prefix) ? resolved.slice(prefix.length) : resolved
|
2188 |
+
).slice(1);
|
2189 |
+
const filename_html = `${filename}/index.html`; // path may also match path/index.html
|
2190 |
+
|
2191 |
+
const is_asset = options.manifest.assets.has(filename);
|
2192 |
+
const is_asset_html = options.manifest.assets.has(filename_html);
|
2193 |
+
|
2194 |
+
if (is_asset || is_asset_html) {
|
2195 |
+
const file = is_asset ? filename : filename_html;
|
2196 |
+
|
2197 |
+
if (options.read) {
|
2198 |
+
const type = is_asset
|
2199 |
+
? options.manifest.mimeTypes[filename.slice(filename.lastIndexOf('.'))]
|
2200 |
+
: 'text/html';
|
2201 |
+
|
2202 |
+
response = new Response(options.read(file), {
|
2203 |
+
headers: type ? { 'content-type': type } : {}
|
2204 |
+
});
|
2205 |
+
} else {
|
2206 |
+
response = await fetch(
|
2207 |
+
`${event.url.origin}/${file}`,
|
2208 |
+
/** @type {RequestInit} */ (opts)
|
2209 |
+
);
|
2210 |
+
}
|
2211 |
+
} else if (is_root_relative(resolved)) {
|
2212 |
+
if (opts.credentials !== 'omit') {
|
2213 |
+
uses_credentials = true;
|
2214 |
+
|
2215 |
+
const authorization = event.request.headers.get('authorization');
|
2216 |
+
|
2217 |
+
// combine cookies from the initiating request with any that were
|
2218 |
+
// added via set-cookie
|
2219 |
+
const combined_cookies = { ...cookies };
|
2220 |
+
|
2221 |
+
for (const cookie of new_cookies) {
|
2222 |
+
if (!domain_matches(event.url.hostname, cookie.domain)) continue;
|
2223 |
+
if (!path_matches(resolved, cookie.path)) continue;
|
2224 |
+
|
2225 |
+
combined_cookies[cookie.name] = cookie.value;
|
2226 |
+
}
|
2227 |
+
|
2228 |
+
const cookie = Object.entries(combined_cookies)
|
2229 |
+
.map(([name, value]) => `${name}=${value}`)
|
2230 |
+
.join('; ');
|
2231 |
+
|
2232 |
+
if (cookie) {
|
2233 |
+
opts.headers.set('cookie', cookie);
|
2234 |
+
}
|
2235 |
+
|
2236 |
+
if (authorization && !opts.headers.has('authorization')) {
|
2237 |
+
opts.headers.set('authorization', authorization);
|
2238 |
+
}
|
2239 |
+
}
|
2240 |
+
|
2241 |
+
if (opts.body && typeof opts.body !== 'string') {
|
2242 |
+
// per https://developer.mozilla.org/en-US/docs/Web/API/Request/Request, this can be a
|
2243 |
+
// Blob, BufferSource, FormData, URLSearchParams, USVString, or ReadableStream object.
|
2244 |
+
// non-string bodies are irksome to deal with, but luckily aren't particularly useful
|
2245 |
+
// in this context anyway, so we take the easy route and ban them
|
2246 |
+
throw new Error('Request body must be a string');
|
2247 |
+
}
|
2248 |
+
|
2249 |
+
response = await respond(
|
2250 |
+
new Request(new URL(requested, event.url).href, { ...opts }),
|
2251 |
+
options,
|
2252 |
+
{
|
2253 |
+
...state,
|
2254 |
+
initiator: route
|
2255 |
+
}
|
2256 |
+
);
|
2257 |
+
|
2258 |
+
if (state.prerendering) {
|
2259 |
+
dependency = { response, body: null };
|
2260 |
+
state.prerendering.dependencies.set(resolved, dependency);
|
2261 |
+
}
|
2262 |
+
} else {
|
2263 |
+
// external
|
2264 |
+
if (resolved.startsWith('//')) {
|
2265 |
+
requested = event.url.protocol + requested;
|
2266 |
+
}
|
2267 |
+
|
2268 |
+
// external fetch
|
2269 |
+
// allow cookie passthrough for "same-origin"
|
2270 |
+
// if SvelteKit is serving my.domain.com:
|
2271 |
+
// - domain.com WILL NOT receive cookies
|
2272 |
+
// - my.domain.com WILL receive cookies
|
2273 |
+
// - api.domain.dom WILL NOT receive cookies
|
2274 |
+
// - sub.my.domain.com WILL receive cookies
|
2275 |
+
// ports do not affect the resolution
|
2276 |
+
// leading dot prevents mydomain.com matching domain.com
|
2277 |
+
if (
|
2278 |
+
`.${new URL(requested).hostname}`.endsWith(`.${event.url.hostname}`) &&
|
2279 |
+
opts.credentials !== 'omit'
|
2280 |
+
) {
|
2281 |
+
uses_credentials = true;
|
2282 |
+
|
2283 |
+
const cookie = event.request.headers.get('cookie');
|
2284 |
+
if (cookie) opts.headers.set('cookie', cookie);
|
2285 |
+
}
|
2286 |
+
|
2287 |
+
// we need to delete the connection header, as explained here:
|
2288 |
+
// https://github.com/nodejs/undici/issues/1470#issuecomment-1140798467
|
2289 |
+
// TODO this may be a case for being selective about which headers we let through
|
2290 |
+
opts.headers.delete('connection');
|
2291 |
+
|
2292 |
+
const external_request = new Request(requested, /** @type {RequestInit} */ (opts));
|
2293 |
+
response = await options.hooks.externalFetch.call(null, external_request);
|
2294 |
+
}
|
2295 |
+
|
2296 |
+
const set_cookie = response.headers.get('set-cookie');
|
2297 |
+
if (set_cookie) {
|
2298 |
+
new_cookies.push(
|
2299 |
+
...splitCookiesString_1(set_cookie)
|
2300 |
+
.map((str) => parseString_1(str))
|
2301 |
+
);
|
2302 |
+
}
|
2303 |
+
|
2304 |
+
const proxy = new Proxy(response, {
|
2305 |
+
get(response, key, _receiver) {
|
2306 |
+
async function text() {
|
2307 |
+
const body = await response.text();
|
2308 |
+
|
2309 |
+
/** @type {import('types').ResponseHeaders} */
|
2310 |
+
const headers = {};
|
2311 |
+
for (const [key, value] of response.headers) {
|
2312 |
+
// TODO skip others besides set-cookie and etag?
|
2313 |
+
if (key !== 'set-cookie' && key !== 'etag') {
|
2314 |
+
headers[key] = value;
|
2315 |
+
}
|
2316 |
+
}
|
2317 |
+
|
2318 |
+
if (!opts.body || typeof opts.body === 'string') {
|
2319 |
+
const status_number = Number(response.status);
|
2320 |
+
if (isNaN(status_number)) {
|
2321 |
+
throw new Error(
|
2322 |
+
`response.status is not a number. value: "${
|
2323 |
+
response.status
|
2324 |
+
}" type: ${typeof response.status}`
|
2325 |
+
);
|
2326 |
+
}
|
2327 |
+
|
2328 |
+
fetched.push({
|
2329 |
+
url: requested,
|
2330 |
+
body: opts.body,
|
2331 |
+
response: {
|
2332 |
+
status: status_number,
|
2333 |
+
statusText: response.statusText,
|
2334 |
+
headers,
|
2335 |
+
body
|
2336 |
+
}
|
2337 |
+
});
|
2338 |
+
}
|
2339 |
+
|
2340 |
+
if (dependency) {
|
2341 |
+
dependency.body = body;
|
2342 |
+
}
|
2343 |
+
|
2344 |
+
return body;
|
2345 |
+
}
|
2346 |
+
|
2347 |
+
if (key === 'arrayBuffer') {
|
2348 |
+
return async () => {
|
2349 |
+
const buffer = await response.arrayBuffer();
|
2350 |
+
|
2351 |
+
if (dependency) {
|
2352 |
+
dependency.body = new Uint8Array(buffer);
|
2353 |
+
}
|
2354 |
+
|
2355 |
+
// TODO should buffer be inlined into the page (albeit base64'd)?
|
2356 |
+
// any conditions in which it shouldn't be?
|
2357 |
+
|
2358 |
+
return buffer;
|
2359 |
+
};
|
2360 |
+
}
|
2361 |
+
|
2362 |
+
if (key === 'text') {
|
2363 |
+
return text;
|
2364 |
+
}
|
2365 |
+
|
2366 |
+
if (key === 'json') {
|
2367 |
+
return async () => {
|
2368 |
+
return JSON.parse(await text());
|
2369 |
+
};
|
2370 |
+
}
|
2371 |
+
|
2372 |
+
// TODO arrayBuffer?
|
2373 |
+
|
2374 |
+
return Reflect.get(response, key, response);
|
2375 |
+
}
|
2376 |
+
});
|
2377 |
+
|
2378 |
+
return proxy;
|
2379 |
+
},
|
2380 |
+
stuff: { ...stuff },
|
2381 |
+
status: is_error ? status ?? null : null,
|
2382 |
+
error: is_error ? error ?? null : null
|
2383 |
+
};
|
2384 |
+
|
2385 |
+
if (options.dev) {
|
2386 |
+
// TODO remove this for 1.0
|
2387 |
+
Object.defineProperty(load_input, 'page', {
|
2388 |
+
get: () => {
|
2389 |
+
throw new Error('`page` in `load` functions has been replaced by `url` and `params`');
|
2390 |
+
}
|
2391 |
+
});
|
2392 |
+
}
|
2393 |
+
|
2394 |
+
loaded = await module.load.call(null, load_input);
|
2395 |
+
|
2396 |
+
if (!loaded) {
|
2397 |
+
// TODO do we still want to enforce this now that there's no fallthrough?
|
2398 |
+
throw new Error(`load function must return a value${options.dev ? ` (${node.entry})` : ''}`);
|
2399 |
+
}
|
2400 |
+
} else if (shadow.body) {
|
2401 |
+
loaded = {
|
2402 |
+
props: shadow.body
|
2403 |
+
};
|
2404 |
+
} else {
|
2405 |
+
loaded = {};
|
2406 |
+
}
|
2407 |
+
|
2408 |
+
// generate __data.json files when prerendering
|
2409 |
+
if (shadow.body && state.prerendering) {
|
2410 |
+
const pathname = `${event.url.pathname.replace(/\/$/, '')}/__data.json`;
|
2411 |
+
|
2412 |
+
const dependency = {
|
2413 |
+
response: new Response(undefined),
|
2414 |
+
body: JSON.stringify(shadow.body)
|
2415 |
+
};
|
2416 |
+
|
2417 |
+
state.prerendering.dependencies.set(pathname, dependency);
|
2418 |
+
}
|
2419 |
+
|
2420 |
+
return {
|
2421 |
+
node,
|
2422 |
+
props: shadow.body,
|
2423 |
+
loaded: normalize(loaded),
|
2424 |
+
stuff: loaded.stuff || stuff,
|
2425 |
+
fetched,
|
2426 |
+
set_cookie_headers: new_cookies.map((new_cookie) => {
|
2427 |
+
const { name, value, ...options } = new_cookie;
|
2428 |
+
// @ts-expect-error
|
2429 |
+
return serialize_1(name, value, options);
|
2430 |
+
}),
|
2431 |
+
uses_credentials
|
2432 |
+
};
|
2433 |
+
}
|
2434 |
+
|
2435 |
+
/**
|
2436 |
+
*
|
2437 |
+
* @param {import('types').SSRPage} route
|
2438 |
+
* @param {import('types').RequestEvent} event
|
2439 |
+
* @param {import('types').SSROptions} options
|
2440 |
+
* @param {boolean} prerender
|
2441 |
+
* @returns {Promise<import('types').ShadowData>}
|
2442 |
+
*/
|
2443 |
+
async function load_shadow_data(route, event, options, prerender) {
|
2444 |
+
if (!route.shadow) return {};
|
2445 |
+
|
2446 |
+
try {
|
2447 |
+
const mod = await route.shadow();
|
2448 |
+
|
2449 |
+
if (prerender && (mod.post || mod.put || mod.del || mod.patch)) {
|
2450 |
+
throw new Error('Cannot prerender pages that have endpoints with mutative methods');
|
2451 |
+
}
|
2452 |
+
|
2453 |
+
const method = normalize_request_method(event);
|
2454 |
+
const is_get = method === 'head' || method === 'get';
|
2455 |
+
const handler = method === 'head' ? mod.head || mod.get : mod[method];
|
2456 |
+
|
2457 |
+
if (!handler && !is_get) {
|
2458 |
+
return {
|
2459 |
+
status: 405,
|
2460 |
+
error: new Error(`${method} method not allowed`)
|
2461 |
+
};
|
2462 |
+
}
|
2463 |
+
|
2464 |
+
/** @type {import('types').ShadowData} */
|
2465 |
+
const data = {
|
2466 |
+
status: 200,
|
2467 |
+
cookies: [],
|
2468 |
+
body: {}
|
2469 |
+
};
|
2470 |
+
|
2471 |
+
if (!is_get) {
|
2472 |
+
const result = await handler(event);
|
2473 |
+
|
2474 |
+
// TODO remove for 1.0
|
2475 |
+
// @ts-expect-error
|
2476 |
+
if (result.fallthrough) {
|
2477 |
+
throw new Error(
|
2478 |
+
'fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching'
|
2479 |
+
);
|
2480 |
+
}
|
2481 |
+
|
2482 |
+
const { status, headers, body } = validate_shadow_output(result);
|
2483 |
+
data.status = status;
|
2484 |
+
|
2485 |
+
add_cookies(/** @type {string[]} */ (data.cookies), headers);
|
2486 |
+
|
2487 |
+
// Redirects are respected...
|
2488 |
+
if (status >= 300 && status < 400) {
|
2489 |
+
data.redirect = /** @type {string} */ (
|
2490 |
+
headers instanceof Headers ? headers.get('location') : headers.location
|
2491 |
+
);
|
2492 |
+
return data;
|
2493 |
+
}
|
2494 |
+
|
2495 |
+
// ...but 4xx and 5xx status codes _don't_ result in the error page
|
2496 |
+
// rendering for non-GET requests — instead, we allow the page
|
2497 |
+
// to render with any validation errors etc that were returned
|
2498 |
+
data.body = body;
|
2499 |
+
}
|
2500 |
+
|
2501 |
+
const get = (method === 'head' && mod.head) || mod.get;
|
2502 |
+
if (get) {
|
2503 |
+
const result = await get(event);
|
2504 |
+
|
2505 |
+
// TODO remove for 1.0
|
2506 |
+
// @ts-expect-error
|
2507 |
+
if (result.fallthrough) {
|
2508 |
+
throw new Error(
|
2509 |
+
'fallthrough is no longer supported. Use matchers instead: https://kit.svelte.dev/docs/routing#advanced-routing-matching'
|
2510 |
+
);
|
2511 |
+
}
|
2512 |
+
|
2513 |
+
const { status, headers, body } = validate_shadow_output(result);
|
2514 |
+
add_cookies(/** @type {string[]} */ (data.cookies), headers);
|
2515 |
+
data.status = status;
|
2516 |
+
|
2517 |
+
if (status >= 400) {
|
2518 |
+
data.error = new Error('Failed to load data');
|
2519 |
+
return data;
|
2520 |
+
}
|
2521 |
+
|
2522 |
+
if (status >= 300) {
|
2523 |
+
data.redirect = /** @type {string} */ (
|
2524 |
+
headers instanceof Headers ? headers.get('location') : headers.location
|
2525 |
+
);
|
2526 |
+
return data;
|
2527 |
+
}
|
2528 |
+
|
2529 |
+
data.body = { ...body, ...data.body };
|
2530 |
+
}
|
2531 |
+
|
2532 |
+
return data;
|
2533 |
+
} catch (e) {
|
2534 |
+
const error = coalesce_to_error(e);
|
2535 |
+
options.handle_error(error, event);
|
2536 |
+
|
2537 |
+
return {
|
2538 |
+
status: 500,
|
2539 |
+
error
|
2540 |
+
};
|
2541 |
+
}
|
2542 |
+
}
|
2543 |
+
|
2544 |
+
/**
|
2545 |
+
* @param {string[]} target
|
2546 |
+
* @param {Partial<import('types').ResponseHeaders>} headers
|
2547 |
+
*/
|
2548 |
+
function add_cookies(target, headers) {
|
2549 |
+
const cookies = headers['set-cookie'];
|
2550 |
+
if (cookies) {
|
2551 |
+
if (Array.isArray(cookies)) {
|
2552 |
+
target.push(...cookies);
|
2553 |
+
} else {
|
2554 |
+
target.push(/** @type {string} */ (cookies));
|
2555 |
+
}
|
2556 |
+
}
|
2557 |
+
}
|
2558 |
+
|
2559 |
+
/**
|
2560 |
+
* @param {import('types').ShadowEndpointOutput} result
|
2561 |
+
*/
|
2562 |
+
function validate_shadow_output(result) {
|
2563 |
+
const { status = 200, body = {} } = result;
|
2564 |
+
let headers = result.headers || {};
|
2565 |
+
|
2566 |
+
if (headers instanceof Headers) {
|
2567 |
+
if (headers.has('set-cookie')) {
|
2568 |
+
throw new Error(
|
2569 |
+
'Endpoint request handler cannot use Headers interface with Set-Cookie headers'
|
2570 |
+
);
|
2571 |
+
}
|
2572 |
+
} else {
|
2573 |
+
headers = lowercase_keys(/** @type {Record<string, string>} */ (headers));
|
2574 |
+
}
|
2575 |
+
|
2576 |
+
if (!is_pojo(body)) {
|
2577 |
+
throw new Error('Body returned from endpoint request handler must be a plain object');
|
2578 |
+
}
|
2579 |
+
|
2580 |
+
return { status, headers, body };
|
2581 |
+
}
|
2582 |
+
|
2583 |
+
/**
|
2584 |
+
* @typedef {import('./types.js').Loaded} Loaded
|
2585 |
+
* @typedef {import('types').SSROptions} SSROptions
|
2586 |
+
* @typedef {import('types').SSRState} SSRState
|
2587 |
+
*/
|
2588 |
+
|
2589 |
+
/**
|
2590 |
+
* @param {{
|
2591 |
+
* event: import('types').RequestEvent;
|
2592 |
+
* options: SSROptions;
|
2593 |
+
* state: SSRState;
|
2594 |
+
* $session: any;
|
2595 |
+
* status: number;
|
2596 |
+
* error: Error;
|
2597 |
+
* resolve_opts: import('types').RequiredResolveOptions;
|
2598 |
+
* }} opts
|
2599 |
+
*/
|
2600 |
+
async function respond_with_error({
|
2601 |
+
event,
|
2602 |
+
options,
|
2603 |
+
state,
|
2604 |
+
$session,
|
2605 |
+
status,
|
2606 |
+
error,
|
2607 |
+
resolve_opts
|
2608 |
+
}) {
|
2609 |
+
try {
|
2610 |
+
const branch = [];
|
2611 |
+
let stuff = {};
|
2612 |
+
|
2613 |
+
if (resolve_opts.ssr) {
|
2614 |
+
const default_layout = await options.manifest._.nodes[0](); // 0 is always the root layout
|
2615 |
+
const default_error = await options.manifest._.nodes[1](); // 1 is always the root error
|
2616 |
+
|
2617 |
+
const layout_loaded = /** @type {Loaded} */ (
|
2618 |
+
await load_node({
|
2619 |
+
event,
|
2620 |
+
options,
|
2621 |
+
state,
|
2622 |
+
route: null,
|
2623 |
+
node: default_layout,
|
2624 |
+
$session,
|
2625 |
+
stuff: {},
|
2626 |
+
is_error: false,
|
2627 |
+
is_leaf: false
|
2628 |
+
})
|
2629 |
+
);
|
2630 |
+
|
2631 |
+
const error_loaded = /** @type {Loaded} */ (
|
2632 |
+
await load_node({
|
2633 |
+
event,
|
2634 |
+
options,
|
2635 |
+
state,
|
2636 |
+
route: null,
|
2637 |
+
node: default_error,
|
2638 |
+
$session,
|
2639 |
+
stuff: layout_loaded ? layout_loaded.stuff : {},
|
2640 |
+
is_error: true,
|
2641 |
+
is_leaf: false,
|
2642 |
+
status,
|
2643 |
+
error
|
2644 |
+
})
|
2645 |
+
);
|
2646 |
+
|
2647 |
+
branch.push(layout_loaded, error_loaded);
|
2648 |
+
stuff = error_loaded.stuff;
|
2649 |
+
}
|
2650 |
+
|
2651 |
+
return await render_response({
|
2652 |
+
options,
|
2653 |
+
state,
|
2654 |
+
$session,
|
2655 |
+
page_config: {
|
2656 |
+
hydrate: options.hydrate,
|
2657 |
+
router: options.router
|
2658 |
+
},
|
2659 |
+
stuff,
|
2660 |
+
status,
|
2661 |
+
error,
|
2662 |
+
branch,
|
2663 |
+
event,
|
2664 |
+
resolve_opts
|
2665 |
+
});
|
2666 |
+
} catch (err) {
|
2667 |
+
const error = coalesce_to_error(err);
|
2668 |
+
|
2669 |
+
options.handle_error(error, event);
|
2670 |
+
|
2671 |
+
return new Response(error.stack, {
|
2672 |
+
status: 500
|
2673 |
+
});
|
2674 |
+
}
|
2675 |
+
}
|
2676 |
+
|
2677 |
+
/**
|
2678 |
+
* @typedef {import('./types.js').Loaded} Loaded
|
2679 |
+
* @typedef {import('types').SSRNode} SSRNode
|
2680 |
+
* @typedef {import('types').SSROptions} SSROptions
|
2681 |
+
* @typedef {import('types').SSRState} SSRState
|
2682 |
+
*/
|
2683 |
+
|
2684 |
+
/**
|
2685 |
+
* Gets the nodes, calls `load` for each of them, and then calls render to build the HTML response.
|
2686 |
+
* @param {{
|
2687 |
+
* event: import('types').RequestEvent;
|
2688 |
+
* options: SSROptions;
|
2689 |
+
* state: SSRState;
|
2690 |
+
* $session: any;
|
2691 |
+
* resolve_opts: import('types').RequiredResolveOptions;
|
2692 |
+
* route: import('types').SSRPage;
|
2693 |
+
* }} opts
|
2694 |
+
* @returns {Promise<Response>}
|
2695 |
+
*/
|
2696 |
+
async function respond$1(opts) {
|
2697 |
+
const { event, options, state, $session, route, resolve_opts } = opts;
|
2698 |
+
|
2699 |
+
/** @type {Array<SSRNode | undefined>} */
|
2700 |
+
let nodes;
|
2701 |
+
|
2702 |
+
if (!resolve_opts.ssr) {
|
2703 |
+
return await render_response({
|
2704 |
+
...opts,
|
2705 |
+
branch: [],
|
2706 |
+
page_config: {
|
2707 |
+
hydrate: true,
|
2708 |
+
router: true
|
2709 |
+
},
|
2710 |
+
status: 200,
|
2711 |
+
error: null,
|
2712 |
+
event,
|
2713 |
+
stuff: {}
|
2714 |
+
});
|
2715 |
+
}
|
2716 |
+
|
2717 |
+
try {
|
2718 |
+
nodes = await Promise.all(
|
2719 |
+
// we use == here rather than === because [undefined] serializes as "[null]"
|
2720 |
+
route.a.map((n) => (n == undefined ? n : options.manifest._.nodes[n]()))
|
2721 |
+
);
|
2722 |
+
} catch (err) {
|
2723 |
+
const error = coalesce_to_error(err);
|
2724 |
+
|
2725 |
+
options.handle_error(error, event);
|
2726 |
+
|
2727 |
+
return await respond_with_error({
|
2728 |
+
event,
|
2729 |
+
options,
|
2730 |
+
state,
|
2731 |
+
$session,
|
2732 |
+
status: 500,
|
2733 |
+
error,
|
2734 |
+
resolve_opts
|
2735 |
+
});
|
2736 |
+
}
|
2737 |
+
|
2738 |
+
// the leaf node will be present. only layouts may be undefined
|
2739 |
+
const leaf = /** @type {SSRNode} */ (nodes[nodes.length - 1]).module;
|
2740 |
+
|
2741 |
+
let page_config = get_page_config(leaf, options);
|
2742 |
+
|
2743 |
+
if (state.prerendering) {
|
2744 |
+
// if the page isn't marked as prerenderable (or is explicitly
|
2745 |
+
// marked NOT prerenderable, if `prerender.default` is `true`),
|
2746 |
+
// then bail out at this point
|
2747 |
+
const should_prerender = leaf.prerender ?? options.prerender.default;
|
2748 |
+
if (!should_prerender) {
|
2749 |
+
return new Response(undefined, {
|
2750 |
+
status: 204
|
2751 |
+
});
|
2752 |
+
}
|
2753 |
+
}
|
2754 |
+
|
2755 |
+
/** @type {Array<Loaded>} */
|
2756 |
+
let branch = [];
|
2757 |
+
|
2758 |
+
/** @type {number} */
|
2759 |
+
let status = 200;
|
2760 |
+
|
2761 |
+
/** @type {Error | null} */
|
2762 |
+
let error = null;
|
2763 |
+
|
2764 |
+
/** @type {string[]} */
|
2765 |
+
let set_cookie_headers = [];
|
2766 |
+
|
2767 |
+
let stuff = {};
|
2768 |
+
|
2769 |
+
ssr: {
|
2770 |
+
for (let i = 0; i < nodes.length; i += 1) {
|
2771 |
+
const node = nodes[i];
|
2772 |
+
|
2773 |
+
/** @type {Loaded | undefined} */
|
2774 |
+
let loaded;
|
2775 |
+
|
2776 |
+
if (node) {
|
2777 |
+
try {
|
2778 |
+
loaded = await load_node({
|
2779 |
+
...opts,
|
2780 |
+
node,
|
2781 |
+
stuff,
|
2782 |
+
is_error: false,
|
2783 |
+
is_leaf: i === nodes.length - 1
|
2784 |
+
});
|
2785 |
+
|
2786 |
+
set_cookie_headers = set_cookie_headers.concat(loaded.set_cookie_headers);
|
2787 |
+
|
2788 |
+
if (loaded.loaded.redirect) {
|
2789 |
+
return with_cookies(
|
2790 |
+
new Response(undefined, {
|
2791 |
+
status: loaded.loaded.status,
|
2792 |
+
headers: {
|
2793 |
+
location: loaded.loaded.redirect
|
2794 |
+
}
|
2795 |
+
}),
|
2796 |
+
set_cookie_headers
|
2797 |
+
);
|
2798 |
+
}
|
2799 |
+
|
2800 |
+
if (loaded.loaded.error) {
|
2801 |
+
({ status, error } = loaded.loaded);
|
2802 |
+
}
|
2803 |
+
} catch (err) {
|
2804 |
+
const e = coalesce_to_error(err);
|
2805 |
+
|
2806 |
+
options.handle_error(e, event);
|
2807 |
+
|
2808 |
+
status = 500;
|
2809 |
+
error = e;
|
2810 |
+
}
|
2811 |
+
|
2812 |
+
if (loaded && !error) {
|
2813 |
+
branch.push(loaded);
|
2814 |
+
}
|
2815 |
+
|
2816 |
+
if (error) {
|
2817 |
+
while (i--) {
|
2818 |
+
if (route.b[i]) {
|
2819 |
+
const index = /** @type {number} */ (route.b[i]);
|
2820 |
+
const error_node = await options.manifest._.nodes[index]();
|
2821 |
+
|
2822 |
+
/** @type {Loaded} */
|
2823 |
+
let node_loaded;
|
2824 |
+
let j = i;
|
2825 |
+
while (!(node_loaded = branch[j])) {
|
2826 |
+
j -= 1;
|
2827 |
+
}
|
2828 |
+
|
2829 |
+
try {
|
2830 |
+
const error_loaded = /** @type {import('./types').Loaded} */ (
|
2831 |
+
await load_node({
|
2832 |
+
...opts,
|
2833 |
+
node: error_node,
|
2834 |
+
stuff: node_loaded.stuff,
|
2835 |
+
is_error: true,
|
2836 |
+
is_leaf: false,
|
2837 |
+
status,
|
2838 |
+
error
|
2839 |
+
})
|
2840 |
+
);
|
2841 |
+
|
2842 |
+
if (error_loaded.loaded.error) {
|
2843 |
+
continue;
|
2844 |
+
}
|
2845 |
+
|
2846 |
+
page_config = get_page_config(error_node.module, options);
|
2847 |
+
branch = branch.slice(0, j + 1).concat(error_loaded);
|
2848 |
+
stuff = { ...node_loaded.stuff, ...error_loaded.stuff };
|
2849 |
+
break ssr;
|
2850 |
+
} catch (err) {
|
2851 |
+
const e = coalesce_to_error(err);
|
2852 |
+
|
2853 |
+
options.handle_error(e, event);
|
2854 |
+
|
2855 |
+
continue;
|
2856 |
+
}
|
2857 |
+
}
|
2858 |
+
}
|
2859 |
+
|
2860 |
+
// TODO backtrack until we find an __error.svelte component
|
2861 |
+
// that we can use as the leaf node
|
2862 |
+
// for now just return regular error page
|
2863 |
+
return with_cookies(
|
2864 |
+
await respond_with_error({
|
2865 |
+
event,
|
2866 |
+
options,
|
2867 |
+
state,
|
2868 |
+
$session,
|
2869 |
+
status,
|
2870 |
+
error,
|
2871 |
+
resolve_opts
|
2872 |
+
}),
|
2873 |
+
set_cookie_headers
|
2874 |
+
);
|
2875 |
+
}
|
2876 |
+
}
|
2877 |
+
|
2878 |
+
if (loaded && loaded.loaded.stuff) {
|
2879 |
+
stuff = {
|
2880 |
+
...stuff,
|
2881 |
+
...loaded.loaded.stuff
|
2882 |
+
};
|
2883 |
+
}
|
2884 |
+
}
|
2885 |
+
}
|
2886 |
+
|
2887 |
+
try {
|
2888 |
+
return with_cookies(
|
2889 |
+
await render_response({
|
2890 |
+
...opts,
|
2891 |
+
stuff,
|
2892 |
+
event,
|
2893 |
+
page_config,
|
2894 |
+
status,
|
2895 |
+
error,
|
2896 |
+
branch: branch.filter(Boolean)
|
2897 |
+
}),
|
2898 |
+
set_cookie_headers
|
2899 |
+
);
|
2900 |
+
} catch (err) {
|
2901 |
+
const error = coalesce_to_error(err);
|
2902 |
+
|
2903 |
+
options.handle_error(error, event);
|
2904 |
+
|
2905 |
+
return with_cookies(
|
2906 |
+
await respond_with_error({
|
2907 |
+
...opts,
|
2908 |
+
status: 500,
|
2909 |
+
error
|
2910 |
+
}),
|
2911 |
+
set_cookie_headers
|
2912 |
+
);
|
2913 |
+
}
|
2914 |
+
}
|
2915 |
+
|
2916 |
+
/**
|
2917 |
+
* @param {import('types').SSRComponent} leaf
|
2918 |
+
* @param {SSROptions} options
|
2919 |
+
*/
|
2920 |
+
function get_page_config(leaf, options) {
|
2921 |
+
// TODO remove for 1.0
|
2922 |
+
if ('ssr' in leaf) {
|
2923 |
+
throw new Error(
|
2924 |
+
'`export const ssr` has been removed — use the handle hook instead: https://kit.svelte.dev/docs/hooks#handle'
|
2925 |
+
);
|
2926 |
+
}
|
2927 |
+
|
2928 |
+
return {
|
2929 |
+
router: 'router' in leaf ? !!leaf.router : options.router,
|
2930 |
+
hydrate: 'hydrate' in leaf ? !!leaf.hydrate : options.hydrate
|
2931 |
+
};
|
2932 |
+
}
|
2933 |
+
|
2934 |
+
/**
|
2935 |
+
* @param {Response} response
|
2936 |
+
* @param {string[]} set_cookie_headers
|
2937 |
+
*/
|
2938 |
+
function with_cookies(response, set_cookie_headers) {
|
2939 |
+
if (set_cookie_headers.length) {
|
2940 |
+
set_cookie_headers.forEach((value) => {
|
2941 |
+
response.headers.append('set-cookie', value);
|
2942 |
+
});
|
2943 |
+
}
|
2944 |
+
return response;
|
2945 |
+
}
|
2946 |
+
|
2947 |
+
/**
|
2948 |
+
* @param {import('types').RequestEvent} event
|
2949 |
+
* @param {import('types').SSRPage} route
|
2950 |
+
* @param {import('types').SSROptions} options
|
2951 |
+
* @param {import('types').SSRState} state
|
2952 |
+
* @param {import('types').RequiredResolveOptions} resolve_opts
|
2953 |
+
* @returns {Promise<Response>}
|
2954 |
+
*/
|
2955 |
+
async function render_page(event, route, options, state, resolve_opts) {
|
2956 |
+
if (state.initiator === route) {
|
2957 |
+
// infinite request cycle detected
|
2958 |
+
return new Response(`Not found: ${event.url.pathname}`, {
|
2959 |
+
status: 404
|
2960 |
+
});
|
2961 |
+
}
|
2962 |
+
|
2963 |
+
if (route.shadow) {
|
2964 |
+
const type = negotiate(event.request.headers.get('accept') || 'text/html', [
|
2965 |
+
'text/html',
|
2966 |
+
'application/json'
|
2967 |
+
]);
|
2968 |
+
|
2969 |
+
if (type === 'application/json') {
|
2970 |
+
return render_endpoint(event, await route.shadow());
|
2971 |
+
}
|
2972 |
+
}
|
2973 |
+
|
2974 |
+
const $session = await options.hooks.getSession(event);
|
2975 |
+
|
2976 |
+
return respond$1({
|
2977 |
+
event,
|
2978 |
+
options,
|
2979 |
+
state,
|
2980 |
+
$session,
|
2981 |
+
resolve_opts,
|
2982 |
+
route
|
2983 |
+
});
|
2984 |
+
}
|
2985 |
+
|
2986 |
+
/**
|
2987 |
+
* @param {string} accept
|
2988 |
+
* @param {string[]} types
|
2989 |
+
*/
|
2990 |
+
function negotiate(accept, types) {
|
2991 |
+
const parts = accept
|
2992 |
+
.split(',')
|
2993 |
+
.map((str, i) => {
|
2994 |
+
const match = /([^/]+)\/([^;]+)(?:;q=([0-9.]+))?/.exec(str);
|
2995 |
+
if (match) {
|
2996 |
+
const [, type, subtype, q = '1'] = match;
|
2997 |
+
return { type, subtype, q: +q, i };
|
2998 |
+
}
|
2999 |
+
|
3000 |
+
throw new Error(`Invalid Accept header: ${accept}`);
|
3001 |
+
})
|
3002 |
+
.sort((a, b) => {
|
3003 |
+
if (a.q !== b.q) {
|
3004 |
+
return b.q - a.q;
|
3005 |
+
}
|
3006 |
+
|
3007 |
+
if ((a.subtype === '*') !== (b.subtype === '*')) {
|
3008 |
+
return a.subtype === '*' ? 1 : -1;
|
3009 |
+
}
|
3010 |
+
|
3011 |
+
if ((a.type === '*') !== (b.type === '*')) {
|
3012 |
+
return a.type === '*' ? 1 : -1;
|
3013 |
+
}
|
3014 |
+
|
3015 |
+
return a.i - b.i;
|
3016 |
+
});
|
3017 |
+
|
3018 |
+
let accepted;
|
3019 |
+
let min_priority = Infinity;
|
3020 |
+
|
3021 |
+
for (const mimetype of types) {
|
3022 |
+
const [type, subtype] = mimetype.split('/');
|
3023 |
+
const priority = parts.findIndex(
|
3024 |
+
(part) =>
|
3025 |
+
(part.type === type || part.type === '*') &&
|
3026 |
+
(part.subtype === subtype || part.subtype === '*')
|
3027 |
+
);
|
3028 |
+
|
3029 |
+
if (priority !== -1 && priority < min_priority) {
|
3030 |
+
accepted = mimetype;
|
3031 |
+
min_priority = priority;
|
3032 |
+
}
|
3033 |
+
}
|
3034 |
+
|
3035 |
+
return accepted;
|
3036 |
+
}
|
3037 |
+
|
3038 |
+
/**
|
3039 |
+
* @param {RegExpMatchArray} match
|
3040 |
+
* @param {string[]} names
|
3041 |
+
* @param {string[]} types
|
3042 |
+
* @param {Record<string, import('types').ParamMatcher>} matchers
|
3043 |
+
*/
|
3044 |
+
function exec(match, names, types, matchers) {
|
3045 |
+
/** @type {Record<string, string>} */
|
3046 |
+
const params = {};
|
3047 |
+
|
3048 |
+
for (let i = 0; i < names.length; i += 1) {
|
3049 |
+
const name = names[i];
|
3050 |
+
const type = types[i];
|
3051 |
+
const value = match[i + 1] || '';
|
3052 |
+
|
3053 |
+
if (type) {
|
3054 |
+
const matcher = matchers[type];
|
3055 |
+
if (!matcher) throw new Error(`Missing "${type}" param matcher`); // TODO do this ahead of time?
|
3056 |
+
|
3057 |
+
if (!matcher(value)) return;
|
3058 |
+
}
|
3059 |
+
|
3060 |
+
params[name] = value;
|
3061 |
+
}
|
3062 |
+
|
3063 |
+
return params;
|
3064 |
+
}
|
3065 |
+
|
3066 |
+
const DATA_SUFFIX = '/__data.json';
|
3067 |
+
|
3068 |
+
/** @param {{ html: string }} opts */
|
3069 |
+
const default_transform = ({ html }) => html;
|
3070 |
+
|
3071 |
+
/** @type {import('types').Respond} */
|
3072 |
+
async function respond(request, options, state) {
|
3073 |
+
let url = new URL(request.url);
|
3074 |
+
|
3075 |
+
const { parameter, allowed } = options.method_override;
|
3076 |
+
const method_override = url.searchParams.get(parameter)?.toUpperCase();
|
3077 |
+
|
3078 |
+
if (method_override) {
|
3079 |
+
if (request.method === 'POST') {
|
3080 |
+
if (allowed.includes(method_override)) {
|
3081 |
+
request = new Proxy(request, {
|
3082 |
+
get: (target, property, _receiver) => {
|
3083 |
+
if (property === 'method') return method_override;
|
3084 |
+
return Reflect.get(target, property, target);
|
3085 |
+
}
|
3086 |
+
});
|
3087 |
+
} else {
|
3088 |
+
const verb = allowed.length === 0 ? 'enabled' : 'allowed';
|
3089 |
+
const body = `${parameter}=${method_override} is not ${verb}. See https://kit.svelte.dev/docs/configuration#methodoverride`;
|
3090 |
+
|
3091 |
+
return new Response(body, {
|
3092 |
+
status: 400
|
3093 |
+
});
|
3094 |
+
}
|
3095 |
+
} else {
|
3096 |
+
throw new Error(`${parameter}=${method_override} is only allowed with POST requests`);
|
3097 |
+
}
|
3098 |
+
}
|
3099 |
+
|
3100 |
+
let decoded;
|
3101 |
+
try {
|
3102 |
+
decoded = decodeURI(url.pathname);
|
3103 |
+
} catch {
|
3104 |
+
return new Response('Malformed URI', { status: 400 });
|
3105 |
+
}
|
3106 |
+
|
3107 |
+
/** @type {import('types').SSRRoute | null} */
|
3108 |
+
let route = null;
|
3109 |
+
|
3110 |
+
/** @type {Record<string, string>} */
|
3111 |
+
let params = {};
|
3112 |
+
|
3113 |
+
if (options.paths.base && !state.prerendering?.fallback) {
|
3114 |
+
if (!decoded.startsWith(options.paths.base)) {
|
3115 |
+
return new Response('Not found', { status: 404 });
|
3116 |
+
}
|
3117 |
+
decoded = decoded.slice(options.paths.base.length) || '/';
|
3118 |
+
}
|
3119 |
+
|
3120 |
+
const is_data_request = decoded.endsWith(DATA_SUFFIX);
|
3121 |
+
|
3122 |
+
if (is_data_request) {
|
3123 |
+
const data_suffix_length = DATA_SUFFIX.length - (options.trailing_slash === 'always' ? 1 : 0);
|
3124 |
+
decoded = decoded.slice(0, -data_suffix_length) || '/';
|
3125 |
+
url = new URL(url.origin + url.pathname.slice(0, -data_suffix_length) + url.search);
|
3126 |
+
}
|
3127 |
+
|
3128 |
+
if (!state.prerendering?.fallback) {
|
3129 |
+
const matchers = await options.manifest._.matchers();
|
3130 |
+
|
3131 |
+
for (const candidate of options.manifest._.routes) {
|
3132 |
+
const match = candidate.pattern.exec(decoded);
|
3133 |
+
if (!match) continue;
|
3134 |
+
|
3135 |
+
const matched = exec(match, candidate.names, candidate.types, matchers);
|
3136 |
+
if (matched) {
|
3137 |
+
route = candidate;
|
3138 |
+
params = decode_params(matched);
|
3139 |
+
break;
|
3140 |
+
}
|
3141 |
+
}
|
3142 |
+
}
|
3143 |
+
|
3144 |
+
if (route) {
|
3145 |
+
if (route.type === 'page') {
|
3146 |
+
const normalized = normalize_path(url.pathname, options.trailing_slash);
|
3147 |
+
|
3148 |
+
if (normalized !== url.pathname && !state.prerendering?.fallback) {
|
3149 |
+
return new Response(undefined, {
|
3150 |
+
status: 301,
|
3151 |
+
headers: {
|
3152 |
+
'x-sveltekit-normalize': '1',
|
3153 |
+
location:
|
3154 |
+
// ensure paths starting with '//' are not treated as protocol-relative
|
3155 |
+
(normalized.startsWith('//') ? url.origin + normalized : normalized) +
|
3156 |
+
(url.search === '?' ? '' : url.search)
|
3157 |
+
}
|
3158 |
+
});
|
3159 |
+
}
|
3160 |
+
} else if (is_data_request) {
|
3161 |
+
// requesting /__data.json should fail for a standalone endpoint
|
3162 |
+
return new Response(undefined, {
|
3163 |
+
status: 404
|
3164 |
+
});
|
3165 |
+
}
|
3166 |
+
}
|
3167 |
+
|
3168 |
+
/** @type {import('types').RequestEvent} */
|
3169 |
+
const event = {
|
3170 |
+
get clientAddress() {
|
3171 |
+
if (!state.getClientAddress) {
|
3172 |
+
throw new Error(
|
3173 |
+
`${
|
3174 |
+
import.meta.env.VITE_SVELTEKIT_ADAPTER_NAME
|
3175 |
+
} does not specify getClientAddress. Please raise an issue`
|
3176 |
+
);
|
3177 |
+
}
|
3178 |
+
|
3179 |
+
Object.defineProperty(event, 'clientAddress', {
|
3180 |
+
value: state.getClientAddress()
|
3181 |
+
});
|
3182 |
+
|
3183 |
+
return event.clientAddress;
|
3184 |
+
},
|
3185 |
+
locals: {},
|
3186 |
+
params,
|
3187 |
+
platform: state.platform,
|
3188 |
+
request,
|
3189 |
+
routeId: route && route.id,
|
3190 |
+
url
|
3191 |
+
};
|
3192 |
+
|
3193 |
+
// TODO remove this for 1.0
|
3194 |
+
/**
|
3195 |
+
* @param {string} property
|
3196 |
+
* @param {string} replacement
|
3197 |
+
* @param {string} suffix
|
3198 |
+
*/
|
3199 |
+
const removed = (property, replacement, suffix = '') => ({
|
3200 |
+
get: () => {
|
3201 |
+
throw new Error(`event.${property} has been replaced by event.${replacement}` + suffix);
|
3202 |
+
}
|
3203 |
+
});
|
3204 |
+
|
3205 |
+
const details = '. See https://github.com/sveltejs/kit/pull/3384 for details';
|
3206 |
+
|
3207 |
+
const body_getter = {
|
3208 |
+
get: () => {
|
3209 |
+
throw new Error(
|
3210 |
+
'To access the request body use the text/json/arrayBuffer/formData methods, e.g. `body = await request.json()`' +
|
3211 |
+
details
|
3212 |
+
);
|
3213 |
+
}
|
3214 |
+
};
|
3215 |
+
|
3216 |
+
Object.defineProperties(event, {
|
3217 |
+
method: removed('method', 'request.method', details),
|
3218 |
+
headers: removed('headers', 'request.headers', details),
|
3219 |
+
origin: removed('origin', 'url.origin'),
|
3220 |
+
path: removed('path', 'url.pathname'),
|
3221 |
+
query: removed('query', 'url.searchParams'),
|
3222 |
+
body: body_getter,
|
3223 |
+
rawBody: body_getter
|
3224 |
+
});
|
3225 |
+
|
3226 |
+
/** @type {import('types').RequiredResolveOptions} */
|
3227 |
+
let resolve_opts = {
|
3228 |
+
ssr: true,
|
3229 |
+
transformPage: default_transform
|
3230 |
+
};
|
3231 |
+
|
3232 |
+
// TODO match route before calling handle?
|
3233 |
+
|
3234 |
+
try {
|
3235 |
+
const response = await options.hooks.handle({
|
3236 |
+
event,
|
3237 |
+
resolve: async (event, opts) => {
|
3238 |
+
if (opts) {
|
3239 |
+
resolve_opts = {
|
3240 |
+
ssr: opts.ssr !== false,
|
3241 |
+
transformPage: opts.transformPage || default_transform
|
3242 |
+
};
|
3243 |
+
}
|
3244 |
+
|
3245 |
+
if (state.prerendering?.fallback) {
|
3246 |
+
return await render_response({
|
3247 |
+
event,
|
3248 |
+
options,
|
3249 |
+
state,
|
3250 |
+
$session: await options.hooks.getSession(event),
|
3251 |
+
page_config: { router: true, hydrate: true },
|
3252 |
+
stuff: {},
|
3253 |
+
status: 200,
|
3254 |
+
error: null,
|
3255 |
+
branch: [],
|
3256 |
+
resolve_opts: {
|
3257 |
+
...resolve_opts,
|
3258 |
+
ssr: false
|
3259 |
+
}
|
3260 |
+
});
|
3261 |
+
}
|
3262 |
+
|
3263 |
+
if (route) {
|
3264 |
+
/** @type {Response} */
|
3265 |
+
let response;
|
3266 |
+
|
3267 |
+
if (is_data_request && route.type === 'page' && route.shadow) {
|
3268 |
+
response = await render_endpoint(event, await route.shadow());
|
3269 |
+
|
3270 |
+
// loading data for a client-side transition is a special case
|
3271 |
+
if (request.headers.has('x-sveltekit-load')) {
|
3272 |
+
// since redirects are opaque to the browser, we need to repackage
|
3273 |
+
// 3xx responses as 200s with a custom header
|
3274 |
+
if (response.status >= 300 && response.status < 400) {
|
3275 |
+
const location = response.headers.get('location');
|
3276 |
+
|
3277 |
+
if (location) {
|
3278 |
+
const headers = new Headers(response.headers);
|
3279 |
+
headers.set('x-sveltekit-location', location);
|
3280 |
+
response = new Response(undefined, {
|
3281 |
+
status: 204,
|
3282 |
+
headers
|
3283 |
+
});
|
3284 |
+
}
|
3285 |
+
}
|
3286 |
+
}
|
3287 |
+
} else {
|
3288 |
+
response =
|
3289 |
+
route.type === 'endpoint'
|
3290 |
+
? await render_endpoint(event, await route.load())
|
3291 |
+
: await render_page(event, route, options, state, resolve_opts);
|
3292 |
+
}
|
3293 |
+
|
3294 |
+
if (response) {
|
3295 |
+
// respond with 304 if etag matches
|
3296 |
+
if (response.status === 200 && response.headers.has('etag')) {
|
3297 |
+
let if_none_match_value = request.headers.get('if-none-match');
|
3298 |
+
|
3299 |
+
// ignore W/ prefix https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match#directives
|
3300 |
+
if (if_none_match_value?.startsWith('W/"')) {
|
3301 |
+
if_none_match_value = if_none_match_value.substring(2);
|
3302 |
+
}
|
3303 |
+
|
3304 |
+
const etag = /** @type {string} */ (response.headers.get('etag'));
|
3305 |
+
|
3306 |
+
if (if_none_match_value === etag) {
|
3307 |
+
const headers = new Headers({ etag });
|
3308 |
+
|
3309 |
+
// https://datatracker.ietf.org/doc/html/rfc7232#section-4.1
|
3310 |
+
for (const key of [
|
3311 |
+
'cache-control',
|
3312 |
+
'content-location',
|
3313 |
+
'date',
|
3314 |
+
'expires',
|
3315 |
+
'vary'
|
3316 |
+
]) {
|
3317 |
+
const value = response.headers.get(key);
|
3318 |
+
if (value) headers.set(key, value);
|
3319 |
+
}
|
3320 |
+
|
3321 |
+
return new Response(undefined, {
|
3322 |
+
status: 304,
|
3323 |
+
headers
|
3324 |
+
});
|
3325 |
+
}
|
3326 |
+
}
|
3327 |
+
|
3328 |
+
return response;
|
3329 |
+
}
|
3330 |
+
}
|
3331 |
+
|
3332 |
+
// if this request came direct from the user, rather than
|
3333 |
+
// via a `fetch` in a `load`, render a 404 page
|
3334 |
+
if (!state.initiator) {
|
3335 |
+
const $session = await options.hooks.getSession(event);
|
3336 |
+
return await respond_with_error({
|
3337 |
+
event,
|
3338 |
+
options,
|
3339 |
+
state,
|
3340 |
+
$session,
|
3341 |
+
status: 404,
|
3342 |
+
error: new Error(`Not found: ${event.url.pathname}`),
|
3343 |
+
resolve_opts
|
3344 |
+
});
|
3345 |
+
}
|
3346 |
+
|
3347 |
+
if (state.prerendering) {
|
3348 |
+
return new Response('not found', { status: 404 });
|
3349 |
+
}
|
3350 |
+
|
3351 |
+
// we can't load the endpoint from our own manifest,
|
3352 |
+
// so we need to make an actual HTTP request
|
3353 |
+
return await fetch(request);
|
3354 |
+
},
|
3355 |
+
|
3356 |
+
// TODO remove for 1.0
|
3357 |
+
// @ts-expect-error
|
3358 |
+
get request() {
|
3359 |
+
throw new Error('request in handle has been replaced with event' + details);
|
3360 |
+
}
|
3361 |
+
});
|
3362 |
+
|
3363 |
+
// TODO for 1.0, change the error message to point to docs rather than PR
|
3364 |
+
if (response && !(response instanceof Response)) {
|
3365 |
+
throw new Error('handle must return a Response object' + details);
|
3366 |
+
}
|
3367 |
+
|
3368 |
+
return response;
|
3369 |
+
} catch (/** @type {unknown} */ e) {
|
3370 |
+
const error = coalesce_to_error(e);
|
3371 |
+
|
3372 |
+
options.handle_error(error, event);
|
3373 |
+
|
3374 |
+
try {
|
3375 |
+
const $session = await options.hooks.getSession(event);
|
3376 |
+
return await respond_with_error({
|
3377 |
+
event,
|
3378 |
+
options,
|
3379 |
+
state,
|
3380 |
+
$session,
|
3381 |
+
status: 500,
|
3382 |
+
error,
|
3383 |
+
resolve_opts
|
3384 |
+
});
|
3385 |
+
} catch (/** @type {unknown} */ e) {
|
3386 |
+
const error = coalesce_to_error(e);
|
3387 |
+
|
3388 |
+
return new Response(options.dev ? error.stack : error.message, {
|
3389 |
+
status: 500
|
3390 |
+
});
|
3391 |
+
}
|
3392 |
+
}
|
3393 |
+
}
|
3394 |
+
|
3395 |
+
export { respond };
|
frontend/.svelte-kit/tsconfig.json
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"baseUrl": "..",
|
4 |
+
"paths": {
|
5 |
+
"$lib": [
|
6 |
+
"src/lib"
|
7 |
+
],
|
8 |
+
"$lib/*": [
|
9 |
+
"src/lib/*"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
"rootDirs": [
|
13 |
+
"..",
|
14 |
+
"./types"
|
15 |
+
],
|
16 |
+
"importsNotUsedAsValues": "error",
|
17 |
+
"isolatedModules": true,
|
18 |
+
"preserveValueImports": true,
|
19 |
+
"lib": [
|
20 |
+
"esnext",
|
21 |
+
"DOM"
|
22 |
+
],
|
23 |
+
"moduleResolution": "node",
|
24 |
+
"module": "esnext",
|
25 |
+
"target": "esnext"
|
26 |
+
},
|
27 |
+
"include": [
|
28 |
+
"../src/**/*.js",
|
29 |
+
"../src/**/*.ts",
|
30 |
+
"../src/**/*.svelte"
|
31 |
+
],
|
32 |
+
"exclude": [
|
33 |
+
"../node_modules/**",
|
34 |
+
"./**"
|
35 |
+
]
|
36 |
+
}
|
frontend/.svelte-kit/types/src/routes/__types/__layout.d.ts
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// this file is auto-generated
|
2 |
+
import type { Load as GenericLoad } from '@sveltejs/kit';
|
3 |
+
|
4 |
+
export type Load<
|
5 |
+
InputProps extends Record<string, any> = Record<string, any>,
|
6 |
+
OutputProps extends Record<string, any> = InputProps
|
7 |
+
> = GenericLoad<{}, InputProps, OutputProps>;
|
frontend/.svelte-kit/types/src/routes/__types/index.d.ts
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// this file is auto-generated
|
2 |
+
import type { Load as GenericLoad } from '@sveltejs/kit';
|
3 |
+
|
4 |
+
export type Load<
|
5 |
+
InputProps extends Record<string, any> = Record<string, any>,
|
6 |
+
OutputProps extends Record<string, any> = InputProps
|
7 |
+
> = GenericLoad<{}, InputProps, OutputProps>;
|
frontend/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# create-svelte
|
2 |
+
|
3 |
+
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
|
4 |
+
|
5 |
+
## Creating a project
|
6 |
+
|
7 |
+
If you're seeing this, you've probably already done this step. Congrats!
|
8 |
+
|
9 |
+
```bash
|
10 |
+
# create a new project in the current directory
|
11 |
+
npm init svelte
|
12 |
+
|
13 |
+
# create a new project in my-app
|
14 |
+
npm init svelte my-app
|
15 |
+
```
|
16 |
+
|
17 |
+
## Developing
|
18 |
+
|
19 |
+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
20 |
+
|
21 |
+
```bash
|
22 |
+
npm run dev
|
23 |
+
|
24 |
+
# or start the server and open the app in a new browser tab
|
25 |
+
npm run dev -- --open
|
26 |
+
```
|
27 |
+
|
28 |
+
## Building
|
29 |
+
|
30 |
+
To create a production version of your app:
|
31 |
+
|
32 |
+
```bash
|
33 |
+
npm run build
|
34 |
+
```
|
35 |
+
|
36 |
+
You can preview the production build with `npm run preview`.
|
37 |
+
|
38 |
+
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|