Skip to main content

euv_example/pages/
fn.rs

1use super::*;
2
3style! {
4    c_full_col {
5        FlexDirection::Column;
6        width: Length::Percent(100.0);
7        height: Length::Percent(100.0);
8    }
9    c_action_row {
10        FlexDirection::Row;
11        FlexWrap::Wrap;
12        AlignItems::Center;
13        width: Length::Percent(100.0);
14        gap: SPACE_SM;
15    }
16    c_scheme_grid {
17        columns: 4;
18        width: Length::Percent(100.0);
19        gap: SPACE_SM;
20    }
21}
22
23/// Registers all 15 showcase routes lazily onto `router` using typed `#[component(retention = Freeze)]` pages.
24///
25/// # Arguments
26///
27/// - `&ShowcaseState` - Shared reactive showcase state.
28fn ensure_showcase_routes_registered(state: &ShowcaseState) {
29    if state.get_router_ready().replace(true) {
30        return;
31    }
32    let all_routes: [(&'static str, &'static str); 15] = [
33        (ROUTE_OVERVIEW, NAV_LABEL_OVERVIEW),
34        (ROUTE_MARKDOWN, NAV_LABEL_MARKDOWN),
35        (ROUTE_REACTIVE, NAV_LABEL_REACTIVE),
36        (ROUTE_RENDER, NAV_LABEL_RENDER),
37        (ROUTE_WINDOW, NAV_LABEL_WINDOW),
38        (ROUTE_FORMS, NAV_LABEL_FORMS),
39        (ROUTE_THEMES, NAV_LABEL_THEMES),
40        (ROUTE_DATA, NAV_LABEL_DATA),
41        (ROUTE_GAME, NAV_LABEL_GAME),
42        (ROUTE_GAME_3D, NAV_LABEL_GAME_3D),
43        (ROUTE_MEDIA, NAV_LABEL_MEDIA),
44        (ROUTE_LAB, NAV_LABEL_LAB),
45        (ROUTE_OVERLAYS, NAV_LABEL_OVERLAYS),
46        (ROUTE_DYNAMIC, NAV_LABEL_DYNAMIC),
47        (ROUTE_STRESS, NAV_LABEL_STRESS),
48    ];
49    let mut router: EuvRouter = state.get_router().clone();
50    for (path, label) in all_routes.into_iter() {
51        let st: ShowcaseState = state.clone();
52        router = router.route_component(path, label, move |_: &EuvRouteMatch| {
53            let tok: ThemeTokens = untracked(|| st.get_theme().get_tokens().get());
54            ShowcasePage::new(path, st.clone(), tok)
55        });
56    }
57    let _: EuvRouter = router;
58}
59
60/// Mounts the fully reactive showcase application shell with lazy `PageRetention::Freeze` routing and cross-component events.
61///
62/// # Arguments
63///
64/// - `&ShowcaseState` - Reactive showcase state.
65///
66/// # Returns
67///
68/// - `NodeId` - Mounted reactive root container handle.
69pub fn mount_showcase_root(state: &ShowcaseState) -> NodeId {
70    ensure_showcase_routes_registered(state);
71    let global_banner: Signal<ShowcaseGlobalBanner> =
72        global_state!(ShowcaseGlobalBanner = ShowcaseGlobalBanner::default());
73    let state_c: ShowcaseState = state.clone();
74    let (ev_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
75        on_event!(ShowcasePulseEvent => move |ev: &ShowcasePulseEvent| {
76            let src: String = ev.get_source().clone();
77            let _: bool = global_banner.update(|b: &mut ShowcaseGlobalBanner| {
78                let next_pulses: u32 = b.get_pulses().saturating_add(1);
79                b.set_pulses(next_pulses);
80                b.set_last_source(src);
81            });
82        })
83    });
84    let root_node: NodeId = view! {
85        column {
86            width: Length::Percent(100.0)
87            height: Length::Percent(100.0)
88            bind_children: move || {
89                let tokens: ThemeTokens = state_c.get_theme().get_tokens().get();
90                let hub: DynamicUpdateHub = state_c.get_dynamic_hub().clone();
91                let _: u64 = hub.routes_signal().get();
92                let cmd_open: Signal<bool> = state_c.get_cmd_palette_open();
93                let cmd_query: Signal<String> = state_c.get_cmd_palette_query();
94                let cmd_items: Vec<String> = vec![
95                    CMD_ITEM_OVERVIEW.to_string(),
96                    CMD_ITEM_MARKDOWN.to_string(),
97                    CMD_ITEM_LAB.to_string(),
98                    CMD_ITEM_GAME_3D.to_string(),
99                    CMD_ITEM_MEDIA.to_string(),
100                    CMD_ITEM_DYNAMIC.to_string(),
101                    CMD_ITEM_STRESS.to_string(),
102                    CMD_ITEM_WINDOW.to_string(),
103                    CMD_ITEM_THEMES.to_string(),
104                    CMD_ITEM_TOGGLE_MODE.to_string(),
105                ];
106                let cmd_sel: Signal<Option<usize>> = Signal::new(None);
107                let cmd_route: Signal<String> = state_c.get_route();
108                let cmd_state: ShowcaseState = state_c.clone();
109                let cmd_list: NodeId = view! {
110                    EuvCommand(cmd_items, cmd_sel, tokens) {
111                        query: cmd_query
112                        placeholder: CMD_PLACEHOLDER
113                    }
114                };
115                let (cmd_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
116                        Effect::new(move || {
117                                if let Some(idx) = cmd_sel.get() {
118                                    match idx {
119                                        0 => {
120                                            let _: bool = cmd_route.set_if_changed(ROUTE_OVERVIEW.to_string());
121                                        }
122                                        1 => {
123                                            let _: bool = cmd_route.set_if_changed(ROUTE_MARKDOWN.to_string());
124                                        }
125                                        2 => {
126                                            let _: bool = cmd_route.set_if_changed(ROUTE_LAB.to_string());
127                                        }
128                                        3 => {
129                                            let _: bool = cmd_route.set_if_changed(ROUTE_GAME_3D.to_string());
130                                        }
131                                        4 => {
132                                            let _: bool = cmd_route.set_if_changed(ROUTE_MEDIA.to_string());
133                                        }
134                                        5 => {
135                                            let _: bool = cmd_route.set_if_changed(ROUTE_DYNAMIC.to_string());
136                                        }
137                                        6 => {
138                                            let _: bool = cmd_route.set_if_changed(ROUTE_STRESS.to_string());
139                                        }
140                                        7 => {
141                                            let _: bool = cmd_route.set_if_changed(ROUTE_WINDOW.to_string());
142                                        }
143                                        8 => {
144                                            let _: bool = cmd_route.set_if_changed(ROUTE_THEMES.to_string());
145                                        }
146                                        _ => {
147                                            cmd_state.toggle_theme_mode();
148                                        }
149                                    }
150                                    let _: bool = cmd_sel.set_if_changed(None);
151                                    let _: bool = cmd_open.set_if_changed(false);
152                                }
153                        })
154                });
155                let cmd_modal: NodeId = view! {
156                    EuvModal(cmd_open, CMD_MODAL_TITLE.to_string(), cmd_list, tokens)
157                };
158                let rctx: Context = current_context();
159                rctx.get_scene().with_write(
160                    |tree: &mut SceneTree| {
161                        tree.attach_scope(cmd_modal, cmd_scope);
162                    },
163                    (),
164                );
165                let state_shell: ShowcaseState = state_c.clone();
166                let hub_shell: DynamicUpdateHub = hub.clone();
167                let global_wasm_slot: NodeId = view! {
168                    slot {
169                        id: WASM_GLOBAL_ROOT_SLOT
170                        hub: hub
171                        style: c_full_col()
172                        fallback: move || {
173                            let mut nav_items: Vec<EuvNavItem> = ShowcaseState::nav_items();
174                            for dyn_route in hub_shell.registered_routes().into_iter() {
175                                if dyn_route == ROUTE_DYNAMIC_PANEL {
176                                    continue;
177                                }
178                                if !nav_items
179                                .iter()
180                                .any(|item: &EuvNavItem| item.get_path().as_str() == dyn_route.as_str())
181                                {
182                                    let label: String = hub_shell
183                                    .page_title(&dyn_route)
184                                    .filter(|t: &String| !t.is_empty())
185                                    .unwrap_or_else(|| dyn_route.clone());
186                                    nav_items.push(EuvNavItem::new(dyn_route, label).section(NAV_SEC_RUNTIME));
187                                }
188                            }
189                            let nav: NodeId = view! {
190                                EuvSidebarNav(nav_items, state_shell.get_route(), tokens)
191                            };
192                            let state_for_outlet: ShowcaseState = state_shell.clone();
193                            let router: EuvRouter = state_shell
194                            .get_router()
195                            .clone()
196                            .with_dynamic_hub(hub_shell.clone());
197                            let route_sig: Signal<String> = state_shell.get_route();
198                            let cur_target: String = route_sig.get_untracked();
199                            if router.get_current_path().get_untracked() != cur_target {
200                                router.replace(&cur_target);
201                            }
202                            let breadcrumb_sig: Signal<String> = Signal::new(
203                                ShowcaseState::breadcrumb_for_route(&cur_target),
204                            );
205                            let router_sync_in: EuvRouter = router.clone();
206                            let router_path_sig: Signal<String> = router.get_current_path();
207                            let sctx: Context = current_context();
208                            let (sync_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
209                                    let _: Effect = Effect::new(move || {
210                                            let target: String = route_sig.get();
211                                            let _: bool = breadcrumb_sig
212                                            .set_if_changed(ShowcaseState::breadcrumb_for_route(&target));
213                                            if router_sync_in.get_current_path().get_untracked() != target {
214                                                router_sync_in.push(&target);
215                                            }
216                                    });
217                                    Effect::new(move || {
218                                            let rp: String = router_path_sig.get();
219                                            if route_sig.get_untracked() != rp {
220                                                let _: bool = route_sig.set_if_changed(rp);
221                                            }
222                                    })
223                            });
224                            let page_node: NodeId = router
225                            .outlet(move |matched: &EuvRouteMatch| {
226                                    let tok: ThemeTokens = untracked(|| {
227                                            state_for_outlet.get_theme().get_tokens().get()
228                                    });
229                                    mount_route_by_name(matched.get_path(), &state_for_outlet, tok)
230                            })
231                            .with_theme(state_shell.get_theme().clone())
232                            .with_double_back_exit(true)
233                            .mount();
234                            sctx.get_scene().with_write(
235                                |tree: &mut SceneTree| {
236                                    tree.attach_scope(page_node, sync_scope);
237                                },
238                                (),
239                            );
240                            let st_dark_top: ShowcaseState = state_shell.clone();
241                            let st_scheme_top: ShowcaseState = state_shell.clone();
242                            let st_dark_mobile: ShowcaseState = state_shell.clone();
243                            let mode_label: String =
244                            match state_shell.get_theme().get_mode().get_untracked() {
245                                ThemeMode::Dark => LABEL_MODE_LIGHT.to_string(),
246                                ThemeMode::Light => LABEL_MODE_DARK.to_string(),
247                            };
248                            let scheme_label: String =
249                            format!("{:?}", state_shell.get_theme().get_scheme().get_untracked());
250                            let top_actions: NodeId = view! {
251                                row {
252                                    gap: SPACE_SM
253                                    align: AlignItems::Center
254                                    EuvButton(BTN_SEARCH_DESKTOP.to_string(), tokens) {
255                                        outline()
256                                        sm()
257                                        on_click: move |_: &UiEvent| {
258                                            let _: bool = cmd_open.set_if_changed(true);
259                                        }
260                                    }
261                                    EuvButton(scheme_label, tokens) {
262                                        secondary()
263                                        sm()
264                                        on_click: move |_: &UiEvent| {
265                                            st_scheme_top.next_scheme();
266                                        }
267                                    }
268                                    EuvButton(mode_label.clone(), tokens) {
269                                        outline()
270                                        sm()
271                                        on_click: move |_: &UiEvent| {
272                                            st_dark_top.toggle_theme_mode();
273                                        }
274                                    }
275                                }
276                            };
277                            let mobile_actions: NodeId = view! {
278                                row {
279                                    gap: SPACE_XS
280                                    align: AlignItems::Center
281                                    EuvButton(BTN_SEARCH_MOBILE.to_string(), tokens) {
282                                        outline()
283                                        sm()
284                                        on_click: move |_: &UiEvent| {
285                                            let _: bool = cmd_open.set_if_changed(true);
286                                        }
287                                    }
288                                    EuvButton(mode_label, tokens) {
289                                        ghost()
290                                        sm()
291                                        on_click: move |_: &UiEvent| {
292                                            st_dark_mobile.toggle_theme_mode();
293                                        }
294                                    }
295                                }
296                            };
297                            view! {
298                                EuvAppShell(SHOWCASE_BRAND.to_string(), nav, page_node, tokens) {
299                                    route: state_shell.get_route()
300                                    breadcrumb: breadcrumb_sig
301                                    top_bar_actions: top_actions
302                                    mobile_header_actions: mobile_actions
303                                }
304                            }
305                        }
306                    }
307                };
308                vec![global_wasm_slot, cmd_modal]
309            }
310        }
311    };
312    let root_ctx: Context = current_context();
313    root_ctx.get_scene().with_write(
314        |tree: &mut SceneTree| {
315            tree.attach_scope(root_node, ev_scope);
316        },
317        (),
318    );
319    root_node
320}
321
322/// Mounts the showcase page corresponding to the active route in `state`.
323///
324/// # Arguments
325///
326/// - `&ShowcaseState` - Reactive showcase state.
327/// - `ThemeTokens` - Active resolved design tokens.
328///
329/// # Returns
330///
331/// - `NodeId` - Mounted page container handle.
332pub fn mount_active_route(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
333    let route: String = state.get_route().get_untracked();
334    mount_route_by_name(&route, state, tokens)
335}
336
337/// Dispatches a route string to its corresponding declarative showcase page builder.
338///
339/// # Arguments
340///
341/// - `&str` - Active route path.
342/// - `&ShowcaseState` - Reactive showcase state.
343/// - `ThemeTokens` - Active resolved design tokens.
344///
345/// # Returns
346///
347/// - `NodeId` - Mounted page container handle.
348pub(crate) fn mount_route_by_name(
349    route: &str,
350    state: &ShowcaseState,
351    tokens: ThemeTokens,
352) -> NodeId {
353    match route {
354        ROUTE_MARKDOWN => mount_markdown_page(state, tokens),
355        ROUTE_REACTIVE => mount_reactive_page(state, tokens),
356        ROUTE_RENDER => mount_render_page(state, tokens),
357        ROUTE_WINDOW => mount_window_page(state, tokens),
358        ROUTE_FORMS => mount_forms_page(state, tokens),
359        ROUTE_THEMES => mount_themes_page(state, tokens),
360        ROUTE_DATA => mount_data_page(state, tokens),
361        ROUTE_GAME => mount_game_page(state, tokens),
362        ROUTE_GAME_3D => mount_game3d_page(state, tokens),
363        ROUTE_MEDIA => mount_media_page(state, tokens),
364        ROUTE_LAB => mount_lab_page(state, tokens),
365        ROUTE_OVERLAYS => mount_overlays_page(state, tokens),
366        ROUTE_DYNAMIC => mount_dynamic_page(state, tokens),
367        ROUTE_STRESS => mount_stress_page(state, tokens),
368        _ => mount_overview_page(state, tokens),
369    }
370}
371
372/// Mounts the redesigned flagship overview dashboard with hero banner, KPI cards, live Freeze lifecycle monitor, cross-component event & state demo, and 7-platform matrix.
373///
374/// # Arguments
375///
376/// - `&ShowcaseState` - Reactive showcase state.
377/// - `ThemeTokens` - Active design tokens.
378///
379/// # Returns
380///
381/// - `NodeId` - Mounted overview page node.
382pub fn mount_overview_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
383    let p: ThemePalette = tokens.get_palette();
384    let g: ThemeGeometry = tokens.get_geometry();
385    let route_sig: Signal<String> = state.get_route();
386    let frozen_sig: Signal<usize> = state.get_router().get_frozen_count();
387    let mounts_sig: Signal<u32> = state.get_lifecycle_mounts();
388    let freezes_sig: Signal<u32> = state.get_lifecycle_freezes();
389    let resumes_sig: Signal<u32> = state.get_lifecycle_resumes();
390    let last_ev_sig: Signal<String> = state.get_lifecycle_last_event();
391    let entries_sig: Signal<Vec<EuvRouteLifecycleEntry>> =
392        state.get_router().get_lifecycle_entries();
393    let local_counter: LocalState<u32> = local_state!(1_u32);
394    let global_banner: Signal<ShowcaseGlobalBanner> =
395        global_state!(ShowcaseGlobalBanner = ShowcaseGlobalBanner::default());
396    let hero_style: Style = style! {
397        FlexDirection::Column;
398        Overflow::Hidden;
399        width: Length::Percent(100.0);
400        padding: Edges::all(SPACE_XL);
401        gap: SPACE_MD;
402        background: p.get_card();
403        border: (g.get_border_width().max(1.0), p.get_primary().with_alpha(96));
404        radius: g.get_radius_xl();
405        shadow: g.get_shadow_md();
406    };
407    view! {
408        EuvPage(OVERVIEW_TITLE.to_string(), OVERVIEW_SUBTITLE.to_string(), tokens) {
409            view {
410                style: hero_style
411                row {
412                    width: Length::Percent(100.0)
413                    flex_wrap: FlexWrap::Wrap
414                    align: AlignItems::Center
415                    gap: SPACE_XS
416                    EuvBadge(HERO_BADGE_VER.to_string(), EuvTone::Primary, tokens)
417                    EuvBadge(HERO_BADGE_ZERO_WV.to_string(), EuvTone::Success, tokens)
418                    EuvBadge(HERO_BADGE_EVA.to_string(), EuvTone::Neutral, tokens)
419                    EuvBadge(HERO_BADGE_FREEZE.to_string(), EuvTone::Warning, tokens)
420                }
421                text {
422                    font_size: 20.0
423                    font_weight: FontWeight::Bold
424                    color: p.get_foreground()
425                    { HERO_HEADLINE }
426                }
427                text {
428                    font_size: 13.5
429                    color: p.get_muted_foreground()
430                    { HERO_DESCRIPTION }
431                }
432                EuvActionRow() {
433                    EuvButton(BTN_OPEN_MARKDOWN.to_string(), tokens) {
434                        on_click: move |_: &UiEvent| {
435                            let _: bool = route_sig.set_if_changed(ROUTE_MARKDOWN.to_string());
436                        }
437                    }
438                    EuvButton(BTN_OPEN_3D_RT.to_string(), tokens) {
439                        secondary()
440                        on_click: move |_: &UiEvent| {
441                            let _: bool = route_sig.set_if_changed(ROUTE_GAME_3D.to_string());
442                        }
443                    }
444                    EuvButton(BTN_OPEN_STRESS_LAB.to_string(), tokens) {
445                        outline()
446                        on_click: move |_: &UiEvent| {
447                            let _: bool = route_sig.set_if_changed(ROUTE_STRESS.to_string());
448                        }
449                    }
450                    EuvButton(BTN_TRY_REACTIVITY.to_string(), tokens) {
451                        outline()
452                        on_click: move |_: &UiEvent| {
453                            let _: bool = route_sig.set_if_changed(ROUTE_REACTIVE.to_string());
454                        }
455                    }
456                }
457            }
458            EuvStatGrid() {
459                EuvStatCard(
460                    STAT_PLATFORMS_LABEL.to_string(),
461                    STAT_PLATFORMS_VAL.to_string(),
462                    STAT_PLATFORMS_CAP.to_string(),
463                    tokens
464                )
465                EuvStatCard(
466                    STAT_SCHEMES_LABEL.to_string(),
467                    STAT_SCHEMES_VAL.to_string(),
468                    STAT_SCHEMES_CAP.to_string(),
469                    tokens
470                )
471                EuvStatCard(
472                    STAT_RENDER_LABEL.to_string(),
473                    STAT_RENDER_VAL.to_string(),
474                    STAT_RENDER_CAP.to_string(),
475                    tokens
476                )
477            }
478            EuvCard(CARD_LIFECYCLE_TITLE.to_string(), tokens) {
479                subtitle: CARD_LIFECYCLE_SUB
480                text {
481                    font_size: 13.5
482                    font_weight: FontWeight::SemiBold
483                    color: p.get_primary()
484                    { move || format!(
485                            "Frozen Pages: {} | Mounts: {} | Freezes: {} | Resumes: {}",
486                            frozen_sig.get(),
487                            mounts_sig.get(),
488                            freezes_sig.get(),
489                            resumes_sig.get()
490                    ) }
491                }
492                text {
493                    font_size: 12.5
494                    font_family: FontFamily::Monospace
495                    color: p.get_muted_foreground()
496                    { move || format!("Last Hook: {}", last_ev_sig.get()) }
497                }
498                text {
499                    font_size: 12.5
500                    color: p.get_foreground()
501                    { move || {
502                            let entries: Vec<EuvRouteLifecycleEntry> = entries_sig.get();
503                            let summary: Vec<String> = entries
504                            .iter()
505                            .map(|e: &EuvRouteLifecycleEntry| format!("{}={:?}", e.get_path(), e.get_phase()))
506                            .collect();
507                            if summary.is_empty() {
508                                LIFECYCLE_ACTIVE_DEFAULT.to_string()
509                            } else {
510                                format!("Cached Routes: {}", summary.join(" | "))
511                            }
512                    } }
513                }
514                text {
515                    font_size: 12.5
516                    font_weight: FontWeight::Medium
517                    color: p.get_success()
518                    { move || {
519                            let gb: ShowcaseGlobalBanner = global_banner.get();
520                            let last_src: &str = if gb.get_last_source().is_empty() {
521                                SOURCE_NONE
522                            } else {
523                                gb.get_last_source().as_str()
524                            };
525                            format!(
526                                "GlobalState Pulses: {} (source: {}) | LocalState (preserved across Freeze): {}",
527                                gb.get_pulses(),
528                                last_src,
529                                local_counter.get()
530                            )
531                    } }
532                }
533                EuvActionRow() {
534                    EuvButton(BTN_EMIT_PULSE.to_string(), tokens) {
535                        sm()
536                        on_click: move |_: &UiEvent| {
537                            let seq: u32 = local_counter.get_untracked();
538                            emit!(ShowcasePulseEvent {
539                                    source: ROUTE_OVERVIEW.to_string(),
540                                    seq,
541                            });
542                        }
543                    }
544                    EuvButton(BTN_LOCAL_INC.to_string(), tokens) {
545                        secondary()
546                        sm()
547                        on_click: move |_: &UiEvent| {
548                            let _: bool = local_counter.update(|v: &mut u32| *v += 1);
549                        }
550                    }
551                    EuvButton(BTN_OPEN_GAME_ENGINE.to_string(), tokens) {
552                        outline()
553                        sm()
554                        on_click: move |_: &UiEvent| {
555                            let _: bool = route_sig.set_if_changed(ROUTE_GAME.to_string());
556                        }
557                    }
558                    EuvButton(BTN_OPEN_OS_SERVICES.to_string(), tokens) {
559                        outline()
560                        sm()
561                        on_click: move |_: &UiEvent| {
562                            let _: bool = route_sig.set_if_changed(ROUTE_WINDOW.to_string());
563                        }
564                    }
565                }
566            }
567            EuvCard(CARD_PLATFORMS_TITLE.to_string(), tokens) {
568                subtitle: CARD_PLATFORMS_SUB
569                EuvTable(
570                    vec![
571                        TABLE_COL_TARGET.to_string(),
572                        TABLE_COL_BACKEND.to_string(),
573                        TABLE_COL_GPU.to_string(),
574                    ],
575                    vec![
576                        vec![ROW_WEB.to_string(), ROW_WEB_API.to_string(), ROW_WEB_GPU.to_string()],
577                        vec![ROW_MACOS.to_string(), ROW_MACOS_API.to_string(), ROW_MACOS_GPU.to_string()],
578                        vec![ROW_IOS.to_string(), ROW_IOS_API.to_string(), ROW_MACOS_GPU.to_string()],
579                        vec![ROW_ANDROID.to_string(), ROW_ANDROID_API.to_string(), ROW_ANDROID_GPU.to_string()],
580                        vec![ROW_WINDOWS.to_string(), ROW_WINDOWS_API.to_string(), ROW_WINDOWS_GPU.to_string()],
581                        vec![ROW_LINUX.to_string(), ROW_LINUX_API.to_string(), ROW_ANDROID_GPU.to_string()],
582                    ],
583                    tokens
584                )
585            }
586        }
587    }
588}
589
590/// Mounts the Markdown & Code Studio page showcasing exact VS Code `Eva Light Bold` / `Eva Dark Bold` `EuvCodeBlock` and the complete native GFM Markdown component suite.
591///
592/// # Arguments
593///
594/// - `&ShowcaseState` - Reactive showcase state.
595/// - `ThemeTokens` - Active design tokens.
596///
597/// # Returns
598///
599/// - `NodeId` - Mounted Markdown & Code Studio page handle.
600pub fn mount_markdown_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
601    let p: ThemePalette = tokens.get_palette();
602    let eva: CodeThemePalette = CodeThemePalette::resolve(tokens.get_mode());
603    let st_toggle: ShowcaseState = state.clone();
604    let lang_tab: Signal<usize> = state.get_markdown_lang_tab();
605    let copy_log: Signal<String> = state.get_markdown_copy_log();
606    let link_log: Signal<String> = state.get_markdown_link_log();
607    let tasks_toggled: Signal<u32> = state.get_markdown_tasks_toggled();
608    let copy_log_doc: Signal<String> = copy_log;
609    let link_log_doc: Signal<String> = link_log;
610    let tasks_doc: Signal<u32> = tasks_toggled;
611    let active_theme_desc: String = match tokens.get_mode() {
612        ThemeMode::Light => MD_THEME_DESC_LIGHT.to_string(),
613        ThemeMode::Dark => MD_THEME_DESC_DARK.to_string(),
614    };
615    let swatch_colors: [Color; 6] = [
616        eva.get_background(),
617        eva.get_keyword(),
618        eva.get_function(),
619        eva.get_number(),
620        eva.get_constant(),
621        eva.get_property(),
622    ];
623    let swatch_nodes: Vec<NodeId> = swatch_colors
624        .into_iter()
625        .map(|col: Color| {
626            view! {
627                view {
628                    width: Length::Px(22.0)
629                    height: Length::Px(22.0)
630                    radius: 6.0
631                    background: col
632                    border: (1.0, eva.get_border())
633                }
634            }
635        })
636        .collect();
637    view! {
638        EuvPage(MD_STUDIO_TITLE.to_string(), MD_STUDIO_SUBTITLE.to_string(), tokens) {
639            EuvCard(MD_THEME_CARD_TITLE.to_string(), tokens) {
640                subtitle: MD_THEME_CARD_SUB
641                text {
642                    font_size: 12.5
643                    font_family: FontFamily::Monospace
644                    font_weight: FontWeight::SemiBold
645                    color: eva.get_keyword()
646                    { active_theme_desc }
647                }
648                row {
649                    width: Length::Percent(100.0)
650                    align: AlignItems::Center
651                    flex_wrap: FlexWrap::Wrap
652                    gap: SPACE_SM
653                    ..swatch_nodes
654                    EuvButton(BTN_TOGGLE_EVA_MODE.to_string(), tokens) {
655                        sm()
656                        on_click: move |_: &UiEvent| {
657                            st_toggle.toggle_theme_mode();
658                        }
659                    }
660                    EuvButton(BTN_EMIT_PULSE.to_string(), tokens) {
661                        outline()
662                        sm()
663                        on_click: move |_: &UiEvent| {
664                            emit!(ShowcasePulseEvent {
665                                    source: ROUTE_MARKDOWN.to_string(),
666                                    seq: 1,
667                            });
668                        }
669                    }
670                }
671            }
672            EuvCard(MD_CODE_CARD_TITLE.to_string(), tokens) {
673                subtitle: MD_CODE_CARD_SUB
674                EuvSegmented(
675                    vec![
676                        MD_TAB_RUST.to_string(),
677                        MD_TAB_TS.to_string(),
678                        MD_TAB_JSON.to_string(),
679                        MD_TAB_DIFF.to_string(),
680                    ],
681                    lang_tab,
682                    tokens
683                )
684                column {
685                    width: Length::Percent(100.0)
686                    bind_children: move || {
687                        let tab: usize = lang_tab.get();
688                        let (src, lang, fname, hl): (&str, &str, &str, Vec<usize>) = match tab {
689                            1 => (MD_SAMPLE_TS, MD_LANG_TS, MD_FILE_TS, vec![3, 7]),
690                            2 => (MD_SAMPLE_JSON, MD_LANG_JSON, MD_FILE_JSON, vec![2, 3]),
691                            3 => (MD_SAMPLE_DIFF, MD_LANG_DIFF, MD_FILE_DIFF, vec![2, 4]),
692                            _ => (MD_SAMPLE_RUST, MD_LANG_RUST, MD_FILE_RUST, vec![1, 7, 8]),
693                        };
694                        let cb_log: Signal<String> = copy_log;
695                        let block: NodeId = EuvCodeBlock::new(src.to_string(), tokens)
696                        .language(lang)
697                        .filename(fname)
698                        .line_numbers(true)
699                        .highlight_lines(hl)
700                        .on_copy(move |txt: &str| {
701                                let _: bool = cb_log.set(format!(
702                                        "Copied {} bytes ({lang}) via Eva Bold EuvCodeBlock",
703                                        txt.len()
704                                ));
705                        })
706                        .mount();
707                        vec![block]
708                    }
709                }
710                text {
711                    font_size: 12.0
712                    font_family: FontFamily::Monospace
713                    color: p.get_primary()
714                    { move || format!("Copy: {} | Link: {} | Tasks Toggled: {}", copy_log.get(), link_log.get(), tasks_toggled.get()) }
715                }
716            }
717            EuvCard(MD_DOC_CARD_TITLE.to_string(), tokens) {
718                subtitle: MD_DOC_CARD_SUB
719                { EuvMarkdown::new(MD_FULL_DOCUMENT.to_string(), tokens)
720                    .on_link(move |url: &str| {
721                            let _: bool = link_log_doc.set(url.to_string());
722                    })
723                    .on_copy(move |code: &str| {
724                            let _: bool = copy_log_doc.set(format!("Copied {} bytes from Markdown fence", code.len()));
725                    })
726                    .on_toggle_task(move |_idx: usize, _checked: bool| {
727                            let _: bool = tasks_doc.update(|n: &mut u32| *n += 1);
728                    })
729                    .mount() }
730            }
731        }
732    }
733}
734
735/// Mounts the fine-grained reactivity showcase demonstrating `Signal`, `computed!`, `batch`, and `view!`.
736///
737/// # Arguments
738///
739/// - `&ShowcaseState` - Reactive showcase state.
740/// - `ThemeTokens` - Active design tokens.
741///
742/// # Returns
743///
744/// - `NodeId` - Mounted reactivity page node.
745pub fn mount_reactive_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
746    let p: ThemePalette = tokens.get_palette();
747    let counter: Signal<i32> = state.get_counter();
748    let doubled: Memo<i32> = state.get_doubled();
749    view! {
750        EuvPage(REACTIVE_TITLE.to_string(), REACTIVE_SUBTITLE.to_string(), tokens) {
751            EuvCard(REACTIVE_CARD_TITLE.to_string(), tokens) {
752                subtitle: REACTIVE_CARD_SUB
753                column {
754                    gap: SPACE_MD
755                    text {
756                        font_size: 18.0
757                        font_weight: FontWeight::Bold
758                        color: p.get_foreground()
759                        { move || format!("{PREFIX_COUNTER}{}", counter.get()) }
760                    }
761                    text {
762                        font_size: 15.0
763                        color: p.get_primary()
764                        { move || format!("{PREFIX_DOUBLED}{}", doubled.get()) }
765                    }
766                    EuvActionRow() {
767                        EuvButton(BTN_INCREMENT.to_string(), tokens) {
768                            on_click: move |_: &UiEvent| {
769                                let _: bool = counter.update(|v: &mut i32| *v += 1);
770                            }
771                        }
772                        EuvButton(BTN_BATCH_TEN.to_string(), tokens) {
773                            secondary()
774                            on_click: move |_: &UiEvent| {
775                                batch(|| {
776                                        for _ in 0..10 {
777                                            let _: bool = counter.update(|v: &mut i32| *v += 1);
778                                        }
779                                });
780                            }
781                        }
782                        EuvButton(BTN_RESET.to_string(), tokens) {
783                            outline()
784                            on_click: move |_: &UiEvent| {
785                                let _: bool = counter.set_if_changed(0);
786                            }
787                        }
788                    }
789                }
790            }
791        }
792    }
793}
794
795/// Mounts the multi-mode rendering inspector with live mode switcher and vector `canvas` via `view!`.
796///
797/// # Arguments
798///
799/// - `&ShowcaseState` - Reactive showcase state.
800/// - `ThemeTokens` - Active design tokens.
801///
802/// # Returns
803///
804/// - `NodeId` - Mounted rendering page node.
805pub fn mount_render_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
806    let p: ThemePalette = tokens.get_palette();
807    let g: ThemeGeometry = tokens.get_geometry();
808    let mode_idx: Signal<usize> = state.get_render_mode_index();
809    view! {
810        EuvPage(RENDER_TITLE.to_string(), RENDER_SUBTITLE.to_string(), tokens) {
811            EuvCard(RENDER_CARD_TITLE.to_string(), tokens) {
812                subtitle: RENDER_CARD_SUB
813                EuvSegmented(
814                    vec![
815                        MODE_AUTO.to_string(),
816                        MODE_SOFTWARE.to_string(),
817                        MODE_HARDWARE.to_string(),
818                        MODE_HYBRID.to_string(),
819                    ],
820                    mode_idx,
821                    tokens
822                )
823                column {
824                    gap: SPACE_SM
825                    text {
826                        font_size: 13.0
827                        font_weight: FontWeight::Medium
828                        color: p.get_primary()
829                        { move || format!("Active Pipeline Selection: {}", match mode_idx.get() { 1 => MODE_SOFTWARE, 2 => MODE_HARDWARE, 3 => MODE_HYBRID, _ => MODE_AUTO }) }
830                    }
831                    text {
832                        font_size: 13.0
833                        font_weight: FontWeight::Medium
834                        color: p.get_muted_foreground()
835                        { CANVAS_LABEL }
836                    }
837                    canvas {
838                        width: Length::Percent(100.0)
839                        height: Length::Px(140.0)
840                        background: p.get_muted()
841                        border: (g.get_border_width(), p.get_border())
842                        radius: g.get_radius_md()
843                        painter: move |bounds: Rect, dl: &mut DisplayList| {
844                            let bw: f32 = bounds.get_width().max(120.0);
845                            let rect_w: f32 = (bw * 0.28).clamp(56.0, 160.0);
846                            let circle_r: f32 = (bw * 0.08).clamp(20.0, 42.0);
847                            let circle_x: f32 = bounds.get_x() + 16.0 + rect_w + circle_r + 20.0;
848                            let line_x0: f32 = (circle_x + circle_r + 16.0).min(bounds.right() - 24.0);
849                            let line_x1: f32 = (bounds.right() - 16.0).max(line_x0);
850                            dl.push(DrawCommand::FillRoundedRect {
851                                    rect: Rect::new(bounds.get_x() + 16.0, bounds.get_y() + 16.0, rect_w, 108.0),
852                                    color: p.get_primary(),
853                                    radius: CornerRadius::all(14.0),
854                                    border: Border::default(),
855                            });
856                            dl.push(DrawCommand::Circle {
857                                    center: Point::new(circle_x.min(bounds.right() - circle_r - 8.0), bounds.get_y() + 70.0),
858                                    radius: circle_r,
859                                    color: p.get_success(),
860                            });
861                            dl.push(DrawCommand::Line {
862                                    from: Point::new(line_x0, bounds.get_y() + 28.0),
863                                    to: Point::new(line_x1, bounds.get_y() + 112.0),
864                                    color: p.get_warning(),
865                                    width: 3.0,
866                            });
867                        }
868                    }
869                }
870            }
871        }
872    }
873}
874
875/// Mounts the OS capabilities page with interactive A11y, Protocol Registration, Dynamic Island, Permissions, and Haptics.
876///
877/// # Arguments
878///
879/// - `&ShowcaseState` - Reactive showcase state.
880/// - `ThemeTokens` - Active design tokens.
881///
882/// # Returns
883///
884/// - `NodeId` - Mounted window & OS services page node.
885pub fn mount_window_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
886    let p: ThemePalette = tokens.get_palette();
887    let font_info: SystemFontInfo = NativeSystemFont::system().font_info();
888    let gpu_driver: NativeGpuDriver = NativeGpuDriver::probe(GraphicsBackend::Metal);
889    let gpu_info: &GpuAdapterInfo = gpu_driver.get_adapter();
890    let platform: PlatformKind = current_platform();
891    let caps: PlatformCapabilities = PlatformCapabilities::for_platform(platform);
892    let hub: PlatformServiceHub = PlatformServiceHub::new(platform);
893    let cam_key: &'static str = SystemPermission::Camera.native_key(platform);
894    let island_active: Signal<bool> = state.get_island_active();
895    let island_progress: Signal<u8> = state.get_island_progress();
896    let cam_status: Signal<String> = state.get_camera_perm_status();
897    let proto_status: Signal<String> = state.get_protocol_status();
898    let a11y_count: Signal<u32> = state.get_a11y_announcements();
899    let haptic_count: Signal<u32> = state.get_haptic_pulses();
900    let bp_sig: Signal<Breakpoint> = use_breakpoint();
901    let vp_sig: Signal<Size> = use_viewport_size();
902    let summary: String = format!(
903        "Platform: {:?} | Font: {} ({:?}) | GPU: {} (shader_ok={})",
904        platform,
905        font_info.get_family_name(),
906        font_info.get_backend(),
907        gpu_info.get_device_name(),
908        gpu_info.get_shader_compiled()
909    );
910    let native_feedback: Signal<String> = Signal::new(
911        "Ready — tap any OS capability below to trigger native platform feedback".to_string(),
912    );
913    let fs_sig: Signal<bool> = state.get_fullscreen();
914    let ctx_win: Context = current_context();
915    let prev_fs: Rc<Cell<bool>> = Rc::new(Cell::new(fs_sig.get_untracked()));
916    let (fs_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
917        Effect::new(move || {
918            let now_fs: bool = fs_sig.get();
919            if prev_fs.replace(now_fs) != now_fs {
920                let arg: &str = if now_fs { "on" } else { "off" };
921                let _: bool = dispatch_native_action(NATIVE_ACTION_FULLSCREEN, arg, "");
922                let _: bool = native_feedback.set(format!("Immersive fullscreen mode: {arg}"));
923            }
924        })
925    });
926    let target_plat_idx: Signal<usize> = state.get_os_target_platform_idx();
927    let island_mode_idx: Signal<usize> = state.get_island_mode_idx();
928    let sys_notifs: Signal<Vec<(String, String)>> = state.get_system_notifications();
929    let perm_statuses: Signal<Vec<PermissionStatus>> = state.get_permission_statuses();
930    let all_platforms: [PlatformKind; 7] = [
931        PlatformKind::Ios,
932        PlatformKind::IpadOs,
933        PlatformKind::Android,
934        PlatformKind::MacOs,
935        PlatformKind::Windows,
936        PlatformKind::Linux,
937        PlatformKind::Web,
938    ];
939    let all_island_modes: [IslandPresentationMode; 6] = [
940        IslandPresentationMode::Compact,
941        IslandPresentationMode::Minimal,
942        IslandPresentationMode::Expanded,
943        IslandPresentationMode::LockScreen,
944        IslandPresentationMode::FallbackNotification,
945        IslandPresentationMode::FallbackStatusBar,
946    ];
947    let all_perms: [SystemPermission; 14] = [
948        SystemPermission::Camera,
949        SystemPermission::Microphone,
950        SystemPermission::LocationWhenInUse,
951        SystemPermission::LocationAlways,
952        SystemPermission::Notifications,
953        SystemPermission::Photos,
954        SystemPermission::Contacts,
955        SystemPermission::Calendar,
956        SystemPermission::Bluetooth,
957        SystemPermission::Biometrics,
958        SystemPermission::FileStorage,
959        SystemPermission::ClipboardRead,
960        SystemPermission::MotionSensors,
961        SystemPermission::LocalNetwork,
962    ];
963    let fps_limit_sig: Signal<Option<u32>> = ctx_win.get_fps_limit();
964    let live_fps_sig: Signal<f32> = ctx_win.get_live_fps();
965    let fps_idx: Signal<usize> = Signal::new(match fps_limit_sig.get_untracked() {
966        Some(30) => 1,
967        Some(60) => 2,
968        Some(120) => 3,
969        Some(144) => 4,
970        Some(240) => 5,
971        _ => 0,
972    });
973    let (fps_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
974        Effect::new(move || {
975            let next_cap: Option<u32> = match fps_idx.get() {
976                1 => Some(30),
977                2 => Some(60),
978                3 => Some(120),
979                4 => Some(144),
980                5 => Some(240),
981                _ => None,
982            };
983            let _: bool = fps_limit_sig.set_if_changed(next_cap);
984        })
985    });
986    let mut body_id: NodeId = NodeId::default();
987    let mut fps_card_id: NodeId = NodeId::default();
988    let page: NodeId = view! {
989        EuvPage(WINDOW_TITLE.to_string(), WINDOW_SUBTITLE.to_string(), tokens) {
990            EuvCard(WINDOW_CARD_TITLE.to_string(), tokens) {
991                subtitle: WINDOW_CARD_SUB
992                column {
993                    node_ref: body_id
994                    role: A11yRole::Region
995                    a11y_label: "Platform Telemetry"
996                    gap: SPACE_MD
997                    text {
998                        font_size: 13.0
999                        font_weight: FontWeight::SemiBold
1000                        color: p.get_success()
1001                        { move || native_feedback.get() }
1002                    }
1003                    text {
1004                        font_size: 14.0
1005                        font_weight: FontWeight::Medium
1006                        color: p.get_foreground()
1007                        { summary }
1008                    }
1009                    text {
1010                        font_size: 13.0
1011                        font_weight: FontWeight::SemiBold
1012                        color: p.get_primary()
1013                        { move || {
1014                                let vp: Size = vp_sig.get();
1015                                format!("Live Viewport: {:.0}x{:.0} | Breakpoint: {:?}", vp.get_width(), vp.get_height(), bp_sig.get())
1016                        } }
1017                    }
1018                    text {
1019                        font_size: 13.0
1020                        color: p.get_primary()
1021                        { move || format!("Dynamic Island: active={} ({}%) | Mode: {:?} | Biometrics: {:?}", island_active.get(), island_progress.get(), PlatformServiceHub::default_island_mode(platform), hub.biometric_kind()) }
1022                    }
1023                    text {
1024                        font_size: 13.0
1025                        color: p.get_muted_foreground()
1026                        { move || format!("Protocol: {} | Camera: {} ({cam_key})", proto_status.get(), cam_status.get()) }
1027                    }
1028                    text {
1029                        font_size: 13.0
1030                        color: p.get_muted_foreground()
1031                        { move || format!("A11y Bridge: {} (announcements={}) | Haptics: {} (pulses={})", caps.get_accessibility_bridge(), a11y_count.get(), caps.get_haptics(), haptic_count.get()) }
1032                    }
1033                    EuvActionRow() {
1034                        EuvButton("Toggle Dynamic Island".to_string(), tokens) {
1035                            on_click: move |_: &UiEvent| {
1036                                let next_active: bool = !island_active.get_untracked();
1037                                let _: bool = island_active.set_if_changed(next_active);
1038                                let next_pct: u8 = if next_active {
1039                                    let cur: u8 = island_progress.get_untracked();
1040                                    if cur >= 100 { 25 } else { (cur + 25).min(100) }
1041                                } else {
1042                                    island_progress.get_untracked()
1043                                };
1044                                let _: bool = island_progress.set_if_changed(next_pct);
1045                                let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
1046                                if next_active {
1047                                    let mut content: LiveActivityContent = LiveActivityContent::new(
1048                                        "Euv Live Activity".to_string(),
1049                                        format!("Active ({next_pct}%) on {platform:?}"),
1050                                    );
1051                                    content.set_progress_percent(Some(next_pct));
1052                                    let _ = svc.start_live_activity("euv-showcase-island".to_string(), content);
1053                                    let _: bool = native_feedback.set(format!(
1054                                            "Dynamic Island LIVE ({next_pct}%) dispatched to {platform:?}"
1055                                    ));
1056                                } else {
1057                                    let _: bool = dispatch_native_action(
1058                                        NATIVE_ACTION_ISLAND,
1059                                        "stop",
1060                                        "Dynamic Island paused",
1061                                    );
1062                                    let _: bool = native_feedback.set("Dynamic Island session ended".to_string());
1063                                }
1064                            }
1065                        }
1066                        EuvButton("Register euv:// Protocol".to_string(), tokens) {
1067                            secondary()
1068                            on_click: move |_: &UiEvent| {
1069                                let mut reg: ProtocolRegistry = ProtocolRegistry::new();
1070                                let spec: ProtocolRegistration = ProtocolRegistration::new(
1071                                    "euv".to_string(),
1072                                    "euv Native Showcase".to_string(),
1073                                    SHOWCASE_BUNDLE_ID.to_string(),
1074                                );
1075                                let native_ok: bool =
1076                                dispatch_native_action(NATIVE_ACTION_PROTOCOL, "euv", SHOWCASE_BUNDLE_ID);
1077                                if let Ok(desc) = reg.register(spec, platform) {
1078                                    let tag: &str = if native_ok { "OS Bridged" } else { "Verified" };
1079                                    let msg: String = format!("Registered euv:// via {} ({tag})", desc.get_mechanism());
1080                                    let _: bool = proto_status.set_if_changed(msg.clone());
1081                                    let _: bool = native_feedback.set(msg);
1082                                }
1083                            }
1084                        }
1085                        EuvButton("Request Camera Permission".to_string(), tokens) {
1086                            outline()
1087                            on_click: move |_: &UiEvent| {
1088                                let mut mgr: PermissionManager = PermissionManager::new();
1089                                let desc: PermissionDescriptor = mgr.request(
1090                                    SystemPermission::Camera,
1091                                    "Native camera preview".to_string(),
1092                                    platform,
1093                                );
1094                                let msg: String = format!("{:?} ({})", desc.get_status(), desc.get_native_key());
1095                                let _: bool = cam_status.set_if_changed(msg.clone());
1096                                let _: bool = native_feedback.set(format!("Permission requested: {msg}"));
1097                            }
1098                        }
1099                        EuvButton("Announce A11y + Haptic".to_string(), tokens) {
1100                            outline()
1101                            on_click: move |_: &UiEvent| {
1102                                let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
1103                                let fired: bool = svc.trigger_haptic(HapticStyle::Medium);
1104                                svc.announce_a11y(
1105                                    "euv native accessibility pulse".to_string(),
1106                                    A11yLiveRegion::Polite,
1107                                );
1108                                let _: bool = a11y_count.update(|v: &mut u32| *v += 1);
1109                                let _: bool = haptic_count.update(|v: &mut u32| *v += 1);
1110                                let _: bool = native_feedback.set(format!(
1111                                        "Dispatched Haptic pulse (ok={fired}) + A11y announcement #{}",
1112                                        a11y_count.get_untracked()
1113                                ));
1114                            }
1115                        }
1116                    }
1117                    EuvSwitch(fs_sig, SWITCH_FULLSCREEN.to_string(), tokens)
1118                    EuvCodeBlock(CODE_WINDOW_SNIPPET.to_string(), tokens)
1119                }
1120            }
1121            EuvCard("Cross-Platform Frame Rate Limiter".to_string(), tokens) {
1122                node_ref: fps_card_id
1123                subtitle: "Default Unlimited (Max FPS) on Desktop, Web, Android & iOS — adjust cap live anytime"
1124                EuvSegmented(
1125                    vec![
1126                        "Unlimited".to_string(),
1127                        "30 FPS".to_string(),
1128                        "60 FPS".to_string(),
1129                        "120 FPS".to_string(),
1130                        "144 FPS".to_string(),
1131                        "240 FPS".to_string(),
1132                    ],
1133                    fps_idx,
1134                    tokens
1135                )
1136                text {
1137                    font_size: 13.0
1138                    font_weight: FontWeight::SemiBold
1139                    color: p.get_primary()
1140                    { move || {
1141                            let cap_txt: String = match fps_limit_sig.get() {
1142                                None => "Unlimited (Max FPS)".to_string(),
1143                                Some(v) => format!("Capped at {v} FPS"),
1144                            };
1145                            format!(
1146                                "Frame Rate Policy: {cap_txt} | Live Measured: {:.1} FPS",
1147                                live_fps_sig.get()
1148                            )
1149                    } }
1150                }
1151            }
1152            EuvCard("Cross-Platform Dynamic Island & Notifications".to_string(), tokens) {
1153                subtitle: "Test Live Activities across all 7 platforms and dispatch native OS notifications"
1154                EuvSegmented(
1155                    vec![
1156                        "iOS".to_string(),
1157                        "iPadOS".to_string(),
1158                        LABEL_PLATFORM_ANDROID.to_string(),
1159                        LABEL_PLATFORM_MACOS.to_string(),
1160                        "Windows".to_string(),
1161                        "Linux".to_string(),
1162                        "Web".to_string(),
1163                    ],
1164                    target_plat_idx,
1165                    tokens
1166                )
1167                EuvSegmented(
1168                    vec![
1169                        "Compact".to_string(),
1170                        "Minimal".to_string(),
1171                        "Expanded".to_string(),
1172                        "LockScreen".to_string(),
1173                        "FallbackNotif".to_string(),
1174                        "StatusBar".to_string(),
1175                    ],
1176                    island_mode_idx,
1177                    tokens
1178                )
1179                column {
1180                    width: Length::Percent(100.0)
1181                    padding: Edges::all(SPACE_MD)
1182                    gap: SPACE_XS
1183                    background: Color::hex(0x09090B)
1184                    radius: 20.0
1185                    text {
1186                        font_size: 12.0
1187                        font_weight: FontWeight::SemiBold
1188                        color: Color::hex(0xF8FAFC)
1189                        { move || {
1190                                let tp: PlatformKind = all_platforms[target_plat_idx.get() % 7];
1191                                let im: IslandPresentationMode = all_island_modes[island_mode_idx.get() % 6];
1192                                let def_im: IslandPresentationMode = PlatformServiceHub::default_island_mode(tp);
1193                                let active: bool = island_active.get();
1194                                let pct: u8 = island_progress.get();
1195                                let state_tag: &str = if active { "LIVE" } else { "IDLE" };
1196                                format!(
1197                                    "[{state_tag}] Dynamic Island ({tp:?}) | Mode: {im:?} (OS Default: {def_im:?}) | Progress: {pct}%"
1198                                )
1199                        } }
1200                    }
1201                }
1202                EuvActionRow() {
1203                    EuvButton("Trigger Alert Notification".to_string(), tokens) {
1204                        sm()
1205                        on_click: move |_: &UiEvent| {
1206                            let tp: PlatformKind = all_platforms[target_plat_idx.get_untracked() % 7];
1207                            let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
1208                            let n: SystemNotification = SystemNotification::new(
1209                                "euv-alert".to_string(),
1210                                format!("{tp:?} Alert Notification"),
1211                                "High-priority native OS alert dispatched cleanly".to_string(),
1212                            );
1213                            svc.send_notification(n.clone());
1214                            let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
1215                                    v.insert(0, (n.get_title().clone(), n.get_body().clone()));
1216                                    v.truncate(5);
1217                            });
1218                        }
1219                    }
1220                    EuvButton("Trigger Silent + Badge(3)".to_string(), tokens) {
1221                        secondary()
1222                        sm()
1223                        on_click: move |_: &UiEvent| {
1224                            let tp: PlatformKind = all_platforms[target_plat_idx.get_untracked() % 7];
1225                            let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
1226                            let mut n: SystemNotification = SystemNotification::new(
1227                                "euv-sync".to_string(),
1228                                format!("{tp:?} Silent Sync (Badge 3)"),
1229                                "Background OTA sync completed silently".to_string(),
1230                            );
1231                            n.set_silent(true);
1232                            n.set_badge_count(Some(3));
1233                            svc.send_notification(n.clone());
1234                            let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
1235                                    v.insert(0, (n.get_title().clone(), n.get_body().clone()));
1236                                    v.truncate(5);
1237                            });
1238                        }
1239                    }
1240                    EuvButton("Clear Notifications".to_string(), tokens) {
1241                        outline()
1242                        sm()
1243                        on_click: move |_: &UiEvent| {
1244                            let _: bool = sys_notifs.set_if_changed(Vec::new());
1245                        }
1246                    }
1247                }
1248                EuvSonner(sys_notifs, tokens)
1249            }
1250            EuvCard("Complete 14-Category OS Permissions Matrix".to_string(), tokens) {
1251                subtitle: "Inspect per-platform native entitlement keys and test Grant / Deny flows"
1252                column {
1253                    width: Length::Percent(100.0)
1254                    gap: SPACE_XS
1255                    bind_children: move || {
1256                        let tp: PlatformKind = all_platforms[target_plat_idx.get() % 7];
1257                        let statuses: Vec<PermissionStatus> = perm_statuses.get();
1258                        let g: ThemeGeometry = tokens.get_geometry();
1259                        all_perms
1260                        .iter()
1261                        .copied()
1262                        .enumerate()
1263                        .map(|(idx, perm): (usize, SystemPermission)| {
1264                                let st: PermissionStatus = statuses
1265                                .get(idx)
1266                                .copied()
1267                                .unwrap_or(PermissionStatus::NotDetermined);
1268                                let native_key: &'static str = perm.native_key(tp);
1269                                view! {
1270                                    column {
1271                                        width: Length::Percent(100.0)
1272                                        padding: Edges::symmetric(SPACE_SM, SPACE_SM)
1273                                        gap: SPACE_XS
1274                                        background: p.get_card()
1275                                        border: (g.get_border_width(), p.get_border())
1276                                        radius: g.get_radius_sm()
1277                                        text {
1278                                            width: Length::Percent(100.0)
1279                                            font_size: 12.0
1280                                            color: p.get_foreground()
1281                                            { format!("{perm:?} [{st:?}] · {native_key}") }
1282                                        }
1283                                        EuvActionRow() {
1284                                            EuvButton("Request".to_string(), tokens) {
1285                                                outline()
1286                                                sm()
1287                                                on_click: move |_: &UiEvent| {
1288                                                    let mut mgr: PermissionManager = PermissionManager::new();
1289                                                    let desc: PermissionDescriptor =
1290                                                    mgr.request(perm, format!("Test {perm:?} access"), platform);
1291                                                    let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
1292                                                            if let Some(slot) = vec.get_mut(idx) {
1293                                                                *slot = desc.get_status();
1294                                                            }
1295                                                    });
1296                                                    let _: bool = native_feedback.set(format!(
1297                                                            "Requested {perm:?} ({}) -> {:?}",
1298                                                            perm.native_key(platform),
1299                                                            desc.get_status()
1300                                                    ));
1301                                                }
1302                                            }
1303                                            EuvButton("Deny".to_string(), tokens) {
1304                                                destructive()
1305                                                sm()
1306                                                on_click: move |_: &UiEvent| {
1307                                                    let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
1308                                                            if let Some(slot) = vec.get_mut(idx) {
1309                                                                *slot = PermissionStatus::Denied;
1310                                                            }
1311                                                    });
1312                                                    let _: bool = native_feedback.set(format!("Marked {perm:?} as Denied"));
1313                                                }
1314                                            }
1315                                        }
1316                                    }
1317                                }
1318                        })
1319                        .collect()
1320                    }
1321                }
1322            }
1323        }
1324    };
1325    ctx_win.get_scene().with_write(
1326        |tree: &mut SceneTree| {
1327            tree.attach_scope(body_id, fs_scope);
1328            tree.attach_scope(fps_card_id, fps_scope);
1329        },
1330        (),
1331    );
1332    page
1333}
1334
1335/// Mounts the complete shadcn/ui component showcase and production edge-case regression lab.
1336///
1337/// # Arguments
1338///
1339/// - `&ShowcaseState` - Reactive showcase state.
1340/// - `ThemeTokens` - Active design tokens.
1341///
1342/// # Returns
1343///
1344/// - `NodeId` - Mounted UI & Edge Lab page node.
1345pub fn mount_lab_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1346    let p: ThemePalette = tokens.get_palette();
1347    let g: ThemeGeometry = tokens.get_geometry();
1348    let ctx: Context = current_context();
1349    let chart_data: Vec<EuvChartPoint> = vec![
1350        EuvChartPoint::new("Mon".to_string(), 60.0),
1351        EuvChartPoint::new("Tue".to_string(), 88.0),
1352        EuvChartPoint::new("Wed".to_string(), 118.0),
1353        EuvChartPoint::new("Thu".to_string(), 104.0),
1354        EuvChartPoint::new("Fri".to_string(), 120.0),
1355        EuvChartPoint::new("Sat".to_string(), 116.0),
1356    ];
1357    let left_split: NodeId = view! {
1358        text {
1359            font_size: 13.0
1360            color: p.get_foreground()
1361            "Left Split Pane (Drag handle ->)"
1362        }
1363    };
1364    let right_split: NodeId = view! {
1365        text {
1366            font_size: 13.0
1367            color: p.get_muted_foreground()
1368            "Right Split Pane (Zero rebuild on drag)"
1369        }
1370    };
1371    let rtl_sig: Signal<bool> = state.get_lab_rtl_mode();
1372    let block_scroll: Signal<bool> = state.get_lab_block_scroll_chain();
1373    let stop_bubble: Signal<bool> = state.get_lab_stop_click_bubble();
1374    let parent_clicks: Signal<u32> = state.get_lab_parent_clicks();
1375    let child_clicks: Signal<u32> = state.get_lab_child_clicks();
1376    let preserve_cnt: Signal<u32> = state.get_lab_resize_preserve_count();
1377    let modal_open: Signal<bool> = state.get_modal_open();
1378    let drawer_open: Signal<bool> = state.get_drawer_open();
1379    let attach_vis: Signal<bool> = Signal::new(true);
1380    let q_sel: Signal<Option<usize>> = Signal::new(Some(0));
1381    let touches_sig: Signal<Vec<(u64, Point)>> = ctx.get_active_touches();
1382    let touch_ids_memo: Memo<Vec<u64>> = Memo::new(move || {
1383        touches_sig
1384            .get()
1385            .into_iter()
1386            .map(|(id, _): (u64, Point)| id)
1387            .collect()
1388    });
1389    let ai_tick: Signal<u32> = Signal::new(0);
1390    let ai_fps_sig: Signal<f32> = ctx.get_live_fps();
1391    let ai_route_sig: Signal<String> = state.get_route();
1392    let ai_scheme_sig: Signal<DesignScheme> = state.get_theme().get_scheme();
1393    let mut touch_pad_id: NodeId = NodeId::default();
1394    let page: NodeId = view! {
1395        EuvPage(
1396            "UI & Edge-Case Lab".to_string(),
1397            "Full shadcn/ui component parity + multi-touch, propagation, overlay stack, AI Schema v1, and resize-preservation tests".to_string(),
1398            tokens
1399        ) {
1400            EuvCard("Multi-Touch & Gesture Isolation Pad".to_string(), tokens) {
1401                subtitle: "Simultaneous multi-finger tracking with pointer IDs, pinch distance line, and gesture non-penetration"
1402                text {
1403                    font_size: 12.5
1404                    font_weight: FontWeight::Medium
1405                    color: p.get_primary()
1406                    { move || {
1407                            let ids: Vec<u64> = touch_ids_memo.get();
1408                            if ids.is_empty() {
1409                                TOUCH_PAD_READY_TEXT.to_string()
1410                            } else {
1411                                let labels: String = ids
1412                                .iter()
1413                                .map(|id: &u64| format!("#{id}"))
1414                                .collect::<Vec<String>>()
1415                                .join("  ");
1416                                format!("Active Touches: {}  |  Pointers: {labels}", ids.len())
1417                            }
1418                    } }
1419                }
1420                canvas {
1421                    node_ref: touch_pad_id
1422                    width: Length::Percent(100.0)
1423                    height: Length::Px(170.0)
1424                    background: p.get_muted()
1425                    border: (g.get_border_width(), p.get_border())
1426                    radius: g.get_radius_md()
1427                    stop_scroll_propagation: true
1428                    stop_event_propagation: true
1429                    painter: move |bounds: Rect, dl: &mut DisplayList| {
1430                        let pts: Vec<(u64, Point)> = touches_sig.get_untracked();
1431                        let palette: [Color; 5] = [
1432                            Color::hex(0x2563EB),
1433                            Color::hex(0x16A34A),
1434                            Color::hex(0xEA580C),
1435                            Color::hex(0x9333EA),
1436                            Color::hex(0xDC2626),
1437                        ];
1438                        let inside_pts: Vec<(u64, Point)> = pts
1439                        .into_iter()
1440                        .filter(|(_, pt): &(u64, Point)| bounds.contains(*pt))
1441                        .collect();
1442                        if inside_pts.is_empty() {
1443                            let mut hint_style: TextStyle = TextStyle::default();
1444                            hint_style
1445                            .set_font_size(12.0)
1446                            .set_color(p.get_muted_foreground())
1447                            .set_align(TextAlign::Center);
1448                            dl.push(DrawCommand::TextRun {
1449                                    rect: Rect::new(
1450                                        bounds.get_x() + 12.0,
1451                                        bounds.get_y() + (bounds.get_height() - 18.0) * 0.5,
1452                                        (bounds.get_width() - 24.0).max(1.0),
1453                                        20.0,
1454                                    ),
1455                                    text: TOUCH_PAD_CANVAS_HINT.to_string(),
1456                                    style: hint_style,
1457                            });
1458                            return;
1459                        }
1460                        if inside_pts.len() >= 2 {
1461                            for pair in inside_pts.windows(2) {
1462                                dl.push(DrawCommand::Line {
1463                                        from: pair[0].1,
1464                                        to: pair[1].1,
1465                                        color: p.get_primary().multiply_alpha(0.75),
1466                                        width: 2.0,
1467                                });
1468                            }
1469                        }
1470                        for (idx, (pid, pt)) in inside_pts.iter().enumerate() {
1471                            let col: Color = palette[idx % palette.len()];
1472                            dl.push(DrawCommand::Circle {
1473                                    center: *pt,
1474                                    radius: 26.0,
1475                                    color: col.multiply_alpha(0.24),
1476                            });
1477                            dl.push(DrawCommand::Circle {
1478                                    center: *pt,
1479                                    radius: 10.0,
1480                                    color: col,
1481                            });
1482                            let mut tag_style: TextStyle = TextStyle::default();
1483                            tag_style
1484                            .set_font_size(11.0)
1485                            .set_weight(FontWeight::Bold)
1486                            .set_color(col);
1487                            dl.push(DrawCommand::TextRun {
1488                                    rect: Rect::new(pt.get_x() + 14.0, pt.get_y() - 24.0, 96.0, 16.0),
1489                                    text: format!("#{pid}({:.0},{:.0})", pt.get_x(), pt.get_y()),
1490                                    style: tag_style,
1491                            });
1492                        }
1493                        let mut hud_style: TextStyle = TextStyle::default();
1494                        hud_style
1495                        .set_font_size(11.5)
1496                        .set_weight(FontWeight::Medium)
1497                        .set_color(p.get_foreground());
1498                        dl.push(DrawCommand::TextRun {
1499                                rect: Rect::new(
1500                                    bounds.get_x() + 10.0,
1501                                    bounds.get_y() + 8.0,
1502                                    (bounds.get_width() - 20.0).max(1.0),
1503                                    18.0,
1504                                ),
1505                                text: format!("Live Contacts Inside Pad: {}", inside_pts.len()),
1506                                style: hud_style,
1507                        });
1508                    }
1509                }
1510            }
1511            EuvCard("AI Schema v1 & Reactive Telemetry Bridge".to_string(), tokens) {
1512                subtitle: "Live introspection of SceneTree bounds, A11y tree, reactive graph, FPS, and interactive agent actions"
1513                text {
1514                    width: Length::Percent(100.0)
1515                    font_size: 12.5
1516                    color: p.get_foreground()
1517                    { move || {
1518                            let _: u32 = ai_tick.get();
1519                            let rs: ReactiveStats = reactive_stats();
1520                            #[cfg(debug_assertions)]
1521                            let proto_label: &str = AI_SCHEMA_PROTOCOL_VERSION;
1522                            #[cfg(not(debug_assertions))]
1523                            let proto_label: &str = AI_SCHEMA_RELEASE_STRIPPED;
1524                            let bridge_label: &str = if DevAutomationBridge::is_enabled() {
1525                                AI_BRIDGE_STATUS_ACTIVE
1526                            } else {
1527                                AI_BRIDGE_STATUS_OFF
1528                            };
1529                            format!(
1530                                "Protocol: {} ({}) | Route: {} | Scheme: {} | Live FPS: {:.1} | Signals: {} | Memos: {} | Effects: {} | Scopes: {} | Clock: {}",
1531                                proto_label,
1532                                bridge_label,
1533                                ai_route_sig.get(),
1534                                ai_scheme_sig.get().as_str(),
1535                                ai_fps_sig.get(),
1536                                rs.get_live_signals(),
1537                                rs.get_live_memos(),
1538                                rs.get_live_effects(),
1539                                rs.get_live_scopes(),
1540                                rs.get_clock()
1541                            )
1542                    } }
1543                }
1544                EuvActionRow() {
1545                    EuvButton("Refresh AI Telemetry".to_string(), tokens) {
1546                        outline()
1547                        sm()
1548                        on_click: move |_: &UiEvent| {
1549                            let _: bool = ai_tick.update(|v: &mut u32| *v = v.wrapping_add(1));
1550                        }
1551                    }
1552                }
1553                EuvCodeBlock(
1554                    "GET /ai/schema | /ai/snapshot | /ai/a11y | /ai/health\nPOST /ai/query | /ai/action | /ai/script (dev-only; 0B in release)".to_string(),
1555                    tokens
1556                )
1557            }
1558            EuvCard("Complete shadcn/ui Component Parity".to_string(), tokens) {
1559                subtitle: "Trace, Attachment, Bubble, Marker, Questionnaire, Chart, Combobox, DataTable, DatePicker, InputGroup, Item, NativeSelect, NavigationMenu, Resizable, Separator, Direction, Avatar, Kbd, Spinner, Skeleton, Breadcrumb, Empty"
1560                row {
1561                    style: c_action_row()
1562                    EuvMarker("01".to_string(), "Zero WebView".to_string(), EuvTone::Primary, tokens)
1563                    EuvMarker("02".to_string(), "120+ FPS".to_string(), EuvTone::Success, tokens)
1564                    EuvMarker("03".to_string(), "Multi-Touch".to_string(), EuvTone::Warning, tokens)
1565                    EuvAvatar("EU".to_string(), 32.0, tokens)
1566                    EuvKbd("Cmd+K".to_string(), tokens)
1567                    EuvSpinner(18.0, tokens)
1568                }
1569                EuvTrace(
1570                    "Frame Pipeline Trace (1.42ms Total)".to_string(),
1571                    vec![
1572                        EuvTraceSpan::new("layout.compute".to_string(), 0.14, 0.0, 0.12, EuvTone::Primary),
1573                        EuvTraceSpan::new("bvh.raytrace_gi".to_string(), 0.88, 0.12, 0.60, EuvTone::Success),
1574                        EuvTraceSpan::new("fxaa.tonemap".to_string(), 0.24, 0.72, 0.16, EuvTone::Warning),
1575                        EuvTraceSpan::new("present.blit".to_string(), 0.16, 0.88, 0.12, EuvTone::Neutral),
1576                    ],
1577                    tokens
1578                )
1579                EuvAttachment(
1580                    "vice-boulevard-rt.wasm".to_string(),
1581                    "48.2 KB · application/wasm · SHA-verified".to_string(),
1582                    attach_vis,
1583                    tokens
1584                )
1585                EuvBubble(
1586                    "Euv Runtime".to_string(),
1587                    "All 60+ shadcn/ui components rendered directly via Rust SceneTree with zero WebView.".to_string(),
1588                    tokens
1589                ) {
1590                    timestamp: "09:41"
1591                }
1592                EuvBubble(
1593                    "Developer".to_string(),
1594                    "Verify multi-touch, text wrapping, blinking input caret & uncapped FPS live!".to_string(),
1595                    tokens
1596                ) {
1597                    timestamp: "09:42"
1598                    outgoing: true
1599                }
1600                EuvQuestionnaire(
1601                    "Preferred native target deployment pipeline?".to_string(),
1602                    vec![
1603                        "Universal Native (Android + iOS + Desktop + Web)".to_string(),
1604                        "Dynamic OTA .wasm Hot-Swap Modules".to_string(),
1605                        "Embedded 3D Ray-Traced Engine Viewport".to_string(),
1606                    ],
1607                    q_sel,
1608                    tokens
1609                )
1610                EuvNavigationMenu(
1611                    vec![
1612                        (
1613                            "Architecture".to_string(),
1614                            "Arena signals + deterministic Flexbox/Grid + retained scene graph.".to_string(),
1615                        ),
1616                        (
1617                            "3D Engine".to_string(),
1618                            "PBR metallic-roughness + BVH ray-traced shadows/reflections + FXAA.".to_string(),
1619                        ),
1620                        (
1621                            "Media Suite".to_string(),
1622                            "Pure-Rust Image, SVG, GIF, LIVE Photo, Video, WAV Audio, PDF, HTML.".to_string(),
1623                        ),
1624                    ],
1625                    state.get_lab_nav_menu_active(),
1626                    tokens
1627                )
1628                EuvChart("Frame Rate Telemetry (Bar)".to_string(), EuvChartKind::Bar, chart_data.clone(), tokens)
1629                EuvChart("3D Ray-Tracing Throughput (Area)".to_string(), EuvChartKind::Area, chart_data, tokens)
1630                EuvCombobox(
1631                    vec![
1632                        "euv Native Rust".to_string(),
1633                        "WebAssembly Zero-JS".to_string(),
1634                        "Android ARM64 JNI".to_string(),
1635                        "iOS CoreText Metal".to_string(),
1636                        "macOS AppKit Retina".to_string(),
1637                    ],
1638                    state.get_lab_combobox_selected(),
1639                    state.get_lab_combobox_open(),
1640                    tokens
1641                ) {
1642                    query: state.get_lab_combobox_query()
1643                    placeholder: "Filter frameworks..."
1644                }
1645                EuvDatePicker(LABEL_CALENDAR_MONTH.to_string(), state.get_lab_date_day(), state.get_lab_date_open(), tokens)
1646                EuvInputGroup(state.get_lab_input_group_val(), tokens) {
1647                    prefix: "https://"
1648                    placeholder: "subdomain"
1649                    suffix: ".euv.dev"
1650                }
1651                EuvNativeSelect(
1652                    vec![
1653                        "60 Hz Standard".to_string(),
1654                        "120 Hz ProMotion".to_string(),
1655                        "Unlocked Benchmark".to_string(),
1656                    ],
1657                    state.get_lab_native_select_idx(),
1658                    tokens
1659                )
1660                EuvDataTable(
1661                    vec!["Target".to_string(), "Font Engine".to_string(), "Status".to_string()],
1662                    vec![
1663                        vec![LABEL_PLATFORM_ANDROID.to_string(), "Skia Paint AA".to_string(), "1:1 DPI".to_string()],
1664                        vec!["iOS / iPadOS".to_string(), "CoreText @3x".to_string(), "ProMotion".to_string()],
1665                        vec![LABEL_PLATFORM_MACOS.to_string(), "CoreText Retina".to_string(), "Live Resize".to_string()],
1666                        vec!["WebAssembly".to_string(), "Canvas2D AA".to_string(), "Zero-JS".to_string()],
1667                    ],
1668                    tokens
1669                ) {
1670                    filter: state.get_lab_table_filter()
1671                    sort_ascending: state.get_lab_table_sort_asc()
1672                    selected_row: state.get_lab_table_selected()
1673                }
1674                EuvResizable(left_split, right_split, state.get_lab_split_ratio(), tokens)
1675                EuvItem("Production shadcn/ui Alignment".to_string(), tokens) {
1676                    leading: "EU"
1677                    description: "Unified layout grammar across all 17 design schemes with per-theme surface/radius tokens"
1678                    trailing: "v0.39"
1679                }
1680                column {
1681                    width: Length::Percent(100.0)
1682                    gap: SPACE_SM
1683                    EuvBreadcrumb(
1684                        vec!["Euv Studio".to_string(), "Design System".to_string(), "Components".to_string()],
1685                        tokens
1686                    ) {
1687                        active: state.get_breadcrumb_active()
1688                    }
1689                    EuvTypography("Unified shadcn/ui Typography & Surface Tokens".to_string(), EuvTypographyVariant::H3, tokens)
1690                    EuvSkeleton(260.0, 18.0, tokens)
1691                    EuvEmpty(
1692                        "No Pending Warnings".to_string(),
1693                        "All layout, scroll, shadow and typography checks passed.".to_string(),
1694                        tokens
1695                    )
1696                }
1697            }
1698            EuvCard("Boundary & Event Penetration Regression Lab".to_string(), tokens) {
1699                subtitle: "Verify scroll lock, flexible event bubbling, overlay back stack, RTL alignment, and zero-rebuild resize preservation"
1700                EuvSeparator("EDGE-CASE REGRESSION SUITE".to_string(), tokens)
1701                column {
1702                    width: Length::Percent(100.0)
1703                    bind_children: move || {
1704                        let dir: EuvTextDirection = if rtl_sig.get() {
1705                            EuvTextDirection::Rtl
1706                        } else {
1707                            EuvTextDirection::Ltr
1708                        };
1709                        vec![view! {
1710                                EuvDirection(
1711                                    dir,
1712                                    view! {
1713                                        text {
1714                                            font_size: 13.0
1715                                            color: p.get_foreground()
1716                                            { format!("Direction preview ({dir:?}): Unified layout alignment across LTR & RTL") }
1717                                        }
1718                                    },
1719                                    tokens
1720                                )
1721                        }]
1722                    }
1723                }
1724                column {
1725                    width: Length::Percent(100.0)
1726                    gap: SPACE_XS
1727                    EuvSwitch(block_scroll, "Lock Scroll Penetration".to_string(), tokens)
1728                    EuvSwitch(stop_bubble, "Stop Click Bubbling".to_string(), tokens)
1729                    EuvSwitch(rtl_sig, "RTL Direction".to_string(), tokens)
1730                }
1731                EuvActionRow() {
1732                    EuvButton("Increment Preserved Counter".to_string(), tokens) {
1733                        sm()
1734                        on_click: move |_: &UiEvent| {
1735                            let _: bool = preserve_cnt.update(|v: &mut u32| *v += 1);
1736                        }
1737                    }
1738                    EuvButton("Open Stacked Modal + Drawer".to_string(), tokens) {
1739                        secondary()
1740                        sm()
1741                        on_click: move |_: &UiEvent| {
1742                            let _: bool = modal_open.set_if_changed(true);
1743                            let _: bool = drawer_open.set_if_changed(true);
1744                        }
1745                    }
1746                    EuvButton("Dismiss Top Overlay (Back)".to_string(), tokens) {
1747                        outline()
1748                        sm()
1749                        on_click: move |_: &UiEvent| {
1750                            let _: bool = EuvOverlayStack::dismiss_top();
1751                        }
1752                    }
1753                }
1754                text {
1755                    font_size: 12.0
1756                    color: p.get_muted_foreground()
1757                    { move || format!(
1758                            "Inner Clicks: {} | Outer Parent Clicks: {} | Resize-Preserved Counter: {} | Overlay Stack Depth: {}",
1759                            child_clicks.get(),
1760                            parent_clicks.get(),
1761                            preserve_cnt.get(),
1762                            EuvOverlayStack::active_count()
1763                    ) }
1764                }
1765                column {
1766                    width: Length::Percent(100.0)
1767                    bind_children: move || {
1768                        let locked: bool = block_scroll.get();
1769                        let stop_clk: bool = stop_bubble.get();
1770                        vec![view! {
1771                                column {
1772                                    width: Length::Percent(100.0)
1773                                    padding: Edges::all(SPACE_MD)
1774                                    gap: SPACE_SM
1775                                    background: p.get_muted()
1776                                    border: (g.get_border_width(), p.get_border())
1777                                    radius: g.get_radius_md()
1778                                    on_click: move |_: &UiEvent| {
1779                                        let _: bool = parent_clicks.update(|v: &mut u32| *v += 1);
1780                                    }
1781                                    scroll {
1782                                        width: Length::Percent(100.0)
1783                                        height: Length::Px(110.0)
1784                                        padding: Edges::all(SPACE_SM)
1785                                        gap: SPACE_XS
1786                                        background: p.get_card()
1787                                        border: (g.get_border_width(), p.get_border())
1788                                        radius: g.get_radius_sm()
1789                                        stop_scroll_propagation: locked
1790                                        stop_event_propagation: stop_clk
1791                                        for row_i in 1..=8 {
1792                                            text {
1793                                                font_size: 12.0
1794                                                color: p.get_foreground()
1795                                                { format!("Nested Scroll Row #{row_i} (scroll_lock={locked}, stop_bubble={stop_clk})") }
1796                                            }
1797                                        }
1798                                    }
1799                                    EuvActionRow() {
1800                                        EuvButton("Click Inner Target".to_string(), tokens) {
1801                                            secondary()
1802                                            sm()
1803                                            on_click: move |_: &UiEvent| {
1804                                                let _: bool = child_clicks.update(|v: &mut u32| *v += 1);
1805                                            }
1806                                        }
1807                                    }
1808                                }
1809                        }]
1810                    }
1811                }
1812            }
1813        }
1814    };
1815    let touch_handle: SceneHandle = ctx.get_scene().clone();
1816    let (touch_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
1817        Effect::new(move || {
1818            let _: Vec<(u64, Point)> = touches_sig.get();
1819            touch_handle.mark_dirty(touch_pad_id, DIRTY_PAINT);
1820        })
1821    });
1822    ctx.get_scene().with_write(
1823        |tree: &mut SceneTree| {
1824            tree.attach_scope(touch_pad_id, touch_scope);
1825        },
1826        (),
1827    );
1828    page
1829}
1830
1831/// Mounts the comprehensive interactive forms showcase covering inputs, steppers, radios, sliders, ratings, toggles, switches, and checkboxes.
1832///
1833/// # Arguments
1834///
1835/// - `&ShowcaseState` - Reactive showcase state.
1836/// - `ThemeTokens` - Active design tokens.
1837///
1838/// # Returns
1839///
1840/// - `NodeId` - Mounted forms page node.
1841pub fn mount_forms_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1842    let p: ThemePalette = tokens.get_palette();
1843    let username: Signal<String> = state.get_username();
1844    let stepper: Signal<i64> = state.get_stepper_value();
1845    let rating: Signal<usize> = state.get_rating_value();
1846    let cal_day: Signal<u32> = state.get_calendar_day();
1847    let picker_color: Signal<Color> = state.get_picker_color();
1848    let picker_time: Signal<(u8, u8)> = state.get_picker_time();
1849    let tag_items: Signal<Vec<String>> = state.get_tag_items();
1850    let input_node: NodeId = view! {
1851        EuvInput(username, PLACEHOLDER_USERNAME.to_string(), tokens)
1852    };
1853    let collapsible_body: NodeId = view! {
1854        text {
1855            font_size: 13.0
1856            color: p.get_muted_foreground()
1857            "shadcn/ui Collapsible disclosure panel adapts across Mobile, Tablet, and Desktop."
1858        }
1859    };
1860    view! {
1861        EuvPage(FORMS_TITLE.to_string(), FORMS_SUBTITLE.to_string(), tokens) {
1862            EuvCard(FORMS_CARD_TITLE.to_string(), tokens) {
1863                subtitle: FORMS_CARD_SUB
1864                column {
1865                    gap: SPACE_MD
1866                    EuvTabs(
1867                        vec![TAB_GENERAL.to_string(), TAB_GRAPHICS.to_string(), TAB_SECURITY.to_string()],
1868                        state.get_active_tab(),
1869                        tokens
1870                    )
1871                    EuvField(FIELD_USERNAME.to_string(), input_node, tokens)
1872                    EuvTextarea(state.get_bio(), "Write notes...".to_string(), 54.0, tokens)
1873                    row {
1874                        style: c_action_row()
1875                        EuvNumberInput(stepper, tokens) {
1876                            range(0, 20)
1877                            step: 1
1878                        }
1879                        EuvToggle(state.get_pin_toggled(), "Pin Config".to_string(), tokens)
1880                        EuvRating(rating, 5, tokens)
1881                    }
1882                    EuvRadioGroup(
1883                        vec!["Software CPU".to_string(), "Hardware GPU".to_string(), "Hybrid".to_string()],
1884                        state.get_radio_index(),
1885                        tokens
1886                    )
1887                    EuvSlider(state.get_slider_value(), 0.0, 100.0, tokens)
1888                    EuvSelect(
1889                        vec!["Metal".to_string(), "Vulkan".to_string(), "Direct3D 12".to_string(), "WebGPU".to_string()],
1890                        state.get_select_index(),
1891                        state.get_select_open(),
1892                        tokens
1893                    )
1894                    EuvSwitch(state.get_hardware_accel(), SWITCH_HW_LABEL.to_string(), tokens)
1895                    EuvCheckbox(state.get_agree_terms(), CHECKBOX_TERMS_LABEL.to_string(), tokens)
1896                    text {
1897                        font_size: 12.0
1898                        color: p.get_muted_foreground()
1899                        { move || format!("Handle: {} | Stepper: {} | Stars: {}/5 | Day: {}", username.get(), stepper.get(), rating.get(), cal_day.get()) }
1900                    }
1901                    EuvActionRow() {
1902                        EuvButton(BTN_PRIMARY_LABEL.to_string(), tokens)
1903                        EuvButton(BTN_SECONDARY_LABEL.to_string(), tokens) { secondary() }
1904                        EuvButton(BTN_OUTLINE_LABEL.to_string(), tokens) { outline() }
1905                        EuvButton(BTN_DESTRUCTIVE_LABEL.to_string(), tokens) {
1906                            destructive()
1907                            on_click: move |_: &UiEvent| {
1908                                let _: bool = username.set_if_changed(DEFAULT_USERNAME.to_string());
1909                            }
1910                        }
1911                    }
1912                }
1913            }
1914            EuvCard("shadcn/ui Extended Form Controls".to_string(), tokens) {
1915                subtitle: FORMS_EXT_CARD_SUB
1916                column {
1917                    gap: SPACE_MD
1918                    EuvToggleGroup(
1919                        vec!["Bold".to_string(), "Italic".to_string(), "Underline".to_string()],
1920                        state.get_toggle_group_index(),
1921                        tokens
1922                    )
1923                    EuvInputOtp(state.get_otp_code(), 6, tokens)
1924                    EuvColorPicker(picker_color, tokens)
1925                    EuvTimePicker(picker_time, tokens)
1926                    EuvTagInput(tag_items, tokens) {
1927                        placeholder: TAG_INPUT_PLACEHOLDER
1928                    }
1929                    text {
1930                        font_size: 12.0
1931                        color: p.get_muted_foreground()
1932                        { move || {
1933                                let c: Color = picker_color.get();
1934                                let (hh, mm): (u8, u8) = picker_time.get();
1935                                format!(
1936                                    "Color: #{:02X}{:02X}{:02X} | Time: {:02}:{:02} | Tags: {}",
1937                                    c.get_r(),
1938                                    c.get_g(),
1939                                    c.get_b(),
1940                                    hh,
1941                                    mm,
1942                                    tag_items.get().len()
1943                                )
1944                        } }
1945                    }
1946                    EuvCalendar(LABEL_CALENDAR_MONTH.to_string(), 30, state.get_calendar_day(), tokens)
1947                    EuvCollapsible(state.get_collapsible_open(), "Advanced Form Details".to_string(), collapsible_body, tokens)
1948                }
1949            }
1950        }
1951    }
1952}
1953
1954/// Mounts the 17-scheme live design token gallery where every scheme button switches the active app theme live.
1955///
1956/// # Arguments
1957///
1958/// - `&ShowcaseState` - Reactive showcase state.
1959/// - `ThemeTokens` - Active design tokens.
1960///
1961/// # Returns
1962///
1963/// - `NodeId` - Mounted themes page node.
1964pub fn mount_themes_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1965    let p: ThemePalette = tokens.get_palette();
1966    let scheme_sig: Signal<DesignScheme> = state.get_theme().get_scheme();
1967    let mode_sig: Signal<ThemeMode> = state.get_theme().get_mode();
1968    let state_for_cycle: ShowcaseState = state.clone();
1969    let state_for_mode: ShowcaseState = state.clone();
1970    let scheme_cols: u16 = match use_breakpoint().get_untracked() {
1971        Breakpoint::Compact => 2,
1972        Breakpoint::Medium => 3,
1973        Breakpoint::Expanded => 4,
1974    };
1975    let all_schemes: [DesignScheme; 17] = DesignScheme::all();
1976    let cur_mode: ThemeMode = mode_sig.get_untracked();
1977    view! {
1978        EuvPage(THEMES_TITLE.to_string(), THEMES_SUBTITLE.to_string(), tokens) {
1979            EuvCard(THEMES_CARD_TITLE.to_string(), tokens) {
1980                subtitle: THEMES_CARD_SUB
1981                column {
1982                    gap: SPACE_MD
1983                    text {
1984                        font_size: 15.0
1985                        font_weight: FontWeight::SemiBold
1986                        color: p.get_foreground()
1987                        { move || format!("{PREFIX_ACTIVE_SCHEME}{} ({:?})", scheme_sig.get().as_str(), mode_sig.get()) }
1988                    }
1989                    EuvActionRow() {
1990                        EuvButton(BTN_NEXT_SCHEME.to_string(), tokens) {
1991                            on_click: move |_: &UiEvent| {
1992                                state_for_cycle.next_scheme();
1993                            }
1994                        }
1995                        EuvButton(BTN_TOGGLE_MODE.to_string(), tokens) {
1996                            outline()
1997                            on_click: move |_: &UiEvent| {
1998                                state_for_mode.toggle_theme_mode();
1999                            }
2000                        }
2001                    }
2002                    grid {
2003                        style: c_scheme_grid()
2004                        columns: scheme_cols
2005                        for scheme in all_schemes.iter().copied() {
2006                            EuvButton(scheme.as_str().to_string(), ThemeTokens::resolve(scheme, cur_mode)) {
2007                                sm()
2008                                on_click: move |_: &UiEvent| {
2009                                    let _: bool = scheme_sig.set_if_changed(scheme);
2010                                }
2011                            }
2012                        }
2013                    }
2014                }
2015            }
2016        }
2017    }
2018}
2019
2020/// Mounts the reactive 10,000-row virtualized scrollable list plus pagination, steps, accordion, and progress.
2021///
2022/// # Arguments
2023///
2024/// - `&ShowcaseState` - Reactive showcase state.
2025/// - `ThemeTokens` - Active design tokens.
2026///
2027/// # Returns
2028///
2029/// - `NodeId` - Mounted data display page node.
2030pub fn mount_data_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2031    let p: ThemePalette = tokens.get_palette();
2032    let g: ThemeGeometry = tokens.get_geometry();
2033    let scroll_y: Signal<f32> = state.get_list_scroll_y();
2034    let vlist: EuvVirtualList =
2035        EuvVirtualList::new(10_000, 32.0, scroll_y, tokens).viewport_height(224.0);
2036    let vlist_down: EuvVirtualList = vlist.clone();
2037    let list_node: NodeId = vlist.mount_with(move |idx: usize| {
2038        view! {
2039            row {
2040                width: Length::Percent(100.0)
2041                height: Length::Px(32.0)
2042                padding: Edges::symmetric(SPACE_XS, SPACE_MD)
2043                align: AlignItems::Center
2044                border: (g.get_border_width(), p.get_border())
2045                text {
2046                    font_size: 13.0
2047                    color: p.get_foreground()
2048                    { format!("{ROW_PREFIX}{idx}") }
2049                }
2050            }
2051        }
2052    });
2053    let aspect_inner: NodeId = view! {
2054        column {
2055            align: AlignItems::Center
2056            gap: SPACE_XS
2057            text {
2058                font_size: 14.0
2059                font_weight: FontWeight::SemiBold
2060                color: p.get_foreground()
2061                "16:9 shadcn AspectRatio"
2062            }
2063            text {
2064                font_size: 12.0
2065                color: p.get_muted_foreground()
2066                "Responsive container locked to 16:9 ratio"
2067            }
2068        }
2069    };
2070    let tree_sel: Signal<Option<String>> = state.get_tree_selected();
2071    view! {
2072        EuvPage(DATA_TITLE.to_string(), DATA_SUBTITLE.to_string(), tokens) {
2073            EuvCard(DATA_CARD_TITLE.to_string(), tokens) {
2074                subtitle: DATA_CARD_SUB
2075                column {
2076                    gap: SPACE_MD
2077                    EuvMenubar(
2078                        vec!["File".to_string(), "Edit".to_string(), "View".to_string(), "Profiles".to_string()],
2079                        state.get_menubar_active(),
2080                        tokens
2081                    )
2082                    row {
2083                        style: c_action_row()
2084                        EuvBadge(BADGE_READY.to_string(), EuvTone::Success, tokens)
2085                        EuvBadge(BADGE_LIVE.to_string(), EuvTone::Primary, tokens)
2086                    }
2087                    EuvActionRow() {
2088                        EuvButton(BTN_SCROLL_DOWN.to_string(), tokens) {
2089                            on_click: move |_: &UiEvent| {
2090                                vlist_down.scroll_by(160.0);
2091                            }
2092                        }
2093                        EuvButton(BTN_SCROLL_TOP.to_string(), tokens) {
2094                            outline()
2095                            on_click: move |_: &UiEvent| {
2096                                let _: bool = scroll_y.set_if_changed(0.0);
2097                            }
2098                        }
2099                    }
2100                    text {
2101                        font_size: 12.0
2102                        color: p.get_muted_foreground()
2103                        { move || format!("scroll_y={:.0}px | top_row=#{}", scroll_y.get(), (scroll_y.get() / 32.0).floor() as usize) }
2104                    }
2105                    EuvProgress(0.84, tokens)
2106                    { list_node }
2107                    EuvCommand(
2108                        vec!["Switch to Dark Mode".to_string(), "Open OTA Updates".to_string(), "Run Physics Tick".to_string()],
2109                        state.get_command_selected(),
2110                        tokens
2111                    ) {
2112                        query: state.get_command_query()
2113                        placeholder: "Search commands..."
2114                    }
2115                    EuvCarousel(
2116                        vec![
2117                            "Slide 1: Native Metal & Vulkan".to_string(),
2118                            "Slide 2: Complete shadcn/ui Parity".to_string(),
2119                            "Slide 3: Instant Responsive Resize".to_string(),
2120                        ],
2121                        state.get_carousel_index(),
2122                        tokens
2123                    )
2124                    column {
2125                        width: Length::Percent(100.0)
2126                        max_width: Length::Px(360.0)
2127                        EuvAspectRatio(16.0 / 9.0, aspect_inner, tokens)
2128                    }
2129                    EuvPagination(state.get_page_index(), 12, tokens)
2130                    EuvSteps(
2131                        vec!["Layout".to_string(), "Paint".to_string(), "Present".to_string()],
2132                        state.get_step_index(),
2133                        tokens
2134                    )
2135                    EuvTree(
2136                        vec![EuvTreeNode::new(
2137                                TREE_NODE_WORKSPACE.to_string(),
2138                                vec![
2139                                    EuvTreeNode::new(
2140                                        TREE_NODE_CORE.to_string(),
2141                                        vec![
2142                                            EuvTreeNode::new(TREE_NODE_RENDER.to_string(), Vec::new()),
2143                                            EuvTreeNode::new(TREE_NODE_REACTIVE.to_string(), Vec::new()),
2144                                        ],
2145                                    ),
2146                                    EuvTreeNode::new(TREE_NODE_UI.to_string(), Vec::new()),
2147                                    EuvTreeNode::new(TREE_NODE_PERF.to_string(), Vec::new()),
2148                                ],
2149                        )],
2150                        tokens
2151                    ) {
2152                        selected: state.get_tree_selected()
2153                    }
2154                    text {
2155                        font_size: 12.0
2156                        color: p.get_muted_foreground()
2157                        { move || {
2158                                let cur: String = tree_sel
2159                                .get()
2160                                .unwrap_or_else(|| TREE_NONE_SELECTED.to_string());
2161                                format!("{TREE_SELECTED_PREFIX}: {cur}")
2162                        } }
2163                    }
2164                    EuvAccordion(
2165                        vec![EuvAccordionItem::new(
2166                                "Virtualization".to_string(),
2167                                "Only visible rows + overscan are materialized in O(visible).".to_string(),
2168                        )],
2169                        state.get_accordion_open(),
2170                        tokens
2171                    )
2172                }
2173            }
2174        }
2175    }
2176}
2177
2178/// Mounts the embedded 2D physics game engine viewport and reactive HUD overlay page.
2179///
2180/// # Arguments
2181///
2182/// - `&ShowcaseState` - Reactive showcase state.
2183/// - `ThemeTokens` - Active design tokens.
2184///
2185/// # Returns
2186///
2187/// - `NodeId` - Mounted game engine showcase page node.
2188pub fn mount_game_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2189    let g: ThemeGeometry = tokens.get_geometry();
2190    let p: ThemePalette = tokens.get_palette();
2191    let host: GameEngineHost = state.get_game_host().clone();
2192    let host_btn: GameEngineHost = host.clone();
2193    let host_wave: GameEngineHost = host.clone();
2194    let host_left: GameEngineHost = host.clone();
2195    let host_up: GameEngineHost = host.clone();
2196    let host_down: GameEngineHost = host.clone();
2197    let host_right: GameEngineHost = host.clone();
2198    let host_dash: GameEngineHost = host.clone();
2199    let viewport: NodeId = host.mount_viewport(
2200        Style::default()
2201            .width(Length::Percent(100.0))
2202            .height(Length::Px(340.0))
2203            .border(g.get_border_width(), p.get_border())
2204            .radius(g.get_radius_md()),
2205    );
2206    let fs_2d_open: Signal<bool> = Signal::new(false);
2207    let fs_2d_portal: NodeId =
2208        mount_game_fullscreen_portal(fs_2d_open, &host, "2D Physics Arena", tokens);
2209    view! {
2210        EuvPage(GAME_TITLE.to_string(), GAME_SUBTITLE.to_string(), tokens) {
2211            EuvCard(GAME_CARD_TITLE.to_string(), tokens) {
2212                subtitle: GAME_CARD_SUB
2213                column {
2214                    gap: SPACE_MD
2215                    EuvActionRow() {
2216                        EuvButton(BTN_STEP_PHYSICS.to_string(), tokens) {
2217                            sm()
2218                            on_click: move |_: &UiEvent| {
2219                                let _: u32 = host_btn.step(0.051);
2220                            }
2221                        }
2222                        EuvButton("Spawn Enemy Wave".to_string(), tokens) {
2223                            outline()
2224                            sm()
2225                            on_click: move |_: &UiEvent| {
2226                                host_wave.ingest_event(&WindowEvent::KeyDown(
2227                                        WindowId::new(1),
2228                                        KeyEvent::new(KeyCode::Character('r'), Modifiers::default(), false),
2229                                ));
2230                                let _: u32 = host_wave.step(1.0 / 60.0);
2231                                host_wave.ingest_event(&WindowEvent::KeyUp(
2232                                        WindowId::new(1),
2233                                        KeyEvent::new(KeyCode::Character('r'), Modifiers::default(), false),
2234                                ));
2235                            }
2236                        }
2237                    }
2238                    { viewport }
2239                    EuvActionRow() {
2240                        EuvButton("Left (A)".to_string(), tokens) {
2241                            outline()
2242                            sm()
2243                            on_click: move |_: &UiEvent| {
2244                                pulse_game_key(&host_left, KeyCode::ArrowLeft);
2245                            }
2246                        }
2247                        EuvButton("Up (W)".to_string(), tokens) {
2248                            outline()
2249                            sm()
2250                            on_click: move |_: &UiEvent| {
2251                                pulse_game_key(&host_up, KeyCode::ArrowUp);
2252                            }
2253                        }
2254                        EuvButton("Down (S)".to_string(), tokens) {
2255                            outline()
2256                            sm()
2257                            on_click: move |_: &UiEvent| {
2258                                pulse_game_key(&host_down, KeyCode::ArrowDown);
2259                            }
2260                        }
2261                        EuvButton("Right (D)".to_string(), tokens) {
2262                            outline()
2263                            sm()
2264                            on_click: move |_: &UiEvent| {
2265                                pulse_game_key(&host_right, KeyCode::ArrowRight);
2266                            }
2267                        }
2268                        EuvButton("Dash (E)".to_string(), tokens) {
2269                            secondary()
2270                            sm()
2271                            on_click: move |_: &UiEvent| {
2272                                pulse_game_key(&host_dash, KeyCode::Character('e'));
2273                            }
2274                        }
2275                        EuvButton("Fullscreen".to_string(), tokens) {
2276                            sm()
2277                            on_click: move |_: &UiEvent| {
2278                                let _: bool = fs_2d_open.set_if_changed(true);
2279                            }
2280                        }
2281                    }
2282                    { fs_2d_portal }
2283                }
2284            }
2285        }
2286    }
2287}
2288
2289/// Mounts a reusable fullscreen portal overlay hosting any 2D/3D `GameEngineHost` with safe exit & Back support.
2290///
2291/// # Arguments
2292///
2293/// - `Signal<bool>` - Fullscreen visibility toggle signal.
2294/// - `&GameEngineHost` - Target game engine host.
2295/// - `&str` - Title shown in the fullscreen HUD bar.
2296/// - `ThemeTokens` - Active design tokens.
2297///
2298/// # Returns
2299///
2300/// - `NodeId` - Mounted fullscreen portal handle.
2301fn mount_game_fullscreen_portal(
2302    open: Signal<bool>,
2303    host: &GameEngineHost,
2304    title: &str,
2305    tokens: ThemeTokens,
2306) -> NodeId {
2307    let ctx: Context = current_context();
2308    let fs_viewport: NodeId = host.mount_viewport(
2309        Style::default()
2310            .flex_grow(1.0)
2311            .width(Length::Percent(100.0))
2312            .height(Length::Percent(100.0))
2313            .stop_scroll_propagation(true)
2314            .stop_event_propagation(true),
2315    );
2316    let mut top_bar_id: NodeId = NodeId::default();
2317    let portal: NodeId = view! {
2318        portal {
2319            display: Display::None
2320            position: Position::Fixed
2321            inset: (Some(0.0), Some(0.0), Some(0.0), Some(0.0))
2322            width: Length::Percent(100.0)
2323            height: Length::Percent(100.0)
2324            background: Color::hex(0x09090B)
2325            stop_scroll_propagation: true
2326            z_index: Z_INDEX_MODAL
2327            row {
2328                node_ref: top_bar_id
2329                width: Length::Percent(100.0)
2330                justify: JustifyContent::SpaceBetween
2331                align: AlignItems::Center
2332                padding: Edges::symmetric(SPACE_SM, SPACE_MD)
2333                background: Color::rgba(9, 9, 11, 220)
2334                text {
2335                    font_size: 14.0
2336                    font_weight: FontWeight::SemiBold
2337                    color: Color::hex(0xFAFAFA)
2338                    { format!("{title} · Fullscreen") }
2339                }
2340                EuvButton("Exit Fullscreen".to_string(), tokens) {
2341                    secondary()
2342                    sm()
2343                    on_click: move |_: &UiEvent| {
2344                        let _: bool = open.set_if_changed(false);
2345                    }
2346                }
2347            }
2348            { fs_viewport }
2349        }
2350    };
2351    let handle: SceneHandle = ctx.get_scene().clone();
2352    let safe_sig: Signal<SafeAreaInsets> = ctx.get_safe_area();
2353    let prev_fs: Rc<Cell<bool>> = Rc::new(Cell::new(false));
2354    let (scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
2355        let _: Effect = EuvOverlayStack::bind_signal(open, "GameFullscreenPortal", Z_INDEX_MODAL);
2356        Effect::new(move || {
2357            let is_open: bool = open.get();
2358            let safe: SafeAreaInsets = safe_sig.get();
2359            if is_open != prev_fs.replace(is_open) {
2360                let _: bool = dispatch_native_action(
2361                    NATIVE_ACTION_FULLSCREEN,
2362                    if is_open { "on" } else { "off" },
2363                    "",
2364                );
2365            }
2366            handle.with_write(
2367                |tree: &mut SceneTree| {
2368                    if let Some(n) = tree.get_node_mut(portal) {
2369                        let mut st: Style = n.get_style();
2370                        st.get_mut_layout().set_display(if is_open {
2371                            Display::Flex
2372                        } else {
2373                            Display::None
2374                        });
2375                        n.set_style(st);
2376                    }
2377                    if let Some(n) = tree.get_node_mut(top_bar_id) {
2378                        let mut st: Style = n.get_style();
2379                        st.get_mut_layout().set_padding(Edges::new(
2380                            SPACE_SM + safe.get_top(),
2381                            SPACE_MD + safe.get_right(),
2382                            SPACE_SM,
2383                            SPACE_MD + safe.get_left(),
2384                        ));
2385                        n.set_style(st);
2386                    }
2387                    let dirty_l: u16 = DIRTY_LAYOUT | DIRTY_SUBTREE_LAYOUT;
2388                    tree.mark_dirty(portal, dirty_l | DIRTY_PAINT);
2389                },
2390                (),
2391            );
2392        })
2393    });
2394    ctx.get_scene().with_write(
2395        |tree: &mut SceneTree| {
2396            tree.attach_scope(portal, scope);
2397        },
2398        (),
2399    );
2400    portal
2401}
2402
2403/// Mounts a press-and-hold cross-platform touch/mouse game control button driving `code` on `host`.
2404///
2405/// # Arguments
2406///
2407/// - `&str` - Button label.
2408/// - `&GameEngineHost` - Target game host.
2409/// - `KeyCode` - Virtual key bound to this button.
2410/// - `bool` - Whether to style as primary (`true`) or outline (`false`).
2411/// - `ThemeTokens` - Active design tokens.
2412///
2413/// # Returns
2414///
2415/// - `NodeId` - Mounted holdable button node.
2416fn mount_game_control_button(
2417    label: &str,
2418    host: &GameEngineHost,
2419    code: KeyCode,
2420    primary: bool,
2421    tokens: ThemeTokens,
2422) -> NodeId {
2423    let host_down: GameEngineHost = host.clone();
2424    let host_up: GameEngineHost = host.clone();
2425    let host_click: GameEngineHost = host.clone();
2426    let node: NodeId = if primary {
2427        view! {
2428            EuvButton(label.to_string(), tokens) {
2429                sm()
2430                on_click: move |_: &UiEvent| {
2431                    pulse_game_key(&host_click, code);
2432                }
2433            }
2434        }
2435    } else {
2436        view! {
2437            EuvButton(label.to_string(), tokens) {
2438                outline()
2439                sm()
2440                on_click: move |_: &UiEvent| {
2441                    pulse_game_key(&host_click, code);
2442                }
2443            }
2444        }
2445    };
2446    let mut ctx: Context = current_context();
2447    ctx.on_pointer_down(node, move |_: &UiEvent| {
2448        host_down.press_key(code);
2449    });
2450    ctx.on_pointer_up(node, move |_: &UiEvent| {
2451        host_up.release_key(code);
2452    });
2453    node
2454}
2455
2456/// Pulses a single directional or action key on `host` for mobile touch/button game controls.
2457///
2458/// # Arguments
2459///
2460/// - `&GameEngineHost` - Target game engine host.
2461/// - `KeyCode` - Virtual key code to pulse.
2462fn pulse_game_key(host: &GameEngineHost, code: KeyCode) {
2463    host.press_key(code);
2464    let _: u32 = host.step(0.08);
2465    host.release_key(code);
2466}
2467
2468/// Mounts the AAA 3D Open-World Engine page with live BVH ray tracing, runtime graphics settings, and `.obj`/`.gltf` model import.
2469///
2470/// # Arguments
2471///
2472/// - `&ShowcaseState` - Reactive showcase state.
2473/// - `ThemeTokens` - Active design tokens.
2474///
2475/// # Returns
2476///
2477/// - `NodeId` - Mounted 3D engine showcase page handle.
2478pub fn mount_game3d_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2479    let g: ThemeGeometry = tokens.get_geometry();
2480    let p: ThemePalette = tokens.get_palette();
2481    let host: GameEngineHost = state.get_game3d_host().clone();
2482    let quality_sig: Signal<RenderQualityConfig> = state.get_engine3d_quality();
2483    let preset_idx: Signal<usize> = state.get_engine3d_preset_idx();
2484    let rt_idx: Signal<usize> = state.get_engine3d_rt_idx();
2485    let res_scale: Signal<f32> = state.get_engine3d_res_scale();
2486    let time_sig: Signal<f32> = state.get_engine3d_time_of_day();
2487    let import_sig: Signal<u64> = state.get_engine3d_import_queue();
2488    let status_sig: Signal<String> = state.get_engine3d_import_status();
2489    let cam_mode_sig: Signal<u8> = state.get_engine3d_camera_mode();
2490    let viewport: NodeId = host.mount_viewport(
2491        Style::default()
2492            .width(Length::Percent(100.0))
2493            .height(Length::Px(340.0))
2494            .border(g.get_border_width(), p.get_border())
2495            .radius(g.get_radius_md()),
2496    );
2497    let fs_3d_open: Signal<bool> = Signal::new(false);
2498    let fs_3d_portal: NodeId =
2499        mount_game_fullscreen_portal(fs_3d_open, &host, "Vice Boulevard 3D RT", tokens);
2500    let res_slider: NodeId = view! { EuvSlider(res_scale, 40.0, 125.0, tokens) };
2501    let sun_slider: NodeId = view! { EuvSlider(time_sig, 6.0, 23.0, tokens) };
2502    let ctx: Context = current_context();
2503    let (sync_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
2504        Effect::new(move || {
2505            let p_idx: usize = preset_idx.get();
2506            let preset: QualityPreset = match p_idx {
2507                0 => QualityPreset::Low,
2508                1 => QualityPreset::Medium,
2509                3 => QualityPreset::Ultra,
2510                4 => QualityPreset::Cinematic,
2511                _ => QualityPreset::High,
2512            };
2513            let rt: RayTracingMode = match rt_idx.get() {
2514                0 => RayTracingMode::Off,
2515                1 => RayTracingMode::ShadowsOnly,
2516                3 => RayTracingMode::FullPathTracedGi,
2517                _ => RayTracingMode::ShadowsAndReflections,
2518            };
2519            let scale_pct: f32 = res_scale.get();
2520            let mut cfg: RenderQualityConfig = RenderQualityConfig::from_preset(preset);
2521            cfg.set_ray_tracing(rt);
2522            cfg.set_resolution_scale((scale_pct / 100.0).clamp(0.40, 1.25));
2523            let _: bool = quality_sig.set_if_changed(cfg);
2524        })
2525    });
2526    let mut sync_host_id: NodeId = NodeId::default();
2527    let page: NodeId = view! {
2528        EuvPage(GAME3D_TITLE.to_string(), GAME3D_SUBTITLE.to_string(), tokens) {
2529            EuvCard(GAME3D_CARD_TITLE.to_string(), tokens) {
2530                subtitle: GAME3D_CARD_SUB
2531                column {
2532                    node_ref: sync_host_id
2533                    width: Length::Percent(100.0)
2534                    gap: SPACE_MD
2535                    { viewport }
2536                    EuvActionRow() {
2537                        { mount_game_control_button("Steer Left (A)", &host, KeyCode::ArrowLeft, false, tokens) }
2538                        { mount_game_control_button("Drive Fwd (W)", &host, KeyCode::ArrowUp, false, tokens) }
2539                        { mount_game_control_button("Reverse (S)", &host, KeyCode::ArrowDown, false, tokens) }
2540                        { mount_game_control_button("Steer Right (D)", &host, KeyCode::ArrowRight, false, tokens) }
2541                        EuvButton("Switch Camera".to_string(), tokens) {
2542                            secondary()
2543                            sm()
2544                            on_click: move |_: &UiEvent| {
2545                                let next: u8 = (cam_mode_sig.get_untracked() + 1) % 4;
2546                                let _: bool = cam_mode_sig.set_if_changed(next);
2547                            }
2548                        }
2549                        EuvButton("Fullscreen 3D".to_string(), tokens) {
2550                            sm()
2551                            on_click: move |_: &UiEvent| {
2552                                let _: bool = fs_3d_open.set_if_changed(true);
2553                            }
2554                        }
2555                        EuvButton("Import .OBJ Monument".to_string(), tokens) {
2556                            secondary()
2557                            sm()
2558                            on_click: move |_: &UiEvent| {
2559                                let cur: u64 = import_sig.get_untracked();
2560                                let next: u64 = if cur.is_multiple_of(2) { cur + 1 } else { cur + 2 };
2561                                let _: bool = import_sig.set_if_changed(next);
2562                            }
2563                        }
2564                        EuvButton("Import .glTF Tower".to_string(), tokens) {
2565                            outline()
2566                            sm()
2567                            on_click: move |_: &UiEvent| {
2568                                let cur: u64 = import_sig.get_untracked();
2569                                let next: u64 = if !cur.is_multiple_of(2) { cur + 1 } else { cur + 2 };
2570                                let _: bool = import_sig.set_if_changed(next);
2571                            }
2572                        }
2573                    }
2574                    text {
2575                        font_size: 12.0
2576                        color: p.get_muted_foreground()
2577                        { move || status_sig.get() }
2578                    }
2579                    EuvSegmented(
2580                        vec![
2581                            "Low".to_string(),
2582                            "Medium".to_string(),
2583                            "High".to_string(),
2584                            "Ultra".to_string(),
2585                            "Cinematic".to_string(),
2586                        ],
2587                        preset_idx,
2588                        tokens
2589                    )
2590                    EuvSegmented(
2591                        vec![
2592                            "RT Off".to_string(),
2593                            "RT Shadows".to_string(),
2594                            "RT Refl".to_string(),
2595                            "RT Full GI".to_string(),
2596                        ],
2597                        rt_idx,
2598                        tokens
2599                    )
2600                    EuvField("Runtime Render Resolution Scale (%)".to_string(), res_slider, tokens)
2601                    EuvField(
2602                        "Time of Day / Sun Lighting (6h Dawn -> 17h Sunset -> 22h Night)".to_string(),
2603                        sun_slider,
2604                        tokens
2605                    )
2606                    { fs_3d_portal }
2607                }
2608            }
2609        }
2610    };
2611    ctx.get_scene().with_write(
2612        |tree: &mut SceneTree| {
2613            tree.attach_scope(sync_host_id, sync_scope);
2614        },
2615        (),
2616    );
2617    page
2618}
2619
2620/// Mounts the overlays page featuring interactive `EuvModal`, `EuvDrawer`, `EuvSheet`, `EuvPopover`, `EuvDropdown`, `EuvToast`, `EuvNotification`, and `EuvLoading`.
2621///
2622/// # Arguments
2623///
2624/// - `&ShowcaseState` - Reactive showcase state.
2625/// - `ThemeTokens` - Active design tokens.
2626///
2627/// # Returns
2628///
2629/// - `NodeId` - Mounted overlays page node.
2630pub fn mount_overlays_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2631    let p: ThemePalette = tokens.get_palette();
2632    let modal_open: Signal<bool> = state.get_modal_open();
2633    let drawer_open: Signal<bool> = state.get_drawer_open();
2634    let sheet_open: Signal<bool> = state.get_sheet_open();
2635    let toast_visible: Signal<bool> = state.get_toast_visible();
2636    let notif_visible: Signal<bool> = state.get_notif_visible();
2637    let alert_open: Signal<bool> = state.get_alert_dialog_open();
2638    let ctx_sel: Signal<Option<usize>> = Signal::new(None);
2639    let tip_btn: NodeId = view! {
2640        EuvButton("Hover Tooltip".to_string(), tokens) {
2641            outline()
2642            sm()
2643        }
2644    };
2645    let modal_body: NodeId = view! {
2646        column {
2647            width: Length::Percent(100.0)
2648            gap: SPACE_MD
2649            text {
2650                font_size: 13.0
2651                color: p.get_muted_foreground()
2652                { MODAL_BODY_TEXT }
2653            }
2654            row {
2655                width: Length::Percent(100.0)
2656                justify: JustifyContent::End
2657                EuvButton(BTN_CLOSE_MODAL.to_string(), tokens) {
2658                    outline()
2659                    on_click: move |_: &UiEvent| {
2660                        let _: bool = modal_open.set_if_changed(false);
2661                    }
2662                }
2663            }
2664        }
2665    };
2666    let drawer_body: NodeId = view! {
2667        column {
2668            width: Length::Percent(100.0)
2669            gap: SPACE_MD
2670            text {
2671                font_size: 13.0
2672                color: p.get_muted_foreground()
2673                "Native slide-over drawer surface"
2674            }
2675            row {
2676                width: Length::Percent(100.0)
2677                justify: JustifyContent::End
2678                EuvButton("Close Drawer".to_string(), tokens) {
2679                    outline()
2680                    on_click: move |_: &UiEvent| {
2681                        let _: bool = drawer_open.set_if_changed(false);
2682                    }
2683                }
2684            }
2685        }
2686    };
2687    let sheet_body: NodeId = view! {
2688        column {
2689            width: Length::Percent(100.0)
2690            gap: SPACE_MD
2691            text {
2692                font_size: 13.0
2693                color: p.get_muted_foreground()
2694                "Native bottom action sheet"
2695            }
2696            row {
2697                width: Length::Percent(100.0)
2698                justify: JustifyContent::End
2699                EuvButton("Close Sheet".to_string(), tokens) {
2700                    outline()
2701                    on_click: move |_: &UiEvent| {
2702                        let _: bool = sheet_open.set_if_changed(false);
2703                    }
2704                }
2705            }
2706        }
2707    };
2708    view! {
2709        EuvPage(OVERLAYS_TITLE.to_string(), OVERLAYS_SUBTITLE.to_string(), tokens) {
2710            column {
2711                width: Length::Percent(100.0)
2712                gap: SPACE_LG
2713                EuvAlert(ALERT_TITLE.to_string(), ALERT_DESC.to_string(), EuvTone::Primary, tokens)
2714                EuvCard(OVERLAYS_CARD_TITLE.to_string(), tokens) {
2715                    subtitle: OVERLAYS_CARD_SUB
2716                    EuvActionRow() {
2717                        EuvButton(BTN_OPEN_MODAL.to_string(), tokens) {
2718                            on_click: move |_: &UiEvent| {
2719                                let _: bool = modal_open.set_if_changed(true);
2720                            }
2721                        }
2722                        EuvButton("Alert Dialog".to_string(), tokens) {
2723                            destructive()
2724                            on_click: move |_: &UiEvent| {
2725                                let _: bool = alert_open.set_if_changed(true);
2726                            }
2727                        }
2728                        EuvButton(BTN_TOGGLE_TOAST.to_string(), tokens) {
2729                            secondary()
2730                            on_click: move |_: &UiEvent| {
2731                                let _: bool = toast_visible.update(|v: &mut bool| *v = !*v);
2732                            }
2733                        }
2734                        EuvButton("Toggle Drawer".to_string(), tokens) {
2735                            outline()
2736                            on_click: move |_: &UiEvent| {
2737                                let _: bool = drawer_open.update(|v: &mut bool| *v = !*v);
2738                            }
2739                        }
2740                        EuvButton("Toggle Sheet".to_string(), tokens) {
2741                            outline()
2742                            on_click: move |_: &UiEvent| {
2743                                let _: bool = sheet_open.update(|v: &mut bool| *v = !*v);
2744                            }
2745                        }
2746                        EuvButton("Toggle Notification".to_string(), tokens) {
2747                            outline()
2748                            on_click: move |_: &UiEvent| {
2749                                let _: bool = notif_visible.update(|v: &mut bool| *v = !*v);
2750                            }
2751                        }
2752                    }
2753                    EuvDropdown(
2754                        "Quick Actions".to_string(),
2755                        vec!["Export PNG".to_string(), "Copy DeepLink".to_string()],
2756                        tokens
2757                    ) {
2758                        open: state.get_dropdown_open()
2759                        selected: state.get_dropdown_selected()
2760                    }
2761                    EuvHoverCard("@euv-dev".to_string(), "euv 0.39 Native Engine".to_string(), tokens) {
2762                        open: state.get_hover_card_open()
2763                        description: "Full ui.shadcn.com component alignment across all 7 native targets."
2764                    }
2765                    EuvTooltip("Zero-WebView floating tooltip".to_string(), tip_btn, tokens)
2766                    EuvContextMenu(
2767                        "Context Menu Surface".to_string(),
2768                        vec![
2769                            "Inspect Scene Node".to_string(),
2770                            "Copy AI Selector".to_string(),
2771                            "Capture Frame Hash".to_string(),
2772                        ],
2773                        tokens
2774                    ) {
2775                        selected: ctx_sel
2776                    }
2777                }
2778                EuvModal(modal_open, MODAL_TITLE.to_string(), modal_body, tokens)
2779                EuvAlertDialog(
2780                    alert_open,
2781                    "Are you absolutely sure?".to_string(),
2782                    state.get_alert_dialog_confirmed(),
2783                    tokens
2784                ) {
2785                    description: "This shadcn AlertDialog confirms destructive operations cleanly."
2786                    labels("Cancel", "Continue")
2787                }
2788                EuvDrawer(drawer_open, "Inspector Drawer".to_string(), drawer_body, tokens)
2789                EuvSheet(sheet_open, "Quick Sheet".to_string(), sheet_body, tokens)
2790                EuvToast(toast_visible, TOAST_TEXT.to_string(), EuvTone::Success, tokens)
2791                EuvNotification(
2792                    notif_visible,
2793                    "Native Sync".to_string(),
2794                    "All 7 targets active.".to_string(),
2795                    tokens
2796                ) {
2797                    tone: EuvTone::Success
2798                }
2799                EuvLoading(state.get_loading_active(), "Syncing...".to_string(), tokens)
2800            }
2801        }
2802    }
2803}
2804
2805/// Mounts the interactive component-level and page-level dynamic OTA updates showcase page.
2806///
2807/// # Arguments
2808///
2809/// - `&ShowcaseState` - Reactive showcase state.
2810/// - `ThemeTokens` - Active design tokens.
2811///
2812/// # Returns
2813///
2814/// - `NodeId` - Mounted dynamic updates page node.
2815pub fn mount_dynamic_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2816    let p: ThemePalette = tokens.get_palette();
2817    let g: ThemeGeometry = tokens.get_geometry();
2818    let hub: DynamicUpdateHub = state.get_dynamic_hub().clone();
2819    let sibling_counter: Signal<i32> = state.get_sibling_counter();
2820    let action_log: Signal<String> = state.get_dynamic_action_log();
2821    let route_sig: Signal<String> = state.get_route();
2822    let tel_sig: Signal<DynamicTelemetry> = hub.telemetry();
2823    let banner_rev: Signal<u64> = hub.component_revision_signal(SLOT_PROMO_BANNER);
2824    let metrics_rev: Signal<u64> = hub.component_revision_signal(SLOT_METRICS_WIDGET);
2825    let panel_rev: Signal<u64> = hub.page_revision_signal(ROUTE_DYNAMIC_PANEL);
2826    let hub_v1: DynamicUpdateHub = hub.clone();
2827    let hub_v2: DynamicUpdateHub = hub.clone();
2828    let hub_rb: DynamicUpdateHub = hub.clone();
2829    let hub_m1: DynamicUpdateHub = hub.clone();
2830    let hub_mrb: DynamicUpdateHub = hub.clone();
2831    let hub_p1: DynamicUpdateHub = hub.clone();
2832    let hub_bundle: DynamicUpdateHub = hub.clone();
2833    let hub_prb: DynamicUpdateHub = hub.clone();
2834    let hub_inject: DynamicUpdateHub = hub.clone();
2835    let hub_for_status: DynamicUpdateHub = hub.clone();
2836    let wasm_mgr: WasmDynamicManager = state.get_wasm_manager().clone();
2837    let wasm_reg: RegistryWasmFetcher = state.get_wasm_registry().clone();
2838    let wasm_offline_sig: Signal<bool> = state.get_wasm_offline();
2839    let wasm_status_sig: Signal<String> = state.get_wasm_fault_status();
2840    let partial_scope: WasmDynamicScope = WasmDynamicScope::Partial {
2841        slot_id: SLOT_WASM_WIDGET.to_string(),
2842    };
2843    let partial_state_sig: Signal<WasmLoadState> = wasm_mgr.state_signal(&partial_scope);
2844    let global_state_sig: Signal<WasmLoadState> = wasm_mgr.state_signal(&WasmDynamicScope::Global);
2845    let wasm_tel_sig: Signal<WasmDynamicTelemetry> = wasm_mgr.telemetry();
2846    let m_p1: WasmDynamicManager = wasm_mgr.clone();
2847    let s_p1: Signal<String> = wasm_status_sig;
2848    let m_p2: WasmDynamicManager = wasm_mgr.clone();
2849    let s_p2: Signal<String> = wasm_status_sig;
2850    let m_prb: WasmDynamicManager = wasm_mgr.clone();
2851    let s_prb: Signal<String> = wasm_status_sig;
2852    let m_pun: WasmDynamicManager = wasm_mgr.clone();
2853    let s_pun: Signal<String> = wasm_status_sig;
2854    let r_off: RegistryWasmFetcher = wasm_reg.clone();
2855    let s_off: Signal<String> = wasm_status_sig;
2856    let m_g1: WasmDynamicManager = wasm_mgr.clone();
2857    let s_g1: Signal<String> = wasm_status_sig;
2858    let m_g2: WasmDynamicManager = wasm_mgr.clone();
2859    let s_g2: Signal<String> = wasm_status_sig;
2860    let m_gbad: WasmDynamicManager = wasm_mgr.clone();
2861    let s_gbad: Signal<String> = wasm_status_sig;
2862    let m_grb: WasmDynamicManager = wasm_mgr.clone();
2863    let s_grb: Signal<String> = wasm_status_sig;
2864    let m_f_retry: WasmDynamicManager = wasm_mgr.clone();
2865    let s_f_retry: Signal<String> = wasm_status_sig;
2866    let m_f_500: WasmDynamicManager = wasm_mgr.clone();
2867    let s_f_500: Signal<String> = wasm_status_sig;
2868    let m_f_corrupt: WasmDynamicManager = wasm_mgr.clone();
2869    let s_f_corrupt: Signal<String> = wasm_status_sig;
2870    let m_f_tamper: WasmDynamicManager = wasm_mgr.clone();
2871    let s_f_tamper: Signal<String> = wasm_status_sig;
2872    let m_f_sig: WasmDynamicManager = wasm_mgr.clone();
2873    let s_f_sig: Signal<String> = wasm_status_sig;
2874    let m_f_abi: WasmDynamicManager = wasm_mgr.clone();
2875    let s_f_abi: Signal<String> = wasm_status_sig;
2876    let m_f_exp: WasmDynamicManager = wasm_mgr.clone();
2877    let s_f_exp: Signal<String> = wasm_status_sig;
2878    let m_f_fuel: WasmDynamicManager = wasm_mgr.clone();
2879    let s_f_fuel: Signal<String> = wasm_status_sig;
2880    let m_f_trap: WasmDynamicManager = wasm_mgr.clone();
2881    let s_f_trap: Signal<String> = wasm_status_sig;
2882    let m_f_big: WasmDynamicManager = wasm_mgr.clone();
2883    let s_f_big: Signal<String> = wasm_status_sig;
2884    let m_f_cancel: WasmDynamicManager = wasm_mgr.clone();
2885    let s_f_cancel: Signal<String> = wasm_status_sig;
2886    let m_http: WasmDynamicManager = wasm_mgr.clone();
2887    let s_http: Signal<String> = wasm_status_sig;
2888    view! {
2889        EuvPage(DYNAMIC_TITLE.to_string(), DYNAMIC_SUBTITLE.to_string(), tokens) {
2890            EuvCard("Scoped / Partial Dynamic WASM Execution".to_string(), tokens) {
2891                subtitle: "Download genuine .wasm binaries into a single native slot with checksum/signature verification, offline cache, interactive euv_on_event & rollback"
2892                column {
2893                    gap: SPACE_MD
2894                    EuvActionRow() {
2895                        EuvButton("Download Real HTTP .wasm".to_string(), tokens) {
2896                            on_click: move |_: &UiEvent| {
2897                                #[cfg(not(target_arch = "wasm32"))]
2898                                {
2899                                    let bytes: Vec<u8> = build_partial_widget_wasm(
2900                                        "Live HTTP-Downloaded .wasm Module v3",
2901                                        3,
2902                                        0x059669,
2903                                    );
2904                                    let bytes_srv: Vec<u8> = bytes.clone();
2905                                    match TcpListener::bind("127.0.0.1:0") {
2906                                        Ok(listener) => {
2907                                            let port: u16 = listener
2908                                            .local_addr()
2909                                            .map(|addr: SocketAddr| addr.port())
2910                                            .unwrap_or(0);
2911                                            drop(spawn(move || {
2912                                                        if let Ok((mut stream, _)) = listener.accept() {
2913                                                            let mut req_buf: [u8; 512] = [0; 512];
2914                                                            let _: Result<usize, Error> = stream.read(&mut req_buf);
2915                                                            let hdr: String = format!(
2916                                                                "HTTP/1.1 200 OK\r\nContent-Type: application/wasm\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
2917                                                                bytes_srv.len()
2918                                                            );
2919                                                            let _: Result<(), Error> = stream.write_all(hdr.as_bytes());
2920                                                            let _: Result<(), Error> = stream.write_all(&bytes_srv);
2921                                                            let _: Result<(), Error> = stream.flush();
2922                                                        }
2923                                            }));
2924                                            let url: String =
2925                                            format!("http://127.0.0.1:{port}/live-module-v3.wasm");
2926                                            let req: WasmDownloadRequest = WasmDownloadRequest::partial(
2927                                                url.clone(),
2928                                                SLOT_WASM_WIDGET.to_string(),
2929                                                3,
2930                                            )
2931                                            .with_checksum(compute_wasm_checksum(&bytes))
2932                                            .with_signature(compute_wasm_signature(
2933                                                    &bytes,
2934                                                    3,
2935                                                    WASM_SHOWCASE_SIGNING_KEY,
2936                                            ))
2937                                            .with_allow_downgrade(true);
2938                                            match m_http.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
2939                                                Ok(v) => {
2940                                                    let _: bool = s_http.set(format!(
2941                                                            "Downloaded {} bytes over real HTTP ({url}) -> executed & mounted .wasm v{v} natively!",
2942                                                            bytes.len()
2943                                                    ));
2944                                                }
2945                                                Err(e) => {
2946                                                    let _: bool = s_http.set(format!("HTTP .wasm download failed: {e}"));
2947                                                }
2948                                            }
2949                                        }
2950                                        Err(err) => {
2951                                            let _: bool = s_http.set(format!("Local HTTP server bind error: {err}"));
2952                                        }
2953                                    }
2954                                }
2955                                #[cfg(target_arch = "wasm32")]
2956                                {
2957                                    let bytes: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
2958                                    let req: WasmDownloadRequest = WasmDownloadRequest::partial(
2959                                        URL_WASM_PARTIAL_V1.to_string(),
2960                                        SLOT_WASM_WIDGET.to_string(),
2961                                        1,
2962                                    )
2963                                    .with_checksum(compute_wasm_checksum(&bytes))
2964                                    .with_signature(compute_wasm_signature(&bytes, 1, WASM_SHOWCASE_SIGNING_KEY))
2965                                    .with_allow_downgrade(true);
2966                                    match m_http.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
2967                                        Ok(v) => { let _: bool = s_http.set(format!("Fetched & executed .wasm v{v} natively in browser sandbox")); }
2968                                        Err(e) => { let _: bool = s_http.set(format!("WASM fetch failed: {e}")); }
2969                                    }
2970                                }
2971                            }
2972                        }
2973                        EuvButton("Download Partial WASM v1".to_string(), tokens) {
2974                            secondary()
2975                            on_click: move |_: &UiEvent| {
2976                                let bytes: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
2977                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(
2978                                    URL_WASM_PARTIAL_V1.to_string(),
2979                                    SLOT_WASM_WIDGET.to_string(),
2980                                    1,
2981                                )
2982                                .with_checksum(compute_wasm_checksum(&bytes))
2983                                .with_signature(compute_wasm_signature(&bytes, 1, WASM_SHOWCASE_SIGNING_KEY))
2984                                .with_allow_downgrade(true);
2985                                match m_p1.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
2986                                    Ok(v) => { let _: bool = s_p1.set(format!("Mounted Partial .wasm v{v} natively (verified checksum + signature)")); }
2987                                    Err(e) => { let _: bool = s_p1.set(format!("Partial v1 failed: {e}")); }
2988                                }
2989                            }
2990                        }
2991                        EuvButton("Hot-Swap Partial WASM v2".to_string(), tokens) {
2992                            secondary()
2993                            on_click: move |_: &UiEvent| {
2994                                let bytes: Vec<u8> = build_partial_widget_wasm("Hot-Swapped Partial WASM Widget v2", 2, 0x7C3AED);
2995                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(
2996                                    URL_WASM_PARTIAL_V2.to_string(),
2997                                    SLOT_WASM_WIDGET.to_string(),
2998                                    2,
2999                                )
3000                                .with_checksum(compute_wasm_checksum(&bytes))
3001                                .with_signature(compute_wasm_signature(&bytes, 2, WASM_SHOWCASE_SIGNING_KEY))
3002                                .with_allow_downgrade(true);
3003                                match m_p2.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
3004                                    Ok(v) => { let _: bool = s_p2.set(format!("Hot-swapped Partial .wasm v{v} natively (sibling UI untouched)")); }
3005                                    Err(e) => { let _: bool = s_p2.set(format!("Partial v2 failed: {e}")); }
3006                                }
3007                            }
3008                        }
3009                        EuvButton("Toggle Offline (Cache Hit)".to_string(), tokens) {
3010                            outline()
3011                            on_click: move |_: &UiEvent| {
3012                                let next: bool = !wasm_offline_sig.get_untracked();
3013                                let _: bool = wasm_offline_sig.set(next);
3014                                r_off.set_offline(next);
3015                                let _: bool = s_off.set(if next {
3016                                        "Simulated OFFLINE enabled — re-downloading v1 will serve verified offline cache!".to_string()
3017                                    } else {
3018                                        "Simulated ONLINE restored — fetching live .wasm from CDN".to_string()
3019                                });
3020                            }
3021                        }
3022                        EuvButton("Rollback Partial".to_string(), tokens) {
3023                            outline()
3024                            on_click: move |_: &UiEvent| {
3025                                match m_prb.rollback_partial(SLOT_WASM_WIDGET, "manual rollback") {
3026                                    Ok(v) => { let _: bool = s_prb.set(format!("Rolled back partial WASM slot to v{v}")); }
3027                                    Err(e) => { let _: bool = s_prb.set(format!("Rollback: {e}")); }
3028                                }
3029                            }
3030                        }
3031                        EuvButton("Unmount Slot".to_string(), tokens) {
3032                            ghost()
3033                            on_click: move |_: &UiEvent| {
3034                                m_pun.unmount_partial(SLOT_WASM_WIDGET);
3035                                let _: bool = s_pun.set("Unmounted partial WASM instance and restored compiled fallback".to_string());
3036                            }
3037                        }
3038                    }
3039                    slot {
3040                        id: SLOT_WASM_WIDGET
3041                        row {
3042                            width: Length::Percent(100.0)
3043                            padding: Edges::all(SPACE_MD)
3044                            background: p.get_muted()
3045                            border: (g.get_border_width(), p.get_border())
3046                            radius: g.get_radius_md()
3047                            text {
3048                                font_size: 13.0
3049                                color: p.get_muted_foreground()
3050                                "Compiled Native Slot (v0) — click 'Download Partial WASM v1' to fetch, verify, execute .wasm in sandbox & render natively."
3051                            }
3052                        }
3053                    }
3054                    text {
3055                        font_size: 12.0
3056                        color: p.get_muted_foreground()
3057                        { move || {
3058                                let st: WasmLoadState = partial_state_sig.get();
3059                                let gst: WasmLoadState = global_state_sig.get();
3060                                let tel: WasmDynamicTelemetry = wasm_tel_sig.get();
3061                                format!(
3062                                    "Partial={st:?} | Global={gst:?} | OK={}/{} Cache={} Retries={} Rollbacks={} Traps={} FuelStops={} Rejects={} Events={}",
3063                                    tel.get_downloads_succeeded(),
3064                                    tel.get_downloads_started(),
3065                                    tel.get_cache_hits(),
3066                                    tel.get_retries_performed(),
3067                                    tel.get_rollbacks_executed(),
3068                                    tel.get_sandbox_traps_caught(),
3069                                    tel.get_fuel_exhaustions_caught(),
3070                                    tel.get_integrity_rejections(),
3071                                    tel.get_events_handled()
3072                                )
3073                        } }
3074                    }
3075                }
3076            }
3077            EuvCard("Global / Full-App Dynamic WASM Takeover".to_string(), tokens) {
3078                subtitle: "Atomically replace the entire native app shell from a downloaded .wasm release with automatic Last-Known-Good (LKG) rollback on any fault"
3079                column {
3080                    gap: SPACE_MD
3081                    EuvActionRow() {
3082                        EuvButton("Download Global WASM v1".to_string(), tokens) {
3083                            on_click: move |_: &UiEvent| {
3084                                let bytes: Vec<u8> =
3085                                build_global_app_wasm("Global Dynamic WASM App Shell v1", 1);
3086                                let req: WasmDownloadRequest =
3087                                WasmDownloadRequest::global(URL_WASM_GLOBAL_V1.to_string(), 1)
3088                                .with_checksum(compute_wasm_checksum(&bytes))
3089                                .with_signature(compute_wasm_signature(
3090                                        &bytes,
3091                                        1,
3092                                        WASM_SHOWCASE_SIGNING_KEY,
3093                                ))
3094                                .with_allow_downgrade(true);
3095                                match m_g1.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
3096                                    Ok(v) => {
3097                                        let _: bool = s_g1
3098                                        .set(format!("Global .wasm v{v} took over root shell natively!"));
3099                                    }
3100                                    Err(e) => {
3101                                        let _: bool = s_g1.set(format!("Global v1 failed: {e}"));
3102                                    }
3103                                }
3104                            }
3105                        }
3106                        EuvButton("Upgrade Global WASM v2".to_string(), tokens) {
3107                            secondary()
3108                            on_click: move |_: &UiEvent| {
3109                                let bytes: Vec<u8> =
3110                                build_global_app_wasm("Global Dynamic WASM App Shell v2", 2);
3111                                let req: WasmDownloadRequest =
3112                                WasmDownloadRequest::global(URL_WASM_GLOBAL_V2.to_string(), 2)
3113                                .with_checksum(compute_wasm_checksum(&bytes))
3114                                .with_signature(compute_wasm_signature(
3115                                        &bytes,
3116                                        2,
3117                                        WASM_SHOWCASE_SIGNING_KEY,
3118                                ))
3119                                .with_allow_downgrade(true);
3120                                match m_g2.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
3121                                    Ok(v) => {
3122                                        let _: bool =
3123                                        s_g2.set(format!("Upgraded Global .wasm to v{v} atomically"));
3124                                    }
3125                                    Err(e) => {
3126                                        let _: bool = s_g2.set(format!("Global v2 failed: {e}"));
3127                                    }
3128                                }
3129                            }
3130                        }
3131                        EuvButton("Faulty Global (Auto LKG Rollback)".to_string(), tokens) {
3132                            destructive()
3133                            on_click: move |_: &UiEvent| {
3134                                let req: WasmDownloadRequest =
3135                                WasmDownloadRequest::global(URL_WASM_TRAP.to_string(), 99);
3136                                match m_gbad.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
3137                                    Ok(v) => {
3138                                        let _: bool = s_gbad.set(format!("Unexpected global mount v{v}"));
3139                                    }
3140                                    Err(e) => {
3141                                        let _: bool =
3142                                        s_gbad.set(format!("Global fault isolated & LKG preserved: {e}"));
3143                                    }
3144                                }
3145                            }
3146                        }
3147                        EuvButton("Restore Native Shell".to_string(), tokens) {
3148                            outline()
3149                            on_click: move |_: &UiEvent| {
3150                                m_grb.restore_native_global();
3151                                let _: bool = s_grb.set(STATUS_RESTORED_NATIVE_SHELL.to_string());
3152                            }
3153                        }
3154                    }
3155                }
3156            }
3157            EuvCard("All-Case Security, Fault & Sandbox Verification Matrix".to_string(), tokens) {
3158                subtitle: "Verify every edge case live: auto-retry, offline cache, integrity rejection, ABI mismatch, infinite-loop fuel cutoff, trap isolation & stale cancel guard"
3159                column {
3160                    gap: SPACE_MD
3161                    EuvActionRow() {
3162                        EuvButton("Timeout -> Auto Retry".to_string(), tokens) {
3163                            outline()
3164                            sm()
3165                            on_click: move |_: &UiEvent| {
3166                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TIMEOUT_RETRY.to_string(), SLOT_WASM_WIDGET.to_string(), 10).with_allow_downgrade(true);
3167                                match m_f_retry.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
3168                                    Ok(v) => { let _: bool = s_f_retry.set(format!("PASS Timeout->Retry recovered and mounted v{v}!")); }
3169                                    Err(e) => { let _: bool = s_f_retry.set(format!("Retry failed: {e}")); }
3170                                }
3171                            }
3172                        }
3173                        EuvButton("HTTP 500".to_string(), tokens) {
3174                            outline()
3175                            sm()
3176                            on_click: move |_: &UiEvent| {
3177                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_HTTP_500.to_string(), SLOT_WASM_WIDGET.to_string(), 11).with_allow_downgrade(true);
3178                                let res: String = format!("Handled HTTP 500 -> {:?}", m_f_500.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3179                                let _: bool = s_f_500.set(res);
3180                            }
3181                        }
3182                        EuvButton("Corrupted Magic".to_string(), tokens) {
3183                            outline()
3184                            sm()
3185                            on_click: move |_: &UiEvent| {
3186                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_CORRUPTED.to_string(), SLOT_WASM_WIDGET.to_string(), 12).with_allow_downgrade(true);
3187                                let res: String = format!("Blocked Corrupted Magic -> {:?}", m_f_corrupt.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3188                                let _: bool = s_f_corrupt.set(res);
3189                            }
3190                        }
3191                        EuvButton("Tampered Checksum".to_string(), tokens) {
3192                            outline()
3193                            sm()
3194                            on_click: move |_: &UiEvent| {
3195                                let good: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
3196                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TAMPERED.to_string(), SLOT_WASM_WIDGET.to_string(), 13)
3197                                .with_checksum(compute_wasm_checksum(&good))
3198                                .with_allow_downgrade(true);
3199                                let res: String = format!("Blocked Tampered Checksum -> {:?}", m_f_tamper.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3200                                let _: bool = s_f_tamper.set(res);
3201                            }
3202                        }
3203                        EuvButton("Invalid Signature".to_string(), tokens) {
3204                            outline()
3205                            sm()
3206                            on_click: move |_: &UiEvent| {
3207                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_PARTIAL_V1.to_string(), SLOT_WASM_WIDGET.to_string(), 14)
3208                                .with_signature("euv-sig-v1:forged".to_string())
3209                                .with_allow_downgrade(true);
3210                                let res: String = format!("Blocked Forged Signature -> {:?}", m_f_sig.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3211                                let _: bool = s_f_sig.set(res);
3212                            }
3213                        }
3214                        EuvButton("ABI Mismatch".to_string(), tokens) {
3215                            outline()
3216                            sm()
3217                            on_click: move |_: &UiEvent| {
3218                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_BAD_ABI.to_string(), SLOT_WASM_WIDGET.to_string(), 15).with_allow_downgrade(true);
3219                                let res: String = format!("Blocked ABI Mismatch -> {:?}", m_f_abi.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3220                                let _: bool = s_f_abi.set(res);
3221                            }
3222                        }
3223                        EuvButton("Missing Export".to_string(), tokens) {
3224                            outline()
3225                            sm()
3226                            on_click: move |_: &UiEvent| {
3227                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_MISSING_EXPORT.to_string(), SLOT_WASM_WIDGET.to_string(), 16).with_allow_downgrade(true);
3228                                let res: String = format!("Blocked Missing Export -> {:?}", m_f_exp.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3229                                let _: bool = s_f_exp.set(res);
3230                            }
3231                        }
3232                        EuvButton("Infinite-Loop Fuel".to_string(), tokens) {
3233                            outline()
3234                            sm()
3235                            on_click: move |_: &UiEvent| {
3236                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_FUEL_BOMB.to_string(), SLOT_WASM_WIDGET.to_string(), 17).with_allow_downgrade(true);
3237                                let res: String = format!("Terminated Runaway Loop -> {:?}", m_f_fuel.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3238                                let _: bool = s_f_fuel.set(res);
3239                            }
3240                        }
3241                        EuvButton("Runtime Trap".to_string(), tokens) {
3242                            outline()
3243                            sm()
3244                            on_click: move |_: &UiEvent| {
3245                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TRAP.to_string(), SLOT_WASM_WIDGET.to_string(), 18).with_allow_downgrade(true);
3246                                let res: String = format!("Isolated Runtime Trap -> {:?}", m_f_trap.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3247                                let _: bool = s_f_trap.set(res);
3248                            }
3249                        }
3250                        EuvButton("Oversized Binary".to_string(), tokens) {
3251                            outline()
3252                            sm()
3253                            on_click: move |_: &UiEvent| {
3254                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_OVERSIZED.to_string(), SLOT_WASM_WIDGET.to_string(), 19).with_allow_downgrade(true);
3255                                let res: String = format!("Blocked Oversized Binary -> {:?}", m_f_big.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
3256                                let _: bool = s_f_big.set(res);
3257                            }
3258                        }
3259                        EuvButton("Cancel / Stale Guard".to_string(), tokens) {
3260                            outline()
3261                            sm()
3262                            on_click: move |_: &UiEvent| {
3263                                let gen_id: u64 = m_f_cancel.cancel_scope(&WasmDynamicScope::Partial { slot_id: SLOT_WASM_WIDGET.to_string() });
3264                                let _: bool = s_f_cancel.set(format!("Cancelled scope request cleanly (generation #{gen_id} blocks stale responses)"));
3265                            }
3266                        }
3267                    }
3268                    text {
3269                        font_size: 12.5
3270                        font_weight: FontWeight::Medium
3271                        color: p.get_primary()
3272                        { move || wasm_status_sig.get() }
3273                    }
3274                }
3275            }
3276            EuvCard(DYNAMIC_COMP_CARD_TITLE.to_string(), tokens) {
3277                subtitle: DYNAMIC_COMP_CARD_SUB
3278                column {
3279                    gap: SPACE_MD
3280                    EuvActionRow() {
3281                        EuvButton(BTN_INC_SIBLING.to_string(), tokens) {
3282                            outline()
3283                            on_click: move |_: &UiEvent| {
3284                                let _: bool = sibling_counter.update(|v: &mut i32| *v += 1);
3285                            }
3286                        }
3287                    }
3288                    text {
3289                        font_size: 13.0
3290                        font_weight: FontWeight::SemiBold
3291                        color: p.get_primary()
3292                        { move || format!("Sibling State Preserved: count={}", sibling_counter.get()) }
3293                    }
3294                    EuvActionRow() {
3295                        EuvButton(BTN_PUSH_BANNER_V1.to_string(), tokens) {
3296                            on_click: move |_: &UiEvent| {
3297                                let next_v: u64 = hub_v1
3298                                .component_version(SLOT_PROMO_BANNER)
3299                                .saturating_add(1);
3300                                let mut badge: DynamicNodeSpec =
3301                                DynamicNodeSpec::badge(format!("OTA v{next_v}"));
3302                                badge
3303                                .get_mut_style()
3304                                .set_background_hex(Some(0x1D4ED8))
3305                                .set_color_hex(Some(0xFFFFFF));
3306                                let mut title: DynamicNodeSpec = DynamicNodeSpec::text(format!(
3307                                        "Dynamic JSON Banner v{next_v}: Surgical Component Patch"
3308                                ));
3309                                title
3310                                .get_mut_style()
3311                                .set_bold(true)
3312                                .set_color_hex(Some(0x1E3A8A));
3313                                let mut offer_btn: DynamicNodeSpec = DynamicNodeSpec::button(
3314                                    BTN_CLAIM_OFFER.to_string(),
3315                                    "claim_offer".to_string(),
3316                                );
3317                                offer_btn.set_payload(format!("json-v{next_v}"));
3318                                let mut box_spec: DynamicNodeSpec = DynamicNodeSpec::row()
3319                                .child(badge)
3320                                .child(title)
3321                                .child(offer_btn);
3322                                box_spec
3323                                .get_mut_style()
3324                                .set_full_width(true)
3325                                .set_padding(Some(12.0))
3326                                .set_radius(Some(8.0))
3327                                .set_background_hex(Some(0xEFF6FF))
3328                                .set_border_width(Some(1.0))
3329                                .set_border_hex(Some(0x93C5FD));
3330                                let mut upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
3331                                    SLOT_PROMO_BANNER.to_string(),
3332                                    next_v,
3333                                    box_spec,
3334                                );
3335                                upd.sign();
3336                                if let Ok(json) = upd.to_json() {
3337                                    let _: Result<u64, DynamicUpdateError> = hub_v1.apply_component_json(&json);
3338                                }
3339                            }
3340                        }
3341                        EuvButton(BTN_PUSH_BANNER_V2.to_string(), tokens) {
3342                            secondary()
3343                            on_click: move |_: &UiEvent| {
3344                                let next_v: u64 = hub_v2.component_version(SLOT_PROMO_BANNER).saturating_add(1).max(2);
3345                                let hub_act: DynamicUpdateHub = hub_v2.clone();
3346                                let _: Result<u64, DynamicUpdateError> = hub_v2.swap_component_builder(
3347                                    SLOT_PROMO_BANNER.to_string(),
3348                                    next_v,
3349                                    move || {
3350                                        let hub_click: DynamicUpdateHub = hub_act.clone();
3351                                        view! {
3352                                            row {
3353                                                width: Length::Percent(100.0)
3354                                                flex_wrap: FlexWrap::Wrap
3355                                                padding: Edges::all(SPACE_MD)
3356                                                gap: SPACE_MD
3357                                                align: AlignItems::Center
3358                                                background: Color::hex(0x064E3B)
3359                                                radius: 8.0
3360                                                text {
3361                                                    font_size: 14.0
3362                                                    font_weight: FontWeight::Bold
3363                                                    color: Color::hex(0xECFDF5)
3364                                                    { format!("Native Hot-Swapped Banner v{next_v} (Zero Restart)") }
3365                                                }
3366                                                EuvButton(BTN_CLAIM_OFFER.to_string(), tokens) {
3367                                                    on_click: move |_: &UiEvent| {
3368                                                        hub_click.dispatch_action(DynamicActionEvent::new(
3369                                                                SLOT_PROMO_BANNER.to_string(),
3370                                                                "claim_offer".to_string(),
3371                                                                format!("native-v{next_v}"),
3372                                                        ));
3373                                                    }
3374                                                }
3375                                            }
3376                                        }
3377                                    },
3378                                );
3379                            }
3380                        }
3381                        EuvButton(BTN_ROLLBACK_BANNER.to_string(), tokens) {
3382                            outline()
3383                            on_click: move |_: &UiEvent| {
3384                                let _: Result<u64, DynamicUpdateError> = hub_rb.rollback_component(SLOT_PROMO_BANNER);
3385                            }
3386                        }
3387                    }
3388                    slot {
3389                        id: SLOT_PROMO_BANNER
3390                        row {
3391                            width: Length::Percent(100.0)
3392                            padding: Edges::all(SPACE_MD)
3393                            background: p.get_muted()
3394                            border: (g.get_border_width(), p.get_border())
3395                            radius: g.get_radius_md()
3396                            text {
3397                                font_size: 13.0
3398                                color: p.get_foreground()
3399                                "Compiled Fallback Banner (v0) — click a button above to hot-update only this component."
3400                            }
3401                        }
3402                    }
3403                    EuvActionRow() {
3404                        EuvButton(BTN_PATCH_METRICS.to_string(), tokens) {
3405                            on_click: move |_: &UiEvent| {
3406                                let next_v: u64 = hub_m1.component_version(SLOT_METRICS_WIDGET).saturating_add(1);
3407                                let mut card_spec: DynamicNodeSpec = DynamicNodeSpec::card(format!("Live Metrics Widget v{next_v}"))
3408                                .child(DynamicNodeSpec::text(format!("Updated independently without touching promo_banner or sibling state (rev {next_v}).")));
3409                                card_spec
3410                                .get_mut_style()
3411                                .set_background_hex(Some(0xFEFCE8))
3412                                .set_border_width(Some(1.0))
3413                                .set_border_hex(Some(0xFACC15));
3414                                let mut upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
3415                                    SLOT_METRICS_WIDGET.to_string(),
3416                                    next_v,
3417                                    card_spec,
3418                                );
3419                                upd.sign();
3420                                let _: Result<u64, DynamicUpdateError> = hub_m1.apply_component(upd);
3421                            }
3422                        }
3423                        EuvButton(BTN_ROLLBACK_METRICS.to_string(), tokens) {
3424                            outline()
3425                            on_click: move |_: &UiEvent| {
3426                                let _: Result<u64, DynamicUpdateError> =
3427                                hub_mrb.rollback_component(SLOT_METRICS_WIDGET);
3428                            }
3429                        }
3430                    }
3431                    slot {
3432                        id: SLOT_METRICS_WIDGET
3433                        row {
3434                            width: Length::Percent(100.0)
3435                            padding: Edges::all(SPACE_MD)
3436                            background: p.get_muted()
3437                            border: (g.get_border_width(), p.get_border())
3438                            radius: g.get_radius_md()
3439                            text {
3440                                font_size: 13.0
3441                                color: p.get_muted_foreground()
3442                                "Compiled Fallback Metrics Widget (v0) — independent surgical slot."
3443                            }
3444                        }
3445                    }
3446                }
3447            }
3448            EuvCard(DYNAMIC_PAGE_CARD_TITLE.to_string(), tokens) {
3449                subtitle: DYNAMIC_PAGE_CARD_SUB
3450                column {
3451                    gap: SPACE_MD
3452                    EuvActionRow() {
3453                        EuvButton(BTN_UPDATE_PAGE_V1.to_string(), tokens) {
3454                            on_click: move |_: &UiEvent| {
3455                                let next_v: u64 = hub_p1.page_version(ROUTE_DYNAMIC_PANEL).saturating_add(1);
3456                                let spec: DynamicNodeSpec = DynamicNodeSpec::card(format!(
3457                                        "Hot-Updated Dynamic Page Panel v{next_v}"
3458                                ))
3459                                .child(DynamicNodeSpec::badge(format!("Page Revision v{next_v}")))
3460                                .child(DynamicNodeSpec::text(
3461                                        "Page-level layout replaced live without restarting the application."
3462                                        .to_string(),
3463                                ));
3464                                let mut upd: DynamicPageUpdate = DynamicPageUpdate::new(
3465                                    ROUTE_DYNAMIC_PANEL.to_string(),
3466                                    format!("Dynamic Panel v{next_v}"),
3467                                    next_v,
3468                                    spec,
3469                                );
3470                                upd.sign();
3471                                let _: Result<u64, DynamicUpdateError> = hub_p1.apply_page(upd);
3472                            }
3473                        }
3474                        EuvButton(BTN_APPLY_BUNDLE.to_string(), tokens) {
3475                            secondary()
3476                            on_click: move |_: &UiEvent| {
3477                                let next_comp_v: u64 = hub_bundle
3478                                .component_version(SLOT_METRICS_WIDGET)
3479                                .saturating_add(1);
3480                                let next_page_v: u64 = hub_bundle
3481                                .page_version(ROUTE_DYNAMIC_PANEL)
3482                                .saturating_add(1);
3483                                let mut comp_upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
3484                                    SLOT_METRICS_WIDGET.to_string(),
3485                                    next_comp_v,
3486                                    DynamicNodeSpec::card(format!("Atomic Bundle Metrics v{next_comp_v}")).child(
3487                                        DynamicNodeSpec::text(
3488                                            "Committed together with page panel inside one atomic transaction."
3489                                            .to_string(),
3490                                        ),
3491                                    ),
3492                                );
3493                                comp_upd.sign();
3494                                let mut page_upd: DynamicPageUpdate = DynamicPageUpdate::new(
3495                                    ROUTE_DYNAMIC_PANEL.to_string(),
3496                                    format!("Atomic Panel v{next_page_v}"),
3497                                    next_page_v,
3498                                    DynamicNodeSpec::card(format!("Atomic Bundle Page Panel v{next_page_v}")).child(
3499                                        DynamicNodeSpec::text(
3500                                            "Both component slot and page slot updated atomically via signed JSON."
3501                                            .to_string(),
3502                                        ),
3503                                    ),
3504                                );
3505                                page_upd.sign();
3506                                let bundle: DynamicUpdateBundle =
3507                                DynamicUpdateBundle::new("ota-atomic-bundle".to_string(), next_page_v)
3508                                .push_component(comp_upd)
3509                                .push_page(page_upd);
3510                                if let Ok(json) = bundle.to_json() {
3511                                    let _: Result<DynamicTelemetry, DynamicUpdateError> =
3512                                    hub_bundle.apply_bundle_json(&json);
3513                                }
3514                            }
3515                        }
3516                        EuvButton(BTN_ROLLBACK_PAGE.to_string(), tokens) {
3517                            outline()
3518                            on_click: move |_: &UiEvent| {
3519                                let _: Result<u64, DynamicUpdateError> = hub_prb.rollback_page(ROUTE_DYNAMIC_PANEL);
3520                            }
3521                        }
3522                        EuvButton(BTN_INJECT_ROUTE.to_string(), tokens) {
3523                            secondary()
3524                            on_click: move |_: &UiEvent| {
3525                                let next_v: u64 = hub_inject.page_version(ROUTE_PROMO_LIVE).saturating_add(1);
3526                                let mut back_btn: DynamicNodeSpec = DynamicNodeSpec::button(
3527                                    BTN_RETURN_DYNAMIC.to_string(),
3528                                    "return_dynamic".to_string(),
3529                                );
3530                                back_btn.set_payload(format!("from-promo-v{next_v}"));
3531                                let page_spec: DynamicNodeSpec = DynamicNodeSpec::column().child(
3532                                    DynamicNodeSpec::card(format!("Runtime-Injected Page /promo-live (v{next_v})"))
3533                                    .child(DynamicNodeSpec::badge("Zero Recompile Route".to_string()))
3534                                    .child(DynamicNodeSpec::text(
3535                                            "This entire route was injected dynamically at runtime via signed JSON manifest."
3536                                            .to_string(),
3537                                    ))
3538                                    .child(back_btn),
3539                                );
3540                                let mut upd: DynamicPageUpdate = DynamicPageUpdate::new(
3541                                    ROUTE_PROMO_LIVE.to_string(),
3542                                    "Flash Promo (OTA)".to_string(),
3543                                    next_v,
3544                                    page_spec,
3545                                );
3546                                upd.sign();
3547                                if let Ok(json) = upd.to_json()
3548                                && hub_inject.apply_page_json(&json).is_ok()
3549                                {
3550                                    let _: bool = route_sig.set_if_changed(ROUTE_PROMO_LIVE.to_string());
3551                                }
3552                            }
3553                        }
3554                    }
3555                    page_slot {
3556                        route: ROUTE_DYNAMIC_PANEL
3557                        column {
3558                            width: Length::Percent(100.0)
3559                            padding: Edges::all(SPACE_MD)
3560                            background: p.get_muted()
3561                            border: (g.get_border_width(), p.get_border())
3562                            radius: g.get_radius_md()
3563                            text {
3564                                font_size: 13.0
3565                                color: p.get_foreground()
3566                                "Compiled Fallback Page Panel (v0) — click Hot-Update Page or Apply Atomic Bundle."
3567                            }
3568                        }
3569                    }
3570                    text {
3571                        font_size: 12.0
3572                        color: p.get_muted_foreground()
3573                        { move || {
3574                                let _: u64 = banner_rev.get();
3575                                let _: u64 = metrics_rev.get();
3576                                let _: u64 = panel_rev.get();
3577                                let tel: DynamicTelemetry = tel_sig.get();
3578                                format!(
3579                                    "Versions: banner=v{} metrics=v{} panel=v{} | Applied: comp={} page={} rollbacks={} rejected={} | Last Action: {}",
3580                                    hub_for_status.component_version(SLOT_PROMO_BANNER),
3581                                    hub_for_status.component_version(SLOT_METRICS_WIDGET),
3582                                    hub_for_status.page_version(ROUTE_DYNAMIC_PANEL),
3583                                    tel.get_components_applied(),
3584                                    tel.get_pages_applied(),
3585                                    tel.get_rollbacks(),
3586                                    tel.get_rejected(),
3587                                    action_log.get(),
3588                                )
3589                        } }
3590                    }
3591                }
3592            }
3593        }
3594    }
3595}
3596
3597/// Mounts the complete cross-platform Media Studio page demonstrating Image, SVG, GIF, LIVE Photo, Video, Audio, PDF, and native HTML5.
3598///
3599/// # Arguments
3600///
3601/// - `&ShowcaseState` - Reactive showcase state.
3602/// - `ThemeTokens` - Active design tokens.
3603///
3604/// # Returns
3605///
3606/// - `NodeId` - Mounted Media Studio page node.
3607pub fn mount_media_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3608    let p: ThemePalette = tokens.get_palette();
3609    let link_log: Signal<String> = state.get_media_html_link_log();
3610    let link_log_cb: Signal<String> = link_log;
3611    let photo_card: NodeId = view! {
3612        EuvImage(ImageAsset::sample_photo("Hero Raster Photo (PNG/BMP/WebP)"), tokens) {
3613            height: 148.0
3614        }
3615    };
3616    let svg_card: NodeId = view! {
3617        EuvSvgView(SvgDocument::sample_svg(), "Vector SVG Badge".to_string(), tokens)
3618    };
3619    let gif_card: NodeId = view! { EuvGifPlayer(state.get_media_gif(), tokens) };
3620    let live_card: NodeId = view! { EuvLivePhoto(state.get_media_live(), tokens) };
3621    let video_card: NodeId = view! { EuvVideoPlayer(state.get_media_video(), tokens) };
3622    let audio_card: NodeId = view! { EuvAudioPlayer(state.get_media_audio(), tokens) };
3623    let pdf_card: NodeId = view! { EuvPdfViewer(state.get_media_pdf(), tokens) };
3624    let html_card: NodeId = view! {
3625        EuvHtmlView(HtmlDocument::sample_html(), tokens) {
3626            on_link: move |href: String| {
3627                let _: bool = link_log_cb.set_if_changed(format!("Opened native link: {href}"));
3628            }
3629        }
3630    };
3631    view! {
3632        EuvPage(
3633            "Full Cross-Platform Media Studio".to_string(),
3634            "Pure-Rust aspect-preserving Image, SVG, animated GIF, LIVE Photo, Video, WAV Audio waveform, multi-page PDF, and sanitized zero-JS HTML5.".to_string(),
3635            tokens
3636        ) {
3637            { mount_bento_pair(photo_card, svg_card) }
3638            { mount_bento_pair(gif_card, live_card) }
3639            { mount_bento_pair(video_card, audio_card) }
3640            { mount_bento_pair(pdf_card, html_card) }
3641            text {
3642                font_size: 12.5
3643                color: p.get_muted_foreground()
3644                { move || link_log.get() }
3645            }
3646        }
3647    }
3648}
3649
3650/// Mounts a responsive 2-column Bento card pair (2 columns on desktop `Expanded`, 1 column on tablet/mobile).
3651///
3652/// # Arguments
3653///
3654/// - `NodeId` - First card node.
3655/// - `NodeId` - Second card node.
3656///
3657/// # Returns
3658///
3659/// - `NodeId` - Mounted responsive Bento container node.
3660fn mount_bento_pair(left: NodeId, right: NodeId) -> NodeId {
3661    let bp_sig: Signal<Breakpoint> = use_breakpoint();
3662    view! {
3663        grid {
3664            bind_style: move || {
3665                let cols: u16 = if bp_sig.get() == Breakpoint::Expanded { 2 } else { 1 };
3666                Style::default()
3667                .grid(cols)
3668                .width(Length::Percent(100.0))
3669                .gap(SPACE_MD)
3670            }
3671            { left }
3672            { right }
3673        }
3674    }
3675}