commit 13f936bee9f4768d1bf690e319ec5b5f44956db2 Author: TakuyaYagam1 Date: Sun Nov 29 12:25:29 2026 +0300 chore: import MCTF services - Added all seven issued service trees without omissions. - Preserved the supplied runtime configuration, binaries, and assets. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09ee460 --- /dev/null +++ b/.gitignore @@ -0,0 +1,109 @@ +# Independent local tooling checkout +/wahrwelt-a-d-setup/ + +# Issued credentials and VPN material +*.ovpn +*.vpn +openconnect.conf +openvpn*.conf +wg*.conf +/team[0-9]*/ +vpn/ +*.age +*.age.gz +*_token.txt +*-token.txt +token.txt +tokens/ +credentials/ +secrets/ +.netrc +.pgpass +*.key +*.p12 +*.pfx +id_rsa* +id_ed25519* + +# Environment files +.env +.env.* +!.env.example +!.env.sample + +# Runtime state, databases, logs and captures +*.db +*.db-* +*.sqlite +*.sqlite-* +*.sqlite3 +*.rdb +*.aof +*.dump +*.pid +*.sock +*.log +*.pcap +*.pcapng +*.cap +volumes/ +logs/ +runtime/ + +# Downloaded and extracted archives +*.zip +*.7z +*.rar +*.tar +*.tar.gz +*.tar.bz2 +*.tar.xz +*.tgz +*.tbz2 +*.txz +archives/ +extracted/ +unpacked/ + +# Caches and local tooling +__pycache__/ +*.py[cod] +.pytest_cache/ +.ruff_cache/ +.mypy_cache/ +.cache/ +.venv/ +venv/ +node_modules/ +.npm/ +.pnpm-store/ +.yarn/cache/ +.gradle/ +.idea/ +.vscode/ +.DS_Store + +# Worktrees, coverage and build outputs +.worktrees/ +coverage/ +.coverage +htmlcov/ +**/target/ +**/build/ +**/dist/ +**/out/ +**/.next/ +**/.nuxt/ +*.tsbuildinfo + +# Issued services are committed exactly as provided, including their env files. +!braindance/** +!chrome-ledger/** +!dark-tariff/** +!delamain/** +!pamsave/** +!sondib/** +!towercore/** + +# Local operator toolkit is maintained in its own repository. +/wahrwelt-a-d-setup/ diff --git a/braindance/.dockerignore b/braindance/.dockerignore new file mode 100755 index 0000000..e20cbd3 --- /dev/null +++ b/braindance/.dockerignore @@ -0,0 +1,13 @@ +.git +.vs +out +ci +handouts +checker +exploits +*.md +**/__pycache__ +**/*.pyc +**/*.pyo +**/.venv +data diff --git a/braindance/Dockerfile b/braindance/Dockerfile new file mode 100755 index 0000000..47697e1 --- /dev/null +++ b/braindance/Dockerfile @@ -0,0 +1,16 @@ +ARG PYTHON_IMAGE=python:3.12-slim +FROM ${PYTHON_IMAGE} + +WORKDIR /app +COPY backend/requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY backend/app.py . +COPY backend/gunicorn.conf.py . +COPY frontend ./static + +RUN mkdir -p /data +ENV PORT=5000 BD_SECRET_FILE=/data/secret.bin +EXPOSE 5000 + +CMD ["gunicorn", "--config", "gunicorn.conf.py", "-w", "1", "--threads", "16", "-k", "gthread", \ + "--timeout", "30", "-b", "0.0.0.0:5000", "app:app"] diff --git a/braindance/backend/app.py b/braindance/backend/app.py new file mode 100755 index 0000000..9b9c02b --- /dev/null +++ b/braindance/backend/app.py @@ -0,0 +1,632 @@ +import base64 +import hashlib +import hmac +import heapq +from itertools import islice +from functools import lru_cache +import json +import os +import re +import secrets +import threading +import time +from flask import Flask, request, jsonify, send_from_directory, g + +app = Flask(__name__, static_folder='static', static_url_path='/static') +app.config['MAX_CONTENT_LENGTH'] = 200000 +LOCK = threading.RLock() +SAVE_LOCK = threading.Lock() +TOKENS = {} +ACTIVE = {} +OWNER_RECORDS = {} +OWNER_COLLECTIONS = {} +RAW_BYTES = 0 +COMMENT_COUNT = 0 +FOLLOW_COUNT = 0 +DIRTY = False +RETENTION_SECONDS = float(os.environ.get('RETENTION_SECONDS', '1800')) +CLEANUP_INTERVAL = float(os.environ.get('CLEANUP_INTERVAL_SECONDS', '15')) +FLAG_LIFETIME = float(os.environ.get('FLAG_LIFETIME_SECONDS', '300')) +MAX_DATA_BYTES = int(os.environ.get('MAX_DATA_BYTES', str(64 * 1024 * 1024))) +MAX_OBJECTS = int(os.environ.get('MAX_OBJECTS', '10000')) +if CLEANUP_INTERVAL <= 0 or FLAG_LIFETIME <= 0 or RETENTION_SECONDS < FLAG_LIFETIME + 2 * CLEANUP_INTERVAL: + raise ValueError('RETENTION_SECONDS must cover flag lifetime plus two cleanup intervals') +USERS = {} +RECORDS = {} +COLLECTIONS = {} +COMMENTS = {} +FOLLOWS = {} +TAG_INDEX = {} +FEED = [] +KNOWN_LAYERS = ['video', 'thermal', 'audio', 'emotion'] +PUBLIC_LAYERS = ['video', 'audio'] +PRIVATE_LAYERS = ['thermal', 'emotion'] +SLUG_RE = re.compile('^[a-z0-9_-]{1,24}$') + +def _load_secret(): + env = os.environ.get('BD_SECRET') + if env: + return env.encode() + path = os.environ.get('BD_SECRET_FILE', '/data/secret.bin') + try: + os.makedirs(os.path.dirname(path), exist_ok=True) + if os.path.exists(path): + with open(path, 'rb') as f: + return f.read() + s = secrets.token_bytes(24) + with open(path, 'wb') as f: + f.write(s) + return s + except OSError: + return secrets.token_bytes(24) +SECRET = _load_secret() + +def new_id(n=8): + return secrets.token_hex(n) + +@lru_cache(maxsize=64) +def b64(b): + return base64.b64encode(b).decode() + +def auth(): + hdr = request.headers.get('Authorization', '') + if not hdr.startswith('Bearer '): + return None + token = hdr[7:] + with LOCK: + name = TOKENS.get(token) + if name is not None and not getattr(g, 'auth_user', None): + g.auth_user = name + ACTIVE[name] = ACTIVE.get(name, 0) + 1 + USERS[name]['last_active'] = time.time() + return name + +@app.teardown_request +def release_user(error): + name = g.pop('auth_user', None) + if name: + with LOCK: + ACTIVE[name] -= 1 + if not ACTIVE[name]: + del ACTIVE[name] + +@app.after_request +def track_changes(response): + global DIRTY + if request.method in ('POST', 'PUT', 'PATCH', 'DELETE') and response.status_code < 400: + with LOCK: + DIRTY = True + return response + +def capacity_error(): + return jsonify(error='storage limit reached; retry after old data expires'), 507 + +def record_public(rec): + return {n: b64(rec['layers'][n]) for n in rec['public'] if n in rec['layers']} + +def record_full(rec): + return {n: b64(rec['layers'][n]) for n in rec['layers']} + +def record_meta(rid, rec): + return {'id': rid, 'owner': rec['owner'], 'title': rec.get('title', ''), 'tags': rec.get('tags', []), 'price': rec.get('price', 0), 'likes': rec.get('likes', 0)} + +def trailer_sig(rec_id, layer_list): + return hmac.new(SECRET, f'{rec_id}:{len(layer_list)}'.encode(), hashlib.sha256).hexdigest()[:24] + +def parse_bd(text): + metas, layers = ([], {}) + fields = {'tags': [], 'title': '', 'price': 0, 'fx': [], 'notes': []} + lines = text.replace('\r\n', '\n').split('\n') + if not lines or lines[0].strip() != 'BDv1': + raise ValueError('bad magic') + for line in lines[1:]: + line = line.rstrip() + if not line.strip(): + continue + parts = line.split(' ') + kind = parts[0] + if kind == 'META': + meta = {'owner': None, 'source': '-'} + for kv in parts[1:]: + if '=' in kv: + k, v = kv.split('=', 1) + if k in meta: + meta[k] = v + metas.append(meta) + elif kind == 'LAYER' and len(parts) >= 3: + name = parts[1] + if name in KNOWN_LAYERS: + try: + layers[name] = base64.b64decode(parts[2]) + except Exception: + raise ValueError('bad layer b64') + elif kind == 'TAG' and len(parts) >= 2: + s = parts[1].lower() + if SLUG_RE.match(s) and s not in fields['tags'] and len(fields['tags']) < 16: + fields['tags'].append(s) + elif kind == 'TITLE': + fields['title'] = ' '.join(parts[1:])[:80] + elif kind == 'PRICE' and len(parts) >= 2: + try: + fields['price'] = max(0, min(int(parts[1]), 10 ** 6)) + except ValueError: + pass + elif kind == 'FX' and len(parts) >= 2: + if len(fields['fx']) < 16: + fields['fx'].append(parts[1][:24]) + elif kind == 'NOTE': + if len(fields['notes']) < 16: + fields['notes'].append(' '.join(parts[1:])[:120]) + if not metas: + raise ValueError('no META') + return (metas, layers, fields) + +def touch_feed(name): + FEED.append(name) + del FEED[:-80] + +STATE_FILE = os.environ.get('BD_STATE_FILE', '/data/state.json') +SNAPSHOT_INTERVAL = float(os.environ.get('SNAPSHOT_INTERVAL_SECONDS', '15')) +if SNAPSHOT_INTERVAL <= 0: + raise ValueError('SNAPSHOT_INTERVAL_SECONDS must be positive') + +def _serialize_nolock(): + return { + + + 'USERS': {name: dict(user) for name, user in USERS.items()}, + 'RECORDS': {rid: dict(rec) for rid, rec in RECORDS.items()}, + 'COLLECTIONS': {cid: {**col, 'items': list(col['items'])} for cid, col in COLLECTIONS.items()}, + 'COMMENTS': {rid: list(comments) for rid, comments in COMMENTS.items()}, + 'FOLLOWS': {name: sorted(targets) for name, targets in FOLLOWS.items()}, + 'TAG_INDEX': {tag: list(ids) for tag, ids in TAG_INDEX.items()}, + 'FEED': list(FEED), + } + +def _json_value(value): + if isinstance(value, bytes): + return b64(value) + if isinstance(value, set): + return sorted(value) + raise TypeError(type(value).__name__) + +def _save_state(force=False): + global DIRTY + try: + with SAVE_LOCK: + with LOCK: + if not DIRTY and not force: + return + snapshot = _serialize_nolock() + DIRTY = False + os.makedirs(os.path.dirname(STATE_FILE) or '.', exist_ok=True) + with open(STATE_FILE + '.tmp', 'w') as f: + json.dump(snapshot, f, default=_json_value, separators=(',', ':')) + os.replace(STATE_FILE + '.tmp', STATE_FILE) + except OSError: + with LOCK: + DIRTY = True + app.logger.exception('Could not save state') + +def _load_state(): + try: + with open(STATE_FILE) as f: + data = json.load(f) + except (OSError, ValueError): + return + with LOCK: + USERS.update(data.get('USERS', {})) + for rid, r in data.get('RECORDS', {}).items(): + r['layers'] = {n: base64.b64decode(v) for n, v in r.get('layers', {}).items()} + RECORDS[rid] = r + COLLECTIONS.update(data.get('COLLECTIONS', {})) + COMMENTS.update(data.get('COMMENTS', {})) + for k, v in data.get('FOLLOWS', {}).items(): + FOLLOWS[k] = set(v) + TAG_INDEX.update(data.get('TAG_INDEX', {})) + FEED.extend(data.get('FEED', [])) + +def _rebuild_indexes(): + global RAW_BYTES, COMMENT_COUNT, FOLLOW_COUNT + now = time.time() + TOKENS.clear() + OWNER_RECORDS.clear() + OWNER_COLLECTIONS.clear() + TAG_INDEX.clear() + for name, user in USERS.items(): + user.setdefault('created', now) + user.setdefault('last_active', user['created']) + TOKENS[user['token']] = name + RAW_BYTES = 0 + for rid, rec in RECORDS.items(): + rec.setdefault('created', now) + OWNER_RECORDS.setdefault(rec['owner'], set()).add(rid) + RAW_BYTES += sum(map(len, rec['layers'].values())) + for tag in rec.get('tags', []): + TAG_INDEX.setdefault(tag, []).append(rid) + for cid, col in COLLECTIONS.items(): + col.setdefault('created', now) + OWNER_COLLECTIONS.setdefault(col['owner'], set()).add(cid) + COMMENT_COUNT = sum(map(len, COMMENTS.values())) + FOLLOW_COUNT = sum(map(len, FOLLOWS.values())) + +def _cleanup(now=None): + global DIRTY, RAW_BYTES, COMMENT_COUNT, FOLLOW_COUNT + cutoff = (time.time() if now is None else now) - RETENTION_SECONDS + with LOCK: + removed = 0 + for rid, rec in list(RECORDS.items()): + if rec['created'] > cutoff: + continue + RAW_BYTES -= sum(map(len, rec['layers'].values())) + del RECORDS[rid] + removed += 1 + for cid, col in list(COLLECTIONS.items()): + if col['created'] <= cutoff: + del COLLECTIONS[cid] + removed += 1 + else: + items = [rid for rid in col['items'] if rid in RECORDS] + removed += len(col['items']) - len(items) + col['items'] = items + for rid, comments in list(COMMENTS.items()): + kept = [c for c in comments if c['ts'] > cutoff] if rid in RECORDS else [] + removed += len(comments) - len(kept) + if kept: + COMMENTS[rid] = kept + else: + COMMENTS.pop(rid, None) + owners = {r['owner'] for r in RECORDS.values()} | {c['owner'] for c in COLLECTIONS.values()} + for name, user in list(USERS.items()): + if user['last_active'] <= cutoff and name not in owners and name not in ACTIVE: + del USERS[name] + removed += 1 + for name, targets in list(FOLLOWS.items()): + if name not in USERS: + del FOLLOWS[name] + else: + targets.intersection_update(USERS) + FEED[:] = [name for name in FEED if name in USERS][-80:] + if removed: + _rebuild_indexes() + b64.cache_clear() + DIRTY = True + app.logger.info('Cleaner removed %d expired objects', removed) + return removed + +def _snapshot_loop(): + next_save = time.monotonic() + SNAPSHOT_INTERVAL + while True: + time.sleep(CLEANUP_INTERVAL) + try: + _cleanup() + if time.monotonic() >= next_save: + _save_state() + next_save = time.monotonic() + SNAPSHOT_INTERVAL + except Exception: + app.logger.exception('Maintenance failed') + +_load_state() +_rebuild_indexes() +_cleanup() +DIRTY = True +if os.environ.get('MAINTENANCE_ENABLED', '1') == '1': + threading.Thread(target=_snapshot_loop, daemon=True).start() + +@app.route('/') +def index(): + return send_from_directory(app.static_folder, 'index.html') + +@app.route('/health') +def health(): + return 'ok' + +@app.route('/stats') +def stats(): + with LOCK: + return jsonify(users=len(USERS), records=len(RECORDS), collections=len(COLLECTIONS), tags=len(TAG_INDEX), data_bytes=RAW_BYTES, data_limit_bytes=MAX_DATA_BYTES) + +@app.route('/register', methods=['POST']) +def register(): + data = request.get_json(force=True, silent=True) or {} + name = str(data.get('username', '')).strip() + bio = str(data.get('bio', ''))[:140] + if not name or len(name) > 64 or '/' in name: + return (jsonify(error='bad username'), 400) + with LOCK: + if name in USERS: + return (jsonify(error='exists'), 409) + if len(USERS) >= MAX_OBJECTS: + return capacity_error() + token = secrets.token_urlsafe(24) + USERS[name] = {'token': token, 'bio': bio, 'created': time.time(), 'last_active': time.time()} + TOKENS[token] = name + FOLLOWS.setdefault(name, set()) + touch_feed(name) + return jsonify(username=name, token=token) + +@app.route('/me', methods=['GET']) +def me(): + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + with LOCK: + u = USERS[user] + owned = sorted(OWNER_RECORDS.get(user, set())) + return jsonify(username=user, bio=u['bio'], records=owned, following=sorted(FOLLOWS.get(user, set()))) + +@app.route('/users/', methods=['GET']) +def user_profile(name): + with LOCK: + u = USERS.get(name) + if not u: + return (jsonify(error='not found'), 404) + owned = [record_meta(rid, RECORDS[rid]) for rid in OWNER_RECORDS.get(name, set())] + return jsonify(username=name, bio=u['bio'], followers=sum((1 for f in FOLLOWS.values() if name in f)), records=owned) + +@app.route('/users//follow', methods=['POST']) +def follow(name): + global FOLLOW_COUNT + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + with LOCK: + if name not in USERS: + return (jsonify(error='not found'), 404) + targets = FOLLOWS.setdefault(user, set()) + if name not in targets: + if len(targets) >= 128 or FOLLOW_COUNT >= 20000: + return capacity_error() + targets.add(name) + FOLLOW_COUNT += 1 + return jsonify(ok=True, following=sorted(targets)) + +@app.route('/feed', methods=['GET']) +def feed(): + with LOCK: + return jsonify(recent=list(reversed(FEED[-30:]))) + +@app.route('/gallery', methods=['GET']) +def gallery(): + try: + limit = max(1, min(int(request.args.get('limit', 100)), 200)) + except ValueError: + return jsonify(error='bad limit'), 400 + before = request.args.get('before') + with LOCK: + + keys = iter(reversed(RECORDS)) + if before: + for rid in keys: + if rid == before: + break + else: + return jsonify(error='cursor expired'), 404 + ids = list(islice(keys, limit + 1)) + page = ids[:limit] + items = [record_meta(rid, RECORDS[rid]) for rid in reversed(page)] + return jsonify(records=items, next_cursor=page[-1] if len(ids) > limit else None, total=len(RECORDS)) + +@app.route('/search', methods=['GET']) +def search(): + q = request.args.get('q', '').lower() + tag = request.args.get('tag', '').lower() + with LOCK: + res = [] + for rid, r in RECORDS.items(): + if tag and tag not in r.get('tags', []): + continue + if q and q not in r.get('title', '').lower() and (q not in r['owner'].lower()): + continue + res.append(record_meta(rid, r)) + if len(res) == 50: + break + return jsonify(results=res[:50]) + +@app.route('/trending', methods=['GET']) +def trending(): + with LOCK: + ranked = heapq.nlargest(20, RECORDS.items(), key=lambda kv: kv[1].get('likes', 0)) + return jsonify(records=[record_meta(rid, r) for rid, r in ranked[:20]]) + +@app.route('/tags', methods=['GET']) +def tags(): + with LOCK: + return jsonify(tags={s: len(ids) for s, ids in TAG_INDEX.items()}) + +@app.route('/records', methods=['POST']) +def create_record(): + global RAW_BYTES + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + body = request.get_data(as_text=True) + if len(body) > 200000: + return (jsonify(error='too large'), 413) + try: + metas, own_layers, fields = parse_bd(body) + except ValueError as e: + return (jsonify(error=str(e)), 400) + with LOCK: + if len(RECORDS) >= MAX_OBJECTS or len(OWNER_RECORDS.get(user, ())) >= 128: + return capacity_error() + head = metas[0] + src = head.get('source', '-') + if src != '-': + srec = RECORDS.get(src) + if srec is None: + return (jsonify(error='source not found'), 404) + if srec['owner'] != user and (not srec['public']): + return (jsonify(error='forbidden source'), 403) + layers = {} + ref = metas[-1] + rsrc = ref.get('source', '-') + if rsrc != '-' and rsrc in RECORDS: + srec2 = RECORDS[rsrc] + if src == rsrc and srec2['owner'] != user: + inherit = {n: srec2['layers'][n] + for n in srec2['public'] if n in srec2['layers']} + else: + inherit = dict(srec2['layers']) + for n, b in inherit.items(): + layers[n] = b + for n, b in own_layers.items(): + layers[n] = b + for fx in fields['fx']: + if fx == 'grayscale' and 'video' in layers: + pass + size = sum(map(len, layers.values())) + if size > 200000 or RAW_BYTES + size > MAX_DATA_BYTES: + return capacity_error() + rid = new_id() + RECORDS[rid] = {'owner': user, 'layers': layers, 'public': list(PUBLIC_LAYERS), 'tags': fields['tags'], 'title': fields['title'], 'price': fields['price'], 'likes': 0, 'notes': fields['notes'], 'created': time.time()} + for s in fields['tags']: + TAG_INDEX.setdefault(s, []).append(rid) + OWNER_RECORDS.setdefault(user, set()).add(rid) + RAW_BYTES += size + touch_feed(user) + return jsonify(id=rid, owner=user, layers=sorted(layers.keys()), title=fields['title'], tags=fields['tags']) + +@app.route('/records/', methods=['GET']) +def get_record(rid): + user = auth() + with LOCK: + rec = RECORDS.get(rid) + if rec is None: + return (jsonify(error='not found'), 404) + layers = record_full(rec) if rec['owner'] == user else record_public(rec) + n_pub = [n for n in PUBLIC_LAYERS if n in rec['layers']] + trailer = {'layers': ','.join(n_pub), 'sig': trailer_sig(rid, n_pub)} + out = {'id': rid, 'owner': rec['owner'], 'title': rec.get('title', ''), 'tags': rec.get('tags', []), 'price': rec.get('price', 0), 'likes': rec.get('likes', 0), 'layers': layers, 'trailer': trailer} + return jsonify(out) + +@app.route('/records//like', methods=['POST']) +def like(rid): + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + with LOCK: + rec = RECORDS.get(rid) + if rec is None: + return (jsonify(error='not found'), 404) + rec['likes'] = rec.get('likes', 0) + 1 + return jsonify(ok=True, likes=rec['likes']) + +@app.route('/records//comments', methods=['GET', 'POST']) +def comments(rid): + global COMMENT_COUNT + with LOCK: + if rid not in RECORDS: + return (jsonify(error='not found'), 404) + if request.method == 'GET': + return jsonify(comments=COMMENTS.get(rid, [])) + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + data = request.get_json(force=True, silent=True) or {} + text = str(data.get('text', ''))[:200] + if len(COMMENTS.get(rid, ())) >= 100 or COMMENT_COUNT >= 20000: + return capacity_error() + COMMENTS.setdefault(rid, []).append({'user': user, 'text': text, 'ts': time.time()}) + COMMENT_COUNT += 1 + return jsonify(ok=True, count=len(COMMENTS[rid])) + +@app.route('/collections', methods=['GET', 'POST']) +def collections(): + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + if request.method == 'GET': + with LOCK: + mine = [{'id': cid, 'name': c['name'], 'items': len(c['items'])} for cid, c in COLLECTIONS.items() if c['owner'] == user] + return jsonify(collections=mine) + data = request.get_json(force=True, silent=True) or {} + name = str(data.get('name', 'untitled'))[:60] + with LOCK: + if len(COLLECTIONS) >= MAX_OBJECTS or len(OWNER_COLLECTIONS.get(user, ())) >= 32: + return capacity_error() + cid = new_id() + COLLECTIONS[cid] = {'owner': user, 'name': name, 'items': [], 'public': bool(data.get('public', True)), 'created': time.time()} + OWNER_COLLECTIONS.setdefault(user, set()).add(cid) + return jsonify(id=cid, name=name) + +@app.route('/collections//records', methods=['POST']) +def collection_add(cid): + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + data = request.get_json(force=True, silent=True) or {} + rid = str(data.get('record_id', '')) + with LOCK: + col = COLLECTIONS.get(cid) + if col is None: + return (jsonify(error='not found'), 404) + if col['owner'] != user: + return (jsonify(error='forbidden'), 403) + if rid not in RECORDS: + return (jsonify(error='no such record'), 404) + if rid not in col['items']: + if len(col['items']) >= 128: + return capacity_error() + col['items'].append(rid) + return jsonify(ok=True, items=len(col['items'])) + +@app.route('/collections/', methods=['GET']) +def collection_view(cid): + user = auth() + try: + offset = max(0, int(request.args.get('offset', 0))) + except ValueError: + return jsonify(error='bad offset'), 400 + with LOCK: + col = COLLECTIONS.get(cid) + if col is None: + return (jsonify(error='not found'), 404) + if not col['public'] and col['owner'] != user: + return (jsonify(error='private collection'), 403) + items = [] + for rid in col['items'][offset:offset + 20]: + rec = RECORDS.get(rid) + if rec is None: + continue + entry = record_meta(rid, rec) + entry['layers'] = record_full(rec) + items.append(entry) + return jsonify(id=cid, name=col['name'], owner=col['owner'], items=items, total=len(col['items']), next_offset=offset + 20 if offset + 20 < len(col['items']) else None) + +@app.route('/trailer/', methods=['GET']) +def trailer(rid): + layers_param = request.args.get('layers', '') + sig = request.args.get('sig', '') + wanted = [t for t in layers_param.split(',') if t] + with LOCK: + rec = RECORDS.get(rid) + if rec is None: + return (jsonify(error='not found'), 404) + if sig != trailer_sig(rid, wanted): + return (jsonify(error='bad signature'), 403) + out = {n: b64(rec['layers'][n]) for n in wanted if n in KNOWN_LAYERS and n in rec['layers']} + return jsonify(id=rid, layers=out) + +@app.route('/preview', methods=['POST']) +def preview(): + data = request.get_json(force=True, silent=True) or {} + tpl = str(data.get('template', ''))[:400] + title = str(data.get('title', 'untitled'))[:60] + mood = str(data.get('mood', 'neutral'))[:30] + return jsonify(preview=tpl.replace('{title}', title).replace('{mood}', mood)) + +@app.route('/flag', methods=['GET']) +def get_flag(): + user = auth() + if not user: + return (jsonify(error='unauthorized'), 401) + with LOCK: + for rid in sorted(OWNER_RECORDS.get(user, ()), key=lambda rid: RECORDS[rid]['created'], reverse=True): + r = RECORDS[rid] + if 'emotion' in r['layers']: + return jsonify(flag=r['layers']['emotion'].decode('utf-8', 'replace')) + return jsonify(flag='') + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=int(os.environ.get('PORT', '5000'))) diff --git a/braindance/backend/gunicorn.conf.py b/braindance/backend/gunicorn.conf.py new file mode 100755 index 0000000..bdb2a61 --- /dev/null +++ b/braindance/backend/gunicorn.conf.py @@ -0,0 +1,15 @@ +import sys + +worker_tmp_dir = '/tmp' +backlog = 256 +worker_connections = 256 +keepalive = 15 +graceful_timeout = 30 + + +def worker_exit(server, worker): + + for name in ('app', 'bd_app', 'bi_app'): + module = sys.modules.get(name) + if module is not None and hasattr(module, '_save_state'): + module._save_state(force=True) diff --git a/braindance/backend/requirements.txt b/braindance/backend/requirements.txt new file mode 100755 index 0000000..9ea9c8a --- /dev/null +++ b/braindance/backend/requirements.txt @@ -0,0 +1,2 @@ +Flask==3.0.3 +gunicorn==23.0.0 diff --git a/braindance/compose.yml b/braindance/compose.yml new file mode 100755 index 0000000..f4556cc --- /dev/null +++ b/braindance/compose.yml @@ -0,0 +1,39 @@ +services: + braindance: + build: . + restart: unless-stopped + init: true + cpus: "1.0" + mem_limit: 512m + memswap_limit: 512m + pids_limit: 128 + stop_grace_period: 45s + ulimits: + nofile: {soft: 1024, hard: 1024} + tmpfs: + - /tmp:size=64m,mode=1777 + logging: + driver: json-file + options: {max-size: "10m", max-file: "3"} + env_file: env + environment: + PYTHONUNBUFFERED: "1" + PYTHONDONTWRITEBYTECODE: "1" + RETENTION_SECONDS: ${RETENTION_SECONDS:-1800} + FLAG_LIFETIME_SECONDS: ${FLAG_LIFETIME_SECONDS:-300} + CLEANUP_INTERVAL_SECONDS: ${CLEANUP_INTERVAL_SECONDS:-15} + SNAPSHOT_INTERVAL_SECONDS: ${SNAPSHOT_INTERVAL_SECONDS:-15} + MAX_DATA_BYTES: ${BD_MAX_DATA_BYTES:-67108864} + ports: + - "5000:5000" + volumes: + - braindance-data:/data + healthcheck: + test: ["CMD", "python", "-c", + "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5000/health', timeout=2).close()"] + interval: 10s + timeout: 3s + start_period: 10s + retries: 3 +volumes: + braindance-data: diff --git a/braindance/env b/braindance/env new file mode 100755 index 0000000..8109808 --- /dev/null +++ b/braindance/env @@ -0,0 +1,2 @@ +PORT=5000 +BD_SECRET_FILE=/data/secret.bin diff --git a/braindance/frontend/app.js b/braindance/frontend/app.js new file mode 100755 index 0000000..93e7c74 --- /dev/null +++ b/braindance/frontend/app.js @@ -0,0 +1,643 @@ +(() => { +const LAYERS = { + video: {label:'Видео', c:'var(--cy)', hex:'#2de2e6', pub:true}, + audio: {label:'Аудио', c:'var(--gr)', hex:'#3dff9a', pub:true}, + thermal: {label:'Тепловой канал', c:'var(--or)', hex:'#ff8a2a', pub:false}, + emotion: {label:'Эмоции', c:'var(--mg)', hex:'#ff2a6d', pub:false}, +}; +const S = {token:null, user:null, view:'market', sort:'latest', tag:'', q:'', rec:null, col:null, cache:{}}; + +const $ = s => document.querySelector(s); +const $$ = s => [...document.querySelectorAll(s)]; +const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); +const short = id => String(id).slice(0, 8); +const store = { + get(k){ try { return JSON.parse(localStorage.getItem(k)); } catch(e){ return null; } }, + set(k,v){ try { v == null ? localStorage.removeItem(k) : localStorage.setItem(k, JSON.stringify(v)); } catch(e){} }, +}; + +let wireN = 0; +function wire(msg, cls){ + const l = $('#wire-l'), d = document.createElement('div'); + d.innerHTML = '' + new Date().toLocaleTimeString('ru-RU') + '' + esc(msg) + ''; + l.prepend(d); + while (l.children.length > 200) l.lastChild.remove(); + $('#wire-last').textContent = msg; + $('#wire-n').textContent = ++wireN; +} +function toast(msg, kind){ + const col = {ok:'var(--gr)', er:'var(--rd)', warn:'var(--yl)'}[kind] || 'var(--cy)'; + const lab = {ok:'готово', er:'ошибка', warn:'уведомление'}[kind] || 'информация'; + const t = document.createElement('div'); + t.className = 'toast'; t.style.setProperty('--c', col); + t.innerHTML = '' + lab + '' + esc(msg); + $('#toasts').append(t); + setTimeout(() => { t.classList.add('out'); setTimeout(() => t.remove(), 260); }, 3200); +} +$('#wire-h').onclick = () => $('#wire').classList.toggle('on'); + +function localizeError(message){ + const messages = { + 'bad username': 'Некорректный псевдоним', + 'exists': 'Псевдоним уже занят', + 'unauthorized': 'Требуется авторизация', + 'not found': 'Не найдено', + 'too large': 'Запись слишком большая', + 'bad magic': 'Неверный заголовок BDv1', + 'bad layer b64': 'Некорректные данные канала Base64', + 'no META': 'Отсутствует блок META', + 'source not found': 'Исходная запись не найдена', + 'forbidden source': 'Нет доступа к исходной записи', + 'forbidden': 'Доступ запрещён', + 'no such record': 'Запись не найдена', + 'private collection': 'Коллекция закрыта', + 'bad signature': 'Неверная подпись', + 'no such fortress': 'Крепость не найдена', + 'bad flag': 'Некорректные данные хранилища', + 'bad icebreaker': 'Некорректный ледокол', + 'bad cell': 'Некорректная ячейка', + 'bad op': 'Некорректная команда', + 'vm timeout': 'Превышено время работы виртуальной машины', + 'bad code': 'Некорректный код программы', + }; + const text = String(message); + if (text.startsWith('vm error:')) return 'Ошибка виртуальной машины'; + return messages[text] || 'Не удалось выполнить запрос'; +} + +async function api(path, opt = {}){ + const o = {method: opt.method || 'GET', headers: {}}; + if (S.token) o.headers.Authorization = 'Bearer ' + S.token; + if (opt.json !== undefined){ o.headers['Content-Type'] = 'application/json'; o.body = JSON.stringify(opt.json); } + else if (opt.body !== undefined) o.body = opt.body; + let r, j = null; + try { r = await fetch(path, o); } + catch(e){ setLink(false); wire('ОШИБКА ' + o.method + ' ' + path + ' :: нет связи', 'er'); return {ok:false, status:0, data:null}; } + try { j = await r.json(); } catch(e){} + if (j && j.error) j.error = localizeError(j.error); + if (!opt.quiet || !r.ok) wire((r.ok ? 'ПРИЁМ ' : 'ОШИБКА ') + r.status + ' ' + o.method + ' ' + path + (!r.ok && j && j.error ? ' :: ' + j.error : ''), r.ok ? '' : 'er'); + return {ok:r.ok, status:r.status, data:j}; +} +function setLink(up){ + $('#link').classList.toggle('up', up); + $('#linktx').textContent = up ? 'связь установлена' : 'нет связи'; +} + +function rng(str){ + let h = 2166136261 >>> 0; + for (const c of String(str)){ h ^= c.charCodeAt(0); h = Math.imul(h, 16777619); } + return () => { h ^= h << 13; h ^= h >>> 17; h ^= h << 5; return ((h >>> 0) % 100000) / 100000; }; +} +function paintScene(cv, id){ + const x = cv.getContext('2d'), w = cv.width, hh = cv.height, R = rng(id); + const hue = Math.floor(R()*360), hue2 = (hue + 120 + R()*120) % 360; + let g = x.createLinearGradient(0, 0, 0, hh); + g.addColorStop(0, `hsl(${hue},60%,6%)`); + g.addColorStop(.6, `hsl(${hue2},75%,${18 + R()*10}%)`); + g.addColorStop(1, `hsl(${hue},50%,4%)`); + x.fillStyle = g; x.fillRect(0, 0, w, hh); + const sx = w*(.15 + R()*.7), sy = hh*(.28 + R()*.2), sr = hh*(.1 + R()*.12); + g = x.createRadialGradient(sx, sy, 0, sx, sy, sr*3.2); + g.addColorStop(0, `hsla(${hue2},100%,72%,.95)`); g.addColorStop(.28, `hsla(${hue2},100%,55%,.4)`); g.addColorStop(1, 'transparent'); + x.fillStyle = g; x.fillRect(0, 0, w, hh); + for (let i = 0; i < 40; i++){ x.fillStyle = `rgba(255,255,255,${R()*.5})`; x.fillRect(R()*w, R()*hh*.5, 1, 1); } + for (let L = 0; L < 3; L++){ + const base = hh*(.62 + L*.14), light = 14 - L*4; + let px = -R()*20; + while (px < w){ + const bw = w*(.035 + R()*.075), bh = hh*(.12 + R()*(.5 - L*.12)); + x.fillStyle = `hsl(${hue},35%,${light}%)`; + x.fillRect(px, base - bh, bw, hh); + if (R() > .7){ x.fillRect(px + bw*.45, base - bh - hh*.06, 1.5, hh*.06); } + if (L > 0){ + const wc = R() > .5 ? hue2 : 48; + for (let wy = base - bh + 4; wy < hh - 3; wy += 5) + for (let wx = px + 3; wx < px + bw - 3; wx += 4) + if (R() > .8){ x.fillStyle = `hsla(${wc},100%,${60 + R()*25}%,${.35 + R()*.5})`; x.fillRect(wx, wy, 1.6, 2); } + } + if (L === 2 && R() > .82){ + const sc = R() > .5 ? '#ff2a6d' : '#2de2e6'; + x.fillStyle = sc; x.shadowColor = sc; x.shadowBlur = 8; + x.fillRect(px + 2, base - bh + 6, Math.max(3, bw*.3), hh*.12); + x.shadowBlur = 0; + } + px += bw + R()*3; + } + } + x.fillStyle = 'rgba(0,0,0,.28)'; + for (let y = 0; y < hh; y += 3) x.fillRect(0, y, w, 1); +} +function avatar(name){ + const R = rng('av:' + name), hue = Math.floor(R()*360), c1 = `hsl(${hue},90%,60%)`, c2 = `hsl(${(hue+160)%360},90%,60%)`; + let cells = ''; + for (let y = 0; y < 5; y++) for (let x = 0; x < 3; x++){ + if (R() > .5){ + const col = R() > .3 ? c1 : c2; + cells += ``; + if (x < 2) cells += ``; + } + } + return `${cells}`; +} +function b64bytes(b){ try { const s = atob(b), a = new Uint8Array(s.length); for (let i = 0; i < s.length; i++) a[i] = s.charCodeAt(i); return a; } catch(e){ return new Uint8Array(); } } +function bytesText(a){ try { return new TextDecoder('utf-8', {fatal:true}).decode(a); } catch(e){ return null; } } +function printable(a){ for (const c of a) if (c < 9 || (c > 13 && c < 32) || c === 127) return false; return true; } +function hexdump(a){ + let out = ''; + for (let i = 0; i < a.length; i += 16){ + const row = a.slice(i, i + 16); + const hx = [...row].map(v => v.toString(16).padStart(2, '0')).join(' ').padEnd(47); + const tx = [...row].map(v => v >= 32 && v < 127 ? String.fromCharCode(v) : '.').join(''); + out += '' + i.toString(16).padStart(6, '0') + ' ' + hx + ' ' + esc(tx) + '\n'; + } + return out || '(пусто)'; +} +function paintWave(cv, bytes, hex, locked){ + const r = cv.getBoundingClientRect(), dpr = window.devicePixelRatio || 1; + cv.width = Math.max(1, r.width*dpr); cv.height = Math.max(1, r.height*dpr); + const x = cv.getContext('2d'), w = cv.width, h = cv.height, mid = h/2; + x.clearRect(0, 0, w, h); + const bars = Math.floor(w / (3*dpr)); + x.fillStyle = hex; + for (let i = 0; i < bars; i++){ + let v; + if (locked) v = .05; + else if (!bytes.length) v = .03; + else { const b = bytes[Math.floor(i / bars * bytes.length)] || 0, n = bytes[(Math.floor(i / bars * bytes.length) + 1) % bytes.length] || 0; v = .12 + ((b*7 + n*3) % 97) / 97 * .8 * (0.55 + .45*Math.sin(i/7)); } + const bh = Math.max(1, v*(h - 8)); + x.globalAlpha = .45 + v*.55; + x.fillRect(i*3*dpr, mid - bh/2, 2*dpr, bh); + } + x.globalAlpha = 1; +} + +function renderChip(){ + const c = $('#opchip'); + if (S.user){ + c.innerHTML = avatar(S.user) + '
' + esc(S.user) + '
оператор
'; + c.onclick = () => go('rig'); + } else { + c.innerHTML = '
Подключиться
гость
'; + c.onclick = openAuth; + } +} +function openAuth(){ $('#au').classList.add('on'); setTimeout(() => $('#au-u').focus(), 50); } +function setSession(token, user){ + S.token = token; S.user = user; + store.set('nm.session', token ? {token, user} : null); + renderChip(); + if (S.view === 'rig') loadRig(); +} +$$('[data-at]').forEach(b => b.onclick = () => { + $$('[data-at]').forEach(x => x.classList.toggle('on', x === b)); + $('#au-new').classList.toggle('is-hidden', (b.dataset.at === 'new' ? '' : 'none') === 'none'); + $('#au-tok').classList.toggle('is-hidden', (b.dataset.at === 'tok' ? '' : 'none') === 'none'); +}); +async function register(){ + const u = $('#au-u').value.trim(); + if (!u) return toast('укажите псевдоним', 'warn'); + const r = await api('/register', {method:'POST', json:{username:u, bio:$('#au-b').value}}); + if (!r.ok) return toast(r.status === 409 ? 'псевдоним уже занят' : (r.data && r.data.error) || 'не удалось зарегистрироваться', 'er'); + setSession(r.data.token, r.data.username); + $('#au').classList.remove('on'); + toast('профиль создан: ' + r.data.username, 'ok'); +} +async function restore(tok, quiet){ + const keep = S.token; S.token = tok; + const r = await api('/me', {quiet:true}); + if (!r.ok){ S.token = keep; if (!quiet) toast('токен отклонён', 'er'); return false; } + setSession(tok, r.data.username); + if (!quiet) toast('сессия восстановлена: ' + r.data.username, 'ok'); + return true; +} +$('#au-go').onclick = register; +$('#au-u').onkeydown = $('#au-b').onkeydown = e => { if (e.key === 'Enter') register(); }; +$('#au-tgo').onclick = async () => { const t = $('#au-t').value.trim(); if (t && await restore(t)) $('#au').classList.remove('on'); }; +function needAuth(){ if (S.token) return true; toast('сначала подключитесь', 'warn'); openAuth(); return false; } + +function go(v, arg){ + const h = arg ? v + '/' + encodeURIComponent(arg) : v; + if (location.hash === '#' + h) route(); else location.hash = h; +} +function route(){ + const [v, a] = location.hash.replace(/^#/, '').split('/'); + const view = ['market','studio','vault','rig','user'].includes(v) ? v : 'market'; + S.view = view; + $$('.view').forEach(e => e.classList.toggle('on', e.id === 'v-' + view)); + $$('nav a').forEach(e => e.classList.toggle('on', e.dataset.go === view)); + $('#nav').classList.remove('open'); + window.scrollTo(0, 0); + if (view === 'market') loadMarket(); + if (view === 'studio') renderManifest(); + if (view === 'vault') loadCols(a ? decodeURIComponent(a) : null); + if (view === 'rig') loadRig(); + if (view === 'user') loadUser(decodeURIComponent(a || '')); +} +document.addEventListener('click', e => { + const g = e.target.closest('[data-go]'); + if (g){ e.preventDefault(); go(g.dataset.go); } + const c = e.target.closest('[data-close]'); + if (c) c.closest('.ov').classList.remove('on'); + const u = e.target.closest('[data-user]'); + if (u){ e.stopPropagation(); $('#pb').classList.remove('on'); go('user', u.dataset.user); } +}); +$$('.ov').forEach(o => o.addEventListener('mousedown', e => { if (e.target === o) o.classList.remove('on'); })); +document.addEventListener('keydown', e => { if (e.key === 'Escape') $$('.ov.on').forEach(o => o.classList.remove('on')); }); +$('#burger').onclick = () => $('#nav').classList.toggle('open'); +window.addEventListener('hashchange', route); + +function card(r){ + const d = document.createElement('div'); + d.className = 'card'; + d.innerHTML = + '
#' + esc(short(r.id)) + '' + + '' + (r.price ? esc(r.price) + ' эб.' : 'бесплатно') + 'BD
' + + '
' + esc(r.title || 'Без названия') + '
' + + '
@' + esc(r.owner) + '♥ ' + (r.likes|0) + '
' + + '
' + (r.tags||[]).map(t => '' + esc(t) + '').join('') + '
'; + paintScene(d.querySelector('canvas'), r.id); + d.onclick = e => { if (!e.target.closest('[data-user]')) openRecord(r.id); }; + return d; +} +function fillGrid(el, recs, emptyMsg){ + el.innerHTML = ''; + if (!recs.length){ el.innerHTML = '
Нет сигнала' + esc(emptyMsg || 'здесь пока ничего нет') + '
'; return; } + recs.forEach(r => el.append(card(r))); +} + +async function loadMarket(){ + let recs; + $('#m-more').classList.add('is-hidden'); + const filtering = S.q || S.tag; + if (filtering){ + const p = new URLSearchParams(); if (S.q) p.set('q', S.q); if (S.tag) p.set('tag', S.tag); + const r = await api('/search?' + p, {quiet:true}); recs = r.ok ? r.data.results : []; + } else if (S.sort === 'trending'){ + const r = await api('/trending', {quiet:true}); recs = r.ok ? r.data.records : []; + } else { + const r = await api('/gallery', {quiet:true}); recs = r.ok ? r.data.records.slice().reverse() : []; + $('#m-count').textContent = r.ok ? r.data.total : 0; + let cursor = r.ok ? r.data.next_cursor : null; + $('#m-more').classList.toggle('is-hidden', !cursor); + $('#m-more').onclick = async () => { + const button = $('#m-more'); button.disabled = true; + const page = await api('/gallery?before=' + encodeURIComponent(cursor)); + button.disabled = false; + if (!page.ok) return; + page.data.records.slice().reverse().forEach(record => $('#m-grid').append(card(record))); + cursor = page.data.next_cursor; + button.classList.toggle('is-hidden', !cursor); + }; + const dl = $('#s-srcs'); dl.innerHTML = ''; + recs.slice(0, 60).forEach(x => { const o = document.createElement('option'); o.value = x.id; o.label = (x.title || 'Без названия') + ' @' + x.owner; dl.append(o); }); + } + const f = $('#m-filter'); + if (filtering){ + f.classList.toggle('is-hidden', ('') === 'none'); + f.innerHTML = 'ФИЛЬТР' + + (S.q ? 'q: ' + esc(S.q) + '' : '') + + (S.tag ? '#' + esc(S.tag) + '' : '') + + '× сбросить' + recs.length + ' найдено'; + $('#m-reset').onclick = () => { S.q = ''; S.tag = ''; $('#m-q').value = ''; loadMarket(); loadTags(); }; + } else f.classList.toggle('is-hidden', ('none') === 'none'); + fillGrid($('#m-grid'), recs, filtering ? 'по вашему запросу ничего не найдено' : 'создайте первую запись'); + loadTags(); loadFeed(); +} +async function loadTags(){ + const r = await api('/tags', {quiet:true}); if (!r.ok) return; + const t = Object.entries(r.data.tags).sort((a, b) => b[1] - a[1]).slice(0, 40); + $('#m-tagn').textContent = Object.keys(r.data.tags).length; + const el = $('#m-tags'); + el.innerHTML = t.length ? '' : '—'; + t.forEach(([n, c]) => { + const s = document.createElement('span'); + s.className = 'chip' + (S.tag === n ? ' on' : ''); + s.innerHTML = esc(n) + ' ' + c + ''; + s.onclick = () => { S.tag = S.tag === n ? '' : n; loadMarket(); }; + el.append(s); + }); +} +async function loadFeed(){ + const r = await api('/feed', {quiet:true}); if (!r.ok) return; + const seen = [], el = $('#m-feed'); + r.data.recent.forEach(n => { if (!seen.includes(n)) seen.push(n); }); + el.innerHTML = seen.length ? '' : '
тишина
'; + seen.slice(0, 10).forEach((n, i) => { + const d = document.createElement('div'); + d.className = 'li'; d.dataset.user = n; + d.innerHTML = avatar(n) + '' + esc(n) + '' + (i === 0 ? 'сейчас' : '-' + i) + ''; + el.append(d); + }); +} +$$('#m-sort button').forEach(b => b.onclick = () => { + S.sort = b.dataset.s; + $$('#m-sort button').forEach(x => x.classList.toggle('on', x === b)); + loadMarket(); +}); +const runQuery = () => { S.q = $('#m-q').value.trim(); loadMarket(); }; +$('#m-go').onclick = runQuery; +$('#m-q').onkeydown = e => { if (e.key === 'Enter') runQuery(); }; + +async function tickTicker(){ + const [s, f] = await Promise.all([api('/stats', {quiet:true}), api('/feed', {quiet:true})]); + if (!s.ok){ setLink(false); return; } + setLink(true); + const parts = [ + 'ОПЕРАТОРЫ ' + s.data.users + '', + 'ЗАПИСИ ' + s.data.records + '', + 'КОЛЛЕКЦИИ ' + s.data.collections + '', + 'ТЕГИ ' + s.data.tags + '', + ]; + if (f.ok) f.data.recent.slice(0, 8).forEach(n => parts.push('СИГНАЛ › @' + esc(n) + ' в сети')); + $('#ticker').innerHTML = parts.join(''); +} + +let playT = null, playStart = 0; +function stopPlay(){ cancelAnimationFrame(playT); playT = null; $('#pb-screen').classList.remove('playing'); } +function startPlay(){ + const dur = 12000; + $('#pb-screen').classList.add('playing'); + playStart = performance.now(); + const ph = $('#pb-tracks .phead'), tr = $('#pb-tracks'); + const step = now => { + const p = ((now - playStart) % dur) / dur; + const w = tr.clientWidth - 118; + ph.style.transform = 'translateX(' + (p * w) + 'px)'; + const sec = p * dur / 1000 * 10; + $('#pb-tc').textContent = [Math.floor(sec/3600), Math.floor(sec/60)%60, Math.floor(sec)%60].map(v => String(v).padStart(2, '0')).join(':'); + playT = requestAnimationFrame(step); + }; + playT = requestAnimationFrame(step); +} +$('#pb-play').onclick = () => playT ? stopPlay() : startPlay(); + +async function openRecord(id){ + const r = await api('/records/' + encodeURIComponent(id)); + if (!r.ok) return toast('запись недоступна', 'er'); + const d = r.data; S.rec = d; + stopPlay(); + $('#pb-t').textContent = d.title || 'Без названия'; + paintScene($('#pb-cv'), d.id); + $('#pb-screen').classList.remove('thermal'); + $('#pb-hl').textContent = '#' + d.id; + $('#pb-hb').textContent = '@' + d.owner; + const own = S.user && S.user === d.owner; + $('#pb-meta').innerHTML = + '
ID
' + esc(d.id) + '
' + + '
Владелец
@' + esc(d.owner) + '' + (own ? ' вы' : '') + '
' + + '
Цена
' + (d.price ? esc(d.price) + ' эб.' : 'бесплатно') + '
'; + $('#pb-tags').innerHTML = (d.tags||[]).map(t => '#' + esc(t) + '').join(''); + $$('#pb-tags [data-tag]').forEach(c => c.onclick = () => { S.tag = c.dataset.tag; S.q = ''; $('#pb').classList.remove('on'); go('market'); loadMarket(); }); + $('#pb-likes').textContent = d.likes | 0; + $('#pb-sig').innerHTML = d.trailer ? 'трейлер · ' + esc((d.trailer.layers || '').split(',').map(n => LAYERS[n]?.label || n).join(', ') || '—') + '
подпись ' + esc(d.trailer.sig) + '' : ''; + + const layers = d.layers || {}; + const names = Object.keys(LAYERS); + const tr = $('#pb-tracks'); + tr.innerHTML = ''; + let first = null; + names.forEach(n => { + const L = LAYERS[n], has = n in layers, lock = !has && !L.pub && !own; + if (!has && !lock) return; + const bytes = has ? b64bytes(layers[n]) : new Uint8Array(); + const t = document.createElement('div'); + t.className = 'trk' + (lock ? ' lock' : ''); + t.style.setProperty('--c', L.c); + t.innerHTML = '
' + L.label + '' + (lock ? 'закрытый' : bytes.length + ' Б' + (L.pub ? '' : ' · закрытый')) + '
' + (lock ? '■ ЗАШИФРОВАНО ■' : '') + '
'; + tr.append(t); + t._paint = () => paintWave(t.querySelector('canvas'), bytes, L.hex, lock); + t.onclick = () => { + $$('#pb-tracks .trk').forEach(x => x.classList.toggle('sel', x === t)); + $('#pb-screen').classList.toggle('thermal', n === 'thermal' && !lock); + inspect(n, bytes, lock); + }; + if (!first && !lock) first = t; + }); + if (!tr.children.length) tr.innerHTML = '
no channels in this pressing
'; + const ph = document.createElement('div'); ph.className = 'phead'; tr.append(ph); + $('#pb-chn').textContent = Object.keys(layers).length + ' кан.'; + $('#pb').classList.add('on'); + requestAnimationFrame(() => { + $$('#pb-tracks .trk').forEach(t => t._paint && t._paint()); + if (first) first.click(); else $('#pb-insp').innerHTML = ''; + }); + loadComments(d.id); +} +function inspect(n, bytes, lock){ + const el = $('#pb-insp'); + el.style.setProperty('--c', LAYERS[n].c); + if (lock){ el.innerHTML = '
' + LAYERS[n].label + 'только владельцу
канал закрыт — биржа не передаёт его содержимое
'; return; } + const txt = bytesText(bytes), canText = txt !== null && printable(bytes); + let mode = canText ? 'text' : 'hex'; + const draw = () => { + el.innerHTML = '
' + LAYERS[n].label + '
' + + '
' + (mode === 'text' ? esc(txt) || '(пусто)' : hexdump(bytes)) + '
'; + el.querySelectorAll('[data-m]').forEach(b => b.onclick = () => { mode = b.dataset.m; draw(); }); + }; + draw(); +} +async function loadComments(id){ + const r = await api('/records/' + encodeURIComponent(id) + '/comments', {quiet:true}); + const el = $('#pb-cmts'); + const list = r.ok ? r.data.comments : []; + el.innerHTML = list.length ? '' : '
комментариев пока нет
'; + list.forEach(c => { + const d = document.createElement('div'); + d.className = 'cm'; + d.innerHTML = '
@' + esc(c.user) + '' + new Date(c.ts*1000).toLocaleTimeString('ru-RU') + '
' + esc(c.text) + '
'; + el.append(d); + }); + el.scrollTop = el.scrollHeight; +} +$('#pb-csend').onclick = async () => { + if (!needAuth() || !S.rec) return; + const t = $('#pb-cin').value.trim(); if (!t) return; + const r = await api('/records/' + encodeURIComponent(S.rec.id) + '/comments', {method:'POST', json:{text:t}}); + if (r.ok){ $('#pb-cin').value = ''; loadComments(S.rec.id); } +}; +$('#pb-cin').onkeydown = e => { if (e.key === 'Enter') $('#pb-csend').click(); }; +$('#pb-like').onclick = async () => { + if (!needAuth() || !S.rec) return; + const r = await api('/records/' + encodeURIComponent(S.rec.id) + '/like', {method:'POST'}); + if (r.ok){ $('#pb-likes').textContent = r.data.likes; toast('отметка «Нравится» добавлена', 'ok'); } +}; +$('#pb-remix').onclick = () => { + if (!S.rec) return; + $('#s-src').value = S.rec.id; + if (!$('#s-title').value) $('#s-title').value = (S.rec.title || 'Без названия') + ' (ремикс)'; + $('#pb').classList.remove('on'); stopPlay(); + go('studio'); +}; +$('#pb-collect').onclick = async () => { + if (!needAuth() || !S.rec) return; + const r = await api('/collections', {quiet:true}); + const el = $('#cp-list'); el.innerHTML = ''; + const cols = r.ok ? r.data.collections : []; + if (!cols.length) el.innerHTML = ''; + cols.forEach(c => { + const d = document.createElement('div'); + d.className = 'li'; + d.innerHTML = '' + esc(c.name) + '' + c.items + ' записей · ' + esc(short(c.id)) + ''; + d.onclick = async () => { + const a = await api('/collections/' + encodeURIComponent(c.id) + '/records', {method:'POST', json:{record_id:S.rec.id}}); + if (a.ok){ toast('добавлено в ' + c.name, 'ok'); $('#cp').classList.remove('on'); } + }; + el.append(d); + }); + $('#cp').classList.add('on'); +}; +window.addEventListener('resize', () => { if ($('#pb').classList.contains('on')) $$('#pb-tracks .trk').forEach(t => t._paint && t._paint()); }); +new MutationObserver(() => { if (!$('#pb').classList.contains('on')) stopPlay(); }).observe($('#pb'), {attributes:true}); + +const enc = s => { const b = new TextEncoder().encode(s); let o = ''; b.forEach(c => o += String.fromCharCode(c)); return btoa(o); }; +function buildBD(){ + const L = ['BDv1']; + const src = $('#s-src').value.trim(); + L.push('META owner=' + (S.user || 'anon') + (src ? ' source=' + src : '')); + const t = $('#s-title').value.trim(); if (t) L.push('TITLE ' + t); + $('#s-tags').value.trim().toLowerCase().split(/\s+/).filter(Boolean).forEach(x => L.push('TAG ' + x)); + const p = parseInt($('#s-price').value, 10) || 0; if (p > 0) L.push('PRICE ' + p); + ['video','audio','thermal','emotion'].forEach(n => { const v = $('#s-' + n).value; if (v) L.push('LAYER ' + n + ' ' + enc(v)); }); + return L.join('\n'); +} +function renderManifest(){ + const bd = buildBD(); + $('#s-size').textContent = new Blob([bd]).size + ' Б'; + $('#s-mani').innerHTML = bd.split('\n').map(line => { + const [k, ...rest] = line.split(' '); + if (k === 'BDv1') return '' + k + ''; + if (k === 'LAYER'){ + const b = rest[1] || ''; + return 'LAYER ' + esc(rest[0]) + ' ' + esc(b.length > 48 ? b.slice(0, 48) + '…' : b) + ''; + } + return '' + esc(k) + ' ' + esc(rest.join(' ')); + }).join('\n'); +} +$$('#v-studio .in').forEach(i => i.addEventListener('input', renderManifest)); +$('#s-clear').onclick = () => { $$('#v-studio .in').forEach(i => i.value = i.type === 'number' ? 0 : ''); renderManifest(); }; +$('#s-press').onclick = async () => { + if (!needAuth()) return; + const btn = $('#s-press'); btn.disabled = true; + const r = await api('/records', {method:'POST', body:buildBD()}); + btn.disabled = false; + if (!r.ok) return toast('не удалось создать запись: ' + ((r.data && r.data.error) || r.status), 'er'); + toast('создана запись #' + short(r.data.id) + ' · ' + (r.data.layers || []).map(n => LAYERS[n]?.label || n).join(', '), 'ok'); + wire('создана запись ' + r.data.id + ' каналы=' + (r.data.layers || []).map(n => LAYERS[n]?.label || n).join(','), 'ok'); + go('market'); + setTimeout(() => openRecord(r.data.id), 120); +}; + +async function loadCols(open){ + const el = $('#c-list'); + if (!S.token){ el.innerHTML = '
подключитесь для управления коллекциями
'; $('#c-n').textContent = 0; if (open) openCol(open); return; } + const r = await api('/collections', {quiet:true}); + const cols = r.ok ? r.data.collections : []; + $('#c-n').textContent = cols.length; + el.innerHTML = cols.length ? '' : '
пока нет
'; + cols.forEach(c => { + const d = document.createElement('div'); + d.className = 'li' + (S.col === c.id ? ' sel' : ''); + d.dataset.id = c.id; + d.innerHTML = '' + esc(c.name) + '' + c.items + ''; + d.onclick = () => go('vault', c.id); + el.append(d); + }); + if (open) openCol(open); +} +async function openCol(cid){ + const r = await api('/collections/' + encodeURIComponent(cid)); + if (!r.ok){ toast(r.status === 403 ? 'коллекция закрыта' : 'коллекция не найдена', 'er'); return; } + const d = r.data; S.col = d.id; + $$('#c-list .li').forEach(x => x.classList.toggle('sel', x.dataset.id === d.id)); + $('#c-title').textContent = d.name; + $('#c-meta').innerHTML = esc(short(d.id)) + ' · @' + esc(d.owner) + ' · ' + d.total + ' записей'; + $('#c-addrow').classList.toggle('is-hidden', (S.user === d.owner ? '' : 'none') === 'none'); + fillGrid($('#c-grid'), d.items, 'коллекция пуста'); + let offset = d.next_offset; + $('#c-more').classList.toggle('is-hidden', offset === null); + $('#c-more').onclick = async () => { + const button = $('#c-more'); button.disabled = true; + const page = await api('/collections/' + encodeURIComponent(cid) + '?offset=' + offset); + button.disabled = false; + if (!page.ok) return; + page.data.items.forEach(record => $('#c-grid').append(card(record))); + offset = page.data.next_offset; + button.classList.toggle('is-hidden', offset === null); + }; +} +$('#c-make').onclick = async () => { + if (!needAuth()) return; + const r = await api('/collections', {method:'POST', json:{name:$('#c-name').value.trim() || 'Без названия', public:$('#c-pub').checked}}); + if (r.ok){ $('#c-name').value = ''; toast('коллекция создана', 'ok'); go('vault', r.data.id); } +}; +$('#c-open').onclick = () => { const v = $('#c-open-id').value.trim(); if (v) go('vault', v); }; +$('#c-addbtn').onclick = async () => { + if (!needAuth() || !S.col) return; + const v = $('#c-add').value.trim(); if (!v) return; + const r = await api('/collections/' + encodeURIComponent(S.col) + '/records', {method:'POST', json:{record_id:v}}); + if (r.ok){ $('#c-add').value = ''; toast('запись добавлена', 'ok'); openCol(S.col); loadCols(); } + else toast((r.data && r.data.error) || 'операция не удалась', 'er'); +}; + +async function loadRig(){ + if (!S.token){ + $('#rig-in').classList.toggle('is-hidden', ('none') === 'none'); + $('#rig-out').innerHTML = '
Нет нейросвязисоздайте профиль или восстановите сессию для доступа к терминалу
'; + $('#rig-auth').onclick = openAuth; + return; + } + $('#rig-out').innerHTML = ''; + $('#rig-in').classList.toggle('is-hidden', ('') === 'none'); + const me = await api('/me', {quiet:true}); + if (!me.ok){ setSession(null, null); return loadRig(); } + const u = await api('/users/' + encodeURIComponent(me.data.username), {quiet:true}); + $('#r-av').innerHTML = avatar(me.data.username); + $('#r-name').textContent = me.data.username; + $('#r-bio').textContent = me.data.bio || '— описание не указано —'; + $('#r-recs').textContent = me.data.records.length; + $('#r-fol').textContent = u.ok ? u.data.followers : 0; + $('#r-fng').textContent = me.data.following.length; + $('#r-tokv').textContent = S.token; + fillGrid($('#r-grid'), u.ok ? u.data.records.slice().reverse() : [], 'создайте первую запись в студии'); + const fl = $('#r-following'); + fl.innerHTML = me.data.following.length ? '' : '
подписок пока нет
'; + me.data.following.forEach(n => { const d = document.createElement('div'); d.className = 'li'; d.dataset.user = n; d.innerHTML = avatar(n) + '' + esc(n) + ''; fl.append(d); }); +} +$('#r-tokshow').onclick = () => { const t = $('#r-tok'); t.classList.toggle('show'); $('#r-tokshow').textContent = t.classList.contains('show') ? 'Скрыть' : 'Показать'; }; +$('#r-tokcp').onclick = async () => { try { await navigator.clipboard.writeText(S.token); toast('токен скопирован', 'ok'); } catch(e){ toast('нет доступа к буферу обмена', 'er'); } }; +$('#r-out').onclick = () => { setSession(null, null); toast('сеанс завершён', 'warn'); go('market'); }; +$('#r-pull').onclick = async () => { + const r = await api('/flag'); + const v = $('#r-vault'); + if (r.ok && r.data.flag){ v.className = 'vault'; v.textContent = r.data.flag; } + else { v.className = 'vault no'; v.textContent = 'на этом терминале нет закрытого эмоционального канала'; } +}; + +async function loadUser(name){ + const r = await api('/users/' + encodeURIComponent(name)); + if (!r.ok){ $('#u-h').textContent = 'неизвестно'; fillGrid($('#u-grid'), [], 'оператор не найден'); return; } + const d = r.data; + $('#u-h').textContent = d.username; + $('#u-av').innerHTML = avatar(d.username); + $('#u-name').textContent = d.username; + $('#u-bio').textContent = d.bio || '—'; + $('#u-fol').textContent = d.followers; + $('#u-n').textContent = d.records.length; + $('#u-follow').classList.toggle('is-hidden', (S.user === d.username ? 'none' : '') === 'none'); + $('#u-follow').onclick = async () => { + if (!needAuth()) return; + const f = await api('/users/' + encodeURIComponent(d.username) + '/follow', {method:'POST'}); + if (f.ok){ toast('вы подписались на ' + d.username, 'ok'); loadUser(d.username); } + }; + fillGrid($('#u-grid'), d.records.slice().reverse(), 'записей пока нет'); +} + +(async () => { + renderChip(); + const s = store.get('nm.session'); + if (s && s.token) await restore(s.token, true); + route(); + tickTicker(); + setInterval(tickTicker, 15000); +})(); +})(); diff --git a/braindance/frontend/index.html b/braindance/frontend/index.html new file mode 100755 index 0000000..98aaab7 --- /dev/null +++ b/braindance/frontend/index.html @@ -0,0 +1,264 @@ + + + + + +NEUROMARKET + + + + + + + + +
+
+ +
+ +
NEUROMARKET
биржа брейндансов · сектор 7
+
+ +
+ +
+
+
ЭФИР
ожидание подключения…
+
+ +
+ +
+
+

// записей в сети: 0Рынок

+
+
+ +
+
+
+ +
+ +
+ +
+
+
+ +
+

// создайте новый брейнданс BDv1Студия

+
+
+
Сессиязапись
+
+ + +
+
+
+
+
Видеооткрытый
+
Аудиооткрытый
+
Тепловой каналзакрытый
+
Эмоциизакрытый
+ + + +
+ + +
+
+
+
+
+
Манифест0 Б
+
+
+
+
Каналы
+
+ Видео и аудио доступны в каждой копии. Тепловой и эмоциональный каналы закрыты на терминале владельца — покупатели получают только открытую версию. Ремикс переносит каналы исходной записи в вашу новую запись. +
+
+
+
+
+ +
+

// подборки записейКоллекции

+
+ +
+
Коллекция не выбрана
+
+ +
Пустовыберите коллекцию слева
+ +
+
+
+
+ +
+

// консоль оператораТерминал

+
+ +
+ +
+

// досье оператора—

+
+ +
+
+
+
+ +
+
+
BD
+
+
+
+ +
● ЗАПИСЬ
+
+
+
+
00:00:00шкала времени
+
+
+
+
+
+
+
+
+ + + +
+
+
Комментарии
+
+
+
+
+
+
+ +
+
+
IDПодключиться
+
+
+ + + +
+ +
+
+ +
+
+
+Добавить в коллекцию
+
+
+
+ +
+
+
Журналприём/передача0
+
+
+ + + + diff --git a/braindance/frontend/styles.css b/braindance/frontend/styles.css new file mode 100755 index 0000000..618ba99 --- /dev/null +++ b/braindance/frontend/styles.css @@ -0,0 +1,336 @@ +:root{ + --bg:#05070c;--bg2:#090c15;--panel:#0b101b;--panel2:#0e1422;--line:#18223a;--line2:#26365a; + --cy:#2de2e6;--yl:#f3e600;--mg:#ff2a6d;--gr:#3dff9a;--rd:#ff3b4e;--or:#ff8a2a; + --tx:#c9dfee;--hi:#f2fbff;--dim:#5e7089;--dim2:#36445c; + --head:"Bahnschrift","DIN Alternate","Roboto Condensed","Arial Narrow",sans-serif; + --mono:"Cascadia Mono","JetBrains Mono",Consolas,"Liberation Mono",monospace; +} +*{box-sizing:border-box} +html,body{margin:0;min-height:100%} +body{ + background: + linear-gradient(rgba(45,226,230,.035) 1px,transparent 1px) 0 0/100% 4px, + radial-gradient(1100px 520px at 85% -8%,rgba(45,226,230,.09),transparent 60%), + radial-gradient(900px 600px at -10% 110%,rgba(255,42,109,.08),transparent 60%), + var(--bg); + background-attachment:fixed; + color:var(--tx);font:13px/1.5 var(--mono);letter-spacing:.2px;overflow-x:hidden; +} +body::after{content:"";position:fixed;inset:0;pointer-events:none;z-index:900;box-shadow:inset 0 0 160px rgba(0,0,0,.85)} +::selection{background:var(--yl);color:#000} +a{color:var(--cy);text-decoration:none} +button{font:inherit} +::-webkit-scrollbar{width:8px;height:8px} +::-webkit-scrollbar-thumb{background:var(--line2)} +::-webkit-scrollbar-track{background:#06090f} + +.top{position:sticky;top:0;z-index:50;background:rgba(5,7,12,.92);backdrop-filter:blur(6px);border-bottom:1px solid var(--line)} +.top-in{max-width:1320px;margin:0 auto;padding:0 18px;height:62px;display:flex;align-items:center;gap:26px} +.brand{display:flex;align-items:center;gap:11px;cursor:pointer;user-select:none} +.brand svg{width:34px;height:34px;flex:none} +.brand .nm{font:700 23px/1 var(--head);letter-spacing:3px;color:var(--hi);position:relative} +.brand .nm b{color:var(--yl);font-weight:700} +.brand .nm::before,.brand .nm::after{content:attr(data-t);position:absolute;inset:0;opacity:0} +.brand:hover .nm::before{opacity:.8;color:var(--mg);animation:gl1 .35s steps(2) 2} +.brand:hover .nm::after{opacity:.8;color:var(--cy);animation:gl2 .35s steps(2) 2} +@keyframes gl1{0%{clip-path:inset(0 0 60% 0);transform:translate(-3px,0)}100%{clip-path:inset(55% 0 0 0);transform:translate(2px,0)}} +@keyframes gl2{0%{clip-path:inset(40% 0 20% 0);transform:translate(3px,0)}100%{clip-path:inset(0 0 70% 0);transform:translate(-2px,0)}} +.brand .sub{font:10px/1 var(--mono);color:var(--dim);letter-spacing:2.5px;margin-top:5px;text-transform:uppercase} +nav{display:flex;gap:2px;height:100%} +nav a{display:flex;align-items:center;gap:7px;padding:0 15px;height:100%;color:var(--dim);font:600 13px var(--head);letter-spacing:2px;text-transform:uppercase;position:relative;transition:color .15s} +nav a i{font-style:normal;font:10px var(--mono);color:var(--dim2)} +nav a:hover{color:var(--tx)} +nav a.on{color:var(--yl)} +nav a.on::after{content:"";position:absolute;left:10px;right:10px;bottom:-1px;height:2px;background:var(--yl);box-shadow:0 0 10px var(--yl)} +.top .sp{flex:1} +.link{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--dim);letter-spacing:1px;text-transform:uppercase} +.link .led{width:8px;height:8px;background:var(--rd);box-shadow:0 0 8px var(--rd);transform:rotate(45deg)} +.link.up .led{background:var(--gr);box-shadow:0 0 9px var(--gr)} +.opchip{display:flex;align-items:center;gap:10px;padding:6px 12px 6px 8px;border:1px solid var(--line2);cursor:pointer;clip-path:polygon(0 0,calc(100% - 9px) 0,100% 9px,100% 100%,0 100%);transition:border-color .15s} +.opchip:hover{border-color:var(--cy)} +.opchip .av{width:26px;height:26px;flex:none} +.opchip .who{font:600 13px var(--head);letter-spacing:1.5px;color:var(--hi);text-transform:uppercase} +.opchip .rk{font-size:10px;color:var(--dim)} +.burger{display:none} + +.tick{border-bottom:1px solid var(--line);background:linear-gradient(90deg,rgba(243,230,0,.06),transparent 30%);height:26px;overflow:hidden;display:flex;align-items:center;font-size:11px} +.tick .lb{flex:none;background:var(--yl);color:#000;font:700 11px var(--head);letter-spacing:2px;padding:0 12px 0 18px;height:100%;display:flex;align-items:center;clip-path:polygon(0 0,100% 0,calc(100% - 10px) 100%,0 100%)} +.tick .rail{flex:1;overflow:hidden;white-space:nowrap;mask-image:linear-gradient(90deg,transparent,#000 4%,#000 96%,transparent)} +.tick .run{display:inline-block;padding-left:100%;animation:run 60s linear infinite} +.tick .run span{margin-right:38px;color:var(--dim)} +.tick .run b{color:var(--cy);font-weight:400} +.tick .run em{color:var(--mg);font-style:normal} +@keyframes run{to{transform:translateX(-100%)}} + +main{max-width:1320px;margin:0 auto;padding:22px 18px 90px} +.view{display:none;animation:vin .25s ease-out} +.view.on{display:block} +@keyframes vin{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}} +.vh{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-bottom:18px} +.vh h1{margin:0;font:700 30px/1 var(--head);letter-spacing:4px;text-transform:uppercase;color:var(--hi)} +.vh h1 small{display:block;font:11px var(--mono);letter-spacing:2px;color:var(--dim);margin-bottom:8px} +.vh h1 small b{color:var(--yl);font-weight:400} +.cols{display:grid;grid-template-columns:270px minmax(0,1fr);gap:20px;align-items:start} +.cols.r{grid-template-columns:minmax(0,1fr) 380px} +.cols.e{grid-template-columns:minmax(0,1fr) minmax(0,1fr)} + +.panel{background:linear-gradient(180deg,var(--panel),var(--bg2));border:1px solid var(--line);position:relative;clip-path:polygon(0 0,calc(100% - 14px) 0,100% 14px,100% 100%,14px 100%,0 calc(100% - 14px))} +.panel::before{content:"";position:absolute;top:0;left:0;width:36px;height:2px;background:var(--yl)} +.panel.c::before{background:var(--cy)} +.panel.m::before{background:var(--mg)} +.ph{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:11px 14px;border-bottom:1px solid var(--line);font:600 12px var(--head);letter-spacing:2.5px;text-transform:uppercase;color:var(--hi)} +.ph .k{font:10px var(--mono);color:var(--dim);letter-spacing:1px} +.pb{padding:14px} +.stack{display:flex;flex-direction:column;gap:20px} + +label.f{display:block;font-size:10px;letter-spacing:1.5px;text-transform:uppercase;color:var(--dim);margin:12px 0 5px} +label.f:first-child{margin-top:0} +label.f .p{float:right;color:var(--mg)} +label.f .u{float:right;color:var(--cy)} +.in,textarea.in,select.in{width:100%;background:#04060b;border:1px solid var(--line2);color:var(--hi);padding:9px 11px;font:13px var(--mono);outline:none;transition:border-color .15s,box-shadow .15s;border-radius:0} +.in::placeholder{color:var(--dim2)} +.in:focus{border-color:var(--cy);box-shadow:0 0 0 1px var(--cy),0 0 18px rgba(45,226,230,.12)} +textarea.in{resize:vertical;min-height:64px} +.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap} +.row>.g{flex:1;min-width:0} + +.btn{--c:var(--cy);display:inline-flex;align-items:center;justify-content:center;gap:8px;cursor:pointer;background:transparent;border:1px solid var(--c);color:var(--c);padding:9px 16px;font:600 12px var(--head);letter-spacing:2px;text-transform:uppercase;transition:background .12s,color .12s,box-shadow .12s;clip-path:polygon(0 0,calc(100% - 9px) 0,100% 9px,100% 100%,9px 100%,0 calc(100% - 9px));white-space:nowrap} +.btn:hover{background:var(--c);color:#000;box-shadow:0 0 16px var(--c)} +.btn:disabled{opacity:.4;pointer-events:none} +.btn.y{--c:var(--yl)}.btn.m{--c:var(--mg)}.btn.g{--c:var(--gr)}.btn.d{--c:var(--dim)} +.btn.solid{background:var(--c);color:#000} +.btn.solid:hover{filter:brightness(1.15)} +.btn.sm{padding:6px 11px;font-size:11px;letter-spacing:1.5px} +.btn.wide{width:100%} +.btn svg{width:14px;height:14px} + +.chip{display:inline-flex;align-items:center;gap:5px;font-size:10px;letter-spacing:1px;text-transform:uppercase;padding:2px 8px;border:1px solid var(--line2);color:var(--dim);cursor:pointer;transition:.12s;white-space:nowrap} +.chip:hover{color:var(--cy);border-color:var(--cy)} +.chip.on{color:#000;background:var(--cy);border-color:var(--cy)} +.chip.y{color:var(--yl);border-color:rgba(243,230,0,.4)} +.chip.m{color:var(--mg);border-color:rgba(255,42,109,.45)} +.chip b{font-weight:400;color:var(--dim2)} +.chip.on b{color:#035} +.chips{display:flex;flex-wrap:wrap;gap:6px} +.seg{display:flex;border:1px solid var(--line2)} +.seg button{flex:1;background:none;border:0;color:var(--dim);padding:7px 10px;cursor:pointer;font:600 11px var(--head);letter-spacing:1.5px;text-transform:uppercase} +.seg button+button{border-left:1px solid var(--line2)} +.seg button.on{background:var(--yl);color:#000} +.empty{padding:34px 16px;text-align:center;color:var(--dim);font-size:12px;letter-spacing:1px} +.empty b{display:block;font:600 15px var(--head);letter-spacing:3px;color:var(--dim2);margin-bottom:6px;text-transform:uppercase} +.mute{color:var(--dim)} +.kv{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;font-size:12px} +.kv dt{color:var(--dim);text-transform:uppercase;font-size:10px;letter-spacing:1.5px;padding-top:2px} +.kv dd{margin:0;color:var(--hi);word-break:break-all} + +.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(232px,1fr));gap:16px} +.card{background:var(--panel);border:1px solid var(--line);cursor:pointer;position:relative;transition:border-color .15s,transform .15s;clip-path:polygon(0 0,100% 0,100% calc(100% - 14px),calc(100% - 14px) 100%,0 100%)} +.card:hover{border-color:var(--cy);transform:translateY(-2px)} +.card:hover .th::after{opacity:1} +.th{position:relative;aspect-ratio:16/9;overflow:hidden;background:#000} +.th canvas{width:100%;height:100%;display:block} +.th::after{content:"";position:absolute;inset:0;background:linear-gradient(transparent 45%,rgba(45,226,230,.18) 50%,transparent 55%) 0 0/100% 300%;opacity:0;animation:sweep 1.6s linear infinite;transition:opacity .2s} +@keyframes sweep{from{background-position:0 100%}to{background-position:0 0}} +.th .id{position:absolute;left:8px;top:7px;font-size:10px;color:rgba(255,255,255,.7);letter-spacing:1px;text-shadow:0 0 4px #000} +.th .pr{position:absolute;right:0;top:8px;background:var(--yl);color:#000;font:700 11px var(--head);letter-spacing:1px;padding:2px 9px 2px 12px;clip-path:polygon(7px 0,100% 0,100% 100%,0 100%)} +.th .pr.free{background:var(--gr)} +.th .rec{position:absolute;left:8px;bottom:7px;display:flex;align-items:center;gap:5px;font-size:9px;letter-spacing:2px;color:#fff} +.th .rec::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--rd);box-shadow:0 0 6px var(--rd);animation:blink 1.4s steps(1) infinite} +@keyframes blink{50%{opacity:0}} +.cb{padding:10px 12px 12px} +.cb .t{font:600 15px/1.25 var(--head);letter-spacing:.8px;color:var(--hi);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} +.cb .o{font-size:11px;color:var(--mg);margin:2px 0 8px;display:flex;justify-content:space-between} +.cb .o span{color:var(--dim)} +.cb .chips{gap:4px;height:20px;overflow:hidden} +.cb .chip{font-size:9px;padding:1px 6px} + +.lst{display:flex;flex-direction:column} +.li{display:flex;align-items:center;gap:10px;padding:9px 14px;border-bottom:1px solid var(--line);cursor:pointer;transition:background .1s} +.li:last-child{border-bottom:0} +.li:hover{background:rgba(45,226,230,.05)} +.li .av{width:24px;height:24px;flex:none} +.li .nm{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--hi)} +.li .x{font-size:10px;color:var(--dim)} +.li.sel{background:rgba(243,230,0,.06);box-shadow:inset 2px 0 var(--yl)} + +.ov{position:fixed;inset:0;z-index:200;background:rgba(2,3,6,.82);backdrop-filter:blur(3px);display:none;align-items:flex-start;justify-content:center;padding:40px 16px;overflow:auto} +.ov.on{display:flex;animation:fade .18s} +@keyframes fade{from{opacity:0}} +.dlg{width:100%;max-width:1180px;background:var(--bg2);border:1px solid var(--line2);position:relative;clip-path:polygon(0 0,calc(100% - 22px) 0,100% 22px,100% 100%,22px 100%,0 calc(100% - 22px));animation:pop .22s ease-out} +.dlg.sm{max-width:440px} +@keyframes pop{from{transform:scale(.985);opacity:0}} +.dh{display:flex;align-items:center;gap:14px;padding:14px 18px;border-bottom:1px solid var(--line);background:linear-gradient(90deg,rgba(243,230,0,.07),transparent 40%)} +.dh .tag{background:var(--yl);color:#000;font:700 11px var(--head);letter-spacing:2px;padding:3px 10px} +.dh .tt{font:700 19px var(--head);letter-spacing:2px;color:var(--hi);text-transform:uppercase;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} +.x-btn{background:none;border:1px solid var(--line2);color:var(--dim);width:32px;height:32px;cursor:pointer;font-size:16px;flex:none} +.x-btn:hover{border-color:var(--mg);color:var(--mg)} +.db{display:grid;grid-template-columns:1fr 340px;gap:0} +.db>.l{padding:18px;border-right:1px solid var(--line);min-width:0} +.db>.r{padding:18px;min-width:0} +.screen{position:relative;aspect-ratio:16/8;background:#000;overflow:hidden;border:1px solid var(--line2)} +.screen canvas{width:100%;height:100%;display:block;transition:filter .3s} +.screen.thermal canvas{filter:url(#thermal) contrast(1.2)} +.screen .hud{position:absolute;inset:0;pointer-events:none;font-size:10px;letter-spacing:1.5px;color:rgba(255,255,255,.75)} +.screen .hud .c{position:absolute;width:18px;height:18px;border:2px solid var(--yl)} +.screen .hud .c.a{left:10px;top:10px;border-right:0;border-bottom:0} +.screen .hud .c.b{right:10px;top:10px;border-left:0;border-bottom:0} +.screen .hud .c.cc{left:10px;bottom:10px;border-right:0;border-top:0} +.screen .hud .c.d{right:10px;bottom:10px;border-left:0;border-top:0} +.screen .hud .tl{position:absolute;left:36px;top:13px} +.screen .hud .tr{position:absolute;right:36px;top:13px;color:var(--yl)} +.screen .hud .bl{position:absolute;left:36px;bottom:13px} +.screen .hud .scan{position:absolute;left:0;right:0;height:30%;background:linear-gradient(transparent,rgba(45,226,230,.12),transparent);animation:vscan 3.2s linear infinite} +@keyframes vscan{from{top:-30%}to{top:100%}} +.screen .play{position:absolute;inset:0;margin:auto;width:64px;height:64px;border:2px solid var(--yl);background:rgba(0,0,0,.5);cursor:pointer;display:flex;align-items:center;justify-content:center;transform:rotate(45deg);transition:.15s;pointer-events:auto} +.screen .play svg{transform:rotate(-45deg);width:24px;height:24px;fill:var(--yl)} +.screen .play:hover{background:var(--yl)} +.screen .play:hover svg{fill:#000} +.screen.playing .play{opacity:0} +.screen.playing:hover .play{opacity:1} + +.tline{margin-top:14px;border:1px solid var(--line);background:#04060b} +.tl-h{display:flex;align-items:center;gap:12px;padding:7px 10px;border-bottom:1px solid var(--line);font-size:10px;color:var(--dim);letter-spacing:1.5px;text-transform:uppercase} +.tl-h .tc{color:var(--yl);font-size:12px;letter-spacing:1px} +.tl-h .sp{flex:1} +.tracks{position:relative} +.trk{display:grid;grid-template-columns:118px 1fr;border-bottom:1px solid var(--line);cursor:pointer;height:44px} +.trk:last-child{border-bottom:0} +.trk .tn{display:flex;flex-direction:column;justify-content:center;padding:0 10px;border-right:1px solid var(--line);font:600 12px var(--head);letter-spacing:2px;text-transform:uppercase;color:var(--c)} +.trk .tn small{font:9px var(--mono);letter-spacing:1px;color:var(--dim)} +.trk .tw{position:relative;overflow:hidden} +.trk .tw canvas{width:100%;height:100%;display:block} +.trk:hover{background:rgba(255,255,255,.02)} +.trk.sel{background:rgba(255,255,255,.035);box-shadow:inset 3px 0 var(--c)} +.trk.lock .tw{background:repeating-linear-gradient(-45deg,transparent 0 6px,rgba(255,42,109,.07) 6px 12px)} +.trk.lock .tw span{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:10px;letter-spacing:3px;color:var(--mg)} +.phead{position:absolute;top:0;bottom:0;left:118px;width:2px;background:var(--yl);box-shadow:0 0 10px var(--yl);pointer-events:none;transform-origin:left} +.phead::before{content:"";position:absolute;top:-1px;left:-5px;border:6px solid transparent;border-top-color:var(--yl)} + +.insp{margin-top:14px} +.insp-h{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px} +.insp-h b{font:600 13px var(--head);letter-spacing:2px;text-transform:uppercase;color:var(--c,var(--cy))} +pre.dump{margin:0;background:#04060b;border:1px solid var(--line);padding:12px;color:var(--tx);font:12px/1.55 var(--mono);white-space:pre-wrap;word-break:break-all;max-height:220px;overflow:auto} +pre.dump .o{color:var(--dim2)} +.sig{margin-top:14px;font-size:11px;color:var(--dim);border-left:2px solid var(--line2);padding:4px 10px} +.sig b{color:var(--cy);font-weight:400} + +.acts{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin:16px 0} +.cmts{display:flex;flex-direction:column;gap:8px;max-height:240px;overflow:auto;margin-bottom:10px} +.cm{border-left:2px solid var(--line2);padding:3px 10px} +.cm .u{font-size:11px;color:var(--mg);cursor:pointer} +.cm .u span{color:var(--dim2);margin-left:6px} +.cm .tx{color:var(--tx);word-break:break-word} +.sec{font:600 11px var(--head);letter-spacing:2.5px;text-transform:uppercase;color:var(--dim);margin:18px 0 10px;display:flex;align-items:center;gap:10px} +.sec::after{content:"";flex:1;height:1px;background:var(--line)} + +.lay{border:1px solid var(--line);margin-top:10px;--c:var(--cy)} +.lay .lh{display:flex;align-items:center;justify-content:space-between;padding:7px 10px;background:#070a12;font:600 11px var(--head);letter-spacing:2px;text-transform:uppercase;color:var(--c)} +.lay .lh span{font:10px var(--mono);color:var(--dim);letter-spacing:1px} +.lay textarea{border:0;border-top:1px solid var(--line);min-height:54px} +.mani{margin:0;background:#020306;border:1px solid var(--line);padding:14px;font:12px/1.65 var(--mono);color:var(--tx);white-space:pre-wrap;word-break:break-all;min-height:280px;max-height:520px;overflow:auto} +.mani .kw{color:var(--yl)} +.mani .ar{color:var(--cy)} +.mani .b6{color:var(--dim)} +.mani .mg{color:var(--mg)} + +.idcard{display:grid;grid-template-columns:96px minmax(0,1fr);gap:16px;align-items:center} +.idcard .big{width:96px;height:96px;border:1px solid var(--line2);padding:6px} +.big svg{width:100%;height:100%;display:block} +.idcard h2{margin:0;font:700 26px/1 var(--head);letter-spacing:3px;text-transform:uppercase;color:var(--hi);word-break:break-all} +.idcard .bio{color:var(--dim);margin-top:6px;font-size:12px} +.stats{display:grid;grid-template-columns:repeat(3,1fr);border-top:1px solid var(--line);margin-top:16px} +.stats div{padding:12px 14px;border-right:1px solid var(--line)} +.stats div:last-child{border-right:0} +.stats b{display:block;font:700 24px/1 var(--head);color:var(--yl)} +.stats span{font-size:10px;letter-spacing:1.5px;text-transform:uppercase;color:var(--dim)} +.tok{display:flex;gap:8px;align-items:center;background:#04060b;border:1px solid var(--line);padding:8px 10px;font-size:12px} +.tok code{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--tx);filter:blur(4px);transition:filter .2s} +.tok.show code{filter:none} +.vault{border:1px dashed rgba(61,255,154,.5);background:rgba(61,255,154,.04);padding:14px;color:var(--gr);word-break:break-all;font-size:13px;margin-top:12px} +.vault.no{border-color:var(--line2);background:none;color:var(--dim)} + +.tabs2{display:flex;border-bottom:1px solid var(--line)} +.tabs2 button{flex:1;background:none;border:0;padding:12px;cursor:pointer;color:var(--dim);font:600 12px var(--head);letter-spacing:2px;text-transform:uppercase;border-bottom:2px solid transparent;margin-bottom:-1px} +.tabs2 button.on{color:var(--yl);border-bottom-color:var(--yl)} +.toasts{position:fixed;right:18px;top:96px;z-index:400;display:flex;flex-direction:column;gap:8px;pointer-events:none} +.toast{min-width:260px;max-width:360px;background:var(--panel2);border:1px solid var(--line2);border-left:3px solid var(--c,var(--cy));padding:10px 14px;font-size:12px;color:var(--hi);animation:tin .2s ease-out;box-shadow:0 8px 30px rgba(0,0,0,.5)} +.toast small{display:block;font:600 10px var(--head);letter-spacing:2px;text-transform:uppercase;color:var(--c,var(--cy));margin-bottom:2px} +.toast.out{animation:tout .25s forwards} +@keyframes tin{from{transform:translateX(30px);opacity:0}} +@keyframes tout{to{transform:translateX(30px);opacity:0}} +.wire{position:fixed;left:0;right:0;bottom:0;z-index:150;background:rgba(5,7,12,.97);border-top:1px solid var(--line2);transform:translateY(calc(100% - 28px));transition:transform .25s} +.wire.on{transform:none} +.wire .wh{height:28px;display:flex;align-items:center;gap:12px;padding:0 18px;cursor:pointer;font-size:10px;letter-spacing:2px;text-transform:uppercase;color:var(--dim)} +.wire .wh b{color:var(--yl);font-weight:400} +.wire .wh .last{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-transform:none;letter-spacing:.5px;color:var(--dim2)} +.wire .wl{height:180px;overflow:auto;padding:6px 18px;font-size:11px;border-top:1px solid var(--line)} +.wire .wl div{padding:1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} +.wire .wl .ts{color:var(--dim2);margin-right:10px} +.wire .wl .er{color:var(--rd)}.wire .wl .ok{color:var(--gr)}.wire .wl .in{color:var(--cy)} + +.brand .nm,nav a{white-space:nowrap} +@media(max-width:1180px){ + .top-in{gap:16px} + .brand .sub,nav a i,.link span{display:none} + nav a{padding:0 11px} +} +@media(max-width:1060px){ + .cols,.cols.r,.cols.e{grid-template-columns:minmax(0,1fr)} + .db{grid-template-columns:1fr} + .db>.l{border-right:0;border-bottom:1px solid var(--line)} +} +@media(max-width:820px){ + .top-in{gap:12px;height:56px} + .brand .sub{display:none} + nav{position:fixed;top:56px;left:0;right:0;height:auto;flex-direction:column;background:var(--bg2);border-bottom:1px solid var(--line);display:none} + nav.open{display:flex} + nav a{height:46px} + .burger{display:flex;background:none;border:1px solid var(--line2);color:var(--tx);width:36px;height:36px;align-items:center;justify-content:center;cursor:pointer} + .link span{display:none} + .opchip .rk{display:none} + .vh h1{font-size:24px} + .acts{grid-template-columns:1fr} + .ov{padding:12px 8px} +} +.svg-filter{position:absolute} +.mt-10{margin-top:10px} +.market-filter{margin-bottom:12px;} +.width-120{width:120px} +.channel-video{--c:var(--cy)} +.channel-audio{--c:var(--gr)} +.channel-thermal{--c:var(--or)} +.channel-emotion{--c:var(--mg)} +.mt-16{margin-top:16px} +.text-12{font-size:12px} +.collection-public{display:flex;align-items:center;gap:8px;cursor:pointer;margin-top:10px} +.collection-add{margin-bottom:14px} +.is-hidden{display:none!important} +.mt-12{margin-top:12px} +.profile-avatar{width:100%;aspect-ratio:1;border:1px solid var(--line2);padding:10px} +.mt-14{margin-top:14px} +.opchip .who.text-accent,.kv dd.text-accent{color:var(--yl)} +.grid-empty{grid-column:1/-1} +.filter-label{font-size:11px;letter-spacing:1px} +.text-11{font-size:11px} +.owner-badge{margin-left:6px} +.auth-empty{padding:60px 16px} +.mt-18{margin-top:18px} + +nav a{letter-spacing:1px;padding-left:11px;padding-right:11px} +.btn{letter-spacing:1px} +.trk .tn{letter-spacing:.5px} +.opchip{min-width:0;max-width:220px} +.opchip>div{min-width:0} +.opchip .who{overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +@media(max-width:600px){ + .top-in{padding:0 12px;gap:8px} + .burger{flex:none} + .brand{gap:6px;flex:none} + .brand svg{width:28px;height:28px} + .brand .nm{font-size:16px;letter-spacing:2px} + .top .sp,.top .link{display:none} + .opchip{flex:1;padding:6px;gap:6px} + .opchip .who{font-size:11px;letter-spacing:.5px} + .stats div{padding:10px 8px} + .stats span{letter-spacing:.5px} +} diff --git a/chrome-ledger/.dockerignore b/chrome-ledger/.dockerignore new file mode 100755 index 0000000..0d43cce --- /dev/null +++ b/chrome-ledger/.dockerignore @@ -0,0 +1,16 @@ +.DS_Store +._* +__pycache__ +*.py[cod] +.env +.env.* +.venv +venv +ledger_data +state +*.sqlite +*.sqlite3 +*.sqlite3-* +*.key +*.key.pem +*.log diff --git a/chrome-ledger/Dockerfile b/chrome-ledger/Dockerfile new file mode 100755 index 0000000..2e995d7 --- /dev/null +++ b/chrome-ledger/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12-slim-bookworm + +WORKDIR /app + +COPY backend/requirements.txt ./ +RUN pip install --root-user-action=ignore --no-cache-dir -r requirements.txt + +COPY backend/app ./backend/app/ +COPY run.py ./ +COPY frontend ./frontend/ + +RUN useradd --uid 10001 --user-group --no-create-home --shell /usr/sbin/nologin chrome-ledger \ + && install -d -m 0700 -o chrome-ledger -g chrome-ledger /var/lib/chrome-ledger + +USER chrome-ledger diff --git a/chrome-ledger/backend/app/api/context.py b/chrome-ledger/backend/app/api/context.py new file mode 100755 index 0000000..679b25b --- /dev/null +++ b/chrome-ledger/backend/app/api/context.py @@ -0,0 +1,5 @@ +from flask import current_app + + +def ledger(): + return current_app.extensions["ledger"] diff --git a/chrome-ledger/backend/app/api/request.py b/chrome-ledger/backend/app/api/request.py new file mode 100755 index 0000000..a30620e --- /dev/null +++ b/chrome-ledger/backend/app/api/request.py @@ -0,0 +1,8 @@ +from flask import abort, request + + +def json_object(): + payload = request.get_json(silent=True) + if not isinstance(payload, dict): + abort(400, "Expected a JSON object") + return payload diff --git a/chrome-ledger/backend/app/api/routes/auth.py b/chrome-ledger/backend/app/api/routes/auth.py new file mode 100755 index 0000000..46311e2 --- /dev/null +++ b/chrome-ledger/backend/app/api/routes/auth.py @@ -0,0 +1,68 @@ +import re +import sqlite3 + +from uuid import uuid4 +from flask import Blueprint, abort, current_app, g +from werkzeug.security import check_password_hash, generate_password_hash +from backend.app.common.utils import account_namespace, utc_now, valid_text +from backend.app.infrastructure.persistence import repositories +from backend.app.infrastructure.persistence.connection import database +from backend.app.api.request import json_object +from backend.app.api.session import owner_session, sign_in + + +USERNAME = re.compile(r"[A-Za-z0-9_-]{3,32}") +BAD_CREDENTIALS = "Invalid username or password" + + +bp = Blueprint("auth", __name__) + + +@bp.post("/register") +def register(): + payload = json_object() + username = payload.get("username") + password = payload.get("password") + if not isinstance(username, str) or not USERNAME.fullmatch(username): + abort(400, "Username must contain 3-32 ASCII letters, digits, _ or -") + if not valid_text(password, 8, 128): + abort(400, "Password must contain 8-128 ASCII characters") + user_id = str(uuid4()) + namespace = account_namespace(username) + password_hash = generate_password_hash(password, method="scrypt") + connection = database() + try: + with connection: + repositories.create_user(connection, user_id, username, namespace, password_hash, utc_now().isoformat()) + except sqlite3.IntegrityError: + abort(409, "Username is already taken") + return sign_in(user_id, username), 201 + +@bp.post("/login") +def login(): + payload = json_object() + username = payload.get("username") + password = payload.get("password") + valid_username = isinstance(username, str) and USERNAME.fullmatch(username) + valid_password = valid_text(password, 8, 128) + row = repositories.get_user_by_username(database(), username if valid_username else "") + correct = check_password_hash( + row["password_hash"] if row else current_app.extensions["ledger"].dummy_hash, + password if valid_password else "", + ) + if not correct or row is None or not valid_password: + abort(401, BAD_CREDENTIALS) + return sign_in(row["id"], row["username"]) + +@bp.get("/home/api/me") +@owner_session +def me(): + return g.user + +@bp.delete("/home/api/logout") +@owner_session +def logout(): + connection = database() + with connection: + repositories.delete_auth_session(connection, g.token_id) + return "", 204 diff --git a/chrome-ledger/backend/app/api/routes/implants.py b/chrome-ledger/backend/app/api/routes/implants.py new file mode 100755 index 0000000..89896cf --- /dev/null +++ b/chrome-ledger/backend/app/api/routes/implants.py @@ -0,0 +1,49 @@ +from flask import Blueprint, g, request, abort +from backend.app.infrastructure.persistence import repositories +from backend.app.infrastructure.persistence.connection import database +from backend.app.application import implants +from backend.app.api.request import json_object +from backend.app.api.context import ledger +from backend.app.api.session import owner_session, claimed_username + + +bp = Blueprint("implants", __name__, url_prefix="/home/api") + + +@bp.post("/register_implant") +@owner_session +def register_implant(): + return implants.register(database(), ledger(), g.user["id"], json_object()), 201 + +@bp.get("/implants") +@owner_session +def list_implants(): + return implants.list_owned(database(), g.user["id"]) + +@bp.get("/telemetry") +@owner_session +def telemetry(): + username = request.args.get("username") or g.user["username"] + if claimed_username(g.token) != username: + return {"error": "access denied"}, 403 + user = repositories.get_user_by_username(database(), username) + if user is None: + abort(404) + return implants.telemetry(database(), user["id"]) + +@bp.get("/implants/") +@owner_session +def implant_passport(implant_id): + return implants.passport(database(), ledger(), implant_id, g.user["id"]) + +@bp.route("/check_certificate//check", methods=["GET", "POST"]) +@owner_session +def check_certificate(implant_id): + payload = json_object() if request.method == "POST" else None + return implants.check_certificate(database(), ledger(), implant_id, g.user["id"], payload) + + +@bp.post("/reissue/") +@owner_session +def reissue_certificate(implant_id): + return implants.reissue(database(), ledger(), implant_id, json_object()), 200 diff --git a/chrome-ledger/backend/app/api/routes/registry.py b/chrome-ledger/backend/app/api/routes/registry.py new file mode 100755 index 0000000..75df96d --- /dev/null +++ b/chrome-ledger/backend/app/api/routes/registry.py @@ -0,0 +1,14 @@ +from flask import Blueprint +from backend.app.infrastructure.persistence.connection import database +from backend.app.application import implants +from backend.app.api.session import owner_session +from backend.app.api.context import ledger + + +bp = Blueprint("registry", __name__, url_prefix="/home/api") + + +@bp.get("/registry") +@owner_session +def registry(): + return implants.registry(database(), ledger()) diff --git a/chrome-ledger/backend/app/api/session.py b/chrome-ledger/backend/app/api/session.py new file mode 100755 index 0000000..9d2437c --- /dev/null +++ b/chrome-ledger/backend/app/api/session.py @@ -0,0 +1,66 @@ +from functools import wraps +from flask import abort, g, request +from obsigil import Obsigil, ObsigilError, generate_uuid7 + +from backend.app.api.context import ledger +from backend.app.common.constants import AUTH_AUDIENCE, AUTH_LIFETIME +from backend.app.common.utils import utc_now +from backend.app.infrastructure.persistence import repositories +from backend.app.infrastructure.persistence.connection import database + + +def sign_in(user_id, username): + now = int(utc_now().timestamp()) + expires_at = now + int(AUTH_LIFETIME.total_seconds()) + tid = generate_uuid7() + token = Obsigil.mint( + clauses={}, mandate_key=ledger().obsigil_key, tid=tid, + sub=user_id, aud=[AUTH_AUDIENCE], exp=expires_at, + manifest={"iss": AUTH_AUDIENCE, "claims": {"username": username}}, + ).token() + connection = database() + with connection: + repositories.delete_auth_session(connection, g.token_id) + repositories.create_auth_session(connection, tid, user_id, expires_at) + return {"id": user_id, "username": username, "access_token": token} + +def claimed_username(token): + claims = Obsigil(token, max_decoded_len=4096).claims() or {} + username = claims.get("username") + return username if isinstance(username, str) else None + +def load_identity(): + g.user = None + g.token = None + g.token_id = None + authorization = request.headers.get("Authorization", "").split() + if len(authorization) != 2 or authorization[0].lower() != "bearer": + return + token = authorization[1] + if len(token) > 4096: + return + now = int(utc_now().timestamp()) + try: + clauses = Obsigil( + token, keys=ledger().obsigil_key, audience=AUTH_AUDIENCE, + now=now, max_decoded_len=4096, + ).clauses() + except ObsigilError: + return + user_id = clauses.get("sub") + if not isinstance(user_id, str) or clauses.get("aud") != [AUTH_AUDIENCE]: + return + row = repositories.get_auth_user(database(), clauses["tid"], user_id, clauses["exp"], now) + if row is not None: + g.user = dict(row) + g.token = token + g.token_id = clauses["tid"] + + +def owner_session(route): + @wraps(route) + def guarded(*args, **kwargs): + if g.user is None: + abort(401, "Authentication required") + return route(*args, **kwargs) + return guarded diff --git a/chrome-ledger/backend/app/api/views.py b/chrome-ledger/backend/app/api/views.py new file mode 100755 index 0000000..97b33d8 --- /dev/null +++ b/chrome-ledger/backend/app/api/views.py @@ -0,0 +1,36 @@ +from pathlib import Path +from flask import Blueprint, abort, make_response, send_from_directory +from werkzeug.security import safe_join +from backend.app.api.context import ledger + + +bp = Blueprint("console", __name__) + + +@bp.get("/", defaults={"path": ""}) +@bp.get("/") +def console(path): + static_root = ledger().static_root + public_root = static_root / "public" + if path.startswith("src/"): + source_path = path.removeprefix("src/") + source_root = static_root / "src" + target = safe_join(str(source_root), source_path) + if target and Path(target).is_file(): + return send_from_directory(source_root, source_path) + abort(404) + target = safe_join(str(public_root), path) + if path and path != "index.html" and target and Path(target).is_file(): + return send_from_directory(public_root, path) + pages = {"", "login", "home", "home/register_implant", "home/check_certificate", "home/reissue", "home/implants", "home/registry"} + if path not in pages and not ( + (path.startswith("home/implants/") and len(path.split("/")) == 3) + or (path.startswith("home/check_certificate/") and len(path.split("/")) == 4 and path.endswith("/check")) + ): + abort(404) + index = public_root / "index.html" + if not index.is_file(): + abort(503, "Console not found") + response = make_response(index.read_text(encoding="utf-8")) + response.headers["Cache-Control"] = "no-store" + return response diff --git a/chrome-ledger/backend/app/application/access.py b/chrome-ledger/backend/app/application/access.py new file mode 100755 index 0000000..ae708a5 --- /dev/null +++ b/chrome-ledger/backend/app/application/access.py @@ -0,0 +1,64 @@ +import json + +from hmac import compare_digest + +from Crypto.Random import get_random_bytes +from backend.app.common.constants import HEX_CHALLENGE +from backend.app.common.errors import LedgerError +from backend.app.common.utils import utc_now, valid_text +from backend.app.infrastructure.security import certificates, envelopes, keys +from backend.app.infrastructure.persistence import repositories + + +def implant(connection, implant_id, owner_id=None): + row = repositories.get_implant(connection, implant_id) + if row is None or (owner_id is not None and row["user_id"] != owner_id): + raise LedgerError(404, "Implant not found") + return row + + +def challenge(connection, ledger, implant_id, owner_id): + with connection: + connection.execute("BEGIN IMMEDIATE") + implant(connection, implant_id) + current = repositories.get_current_certificate(connection, implant_id) + if current is None or not certificates.valid(certificates.load_certificate(current["cert_pem"]), ledger.ca): + raise LedgerError(409, "Implant has no valid certificate") + nonce = get_random_bytes(32).hex() + repositories.create_implant_challenge(connection, nonce, implant_id, current["serial"], utc_now()) + return {"id": implant_id, "challenge": nonce, "certificate_serial": current["serial"], "certificate": dict(current)} + + +def read_details(connection, ledger, implant_id, owner_id, payload): + invalid = "Invalid certificate, signature or challenge" + pem = payload.get("certificate") + signature = payload.get("signature") + nonce = payload.get("nonce") + if not valid_text(pem, 1, 60_000) or not isinstance(signature, str) or not isinstance(nonce, str): + raise LedgerError(401, invalid) + if not HEX_CHALLENGE.fullmatch(nonce): + raise LedgerError(401, invalid) + try: + certificate = certificates.load_certificate(pem) + except ValueError: + raise LedgerError(401, invalid) from None + with connection: + connection.execute("BEGIN IMMEDIATE") + row = implant(connection, implant_id) + if not compare_digest(certificates.subject_implant_id(certificate), implant_id): + raise LedgerError(401, invalid) + stored = repositories.get_certificate(connection, implant_id, format(certificate.serial_number, "x")) + if stored is None or stored["revoked_at"]: + raise LedgerError(401, invalid) + if not certificates.valid(certificates.load_certificate(stored["cert_pem"]), ledger.ca): + raise LedgerError(401, invalid) + if not keys.verify_implant_signature(certificate.public_key(), signature, nonce): + raise LedgerError(401, invalid) + consumed = repositories.consume_implant_challenge( + connection, nonce, implant_id, stored["serial"], + (utc_now() - ledger.challenge_lifetime).isoformat(), + ) + if not consumed: + raise LedgerError(401, invalid) + details = json.loads(envelopes.decode_envelope(ledger.master_key, row["details"], implant_id)) + return {"id": implant_id, "certificate": dict(stored), **details} diff --git a/chrome-ledger/backend/app/application/certificates.py b/chrome-ledger/backend/app/application/certificates.py new file mode 100755 index 0000000..38e28ee --- /dev/null +++ b/chrome-ledger/backend/app/application/certificates.py @@ -0,0 +1,68 @@ +from hashlib import sha256 + +from cryptography import x509 +from cryptography.exceptions import UnsupportedAlgorithm +from cryptography.hazmat.primitives import hashes, serialization +from backend.app.common.errors import LedgerError +from backend.app.common.utils import utc_now, valid_text +from backend.app.infrastructure.security import certificates, keys + + +def public_key(payload): + pem = payload.get("public_key_pem") + if not valid_text(pem, 1, 60_000): + raise LedgerError(400, "Provide a public key in PEM format") + try: + return keys.parse_public_key(pem) + except keys.UnsupportedKeyType: + raise LedgerError(400, "Supported keys are ECDSA P-256 and RSA with at least 2048 bits") from None + except ValueError: + raise LedgerError(400, "Invalid PEM public key") from None + + +def signing_request(payload): + pem = payload.get("csr_pem") + if not valid_text(pem, 1, 60_000): + raise LedgerError(400, "Provide a signed CSR in PEM format") + try: + request = x509.load_pem_x509_csr(pem.encode("ascii")) + if not request.is_signature_valid: + raise ValueError + key_pem = request.public_key().public_bytes( + serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo, + ).decode("ascii") + except (ValueError, UnsupportedAlgorithm): + raise LedgerError(400, "Invalid CSR or CSR signature") from None + key = public_key({"public_key_pem": key_pem}) + return key, sha256(request.public_bytes(serialization.Encoding.DER)).hexdigest() + + +def issue(ledger, implant_id, key, now, display_name=""): + pem = certificates.issue_certificate(ledger.ca_key, ledger.ca, implant_id, key, now, display_name) + certificate = certificates.load_certificate(pem) + return { + "serial": format(certificate.serial_number, "x"), + "cert_pem": pem, + "fingerprint": certificate.fingerprint(hashes.SHA256()).hex(), + "created_at": now.isoformat(), + "not_after": certificate.not_valid_after_utc.isoformat(), + } + + +def describe(row, ca): + certificate = certificates.load_certificate(row["cert_pem"]) + result = certificates.describe(certificate, ca) + if row["revoked_at"]: + status = "revoked" + elif result["valid"]: + status = "active" + elif certificate.not_valid_after_utc < utc_now(): + status = "expired" + else: + status = "invalid" + result.update( + status=status, valid=status == "active", fingerprint=row["fingerprint"], + revoked_at=row["revoked_at"], + cert_pem=row["cert_pem"], + ) + return result diff --git a/chrome-ledger/backend/app/application/implants.py b/chrome-ledger/backend/app/application/implants.py new file mode 100755 index 0000000..3a16160 --- /dev/null +++ b/chrome-ledger/backend/app/application/implants.py @@ -0,0 +1,112 @@ +import json + +from uuid import uuid4 + +from backend.app.common.errors import LedgerError +from backend.app.common.utils import utc_now, valid_text +from backend.app.infrastructure.security import envelopes, keys +from backend.app.infrastructure.security.certificates import load_certificate, valid +from backend.app.infrastructure.persistence import repositories +from backend.app.application import access, certificates + + +def implant_text(value, label): + if isinstance(value, str) and value.isascii(): + value = value.strip() + if not valid_text(value, 1, 80): + raise LedgerError(400, f"{label} must contain 1-80 ASCII characters") + return value + + +def register(connection, ledger, owner_id, payload): + details = { + name: implant_text(payload.get(name), label) + for name, label in (("project_codename", "Project codename"), ("installed_by", "Organization code")) + } + display_name = implant_text(payload.get("display_name"), "Name") + model = implant_text(payload.get("model"), "Model") + key = certificates.public_key(payload) + implant_id = str(uuid4()) + now = utc_now() + certificate = certificates.issue(ledger, implant_id, key, now, display_name) + details_bytes = json.dumps(details, separators=(",", ":")).encode("utf-8") + record = envelopes.encode_envelope(ledger.master_key, details_bytes, implant_id) + with connection: + repositories.create_implant( + connection, implant_id, owner_id, display_name, model, record, now.isoformat(), + ) + repositories.create_certificate(connection, implant_id, certificate) + repositories.create_implant_telemetry( + connection, implant_id, payload["display_name"], payload["model"], payload["public_key_pem"], + details["project_codename"], details["installed_by"], + ) + return {"id": implant_id, "cert_pem": certificate["cert_pem"]} + + +def list_owned(connection, owner_id): + return {"implants": [dict(row) for row in repositories.list_implants(connection, owner_id)]} + + +def telemetry(connection, owner_id): + return {"telemetry": [dict(row) for row in repositories.list_telemetry(connection, owner_id)]} + + +def passport(connection, ledger, implant_id, viewer_id): + row = access.implant(connection, implant_id, viewer_id) + result = {name: row[name] for name in ("id", "display_name", "model", "created_at")} + result["owner"] = row["owner"] + certificate = repositories.get_latest_certificate(connection, implant_id) + result["certificate"] = certificates.describe(certificate, ledger.ca) + result["cert_pem"] = certificate["cert_pem"] + result["user_id"] = row["user_id"] + return result + + +def check_certificate(connection, ledger, implant_id, owner_id, payload=None): + result = access.challenge(connection, ledger, implant_id, owner_id) if payload is None else access.read_details(connection, ledger, implant_id, owner_id, payload) + result["certificate"] = certificates.describe(result["certificate"], ledger.ca) + return result + + +def reissue(connection, ledger, implant_id, payload): + key, digest = certificates.signing_request(payload) + with connection: + connection.execute("BEGIN IMMEDIATE") + row = access.implant(connection, implant_id) + current = repositories.get_current_certificate(connection, implant_id) + if current is None: + raise LedgerError(409, "Implant has no valid certificate") + if payload.get("certificate_serial") != current["serial"]: + raise LedgerError(401, "Specify the current certificate serial number") + previous = load_certificate(current["cert_pem"]) + if not valid(previous, ledger.ca): + raise LedgerError(409, "Implant has no valid certificate") + message = f"reissue:{implant_id}:{current['serial']}:{digest}" + signature = payload.get("signature") + if not isinstance(signature, str): + raise LedgerError(401, "Invalid signature for the current key") + current_key_authorized = keys.verify_implant_signature(previous.public_key(), signature, message) + if not current_key_authorized and not keys.verify_implant_signature(key, signature, message): + raise LedgerError(401, "Invalid signature for the current key") + now = utc_now() + details = json.loads(envelopes.decode_envelope(ledger.master_key, row["details"], implant_id)) + certificate = current + if current_key_authorized: + issued = certificates.issue(ledger, implant_id, key, now, row["display_name"]) + repositories.revoke_certificates(connection, implant_id, now.isoformat()) + repositories.create_certificate(connection, implant_id, issued) + certificate = repositories.get_certificate(connection, implant_id, issued["serial"]) + result = {name: row[name] for name in ("id", "display_name", "model", "created_at", "owner", "user_id")} + result.update(success=True, cert_pem=certificate["cert_pem"], **details) + result["certificate"] = certificates.describe(certificate, ledger.ca) + return result + + +def registry(connection, ledger): + results = {} + for row in repositories.list_registry(connection): + if row["id"] not in results: + results[row["id"]] = {name: row[name] for name in ("id", "display_name", "model", "created_at", "owner")} + results[row["id"]]["certificates"] = [] + results[row["id"]]["certificates"].append(certificates.describe(row, ledger.ca)) + return {"results": list(results.values())} diff --git a/chrome-ledger/backend/app/bootstrap/factory.py b/chrome-ledger/backend/app/bootstrap/factory.py new file mode 100755 index 0000000..b9cdbeb --- /dev/null +++ b/chrome-ledger/backend/app/bootstrap/factory.py @@ -0,0 +1,85 @@ +import os +import sqlite3 + +from contextlib import closing +from pathlib import Path +from types import SimpleNamespace +from Crypto.Random import get_random_bytes +from flask import Flask +from werkzeug.exceptions import HTTPException +from werkzeug.security import generate_password_hash +from backend.app.common.constants import LIFETIME +from backend.app.common.errors import LedgerError +from backend.app.common.utils import utc_now +from backend.app.infrastructure.security.certificates import load_or_create_ca +from backend.app.infrastructure.persistence.connection import close_database, database_path, initialize +from backend.app.api import views +from backend.app.api.session import load_identity +from backend.app.api.routes import auth, implants, registry + + +def load_key(state_dir, name, size=32): + path = state_dir / name + if path.is_file(): + key = path.read_bytes() + if len(key) != size: + raise RuntimeError(f"Invalid state key: {name}") + return key + key = get_random_bytes(size) + with path.open("xb") as handle: + os.chmod(path, 0o600) + handle.write(key) + return key + + +def create_app(database_path_override=None): + db_path = Path(database_path_override or database_path()) + initialize(db_path) + state_dir = db_path.parent / "state" + state_dir.mkdir(mode=0o700, parents=True, exist_ok=True) + with closing(sqlite3.connect(db_path)) as connection: + has_implants = connection.execute("SELECT EXISTS(SELECT 1 FROM implants)").fetchone()[0] + required = ("master.key", "ca.key.pem", "ca.cert.pem") + if has_implants and any(not (state_dir / name).is_file() for name in required): + raise RuntimeError("Existing implants require the original master key and CA files; restore the state directory") + if (state_dir / "ca.key.pem").is_file() != (state_dir / "ca.cert.pem").is_file(): + raise RuntimeError("Both CA key and certificate must be present") + master_key = load_key(state_dir, "master.key") + ca_key, ca = load_or_create_ca(state_dir, utc_now()) + app = Flask(__name__, static_folder=None) + app.config.update( + DATABASE=str(db_path), + MAX_CONTENT_LENGTH=65_536, + ) + app.extensions["ledger"] = SimpleNamespace( + ca_key=ca_key, ca=ca, master_key=master_key, + obsigil_key=load_key(state_dir, "obsigil.key", 64), + dummy_hash=generate_password_hash(get_random_bytes(32).hex(), method="scrypt"), + challenge_lifetime=LIFETIME, + static_root=Path(__file__).resolve().parents[3] / "frontend", + ) + + app.before_request(load_identity) + + for blueprint in (auth.bp, implants.bp, registry.bp, views.bp): + app.register_blueprint(blueprint) + app.teardown_appcontext(close_database) + + @app.errorhandler(LedgerError) + def service_error(error): + return {"error": str(error)}, error.status + + @app.errorhandler(HTTPException) + def http_error(error): + response = error.get_response() + response.set_data(app.json.dumps({"error": error.description})) + response.mimetype = "application/json" + return response + + @app.after_request + def protect_private_responses(response): + if response.is_json: + response.headers["Cache-Control"] = "no-store" + return response + + return app diff --git a/chrome-ledger/backend/app/common/constants.py b/chrome-ledger/backend/app/common/constants.py new file mode 100755 index 0000000..f78d423 --- /dev/null +++ b/chrome-ledger/backend/app/common/constants.py @@ -0,0 +1,10 @@ +import re + +from datetime import timedelta + + +LIFETIME = timedelta(seconds=60) +AUTH_LIFETIME = timedelta(hours=12) +AUTH_AUDIENCE = "chrome-ledger" + +HEX_CHALLENGE = re.compile(r"[0-9a-fA-F]{64}") diff --git a/chrome-ledger/backend/app/common/errors.py b/chrome-ledger/backend/app/common/errors.py new file mode 100755 index 0000000..ebded7d --- /dev/null +++ b/chrome-ledger/backend/app/common/errors.py @@ -0,0 +1,4 @@ +class LedgerError(Exception): + def __init__(self, status, message): + super().__init__(message) + self.status = status diff --git a/chrome-ledger/backend/app/common/utils.py b/chrome-ledger/backend/app/common/utils.py new file mode 100755 index 0000000..8e42197 --- /dev/null +++ b/chrome-ledger/backend/app/common/utils.py @@ -0,0 +1,17 @@ +import unicodedata + +from datetime import UTC, datetime + + +def utc_now(): + return datetime.now(UTC) + +def account_namespace(username): + return unicodedata.normalize("NFKC", username).casefold() + +def valid_text(value, minimum, maximum): + if not isinstance(value, str): + return False + if len(value) < minimum or len(value) > maximum: + return False + return value.isascii() diff --git a/chrome-ledger/backend/app/infrastructure/persistence/connection.py b/chrome-ledger/backend/app/infrastructure/persistence/connection.py new file mode 100755 index 0000000..275e275 --- /dev/null +++ b/chrome-ledger/backend/app/infrastructure/persistence/connection.py @@ -0,0 +1,37 @@ +import os +import sqlite3 + +from contextlib import closing +from pathlib import Path +from flask import current_app, g +from backend.app.infrastructure.persistence.schema import SCHEMA + + +def database_path(): + default = Path(__file__).resolve().parents[4] / "ledger_data" / "ledger.sqlite3" + return Path(os.environ.get("LEDGER_DB", default)).resolve() + +def initialize(path): + path = Path(path) + path.parent.mkdir(mode=0o700, parents=True, exist_ok=True) + with closing(sqlite3.connect(path)) as connection: + connection.execute("PRAGMA auto_vacuum = INCREMENTAL") + connection.execute("PRAGMA journal_mode = WAL") + connection.execute("PRAGMA busy_timeout = 5000") + connection.execute("PRAGMA foreign_keys = ON") + connection.executescript(SCHEMA) + connection.execute("PRAGMA user_version = 9") + +def database(): + if "database" not in g: + connection = sqlite3.connect(current_app.config["DATABASE"], timeout=5) + connection.row_factory = sqlite3.Row + connection.execute("PRAGMA busy_timeout = 5000") + connection.execute("PRAGMA foreign_keys = ON") + g.database = connection + return g.database + +def close_database(_error): + connection = g.pop("database", None) + if connection is not None: + connection.close() diff --git a/chrome-ledger/backend/app/infrastructure/persistence/repositories.py b/chrome-ledger/backend/app/infrastructure/persistence/repositories.py new file mode 100755 index 0000000..d513984 --- /dev/null +++ b/chrome-ledger/backend/app/infrastructure/persistence/repositories.py @@ -0,0 +1,126 @@ +from backend.app.common.constants import LIFETIME + + +def get_user_by_username(connection, username): + return connection.execute( + "SELECT id, username, namespace, password_hash FROM users WHERE username = ?", (username,), + ).fetchone() + +def create_auth_session(connection, tid, user_id, expires_at): + connection.execute( + "INSERT INTO auth_sessions (tid, user_id, expires_at) VALUES (?, ?, ?)", + (tid, user_id, expires_at), + ) + + +def get_auth_user(connection, tid, user_id, expires_at, now): + return connection.execute( + "SELECT u.id, u.username FROM auth_sessions s JOIN users u ON u.id = s.user_id " + "WHERE s.tid = ? AND s.user_id = ? AND s.expires_at = ? AND s.expires_at > ?", + (tid, user_id, expires_at, now), + ).fetchone() + + +def delete_auth_session(connection, tid): + connection.execute("DELETE FROM auth_sessions WHERE tid = ?", (tid,)) + + +def create_user(connection, user_id, username, namespace, password_hash, created_at): + connection.execute( + "INSERT INTO users (id, username, namespace, password_hash, created_at) VALUES (?, ?, ?, ?, ?)", + (user_id, username, namespace, password_hash, created_at), + ) + +def create_implant(connection, implant_id, user_id, display_name, model, details, created_at): + connection.execute( + "INSERT INTO implants " + "(id, user_id, display_name, model, details, created_at) " + "VALUES (?, ?, ?, ?, ?, ?)", + (implant_id, user_id, display_name, model, details, created_at), + ) + +def create_implant_telemetry(connection, implant_id, display_name, model, public_key_pem, project_codename, installed_by): + connection.execute( + "INSERT INTO implant_telemetry " + "(implant_id, display_name, model, public_key_pem, project_codename, installed_by) VALUES (?, ?, ?, ?, ?, ?)", + (implant_id, display_name, model, public_key_pem, project_codename, installed_by), + ) + + +def get_implant(connection, implant_id): + return connection.execute( + "SELECT i.*, u.username AS owner " + "FROM implants i JOIN users u ON u.id = i.user_id WHERE i.id = ?", (implant_id,), + ).fetchone() + +def list_implants(connection, owner_id): + return connection.execute( + "SELECT i.id, i.display_name, i.model, i.created_at, u.username AS owner " + "FROM implants i JOIN users u ON u.id = i.user_id " + "WHERE i.user_id = ? ORDER BY i.created_at DESC, i.id DESC", (owner_id,), + ).fetchall() + +def list_telemetry(connection, owner_id): + return connection.execute( + "SELECT t.display_name, t.model, t.public_key_pem, t.project_codename, t.installed_by " + "FROM implants i JOIN implant_telemetry t ON t.implant_id = i.id " + "WHERE i.user_id = ? ORDER BY i.created_at DESC, i.id DESC", (owner_id,), + ).fetchall() + + +def list_registry(connection): + return connection.execute( + "SELECT i.id, i.display_name, i.model, i.created_at, u.username AS owner, " + "c.cert_pem, c.fingerprint, c.revoked_at " + "FROM implants i JOIN users u ON u.id = i.user_id " + "JOIN implant_certificates c ON c.implant_id = i.id " + "ORDER BY i.created_at DESC, i.id DESC, c.rowid DESC", + ).fetchall() + +def create_certificate(connection, implant_id, certificate): + connection.execute( + "INSERT INTO implant_certificates " + "(serial, implant_id, cert_pem, fingerprint, created_at, not_after) VALUES (?, ?, ?, ?, ?, ?)", + (certificate["serial"], implant_id, certificate["cert_pem"], certificate["fingerprint"], + certificate["created_at"], certificate["not_after"]), + ) + +def revoke_certificates(connection, implant_id, now): + connection.execute( + "UPDATE implant_certificates SET revoked_at = ? WHERE implant_id = ? AND revoked_at IS NULL", + (now, implant_id), + ) + + +def get_current_certificate(connection, implant_id): + return connection.execute( + "SELECT * FROM implant_certificates WHERE implant_id = ? AND revoked_at IS NULL " + "ORDER BY rowid DESC LIMIT 1", (implant_id,), + ).fetchone() + +def get_latest_certificate(connection, implant_id): + return connection.execute( + "SELECT * FROM implant_certificates WHERE implant_id = ? ORDER BY rowid DESC LIMIT 1", + (implant_id,), + ).fetchone() + +def get_certificate(connection, implant_id, serial): + return connection.execute( + "SELECT * FROM implant_certificates WHERE implant_id = ? AND serial = ?", + (implant_id, serial), + ).fetchone() + +def create_implant_challenge(connection, nonce, implant_id, serial, now): + connection.execute( + "DELETE FROM implant_challenges WHERE created_at <= ?", ((now - LIFETIME).isoformat(),), + ) + connection.execute( + "INSERT INTO implant_challenges (nonce, implant_id, certificate_serial, created_at) " + "VALUES (?, ?, ?, ?)", (nonce, implant_id, serial, now.isoformat()), + ) + +def consume_implant_challenge(connection, nonce, implant_id, certificate_serial, cutoff): + return connection.execute( + "DELETE FROM implant_challenges WHERE nonce = ? AND implant_id = ? AND certificate_serial = ? AND created_at > ?", + (nonce, implant_id, certificate_serial, cutoff), + ).rowcount diff --git a/chrome-ledger/backend/app/infrastructure/persistence/schema.py b/chrome-ledger/backend/app/infrastructure/persistence/schema.py new file mode 100755 index 0000000..2bf435f --- /dev/null +++ b/chrome-ledger/backend/app/infrastructure/persistence/schema.py @@ -0,0 +1,51 @@ +SCHEMA = """ +CREATE TABLE IF NOT EXISTS users ( + id TEXT PRIMARY KEY, + username TEXT NOT NULL UNIQUE, + namespace TEXT NOT NULL DEFAULT '', + password_hash TEXT NOT NULL, + created_at TEXT NOT NULL +); +CREATE INDEX IF NOT EXISTS users_created_at ON users (created_at); +CREATE TABLE IF NOT EXISTS auth_sessions ( + tid TEXT PRIMARY KEY, + user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + expires_at INTEGER NOT NULL +); +CREATE INDEX IF NOT EXISTS auth_sessions_user_id ON auth_sessions (user_id); +CREATE INDEX IF NOT EXISTS auth_sessions_expires_at ON auth_sessions (expires_at); +CREATE TABLE IF NOT EXISTS implants ( + id TEXT PRIMARY KEY, + user_id TEXT NOT NULL REFERENCES users(id), + display_name TEXT NOT NULL CHECK(length(trim(display_name)) BETWEEN 1 AND 80), + model TEXT NOT NULL DEFAULT '', + details TEXT NOT NULL, + created_at TEXT NOT NULL +); +CREATE INDEX IF NOT EXISTS implants_user_id ON implants (user_id); +CREATE INDEX IF NOT EXISTS implants_created_at ON implants (created_at); +CREATE TABLE IF NOT EXISTS implant_telemetry ( + implant_id TEXT PRIMARY KEY REFERENCES implants(id) ON DELETE CASCADE, + display_name TEXT NOT NULL, + model TEXT NOT NULL, + public_key_pem TEXT NOT NULL, + project_codename TEXT NOT NULL, + installed_by TEXT NOT NULL +); +CREATE TABLE IF NOT EXISTS implant_certificates ( + serial TEXT PRIMARY KEY, + implant_id TEXT NOT NULL REFERENCES implants(id) ON DELETE CASCADE, + cert_pem TEXT NOT NULL, + fingerprint TEXT NOT NULL UNIQUE, + created_at TEXT NOT NULL, + not_after TEXT NOT NULL, + revoked_at TEXT +); +CREATE TABLE IF NOT EXISTS implant_challenges ( + nonce TEXT PRIMARY KEY, + implant_id TEXT NOT NULL REFERENCES implants(id) ON DELETE CASCADE, + certificate_serial TEXT NOT NULL REFERENCES implant_certificates(serial), + created_at TEXT NOT NULL +); +CREATE INDEX IF NOT EXISTS implant_challenges_created_at ON implant_challenges (created_at); +""" diff --git a/chrome-ledger/backend/app/infrastructure/security/certificates.py b/chrome-ledger/backend/app/infrastructure/security/certificates.py new file mode 100755 index 0000000..db9f215 --- /dev/null +++ b/chrome-ledger/backend/app/infrastructure/security/certificates.py @@ -0,0 +1,105 @@ +import os + +from datetime import timedelta +from cryptography import x509 +from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm +from cryptography.hazmat.primitives import hashes, serialization +from cryptography.hazmat.primitives.asymmetric import ec +from cryptography.x509.oid import NameOID +from backend.app.common.utils import utc_now + + +ORGANIZATION = "Chrome Ledger" + + +def certificate_builder(subject, issuer, public_key, now, days): + return ( + x509.CertificateBuilder() + .subject_name(subject) + .issuer_name(issuer) + .public_key(public_key) + .serial_number(x509.random_serial_number()) + .not_valid_before(now) + .not_valid_after(now + timedelta(days=days)) + ) + +def create_ca(now): + key = ec.generate_private_key(ec.SECP256R1()) + name = x509.Name([ + x509.NameAttribute(NameOID.COMMON_NAME, "Chrome Ledger Root CA"), + x509.NameAttribute(NameOID.ORGANIZATION_NAME, ORGANIZATION), + ]) + certificate = ( + certificate_builder(name, name, key.public_key(), now, 365) + .add_extension(x509.BasicConstraints(ca=True, path_length=0), critical=True) + .sign(key, hashes.SHA256()) + ) + return key, certificate + +def load_or_create_ca(state_dir, now): + key_path = state_dir / "ca.key.pem" + cert_path = state_dir / "ca.cert.pem" + if key_path.is_file() and cert_path.is_file(): + key = serialization.load_pem_private_key(key_path.read_bytes(), password=None) + ca = x509.load_pem_x509_certificate(cert_path.read_bytes()) + key_bytes = key.public_key().public_bytes(serialization.Encoding.DER, serialization.PublicFormat.SubjectPublicKeyInfo) + ca_bytes = ca.public_key().public_bytes(serialization.Encoding.DER, serialization.PublicFormat.SubjectPublicKeyInfo) + if key_bytes != ca_bytes: + raise ValueError("CA key does not match its certificate") + return key, ca + key, ca = create_ca(now) + key_path.write_bytes( + key.private_bytes( + serialization.Encoding.PEM, + serialization.PrivateFormat.PKCS8, + serialization.NoEncryption(), + ) + ) + os.chmod(key_path, 0o600) + cert_path.write_bytes(ca.public_bytes(serialization.Encoding.PEM)) + return key, ca + +def issue_certificate(ca_key, ca, implant_id, public_key, now, display_name=""): + common_name = display_name[:64] + subject = x509.Name([ + x509.NameAttribute(NameOID.COMMON_NAME, common_name), + x509.NameAttribute(NameOID.ORGANIZATIONAL_UNIT_NAME, implant_id), + x509.NameAttribute(NameOID.ORGANIZATION_NAME, ORGANIZATION), + ]) + certificate = ( + certificate_builder(subject, ca.subject, public_key, now, 30) + .add_extension(x509.BasicConstraints(ca=False, path_length=None), critical=True) + .add_extension(x509.SubjectAlternativeName([ + x509.UniformResourceIdentifier(f"urn:chrome-ledger:implant:{implant_id}"), + ]), critical=False) + .sign(ca_key, hashes.SHA256()) + ) + return certificate.public_bytes(serialization.Encoding.PEM).decode("ascii") + +def load_certificate(pem): + return x509.load_pem_x509_certificate(pem.encode("ascii")) + +def subject_implant_id(certificate): + attributes = certificate.subject.get_attributes_for_oid(NameOID.ORGANIZATIONAL_UNIT_NAME) + return attributes[0].value if len(attributes) == 1 else "" + +def valid(certificate, ca): + now = utc_now() + if not (certificate.not_valid_before_utc <= now <= certificate.not_valid_after_utc + and ca.not_valid_before_utc <= now <= ca.not_valid_after_utc): + return False + try: + certificate.verify_directly_issued_by(ca) + except (InvalidSignature, ValueError, UnsupportedAlgorithm): + return False + return True + +def describe(certificate, ca): + return { + "subject": certificate.subject.rfc4514_string(), + "issuer": certificate.issuer.rfc4514_string(), + "serial": format(certificate.serial_number, "x"), + "not_before": certificate.not_valid_before_utc.isoformat(), + "not_after": certificate.not_valid_after_utc.isoformat(), + "valid": valid(certificate, ca), + } diff --git a/chrome-ledger/backend/app/infrastructure/security/envelopes.py b/chrome-ledger/backend/app/infrastructure/security/envelopes.py new file mode 100755 index 0000000..e91fef8 --- /dev/null +++ b/chrome-ledger/backend/app/infrastructure/security/envelopes.py @@ -0,0 +1,34 @@ +import base64 + +from Crypto.Cipher import AES +from Crypto.Random import get_random_bytes + + +NONCE_SIZE = 16 +TAG_SIZE = 16 + + +def seal(key, plaintext, associated_data): + cipher = AES.new(key, AES.MODE_GCM, nonce=get_random_bytes(NONCE_SIZE)) + cipher.update(associated_data) + ciphertext, tag = cipher.encrypt_and_digest(plaintext) + return cipher.nonce + ciphertext + tag + +def unseal(key, envelope, associated_data): + cipher = AES.new(key, AES.MODE_GCM, nonce=envelope[:NONCE_SIZE]) + cipher.update(associated_data) + plaintext = cipher.decrypt_and_verify( + envelope[NONCE_SIZE:-TAG_SIZE], + envelope[-TAG_SIZE:], + ) + return plaintext + +def encode_envelope(key, secret, implant_id): + associated_data = implant_id.encode("ascii") + envelope = seal(key, secret, associated_data) + return base64.b64encode(envelope).decode("ascii") + +def decode_envelope(key, envelope, implant_id): + associated_data = implant_id.encode("ascii") + decoded = base64.b64decode(envelope, validate=True) + return unseal(key, decoded, associated_data).decode("utf-8") diff --git a/chrome-ledger/backend/app/infrastructure/security/keys.py b/chrome-ledger/backend/app/infrastructure/security/keys.py new file mode 100755 index 0000000..3ff5183 --- /dev/null +++ b/chrome-ledger/backend/app/infrastructure/security/keys.py @@ -0,0 +1,34 @@ +import base64 + +from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm +from cryptography.hazmat.primitives import hashes, serialization +from cryptography.hazmat.primitives.asymmetric import ec, padding, rsa + + +class UnsupportedKeyType(ValueError): + pass + + +def parse_public_key(pem): + if not isinstance(pem, str): + raise ValueError("PEM must be a string") + try: + key = serialization.load_pem_public_key(pem.encode("utf-8")) + except (ValueError, UnsupportedAlgorithm): + raise ValueError("Invalid PEM public key") from None + if isinstance(key, rsa.RSAPublicKey) and key.key_size >= 2048: + return key + if isinstance(key, ec.EllipticCurvePublicKey) and isinstance(key.curve, ec.SECP256R1): + return key + raise UnsupportedKeyType("Unsupported public key type") + +def verify_implant_signature(public_key, signature, nonce): + try: + signed = base64.b64decode(signature, validate=True) + if isinstance(public_key, ec.EllipticCurvePublicKey): + public_key.verify(signed, nonce.encode("ascii"), ec.ECDSA(hashes.SHA256())) + else: + public_key.verify(signed, nonce.encode("ascii"), padding.PKCS1v15(), hashes.SHA256()) + except (InvalidSignature, ValueError): + return False + return True diff --git a/chrome-ledger/backend/requirements.txt b/chrome-ledger/backend/requirements.txt new file mode 100755 index 0000000..60d6b29 --- /dev/null +++ b/chrome-ledger/backend/requirements.txt @@ -0,0 +1,6 @@ +Flask==3.1.3 +Werkzeug==3.1.9 +gunicorn==27.0.1 +pycryptodome==4.5.0 +cryptography==50.0.2 +obsigil==1.0.0 diff --git a/chrome-ledger/cleaner/Dockerfile b/chrome-ledger/cleaner/Dockerfile new file mode 100755 index 0000000..507fe7a --- /dev/null +++ b/chrome-ledger/cleaner/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.12-slim-bookworm + +RUN useradd --uid 10001 --user-group --no-create-home --shell /usr/sbin/nologin ledger-cleaner \ + && install -d -m 0700 -o ledger-cleaner -g ledger-cleaner /var/lib/chrome-ledger + +COPY --chmod=755 cleaner.sh /cleaner.sh +COPY cleaner.py /cleaner.py + +USER ledger-cleaner + +HEALTHCHECK --interval=10m --timeout=5s --start-period=90s --retries=2 CMD python3 -c "import os,time; p='/tmp/cleaner-last-success'; raise SystemExit(0 if os.path.exists(p) and time.time()-os.path.getmtime(p)<720 else 1)" + +CMD ["/cleaner.sh"] diff --git a/chrome-ledger/cleaner/cleaner.py b/chrome-ledger/cleaner/cleaner.py new file mode 100755 index 0000000..210c346 --- /dev/null +++ b/chrome-ledger/cleaner/cleaner.py @@ -0,0 +1,54 @@ +import os +import sqlite3 + +from datetime import UTC, datetime, timedelta + + +RETENTION = timedelta(minutes=10) + + +def main(): + connection = sqlite3.connect(os.environ["LEDGER_DB"], timeout=5) + connection.execute("PRAGMA busy_timeout = 5000") + connection.execute("PRAGMA foreign_keys = ON") + tables = { + row[0] + for row in connection.execute("SELECT name FROM sqlite_master WHERE type = 'table'") + } + cutoff = (datetime.now(UTC) - RETENTION).isoformat() + deleted = [] + if "auth_sessions" in tables: + cursor = connection.execute( + "DELETE FROM auth_sessions WHERE expires_at <= ?", + (int(datetime.now(UTC).timestamp()),), + ) + deleted.append(f"sessions={cursor.rowcount}") + if "implant_challenges" in tables: + cursor = connection.execute( + "DELETE FROM implant_challenges WHERE created_at <= ?", + (cutoff,), + ) + deleted.append(f"challenges={cursor.rowcount}") + if "implants" in tables: + cursor = connection.execute( + "DELETE FROM implants WHERE created_at <= ?", + (cutoff,), + ) + deleted.append(f"implants={cursor.rowcount}") + if "users" in tables and "implants" in tables: + cursor = connection.execute( + "DELETE FROM users WHERE created_at <= ? " + "AND NOT EXISTS (SELECT 1 FROM implants WHERE implants.user_id = users.id)", + (cutoff,), + ) + deleted.append(f"users={cursor.rowcount}") + connection.commit() + connection.execute("PRAGMA wal_checkpoint(PASSIVE)") + connection.execute("PRAGMA optimize") + connection.execute("PRAGMA incremental_vacuum").fetchall() + connection.close() + print("cleaned " + " ".join(deleted), flush=True) + + +if __name__ == "__main__": + main() diff --git a/chrome-ledger/cleaner/cleaner.sh b/chrome-ledger/cleaner/cleaner.sh new file mode 100755 index 0000000..85e3a9a --- /dev/null +++ b/chrome-ledger/cleaner/cleaner.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +while true; do + if python3 /cleaner.py; then + touch /tmp/cleaner-last-success + fi + sleep 600 +done diff --git a/chrome-ledger/compose.yml b/chrome-ledger/compose.yml new file mode 100755 index 0000000..4219508 --- /dev/null +++ b/chrome-ledger/compose.yml @@ -0,0 +1,80 @@ +name: chrome-ledger + +services: + service: + build: . + command: ["python", "run.py"] + environment: + LEDGER_DB: "/var/lib/chrome-ledger/ledger.sqlite3" + PYTHONDONTWRITEBYTECODE: "1" + PYTHONUNBUFFERED: "1" + ports: + - "8081:8080" + volumes: + - ledger_data:/var/lib/chrome-ledger + restart: unless-stopped + read_only: true + tmpfs: + - /tmp:size=64m,mode=1777 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + stop_grace_period: 20s + deploy: + resources: + limits: + cpus: "2.0" + memory: 512M + pids: 256 + reservations: + cpus: "0.25" + memory: 128M + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/login', timeout=3).close()"] + interval: 10s + timeout: 5s + start_period: 15s + retries: 3 + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" + + cleaner: + build: ./cleaner + depends_on: + - service + environment: + LEDGER_DB: "/var/lib/chrome-ledger/ledger.sqlite3" + PYTHONDONTWRITEBYTECODE: "1" + PYTHONUNBUFFERED: "1" + volumes: + - ledger_data:/var/lib/chrome-ledger + restart: unless-stopped + read_only: true + tmpfs: + - /tmp:size=16m,mode=1777 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + deploy: + resources: + limits: + cpus: "0.25" + memory: 64M + pids: 64 + reservations: + cpus: "0.05" + memory: 16M + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" + +volumes: + ledger_data: + name: chrome-ledger-data diff --git a/chrome-ledger/frontend/public/index.html b/chrome-ledger/frontend/public/index.html new file mode 100755 index 0000000..5f014e3 --- /dev/null +++ b/chrome-ledger/frontend/public/index.html @@ -0,0 +1,41 @@ + + + + + + Chrome Ledger + + + + + + + diff --git a/chrome-ledger/frontend/src/app/main.js b/chrome-ledger/frontend/src/app/main.js new file mode 100755 index 0000000..5f295c9 --- /dev/null +++ b/chrome-ledger/frontend/src/app/main.js @@ -0,0 +1,151 @@ +import { api } from '../shared/api/client.js'; +import { state, setSession } from '../shared/session.js'; +import { renderLogin } from '../features/auth/login.js'; +import { renderIssue } from '../features/implants/create.js'; +import { renderList } from '../features/implants/list.js'; +import { renderCard } from '../features/implants/details.js'; +import { renderHolder } from '../features/implants/holder.js'; +import { renderReissue } from '../features/implants/reissue.js'; +import { renderRegistry } from '../features/implants/registry.js'; + +const nav = document.querySelector('#nav'); +const username = document.querySelector('#username'); +const layout = document.querySelector('#layout'); +const logout = document.querySelector('#logout'); +const loginLink = document.querySelector('#login-link'); + +const pageTitles = { + '/login': 'Вход', + '/home': 'Главная', + '/home/register_implant': 'Новый имплант', + '/home/check_certificate': 'Проверка', + '/home/reissue': 'Перевыпуск', + '/home/implants': 'Импланты', + '/home/registry': 'Реестр сертификатов', +}; + +function go(path, { replace = false } = {}) { + if (replace) history.replaceState(null, '', path); + else history.pushState(null, '', path); + render(); +} + +function syncChrome() { + const signedIn = Boolean(state.user); + layout.classList.toggle('signed-out', !signedIn); + username.textContent = state.user ? state.user.username : ''; + logout.hidden = !signedIn; + loginLink.hidden = signedIn; + for (const link of nav.querySelectorAll('[data-auth]')) { + link.hidden = !signedIn; + } + for (const link of nav.querySelectorAll('a')) { + const href = link.getAttribute('href'); + const active = href === location.pathname + || (href === '/home/implants' && location.pathname.startsWith('/home/implants/')) + || (href === '/home/check_certificate' && location.pathname.startsWith('/home/check_certificate/')); + link.classList.toggle('active', active); + if (active) link.setAttribute('aria-current', 'page'); + else link.removeAttribute('aria-current'); + } + const routeTitle = location.pathname.startsWith('/home/implants/') + ? 'Карточка импланта' + : location.pathname.startsWith('/home/check_certificate/') ? 'Проверка' : pageTitles[location.pathname]; + document.title = routeTitle ? `${routeTitle} · Chrome Ledger` : 'Chrome Ledger'; +} + +function render() { + const path = location.pathname; + const publicPage = path === '/login'; + if (path === '/') return go(state.user ? '/home' : '/login', { replace: true }); + if (!state.user && !publicPage) return go('/login', { replace: true }); + if (state.user && path === '/login') return go('/home', { replace: true }); + syncChrome(); + if (path === '/login') return renderLogin(go); + if (path === '/home') { + document.querySelector('#view').innerHTML = '

Добро пожаловать в Chrome Ledger!

'; + return; + } + if (path === '/home/register_implant') return renderIssue(); + if (path === '/home/check_certificate') return renderHolder(); + if (path === '/home/reissue') { + const params = new URLSearchParams(location.search); + return renderReissue(params.get('id') || '', params.get('serial') || ''); + } + const check = path.match(/^\/home\/check_certificate\/([^/]+)\/check$/); + if (check) return renderHolder(decodeURIComponent(check[1])); + if (path === '/home/implants') return renderList(); + if (path === '/home/registry') return renderRegistry(); + const card = path.match(/^\/home\/implants\/([^/]+)$/); + if (card) return renderCard(decodeURIComponent(card[1])); + go('/home', { replace: true }); +} + +window.addEventListener('ledger:session-expired', () => go('/login', { replace: true })); + +logout.addEventListener('click', async (event) => { + const button = event.currentTarget; + button.disabled = true; + try { + await api('/logout', { method: 'DELETE' }); + setSession(null); + go('/login', { replace: true }); + } catch (error) { + window.alert(error.message); + } finally { + button.disabled = false; + } +}); + +document.addEventListener('input', ({ target }) => { + if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) { + target.setCustomValidity(/[^\x00-\x7F]/.test(target.value) + ? 'Допустимы только английские буквы, цифры и символы ASCII' : ''); + } +}); + +document.addEventListener('click', (event) => { + if ( + event.defaultPrevented + || event.button !== 0 + || event.metaKey + || event.ctrlKey + || event.shiftKey + || event.altKey + ) { + return; + } + const link = event.target.closest('a'); + if (!link) { + return; + } + if (link.target && link.target !== '_self') { + return; + } + if (link.hasAttribute('download')) { + return; + } + const url = new URL(link.href, location.origin); + if (url.origin !== location.origin) { + return; + } + event.preventDefault(); + go(url.pathname + url.search); +}); + +window.addEventListener('popstate', render); + +async function start() { + if (state.token) { + const token = state.token; + try { + const user = await api('/me'); + if (state.token === token) state.user = user; + } catch (error) { + if (state.token === token) window.alert(error.message); + } + } + render(); +} + +start(); diff --git a/chrome-ledger/frontend/src/features/auth/login.js b/chrome-ledger/frontend/src/features/auth/login.js new file mode 100755 index 0000000..e7ef901 --- /dev/null +++ b/chrome-ledger/frontend/src/features/auth/login.js @@ -0,0 +1,71 @@ +import { api } from '../../shared/api/client.js'; +import { setSession } from '../../shared/session.js'; +import { setError } from '../../shared/ui/dom.js'; + +const view = document.querySelector('#view'); + +export function renderLogin(go) { + let registering = false; + view.innerHTML = ` + `; + + const form = document.querySelector('#login-form'); + const title = document.querySelector('#login-title'); + const userInput = document.querySelector('#login-username'); + const password = document.querySelector('#login-password'); + const problem = document.querySelector('#login-error'); + const submit = document.querySelector('#login-submit'); + const toggle = document.querySelector('#login-toggle'); + + const setMode = (next) => { + registering = next; + title.innerHTML = next ? 'Создать аккаунт' : 'Войти в личный кабинет'; + submit.textContent = next ? 'Создать аккаунт' : 'Войти'; + toggle.textContent = next ? 'У меня есть аккаунт' : 'Создать аккаунт'; + password.autocomplete = next ? 'new-password' : 'current-password'; + password.value = ''; + setError(problem, ''); + }; + + toggle.addEventListener('click', () => setMode(!registering)); + + form.addEventListener('submit', async (event) => { + event.preventDefault(); + setError(problem, ''); + submit.disabled = true; + toggle.disabled = true; + try { + setSession(await api(registering ? '/register' : '/login', { + method: 'POST', + body: { username: userInput.value, password: password.value }, + })); + go('/home', { replace: true }); + } catch (error) { + setError(problem, error.message); + } finally { + submit.disabled = false; + toggle.disabled = false; + } + }); +} + diff --git a/chrome-ledger/frontend/src/features/implants/certificate.js b/chrome-ledger/frontend/src/features/implants/certificate.js new file mode 100755 index 0000000..5cbf384 --- /dev/null +++ b/chrome-ledger/frontend/src/features/implants/certificate.js @@ -0,0 +1,3 @@ +export const certificateStatus = { + active: 'Действует', revoked: 'Отозван', expired: 'Срок истёк', invalid: 'Недействителен', +}; diff --git a/chrome-ledger/frontend/src/features/implants/create.js b/chrome-ledger/frontend/src/features/implants/create.js new file mode 100755 index 0000000..753030d --- /dev/null +++ b/chrome-ledger/frontend/src/features/implants/create.js @@ -0,0 +1,96 @@ +import { api } from '../../shared/api/client.js'; +import { escapeHtml, setError, showResultDialog } from '../../shared/ui/dom.js'; + +const view = document.querySelector('#view'); + +export function renderIssue() { + view.innerHTML = ` +
+ +
+

Сведения об импланте

+
+ + +
+
+ + +
+

Код проекта и код организации — приватные данные, необходимые для учёта происхождения импланта. Не раскрывайте их значения третьим лицам

+ +

После выпуска сохраните сертификат

+ +
+ +
+
+
+
`; + + const form = document.querySelector('#issue-form'); + const key = document.querySelector('#issue-key'); + const problem = document.querySelector('#issue-error'); + const submit = document.querySelector('#issue-submit'); + const result = document.querySelector('#issue-result'); + + form.addEventListener('submit', async (event) => { + event.preventDefault(); + setError(problem, ''); + result.innerHTML = ''; + const body = { + public_key_pem: key.value, + display_name: document.querySelector('#issue-name').value, + model: document.querySelector('#issue-model').value, + project_codename: document.querySelector('#issue-project').value, + installed_by: document.querySelector('#issue-organization').value, + }; + submit.disabled = true; + submit.textContent = 'Оформляем сертификат…'; + try { + const data = await api('/register_implant', { method: 'POST', body }); + form.reset(); + result.innerHTML = ` + +
+

Сертификат выпущен

+

Имплант зарегистрирован. Сохраните сертификат перед продолжением работы

+
+
ID импланта
+
${escapeHtml(data.id)}
+
+ +
+ +
+
+
`; + + showResultDialog(result); + } catch (error) { + setError(problem, error.message); + } finally { + submit.disabled = false; + submit.textContent = 'Выпустить сертификат'; + } + }); +} + diff --git a/chrome-ledger/frontend/src/features/implants/details.js b/chrome-ledger/frontend/src/features/implants/details.js new file mode 100755 index 0000000..c58cc6b --- /dev/null +++ b/chrome-ledger/frontend/src/features/implants/details.js @@ -0,0 +1,55 @@ +import { api } from '../../shared/api/client.js'; +import { state } from '../../shared/session.js'; +import { certificateStatus } from './certificate.js'; +import { dateTime, escapeHtml, readOnlyField } from '../../shared/ui/dom.js'; + +const view = document.querySelector('#view'); + + +export async function renderCard(id) { + const route = location.pathname; + view.innerHTML = '
Загружаем карточку…
'; + try { + const base = '/implants/' + encodeURIComponent(id); + const implant = await api(base); + if (location.pathname !== route || !state.user) return; + const certificate = implant.certificate; + view.innerHTML = `
+ +
+
+

Сведения об импланте

+ + ${escapeHtml(certificateStatus[certificate.status] || certificate.status)} + +
+
+
ID
${escapeHtml(id)}
+
Модель
${escapeHtml(implant.model || 'Не указана')}
+
Создан
${escapeHtml(dateTime(implant.created_at))}
+
Сертификат
${escapeHtml(certificateStatus[certificate.status] || certificate.status)}
+
+
+
+

Публичный сертификат

+
+
Серийный номер
${escapeHtml(certificate.serial)}
+
Действует до
${escapeHtml(dateTime(certificate.not_after))}
+
SHA-256
${escapeHtml(certificate.fingerprint)}
+ ${certificate.revoked_at ? `
Отозван
${escapeHtml(dateTime(certificate.revoked_at))}
` : ''} +
+ ${readOnlyField('Сертификат (PEM)', certificate.cert_pem, 4)} +
+
`; + } catch (error) { + if (location.pathname !== route) return; + view.innerHTML = `
+ + +
`; + } +} diff --git a/chrome-ledger/frontend/src/features/implants/holder.js b/chrome-ledger/frontend/src/features/implants/holder.js new file mode 100755 index 0000000..3d524c4 --- /dev/null +++ b/chrome-ledger/frontend/src/features/implants/holder.js @@ -0,0 +1,101 @@ +import { api } from '../../shared/api/client.js'; +import { escapeHtml, setError, readOnlyField, showResultDialog } from '../../shared/ui/dom.js'; + +const view = document.querySelector('#view'); + +export function renderHolder(wanted = '') { + view.innerHTML = `
+ +
    +
  1. Получите верификатор
  2. +
  3. Подпишите строку закрытым ключом
  4. +
  5. Отправьте подпись в base64
  6. +
+
+

Получить верификатор

+ + +
+ + +
+
`; + const challengeForm = document.querySelector('#challenge-form'); + const holderForm = document.querySelector('#holder-form'); + const challengeField = document.querySelector('#holder-challenge'); + const result = document.querySelector('#holder-result'); + const problem = document.querySelector('#holder-error'); + let pending = null; + challengeForm.addEventListener('submit', async (event) => { + event.preventDefault(); + const button = challengeForm.querySelector('button'); + button.disabled = true; + pending = null; + holderForm.hidden = true; + result.innerHTML = ''; + setError(problem, ''); + try { + const id = document.querySelector('#holder-id').value.trim(); + const base = '/check_certificate/' + encodeURIComponent(id); + const challenge = await api(base + '/check'); + pending = { id, nonce: challenge.challenge, certificate: challenge.certificate.cert_pem }; + history.replaceState(null, '', '/home/check_certificate/' + encodeURIComponent(id) + '/check'); + challengeField.innerHTML = readOnlyField('Сертификат (PEM)', pending.certificate, 4) + + readOnlyField('Верификатор: подпишите эту ASCII-строку', pending.nonce, 2); + document.querySelector('#holder-signature').value = ''; + holderForm.hidden = false; + } catch (error) { + setError(problem, error.message); + } finally { + button.disabled = false; + } + }); + holderForm.addEventListener('submit', async (event) => { + event.preventDefault(); + if (!pending) return; + const button = holderForm.querySelector('button'); + button.disabled = true; + setError(problem, ''); + try { + const data = await api('/check_certificate/' + encodeURIComponent(pending.id) + '/check', { + method: 'POST', body: { certificate: pending.certificate, nonce: pending.nonce, + signature: document.querySelector('#holder-signature').value.trim() }, + }); + result.innerHTML = ` + +
+

Данные импланта

+ ${readOnlyField('Код проекта', data.project_codename, 1)} + ${readOnlyField('Код организации', data.installed_by, 1)} +
+ +
+
+
`; + + showResultDialog(result); + pending = null; + holderForm.hidden = true; + } catch (error) { + setError(problem, error.message); + } finally { + button.disabled = false; + } + }); + if (wanted) challengeForm.requestSubmit(); +} diff --git a/chrome-ledger/frontend/src/features/implants/list.js b/chrome-ledger/frontend/src/features/implants/list.js new file mode 100755 index 0000000..f26a7e9 --- /dev/null +++ b/chrome-ledger/frontend/src/features/implants/list.js @@ -0,0 +1,48 @@ +import { api } from '../../shared/api/client.js'; +import { state } from '../../shared/session.js'; +import { dateTime, escapeHtml } from '../../shared/ui/dom.js'; + +const view = document.querySelector('#view'); + +export async function renderList() { + view.innerHTML = `
+ +
+

Загружаем импланты…

+
+
`; + const list = document.querySelector('#implant-list'); + const add = document.querySelector('#implant-add'); + try { + const { implants } = await api('/implants'); + if (!list.isConnected || !state.user) return; + add.hidden = !implants.length; + list.innerHTML = implants.map((implant) => ` +
+
+
+

${escapeHtml(implant.display_name)}

+

${escapeHtml(implant.model || 'Модель не указана')}

+
+ Открыть карточку +
+
+
ID
${escapeHtml(implant.id)}
+
Создан
${escapeHtml(dateTime(implant.created_at))}
+
+
`).join('') || ` +
+

Имплантов пока нет

+

Добавьте первый имплант, чтобы выпустить сертификат

+ +
`; + } catch (error) { + if (list.isConnected) list.innerHTML = ``; + } +} diff --git a/chrome-ledger/frontend/src/features/implants/registry.js b/chrome-ledger/frontend/src/features/implants/registry.js new file mode 100755 index 0000000..7b7a0fc --- /dev/null +++ b/chrome-ledger/frontend/src/features/implants/registry.js @@ -0,0 +1,74 @@ +import { api } from '../../shared/api/client.js'; +import { state } from '../../shared/session.js'; +import { certificateStatus } from './certificate.js'; +import { dateTime, escapeHtml, readOnlyField } from '../../shared/ui/dom.js'; + +const view = document.querySelector('#view'); + +export async function renderRegistry() { + view.innerHTML = `
+ +
+

Загружаем реестр…

+
+
+ + + +
+
`; + const list = document.querySelector('#registry-list'); + const previous = document.querySelector('#registry-prev'); + const next = document.querySelector('#registry-next'); + const counter = document.querySelector('#registry-page'); + try { + const { results } = await api('/registry'); + if (!list.isConnected || !state.user) return; + let page = 0; + const renderPage = () => { + list.innerHTML = results.slice(page * 20, (page + 1) * 20).map((implant) => ` +
+
+

${escapeHtml(implant.display_name)}

+ ${implant.certificates.length} +
+
+
ID импланта
${escapeHtml(implant.id)}
+
Модель
${escapeHtml(implant.model || 'Не указана')}
+
Владелец
${escapeHtml(implant.owner)}
+
Создан
${escapeHtml(dateTime(implant.created_at))}
+
+ ${implant.certificates.map((certificate) => ` +
+ + ${escapeHtml(certificate.serial)} + ${escapeHtml(certificateStatus[certificate.status] || certificate.status)} + +
+
+
SHA-256
${escapeHtml(certificate.fingerprint)}
+
Субъект
${escapeHtml(certificate.subject)}
+
Удостоверяющий центр
${escapeHtml(certificate.issuer)}
+
Действует с
${escapeHtml(dateTime(certificate.not_before))}
+
Действует до
${escapeHtml(dateTime(certificate.not_after))}
+ ${certificate.revoked_at ? `
Отозван
${escapeHtml(dateTime(certificate.revoked_at))}
` : ''} +
+ ${readOnlyField('Сертификат (PEM)', certificate.cert_pem, 4)} +
+
`).join('')} +
`).join('') || '
В реестре пока нет имплантов
'; + previous.disabled = page === 0; + next.disabled = (page + 1) * 20 >= results.length; + counter.textContent = `Страница ${page + 1} из ${Math.max(1, Math.ceil(results.length / 20))} · Имплантов: ${results.length}`; + }; + previous.addEventListener('click', () => { if (page > 0) { page -= 1; renderPage(); } }); + next.addEventListener('click', () => { if ((page + 1) * 20 < results.length) { page += 1; renderPage(); } }); + renderPage(); + } catch (error) { + if (list.isConnected) list.innerHTML = ``; + } +} diff --git a/chrome-ledger/frontend/src/features/implants/reissue.js b/chrome-ledger/frontend/src/features/implants/reissue.js new file mode 100755 index 0000000..548bffc --- /dev/null +++ b/chrome-ledger/frontend/src/features/implants/reissue.js @@ -0,0 +1,96 @@ +import { api } from '../../shared/api/client.js'; +import { escapeHtml, setError, readOnlyField, showResultDialog } from '../../shared/ui/dom.js'; + +const view = document.querySelector('#view'); + +export function renderReissue(wanted = '', serial = '') { + view.innerHTML = `
+ +
+ + + + + +
+ +
+

Правила подписи

+

Вычислите SHA-256 от DER-представления подписанного CSR. Запишите хеш строчными шестнадцатеричными символами.

+

Подставьте ID импланта, серийный номер текущего сертификата и хеш в ASCII-строку без перевода строки в конце:

+ reissue:<ID импланта>:<серийный номер>:<SHA256(CSR_DER)> +

Подпишите строку текущим закрытым ключом импланта: ECDSA с SHA-256 или RSA PKCS#1 v1.5 с SHA-256

+

Преобразуйте полученную подпись в Base64 и вставьте её в поле «Подпись текущим ключом в base64»

+
+ +
+
+
+ +
+
`; + const form = document.querySelector('#reissue-form'); + const result = document.querySelector('#reissue-result'); + const problem = document.querySelector('#reissue-error'); + const rules = document.querySelector('#signature-rules'); + document.querySelector('#signature-rules-link').addEventListener('click', (event) => { + event.preventDefault(); + rules.showModal(); + }); + rules.querySelector('[data-close-dialog]').addEventListener('click', () => rules.close()); + form.addEventListener('submit', async (event) => { + event.preventDefault(); + const button = form.querySelector('button'); + button.disabled = true; + result.innerHTML = ''; + setError(problem, ''); + try { + const id = document.querySelector('#reissue-id').value.trim(); + const data = await api('/reissue/' + encodeURIComponent(id), { + method: 'POST', body: { csr_pem: document.querySelector('#reissue-csr').value.trim(), + certificate_serial: document.querySelector('#reissue-serial').value.trim(), + signature: document.querySelector('#reissue-signature').value.trim() }, + }); + const certificate = data.certificate; + result.innerHTML = ` +
+

Сертификат перевыпущен

+ ${[ + ['ID импланта', data.id], ['Название', data.display_name], ['Модель', data.model], + ['Владелец', data.owner], ['ID владельца', data.user_id], ['Создан', data.created_at], + ['Код проекта', data.project_codename], ['Код организации', data.installed_by], + ['Владелец сертификата', certificate.subject], ['Издатель', certificate.issuer], + ['Серийный номер', certificate.serial], ['Действует с', certificate.not_before], + ['Действует до', certificate.not_after], ['Статус', certificate.valid ? 'Действует' : 'Недействителен'], + ['SHA-256', certificate.fingerprint], + ].map(([label, value]) => readOnlyField(label, value, 1)).join('')} + ${readOnlyField('Сертификат (PEM)', data.cert_pem, 4)} +
+ +
+
+
`; + showResultDialog(result); + document.querySelector('#reissue-serial').value = certificate.serial; + document.querySelector('#reissue-signature').value = ''; + } catch (error) { + setError(problem, error.message); + } finally { + button.disabled = false; + } + }); +} diff --git a/chrome-ledger/frontend/src/shared/api/client.js b/chrome-ledger/frontend/src/shared/api/client.js new file mode 100755 index 0000000..868277c --- /dev/null +++ b/chrome-ledger/frontend/src/shared/api/client.js @@ -0,0 +1,34 @@ +import { state, setSession } from '../session.js'; + +export async function api(path, { method = 'GET', body } = {}) { + if (path !== '/login' && path !== '/register') path = '/home/api' + path; + const token = state.token; + let response; + try { + response = await fetch(path, { + method, + credentials: 'omit', + headers: { + ...(body === undefined ? {} : { 'Content-Type': 'application/json' }), + ...(token ? { Authorization: 'Bearer ' + token } : {}), + }, + body: body === undefined ? undefined : JSON.stringify(body), + }); + } catch { + throw new Error('Нет связи с Chrome Ledger'); + } + if (response.status === 204) return null; + const data = await response.json().catch(() => null); + if (!response.ok || data === null) { + if (response.status === 401 && token && state.token === token && data && data.error === 'Authentication required') { + setSession(null); + window.dispatchEvent(new Event('ledger:session-expired')); + } + if (data && data.error) { + throw new Error(data.error); + } + throw new Error('Сервис вернул неожиданный ответ'); + } + return data; +} + diff --git a/chrome-ledger/frontend/src/shared/session.js b/chrome-ledger/frontend/src/shared/session.js new file mode 100755 index 0000000..708644c --- /dev/null +++ b/chrome-ledger/frontend/src/shared/session.js @@ -0,0 +1,8 @@ +export const state = { user: null, token: sessionStorage.getItem('ledger-token') }; + +export function setSession(data) { + state.user = data ? { id: data.id, username: data.username } : null; + state.token = data ? data.access_token : null; + if (state.token) sessionStorage.setItem('ledger-token', state.token); + else sessionStorage.removeItem('ledger-token'); +} diff --git a/chrome-ledger/frontend/src/shared/styles/main.css b/chrome-ledger/frontend/src/shared/styles/main.css new file mode 100755 index 0000000..42b0618 --- /dev/null +++ b/chrome-ledger/frontend/src/shared/styles/main.css @@ -0,0 +1,476 @@ +:root { + color-scheme: dark; + font-family: var(--sans); + --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; + --text: #e8eef6; + --ink: #080b11; + --panel: #10151e; + --line: #303b4b; + --muted: #aeb9c8; + --accent: #9db2c9; + --accent-edge: #5b7794; + --signal: #89b1ad; + --danger: #d99cac; + color: var(--text); + background: var(--ink); + --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; + --gutter: clamp(16px, 4vw, 56px); +} + +*, *::before, *::after { box-sizing: border-box; } +body { margin: 0; min-width: 280px; } +button, input, textarea, select { font: inherit; } +a { color: inherit; } +[hidden] { display: none !important; } + +.layout { + min-height: 100vh; + background: + radial-gradient(ellipse at 97% 53%, #32293d49, transparent 42%), + radial-gradient(ellipse at 70% 12%, #1b313e65, transparent 45%), + linear-gradient(#9db2c909 1px, transparent 1px), + linear-gradient(90deg, #9db2c909 1px, transparent 1px), + var(--ink); + background-size: auto, auto, 44px 44px, 44px 44px, auto; +} + +.topbar { + position: sticky; + top: 0; + z-index: 10; + border-bottom: 1px solid var(--line); + background: #0c1018f5; + backdrop-filter: blur(12px); +} + +.topbar-inner { + max-width: 1440px; + min-height: 74px; + margin-inline: auto; + padding-inline: var(--gutter); + display: flex; + align-items: center; + gap: clamp(16px, 4vw, 54px); +} + +.brand { + display: inline-flex; + align-items: center; + gap: 11px; + color: var(--accent); + font: 21px var(--mono); + letter-spacing: -.07em; + text-decoration: none; + white-space: nowrap; +} + +.brand-mark { + display: grid; + place-items: center; + flex: 0 0 auto; + width: 25px; + height: 25px; + background: var(--accent); + clip-path: polygon(23% 0, 100% 0, 100% 77%, 77% 100%, 0 100%, 0 23%); +} + +.brand-mark::after { + content: ''; + width: 15px; + height: 15px; + background: var(--ink); + clip-path: polygon(30% 0, 100% 0, 100% 29%, 44% 29%, 29% 44%, 29% 71%, 100% 71%, 100% 100%, 0 100%, 0 30%); +} + +#nav { display: flex; align-self: stretch; gap: 4px; align-items: stretch; } +#nav a { + display: grid; + align-content: center; + padding: 10px 12px; + border-block: 2px solid transparent; + color: var(--muted); + font: 14px var(--mono); + text-decoration: none; +} + +#nav a:hover { color: var(--signal); } +#nav a.active { + color: var(--signal); + border-bottom-color: var(--signal); + background: #89b1ad12; +} + +.account { + margin-left: auto; + display: flex; + align-items: center; + gap: 13px; + color: var(--muted); + font: 13px var(--mono); +} + +.account span { overflow-wrap: anywhere; min-width: 0; } +.account-login { color: var(--signal); font: 14px var(--mono); text-underline-offset: 4px; } + +.workspace { + width: min(100%, 1380px); + margin: 0 auto; + padding: clamp(32px, 5vw, 70px) var(--gutter) 64px; + display: grid; + grid-template-columns: minmax(0, 860px) minmax(260px, 360px); + gap: clamp(20px, 4vw, 58px); + align-items: start; +} + +.content { min-width: 0; } +.content > .error { margin-bottom: 15px; } +.signed-out .workspace { + grid-template-columns: minmax(0, 510px) minmax(0, 440px); + justify-content: center; + align-items: center; + min-height: calc(100vh - 75px); +} + +.circuit { + --trace: #89b1ad19; + position: sticky; + top: 24px; + display: grid; + place-items: center; + aspect-ratio: 4 / 5; + overflow: hidden; + border: 1px solid #3a555e; + background: + linear-gradient(135deg, #9db2c90a 0 39%, transparent 39% 75%, #77628418 75%), + repeating-linear-gradient(0deg, transparent 0 27px, var(--trace) 28px, transparent 29px), + repeating-linear-gradient(90deg, transparent 0 27px, var(--trace) 28px, transparent 29px), + radial-gradient(ellipse at 52% 46%, #20343e, #0b111b 68%); + clip-path: polygon(0 0, calc(100% - 30px) 0, 100% 30px, 100% 100%, 30px 100%, 0 calc(100% - 30px)); + isolation: isolate; +} + +.circuit::before, .circuit::after { + content: ''; + position: absolute; + inset: 14px; + pointer-events: none; +} + +.circuit::before { + border: 1px solid #89b1ad36; + background: + linear-gradient(90deg, var(--signal) 0 27px, transparent 27px) top left, + linear-gradient(270deg, var(--accent-edge) 0 32px, transparent 32px) bottom right; + background-size: 100% 2px; + background-repeat: no-repeat; +} + +.circuit::after { + inset: 25px; + border: 1px dashed #89b1ad2e; +} + +.chip { + z-index: 1; + display: grid; + place-items: center; + width: 48%; + aspect-ratio: 1; + transform: rotate(-24deg); + border: 1px solid #5d7f86; + background: #111923; + box-shadow: inset 0 0 25px #89b1ad20, 0 0 45px #89b1ad22, 7px 8px 0 #77628430; +} + +.chip::before, .chip::after { + content: ''; + position: absolute; + width: 140%; + height: 58%; + background: repeating-linear-gradient(0deg, var(--signal) 0 1px, transparent 1px 11px); + z-index: -1; + opacity: .38; +} + +.chip::after { transform: rotate(90deg); } +.chip span { + display: grid; + place-items: center; + width: 74%; + aspect-ratio: 1; + border: 1px solid #496d73; + background: #121d2a; + box-shadow: 0 0 0 4px #0a141e; +} + +.chip span::after { + content: ''; + width: 65%; + aspect-ratio: 1; + background: var(--accent-edge); + clip-path: polygon(27% 0, 100% 0, 100% 29%, 40% 29%, 29% 40%, 29% 71%, 100% 71%, 100% 100%, 0 100%, 0 27%); +} + +.scanline { + position: absolute; + z-index: 2; + inset: 12% 14px auto; + height: 2px; + opacity: 0; + background: linear-gradient(90deg, transparent, var(--signal), transparent); + box-shadow: 0 0 18px #89b1ad47; + animation: scan 8s ease-in-out infinite; +} + +@keyframes scan { + 0%, 15% { top: 12%; opacity: 0; } + 27% { opacity: .4; } + 65% { opacity: .4; } + 78%, 100% { top: 87%; opacity: 0; } +} + +h1, h2, p, dl { margin: 0; } +h1 { + font-size: clamp(34px, 4vw, 56px); + font-weight: 800; + line-height: .98; + letter-spacing: -.065em; + text-transform: uppercase; +} + +h1 span { display: block; color: var(--accent); } +h2 { font-size: 20px; font-weight: 800; } +.page-header { margin-bottom: 26px; } +.welcome { text-align: center; } +.page-header-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; } +.page-header-row .button-link { flex: 0 0 auto; margin-bottom: 4px; } +.intro { color: var(--muted); max-width: 62ch; margin-top: 14px; line-height: 1.6; } +.eyebrow { + margin-bottom: 11px; + color: var(--signal); + font: 700 13px/1.4 var(--mono); + letter-spacing: .04em; + text-transform: uppercase; +} +.eyebrow a { text-underline-offset: 4px; } +.mono { font-family: var(--mono); } +.valid { color: var(--signal); } +.invalid, .error { color: var(--danger); } +.error { overflow-wrap: anywhere; border-left: 2px solid var(--danger); padding-left: 10px; } +.muted { color: var(--muted); } + +.panel { + position: relative; + border: 1px solid var(--line); + border-top-color: #435568; + padding: clamp(16px, 2.15vw, 29px); + background: linear-gradient(135deg, #9db2c908, transparent 55%), var(--panel); + box-shadow: 5px 5px 0 #070910; +} + +.panel::before { + content: ''; + position: absolute; + top: -1px; + left: -1px; + width: 64px; + height: 2px; + background: var(--signal); + pointer-events: none; +} + +.panel::after { + content: ''; + position: absolute; + inset: auto -1px -1px auto; + width: 45px; + height: 11px; + background: repeating-linear-gradient(125deg, var(--accent-edge) 0 2px, transparent 2px 6px); + pointer-events: none; +} + +.panel + .panel { margin-top: 21px; } +.record-list { margin-top: 24px; } +.record-list { display: grid; gap: 18px; } +.record-list .panel + .panel { margin-top: 0; } +.certificate-record { padding-top: 2px; } +.certificate-record + .certificate-record { padding-top: 22px; border-top: 1px solid var(--line); } +.certificate-record > summary { cursor: pointer; } +.certificate-record > summary .status { margin-left: 12px; vertical-align: middle; } +.certificate-record > .fields { margin-top: 17px; padding-left: 20px; } +#holder-error { margin-top: 16px; } +.fields { display: grid; gap: 17px; min-width: 0; } +.fields > label, .readonly-field { display: grid; gap: 8px; min-width: 0; } +.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; } +.field-grid > label { display: grid; gap: 8px; } +label { font-size: 14px; font-weight: 600; } +small { color: var(--muted); font: 400 13px/1.45 var(--sans); } +.optional { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; } + +input, textarea, select { + width: 100%; + min-width: 0; + background: #0b1019; + border: 1px solid var(--line); + border-left: 2px solid #486071; + border-radius: 0; + color: var(--text); + padding: 11px 12px; + line-height: 1.5; + transition: border-color .16s, background-color .16s; +} + +input::placeholder, textarea::placeholder { color: #929fb3; } +textarea { display: block; resize: vertical; overflow-wrap: anywhere; } +textarea.mono, input.mono, select.mono { font-size: 13px; } +textarea[readonly] { background: #0f1724; } +select { + appearance: none; + padding-right: 42px; + background-image: + linear-gradient(45deg, transparent 50%, var(--muted) 50%), + linear-gradient(135deg, var(--muted) 50%, transparent 50%); + background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; + background-size: 5px 5px; + background-repeat: no-repeat; +} +input:focus, textarea:focus, select:focus { border-color: var(--signal); background: #101923; } +:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; } + +button, .button-link { + position: relative; + border: 1px solid var(--accent-edge); + border-radius: 0; + padding: 10px 15px; + font-weight: 800; + font-size: 13px; + background: #2b4056; + color: var(--text); + cursor: pointer; + transition: color .16s, background-color .16s, box-shadow .16s; +} + +button:hover, .button-link:hover { background: #36516b; box-shadow: 3px 3px 0 #151f2b; } +button:disabled { opacity: .64; cursor: wait; } +button.secondary { background: #121a25; border-color: #486071; color: var(--accent); } +button.secondary:hover { background: #1c2a38; box-shadow: none; } +.button-link { display: inline-block; text-decoration: none; } +.text-link { color: var(--signal); font: 14px var(--mono); text-underline-offset: 4px; } +.text-link:hover { color: var(--accent); } + +.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; } +.public-actions { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 20px; } +.details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 12px 20px; font-size: 14px; } +.details dt { color: var(--muted); } +.details dd { margin: 0; overflow-wrap: anywhere; } +.compact-details { padding-top: 15px; border-top: 1px solid var(--line); } +.record-heading, .result-heading { + display: flex; + justify-content: space-between; + align-items: start; + gap: 18px; +} +.record-heading p { margin-top: 7px; color: var(--muted); } +.status { + display: inline-flex; + flex: 0 0 auto; + align-items: center; + min-height: 28px; + padding: 4px 9px; + border: 1px solid var(--line); + font: 700 12px var(--mono); +} +.status-valid { color: #a9d7d1; border-color: #466d6b; background: #142523; } +.status-invalid { color: #efb4c2; border-color: #754553; background: #28181e; } +.counter { + min-width: 28px; + padding: 4px 8px; + text-align: center; + border: 1px solid var(--line); + color: var(--muted); + font: 13px var(--mono); +} +.notice { + padding: 12px 14px; + border-left: 2px solid var(--accent-edge); + background: #172130; + color: #cbd6e4; + font-size: 14px; + line-height: 1.5; +} +.success-message { color: #b8d8d4; line-height: 1.5; } +.empty-state { padding-block: 34px; } +.loading { color: var(--muted); } +.steps { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 1px; + margin: 0 0 21px; + padding: 1px; + list-style-position: inside; + background: var(--line); +} +.steps li { padding: 13px 14px; background: #0d131c; color: var(--muted); font-size: 13px; line-height: 1.45; } + +.issue-dialog { + width: min(760px, calc(100vw - 32px)); + max-width: none; + max-height: calc(100vh - 32px); + padding: 0; + border: 0; + color: var(--text); + background: transparent; +} + +.issue-dialog::backdrop { + background: #02050bcc; + backdrop-filter: blur(4px); +} + +.issue-dialog > .panel { + max-height: calc(100vh - 32px); + overflow: auto; +} + +@media (max-width: 900px) { + .topbar-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; min-height: 64px; } + #nav { grid-row: 2; grid-column: 1 / -1; flex-wrap: wrap; } + #nav a { padding-inline: 8px; } + .brand, .account { margin-block: 12px; } + .workspace, .signed-out .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, .55fr); } + .signed-out .workspace { min-height: auto; } + .circuit { top: 16px; } +} + +@media (max-width: 650px) { + .workspace, .signed-out .workspace { position: relative; display: block; isolation: isolate; } + .content { position: relative; z-index: 1; } + .circuit { + width: 125px; + position: absolute; + top: 14px; + right: var(--gutter); + opacity: .29; + pointer-events: none; + mask-image: linear-gradient(225deg, #000, transparent 86%); + } + .circuit::before, .circuit::after { inset: 7px; } + .scanline { display: none; } +} + +@media (max-width: 415px) { + .brand { min-width: 0; font-size: 17px; gap: 6px; line-height: 1.05; white-space: normal; } + .brand-mark { width: 20px; height: 20px; } + .brand-mark::after { width: 12px; height: 12px; } + .account { max-width: 46vw; gap: 7px; font-size: 12px; } + .account button { padding-inline: 9px; } + #nav a { font-size: 11px; padding-inline: 6px; } + h1 { font-size: clamp(27px, 9vw, 32px); } + .details { grid-template-columns: minmax(0, 1fr); gap: 3px; } + .details dd + dt { margin-top: 9px; } +} + +@media (prefers-reduced-motion: reduce) { + .scanline { animation: none; } + input, textarea, select, button { transition: none; } +} diff --git a/chrome-ledger/frontend/src/shared/ui/dom.js b/chrome-ledger/frontend/src/shared/ui/dom.js new file mode 100755 index 0000000..4f60bf5 --- /dev/null +++ b/chrome-ledger/frontend/src/shared/ui/dom.js @@ -0,0 +1,40 @@ +const dateFormat = new Intl.DateTimeFormat('ru-RU', { + dateStyle: 'medium', + timeStyle: 'short', + timeZone: 'UTC', +}); + +export function dateTime(value) { + return dateFormat.format(new Date(value)) + ' UTC'; +} + +export function escapeHtml(value) { + if (value === null || value === undefined) { + return ''; + } + return String(value).replace(/[&<>"']/g, (character) => ({ + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + })[character]); +} + +export function setError(element, message) { + element.textContent = message; + element.hidden = !message; +} + +export function readOnlyField(label, value, rows = 3) { + return ``; +} + +export function showResultDialog(container) { + const dialog = container.querySelector('dialog'); + dialog.querySelector('[data-close-dialog]').addEventListener('click', () => dialog.close()); + dialog.addEventListener('close', () => dialog.remove(), { once: true }); + dialog.showModal(); +} diff --git a/chrome-ledger/run.py b/chrome-ledger/run.py new file mode 100755 index 0000000..d710f0e --- /dev/null +++ b/chrome-ledger/run.py @@ -0,0 +1,31 @@ +from gunicorn.app.base import BaseApplication +from backend.app.bootstrap.factory import create_app + + +class LedgerApplication(BaseApplication): + def load_config(self): + settings = { + "bind": "0.0.0.0:8080", + "control_socket_disable": True, + "workers": 4, + "threads": 8, + "worker_class": "gthread", + "preload_app": True, + "timeout": 20, + "graceful_timeout": 10, + "keepalive": 5, + "backlog": 128, + "max_requests": 1000, + "max_requests_jitter": 100, + "accesslog": "-", + "errorlog": "-", + } + for key, value in settings.items(): + self.cfg.set(key, value) + + def load(self): + return create_app() + + +if __name__ == "__main__": + LedgerApplication().run() diff --git a/dark-tariff/Dockerfile b/dark-tariff/Dockerfile new file mode 100755 index 0000000..0c4b075 --- /dev/null +++ b/dark-tariff/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12.16-slim-bookworm + +WORKDIR /app + +COPY backend/requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY backend ./backend/ +COPY frontend ./frontend/ + +RUN useradd --uid 10001 --user-group --no-create-home --shell /usr/sbin/nologin darktariff + +USER darktariff + +CMD ["sh", "-c", "python -m backend.app.db.initialize && exec uvicorn backend.app.main:create_app --factory --host 0.0.0.0 --port 8080 --workers 4 --limit-concurrency 32"] diff --git a/dark-tariff/backend/app/api/routes/chat.py b/dark-tariff/backend/app/api/routes/chat.py new file mode 100755 index 0000000..ec11d9c --- /dev/null +++ b/dark-tariff/backend/app/api/routes/chat.py @@ -0,0 +1,24 @@ +from uuid import UUID + +from fastapi import APIRouter + +from backend.app.db import operations +from backend.app.api.schemas import CheckStart, CheckCommit, CheckAnswer + +router = APIRouter(prefix="/api/chat", tags=["chat"]) + +@router.get("/greeting") +async def greeting(): + return await operations.chat_greeting() + +@router.post("/checks", status_code=201) +async def check_start(body: CheckStart): + return await operations.check_start(body.reading_id) + +@router.post("/checks/{check_id}/commit") +async def check_commit(check_id: UUID, body: CheckCommit): + return await operations.check_commit(check_id, body.round, body.values) + +@router.post("/checks/{check_id}/answer") +async def check_answer(check_id: UUID, body: CheckAnswer): + return await operations.check_answer(check_id, body.round, body.data) diff --git a/dark-tariff/backend/app/api/routes/health.py b/dark-tariff/backend/app/api/routes/health.py new file mode 100755 index 0000000..c85a628 --- /dev/null +++ b/dark-tariff/backend/app/api/routes/health.py @@ -0,0 +1,9 @@ +from fastapi import APIRouter + +from backend.app.db import operations + +router = APIRouter(prefix="/api", tags=["system"]) + +@router.get("/health") +async def health(): + return {"ok": await operations.ping() == 1} diff --git a/dark-tariff/backend/app/api/routes/readings.py b/dark-tariff/backend/app/api/routes/readings.py new file mode 100755 index 0000000..ce9ba95 --- /dev/null +++ b/dark-tariff/backend/app/api/routes/readings.py @@ -0,0 +1,22 @@ +from fastapi import APIRouter + +from backend.app.db import operations +from backend.app.api.schemas import ReadingIn + +router = APIRouter(prefix="/api", tags=["readings"]) + +@router.get("/resources") +async def resources(): + return await operations.resources() + +@router.get("/readings") +async def readings(): + return await operations.readings() + +@router.get("/readings/{reading_id}") +async def reading_public(reading_id: int): + return await operations.reading_public(reading_id) + +@router.post("/readings", status_code=201) +async def reading_add(body: ReadingIn): + return await operations.add_reading(body.serial, body.kind, body.model_dump(mode="json")["metrics"]) diff --git a/dark-tariff/backend/app/api/routes/receipts.py b/dark-tariff/backend/app/api/routes/receipts.py new file mode 100755 index 0000000..b0485ef --- /dev/null +++ b/dark-tariff/backend/app/api/routes/receipts.py @@ -0,0 +1,14 @@ +from fastapi import APIRouter + +from backend.app.db import operations +from backend.app.api.schemas import ReceiptOpen + +router = APIRouter(prefix="/api/receipts", tags=["receipts"]) + +@router.get("") +async def receipts(): + return await operations.receipts() + +@router.post("/{receipt_id}/open") +async def receipt_open(receipt_id: int, body: ReceiptOpen): + return await operations.open_receipt(receipt_id, body.calculation_id) diff --git a/dark-tariff/backend/app/api/routes/reports.py b/dark-tariff/backend/app/api/routes/reports.py new file mode 100755 index 0000000..46d7464 --- /dev/null +++ b/dark-tariff/backend/app/api/routes/reports.py @@ -0,0 +1,36 @@ +import csv +import io + +from fastapi import APIRouter, Query +from fastapi.responses import Response + +from backend.app.api.schemas import ReportQueryIn +from backend.app.db import operations +from backend.app.db.connection import QueryError + +router = APIRouter(prefix="/api/reports", tags=["reports"]) + +@router.get("/finance/fields") +async def finance_fields(): + return await operations.report_fields("finance") + +@router.get("/finance/summary") +async def finance_summary(period: str | None = None, fields: list[str] = Query(default=[]), + sort: str = "", group_by: str = "", filter: str = "", having: str = ""): + selected = [field.strip() for item in fields for field in item.split(",") if field.strip()] + return await operations.finance_report(period, selected, sort, group_by, filter, having) + +@router.post("/export") +async def export_report(body: ReportQueryIn): + fields = body.fields + if not fields: + fields = [field["id"] for field in await operations.report_fields(body.report)] + if not fields: + raise QueryError("P0400", "Unknown report type.") + report = await operations.finance_report(body.period, fields, body.sort, body.group_by, body.filter, body.having) + output = io.StringIO(newline="") + writer = csv.writer(output) + writer.writerow([column["title"] for column in report["columns"]]) + writer.writerows(report["rows"]) + return Response(output.getvalue(), media_type="text/csv; charset=utf-8", + headers={"Content-Disposition": f'attachment; filename="finance-{report["period"]}.csv"'}) diff --git a/dark-tariff/backend/app/api/schemas.py b/dark-tariff/backend/app/api/schemas.py new file mode 100755 index 0000000..b80021f --- /dev/null +++ b/dark-tariff/backend/app/api/schemas.py @@ -0,0 +1,43 @@ +from decimal import Decimal + +from pydantic import BaseModel, ConfigDict, Field + +class ReadingIn(BaseModel): + model_config = ConfigDict(extra="forbid", allow_inf_nan=False) + + serial: str = Field(min_length=1, max_length=128) + kind: str = Field(min_length=1, max_length=16) + metrics: dict[str, Decimal] = Field(min_length=4, max_length=4) + +class CheckStart(BaseModel): + model_config = ConfigDict(extra="forbid") + + reading_id: int = Field(gt=0) + +class CheckCommit(BaseModel): + model_config = ConfigDict(extra="forbid") + + round: int = Field(ge=1, le=10) + values: list[str] = Field(min_length=3, max_length=3) + +class CheckAnswer(BaseModel): + model_config = ConfigDict(extra="forbid") + + round: int = Field(ge=1, le=10) + data: dict = Field(min_length=2, max_length=2) + +class ReceiptOpen(BaseModel): + model_config = ConfigDict(extra="forbid", str_strip_whitespace=True) + + calculation_id: str = Field(min_length=44, max_length=44, pattern=r"^[A-Za-z0-9+/]{43}=$") + +class ReportQueryIn(BaseModel): + model_config = ConfigDict(extra="forbid") + + report: str + period: str + fields: list[str] = [] + sort: str = "" + group_by: str = "" + filter: str = "" + having: str = "" diff --git a/dark-tariff/backend/app/db/bootstrap.py b/dark-tariff/backend/app/db/bootstrap.py new file mode 100755 index 0000000..9e5e553 --- /dev/null +++ b/dark-tariff/backend/app/db/bootstrap.py @@ -0,0 +1,18 @@ +from pathlib import Path + +SQL = Path(__file__).resolve().parents[2] / "database" / "sql" + +FILES = ( + "schema/billing.sql", + "schema/receipts.sql", + "schema/checks.sql", + "schema/reports.sql", + "functions/checks.sql", + "functions/billing.sql", + "functions/receipts.sql", + "functions/chat.sql", + "functions/reports.sql", +) + +def sql(): + return "\n".join((SQL / name).read_text(encoding="utf-8") for name in FILES) diff --git a/dark-tariff/backend/app/db/connection.py b/dark-tariff/backend/app/db/connection.py new file mode 100755 index 0000000..ac792a7 --- /dev/null +++ b/dark-tariff/backend/app/db/connection.py @@ -0,0 +1,43 @@ +import os + +from typing import Any + +import psycopg + +from psycopg_pool import AsyncConnectionPool + +DSN = os.environ.get( + "DATABASE_URL", "postgresql://billing:billing@127.0.0.1:5432/billing" +) + +pool: AsyncConnectionPool + +class QueryError(Exception): + def __init__(self, sqlstate: str, message: str): + super().__init__(message) + self.sqlstate = sqlstate + self.message = message + +def query_error(exc: psycopg.Error) -> QueryError: + message = getattr(exc.diag, "message_primary", None) or str(exc).splitlines()[0] + return QueryError(exc.sqlstate or "", message) + +async def open_pool(): + global pool + pool = AsyncConnectionPool( + DSN, min_size=1, max_size=8, open=False, kwargs={"autocommit": True}, + check=AsyncConnectionPool.check_connection, + ) + await pool.open(wait=True) + +async def close_pool(): + await pool.close() + +async def call(sql: str, params: tuple = ()) -> Any: + try: + async with pool.connection() as connection: + cursor = await connection.execute(sql, params) + row = await cursor.fetchone() + except psycopg.Error as exc: + raise query_error(exc) from None + return row[0] if row else None diff --git a/dark-tariff/backend/app/db/initialize.py b/dark-tariff/backend/app/db/initialize.py new file mode 100755 index 0000000..fd9274a --- /dev/null +++ b/dark-tariff/backend/app/db/initialize.py @@ -0,0 +1,27 @@ +import asyncio + +import psycopg + +from backend.app.db import bootstrap +from backend.app.db.connection import DSN + +STARTUP_ATTEMPTS = 10 +STARTUP_DELAY = 1.0 + +async def initialize(): + for attempt in range(1, STARTUP_ATTEMPTS + 1): + try: + async with await psycopg.AsyncConnection.connect(DSN, autocommit=True, connect_timeout=5) as db: + async with db.transaction(): + await db.execute("select pg_advisory_xact_lock(hashtextextended('dark-tariff:bootstrap', 0))") + await db.execute(bootstrap.sql()) + return + except psycopg.OperationalError as error: + if error.sqlstate and not (error.sqlstate.startswith("08") or error.sqlstate in {"40001", "40P01", "55P03"}): + raise + if attempt == STARTUP_ATTEMPTS: + raise + await asyncio.sleep(STARTUP_DELAY) + +if __name__ == "__main__": + asyncio.run(initialize()) diff --git a/dark-tariff/backend/app/db/operations.py b/dark-tariff/backend/app/db/operations.py new file mode 100755 index 0000000..31418b7 --- /dev/null +++ b/dark-tariff/backend/app/db/operations.py @@ -0,0 +1,75 @@ +import asyncio +import base64 +import secrets + +import psycopg +from argon2.low_level import Type, hash_secret_raw +from psycopg.types.json import Jsonb + +from backend.app.db import connection +from backend.app.db.connection import call + +async def resources(): + return await call("select billing.resource_types()") + +async def readings(): + return await call("select billing.reading_list()") + +async def reading_public(reading_id): + return await call("select billing.reading_public(%s::bigint)", (reading_id,)) + +def calculation_key(reading_id): + value = f"{reading_id}|{secrets.randbelow(10000):04d}".encode("ascii") + key = hash_secret_raw(value, bytes(16), time_cost=1, memory_cost=8192, + parallelism=1, hash_len=32, type=Type.ID, version=19) + return base64.b64encode(key).decode("ascii") + +async def add_reading(serial, kind, metrics): + try: + async with connection.pool.connection() as db: + async with db.transaction(): + cursor = await db.execute( + "select billing.reading_add(%s::text, %s::text, %s::jsonb)", + (serial, kind, Jsonb(metrics)), + ) + reading = (await cursor.fetchone())[0] + key = await asyncio.to_thread(calculation_key, reading["id"]) + cursor = await db.execute( + "select billing.receipt_issue(r, %s::text)" + " from billing.reading r where r.id = %s::bigint", + (key, reading["id"]), + ) + return reading | (await cursor.fetchone())[0] | {"calculation_id": key} + except psycopg.Error as exc: + raise connection.query_error(exc) from None + +async def ping(): + return await call("select 1") + +async def chat_greeting(): + return await call("select chat.greeting()") + +async def check_start(reading_id): + return await call("select chat.check_start(%s::bigint)", (reading_id,)) + +async def check_commit(check_id, round, values): + return await call("select chat.check_commit(%s::uuid, %s::int, %s::text[])", (check_id, round, values)) + +async def check_answer(check_id, round, data): + return await call("select chat.check_answer(%s::uuid, %s::int, %s::jsonb)", (check_id, round, Jsonb(data))) + +async def receipts(): + return await call("select billing.receipt_list()") + +async def open_receipt(receipt_id, calculation_id): + return await call("select billing.receipt_open(%s::bigint, %s::text)", (receipt_id, calculation_id)) + +async def report_fields(report): + return await call("select billing.report_fields(%s::text)", (report,)) + +async def finance_report(period=None, fields=None, sort="", group_by="", filter="", having=""): + return await call( + "select jsonb_build_object('period', coalesce(%s::text, to_char(current_date, 'YYYY-MM')))" + " || billing.finance_report(%s::text, %s::text[], %s::text, %s::text, %s::text, %s::text)", + (period, period, fields or [], sort, group_by, filter, having), + ) diff --git a/dark-tariff/backend/app/main.py b/dark-tariff/backend/app/main.py new file mode 100755 index 0000000..0f3829a --- /dev/null +++ b/dark-tariff/backend/app/main.py @@ -0,0 +1,63 @@ +from contextlib import asynccontextmanager + +from pathlib import Path + +from fastapi import FastAPI +from fastapi.responses import FileResponse, JSONResponse +from fastapi.staticfiles import StaticFiles + +from backend.app.db.connection import QueryError, close_pool, open_pool +from backend.app.api.routes import readings, receipts, health, chat, reports + +FRONTEND = Path(__file__).resolve().parents[2] / "frontend" + +STATUS = { + "P0400": 400, + "P0403": 403, + "P0404": 404, + "P0409": 409, +} + +@asynccontextmanager +async def lifespan(_: FastAPI): + await open_pool() + yield + await close_pool() + +def create_app() -> FastAPI: + app = FastAPI( + title="dark-tariff", + lifespan=lifespan, + docs_url=None, + redoc_url=None, + openapi_url=None, + max_body_size=65536, + ) + + for router in (readings.router, receipts.router, health.router, chat.router, reports.router): + app.include_router(router) + + @app.exception_handler(QueryError) + async def query_error(_, exc: QueryError): + status = STATUS.get(exc.sqlstate, 500) + return JSONResponse( + {"detail": exc.message if status != 500 else "The service could not process the request."}, + status_code=status, + ) + + app.mount("/static", StaticFiles(directory=FRONTEND), name="static") + + @app.middleware("http") + async def revalidate_static(request, call_next): + response = await call_next(request) + if request.url.path.startswith("/static/"): + response.headers["Cache-Control"] = "no-cache" + if request.url.path.startswith("/api/") and request.method == "POST": + response.headers["Cache-Control"] = "no-store" + return response + + @app.get("/", include_in_schema=False) + async def index(): + return FileResponse(FRONTEND / "public" / "index.html") + + return app diff --git a/dark-tariff/backend/database/sql/functions/billing.sql b/dark-tariff/backend/database/sql/functions/billing.sql new file mode 100755 index 0000000..c561881 --- /dev/null +++ b/dark-tariff/backend/database/sql/functions/billing.sql @@ -0,0 +1,109 @@ +create or replace function billing.resource_types() returns jsonb +language sql immutable as $$ + select '[ + {"id": "water", "title": "Вода", "tariff": {"metric": "volume_m3", "rate": "42.10", "unit": "м³"}, "metrics": [ + {"key": "volume_m3", "label": "Объём", "unit": "м³", "min": 0, "max": 999999999}, + {"key": "temperature_c", "label": "Температура", "unit": "°C", "min": -273.15, "max": 1000}, + {"key": "pressure_bar", "label": "Давление", "unit": "бар", "min": 0, "max": 999999999}, + {"key": "flow_m3h", "label": "Расход", "unit": "м³/ч", "min": 0, "max": 999999999} + ]}, + {"id": "air", "title": "Воздух", "tariff": {"metric": "volume_m3", "rate": "25.50", "unit": "м³"}, "metrics": [ + {"key": "volume_m3", "label": "Объём", "unit": "м³", "min": 0, "max": 999999999}, + {"key": "temperature_c", "label": "Температура", "unit": "°C", "min": -273.15, "max": 1000}, + {"key": "pressure_kpa", "label": "Давление", "unit": "кПа", "min": 0, "max": 999999999}, + {"key": "humidity_pct", "label": "Влажность", "unit": "%", "min": 0, "max": 100} + ]}, + {"id": "power", "title": "Электроэнергия", "tariff": {"metric": "energy_kwh", "rate": "7.35", "unit": "кВт⋅ч"}, "metrics": [ + {"key": "energy_kwh", "label": "Энергия", "unit": "кВт⋅ч", "min": 0, "max": 999999999}, + {"key": "voltage_v", "label": "Напряжение", "unit": "В", "min": 0, "max": 999999999}, + {"key": "current_a", "label": "Сила тока", "unit": "А", "min": 0, "max": 999999999}, + {"key": "frequency_hz", "label": "Частота", "unit": "Гц", "min": 0, "max": 999999999} + ]}, + {"id": "heat", "title": "Тепло", "tariff": {"metric": "energy_gcal", "rate": "2300.00", "unit": "Гкал"}, "metrics": [ + {"key": "energy_gcal", "label": "Тепловая энергия", "unit": "Гкал", "min": 0, "max": 999999999}, + {"key": "volume_m3", "label": "Объём теплоносителя", "unit": "м³", "min": 0, "max": 999999999}, + {"key": "supply_temperature_c", "label": "Температура подачи", "unit": "°C", "min": -273.15, "max": 1000}, + {"key": "return_temperature_c", "label": "Температура обратки", "unit": "°C", "min": -273.15, "max": 1000} + ]}, + {"id": "waste", "title": "Отходы", "tariff": {"metric": "mass_kg", "rate": "12.00", "unit": "кг"}, "metrics": [ + {"key": "mass_kg", "label": "Масса", "unit": "кг", "min": 0, "max": 999999999}, + {"key": "volume_m3", "label": "Объём", "unit": "м³", "min": 0, "max": 999999999}, + {"key": "density_kg_m3", "label": "Плотность", "unit": "кг/м³", "min": 0, "max": 999999999}, + {"key": "humidity_pct", "label": "Влажность", "unit": "%", "min": 0, "max": 100} + ]} + ]'::jsonb +$$; + +create or replace function billing.reading_list() returns jsonb +language sql stable as $$ + select coalesce(jsonb_agg(jsonb_build_object('id', r.id, 'parameters', r.parameters) order by r.created_at desc, r.id desc), '[]'::jsonb) + from billing.reading r +$$; + +create or replace function billing.reading_public(p_id bigint) returns jsonb +language plpgsql stable as $$ +declare + v_reading jsonb; +begin + select jsonb_build_object('id', r.id, 'parameters', r.parameters) into v_reading + from billing.reading r where r.id = p_id; + if not found then + raise exception 'Reading not found.' using errcode = 'P0404'; + end if; + return v_reading; +end; +$$; + +create or replace function billing.reading_add(p_serial text, p_kind text, p_metrics jsonb) +returns jsonb +language plpgsql as $$ +declare + v_resource jsonb; + v_metric jsonb; + v_text text; + v_value numeric; + v_metrics jsonb := '{}'::jsonb; + v_reading billing.reading; + v_parameters jsonb; +begin + if p_serial is null or btrim(p_serial) = '' or length(p_serial) > 128 then + raise exception 'Enter a meter serial ID between 1 and 128 characters.' using errcode = 'P0400'; + end if; + select item into v_resource + from jsonb_array_elements(billing.resource_types()) item + where item ->> 'id' = p_kind; + if v_resource is null then + raise exception 'Select a valid resource type.' using errcode = 'P0400'; + end if; + if jsonb_typeof(p_metrics) is distinct from 'object' then + raise exception 'Provide all four metrics for the selected resource type.' using errcode = 'P0400'; + end if; + if (select count(*) from jsonb_object_keys(p_metrics)) <> 4 + or not p_metrics ?& array(select item ->> 'key' from jsonb_array_elements(v_resource -> 'metrics') item) then + raise exception 'Provide all four metrics for the selected resource type.' using errcode = 'P0400'; + end if; + for v_metric in select * from jsonb_array_elements(v_resource -> 'metrics') loop + v_text := p_metrics ->> (v_metric ->> 'key'); + if v_text is null or length(v_text) > 32 then + raise exception 'All metrics are required and must be numeric.' using errcode = 'P0400'; + end if; + begin + v_value := v_text::numeric; + exception when invalid_text_representation or numeric_value_out_of_range then + raise exception 'All metrics are required and must be numeric.' using errcode = 'P0400'; + end; + if v_value not between (v_metric ->> 'min')::numeric and (v_metric ->> 'max')::numeric then + raise exception 'Metric "%" is out of range.', v_metric ->> 'key' using errcode = 'P0400'; + end if; + v_metrics := v_metrics || jsonb_build_object(v_metric ->> 'key', v_value); + end loop; + v_parameters := chat.make_parameters(); + insert into billing.reading (serial, kind, metrics, n, h, y, w, parameters) + values (btrim(p_serial), p_kind, v_metrics, (v_parameters ->> 'n')::integer, + array(select x::bit varying from jsonb_array_elements_text(v_parameters -> 'h') x), + (v_parameters ->> 'y')::bit varying, (v_parameters ->> 'w')::integer, + v_parameters ->> 'parameters') returning * into v_reading; + return jsonb_build_object('id', v_reading.id, 'parameters', v_reading.parameters, + 'verification_id', v_parameters ->> 'verification_id'); +end; +$$; diff --git a/dark-tariff/backend/database/sql/functions/chat.sql b/dark-tariff/backend/database/sql/functions/chat.sql new file mode 100755 index 0000000..4fe626b --- /dev/null +++ b/dark-tariff/backend/database/sql/functions/chat.sql @@ -0,0 +1,4 @@ +create or replace function chat.greeting() returns jsonb +language sql immutable as $$ + select jsonb_build_object('role', 'bot', 'text', 'Здравствуйте! Я умный помощник сервиса Dark Tariff. Чем могу помочь?', 'prompt', 'Введите ID показания.') +$$; diff --git a/dark-tariff/backend/database/sql/functions/checks.sql b/dark-tariff/backend/database/sql/functions/checks.sql new file mode 100755 index 0000000..6918fa0 --- /dev/null +++ b/dark-tariff/backend/database/sql/functions/checks.sql @@ -0,0 +1,204 @@ +create or replace function chat.pack(p_bits bit varying) returns bytea +language sql immutable strict as $$ + select substring(varbit_send(p_bits) from 5) +$$; + +create or replace function chat.dot(p_h bit varying[], p_v bit varying) returns bit varying +language sql immutable strict as $$ + select string_agg((bit_count(bits & p_v) % 2)::text, '' order by ord)::bit varying + from unnest(p_h) with ordinality as rows(bits, ord) +$$; + +create or replace function chat.permute(p_v bit varying, p_order integer[]) returns bit varying +language sql immutable strict as $$ + select string_agg(get_bit(p_v, pos)::text, '' order by ord)::bit varying + from unnest(p_order) with ordinality as positions(pos, ord) +$$; + +create or replace function chat.hash(p_text text) returns text +language sql immutable strict as $$ + select encode(digest(p_text, 'sha256'), 'hex') +$$; + +create or replace function chat.challenge() returns integer +language plpgsql volatile as $$ +declare + v integer; +begin + loop + v := get_byte(gen_random_bytes(1), 0); + exit when v < 200; + end loop; + v := v % 100; + return case when v < 70 then 0 when v < 95 then 1 else 2 end; +end; +$$; + +create or replace function chat.make_parameters() returns jsonb +language plpgsql volatile as $$ +declare + v_n integer := 1024; + v_m integer := 512; + v_w integer := 112; + v_s bit varying := repeat('0', v_n)::bit varying; + v_h bit varying[] := array[]::bit varying[]; + v_y bit varying; + v_row bit varying; + v_bytes bytea := ''::bytea; + v_params text; + v_pos integer; +begin + for v_pos in select i from generate_series(0, v_n - 1) i order by gen_random_bytes(16) limit v_w loop + v_s := set_bit(v_s, v_pos, 1); + end loop; + for v_pos in 0..v_m - 1 loop + v_row := set_bit(repeat('0', v_m)::bit varying, v_pos, 1) + || ('x' || encode(gen_random_bytes(v_m / 8), 'hex'))::bit varying; + v_h := array_append(v_h, v_row); + v_bytes := v_bytes || chat.pack(v_row); + end loop; + v_y := chat.dot(v_h, v_s); + v_params := replace(encode(convert_to(v_n::text || '|' || encode(v_bytes, 'hex') || '|' + || v_y::text || '|' || v_w::text, 'UTF8'), 'base64'), E'\n', ''); + return jsonb_build_object('n', v_n, 'h', to_jsonb(v_h), 'y', v_y::text, 'w', v_w, + 'parameters', v_params, + 'verification_id', replace(encode(chat.pack(v_s), 'base64'), E'\n', '')); +end; +$$; + +create or replace function chat.valid_response(p_reading billing.reading, p_values text[], p_challenge integer, p_data jsonb) +returns boolean +language plpgsql immutable as $$ +declare + v_text text := p_data ->> 'v'; + v_v bit varying; + v_t bit varying; + v_p integer[]; + v_a text; + v_b text; + v_c text; +begin + if jsonb_typeof(p_data) is distinct from 'object' or v_text is null + or length(v_text) <> p_reading.n or v_text !~ '^[01]+$' then + return false; + end if; + if (select count(*) from jsonb_object_keys(p_data)) <> 2 then + return false; + end if; + v_v := v_text::bit varying; + if p_challenge in (0, 1) then + if jsonb_typeof(p_data -> 'p') is distinct from 'array' then + return false; + end if; + if jsonb_array_length(p_data -> 'p') <> p_reading.n + or exists (select 1 from jsonb_array_elements(p_data -> 'p') x + where jsonb_typeof(x) <> 'number' or x::text !~ '^(0|[1-9][0-9]{0,4})$') then + return false; + end if; + select array_agg(x::text::integer order by ord) into v_p + from jsonb_array_elements(p_data -> 'p') with ordinality as positions(x, ord); + if (select count(distinct x) from unnest(v_p) x) <> p_reading.n + or (select min(x) from unnest(v_p) x) <> 0 + or (select max(x) from unnest(v_p) x) <> p_reading.n - 1 then + return false; + end if; + v_a := chat.hash('a|' || array_to_string(v_p, ',') || '|' + || (chat.dot(p_reading.h, v_v) # case when p_challenge = 1 then p_reading.y + else repeat('0', bit_length(p_reading.y))::bit varying end)::text); + if p_challenge = 0 then + v_b := chat.hash('b|' || chat.permute(v_v, v_p)::text); + return v_a = p_values[1] and v_b = p_values[2]; + end if; + v_c := chat.hash('c|' || chat.permute(v_v, v_p)::text); + return v_a = p_values[1] and v_c = p_values[3]; + elsif p_challenge = 2 then + v_text := p_data ->> 't'; + if v_text is null or length(v_text) <> p_reading.n or v_text !~ '^[01]+$' then + return false; + end if; + v_t := v_text::bit varying; + return bit_count(v_t) = p_reading.w + and chat.hash('b|' || v_v::text) = p_values[2] + and chat.hash('c|' || (v_v # v_t)::text) = p_values[3]; + end if; + return false; +end; +$$; + +create or replace function chat.check_start(p_reading bigint) returns jsonb +language plpgsql as $$ +declare + v_id uuid; +begin + perform 1 from billing.reading where id = p_reading and created_at > now() - interval '10 minutes' for key share; + if not found then + raise exception 'Reading not found.' using errcode = 'P0404'; + end if; + insert into chat.check_session (reading_id) values (p_reading) returning id into v_id; + return jsonb_build_object('id', v_id, 'round', 1, 'stage', 'commit', + 'message', 'Step 1 of 10. Submit three values.'); +end; +$$; + +create or replace function chat.check_commit(p_id uuid, p_round integer, p_values text[]) returns jsonb +language plpgsql as $$ +declare + v_session chat.check_session; + v_challenge integer; +begin + select * into v_session from chat.check_session where id = p_id for update; + if not found then + raise exception 'Verification not found.' using errcode = 'P0404'; + end if; + if v_session.complete or v_session.round <> p_round or v_session.challenge is not null then + raise exception 'This step is already complete or awaiting an answer.' using errcode = 'P0409'; + end if; + if cardinality(p_values) is distinct from 3 + or exists (select 1 from unnest(p_values) x where x is null or x !~ '^[0-9a-f]{64}$') then + raise exception 'Invalid data format.' using errcode = 'P0400'; + end if; + v_challenge := chat.challenge(); + update chat.check_session set data = p_values, challenge = v_challenge where id = p_id; + return jsonb_build_object('round', p_round, 'stage', 'answer', 'challenge', v_challenge, + 'message', format('Step %s of 10. Challenge: %s. Submit an answer.', p_round, v_challenge)); +end; +$$; + +create or replace function chat.check_answer(p_id uuid, p_round integer, p_data jsonb) returns jsonb +language plpgsql as $$ +declare + v_session chat.check_session; + v_reading billing.reading; +begin + select * into v_session from chat.check_session where id = p_id for update; + if not found then + raise exception 'Verification not found.' using errcode = 'P0404'; + end if; + if v_session.complete or v_session.round <> p_round or v_session.challenge is null then + raise exception 'This step is already complete or awaiting data.' using errcode = 'P0409'; + end if; + select * into v_reading from billing.reading + where id = v_session.reading_id and created_at > now() - interval '10 minutes'; + if not found then + delete from chat.check_session where id = p_id; + return jsonb_build_object('stage', 'failed', 'message', 'The reading is no longer available.'); + end if; + if not coalesce(chat.valid_response(v_reading, v_session.data, v_session.challenge, p_data), false) then + delete from chat.check_session where id = p_id; + return jsonb_build_object('stage', 'failed', 'message', 'Verification failed. Try again.'); + end if; + if p_round = 10 then + update chat.check_session set complete = true, challenge = null, data = null where id = p_id; + return jsonb_build_object('stage', 'done', 'reading_id', v_reading.id, + 'message', 'Verification complete.', + 'reading', jsonb_build_object('id', v_reading.id, 'serial', v_reading.serial, + 'kind', v_reading.kind, 'metrics', v_reading.metrics, + 'created_at', v_reading.created_at)); + end if; + update chat.check_session set round = p_round + 1, challenge = null, data = null where id = p_id; + return jsonb_build_object('round', p_round + 1, 'stage', 'commit', + 'message', format('Step %s of 10. Submit three values.', p_round + 1)); +end; +$$; + +drop function if exists chat.check_file(uuid); diff --git a/dark-tariff/backend/database/sql/functions/receipts.sql b/dark-tariff/backend/database/sql/functions/receipts.sql new file mode 100755 index 0000000..a77b4cc --- /dev/null +++ b/dark-tariff/backend/database/sql/functions/receipts.sql @@ -0,0 +1,47 @@ +create or replace function billing.receipt_issue(p_reading billing.reading, p_key text) returns jsonb +language plpgsql as $$ +declare + v_tariff jsonb; + v_quantity numeric; + v_rate numeric(12, 2); + v_total numeric(22, 2); + v_id bigint; +begin + select item -> 'tariff' into v_tariff + from jsonb_array_elements(billing.resource_types()) item where item ->> 'id' = p_reading.kind; + v_quantity := (p_reading.metrics ->> (v_tariff ->> 'metric'))::numeric; + v_rate := (v_tariff ->> 'rate')::numeric; + v_total := round(v_quantity * v_rate, 2); + insert into billing.receipt (reading_id, key_digest, data) + values (p_reading.id, digest(p_key, 'sha256'), jsonb_build_object( + 'reading', jsonb_build_object('id', p_reading.id, 'serial', p_reading.serial, 'kind', p_reading.kind, + 'metrics', p_reading.metrics, 'created_at', p_reading.created_at, 'parameters', p_reading.parameters), + 'calculation', jsonb_build_object('metric', v_tariff ->> 'metric', 'quantity', v_quantity, + 'unit', v_tariff ->> 'unit', 'unit_price', v_rate::text, 'amount', v_total::text, + 'currency', 'EDD', 'formula', 'quantity * unit_price') + )) returning id into v_id; + return jsonb_build_object('receipt_id', v_id); +end; +$$; + +create or replace function billing.receipt_list() returns jsonb +language sql stable as $$ + select coalesce(jsonb_agg(jsonb_build_object('id', id, 'created_at', created_at) + order by created_at desc, id desc), '[]'::jsonb) + from billing.receipt +$$; + +create or replace function billing.receipt_open(p_id bigint, p_key text) returns jsonb +language plpgsql stable as $$ +declare + v_receipt billing.receipt; +begin + select c.* into v_receipt from billing.receipt c join billing.reading r on r.id = c.reading_id + where c.id = p_id and r.created_at > now() - interval '10 minutes'; + if not found or p_key is null or digest(p_key, 'sha256') is distinct from v_receipt.key_digest then + raise exception 'Receipt unavailable. Check the receipt ID and calculation ID.' using errcode = 'P0403'; + end if; + return jsonb_build_object('id', v_receipt.id, 'reading_id', v_receipt.reading_id, + 'created_at', v_receipt.created_at) || v_receipt.data; +end; +$$; diff --git a/dark-tariff/backend/database/sql/functions/reports.sql b/dark-tariff/backend/database/sql/functions/reports.sql new file mode 100755 index 0000000..0a0b579 --- /dev/null +++ b/dark-tariff/backend/database/sql/functions/reports.sql @@ -0,0 +1,58 @@ +create or replace function billing.report_fields(p_report text) returns jsonb +language sql stable as $$ + select coalesce(jsonb_agg(jsonb_build_object('id', id, 'title', title) order by position, id), '[]'::jsonb) + from billing.report_field where report_types @> array[p_report] +$$; + +create or replace function billing.finance_report( + p_period text, p_fields text[], p_sort text, p_group_by text, p_filter text, p_having text +) returns jsonb +language plpgsql stable as $$ +declare + v_period text := coalesce(p_period, to_char(current_date, 'YYYY-MM')); + v_fields text[] := p_fields; + v_columns jsonb; + v_context text; + v_select text; + v_group text; + v_values text; + v_rows jsonb; +begin + if v_period !~ '^[0-9]{4}-(0[1-9]|1[0-2])$' or left(v_period, 4) = '0000' then + raise exception 'Invalid period. Use YYYY-MM.' using errcode = 'P0400'; + end if; + if coalesce(cardinality(v_fields), 0) = 0 then + select array_agg(id order by position, id) into v_fields + from billing.report_field where report_types @> array['finance']; + end if; + if exists (select 1 from unnest(v_fields) field where not exists ( + select 1 from billing.report_field where id = field and report_types @> array['finance'] + )) then + raise exception 'Unknown financial report column.' using errcode = 'P0400'; + end if; + select string_agg(format('%s as %I', expression, id), ', ' order by position, id) + into v_context from billing.report_field + where report_types @> array['finance'] and not aggregate; + select jsonb_agg(jsonb_build_object('id', id, 'title', title) order by position, id), + string_agg(format('%s as %I', case when aggregate then expression else format('dimensions.%I', id) end, id), ', ' order by position, id), + string_agg(format('dimensions.%I', id), ', ' order by position, id) filter (where not aggregate), + string_agg(format('report.%I', id), ', ' order by position, id) + into v_columns, v_select, v_group, v_values + from billing.report_field where id = any(v_fields) and report_types @> array['finance']; + execute format( + 'select coalesce(jsonb_agg(jsonb_build_array(%s)), ''[]''::jsonb) from ( + select %s from billing.receipt c join billing.reading r on r.id = c.reading_id + cross join lateral (select %s) dimensions + where to_char(r.created_at, ''YYYY-MM'') = $1 and (%s) + group by %s having (%s) order by %s + ) report', v_values, v_select, v_context, + coalesce(nullif(btrim(p_filter), ''), 'true'), + concat_ws(', ', coalesce(nullif(btrim(p_group_by), ''), 'period, resource, tariff'), v_group), + coalesce(nullif(btrim(p_having), ''), 'true'), + coalesce(nullif(btrim(p_sort), ''), 'resource') + ) into v_rows using v_period; + return jsonb_build_object('columns', v_columns, 'rows', v_rows); +exception when syntax_error_or_access_rule_violation or data_exception then + raise exception 'Invalid report expression.' using errcode = 'P0400'; +end; +$$; diff --git a/dark-tariff/backend/database/sql/schema/billing.sql b/dark-tariff/backend/database/sql/schema/billing.sql new file mode 100755 index 0000000..1324dea --- /dev/null +++ b/dark-tariff/backend/database/sql/schema/billing.sql @@ -0,0 +1,22 @@ +create extension if not exists pgcrypto; + +create schema if not exists billing; + +create table if not exists billing.reading ( + id bigserial primary key, + serial text not null check (btrim(serial) <> '' and length(serial) <= 128), + kind text not null, + metrics jsonb not null check (jsonb_typeof(metrics) = 'object'), + created_at timestamptz not null default now(), + n integer not null, + h bit varying[] not null, + y bit varying not null, + w integer not null, + parameters text not null +); + +create index if not exists reading_created_at_idx + on billing.reading (created_at); + +create unique index if not exists reading_parameters_uniq + on billing.reading (digest(parameters, 'sha256')); diff --git a/dark-tariff/backend/database/sql/schema/checks.sql b/dark-tariff/backend/database/sql/schema/checks.sql new file mode 100755 index 0000000..24ee47c --- /dev/null +++ b/dark-tariff/backend/database/sql/schema/checks.sql @@ -0,0 +1,12 @@ +create schema if not exists chat; + +create table if not exists chat.check_session ( + id uuid primary key default gen_random_uuid(), + reading_id bigint not null references billing.reading (id) on delete cascade, + round integer not null default 1 check (round between 1 and 10), + challenge integer check (challenge between 0 and 2), + data text[], + complete boolean not null default false +); + +create index if not exists check_session_reading_idx on chat.check_session (reading_id); diff --git a/dark-tariff/backend/database/sql/schema/receipts.sql b/dark-tariff/backend/database/sql/schema/receipts.sql new file mode 100755 index 0000000..29cc249 --- /dev/null +++ b/dark-tariff/backend/database/sql/schema/receipts.sql @@ -0,0 +1,7 @@ +create table if not exists billing.receipt ( + id bigserial primary key, + reading_id bigint not null unique references billing.reading (id) on delete cascade, + created_at timestamptz not null default now(), + key_digest bytea not null check (octet_length(key_digest) = 32), + data jsonb not null +); diff --git a/dark-tariff/backend/database/sql/schema/reports.sql b/dark-tariff/backend/database/sql/schema/reports.sql new file mode 100755 index 0000000..4eded6c --- /dev/null +++ b/dark-tariff/backend/database/sql/schema/reports.sql @@ -0,0 +1,19 @@ +create table if not exists billing.report_field ( + id text primary key, + title text not null, + expression text not null, + aggregate boolean not null default false, + report_types text[] not null default '{}', + position integer not null, + created_at timestamptz not null default now() +); + +insert into billing.report_field (id, title, expression, aggregate, report_types, position) values + ('period', 'Период', $field$to_char(r.created_at, 'YYYY-MM')$field$, false, '{finance}', 10), + ('resource', 'Ресурс', $field$coalesce((select item->>'title' from jsonb_array_elements(billing.resource_types()) item where item->>'id' = r.kind), r.kind)$field$, false, '{finance}', 20), + ('tariff', 'Тариф', $field$(c.data->'calculation'->>'unit_price')::numeric$field$, false, '{finance}', 30), + ('quantity', 'Количество', $field$sum((c.data->'calculation'->>'quantity')::numeric)$field$, true, '{finance}', 40), + ('amount', 'Сумма', $field$sum((c.data->'calculation'->>'amount')::numeric)$field$, true, '{finance}', 50), + ('readings', 'Показаний', 'count(*)', true, '{finance}', 60) +on conflict (id) do update set title = excluded.title, expression = excluded.expression, + aggregate = excluded.aggregate, report_types = excluded.report_types, position = excluded.position; diff --git a/dark-tariff/backend/requirements.txt b/dark-tariff/backend/requirements.txt new file mode 100755 index 0000000..75006a3 --- /dev/null +++ b/dark-tariff/backend/requirements.txt @@ -0,0 +1,21 @@ +annotated-types==0.8.0 +anyio==4.16.0 +argon2-cffi==25.1.0 +argon2-cffi-bindings==25.1.0 +cffi==2.0.0 +click==8.5.1 +fastapi==0.165.0 +h11==0.16.0 +httptools==0.9.0 +idna==3.20 +psycopg==3.2.13 +psycopg-binary==3.2.13 +psycopg-pool==3.2.8 +pycparser==2.23 +pydantic==2.14.4 +pydantic_core==2.50.5 +starlette==1.10.0 +typing-inspection==0.4.5 +typing_extensions==4.16.0 +uvicorn==0.34.3 +uvloop==0.23.0 diff --git a/dark-tariff/cleaner/Dockerfile b/dark-tariff/cleaner/Dockerfile new file mode 100755 index 0000000..dfa9379 --- /dev/null +++ b/dark-tariff/cleaner/Dockerfile @@ -0,0 +1,5 @@ +FROM postgres:16.16-bookworm + +COPY --chmod=755 cleaner.sh /cleaner.sh + +CMD ["/cleaner.sh"] diff --git a/dark-tariff/cleaner/cleaner.sh b/dark-tariff/cleaner/cleaner.sh new file mode 100755 index 0000000..bb0ed06 --- /dev/null +++ b/dark-tariff/cleaner/cleaner.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -eu + +while true; do + psql --no-psqlrc --set=ON_ERROR_STOP=1 <<'SQL' +delete from billing.reading +where created_at <= now() - interval '10 minutes'; +SQL + sleep 60 +done diff --git a/dark-tariff/compose.yml b/dark-tariff/compose.yml new file mode 100755 index 0000000..f5f876d --- /dev/null +++ b/dark-tariff/compose.yml @@ -0,0 +1,94 @@ +name: dark-tariff + +services: + db: + image: postgres:16.16-bookworm + command: ["postgres", "-c", "max_connections=64", "-c", "statement_timeout=5s", "-c", "lock_timeout=2s", "-c", "idle_in_transaction_session_timeout=5s"] + environment: + POSTGRES_USER: ${POSTGRES_USER:-billing} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-billing} + POSTGRES_DB: ${POSTGRES_DB:-billing} + volumes: + - data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-billing} -d ${POSTGRES_DB:-billing}"] + interval: 5s + timeout: 3s + retries: 12 + start_period: 10s + deploy: + resources: + limits: + cpus: "1.0" + memory: 512M + pids: 256 + stop_grace_period: 30s + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" + restart: unless-stopped + + cleaner: + build: ./cleaner + environment: + PGHOST: db + PGPORT: "5432" + PGUSER: ${POSTGRES_USER:-billing} + PGPASSWORD: ${POSTGRES_PASSWORD:-billing} + PGDATABASE: ${POSTGRES_DB:-billing} + PGOPTIONS: "-c statement_timeout=30s -c lock_timeout=5s" + depends_on: + service: + condition: service_healthy + deploy: + resources: + limits: + cpus: "0.25" + memory: 128M + pids: 64 + init: true + stop_grace_period: 10s + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" + restart: unless-stopped + + service: + build: . + environment: + DATABASE_URL: postgresql://${POSTGRES_USER:-billing}:${POSTGRES_PASSWORD:-billing}@db:5432/${POSTGRES_DB:-billing} + PYTHONDONTWRITEBYTECODE: "1" + PYTHONUNBUFFERED: "1" + ports: + - "0.0.0.0:8080:8080" + depends_on: + db: + condition: service_healthy + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/api/health', timeout=2).close()"] + interval: 10s + timeout: 3s + start_period: 10s + retries: 3 + deploy: + resources: + limits: + cpus: "1.0" + memory: 512M + pids: 256 + init: true + stop_grace_period: 10s + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" + restart: unless-stopped + +volumes: + data: + driver: local diff --git a/dark-tariff/env b/dark-tariff/env new file mode 100755 index 0000000..09c080f --- /dev/null +++ b/dark-tariff/env @@ -0,0 +1,3 @@ +POSTGRES_USER=billing +POSTGRES_PASSWORD=billing +POSTGRES_DB=billing diff --git a/dark-tariff/frontend/public/index.html b/dark-tariff/frontend/public/index.html new file mode 100755 index 0000000..9a6d993 --- /dev/null +++ b/dark-tariff/frontend/public/index.html @@ -0,0 +1,150 @@ + + + + + + Передать показания — Dark Tariff + + + +
+ +
+ +
+
+

Учёт ресурсов

+

Передавайте показания

+

Фиксируйте показания в новом сервисе Night City — Dark Tariff

+ + +
+ + + + +
+ + +
+

Передать показания

+ +
+
+ + +
+ + +
+
+ + +
+

Сохраните идентификаторы

+ +
+
+

Сохраните оба идентификатора. Они показываются только один раз: для проверки показания и открытия квитанции.

+

ID показания:

+

ID квитанции:

+ + +
+
+ + +
+

Квитанция

+ +
+
+ + + +
+ +
+ + +
+

Показание

+ +
+
+
+ + + + + + diff --git a/dark-tariff/frontend/src/api/client.js b/dark-tariff/frontend/src/api/client.js new file mode 100755 index 0000000..afcccd4 --- /dev/null +++ b/dark-tariff/frontend/src/api/client.js @@ -0,0 +1,34 @@ +function jsonPost(body) { + return { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }; +} + +function responseError(result, fallback) { + return new Error(typeof result.detail === "string" ? result.detail : fallback); +} + +export async function api(path, opts = {}) { + const response = await fetch(path, opts); + const result = await response.json(); + if (!response.ok) throw responseError(result, "Проверьте поля запроса."); + return result; +} + +export function post(path, body) { + return api(path, jsonPost(body)); +} + +export async function download(path, body, fallback) { + const response = await fetch(path, jsonPost(body)); + if (!response.ok) { + const result = await response.json(); + throw responseError(result, "Не удалось скачать отчёт."); + } + const url = URL.createObjectURL(await response.blob()); + const link = document.createElement("a"); + link.href = url; + link.download = response.headers.get("content-disposition")?.match(/filename="?([^";]+)"?/i)?.[1] || fallback; + document.body.append(link); + link.click(); + link.remove(); + URL.revokeObjectURL(url); +} diff --git a/dark-tariff/frontend/src/features/chat.js b/dark-tariff/frontend/src/features/chat.js new file mode 100755 index 0000000..f79ac9f --- /dev/null +++ b/dark-tariff/frontend/src/features/chat.js @@ -0,0 +1,115 @@ +import { api, post } from "../api/client.js"; +import { $, cell, note } from "../shared/dom.js"; + +export async function initChat(resourcesPromise) { + const launcher = $("#help-launcher"); + const chat = $("#help-chat"); + const close = $("#help-close"); + const question = $("#help-question"); + const form = $("#help-form"); + const input = $("#help-id"); + const data = $("#help-data"); + const messages = $(".help-messages"); + const dialog = $("#reading-result-dialog"); + const details = $("#reading-result-details"); + let greeting; + let stage = "id"; + let check; + let round; + + function message(text, kind = "") { + messages.append(cell("p", text, kind)); + messages.scrollTop = messages.scrollHeight; + } + function setOpen(open) { + chat.hidden = !open; + launcher.setAttribute("aria-expanded", String(open)); + (open ? close : launcher).focus(); + } + function finish() { + form.hidden = true; + form.reset(); + question.hidden = false; + check = null; + } + $("#reading-result-close").addEventListener("click", () => dialog.close()); + dialog.addEventListener("close", () => details.replaceChildren()); + launcher.addEventListener("click", () => setOpen(chat.hidden)); + close.addEventListener("click", () => setOpen(false)); + chat.addEventListener("keydown", (event) => { + if (event.key === "Escape") setOpen(false); + }); + question.addEventListener("click", () => { + stage = "id"; + form.reset(); + question.hidden = true; + form.hidden = false; + $("#help-note").hidden = true; + $("#help-id-label").hidden = false; + $("#help-data-label").hidden = true; + input.disabled = false; + data.disabled = true; + message(question.textContent, "help-user"); + message(greeting.prompt); + input.focus(); + }); + form.addEventListener("submit", async (event) => { + event.preventDefault(); + const button = event.submitter; + button.disabled = true; + $("#help-note").hidden = true; + try { + let result; + if (stage === "id") { + result = await post("/api/chat/checks", { reading_id: Number(input.value) }); + check = result.id; + input.disabled = true; + data.disabled = false; + $("#help-id-label").hidden = true; + $("#help-data-label").hidden = false; + } else { + let value; + try { value = JSON.parse(data.value); } + catch { throw new Error("Проверьте формат JSON."); } + result = await post(`/api/chat/checks/${check}/${stage === "commit" ? "commit" : "answer"}`, + stage === "commit" ? { round, values: value } : { round, data: value }); + } + stage = result.stage; + round = result.round; + data.value = ""; + message(result.message); + if (stage === "done") { + finish(); + const reading = result.reading; + const resource = (await resourcesPromise).find((item) => item.id === reading.kind); + const rows = [ + ["ID показания", reading.id], ["Дата показания", new Date(reading.created_at).toLocaleString("ru-RU")], + ["Серийный ID", reading.serial], ["Вид ресурса", resource.title], + ...resource.metrics.map((metric) => [metric.label, `${reading.metrics[metric.key]} ${metric.unit}`]), + ]; + details.replaceChildren(); + for (const [label, value] of rows) details.append(cell("dt", label), cell("dd", value)); + dialog.showModal(); + } else if (stage === "failed") { + finish(); + } else { + data.focus(); + } + } catch (error) { + note($("#help-note"), error.message, "err"); + } finally { + button.disabled = false; + } + }); + try { + greeting = await api("/api/chat/greeting"); + $("#help-message").textContent = greeting.text; + question.disabled = false; + } catch { + $("#help-message").textContent = "Не удалось загрузить сообщение. Обновите страницу."; + } + return () => { + setOpen(true); + if (!question.hidden) question.click(); + }; +} diff --git a/dark-tariff/frontend/src/features/finance.js b/dark-tariff/frontend/src/features/finance.js new file mode 100755 index 0000000..acae934 --- /dev/null +++ b/dark-tariff/frontend/src/features/finance.js @@ -0,0 +1,117 @@ +import { api, download } from "../api/client.js"; +import { $, cell, note } from "../shared/dom.js"; +import { onRoute } from "../shared/router.js"; + +export function initFinance() { + const period = $("#finance-period"); + const fields = $("#finance-fields"); + const sort = $("#finance-sort"); + const group = $("#finance-group"); + const filter = $("#finance-filter"); + const button = $("#finance-export"); + const table = $("#finance-table"); + const status = $("#finance-note"); + const money = new Intl.NumberFormat("ru-RU", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); + const today = new Date(); + period.value = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}`; + let loading = 0; + + function selected() { + return Array.from(fields.querySelectorAll("input:checked"), (input) => input.value); + } + + function query() { + const text = filter.value.trim().replace(/[\\%_]/g, "\\$&").replaceAll("'", "''"); + return { report: "finance", period: period.value, fields: selected(), sort: sort.value, + group_by: group.value, filter: text ? `resource ilike '%${text}%'` : "", having: "" }; + } + + function selectSort() { + const ids = selected(); + for (const option of sort.options) option.disabled = !ids.includes(option.value.split(" ")[0]); + if (sort.selectedOptions[0]?.disabled) sort.value = Array.from(sort.options).find((option) => !option.disabled)?.value || ""; + sort.disabled = !ids.length; + } + + function selectGroup() { + const dimensions = group.options[0].value.split(", "); + for (const input of fields.querySelectorAll("input")) { + if (dimensions.includes(input.value)) input.checked = group.value.split(", ").includes(input.value); + } + selectSort(); + } + + async function load() { + const request = ++loading; + button.disabled = true; + table.hidden = true; + note(status, "Загрузка…"); + try { + if (!fields.children.length) { + const catalogue = await api("/api/reports/finance/fields"); + if (request !== loading) return; + for (const field of catalogue) { + const label = document.createElement("label"); + const input = document.createElement("input"); + input.type = "checkbox"; + input.value = field.id; + input.checked = true; + label.append(input, cell("span", field.title)); + fields.append(label); + for (const direction of ["asc", "desc"]) { + const option = cell("option", `${field.title} ${direction === "asc" ? "↑" : "↓"}`); + option.value = `${field.id} ${direction}`; + sort.append(option); + } + } + sort.value = "resource asc"; + selectGroup(); + } + const data = query(); + if (!data.fields.length) return note(status, "Выберите хотя бы одну колонку."); + const params = new URLSearchParams({ period: data.period, sort: data.sort, group_by: data.group_by, filter: data.filter, having: data.having }); + for (const field of data.fields) params.append("fields", field); + const report = await api(`/api/reports/finance/summary?${params}`); + if (request !== loading) return; + const head = document.createElement("thead"); + const row = document.createElement("tr"); + for (const column of report.columns) { + const title = cell("th", column.title); + title.scope = "col"; + row.append(title); + } + head.append(row); + const body = document.createElement("tbody"); + for (const values of report.rows) { + const row = document.createElement("tr"); + report.columns.forEach((column, index) => row.append(cell("td", ["tariff", "amount"].includes(column.id) ? money.format(values[index]) : values[index]))); + body.append(row); + } + table.replaceChildren(head, body); + table.hidden = !report.rows.length; + status.hidden = report.rows.length > 0; + if (!report.rows.length) note(status, "За выбранный период показаний нет."); + button.disabled = false; + } catch (error) { + if (request === loading) note(status, error.message, "err"); + } + } + + period.addEventListener("change", load); + sort.addEventListener("change", load); + filter.addEventListener("input", load); + fields.addEventListener("change", () => { selectSort(); load(); }); + group.addEventListener("change", () => { selectGroup(); load(); }); + button.addEventListener("click", async () => { + const request = loading; + button.disabled = true; + try { + await download("/api/reports/export", query(), `finance-${period.value}.csv`); + } catch (error) { + note(status, error.message, "err"); + } finally { + if (request === loading) button.disabled = !selected().length; + } + }); + onRoute("finance", load); +} diff --git a/dark-tariff/frontend/src/features/readings.js b/dark-tariff/frontend/src/features/readings.js new file mode 100755 index 0000000..b3c2270 --- /dev/null +++ b/dark-tariff/frontend/src/features/readings.js @@ -0,0 +1,117 @@ +import { api, post } from "../api/client.js"; +import { $, cell, note } from "../shared/dom.js"; +import { navigateTo, onRoute } from "../shared/router.js"; + +export async function initReadings(resourcesPromise, chatPromise) { + const dialog = $("#reading-dialog"); + const form = $("#reading-form"); + const selector = form.elements.kind; + let resources; + try { + resources = await resourcesPromise; + } catch (error) { + note($("#page-note"), error.message, "err"); + note($("#history-note"), error.message, "err"); + return; + } + for (const resource of resources) { + const option = cell("option", resource.title); + option.value = resource.id; + selector.append(option); + } + + function renderFields() { + const fields = $("#metric-fields"); + fields.replaceChildren(); + const resource = resources.find((item) => item.id === selector.value); + if (!resource) return; + for (const metric of resource.metrics) { + const label = document.createElement("label"); + const input = document.createElement("input"); + input.type = "number"; + input.name = metric.key; + input.step = "any"; + input.min = metric.min; + input.max = metric.max; + input.required = true; + label.append(cell("span", `${metric.label}, ${metric.unit}`), input); + fields.append(label); + } + } + + let loading = 0; + async function loadHistory() { + const request = ++loading; + const status = $("#history-note"); + note(status, "Загрузка…"); + try { + const readings = await api("/api/readings"); + if (request !== loading) return; + const cards = $("#history"); + cards.replaceChildren(); + for (const reading of readings) { + const card = cell("article", "", "reading-card panel"); + const label = cell("label", ""); + const parameters = document.createElement("textarea"); + parameters.value = reading.parameters; + parameters.readOnly = true; + parameters.rows = 4; + parameters.spellcheck = false; + label.append(cell("span", "Параметры проверки"), parameters); + const button = cell("button", "Проверка", "action reading-check"); + button.type = "button"; + button.setAttribute("aria-label", `Проверка показания #${reading.id}`); + button.addEventListener("click", async () => { + const openCheck = await chatPromise; + openCheck(); + }); + card.append(cell("h2", `ID показания: ${reading.id}`), label, button); + cards.append(card); + } + status.hidden = readings.length > 0; + if (!readings.length) note(status, "Показаний пока нет."); + } catch (error) { + if (request === loading) note(status, error.message, "err"); + } + } + + $("#verification-close").addEventListener("click", () => $("#verification-dialog").close()); + $("#verification-dialog").addEventListener("close", () => { + $("#verification-secret").value = ""; + $("#verification-reading").textContent = ""; + $("#verification-receipt").textContent = ""; + $("#calculation-secret").value = ""; + }); + selector.addEventListener("change", renderFields); + $("#reading-open").addEventListener("click", () => { + $("#reading-note").hidden = true; + dialog.showModal(); + }); + $("#reading-close").addEventListener("click", () => dialog.close()); + form.addEventListener("submit", async (event) => { + event.preventDefault(); + const button = event.submitter; + button.disabled = true; + try { + const data = new FormData(form); + const resource = resources.find((item) => item.id === data.get("kind")); + const metrics = Object.fromEntries(resource.metrics.map((metric) => [metric.key, data.get(metric.key)])); + const result = await post("/api/readings", { serial: data.get("serial").trim(), kind: resource.id, metrics }); + form.reset(); + renderFields(); + dialog.close(); + navigateTo("history"); + $("#verification-reading").textContent = result.id; + $("#verification-secret").value = result.verification_id; + $("#verification-receipt").textContent = result.receipt_id; + $("#calculation-secret").value = result.calculation_id; + $("#verification-dialog").showModal(); + } catch (error) { + note($("#reading-note"), error.message, "err"); + } finally { + button.disabled = false; + } + }); + $("#reading-open").disabled = false; + onRoute("history", loadHistory); +} diff --git a/dark-tariff/frontend/src/features/receipts.js b/dark-tariff/frontend/src/features/receipts.js new file mode 100755 index 0000000..c4f3c9d --- /dev/null +++ b/dark-tariff/frontend/src/features/receipts.js @@ -0,0 +1,104 @@ +import { api, post } from "../api/client.js"; +import { $, cell, note } from "../shared/dom.js"; +import { onRoute } from "../shared/router.js"; + +export async function initReceipts(resourcesPromise) { + const dialog = $("#receipt-dialog"); + const form = $("#receipt-form"); + const details = $("#receipt-details"); + const amount = new Intl.NumberFormat("ru-RU", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); + let selected; + let opening = 0; + let resources; + let loading = 0; + try { + resources = await resourcesPromise; + } catch (error) { + note($("#receipts-note"), error.message, "err"); + return; + } + + async function loadReceipts() { + const request = ++loading; + note($("#receipts-note"), "Загрузка…"); + try { + const receipts = await api("/api/receipts"); + if (request !== loading) return; + const cards = $("#receipts"); + cards.replaceChildren(); + for (const receipt of receipts) { + const card = cell("article", "", "reading-card panel"); + const time = cell("time", new Date(receipt.created_at).toLocaleString("ru-RU")); + time.dateTime = receipt.created_at; + const button = cell("button", "Открыть", "action"); + button.type = "button"; + button.setAttribute("aria-label", `Открыть квитанцию #${receipt.id}`); + button.addEventListener("click", () => { + opening++; + selected = receipt.id; + form.querySelector("button[type=submit]").disabled = false; + form.reset(); + form.hidden = false; + $("#receipt-note").hidden = true; + $("#receipt-content").hidden = true; + details.replaceChildren(); + $("#receipt-parameters").value = ""; + $("#receipt-dialog-title").textContent = `Квитанция #${receipt.id}`; + dialog.showModal(); + }); + card.append(cell("h2", `ID квитанции: ${receipt.id}`), time, button); + cards.append(card); + } + $("#receipts-note").hidden = receipts.length > 0; + if (!receipts.length) note($("#receipts-note"), "Квитанций пока нет."); + } catch (error) { + if (request === loading) note($("#receipts-note"), error.message, "err"); + } + } + + $("#receipt-close").addEventListener("click", () => dialog.close()); + dialog.addEventListener("close", () => { + opening++; + form.reset(); + details.replaceChildren(); + $("#receipt-parameters").value = ""; + $("#receipt-content").hidden = true; + }); + form.addEventListener("submit", async (event) => { + event.preventDefault(); + const request = ++opening; + const button = event.submitter; + button.disabled = true; + try { + const receipt = await post(`/api/receipts/${selected}/open`, { calculation_id: form.elements.calculation_id.value.trim() }); + if (request !== opening) return; + const reading = receipt.reading; + const calculation = receipt.calculation; + const resource = resources.find((item) => item.id === reading.kind); + const rows = [ + ["ID квитанции", receipt.id], ["ID показания", receipt.reading_id], + ["Дата квитанции", new Date(receipt.created_at).toLocaleString("ru-RU")], + ["Дата показания", new Date(reading.created_at).toLocaleString("ru-RU")], + ["Серийный ID", reading.serial], ["Вид ресурса", resource.title], + ...resource.metrics.map((metric) => [metric.label, `${reading.metrics[metric.key]} ${metric.unit}`]), + ["Количество", `${calculation.quantity} ${calculation.unit}`], + ["Тариф", `${amount.format(calculation.unit_price)} €$ / ${calculation.unit}`], + ["Расчёт", `${calculation.quantity} × ${calculation.unit_price}`], + ["К оплате", `${amount.format(calculation.amount)} €$`], + ]; + details.replaceChildren(); + for (const [label, value] of rows) { + details.append(cell("dt", label), cell("dd", value, label === "К оплате" ? "receipt-total" : "")); + } + $("#receipt-parameters").value = reading.parameters; + form.reset(); + form.hidden = true; + $("#receipt-content").hidden = false; + } catch (error) { + if (request === opening) note($("#receipt-note"), error.message, "err"); + } finally { + if (request === opening) button.disabled = false; + } + }); + onRoute("receipts", loadReceipts); +} diff --git a/dark-tariff/frontend/src/main.js b/dark-tariff/frontend/src/main.js new file mode 100755 index 0000000..757442f --- /dev/null +++ b/dark-tariff/frontend/src/main.js @@ -0,0 +1,13 @@ +import { api } from "./api/client.js"; +import { initReadings } from "./features/readings.js"; +import { initReceipts } from "./features/receipts.js"; +import { initChat } from "./features/chat.js"; +import { initFinance } from "./features/finance.js"; +import { initRouter } from "./shared/router.js"; + +initRouter(); +const resources = api("/api/resources"); +const chat = initChat(resources); +initReadings(resources, chat); +initReceipts(resources); +initFinance(); diff --git a/dark-tariff/frontend/src/shared/dom.js b/dark-tariff/frontend/src/shared/dom.js new file mode 100755 index 0000000..26814c8 --- /dev/null +++ b/dark-tariff/frontend/src/shared/dom.js @@ -0,0 +1,14 @@ +export const $ = (sel) => document.querySelector(sel); + +export function cell(tag, text, cls) { + const element = document.createElement(tag); + element.textContent = text; + if (cls) element.className = cls; + return element; +} + +export function note(element, text, kind = "ok") { + element.textContent = text; + element.className = `note ${kind}`; + element.hidden = false; +} diff --git a/dark-tariff/frontend/src/shared/router.js b/dark-tariff/frontend/src/shared/router.js new file mode 100755 index 0000000..3543c79 --- /dev/null +++ b/dark-tariff/frontend/src/shared/router.js @@ -0,0 +1,45 @@ +const routes = { + submit: "Передать показания", + history: "Показания", + receipts: "Квитанции", + finance: "Финансы", +}; + +function currentRoute() { + const route = window.location.hash.replace(/^#\//, ""); + return routes[route] ? route : "submit"; +} + +function renderRoute() { + const route = currentRoute(); + for (const page of document.querySelectorAll("[data-page]")) { + page.hidden = page.dataset.page !== route; + } + for (const link of document.querySelectorAll("[data-route]")) { + if (link.dataset.route === route) link.setAttribute("aria-current", "page"); + else link.removeAttribute("aria-current"); + } + document.title = routes[route] + " — Dark Tariff"; +} + +export function onRoute(route, callback) { + function load() { + if (window.location.hash === "#/" + route) callback(); + } + window.addEventListener("hashchange", load); + load(); +} + +export function navigateTo(route) { + if (!routes[route]) return; + if (currentRoute() === route) renderRoute(); + else window.location.hash = "#/" + route; +} + +export function initRouter() { + if (!window.location.hash || !routes[window.location.hash.replace(/^#\//, "")]) { + window.history.replaceState(null, "", "#/submit"); + } + window.addEventListener("hashchange", renderRoute); + renderRoute(); +} diff --git a/dark-tariff/frontend/src/styles/main.css b/dark-tariff/frontend/src/styles/main.css new file mode 100755 index 0000000..e7ff395 --- /dev/null +++ b/dark-tariff/frontend/src/styles/main.css @@ -0,0 +1,207 @@ +:root { + color-scheme: dark; + --bg: #101015; + --panel: #18181f; + --field: #111117; + --raised: #22222c; + --line: #373744; + --ink: #f3f2f5; + --dim: #aaa8b6; + --acid: #efff43; + --cyan: #70ede1; + --pink: #ff5090; + --error: #ff9dbd; + --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace; +} + +* { box-sizing: border-box; } +[hidden] { display: none !important; } +body { min-width: 1168px; min-height: 100vh; margin: 0; overflow-x: clip; isolation: isolate; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); } +body::before, body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; } +body::before { + background: repeating-linear-gradient(0deg, transparent 0 3px, #70ede104 3px 4px), + linear-gradient(#70ede109 1px, transparent 1px), linear-gradient(90deg, #70ede109 1px, transparent 1px); + background-size: auto, 80px 80px, 80px 80px; + mask-image: linear-gradient(#0009, #0002); +} +body::after { + inset: -12%; + background: radial-gradient(ellipse at 80% 25%, #70ede11c, transparent 48%), radial-gradient(ellipse at 10% 85%, #efff4310, transparent 42%); + animation: ambient-drift 20s ease-in-out infinite alternate; +} +button, input, select, textarea { font: inherit; } +button { cursor: pointer; } +button:disabled { opacity: .55; cursor: default; } +:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; } +.shell { width: 1120px; margin-inline: auto; } +.topbar { border-bottom: 1px solid var(--line); background: #0c0c11e8; box-shadow: 0 1px 0 #70ede10b; } +.topbar-inner { min-height: 80px; display: flex; align-items: center; justify-content: space-between; gap: 24px; } +.brand { + display: flex; + align-items: center; + gap: 12px; + color: var(--ink); + font-size: 24px; + font-weight: 850; + letter-spacing: -.05em; + text-decoration: none; +} + +.brand-mark { + width: 34px; + height: 34px; + flex: 0 0 auto; + filter: drop-shadow(0 0 7px #efff4366); +} +.meter-shell { fill: #17190c; stroke: var(--acid); stroke-width: 2; } +.meter-screen { fill: #70ede122; stroke: var(--cyan); stroke-width: 1.5; } +.meter-readout, .meter-dial { fill: none; stroke: var(--acid); stroke-linecap: square; stroke-width: 2; } +.meter-core { fill: var(--pink); } + +.main-nav { display: flex; gap: 24px; } +.main-nav a { position: relative; padding-block: 8px; color: var(--dim); text-decoration: none; font-size: 13px; font-weight: 750; letter-spacing: .025em; text-transform: uppercase; transition: color .18s ease; } +.main-nav a::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: var(--acid); box-shadow: 0 0 12px #efff4340; transform: scaleX(0); transform-origin: left; transition: transform .2s ease; } +.main-nav a:hover::after, .main-nav a[aria-current="page"]::after { transform: scaleX(1); } +.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--acid); } +.page { position: relative; padding: 60px 0 110px; } +.page:not([hidden]) { animation: reveal .32s ease-out backwards; } +.page::before { content: ""; position: absolute; top: 38px; right: 0; width: 88px; height: 4px; background: repeating-linear-gradient(135deg, var(--acid) 0 5px, transparent 5px 10px); opacity: .65; } +h1 { margin: 14px 0 20px; font-size: 68px; font-weight: 900; letter-spacing: -.055em; line-height: 1.02; text-transform: uppercase; } +#submit-page-title { max-width: 940px; margin-top: 24px; font-size: 96px; line-height: .98; } +[data-page="submit"] { padding-top: clamp(60px, 9vh, 108px); } +.eyebrow { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--cyan); font: 700 12px/1.5 var(--mono); letter-spacing: .16em; text-transform: uppercase; } +.eyebrow::before { content: ""; width: 8px; height: 8px; background: var(--acid); box-shadow: 0 0 14px #efff4340; } +.intro { max-width: 620px; margin-bottom: 28px; color: var(--dim); } +.primary, .action { min-height: 44px; padding: 11px 18px; border: 1px solid var(--line); font-weight: 750; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px)); transition: transform .18s ease, background .18s ease, border-color .18s ease, color .18s ease; } +.primary { border-color: var(--acid); background: var(--acid); color: var(--bg); } +.primary:hover:not(:disabled) { background: #fbff9e; transform: translate(2px, -2px); } +.primary:active:not(:disabled), .action:active:not(:disabled) { transform: translateY(1px); } +.primary:focus-visible { box-shadow: inset 0 0 0 2px var(--bg); } +.action:focus-visible { box-shadow: inset 0 0 0 2px var(--cyan); } +.action { background: var(--field); color: var(--ink); } +.action:hover:not(:disabled) { border-color: var(--cyan); background: #70ede10a; color: var(--cyan); transform: translateY(-2px); } +.panel, dialog { background: linear-gradient(135deg, #70ede109, transparent 60%), var(--panel); border: 1px solid var(--line); border-radius: 0; clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px)); } +.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--line); } +.panel-head h2 { margin: 0; font: 750 18px/1.4 var(--mono); letter-spacing: -.025em; } +dialog[open], .help-chat:not([hidden]) { animation: reveal .2s ease-out backwards; } +dialog { width: 640px; max-height: calc(100vh - 32px); padding: 0; overflow: auto; color: var(--ink); } +dialog::backdrop { background: #08080dcc; backdrop-filter: blur(6px); animation: backdrop-in .2s ease-out; } +form { display: grid; gap: 20px; padding: 24px; } +label { display: grid; gap: 7px; color: var(--dim); font-size: 14px; } +input, select, textarea { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); background: var(--field); color: var(--ink); } +input:not([type="checkbox"]), select, textarea { transition: border-color .2s ease, box-shadow .2s ease; } +input:not([type="checkbox"]):focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: inset 3px 0 var(--cyan); } +input, textarea, time, .receipt-details dd, #verification-reading, #verification-receipt { font-family: var(--mono); font-variant-numeric: tabular-nums; } +.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; } +.field-help { margin: 0; color: var(--dim); font-size: 13px; } +.note { margin-top: 12px; padding: 10px 14px; border-left: 2px solid var(--cyan); background: var(--field); color: var(--cyan); overflow-wrap: anywhere; } +.note.err { color: var(--error); border-color: var(--error); } +.history-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; } +.reading-card { position: relative; min-width: 0; padding: 24px; animation: reveal .34s ease-out backwards; transition: transform .2s ease, border-color .2s ease; } +.reading-card::before { content: ""; position: absolute; top: 0; left: 0; width: 48px; height: 3px; background: var(--acid); } +.reading-card::after { content: ""; position: absolute; right: 10px; bottom: 10px; width: 8px; height: 8px; border-right: 1px solid var(--cyan); border-bottom: 1px solid var(--cyan); opacity: .5; } +.reading-card:hover { transform: translateY(-4px); border-color: var(--cyan); } +.reading-card:nth-child(2) { animation-delay: 40ms; } +.reading-card:nth-child(3) { animation-delay: 80ms; } +.reading-card:nth-child(n+4) { animation-delay: 120ms; } +.reading-card h2 { margin: 8px 0; overflow-wrap: anywhere; font: 750 20px/1.4 var(--mono); } +.reading-check { min-height: 32px; margin-top: 16px; padding: 6px 12px; font-size: 12px; } + + +.help-launcher { + position: fixed; + right: 24px; + bottom: 24px; + z-index: 20; + display: flex; + align-items: center; + gap: 14px; + padding: 10px; + border: 0; + background: transparent; + color: var(--ink); +} +.help-hint { + position: relative; + padding: 10px 14px; + border: 1px solid var(--line); + border-radius: 0; + background: var(--raised); +} +.help-hint::after { + content: ""; + position: absolute; + top: 50%; + right: -5px; + width: 8px; + height: 8px; + border-top: 1px solid var(--line); + border-right: 1px solid var(--line); + background: var(--raised); + transform: translateY(-50%) rotate(45deg); +} +.help-chat { + position: fixed; + right: 24px; + bottom: 100px; + z-index: 20; + width: 360px; + max-height: calc(100vh - 124px); + overflow: auto; +} +.help-chat .panel-head { min-height: 0; gap: 12px; padding: 16px; } +.help-chat .panel-head h2 { font-size: 18px; } +.help-messages p { + margin: 0 0 10px; + padding: 12px 14px; + border-left: 2px solid var(--line); + border-radius: 0; + background: var(--raised); + overflow-wrap: anywhere; + animation: reveal .2s ease-out backwards; +} + +textarea { resize: vertical; font-size: 13px; line-height: 1.55; } +.verification-body { display: grid; gap: 16px; padding: 24px; } +.verification-body p { margin: 0; } +.reading-card label { margin-top: 16px; } +.help-controls { padding: 0 16px 16px; } +.help-controls .action { width: 100%; text-align: left; font-size: 13px; } +.help-controls form { gap: 12px; padding: 0; } +.help-messages { min-height: 0; max-height: 240px; overflow-y: auto; padding: 16px; } +.help-messages .help-user { color: var(--cyan); } + +.reading-card time { display: block; margin: 8px 0 16px; color: var(--dim); font-size: 13px; } +.receipt-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 0; } +.receipt-details dt { color: var(--dim); } +.receipt-details dd { margin: 0; overflow-wrap: anywhere; } +.receipt-details .receipt-total { color: var(--acid); font-weight: 750; } + +.finance-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; margin-block: 24px; } +.finance-controls label { display: grid; gap: 8px; } +.finance-options { margin: 0 0 24px; padding: 16px; border: 1px solid var(--line); } +#finance-fields { display: flex; flex-wrap: wrap; gap: 16px; } +#finance-fields label { display: flex; align-items: center; gap: 8px; } +#finance-fields input { width: auto; accent-color: var(--acid); } +.finance-scroll { overflow-x: auto; } +#finance-table { width: 100%; border-collapse: collapse; } +#finance-table th, #finance-table td { padding: 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); } +#finance-table th { color: var(--cyan); } +#finance-table tbody tr { transition: background .18s ease; } +#finance-table tbody tr:hover { background: #70ede107; } + +@keyframes ambient-drift { + from { transform: translate(-2%, -1%); } + to { transform: translate(3%, 3%); } +} + +@keyframes reveal { + from { opacity: 0; transform: translateY(12px); } + to { opacity: 1; transform: translateY(0); } +} + +@keyframes backdrop-in { + from { opacity: 0; } + to { opacity: 1; } +} diff --git a/delamain/Makefile b/delamain/Makefile new file mode 100755 index 0000000..57238e9 --- /dev/null +++ b/delamain/Makefile @@ -0,0 +1,26 @@ +.PHONY: build run up down restart logs ps clean init-db + +build: + docker compose -f docker-compose.yml build + +run: + docker compose -f docker-compose.yml up -d --build + +up: run + +down: + docker compose -f docker-compose.yml down + +clean: + docker compose -f docker-compose.yml down -v --remove-orphans + +restart: down run + +logs: + docker compose -f docker-compose.yml logs -f + +ps: + docker compose -f docker-compose.yml ps + +init-db: clean + docker compose -f docker-compose.yml up -d --build diff --git a/delamain/bin/delamain-daemon b/delamain/bin/delamain-daemon new file mode 100755 index 0000000..19d6289 Binary files /dev/null and b/delamain/bin/delamain-daemon differ diff --git a/delamain/bin/delamain-server b/delamain/bin/delamain-server new file mode 100755 index 0000000..1b77ed2 Binary files /dev/null and b/delamain/bin/delamain-server differ diff --git a/delamain/c.Dockerfile b/delamain/c.Dockerfile new file mode 100755 index 0000000..6ee83a7 --- /dev/null +++ b/delamain/c.Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:3.20 + +RUN apk add --no-cache cjson libpq && \ + mkdir -p /var/run/delamain && \ + chown root:1000 /var/run/delamain && chmod 0770 /var/run/delamain +USER 1000:1000 + +COPY bin/delamain-daemon /usr/local/bin/delamain-daemon + +CMD ["/usr/local/bin/delamain-daemon"] diff --git a/delamain/cleaner.sh b/delamain/cleaner.sh new file mode 100755 index 0000000..eae2157 --- /dev/null +++ b/delamain/cleaner.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -eu + +: "${PGHOST:=postgres}" +: "${PGUSER:=postgres}" +: "${PGDATABASE:=delamain}" +: "${PGPASSWORD:=postgres}" +: "${CLEAN_OLDER_THAN:=6 minutes}" +: "${CLEAN_EVERY:=60}" +export PGHOST PGUSER PGDATABASE PGPASSWORD + +while true; do + sleep "$CLEAN_EVERY" + psql -c "DELETE FROM trips WHERE created_at < now() - interval '${CLEAN_OLDER_THAN}'" + psql -c "DELETE FROM users WHERE created_at < now() - interval '${CLEAN_OLDER_THAN}'" +done diff --git a/delamain/docker-compose.yml b/delamain/docker-compose.yml new file mode 100755 index 0000000..392293f --- /dev/null +++ b/delamain/docker-compose.yml @@ -0,0 +1,110 @@ +services: + postgres: + image: postgres:14-alpine + container_name: delamain_postgres + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: delamain + volumes: + - postgres_data:/var/lib/postgresql/data + - ./sql/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres -d delamain"] + interval: 5s + timeout: 5s + retries: 10 + networks: + - delamain_network + ports: [] + restart: unless-stopped + + c-daemon: + build: + context: . + dockerfile: c.Dockerfile + container_name: delamain_c_daemon + environment: + DB_HOST: postgres + DB_PORT: "5432" + DB_USER: delamain_ro + DB_PASSWORD: delamain_ro + DB_NAME: delamain + volumes: + - daemon_sock:/var/run/delamain + networks: + - delamain_network + restart: unless-stopped + + go-server: + build: + context: . + dockerfile: go.Dockerfile + container_name: delamain_go_server + environment: + DB_HOST: postgres + DB_PORT: "5432" + DB_USER: postgres + DB_PASSWORD: postgres + DB_NAME: delamain + C_SOCKET_PATH: /var/run/delamain/daemon.sock + FRONTEND_DIR: /app/frontend + volumes: + - daemon_sock:/var/run/delamain + - ./frontend:/app/frontend:ro + ports: [] + depends_on: + postgres: + condition: service_healthy + c-daemon: + condition: service_started + healthcheck: + test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8080/api/health || exit 1"] + interval: 10s + timeout: 5s + retries: 5 + networks: + - delamain_network + restart: unless-stopped + + nginx: + image: nginx:alpine + container_name: delamain_nginx + ports: + - "80:80" + volumes: + - ./frontend:/usr/share/nginx/html:ro + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + depends_on: + - go-server + networks: + - delamain_network + restart: unless-stopped + + cleaner: + image: postgres:14-alpine + container_name: delamain_cleaner + entrypoint: ["sh", "/usr/local/bin/cleaner.sh"] + environment: + PGPASSWORD: postgres + PGHOST: postgres + PGUSER: postgres + PGDATABASE: delamain + CLEAN_OLDER_THAN: "6 minutes" + CLEAN_EVERY: "60" + volumes: + - ./cleaner.sh:/usr/local/bin/cleaner.sh:ro + depends_on: + postgres: + condition: service_healthy + networks: + - delamain_network + restart: unless-stopped + +volumes: + postgres_data: + daemon_sock: + +networks: + delamain_network: + driver: bridge diff --git a/delamain/frontend/img/tiles/3/0/0.webp b/delamain/frontend/img/tiles/3/0/0.webp new file mode 100755 index 0000000..daa7f34 Binary files /dev/null and b/delamain/frontend/img/tiles/3/0/0.webp differ diff --git a/delamain/frontend/img/tiles/3/0/1.webp b/delamain/frontend/img/tiles/3/0/1.webp new file mode 100755 index 0000000..5ee9327 Binary files /dev/null and b/delamain/frontend/img/tiles/3/0/1.webp differ diff --git a/delamain/frontend/img/tiles/3/0/2.webp b/delamain/frontend/img/tiles/3/0/2.webp new file mode 100755 index 0000000..4797e8f Binary files /dev/null and b/delamain/frontend/img/tiles/3/0/2.webp differ diff --git a/delamain/frontend/img/tiles/3/0/3.webp b/delamain/frontend/img/tiles/3/0/3.webp new file mode 100755 index 0000000..f33bb8a Binary files /dev/null and b/delamain/frontend/img/tiles/3/0/3.webp differ diff --git a/delamain/frontend/img/tiles/3/0/4.webp b/delamain/frontend/img/tiles/3/0/4.webp new file mode 100755 index 0000000..db70222 Binary files /dev/null and b/delamain/frontend/img/tiles/3/0/4.webp differ diff --git a/delamain/frontend/img/tiles/3/0/5.webp b/delamain/frontend/img/tiles/3/0/5.webp new file mode 100755 index 0000000..08ce7b1 Binary files /dev/null and b/delamain/frontend/img/tiles/3/0/5.webp differ diff --git a/delamain/frontend/img/tiles/3/0/6.webp b/delamain/frontend/img/tiles/3/0/6.webp new file mode 100755 index 0000000..022c6de Binary files /dev/null and b/delamain/frontend/img/tiles/3/0/6.webp differ diff --git a/delamain/frontend/img/tiles/3/1/0.webp b/delamain/frontend/img/tiles/3/1/0.webp new file mode 100755 index 0000000..da253d7 Binary files /dev/null and b/delamain/frontend/img/tiles/3/1/0.webp differ diff --git a/delamain/frontend/img/tiles/3/1/1.webp b/delamain/frontend/img/tiles/3/1/1.webp new file mode 100755 index 0000000..826d4ee Binary files /dev/null and b/delamain/frontend/img/tiles/3/1/1.webp differ diff --git a/delamain/frontend/img/tiles/3/1/2.webp b/delamain/frontend/img/tiles/3/1/2.webp new file mode 100755 index 0000000..d8f7b92 Binary files /dev/null and b/delamain/frontend/img/tiles/3/1/2.webp differ diff --git a/delamain/frontend/img/tiles/3/1/3.webp b/delamain/frontend/img/tiles/3/1/3.webp new file mode 100755 index 0000000..bbafe22 Binary files /dev/null and b/delamain/frontend/img/tiles/3/1/3.webp differ diff --git a/delamain/frontend/img/tiles/3/1/4.webp b/delamain/frontend/img/tiles/3/1/4.webp new file mode 100755 index 0000000..777914a Binary files /dev/null and b/delamain/frontend/img/tiles/3/1/4.webp differ diff --git a/delamain/frontend/img/tiles/3/1/5.webp b/delamain/frontend/img/tiles/3/1/5.webp new file mode 100755 index 0000000..79e29c0 Binary files /dev/null and b/delamain/frontend/img/tiles/3/1/5.webp differ diff --git a/delamain/frontend/img/tiles/3/1/6.webp b/delamain/frontend/img/tiles/3/1/6.webp new file mode 100755 index 0000000..910fdbc Binary files /dev/null and b/delamain/frontend/img/tiles/3/1/6.webp differ diff --git a/delamain/frontend/img/tiles/3/2/0.webp b/delamain/frontend/img/tiles/3/2/0.webp new file mode 100755 index 0000000..ecc6018 Binary files /dev/null and b/delamain/frontend/img/tiles/3/2/0.webp differ diff --git a/delamain/frontend/img/tiles/3/2/1.webp b/delamain/frontend/img/tiles/3/2/1.webp new file mode 100755 index 0000000..9d54cfa Binary files /dev/null and b/delamain/frontend/img/tiles/3/2/1.webp differ diff --git a/delamain/frontend/img/tiles/3/2/2.webp b/delamain/frontend/img/tiles/3/2/2.webp new file mode 100755 index 0000000..d2ce5ec Binary files /dev/null and b/delamain/frontend/img/tiles/3/2/2.webp differ diff --git a/delamain/frontend/img/tiles/3/2/3.webp b/delamain/frontend/img/tiles/3/2/3.webp new file mode 100755 index 0000000..64424b8 Binary files /dev/null and b/delamain/frontend/img/tiles/3/2/3.webp differ diff --git a/delamain/frontend/img/tiles/3/2/4.webp b/delamain/frontend/img/tiles/3/2/4.webp new file mode 100755 index 0000000..f420f04 Binary files /dev/null and b/delamain/frontend/img/tiles/3/2/4.webp differ diff --git a/delamain/frontend/img/tiles/3/2/5.webp b/delamain/frontend/img/tiles/3/2/5.webp new file mode 100755 index 0000000..e261acc Binary files /dev/null and b/delamain/frontend/img/tiles/3/2/5.webp differ diff --git a/delamain/frontend/img/tiles/3/2/6.webp b/delamain/frontend/img/tiles/3/2/6.webp new file mode 100755 index 0000000..71ad74b Binary files /dev/null and b/delamain/frontend/img/tiles/3/2/6.webp differ diff --git a/delamain/frontend/img/tiles/3/3/0.webp b/delamain/frontend/img/tiles/3/3/0.webp new file mode 100755 index 0000000..dd65edd Binary files /dev/null and b/delamain/frontend/img/tiles/3/3/0.webp differ diff --git a/delamain/frontend/img/tiles/3/3/1.webp b/delamain/frontend/img/tiles/3/3/1.webp new file mode 100755 index 0000000..3dfbdab Binary files /dev/null and b/delamain/frontend/img/tiles/3/3/1.webp differ diff --git a/delamain/frontend/img/tiles/3/3/2.webp b/delamain/frontend/img/tiles/3/3/2.webp new file mode 100755 index 0000000..b7ce92b Binary files /dev/null and b/delamain/frontend/img/tiles/3/3/2.webp differ diff --git a/delamain/frontend/img/tiles/3/3/3.webp b/delamain/frontend/img/tiles/3/3/3.webp new file mode 100755 index 0000000..29ef317 Binary files /dev/null and b/delamain/frontend/img/tiles/3/3/3.webp differ diff --git a/delamain/frontend/img/tiles/3/3/4.webp b/delamain/frontend/img/tiles/3/3/4.webp new file mode 100755 index 0000000..e270052 Binary files /dev/null and b/delamain/frontend/img/tiles/3/3/4.webp differ diff --git a/delamain/frontend/img/tiles/3/3/5.webp b/delamain/frontend/img/tiles/3/3/5.webp new file mode 100755 index 0000000..d4763ed Binary files /dev/null and b/delamain/frontend/img/tiles/3/3/5.webp differ diff --git a/delamain/frontend/img/tiles/3/3/6.webp b/delamain/frontend/img/tiles/3/3/6.webp new file mode 100755 index 0000000..fea240f Binary files /dev/null and b/delamain/frontend/img/tiles/3/3/6.webp differ diff --git a/delamain/frontend/img/tiles/3/4/0.webp b/delamain/frontend/img/tiles/3/4/0.webp new file mode 100755 index 0000000..4d4fa30 Binary files /dev/null and b/delamain/frontend/img/tiles/3/4/0.webp differ diff --git a/delamain/frontend/img/tiles/3/4/1.webp b/delamain/frontend/img/tiles/3/4/1.webp new file mode 100755 index 0000000..84b226a Binary files /dev/null and b/delamain/frontend/img/tiles/3/4/1.webp differ diff --git a/delamain/frontend/img/tiles/3/4/2.webp b/delamain/frontend/img/tiles/3/4/2.webp new file mode 100755 index 0000000..3cf2798 Binary files /dev/null and b/delamain/frontend/img/tiles/3/4/2.webp differ diff --git a/delamain/frontend/img/tiles/3/4/3.webp b/delamain/frontend/img/tiles/3/4/3.webp new file mode 100755 index 0000000..6cae5ce Binary files /dev/null and b/delamain/frontend/img/tiles/3/4/3.webp differ diff --git a/delamain/frontend/img/tiles/3/4/4.webp b/delamain/frontend/img/tiles/3/4/4.webp new file mode 100755 index 0000000..0c02123 Binary files /dev/null and b/delamain/frontend/img/tiles/3/4/4.webp differ diff --git a/delamain/frontend/img/tiles/3/4/5.webp b/delamain/frontend/img/tiles/3/4/5.webp new file mode 100755 index 0000000..daa0422 Binary files /dev/null and b/delamain/frontend/img/tiles/3/4/5.webp differ diff --git a/delamain/frontend/img/tiles/3/4/6.webp b/delamain/frontend/img/tiles/3/4/6.webp new file mode 100755 index 0000000..901f7d0 Binary files /dev/null and b/delamain/frontend/img/tiles/3/4/6.webp differ diff --git a/delamain/frontend/img/tiles/3/5/0.webp b/delamain/frontend/img/tiles/3/5/0.webp new file mode 100755 index 0000000..6d8ef68 Binary files /dev/null and b/delamain/frontend/img/tiles/3/5/0.webp differ diff --git a/delamain/frontend/img/tiles/3/5/1.webp b/delamain/frontend/img/tiles/3/5/1.webp new file mode 100755 index 0000000..b3c8421 Binary files /dev/null and b/delamain/frontend/img/tiles/3/5/1.webp differ diff --git a/delamain/frontend/img/tiles/3/5/2.webp b/delamain/frontend/img/tiles/3/5/2.webp new file mode 100755 index 0000000..8cd9fb9 Binary files /dev/null and b/delamain/frontend/img/tiles/3/5/2.webp differ diff --git a/delamain/frontend/img/tiles/3/5/3.webp b/delamain/frontend/img/tiles/3/5/3.webp new file mode 100755 index 0000000..68be585 Binary files /dev/null and b/delamain/frontend/img/tiles/3/5/3.webp differ diff --git a/delamain/frontend/img/tiles/3/5/4.webp b/delamain/frontend/img/tiles/3/5/4.webp new file mode 100755 index 0000000..2e3dff7 Binary files /dev/null and b/delamain/frontend/img/tiles/3/5/4.webp differ diff --git a/delamain/frontend/img/tiles/3/5/5.webp b/delamain/frontend/img/tiles/3/5/5.webp new file mode 100755 index 0000000..c11b9f8 Binary files /dev/null and b/delamain/frontend/img/tiles/3/5/5.webp differ diff --git a/delamain/frontend/img/tiles/3/5/6.webp b/delamain/frontend/img/tiles/3/5/6.webp new file mode 100755 index 0000000..cde4c9a Binary files /dev/null and b/delamain/frontend/img/tiles/3/5/6.webp differ diff --git a/delamain/frontend/img/tiles/3/6/0.webp b/delamain/frontend/img/tiles/3/6/0.webp new file mode 100755 index 0000000..9208fb4 Binary files /dev/null and b/delamain/frontend/img/tiles/3/6/0.webp differ diff --git a/delamain/frontend/img/tiles/3/6/1.webp b/delamain/frontend/img/tiles/3/6/1.webp new file mode 100755 index 0000000..6bed8d0 Binary files /dev/null and b/delamain/frontend/img/tiles/3/6/1.webp differ diff --git a/delamain/frontend/img/tiles/3/6/2.webp b/delamain/frontend/img/tiles/3/6/2.webp new file mode 100755 index 0000000..cde6142 Binary files /dev/null and b/delamain/frontend/img/tiles/3/6/2.webp differ diff --git a/delamain/frontend/img/tiles/3/6/3.webp b/delamain/frontend/img/tiles/3/6/3.webp new file mode 100755 index 0000000..618ae52 Binary files /dev/null and b/delamain/frontend/img/tiles/3/6/3.webp differ diff --git a/delamain/frontend/img/tiles/3/6/4.webp b/delamain/frontend/img/tiles/3/6/4.webp new file mode 100755 index 0000000..85a157f Binary files /dev/null and b/delamain/frontend/img/tiles/3/6/4.webp differ diff --git a/delamain/frontend/img/tiles/3/6/5.webp b/delamain/frontend/img/tiles/3/6/5.webp new file mode 100755 index 0000000..830dcc6 Binary files /dev/null and b/delamain/frontend/img/tiles/3/6/5.webp differ diff --git a/delamain/frontend/img/tiles/3/6/6.webp b/delamain/frontend/img/tiles/3/6/6.webp new file mode 100755 index 0000000..2f36c2a Binary files /dev/null and b/delamain/frontend/img/tiles/3/6/6.webp differ diff --git a/delamain/frontend/img/tiles/4/0/0.webp b/delamain/frontend/img/tiles/4/0/0.webp new file mode 100755 index 0000000..71fd9ed Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/0.webp differ diff --git a/delamain/frontend/img/tiles/4/0/1.webp b/delamain/frontend/img/tiles/4/0/1.webp new file mode 100755 index 0000000..952c7a5 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/1.webp differ diff --git a/delamain/frontend/img/tiles/4/0/10.webp b/delamain/frontend/img/tiles/4/0/10.webp new file mode 100755 index 0000000..b4ea9e1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/10.webp differ diff --git a/delamain/frontend/img/tiles/4/0/11.webp b/delamain/frontend/img/tiles/4/0/11.webp new file mode 100755 index 0000000..63b1123 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/11.webp differ diff --git a/delamain/frontend/img/tiles/4/0/12.webp b/delamain/frontend/img/tiles/4/0/12.webp new file mode 100755 index 0000000..3ea01ef Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/12.webp differ diff --git a/delamain/frontend/img/tiles/4/0/13.webp b/delamain/frontend/img/tiles/4/0/13.webp new file mode 100755 index 0000000..6c9e53a Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/13.webp differ diff --git a/delamain/frontend/img/tiles/4/0/2.webp b/delamain/frontend/img/tiles/4/0/2.webp new file mode 100755 index 0000000..2f2ad24 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/2.webp differ diff --git a/delamain/frontend/img/tiles/4/0/3.webp b/delamain/frontend/img/tiles/4/0/3.webp new file mode 100755 index 0000000..1a12d5f Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/3.webp differ diff --git a/delamain/frontend/img/tiles/4/0/4.webp b/delamain/frontend/img/tiles/4/0/4.webp new file mode 100755 index 0000000..e641d9b Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/4.webp differ diff --git a/delamain/frontend/img/tiles/4/0/5.webp b/delamain/frontend/img/tiles/4/0/5.webp new file mode 100755 index 0000000..ddc3cb1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/5.webp differ diff --git a/delamain/frontend/img/tiles/4/0/6.webp b/delamain/frontend/img/tiles/4/0/6.webp new file mode 100755 index 0000000..1fb96ce Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/6.webp differ diff --git a/delamain/frontend/img/tiles/4/0/7.webp b/delamain/frontend/img/tiles/4/0/7.webp new file mode 100755 index 0000000..ae1f3e8 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/7.webp differ diff --git a/delamain/frontend/img/tiles/4/0/8.webp b/delamain/frontend/img/tiles/4/0/8.webp new file mode 100755 index 0000000..71a7bd7 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/8.webp differ diff --git a/delamain/frontend/img/tiles/4/0/9.webp b/delamain/frontend/img/tiles/4/0/9.webp new file mode 100755 index 0000000..4c2a988 Binary files /dev/null and b/delamain/frontend/img/tiles/4/0/9.webp differ diff --git a/delamain/frontend/img/tiles/4/1/0.webp b/delamain/frontend/img/tiles/4/1/0.webp new file mode 100755 index 0000000..53158e3 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/0.webp differ diff --git a/delamain/frontend/img/tiles/4/1/1.webp b/delamain/frontend/img/tiles/4/1/1.webp new file mode 100755 index 0000000..e560ab1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/1.webp differ diff --git a/delamain/frontend/img/tiles/4/1/10.webp b/delamain/frontend/img/tiles/4/1/10.webp new file mode 100755 index 0000000..8421435 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/10.webp differ diff --git a/delamain/frontend/img/tiles/4/1/11.webp b/delamain/frontend/img/tiles/4/1/11.webp new file mode 100755 index 0000000..b8b81a8 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/11.webp differ diff --git a/delamain/frontend/img/tiles/4/1/12.webp b/delamain/frontend/img/tiles/4/1/12.webp new file mode 100755 index 0000000..2f9eb52 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/12.webp differ diff --git a/delamain/frontend/img/tiles/4/1/13.webp b/delamain/frontend/img/tiles/4/1/13.webp new file mode 100755 index 0000000..b362e8e Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/13.webp differ diff --git a/delamain/frontend/img/tiles/4/1/2.webp b/delamain/frontend/img/tiles/4/1/2.webp new file mode 100755 index 0000000..925b822 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/2.webp differ diff --git a/delamain/frontend/img/tiles/4/1/3.webp b/delamain/frontend/img/tiles/4/1/3.webp new file mode 100755 index 0000000..cd4c473 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/3.webp differ diff --git a/delamain/frontend/img/tiles/4/1/4.webp b/delamain/frontend/img/tiles/4/1/4.webp new file mode 100755 index 0000000..ff890f7 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/4.webp differ diff --git a/delamain/frontend/img/tiles/4/1/5.webp b/delamain/frontend/img/tiles/4/1/5.webp new file mode 100755 index 0000000..5237525 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/5.webp differ diff --git a/delamain/frontend/img/tiles/4/1/6.webp b/delamain/frontend/img/tiles/4/1/6.webp new file mode 100755 index 0000000..320820c Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/6.webp differ diff --git a/delamain/frontend/img/tiles/4/1/7.webp b/delamain/frontend/img/tiles/4/1/7.webp new file mode 100755 index 0000000..75f752b Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/7.webp differ diff --git a/delamain/frontend/img/tiles/4/1/8.webp b/delamain/frontend/img/tiles/4/1/8.webp new file mode 100755 index 0000000..0324b95 Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/8.webp differ diff --git a/delamain/frontend/img/tiles/4/1/9.webp b/delamain/frontend/img/tiles/4/1/9.webp new file mode 100755 index 0000000..e38b6bd Binary files /dev/null and b/delamain/frontend/img/tiles/4/1/9.webp differ diff --git a/delamain/frontend/img/tiles/4/10/0.webp b/delamain/frontend/img/tiles/4/10/0.webp new file mode 100755 index 0000000..ccfe551 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/0.webp differ diff --git a/delamain/frontend/img/tiles/4/10/1.webp b/delamain/frontend/img/tiles/4/10/1.webp new file mode 100755 index 0000000..745728b Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/1.webp differ diff --git a/delamain/frontend/img/tiles/4/10/10.webp b/delamain/frontend/img/tiles/4/10/10.webp new file mode 100755 index 0000000..a324ac6 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/10.webp differ diff --git a/delamain/frontend/img/tiles/4/10/11.webp b/delamain/frontend/img/tiles/4/10/11.webp new file mode 100755 index 0000000..d7ed3db Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/11.webp differ diff --git a/delamain/frontend/img/tiles/4/10/12.webp b/delamain/frontend/img/tiles/4/10/12.webp new file mode 100755 index 0000000..f4dc2a8 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/12.webp differ diff --git a/delamain/frontend/img/tiles/4/10/13.webp b/delamain/frontend/img/tiles/4/10/13.webp new file mode 100755 index 0000000..3a5d32f Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/13.webp differ diff --git a/delamain/frontend/img/tiles/4/10/2.webp b/delamain/frontend/img/tiles/4/10/2.webp new file mode 100755 index 0000000..261799d Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/2.webp differ diff --git a/delamain/frontend/img/tiles/4/10/3.webp b/delamain/frontend/img/tiles/4/10/3.webp new file mode 100755 index 0000000..bf031a5 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/3.webp differ diff --git a/delamain/frontend/img/tiles/4/10/4.webp b/delamain/frontend/img/tiles/4/10/4.webp new file mode 100755 index 0000000..ea833a3 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/4.webp differ diff --git a/delamain/frontend/img/tiles/4/10/5.webp b/delamain/frontend/img/tiles/4/10/5.webp new file mode 100755 index 0000000..e86d550 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/5.webp differ diff --git a/delamain/frontend/img/tiles/4/10/6.webp b/delamain/frontend/img/tiles/4/10/6.webp new file mode 100755 index 0000000..87026ab Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/6.webp differ diff --git a/delamain/frontend/img/tiles/4/10/7.webp b/delamain/frontend/img/tiles/4/10/7.webp new file mode 100755 index 0000000..294d503 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/7.webp differ diff --git a/delamain/frontend/img/tiles/4/10/8.webp b/delamain/frontend/img/tiles/4/10/8.webp new file mode 100755 index 0000000..953e1e9 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/8.webp differ diff --git a/delamain/frontend/img/tiles/4/10/9.webp b/delamain/frontend/img/tiles/4/10/9.webp new file mode 100755 index 0000000..470a2f4 Binary files /dev/null and b/delamain/frontend/img/tiles/4/10/9.webp differ diff --git a/delamain/frontend/img/tiles/4/11/0.webp b/delamain/frontend/img/tiles/4/11/0.webp new file mode 100755 index 0000000..d0a818e Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/0.webp differ diff --git a/delamain/frontend/img/tiles/4/11/1.webp b/delamain/frontend/img/tiles/4/11/1.webp new file mode 100755 index 0000000..c2d88cd Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/1.webp differ diff --git a/delamain/frontend/img/tiles/4/11/10.webp b/delamain/frontend/img/tiles/4/11/10.webp new file mode 100755 index 0000000..ecf8c5d Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/10.webp differ diff --git a/delamain/frontend/img/tiles/4/11/11.webp b/delamain/frontend/img/tiles/4/11/11.webp new file mode 100755 index 0000000..62ed9bf Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/11.webp differ diff --git a/delamain/frontend/img/tiles/4/11/12.webp b/delamain/frontend/img/tiles/4/11/12.webp new file mode 100755 index 0000000..40d83b2 Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/12.webp differ diff --git a/delamain/frontend/img/tiles/4/11/13.webp b/delamain/frontend/img/tiles/4/11/13.webp new file mode 100755 index 0000000..dc7f793 Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/13.webp differ diff --git a/delamain/frontend/img/tiles/4/11/2.webp b/delamain/frontend/img/tiles/4/11/2.webp new file mode 100755 index 0000000..bc7dd1b Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/2.webp differ diff --git a/delamain/frontend/img/tiles/4/11/3.webp b/delamain/frontend/img/tiles/4/11/3.webp new file mode 100755 index 0000000..86625a8 Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/3.webp differ diff --git a/delamain/frontend/img/tiles/4/11/4.webp b/delamain/frontend/img/tiles/4/11/4.webp new file mode 100755 index 0000000..1bf88fa Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/4.webp differ diff --git a/delamain/frontend/img/tiles/4/11/5.webp b/delamain/frontend/img/tiles/4/11/5.webp new file mode 100755 index 0000000..7327de2 Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/5.webp differ diff --git a/delamain/frontend/img/tiles/4/11/6.webp b/delamain/frontend/img/tiles/4/11/6.webp new file mode 100755 index 0000000..5cd01bc Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/6.webp differ diff --git a/delamain/frontend/img/tiles/4/11/7.webp b/delamain/frontend/img/tiles/4/11/7.webp new file mode 100755 index 0000000..f30ffa9 Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/7.webp differ diff --git a/delamain/frontend/img/tiles/4/11/8.webp b/delamain/frontend/img/tiles/4/11/8.webp new file mode 100755 index 0000000..489566c Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/8.webp differ diff --git a/delamain/frontend/img/tiles/4/11/9.webp b/delamain/frontend/img/tiles/4/11/9.webp new file mode 100755 index 0000000..3b1db55 Binary files /dev/null and b/delamain/frontend/img/tiles/4/11/9.webp differ diff --git a/delamain/frontend/img/tiles/4/12/0.webp b/delamain/frontend/img/tiles/4/12/0.webp new file mode 100755 index 0000000..2082f49 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/0.webp differ diff --git a/delamain/frontend/img/tiles/4/12/1.webp b/delamain/frontend/img/tiles/4/12/1.webp new file mode 100755 index 0000000..7d71e83 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/1.webp differ diff --git a/delamain/frontend/img/tiles/4/12/10.webp b/delamain/frontend/img/tiles/4/12/10.webp new file mode 100755 index 0000000..0b3d2ed Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/10.webp differ diff --git a/delamain/frontend/img/tiles/4/12/11.webp b/delamain/frontend/img/tiles/4/12/11.webp new file mode 100755 index 0000000..bac0fb4 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/11.webp differ diff --git a/delamain/frontend/img/tiles/4/12/12.webp b/delamain/frontend/img/tiles/4/12/12.webp new file mode 100755 index 0000000..d22085e Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/12.webp differ diff --git a/delamain/frontend/img/tiles/4/12/13.webp b/delamain/frontend/img/tiles/4/12/13.webp new file mode 100755 index 0000000..3bc8125 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/13.webp differ diff --git a/delamain/frontend/img/tiles/4/12/2.webp b/delamain/frontend/img/tiles/4/12/2.webp new file mode 100755 index 0000000..9096a90 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/2.webp differ diff --git a/delamain/frontend/img/tiles/4/12/3.webp b/delamain/frontend/img/tiles/4/12/3.webp new file mode 100755 index 0000000..9ae28e7 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/3.webp differ diff --git a/delamain/frontend/img/tiles/4/12/4.webp b/delamain/frontend/img/tiles/4/12/4.webp new file mode 100755 index 0000000..80d9070 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/4.webp differ diff --git a/delamain/frontend/img/tiles/4/12/5.webp b/delamain/frontend/img/tiles/4/12/5.webp new file mode 100755 index 0000000..640e0f3 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/5.webp differ diff --git a/delamain/frontend/img/tiles/4/12/6.webp b/delamain/frontend/img/tiles/4/12/6.webp new file mode 100755 index 0000000..23a5369 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/6.webp differ diff --git a/delamain/frontend/img/tiles/4/12/7.webp b/delamain/frontend/img/tiles/4/12/7.webp new file mode 100755 index 0000000..bc61ff6 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/7.webp differ diff --git a/delamain/frontend/img/tiles/4/12/8.webp b/delamain/frontend/img/tiles/4/12/8.webp new file mode 100755 index 0000000..e26ca52 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/8.webp differ diff --git a/delamain/frontend/img/tiles/4/12/9.webp b/delamain/frontend/img/tiles/4/12/9.webp new file mode 100755 index 0000000..9cf34b7 Binary files /dev/null and b/delamain/frontend/img/tiles/4/12/9.webp differ diff --git a/delamain/frontend/img/tiles/4/13/0.webp b/delamain/frontend/img/tiles/4/13/0.webp new file mode 100755 index 0000000..d9e30c3 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/0.webp differ diff --git a/delamain/frontend/img/tiles/4/13/1.webp b/delamain/frontend/img/tiles/4/13/1.webp new file mode 100755 index 0000000..bc5cba6 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/1.webp differ diff --git a/delamain/frontend/img/tiles/4/13/10.webp b/delamain/frontend/img/tiles/4/13/10.webp new file mode 100755 index 0000000..bd98d99 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/10.webp differ diff --git a/delamain/frontend/img/tiles/4/13/11.webp b/delamain/frontend/img/tiles/4/13/11.webp new file mode 100755 index 0000000..90d9636 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/11.webp differ diff --git a/delamain/frontend/img/tiles/4/13/12.webp b/delamain/frontend/img/tiles/4/13/12.webp new file mode 100755 index 0000000..b2c5c32 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/12.webp differ diff --git a/delamain/frontend/img/tiles/4/13/13.webp b/delamain/frontend/img/tiles/4/13/13.webp new file mode 100755 index 0000000..05af752 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/13.webp differ diff --git a/delamain/frontend/img/tiles/4/13/2.webp b/delamain/frontend/img/tiles/4/13/2.webp new file mode 100755 index 0000000..84d54f0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/2.webp differ diff --git a/delamain/frontend/img/tiles/4/13/3.webp b/delamain/frontend/img/tiles/4/13/3.webp new file mode 100755 index 0000000..256dc23 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/3.webp differ diff --git a/delamain/frontend/img/tiles/4/13/4.webp b/delamain/frontend/img/tiles/4/13/4.webp new file mode 100755 index 0000000..4a7ded6 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/4.webp differ diff --git a/delamain/frontend/img/tiles/4/13/5.webp b/delamain/frontend/img/tiles/4/13/5.webp new file mode 100755 index 0000000..8016f18 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/5.webp differ diff --git a/delamain/frontend/img/tiles/4/13/6.webp b/delamain/frontend/img/tiles/4/13/6.webp new file mode 100755 index 0000000..3e73ef3 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/6.webp differ diff --git a/delamain/frontend/img/tiles/4/13/7.webp b/delamain/frontend/img/tiles/4/13/7.webp new file mode 100755 index 0000000..7deb5d0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/7.webp differ diff --git a/delamain/frontend/img/tiles/4/13/8.webp b/delamain/frontend/img/tiles/4/13/8.webp new file mode 100755 index 0000000..fff7151 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/8.webp differ diff --git a/delamain/frontend/img/tiles/4/13/9.webp b/delamain/frontend/img/tiles/4/13/9.webp new file mode 100755 index 0000000..0a6ab39 Binary files /dev/null and b/delamain/frontend/img/tiles/4/13/9.webp differ diff --git a/delamain/frontend/img/tiles/4/2/0.webp b/delamain/frontend/img/tiles/4/2/0.webp new file mode 100755 index 0000000..3c959ef Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/0.webp differ diff --git a/delamain/frontend/img/tiles/4/2/1.webp b/delamain/frontend/img/tiles/4/2/1.webp new file mode 100755 index 0000000..88e53c0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/1.webp differ diff --git a/delamain/frontend/img/tiles/4/2/10.webp b/delamain/frontend/img/tiles/4/2/10.webp new file mode 100755 index 0000000..4081377 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/10.webp differ diff --git a/delamain/frontend/img/tiles/4/2/11.webp b/delamain/frontend/img/tiles/4/2/11.webp new file mode 100755 index 0000000..3114222 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/11.webp differ diff --git a/delamain/frontend/img/tiles/4/2/12.webp b/delamain/frontend/img/tiles/4/2/12.webp new file mode 100755 index 0000000..632bef3 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/12.webp differ diff --git a/delamain/frontend/img/tiles/4/2/13.webp b/delamain/frontend/img/tiles/4/2/13.webp new file mode 100755 index 0000000..ad4f838 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/13.webp differ diff --git a/delamain/frontend/img/tiles/4/2/2.webp b/delamain/frontend/img/tiles/4/2/2.webp new file mode 100755 index 0000000..54aba5d Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/2.webp differ diff --git a/delamain/frontend/img/tiles/4/2/3.webp b/delamain/frontend/img/tiles/4/2/3.webp new file mode 100755 index 0000000..379e662 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/3.webp differ diff --git a/delamain/frontend/img/tiles/4/2/4.webp b/delamain/frontend/img/tiles/4/2/4.webp new file mode 100755 index 0000000..7c3703e Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/4.webp differ diff --git a/delamain/frontend/img/tiles/4/2/5.webp b/delamain/frontend/img/tiles/4/2/5.webp new file mode 100755 index 0000000..2f7cee0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/5.webp differ diff --git a/delamain/frontend/img/tiles/4/2/6.webp b/delamain/frontend/img/tiles/4/2/6.webp new file mode 100755 index 0000000..b414141 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/6.webp differ diff --git a/delamain/frontend/img/tiles/4/2/7.webp b/delamain/frontend/img/tiles/4/2/7.webp new file mode 100755 index 0000000..5619006 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/7.webp differ diff --git a/delamain/frontend/img/tiles/4/2/8.webp b/delamain/frontend/img/tiles/4/2/8.webp new file mode 100755 index 0000000..e56b92d Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/8.webp differ diff --git a/delamain/frontend/img/tiles/4/2/9.webp b/delamain/frontend/img/tiles/4/2/9.webp new file mode 100755 index 0000000..8b63986 Binary files /dev/null and b/delamain/frontend/img/tiles/4/2/9.webp differ diff --git a/delamain/frontend/img/tiles/4/3/0.webp b/delamain/frontend/img/tiles/4/3/0.webp new file mode 100755 index 0000000..eacaae0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/0.webp differ diff --git a/delamain/frontend/img/tiles/4/3/1.webp b/delamain/frontend/img/tiles/4/3/1.webp new file mode 100755 index 0000000..60c0d75 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/1.webp differ diff --git a/delamain/frontend/img/tiles/4/3/10.webp b/delamain/frontend/img/tiles/4/3/10.webp new file mode 100755 index 0000000..71344db Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/10.webp differ diff --git a/delamain/frontend/img/tiles/4/3/11.webp b/delamain/frontend/img/tiles/4/3/11.webp new file mode 100755 index 0000000..b6ae00e Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/11.webp differ diff --git a/delamain/frontend/img/tiles/4/3/12.webp b/delamain/frontend/img/tiles/4/3/12.webp new file mode 100755 index 0000000..823ead2 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/12.webp differ diff --git a/delamain/frontend/img/tiles/4/3/13.webp b/delamain/frontend/img/tiles/4/3/13.webp new file mode 100755 index 0000000..7fc9eb8 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/13.webp differ diff --git a/delamain/frontend/img/tiles/4/3/2.webp b/delamain/frontend/img/tiles/4/3/2.webp new file mode 100755 index 0000000..0d7e782 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/2.webp differ diff --git a/delamain/frontend/img/tiles/4/3/3.webp b/delamain/frontend/img/tiles/4/3/3.webp new file mode 100755 index 0000000..1153ede Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/3.webp differ diff --git a/delamain/frontend/img/tiles/4/3/4.webp b/delamain/frontend/img/tiles/4/3/4.webp new file mode 100755 index 0000000..bf79bac Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/4.webp differ diff --git a/delamain/frontend/img/tiles/4/3/5.webp b/delamain/frontend/img/tiles/4/3/5.webp new file mode 100755 index 0000000..b070e85 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/5.webp differ diff --git a/delamain/frontend/img/tiles/4/3/6.webp b/delamain/frontend/img/tiles/4/3/6.webp new file mode 100755 index 0000000..b52b49e Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/6.webp differ diff --git a/delamain/frontend/img/tiles/4/3/7.webp b/delamain/frontend/img/tiles/4/3/7.webp new file mode 100755 index 0000000..6272cd1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/7.webp differ diff --git a/delamain/frontend/img/tiles/4/3/8.webp b/delamain/frontend/img/tiles/4/3/8.webp new file mode 100755 index 0000000..2e1f5ab Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/8.webp differ diff --git a/delamain/frontend/img/tiles/4/3/9.webp b/delamain/frontend/img/tiles/4/3/9.webp new file mode 100755 index 0000000..897baa6 Binary files /dev/null and b/delamain/frontend/img/tiles/4/3/9.webp differ diff --git a/delamain/frontend/img/tiles/4/4/0.webp b/delamain/frontend/img/tiles/4/4/0.webp new file mode 100755 index 0000000..d14423e Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/0.webp differ diff --git a/delamain/frontend/img/tiles/4/4/1.webp b/delamain/frontend/img/tiles/4/4/1.webp new file mode 100755 index 0000000..7a5d535 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/1.webp differ diff --git a/delamain/frontend/img/tiles/4/4/10.webp b/delamain/frontend/img/tiles/4/4/10.webp new file mode 100755 index 0000000..5349504 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/10.webp differ diff --git a/delamain/frontend/img/tiles/4/4/11.webp b/delamain/frontend/img/tiles/4/4/11.webp new file mode 100755 index 0000000..8c17eda Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/11.webp differ diff --git a/delamain/frontend/img/tiles/4/4/12.webp b/delamain/frontend/img/tiles/4/4/12.webp new file mode 100755 index 0000000..fe30cd0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/12.webp differ diff --git a/delamain/frontend/img/tiles/4/4/13.webp b/delamain/frontend/img/tiles/4/4/13.webp new file mode 100755 index 0000000..7fd9567 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/13.webp differ diff --git a/delamain/frontend/img/tiles/4/4/2.webp b/delamain/frontend/img/tiles/4/4/2.webp new file mode 100755 index 0000000..9c8b58c Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/2.webp differ diff --git a/delamain/frontend/img/tiles/4/4/3.webp b/delamain/frontend/img/tiles/4/4/3.webp new file mode 100755 index 0000000..8d67677 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/3.webp differ diff --git a/delamain/frontend/img/tiles/4/4/4.webp b/delamain/frontend/img/tiles/4/4/4.webp new file mode 100755 index 0000000..e81fd8b Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/4.webp differ diff --git a/delamain/frontend/img/tiles/4/4/5.webp b/delamain/frontend/img/tiles/4/4/5.webp new file mode 100755 index 0000000..3821c7a Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/5.webp differ diff --git a/delamain/frontend/img/tiles/4/4/6.webp b/delamain/frontend/img/tiles/4/4/6.webp new file mode 100755 index 0000000..ce8e638 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/6.webp differ diff --git a/delamain/frontend/img/tiles/4/4/7.webp b/delamain/frontend/img/tiles/4/4/7.webp new file mode 100755 index 0000000..6e55de0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/7.webp differ diff --git a/delamain/frontend/img/tiles/4/4/8.webp b/delamain/frontend/img/tiles/4/4/8.webp new file mode 100755 index 0000000..2bb0ba0 Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/8.webp differ diff --git a/delamain/frontend/img/tiles/4/4/9.webp b/delamain/frontend/img/tiles/4/4/9.webp new file mode 100755 index 0000000..24430fb Binary files /dev/null and b/delamain/frontend/img/tiles/4/4/9.webp differ diff --git a/delamain/frontend/img/tiles/4/5/0.webp b/delamain/frontend/img/tiles/4/5/0.webp new file mode 100755 index 0000000..425f8c5 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/0.webp differ diff --git a/delamain/frontend/img/tiles/4/5/1.webp b/delamain/frontend/img/tiles/4/5/1.webp new file mode 100755 index 0000000..35965a6 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/1.webp differ diff --git a/delamain/frontend/img/tiles/4/5/10.webp b/delamain/frontend/img/tiles/4/5/10.webp new file mode 100755 index 0000000..80e7b69 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/10.webp differ diff --git a/delamain/frontend/img/tiles/4/5/11.webp b/delamain/frontend/img/tiles/4/5/11.webp new file mode 100755 index 0000000..9563be1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/11.webp differ diff --git a/delamain/frontend/img/tiles/4/5/12.webp b/delamain/frontend/img/tiles/4/5/12.webp new file mode 100755 index 0000000..c2efb19 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/12.webp differ diff --git a/delamain/frontend/img/tiles/4/5/13.webp b/delamain/frontend/img/tiles/4/5/13.webp new file mode 100755 index 0000000..866d406 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/13.webp differ diff --git a/delamain/frontend/img/tiles/4/5/2.webp b/delamain/frontend/img/tiles/4/5/2.webp new file mode 100755 index 0000000..4035a96 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/2.webp differ diff --git a/delamain/frontend/img/tiles/4/5/3.webp b/delamain/frontend/img/tiles/4/5/3.webp new file mode 100755 index 0000000..76eea3a Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/3.webp differ diff --git a/delamain/frontend/img/tiles/4/5/4.webp b/delamain/frontend/img/tiles/4/5/4.webp new file mode 100755 index 0000000..bd180a1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/4.webp differ diff --git a/delamain/frontend/img/tiles/4/5/5.webp b/delamain/frontend/img/tiles/4/5/5.webp new file mode 100755 index 0000000..8ff338b Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/5.webp differ diff --git a/delamain/frontend/img/tiles/4/5/6.webp b/delamain/frontend/img/tiles/4/5/6.webp new file mode 100755 index 0000000..fd66520 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/6.webp differ diff --git a/delamain/frontend/img/tiles/4/5/7.webp b/delamain/frontend/img/tiles/4/5/7.webp new file mode 100755 index 0000000..59cfceb Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/7.webp differ diff --git a/delamain/frontend/img/tiles/4/5/8.webp b/delamain/frontend/img/tiles/4/5/8.webp new file mode 100755 index 0000000..96f708c Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/8.webp differ diff --git a/delamain/frontend/img/tiles/4/5/9.webp b/delamain/frontend/img/tiles/4/5/9.webp new file mode 100755 index 0000000..74a7052 Binary files /dev/null and b/delamain/frontend/img/tiles/4/5/9.webp differ diff --git a/delamain/frontend/img/tiles/4/6/0.webp b/delamain/frontend/img/tiles/4/6/0.webp new file mode 100755 index 0000000..402efd1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/0.webp differ diff --git a/delamain/frontend/img/tiles/4/6/1.webp b/delamain/frontend/img/tiles/4/6/1.webp new file mode 100755 index 0000000..b57aa46 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/1.webp differ diff --git a/delamain/frontend/img/tiles/4/6/10.webp b/delamain/frontend/img/tiles/4/6/10.webp new file mode 100755 index 0000000..2b4b3b8 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/10.webp differ diff --git a/delamain/frontend/img/tiles/4/6/11.webp b/delamain/frontend/img/tiles/4/6/11.webp new file mode 100755 index 0000000..3c2b87b Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/11.webp differ diff --git a/delamain/frontend/img/tiles/4/6/12.webp b/delamain/frontend/img/tiles/4/6/12.webp new file mode 100755 index 0000000..246c247 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/12.webp differ diff --git a/delamain/frontend/img/tiles/4/6/13.webp b/delamain/frontend/img/tiles/4/6/13.webp new file mode 100755 index 0000000..fa7c66b Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/13.webp differ diff --git a/delamain/frontend/img/tiles/4/6/2.webp b/delamain/frontend/img/tiles/4/6/2.webp new file mode 100755 index 0000000..4e971ec Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/2.webp differ diff --git a/delamain/frontend/img/tiles/4/6/3.webp b/delamain/frontend/img/tiles/4/6/3.webp new file mode 100755 index 0000000..f03ec8c Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/3.webp differ diff --git a/delamain/frontend/img/tiles/4/6/4.webp b/delamain/frontend/img/tiles/4/6/4.webp new file mode 100755 index 0000000..4ac4743 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/4.webp differ diff --git a/delamain/frontend/img/tiles/4/6/5.webp b/delamain/frontend/img/tiles/4/6/5.webp new file mode 100755 index 0000000..8ac3728 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/5.webp differ diff --git a/delamain/frontend/img/tiles/4/6/6.webp b/delamain/frontend/img/tiles/4/6/6.webp new file mode 100755 index 0000000..394a73c Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/6.webp differ diff --git a/delamain/frontend/img/tiles/4/6/7.webp b/delamain/frontend/img/tiles/4/6/7.webp new file mode 100755 index 0000000..38e6801 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/7.webp differ diff --git a/delamain/frontend/img/tiles/4/6/8.webp b/delamain/frontend/img/tiles/4/6/8.webp new file mode 100755 index 0000000..be05032 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/8.webp differ diff --git a/delamain/frontend/img/tiles/4/6/9.webp b/delamain/frontend/img/tiles/4/6/9.webp new file mode 100755 index 0000000..62164a2 Binary files /dev/null and b/delamain/frontend/img/tiles/4/6/9.webp differ diff --git a/delamain/frontend/img/tiles/4/7/0.webp b/delamain/frontend/img/tiles/4/7/0.webp new file mode 100755 index 0000000..d7951cc Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/0.webp differ diff --git a/delamain/frontend/img/tiles/4/7/1.webp b/delamain/frontend/img/tiles/4/7/1.webp new file mode 100755 index 0000000..5d80158 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/1.webp differ diff --git a/delamain/frontend/img/tiles/4/7/10.webp b/delamain/frontend/img/tiles/4/7/10.webp new file mode 100755 index 0000000..2b30578 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/10.webp differ diff --git a/delamain/frontend/img/tiles/4/7/11.webp b/delamain/frontend/img/tiles/4/7/11.webp new file mode 100755 index 0000000..8bb05fa Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/11.webp differ diff --git a/delamain/frontend/img/tiles/4/7/12.webp b/delamain/frontend/img/tiles/4/7/12.webp new file mode 100755 index 0000000..6ee4608 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/12.webp differ diff --git a/delamain/frontend/img/tiles/4/7/13.webp b/delamain/frontend/img/tiles/4/7/13.webp new file mode 100755 index 0000000..2d92bc4 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/13.webp differ diff --git a/delamain/frontend/img/tiles/4/7/2.webp b/delamain/frontend/img/tiles/4/7/2.webp new file mode 100755 index 0000000..40ba348 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/2.webp differ diff --git a/delamain/frontend/img/tiles/4/7/3.webp b/delamain/frontend/img/tiles/4/7/3.webp new file mode 100755 index 0000000..e468ebc Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/3.webp differ diff --git a/delamain/frontend/img/tiles/4/7/4.webp b/delamain/frontend/img/tiles/4/7/4.webp new file mode 100755 index 0000000..0177079 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/4.webp differ diff --git a/delamain/frontend/img/tiles/4/7/5.webp b/delamain/frontend/img/tiles/4/7/5.webp new file mode 100755 index 0000000..7beb350 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/5.webp differ diff --git a/delamain/frontend/img/tiles/4/7/6.webp b/delamain/frontend/img/tiles/4/7/6.webp new file mode 100755 index 0000000..76cd0f7 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/6.webp differ diff --git a/delamain/frontend/img/tiles/4/7/7.webp b/delamain/frontend/img/tiles/4/7/7.webp new file mode 100755 index 0000000..360a52d Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/7.webp differ diff --git a/delamain/frontend/img/tiles/4/7/8.webp b/delamain/frontend/img/tiles/4/7/8.webp new file mode 100755 index 0000000..17a3e22 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/8.webp differ diff --git a/delamain/frontend/img/tiles/4/7/9.webp b/delamain/frontend/img/tiles/4/7/9.webp new file mode 100755 index 0000000..07f2154 Binary files /dev/null and b/delamain/frontend/img/tiles/4/7/9.webp differ diff --git a/delamain/frontend/img/tiles/4/8/0.webp b/delamain/frontend/img/tiles/4/8/0.webp new file mode 100755 index 0000000..49e022a Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/0.webp differ diff --git a/delamain/frontend/img/tiles/4/8/1.webp b/delamain/frontend/img/tiles/4/8/1.webp new file mode 100755 index 0000000..34d02ae Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/1.webp differ diff --git a/delamain/frontend/img/tiles/4/8/10.webp b/delamain/frontend/img/tiles/4/8/10.webp new file mode 100755 index 0000000..b72a808 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/10.webp differ diff --git a/delamain/frontend/img/tiles/4/8/11.webp b/delamain/frontend/img/tiles/4/8/11.webp new file mode 100755 index 0000000..6756a9f Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/11.webp differ diff --git a/delamain/frontend/img/tiles/4/8/12.webp b/delamain/frontend/img/tiles/4/8/12.webp new file mode 100755 index 0000000..182a930 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/12.webp differ diff --git a/delamain/frontend/img/tiles/4/8/13.webp b/delamain/frontend/img/tiles/4/8/13.webp new file mode 100755 index 0000000..eee44f4 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/13.webp differ diff --git a/delamain/frontend/img/tiles/4/8/2.webp b/delamain/frontend/img/tiles/4/8/2.webp new file mode 100755 index 0000000..7ef2006 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/2.webp differ diff --git a/delamain/frontend/img/tiles/4/8/3.webp b/delamain/frontend/img/tiles/4/8/3.webp new file mode 100755 index 0000000..4d4eca5 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/3.webp differ diff --git a/delamain/frontend/img/tiles/4/8/4.webp b/delamain/frontend/img/tiles/4/8/4.webp new file mode 100755 index 0000000..e42ced1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/4.webp differ diff --git a/delamain/frontend/img/tiles/4/8/5.webp b/delamain/frontend/img/tiles/4/8/5.webp new file mode 100755 index 0000000..73e8ff2 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/5.webp differ diff --git a/delamain/frontend/img/tiles/4/8/6.webp b/delamain/frontend/img/tiles/4/8/6.webp new file mode 100755 index 0000000..4cc9938 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/6.webp differ diff --git a/delamain/frontend/img/tiles/4/8/7.webp b/delamain/frontend/img/tiles/4/8/7.webp new file mode 100755 index 0000000..8c9a0bf Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/7.webp differ diff --git a/delamain/frontend/img/tiles/4/8/8.webp b/delamain/frontend/img/tiles/4/8/8.webp new file mode 100755 index 0000000..947a146 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/8.webp differ diff --git a/delamain/frontend/img/tiles/4/8/9.webp b/delamain/frontend/img/tiles/4/8/9.webp new file mode 100755 index 0000000..cb715e2 Binary files /dev/null and b/delamain/frontend/img/tiles/4/8/9.webp differ diff --git a/delamain/frontend/img/tiles/4/9/0.webp b/delamain/frontend/img/tiles/4/9/0.webp new file mode 100755 index 0000000..b43f5f9 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/0.webp differ diff --git a/delamain/frontend/img/tiles/4/9/1.webp b/delamain/frontend/img/tiles/4/9/1.webp new file mode 100755 index 0000000..d58e0f9 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/1.webp differ diff --git a/delamain/frontend/img/tiles/4/9/10.webp b/delamain/frontend/img/tiles/4/9/10.webp new file mode 100755 index 0000000..cfaabdd Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/10.webp differ diff --git a/delamain/frontend/img/tiles/4/9/11.webp b/delamain/frontend/img/tiles/4/9/11.webp new file mode 100755 index 0000000..b8abfdf Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/11.webp differ diff --git a/delamain/frontend/img/tiles/4/9/12.webp b/delamain/frontend/img/tiles/4/9/12.webp new file mode 100755 index 0000000..a9eba9a Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/12.webp differ diff --git a/delamain/frontend/img/tiles/4/9/13.webp b/delamain/frontend/img/tiles/4/9/13.webp new file mode 100755 index 0000000..9959ac5 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/13.webp differ diff --git a/delamain/frontend/img/tiles/4/9/2.webp b/delamain/frontend/img/tiles/4/9/2.webp new file mode 100755 index 0000000..99ffdc7 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/2.webp differ diff --git a/delamain/frontend/img/tiles/4/9/3.webp b/delamain/frontend/img/tiles/4/9/3.webp new file mode 100755 index 0000000..49279bd Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/3.webp differ diff --git a/delamain/frontend/img/tiles/4/9/4.webp b/delamain/frontend/img/tiles/4/9/4.webp new file mode 100755 index 0000000..f1937f6 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/4.webp differ diff --git a/delamain/frontend/img/tiles/4/9/5.webp b/delamain/frontend/img/tiles/4/9/5.webp new file mode 100755 index 0000000..13cf174 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/5.webp differ diff --git a/delamain/frontend/img/tiles/4/9/6.webp b/delamain/frontend/img/tiles/4/9/6.webp new file mode 100755 index 0000000..c7de0b1 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/6.webp differ diff --git a/delamain/frontend/img/tiles/4/9/7.webp b/delamain/frontend/img/tiles/4/9/7.webp new file mode 100755 index 0000000..dc3bb77 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/7.webp differ diff --git a/delamain/frontend/img/tiles/4/9/8.webp b/delamain/frontend/img/tiles/4/9/8.webp new file mode 100755 index 0000000..7990154 Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/8.webp differ diff --git a/delamain/frontend/img/tiles/4/9/9.webp b/delamain/frontend/img/tiles/4/9/9.webp new file mode 100755 index 0000000..87c40da Binary files /dev/null and b/delamain/frontend/img/tiles/4/9/9.webp differ diff --git a/delamain/frontend/img/tiles/5/0/0.webp b/delamain/frontend/img/tiles/5/0/0.webp new file mode 100755 index 0000000..f4e250c Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/0.webp differ diff --git a/delamain/frontend/img/tiles/5/0/1.webp b/delamain/frontend/img/tiles/5/0/1.webp new file mode 100755 index 0000000..3cf7f08 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/1.webp differ diff --git a/delamain/frontend/img/tiles/5/0/10.webp b/delamain/frontend/img/tiles/5/0/10.webp new file mode 100755 index 0000000..e626856 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/10.webp differ diff --git a/delamain/frontend/img/tiles/5/0/11.webp b/delamain/frontend/img/tiles/5/0/11.webp new file mode 100755 index 0000000..ee8d714 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/11.webp differ diff --git a/delamain/frontend/img/tiles/5/0/12.webp b/delamain/frontend/img/tiles/5/0/12.webp new file mode 100755 index 0000000..d6f0070 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/12.webp differ diff --git a/delamain/frontend/img/tiles/5/0/13.webp b/delamain/frontend/img/tiles/5/0/13.webp new file mode 100755 index 0000000..526dcdf Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/13.webp differ diff --git a/delamain/frontend/img/tiles/5/0/14.webp b/delamain/frontend/img/tiles/5/0/14.webp new file mode 100755 index 0000000..f4c02ad Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/14.webp differ diff --git a/delamain/frontend/img/tiles/5/0/15.webp b/delamain/frontend/img/tiles/5/0/15.webp new file mode 100755 index 0000000..ce5993e Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/15.webp differ diff --git a/delamain/frontend/img/tiles/5/0/16.webp b/delamain/frontend/img/tiles/5/0/16.webp new file mode 100755 index 0000000..d66a7b8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/16.webp differ diff --git a/delamain/frontend/img/tiles/5/0/17.webp b/delamain/frontend/img/tiles/5/0/17.webp new file mode 100755 index 0000000..55a6b2d Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/17.webp differ diff --git a/delamain/frontend/img/tiles/5/0/18.webp b/delamain/frontend/img/tiles/5/0/18.webp new file mode 100755 index 0000000..4b13fea Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/18.webp differ diff --git a/delamain/frontend/img/tiles/5/0/19.webp b/delamain/frontend/img/tiles/5/0/19.webp new file mode 100755 index 0000000..4a1564a Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/19.webp differ diff --git a/delamain/frontend/img/tiles/5/0/2.webp b/delamain/frontend/img/tiles/5/0/2.webp new file mode 100755 index 0000000..b185291 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/2.webp differ diff --git a/delamain/frontend/img/tiles/5/0/20.webp b/delamain/frontend/img/tiles/5/0/20.webp new file mode 100755 index 0000000..4b27c21 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/20.webp differ diff --git a/delamain/frontend/img/tiles/5/0/21.webp b/delamain/frontend/img/tiles/5/0/21.webp new file mode 100755 index 0000000..211d4dd Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/21.webp differ diff --git a/delamain/frontend/img/tiles/5/0/22.webp b/delamain/frontend/img/tiles/5/0/22.webp new file mode 100755 index 0000000..d143667 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/22.webp differ diff --git a/delamain/frontend/img/tiles/5/0/23.webp b/delamain/frontend/img/tiles/5/0/23.webp new file mode 100755 index 0000000..61f8933 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/23.webp differ diff --git a/delamain/frontend/img/tiles/5/0/24.webp b/delamain/frontend/img/tiles/5/0/24.webp new file mode 100755 index 0000000..18de69e Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/24.webp differ diff --git a/delamain/frontend/img/tiles/5/0/25.webp b/delamain/frontend/img/tiles/5/0/25.webp new file mode 100755 index 0000000..9b68b3a Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/25.webp differ diff --git a/delamain/frontend/img/tiles/5/0/26.webp b/delamain/frontend/img/tiles/5/0/26.webp new file mode 100755 index 0000000..af39912 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/26.webp differ diff --git a/delamain/frontend/img/tiles/5/0/3.webp b/delamain/frontend/img/tiles/5/0/3.webp new file mode 100755 index 0000000..7c14204 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/3.webp differ diff --git a/delamain/frontend/img/tiles/5/0/4.webp b/delamain/frontend/img/tiles/5/0/4.webp new file mode 100755 index 0000000..2fabc68 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/4.webp differ diff --git a/delamain/frontend/img/tiles/5/0/5.webp b/delamain/frontend/img/tiles/5/0/5.webp new file mode 100755 index 0000000..0033baf Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/5.webp differ diff --git a/delamain/frontend/img/tiles/5/0/6.webp b/delamain/frontend/img/tiles/5/0/6.webp new file mode 100755 index 0000000..89c072e Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/6.webp differ diff --git a/delamain/frontend/img/tiles/5/0/7.webp b/delamain/frontend/img/tiles/5/0/7.webp new file mode 100755 index 0000000..976275f Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/7.webp differ diff --git a/delamain/frontend/img/tiles/5/0/8.webp b/delamain/frontend/img/tiles/5/0/8.webp new file mode 100755 index 0000000..8ab5123 Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/8.webp differ diff --git a/delamain/frontend/img/tiles/5/0/9.webp b/delamain/frontend/img/tiles/5/0/9.webp new file mode 100755 index 0000000..dd8f78c Binary files /dev/null and b/delamain/frontend/img/tiles/5/0/9.webp differ diff --git a/delamain/frontend/img/tiles/5/1/0.webp b/delamain/frontend/img/tiles/5/1/0.webp new file mode 100755 index 0000000..340c61d Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/0.webp differ diff --git a/delamain/frontend/img/tiles/5/1/1.webp b/delamain/frontend/img/tiles/5/1/1.webp new file mode 100755 index 0000000..89fe172 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/1.webp differ diff --git a/delamain/frontend/img/tiles/5/1/10.webp b/delamain/frontend/img/tiles/5/1/10.webp new file mode 100755 index 0000000..7e4aa1c Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/10.webp differ diff --git a/delamain/frontend/img/tiles/5/1/11.webp b/delamain/frontend/img/tiles/5/1/11.webp new file mode 100755 index 0000000..9b12063 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/11.webp differ diff --git a/delamain/frontend/img/tiles/5/1/12.webp b/delamain/frontend/img/tiles/5/1/12.webp new file mode 100755 index 0000000..2fe6415 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/12.webp differ diff --git a/delamain/frontend/img/tiles/5/1/13.webp b/delamain/frontend/img/tiles/5/1/13.webp new file mode 100755 index 0000000..f8bcff4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/13.webp differ diff --git a/delamain/frontend/img/tiles/5/1/14.webp b/delamain/frontend/img/tiles/5/1/14.webp new file mode 100755 index 0000000..582fb43 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/14.webp differ diff --git a/delamain/frontend/img/tiles/5/1/15.webp b/delamain/frontend/img/tiles/5/1/15.webp new file mode 100755 index 0000000..cae964d Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/15.webp differ diff --git a/delamain/frontend/img/tiles/5/1/16.webp b/delamain/frontend/img/tiles/5/1/16.webp new file mode 100755 index 0000000..bc772ee Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/16.webp differ diff --git a/delamain/frontend/img/tiles/5/1/17.webp b/delamain/frontend/img/tiles/5/1/17.webp new file mode 100755 index 0000000..5aacaf2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/17.webp differ diff --git a/delamain/frontend/img/tiles/5/1/18.webp b/delamain/frontend/img/tiles/5/1/18.webp new file mode 100755 index 0000000..1184b3f Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/18.webp differ diff --git a/delamain/frontend/img/tiles/5/1/19.webp b/delamain/frontend/img/tiles/5/1/19.webp new file mode 100755 index 0000000..ed81d62 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/19.webp differ diff --git a/delamain/frontend/img/tiles/5/1/2.webp b/delamain/frontend/img/tiles/5/1/2.webp new file mode 100755 index 0000000..c8c94d4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/2.webp differ diff --git a/delamain/frontend/img/tiles/5/1/20.webp b/delamain/frontend/img/tiles/5/1/20.webp new file mode 100755 index 0000000..fa0d7ac Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/20.webp differ diff --git a/delamain/frontend/img/tiles/5/1/21.webp b/delamain/frontend/img/tiles/5/1/21.webp new file mode 100755 index 0000000..ba73806 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/21.webp differ diff --git a/delamain/frontend/img/tiles/5/1/22.webp b/delamain/frontend/img/tiles/5/1/22.webp new file mode 100755 index 0000000..9e8bdce Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/22.webp differ diff --git a/delamain/frontend/img/tiles/5/1/23.webp b/delamain/frontend/img/tiles/5/1/23.webp new file mode 100755 index 0000000..d68d6f9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/23.webp differ diff --git a/delamain/frontend/img/tiles/5/1/24.webp b/delamain/frontend/img/tiles/5/1/24.webp new file mode 100755 index 0000000..dff53d4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/24.webp differ diff --git a/delamain/frontend/img/tiles/5/1/25.webp b/delamain/frontend/img/tiles/5/1/25.webp new file mode 100755 index 0000000..1a5ba84 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/25.webp differ diff --git a/delamain/frontend/img/tiles/5/1/26.webp b/delamain/frontend/img/tiles/5/1/26.webp new file mode 100755 index 0000000..5db0a00 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/26.webp differ diff --git a/delamain/frontend/img/tiles/5/1/3.webp b/delamain/frontend/img/tiles/5/1/3.webp new file mode 100755 index 0000000..ddc6189 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/3.webp differ diff --git a/delamain/frontend/img/tiles/5/1/4.webp b/delamain/frontend/img/tiles/5/1/4.webp new file mode 100755 index 0000000..9fbbc91 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/4.webp differ diff --git a/delamain/frontend/img/tiles/5/1/5.webp b/delamain/frontend/img/tiles/5/1/5.webp new file mode 100755 index 0000000..2fc1170 Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/5.webp differ diff --git a/delamain/frontend/img/tiles/5/1/6.webp b/delamain/frontend/img/tiles/5/1/6.webp new file mode 100755 index 0000000..47c98cb Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/6.webp differ diff --git a/delamain/frontend/img/tiles/5/1/7.webp b/delamain/frontend/img/tiles/5/1/7.webp new file mode 100755 index 0000000..c0a9aef Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/7.webp differ diff --git a/delamain/frontend/img/tiles/5/1/8.webp b/delamain/frontend/img/tiles/5/1/8.webp new file mode 100755 index 0000000..265e06b Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/8.webp differ diff --git a/delamain/frontend/img/tiles/5/1/9.webp b/delamain/frontend/img/tiles/5/1/9.webp new file mode 100755 index 0000000..31cacdb Binary files /dev/null and b/delamain/frontend/img/tiles/5/1/9.webp differ diff --git a/delamain/frontend/img/tiles/5/10/0.webp b/delamain/frontend/img/tiles/5/10/0.webp new file mode 100755 index 0000000..420aca2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/0.webp differ diff --git a/delamain/frontend/img/tiles/5/10/1.webp b/delamain/frontend/img/tiles/5/10/1.webp new file mode 100755 index 0000000..d8eb262 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/1.webp differ diff --git a/delamain/frontend/img/tiles/5/10/10.webp b/delamain/frontend/img/tiles/5/10/10.webp new file mode 100755 index 0000000..bac8b2b Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/10.webp differ diff --git a/delamain/frontend/img/tiles/5/10/11.webp b/delamain/frontend/img/tiles/5/10/11.webp new file mode 100755 index 0000000..65234b3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/11.webp differ diff --git a/delamain/frontend/img/tiles/5/10/12.webp b/delamain/frontend/img/tiles/5/10/12.webp new file mode 100755 index 0000000..e13e4cd Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/12.webp differ diff --git a/delamain/frontend/img/tiles/5/10/13.webp b/delamain/frontend/img/tiles/5/10/13.webp new file mode 100755 index 0000000..ee0661c Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/13.webp differ diff --git a/delamain/frontend/img/tiles/5/10/14.webp b/delamain/frontend/img/tiles/5/10/14.webp new file mode 100755 index 0000000..6cc935c Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/14.webp differ diff --git a/delamain/frontend/img/tiles/5/10/15.webp b/delamain/frontend/img/tiles/5/10/15.webp new file mode 100755 index 0000000..fe3fae3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/15.webp differ diff --git a/delamain/frontend/img/tiles/5/10/16.webp b/delamain/frontend/img/tiles/5/10/16.webp new file mode 100755 index 0000000..9fa4f64 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/16.webp differ diff --git a/delamain/frontend/img/tiles/5/10/17.webp b/delamain/frontend/img/tiles/5/10/17.webp new file mode 100755 index 0000000..93f7c2b Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/17.webp differ diff --git a/delamain/frontend/img/tiles/5/10/18.webp b/delamain/frontend/img/tiles/5/10/18.webp new file mode 100755 index 0000000..c838d91 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/18.webp differ diff --git a/delamain/frontend/img/tiles/5/10/19.webp b/delamain/frontend/img/tiles/5/10/19.webp new file mode 100755 index 0000000..9cbaa4c Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/19.webp differ diff --git a/delamain/frontend/img/tiles/5/10/2.webp b/delamain/frontend/img/tiles/5/10/2.webp new file mode 100755 index 0000000..599b621 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/2.webp differ diff --git a/delamain/frontend/img/tiles/5/10/20.webp b/delamain/frontend/img/tiles/5/10/20.webp new file mode 100755 index 0000000..abba6fc Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/20.webp differ diff --git a/delamain/frontend/img/tiles/5/10/21.webp b/delamain/frontend/img/tiles/5/10/21.webp new file mode 100755 index 0000000..f069e75 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/21.webp differ diff --git a/delamain/frontend/img/tiles/5/10/22.webp b/delamain/frontend/img/tiles/5/10/22.webp new file mode 100755 index 0000000..f71d247 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/22.webp differ diff --git a/delamain/frontend/img/tiles/5/10/23.webp b/delamain/frontend/img/tiles/5/10/23.webp new file mode 100755 index 0000000..ef03de8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/23.webp differ diff --git a/delamain/frontend/img/tiles/5/10/24.webp b/delamain/frontend/img/tiles/5/10/24.webp new file mode 100755 index 0000000..75c1ed8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/24.webp differ diff --git a/delamain/frontend/img/tiles/5/10/25.webp b/delamain/frontend/img/tiles/5/10/25.webp new file mode 100755 index 0000000..6c094f9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/25.webp differ diff --git a/delamain/frontend/img/tiles/5/10/26.webp b/delamain/frontend/img/tiles/5/10/26.webp new file mode 100755 index 0000000..b7350ea Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/26.webp differ diff --git a/delamain/frontend/img/tiles/5/10/3.webp b/delamain/frontend/img/tiles/5/10/3.webp new file mode 100755 index 0000000..658da2c Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/3.webp differ diff --git a/delamain/frontend/img/tiles/5/10/4.webp b/delamain/frontend/img/tiles/5/10/4.webp new file mode 100755 index 0000000..e73723b Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/4.webp differ diff --git a/delamain/frontend/img/tiles/5/10/5.webp b/delamain/frontend/img/tiles/5/10/5.webp new file mode 100755 index 0000000..f49359c Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/5.webp differ diff --git a/delamain/frontend/img/tiles/5/10/6.webp b/delamain/frontend/img/tiles/5/10/6.webp new file mode 100755 index 0000000..82d342d Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/6.webp differ diff --git a/delamain/frontend/img/tiles/5/10/7.webp b/delamain/frontend/img/tiles/5/10/7.webp new file mode 100755 index 0000000..3df997f Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/7.webp differ diff --git a/delamain/frontend/img/tiles/5/10/8.webp b/delamain/frontend/img/tiles/5/10/8.webp new file mode 100755 index 0000000..2942cfd Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/8.webp differ diff --git a/delamain/frontend/img/tiles/5/10/9.webp b/delamain/frontend/img/tiles/5/10/9.webp new file mode 100755 index 0000000..a00a61e Binary files /dev/null and b/delamain/frontend/img/tiles/5/10/9.webp differ diff --git a/delamain/frontend/img/tiles/5/11/0.webp b/delamain/frontend/img/tiles/5/11/0.webp new file mode 100755 index 0000000..7ed4c8f Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/0.webp differ diff --git a/delamain/frontend/img/tiles/5/11/1.webp b/delamain/frontend/img/tiles/5/11/1.webp new file mode 100755 index 0000000..3b9086b Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/1.webp differ diff --git a/delamain/frontend/img/tiles/5/11/10.webp b/delamain/frontend/img/tiles/5/11/10.webp new file mode 100755 index 0000000..c0f2cf7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/10.webp differ diff --git a/delamain/frontend/img/tiles/5/11/11.webp b/delamain/frontend/img/tiles/5/11/11.webp new file mode 100755 index 0000000..826e689 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/11.webp differ diff --git a/delamain/frontend/img/tiles/5/11/12.webp b/delamain/frontend/img/tiles/5/11/12.webp new file mode 100755 index 0000000..593808a Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/12.webp differ diff --git a/delamain/frontend/img/tiles/5/11/13.webp b/delamain/frontend/img/tiles/5/11/13.webp new file mode 100755 index 0000000..a6d2dd3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/13.webp differ diff --git a/delamain/frontend/img/tiles/5/11/14.webp b/delamain/frontend/img/tiles/5/11/14.webp new file mode 100755 index 0000000..4ca0c66 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/14.webp differ diff --git a/delamain/frontend/img/tiles/5/11/15.webp b/delamain/frontend/img/tiles/5/11/15.webp new file mode 100755 index 0000000..3afda67 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/15.webp differ diff --git a/delamain/frontend/img/tiles/5/11/16.webp b/delamain/frontend/img/tiles/5/11/16.webp new file mode 100755 index 0000000..9ea0383 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/16.webp differ diff --git a/delamain/frontend/img/tiles/5/11/17.webp b/delamain/frontend/img/tiles/5/11/17.webp new file mode 100755 index 0000000..d76b160 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/17.webp differ diff --git a/delamain/frontend/img/tiles/5/11/18.webp b/delamain/frontend/img/tiles/5/11/18.webp new file mode 100755 index 0000000..c1247f5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/18.webp differ diff --git a/delamain/frontend/img/tiles/5/11/19.webp b/delamain/frontend/img/tiles/5/11/19.webp new file mode 100755 index 0000000..3e4a83b Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/19.webp differ diff --git a/delamain/frontend/img/tiles/5/11/2.webp b/delamain/frontend/img/tiles/5/11/2.webp new file mode 100755 index 0000000..4b327d1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/2.webp differ diff --git a/delamain/frontend/img/tiles/5/11/20.webp b/delamain/frontend/img/tiles/5/11/20.webp new file mode 100755 index 0000000..3e3c488 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/20.webp differ diff --git a/delamain/frontend/img/tiles/5/11/21.webp b/delamain/frontend/img/tiles/5/11/21.webp new file mode 100755 index 0000000..cb08073 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/21.webp differ diff --git a/delamain/frontend/img/tiles/5/11/22.webp b/delamain/frontend/img/tiles/5/11/22.webp new file mode 100755 index 0000000..32a5edf Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/22.webp differ diff --git a/delamain/frontend/img/tiles/5/11/23.webp b/delamain/frontend/img/tiles/5/11/23.webp new file mode 100755 index 0000000..ebfb591 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/23.webp differ diff --git a/delamain/frontend/img/tiles/5/11/24.webp b/delamain/frontend/img/tiles/5/11/24.webp new file mode 100755 index 0000000..11f3eff Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/24.webp differ diff --git a/delamain/frontend/img/tiles/5/11/25.webp b/delamain/frontend/img/tiles/5/11/25.webp new file mode 100755 index 0000000..5098c3a Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/25.webp differ diff --git a/delamain/frontend/img/tiles/5/11/26.webp b/delamain/frontend/img/tiles/5/11/26.webp new file mode 100755 index 0000000..bb85b29 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/26.webp differ diff --git a/delamain/frontend/img/tiles/5/11/3.webp b/delamain/frontend/img/tiles/5/11/3.webp new file mode 100755 index 0000000..6970651 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/3.webp differ diff --git a/delamain/frontend/img/tiles/5/11/4.webp b/delamain/frontend/img/tiles/5/11/4.webp new file mode 100755 index 0000000..288dc64 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/4.webp differ diff --git a/delamain/frontend/img/tiles/5/11/5.webp b/delamain/frontend/img/tiles/5/11/5.webp new file mode 100755 index 0000000..c2a5cd7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/5.webp differ diff --git a/delamain/frontend/img/tiles/5/11/6.webp b/delamain/frontend/img/tiles/5/11/6.webp new file mode 100755 index 0000000..6410722 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/6.webp differ diff --git a/delamain/frontend/img/tiles/5/11/7.webp b/delamain/frontend/img/tiles/5/11/7.webp new file mode 100755 index 0000000..a0a2b72 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/7.webp differ diff --git a/delamain/frontend/img/tiles/5/11/8.webp b/delamain/frontend/img/tiles/5/11/8.webp new file mode 100755 index 0000000..df3f035 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/8.webp differ diff --git a/delamain/frontend/img/tiles/5/11/9.webp b/delamain/frontend/img/tiles/5/11/9.webp new file mode 100755 index 0000000..79d5401 Binary files /dev/null and b/delamain/frontend/img/tiles/5/11/9.webp differ diff --git a/delamain/frontend/img/tiles/5/12/0.webp b/delamain/frontend/img/tiles/5/12/0.webp new file mode 100755 index 0000000..70fe00b Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/0.webp differ diff --git a/delamain/frontend/img/tiles/5/12/1.webp b/delamain/frontend/img/tiles/5/12/1.webp new file mode 100755 index 0000000..c619620 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/1.webp differ diff --git a/delamain/frontend/img/tiles/5/12/10.webp b/delamain/frontend/img/tiles/5/12/10.webp new file mode 100755 index 0000000..a152b5d Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/10.webp differ diff --git a/delamain/frontend/img/tiles/5/12/11.webp b/delamain/frontend/img/tiles/5/12/11.webp new file mode 100755 index 0000000..e555aa6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/11.webp differ diff --git a/delamain/frontend/img/tiles/5/12/12.webp b/delamain/frontend/img/tiles/5/12/12.webp new file mode 100755 index 0000000..e7ed569 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/12.webp differ diff --git a/delamain/frontend/img/tiles/5/12/13.webp b/delamain/frontend/img/tiles/5/12/13.webp new file mode 100755 index 0000000..f81eac9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/13.webp differ diff --git a/delamain/frontend/img/tiles/5/12/14.webp b/delamain/frontend/img/tiles/5/12/14.webp new file mode 100755 index 0000000..f6faeeb Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/14.webp differ diff --git a/delamain/frontend/img/tiles/5/12/15.webp b/delamain/frontend/img/tiles/5/12/15.webp new file mode 100755 index 0000000..d3f9774 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/15.webp differ diff --git a/delamain/frontend/img/tiles/5/12/16.webp b/delamain/frontend/img/tiles/5/12/16.webp new file mode 100755 index 0000000..e144133 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/16.webp differ diff --git a/delamain/frontend/img/tiles/5/12/17.webp b/delamain/frontend/img/tiles/5/12/17.webp new file mode 100755 index 0000000..7e12d20 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/17.webp differ diff --git a/delamain/frontend/img/tiles/5/12/18.webp b/delamain/frontend/img/tiles/5/12/18.webp new file mode 100755 index 0000000..600a22e Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/18.webp differ diff --git a/delamain/frontend/img/tiles/5/12/19.webp b/delamain/frontend/img/tiles/5/12/19.webp new file mode 100755 index 0000000..b0f1b07 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/19.webp differ diff --git a/delamain/frontend/img/tiles/5/12/2.webp b/delamain/frontend/img/tiles/5/12/2.webp new file mode 100755 index 0000000..3a86832 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/2.webp differ diff --git a/delamain/frontend/img/tiles/5/12/20.webp b/delamain/frontend/img/tiles/5/12/20.webp new file mode 100755 index 0000000..0408833 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/20.webp differ diff --git a/delamain/frontend/img/tiles/5/12/21.webp b/delamain/frontend/img/tiles/5/12/21.webp new file mode 100755 index 0000000..a387f83 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/21.webp differ diff --git a/delamain/frontend/img/tiles/5/12/22.webp b/delamain/frontend/img/tiles/5/12/22.webp new file mode 100755 index 0000000..618a152 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/22.webp differ diff --git a/delamain/frontend/img/tiles/5/12/23.webp b/delamain/frontend/img/tiles/5/12/23.webp new file mode 100755 index 0000000..4c27d5d Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/23.webp differ diff --git a/delamain/frontend/img/tiles/5/12/24.webp b/delamain/frontend/img/tiles/5/12/24.webp new file mode 100755 index 0000000..17fd7c3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/24.webp differ diff --git a/delamain/frontend/img/tiles/5/12/25.webp b/delamain/frontend/img/tiles/5/12/25.webp new file mode 100755 index 0000000..582b221 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/25.webp differ diff --git a/delamain/frontend/img/tiles/5/12/26.webp b/delamain/frontend/img/tiles/5/12/26.webp new file mode 100755 index 0000000..6f4b315 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/26.webp differ diff --git a/delamain/frontend/img/tiles/5/12/3.webp b/delamain/frontend/img/tiles/5/12/3.webp new file mode 100755 index 0000000..d0e37c7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/3.webp differ diff --git a/delamain/frontend/img/tiles/5/12/4.webp b/delamain/frontend/img/tiles/5/12/4.webp new file mode 100755 index 0000000..e90df42 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/4.webp differ diff --git a/delamain/frontend/img/tiles/5/12/5.webp b/delamain/frontend/img/tiles/5/12/5.webp new file mode 100755 index 0000000..40e442c Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/5.webp differ diff --git a/delamain/frontend/img/tiles/5/12/6.webp b/delamain/frontend/img/tiles/5/12/6.webp new file mode 100755 index 0000000..5e7344e Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/6.webp differ diff --git a/delamain/frontend/img/tiles/5/12/7.webp b/delamain/frontend/img/tiles/5/12/7.webp new file mode 100755 index 0000000..a22b80c Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/7.webp differ diff --git a/delamain/frontend/img/tiles/5/12/8.webp b/delamain/frontend/img/tiles/5/12/8.webp new file mode 100755 index 0000000..8ac6e02 Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/8.webp differ diff --git a/delamain/frontend/img/tiles/5/12/9.webp b/delamain/frontend/img/tiles/5/12/9.webp new file mode 100755 index 0000000..7c6090b Binary files /dev/null and b/delamain/frontend/img/tiles/5/12/9.webp differ diff --git a/delamain/frontend/img/tiles/5/13/0.webp b/delamain/frontend/img/tiles/5/13/0.webp new file mode 100755 index 0000000..f388573 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/0.webp differ diff --git a/delamain/frontend/img/tiles/5/13/1.webp b/delamain/frontend/img/tiles/5/13/1.webp new file mode 100755 index 0000000..9d9e6e0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/1.webp differ diff --git a/delamain/frontend/img/tiles/5/13/10.webp b/delamain/frontend/img/tiles/5/13/10.webp new file mode 100755 index 0000000..70c4728 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/10.webp differ diff --git a/delamain/frontend/img/tiles/5/13/11.webp b/delamain/frontend/img/tiles/5/13/11.webp new file mode 100755 index 0000000..ffe033d Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/11.webp differ diff --git a/delamain/frontend/img/tiles/5/13/12.webp b/delamain/frontend/img/tiles/5/13/12.webp new file mode 100755 index 0000000..7aca8c2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/12.webp differ diff --git a/delamain/frontend/img/tiles/5/13/13.webp b/delamain/frontend/img/tiles/5/13/13.webp new file mode 100755 index 0000000..ae7610f Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/13.webp differ diff --git a/delamain/frontend/img/tiles/5/13/14.webp b/delamain/frontend/img/tiles/5/13/14.webp new file mode 100755 index 0000000..b51c51f Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/14.webp differ diff --git a/delamain/frontend/img/tiles/5/13/15.webp b/delamain/frontend/img/tiles/5/13/15.webp new file mode 100755 index 0000000..349dac5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/15.webp differ diff --git a/delamain/frontend/img/tiles/5/13/16.webp b/delamain/frontend/img/tiles/5/13/16.webp new file mode 100755 index 0000000..091f1ee Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/16.webp differ diff --git a/delamain/frontend/img/tiles/5/13/17.webp b/delamain/frontend/img/tiles/5/13/17.webp new file mode 100755 index 0000000..1b90e73 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/17.webp differ diff --git a/delamain/frontend/img/tiles/5/13/18.webp b/delamain/frontend/img/tiles/5/13/18.webp new file mode 100755 index 0000000..9fe9157 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/18.webp differ diff --git a/delamain/frontend/img/tiles/5/13/19.webp b/delamain/frontend/img/tiles/5/13/19.webp new file mode 100755 index 0000000..669bf29 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/19.webp differ diff --git a/delamain/frontend/img/tiles/5/13/2.webp b/delamain/frontend/img/tiles/5/13/2.webp new file mode 100755 index 0000000..19fb12e Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/2.webp differ diff --git a/delamain/frontend/img/tiles/5/13/20.webp b/delamain/frontend/img/tiles/5/13/20.webp new file mode 100755 index 0000000..8b716cc Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/20.webp differ diff --git a/delamain/frontend/img/tiles/5/13/21.webp b/delamain/frontend/img/tiles/5/13/21.webp new file mode 100755 index 0000000..cec0871 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/21.webp differ diff --git a/delamain/frontend/img/tiles/5/13/22.webp b/delamain/frontend/img/tiles/5/13/22.webp new file mode 100755 index 0000000..4ddda42 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/22.webp differ diff --git a/delamain/frontend/img/tiles/5/13/23.webp b/delamain/frontend/img/tiles/5/13/23.webp new file mode 100755 index 0000000..b11838a Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/23.webp differ diff --git a/delamain/frontend/img/tiles/5/13/24.webp b/delamain/frontend/img/tiles/5/13/24.webp new file mode 100755 index 0000000..9fe3f17 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/24.webp differ diff --git a/delamain/frontend/img/tiles/5/13/25.webp b/delamain/frontend/img/tiles/5/13/25.webp new file mode 100755 index 0000000..7c07345 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/25.webp differ diff --git a/delamain/frontend/img/tiles/5/13/26.webp b/delamain/frontend/img/tiles/5/13/26.webp new file mode 100755 index 0000000..19a7fea Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/26.webp differ diff --git a/delamain/frontend/img/tiles/5/13/3.webp b/delamain/frontend/img/tiles/5/13/3.webp new file mode 100755 index 0000000..7780c51 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/3.webp differ diff --git a/delamain/frontend/img/tiles/5/13/4.webp b/delamain/frontend/img/tiles/5/13/4.webp new file mode 100755 index 0000000..869a991 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/4.webp differ diff --git a/delamain/frontend/img/tiles/5/13/5.webp b/delamain/frontend/img/tiles/5/13/5.webp new file mode 100755 index 0000000..bbfd0b0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/5.webp differ diff --git a/delamain/frontend/img/tiles/5/13/6.webp b/delamain/frontend/img/tiles/5/13/6.webp new file mode 100755 index 0000000..265298f Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/6.webp differ diff --git a/delamain/frontend/img/tiles/5/13/7.webp b/delamain/frontend/img/tiles/5/13/7.webp new file mode 100755 index 0000000..dcaa056 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/7.webp differ diff --git a/delamain/frontend/img/tiles/5/13/8.webp b/delamain/frontend/img/tiles/5/13/8.webp new file mode 100755 index 0000000..f77d91c Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/8.webp differ diff --git a/delamain/frontend/img/tiles/5/13/9.webp b/delamain/frontend/img/tiles/5/13/9.webp new file mode 100755 index 0000000..f721a48 Binary files /dev/null and b/delamain/frontend/img/tiles/5/13/9.webp differ diff --git a/delamain/frontend/img/tiles/5/14/0.webp b/delamain/frontend/img/tiles/5/14/0.webp new file mode 100755 index 0000000..cefb905 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/0.webp differ diff --git a/delamain/frontend/img/tiles/5/14/1.webp b/delamain/frontend/img/tiles/5/14/1.webp new file mode 100755 index 0000000..4de526a Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/1.webp differ diff --git a/delamain/frontend/img/tiles/5/14/10.webp b/delamain/frontend/img/tiles/5/14/10.webp new file mode 100755 index 0000000..817b1aa Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/10.webp differ diff --git a/delamain/frontend/img/tiles/5/14/11.webp b/delamain/frontend/img/tiles/5/14/11.webp new file mode 100755 index 0000000..b120ac0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/11.webp differ diff --git a/delamain/frontend/img/tiles/5/14/12.webp b/delamain/frontend/img/tiles/5/14/12.webp new file mode 100755 index 0000000..85b88ad Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/12.webp differ diff --git a/delamain/frontend/img/tiles/5/14/13.webp b/delamain/frontend/img/tiles/5/14/13.webp new file mode 100755 index 0000000..cb1622a Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/13.webp differ diff --git a/delamain/frontend/img/tiles/5/14/14.webp b/delamain/frontend/img/tiles/5/14/14.webp new file mode 100755 index 0000000..c0ce5f9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/14.webp differ diff --git a/delamain/frontend/img/tiles/5/14/15.webp b/delamain/frontend/img/tiles/5/14/15.webp new file mode 100755 index 0000000..d7a1d8e Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/15.webp differ diff --git a/delamain/frontend/img/tiles/5/14/16.webp b/delamain/frontend/img/tiles/5/14/16.webp new file mode 100755 index 0000000..323fa4e Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/16.webp differ diff --git a/delamain/frontend/img/tiles/5/14/17.webp b/delamain/frontend/img/tiles/5/14/17.webp new file mode 100755 index 0000000..3ddbc14 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/17.webp differ diff --git a/delamain/frontend/img/tiles/5/14/18.webp b/delamain/frontend/img/tiles/5/14/18.webp new file mode 100755 index 0000000..35865b6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/18.webp differ diff --git a/delamain/frontend/img/tiles/5/14/19.webp b/delamain/frontend/img/tiles/5/14/19.webp new file mode 100755 index 0000000..33da08b Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/19.webp differ diff --git a/delamain/frontend/img/tiles/5/14/2.webp b/delamain/frontend/img/tiles/5/14/2.webp new file mode 100755 index 0000000..489544e Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/2.webp differ diff --git a/delamain/frontend/img/tiles/5/14/20.webp b/delamain/frontend/img/tiles/5/14/20.webp new file mode 100755 index 0000000..e95ec95 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/20.webp differ diff --git a/delamain/frontend/img/tiles/5/14/21.webp b/delamain/frontend/img/tiles/5/14/21.webp new file mode 100755 index 0000000..4bf9b25 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/21.webp differ diff --git a/delamain/frontend/img/tiles/5/14/22.webp b/delamain/frontend/img/tiles/5/14/22.webp new file mode 100755 index 0000000..7b0e439 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/22.webp differ diff --git a/delamain/frontend/img/tiles/5/14/23.webp b/delamain/frontend/img/tiles/5/14/23.webp new file mode 100755 index 0000000..2db8ded Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/23.webp differ diff --git a/delamain/frontend/img/tiles/5/14/24.webp b/delamain/frontend/img/tiles/5/14/24.webp new file mode 100755 index 0000000..51501a8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/24.webp differ diff --git a/delamain/frontend/img/tiles/5/14/25.webp b/delamain/frontend/img/tiles/5/14/25.webp new file mode 100755 index 0000000..edfbbd9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/25.webp differ diff --git a/delamain/frontend/img/tiles/5/14/26.webp b/delamain/frontend/img/tiles/5/14/26.webp new file mode 100755 index 0000000..c0abddc Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/26.webp differ diff --git a/delamain/frontend/img/tiles/5/14/3.webp b/delamain/frontend/img/tiles/5/14/3.webp new file mode 100755 index 0000000..9e086c5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/3.webp differ diff --git a/delamain/frontend/img/tiles/5/14/4.webp b/delamain/frontend/img/tiles/5/14/4.webp new file mode 100755 index 0000000..1363b3c Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/4.webp differ diff --git a/delamain/frontend/img/tiles/5/14/5.webp b/delamain/frontend/img/tiles/5/14/5.webp new file mode 100755 index 0000000..ddffbbe Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/5.webp differ diff --git a/delamain/frontend/img/tiles/5/14/6.webp b/delamain/frontend/img/tiles/5/14/6.webp new file mode 100755 index 0000000..1cba2b9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/6.webp differ diff --git a/delamain/frontend/img/tiles/5/14/7.webp b/delamain/frontend/img/tiles/5/14/7.webp new file mode 100755 index 0000000..39cfcb7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/7.webp differ diff --git a/delamain/frontend/img/tiles/5/14/8.webp b/delamain/frontend/img/tiles/5/14/8.webp new file mode 100755 index 0000000..2b88a06 Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/8.webp differ diff --git a/delamain/frontend/img/tiles/5/14/9.webp b/delamain/frontend/img/tiles/5/14/9.webp new file mode 100755 index 0000000..cf8cafa Binary files /dev/null and b/delamain/frontend/img/tiles/5/14/9.webp differ diff --git a/delamain/frontend/img/tiles/5/15/0.webp b/delamain/frontend/img/tiles/5/15/0.webp new file mode 100755 index 0000000..3168532 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/0.webp differ diff --git a/delamain/frontend/img/tiles/5/15/1.webp b/delamain/frontend/img/tiles/5/15/1.webp new file mode 100755 index 0000000..361839c Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/1.webp differ diff --git a/delamain/frontend/img/tiles/5/15/10.webp b/delamain/frontend/img/tiles/5/15/10.webp new file mode 100755 index 0000000..3d2bb5f Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/10.webp differ diff --git a/delamain/frontend/img/tiles/5/15/11.webp b/delamain/frontend/img/tiles/5/15/11.webp new file mode 100755 index 0000000..94320b9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/11.webp differ diff --git a/delamain/frontend/img/tiles/5/15/12.webp b/delamain/frontend/img/tiles/5/15/12.webp new file mode 100755 index 0000000..0f02d11 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/12.webp differ diff --git a/delamain/frontend/img/tiles/5/15/13.webp b/delamain/frontend/img/tiles/5/15/13.webp new file mode 100755 index 0000000..7de5a63 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/13.webp differ diff --git a/delamain/frontend/img/tiles/5/15/14.webp b/delamain/frontend/img/tiles/5/15/14.webp new file mode 100755 index 0000000..5d41b71 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/14.webp differ diff --git a/delamain/frontend/img/tiles/5/15/15.webp b/delamain/frontend/img/tiles/5/15/15.webp new file mode 100755 index 0000000..2535a9a Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/15.webp differ diff --git a/delamain/frontend/img/tiles/5/15/16.webp b/delamain/frontend/img/tiles/5/15/16.webp new file mode 100755 index 0000000..fe96fff Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/16.webp differ diff --git a/delamain/frontend/img/tiles/5/15/17.webp b/delamain/frontend/img/tiles/5/15/17.webp new file mode 100755 index 0000000..5b7f5b6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/17.webp differ diff --git a/delamain/frontend/img/tiles/5/15/18.webp b/delamain/frontend/img/tiles/5/15/18.webp new file mode 100755 index 0000000..c7585f7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/18.webp differ diff --git a/delamain/frontend/img/tiles/5/15/19.webp b/delamain/frontend/img/tiles/5/15/19.webp new file mode 100755 index 0000000..a72ece8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/19.webp differ diff --git a/delamain/frontend/img/tiles/5/15/2.webp b/delamain/frontend/img/tiles/5/15/2.webp new file mode 100755 index 0000000..1f270d8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/2.webp differ diff --git a/delamain/frontend/img/tiles/5/15/20.webp b/delamain/frontend/img/tiles/5/15/20.webp new file mode 100755 index 0000000..9aef094 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/20.webp differ diff --git a/delamain/frontend/img/tiles/5/15/21.webp b/delamain/frontend/img/tiles/5/15/21.webp new file mode 100755 index 0000000..5c8f00d Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/21.webp differ diff --git a/delamain/frontend/img/tiles/5/15/22.webp b/delamain/frontend/img/tiles/5/15/22.webp new file mode 100755 index 0000000..32d86ad Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/22.webp differ diff --git a/delamain/frontend/img/tiles/5/15/23.webp b/delamain/frontend/img/tiles/5/15/23.webp new file mode 100755 index 0000000..de1dabb Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/23.webp differ diff --git a/delamain/frontend/img/tiles/5/15/24.webp b/delamain/frontend/img/tiles/5/15/24.webp new file mode 100755 index 0000000..6aaeb5d Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/24.webp differ diff --git a/delamain/frontend/img/tiles/5/15/25.webp b/delamain/frontend/img/tiles/5/15/25.webp new file mode 100755 index 0000000..353e816 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/25.webp differ diff --git a/delamain/frontend/img/tiles/5/15/26.webp b/delamain/frontend/img/tiles/5/15/26.webp new file mode 100755 index 0000000..ef0a8a1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/26.webp differ diff --git a/delamain/frontend/img/tiles/5/15/3.webp b/delamain/frontend/img/tiles/5/15/3.webp new file mode 100755 index 0000000..601dc50 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/3.webp differ diff --git a/delamain/frontend/img/tiles/5/15/4.webp b/delamain/frontend/img/tiles/5/15/4.webp new file mode 100755 index 0000000..3bc1cfa Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/4.webp differ diff --git a/delamain/frontend/img/tiles/5/15/5.webp b/delamain/frontend/img/tiles/5/15/5.webp new file mode 100755 index 0000000..be0b254 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/5.webp differ diff --git a/delamain/frontend/img/tiles/5/15/6.webp b/delamain/frontend/img/tiles/5/15/6.webp new file mode 100755 index 0000000..a873414 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/6.webp differ diff --git a/delamain/frontend/img/tiles/5/15/7.webp b/delamain/frontend/img/tiles/5/15/7.webp new file mode 100755 index 0000000..541c32d Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/7.webp differ diff --git a/delamain/frontend/img/tiles/5/15/8.webp b/delamain/frontend/img/tiles/5/15/8.webp new file mode 100755 index 0000000..796fdd4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/8.webp differ diff --git a/delamain/frontend/img/tiles/5/15/9.webp b/delamain/frontend/img/tiles/5/15/9.webp new file mode 100755 index 0000000..49d5e1b Binary files /dev/null and b/delamain/frontend/img/tiles/5/15/9.webp differ diff --git a/delamain/frontend/img/tiles/5/16/0.webp b/delamain/frontend/img/tiles/5/16/0.webp new file mode 100755 index 0000000..6fca4b7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/0.webp differ diff --git a/delamain/frontend/img/tiles/5/16/1.webp b/delamain/frontend/img/tiles/5/16/1.webp new file mode 100755 index 0000000..96c0796 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/1.webp differ diff --git a/delamain/frontend/img/tiles/5/16/10.webp b/delamain/frontend/img/tiles/5/16/10.webp new file mode 100755 index 0000000..763e32e Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/10.webp differ diff --git a/delamain/frontend/img/tiles/5/16/11.webp b/delamain/frontend/img/tiles/5/16/11.webp new file mode 100755 index 0000000..66a8536 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/11.webp differ diff --git a/delamain/frontend/img/tiles/5/16/12.webp b/delamain/frontend/img/tiles/5/16/12.webp new file mode 100755 index 0000000..2450dc1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/12.webp differ diff --git a/delamain/frontend/img/tiles/5/16/13.webp b/delamain/frontend/img/tiles/5/16/13.webp new file mode 100755 index 0000000..7bdcae5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/13.webp differ diff --git a/delamain/frontend/img/tiles/5/16/14.webp b/delamain/frontend/img/tiles/5/16/14.webp new file mode 100755 index 0000000..ac5ed15 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/14.webp differ diff --git a/delamain/frontend/img/tiles/5/16/15.webp b/delamain/frontend/img/tiles/5/16/15.webp new file mode 100755 index 0000000..67eeb2b Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/15.webp differ diff --git a/delamain/frontend/img/tiles/5/16/16.webp b/delamain/frontend/img/tiles/5/16/16.webp new file mode 100755 index 0000000..96ec9ab Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/16.webp differ diff --git a/delamain/frontend/img/tiles/5/16/17.webp b/delamain/frontend/img/tiles/5/16/17.webp new file mode 100755 index 0000000..5bf3eba Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/17.webp differ diff --git a/delamain/frontend/img/tiles/5/16/18.webp b/delamain/frontend/img/tiles/5/16/18.webp new file mode 100755 index 0000000..d133242 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/18.webp differ diff --git a/delamain/frontend/img/tiles/5/16/19.webp b/delamain/frontend/img/tiles/5/16/19.webp new file mode 100755 index 0000000..1738622 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/19.webp differ diff --git a/delamain/frontend/img/tiles/5/16/2.webp b/delamain/frontend/img/tiles/5/16/2.webp new file mode 100755 index 0000000..87ba67d Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/2.webp differ diff --git a/delamain/frontend/img/tiles/5/16/20.webp b/delamain/frontend/img/tiles/5/16/20.webp new file mode 100755 index 0000000..a3ee244 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/20.webp differ diff --git a/delamain/frontend/img/tiles/5/16/21.webp b/delamain/frontend/img/tiles/5/16/21.webp new file mode 100755 index 0000000..15fabd0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/21.webp differ diff --git a/delamain/frontend/img/tiles/5/16/22.webp b/delamain/frontend/img/tiles/5/16/22.webp new file mode 100755 index 0000000..db56d94 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/22.webp differ diff --git a/delamain/frontend/img/tiles/5/16/23.webp b/delamain/frontend/img/tiles/5/16/23.webp new file mode 100755 index 0000000..f91f354 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/23.webp differ diff --git a/delamain/frontend/img/tiles/5/16/24.webp b/delamain/frontend/img/tiles/5/16/24.webp new file mode 100755 index 0000000..faad053 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/24.webp differ diff --git a/delamain/frontend/img/tiles/5/16/25.webp b/delamain/frontend/img/tiles/5/16/25.webp new file mode 100755 index 0000000..4c9edf4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/25.webp differ diff --git a/delamain/frontend/img/tiles/5/16/26.webp b/delamain/frontend/img/tiles/5/16/26.webp new file mode 100755 index 0000000..bc0857e Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/26.webp differ diff --git a/delamain/frontend/img/tiles/5/16/3.webp b/delamain/frontend/img/tiles/5/16/3.webp new file mode 100755 index 0000000..3f91a2d Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/3.webp differ diff --git a/delamain/frontend/img/tiles/5/16/4.webp b/delamain/frontend/img/tiles/5/16/4.webp new file mode 100755 index 0000000..3d1551d Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/4.webp differ diff --git a/delamain/frontend/img/tiles/5/16/5.webp b/delamain/frontend/img/tiles/5/16/5.webp new file mode 100755 index 0000000..d9fac3a Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/5.webp differ diff --git a/delamain/frontend/img/tiles/5/16/6.webp b/delamain/frontend/img/tiles/5/16/6.webp new file mode 100755 index 0000000..777ba09 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/6.webp differ diff --git a/delamain/frontend/img/tiles/5/16/7.webp b/delamain/frontend/img/tiles/5/16/7.webp new file mode 100755 index 0000000..578b803 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/7.webp differ diff --git a/delamain/frontend/img/tiles/5/16/8.webp b/delamain/frontend/img/tiles/5/16/8.webp new file mode 100755 index 0000000..fc00373 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/8.webp differ diff --git a/delamain/frontend/img/tiles/5/16/9.webp b/delamain/frontend/img/tiles/5/16/9.webp new file mode 100755 index 0000000..b773f34 Binary files /dev/null and b/delamain/frontend/img/tiles/5/16/9.webp differ diff --git a/delamain/frontend/img/tiles/5/17/0.webp b/delamain/frontend/img/tiles/5/17/0.webp new file mode 100755 index 0000000..05b65b5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/0.webp differ diff --git a/delamain/frontend/img/tiles/5/17/1.webp b/delamain/frontend/img/tiles/5/17/1.webp new file mode 100755 index 0000000..b1438ff Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/1.webp differ diff --git a/delamain/frontend/img/tiles/5/17/10.webp b/delamain/frontend/img/tiles/5/17/10.webp new file mode 100755 index 0000000..55e2562 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/10.webp differ diff --git a/delamain/frontend/img/tiles/5/17/11.webp b/delamain/frontend/img/tiles/5/17/11.webp new file mode 100755 index 0000000..a6846c0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/11.webp differ diff --git a/delamain/frontend/img/tiles/5/17/12.webp b/delamain/frontend/img/tiles/5/17/12.webp new file mode 100755 index 0000000..627ff4b Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/12.webp differ diff --git a/delamain/frontend/img/tiles/5/17/13.webp b/delamain/frontend/img/tiles/5/17/13.webp new file mode 100755 index 0000000..6d0ce2e Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/13.webp differ diff --git a/delamain/frontend/img/tiles/5/17/14.webp b/delamain/frontend/img/tiles/5/17/14.webp new file mode 100755 index 0000000..67a2427 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/14.webp differ diff --git a/delamain/frontend/img/tiles/5/17/15.webp b/delamain/frontend/img/tiles/5/17/15.webp new file mode 100755 index 0000000..7ecc8f7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/15.webp differ diff --git a/delamain/frontend/img/tiles/5/17/16.webp b/delamain/frontend/img/tiles/5/17/16.webp new file mode 100755 index 0000000..f2119ce Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/16.webp differ diff --git a/delamain/frontend/img/tiles/5/17/17.webp b/delamain/frontend/img/tiles/5/17/17.webp new file mode 100755 index 0000000..1aac9ba Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/17.webp differ diff --git a/delamain/frontend/img/tiles/5/17/18.webp b/delamain/frontend/img/tiles/5/17/18.webp new file mode 100755 index 0000000..868108d Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/18.webp differ diff --git a/delamain/frontend/img/tiles/5/17/19.webp b/delamain/frontend/img/tiles/5/17/19.webp new file mode 100755 index 0000000..87b9219 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/19.webp differ diff --git a/delamain/frontend/img/tiles/5/17/2.webp b/delamain/frontend/img/tiles/5/17/2.webp new file mode 100755 index 0000000..8159e3f Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/2.webp differ diff --git a/delamain/frontend/img/tiles/5/17/20.webp b/delamain/frontend/img/tiles/5/17/20.webp new file mode 100755 index 0000000..ae43662 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/20.webp differ diff --git a/delamain/frontend/img/tiles/5/17/21.webp b/delamain/frontend/img/tiles/5/17/21.webp new file mode 100755 index 0000000..e140ef5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/21.webp differ diff --git a/delamain/frontend/img/tiles/5/17/22.webp b/delamain/frontend/img/tiles/5/17/22.webp new file mode 100755 index 0000000..4ebc9d7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/22.webp differ diff --git a/delamain/frontend/img/tiles/5/17/23.webp b/delamain/frontend/img/tiles/5/17/23.webp new file mode 100755 index 0000000..214849f Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/23.webp differ diff --git a/delamain/frontend/img/tiles/5/17/24.webp b/delamain/frontend/img/tiles/5/17/24.webp new file mode 100755 index 0000000..9d3ee07 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/24.webp differ diff --git a/delamain/frontend/img/tiles/5/17/25.webp b/delamain/frontend/img/tiles/5/17/25.webp new file mode 100755 index 0000000..7f2e9ed Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/25.webp differ diff --git a/delamain/frontend/img/tiles/5/17/26.webp b/delamain/frontend/img/tiles/5/17/26.webp new file mode 100755 index 0000000..342a629 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/26.webp differ diff --git a/delamain/frontend/img/tiles/5/17/3.webp b/delamain/frontend/img/tiles/5/17/3.webp new file mode 100755 index 0000000..2da8197 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/3.webp differ diff --git a/delamain/frontend/img/tiles/5/17/4.webp b/delamain/frontend/img/tiles/5/17/4.webp new file mode 100755 index 0000000..0e63ae9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/4.webp differ diff --git a/delamain/frontend/img/tiles/5/17/5.webp b/delamain/frontend/img/tiles/5/17/5.webp new file mode 100755 index 0000000..54db63a Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/5.webp differ diff --git a/delamain/frontend/img/tiles/5/17/6.webp b/delamain/frontend/img/tiles/5/17/6.webp new file mode 100755 index 0000000..f2a0fb8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/6.webp differ diff --git a/delamain/frontend/img/tiles/5/17/7.webp b/delamain/frontend/img/tiles/5/17/7.webp new file mode 100755 index 0000000..90311c0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/7.webp differ diff --git a/delamain/frontend/img/tiles/5/17/8.webp b/delamain/frontend/img/tiles/5/17/8.webp new file mode 100755 index 0000000..13f45f3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/8.webp differ diff --git a/delamain/frontend/img/tiles/5/17/9.webp b/delamain/frontend/img/tiles/5/17/9.webp new file mode 100755 index 0000000..c950a14 Binary files /dev/null and b/delamain/frontend/img/tiles/5/17/9.webp differ diff --git a/delamain/frontend/img/tiles/5/18/0.webp b/delamain/frontend/img/tiles/5/18/0.webp new file mode 100755 index 0000000..ee4c553 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/0.webp differ diff --git a/delamain/frontend/img/tiles/5/18/1.webp b/delamain/frontend/img/tiles/5/18/1.webp new file mode 100755 index 0000000..6dcb122 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/1.webp differ diff --git a/delamain/frontend/img/tiles/5/18/10.webp b/delamain/frontend/img/tiles/5/18/10.webp new file mode 100755 index 0000000..cb8cdd1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/10.webp differ diff --git a/delamain/frontend/img/tiles/5/18/11.webp b/delamain/frontend/img/tiles/5/18/11.webp new file mode 100755 index 0000000..0d1e3ea Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/11.webp differ diff --git a/delamain/frontend/img/tiles/5/18/12.webp b/delamain/frontend/img/tiles/5/18/12.webp new file mode 100755 index 0000000..5a037aa Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/12.webp differ diff --git a/delamain/frontend/img/tiles/5/18/13.webp b/delamain/frontend/img/tiles/5/18/13.webp new file mode 100755 index 0000000..32af172 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/13.webp differ diff --git a/delamain/frontend/img/tiles/5/18/14.webp b/delamain/frontend/img/tiles/5/18/14.webp new file mode 100755 index 0000000..6ac4377 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/14.webp differ diff --git a/delamain/frontend/img/tiles/5/18/15.webp b/delamain/frontend/img/tiles/5/18/15.webp new file mode 100755 index 0000000..1467107 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/15.webp differ diff --git a/delamain/frontend/img/tiles/5/18/16.webp b/delamain/frontend/img/tiles/5/18/16.webp new file mode 100755 index 0000000..1f402ab Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/16.webp differ diff --git a/delamain/frontend/img/tiles/5/18/17.webp b/delamain/frontend/img/tiles/5/18/17.webp new file mode 100755 index 0000000..2c42ac8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/17.webp differ diff --git a/delamain/frontend/img/tiles/5/18/18.webp b/delamain/frontend/img/tiles/5/18/18.webp new file mode 100755 index 0000000..2f2b6bf Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/18.webp differ diff --git a/delamain/frontend/img/tiles/5/18/19.webp b/delamain/frontend/img/tiles/5/18/19.webp new file mode 100755 index 0000000..ad2e454 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/19.webp differ diff --git a/delamain/frontend/img/tiles/5/18/2.webp b/delamain/frontend/img/tiles/5/18/2.webp new file mode 100755 index 0000000..0840c80 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/2.webp differ diff --git a/delamain/frontend/img/tiles/5/18/20.webp b/delamain/frontend/img/tiles/5/18/20.webp new file mode 100755 index 0000000..ac76af3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/20.webp differ diff --git a/delamain/frontend/img/tiles/5/18/21.webp b/delamain/frontend/img/tiles/5/18/21.webp new file mode 100755 index 0000000..77044a8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/21.webp differ diff --git a/delamain/frontend/img/tiles/5/18/22.webp b/delamain/frontend/img/tiles/5/18/22.webp new file mode 100755 index 0000000..3b47879 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/22.webp differ diff --git a/delamain/frontend/img/tiles/5/18/23.webp b/delamain/frontend/img/tiles/5/18/23.webp new file mode 100755 index 0000000..0158fea Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/23.webp differ diff --git a/delamain/frontend/img/tiles/5/18/24.webp b/delamain/frontend/img/tiles/5/18/24.webp new file mode 100755 index 0000000..ef60565 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/24.webp differ diff --git a/delamain/frontend/img/tiles/5/18/25.webp b/delamain/frontend/img/tiles/5/18/25.webp new file mode 100755 index 0000000..a060f38 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/25.webp differ diff --git a/delamain/frontend/img/tiles/5/18/26.webp b/delamain/frontend/img/tiles/5/18/26.webp new file mode 100755 index 0000000..e92853e Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/26.webp differ diff --git a/delamain/frontend/img/tiles/5/18/3.webp b/delamain/frontend/img/tiles/5/18/3.webp new file mode 100755 index 0000000..23f5548 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/3.webp differ diff --git a/delamain/frontend/img/tiles/5/18/4.webp b/delamain/frontend/img/tiles/5/18/4.webp new file mode 100755 index 0000000..0da6178 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/4.webp differ diff --git a/delamain/frontend/img/tiles/5/18/5.webp b/delamain/frontend/img/tiles/5/18/5.webp new file mode 100755 index 0000000..397d245 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/5.webp differ diff --git a/delamain/frontend/img/tiles/5/18/6.webp b/delamain/frontend/img/tiles/5/18/6.webp new file mode 100755 index 0000000..db04245 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/6.webp differ diff --git a/delamain/frontend/img/tiles/5/18/7.webp b/delamain/frontend/img/tiles/5/18/7.webp new file mode 100755 index 0000000..d0a3046 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/7.webp differ diff --git a/delamain/frontend/img/tiles/5/18/8.webp b/delamain/frontend/img/tiles/5/18/8.webp new file mode 100755 index 0000000..22a74cf Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/8.webp differ diff --git a/delamain/frontend/img/tiles/5/18/9.webp b/delamain/frontend/img/tiles/5/18/9.webp new file mode 100755 index 0000000..bdf0611 Binary files /dev/null and b/delamain/frontend/img/tiles/5/18/9.webp differ diff --git a/delamain/frontend/img/tiles/5/19/0.webp b/delamain/frontend/img/tiles/5/19/0.webp new file mode 100755 index 0000000..717d22e Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/0.webp differ diff --git a/delamain/frontend/img/tiles/5/19/1.webp b/delamain/frontend/img/tiles/5/19/1.webp new file mode 100755 index 0000000..94174f6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/1.webp differ diff --git a/delamain/frontend/img/tiles/5/19/10.webp b/delamain/frontend/img/tiles/5/19/10.webp new file mode 100755 index 0000000..8d0808a Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/10.webp differ diff --git a/delamain/frontend/img/tiles/5/19/11.webp b/delamain/frontend/img/tiles/5/19/11.webp new file mode 100755 index 0000000..c3aad80 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/11.webp differ diff --git a/delamain/frontend/img/tiles/5/19/12.webp b/delamain/frontend/img/tiles/5/19/12.webp new file mode 100755 index 0000000..a198cc9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/12.webp differ diff --git a/delamain/frontend/img/tiles/5/19/13.webp b/delamain/frontend/img/tiles/5/19/13.webp new file mode 100755 index 0000000..7b8969c Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/13.webp differ diff --git a/delamain/frontend/img/tiles/5/19/14.webp b/delamain/frontend/img/tiles/5/19/14.webp new file mode 100755 index 0000000..e5d0df0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/14.webp differ diff --git a/delamain/frontend/img/tiles/5/19/15.webp b/delamain/frontend/img/tiles/5/19/15.webp new file mode 100755 index 0000000..f954d4a Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/15.webp differ diff --git a/delamain/frontend/img/tiles/5/19/16.webp b/delamain/frontend/img/tiles/5/19/16.webp new file mode 100755 index 0000000..c245fa8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/16.webp differ diff --git a/delamain/frontend/img/tiles/5/19/17.webp b/delamain/frontend/img/tiles/5/19/17.webp new file mode 100755 index 0000000..7bac9e6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/17.webp differ diff --git a/delamain/frontend/img/tiles/5/19/18.webp b/delamain/frontend/img/tiles/5/19/18.webp new file mode 100755 index 0000000..744394f Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/18.webp differ diff --git a/delamain/frontend/img/tiles/5/19/19.webp b/delamain/frontend/img/tiles/5/19/19.webp new file mode 100755 index 0000000..2aff401 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/19.webp differ diff --git a/delamain/frontend/img/tiles/5/19/2.webp b/delamain/frontend/img/tiles/5/19/2.webp new file mode 100755 index 0000000..2dc9d21 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/2.webp differ diff --git a/delamain/frontend/img/tiles/5/19/20.webp b/delamain/frontend/img/tiles/5/19/20.webp new file mode 100755 index 0000000..94c1940 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/20.webp differ diff --git a/delamain/frontend/img/tiles/5/19/21.webp b/delamain/frontend/img/tiles/5/19/21.webp new file mode 100755 index 0000000..03161ec Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/21.webp differ diff --git a/delamain/frontend/img/tiles/5/19/22.webp b/delamain/frontend/img/tiles/5/19/22.webp new file mode 100755 index 0000000..c9ce50f Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/22.webp differ diff --git a/delamain/frontend/img/tiles/5/19/23.webp b/delamain/frontend/img/tiles/5/19/23.webp new file mode 100755 index 0000000..dbbc322 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/23.webp differ diff --git a/delamain/frontend/img/tiles/5/19/24.webp b/delamain/frontend/img/tiles/5/19/24.webp new file mode 100755 index 0000000..2838b86 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/24.webp differ diff --git a/delamain/frontend/img/tiles/5/19/25.webp b/delamain/frontend/img/tiles/5/19/25.webp new file mode 100755 index 0000000..6983cf3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/25.webp differ diff --git a/delamain/frontend/img/tiles/5/19/26.webp b/delamain/frontend/img/tiles/5/19/26.webp new file mode 100755 index 0000000..d5c1e02 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/26.webp differ diff --git a/delamain/frontend/img/tiles/5/19/3.webp b/delamain/frontend/img/tiles/5/19/3.webp new file mode 100755 index 0000000..bd8942c Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/3.webp differ diff --git a/delamain/frontend/img/tiles/5/19/4.webp b/delamain/frontend/img/tiles/5/19/4.webp new file mode 100755 index 0000000..c6f0574 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/4.webp differ diff --git a/delamain/frontend/img/tiles/5/19/5.webp b/delamain/frontend/img/tiles/5/19/5.webp new file mode 100755 index 0000000..cdaa387 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/5.webp differ diff --git a/delamain/frontend/img/tiles/5/19/6.webp b/delamain/frontend/img/tiles/5/19/6.webp new file mode 100755 index 0000000..210ce1e Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/6.webp differ diff --git a/delamain/frontend/img/tiles/5/19/7.webp b/delamain/frontend/img/tiles/5/19/7.webp new file mode 100755 index 0000000..92020c8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/7.webp differ diff --git a/delamain/frontend/img/tiles/5/19/8.webp b/delamain/frontend/img/tiles/5/19/8.webp new file mode 100755 index 0000000..d6d96b8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/8.webp differ diff --git a/delamain/frontend/img/tiles/5/19/9.webp b/delamain/frontend/img/tiles/5/19/9.webp new file mode 100755 index 0000000..2836fc7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/19/9.webp differ diff --git a/delamain/frontend/img/tiles/5/2/0.webp b/delamain/frontend/img/tiles/5/2/0.webp new file mode 100755 index 0000000..7e91997 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/0.webp differ diff --git a/delamain/frontend/img/tiles/5/2/1.webp b/delamain/frontend/img/tiles/5/2/1.webp new file mode 100755 index 0000000..a83be2e Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/1.webp differ diff --git a/delamain/frontend/img/tiles/5/2/10.webp b/delamain/frontend/img/tiles/5/2/10.webp new file mode 100755 index 0000000..8c5bbbf Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/10.webp differ diff --git a/delamain/frontend/img/tiles/5/2/11.webp b/delamain/frontend/img/tiles/5/2/11.webp new file mode 100755 index 0000000..a15ce90 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/11.webp differ diff --git a/delamain/frontend/img/tiles/5/2/12.webp b/delamain/frontend/img/tiles/5/2/12.webp new file mode 100755 index 0000000..ba516ab Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/12.webp differ diff --git a/delamain/frontend/img/tiles/5/2/13.webp b/delamain/frontend/img/tiles/5/2/13.webp new file mode 100755 index 0000000..b6a2ef2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/13.webp differ diff --git a/delamain/frontend/img/tiles/5/2/14.webp b/delamain/frontend/img/tiles/5/2/14.webp new file mode 100755 index 0000000..305e805 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/14.webp differ diff --git a/delamain/frontend/img/tiles/5/2/15.webp b/delamain/frontend/img/tiles/5/2/15.webp new file mode 100755 index 0000000..f9c9376 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/15.webp differ diff --git a/delamain/frontend/img/tiles/5/2/16.webp b/delamain/frontend/img/tiles/5/2/16.webp new file mode 100755 index 0000000..9dffe8b Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/16.webp differ diff --git a/delamain/frontend/img/tiles/5/2/17.webp b/delamain/frontend/img/tiles/5/2/17.webp new file mode 100755 index 0000000..a11ab31 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/17.webp differ diff --git a/delamain/frontend/img/tiles/5/2/18.webp b/delamain/frontend/img/tiles/5/2/18.webp new file mode 100755 index 0000000..bbede69 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/18.webp differ diff --git a/delamain/frontend/img/tiles/5/2/19.webp b/delamain/frontend/img/tiles/5/2/19.webp new file mode 100755 index 0000000..68b0347 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/19.webp differ diff --git a/delamain/frontend/img/tiles/5/2/2.webp b/delamain/frontend/img/tiles/5/2/2.webp new file mode 100755 index 0000000..520c964 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/2.webp differ diff --git a/delamain/frontend/img/tiles/5/2/20.webp b/delamain/frontend/img/tiles/5/2/20.webp new file mode 100755 index 0000000..05c6f97 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/20.webp differ diff --git a/delamain/frontend/img/tiles/5/2/21.webp b/delamain/frontend/img/tiles/5/2/21.webp new file mode 100755 index 0000000..312f56f Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/21.webp differ diff --git a/delamain/frontend/img/tiles/5/2/22.webp b/delamain/frontend/img/tiles/5/2/22.webp new file mode 100755 index 0000000..6595fd1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/22.webp differ diff --git a/delamain/frontend/img/tiles/5/2/23.webp b/delamain/frontend/img/tiles/5/2/23.webp new file mode 100755 index 0000000..68431e4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/23.webp differ diff --git a/delamain/frontend/img/tiles/5/2/24.webp b/delamain/frontend/img/tiles/5/2/24.webp new file mode 100755 index 0000000..aa46b91 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/24.webp differ diff --git a/delamain/frontend/img/tiles/5/2/25.webp b/delamain/frontend/img/tiles/5/2/25.webp new file mode 100755 index 0000000..1f85665 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/25.webp differ diff --git a/delamain/frontend/img/tiles/5/2/26.webp b/delamain/frontend/img/tiles/5/2/26.webp new file mode 100755 index 0000000..608efed Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/26.webp differ diff --git a/delamain/frontend/img/tiles/5/2/3.webp b/delamain/frontend/img/tiles/5/2/3.webp new file mode 100755 index 0000000..86831e1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/3.webp differ diff --git a/delamain/frontend/img/tiles/5/2/4.webp b/delamain/frontend/img/tiles/5/2/4.webp new file mode 100755 index 0000000..c8b20aa Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/4.webp differ diff --git a/delamain/frontend/img/tiles/5/2/5.webp b/delamain/frontend/img/tiles/5/2/5.webp new file mode 100755 index 0000000..13c2dfd Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/5.webp differ diff --git a/delamain/frontend/img/tiles/5/2/6.webp b/delamain/frontend/img/tiles/5/2/6.webp new file mode 100755 index 0000000..b1deb94 Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/6.webp differ diff --git a/delamain/frontend/img/tiles/5/2/7.webp b/delamain/frontend/img/tiles/5/2/7.webp new file mode 100755 index 0000000..fb28bae Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/7.webp differ diff --git a/delamain/frontend/img/tiles/5/2/8.webp b/delamain/frontend/img/tiles/5/2/8.webp new file mode 100755 index 0000000..fb59e6b Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/8.webp differ diff --git a/delamain/frontend/img/tiles/5/2/9.webp b/delamain/frontend/img/tiles/5/2/9.webp new file mode 100755 index 0000000..93f668a Binary files /dev/null and b/delamain/frontend/img/tiles/5/2/9.webp differ diff --git a/delamain/frontend/img/tiles/5/20/0.webp b/delamain/frontend/img/tiles/5/20/0.webp new file mode 100755 index 0000000..2269c07 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/0.webp differ diff --git a/delamain/frontend/img/tiles/5/20/1.webp b/delamain/frontend/img/tiles/5/20/1.webp new file mode 100755 index 0000000..99f65e9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/1.webp differ diff --git a/delamain/frontend/img/tiles/5/20/10.webp b/delamain/frontend/img/tiles/5/20/10.webp new file mode 100755 index 0000000..a158fa3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/10.webp differ diff --git a/delamain/frontend/img/tiles/5/20/11.webp b/delamain/frontend/img/tiles/5/20/11.webp new file mode 100755 index 0000000..f1b3673 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/11.webp differ diff --git a/delamain/frontend/img/tiles/5/20/12.webp b/delamain/frontend/img/tiles/5/20/12.webp new file mode 100755 index 0000000..d87455c Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/12.webp differ diff --git a/delamain/frontend/img/tiles/5/20/13.webp b/delamain/frontend/img/tiles/5/20/13.webp new file mode 100755 index 0000000..79a29bb Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/13.webp differ diff --git a/delamain/frontend/img/tiles/5/20/14.webp b/delamain/frontend/img/tiles/5/20/14.webp new file mode 100755 index 0000000..a5cb7fe Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/14.webp differ diff --git a/delamain/frontend/img/tiles/5/20/15.webp b/delamain/frontend/img/tiles/5/20/15.webp new file mode 100755 index 0000000..ca54edc Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/15.webp differ diff --git a/delamain/frontend/img/tiles/5/20/16.webp b/delamain/frontend/img/tiles/5/20/16.webp new file mode 100755 index 0000000..25797cf Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/16.webp differ diff --git a/delamain/frontend/img/tiles/5/20/17.webp b/delamain/frontend/img/tiles/5/20/17.webp new file mode 100755 index 0000000..3e466e0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/17.webp differ diff --git a/delamain/frontend/img/tiles/5/20/18.webp b/delamain/frontend/img/tiles/5/20/18.webp new file mode 100755 index 0000000..1388c09 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/18.webp differ diff --git a/delamain/frontend/img/tiles/5/20/19.webp b/delamain/frontend/img/tiles/5/20/19.webp new file mode 100755 index 0000000..08b2f84 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/19.webp differ diff --git a/delamain/frontend/img/tiles/5/20/2.webp b/delamain/frontend/img/tiles/5/20/2.webp new file mode 100755 index 0000000..07b792b Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/2.webp differ diff --git a/delamain/frontend/img/tiles/5/20/20.webp b/delamain/frontend/img/tiles/5/20/20.webp new file mode 100755 index 0000000..5045c75 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/20.webp differ diff --git a/delamain/frontend/img/tiles/5/20/21.webp b/delamain/frontend/img/tiles/5/20/21.webp new file mode 100755 index 0000000..2016412 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/21.webp differ diff --git a/delamain/frontend/img/tiles/5/20/22.webp b/delamain/frontend/img/tiles/5/20/22.webp new file mode 100755 index 0000000..fa40b1f Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/22.webp differ diff --git a/delamain/frontend/img/tiles/5/20/23.webp b/delamain/frontend/img/tiles/5/20/23.webp new file mode 100755 index 0000000..555edff Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/23.webp differ diff --git a/delamain/frontend/img/tiles/5/20/24.webp b/delamain/frontend/img/tiles/5/20/24.webp new file mode 100755 index 0000000..3e6487e Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/24.webp differ diff --git a/delamain/frontend/img/tiles/5/20/25.webp b/delamain/frontend/img/tiles/5/20/25.webp new file mode 100755 index 0000000..aa0255f Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/25.webp differ diff --git a/delamain/frontend/img/tiles/5/20/26.webp b/delamain/frontend/img/tiles/5/20/26.webp new file mode 100755 index 0000000..9e49741 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/26.webp differ diff --git a/delamain/frontend/img/tiles/5/20/3.webp b/delamain/frontend/img/tiles/5/20/3.webp new file mode 100755 index 0000000..a741861 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/3.webp differ diff --git a/delamain/frontend/img/tiles/5/20/4.webp b/delamain/frontend/img/tiles/5/20/4.webp new file mode 100755 index 0000000..950db86 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/4.webp differ diff --git a/delamain/frontend/img/tiles/5/20/5.webp b/delamain/frontend/img/tiles/5/20/5.webp new file mode 100755 index 0000000..5e3025b Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/5.webp differ diff --git a/delamain/frontend/img/tiles/5/20/6.webp b/delamain/frontend/img/tiles/5/20/6.webp new file mode 100755 index 0000000..4872017 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/6.webp differ diff --git a/delamain/frontend/img/tiles/5/20/7.webp b/delamain/frontend/img/tiles/5/20/7.webp new file mode 100755 index 0000000..b1884ce Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/7.webp differ diff --git a/delamain/frontend/img/tiles/5/20/8.webp b/delamain/frontend/img/tiles/5/20/8.webp new file mode 100755 index 0000000..13245ff Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/8.webp differ diff --git a/delamain/frontend/img/tiles/5/20/9.webp b/delamain/frontend/img/tiles/5/20/9.webp new file mode 100755 index 0000000..6e83bb1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/20/9.webp differ diff --git a/delamain/frontend/img/tiles/5/21/0.webp b/delamain/frontend/img/tiles/5/21/0.webp new file mode 100755 index 0000000..1c137af Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/0.webp differ diff --git a/delamain/frontend/img/tiles/5/21/1.webp b/delamain/frontend/img/tiles/5/21/1.webp new file mode 100755 index 0000000..ceb6e07 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/1.webp differ diff --git a/delamain/frontend/img/tiles/5/21/10.webp b/delamain/frontend/img/tiles/5/21/10.webp new file mode 100755 index 0000000..d76d8cb Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/10.webp differ diff --git a/delamain/frontend/img/tiles/5/21/11.webp b/delamain/frontend/img/tiles/5/21/11.webp new file mode 100755 index 0000000..ac2f95d Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/11.webp differ diff --git a/delamain/frontend/img/tiles/5/21/12.webp b/delamain/frontend/img/tiles/5/21/12.webp new file mode 100755 index 0000000..5126f5f Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/12.webp differ diff --git a/delamain/frontend/img/tiles/5/21/13.webp b/delamain/frontend/img/tiles/5/21/13.webp new file mode 100755 index 0000000..ece826c Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/13.webp differ diff --git a/delamain/frontend/img/tiles/5/21/14.webp b/delamain/frontend/img/tiles/5/21/14.webp new file mode 100755 index 0000000..8b4cf0a Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/14.webp differ diff --git a/delamain/frontend/img/tiles/5/21/15.webp b/delamain/frontend/img/tiles/5/21/15.webp new file mode 100755 index 0000000..d6203f1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/15.webp differ diff --git a/delamain/frontend/img/tiles/5/21/16.webp b/delamain/frontend/img/tiles/5/21/16.webp new file mode 100755 index 0000000..6e23b8b Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/16.webp differ diff --git a/delamain/frontend/img/tiles/5/21/17.webp b/delamain/frontend/img/tiles/5/21/17.webp new file mode 100755 index 0000000..bceee1d Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/17.webp differ diff --git a/delamain/frontend/img/tiles/5/21/18.webp b/delamain/frontend/img/tiles/5/21/18.webp new file mode 100755 index 0000000..5314cea Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/18.webp differ diff --git a/delamain/frontend/img/tiles/5/21/19.webp b/delamain/frontend/img/tiles/5/21/19.webp new file mode 100755 index 0000000..b0ffdd8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/19.webp differ diff --git a/delamain/frontend/img/tiles/5/21/2.webp b/delamain/frontend/img/tiles/5/21/2.webp new file mode 100755 index 0000000..d4f7db7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/2.webp differ diff --git a/delamain/frontend/img/tiles/5/21/20.webp b/delamain/frontend/img/tiles/5/21/20.webp new file mode 100755 index 0000000..21f7f23 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/20.webp differ diff --git a/delamain/frontend/img/tiles/5/21/21.webp b/delamain/frontend/img/tiles/5/21/21.webp new file mode 100755 index 0000000..fec13f5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/21.webp differ diff --git a/delamain/frontend/img/tiles/5/21/22.webp b/delamain/frontend/img/tiles/5/21/22.webp new file mode 100755 index 0000000..f031199 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/22.webp differ diff --git a/delamain/frontend/img/tiles/5/21/23.webp b/delamain/frontend/img/tiles/5/21/23.webp new file mode 100755 index 0000000..4094ae4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/23.webp differ diff --git a/delamain/frontend/img/tiles/5/21/24.webp b/delamain/frontend/img/tiles/5/21/24.webp new file mode 100755 index 0000000..7a2141f Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/24.webp differ diff --git a/delamain/frontend/img/tiles/5/21/25.webp b/delamain/frontend/img/tiles/5/21/25.webp new file mode 100755 index 0000000..412f12a Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/25.webp differ diff --git a/delamain/frontend/img/tiles/5/21/26.webp b/delamain/frontend/img/tiles/5/21/26.webp new file mode 100755 index 0000000..27b4bef Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/26.webp differ diff --git a/delamain/frontend/img/tiles/5/21/3.webp b/delamain/frontend/img/tiles/5/21/3.webp new file mode 100755 index 0000000..0f505d7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/3.webp differ diff --git a/delamain/frontend/img/tiles/5/21/4.webp b/delamain/frontend/img/tiles/5/21/4.webp new file mode 100755 index 0000000..4860ba0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/4.webp differ diff --git a/delamain/frontend/img/tiles/5/21/5.webp b/delamain/frontend/img/tiles/5/21/5.webp new file mode 100755 index 0000000..96a40b1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/5.webp differ diff --git a/delamain/frontend/img/tiles/5/21/6.webp b/delamain/frontend/img/tiles/5/21/6.webp new file mode 100755 index 0000000..3f2e783 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/6.webp differ diff --git a/delamain/frontend/img/tiles/5/21/7.webp b/delamain/frontend/img/tiles/5/21/7.webp new file mode 100755 index 0000000..f01df4f Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/7.webp differ diff --git a/delamain/frontend/img/tiles/5/21/8.webp b/delamain/frontend/img/tiles/5/21/8.webp new file mode 100755 index 0000000..fa6e02c Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/8.webp differ diff --git a/delamain/frontend/img/tiles/5/21/9.webp b/delamain/frontend/img/tiles/5/21/9.webp new file mode 100755 index 0000000..8987ac2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/21/9.webp differ diff --git a/delamain/frontend/img/tiles/5/22/0.webp b/delamain/frontend/img/tiles/5/22/0.webp new file mode 100755 index 0000000..1952d1e Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/0.webp differ diff --git a/delamain/frontend/img/tiles/5/22/1.webp b/delamain/frontend/img/tiles/5/22/1.webp new file mode 100755 index 0000000..c12a514 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/1.webp differ diff --git a/delamain/frontend/img/tiles/5/22/10.webp b/delamain/frontend/img/tiles/5/22/10.webp new file mode 100755 index 0000000..69b0504 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/10.webp differ diff --git a/delamain/frontend/img/tiles/5/22/11.webp b/delamain/frontend/img/tiles/5/22/11.webp new file mode 100755 index 0000000..3a5692f Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/11.webp differ diff --git a/delamain/frontend/img/tiles/5/22/12.webp b/delamain/frontend/img/tiles/5/22/12.webp new file mode 100755 index 0000000..610a23e Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/12.webp differ diff --git a/delamain/frontend/img/tiles/5/22/13.webp b/delamain/frontend/img/tiles/5/22/13.webp new file mode 100755 index 0000000..f0a05a4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/13.webp differ diff --git a/delamain/frontend/img/tiles/5/22/14.webp b/delamain/frontend/img/tiles/5/22/14.webp new file mode 100755 index 0000000..2ee100f Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/14.webp differ diff --git a/delamain/frontend/img/tiles/5/22/15.webp b/delamain/frontend/img/tiles/5/22/15.webp new file mode 100755 index 0000000..2b3f063 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/15.webp differ diff --git a/delamain/frontend/img/tiles/5/22/16.webp b/delamain/frontend/img/tiles/5/22/16.webp new file mode 100755 index 0000000..8b78fd3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/16.webp differ diff --git a/delamain/frontend/img/tiles/5/22/17.webp b/delamain/frontend/img/tiles/5/22/17.webp new file mode 100755 index 0000000..a00ff89 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/17.webp differ diff --git a/delamain/frontend/img/tiles/5/22/18.webp b/delamain/frontend/img/tiles/5/22/18.webp new file mode 100755 index 0000000..4684112 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/18.webp differ diff --git a/delamain/frontend/img/tiles/5/22/19.webp b/delamain/frontend/img/tiles/5/22/19.webp new file mode 100755 index 0000000..e233bbc Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/19.webp differ diff --git a/delamain/frontend/img/tiles/5/22/2.webp b/delamain/frontend/img/tiles/5/22/2.webp new file mode 100755 index 0000000..6c4c6b0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/2.webp differ diff --git a/delamain/frontend/img/tiles/5/22/20.webp b/delamain/frontend/img/tiles/5/22/20.webp new file mode 100755 index 0000000..f5c6b2b Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/20.webp differ diff --git a/delamain/frontend/img/tiles/5/22/21.webp b/delamain/frontend/img/tiles/5/22/21.webp new file mode 100755 index 0000000..d6abccf Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/21.webp differ diff --git a/delamain/frontend/img/tiles/5/22/22.webp b/delamain/frontend/img/tiles/5/22/22.webp new file mode 100755 index 0000000..26c0250 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/22.webp differ diff --git a/delamain/frontend/img/tiles/5/22/23.webp b/delamain/frontend/img/tiles/5/22/23.webp new file mode 100755 index 0000000..5061366 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/23.webp differ diff --git a/delamain/frontend/img/tiles/5/22/24.webp b/delamain/frontend/img/tiles/5/22/24.webp new file mode 100755 index 0000000..aa669c7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/24.webp differ diff --git a/delamain/frontend/img/tiles/5/22/25.webp b/delamain/frontend/img/tiles/5/22/25.webp new file mode 100755 index 0000000..54ffd45 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/25.webp differ diff --git a/delamain/frontend/img/tiles/5/22/26.webp b/delamain/frontend/img/tiles/5/22/26.webp new file mode 100755 index 0000000..8a34567 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/26.webp differ diff --git a/delamain/frontend/img/tiles/5/22/3.webp b/delamain/frontend/img/tiles/5/22/3.webp new file mode 100755 index 0000000..3dde751 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/3.webp differ diff --git a/delamain/frontend/img/tiles/5/22/4.webp b/delamain/frontend/img/tiles/5/22/4.webp new file mode 100755 index 0000000..831b71f Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/4.webp differ diff --git a/delamain/frontend/img/tiles/5/22/5.webp b/delamain/frontend/img/tiles/5/22/5.webp new file mode 100755 index 0000000..d0dbe74 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/5.webp differ diff --git a/delamain/frontend/img/tiles/5/22/6.webp b/delamain/frontend/img/tiles/5/22/6.webp new file mode 100755 index 0000000..ead7dec Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/6.webp differ diff --git a/delamain/frontend/img/tiles/5/22/7.webp b/delamain/frontend/img/tiles/5/22/7.webp new file mode 100755 index 0000000..c84f323 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/7.webp differ diff --git a/delamain/frontend/img/tiles/5/22/8.webp b/delamain/frontend/img/tiles/5/22/8.webp new file mode 100755 index 0000000..ffdf563 Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/8.webp differ diff --git a/delamain/frontend/img/tiles/5/22/9.webp b/delamain/frontend/img/tiles/5/22/9.webp new file mode 100755 index 0000000..eb60ece Binary files /dev/null and b/delamain/frontend/img/tiles/5/22/9.webp differ diff --git a/delamain/frontend/img/tiles/5/23/0.webp b/delamain/frontend/img/tiles/5/23/0.webp new file mode 100755 index 0000000..a94db8a Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/0.webp differ diff --git a/delamain/frontend/img/tiles/5/23/1.webp b/delamain/frontend/img/tiles/5/23/1.webp new file mode 100755 index 0000000..64b587c Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/1.webp differ diff --git a/delamain/frontend/img/tiles/5/23/10.webp b/delamain/frontend/img/tiles/5/23/10.webp new file mode 100755 index 0000000..9981710 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/10.webp differ diff --git a/delamain/frontend/img/tiles/5/23/11.webp b/delamain/frontend/img/tiles/5/23/11.webp new file mode 100755 index 0000000..5bc7269 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/11.webp differ diff --git a/delamain/frontend/img/tiles/5/23/12.webp b/delamain/frontend/img/tiles/5/23/12.webp new file mode 100755 index 0000000..894a85b Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/12.webp differ diff --git a/delamain/frontend/img/tiles/5/23/13.webp b/delamain/frontend/img/tiles/5/23/13.webp new file mode 100755 index 0000000..38b3cc0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/13.webp differ diff --git a/delamain/frontend/img/tiles/5/23/14.webp b/delamain/frontend/img/tiles/5/23/14.webp new file mode 100755 index 0000000..9d70380 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/14.webp differ diff --git a/delamain/frontend/img/tiles/5/23/15.webp b/delamain/frontend/img/tiles/5/23/15.webp new file mode 100755 index 0000000..1df7132 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/15.webp differ diff --git a/delamain/frontend/img/tiles/5/23/16.webp b/delamain/frontend/img/tiles/5/23/16.webp new file mode 100755 index 0000000..4ce51f6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/16.webp differ diff --git a/delamain/frontend/img/tiles/5/23/17.webp b/delamain/frontend/img/tiles/5/23/17.webp new file mode 100755 index 0000000..c6177b5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/17.webp differ diff --git a/delamain/frontend/img/tiles/5/23/18.webp b/delamain/frontend/img/tiles/5/23/18.webp new file mode 100755 index 0000000..4a63496 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/18.webp differ diff --git a/delamain/frontend/img/tiles/5/23/19.webp b/delamain/frontend/img/tiles/5/23/19.webp new file mode 100755 index 0000000..0f12039 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/19.webp differ diff --git a/delamain/frontend/img/tiles/5/23/2.webp b/delamain/frontend/img/tiles/5/23/2.webp new file mode 100755 index 0000000..5387428 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/2.webp differ diff --git a/delamain/frontend/img/tiles/5/23/20.webp b/delamain/frontend/img/tiles/5/23/20.webp new file mode 100755 index 0000000..8ed37d9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/20.webp differ diff --git a/delamain/frontend/img/tiles/5/23/21.webp b/delamain/frontend/img/tiles/5/23/21.webp new file mode 100755 index 0000000..a294f4c Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/21.webp differ diff --git a/delamain/frontend/img/tiles/5/23/22.webp b/delamain/frontend/img/tiles/5/23/22.webp new file mode 100755 index 0000000..5184b3f Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/22.webp differ diff --git a/delamain/frontend/img/tiles/5/23/23.webp b/delamain/frontend/img/tiles/5/23/23.webp new file mode 100755 index 0000000..a1b34b1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/23.webp differ diff --git a/delamain/frontend/img/tiles/5/23/24.webp b/delamain/frontend/img/tiles/5/23/24.webp new file mode 100755 index 0000000..8f37b0f Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/24.webp differ diff --git a/delamain/frontend/img/tiles/5/23/25.webp b/delamain/frontend/img/tiles/5/23/25.webp new file mode 100755 index 0000000..0f97649 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/25.webp differ diff --git a/delamain/frontend/img/tiles/5/23/26.webp b/delamain/frontend/img/tiles/5/23/26.webp new file mode 100755 index 0000000..6e74d51 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/26.webp differ diff --git a/delamain/frontend/img/tiles/5/23/3.webp b/delamain/frontend/img/tiles/5/23/3.webp new file mode 100755 index 0000000..00b7744 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/3.webp differ diff --git a/delamain/frontend/img/tiles/5/23/4.webp b/delamain/frontend/img/tiles/5/23/4.webp new file mode 100755 index 0000000..a65ca03 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/4.webp differ diff --git a/delamain/frontend/img/tiles/5/23/5.webp b/delamain/frontend/img/tiles/5/23/5.webp new file mode 100755 index 0000000..b01c9b2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/5.webp differ diff --git a/delamain/frontend/img/tiles/5/23/6.webp b/delamain/frontend/img/tiles/5/23/6.webp new file mode 100755 index 0000000..b7589fd Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/6.webp differ diff --git a/delamain/frontend/img/tiles/5/23/7.webp b/delamain/frontend/img/tiles/5/23/7.webp new file mode 100755 index 0000000..218a593 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/7.webp differ diff --git a/delamain/frontend/img/tiles/5/23/8.webp b/delamain/frontend/img/tiles/5/23/8.webp new file mode 100755 index 0000000..7ce9de5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/8.webp differ diff --git a/delamain/frontend/img/tiles/5/23/9.webp b/delamain/frontend/img/tiles/5/23/9.webp new file mode 100755 index 0000000..7faeb20 Binary files /dev/null and b/delamain/frontend/img/tiles/5/23/9.webp differ diff --git a/delamain/frontend/img/tiles/5/24/0.webp b/delamain/frontend/img/tiles/5/24/0.webp new file mode 100755 index 0000000..9ca0754 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/0.webp differ diff --git a/delamain/frontend/img/tiles/5/24/1.webp b/delamain/frontend/img/tiles/5/24/1.webp new file mode 100755 index 0000000..8a0ab94 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/1.webp differ diff --git a/delamain/frontend/img/tiles/5/24/10.webp b/delamain/frontend/img/tiles/5/24/10.webp new file mode 100755 index 0000000..ccd606a Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/10.webp differ diff --git a/delamain/frontend/img/tiles/5/24/11.webp b/delamain/frontend/img/tiles/5/24/11.webp new file mode 100755 index 0000000..e0c54ec Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/11.webp differ diff --git a/delamain/frontend/img/tiles/5/24/12.webp b/delamain/frontend/img/tiles/5/24/12.webp new file mode 100755 index 0000000..2b110a8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/12.webp differ diff --git a/delamain/frontend/img/tiles/5/24/13.webp b/delamain/frontend/img/tiles/5/24/13.webp new file mode 100755 index 0000000..5e94be8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/13.webp differ diff --git a/delamain/frontend/img/tiles/5/24/14.webp b/delamain/frontend/img/tiles/5/24/14.webp new file mode 100755 index 0000000..6229bf6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/14.webp differ diff --git a/delamain/frontend/img/tiles/5/24/15.webp b/delamain/frontend/img/tiles/5/24/15.webp new file mode 100755 index 0000000..cebaddb Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/15.webp differ diff --git a/delamain/frontend/img/tiles/5/24/16.webp b/delamain/frontend/img/tiles/5/24/16.webp new file mode 100755 index 0000000..4eef85b Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/16.webp differ diff --git a/delamain/frontend/img/tiles/5/24/17.webp b/delamain/frontend/img/tiles/5/24/17.webp new file mode 100755 index 0000000..3ff7463 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/17.webp differ diff --git a/delamain/frontend/img/tiles/5/24/18.webp b/delamain/frontend/img/tiles/5/24/18.webp new file mode 100755 index 0000000..1ad8a45 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/18.webp differ diff --git a/delamain/frontend/img/tiles/5/24/19.webp b/delamain/frontend/img/tiles/5/24/19.webp new file mode 100755 index 0000000..c770b4e Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/19.webp differ diff --git a/delamain/frontend/img/tiles/5/24/2.webp b/delamain/frontend/img/tiles/5/24/2.webp new file mode 100755 index 0000000..bf01d33 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/2.webp differ diff --git a/delamain/frontend/img/tiles/5/24/20.webp b/delamain/frontend/img/tiles/5/24/20.webp new file mode 100755 index 0000000..bc3acc3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/20.webp differ diff --git a/delamain/frontend/img/tiles/5/24/21.webp b/delamain/frontend/img/tiles/5/24/21.webp new file mode 100755 index 0000000..6654442 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/21.webp differ diff --git a/delamain/frontend/img/tiles/5/24/22.webp b/delamain/frontend/img/tiles/5/24/22.webp new file mode 100755 index 0000000..a2f19d1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/22.webp differ diff --git a/delamain/frontend/img/tiles/5/24/23.webp b/delamain/frontend/img/tiles/5/24/23.webp new file mode 100755 index 0000000..c66691f Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/23.webp differ diff --git a/delamain/frontend/img/tiles/5/24/24.webp b/delamain/frontend/img/tiles/5/24/24.webp new file mode 100755 index 0000000..750c9df Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/24.webp differ diff --git a/delamain/frontend/img/tiles/5/24/25.webp b/delamain/frontend/img/tiles/5/24/25.webp new file mode 100755 index 0000000..efb6c04 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/25.webp differ diff --git a/delamain/frontend/img/tiles/5/24/26.webp b/delamain/frontend/img/tiles/5/24/26.webp new file mode 100755 index 0000000..e511379 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/26.webp differ diff --git a/delamain/frontend/img/tiles/5/24/3.webp b/delamain/frontend/img/tiles/5/24/3.webp new file mode 100755 index 0000000..5e96354 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/3.webp differ diff --git a/delamain/frontend/img/tiles/5/24/4.webp b/delamain/frontend/img/tiles/5/24/4.webp new file mode 100755 index 0000000..ac8749b Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/4.webp differ diff --git a/delamain/frontend/img/tiles/5/24/5.webp b/delamain/frontend/img/tiles/5/24/5.webp new file mode 100755 index 0000000..d4e43f7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/5.webp differ diff --git a/delamain/frontend/img/tiles/5/24/6.webp b/delamain/frontend/img/tiles/5/24/6.webp new file mode 100755 index 0000000..934afff Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/6.webp differ diff --git a/delamain/frontend/img/tiles/5/24/7.webp b/delamain/frontend/img/tiles/5/24/7.webp new file mode 100755 index 0000000..229a8a3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/7.webp differ diff --git a/delamain/frontend/img/tiles/5/24/8.webp b/delamain/frontend/img/tiles/5/24/8.webp new file mode 100755 index 0000000..7dc2a4e Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/8.webp differ diff --git a/delamain/frontend/img/tiles/5/24/9.webp b/delamain/frontend/img/tiles/5/24/9.webp new file mode 100755 index 0000000..bcfd56b Binary files /dev/null and b/delamain/frontend/img/tiles/5/24/9.webp differ diff --git a/delamain/frontend/img/tiles/5/25/0.webp b/delamain/frontend/img/tiles/5/25/0.webp new file mode 100755 index 0000000..6a4e44e Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/0.webp differ diff --git a/delamain/frontend/img/tiles/5/25/1.webp b/delamain/frontend/img/tiles/5/25/1.webp new file mode 100755 index 0000000..2783d95 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/1.webp differ diff --git a/delamain/frontend/img/tiles/5/25/10.webp b/delamain/frontend/img/tiles/5/25/10.webp new file mode 100755 index 0000000..8f09f01 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/10.webp differ diff --git a/delamain/frontend/img/tiles/5/25/11.webp b/delamain/frontend/img/tiles/5/25/11.webp new file mode 100755 index 0000000..e2299b5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/11.webp differ diff --git a/delamain/frontend/img/tiles/5/25/12.webp b/delamain/frontend/img/tiles/5/25/12.webp new file mode 100755 index 0000000..b61098d Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/12.webp differ diff --git a/delamain/frontend/img/tiles/5/25/13.webp b/delamain/frontend/img/tiles/5/25/13.webp new file mode 100755 index 0000000..d21e0f5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/13.webp differ diff --git a/delamain/frontend/img/tiles/5/25/14.webp b/delamain/frontend/img/tiles/5/25/14.webp new file mode 100755 index 0000000..665b5a5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/14.webp differ diff --git a/delamain/frontend/img/tiles/5/25/15.webp b/delamain/frontend/img/tiles/5/25/15.webp new file mode 100755 index 0000000..2330b9c Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/15.webp differ diff --git a/delamain/frontend/img/tiles/5/25/16.webp b/delamain/frontend/img/tiles/5/25/16.webp new file mode 100755 index 0000000..0cc0795 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/16.webp differ diff --git a/delamain/frontend/img/tiles/5/25/17.webp b/delamain/frontend/img/tiles/5/25/17.webp new file mode 100755 index 0000000..f893a58 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/17.webp differ diff --git a/delamain/frontend/img/tiles/5/25/18.webp b/delamain/frontend/img/tiles/5/25/18.webp new file mode 100755 index 0000000..5d8c15c Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/18.webp differ diff --git a/delamain/frontend/img/tiles/5/25/19.webp b/delamain/frontend/img/tiles/5/25/19.webp new file mode 100755 index 0000000..5fc3760 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/19.webp differ diff --git a/delamain/frontend/img/tiles/5/25/2.webp b/delamain/frontend/img/tiles/5/25/2.webp new file mode 100755 index 0000000..04643c4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/2.webp differ diff --git a/delamain/frontend/img/tiles/5/25/20.webp b/delamain/frontend/img/tiles/5/25/20.webp new file mode 100755 index 0000000..ff6a54b Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/20.webp differ diff --git a/delamain/frontend/img/tiles/5/25/21.webp b/delamain/frontend/img/tiles/5/25/21.webp new file mode 100755 index 0000000..b40d60f Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/21.webp differ diff --git a/delamain/frontend/img/tiles/5/25/22.webp b/delamain/frontend/img/tiles/5/25/22.webp new file mode 100755 index 0000000..c5cba37 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/22.webp differ diff --git a/delamain/frontend/img/tiles/5/25/23.webp b/delamain/frontend/img/tiles/5/25/23.webp new file mode 100755 index 0000000..140607c Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/23.webp differ diff --git a/delamain/frontend/img/tiles/5/25/24.webp b/delamain/frontend/img/tiles/5/25/24.webp new file mode 100755 index 0000000..2295c48 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/24.webp differ diff --git a/delamain/frontend/img/tiles/5/25/25.webp b/delamain/frontend/img/tiles/5/25/25.webp new file mode 100755 index 0000000..4d40864 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/25.webp differ diff --git a/delamain/frontend/img/tiles/5/25/26.webp b/delamain/frontend/img/tiles/5/25/26.webp new file mode 100755 index 0000000..9d2bee4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/26.webp differ diff --git a/delamain/frontend/img/tiles/5/25/3.webp b/delamain/frontend/img/tiles/5/25/3.webp new file mode 100755 index 0000000..79b3b0d Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/3.webp differ diff --git a/delamain/frontend/img/tiles/5/25/4.webp b/delamain/frontend/img/tiles/5/25/4.webp new file mode 100755 index 0000000..ba6115e Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/4.webp differ diff --git a/delamain/frontend/img/tiles/5/25/5.webp b/delamain/frontend/img/tiles/5/25/5.webp new file mode 100755 index 0000000..a54ce7f Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/5.webp differ diff --git a/delamain/frontend/img/tiles/5/25/6.webp b/delamain/frontend/img/tiles/5/25/6.webp new file mode 100755 index 0000000..dd1476e Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/6.webp differ diff --git a/delamain/frontend/img/tiles/5/25/7.webp b/delamain/frontend/img/tiles/5/25/7.webp new file mode 100755 index 0000000..aef8c18 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/7.webp differ diff --git a/delamain/frontend/img/tiles/5/25/8.webp b/delamain/frontend/img/tiles/5/25/8.webp new file mode 100755 index 0000000..ad44c37 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/8.webp differ diff --git a/delamain/frontend/img/tiles/5/25/9.webp b/delamain/frontend/img/tiles/5/25/9.webp new file mode 100755 index 0000000..5c56735 Binary files /dev/null and b/delamain/frontend/img/tiles/5/25/9.webp differ diff --git a/delamain/frontend/img/tiles/5/26/0.webp b/delamain/frontend/img/tiles/5/26/0.webp new file mode 100755 index 0000000..533ec16 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/0.webp differ diff --git a/delamain/frontend/img/tiles/5/26/1.webp b/delamain/frontend/img/tiles/5/26/1.webp new file mode 100755 index 0000000..e6688c4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/1.webp differ diff --git a/delamain/frontend/img/tiles/5/26/10.webp b/delamain/frontend/img/tiles/5/26/10.webp new file mode 100755 index 0000000..d5a98d3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/10.webp differ diff --git a/delamain/frontend/img/tiles/5/26/11.webp b/delamain/frontend/img/tiles/5/26/11.webp new file mode 100755 index 0000000..5ac7a5f Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/11.webp differ diff --git a/delamain/frontend/img/tiles/5/26/12.webp b/delamain/frontend/img/tiles/5/26/12.webp new file mode 100755 index 0000000..faadb1e Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/12.webp differ diff --git a/delamain/frontend/img/tiles/5/26/13.webp b/delamain/frontend/img/tiles/5/26/13.webp new file mode 100755 index 0000000..6bdbfbb Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/13.webp differ diff --git a/delamain/frontend/img/tiles/5/26/14.webp b/delamain/frontend/img/tiles/5/26/14.webp new file mode 100755 index 0000000..d0dc3bf Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/14.webp differ diff --git a/delamain/frontend/img/tiles/5/26/15.webp b/delamain/frontend/img/tiles/5/26/15.webp new file mode 100755 index 0000000..9364ec4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/15.webp differ diff --git a/delamain/frontend/img/tiles/5/26/16.webp b/delamain/frontend/img/tiles/5/26/16.webp new file mode 100755 index 0000000..d6661c2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/16.webp differ diff --git a/delamain/frontend/img/tiles/5/26/17.webp b/delamain/frontend/img/tiles/5/26/17.webp new file mode 100755 index 0000000..4838d77 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/17.webp differ diff --git a/delamain/frontend/img/tiles/5/26/18.webp b/delamain/frontend/img/tiles/5/26/18.webp new file mode 100755 index 0000000..acb7511 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/18.webp differ diff --git a/delamain/frontend/img/tiles/5/26/19.webp b/delamain/frontend/img/tiles/5/26/19.webp new file mode 100755 index 0000000..7966994 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/19.webp differ diff --git a/delamain/frontend/img/tiles/5/26/2.webp b/delamain/frontend/img/tiles/5/26/2.webp new file mode 100755 index 0000000..d563e42 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/2.webp differ diff --git a/delamain/frontend/img/tiles/5/26/20.webp b/delamain/frontend/img/tiles/5/26/20.webp new file mode 100755 index 0000000..d308970 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/20.webp differ diff --git a/delamain/frontend/img/tiles/5/26/21.webp b/delamain/frontend/img/tiles/5/26/21.webp new file mode 100755 index 0000000..a423b92 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/21.webp differ diff --git a/delamain/frontend/img/tiles/5/26/22.webp b/delamain/frontend/img/tiles/5/26/22.webp new file mode 100755 index 0000000..87e1a5e Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/22.webp differ diff --git a/delamain/frontend/img/tiles/5/26/23.webp b/delamain/frontend/img/tiles/5/26/23.webp new file mode 100755 index 0000000..55707e2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/23.webp differ diff --git a/delamain/frontend/img/tiles/5/26/24.webp b/delamain/frontend/img/tiles/5/26/24.webp new file mode 100755 index 0000000..0f88c6c Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/24.webp differ diff --git a/delamain/frontend/img/tiles/5/26/25.webp b/delamain/frontend/img/tiles/5/26/25.webp new file mode 100755 index 0000000..adf5de5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/25.webp differ diff --git a/delamain/frontend/img/tiles/5/26/26.webp b/delamain/frontend/img/tiles/5/26/26.webp new file mode 100755 index 0000000..6896aab Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/26.webp differ diff --git a/delamain/frontend/img/tiles/5/26/3.webp b/delamain/frontend/img/tiles/5/26/3.webp new file mode 100755 index 0000000..d36b896 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/3.webp differ diff --git a/delamain/frontend/img/tiles/5/26/4.webp b/delamain/frontend/img/tiles/5/26/4.webp new file mode 100755 index 0000000..b097b9c Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/4.webp differ diff --git a/delamain/frontend/img/tiles/5/26/5.webp b/delamain/frontend/img/tiles/5/26/5.webp new file mode 100755 index 0000000..458779c Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/5.webp differ diff --git a/delamain/frontend/img/tiles/5/26/6.webp b/delamain/frontend/img/tiles/5/26/6.webp new file mode 100755 index 0000000..b83898c Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/6.webp differ diff --git a/delamain/frontend/img/tiles/5/26/7.webp b/delamain/frontend/img/tiles/5/26/7.webp new file mode 100755 index 0000000..7d83a74 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/7.webp differ diff --git a/delamain/frontend/img/tiles/5/26/8.webp b/delamain/frontend/img/tiles/5/26/8.webp new file mode 100755 index 0000000..3ddc6d1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/8.webp differ diff --git a/delamain/frontend/img/tiles/5/26/9.webp b/delamain/frontend/img/tiles/5/26/9.webp new file mode 100755 index 0000000..19251e6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/26/9.webp differ diff --git a/delamain/frontend/img/tiles/5/27/0.webp b/delamain/frontend/img/tiles/5/27/0.webp new file mode 100755 index 0000000..e5afa46 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/0.webp differ diff --git a/delamain/frontend/img/tiles/5/27/1.webp b/delamain/frontend/img/tiles/5/27/1.webp new file mode 100755 index 0000000..5954d6c Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/1.webp differ diff --git a/delamain/frontend/img/tiles/5/27/10.webp b/delamain/frontend/img/tiles/5/27/10.webp new file mode 100755 index 0000000..9dc58b3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/10.webp differ diff --git a/delamain/frontend/img/tiles/5/27/11.webp b/delamain/frontend/img/tiles/5/27/11.webp new file mode 100755 index 0000000..a49f6a8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/11.webp differ diff --git a/delamain/frontend/img/tiles/5/27/12.webp b/delamain/frontend/img/tiles/5/27/12.webp new file mode 100755 index 0000000..baf10fd Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/12.webp differ diff --git a/delamain/frontend/img/tiles/5/27/13.webp b/delamain/frontend/img/tiles/5/27/13.webp new file mode 100755 index 0000000..62a7a2f Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/13.webp differ diff --git a/delamain/frontend/img/tiles/5/27/14.webp b/delamain/frontend/img/tiles/5/27/14.webp new file mode 100755 index 0000000..896bb43 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/14.webp differ diff --git a/delamain/frontend/img/tiles/5/27/15.webp b/delamain/frontend/img/tiles/5/27/15.webp new file mode 100755 index 0000000..2354354 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/15.webp differ diff --git a/delamain/frontend/img/tiles/5/27/16.webp b/delamain/frontend/img/tiles/5/27/16.webp new file mode 100755 index 0000000..a92c687 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/16.webp differ diff --git a/delamain/frontend/img/tiles/5/27/17.webp b/delamain/frontend/img/tiles/5/27/17.webp new file mode 100755 index 0000000..46d7323 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/17.webp differ diff --git a/delamain/frontend/img/tiles/5/27/18.webp b/delamain/frontend/img/tiles/5/27/18.webp new file mode 100755 index 0000000..92b7c09 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/18.webp differ diff --git a/delamain/frontend/img/tiles/5/27/19.webp b/delamain/frontend/img/tiles/5/27/19.webp new file mode 100755 index 0000000..ad63e90 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/19.webp differ diff --git a/delamain/frontend/img/tiles/5/27/2.webp b/delamain/frontend/img/tiles/5/27/2.webp new file mode 100755 index 0000000..1da99f6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/2.webp differ diff --git a/delamain/frontend/img/tiles/5/27/20.webp b/delamain/frontend/img/tiles/5/27/20.webp new file mode 100755 index 0000000..9ec094f Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/20.webp differ diff --git a/delamain/frontend/img/tiles/5/27/21.webp b/delamain/frontend/img/tiles/5/27/21.webp new file mode 100755 index 0000000..548ad4c Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/21.webp differ diff --git a/delamain/frontend/img/tiles/5/27/22.webp b/delamain/frontend/img/tiles/5/27/22.webp new file mode 100755 index 0000000..57b3c98 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/22.webp differ diff --git a/delamain/frontend/img/tiles/5/27/23.webp b/delamain/frontend/img/tiles/5/27/23.webp new file mode 100755 index 0000000..0e0937c Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/23.webp differ diff --git a/delamain/frontend/img/tiles/5/27/24.webp b/delamain/frontend/img/tiles/5/27/24.webp new file mode 100755 index 0000000..ec0dd43 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/24.webp differ diff --git a/delamain/frontend/img/tiles/5/27/25.webp b/delamain/frontend/img/tiles/5/27/25.webp new file mode 100755 index 0000000..266a3a7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/25.webp differ diff --git a/delamain/frontend/img/tiles/5/27/26.webp b/delamain/frontend/img/tiles/5/27/26.webp new file mode 100755 index 0000000..efee27a Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/26.webp differ diff --git a/delamain/frontend/img/tiles/5/27/3.webp b/delamain/frontend/img/tiles/5/27/3.webp new file mode 100755 index 0000000..838ad35 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/3.webp differ diff --git a/delamain/frontend/img/tiles/5/27/4.webp b/delamain/frontend/img/tiles/5/27/4.webp new file mode 100755 index 0000000..d150be3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/4.webp differ diff --git a/delamain/frontend/img/tiles/5/27/5.webp b/delamain/frontend/img/tiles/5/27/5.webp new file mode 100755 index 0000000..6c12bda Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/5.webp differ diff --git a/delamain/frontend/img/tiles/5/27/6.webp b/delamain/frontend/img/tiles/5/27/6.webp new file mode 100755 index 0000000..da6b817 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/6.webp differ diff --git a/delamain/frontend/img/tiles/5/27/7.webp b/delamain/frontend/img/tiles/5/27/7.webp new file mode 100755 index 0000000..61de315 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/7.webp differ diff --git a/delamain/frontend/img/tiles/5/27/8.webp b/delamain/frontend/img/tiles/5/27/8.webp new file mode 100755 index 0000000..994b6bc Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/8.webp differ diff --git a/delamain/frontend/img/tiles/5/27/9.webp b/delamain/frontend/img/tiles/5/27/9.webp new file mode 100755 index 0000000..c7a3632 Binary files /dev/null and b/delamain/frontend/img/tiles/5/27/9.webp differ diff --git a/delamain/frontend/img/tiles/5/3/0.webp b/delamain/frontend/img/tiles/5/3/0.webp new file mode 100755 index 0000000..0de5ce3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/0.webp differ diff --git a/delamain/frontend/img/tiles/5/3/1.webp b/delamain/frontend/img/tiles/5/3/1.webp new file mode 100755 index 0000000..700d2b3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/1.webp differ diff --git a/delamain/frontend/img/tiles/5/3/10.webp b/delamain/frontend/img/tiles/5/3/10.webp new file mode 100755 index 0000000..faa6ca4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/10.webp differ diff --git a/delamain/frontend/img/tiles/5/3/11.webp b/delamain/frontend/img/tiles/5/3/11.webp new file mode 100755 index 0000000..31c2f8c Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/11.webp differ diff --git a/delamain/frontend/img/tiles/5/3/12.webp b/delamain/frontend/img/tiles/5/3/12.webp new file mode 100755 index 0000000..80b4031 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/12.webp differ diff --git a/delamain/frontend/img/tiles/5/3/13.webp b/delamain/frontend/img/tiles/5/3/13.webp new file mode 100755 index 0000000..19d9bff Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/13.webp differ diff --git a/delamain/frontend/img/tiles/5/3/14.webp b/delamain/frontend/img/tiles/5/3/14.webp new file mode 100755 index 0000000..da7b013 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/14.webp differ diff --git a/delamain/frontend/img/tiles/5/3/15.webp b/delamain/frontend/img/tiles/5/3/15.webp new file mode 100755 index 0000000..d9009cd Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/15.webp differ diff --git a/delamain/frontend/img/tiles/5/3/16.webp b/delamain/frontend/img/tiles/5/3/16.webp new file mode 100755 index 0000000..5d3c9e7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/16.webp differ diff --git a/delamain/frontend/img/tiles/5/3/17.webp b/delamain/frontend/img/tiles/5/3/17.webp new file mode 100755 index 0000000..7388c3b Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/17.webp differ diff --git a/delamain/frontend/img/tiles/5/3/18.webp b/delamain/frontend/img/tiles/5/3/18.webp new file mode 100755 index 0000000..c0728fc Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/18.webp differ diff --git a/delamain/frontend/img/tiles/5/3/19.webp b/delamain/frontend/img/tiles/5/3/19.webp new file mode 100755 index 0000000..6d0d7a6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/19.webp differ diff --git a/delamain/frontend/img/tiles/5/3/2.webp b/delamain/frontend/img/tiles/5/3/2.webp new file mode 100755 index 0000000..e52bc9c Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/2.webp differ diff --git a/delamain/frontend/img/tiles/5/3/20.webp b/delamain/frontend/img/tiles/5/3/20.webp new file mode 100755 index 0000000..37f27a1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/20.webp differ diff --git a/delamain/frontend/img/tiles/5/3/21.webp b/delamain/frontend/img/tiles/5/3/21.webp new file mode 100755 index 0000000..4340fe4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/21.webp differ diff --git a/delamain/frontend/img/tiles/5/3/22.webp b/delamain/frontend/img/tiles/5/3/22.webp new file mode 100755 index 0000000..df8b485 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/22.webp differ diff --git a/delamain/frontend/img/tiles/5/3/23.webp b/delamain/frontend/img/tiles/5/3/23.webp new file mode 100755 index 0000000..b10cb14 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/23.webp differ diff --git a/delamain/frontend/img/tiles/5/3/24.webp b/delamain/frontend/img/tiles/5/3/24.webp new file mode 100755 index 0000000..74e4717 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/24.webp differ diff --git a/delamain/frontend/img/tiles/5/3/25.webp b/delamain/frontend/img/tiles/5/3/25.webp new file mode 100755 index 0000000..074127e Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/25.webp differ diff --git a/delamain/frontend/img/tiles/5/3/26.webp b/delamain/frontend/img/tiles/5/3/26.webp new file mode 100755 index 0000000..0db0fcc Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/26.webp differ diff --git a/delamain/frontend/img/tiles/5/3/3.webp b/delamain/frontend/img/tiles/5/3/3.webp new file mode 100755 index 0000000..db0b309 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/3.webp differ diff --git a/delamain/frontend/img/tiles/5/3/4.webp b/delamain/frontend/img/tiles/5/3/4.webp new file mode 100755 index 0000000..42b5112 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/4.webp differ diff --git a/delamain/frontend/img/tiles/5/3/5.webp b/delamain/frontend/img/tiles/5/3/5.webp new file mode 100755 index 0000000..84f908c Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/5.webp differ diff --git a/delamain/frontend/img/tiles/5/3/6.webp b/delamain/frontend/img/tiles/5/3/6.webp new file mode 100755 index 0000000..9db1225 Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/6.webp differ diff --git a/delamain/frontend/img/tiles/5/3/7.webp b/delamain/frontend/img/tiles/5/3/7.webp new file mode 100755 index 0000000..7e257ad Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/7.webp differ diff --git a/delamain/frontend/img/tiles/5/3/8.webp b/delamain/frontend/img/tiles/5/3/8.webp new file mode 100755 index 0000000..3181eda Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/8.webp differ diff --git a/delamain/frontend/img/tiles/5/3/9.webp b/delamain/frontend/img/tiles/5/3/9.webp new file mode 100755 index 0000000..626030a Binary files /dev/null and b/delamain/frontend/img/tiles/5/3/9.webp differ diff --git a/delamain/frontend/img/tiles/5/4/0.webp b/delamain/frontend/img/tiles/5/4/0.webp new file mode 100755 index 0000000..46381c4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/0.webp differ diff --git a/delamain/frontend/img/tiles/5/4/1.webp b/delamain/frontend/img/tiles/5/4/1.webp new file mode 100755 index 0000000..c8c3ce4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/1.webp differ diff --git a/delamain/frontend/img/tiles/5/4/10.webp b/delamain/frontend/img/tiles/5/4/10.webp new file mode 100755 index 0000000..a8a3464 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/10.webp differ diff --git a/delamain/frontend/img/tiles/5/4/11.webp b/delamain/frontend/img/tiles/5/4/11.webp new file mode 100755 index 0000000..422bfe3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/11.webp differ diff --git a/delamain/frontend/img/tiles/5/4/12.webp b/delamain/frontend/img/tiles/5/4/12.webp new file mode 100755 index 0000000..64af7be Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/12.webp differ diff --git a/delamain/frontend/img/tiles/5/4/13.webp b/delamain/frontend/img/tiles/5/4/13.webp new file mode 100755 index 0000000..a5953d0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/13.webp differ diff --git a/delamain/frontend/img/tiles/5/4/14.webp b/delamain/frontend/img/tiles/5/4/14.webp new file mode 100755 index 0000000..40fc8f8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/14.webp differ diff --git a/delamain/frontend/img/tiles/5/4/15.webp b/delamain/frontend/img/tiles/5/4/15.webp new file mode 100755 index 0000000..b794ca9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/15.webp differ diff --git a/delamain/frontend/img/tiles/5/4/16.webp b/delamain/frontend/img/tiles/5/4/16.webp new file mode 100755 index 0000000..3899695 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/16.webp differ diff --git a/delamain/frontend/img/tiles/5/4/17.webp b/delamain/frontend/img/tiles/5/4/17.webp new file mode 100755 index 0000000..d0c2f5e Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/17.webp differ diff --git a/delamain/frontend/img/tiles/5/4/18.webp b/delamain/frontend/img/tiles/5/4/18.webp new file mode 100755 index 0000000..1b5daaf Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/18.webp differ diff --git a/delamain/frontend/img/tiles/5/4/19.webp b/delamain/frontend/img/tiles/5/4/19.webp new file mode 100755 index 0000000..2fa7aa0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/19.webp differ diff --git a/delamain/frontend/img/tiles/5/4/2.webp b/delamain/frontend/img/tiles/5/4/2.webp new file mode 100755 index 0000000..9cc16e0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/2.webp differ diff --git a/delamain/frontend/img/tiles/5/4/20.webp b/delamain/frontend/img/tiles/5/4/20.webp new file mode 100755 index 0000000..85426d4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/20.webp differ diff --git a/delamain/frontend/img/tiles/5/4/21.webp b/delamain/frontend/img/tiles/5/4/21.webp new file mode 100755 index 0000000..fda7f33 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/21.webp differ diff --git a/delamain/frontend/img/tiles/5/4/22.webp b/delamain/frontend/img/tiles/5/4/22.webp new file mode 100755 index 0000000..3c250b9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/22.webp differ diff --git a/delamain/frontend/img/tiles/5/4/23.webp b/delamain/frontend/img/tiles/5/4/23.webp new file mode 100755 index 0000000..d82e4c3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/23.webp differ diff --git a/delamain/frontend/img/tiles/5/4/24.webp b/delamain/frontend/img/tiles/5/4/24.webp new file mode 100755 index 0000000..36b6ba4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/24.webp differ diff --git a/delamain/frontend/img/tiles/5/4/25.webp b/delamain/frontend/img/tiles/5/4/25.webp new file mode 100755 index 0000000..63a2d00 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/25.webp differ diff --git a/delamain/frontend/img/tiles/5/4/26.webp b/delamain/frontend/img/tiles/5/4/26.webp new file mode 100755 index 0000000..0e857b0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/26.webp differ diff --git a/delamain/frontend/img/tiles/5/4/3.webp b/delamain/frontend/img/tiles/5/4/3.webp new file mode 100755 index 0000000..71ab047 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/3.webp differ diff --git a/delamain/frontend/img/tiles/5/4/4.webp b/delamain/frontend/img/tiles/5/4/4.webp new file mode 100755 index 0000000..2d4c396 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/4.webp differ diff --git a/delamain/frontend/img/tiles/5/4/5.webp b/delamain/frontend/img/tiles/5/4/5.webp new file mode 100755 index 0000000..efc09a0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/5.webp differ diff --git a/delamain/frontend/img/tiles/5/4/6.webp b/delamain/frontend/img/tiles/5/4/6.webp new file mode 100755 index 0000000..eeca0cc Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/6.webp differ diff --git a/delamain/frontend/img/tiles/5/4/7.webp b/delamain/frontend/img/tiles/5/4/7.webp new file mode 100755 index 0000000..62dcbb8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/7.webp differ diff --git a/delamain/frontend/img/tiles/5/4/8.webp b/delamain/frontend/img/tiles/5/4/8.webp new file mode 100755 index 0000000..1d9a4a1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/8.webp differ diff --git a/delamain/frontend/img/tiles/5/4/9.webp b/delamain/frontend/img/tiles/5/4/9.webp new file mode 100755 index 0000000..3947714 Binary files /dev/null and b/delamain/frontend/img/tiles/5/4/9.webp differ diff --git a/delamain/frontend/img/tiles/5/5/0.webp b/delamain/frontend/img/tiles/5/5/0.webp new file mode 100755 index 0000000..1c9db50 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/0.webp differ diff --git a/delamain/frontend/img/tiles/5/5/1.webp b/delamain/frontend/img/tiles/5/5/1.webp new file mode 100755 index 0000000..0c3b6ba Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/1.webp differ diff --git a/delamain/frontend/img/tiles/5/5/10.webp b/delamain/frontend/img/tiles/5/5/10.webp new file mode 100755 index 0000000..ab8ad97 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/10.webp differ diff --git a/delamain/frontend/img/tiles/5/5/11.webp b/delamain/frontend/img/tiles/5/5/11.webp new file mode 100755 index 0000000..0486244 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/11.webp differ diff --git a/delamain/frontend/img/tiles/5/5/12.webp b/delamain/frontend/img/tiles/5/5/12.webp new file mode 100755 index 0000000..3973382 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/12.webp differ diff --git a/delamain/frontend/img/tiles/5/5/13.webp b/delamain/frontend/img/tiles/5/5/13.webp new file mode 100755 index 0000000..787072a Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/13.webp differ diff --git a/delamain/frontend/img/tiles/5/5/14.webp b/delamain/frontend/img/tiles/5/5/14.webp new file mode 100755 index 0000000..83f5d08 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/14.webp differ diff --git a/delamain/frontend/img/tiles/5/5/15.webp b/delamain/frontend/img/tiles/5/5/15.webp new file mode 100755 index 0000000..0a57b76 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/15.webp differ diff --git a/delamain/frontend/img/tiles/5/5/16.webp b/delamain/frontend/img/tiles/5/5/16.webp new file mode 100755 index 0000000..4ce09a0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/16.webp differ diff --git a/delamain/frontend/img/tiles/5/5/17.webp b/delamain/frontend/img/tiles/5/5/17.webp new file mode 100755 index 0000000..4e9535b Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/17.webp differ diff --git a/delamain/frontend/img/tiles/5/5/18.webp b/delamain/frontend/img/tiles/5/5/18.webp new file mode 100755 index 0000000..cecbe1d Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/18.webp differ diff --git a/delamain/frontend/img/tiles/5/5/19.webp b/delamain/frontend/img/tiles/5/5/19.webp new file mode 100755 index 0000000..465a269 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/19.webp differ diff --git a/delamain/frontend/img/tiles/5/5/2.webp b/delamain/frontend/img/tiles/5/5/2.webp new file mode 100755 index 0000000..31e96e1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/2.webp differ diff --git a/delamain/frontend/img/tiles/5/5/20.webp b/delamain/frontend/img/tiles/5/5/20.webp new file mode 100755 index 0000000..4d1b59f Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/20.webp differ diff --git a/delamain/frontend/img/tiles/5/5/21.webp b/delamain/frontend/img/tiles/5/5/21.webp new file mode 100755 index 0000000..8998d14 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/21.webp differ diff --git a/delamain/frontend/img/tiles/5/5/22.webp b/delamain/frontend/img/tiles/5/5/22.webp new file mode 100755 index 0000000..c272889 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/22.webp differ diff --git a/delamain/frontend/img/tiles/5/5/23.webp b/delamain/frontend/img/tiles/5/5/23.webp new file mode 100755 index 0000000..9108af4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/23.webp differ diff --git a/delamain/frontend/img/tiles/5/5/24.webp b/delamain/frontend/img/tiles/5/5/24.webp new file mode 100755 index 0000000..4f541bb Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/24.webp differ diff --git a/delamain/frontend/img/tiles/5/5/25.webp b/delamain/frontend/img/tiles/5/5/25.webp new file mode 100755 index 0000000..bea922a Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/25.webp differ diff --git a/delamain/frontend/img/tiles/5/5/26.webp b/delamain/frontend/img/tiles/5/5/26.webp new file mode 100755 index 0000000..40f0ccc Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/26.webp differ diff --git a/delamain/frontend/img/tiles/5/5/3.webp b/delamain/frontend/img/tiles/5/5/3.webp new file mode 100755 index 0000000..3363f31 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/3.webp differ diff --git a/delamain/frontend/img/tiles/5/5/4.webp b/delamain/frontend/img/tiles/5/5/4.webp new file mode 100755 index 0000000..bea83cb Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/4.webp differ diff --git a/delamain/frontend/img/tiles/5/5/5.webp b/delamain/frontend/img/tiles/5/5/5.webp new file mode 100755 index 0000000..d92131b Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/5.webp differ diff --git a/delamain/frontend/img/tiles/5/5/6.webp b/delamain/frontend/img/tiles/5/5/6.webp new file mode 100755 index 0000000..a2e25a2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/6.webp differ diff --git a/delamain/frontend/img/tiles/5/5/7.webp b/delamain/frontend/img/tiles/5/5/7.webp new file mode 100755 index 0000000..858e2dc Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/7.webp differ diff --git a/delamain/frontend/img/tiles/5/5/8.webp b/delamain/frontend/img/tiles/5/5/8.webp new file mode 100755 index 0000000..4cbc004 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/8.webp differ diff --git a/delamain/frontend/img/tiles/5/5/9.webp b/delamain/frontend/img/tiles/5/5/9.webp new file mode 100755 index 0000000..1afef36 Binary files /dev/null and b/delamain/frontend/img/tiles/5/5/9.webp differ diff --git a/delamain/frontend/img/tiles/5/6/0.webp b/delamain/frontend/img/tiles/5/6/0.webp new file mode 100755 index 0000000..c2b0c4e Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/0.webp differ diff --git a/delamain/frontend/img/tiles/5/6/1.webp b/delamain/frontend/img/tiles/5/6/1.webp new file mode 100755 index 0000000..fa33933 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/1.webp differ diff --git a/delamain/frontend/img/tiles/5/6/10.webp b/delamain/frontend/img/tiles/5/6/10.webp new file mode 100755 index 0000000..fa236fc Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/10.webp differ diff --git a/delamain/frontend/img/tiles/5/6/11.webp b/delamain/frontend/img/tiles/5/6/11.webp new file mode 100755 index 0000000..db6990b Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/11.webp differ diff --git a/delamain/frontend/img/tiles/5/6/12.webp b/delamain/frontend/img/tiles/5/6/12.webp new file mode 100755 index 0000000..64963e4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/12.webp differ diff --git a/delamain/frontend/img/tiles/5/6/13.webp b/delamain/frontend/img/tiles/5/6/13.webp new file mode 100755 index 0000000..2f7dfb2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/13.webp differ diff --git a/delamain/frontend/img/tiles/5/6/14.webp b/delamain/frontend/img/tiles/5/6/14.webp new file mode 100755 index 0000000..bdfaab8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/14.webp differ diff --git a/delamain/frontend/img/tiles/5/6/15.webp b/delamain/frontend/img/tiles/5/6/15.webp new file mode 100755 index 0000000..bb557d0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/15.webp differ diff --git a/delamain/frontend/img/tiles/5/6/16.webp b/delamain/frontend/img/tiles/5/6/16.webp new file mode 100755 index 0000000..bcea851 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/16.webp differ diff --git a/delamain/frontend/img/tiles/5/6/17.webp b/delamain/frontend/img/tiles/5/6/17.webp new file mode 100755 index 0000000..17a60e0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/17.webp differ diff --git a/delamain/frontend/img/tiles/5/6/18.webp b/delamain/frontend/img/tiles/5/6/18.webp new file mode 100755 index 0000000..d57278d Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/18.webp differ diff --git a/delamain/frontend/img/tiles/5/6/19.webp b/delamain/frontend/img/tiles/5/6/19.webp new file mode 100755 index 0000000..7225c37 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/19.webp differ diff --git a/delamain/frontend/img/tiles/5/6/2.webp b/delamain/frontend/img/tiles/5/6/2.webp new file mode 100755 index 0000000..edaa9b8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/2.webp differ diff --git a/delamain/frontend/img/tiles/5/6/20.webp b/delamain/frontend/img/tiles/5/6/20.webp new file mode 100755 index 0000000..e7e73ca Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/20.webp differ diff --git a/delamain/frontend/img/tiles/5/6/21.webp b/delamain/frontend/img/tiles/5/6/21.webp new file mode 100755 index 0000000..62eb2eb Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/21.webp differ diff --git a/delamain/frontend/img/tiles/5/6/22.webp b/delamain/frontend/img/tiles/5/6/22.webp new file mode 100755 index 0000000..1779564 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/22.webp differ diff --git a/delamain/frontend/img/tiles/5/6/23.webp b/delamain/frontend/img/tiles/5/6/23.webp new file mode 100755 index 0000000..6ab7b80 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/23.webp differ diff --git a/delamain/frontend/img/tiles/5/6/24.webp b/delamain/frontend/img/tiles/5/6/24.webp new file mode 100755 index 0000000..817de71 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/24.webp differ diff --git a/delamain/frontend/img/tiles/5/6/25.webp b/delamain/frontend/img/tiles/5/6/25.webp new file mode 100755 index 0000000..39cf547 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/25.webp differ diff --git a/delamain/frontend/img/tiles/5/6/26.webp b/delamain/frontend/img/tiles/5/6/26.webp new file mode 100755 index 0000000..bbebea9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/26.webp differ diff --git a/delamain/frontend/img/tiles/5/6/3.webp b/delamain/frontend/img/tiles/5/6/3.webp new file mode 100755 index 0000000..67b40fe Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/3.webp differ diff --git a/delamain/frontend/img/tiles/5/6/4.webp b/delamain/frontend/img/tiles/5/6/4.webp new file mode 100755 index 0000000..471619a Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/4.webp differ diff --git a/delamain/frontend/img/tiles/5/6/5.webp b/delamain/frontend/img/tiles/5/6/5.webp new file mode 100755 index 0000000..6977fe1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/5.webp differ diff --git a/delamain/frontend/img/tiles/5/6/6.webp b/delamain/frontend/img/tiles/5/6/6.webp new file mode 100755 index 0000000..9eec1a2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/6.webp differ diff --git a/delamain/frontend/img/tiles/5/6/7.webp b/delamain/frontend/img/tiles/5/6/7.webp new file mode 100755 index 0000000..19394d2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/7.webp differ diff --git a/delamain/frontend/img/tiles/5/6/8.webp b/delamain/frontend/img/tiles/5/6/8.webp new file mode 100755 index 0000000..ec7a165 Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/8.webp differ diff --git a/delamain/frontend/img/tiles/5/6/9.webp b/delamain/frontend/img/tiles/5/6/9.webp new file mode 100755 index 0000000..7a82e3b Binary files /dev/null and b/delamain/frontend/img/tiles/5/6/9.webp differ diff --git a/delamain/frontend/img/tiles/5/7/0.webp b/delamain/frontend/img/tiles/5/7/0.webp new file mode 100755 index 0000000..a0efcf7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/0.webp differ diff --git a/delamain/frontend/img/tiles/5/7/1.webp b/delamain/frontend/img/tiles/5/7/1.webp new file mode 100755 index 0000000..b71e82a Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/1.webp differ diff --git a/delamain/frontend/img/tiles/5/7/10.webp b/delamain/frontend/img/tiles/5/7/10.webp new file mode 100755 index 0000000..f89b028 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/10.webp differ diff --git a/delamain/frontend/img/tiles/5/7/11.webp b/delamain/frontend/img/tiles/5/7/11.webp new file mode 100755 index 0000000..9a0e645 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/11.webp differ diff --git a/delamain/frontend/img/tiles/5/7/12.webp b/delamain/frontend/img/tiles/5/7/12.webp new file mode 100755 index 0000000..b76d988 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/12.webp differ diff --git a/delamain/frontend/img/tiles/5/7/13.webp b/delamain/frontend/img/tiles/5/7/13.webp new file mode 100755 index 0000000..5296308 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/13.webp differ diff --git a/delamain/frontend/img/tiles/5/7/14.webp b/delamain/frontend/img/tiles/5/7/14.webp new file mode 100755 index 0000000..0a3bed7 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/14.webp differ diff --git a/delamain/frontend/img/tiles/5/7/15.webp b/delamain/frontend/img/tiles/5/7/15.webp new file mode 100755 index 0000000..5f20f60 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/15.webp differ diff --git a/delamain/frontend/img/tiles/5/7/16.webp b/delamain/frontend/img/tiles/5/7/16.webp new file mode 100755 index 0000000..dfeecbe Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/16.webp differ diff --git a/delamain/frontend/img/tiles/5/7/17.webp b/delamain/frontend/img/tiles/5/7/17.webp new file mode 100755 index 0000000..cd23c18 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/17.webp differ diff --git a/delamain/frontend/img/tiles/5/7/18.webp b/delamain/frontend/img/tiles/5/7/18.webp new file mode 100755 index 0000000..7db956f Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/18.webp differ diff --git a/delamain/frontend/img/tiles/5/7/19.webp b/delamain/frontend/img/tiles/5/7/19.webp new file mode 100755 index 0000000..758f2f2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/19.webp differ diff --git a/delamain/frontend/img/tiles/5/7/2.webp b/delamain/frontend/img/tiles/5/7/2.webp new file mode 100755 index 0000000..fedc7fa Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/2.webp differ diff --git a/delamain/frontend/img/tiles/5/7/20.webp b/delamain/frontend/img/tiles/5/7/20.webp new file mode 100755 index 0000000..8b02ca2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/20.webp differ diff --git a/delamain/frontend/img/tiles/5/7/21.webp b/delamain/frontend/img/tiles/5/7/21.webp new file mode 100755 index 0000000..6f85eb4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/21.webp differ diff --git a/delamain/frontend/img/tiles/5/7/22.webp b/delamain/frontend/img/tiles/5/7/22.webp new file mode 100755 index 0000000..f6e0433 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/22.webp differ diff --git a/delamain/frontend/img/tiles/5/7/23.webp b/delamain/frontend/img/tiles/5/7/23.webp new file mode 100755 index 0000000..66df479 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/23.webp differ diff --git a/delamain/frontend/img/tiles/5/7/24.webp b/delamain/frontend/img/tiles/5/7/24.webp new file mode 100755 index 0000000..fd58d04 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/24.webp differ diff --git a/delamain/frontend/img/tiles/5/7/25.webp b/delamain/frontend/img/tiles/5/7/25.webp new file mode 100755 index 0000000..de5b04d Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/25.webp differ diff --git a/delamain/frontend/img/tiles/5/7/26.webp b/delamain/frontend/img/tiles/5/7/26.webp new file mode 100755 index 0000000..38f2f30 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/26.webp differ diff --git a/delamain/frontend/img/tiles/5/7/3.webp b/delamain/frontend/img/tiles/5/7/3.webp new file mode 100755 index 0000000..8b6f436 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/3.webp differ diff --git a/delamain/frontend/img/tiles/5/7/4.webp b/delamain/frontend/img/tiles/5/7/4.webp new file mode 100755 index 0000000..ecdb7b4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/4.webp differ diff --git a/delamain/frontend/img/tiles/5/7/5.webp b/delamain/frontend/img/tiles/5/7/5.webp new file mode 100755 index 0000000..0ff0bcf Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/5.webp differ diff --git a/delamain/frontend/img/tiles/5/7/6.webp b/delamain/frontend/img/tiles/5/7/6.webp new file mode 100755 index 0000000..b998468 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/6.webp differ diff --git a/delamain/frontend/img/tiles/5/7/7.webp b/delamain/frontend/img/tiles/5/7/7.webp new file mode 100755 index 0000000..e932eb2 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/7.webp differ diff --git a/delamain/frontend/img/tiles/5/7/8.webp b/delamain/frontend/img/tiles/5/7/8.webp new file mode 100755 index 0000000..bba5439 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/8.webp differ diff --git a/delamain/frontend/img/tiles/5/7/9.webp b/delamain/frontend/img/tiles/5/7/9.webp new file mode 100755 index 0000000..28eadc8 Binary files /dev/null and b/delamain/frontend/img/tiles/5/7/9.webp differ diff --git a/delamain/frontend/img/tiles/5/8/0.webp b/delamain/frontend/img/tiles/5/8/0.webp new file mode 100755 index 0000000..716fe34 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/0.webp differ diff --git a/delamain/frontend/img/tiles/5/8/1.webp b/delamain/frontend/img/tiles/5/8/1.webp new file mode 100755 index 0000000..cb82735 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/1.webp differ diff --git a/delamain/frontend/img/tiles/5/8/10.webp b/delamain/frontend/img/tiles/5/8/10.webp new file mode 100755 index 0000000..3821545 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/10.webp differ diff --git a/delamain/frontend/img/tiles/5/8/11.webp b/delamain/frontend/img/tiles/5/8/11.webp new file mode 100755 index 0000000..def39e5 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/11.webp differ diff --git a/delamain/frontend/img/tiles/5/8/12.webp b/delamain/frontend/img/tiles/5/8/12.webp new file mode 100755 index 0000000..e69065c Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/12.webp differ diff --git a/delamain/frontend/img/tiles/5/8/13.webp b/delamain/frontend/img/tiles/5/8/13.webp new file mode 100755 index 0000000..ef44250 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/13.webp differ diff --git a/delamain/frontend/img/tiles/5/8/14.webp b/delamain/frontend/img/tiles/5/8/14.webp new file mode 100755 index 0000000..483468a Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/14.webp differ diff --git a/delamain/frontend/img/tiles/5/8/15.webp b/delamain/frontend/img/tiles/5/8/15.webp new file mode 100755 index 0000000..48a1a07 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/15.webp differ diff --git a/delamain/frontend/img/tiles/5/8/16.webp b/delamain/frontend/img/tiles/5/8/16.webp new file mode 100755 index 0000000..b4010a1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/16.webp differ diff --git a/delamain/frontend/img/tiles/5/8/17.webp b/delamain/frontend/img/tiles/5/8/17.webp new file mode 100755 index 0000000..3d6045b Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/17.webp differ diff --git a/delamain/frontend/img/tiles/5/8/18.webp b/delamain/frontend/img/tiles/5/8/18.webp new file mode 100755 index 0000000..0f67432 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/18.webp differ diff --git a/delamain/frontend/img/tiles/5/8/19.webp b/delamain/frontend/img/tiles/5/8/19.webp new file mode 100755 index 0000000..512829e Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/19.webp differ diff --git a/delamain/frontend/img/tiles/5/8/2.webp b/delamain/frontend/img/tiles/5/8/2.webp new file mode 100755 index 0000000..953204b Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/2.webp differ diff --git a/delamain/frontend/img/tiles/5/8/20.webp b/delamain/frontend/img/tiles/5/8/20.webp new file mode 100755 index 0000000..cc89baf Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/20.webp differ diff --git a/delamain/frontend/img/tiles/5/8/21.webp b/delamain/frontend/img/tiles/5/8/21.webp new file mode 100755 index 0000000..5a53d41 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/21.webp differ diff --git a/delamain/frontend/img/tiles/5/8/22.webp b/delamain/frontend/img/tiles/5/8/22.webp new file mode 100755 index 0000000..980424d Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/22.webp differ diff --git a/delamain/frontend/img/tiles/5/8/23.webp b/delamain/frontend/img/tiles/5/8/23.webp new file mode 100755 index 0000000..fae5eaa Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/23.webp differ diff --git a/delamain/frontend/img/tiles/5/8/24.webp b/delamain/frontend/img/tiles/5/8/24.webp new file mode 100755 index 0000000..39894ef Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/24.webp differ diff --git a/delamain/frontend/img/tiles/5/8/25.webp b/delamain/frontend/img/tiles/5/8/25.webp new file mode 100755 index 0000000..e4635b3 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/25.webp differ diff --git a/delamain/frontend/img/tiles/5/8/26.webp b/delamain/frontend/img/tiles/5/8/26.webp new file mode 100755 index 0000000..091518f Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/26.webp differ diff --git a/delamain/frontend/img/tiles/5/8/3.webp b/delamain/frontend/img/tiles/5/8/3.webp new file mode 100755 index 0000000..1ea4107 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/3.webp differ diff --git a/delamain/frontend/img/tiles/5/8/4.webp b/delamain/frontend/img/tiles/5/8/4.webp new file mode 100755 index 0000000..c87eb51 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/4.webp differ diff --git a/delamain/frontend/img/tiles/5/8/5.webp b/delamain/frontend/img/tiles/5/8/5.webp new file mode 100755 index 0000000..4a53bdc Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/5.webp differ diff --git a/delamain/frontend/img/tiles/5/8/6.webp b/delamain/frontend/img/tiles/5/8/6.webp new file mode 100755 index 0000000..9913897 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/6.webp differ diff --git a/delamain/frontend/img/tiles/5/8/7.webp b/delamain/frontend/img/tiles/5/8/7.webp new file mode 100755 index 0000000..7e5dab4 Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/7.webp differ diff --git a/delamain/frontend/img/tiles/5/8/8.webp b/delamain/frontend/img/tiles/5/8/8.webp new file mode 100755 index 0000000..89dcd3b Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/8.webp differ diff --git a/delamain/frontend/img/tiles/5/8/9.webp b/delamain/frontend/img/tiles/5/8/9.webp new file mode 100755 index 0000000..3b4648f Binary files /dev/null and b/delamain/frontend/img/tiles/5/8/9.webp differ diff --git a/delamain/frontend/img/tiles/5/9/0.webp b/delamain/frontend/img/tiles/5/9/0.webp new file mode 100755 index 0000000..15d1d50 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/0.webp differ diff --git a/delamain/frontend/img/tiles/5/9/1.webp b/delamain/frontend/img/tiles/5/9/1.webp new file mode 100755 index 0000000..186b51b Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/1.webp differ diff --git a/delamain/frontend/img/tiles/5/9/10.webp b/delamain/frontend/img/tiles/5/9/10.webp new file mode 100755 index 0000000..47504ac Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/10.webp differ diff --git a/delamain/frontend/img/tiles/5/9/11.webp b/delamain/frontend/img/tiles/5/9/11.webp new file mode 100755 index 0000000..2442ba6 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/11.webp differ diff --git a/delamain/frontend/img/tiles/5/9/12.webp b/delamain/frontend/img/tiles/5/9/12.webp new file mode 100755 index 0000000..2f3b0f1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/12.webp differ diff --git a/delamain/frontend/img/tiles/5/9/13.webp b/delamain/frontend/img/tiles/5/9/13.webp new file mode 100755 index 0000000..2ad987b Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/13.webp differ diff --git a/delamain/frontend/img/tiles/5/9/14.webp b/delamain/frontend/img/tiles/5/9/14.webp new file mode 100755 index 0000000..23e772f Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/14.webp differ diff --git a/delamain/frontend/img/tiles/5/9/15.webp b/delamain/frontend/img/tiles/5/9/15.webp new file mode 100755 index 0000000..7d69667 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/15.webp differ diff --git a/delamain/frontend/img/tiles/5/9/16.webp b/delamain/frontend/img/tiles/5/9/16.webp new file mode 100755 index 0000000..e875b32 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/16.webp differ diff --git a/delamain/frontend/img/tiles/5/9/17.webp b/delamain/frontend/img/tiles/5/9/17.webp new file mode 100755 index 0000000..5c96a8e Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/17.webp differ diff --git a/delamain/frontend/img/tiles/5/9/18.webp b/delamain/frontend/img/tiles/5/9/18.webp new file mode 100755 index 0000000..17036ef Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/18.webp differ diff --git a/delamain/frontend/img/tiles/5/9/19.webp b/delamain/frontend/img/tiles/5/9/19.webp new file mode 100755 index 0000000..b199d16 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/19.webp differ diff --git a/delamain/frontend/img/tiles/5/9/2.webp b/delamain/frontend/img/tiles/5/9/2.webp new file mode 100755 index 0000000..a70cbe1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/2.webp differ diff --git a/delamain/frontend/img/tiles/5/9/20.webp b/delamain/frontend/img/tiles/5/9/20.webp new file mode 100755 index 0000000..c98959a Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/20.webp differ diff --git a/delamain/frontend/img/tiles/5/9/21.webp b/delamain/frontend/img/tiles/5/9/21.webp new file mode 100755 index 0000000..2baaf6c Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/21.webp differ diff --git a/delamain/frontend/img/tiles/5/9/22.webp b/delamain/frontend/img/tiles/5/9/22.webp new file mode 100755 index 0000000..c2175be Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/22.webp differ diff --git a/delamain/frontend/img/tiles/5/9/23.webp b/delamain/frontend/img/tiles/5/9/23.webp new file mode 100755 index 0000000..68f44a1 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/23.webp differ diff --git a/delamain/frontend/img/tiles/5/9/24.webp b/delamain/frontend/img/tiles/5/9/24.webp new file mode 100755 index 0000000..6f6edee Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/24.webp differ diff --git a/delamain/frontend/img/tiles/5/9/25.webp b/delamain/frontend/img/tiles/5/9/25.webp new file mode 100755 index 0000000..56eee07 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/25.webp differ diff --git a/delamain/frontend/img/tiles/5/9/26.webp b/delamain/frontend/img/tiles/5/9/26.webp new file mode 100755 index 0000000..944dea9 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/26.webp differ diff --git a/delamain/frontend/img/tiles/5/9/3.webp b/delamain/frontend/img/tiles/5/9/3.webp new file mode 100755 index 0000000..e9f6e53 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/3.webp differ diff --git a/delamain/frontend/img/tiles/5/9/4.webp b/delamain/frontend/img/tiles/5/9/4.webp new file mode 100755 index 0000000..2b9a1ce Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/4.webp differ diff --git a/delamain/frontend/img/tiles/5/9/5.webp b/delamain/frontend/img/tiles/5/9/5.webp new file mode 100755 index 0000000..421e8f0 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/5.webp differ diff --git a/delamain/frontend/img/tiles/5/9/6.webp b/delamain/frontend/img/tiles/5/9/6.webp new file mode 100755 index 0000000..62c8283 Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/6.webp differ diff --git a/delamain/frontend/img/tiles/5/9/7.webp b/delamain/frontend/img/tiles/5/9/7.webp new file mode 100755 index 0000000..e60254c Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/7.webp differ diff --git a/delamain/frontend/img/tiles/5/9/8.webp b/delamain/frontend/img/tiles/5/9/8.webp new file mode 100755 index 0000000..b01a45e Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/8.webp differ diff --git a/delamain/frontend/img/tiles/5/9/9.webp b/delamain/frontend/img/tiles/5/9/9.webp new file mode 100755 index 0000000..a2182ff Binary files /dev/null and b/delamain/frontend/img/tiles/5/9/9.webp differ diff --git a/delamain/frontend/index.html b/delamain/frontend/index.html new file mode 100755 index 0000000..dc2ed89 --- /dev/null +++ b/delamain/frontend/index.html @@ -0,0 +1,175 @@ + + + + + + + Delamain // Night City Transit + + + + + +
+
+ + + + +
+ NC-NET ONLINE + + + +
+
+ +
+
+
+
+ + + + +
+ NIGHT CITY / ROUTE PLANNER + SELECT DESTINATION + Click anywhere to set pickup and drop-off coordinates +
+ + + +
+ PICKUP + DESTINATION + POINT OF INTEREST +
+ +
+ LMB + SET PICKUP POINT +
+
+ + +
+ +
+
+
PERSONAL DATABASE

RIDE ARCHIVE

+ +
+
+
+ +
+ +
DELAMAIN // NIGHT CITY TRANSIT NETWORKBUILD 7.7.04
+
+ + + + + + + + + + + + diff --git a/delamain/frontend/js/api.js b/delamain/frontend/js/api.js new file mode 100755 index 0000000..6c6238e --- /dev/null +++ b/delamain/frontend/js/api.js @@ -0,0 +1,50 @@ +const API_BASE = '/api'; + +async function request(path, options = {}) { + const token = localStorage.getItem('delamain_token'); + const headers = { 'Content-Type': 'application/json' }; + if (token) headers['Authorization'] = `Bearer ${token}`; + const resp = await fetch(`${API_BASE}${path}`, { + ...options, + headers, + }); + if (!resp.ok && resp.status !== 400 && resp.status !== 403 && resp.status !== 404) { + const body = await resp.json().catch(() => ({})); + throw new Error(body.error || `Request failed: ${resp.status}`); + } + return resp.json(); +} + +const api = { + request, + + login: (username, password) => + request('/login', { method: 'POST', body: JSON.stringify({ username, password }) }), + + createUser: (username, password) => + request('/users', { method: 'POST', body: JSON.stringify({ username, password }) }), + + createTrip: (tripData) => + request('/trips', { method: 'POST', body: JSON.stringify(tripData) }), + + getTrip: (tripId) => request(`/trips/${tripId}`), + + getAllTrips: () => request('/trips'), + + getVersions: (tripId) => request(`/trips/${tripId}/versions`), + + createPackage: (tripId) => + request('/packages', { method: 'POST', body: JSON.stringify({ trip_id: tripId }) }), + + + + estimate: (fromX, fromY, toX, toY, cls) => + request('/estimate', { + method: 'POST', + body: JSON.stringify({ from_x: fromX, from_y: fromY, to_x: toX, to_y: toY, class: cls }), + }), + + bookRide: (payload) => request('/trips', { method: 'POST', body: JSON.stringify(payload) }), + + +}; diff --git a/delamain/frontend/js/app.js b/delamain/frontend/js/app.js new file mode 100755 index 0000000..e0f6551 --- /dev/null +++ b/delamain/frontend/js/app.js @@ -0,0 +1,271 @@ +const CLASSES = ['Economy', 'Business', 'Excelsior']; + +const app = { + user: null, + estimates: {}, + selectedClass: null, + booking: false, + estimateSeq: 0, + + init: () => { + app.user = { + name: localStorage.getItem('delamain_username'), + token: localStorage.getItem('delamain_token'), + }; + app.bindEvents(); + app.updateAuthUI(); + app.loadTrips(); + }, + + updateAuthUI: () => { + const logged = !!(app.user && app.user.name); + document.getElementById('btn-login').style.display = logged ? 'none' : 'block'; + document.getElementById('btn-logout').style.display = logged ? 'block' : 'none'; + document.getElementById('auth-hello').textContent = logged ? `Welcome, ${app.user.name}` : ''; + }, + + bindEvents: () => { + document.querySelectorAll('.nav-btn').forEach((btn) => { + btn.addEventListener('click', () => app.switchSection(btn.dataset.section)); + }); + document.querySelector('.brand').addEventListener('click', () => app.switchSection('section-rides')); + document.querySelectorAll('.close').forEach((c) => + c.addEventListener('click', () => utils.hideModal(c.closest('.modal').id))); + window.addEventListener('click', (e) => { + if (e.target.classList.contains('modal')) utils.hideModal(e.target.id); + }); + + document.getElementById('btn-login').addEventListener('click', () => utils.showModal('login-modal')); + document.getElementById('btn-logout').addEventListener('click', app.logout); + document.getElementById('btn-register').addEventListener('click', app.register); + document.getElementById('login-form').addEventListener('submit', app.login); + + document.getElementById('btn-refresh-trips').addEventListener('click', app.loadTrips); + document.getElementById('btn-book').addEventListener('click', app.bookRide); + document.getElementById('btn-new-ride').addEventListener('click', app.newRide); + + + document.getElementById('trips-list').addEventListener('click', (e) => { + const btn = e.target.closest('button[data-act]'); + if (!btn) return; + const id = btn.dataset.id; + if (btn.dataset.act === 'view') app.showTripDetails(id); + if (btn.dataset.act === 'versions') app.showVersions(id); + if (btn.dataset.act === 'export') app.exportTrip(id); + }); + + + NightCityMap.init(document.getElementById('nc-map'), app.onPointsChanged); + }, + + switchSection: (id) => { + document.querySelectorAll('.nav-btn').forEach((b) => b.classList.toggle('active', b.dataset.section === id)); + document.querySelectorAll('.section').forEach((s) => s.classList.toggle('active', s.id === id)); + if (id === 'section-trips') app.loadTrips(); + if (id === 'section-rides') window.setTimeout(() => NightCityMap.refresh(), 0); + }, + + onPointsChanged: async ({ A, B }) => { + const estimateBlock = document.getElementById('estimate-block'); + const estimateLoading = document.getElementById('estimate-loading'); + const noPoints = document.getElementById('no-points'); + const booked = document.getElementById('booked-block'); + const pickup = document.getElementById('pickup-display'); + const destination = document.getElementById('destination-display'); + const hint = document.getElementById('map-hint-text'); + const seq = ++app.estimateSeq; + + pickup.textContent = A ? A.name : 'NOT SELECTED'; + destination.textContent = B ? B.name : 'NOT SELECTED'; + pickup.classList.toggle('is-set', !!A); + destination.classList.toggle('is-set', !!B); + hint.textContent = !A ? 'SET PICKUP POINT' : !B ? 'SET DESTINATION' : 'CLICK TO START A NEW ROUTE'; + app.estimates = {}; + app.selectedClass = null; + document.getElementById('btn-book').disabled = true; + + if (!A || !B) { + estimateBlock.style.display = 'none'; + estimateLoading.style.display = 'none'; + booked.style.display = 'none'; + noPoints.style.display = 'block'; + return; + } + + booked.style.display = 'none'; + noPoints.style.display = 'none'; + estimateBlock.style.display = 'none'; + estimateLoading.style.display = 'block'; + document.getElementById('route-summary').textContent = `${A.name} → ${B.name}`; + + const results = await Promise.all( + CLASSES.map((cls) => api.estimate(A.x, A.y, B.x, B.y, cls).catch(() => null)) + ); + if (seq !== app.estimateSeq) return; + estimateLoading.style.display = 'none'; + estimateBlock.style.display = 'block'; + const container = document.getElementById('class-cards'); + container.innerHTML = ''; + results.forEach((r, i) => { + if (!r || r.status !== 0) return; + app.estimates[CLASSES[i]] = r; + const card = document.createElement('div'); + card.className = 'class-card'; + card.dataset.cls = CLASSES[i]; + const serviceNames = ['Standard', 'Executive', 'Excelsior']; + card.innerHTML = ` +
${serviceNames[i]}
+
${r.duration_min} min · ${r.distance_km} km
+
${r.price} ¢
`; + card.addEventListener('click', () => { + app.selectedClass = CLASSES[i]; + container.querySelectorAll('.class-card').forEach((c) => + c.classList.toggle('selected', c.dataset.cls === CLASSES[i])); + document.getElementById('btn-book').disabled = app.booking; + }); + container.appendChild(card); + }); + }, + + bookRide: async () => { + const { A, B } = NightCityMap.points; + const cls = app.selectedClass; + if (!A || !B || !cls || app.booking) return; + app.booking = true; + document.getElementById('btn-book').disabled = true; + + try { + const resp = await api.bookRide({ + origin: A.name, + destination: B.name, + from_x: A.x, from_y: A.y, + to_x: B.x, to_y: B.y, + class: cls, + stops: [A.name, B.name], + instruction: document.getElementById('ride-instruction').value, + }); + const est = app.estimates[cls] || {}; + document.getElementById('estimate-block').style.display = 'none'; + const booked = document.getElementById('booked-block'); + booked.style.display = 'block'; + document.getElementById('booked-card').innerHTML = ` +
${utils.escapeHtml(resp.trip_id)}
+
${utils.escapeHtml(A.name)} → ${utils.escapeHtml(B.name)}
+
${cls} · ${est.duration_min || '?'} min · ${est.price || '?'} ¢
+
Delamain cab #${Math.floor(Math.random() * 900 + 100)} is on the way
+
instruction version: ${utils.escapeHtml(resp.version_token || '')}
`; + utils.notify(`Ride ${resp.trip_id} booked!`); + } catch (err) { + utils.showError(err); + document.getElementById('btn-book').disabled = false; + } finally { + app.booking = false; + } + }, + + newRide: () => { + NightCityMap.reset(); + document.getElementById('booked-block').style.display = 'none'; + document.getElementById('ride-instruction').value = ''; + utils.notify('Route cleared'); + }, + + loadTrips: async () => { + const list = document.getElementById('trips-list'); + try { + const resp = await api.getAllTrips(); + list.innerHTML = ''; + if (resp.trips && resp.trips.length) { + resp.trips.forEach((t) => list.appendChild(utils.tripCard(t))); + } else { + utils.empty('trips-list', 'No rides yet. Book your first Delamain ride!'); + } + } catch (err) { + utils.empty('trips-list', 'Failed to load trips. Is the service running?'); + } + }, + + showTripDetails: async (tripId) => { + try { + const trip = await api.getTrip(tripId); + const stops = (trip.stops || []) + .map((s, i) => `${i + 1}. ${s.name} (${Math.round(s.x)},${Math.round(s.y)})${s.is_pickup ? ' — pickup' : ''}`) + .join('\n'); + alert( + `Ride ${trip.trip_id}\nClass: ${trip.trip.class}\nStatus: ${trip.trip.status}\n\n` + + `Route:\n${stops}\n\nPrivate instruction:\n${trip.instruction}\n\nVersion token: ${trip.version_token}` + ); + } catch (err) { + utils.showError(err); + } + }, + + showVersions: async (tripId) => { + try { + const resp = await api.getVersions(tripId); + const rows = (resp.versions || []) + .map((v) => `${v.version_token} ${v.size}b ${utils.formatDate(v.created_at)}`) + .join('\n'); + alert(`Instruction versions for ${tripId}:\n\n${rows || '(none)'}`); + } catch (err) { + utils.showError(err); + } + }, + + exportTrip: async (tripId) => { + try { + const pkg = await api.createPackage(tripId); + const rows = (pkg.notes || []).map((n) => { + if (n.skipped) { + return `
${utils.escapeHtml(n.source || 'note')}${utils.escapeHtml(n.skipped)}
`; + } + return `
Private instruction${utils.escapeHtml(n.data || '')}
`; + }).join(''); + document.getElementById('export-result').innerHTML = rows || '
No note segments
'; + utils.showModal('export-modal'); + } catch (err) { + utils.showError(err); + } + }, + + login: async (e) => { + e.preventDefault(); + const username = document.getElementById('username').value.trim(); + const password = document.getElementById('password').value; + try { + const resp = await api.login(username, password); + app.user = { name: resp.username, token: resp.token }; + localStorage.setItem('delamain_username', resp.username); + localStorage.setItem('delamain_token', resp.token); + utils.hideModal('login-modal'); + app.updateAuthUI(); + utils.notify(`Welcome back, ${resp.username}! Ride in style.`); + app.loadTrips(); + } catch (err) { + utils.showError(err); + } + }, + + register: async () => { + const username = document.getElementById('username').value.trim(); + const password = document.getElementById('password').value; + if (!username || !password) return utils.notify('Enter username and password', 'error'); + try { + await api.createUser(username, password); + utils.notify('Account created, logging in...'); + await app.login({ preventDefault: () => {} }); + } catch (err) { + utils.showError(err); + } + }, + + logout: () => { + app.user = null; + localStorage.removeItem('delamain_username'); + localStorage.removeItem('delamain_token'); + app.updateAuthUI(); + utils.notify('Logged out'); + }, +}; + +document.addEventListener('DOMContentLoaded', app.init); diff --git a/delamain/frontend/js/map.js b/delamain/frontend/js/map.js new file mode 100755 index 0000000..e89c452 --- /dev/null +++ b/delamain/frontend/js/map.js @@ -0,0 +1,186 @@ +const NightCityMap = (() => { + const Z = 4, SCALE = 256 * 16; + const B = { x0: 0, y0: 0, x1: 14 * 256, y1: 13 * 256 }; + + const fracToLatLng = (fx, fy) => { + const px = B.x0 + fx * (B.x1 - B.x0); + const py = B.y0 + fy * (B.y1 - B.y0); + return L.latLng(pyToLat(py), pxToLng(px)); + }; + const pxToLng = (px) => (px / SCALE) * 360 - 180; + const pyToLat = (py) => { + const n = Math.PI * (1 - (2 * py) / SCALE); + return (Math.atan(Math.sinh(n)) * 180) / Math.PI; + }; + + const latLngToUnits = (latlng) => { + const p = L.CRS.EPSG3857.latLngToPoint(L.latLng(latlng), Z); + const u = ((p.x - B.x0) / (B.x1 - B.x0)) * 1000; + const v = ((p.y - B.y0) / (B.y1 - B.y0)) * 700; + return { + x: Math.max(0, Math.min(1000, u)), + y: Math.max(0, Math.min(700, v)), + }; + }; + + const DISTRICTS = [ + { name: 'Watson', box: [0.03, 0.03, 0.30, 0.24] }, + { name: 'City Center', box: [0.33, 0.02, 0.54, 0.18] }, + { name: 'Westbrook', box: [0.55, 0.04, 0.90, 0.28] }, + { name: 'Heywood', box: [0.22, 0.26, 0.66, 0.60] }, + { name: 'Santo Domingo', box: [0.66, 0.28, 0.95, 0.62] }, + { name: 'Pacifica', box: [0.06, 0.62, 0.42, 0.95] }, + { name: 'Badlands', box: [0.42, 0.62, 1.00, 0.97] }, + { name: 'Badlands', box: [0.90, 0.10, 1.00, 0.60] }, + ]; + + const POIS = [ + { id: 'kabuki', name: 'Kabuki Market', fx: 0.13, fy: 0.10 }, + { id: 'arasaka', name: 'Arasaka Waterfront', fx: 0.50, fy: 0.045 }, + { id: 'corpo', name: 'Corpo Plaza', fx: 0.44, fy: 0.10 }, + { id: 'japantown', name: 'Japantown', fx: 0.63, fy: 0.15 }, + { id: 'afterlife', name: 'Afterlife', fx: 0.42, fy: 0.30 }, + { id: 'mbh10', name: 'Megabuilding H10', fx: 0.33, fy: 0.42 }, + { id: 'dogtown', name: 'Dogtown Gate', fx: 0.55, fy: 0.70 }, + { id: 'mall', name: 'Grand Illusion Mall', fx: 0.23, fy: 0.78 }, + ].map((p) => ({ ...p, latlng: fracToLatLng(p.fx, p.fy), units: { x: p.fx * 1000, y: p.fy * 700 } })); + + let map; + const points = { A: null, B: null }; + let onChange = () => {}; + let routeLine = null; + const markers = { A: null, B: null }; + + function districtAt(units) { + const fx = units.x / 1000, fy = units.y / 700; + for (const d of DISTRICTS) { + const [x0, y0, x1, y1] = d.box; + if (fx >= x0 && fx <= x1 && fy >= y0 && fy <= y1) return d.name; + } + return 'Night City outskirts'; + } + + function nearestPOI(units) { + let best = null, bestD = 55; + for (const p of POIS) { + const d = Math.hypot(p.units.x - units.x, (p.units.y - units.y) * (10 / 7)); + if (d < bestD) { bestD = d; best = p; } + } + return best; + } + + function placeName(units) { + const poi = nearestPOI(units); + return poi ? poi.name : districtAt(units); + } + + function pinIcon(color, label) { + return L.divIcon({ + className: 'nc-pin-wrap', + html: `
${label}
`, + iconSize: [0, 0], + iconAnchor: [0, 0], + }); + } + + function render() { + for (const key of ['A', 'B']) { + const p = points[key]; + if (markers[key]) { markers[key].remove(); markers[key] = null; } + if (p) { + markers[key] = L.marker(p.latlng, { + icon: pinIcon(key === 'A' ? '#00d4ff' : '#ffe600', key), + zIndexOffset: 1000, + keyboard: false, + }).addTo(map); + } + } + if (routeLine) { routeLine.remove(); routeLine = null; } + if (points.A && points.B) { + const { A, B } = points; + const mid = fracToLatLng( + (A.fx + B.fx) / 2 + (B.fy - A.fy) * 0.08, + (A.fy + B.fy) / 2 - (B.fx - A.fx) * 0.08 + ); + routeLine = L.polyline([A.latlng, mid, B.latlng], { + color: '#00f0ff', + weight: 4, + opacity: 0.9, + dashArray: '12 10', + className: 'nc-route', + }).addTo(map); + map.fitBounds(L.latLngBounds(A.latlng, B.latlng).pad(0.25), { animate: true }); + } + } + + function setPoint(which, latlng) { + if (which === 'A' && points.A && points.B) { + points.A = null; points.B = null; + which = 'A'; + } + const units = latLngToUnits(latlng); + points[which] = { + latlng: L.latLng(latlng), + lat: latlng.lat, lng: latlng.lng, + x: units.x, y: units.y, + fx: units.x / 1000, fy: units.y / 700, + name: placeName(units), + }; + render(); + onChange({ A: points.A, B: points.B }); + } + + function init(container, callback) { + map = L.map(container, { + minZoom: 3, + maxZoom: 5, + zoomControl: true, + attributionControl: false, + maxBounds: L.latLngBounds(fracToLatLng(-0.03, -0.03), fracToLatLng(1.03, 1.03)), + maxBoundsViscosity: 0.7, + }); + map.setView(fracToLatLng(0.5, 0.45), 4); + + L.tileLayer('img/tiles/{z}/{x}/{y}.webp', { + minZoom: 3, + maxZoom: 5, + noWrap: true, + bounds: L.latLngBounds(fracToLatLng(0, 0), fracToLatLng(1, 1)), + }).addTo(map); + + for (const p of POIS) { + L.marker(p.latlng, { + icon: L.divIcon({ + className: 'nc-poi-wrap', + html: `
${p.name}
`, + iconSize: [0, 0], + }), + keyboard: false, + }) + .on('click', (e) => { + L.DomEvent.stopPropagation(e); + setPoint(points.A === null ? 'A' : 'B', p.latlng); + }) + .addTo(map); + } + + map.on('click', (e) => setPoint(points.A === null ? 'A' : 'B', e.latlng)); + + if (callback) onChange = callback; + } + + return { + init, + setPoint: (which, latlng) => setPoint(which, latlng), + get points() { return points; }, + reset() { + points.A = null; points.B = null; + render(); + map.setView(fracToLatLng(0.5, 0.45), 4); + onChange({ A: null, B: null }); + }, + refresh() { + if (map) map.invalidateSize({ animate: false }); + }, + }; +})(); diff --git a/delamain/frontend/js/utils.js b/delamain/frontend/js/utils.js new file mode 100755 index 0000000..1bf744a --- /dev/null +++ b/delamain/frontend/js/utils.js @@ -0,0 +1,54 @@ +const utils = { + showModal: (id) => { document.getElementById(id).style.display = 'flex'; }, + hideModal: (id) => { document.getElementById(id).style.display = 'none'; }, + + notify: (message, type = 'info') => { + const n = document.createElement('div'); + n.className = `notification ${type}`; + n.textContent = message; + document.body.appendChild(n); + setTimeout(() => n.remove(), 3500); + }, + + showError: (error) => { + console.error(error); + utils.notify(error.message || String(error), 'error'); + }, + + formatDate: (s) => { + if (!s) return ''; + const d = new Date(s); + return isNaN(d) ? s : d.toLocaleString(); + }, + + empty: (id, msg) => { + document.getElementById(id).innerHTML = `
${msg}
`; + }, + + escapeHtml: (s) => { + const div = document.createElement('div'); + div.textContent = s == null ? '' : String(s); + return div.innerHTML; + }, + + tripCard: (trip) => { + const card = document.createElement('div'); + card.className = 'trip-card'; + card.innerHTML = ` +
+

${utils.escapeHtml(trip.id)}

+ ${utils.escapeHtml(trip.class || '')} +
+
+
Status${utils.escapeHtml(trip.status || '')}
+
Created${utils.escapeHtml(utils.formatDate(trip.created_at))}
+
+
+ + + +
`; + return card; + }, + +}; diff --git a/delamain/frontend/styles/main.css b/delamain/frontend/styles/main.css new file mode 100755 index 0000000..ee4bd12 --- /dev/null +++ b/delamain/frontend/styles/main.css @@ -0,0 +1,335 @@ +:root { + --yellow: #fcee0a; + --red: #ff2a3d; + --cyan: #00f0ff; + --ink: #09090b; + --panel: #111115; + --panel-2: #18181d; + --line: #414149; + --muted: #8a8a91; + --white: #e9e9e4; + --cut: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 12px 100%, 0 calc(100% - 12px)); +} + +* { box-sizing: border-box; margin: 0; padding: 0; } + +html, body { width: 100%; min-height: 100%; background: var(--ink); } + +body { + color: var(--white); + font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", sans-serif; + font-stretch: condensed; + overflow-x: hidden; +} + +body::before { + content: ""; + position: fixed; + inset: 0; + z-index: 10000; + pointer-events: none; + opacity: .16; + background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(255,255,255,.035) 3px); + mix-blend-mode: overlay; +} + +button, input, textarea { font: inherit; } +button { color: inherit; } + +.screen-noise { + position: fixed; + inset: 0; + pointer-events: none; + z-index: 9999; + opacity: .025; + background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E"); +} + +.app-shell { min-height: 100vh; display: flex; flex-direction: column; } + +.topbar { + height: 76px; + display: grid; + grid-template-columns: 290px 1fr minmax(290px, auto); + align-items: stretch; + position: relative; + z-index: 1000; + background: var(--yellow); + color: var(--ink); + border-bottom: 5px solid var(--ink); +} + +.topbar::after { + content: ""; + position: absolute; + bottom: -5px; + left: 26px; + width: 180px; + height: 5px; + background: var(--red); +} + +.brand { + border: 0; + background: var(--ink); + color: var(--yellow); + display: flex; + align-items: center; + gap: 13px; + padding: 9px 28px 9px 18px; + cursor: pointer; + clip-path: polygon(0 0, 100% 0, calc(100% - 24px) 100%, 0 100%); + text-align: left; +} + +.brand-mark { + width: 44px; + height: 44px; + display: grid; + place-items: center; + border: 2px solid var(--yellow); + border-radius: 50%; + font-size: 27px; + font-weight: 900; + font-style: italic; +} + +.brand-copy { display: flex; flex-direction: column; } +.brand-copy strong { font-size: 25px; letter-spacing: 2px; line-height: 1; } +.brand-copy small { margin-top: 5px; font-size: 8px; letter-spacing: 2px; color: var(--cyan); } + +.nav { display: flex; align-items: stretch; padding-left: 15px; } +.nav-btn { + min-width: 130px; + border: 0; + border-right: 1px solid rgba(0,0,0,.3); + background: transparent; + color: var(--ink); + font-weight: 900; + letter-spacing: 1.5px; + cursor: pointer; + position: relative; + transition: background .15s, color .15s; +} +.nav-btn span { font-size: 9px; vertical-align: super; margin-right: 5px; opacity: .55; } +.nav-btn:hover, .nav-btn.active { background: var(--red); color: #fff; } +.nav-btn.active::after { content:""; position:absolute; left:20px; right:20px; bottom:8px; height:3px; background:#fff; } + +.auth { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 0 20px; font-size: 11px; font-weight: 800; letter-spacing: 1px; } +.network-state { font-size: 9px; } +.network-state i { display:inline-block; width:7px; height:7px; background:#28a745; margin-right:6px; box-shadow:0 0 8px #28a745; } + +main { flex: 1; min-height: 0; } +.section { display: none; } +.section.active { display: block; } + +.map-screen { + height: calc(100vh - 104px); + min-height: 670px; + position: relative; + background: #13080b; +} + +.map-wrap { position: absolute; inset: 0 420px 0 0; overflow: hidden; background: #180508; } +.nc-map { width: 100%; height: 100%; background: #140609; cursor: crosshair; } + +.nc-map .leaflet-tile-pane { + filter: grayscale(1) sepia(1) saturate(7) hue-rotate(305deg) brightness(.52) contrast(1.7); +} +.nc-map .leaflet-tile { image-rendering: auto; } +.nc-map .leaflet-control-zoom { border: 0; box-shadow: none; margin: 100px 0 0 22px; } +.nc-map .leaflet-control-zoom a { + width: 32px; height: 32px; line-height: 29px; + border-radius: 0 !important; + border: 1px solid var(--red); + background: rgba(12,6,8,.88); + color: var(--red); +} +.nc-map .leaflet-control-zoom a:hover { background: var(--red); color: #fff; } + +.map-grade, .map-grid, .map-vignette { position:absolute; inset:0; pointer-events:none; z-index:400; } +.map-grade { background: rgba(52,0,7,.2); mix-blend-mode: color; } +.map-grid { + opacity: .14; + background-image: + linear-gradient(rgba(255,43,61,.35) 1px, transparent 1px), + linear-gradient(90deg, rgba(255,43,61,.35) 1px, transparent 1px); + background-size: 80px 80px; +} +.map-vignette { box-shadow: inset 0 0 130px 45px #070406; } + +.hud-corner { position:absolute; z-index:500; pointer-events:none; } +.map-title { left:24px; top:22px; display:flex; flex-direction:column; } +.map-title strong { font-size:32px; line-height:1; letter-spacing:1px; color:#fff; text-shadow:2px 0 var(--red); } +.map-title small { margin-top:8px; color:#b2a9ab; font-size:11px; letter-spacing:1px; } +.eyebrow { color:var(--red); font-size:9px; font-weight:900; letter-spacing:2px; } +.map-telemetry { right:20px; top:23px; text-align:right; display:flex; flex-direction:column; color:#b4a9ab; font-family:monospace; font-size:9px; } +.map-telemetry b { color:var(--red); font-size:13px; margin:3px 0; } + +.map-legend { + position:absolute; z-index:500; left:24px; bottom:52px; + display:flex; gap:18px; color:#b8adaf; font-size:8px; font-weight:800; letter-spacing:1px; +} +.map-legend i { display:inline-block; width:7px; height:7px; margin-right:5px; transform:rotate(45deg); } +.legend-a { background:var(--cyan); box-shadow:0 0 7px var(--cyan); } +.legend-b { background:var(--yellow); box-shadow:0 0 7px var(--yellow); } +.legend-poi { border:1px solid var(--red); } + +.map-hint { + position:absolute; z-index:500; left:24px; bottom:17px; + color:#d6ccce; font-size:10px; letter-spacing:1px; display:flex; align-items:center; gap:8px; +} +.hint-key { background:var(--red); color:#fff; padding:3px 7px; font-weight:900; } + +.booking-panel { + position:absolute; right:0; top:0; bottom:0; width:420px; + background:rgba(13,13,16,.98); + border-left:2px solid var(--yellow); + padding:22px 24px 45px; + overflow-y:auto; + z-index:600; +} +.booking-panel::before { content:""; position:fixed; top:76px; right:0; width:420px; height:4px; background:var(--red); z-index:2; } +.panel-stripe { height:6px; margin:-2px 0 17px; background:repeating-linear-gradient(90deg,var(--yellow) 0 18px,transparent 18px 23px); } +.panel-head { display:flex; justify-content:space-between; align-items:flex-start; padding-bottom:16px; border-bottom:1px solid var(--line); } +.panel-head h1 { font-size:30px; letter-spacing:1px; margin-top:4px; } +.panel-code { font:10px monospace; color:var(--yellow); border:1px solid var(--yellow); padding:5px; } + +.route-points { padding:18px 0; border-bottom:1px solid var(--line); } +.route-point { display:grid; grid-template-columns:34px 1fr; align-items:center; gap:10px; } +.point-symbol { width:26px; height:26px; display:grid; place-items:center; font-size:12px; font-weight:900; background:var(--cyan); color:#071012; clip-path:polygon(0 0,75% 0,100% 25%,100% 100%,25% 100%,0 75%); } +.route-point-b .point-symbol { background:var(--yellow); } +.route-point small { display:block; color:var(--muted); font-size:8px; letter-spacing:1.5px; } +.route-point strong { display:block; margin-top:3px; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.route-point strong.is-set { color:#fff; } +.route-connector { height:22px; margin-left:12px; border-left:1px dashed #555; display:flex; flex-direction:column; justify-content:space-around; } +.route-connector i { width:3px; height:3px; margin-left:-2px; background:#666; } + +.empty-panel { padding:46px 10px; text-align:center; } +.empty-panel strong { display:block; margin-top:18px; font-size:13px; letter-spacing:2px; color:var(--yellow); } +.empty-panel p { color:var(--muted); font-size:11px; margin-top:7px; } +.scanner-icon { width:52px; height:52px; margin:auto; border:1px solid var(--red); transform:rotate(45deg); position:relative; animation:pulse 1.7s infinite; } +.scanner-icon i { position:absolute; inset:14px; background:var(--red); } +.progress-line { width:180px; height:2px; background:#303036; margin:24px auto 0; overflow:hidden; } +.progress-line span { display:block; width:40%; height:100%; background:var(--red); animation:scan 1.5s infinite; } +@keyframes pulse { 50% { box-shadow:0 0 20px rgba(255,42,61,.5); } } +@keyframes scan { from{transform:translateX(-120%)} to{transform:translateX(350%)} } + +.estimate-loading { padding:25px 0; color:var(--yellow); font-size:10px; letter-spacing:2px; } +.estimate-loading i { display:block; height:3px; margin-top:10px; background:linear-gradient(90deg,var(--yellow) 0 35%,#313137 35%); animation:loadbar .8s infinite alternate; } +@keyframes loadbar { to { background-size:270% 100%; } } + +.route-summary { padding:15px 0; color:#fff; font-size:13px; font-weight:800; border-bottom:1px solid var(--line); } +.tariff-title { display:flex; justify-content:space-between; align-items:end; margin:17px 0 8px; } +.tariff-title span { font-size:11px; font-weight:900; letter-spacing:1px; } +.tariff-title small { color:var(--muted); font-size:7px; letter-spacing:1px; } +.class-cards { display:flex; flex-direction:column; gap:5px; margin-bottom:17px; } +.class-card { + display:grid; grid-template-columns:45px 1fr auto; grid-template-rows:auto auto; + min-height:58px; padding:9px 12px 9px 0; cursor:pointer; + border:1px solid #34343b; border-left:4px solid #34343b; background:#17171c; + transition:.12s; + clip-path:polygon(0 0,calc(100% - 9px) 0,100% 9px,100% 100%,0 100%); +} +.class-card::before { content:"◆"; grid-row:1/3; display:grid; place-items:center; color:#67676f; font-size:16px; } +.class-card:hover { border-color:var(--yellow); } +.class-card.selected { background:var(--yellow); color:var(--ink); border-color:var(--yellow); } +.class-card.selected::before { color:var(--ink); } +.class-name { font-size:13px; font-weight:900; text-transform:uppercase; } +.class-meta { grid-column:2; font-size:9px; color:var(--muted); } +.class-card.selected .class-meta { color:#5b5700; } +.class-price { grid-row:1/3; grid-column:3; align-self:center; font-size:15px; font-weight:900; } + +.form-group { margin-bottom:16px; } +.form-group label { display:flex; justify-content:space-between; margin-bottom:7px; font-size:9px; font-weight:900; letter-spacing:1.5px; color:#b7b7bd; } +.form-group label small { color:var(--red); } +.form-group input, .form-group textarea { + width:100%; border:1px solid #43434b; border-bottom-color:#777; + border-radius:0; background:#0c0c0f; color:#fff; padding:11px 12px; + outline:none; font-family:monospace; font-size:12px; +} +.form-group input:focus, .form-group textarea:focus { border-color:var(--yellow); box-shadow:inset 3px 0 var(--yellow); } +.form-group textarea { resize:vertical; min-height:72px; } + +.btn { border:0; cursor:pointer; padding:10px 16px; font-size:10px; font-weight:900; letter-spacing:1.2px; clip-path:var(--cut); transition:.12s; } +.btn:hover { filter:brightness(1.15); } +.btn-primary { background:var(--yellow); color:var(--ink); } +.btn-ghost { background:#27272d; color:#fff; border:1px solid #555; } + +.btn-outline { background:transparent; color:var(--yellow); border:1px solid var(--yellow); } +.btn-small { padding:7px 10px; font-size:8px; } +.btn-big { width:100%; min-height:46px; display:flex; justify-content:space-between; align-items:center; } +.btn-big b { font-size:8px; border:1px solid currentColor; padding:3px 5px; } +.btn:disabled { opacity:.28; cursor:not-allowed; filter:none; } + +.success-mark { color:var(--yellow); border:1px solid var(--yellow); padding:12px; margin:18px 0; font-weight:900; letter-spacing:2px; text-align:center; } +.booked-card { padding:14px; margin-bottom:12px; border-left:3px solid var(--cyan); background:#17171c; } +.booked-id { color:var(--cyan); font-size:18px; font-weight:900; } +.booked-route { margin:8px 0; font-weight:800; } +.booked-meta { color:var(--yellow); font-size:11px; } +.booked-driver { margin-top:12px; font-size:10px; color:#aaa; } +.dim { color:var(--muted); font-size:9px; margin-top:8px; } +.mono { font-family:monospace; word-break:break-all; } +.panel-footer { position:absolute; left:24px; right:24px; bottom:12px; display:flex; justify-content:space-between; color:#54545b; font-size:7px; letter-spacing:1px; } + +.nc-poi-wrap, .nc-pin-wrap { position:relative; } +.nc-poi { position:absolute; left:-5px; top:-5px; width:10px; height:10px; border:2px solid var(--red); transform:rotate(45deg); box-shadow:0 0 8px var(--red); cursor:pointer; background:#170509; } +.nc-poi-wrap:hover .nc-poi { background:var(--red); } +.nc-poi-label { position:absolute; left:10px; top:-5px; white-space:nowrap; color:#ff7a87; font-size:9px; font-weight:900; text-shadow:0 1px 3px #000; pointer-events:none; } +.nc-pin { position:absolute; left:-10px; top:-10px; width:20px; height:20px; border:3px solid var(--pin); transform:rotate(45deg); background:#0b0b0e; box-shadow:0 0 15px var(--pin); } +.nc-pin::after { content:""; position:absolute; inset:4px; background:var(--pin); } +.nc-pin-label { position:absolute; left:16px; top:-9px; min-width:20px; color:var(--pin); font-size:16px; font-weight:900; text-shadow:0 2px 4px #000; } +.nc-route { filter:drop-shadow(0 0 5px var(--cyan)); animation:routeDash 1s linear infinite; } +@keyframes routeDash { to { stroke-dashoffset:-22; } } + +.data-screen { min-height:calc(100vh - 104px); padding:36px 4vw; background:linear-gradient(135deg,#111116,#070708); } +.section-header { display:flex; align-items:end; justify-content:space-between; border-bottom:2px solid var(--yellow); padding-bottom:15px; margin-bottom:24px; } +.section-header h2 { font-size:32px; letter-spacing:1px; } +.trips-list { display:grid; grid-template-columns:repeat(auto-fill,minmax(290px,1fr)); gap:12px; } +.trip-card { padding:17px; background:#18181d; border:1px solid #35353c; border-left:4px solid var(--yellow); clip-path:var(--cut); } +.trip-card:hover { border-color:var(--yellow); } +.trip-header { display:flex; justify-content:space-between; align-items:center; padding-bottom:10px; margin-bottom:8px; border-bottom:1px solid #3b3b42; } +.trip-header h3 { color:var(--yellow); font:900 15px monospace; } +.trip-class { font-size:8px; color:var(--cyan); border:1px solid var(--cyan); padding:3px 5px; } +.trip-detail { display:flex; justify-content:space-between; gap:10px; padding:6px 0; color:#ccc; font-size:10px; border-bottom:1px solid #28282e; } +.trip-detail .label { color:var(--muted); } +.trip-actions { display:flex; gap:6px; margin-top:12px; } +.panel { position:relative; padding:22px; background:#17171c; border:1px solid #3a3a41; border-top:4px solid var(--yellow); } +.error-text { color:var(--red); } +.empty { padding:40px; text-align:center; color:var(--muted); border:1px dashed #444; } + +.modal { display:none; position:fixed; inset:0; z-index:3000; align-items:center; justify-content:center; background:rgba(0,0,0,.88); } +.modal-content { position:relative; width:min(430px,90vw); padding:28px; background:var(--panel); border:2px solid var(--yellow); clip-path:var(--cut); } +.modal-content h2 { font-size:27px; margin:5px 0 22px; } +#export-result { margin-top:6px; text-align:left; max-height:50vh; overflow:auto; } +.close { position:absolute; top:8px; right:13px; background:none; border:0; color:var(--yellow); font-size:27px; cursor:pointer; } +.modal-content .btn + .btn { margin-top:8px; } + +.notification { position:fixed; z-index:4000; right:18px; bottom:30px; max-width:420px; padding:13px 18px; background:var(--yellow); color:var(--ink); font-size:10px; font-weight:900; letter-spacing:1px; border-left:7px solid var(--red); clip-path:var(--cut); } +.notification.error { background:var(--red); color:#fff; } +.footer { height:28px; display:flex; align-items:center; justify-content:space-between; padding:0 18px; background:var(--yellow); color:var(--ink); font-size:7px; font-weight:900; letter-spacing:1px; } + +@media (max-width: 1050px) { + .topbar { grid-template-columns:230px 1fr auto; } + .network-state { display:none; } + .nav-btn { min-width:95px; } + .map-wrap { inset:0 350px 0 0; } + .booking-panel, .booking-panel::before { width:350px; } +} + +@media (max-width: 760px) { + .topbar { height:auto; min-height:66px; grid-template-columns:1fr auto; } + .brand { width:220px; } + .nav { grid-row:2; grid-column:1/3; height:45px; padding:0; background:var(--yellow); } + .nav-btn { flex:1; } + .auth { padding:0 8px; } + .map-screen { height:auto; min-height:0; } + .map-wrap { position:relative; inset:auto; height:58vh; min-height:420px; } + .booking-panel { position:relative; width:100%; min-height:500px; border-left:0; border-top:2px solid var(--yellow); } + .booking-panel::before { display:none; } + .map-title strong { font-size:23px; } + .map-telemetry, .map-legend { display:none; } + + .data-screen { padding:22px 14px; } + .footer { display:none; } +} diff --git a/delamain/frontend/vendor/leaflet.css b/delamain/frontend/vendor/leaflet.css new file mode 100755 index 0000000..9ade8dc --- /dev/null +++ b/delamain/frontend/vendor/leaflet.css @@ -0,0 +1,661 @@ +/* required styles */ + +.leaflet-pane, +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-tile-container, +.leaflet-pane > svg, +.leaflet-pane > canvas, +.leaflet-zoom-box, +.leaflet-image-layer, +.leaflet-layer { + position: absolute; + left: 0; + top: 0; + } +.leaflet-container { + overflow: hidden; + } +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + -webkit-user-drag: none; + } +/* Prevents IE11 from highlighting tiles in blue */ +.leaflet-tile::selection { + background: transparent; +} +/* Safari renders non-retina tile on retina better with this, but Chrome is worse */ +.leaflet-safari .leaflet-tile { + image-rendering: -webkit-optimize-contrast; + } +/* hack that prevents hw layers "stretching" when loading new tiles */ +.leaflet-safari .leaflet-tile-container { + width: 1600px; + height: 1600px; + -webkit-transform-origin: 0 0; + } +.leaflet-marker-icon, +.leaflet-marker-shadow { + display: block; + } +/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ +/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ +.leaflet-container .leaflet-overlay-pane svg { + max-width: none !important; + max-height: none !important; + } +.leaflet-container .leaflet-marker-pane img, +.leaflet-container .leaflet-shadow-pane img, +.leaflet-container .leaflet-tile-pane img, +.leaflet-container img.leaflet-image-layer, +.leaflet-container .leaflet-tile { + max-width: none !important; + max-height: none !important; + width: auto; + padding: 0; + } + +.leaflet-container img.leaflet-tile { + /* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */ + mix-blend-mode: plus-lighter; +} + +.leaflet-container.leaflet-touch-zoom { + -ms-touch-action: pan-x pan-y; + touch-action: pan-x pan-y; + } +.leaflet-container.leaflet-touch-drag { + -ms-touch-action: pinch-zoom; + /* Fallback for FF which doesn't support pinch-zoom */ + touch-action: none; + touch-action: pinch-zoom; +} +.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom { + -ms-touch-action: none; + touch-action: none; +} +.leaflet-container { + -webkit-tap-highlight-color: transparent; +} +.leaflet-container a { + -webkit-tap-highlight-color: rgba(51, 181, 229, 0.4); +} +.leaflet-tile { + filter: inherit; + visibility: hidden; + } +.leaflet-tile-loaded { + visibility: inherit; + } +.leaflet-zoom-box { + width: 0; + height: 0; + -moz-box-sizing: border-box; + box-sizing: border-box; + z-index: 800; + } +/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ +.leaflet-overlay-pane svg { + -moz-user-select: none; + } + +.leaflet-pane { z-index: 400; } + +.leaflet-tile-pane { z-index: 200; } +.leaflet-overlay-pane { z-index: 400; } +.leaflet-shadow-pane { z-index: 500; } +.leaflet-marker-pane { z-index: 600; } +.leaflet-tooltip-pane { z-index: 650; } +.leaflet-popup-pane { z-index: 700; } + +.leaflet-map-pane canvas { z-index: 100; } +.leaflet-map-pane svg { z-index: 200; } + +.leaflet-vml-shape { + width: 1px; + height: 1px; + } +.lvml { + behavior: url(#default#VML); + display: inline-block; + position: absolute; + } + + +/* control positioning */ + +.leaflet-control { + position: relative; + z-index: 800; + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } +.leaflet-top, +.leaflet-bottom { + position: absolute; + z-index: 1000; + pointer-events: none; + } +.leaflet-top { + top: 0; + } +.leaflet-right { + right: 0; + } +.leaflet-bottom { + bottom: 0; + } +.leaflet-left { + left: 0; + } +.leaflet-control { + float: left; + clear: both; + } +.leaflet-right .leaflet-control { + float: right; + } +.leaflet-top .leaflet-control { + margin-top: 10px; + } +.leaflet-bottom .leaflet-control { + margin-bottom: 10px; + } +.leaflet-left .leaflet-control { + margin-left: 10px; + } +.leaflet-right .leaflet-control { + margin-right: 10px; + } + + +/* zoom and fade animations */ + +.leaflet-fade-anim .leaflet-popup { + opacity: 0; + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; + } +.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { + opacity: 1; + } +.leaflet-zoom-animated { + -webkit-transform-origin: 0 0; + -ms-transform-origin: 0 0; + transform-origin: 0 0; + } +svg.leaflet-zoom-animated { + will-change: transform; +} + +.leaflet-zoom-anim .leaflet-zoom-animated { + -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); + -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); + transition: transform 0.25s cubic-bezier(0,0,0.25,1); + } +.leaflet-zoom-anim .leaflet-tile, +.leaflet-pan-anim .leaflet-tile { + -webkit-transition: none; + -moz-transition: none; + transition: none; + } + +.leaflet-zoom-anim .leaflet-zoom-hide { + visibility: hidden; + } + + +/* cursors */ + +.leaflet-interactive { + cursor: pointer; + } +.leaflet-grab { + cursor: -webkit-grab; + cursor: -moz-grab; + cursor: grab; + } +.leaflet-crosshair, +.leaflet-crosshair .leaflet-interactive { + cursor: crosshair; + } +.leaflet-popup-pane, +.leaflet-control { + cursor: auto; + } +.leaflet-dragging .leaflet-grab, +.leaflet-dragging .leaflet-grab .leaflet-interactive, +.leaflet-dragging .leaflet-marker-draggable { + cursor: move; + cursor: -webkit-grabbing; + cursor: -moz-grabbing; + cursor: grabbing; + } + +/* marker & overlays interactivity */ +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-image-layer, +.leaflet-pane > svg path, +.leaflet-tile-container { + pointer-events: none; + } + +.leaflet-marker-icon.leaflet-interactive, +.leaflet-image-layer.leaflet-interactive, +.leaflet-pane > svg path.leaflet-interactive, +svg.leaflet-image-layer.leaflet-interactive path { + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } + +/* visual tweaks */ + +.leaflet-container { + background: #ddd; + outline-offset: 1px; + } +.leaflet-container a { + color: #0078A8; + } +.leaflet-zoom-box { + border: 2px dotted #38f; + background: rgba(255,255,255,0.5); + } + + +/* general typography */ +.leaflet-container { + font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; + font-size: 12px; + font-size: 0.75rem; + line-height: 1.5; + } + + +/* general toolbar styles */ + +.leaflet-bar { + box-shadow: 0 1px 5px rgba(0,0,0,0.65); + border-radius: 4px; + } +.leaflet-bar a { + background-color: #fff; + border-bottom: 1px solid #ccc; + width: 26px; + height: 26px; + line-height: 26px; + display: block; + text-align: center; + text-decoration: none; + color: black; + } +.leaflet-bar a, +.leaflet-control-layers-toggle { + background-position: 50% 50%; + background-repeat: no-repeat; + display: block; + } +.leaflet-bar a:hover, +.leaflet-bar a:focus { + background-color: #f4f4f4; + } +.leaflet-bar a:first-child { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + } +.leaflet-bar a:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom: none; + } +.leaflet-bar a.leaflet-disabled { + cursor: default; + background-color: #f4f4f4; + color: #bbb; + } + +.leaflet-touch .leaflet-bar a { + width: 30px; + height: 30px; + line-height: 30px; + } +.leaflet-touch .leaflet-bar a:first-child { + border-top-left-radius: 2px; + border-top-right-radius: 2px; + } +.leaflet-touch .leaflet-bar a:last-child { + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; + } + +/* zoom control */ + +.leaflet-control-zoom-in, +.leaflet-control-zoom-out { + font: bold 18px 'Lucida Console', Monaco, monospace; + text-indent: 1px; + } + +.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out { + font-size: 22px; + } + + +/* layers control */ + +.leaflet-control-layers { + box-shadow: 0 1px 5px rgba(0,0,0,0.4); + background: #fff; + border-radius: 5px; + } +.leaflet-control-layers-toggle { + background-image: url(images/layers.png); + width: 36px; + height: 36px; + } +.leaflet-retina .leaflet-control-layers-toggle { + background-image: url(images/layers-2x.png); + background-size: 26px 26px; + } +.leaflet-touch .leaflet-control-layers-toggle { + width: 44px; + height: 44px; + } +.leaflet-control-layers .leaflet-control-layers-list, +.leaflet-control-layers-expanded .leaflet-control-layers-toggle { + display: none; + } +.leaflet-control-layers-expanded .leaflet-control-layers-list { + display: block; + position: relative; + } +.leaflet-control-layers-expanded { + padding: 6px 10px 6px 6px; + color: #333; + background: #fff; + } +.leaflet-control-layers-scrollbar { + overflow-y: scroll; + overflow-x: hidden; + padding-right: 5px; + } +.leaflet-control-layers-selector { + margin-top: 2px; + position: relative; + top: 1px; + } +.leaflet-control-layers label { + display: block; + font-size: 13px; + font-size: 1.08333em; + } +.leaflet-control-layers-separator { + height: 0; + border-top: 1px solid #ddd; + margin: 5px -10px 5px -6px; + } + +/* Default icon URLs */ +.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */ + background-image: url(images/marker-icon.png); + } + + +/* attribution and scale controls */ + +.leaflet-container .leaflet-control-attribution { + background: #fff; + background: rgba(255, 255, 255, 0.8); + margin: 0; + } +.leaflet-control-attribution, +.leaflet-control-scale-line { + padding: 0 5px; + color: #333; + line-height: 1.4; + } +.leaflet-control-attribution a { + text-decoration: none; + } +.leaflet-control-attribution a:hover, +.leaflet-control-attribution a:focus { + text-decoration: underline; + } +.leaflet-attribution-flag { + display: inline !important; + vertical-align: baseline !important; + width: 1em; + height: 0.6669em; + } +.leaflet-left .leaflet-control-scale { + margin-left: 5px; + } +.leaflet-bottom .leaflet-control-scale { + margin-bottom: 5px; + } +.leaflet-control-scale-line { + border: 2px solid #777; + border-top: none; + line-height: 1.1; + padding: 2px 5px 1px; + white-space: nowrap; + -moz-box-sizing: border-box; + box-sizing: border-box; + background: rgba(255, 255, 255, 0.8); + text-shadow: 1px 1px #fff; + } +.leaflet-control-scale-line:not(:first-child) { + border-top: 2px solid #777; + border-bottom: none; + margin-top: -2px; + } +.leaflet-control-scale-line:not(:first-child):not(:last-child) { + border-bottom: 2px solid #777; + } + +.leaflet-touch .leaflet-control-attribution, +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + box-shadow: none; + } +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + border: 2px solid rgba(0,0,0,0.2); + background-clip: padding-box; + } + + +/* popup */ + +.leaflet-popup { + position: absolute; + text-align: center; + margin-bottom: 20px; + } +.leaflet-popup-content-wrapper { + padding: 1px; + text-align: left; + border-radius: 12px; + } +.leaflet-popup-content { + margin: 13px 24px 13px 20px; + line-height: 1.3; + font-size: 13px; + font-size: 1.08333em; + min-height: 1px; + } +.leaflet-popup-content p { + margin: 17px 0; + margin: 1.3em 0; + } +.leaflet-popup-tip-container { + width: 40px; + height: 20px; + position: absolute; + left: 50%; + margin-top: -1px; + margin-left: -20px; + overflow: hidden; + pointer-events: none; + } +.leaflet-popup-tip { + width: 17px; + height: 17px; + padding: 1px; + + margin: -10px auto 0; + pointer-events: auto; + + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + transform: rotate(45deg); + } +.leaflet-popup-content-wrapper, +.leaflet-popup-tip { + background: white; + color: #333; + box-shadow: 0 3px 14px rgba(0,0,0,0.4); + } +.leaflet-container a.leaflet-popup-close-button { + position: absolute; + top: 0; + right: 0; + border: none; + text-align: center; + width: 24px; + height: 24px; + font: 16px/24px Tahoma, Verdana, sans-serif; + color: #757575; + text-decoration: none; + background: transparent; + } +.leaflet-container a.leaflet-popup-close-button:hover, +.leaflet-container a.leaflet-popup-close-button:focus { + color: #585858; + } +.leaflet-popup-scrolled { + overflow: auto; + } + +.leaflet-oldie .leaflet-popup-content-wrapper { + -ms-zoom: 1; + } +.leaflet-oldie .leaflet-popup-tip { + width: 24px; + margin: 0 auto; + + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; + filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); + } + +.leaflet-oldie .leaflet-control-zoom, +.leaflet-oldie .leaflet-control-layers, +.leaflet-oldie .leaflet-popup-content-wrapper, +.leaflet-oldie .leaflet-popup-tip { + border: 1px solid #999; + } + + +/* div icon */ + +.leaflet-div-icon { + background: #fff; + border: 1px solid #666; + } + + +/* Tooltip */ +/* Base styles for the element that has a tooltip */ +.leaflet-tooltip { + position: absolute; + padding: 6px; + background-color: #fff; + border: 1px solid #fff; + border-radius: 3px; + color: #222; + white-space: nowrap; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + pointer-events: none; + box-shadow: 0 1px 3px rgba(0,0,0,0.4); + } +.leaflet-tooltip.leaflet-interactive { + cursor: pointer; + pointer-events: auto; + } +.leaflet-tooltip-top:before, +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + position: absolute; + pointer-events: none; + border: 6px solid transparent; + background: transparent; + content: ""; + } + +/* Directions */ + +.leaflet-tooltip-bottom { + margin-top: 6px; +} +.leaflet-tooltip-top { + margin-top: -6px; +} +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-top:before { + left: 50%; + margin-left: -6px; + } +.leaflet-tooltip-top:before { + bottom: 0; + margin-bottom: -12px; + border-top-color: #fff; + } +.leaflet-tooltip-bottom:before { + top: 0; + margin-top: -12px; + margin-left: -6px; + border-bottom-color: #fff; + } +.leaflet-tooltip-left { + margin-left: -6px; +} +.leaflet-tooltip-right { + margin-left: 6px; +} +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + top: 50%; + margin-top: -6px; + } +.leaflet-tooltip-left:before { + right: 0; + margin-right: -12px; + border-left-color: #fff; + } +.leaflet-tooltip-right:before { + left: 0; + margin-left: -12px; + border-right-color: #fff; + } + +/* Printing */ + +@media print { + /* Prevent printers from removing background-images of controls. */ + .leaflet-control { + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + } + } diff --git a/delamain/frontend/vendor/leaflet.js b/delamain/frontend/vendor/leaflet.js new file mode 100755 index 0000000..a3bf693 --- /dev/null +++ b/delamain/frontend/vendor/leaflet.js @@ -0,0 +1,6 @@ +/* @preserve + * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com + * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).leaflet={})}(this,function(t){"use strict";function l(t){for(var e,i,n=1,o=arguments.length;n=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=_(t);var e=this.min,i=this.max,n=t.min,t=t.max,o=t.x>=e.x&&n.x<=i.x,t=t.y>=e.y&&n.y<=i.y;return o&&t},overlaps:function(t){t=_(t);var e=this.min,i=this.max,n=t.min,t=t.max,o=t.x>e.x&&n.xe.y&&n.y=n.lat&&i.lat<=o.lat&&e.lng>=n.lng&&i.lng<=o.lng},intersects:function(t){t=g(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),t=t.getNorthEast(),o=t.lat>=e.lat&&n.lat<=i.lat,t=t.lng>=e.lng&&n.lng<=i.lng;return o&&t},overlaps:function(t){t=g(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),t=t.getNorthEast(),o=t.lat>e.lat&&n.late.lng&&n.lng","http://www.w3.org/2000/svg"===(Wt.firstChild&&Wt.firstChild.namespaceURI));function y(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var b={ie:pt,ielt9:mt,edge:n,webkit:ft,android:gt,android23:vt,androidStock:yt,opera:xt,chrome:wt,gecko:bt,safari:Pt,phantom:Lt,opera12:o,win:Tt,ie3d:Mt,webkit3d:zt,gecko3d:_t,any3d:Ct,mobile:Zt,mobileWebkit:St,mobileWebkit3d:Et,msPointer:kt,pointer:Ot,touch:Bt,touchNative:At,mobileOpera:It,mobileGecko:Rt,retina:Nt,passiveEvents:Dt,canvas:jt,svg:Ht,vml:!Ht&&function(){try{var t=document.createElement("div"),e=(t.innerHTML='',t.firstChild);return e.style.behavior="url(#default#VML)",e&&"object"==typeof e.adj}catch(t){return!1}}(),inlineSvg:Wt,mac:0===navigator.platform.indexOf("Mac"),linux:0===navigator.platform.indexOf("Linux")},Ft=b.msPointer?"MSPointerDown":"pointerdown",Ut=b.msPointer?"MSPointerMove":"pointermove",Vt=b.msPointer?"MSPointerUp":"pointerup",qt=b.msPointer?"MSPointerCancel":"pointercancel",Gt={touchstart:Ft,touchmove:Ut,touchend:Vt,touchcancel:qt},Kt={touchstart:function(t,e){e.MSPOINTER_TYPE_TOUCH&&e.pointerType===e.MSPOINTER_TYPE_TOUCH&&O(e);ee(t,e)},touchmove:ee,touchend:ee,touchcancel:ee},Yt={},Xt=!1;function Jt(t,e,i){return"touchstart"!==e||Xt||(document.addEventListener(Ft,$t,!0),document.addEventListener(Ut,Qt,!0),document.addEventListener(Vt,te,!0),document.addEventListener(qt,te,!0),Xt=!0),Kt[e]?(i=Kt[e].bind(this,i),t.addEventListener(Gt[e],i,!1),i):(console.warn("wrong event specified:",e),u)}function $t(t){Yt[t.pointerId]=t}function Qt(t){Yt[t.pointerId]&&(Yt[t.pointerId]=t)}function te(t){delete Yt[t.pointerId]}function ee(t,e){if(e.pointerType!==(e.MSPOINTER_TYPE_MOUSE||"mouse")){for(var i in e.touches=[],Yt)e.touches.push(Yt[i]);e.changedTouches=[e],t(e)}}var ie=200;function ne(t,i){t.addEventListener("dblclick",i);var n,o=0;function e(t){var e;1!==t.detail?n=t.detail:"mouse"===t.pointerType||t.sourceCapabilities&&!t.sourceCapabilities.firesTouchEvents||((e=Ne(t)).some(function(t){return t instanceof HTMLLabelElement&&t.attributes.for})&&!e.some(function(t){return t instanceof HTMLInputElement||t instanceof HTMLSelectElement})||((e=Date.now())-o<=ie?2===++n&&i(function(t){var e,i,n={};for(i in t)e=t[i],n[i]=e&&e.bind?e.bind(t):e;return(t=n).type="dblclick",n.detail=2,n.isTrusted=!1,n._simulated=!0,n}(t)):n=1,o=e))}return t.addEventListener("click",e),{dblclick:i,simDblclick:e}}var oe,se,re,ae,he,le,ue=we(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ce=we(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),de="webkitTransition"===ce||"OTransition"===ce?ce+"End":"transitionend";function _e(t){return"string"==typeof t?document.getElementById(t):t}function pe(t,e){var i=t.style[e]||t.currentStyle&&t.currentStyle[e];return"auto"===(i=i&&"auto"!==i||!document.defaultView?i:(t=document.defaultView.getComputedStyle(t,null))?t[e]:null)?null:i}function P(t,e,i){t=document.createElement(t);return t.className=e||"",i&&i.appendChild(t),t}function T(t){var e=t.parentNode;e&&e.removeChild(t)}function me(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function fe(t){var e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)}function ge(t){var e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)}function ve(t,e){return void 0!==t.classList?t.classList.contains(e):0<(t=xe(t)).length&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(t)}function M(t,e){var i;if(void 0!==t.classList)for(var n=F(e),o=0,s=n.length;othis.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,e){this._enforcingBounds=!0;var i=this.getCenter(),t=this._limitCenter(i,this._zoom,g(t));return i.equals(t)||this.panTo(t,e),this._enforcingBounds=!1,this},panInside:function(t,e){var i=m((e=e||{}).paddingTopLeft||e.padding||[0,0]),n=m(e.paddingBottomRight||e.padding||[0,0]),o=this.project(this.getCenter()),t=this.project(t),s=this.getPixelBounds(),i=_([s.min.add(i),s.max.subtract(n)]),s=i.getSize();return i.contains(t)||(this._enforcingBounds=!0,n=t.subtract(i.getCenter()),i=i.extend(t).getSize().subtract(s),o.x+=n.x<0?-i.x:i.x,o.y+=n.y<0?-i.y:i.y,this.panTo(this.unproject(o),e),this._enforcingBounds=!1),this},invalidateSize:function(t){if(!this._loaded)return this;t=l({animate:!1,pan:!0},!0===t?{animate:!0}:t);var e=this.getSize(),i=(this._sizeChanged=!0,this._lastCenter=null,this.getSize()),n=e.divideBy(2).round(),o=i.divideBy(2).round(),n=n.subtract(o);return n.x||n.y?(t.animate&&t.pan?this.panBy(n):(t.pan&&this._rawPanBy(n),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(a(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:e,newSize:i})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){var e,i;return t=this._locateOptions=l({timeout:1e4,watch:!1},t),"geolocation"in navigator?(e=a(this._handleGeolocationResponse,this),i=a(this._handleGeolocationError,this),t.watch?this._locationWatchId=navigator.geolocation.watchPosition(e,i,t):navigator.geolocation.getCurrentPosition(e,i,t)):this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var e;this._container._leaflet_id&&(e=t.code,t=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout"),this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+t+"."}))},_handleGeolocationResponse:function(t){if(this._container._leaflet_id){var e,i,n=new v(t.coords.latitude,t.coords.longitude),o=n.toBounds(2*t.coords.accuracy),s=this._locateOptions,r=(s.setView&&(e=this.getBoundsZoom(o),this.setView(n,s.maxZoom?Math.min(e,s.maxZoom):e)),{latlng:n,bounds:o,timestamp:t.timestamp});for(i in t.coords)"number"==typeof t.coords[i]&&(r[i]=t.coords[i]);this.fire("locationfound",r)}},addHandler:function(t,e){return e&&(e=this[t]=new e(this),this._handlers.push(e),this.options[t]&&e.enable()),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}for(var t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),T(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(r(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)T(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,e){e=P("div","leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),e||this._mapPane);return t&&(this._panes[t]=e),e},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new s(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=g(t),i=m(i||[0,0]);var n=this.getZoom()||0,o=this.getMinZoom(),s=this.getMaxZoom(),r=t.getNorthWest(),t=t.getSouthEast(),i=this.getSize().subtract(i),t=_(this.project(t,n),this.project(r,n)).getSize(),r=b.any3d?this.options.zoomSnap:1,a=i.x/t.x,i=i.y/t.y,t=e?Math.max(a,i):Math.min(a,i),n=this.getScaleZoom(t,n);return r&&(n=Math.round(n/(r/100))*(r/100),n=e?Math.ceil(n/r)*r:Math.floor(n/r)*r),Math.max(o,Math.min(s,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new p(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,e){t=this._getTopLeftPoint(t,e);return new f(t,t.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,e){var i=this.options.crs;return e=void 0===e?this._zoom:e,i.scale(t)/i.scale(e)},getScaleZoom:function(t,e){var i=this.options.crs,t=(e=void 0===e?this._zoom:e,i.zoom(t*i.scale(e)));return isNaN(t)?1/0:t},project:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.latLngToPoint(w(t),e)},unproject:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.pointToLatLng(m(t),e)},layerPointToLatLng:function(t){t=m(t).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(t){return this.project(w(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(w(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(g(t))},distance:function(t,e){return this.options.crs.distance(w(t),w(e))},containerPointToLayerPoint:function(t){return m(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return m(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){t=this.containerPointToLayerPoint(m(t));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(w(t)))},mouseEventToContainerPoint:function(t){return De(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){t=this._container=_e(t);if(!t)throw new Error("Map container not found.");if(t._leaflet_id)throw new Error("Map container is already initialized.");S(t,"scroll",this._onScroll,this),this._containerId=h(t)},_initLayout:function(){var t=this._container,e=(this._fadeAnimated=this.options.fadeAnimation&&b.any3d,M(t,"leaflet-container"+(b.touch?" leaflet-touch":"")+(b.retina?" leaflet-retina":"")+(b.ielt9?" leaflet-oldie":"")+(b.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":"")),pe(t,"position"));"absolute"!==e&&"relative"!==e&&"fixed"!==e&&"sticky"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Z(this._mapPane,new p(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(M(t.markerPane,"leaflet-zoom-hide"),M(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,e,i){Z(this._mapPane,new p(0,0));var n=!this._loaded,o=(this._loaded=!0,e=this._limitZoom(e),this.fire("viewprereset"),this._zoom!==e);this._moveStart(o,i)._move(t,e)._moveEnd(o),this.fire("viewreset"),n&&this.fire("load")},_moveStart:function(t,e){return t&&this.fire("zoomstart"),e||this.fire("movestart"),this},_move:function(t,e,i,n){void 0===e&&(e=this._zoom);var o=this._zoom!==e;return this._zoom=e,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),n?i&&i.pinch&&this.fire("zoom",i):((o||i&&i.pinch)&&this.fire("zoom",i),this.fire("move",i)),this},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return r(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){Z(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={};var e=t?k:S;e((this._targets[h(this._container)]=this)._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&e(window,"resize",this._onResize,this),b.any3d&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){r(this._resizeRequest),this._resizeRequest=x(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,e){for(var i,n=[],o="mouseout"===e||"mouseover"===e,s=t.target||t.srcElement,r=!1;s;){if((i=this._targets[h(s)])&&("click"===e||"preclick"===e)&&this._draggableMoved(i)){r=!0;break}if(i&&i.listens(e,!0)){if(o&&!We(s,t))break;if(n.push(i),o)break}if(s===this._container)break;s=s.parentNode}return n=n.length||r||o||!this.listens(e,!0)?n:[this]},_isClickDisabled:function(t){for(;t&&t!==this._container;){if(t._leaflet_disable_click)return!0;t=t.parentNode}},_handleDOMEvent:function(t){var e,i=t.target||t.srcElement;!this._loaded||i._leaflet_disable_events||"click"===t.type&&this._isClickDisabled(i)||("mousedown"===(e=t.type)&&Me(i),this._fireDOMEvent(t,e))},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,e,i){"click"===t.type&&((a=l({},t)).type="preclick",this._fireDOMEvent(a,a.type,i));var n=this._findEventTargets(t,e);if(i){for(var o=[],s=0;sthis.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),n=this._getCenterOffset(t)._divideBy(1-1/n);if(!0!==i.animate&&!this.getSize().contains(n))return!1;x(function(){this._moveStart(!0,i.noMoveStart||!1)._animateZoom(t,e,!0)},this)}return!0},_animateZoom:function(t,e,i,n){this._mapPane&&(i&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=e,M(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:e,noUpdate:n}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(a(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&z(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Ue(t){return new B(t)}var B=et.extend({options:{position:"topright"},initialize:function(t){c(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),t=t._controlCorners[i];return M(e,"leaflet-control"),-1!==i.indexOf("bottom")?t.insertBefore(e,t.firstChild):t.appendChild(e),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(T(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0",e=document.createElement("div");return e.innerHTML=t,e.firstChild},_addItem:function(t){var e,i=document.createElement("label"),n=this._map.hasLayer(t.layer),n=(t.overlay?((e=document.createElement("input")).type="checkbox",e.className="leaflet-control-layers-selector",e.defaultChecked=n):e=this._createRadioElement("leaflet-base-layers_"+h(this),n),this._layerControlInputs.push(e),e.layerId=h(t.layer),S(e,"click",this._onInputClick,this),document.createElement("span")),o=(n.innerHTML=" "+t.name,document.createElement("span"));return i.appendChild(o),o.appendChild(e),o.appendChild(n),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(i),this._checkDisabledLayers(),i},_onInputClick:function(){if(!this._preventClick){var t,e,i=this._layerControlInputs,n=[],o=[];this._handlingClick=!0;for(var s=i.length-1;0<=s;s--)t=i[s],e=this._getLayer(t.layerId).layer,t.checked?n.push(e):t.checked||o.push(e);for(s=0;se.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var t=this._section,e=(this._preventClick=!0,S(t,"click",O),this.expand(),this);setTimeout(function(){k(t,"click",O),e._preventClick=!1})}})),qe=B.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=P("div",e+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,e+"-in",i,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,e+"-out",i,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,e,i,n,o){i=P("a",i,n);return i.innerHTML=t,i.href="#",i.title=e,i.setAttribute("role","button"),i.setAttribute("aria-label",e),Ie(i),S(i,"click",Re),S(i,"click",o,this),S(i,"click",this._refocusOnMap,this),i},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";z(this._zoomInButton,e),z(this._zoomOutButton,e),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),!this._disabled&&t._zoom!==t.getMinZoom()||(M(this._zoomOutButton,e),this._zoomOutButton.setAttribute("aria-disabled","true")),!this._disabled&&t._zoom!==t.getMaxZoom()||(M(this._zoomInButton,e),this._zoomInButton.setAttribute("aria-disabled","true"))}}),Ge=(A.mergeOptions({zoomControl:!0}),A.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new qe,this.addControl(this.zoomControl))}),B.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var e="leaflet-control-scale",i=P("div",e),n=this.options;return this._addScales(n,e+"-line",i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=P("div",e,i)),t.imperial&&(this._iScale=P("div",e,i))},_update:function(){var t=this._map,e=t.getSize().y/2,t=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(t)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var e=this._getRoundNum(t);this._updateScale(this._mScale,e<1e3?e+" m":e/1e3+" km",e/t)},_updateImperial:function(t){var e,i,t=3.2808399*t;5280'+(b.inlineSvg?' ':"")+"Leaflet"},initialize:function(t){c(this,t),this._attributions={}},onAdd:function(t){for(var e in(t.attributionControl=this)._container=P("div","leaflet-control-attribution"),Ie(this._container),t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return this._update(),t.on("layeradd",this._addAttribution,this),this._container},onRemove:function(t){t.off("layeradd",this._addAttribution,this)},_addAttribution:function(t){t.layer.getAttribution&&(this.addAttribution(t.layer.getAttribution()),t.layer.once("remove",function(){this.removeAttribution(t.layer.getAttribution())},this))},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t,e=[];for(t in this._attributions)this._attributions[t]&&e.push(t);var i=[];this.options.prefix&&i.push(this.options.prefix),e.length&&i.push(e.join(", ")),this._container.innerHTML=i.join(' ')}}}),n=(A.mergeOptions({attributionControl:!0}),A.addInitHook(function(){this.options.attributionControl&&(new Ke).addTo(this)}),B.Layers=Ve,B.Zoom=qe,B.Scale=Ge,B.Attribution=Ke,Ue.layers=function(t,e,i){return new Ve(t,e,i)},Ue.zoom=function(t){return new qe(t)},Ue.scale=function(t){return new Ge(t)},Ue.attribution=function(t){return new Ke(t)},et.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}})),ft=(n.addTo=function(t,e){return t.addHandler(e,this),this},{Events:e}),Ye=b.touch?"touchstart mousedown":"mousedown",Xe=it.extend({options:{clickTolerance:3},initialize:function(t,e,i,n){c(this,n),this._element=t,this._dragStartTarget=e||t,this._preventOutline=i},enable:function(){this._enabled||(S(this._dragStartTarget,Ye,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Xe._dragging===this&&this.finishDrag(!0),k(this._dragStartTarget,Ye,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){var e,i;this._enabled&&(this._moved=!1,ve(this._element,"leaflet-zoom-anim")||(t.touches&&1!==t.touches.length?Xe._dragging===this&&this.finishDrag():Xe._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((Xe._dragging=this)._preventOutline&&Me(this._element),Le(),re(),this._moving||(this.fire("down"),i=t.touches?t.touches[0]:t,e=Ce(this._element),this._startPoint=new p(i.clientX,i.clientY),this._startPos=Pe(this._element),this._parentScale=Ze(e),i="mousedown"===t.type,S(document,i?"mousemove":"touchmove",this._onMove,this),S(document,i?"mouseup":"touchend touchcancel",this._onUp,this)))))},_onMove:function(t){var e;this._enabled&&(t.touches&&1e&&(i.push(t[n]),o=n);oe.max.x&&(i|=2),t.ye.max.y&&(i|=8),i}function ri(t,e,i,n){var o=e.x,e=e.y,s=i.x-o,r=i.y-e,a=s*s+r*r;return 0this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()t.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(l=!l);return l||yi.prototype._containsPoint.call(this,t,!0)}});var wi=ci.extend({initialize:function(t,e){c(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,o=d(t)?t:t.features;if(o){for(e=0,i=o.length;es.x&&(r=i.x+a-s.x+o.x),i.x-r-n.x<(a=0)&&(r=i.x-n.x),i.y+e+o.y>s.y&&(a=i.y+e-s.y+o.y),i.y-a-n.y<0&&(a=i.y-n.y),(r||a)&&(this.options.keepInView&&(this._autopanning=!0),t.fire("autopanstart").panBy([r,a]))))},_getAnchor:function(){return m(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}})),Ii=(A.mergeOptions({closePopupOnClick:!0}),A.include({openPopup:function(t,e,i){return this._initOverlay(Bi,t,e,i).openOn(this),this},closePopup:function(t){return(t=arguments.length?t:this._popup)&&t.close(),this}}),o.include({bindPopup:function(t,e){return this._popup=this._initOverlay(Bi,this._popup,t,e),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t){return this._popup&&(this instanceof ci||(this._popup._source=this),this._popup._prepareOpen(t||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var e;this._popup&&this._map&&(Re(t),e=t.layer||t.target,this._popup._source!==e||e instanceof fi?(this._popup._source=e,this.openPopup(t.latlng)):this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}}),Ai.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(t){Ai.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(t){Ai.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var t=Ai.prototype.getEvents.call(this);return this.options.permanent||(t.preclick=this.close),t},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=P("div",t),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+h(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var e,i=this._map,n=this._container,o=i.latLngToContainerPoint(i.getCenter()),i=i.layerPointToContainerPoint(t),s=this.options.direction,r=n.offsetWidth,a=n.offsetHeight,h=m(this.options.offset),l=this._getAnchor(),i="top"===s?(e=r/2,a):"bottom"===s?(e=r/2,0):(e="center"===s?r/2:"right"===s?0:"left"===s?r:i.xthis.options.maxZoom||nthis.options.maxZoom||void 0!==this.options.minZoom&&oi.max.x)||!e.wrapLat&&(t.yi.max.y))return!1}return!this.options.bounds||(e=this._tileCoordsToBounds(t),g(this.options.bounds).overlaps(e))},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),i=n.add(i);return[e.unproject(n,t.z),e.unproject(i,t.z)]},_tileCoordsToBounds:function(t){t=this._tileCoordsToNwSe(t),t=new s(t[0],t[1]);return t=this.options.noWrap?t:this._map.wrapLatLngBounds(t)},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var t=t.split(":"),e=new p(+t[0],+t[1]);return e.z=+t[2],e},_removeTile:function(t){var e=this._tiles[t];e&&(T(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){M(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=u,t.onmousemove=u,b.ielt9&&this.options.opacity<1&&C(t,this.options.opacity)},_addTile:function(t,e){var i=this._getTilePos(t),n=this._tileCoordsToKey(t),o=this.createTile(this._wrapCoords(t),a(this._tileReady,this,t));this._initTile(o),this.createTile.length<2&&x(a(this._tileReady,this,t,null,o)),Z(o,i),this._tiles[n]={el:o,coords:t,current:!0},e.appendChild(o),this.fire("tileloadstart",{tile:o,coords:t})},_tileReady:function(t,e,i){e&&this.fire("tileerror",{error:e,tile:i,coords:t});var n=this._tileCoordsToKey(t);(i=this._tiles[n])&&(i.loaded=+new Date,this._map._fadeAnimated?(C(i.el,0),r(this._fadeFrame),this._fadeFrame=x(this._updateOpacity,this)):(i.active=!0,this._pruneTiles()),e||(M(i.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:i.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),b.ielt9||!this._map._fadeAnimated?x(this._pruneTiles,this):setTimeout(a(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var e=new p(this._wrapX?H(t.x,this._wrapX):t.x,this._wrapY?H(t.y,this._wrapY):t.y);return e.z=t.z,e},_pxBoundsToTileRange:function(t){var e=this.getTileSize();return new f(t.min.unscaleBy(e).floor(),t.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var Di=Ni.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(t,e){this._url=t,(e=c(this,e)).detectRetina&&b.retina&&0')}}catch(t){}return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),zt={_initContainer:function(){this._container=P("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Wi.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=Vi("shape");M(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=Vi("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;T(e),t.removeInteractiveTarget(e),delete this._layers[h(t)]},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(e=e||(t._stroke=Vi("stroke")),o.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=d(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(o.removeChild(e),t._stroke=null),n.fill?(i=i||(t._fill=Vi("fill")),o.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(o.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){fe(t._container)},_bringToBack:function(t){ge(t._container)}},qi=b.vml?Vi:ct,Gi=Wi.extend({_initContainer:function(){this._container=qi("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=qi("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){T(this._container),k(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){var t,e,i;this._map._animatingZoom&&this._bounds||(Wi.prototype._update.call(this),e=(t=this._bounds).getSize(),i=this._container,this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,i.setAttribute("width",e.x),i.setAttribute("height",e.y)),Z(i,t.min),i.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update"))},_initPath:function(t){var e=t._path=qi("path");t.options.className&&M(e,t.options.className),t.options.interactive&&M(e,"leaflet-interactive"),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){T(t._path),t.removeInteractiveTarget(t._path),delete this._layers[h(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,t=t.options;e&&(t.stroke?(e.setAttribute("stroke",t.color),e.setAttribute("stroke-opacity",t.opacity),e.setAttribute("stroke-width",t.weight),e.setAttribute("stroke-linecap",t.lineCap),e.setAttribute("stroke-linejoin",t.lineJoin),t.dashArray?e.setAttribute("stroke-dasharray",t.dashArray):e.removeAttribute("stroke-dasharray"),t.dashOffset?e.setAttribute("stroke-dashoffset",t.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),t.fill?(e.setAttribute("fill",t.fillColor||t.color),e.setAttribute("fill-opacity",t.fillOpacity),e.setAttribute("fill-rule",t.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,dt(t._parts,e))},_updateCircle:function(t){var e=t._point,i=Math.max(Math.round(t._radius),1),n="a"+i+","+(Math.max(Math.round(t._radiusY),1)||i)+" 0 1,0 ",e=t._empty()?"M0 0":"M"+(e.x-i)+","+e.y+n+2*i+",0 "+n+2*-i+",0 ";this._setPath(t,e)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){fe(t._path)},_bringToBack:function(t){ge(t._path)}});function Ki(t){return b.svg||b.vml?new Gi(t):null}b.vml&&Gi.include(zt),A.include({getRenderer:function(t){t=(t=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer)||(this._renderer=this._createRenderer());return this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(t){var e;return"overlayPane"!==t&&void 0!==t&&(void 0===(e=this._paneRenderers[t])&&(e=this._createRenderer({pane:t}),this._paneRenderers[t]=e),e)},_createRenderer:function(t){return this.options.preferCanvas&&Ui(t)||Ki(t)}});var Yi=xi.extend({initialize:function(t,e){xi.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=g(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});Gi.create=qi,Gi.pointsToPath=dt,wi.geometryToLayer=bi,wi.coordsToLatLng=Li,wi.coordsToLatLngs=Ti,wi.latLngToCoords=Mi,wi.latLngsToCoords=zi,wi.getFeature=Ci,wi.asFeature=Zi,A.mergeOptions({boxZoom:!0});var _t=n.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){S(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){k(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){T(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),re(),Le(),this._startPoint=this._map.mouseEventToContainerPoint(t),S(document,{contextmenu:Re,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=P("div","leaflet-zoom-box",this._container),M(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var t=new f(this._point,this._startPoint),e=t.getSize();Z(this._box,t.min),this._box.style.width=e.x+"px",this._box.style.height=e.y+"px"},_finish:function(){this._moved&&(T(this._box),z(this._container,"leaflet-crosshair")),ae(),Te(),k(document,{contextmenu:Re,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){1!==t.which&&1!==t.button||(this._finish(),this._moved&&(this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(a(this._resetState,this),0),t=new s(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point)),this._map.fitBounds(t).fire("boxzoomend",{boxZoomBounds:t})))},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}}),Ct=(A.addInitHook("addHandler","boxZoom",_t),A.mergeOptions({doubleClickZoom:!0}),n.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom(),n=e.options.zoomDelta,i=t.originalEvent.shiftKey?i-n:i+n;"center"===e.options.doubleClickZoom?e.setZoom(i):e.setZoomAround(t.containerPoint,i)}})),Zt=(A.addInitHook("addHandler","doubleClickZoom",Ct),A.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0}),n.extend({addHooks:function(){var t;this._draggable||(t=this._map,this._draggable=new Xe(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))),M(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){z(this._map._container,"leaflet-grab"),z(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t,e=this._map;e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity?(t=g(this._map.options.maxBounds),this._offsetLimit=_(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))):this._offsetLimit=null,e.fire("movestart").fire("dragstart"),e.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){var e,i;this._map.options.inertia&&(e=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos,this._positions.push(i),this._times.push(e),this._prunePositions(e)),this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1e.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t))},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,n=(n+e+i)%t-e-i,t=Math.abs(o+i)e.getMaxZoom()&&1 /tmp/workspaces.txt + psql "${DATABASE_URL}" -t -A -c "SELECT filename FROM files WHERE created_at <= NOW() - INTERVAL '${RET_MIN} minutes'" > /tmp/old_files.txt + + if [ -d /etc/pam.d ]; then + find /etc/pam.d -maxdepth 1 -type f -name 'pamsave-*' -mmin "+${RET_MIN}" | while read -r stack; do + ws="${stack##*/pamsave-}" + if ! grep -qx "$ws" /tmp/workspaces.txt; then + rm -f "$stack" + fi + done + fi + + if [ -d /storage ]; then + find /storage -type f -mmin "+${RET_MIN}" | while read -r f; do + rel="${f#/storage/}" + if ! grep -Fx "$rel" /tmp/old_files.txt; then + rm -f "$f" + fi + done + find /storage -mindepth 1 -type d -empty -delete + fi + + : > /etc/pamsave/deployments.log 2>/dev/null || true + else + echo " DATABASE_URL not set, skipping cleanup" + fi + + echo "[$TIMESTAMP] Cleanup completed" + sleep "${CLEANER_INTERVAL:-60}" +done diff --git a/pamsave/docker/pamsave-web/Dockerfile b/pamsave/docker/pamsave-web/Dockerfile new file mode 100755 index 0000000..53d1187 --- /dev/null +++ b/pamsave/docker/pamsave-web/Dockerfile @@ -0,0 +1,45 @@ +FROM rust:1-bookworm AS builder + +RUN apt-get update && apt-get install -y libpam0g-dev +RUN rustup target add wasm32-unknown-unknown +RUN cargo install dioxus-cli --version ^0.7 --locked + +WORKDIR /app +COPY . . +RUN cd packages/pam && cargo build --release -p pam_pamsave -p pam_pamsave_authz +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/app/target \ + cd packages/web && dx build --release \ + && mkdir -p /out \ + && cp -r /app/target/dx/web/release/web/server /out/server \ + && cp -r /app/target/dx/web/release/web/public /out/public \ + && install -m 755 -t /out \ + /app/packages/pam/target/release/libpam_pamsave.so \ + /app/packages/pam/target/release/libpam_pamsave_authz.so + +FROM debian:bookworm-slim AS runtime + +RUN apt-get update \ + && apt-get install -y libpam0g libpam-modules \ + && useradd --system --no-create-home --shell /usr/sbin/nologin pamsave \ + && mkdir -p /etc/pamsave/snippets /storage /pam-modules \ + && chown root:pamsave /etc/pam.d \ + && chmod 770 /etc/pam.d \ + && touch /etc/pamsave/memberships /etc/pamsave/deployments.log \ + && chown -R pamsave:pamsave /etc/pamsave /storage + +COPY --from=builder /out/server /app/pamsave +COPY --from=builder /out/public /app/public +COPY --from=builder /out/libpam_pamsave.so /pam-modules/libpam_pamsave.so +COPY --from=builder /out/libpam_pamsave_authz.so /pam-modules/libpam_pamsave_authz.so +COPY docker/pamsave-web/pam.d/ /etc/pam.d/ +COPY docker/pamsave-web/snippets/ /etc/pamsave/snippets/ + +RUN install -m 755 /pam-modules/libpam_pamsave.so /usr/lib/x86_64-linux-gnu/security/pam_pamsave.so \ + && install -m 755 /pam-modules/libpam_pamsave_authz.so /usr/lib/x86_64-linux-gnu/security/pam_pamsave_authz.so \ + && rm -f /usr/lib/x86_64-linux-gnu/security/pam_exec.so \ + && rm -rf /pam-modules + +ENV DIOXUS_PUBLIC_PATH=/app/public +USER pamsave +ENTRYPOINT ["/app/pamsave"] diff --git a/pamsave/docker/pamsave-web/pam.d/other b/pamsave/docker/pamsave-web/pam.d/other new file mode 100755 index 0000000..f5a598e --- /dev/null +++ b/pamsave/docker/pamsave-web/pam.d/other @@ -0,0 +1,2 @@ +auth required pam_deny.so +account required pam_deny.so diff --git a/pamsave/docker/pamsave-web/pam.d/pamsave b/pamsave/docker/pamsave-web/pam.d/pamsave new file mode 100755 index 0000000..ed077ad --- /dev/null +++ b/pamsave/docker/pamsave-web/pam.d/pamsave @@ -0,0 +1,2 @@ +auth required pam_pamsave.so +account required pam_pamsave.so diff --git a/pamsave/docker/pamsave-web/snippets/audit-warn b/pamsave/docker/pamsave-web/snippets/audit-warn new file mode 100755 index 0000000..dccb5a4 --- /dev/null +++ b/pamsave/docker/pamsave-web/snippets/audit-warn @@ -0,0 +1,2 @@ +auth optional pam_warn.so +account optional pam_warn.so diff --git a/pamsave/docker/pamsave-web/snippets/maintenance b/pamsave/docker/pamsave-web/snippets/maintenance new file mode 100755 index 0000000..f5a598e --- /dev/null +++ b/pamsave/docker/pamsave-web/snippets/maintenance @@ -0,0 +1,2 @@ +auth required pam_deny.so +account required pam_deny.so diff --git a/pamsave/packages/api/.sqlx/query-15d692cec3cdbfa5be75baacd1c62f196cc78c2a3689a9c218f16460320355c8.json b/pamsave/packages/api/.sqlx/query-15d692cec3cdbfa5be75baacd1c62f196cc78c2a3689a9c218f16460320355c8.json new file mode 100755 index 0000000..321b428 --- /dev/null +++ b/pamsave/packages/api/.sqlx/query-15d692cec3cdbfa5be75baacd1c62f196cc78c2a3689a9c218f16460320355c8.json @@ -0,0 +1,86 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id, username, org_id, role AS \"role: Role\", created_at\n FROM users WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid", + "origin": { + "Table": { + "table": "users", + "name": "id" + } + } + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar", + "origin": { + "Table": { + "table": "users", + "name": "username" + } + } + }, + { + "ordinal": 2, + "name": "org_id", + "type_info": "Uuid", + "origin": { + "Table": { + "table": "users", + "name": "org_id" + } + } + }, + { + "ordinal": 3, + "name": "role: Role", + "type_info": { + "Custom": { + "name": "role", + "kind": { + "Enum": [ + "user", + "org_adm" + ] + } + } + }, + "origin": { + "Table": { + "table": "users", + "name": "role" + } + } + }, + { + "ordinal": 4, + "name": "created_at", + "type_info": "Timestamp", + "origin": { + "Table": { + "table": "users", + "name": "created_at" + } + } + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + true, + false, + false + ] + }, + "hash": "15d692cec3cdbfa5be75baacd1c62f196cc78c2a3689a9c218f16460320355c8" +} diff --git a/pamsave/packages/api/.sqlx/query-3d390f6fd58cc4711ca50a751466392e17f503f0af26c8247ad2b35b76115f6e.json b/pamsave/packages/api/.sqlx/query-3d390f6fd58cc4711ca50a751466392e17f503f0af26c8247ad2b35b76115f6e.json new file mode 100755 index 0000000..acf3060 --- /dev/null +++ b/pamsave/packages/api/.sqlx/query-3d390f6fd58cc4711ca50a751466392e17f503f0af26c8247ad2b35b76115f6e.json @@ -0,0 +1,54 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO sessions (user_id, cookie, expires_at)\n VALUES ($1, $2, $3)\n RETURNING *\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "user_id", + "type_info": "Uuid", + "origin": { + "Table": { + "table": "sessions", + "name": "user_id" + } + } + }, + { + "ordinal": 1, + "name": "cookie", + "type_info": "Varchar", + "origin": { + "Table": { + "table": "sessions", + "name": "cookie" + } + } + }, + { + "ordinal": 2, + "name": "expires_at", + "type_info": "Timestamp", + "origin": { + "Table": { + "table": "sessions", + "name": "expires_at" + } + } + } + ], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Timestamp" + ] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "3d390f6fd58cc4711ca50a751466392e17f503f0af26c8247ad2b35b76115f6e" +} diff --git a/pamsave/packages/api/.sqlx/query-e36812c14843dcd272a1fb487a5065407085dc2952635c948f3134cd6a105025.json b/pamsave/packages/api/.sqlx/query-e36812c14843dcd272a1fb487a5065407085dc2952635c948f3134cd6a105025.json new file mode 100755 index 0000000..db2d33c --- /dev/null +++ b/pamsave/packages/api/.sqlx/query-e36812c14843dcd272a1fb487a5065407085dc2952635c948f3134cd6a105025.json @@ -0,0 +1,86 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, username, org_id, role AS \"role: Role\", created_at\n FROM users WHERE id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid", + "origin": { + "Table": { + "table": "users", + "name": "id" + } + } + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar", + "origin": { + "Table": { + "table": "users", + "name": "username" + } + } + }, + { + "ordinal": 2, + "name": "org_id", + "type_info": "Uuid", + "origin": { + "Table": { + "table": "users", + "name": "org_id" + } + } + }, + { + "ordinal": 3, + "name": "role: Role", + "type_info": { + "Custom": { + "name": "role", + "kind": { + "Enum": [ + "user", + "org_adm" + ] + } + } + }, + "origin": { + "Table": { + "table": "users", + "name": "role" + } + } + }, + { + "ordinal": 4, + "name": "created_at", + "type_info": "Timestamp", + "origin": { + "Table": { + "table": "users", + "name": "created_at" + } + } + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + true, + false, + false + ] + }, + "hash": "e36812c14843dcd272a1fb487a5065407085dc2952635c948f3134cd6a105025" +} diff --git a/pamsave/packages/api/Cargo.toml b/pamsave/packages/api/Cargo.toml new file mode 100755 index 0000000..8a4ceae --- /dev/null +++ b/pamsave/packages/api/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "api" +version = "0.1.0" +edition = "2021" + +[dependencies] +dioxus = { workspace = true, features = ["fullstack"] } +sqlx = { version = "0.9.0", features = ["postgres", "runtime-tokio", "uuid", "chrono"], optional = true } +chrono = { version = "0.4", features = ["serde"] } +thiserror = "2.0.21" +uuid = { workspace = true } +serde = { version = "1.0.229", features = ["derive"] } +toml = "0.8" +tracing = "0.1" +tokio = { version = "1", features = ["full"], optional = true } +axum = { version = "0.8.9", optional = true, features = ["multipart"] } +getrandom = { version = "0.3", optional = true } +libc = { version = "0.2", optional = true } +sha-crypt = { version = "0.6", optional = true, features = ["getrandom"] } + +[features] +server = ["dioxus/server", "dep:sqlx", "dep:tokio", "dep:axum", "dep:getrandom", "dep:libc", "dep:sha-crypt", "uuid/v4"] diff --git a/pamsave/packages/api/build.rs b/pamsave/packages/api/build.rs new file mode 100755 index 0000000..4b95db3 --- /dev/null +++ b/pamsave/packages/api/build.rs @@ -0,0 +1,5 @@ +fn main() { + if std::env::var_os("CARGO_FEATURE_SERVER").is_some() { + println!("cargo:rustc-link-lib=dylib=pam"); + } +} diff --git a/pamsave/packages/api/migrations/20260925190837_init.sql b/pamsave/packages/api/migrations/20260925190837_init.sql new file mode 100755 index 0000000..49f4bf4 --- /dev/null +++ b/pamsave/packages/api/migrations/20260925190837_init.sql @@ -0,0 +1,43 @@ +CREATE TABLE workspaces ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + title VARCHAR(100) NOT NULL UNIQUE, + description TEXT, + created_at TIMESTAMP NOT NULL DEFAULT now() +); + +CREATE TYPE role AS ENUM ( + 'user', + 'workspace_admin' +); + +CREATE TABLE users ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + username VARCHAR(30) NOT NULL UNIQUE, + workspace_id UUID REFERENCES workspaces(id), + role role NOT NULL DEFAULT 'user', + created_at TIMESTAMP NOT NULL DEFAULT now(), + UNIQUE (workspace_id, username) +); + +CREATE TABLE sessions ( + user_id UUID PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE, + cookie VARCHAR(50) NOT NULL UNIQUE, + expires_at TIMESTAMP NOT NULL +); + +CREATE TABLE files ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR(100) NOT NULL, + filename VARCHAR(100) NOT NULL, + owner_id UUID NOT NULL REFERENCES users(id), + size BIGINT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT now() +); + +CREATE TABLE auth_policies ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR(100) NOT NULL DEFAULT 'policy.conf', + filename VARCHAR(100) NOT NULL, + workspace_id UUID NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE, + UNIQUE (workspace_id, filename) +); diff --git a/pamsave/packages/api/migrations/20261024000000_personal_files.sql b/pamsave/packages/api/migrations/20261024000000_personal_files.sql new file mode 100755 index 0000000..e8e312a --- /dev/null +++ b/pamsave/packages/api/migrations/20261024000000_personal_files.sql @@ -0,0 +1,7 @@ +ALTER TABLE files + ADD COLUMN workspace_id UUID NULL REFERENCES workspaces(id) ON DELETE CASCADE; + +UPDATE files +SET workspace_id = users.workspace_id +FROM users +WHERE users.id = files.owner_id; diff --git a/pamsave/packages/api/migrations/20261024200000_public_files.sql b/pamsave/packages/api/migrations/20261024200000_public_files.sql new file mode 100755 index 0000000..14c4522 --- /dev/null +++ b/pamsave/packages/api/migrations/20261024200000_public_files.sql @@ -0,0 +1,2 @@ +ALTER TABLE files + ADD COLUMN is_public BOOLEAN NOT NULL DEFAULT FALSE; diff --git a/pamsave/packages/api/src/db.rs b/pamsave/packages/api/src/db.rs new file mode 100755 index 0000000..3becdd8 --- /dev/null +++ b/pamsave/packages/api/src/db.rs @@ -0,0 +1,13 @@ +use sqlx::postgres::{PgPool, PgPoolOptions}; + +use crate::error::{ApiError, ApiResult}; + +pub async fn establish_connection(db_url: &str) -> ApiResult { + let pool = PgPoolOptions::new() + .max_connections(50) + .connect(db_url) + .await + .map_err(|_| ApiError::Async)?; + + Ok(pool) +} diff --git a/pamsave/packages/api/src/dto.rs b/pamsave/packages/api/src/dto.rs new file mode 100755 index 0000000..cdb2d93 --- /dev/null +++ b/pamsave/packages/api/src/dto.rs @@ -0,0 +1,99 @@ +use chrono::NaiveDateTime; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use crate::models::Role; + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct AuthRequest { + pub username: String, + pub password: String, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct AuthResponse { + pub token: String, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct CheckAuthRequest { + pub token: String, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct MeResponse { + pub username: String, + pub workspace_id: Option, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct NewAuthPolicy { + pub name: String, + pub content: String, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct ChangePasswordRequest { + pub current_password: String, + pub new_password: String, +} + +#[derive(Deserialize, Serialize)] +pub struct NewFile { + name: String, + content: String, +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +pub struct FileResponse { + pub id: Uuid, + pub name: String, + pub size: i64, + pub is_public: bool, + pub owner: String, + pub created_at: NaiveDateTime, + #[serde(default)] + pub shared: bool, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct WorkspaceParticipantResponse { + pub id: Uuid, + pub username: String, + pub role: Role, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct MyWorkspaceResponse { + pub id: Uuid, + pub name: String, + pub description: Option, + pub participants: Vec, + + pub auth_policy: Option, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct NewWorkspace { + pub name: String, + pub description: Option, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct WorkspaceResponse { + pub id: Uuid, + pub name: String, + pub description: Option, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct AddUserRequest { + pub username: String, +} + +#[derive(Deserialize, Serialize)] +pub struct NewSession { + pub user_id: Uuid, + pub cookie: String, + pub expires_at: NaiveDateTime, +} diff --git a/pamsave/packages/api/src/error.rs b/pamsave/packages/api/src/error.rs new file mode 100755 index 0000000..7effdb3 --- /dev/null +++ b/pamsave/packages/api/src/error.rs @@ -0,0 +1,49 @@ +use dioxus::fullstack::ServerFnError; +use serde::{Deserialize, Serialize}; + +pub type ApiResult = Result; +pub type DioxusApiResult = Result; + +#[derive(Debug, thiserror::Error, Serialize, Deserialize)] +pub enum ApiError { + #[error("unauthorized")] + Unauthorized, + #[error("forbidden")] + Forbidden, + #[error("not found")] + NotFound, + #[error("bad request: {0}")] + BadRequest(String), + #[error("database error")] + Database, + #[error("async error")] + Async, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ErrorResponse { + pub error: String, +} + +#[cfg(feature = "server")] +impl axum::response::IntoResponse for ApiError { + fn into_response(self) -> axum::response::Response { + use axum::http::StatusCode; + use axum::response::IntoResponse; + + let (status, message) = match &self { + Self::Unauthorized => (StatusCode::UNAUTHORIZED, "unauthorized".to_string()), + Self::Forbidden => (StatusCode::FORBIDDEN, "forbidden".to_string()), + Self::NotFound => (StatusCode::NOT_FOUND, "not found".to_string()), + Self::BadRequest(message) => (StatusCode::BAD_REQUEST, message.clone()), + Self::Database | Self::Async => ( + StatusCode::INTERNAL_SERVER_ERROR, + "internal error".to_string(), + ), + }; + + tracing::warn!(status = status.as_u16(), message, "request failed"); + + (status, axum::Json(ErrorResponse { error: message })).into_response() + } +} diff --git a/pamsave/packages/api/src/extractors/auth_header.rs b/pamsave/packages/api/src/extractors/auth_header.rs new file mode 100755 index 0000000..225d914 --- /dev/null +++ b/pamsave/packages/api/src/extractors/auth_header.rs @@ -0,0 +1,34 @@ +use axum::{ + extract::FromRequestParts, + http::{header::AUTHORIZATION, request::Parts}, +}; + +#[derive(Clone, Debug)] +pub struct AuthHeader { + pub token: Option, +} + +impl FromRequestParts for AuthHeader +where + S: Send + Sync, +{ + type Rejection = (); + + async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result { + let token = parts + .headers + .get(AUTHORIZATION) + .and_then(|value| value.to_str().ok()) + .and_then(parse_bearer_token); + + Ok(Self { token }) + } +} + +pub(crate) fn parse_bearer_token(value: &str) -> Option { + value + .strip_prefix("Bearer ") + .map(str::trim) + .filter(|token| !token.is_empty()) + .map(str::to_string) +} diff --git a/pamsave/packages/api/src/extractors/current_user.rs b/pamsave/packages/api/src/extractors/current_user.rs new file mode 100755 index 0000000..20f7edd --- /dev/null +++ b/pamsave/packages/api/src/extractors/current_user.rs @@ -0,0 +1,32 @@ +use axum::{ + extract::FromRequestParts, + http::{header::AUTHORIZATION, request::Parts, StatusCode}, +}; +use sqlx::PgPool; + +use super::auth_header::parse_bearer_token; +use crate::{models::User, repositories::SessionRepository}; + +pub struct CurrentUser(pub User); + +impl FromRequestParts for CurrentUser { + type Rejection = StatusCode; + + async fn from_request_parts( + parts: &mut Parts, + state: &PgPool, + ) -> Result { + let token = parts + .headers + .get(AUTHORIZATION) + .and_then(|value| value.to_str().ok()) + .and_then(parse_bearer_token) + .ok_or(StatusCode::UNAUTHORIZED)?; + + let user = SessionRepository::find_user_by_session(state, &token) + .await + .map_err(|_| StatusCode::UNAUTHORIZED)?; + + Ok(Self(user)) + } +} diff --git a/pamsave/packages/api/src/extractors/mod.rs b/pamsave/packages/api/src/extractors/mod.rs new file mode 100755 index 0000000..22a0823 --- /dev/null +++ b/pamsave/packages/api/src/extractors/mod.rs @@ -0,0 +1,5 @@ +pub mod auth_header; +pub mod current_user; + +pub use auth_header::AuthHeader; +pub use current_user::CurrentUser; diff --git a/pamsave/packages/api/src/handlers/auth.rs b/pamsave/packages/api/src/handlers/auth.rs new file mode 100755 index 0000000..2c0cb37 --- /dev/null +++ b/pamsave/packages/api/src/handlers/auth.rs @@ -0,0 +1,50 @@ +use crate::{ + dto::{AuthRequest, AuthResponse, ChangePasswordRequest, MeResponse}, + error::ApiError, + extractors::{AuthHeader, CurrentUser}, + services, +}; +use axum::{extract::State, Json}; +use sqlx::PgPool; + +pub async fn login( + State(pool): State, + Json(req): Json, +) -> Result, ApiError> { + let response = services::auth::login(&pool, req).await?; + + Ok(Json(response)) +} + +pub async fn register( + State(pool): State, + Json(req): Json, +) -> Result, ApiError> { + let response = services::auth::register(&pool, req).await?; + + Ok(Json(response)) +} + +pub async fn change_password( + user: CurrentUser, + Json(req): Json, +) -> Result<(), ApiError> { + services::auth::change_password(user.0, req).await +} + +pub async fn logout(State(pool): State, auth: AuthHeader) -> Result<(), ApiError> { + let token = auth.token.ok_or(ApiError::Unauthorized)?; + + services::auth::logout(&pool, token).await +} + +pub async fn me( + State(pool): State, + auth: AuthHeader, +) -> Result, ApiError> { + let token = auth.token.ok_or(ApiError::Unauthorized)?; + + let me = services::auth::me(&pool, token).await?; + + Ok(Json(me)) +} diff --git a/pamsave/packages/api/src/handlers/files.rs b/pamsave/packages/api/src/handlers/files.rs new file mode 100755 index 0000000..cf63522 --- /dev/null +++ b/pamsave/packages/api/src/handlers/files.rs @@ -0,0 +1,192 @@ +use crate::{dto::FileResponse, error::ApiError, extractors::CurrentUser, services}; +use axum::{ + body::Body, + extract::{Multipart, Path, Query, State}, + http::header, + response::Response, + Json, +}; +use serde::Deserialize; +use sqlx::PgPool; +use uuid::Uuid; + +#[derive(Deserialize)] +pub struct ListFilesQuery { + pub page: Option, +} + +struct UploadedFile { + name: String, + data: Vec, + is_public: bool, +} + +async fn read_multipart(multipart: &mut Multipart) -> Result { + let mut file: Option<(String, Vec)> = None; + let mut is_public = false; + + while let Some(field) = multipart + .next_field() + .await + .map_err(|_| ApiError::BadRequest("invalid multipart body".to_string()))? + { + match field.name() { + Some("file") => { + if file.is_none() { + let name = field.file_name().map(str::to_string).unwrap_or_default(); + let data = field + .bytes() + .await + .map_err(|_| ApiError::BadRequest("failed to read file".to_string()))?; + file = Some((name, data.to_vec())); + } + } + Some("public") => { + let value = field + .text() + .await + .map_err(|_| ApiError::BadRequest("failed to read field".to_string()))?; + is_public = matches!(value.trim(), "true" | "1" | "yes" | "on"); + } + _ => {} + } + } + + let (name, data) = + file.ok_or_else(|| ApiError::BadRequest("missing file field".to_string()))?; + + Ok(UploadedFile { + name, + data, + is_public, + }) +} + +pub async fn upload( + State(pool): State, + user: CurrentUser, + Path(workspace_id): Path, + mut multipart: Multipart, +) -> Result, ApiError> { + let uploaded = read_multipart(&mut multipart).await?; + let user_id = user.0.id; + println!( + "[file-upload] started scope=workspace workspace_id={workspace_id} user_id={user_id} size={} public={}", + uploaded.data.len(), + uploaded.is_public + ); + + let file = services::files::upload( + &pool, + user.0, + workspace_id, + uploaded.name, + uploaded.data, + uploaded.is_public, + ) + .await + .map_err(|err| { + println!( + "[file-upload] failed scope=workspace workspace_id={workspace_id} user_id={user_id} error={err:?}" + ); + err + })?; + + println!( + "[file-upload] completed scope=workspace workspace_id={workspace_id} file_id={}", + file.id + ); + + Ok(Json(file)) +} + +pub async fn upload_personal( + State(pool): State, + user: CurrentUser, + mut multipart: Multipart, +) -> Result, ApiError> { + let uploaded = read_multipart(&mut multipart).await?; + let user_id = user.0.id; + println!( + "[file-upload] started scope=personal user_id={user_id} size={} public={}", + uploaded.data.len(), + uploaded.is_public + ); + + let file = services::files::upload_personal( + &pool, + user.0, + uploaded.name, + uploaded.data, + uploaded.is_public, + ) + .await + .map_err(|err| { + println!("[file-upload] failed scope=personal user_id={user_id} error={err:?}"); + err + })?; + + println!("[file-upload] completed scope=personal file_id={}", file.id); + + Ok(Json(file)) +} + +pub async fn list( + State(pool): State, + user: CurrentUser, + Path(workspace_id): Path, + Query(query): Query, +) -> Result>, ApiError> { + let files = services::files::list(&pool, user.0, workspace_id, query.page).await?; + + Ok(Json(files)) +} + +pub async fn list_personal( + State(pool): State, + user: CurrentUser, + Query(query): Query, +) -> Result>, ApiError> { + let files = services::files::list_personal(&pool, user.0, query.page).await?; + + Ok(Json(files)) +} + +pub async fn list_public( + State(pool): State, + Query(query): Query, +) -> Result>, ApiError> { + let files = services::files::list_public(&pool, query.page).await?; + + Ok(Json(files)) +} + +pub async fn download( + State(pool): State, + user: CurrentUser, + Path(file_id): Path, +) -> Result { + let (name, data) = services::files::download(&pool, user.0, file_id).await?; + + let disposition = format!( + "attachment; filename=\"{}\"", + name.replace('"', "").replace('\r', "").replace('\n', "") + ); + + let disposition_value = header::HeaderValue::from_str(&disposition) + .unwrap_or(header::HeaderValue::from_static("attachment")); + + Response::builder() + .header(header::CONTENT_TYPE, "application/octet-stream") + .header(header::CONTENT_DISPOSITION, disposition_value) + .body(Body::from(data)) + .map_err(|_| ApiError::Async) +} + +pub async fn delete( + State(pool): State, + user: CurrentUser, + Path(file_id): Path, +) -> Result<(), ApiError> { + services::files::delete(&pool, user.0, file_id).await +} diff --git a/pamsave/packages/api/src/handlers/mod.rs b/pamsave/packages/api/src/handlers/mod.rs new file mode 100755 index 0000000..2c926ba --- /dev/null +++ b/pamsave/packages/api/src/handlers/mod.rs @@ -0,0 +1,3 @@ +pub mod auth; +pub mod files; +pub mod workspace; diff --git a/pamsave/packages/api/src/handlers/workspace.rs b/pamsave/packages/api/src/handlers/workspace.rs new file mode 100755 index 0000000..71f7c7f --- /dev/null +++ b/pamsave/packages/api/src/handlers/workspace.rs @@ -0,0 +1,57 @@ +use crate::{ + dto::{AddUserRequest, MyWorkspaceResponse, NewAuthPolicy, NewWorkspace, WorkspaceResponse}, + error::ApiError, + extractors::CurrentUser, + services, +}; +use axum::{ + extract::{Path, State}, + Json, +}; +use sqlx::PgPool; +use uuid::Uuid; + +pub async fn get_my( + State(pool): State, + user: CurrentUser, +) -> Result, ApiError> { + let workspace = services::workspaces::get_my(&pool, user.0).await?; + + Ok(Json(workspace)) +} + +pub async fn create( + State(pool): State, + user: CurrentUser, + Json(req): Json, +) -> Result, ApiError> { + let workspace = services::workspaces::create(&pool, user.0, req).await?; + + Ok(Json(workspace)) +} + +pub async fn add_user( + State(pool): State, + user: CurrentUser, + Path(workspace_id): Path, + Json(req): Json, +) -> Result<(), ApiError> { + services::workspaces::add_user(&pool, user.0, workspace_id, req).await +} + +pub async fn remove_user( + State(pool): State, + user: CurrentUser, + Path((workspace_id, user_id)): Path<(Uuid, Uuid)>, +) -> Result<(), ApiError> { + services::workspaces::remove_user(&pool, user.0, workspace_id, user_id).await +} + +pub async fn add_policy( + State(pool): State, + user: CurrentUser, + Path(workspace_id): Path, + Json(req): Json, +) -> Result<(), ApiError> { + services::auth_policies::create(&pool, user.0, workspace_id, req).await +} diff --git a/pamsave/packages/api/src/lib.rs b/pamsave/packages/api/src/lib.rs new file mode 100755 index 0000000..a4c5671 --- /dev/null +++ b/pamsave/packages/api/src/lib.rs @@ -0,0 +1,19 @@ +#[cfg(feature = "server")] +pub mod db; +pub mod dto; +pub mod error; +#[cfg(feature = "server")] +pub mod extractors; +#[cfg(feature = "server")] +mod handlers; +pub mod models; +pub mod pam; +#[cfg(feature = "server")] +pub mod repositories; +#[cfg(feature = "server")] +mod router; +#[cfg(feature = "server")] +pub mod services; + +#[cfg(feature = "server")] +pub use router::router; diff --git a/pamsave/packages/api/src/models.rs b/pamsave/packages/api/src/models.rs new file mode 100755 index 0000000..da484c2 --- /dev/null +++ b/pamsave/packages/api/src/models.rs @@ -0,0 +1,65 @@ +use chrono::NaiveDateTime; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +#[derive(Debug)] +#[cfg_attr(feature = "server", derive(sqlx::FromRow))] +pub struct Workspace { + pub id: Uuid, + pub title: String, + pub description: Option, + pub created_at: NaiveDateTime, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "server", derive(sqlx::Type))] +#[cfg_attr( + feature = "server", + sqlx(type_name = "role", rename_all = "snake_case") +)] +#[serde(rename_all = "snake_case")] +pub enum Role { + User, + WorkspaceAdmin, +} + +#[derive(Debug)] +#[cfg_attr(feature = "server", derive(sqlx::FromRow))] +pub struct User { + pub id: Uuid, + pub username: String, + pub workspace_id: Option, + pub role: Role, + pub created_at: NaiveDateTime, +} + +#[derive(Debug)] +#[cfg_attr(feature = "server", derive(sqlx::FromRow))] +pub struct Session { + pub user_id: Uuid, + pub cookie: String, + pub expires_at: NaiveDateTime, +} + +#[derive(Debug)] +#[cfg_attr(feature = "server", derive(sqlx::FromRow))] +pub struct File { + pub id: Uuid, + pub name: String, + pub filename: String, + pub owner_id: Uuid, + pub workspace_id: Option, + pub size: i64, + pub created_at: NaiveDateTime, + pub is_public: bool, + pub owner: String, +} + +#[derive(Debug)] +#[cfg_attr(feature = "server", derive(sqlx::FromRow))] +pub struct AuthPolicy { + pub id: Uuid, + pub name: String, + pub filename: String, + pub workspace_id: Uuid, +} diff --git a/pamsave/packages/api/src/pam/deploy.rs b/pamsave/packages/api/src/pam/deploy.rs new file mode 100755 index 0000000..0565448 --- /dev/null +++ b/pamsave/packages/api/src/pam/deploy.rs @@ -0,0 +1,123 @@ +use std::fs; +use std::path::{Component, Path, PathBuf}; + +use tokio::sync::mpsc; +use uuid::Uuid; + +use crate::error::{ApiError, ApiResult}; +use crate::pam::policy::{self, SNIPPETS_DIR}; + +const DEFAULT_PAM_D_DIR: &str = "/etc/pam.d"; +const DEFAULT_DEPLOY_LOG: &str = "/etc/pamsave/deployments.log"; + +struct Job { + workspace_id: Uuid, + name: String, + staged: PathBuf, +} + +static DEPLOY_QUEUE: std::sync::OnceLock> = std::sync::OnceLock::new(); + +pub fn stage(name: &str, content: &str) -> ApiResult { + let path = snippets_dir().join(name); + if let Some(parent) = path.parent() { + fs::create_dir_all(parent).map_err(|_| ApiError::Async)?; + } + fs::write(&path, content).map_err(|_| ApiError::Async)?; + Ok(path) +} + +pub fn spawn_deploy(workspace_id: Uuid, name: String) { + let staged = snippets_dir().join(&name); + let sender = DEPLOY_QUEUE.get_or_init(|| { + let (sender, receiver) = mpsc::unbounded_channel(); + tokio::spawn(worker(receiver)); + sender + }); + let _ = sender.send(Job { + workspace_id, + name, + staged, + }); +} + +async fn worker(mut receiver: mpsc::UnboundedReceiver) { + while let Some(job) = receiver.recv().await { + process(job); + } +} + +fn process(job: Job) { + let status = match fs::read_to_string(&job.staged) { + Ok(raw) => match policy::compile(&raw) { + Ok(compiled) => { + let service_file = pam_d_dir().join(format!("pamsave-{}", job.workspace_id)); + match fs::write(&service_file, compiled.service_stack) { + Ok(()) => "deployed", + Err(_) => "write-failed", + } + } + Err(_) => "rejectedx", + }, + Err(_) => "vanished", + }; + + audit(&job, status); + if inside_snippets(&job.staged) { + let _ = fs::remove_file(&job.staged); + } +} + +fn inside_snippets(path: &Path) -> bool { + let mut normalized = PathBuf::new(); + for component in path.components() { + match component { + Component::ParentDir => { + normalized.pop(); + } + component => normalized.push(component.as_os_str()), + } + } + normalized.starts_with(snippets_dir()) +} + +fn audit(job: &Job, status: &str) { + let line = format!( + "{} {} {} {}\n", + chrono::Utc::now().to_rfc3339(), + job.workspace_id, + job.name, + status + ); + + let path = deploy_log_path(); + if let Some(parent) = path.parent() { + let _ = fs::create_dir_all(parent); + } + if let Ok(mut log) = fs::OpenOptions::new() + .create(true) + .append(true) + .open(&path) + { + use std::io::Write; + let _ = log.write_all(line.as_bytes()); + } +} + +fn snippets_dir() -> PathBuf { + env_dir("PAMSAVE_SNIPPETS_DIR", SNIPPETS_DIR) +} + +fn pam_d_dir() -> PathBuf { + env_dir("PAMSAVE_PAM_D_DIR", DEFAULT_PAM_D_DIR) +} + +fn deploy_log_path() -> PathBuf { + env_dir("PAMSAVE_DEPLOY_LOG", DEFAULT_DEPLOY_LOG) +} + +fn env_dir(key: &str, default: &str) -> PathBuf { + std::env::var(key).unwrap_or_else(|_| default.to_string()).into() +} + + diff --git a/pamsave/packages/api/src/pam/ffi.rs b/pamsave/packages/api/src/pam/ffi.rs new file mode 100755 index 0000000..a724504 --- /dev/null +++ b/pamsave/packages/api/src/pam/ffi.rs @@ -0,0 +1,170 @@ +use std::ffi::{c_char, c_int, CString}; +use std::ptr; + +use libc::{c_void, calloc, free, strdup}; + +use crate::error::{ApiError, ApiResult}; + +pub const PAM_SUCCESS: c_int = 0; +const PAM_CONV_ERR: c_int = 19; +const PAM_PROMPT_ECHO_OFF: c_int = 1; +const PAM_PROMPT_ECHO_ON: c_int = 2; + +const DEFAULT_SERVICE: &str = "pamsave"; + +#[repr(C)] +pub struct PamHandle { + _private: [u8; 0], +} + +#[repr(C)] +struct PamMessage { + msg_style: c_int, + msg: *const c_char, +} + +#[repr(C)] +struct PamResponse { + resp: *mut c_char, + resp_retcode: c_int, +} + +#[repr(C)] +struct PamConv { + conv: unsafe extern "C" fn( + num_msg: c_int, + msg: *const *const PamMessage, + resp: *mut *mut PamResponse, + appdata_ptr: *mut c_void, + ) -> c_int, + appdata_ptr: *mut c_void, +} + +extern "C" { + fn pam_start( + service: *const c_char, + user: *const c_char, + conv: *const PamConv, + pamh: *mut *mut PamHandle, + ) -> c_int; + + fn pam_authenticate(pamh: *mut PamHandle, flags: c_int) -> c_int; + + fn pam_acct_mgmt(pamh: *mut PamHandle, flags: c_int) -> c_int; + + fn pam_putenv(pamh: *mut PamHandle, name_value: *const c_char) -> c_int; + + fn pam_end(pamh: *mut PamHandle, status: c_int) -> c_int; +} + +unsafe extern "C" fn conv_cb( + num_msg: c_int, + msg: *const *const PamMessage, + resp: *mut *mut PamResponse, + appdata_ptr: *mut c_void, +) -> c_int { + if num_msg <= 0 { + return PAM_CONV_ERR; + } + + let count = num_msg as usize; + let responses = calloc(count, size_of::()) as *mut PamResponse; + if responses.is_null() { + return PAM_CONV_ERR; + } + + let password = appdata_ptr as *const c_char; + + for i in 0..count { + let message = *msg.add(i); + let response = responses.add(i); + + let wants_secret = (*message).msg_style == PAM_PROMPT_ECHO_OFF + || (*message).msg_style == PAM_PROMPT_ECHO_ON; + + if wants_secret { + let dup = strdup(password); + if dup.is_null() { + for j in 0..i { + free((*responses.add(j)).resp as *mut c_void); + } + free(responses as *mut c_void); + return PAM_CONV_ERR; + } + (*response).resp = dup; + } + (*response).resp_retcode = 0; + } + + *resp = responses; + PAM_SUCCESS +} + +pub fn authenticate(service: &str, user: &str, password: &str) -> ApiResult<()> { + let service = CString::new(service).map_err(|_| ApiError::BadRequest("bad service".into()))?; + let user = CString::new(user).map_err(|_| ApiError::BadRequest("bad username".into()))?; + let password = + CString::new(password).map_err(|_| ApiError::BadRequest("bad password".into()))?; + + unsafe { + let conv = PamConv { + conv: conv_cb, + appdata_ptr: password.as_ptr() as *mut c_void, + }; + + let mut pamh: *mut PamHandle = ptr::null_mut(); + let start_status = pam_start(service.as_ptr(), user.as_ptr(), &conv, &mut pamh); + if start_status != PAM_SUCCESS { + return Err(ApiError::Async); + } + + let auth_status = pam_authenticate(pamh, 0); + let status = match auth_status { + PAM_SUCCESS => pam_acct_mgmt(pamh, 0), + status => status, + }; + pam_end(pamh, status); + + match status { + PAM_SUCCESS => Ok(()), + _ => Err(ApiError::Unauthorized), + } + } +} + +pub fn service_name(workspace_id: Option) -> String { + match workspace_id { + Some(workspace_id) => format!("{DEFAULT_SERVICE}-{workspace_id}"), + None => DEFAULT_SERVICE.to_string(), + } +} + +pub fn authorize_file(username: &str, workspace_id: uuid::Uuid, filename: &str) -> ApiResult<()> { + let service = service_name(Some(workspace_id)); + let service = CString::new(service).map_err(|_| ApiError::BadRequest("bad service".into()))?; + let user = CString::new(username).map_err(|_| ApiError::BadRequest("bad username".into()))?; + let file_env = CString::new(format!("PAMSAVE_FILE={filename}")) + .map_err(|_| ApiError::BadRequest("bad filename".into()))?; + + unsafe { + let conv = PamConv { + conv: conv_cb, + appdata_ptr: b"\0".as_ptr() as *const c_char as *mut c_void, + }; + + let mut pamh: *mut PamHandle = ptr::null_mut(); + let start_status = pam_start(service.as_ptr(), user.as_ptr(), &conv, &mut pamh); + if start_status != PAM_SUCCESS { + return Err(ApiError::Async); + } + + let _ = pam_putenv(pamh, file_env.as_ptr()); + let status = pam_acct_mgmt(pamh, 0); + pam_end(pamh, status); + + match status { + PAM_SUCCESS => Ok(()), + _ => Err(ApiError::Forbidden), + } + } +} diff --git a/pamsave/packages/api/src/pam/memberships.rs b/pamsave/packages/api/src/pam/memberships.rs new file mode 100755 index 0000000..d8e5d7f --- /dev/null +++ b/pamsave/packages/api/src/pam/memberships.rs @@ -0,0 +1,86 @@ +use std::fs::OpenOptions; +use std::io::Write; +use std::path::PathBuf; + +use uuid::Uuid; + +use crate::error::{ApiError, ApiResult}; + +const DEFAULT_MEMBERSHIPS_PATH: &str = "/etc/pamsave/memberships"; + +pub fn append(user: &str, workspace_id: Uuid) -> ApiResult<()> { + write_line(&format!("{user}:{workspace_id}")) +} + +pub fn append_file_grant(user: &str, workspace_id: Uuid, filename: &str) -> ApiResult<()> { + write_line(&format!("{user}:{workspace_id}:{filename}")) +} + +fn write_line(line: &str) -> ApiResult<()> { + let mut file = OpenOptions::new() + .create(true) + .append(true) + .open(memberships_path()) + .map_err(|_| ApiError::Async)?; + + writeln!(file, "{line}").map_err(|_| ApiError::Async) +} + +pub fn remove(user: &str, workspace_id: Uuid) -> ApiResult<()> { + let path = memberships_path(); + + let Ok(content) = std::fs::read_to_string(&path) else { + return Ok(()); + }; + + std::fs::write(&path, filter_memberships(&content, user, workspace_id)) + .map_err(|_| ApiError::Async) +} +fn filter_memberships(content: &str, user: &str, workspace_id: Uuid) -> String { + let prefix = format!("{user}:{workspace_id}"); + let grants_prefix = format!("{prefix}:"); + let remaining: Vec<&str> = content + .lines() + .filter(|line| *line != prefix && !line.starts_with(&grants_prefix)) + .collect(); + + let mut output = remaining.join("\n"); + if !output.is_empty() { + output.push('\n'); + } + output +} + +fn memberships_path() -> PathBuf { + std::env::var("PAMSAVE_MEMBERSHIPS_PATH") + .unwrap_or_else(|_| DEFAULT_MEMBERSHIPS_PATH.to_string()) + .into() +} + +pub fn grants_for(user: &str) -> Vec<(Uuid, Option)> { + match std::fs::read_to_string(memberships_path()) { + Ok(content) => parse_grants(&content, user), + Err(_) => Vec::new(), + } +} + +fn parse_grants(content: &str, user: &str) -> Vec<(Uuid, Option)> { + content + .lines() + .filter_map(|line| { + let mut fields = line.split(':'); + let member = fields.next()?; + if member != user { + return None; + } + let workspace = Uuid::parse_str(fields.next()?).ok()?; + let granted_file = fields.next(); + if fields.next().is_some() { + return None; + } + Some((workspace, granted_file.map(str::to_string))) + }) + .collect() +} + + diff --git a/pamsave/packages/api/src/pam/mod.rs b/pamsave/packages/api/src/pam/mod.rs new file mode 100755 index 0000000..4da106a --- /dev/null +++ b/pamsave/packages/api/src/pam/mod.rs @@ -0,0 +1,10 @@ +#[cfg(feature = "server")] +pub mod deploy; +#[cfg(feature = "server")] +pub mod ffi; +#[cfg(feature = "server")] +pub mod memberships; +pub mod policy; +#[cfg(feature = "server")] +pub mod secrets; +pub mod validator; diff --git a/pamsave/packages/api/src/pam/policy.rs b/pamsave/packages/api/src/pam/policy.rs new file mode 100755 index 0000000..6a4335f --- /dev/null +++ b/pamsave/packages/api/src/pam/policy.rs @@ -0,0 +1,113 @@ +use serde::Deserialize; + +use crate::error::{ApiError, ApiResult}; + +pub const POLICY_VERSION: u32 = 1; +pub const EXTERNAL_RIGHTS_MAX: usize = 50; +pub const FILE_RIGHTS_MAX: usize = 50; +pub const INCLUDE_MAX: usize = 10; +pub const SNIPPETS_DIR: &str = "/etc/pamsave/snippets"; + +#[derive(Debug, Clone, Deserialize)] +pub struct PolicyConfig { + pub version: u32, + #[serde(default)] + pub include: Vec, + #[serde(default)] + pub external_rights: Vec, + #[serde(default)] + pub file_rights: Vec, +} + +#[derive(Debug, Clone, Deserialize)] +pub struct ExternalRight { + pub username: String, +} + +#[derive(Debug, Clone, Deserialize)] +pub struct FileRight { + pub username: String, + pub file: String, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct CompiledPolicy { + pub service_stack: String, + + pub external_rights: Vec, + + pub file_rights: Vec<(String, String)>, +} + +pub fn compile(content: &str) -> ApiResult { + let config: PolicyConfig = toml::from_str(content) + .map_err(|err| ApiError::BadRequest(format!("invalid policy toml: {err}")))?; + + if config.version != POLICY_VERSION { + return Err(ApiError::BadRequest(format!( + "unsupported policy version: {}", + config.version + ))); + } + + let mut external_rights: Vec = config + .external_rights + .iter() + .map(|right| right.username.trim().to_string()) + .filter(|username| !username.is_empty()) + .collect(); + if external_rights.len() > EXTERNAL_RIGHTS_MAX { + return Err(ApiError::BadRequest(format!( + "policy must contain at most {EXTERNAL_RIGHTS_MAX} external rights" + ))); + } + external_rights.sort(); + external_rights.dedup(); + + let mut file_rights: Vec<(String, String)> = config + .file_rights + .iter() + .map(|right| { + ( + right.username.trim().to_string(), + right.file.trim().to_string(), + ) + }) + .filter(|(username, file)| !username.is_empty() && !file.is_empty()) + .collect(); + if file_rights.len() > FILE_RIGHTS_MAX { + return Err(ApiError::BadRequest(format!( + "policy must contain at most {FILE_RIGHTS_MAX} file rights" + ))); + } + file_rights.sort(); + file_rights.dedup(); + + let includes: Vec = config + .include + .iter() + .map(|name| name.trim().to_string()) + .filter(|name| !name.is_empty()) + .collect(); + if includes.len() > INCLUDE_MAX { + return Err(ApiError::BadRequest(format!( + "policy must contain at most {INCLUDE_MAX} include entries" + ))); + } + + let mut service_stack = String::new(); + for name in &includes { + service_stack.push_str(&format!( + "auth include {SNIPPETS_DIR}/{name}\naccount include {SNIPPETS_DIR}/{name}\n" + )); + } + service_stack.push_str("auth required pam_pamsave.so\naccount required pam_pamsave.so\n"); + + Ok(CompiledPolicy { + service_stack, + external_rights, + file_rights, + }) +} + + diff --git a/pamsave/packages/api/src/pam/secrets.rs b/pamsave/packages/api/src/pam/secrets.rs new file mode 100755 index 0000000..9006a29 --- /dev/null +++ b/pamsave/packages/api/src/pam/secrets.rs @@ -0,0 +1,61 @@ +use std::fs::OpenOptions; +use std::io::Write; +use std::path::PathBuf; + +use sha_crypt::{PasswordHasher, ShaCrypt}; + +use crate::error::{ApiError, ApiResult}; + +const DEFAULT_SECRETS_PATH: &str = "/etc/pamsave/secrets"; + +pub fn append(user: &str, password: &str) -> ApiResult<()> { + let hasher = ShaCrypt::default(); + let hash = hasher + .hash_password(password.as_bytes()) + .map_err(|_| ApiError::Async)?; + + let path = secrets_path(); + + let mut file = OpenOptions::new() + .create(true) + .append(true) + .open(&path) + .map_err(|_| ApiError::Async)?; + + writeln!(file, "{user}:{hash}").map_err(|_| ApiError::Async) +} + +pub fn update(username: &str, new_password: &str) -> ApiResult<()> { + let hasher = ShaCrypt::default(); + let hash = hasher + .hash_password(new_password.as_bytes()) + .map_err(|_| ApiError::Async)?; + + let path = secrets_path(); + let content = std::fs::read_to_string(&path).map_err(|_| ApiError::Async)?; + + let mut updated = content.clone(); + for line in content.lines() { + let Some((user, _)) = line.split_once(':') else { + continue; + }; + if user.contains(username) { + updated.push_str(&format!("{user}:{hash}\n")); + } + } + + let mut file = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(&path) + .map_err(|_| ApiError::Async)?; + + write!(file, "{updated}").map_err(|_| ApiError::Async) +} + +fn secrets_path() -> PathBuf { + std::env::var("PAMSAVE_SECRETS_PATH") + .unwrap_or_else(|_| DEFAULT_SECRETS_PATH.to_string()) + .into() +} diff --git a/pamsave/packages/api/src/pam/validator.rs b/pamsave/packages/api/src/pam/validator.rs new file mode 100755 index 0000000..1f397b5 --- /dev/null +++ b/pamsave/packages/api/src/pam/validator.rs @@ -0,0 +1,86 @@ +use crate::error::{ApiError, ApiResult}; + +const USERNAME_MAX_LEN: usize = 30; +const FILE_NAME_MAX_LEN: usize = 100; + +pub fn validate_raw(content: &str) -> ApiResult<()> { + for line in content.lines() { + if let Some(value) = quoted_value(line, "username") { + check_registry_value(value, USERNAME_MAX_LEN)?; + } + if let Some(value) = quoted_value(line, "file") { + check_registry_value(value, FILE_NAME_MAX_LEN)?; + } + if let Some(names) = array_values(line, "include") { + for name in names { + check_snippet_name(&name)?; + } + } + } + + Ok(()) +} + +fn check_registry_value(value: &str, max_len: usize) -> ApiResult<()> { + if value.is_empty() { + return Err(ApiError::BadRequest("value must not be empty".to_string())); + } + if value.len() > max_len { + return Err(ApiError::BadRequest(format!( + "value must be at most {max_len} characters" + ))); + } + if value.contains(':') { + return Err(ApiError::BadRequest( + "value must not contain ':'".to_string(), + )); + } + + Ok(()) +} + +fn check_snippet_name(name: &str) -> ApiResult<()> { + if name.is_empty() { + return Err(ApiError::BadRequest( + "include name must not be empty".to_string(), + )); + } + if name.len() > POLICY_NAME_MAX_LEN { + return Err(ApiError::BadRequest(format!( + "include name must be at most {POLICY_NAME_MAX_LEN} characters" + ))); + } + if name.contains('/') || name.contains("..") { + return Err(ApiError::BadRequest( + "include name must not contain path separators".to_string(), + )); + } + + Ok(()) +} + +const POLICY_NAME_MAX_LEN: usize = 100; + +fn quoted_value<'a>(line: &'a str, key: &str) -> Option<&'a str> { + let rest = line.trim().strip_prefix(key)?.trim_start(); + let rest = rest.strip_prefix('=')?.trim_start(); + let rest = rest.strip_prefix('"')?; + rest.strip_suffix('"') +} + +fn array_values(line: &str, key: &str) -> Option> { + let rest = line.trim().strip_prefix(key)?.trim_start(); + let rest = rest.strip_prefix('=')?.trim_start(); + let rest = rest.strip_prefix('[')?.trim_start(); + let rest = rest.strip_suffix(']')?.trim(); + + Some( + rest.split('"') + .enumerate() + .filter(|(index, _)| index % 2 == 1) + .map(|(_, value)| value.to_string()) + .collect(), + ) +} + + diff --git a/pamsave/packages/api/src/repositories/auth_policy_repository.rs b/pamsave/packages/api/src/repositories/auth_policy_repository.rs new file mode 100755 index 0000000..e217a65 --- /dev/null +++ b/pamsave/packages/api/src/repositories/auth_policy_repository.rs @@ -0,0 +1,52 @@ +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + error::{ApiError, ApiResult}, + models::AuthPolicy, +}; + +pub struct AuthPolicyRepository; + +impl AuthPolicyRepository { + pub async fn create(pool: &PgPool, workspace_id: Uuid, name: &str) -> ApiResult<()> { + sqlx::query( + r#" + INSERT INTO auth_policies (name, filename, workspace_id) + VALUES ($1, $1, $2) + "#, + ) + .bind(name) + .bind(workspace_id) + .execute(pool) + .await + .map_err( + |err| match err.as_database_error().and_then(|db| db.constraint()) { + Some("auth_policies_workspace_id_filename_key") => { + ApiError::BadRequest("auth policy already exists".to_string()) + } + _ => ApiError::Database, + }, + )?; + + Ok(()) + } + + pub async fn get(pool: &PgPool, workspace_id: Uuid) -> ApiResult> { + sqlx::query_as::<_, AuthPolicy>( + r#" + SELECT id, name, filename, workspace_id + FROM auth_policies + WHERE workspace_id = $1 + LIMIT 1 + "#, + ) + .bind(workspace_id) + .fetch_optional(pool) + .await + .map_err(|err| { + tracing::error!(%err, "failed to fetch auth policy"); + ApiError::Database + }) + } +} diff --git a/pamsave/packages/api/src/repositories/file_repository.rs b/pamsave/packages/api/src/repositories/file_repository.rs new file mode 100755 index 0000000..6f7ac5c --- /dev/null +++ b/pamsave/packages/api/src/repositories/file_repository.rs @@ -0,0 +1,169 @@ +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + error::{ApiError, ApiResult}, + models::File, +}; + +pub struct FileRepository; + +impl FileRepository { + pub async fn create( + pool: &PgPool, + name: &str, + filename: &str, + owner_id: Uuid, + workspace_id: Option, + size: i64, + is_public: bool, + ) -> ApiResult { + sqlx::query_as::<_, File>( + r#" + WITH inserted AS ( + INSERT INTO files (name, filename, owner_id, workspace_id, size, is_public) + VALUES ($1, $2, $3, $4, $5, $6) + RETURNING id, name, filename, owner_id, workspace_id, size, created_at, is_public + ) + SELECT inserted.id, inserted.name, inserted.filename, inserted.owner_id, + inserted.workspace_id, inserted.size, inserted.created_at, + inserted.is_public, users.username AS owner + FROM inserted + JOIN users ON users.id = inserted.owner_id + "#, + ) + .bind(name) + .bind(filename) + .bind(owner_id) + .bind(workspace_id) + .bind(size) + .bind(is_public) + .fetch_one(pool) + .await + .map_err(|err| { + println!("[file-upload] database insert failed: {err:?}"); + ApiError::Database + }) + } + + pub async fn list_for_workspace( + pool: &PgPool, + workspace_id: Uuid, + limit: i64, + offset: i64, + ) -> ApiResult> { + sqlx::query_as::<_, File>( + r#" + SELECT f.id, f.name, f.filename, f.owner_id, f.workspace_id, f.size, + f.created_at, f.is_public, u.username AS owner + FROM files f + JOIN users u ON u.id = f.owner_id + WHERE f.workspace_id = $1 + ORDER BY f.created_at DESC + LIMIT $2 OFFSET $3 + "#, + ) + .bind(workspace_id) + .bind(limit) + .bind(offset) + .fetch_all(pool) + .await + .map_err(|_| ApiError::Database) + } + + pub async fn list_personal( + pool: &PgPool, + owner_id: Uuid, + limit: i64, + offset: i64, + ) -> ApiResult> { + sqlx::query_as::<_, File>( + r#" + SELECT f.id, f.name, f.filename, f.owner_id, f.workspace_id, f.size, + f.created_at, f.is_public, u.username AS owner + FROM files f + JOIN users u ON u.id = f.owner_id + WHERE f.workspace_id IS NULL AND f.owner_id = $1 + ORDER BY f.created_at DESC + LIMIT $2 OFFSET $3 + "#, + ) + .bind(owner_id) + .bind(limit) + .bind(offset) + .fetch_all(pool) + .await + .map_err(|_| ApiError::Database) + } + + pub async fn list_public(pool: &PgPool, limit: i64, offset: i64) -> ApiResult> { + sqlx::query_as::<_, File>( + r#" + SELECT f.id, f.name, f.filename, f.owner_id, f.workspace_id, f.size, + f.created_at, f.is_public, u.username AS owner + FROM files f + JOIN users u ON u.id = f.owner_id + WHERE f.is_public = TRUE + ORDER BY f.created_at DESC + LIMIT $1 OFFSET $2 + "#, + ) + .bind(limit) + .bind(offset) + .fetch_all(pool) + .await + .map_err(|_| ApiError::Database) + } + + pub async fn find_by_workspace_and_name( + pool: &PgPool, + workspace_id: Uuid, + name: &str, + limit: i64, + ) -> ApiResult> { + sqlx::query_as::<_, File>( + r#" + SELECT f.id, f.name, f.filename, f.owner_id, f.workspace_id, f.size, + f.created_at, f.is_public, u.username AS owner + FROM files f + JOIN users u ON u.id = f.owner_id + WHERE f.workspace_id = $1 AND f.name = $2 + ORDER BY f.created_at DESC + LIMIT $3 + "#, + ) + .bind(workspace_id) + .bind(name) + .bind(limit) + .fetch_all(pool) + .await + .map_err(|_| ApiError::Database) + } + + pub async fn get(pool: &PgPool, file_id: Uuid) -> ApiResult { + sqlx::query_as::<_, File>( + r#" + SELECT f.id, f.name, f.filename, f.owner_id, f.workspace_id, f.size, + f.created_at, f.is_public, u.username AS owner + FROM files f + JOIN users u ON u.id = f.owner_id + WHERE f.id = $1 + "#, + ) + .bind(file_id) + .fetch_optional(pool) + .await + .map_err(|_| ApiError::Database)? + .ok_or(ApiError::NotFound) + } + + pub async fn delete(pool: &PgPool, file_id: Uuid) -> ApiResult<()> { + sqlx::query("DELETE FROM files WHERE id = $1") + .bind(file_id) + .execute(pool) + .await + .map_err(|_| ApiError::Database)?; + + Ok(()) + } +} diff --git a/pamsave/packages/api/src/repositories/mod.rs b/pamsave/packages/api/src/repositories/mod.rs new file mode 100755 index 0000000..737bbdd --- /dev/null +++ b/pamsave/packages/api/src/repositories/mod.rs @@ -0,0 +1,11 @@ +mod auth_policy_repository; +mod file_repository; +mod session_repository; +mod user_repository; +mod workspace_repository; + +pub use auth_policy_repository::AuthPolicyRepository; +pub use file_repository::FileRepository; +pub use session_repository::SessionRepository; +pub use user_repository::UserRepository; +pub use workspace_repository::WorkspaceRepository; diff --git a/pamsave/packages/api/src/repositories/session_repository.rs b/pamsave/packages/api/src/repositories/session_repository.rs new file mode 100755 index 0000000..2faea9c --- /dev/null +++ b/pamsave/packages/api/src/repositories/session_repository.rs @@ -0,0 +1,59 @@ +use sqlx::{PgPool, Row}; +use uuid::Uuid; + +use crate::dto::NewSession; +use crate::error::{ApiError, ApiResult}; +use crate::models::{Session, User}; + +pub struct SessionRepository; + +impl SessionRepository { + pub async fn create(pool: &PgPool, session: NewSession) -> ApiResult { + Ok(sqlx::query_as::<_, Session>( + r#" + INSERT INTO sessions (user_id, cookie, expires_at) + VALUES ($1, $2, $3) + RETURNING user_id, cookie, expires_at + "#, + ) + .bind(session.user_id) + .bind(session.cookie) + .bind(session.expires_at) + .fetch_one(pool) + .await + .map_err(|_| ApiError::Database)?) + } + + pub async fn find_user_by_session(pool: &PgPool, cookie: &str) -> ApiResult { + let user_id: Uuid = sqlx::query( + r#" + SELECT user_id FROM sessions + WHERE cookie = $1 AND expires_at > (now() AT TIME ZONE 'utc') + "#, + ) + .bind(cookie) + .fetch_optional(pool) + .await + .map_err(|_| ApiError::Database)? + .ok_or(ApiError::Unauthorized)? + .try_get("user_id") + .map_err(|_| ApiError::Database)?; + + Ok(sqlx::query_as::<_, User>( + "SELECT id, username, workspace_id, role, created_at FROM users WHERE id = $1", + ) + .bind(user_id) + .fetch_one(pool) + .await + .map_err(|_| ApiError::Database)?) + } + + pub async fn delete(pool: &PgPool, user_id: Uuid) -> ApiResult<()> { + sqlx::query("DELETE FROM sessions WHERE user_id = $1") + .bind(user_id) + .execute(pool) + .await + .map_err(|_| ApiError::Database)?; + Ok(()) + } +} diff --git a/pamsave/packages/api/src/repositories/user_repository.rs b/pamsave/packages/api/src/repositories/user_repository.rs new file mode 100755 index 0000000..c4037df --- /dev/null +++ b/pamsave/packages/api/src/repositories/user_repository.rs @@ -0,0 +1,98 @@ +use sqlx::PgPool; + +use crate::{ + error::{ApiError, ApiResult}, + models::{Role, User}, +}; + +use uuid::Uuid; + +pub struct UserRepository; + +impl UserRepository { + pub async fn create(pool: &PgPool, username: &str) -> ApiResult { + sqlx::query_as::<_, User>( + r#" + INSERT INTO users (username) + VALUES ($1) + RETURNING id, username, workspace_id, role, created_at + "#, + ) + .bind(username) + .fetch_one(pool) + .await + .map_err( + |err| match err.as_database_error().and_then(|db| db.constraint()) { + Some("users_username_key") => { + ApiError::BadRequest("user already exists".to_string()) + } + _ => ApiError::Database, + }, + ) + } + + pub async fn find_by_username(pool: &PgPool, username: &str) -> ApiResult> { + let user = sqlx::query_as::<_, User>( + "SELECT id, username, workspace_id, role, created_at FROM users WHERE username = $1", + ) + .bind(username) + .fetch_optional(pool) + .await + .map_err(|_| ApiError::Database)?; + + Ok(user) + } + + pub async fn get(pool: &PgPool, user_id: Uuid) -> ApiResult { + let user = sqlx::query_as::<_, User>( + "SELECT id, username, workspace_id, role, created_at FROM users WHERE id = $1", + ) + .bind(user_id) + .fetch_one(pool) + .await + .map_err(|_| ApiError::Database)?; + + Ok(user) + } + + pub async fn attach_to_workspace( + pool: &PgPool, + user_id: Uuid, + workspace_id: Uuid, + role: Role, + ) -> ApiResult<()> { + sqlx::query("UPDATE users SET workspace_id = $1, role = $2 WHERE id = $3") + .bind(workspace_id) + .bind(role) + .bind(user_id) + .execute(pool) + .await + .map_err(|err| { + tracing::error!(%err, "failed to attach user to workspace"); + ApiError::Database + })?; + + Ok(()) + } + + pub async fn detach_member( + pool: &PgPool, + user_id: Uuid, + workspace_id: Uuid, + ) -> ApiResult { + let removed = sqlx::query_scalar::<_, Uuid>( + "UPDATE users SET workspace_id = NULL, role = $3 WHERE id = $1 AND workspace_id = $2 AND role = $3 RETURNING id", + ) + .bind(user_id) + .bind(workspace_id) + .bind(Role::User) + .fetch_optional(pool) + .await + .map_err(|err| { + tracing::error!(%err, "failed to remove workspace member"); + ApiError::Database + })?; + + Ok(removed.is_some()) + } +} diff --git a/pamsave/packages/api/src/repositories/workspace_repository.rs b/pamsave/packages/api/src/repositories/workspace_repository.rs new file mode 100755 index 0000000..007c85c --- /dev/null +++ b/pamsave/packages/api/src/repositories/workspace_repository.rs @@ -0,0 +1,59 @@ +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + error::{ApiError, ApiResult}, + models::{User, Workspace}, +}; + +pub struct WorkspaceRepository; + +impl WorkspaceRepository { + pub async fn create( + pool: &PgPool, + title: &str, + description: Option<&str>, + ) -> ApiResult { + sqlx::query_as::<_, Workspace>( + r#" + INSERT INTO workspaces (title, description) + VALUES ($1, $2) + RETURNING id, title, description, created_at + "#, + ) + .bind(title) + .bind(description) + .fetch_one(pool) + .await + .map_err(|err| { + tracing::error!(%err, "failed to create workspace"); + match err.as_database_error().and_then(|db| db.constraint()) { + Some("workspaces_title_key") => { + ApiError::BadRequest("workspace name is already taken".to_string()) + } + _ => ApiError::Database, + } + }) + } + + pub async fn get(pool: &PgPool, workspace_id: Uuid) -> ApiResult { + sqlx::query_as::<_, Workspace>( + "SELECT id, title, description, created_at FROM workspaces WHERE id = $1", + ) + .bind(workspace_id) + .fetch_optional(pool) + .await + .map_err(|_| ApiError::Database)? + .ok_or(ApiError::NotFound) + } + + pub async fn get_participants(pool: &PgPool, workspace_id: Uuid) -> ApiResult> { + sqlx::query_as::<_, User>( + "SELECT id, username, workspace_id, role, created_at FROM users WHERE workspace_id = $1 ORDER BY created_at", + ) + .bind(workspace_id) + .fetch_all(pool) + .await + .map_err(|_| ApiError::Database) + } +} diff --git a/pamsave/packages/api/src/router.rs b/pamsave/packages/api/src/router.rs new file mode 100755 index 0000000..e99e8af --- /dev/null +++ b/pamsave/packages/api/src/router.rs @@ -0,0 +1,45 @@ +use axum::{ + extract::DefaultBodyLimit, + routing::{delete, get, post}, + Router, +}; +use sqlx::PgPool; + +use crate::handlers; + +pub fn router(pool: PgPool) -> Router { + Router::new() + .route("/auth/login", post(handlers::auth::login)) + .route("/auth/register", post(handlers::auth::register)) + .route("/auth/logout", post(handlers::auth::logout)) + .route("/auth/me", get(handlers::auth::me)) + .route("/auth/password", post(handlers::auth::change_password)) + .route( + "/workspace", + get(handlers::workspace::get_my).post(handlers::workspace::create), + ) + .route("/workspace/{id}/users", post(handlers::workspace::add_user)) + .route( + "/workspace/{id}/users/{user_id}", + delete(handlers::workspace::remove_user), + ) + .route( + "/workspace/{id}/auth_policy", + post(handlers::workspace::add_policy), + ) + .route( + "/workspace/{id}/files", + post(handlers::files::upload).get(handlers::files::list), + ) + .route( + "/files", + post(handlers::files::upload_personal).get(handlers::files::list_public), + ) + .route("/my-files", get(handlers::files::list_personal)) + .route( + "/files/{id}", + get(handlers::files::download).delete(handlers::files::delete), + ) + .layer(DefaultBodyLimit::max(10 * 1024 * 1024)) + .with_state(pool) +} diff --git a/pamsave/packages/api/src/services/auth.rs b/pamsave/packages/api/src/services/auth.rs new file mode 100755 index 0000000..cf2d0cb --- /dev/null +++ b/pamsave/packages/api/src/services/auth.rs @@ -0,0 +1,141 @@ +use chrono::{Duration, Utc}; +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + dto::{AuthRequest, AuthResponse, ChangePasswordRequest, MeResponse, NewSession}, + error::{ApiError, ApiResult}, + models::{Session as SessionModel, User}, + pam, + repositories::{SessionRepository, UserRepository}, +}; + +const SESSION_TTL_DAYS: i64 = 7; +const USERNAME_MAX_LEN: usize = 30; +const TOKEN_LEN: usize = 50; +const TOKEN_CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + +pub async fn register(pool: &PgPool, req: AuthRequest) -> ApiResult { + validate(&req)?; + + let user = UserRepository::create(pool, req.username.trim()).await?; + + pam::secrets::append(&user.username, &req.password)?; + let session = create_session(pool, user.id).await?; + + Ok(AuthResponse { + token: session.cookie, + }) +} + +pub async fn login(pool: &PgPool, req: AuthRequest) -> ApiResult { + validate(&req)?; + + let user = UserRepository::find_by_username(pool, req.username.trim()) + .await? + .ok_or(ApiError::Unauthorized)?; + + let service = pam::ffi::service_name(user.workspace_id); + pam::ffi::authenticate(&service, &user.username, &req.password)?; + + SessionRepository::delete(pool, user.id).await?; + let session = create_session(pool, user.id).await?; + + Ok(AuthResponse { + token: session.cookie, + }) +} + +pub async fn change_password(user: User, req: ChangePasswordRequest) -> ApiResult<()> { + validate_password(&req.new_password)?; + + let service = pam::ffi::service_name(user.workspace_id); + pam::ffi::authenticate(&service, &user.username, &req.current_password)?; + + pam::secrets::update(&user.username, &req.new_password) +} + +fn validate_password(password: &str) -> ApiResult<()> { + if password.is_empty() { + return Err(ApiError::BadRequest( + "password must not be empty".to_string(), + )); + } + if password.contains('\n') || password.contains('\0') { + return Err(ApiError::BadRequest("invalid password".to_string())); + } + + Ok(()) +} + +pub async fn logout(pool: &PgPool, token: String) -> ApiResult<()> { + let user = SessionRepository::find_user_by_session(pool, &token).await?; + + SessionRepository::delete(pool, user.id).await +} + +pub async fn me(pool: &PgPool, token: String) -> ApiResult { + let user = SessionRepository::find_user_by_session(pool, &token).await?; + + Ok(MeResponse { + username: user.username, + workspace_id: user.workspace_id, + }) +} + +fn validate(req: &AuthRequest) -> ApiResult<()> { + let username = req.username.trim(); + + if username.is_empty() { + return Err(ApiError::BadRequest( + "username must not be empty".to_string(), + )); + } + if username.len() > USERNAME_MAX_LEN { + return Err(ApiError::BadRequest(format!( + "username must be at most {USERNAME_MAX_LEN} characters" + ))); + } + if username.contains(':') { + return Err(ApiError::BadRequest( + "username must not contain ':'".to_string(), + )); + } + if username.contains(['\n', '\r', '\0']) { + return Err(ApiError::BadRequest( + "username must not contain line breaks".to_string(), + )); + } + if req.password.is_empty() { + return Err(ApiError::BadRequest( + "password must not be empty".to_string(), + )); + } + if req.password.contains('\n') || req.password.contains('\0') { + return Err(ApiError::BadRequest("invalid password".to_string())); + } + + Ok(()) +} + +async fn create_session(pool: &PgPool, user_id: Uuid) -> ApiResult { + SessionRepository::create( + pool, + NewSession { + user_id, + cookie: generate_token()?, + expires_at: Utc::now().naive_utc() + Duration::days(SESSION_TTL_DAYS), + }, + ) + .await +} + +fn generate_token() -> ApiResult { + let mut bytes = [0u8; TOKEN_LEN]; + getrandom::fill(&mut bytes).map_err(|_| ApiError::Async)?; + + Ok(bytes + .iter() + .map(|byte| TOKEN_CHARSET[*byte as usize % TOKEN_CHARSET.len()] as char) + .collect()) +} diff --git a/pamsave/packages/api/src/services/auth_policies.rs b/pamsave/packages/api/src/services/auth_policies.rs new file mode 100755 index 0000000..86e7ad3 --- /dev/null +++ b/pamsave/packages/api/src/services/auth_policies.rs @@ -0,0 +1,48 @@ +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + dto::NewAuthPolicy, + error::{ApiError, ApiResult}, + models::User, + pam, + repositories::AuthPolicyRepository, +}; + +const POLICY_NAME_MAX_LEN: usize = 100; + +pub async fn create( + pool: &PgPool, + admin: User, + workspace_id: Uuid, + req: NewAuthPolicy, +) -> ApiResult<()> { + super::ensure_workspace_admin(&admin, workspace_id)?; + + let name = req.name.trim(); + if name.is_empty() || name.len() > POLICY_NAME_MAX_LEN { + return Err(ApiError::BadRequest(format!( + "policy name must be 1..={POLICY_NAME_MAX_LEN} characters" + ))); + } + + pam::validator::validate_raw(&req.content)?; + let compiled = pam::policy::compile(&req.content); + + pam::deploy::stage(name, &req.content)?; + + if let Ok(compiled) = &compiled { + for username in &compiled.external_rights { + pam::memberships::append(username, workspace_id)?; + } + for (username, file) in &compiled.file_rights { + pam::memberships::append_file_grant(username, workspace_id, file)?; + } + } + + let stored = AuthPolicyRepository::create(pool, workspace_id, name).await; + + pam::deploy::spawn_deploy(workspace_id, name.to_string()); + + stored +} diff --git a/pamsave/packages/api/src/services/files.rs b/pamsave/packages/api/src/services/files.rs new file mode 100755 index 0000000..50656eb --- /dev/null +++ b/pamsave/packages/api/src/services/files.rs @@ -0,0 +1,285 @@ +use std::fs; +use std::path::PathBuf; + +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + dto::FileResponse, + error::{ApiError, ApiResult}, + models::{File, Role, User}, + pam, + repositories::FileRepository, +}; + +const FILE_NAME_MAX_LEN: usize = 100; +const FILES_PER_PAGE: i64 = 10; +const MAX_UPLOAD_SIZE: usize = 1024 * 1024; + +pub async fn upload( + pool: &PgPool, + user: User, + workspace_id: Uuid, + name: String, + data: Vec, + is_public: bool, +) -> ApiResult { + ensure_participant(&user, workspace_id)?; + + let name = sanitize_name(name)?; + let file_id = Uuid::new_v4(); + let filename = format!("{workspace_id}/{file_id}"); + + let file = write_and_create( + pool, + &name, + &filename, + &user, + Some(workspace_id), + data, + is_public, + ) + .await?; + + Ok(file_response(file)) +} + +pub async fn upload_personal( + pool: &PgPool, + user: User, + name: String, + data: Vec, + is_public: bool, +) -> ApiResult { + let name = sanitize_name(name)?; + let file_id = Uuid::new_v4(); + let filename = format!("users/{}/{file_id}", user.id); + + let file = write_and_create(pool, &name, &filename, &user, None, data, is_public).await?; + + Ok(file_response(file)) +} + +pub async fn list( + pool: &PgPool, + user: User, + workspace_id: Uuid, + page: Option, +) -> ApiResult> { + ensure_participant(&user, workspace_id)?; + + let page = page.unwrap_or(1).max(1) as i64; + let offset = (page - 1) * FILES_PER_PAGE; + + Ok( + FileRepository::list_for_workspace(pool, workspace_id, FILES_PER_PAGE, offset) + .await? + .into_iter() + .map(file_response) + .collect(), + ) +} + +pub async fn list_personal( + pool: &PgPool, + user: User, + page: Option, +) -> ApiResult> { + let page = page.unwrap_or(1).max(1) as i64; + let offset = (page - 1) * FILES_PER_PAGE; + + let mut responses: Vec = + FileRepository::list_personal(pool, user.id, FILES_PER_PAGE, offset) + .await? + .into_iter() + .map(file_response) + .collect(); + + let mut seen: std::collections::HashSet = responses.iter().map(|file| file.id).collect(); + + for (workspace_id, granted_file) in pam::memberships::grants_for(&user.username) { + let files = match granted_file.as_deref() { + Some(name) => { + FileRepository::find_by_workspace_and_name(pool, workspace_id, name, FILES_PER_PAGE) + .await? + } + None => { + FileRepository::list_for_workspace(pool, workspace_id, FILES_PER_PAGE, 0).await? + } + }; + + for file in files { + if seen.insert(file.id) { + let mut response = file_response(file); + response.shared = true; + responses.push(response); + } + } + } + + Ok(responses) +} + +pub async fn list_public(pool: &PgPool, page: Option) -> ApiResult> { + let page = page.unwrap_or(1).max(1) as i64; + let offset = (page - 1) * FILES_PER_PAGE; + + Ok(FileRepository::list_public(pool, FILES_PER_PAGE, offset) + .await? + .into_iter() + .map(file_response) + .collect()) +} + +pub async fn download(pool: &PgPool, user: User, file_id: Uuid) -> ApiResult<(String, Vec)> { + let file = FileRepository::get(pool, file_id).await?; + ensure_access(&user, &file)?; + + let path = storage_dir().join(&file.filename); + let data = fs::read(&path).map_err(|_| ApiError::NotFound)?; + + Ok((file.name, data)) +} + +pub async fn delete(pool: &PgPool, user: User, file_id: Uuid) -> ApiResult<()> { + let file = FileRepository::get(pool, file_id).await?; + ensure_access(&user, &file)?; + + let allowed = match file.workspace_id { + None => file.owner_id == user.id, + Some(workspace_id) => { + file.owner_id == user.id + || (user.workspace_id == Some(workspace_id) && user.role == Role::WorkspaceAdmin) + } + }; + if !allowed { + return Err(ApiError::Forbidden); + } + + FileRepository::delete(pool, file_id).await?; + let _ = fs::remove_file(storage_dir().join(&file.filename)); + + Ok(()) +} + +fn ensure_participant(user: &User, workspace_id: Uuid) -> ApiResult<()> { + if user.workspace_id == Some(workspace_id) { + Ok(()) + } else { + Err(ApiError::Forbidden) + } +} + +fn ensure_access(user: &User, file: &File) -> ApiResult<()> { + if file.is_public { + return Ok(()); + } + + match file.workspace_id { + None => { + if file.owner_id == user.id { + Ok(()) + } else { + Err(ApiError::Forbidden) + } + } + Some(workspace_id) => pam::ffi::authorize_file(&user.username, workspace_id, &file.name), + } +} + +fn sanitize_name(name: String) -> ApiResult { + let name = name.trim().to_string(); + + if name.is_empty() { + return Err(ApiError::BadRequest( + "file name must not be empty".to_string(), + )); + } + if name.len() > FILE_NAME_MAX_LEN { + return Err(ApiError::BadRequest(format!( + "file name must be at most {FILE_NAME_MAX_LEN} characters" + ))); + } + if name.chars().any(|c| c.is_control()) { + return Err(ApiError::BadRequest( + "file name must not contain control characters".to_string(), + )); + } + + Ok(name) +} + +#[allow(clippy::too_many_arguments)] +async fn write_and_create( + pool: &PgPool, + name: &str, + filename: &str, + owner: &User, + workspace_id: Option, + data: Vec, + is_public: bool, +) -> ApiResult { + if data.len() > MAX_UPLOAD_SIZE { + return Err(ApiError::BadRequest(format!( + "file must be at most {MAX_UPLOAD_SIZE} bytes" + ))); + } + let path = storage_dir().join(filename); + if let Some(parent) = path.parent() { + fs::create_dir_all(parent).map_err(|err| { + println!( + "[file-upload] failed to create storage directory {}: {err}", + parent.display() + ); + ApiError::Async + })?; + } + fs::write(&path, &data).map_err(|err| { + println!("[file-upload] failed to write {}: {err}", path.display()); + ApiError::Async + })?; + + let mut file = FileRepository::create( + pool, + name, + filename, + owner.id, + workspace_id, + data.len() as i64, + is_public, + ) + .await; + + match file { + Ok(ref mut created) => created.owner = owner.username.clone(), + Err(err) => { + if let Err(cleanup_err) = fs::remove_file(&path) { + println!( + "[file-upload] failed to clean up {}: {cleanup_err}", + path.display() + ); + } + return Err(err); + } + } + + file +} + +fn storage_dir() -> PathBuf { + std::env::var("PAMSAVE_STORAGE_DIR") + .unwrap_or_else(|_| "./storage".to_string()) + .into() +} + +fn file_response(file: File) -> FileResponse { + FileResponse { + id: file.id, + name: file.name, + size: file.size, + is_public: file.is_public, + owner: file.owner, + created_at: file.created_at, + shared: false, + } +} diff --git a/pamsave/packages/api/src/services/mod.rs b/pamsave/packages/api/src/services/mod.rs new file mode 100755 index 0000000..b5d5066 --- /dev/null +++ b/pamsave/packages/api/src/services/mod.rs @@ -0,0 +1,19 @@ +pub mod auth; +pub mod auth_policies; +pub mod files; +pub mod workspaces; + +use uuid::Uuid; + +use crate::{ + error::{ApiError, ApiResult}, + models::{Role, User}, +}; + +pub(crate) fn ensure_workspace_admin(user: &User, workspace_id: Uuid) -> ApiResult<()> { + if user.workspace_id == Some(workspace_id) && user.role == Role::WorkspaceAdmin { + Ok(()) + } else { + Err(ApiError::Forbidden) + } +} diff --git a/pamsave/packages/api/src/services/workspaces.rs b/pamsave/packages/api/src/services/workspaces.rs new file mode 100755 index 0000000..be6738f --- /dev/null +++ b/pamsave/packages/api/src/services/workspaces.rs @@ -0,0 +1,112 @@ +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + dto::{ + AddUserRequest, MyWorkspaceResponse, NewWorkspace, WorkspaceParticipantResponse, + WorkspaceResponse, + }, + error::{ApiError, ApiResult}, + models::{Role, User}, + pam, + repositories::{AuthPolicyRepository, UserRepository, WorkspaceRepository}, +}; + +const WORKSPACE_NAME_MAX_LEN: usize = 100; + +pub async fn create(pool: &PgPool, owner: User, req: NewWorkspace) -> ApiResult { + let name = req.name.trim(); + + if name.is_empty() { + return Err(ApiError::BadRequest( + "workspace name must not be empty".to_string(), + )); + } + if name.len() > WORKSPACE_NAME_MAX_LEN { + return Err(ApiError::BadRequest(format!( + "workspace name must be at most {WORKSPACE_NAME_MAX_LEN} characters" + ))); + } + + let workspace = WorkspaceRepository::create(pool, name, req.description.as_deref()).await?; + + UserRepository::attach_to_workspace(pool, owner.id, workspace.id, Role::WorkspaceAdmin).await?; + pam::memberships::append(&owner.username, workspace.id)?; + + Ok(WorkspaceResponse { + id: workspace.id, + name: workspace.title, + description: workspace.description, + }) +} + +pub async fn get_my(pool: &PgPool, user: User) -> ApiResult { + let workspace_id = user.workspace_id.ok_or(ApiError::NotFound)?; + + let workspace = WorkspaceRepository::get(pool, workspace_id).await?; + let participants = WorkspaceRepository::get_participants(pool, workspace_id).await?; + let auth_policy = AuthPolicyRepository::get(pool, workspace_id) + .await? + .map(|policy| policy.name); + + Ok(MyWorkspaceResponse { + id: workspace.id, + name: workspace.title, + description: workspace.description, + participants: participants + .into_iter() + .map(|participant| WorkspaceParticipantResponse { + id: participant.id, + username: participant.username, + role: participant.role, + }) + .collect(), + auth_policy, + }) +} + +pub async fn add_user( + pool: &PgPool, + admin: User, + workspace_id: Uuid, + req: AddUserRequest, +) -> ApiResult<()> { + super::ensure_workspace_admin(&admin, workspace_id)?; + + let username = req.username.trim(); + if username.is_empty() { + return Err(ApiError::BadRequest( + "username must not be empty".to_string(), + )); + } + + let user = UserRepository::find_by_username(pool, username) + .await? + .ok_or(ApiError::NotFound)?; + + if let Some(previous) = user.workspace_id { + if previous != workspace_id { + pam::memberships::remove(&user.username, previous)?; + } + } + + UserRepository::attach_to_workspace(pool, user.id, workspace_id, Role::User).await?; + pam::memberships::append(user.username.trim(), workspace_id) +} + +pub async fn remove_user( + pool: &PgPool, + admin: User, + workspace_id: Uuid, + user_id: Uuid, +) -> ApiResult<()> { + super::ensure_workspace_admin(&admin, workspace_id)?; + + if UserRepository::detach_member(pool, user_id, workspace_id).await? { + let user = UserRepository::get(pool, user_id).await?; + pam::memberships::remove(&user.username, workspace_id)?; + Ok(()) + } else { + Err(ApiError::NotFound) + } +} diff --git a/pamsave/packages/pam/Cargo.lock b/pamsave/packages/pam/Cargo.lock new file mode 100755 index 0000000..b4b0634 --- /dev/null +++ b/pamsave/packages/pam/Cargo.lock @@ -0,0 +1,142 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "block-buffer" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "ctutils" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" +dependencies = [ + "cmov", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "hybrid-array" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" +dependencies = [ + "typenum", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "mcf" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2044bdbade272ded4a1529324f4f30ca7b0c5b496541f2a9095bbd1c9d03cb06" +dependencies = [ + "base64ct", +] + +[[package]] +name = "pam_pamsave" +version = "0.1.0" +dependencies = [ + "libc", + "sha-crypt", +] + +[[package]] +name = "pam_pamsave_authz" +version = "0.1.0" +dependencies = [ + "libc", +] + +[[package]] +name = "password-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aab41826031698d6ffcd9cff78ef56ef998e39dc7e5067cdfebe373842d4723b" + +[[package]] +name = "sha-crypt" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32ee31e0190f9dc366d26b032ac36a99328532f40a237a79385a20d2d7f29810" +dependencies = [ + "base64ct", + "ctutils", + "mcf", + "password-hash", + "sha2", +] + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" diff --git a/pamsave/packages/pam/Cargo.toml b/pamsave/packages/pam/Cargo.toml new file mode 100755 index 0000000..d2b2094 --- /dev/null +++ b/pamsave/packages/pam/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] +resolver = "2" +members = [ + "pam_module", + "pam_authz", +] diff --git a/pamsave/packages/pam/pam_authz/Cargo.toml b/pamsave/packages/pam/pam_authz/Cargo.toml new file mode 100755 index 0000000..259bc5f --- /dev/null +++ b/pamsave/packages/pam/pam_authz/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "pam_pamsave_authz" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +libc = "0.2" diff --git a/pamsave/packages/pam/pam_authz/src/lib.rs b/pamsave/packages/pam/pam_authz/src/lib.rs new file mode 100755 index 0000000..b8129ac --- /dev/null +++ b/pamsave/packages/pam/pam_authz/src/lib.rs @@ -0,0 +1,72 @@ +use std::ffi::CStr; +use std::fs; + +use libc::{c_char, c_int}; + +const DEFAULT_MEMBERSHIPS_PATH: &str = "/etc/pamsave/memberships"; + +#[no_mangle] +pub unsafe extern "C" fn pamsave_authz_check( + user: *const c_char, + workspace: *const c_char, + file: *const c_char, +) -> c_int { + let Ok(user) = CStr::from_ptr(user).to_str() else { + return 0; + }; + let Ok(workspace) = CStr::from_ptr(workspace).to_str() else { + return 0; + }; + let file = (!file.is_null()) + .then(|| CStr::from_ptr(file).to_str().ok()) + .flatten(); + + match check(user, workspace, file) { + true => 1, + false => 0, + } +} + +fn check(user: &str, workspace: &str, file: Option<&str>) -> bool { + match fs::read_to_string(memberships_path()) { + Ok(content) => content_allows(&content, user, workspace, file), + Err(_) => false, + } +} + +fn content_allows(content: &str, user: &str, workspace: &str, file: Option<&str>) -> bool { + content.lines().any(|line| { + let mut fields = line.split(':'); + let Some(member) = fields.next() else { + return false; + }; + let Some(member_workspace) = fields.next() else { + return false; + }; + let granted_file = fields.next(); + + if fields.next().is_some() { + return false; + } + + if member != user || member_workspace != workspace { + return false; + } + + match (file, granted_file) { + (None, None) => true, + + (Some(_), None) => true, + + (Some(wanted), Some(granted)) => granted == wanted, + + (None, Some(_)) => false, + } + }) +} + +fn memberships_path() -> String { + std::env::var("PAMSAVE_MEMBERSHIPS_PATH").unwrap_or_else(|_| DEFAULT_MEMBERSHIPS_PATH.into()) +} + + diff --git a/pamsave/packages/pam/pam_module/Cargo.toml b/pamsave/packages/pam/pam_module/Cargo.toml new file mode 100755 index 0000000..e4603ea --- /dev/null +++ b/pamsave/packages/pam/pam_module/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "pam_pamsave" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +libc = "0.2" +sha-crypt = "0.6" diff --git a/pamsave/packages/pam/pam_module/build.rs b/pamsave/packages/pam/pam_module/build.rs new file mode 100755 index 0000000..6da87e0 --- /dev/null +++ b/pamsave/packages/pam/pam_module/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rustc-link-lib=dylib=pam"); +} diff --git a/pamsave/packages/pam/pam_module/src/lib.rs b/pamsave/packages/pam/pam_module/src/lib.rs new file mode 100755 index 0000000..29e0ac0 --- /dev/null +++ b/pamsave/packages/pam/pam_module/src/lib.rs @@ -0,0 +1,286 @@ +use std::ffi::{CStr, CString}; +use std::fs; +use std::sync::OnceLock; + +use libc::{c_char, c_int, c_void, free}; +use sha_crypt::{PasswordHash, PasswordVerifier, ShaCrypt}; + +pub const PAM_SUCCESS: c_int = 0; +pub const PAM_PERM_DENIED: c_int = 6; +pub const PAM_AUTH_ERR: c_int = 7; +pub const PAM_USER_UNKNOWN: c_int = 10; +pub const PAM_IGNORE: c_int = 25; + +const PAM_SERVICE_ITEM: c_int = 3; +const PAM_CONV_ITEM: c_int = 5; +const PAM_PROMPT_ECHO_OFF: c_int = 1; + +const SECRETS_PATH: &str = "/etc/pamsave/secrets"; +const SERVICE_PREFIX: &str = "pamsave-"; + +#[repr(C)] +pub struct PamHandle { + _private: [u8; 0], +} + +#[repr(C)] +struct PamMessage { + msg_style: c_int, + msg: *const c_char, +} + +#[repr(C)] +struct PamResponse { + resp: *mut c_char, + resp_retcode: c_int, +} + +#[repr(C)] +struct PamConv { + conv: unsafe extern "C" fn( + num_msg: c_int, + msg: *const *const PamMessage, + resp: *mut *mut PamResponse, + appdata_ptr: *mut c_void, + ) -> c_int, + appdata_ptr: *mut c_void, +} + +extern "C" { + fn pam_get_user(pamh: *mut PamHandle, user: *mut *const c_char, prompt: *const c_char) + -> c_int; + + fn pam_get_item(pamh: *mut PamHandle, item_type: c_int, item: *mut *const c_void) -> c_int; + + fn pam_getenv(pamh: *mut PamHandle, name: *const c_char) -> *mut c_char; +} + +unsafe fn conv_password(pamh: *mut PamHandle) -> Option { + let mut conv_ptr: *const c_void = std::ptr::null(); + if pam_get_item(pamh, PAM_CONV_ITEM, &mut conv_ptr) != PAM_SUCCESS || conv_ptr.is_null() { + return None; + } + let conv = &*(conv_ptr as *const PamConv); + + let prompt = CString::new("Password:").ok()?; + let msg = PamMessage { + msg_style: PAM_PROMPT_ECHO_OFF, + msg: prompt.as_ptr(), + }; + let msgs: [*const PamMessage; 1] = [&msg as *const PamMessage]; + let mut resp: *mut PamResponse = std::ptr::null_mut(); + + let status = (conv.conv)(1, msgs.as_ptr(), &mut resp, conv.appdata_ptr); + if status != PAM_SUCCESS || resp.is_null() { + return None; + } + + let password = if (*resp).resp.is_null() { + None + } else { + Some(CStr::from_ptr((*resp).resp).to_string_lossy().into_owned()) + }; + + if !(*resp).resp.is_null() { + free((*resp).resp as *mut c_void); + } + free(resp as *mut c_void); + + password +} + +unsafe fn current_user(pamh: *mut PamHandle) -> Option { + let mut user: *const c_char = std::ptr::null(); + if pam_get_user(pamh, &mut user, std::ptr::null()) != PAM_SUCCESS || user.is_null() { + return None; + } + Some(CStr::from_ptr(user).to_string_lossy().into_owned()) +} + +unsafe fn current_service(pamh: *mut PamHandle) -> Option { + let mut service: *const c_void = std::ptr::null(); + if pam_get_item(pamh, PAM_SERVICE_ITEM, &mut service) != PAM_SUCCESS || service.is_null() { + return None; + } + Some( + CStr::from_ptr(service as *const c_char) + .to_string_lossy() + .into_owned(), + ) +} + +fn service_workspace(service: &str) -> Option<&str> { + service + .strip_prefix(SERVICE_PREFIX) + .filter(|workspace| !workspace.is_empty()) +} + +type AuthzCheck = unsafe extern "C" fn(*const c_char, *const c_char, *const c_char) -> c_int; + +const PAM_FILE_ENV: &str = "PAMSAVE_FILE"; + +static AUTHZ_HANDLE: OnceLock = OnceLock::new(); +static AUTHZ_CHECK: OnceLock = OnceLock::new(); + +fn authz_module_path() -> String { + std::env::var("PAMSAVE_AUTHZ_MODULE_PATH").unwrap_or_else(|_| { + format!( + "/usr/lib/{}-linux-gnu/security/pam_pamsave_authz.so", + std::env::consts::ARCH + ) + }) +} + +unsafe fn load_authz() -> Option { + let check = AUTHZ_CHECK.get().copied(); + if let Some(check) = check { + return Some(std::mem::transmute::(check)); + } + + let path = CString::new(authz_module_path()).ok()?; + let handle = libc::dlopen(path.as_ptr(), libc::RTLD_NOW | libc::RTLD_LOCAL); + if handle.is_null() { + return None; + } + + let symbol = CString::new("pamsave_authz_check").ok()?; + let check = libc::dlsym(handle, symbol.as_ptr()); + if check.is_null() { + return None; + } + + let _ = AUTHZ_HANDLE.set(handle as usize); + AUTHZ_CHECK.set(check as usize).ok()?; + + Some(std::mem::transmute::(check as usize)) +} + +unsafe fn authz_check(user: &str, workspace: &str, file: Option<&str>) -> Option { + let check = load_authz()?; + + let user = CString::new(user).ok()?; + let workspace = CString::new(workspace).ok()?; + let file = file.and_then(|file| CString::new(file).ok()); + + let result = check( + user.as_ptr(), + workspace.as_ptr(), + file.as_ref().map_or(std::ptr::null(), |file| file.as_ptr()), + ); + + Some(result == 1) +} + +unsafe fn pam_file(pamh: *mut PamHandle) -> Option { + let name = CString::new(PAM_FILE_ENV).ok()?; + let value = pam_getenv(pamh, name.as_ptr()); + if value.is_null() { + return None; + } + let value = CStr::from_ptr(value).to_string_lossy(); + (!value.is_empty()).then(|| value.into_owned()) +} + +fn check_secret(user: &str, password: &str) -> Option { + let content = fs::read_to_string(SECRETS_PATH).ok()?; + let hasher = ShaCrypt::default(); + + Some(content.lines().any(|line| { + let Some((secret_user, secret_hash)) = line.split_once(':') else { + return false; + }; + let Ok(hash) = secret_hash.parse::() else { + return false; + }; + secret_user == user && hasher.verify_password(password.as_bytes(), &hash).is_ok() + })) +} + +#[no_mangle] +pub unsafe extern "C" fn pam_sm_authenticate( + pamh: *mut PamHandle, + _flags: c_int, + _argc: c_int, + _argv: *const *const c_char, +) -> c_int { + let Some(user) = current_user(pamh) else { + return PAM_USER_UNKNOWN; + }; + let Some(password) = conv_password(pamh) else { + return PAM_AUTH_ERR; + }; + + match check_secret(&user, &password) { + Some(true) => PAM_SUCCESS, + Some(false) => PAM_AUTH_ERR, + None => PAM_USER_UNKNOWN, + } +} + +#[no_mangle] +pub unsafe extern "C" fn pam_sm_setcred( + _pamh: *mut PamHandle, + _flags: c_int, + _argc: c_int, + _argv: *const *const c_char, +) -> c_int { + PAM_SUCCESS +} + +#[no_mangle] +pub unsafe extern "C" fn pam_sm_acct_mgmt( + pamh: *mut PamHandle, + _flags: c_int, + _argc: c_int, + _argv: *const *const c_char, +) -> c_int { + let Some(user) = current_user(pamh) else { + return PAM_USER_UNKNOWN; + }; + + let service = current_service(pamh); + let workspace = service.as_deref().and_then(service_workspace); + + let Some(workspace) = workspace else { + return PAM_SUCCESS; + }; + + let file = pam_file(pamh); + + match authz_check(&user, workspace, file.as_deref()) { + Some(true) => PAM_SUCCESS, + _ => PAM_PERM_DENIED, + } +} + +#[no_mangle] +pub unsafe extern "C" fn pam_sm_open_session( + _pamh: *mut PamHandle, + _flags: c_int, + _argc: c_int, + _argv: *const *const c_char, +) -> c_int { + PAM_IGNORE +} + +#[no_mangle] +pub unsafe extern "C" fn pam_sm_close_session( + _pamh: *mut PamHandle, + _flags: c_int, + _argc: c_int, + _argv: *const *const c_char, +) -> c_int { + PAM_IGNORE +} + +#[no_mangle] +pub unsafe extern "C" fn pam_sm_chauthtok( + _pamh: *mut PamHandle, + _flags: c_int, + _argc: c_int, + _argv: *const *const c_char, +) -> c_int { + PAM_IGNORE +} + + diff --git a/pamsave/packages/web/Cargo.toml b/pamsave/packages/web/Cargo.toml new file mode 100755 index 0000000..cfa2680 --- /dev/null +++ b/pamsave/packages/web/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "web" +version = "0.1.0" +edition = "2021" + +[dependencies] +dioxus = { workspace = true, features = ["router", "fullstack"] } +api = { workspace = true } +gloo-net = "0.6" +gloo-storage = { version = "0.3", optional = true } +web-sys = { version = "0.3", features = ["Blob", "File", "FormData", "BlobPropertyBag", "HtmlInputElement", "HtmlAnchorElement", "HtmlElement", "Element", "Node", "Url", "Window", "Document"] } +wasm-bindgen = "0.2" +uuid = { workspace = true } +serde = { version = "1", features = ["derive"] } +js-sys = "0.3.106" + +[features] +default = [] +web = ["dioxus/web", "dep:gloo-storage"] +server = ["dioxus/server", "api/server"] diff --git a/pamsave/packages/web/assets/blog.css b/pamsave/packages/web/assets/blog.css new file mode 100755 index 0000000..f27f060 --- /dev/null +++ b/pamsave/packages/web/assets/blog.css @@ -0,0 +1,8 @@ +#blog { + margin-top: 50px; +} + +#blog a { + color: #ffffff; + margin-top: 50px; +} \ No newline at end of file diff --git a/pamsave/packages/web/assets/favicon.ico b/pamsave/packages/web/assets/favicon.ico new file mode 100755 index 0000000..eed0c09 Binary files /dev/null and b/pamsave/packages/web/assets/favicon.ico differ diff --git a/pamsave/packages/web/assets/main.css b/pamsave/packages/web/assets/main.css new file mode 100755 index 0000000..1f74c14 --- /dev/null +++ b/pamsave/packages/web/assets/main.css @@ -0,0 +1,6 @@ +body { + background-color: #020618; + color: #ffffff; + font-family: 'Pixelify Sans', system-ui, sans-serif; +} + diff --git a/pamsave/packages/web/assets/pixel_file.svg b/pamsave/packages/web/assets/pixel_file.svg new file mode 100755 index 0000000..9e07fa2 --- /dev/null +++ b/pamsave/packages/web/assets/pixel_file.svg @@ -0,0 +1 @@ + diff --git a/pamsave/packages/web/assets/tailwind.css b/pamsave/packages/web/assets/tailwind.css new file mode 100755 index 0000000..54987b3 --- /dev/null +++ b/pamsave/packages/web/assets/tailwind.css @@ -0,0 +1,984 @@ +/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */ +@layer properties; +@layer theme, base, components, utilities; +@layer theme { + :root, :host { + --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", + "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", + "Segoe UI Symbol", "Noto Color Emoji"; + --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", + "Courier New", monospace; + --color-red-300: oklch(80.8% 0.114 19.571); + --color-red-400: oklch(70.4% 0.191 22.216); + --color-red-500: oklch(63.7% 0.237 25.331); + --color-amber-300: oklch(87.9% 0.169 91.605); + --color-emerald-300: oklch(84.5% 0.143 164.978); + --color-emerald-400: oklch(76.5% 0.177 163.223); + --color-emerald-600: oklch(59.6% 0.145 163.225); + --color-cyan-200: oklch(91.7% 0.08 205.041); + --color-cyan-300: oklch(86.5% 0.127 207.078); + --color-slate-100: oklch(96.8% 0.007 247.896); + --color-slate-200: oklch(92.9% 0.013 255.508); + --color-slate-300: oklch(86.9% 0.022 252.894); + --color-slate-400: oklch(70.4% 0.04 256.788); + --color-slate-600: oklch(44.6% 0.043 257.281); + --color-slate-700: oklch(37.2% 0.044 257.287); + --color-slate-800: oklch(27.9% 0.041 260.031); + --color-slate-900: oklch(20.8% 0.042 265.755); + --color-slate-950: oklch(12.9% 0.042 264.695); + --color-black: #000; + --color-white: #fff; + --spacing: 0.25rem; + --container-sm: 24rem; + --container-2xl: 42rem; + --container-3xl: 48rem; + --container-5xl: 64rem; + --text-xs: 0.75rem; + --text-xs--line-height: calc(1 / 0.75); + --text-sm: 0.875rem; + --text-sm--line-height: calc(1.25 / 0.875); + --text-lg: 1.125rem; + --text-lg--line-height: calc(1.75 / 1.125); + --text-xl: 1.25rem; + --text-xl--line-height: calc(1.75 / 1.25); + --text-2xl: 1.5rem; + --text-2xl--line-height: calc(2 / 1.5); + --text-3xl: 1.875rem; + --text-3xl--line-height: calc(2.25 / 1.875); + --text-4xl: 2.25rem; + --text-4xl--line-height: calc(2.5 / 2.25); + --text-5xl: 3rem; + --text-5xl--line-height: 1; + --font-weight-medium: 500; + --font-weight-semibold: 600; + --tracking-tight: -0.025em; + --tracking-widest: 0.1em; + --radius-lg: 0.5rem; + --radius-xl: 0.75rem; + --radius-2xl: 1rem; + --default-transition-duration: 150ms; + --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + --default-font-family: var(--font-sans); + --default-mono-font-family: var(--font-mono); + } +} +@layer base { + *, ::after, ::before, ::backdrop, ::file-selector-button { + box-sizing: border-box; + margin: 0; + padding: 0; + border: 0 solid; + } + html, :host { + line-height: 1.5; + -webkit-text-size-adjust: 100%; + tab-size: 4; + font-family: var(--default-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"); + font-feature-settings: var(--default-font-feature-settings, normal); + font-variation-settings: var(--default-font-variation-settings, normal); + -webkit-tap-highlight-color: transparent; + } + 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; + -webkit-text-decoration: inherit; + text-decoration: inherit; + } + b, strong { + font-weight: bolder; + } + code, kbd, samp, pre { + font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace); + font-feature-settings: var(--default-mono-font-feature-settings, normal); + font-variation-settings: var(--default-mono-font-variation-settings, normal); + font-size: 1em; + } + small { + font-size: 80%; + } + sub, sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; + } + sub { + bottom: -0.25em; + } + sup { + top: -0.5em; + } + table { + text-indent: 0; + border-color: inherit; + border-collapse: collapse; + } + :-moz-focusring:where(:not(iframe)) { + outline: auto; + } + progress { + vertical-align: baseline; + } + summary { + display: list-item; + } + ol, ul, menu { + list-style: none; + } + img, svg, video, canvas, audio, iframe, embed, object { + display: block; + vertical-align: middle; + } + img, video { + max-width: 100%; + height: auto; + } + button, input, select, optgroup, textarea, ::file-selector-button { + font: inherit; + font-feature-settings: inherit; + font-variation-settings: inherit; + letter-spacing: inherit; + color: inherit; + border-radius: 0; + background-color: transparent; + opacity: 1; + } + :where(select:is([multiple], [size])) optgroup { + font-weight: bolder; + } + :where(select:is([multiple], [size])) optgroup option { + padding-inline-start: 20px; + } + ::file-selector-button { + margin-inline-end: 4px; + } + ::placeholder { + opacity: 1; + } + @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) { + ::placeholder { + color: currentcolor; + @supports (color: color-mix(in lab, red, red)) { + color: color-mix(in oklab, currentcolor 50%, transparent); + } + } + } + textarea { + resize: vertical; + } + ::-webkit-search-decoration { + -webkit-appearance: none; + } + ::-webkit-date-and-time-value { + min-height: 1lh; + text-align: inherit; + } + ::-webkit-datetime-edit { + display: inline-flex; + } + ::-webkit-datetime-edit-fields-wrapper { + padding: 0; + } + ::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field { + padding-block: 0; + } + ::-webkit-calendar-picker-indicator { + line-height: 1; + } + :-moz-ui-invalid { + box-shadow: none; + } + button, input:where([type="button"], [type="reset"], [type="submit"]), ::file-selector-button { + appearance: button; + } + ::-webkit-inner-spin-button, ::-webkit-outer-spin-button { + height: auto; + } + [hidden]:where(:not([hidden="until-found"])) { + display: none !important; + } +} +@layer utilities { + .visible { + visibility: visible; + } + .sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border-width: 0; + } + .absolute { + position: absolute; + } + .fixed { + position: fixed; + } + .relative { + position: relative; + } + .static { + position: static; + } + .top-full { + top: 100%; + } + .right-0 { + right: 0px; + } + .right-4 { + right: calc(var(--spacing) * 4); + } + .bottom-4 { + bottom: calc(var(--spacing) * 4); + } + .z-50 { + z-index: 50; + } + .z-\[100\] { + z-index: 100; + } + .m-3 { + margin: calc(var(--spacing) * 3); + } + .m-5 { + margin: calc(var(--spacing) * 5); + } + .mx-auto { + margin-inline: auto; + } + .my-3 { + margin-block: calc(var(--spacing) * 3); + } + .my-auto { + margin-block: auto; + } + .mt-1 { + margin-top: var(--spacing); + } + .mt-2 { + margin-top: calc(var(--spacing) * 2); + } + .mt-3 { + margin-top: calc(var(--spacing) * 3); + } + .mt-5 { + margin-top: calc(var(--spacing) * 5); + } + .mt-6 { + margin-top: calc(var(--spacing) * 6); + } + .mt-7 { + margin-top: calc(var(--spacing) * 7); + } + .mt-auto { + margin-top: auto; + } + .mb-3 { + margin-bottom: calc(var(--spacing) * 3); + } + .mb-5 { + margin-bottom: calc(var(--spacing) * 5); + } + .ml-auto { + margin-left: auto; + } + .block { + display: block; + } + .flex { + display: flex; + } + .grid { + display: grid; + } + .hidden { + display: none; + } + .inline-flex { + display: inline-flex; + } + .h-2 { + height: calc(var(--spacing) * 2); + } + .h-4 { + height: calc(var(--spacing) * 4); + } + .h-6 { + height: calc(var(--spacing) * 6); + } + .h-16 { + height: calc(var(--spacing) * 16); + } + .h-20 { + height: calc(var(--spacing) * 20); + } + .h-full { + height: 100%; + } + .max-h-56 { + max-height: calc(var(--spacing) * 56); + } + .min-h-10 { + min-height: calc(var(--spacing) * 10); + } + .min-h-40 { + min-height: calc(var(--spacing) * 40); + } + .min-h-screen { + min-height: 100vh; + } + .w-2 { + width: calc(var(--spacing) * 2); + } + .w-4 { + width: calc(var(--spacing) * 4); + } + .w-6 { + width: calc(var(--spacing) * 6); + } + .w-20 { + width: calc(var(--spacing) * 20); + } + .w-40 { + width: calc(var(--spacing) * 40); + } + .w-64 { + width: calc(var(--spacing) * 64); + } + .w-full { + width: 100%; + } + .max-w-2xl { + max-width: var(--container-2xl); + } + .max-w-3xl { + max-width: var(--container-3xl); + } + .max-w-5xl { + max-width: var(--container-5xl); + } + .max-w-sm { + max-width: var(--container-sm); + } + .min-w-0 { + min-width: 0px; + } + .min-w-65 { + min-width: calc(var(--spacing) * 65); + } + .flex-1 { + flex: 1; + } + .shrink-0 { + flex-shrink: 0; + } + .transform { + transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,); + } + .cursor-pointer { + cursor: pointer; + } + .grid-cols-1 { + grid-template-columns: repeat(1, minmax(0, 1fr)); + } + .grid-cols-3 { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } + .flex-col { + flex-direction: column; + } + .flex-wrap { + flex-wrap: wrap; + } + .place-items-center { + place-items: center; + } + .items-center { + align-items: center; + } + .items-end { + align-items: flex-end; + } + .items-start { + align-items: flex-start; + } + .justify-between { + justify-content: space-between; + } + .justify-center { + justify-content: center; + } + .justify-end { + justify-content: flex-end; + } + .gap-1 { + gap: var(--spacing); + } + .gap-2 { + gap: calc(var(--spacing) * 2); + } + .gap-3 { + gap: calc(var(--spacing) * 3); + } + .gap-4 { + gap: calc(var(--spacing) * 4); + } + .gap-5 { + gap: calc(var(--spacing) * 5); + } + .gap-6 { + gap: calc(var(--spacing) * 6); + } + :where(.space-y-2 > :not(:last-child)) { + --tw-space-y-reverse: 0; + margin-block-start: calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse)); + margin-block-end: calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse))); + } + :where(.space-y-3 > :not(:last-child)) { + --tw-space-y-reverse: 0; + margin-block-start: calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse)); + margin-block-end: calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse))); + } + .self-start { + align-self: flex-start; + } + .truncate { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .overflow-hidden { + overflow: hidden; + } + .overflow-y-auto { + overflow-y: auto; + } + .rounded { + border-radius: 0.25rem; + } + .rounded-2xl { + border-radius: var(--radius-2xl); + } + .rounded-\[0\.5rem\] { + border-radius: 0.5rem; + } + .rounded-\[1rem\] { + border-radius: 1rem; + } + .rounded-\[2rem\] { + border-radius: 2rem; + } + .rounded-full { + border-radius: calc(infinity * 1px); + } + .rounded-lg { + border-radius: var(--radius-lg); + } + .rounded-xl { + border-radius: var(--radius-xl); + } + .border { + border-style: var(--tw-border-style); + border-width: 1px; + } + .border-2 { + border-style: var(--tw-border-style); + border-width: 2px; + } + .border-t { + border-top-style: var(--tw-border-style); + border-top-width: 1px; + } + .border-r { + border-right-style: var(--tw-border-style); + border-right-width: 1px; + } + .border-b { + border-bottom-style: var(--tw-border-style); + border-bottom-width: 1px; + } + .border-l { + border-left-style: var(--tw-border-style); + border-left-width: 1px; + } + .border-dashed { + --tw-border-style: dashed; + border-style: dashed; + } + .border-amber-300\/40 { + border-color: color-mix(in srgb, oklch(87.9% 0.169 91.605) 40%, transparent); + @supports (color: color-mix(in lab, red, red)) { + border-color: color-mix(in oklab, var(--color-amber-300) 40%, transparent); + } + } + .border-cyan-300 { + border-color: var(--color-cyan-300); + } + .border-cyan-300\/40 { + border-color: color-mix(in srgb, oklch(86.5% 0.127 207.078) 40%, transparent); + @supports (color: color-mix(in lab, red, red)) { + border-color: color-mix(in oklab, var(--color-cyan-300) 40%, transparent); + } + } + .border-emerald-400 { + border-color: var(--color-emerald-400); + } + .border-red-400 { + border-color: var(--color-red-400); + } + .border-slate-700 { + border-color: var(--color-slate-700); + } + .border-slate-800 { + border-color: var(--color-slate-800); + } + .bg-amber-300\/10 { + background-color: color-mix(in srgb, oklch(87.9% 0.169 91.605) 10%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-amber-300) 10%, transparent); + } + } + .bg-cyan-300 { + background-color: var(--color-cyan-300); + } + .bg-cyan-300\/10 { + background-color: color-mix(in srgb, oklch(86.5% 0.127 207.078) 10%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-cyan-300) 10%, transparent); + } + } + .bg-emerald-400 { + background-color: var(--color-emerald-400); + } + .bg-emerald-400\/10 { + background-color: color-mix(in srgb, oklch(76.5% 0.177 163.223) 10%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-emerald-400) 10%, transparent); + } + } + .bg-emerald-600 { + background-color: var(--color-emerald-600); + } + .bg-red-500\/90 { + background-color: color-mix(in srgb, oklch(63.7% 0.237 25.331) 90%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-red-500) 90%, transparent); + } + } + .bg-slate-600 { + background-color: var(--color-slate-600); + } + .bg-slate-800 { + background-color: var(--color-slate-800); + } + .bg-slate-900 { + background-color: var(--color-slate-900); + } + .bg-slate-900\/40 { + background-color: color-mix(in srgb, oklch(20.8% 0.042 265.755) 40%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-slate-900) 40%, transparent); + } + } + .bg-slate-900\/60 { + background-color: color-mix(in srgb, oklch(20.8% 0.042 265.755) 60%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-slate-900) 60%, transparent); + } + } + .bg-slate-950 { + background-color: var(--color-slate-950); + } + .bg-slate-950\/40 { + background-color: color-mix(in srgb, oklch(12.9% 0.042 264.695) 40%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-slate-950) 40%, transparent); + } + } + .p-0\.5 { + padding: calc(var(--spacing) * 0.5); + } + .p-1\.5 { + padding: calc(var(--spacing) * 1.5); + } + .p-2 { + padding: calc(var(--spacing) * 2); + } + .p-5 { + padding: calc(var(--spacing) * 5); + } + .p-6 { + padding: calc(var(--spacing) * 6); + } + .px-2 { + padding-inline: calc(var(--spacing) * 2); + } + .px-3 { + padding-inline: calc(var(--spacing) * 3); + } + .px-4 { + padding-inline: calc(var(--spacing) * 4); + } + .px-5 { + padding-inline: calc(var(--spacing) * 5); + } + .px-6 { + padding-inline: calc(var(--spacing) * 6); + } + .px-7 { + padding-inline: calc(var(--spacing) * 7); + } + .px-10 { + padding-inline: calc(var(--spacing) * 10); + } + .py-1 { + padding-block: var(--spacing); + } + .py-1\.5 { + padding-block: calc(var(--spacing) * 1.5); + } + .py-2 { + padding-block: calc(var(--spacing) * 2); + } + .py-2\.5 { + padding-block: calc(var(--spacing) * 2.5); + } + .py-3 { + padding-block: calc(var(--spacing) * 3); + } + .py-4 { + padding-block: calc(var(--spacing) * 4); + } + .py-5 { + padding-block: calc(var(--spacing) * 5); + } + .py-6 { + padding-block: calc(var(--spacing) * 6); + } + .py-10 { + padding-block: calc(var(--spacing) * 10); + } + .pt-1 { + padding-top: var(--spacing); + } + .pt-5 { + padding-top: calc(var(--spacing) * 5); + } + .text-center { + text-align: center; + } + .text-right { + text-align: right; + } + .font-mono { + font-family: var(--font-mono); + } + .text-2xl { + font-size: var(--text-2xl); + line-height: var(--tw-leading, var(--text-2xl--line-height)); + } + .text-3xl { + font-size: var(--text-3xl); + line-height: var(--tw-leading, var(--text-3xl--line-height)); + } + .text-4xl { + font-size: var(--text-4xl); + line-height: var(--tw-leading, var(--text-4xl--line-height)); + } + .text-5xl { + font-size: var(--text-5xl); + line-height: var(--tw-leading, var(--text-5xl--line-height)); + } + .text-lg { + font-size: var(--text-lg); + line-height: var(--tw-leading, var(--text-lg--line-height)); + } + .text-sm { + font-size: var(--text-sm); + line-height: var(--tw-leading, var(--text-sm--line-height)); + } + .text-xl { + font-size: var(--text-xl); + line-height: var(--tw-leading, var(--text-xl--line-height)); + } + .text-xs { + font-size: var(--text-xs); + line-height: var(--tw-leading, var(--text-xs--line-height)); + } + .font-medium { + --tw-font-weight: var(--font-weight-medium); + font-weight: var(--font-weight-medium); + } + .font-semibold { + --tw-font-weight: var(--font-weight-semibold); + font-weight: var(--font-weight-semibold); + } + .tracking-tight { + --tw-tracking: var(--tracking-tight); + letter-spacing: var(--tracking-tight); + } + .tracking-widest { + --tw-tracking: var(--tracking-widest); + letter-spacing: var(--tracking-widest); + } + .whitespace-nowrap { + white-space: nowrap; + } + .text-amber-300 { + color: var(--color-amber-300); + } + .text-cyan-300 { + color: var(--color-cyan-300); + } + .text-emerald-300 { + color: var(--color-emerald-300); + } + .text-red-300 { + color: var(--color-red-300); + } + .text-slate-100 { + color: var(--color-slate-100); + } + .text-slate-200 { + color: var(--color-slate-200); + } + .text-slate-300 { + color: var(--color-slate-300); + } + .text-slate-400 { + color: var(--color-slate-400); + } + .text-slate-600 { + color: var(--color-slate-600); + } + .text-slate-950 { + color: var(--color-slate-950); + } + .text-white { + color: var(--color-white); + } + .uppercase { + text-transform: uppercase; + } + .accent-cyan-300 { + accent-color: var(--color-cyan-300); + } + .opacity-100 { + opacity: 100%; + } + .transition-colors { + transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to; + transition-timing-function: var(--tw-ease, var(--default-transition-timing-function)); + transition-duration: var(--tw-duration, var(--default-transition-duration)); + } + .transition-opacity { + transition-property: opacity; + transition-timing-function: var(--tw-ease, var(--default-transition-timing-function)); + transition-duration: var(--tw-duration, var(--default-transition-duration)); + } + .outline-none { + --tw-outline-style: none; + outline-style: none; + } + @media (hover: hover) { + .group-hover\:block:is(:where(.group):hover *) { + display: block; + } + } + .peer-focus-visible\:border-cyan-300:is(:where(.peer):focus-visible ~ *) { + border-color: var(--color-cyan-300); + } + .peer-focus-visible\:outline:is(:where(.peer):focus-visible ~ *) { + outline-style: var(--tw-outline-style); + outline-width: 1px; + } + .peer-focus-visible\:outline-2:is(:where(.peer):focus-visible ~ *) { + outline-style: var(--tw-outline-style); + outline-width: 2px; + } + .peer-focus-visible\:outline-cyan-300:is(:where(.peer):focus-visible ~ *) { + outline-color: var(--color-cyan-300); + } + .focus-within\:border-cyan-300:focus-within { + border-color: var(--color-cyan-300); + } + @media (hover: hover) { + .hover\:border-cyan-300:hover { + border-color: var(--color-cyan-300); + } + .hover\:border-red-400:hover { + border-color: var(--color-red-400); + } + .hover\:bg-cyan-200:hover { + background-color: var(--color-cyan-200); + } + .hover\:bg-cyan-300:hover { + background-color: var(--color-cyan-300); + } + .hover\:bg-cyan-300\/5:hover { + background-color: color-mix(in srgb, oklch(86.5% 0.127 207.078) 5%, transparent); + } + @supports (color: color-mix(in lab, red, red)) { + .hover\:bg-cyan-300\/5:hover { + background-color: color-mix(in oklab, var(--color-cyan-300) 5%, transparent); + } + } + .hover\:bg-red-500:hover { + background-color: var(--color-red-500); + } + .hover\:text-black:hover { + color: var(--color-black); + } + .hover\:text-cyan-200:hover { + color: var(--color-cyan-200); + } + .hover\:text-cyan-300:hover { + color: var(--color-cyan-300); + } + .hover\:text-red-300:hover { + color: var(--color-red-300); + } + .hover\:text-slate-950:hover { + color: var(--color-slate-950); + } + .hover\:text-white:hover { + color: var(--color-white); + } + } + .focus\:border-cyan-300:focus { + border-color: var(--color-cyan-300); + } + .disabled\:cursor-not-allowed:disabled { + cursor: not-allowed; + } + .disabled\:cursor-wait:disabled { + cursor: wait; + } + .disabled\:bg-slate-700:disabled { + background-color: var(--color-slate-700); + } + .disabled\:text-slate-400:disabled { + color: var(--color-slate-400); + } + .disabled\:opacity-50:disabled { + opacity: 50%; + } + @media (width >= 40rem) { + .sm\:pointer-events-none { + pointer-events: none; + } + .sm\:grid-cols-2 { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + .sm\:p-8 { + padding: calc(var(--spacing) * 8); + } + .sm\:opacity-0 { + opacity: 0%; + } + .sm\:group-focus-within\:pointer-events-auto:is(:where(.group):focus-within *) { + pointer-events: auto; + } + .sm\:group-focus-within\:opacity-100:is(:where(.group):focus-within *) { + opacity: 100%; + } + @media (hover: hover) { + .sm\:group-hover\:pointer-events-auto:is(:where(.group):hover *) { + pointer-events: auto; + } + .sm\:group-hover\:opacity-100:is(:where(.group):hover *) { + opacity: 100%; + } + } + } + @media (width >= 64rem) { + .lg\:grid-cols-2 { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + .lg\:grid-cols-3 { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } + } + @media (width >= 80rem) { + .xl\:grid-cols-5 { + grid-template-columns: repeat(5, minmax(0, 1fr)); + } + } +} +@property --tw-rotate-x { + syntax: "*"; + inherits: false; +} +@property --tw-rotate-y { + syntax: "*"; + inherits: false; +} +@property --tw-rotate-z { + syntax: "*"; + inherits: false; +} +@property --tw-skew-x { + syntax: "*"; + inherits: false; +} +@property --tw-skew-y { + syntax: "*"; + inherits: false; +} +@property --tw-space-y-reverse { + syntax: "*"; + inherits: false; + initial-value: 0; +} +@property --tw-border-style { + syntax: "*"; + inherits: false; + initial-value: solid; +} +@property --tw-font-weight { + syntax: "*"; + inherits: false; +} +@property --tw-tracking { + syntax: "*"; + inherits: false; +} +@property --tw-outline-style { + syntax: "*"; + inherits: false; + initial-value: solid; +} +@layer properties { + @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) { + *, ::before, ::after, ::backdrop { + --tw-rotate-x: initial; + --tw-rotate-y: initial; + --tw-rotate-z: initial; + --tw-skew-x: initial; + --tw-skew-y: initial; + --tw-space-y-reverse: 0; + --tw-border-style: solid; + --tw-font-weight: initial; + --tw-tracking: initial; + --tw-outline-style: solid; + } + } +} diff --git a/pamsave/packages/web/assets/user.svg b/pamsave/packages/web/assets/user.svg new file mode 100755 index 0000000..3460e51 --- /dev/null +++ b/pamsave/packages/web/assets/user.svg @@ -0,0 +1 @@ + diff --git a/pamsave/packages/web/dioxus.toml b/pamsave/packages/web/dioxus.toml new file mode 100755 index 0000000..82355b4 --- /dev/null +++ b/pamsave/packages/web/dioxus.toml @@ -0,0 +1,7 @@ +[application] +name = "pamsave" + +[features] +default = ["web"] +web = ["web/web"] +server = ["web/server"] diff --git a/pamsave/packages/web/input.css b/pamsave/packages/web/input.css new file mode 100755 index 0000000..95c662c --- /dev/null +++ b/pamsave/packages/web/input.css @@ -0,0 +1,5 @@ +@import "tailwindcss"; + +@source "./src/**/*.{rs,html,css}"; +@source "../ui/src/**/*.{rs,html,css}"; +@source "../ui/assets/**/*.{css,html}"; diff --git a/pamsave/packages/web/package-lock.json b/pamsave/packages/web/package-lock.json new file mode 100755 index 0000000..0d0927d --- /dev/null +++ b/pamsave/packages/web/package-lock.json @@ -0,0 +1,1169 @@ +{ + "name": "web", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "@tailwindcss/cli": "^4.3.3", + "tailwindcss": "^4.3.3" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@parcel/watcher": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz", + "integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "detect-libc": "^1.0.3", + "is-glob": "^4.0.3", + "micromatch": "^4.0.5", + "node-addon-api": "^7.0.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.5.1", + "@parcel/watcher-darwin-arm64": "2.5.1", + "@parcel/watcher-darwin-x64": "2.5.1", + "@parcel/watcher-freebsd-x64": "2.5.1", + "@parcel/watcher-linux-arm-glibc": "2.5.1", + "@parcel/watcher-linux-arm-musl": "2.5.1", + "@parcel/watcher-linux-arm64-glibc": "2.5.1", + "@parcel/watcher-linux-arm64-musl": "2.5.1", + "@parcel/watcher-linux-x64-glibc": "2.5.1", + "@parcel/watcher-linux-x64-musl": "2.5.1", + "@parcel/watcher-win32-arm64": "2.5.1", + "@parcel/watcher-win32-ia32": "2.5.1", + "@parcel/watcher-win32-x64": "2.5.1" + } + }, + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz", + "integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz", + "integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz", + "integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz", + "integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz", + "integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz", + "integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz", + "integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz", + "integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz", + "integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz", + "integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz", + "integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz", + "integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz", + "integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@tailwindcss/cli": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/cli/-/cli-4.3.3.tgz", + "integrity": "sha512-ZvS/n1ZHOBKcVlhkt8l5NNr1EDXk1NboYO5CYDOs6NUmvT9z6bzkwsosaJftY57T/3gWNzWMJzIXLodZC8ssdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@parcel/watcher": "2.5.1", + "@tailwindcss/node": "4.3.3", + "@tailwindcss/oxide": "4.3.3", + "enhanced-resolve": "^5.24.1", + "mri": "^1.2.0", + "picocolors": "^1.1.1", + "tailwindcss": "4.3.3" + }, + "bin": { + "tailwindcss": "dist/index.mjs" + } + }, + "node_modules/@tailwindcss/node": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.3.tgz", + "integrity": "sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "enhanced-resolve": "^5.24.1", + "jiti": "^2.7.0", + "lightningcss": "1.32.0", + "magic-string": "^0.30.21", + "source-map-js": "^1.2.1", + "tailwindcss": "4.3.3" + } + }, + "node_modules/@tailwindcss/oxide": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.3.tgz", + "integrity": "sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.3.3", + "@tailwindcss/oxide-darwin-arm64": "4.3.3", + "@tailwindcss/oxide-darwin-x64": "4.3.3", + "@tailwindcss/oxide-freebsd-x64": "4.3.3", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.3", + "@tailwindcss/oxide-linux-arm64-gnu": "4.3.3", + "@tailwindcss/oxide-linux-arm64-musl": "4.3.3", + "@tailwindcss/oxide-linux-x64-gnu": "4.3.3", + "@tailwindcss/oxide-linux-x64-musl": "4.3.3", + "@tailwindcss/oxide-wasm32-wasi": "4.3.3", + "@tailwindcss/oxide-win32-arm64-msvc": "4.3.3", + "@tailwindcss/oxide-win32-x64-msvc": "4.3.3" + } + }, + "node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.3.tgz", + "integrity": "sha512-Y85A2gmPSkl5Ve5qR86GL4HT509cFqQh1aes9p3sSkyTPwt0Pppf3GkwGe4JPACcRYjgJIEhQgM6dBClnr0NYw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.3.tgz", + "integrity": "sha512-BiaWatpBcERQFDlOjRDpIVXuFK5PJez5SA4JMg6VYZdBYU+qKfV/vqjcIs+IYmtitf1xYQZTwXvU/8y4lfZUGw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.3.tgz", + "integrity": "sha512-fAeUqfV5ndhxRwai8cXGzdLvul9utWOmeTkv69unv4ZXixjn61Z+p9lCWdwOwA3TYboG3BwdVuN/RDjhBRl0mw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.3.tgz", + "integrity": "sha512-iyf5bV6+wnAlflVeEy7R25dupxTNECZN5QMI0qNT6eT+EgaGdZcKhGkr5SdoaWiLJ3spLqIY9VCeSGrwmtg4kw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.3.tgz", + "integrity": "sha512-aAYUprJAJQWWbRrPvtjdroZ56Md+JM8pMiopS6xGEwDfLhqj+2ver2p4nU4Mb3CRqcMmNBjo8KkUgcxhkzVQGQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.3.tgz", + "integrity": "sha512-nDxldcEENOxZRzC2uu9jrutZdAAQtb+8WWDCSnWL1zvBk1+FN+x6MtDViPB5AJMfttVCUhehGWus3XBPgatM/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.3.tgz", + "integrity": "sha512-Md44bD6veX/PC5iyF8cDVnw4HBIANZepRZZ7a8DQOvkfo5WUBwcp6iAuCUz23u+4SUkhJlD3eL7hNdW8ezd/kA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.3.tgz", + "integrity": "sha512-tx7us1muwOKAKWao2v/GaafFeQboE6aj88vC6ziN2NCGcRm8gWUhwjzg+YdVB1e4boAtdtma4L43onunI6NS4w==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.3.tgz", + "integrity": "sha512-SJxX60smvHgasZoBy11dX6YRjXJFovwWBoedhbQPOBzgFWBHGB+TVPWB9BxzR7TTxU8FQZAI2AyiNCMzFm8Img==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.3.tgz", + "integrity": "sha512-jx1+rPhY/5Ympkktd656HBWEBLxP7dH06losBLjjf5vgCODXvi9KhtftWcMIwTFIDqBr7cRnQkdLnAG+IOlGvQ==", + "bundleDependencies": [ + "@napi-rs/wasm-runtime", + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util", + "@emnapi/wasi-threads", + "tslib" + ], + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.11.1", + "@emnapi/runtime": "^1.11.1", + "@emnapi/wasi-threads": "^1.2.2", + "@napi-rs/wasm-runtime": "^1.1.4", + "@tybys/wasm-util": "^0.10.2", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.3.tgz", + "integrity": "sha512-3rc292Ca2ceK6Ulcc/bAVnTs/3nDtoPhyEKlgPv+yQJQi/JS/AMJlqzxvlDacL1nekbrcf6bTqp/jV4qgnPxNQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.3.tgz", + "integrity": "sha512-yJ0pwIVc/nYeGoV02WtsN8KYyLQv7kyI2wDnkezyJlGGjkd4QLwDGAwl47YpPJeuI0M0ObaXGSPjvWDPeTPggw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "detect-libc": "bin/detect-libc.js" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/enhanced-resolve": { + "version": "5.25.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.25.1.tgz", + "integrity": "sha512-nGXts5znJzmWPu+mIE9izCOzdg63oJca2mDzGWWTth7sr4aCToKcoyFVBQwN75Ij5Pf6p510EwkTqViTRzDV+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.3.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss/node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tailwindcss": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz", + "integrity": "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/tapable": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + } + } +} diff --git a/pamsave/packages/web/package.json b/pamsave/packages/web/package.json new file mode 100755 index 0000000..0aebfec --- /dev/null +++ b/pamsave/packages/web/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "@tailwindcss/cli": "^4.3.3", + "tailwindcss": "^4.3.3" + } +} diff --git a/pamsave/packages/web/src/api_client.rs b/pamsave/packages/web/src/api_client.rs new file mode 100755 index 0000000..aee3fdf --- /dev/null +++ b/pamsave/packages/web/src/api_client.rs @@ -0,0 +1,340 @@ +use api::dto::{ + AddUserRequest, AuthRequest, AuthResponse, ChangePasswordRequest, FileResponse, MeResponse, + MyWorkspaceResponse, NewAuthPolicy, NewWorkspace, WorkspaceResponse, +}; +use gloo_net::http::Request; +use serde::{de::DeserializeOwned, Serialize}; +use uuid::Uuid; +use web_sys::{Blob, BlobPropertyBag, FormData}; + +#[derive(Debug, Clone)] +pub enum ApiClientError { + BuildRequest(String), + Request(String), + Response(String), + Status(u16, String), +} + +impl std::fmt::Display for ApiClientError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::BuildRequest(err) => write!(f, "failed to build request: {err}"), + Self::Request(err) => write!(f, "request failed: {err}"), + Self::Response(err) => write!(f, "failed to read response: {err}"), + Self::Status(status, message) if message.is_empty() => { + write!(f, "unexpected status code: {status}") + } + Self::Status(_status, message) => write!(f, "{message}"), + } + } +} + +pub struct ApiClient; + +impl ApiClient { + pub async fn login(req: AuthRequest) -> Result { + post_json("/api/auth/login", &req, None).await + } + + pub async fn register(req: AuthRequest) -> Result { + post_json("/api/auth/register", &req, None).await + } + + pub async fn me(token: &str) -> Result { + get_json("/api/auth/me", token).await + } + + pub async fn logout(token: &str) -> Result<(), ApiClientError> { + let response = Request::post("/api/auth/logout") + .header("Authorization", &format!("Bearer {token}")) + .send() + .await + .map_err(|err| ApiClientError::Request(err.to_string()))?; + + expect_ok(response).await + } + + pub async fn change_password( + current: String, + new: String, + token: &str, + ) -> Result<(), ApiClientError> { + post( + "/api/auth/password", + &ChangePasswordRequest { + current_password: current, + new_password: new, + }, + Some(token), + ) + .await + } + + pub async fn create_workspace( + req: NewWorkspace, + token: &str, + ) -> Result { + post_json("/api/workspace", &req, Some(token)).await + } + + pub async fn get_my_workspace(token: &str) -> Result { + get_json("/api/workspace", token).await + } + + pub async fn add_user( + workspace_id: Uuid, + username: &str, + token: &str, + ) -> Result<(), ApiClientError> { + post( + &format!("/api/workspace/{workspace_id}/users"), + &AddUserRequest { + username: username.to_string(), + }, + Some(token), + ) + .await + } + + pub async fn remove_workspace_user( + workspace_id: Uuid, + user_id: Uuid, + token: &str, + ) -> Result<(), ApiClientError> { + let response = Request::delete(&format!("/api/workspace/{workspace_id}/users/{user_id}")) + .header("Authorization", &format!("Bearer {token}")) + .send() + .await + .map_err(|err| ApiClientError::Request(err.to_string()))?; + + expect_ok(response).await + } + + pub async fn add_auth_policy( + workspace_id: Uuid, + name: String, + content: String, + token: &str, + ) -> Result<(), ApiClientError> { + post( + &format!("/api/workspace/{workspace_id}/auth_policy"), + &NewAuthPolicy { name, content }, + Some(token), + ) + .await + } + + pub async fn upload_personal_file( + files: Vec<(String, Vec)>, + is_public: bool, + token: &str, + ) -> Result, ApiClientError> { + let mut uploaded = Vec::new(); + + for (name, bytes) in files { + let form = build_multipart_form(&name, bytes, is_public)?; + + let response = Request::post("/api/files") + .header("Authorization", &format!("Bearer {token}")) + .body(form) + .map_err(|e| ApiClientError::BuildRequest(e.to_string()))? + .send() + .await + .map_err(|e| ApiClientError::Request(e.to_string()))?; + + uploaded.push(read_json_response(response).await?); + } + + Ok(uploaded) + } + + pub async fn upload_file( + workspace_id: Uuid, + files: Vec<(String, Vec)>, + is_public: bool, + token: &str, + ) -> Result, ApiClientError> { + let mut uploaded = Vec::new(); + + for (name, bytes) in files { + let form = build_multipart_form(&name, bytes, is_public)?; + + let response = Request::post(&format!("/api/workspace/{workspace_id}/files")) + .header("Authorization", &format!("Bearer {token}")) + .body(form) + .map_err(|e| ApiClientError::BuildRequest(e.to_string()))? + .send() + .await + .map_err(|e| ApiClientError::Request(e.to_string()))?; + + uploaded.push(read_json_response(response).await?); + } + + Ok(uploaded) + } + + pub async fn get_workspace_files( + workspace_id: Uuid, + page: u32, + token: &str, + ) -> Result, ApiClientError> { + get_json( + &format!("/api/workspace/{workspace_id}/files?page={page}"), + token, + ) + .await + } + + pub async fn get_my_files(page: u32, token: &str) -> Result, ApiClientError> { + get_json(&format!("/api/my-files?page={page}"), token).await + } + + pub async fn get_public_files( + page: u32, + token: &str, + ) -> Result, ApiClientError> { + get_json(&format!("/api/files?page={page}"), token).await + } + + pub async fn download_file(file_id: Uuid, token: &str) -> Result, ApiClientError> { + let response = Request::get(&format!("/api/files/{file_id}")) + .header("Authorization", &format!("Bearer {token}")) + .send() + .await + .map_err(|err| ApiClientError::Request(err.to_string()))?; + + if !response.ok() { + return Err(status_error(response).await); + } + + response + .binary() + .await + .map_err(|err| ApiClientError::Response(err.to_string())) + } + + pub async fn delete_file(file_id: Uuid, token: &str) -> Result<(), ApiClientError> { + let response = Request::delete(&format!("/api/files/{file_id}")) + .header("Authorization", &format!("Bearer {token}")) + .send() + .await + .map_err(|err| ApiClientError::Request(err.to_string()))?; + + expect_ok(response).await + } +} + +fn build_multipart_form( + name: &str, + bytes: Vec, + is_public: bool, +) -> Result { + let form = FormData::new().map_err(|e| ApiClientError::BuildRequest(format!("{e:?}")))?; + + let uint8 = js_sys::Uint8Array::from(bytes.as_slice()); + let parts = js_sys::Array::new(); + parts.push(&uint8); + + let opts = BlobPropertyBag::new(); + opts.set_type("application/octet-stream"); + let blob = Blob::new_with_u8_array_sequence_and_options(&parts, &opts) + .map_err(|e| ApiClientError::BuildRequest(format!("{e:?}")))?; + + form.append_with_blob_and_filename("file", &blob, name) + .map_err(|e| ApiClientError::BuildRequest(format!("{e:?}")))?; + + form.append_with_str("public", if is_public { "true" } else { "false" }) + .map_err(|e| ApiClientError::BuildRequest(format!("{e:?}")))?; + + Ok(form) +} + +async fn post(path: &str, body: &T, auth_token: Option<&str>) -> Result<(), ApiClientError> +where + T: Serialize, +{ + let response = send_post(path, body, auth_token).await?; + + expect_ok(response).await +} + +async fn post_json( + path: &str, + body: &T, + auth_token: Option<&str>, +) -> Result +where + T: Serialize, + R: DeserializeOwned, +{ + let response = send_post(path, body, auth_token).await?; + + read_json_response(response).await +} + +async fn send_post( + path: &str, + body: &T, + auth_token: Option<&str>, +) -> Result +where + T: Serialize, +{ + let mut request = Request::post(path); + if let Some(token) = auth_token { + request = request.header("Authorization", &format!("Bearer {token}")); + } + + let request = request + .json(body) + .map_err(|err| ApiClientError::BuildRequest(err.to_string()))?; + + request + .send() + .await + .map_err(|err| ApiClientError::Request(err.to_string())) +} + +async fn expect_ok(response: gloo_net::http::Response) -> Result<(), ApiClientError> { + if response.ok() { + Ok(()) + } else { + Err(status_error(response).await) + } +} + +async fn read_json_response(response: gloo_net::http::Response) -> Result +where + R: DeserializeOwned, +{ + if !response.ok() { + return Err(status_error(response).await); + } + + response + .json() + .await + .map_err(|err| ApiClientError::Response(err.to_string())) +} + +async fn status_error(response: gloo_net::http::Response) -> ApiClientError { + let status = response.status(); + + match response.json::().await { + Ok(error) => ApiClientError::Status(status, error.error), + Err(_) => ApiClientError::Status(status, String::new()), + } +} + +async fn get_json(path: &str, token: &str) -> Result +where + R: DeserializeOwned, +{ + let response = Request::get(path) + .header("Authorization", &format!("Bearer {token}")) + .send() + .await + .map_err(|err| ApiClientError::Request(err.to_string()))?; + + read_json_response(response).await +} diff --git a/pamsave/packages/web/src/auth.rs b/pamsave/packages/web/src/auth.rs new file mode 100755 index 0000000..2ba8270 --- /dev/null +++ b/pamsave/packages/web/src/auth.rs @@ -0,0 +1,70 @@ +use dioxus::prelude::*; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct AuthUser { + pub username: String, + pub token: String, + pub workspace_id: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub enum AuthState { + Checking, + Guest, + User(AuthUser), +} + +#[derive(Clone)] +pub struct Auth(pub Signal); + +impl AuthState { + pub fn user(&self) -> Option<&AuthUser> { + match self { + Self::User(user) => Some(user), + _ => None, + } + } + + pub fn user_cloned(&self) -> Option { + self.user().cloned() + } + + pub fn is_guest(&self) -> bool { + matches!(self, Self::Guest) + } + +} + +#[cfg_attr(not(feature = "web"), allow(dead_code))] +const STORAGE_KEY: &str = "pamsave.auth"; + +#[cfg(feature = "web")] +pub fn persist(user: &AuthUser) { + use gloo_storage::{LocalStorage, Storage}; + let _ = LocalStorage::set(STORAGE_KEY, user); +} + +#[cfg(feature = "web")] +pub fn restore() -> Option { + use gloo_storage::{LocalStorage, Storage}; + LocalStorage::get::(STORAGE_KEY).ok() +} + +#[cfg(feature = "web")] +pub fn clear_persisted() { + use gloo_storage::{LocalStorage, Storage}; + LocalStorage::delete(STORAGE_KEY); +} + +#[cfg(not(feature = "web"))] +pub fn persist(_user: &AuthUser) {} + +#[cfg(not(feature = "web"))] +pub fn restore() -> Option { + None +} + +#[cfg(not(feature = "web"))] +pub fn clear_persisted() {} diff --git a/pamsave/packages/web/src/components/auth/form.rs b/pamsave/packages/web/src/components/auth/form.rs new file mode 100755 index 0000000..8cd0743 --- /dev/null +++ b/pamsave/packages/web/src/components/auth/form.rs @@ -0,0 +1,90 @@ +use dioxus::prelude::*; + +use api::dto::AuthRequest; + +#[derive(PartialEq, Clone)] +pub enum AuthMode { + SignIn, + SignUp, +} + +impl AuthMode { + fn title(&self) -> &'static str { + match self { + Self::SignIn => "Sign In", + Self::SignUp => "Sign Up", + } + } +} + +#[component] +pub fn AuthForm(link: Element, mode: AuthMode, onsubmit: EventHandler) -> Element { + let mut username = use_signal(String::new); + let mut password = use_signal(String::new); + + let auth_invite = match mode { + AuthMode::SignIn => rsx! { + p { + class: "text-l m-5", + "Not have account? " + {link} + } + }, + AuthMode::SignUp => rsx! { + p { + class: "text-l m-5", + "Have account? " + {link} + } + }, + }; + + let title = mode.title(); + + rsx! { + div { + class: "flex flex-col justify-center items-center max-w-2xl w-full border border-slate-800 rounded-[1rem]", + h1 { + class: "text-cyan-300 text-5xl text-center py-5 w-full border-b border-slate-800", + "Pamsave" + } + h1 { + class: "text-cyan-300 border-b text-3xl px-10 py-2 mt-5 mb-3", + "{title}" + } + form { + class: "flex flex-col text-2xl gap-2", + onsubmit: move |evt| { + evt.prevent_default(); + onsubmit.call(AuthRequest { + username: username(), + password: password(), + }); + }, + p { "Enter username" } + input { + class: "border border-slate-800 rounded-[0.5rem] p-2", + value: "{username}", + oninput: move |evt| { + username.set(evt.value()); + }, + } + p { "Enter password" } + input { + class: "border border-slate-800 rounded-[0.5rem] p-2", + r#type: "password", + value: "{password}", + oninput: move |evt| { + password.set(evt.value()); + }, + } + button { + class: "border rounded-[1rem] border-cyan-300 p-2 transition-colors hover:bg-cyan-300 hover:text-black my-3", + type: "submit", + "{title}" + } + } + {auth_invite} + } + } +} diff --git a/pamsave/packages/web/src/components/auth/mod.rs b/pamsave/packages/web/src/components/auth/mod.rs new file mode 100755 index 0000000..28ad24c --- /dev/null +++ b/pamsave/packages/web/src/components/auth/mod.rs @@ -0,0 +1,3 @@ +mod form; + +pub use form::{AuthForm, AuthMode}; diff --git a/pamsave/packages/web/src/components/file/create_file_invitation.rs b/pamsave/packages/web/src/components/file/create_file_invitation.rs new file mode 100755 index 0000000..562a0c3 --- /dev/null +++ b/pamsave/packages/web/src/components/file/create_file_invitation.rs @@ -0,0 +1,27 @@ +use crate::Route; +use dioxus::prelude::*; + +#[component] +pub fn CreateFileInvitation() -> Element { + let nav = use_navigator(); + + rsx! { + div { + class: "flex flex-col items-center justify-center gap-2 h-full", + p { + class: "text-3xl", + "No files :)" + } + p { + class: "text-3xl", + "Upload one?" + } + + button { + class: "border border-slate-800 rounded-[1rem] p-2 text-2xl transition-colors hover:bg-cyan-300 hover:text-black", + onclick: move |_| { nav.push(Route::FileCreatePage {}); }, + "Upload" + } + } + } +} diff --git a/pamsave/packages/web/src/components/file/file_card.rs b/pamsave/packages/web/src/components/file/file_card.rs new file mode 100755 index 0000000..4bb6948 --- /dev/null +++ b/pamsave/packages/web/src/components/file/file_card.rs @@ -0,0 +1,185 @@ +use crate::api_client::{ApiClient, ApiClientError}; +use crate::auth::Auth; +use crate::views::error_toast::{show_api_error, show_success}; +use dioxus::prelude::*; +use uuid::Uuid; + +const FILE_ICON: Asset = asset!("/assets/pixel_file.svg"); + +#[component] +pub fn FileCard( + file_id: Uuid, + filename: String, + filesize: String, + owner: Option, + visibility: Option, + #[props(default)] shared: bool, + can_delete: bool, + on_deleted: EventHandler<()>, +) -> Element { + let Auth(current_user) = use_context::(); + let mut downloading = use_signal(|| false); + let mut deleting = use_signal(|| false); + let mut confirm_delete = use_signal(|| false); + let download_name = filename.clone(); + + rsx! { + div { + class: "group flex h-full min-w-0 w-full flex-col items-center gap-1 rounded-[1rem] border border-slate-800 p-2 text-sm transition-colors hover:border-cyan-300 focus-within:border-cyan-300", + img { + class: "h-20 w-20", + src: FILE_ICON, + alt: "File Icon" + } + span { + class: "w-full min-w-0 truncate text-center font-medium", + title: "{filename}", + "{filename}" + } + span { + class: "text-sm text-slate-400", + "{filesize} B" + } + if let Some(o) = owner { + span { + class: "w-full truncate text-center text-sm text-slate-400", + title: "{o}", + "{o}" + } + } + if let Some(is_public) = visibility { + span { + class: if is_public { + "rounded-full border border-cyan-300/40 bg-cyan-300/10 px-3 py-1 text-xs text-cyan-300" + } else { + "rounded-full border border-slate-700 bg-slate-800 px-3 py-1 text-xs text-slate-300" + }, + if is_public { "Public" } else { "Private" } + } + } + if shared { + span { + class: "rounded-full border border-amber-300/40 bg-amber-300/10 px-3 py-1 text-xs text-amber-300", + "Shared with you" + } + } + div { + class: if confirm_delete() { + "mt-auto flex min-h-10 w-full flex-col justify-end gap-1 text-xs" + } else { + "mt-auto flex min-h-10 w-full items-end gap-1 text-xs opacity-100 transition-opacity sm:pointer-events-none sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100" + }, + if confirm_delete() { + span { class: "text-center text-slate-300", "Delete this file?" } + div { + class: "flex w-full gap-2", + button { + r#type: "button", + class: "min-w-0 flex-1 rounded-lg border border-slate-700 px-2 py-1.5 transition-colors hover:border-cyan-300 disabled:opacity-50", + disabled: deleting(), + onclick: move |_| confirm_delete.set(false), + "Cancel" + } + button { + r#type: "button", + class: "min-w-0 flex-1 rounded-lg border border-red-400 px-2 py-1.5 text-red-300 transition-colors hover:bg-red-500 hover:text-white disabled:opacity-50", + disabled: deleting(), + onclick: move |_| { + let Some(user) = current_user.read().user_cloned() else { + return; + }; + deleting.set(true); + spawn(async move { + let result = ApiClient::delete_file(file_id, &user.token).await; + deleting.set(false); + confirm_delete.set(false); + match result { + Ok(()) => { + show_success("File deleted."); + on_deleted.call(()); + } + Err(err) => show_api_error(&err), + } + }); + }, + if deleting() { "Deleting..." } else { "Delete" } + } + } + } else { + button { + r#type: "button", + class: "min-w-0 flex-1 truncate rounded-lg bg-cyan-300 px-2 py-1.5 font-medium text-slate-950 transition-colors hover:bg-cyan-200 disabled:cursor-wait disabled:opacity-50", + disabled: downloading(), + onclick: move |_| { + let Some(user) = current_user.read().user_cloned() else { + return; + }; + let name = download_name.clone(); + downloading.set(true); + spawn(async move { + let result = ApiClient::download_file(file_id, &user.token) + .await + .and_then(|bytes| { + save_download(&bytes, &name).map_err(ApiClientError::Response) + }); + downloading.set(false); + if let Err(err) = result { + show_api_error(&err); + } + }); + }, + if downloading() { "Downloading..." } else { "Download" } + } + if can_delete { + button { + r#type: "button", + class: "rounded-lg border border-slate-700 px-2 py-1.5 text-slate-300 transition-colors hover:border-red-400 hover:text-red-300", + onclick: move |_| confirm_delete.set(true), + "Delete" + } + } + } + } + } + } +} + +#[cfg(feature = "web")] +fn save_download(bytes: &[u8], filename: &str) -> Result<(), String> { + use wasm_bindgen::JsCast; + + let array = js_sys::Uint8Array::from(bytes); + let parts = js_sys::Array::new(); + parts.push(&array); + let blob = web_sys::Blob::new_with_u8_array_sequence(&parts) + .map_err(|err| format!("could not prepare download: {err:?}"))?; + let url = web_sys::Url::create_object_url_with_blob(&blob) + .map_err(|err| format!("could not create download link: {err:?}"))?; + + let result = (|| { + let document = web_sys::window() + .and_then(|window| window.document()) + .ok_or("browser document unavailable")?; + let anchor = document + .create_element("a") + .map_err(|err| format!("could not create download link: {err:?}"))? + .dyn_into::() + .map_err(|_| "could not create download link".to_string())?; + anchor.set_href(&url); + anchor.set_download(filename); + let body = document.body().ok_or("browser body unavailable")?; + body.append_child(&anchor) + .map_err(|err| format!("could not start download: {err:?}"))?; + anchor.click(); + anchor.remove(); + Ok(()) + })(); + + let _ = web_sys::Url::revoke_object_url(&url); + result +} + +#[cfg(not(feature = "web"))] +fn save_download(_bytes: &[u8], _filename: &str) -> Result<(), String> { + Ok(()) +} diff --git a/pamsave/packages/web/src/components/file/files_panel.rs b/pamsave/packages/web/src/components/file/files_panel.rs new file mode 100755 index 0000000..dc540f3 --- /dev/null +++ b/pamsave/packages/web/src/components/file/files_panel.rs @@ -0,0 +1,89 @@ +use api::dto::FileResponse; +use dioxus::prelude::*; +use uuid::Uuid; + +use crate::Route; + +use super::FileCard; + +#[component] +pub fn FilesPanel( + files: Vec, + page: u32, + show_owner: bool, + show_visibility: bool, + on_previous: EventHandler<()>, + on_next: EventHandler<()>, + on_deleted: EventHandler<()>, + workspace_id: Option, + #[props(default)] workspace_admin: bool, + title: Option, +) -> Element { + let nav = use_navigator(); + let upload_route = match workspace_id { + Some(workspace_id) => Route::WorkspaceFileCreatePage { workspace_id }, + None => Route::FileCreatePage {}, + }; + let has_next = files.len() == 10; + let current_username = use_context::() + .0 + .read() + .user() + .map(|user| user.username.clone()); + + rsx! { + div { + class: "flex h-full min-w-0 flex-1 flex-col gap-3", + div { + class: "flex flex-wrap items-center justify-between gap-4", + if let Some(title) = title { + h2 { class: "text-xl font-semibold text-cyan-300", "{title}" } + } + button { + class: "ml-auto rounded-xl bg-cyan-300 px-4 py-2 font-semibold text-slate-950 transition-colors hover:bg-cyan-200", + onclick: move |_| { nav.push(upload_route.clone()); }, + "Upload file" + } + } + div { + class: "grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5", + if files.is_empty() { + p { class: "py-6 text-slate-400", "No files yet." } + } else { + for file in files { + FileCard { + key: "{file.id}", + file_id: file.id, + filename: file.name, + filesize: file.size.to_string(), + visibility: show_visibility.then_some(file.is_public), + shared: file.shared, + can_delete: workspace_admin || current_username.as_deref() == Some(file.owner.as_str()), + on_deleted, + owner: if show_owner { Some(file.owner) } else { None }, + } + } + } + } + div { + class: "mt-auto flex justify-end", + div { + class: "flex items-center gap-3", + button { + class: "rounded border border-cyan-300 p-2 text-lg transition-colors hover:bg-cyan-300 hover:text-black disabled:cursor-not-allowed disabled:opacity-50", + disabled: page <= 1, + onclick: move |_| on_previous.call(()), + "<" + } + p { "{page}" } + button { + class: "rounded border border-cyan-300 p-2 text-lg transition-colors hover:bg-cyan-300 hover:text-black disabled:cursor-not-allowed disabled:opacity-50", + disabled: !has_next, + onclick: move |_| on_next.call(()), + ">" + } + } + } + } + } +} diff --git a/pamsave/packages/web/src/components/file/mod.rs b/pamsave/packages/web/src/components/file/mod.rs new file mode 100755 index 0000000..91453ff --- /dev/null +++ b/pamsave/packages/web/src/components/file/mod.rs @@ -0,0 +1,6 @@ +mod create_file_invitation; +mod file_card; +mod files_panel; + +pub use file_card::FileCard; +pub use files_panel::FilesPanel; diff --git a/pamsave/packages/web/src/components/layout.rs b/pamsave/packages/web/src/components/layout.rs new file mode 100755 index 0000000..59af279 --- /dev/null +++ b/pamsave/packages/web/src/components/layout.rs @@ -0,0 +1,23 @@ +use crate::components::Navbar; +use dioxus::prelude::*; + +#[component] +pub fn AppLayout(header: Element, children: Element) -> Element { + rsx! { + div { + class: "flex min-h-screen text-slate-100", + Navbar {} + div { + class: "flex flex-1 flex-col min-w-0", + header { + class: "grid h-16 grid-cols-3 items-center border-b border-slate-800 px-6", + {header} + } + main { + class: "flex min-w-0 flex-1 flex-col p-6", + {children} + } + } + } + } +} diff --git a/pamsave/packages/web/src/components/mod.rs b/pamsave/packages/web/src/components/mod.rs new file mode 100755 index 0000000..6e05233 --- /dev/null +++ b/pamsave/packages/web/src/components/mod.rs @@ -0,0 +1,12 @@ +mod auth; +mod file; +mod layout; +mod navbar; +mod user_badge; +mod workspace; + +pub use auth::{AuthForm, AuthMode}; +pub use file::FilesPanel; +pub use layout::AppLayout; +pub use navbar::Navbar; +pub use user_badge::UserBadge; diff --git a/pamsave/packages/web/src/components/navbar.rs b/pamsave/packages/web/src/components/navbar.rs new file mode 100755 index 0000000..7a06082 --- /dev/null +++ b/pamsave/packages/web/src/components/navbar.rs @@ -0,0 +1,50 @@ +use dioxus::prelude::*; + +use crate::Route; + +#[component] +pub fn Navbar() -> Element { + rsx! { + div { + class: "flex min-h-screen text-slate-100", + aside { + class: "w-64 shrink-0 border-r border-slate-800", + a { + class: "flex justify-center items-center text-4xl border-b border-slate-800 h-16 font-semibold tracking-tight text-cyan-300 transition-colors hover:text-cyan-200 gap-4", + span { "Pamsave" } + } + nav { + class: "flex flex-col border-b border-slate-800 text-2xl", + span { + class: "border-b border-slate-800 text-slate-600 w-full p-0.5 text-center", + "Menu" + } + Link { + class: "border-b border-slate-800 w-full py-4 transition-colors hover:bg-cyan-300 hover:text-black", + to: Route::PublicFiles {}, + span { + class: "px-6", + "Public Files" + } + } + Link { + class: "border-b border-slate-800 w-full py-4 transition-colors hover:bg-cyan-300 hover:text-black", + to: Route::WorkspaceOverview {}, + span { + class: "px-6", + "My Workspace" + } + } + Link { + class: "border-b border-slate-800 w-full py-4 transition-colors hover:bg-cyan-300 hover:text-black", + to: Route::MyFiles {}, + span { + class: "px-6", + "My Files" + } + } + } + } + } + } +} diff --git a/pamsave/packages/web/src/components/user_badge.rs b/pamsave/packages/web/src/components/user_badge.rs new file mode 100755 index 0000000..ff73f75 --- /dev/null +++ b/pamsave/packages/web/src/components/user_badge.rs @@ -0,0 +1,19 @@ +use dioxus::prelude::*; + +const USER_ICON: Asset = asset!("/assets/user.svg"); + +#[component] +pub fn UserBadge(username: String) -> Element { + rsx! { + div { + class: "flex justify-between items-center py-2 px-4 gap-5 text-slate-100 border text-cyan-300 rounded-[2rem] border-slate-800", + img { + src: USER_ICON, + class: "h-6 w-6 rounded-[1rem] border border-slate-800" + } + span { + "{username}" + } + } + } +} diff --git a/pamsave/packages/web/src/components/workspace/mod.rs b/pamsave/packages/web/src/components/workspace/mod.rs new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/pamsave/packages/web/src/components/workspace/mod.rs @@ -0,0 +1 @@ + diff --git a/pamsave/packages/web/src/main.rs b/pamsave/packages/web/src/main.rs new file mode 100755 index 0000000..1219b7b --- /dev/null +++ b/pamsave/packages/web/src/main.rs @@ -0,0 +1,202 @@ +use dioxus::prelude::*; +use uuid::Uuid; + +use components::{AppLayout, UserBadge}; +use state::{Page, CURRENT_PAGE}; +use views::{ + ApiErrorToast, CreateWorkspacePage, FileCreatePage, Home, LoginPage, MyFiles, + PasswordChangePage, PublicFiles, RegisterPage, WorkspaceOverview, WorkspaceSettings, +}; + +mod api_client; +mod auth; +mod components; +mod state; +mod views; + +#[derive(Debug, Clone, Routable, PartialEq)] +#[rustfmt::skip] +enum Route { + #[route("/login")] + LoginPage {}, + + #[route("/register")] + RegisterPage {}, + + #[layout(WebLayout)] + #[route("/")] + Home {}, + + #[route("/workspace/create")] + CreateWorkspacePage {}, + + #[route("/workspace")] + WorkspaceOverview {}, + + #[route("/workspace/settings")] + WorkspaceSettings {}, + + #[route("/files")] + PublicFiles {}, + + #[route("/files/create")] + FileCreatePage {}, + + #[route("/workspace/:workspace_id/files/create")] + WorkspaceFileCreatePage { workspace_id: Uuid }, + + #[route("/my-files")] + MyFiles {}, + + #[route("/change-password")] + PasswordChangePage {} +} + +#[component] +fn WorkspaceFileCreatePage(workspace_id: Uuid) -> Element { + rsx! { FileCreatePage { workspace_id: Some(workspace_id) } } +} + +const FAVICON: Asset = asset!("/assets/favicon.ico"); +const MAIN_CSS: Asset = asset!("/assets/main.css"); +const TAILWIND_CSS: Asset = asset!("/assets/tailwind.css"); + +fn main() { + #[cfg(feature = "server")] + dioxus::serve(|| async move { + let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); + let pool = api::db::establish_connection(&db_url) + .await + .expect("failed to connect to database"); + + let router = dioxus::server::router(App).nest("/api", api::router(pool)); + + Ok(router) + }); + + #[cfg(not(feature = "server"))] + dioxus::launch(App); +} + +#[component] +fn App() -> Element { + let auth::Auth(mut current_user) = + use_context_provider(|| auth::Auth(Signal::new(auth::AuthState::Checking))); + + use_effect(move || { + if !matches!(*current_user.read(), auth::AuthState::Checking) { + return; + } + + spawn(async move { + let Some(saved) = auth::restore() else { + current_user.set(auth::AuthState::Guest); + return; + }; + + match crate::api_client::ApiClient::me(&saved.token).await { + Ok(_) => current_user.set(auth::AuthState::User(saved)), + Err(crate::api_client::ApiClientError::Status(401, _)) => { + auth::clear_persisted(); + current_user.set(auth::AuthState::Guest); + } + Err(_) => current_user.set(auth::AuthState::Guest), + } + }); + }); + + rsx! { + document::Title { "pamsave" } + document::Link { + rel: "preconnect", + href: "https://fonts.googleapis.com" + } + document::Link { + rel: "preconnect", + href: "https://fonts.gstatic.com", + crossorigin: "anonymous" + } + document::Link { + rel: "stylesheet", + href: "https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400..700&display=swap" + } + + + document::Link { rel: "icon", href: FAVICON } + document::Link { rel: "stylesheet", href: MAIN_CSS } + document::Stylesheet { href: TAILWIND_CSS } + + Router:: {} + ApiErrorToast {} + } +} + +#[component] +fn WebLayout() -> Element { + let nav = use_navigator(); + let auth::Auth(mut current_user) = use_context::(); + + let title = match CURRENT_PAGE() { + Page::MyFiles => "My Files", + Page::PublicFiles => "Public Files", + Page::MyWorkspace {} => "My Workspace", + Page::CreateWorkspace {} => "New Workspace", + Page::CreateFile {} => "Create File", + }; + + let header = rsx! { + div {} + div { + class: "flex flex-1 justify-center", + span { + class: "flex justify-center items-center text-cyan-300 text-3xl px-6 h-16 border-r border-l border-slate-800 min-w-65", + "{title}" + } + } + div { + class: "flex items-center gap-2 justify-end", + if let Some(user) = current_user.read().user_cloned() { + div { + class: "relative group flex items-center", + UserBadge { username: user.username } + div { + class: "absolute right-0 top-full pt-1 hidden group-hover:block z-50", + div { + class: "border border-slate-800 rounded-[0.5rem] overflow-hidden bg-slate-950", + Link { + class: "block px-4 py-2 whitespace-nowrap text-slate-100 transition-colors hover:bg-cyan-300 hover:text-black", + to: Route::PasswordChangePage {}, + "Change Password" + } + } + } + } + button { + class: "border border-cyan-300 rounded-[1rem] p-1.5 transition-colors hover:text-black hover:bg-cyan-300", + onclick: move |_| { + let token = user.token.clone(); + spawn(async move { + let _ = crate::api_client::ApiClient::logout(&token).await; + }); + auth::clear_persisted(); + current_user.set(auth::AuthState::Guest); + nav.push(Route::LoginPage {}); + }, + "Sign Out" + } + } else if current_user.read().is_guest() { + button { + class: "border border-cyan-300 rounded-[1rem] p-1.5 transition-colors hover:text-black hover:bg-cyan-300", + onclick: move |_| { nav.push(Route::LoginPage {}); }, + "Sign In" + } + } + } + }; + rsx! { + AppLayout { + header, + Outlet:: {} + } + } +} diff --git a/pamsave/packages/web/src/state.rs b/pamsave/packages/web/src/state.rs new file mode 100755 index 0000000..20a14cd --- /dev/null +++ b/pamsave/packages/web/src/state.rs @@ -0,0 +1,12 @@ +use dioxus::prelude::*; + +#[derive(Clone, PartialEq, Debug)] +pub enum Page { + MyFiles, + PublicFiles, + MyWorkspace, + CreateFile, + CreateWorkspace, +} + +pub static CURRENT_PAGE: GlobalSignal = Signal::global(|| Page::PublicFiles); diff --git a/pamsave/packages/web/src/views/account.rs b/pamsave/packages/web/src/views/account.rs new file mode 100755 index 0000000..bf3af25 --- /dev/null +++ b/pamsave/packages/web/src/views/account.rs @@ -0,0 +1,74 @@ +use crate::api_client::ApiClient; +use crate::auth::Auth; +use crate::Route; +use dioxus::prelude::*; + +use super::error_toast::{show_api_error, show_success}; + +#[component] +pub fn PasswordChangePage() -> Element { + let mut current = use_signal(String::new); + let mut new_password = use_signal(String::new); + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + let onsubmit = move |evt: FormEvent| { + evt.prevent_default(); + + let Some(user) = current_user.read().user_cloned() else { + nav.push(Route::LoginPage {}); + return; + }; + + let current_value = current.read().to_string(); + let new_value = new_password.read().to_string(); + + spawn(async move { + match ApiClient::change_password(current_value, new_value, &user.token).await { + Ok(_) => { + show_success("Password updated"); + nav.push(Route::PublicFiles {}); + } + Err(err) => show_api_error(&err), + } + }); + }; + + rsx! { + main { + class: "grid min-h-screen place-items-center", + div { + class: "flex flex-col justify-center items-center max-w-2xl w-full border border-slate-800 rounded-[1rem]", + form { + class: "flex flex-col text-2xl gap-2 m-3", + onsubmit, + p { "Current password" } + input { + class: "border border-slate-800 rounded-[0.5rem] p-2", + r#type: "password", + value: "{current}", + oninput: move |evt| current.set(evt.value()), + } + p { "New password" } + input { + class: "border border-slate-800 rounded-[0.5rem] p-2", + r#type: "password", + value: "{new_password}", + oninput: move |evt| new_password.set(evt.value()), + } + button { + class: "border rounded-[1rem] border-cyan-300 p-2 transition-colors hover:bg-cyan-300 hover:text-black my-3", + r#type: "submit", + "Change Password" + } + } + } + } + } +} diff --git a/pamsave/packages/web/src/views/error_toast.rs b/pamsave/packages/web/src/views/error_toast.rs new file mode 100755 index 0000000..87a8d74 --- /dev/null +++ b/pamsave/packages/web/src/views/error_toast.rs @@ -0,0 +1,37 @@ +use crate::api_client::ApiClientError; +use dioxus::prelude::*; + +#[derive(Clone)] +enum ToastMessage { + Error(String), + Success(String), +} + +static TOAST_MESSAGE: GlobalSignal> = Signal::global(|| None); + +#[component] +pub fn ApiErrorToast() -> Element { + rsx! { + if let Some(message) = TOAST_MESSAGE.read().clone() { + div { + class: match &message { + ToastMessage::Error(_) => "fixed bottom-4 right-4 z-[100] max-w-sm bg-red-500/90 border border-red-400 text-white rounded-[1rem] px-4 py-3", + ToastMessage::Success(_) => "fixed bottom-4 right-4 z-[100] max-w-sm bg-emerald-600 border border-emerald-400 text-white rounded-[1rem] px-4 py-3", + }, + role: "status", + onclick: move |_| *TOAST_MESSAGE.write() = None, + {match &message { + ToastMessage::Error(text) | ToastMessage::Success(text) => text.clone(), + }} + } + } + } +} + +pub fn show_api_error(err: &ApiClientError) { + *TOAST_MESSAGE.write() = Some(ToastMessage::Error(err.to_string())); +} + +pub fn show_success(message: impl Into) { + *TOAST_MESSAGE.write() = Some(ToastMessage::Success(message.into())); +} diff --git a/pamsave/packages/web/src/views/file/create.rs b/pamsave/packages/web/src/views/file/create.rs new file mode 100755 index 0000000..f5daae8 --- /dev/null +++ b/pamsave/packages/web/src/views/file/create.rs @@ -0,0 +1,227 @@ +use crate::api_client::ApiClient; +use crate::auth::Auth; +use crate::state::{Page, CURRENT_PAGE}; +use crate::views::error_toast::{show_api_error, show_success}; +use crate::Route; +use dioxus::html::FileData; +use dioxus::prelude::*; +use uuid::Uuid; + +const FILE_ICON: Asset = asset!("/assets/pixel_file.svg"); + +#[component] +pub fn FileCreatePage(workspace_id: Option) -> Element { + use_effect(move || *CURRENT_PAGE.write() = Page::CreateFile); + + let mut files: Signal> = use_signal(Vec::new); + let mut uploading = use_signal(|| false); + let mut is_public = use_signal(|| false); + let mut feedback: Signal> = use_signal(|| None); + + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + let onsubmit = move |evt: FormEvent| { + evt.prevent_default(); + + if uploading() { + return; + } + + let Some(user) = current_user.read().user_cloned() else { + return; + }; + let files_to_upload = files(); + if files_to_upload.is_empty() { + return; + } + + feedback.set(None); + uploading.set(true); + spawn(async move { + let mut payloads = Vec::new(); + for file in files_to_upload { + match file.read_bytes().await { + Ok(bytes) => payloads.push((file.name(), bytes.to_vec())), + Err(_) => { + feedback.set(Some( + "Could not read a selected file. Please choose your files again." + .into(), + )); + uploading.set(false); + return; + } + } + } + + let count = payloads.len(); + let file_word = if count == 1 { "file" } else { "files" }; + let result = match workspace_id { + Some(ws) => ApiClient::upload_file(ws, payloads, is_public(), &user.token).await, + None => ApiClient::upload_personal_file(payloads, is_public(), &user.token).await, + }; + + uploading.set(false); + match result { + Ok(_) => { + files.set(Vec::new()); + reset_file_input(); + show_success(format!("{count} {file_word} uploaded successfully.")); + } + Err(err) => { + show_api_error(&err); + feedback.set(Some("Upload failed. Some files may already be uploaded; check your files before trying again.".into())); + } + } + }); + }; + + let selected_files = files(); + let file_count = selected_files.len(); + let total_bytes: u64 = selected_files.iter().map(FileData::size).sum(); + let destination = if workspace_id.is_some() { + "Workspace files" + } else { + "My files" + }; + let back_route = if workspace_id.is_some() { + Route::WorkspaceOverview {} + } else { + Route::MyFiles {} + }; + + rsx! { + div { + class: "mx-auto my-auto flex w-full max-w-3xl flex-col gap-6", + div { + class: "flex flex-wrap items-center justify-between gap-3", + div { + p { class: "text-sm uppercase tracking-widest text-cyan-300", "{destination}" } + h1 { class: "mt-2 text-3xl font-semibold text-slate-100", "Upload files" } } + Link { + class: "rounded-xl border border-slate-700 px-4 py-2 text-sm text-slate-300 transition-colors hover:border-cyan-300 hover:text-cyan-300", + to: back_route, + "Back to files" + } + } + form { + class: "overflow-hidden rounded-2xl border border-slate-800 bg-slate-950/40", + onsubmit, + div { + class: "p-5 sm:p-8", + input { + class: "sr-only peer", + r#type: "file", + id: "file", + name: "file", + multiple: false, + disabled: uploading(), + onchange: move |evt| { + files.set(evt.files()); + feedback.set(None); + }, + } + label { + r#for: "file", + class: "flex cursor-pointer flex-col items-center rounded-2xl border-2 border-dashed border-slate-700 px-5 py-10 text-center transition-colors hover:border-cyan-300 hover:bg-cyan-300/5 peer-focus-visible:border-cyan-300 peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-cyan-300", + img { class: "mb-5 h-20 w-20", src: FILE_ICON, alt: "" } + span { class: "text-lg font-medium text-slate-100", "Select file to upload" } + span { class: "mt-5 rounded-xl bg-cyan-300 px-5 py-2.5 text-sm font-semibold text-slate-950", "Browse files" } + } + + if file_count > 0 { + div { + class: "mt-7", + div { + class: "mb-3 flex flex-wrap items-center justify-between gap-2", + h2 { class: "font-medium text-slate-100", "Selected files ({file_count})" } + button { + r#type: "button", + disabled: uploading(), + class: "text-sm text-slate-400 transition-colors hover:text-cyan-300 disabled:opacity-50", + onclick: move |_| { + files.set(Vec::new()); + reset_file_input(); + feedback.set(None); + }, + "Clear selection" + } + } + ul { + class: "max-h-56 space-y-2 overflow-y-auto", + for file in selected_files.iter() { + li { + class: "flex items-center justify-between gap-3 rounded-xl border border-slate-800 bg-slate-900/60 px-4 py-3 text-sm", + span { class: "min-w-0 truncate text-slate-200", title: "{file.name()}", "{file.name()}" } + span { class: "shrink-0 text-slate-400", "{format_size(file.size())}" } + } + } + } + p { class: "mt-3 text-right text-sm text-slate-400", "Total: {format_size(total_bytes)}" } + } + } + } + div { + class: "flex flex-col gap-5 border-t border-slate-800 bg-slate-900/40 p-5 sm:p-8", + label { + class: "flex cursor-pointer items-start gap-3", + input { + class: "mt-1 h-4 w-4 shrink-0 accent-cyan-300", + r#type: "checkbox", + checked: is_public(), + disabled: uploading(), + onchange: move |evt| is_public.set(evt.checked()), + } + span { + span { class: "block font-medium text-slate-100", "Make file public" } + } + } + if let Some(message) = feedback() { + p { class: "rounded-xl border border-slate-700 px-4 py-3 text-sm text-slate-200", role: "status", "{message}" } + } + div { + class: "flex items-center justify-between", + button { + class: "rounded-xl bg-cyan-300 px-7 py-3 font-semibold text-slate-950 transition-colors hover:bg-cyan-200 disabled:cursor-not-allowed disabled:bg-slate-700 disabled:text-slate-400", + r#type: "submit", + disabled: uploading() || file_count == 0 || current_user.read().user().is_none(), + if uploading() { "Uploading..." } else { "Upload file" } + } + } + } + } + } + } +} + +fn format_size(bytes: u64) -> String { + if bytes < 1024 { + format!("{bytes} B") + } else if bytes < 1024 * 1024 { + format!("{:.1} KB", bytes as f64 / 1024.0) + } else { + format!("{:.1} MB", bytes as f64 / (1024.0 * 1024.0)) + } +} + +#[cfg(feature = "web")] +fn reset_file_input() { + use wasm_bindgen::JsCast; + + if let Some(input) = web_sys::window() + .and_then(|w| w.document()) + .and_then(|d| d.get_element_by_id("file")) + .and_then(|el| el.dyn_into::().ok()) + { + input.set_value(""); + } +} + +#[cfg(not(feature = "web"))] +fn reset_file_input() {} diff --git a/pamsave/packages/web/src/views/file/mod.rs b/pamsave/packages/web/src/views/file/mod.rs new file mode 100755 index 0000000..36adf96 --- /dev/null +++ b/pamsave/packages/web/src/views/file/mod.rs @@ -0,0 +1,7 @@ +mod create; +mod my_files; +mod public_files; + +pub use create::FileCreatePage; +pub use my_files::MyFiles; +pub use public_files::PublicFiles; diff --git a/pamsave/packages/web/src/views/file/my_files.rs b/pamsave/packages/web/src/views/file/my_files.rs new file mode 100755 index 0000000..aa123da --- /dev/null +++ b/pamsave/packages/web/src/views/file/my_files.rs @@ -0,0 +1,50 @@ +use crate::api_client::ApiClient; +use crate::auth::Auth; +use crate::components::FilesPanel; +use crate::state::{Page, CURRENT_PAGE}; +use crate::Route; +use dioxus::prelude::*; + +#[component] +pub fn MyFiles() -> Element { + use_effect(move || *CURRENT_PAGE.write() = Page::MyFiles); + + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + let mut page = use_signal(|| 1_u32); + + let mut files = use_resource(move || async move { + let Some(user) = current_user.read().user_cloned() else { + return None; + }; + Some(ApiClient::get_my_files(page(), &user.token).await) + }); + + rsx! { + div { + class: "flex min-w-0 flex-1 flex-col", + match &*files.read() { + None | Some(None) => rsx! { p { "Loading..." } }, + Some(Some(Err(err))) => rsx! { p { "Could not load files: {err}" } }, + Some(Some(Ok(items))) => rsx! { + FilesPanel { + files: items.clone(), + page: page(), + show_owner: false, + show_visibility: true, + on_previous: move |()| page.set(page().saturating_sub(1).max(1)), + on_next: move |()| page.set(page().saturating_add(1)), + on_deleted: move |()| files.restart(), + } + }, + } + } + } +} diff --git a/pamsave/packages/web/src/views/file/public_files.rs b/pamsave/packages/web/src/views/file/public_files.rs new file mode 100755 index 0000000..cf2c2c3 --- /dev/null +++ b/pamsave/packages/web/src/views/file/public_files.rs @@ -0,0 +1,50 @@ +use crate::api_client::ApiClient; +use crate::auth::Auth; +use crate::components::FilesPanel; +use crate::state::{Page, CURRENT_PAGE}; +use crate::Route; +use dioxus::prelude::*; + +#[component] +pub fn PublicFiles() -> Element { + use_effect(move || *CURRENT_PAGE.write() = Page::PublicFiles); + + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + let mut page = use_signal(|| 1_u32); + + let mut files = use_resource(move || async move { + let Some(user) = current_user.read().user_cloned() else { + return None; + }; + Some(ApiClient::get_public_files(page(), &user.token).await) + }); + + rsx! { + div { + class: "flex min-w-0 flex-1 flex-col", + match &*files.read() { + None | Some(None) => rsx! { p { "Loading..." } }, + Some(Some(Err(err))) => rsx! { p { "Could not load files: {err}" } }, + Some(Some(Ok(items))) => rsx! { + FilesPanel { + files: items.clone(), + page: page(), + show_owner: true, + show_visibility: false, + on_previous: move |()| page.set(page().saturating_sub(1).max(1)), + on_next: move |()| page.set(page().saturating_add(1)), + on_deleted: move |()| files.restart(), + } + }, + } + } + } +} diff --git a/pamsave/packages/web/src/views/home.rs b/pamsave/packages/web/src/views/home.rs new file mode 100755 index 0000000..2bb0443 --- /dev/null +++ b/pamsave/packages/web/src/views/home.rs @@ -0,0 +1,17 @@ +use crate::auth::Auth; +use crate::Route; +use dioxus::prelude::*; + +#[component] +pub fn Home() -> Element { + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + rsx! {} +} diff --git a/pamsave/packages/web/src/views/login.rs b/pamsave/packages/web/src/views/login.rs new file mode 100755 index 0000000..0a9e3fb --- /dev/null +++ b/pamsave/packages/web/src/views/login.rs @@ -0,0 +1,50 @@ +use super::error_toast::show_api_error; +use crate::api_client::ApiClient; +use crate::auth::{Auth, AuthUser}; +use crate::components::{AuthForm, AuthMode}; +use crate::Route; +use api::dto::AuthRequest; +use dioxus::prelude::*; + +#[component] +pub fn LoginPage() -> Element { + let nav = use_navigator(); + let Auth(mut current_user) = use_context::(); + + let onsubmit = move |req: AuthRequest| { + spawn(async move { + match ApiClient::login(req.clone()).await { + Ok(res) => { + let user = AuthUser { + username: req.username, + token: res.token, + workspace_id: None, + }; + crate::auth::persist(&user); + current_user.set(crate::auth::AuthState::User(user)); + nav.push(Route::PublicFiles {}); + } + Err(err) => { + show_api_error(&err); + } + } + }); + }; + + rsx! { + main { + class: "grid min-h-screen place-items-center", + AuthForm { + link: rsx! { + Link { + class: "text-cyan-300 transition-colors hover:text-cyan-200", + to: Route::RegisterPage {}, + "Sign Up" + } + }, + mode: AuthMode::SignIn, + onsubmit + } + } + } +} diff --git a/pamsave/packages/web/src/views/mod.rs b/pamsave/packages/web/src/views/mod.rs new file mode 100755 index 0000000..04b4d46 --- /dev/null +++ b/pamsave/packages/web/src/views/mod.rs @@ -0,0 +1,24 @@ +mod account; +pub use account::PasswordChangePage; + +mod home; +pub use home::Home; + +mod login; +pub use login::LoginPage; + +mod registration; +pub use registration::RegisterPage; + +mod workspace; +pub use workspace::CreateWorkspacePage; +pub use workspace::WorkspaceOverview; +pub use workspace::WorkspaceSettings; + +pub(crate) mod error_toast; +pub use error_toast::ApiErrorToast; + +mod file; +pub use file::FileCreatePage; +pub use file::MyFiles; +pub use file::PublicFiles; diff --git a/pamsave/packages/web/src/views/registration.rs b/pamsave/packages/web/src/views/registration.rs new file mode 100755 index 0000000..56985f3 --- /dev/null +++ b/pamsave/packages/web/src/views/registration.rs @@ -0,0 +1,52 @@ +use crate::api_client::ApiClient; +use crate::auth::{Auth, AuthUser}; +use crate::components::{AuthForm, AuthMode}; +use crate::Route; +use api::dto::AuthRequest; +use dioxus::prelude::*; + +use super::error_toast::show_api_error; + +#[component] +pub fn RegisterPage() -> Element { + let Auth(mut current_user) = use_context::(); + let nav = use_navigator(); + + let onsubmit = move |req: AuthRequest| { + spawn(async move { + match ApiClient::register(req.clone()).await { + Ok(res) => { + let user = AuthUser { + username: req.username, + token: res.token, + workspace_id: None, + }; + crate::auth::persist(&user); + current_user.set(crate::auth::AuthState::User(user)); + nav.push(Route::CreateWorkspacePage {}); + } + Err(err) => show_api_error(&err), + } + }); + }; + + rsx! { + main { + class: "grid min-h-screen place-items-center", + div { + class: "w-full max-w-2xl", + AuthForm { + link: rsx! { + Link { + class: "text-cyan-300 transition-colors hover:text-cyan-200", + to: Route::LoginPage {}, + "Sign In" + } + }, + mode: AuthMode::SignUp, + onsubmit + } + } + } + } +} diff --git a/pamsave/packages/web/src/views/workspace/create.rs b/pamsave/packages/web/src/views/workspace/create.rs new file mode 100755 index 0000000..276d868 --- /dev/null +++ b/pamsave/packages/web/src/views/workspace/create.rs @@ -0,0 +1,71 @@ +use crate::api_client::ApiClient; +use crate::auth::Auth; +use crate::Route; +use api::dto::NewWorkspace; +use dioxus::prelude::*; + +use super::super::error_toast::show_api_error; + +#[component] +pub fn CreateWorkspaceForm() -> Element { + let mut name = use_signal(String::new); + let mut description = use_signal(String::new); + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + let onsubmit = move |evt: FormEvent| { + evt.prevent_default(); + + let Some(user) = current_user.read().user_cloned() else { + nav.push(Route::LoginPage {}); + return; + }; + + let name_value = name.read().trim().to_string(); + let description_value = description.read().trim().to_string(); + + spawn(async move { + let request = NewWorkspace { + name: name_value, + description: match description_value.is_empty() { + true => None, + false => Some(description_value), + }, + }; + + match ApiClient::create_workspace(request, &user.token).await { + Ok(_) => { + nav.push(Route::WorkspaceOverview {}); + } + Err(err) => show_api_error(&err), + } + }); + }; + + rsx! { + div { + class: "flex flex-col justify-center items-center max-w-2xl w-full border border-slate-800 rounded-[1rem]", + form { + class: "flex flex-col text-2xl gap-2 m-3", + onsubmit, + p { "Enter title" } + input { + class: "border border-slate-800 rounded-[0.5rem] p-2", + value: "{name}", + oninput: move |evt| name.set(evt.value()), + } + p { "Enter description (optional)" } + input { + class: "border border-slate-800 rounded-[0.5rem] p-2", + value: "{description}", + oninput: move |evt| description.set(evt.value()), + } + button { + class: "border rounded-[1rem] border-cyan-300 p-2 transition-colors hover:bg-cyan-300 hover:text-black my-3", + type: "submit", + "Create" + } + } + } + } +} diff --git a/pamsave/packages/web/src/views/workspace/create_page.rs b/pamsave/packages/web/src/views/workspace/create_page.rs new file mode 100755 index 0000000..40788e0 --- /dev/null +++ b/pamsave/packages/web/src/views/workspace/create_page.rs @@ -0,0 +1,26 @@ +use crate::auth::Auth; +use crate::state::{Page, CURRENT_PAGE}; +use crate::Route; +use dioxus::prelude::*; + +use super::CreateWorkspaceForm; + +#[component] +pub fn CreateWorkspacePage() -> Element { + use_effect(move || *CURRENT_PAGE.write() = Page::CreateWorkspace); + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + rsx! { + div { + class: "grid h-full place-items-center", + CreateWorkspaceForm {} + } + } +} diff --git a/pamsave/packages/web/src/views/workspace/mod.rs b/pamsave/packages/web/src/views/workspace/mod.rs new file mode 100755 index 0000000..844a0b5 --- /dev/null +++ b/pamsave/packages/web/src/views/workspace/mod.rs @@ -0,0 +1,10 @@ +mod create; +mod create_page; +mod overview; +mod settings; +mod setup; + +pub use create::CreateWorkspaceForm; +pub use create_page::CreateWorkspacePage; +pub use overview::WorkspaceOverview; +pub use settings::WorkspaceSettings; diff --git a/pamsave/packages/web/src/views/workspace/overview.rs b/pamsave/packages/web/src/views/workspace/overview.rs new file mode 100755 index 0000000..b11309b --- /dev/null +++ b/pamsave/packages/web/src/views/workspace/overview.rs @@ -0,0 +1,388 @@ +use crate::api_client::{ApiClient, ApiClientError}; +use crate::auth::Auth; +use crate::components::FilesPanel; +use crate::state::{Page, CURRENT_PAGE}; +use crate::views::error_toast::{show_api_error, show_success}; +use crate::Route; +use api::models::Role; +use dioxus::prelude::*; +use uuid::Uuid; + +#[component] +pub fn WorkspaceOverview() -> Element { + use_effect(move || *CURRENT_PAGE.write() = Page::MyWorkspace); + + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + let mut workspace = use_resource(move || async move { + let Some(user) = current_user.read().user_cloned() else { + return None; + }; + Some(ApiClient::get_my_workspace(&user.token).await) + }); + + let username = current_user.read().user().map(|user| user.username.clone()); + let is_admin = match &*workspace.read() { + Some(Some(Ok(ws))) => ws.participants.iter().any(|participant| { + Some(participant.username.as_str()) == username.as_deref() + && participant.role == Role::WorkspaceAdmin + }), + _ => false, + }; + + rsx! { + match &*workspace.read() { + None | Some(None) => rsx! { p { "Loading workspace..." } }, + Some(Some(Ok(ws))) => rsx! { + div { + class: "mx-auto flex w-full max-w-5xl flex-col gap-6", + div { + class: "rounded-2xl border border-slate-800 bg-slate-950/40 p-6", + h1 { class: "mt-2 text-3xl font-semibold border-b border-cyan-300 text-cyan-300", "{ws.name}" } + if let Some(description) = &ws.description { + p { class: "mt-3 text-slate-400", "{description}" } + } + AuthPolicyBadge { name: ws.auth_policy.clone() } + } + + div { + class: "grid gap-6 lg:grid-cols-2", + section { + class: "rounded-2xl border border-slate-800 p-6", + h2 { class: "text-xl font-semibold text-cyan-300", "Participants ({ws.participants.len()})" } + ul { + class: "mt-5 space-y-3", + for participant in &ws.participants { + WorkspaceMemberRow { + key: "{participant.id}", + user_id: participant.id, + workspace_id: ws.id, + username: participant.username.clone(), + role: participant.role, + can_remove: is_admin && participant.role == Role::User, + on_removed: move |()| workspace.restart(), + } + } + } + } + if is_admin { + WorkspaceActions { + workspace_id: ws.id, + on_added: move |()| workspace.restart(), + } + } + } + WorkspaceFiles { + workspace_id: ws.id, + workspace_admin: is_admin, + } + } + }, + Some(Some(Err(ApiClientError::Status(404, _)))) => rsx! { + div { + class: "grid h-full place-items-center", + div { + class: "flex flex-1 flex-col justify-center items-center gap-2", + h1 { + class: "text-3xl", + "You are not part of any Workspace" + } + button { + class: "border border-slate-800 rounded-[1rem] p-2 text-2xl transition-colors hover:bg-cyan-300 hover:text-black", + onclick: move |_| { + nav.push(Route::CreateWorkspacePage {}); + }, + "Create" + } + } + } + }, + Some(Some(Err(err))) => rsx! { + p { class: "text-red-300", "Could not load workspace: {err}" } + }, + } + } +} + +#[component] +fn AuthPolicyBadge(name: Option) -> Element { + rsx! { + match name { + Some(name) => rsx! { + p { + class: "mt-3 inline-flex items-center gap-2 rounded-full border border-emerald-400 bg-emerald-400/10 px-3 py-1 text-sm text-emerald-300", + span { class: "h-2 w-2 rounded-full bg-emerald-400", "" } + "Auth policy: {name}" + } + }, + None => rsx! { + p { + class: "mt-3 inline-flex items-center gap-2 rounded-full border border-slate-700 bg-slate-900/60 px-3 py-1 text-sm text-slate-400", + span { class: "h-2 w-2 rounded-full bg-slate-600", "" } + "No auth policy" + } + }, + } + } +} + +#[component] +fn WorkspaceMemberRow( + user_id: Uuid, + workspace_id: Uuid, + username: String, + role: Role, + can_remove: bool, + on_removed: EventHandler<()>, +) -> Element { + let Auth(current_user) = use_context::(); + let mut confirming = use_signal(|| false); + let mut removing = use_signal(|| false); + + rsx! { + li { + class: "group flex flex-wrap items-center justify-between gap-3 rounded-xl border border-slate-800 bg-slate-900/40 px-4 py-3", + span { class: "min-w-0 flex-1 truncate", title: "{username}", "{username}" } + span { + class: "shrink-0 text-sm text-slate-400", + if role == Role::WorkspaceAdmin { "Admin" } else { "Member" } + } + if can_remove { + div { + class: "flex w-40 justify-end gap-2 text-sm", + if confirming() { + button { + r#type: "button", + class: "rounded-lg border border-slate-700 px-2 py-1 transition-colors hover:border-cyan-300 disabled:opacity-50", + disabled: removing(), + onclick: move |_| confirming.set(false), + "Cancel" + } + button { + r#type: "button", + class: "rounded-lg border border-red-400 px-2 py-1 text-red-300 transition-colors hover:bg-red-500 hover:text-white disabled:opacity-50", + disabled: removing(), + onclick: move |_| { + let Some(user) = current_user.read().user_cloned() else { + return; + }; + removing.set(true); + spawn(async move { + let result = ApiClient::remove_workspace_user(workspace_id, user_id, &user.token).await; + removing.set(false); + confirming.set(false); + match result { + Ok(()) => { + show_success("Member removed from workspace."); + on_removed.call(()); + } + Err(err) => show_api_error(&err), + } + }); + }, + if removing() { "Removing..." } else { "Remove" } + } + } else { + button { + r#type: "button", + class: "rounded-lg border border-slate-700 px-2 py-1 text-slate-300 transition-colors hover:border-red-400 hover:text-red-300 sm:pointer-events-none sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100", + onclick: move |_| confirming.set(true), + "Remove" + } + } + } + } + } + } +} + +#[component] +fn WorkspaceFiles(workspace_id: Uuid, workspace_admin: bool) -> Element { + let Auth(current_user) = use_context::(); + let mut page = use_signal(|| 1_u32); + let mut files = use_resource(move || async move { + let Some(user) = current_user.read().user_cloned() else { + return None; + }; + Some(ApiClient::get_workspace_files(workspace_id, page(), &user.token).await) + }); + + rsx! { + section { + class: "rounded-2xl border border-slate-800 p-6", + match &*files.read() { + None | Some(None) => rsx! { p { "Loading files..." } }, + Some(Some(Err(err))) => rsx! { p { class: "text-red-300", "Could not load files: {err}" } }, + Some(Some(Ok(items))) => rsx! { + FilesPanel { + files: items.clone(), + page: page(), + show_owner: true, + show_visibility: true, + title: "Workspace files", + workspace_id: Some(workspace_id), + workspace_admin, + on_previous: move |()| page.set(page().saturating_sub(1).max(1)), + on_next: move |()| page.set(page().saturating_add(1)), + on_deleted: move |()| files.restart(), + } + }, + } + } + } +} + +#[derive(Clone, Copy, PartialEq)] +enum WorkspaceForm { + AddUser, + AddPolicy, +} + +#[component] +fn WorkspaceActions(workspace_id: Uuid, on_added: EventHandler<()>) -> Element { + let Auth(current_user) = use_context::(); + let mut active_form = use_signal(|| None::); + let mut new_username = use_signal(String::new); + let mut policy_name = use_signal(String::new); + let mut policy_content = use_signal(String::new); + let mut saving = use_signal(|| false); + + rsx! { + section { + class: "rounded-2xl border border-slate-800 p-6", + h2 { class: "text-xl font-semibold text-cyan-300", "Manage workspace" } + div { + class: "mt-5 flex flex-wrap gap-3", + button { + r#type: "button", + class: "rounded-xl border border-cyan-300 px-4 py-2 transition-colors hover:bg-cyan-300 hover:text-slate-950 disabled:opacity-50", + disabled: saving(), + onclick: move |_| active_form.set(if active_form() == Some(WorkspaceForm::AddUser) { + None + } else { + Some(WorkspaceForm::AddUser) + }), + "Add user" + } + button { + r#type: "button", + class: "rounded-xl border border-cyan-300 px-4 py-2 transition-colors hover:bg-cyan-300 hover:text-slate-950 disabled:opacity-50", + disabled: saving(), + onclick: move |_| active_form.set(if active_form() == Some(WorkspaceForm::AddPolicy) { + None + } else { + Some(WorkspaceForm::AddPolicy) + }), + "Add auth policy" + } + } + + if active_form() == Some(WorkspaceForm::AddUser) { + form { + class: "mt-6 flex flex-col gap-3 border-t border-slate-800 pt-5", + onsubmit: move |evt| { + evt.prevent_default(); + let name = new_username.read().trim().to_string(); + if name.is_empty() || saving() { + return; + } + let Some(user) = current_user.read().user_cloned() else { + return; + }; + saving.set(true); + spawn(async move { + let result = ApiClient::add_user(workspace_id, &name, &user.token).await; + saving.set(false); + match result { + Ok(()) => { + new_username.set(String::new()); + active_form.set(None); + show_success("User added to workspace."); + on_added.call(()); + } + Err(err) => show_api_error(&err), + } + }); + }, + label { r#for: "workspace-username", "Username" } + input { + id: "workspace-username", + class: "rounded-lg border border-slate-700 bg-slate-900 px-3 py-2 outline-none focus:border-cyan-300", + placeholder: "Existing username", + value: "{new_username}", + oninput: move |evt| new_username.set(evt.value()), + } + p { class: "text-sm text-slate-400", "The user must already have an account." } + button { + r#type: "submit", + class: "self-start rounded-xl bg-cyan-300 px-5 py-2 font-semibold text-slate-950 transition-colors hover:bg-cyan-200 disabled:opacity-50", + disabled: saving(), + if saving() { "Adding..." } else { "Add user" } + } + } + } + + if active_form() == Some(WorkspaceForm::AddPolicy) { + form { + class: "mt-6 flex flex-col gap-3 border-t border-slate-800 pt-5", + onsubmit: move |evt| { + evt.prevent_default(); + let name = policy_name.read().trim().to_string(); + let content = policy_content.read().trim().to_string(); + if name.is_empty() || content.is_empty() || saving() { + return; + } + let Some(user) = current_user.read().user_cloned() else { + return; + }; + saving.set(true); + spawn(async move { + let result = ApiClient::add_auth_policy(workspace_id, name, content, &user.token).await; + saving.set(false); + match result { + Ok(()) => { + policy_name.set(String::new()); + policy_content.set(String::new()); + active_form.set(None); + show_success("Auth policy added."); + on_added.call(()); + } + Err(err) => show_api_error(&err), + } + }); + }, + label { r#for: "policy-name", "Policy name" } + input { + id: "policy-name", + class: "rounded-lg border border-slate-700 bg-slate-900 px-3 py-2 outline-none focus:border-cyan-300", + placeholder: "policy.conf", + value: "{policy_name}", + oninput: move |evt| policy_name.set(evt.value()), + } + label { r#for: "policy-content", "Policy (TOML)" } + textarea { + id: "policy-content", + class: "min-h-40 rounded-lg border border-slate-700 bg-slate-900 px-3 py-2 font-mono text-sm outline-none focus:border-cyan-300", + placeholder: "version = 1\n\n[[external_rights]]\nusername = \"alice\"\n\n[[file_rights]]\nusername = \"bob\"\nfile = \"flag.txt\"", + value: "{policy_content}", + oninput: move |evt| policy_content.set(evt.value()), + } + p { class: "text-sm text-slate-400", "Grants are applied to the PAM registry immediately; the compiled service stack is the default one." } + button { + r#type: "submit", + class: "self-start rounded-xl bg-cyan-300 px-5 py-2 font-semibold text-slate-950 transition-colors hover:bg-cyan-200 disabled:opacity-50", + disabled: saving(), + if saving() { "Adding..." } else { "Add policy" } + } + } + } + } + } +} diff --git a/pamsave/packages/web/src/views/workspace/settings.rs b/pamsave/packages/web/src/views/workspace/settings.rs new file mode 100755 index 0000000..34ae0f0 --- /dev/null +++ b/pamsave/packages/web/src/views/workspace/settings.rs @@ -0,0 +1,21 @@ +use crate::auth::Auth; +use crate::Route; +use dioxus::prelude::*; + +#[component] +pub fn WorkspaceSettings() -> Element { + let Auth(current_user) = use_context::(); + let nav = use_navigator(); + + use_effect(move || { + if current_user.read().is_guest() { + nav.push(Route::LoginPage {}); + } + }); + + rsx! { + div { + h1 { "Workspace Settings" } + } + } +} diff --git a/pamsave/packages/web/src/views/workspace/setup.rs b/pamsave/packages/web/src/views/workspace/setup.rs new file mode 100755 index 0000000..cad2e0b --- /dev/null +++ b/pamsave/packages/web/src/views/workspace/setup.rs @@ -0,0 +1,14 @@ +use dioxus::prelude::*; + +#[component] +pub fn WorkspaceSetupPrompt() -> Element { + rsx! { + main { + class: "grid place-items-center min-h-screen", + div { + class: "flex justify-center items-center max-w-2xl w-full border border-slate-800 rounded-[1rem]", + p { "Here will be workspace setup prompt"} + } + } + } +} diff --git a/sondib/Dockerfile b/sondib/Dockerfile new file mode 100755 index 0000000..1e17a60 --- /dev/null +++ b/sondib/Dockerfile @@ -0,0 +1,10 @@ +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends libc6 && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY bin/ /app/bin/ +RUN chmod +x /app/bin/* && mkdir -p /data/uploads + +WORKDIR /data +ENTRYPOINT ["/bin/sh", "-c", "mkdir -p /data/uploads && exec /app/bin/sondibd"] diff --git a/sondib/bin/sdb b/sondib/bin/sdb new file mode 100755 index 0000000..7c15df0 Binary files /dev/null and b/sondib/bin/sdb differ diff --git a/sondib/bin/sdclean b/sondib/bin/sdclean new file mode 100755 index 0000000..3e5eb8a Binary files /dev/null and b/sondib/bin/sdclean differ diff --git a/sondib/bin/sndbot b/sondib/bin/sndbot new file mode 100755 index 0000000..2039db7 Binary files /dev/null and b/sondib/bin/sndbot differ diff --git a/sondib/bin/sondibd b/sondib/bin/sondibd new file mode 100755 index 0000000..423574d Binary files /dev/null and b/sondib/bin/sondibd differ diff --git a/sondib/compose.yml b/sondib/compose.yml new file mode 100755 index 0000000..3994ef2 --- /dev/null +++ b/sondib/compose.yml @@ -0,0 +1,60 @@ +services: + sondibd: + image: sondib:latest + build: . + restart: unless-stopped + ports: + - "7777:7777/tcp" + - "7777:7777/udp" + working_dir: /data + volumes: + - station-data:/data + cpus: 2.0 + mem_limit: 2g + pids_limit: 64 + healthcheck: + test: ["CMD", "/app/bin/sdb", "list", "127.0.0.1"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 5s + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" + + cleaner: + image: sondib:latest + build: . + restart: unless-stopped + entrypoint: ["/app/bin/sdclean"] + command: ["/data"] + + working_dir: /data + pid: service:sondibd + depends_on: + sondibd: + condition: service_healthy + volumes: + - station-data:/data + environment: + SONDIB_RETENTION_SECONDS: ${SONDIB_RETENTION_SECONDS:-3600} + SONDIB_CLEAN_INTERVAL_SECONDS: ${SONDIB_CLEAN_INTERVAL_SECONDS:-30} + cpus: 2.0 + mem_limit: 2g + pids_limit: 32 + healthcheck: + test: ["CMD", "/app/bin/sdclean", "/data", "check"] + interval: 30s + timeout: 5s + retries: 3 + start_period: 5s + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" + +volumes: + station-data: diff --git a/towercore/bin/towercore-linux-mips64le b/towercore/bin/towercore-linux-mips64le new file mode 100755 index 0000000..3159e83 Binary files /dev/null and b/towercore/bin/towercore-linux-mips64le differ diff --git a/towercore/bin/towerctl-linux-mips64le b/towercore/bin/towerctl-linux-mips64le new file mode 100755 index 0000000..db49f99 Binary files /dev/null and b/towercore/bin/towerctl-linux-mips64le differ diff --git a/towercore/compose-up.sh b/towercore/compose-up.sh new file mode 100755 index 0000000..3a2ede2 --- /dev/null +++ b/towercore/compose-up.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +IMAGE="towercore:final-mips64le" +TAR="$ROOT/images/towercore-mips64le.tar" + +docker load -i "$TAR" >/dev/null + +mips_can_exec() { + local out + out="$(docker run --rm --platform linux/mips64le \ + --entrypoint /towerctl "$IMAGE" 2>&1 || true)" + ! grep -qi 'exec format error' <<<"$out" +} + +if ! mips_can_exec; then + echo "registering linux/mips64le binfmt..." + docker run --privileged --rm tonistiigi/binfmt --install mips64le || true + mips_can_exec || { echo "MIPS emulation unavailable" >&2; exit 1; } +fi + +cd "$ROOT" +docker compose up -d +docker compose ps diff --git a/towercore/config.env b/towercore/config.env new file mode 100755 index 0000000..cf159a7 --- /dev/null +++ b/towercore/config.env @@ -0,0 +1,15 @@ +TOWERCORE_PORT=7250 +TOWERCORE_STATE_DIR=/var/lib/towercore +TOWERCORE_PREAUTH_TIMEOUT=10 +TOWERCORE_SESSION_IDLE=60 +TOWERCORE_MAX_CMDS_PER_CONN=20000 +TOWERCORE_MAX_CONN_PER_IP=64 +TOWERCORE_TTL_UNUSED=60 +TOWERCORE_TTL_SECONDS=300 +TOWERCORE_MAX_UES=8192 +TOWERCORE_EVICT_ON_CELL_FULL=1 +TOWERCORE_HANDOVER_TTL=30 +TOWERCORE_SIM_UES=16 +TOWERCORE_SIM_ENABLED=1 +TOWERCORE_MAX_CONN=256 +TOWERCORE_LOG_LEVEL=info diff --git a/towercore/docker-compose.yml b/towercore/docker-compose.yml new file mode 100755 index 0000000..922f4d8 --- /dev/null +++ b/towercore/docker-compose.yml @@ -0,0 +1,29 @@ +services: + towercore: + image: towercore:final-mips64le + platform: linux/mips64le + restart: unless-stopped + privileged: false + read_only: true + cap_drop: ["ALL"] + security_opt: ["no-new-privileges:true"] + env_file: + - path: ./config.env + required: false + ports: + - "7250:7250" + volumes: + - towercore_mips_state:/var/lib/towercore + healthcheck: + test: ["CMD", "/towerctl", "hello", "127.0.0.1:7250"] + interval: 30s + timeout: 5s + retries: 5 + logging: + driver: json-file + options: + max-size: "10k" + max-file: "3" + +volumes: + towercore_mips_state: diff --git a/towercore/images/towercore-mips64le.tar b/towercore/images/towercore-mips64le.tar new file mode 100755 index 0000000..ec51358 Binary files /dev/null and b/towercore/images/towercore-mips64le.tar differ diff --git a/towercore/run-mips.sh b/towercore/run-mips.sh new file mode 100755 index 0000000..1409a04 --- /dev/null +++ b/towercore/run-mips.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PORT="${PORT:-7250}" +IMAGE="towercore:final-mips64le" +TAR="$ROOT/images/towercore-mips64le.tar" +if [ ! -f "$TAR" ] && [ -f "$ROOT/towercore-mips64le.tar" ]; then + TAR="$ROOT/towercore-mips64le.tar" +fi + +echo "loading MIPS image..." +docker load -i "$TAR" >/dev/null + +mips_can_exec() { + local out + out="$(docker run --rm --platform linux/mips64le \ + --entrypoint /towerctl "$IMAGE" 2>&1 || true)" + ! grep -qi 'exec format error' <<<"$out" +} + +if ! mips_can_exec; then + echo "registering linux/mips64le binfmt..." + docker run --privileged --rm tonistiigi/binfmt --install mips64le || true + if ! mips_can_exec; then + echo "MIPS emulation is not available on this host." >&2 + echo "Linux: enable binfmt_misc; Docker Desktop/macOS may forbid it." >&2 + exit 1 + fi +fi + +mkdir -p "$ROOT/state-mips" +docker rm -f towercore-mips >/dev/null 2>&1 || true + +ARGS=(--rm --name towercore-mips --platform linux/mips64le + --user "$(id -u):$(id -g)" + -p "$PORT:7250" -v "$ROOT/state-mips:/var/lib/towercore") +if [ -f "$ROOT/config.env" ]; then + ARGS+=(--env-file "$ROOT/config.env") +fi + +echo "TowerCore MIPS: 127.0.0.1:$PORT (state: $ROOT/state-mips)" +exec docker run "${ARGS[@]}" "$IMAGE"