diff --git a/Cargo.lock b/Cargo.lock index 0ee08bf..c0a8474 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -525,6 +525,7 @@ dependencies = [ name = "bsnext_example" version = "0.2.2" dependencies = [ + "bsnext_html", "bsnext_input", "bsnext_md", "clap", @@ -548,6 +549,18 @@ dependencies = [ "tracing", ] +[[package]] +name = "bsnext_html" +version = "0.1.0" +dependencies = [ + "anyhow", + "bsnext_input", + "indent", + "insta", + "scraper", + "unindent", +] + [[package]] name = "bsnext_input" version = "0.2.2" @@ -632,6 +645,7 @@ dependencies = [ "bsnext_dto", "bsnext_example", "bsnext_fs", + "bsnext_html", "bsnext_input", "bsnext_md", "bsnext_output", @@ -932,6 +946,29 @@ dependencies = [ "typenum", ] +[[package]] +name = "cssparser" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c66d1cd8ed61bf80b38432613a7a2f09401ab8d0501110655f8b341484a3e3" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "phf", + "smallvec", +] + +[[package]] +name = "cssparser-macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "ctor" version = "0.2.8" @@ -957,6 +994,17 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.10.7" @@ -967,6 +1015,27 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dtoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" + +[[package]] +name = "dtoa-short" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +dependencies = [ + "dtoa", +] + +[[package]] +name = "ego-tree" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c6ba7d4eec39eaa9ab24d44a0e73a7949a1095a8b3f3abb11eddf27dbb56a53" + [[package]] name = "either" version = "1.12.0" @@ -1072,6 +1141,16 @@ dependencies = [ "libc", ] +[[package]] +name = "futf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" +dependencies = [ + "mac", + "new_debug_unreachable", +] + [[package]] name = "futures" version = "0.3.30" @@ -1161,6 +1240,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1171,6 +1259,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -1259,6 +1356,20 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "html5ever" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e15626aaf9c351bc696217cbe29cb9b5e86c43f8a46b5e2f5c6c5cf7cb904ce" +dependencies = [ + "log", + "mac", + "markup5ever", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "http" version = "1.1.0" @@ -1580,6 +1691,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "mac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" + [[package]] name = "markdown" version = "1.0.0-alpha.17" @@ -1589,6 +1706,20 @@ dependencies = [ "unicode-id", ] +[[package]] +name = "markup5ever" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82c88c6129bd24319e62a0359cb6b958fa7e8be6e19bb1663bc396b90883aca5" +dependencies = [ + "log", + "phf", + "phf_codegen", + "string_cache", + "string_cache_codegen", + "tendril", +] + [[package]] name = "matchers" version = "0.1.0" @@ -1761,6 +1892,12 @@ dependencies = [ "tempfile", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + [[package]] name = "nom" version = "7.1.3" @@ -1959,6 +2096,77 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +dependencies = [ + "phf_generator 0.11.2", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator 0.11.2", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.5" @@ -2022,6 +2230,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + [[package]] name = "proc-macro2" version = "1.0.81" @@ -2284,6 +2498,22 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scraper" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0e749d29b2064585327af5038a5a8eb73aeebad4a3472e83531a436563f7208" +dependencies = [ + "ahash", + "cssparser", + "ego-tree", + "getopts", + "html5ever", + "precomputed-hash", + "selectors", + "tendril", +] + [[package]] name = "sct" version = "0.7.1" @@ -2317,6 +2547,25 @@ dependencies = [ "libc", ] +[[package]] +name = "selectors" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd568a4c9bb598e291a08244a5c1f5a8a6650bee243b5b0f8dbb3d9cc1d87fe8" +dependencies = [ + "bitflags 2.5.0", + "cssparser", + "derive_more", + "fxhash", + "log", + "new_debug_unreachable", + "phf", + "phf_codegen", + "precomputed-hash", + "servo_arc", + "smallvec", +] + [[package]] name = "semver" version = "1.0.22" @@ -2398,6 +2647,15 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "servo_arc" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae65c4249478a2647db249fb43e23cec56a2c8974a427e7bd8cb5a1d0964921a" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "sha1" version = "0.10.6" @@ -2454,6 +2712,12 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -2501,12 +2765,44 @@ dependencies = [ "syn", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared 0.10.0", + "precomputed-hash", + "serde", +] + +[[package]] +name = "string_cache_codegen" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", + "proc-macro2", + "quote", +] + [[package]] name = "strip-ansi-escapes" version = "0.2.0" @@ -2622,6 +2918,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "tendril" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0" +dependencies = [ + "futf", + "mac", + "utf-8", +] + [[package]] name = "terminal_size" version = "0.3.0" @@ -3141,6 +3448,12 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "unsafe-libyaml" version = "0.2.11" diff --git a/bslive.html b/bslive.html new file mode 100644 index 0000000..6222540 --- /dev/null +++ b/bslive.html @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/crates/bsnext_dto/src/lib.rs b/crates/bsnext_dto/src/lib.rs index 2227ca0..08b08ca 100644 --- a/crates/bsnext_dto/src/lib.rs +++ b/crates/bsnext_dto/src/lib.rs @@ -287,6 +287,7 @@ pub enum InputErrorDTO { DirError(String), YamlError(String), MarkdownError(String), + HtmlError(String), Io(String), UnsupportedExtension(String), MissingExtension(String), @@ -305,6 +306,7 @@ impl From<&InputError> for InputErrorDTO { e @ InputError::PortError(_) => InputErrorDTO::PortError(e.to_string()), e @ InputError::DirError(_) => InputErrorDTO::DirError(e.to_string()), e @ InputError::MarkdownError(_) => InputErrorDTO::MarkdownError(e.to_string()), + e @ InputError::HtmlError(_) => InputErrorDTO::HtmlError(e.to_string()), e @ InputError::YamlError(_) => InputErrorDTO::YamlError(e.to_string()), e @ InputError::Io(_) => InputErrorDTO::Io(e.to_string()), e @ InputError::UnsupportedExtension(_) => { diff --git a/crates/bsnext_example/Cargo.toml b/crates/bsnext_example/Cargo.toml index caf28d6..b6922b7 100644 --- a/crates/bsnext_example/Cargo.toml +++ b/crates/bsnext_example/Cargo.toml @@ -8,4 +8,5 @@ edition = "2021" [dependencies] bsnext_input = { path = "../bsnext_input" } bsnext_md = { path = "../bsnext_md" } +bsnext_html = { path = "../bsnext_html" } clap = { workspace = true } diff --git a/crates/bsnext_example/src/md.rs b/crates/bsnext_example/src/md.rs index 2c77b9a..ace7250 100644 --- a/crates/bsnext_example/src/md.rs +++ b/crates/bsnext_example/src/md.rs @@ -1,6 +1,6 @@ use bsnext_input::server_config::ServerIdentity; -use bsnext_input::{InputSource, InputSourceKind}; -use bsnext_md::md_to_input; +use bsnext_input::{InputCreation, InputSource, InputSourceKind}; +use bsnext_md::md_fs::MdFs; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct MdExample; @@ -8,7 +8,8 @@ pub struct MdExample; impl InputSource for MdExample { fn into_input(self, identity: Option) -> InputSourceKind { let input_str = include_str!("../../../examples/markdown/single.md"); - let mut input = md_to_input(input_str).expect("example cannot fail?"); + let mut input = + MdFs::from_input_str(input_str, &Default::default()).expect("example cannot fail?"); let server = input .servers .first_mut() diff --git a/crates/bsnext_example/src/playground.rs b/crates/bsnext_example/src/playground.rs index f267313..ad92e50 100644 --- a/crates/bsnext_example/src/playground.rs +++ b/crates/bsnext_example/src/playground.rs @@ -1,14 +1,14 @@ +use bsnext_html::HtmlFs; use bsnext_input::server_config::ServerIdentity; -use bsnext_input::{InputCreation, InputSource, InputSourceKind}; -use bsnext_md::md_fs::MdFs; +use bsnext_input::{InputCreation, InputCtx, InputSource, InputSourceKind}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct PlaygroundExample; impl InputSource for PlaygroundExample { fn into_input(self, identity: Option) -> InputSourceKind { - let input_str = include_str!("../../../examples/markdown/playground.md"); - let mut input = MdFs::from_input_str(input_str).unwrap(); + let input_str = include_str!("../../../examples/html/playground.html"); + let mut input = HtmlFs::from_input_str(input_str, &InputCtx::default()).unwrap(); // update the server identity if it was provided if let (Some(server), Some(identity)) = (input.servers.get_mut(0), identity) { diff --git a/crates/bsnext_html/Cargo.toml b/crates/bsnext_html/Cargo.toml new file mode 100644 index 0000000..bb874e8 --- /dev/null +++ b/crates/bsnext_html/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "bsnext_html" +version = "0.1.0" +edition = "2021" + +[dependencies] +bsnext_input = { path = "../bsnext_input" } +unindent = "0.2.3" +indent = "0.1.1" +scraper = "0.21.0" + +[dev-dependencies] +anyhow = { workspace = true } +insta = { workspace = true } diff --git a/crates/bsnext_html/src/html_writer.rs b/crates/bsnext_html/src/html_writer.rs new file mode 100644 index 0000000..62623d6 --- /dev/null +++ b/crates/bsnext_html/src/html_writer.rs @@ -0,0 +1,54 @@ +use bsnext_input::playground::Playground; +use bsnext_input::server_config::ServerConfig; +use bsnext_input::{Input, InputWriter}; + +pub struct HtmlWriter; + +impl InputWriter for HtmlWriter { + fn input_to_str(&self, input: &Input) -> String { + if input.servers.is_empty() { + todo!("html requires at least 1 server definition") + } + if input.servers.len() > 1 { + todo!("more than 1 server not supported yet") + } + let server = input.servers.first().expect("must access first"); + let Some(playground) = &server.playground else { + todo!("only playground is supported in HTML for now") + }; + let mut blocks: Vec = vec![]; + if let Some(css) = &playground.css { + blocks.push("".into()); + } + blocks.push(playground.html.clone()); + if let Some(js) = &playground.js { + blocks.push("".into()); + } + blocks.join("\n") + } +} + +#[test] +fn test_html_writer_for_playground() { + let css = r#"body { + background: red; +}"#; + let js = r#"console.log("hello world!")"#; + let playground = Playground { + html: "

Hello world

".to_string(), + js: Some(js.to_string()), + css: Some(css.to_string()), + }; + let mut input = Input::default(); + let mut server = ServerConfig::default(); + server.playground = Some(playground); + input.servers.push(server); + let output = HtmlWriter.input_to_str(&input); + insta::assert_snapshot!(output); +} diff --git a/crates/bsnext_html/src/lib.rs b/crates/bsnext_html/src/lib.rs new file mode 100644 index 0000000..66708c6 --- /dev/null +++ b/crates/bsnext_html/src/lib.rs @@ -0,0 +1,96 @@ +use bsnext_input::playground::Playground; +use bsnext_input::server_config::{ServerConfig, ServerIdentity}; +use bsnext_input::{Input, InputCreation, InputCtx, InputError}; +use std::fs::read_to_string; +use std::path::Path; + +pub mod html_writer; + +pub struct HtmlFs; + +impl InputCreation for HtmlFs { + fn from_input_path>(path: P, ctx: &InputCtx) -> Result> { + let str = read_to_string(path).map_err(|e| Box::new(e.into()))?; + let input = playground_html_str_to_input(&str, ctx) + .map_err(|e| Box::new(InputError::HtmlError(e.to_string())))?; + Ok(input) + } + + fn from_input_str>(content: P, ctx: &InputCtx) -> Result> { + let input = playground_html_str_to_input(&content.as_ref(), ctx) + .map_err(|e| Box::new(InputError::HtmlError(e.to_string())))?; + Ok(input) + } +} + +fn playground_html_str_to_input(html: &str, ctx: &InputCtx) -> Result> { + use unindent::unindent; + + // parse the HTML + let mut document = scraper::Html::parse_fragment(html); + + let style = scraper::Selector::parse("style:first-of-type").unwrap(); + let script = scraper::Selector::parse("script:first-of-type").unwrap(); + + let mut style_elems = document.select(&style); + let mut script_elems = document.select(&script); + let mut node_ids_to_remove = vec![]; + + // start an empty playground + let mut playground = Playground { + html: "".to_string(), + css: None, + js: None, + }; + + if let Some(style) = style_elems.next() { + node_ids_to_remove.push(style.id()); + let t = style.text().nth(0).unwrap(); + let unindented = unindent(t); + playground.css = Some(unindented); + } + + if let Some(script) = script_elems.next() { + node_ids_to_remove.push(script.id()); + let t = script.text().nth(0).unwrap(); + let unindented = unindent(t); + playground.js = Some(unindented); + } + + for node_id in node_ids_to_remove { + document.tree.get_mut(node_id).unwrap().detach(); + } + + // grab the HTML + let as_html = document.html(); + let trimmed = as_html + .strip_prefix("") + .unwrap() + .strip_suffix("") + .unwrap(); + let un_indented = unindent(trimmed); + playground.html = un_indented; + + // Now start to build up the input + let mut input = Input::default(); + + // 1: first try prev + // 2: next try if 'port' was provided + // 3: finally, make one up + let iden = ctx + .first_id() + .or_else(|| ServerIdentity::from_port_or_named(ctx.port()).ok()) + .unwrap_or_default(); + + // Create the server + let server = ServerConfig { + identity: iden, + playground: Some(playground), + ..Default::default() + }; + + // Add it to the input + input.servers.push(server); + + Ok(input) +} diff --git a/crates/bsnext_html/src/snapshots/bsnext_html__html_writer__html_writer_for_playground.snap b/crates/bsnext_html/src/snapshots/bsnext_html__html_writer__html_writer_for_playground.snap new file mode 100644 index 0000000..01cb230 --- /dev/null +++ b/crates/bsnext_html/src/snapshots/bsnext_html__html_writer__html_writer_for_playground.snap @@ -0,0 +1,13 @@ +--- +source: crates/bsnext_html/src/html_writer.rs +expression: output +--- + +

Hello world

+ diff --git a/crates/bsnext_html/tests/html_playground.rs b/crates/bsnext_html/tests/html_playground.rs new file mode 100644 index 0000000..07e5dc2 --- /dev/null +++ b/crates/bsnext_html/tests/html_playground.rs @@ -0,0 +1,82 @@ +use bsnext_html::HtmlFs; +use bsnext_input::server_config::ServerIdentity; +use bsnext_input::{InputArgs, InputCreation, InputCtx}; +use insta::assert_debug_snapshot; + +const INPUT: &str = r#" + +
+

Test!

+ +
+"#; + +#[test] +fn test_html_playground_content() -> anyhow::Result<()> { + let idens = vec![]; + let ctx = InputCtx::new(&idens, None); + let as_input = HtmlFs::from_input_str(INPUT, &ctx)?; + let Some(server) = as_input.servers.get(0) else { + return Err(anyhow::anyhow!("no server")); + }; + let routes = server.routes(); + let html = routes.get(0).unwrap(); + let js = routes.get(1).unwrap(); + let css = routes.get(2).unwrap(); + assert_debug_snapshot!(html.kind); + assert_debug_snapshot!(js.kind); + assert_debug_snapshot!(css.kind); + Ok(()) +} +#[test] +fn test_html_playground_without_server_id() -> anyhow::Result<()> { + let idens = vec![]; + let ctx = InputCtx::new(&idens, None); + let as_input = HtmlFs::from_input_str(INPUT, &ctx)?; + assert_eq!(as_input.servers.len(), 1); + let first = as_input.servers.get(0).unwrap(); + let is_named = matches!(first.identity, ServerIdentity::Named { .. }); + assert_eq!(is_named, true); + Ok(()) +} +#[test] +fn test_html_playground_with_server_id() -> anyhow::Result<()> { + let ident = ServerIdentity::Address { + bind_address: String::from("127.0.0.1:8080"), + }; + let ctx = InputCtx::new(&[ident.clone()], None); + let as_input = HtmlFs::from_input_str(INPUT, &ctx)?; + + assert_eq!(as_input.servers.len(), 1); + let first = as_input.servers.get(0).unwrap(); + assert_eq!(ident, first.identity); + Ok(()) +} +#[test] +fn test_html_playground_with_port() -> anyhow::Result<()> { + let ident = ServerIdentity::Address { + bind_address: String::from("0.0.0.0:8080"), + }; + let input_args = InputArgs { port: Some(8080) }; + let ctx = InputCtx::new(&[], Some(input_args)); + let as_input = HtmlFs::from_input_str(INPUT, &ctx)?; + let first = as_input.servers.get(0).unwrap(); + assert_eq!(first.identity, ident); + Ok(()) +} diff --git a/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content-2.snap b/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content-2.snap new file mode 100644 index 0000000..19bbacc --- /dev/null +++ b/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content-2.snap @@ -0,0 +1,9 @@ +--- +source: crates/bsnext_html/tests/html_playground.rs +expression: js.kind +--- +Raw( + Raw { + raw: "class BSlive extends HTMLElement {\n connectedCallback() {\n this.innerHTML = \"Hello world\";\n }\n}\n\ncustomElements.define(\"abc-shane\", BSlive);\n", + }, +) diff --git a/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content-3.snap b/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content-3.snap new file mode 100644 index 0000000..81a1760 --- /dev/null +++ b/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content-3.snap @@ -0,0 +1,9 @@ +--- +source: crates/bsnext_html/tests/html_playground.rs +expression: css.kind +--- +Raw( + Raw { + raw: "p {\n color: red;\n}\n\nabc-shane {\n color: red;\n}\n", + }, +) diff --git a/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content.snap b/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content.snap new file mode 100644 index 0000000..e5ac0af --- /dev/null +++ b/crates/bsnext_html/tests/snapshots/html_playground__html_playground_content.snap @@ -0,0 +1,9 @@ +--- +source: crates/bsnext_html/tests/html_playground.rs +expression: html.kind +--- +Raw( + Html { + html: "\n
\n

Test!

\n \n
\n", + }, +) diff --git a/crates/bsnext_input/src/lib.rs b/crates/bsnext_input/src/lib.rs index e5f43c7..ebc3efd 100644 --- a/crates/bsnext_input/src/lib.rs +++ b/crates/bsnext_input/src/lib.rs @@ -10,7 +10,6 @@ pub mod client_config; #[cfg(test)] pub mod input_test; pub mod path_def; -pub mod paths; pub mod playground; pub mod route; pub mod route_manifest; @@ -90,9 +89,57 @@ pub trait InputSource { } } +#[derive(Debug, Default, Clone)] +pub struct InputArgs { + pub port: Option, +} + +#[derive(Debug, Default, Clone)] +pub struct InputCtx { + prev_server_ids: Option>, + args: Option, +} + +impl InputCtx { + pub fn new(servers: &[ServerIdentity], args: Option) -> Self { + let prev = if servers.is_empty() { + None + } else { + Some(servers.to_vec()) + }; + Self { + prev_server_ids: prev, + args: args.to_owned(), + } + } + + pub fn server_ids(&self) -> Option<&[ServerIdentity]> { + self.prev_server_ids.as_deref() + } + + pub fn first_id_or_named(&self) -> ServerIdentity { + self.prev_server_ids + .as_ref() + .and_then(|x| x.get(0)) + .map(ToOwned::to_owned) + .unwrap_or_else(|| ServerIdentity::named()) + } + + pub fn first_id(&self) -> Option { + self.prev_server_ids + .as_ref() + .and_then(|x| x.get(0)) + .map(ToOwned::to_owned) + } + + pub fn port(&self) -> Option { + self.args.as_ref().and_then(|x| x.port) + } +} + pub trait InputCreation { - fn from_input_path>(path: P) -> Result>; - fn from_input_str>(content: P) -> Result>; + fn from_input_path>(path: P, ctx: &InputCtx) -> Result>; + fn from_input_str>(content: P, ctx: &InputCtx) -> Result>; } pub trait InputWriter { @@ -125,6 +172,8 @@ pub enum InputError { DirError(#[from] DirError), #[error("Markdown error: {0}")] MarkdownError(String), + #[error("HTML error: {0}")] + HtmlError(String), #[error("{0}")] YamlError(#[from] YamlError), #[error(transparent)] diff --git a/crates/bsnext_input/src/paths.rs b/crates/bsnext_input/src/paths.rs deleted file mode 100644 index 1b345ae..0000000 --- a/crates/bsnext_input/src/paths.rs +++ /dev/null @@ -1,67 +0,0 @@ -use crate::route::{DirRoute, Route, RouteKind}; -use crate::server_config::{ServerConfig, ServerIdentity}; -use crate::{Input, PathDefinition, PathDefs, PathError}; -use std::path::{Path, PathBuf}; - -pub fn from_paths>( - cwd: &Path, - paths: &[T], - identity: ServerIdentity, -) -> Result { - let path_defs = paths - .iter() - .map(|p| { - let pb = PathBuf::from(p.as_ref()); - if pb.is_absolute() { - return PathDefinition { - input: p.as_ref().to_string(), - cwd: cwd.to_path_buf(), - absolute: pb, - }; - } else { - return PathDefinition { - input: p.as_ref().to_string(), - cwd: cwd.to_path_buf(), - absolute: cwd.join(pb), - }; - } - }) - .map(|path_def| { - let exists = path_def.absolute.exists(); - (path_def, exists) - }) - .collect::>(); - - let invalid = path_defs - .into_iter() - .filter_map(|(pb, exists)| if exists { None } else { Some(pb) }) - .collect::>(); - - if !invalid.is_empty() { - return Err(PathError::MissingPaths { - paths: PathDefs(invalid), - }); - } - - let server = ServerConfig { - identity, - routes: paths - .iter() - .map(|p| -> Route { - let str = p.as_ref(); - Route { - path: "/".to_string().parse().unwrap(), - kind: RouteKind::Dir(DirRoute { - dir: str.into(), - base: None, - }), - ..Default::default() - } - }) - .collect(), - ..Default::default() - }; - Ok(Input { - servers: vec![server], - }) -} diff --git a/crates/bsnext_input/src/target.rs b/crates/bsnext_input/src/target.rs index 39bf79f..3d863d2 100644 --- a/crates/bsnext_input/src/target.rs +++ b/crates/bsnext_input/src/target.rs @@ -4,4 +4,5 @@ pub enum TargetKind { Yaml, Toml, Md, + Html, } diff --git a/crates/bsnext_md/src/lib.rs b/crates/bsnext_md/src/lib.rs index d3f73f2..fb673af 100644 --- a/crates/bsnext_md/src/lib.rs +++ b/crates/bsnext_md/src/lib.rs @@ -5,7 +5,7 @@ use bsnext_input::path_def::PathDef; use bsnext_input::playground::Playground; use bsnext_input::route::{Route, RouteKind}; use bsnext_input::server_config::ServerConfig; -use bsnext_input::Input; +use bsnext_input::{Input, InputCtx}; use markdown::mdast::Node; use markdown::{Constructs, ParseOptions}; use nom::branch::alt; @@ -220,7 +220,7 @@ enum Convert { Playground(Playground), } -pub fn nodes_to_input(nodes: &[Node]) -> Result { +pub fn nodes_to_input(nodes: &[Node], ctx: &InputCtx) -> Result { let mut routes = vec![]; let mut input: Option = None; let mut parser = many0(alt(( @@ -334,6 +334,7 @@ pub fn nodes_to_input(nodes: &[Node]) -> Result { let mut input = Input::default(); let server = ServerConfig { routes, + identity: ctx.first_id_or_named(), ..Default::default() }; input.servers.push(server); @@ -360,7 +361,7 @@ fn code_val(n: &Node) -> &str { } } -fn str_to_nodes(input: &str) -> Result, MarkdownError> { +pub(crate) fn str_to_nodes(input: &str) -> Result, MarkdownError> { let opts = ParseOptions { constructs: Constructs { frontmatter: true, @@ -377,8 +378,3 @@ fn str_to_nodes(input: &str) -> Result, MarkdownError> { } } } - -pub fn md_to_input(input: &str) -> Result { - let root = str_to_nodes(input)?; - nodes_to_input(&root) -} diff --git a/crates/bsnext_md/src/md_fs.rs b/crates/bsnext_md/src/md_fs.rs index 1e67db6..e668e49 100644 --- a/crates/bsnext_md/src/md_fs.rs +++ b/crates/bsnext_md/src/md_fs.rs @@ -1,20 +1,25 @@ -use crate::md_to_input; -use bsnext_input::{Input, InputCreation, InputError}; +use crate::{nodes_to_input, str_to_nodes, MarkdownError}; +use bsnext_input::{Input, InputCreation, InputCtx, InputError}; use std::fs::read_to_string; use std::path::Path; pub struct MdFs; impl InputCreation for MdFs { - fn from_input_path>(path: P) -> Result> { + fn from_input_path>(path: P, ctx: &InputCtx) -> Result> { let str = read_to_string(path).map_err(|e| Box::new(e.into()))?; - let input = - md_to_input(&str).map_err(|e| Box::new(InputError::MarkdownError(e.to_string())))?; + let input = md_to_input(&str, ctx) + .map_err(|e| Box::new(InputError::MarkdownError(e.to_string())))?; Ok(input) } - fn from_input_str>(content: P) -> Result> { - let input = md_to_input(content.as_ref()) + fn from_input_str>(content: P, ctx: &InputCtx) -> Result> { + let input = md_to_input(content.as_ref(), ctx) .map_err(|e| Box::new(InputError::MarkdownError(e.to_string())))?; Ok(input) } } + +fn md_to_input(input: &str, ctx: &InputCtx) -> Result { + let root = str_to_nodes(input)?; + nodes_to_input(&root, ctx) +} diff --git a/crates/bsnext_md/src/md_writer.rs b/crates/bsnext_md/src/md_writer.rs index 0b3f2a2..a911f3d 100644 --- a/crates/bsnext_md/src/md_writer.rs +++ b/crates/bsnext_md/src/md_writer.rs @@ -12,7 +12,7 @@ impl InputWriter for MdWriter { } } -pub fn _input_to_str(input: &Input) -> String { +fn _input_to_str(input: &Input) -> String { let mut chunks = vec![]; if let Some(server_config) = input.servers.first() { #[derive(Debug, serde::Serialize)] diff --git a/crates/bsnext_md/tests/md.rs b/crates/bsnext_md/tests/md.rs index 3cc73b4..b4e41a4 100644 --- a/crates/bsnext_md/tests/md.rs +++ b/crates/bsnext_md/tests/md.rs @@ -1,7 +1,8 @@ use bsnext_input::path_def::PathDef; use bsnext_input::route::{Route, RouteKind}; use bsnext_input::server_config::ServerIdentity; -use bsnext_md::md_to_input; +use bsnext_input::InputCreation; +use bsnext_md::md_fs::MdFs; use std::str::FromStr; #[test] @@ -21,7 +22,7 @@ body { } ``` "#; - let config = md_to_input(&input).expect("unwrap"); + let config = MdFs::from_input_str(&input, &Default::default()).expect("unwrap"); let server_1 = config.servers.first().unwrap(); assert_eq!( server_1.routes[0], @@ -61,7 +62,7 @@ body { } ``` "#; - let config = md_to_input(&input).expect("unwrap"); + let config = MdFs::from_input_str(&input, &Default::default()).expect("unwrap"); let server_1 = config.servers.first().unwrap(); assert_eq!( server_1.routes[0], @@ -114,7 +115,7 @@ path: /abc # Before "#; - let input = md_to_input(&markdown).expect("unwrap"); + let input = MdFs::from_input_str(&markdown, &Default::default()).expect("unwrap"); let server_1 = input.servers.first().unwrap(); let expected_id = ServerIdentity::Address { bind_address: "0.0.0.0:3001".into(), @@ -149,7 +150,7 @@ path: /abc } fn default_md_assertions(input: &str) -> anyhow::Result<()> { - let input = md_to_input(&input).expect("unwrap"); + let input = MdFs::from_input_str(&input, &Default::default()).expect("unwrap"); let server_1 = input.servers.first().unwrap(); let expected_id = ServerIdentity::Address { bind_address: "0.0.0.0:5001".into(), diff --git a/crates/bsnext_md/tests/md_playground.rs b/crates/bsnext_md/tests/md_playground.rs index 841f5c1..3906fe4 100644 --- a/crates/bsnext_md/tests/md_playground.rs +++ b/crates/bsnext_md/tests/md_playground.rs @@ -1,4 +1,5 @@ -use bsnext_md::md_to_input; +use bsnext_input::InputCreation; +use bsnext_md::md_fs::MdFs; #[test] fn test_md_playground() -> anyhow::Result<()> { @@ -27,7 +28,7 @@ console.log("hello world") ``` "#; - let config = md_to_input(&input).expect("unwrap"); + let config = MdFs::from_input_str(&input, &Default::default()).expect("unwrap"); let first_server = config.servers.get(0).unwrap(); let routes = first_server .playground diff --git a/crates/bsnext_md/tests/md_serialize.rs b/crates/bsnext_md/tests/md_serialize.rs index ab53ceb..cc2b8ae 100644 --- a/crates/bsnext_md/tests/md_serialize.rs +++ b/crates/bsnext_md/tests/md_serialize.rs @@ -1,14 +1,14 @@ -use bsnext_input::InputWriter; -use bsnext_md::md_to_input; +use bsnext_input::{InputCreation, InputWriter}; +use bsnext_md::md_fs::MdFs; use bsnext_md::md_writer::MdWriter; #[test] fn test_input_to_str() -> anyhow::Result<()> { let input_str = include_str!("../../../examples/markdown/single.md"); - let input = md_to_input(&input_str).expect("unwrap"); + let input = MdFs::from_input_str(&input_str, &Default::default()).expect("unwrap"); let output = MdWriter.input_to_str(&input); println!("{}", output); - let input = md_to_input(&output).expect("unwrapped 2"); + let input = MdFs::from_input_str(&output, &Default::default()).expect("unwrapped 2"); println!("{:#?}", input); assert_eq!(input.servers.len(), 1); assert_eq!(input.servers.first().unwrap().routes.len(), 2); diff --git a/crates/bsnext_md/tests/snapshots/md_playground__md_playground.snap b/crates/bsnext_md/tests/snapshots/md_playground__md_playground.snap index 6fc8724..adf8ecd 100644 --- a/crates/bsnext_md/tests/snapshots/md_playground__md_playground.snap +++ b/crates/bsnext_md/tests/snapshots/md_playground__md_playground.snap @@ -24,7 +24,7 @@ expression: routes inner: Addition( InjectAddition { addition_position: Prepend( - "\n\n \n \n \n \n Document\n \n \n \n", + "\n\n \n \n \n \n Browsersync Live - Playground\n \n \n \n", ), }, ), @@ -40,7 +40,7 @@ expression: routes inner: Addition( InjectAddition { addition_position: Append( - "\n \n \n\n", + "\n \n \n\n", ), }, ), diff --git a/crates/bsnext_system/Cargo.toml b/crates/bsnext_system/Cargo.toml index 150b2f0..4ff721b 100644 --- a/crates/bsnext_system/Cargo.toml +++ b/crates/bsnext_system/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" [dependencies] bsnext_input = { path = "../bsnext_input" } bsnext_md = { path = "../bsnext_md" } +bsnext_html = { path = "../bsnext_html" } bsnext_yaml = { path = "../bsnext_yaml" } bsnext_tracing = { path = "../bsnext_tracing" } bsnext_core = { path = "../bsnext_core" } diff --git a/crates/bsnext_system/src/input_fs.rs b/crates/bsnext_system/src/input_fs.rs index 02a25e5..bf3e8e5 100644 --- a/crates/bsnext_system/src/input_fs.rs +++ b/crates/bsnext_system/src/input_fs.rs @@ -1,13 +1,14 @@ -use bsnext_input::{Input, InputCreation, InputError}; +use bsnext_input::{Input, InputCreation, InputCtx, InputError}; use std::path::Path; -pub fn from_input_path>(path: P) -> Result> { +pub fn from_input_path>(path: P, ctx: &InputCtx) -> Result> { match path.as_ref().extension().and_then(|x| x.to_str()) { None => Err(Box::new(InputError::MissingExtension( path.as_ref().to_owned(), ))), - Some("yml") | Some("yaml") => bsnext_yaml::yaml_fs::YamlFs::from_input_path(path), - Some("md") | Some("markdown") => bsnext_md::md_fs::MdFs::from_input_path(path), + Some("yml") | Some("yaml") => bsnext_yaml::yaml_fs::YamlFs::from_input_path(path, ctx), + Some("md") | Some("markdown") => bsnext_md::md_fs::MdFs::from_input_path(path, ctx), + Some("html") => bsnext_html::HtmlFs::from_input_path(path, ctx), Some(other) => Err(Box::new(InputError::UnsupportedExtension( other.to_string(), ))), diff --git a/crates/bsnext_system/src/lib.rs b/crates/bsnext_system/src/lib.rs index 932d729..e74db75 100644 --- a/crates/bsnext_system/src/lib.rs +++ b/crates/bsnext_system/src/lib.rs @@ -3,7 +3,7 @@ use crate::monitor::{ }; use actix::{Actor, Addr, AsyncContext, Handler, Running}; -use bsnext_input::Input; +use bsnext_input::{Input, InputCtx}; use std::collections::HashMap; use actix_rt::Arbiter; @@ -43,11 +43,17 @@ pub struct BsSystem { self_addr: Option>, servers_addr: Option>, any_event_sender: Option>, - input_monitors: Vec>, + input_monitors: Option, any_monitors: HashMap, cwd: Option, } +#[derive(Debug, Clone)] +pub struct InputMonitor { + pub addr: Addr, + pub ctx: InputCtx, +} + #[derive(Debug)] pub struct EventWithSpan { pub evt: ExternalEventsDTO, @@ -73,7 +79,7 @@ impl BsSystem { self_addr: None, servers_addr: None, any_event_sender: None, - input_monitors: vec![], + input_monitors: None, any_monitors: Default::default(), cwd: None, } @@ -294,9 +300,16 @@ impl Handler for BsSystem { match msg.kind.input(&start_context) { Ok(SystemStartArgs::PathWithInput { path, input }) => { tracing::debug!("PathWithInput"); + let ids = input + .servers + .iter() + .map(|x| x.identity.clone()) + .collect::>(); + let input_ctx = InputCtx::new(&ids, None); ctx.notify(MonitorInput { path: path.clone(), cwd: cwd.clone(), + ctx: input_ctx, }); self.accept_watchables(&input); @@ -314,6 +327,7 @@ impl Handler for BsSystem { ctx.notify(MonitorInput { path: path.clone(), cwd: cwd.clone(), + ctx: InputCtx::default(), }); self.publish_any_event(AnyEvent::Internal(InternalEvents::InputError(input_error))); Ok(DidStart::Started) diff --git a/crates/bsnext_system/src/monitor.rs b/crates/bsnext_system/src/monitor.rs index 07186d9..81c3a50 100644 --- a/crates/bsnext_system/src/monitor.rs +++ b/crates/bsnext_system/src/monitor.rs @@ -1,4 +1,4 @@ -use crate::BsSystem; +use crate::{BsSystem, InputMonitor}; use actix::{Actor, Addr, AsyncContext}; use std::hash::Hash; @@ -10,7 +10,7 @@ use bsnext_fs::{ }; use bsnext_input::route::{DebounceDuration, DirRoute, FilterKind, RouteKind, Spec, SpecOpts}; use bsnext_input::server_config::ServerIdentity; -use bsnext_input::{Input, InputError, PathDefinition, PathDefs, PathError}; +use bsnext_input::{Input, InputCtx, InputError, PathDefinition, PathDefs, PathError}; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::Duration; @@ -33,6 +33,7 @@ pub struct Monitor { pub struct MonitorInput { pub path: PathBuf, pub cwd: PathBuf, + pub ctx: InputCtx, } impl actix::Handler for BsSystem { @@ -53,7 +54,11 @@ impl actix::Handler for BsSystem { tracing::trace!("[main.rs] starting input monitor"); let input_watcher_addr = input_watcher.start(); - self.input_monitors.push(input_watcher_addr.clone()); + let input_monitor = InputMonitor { + addr: input_watcher_addr.clone(), + ctx: msg.ctx.clone(), + }; + self.input_monitors = Some(input_monitor); input_watcher_addr.do_send(RequestWatchPath { recipients: vec![ctx.address().recipient()], @@ -92,14 +97,34 @@ impl BsSystem { let _guard = span.enter(); match msg.ctx.id() { 0 => { - tracing::info!(?inner, "InputFile file changed"); - let input = from_input_path(&inner.absolute_path); + tracing::info!("InputFile file changed {:?}", inner); + + let ctx = self + .input_monitors + .as_ref() + .map(|x| x.ctx.clone()) + .unwrap_or_default(); + + let input = from_input_path(&inner.absolute_path, &ctx); let Ok(input) = input else { let err = input.unwrap_err(); return Some(AnyEvent::Internal(InternalEvents::InputError(*err))); }; + if let Some(mon) = self.input_monitors.as_mut() { + let next = input + .servers + .iter() + .map(|s| s.identity.clone()) + .collect::>(); + let ctx = InputCtx::new(&next, None); + tracing::info!("will set next ids {:?}", next); + if !next.is_empty() { + mon.ctx = ctx + } + } + self.accept_watchables(&input); self.resolve_servers(input); diff --git a/crates/bsnext_system/src/start_kind.rs b/crates/bsnext_system/src/start_kind.rs index fbd38e0..bcd0565 100644 --- a/crates/bsnext_system/src/start_kind.rs +++ b/crates/bsnext_system/src/start_kind.rs @@ -1,7 +1,7 @@ use crate::args::Args; use crate::start_kind::start_from_example::StartFromExample; use crate::start_kind::start_from_inputs::{StartFromInput, StartFromInputPaths}; -use crate::start_kind::start_from_paths::StartFromPaths; +use crate::start_kind::start_from_paths::StartFromDirPaths; use bsnext_input::startup::{StartupContext, SystemStart, SystemStartArgs}; use bsnext_input::{Input, InputError}; @@ -14,7 +14,7 @@ pub enum StartKind { FromInput(StartFromInput), FromInputPaths(StartFromInputPaths), FromExample(StartFromExample), - FromPaths(StartFromPaths), + FromDirPaths(StartFromDirPaths), } impl StartKind { @@ -33,7 +33,7 @@ impl StartKind { } if !args.paths.is_empty() { - StartKind::FromPaths(StartFromPaths { + StartKind::FromDirPaths(StartFromDirPaths { paths: args.paths, write_input: args.write, port: args.port, @@ -42,6 +42,7 @@ impl StartKind { } else { StartKind::FromInputPaths(StartFromInputPaths { input_paths: args.input.clone(), + port: args.port, }) } } @@ -55,7 +56,7 @@ impl SystemStart for StartKind { match self { StartKind::FromInputPaths(from_inputs) => from_inputs.input(ctx), StartKind::FromExample(from_example) => from_example.input(ctx), - StartKind::FromPaths(from_input_paths) => from_input_paths.input(ctx), + StartKind::FromDirPaths(from_dir_paths) => from_dir_paths.input(ctx), StartKind::FromInput(from_inputs) => from_inputs.input(ctx), } } @@ -67,7 +68,7 @@ pub mod start_fs { use std::path::{Path, PathBuf}; use bsnext_input::target::TargetKind; - use bsnext_input::{DirError, Input, InputWriteError}; + use bsnext_input::{DirError, Input, InputWriteError, InputWriter}; #[derive(Default, Debug, PartialEq)] pub enum WriteMode { @@ -82,14 +83,16 @@ pub mod start_fs { write_mode: &WriteMode, ) -> Result { let string = match target_kind { - TargetKind::Yaml => bsnext_yaml::input_to_str(input), + TargetKind::Yaml => bsnext_yaml::yaml_writer::YamlWriter.input_to_str(input), TargetKind::Toml => todo!("toml missing"), - TargetKind::Md => bsnext_md::md_writer::_input_to_str(input), + TargetKind::Md => bsnext_md::md_writer::MdWriter.input_to_str(input), + TargetKind::Html => bsnext_html::html_writer::HtmlWriter.input_to_str(input), }; let name = match target_kind { TargetKind::Yaml => "bslive.yml", TargetKind::Toml => todo!("toml missing"), TargetKind::Md => "bslive.md", + TargetKind::Html => "bslive.html", }; let next_path = cwd.join(name); tracing::info!( diff --git a/crates/bsnext_system/src/start_kind/start_from_example.rs b/crates/bsnext_system/src/start_kind/start_from_example.rs index 5f76fb1..ef2945f 100644 --- a/crates/bsnext_system/src/start_kind/start_from_example.rs +++ b/crates/bsnext_system/src/start_kind/start_from_example.rs @@ -19,6 +19,7 @@ pub struct StartFromExample { impl SystemStart for StartFromExample { fn input(&self, ctx: &StartupContext) -> Result> { + // todo: mimic this for other kinds of startup - basically allow 'port' to be given and respected let identity = ServerIdentity::from_port_or_named(self.port).map_err(|e| Box::new(e.into()))?; let input_source_kind = self.example.into_input(Some(identity)); diff --git a/crates/bsnext_system/src/start_kind/start_from_inputs.rs b/crates/bsnext_system/src/start_kind/start_from_inputs.rs index 9be6874..16f7517 100644 --- a/crates/bsnext_system/src/start_kind/start_from_inputs.rs +++ b/crates/bsnext_system/src/start_kind/start_from_inputs.rs @@ -1,21 +1,22 @@ use bsnext_input::startup::{StartupContext, SystemStart, SystemStartArgs}; use crate::input_fs::from_input_path; -use bsnext_input::{Input, InputError}; +use bsnext_input::{Input, InputArgs, InputCtx, InputError}; use std::path::{Path, PathBuf}; #[derive(Debug)] pub struct StartFromInputPaths { pub input_paths: Vec, + pub port: Option, } impl SystemStart for StartFromInputPaths { fn input(&self, ctx: &StartupContext) -> Result> { - from_yml_paths(&ctx.cwd, &self.input_paths) + from_input_paths(&ctx.cwd, &self.input_paths, &self.port) } } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct StartFromInput { pub input: Input, } @@ -28,16 +29,17 @@ impl SystemStart for StartFromInput { } } -fn from_yml_paths>( +fn from_input_paths>( cwd: &Path, inputs: &[T], + port: &Option, ) -> Result> { let input_candidates = inputs .iter() .map(|path| cwd.join(path.as_ref())) .collect::>(); - let lookups = ["bslive.yml", "bslive.yaml", "bslive.md"] + let lookups = ["bslive.yml", "bslive.yaml", "bslive.md", "bslive.html"] .iter() .map(|path| cwd.join(path)) .collect::>(); @@ -75,7 +77,11 @@ fn from_yml_paths>( tracing::info!(?input_path); - let result = from_input_path(input_path); + let input_args = InputArgs { + port: port.to_owned(), + }; + let initial_ctx = InputCtx::new(&[], Some(input_args)); + let result = from_input_path(input_path, &initial_ctx); match result { Ok(input) => Ok(SystemStartArgs::PathWithInput { path: input_path.to_path_buf(), diff --git a/crates/bsnext_system/src/start_kind/start_from_paths.rs b/crates/bsnext_system/src/start_kind/start_from_paths.rs index 88114c5..32a40c8 100644 --- a/crates/bsnext_system/src/start_kind/start_from_paths.rs +++ b/crates/bsnext_system/src/start_kind/start_from_paths.rs @@ -1,24 +1,26 @@ use crate::start_kind::start_fs; use crate::start_kind::start_fs::WriteMode; -use bsnext_input::paths::from_paths; -use bsnext_input::server_config::ServerIdentity; +use bsnext_input::route::{DirRoute, Route, RouteKind}; +use bsnext_input::server_config::{ServerConfig, ServerIdentity}; use bsnext_input::startup::{StartupContext, SystemStart, SystemStartArgs}; use bsnext_input::target::TargetKind; -use bsnext_input::InputError; +use bsnext_input::{Input, InputError, PathDefinition, PathDefs, PathError}; +use std::path::{Path, PathBuf}; #[derive(Debug)] -pub struct StartFromPaths { +pub struct StartFromDirPaths { pub paths: Vec, pub write_input: bool, pub port: Option, pub force: bool, } -impl SystemStart for StartFromPaths { +impl SystemStart for StartFromDirPaths { fn input(&self, ctx: &StartupContext) -> Result> { let identity = ServerIdentity::from_port_or_named(self.port).map_err(|e| Box::new(e.into()))?; - let input = from_paths(&ctx.cwd, &self.paths, identity).map_err(|e| Box::new(e.into()))?; + let input = + from_dir_paths(&ctx.cwd, &self.paths, identity).map_err(|e| Box::new(e.into()))?; let write_mode = if self.force { WriteMode::Override } else { @@ -34,6 +36,69 @@ impl SystemStart for StartFromPaths { } } +fn from_dir_paths>( + cwd: &Path, + paths: &[T], + identity: ServerIdentity, +) -> Result { + let path_defs = paths + .iter() + .map(|p| { + let pb = PathBuf::from(p.as_ref()); + if pb.is_absolute() { + return PathDefinition { + input: p.as_ref().to_string(), + cwd: cwd.to_path_buf(), + absolute: pb, + }; + } else { + return PathDefinition { + input: p.as_ref().to_string(), + cwd: cwd.to_path_buf(), + absolute: cwd.join(pb), + }; + } + }) + .map(|path_def| { + let exists = path_def.absolute.exists(); + (path_def, exists) + }) + .collect::>(); + + let invalid = path_defs + .into_iter() + .filter_map(|(pb, exists)| if exists { None } else { Some(pb) }) + .collect::>(); + + if !invalid.is_empty() { + return Err(PathError::MissingPaths { + paths: PathDefs(invalid), + }); + } + + let server = ServerConfig { + identity, + routes: paths + .iter() + .map(|p| -> Route { + let str = p.as_ref(); + Route { + path: "/".to_string().parse().unwrap(), + kind: RouteKind::Dir(DirRoute { + dir: str.into(), + base: None, + }), + ..Default::default() + } + }) + .collect(), + ..Default::default() + }; + Ok(Input { + servers: vec![server], + }) +} + #[cfg(test)] mod test { use super::*; @@ -41,7 +106,7 @@ mod test { fn test() -> anyhow::Result<()> { use tempfile::tempdir; let tmp_dir = tempdir()?; - let v = StartFromPaths { + let v = StartFromDirPaths { paths: vec![".".into()], write_input: false, port: Some(3000), diff --git a/crates/bsnext_yaml/src/lib.rs b/crates/bsnext_yaml/src/lib.rs index 5768f57..1ee67cc 100644 --- a/crates/bsnext_yaml/src/lib.rs +++ b/crates/bsnext_yaml/src/lib.rs @@ -1,6 +1,2 @@ pub mod yaml_fs; -use bsnext_input::Input; - -pub fn input_to_str(input: &Input) -> String { - serde_yaml::to_string(&input).expect("create yaml?") -} +pub mod yaml_writer; diff --git a/crates/bsnext_yaml/src/yaml_fs.rs b/crates/bsnext_yaml/src/yaml_fs.rs index 0df1d03..948ad60 100644 --- a/crates/bsnext_yaml/src/yaml_fs.rs +++ b/crates/bsnext_yaml/src/yaml_fs.rs @@ -1,5 +1,5 @@ use bsnext_input::yml::YamlError; -use bsnext_input::{BsLiveRulesError, Input, InputCreation, InputError}; +use bsnext_input::{BsLiveRulesError, Input, InputCreation, InputCtx, InputError}; use miette::NamedSource; use std::fs::read_to_string; use std::path::Path; @@ -7,7 +7,7 @@ use std::path::Path; pub struct YamlFs; impl InputCreation for YamlFs { - fn from_input_path>(path: P) -> Result> { + fn from_input_path>(path: P, _ctx: &InputCtx) -> Result> { let str = read_to_string(&path).map_err(|e| Box::new(e.into()))?; if str.trim().is_empty() { return Err(Box::new(InputError::YamlError(YamlError::EmptyError { @@ -32,7 +32,10 @@ impl InputCreation for YamlFs { Ok(output) } - fn from_input_str>(_content: P) -> Result> { + fn from_input_str>( + _content: P, + _ctx: &InputCtx, + ) -> Result> { todo!() } } diff --git a/crates/bsnext_yaml/src/yaml_writer.rs b/crates/bsnext_yaml/src/yaml_writer.rs new file mode 100644 index 0000000..bf686a5 --- /dev/null +++ b/crates/bsnext_yaml/src/yaml_writer.rs @@ -0,0 +1,13 @@ +use bsnext_input::{Input, InputWriter}; + +pub struct YamlWriter; + +impl InputWriter for YamlWriter { + fn input_to_str(&self, input: &Input) -> String { + input_to_str(input) + } +} + +fn input_to_str(input: &Input) -> String { + serde_yaml::to_string(&input).expect("create yaml?") +} diff --git a/examples/basic/public/index.html b/examples/basic/public/index.html index 45d6b1b..081fd9d 100644 --- a/examples/basic/public/index.html +++ b/examples/basic/public/index.html @@ -9,7 +9,7 @@ -

Edit me!

+

Edit me! - a full HTML

\ No newline at end of file diff --git a/examples/basic/public/styles.css b/examples/basic/public/styles.css index 870d334..9fbc98d 100644 --- a/examples/basic/public/styles.css +++ b/examples/basic/public/styles.css @@ -1,3 +1,6 @@ @import url("./reset.css"); /** your styles here */ +body { + background: red; +} \ No newline at end of file diff --git a/examples/html/playground.html b/examples/html/playground.html new file mode 100644 index 0000000..a234b1f --- /dev/null +++ b/examples/html/playground.html @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/generated/dto.ts b/generated/dto.ts index ab0cddb..9900352 100644 --- a/generated/dto.ts +++ b/generated/dto.ts @@ -149,6 +149,7 @@ export type InputErrorDTO = | { kind: "DirError", payload: string } | { kind: "YamlError", payload: string } | { kind: "MarkdownError", payload: string } + | { kind: "HtmlError", payload: string } | { kind: "Io", payload: string } | { kind: "UnsupportedExtension", payload: string } | { kind: "MissingExtension", payload: string } diff --git a/generated/schema.js b/generated/schema.js index 19c120f..a516bfa 100644 --- a/generated/schema.js +++ b/generated/schema.js @@ -235,6 +235,10 @@ var inputErrorDTOSchema = z.union([ kind: z.literal("MarkdownError"), payload: z.string() }), + z.object({ + kind: z.literal("HtmlError"), + payload: z.string() + }), z.object({ kind: z.literal("Io"), payload: z.string() diff --git a/generated/schema.ts b/generated/schema.ts index 0369006..6f79d60 100644 --- a/generated/schema.ts +++ b/generated/schema.ts @@ -238,6 +238,10 @@ export const inputErrorDTOSchema = z.union([ kind: z.literal("MarkdownError"), payload: z.string(), }), + z.object({ + kind: z.literal("HtmlError"), + payload: z.string(), + }), z.object({ kind: z.literal("Io"), payload: z.string(), diff --git a/inject/dist/index.js b/inject/dist/index.js index 3d53464..24b29ea 100644 --- a/inject/dist/index.js +++ b/inject/dist/index.js @@ -1,3 +1,3 @@ var dn=Object.create;var rr=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var hn=Object.getPrototypeOf,mn=Object.prototype.hasOwnProperty;var vn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var yn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pn(e))!mn.call(r,o)&&o!==t&&rr(r,o,{get:()=>e[o],enumerable:!(n=fn(e,o))||n.enumerable});return r};var gn=(r,e,t)=>(t=r!=null?dn(hn(r)):{},yn(e||!r||!r.__esModule?rr(t,"default",{value:r,enumerable:!0}):t,r));var cn=vn(sn=>{"use strict";var At=class{constructor(e){this.func=e,this.running=!1,this.id=null,this._handler=()=>(this.running=!1,this.id=null,this.func())}start(e){this.running&&clearTimeout(this.id),this.id=setTimeout(this._handler,e),this.running=!0}stop(){this.running&&(clearTimeout(this.id),this.running=!1,this.id=null)}};At.start=(r,e)=>setTimeout(e,r);sn.Timer=At});var Pt=function(r,e){return Pt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])},Pt(r,e)};function R(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Pt(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var et=function(){return et=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function V(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),o,i=[],a;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(s){a={error:s}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return i}function F(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,i;n1||c(g,w)})},E&&(o[g]=E(o[g])))}function c(g,E){try{l(n[g](E))}catch(w){T(i[0][3],w)}}function l(g){g.value instanceof ae?Promise.resolve(g.value.v).then(d,v):T(i[0][2],g)}function d(g){c("next",g)}function v(g){c("throw",g)}function T(g,E){g(E),i.shift(),i.length&&c(i[0][0],i[0][1])}}function ir(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof J=="function"?J(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=r[i]&&function(a){return new Promise(function(s,c){a=r[i](a),o(s,c,a.done,a.value)})}}function o(i,a,s,c){Promise.resolve(c).then(function(l){i({value:l,done:s})},a)}}function S(r){return typeof r=="function"}function rt(r){var e=function(n){Error.call(n),n.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var nt=rt(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription: `+t.map(function(n,o){return o+1+") "+n.toString()}).join(` - `):"",this.name="UnsubscriptionError",this.errors=t}});function se(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var Y=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var s=J(a),c=s.next();!c.done;c=s.next()){var l=c.value;l.remove(this)}}catch(w){e={error:w}}finally{try{c&&!c.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else a.remove(this);var d=this.initialTeardown;if(S(d))try{d()}catch(w){i=w instanceof nt?w.errors:[w]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var T=J(v),g=T.next();!g.done;g=T.next()){var E=g.value;try{ar(E)}catch(w){i=i??[],w instanceof nt?i=F(F([],V(i)),V(w.errors)):i.push(w)}}}catch(w){n={error:w}}finally{try{g&&!g.done&&(o=T.return)&&o.call(T)}finally{if(n)throw n.error}}}if(i)throw new nt(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)ar(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&se(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&se(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();var Nt=Y.EMPTY;function ot(r){return r instanceof Y||r&&"closed"in r&&S(r.remove)&&S(r.add)&&S(r.unsubscribe)}function ar(r){S(r)?r():r.unsubscribe()}var B={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Ce={setTimeout:function(r,e){for(var t=[],n=2;n0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,o=this,i=o.hasError,a=o.isStopped,s=o.observers;return i||a?Nt:(this.currentObservers=null,s.push(t),new Y(function(){n.currentObservers=null,se(s,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?t.error(i):a&&t.complete()},e.prototype.asObservable=function(){var t=new O;return t.source=this,t},e.create=function(t,n){return new st(t,n)},e}(O);var st=function(r){R(e,r);function e(t,n){var o=r.call(this)||this;return o.destination=t,o.source=n,o}return e.prototype.next=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,t)},e.prototype.error=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&o!==void 0?o:Nt},e}(z);var We={now:function(){return(We.delegate||Date).now()},delegate:void 0};var ct=function(r){R(e,r);function e(t,n,o){t===void 0&&(t=1/0),n===void 0&&(n=1/0),o===void 0&&(o=We);var i=r.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return e.prototype.next=function(t){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,s=n._timestampProvider,c=n._windowTime;o||(i.push(t),!a&&i.push(s.now()+c)),this._trimBuffer(),r.prototype.next.call(this,t)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),o=this,i=o._infiniteTimeWindow,a=o._buffer,s=a.slice(),c=0;c0&&(d=new le({next:function(Qe){return Xe.next(Qe)},error:function(Qe){w=!0,A(),v=Wt(M,o,Qe),Xe.error(Qe)},complete:function(){E=!0,A(),v=Wt(M,a),Xe.complete()}}),I($e).subscribe(d))})(l)}}function Wt(r,e){for(var t=[],n=2;n{let r=new URL(window.location.href);return r.protocol=r.protocol==="http:"?"ws":"wss",r.pathname="/__bs_ws",Bt(r.origin+r.pathname).pipe(Ut({delay:5e3}))}}}var Mr={debug(...r){},error(...r){},info(...r){},trace(...r){}},zt={name:"console",globalSetup:r=>{let e=new z;return[e,{debug:function(...n){e.next({level:"debug",args:n})},info:function(...n){e.next({level:"info",args:n})},trace:function(...n){e.next({level:"trace",args:n})},error:function(...n){e.next({level:"error",args:n})}}]},resetSink:(r,e,t)=>r.pipe(Be(n=>{let o=["trace","debug","info","error"],i=o.indexOf(n.level),a=o.indexOf(t.log_level);i>=a&&console.log(`[${n.level}]`,...n.args)}),Fe())};var k;(function(r){r.assertEqual=o=>o;function e(o){}r.assertIs=e;function t(o){throw new Error}r.assertNever=t,r.arrayToEnum=o=>{let i={};for(let a of o)i[a]=a;return i},r.getValidEnumValues=o=>{let i=r.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),a={};for(let s of i)a[s]=o[s];return r.objectValues(a)},r.objectValues=o=>r.objectKeys(o).map(function(i){return o[i]}),r.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},r.find=(o,i)=>{for(let a of o)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(k||(k={}));var Yt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Yt||(Yt={}));var h=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),re=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}},f=k.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ln=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),L=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(i){return i.message},n={_errors:[]},o=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let s=n,c=0;for(;ct.message){let t={},n=[];for(let o of this.issues)o.path.length>0?(t[o.path[0]]=t[o.path[0]]||[],t[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};L.create=r=>new L(r);var Pe=(r,e)=>{let t;switch(r.code){case f.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case f.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case f.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(r)}return{message:t}},$r=Pe;function Zn(r){$r=r}function St(){return $r}var kt=r=>{let{data:e,path:t,errorMaps:n,issueData:o}=r,i=[...t,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let s="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)s=l(a,{data:e,defaultError:s}).message;return{...o,path:i,message:s}},$n=[];function p(r,e){let t=St(),n=kt({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Pe?void 0:Pe].filter(o=>!!o)});r.common.issues.push(n)}var P=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let o of t){if(o.status==="aborted")return _;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let o of t){let i=await o.key,a=await o.value;n.push({key:i,value:a})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let o of t){let{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return _;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},_=Object.freeze({status:"aborted"}),Ae=r=>({status:"dirty",value:r}),N=r=>({status:"valid",value:r}),Ht=r=>r.status==="aborted",Gt=r=>r.status==="dirty",Ye=r=>r.status==="valid",He=r=>typeof Promise<"u"&&r instanceof Promise;function Tt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Ur(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t}var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));var ze,qe,W=class{constructor(e,t,n,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=o}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Lr=(r,e)=>{if(Ye(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new L(r.common.issues);return this._error=t,this._error}}};function b(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:o}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(a,s)=>{var c,l;let{message:d}=r;return a.code==="invalid_enum_value"?{message:d??s.defaultError}:typeof s.data>"u"?{message:(c=d??n)!==null&&c!==void 0?c:s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:(l=d??t)!==null&&l!==void 0?l:s.defaultError}},description:o}}var x=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return re(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(He(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let o={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)},i=this._parseSync({data:e,path:o.path,parent:o});return Lr(o,i)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)},o=this._parse({data:e,path:n.path,parent:n}),i=await(He(o)?o:Promise.resolve(o));return Lr(n,i)}refine(e,t){let n=o=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(o):t;return this._refinement((o,i)=>{let a=e(o),s=()=>i.addIssue({code:f.custom,...n(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,t){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof t=="function"?t(n,o):t),!1))}_refinement(e){return new Z({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return U.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ee.create(this,this._def)}promise(){return ie.create(this,this._def)}or(e){return ge.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new Z({...b(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ke({...b(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Ge({typeName:y.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Te({...b(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Je.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Un=/^c[^\s-]{8,}$/i,Wn=/^[0-9a-z]+$/,Vn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Fn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Bn=/^[a-z0-9_-]{21}$/i,zn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,qn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",qt,Hn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Gn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Jn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Kn=new RegExp(`^${Wr}$`);function Vr(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Xn(r){return new RegExp(`^${Vr(r)}$`)}function Fr(r){let e=`${Wr}T${Vr(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Qn(r,e){return!!((e==="v4"||!e)&&Hn.test(r)||(e==="v6"||!e)&&Gn.test(r))}var ne=class r extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.string,received:i.parsedType}),_}let n=new P,o;for(let i of this._def.checks)if(i.kind==="min")e.data.lengthi.value&&(o=this._getOrReturnCtx(e,o),p(o,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,s=e.data.lengthe.test(o),{validation:t,code:f.invalid_string,...m.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new ne({checks:[],typeName:y.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};function eo(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=t>n?t:n,i=parseInt(r.toFixed(o).replace(".","")),a=parseInt(e.toFixed(o).replace(".",""));return i%a/Math.pow(10,o)}var fe=class r extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.number,received:i.parsedType}),_}let n,o=new P;for(let i of this._def.checks)i.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?eo(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:f.not_finite,message:i.message}),o.dirty()):k.assertNever(i);return{status:o.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,o){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(o)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.valuenew fe({checks:[],typeName:y.ZodNumber,coerce:r?.coerce||!1,...b(r)});var pe=class r extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==h.bigint){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.bigint,received:i.parsedType}),_}let n,o=new P;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):k.assertNever(i);return{status:o.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,o){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(o)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new pe({checks:[],typeName:y.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};var he=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.boolean,received:n.parsedType}),_}return N(e.data)}};he.create=r=>new he({typeName:y.ZodBoolean,coerce:r?.coerce||!1,...b(r)});var me=class r extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.date,received:i.parsedType}),_}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_date}),_}let n=new P,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()i.value&&(o=this._getOrReturnCtx(e,o),p(o,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):k.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew me({checks:[],coerce:r?.coerce||!1,typeName:y.ZodDate,...b(r)});var Ne=class extends x{_parse(e){if(this._getType(e)!==h.symbol){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.symbol,received:n.parsedType}),_}return N(e.data)}};Ne.create=r=>new Ne({typeName:y.ZodSymbol,...b(r)});var ve=class extends x{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.undefined,received:n.parsedType}),_}return N(e.data)}};ve.create=r=>new ve({typeName:y.ZodUndefined,...b(r)});var ye=class extends x{_parse(e){if(this._getType(e)!==h.null){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.null,received:n.parsedType}),_}return N(e.data)}};ye.create=r=>new ye({typeName:y.ZodNull,...b(r)});var oe=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}};oe.create=r=>new oe({typeName:y.ZodAny,...b(r)});var Q=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}};Q.create=r=>new Q({typeName:y.ZodUnknown,...b(r)});var q=class extends x{_parse(e){let t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:h.never,received:t.parsedType}),_}};q.create=r=>new q({typeName:y.ZodNever,...b(r)});var De=class extends x{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.void,received:n.parsedType}),_}return N(e.data)}};De.create=r=>new De({typeName:y.ZodVoid,...b(r)});var ee=class r extends x{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),o=this._def;if(t.parsedType!==h.array)return p(t,{code:f.invalid_type,expected:h.array,received:t.parsedType}),_;if(o.exactLength!==null){let a=t.data.length>o.exactLength.value,s=t.data.lengtho.maxLength.value&&(p(t,{code:f.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,s)=>o.type._parseAsync(new W(t,a,t.path,s)))).then(a=>P.mergeArray(n,a));let i=[...t.data].map((a,s)=>o.type._parseSync(new W(t,a,t.path,s)));return P.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}};ee.create=(r,e)=>new ee({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...b(e)});function Re(r){if(r instanceof D){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=U.create(Re(n))}return new D({...r._def,shape:()=>e})}else return r instanceof ee?new ee({...r._def,type:Re(r.element)}):r instanceof U?U.create(Re(r.unwrap())):r instanceof G?G.create(Re(r.unwrap())):r instanceof H?H.create(r.items.map(e=>Re(e))):r}var D=class r extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.object){let l=this._getOrReturnCtx(e);return p(l,{code:f.invalid_type,expected:h.object,received:l.parsedType}),_}let{status:n,ctx:o}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof q&&this._def.unknownKeys==="strip"))for(let l in o.data)a.includes(l)||s.push(l);let c=[];for(let l of a){let d=i[l],v=o.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new W(o,v,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof q){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of s)c.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")s.length>0&&(p(o,{code:f.unrecognized_keys,keys:s}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let d of s){let v=o.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new W(o,v,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of c){let v=await d.key,T=await d.value;l.push({key:v,value:T,alwaysSet:d.alwaysSet})}return l}).then(l=>P.mergeObjectSync(n,l)):P.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var o,i,a,s;let c=(a=(i=(o=this._def).errorMap)===null||i===void 0?void 0:i.call(o,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(s=m.errToObj(e).message)!==null&&s!==void 0?s:c}:{message:c}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return k.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return k.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return Re(this)}partial(e){let t={};return k.objectKeys(this.shape).forEach(n=>{let o=this.shape[n];e&&!e[n]?t[n]=o:t[n]=o.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return k.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof U;)i=i._def.innerType;t[n]=i}}),new r({...this._def,shape:()=>t})}keyof(){return Br(k.objectKeys(this.shape))}};D.create=(r,e)=>new D({shape:()=>r,unknownKeys:"strip",catchall:q.create(),typeName:y.ZodObject,...b(e)});D.strictCreate=(r,e)=>new D({shape:()=>r,unknownKeys:"strict",catchall:q.create(),typeName:y.ZodObject,...b(e)});D.lazycreate=(r,e)=>new D({shape:r,unknownKeys:"strip",catchall:q.create(),typeName:y.ZodObject,...b(e)});var ge=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function o(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(s=>new L(s.ctx.common.issues));return p(t,{code:f.invalid_union,unionErrors:a}),_}if(t.common.async)return Promise.all(n.map(async i=>{let a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(o);{let i,a=[];for(let c of n){let l={...t,common:{...t.common,issues:[]},parent:null},d=c._parseSync({data:t.data,path:t.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let s=a.map(c=>new L(c));return p(t,{code:f.invalid_union,unionErrors:s}),_}}get options(){return this._def.options}};ge.create=(r,e)=>new ge({options:r,typeName:y.ZodUnion,...b(e)});var X=r=>r instanceof be?X(r.schema):r instanceof Z?X(r.innerType()):r instanceof xe?[r.value]:r instanceof we?r.options:r instanceof Se?k.objectValues(r.enum):r instanceof ke?X(r._def.innerType):r instanceof ve?[void 0]:r instanceof ye?[null]:r instanceof U?[void 0,...X(r.unwrap())]:r instanceof G?[null,...X(r.unwrap())]:r instanceof Ge||r instanceof Ee?X(r.unwrap()):r instanceof Te?X(r._def.innerType):[],Et=class r extends x{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return p(t,{code:f.invalid_type,expected:h.object,received:t.parsedType}),_;let n=this.discriminator,o=t.data[n],i=this.optionsMap.get(o);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let o=new Map;for(let i of t){let a=X(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(o.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);o.set(s,i)}}return new r({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:o,...b(n)})}};function Jt(r,e){let t=re(r),n=re(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&n===h.object){let o=k.objectKeys(e),i=k.objectKeys(r).filter(s=>o.indexOf(s)!==-1),a={...r,...e};for(let s of i){let c=Jt(r[s],e[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(t===h.array&&n===h.array){if(r.length!==e.length)return{valid:!1};let o=[];for(let i=0;i{if(Ht(i)||Ht(a))return _;let s=Jt(i.value,a.value);return s.valid?((Gt(i)||Gt(a))&&t.dirty(),{status:t.value,value:s.data}):(p(n,{code:f.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};_e.create=(r,e,t)=>new _e({left:r,right:e,typeName:y.ZodIntersection,...b(t)});var H=class r extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return p(n,{code:f.invalid_type,expected:h.array,received:n.parsedType}),_;if(n.data.lengththis._def.items.length&&(p(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new W(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>P.mergeArray(t,a)):P.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};H.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:r,typeName:y.ZodTuple,rest:null,...b(e)})};var Ot=class r extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return p(n,{code:f.invalid_type,expected:h.object,received:n.parsedType}),_;let o=[],i=this._def.keyType,a=this._def.valueType;for(let s in n.data)o.push({key:i._parse(new W(n,s,n.path,s)),value:a._parse(new W(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?P.mergeObjectAsync(t,o):P.mergeObjectSync(t,o)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof x?new r({keyType:e,valueType:t,typeName:y.ZodRecord,...b(n)}):new r({keyType:ne.create(),valueType:e,typeName:y.ZodRecord,...b(t)})}},Me=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return p(n,{code:f.invalid_type,expected:h.map,received:n.parsedType}),_;let o=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([s,c],l)=>({key:o._parse(new W(n,s,n.path,[l,"key"])),value:i._parse(new W(n,c,n.path,[l,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return _;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let c of a){let l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return _;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}}}};Me.create=(r,e,t)=>new Me({valueType:e,keyType:r,typeName:y.ZodMap,...b(t)});var Le=class r extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return p(n,{code:f.invalid_type,expected:h.set,received:n.parsedType}),_;let o=this._def;o.minSize!==null&&n.data.sizeo.maxSize.value&&(p(n,{code:f.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),t.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let d of c){if(d.status==="aborted")return _;d.status==="dirty"&&t.dirty(),l.add(d.value)}return{status:t.value,value:l}}let s=[...n.data.values()].map((c,l)=>i._parse(new W(n,c,n.path,l)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(e,t){return new r({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Le.create=(r,e)=>new Le({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...b(e)});var Ct=class r extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return p(t,{code:f.invalid_type,expected:h.function,received:t.parsedType}),_;function n(s,c){return kt({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,St(),Pe].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:c}})}function o(s,c){return kt({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,St(),Pe].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ie){let s=this;return N(async function(...c){let l=new L([]),d=await s._def.args.parseAsync(c,i).catch(g=>{throw l.addIssue(n(c,g)),l}),v=await Reflect.apply(a,this,d);return await s._def.returns._def.type.parseAsync(v,i).catch(g=>{throw l.addIssue(o(v,g)),l})})}else{let s=this;return N(function(...c){let l=s._def.args.safeParse(c,i);if(!l.success)throw new L([n(c,l.error)]);let d=Reflect.apply(a,this,l.data),v=s._def.returns.safeParse(d,i);if(!v.success)throw new L([o(d,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:H.create(e).rest(Q.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||H.create([]).rest(Q.create()),returns:t||Q.create(),typeName:y.ZodFunction,...b(n)})}},be=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};be.create=(r,e)=>new be({getter:r,typeName:y.ZodLazy,...b(e)});var xe=class extends x{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}};xe.create=(r,e)=>new xe({value:r,typeName:y.ZodLiteral,...b(e)});function Br(r,e){return new we({values:r,typeName:y.ZodEnum,...b(e)})}var we=class r extends x{constructor(){super(...arguments),ze.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:k.joinValues(n),received:t.parsedType,code:f.invalid_type}),_}if(Tt(this,ze,"f")||Ur(this,ze,new Set(this._def.values),"f"),!Tt(this,ze,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:f.invalid_enum_value,options:n}),_}return N(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};ze=new WeakMap;we.create=Br;var Se=class extends x{constructor(){super(...arguments),qe.set(this,void 0)}_parse(e){let t=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){let o=k.objectValues(t);return p(n,{expected:k.joinValues(o),received:n.parsedType,code:f.invalid_type}),_}if(Tt(this,qe,"f")||Ur(this,qe,new Set(k.getValidEnumValues(this._def.values)),"f"),!Tt(this,qe,"f").has(e.data)){let o=k.objectValues(t);return p(n,{received:n.data,code:f.invalid_enum_value,options:o}),_}return N(e.data)}get enum(){return this._def.values}};qe=new WeakMap;Se.create=(r,e)=>new Se({values:r,typeName:y.ZodNativeEnum,...b(e)});var ie=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return p(t,{code:f.invalid_type,expected:h.promise,received:t.parsedType}),_;let n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return N(n.then(o=>this._def.type.parseAsync(o,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ie.create=(r,e)=>new ie({type:r,typeName:y.ZodPromise,...b(e)});var Z=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),o=this._def.effect||null,i={addIssue:a=>{p(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let a=o.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async s=>{if(t.value==="aborted")return _;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?_:c.status==="dirty"||t.value==="dirty"?Ae(c.value):c});{if(t.value==="aborted")return _;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"||t.value==="dirty"?Ae(s.value):s}}if(o.type==="refinement"){let a=s=>{let c=o.refinement(s,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:(s.status==="dirty"&&t.dirty(),a(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?_:(s.status==="dirty"&&t.dirty(),a(s.value).then(()=>({status:t.value,value:s.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ye(a))return a;let s=o.transform(a.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ye(a)?Promise.resolve(o.transform(a.value,i)).then(s=>({status:t.value,value:s})):a);k.assertNever(o)}};Z.create=(r,e,t)=>new Z({schema:r,typeName:y.ZodEffects,effect:e,...b(t)});Z.createWithPreprocess=(r,e,t)=>new Z({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...b(t)});var U=class extends x{_parse(e){return this._getType(e)===h.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(r,e)=>new U({innerType:r,typeName:y.ZodOptional,...b(e)});var G=class extends x{_parse(e){return this._getType(e)===h.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};G.create=(r,e)=>new G({innerType:r,typeName:y.ZodNullable,...b(e)});var ke=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ke.create=(r,e)=>new ke({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var Te=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return He(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Te.create=(r,e)=>new Te({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var Ze=class extends x{_parse(e){if(this._getType(e)!==h.nan){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}};Ze.create=r=>new Ze({typeName:y.ZodNaN,...b(r)});var to=Symbol("zod_brand"),Ge=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Je=class r extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?_:i.status==="dirty"?(t.dirty(),Ae(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"?(t.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:y.ZodPipeline})}},Ee=class extends x{_parse(e){let t=this._def.innerType._parse(e),n=o=>(Ye(o)&&(o.value=Object.freeze(o.value)),o);return He(t)?t.then(o=>n(o)):n(t)}unwrap(){return this._def.innerType}};Ee.create=(r,e)=>new Ee({innerType:r,typeName:y.ZodReadonly,...b(e)});function zr(r,e={},t){return r?oe.create().superRefine((n,o)=>{var i,a;if(!r(n)){let s=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=s.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,l=typeof s=="string"?{message:s}:s;o.addIssue({code:"custom",...l,fatal:c})}}):oe.create()}var ro={object:D.lazycreate},y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));var no=(r,e={message:`Input not instance of ${r.name}`})=>zr(t=>t instanceof r,e),qr=ne.create,Yr=fe.create,oo=Ze.create,io=pe.create,Hr=he.create,ao=me.create,so=Ne.create,co=ve.create,uo=ye.create,lo=oe.create,fo=Q.create,po=q.create,ho=De.create,mo=ee.create,vo=D.create,yo=D.strictCreate,go=ge.create,_o=Et.create,bo=_e.create,xo=H.create,wo=Ot.create,So=Me.create,ko=Le.create,To=Ct.create,Eo=be.create,Oo=xe.create,Co=we.create,jo=Se.create,Io=ie.create,Zr=Z.create,Ro=U.create,Ao=G.create,Po=Z.createWithPreprocess,No=Je.create,Do=()=>qr().optional(),Mo=()=>Yr().optional(),Lo=()=>Hr().optional(),Zo={string:r=>ne.create({...r,coerce:!0}),number:r=>fe.create({...r,coerce:!0}),boolean:r=>he.create({...r,coerce:!0}),bigint:r=>pe.create({...r,coerce:!0}),date:r=>me.create({...r,coerce:!0})},$o=_,u=Object.freeze({__proto__:null,defaultErrorMap:Pe,setErrorMap:Zn,getErrorMap:St,makeIssue:kt,EMPTY_PATH:$n,addIssueToContext:p,ParseStatus:P,INVALID:_,DIRTY:Ae,OK:N,isAborted:Ht,isDirty:Gt,isValid:Ye,isAsync:He,get util(){return k},get objectUtil(){return Yt},ZodParsedType:h,getParsedType:re,ZodType:x,datetimeRegex:Fr,ZodString:ne,ZodNumber:fe,ZodBigInt:pe,ZodBoolean:he,ZodDate:me,ZodSymbol:Ne,ZodUndefined:ve,ZodNull:ye,ZodAny:oe,ZodUnknown:Q,ZodNever:q,ZodVoid:De,ZodArray:ee,ZodObject:D,ZodUnion:ge,ZodDiscriminatedUnion:Et,ZodIntersection:_e,ZodTuple:H,ZodRecord:Ot,ZodMap:Me,ZodSet:Le,ZodFunction:Ct,ZodLazy:be,ZodLiteral:xe,ZodEnum:we,ZodNativeEnum:Se,ZodPromise:ie,ZodEffects:Z,ZodTransformer:Z,ZodOptional:U,ZodNullable:G,ZodDefault:ke,ZodCatch:Te,ZodNaN:Ze,BRAND:to,ZodBranded:Ge,ZodPipeline:Je,ZodReadonly:Ee,custom:zr,Schema:x,ZodSchema:x,late:ro,get ZodFirstPartyTypeKind(){return y},coerce:Zo,any:lo,array:mo,bigint:io,boolean:Hr,date:ao,discriminatedUnion:_o,effect:Zr,enum:Co,function:To,instanceof:no,intersection:bo,lazy:Eo,literal:Oo,map:So,nan:oo,nativeEnum:jo,never:po,null:uo,nullable:Ao,number:Yr,object:vo,oboolean:Lo,onumber:Mo,optional:Ro,ostring:Do,pipeline:No,preprocess:Po,promise:Io,record:wo,set:ko,strictObject:yo,string:qr,symbol:so,transformer:Zr,tuple:xo,undefined:co,union:go,unknown:fo,void:ho,NEVER:$o,ZodIssueCode:f,quotelessJson:Ln,ZodError:L});var Kr=(r=>(r.Info="info",r.Debug="debug",r.Trace="trace",r.Error="error",r))(Kr||{}),Xr=(r=>(r.External="BSLIVE_EXTERNAL",r))(Xr||{}),Qr=(r=>(r.Changed="Changed",r.Added="Added",r.Removed="Removed",r))(Qr||{}),Uo=u.union([u.object({kind:u.literal("Html"),payload:u.object({html:u.string()})}),u.object({kind:u.literal("Json"),payload:u.object({json_str:u.string()})}),u.object({kind:u.literal("Raw"),payload:u.object({raw:u.string()})}),u.object({kind:u.literal("Sse"),payload:u.object({sse:u.string()})}),u.object({kind:u.literal("Proxy"),payload:u.object({proxy:u.string()})}),u.object({kind:u.literal("Dir"),payload:u.object({dir:u.string(),base:u.string().optional()})})]),Wo=u.object({path:u.string(),kind:Uo}),Fu=u.object({routes:u.array(Wo),id:u.string()}),en=u.union([u.object({kind:u.literal("Both"),payload:u.object({name:u.string(),bind_address:u.string()})}),u.object({kind:u.literal("Address"),payload:u.object({bind_address:u.string()})}),u.object({kind:u.literal("Named"),payload:u.object({name:u.string()})})]),Vo=u.object({id:u.string(),identity:en,socket_addr:u.string()}),tn=u.object({servers:u.array(Vo)}),Fo=u.object({servers_resp:tn}),Bo=u.object({path:u.string()}),Gr=u.object({path:u.string()}),zo=u.object({paths:u.array(u.string())}),qo=u.object({kind:u.string(),ms:u.string()}),Yo=u.object({paths:u.array(u.string()),debounce:qo}),Ho=u.object({paths:u.array(u.string())}),Go=u.union([u.object({kind:u.literal("Stopped"),payload:u.object({bind_address:u.string()})}),u.object({kind:u.literal("Started"),payload:u.undefined().optional()}),u.object({kind:u.literal("Patched"),payload:u.undefined().optional()}),u.object({kind:u.literal("Errored"),payload:u.object({error:u.string()})})]),Jo=u.object({identity:en,change:Go}),Bu=u.object({items:u.array(Jo)}),Ko=u.nativeEnum(Kr),Jr=u.object({log_level:Ko}),zu=u.object({kind:u.literal("ServersChanged"),payload:tn}),qu=u.nativeEnum(Xr),Yu=u.union([u.object({kind:u.literal("ServersChanged"),payload:Fo}),u.object({kind:u.literal("Watching"),payload:Yo}),u.object({kind:u.literal("WatchingStopped"),payload:Ho}),u.object({kind:u.literal("FileChanged"),payload:Gr}),u.object({kind:u.literal("FilesChanged"),payload:zo}),u.object({kind:u.literal("InputFileChanged"),payload:Gr}),u.object({kind:u.literal("InputAccepted"),payload:Bo})]),Hu=u.union([u.object({kind:u.literal("Started"),payload:u.undefined().optional()}),u.object({kind:u.literal("FailedStartup"),payload:u.string()})]),Gu=u.union([u.object({kind:u.literal("MissingInputs"),payload:u.string()}),u.object({kind:u.literal("InvalidInput"),payload:u.string()}),u.object({kind:u.literal("NotFound"),payload:u.string()}),u.object({kind:u.literal("InputWriteError"),payload:u.string()}),u.object({kind:u.literal("PathError"),payload:u.string()}),u.object({kind:u.literal("PortError"),payload:u.string()}),u.object({kind:u.literal("DirError"),payload:u.string()}),u.object({kind:u.literal("YamlError"),payload:u.string()}),u.object({kind:u.literal("MarkdownError"),payload:u.string()}),u.object({kind:u.literal("Io"),payload:u.string()}),u.object({kind:u.literal("UnsupportedExtension"),payload:u.string()}),u.object({kind:u.literal("MissingExtension"),payload:u.string()}),u.object({kind:u.literal("EmptyInput"),payload:u.string()}),u.object({kind:u.literal("BsLiveRules"),payload:u.string()})]),Xo=u.nativeEnum(Qr),jt=u.lazy(()=>u.union([u.object({kind:u.literal("Fs"),payload:u.object({path:u.string(),change_kind:Xo})}),u.object({kind:u.literal("FsMany"),payload:u.array(jt)})])),Ju=u.union([u.object({kind:u.literal("Change"),payload:jt}),u.object({kind:u.literal("WsConnection"),payload:Jr}),u.object({kind:u.literal("Config"),payload:Jr})]);var rn=[{selector:"background",styleNames:["backgroundImage"]},{selector:"border",styleNames:["borderImage","webkitBorderImage","MozBorderImage"]}],It={stylesheetReloadTimeout:15e3},Qo=/\.(jpe?g|png|gif|svg)$/i,Rt=class{constructor(e,t,n){this.window=e,this.console=t,this.Timer=n,this.document=this.window.document,this.importCacheWaitPeriod=200,this.plugins=[]}addPlugin(e){return this.plugins.push(e)}analyze(e){}reload(e,t={}){if(this.options={...It,...t},!(t.liveCSS&&e.match(/\.css(?:\.map)?$/i)&&this.reloadStylesheet(e))){if(t.liveImg&&e.match(Qo)){this.reloadImages(e);return}if(t.isChromeExtension){this.reloadChromeExtension();return}return this.reloadPage()}}reloadPage(){return this.window.document.location.reload()}reloadChromeExtension(){return this.window.chrome.runtime.reload()}reloadImages(e){let t,n=this.generateUniqueString();for(t of Array.from(this.document.images))nn(e,Kt(t.src))&&(t.src=this.generateCacheBustUrl(t.src,n));if(this.document.querySelectorAll)for(let{selector:o,styleNames:i}of rn)for(t of Array.from(this.document.querySelectorAll(`[style*=${o}]`)))this.reloadStyleImages(t.style,i,e,n);if(this.document.styleSheets)return Array.from(this.document.styleSheets).map(o=>this.reloadStylesheetImages(o,e,n))}reloadStylesheetImages(e,t,n){let o;try{o=(e||{}).cssRules}catch{}if(o)for(let i of Array.from(o))switch(i.type){case CSSRule.IMPORT_RULE:this.reloadStylesheetImages(i.styleSheet,t,n);break;case CSSRule.STYLE_RULE:for(let{styleNames:a}of rn)this.reloadStyleImages(i.style,a,t,n);break;case CSSRule.MEDIA_RULE:this.reloadStylesheetImages(i,t,n);break}}reloadStyleImages(e,t,n,o){for(let i of t){let a=e[i];if(typeof a=="string"){let s=a.replace(new RegExp("\\burl\\s*\\(([^)]*)\\)"),(c,l)=>nn(n,Kt(l))?`url(${this.generateCacheBustUrl(l,o)})`:c);s!==a&&(e[i]=s)}}}reloadStylesheet(e){let t=this.options||It,n,o,i=(()=>{let c=[];for(o of Array.from(this.document.getElementsByTagName("link")))o.rel.match(/^stylesheet$/i)&&!o.__LiveReload_pendingRemoval&&c.push(o);return c})(),a=[];for(n of Array.from(this.document.getElementsByTagName("style")))n.sheet&&this.collectImportedStylesheets(n,n.sheet,a);for(o of Array.from(i))this.collectImportedStylesheets(o,o.sheet,a);if(this.window.StyleFix&&this.document.querySelectorAll)for(n of Array.from(this.document.querySelectorAll("style[data-href]")))i.push(n);this.console.debug(`found ${i.length} LINKed stylesheets, ${a.length} @imported stylesheets`);let s=ei(e,i.concat(a),c=>Kt(this.linkHref(c)));if(s)s.object.rule?(this.console.debug(`is reloading imported stylesheet: ${s.object.href}`),this.reattachImportedRule(s.object)):(this.console.debug(`is reloading stylesheet: ${this.linkHref(s.object)}`),this.reattachStylesheetLink(s.object));else if(t.reloadMissingCSS){this.console.debug(`will reload all stylesheets because path '${e}' did not match any specific one. To disable this behavior, set 'options.reloadMissingCSS' to 'false'.`);for(o of Array.from(i))this.reattachStylesheetLink(o)}else this.console.debug(`will not reload path '${e}' because the stylesheet was not found on the page and 'options.reloadMissingCSS' was set to 'false'.`);return!0}collectImportedStylesheets(e,t,n){let o;try{o=(t||{}).cssRules}catch{}if(o&&o.length)for(let i=0;i{if(!o)return o=!0,t()};if(e.onload=()=>(this.console.debug("the new stylesheet has finished loading"),this.knownToSupportCssOnLoad=!0,i()),!this.knownToSupportCssOnLoad){let a;(a=()=>e.sheet?(this.console.debug("is polling until the new CSS finishes loading..."),i()):this.Timer.start(50,a))()}return this.Timer.start(n.stylesheetReloadTimeout,i)}linkHref(e){return e.href||e.getAttribute&&e.getAttribute("data-href")}reattachStylesheetLink(e){let t;if(e.__LiveReload_pendingRemoval)return;e.__LiveReload_pendingRemoval=!0,e.tagName==="STYLE"?(t=this.document.createElement("link"),t.rel="stylesheet",t.media=e.media,t.disabled=e.disabled):t=e.cloneNode(!1),t.href=this.generateCacheBustUrl(this.linkHref(e));let n=e.parentNode;return n.lastChild===e?n.appendChild(t):n.insertBefore(t,e.nextSibling),this.waitUntilCssLoads(t,()=>{let o;return/AppleWebKit/.test(this.window.navigator.userAgent)?o=5:o=200,this.Timer.start(o,()=>{if(e.parentNode)return e.parentNode.removeChild(e),t.onreadystatechange=null,this.window.StyleFix?this.window.StyleFix.link(t):void 0})})}reattachImportedRule({rule:e,index:t,link:n}){let o=e.parentStyleSheet,i=this.generateCacheBustUrl(e.href),a=e.media.length?[].join.call(e.media,", "):"",s=`@import url("${i}") ${a};`;e.__LiveReload_newHref=i;let c=this.document.createElement("link");return c.rel="stylesheet",c.href=i,c.__LiveReload_pendingRemoval=!0,n.parentNode&&n.parentNode.insertBefore(c,n),this.Timer.start(this.importCacheWaitPeriod,()=>{if(c.parentNode&&c.parentNode.removeChild(c),e.__LiveReload_newHref===i)return o.insertRule(s,t),o.deleteRule(t+1),e=o.cssRules[t],e.__LiveReload_newHref=i,this.Timer.start(this.importCacheWaitPeriod,()=>{if(e.__LiveReload_newHref===i)return o.insertRule(s,t),o.deleteRule(t+1)})})}generateUniqueString(){return`livereload=${Date.now()}`}generateCacheBustUrl(e,t){let n=this.options||It,o,i;if(t||(t=this.generateUniqueString()),{url:e,hash:o,params:i}=on(e),n.overrideURL&&e.indexOf(n.serverURL)<0){let s=e;e=n.serverURL+n.overrideURL+"?url="+encodeURIComponent(e),this.console.debug(`is overriding source URL ${s} with ${e}`)}let a=i.replace(/(\?|&)livereload=(\d+)/,(s,c)=>`${c}${t}`);return a===i&&(i.length===0?a=`?${t}`:a=`${i}&${t}`),e+a+o}};function on(r){let e="",t="",n=r.indexOf("#");n>=0&&(e=r.slice(n),r=r.slice(0,n));let o=r.indexOf("??");return o>=0?o+1!==r.lastIndexOf("?")&&(n=r.lastIndexOf("?")):n=r.indexOf("?"),n>=0&&(t=r.slice(n),r=r.slice(0,n)),{url:r,params:t,hash:e}}function Kt(r){if(!r)return"";let e;return{url:r}=on(r),r.indexOf("file://")===0?e=r.replace(new RegExp("^file://(localhost)?"),""):e=r.replace(new RegExp("^([^:]+:)?//([^:/]+)(:\\d*)?/"),"/"),decodeURIComponent(e)}function an(r,e){if(r=r.replace(/^\/+/,"").toLowerCase(),e=e.replace(/^\/+/,"").toLowerCase(),r===e)return 1e4;let t=r.split(/\/|\\/).reverse(),n=e.split(/\/|\\/).reverse(),o=Math.min(t.length,n.length),i=0;for(;in){let n,o={score:0};for(let i of e)n=an(r,t(i)),n>o.score&&(o={object:i,score:n});return o.score===0?null:o}function nn(r,e){return an(r,e)>0}var un=gn(cn());var ti=/\.(jpe?g|png|gif|svg)$/i;function Xt(r,e,t){switch(r.kind){case"FsMany":{if(r.payload.some(o=>{switch(o.kind){case"Fs":return!(o.payload.path.match(/\.css(?:\.map)?$/i)||o.payload.path.match(ti));case"FsMany":throw new Error("unreachable")}}))return window.__playwright?.record?window.__playwright?.record({kind:"reloadPage"}):t.reloadPage();for(let o of r.payload)Xt(o,e,t);break}case"Fs":{let n=r.payload.path,o={liveCSS:!0,liveImg:!0,reloadMissingCSS:!0,originalPath:"",overrideURL:"",serverURL:""};window.__playwright?.record?window.__playwright?.record({kind:"reload",args:{path:n,opts:o}}):(e.trace("will reload a file with path ",n),t.reload(n,o))}}}var Qt={name:"dom plugin",globalSetup:(r,e)=>{let t=new Rt(window,e,un.Timer);return[r,[e,t]]},resetSink(r,e,t){let[n,o]=e;return r.pipe(de(i=>i.kind==="Change"),K(i=>i.payload),Be(i=>{n.trace("incoming message",JSON.stringify({change:i,config:t},null,2));let a=jt.parse(i);Xt(a,n,o)}),Fe())}};var ri=Dr(),Ke=ri.create(),[ni,er]=zt.globalSetup(Ke,Mr),[oi,ii]=Qt.globalSetup(Ke,er),ln=Ke.pipe(de(r=>r.kind==="WsConnection"),K(r=>r.payload),Vt()),ai=Ke.pipe(de(r=>r.kind==="Config"),K(r=>r.payload)),fl=Ke.pipe(de(r=>r.kind==="Change"),K(r=>r.payload));wt(ai,ln).pipe(Ft(r=>{let e=[Qt.resetSink(oi,ii,r),zt.resetSink(ni,er,r)];return wt(...e)})).subscribe();ln.subscribe(r=>{er.info("\u{1F7E2} Browsersync Live connected",{config:r})}); + `):"",this.name="UnsubscriptionError",this.errors=t}});function se(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var H=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var s=J(a),c=s.next();!c.done;c=s.next()){var l=c.value;l.remove(this)}}catch(w){e={error:w}}finally{try{c&&!c.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else a.remove(this);var d=this.initialTeardown;if(S(d))try{d()}catch(w){i=w instanceof nt?w.errors:[w]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var T=J(v),g=T.next();!g.done;g=T.next()){var E=g.value;try{ar(E)}catch(w){i=i??[],w instanceof nt?i=F(F([],V(i)),V(w.errors)):i.push(w)}}}catch(w){n={error:w}}finally{try{g&&!g.done&&(o=T.return)&&o.call(T)}finally{if(n)throw n.error}}}if(i)throw new nt(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)ar(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&se(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&se(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();var Nt=H.EMPTY;function ot(r){return r instanceof H||r&&"closed"in r&&S(r.remove)&&S(r.add)&&S(r.unsubscribe)}function ar(r){S(r)?r():r.unsubscribe()}var B={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Ce={setTimeout:function(r,e){for(var t=[],n=2;n0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,o=this,i=o.hasError,a=o.isStopped,s=o.observers;return i||a?Nt:(this.currentObservers=null,s.push(t),new H(function(){n.currentObservers=null,se(s,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?t.error(i):a&&t.complete()},e.prototype.asObservable=function(){var t=new O;return t.source=this,t},e.create=function(t,n){return new st(t,n)},e}(O);var st=function(r){R(e,r);function e(t,n){var o=r.call(this)||this;return o.destination=t,o.source=n,o}return e.prototype.next=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,t)},e.prototype.error=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&o!==void 0?o:Nt},e}(z);var We={now:function(){return(We.delegate||Date).now()},delegate:void 0};var ct=function(r){R(e,r);function e(t,n,o){t===void 0&&(t=1/0),n===void 0&&(n=1/0),o===void 0&&(o=We);var i=r.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return e.prototype.next=function(t){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,s=n._timestampProvider,c=n._windowTime;o||(i.push(t),!a&&i.push(s.now()+c)),this._trimBuffer(),r.prototype.next.call(this,t)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),o=this,i=o._infiniteTimeWindow,a=o._buffer,s=a.slice(),c=0;c0&&(d=new le({next:function(Qe){return Xe.next(Qe)},error:function(Qe){w=!0,A(),v=Wt(M,o,Qe),Xe.error(Qe)},complete:function(){E=!0,A(),v=Wt(M,a),Xe.complete()}}),I($e).subscribe(d))})(l)}}function Wt(r,e){for(var t=[],n=2;n{let r=new URL(window.location.href);return r.protocol=r.protocol==="http:"?"ws":"wss",r.pathname="/__bs_ws",Bt(r.origin+r.pathname).pipe(Ut({delay:5e3}))}}}var Mr={debug(...r){},error(...r){},info(...r){},trace(...r){}},zt={name:"console",globalSetup:r=>{let e=new z;return[e,{debug:function(...n){e.next({level:"debug",args:n})},info:function(...n){e.next({level:"info",args:n})},trace:function(...n){e.next({level:"trace",args:n})},error:function(...n){e.next({level:"error",args:n})}}]},resetSink:(r,e,t)=>r.pipe(Be(n=>{let o=["trace","debug","info","error"],i=o.indexOf(n.level),a=o.indexOf(t.log_level);i>=a&&console.log(`[${n.level}]`,...n.args)}),Fe())};var k;(function(r){r.assertEqual=o=>o;function e(o){}r.assertIs=e;function t(o){throw new Error}r.assertNever=t,r.arrayToEnum=o=>{let i={};for(let a of o)i[a]=a;return i},r.getValidEnumValues=o=>{let i=r.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),a={};for(let s of i)a[s]=o[s];return r.objectValues(a)},r.objectValues=o=>r.objectKeys(o).map(function(i){return o[i]}),r.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},r.find=(o,i)=>{for(let a of o)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(k||(k={}));var Ht;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ht||(Ht={}));var h=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),re=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}},f=k.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ln=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),L=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(i){return i.message},n={_errors:[]},o=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let s=n,c=0;for(;ct.message){let t={},n=[];for(let o of this.issues)o.path.length>0?(t[o.path[0]]=t[o.path[0]]||[],t[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};L.create=r=>new L(r);var Pe=(r,e)=>{let t;switch(r.code){case f.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case f.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case f.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(r)}return{message:t}},$r=Pe;function Zn(r){$r=r}function St(){return $r}var kt=r=>{let{data:e,path:t,errorMaps:n,issueData:o}=r,i=[...t,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let s="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)s=l(a,{data:e,defaultError:s}).message;return{...o,path:i,message:s}},$n=[];function p(r,e){let t=St(),n=kt({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Pe?void 0:Pe].filter(o=>!!o)});r.common.issues.push(n)}var P=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let o of t){if(o.status==="aborted")return _;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let o of t){let i=await o.key,a=await o.value;n.push({key:i,value:a})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let o of t){let{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return _;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},_=Object.freeze({status:"aborted"}),Ae=r=>({status:"dirty",value:r}),N=r=>({status:"valid",value:r}),Yt=r=>r.status==="aborted",Gt=r=>r.status==="dirty",He=r=>r.status==="valid",Ye=r=>typeof Promise<"u"&&r instanceof Promise;function Tt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Ur(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t}var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));var ze,qe,W=class{constructor(e,t,n,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=o}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Lr=(r,e)=>{if(He(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new L(r.common.issues);return this._error=t,this._error}}};function b(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:o}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(a,s)=>{var c,l;let{message:d}=r;return a.code==="invalid_enum_value"?{message:d??s.defaultError}:typeof s.data>"u"?{message:(c=d??n)!==null&&c!==void 0?c:s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:(l=d??t)!==null&&l!==void 0?l:s.defaultError}},description:o}}var x=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return re(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ye(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let o={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)},i=this._parseSync({data:e,path:o.path,parent:o});return Lr(o,i)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)},o=this._parse({data:e,path:n.path,parent:n}),i=await(Ye(o)?o:Promise.resolve(o));return Lr(n,i)}refine(e,t){let n=o=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(o):t;return this._refinement((o,i)=>{let a=e(o),s=()=>i.addIssue({code:f.custom,...n(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,t){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof t=="function"?t(n,o):t),!1))}_refinement(e){return new Z({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return U.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ee.create(this,this._def)}promise(){return ie.create(this,this._def)}or(e){return ge.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new Z({...b(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ke({...b(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Ge({typeName:y.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Te({...b(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Je.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Un=/^c[^\s-]{8,}$/i,Wn=/^[0-9a-z]+$/,Vn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Fn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Bn=/^[a-z0-9_-]{21}$/i,zn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,qn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",qt,Yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Gn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Jn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Kn=new RegExp(`^${Wr}$`);function Vr(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Xn(r){return new RegExp(`^${Vr(r)}$`)}function Fr(r){let e=`${Wr}T${Vr(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Qn(r,e){return!!((e==="v4"||!e)&&Yn.test(r)||(e==="v6"||!e)&&Gn.test(r))}var ne=class r extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.string,received:i.parsedType}),_}let n=new P,o;for(let i of this._def.checks)if(i.kind==="min")e.data.lengthi.value&&(o=this._getOrReturnCtx(e,o),p(o,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,s=e.data.lengthe.test(o),{validation:t,code:f.invalid_string,...m.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new ne({checks:[],typeName:y.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};function eo(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=t>n?t:n,i=parseInt(r.toFixed(o).replace(".","")),a=parseInt(e.toFixed(o).replace(".",""));return i%a/Math.pow(10,o)}var fe=class r extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.number,received:i.parsedType}),_}let n,o=new P;for(let i of this._def.checks)i.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?eo(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:f.not_finite,message:i.message}),o.dirty()):k.assertNever(i);return{status:o.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,o){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(o)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.valuenew fe({checks:[],typeName:y.ZodNumber,coerce:r?.coerce||!1,...b(r)});var pe=class r extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==h.bigint){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.bigint,received:i.parsedType}),_}let n,o=new P;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):k.assertNever(i);return{status:o.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,o){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(o)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value{var e;return new pe({checks:[],typeName:y.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};var he=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.boolean,received:n.parsedType}),_}return N(e.data)}};he.create=r=>new he({typeName:y.ZodBoolean,coerce:r?.coerce||!1,...b(r)});var me=class r extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_type,expected:h.date,received:i.parsedType}),_}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return p(i,{code:f.invalid_date}),_}let n=new P,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()i.value&&(o=this._getOrReturnCtx(e,o),p(o,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):k.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew me({checks:[],coerce:r?.coerce||!1,typeName:y.ZodDate,...b(r)});var Ne=class extends x{_parse(e){if(this._getType(e)!==h.symbol){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.symbol,received:n.parsedType}),_}return N(e.data)}};Ne.create=r=>new Ne({typeName:y.ZodSymbol,...b(r)});var ve=class extends x{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.undefined,received:n.parsedType}),_}return N(e.data)}};ve.create=r=>new ve({typeName:y.ZodUndefined,...b(r)});var ye=class extends x{_parse(e){if(this._getType(e)!==h.null){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.null,received:n.parsedType}),_}return N(e.data)}};ye.create=r=>new ye({typeName:y.ZodNull,...b(r)});var oe=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}};oe.create=r=>new oe({typeName:y.ZodAny,...b(r)});var Q=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}};Q.create=r=>new Q({typeName:y.ZodUnknown,...b(r)});var q=class extends x{_parse(e){let t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:h.never,received:t.parsedType}),_}};q.create=r=>new q({typeName:y.ZodNever,...b(r)});var De=class extends x{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.void,received:n.parsedType}),_}return N(e.data)}};De.create=r=>new De({typeName:y.ZodVoid,...b(r)});var ee=class r extends x{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),o=this._def;if(t.parsedType!==h.array)return p(t,{code:f.invalid_type,expected:h.array,received:t.parsedType}),_;if(o.exactLength!==null){let a=t.data.length>o.exactLength.value,s=t.data.lengtho.maxLength.value&&(p(t,{code:f.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,s)=>o.type._parseAsync(new W(t,a,t.path,s)))).then(a=>P.mergeArray(n,a));let i=[...t.data].map((a,s)=>o.type._parseSync(new W(t,a,t.path,s)));return P.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}};ee.create=(r,e)=>new ee({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...b(e)});function Re(r){if(r instanceof D){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=U.create(Re(n))}return new D({...r._def,shape:()=>e})}else return r instanceof ee?new ee({...r._def,type:Re(r.element)}):r instanceof U?U.create(Re(r.unwrap())):r instanceof G?G.create(Re(r.unwrap())):r instanceof Y?Y.create(r.items.map(e=>Re(e))):r}var D=class r extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.object){let l=this._getOrReturnCtx(e);return p(l,{code:f.invalid_type,expected:h.object,received:l.parsedType}),_}let{status:n,ctx:o}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof q&&this._def.unknownKeys==="strip"))for(let l in o.data)a.includes(l)||s.push(l);let c=[];for(let l of a){let d=i[l],v=o.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new W(o,v,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof q){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of s)c.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")s.length>0&&(p(o,{code:f.unrecognized_keys,keys:s}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let d of s){let v=o.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new W(o,v,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of c){let v=await d.key,T=await d.value;l.push({key:v,value:T,alwaysSet:d.alwaysSet})}return l}).then(l=>P.mergeObjectSync(n,l)):P.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var o,i,a,s;let c=(a=(i=(o=this._def).errorMap)===null||i===void 0?void 0:i.call(o,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(s=m.errToObj(e).message)!==null&&s!==void 0?s:c}:{message:c}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return k.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return k.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return Re(this)}partial(e){let t={};return k.objectKeys(this.shape).forEach(n=>{let o=this.shape[n];e&&!e[n]?t[n]=o:t[n]=o.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return k.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof U;)i=i._def.innerType;t[n]=i}}),new r({...this._def,shape:()=>t})}keyof(){return Br(k.objectKeys(this.shape))}};D.create=(r,e)=>new D({shape:()=>r,unknownKeys:"strip",catchall:q.create(),typeName:y.ZodObject,...b(e)});D.strictCreate=(r,e)=>new D({shape:()=>r,unknownKeys:"strict",catchall:q.create(),typeName:y.ZodObject,...b(e)});D.lazycreate=(r,e)=>new D({shape:r,unknownKeys:"strip",catchall:q.create(),typeName:y.ZodObject,...b(e)});var ge=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function o(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(s=>new L(s.ctx.common.issues));return p(t,{code:f.invalid_union,unionErrors:a}),_}if(t.common.async)return Promise.all(n.map(async i=>{let a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(o);{let i,a=[];for(let c of n){let l={...t,common:{...t.common,issues:[]},parent:null},d=c._parseSync({data:t.data,path:t.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let s=a.map(c=>new L(c));return p(t,{code:f.invalid_union,unionErrors:s}),_}}get options(){return this._def.options}};ge.create=(r,e)=>new ge({options:r,typeName:y.ZodUnion,...b(e)});var X=r=>r instanceof be?X(r.schema):r instanceof Z?X(r.innerType()):r instanceof xe?[r.value]:r instanceof we?r.options:r instanceof Se?k.objectValues(r.enum):r instanceof ke?X(r._def.innerType):r instanceof ve?[void 0]:r instanceof ye?[null]:r instanceof U?[void 0,...X(r.unwrap())]:r instanceof G?[null,...X(r.unwrap())]:r instanceof Ge||r instanceof Ee?X(r.unwrap()):r instanceof Te?X(r._def.innerType):[],Et=class r extends x{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return p(t,{code:f.invalid_type,expected:h.object,received:t.parsedType}),_;let n=this.discriminator,o=t.data[n],i=this.optionsMap.get(o);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let o=new Map;for(let i of t){let a=X(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(o.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);o.set(s,i)}}return new r({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:o,...b(n)})}};function Jt(r,e){let t=re(r),n=re(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&n===h.object){let o=k.objectKeys(e),i=k.objectKeys(r).filter(s=>o.indexOf(s)!==-1),a={...r,...e};for(let s of i){let c=Jt(r[s],e[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(t===h.array&&n===h.array){if(r.length!==e.length)return{valid:!1};let o=[];for(let i=0;i{if(Yt(i)||Yt(a))return _;let s=Jt(i.value,a.value);return s.valid?((Gt(i)||Gt(a))&&t.dirty(),{status:t.value,value:s.data}):(p(n,{code:f.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};_e.create=(r,e,t)=>new _e({left:r,right:e,typeName:y.ZodIntersection,...b(t)});var Y=class r extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return p(n,{code:f.invalid_type,expected:h.array,received:n.parsedType}),_;if(n.data.lengththis._def.items.length&&(p(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new W(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>P.mergeArray(t,a)):P.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};Y.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Y({items:r,typeName:y.ZodTuple,rest:null,...b(e)})};var Ot=class r extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return p(n,{code:f.invalid_type,expected:h.object,received:n.parsedType}),_;let o=[],i=this._def.keyType,a=this._def.valueType;for(let s in n.data)o.push({key:i._parse(new W(n,s,n.path,s)),value:a._parse(new W(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?P.mergeObjectAsync(t,o):P.mergeObjectSync(t,o)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof x?new r({keyType:e,valueType:t,typeName:y.ZodRecord,...b(n)}):new r({keyType:ne.create(),valueType:e,typeName:y.ZodRecord,...b(t)})}},Me=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return p(n,{code:f.invalid_type,expected:h.map,received:n.parsedType}),_;let o=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([s,c],l)=>({key:o._parse(new W(n,s,n.path,[l,"key"])),value:i._parse(new W(n,c,n.path,[l,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return _;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let c of a){let l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return _;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}}}};Me.create=(r,e,t)=>new Me({valueType:e,keyType:r,typeName:y.ZodMap,...b(t)});var Le=class r extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return p(n,{code:f.invalid_type,expected:h.set,received:n.parsedType}),_;let o=this._def;o.minSize!==null&&n.data.sizeo.maxSize.value&&(p(n,{code:f.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),t.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let d of c){if(d.status==="aborted")return _;d.status==="dirty"&&t.dirty(),l.add(d.value)}return{status:t.value,value:l}}let s=[...n.data.values()].map((c,l)=>i._parse(new W(n,c,n.path,l)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(e,t){return new r({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Le.create=(r,e)=>new Le({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...b(e)});var Ct=class r extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return p(t,{code:f.invalid_type,expected:h.function,received:t.parsedType}),_;function n(s,c){return kt({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,St(),Pe].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:c}})}function o(s,c){return kt({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,St(),Pe].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ie){let s=this;return N(async function(...c){let l=new L([]),d=await s._def.args.parseAsync(c,i).catch(g=>{throw l.addIssue(n(c,g)),l}),v=await Reflect.apply(a,this,d);return await s._def.returns._def.type.parseAsync(v,i).catch(g=>{throw l.addIssue(o(v,g)),l})})}else{let s=this;return N(function(...c){let l=s._def.args.safeParse(c,i);if(!l.success)throw new L([n(c,l.error)]);let d=Reflect.apply(a,this,l.data),v=s._def.returns.safeParse(d,i);if(!v.success)throw new L([o(d,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:Y.create(e).rest(Q.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||Y.create([]).rest(Q.create()),returns:t||Q.create(),typeName:y.ZodFunction,...b(n)})}},be=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};be.create=(r,e)=>new be({getter:r,typeName:y.ZodLazy,...b(e)});var xe=class extends x{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}};xe.create=(r,e)=>new xe({value:r,typeName:y.ZodLiteral,...b(e)});function Br(r,e){return new we({values:r,typeName:y.ZodEnum,...b(e)})}var we=class r extends x{constructor(){super(...arguments),ze.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:k.joinValues(n),received:t.parsedType,code:f.invalid_type}),_}if(Tt(this,ze,"f")||Ur(this,ze,new Set(this._def.values),"f"),!Tt(this,ze,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:f.invalid_enum_value,options:n}),_}return N(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};ze=new WeakMap;we.create=Br;var Se=class extends x{constructor(){super(...arguments),qe.set(this,void 0)}_parse(e){let t=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){let o=k.objectValues(t);return p(n,{expected:k.joinValues(o),received:n.parsedType,code:f.invalid_type}),_}if(Tt(this,qe,"f")||Ur(this,qe,new Set(k.getValidEnumValues(this._def.values)),"f"),!Tt(this,qe,"f").has(e.data)){let o=k.objectValues(t);return p(n,{received:n.data,code:f.invalid_enum_value,options:o}),_}return N(e.data)}get enum(){return this._def.values}};qe=new WeakMap;Se.create=(r,e)=>new Se({values:r,typeName:y.ZodNativeEnum,...b(e)});var ie=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return p(t,{code:f.invalid_type,expected:h.promise,received:t.parsedType}),_;let n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return N(n.then(o=>this._def.type.parseAsync(o,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ie.create=(r,e)=>new ie({type:r,typeName:y.ZodPromise,...b(e)});var Z=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),o=this._def.effect||null,i={addIssue:a=>{p(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let a=o.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async s=>{if(t.value==="aborted")return _;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?_:c.status==="dirty"||t.value==="dirty"?Ae(c.value):c});{if(t.value==="aborted")return _;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"||t.value==="dirty"?Ae(s.value):s}}if(o.type==="refinement"){let a=s=>{let c=o.refinement(s,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:(s.status==="dirty"&&t.dirty(),a(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?_:(s.status==="dirty"&&t.dirty(),a(s.value).then(()=>({status:t.value,value:s.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!He(a))return a;let s=o.transform(a.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>He(a)?Promise.resolve(o.transform(a.value,i)).then(s=>({status:t.value,value:s})):a);k.assertNever(o)}};Z.create=(r,e,t)=>new Z({schema:r,typeName:y.ZodEffects,effect:e,...b(t)});Z.createWithPreprocess=(r,e,t)=>new Z({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...b(t)});var U=class extends x{_parse(e){return this._getType(e)===h.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(r,e)=>new U({innerType:r,typeName:y.ZodOptional,...b(e)});var G=class extends x{_parse(e){return this._getType(e)===h.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};G.create=(r,e)=>new G({innerType:r,typeName:y.ZodNullable,...b(e)});var ke=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ke.create=(r,e)=>new ke({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var Te=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ye(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Te.create=(r,e)=>new Te({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var Ze=class extends x{_parse(e){if(this._getType(e)!==h.nan){let n=this._getOrReturnCtx(e);return p(n,{code:f.invalid_type,expected:h.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}};Ze.create=r=>new Ze({typeName:y.ZodNaN,...b(r)});var to=Symbol("zod_brand"),Ge=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Je=class r extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?_:i.status==="dirty"?(t.dirty(),Ae(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"?(t.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:y.ZodPipeline})}},Ee=class extends x{_parse(e){let t=this._def.innerType._parse(e),n=o=>(He(o)&&(o.value=Object.freeze(o.value)),o);return Ye(t)?t.then(o=>n(o)):n(t)}unwrap(){return this._def.innerType}};Ee.create=(r,e)=>new Ee({innerType:r,typeName:y.ZodReadonly,...b(e)});function zr(r,e={},t){return r?oe.create().superRefine((n,o)=>{var i,a;if(!r(n)){let s=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=s.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,l=typeof s=="string"?{message:s}:s;o.addIssue({code:"custom",...l,fatal:c})}}):oe.create()}var ro={object:D.lazycreate},y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));var no=(r,e={message:`Input not instance of ${r.name}`})=>zr(t=>t instanceof r,e),qr=ne.create,Hr=fe.create,oo=Ze.create,io=pe.create,Yr=he.create,ao=me.create,so=Ne.create,co=ve.create,uo=ye.create,lo=oe.create,fo=Q.create,po=q.create,ho=De.create,mo=ee.create,vo=D.create,yo=D.strictCreate,go=ge.create,_o=Et.create,bo=_e.create,xo=Y.create,wo=Ot.create,So=Me.create,ko=Le.create,To=Ct.create,Eo=be.create,Oo=xe.create,Co=we.create,jo=Se.create,Io=ie.create,Zr=Z.create,Ro=U.create,Ao=G.create,Po=Z.createWithPreprocess,No=Je.create,Do=()=>qr().optional(),Mo=()=>Hr().optional(),Lo=()=>Yr().optional(),Zo={string:r=>ne.create({...r,coerce:!0}),number:r=>fe.create({...r,coerce:!0}),boolean:r=>he.create({...r,coerce:!0}),bigint:r=>pe.create({...r,coerce:!0}),date:r=>me.create({...r,coerce:!0})},$o=_,u=Object.freeze({__proto__:null,defaultErrorMap:Pe,setErrorMap:Zn,getErrorMap:St,makeIssue:kt,EMPTY_PATH:$n,addIssueToContext:p,ParseStatus:P,INVALID:_,DIRTY:Ae,OK:N,isAborted:Yt,isDirty:Gt,isValid:He,isAsync:Ye,get util(){return k},get objectUtil(){return Ht},ZodParsedType:h,getParsedType:re,ZodType:x,datetimeRegex:Fr,ZodString:ne,ZodNumber:fe,ZodBigInt:pe,ZodBoolean:he,ZodDate:me,ZodSymbol:Ne,ZodUndefined:ve,ZodNull:ye,ZodAny:oe,ZodUnknown:Q,ZodNever:q,ZodVoid:De,ZodArray:ee,ZodObject:D,ZodUnion:ge,ZodDiscriminatedUnion:Et,ZodIntersection:_e,ZodTuple:Y,ZodRecord:Ot,ZodMap:Me,ZodSet:Le,ZodFunction:Ct,ZodLazy:be,ZodLiteral:xe,ZodEnum:we,ZodNativeEnum:Se,ZodPromise:ie,ZodEffects:Z,ZodTransformer:Z,ZodOptional:U,ZodNullable:G,ZodDefault:ke,ZodCatch:Te,ZodNaN:Ze,BRAND:to,ZodBranded:Ge,ZodPipeline:Je,ZodReadonly:Ee,custom:zr,Schema:x,ZodSchema:x,late:ro,get ZodFirstPartyTypeKind(){return y},coerce:Zo,any:lo,array:mo,bigint:io,boolean:Yr,date:ao,discriminatedUnion:_o,effect:Zr,enum:Co,function:To,instanceof:no,intersection:bo,lazy:Eo,literal:Oo,map:So,nan:oo,nativeEnum:jo,never:po,null:uo,nullable:Ao,number:Hr,object:vo,oboolean:Lo,onumber:Mo,optional:Ro,ostring:Do,pipeline:No,preprocess:Po,promise:Io,record:wo,set:ko,strictObject:yo,string:qr,symbol:so,transformer:Zr,tuple:xo,undefined:co,union:go,unknown:fo,void:ho,NEVER:$o,ZodIssueCode:f,quotelessJson:Ln,ZodError:L});var Kr=(r=>(r.Info="info",r.Debug="debug",r.Trace="trace",r.Error="error",r))(Kr||{}),Xr=(r=>(r.External="BSLIVE_EXTERNAL",r))(Xr||{}),Qr=(r=>(r.Changed="Changed",r.Added="Added",r.Removed="Removed",r))(Qr||{}),Uo=u.union([u.object({kind:u.literal("Html"),payload:u.object({html:u.string()})}),u.object({kind:u.literal("Json"),payload:u.object({json_str:u.string()})}),u.object({kind:u.literal("Raw"),payload:u.object({raw:u.string()})}),u.object({kind:u.literal("Sse"),payload:u.object({sse:u.string()})}),u.object({kind:u.literal("Proxy"),payload:u.object({proxy:u.string()})}),u.object({kind:u.literal("Dir"),payload:u.object({dir:u.string(),base:u.string().optional()})})]),Wo=u.object({path:u.string(),kind:Uo}),Fu=u.object({routes:u.array(Wo),id:u.string()}),en=u.union([u.object({kind:u.literal("Both"),payload:u.object({name:u.string(),bind_address:u.string()})}),u.object({kind:u.literal("Address"),payload:u.object({bind_address:u.string()})}),u.object({kind:u.literal("Named"),payload:u.object({name:u.string()})})]),Vo=u.object({id:u.string(),identity:en,socket_addr:u.string()}),tn=u.object({servers:u.array(Vo)}),Fo=u.object({servers_resp:tn}),Bo=u.object({path:u.string()}),Gr=u.object({path:u.string()}),zo=u.object({paths:u.array(u.string())}),qo=u.object({kind:u.string(),ms:u.string()}),Ho=u.object({paths:u.array(u.string()),debounce:qo}),Yo=u.object({paths:u.array(u.string())}),Go=u.union([u.object({kind:u.literal("Stopped"),payload:u.object({bind_address:u.string()})}),u.object({kind:u.literal("Started"),payload:u.undefined().optional()}),u.object({kind:u.literal("Patched"),payload:u.undefined().optional()}),u.object({kind:u.literal("Errored"),payload:u.object({error:u.string()})})]),Jo=u.object({identity:en,change:Go}),Bu=u.object({items:u.array(Jo)}),Ko=u.nativeEnum(Kr),Jr=u.object({log_level:Ko}),zu=u.object({kind:u.literal("ServersChanged"),payload:tn}),qu=u.nativeEnum(Xr),Hu=u.union([u.object({kind:u.literal("ServersChanged"),payload:Fo}),u.object({kind:u.literal("Watching"),payload:Ho}),u.object({kind:u.literal("WatchingStopped"),payload:Yo}),u.object({kind:u.literal("FileChanged"),payload:Gr}),u.object({kind:u.literal("FilesChanged"),payload:zo}),u.object({kind:u.literal("InputFileChanged"),payload:Gr}),u.object({kind:u.literal("InputAccepted"),payload:Bo})]),Yu=u.union([u.object({kind:u.literal("Started"),payload:u.undefined().optional()}),u.object({kind:u.literal("FailedStartup"),payload:u.string()})]),Gu=u.union([u.object({kind:u.literal("MissingInputs"),payload:u.string()}),u.object({kind:u.literal("InvalidInput"),payload:u.string()}),u.object({kind:u.literal("NotFound"),payload:u.string()}),u.object({kind:u.literal("InputWriteError"),payload:u.string()}),u.object({kind:u.literal("PathError"),payload:u.string()}),u.object({kind:u.literal("PortError"),payload:u.string()}),u.object({kind:u.literal("DirError"),payload:u.string()}),u.object({kind:u.literal("YamlError"),payload:u.string()}),u.object({kind:u.literal("MarkdownError"),payload:u.string()}),u.object({kind:u.literal("HtmlError"),payload:u.string()}),u.object({kind:u.literal("Io"),payload:u.string()}),u.object({kind:u.literal("UnsupportedExtension"),payload:u.string()}),u.object({kind:u.literal("MissingExtension"),payload:u.string()}),u.object({kind:u.literal("EmptyInput"),payload:u.string()}),u.object({kind:u.literal("BsLiveRules"),payload:u.string()})]),Xo=u.nativeEnum(Qr),jt=u.lazy(()=>u.union([u.object({kind:u.literal("Fs"),payload:u.object({path:u.string(),change_kind:Xo})}),u.object({kind:u.literal("FsMany"),payload:u.array(jt)})])),Ju=u.union([u.object({kind:u.literal("Change"),payload:jt}),u.object({kind:u.literal("WsConnection"),payload:Jr}),u.object({kind:u.literal("Config"),payload:Jr})]);var rn=[{selector:"background",styleNames:["backgroundImage"]},{selector:"border",styleNames:["borderImage","webkitBorderImage","MozBorderImage"]}],It={stylesheetReloadTimeout:15e3},Qo=/\.(jpe?g|png|gif|svg)$/i,Rt=class{constructor(e,t,n){this.window=e,this.console=t,this.Timer=n,this.document=this.window.document,this.importCacheWaitPeriod=200,this.plugins=[]}addPlugin(e){return this.plugins.push(e)}analyze(e){}reload(e,t={}){if(this.options={...It,...t},!(t.liveCSS&&e.match(/\.css(?:\.map)?$/i)&&this.reloadStylesheet(e))){if(t.liveImg&&e.match(Qo)){this.reloadImages(e);return}if(t.isChromeExtension){this.reloadChromeExtension();return}return this.reloadPage()}}reloadPage(){return this.window.document.location.reload()}reloadChromeExtension(){return this.window.chrome.runtime.reload()}reloadImages(e){let t,n=this.generateUniqueString();for(t of Array.from(this.document.images))nn(e,Kt(t.src))&&(t.src=this.generateCacheBustUrl(t.src,n));if(this.document.querySelectorAll)for(let{selector:o,styleNames:i}of rn)for(t of Array.from(this.document.querySelectorAll(`[style*=${o}]`)))this.reloadStyleImages(t.style,i,e,n);if(this.document.styleSheets)return Array.from(this.document.styleSheets).map(o=>this.reloadStylesheetImages(o,e,n))}reloadStylesheetImages(e,t,n){let o;try{o=(e||{}).cssRules}catch{}if(o)for(let i of Array.from(o))switch(i.type){case CSSRule.IMPORT_RULE:this.reloadStylesheetImages(i.styleSheet,t,n);break;case CSSRule.STYLE_RULE:for(let{styleNames:a}of rn)this.reloadStyleImages(i.style,a,t,n);break;case CSSRule.MEDIA_RULE:this.reloadStylesheetImages(i,t,n);break}}reloadStyleImages(e,t,n,o){for(let i of t){let a=e[i];if(typeof a=="string"){let s=a.replace(new RegExp("\\burl\\s*\\(([^)]*)\\)"),(c,l)=>nn(n,Kt(l))?`url(${this.generateCacheBustUrl(l,o)})`:c);s!==a&&(e[i]=s)}}}reloadStylesheet(e){let t=this.options||It,n,o,i=(()=>{let c=[];for(o of Array.from(this.document.getElementsByTagName("link")))o.rel.match(/^stylesheet$/i)&&!o.__LiveReload_pendingRemoval&&c.push(o);return c})(),a=[];for(n of Array.from(this.document.getElementsByTagName("style")))n.sheet&&this.collectImportedStylesheets(n,n.sheet,a);for(o of Array.from(i))this.collectImportedStylesheets(o,o.sheet,a);if(this.window.StyleFix&&this.document.querySelectorAll)for(n of Array.from(this.document.querySelectorAll("style[data-href]")))i.push(n);this.console.debug(`found ${i.length} LINKed stylesheets, ${a.length} @imported stylesheets`);let s=ei(e,i.concat(a),c=>Kt(this.linkHref(c)));if(s)s.object.rule?(this.console.debug(`is reloading imported stylesheet: ${s.object.href}`),this.reattachImportedRule(s.object)):(this.console.debug(`is reloading stylesheet: ${this.linkHref(s.object)}`),this.reattachStylesheetLink(s.object));else if(t.reloadMissingCSS){this.console.debug(`will reload all stylesheets because path '${e}' did not match any specific one. To disable this behavior, set 'options.reloadMissingCSS' to 'false'.`);for(o of Array.from(i))this.reattachStylesheetLink(o)}else this.console.debug(`will not reload path '${e}' because the stylesheet was not found on the page and 'options.reloadMissingCSS' was set to 'false'.`);return!0}collectImportedStylesheets(e,t,n){let o;try{o=(t||{}).cssRules}catch{}if(o&&o.length)for(let i=0;i{if(!o)return o=!0,t()};if(e.onload=()=>(this.console.debug("the new stylesheet has finished loading"),this.knownToSupportCssOnLoad=!0,i()),!this.knownToSupportCssOnLoad){let a;(a=()=>e.sheet?(this.console.debug("is polling until the new CSS finishes loading..."),i()):this.Timer.start(50,a))()}return this.Timer.start(n.stylesheetReloadTimeout,i)}linkHref(e){return e.href||e.getAttribute&&e.getAttribute("data-href")}reattachStylesheetLink(e){let t;if(e.__LiveReload_pendingRemoval)return;e.__LiveReload_pendingRemoval=!0,e.tagName==="STYLE"?(t=this.document.createElement("link"),t.rel="stylesheet",t.media=e.media,t.disabled=e.disabled):t=e.cloneNode(!1),t.href=this.generateCacheBustUrl(this.linkHref(e));let n=e.parentNode;return n.lastChild===e?n.appendChild(t):n.insertBefore(t,e.nextSibling),this.waitUntilCssLoads(t,()=>{let o;return/AppleWebKit/.test(this.window.navigator.userAgent)?o=5:o=200,this.Timer.start(o,()=>{if(e.parentNode)return e.parentNode.removeChild(e),t.onreadystatechange=null,this.window.StyleFix?this.window.StyleFix.link(t):void 0})})}reattachImportedRule({rule:e,index:t,link:n}){let o=e.parentStyleSheet,i=this.generateCacheBustUrl(e.href),a=e.media.length?[].join.call(e.media,", "):"",s=`@import url("${i}") ${a};`;e.__LiveReload_newHref=i;let c=this.document.createElement("link");return c.rel="stylesheet",c.href=i,c.__LiveReload_pendingRemoval=!0,n.parentNode&&n.parentNode.insertBefore(c,n),this.Timer.start(this.importCacheWaitPeriod,()=>{if(c.parentNode&&c.parentNode.removeChild(c),e.__LiveReload_newHref===i)return o.insertRule(s,t),o.deleteRule(t+1),e=o.cssRules[t],e.__LiveReload_newHref=i,this.Timer.start(this.importCacheWaitPeriod,()=>{if(e.__LiveReload_newHref===i)return o.insertRule(s,t),o.deleteRule(t+1)})})}generateUniqueString(){return`livereload=${Date.now()}`}generateCacheBustUrl(e,t){let n=this.options||It,o,i;if(t||(t=this.generateUniqueString()),{url:e,hash:o,params:i}=on(e),n.overrideURL&&e.indexOf(n.serverURL)<0){let s=e;e=n.serverURL+n.overrideURL+"?url="+encodeURIComponent(e),this.console.debug(`is overriding source URL ${s} with ${e}`)}let a=i.replace(/(\?|&)livereload=(\d+)/,(s,c)=>`${c}${t}`);return a===i&&(i.length===0?a=`?${t}`:a=`${i}&${t}`),e+a+o}};function on(r){let e="",t="",n=r.indexOf("#");n>=0&&(e=r.slice(n),r=r.slice(0,n));let o=r.indexOf("??");return o>=0?o+1!==r.lastIndexOf("?")&&(n=r.lastIndexOf("?")):n=r.indexOf("?"),n>=0&&(t=r.slice(n),r=r.slice(0,n)),{url:r,params:t,hash:e}}function Kt(r){if(!r)return"";let e;return{url:r}=on(r),r.indexOf("file://")===0?e=r.replace(new RegExp("^file://(localhost)?"),""):e=r.replace(new RegExp("^([^:]+:)?//([^:/]+)(:\\d*)?/"),"/"),decodeURIComponent(e)}function an(r,e){if(r=r.replace(/^\/+/,"").toLowerCase(),e=e.replace(/^\/+/,"").toLowerCase(),r===e)return 1e4;let t=r.split(/\/|\\/).reverse(),n=e.split(/\/|\\/).reverse(),o=Math.min(t.length,n.length),i=0;for(;in){let n,o={score:0};for(let i of e)n=an(r,t(i)),n>o.score&&(o={object:i,score:n});return o.score===0?null:o}function nn(r,e){return an(r,e)>0}var un=gn(cn());var ti=/\.(jpe?g|png|gif|svg)$/i;function Xt(r,e,t){switch(r.kind){case"FsMany":{if(r.payload.some(o=>{switch(o.kind){case"Fs":return!(o.payload.path.match(/\.css(?:\.map)?$/i)||o.payload.path.match(ti));case"FsMany":throw new Error("unreachable")}}))return window.__playwright?.record?window.__playwright?.record({kind:"reloadPage"}):t.reloadPage();for(let o of r.payload)Xt(o,e,t);break}case"Fs":{let n=r.payload.path,o={liveCSS:!0,liveImg:!0,reloadMissingCSS:!0,originalPath:"",overrideURL:"",serverURL:""};window.__playwright?.record?window.__playwright?.record({kind:"reload",args:{path:n,opts:o}}):(e.trace("will reload a file with path ",n),t.reload(n,o))}}}var Qt={name:"dom plugin",globalSetup:(r,e)=>{let t=new Rt(window,e,un.Timer);return[r,[e,t]]},resetSink(r,e,t){let[n,o]=e;return r.pipe(de(i=>i.kind==="Change"),K(i=>i.payload),Be(i=>{n.trace("incoming message",JSON.stringify({change:i,config:t},null,2));let a=jt.parse(i);Xt(a,n,o)}),Fe())}};var ri=Dr(),Ke=ri.create(),[ni,er]=zt.globalSetup(Ke,Mr),[oi,ii]=Qt.globalSetup(Ke,er),ln=Ke.pipe(de(r=>r.kind==="WsConnection"),K(r=>r.payload),Vt()),ai=Ke.pipe(de(r=>r.kind==="Config"),K(r=>r.payload)),fl=Ke.pipe(de(r=>r.kind==="Change"),K(r=>r.payload));wt(ai,ln).pipe(Ft(r=>{let e=[Qt.resetSink(oi,ii,r),zt.resetSink(ni,er,r)];return wt(...e)})).subscribe();ln.subscribe(r=>{er.info("\u{1F7E2} Browsersync Live connected",{config:r})}); diff --git a/tests/playground.spec.ts b/tests/playground.spec.ts index 6f17a7a..8e1ca73 100644 --- a/tests/playground.spec.ts +++ b/tests/playground.spec.ts @@ -12,7 +12,7 @@ test.describe( }, }, () => { - test("playground", async ({ page, bs }) => { + test("markdown playground", async ({ page, bs }) => { const text: string[] = []; page.on("console", (msg) => text.push(msg.text())); await page.goto(bs.path("/"), { waitUntil: "networkidle" }); @@ -20,3 +20,25 @@ test.describe( }); }, ); + +test.describe( + "examples/html/playground.html", + { + annotation: { + type: bstest({ + input: "examples/html/playground.html", + }), + description: "", + }, + }, + () => { + test("html playground", async ({ page, bs }) => { + const text: string[] = []; + page.on("console", (msg) => text.push(msg.text())); + await page.goto(bs.path("/"), { waitUntil: "networkidle" }); + await expect(page.locator("abc-element")).toContainText( + "Hello World!", + ); + }); + }, +);