diff options
50 files changed, 2428 insertions, 928 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml index 9fa8b2c..7b1202b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +# +# SPDX-License-Identifier: AGPL-3.0-or-later + [build] rustflags = [ # LLD (shipped with the Rust toolchain) is used as the default linker @@ -1,2 +1,6 @@ +# SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +# +# SPDX-License-Identifier: AGPL-3.0-or-later + /target /dist diff --git a/.helix/languages.toml b/.helix/languages.toml index 80cd6e7..c06a8b0 100644 --- a/.helix/languages.toml +++ b/.helix/languages.toml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +# +# SPDX-License-Identifier: AGPL-3.0-or-later + [language-server.rust-analyzer] command = "rust-analyzer" config = { rustfmt.overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"], cargo.features = ["filamento/reactive_stores"], cargo.target = "wasm32-unknown-unknown" } @@ -11,7 +11,7 @@ dependencies = [ "macroific", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -25,9 +25,9 @@ dependencies = [ [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aho-corasick" @@ -40,9 +40,12 @@ dependencies = [ [[package]] name = "aligned-vec" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" +dependencies = [ + "equator", +] [[package]] name = "android-tzdata" @@ -90,7 +93,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -118,7 +121,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -129,7 +132,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -143,7 +146,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -159,7 +162,7 @@ dependencies = [ "proc-macro2", "quote", "quote-use", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -253,15 +256,15 @@ checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee" [[package]] name = "bytemuck" -version = "1.23.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" [[package]] name = "byteorder-lite" @@ -277,15 +280,15 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "camino" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +checksum = "0da45bc31171d8d6960122e222a67740df867c1dd53b4d51caa297084c185cab" [[package]] name = "cc" -version = "1.2.25" +version = "1.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951" +checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac" dependencies = [ "jobserver", "libc", @@ -304,9 +307,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "chrono" @@ -381,7 +384,7 @@ dependencies = [ "pathdiff", "serde", "toml", - "winnow 0.7.10", + "winnow 0.7.11", ] [[package]] @@ -559,7 +562,7 @@ dependencies = [ "macroific", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -570,7 +573,7 @@ checksum = "e73f2692d4bd3cac41dca28934a39894200c9fabf49586d77d0e5954af1d7902" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -590,7 +593,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", "unicode-xid", ] @@ -613,7 +616,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -651,6 +654,26 @@ dependencies = [ ] [[package]] +name = "equator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" +dependencies = [ + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.102", +] + +[[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -729,7 +752,7 @@ dependencies = [ "macroific", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -757,6 +780,7 @@ dependencies = [ "hex", "image", "jid", + "js-sys", "lampada", "reactive_stores", "rusqlite", @@ -776,9 +800,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", "miniz_oxide", @@ -883,7 +907,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -935,7 +959,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", "wasm-bindgen", ] @@ -1025,9 +1049,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.3" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" dependencies = [ "foldhash", ] @@ -1038,7 +1062,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" dependencies = [ - "hashbrown 0.15.3", + "hashbrown 0.15.4", ] [[package]] @@ -1055,9 +1079,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" @@ -1275,9 +1299,9 @@ dependencies = [ [[package]] name = "image-webp" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77d01e822461baa8409e156015a1d91735549f0f2c17691bd2d996bef238f7f" +checksum = "14d75c7014ddab93c232bc6bb9f64790d3dfd1d605199acd4b40b6d69e691e9f" dependencies = [ "byteorder-lite", "quick-error", @@ -1297,7 +1321,7 @@ checksum = "0ab604ee7085efba6efc65e4ebca0e9533e3aff6cb501d7d77b211e3a781c6d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1331,7 +1355,7 @@ dependencies = [ "macroific", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1341,7 +1365,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown 0.15.3", + "hashbrown 0.15.4", ] [[package]] @@ -1352,7 +1376,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1551,7 +1575,7 @@ dependencies = [ "quote", "rstml", "serde", - "syn 2.0.101", + "syn 2.0.102", "walkdir", ] @@ -1574,7 +1598,7 @@ dependencies = [ "rstml", "rustc_version", "server_fn_macro", - "syn 2.0.101", + "syn 2.0.102", "uuid", ] @@ -1714,7 +1738,9 @@ dependencies = [ "futures", "indexmap", "jid", + "js-sys", "leptos", + "overlay-scrollbars", "reactive_stores", "serde", "stylance", @@ -1746,7 +1772,7 @@ dependencies = [ "proc-macro2", "quote", "sealed", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1758,7 +1784,7 @@ dependencies = [ "proc-macro2", "quote", "sealed", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1771,7 +1797,7 @@ dependencies = [ "macroific_core", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1783,7 +1809,7 @@ dependencies = [ "manyhow-macros", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1815,9 +1841,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "minimal-lexical" @@ -1827,9 +1853,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", "simd-adler32", @@ -1842,7 +1868,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", "windows-sys 0.59.0", ] @@ -1909,7 +1935,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -1999,7 +2025,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2027,6 +2053,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c04f5d74368e4d0dfe06c45c8627c81bd7c317d52762d118fb9b3076f6420fd" [[package]] +name = "overlay-scrollbars" +version = "0.1.0" +source = "git+https://bunny.garden/forks/overlay-scrollbars#5ff8a16e3f411a253bdf5f157bacf48f3a7da93b" +dependencies = [ + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] name = "parking" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2118,7 +2154,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2177,7 +2213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dee91521343f4c5c6a63edd65e54f31f5c92fe8978c40a4282f8372194c6a7d" dependencies = [ "proc-macro2", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2199,7 +2235,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2230,7 +2266,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", "version_check", "yansi", ] @@ -2251,7 +2287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" dependencies = [ "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2297,7 +2333,7 @@ dependencies = [ "proc-macro-utils", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2455,7 +2491,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2536,7 +2572,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.101", + "syn 2.0.102", "syn_derive", "thiserror 2.0.12", ] @@ -2559,9 +2595,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustc-hash" @@ -2635,7 +2671,7 @@ checksum = "22f968c5ea23d555e670b449c1c5e7b2fc399fdaec1d304a17cd48e288abc107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2693,7 +2729,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2721,9 +2757,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" dependencies = [ "serde", ] @@ -2773,7 +2809,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.101", + "syn 2.0.102", "xxhash-rust", ] @@ -2784,7 +2820,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5ab934f581482a66da82f2b57b15390ad67c9ab85bd9a6c54bb65060fb1380" dependencies = [ "server_fn_macro", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2875,9 +2911,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.15.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" @@ -2891,9 +2927,9 @@ dependencies = [ [[package]] name = "sqlite-wasm-rs" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c6fdb636283dad1283b20bc62157ac68a7124fde269723467689c4fd6d356c" +checksum = "c3154cbfc5c60b307a5ce91ee19314571b22f4549628f3c1d731c24696dfa3af" dependencies = [ "fragile", "indexed_db_futures", @@ -2902,6 +2938,7 @@ dependencies = [ "parking_lot", "thiserror 2.0.12", "tokio", + "wasm-array-cp", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -2966,7 +3003,7 @@ dependencies = [ "proc-macro2", "quote", "stylance-core", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -2988,9 +3025,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.101" +version = "2.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "f6397daf94fa90f058bd0fd88429dd9e5738999cca8d701813c80723add80462" dependencies = [ "proc-macro2", "quote", @@ -3006,7 +3043,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3017,7 +3054,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3113,7 +3150,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3124,7 +3161,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3206,7 +3243,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3233,19 +3270,19 @@ dependencies = [ [[package]] name = "tokio_with_wasm_proc" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "499ed9d797c376545920fa64c39c3efb34217ba4db826102db6c3912555291c9" +checksum = "c77ab10ef5cedbe0955cc210ffa852567f9c4bcfd16fd8fb7b7870eef9b7dcec" dependencies = [ "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] name = "toml" -version = "0.8.22" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned", @@ -3255,32 +3292,32 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.26" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "toml_write", - "winnow 0.7.10", + "winnow 0.7.11", ] [[package]] name = "toml_write" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "tracing" @@ -3295,20 +3332,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", ] @@ -3397,7 +3434,7 @@ checksum = "60d8d828da2a3d759d3519cdf29a5bac49c77d039ad36d0782edadbf9cd5415b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3481,9 +3518,9 @@ dependencies = [ [[package]] name = "v_frame" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" dependencies = [ "aligned-vec", "num-traits", @@ -3520,9 +3557,9 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" @@ -3534,6 +3571,16 @@ dependencies = [ ] [[package]] +name = "wasm-array-cp" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb633b3e235f0ebe0a35162adc1e0293fc4b7e3f3a6fc7b5374d80464267ff84" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] name = "wasm-bindgen" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3555,7 +3602,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", "wasm-bindgen-shared", ] @@ -3590,7 +3637,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3669,7 +3716,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3680,14 +3727,14 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] name = "windows-link" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" +checksum = "d3bfe459f85da17560875b8bf1423d6f113b7a87a5d942e7da0ac71be7c61f8b" [[package]] name = "windows-result" @@ -3866,9 +3913,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" +checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd" dependencies = [ "memchr", ] @@ -3930,7 +3977,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", "synstructure", ] @@ -3951,7 +3998,7 @@ checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -3971,7 +4018,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", "synstructure", ] @@ -4005,7 +4052,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.102", ] [[package]] @@ -4025,9 +4072,9 @@ dependencies = [ [[package]] name = "zune-jpeg" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" +checksum = "0f6fe2e33d02a98ee64423802e16df3de99c43e5cf5ff983767e1128b394c8ac" dependencies = [ "zune-core", ] diff --git a/Cargo.lock.license b/Cargo.lock.license new file mode 100644 index 0000000..e06abbf --- /dev/null +++ b/Cargo.lock.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> + +SPDX-License-Identifier: AGPL-3.0-or-later @@ -1,8 +1,15 @@ +# SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +# +# SPDX-License-Identifier: AGPL-3.0-or-later + [package] name = "macaw-web" version = "0.1.0" edition = "2024" +# [lib] +# crate-type = ["cdylib", "rlib"] + [dependencies] base64 = "0.22.1" chrono = "0.4.41" @@ -11,6 +18,7 @@ console_error_panic_hook = "0.1.7" filamento = { path = "../luz/filamento", features = [ "reactive_stores", "opfs", + # "serde" ] } futures = "0.3.31" indexmap = "2.9.0" @@ -29,7 +37,9 @@ tracing = "0.1.41" tracing-wasm = "0.2.1" uuid = { version = "1.16.0", features = ["v4"] } # wasm-bindgen = "0.2.100" -web-sys = { version = "0.3.77", features = ["HtmlInputElement", "FileList"] } +overlay-scrollbars = { git = "https://bunny.garden/forks/overlay-scrollbars" } +web-sys = { version = "0.3.77", features = ["HtmlInputElement", "FileList", "Url"] } +js-sys = { version = "0.3.77" } [patch.crates-io] tokio_with_wasm = { path = "../tokio-with-wasm/tokio_with_wasm" } diff --git a/LICENSES/AGPL-3.0-or-later.txt b/LICENSES/AGPL-3.0-or-later.txt new file mode 100644 index 0000000..0c97efd --- /dev/null +++ b/LICENSES/AGPL-3.0-or-later.txt @@ -0,0 +1,235 @@ +GNU AFFERO GENERAL PUBLIC LICENSE +Version 3, 19 November 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + + Preamble + +The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. + +A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. + +The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. + +An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. + +The precise terms and conditions for copying, distribution and modification follow. + + TERMS AND CONDITIONS + +0. Definitions. + +"This License" refers to version 3 of the GNU Affero General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based on the Program. + +To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. + +A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. + +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. + +A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Remote Network Interaction; Use with the GNU General Public License. + +Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. + +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + +If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>. @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +# +# SPDX-License-Identifier: AGPL-3.0-or-later + [build] # The index HTML file to drive the bundling process. target = "index.html" diff --git a/assets/overlayscrollbars.browser.es6.min.js b/assets/overlayscrollbars.browser.es6.min.js new file mode 100644 index 0000000..7f44ae6 --- /dev/null +++ b/assets/overlayscrollbars.browser.es6.min.js @@ -0,0 +1,10 @@ +/*! + * OverlayScrollbars + * Version: 2.11.0 + * + * Copyright (c) Rene Haas | KingSora. + * https://github.com/KingSora + * + * Released under the MIT license. + */ +var OverlayScrollbarsGlobal=function(t){"use strict";const e=(t,e)=>{const{o:n,i:r,u:o}=t;let s,i=n;const l=(t,e)=>{const n=i,l=t,c=e||(r?!r(n,l):n!==l);return(c||o)&&(i=l,s=n),[i,c,s]};return[e?t=>l(e(i,s),t):l,t=>[i,!!t,s]]},n="undefined"!=typeof window&&"undefined"!=typeof HTMLElement&&window.document?window:{},r=Math.max,o=Math.min,s=Math.round,i=Math.abs,l=Math.sign,c=n.cancelAnimationFrame,a=n.requestAnimationFrame,u=n.setTimeout,d=n.clearTimeout,p=t=>void 0!==n[t]?n[t]:void 0,y=p("MutationObserver"),h=p("IntersectionObserver"),f=p("ResizeObserver"),v=p("ScrollTimeline"),x=t=>void 0===t,b=t=>null===t,g=t=>"number"==typeof t,w=t=>"string"==typeof t,m=t=>"boolean"==typeof t,$=t=>"function"==typeof t,S=t=>Array.isArray(t),O=t=>"object"==typeof t&&!S(t)&&!b(t),M=t=>{const e=!!t&&t.length,n=g(e)&&e>-1&&e%1==0;return!(!(S(t)||!$(t)&&n)||e>0&&O(t)&&!(e-1 in t))},C=t=>!!t&&t.constructor===Object,D=t=>t instanceof HTMLElement,T=t=>t instanceof Element,k=()=>performance.now(),P=(t,e,n,o,s)=>{let i=0;const l=k(),u=r(0,n),d=n=>{const c=k(),p=c-l>=u,y=n?1:1-(r(0,l+u-c)/u||0),h=(e-t)*($(s)?s(y,y*u,0,1,u):y)+t,f=p||1===y;o&&o(h,y,f),i=f?0:a((()=>d()))};return d(),t=>{c(i),t&&d(t)}};function H(t,e){if(M(t))for(let n=0;n<t.length&&!1!==e(t[n],n,t);n++);else t&&H(Object.keys(t),(n=>e(t[n],n,t)));return t}const A=(t,e)=>t.indexOf(e)>=0,L=(t,e)=>t.concat(e),E=(t,e,n)=>(!w(e)&&M(e)?Array.prototype.push.apply(t,e):t.push(e),t),R=t=>Array.from(t||[]),U=t=>S(t)?t:!w(t)&&M(t)?R(t):[t],z=t=>!!t&&!t.length,I=t=>R(new Set(t)),_=(t,e,n)=>{H(t,(t=>!t||t.apply(void 0,e||[]))),!n&&(t.length=0)},j="paddingTop",N="paddingRight",V="paddingLeft",B="paddingBottom",F="marginLeft",Z="marginRight",W="marginBottom",q="overflowX",Y="overflowY",X="width",G="height",J="visible",K="hidden",Q="scroll",tt=(t,e,n,r)=>{if(t&&e){let r=!0;return H(n,(n=>{t[n]!==e[n]&&(r=!1)})),r}return!1},et=(t,e)=>tt(t,e,["w","h"]),nt=(t,e)=>tt(t,e,["x","y"]),rt=(t,e)=>tt(t,e,["t","r","b","l"]),ot=()=>{},st=(t,...e)=>t.bind(0,...e),it=t=>{let e;const n=t?u:a,r=t?d:c;return[o=>{r(e),e=n((()=>o()),$(t)?t():t)},()=>r(e)]},lt=(t,e)=>{const{_:n,v:r,p:o,S:s}=e||{};let i,l,p,y,h=ot;const f=function(e){h(),d(i),y=i=l=void 0,h=ot,t.apply(this,e)},v=t=>s&&l?s(l,t):t,x=()=>{h!==ot&&f(v(p)||p)},b=function(){const t=R(arguments),e=$(n)?n():n;if(g(e)&&e>=0){const n=$(r)?r():r,s=g(n)&&n>=0,b=e>0?u:a,w=e>0?d:c,m=v(t)||t,S=f.bind(0,m);let O;h(),o&&!y?(S(),y=!0,O=b((()=>y=void 0),e)):(O=b(S,e),s&&!i&&(i=u(x,n))),h=()=>w(O),l=p=m}else f(t)};return b.m=x,b},ct=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),at=t=>t?Object.keys(t):[],ut=(t,e,n,r,o,s,i)=>{const l=[e,n,r,o,s,i];return"object"==typeof t&&!b(t)||$(t)||(t={}),H(l,(e=>{H(e,((n,r)=>{const o=e[r];if(t===o)return!0;const s=S(o);if(o&&C(o)){const e=t[r];let n=e;s&&!S(e)?n=[]:s||C(e)||(n={}),t[r]=ut(n,o)}else t[r]=s?o.slice():o}))})),t},dt=(t,e)=>H(ut({},t),((t,e,n)=>{void 0===t?delete n[e]:t&&C(t)&&(n[e]=dt(t))})),pt=t=>!at(t).length,yt=(t,e,n)=>r(t,o(e,n)),ht=t=>I((S(t)?t:(t||"").split(" ")).filter((t=>t))),ft=(t,e)=>t&&t.getAttribute(e),vt=(t,e)=>t&&t.hasAttribute(e),xt=(t,e,n)=>{H(ht(e),(e=>{t&&t.setAttribute(e,String(n||""))}))},bt=(t,e)=>{H(ht(e),(e=>t&&t.removeAttribute(e)))},gt=(t,e)=>{const n=ht(ft(t,e)),r=st(xt,t,e),o=(t,e)=>{const r=new Set(n);return H(ht(t),(t=>{r[e](t)})),R(r).join(" ")};return{O:t=>r(o(t,"delete")),$:t=>r(o(t,"add")),C:t=>{const e=ht(t);return e.reduce(((t,e)=>t&&n.includes(e)),e.length>0)}}},wt=(t,e,n)=>(gt(t,e).O(n),st(mt,t,e,n)),mt=(t,e,n)=>(gt(t,e).$(n),st(wt,t,e,n)),$t=(t,e,n,r)=>(r?mt:wt)(t,e,n),St=(t,e,n)=>gt(t,e).C(n),Ot=t=>gt(t,"class"),Mt=(t,e)=>{Ot(t).O(e)},Ct=(t,e)=>(Ot(t).$(e),st(Mt,t,e)),Dt=(t,e)=>{const n=e?T(e)&&e:document;return n?R(n.querySelectorAll(t)):[]},Tt=(t,e)=>T(t)&&t.matches(e),kt=t=>Tt(t,"body"),Pt=t=>t?R(t.childNodes):[],Ht=t=>t&&t.parentElement,At=(t,e)=>T(t)&&t.closest(e),Lt=t=>document.activeElement,Et=t=>{H(U(t),(t=>{const e=Ht(t);t&&e&&e.removeChild(t)}))},Rt=(t,e)=>st(Et,t&&e&&H(U(e),(e=>{e&&t.appendChild(e)})));let Ut;const zt=t=>{const e=document.createElement("div");return xt(e,"class",t),e},It=t=>{const e=zt(),n=Ut,r=t.trim();return e.innerHTML=n?n.createHTML(r):r,H(Pt(e),(t=>Et(t)))},_t=(t,e)=>t.getPropertyValue(e)||t[e]||"",jt=t=>{const e=t||0;return isFinite(e)?e:0},Nt=t=>jt(parseFloat(t||"")),Vt=t=>Math.round(1e4*t)/1e4,Bt=t=>`${Vt(jt(t))}px`;function Ft(t,e){t&&e&&H(e,((e,n)=>{try{const r=t.style,o=b(e)||m(e)?"":g(e)?Bt(e):e;0===n.indexOf("--")?r.setProperty(n,o):r[n]=o}catch(r){}}))}function Zt(t,e,r){const o=w(e);let s=o?"":{};if(t){const i=n.getComputedStyle(t,r)||t.style;s=o?_t(i,e):R(e).reduce(((t,e)=>(t[e]=_t(i,e),t)),s)}return s}const Wt=(t,e,n)=>{const r=e?`${e}-`:"",o=n?`-${n}`:"",s=`${r}top${o}`,i=`${r}right${o}`,l=`${r}bottom${o}`,c=`${r}left${o}`,a=Zt(t,[s,i,l,c]);return{t:Nt(a[s]),r:Nt(a[i]),b:Nt(a[l]),l:Nt(a[c])}},qt=(t,e)=>`translate${O(t)?`(${t.x},${t.y})`:`${e?"X":"Y"}(${t})`}`,Yt={w:0,h:0},Xt=(t,e)=>e?{w:e[`${t}Width`],h:e[`${t}Height`]}:Yt,Gt=t=>Xt("inner",t||n),Jt=st(Xt,"offset"),Kt=st(Xt,"client"),Qt=st(Xt,"scroll"),te=t=>{const e=parseFloat(Zt(t,X))||0,n=parseFloat(Zt(t,G))||0;return{w:e-s(e),h:n-s(n)}},ee=t=>t.getBoundingClientRect(),ne=t=>!(!t||!t[G]&&!t[X]),re=(t,e)=>{const n=ne(t);return!ne(e)&&n},oe=(t,e,n,r)=>{H(ht(e),(e=>{t&&t.removeEventListener(e,n,r)}))},se=(t,e,n,r)=>{var o;const s=null==(o=r&&r.H)||o,i=r&&r.I||!1,l=r&&r.A||!1,c={passive:s,capture:i};return st(_,ht(e).map((e=>{const r=l?o=>{oe(t,e,r,i),n&&n(o)}:n;return t&&t.addEventListener(e,r,c),st(oe,t,e,r,i)})))},ie=t=>t.stopPropagation(),le=t=>t.preventDefault(),ce=t=>ie(t)||le(t),ae=(t,e)=>{const{x:n,y:r}=g(e)?{x:e,y:e}:e||{};g(n)&&(t.scrollLeft=n),g(r)&&(t.scrollTop=r)},ue=t=>({x:t.scrollLeft,y:t.scrollTop}),de=(t,e)=>{const{D:n,M:r}=t,{w:o,h:s}=e,c=(t,e,n)=>{let r=l(t)*n,o=l(e)*n;if(r===o){const n=i(t),s=i(e);o=n>s?0:o,r=n<s?0:r}return r=r===o?0:r,[r+0,o+0]},[a,u]=c(n.x,r.x,o),[d,p]=c(n.y,r.y,s);return{D:{x:a,y:d},M:{x:u,y:p}}},pe=({D:t,M:e})=>{const n=(t,e)=>0===t&&t<=e;return{x:n(t.x,e.x),y:n(t.y,e.y)}},ye=({D:t,M:e},n)=>{const r=(t,e,n)=>yt(0,1,(t-n)/(t-e)||0);return{x:r(t.x,e.x,n.x),y:r(t.y,e.y,n.y)}},he=t=>{t&&t.focus&&t.focus({preventScroll:!0})},fe=(t,e)=>{H(U(e),t)},ve=t=>{const e=new Map,n=(t,n)=>{if(t){const r=e.get(t);fe((t=>{r&&r[t?"delete":"clear"](t)}),n)}else e.forEach((t=>{t.clear()})),e.clear()},r=(t,o)=>{if(w(t)){const r=e.get(t)||new Set;return e.set(t,r),fe((t=>{$(t)&&r.add(t)}),o),st(n,t,o)}m(o)&&o&&n();const s=at(t),i=[];return H(s,(e=>{const n=t[e];n&&E(i,r(e,n))})),st(_,i)};return r(t||{}),[r,n,(t,n)=>{H(R(e.get(t)),(t=>{n&&!z(n)?t.apply(0,n):t()}))}]},xe={},be={},ge=(t,e,n)=>at(t).map((r=>{const{static:o,instance:s}=t[r],[i,l,c]=n||[],a=n?s:o;if(a){const t=n?a(i,l,e):a(e);return(c||be)[r]=t}})),we=t=>be[t],me="__osOptionsValidationPlugin",$e=`data-overlayscrollbars`,Se="os-environment",Oe=`${Se}-scrollbar-hidden`,Me=`${$e}-initialize`,Ce="noClipping",De=`${$e}-body`,Te=$e,ke="host",Pe=`${$e}-viewport`,He=q,Ae=Y,Le="arrange",Ee="measuring",Re="scrolling",Ue="scrollbarHidden",ze="noContent",Ie=`${$e}-padding`,_e=`${$e}-content`,je="os-size-observer",Ne=`${je}-appear`,Ve=`${je}-listener`,Be=`${Ve}-scroll`,Fe=`${Ve}-item`,Ze=`${Fe}-final`,We="os-trinsic-observer",qe="os-theme-none",Ye="os-scrollbar",Xe=`${Ye}-rtl`,Ge=`${Ye}-horizontal`,Je=`${Ye}-vertical`,Ke=`${Ye}-track`,Qe=`${Ye}-handle`,tn=`${Ye}-visible`,en=`${Ye}-cornerless`,nn=`${Ye}-interaction`,rn=`${Ye}-unusable`,on=`${Ye}-auto-hide`,sn=`${on}-hidden`,ln=`${Ye}-wheel`,cn=`${Ke}-interactive`,an=`${Qe}-interactive`,un="__osSizeObserverPlugin",dn=(()=>({[un]:{static:()=>(t,e,n)=>{const r=3333333,o="scroll",s=It(`<div class="${Fe}" dir="ltr"><div class="${Fe}"><div class="${Ze}"></div></div><div class="${Fe}"><div class="${Ze}" style="width: 200%; height: 200%"></div></div></div>`),i=s[0],l=i.lastChild,u=i.firstChild,d=null==u?void 0:u.firstChild;let p,y=Jt(i),h=y,f=!1;const v=()=>{ae(u,r),ae(l,r)},x=t=>{p=0,f&&(y=h,e(!0===t))},b=t=>{h=Jt(i),f=!t||!et(h,y),t?(ie(t),f&&!p&&(c(p),p=a(x))):x(!1===t),v()},g=[Rt(t,s),se(u,o,b),se(l,o,b)];return Ct(t,Be),Ft(d,{[X]:r,[G]:r}),a(v),[n?st(b,!1):v,g]}}}))(),pn=(t,e)=>{const{T:n}=e,[r,o]=t("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,o]},yn=t=>0===t.indexOf(J),hn=(t,e)=>{const n=(t,e,n,r)=>{const o=t===J?K:t.replace(`${J}-`,""),s=yn(t),i=yn(n);return e||r?s&&i?J:s?e&&r?o:e?J:K:e?o:i&&r?J:K:K},r={x:n(e.x,t.x,e.y,t.y),y:n(e.y,t.y,e.x,t.x)};return{k:r,R:{x:r.x===Q,y:r.y===Q}}},fn="__osScrollbarsHidingPlugin",vn=(()=>({[fn]:{static:()=>({V:(t,e,n,r,o)=>{const{L:s,U:i}=t,{P:l,T:c,N:a}=r,u=!s&&!l&&(c.x||c.y),[d]=pn(o,r),p=t=>{const{R:e}=t,n=l||d?0:42,r=(t,e,r)=>[e&&!l?t?n:r:0,t&&!!n],[o,s]=r(c.x,e.x,a.x),[i,u]=r(c.y,e.y,a.y);return{q:{x:o,y:i},j:{x:s,y:u}}},y=(t,{B:n},r)=>{if(!s){const o=ut({},{[Z]:0,[W]:0,[F]:0}),{q:s,j:i}=p(t),{x:l,y:c}=i,{x:a,y:u}=s,{F:d}=e,y=n?F:Z,h=n?V:N,f=d[y],v=d[W],x=d[h],b=d[B];return o[X]=`calc(100% + ${u+-1*f}px)`,o[y]=-u+f,o[W]=-a+v,r&&(o[h]=x+(c?u:0),o[B]=b+(l?a:0)),o}};return{X:p,Y:(t,r,o)=>{if(u){const{F:s}=e,{q:l,j:c}=p(t),{x:a,y:u}=c,{x:d,y}=l,{B:h}=n,f=s[h?N:V],v=s.paddingTop,x=r.w+o.w,b=r.h+o.h,g={w:y&&u?`${y+x-f}px`:"",h:d&&a?`${d+b-v}px`:""};Ft(i,{"--os-vaw":g.w,"--os-vah":g.h})}return u},W:t=>{if(u){const r=t||(()=>{const t=t=>{const e=Zt(i,t);return[e,e===Q]},[e,n]=t(q),[r,o]=t(Y);return{k:{x:e,y:r},R:{x:n,y:o}}})(),{F:o}=e,{j:s}=p(r),{x:l,y:c}=s,a={},d=t=>H(t,(t=>{a[t]=o[t]}));l&&d([W,j,B]),c&&d([F,Z,V,N]);const h=Zt(i,at(a)),f=wt(i,Pe,Le);return Ft(i,a),[()=>{Ft(i,ut({},h,y(r,n,u))),f()},r]}return[ot]},G:y}}})}}))(),xn="__osClickScrollPlugin",bn=(()=>({[xn]:{static:()=>(t,e,n,r)=>{let o=!1,s=ot;const i=133,l=222,[c,a]=it(i),u=Math.sign(e),d=n*u,p=d/2,y=t=>1-(1-t)*(1-t),h=(e,n)=>P(e,n,l,t,y),f=(n,r)=>P(n,e-d,i*r,((n,r,o)=>{t(n),o&&(s=h(n,e))})),v=P(0,d,l,((i,l,a)=>{if(t(i),a&&(r(o),!o)){const t=e-i;Math.sign(t-p)===u&&c((()=>{const r=t-d,o=Math.sign(r)===u;s=o?f(i,Math.abs(r)/n):h(i,e)}))}}),y);return t=>{o=!0,t&&v(),a(),s()}}}}))(),gn=t=>JSON.stringify(t,((t,e)=>{if($(e))throw 0;return e})),wn=(t,e)=>t?`${e}`.split(".").reduce(((t,e)=>t&&ct(t,e)?t[e]:void 0),t):void 0,mn={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:[0,33],attributes:null,ignoreMutation:null},overflow:{x:"scroll",y:"scroll"},scrollbars:{theme:"os-theme-dark",visibility:"auto",autoHide:"never",autoHideDelay:1300,autoHideSuspend:!1,dragScroll:!0,clickScroll:!1,pointers:["mouse","touch","pen"]}},$n=(t,e)=>{const n={};return H(L(at(e),at(t)),(r=>{const o=t[r],s=e[r];if(O(o)&&O(s))ut(n[r]={},$n(o,s)),pt(n[r])&&delete n[r];else if(ct(e,r)&&s!==o){let t=!0;if(S(o)||S(s))try{gn(o)===gn(s)&&(t=!1)}catch(i){}t&&(n[r]=s)}})),n},Sn=(t,e,n)=>r=>[wn(t,r),n||void 0!==wn(e,r)];let On,Mn;const Cn=()=>(Mn||(Mn=(()=>{const t=(t,e,n)=>{Rt(document.body,t),Rt(document.body,t);const r=Kt(t),o=Jt(t),s=te(e);return n&&Et(t),{x:o.h-r.h+s.h,y:o.w-r.w+s.w}},r=It(`<div class="${Se}"><div></div><style>${`.${Se}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${Se} div{width:200%;height:200%;margin:10px 0}.${Oe}{scrollbar-width:none!important}.${Oe}::-webkit-scrollbar,.${Oe}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`}</style></div>`)[0],o=r.firstChild,s=r.lastChild,i=On;i&&(s.nonce=i);const[l,,c]=ve(),[a,u]=e({o:t(r,o),i:nt},st(t,r,o,!0)),[d]=u(),p=(t=>{let e=!1;const n=Ct(t,Oe);try{e="none"===Zt(t,"scrollbar-width")||"none"===Zt(t,"display","::-webkit-scrollbar")}catch(r){}return n(),e})(r),y={x:0===d.x,y:0===d.y},h={elements:{host:null,padding:!p,viewport:t=>p&&kt(t)&&t,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},f=ut({},mn),x=st(ut,{},f),b=st(ut,{},h),g={N:d,T:y,P:p,J:!!v,K:st(l,"r"),Z:b,tt:t=>ut(h,t)&&b(),nt:x,ot:t=>ut(f,t)&&x(),st:ut({},h),et:ut({},f)};if(bt(r,"style"),Et(r),se(n,"resize",(()=>{c("r",[])})),$(n.matchMedia)&&!p&&(!y.x||!y.y)){const t=e=>{const r=n.matchMedia(`(resolution: ${n.devicePixelRatio}dppx)`);se(r,"change",(()=>{e(),t(e)}),{A:!0})};t((()=>{const[t,e]=a();ut(g.N,t),c("r",[e])}))}return g})()),Mn),Dn=(t,e,n,r)=>{let o=!1;const{ct:s,rt:i,lt:l,it:c,ut:a,_t:u}=r||{},d=lt((()=>o&&n(!0)),{_:33,v:99}),[p,h]=((t,e,n)=>{let r=!1;const o=!!n&&new WeakMap,s=s=>{if(o&&n){const i=n.map((e=>{const[n,r]=e||[];return[r&&n?(s||Dt)(n,t):[],r]}));H(i,(n=>H(n[0],(s=>{const i=n[1],l=o.get(s)||[];if(t.contains(s)&&i){const t=se(s,i,(n=>{r?(t(),o.delete(s)):e(n)}));o.set(s,E(l,t))}else _(l),o.delete(s)}))))}};return s(),[()=>{r=!0},s]})(t,d,l),f=i||[],v=L(s||[],f),x=(o,s)=>{if(!z(s)){const i=a||ot,l=u||ot,d=[],p=[];let y=!1,v=!1;if(H(s,(n=>{const{attributeName:o,target:s,type:a,oldValue:u,addedNodes:h,removedNodes:x}=n,b="attributes"===a,g="childList"===a,m=t===s,$=b&&o,S=$&&ft(s,o||""),O=w(S)?S:null,M=$&&u!==O,C=A(f,o)&&M;if(e&&(g||!m)){const e=b&&M,a=e&&c&&Tt(s,c),p=(a?!i(s,o,u,O):!b||e)&&!l(n,!!a,t,r);H(h,(t=>E(d,t))),H(x,(t=>E(d,t))),v=v||p}!e&&m&&M&&!i(s,o,u,O)&&(E(p,o),y=y||C)})),h((t=>I(d).reduce(((e,n)=>(E(e,Dt(t,n)),Tt(n,t)?E(e,n):e)),[]))),e)return!o&&v&&n(!1),[!1];if(!z(p)||y){const t=[I(p),y];return!o&&n.apply(0,t),t}}},b=new y(st(x,!1));return[()=>(b.observe(t,{attributes:!0,attributeOldValue:!0,attributeFilter:v,subtree:e,childList:e,characterData:e}),o=!0,()=>{o&&(p(),b.disconnect(),o=!1)}),()=>{if(o)return d.m(),x(!0,b.takeRecords())}]},Tn=(t,n,r)=>{const{dt:o}=r||{},s=we(un),[i]=e({o:!1,u:!0});return()=>{const e=[],r=It(`<div class="${je}"><div class="${Ve}"></div></div>`)[0],l=r.firstChild,c=t=>{let e=!1,r=!1;if(t instanceof ResizeObserverEntry){const[n,,o]=i(t.contentRect),s=ne(n);r=re(n,o),e=!r&&!s}else r=!0===t;e||n({ft:!0,dt:r})};if(f){const t=new f((t=>c(t.pop())));t.observe(l),E(e,(()=>{t.disconnect()}))}else{if(!s)return ot;{const[t,n]=s(l,c,o);E(e,L([Ct(r,Ne),se(r,"animationstart",t)],n))}}return st(_,E(e,Rt(t,r)))}},kn=(t,n)=>{let r;const o=zt(We),[s]=e({o:!1}),i=(t,e)=>{if(t){const r=s((t=>0===t.h||t.isIntersecting||t.intersectionRatio>0)(t)),[,o]=r;return o&&!e&&n(r)&&[r]}},l=(t,e)=>i(e.pop(),t);return[()=>{const e=[];if(h)r=new h(st(l,!1),{root:t}),r.observe(o),E(e,(()=>{r.disconnect()}));else{const t=()=>{const t=Jt(o);i(t)};E(e,Tn(o,t)()),t()}return st(_,E(e,Rt(t,o)))},()=>r&&l(!0,r.takeRecords())]},Pn=(t,n,r,o)=>{let s,i,l,c,a,u;const d=`[${Te}]`,p=`[${Pe}]`,y=["id","class","style","open","wrap","cols","rows"],{vt:h,ht:v,U:x,gt:b,bt:w,L:m,yt:O,wt:M,St:C,Ot:D}=t,k=t=>"rtl"===Zt(t,"direction"),P={$t:!1,B:k(h)},H=Cn(),A=we(fn),[E]=e({i:et,o:{w:0,h:0}},(()=>{const e=A&&A.V(t,n,P,H,r).W,o=!(O&&m)&&St(v,Te,Ce),s=!m&&M(Le),i=s&&ue(b),l=i&&D(),c=C(Ee,o),a=s&&e&&e()[0],u=Qt(x),d=te(x);return a&&a(),ae(b,i),l&&l(),o&&c(),{w:u.w+d.w,h:u.h+d.h}})),R=lt(o,{_:()=>s,v:()=>i,S(t,e){const[n]=t,[r]=e;return[L(at(n),at(r)).reduce(((t,e)=>(t[e]=n[e]||r[e],t)),{})]}}),U=t=>{const e=k(h);ut(t,{Ct:u!==e}),ut(P,{B:e}),u=e},z=(t,e)=>{const[n,r]=t,s={xt:r};return ut(P,{$t:n}),!e&&o(s),s},I=({ft:t,dt:e})=>{const n=t&&!e||!H.P?o:R,r={ft:t||e,dt:e};U(r),n(r)},_=(t,e)=>{const[,n]=E(),r={Ht:n};return U(r),n&&!e&&(t?o:R)(r),r},j=(t,e,n)=>{const r={Et:e};return U(r),e&&!n&&R(r),r},[N,V]=w?kn(v,z):[],B=!m&&Tn(v,I,{dt:!0}),[F,Z]=Dn(v,!1,j,{rt:y,ct:y}),W=m&&f&&new f((t=>{const e=t[t.length-1].contentRect;I({ft:!0,dt:re(e,a)}),a=e})),q=lt((()=>{const[,t]=E();o({Ht:t})}),{_:222,p:!0});return[()=>{W&&W.observe(v);const t=B&&B(),e=N&&N(),n=F(),r=H.K((t=>{t?R({zt:t}):q()}));return()=>{W&&W.disconnect(),t&&t(),e&&e(),c&&c(),n(),r()}},({It:t,At:e,Dt:n})=>{const r={},[o]=t("update.ignoreMutation"),[a,u]=t("update.attributes"),[h,f]=t("update.elementEvents"),[v,b]=t("update.debounce"),O=e||n;if(f||u){l&&l(),c&&c();const[t,e]=Dn(w||x,!0,_,{ct:L(y,a||[]),lt:h,it:d,_t:(t,e)=>{const{target:n,attributeName:r}=t;return!(e||!r||m)&&((t,e,n)=>{const r=At(t,e),o=t&&((t,e)=>{const n=e?T(e)&&e:document;return n&&n.querySelector(t)})(n,r),s=At(o,e)===r;return!(!r||!o)&&(r===t||o===t||s&&At(At(t,n),e)!==r)})(n,d,p)||!!At(n,`.${Ye}`)||!!(t=>$(o)&&o(t))(t)}});c=t(),l=e}if(b)if(R.m(),S(v)){const t=v[0],e=v[1];s=g(t)&&t,i=g(e)&&e}else g(v)?(s=v,i=!1):(s=!1,i=!1);if(O){const t=Z(),e=V&&V(),n=l&&l();t&&ut(r,j(t[0],t[1],O)),e&&ut(r,z(e[0],O)),n&&ut(r,_(n[0],O))}return U(r),r},P]},Hn=(t,e)=>$(e)?e.apply(0,t):e,An=(t,e,n,r)=>{const o=x(r)?n:r;return Hn(t,o)||e.apply(0,t)},Ln=(t,e,n,r)=>{const o=x(r)?n:r,s=Hn(t,o);return!!s&&(D(s)?s:e.apply(0,t))},En=(t,e,n,r)=>{const o="--os-viewport-percent",s="--os-scroll-percent",i="--os-scroll-direction",{Z:l}=Cn(),{scrollbars:c}=l(),{slot:a}=c,{vt:u,ht:d,U:p,Mt:y,gt:h,yt:f,L:x}=e,{scrollbars:b}=y?{}:t,{slot:g}=b||{},w=[],$=[],S=[],O=Ln([u,d,p],(()=>x&&f?u:d),a,g),M=t=>{if(v){let e=null,r=[];const o=new v({source:h,axis:t}),s=()=>{e&&e.cancel(),e=null},i=i=>{const{Tt:l}=n,c=pe(l)[t],a="x"===t,u=[qt(0,a),qt(`calc(100cq${a?"w":"h"} + -100%)`,a)],d=c?u:u.reverse();return r[0]===d[0]&&r[1]===d[1]||(s(),r=d,e=i.kt.animate({clear:["left"],transform:d},{timeline:o})),s};return{Rt:i}}},C={x:M("x"),y:M("y")},D=(t,e,n)=>{const r=n?Ct:Mt;H(t,(t=>{r(t.Ut,e)}))},T=(t,e)=>{H(t,(t=>{const[n,r]=e(t);Ft(n,r)}))},k=(t,e,n)=>{const r=m(n),o=!r||!n;(!r||n)&&D($,t,e),o&&D(S,t,e)},P=t=>{const e=t?"x":"y",n=zt(`${Ye} ${t?Ge:Je}`),o=zt(Ke),s=zt(Qe),i={Ut:n,Pt:o,kt:s},l=C[e];return E(t?$:S,i),E(w,[Rt(n,o),Rt(o,s),st(Et,n),l&&l.Rt(i),r(i,k,t)]),i},A=st(P,!0),L=st(P,!1);return A(),L(),[{Nt:()=>{const t=(()=>{const{Vt:t,Lt:e}=n,r=(t,e)=>yt(0,1,t/(t+e)||0);return{x:r(e.x,t.x),y:r(e.y,t.y)}})(),e=t=>e=>[e.Ut,{[o]:Vt(t)+""}];T($,e(t.x)),T(S,e(t.y))},qt:()=>{if(!v){const{Tt:t}=n,e=ye(t,ue(h)),r=t=>e=>[e.Ut,{[s]:Vt(t)+""}];T($,r(e.x)),T(S,r(e.y))}},jt:()=>{const{Tt:t}=n,e=pe(t),r=t=>e=>[e.Ut,{[i]:t?"0":"1"}];T($,r(e.x)),T(S,r(e.y)),v&&($.forEach(C.x.Rt),S.forEach(C.y.Rt))},Bt:()=>{if(x&&!f){const{Vt:t,Tt:e}=n,r=pe(e),o=ye(e,ue(h)),s=e=>{const{Ut:n}=e,s=Ht(n)===p&&n,i=(t,e,n)=>{const r=e*t;return Bt(n?r:-r)};return[s,s&&{transform:qt({x:i(o.x,t.x,r.x),y:i(o.y,t.y,r.y)})}]};T($,s),T(S,s)}},Ft:k,Xt:{Yt:$,Wt:A,Gt:st(T,$)},Jt:{Yt:S,Wt:L,Gt:st(T,S)}},()=>(Rt(O,$[0].Ut),Rt(O,S[0].Ut),st(_,w))]},Rn=(t,e,n,r)=>(o,l,c)=>{const{ht:a,U:d,L:p,gt:y,Kt:h,Ot:f}=e,{Ut:v,Pt:x,kt:b}=o,[g,w]=it(333),[m,S]=it(444),O=t=>{$(y.scrollBy)&&y.scrollBy({behavior:"smooth",left:t.x,top:t.y})};let M=!0;return st(_,[se(b,"pointermove pointerleave",r),se(v,"pointerenter",(()=>{l(nn,!0)})),se(v,"pointerleave pointercancel",(()=>{l(nn,!1)})),!p&&se(v,"mousedown",(()=>{const t=Lt();(vt(t,Pe)||vt(t,Te)||t===document.body)&&u(st(he,d),25)})),se(v,"wheel",(t=>{const{deltaX:e,deltaY:n,deltaMode:r}=t;M&&0===r&&Ht(v)===a&&O({x:e,y:n}),M=!1,l(ln,!0),g((()=>{M=!0,l(ln)})),le(t)}),{H:!1,I:!0}),se(v,"pointerdown",st(se,h,"click",ce,{A:!0,I:!0,H:!1}),{I:!0}),(()=>{const e="pointerup pointercancel lostpointercapture",r=`client${c?"X":"Y"}`,o=c?X:G,l=c?"left":"top",a=c?"w":"h",u=c?"x":"y",d=(t,e)=>r=>{const{Vt:o}=n,s=Jt(x)[a]-Jt(b)[a],i=e*r/s*o[u];ae(y,{[u]:t+i})},p=[];return se(x,"pointerdown",(n=>{const c=At(n.target,`.${Qe}`)===b,v=c?b:x,g=t.scrollbars,w=g[c?"dragScroll":"clickScroll"],{button:$,isPrimary:M,pointerType:C}=n,{pointers:D}=g;if(0===$&&M&&w&&(D||[]).includes(C)){_(p),S();const t=!c&&(n.shiftKey||"instant"===w),g=st(ee,b),$=st(ee,x),M=(t,e)=>(t||g())[l]-(e||$())[l],C=s(ee(y)[o])/Jt(y)[a]||1,D=d(ue(y)[u],1/C),T=n[r],k=g(),P=$(),H=k[o],A=M(k,P)+H/2,L=T-P[l],R=c?0:L-A,U=t=>{_(j),v.releasePointerCapture(t.pointerId)},z=c||t,I=f(),j=[se(h,e,U),se(h,"selectstart",(t=>le(t)),{H:!1}),se(x,e,U),z&&se(x,"pointermove",(t=>D(R+(t[r]-T)))),z&&(()=>{const t=ue(y);I();const e=ue(y),n={x:e.x-t.x,y:e.y-t.y};(i(n.x)>3||i(n.y)>3)&&(f(),ae(y,t),O(n),m(I))})];if(v.setPointerCapture(n.pointerId),t)D(R);else if(!c){const t=we(xn);if(t){const e=t(D,R,H,(t=>{t?I():E(j,I)}));E(j,e),E(p,st(e,!0))}}}}))})(),w,S])},Un=t=>{const e=Cn(),{Z:r,P:o}=e,{elements:s}=r(),{padding:i,viewport:l,content:c}=s,a=D(t),u=a?{}:t,{elements:d}=u,{padding:p,viewport:y,content:h}=d||{},f=a?t:u.target,v=kt(f),x=f.ownerDocument,b=x.documentElement,g=()=>x.defaultView||n,w=st(An,[f]),m=st(Ln,[f]),$=st(zt,""),S=st(w,$,l),O=st(m,$,c),M=S(y),C=M===f,T=C&&v,k=!C&&O(h),P=!C&&M===k,H=T?b:M,L=T?H:f,R=!C&&m($,i,p),U=!P&&k,z=[U,H,R,L].map((t=>D(t)&&!Ht(t)&&t)),I=t=>t&&A(z,t),j=!I(H)&&(t=>{const e=Jt(t),n=Qt(t),r=Zt(t,q),o=Zt(t,Y);return n.w-e.w>0&&!yn(r)||n.h-e.h>0&&!yn(o)})(H)?H:f,N=T?b:H,V={vt:f,ht:L,U:H,ln:R,bt:U,gt:N,Qt:T?x:H,an:v?b:j,Kt:x,yt:v,Mt:a,L:C,un:g,wt:t=>St(H,Pe,t),St:(t,e)=>$t(H,Pe,t,e),Ot:()=>$t(N,Pe,Re,!0)},{vt:B,ht:F,ln:Z,U:W,bt:X}=V,G=[()=>{bt(F,[Te,Me]),bt(B,Me),v&&bt(b,[Me,Te])}];let J=Pt([X,W,Z,F,B].find((t=>t&&!I(t))));const K=T?B:X||W,Q=st(_,G);return[V,()=>{const t=g(),e=Lt(),n=t=>{Rt(Ht(t),Pt(t)),Et(t)},r=t=>se(t,"focusin focusout focus blur",ce,{I:!0,H:!1}),s="tabindex",i=ft(W,s),l=r(e);return xt(F,Te,C?"":ke),xt(Z,Ie,""),xt(W,Pe,""),xt(X,_e,""),C||(xt(W,s,i||"-1"),v&&xt(b,De,"")),Rt(K,J),Rt(F,Z),Rt(Z||F,!C&&W),Rt(W,X),E(G,[l,()=>{const t=Lt(),e=I(W),o=e&&t===W?B:t,l=r(o);bt(Z,Ie),bt(X,_e),bt(W,Pe),v&&bt(b,De),i?xt(W,s,i):bt(W,s),I(X)&&n(X),e&&n(W),I(Z)&&n(Z),he(o),l()}]),o&&!C&&(mt(W,Pe,Ue),E(G,st(bt,W,Pe))),he(!C&&v&&e===B&&t.top===t?W:e),l(),J=0,Q},Q]},zn=({bt:t})=>({Zt:e,_n:n,Dt:r})=>{const{xt:o}=e||{},{$t:s}=n;t&&(o||r)&&Ft(t,{[G]:s&&"100%"})},In=({ht:t,ln:n,U:r,L:o},s)=>{const[i,l]=e({i:rt,o:Wt()},st(Wt,t,"padding",""));return({It:t,Zt:e,_n:c,Dt:a})=>{let[u,d]=l(a);const{P:p}=Cn(),{ft:y,Ht:h,Ct:f}=e||{},{B:v}=c,[x,b]=t("paddingAbsolute");(y||d||a||h)&&([u,d]=i(a));const g=!o&&(b||f||d);if(g){const t=!x||!n&&!p,e=u.r+u.l,o=u.t+u.b,i={[Z]:t&&!v?-e:0,[W]:t?-o:0,[F]:t&&v?-e:0,top:t?-u.t:0,right:t?v?-u.r:"auto":0,left:t?v?"auto":-u.l:0,[X]:t&&`calc(100% + ${e}px)`},l={[j]:t?u.t:0,[N]:t?u.r:0,[B]:t?u.b:0,[V]:t?u.l:0};Ft(n||r,i),Ft(r,l),ut(s,{ln:u,dn:!t,F:n?l:ut({},i,l)})}return{fn:g}}},_n=(t,o)=>{const s=Cn(),{ht:i,ln:l,U:c,L:u,Qt:d,gt:p,yt:y,St:h,un:f}=t,{P:v}=s,x=y&&u,b=st(r,0),g={display:()=>!1,direction:t=>"ltr"!==t,flexDirection:t=>t.endsWith("-reverse"),writingMode:t=>"horizontal-tb"!==t},w=at(g),m={i:et,o:{w:0,h:0}},$={i:nt,o:{}},S=t=>{h(Ee,!x&&t)},O=t=>{const e=w.some((e=>{const n=t[e];return n&&g[e](n)}));if(!e)return{D:{x:0,y:0},M:{x:1,y:1}};S(!0);const n=ue(p),r=h(ze,!0),o=se(d,Q,(t=>{const e=ue(p);t.isTrusted&&e.x===n.x&&e.y===n.y&&ie(t)}),{I:!0,A:!0});ae(p,{x:0,y:0}),r();const s=ue(p),i=Qt(p);ae(p,{x:i.w,y:i.h});const l=ue(p);ae(p,{x:l.x-s.x<1&&-i.w,y:l.y-s.y<1&&-i.h});const c=ue(p);return ae(p,n),a((()=>o())),{D:s,M:c}},M=(t,e)=>{const r=n.devicePixelRatio%1!=0?1:0,o={w:b(t.w-e.w),h:b(t.h-e.h)};return{w:o.w>r?o.w:0,h:o.h>r?o.h:0}},[C,D]=e(m,st(te,c)),[T,k]=e(m,st(Qt,c)),[P,H]=e(m),[A]=e($),[L,E]=e(m),[R]=e($),[U]=e({i:(t,e)=>tt(t,e,w),o:{}},(()=>(t=>!!t&&(t=>!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length))(t))(c)?Zt(c,w):{})),[z,I]=e({i:(t,e)=>nt(t.D,e.D)&&nt(t.M,e.M),o:{D:{x:0,y:0},M:{x:0,y:0}}}),_=we(fn),j=(t,e)=>`${e?He:Ae}${(t=>{const e=String(t||"");return e?e[0].toUpperCase()+e.slice(1):""})(t)}`,N=t=>{const e=t=>[J,K,Q].map((e=>j(e,t))),n=e(!0).concat(e()).join(" ");h(n),h(at(t).map((e=>j(t[e],"x"===e))).join(" "),!0)};return({It:e,Zt:n,_n:r,Dt:a},{fn:u})=>{const{ft:d,Ht:p,Ct:y,dt:g,zt:w}=n||{},m=_&&_.V(t,o,r,s,e),{Y:$,W:j,G:V}=m||{},[B,F]=pn(e,s),[Z,W]=e("overflow"),q=yn(Z.x),Y=yn(Z.y);let X=D(a),G=k(a),J=H(a),K=E(a);F&&v&&h(Ue,!B);{St(i,Te,Ce)&&S(!0);const[t]=j?j():[],[e]=X=C(a),[n]=G=T(a),r=Kt(c),o=x&&Gt(f()),s={w:b(n.w+e.w),h:b(n.h+e.h)},l={w:b((o?o.w:r.w+b(r.w-n.w))+e.w),h:b((o?o.h:r.h+b(r.h-n.h))+e.h)};t&&t(),K=L(l),J=P(M(s,l),a)}const[Q,tt]=K,[et,nt]=J,[rt,ot]=G,[st,it]=X,[lt,ct]=A({x:et.w>0,y:et.h>0}),at=q&&Y&&(lt.x||lt.y)||q&<.x&&!lt.y||Y&<.y&&!lt.x,dt=u||y||w||it||ot||tt||nt||W||F||!0,pt=hn(lt,Z),[yt,ht]=R(pt.k),[ft,vt]=U(a),xt=y||g||vt||ct||a,[bt,gt]=xt?z(O(ft),a):I();return dt&&(ht&&N(pt.k),V&&$&&Ft(c,V(pt,r,$(pt,rt,st)))),S(!1),$t(i,Te,Ce,at),$t(l,Ie,Ce,at),ut(o,{k:yt,Lt:{x:Q.w,y:Q.h},Vt:{x:et.w,y:et.h},rn:lt,Tt:de(bt,et)}),{en:ht,nn:tt,sn:nt,cn:gt||nt,vn:xt}}},jn=t=>{const[e,n,r]=Un(t),o={ln:{t:0,r:0,b:0,l:0},dn:!1,F:{[Z]:0,[W]:0,[F]:0,[j]:0,[N]:0,[B]:0,[V]:0},Lt:{x:0,y:0},Vt:{x:0,y:0},k:{x:K,y:K},rn:{x:!1,y:!1},Tt:{D:{x:0,y:0},M:{x:0,y:0}}},{vt:s,gt:i,L:l,Ot:c}=e,{P:a,T:u}=Cn(),d=!a&&(u.x||u.y),p=[zn(e),In(e,o),_n(e,o)];return[n,t=>{const e={},n=d&&ue(i),r=n&&c();return H(p,(n=>{ut(e,n(t,e)||{})})),ae(i,n),r&&r(),!l&&ae(s,0),e},o,e,r]},Nn=new WeakMap,Vn=t=>Nn.get(t),Bn=(t,e,n)=>{const{nt:r}=Cn(),o=D(t),s=o?t:t.target,i=Vn(s);if(e&&!i){let i=!1;const l=[],c={},a=t=>{const e=dt(t),n=we(me);return n?n(e,!0):e},u=ut({},r(),a(e)),[d,p,y]=ve(),[h,f,v]=ve(n),g=(t,e)=>{v(t,e),y(t,e)},[w,m,$,S,O]=((t,e,n,r)=>{let o=!1;const s=Sn(e,{}),[i,l,c,a,u]=jn(t),[d,p,y]=Pn(a,c,s,(t=>{b({},t)})),[h,f,,v]=((t,e,n,r,o,s)=>{let i,l,c,a,u,d=ot,p=0;const y=["mouse","pen"],h=t=>y.includes(t.pointerType),[f,v]=it(),[x,b]=it(100),[g,w]=it(100),[m,$]=it((()=>p)),[S,O]=En(t,o,r,Rn(e,o,r,(t=>h(t)&&R()))),{ht:M,Qt:C,yt:D}=o,{Ft:T,Nt:k,qt:P,jt:H,Bt:A}=S,L=(t,e)=>{if($(),t)T(sn);else{const t=st(T,sn,!0);p>0&&!e?m(t):t()}},R=()=>{(c?i:a)||(L(!0),x((()=>{L(!1)})))},U=t=>{T(on,t,!0),T(on,t,!1)},z=t=>{h(t)&&(i=c,c&&L(!0))},I=[$,b,w,v,()=>d(),se(M,"pointerover",z,{A:!0}),se(M,"pointerenter",z),se(M,"pointerleave",(t=>{h(t)&&(i=!1,c&&L(!1))})),se(M,"pointermove",(t=>{h(t)&&l&&R()})),se(C,"scroll",(t=>{f((()=>{P(),R()})),s(t),A()}))];return[()=>st(_,E(I,O())),({It:t,Dt:e,Zt:o,tn:s})=>{const{nn:i,sn:y,en:h,cn:f}=s||{},{Ct:v,dt:x}=o||{},{B:b}=n,{T:w}=Cn(),{k:m,rn:$}=r,[S,O]=t("showNativeOverlaidScrollbars"),[M,E]=t("scrollbars.theme"),[R,z]=t("scrollbars.visibility"),[I,_]=t("scrollbars.autoHide"),[j,N]=t("scrollbars.autoHideSuspend"),[V]=t("scrollbars.autoHideDelay"),[B,F]=t("scrollbars.dragScroll"),[Z,W]=t("scrollbars.clickScroll"),[q,Y]=t("overflow"),X=x&&!e,G=$.x||$.y,K=i||y||f||v||e,tt=h||z||Y,et=S&&w.x&&w.y,nt=(t,e,n)=>{const r=t.includes(Q)&&(R===J||"auto"===R&&e===Q);return T(tn,r,n),r};if(p=V,X&&(j&&G?(U(!1),d(),g((()=>{d=se(C,"scroll",st(U,!0),{A:!0})}))):U(!0)),O&&T(qe,et),E&&(T(u),T(M,!0),u=M),N&&!j&&U(!0),_&&(l="move"===I,c="leave"===I,a="never"===I,L(a,!0)),F&&T(an,B),W&&T(cn,!!Z),tt){const t=nt(q.x,m.x,!0),e=nt(q.y,m.y,!1);T(en,!(t&&e))}K&&(P(),k(),A(),f&&H(),T(rn,!$.x,!0),T(rn,!$.y,!1),T(Xe,b&&!D))},{},S]})(t,e,y,c,a,(t=>g("scroll",[C,t]))),x=t=>at(t).some((e=>!!t[e])),b=(t,s)=>{if(n())return!1;const{pn:i,Dt:c,At:a,hn:u}=t,d=i||{},h=!!c||!o,v={It:Sn(e,d,h),pn:d,Dt:h};if(u)return f(v),!1;const b=s||p(ut({},v,{At:a})),g=l(ut({},v,{_n:y,Zt:b}));f(ut({},v,{Zt:b,tn:g}));const w=x(b),m=x(g),$=w||m||!pt(d)||h;return o=!0,$&&r(t,{Zt:b,tn:g}),$};return[()=>{const{an:t,gt:e,Ot:n}=a,r=ue(t),o=[d(),i(),h()],s=n();return ae(e,r),s(),st(_,o)},b,()=>({gn:y,bn:c}),{yn:a,wn:v},u]})(t,u,(()=>i),(({pn:t,Dt:e},{Zt:n,tn:r})=>{const{ft:o,Ct:s,xt:i,Ht:l,Et:c,dt:a}=n,{nn:u,sn:d,en:p,cn:y}=r;g("updated",[C,{updateHints:{sizeChanged:!!o,directionChanged:!!s,heightIntrinsicChanged:!!i,overflowEdgeChanged:!!u,overflowAmountChanged:!!d,overflowStyleChanged:!!p,scrollCoordinatesChanged:!!y,contentMutation:!!l,hostMutation:!!c,appear:!!a},changedOptions:t||{},force:!!e}])})),M=t=>{(t=>{Nn.delete(t)})(s),_(l),i=!0,g("destroyed",[C,t]),p(),f()},C={options(t,e){if(t){const n=e?r():{},o=$n(u,ut(n,a(t)));pt(o)||(ut(u,o),m({pn:o}))}return ut({},u)},on:h,off:(t,e)=>{t&&e&&f(t,e)},state(){const{gn:t,bn:e}=$(),{B:n}=t,{Lt:r,Vt:o,k:s,rn:l,ln:c,dn:a,Tt:u}=e;return ut({},{overflowEdge:r,overflowAmount:o,overflowStyle:s,hasOverflow:l,scrollCoordinates:{start:u.D,end:u.M},padding:c,paddingAbsolute:a,directionRTL:n,destroyed:i})},elements(){const{vt:t,ht:e,ln:n,U:r,bt:o,gt:s,Qt:i}=S.yn,{Xt:l,Jt:c}=S.wn,a=t=>{const{kt:e,Pt:n,Ut:r}=t;return{scrollbar:r,track:n,handle:e}},u=t=>{const{Yt:e,Wt:n}=t,r=a(e[0]);return ut({},r,{clone:()=>{const t=a(n());return m({hn:!0}),t}})};return ut({},{target:t,host:e,padding:n||r,viewport:r,content:o||r,scrollOffsetElement:s,scrollEventElement:i,scrollbarHorizontal:u(l),scrollbarVertical:u(c)})},update:t=>m({Dt:t,At:!0}),destroy:st(M,!1),plugin:t=>c[at(t)[0]]};return E(l,[O]),((t,e)=>{Nn.set(t,e)})(s,C),ge(xe,Bn,[C,d,c]),((t,e)=>{const{nativeScrollbarsOverlaid:n,body:r}=e||{},{T:o,P:s,Z:i}=Cn(),{nativeScrollbarsOverlaid:l,body:c}=i().cancel,a=null!=n?n:l,u=x(r)?c:r,d=(o.x||o.y)&&a,p=t&&(b(u)?!s:u);return!!d||!!p})(S.yn.yt,!o&&t.cancel)?(M(!0),C):(E(l,w()),g("initialized",[C]),C.update(),C)}return i};return Bn.plugin=t=>{const e=S(t),n=e?t:[t],r=n.map((t=>ge(t,Bn)[0]));return(t=>{H(t,(t=>H(t,((e,n)=>{xe[n]=t[n]}))))})(n),e?r:r[0]},Bn.valid=t=>{const e=t&&t.elements,n=$(e)&&e();return C(n)&&!!Vn(n.target)},Bn.env=()=>{const{N:t,T:e,P:n,J:r,st:o,et:s,Z:i,tt:l,nt:c,ot:a}=Cn();return ut({},{scrollbarsSize:t,scrollbarsOverlaid:e,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:o,staticDefaultOptions:s,getDefaultInitialization:i,setDefaultInitialization:l,getDefaultOptions:c,setDefaultOptions:a})},Bn.nonce=t=>{On=t},Bn.trustedTypePolicy=t=>{Ut=t},t.ClickScrollPlugin=bn,t.OverlayScrollbars=Bn,t.ScrollbarsHidingPlugin=vn,t.SizeObserverPlugin=dn,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
\ No newline at end of file diff --git a/assets/overlayscrollbars.min.css b/assets/overlayscrollbars.min.css new file mode 100644 index 0000000..47a496c --- /dev/null +++ b/assets/overlayscrollbars.min.css @@ -0,0 +1,9 @@ +/*! + * OverlayScrollbars + * Version: 2.11.0 + * + * Copyright (c) Rene Haas | KingSora. + * https://github.com/KingSora + * + * Released under the MIT license. + */.os-size-observer,.os-size-observer-listener{box-sizing:border-box;direction:inherit;overflow:hidden;pointer-events:none;scroll-behavior:auto!important;visibility:hidden}.os-size-observer,.os-size-observer-listener,.os-size-observer-listener-item,.os-size-observer-listener-item-final{left:0;position:absolute;top:0;writing-mode:horizontal-tb}.os-size-observer{border:inherit;bottom:0;box-sizing:inherit;contain:strict;display:flex;flex-direction:row;flex-wrap:nowrap;left:0;margin:-133px;padding:inherit;right:0;top:0;transform:scale(.1);z-index:-1}.os-size-observer:before{box-sizing:inherit;content:"";flex:none;height:10px;padding:10px;width:10px}.os-size-observer-appear{animation:os-size-observer-appear-animation 1ms forwards}.os-size-observer-listener{border:inherit;box-sizing:border-box;flex:auto;margin:-133px;padding:inherit;position:relative;transform:scale(10)}.os-size-observer-listener.ltr{margin-left:0;margin-right:-266px}.os-size-observer-listener.rtl{margin-left:-266px;margin-right:0}.os-size-observer-listener:empty:before{content:"";height:100%;width:100%}.os-size-observer-listener:empty:before,.os-size-observer-listener>.os-size-observer-listener-item{border:inherit;box-sizing:content-box;display:block;flex:auto;padding:inherit;position:relative}.os-size-observer-listener-scroll{box-sizing:border-box;display:flex}.os-size-observer-listener-item{bottom:0;direction:ltr;flex:none;overflow:hidden;right:0}.os-size-observer-listener-item-final{transition:none}@keyframes os-size-observer-appear-animation{0%{cursor:auto}to{cursor:none}}.os-trinsic-observer{border:none;box-sizing:border-box;contain:strict;flex:none;height:0;margin:0;max-height:1px;max-width:0;overflow:hidden;padding:0;position:relative;top:calc(100% + 1px);z-index:-1}.os-trinsic-observer:not(:empty){height:calc(100% + 1px);top:-1px}.os-trinsic-observer:not(:empty)>.os-size-observer{height:1000%;min-height:1px;min-width:1px;width:1000%}[data-overlayscrollbars-initialize],[data-overlayscrollbars-viewport~=scrollbarHidden]{scrollbar-width:none!important}[data-overlayscrollbars-initialize]::-webkit-scrollbar,[data-overlayscrollbars-initialize]::-webkit-scrollbar-corner,[data-overlayscrollbars-viewport~=scrollbarHidden]::-webkit-scrollbar,[data-overlayscrollbars-viewport~=scrollbarHidden]::-webkit-scrollbar-corner{-webkit-appearance:none!important;appearance:none!important;display:none!important;height:0!important;width:0!important}[data-overlayscrollbars-initialize]:not([data-overlayscrollbars]):not(html):not(body){overflow:auto}html[data-overlayscrollbars-body]{overflow:hidden}html[data-overlayscrollbars-body],html[data-overlayscrollbars-body]>body{height:100%;margin:0;width:100%}html[data-overlayscrollbars-body]>body{margin:0;overflow:visible}[data-overlayscrollbars]{position:relative}[data-overlayscrollbars-padding],[data-overlayscrollbars~=host]{align-items:stretch!important;display:flex;flex-direction:row!important;flex-wrap:nowrap!important;scroll-behavior:auto!important}[data-overlayscrollbars-padding],[data-overlayscrollbars-viewport]:not([data-overlayscrollbars]){border:none;box-sizing:inherit;flex:auto!important;height:auto;margin:0;min-width:0;padding:0;position:relative;width:100%;z-index:0}[data-overlayscrollbars-viewport]:not([data-overlayscrollbars]){--os-vaw:0;--os-vah:0;outline:none}[data-overlayscrollbars-viewport]:not([data-overlayscrollbars]):focus{outline:none}[data-overlayscrollbars-viewport][data-overlayscrollbars-viewport~=arrange]:before{content:"";height:var(--os-vah);min-height:1px;min-width:1px;pointer-events:none;position:absolute;width:var(--os-vaw);z-index:-1}[data-overlayscrollbars-padding],[data-overlayscrollbars-viewport],[data-overlayscrollbars]{overflow:hidden!important}[data-overlayscrollbars-padding~=noClipping],[data-overlayscrollbars~=noClipping]{overflow:visible!important}[data-overlayscrollbars-viewport~=measuring]{overflow:hidden!important;scroll-behavior:auto!important;scroll-snap-type:none!important}[data-overlayscrollbars-viewport~=overflowXVisible]:not([data-overlayscrollbars-viewport~=measuring]){overflow-x:visible!important}[data-overlayscrollbars-viewport~=overflowXHidden]{overflow-x:hidden!important}[data-overlayscrollbars-viewport~=overflowXScroll]{overflow-x:scroll!important}[data-overlayscrollbars-viewport~=overflowYVisible]:not([data-overlayscrollbars-viewport~=measuring]){overflow-y:visible!important}[data-overlayscrollbars-viewport~=overflowYHidden]{overflow-y:hidden!important}[data-overlayscrollbars-viewport~=overflowYScroll]{overflow-y:scroll!important}[data-overlayscrollbars-viewport~=noContent]:not(#osFakeId){font-size:0!important;line-height:0!important}[data-overlayscrollbars-viewport~=noContent]:not(#osFakeId):after,[data-overlayscrollbars-viewport~=noContent]:not(#osFakeId):before,[data-overlayscrollbars-viewport~=noContent]:not(#osFakeId)>*{clip:rect(0,0,0,0)!important;border-width:0!important;display:none!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;white-space:nowrap!important;width:1px!important}[data-overlayscrollbars-viewport~=scrolling]{scroll-behavior:auto!important;scroll-snap-type:none!important}[data-overlayscrollbars-content]{box-sizing:inherit}[data-overlayscrollbars-contents]:not(#osFakeId):not([data-overlayscrollbars-padding]):not([data-overlayscrollbars-viewport]):not([data-overlayscrollbars-content]){display:contents}[data-overlayscrollbars-grid],[data-overlayscrollbars-grid] [data-overlayscrollbars-padding]{display:grid;grid-template:1fr/1fr}[data-overlayscrollbars-grid]>[data-overlayscrollbars-padding],[data-overlayscrollbars-grid]>[data-overlayscrollbars-padding]>[data-overlayscrollbars-viewport],[data-overlayscrollbars-grid]>[data-overlayscrollbars-viewport]{height:auto!important;width:auto!important}@property --os-scroll-percent{syntax:"<number>";inherits:true;initial-value:0}@property --os-viewport-percent{syntax:"<number>";inherits:true;initial-value:0}.os-scrollbar{--os-viewport-percent:0;--os-scroll-percent:0;--os-scroll-direction:0;--os-scroll-percent-directional:calc(var(--os-scroll-percent) - (var(--os-scroll-percent) + (1 - var(--os-scroll-percent))*-1)*var(--os-scroll-direction));contain:size layout;contain:size layout style;opacity:0;pointer-events:none;position:absolute;transition:opacity .15s,visibility .15s,top .15s,right .15s,bottom .15s,left .15s;visibility:hidden}body>.os-scrollbar{position:fixed;z-index:99999}.os-scrollbar-transitionless{transition:none!important}.os-scrollbar-track{border:none!important;padding:0!important;position:relative}.os-scrollbar-handle{position:absolute}.os-scrollbar-handle,.os-scrollbar-track{height:100%;pointer-events:none;width:100%}.os-scrollbar.os-scrollbar-handle-interactive .os-scrollbar-handle,.os-scrollbar.os-scrollbar-track-interactive .os-scrollbar-track{pointer-events:auto;touch-action:none}.os-scrollbar-horizontal{bottom:0;left:0}.os-scrollbar-vertical{right:0;top:0}.os-scrollbar-rtl.os-scrollbar-horizontal{right:0}.os-scrollbar-rtl.os-scrollbar-vertical{left:0;right:auto}.os-scrollbar-visible{opacity:1;visibility:visible}.os-scrollbar-auto-hide.os-scrollbar-auto-hide-hidden{opacity:0;visibility:hidden}.os-scrollbar-interaction.os-scrollbar-visible{opacity:1;visibility:visible}.os-scrollbar-unusable,.os-scrollbar-unusable *,.os-scrollbar-wheel,.os-scrollbar-wheel *{pointer-events:none!important}.os-scrollbar-unusable .os-scrollbar-handle{opacity:0!important;transition:none!important}.os-scrollbar-horizontal .os-scrollbar-handle{bottom:0;left:calc(var(--os-scroll-percent-directional)*100%);transform:translateX(calc(var(--os-scroll-percent-directional)*-100%));width:calc(var(--os-viewport-percent)*100%)}.os-scrollbar-vertical .os-scrollbar-handle{height:calc(var(--os-viewport-percent)*100%);right:0;top:calc(var(--os-scroll-percent-directional)*100%);transform:translateY(calc(var(--os-scroll-percent-directional)*-100%))}@supports (container-type:size){.os-scrollbar-track{container-type:size}.os-scrollbar-horizontal .os-scrollbar-handle{left:auto;transform:translateX(calc(var(--os-scroll-percent-directional)*100cqw + var(--os-scroll-percent-directional)*-100%))}.os-scrollbar-vertical .os-scrollbar-handle{top:auto;transform:translateY(calc(var(--os-scroll-percent-directional)*100cqh + var(--os-scroll-percent-directional)*-100%))}.os-scrollbar-rtl.os-scrollbar-horizontal .os-scrollbar-handle{left:0;right:auto}}.os-scrollbar-rtl.os-scrollbar-vertical .os-scrollbar-handle{left:0;right:auto}.os-scrollbar.os-scrollbar-horizontal.os-scrollbar-cornerless,.os-scrollbar.os-scrollbar-horizontal.os-scrollbar-cornerless.os-scrollbar-rtl{left:0;right:0}.os-scrollbar.os-scrollbar-vertical.os-scrollbar-cornerless,.os-scrollbar.os-scrollbar-vertical.os-scrollbar-cornerless.os-scrollbar-rtl{bottom:0;top:0}@media print{.os-scrollbar{display:none}}.os-scrollbar{--os-size:0;--os-padding-perpendicular:0;--os-padding-axis:0;--os-track-border-radius:0;--os-track-bg:none;--os-track-bg-hover:none;--os-track-bg-active:none;--os-track-border:none;--os-track-border-hover:none;--os-track-border-active:none;--os-handle-border-radius:0;--os-handle-bg:none;--os-handle-bg-hover:none;--os-handle-bg-active:none;--os-handle-border:none;--os-handle-border-hover:none;--os-handle-border-active:none;--os-handle-min-size:33px;--os-handle-max-size:none;--os-handle-perpendicular-size:100%;--os-handle-perpendicular-size-hover:100%;--os-handle-perpendicular-size-active:100%;--os-handle-interactive-area-offset:0}.os-scrollbar-track{background:var(--os-track-bg);border:var(--os-track-border);border-radius:var(--os-track-border-radius);transition:opacity .15s,background-color .15s,border-color .15s}.os-scrollbar-track:hover{background:var(--os-track-bg-hover);border:var(--os-track-border-hover)}.os-scrollbar-track:active{background:var(--os-track-bg-active);border:var(--os-track-border-active)}.os-scrollbar-handle{background:var(--os-handle-bg);border:var(--os-handle-border);border-radius:var(--os-handle-border-radius)}.os-scrollbar-handle:hover{background:var(--os-handle-bg-hover);border:var(--os-handle-border-hover)}.os-scrollbar-handle:active{background:var(--os-handle-bg-active);border:var(--os-handle-border-active)}.os-scrollbar-handle:before,.os-scrollbar-track:before{bottom:0;content:"";display:block;left:0;position:absolute;right:0;top:0}.os-scrollbar-horizontal{height:var(--os-size);padding:var(--os-padding-perpendicular) var(--os-padding-axis);right:var(--os-size)}.os-scrollbar-horizontal.os-scrollbar-rtl{left:var(--os-size);right:0}.os-scrollbar-horizontal .os-scrollbar-track:before{bottom:calc(var(--os-padding-perpendicular)*-1);top:calc(var(--os-padding-perpendicular)*-1)}.os-scrollbar-horizontal .os-scrollbar-handle{height:var(--os-handle-perpendicular-size);max-width:var(--os-handle-max-size);min-width:var(--os-handle-min-size);transition:opacity .15s,background-color .15s,border-color .15s,height .15s}.os-scrollbar-horizontal .os-scrollbar-handle:before{bottom:calc(var(--os-padding-perpendicular)*-1);top:calc((var(--os-padding-perpendicular) + var(--os-handle-interactive-area-offset))*-1)}.os-scrollbar-horizontal:hover .os-scrollbar-handle{height:var(--os-handle-perpendicular-size-hover)}.os-scrollbar-horizontal:active .os-scrollbar-handle{height:var(--os-handle-perpendicular-size-active)}.os-scrollbar-vertical{bottom:var(--os-size);padding:var(--os-padding-axis) var(--os-padding-perpendicular);width:var(--os-size)}.os-scrollbar-vertical .os-scrollbar-track:before{left:calc(var(--os-padding-perpendicular)*-1);right:calc(var(--os-padding-perpendicular)*-1)}.os-scrollbar-vertical .os-scrollbar-handle{max-height:var(--os-handle-max-size);min-height:var(--os-handle-min-size);transition:opacity .15s,background-color .15s,border-color .15s,width .15s;width:var(--os-handle-perpendicular-size)}.os-scrollbar-vertical .os-scrollbar-handle:before{left:calc((var(--os-padding-perpendicular) + var(--os-handle-interactive-area-offset))*-1);right:calc(var(--os-padding-perpendicular)*-1)}.os-scrollbar-vertical.os-scrollbar-rtl .os-scrollbar-handle:before{left:calc(var(--os-padding-perpendicular)*-1);right:calc((var(--os-padding-perpendicular) + var(--os-handle-interactive-area-offset))*-1)}.os-scrollbar-vertical:hover .os-scrollbar-handle{width:var(--os-handle-perpendicular-size-hover)}.os-scrollbar-vertical:active .os-scrollbar-handle{width:var(--os-handle-perpendicular-size-active)}.os-theme-none.os-scrollbar,[data-overlayscrollbars-viewport~=measuring]>.os-scrollbar{display:none!important}.os-theme-dark,.os-theme-light{--os-size:8px;--os-padding-perpendicular:0px;--os-padding-axis:0px;--os-track-border-radius:0px;--os-handle-interactive-area-offset:0px;--os-handle-border-radius:0px;box-sizing:border-box}.os-theme-dark{--os-handle-bg:rgba(0,0,0);--os-handle-bg-hover:rgba(0,0,0);--os-handle-bg-active:rgba(0,0,0)}.os-theme-light{--os-handle-bg:hsla(0,0%,100%,.44);--os-handle-bg-hover:hsla(0,0%,100%,.55);--os-handle-bg-active:hsla(0,0%,100%,.66)} diff --git a/assets/style.scss b/assets/style.scss index 7bdffa0..10042c2 100644 --- a/assets/style.scss +++ b/assets/style.scss @@ -1,8 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + /* App-wide styling */ img { display: block; } +::-webkit-scrollbar { + width: 8px; +} +.messages-buffer::-webkit-scrollbar { + width: 10px !important; +} + +::-webkit-scrollbar-thumb { + background: black; +} + body { max-width: 100vw; max-height: 100vh; @@ -102,6 +119,7 @@ label { input[type="text"], input[type="password"] { + font-size: 1rem; border: 2px solid black; font-family: "k2d"; } @@ -118,6 +136,8 @@ main { button, .button { + text-align: center; + font-size: 1rem; background: #FACC34; color: #000000; text-decoration: none !important; @@ -127,6 +147,19 @@ button, font-family: K2D; font-weight: 600; box-shadow: inset 0px -0.75em 0.5em #ebb62e, 0 0.25em 0.25em #00000048; + cursor: pointer; +} + +.overlay .error { + color: black; +} + +button:hover, .button:hover { + background: #f9c61b; +} + +button:clicked, .button:clicked { + background: #ffc300; } h1, @@ -143,7 +176,9 @@ p { margin: 0; } -.chats-list, .roster-list, .settings-sidebar { +.chats-list, +.roster-list, +.settings-sidebar { border-width: 0 2px 0 0; border-color: black; border-style: solid; @@ -163,17 +198,23 @@ p { .settings-sidebar>* { padding: 8px 16px; + cursor: pointer; } -.settings-sidebar>.open, .settings-sidebar>*:hover { +.settings-sidebar>.open, +.settings-sidebar>*:hover { background: #00000060; } -.chats-list>*, .roster-list>*, .settings .header { +.chats-list>*, +.roster-list>*, +.settings .header { padding: 8px 16px; } -.chats-list .header, .roster-list .header, .settings .header { +.chats-list .header, +.roster-list .header, +.settings .header { margin-top: 0.4rem; border-bottom: 2px solid black; display: flex; @@ -181,11 +222,15 @@ p { align-items: center; } -.chats-list h2, .roster-list h2 { +.chats-list h2, +.roster-list h2 { flex: 0 0 auto; } -.chats-list-item, .roster-list-item, { +.chats-list-item, +.roster-list-item, +{ + cursor: pointer; display: flex; align-items: start; gap: 8px; @@ -199,15 +244,17 @@ p { .chats-list-item:hover, .chats-list-item.open, .roster-list-item:hover, -.roster-list-item.open, { - background: #00000060; - /* color: black; */ - /* border: 2px solid black; */ - /* box-shadow: inset 0px -0.75em 0.5em #19311F, 0 0.25em 0.25em #00000048; */ - /* background: linear-gradient(0deg, #364B3B 0%, #19311F 100%); */ +.roster-list-item.open, +{ +background: #00000060; +/* color: black; */ +/* border: 2px solid black; */ +/* box-shadow: inset 0px -0.75em 0.5em #19311F, 0 0.25em 0.25em #00000048; */ +/* background: linear-gradient(0deg, #364B3B 0%, #19311F 100%); */ } -.chats-list-item .item-info, .roster-list-item .item-info { +.chats-list-item .item-info, +.roster-list-item .item-info { width: 0; display: flex; flex: 1 1 auto; @@ -215,22 +262,26 @@ p { justify-content: space-between; } -.chats-list-item .main-info, .roster-list-item .main-info { +.chats-list-item .main-info, +.roster-list-item .main-info { display: flex; justify-content: space-between; align-items: baseline; } -.chats-list-item .name, .roster-list-item .name { +.chats-list-item .name, +.roster-list-item .name { font-weight: bold; font-size: 1.1em; } -.chats-list-item .name, .roster-list-item .name { +.chats-list-item .name, +.roster-list-item .name { font-weight: light; } -.chats-list-item .sub-info, .roster-list-item .sub-info { +.chats-list-item .sub-info, +.roster-list-item .sub-info { display: flex; } @@ -259,14 +310,16 @@ p { height: 48px; } -.chats-list-item .avatar, .roster-list-item .avatar { +.chats-list-item .avatar, +.roster-list-item .avatar { width: 48px; height: 48px; } -.chats-list-chats, .roster-list-roster { +.chats-list-chats, +.roster-list-roster { flex-grow: 1; - overflow: scroll; + /* overflow-y: scroll; */ } .open-chat-views { @@ -308,29 +361,22 @@ p { max-height: auto; } -.new-message-composer textarea { - font-family: 'K2D'; +.new-message-composer .overlay-scroll { + max-height: min(32em, 50vh); + background-color: #dcdcdc; border: 2px solid black; - font-size: 16px; - padding: 8px; - /* width: auto; */ - margin: 0; - height: auto; - /* resize: none; */ - /* box-sizing: border-box; */ - /* overflow: scroll; */ - /* display: block; */ +} + +[contenteditable]:focus { + outline: 0px solid transparent; } .new-message-composer .text-box { + padding: 8px; white-space: pre-wrap; color: black; - background-color: #dcdcdc; - max-height: 32em; - overflow: scroll; + /* overflow-y: auto; */ font-size: 16px; - border: 2px solid black; - padding: 8px; margin: 0; height: fit-content; } @@ -354,7 +400,7 @@ p { /* You could leave this, but after a user resizes, then it ruins the auto sizing */ resize: none; /* Firefox shows scrollbar on growth, you can hide like this. */ - overflow: scroll; + overflow-y: scroll; } .grow-wrap>textarea, @@ -377,7 +423,25 @@ p { display: flex; flex-direction: column-reverse; flex-grow: 1; - overflow: scroll; + overflow-y: scroll; +} + + +.messages-buffer .new-day { + display: flex; + align-items: center; + margin: 0.5em 0 0 0; + /* margin: 1em -1em; */ + + + &:before, + &:after { + content: ""; + flex: 1; + height: 2px; + margin: 0 1em; + background: black; + } } .chat-message { @@ -457,7 +521,8 @@ p { filter: invert(99%) sepia(1%) saturate(2689%) hue-rotate(208deg) brightness(106%) contrast(73%); } -.chat-message.final .message-delivery, .visible { +.chat-message.final .message-delivery, +.visible { opacity: 100% !important; } @@ -486,6 +551,7 @@ p { display: flex; justify-content: center; position: relative; + cursor: pointer; } .dock-pill { @@ -504,7 +570,8 @@ p { opacity: 100%; } -.dock-item:hover .dock-pill, .dock-item.hovering .dock-pill { +.dock-item:hover .dock-pill, +.dock-item.hovering .dock-pill { top: calc(50% - 14px); height: 28px; opacity: 100%; @@ -534,6 +601,7 @@ p { .avatar-with-presence { position: relative; + height: fit-content; } .avatar-with-presence>.presence-show-icon { @@ -552,6 +620,10 @@ p { border-top: 2px solid black; } +.sidebar { + position: relative; +} + .dock .personal .dock-item { padding: 8px 16px } @@ -563,7 +635,6 @@ p { .sidebar-drawer { height: auto; - position: relative; z-index: 5; } @@ -571,16 +642,29 @@ p { z-index: 10; } -.sidebar .sidebar-hovering-drawer>* { +.sidebar .sidebar-hovering-drawer { position: absolute; - left: 0; - transition: left 0.2s ease-in; - transition-behaviour: allow-discrete; + height: 100%; + /* must be width of dock... */ + left: 82px; + transition: left 0.2s ease-out allow-discrete; } + @starting-style { - .sidebar .sidebar-hovering-drawer>* { + .sidebar .sidebar-hovering-drawer { /* TODO: allow to edit this width */ - left: -400px; + left: -318px; + } +} + +.sidebar .behind-hovering { + width: 402px; + transition: width 0.2s ease-out allow-discrete; +} + +@starting-style { + .sidebar .behind-hovering { + width: 0; } } @@ -589,7 +673,8 @@ p { z-index: 100; } -.overlay-background, .modal-background { +.overlay-background, +.modal-background { position: fixed; top: 0; left: 0; @@ -623,12 +708,83 @@ p { } .settings-main { + height: calc(100% - 56px); display: flex; flex: 1 1 auto; } .settings-page { flex: 1 1 0; + overflow-y: auto; +} + +.profile-settings { + display: flex; + justify-content: flex-end; + flex-wrap: wrap; + flex-direction: row-reverse; +} + +.profile-form { + flex: 1 1 auto; + margin: 16px; + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 16px; +} + +.profile-form label { + font-size: 1rem; +} + +.profile-form .change-avatar { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 16px; +} + +#client-user-avatar { + opacity: 0; + position: absolute; + z-index: -1; +} + +.profile-preview { + margin: 24px; + border: 2px solid black; + min-width: 240px; +} + +.profile-preview .preview { + display: flex; + flex-direction: column; + gap: 8px; +} + +.profile-preview h2 { + padding: 8px 16px; + border-bottom: 2px solid black; +} + +.profile-preview .avatar { + width: 64px; + height: 64px; +} + +.profile-preview .nick { + font-size: 20px; + font-weight: bold; +} + +hr { + width: 100%; + border: 1px solid black; +} + +.profile-preview .preview { + padding: 16px; } .modal .overlay { @@ -652,6 +808,7 @@ p { } .menu-item { + cursor: pointer; padding: 4px 8px; } @@ -674,6 +831,7 @@ p { font-size: 1.1em; font-weight: bold; } + .personal-status-menu .user .jid { font-family: Diolce; } @@ -697,12 +855,24 @@ hr { padding: 4px; } -.new-chat:hover, .new-chat.open, -.add-contact:hover, .add-contact.open, +.new-chat, .add-contact, .close { + cursor: pointer; +} + +.new-chat:hover, +.new-chat.open, +.add-contact:hover, +.add-contact.open, .close:hover { background: #00000060; } +.add-contact-panel { + flex-shrink: 0; + max-height: calc(100% - 150px); + border-bottom: 2px solid black; +} + .new-chat-widget form { border: 2px solid black; padding: 4px; @@ -713,17 +883,14 @@ hr { align-items: end; } -.roster-add-contact { - border-bottom: 2px solid black; -} - .add-contact-menu h3 { margin: 1em 0 0.5em; } .add-contact-menu form { display: flex; - gap: 16px; + flex-direction: column; + gap: 8px; } .add-contact-menu form input { @@ -736,6 +903,24 @@ hr { justify-content: space-between; } +.jid-with-buttons { + display: flex; + flex-direction: column; + align-items: stretch; + gap: 4px; + margin-bottom: 8px; +} + +.jid-with-buttons .buttons { + display: flex; + align-items: center; + gap: 4px; +} + +.jid-with-buttons .buttons>* { + flex: 1 1 auto; +} + .jid-with-button .jid { flex: 1 1 auto; } @@ -1,3 +1,9 @@ +<!-- +SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> + +SPDX-License-Identifier: AGPL-3.0-or-later +--> + <!DOCTYPE html> <html> @@ -7,6 +13,9 @@ <!-- If using Tailwind with Leptos CSR, see https://trunkrs.dev/assets/#tailwind instead--> <link data-trunk rel="scss" href="assets/style.scss" /> + <!-- overlay scrollbars --> + <link type="text/css" href="/assets/overlayscrollbars.min.css" rel="stylesheet" /> + <!-- Include favicon in dist output: see https://trunkrs.dev/assets/#icon --> <link data-trunk rel="icon" href="assets/bubble.png" /> diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d56faf..76a88f6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,6 @@ +# SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +# +# SPDX-License-Identifier: AGPL-3.0-or-later + [toolchain] channel = "nightly" diff --git a/src/chat.rs b/src/chat.rs index 29e2641..e40119f 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1,11 +1,18 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::ops::{Deref, DerefMut}; use filamento::{chat::Chat, user::User}; use jid::BareJID; -use reactive_stores::ArcStore; use leptos::prelude::*; +use reactive_stores::ArcStore; -use crate::{state_store::{StateListener, StateStore}, user::{ArcMacawUser, MacawUser}}; +use crate::{ + state_store::{StateListener, StateStore}, + user::{ArcMacawUser, MacawUser}, +}; #[derive(Clone, Copy)] pub struct MacawChat { @@ -59,11 +66,11 @@ pub struct ArcMacawChat { } impl ArcMacawChat { - pub fn got_chat_and_user(chat: Chat, user: User) -> Self { + pub async fn got_chat_and_user(chat: Chat, user: User) -> Self { let chat_state_store: StateStore<BareJID, ArcStore<Chat>> = use_context().expect("no chat state store"); let chat = chat_state_store.store(chat.correspondent.clone(), ArcStore::new(chat)); - let user = ArcMacawUser::got_user(user); + let user = ArcMacawUser::got_user(user).await; Self { chat, user } } } @@ -81,4 +88,3 @@ impl DerefMut for ArcMacawChat { &mut self.chat } } - diff --git a/src/client.rs b/src/client.rs index b3ff6bb..02ee537 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,4 +1,11 @@ -use std::{ops::{Deref, DerefMut}, sync::Arc}; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use std::{ + ops::{Deref, DerefMut}, + sync::Arc, +}; use jid::BareJID; use leptos::prelude::*; @@ -27,4 +34,3 @@ impl DerefMut for Client { &mut self.client } } - diff --git a/src/components/avatar.rs b/src/components/avatar.rs index 9265ef7..11d2097 100644 --- a/src/components/avatar.rs +++ b/src/components/avatar.rs @@ -1,36 +1,53 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use filamento::{presence::PresenceType, user::User}; use leptos::prelude::*; use reactive_stores::Store; -use crate::{components::icon::{show_to_icon, IconComponent}, icon::Icon, user::get_avatar, user_presences::UserPresences}; +use crate::{ + components::icon::{IconComponent, show_to_icon}, + icon::Icon, + user::{MacawUser, get_avatar}, + user_presences::UserPresences, +}; #[component] -pub fn AvatarWithPresence(user: Store<User>) -> impl IntoView { - let avatar = LocalResource::new(move || get_avatar(user)); +pub fn AvatarWithPresence(user: MacawUser) -> impl IntoView { let user_presences: Store<UserPresences> = use_context().expect("no user presences in context"); - let presence = move || user_presences.write().get_user_presences(&user.read().jid).read().presence(); - let show_icon = move || presence().map(|(_, presence)| { - match presence.presence { - PresenceType::Online(online) => if let Some(show) = online.show { - Some(show_to_icon(show)) - } else { - Some(Icon::Available16Color) - }, - PresenceType::Offline(offline) => None, - } - }).unwrap_or_default(); + let presence = move || { + user_presences + .write() + .get_user_presences(&user.get().read().jid) + .read() + .presence() + }; + let show_icon = move || { + presence() + .map(|(_, presence)| match presence.presence { + PresenceType::Online(online) => { + if let Some(show) = online.show { + Some(show_to_icon(show)) + } else { + Some(Icon::Available16Color) + } + } + PresenceType::Offline(offline) => None, + }) + .unwrap_or_default() + }; view! { <div class="avatar-with-presence"> - <img class="avatar" src=move || avatar.get() /> - {move || if let Some(icon) = show_icon() { - view!{ - <IconComponent icon=icon class:presence-show-icon=true /> - }.into_any() - } else { - view! {}.into_any() - }} + <img class="avatar" src=move || user.avatar().get() /> + {move || { + if let Some(icon) = show_icon() { + view! { <IconComponent icon=icon class:presence-show-icon=true /> }.into_any() + } else { + view! {}.into_any() + } + }} </div> } } - diff --git a/src/components/chat_header.rs b/src/components/chat_header.rs index ab33d2b..3fb5df8 100644 --- a/src/components/chat_header.rs +++ b/src/components/chat_header.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use filamento::user::UserStoreFields; use leptos::prelude::*; use reactive_stores::ArcStore; @@ -11,12 +15,12 @@ pub fn ChatViewHeader(chat: MacawChat) -> impl IntoView { view! { <div class="chat-view-header panel"> - <AvatarWithPresence user=chat.user.get().into() /> - <div class="user-info"> + {move || { + view! { <AvatarWithPresence user=chat.user /> } + }} <div class="user-info"> <h2 class="name">{name}</h2> <h3>{jid}</h3> </div> </div> } } - diff --git a/src/components/chats_list.rs b/src/components/chats_list.rs index a5ecc9b..73ffdff 100644 --- a/src/components/chats_list.rs +++ b/src/components/chats_list.rs @@ -1,10 +1,23 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use chats_list_item::ChatsListItem; use indexmap::IndexMap; use jid::BareJID; -use leptos::prelude::*; +use js_sys::{wasm_bindgen::UnwrapThrowExt, Object, Reflect, JSON}; +use leptos::{html::Div, prelude::*}; +use overlay_scrollbars::OverlayScrollbars; use tracing::debug; -use crate::{chat::{ArcMacawChat, MacawChat}, client::Client, components::{icon::IconComponent, new_chat::NewChatWidget, overlay::Overlay}, icon::Icon, message::{ArcMacawMessage, MacawMessage}, message_subscriptions::MessageSubscriptions}; +use crate::{ + chat::{ArcMacawChat, MacawChat}, + client::Client, + components::{icon::IconComponent, new_chat::NewChatWidget, overlay::Overlay}, + icon::Icon, + message::{ArcMacawMessage, MacawMessage}, + message_subscriptions::MessageSubscriptions, +}; mod chats_list_item; @@ -20,18 +33,16 @@ pub fn ChatsList() -> impl IntoView { .map_err(|e| e.to_string()); match chats { Ok(c) => { - let chats = c - .into_iter() - .map(|((chat, chat_user), (message, message_user))| { + let mut chats = IndexMap::new(); + for ((chat, chat_user), (message, message_user)) in c { + chats.insert( + chat.correspondent.clone(), ( - chat.correspondent.clone(), - ( - ArcMacawChat::got_chat_and_user(chat, chat_user), - ArcMacawMessage::got_message_and_user(message, message_user), - ), - ) - }) - .collect::<IndexMap<BareJID, _>>(); + ArcMacawChat::got_chat_and_user(chat, chat_user).await, + ArcMacawMessage::got_message_and_user(message, message_user).await, + ), + ); + } set_chats.set(chats); } Err(_) => { @@ -55,7 +66,10 @@ pub fn ChatsList() -> impl IntoView { if let Some((chat, _latest_message)) = chats.shift_remove(&to) { // TODO: check if new message is actually latest message debug!("chat existed"); - debug!("new message: {}", new_message.message.get().read().body.body); + debug!( + "new message: {}", + new_message.message.get().read().body.body + ); chats.insert_before(0, to, (chat.clone(), new_message)); debug!("done setting"); } else { @@ -64,7 +78,7 @@ pub fn ChatsList() -> impl IntoView { let chat = client.get_chat(to.clone()).await.unwrap(); let user = client.get_user(to.clone()).await.unwrap(); debug!("before got chat"); - let chat = ArcMacawChat::got_chat_and_user(chat, user); + let chat = ArcMacawChat::got_chat_and_user(chat, user).await; debug!("after got chat"); chats.insert_before(0, to, (chat, new_message)); debug!("done setting"); @@ -78,32 +92,65 @@ pub fn ChatsList() -> impl IntoView { } }); + let chats_list: NodeRef<Div> = NodeRef::new(); + let chats_list_viewport: NodeRef<Div> = NodeRef::new(); + + let _scrollbars = Effect::new(move |_| { + if let Some(buffer) = chats_list.get() { + if let Some(viewport) = chats_list_viewport.get() { + let scrollbars_obj = Object::new(); + // Reflect::set(&scrollbars_obj, &"theme".into(), &"os-macaw".into()).unwrap_throw(); + // Reflect::set(&scrollbars_obj, &"autoHide".into(), &"leave".into()).unwrap_throw(); + let options_obj = Object::new(); + // Reflect::set(&options_obj, &"scrollbars".into(), &scrollbars_obj).unwrap_throw(); + + let elements_obj = Object::new(); + Reflect::set(&elements_obj, &"viewport".into(), &viewport.into()).unwrap_throw(); + let element_obj = Object::new(); + Reflect::set(&elements_obj, &"elements".into(), &elements_obj).unwrap_throw(); + Reflect::set(&element_obj, &"target".into(), &buffer.into()).unwrap_throw(); + // let element = Object::define_property(&Object::define_property(&Object::new(), &"target".into(), &buffer.into()), &"elements".into(), &Object::define_property(&Object::new(), &"viewport".into(), &viewport.into())); + debug!("scrollable element: {}", JSON::stringify(&element_obj.clone().into()).unwrap_throw()); + OverlayScrollbars(element_obj, options_obj); + } + } + }); + view! { <div class="chats-list panel"> // TODO: update icon, tooltip on hover. <div class="header"> <h2>Chats</h2> - <div class="new-chat header-icon" class:open=open_new_chat > - <IconComponent icon=Icon::NewBubble24 on:click=move |_| set_open_new_chat.update(|state| *state = !*state)/> + <div class="new-chat header-icon" class:open=open_new_chat> + <IconComponent + icon=Icon::NewBubble24 + on:click=move |_| set_open_new_chat.update(|state| *state = !*state) + /> {move || { if *open_new_chat.read() { view! { <Overlay set_open=set_open_new_chat> <NewChatWidget set_open_new_chat /> </Overlay> - }.into_any() + } + .into_any() } else { view! {}.into_any() } }} </div> </div> - <div class="chats-list-chats"> - <For each=move || chats.get() key=|chat| chat.1.1.message.get().read().id let(chat)> - <ChatsListItem chat=chat.1.0.into() message=chat.1.1.into() /> - </For> + <div class="overlay-scroll" node_ref=chats_list> + <div class="chats-list-chats" node_ref=chats_list_viewport> + <For + each=move || chats.get() + key=|chat| chat.1.1.message.get().read().id + let(chat) + > + <ChatsListItem chat=chat.1.0.into() message=chat.1.1.into() /> + </For> + </div> </div> </div> } } - diff --git a/src/components/chats_list/chats_list_item.rs b/src/components/chats_list/chats_list_item.rs index d1da727..3e18dbe 100644 --- a/src/components/chats_list/chats_list_item.rs +++ b/src/components/chats_list/chats_list_item.rs @@ -1,12 +1,25 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::ops::Deref; use chrono::Local; -use filamento::{chat::{Chat, ChatStoreFields, Message, MessageStoreFields}, user::User}; +use filamento::{ + chat::{Chat, ChatStoreFields, Message, MessageStoreFields}, + user::User, +}; use leptos::prelude::*; use reactive_stores::{ArcStore, Store}; use tracing::debug; -use crate::{chat::MacawChat, components::{avatar::AvatarWithPresence, sidebar::Open}, message::MacawMessage, open_chats::{OpenChatsPanel, OpenChatsPanelStoreFields}, user::get_name}; +use crate::{ + chat::MacawChat, + components::{avatar::AvatarWithPresence, sidebar::Open}, + message::MacawMessage, + open_chats::{OpenChatsPanel, OpenChatsPanelStoreFields}, + user::get_name, +}; #[component] pub fn ChatsListItem(chat: MacawChat, message: MacawMessage) -> impl IntoView { @@ -44,19 +57,36 @@ pub fn ChatsListItem(chat: MacawChat, message: MacawMessage) -> impl IntoView { let date = move || message.get().timestamp().read().naive_local(); let now = move || Local::now().naive_local(); - let timeinfo = move || if date().date() == now().date() { - // TODO: localisation/config - date().time().format("%H:%M").to_string() - } else { - date().date().format("%d/%m").to_string() + let timeinfo = move || { + if date().date() == now().date() { + // TODO: localisation/config + date().time().format("%H:%M").to_string() + } else { + date().date().format("%d/%m").to_string() + } }; view! { - <div class="chats-list-item" class:open=move || open() class:focused=move || focused() on:click=open_chat> - <AvatarWithPresence user=chat.user.get().into() /> + <div + class="chats-list-item" + class:open=move || open() + class:focused=move || focused() + on:click=open_chat + > + {move || { + view! { <AvatarWithPresence user=chat.user /> } + }} <div class="item-info"> - <div class="main-info"><p class="name">{name}</p><p class="timestamp">{timeinfo}</p></div> - <div class="sub-info"><p class="message-preview">{latest_message_body}</p><p><!-- "TODO: delivery or unread state" --></p></div> + <div class="main-info"> + <p class="name">{name}</p> + <p class="timestamp">{timeinfo}</p> + </div> + <div class="sub-info"> + <p class="message-preview">{latest_message_body}</p> + <p> + <!-- "TODO: delivery or unread state" --> + </p> + </div> </div> </div> } diff --git a/src/components/icon.rs b/src/components/icon.rs index 7eaa52f..73b0f5d 100644 --- a/src/components/icon.rs +++ b/src/components/icon.rs @@ -1,5 +1,9 @@ -use leptos::prelude::*; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use filamento::{chat::Delivery, presence::Show}; +use leptos::prelude::*; use crate::icon::Icon; @@ -7,7 +11,12 @@ use crate::icon::Icon; #[component] pub fn IconComponent(icon: Icon) -> impl IntoView { view! { - <img class:light=icon.light() class:icon=true style=move || format!("height: {}px; width: {}px", icon.size(), icon.size()) src=move || icon.src() /> + <img + class:light=icon.light() + class:icon=true + style=move || format!("height: {}px; width: {}px", icon.size(), icon.size()) + src=move || icon.src() + /> } } @@ -53,5 +62,3 @@ pub fn Delivery(delivery: Delivery) -> impl IntoView { } } } - - diff --git a/src/components/message.rs b/src/components/message.rs index 5deccdd..83a4bad 100644 --- a/src/components/message.rs +++ b/src/components/message.rs @@ -1,52 +1,98 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use filamento::chat::MessageStoreFields; use leptos::prelude::*; use reactive_stores::{ArcStore, Store}; -use crate::{message::MacawMessage, user::{get_avatar, get_name, NO_AVATAR}}; +use crate::{ + message::MacawMessage, + user::{get_avatar, get_name, NO_AVATAR}, +}; use super::icon::Delivery; #[component] -pub fn Message(message: MacawMessage, major: bool, r#final: bool) -> impl IntoView { - let message_message: Store<filamento::chat::Message> = - <ArcStore<filamento::chat::Message> as Clone>::clone(&message.get()).into(); - let message_user = <ArcStore<filamento::user::User> as Clone>::clone(&message.user.get()).into(); - let avatar = LocalResource::new(move || get_avatar(message_user)); - let name = move || get_name(message_user, false); +pub fn Message(message: MacawMessage, major: bool, r#final: bool, new_day: bool) -> impl IntoView { + let name = move || get_name(message.user.get().into(), false); // TODO: chrono-humanize? // TODO: if final, show delivery not only on hover. // {move || message_message.delivery().read().map(|delivery| delivery.to_string()).unwrap_or_default()} - if major { - view! { - <div class:final=r#final class="chat-message major"> - <div class="left"> - <Transition fallback=|| view! { <img class="avatar" src=NO_AVATAR /> } > - <img class="avatar" src=move || avatar.get() /> - </Transition> + view! { + {move || { + if major { + view! { + <div class:final=r#final class="chat-message major"> + <div class="left"> + <Transition fallback=|| view! { <img class="avatar" src=NO_AVATAR /> }> + <img class="avatar" src=move || message.user.avatar().get() /> + </Transition> + </div> + <div class="middle"> + <div class="message-info"> + <div class="message-user-name">{name}</div> + <div class="message-timestamp"> + {move || { + message.get().timestamp().read().format("%H:%M").to_string() + }} + </div> + </div> + <div class="message-text"> + {move || message.get().body().read().body.clone()} + </div> + </div> + <div class="right message-delivery"> + {move || { + message + .get() + .delivery() + .get() + .map(|delivery| { + view! { <Delivery class:light=true delivery /> } + }) + }} + </div> </div> - <div class="middle"> - <div class="message-info"> - <div class="message-user-name">{name}</div> - <div class="message-timestamp">{move || message_message.timestamp().read().format("%H:%M").to_string()}</div> + } + .into_any() + } else { + view! { + <div class:final=r#final class="chat-message minor"> + <div class="left message-timestamp"> + {move || message.get().timestamp().read().format("%H:%M").to_string()} + </div> + <div class="middle message-text"> + {move || message.get().body().read().body.clone()} + </div> + <div class="right message-delivery"> + {move || { + message + .get() + .delivery() + .get() + .map(|delivery| view! { <Delivery delivery /> }) + }} + </div> </div> - <div class="message-text"> - {move || message_message.body().read().body.clone()} + } + .into_any() + } + }} + {move || { + if new_day { + view! { + <div class="new-day"> + {move || { + message.get().timestamp().read().format("%Y-%m-%d").to_string() + }} </div> - </div> - <div class="right message-delivery">{move || message_message.delivery().get().map(|delivery| view! { <Delivery class:light=true delivery /> } ) }</div> - </div> - }.into_any() - } else { - view! { - <div class:final=r#final class="chat-message minor"> - <div class="left message-timestamp"> - {move || message_message.timestamp().read().format("%H:%M").to_string()} - </div> - <div class="middle message-text">{move || message_message.body().read().body.clone()}</div> - <div class="right message-delivery">{move || message_message.delivery().get().map(|delivery| view! { <Delivery delivery /> } ) }</div> - </div> - }.into_any() + } + .into_any() + } else { + view! {}.into_any() + } + }} } } - diff --git a/src/components/message_composer.rs b/src/components/message_composer.rs index 3876a5a..fd4e59b 100644 --- a/src/components/message_composer.rs +++ b/src/components/message_composer.rs @@ -1,6 +1,13 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use filamento::chat::Body; use jid::BareJID; +use js_sys::{wasm_bindgen::UnwrapThrowExt, Object, Reflect, JSON}; use leptos::{html::Div, prelude::*, task::spawn_local}; +use overlay_scrollbars::OverlayScrollbars; +use tracing::debug; use crate::client::Client; @@ -60,38 +67,68 @@ pub fn ChatViewMessageComposer(chat: BareJID) -> impl IntoView { // }; // + let composer: NodeRef<Div> = NodeRef::new(); + + let _scrollbars = Effect::new(move |_| { + if let Some(buffer) = composer.get() { + if let Some(viewport) = message_input.get() { + let scrollbars_obj = Object::new(); + Reflect::set(&scrollbars_obj, &"theme".into(), &"os-macaw".into()).unwrap_throw(); + Reflect::set(&scrollbars_obj, &"autoHide".into(), &"leave".into()).unwrap_throw(); + let options_obj = Object::new(); + Reflect::set(&options_obj, &"scrollbars".into(), &scrollbars_obj).unwrap_throw(); + + let elements_obj = Object::new(); + Reflect::set(&elements_obj, &"viewport".into(), &viewport.into()).unwrap_throw(); + let element_obj = Object::new(); + Reflect::set(&elements_obj, &"elements".into(), &elements_obj).unwrap_throw(); + Reflect::set(&element_obj, &"target".into(), &buffer.into()).unwrap_throw(); + // let element = Object::define_property(&Object::define_property(&Object::new(), &"target".into(), &buffer.into()), &"elements".into(), &Object::define_property(&Object::new(), &"viewport".into(), &viewport.into())); + debug!( + "scrollable element: {}", + JSON::stringify(&element_obj.clone().into()).unwrap_throw() + ); + debug!( + "scrollable options: {}", + JSON::stringify(&options_obj.clone().into()).unwrap_throw() + ); + OverlayScrollbars(element_obj, options_obj); + } + } + }); + // TODO: placeholder view! { - <form - class="new-message-composer panel" - > - <div - class="text-box" - on:input:target=move |ev| new_message.set(ev.target().text_content().unwrap_or_default()) - node_ref=message_input - contenteditable - on:keydown=move |ev| { - match ev.key_code() { - 16 => set_shift_pressed.set(true), - 13 => if !shift_pressed.get() { - ev.prevent_default(); - send_message(); + <form class="new-message-composer panel"> + <div class="overlay-scroll" node_ref=composer> + <div + class="text-box" + on:input:target=move |ev| { + new_message.set(ev.target().text_content().unwrap_or_default()) + } + node_ref=message_input + contenteditable + on:keydown=move |ev| { + match ev.key_code() { + 16 => set_shift_pressed.set(true), + 13 => { + if !shift_pressed.get() { + ev.prevent_default(); + send_message(); + } + } + _ => {} } - _ => {} - // debug!("shift pressed down"); } - } - on:keyup=move |ev| { - match ev.key_code() { - 16 => set_shift_pressed.set(false), - _ => {} - // debug!("shift released"); + on:keyup=move |ev| { + match ev.key_code() { + 16 => set_shift_pressed.set(false), + _ => {} + } } - } - ></div> - // <input hidden type="submit" /> + ></div> + </div> + // <input hidden type="submit" /> </form> } } - - diff --git a/src/components/message_history_buffer.rs b/src/components/message_history_buffer.rs index ecdba5b..c733700 100644 --- a/src/components/message_history_buffer.rs +++ b/src/components/message_history_buffer.rs @@ -1,5 +1,12 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use chrono::{NaiveDateTime, TimeDelta}; -use filamento::{chat::{Chat, ChatStoreFields, MessageStoreFields}, user::User}; +use filamento::{ + chat::{Chat, ChatStoreFields, MessageStoreFields}, + user::User, +}; use indexmap::IndexMap; use jid::BareJID; use leptos::prelude::*; @@ -7,15 +14,17 @@ use reactive_stores::{ArcStore, Store}; use tracing::{debug, error}; use uuid::Uuid; -use crate::{chat::MacawChat, client::Client, components::message::Message, message::{ArcMacawMessage, MacawMessage}, message_subscriptions::MessageSubscriptions}; +use crate::{ + chat::MacawChat, + client::Client, + components::message::Message, + message::{ArcMacawMessage, MacawMessage}, + message_subscriptions::MessageSubscriptions, +}; #[component] pub fn MessageHistoryBuffer(chat: MacawChat) -> impl IntoView { let (messages, set_messages) = arc_signal(IndexMap::new()); - let chat_chat: Store<Chat> = - <ArcStore<filamento::chat::Chat> as Clone>::clone(&chat.get()).into(); - let chat_user: Store<User> = - <ArcStore<filamento::user::User> as Clone>::clone(&chat.user.get()).into(); let load_set_messages = set_messages.clone(); let load_messages = LocalResource::new(move || { @@ -23,20 +32,18 @@ pub fn MessageHistoryBuffer(chat: MacawChat) -> impl IntoView { async move { let client = use_context::<Client>().expect("client not in context"); let messages = client - .get_messages_with_users(chat_chat.correspondent().get()) + .get_messages_with_users(chat.get().correspondent().get()) .await .map_err(|e| e.to_string()); match messages { Ok(m) => { - let messages = m - .into_iter() - .map(|(message, message_user)| { - ( - message.id, - ArcMacawMessage::got_message_and_user(message, message_user), - ) - }) - .collect::<IndexMap<Uuid, _>>(); + let mut messages = IndexMap::new(); + for (message, message_user) in m { + messages.insert( + message.id, + ArcMacawMessage::got_message_and_user(message, message_user).await, + ); + } load_set_messages.set(messages); } Err(err) => { @@ -57,40 +64,22 @@ pub fn MessageHistoryBuffer(chat: MacawChat) -> impl IntoView { load_messages.await; let (sub_id, mut new_messages) = new_messages_signal .write() - .subscribe_chat(chat_chat.correspondent().get()); + .subscribe_chat(chat.get().correspondent().get()); set_sub_id.set(Some(sub_id)); while let Some(new_message) = new_messages.recv().await { debug!("got new message in let message buffer"); let mut messages = load_new_messages_set.write(); if let Some((_, last)) = messages.last() { - if *<ArcStore<filamento::chat::Message> as Clone>::clone(&last.message.get()) - .timestamp() - .read() - < *<ArcStore<filamento::chat::Message> as Clone>::clone(&new_message.message.get()) - .timestamp() - .read() - { - messages.insert( - <ArcStore<filamento::chat::Message> as Clone>::clone( - &new_message.message.get(), - ) - .id() - .get(), - new_message, - ); + if *last.get().timestamp().read() < *new_message.get().timestamp().read() { + messages.insert(new_message.get().id().get(), new_message); debug!("set the new message in message buffer"); } else { let index = match messages.binary_search_by(|_, value| { - <ArcStore<filamento::chat::Message> as Clone>::clone(&value.message.get()) + value + .get() .timestamp() .read() - .cmp( - &<ArcStore<filamento::chat::Message> as Clone>::clone( - &new_message.message.get(), - ) - .timestamp() - .read(), - ) + .cmp(&new_message.get().timestamp().read()) }) { Ok(i) => i, Err(i) => i, @@ -98,22 +87,13 @@ pub fn MessageHistoryBuffer(chat: MacawChat) -> impl IntoView { messages.insert_before( // TODO: check if this logic is correct index, - <ArcStore<filamento::chat::Message> as Clone>::clone( - &new_message.message.get(), - ) - .id() - .get(), + new_message.get().id().get(), new_message, ); debug!("set the new message in message buffer"); } } else { - messages.insert( - <ArcStore<filamento::chat::Message> as Clone>::clone(&new_message.message.get()) - .id() - .get(), - new_message, - ); + messages.insert(new_message.get().id().get(), new_message); debug!("set the new message in message buffer"); } } @@ -123,7 +103,7 @@ pub fn MessageHistoryBuffer(chat: MacawChat) -> impl IntoView { if let Some(sub_id) = sub_id.get_untracked() { new_messages_signal .write() - .unsubscribe_chat(sub_id, chat_chat.correspondent().get_untracked()); + .unsubscribe_chat(sub_id, chat.get().correspondent().get_untracked()); } }); @@ -134,32 +114,26 @@ pub fn MessageHistoryBuffer(chat: MacawChat) -> impl IntoView { .get() .into_iter() .map(|(id, message)| { - let message_timestamp = - <ArcStore<filamento::chat::Message> as Clone>::clone(&message.message.get()) - .timestamp() - .read() - .naive_local(); - // TODO: mark new day - // if message_timestamp.date() > last_timestamp.date() { - // messages_view = messages_view.push(date(message_timestamp.date())); - // } - let major = if last_user.as_ref() != Some(&message.message.get().read().from) + let message_timestamp = message.message.get().timestamp().read().naive_local(); + let mut major = if last_user.as_ref() != Some(&message.message.get().read().from) || message_timestamp - last_timestamp > TimeDelta::minutes(3) { true } else { false }; - last_user = Some( - <ArcStore<filamento::chat::Message> as Clone>::clone(&message.message.get()) - .from() - .get(), - ); + let new_day = if message_timestamp.date() > last_timestamp.date() { + major = true; + true + } else { + false + }; + last_user = Some(message.get().from().get()); last_timestamp = message_timestamp; - (id, (message, major, false)) + (id, (message, major, false, new_day)) }) .collect::<Vec<_>>(); - if let Some((_id, (_, _, last))) = messages.last_mut() { + if let Some((_id, (_, _, last, _))) = messages.last_mut() { *last = true } messages.into_iter().rev() @@ -167,10 +141,18 @@ pub fn MessageHistoryBuffer(chat: MacawChat) -> impl IntoView { view! { <div class="messages-buffer"> - <For each=each key=|message| (message.0, message.1.1, message.1.2) let(message)> - <Message message=message.1.0.into() major=message.1.1 r#final=message.1.2 /> + <For + each=each + key=|message| (message.0, message.1.1, message.1.2, message.1.3) + let(message) + > + <Message + message=message.1.0.into() + major=message.1.1 + r#final=message.1.2 + new_day=message.1.3 + /> </For> </div> } } - diff --git a/src/components/mod.rs b/src/components/mod.rs index 879f99e..d2fb6b5 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,13 +1,17 @@ -pub mod sidebar; -mod chats_list; -mod new_chat; -mod roster_list; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + mod avatar; +pub mod chat_header; +mod chats_list; +pub mod icon; mod message; -pub mod message_history_buffer; pub mod message_composer; -pub mod chat_header; -mod overlay; +pub mod message_history_buffer; pub mod modal; -pub mod icon; +mod new_chat; +mod overlay; mod personal_status; +mod roster_list; +pub mod sidebar; diff --git a/src/components/modal.rs b/src/components/modal.rs index 62e1fac..e23fa5d 100644 --- a/src/components/modal.rs +++ b/src/components/modal.rs @@ -1,16 +1,25 @@ -use leptos::prelude::*; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use leptos::ev::MouseEvent; +use leptos::prelude::*; #[component] -pub fn Modal(on_background_click: impl Fn(MouseEvent) + 'static, children: Children) -> impl IntoView { +pub fn Modal( + on_background_click: impl Fn(MouseEvent) + 'static, + children: Children, +) -> impl IntoView { view! { - <div class="modal" on:click=move |e| { - if e.current_target() == e.target() { - on_background_click(e) + <div + class="modal" + on:click=move |e| { + if e.current_target() == e.target() { + on_background_click(e) + } } - }> + > {children()} </div> } } - diff --git a/src/components/new_chat.rs b/src/components/new_chat.rs index b706ca9..925ec57 100644 --- a/src/components/new_chat.rs +++ b/src/components/new_chat.rs @@ -1,12 +1,26 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::str::FromStr; -use filamento::{chat::Chat, error::{CommandError, DatabaseError}, user::User}; +use filamento::{ + chat::Chat, + error::{CommandError, DatabaseError}, + user::User, +}; use jid::{BareJID, JID}; use leptos::{html::Input, prelude::*}; use reactive_stores::{ArcStore, Store}; use thiserror::Error; -use crate::{chat::{ArcMacawChat, MacawChat}, client::Client, open_chats::OpenChatsPanel, state_store::StateStore, user::{ArcMacawUser, MacawUser}}; +use crate::{ + chat::{ArcMacawChat, MacawChat}, + client::Client, + open_chats::OpenChatsPanel, + state_store::StateStore, + user::{ArcMacawUser, MacawUser, fetch_avatar}, +}; #[derive(Clone, Debug, Error)] pub enum NewChatError { @@ -34,14 +48,14 @@ pub fn NewChatWidget(set_open_new_chat: WriteSignal<bool>) -> impl IntoView { }) }; let (new_chat_pending, set_new_chat_pending) = signal(false); - + let open_chats: Store<OpenChatsPanel> = use_context().expect("no open chats panel store in context"); let client = use_context::<Client>().expect("client not in context"); let chat_state_store: StateStore<BareJID, ArcStore<Chat>> = use_context().expect("no chat state store"); - let user_state_store: StateStore<BareJID, ArcStore<User>> = + let user_state_store: StateStore<BareJID, (ArcStore<User>, ArcRwSignal<String>)> = use_context().expect("no user state store"); let open_chat = Action::new_local(move |_| { @@ -72,12 +86,23 @@ pub fn NewChatWidget(set_open_new_chat: WriteSignal<bool>) -> impl IntoView { set_error.set(Some(e.into())); set_new_chat_pending.set(false); return; - }, + } }; let chat = { // let user = MacawUser::got_user(user); - let user = user_state_store.store(user.jid.clone(), ArcStore::new(user)); + // let user = user_state_store.store(user.jid.clone(), ArcStore::new(user)); + let old_user = user_state_store.get_listener(user.jid.clone()); + let user = if let Some(old_user) = old_user { + old_user.update(|(old_user, _avatar)| { + old_user.set(user); + }); + old_user + } else { + let avatar = fetch_avatar(user.avatar.as_deref()).await; + let avatar = ArcRwSignal::new(avatar); + user_state_store.store(user.jid.clone(), (ArcStore::new(user), avatar)) + }; let user = ArcMacawUser { user }; let chat = chat_state_store.store(chat.correspondent.clone(), ArcStore::new(chat)); ArcMacawChat { chat, user } @@ -120,4 +145,3 @@ pub fn NewChatWidget(set_open_new_chat: WriteSignal<bool>) -> impl IntoView { </div> } } - diff --git a/src/components/overlay.rs b/src/components/overlay.rs index d4ff1bf..d10f33a 100644 --- a/src/components/overlay.rs +++ b/src/components/overlay.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use leptos::prelude::*; use tracing::debug; @@ -5,12 +9,14 @@ use tracing::debug; pub fn Overlay(set_open: WriteSignal<bool>, children: Children) -> impl IntoView { view! { <div class="overlay"> - <div class="overlay-background" on:click=move |_| { - debug!("set open to false"); - set_open.update(|state| *state = false) - }></div> + <div + class="overlay-background" + on:click=move |_| { + debug!("set open to false"); + set_open.update(|state| *state = false) + } + ></div> <div class="overlay-content">{children()}</div> </div> } } - diff --git a/src/components/personal_status.rs b/src/components/personal_status.rs index 8439756..b74b366 100644 --- a/src/components/personal_status.rs +++ b/src/components/personal_status.rs @@ -1,65 +1,93 @@ -use filamento::{presence::{Offline, Online, PresenceType, Show}, user::{User, UserStoreFields}}; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use filamento::{ + presence::{Offline, Online, PresenceType, Show}, + user::{User, UserStoreFields}, +}; use leptos::{html, prelude::*}; use reactive_stores::{ArcStore, Store}; use tracing::{debug, error}; -use crate::{client::Client, components::{avatar::AvatarWithPresence, overlay::Overlay}, user::{get_name, MacawUser}, user_presences::UserPresences, views::{macaw::settings::SettingsPage, AppState}}; +use crate::{ + client::Client, + components::{avatar::AvatarWithPresence, overlay::Overlay}, + user::{MacawUser, get_name}, + user_presences::UserPresences, + views::{AppState, macaw::settings::SettingsPage}, +}; #[component] pub fn PersonalStatus() -> impl IntoView { let user: LocalResource<MacawUser> = use_context().expect("no local user in context"); let (open, set_open) = signal(false); - move || if let Some(user) = user.get() { - view! { - <div class="dock-item" class:focused=move || *open.read() on:click=move |_| { - debug!("set open to true"); - set_open.update(|state| *state = !*state) - }> - <AvatarWithPresence user=user.get().into() /> - <div class="dock-pill"></div> - </div> - {move || { - let open = open.get(); - debug!("open = {:?}", open); - if open { - view! { - <Overlay set_open> - <PersonalStatusMenu user=user.get().into() set_open/> - </Overlay> - }.into_any() - } else { - view! {}.into_any() - }}} - }.into_any() - } else { - view! {}.into_any() + move || { + if let Some(user) = user.get() { + view! { + <div + class="dock-item" + class:focused=move || *open.read() + on:click=move |_| { + debug!("set open to true"); + set_open.update(|state| *state = !*state) + } + > + <AvatarWithPresence user /> + <div class="dock-pill"></div> + </div> + {move || { + let open = open.get(); + debug!("open = {:?}", open); + if open { + view! { + <Overlay set_open> + <PersonalStatusMenu user set_open /> + </Overlay> + } + .into_any() + } else { + view! {}.into_any() + } + }} + } + .into_any() + } else { + view! {}.into_any() + } } } #[component] -pub fn PersonalStatusMenu(user: Store<User>, set_open: WriteSignal<bool>) -> impl IntoView { +pub fn PersonalStatusMenu(user: MacawUser, set_open: WriteSignal<bool>) -> impl IntoView { let set_app: WriteSignal<AppState> = use_context().unwrap(); let show_settings: RwSignal<Option<SettingsPage>> = use_context().unwrap(); let user_presences: Store<UserPresences> = use_context().expect("no user presence store"); - + let client = use_context::<Client>().expect("client not in context"); let client1 = client.clone(); let (show_value, set_show_value) = signal({ - let show = match user_presences.write().get_user_presences(&user.jid().read()).write().resource_presence(client.resource.read().clone().unwrap_or_default()).presence { - PresenceType::Online(online) => match online.show { - Some(s) => match s { - Show::Away => 3, - Show::Chat => 0, - Show::DoNotDisturb => 2, - Show::ExtendedAway => 4, + let show = match user_presences + .write() + .get_user_presences(&user.get().jid().read()) + .write() + .resource_presence(client.resource.read().clone().unwrap_or_default()) + .presence + { + PresenceType::Online(online) => match online.show { + Some(s) => match s { + Show::Away => 3, + Show::Chat => 0, + Show::DoNotDisturb => 2, + Show::ExtendedAway => 4, + }, + None => 1, }, - None => 1, - }, - PresenceType::Offline(_offline) => 5, - }; - debug!("initial show = {show}"); - show + PresenceType::Offline(_offline) => 5, + }; + debug!("initial show = {show}"); + show }); let show_select: NodeRef<html::Select> = NodeRef::new(); @@ -71,7 +99,7 @@ pub fn PersonalStatusMenu(user: Store<User>, set_open: WriteSignal<bool>) -> imp } }); let set_status = Action::new_local(move |show_value: &i32| { - let show_value = show_value.to_owned(); + let show_value = show_value.to_owned(); let client = client1.clone(); async move { if let Err(e) = match show_value { @@ -79,46 +107,71 @@ pub fn PersonalStatusMenu(user: Store<User>, set_open: WriteSignal<bool>) -> imp if let Ok(r) = client.connect().await { client.resource.set(Some(r)) }; - client.set_status(Online { show: Some(Show::Chat), ..Default::default() }).await - }, + client + .set_status(Online { + show: Some(Show::Chat), + ..Default::default() + }) + .await + } 1 => { if let Ok(r) = client.connect().await { client.resource.set(Some(r)) }; - client.set_status(Online { show: None, ..Default::default() }).await - }, + client + .set_status(Online { + show: None, + ..Default::default() + }) + .await + } 2 => { if let Ok(r) = client.connect().await { client.resource.set(Some(r)) }; - client.set_status(Online { show: Some(Show::DoNotDisturb), ..Default::default() }).await - }, + client + .set_status(Online { + show: Some(Show::DoNotDisturb), + ..Default::default() + }) + .await + } 3 => { if let Ok(r) = client.connect().await { client.resource.set(Some(r)) }; - client.set_status(Online { show: Some(Show::Away), ..Default::default() }).await - }, + client + .set_status(Online { + show: Some(Show::Away), + ..Default::default() + }) + .await + } 4 => { if let Ok(r) = client.connect().await { client.resource.set(Some(r)) }; - client.set_status(Online { show: Some(Show::ExtendedAway), ..Default::default() }).await - }, + client + .set_status(Online { + show: Some(Show::ExtendedAway), + ..Default::default() + }) + .await + } 5 => { if let Ok(_) = client.disconnect(Offline::default()).await { client.resource.set(None) } set_show_value.set(5); - return + return; } _ => { error!("invalid availability select"); - return + return; } } { error!("show set error: {e}"); - return + return; } set_show_value.set(show_value); } @@ -129,8 +182,8 @@ pub fn PersonalStatusMenu(user: Store<User>, set_open: WriteSignal<bool>) -> imp <div class="user"> <AvatarWithPresence user=user /> <div class="user-info"> - <div class="nick">{move || get_name(user, false)}</div> - <div class="jid">{move || user.jid().with(|jid| jid.to_string())}</div> + <div class="nick">{move || get_name(user.get().into(), false)}</div> + <div class="jid">{move || user.get().jid().with(|jid| jid.to_string())}</div> </div> </div> <div class="status-edit"> @@ -142,36 +195,55 @@ pub fn PersonalStatusMenu(user: Store<User>, set_open: WriteSignal<bool>) -> imp } prop:show_value=move || show_value.get().to_string() > - <option value="0" selected=move || show_value.get_untracked() == 0>Available to Chat</option> - <option value="1" selected=move || show_value.get_untracked() == 1>Online</option> - <option value="2" selected=move || show_value.get_untracked() == 2>Do not disturb</option> - <option value="3" selected=move || show_value.get_untracked() == 3>Away</option> - <option value="4" selected=move || show_value.get_untracked() == 4>Extended Away</option> - <option value="5" selected=move || show_value.get_untracked() == 5>Offline</option> + <option value="0" selected=move || show_value.get_untracked() == 0> + Available to Chat + </option> + <option value="1" selected=move || show_value.get_untracked() == 1> + Online + </option> + <option value="2" selected=move || show_value.get_untracked() == 2> + Do not disturb + </option> + <option value="3" selected=move || show_value.get_untracked() == 3> + Away + </option> + <option value="4" selected=move || show_value.get_untracked() == 4> + Extended Away + </option> + <option value="5" selected=move || show_value.get_untracked() == 5> + Offline + </option> </select> </div> <hr /> - <div class="menu-item" on:click=move |_| { - show_settings.set(Some(SettingsPage::Profile)); - set_open.set(false); - }> + <div + class="menu-item" + on:click=move |_| { + show_settings.set(Some(SettingsPage::Profile)); + set_open.set(false); + } + > Profile </div> - <div class="menu-item" on:click=move |_| { - show_settings.set(Some(SettingsPage::Account)); - set_open.set(false); - }> + <div + class="menu-item" + on:click=move |_| { + show_settings.set(Some(SettingsPage::Account)); + set_open.set(false); + } + > Settings </div> <hr /> - <div class="menu-item" on:click=move |_| { - // TODO: check if client is actually dropped/shutdown eventually - disconnect.dispatch(()); - set_app.set(AppState::LoggedOut) - }> + <div + class="menu-item" + on:click=move |_| { + disconnect.dispatch(()); + set_app.set(AppState::LoggedOut) + } + > Log out </div> </div> } } - diff --git a/src/components/roster_list.rs b/src/components/roster_list.rs index a398ffe..b018d45 100644 --- a/src/components/roster_list.rs +++ b/src/components/roster_list.rs @@ -1,22 +1,88 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::collections::HashSet; use contact_request_manager::AddContact; use jid::BareJID; -use leptos::prelude::*; +use js_sys::{wasm_bindgen::UnwrapThrowExt, Object, Reflect, JSON}; +use leptos::{html::Div, prelude::*}; +use overlay_scrollbars::OverlayScrollbars; use reactive_stores::Store; use roster_list_item::RosterListItem; +use tracing::debug; -use crate::{components::icon::IconComponent, icon::Icon, roster::{Roster, RosterStoreFields}}; +use crate::{ + components::icon::IconComponent, + icon::Icon, + open_chats::{OpenChatsPanel, OpenChatsPanelStoreFields}, + roster::{Roster, RosterStoreFields}, +}; mod contact_request_manager; mod roster_list_item; #[component] pub fn RosterList() -> impl IntoView { - let requests: ReadSignal<HashSet<BareJID>> = use_context().expect("no pending subscriptions in context"); + let requests: ReadSignal<HashSet<BareJID>> = + use_context().expect("no pending subscriptions in context"); + + let open_chats: Store<OpenChatsPanel> = + use_context().expect("no open chats panel store in context"); let roster: Store<Roster> = use_context().expect("no roster in context"); let (open_add_contact, set_open_add_contact) = signal(false); + let open_chat = Memo::new(move |_| open_chats.chat_view().get()); + provide_context(open_chat); + + let roster_list: NodeRef<Div> = NodeRef::new(); + let roster_list_viewport: NodeRef<Div> = NodeRef::new(); + + let _scrollbars = Effect::new(move |_| { + if let Some(buffer) = roster_list.get() { + if let Some(viewport) = roster_list_viewport.get() { + let elements_obj = Object::new(); + Reflect::set(&elements_obj, &"viewport".into(), &viewport.into()).unwrap_throw(); + let element_obj = Object::new(); + Reflect::set(&elements_obj, &"elements".into(), &elements_obj).unwrap_throw(); + Reflect::set(&element_obj, &"target".into(), &buffer.into()).unwrap_throw(); + // let element = Object::define_property(&Object::define_property(&Object::new(), &"target".into(), &buffer.into()), &"elements".into(), &Object::define_property(&Object::new(), &"viewport".into(), &viewport.into())); + debug!( + "scrollable element: {}", + JSON::stringify(&element_obj.clone().into()).unwrap_throw() + ); + OverlayScrollbars(element_obj, Object::new()); + } + } + }); + + let add_contact: NodeRef<Div> = NodeRef::new(); + let add_contact_viewport: NodeRef<Div> = NodeRef::new(); + + let _scrollbars = Effect::new(move |_| { + if let Some(buffer) = add_contact.get() { + if let Some(viewport) = add_contact_viewport.get() { + let scrollbars_obj = Object::new(); + Reflect::set(&scrollbars_obj, &"theme".into(), &"os-macaw".into()).unwrap_throw(); + Reflect::set(&scrollbars_obj, &"move".into(), &"leave".into()).unwrap_throw(); + let options_obj = Object::new(); + Reflect::set(&options_obj, &"scrollbars".into(), &scrollbars_obj).unwrap_throw(); + + let elements_obj = Object::new(); + Reflect::set(&elements_obj, &"viewport".into(), &viewport.into()).unwrap_throw(); + let element_obj = Object::new(); + Reflect::set(&elements_obj, &"elements".into(), &elements_obj).unwrap_throw(); + Reflect::set(&element_obj, &"target".into(), &buffer.into()).unwrap_throw(); + // let element = Object::define_property(&Object::define_property(&Object::new(), &"target".into(), &buffer.into()), &"elements".into(), &Object::define_property(&Object::new(), &"viewport".into(), &viewport.into())); + debug!( + "scrollable element: {}", + JSON::stringify(&element_obj.clone().into()).unwrap_throw() + ); + OverlayScrollbars(element_obj, options_obj); + } + } + }); // TODO: filter new messages signal view! { @@ -24,12 +90,13 @@ pub fn RosterList() -> impl IntoView { <div class="header"> <h2>Roster</h2> <div class="add-contact header-icon" class:open=open_add_contact> - <IconComponent icon=Icon::AddContact24 on:click=move |_| set_open_add_contact.update(|state| *state = !*state)/> + <IconComponent + icon=Icon::AddContact24 + on:click=move |_| set_open_add_contact.update(|state| *state = !*state) + /> {move || { if !requests.read().is_empty() { - view! { - <div class="badge"></div> - }.into_any() + view! { <div class="badge"></div> }.into_any() } else { view! {}.into_any() } @@ -39,20 +106,28 @@ pub fn RosterList() -> impl IntoView { {move || { if *open_add_contact.read() { view! { - <div class="roster-add-contact"> - <AddContact /> + <div class="overlay-scroll add-contact-panel" node_ref=add_contact> + <div class="roster-add-contact" node_ref=add_contact_viewport> + <AddContact /> + </div> </div> - }.into_any() + } + .into_any() } else { view! {}.into_any() } }} - <div class="roster-list-roster"> - <For each=move || roster.contacts().get() key=|contact| contact.0.clone() let(contact)> - <RosterListItem contact=contact.1 /> - </For> + <div class="overlay-scroll" node_ref=roster_list> + <div class="roster-list-roster" node_ref=roster_list_viewport> + <For + each=move || roster.contacts().get() + key=|contact| contact.0.clone() + let(contact) + > + <RosterListItem contact=contact.1 /> + </For> + </div> </div> </div> } } - diff --git a/src/components/roster_list/contact_request_manager.rs b/src/components/roster_list/contact_request_manager.rs index 174e677..4c28142 100644 --- a/src/components/roster_list/contact_request_manager.rs +++ b/src/components/roster_list/contact_request_manager.rs @@ -1,12 +1,22 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::{collections::HashSet, str::FromStr}; -use filamento::{error::{CommandError, SubscribeError}, roster::ContactStoreFields}; +use filamento::{ + error::{CommandError, SubscribeError}, + roster::ContactStoreFields, +}; use jid::{BareJID, JID}; use leptos::{html::Input, prelude::*}; use reactive_stores::Store; use thiserror::Error; -use crate::{client::Client, roster::{Roster, RosterStoreFields}}; +use crate::{ + client::Client, + roster::{Roster, RosterStoreFields}, +}; #[derive(Clone, Debug, Error)] pub enum AddContactError { @@ -21,9 +31,11 @@ pub enum AddContactError { #[component] // TODO: rename pub fn AddContact() -> impl IntoView { - let requests: ReadSignal<HashSet<BareJID>> = use_context().expect("no pending subscriptions in context"); - let set_requests: WriteSignal<HashSet<BareJID>> = use_context().expect("no pending subscriptions write signal in context"); - let roster: Store<Roster> = use_context().expect("no roster in context"); + let requests: ReadSignal<HashSet<BareJID>> = + use_context().expect("no pending subscriptions in context"); + let set_requests: WriteSignal<HashSet<BareJID>> = + use_context().expect("no pending subscriptions write signal in context"); + let roster: Store<Roster> = use_context().expect("no roster in context"); let jid = RwSignal::new("".to_string()); // TODO: compartmentalise into error component, form component... @@ -43,8 +55,9 @@ pub fn AddContact() -> impl IntoView { let client2 = client.clone(); let client3 = client.clone(); let client4 = client.clone(); + let client5 = client.clone(); - let add_contact= Action::new_local(move |_| { + let add_contact = Action::new_local(move |_| { let client = client.clone(); async move { set_add_contact_pending.set(true); @@ -71,8 +84,8 @@ pub fn AddContact() -> impl IntoView { Err(e) => { set_error.set(Some(e.into())); set_add_contact_pending.set(false); - return; - }, + return; + } }; set_add_contact_pending.set(false); @@ -90,26 +103,44 @@ pub fn AddContact() -> impl IntoView { } }); - let outgoing = move || roster.contacts().get().into_iter().filter(|(jid, contact)| { - match *contact.contact.subscription().read() { - filamento::roster::Subscription::None => false, - filamento::roster::Subscription::PendingOut => true, - filamento::roster::Subscription::PendingIn => false, - filamento::roster::Subscription::PendingInPendingOut => true, - filamento::roster::Subscription::OnlyOut => false, - filamento::roster::Subscription::OnlyIn => false, - filamento::roster::Subscription::OutPendingIn => false, - filamento::roster::Subscription::InPendingOut => true, - filamento::roster::Subscription::Buddy => false, - } - }).collect::<Vec<_>>(); + let outgoing = move || { + roster + .contacts() + .get() + .into_iter() + .filter( + |(jid, contact)| match *contact.contact.subscription().read() { + filamento::roster::Subscription::None => false, + filamento::roster::Subscription::PendingOut => true, + filamento::roster::Subscription::PendingIn => false, + filamento::roster::Subscription::PendingInPendingOut => true, + filamento::roster::Subscription::OnlyOut => false, + filamento::roster::Subscription::OnlyIn => false, + filamento::roster::Subscription::OutPendingIn => false, + filamento::roster::Subscription::InPendingOut => true, + filamento::roster::Subscription::Buddy => false, + }, + ) + .collect::<Vec<_>>() + }; let accept_friend_request = Action::new_local(move |jid: &BareJID| { let client = client2.clone(); let jid = jid.clone(); async move { // TODO: error - client.accept_buddy_request(jid).await; + client.accept_buddy_request(jid.clone()).await; + set_requests.write().remove(&jid); + } + }); + + let accept_subscription_request = Action::new_local(move |jid: &BareJID| { + let client = client5.clone(); + let jid = jid.clone(); + async move { + // TODO: error + client.accept_subscription_request(jid.clone()).await; + set_requests.write().remove(&jid); } }); @@ -129,70 +160,125 @@ pub fn AddContact() -> impl IntoView { async move { // TODO: error client.unsubscribe_from_contact(jid).await; - } }); view! { <div class="add-contact-menu"> - <div> - {error_message} - <form on:submit=move |ev| { - ev.prevent_default(); - add_contact.dispatch(()); - }> - <input - disabled=add_contact_pending - placeholder="JID" - type="text" - node_ref=jid_input - bind:value=jid - name="jid" - id="jid" - autofocus="true" - /> - <input disabled=add_contact_pending class="button" type="submit" value="Send Friend Request" /> - </form> - </div> - {move || if !requests.read().is_empty() { - view! { - <div> - <h3>Incoming Subscription Requests</h3> - <For each=move || requests.get() key=|request| request.clone() let(request)> - { - let request2 = request.clone(); - let request3 = request.clone(); - let jid_string = move || request.to_string(); - view! { - <div class="jid-with-button"><div class="jid">{jid_string}</div> - <div><div class="button" on:click=move |_| { accept_friend_request.dispatch(request2.clone()); } >Accept</div><div class="button" on:click=move |_| { reject_friend_request.dispatch(request3.clone()); } >Reject</div></div></div> - } - } - </For> - </div> - }.into_any() - } else { - view! {}.into_any() - }} - {move || if !outgoing().is_empty() { - view! { - <div> - <h3>Pending Outgoing Subscription Requests</h3> - <For each=move || outgoing() key=|(jid, _contact)| jid.clone() let((jid, contact))> - { - let jid2 = jid.clone(); - let jid_string = move || jid.to_string(); - view! { - <div class="jid-with-button"><div class="jid">{jid_string}</div><div class="button" on:click=move |_| { cancel_subscription_request.dispatch(jid2.clone()); } >Cancel</div></div> - } - } - </For> - </div> - }.into_any() - } else { - view! {}.into_any() - }} + <div> + {error_message} + <form on:submit=move |ev| { + ev.prevent_default(); + add_contact.dispatch(()); + }> + <input + disabled=add_contact_pending + placeholder="JID" + type="text" + node_ref=jid_input + bind:value=jid + name="jid" + id="jid" + autofocus="true" + /> + <input + disabled=add_contact_pending + class="button" + type="submit" + value="Send Friend Request" + /> + </form> + </div> + {move || { + if !requests.read().is_empty() { + view! { + <div> + <h3>Incoming Subscription Requests</h3> + <For + each=move || requests.get() + key=|request| request.clone() + let(request) + > + { + let request2 = request.clone(); + let request3 = request.clone(); + let request4 = request.clone(); + let jid_string = move || request.to_string(); + view! { + <div class="jid-with-buttons"> + <div class="jid">{jid_string}</div> + <div class="buttons"> + <div + class="button" + on:click=move |_| { + reject_friend_request.dispatch(request3.clone()); + } + > + Reject + </div> + <div + class="button" + on:click=move |_| { + accept_subscription_request.dispatch(request4.clone()); + } + > + Sub-only + </div> + <div + class="button" + on:click=move |_| { + accept_friend_request.dispatch(request2.clone()); + } + > + Accept Buddy + </div> + </div> + </div> + } + } + </For> + </div> + } + .into_any() + } else { + view! {}.into_any() + } + }} + {move || { + if !outgoing().is_empty() { + view! { + <div> + <h3>Pending Outgoing Subscription Requests</h3> + <For + each=move || outgoing() + key=|(jid, _contact)| jid.clone() + let((jid, contact)) + > + { + let jid2 = jid.clone(); + let jid_string = move || jid.to_string(); + view! { + <div class="jid-with-button"> + <div class="jid">{jid_string}</div> + <div + class="button" + on:click=move |_| { + cancel_subscription_request.dispatch(jid2.clone()); + } + > + Cancel + </div> + </div> + } + } + </For> + </div> + } + .into_any() + } else { + view! {}.into_any() + } + }} </div> } } - diff --git a/src/components/roster_list/roster_list_item.rs b/src/components/roster_list/roster_list_item.rs index 9ebc26a..a6fd714 100644 --- a/src/components/roster_list/roster_list_item.rs +++ b/src/components/roster_list/roster_list_item.rs @@ -1,46 +1,93 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::ops::Deref; -use filamento::{chat::Chat, roster::{Contact, ContactStoreFields}, user::{User, UserStoreFields}}; +use filamento::{ + chat::Chat, + roster::{Contact, ContactStoreFields}, + user::{User, UserStoreFields}, +}; +use jid::BareJID; use leptos::prelude::*; use reactive_stores::{ArcStore, Store}; use tracing::debug; -use crate::{chat::{ArcMacawChat, MacawChat}, components::{avatar::AvatarWithPresence, sidebar::Open}, contact::MacawContact, open_chats::{OpenChatsPanel, OpenChatsPanelStoreFields}, user::get_name}; +use crate::{ + chat::{ArcMacawChat, MacawChat}, + client::Client, + components::{avatar::AvatarWithPresence, sidebar::Open}, + contact::MacawContact, + open_chats::{OpenChatsPanel, OpenChatsPanelStoreFields}, + state_store::StateStore, + user::{ArcMacawUser, fetch_avatar, get_name}, +}; #[component] pub fn RosterListItem(contact: MacawContact) -> impl IntoView { - let contact_contact: Store<Contact> = contact.contact; - let contact_user: Store<User> = - <ArcStore<filamento::user::User> as Clone>::clone(&contact.user.get()).into(); - let name = move || get_name(contact_user, false); + let name = move || get_name(contact.user.get().into(), false); let open_chats: Store<OpenChatsPanel> = use_context().expect("no open chats panel store in context"); - // TODO: why can this not be in the closure????? - // TODO: not good, as overwrites preexisting chat state with possibly incorrect one... - let chat = Chat { - correspondent: contact_user.jid().get(), - have_chatted: false, - }; - let chat = ArcMacawChat::got_chat_and_user(chat, contact_user.get()); + let client = use_context::<Client>().expect("client not in context"); - let open_chat = move |_| { - debug!("opening chat"); - open_chats.update(|open_chats| open_chats.open(Clone::clone(&chat))); - }; + let chat_state_store: StateStore<BareJID, ArcStore<Chat>> = + use_context().expect("no chat state store"); + let user_state_store: StateStore<BareJID, (ArcStore<User>, ArcRwSignal<String>)> = + use_context().expect("no user state store"); + + let open_chat = Action::new_local(move |_| { + let client = client.clone(); + async move { + let to = contact.user.get().jid().get(); + let (chat, user) = match client.get_chat_and_user(to).await { + Ok(c) => c, + Err(e) => { + // TODO: error + // set_error.set(Some(e.into())); + // set_new_chat_pending.set(false); + return; + } + }; + + let chat = { + // let user = MacawUser::got_user(user); + // let user = user_state_store.store(user.jid.clone(), ArcStore::new(user)); + let old_user = user_state_store.get_listener(user.jid.clone()); + let user = if let Some(old_user) = old_user { + old_user.update(|(old_user, _avatar)| { + old_user.set(user); + }); + old_user + } else { + let avatar = fetch_avatar(user.avatar.as_deref()).await; + let avatar = ArcRwSignal::new(avatar); + user_state_store.store(user.jid.clone(), (ArcStore::new(user), avatar)) + }; + let user = ArcMacawUser { user }; + let chat = chat_state_store.store(chat.correspondent.clone(), ArcStore::new(chat)); + ArcMacawChat { chat, user } + }; + open_chats.update(|open_chats| open_chats.open(chat.clone())); + } + }); + + let current_open_chat: Memo<Option<BareJID>> = + use_context().expect("no open chat memo in context"); let open = move || { - if let Some(open_chat) = &*open_chats.chat_view().read() { + if let Some(open_chat) = &*current_open_chat.read() { debug!("got open chat: {:?}", open_chat); - if *open_chat == *contact_user.jid().read() { + if *open_chat == *contact.user.get().jid().read() { return Open::Focused; } } if let Some(_backgrounded_chat) = open_chats .chats() .read() - .get(contact_user.jid().read().deref()) + .get(contact.user.get().jid().read().deref()) { return Open::Open; } @@ -50,13 +97,26 @@ pub fn RosterListItem(contact: MacawContact) -> impl IntoView { let open = move || open().is_open(); view! { - <div class="roster-list-item" class:open=move || open() class:focused=move || focused() on:click=open_chat> - <AvatarWithPresence user=contact_user /> + <div + class="roster-list-item" + class:open=move || open() + class:focused=move || focused() + on:click=move |_| { + open_chat.dispatch(()); + } + > + {move || { + view! { <AvatarWithPresence user=contact.user /> } + }} <div class="item-info"> - <div class="main-info"><p class="name">{name}<span class="jid"> - {move || contact_contact.user_jid().read().to_string()}</span></p></div> - <div class="sub-info">{move || contact_contact.subscription().read().to_string()}</div> + <div class="main-info"> + <p class="name"> + {name} + <span class="jid">- {move || contact.user_jid().read().to_string()}</span> + </p> + </div> + <div class="sub-info">{move || contact.subscription().read().to_string()}</div> </div> </div> } } - diff --git a/src/components/sidebar.rs b/src/components/sidebar.rs index ca753ef..9f555b5 100644 --- a/src/components/sidebar.rs +++ b/src/components/sidebar.rs @@ -1,20 +1,29 @@ -use std::collections::HashSet; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use std::collections::{HashMap, HashSet}; use jid::BareJID; use leptos::prelude::*; +use reactive_stores::Store; use crate::components::{ - personal_status::PersonalStatus, - chats_list::ChatsList, - roster_list::RosterList, + chats_list::ChatsList, personal_status::PersonalStatus, roster_list::RosterList, }; -#[derive(PartialEq, Eq, Clone, Copy)] +#[derive(PartialEq, Eq, Clone, Copy, Hash)] pub enum SidebarOpen { Roster, Chats, } +#[derive(Store)] +pub struct Drawer { + open: SidebarOpen, + hovering: bool, +} + pub enum Open { /// Currently on screen Focused, @@ -55,122 +64,170 @@ pub fn toggle_open(state: &mut Option<SidebarOpen>, open: SidebarOpen) -> bool { } } None => { - *state = Some(open); - true - }, + *state = Some(open); + true + } } } #[component] pub fn Sidebar() -> impl IntoView { - let requests: ReadSignal<HashSet<BareJID>> = use_context().expect("no pending subscriptions in context"); + let requests: ReadSignal<HashSet<BareJID>> = + use_context().expect("no pending subscriptions in context"); // for what has been clicked open (in the background) let (open, set_open) = signal(None::<SidebarOpen>); // for what is just in the hovered state (not clicked to be pinned open yet necessarily) + let open = Memo::new(move |_| open.get()); let (hovered, set_hovered) = signal(None::<SidebarOpen>); + let hovered = Memo::new(move |_| hovered.get()); let (just_closed, set_just_closed) = signal(false); + let just_closed = Memo::new(move |_| just_closed.get()); + + let pages = Memo::new(move |_| { + let mut pages = HashSet::new(); + if let Some(hovered) = *hovered.read() { + pages.insert(hovered); + } + if let Some(opened) = *open.read() { + pages.insert(opened); + } + pages + }); view! { - <div class="sidebar" on:mouseleave=move |_| { - set_hovered.set(None); - set_just_closed.set(false); - }> + <div + class="sidebar" + on:mouseleave=move |_| { + set_hovered.set(None); + set_just_closed.set(false); + } + > <div class="dock panel"> <div class="shortcuts"> - <div class="roster-tab dock-item" class:focused=move || *open.read() == Some(SidebarOpen::Roster) class:hovering=move || *hovered.read() == Some(SidebarOpen::Roster) - on:mouseenter=move |_| { - set_just_closed.set(false); - set_hovered.set(Some(SidebarOpen::Roster)) - } - on:click=move |_| { - set_open.update(|state| { - if !toggle_open(state, SidebarOpen::Roster) { - set_just_closed.set(true); - } - }) - }> + <div + class="roster-tab dock-item" + class:focused=move || *open.read() == Some(SidebarOpen::Roster) + class:hovering=move || *hovered.read() == Some(SidebarOpen::Roster) + on:mouseenter=move |_| { + set_just_closed.set(false); + set_hovered.set(Some(SidebarOpen::Roster)) + } + on:click=move |_| { + set_open + .update(|state| { + if !toggle_open(state, SidebarOpen::Roster) { + set_just_closed.set(true); + } else { + set_just_closed.set(false); + } + }) + } + > <div class="dock-pill"></div> <div class="dock-icon"> <div class="icon-with-badge"> - <img src="/assets/caw.png" /> - {move || { - let len = requests.read().len(); - if len > 0 { - view! { - <div class="badge">{len}</div> - }.into_any() - } else { - view! {}.into_any() - } - }} + <img src="/assets/caw.png" /> + {move || { + let len = requests.read().len(); + if len > 0 { + view! { <div class="badge">{len}</div> }.into_any() + } else { + view! {}.into_any() + } + }} </div> </div> </div> - <div class="chats-tab dock-item" class:focused=move || *open.read() == Some(SidebarOpen::Chats) class:hovering=move || *hovered.read() == Some(SidebarOpen::Chats) - on:mouseenter=move |_| { - set_just_closed.set(false); - set_hovered.set(Some(SidebarOpen::Chats)) - } - on:click=move |_| { - set_open.update(|state| { - if !toggle_open(state, SidebarOpen::Chats) { - set_just_closed.set(true); - } - }) - }> + <div + class="chats-tab dock-item" + class:focused=move || *open.read() == Some(SidebarOpen::Chats) + class:hovering=move || *hovered.read() == Some(SidebarOpen::Chats) + on:mouseenter=move |_| { + set_just_closed.set(false); + set_hovered.set(Some(SidebarOpen::Chats)) + } + on:click=move |_| { + set_open + .update(|state| { + if !toggle_open(state, SidebarOpen::Chats) { + set_just_closed.set(true); + } else { + set_just_closed.set(false); + } + }) + } + > <div class="dock-pill"></div> <img src="/assets/bubble.png" /> </div> </div> - <div class="pins"> - </div> + <div class="pins"></div> <div class="personal"> <PersonalStatus /> </div> </div> - {move || if let Some(hovered) = *hovered.read() { - if Some(hovered) != *open.read() { - if !just_closed.get() { - match hovered { - SidebarOpen::Roster => view! { - <div class="sidebar-drawer sidebar-hovering-drawer"> - <RosterList /> - </div> - }.into_any(), - SidebarOpen::Chats => view! { - <div class="sidebar-drawer sidebar-hovering-drawer"> - <ChatsList /> - </div> - }.into_any(), - } - } else { - - view! {}.into_any() + {move || { + if !just_closed.get() { + view! { + <For each=move || pages.get() key=|page| *page let(page)> + {move || match page { + SidebarOpen::Roster => { + view! { + {move || { + if *open.read() == None + && *hovered.read() == Some(SidebarOpen::Roster) + { + view! { <div class="sidebar-drawer behind-hovering"></div> } + .into_any() + } else { + view! {}.into_any() + } + }} + <div + class:sidebar-drawer=true + class:sidebar-hovering-drawer=move || { + !(*open.read() == Some(SidebarOpen::Roster)) + && (*hovered.read() == Some(SidebarOpen::Roster)) + } + > + <RosterList /> + </div> + } + .into_any() + } + SidebarOpen::Chats => { + view! { + {move || { + if *open.read() == None + && *hovered.read() == Some(SidebarOpen::Chats) + { + view! { <div class="sidebar-drawer behind-hovering"></div> } + .into_any() + } else { + view! {}.into_any() + } + }} + <div + class:sidebar-drawer=true + class:sidebar-hovering-drawer=move || { + !(*open.read() == Some(SidebarOpen::Chats)) + && (*hovered.read() == Some(SidebarOpen::Chats)) + } + > + <ChatsList /> + </div> + } + .into_any() + } + }} + </For> } + .into_any() } else { view! {}.into_any() } - } else { - view! {}.into_any() - }} - {move || if let Some(opened) = *open.read() { - match opened { - SidebarOpen::Roster => view! { - <div class="sidebar-drawer"> - <RosterList /> - </div> - }.into_any(), - SidebarOpen::Chats => view! { - <div class="sidebar-drawer"> - <ChatsList /> - </div> - }.into_any(), - } - } else { - view! {}.into_any() }} </div> } } - diff --git a/src/contact.rs b/src/contact.rs index 9adec16..b7f57fa 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::ops::{Deref, DerefMut}; use filamento::{roster::Contact, user::User}; @@ -41,9 +45,9 @@ pub struct ArcMacawContact { } impl ArcMacawContact { - pub fn got_contact_and_user(contact: Contact, user: User) -> Self { + pub async fn got_contact_and_user(contact: Contact, user: User) -> Self { let contact = Store::new(contact); - let user = ArcMacawUser::got_user(user); + let user = ArcMacawUser::got_user(user).await; Self { contact, user } } } @@ -61,4 +65,3 @@ impl DerefMut for ArcMacawContact { &mut self.contact } } - diff --git a/src/context.rs b/src/context.rs index e69de29..da660dc 100644 --- a/src/context.rs +++ b/src/context.rs @@ -0,0 +1,3 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/src/files.rs b/src/files.rs index b9e50df..760549f 100644 --- a/src/files.rs +++ b/src/files.rs @@ -1,5 +1,9 @@ -use base64::{prelude::BASE64_STANDARD, Engine}; -use filamento::files::{opfs::OPFSError, FileStore, FilesMem, FilesOPFS}; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use base64::{Engine, prelude::BASE64_STANDARD}; +use filamento::files::{FileStore, FilesMem, FilesOPFS, opfs::OPFSError}; #[derive(Clone, Debug)] pub enum Files { @@ -47,4 +51,3 @@ impl Files { } } } - diff --git a/src/icon.rs b/src/icon.rs index b0ef60e..231ad2e 100644 --- a/src/icon.rs +++ b/src/icon.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + #[derive(Copy, Clone)] pub enum Icon { AddContact24, @@ -108,4 +112,3 @@ impl Icon { } } } - @@ -1,17 +1,20 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + pub use views::App; -mod state_store; -mod icon; -mod user; mod chat; -mod open_chats; -mod components; -mod views; -mod files; mod client; -mod roster; +mod components; mod contact; +mod files; +mod icon; mod message; mod message_subscriptions; +mod open_chats; +mod roster; +mod state_store; +mod user; mod user_presences; - +mod views; diff --git a/src/main.rs b/src/main.rs index fd4a1de..3db4c25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use leptos::prelude::*; use macaw_web::App; diff --git a/src/message.rs b/src/message.rs index 878085e..20e37b9 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,11 +1,18 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::ops::{Deref, DerefMut}; use filamento::{chat::Message, user::User}; +use leptos::prelude::*; use reactive_stores::ArcStore; use uuid::Uuid; -use leptos::prelude::*; -use crate::{state_store::{StateListener, StateStore}, user::{ArcMacawUser, MacawUser}}; +use crate::{ + state_store::{StateListener, StateStore}, + user::{ArcMacawUser, MacawUser}, +}; #[derive(Clone, Copy)] pub struct MacawMessage { @@ -49,11 +56,11 @@ pub struct ArcMacawMessage { } impl ArcMacawMessage { - pub fn got_message_and_user(message: Message, user: User) -> Self { + pub async fn got_message_and_user(message: Message, user: User) -> Self { let message_state_store: StateStore<Uuid, ArcStore<Message>> = use_context().expect("no message state store"); let message = message_state_store.store(message.id, ArcStore::new(message)); - let user = ArcMacawUser::got_user(user); + let user = ArcMacawUser::got_user(user).await; Self { message, user } } } @@ -71,4 +78,3 @@ impl DerefMut for ArcMacawMessage { &mut self.message } } - diff --git a/src/message_subscriptions.rs b/src/message_subscriptions.rs index 17d924f..eebbef3 100644 --- a/src/message_subscriptions.rs +++ b/src/message_subscriptions.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::collections::HashMap; use jid::BareJID; @@ -83,4 +87,3 @@ impl MessageSubscriptions { } } } - diff --git a/src/open_chats.rs b/src/open_chats.rs index 6d08c5d..bf2eb73 100644 --- a/src/open_chats.rs +++ b/src/open_chats.rs @@ -1,9 +1,13 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use filamento::chat::ChatStoreFields; use indexmap::IndexMap; use jid::BareJID; +use leptos::prelude::*; use reactive_stores::{ArcStore, Store}; use tracing::debug; -use leptos::prelude::*; use crate::chat::{ArcMacawChat, MacawChat}; @@ -18,28 +22,19 @@ pub struct OpenChatsPanel { pub fn open_chat(open_chats: Store<OpenChatsPanel>, chat: ArcMacawChat) { if let Some(jid) = &*open_chats.chat_view().read() { if let Some((index, _jid, entry)) = open_chats.chats().write().shift_remove_full(jid) { - let new_jid = chat.get() - .correspondent() - .read() - .clone(); + let new_jid = chat.get().correspondent().read().clone(); open_chats .chats() .write() .insert_before(index, new_jid.clone(), chat); *open_chats.chat_view().write() = Some(new_jid); } else { - let new_jid = chat.get() - .correspondent() - .read() - .clone(); + let new_jid = chat.get().correspondent().read().clone(); open_chats.chats().write().insert(new_jid.clone(), chat); *open_chats.chat_view().write() = Some(new_jid); } } else { - let new_jid = chat.get() - .correspondent() - .read() - .clone(); + let new_jid = chat.get().correspondent().read().clone(); open_chats.chats().write().insert(new_jid.clone(), chat); *open_chats.chat_view().write() = Some(new_jid); } @@ -50,25 +45,16 @@ impl OpenChatsPanel { if let Some(jid) = &mut self.chat_view { debug!("a chat was already open"); if let Some((index, _jid, entry)) = self.chats.shift_remove_full(jid) { - let new_jid = chat.get() - .correspondent() - .read() - .clone(); + let new_jid = chat.get().correspondent().read().clone(); self.chats.insert_before(index, new_jid.clone(), chat); *&mut self.chat_view = Some(new_jid); } else { - let new_jid = chat.get() - .correspondent() - .read() - .clone(); + let new_jid = chat.get().correspondent().read().clone(); self.chats.insert(new_jid.clone(), chat); *&mut self.chat_view = Some(new_jid); } } else { - let new_jid = chat.get() - .correspondent() - .read() - .clone(); + let new_jid = chat.get().correspondent().read().clone(); self.chats.insert(new_jid.clone(), chat); *&mut self.chat_view = Some(new_jid); } @@ -84,5 +70,3 @@ impl OpenChatsPanel { // } } - - diff --git a/src/roster.rs b/src/roster.rs index 75f4c3b..13aed19 100644 --- a/src/roster.rs +++ b/src/roster.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::collections::HashMap; use jid::BareJID; @@ -18,4 +22,3 @@ impl Roster { } } } - diff --git a/src/state_store.rs b/src/state_store.rs index 8d80b3f..1e67f34 100644 --- a/src/state_store.rs +++ b/src/state_store.rs @@ -1,6 +1,15 @@ -use std::{collections::HashMap, ops::{Deref, DerefMut}, sync::{Arc, RwLock}}; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use std::{ + collections::HashMap, + ops::{Deref, DerefMut}, + sync::{Arc, RwLock}, +}; use leptos::prelude::*; +use tracing::debug; // TODO: get rid of this // V has to be an arc signal @@ -105,36 +114,57 @@ impl<K, V, S> Clone for StateStore<K, V, S> { } } -impl<K: Eq + std::hash::Hash + Clone, V: Clone> StateStore<K, V> +impl<K: Eq + std::hash::Hash + Clone + std::fmt::Debug, V: Clone + std::fmt::Debug> StateStore<K, V> where K: Send + Sync + 'static, V: Send + Sync + 'static, { pub fn store(&self, key: K, value: V) -> StateListener<K, V> { - { - let store = self.inner.try_get_value().unwrap(); - let mut store = store.store.write().unwrap(); - if let Some((v, count)) = store.get_mut(&key) { - v.set(value); - *count += 1; - StateListener { - value: v.clone(), - cleaner: StateCleaner { - key, - state_store: self.clone(), - }, - } - } else { - let v = ArcRwSignal::new(value); - store.insert(key.clone(), (v.clone(), 1)); - StateListener { - value: v.into(), - cleaner: StateCleaner { - key, - state_store: self.clone(), - }, - } + let arc_store = self.inner.try_get_value().unwrap(); + let store = arc_store.store.clone(); + let mut store = store.write().unwrap(); + debug!("store state: {:?}", store); + if let Some((v, count)) = store.get_mut(&key) { + debug!("updating old value already in store"); + v.set(value); + *count += 1; + StateListener { + value: v.clone(), + cleaner: StateCleaner { + key, + state_store: arc_store, + }, } + } else { + let v = ArcRwSignal::new(value); + store.insert(key.clone(), (v.clone(), 1)); + debug!("inserting new value: {:?}", store); + StateListener { + value: v.into(), + cleaner: StateCleaner { + key, + state_store: arc_store, + }, + } + } + } + + pub fn get_listener(&self, key: K) -> Option<StateListener<K, V>> { + let arc_store = self.inner.try_get_value().unwrap(); + let store = arc_store.store.clone(); + let mut store = store.write().unwrap(); + debug!("store state: {:?}", store); + if let Some((v, count)) = store.get_mut(&key) { + *count += 1; + Some(StateListener { + value: v.clone(), + cleaner: StateCleaner { + key, + state_store: arc_store, + }, + }) + } else { + None } } } @@ -159,18 +189,6 @@ where v.update(|v| modify(v)); } } - - fn remove(&self, key: &K) { - // let store = self.inner.try_get_value().unwrap(); - // let mut store = store.store.write().unwrap(); - // if let Some((_v, count)) = store.get_mut(key) { - // *count -= 1; - // if *count == 0 { - // store.remove(key); - // debug!("dropped item from store"); - // } - // } - } } #[derive(Clone)] @@ -214,7 +232,7 @@ where V: Send + Sync + 'static, { key: K, - state_store: StateStore<K, V>, + state_store: ArcStateStore<K, V>, } impl<K, V> Clone for StateCleaner<K, V> @@ -224,8 +242,7 @@ where { fn clone(&self) -> Self { { - let store = self.state_store.inner.try_get_value().unwrap(); - let mut store = store.store.write().unwrap(); + let mut store = self.state_store.store.write().unwrap(); if let Some((_v, count)) = store.get_mut(&self.key) { *count += 1; } @@ -241,6 +258,13 @@ impl<K: Eq + std::hash::Hash + Send + Sync + 'static, V: Send + Sync + 'static> for StateCleaner<K, V> { fn drop(&mut self) { - self.state_store.remove(&self.key); + let mut store = self.state_store.store.write().unwrap(); + if let Some((_v, count)) = store.get_mut(&self.key) { + *count -= 1; + if *count == 0 { + store.remove(&self.key); + debug!("dropped item from store"); + } + } } } diff --git a/src/user.rs b/src/user.rs index e62ebea..e277efd 100644 --- a/src/user.rs +++ b/src/user.rs @@ -1,22 +1,35 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::ops::{Deref, DerefMut}; use filamento::user::{User, UserStoreFields}; use jid::BareJID; -use reactive_stores::{ArcStore, Store}; use leptos::prelude::*; +use reactive_stores::{ArcStore, Store}; -use crate::{client::Client, roster::{Roster, RosterStoreFields}, state_store::{StateListener, StateStore}}; +use crate::{ + client::Client, + roster::{Roster, RosterStoreFields}, + state_store::{StateListener, StateStore}, +}; #[derive(Clone, Copy)] pub struct MacawUser { pub user: ArenaItem<ArcMacawUser>, // TODO: just store avatar src in user // pub avatar: String, + // pub avatar: RwSignal<String>, } impl MacawUser { pub fn get(&self) -> ArcStore<User> { - self.try_get_value().unwrap().get() + self.try_get_value().unwrap().get().0 + } + + pub fn avatar(&self) -> ArcRwSignal<String> { + self.try_get_value().unwrap().get().1 } } @@ -38,6 +51,7 @@ impl From<ArcMacawUser> for MacawUser { fn from(value: ArcMacawUser) -> Self { Self { user: ArenaItem::new_with_storage(value), + // avatar: value.avatar.into(), } } } @@ -50,21 +64,31 @@ impl From<MacawUser> for ArcMacawUser { #[derive(Clone)] pub struct ArcMacawUser { - pub user: StateListener<BareJID, ArcStore<User>>, + pub user: StateListener<BareJID, (ArcStore<User>, ArcRwSignal<String>)>, } impl ArcMacawUser { - pub fn got_user(user: User) -> Self { - - let user_state_store: StateStore<BareJID, ArcStore<User>> = + pub async fn got_user(user: User) -> Self { + let user_state_store: StateStore<BareJID, (ArcStore<User>, ArcRwSignal<String>)> = use_context().expect("no user state store"); - let user = user_state_store.store(user.jid.clone(), ArcStore::new(user)); - Self { user } + let old_user = user_state_store.get_listener(user.jid.clone()); + let user = if let Some(old_user) = old_user { + old_user.update(|(old_user, _avatar)| { + old_user.set(user); + }); + old_user + } else { + let avatar = fetch_avatar(user.avatar.as_deref()).await; + let avatar = ArcRwSignal::new(avatar); + user_state_store.store(user.jid.clone(), (ArcStore::new(user), avatar)) + }; + let user = ArcMacawUser { user }; + user } } impl Deref for ArcMacawUser { - type Target = StateListener<BareJID, ArcStore<User>>; + type Target = StateListener<BareJID, (ArcStore<User>, ArcRwSignal<String>)>; fn deref(&self) -> &Self::Target { &self.user @@ -79,6 +103,19 @@ impl DerefMut for ArcMacawUser { pub const NO_AVATAR: &str = "/assets/no-avatar.png"; +pub async fn fetch_avatar(id: Option<&str>) -> String { + if let Some(avatar) = id { + let client = use_context::<Client>().expect("client not in context"); + if let Some(data) = client.file_store.get_src(avatar).await { + data + } else { + NO_AVATAR.to_string() + } + } else { + NO_AVATAR.to_string() + } +} + pub async fn get_avatar(user: Store<User>) -> String { if let Some(avatar) = &user.read().avatar { let client = use_context::<Client>().expect("client not in context"); @@ -87,8 +124,6 @@ pub async fn get_avatar(user: Store<User>) -> String { } else { NO_AVATAR.to_string() } - // TODO: enable avatar fetching - // format!("/files/{}", avatar) } else { NO_AVATAR.to_string() } @@ -99,7 +134,7 @@ pub fn get_name(user: Store<User>, note_to_self: bool) -> String { if note_to_self { let client: Client = use_context().expect("no client in context"); if *client.jid == *user.jid().read() { - return "Note to self".to_string() + return "Note to self".to_string(); } } if let Some(name) = roster @@ -116,4 +151,3 @@ pub fn get_name(user: Store<User>, note_to_self: bool) -> String { user.read().jid.to_string() } } - diff --git a/src/user_presences.rs b/src/user_presences.rs index 1a719a2..87f9bdc 100644 --- a/src/user_presences.rs +++ b/src/user_presences.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::collections::HashMap; use chrono::Utc; @@ -43,7 +47,7 @@ impl UserPresences { pub struct Presences { /// presences are sorted by time, first by type, then by last activity. - presences: IndexMap<String, Presence> + presences: IndexMap<String, Presence>, } impl Presences { @@ -55,47 +59,89 @@ impl Presences { /// gets the highest priority presence pub fn presence(&self) -> Option<(String, Presence)> { - if let Some((resource, presence)) = self.presences.iter().filter(|(_resource, presence)| if let PresenceType::Online(online) = &presence.presence { - online.show == Some(Show::DoNotDisturb) - } else { - false - }).next() { - return Some((resource.clone(), presence.clone())) + if let Some((resource, presence)) = self + .presences + .iter() + .filter(|(_resource, presence)| { + if let PresenceType::Online(online) = &presence.presence { + online.show == Some(Show::DoNotDisturb) + } else { + false + } + }) + .next() + { + return Some((resource.clone(), presence.clone())); } - if let Some((resource, presence)) = self.presences.iter().filter(|(_resource, presence)| if let PresenceType::Online(online) = &presence.presence { - online.show == Some(Show::Chat) - } else { - false - }).next() { - return Some((resource.clone(), presence.clone())) + if let Some((resource, presence)) = self + .presences + .iter() + .filter(|(_resource, presence)| { + if let PresenceType::Online(online) = &presence.presence { + online.show == Some(Show::Chat) + } else { + false + } + }) + .next() + { + return Some((resource.clone(), presence.clone())); } - if let Some((resource, presence)) = self.presences.iter().filter(|(_resource, presence)| if let PresenceType::Online(online) = &presence.presence { - online.show == None - } else { - false - }).next() { - return Some((resource.clone(), presence.clone())) + if let Some((resource, presence)) = self + .presences + .iter() + .filter(|(_resource, presence)| { + if let PresenceType::Online(online) = &presence.presence { + online.show == None + } else { + false + } + }) + .next() + { + return Some((resource.clone(), presence.clone())); } - if let Some((resource, presence)) = self.presences.iter().filter(|(_resource, presence)| if let PresenceType::Online(online) = &presence.presence { - online.show == Some(Show::Away) - } else { - false - }).next() { - return Some((resource.clone(), presence.clone())) + if let Some((resource, presence)) = self + .presences + .iter() + .filter(|(_resource, presence)| { + if let PresenceType::Online(online) = &presence.presence { + online.show == Some(Show::Away) + } else { + false + } + }) + .next() + { + return Some((resource.clone(), presence.clone())); } - if let Some((resource, presence)) = self.presences.iter().filter(|(_resource, presence)| if let PresenceType::Online(online) = &presence.presence { - online.show == Some(Show::ExtendedAway) - } else { - false - }).next() { - return Some((resource.clone(), presence.clone())) + if let Some((resource, presence)) = self + .presences + .iter() + .filter(|(_resource, presence)| { + if let PresenceType::Online(online) = &presence.presence { + online.show == Some(Show::ExtendedAway) + } else { + false + } + }) + .next() + { + return Some((resource.clone(), presence.clone())); } - if let Some((resource, presence)) = self.presences.iter().filter(|(_resource, presence)| if let PresenceType::Offline(_offline) = &presence.presence { - true - } else { - false - }).next() { - return Some((resource.clone(), presence.clone())) + if let Some((resource, presence)) = self + .presences + .iter() + .filter(|(_resource, presence)| { + if let PresenceType::Offline(_offline) = &presence.presence { + true + } else { + false + } + }) + .next() + { + return Some((resource.clone(), presence.clone())); } else { None } @@ -103,19 +149,14 @@ impl Presences { pub fn update_presence(&mut self, resource: String, presence: Presence) { let index = match self.presences.binary_search_by(|_, existing_presence| { - presence.timestamp - .cmp( - &existing_presence.timestamp - ) + presence.timestamp.cmp(&existing_presence.timestamp) }) { Ok(i) => i, Err(i) => i, }; self.presences.insert_before( // TODO: check if this logic is correct - index, - resource, - presence, + index, resource, presence, ); } @@ -130,4 +171,3 @@ impl Presences { } } } - diff --git a/src/views/login_page.rs b/src/views/login_page.rs index 2edd4b5..d1bb29a 100644 --- a/src/views/login_page.rs +++ b/src/views/login_page.rs @@ -1,9 +1,15 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::{str::FromStr, sync::Arc}; -use filamento::{db::Db, error::{CommandError, ConnectionError}, files::{opfs::OPFSError, FilesMem, FilesOPFS}, UpdateMessage}; +use filamento::{ + db::Db, error::{CommandError, ConnectionError, DatabaseOpenError}, files::{opfs::OPFSError, FilesMem, FilesOPFS}, UpdateMessage +}; use jid::JID; -use thiserror::Error; use leptos::prelude::*; +use thiserror::Error; use tokio::sync::mpsc::Receiver; use tracing::debug; @@ -21,6 +27,8 @@ pub enum LoginError { InvalidJID(#[from] jid::ParseError), #[error("Connection Error: {0}")] ConnectionError(#[from] CommandError<ConnectionError>), + #[error("Failed to open database: {0}")] + DatabaseOpen(#[from] DatabaseOpenError), #[error("OPFS: {0}")] OPFS(#[from] OPFSError), } @@ -79,10 +87,17 @@ pub fn LoginPage( debug!("creating db in opfs"); Db::create_connect_and_migrate(jid.as_bare().to_string()) .await - .unwrap() } else { debug!("creating db in memory"); - Db::create_connect_and_migrate_memory().await.unwrap() + Db::create_connect_and_migrate_memory().await + }; + let db = match db { + Ok(db) => db, + Err(e) => { + set_error.set(Some(e.into())); + set_login_pending.set(false); + return; + } }; let files = if remember_me { let opfs = FilesOPFS::new(jid.as_bare().to_string()).await; @@ -113,9 +128,7 @@ pub fn LoginPage( if *connect_on_login.read_untracked() { match client.connect().await { - Ok(r) => { - resource.set(Some(r)) - } + Ok(r) => resource.set(Some(r)), Err(e) => { set_error.set(Some(e.into())); set_login_pending.set(false); diff --git a/src/views/macaw.rs b/src/views/macaw.rs index 1b7051f..e91e08a 100644 --- a/src/views/macaw.rs +++ b/src/views/macaw.rs @@ -1,6 +1,14 @@ -use std::collections::HashSet; +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later -use filamento::{chat::{Chat, Message, MessageStoreFields}, user::User, UpdateMessage}; +use std::collections::{HashMap, HashSet}; + +use filamento::{ + UpdateMessage, + chat::{Chat, Message, MessageStoreFields}, + user::User, +}; use jid::BareJID; use leptos::{prelude::*, task::spawn_local}; use open_chats_panel::OpenChatsPanelView; @@ -10,12 +18,23 @@ use tokio::sync::mpsc::Receiver; use tracing::debug; use uuid::Uuid; -use crate::{client::Client, components::sidebar::Sidebar, contact::{ArcMacawContact, MacawContact}, message::{ArcMacawMessage, MacawMessage}, message_subscriptions::MessageSubscriptions, open_chats::OpenChatsPanel, roster::{Roster, RosterStoreFields}, state_store::StateStore, user::{ArcMacawUser, MacawUser}, user_presences::{Presences, UserPresences}}; +use crate::{ + client::Client, + components::sidebar::Sidebar, + contact::{ArcMacawContact, MacawContact}, + message::{ArcMacawMessage, MacawMessage}, + message_subscriptions::MessageSubscriptions, + open_chats::OpenChatsPanel, + roster::{Roster, RosterStoreFields}, + state_store::StateStore, + user::{ArcMacawUser, MacawUser, fetch_avatar}, + user_presences::{Presences, UserPresences}, +}; use super::AppState; -pub mod settings; mod open_chats_panel; +pub mod settings; #[component] pub fn Macaw( @@ -25,6 +44,7 @@ pub fn Macaw( mut updates: Receiver<UpdateMessage>, set_app: WriteSignal<AppState>, ) -> impl IntoView { + let (updates, set_updates) = signal(Some(updates)); provide_context(set_app); provide_context(client); @@ -38,46 +58,45 @@ pub fn Macaw( provide_context(messages_store); let chats_store: StateStore<BareJID, ArcStore<Chat>> = StateStore::new(); provide_context(chats_store); - let users_store: StateStore<BareJID, ArcStore<User>> = StateStore::new(); + let users_store: StateStore<BareJID, (ArcStore<User>, ArcRwSignal<String>)> = StateStore::new(); provide_context(users_store); let open_chats = Store::new(OpenChatsPanel::default()); provide_context(open_chats); - let show_settings = RwSignal::new(None::<SettingsPage>); + let show_settings = RwSignal::new(None::<SettingsPage>); provide_context(show_settings); let user_presences = Store::new(UserPresences::new()); provide_context(user_presences); - let client_user: LocalResource<MacawUser> = LocalResource::new(move || { - async move { - let client = use_context::<Client>().expect("client not in context"); - let user = client.get_user((*client.jid).clone()).await.unwrap(); - ArcMacawUser::got_user(user).into() - } + let client_user: LocalResource<MacawUser> = LocalResource::new(move || async move { + let client = use_context::<Client>().expect("client not in context"); + let user = client.get_user((*client.jid).clone()).await.unwrap(); + ArcMacawUser::got_user(user).await.into() }); provide_context(client_user); // TODO: timestamp incoming/outgoing subscription requests - let (subscription_requests, set_subscription_requests)= signal(HashSet::<BareJID>::new()); + let (subscription_requests, set_subscription_requests) = signal(HashSet::<BareJID>::new()); provide_context(subscription_requests); provide_context(set_subscription_requests); // TODO: get cached contacts on login before getting the updated contacts - OnceResource::new(async move { + LocalResource::new(move || async move { + let mut updates = set_updates.write().take().expect("main loop ran twice"); while let Some(update) = updates.recv().await { match update { UpdateMessage::Online(online, items) => { - let contacts = items - .into_iter() - .map(|(contact, user)| { - ( - contact.user_jid.clone(), - ArcMacawContact::got_contact_and_user(contact, user).into(), - ) - }) - .collect(); + let mut contacts = HashMap::new(); + for (contact, user) in items { + contacts.insert( + contact.user_jid.clone(), + ArcMacawContact::got_contact_and_user(contact, user) + .await + .into(), + ); + } roster.contacts().set(contacts); } UpdateMessage::Offline(offline) => { @@ -85,13 +104,15 @@ pub fn Macaw( user_presences.write().clear(); } UpdateMessage::RosterUpdate(contact, user) => { + let new_contact = ArcMacawContact::got_contact_and_user(contact.clone(), user) + .await + .into(); roster.contacts().update(|roster| { if let Some(macaw_contact) = roster.get_mut(&contact.user_jid) { macaw_contact.set(contact); } else { let jid = contact.user_jid.clone(); - let contact = ArcMacawContact::got_contact_and_user(contact, user).into(); - roster.insert(jid, contact); + roster.insert(jid, new_contact); } }); } @@ -102,21 +123,30 @@ pub fn Macaw( } UpdateMessage::Presence { from, presence } => { let bare_jid = from.to_bare(); - if let Some(presences) = user_presences.read().user_presences.get(&bare_jid) { + if let Some(presences) = user_presences + .read_untracked() + .user_presences + .get(&bare_jid) + { if let Some(resource) = from.resourcepart() { - presences.write().update_presence(resource.clone(), presence); + presences + .write() + .update_presence(resource.clone(), presence); } } else { if let Some(resource) = from.resourcepart() { let mut presences = Presences::new(); presences.update_presence(resource.clone(), presence); - user_presences.write().user_presences.insert(bare_jid, ArcRwSignal::new(presences)); + user_presences + .write() + .user_presences + .insert(bare_jid, ArcRwSignal::new(presences)); } } } UpdateMessage::Message { to, from, message } => { debug!("before got message"); - let new_message = ArcMacawMessage::got_message_and_user(message, from); + let new_message = ArcMacawMessage::got_message_and_user(message, from).await; debug!("after got message"); spawn_local(async move { message_subscriptions @@ -134,15 +164,21 @@ pub fn Macaw( }); } UpdateMessage::SubscriptionRequest(jid) => { - set_subscription_requests.update(|req| { req.insert(jid); }); + set_subscription_requests.update(|req| { + req.insert(jid); + }); } UpdateMessage::NickChanged { jid, nick } => { - users_store.modify(&jid, |user| { + users_store.modify(&jid, |(user, _avatar)| { user.update(|user| *&mut user.nick = nick.clone()) }); } UpdateMessage::AvatarChanged { jid, id } => { - users_store.modify(&jid, |user| *&mut user.write().avatar = id.clone()); + let new_avatar = fetch_avatar(id.as_deref()).await; + users_store.modify(&jid, |(user, avatar)| { + *&mut user.write().avatar = id.clone(); + *&mut avatar.set(new_avatar.clone()) + }); } } } @@ -152,11 +188,12 @@ pub fn Macaw( <Sidebar /> // <ChatsList /> <OpenChatsPanelView /> - {move || if let Some(_) = *show_settings.read() { - view! { <Settings /> }.into_any() - } else { - view! {}.into_any() + {move || { + if let Some(_) = *show_settings.read() { + view! { <Settings /> }.into_any() + } else { + view! {}.into_any() + } }} } } - diff --git a/src/views/macaw/open_chats_panel.rs b/src/views/macaw/open_chats_panel.rs index ddc9ec9..375e8f3 100644 --- a/src/views/macaw/open_chats_panel.rs +++ b/src/views/macaw/open_chats_panel.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use leptos::prelude::*; use open_chat::OpenChatView; use reactive_stores::{ArcStore, Store}; @@ -53,19 +57,25 @@ mod open_chat { use leptos::prelude::*; use reactive_stores::{ArcStore, Store}; - use crate::{chat::MacawChat, components::{chat_header::ChatViewHeader, message_composer::ChatViewMessageComposer, message_history_buffer::MessageHistoryBuffer}}; + use crate::{ + chat::MacawChat, + components::{ + chat_header::ChatViewHeader, message_composer::ChatViewMessageComposer, + message_history_buffer::MessageHistoryBuffer, + }, + }; #[component] pub fn OpenChatView(chat: MacawChat) -> impl IntoView { - let chat_jid = move || chat.chat.try_get_value().unwrap().get().correspondent().get(); - view! { <div class="open-chat-view"> <ChatViewHeader chat=chat.clone() /> <MessageHistoryBuffer chat=chat.clone() /> - <ChatViewMessageComposer chat=chat_jid() /> + {move || { + let chat_jid = chat.get().correspondent().get(); + view! { <ChatViewMessageComposer chat=chat_jid /> } + }} </div> } } } - diff --git a/src/views/macaw/settings.rs b/src/views/macaw/settings.rs index 11a3fc3..7bdc2b9 100644 --- a/src/views/macaw/settings.rs +++ b/src/views/macaw/settings.rs @@ -1,26 +1,71 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use leptos::prelude::*; use profile_settings::ProfileSettings; -use crate::{components::{icon::IconComponent, modal::Modal}, icon::Icon}; +use crate::{ + components::{icon::IconComponent, modal::Modal}, + icon::Icon, +}; mod profile_settings { - use filamento::error::{AvatarPublishError, CommandError}; - use thiserror::Error; + use filamento::{ + error::{AvatarPublishError, CommandError, NickError}, + user::User, + }; use leptos::prelude::*; - use web_sys::{js_sys::Uint8Array, wasm_bindgen::{prelude::Closure, JsCast, UnwrapThrowExt}, Event, FileReader, HtmlInputElement, ProgressEvent}; + use thiserror::Error; + use web_sys::{ + Event, FileReader, HtmlInputElement, ProgressEvent, Url, + js_sys::Uint8Array, + wasm_bindgen::{JsCast, UnwrapThrowExt, prelude::Closure}, + }; - use crate::{client::Client, files::Files}; + use crate::{ + client::Client, + files::Files, + user::{NO_AVATAR, fetch_avatar}, + }; #[derive(Debug, Clone, Error)] pub enum ProfileSaveError { #[error("avatar publish: {0}")] Avatar(#[from] CommandError<AvatarPublishError<Files>>), + #[error("nick publish: {0}")] + Nick(#[from] CommandError<NickError>), } #[component] pub fn ProfileSettings() -> impl IntoView { let client: Client = use_context().expect("no client in context"); + let old_profile = LocalResource::new(move || { + let value = client.clone(); + async move { + // TODO: error + let jid = &*value.jid; + let old_profile = value.get_user(jid.clone()).await.unwrap(); + old_profile + } + }); + + view! { + {move || { + if let Some(old_profile) = old_profile.get() { + view! { <ProfileForm old_profile /> }.into_any() + } else { + view! {}.into_any() + } + }} + } + } + + #[component] + pub fn ProfileForm(old_profile: User) -> impl IntoView { + let client: Client = use_context().expect("no client in context"); + // TODO: compartmentalise into error component, form component... let (error, set_error) = signal(None::<ProfileSaveError>); let error_message = move || { @@ -32,17 +77,35 @@ mod profile_settings { } }) }; + + let (success_message, set_success_message) = signal(None::<String>); + let success_message = move || { + if let Some(message) = success_message.get() { + view! { <div class="success">{message}</div> }.into_any() + } else { + view! {}.into_any() + } + }; + let (profile_save_pending, set_profile_save_pending) = signal(false); let profile_upload_data = RwSignal::new(None::<Vec<u8>>); + let new_nick = RwSignal::new(old_profile.nick.clone().unwrap_or_default().to_string()); + let has_avatar = RwSignal::new(old_profile.avatar.is_some()); + let new_avatar_preview_url = RwSignal::new(None::<String>); + let remove_avatar = RwSignal::new(false); + let from_input = move |ev: Event| { let elem = ev.target().unwrap().unchecked_into::<HtmlInputElement>(); - + // let UploadSignal(file_signal) = expect_context(); // file_signal.update(Vec::clear); // Clear list from previous change let files = elem.files().unwrap_throw(); if let Some(file) = files.get(0) { + let url = Url::create_object_url_with_blob(&file).unwrap_throw(); + + new_avatar_preview_url.set(Some(url)); let reader = FileReader::new().unwrap_throw(); // let name = file.name(); @@ -56,7 +119,7 @@ mod profile_settings { // `.result` valid after the `read_*` completes on FileReader // https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result let result = reader.result().unwrap_throw(); - let data= Uint8Array::new(&result).to_vec(); + let data = Uint8Array::new(&result).to_vec(); // Do whatever you want with the Vec<u8> profile_upload_data.set(Some(data)); }) @@ -92,32 +155,141 @@ mod profile_settings { let save_profile = Action::new_local(move |_| { let client = client.clone(); - async move {} + let old_nick = old_profile.nick.clone(); + async move { + set_profile_save_pending.set(true); + + let new_nick = new_nick.get(); + let new_nick = if new_nick.is_empty() { + None + } else { + Some(new_nick) + }; + if new_nick != old_nick { + match client.change_nick(new_nick).await { + Ok(_) => {} + Err(e) => { + set_error.set(Some(ProfileSaveError::Nick(e))); + set_profile_save_pending.set(false); + return; + } + } + } + + if let Some(profile_data) = profile_upload_data.get() { + match client.change_avatar(Some(profile_data)).await { + Ok(_) => {} + Err(e) => { + set_error.set(Some(ProfileSaveError::Avatar(e))); + set_profile_save_pending.set(false); + return; + } + } + } else if remove_avatar.get() { + match client.change_avatar(None).await { + Ok(_) => {} + Err(e) => { + set_error.set(Some(ProfileSaveError::Avatar(e))); + set_profile_save_pending.set(false); + return; + } + } + } + + set_profile_save_pending.set(false); + set_error.set(None); + set_success_message.set(Some("Profile Updated!".to_string())); + } }); - let new_nick= RwSignal::new("".to_string()); + let _old_account_avatar = LocalResource::new(move || { + let avatar = old_profile.avatar.clone(); + async move { + let url = fetch_avatar(avatar.as_deref()).await; + new_avatar_preview_url.set(Some(url)); + } + }); view! { <div class="profile-settings"> - <form on:submit=move |ev| { + <div class="profile-preview"> + <h2>Profile Preview</h2> + <div class="preview"> + <img class="avatar" src=new_avatar_preview_url /> + <div class="nick"> + {move || { + let nick = new_nick.get(); + if nick.is_empty() { old_profile.jid.to_string() } else { nick } + }} + </div> + </div> + </div> + <form + class="profile-form" + on:submit=move |ev| { ev.prevent_default(); save_profile.dispatch(()); - }> + } + > + {success_message} {error_message} - <div class="change-avatar"> - <input type="file" id="client-user-avatar" on:change=from_input /> + <div> + <h3>Nick</h3> + <input + disabled=profile_save_pending + placeholder="Nick" + type="text" + id="client-user-nick" + bind:value=new_nick + name="client-user-nick" + /> + </div> + <div> + <h3>Avatar</h3> + <div class="change-avatar"> + <label for="client-user-avatar"> + <div class="button">Change Avatar</div> + </label> + <input + type="file" + id="client-user-avatar" + on:change=move |e| { + has_avatar.set(true); + remove_avatar.set(false); + from_input(e); + } + /> + {move || { + if has_avatar.get() { + view! { + <a + on:click=move |_| { + profile_upload_data.set(None); + remove_avatar.set(true); + has_avatar.set(false); + new_avatar_preview_url.set(Some(NO_AVATAR.to_string())); + } + style="cursor: pointer" + > + Remove Avatar + </a> + } + .into_any() + } else { + view! {}.into_any() + } + }} + </div> </div> - <input disabled=profile_save_pending placeholder="Nickname" type="text" id="client-user-nick" bind:value=new_nick name="client-user-nick" /> - <input disabled=profile_save_pending class="button" type="submit" value="Save Changes" /> + <hr /> + <input + disabled=profile_save_pending + class="button" + type="submit" + value="Save Changes" + /> </form> </div> - <div class="profile-preview"> - <h2>Profile Preview</h2> - <div class="preview"> - <img /> - <div>nick</div> - </div> - </div> } } } @@ -135,31 +307,81 @@ pub fn Settings() -> impl IntoView { let show_settings: RwSignal<Option<SettingsPage>> = use_context().unwrap(); view! { - <Modal on_background_click=move |_| { show_settings.set(None); }> + <Modal on_background_click=move |_| { + show_settings.set(None); + }> <div class="settings panel"> <div class="header"> <h2>Settings</h2> <div class="header-icon close"> - <IconComponent icon=Icon::Close24 on:click=move |_| show_settings.set(None)/> + <IconComponent + icon=Icon::Close24 + on:click=move |_| show_settings.set(None) + /> </div> </div> <div class="settings-main"> <div class="settings-sidebar"> - <div class:open=move || *show_settings.read() == Some(SettingsPage::Account) on:click=move |_| show_settings.set(Some(SettingsPage::Account))>Account</div> - <div class:open=move || *show_settings.read() == Some(SettingsPage::Chat) on:click=move |_| show_settings.set(Some(SettingsPage::Chat))>Chat</div> - <div class:open=move || *show_settings.read() == Some(SettingsPage::Privacy) on:click=move |_| show_settings.set(Some(SettingsPage::Privacy))>Privacy</div> - <div class:open=move || *show_settings.read() == Some(SettingsPage::Profile) on:click=move |_| show_settings.set(Some(SettingsPage::Profile))>Profile</div> + <div + class:open=move || *show_settings.read() == Some(SettingsPage::Account) + on:click=move |_| show_settings.set(Some(SettingsPage::Account)) + > + Account + </div> + <div + class:open=move || *show_settings.read() == Some(SettingsPage::Chat) + on:click=move |_| show_settings.set(Some(SettingsPage::Chat)) + > + Chat + </div> + <div + class:open=move || *show_settings.read() == Some(SettingsPage::Privacy) + on:click=move |_| show_settings.set(Some(SettingsPage::Privacy)) + > + Privacy + </div> + <div + class:open=move || *show_settings.read() == Some(SettingsPage::Profile) + on:click=move |_| show_settings.set(Some(SettingsPage::Profile)) + > + Profile + </div> </div> <div class="settings-page"> - {move || if let Some(page) = show_settings.get() { - match page { - SettingsPage::Account => view! { <div>"account"</div> }.into_any(), - SettingsPage::Chat => view! { <div>"chat"</div> }.into_any(), - SettingsPage::Profile => view! { <ProfileSettings /> }.into_any(), - SettingsPage::Privacy => view! { <div>"privacy"</div> }.into_any(), + {move || { + if let Some(page) = show_settings.get() { + match page { + SettingsPage::Account => { + view! { + <div style="padding: 16px"> + "Account settings coming soon!" + </div> + } + .into_any() + } + SettingsPage::Chat => { + view! { + <div style="padding: 16px"> + "Chat settings coming soon!" + </div> + } + .into_any() + } + SettingsPage::Profile => { + view! { <ProfileSettings /> }.into_any() + } + SettingsPage::Privacy => { + view! { + <div style="padding: 16px"> + "Privacy settings coming soon!" + </div> + } + .into_any() + } + } + } else { + view! {}.into_any() } - } else { - view! {}.into_any() }} </div> </div> @@ -167,4 +389,3 @@ pub fn Settings() -> impl IntoView { </Modal> } } - diff --git a/src/views/mod.rs b/src/views/mod.rs index 112f930..69ba606 100644 --- a/src/views/mod.rs +++ b/src/views/mod.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use filamento::UpdateMessage; use leptos::prelude::*; use login_page::LoginPage; @@ -33,4 +37,3 @@ pub fn App() -> impl IntoView { }} } } - |
