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 16 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); 16] = [
33        (ROUTE_OVERVIEW, NAV_LABEL_OVERVIEW),
34        (ROUTE_CHARTS, NAV_LABEL_CHARTS),
35        (ROUTE_MARKDOWN, NAV_LABEL_MARKDOWN),
36        (ROUTE_REACTIVE, NAV_LABEL_REACTIVE),
37        (ROUTE_RENDER, NAV_LABEL_RENDER),
38        (ROUTE_WINDOW, NAV_LABEL_WINDOW),
39        (ROUTE_FORMS, NAV_LABEL_FORMS),
40        (ROUTE_THEMES, NAV_LABEL_THEMES),
41        (ROUTE_DATA, NAV_LABEL_DATA),
42        (ROUTE_GAME, NAV_LABEL_GAME),
43        (ROUTE_GAME_3D, NAV_LABEL_GAME_3D),
44        (ROUTE_MEDIA, NAV_LABEL_MEDIA),
45        (ROUTE_LAB, NAV_LABEL_LAB),
46        (ROUTE_OVERLAYS, NAV_LABEL_OVERLAYS),
47        (ROUTE_DYNAMIC, NAV_LABEL_DYNAMIC),
48        (ROUTE_STRESS, NAV_LABEL_STRESS),
49    ];
50    let mut router: EuvRouter = state.get_router().clone();
51    for (path, label) in all_routes.into_iter() {
52        let st: ShowcaseState = state.clone();
53        router = router.route_component(path, label, move |_: &EuvRouteMatch| {
54            let tok: ThemeTokens = untracked(|| st.get_theme().get_tokens().get());
55            ShowcasePage::new(path, st.clone(), tok)
56        });
57    }
58    let _: EuvRouter = router;
59}
60
61/// Mounts the fully reactive showcase application shell with lazy `PageRetention::Freeze` routing and cross-component events.
62///
63/// # Arguments
64///
65/// - `&ShowcaseState` - Reactive showcase state.
66///
67/// # Returns
68///
69/// - `NodeId` - Mounted reactive root container handle.
70pub fn mount_showcase_root(state: &ShowcaseState) -> NodeId {
71    provide_theme(state.get_theme().clone());
72    ensure_showcase_routes_registered(state);
73    let global_banner: Signal<ShowcaseGlobalBanner> =
74        state!(global ShowcaseGlobalBanner = ShowcaseGlobalBanner::default());
75    let state_c: ShowcaseState = state.clone();
76    let bg_state: ShowcaseState = state.clone();
77    let fg_state: ShowcaseState = state.clone();
78    let sys_state: ShowcaseState = state.clone();
79    let sys_log_sig: Signal<Vec<String>> = state.get_system_event_log();
80    let sys_count_sig: Signal<u32> = state.get_system_event_count();
81    let (ev_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
82        let _: SystemEventSubscription = on_background(move || {
83            bg_state.freeze_for_background();
84        });
85        let _: SystemEventSubscription = on_foreground(move || {
86            fg_state.restore_from_foreground();
87        });
88        let _: SystemEventSubscription = on_system_event(move |ev: &SystemEvent| {
89            if matches!(ev, SystemEvent::Terminate) {
90                sys_state.freeze_for_background();
91                let _: usize = EuvOverlayStack::dismiss_all();
92                reset_fullscreen_state();
93            } else if matches!(ev, SystemEvent::Foreground) {
94                sys_state.restore_from_foreground();
95            }
96            let next_seq: u32 = sys_count_sig.get_untracked().saturating_add(1);
97            let _: bool = sys_count_sig.set(next_seq);
98            let entry: String = format!("#{next_seq}: {ev:?}");
99            let _: bool = sys_log_sig.update(|items: &mut Vec<String>| {
100                items.insert(0, entry);
101                if items.len() > SYS_EVENTS_LOG_LIMIT {
102                    items.truncate(SYS_EVENTS_LOG_LIMIT);
103                }
104            });
105        });
106        on_event!(ShowcasePulseEvent => move |ev: &ShowcasePulseEvent| {
107            let src: String = ev.get_source().clone();
108            let _: bool = global_banner.update(|b: &mut ShowcaseGlobalBanner| {
109                let next_pulses: u32 = b.get_pulses().saturating_add(1);
110                b.set_pulses(next_pulses);
111                b.set_last_source(src);
112            });
113        })
114    });
115    let root_node: NodeId = view! {
116        column {
117            style: {
118                width: Length::Percent(100.0)
119                height: Length::Percent(100.0)
120            }
121            bind_children: move || {
122                let tokens: ThemeTokens = untracked(|| state_c.get_theme().get_tokens().get());
123                let hub: DynamicUpdateHub = state_c.get_dynamic_hub().clone();
124                let _: u64 = hub.routes_signal().get();
125                let cmd_open: Signal<bool> = state_c.get_cmd_palette_open();
126                let cmd_query: Signal<String> = state_c.get_cmd_palette_query();
127                let cmd_items: Vec<String> = vec![
128                    CMD_ITEM_OVERVIEW.to_string(),
129                    CMD_ITEM_MARKDOWN.to_string(),
130                    CMD_ITEM_LAB.to_string(),
131                    CMD_ITEM_GAME_3D.to_string(),
132                    CMD_ITEM_MEDIA.to_string(),
133                    CMD_ITEM_DYNAMIC.to_string(),
134                    CMD_ITEM_STRESS.to_string(),
135                    CMD_ITEM_WINDOW.to_string(),
136                    CMD_ITEM_THEMES.to_string(),
137                    CMD_ITEM_CHARTS.to_string(),
138                    CMD_ITEM_TOGGLE_MODE.to_string(),
139                ];
140                let cmd_sel: Signal<Option<usize>> = Signal::new(None);
141                let cmd_route: Signal<String> = state_c.get_route();
142                let cmd_state: ShowcaseState = state_c.clone();
143                let cmd_list: NodeId = view! {
144                    EuvCommand {
145                        items: cmd_items
146                        selected: cmd_sel
147                        tokens: tokens
148                        query: cmd_query
149                        placeholder: CMD_PLACEHOLDER
150                    }
151                };
152                let (cmd_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
153                    Effect::new(move || {
154                        if let Some(idx) = cmd_sel.get() {
155                            match idx {
156                                0 => {
157                                    let _: bool = cmd_route.set_if_changed(ROUTE_OVERVIEW.to_string());
158                                }
159                                1 => {
160                                    let _: bool = cmd_route.set_if_changed(ROUTE_MARKDOWN.to_string());
161                                }
162                                2 => {
163                                    let _: bool = cmd_route.set_if_changed(ROUTE_LAB.to_string());
164                                }
165                                3 => {
166                                    let _: bool = cmd_route.set_if_changed(ROUTE_GAME_3D.to_string());
167                                }
168                                4 => {
169                                    let _: bool = cmd_route.set_if_changed(ROUTE_MEDIA.to_string());
170                                }
171                                5 => {
172                                    let _: bool = cmd_route.set_if_changed(ROUTE_DYNAMIC.to_string());
173                                }
174                                6 => {
175                                    let _: bool = cmd_route.set_if_changed(ROUTE_STRESS.to_string());
176                                }
177                                7 => {
178                                    let _: bool = cmd_route.set_if_changed(ROUTE_WINDOW.to_string());
179                                }
180                                8 => {
181                                    let _: bool = cmd_route.set_if_changed(ROUTE_THEMES.to_string());
182                                }
183                                9 => {
184                                    let _: bool = cmd_route.set_if_changed(ROUTE_CHARTS.to_string());
185                                }
186                                _ => {
187                                    cmd_state.toggle_theme_mode();
188                                }
189                            }
190                            let _: bool = cmd_sel.set_if_changed(None);
191                            let _: bool = cmd_open.set_if_changed(false);
192                        }
193                    })
194                });
195                let cmd_modal: NodeId = view! {
196                    EuvModal {
197                        open: cmd_open
198                        title: CMD_MODAL_TITLE.to_string()
199                        body: cmd_list
200                        tokens: tokens
201                    }
202                };
203                let rctx: Context = current_context();
204                let cmd_theme_sig: Memo<ThemeTokens> = state_c.get_theme().get_tokens();
205                let prev_cmd_tok: Rc<Cell<ThemeTokens>> = Rc::new(Cell::new(tokens));
206                let cmd_theme_ctx: Context = rctx.clone();
207                let (cmd_theme_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
208                    Effect::new(move || {
209                        let next_tok: ThemeTokens = cmd_theme_sig.get();
210                        let old_tok: ThemeTokens = prev_cmd_tok.replace(next_tok);
211                        if old_tok == next_tok {
212                            return;
213                        }
214                        cmd_theme_ctx.get_scene().with_write(
215                            |tree: &mut SceneTree| {
216                                remap_subtree_theme_in_place(tree, cmd_modal, old_tok, next_tok);
217                            },
218                            (),
219                        );
220                    })
221                });
222                rctx.get_scene().with_write(
223                    |tree: &mut SceneTree| {
224                        tree.attach_scope(cmd_modal, cmd_scope);
225                        tree.attach_scope(cmd_modal, cmd_theme_scope);
226                    },
227                    (),
228                );
229                let state_shell: ShowcaseState = state_c.clone();
230                let hub_shell: DynamicUpdateHub = hub.clone();
231                let global_wasm_slot: NodeId = view! {
232                    slot {
233                        id: WASM_GLOBAL_ROOT_SLOT
234                        hub: hub
235                        style: c_full_col()
236                        fallback: move || {
237                            let mut nav_items: Vec<EuvNavItem> = ShowcaseState::nav_items();
238                            for dyn_route in hub_shell.registered_routes().into_iter() {
239                                if dyn_route == ROUTE_DYNAMIC_PANEL {
240                                    continue;
241                                }
242                                if !nav_items
243                                .iter()
244                                .any(|item: &EuvNavItem| item.get_path().as_str() == dyn_route.as_str())
245                                {
246                                    let label: String = hub_shell
247                                    .page_title(&dyn_route)
248                                    .filter(|t: &String| !t.is_empty())
249                                    .unwrap_or_else(|| dyn_route.clone());
250                                    nav_items.push(EuvNavItem::new(dyn_route, label).section(NAV_SEC_RUNTIME));
251                                }
252                            }
253                            let nav: NodeId = view! {
254                                EuvSidebarNav {
255                                    items: nav_items
256                                    active_route: state_shell.get_route()
257                                    tokens: tokens
258                                }
259                            };
260                            let bottom_items: Vec<EuvNavItem> = vec![
261                                EuvNavItem::new(
262                                    ROUTE_OVERVIEW.to_string(),
263                                    BNAV_HOME_LABEL.to_string(),
264                                )
265                                .section(BNAV_HOME_ICON),
266                                EuvNavItem::new(
267                                    ROUTE_MARKDOWN.to_string(),
268                                    BNAV_DOCS_LABEL.to_string(),
269                                )
270                                .section(BNAV_DOCS_ICON),
271                                EuvNavItem::new(ROUTE_LAB.to_string(), BNAV_CASES_LABEL.to_string())
272                                .section(BNAV_CASES_ICON),
273                                EuvNavItem::new(
274                                    ROUTE_STRESS.to_string(),
275                                    BNAV_STRESS_LABEL.to_string(),
276                                )
277                                .section(BNAV_STRESS_ICON),
278                                EuvNavItem::new(
279                                    ROUTE_GAME_3D.to_string(),
280                                    BNAV_3D_LABEL.to_string(),
281                                )
282                                .section(BNAV_3D_ICON),
283                            ];
284                            let bottom_nav: NodeId = view! {
285                                EuvBottomNav {
286                                    items: bottom_items
287                                    active_route: state_shell.get_route()
288                                    tokens: tokens
289                                }
290                            };
291                            let swipe_order: Vec<String> = vec![
292                                ROUTE_OVERVIEW.to_string(),
293                                ROUTE_MARKDOWN.to_string(),
294                                ROUTE_LAB.to_string(),
295                                ROUTE_STRESS.to_string(),
296                                ROUTE_GAME_3D.to_string(),
297                                ROUTE_CHARTS.to_string(),
298                                ROUTE_FORMS.to_string(),
299                                ROUTE_MEDIA.to_string(),
300                                ROUTE_OVERLAYS.to_string(),
301                                ROUTE_THEMES.to_string(),
302                                ROUTE_DATA.to_string(),
303                                ROUTE_REACTIVE.to_string(),
304                                ROUTE_RENDER.to_string(),
305                                ROUTE_WINDOW.to_string(),
306                                ROUTE_GAME.to_string(),
307                                ROUTE_DYNAMIC.to_string(),
308                            ];
309                            let state_for_outlet: ShowcaseState = state_shell.clone();
310                            let router: EuvRouter = state_shell
311                            .get_router()
312                            .clone()
313                            .with_dynamic_hub(hub_shell.clone());
314                            let route_sig: Signal<String> = state_shell.get_route();
315                            let cur_target: String = route_sig.get_untracked();
316                            if router.get_current_path().get_untracked() != cur_target {
317                                router.replace(&cur_target);
318                            }
319                            let breadcrumb_sig: Signal<String> = Signal::new(
320                                ShowcaseState::breadcrumb_for_route(&cur_target),
321                            );
322                            let page_pad_sig: Signal<Edges> = Signal::new(Edges::all(SPACE_LG));
323                            let router_sync_in: EuvRouter = router.clone();
324                            let router_path_sig: Signal<String> = router.get_current_path();
325                            let sctx: Context = current_context();
326                            let (sync_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
327                                let _: Effect = Effect::new(move || {
328                                    let target: String = route_sig.get();
329                                    let _: bool = breadcrumb_sig
330                                    .set_if_changed(ShowcaseState::breadcrumb_for_route(&target));
331                                    if router_sync_in.get_current_path().get_untracked() != target {
332                                        router_sync_in.push(&target);
333                                    }
334                                });
335                                Effect::new(move || {
336                                    let rp: String = router_path_sig.get();
337                                    if route_sig.get_untracked() != rp {
338                                        let _: bool = route_sig.set_if_changed(rp);
339                                    }
340                                })
341                            });
342                            let page_node: NodeId = router
343                            .outlet(move |matched: &EuvRouteMatch| {
344                                let tok: ThemeTokens = untracked(|| {
345                                    state_for_outlet.get_theme().get_tokens().get()
346                                });
347                                mount_route_by_name(matched.get_path(), &state_for_outlet, tok)
348                            })
349                            .with_theme(state_shell.get_theme().clone())
350                            .with_page_padding(page_pad_sig)
351                            .with_route_order(swipe_order.clone())
352                            .with_double_back_exit(true)
353                            .mount();
354                            sctx.get_scene().with_write(
355                                |tree: &mut SceneTree| {
356                                    tree.attach_scope(page_node, sync_scope);
357                                },
358                                (),
359                            );
360                            let st_dark_top: ShowcaseState = state_shell.clone();
361                            let st_scheme_top: ShowcaseState = state_shell.clone();
362                            let st_dark_mobile: ShowcaseState = state_shell.clone();
363                            let st_scheme_mobile: ShowcaseState = state_shell.clone();
364                            let theme_mode_sig: Signal<ThemeMode> = state_shell.get_theme().get_mode();
365                            let icon_btn_style_desk = move || -> Style {
366                                let live_tok: ThemeTokens = use_live_tokens(tokens);
367                                let live_p: ThemePalette = live_tok.get_palette();
368                                let live_g: ThemeGeometry = live_tok.get_geometry();
369                                Style::default()
370                                .row()
371                                .width(Length::Px(30.0))
372                                .height(Length::Px(30.0))
373                                .justify(JustifyContent::Center)
374                                .align(AlignItems::Center)
375                                .background(live_p.get_background())
376                                .border(live_g.get_border_width(), live_p.get_border())
377                                .radius(live_g.get_radius_md())
378                                .cursor(CursorIcon::Pointer)
379                            };
380                            let icon_btn_style_mob = move || -> Style {
381                                let live_tok: ThemeTokens = use_live_tokens(tokens);
382                                let live_p: ThemePalette = live_tok.get_palette();
383                                let live_g: ThemeGeometry = live_tok.get_geometry();
384                                Style::default()
385                                .row()
386                                .width(Length::Px(28.0))
387                                .height(Length::Px(28.0))
388                                .justify(JustifyContent::Center)
389                                .align(AlignItems::Center)
390                                .background(live_p.get_background())
391                                .border(live_g.get_border_width(), live_p.get_border())
392                                .radius(live_g.get_radius_md())
393                                .cursor(CursorIcon::Pointer)
394                            };
395                            let paint_search_desk = move |bounds: Rect, dl: &mut DisplayList| {
396                                let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
397                                draw_euv_icon(EuvIconName::Search, bounds, dl, live_p.get_foreground());
398                            };
399                            let paint_search_mob = move |bounds: Rect, dl: &mut DisplayList| {
400                                let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
401                                draw_euv_icon(EuvIconName::Search, bounds, dl, live_p.get_foreground());
402                            };
403                            let paint_scheme_desk = move |bounds: Rect, dl: &mut DisplayList| {
404                                let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
405                                draw_euv_icon(EuvIconName::Palette, bounds, dl, live_p.get_primary());
406                            };
407                            let paint_scheme_mob = move |bounds: Rect, dl: &mut DisplayList| {
408                                let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
409                                draw_euv_icon(EuvIconName::Palette, bounds, dl, live_p.get_primary());
410                            };
411                            let paint_mode_desk = move |bounds: Rect, dl: &mut DisplayList| {
412                                let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
413                                let glyph: EuvIconName = match theme_mode_sig.get_untracked() {
414                                    ThemeMode::Dark => EuvIconName::Sun,
415                                    ThemeMode::Light => EuvIconName::Moon,
416                                };
417                                draw_euv_icon(glyph, bounds, dl, live_p.get_foreground());
418                            };
419                            let paint_mode_mob = move |bounds: Rect, dl: &mut DisplayList| {
420                                let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
421                                let glyph: EuvIconName = match theme_mode_sig.get_untracked() {
422                                    ThemeMode::Dark => EuvIconName::Sun,
423                                    ThemeMode::Light => EuvIconName::Moon,
424                                };
425                                draw_euv_icon(glyph, bounds, dl, live_p.get_foreground());
426                            };
427                            let on_open_cmd_desktop = move |_: &UiEvent| {
428                                let _: bool = cmd_open.set_if_changed(true);
429                            };
430                            let on_open_cmd_mobile = move |_: &UiEvent| {
431                                let _: bool = cmd_open.set_if_changed(true);
432                            };
433                            let on_cycle_scheme_desktop = move |_: &UiEvent| {
434                                st_scheme_top.next_scheme();
435                            };
436                            let on_cycle_scheme_mobile = move |_: &UiEvent| {
437                                st_scheme_mobile.next_scheme();
438                            };
439                            let on_toggle_mode_desktop = move |_: &UiEvent| {
440                                st_dark_top.toggle_theme_mode();
441                            };
442                            let on_toggle_mode_mobile = move |_: &UiEvent| {
443                                st_dark_mobile.toggle_theme_mode();
444                            };
445                            let top_actions: NodeId = view! {
446                                row {
447                                    style: {
448                                        gap: SPACE_XS
449                                        align: AlignItems::Center
450                                    }
451                                    row {
452                                        bind_style: icon_btn_style_desk
453                                        role: A11yRole::Button
454                                        a11y_label: BTN_SEARCH_A11Y.to_string()
455                                        on_click: on_open_cmd_desktop
456                                        canvas {
457                                            style: {
458                                                width: Length::Px(15.0)
459                                                height: Length::Px(15.0)
460                                            }
461                                            painter: paint_search_desk
462                                        }
463                                    }
464                                    row {
465                                        bind_style: icon_btn_style_desk
466                                        role: A11yRole::Button
467                                        a11y_label: BTN_SCHEME_A11Y.to_string()
468                                        on_click: on_cycle_scheme_desktop
469                                        canvas {
470                                            style: {
471                                                width: Length::Px(15.0)
472                                                height: Length::Px(15.0)
473                                            }
474                                            painter: paint_scheme_desk
475                                        }
476                                    }
477                                    row {
478                                        bind_style: icon_btn_style_desk
479                                        role: A11yRole::Button
480                                        a11y_label: BTN_MODE_A11Y.to_string()
481                                        on_click: on_toggle_mode_desktop
482                                        canvas {
483                                            style: {
484                                                width: Length::Px(15.0)
485                                                height: Length::Px(15.0)
486                                            }
487                                            painter: paint_mode_desk
488                                        }
489                                    }
490                                }
491                            };
492                            let mobile_actions: NodeId = view! {
493                                row {
494                                    style: {
495                                        gap: SPACE_XS
496                                        align: AlignItems::Center
497                                    }
498                                    row {
499                                        bind_style: icon_btn_style_mob
500                                        role: A11yRole::Button
501                                        a11y_label: BTN_SEARCH_A11Y.to_string()
502                                        on_click: on_open_cmd_mobile
503                                        canvas {
504                                            style: {
505                                                width: Length::Px(14.0)
506                                                height: Length::Px(14.0)
507                                            }
508                                            painter: paint_search_mob
509                                        }
510                                    }
511                                    row {
512                                        bind_style: icon_btn_style_mob
513                                        role: A11yRole::Button
514                                        a11y_label: BTN_SCHEME_A11Y.to_string()
515                                        on_click: on_cycle_scheme_mobile
516                                        canvas {
517                                            style: {
518                                                width: Length::Px(14.0)
519                                                height: Length::Px(14.0)
520                                            }
521                                            painter: paint_scheme_mob
522                                        }
523                                    }
524                                    row {
525                                        bind_style: icon_btn_style_mob
526                                        role: A11yRole::Button
527                                        a11y_label: BTN_MODE_A11Y.to_string()
528                                        on_click: on_toggle_mode_mobile
529                                        canvas {
530                                            style: {
531                                                width: Length::Px(14.0)
532                                                height: Length::Px(14.0)
533                                            }
534                                            painter: paint_mode_mob
535                                        }
536                                    }
537                                }
538                            };
539                            view! {
540                                EuvAppShell {
541                                    brand: SHOWCASE_BRAND.to_string()
542                                    sidebar: nav
543                                    main_content: page_node
544                                    tokens: tokens
545                                    theme: state_shell.get_theme().clone()
546                                    page_padding: page_pad_sig
547                                    route: state_shell.get_route()
548                                    breadcrumb: breadcrumb_sig
549                                    top_bar_actions: top_actions
550                                    mobile_header_actions: mobile_actions
551                                    bottom_nav: bottom_nav
552                                    swipe_routes: swipe_order
553                                    show_fps: true
554                                }
555                            }
556                        }
557                    }
558                };
559                vec![global_wasm_slot, cmd_modal]
560            }
561        }
562    };
563    let root_ctx: Context = current_context();
564    root_ctx.get_scene().with_write(
565        |tree: &mut SceneTree| {
566            tree.attach_scope(root_node, ev_scope);
567        },
568        (),
569    );
570    root_node
571}
572
573/// Mounts the showcase page corresponding to the active route in `state`.
574///
575/// # Arguments
576///
577/// - `&ShowcaseState` - Reactive showcase state.
578/// - `ThemeTokens` - Active resolved design tokens.
579///
580/// # Returns
581///
582/// - `NodeId` - Mounted page container handle.
583pub fn mount_active_route(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
584    let route: String = state.get_route().get_untracked();
585    mount_route_by_name(&route, state, tokens)
586}
587
588/// Dispatches a route string to its corresponding declarative showcase page builder.
589///
590/// # Arguments
591///
592/// - `&str` - Active route path.
593/// - `&ShowcaseState` - Reactive showcase state.
594/// - `ThemeTokens` - Active resolved design tokens.
595///
596/// # Returns
597///
598/// - `NodeId` - Mounted page container handle.
599pub(crate) fn mount_route_by_name(
600    route: &str,
601    state: &ShowcaseState,
602    tokens: ThemeTokens,
603) -> NodeId {
604    match route {
605        ROUTE_CHARTS => mount_charts_page(state, tokens),
606        ROUTE_MARKDOWN => mount_markdown_page(state, tokens),
607        ROUTE_REACTIVE => mount_reactive_page(state, tokens),
608        ROUTE_RENDER => mount_render_page(state, tokens),
609        ROUTE_WINDOW => mount_window_page(state, tokens),
610        ROUTE_FORMS => mount_forms_page(state, tokens),
611        ROUTE_THEMES => mount_themes_page(state, tokens),
612        ROUTE_DATA => mount_data_page(state, tokens),
613        ROUTE_GAME => mount_game_page(state, tokens),
614        ROUTE_GAME_3D => mount_game3d_page(state, tokens),
615        ROUTE_MEDIA => mount_media_page(state, tokens),
616        ROUTE_LAB => mount_lab_page(state, tokens),
617        ROUTE_OVERLAYS => mount_overlays_page(state, tokens),
618        ROUTE_DYNAMIC => mount_dynamic_page(state, tokens),
619        ROUTE_STRESS => mount_stress_page(state, tokens),
620        _ => mount_overview_page(state, tokens),
621    }
622}
623
624/// Mounts the redesigned flagship overview dashboard with hero banner, KPI cards, live Freeze lifecycle monitor, cross-component event & state demo, and 7-platform matrix.
625///
626/// # Arguments
627///
628/// - `&ShowcaseState` - Reactive showcase state.
629/// - `ThemeTokens` - Active design tokens.
630///
631/// # Returns
632///
633/// - `NodeId` - Mounted overview page node.
634pub fn mount_overview_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
635    let p: ThemePalette = tokens.get_palette();
636    let g: ThemeGeometry = tokens.get_geometry();
637    let route_sig: Signal<String> = state.get_route();
638    let frozen_sig: Signal<usize> = state.get_router().get_frozen_count();
639    let mounts_sig: Signal<u32> = state.get_lifecycle_mounts();
640    let freezes_sig: Signal<u32> = state.get_lifecycle_freezes();
641    let resumes_sig: Signal<u32> = state.get_lifecycle_resumes();
642    let last_ev_sig: Signal<String> = state.get_lifecycle_last_event();
643    let entries_sig: Signal<Vec<EuvRouteLifecycleEntry>> =
644        state.get_router().get_lifecycle_entries();
645    let local_counter: LocalState<u32> = state!(1_u32);
646    let global_banner: Signal<ShowcaseGlobalBanner> =
647        state!(global ShowcaseGlobalBanner = ShowcaseGlobalBanner::default());
648    let dir_items: [(&str, &str, &str, &str); 15] = [
649        (
650            ROUTE_CHARTS,
651            HOME_DIR_TAG_CH,
652            NAV_LABEL_CHARTS,
653            HOME_DIR_DESC_CH,
654        ),
655        (
656            ROUTE_MARKDOWN,
657            HOME_DIR_TAG_MD,
658            NAV_LABEL_MARKDOWN,
659            HOME_DIR_DESC_MD,
660        ),
661        (ROUTE_LAB, HOME_DIR_TAG_LB, NAV_LABEL_LAB, HOME_DIR_DESC_LB),
662        (
663            ROUTE_STRESS,
664            HOME_DIR_TAG_ST,
665            NAV_LABEL_STRESS,
666            HOME_DIR_DESC_ST,
667        ),
668        (
669            ROUTE_GAME_3D,
670            HOME_DIR_TAG_3D,
671            NAV_LABEL_GAME_3D,
672            HOME_DIR_DESC_3D,
673        ),
674        (
675            ROUTE_FORMS,
676            HOME_DIR_TAG_FM,
677            NAV_LABEL_FORMS,
678            HOME_DIR_DESC_FM,
679        ),
680        (
681            ROUTE_MEDIA,
682            HOME_DIR_TAG_ME,
683            NAV_LABEL_MEDIA,
684            HOME_DIR_DESC_ME,
685        ),
686        (
687            ROUTE_OVERLAYS,
688            HOME_DIR_TAG_OV,
689            NAV_LABEL_OVERLAYS,
690            HOME_DIR_DESC_OV,
691        ),
692        (
693            ROUTE_THEMES,
694            HOME_DIR_TAG_TH,
695            NAV_LABEL_THEMES,
696            HOME_DIR_DESC_TH,
697        ),
698        (
699            ROUTE_DATA,
700            HOME_DIR_TAG_DT,
701            NAV_LABEL_DATA,
702            HOME_DIR_DESC_DT,
703        ),
704        (
705            ROUTE_REACTIVE,
706            HOME_DIR_TAG_RX,
707            NAV_LABEL_REACTIVE,
708            HOME_DIR_DESC_RX,
709        ),
710        (
711            ROUTE_RENDER,
712            HOME_DIR_TAG_RN,
713            NAV_LABEL_RENDER,
714            HOME_DIR_DESC_RN,
715        ),
716        (
717            ROUTE_WINDOW,
718            HOME_DIR_TAG_OS,
719            NAV_LABEL_WINDOW,
720            HOME_DIR_DESC_OS,
721        ),
722        (
723            ROUTE_GAME,
724            HOME_DIR_TAG_2D,
725            NAV_LABEL_GAME,
726            HOME_DIR_DESC_2D,
727        ),
728        (
729            ROUTE_DYNAMIC,
730            HOME_DIR_TAG_OT,
731            NAV_LABEL_DYNAMIC,
732            HOME_DIR_DESC_OT,
733        ),
734    ];
735    let dir_rows: Vec<NodeId> = dir_items
736        .iter()
737        .map(|(path, tag, label, desc): &(&str, &str, &str, &str)| {
738            let target: String = (*path).to_string();
739            let badge_txt: String = (*tag).to_string();
740            let title_txt: String = (*label).to_string();
741            let desc_txt: String = (*desc).to_string();
742            let on_dir_click = move |_: &UiEvent| {
743                let _: bool = route_sig.set_if_changed(target.clone());
744            };
745            view! {
746                row {
747                    style: {
748                        width: Length::Percent(100.0)
749                        padding: Edges::symmetric(SPACE_SM, SPACE_MD)
750                        align: AlignItems::Center
751                        justify: JustifyContent::SpaceBetween
752                        gap: SPACE_SM
753                        radius: g.get_radius_md()
754                        background: p.get_background()
755                        border: (g.get_border_width(), p.get_border())
756                        cursor: CursorIcon::Pointer
757                    }
758                    on_click: on_dir_click
759                    row {
760                        style: {
761                            flex_grow: 1.0
762                            flex_shrink: 1.0
763                            min_width: Length::Px(0.0)
764                            align: AlignItems::Center
765                            gap: SPACE_SM
766                            overflow: Overflow::Hidden
767                        }
768                        row {
769                            style: {
770                                width: Length::Px(34.0)
771                                height: Length::Px(34.0)
772                                flex_shrink: 0.0
773                                radius: 99.0
774                                background: p.get_primary().with_alpha(26)
775                                justify: JustifyContent::Center
776                                align: AlignItems::Center
777                            }
778                            text {
779                                style: {
780                                    font_size: 11.5
781                                    font_family: FontFamily::Monospace
782                                    font_weight: FontWeight::Bold
783                                    color: p.get_primary()
784                                    text_align: TextAlign::Center
785                                    text_overflow: TextOverflow::Clip
786                                }
787                                { badge_txt }
788                            }
789                        }
790                        column {
791                            style: {
792                                flex_grow: 1.0
793                                flex_shrink: 1.0
794                                min_width: Length::Px(0.0)
795                                gap: 2.0
796                                overflow: Overflow::Hidden
797                            }
798                            text {
799                                style: {
800                                    width: Length::Percent(100.0)
801                                    font_size: 14.0
802                                    font_weight: FontWeight::SemiBold
803                                    color: p.get_foreground()
804                                    overflow: Overflow::Hidden
805                                    text_overflow: TextOverflow::Ellipsis
806                                }
807                                { title_txt }
808                            }
809                            text {
810                                style: {
811                                    width: Length::Percent(100.0)
812                                    font_size: 12.0
813                                    color: p.get_muted_foreground()
814                                    overflow: Overflow::Hidden
815                                    text_overflow: TextOverflow::Ellipsis
816                                }
817                                { desc_txt }
818                            }
819                        }
820                    }
821                    text {
822                        style: {
823                            flex_shrink: 0.0
824                            font_size: 14.0
825                            font_weight: FontWeight::Bold
826                            color: p.get_muted_foreground()
827                            text_overflow: TextOverflow::Clip
828                        }
829                        { HOME_DIR_ARROW }
830                    }
831                }
832            }
833        })
834        .collect();
835    let hero_style: Style = style! {
836        FlexDirection::Column
837        Overflow::Hidden
838        width: Length::Percent(100.0)
839        padding: Edges::all(SPACE_XL)
840        gap: SPACE_MD
841        background: p.get_card()
842        border: (g.get_border_width().max(1.0), p.get_primary().with_alpha(96))
843        radius: g.get_radius_xl()
844        shadow: g.get_shadow_md()
845    };
846    let on_open_markdown = move |_: &UiEvent| {
847        let _: bool = route_sig.set_if_changed(ROUTE_MARKDOWN.to_string());
848    };
849    let on_open_charts = move |_: &UiEvent| {
850        let _: bool = route_sig.set_if_changed(ROUTE_CHARTS.to_string());
851    };
852    let on_open_3d = move |_: &UiEvent| {
853        let _: bool = route_sig.set_if_changed(ROUTE_GAME_3D.to_string());
854    };
855    let on_open_stress = move |_: &UiEvent| {
856        let _: bool = route_sig.set_if_changed(ROUTE_STRESS.to_string());
857    };
858    let on_open_reactive = move |_: &UiEvent| {
859        let _: bool = route_sig.set_if_changed(ROUTE_REACTIVE.to_string());
860    };
861    let lifecycle_stats_text = move || -> String {
862        format!(
863            "Frozen Pages: {} | Mounts: {} | Freezes: {} | Resumes: {}",
864            frozen_sig.get(),
865            mounts_sig.get(),
866            freezes_sig.get(),
867            resumes_sig.get()
868        )
869    };
870    let last_hook_text = move || -> String { format!("Last Hook: {}", last_ev_sig.get()) };
871    let cached_routes_text = move || -> String {
872        let entries: Vec<EuvRouteLifecycleEntry> = entries_sig.get();
873        let summary: Vec<String> = entries
874            .iter()
875            .map(|e: &EuvRouteLifecycleEntry| format!("{}={:?}", e.get_path(), e.get_phase()))
876            .collect();
877        if summary.is_empty() {
878            LIFECYCLE_ACTIVE_DEFAULT.to_string()
879        } else {
880            format!("Cached Routes: {}", summary.join(" | "))
881        }
882    };
883    let global_local_text = move || -> String {
884        let gb: ShowcaseGlobalBanner = global_banner.get();
885        let last_src: &str = if gb.get_last_source().is_empty() {
886            SOURCE_NONE
887        } else {
888            gb.get_last_source().as_str()
889        };
890        format!(
891            "GlobalState Pulses: {} (source: {}) | LocalState (preserved across Freeze): {}",
892            gb.get_pulses(),
893            last_src,
894            local_counter.get()
895        )
896    };
897    let on_emit_pulse = move |_: &UiEvent| {
898        let seq: u32 = local_counter.get_untracked();
899        emit!(ShowcasePulseEvent {
900            source: ROUTE_OVERVIEW.to_string(),
901            seq,
902        });
903    };
904    let on_local_inc = move |_: &UiEvent| {
905        let _: bool = local_counter.update(|v: &mut u32| *v += 1);
906    };
907    let on_open_game = move |_: &UiEvent| {
908        let _: bool = route_sig.set_if_changed(ROUTE_GAME.to_string());
909    };
910    let on_open_window = move |_: &UiEvent| {
911        let _: bool = route_sig.set_if_changed(ROUTE_WINDOW.to_string());
912    };
913    view! {
914        EuvPage {
915            title: OVERVIEW_TITLE.to_string()
916            subtitle: OVERVIEW_SUBTITLE.to_string()
917            tokens: tokens
918            EuvCard {
919                title: HOME_DIR_TITLE.to_string()
920                tokens: tokens
921                subtitle: HOME_DIR_SUBTITLE
922                column {
923                    style: {
924                        width: Length::Percent(100.0)
925                        gap: SPACE_SM
926                    }
927                    ..dir_rows
928                }
929            }
930            view {
931                style: hero_style
932                row {
933                    style: {
934                        width: Length::Percent(100.0)
935                        flex_wrap: FlexWrap::Wrap
936                        align: AlignItems::Center
937                        gap: SPACE_XS
938                    }
939                    EuvBadge {
940                        label: HERO_BADGE_VER.to_string()
941                        tone: EuvTone::Primary
942                        tokens: tokens
943                    }
944                    EuvBadge {
945                        label: HERO_BADGE_ZERO_WV.to_string()
946                        tone: EuvTone::Success
947                        tokens: tokens
948                    }
949                    EuvBadge {
950                        label: HERO_BADGE_EVA.to_string()
951                        tone: EuvTone::Neutral
952                        tokens: tokens
953                    }
954                    EuvBadge {
955                        label: HERO_BADGE_FREEZE.to_string()
956                        tone: EuvTone::Warning
957                        tokens: tokens
958                    }
959                }
960                text {
961                    style: {
962                        width: Length::Percent(100.0)
963                        font_size: 20.0
964                        font_weight: FontWeight::Bold
965                        color: p.get_foreground()
966                    }
967                    { HERO_HEADLINE }
968                }
969                text {
970                    style: {
971                        width: Length::Percent(100.0)
972                        font_size: 13.5
973                        color: p.get_muted_foreground()
974                    }
975                    { HERO_DESCRIPTION }
976                }
977                EuvActionRow {
978                    EuvButton {
979                        label: BTN_OPEN_CHARTS.to_string()
980                        tokens: tokens
981                        on_click: on_open_charts
982                    }
983                    EuvButton {
984                        label: BTN_OPEN_MARKDOWN.to_string()
985                        tokens: tokens
986                        secondary()
987                        on_click: on_open_markdown
988                    }
989                    EuvButton {
990                        label: BTN_OPEN_3D_RT.to_string()
991                        tokens: tokens
992                        secondary()
993                        on_click: on_open_3d
994                    }
995                    EuvButton {
996                        label: BTN_OPEN_STRESS_LAB.to_string()
997                        tokens: tokens
998                        outline()
999                        on_click: on_open_stress
1000                    }
1001                    EuvButton {
1002                        label: BTN_TRY_REACTIVITY.to_string()
1003                        tokens: tokens
1004                        outline()
1005                        on_click: on_open_reactive
1006                    }
1007                }
1008            }
1009            EuvStatGrid {
1010                EuvStatCard {
1011                    label: STAT_PLATFORMS_LABEL.to_string()
1012                    value: STAT_PLATFORMS_VAL.to_string()
1013                    caption: STAT_PLATFORMS_CAP.to_string()
1014                    tokens: tokens
1015                }
1016                EuvStatCard {
1017                    label: STAT_SCHEMES_LABEL.to_string()
1018                    value: STAT_SCHEMES_VAL.to_string()
1019                    caption: STAT_SCHEMES_CAP.to_string()
1020                    tokens: tokens
1021                }
1022                EuvStatCard {
1023                    label: STAT_RENDER_LABEL.to_string()
1024                    value: STAT_RENDER_VAL.to_string()
1025                    caption: STAT_RENDER_CAP.to_string()
1026                    tokens: tokens
1027                }
1028            }
1029            EuvCard {
1030                title: CARD_LIFECYCLE_TITLE.to_string()
1031                tokens: tokens
1032                subtitle: CARD_LIFECYCLE_SUB
1033                text {
1034                    style: {
1035                        width: Length::Percent(100.0)
1036                        font_size: 13.5
1037                        font_weight: FontWeight::SemiBold
1038                        color: p.get_primary()
1039                    }
1040                    { lifecycle_stats_text }
1041                }
1042                text {
1043                    style: {
1044                        width: Length::Percent(100.0)
1045                        font_size: 12.5
1046                        font_family: FontFamily::Monospace
1047                        color: p.get_muted_foreground()
1048                    }
1049                    { last_hook_text }
1050                }
1051                text {
1052                    style: {
1053                        width: Length::Percent(100.0)
1054                        font_size: 12.5
1055                        color: p.get_foreground()
1056                    }
1057                    { cached_routes_text }
1058                }
1059                text {
1060                    style: {
1061                        width: Length::Percent(100.0)
1062                        font_size: 12.5
1063                        font_weight: FontWeight::Medium
1064                        color: p.get_success()
1065                    }
1066                    { global_local_text }
1067                }
1068                EuvActionRow {
1069                    EuvButton {
1070                        label: BTN_EMIT_PULSE.to_string()
1071                        tokens: tokens
1072                        sm()
1073                        on_click: on_emit_pulse
1074                    }
1075                    EuvButton {
1076                        label: BTN_LOCAL_INC.to_string()
1077                        tokens: tokens
1078                        secondary()
1079                        sm()
1080                        on_click: on_local_inc
1081                    }
1082                    EuvButton {
1083                        label: BTN_OPEN_GAME_ENGINE.to_string()
1084                        tokens: tokens
1085                        outline()
1086                        sm()
1087                        on_click: on_open_game
1088                    }
1089                    EuvButton {
1090                        label: BTN_OPEN_OS_SERVICES.to_string()
1091                        tokens: tokens
1092                        outline()
1093                        sm()
1094                        on_click: on_open_window
1095                    }
1096                }
1097            }
1098            EuvCard {
1099                title: CARD_PLATFORMS_TITLE.to_string()
1100                tokens: tokens
1101                subtitle: CARD_PLATFORMS_SUB
1102                EuvTable {
1103                    headers: vec![
1104                        TABLE_COL_TARGET.to_string(),
1105                        TABLE_COL_BACKEND.to_string(),
1106                        TABLE_COL_GPU.to_string(),
1107                    ]
1108                    rows: vec![
1109                        vec![ROW_WEB.to_string(), ROW_WEB_API.to_string(), ROW_WEB_GPU.to_string()],
1110                        vec![ROW_MACOS.to_string(), ROW_MACOS_API.to_string(), ROW_MACOS_GPU.to_string()],
1111                        vec![ROW_IOS.to_string(), ROW_IOS_API.to_string(), ROW_MACOS_GPU.to_string()],
1112                        vec![ROW_ANDROID.to_string(), ROW_ANDROID_API.to_string(), ROW_ANDROID_GPU.to_string()],
1113                        vec![ROW_WINDOWS.to_string(), ROW_WINDOWS_API.to_string(), ROW_WINDOWS_GPU.to_string()],
1114                        vec![ROW_LINUX.to_string(), ROW_LINUX_API.to_string(), ROW_ANDROID_GPU.to_string()],
1115                    ]
1116                    tokens: tokens
1117                }
1118            }
1119        }
1120    }
1121}
1122
1123/// 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.
1124///
1125/// # Arguments
1126///
1127/// - `&ShowcaseState` - Reactive showcase state.
1128/// - `ThemeTokens` - Active design tokens.
1129///
1130/// # Returns
1131///
1132/// - `NodeId` - Mounted Markdown & Code Studio page handle.
1133pub fn mount_markdown_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1134    let p: ThemePalette = tokens.get_palette();
1135    let eva: CodeThemePalette = CodeThemePalette::resolve(tokens.get_mode());
1136    let st_toggle: ShowcaseState = state.clone();
1137    let theme_mode_sig: Signal<ThemeMode> = state.get_theme().get_mode();
1138    let lang_tab: Signal<usize> = state.get_markdown_lang_tab();
1139    let selectable_sig: Signal<bool> = state.get_markdown_selectable();
1140    let copy_log: Signal<String> = state.get_markdown_copy_log();
1141    let link_log: Signal<String> = state.get_markdown_link_log();
1142    let tasks_toggled: Signal<u32> = state.get_markdown_tasks_toggled();
1143    let copy_log_doc: Signal<String> = copy_log;
1144    let link_log_doc: Signal<String> = link_log;
1145    let tasks_doc: Signal<u32> = tasks_toggled;
1146    let active_theme_desc = move || -> String {
1147        match theme_mode_sig.get() {
1148            ThemeMode::Light => MD_THEME_DESC_LIGHT.to_string(),
1149            ThemeMode::Dark => MD_THEME_DESC_DARK.to_string(),
1150        }
1151    };
1152    let swatch_nodes: Vec<NodeId> = (0usize..6usize)
1153        .map(|slot: usize| {
1154            let swatch_style = move || -> Style {
1155                let live_eva: CodeThemePalette = CodeThemePalette::resolve(theme_mode_sig.get());
1156                let col: Color = match slot {
1157                    0 => live_eva.get_background(),
1158                    1 => live_eva.get_keyword(),
1159                    2 => live_eva.get_function(),
1160                    3 => live_eva.get_number(),
1161                    4 => live_eva.get_constant(),
1162                    _ => live_eva.get_property(),
1163                };
1164                Style::default()
1165                    .width(Length::Px(22.0))
1166                    .height(Length::Px(22.0))
1167                    .radius(6.0)
1168                    .background(col)
1169                    .border(1.0, live_eva.get_border())
1170            };
1171            view! {
1172                view {
1173                    bind_style: swatch_style
1174                }
1175            }
1176        })
1177        .collect();
1178    let on_toggle_eva = move |_: &UiEvent| {
1179        st_toggle.toggle_theme_mode();
1180    };
1181    let on_emit_pulse = move |_: &UiEvent| {
1182        emit!(ShowcasePulseEvent {
1183            source: ROUTE_MARKDOWN.to_string(),
1184            seq: 1,
1185        });
1186    };
1187    let build_code_tab = move || -> Vec<NodeId> {
1188        let tab: usize = lang_tab.get();
1189        let is_sel: bool = selectable_sig.get();
1190        let live_tok: ThemeTokens = live_tokens_untracked(tokens);
1191        let (src, lang, fname): (&str, &str, &str) = match tab {
1192            1 => (MD_SAMPLE_TS, MD_LANG_TS, MD_FILE_TS),
1193            2 => (MD_SAMPLE_JSON, MD_LANG_JSON, MD_FILE_JSON),
1194            3 => (MD_SAMPLE_DIFF, MD_LANG_DIFF, MD_FILE_DIFF),
1195            _ => (MD_SAMPLE_RUST, MD_LANG_RUST, MD_FILE_RUST),
1196        };
1197        let cb_log: Signal<String> = copy_log;
1198        let block: NodeId = EuvCodeBlock::new(src.to_string(), live_tok)
1199            .language(lang)
1200            .filename(fname)
1201            .line_numbers(true)
1202            .max_height(260.0)
1203            .selectable(is_sel)
1204            .on_copy(move |txt: &str| {
1205                let _: bool = cb_log.set(format!(
1206                    "Copied {} bytes ({lang}) via Eva Bold EuvCodeBlock",
1207                    txt.len()
1208                ));
1209            })
1210            .mount();
1211        vec![block]
1212    };
1213    let telemetry_text = move || -> String {
1214        format!(
1215            "Copy: {} | Link: {} | Tasks Toggled: {} | Selectable: {}",
1216            copy_log.get(),
1217            link_log.get(),
1218            tasks_toggled.get(),
1219            selectable_sig.get()
1220        )
1221    };
1222    let build_md_doc = move || -> Vec<NodeId> {
1223        let is_sel: bool = selectable_sig.get();
1224        let live_tok: ThemeTokens = live_tokens_untracked(tokens);
1225        let doc_node: NodeId = EuvMarkdown::new(MD_FULL_DOCUMENT.to_string(), live_tok)
1226            .selectable(is_sel)
1227            .on_link(move |url: &str| {
1228                let _: bool = link_log_doc.set(url.to_string());
1229            })
1230            .on_copy(move |code: &str| {
1231                let _: bool =
1232                    copy_log_doc.set(format!("Copied {} bytes from Markdown block", code.len()));
1233            })
1234            .on_toggle_task(move |_idx: usize, _checked: bool| {
1235                let _: bool = tasks_doc.update(|n: &mut u32| *n += 1);
1236            })
1237            .mount();
1238        vec![doc_node]
1239    };
1240    view! {
1241        EuvPage {
1242            title: MD_STUDIO_TITLE.to_string()
1243            subtitle: MD_STUDIO_SUBTITLE.to_string()
1244            tokens: tokens
1245            EuvCard {
1246                title: MD_THEME_CARD_TITLE.to_string()
1247                tokens: tokens
1248                subtitle: MD_THEME_CARD_SUB
1249                text {
1250                    style: {
1251                        font_size: 12.5
1252                        font_family: FontFamily::Monospace
1253                        font_weight: FontWeight::SemiBold
1254                        color: eva.get_keyword()
1255                    }
1256                    { active_theme_desc }
1257                }
1258                row {
1259                    style: {
1260                        width: Length::Percent(100.0)
1261                        align: AlignItems::Center
1262                        flex_wrap: FlexWrap::Wrap
1263                        gap: SPACE_SM
1264                    }
1265                    ..swatch_nodes
1266                }
1267                EuvActionRow {
1268                    EuvButton {
1269                        label: BTN_TOGGLE_EVA_MODE.to_string()
1270                        tokens: tokens
1271                        sm()
1272                        on_click: on_toggle_eva
1273                    }
1274                    EuvButton {
1275                        label: BTN_EMIT_PULSE.to_string()
1276                        tokens: tokens
1277                        outline()
1278                        sm()
1279                        on_click: on_emit_pulse
1280                    }
1281                    EuvSwitch {
1282                        checked: selectable_sig
1283                        label: MD_SELECTABLE_LABEL.to_string()
1284                        tokens: tokens
1285                    }
1286                }
1287            }
1288            EuvCard {
1289                title: MD_CODE_CARD_TITLE.to_string()
1290                tokens: tokens
1291                subtitle: MD_CODE_CARD_SUB
1292                EuvSegmented {
1293                    options: vec![
1294                        MD_TAB_RUST.to_string(),
1295                        MD_TAB_TS.to_string(),
1296                        MD_TAB_JSON.to_string(),
1297                        MD_TAB_DIFF.to_string(),
1298                    ]
1299                    selected: lang_tab
1300                    tokens: tokens
1301                }
1302                column {
1303                    style: {
1304                        width: Length::Percent(100.0)
1305                    }
1306                    bind_children: build_code_tab
1307                }
1308                text {
1309                    style: {
1310                        font_size: 12.0
1311                        font_family: FontFamily::Monospace
1312                        color: p.get_primary()
1313                    }
1314                    { telemetry_text }
1315                }
1316            }
1317            EuvCard {
1318                title: MD_DOC_CARD_TITLE.to_string()
1319                tokens: tokens
1320                subtitle: MD_DOC_CARD_SUB
1321                column {
1322                    style: {
1323                        width: Length::Percent(100.0)
1324                    }
1325                    bind_children: build_md_doc
1326                }
1327            }
1328        }
1329    }
1330}
1331
1332/// Mounts the fine-grained reactivity showcase demonstrating `Signal`, `computed!`, `batch`, and `view!`.
1333///
1334/// # Arguments
1335///
1336/// - `&ShowcaseState` - Reactive showcase state.
1337/// - `ThemeTokens` - Active design tokens.
1338///
1339/// # Returns
1340///
1341/// - `NodeId` - Mounted reactivity page node.
1342pub fn mount_reactive_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1343    let p: ThemePalette = tokens.get_palette();
1344    let counter: Signal<i32> = state.get_counter();
1345    let doubled: Memo<i32> = state.get_doubled();
1346    view! {
1347        EuvPage {
1348            title: REACTIVE_TITLE.to_string()
1349            subtitle: REACTIVE_SUBTITLE.to_string()
1350            tokens: tokens
1351            EuvCard {
1352                title: REACTIVE_CARD_TITLE.to_string()
1353                tokens: tokens
1354                subtitle: REACTIVE_CARD_SUB
1355                column {
1356                    style: {
1357                        gap: SPACE_MD
1358                    }
1359                    text {
1360                        style: {
1361                            font_size: 18.0
1362                            font_weight: FontWeight::Bold
1363                            color: p.get_foreground()
1364                        }
1365                        { move || format!("{PREFIX_COUNTER}{}", counter.get()) }
1366                    }
1367                    text {
1368                        style: {
1369                            font_size: 15.0
1370                            color: p.get_primary()
1371                        }
1372                        { move || format!("{PREFIX_DOUBLED}{}", doubled.get()) }
1373                    }
1374                    EuvActionRow {
1375                        EuvButton {
1376                            label: BTN_INCREMENT.to_string()
1377                            tokens: tokens
1378                            on_click: move |_: &UiEvent| {
1379                                let _: bool = counter.update(|v: &mut i32| *v += 1);
1380                            }
1381                        }
1382                        EuvButton {
1383                            label: BTN_BATCH_TEN.to_string()
1384                            tokens: tokens
1385                            secondary()
1386                            on_click: move |_: &UiEvent| {
1387                                batch(|| {
1388                                    for _ in 0..10 {
1389                                        let _: bool = counter.update(|v: &mut i32| *v += 1);
1390                                    }
1391                                });
1392                            }
1393                        }
1394                        EuvButton {
1395                            label: BTN_RESET.to_string()
1396                            tokens: tokens
1397                            outline()
1398                            on_click: move |_: &UiEvent| {
1399                                let _: bool = counter.set_if_changed(0);
1400                            }
1401                        }
1402                    }
1403                }
1404            }
1405        }
1406    }
1407}
1408
1409/// Mounts the multi-mode rendering inspector with live mode switcher and vector `canvas` via `view!`.
1410///
1411/// # Arguments
1412///
1413/// - `&ShowcaseState` - Reactive showcase state.
1414/// - `ThemeTokens` - Active design tokens.
1415///
1416/// # Returns
1417///
1418/// - `NodeId` - Mounted rendering page node.
1419pub fn mount_render_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1420    let p: ThemePalette = tokens.get_palette();
1421    let g: ThemeGeometry = tokens.get_geometry();
1422    let mode_idx: Signal<usize> = state.get_render_mode_index();
1423    view! {
1424        EuvPage {
1425            title: RENDER_TITLE.to_string()
1426            subtitle: RENDER_SUBTITLE.to_string()
1427            tokens: tokens
1428            EuvCard {
1429                title: RENDER_CARD_TITLE.to_string()
1430                tokens: tokens
1431                subtitle: RENDER_CARD_SUB
1432                EuvSegmented {
1433                    options: vec![
1434                        MODE_AUTO.to_string(),
1435                        MODE_SOFTWARE.to_string(),
1436                        MODE_HARDWARE.to_string(),
1437                        MODE_HYBRID.to_string(),
1438                    ]
1439                    selected: mode_idx
1440                    tokens: tokens
1441                }
1442                column {
1443                    style: {
1444                        gap: SPACE_SM
1445                    }
1446                    text {
1447                        style: {
1448                            font_size: 13.0
1449                            font_weight: FontWeight::Medium
1450                            color: p.get_primary()
1451                        }
1452                        { move || format!("Active Pipeline Selection: {}", match mode_idx.get() { 1 => MODE_SOFTWARE, 2 => MODE_HARDWARE, 3 => MODE_HYBRID, _ => MODE_AUTO }) }
1453                    }
1454                    text {
1455                        style: {
1456                            font_size: 13.0
1457                            font_weight: FontWeight::Medium
1458                            color: p.get_muted_foreground()
1459                        }
1460                        { CANVAS_LABEL }
1461                    }
1462                    canvas {
1463                        style: {
1464                            width: Length::Percent(100.0)
1465                            height: Length::Px(140.0)
1466                            background: p.get_muted()
1467                            border: (g.get_border_width(), p.get_border())
1468                            radius: g.get_radius_md()
1469                        }
1470                        painter: move |bounds: Rect, dl: &mut DisplayList| {
1471                            let bw: f32 = bounds.get_width().max(120.0);
1472                            let rect_w: f32 = (bw * 0.28).clamp(56.0, 160.0);
1473                            let circle_r: f32 = (bw * 0.08).clamp(20.0, 42.0);
1474                            let circle_x: f32 = bounds.get_x() + 16.0 + rect_w + circle_r + 20.0;
1475                            let line_x0: f32 = (circle_x + circle_r + 16.0).min(bounds.right() - 24.0);
1476                            let line_x1: f32 = (bounds.right() - 16.0).max(line_x0);
1477                            dl.push(DrawCommand::FillRoundedRect {
1478                                rect: Rect::new(bounds.get_x() + 16.0, bounds.get_y() + 16.0, rect_w, 108.0),
1479                                color: p.get_primary(),
1480                                radius: CornerRadius::all(14.0),
1481                                border: Border::default(),
1482                            });
1483                            dl.push(DrawCommand::Circle {
1484                                center: Point::new(circle_x.min(bounds.right() - circle_r - 8.0), bounds.get_y() + 70.0),
1485                                radius: circle_r,
1486                                color: p.get_success(),
1487                            });
1488                            dl.push(DrawCommand::Line {
1489                                from: Point::new(line_x0, bounds.get_y() + 28.0),
1490                                to: Point::new(line_x1, bounds.get_y() + 112.0),
1491                                color: p.get_warning(),
1492                                width: 3.0,
1493                            });
1494                        }
1495                    }
1496                }
1497            }
1498        }
1499    }
1500}
1501
1502/// Mounts the OS capabilities page with interactive A11y, Protocol Registration, Dynamic Island, Permissions, and Haptics.
1503///
1504/// # Arguments
1505///
1506/// - `&ShowcaseState` - Reactive showcase state.
1507/// - `ThemeTokens` - Active design tokens.
1508///
1509/// # Returns
1510///
1511/// - `NodeId` - Mounted window & OS services page node.
1512pub fn mount_window_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1513    let p: ThemePalette = tokens.get_palette();
1514    let font_info: SystemFontInfo = NativeSystemFont::system().font_info();
1515    let gpu_driver: NativeGpuDriver = NativeGpuDriver::probe(GraphicsBackend::Metal);
1516    let gpu_info: &GpuAdapterInfo = gpu_driver.get_adapter();
1517    let platform: PlatformKind = current_platform();
1518    let caps: PlatformCapabilities = PlatformCapabilities::for_platform(platform);
1519    let hub: PlatformServiceHub = PlatformServiceHub::new(platform);
1520    let cam_key: &'static str = SystemPermission::Camera.native_key(platform);
1521    let island_active: Signal<bool> = state.get_island_active();
1522    let island_progress: Signal<u8> = state.get_island_progress();
1523    let cam_status: Signal<String> = state.get_camera_perm_status();
1524    let proto_status: Signal<String> = state.get_protocol_status();
1525    let a11y_count: Signal<u32> = state.get_a11y_announcements();
1526    let haptic_count: Signal<u32> = state.get_haptic_pulses();
1527    let bp_sig: Signal<Breakpoint> = use_breakpoint();
1528    let vp_sig: Signal<Size> = use_viewport_size();
1529    let summary: String = format!(
1530        "Platform: {:?} | Font: {} ({:?}) | GPU: {} (shader_ok={})",
1531        platform,
1532        font_info.get_family_name(),
1533        font_info.get_backend(),
1534        gpu_info.get_device_name(),
1535        gpu_info.get_shader_compiled()
1536    );
1537    let native_feedback: Signal<String> = Signal::new(
1538        "Ready — tap any OS capability below to trigger native platform feedback".to_string(),
1539    );
1540    let fs_sig: Signal<bool> = state.get_fullscreen();
1541    let ctx_win: Context = current_context();
1542    let prev_fs: Rc<Cell<bool>> = Rc::new(Cell::new(fs_sig.get_untracked()));
1543    let (fs_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
1544        Effect::new(move || {
1545            let now_fs: bool = fs_sig.get();
1546            if prev_fs.replace(now_fs) != now_fs {
1547                let arg: &str = if now_fs { "on" } else { "off" };
1548                let _: bool = dispatch_native_action(NATIVE_ACTION_FULLSCREEN, arg, "");
1549                let _: bool = native_feedback.set(format!("Immersive fullscreen mode: {arg}"));
1550            }
1551        })
1552    });
1553    let target_plat_idx: Signal<usize> = state.get_os_target_platform_idx();
1554    let island_mode_idx: Signal<usize> = state.get_island_mode_idx();
1555    let sys_notifs: Signal<Vec<(String, String)>> = state.get_system_notifications();
1556    let perm_statuses: Signal<Vec<PermissionStatus>> = state.get_permission_statuses();
1557    let all_platforms: [PlatformKind; 7] = [
1558        PlatformKind::Ios,
1559        PlatformKind::IpadOs,
1560        PlatformKind::Android,
1561        PlatformKind::MacOs,
1562        PlatformKind::Windows,
1563        PlatformKind::Linux,
1564        PlatformKind::Web,
1565    ];
1566    let all_island_modes: [IslandPresentationMode; 6] = [
1567        IslandPresentationMode::Compact,
1568        IslandPresentationMode::Minimal,
1569        IslandPresentationMode::Expanded,
1570        IslandPresentationMode::LockScreen,
1571        IslandPresentationMode::FallbackNotification,
1572        IslandPresentationMode::FallbackStatusBar,
1573    ];
1574    let all_perms: [SystemPermission; 14] = [
1575        SystemPermission::Camera,
1576        SystemPermission::Microphone,
1577        SystemPermission::LocationWhenInUse,
1578        SystemPermission::LocationAlways,
1579        SystemPermission::Notifications,
1580        SystemPermission::Photos,
1581        SystemPermission::Contacts,
1582        SystemPermission::Calendar,
1583        SystemPermission::Bluetooth,
1584        SystemPermission::Biometrics,
1585        SystemPermission::FileStorage,
1586        SystemPermission::ClipboardRead,
1587        SystemPermission::MotionSensors,
1588        SystemPermission::LocalNetwork,
1589    ];
1590    let fps_limit_sig: Signal<Option<u32>> = ctx_win.get_fps_limit();
1591    let live_fps_sig: Signal<f32> = ctx_win.get_live_fps();
1592    let native_hz_sig: Signal<f32> = ctx_win.get_display_refresh_rate();
1593    let fps_idx: Signal<usize> = Signal::new(match fps_limit_sig.get_untracked() {
1594        Some(30) => 1,
1595        Some(60) => 2,
1596        Some(120) => 3,
1597        Some(144) => 4,
1598        Some(240) => 5,
1599        _ => 0,
1600    });
1601    let (fps_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
1602        Effect::new(move || {
1603            let next_cap: Option<u32> = match fps_idx.get() {
1604                1 => Some(30),
1605                2 => Some(60),
1606                3 => Some(120),
1607                4 => Some(144),
1608                5 => Some(240),
1609                _ => None,
1610            };
1611            let _: bool = fps_limit_sig.set_if_changed(next_cap);
1612        })
1613    });
1614    let mut body_id: NodeId = NodeId::default();
1615    let mut fps_card_id: NodeId = NodeId::default();
1616    let app_state_sig: Signal<AppState> = use_app_state();
1617    let sys_theme_sig: Signal<SystemTheme> = use_system_theme();
1618    let net_status_sig: Signal<NetworkStatus> = use_network_status();
1619    let kb_height_sig: Signal<f32> = use_keyboard_height();
1620    let safe_area_sig: Signal<SafeAreaInsets> = use_safe_area();
1621    let sys_log_sig: Signal<Vec<String>> = state.get_system_event_log();
1622    let sys_count_sig: Signal<u32> = state.get_system_event_count();
1623    let bg_frozen_sig: Signal<bool> = state.get_bg_frozen();
1624    let bg_freeze_cnt: Signal<u32> = state.get_bg_freeze_count();
1625    let bg_restore_cnt: Signal<u32> = state.get_bg_restore_count();
1626    let page_appear_count: Signal<u32> = Signal::new(0);
1627    let page_disappear_count: Signal<u32> = Signal::new(0);
1628    let _: SystemEventSubscription = on_appear(move || {
1629        let _: bool = page_appear_count.update(|n: &mut u32| *n = n.saturating_add(1));
1630    });
1631    let _: SystemEventSubscription = on_disappear(move || {
1632        let _: bool = page_disappear_count.update(|n: &mut u32| *n = n.saturating_add(1));
1633    });
1634    let sys_primary_line = move || -> String {
1635        format!(
1636            "AppState: {:?} | OS Theme: {:?} | Network: {:?}",
1637            app_state_sig.get(),
1638            sys_theme_sig.get(),
1639            net_status_sig.get()
1640        )
1641    };
1642    let sys_freeze_line = move || -> String {
1643        let mode: &str = if bg_frozen_sig.get() {
1644            BG_FREEZE_STATUS_FROZEN
1645        } else {
1646            BG_FREEZE_STATUS_ACTIVE
1647        };
1648        format!(
1649            "Background Freeze: {mode} | Freezes: {} | Restores: {}",
1650            bg_freeze_cnt.get(),
1651            bg_restore_cnt.get()
1652        )
1653    };
1654    let sys_secondary_line = move || -> String {
1655        let sa: SafeAreaInsets = safe_area_sig.get();
1656        format!(
1657            "Keyboard: {:.0}px | SafeArea: T{:.0} R{:.0} B{:.0} L{:.0} | Page Appear: {} / Disappear: {} | Total Events: {}",
1658            kb_height_sig.get(),
1659            sa.get_top(),
1660            sa.get_right(),
1661            sa.get_bottom(),
1662            sa.get_left(),
1663            page_appear_count.get(),
1664            page_disappear_count.get(),
1665            sys_count_sig.get()
1666        )
1667    };
1668    let build_sys_log_rows = move || -> Vec<NodeId> {
1669        let live_tok: ThemeTokens = live_tokens_untracked(tokens);
1670        let live_p: ThemePalette = live_tok.get_palette();
1671        sys_log_sig
1672            .get()
1673            .into_iter()
1674            .map(|entry: String| {
1675                view! {
1676                    text {
1677                        style: {
1678                            width: Length::Percent(100.0)
1679                            font_size: 12.0
1680                            font_family: FontFamily::Monospace
1681                            color: live_p.get_muted_foreground()
1682                        }
1683                        { entry }
1684                    }
1685                }
1686            })
1687            .collect()
1688    };
1689    let page: NodeId = view! {
1690        EuvPage {
1691            title: WINDOW_TITLE.to_string()
1692            subtitle: WINDOW_SUBTITLE.to_string()
1693            tokens: tokens
1694            EuvCard {
1695                title: SYS_EVENTS_CARD_TITLE.to_string()
1696                tokens: tokens
1697                subtitle: SYS_EVENTS_CARD_SUB
1698                selectable: true
1699                text {
1700                    style: {
1701                        width: Length::Percent(100.0)
1702                        font_size: 13.5
1703                        font_weight: FontWeight::SemiBold
1704                        color: p.get_primary()
1705                    }
1706                    { sys_primary_line }
1707                }
1708                text {
1709                    style: {
1710                        width: Length::Percent(100.0)
1711                        font_size: 12.5
1712                        font_weight: FontWeight::Medium
1713                        color: p.get_success()
1714                    }
1715                    { sys_freeze_line }
1716                }
1717                text {
1718                    style: {
1719                        width: Length::Percent(100.0)
1720                        font_size: 12.5
1721                        font_family: FontFamily::Monospace
1722                        color: p.get_foreground()
1723                    }
1724                    { sys_secondary_line }
1725                }
1726                column {
1727                    style: {
1728                        width: Length::Percent(100.0)
1729                        padding: Edges::all(SPACE_SM)
1730                        gap: 4.0
1731                        background: p.get_muted()
1732                        radius: tokens.get_geometry().get_radius_md()
1733                        overflow: Overflow::Hidden
1734                    }
1735                    bind_children: build_sys_log_rows
1736                }
1737            }
1738            EuvCard {
1739                title: WINDOW_CARD_TITLE.to_string()
1740                tokens: tokens
1741                subtitle: WINDOW_CARD_SUB
1742                column {
1743                    node_ref: body_id
1744                    role: A11yRole::Region
1745                    a11y_label: "Platform Telemetry"
1746                    style: {
1747                        gap: SPACE_MD
1748                    }
1749                    text {
1750                        style: {
1751                            font_size: 13.0
1752                            font_weight: FontWeight::SemiBold
1753                            color: p.get_success()
1754                        }
1755                        { move || native_feedback.get() }
1756                    }
1757                    text {
1758                        style: {
1759                            font_size: 14.0
1760                            font_weight: FontWeight::Medium
1761                            color: p.get_foreground()
1762                        }
1763                        { summary }
1764                    }
1765                    text {
1766                        style: {
1767                            font_size: 13.0
1768                            font_weight: FontWeight::SemiBold
1769                            color: p.get_primary()
1770                        }
1771                        { move || {
1772                            let vp: Size = vp_sig.get();
1773                            format!("Live Viewport: {:.0}x{:.0} | Breakpoint: {:?}", vp.get_width(), vp.get_height(), bp_sig.get())
1774                        } }
1775                    }
1776                    text {
1777                        style: {
1778                            font_size: 13.0
1779                            color: p.get_primary()
1780                        }
1781                        { move || format!("Dynamic Island: active={} ({}%) | Mode: {:?} | Biometrics: {:?}", island_active.get(), island_progress.get(), PlatformServiceHub::default_island_mode(platform), hub.biometric_kind()) }
1782                    }
1783                    text {
1784                        style: {
1785                            font_size: 13.0
1786                            color: p.get_muted_foreground()
1787                        }
1788                        { move || format!("Protocol: {} | Camera: {} ({cam_key})", proto_status.get(), cam_status.get()) }
1789                    }
1790                    text {
1791                        style: {
1792                            font_size: 13.0
1793                            color: p.get_muted_foreground()
1794                        }
1795                        { move || format!("A11y Bridge: {} (announcements={}) | Haptics: {} (pulses={})", caps.get_accessibility_bridge(), a11y_count.get(), caps.get_haptics(), haptic_count.get()) }
1796                    }
1797                    EuvActionRow {
1798                        EuvButton {
1799                            label: "Toggle Dynamic Island".to_string()
1800                            tokens: tokens
1801                            on_click: move |_: &UiEvent| {
1802                                let next_active: bool = !island_active.get_untracked();
1803                                let _: bool = island_active.set_if_changed(next_active);
1804                                let next_pct: u8 = if next_active {
1805                                    let cur: u8 = island_progress.get_untracked();
1806                                    if cur >= 100 { 25 } else { (cur + 25).min(100) }
1807                                } else {
1808                                    island_progress.get_untracked()
1809                                };
1810                                let _: bool = island_progress.set_if_changed(next_pct);
1811                                let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
1812                                if next_active {
1813                                    let mut content: LiveActivityContent = LiveActivityContent::new(
1814                                        "Euv Live Activity".to_string(),
1815                                        format!("Active ({next_pct}%) on {platform:?}"),
1816                                    );
1817                                    content.set_progress_percent(Some(next_pct));
1818                                    let _ = svc.start_live_activity("euv-showcase-island".to_string(), content);
1819                                    let _: bool = native_feedback.set(format!(
1820                                        "Dynamic Island LIVE ({next_pct}%) dispatched to {platform:?}"
1821                                    ));
1822                                } else {
1823                                    let _: bool = dispatch_native_action(
1824                                        NATIVE_ACTION_ISLAND,
1825                                        "stop",
1826                                        "Dynamic Island paused",
1827                                    );
1828                                    let _: bool = native_feedback.set("Dynamic Island session ended".to_string());
1829                                }
1830                            }
1831                        }
1832                        EuvButton {
1833                            label: "Register euv:// Protocol".to_string()
1834                            tokens: tokens
1835                            secondary()
1836                            on_click: move |_: &UiEvent| {
1837                                let mut reg: ProtocolRegistry = ProtocolRegistry::new();
1838                                let spec: ProtocolRegistration = ProtocolRegistration::new(
1839                                    "euv".to_string(),
1840                                    "euv Native Showcase".to_string(),
1841                                    SHOWCASE_BUNDLE_ID.to_string(),
1842                                );
1843                                let native_ok: bool =
1844                                dispatch_native_action(NATIVE_ACTION_PROTOCOL, "euv", SHOWCASE_BUNDLE_ID);
1845                                if let Ok(desc) = reg.register(spec, platform) {
1846                                    let tag: &str = if native_ok { "OS Bridged" } else { "Verified" };
1847                                    let msg: String = format!("Registered euv:// via {} ({tag})", desc.get_mechanism());
1848                                    let _: bool = proto_status.set_if_changed(msg.clone());
1849                                    let _: bool = native_feedback.set(msg);
1850                                }
1851                            }
1852                        }
1853                        EuvButton {
1854                            label: "Request Camera Permission".to_string()
1855                            tokens: tokens
1856                            outline()
1857                            on_click: move |_: &UiEvent| {
1858                                let mut mgr: PermissionManager = PermissionManager::new();
1859                                let desc: PermissionDescriptor = mgr.request(
1860                                    SystemPermission::Camera,
1861                                    "Native camera preview".to_string(),
1862                                    platform,
1863                                );
1864                                let msg: String = format!("{:?} ({})", desc.get_status(), desc.get_native_key());
1865                                let _: bool = cam_status.set_if_changed(msg.clone());
1866                                let _: bool = native_feedback.set(format!("Permission requested: {msg}"));
1867                            }
1868                        }
1869                        EuvButton {
1870                            label: "Announce A11y + Haptic".to_string()
1871                            tokens: tokens
1872                            outline()
1873                            on_click: move |_: &UiEvent| {
1874                                let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
1875                                let fired: bool = svc.trigger_haptic(HapticStyle::Medium);
1876                                svc.announce_a11y(
1877                                    "euv native accessibility pulse".to_string(),
1878                                    A11yLiveRegion::Polite,
1879                                );
1880                                let _: bool = a11y_count.update(|v: &mut u32| *v += 1);
1881                                let _: bool = haptic_count.update(|v: &mut u32| *v += 1);
1882                                let _: bool = native_feedback.set(format!(
1883                                    "Dispatched Haptic pulse (ok={fired}) + A11y announcement #{}",
1884                                    a11y_count.get_untracked()
1885                                ));
1886                            }
1887                        }
1888                    }
1889                    EuvSwitch {
1890                        checked: fs_sig
1891                        label: SWITCH_FULLSCREEN.to_string()
1892                        tokens: tokens
1893                    }
1894                    EuvCodeBlock {
1895                        code: CODE_WINDOW_SNIPPET.to_string()
1896                        tokens: tokens
1897                    }
1898                }
1899            }
1900            EuvCard {
1901                title: "Cross-Platform Frame Rate Limiter".to_string()
1902                tokens: tokens
1903                node_ref: fps_card_id
1904                subtitle: "Prioritizes native hardware refresh rate (120Hz/144Hz/180Hz+) across Desktop, Web, Android & iOS"
1905                EuvSegmented {
1906                    options: vec![
1907                        "Native Auto".to_string(),
1908                        "30 FPS".to_string(),
1909                        "60 FPS".to_string(),
1910                        "120 FPS".to_string(),
1911                        "144 FPS".to_string(),
1912                        "240 FPS".to_string(),
1913                    ]
1914                    selected: fps_idx
1915                    tokens: tokens
1916                }
1917                text {
1918                    style: {
1919                        font_size: 13.0
1920                        font_weight: FontWeight::SemiBold
1921                        color: p.get_primary()
1922                    }
1923                    { move || {
1924                        let native_hz: f32 = native_hz_sig.get();
1925                        let cap_txt: String = match fps_limit_sig.get() {
1926                            None => format!("Native Auto ({native_hz:.0} Hz)"),
1927                            Some(v) => format!("Capped at {v} FPS"),
1928                        };
1929                        let live_fps: f32 = live_fps_sig.get();
1930                        if !live_fps.is_finite() || live_fps <= 0.05 {
1931                            format!("Frame Rate Policy: {cap_txt} | Status: Idle (0.0 FPS)")
1932                        } else {
1933                            format!(
1934                                "Frame Rate Policy: {cap_txt} | Live Measured: {live_fps:.1} FPS"
1935                            )
1936                        }
1937                    } }
1938                }
1939            }
1940            EuvCard {
1941                title: "Cross-Platform Dynamic Island & Notifications".to_string()
1942                tokens: tokens
1943                subtitle: "Test Live Activities across all 7 platforms and dispatch native OS notifications"
1944                EuvSegmented {
1945                    options: vec![
1946                        "iOS".to_string(),
1947                        "iPadOS".to_string(),
1948                        LABEL_PLATFORM_ANDROID.to_string(),
1949                        LABEL_PLATFORM_MACOS.to_string(),
1950                        "Windows".to_string(),
1951                        "Linux".to_string(),
1952                        "Web".to_string(),
1953                    ]
1954                    selected: target_plat_idx
1955                    tokens: tokens
1956                }
1957                EuvSegmented {
1958                    options: vec![
1959                        "Compact".to_string(),
1960                        "Minimal".to_string(),
1961                        "Expanded".to_string(),
1962                        "LockScreen".to_string(),
1963                        "FallbackNotif".to_string(),
1964                        "StatusBar".to_string(),
1965                    ]
1966                    selected: island_mode_idx
1967                    tokens: tokens
1968                }
1969                column {
1970                    style: {
1971                        width: Length::Percent(100.0)
1972                        padding: Edges::all(SPACE_MD)
1973                        gap: SPACE_XS
1974                        background: Color::hex(0x09090B)
1975                        radius: 20.0
1976                    }
1977                    text {
1978                        style: {
1979                            font_size: 12.0
1980                            font_weight: FontWeight::SemiBold
1981                            color: Color::hex(0xF8FAFC)
1982                        }
1983                        { move || {
1984                            let tp: PlatformKind = all_platforms[target_plat_idx.get() % 7];
1985                            let im: IslandPresentationMode = all_island_modes[island_mode_idx.get() % 6];
1986                            let def_im: IslandPresentationMode = PlatformServiceHub::default_island_mode(tp);
1987                            let active: bool = island_active.get();
1988                            let pct: u8 = island_progress.get();
1989                            let state_tag: &str = if active { "LIVE" } else { "IDLE" };
1990                            format!(
1991                                "[{state_tag}] Dynamic Island ({tp:?}) | Mode: {im:?} (OS Default: {def_im:?}) | Progress: {pct}%"
1992                            )
1993                        } }
1994                    }
1995                }
1996                EuvActionRow {
1997                    EuvButton {
1998                        label: "Trigger Alert Notification".to_string()
1999                        tokens: tokens
2000                        sm()
2001                        on_click: move |_: &UiEvent| {
2002                            let tp: PlatformKind = all_platforms[target_plat_idx.get_untracked() % 7];
2003                            let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
2004                            let n: SystemNotification = SystemNotification::new(
2005                                "euv-alert".to_string(),
2006                                format!("{tp:?} Alert Notification"),
2007                                "High-priority native OS alert dispatched cleanly".to_string(),
2008                            );
2009                            svc.send_notification(n.clone());
2010                            let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
2011                                v.insert(0, (n.get_title().clone(), n.get_body().clone()));
2012                                v.truncate(5);
2013                            });
2014                        }
2015                    }
2016                    EuvButton {
2017                        label: "Trigger Silent + Badge(3)".to_string()
2018                        tokens: tokens
2019                        secondary()
2020                        sm()
2021                        on_click: move |_: &UiEvent| {
2022                            let tp: PlatformKind = all_platforms[target_plat_idx.get_untracked() % 7];
2023                            let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
2024                            let mut n: SystemNotification = SystemNotification::new(
2025                                "euv-sync".to_string(),
2026                                format!("{tp:?} Silent Sync (Badge 3)"),
2027                                "Background OTA sync completed silently".to_string(),
2028                            );
2029                            n.set_silent(true);
2030                            n.set_badge_count(Some(3));
2031                            svc.send_notification(n.clone());
2032                            let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
2033                                v.insert(0, (n.get_title().clone(), n.get_body().clone()));
2034                                v.truncate(5);
2035                            });
2036                        }
2037                    }
2038                    EuvButton {
2039                        label: "Clear Notifications".to_string()
2040                        tokens: tokens
2041                        outline()
2042                        sm()
2043                        on_click: move |_: &UiEvent| {
2044                            let _: bool = sys_notifs.set_if_changed(Vec::new());
2045                        }
2046                    }
2047                }
2048                EuvSonner {
2049                    messages: sys_notifs
2050                    tokens: tokens
2051                }
2052            }
2053            EuvCard {
2054                title: "Complete 14-Category OS Permissions Matrix".to_string()
2055                tokens: tokens
2056                subtitle: "Inspect per-platform native entitlement keys and test Grant / Deny flows"
2057                column {
2058                    style: {
2059                        width: Length::Percent(100.0)
2060                        gap: SPACE_XS
2061                    }
2062                    bind_children: move || {
2063                        let tp: PlatformKind = all_platforms[target_plat_idx.get() % 7];
2064                        let statuses: Vec<PermissionStatus> = perm_statuses.get();
2065                        let g: ThemeGeometry = tokens.get_geometry();
2066                        all_perms
2067                        .iter()
2068                        .copied()
2069                        .enumerate()
2070                        .map(|(idx, perm): (usize, SystemPermission)| {
2071                            let st: PermissionStatus = statuses
2072                            .get(idx)
2073                            .copied()
2074                            .unwrap_or(PermissionStatus::NotDetermined);
2075                            let native_key: &'static str = perm.native_key(tp);
2076                            view! {
2077                                column {
2078                                    style: {
2079                                        width: Length::Percent(100.0)
2080                                        padding: Edges::symmetric(SPACE_SM, SPACE_SM)
2081                                        gap: SPACE_XS
2082                                        background: p.get_card()
2083                                        border: (g.get_border_width(), p.get_border())
2084                                        radius: g.get_radius_sm()
2085                                    }
2086                                    text {
2087                                        style: {
2088                                            width: Length::Percent(100.0)
2089                                            font_size: 12.0
2090                                            color: p.get_foreground()
2091                                        }
2092                                        { format!("{perm:?} [{st:?}] · {native_key}") }
2093                                    }
2094                                    EuvActionRow {
2095                                        EuvButton {
2096                                            label: "Request".to_string()
2097                                            tokens: tokens
2098                                            outline()
2099                                            sm()
2100                                            on_click: move |_: &UiEvent| {
2101                                                let mut mgr: PermissionManager = PermissionManager::new();
2102                                                let desc: PermissionDescriptor =
2103                                                mgr.request(perm, format!("Test {perm:?} access"), platform);
2104                                                let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
2105                                                    if let Some(slot) = vec.get_mut(idx) {
2106                                                        *slot = desc.get_status();
2107                                                    }
2108                                                });
2109                                                let _: bool = native_feedback.set(format!(
2110                                                    "Requested {perm:?} ({}) -> {:?}",
2111                                                    perm.native_key(platform),
2112                                                    desc.get_status()
2113                                                ));
2114                                            }
2115                                        }
2116                                        EuvButton {
2117                                            label: "Deny".to_string()
2118                                            tokens: tokens
2119                                            destructive()
2120                                            sm()
2121                                            on_click: move |_: &UiEvent| {
2122                                                let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
2123                                                    if let Some(slot) = vec.get_mut(idx) {
2124                                                        *slot = PermissionStatus::Denied;
2125                                                    }
2126                                                });
2127                                                let _: bool = native_feedback.set(format!("Marked {perm:?} as Denied"));
2128                                            }
2129                                        }
2130                                    }
2131                                }
2132                            }
2133                        })
2134                        .collect()
2135                    }
2136                }
2137            }
2138        }
2139    };
2140    ctx_win.get_scene().with_write(
2141        |tree: &mut SceneTree| {
2142            tree.attach_scope(body_id, fs_scope);
2143            tree.attach_scope(fps_card_id, fps_scope);
2144        },
2145        (),
2146    );
2147    page
2148}
2149
2150/// Mounts the complete shadcn/ui component showcase and production edge-case regression lab.
2151///
2152/// # Arguments
2153///
2154/// - `&ShowcaseState` - Reactive showcase state.
2155/// - `ThemeTokens` - Active design tokens.
2156///
2157/// # Returns
2158///
2159/// - `NodeId` - Mounted UI & Edge Lab page node.
2160pub fn mount_lab_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2161    let p: ThemePalette = tokens.get_palette();
2162    let g: ThemeGeometry = tokens.get_geometry();
2163    let ctx: Context = current_context();
2164    let chart_data: Vec<EuvChartPoint> = vec![
2165        EuvChartPoint::new("Mon".to_string(), 60.0),
2166        EuvChartPoint::new("Tue".to_string(), 88.0),
2167        EuvChartPoint::new("Wed".to_string(), 118.0),
2168        EuvChartPoint::new("Thu".to_string(), 104.0),
2169        EuvChartPoint::new("Fri".to_string(), 120.0),
2170        EuvChartPoint::new("Sat".to_string(), 116.0),
2171    ];
2172    let left_split: NodeId = view! {
2173        text {
2174            style: {
2175                font_size: 13.0
2176                color: p.get_foreground()
2177            }
2178            "Left Split Pane (Drag handle ->)"
2179        }
2180    };
2181    let right_split: NodeId = view! {
2182        text {
2183            style: {
2184                font_size: 13.0
2185                color: p.get_muted_foreground()
2186            }
2187            "Right Split Pane (Zero rebuild on drag)"
2188        }
2189    };
2190    let rtl_sig: Signal<bool> = state.get_lab_rtl_mode();
2191    let block_scroll: Signal<bool> = state.get_lab_block_scroll_chain();
2192    let stop_bubble: Signal<bool> = state.get_lab_stop_click_bubble();
2193    let parent_clicks: Signal<u32> = state.get_lab_parent_clicks();
2194    let child_clicks: Signal<u32> = state.get_lab_child_clicks();
2195    let preserve_cnt: Signal<u32> = state.get_lab_resize_preserve_count();
2196    let modal_open: Signal<bool> = state.get_modal_open();
2197    let drawer_open: Signal<bool> = state.get_drawer_open();
2198    let attach_vis: Signal<bool> = Signal::new(true);
2199    let q_sel: Signal<Option<usize>> = Signal::new(Some(0));
2200    let touches_sig: Signal<Vec<(u64, Point)>> = ctx.get_active_touches();
2201    let pad_bounds_cell: Rc<Cell<Rect>> = Rc::new(Cell::new(Rect::default()));
2202    let pad_bounds_memo: Rc<Cell<Rect>> = Rc::clone(&pad_bounds_cell);
2203    let pad_bounds_paint: Rc<Cell<Rect>> = Rc::clone(&pad_bounds_cell);
2204    let touch_ids_memo: Memo<Vec<u64>> = Memo::new(move || {
2205        let pad_rect: Rect = pad_bounds_memo.get();
2206        if pad_rect.get_width() <= 0.0 || pad_rect.get_height() <= 0.0 {
2207            return Vec::new();
2208        }
2209        touches_sig
2210            .get()
2211            .into_iter()
2212            .filter(|(_, pt): &(u64, Point)| pad_rect.contains(*pt))
2213            .map(|(id, _): (u64, Point)| id)
2214            .collect()
2215    });
2216    let ai_tick: Signal<u32> = Signal::new(0);
2217    let ai_fps_sig: Signal<f32> = ctx.get_live_fps();
2218    let ai_hz_sig: Signal<f32> = ctx.get_display_refresh_rate();
2219    let ai_route_sig: Signal<String> = state.get_route();
2220    let ai_scheme_sig: Signal<DesignScheme> = state.get_theme().get_scheme();
2221    let mut touch_pad_id: NodeId = NodeId::default();
2222    let page: NodeId = view! {
2223        EuvPage {
2224            title: "UI & Edge-Case Lab".to_string()
2225            subtitle: "Full shadcn/ui component parity + multi-touch, propagation, overlay stack, AI Schema v1, and resize-preservation tests".to_string()
2226            tokens: tokens
2227            EuvCard {
2228                title: "Multi-Touch & Gesture Isolation Pad".to_string()
2229                tokens: tokens
2230                subtitle: "Simultaneous multi-finger tracking with pointer IDs, pinch distance line, and gesture non-penetration"
2231                row {
2232                    style: {
2233                        width: Length::Percent(100.0)
2234                        height: Length::Px(22.0)
2235                        align: AlignItems::Center
2236                        overflow: Overflow::Hidden
2237                    }
2238                    text {
2239                        style: {
2240                            width: Length::Percent(100.0)
2241                            font_size: 12.5
2242                            font_weight: FontWeight::Medium
2243                            color: p.get_primary()
2244                            overflow: Overflow::Hidden
2245                            text_overflow: TextOverflow::Ellipsis
2246                        }
2247                        { move || {
2248                            let ids: Vec<u64> = touch_ids_memo.get();
2249                            if ids.is_empty() {
2250                                TOUCH_PAD_READY_TEXT.to_string()
2251                            } else {
2252                                let labels: String = ids
2253                                .iter()
2254                                .map(|id: &u64| format!("#{id}"))
2255                                .collect::<Vec<String>>()
2256                                .join(" ");
2257                                format!("Inside Pad: {} | Pointers: {labels}", ids.len())
2258                            }
2259                        } }
2260                    }
2261                }
2262                canvas {
2263                    node_ref: touch_pad_id
2264                    style: {
2265                        width: Length::Percent(100.0)
2266                        height: Length::Px(170.0)
2267                        background: p.get_muted()
2268                        border: (g.get_border_width(), p.get_border())
2269                        radius: g.get_radius_md()
2270                        stop_scroll_propagation: true
2271                        stop_event_propagation: true
2272                    }
2273                    painter: move |bounds: Rect, dl: &mut DisplayList| {
2274                        pad_bounds_paint.set(bounds);
2275                        let pts: Vec<(u64, Point)> = touches_sig.get_untracked();
2276                        let palette: [Color; 5] = [
2277                            Color::hex(0x2563EB),
2278                            Color::hex(0x16A34A),
2279                            Color::hex(0xEA580C),
2280                            Color::hex(0x9333EA),
2281                            Color::hex(0xDC2626),
2282                        ];
2283                        let inside_pts: Vec<(u64, Point)> = pts
2284                        .into_iter()
2285                        .filter(|(_, pt): &(u64, Point)| bounds.contains(*pt))
2286                        .collect();
2287                        if inside_pts.is_empty() {
2288                            let mut hint_style: TextStyle = TextStyle::default();
2289                            hint_style
2290                            .set_font_size(12.0)
2291                            .set_color(p.get_muted_foreground())
2292                            .set_align(TextAlign::Center);
2293                            dl.push(DrawCommand::TextRun {
2294                                rect: Rect::new(
2295                                    bounds.get_x() + 12.0,
2296                                    bounds.get_y() + (bounds.get_height() - 18.0) * 0.5,
2297                                    (bounds.get_width() - 24.0).max(1.0),
2298                                    20.0,
2299                                ),
2300                                text: TOUCH_PAD_CANVAS_HINT.to_string(),
2301                                style: hint_style,
2302                            });
2303                            return;
2304                        }
2305                        if inside_pts.len() >= 2 {
2306                            for pair in inside_pts.windows(2) {
2307                                dl.push(DrawCommand::Line {
2308                                    from: pair[0].1,
2309                                    to: pair[1].1,
2310                                    color: p.get_primary().multiply_alpha(0.75),
2311                                    width: 2.0,
2312                                });
2313                            }
2314                        }
2315                        for (idx, (pid, pt)) in inside_pts.iter().enumerate() {
2316                            let col: Color = palette[idx % palette.len()];
2317                            dl.push(DrawCommand::Circle {
2318                                center: *pt,
2319                                radius: 26.0,
2320                                color: col.multiply_alpha(0.24),
2321                            });
2322                            dl.push(DrawCommand::Circle {
2323                                center: *pt,
2324                                radius: 10.0,
2325                                color: col,
2326                            });
2327                            let mut tag_style: TextStyle = TextStyle::default();
2328                            tag_style
2329                            .set_font_size(11.0)
2330                            .set_weight(FontWeight::Bold)
2331                            .set_color(col);
2332                            dl.push(DrawCommand::TextRun {
2333                                rect: Rect::new(pt.get_x() + 14.0, pt.get_y() - 24.0, 96.0, 16.0),
2334                                text: format!("#{pid}({:.0},{:.0})", pt.get_x(), pt.get_y()),
2335                                style: tag_style,
2336                            });
2337                        }
2338                        let mut hud_style: TextStyle = TextStyle::default();
2339                        hud_style
2340                        .set_font_size(11.5)
2341                        .set_weight(FontWeight::Medium)
2342                        .set_color(p.get_foreground());
2343                        dl.push(DrawCommand::TextRun {
2344                            rect: Rect::new(
2345                                bounds.get_x() + 10.0,
2346                                bounds.get_y() + 8.0,
2347                                (bounds.get_width() - 20.0).max(1.0),
2348                                18.0,
2349                            ),
2350                            text: format!("Live Contacts Inside Pad: {}", inside_pts.len()),
2351                            style: hud_style,
2352                        });
2353                    }
2354                }
2355            }
2356            EuvCard {
2357                title: "AI Schema v1 & Reactive Telemetry Bridge".to_string()
2358                tokens: tokens
2359                subtitle: "Live introspection of SceneTree bounds, A11y tree, reactive graph, FPS, and interactive agent actions"
2360                text {
2361                    style: {
2362                        width: Length::Percent(100.0)
2363                        font_size: 12.5
2364                        color: p.get_foreground()
2365                    }
2366                    { move || {
2367                        let _: u32 = ai_tick.get();
2368                        let rs: ReactiveStats = reactive_stats();
2369                        #[cfg(debug_assertions)]
2370                        let proto_label: &str = AI_SCHEMA_PROTOCOL_VERSION;
2371                        #[cfg(not(debug_assertions))]
2372                        let proto_label: &str = AI_SCHEMA_RELEASE_STRIPPED;
2373                        let bridge_label: &str = if DevAutomationBridge::is_enabled() {
2374                            AI_BRIDGE_STATUS_ACTIVE
2375                        } else {
2376                            AI_BRIDGE_STATUS_OFF
2377                        };
2378                        let ai_fps: f32 = ai_fps_sig.get();
2379                        let ai_hz: f32 = ai_hz_sig.get().clamp(30.0, 480.0);
2380                        let fps_display: String = if !ai_fps.is_finite() || ai_fps <= 0.05 {
2381                            LABEL_FPS_IDLE.to_string()
2382                        } else {
2383                            format!("{ai_fps:.1}")
2384                        };
2385                        format!(
2386                            "Protocol: {} ({}) | Route: {} | Scheme: {} | Display: {:.0}Hz | Live FPS: {} | Signals: {} | Memos: {} | Effects: {} | Scopes: {} | Clock: {}",
2387                            proto_label,
2388                            bridge_label,
2389                            ai_route_sig.get(),
2390                            ai_scheme_sig.get().as_str(),
2391                            ai_hz,
2392                            fps_display,
2393                            rs.get_live_signals(),
2394                            rs.get_live_memos(),
2395                            rs.get_live_effects(),
2396                            rs.get_live_scopes(),
2397                            rs.get_clock()
2398                        )
2399                    } }
2400                }
2401                EuvActionRow {
2402                    EuvButton {
2403                        label: "Refresh AI Telemetry".to_string()
2404                        tokens: tokens
2405                        outline()
2406                        sm()
2407                        on_click: move |_: &UiEvent| {
2408                            let _: bool = ai_tick.update(|v: &mut u32| *v = v.wrapping_add(1));
2409                        }
2410                    }
2411                }
2412                EuvCodeBlock {
2413                    code: "GET /ai/schema | /ai/snapshot | /ai/a11y | /ai/health\nPOST /ai/query | /ai/action | /ai/script (dev-only; 0B in release)".to_string()
2414                    tokens: tokens
2415                }
2416            }
2417            EuvCard {
2418                title: "Complete shadcn/ui Component Parity".to_string()
2419                tokens: tokens
2420                subtitle: "Trace, Attachment, Bubble, Marker, Questionnaire, Chart, Combobox, DataTable, DatePicker, InputGroup, Item, NativeSelect, NavigationMenu, Resizable, Separator, Direction, Avatar, Kbd, Spinner, Skeleton, Breadcrumb, Empty"
2421                row {
2422                    style: c_action_row()
2423                    EuvMarker {
2424                        code: "01".to_string()
2425                        label: "Zero WebView".to_string()
2426                        tone: EuvTone::Primary
2427                        tokens: tokens
2428                    }
2429                    EuvMarker {
2430                        code: "02".to_string()
2431                        label: "120+ FPS".to_string()
2432                        tone: EuvTone::Success
2433                        tokens: tokens
2434                    }
2435                    EuvMarker {
2436                        code: "03".to_string()
2437                        label: "Multi-Touch".to_string()
2438                        tone: EuvTone::Warning
2439                        tokens: tokens
2440                    }
2441                    EuvAvatar {
2442                        initials: "EU".to_string()
2443                        size: 32.0
2444                        tokens: tokens
2445                    }
2446                    EuvKbd {
2447                        key: "Cmd+K".to_string()
2448                        tokens: tokens
2449                    }
2450                    EuvSpinner {
2451                        size: 18.0
2452                        tokens: tokens
2453                    }
2454                }
2455                EuvTrace {
2456                    title: "Frame Pipeline Trace (1.42ms Total)".to_string()
2457                    spans: vec![
2458                        EuvTraceSpan::new("layout.compute".to_string(), 0.14, 0.0, 0.12, EuvTone::Primary),
2459                        EuvTraceSpan::new("bvh.raytrace_gi".to_string(), 0.88, 0.12, 0.60, EuvTone::Success),
2460                        EuvTraceSpan::new("fxaa.tonemap".to_string(), 0.24, 0.72, 0.16, EuvTone::Warning),
2461                        EuvTraceSpan::new("present.blit".to_string(), 0.16, 0.88, 0.12, EuvTone::Neutral),
2462                    ]
2463                    tokens: tokens
2464                }
2465                EuvAttachment {
2466                    filename: "vice-boulevard-rt.wasm".to_string()
2467                    meta: "48.2 KB · application/wasm · SHA-verified".to_string()
2468                    visible: attach_vis
2469                    tokens: tokens
2470                }
2471                EuvBubble {
2472                    author: "Euv Runtime".to_string()
2473                    content: "All 60+ shadcn/ui components rendered directly via Rust SceneTree with zero WebView.".to_string()
2474                    tokens: tokens
2475                    timestamp: "09:41"
2476                }
2477                EuvBubble {
2478                    author: "Developer".to_string()
2479                    content: "Verify multi-touch, text wrapping, blinking input caret & uncapped FPS live!".to_string()
2480                    tokens: tokens
2481                    timestamp: "09:42"
2482                    outgoing: true
2483                }
2484                EuvQuestionnaire {
2485                    prompt: "Preferred native target deployment pipeline?".to_string()
2486                    options: vec![
2487                        "Universal Native (Android + iOS + Desktop + Web)".to_string(),
2488                        "Dynamic OTA .wasm Hot-Swap Modules".to_string(),
2489                        "Embedded 3D Ray-Traced Engine Viewport".to_string(),
2490                    ]
2491                    selected: q_sel
2492                    tokens: tokens
2493                }
2494                EuvNavigationMenu {
2495                    items: vec![
2496                        (
2497                            "Architecture".to_string(),
2498                            "Arena signals + deterministic Flexbox/Grid + retained scene graph.".to_string(),
2499                        ),
2500                        (
2501                            "3D Engine".to_string(),
2502                            "PBR metallic-roughness + BVH ray-traced shadows/reflections + FXAA.".to_string(),
2503                        ),
2504                        (
2505                            "Media Suite".to_string(),
2506                            "Pure-Rust Image, SVG, GIF, LIVE Photo, Video, WAV Audio, PDF, HTML.".to_string(),
2507                        ),
2508                    ]
2509                    active: state.get_lab_nav_menu_active()
2510                    tokens: tokens
2511                }
2512                EuvChart {
2513                    title: "Frame Rate Telemetry (Bar)".to_string()
2514                    kind: EuvChartKind::Bar
2515                    data: chart_data.clone()
2516                    tokens: tokens
2517                }
2518                EuvChart {
2519                    title: "3D Ray-Tracing Throughput (Area)".to_string()
2520                    kind: EuvChartKind::Area
2521                    data: chart_data
2522                    tokens: tokens
2523                }
2524                EuvCombobox {
2525                    options: vec![
2526                        "euv Native Rust".to_string(),
2527                        "WebAssembly Zero-JS".to_string(),
2528                        "Android ARM64 JNI".to_string(),
2529                        "iOS CoreText Metal".to_string(),
2530                        "macOS AppKit Retina".to_string(),
2531                    ]
2532                    selected: state.get_lab_combobox_selected()
2533                    open: state.get_lab_combobox_open()
2534                    tokens: tokens
2535                    query: state.get_lab_combobox_query()
2536                    placeholder: "Filter frameworks..."
2537                }
2538                EuvDatePicker {
2539                    month_label: LABEL_CALENDAR_MONTH.to_string()
2540                    selected_day: state.get_lab_date_day()
2541                    open: state.get_lab_date_open()
2542                    tokens: tokens
2543                }
2544                EuvInputGroup {
2545                    value: state.get_lab_input_group_val()
2546                    tokens: tokens
2547                    prefix: "https://"
2548                    placeholder: "subdomain"
2549                    suffix: ".euv.dev"
2550                }
2551                EuvNativeSelect {
2552                    options: vec![
2553                        "60 Hz Standard".to_string(),
2554                        "120 Hz ProMotion".to_string(),
2555                        "Unlocked Benchmark".to_string(),
2556                    ]
2557                    selected: state.get_lab_native_select_idx()
2558                    tokens: tokens
2559                }
2560                EuvDataTable {
2561                    headers: vec!["Target".to_string(), "Font Engine".to_string(), "Status".to_string()]
2562                    rows: vec![
2563                        vec![LABEL_PLATFORM_ANDROID.to_string(), "Skia Paint AA".to_string(), "1:1 DPI".to_string()],
2564                        vec!["iOS / iPadOS".to_string(), "CoreText @3x".to_string(), "ProMotion".to_string()],
2565                        vec![LABEL_PLATFORM_MACOS.to_string(), "CoreText Retina".to_string(), "Live Resize".to_string()],
2566                        vec!["WebAssembly".to_string(), "Canvas2D AA".to_string(), "Zero-JS".to_string()],
2567                    ]
2568                    tokens: tokens
2569                    filter: state.get_lab_table_filter()
2570                    sort_ascending: state.get_lab_table_sort_asc()
2571                    selected_row: state.get_lab_table_selected()
2572                }
2573                EuvResizable {
2574                    left: left_split
2575                    right: right_split
2576                    split_ratio: state.get_lab_split_ratio()
2577                    tokens: tokens
2578                }
2579                EuvItem {
2580                    title: "Production shadcn/ui Alignment".to_string()
2581                    tokens: tokens
2582                    leading: "EU"
2583                    description: "Unified layout grammar across all 17 design schemes with per-theme surface/radius tokens"
2584                    trailing: LAB_ITEM_VER
2585                }
2586                column {
2587                    style: {
2588                        width: Length::Percent(100.0)
2589                        gap: SPACE_SM
2590                    }
2591                    EuvBreadcrumb {
2592                        segments: vec!["Euv Studio".to_string(), "Design System".to_string(), "Components".to_string()]
2593                        tokens: tokens
2594                        active: state.get_breadcrumb_active()
2595                    }
2596                    EuvTypography {
2597                        text: "Unified shadcn/ui Typography & Surface Tokens".to_string()
2598                        variant: EuvTypographyVariant::H3
2599                        tokens: tokens
2600                    }
2601                    EuvSkeleton {
2602                        width: 260.0
2603                        height: 18.0
2604                        tokens: tokens
2605                    }
2606                    EuvEmpty {
2607                        title: "No Pending Warnings".to_string()
2608                        description: "All layout, scroll, shadow and typography checks passed.".to_string()
2609                        tokens: tokens
2610                    }
2611                }
2612            }
2613            EuvCard {
2614                title: "Boundary & Event Penetration Regression Lab".to_string()
2615                tokens: tokens
2616                subtitle: "Verify scroll lock, flexible event bubbling, overlay back stack, RTL alignment, and zero-rebuild resize preservation"
2617                EuvSeparator {
2618                    label: "EDGE-CASE REGRESSION SUITE".to_string()
2619                    tokens: tokens
2620                }
2621                column {
2622                    style: {
2623                        width: Length::Percent(100.0)
2624                    }
2625                    bind_children: move || {
2626                        let dir: EuvTextDirection = if rtl_sig.get() {
2627                            EuvTextDirection::Rtl
2628                        } else {
2629                            EuvTextDirection::Ltr
2630                        };
2631                        vec![view! {
2632                            EuvDirection {
2633                                direction: dir
2634                                child: view! {
2635                                    text {
2636                                        style: {
2637                                            font_size: 13.0
2638                                            color: p.get_foreground()
2639                                        }
2640                                        { format!("Direction preview ({dir:?}): Unified layout alignment across LTR & RTL") }
2641                                    }
2642                                }
2643                                tokens: tokens
2644                            }
2645                        }]
2646                    }
2647                }
2648                column {
2649                    style: {
2650                        width: Length::Percent(100.0)
2651                        gap: SPACE_XS
2652                    }
2653                    EuvSwitch {
2654                        checked: block_scroll
2655                        label: "Lock Scroll Penetration".to_string()
2656                        tokens: tokens
2657                    }
2658                    EuvSwitch {
2659                        checked: stop_bubble
2660                        label: "Stop Click Bubbling".to_string()
2661                        tokens: tokens
2662                    }
2663                    EuvSwitch {
2664                        checked: rtl_sig
2665                        label: "RTL Direction".to_string()
2666                        tokens: tokens
2667                    }
2668                }
2669                EuvActionRow {
2670                    EuvButton {
2671                        label: "Increment Preserved Counter".to_string()
2672                        tokens: tokens
2673                        sm()
2674                        on_click: move |_: &UiEvent| {
2675                            let _: bool = preserve_cnt.update(|v: &mut u32| *v += 1);
2676                        }
2677                    }
2678                    EuvButton {
2679                        label: "Open Stacked Modal + Drawer".to_string()
2680                        tokens: tokens
2681                        secondary()
2682                        sm()
2683                        on_click: move |_: &UiEvent| {
2684                            let _: bool = modal_open.set_if_changed(true);
2685                            let _: bool = drawer_open.set_if_changed(true);
2686                        }
2687                    }
2688                    EuvButton {
2689                        label: "Dismiss Top Overlay (Back)".to_string()
2690                        tokens: tokens
2691                        outline()
2692                        sm()
2693                        on_click: move |_: &UiEvent| {
2694                            let _: bool = EuvOverlayStack::dismiss_top();
2695                        }
2696                    }
2697                }
2698                text {
2699                    style: {
2700                        font_size: 12.0
2701                        color: p.get_muted_foreground()
2702                    }
2703                    { move || format!(
2704                        "Inner Clicks: {} | Outer Parent Clicks: {} | Resize-Preserved Counter: {} | Overlay Stack Depth: {}",
2705                        child_clicks.get(),
2706                        parent_clicks.get(),
2707                        preserve_cnt.get(),
2708                        EuvOverlayStack::active_count()
2709                    ) }
2710                }
2711                column {
2712                    style: {
2713                        width: Length::Percent(100.0)
2714                    }
2715                    bind_children: move || {
2716                        let locked: bool = block_scroll.get();
2717                        let stop_clk: bool = stop_bubble.get();
2718                        vec![view! {
2719                            column {
2720                                style: {
2721                                    width: Length::Percent(100.0)
2722                                    padding: Edges::all(SPACE_MD)
2723                                    gap: SPACE_SM
2724                                    background: p.get_muted()
2725                                    border: (g.get_border_width(), p.get_border())
2726                                    radius: g.get_radius_md()
2727                                }
2728                                on_click: move |_: &UiEvent| {
2729                                    let _: bool = parent_clicks.update(|v: &mut u32| *v += 1);
2730                                }
2731                                scroll {
2732                                    style: {
2733                                        width: Length::Percent(100.0)
2734                                        height: Length::Px(110.0)
2735                                        padding: Edges::all(SPACE_SM)
2736                                        gap: SPACE_XS
2737                                        background: p.get_card()
2738                                        border: (g.get_border_width(), p.get_border())
2739                                        radius: g.get_radius_sm()
2740                                        stop_scroll_propagation: locked
2741                                        stop_event_propagation: stop_clk
2742                                    }
2743                                    for row_i in 1..=8 {
2744                                        text {
2745                                            style: {
2746                                                font_size: 12.0
2747                                                color: p.get_foreground()
2748                                            }
2749                                            { format!("Nested Scroll Row #{row_i} (scroll_lock={locked}, stop_bubble={stop_clk})") }
2750                                        }
2751                                    }
2752                                }
2753                                EuvActionRow {
2754                                    EuvButton {
2755                                        label: "Click Inner Target".to_string()
2756                                        tokens: tokens
2757                                        secondary()
2758                                        sm()
2759                                        on_click: move |_: &UiEvent| {
2760                                            let _: bool = child_clicks.update(|v: &mut u32| *v += 1);
2761                                        }
2762                                    }
2763                                }
2764                            }
2765                        }]
2766                    }
2767                }
2768            }
2769        }
2770    };
2771    let touch_handle: SceneHandle = ctx.get_scene().clone();
2772    let (touch_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
2773        Effect::new(move || {
2774            let _: Vec<(u64, Point)> = touches_sig.get();
2775            touch_handle.mark_dirty(touch_pad_id, DIRTY_PAINT);
2776        })
2777    });
2778    ctx.get_scene().with_write(
2779        |tree: &mut SceneTree| {
2780            tree.attach_scope(touch_pad_id, touch_scope);
2781        },
2782        (),
2783    );
2784    page
2785}
2786
2787/// Mounts the comprehensive interactive forms showcase covering inputs, steppers, radios, sliders, ratings, toggles, switches, and checkboxes.
2788///
2789/// # Arguments
2790///
2791/// - `&ShowcaseState` - Reactive showcase state.
2792/// - `ThemeTokens` - Active design tokens.
2793///
2794/// # Returns
2795///
2796/// - `NodeId` - Mounted forms page node.
2797pub fn mount_forms_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2798    let p: ThemePalette = tokens.get_palette();
2799    let username: Signal<String> = state.get_username();
2800    let stepper: Signal<i64> = state.get_stepper_value();
2801    let rating: Signal<usize> = state.get_rating_value();
2802    let cal_day: Signal<u32> = state.get_calendar_day();
2803    let picker_color: Signal<Color> = state.get_picker_color();
2804    let picker_time: Signal<(u8, u8)> = state.get_picker_time();
2805    let tag_items: Signal<Vec<String>> = state.get_tag_items();
2806    let input_node: NodeId = view! {
2807        EuvInput {
2808            value: username
2809            placeholder: PLACEHOLDER_USERNAME.to_string()
2810            tokens: tokens
2811        }
2812    };
2813    let collapsible_body: NodeId = view! {
2814        text {
2815            style: {
2816                font_size: 13.0
2817                color: p.get_muted_foreground()
2818            }
2819            "shadcn/ui Collapsible disclosure panel adapts across Mobile, Tablet, and Desktop."
2820        }
2821    };
2822    view! {
2823        EuvPage {
2824            title: FORMS_TITLE.to_string()
2825            subtitle: FORMS_SUBTITLE.to_string()
2826            tokens: tokens
2827            EuvCard {
2828                title: FORMS_CARD_TITLE.to_string()
2829                tokens: tokens
2830                subtitle: FORMS_CARD_SUB
2831                column {
2832                    style: {
2833                        gap: SPACE_MD
2834                    }
2835                    EuvTabs {
2836                        labels: vec![TAB_GENERAL.to_string(), TAB_GRAPHICS.to_string(), TAB_SECURITY.to_string()]
2837                        active: state.get_active_tab()
2838                        tokens: tokens
2839                    }
2840                    EuvField {
2841                        label: FIELD_USERNAME.to_string()
2842                        control: input_node
2843                        tokens: tokens
2844                    }
2845                    EuvTextarea {
2846                        value: state.get_bio()
2847                        placeholder: "Write notes...".to_string()
2848                        height: 54.0
2849                        tokens: tokens
2850                    }
2851                    row {
2852                        style: c_action_row()
2853                        EuvNumberInput {
2854                            value: stepper
2855                            tokens: tokens
2856                            range(0, 20)
2857                            step: 1
2858                        }
2859                        EuvToggle {
2860                            pressed: state.get_pin_toggled()
2861                            label: "Pin Config".to_string()
2862                            tokens: tokens
2863                        }
2864                        EuvRating {
2865                            value: rating
2866                            max_stars: 5
2867                            tokens: tokens
2868                        }
2869                    }
2870                    EuvRadioGroup {
2871                        options: vec!["Software CPU".to_string(), "Hardware GPU".to_string(), "Hybrid".to_string()]
2872                        selected: state.get_radio_index()
2873                        tokens: tokens
2874                    }
2875                    EuvSlider {
2876                        value: state.get_slider_value()
2877                        min: 0.0
2878                        max: 100.0
2879                        tokens: tokens
2880                    }
2881                    EuvSelect {
2882                        options: vec!["Metal".to_string(), "Vulkan".to_string(), "Direct3D 12".to_string(), "WebGPU".to_string()]
2883                        selected: state.get_select_index()
2884                        open: state.get_select_open()
2885                        tokens: tokens
2886                    }
2887                    EuvSwitch {
2888                        checked: state.get_hardware_accel()
2889                        label: SWITCH_HW_LABEL.to_string()
2890                        tokens: tokens
2891                    }
2892                    EuvCheckbox {
2893                        checked: state.get_agree_terms()
2894                        label: CHECKBOX_TERMS_LABEL.to_string()
2895                        tokens: tokens
2896                    }
2897                    text {
2898                        style: {
2899                            font_size: 12.0
2900                            color: p.get_muted_foreground()
2901                        }
2902                        { move || format!("Handle: {} | Stepper: {} | Stars: {}/5 | Day: {}", username.get(), stepper.get(), rating.get(), cal_day.get()) }
2903                    }
2904                    EuvActionRow {
2905                        EuvButton {
2906                            label: BTN_PRIMARY_LABEL.to_string()
2907                            tokens: tokens
2908                        }
2909                        EuvButton {
2910                            label: BTN_SECONDARY_LABEL.to_string()
2911                            tokens: tokens
2912                            secondary() }
2913                        EuvButton {
2914                            label: BTN_OUTLINE_LABEL.to_string()
2915                            tokens: tokens
2916                            outline() }
2917                        EuvButton {
2918                            label: BTN_DESTRUCTIVE_LABEL.to_string()
2919                            tokens: tokens
2920                            destructive()
2921                            on_click: move |_: &UiEvent| {
2922                                let _: bool = username.set_if_changed(DEFAULT_USERNAME.to_string());
2923                            }
2924                        }
2925                    }
2926                }
2927            }
2928            EuvCard {
2929                title: "shadcn/ui Extended Form Controls".to_string()
2930                tokens: tokens
2931                subtitle: FORMS_EXT_CARD_SUB
2932                column {
2933                    style: {
2934                        gap: SPACE_MD
2935                    }
2936                    EuvToggleGroup {
2937                        options: vec!["Bold".to_string(), "Italic".to_string(), "Underline".to_string()]
2938                        selected: state.get_toggle_group_index()
2939                        tokens: tokens
2940                    }
2941                    EuvInputOtp {
2942                        value: state.get_otp_code()
2943                        length: 6
2944                        tokens: tokens
2945                    }
2946                    EuvColorPicker {
2947                        value: picker_color
2948                        tokens: tokens
2949                    }
2950                    EuvTimePicker {
2951                        value: picker_time
2952                        tokens: tokens
2953                    }
2954                    EuvTagInput {
2955                        tags: tag_items
2956                        tokens: tokens
2957                        placeholder: TAG_INPUT_PLACEHOLDER
2958                    }
2959                    text {
2960                        style: {
2961                            font_size: 12.0
2962                            color: p.get_muted_foreground()
2963                        }
2964                        { move || {
2965                            let c: Color = picker_color.get();
2966                            let (hh, mm): (u8, u8) = picker_time.get();
2967                            format!(
2968                                "Color: #{:02X}{:02X}{:02X} | Time: {:02}:{:02} | Tags: {}",
2969                                c.get_r(),
2970                                c.get_g(),
2971                                c.get_b(),
2972                                hh,
2973                                mm,
2974                                tag_items.get().len()
2975                            )
2976                        } }
2977                    }
2978                    EuvCalendar {
2979                        month_label: LABEL_CALENDAR_MONTH.to_string()
2980                        days_in_month: 30
2981                        selected_day: state.get_calendar_day()
2982                        tokens: tokens
2983                    }
2984                    EuvCollapsible {
2985                        open: state.get_collapsible_open()
2986                        title: "Advanced Form Details".to_string()
2987                        content: collapsible_body
2988                        tokens: tokens
2989                    }
2990                }
2991            }
2992        }
2993    }
2994}
2995
2996/// Mounts the 17-scheme live design token gallery where every scheme button switches the active app theme live.
2997///
2998/// # Arguments
2999///
3000/// - `&ShowcaseState` - Reactive showcase state.
3001/// - `ThemeTokens` - Active design tokens.
3002///
3003/// # Returns
3004///
3005/// - `NodeId` - Mounted themes page node.
3006pub fn mount_themes_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3007    let p: ThemePalette = tokens.get_palette();
3008    let scheme_sig: Signal<DesignScheme> = state.get_theme().get_scheme();
3009    let mode_sig: Signal<ThemeMode> = state.get_theme().get_mode();
3010    let state_for_cycle: ShowcaseState = state.clone();
3011    let state_for_mode: ShowcaseState = state.clone();
3012    let scheme_cols: u16 = match use_breakpoint().get_untracked() {
3013        Breakpoint::Compact => 2,
3014        Breakpoint::Medium => 3,
3015        Breakpoint::Expanded => 4,
3016    };
3017    let all_schemes: [DesignScheme; 17] = DesignScheme::all();
3018    let cur_mode: ThemeMode = mode_sig.get_untracked();
3019    view! {
3020        EuvPage {
3021            title: THEMES_TITLE.to_string()
3022            subtitle: THEMES_SUBTITLE.to_string()
3023            tokens: tokens
3024            EuvCard {
3025                title: THEMES_CARD_TITLE.to_string()
3026                tokens: tokens
3027                subtitle: THEMES_CARD_SUB
3028                column {
3029                    style: {
3030                        gap: SPACE_MD
3031                    }
3032                    text {
3033                        style: {
3034                            font_size: 15.0
3035                            font_weight: FontWeight::SemiBold
3036                            color: p.get_foreground()
3037                        }
3038                        { move || format!("{PREFIX_ACTIVE_SCHEME}{} ({:?})", scheme_sig.get().as_str(), mode_sig.get()) }
3039                    }
3040                    EuvActionRow {
3041                        EuvButton {
3042                            label: BTN_NEXT_SCHEME.to_string()
3043                            tokens: tokens
3044                            on_click: move |_: &UiEvent| {
3045                                state_for_cycle.next_scheme();
3046                            }
3047                        }
3048                        EuvButton {
3049                            label: BTN_TOGGLE_MODE.to_string()
3050                            tokens: tokens
3051                            outline()
3052                            on_click: move |_: &UiEvent| {
3053                                state_for_mode.toggle_theme_mode();
3054                            }
3055                        }
3056                    }
3057                    grid {
3058                        style: {
3059                            c_scheme_grid()
3060                            columns: scheme_cols
3061                        }
3062                        for scheme in all_schemes.iter().copied() {
3063                            EuvButton {
3064                                label: scheme.as_str().to_string()
3065                                tokens: ThemeTokens::resolve(scheme, cur_mode)
3066                                sm()
3067                                on_click: move |_: &UiEvent| {
3068                                    let _: bool = scheme_sig.set_if_changed(scheme);
3069                                }
3070                            }
3071                        }
3072                    }
3073                }
3074            }
3075        }
3076    }
3077}
3078
3079/// Mounts the reactive 10,000-row virtualized scrollable list plus pagination, steps, accordion, and progress.
3080///
3081/// # Arguments
3082///
3083/// - `&ShowcaseState` - Reactive showcase state.
3084/// - `ThemeTokens` - Active design tokens.
3085///
3086/// # Returns
3087///
3088/// - `NodeId` - Mounted data display page node.
3089pub fn mount_data_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3090    let p: ThemePalette = tokens.get_palette();
3091    let g: ThemeGeometry = tokens.get_geometry();
3092    let scroll_y: Signal<f32> = state.get_list_scroll_y();
3093    let vlist: EuvVirtualList =
3094        EuvVirtualList::new(10_000, 32.0, scroll_y, tokens).viewport_height(224.0);
3095    let vlist_down: EuvVirtualList = vlist.clone();
3096    let list_node: NodeId = vlist.mount_with(move |idx: usize| {
3097        view! {
3098            row {
3099                style: {
3100                    width: Length::Percent(100.0)
3101                    height: Length::Px(32.0)
3102                    padding: Edges::symmetric(SPACE_XS, SPACE_MD)
3103                    align: AlignItems::Center
3104                    border: (g.get_border_width(), p.get_border())
3105                }
3106                text {
3107                    style: {
3108                        font_size: 13.0
3109                        color: p.get_foreground()
3110                    }
3111                    { format!("{ROW_PREFIX}{idx}") }
3112                }
3113            }
3114        }
3115    });
3116    let aspect_inner: NodeId = view! {
3117        column {
3118            style: {
3119                align: AlignItems::Center
3120                gap: SPACE_XS
3121            }
3122            text {
3123                style: {
3124                    font_size: 14.0
3125                    font_weight: FontWeight::SemiBold
3126                    color: p.get_foreground()
3127                }
3128                "16:9 shadcn AspectRatio"
3129            }
3130            text {
3131                style: {
3132                    font_size: 12.0
3133                    color: p.get_muted_foreground()
3134                }
3135                "Responsive container locked to 16:9 ratio"
3136            }
3137        }
3138    };
3139    let tree_sel: Signal<Option<String>> = state.get_tree_selected();
3140    view! {
3141        EuvPage {
3142            title: DATA_TITLE.to_string()
3143            subtitle: DATA_SUBTITLE.to_string()
3144            tokens: tokens
3145            EuvCard {
3146                title: DATA_CARD_TITLE.to_string()
3147                tokens: tokens
3148                subtitle: DATA_CARD_SUB
3149                column {
3150                    style: {
3151                        gap: SPACE_MD
3152                    }
3153                    EuvMenubar {
3154                        menus: vec!["File".to_string(), "Edit".to_string(), "View".to_string(), "Profiles".to_string()]
3155                        active_menu: state.get_menubar_active()
3156                        tokens: tokens
3157                    }
3158                    row {
3159                        style: c_action_row()
3160                        EuvBadge {
3161                            label: BADGE_READY.to_string()
3162                            tone: EuvTone::Success
3163                            tokens: tokens
3164                        }
3165                        EuvBadge {
3166                            label: BADGE_LIVE.to_string()
3167                            tone: EuvTone::Primary
3168                            tokens: tokens
3169                        }
3170                    }
3171                    EuvActionRow {
3172                        EuvButton {
3173                            label: BTN_SCROLL_DOWN.to_string()
3174                            tokens: tokens
3175                            on_click: move |_: &UiEvent| {
3176                                vlist_down.scroll_by(160.0);
3177                            }
3178                        }
3179                        EuvButton {
3180                            label: BTN_SCROLL_TOP.to_string()
3181                            tokens: tokens
3182                            outline()
3183                            on_click: move |_: &UiEvent| {
3184                                let _: bool = scroll_y.set_if_changed(0.0);
3185                            }
3186                        }
3187                    }
3188                    text {
3189                        style: {
3190                            font_size: 12.0
3191                            color: p.get_muted_foreground()
3192                        }
3193                        { move || format!("scroll_y={:.0}px | top_row=#{}", scroll_y.get(), (scroll_y.get() / 32.0).floor() as usize) }
3194                    }
3195                    EuvProgress {
3196                        value: 0.84
3197                        tokens: tokens
3198                    }
3199                    { list_node }
3200                    EuvCommand {
3201                        items: vec!["Switch to Dark Mode".to_string(), "Open OTA Updates".to_string(), "Run Physics Tick".to_string()]
3202                        selected: state.get_command_selected()
3203                        tokens: tokens
3204                        query: state.get_command_query()
3205                        placeholder: "Search commands..."
3206                    }
3207                    EuvCarousel {
3208                        slides: vec![
3209                            "Slide 1: Native Metal & Vulkan".to_string(),
3210                            "Slide 2: Complete shadcn/ui Parity".to_string(),
3211                            "Slide 3: Instant Responsive Resize".to_string(),
3212                        ]
3213                        active_slide: state.get_carousel_index()
3214                        tokens: tokens
3215                    }
3216                    column {
3217                        style: {
3218                            width: Length::Percent(100.0)
3219                            max_width: Length::Px(360.0)
3220                        }
3221                        EuvAspectRatio {
3222                            ratio: 16.0 / 9.0
3223                            child: aspect_inner
3224                            tokens: tokens
3225                        }
3226                    }
3227                    EuvPagination {
3228                        current: state.get_page_index()
3229                        total_pages: 12
3230                        tokens: tokens
3231                    }
3232                    EuvSteps {
3233                        labels: vec!["Layout".to_string(), "Paint".to_string(), "Present".to_string()]
3234                        active: state.get_step_index()
3235                        tokens: tokens
3236                    }
3237                    EuvTree {
3238                        roots: vec![EuvTreeNode::new(
3239                            TREE_NODE_WORKSPACE.to_string(),
3240                            vec![
3241                                EuvTreeNode::new(
3242                                    TREE_NODE_CORE.to_string(),
3243                                    vec![
3244                                        EuvTreeNode::new(TREE_NODE_RENDER.to_string(), Vec::new()),
3245                                        EuvTreeNode::new(TREE_NODE_REACTIVE.to_string(), Vec::new()),
3246                                    ],
3247                                ),
3248                                EuvTreeNode::new(TREE_NODE_UI.to_string(), Vec::new()),
3249                                EuvTreeNode::new(TREE_NODE_PERF.to_string(), Vec::new()),
3250                            ],
3251                        )]
3252                        tokens: tokens
3253                        selected: state.get_tree_selected()
3254                    }
3255                    text {
3256                        style: {
3257                            font_size: 12.0
3258                            color: p.get_muted_foreground()
3259                        }
3260                        { move || {
3261                            let cur: String = tree_sel
3262                            .get()
3263                            .unwrap_or_else(|| TREE_NONE_SELECTED.to_string());
3264                            format!("{TREE_SELECTED_PREFIX}: {cur}")
3265                        } }
3266                    }
3267                    EuvAccordion {
3268                        items: vec![EuvAccordionItem::new(
3269                            "Virtualization".to_string(),
3270                            "Only visible rows + overscan are materialized in O(visible).".to_string(),
3271                        )]
3272                        open_index: state.get_accordion_open()
3273                        tokens: tokens
3274                    }
3275                }
3276            }
3277        }
3278    }
3279}
3280
3281/// Mounts the embedded 2D physics game engine viewport and reactive HUD overlay page.
3282///
3283/// # Arguments
3284///
3285/// - `&ShowcaseState` - Reactive showcase state.
3286/// - `ThemeTokens` - Active design tokens.
3287///
3288/// # Returns
3289///
3290/// - `NodeId` - Mounted game engine showcase page node.
3291pub fn mount_game_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3292    let g: ThemeGeometry = tokens.get_geometry();
3293    let p: ThemePalette = tokens.get_palette();
3294    let host: GameEngineHost = state.get_game_host().clone();
3295    let host_btn: GameEngineHost = host.clone();
3296    let host_wave: GameEngineHost = host.clone();
3297    let host_left: GameEngineHost = host.clone();
3298    let host_up: GameEngineHost = host.clone();
3299    let host_down: GameEngineHost = host.clone();
3300    let host_right: GameEngineHost = host.clone();
3301    let host_dash: GameEngineHost = host.clone();
3302    let viewport: NodeId = host.mount_viewport(
3303        Style::default()
3304            .width(Length::Percent(100.0))
3305            .height(Length::Px(340.0))
3306            .border(g.get_border_width(), p.get_border())
3307            .radius(g.get_radius_md()),
3308    );
3309    let fs_2d_open: Signal<bool> = Signal::new(false);
3310    let fs_2d_portal: NodeId = mount_game_fullscreen_portal(
3311        fs_2d_open,
3312        &host,
3313        viewport,
3314        None,
3315        "2D Physics Arena",
3316        tokens,
3317    );
3318    view! {
3319        EuvPage {
3320            title: GAME_TITLE.to_string()
3321            subtitle: GAME_SUBTITLE.to_string()
3322            tokens: tokens
3323            EuvCard {
3324                title: GAME_CARD_TITLE.to_string()
3325                tokens: tokens
3326                subtitle: GAME_CARD_SUB
3327                column {
3328                    style: {
3329                        gap: SPACE_MD
3330                    }
3331                    EuvActionRow {
3332                        EuvButton {
3333                            label: BTN_STEP_PHYSICS.to_string()
3334                            tokens: tokens
3335                            sm()
3336                            on_click: move |_: &UiEvent| {
3337                                let _: u32 = host_btn.step(0.051);
3338                            }
3339                        }
3340                        EuvButton {
3341                            label: "Spawn Enemy Wave".to_string()
3342                            tokens: tokens
3343                            outline()
3344                            sm()
3345                            on_click: move |_: &UiEvent| {
3346                                host_wave.ingest_event(&WindowEvent::KeyDown(
3347                                    WindowId::new(1),
3348                                    KeyEvent::new(KeyCode::Character('r'), Modifiers::default(), false),
3349                                ));
3350                                let _: u32 = host_wave.step(1.0 / 60.0);
3351                                host_wave.ingest_event(&WindowEvent::KeyUp(
3352                                    WindowId::new(1),
3353                                    KeyEvent::new(KeyCode::Character('r'), Modifiers::default(), false),
3354                                ));
3355                            }
3356                        }
3357                    }
3358                    { viewport }
3359                    EuvActionRow {
3360                        EuvButton {
3361                            label: "Left (A)".to_string()
3362                            tokens: tokens
3363                            outline()
3364                            sm()
3365                            on_click: move |_: &UiEvent| {
3366                                pulse_game_key(&host_left, KeyCode::ArrowLeft);
3367                            }
3368                        }
3369                        EuvButton {
3370                            label: "Up (W)".to_string()
3371                            tokens: tokens
3372                            outline()
3373                            sm()
3374                            on_click: move |_: &UiEvent| {
3375                                pulse_game_key(&host_up, KeyCode::ArrowUp);
3376                            }
3377                        }
3378                        EuvButton {
3379                            label: "Down (S)".to_string()
3380                            tokens: tokens
3381                            outline()
3382                            sm()
3383                            on_click: move |_: &UiEvent| {
3384                                pulse_game_key(&host_down, KeyCode::ArrowDown);
3385                            }
3386                        }
3387                        EuvButton {
3388                            label: "Right (D)".to_string()
3389                            tokens: tokens
3390                            outline()
3391                            sm()
3392                            on_click: move |_: &UiEvent| {
3393                                pulse_game_key(&host_right, KeyCode::ArrowRight);
3394                            }
3395                        }
3396                        EuvButton {
3397                            label: "Dash (E)".to_string()
3398                            tokens: tokens
3399                            secondary()
3400                            sm()
3401                            on_click: move |_: &UiEvent| {
3402                                pulse_game_key(&host_dash, KeyCode::Character('e'));
3403                            }
3404                        }
3405                        EuvButton {
3406                            label: "Fullscreen".to_string()
3407                            tokens: tokens
3408                            sm()
3409                            on_click: move |_: &UiEvent| {
3410                                let _: bool = fs_2d_open.set_if_changed(true);
3411                            }
3412                        }
3413                    }
3414                    { fs_2d_portal }
3415                }
3416            }
3417        }
3418    }
3419}
3420
3421/// Mounts a reusable fullscreen portal overlay hosting any 2D/3D `GameEngineHost` with safe exit, Back support, and touch controls.
3422///
3423/// # Arguments
3424///
3425/// - `Signal<bool>` - Fullscreen visibility toggle signal.
3426/// - `&GameEngineHost` - Target game engine host.
3427/// - `NodeId` - Embedded inline viewport hidden while fullscreen is active to avoid redundant rendering.
3428/// - `Option<Signal<u8>>` - Optional 3D camera mode signal for fullscreen camera toggling.
3429/// - `&str` - Title shown in the fullscreen HUD bar.
3430/// - `ThemeTokens` - Active design tokens.
3431///
3432/// # Returns
3433///
3434/// - `NodeId` - Mounted fullscreen portal handle.
3435fn mount_game_fullscreen_portal(
3436    open: Signal<bool>,
3437    host: &GameEngineHost,
3438    inline_viewport: NodeId,
3439    cam_mode_opt: Option<Signal<u8>>,
3440    title: &str,
3441    tokens: ThemeTokens,
3442) -> NodeId {
3443    let ctx: Context = current_context();
3444    bind_fullscreen_context(&ctx);
3445    let fs_viewport: NodeId = host.mount_viewport(
3446        Style::default()
3447            .flex_grow(1.0)
3448            .flex_shrink(1.0)
3449            .min_height(Length::Px(0.0))
3450            .width(Length::Percent(100.0))
3451            .overflow(Overflow::Hidden)
3452            .stop_scroll_propagation(true)
3453            .stop_event_propagation(true),
3454    );
3455    let ctrl_left: NodeId =
3456        mount_game_control_button(FS_CTRL_LEFT, host, KeyCode::ArrowLeft, false, tokens);
3457    let ctrl_up: NodeId = mount_game_control_button(
3458        if cam_mode_opt.is_some() {
3459            FS_CTRL_DRIVE
3460        } else {
3461            FS_CTRL_UP
3462        },
3463        host,
3464        KeyCode::ArrowUp,
3465        true,
3466        tokens,
3467    );
3468    let ctrl_down: NodeId = mount_game_control_button(
3469        if cam_mode_opt.is_some() {
3470            FS_CTRL_REVERSE
3471        } else {
3472            FS_CTRL_DOWN
3473        },
3474        host,
3475        KeyCode::ArrowDown,
3476        false,
3477        tokens,
3478    );
3479    let ctrl_right: NodeId =
3480        mount_game_control_button(FS_CTRL_RIGHT, host, KeyCode::ArrowRight, false, tokens);
3481    let extra_ctrl: NodeId = if let Some(cam_sig) = cam_mode_opt {
3482        let on_cam = move |_: &UiEvent| {
3483            let next: u8 = (cam_sig.get_untracked() + 1) % 4;
3484            let _: bool = cam_sig.set_if_changed(next);
3485        };
3486        view! {
3487            EuvButton {
3488                label: FS_CTRL_CAMERA.to_string()
3489                tokens: tokens
3490                secondary()
3491                sm()
3492                on_click: on_cam
3493            }
3494        }
3495    } else {
3496        mount_game_control_button(FS_CTRL_DASH, host, KeyCode::Character('e'), false, tokens)
3497    };
3498    let on_exit = move |_: &UiEvent| {
3499        let _: bool = open.set_if_changed(false);
3500    };
3501    let paint_exit_icon = move |bounds: Rect, dl: &mut DisplayList| {
3502        draw_euv_icon(EuvIconName::Minimize, bounds, dl, Color::hex(0xFAFAFA));
3503    };
3504    let mut top_bar_id: NodeId = NodeId::default();
3505    let mut bottom_bar_id: NodeId = NodeId::default();
3506    let portal: NodeId = view! {
3507        portal {
3508            style: {
3509                Style::default().column()
3510                display: Display::None
3511                position: Position::Fixed
3512                inset: (Some(0.0), Some(0.0), Some(0.0), Some(0.0))
3513                width: Length::Percent(100.0)
3514                height: Length::Percent(100.0)
3515                padding: Edges::all(0.0)
3516                margin: Edges::all(0.0)
3517                background: Color::hex(0x09090B)
3518                border: (0.0, COLOR_TRANSPARENT)
3519                radius: 0.0
3520                overflow: Overflow::Hidden
3521                pointer_events: PointerEvents::None
3522                stop_scroll_propagation: true
3523                stop_event_propagation: true
3524                z_index: Z_INDEX_FULLSCREEN
3525            }
3526            row {
3527                node_ref: top_bar_id
3528                style: {
3529                    width: Length::Percent(100.0)
3530                    flex_shrink: 0.0
3531                    justify: JustifyContent::SpaceBetween
3532                    align: AlignItems::Center
3533                    padding: Edges::symmetric(SPACE_SM, SPACE_MD)
3534                    background: Color::rgba(9, 9, 11, 236)
3535                }
3536                text {
3537                    style: {
3538                        flex_shrink: 1.0
3539                        min_width: Length::Px(0.0)
3540                        font_size: 14.0
3541                        font_weight: FontWeight::SemiBold
3542                        color: Color::hex(0xFAFAFA)
3543                        text_overflow: TextOverflow::Ellipsis
3544                    }
3545                    { title.to_string() }
3546                }
3547                row {
3548                    style: {
3549                        width: Length::Px(28.0)
3550                        height: Length::Px(28.0)
3551                        justify: JustifyContent::Center
3552                        align: AlignItems::Center
3553                        radius: 6.0
3554                        background: Color::rgba(255, 255, 255, 24)
3555                        border: (1.0, Color::rgba(255, 255, 255, 44))
3556                        cursor: CursorIcon::Pointer
3557                    }
3558                    role: A11yRole::Button
3559                    a11y_label: BTN_EXIT_FULLSCREEN.to_string()
3560                    on_click: on_exit
3561                    canvas {
3562                        style: {
3563                            width: Length::Px(14.0)
3564                            height: Length::Px(14.0)
3565                        }
3566                        painter: paint_exit_icon
3567                    }
3568                }
3569            }
3570            { fs_viewport }
3571            row {
3572                node_ref: bottom_bar_id
3573                style: {
3574                    width: Length::Percent(100.0)
3575                    flex_shrink: 0.0
3576                    padding: Edges::symmetric(SPACE_SM, SPACE_MD)
3577                    background: Color::rgba(9, 9, 11, 232)
3578                }
3579                EuvActionRow {
3580                    { ctrl_left }
3581                    { ctrl_up }
3582                    { ctrl_down }
3583                    { ctrl_right }
3584                    { extra_ctrl }
3585                }
3586            }
3587        }
3588    };
3589    let handle: SceneHandle = ctx.get_scene().clone();
3590    let safe_sig: Signal<SafeAreaInsets> = ctx.get_safe_area();
3591    let prev_fs: Rc<Cell<bool>> = Rc::new(Cell::new(false));
3592    let fs_acquired: Rc<Cell<bool>> = Rc::new(Cell::new(false));
3593    let fs_cleanup: Rc<Cell<bool>> = Rc::clone(&fs_acquired);
3594    let (scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
3595        on_cleanup(move || {
3596            if fs_cleanup.replace(false) {
3597                exit_fullscreen();
3598            }
3599        });
3600        let _: Effect = EuvOverlayStack::bind_signal(open, FS_OVERLAY_NAME, Z_INDEX_FULLSCREEN);
3601        Effect::new(move || {
3602            let is_open: bool = open.get();
3603            let safe: SafeAreaInsets = safe_sig.get();
3604            if is_open != prev_fs.replace(is_open) {
3605                if is_open {
3606                    if !fs_acquired.replace(true) {
3607                        enter_fullscreen();
3608                    }
3609                } else if fs_acquired.replace(false) {
3610                    exit_fullscreen();
3611                }
3612            }
3613            handle.with_write(
3614                |tree: &mut SceneTree| {
3615                    tree.cancel_subtree_transitions(portal);
3616                    if let Some(n) = tree.get_node_mut(inline_viewport) {
3617                        let mut st: Style = n.get_style();
3618                        st.get_mut_layout().set_display(if is_open {
3619                            Display::None
3620                        } else {
3621                            Display::Flex
3622                        });
3623                        n.set_style(st);
3624                        tree.mark_dirty(inline_viewport, DIRTY_LAYOUT | DIRTY_PAINT);
3625                    }
3626                    if let Some(n) = tree.get_node_mut(portal) {
3627                        let mut st: Style = n.get_style();
3628                        st.get_mut_layout().set_display(if is_open {
3629                            Display::Flex
3630                        } else {
3631                            Display::None
3632                        });
3633                        st.get_mut_paint()
3634                            .set_pointer_events(if is_open {
3635                                PointerEvents::Auto
3636                            } else {
3637                                PointerEvents::None
3638                            })
3639                            .set_opacity(1.0)
3640                            .set_transform(Transform2D::default());
3641                        n.set_style(st);
3642                    }
3643                    if let Some(n) = tree.get_node_mut(top_bar_id) {
3644                        let mut st: Style = n.get_style();
3645                        st.get_mut_layout().set_padding(Edges::new(
3646                            SPACE_SM + safe.get_top(),
3647                            SPACE_MD + safe.get_right(),
3648                            SPACE_SM,
3649                            SPACE_MD + safe.get_left(),
3650                        ));
3651                        n.set_style(st);
3652                        tree.mark_dirty(top_bar_id, DIRTY_LAYOUT | DIRTY_PAINT);
3653                    }
3654                    if let Some(n) = tree.get_node_mut(bottom_bar_id) {
3655                        let mut st: Style = n.get_style();
3656                        st.get_mut_layout().set_padding(Edges::new(
3657                            SPACE_SM,
3658                            SPACE_MD + safe.get_right(),
3659                            SPACE_SM + safe.get_bottom(),
3660                            SPACE_MD + safe.get_left(),
3661                        ));
3662                        n.set_style(st);
3663                        tree.mark_dirty(bottom_bar_id, DIRTY_LAYOUT | DIRTY_PAINT);
3664                    }
3665                    let dirty_l: u16 = DIRTY_LAYOUT | DIRTY_SUBTREE_LAYOUT;
3666                    tree.mark_dirty(portal, dirty_l | DIRTY_PAINT);
3667                },
3668                (),
3669            );
3670        })
3671    });
3672    ctx.get_scene().with_write(
3673        |tree: &mut SceneTree| {
3674            tree.attach_scope(portal, scope);
3675        },
3676        (),
3677    );
3678    portal
3679}
3680
3681/// Mounts a press-and-hold cross-platform touch/mouse game control button driving `code` on `host`.
3682///
3683/// # Arguments
3684///
3685/// - `&str` - Button label.
3686/// - `&GameEngineHost` - Target game host.
3687/// - `KeyCode` - Virtual key bound to this button.
3688/// - `bool` - Whether to style as primary (`true`) or outline (`false`).
3689/// - `ThemeTokens` - Active design tokens.
3690///
3691/// # Returns
3692///
3693/// - `NodeId` - Mounted holdable button node.
3694fn mount_game_control_button(
3695    label: &str,
3696    host: &GameEngineHost,
3697    code: KeyCode,
3698    primary: bool,
3699    tokens: ThemeTokens,
3700) -> NodeId {
3701    let host_down: GameEngineHost = host.clone();
3702    let host_up: GameEngineHost = host.clone();
3703    let host_click: GameEngineHost = host.clone();
3704    let node: NodeId = if primary {
3705        view! {
3706            EuvButton {
3707                label: label.to_string()
3708                tokens: tokens
3709                sm()
3710                on_click: move |_: &UiEvent| {
3711                    pulse_game_key(&host_click, code);
3712                }
3713            }
3714        }
3715    } else {
3716        view! {
3717            EuvButton {
3718                label: label.to_string()
3719                tokens: tokens
3720                outline()
3721                sm()
3722                on_click: move |_: &UiEvent| {
3723                    pulse_game_key(&host_click, code);
3724                }
3725            }
3726        }
3727    };
3728    let mut ctx: Context = current_context();
3729    ctx.on_pointer_down(node, move |_: &UiEvent| {
3730        host_down.press_key(code);
3731    });
3732    ctx.on_pointer_up(node, move |_: &UiEvent| {
3733        host_up.release_key(code);
3734    });
3735    node
3736}
3737
3738/// Pulses a single directional or action key on `host` for mobile touch/button game controls.
3739///
3740/// # Arguments
3741///
3742/// - `&GameEngineHost` - Target game engine host.
3743/// - `KeyCode` - Virtual key code to pulse.
3744fn pulse_game_key(host: &GameEngineHost, code: KeyCode) {
3745    host.press_key(code);
3746    let _: u32 = host.step(0.08);
3747    host.release_key(code);
3748}
3749
3750/// Mounts the AAA 3D Open-World Engine page with live BVH ray tracing, runtime graphics settings, and `.obj`/`.gltf` model import.
3751///
3752/// # Arguments
3753///
3754/// - `&ShowcaseState` - Reactive showcase state.
3755/// - `ThemeTokens` - Active design tokens.
3756///
3757/// # Returns
3758///
3759/// - `NodeId` - Mounted 3D engine showcase page handle.
3760pub fn mount_game3d_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3761    let g: ThemeGeometry = tokens.get_geometry();
3762    let p: ThemePalette = tokens.get_palette();
3763    let host: GameEngineHost = state.get_game3d_host().clone();
3764    let quality_sig: Signal<RenderQualityConfig> = state.get_engine3d_quality();
3765    let preset_idx: Signal<usize> = state.get_engine3d_preset_idx();
3766    let rt_idx: Signal<usize> = state.get_engine3d_rt_idx();
3767    let res_scale: Signal<f32> = state.get_engine3d_res_scale();
3768    let time_sig: Signal<f32> = state.get_engine3d_time_of_day();
3769    let import_sig: Signal<u64> = state.get_engine3d_import_queue();
3770    let status_sig: Signal<String> = state.get_engine3d_import_status();
3771    let cam_mode_sig: Signal<u8> = state.get_engine3d_camera_mode();
3772    let viewport: NodeId = host.mount_viewport(
3773        Style::default()
3774            .width(Length::Percent(100.0))
3775            .height(Length::Px(340.0))
3776            .border(g.get_border_width(), p.get_border())
3777            .radius(g.get_radius_md()),
3778    );
3779    let fs_3d_open: Signal<bool> = Signal::new(false);
3780    let fs_3d_portal: NodeId = mount_game_fullscreen_portal(
3781        fs_3d_open,
3782        &host,
3783        viewport,
3784        Some(cam_mode_sig),
3785        "Vice Boulevard 3D RT",
3786        tokens,
3787    );
3788    let res_slider: NodeId = view! {
3789        EuvSlider {
3790            value: res_scale
3791            min: 40.0
3792            max: 125.0
3793            tokens: tokens
3794        }
3795    };
3796    let sun_slider: NodeId = view! {
3797        EuvSlider {
3798            value: time_sig
3799            min: 6.0
3800            max: 23.0
3801            tokens: tokens
3802        }
3803    };
3804    let ctx: Context = current_context();
3805    let (sync_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
3806        Effect::new(move || {
3807            let p_idx: usize = preset_idx.get();
3808            let preset: QualityPreset = match p_idx {
3809                0 => QualityPreset::Low,
3810                1 => QualityPreset::Medium,
3811                3 => QualityPreset::Ultra,
3812                4 => QualityPreset::Cinematic,
3813                _ => QualityPreset::High,
3814            };
3815            let rt: RayTracingMode = match rt_idx.get() {
3816                0 => RayTracingMode::Off,
3817                1 => RayTracingMode::ShadowsOnly,
3818                3 => RayTracingMode::FullPathTracedGi,
3819                _ => RayTracingMode::ShadowsAndReflections,
3820            };
3821            let scale_pct: f32 = res_scale.get();
3822            let mut cfg: RenderQualityConfig = RenderQualityConfig::from_preset(preset);
3823            cfg.set_ray_tracing(rt);
3824            cfg.set_resolution_scale((scale_pct / 100.0).clamp(0.40, 1.25));
3825            let _: bool = quality_sig.set_if_changed(cfg);
3826        })
3827    });
3828    let mut sync_host_id: NodeId = NodeId::default();
3829    let page: NodeId = view! {
3830        EuvPage {
3831            title: GAME3D_TITLE.to_string()
3832            subtitle: GAME3D_SUBTITLE.to_string()
3833            tokens: tokens
3834            EuvCard {
3835                title: GAME3D_CARD_TITLE.to_string()
3836                tokens: tokens
3837                subtitle: GAME3D_CARD_SUB
3838                column {
3839                    node_ref: sync_host_id
3840                    style: {
3841                        width: Length::Percent(100.0)
3842                        gap: SPACE_MD
3843                    }
3844                    { viewport }
3845                    EuvActionRow {
3846                        { mount_game_control_button("Steer Left (A)", &host, KeyCode::ArrowLeft, false, tokens) }
3847                        { mount_game_control_button("Drive Fwd (W)", &host, KeyCode::ArrowUp, false, tokens) }
3848                        { mount_game_control_button("Reverse (S)", &host, KeyCode::ArrowDown, false, tokens) }
3849                        { mount_game_control_button("Steer Right (D)", &host, KeyCode::ArrowRight, false, tokens) }
3850                        EuvButton {
3851                            label: "Switch Camera".to_string()
3852                            tokens: tokens
3853                            secondary()
3854                            sm()
3855                            on_click: move |_: &UiEvent| {
3856                                let next: u8 = (cam_mode_sig.get_untracked() + 1) % 4;
3857                                let _: bool = cam_mode_sig.set_if_changed(next);
3858                            }
3859                        }
3860                        EuvButton {
3861                            label: "Fullscreen 3D".to_string()
3862                            tokens: tokens
3863                            sm()
3864                            on_click: move |_: &UiEvent| {
3865                                let _: bool = fs_3d_open.set_if_changed(true);
3866                            }
3867                        }
3868                        EuvButton {
3869                            label: "Import .OBJ Monument".to_string()
3870                            tokens: tokens
3871                            secondary()
3872                            sm()
3873                            on_click: move |_: &UiEvent| {
3874                                let cur: u64 = import_sig.get_untracked();
3875                                let next: u64 = if cur.is_multiple_of(2) { cur + 1 } else { cur + 2 };
3876                                let _: bool = import_sig.set_if_changed(next);
3877                            }
3878                        }
3879                        EuvButton {
3880                            label: "Import .glTF Tower".to_string()
3881                            tokens: tokens
3882                            outline()
3883                            sm()
3884                            on_click: move |_: &UiEvent| {
3885                                let cur: u64 = import_sig.get_untracked();
3886                                let next: u64 = if !cur.is_multiple_of(2) { cur + 1 } else { cur + 2 };
3887                                let _: bool = import_sig.set_if_changed(next);
3888                            }
3889                        }
3890                    }
3891                    text {
3892                        style: {
3893                            font_size: 12.0
3894                            color: p.get_muted_foreground()
3895                        }
3896                        { move || status_sig.get() }
3897                    }
3898                    EuvSegmented {
3899                        options: vec![
3900                            "Low".to_string(),
3901                            "Medium".to_string(),
3902                            "High".to_string(),
3903                            "Ultra".to_string(),
3904                            "Cinematic".to_string(),
3905                        ]
3906                        selected: preset_idx
3907                        tokens: tokens
3908                    }
3909                    EuvSegmented {
3910                        options: vec![
3911                            "RT Off".to_string(),
3912                            "RT Shadows".to_string(),
3913                            "RT Refl".to_string(),
3914                            "RT Full GI".to_string(),
3915                        ]
3916                        selected: rt_idx
3917                        tokens: tokens
3918                    }
3919                    EuvField {
3920                        label: "Runtime Render Resolution Scale (%)".to_string()
3921                        control: res_slider
3922                        tokens: tokens
3923                    }
3924                    EuvField {
3925                        label: "Time of Day / Sun Lighting (6h Dawn -> 17h Sunset -> 22h Night)".to_string()
3926                        control: sun_slider
3927                        tokens: tokens
3928                    }
3929                    { fs_3d_portal }
3930                }
3931            }
3932        }
3933    };
3934    ctx.get_scene().with_write(
3935        |tree: &mut SceneTree| {
3936            tree.attach_scope(sync_host_id, sync_scope);
3937        },
3938        (),
3939    );
3940    page
3941}
3942
3943/// Mounts the overlays page featuring interactive `EuvModal`, `EuvDrawer`, `EuvSheet`, `EuvPopover`, `EuvDropdown`, `EuvToast`, `EuvNotification`, and `EuvLoading`.
3944///
3945/// # Arguments
3946///
3947/// - `&ShowcaseState` - Reactive showcase state.
3948/// - `ThemeTokens` - Active design tokens.
3949///
3950/// # Returns
3951///
3952/// - `NodeId` - Mounted overlays page node.
3953pub fn mount_overlays_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3954    let p: ThemePalette = tokens.get_palette();
3955    let modal_open: Signal<bool> = state.get_modal_open();
3956    let drawer_open: Signal<bool> = state.get_drawer_open();
3957    let sheet_open: Signal<bool> = state.get_sheet_open();
3958    let toast_visible: Signal<bool> = state.get_toast_visible();
3959    let notif_visible: Signal<bool> = state.get_notif_visible();
3960    let alert_open: Signal<bool> = state.get_alert_dialog_open();
3961    let ctx_sel: Signal<Option<usize>> = Signal::new(None);
3962    let tip_btn: NodeId = view! {
3963        EuvButton {
3964            label: "Hover Tooltip".to_string()
3965            tokens: tokens
3966            outline()
3967            sm()
3968        }
3969    };
3970    let modal_body: NodeId = view! {
3971        column {
3972            style: {
3973                width: Length::Percent(100.0)
3974                gap: SPACE_MD
3975            }
3976            text {
3977                style: {
3978                    font_size: 13.0
3979                    color: p.get_muted_foreground()
3980                }
3981                { MODAL_BODY_TEXT }
3982            }
3983            row {
3984                style: {
3985                    width: Length::Percent(100.0)
3986                    justify: JustifyContent::End
3987                }
3988                EuvButton {
3989                    label: BTN_CLOSE_MODAL.to_string()
3990                    tokens: tokens
3991                    outline()
3992                    on_click: move |_: &UiEvent| {
3993                        let _: bool = modal_open.set_if_changed(false);
3994                    }
3995                }
3996            }
3997        }
3998    };
3999    let drawer_body: NodeId = view! {
4000        column {
4001            style: {
4002                width: Length::Percent(100.0)
4003                gap: SPACE_MD
4004            }
4005            text {
4006                style: {
4007                    font_size: 13.0
4008                    color: p.get_muted_foreground()
4009                }
4010                "Native slide-over drawer surface"
4011            }
4012            row {
4013                style: {
4014                    width: Length::Percent(100.0)
4015                    justify: JustifyContent::End
4016                }
4017                EuvButton {
4018                    label: "Close Drawer".to_string()
4019                    tokens: tokens
4020                    outline()
4021                    on_click: move |_: &UiEvent| {
4022                        let _: bool = drawer_open.set_if_changed(false);
4023                    }
4024                }
4025            }
4026        }
4027    };
4028    let sheet_body: NodeId = view! {
4029        column {
4030            style: {
4031                width: Length::Percent(100.0)
4032                gap: SPACE_MD
4033            }
4034            text {
4035                style: {
4036                    font_size: 13.0
4037                    color: p.get_muted_foreground()
4038                }
4039                "Native bottom action sheet"
4040            }
4041            row {
4042                style: {
4043                    width: Length::Percent(100.0)
4044                    justify: JustifyContent::End
4045                }
4046                EuvButton {
4047                    label: "Close Sheet".to_string()
4048                    tokens: tokens
4049                    outline()
4050                    on_click: move |_: &UiEvent| {
4051                        let _: bool = sheet_open.set_if_changed(false);
4052                    }
4053                }
4054            }
4055        }
4056    };
4057    view! {
4058        EuvPage {
4059            title: OVERLAYS_TITLE.to_string()
4060            subtitle: OVERLAYS_SUBTITLE.to_string()
4061            tokens: tokens
4062            column {
4063                style: {
4064                    width: Length::Percent(100.0)
4065                    gap: SPACE_LG
4066                }
4067                EuvAlert {
4068                    title: ALERT_TITLE.to_string()
4069                    description: ALERT_DESC.to_string()
4070                    tone: EuvTone::Primary
4071                    tokens: tokens
4072                }
4073                EuvCard {
4074                    title: OVERLAYS_CARD_TITLE.to_string()
4075                    tokens: tokens
4076                    subtitle: OVERLAYS_CARD_SUB
4077                    EuvActionRow {
4078                        EuvButton {
4079                            label: BTN_OPEN_MODAL.to_string()
4080                            tokens: tokens
4081                            on_click: move |_: &UiEvent| {
4082                                let _: bool = modal_open.set_if_changed(true);
4083                            }
4084                        }
4085                        EuvButton {
4086                            label: "Alert Dialog".to_string()
4087                            tokens: tokens
4088                            destructive()
4089                            on_click: move |_: &UiEvent| {
4090                                let _: bool = alert_open.set_if_changed(true);
4091                            }
4092                        }
4093                        EuvButton {
4094                            label: BTN_TOGGLE_TOAST.to_string()
4095                            tokens: tokens
4096                            secondary()
4097                            on_click: move |_: &UiEvent| {
4098                                let _: bool = toast_visible.update(|v: &mut bool| *v = !*v);
4099                            }
4100                        }
4101                        EuvButton {
4102                            label: "Toggle Drawer".to_string()
4103                            tokens: tokens
4104                            outline()
4105                            on_click: move |_: &UiEvent| {
4106                                let _: bool = drawer_open.update(|v: &mut bool| *v = !*v);
4107                            }
4108                        }
4109                        EuvButton {
4110                            label: "Toggle Sheet".to_string()
4111                            tokens: tokens
4112                            outline()
4113                            on_click: move |_: &UiEvent| {
4114                                let _: bool = sheet_open.update(|v: &mut bool| *v = !*v);
4115                            }
4116                        }
4117                        EuvButton {
4118                            label: "Toggle Notification".to_string()
4119                            tokens: tokens
4120                            outline()
4121                            on_click: move |_: &UiEvent| {
4122                                let _: bool = notif_visible.update(|v: &mut bool| *v = !*v);
4123                            }
4124                        }
4125                    }
4126                    EuvDropdown {
4127                        label: "Quick Actions".to_string()
4128                        items: vec!["Export PNG".to_string(), "Copy DeepLink".to_string()]
4129                        tokens: tokens
4130                        open: state.get_dropdown_open()
4131                        selected: state.get_dropdown_selected()
4132                    }
4133                    EuvHoverCard {
4134                        trigger_label: "@euv-dev".to_string()
4135                        title: HOVER_CARD_ENGINE_TITLE.to_string()
4136                        tokens: tokens
4137                        open: state.get_hover_card_open()
4138                        description: "Full ui.shadcn.com component alignment across all 7 native targets."
4139                    }
4140                    EuvTooltip {
4141                        text: "Zero-WebView floating tooltip".to_string()
4142                        trigger: tip_btn
4143                        tokens: tokens
4144                    }
4145                    EuvContextMenu {
4146                        trigger_label: "Context Menu Surface".to_string()
4147                        items: vec![
4148                            "Inspect Scene Node".to_string(),
4149                            "Copy AI Selector".to_string(),
4150                            "Capture Frame Hash".to_string(),
4151                        ]
4152                        tokens: tokens
4153                        selected: ctx_sel
4154                    }
4155                }
4156                EuvModal {
4157                    open: modal_open
4158                    title: MODAL_TITLE.to_string()
4159                    body: modal_body
4160                    tokens: tokens
4161                }
4162                EuvAlertDialog {
4163                    open: alert_open
4164                    title: "Are you absolutely sure?".to_string()
4165                    confirmed: state.get_alert_dialog_confirmed()
4166                    tokens: tokens
4167                    description: "This shadcn AlertDialog confirms destructive operations cleanly."
4168                    labels("Cancel", "Continue")
4169                }
4170                EuvDrawer {
4171                    open: drawer_open
4172                    title: "Inspector Drawer".to_string()
4173                    body: drawer_body
4174                    tokens: tokens
4175                }
4176                EuvSheet {
4177                    open: sheet_open
4178                    title: "Quick Sheet".to_string()
4179                    body: sheet_body
4180                    tokens: tokens
4181                }
4182                EuvToast {
4183                    visible: toast_visible
4184                    message: TOAST_TEXT.to_string()
4185                    tone: EuvTone::Success
4186                    tokens: tokens
4187                }
4188                EuvNotification {
4189                    visible: notif_visible
4190                    title: "Native Sync".to_string()
4191                    message: "All 7 targets active.".to_string()
4192                    tokens: tokens
4193                    tone: EuvTone::Success
4194                }
4195                EuvLoading {
4196                    active: state.get_loading_active()
4197                    label: "Syncing...".to_string()
4198                    tokens: tokens
4199                }
4200            }
4201        }
4202    }
4203}
4204
4205/// Mounts the interactive component-level and page-level dynamic OTA updates showcase page.
4206///
4207/// # Arguments
4208///
4209/// - `&ShowcaseState` - Reactive showcase state.
4210/// - `ThemeTokens` - Active design tokens.
4211///
4212/// # Returns
4213///
4214/// - `NodeId` - Mounted dynamic updates page node.
4215pub fn mount_dynamic_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
4216    state.ensure_wasm_registry_loaded();
4217    let p: ThemePalette = tokens.get_palette();
4218    let g: ThemeGeometry = tokens.get_geometry();
4219    let hub: DynamicUpdateHub = state.get_dynamic_hub().clone();
4220    let sibling_counter: Signal<i32> = state.get_sibling_counter();
4221    let action_log: Signal<String> = state.get_dynamic_action_log();
4222    let route_sig: Signal<String> = state.get_route();
4223    let tel_sig: Signal<DynamicTelemetry> = hub.telemetry();
4224    let banner_rev: Signal<u64> = hub.component_revision_signal(SLOT_PROMO_BANNER);
4225    let metrics_rev: Signal<u64> = hub.component_revision_signal(SLOT_METRICS_WIDGET);
4226    let panel_rev: Signal<u64> = hub.page_revision_signal(ROUTE_DYNAMIC_PANEL);
4227    let hub_v1: DynamicUpdateHub = hub.clone();
4228    let hub_v2: DynamicUpdateHub = hub.clone();
4229    let hub_rb: DynamicUpdateHub = hub.clone();
4230    let hub_m1: DynamicUpdateHub = hub.clone();
4231    let hub_mrb: DynamicUpdateHub = hub.clone();
4232    let hub_p1: DynamicUpdateHub = hub.clone();
4233    let hub_bundle: DynamicUpdateHub = hub.clone();
4234    let hub_prb: DynamicUpdateHub = hub.clone();
4235    let hub_inject: DynamicUpdateHub = hub.clone();
4236    let hub_for_status: DynamicUpdateHub = hub.clone();
4237    let wasm_mgr: WasmDynamicManager = state.get_wasm_manager().clone();
4238    let wasm_reg: RegistryWasmFetcher = state.get_wasm_registry().clone();
4239    let wasm_offline_sig: Signal<bool> = state.get_wasm_offline();
4240    let wasm_status_sig: Signal<String> = state.get_wasm_fault_status();
4241    let partial_scope: WasmDynamicScope = WasmDynamicScope::Partial {
4242        slot_id: SLOT_WASM_WIDGET.to_string(),
4243    };
4244    let partial_state_sig: Signal<WasmLoadState> = wasm_mgr.state_signal(&partial_scope);
4245    let global_state_sig: Signal<WasmLoadState> = wasm_mgr.state_signal(&WasmDynamicScope::Global);
4246    let wasm_tel_sig: Signal<WasmDynamicTelemetry> = wasm_mgr.telemetry();
4247    let m_p1: WasmDynamicManager = wasm_mgr.clone();
4248    let s_p1: Signal<String> = wasm_status_sig;
4249    let m_p2: WasmDynamicManager = wasm_mgr.clone();
4250    let s_p2: Signal<String> = wasm_status_sig;
4251    let m_prb: WasmDynamicManager = wasm_mgr.clone();
4252    let s_prb: Signal<String> = wasm_status_sig;
4253    let m_pun: WasmDynamicManager = wasm_mgr.clone();
4254    let s_pun: Signal<String> = wasm_status_sig;
4255    let r_off: RegistryWasmFetcher = wasm_reg.clone();
4256    let s_off: Signal<String> = wasm_status_sig;
4257    let m_g1: WasmDynamicManager = wasm_mgr.clone();
4258    let s_g1: Signal<String> = wasm_status_sig;
4259    let m_g2: WasmDynamicManager = wasm_mgr.clone();
4260    let s_g2: Signal<String> = wasm_status_sig;
4261    let m_gbad: WasmDynamicManager = wasm_mgr.clone();
4262    let s_gbad: Signal<String> = wasm_status_sig;
4263    let m_grb: WasmDynamicManager = wasm_mgr.clone();
4264    let s_grb: Signal<String> = wasm_status_sig;
4265    let m_f_retry: WasmDynamicManager = wasm_mgr.clone();
4266    let s_f_retry: Signal<String> = wasm_status_sig;
4267    let m_f_500: WasmDynamicManager = wasm_mgr.clone();
4268    let s_f_500: Signal<String> = wasm_status_sig;
4269    let m_f_corrupt: WasmDynamicManager = wasm_mgr.clone();
4270    let s_f_corrupt: Signal<String> = wasm_status_sig;
4271    let m_f_tamper: WasmDynamicManager = wasm_mgr.clone();
4272    let s_f_tamper: Signal<String> = wasm_status_sig;
4273    let m_f_sig: WasmDynamicManager = wasm_mgr.clone();
4274    let s_f_sig: Signal<String> = wasm_status_sig;
4275    let m_f_abi: WasmDynamicManager = wasm_mgr.clone();
4276    let s_f_abi: Signal<String> = wasm_status_sig;
4277    let m_f_exp: WasmDynamicManager = wasm_mgr.clone();
4278    let s_f_exp: Signal<String> = wasm_status_sig;
4279    let m_f_fuel: WasmDynamicManager = wasm_mgr.clone();
4280    let s_f_fuel: Signal<String> = wasm_status_sig;
4281    let m_f_trap: WasmDynamicManager = wasm_mgr.clone();
4282    let s_f_trap: Signal<String> = wasm_status_sig;
4283    let m_f_big: WasmDynamicManager = wasm_mgr.clone();
4284    let s_f_big: Signal<String> = wasm_status_sig;
4285    let m_f_cancel: WasmDynamicManager = wasm_mgr.clone();
4286    let s_f_cancel: Signal<String> = wasm_status_sig;
4287    let m_http: WasmDynamicManager = wasm_mgr.clone();
4288    let s_http: Signal<String> = wasm_status_sig;
4289    view! {
4290        EuvPage {
4291            title: DYNAMIC_TITLE.to_string()
4292            subtitle: DYNAMIC_SUBTITLE.to_string()
4293            tokens: tokens
4294            EuvCard {
4295                title: "Scoped / Partial Dynamic WASM Execution".to_string()
4296                tokens: tokens
4297                subtitle: "Download genuine .wasm binaries into a single native slot with checksum/signature verification, offline cache, interactive euv_on_event & rollback"
4298                column {
4299                    style: {
4300                        gap: SPACE_MD
4301                    }
4302                    EuvActionRow {
4303                        EuvButton {
4304                            label: "Download Real HTTP .wasm".to_string()
4305                            tokens: tokens
4306                            on_click: move |_: &UiEvent| {
4307                                #[cfg(not(target_arch = "wasm32"))]
4308                                {
4309                                    let bytes: Vec<u8> = build_partial_widget_wasm(
4310                                        "Live HTTP-Downloaded .wasm Module v3",
4311                                        3,
4312                                        0x059669,
4313                                    );
4314                                    let bytes_srv: Vec<u8> = bytes.clone();
4315                                    match TcpListener::bind("127.0.0.1:0") {
4316                                        Ok(listener) => {
4317                                            let port: u16 = listener
4318                                            .local_addr()
4319                                            .map(|addr: SocketAddr| addr.port())
4320                                            .unwrap_or(0);
4321                                            drop(spawn(move || {
4322                                                if let Ok((mut stream, _)) = listener.accept() {
4323                                                    let mut req_buf: [u8; 512] = [0; 512];
4324                                                    let _: Result<usize, Error> = stream.read(&mut req_buf);
4325                                                    let hdr: String = format!(
4326                                                        "HTTP/1.1 200 OK\r\nContent-Type: application/wasm\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
4327                                                        bytes_srv.len()
4328                                                    );
4329                                                    let _: Result<(), Error> = stream.write_all(hdr.as_bytes());
4330                                                    let _: Result<(), Error> = stream.write_all(&bytes_srv);
4331                                                    let _: Result<(), Error> = stream.flush();
4332                                                }
4333                                            }));
4334                                            let url: String =
4335                                            format!("http://127.0.0.1:{port}/live-module-v3.wasm");
4336                                            let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4337                                                url.clone(),
4338                                                SLOT_WASM_WIDGET.to_string(),
4339                                                3,
4340                                            )
4341                                            .with_checksum(compute_wasm_checksum(&bytes))
4342                                            .with_signature(compute_wasm_signature(
4343                                                &bytes,
4344                                                3,
4345                                                WASM_SHOWCASE_SIGNING_KEY,
4346                                            ))
4347                                            .with_allow_downgrade(true);
4348                                            match m_http.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4349                                                Ok(v) => {
4350                                                    let _: bool = s_http.set(format!(
4351                                                        "Downloaded {} bytes over real HTTP ({url}) -> executed & mounted .wasm v{v} natively!",
4352                                                        bytes.len()
4353                                                    ));
4354                                                }
4355                                                Err(e) => {
4356                                                    let _: bool = s_http.set(format!("HTTP .wasm download failed: {e}"));
4357                                                }
4358                                            }
4359                                        }
4360                                        Err(err) => {
4361                                            let _: bool = s_http.set(format!("Local HTTP server bind error: {err}"));
4362                                        }
4363                                    }
4364                                }
4365                                #[cfg(target_arch = "wasm32")]
4366                                {
4367                                    let bytes: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
4368                                    let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4369                                        URL_WASM_PARTIAL_V1.to_string(),
4370                                        SLOT_WASM_WIDGET.to_string(),
4371                                        1,
4372                                    )
4373                                    .with_checksum(compute_wasm_checksum(&bytes))
4374                                    .with_signature(compute_wasm_signature(&bytes, 1, WASM_SHOWCASE_SIGNING_KEY))
4375                                    .with_allow_downgrade(true);
4376                                    match m_http.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4377                                        Ok(v) => { let _: bool = s_http.set(format!("Fetched & executed .wasm v{v} natively in browser sandbox")); }
4378                                        Err(e) => { let _: bool = s_http.set(format!("WASM fetch failed: {e}")); }
4379                                    }
4380                                }
4381                            }
4382                        }
4383                        EuvButton {
4384                            label: "Download Partial WASM v1".to_string()
4385                            tokens: tokens
4386                            secondary()
4387                            on_click: move |_: &UiEvent| {
4388                                let bytes: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
4389                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4390                                    URL_WASM_PARTIAL_V1.to_string(),
4391                                    SLOT_WASM_WIDGET.to_string(),
4392                                    1,
4393                                )
4394                                .with_checksum(compute_wasm_checksum(&bytes))
4395                                .with_signature(compute_wasm_signature(&bytes, 1, WASM_SHOWCASE_SIGNING_KEY))
4396                                .with_allow_downgrade(true);
4397                                match m_p1.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4398                                    Ok(v) => { let _: bool = s_p1.set(format!("Mounted Partial .wasm v{v} natively (verified checksum + signature)")); }
4399                                    Err(e) => { let _: bool = s_p1.set(format!("Partial v1 failed: {e}")); }
4400                                }
4401                            }
4402                        }
4403                        EuvButton {
4404                            label: "Hot-Swap Partial WASM v2".to_string()
4405                            tokens: tokens
4406                            secondary()
4407                            on_click: move |_: &UiEvent| {
4408                                let bytes: Vec<u8> = build_partial_widget_wasm("Hot-Swapped Partial WASM Widget v2", 2, 0x7C3AED);
4409                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4410                                    URL_WASM_PARTIAL_V2.to_string(),
4411                                    SLOT_WASM_WIDGET.to_string(),
4412                                    2,
4413                                )
4414                                .with_checksum(compute_wasm_checksum(&bytes))
4415                                .with_signature(compute_wasm_signature(&bytes, 2, WASM_SHOWCASE_SIGNING_KEY))
4416                                .with_allow_downgrade(true);
4417                                match m_p2.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4418                                    Ok(v) => { let _: bool = s_p2.set(format!("Hot-swapped Partial .wasm v{v} natively (sibling UI untouched)")); }
4419                                    Err(e) => { let _: bool = s_p2.set(format!("Partial v2 failed: {e}")); }
4420                                }
4421                            }
4422                        }
4423                        EuvButton {
4424                            label: "Toggle Offline (Cache Hit)".to_string()
4425                            tokens: tokens
4426                            outline()
4427                            on_click: move |_: &UiEvent| {
4428                                let next: bool = !wasm_offline_sig.get_untracked();
4429                                let _: bool = wasm_offline_sig.set(next);
4430                                r_off.set_offline(next);
4431                                let _: bool = s_off.set(if next {
4432                                    "Simulated OFFLINE enabled — re-downloading v1 will serve verified offline cache!".to_string()
4433                                    } else {
4434                                        "Simulated ONLINE restored — fetching live .wasm from CDN".to_string()
4435                                });
4436                            }
4437                        }
4438                        EuvButton {
4439                            label: "Rollback Partial".to_string()
4440                            tokens: tokens
4441                            outline()
4442                            on_click: move |_: &UiEvent| {
4443                                match m_prb.rollback_partial(SLOT_WASM_WIDGET, "manual rollback") {
4444                                    Ok(v) => { let _: bool = s_prb.set(format!("Rolled back partial WASM slot to v{v}")); }
4445                                    Err(e) => { let _: bool = s_prb.set(format!("Rollback: {e}")); }
4446                                }
4447                            }
4448                        }
4449                        EuvButton {
4450                            label: "Unmount Slot".to_string()
4451                            tokens: tokens
4452                            ghost()
4453                            on_click: move |_: &UiEvent| {
4454                                m_pun.unmount_partial(SLOT_WASM_WIDGET);
4455                                let _: bool = s_pun.set("Unmounted partial WASM instance and restored compiled fallback".to_string());
4456                            }
4457                        }
4458                    }
4459                    slot {
4460                        id: SLOT_WASM_WIDGET
4461                        row {
4462                            style: {
4463                                width: Length::Percent(100.0)
4464                                padding: Edges::all(SPACE_MD)
4465                                background: p.get_muted()
4466                                border: (g.get_border_width(), p.get_border())
4467                                radius: g.get_radius_md()
4468                            }
4469                            text {
4470                                style: {
4471                                    font_size: 13.0
4472                                    color: p.get_muted_foreground()
4473                                }
4474                                "Compiled Native Slot (v0) — click 'Download Partial WASM v1' to fetch, verify, execute .wasm in sandbox & render natively."
4475                            }
4476                        }
4477                    }
4478                    text {
4479                        style: {
4480                            font_size: 12.0
4481                            color: p.get_muted_foreground()
4482                        }
4483                        { move || {
4484                            let st: WasmLoadState = partial_state_sig.get();
4485                            let gst: WasmLoadState = global_state_sig.get();
4486                            let tel: WasmDynamicTelemetry = wasm_tel_sig.get();
4487                            format!(
4488                                "Partial={st:?} | Global={gst:?} | OK={}/{} Cache={} Retries={} Rollbacks={} Traps={} FuelStops={} Rejects={} Events={}",
4489                                tel.get_downloads_succeeded(),
4490                                tel.get_downloads_started(),
4491                                tel.get_cache_hits(),
4492                                tel.get_retries_performed(),
4493                                tel.get_rollbacks_executed(),
4494                                tel.get_sandbox_traps_caught(),
4495                                tel.get_fuel_exhaustions_caught(),
4496                                tel.get_integrity_rejections(),
4497                                tel.get_events_handled()
4498                            )
4499                        } }
4500                    }
4501                }
4502            }
4503            EuvCard {
4504                title: "Global / Full-App Dynamic WASM Takeover".to_string()
4505                tokens: tokens
4506                subtitle: "Atomically replace the entire native app shell from a downloaded .wasm release with automatic Last-Known-Good (LKG) rollback on any fault"
4507                column {
4508                    style: {
4509                        gap: SPACE_MD
4510                    }
4511                    EuvActionRow {
4512                        EuvButton {
4513                            label: "Download Global WASM v1".to_string()
4514                            tokens: tokens
4515                            on_click: move |_: &UiEvent| {
4516                                let bytes: Vec<u8> =
4517                                build_global_app_wasm("Global Dynamic WASM App Shell v1", 1);
4518                                let req: WasmDownloadRequest =
4519                                WasmDownloadRequest::global(URL_WASM_GLOBAL_V1.to_string(), 1)
4520                                .with_checksum(compute_wasm_checksum(&bytes))
4521                                .with_signature(compute_wasm_signature(
4522                                    &bytes,
4523                                    1,
4524                                    WASM_SHOWCASE_SIGNING_KEY,
4525                                ))
4526                                .with_allow_downgrade(true);
4527                                match m_g1.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4528                                    Ok(v) => {
4529                                        let _: bool = s_g1
4530                                        .set(format!("Global .wasm v{v} took over root shell natively!"));
4531                                    }
4532                                    Err(e) => {
4533                                        let _: bool = s_g1.set(format!("Global v1 failed: {e}"));
4534                                    }
4535                                }
4536                            }
4537                        }
4538                        EuvButton {
4539                            label: "Upgrade Global WASM v2".to_string()
4540                            tokens: tokens
4541                            secondary()
4542                            on_click: move |_: &UiEvent| {
4543                                let bytes: Vec<u8> =
4544                                build_global_app_wasm("Global Dynamic WASM App Shell v2", 2);
4545                                let req: WasmDownloadRequest =
4546                                WasmDownloadRequest::global(URL_WASM_GLOBAL_V2.to_string(), 2)
4547                                .with_checksum(compute_wasm_checksum(&bytes))
4548                                .with_signature(compute_wasm_signature(
4549                                    &bytes,
4550                                    2,
4551                                    WASM_SHOWCASE_SIGNING_KEY,
4552                                ))
4553                                .with_allow_downgrade(true);
4554                                match m_g2.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4555                                    Ok(v) => {
4556                                        let _: bool =
4557                                        s_g2.set(format!("Upgraded Global .wasm to v{v} atomically"));
4558                                    }
4559                                    Err(e) => {
4560                                        let _: bool = s_g2.set(format!("Global v2 failed: {e}"));
4561                                    }
4562                                }
4563                            }
4564                        }
4565                        EuvButton {
4566                            label: "Faulty Global (Auto LKG Rollback)".to_string()
4567                            tokens: tokens
4568                            destructive()
4569                            on_click: move |_: &UiEvent| {
4570                                let req: WasmDownloadRequest =
4571                                WasmDownloadRequest::global(URL_WASM_TRAP.to_string(), 99);
4572                                match m_gbad.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4573                                    Ok(v) => {
4574                                        let _: bool = s_gbad.set(format!("Unexpected global mount v{v}"));
4575                                    }
4576                                    Err(e) => {
4577                                        let _: bool =
4578                                        s_gbad.set(format!("Global fault isolated & LKG preserved: {e}"));
4579                                    }
4580                                }
4581                            }
4582                        }
4583                        EuvButton {
4584                            label: "Restore Native Shell".to_string()
4585                            tokens: tokens
4586                            outline()
4587                            on_click: move |_: &UiEvent| {
4588                                m_grb.restore_native_global();
4589                                let _: bool = s_grb.set(STATUS_RESTORED_NATIVE_SHELL.to_string());
4590                            }
4591                        }
4592                    }
4593                }
4594            }
4595            EuvCard {
4596                title: "All-Case Security, Fault & Sandbox Verification Matrix".to_string()
4597                tokens: tokens
4598                subtitle: "Verify every edge case live: auto-retry, offline cache, integrity rejection, ABI mismatch, infinite-loop fuel cutoff, trap isolation & stale cancel guard"
4599                column {
4600                    style: {
4601                        gap: SPACE_MD
4602                    }
4603                    EuvActionRow {
4604                        EuvButton {
4605                            label: "Timeout -> Auto Retry".to_string()
4606                            tokens: tokens
4607                            outline()
4608                            sm()
4609                            on_click: move |_: &UiEvent| {
4610                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TIMEOUT_RETRY.to_string(), SLOT_WASM_WIDGET.to_string(), 10).with_allow_downgrade(true);
4611                                match m_f_retry.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4612                                    Ok(v) => { let _: bool = s_f_retry.set(format!("PASS Timeout->Retry recovered and mounted v{v}!")); }
4613                                    Err(e) => { let _: bool = s_f_retry.set(format!("Retry failed: {e}")); }
4614                                }
4615                            }
4616                        }
4617                        EuvButton {
4618                            label: "HTTP 500".to_string()
4619                            tokens: tokens
4620                            outline()
4621                            sm()
4622                            on_click: move |_: &UiEvent| {
4623                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_HTTP_500.to_string(), SLOT_WASM_WIDGET.to_string(), 11).with_allow_downgrade(true);
4624                                let res: String = format!("Handled HTTP 500 -> {:?}", m_f_500.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4625                                let _: bool = s_f_500.set(res);
4626                            }
4627                        }
4628                        EuvButton {
4629                            label: "Corrupted Magic".to_string()
4630                            tokens: tokens
4631                            outline()
4632                            sm()
4633                            on_click: move |_: &UiEvent| {
4634                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_CORRUPTED.to_string(), SLOT_WASM_WIDGET.to_string(), 12).with_allow_downgrade(true);
4635                                let res: String = format!("Blocked Corrupted Magic -> {:?}", m_f_corrupt.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4636                                let _: bool = s_f_corrupt.set(res);
4637                            }
4638                        }
4639                        EuvButton {
4640                            label: "Tampered Checksum".to_string()
4641                            tokens: tokens
4642                            outline()
4643                            sm()
4644                            on_click: move |_: &UiEvent| {
4645                                let good: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
4646                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TAMPERED.to_string(), SLOT_WASM_WIDGET.to_string(), 13)
4647                                .with_checksum(compute_wasm_checksum(&good))
4648                                .with_allow_downgrade(true);
4649                                let res: String = format!("Blocked Tampered Checksum -> {:?}", m_f_tamper.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4650                                let _: bool = s_f_tamper.set(res);
4651                            }
4652                        }
4653                        EuvButton {
4654                            label: "Invalid Signature".to_string()
4655                            tokens: tokens
4656                            outline()
4657                            sm()
4658                            on_click: move |_: &UiEvent| {
4659                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_PARTIAL_V1.to_string(), SLOT_WASM_WIDGET.to_string(), 14)
4660                                .with_signature("euv-sig-v1:forged".to_string())
4661                                .with_allow_downgrade(true);
4662                                let res: String = format!("Blocked Forged Signature -> {:?}", m_f_sig.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4663                                let _: bool = s_f_sig.set(res);
4664                            }
4665                        }
4666                        EuvButton {
4667                            label: "ABI Mismatch".to_string()
4668                            tokens: tokens
4669                            outline()
4670                            sm()
4671                            on_click: move |_: &UiEvent| {
4672                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_BAD_ABI.to_string(), SLOT_WASM_WIDGET.to_string(), 15).with_allow_downgrade(true);
4673                                let res: String = format!("Blocked ABI Mismatch -> {:?}", m_f_abi.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4674                                let _: bool = s_f_abi.set(res);
4675                            }
4676                        }
4677                        EuvButton {
4678                            label: "Missing Export".to_string()
4679                            tokens: tokens
4680                            outline()
4681                            sm()
4682                            on_click: move |_: &UiEvent| {
4683                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_MISSING_EXPORT.to_string(), SLOT_WASM_WIDGET.to_string(), 16).with_allow_downgrade(true);
4684                                let res: String = format!("Blocked Missing Export -> {:?}", m_f_exp.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4685                                let _: bool = s_f_exp.set(res);
4686                            }
4687                        }
4688                        EuvButton {
4689                            label: "Infinite-Loop Fuel".to_string()
4690                            tokens: tokens
4691                            outline()
4692                            sm()
4693                            on_click: move |_: &UiEvent| {
4694                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_FUEL_BOMB.to_string(), SLOT_WASM_WIDGET.to_string(), 17).with_allow_downgrade(true);
4695                                let res: String = format!("Terminated Runaway Loop -> {:?}", m_f_fuel.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4696                                let _: bool = s_f_fuel.set(res);
4697                            }
4698                        }
4699                        EuvButton {
4700                            label: "Runtime Trap".to_string()
4701                            tokens: tokens
4702                            outline()
4703                            sm()
4704                            on_click: move |_: &UiEvent| {
4705                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TRAP.to_string(), SLOT_WASM_WIDGET.to_string(), 18).with_allow_downgrade(true);
4706                                let res: String = format!("Isolated Runtime Trap -> {:?}", m_f_trap.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4707                                let _: bool = s_f_trap.set(res);
4708                            }
4709                        }
4710                        EuvButton {
4711                            label: "Oversized Binary".to_string()
4712                            tokens: tokens
4713                            outline()
4714                            sm()
4715                            on_click: move |_: &UiEvent| {
4716                                let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_OVERSIZED.to_string(), SLOT_WASM_WIDGET.to_string(), 19).with_allow_downgrade(true);
4717                                let res: String = format!("Blocked Oversized Binary -> {:?}", m_f_big.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4718                                let _: bool = s_f_big.set(res);
4719                            }
4720                        }
4721                        EuvButton {
4722                            label: "Cancel / Stale Guard".to_string()
4723                            tokens: tokens
4724                            outline()
4725                            sm()
4726                            on_click: move |_: &UiEvent| {
4727                                let gen_id: u64 = m_f_cancel.cancel_scope(&WasmDynamicScope::Partial { slot_id: SLOT_WASM_WIDGET.to_string() });
4728                                let _: bool = s_f_cancel.set(format!("Cancelled scope request cleanly (generation #{gen_id} blocks stale responses)"));
4729                            }
4730                        }
4731                    }
4732                    text {
4733                        style: {
4734                            font_size: 12.5
4735                            font_weight: FontWeight::Medium
4736                            color: p.get_primary()
4737                        }
4738                        { move || wasm_status_sig.get() }
4739                    }
4740                }
4741            }
4742            EuvCard {
4743                title: DYNAMIC_COMP_CARD_TITLE.to_string()
4744                tokens: tokens
4745                subtitle: DYNAMIC_COMP_CARD_SUB
4746                column {
4747                    style: {
4748                        gap: SPACE_MD
4749                    }
4750                    EuvActionRow {
4751                        EuvButton {
4752                            label: BTN_INC_SIBLING.to_string()
4753                            tokens: tokens
4754                            outline()
4755                            on_click: move |_: &UiEvent| {
4756                                let _: bool = sibling_counter.update(|v: &mut i32| *v += 1);
4757                            }
4758                        }
4759                    }
4760                    text {
4761                        style: {
4762                            font_size: 13.0
4763                            font_weight: FontWeight::SemiBold
4764                            color: p.get_primary()
4765                        }
4766                        { move || format!("Sibling State Preserved: count={}", sibling_counter.get()) }
4767                    }
4768                    EuvActionRow {
4769                        EuvButton {
4770                            label: BTN_PUSH_BANNER_V1.to_string()
4771                            tokens: tokens
4772                            on_click: move |_: &UiEvent| {
4773                                let next_v: u64 = hub_v1
4774                                .component_version(SLOT_PROMO_BANNER)
4775                                .saturating_add(1);
4776                                let mut badge: DynamicNodeSpec =
4777                                DynamicNodeSpec::badge(format!("OTA v{next_v}"));
4778                                badge
4779                                .get_mut_style()
4780                                .set_background_hex(Some(0x1D4ED8))
4781                                .set_color_hex(Some(0xFFFFFF));
4782                                let mut title: DynamicNodeSpec = DynamicNodeSpec::text(format!(
4783                                    "Dynamic JSON Banner v{next_v}: Surgical Component Patch"
4784                                ));
4785                                title
4786                                .get_mut_style()
4787                                .set_bold(true)
4788                                .set_color_hex(Some(0x1E3A8A));
4789                                let mut offer_btn: DynamicNodeSpec = DynamicNodeSpec::button(
4790                                    BTN_CLAIM_OFFER.to_string(),
4791                                    "claim_offer".to_string(),
4792                                );
4793                                offer_btn.set_payload(format!("json-v{next_v}"));
4794                                let mut box_spec: DynamicNodeSpec = DynamicNodeSpec::row()
4795                                .child(badge)
4796                                .child(title)
4797                                .child(offer_btn);
4798                                box_spec
4799                                .get_mut_style()
4800                                .set_full_width(true)
4801                                .set_padding(Some(12.0))
4802                                .set_radius(Some(8.0))
4803                                .set_background_hex(Some(0xEFF6FF))
4804                                .set_border_width(Some(1.0))
4805                                .set_border_hex(Some(0x93C5FD));
4806                                let mut upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
4807                                    SLOT_PROMO_BANNER.to_string(),
4808                                    next_v,
4809                                    box_spec,
4810                                );
4811                                upd.sign();
4812                                if let Ok(json) = upd.to_json() {
4813                                    let _: Result<u64, DynamicUpdateError> = hub_v1.apply_component_json(&json);
4814                                }
4815                            }
4816                        }
4817                        EuvButton {
4818                            label: BTN_PUSH_BANNER_V2.to_string()
4819                            tokens: tokens
4820                            secondary()
4821                            on_click: move |_: &UiEvent| {
4822                                let next_v: u64 = hub_v2.component_version(SLOT_PROMO_BANNER).saturating_add(1).max(2);
4823                                let hub_act: DynamicUpdateHub = hub_v2.clone();
4824                                let _: Result<u64, DynamicUpdateError> = hub_v2.swap_component_builder(
4825                                    SLOT_PROMO_BANNER.to_string(),
4826                                    next_v,
4827                                    move || {
4828                                        let hub_click: DynamicUpdateHub = hub_act.clone();
4829                                        view! {
4830                                            row {
4831                                                style: {
4832                                                    width: Length::Percent(100.0)
4833                                                    flex_wrap: FlexWrap::Wrap
4834                                                    padding: Edges::all(SPACE_MD)
4835                                                    gap: SPACE_MD
4836                                                    align: AlignItems::Center
4837                                                    background: Color::hex(0x064E3B)
4838                                                    radius: 8.0
4839                                                }
4840                                                text {
4841                                                    style: {
4842                                                        font_size: 14.0
4843                                                        font_weight: FontWeight::Bold
4844                                                        color: Color::hex(0xECFDF5)
4845                                                    }
4846                                                    { format!("Native Hot-Swapped Banner v{next_v} (Zero Restart)") }
4847                                                }
4848                                                EuvButton {
4849                                                    label: BTN_CLAIM_OFFER.to_string()
4850                                                    tokens: tokens
4851                                                    on_click: move |_: &UiEvent| {
4852                                                        hub_click.dispatch_action(DynamicActionEvent::new(
4853                                                            SLOT_PROMO_BANNER.to_string(),
4854                                                            "claim_offer".to_string(),
4855                                                            format!("native-v{next_v}"),
4856                                                        ));
4857                                                    }
4858                                                }
4859                                            }
4860                                        }
4861                                    },
4862                                );
4863                            }
4864                        }
4865                        EuvButton {
4866                            label: BTN_ROLLBACK_BANNER.to_string()
4867                            tokens: tokens
4868                            outline()
4869                            on_click: move |_: &UiEvent| {
4870                                let _: Result<u64, DynamicUpdateError> = hub_rb.rollback_component(SLOT_PROMO_BANNER);
4871                            }
4872                        }
4873                    }
4874                    slot {
4875                        id: SLOT_PROMO_BANNER
4876                        row {
4877                            style: {
4878                                width: Length::Percent(100.0)
4879                                padding: Edges::all(SPACE_MD)
4880                                background: p.get_muted()
4881                                border: (g.get_border_width(), p.get_border())
4882                                radius: g.get_radius_md()
4883                            }
4884                            text {
4885                                style: {
4886                                    font_size: 13.0
4887                                    color: p.get_foreground()
4888                                }
4889                                "Compiled Fallback Banner (v0) — click a button above to hot-update only this component."
4890                            }
4891                        }
4892                    }
4893                    EuvActionRow {
4894                        EuvButton {
4895                            label: BTN_PATCH_METRICS.to_string()
4896                            tokens: tokens
4897                            on_click: move |_: &UiEvent| {
4898                                let next_v: u64 = hub_m1.component_version(SLOT_METRICS_WIDGET).saturating_add(1);
4899                                let mut card_spec: DynamicNodeSpec = DynamicNodeSpec::card(format!("Live Metrics Widget v{next_v}"))
4900                                .child(DynamicNodeSpec::text(format!("Updated independently without touching promo_banner or sibling state (rev {next_v}).")));
4901                                card_spec
4902                                .get_mut_style()
4903                                .set_background_hex(Some(0xFEFCE8))
4904                                .set_border_width(Some(1.0))
4905                                .set_border_hex(Some(0xFACC15));
4906                                let mut upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
4907                                    SLOT_METRICS_WIDGET.to_string(),
4908                                    next_v,
4909                                    card_spec,
4910                                );
4911                                upd.sign();
4912                                let _: Result<u64, DynamicUpdateError> = hub_m1.apply_component(upd);
4913                            }
4914                        }
4915                        EuvButton {
4916                            label: BTN_ROLLBACK_METRICS.to_string()
4917                            tokens: tokens
4918                            outline()
4919                            on_click: move |_: &UiEvent| {
4920                                let _: Result<u64, DynamicUpdateError> =
4921                                hub_mrb.rollback_component(SLOT_METRICS_WIDGET);
4922                            }
4923                        }
4924                    }
4925                    slot {
4926                        id: SLOT_METRICS_WIDGET
4927                        row {
4928                            style: {
4929                                width: Length::Percent(100.0)
4930                                padding: Edges::all(SPACE_MD)
4931                                background: p.get_muted()
4932                                border: (g.get_border_width(), p.get_border())
4933                                radius: g.get_radius_md()
4934                            }
4935                            text {
4936                                style: {
4937                                    font_size: 13.0
4938                                    color: p.get_muted_foreground()
4939                                }
4940                                "Compiled Fallback Metrics Widget (v0) — independent surgical slot."
4941                            }
4942                        }
4943                    }
4944                }
4945            }
4946            EuvCard {
4947                title: DYNAMIC_PAGE_CARD_TITLE.to_string()
4948                tokens: tokens
4949                subtitle: DYNAMIC_PAGE_CARD_SUB
4950                column {
4951                    style: {
4952                        gap: SPACE_MD
4953                    }
4954                    EuvActionRow {
4955                        EuvButton {
4956                            label: BTN_UPDATE_PAGE_V1.to_string()
4957                            tokens: tokens
4958                            on_click: move |_: &UiEvent| {
4959                                let next_v: u64 = hub_p1.page_version(ROUTE_DYNAMIC_PANEL).saturating_add(1);
4960                                let spec: DynamicNodeSpec = DynamicNodeSpec::card(format!(
4961                                    "Hot-Updated Dynamic Page Panel v{next_v}"
4962                                ))
4963                                .child(DynamicNodeSpec::badge(format!("Page Revision v{next_v}")))
4964                                .child(DynamicNodeSpec::text(
4965                                    "Page-level layout replaced live without restarting the application."
4966                                    .to_string(),
4967                                ));
4968                                let mut upd: DynamicPageUpdate = DynamicPageUpdate::new(
4969                                    ROUTE_DYNAMIC_PANEL.to_string(),
4970                                    format!("Dynamic Panel v{next_v}"),
4971                                    next_v,
4972                                    spec,
4973                                );
4974                                upd.sign();
4975                                let _: Result<u64, DynamicUpdateError> = hub_p1.apply_page(upd);
4976                            }
4977                        }
4978                        EuvButton {
4979                            label: BTN_APPLY_BUNDLE.to_string()
4980                            tokens: tokens
4981                            secondary()
4982                            on_click: move |_: &UiEvent| {
4983                                let next_comp_v: u64 = hub_bundle
4984                                .component_version(SLOT_METRICS_WIDGET)
4985                                .saturating_add(1);
4986                                let next_page_v: u64 = hub_bundle
4987                                .page_version(ROUTE_DYNAMIC_PANEL)
4988                                .saturating_add(1);
4989                                let mut comp_upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
4990                                    SLOT_METRICS_WIDGET.to_string(),
4991                                    next_comp_v,
4992                                    DynamicNodeSpec::card(format!("Atomic Bundle Metrics v{next_comp_v}")).child(
4993                                        DynamicNodeSpec::text(
4994                                            "Committed together with page panel inside one atomic transaction."
4995                                            .to_string(),
4996                                        ),
4997                                    ),
4998                                );
4999                                comp_upd.sign();
5000                                let mut page_upd: DynamicPageUpdate = DynamicPageUpdate::new(
5001                                    ROUTE_DYNAMIC_PANEL.to_string(),
5002                                    format!("Atomic Panel v{next_page_v}"),
5003                                    next_page_v,
5004                                    DynamicNodeSpec::card(format!("Atomic Bundle Page Panel v{next_page_v}")).child(
5005                                        DynamicNodeSpec::text(
5006                                            "Both component slot and page slot updated atomically via signed JSON."
5007                                            .to_string(),
5008                                        ),
5009                                    ),
5010                                );
5011                                page_upd.sign();
5012                                let bundle: DynamicUpdateBundle =
5013                                DynamicUpdateBundle::new("ota-atomic-bundle".to_string(), next_page_v)
5014                                .push_component(comp_upd)
5015                                .push_page(page_upd);
5016                                if let Ok(json) = bundle.to_json() {
5017                                    let _: Result<DynamicTelemetry, DynamicUpdateError> =
5018                                    hub_bundle.apply_bundle_json(&json);
5019                                }
5020                            }
5021                        }
5022                        EuvButton {
5023                            label: BTN_ROLLBACK_PAGE.to_string()
5024                            tokens: tokens
5025                            outline()
5026                            on_click: move |_: &UiEvent| {
5027                                let _: Result<u64, DynamicUpdateError> = hub_prb.rollback_page(ROUTE_DYNAMIC_PANEL);
5028                            }
5029                        }
5030                        EuvButton {
5031                            label: BTN_INJECT_ROUTE.to_string()
5032                            tokens: tokens
5033                            secondary()
5034                            on_click: move |_: &UiEvent| {
5035                                let next_v: u64 = hub_inject.page_version(ROUTE_PROMO_LIVE).saturating_add(1);
5036                                let mut back_btn: DynamicNodeSpec = DynamicNodeSpec::button(
5037                                    BTN_RETURN_DYNAMIC.to_string(),
5038                                    "return_dynamic".to_string(),
5039                                );
5040                                back_btn.set_payload(format!("from-promo-v{next_v}"));
5041                                let page_spec: DynamicNodeSpec = DynamicNodeSpec::column().child(
5042                                    DynamicNodeSpec::card(format!("Runtime-Injected Page /promo-live (v{next_v})"))
5043                                    .child(DynamicNodeSpec::badge("Zero Recompile Route".to_string()))
5044                                    .child(DynamicNodeSpec::text(
5045                                        "This entire route was injected dynamically at runtime via signed JSON manifest."
5046                                        .to_string(),
5047                                    ))
5048                                    .child(back_btn),
5049                                );
5050                                let mut upd: DynamicPageUpdate = DynamicPageUpdate::new(
5051                                    ROUTE_PROMO_LIVE.to_string(),
5052                                    "Flash Promo (OTA)".to_string(),
5053                                    next_v,
5054                                    page_spec,
5055                                );
5056                                upd.sign();
5057                                if let Ok(json) = upd.to_json()
5058                                && hub_inject.apply_page_json(&json).is_ok()
5059                                {
5060                                    let _: bool = route_sig.set_if_changed(ROUTE_PROMO_LIVE.to_string());
5061                                }
5062                            }
5063                        }
5064                    }
5065                    page_slot {
5066                        route: ROUTE_DYNAMIC_PANEL
5067                        column {
5068                            style: {
5069                                width: Length::Percent(100.0)
5070                                padding: Edges::all(SPACE_MD)
5071                                background: p.get_muted()
5072                                border: (g.get_border_width(), p.get_border())
5073                                radius: g.get_radius_md()
5074                            }
5075                            text {
5076                                style: {
5077                                    font_size: 13.0
5078                                    color: p.get_foreground()
5079                                }
5080                                "Compiled Fallback Page Panel (v0) — click Hot-Update Page or Apply Atomic Bundle."
5081                            }
5082                        }
5083                    }
5084                    text {
5085                        style: {
5086                            font_size: 12.0
5087                            color: p.get_muted_foreground()
5088                        }
5089                        { move || {
5090                            let _: u64 = banner_rev.get();
5091                            let _: u64 = metrics_rev.get();
5092                            let _: u64 = panel_rev.get();
5093                            let tel: DynamicTelemetry = tel_sig.get();
5094                            format!(
5095                                "Versions: banner=v{} metrics=v{} panel=v{} | Applied: comp={} page={} rollbacks={} rejected={} | Last Action: {}",
5096                                hub_for_status.component_version(SLOT_PROMO_BANNER),
5097                                hub_for_status.component_version(SLOT_METRICS_WIDGET),
5098                                hub_for_status.page_version(ROUTE_DYNAMIC_PANEL),
5099                                tel.get_components_applied(),
5100                                tel.get_pages_applied(),
5101                                tel.get_rollbacks(),
5102                                tel.get_rejected(),
5103                                action_log.get(),
5104                            )
5105                        } }
5106                    }
5107                }
5108            }
5109        }
5110    }
5111}
5112
5113/// Mounts the complete cross-platform Media Studio page demonstrating Image, SVG, GIF, LIVE Photo, Video, Audio, PDF, and native HTML5.
5114///
5115/// # Arguments
5116///
5117/// - `&ShowcaseState` - Reactive showcase state.
5118/// - `ThemeTokens` - Active design tokens.
5119///
5120/// # Returns
5121///
5122/// - `NodeId` - Mounted Media Studio page node.
5123pub fn mount_media_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
5124    state.ensure_media_loaded();
5125    let p: ThemePalette = tokens.get_palette();
5126    let link_log: Signal<String> = state.get_media_html_link_log();
5127    let link_log_cb: Signal<String> = link_log;
5128    let photo_card: NodeId = view! {
5129        EuvImage {
5130            asset: ImageAsset::sample_photo("Hero Raster Photo (PNG/BMP/WebP)")
5131            tokens: tokens
5132            height: 148.0
5133        }
5134    };
5135    let svg_card: NodeId = view! {
5136        EuvSvgView {
5137            document: SvgDocument::sample_svg()
5138            label: "Vector SVG Badge".to_string()
5139            tokens: tokens
5140        }
5141    };
5142    let gif_card: NodeId = view! {
5143        EuvGifPlayer {
5144            state: state.get_media_gif()
5145            tokens: tokens
5146        }
5147    };
5148    let live_card: NodeId = view! {
5149        EuvLivePhoto {
5150            state: state.get_media_live()
5151            tokens: tokens
5152        }
5153    };
5154    let video_card: NodeId = view! {
5155        EuvVideoPlayer {
5156            state: state.get_media_video()
5157            tokens: tokens
5158        }
5159    };
5160    let audio_card: NodeId = view! {
5161        EuvAudioPlayer {
5162            state: state.get_media_audio()
5163            tokens: tokens
5164        }
5165    };
5166    let pdf_card: NodeId = view! {
5167        EuvPdfViewer {
5168            state: state.get_media_pdf()
5169            tokens: tokens
5170        }
5171    };
5172    let html_card: NodeId = view! {
5173        EuvHtmlView {
5174            document: HtmlDocument::sample_html()
5175            tokens: tokens
5176            on_link: move |href: String| {
5177                let _: bool = link_log_cb.set_if_changed(format!("Opened native link: {href}"));
5178            }
5179        }
5180    };
5181    view! {
5182        EuvPage {
5183            title: "Full Cross-Platform Media Studio".to_string()
5184            subtitle: "Pure-Rust aspect-preserving Image, SVG, animated GIF, LIVE Photo, Video, WAV Audio waveform, multi-page PDF, and sanitized zero-JS HTML5.".to_string()
5185            tokens: tokens
5186            { mount_bento_pair(photo_card, svg_card) }
5187            { mount_bento_pair(gif_card, live_card) }
5188            { mount_bento_pair(video_card, audio_card) }
5189            { mount_bento_pair(pdf_card, html_card) }
5190            text {
5191                style: {
5192                    font_size: 12.5
5193                    color: p.get_muted_foreground()
5194                }
5195                { move || link_log.get() }
5196            }
5197        }
5198    }
5199}
5200
5201/// Mounts a responsive 2-column Bento card pair (2 columns on desktop `Expanded`, 1 column on tablet/mobile).
5202///
5203/// # Arguments
5204///
5205/// - `NodeId` - First card node.
5206/// - `NodeId` - Second card node.
5207///
5208/// # Returns
5209///
5210/// - `NodeId` - Mounted responsive Bento container node.
5211fn mount_bento_pair(left: NodeId, right: NodeId) -> NodeId {
5212    let bp_sig: Signal<Breakpoint> = use_breakpoint();
5213    view! {
5214        grid {
5215            bind_style: move || {
5216                let cols: u16 = if bp_sig.get() == Breakpoint::Expanded { 2 } else { 1 };
5217                Style::default()
5218                .grid(cols)
5219                .width(Length::Percent(100.0))
5220                .gap(SPACE_MD)
5221            }
5222            { left }
5223            { right }
5224        }
5225    }
5226}