Skip to main content

euv_example/pages/
fn.rs

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