From db416035c5bfb93b2b1e2e965fee90a57b208a82 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Sat, 13 Jun 2026 17:46:34 +0800 Subject: [PATCH 1/3] feat(ppt-live): add staged deck generation with reusable agent sessions Move PPT Live research and deck authoring to hidden Cowork agent turns with session reuse, app-owned workspaces, and ppt-design skill file protocol. Tighten execution recovery to failed-tool rounds only and remove duplicate tool-loop gating from tool-contracts. --- src/apps/desktop/src/api/miniapp_agent_api.rs | 242 ++- src/apps/desktop/src/theme.rs | 4 +- .../src/agentic/execution/execution_engine.rs | 310 +++- .../tools/implementations/skill_tool.rs | 103 +- .../tools/implementations/skills/registry.rs | 67 + .../agentic/tools/pipeline/tool_pipeline.rs | 64 +- .../product-domains/src/miniapp/builtin.rs | 97 +- .../builtin/assets/ppt-live/build-bitfun.mjs | 9 +- .../builtin/assets/ppt-live/bundle.json | 2 +- .../builtin/assets/ppt-live/dist/ui.bundle.js | 522 +++--- .../builtin/assets/ppt-live/index.html | 21 +- .../miniapp/builtin/assets/ppt-live/meta.json | 16 +- .../ppt-live/src/bitfun-backend-adapter.js | 595 ++++--- .../builtin/assets/ppt-live/src/deck-ai.js | 152 +- .../ppt-live/src/export-slide-browser.js | 154 ++ .../builtin/assets/ppt-live/src/i18n.js | 40 +- .../builtin/assets/ppt-live/src/render.js | 56 +- .../builtin/assets/ppt-live/src/state.js | 14 +- .../assets/ppt-live/src/style-presets.js | 80 +- .../miniapp/builtin/assets/ppt-live/style.css | 148 +- .../src/miniapp/builtin/assets/ppt-live/ui.js | 1481 ++++++++++++++--- src/crates/execution/agent-stream/src/lib.rs | 139 +- .../tool-contracts/src/execution_gate.rs | 93 -- .../execution/tool-contracts/src/lib.rs | 5 +- .../tool-contracts/tests/tool_contracts.rs | 49 +- .../scenes/miniapps/hooks/useMiniAppBridge.ts | 3 + .../api/service-api/MiniAppAPI.ts | 12 + 27 files changed, 3039 insertions(+), 1439 deletions(-) diff --git a/src/apps/desktop/src/api/miniapp_agent_api.rs b/src/apps/desktop/src/api/miniapp_agent_api.rs index 1df45072d..d3080a703 100644 --- a/src/apps/desktop/src/api/miniapp_agent_api.rs +++ b/src/apps/desktop/src/api/miniapp_agent_api.rs @@ -5,8 +5,8 @@ //! and skills — instead of the raw single-call LLM access provided by the //! `ai` permission group. //! -//! Each run creates a hidden subagent session (invisible in the session list) -//! owned by `miniapp-agent:{app_id}:{run_id}` and submits exactly one dialog +//! A run creates or reuses a hidden subagent session (invisible in the session +//! list), owned by `miniapp-agent:{app_id}:{run_id}`, and submits one dialog //! turn through the standard `DialogScheduler`. Streaming output reaches the //! MiniApp iframe through the normal `agentic://*` Tauri events, which the //! web-ui MiniApp bridge filters by session id and forwards into the iframe. @@ -63,6 +63,39 @@ fn now_ms() -> u64 { .as_millis() as u64 } +/// A clean relative subdir contains only normal components: no `..`, no root, +/// no prefix, so joining it onto a base directory can never escape the base. +fn is_clean_relative_subdir(subdir: &str) -> bool { + let relative = std::path::Path::new(subdir); + !relative.as_os_str().is_empty() + && relative + .components() + .all(|component| matches!(component, std::path::Component::Normal(_))) +} + +/// Resolve a MiniApp-requested agent workspace inside the app's own appdata +/// directory. The subdir must be a clean relative path (no `..`, no absolute +/// or rooted components) so a MiniApp can never point the agent outside its +/// own storage. The directory is created if missing. +fn resolve_app_data_workspace( + state: &AppState, + app_id: &str, + subdir: &str, +) -> Result { + if !is_clean_relative_subdir(subdir) { + return Err("appDataWorkspace must be a clean relative path".to_string()); + } + let relative = std::path::Path::new(subdir); + let workspace = state + .miniapp_manager + .path_manager() + .miniapp_dir(app_id) + .join(relative); + std::fs::create_dir_all(&workspace) + .map_err(|e| format!("Failed to create MiniApp agent workspace: {}", e))?; + Ok(workspace.to_string_lossy().to_string()) +} + fn check_agent_rate_limit(app_id: &str, rate_limit_per_minute: u32) -> Result<(), String> { if rate_limit_per_minute == 0 { return Ok(()); @@ -174,6 +207,23 @@ pub struct MiniAppAgentRunRequest { pub session_name: Option, #[serde(default)] pub workspace_path: Option, + /// Defaults to true for backward compatibility. MiniApps may disable tools + /// for deterministic render-only turns after a tool-enabled planning turn. + /// Only applies when a new session is created. + #[serde(default)] + pub enable_tools: Option, + /// Reuse an existing hidden session created by an earlier run of the same + /// MiniApp. Later turns then share the session context (loaded skills, + /// research results, prior outputs), so multi-step tasks load each + /// resource once and "continue" turns can resume interrupted work. + #[serde(default)] + pub session_id: Option, + /// Relative subdirectory inside the MiniApp's own appdata directory to use + /// as the agent workspace (created if missing). File-protocol MiniApps use + /// this so the agent reads/writes project files in app-owned storage + /// instead of the user's workspace. Must be a clean relative path. + #[serde(default)] + pub app_data_workspace: Option, } #[derive(Debug, Serialize)] @@ -238,13 +288,22 @@ pub async fn miniapp_agent_run( agent_perms.rate_limit_per_minute.unwrap_or(0), )?; - let workspace_path = request - .workspace_path + let workspace_path = if let Some(subdir) = request + .app_data_workspace .as_deref() .map(str::trim) .filter(|value| !value.is_empty()) - .ok_or("workspacePath is required for MiniApp agent runs")? - .to_string(); + { + resolve_app_data_workspace(&state, &request.app_id, subdir)? + } else { + request + .workspace_path + .as_deref() + .map(str::trim) + .filter(|value| !value.is_empty()) + .ok_or("workspacePath is required for MiniApp agent runs")? + .to_string() + }; let run_id = request .run_id @@ -268,31 +327,59 @@ pub async fn miniapp_agent_run( .unwrap_or("MiniApp Agent Run") .to_string(); - // One hidden single-turn session per run so parallel runs never queue - // behind each other and never pollute the visible session list. - let config = SessionConfig { - enable_tools: true, - safe_mode: true, - auto_compact: false, - enable_context_compression: false, - max_turns: 1, - ..Default::default() + let requested_session_id = request + .session_id + .as_deref() + .map(str::trim) + .filter(|value| !value.is_empty()) + .map(str::to_string); + + let session_id = if let Some(existing_session_id) = requested_session_id { + // Reuse a hidden session created by an earlier run of this MiniApp so + // the new turn shares its context (skills, research, prior outputs). + let session = coordinator + .get_session_manager() + .get_session(&existing_session_id) + .ok_or("Unknown MiniApp agent session")?; + let owner_prefix = format!("miniapp-agent:{}:", request.app_id); + if !session + .created_by + .as_deref() + .is_some_and(|created_by| created_by.starts_with(&owner_prefix)) + { + return Err("Unknown MiniApp agent session".to_string()); + } + if session.config.workspace_path.as_deref() != Some(workspace_path.as_str()) { + return Err("MiniApp agent session workspace does not match this run".to_string()); + } + existing_session_id + } else { + // One hidden session per task keeps MiniApp work isolated and out of + // the visible session list. Follow-up turns may reuse it via sessionId. + let enable_tools = request.enable_tools.unwrap_or(true); + let config = SessionConfig { + enable_tools, + safe_mode: true, + auto_compact: true, + enable_context_compression: true, + compression_threshold: 0.65, + ..Default::default() + }; + // Cowork supplies the office skill group and research/file tools when + // enabled. + let session = coordinator + .create_hidden_subagent_session_with_workspace( + None, + session_name, + "Cowork".to_string(), + config, + workspace_path.clone(), + Some(owner), + ) + .await + .map_err(|e| format!("Failed to create MiniApp agent session: {}", e))?; + session.session_id }; - // Cowork is the office/collaboration mode: it is the only mode where the - // office skill group (incl. ppt-design) is enabled by default, and its - // toolset covers the research + file tools PPT generation needs. - let session = coordinator - .create_hidden_subagent_session_with_workspace( - None, - session_name, - "Cowork".to_string(), - config, - workspace_path.clone(), - Some(owner), - ) - .await - .map_err(|e| format!("Failed to create MiniApp agent session: {}", e))?; - let session_id = session.session_id.clone(); let policy = DialogSubmissionPolicy::for_source(DialogTriggerSource::DesktopApi) .with_skip_tool_confirmation(true); @@ -375,25 +462,41 @@ pub async fn miniapp_agent_turn_text( .get_context_messages(&request.session_id) .await .map_err(|e| e.to_string())?; - let text = messages + // Sessions may hold multiple MiniApp turns; only this turn's assistant + // text is a valid answer for this run. The answer itself may span several + // assistant messages when the engine continues a truncated stream across + // rounds ("continue from exactly where you stopped"), so concatenate, in + // order, every assistant text after this turn's last tool result. The + // internal reminder user messages between segments do not break the run. + let turn_messages: Vec<&_> = messages + .iter() + .filter(|message| message.metadata.turn_id.as_deref() == Some(request.turn_id.as_str())) + .collect(); + let answer_start = turn_messages + .iter() + .rposition(|message| { + message.role == MessageRole::Tool + || matches!(message.content, MessageContent::ToolResult { .. }) + }) + .map_or(0, |index| index + 1); + let text = turn_messages[answer_start..] .iter() - .rev() .filter(|message| message.role == MessageRole::Assistant) - .find_map(|message| { + .filter_map(|message| { let text = match &message.content { MessageContent::Text(text) => text.as_str(), MessageContent::Multimodal { text, .. } => text.as_str(), MessageContent::Mixed { text, .. } => text.as_str(), MessageContent::ToolResult { .. } => "", }; - let trimmed = text.trim(); - if trimmed.is_empty() { + if text.trim().is_empty() { None } else { - Some(text.to_string()) + Some(text) } }) - .unwrap_or_default(); + .collect::>() + .concat(); Ok(MiniAppAgentTurnTextResponse { text }) } @@ -430,3 +533,68 @@ pub async fn miniapp_agent_cancel_stale_runs( cancelled_runs: cancelled, }) } + +#[cfg(test)] +mod tests { + use super::{is_clean_relative_subdir, MiniAppAgentRunRequest}; + use serde_json::json; + + #[test] + fn miniapp_agent_run_request_keeps_tool_enablement_backward_compatible() { + let legacy: MiniAppAgentRunRequest = serde_json::from_value(json!({ + "appId": "builtin-ppt-live", + "prompt": "plan", + "workspacePath": "/tmp/workspace" + })) + .expect("legacy MiniApp agent request should deserialize"); + assert!(legacy.enable_tools.unwrap_or(true)); + assert!(legacy.session_id.is_none()); + + let render: MiniAppAgentRunRequest = serde_json::from_value(json!({ + "appId": "builtin-ppt-live", + "prompt": "render", + "workspacePath": "/tmp/workspace", + "enableTools": false + })) + .expect("render-only MiniApp agent request should deserialize"); + assert_eq!(render.enable_tools, Some(false)); + } + + #[test] + fn miniapp_agent_run_request_accepts_session_reuse() { + let follow_up: MiniAppAgentRunRequest = serde_json::from_value(json!({ + "appId": "builtin-ppt-live", + "prompt": "render slide 2", + "workspacePath": "/tmp/workspace", + "sessionId": "session-1" + })) + .expect("session-reuse MiniApp agent request should deserialize"); + assert_eq!(follow_up.session_id.as_deref(), Some("session-1")); + } + + #[test] + fn miniapp_agent_run_request_accepts_app_data_workspace() { + let request: MiniAppAgentRunRequest = serde_json::from_value(json!({ + "appId": "builtin-ppt-live", + "prompt": "plan a deck", + "appDataWorkspace": "decks/deck-123" + })) + .expect("appdata-workspace MiniApp agent request should deserialize"); + assert_eq!( + request.app_data_workspace.as_deref(), + Some("decks/deck-123") + ); + assert!(request.workspace_path.is_none()); + } + + #[test] + fn app_data_workspace_subdir_must_stay_inside_app_storage() { + assert!(is_clean_relative_subdir("decks/deck-123")); + assert!(is_clean_relative_subdir("decks")); + assert!(!is_clean_relative_subdir("")); + assert!(!is_clean_relative_subdir("/etc")); + assert!(!is_clean_relative_subdir("../outside")); + assert!(!is_clean_relative_subdir("decks/../../outside")); + assert!(!is_clean_relative_subdir("./decks")); + } +} diff --git a/src/apps/desktop/src/theme.rs b/src/apps/desktop/src/theme.rs index ef4b93a0e..27ecfedeb 100644 --- a/src/apps/desktop/src/theme.rs +++ b/src/apps/desktop/src/theme.rs @@ -1,7 +1,9 @@ //! Theme System use std::sync::{OnceLock, RwLock}; -use std::time::{Duration, Instant}; +#[cfg(target_os = "windows")] +use std::time::Duration; +use std::time::Instant; use bitfun_core::infrastructure::try_get_path_manager_arc; use bitfun_core::service::config::types::GlobalConfig; diff --git a/src/crates/assembly/core/src/agentic/execution/execution_engine.rs b/src/crates/assembly/core/src/agentic/execution/execution_engine.rs index fe868b820..b20a43407 100644 --- a/src/crates/assembly/core/src/agentic/execution/execution_engine.rs +++ b/src/crates/assembly/core/src/agentic/execution/execution_engine.rs @@ -248,6 +248,11 @@ pub struct ExecutionEngine { } impl ExecutionEngine { + const FINALIZE_AFTER_TOOL_USE_REMINDER: &'static str = "Tool execution for this turn has already completed, but the turn is ending at this round boundary. Do not call any more tools. Provide the final response to the user based on the tool results already available."; + const FINALIZE_AFTER_REPEATED_TOOL_FAILURES_REMINDER: &'static str = "Repeated tool attempts have failed and tool use is now disabled for this turn. Provide a concise final response explaining what was completed, what failed, the evidence from the tool results, and the best actionable next step. Do not call any more tools."; + const FINALIZE_AFTER_MAX_ROUNDS_REMINDER: &'static str = "The execution round budget has been reached and tool use is now disabled for this turn. Provide the best final response possible from the work and evidence already collected. Clearly distinguish completed work from unresolved items. Do not call any more tools."; + const FORCE_TEXT_ONLY_REMINDER: &'static str = "STOP. Tool calls are disabled for this final turn. Respond ONLY with a plain-text answer summarizing what you have done and the result for the user. Do not output tool call syntax of any kind."; + pub fn new( round_executor: Arc, event_queue: Arc, @@ -316,6 +321,44 @@ impl ExecutionEngine { ) } + fn tool_call_signature(tool_calls: &[crate::agentic::core::ToolCall]) -> Option { + if tool_calls.is_empty() { + return None; + } + + let mut signatures: Vec = tool_calls + .iter() + .map(|tool_call| { + let arguments = tool_call.arguments.to_string(); + let arguments_summary = Self::tool_signature_args_summary(&arguments); + format!("{}:{}", tool_call.tool_name, arguments_summary) + }) + .collect(); + signatures.sort(); + Some(signatures.join("|")) + } + + fn failed_tool_round_signature( + tool_calls: &[crate::agentic::core::ToolCall], + tool_result_messages: &[Message], + ) -> Option { + if tool_result_messages.is_empty() + || !tool_result_messages.iter().all(|message| { + let MessageContent::ToolResult { + result, is_error, .. + } = &message.content + else { + return false; + }; + ContextHealthSnapshot::tool_result_failed(result, *is_error) + }) + { + return None; + } + + Self::tool_call_signature(tool_calls) + } + /// Whether a partial stream recovery should trigger a continuation round /// instead of treating truncated assistant text as the final answer. /// @@ -2102,11 +2145,12 @@ impl ExecutionEngine { let mut consecutive_compression_failures: u32 = 0; const MAX_CONSECUTIVE_COMPRESSION_FAILURES: u32 = 3; - // P0: Loop detection: track recent tool call signatures + // Track tool-call patterns for context health, but only use rounds with + // actual failed tool results for no-progress recovery decisions. let mut recent_tool_signatures: Vec = Vec::new(); - let mut loop_detected = false; - let mut loop_recovery_attempts: usize = 0; - const MAX_LOOP_RECOVERY_ATTEMPTS: usize = 3; + let mut recent_failed_tool_signatures: Vec = Vec::new(); + let mut failed_tool_recovery_attempts: usize = 0; + const MAX_FAILED_TOOL_RECOVERY_ATTEMPTS: usize = 3; const MAX_PARTIAL_CONTINUATION_ATTEMPTS: usize = 3; let mut full_compression_count = 0usize; let mut compression_failure_count = 0u32; @@ -2454,22 +2498,23 @@ impl ExecutionEngine { last_partial_recovery_reason = round_result.partial_recovery_reason.clone(); } - // P0: Consecutive same-tool-call loop detection - if !round_result.tool_calls.is_empty() { - let mut sigs: Vec = round_result - .tool_calls - .iter() - .map(|tc| { - let args_str = tc.arguments.to_string(); - let args_summary = Self::tool_signature_args_summary(&args_str); - format!("{}:{}", tc.tool_name, args_summary) - }) - .collect(); - sigs.sort(); - let round_sig = sigs.join("|"); - recent_tool_signatures.push(round_sig); + if let Some(round_signature) = Self::tool_call_signature(&round_result.tool_calls) { + recent_tool_signatures.push(round_signature.clone()); + if Self::failed_tool_round_signature( + &round_result.tool_calls, + &round_result.tool_result_messages, + ) + .is_some() + { + recent_failed_tool_signatures.push(round_signature); + } else { + recent_failed_tool_signatures.clear(); + failed_tool_recovery_attempts = 0; + } } else { recent_tool_signatures.clear(); + recent_failed_tool_signatures.clear(); + failed_tool_recovery_attempts = 0; } let after_round_tokens = @@ -2496,18 +2541,19 @@ impl ExecutionEngine { let max_consec = context_profile_policy .effective_loop_threshold(self.config.max_consecutive_same_tool); - if recent_tool_signatures.len() >= max_consec { - let tail = &recent_tool_signatures[recent_tool_signatures.len() - max_consec..]; + if recent_failed_tool_signatures.len() >= max_consec { + let tail = &recent_failed_tool_signatures + [recent_failed_tool_signatures.len() - max_consec..]; if tail.windows(2).all(|w| w[0] == w[1]) { - if loop_recovery_attempts < MAX_LOOP_RECOVERY_ATTEMPTS { - loop_recovery_attempts += 1; + if failed_tool_recovery_attempts < MAX_FAILED_TOOL_RECOVERY_ATTEMPTS { + failed_tool_recovery_attempts += 1; warn!( - "Loop detected: {} consecutive rounds with identical tool signatures, injecting recovery prompt #{}", - max_consec, loop_recovery_attempts + "Repeated tool failure detected: {} consecutive rounds with identical tool signatures, injecting recovery prompt #{}", + max_consec, failed_tool_recovery_attempts ); let reminder = format!( - "Loop detected: you have repeated the same tool call with identical arguments {} times in a row. \ - This means the approach is not making progress. You MUST now change your strategy: \ + "Repeated tool failure detected: the same tool call with identical arguments has failed {} times in a row. \ + The current approach is not making progress. You MUST now change your strategy: \ (1) if the tool keeps failing, try a completely different approach or tool; \ (2) if you are stuck, step back and reason about the root cause before acting; \ (3) if the task is genuinely impossible with the available tools, provide a clear explanation to the user. \ @@ -2525,18 +2571,15 @@ impl ExecutionEngine { .add_message(&context.session_id, user_msg) .await { - warn!("Failed to persist loop recovery reminder: {}", e); + warn!("Failed to persist failed-tool recovery reminder: {}", e); } - // Clear the recent signatures so the detector resets after recovery. - recent_tool_signatures.clear(); - // Do NOT break — continue the loop so the model gets a chance to recover. + recent_failed_tool_signatures.clear(); } else { warn!( - "Loop detected: {} consecutive rounds with identical tool signatures, max recovery attempts ({}) exhausted, stopping", - max_consec, MAX_LOOP_RECOVERY_ATTEMPTS + "Repeated tool failure detected: {} consecutive rounds with identical tool signatures, max recovery attempts ({}) exhausted, finalizing without tools", + max_consec, MAX_FAILED_TOOL_RECOVERY_ATTEMPTS ); - loop_detected = true; - finalization_reason = Some("loop_detected"); + finalization_reason = Some("repeated_tool_failures"); break; } } @@ -2556,17 +2599,17 @@ impl ExecutionEngine { // if at most `max_consec` distinct signatures appear AND every one // of those signatures appears at least twice, the window contains // no genuine new exploration and we treat it as a loop. - if Self::is_periodic_tool_signature_loop(&recent_tool_signatures, max_consec) { + if Self::is_periodic_tool_signature_loop(&recent_failed_tool_signatures, max_consec) { let window_size = max_consec.max(1).saturating_mul(2); - if loop_recovery_attempts < MAX_LOOP_RECOVERY_ATTEMPTS { - loop_recovery_attempts += 1; + if failed_tool_recovery_attempts < MAX_FAILED_TOOL_RECOVERY_ATTEMPTS { + failed_tool_recovery_attempts += 1; warn!( - "Loop detected: last {} rounds form a periodic tool-call pattern (<= {} distinct signatures, each repeated), injecting recovery prompt #{}", - window_size, max_consec, loop_recovery_attempts + "Repeated tool failure detected: last {} failed rounds form a periodic tool-call pattern (<= {} distinct signatures, each repeated), injecting recovery prompt #{}", + window_size, max_consec, failed_tool_recovery_attempts ); let reminder = format!( - "Loop detected: your last {} tool calls form a repeating pattern with no new progress. \ - You are cycling between the same actions without advancing the task. You MUST now change your strategy: \ + "Repeated tool failure detected: your last {} failed tool calls form a repeating pattern with no new progress. \ + You are cycling between failing actions without advancing the task. You MUST now change your strategy: \ (1) try a completely different approach or tool; \ (2) step back and reason about the root cause before acting; \ (3) if the task is genuinely impossible with the available tools, provide a clear explanation to the user. \ @@ -2586,16 +2629,13 @@ impl ExecutionEngine { { warn!("Failed to persist periodic loop recovery reminder: {}", e); } - // Clear the recent signatures so the detector resets after recovery. - recent_tool_signatures.clear(); - // Do NOT break — continue the loop so the model gets a chance to recover. + recent_failed_tool_signatures.clear(); } else { warn!( - "Loop detected: last {} rounds form a periodic tool-call pattern, max recovery attempts ({}) exhausted, stopping", - window_size, MAX_LOOP_RECOVERY_ATTEMPTS + "Repeated tool failure detected: last {} failed rounds form a periodic tool-call pattern, max recovery attempts ({}) exhausted, finalizing without tools", + window_size, MAX_FAILED_TOOL_RECOVERY_ATTEMPTS ); - loop_detected = true; - finalization_reason = Some("loop_detected"); + finalization_reason = Some("repeated_tool_failures"); break; } } @@ -2807,10 +2847,121 @@ impl ExecutionEngine { // P1-6: Track the actual termination reason for downstream reporting. // Defaults to "complete" (model produced a final answer naturally). - let effective_finish_reason: &'static str = match finalization_reason { + let mut effective_finish_reason: &'static str = match finalization_reason { Some(r) => r, None => "complete", }; + let mut finalize_fallback_text_used = false; + + if let Some(reason) = finalization_reason { + let finalize_reminder = match reason { + "queued_user_message" + if messages + .iter() + .rev() + .find(|message| message.role == MessageRole::Assistant) + .is_some_and(Self::assistant_has_tool_calls) + && Self::has_tool_result_after_last_assistant(&messages) => + { + Some(Self::FINALIZE_AFTER_TOOL_USE_REMINDER) + } + "repeated_tool_failures" => { + Some(Self::FINALIZE_AFTER_REPEATED_TOOL_FAILURES_REMINDER) + } + "max_rounds" => Some(Self::FINALIZE_AFTER_MAX_ROUNDS_REMINDER), + _ => None, + }; + + if let Some(finalize_reminder) = finalize_reminder { + info!( + "Finalizing dialog turn: session_id={}, turn_id={}, reason={}", + context.session_id, context.dialog_turn_id, reason + ); + + let final_round_result = self + .run_finalize_round( + ai_client.clone(), + &context, + agent_type.clone(), + completed_rounds, + &execution_context_vars, + primary_supports_image_understanding, + &prepended_reminders, + &messages, + finalize_reminder, + context_window, + ) + .await?; + + let mut accepted = final_round_result.had_assistant_text + && !Self::assistant_has_tool_calls(&final_round_result.assistant_message); + let mut chosen_assistant_message: Option = None; + let mut chosen_usage: Option = + final_round_result.usage.clone(); + + if accepted { + chosen_assistant_message = Some(final_round_result.assistant_message.clone()); + } else { + // P1-10: First finalize round still returned tool calls + // (rare; tools were not provided, but model hallucinated). + // One last attempt with a stricter text-only reminder. + warn!( + "Finalize round still returned tool calls; retrying with text-only reminder: session_id={}, turn_id={}", + context.session_id, context.dialog_turn_id + ); + let retry_result = self + .run_finalize_round( + ai_client.clone(), + &context, + agent_type.clone(), + completed_rounds, + &execution_context_vars, + primary_supports_image_understanding, + &prepended_reminders, + &messages, + Self::FORCE_TEXT_ONLY_REMINDER, + context_window, + ) + .await?; + finalize_fallback_text_used = true; + if !retry_result.had_assistant_text + || Self::assistant_has_tool_calls(&retry_result.assistant_message) + { + warn!( + "Text-only retry did not return usable assistant text; keeping prior messages: session_id={}, turn_id={}", + context.session_id, context.dialog_turn_id + ); + } else { + accepted = true; + chosen_usage = retry_result.usage.clone(); + chosen_assistant_message = Some(retry_result.assistant_message); + } + } + + if let Some(msg) = chosen_assistant_message { + completed_rounds += 1; + if let Some(usage) = chosen_usage { + last_usage = Some(usage); + } + messages.push(msg.clone()); + if let Err(e) = self + .session_manager + .add_message(&context.session_id, msg) + .await + { + warn!("Failed to update final assistant message in memory: {}", e); + } + } + + if !accepted { + effective_finish_reason = "finalize_failed"; + } else if reason == "max_rounds" { + effective_finish_reason = "max_rounds_finalized"; + } else if finalize_fallback_text_used { + effective_finish_reason = "finalize_text_only_forced"; + } + } + } let duration_ms = elapsed_ms_u64(start_time); @@ -2821,11 +2972,10 @@ impl ExecutionEngine { let finish_reason = FinishReason::Complete; // success reflects whether we ended with a usable final answer. - let success = !loop_detected - && !matches!( - effective_finish_reason, - "finalize_failed" | "empty_round" | "max_rounds" - ); + let success = !matches!( + effective_finish_reason, + "finalize_failed" | "empty_round" | "max_rounds" + ); // Post-processing hook: when a DeepResearch dialog turn finishes // successfully, renumber `cit_XXX` references in the final report @@ -3066,6 +3216,58 @@ mod tests { assert_ne!(first_summary, second_summary); } + #[test] + fn failed_tool_round_signature_ignores_successful_repeated_calls() { + let tool_calls = vec![ToolCall { + tool_id: "tool-1".to_string(), + tool_name: "PollStatus".to_string(), + arguments: json!({ "job_id": "job-1" }), + raw_arguments: None, + is_error: false, + recovered_from_truncation: false, + }]; + let results = vec![Message::tool_result(ToolResult { + tool_id: "tool-1".to_string(), + tool_name: "PollStatus".to_string(), + result: json!({ "status": "pending", "success": true }), + result_for_assistant: Some("The job is still pending.".to_string()), + is_error: false, + duration_ms: Some(1), + image_attachments: None, + })]; + + assert!( + ExecutionEngine::failed_tool_round_signature(&tool_calls, &results).is_none(), + "successful polling must not be treated as a failed loop" + ); + } + + #[test] + fn failed_tool_round_signature_requires_actual_failure_evidence() { + let tool_calls = vec![ToolCall { + tool_id: "tool-1".to_string(), + tool_name: "Read".to_string(), + arguments: json!({ "path": "missing.txt" }), + raw_arguments: None, + is_error: false, + recovered_from_truncation: false, + }]; + let results = vec![Message::tool_result(ToolResult { + tool_id: "tool-1".to_string(), + tool_name: "Read".to_string(), + result: json!({ "success": false, "error": "not found" }), + result_for_assistant: Some("File not found.".to_string()), + is_error: true, + duration_ms: Some(1), + image_attachments: None, + })]; + + assert_eq!( + ExecutionEngine::failed_tool_round_signature(&tool_calls, &results).as_deref(), + Some(r#"Read:{"path":"missing.txt"}"#) + ); + } + #[test] fn periodic_loop_detector_ignores_short_windows() { let signatures: Vec = vec!["A".to_string(), "B".to_string(), "A".to_string()]; diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs b/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs index a3bde63e6..a4abe92ed 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs @@ -29,15 +29,15 @@ impl SkillTool { When users ask you to perform tasks, check whether any skills listed in the current skill listing can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge. How to use skills: -- Invoke skills using this tool with the skill name only (no arguments) +- Invoke skills using this tool with the listed skill name or stable key (no arguments) - The skill's prompt will expand and provide detailed instructions on how to complete the task - Examples: - `command: "pdf"` - invoke the pdf skill - `command: "xlsx"` - invoke the xlsx skill - - `command: "ms-office-suite:pdf"` - invoke using fully qualified name + - `command: "user::bitfun-system::ppt-design"` - invoke a specific built-in skill by stable key Important: -- Only use skills listed in the current skill listing's section +- Only use skills listed in the current skill listing's section, unless a trusted host task explicitly supplies an exact stable key - Do not invoke a skill that is already running "# .to_string() @@ -202,6 +202,7 @@ impl Tool for SkillTool { // Find and load skill through registry let registry = get_skill_registry(); + let use_stable_key = skill_name.split("::").count() == 3; let skill_data = if context.is_remote() { if let Some(ws_fs) = context.ws_fs() { let root = context @@ -209,11 +210,50 @@ impl Tool for SkillTool { .as_ref() .map(|w| w.root_path_string()) .unwrap_or_default(); + if use_stable_key { + registry + .find_and_load_skill_by_key_for_remote_workspace( + skill_name, + ws_fs, + &root, + context.agent_type.as_deref(), + ) + .await? + } else { + registry + .find_and_load_skill_for_remote_workspace( + skill_name, + ws_fs, + &root, + context.agent_type.as_deref(), + ) + .await? + } + } else { + if use_stable_key { + registry + .find_and_load_skill_by_key_for_workspace( + skill_name, + None, + context.agent_type.as_deref(), + ) + .await? + } else { + registry + .find_and_load_skill_for_workspace( + skill_name, + None, + context.agent_type.as_deref(), + ) + .await? + } + } + } else { + if use_stable_key { registry - .find_and_load_skill_for_remote_workspace( + .find_and_load_skill_by_key_for_workspace( skill_name, - ws_fs, - &root, + context.workspace_root(), context.agent_type.as_deref(), ) .await? @@ -221,19 +261,11 @@ impl Tool for SkillTool { registry .find_and_load_skill_for_workspace( skill_name, - None, + context.workspace_root(), context.agent_type.as_deref(), ) .await? } - } else { - registry - .find_and_load_skill_for_workspace( - skill_name, - context.workspace_root(), - context.agent_type.as_deref(), - ) - .await? }; let location_str = match skill_data.location { @@ -242,13 +274,15 @@ impl Tool for SkillTool { }; let result_for_assistant = format!( - "Skill '{}' loaded successfully. Note: any paths mentioned in this skill are relative to {}, not the workspace.\n\n{}", - skill_data.name, skill_data.path, skill_data.content + "Skill '{}' loaded successfully from stable key '{}'. Note: any paths mentioned in this skill are relative to {}, not the workspace.\n\n{}", + skill_data.name, skill_data.key, skill_data.path, skill_data.content ); let result = ToolResult::Result { data: json!({ "skill_name": skill_data.name, + "skill_key": skill_data.key, + "source_slot": skill_data.source_slot, "description": skill_data.description, "location": location_str, "content": skill_data.content, @@ -450,6 +484,41 @@ Use the remote project skill. .contains("# /cso")); } + #[tokio::test] + async fn stable_key_loads_the_exact_builtin_skill() { + let context = crate::agentic::tools::framework::ToolUseContext { + tool_call_id: None, + agent_type: Some("Cowork".to_string()), + session_id: None, + dialog_turn_id: None, + workspace: None, + unlocked_collapsed_tools: Vec::new(), + custom_data: Default::default(), + computer_use_host: None, + runtime_tool_restrictions: Default::default(), + runtime_handles: bitfun_runtime_ports::ToolRuntimeHandles::new(None, None), + }; + + let results = SkillTool::new() + .call_impl( + &json!({ "command": "user::bitfun-system::ppt-design" }), + &context, + ) + .await + .expect("stable key should load BitFun's built-in ppt-design skill"); + + let ToolResult::Result { data, .. } = &results[0] else { + panic!("expected result payload"); + }; + assert_eq!(data["skill_name"], "ppt-design"); + assert_eq!(data["skill_key"], "user::bitfun-system::ppt-design"); + assert_eq!(data["source_slot"], "bitfun-system"); + assert!(data["content"] + .as_str() + .unwrap_or_default() + .contains("references/editable-pptx.md")); + } + struct OrderingRemoteFs; #[async_trait] diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/skills/registry.rs b/src/crates/assembly/core/src/agentic/tools/implementations/skills/registry.rs index b1d811a00..0d0855f04 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/skills/registry.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/skills/registry.rs @@ -909,6 +909,41 @@ impl SkillRegistry { Ok(data) } + pub async fn find_and_load_skill_by_key_for_workspace( + &self, + skill_key: &str, + workspace_root: Option<&Path>, + agent_type: Option<&str>, + ) -> BitFunResult { + let candidates = self + .scan_skill_candidates_for_workspace(workspace_root) + .await; + let filtered = self + .apply_mode_filters_for_workspace(candidates, workspace_root, agent_type) + .await; + let info = filtered + .into_iter() + .map(|candidate| candidate.info) + .find(|skill| skill.key == skill_key) + .ok_or_else(|| { + BitFunError::tool(format!( + "Skill key '{}' was not found or is disabled for this mode", + skill_key + )) + })?; + + let skill_md_path = PathBuf::from(&info.path).join("SKILL.md"); + let content = fs::read_to_string(&skill_md_path) + .await + .map_err(|error| BitFunError::tool(format!("Failed to read skill file: {}", error)))?; + + let mut data = SkillData::from_markdown(info.path.clone(), &content, info.level, true)?; + data.key = info.key; + data.source_slot = info.source_slot; + data.dir_name = info.dir_name; + Ok(data) + } + pub async fn find_and_load_skill_for_remote_workspace( &self, skill_name: &str, @@ -933,6 +968,38 @@ impl SkillRegistry { Ok(data) } + pub async fn find_and_load_skill_by_key_for_remote_workspace( + &self, + skill_key: &str, + fs: &dyn WorkspaceFileSystem, + remote_root: &str, + agent_type: Option<&str>, + ) -> BitFunResult { + let candidates = self + .scan_skill_candidates_for_remote_workspace(fs, remote_root) + .await; + let filtered = self + .apply_mode_filters_for_remote_workspace(candidates, fs, remote_root, agent_type) + .await; + let info = filtered + .into_iter() + .map(|candidate| candidate.info) + .find(|skill| skill.key == skill_key) + .ok_or_else(|| { + BitFunError::tool(format!( + "Skill key '{}' was not found or is disabled for this mode", + skill_key + )) + })?; + + let content = Self::read_skill_md_for_remote_merge(&info, fs).await?; + let mut data = SkillData::from_markdown(info.path.clone(), &content, info.level, true)?; + data.key = info.key; + data.source_slot = info.source_slot; + data.dir_name = info.dir_name; + Ok(data) + } + pub async fn get_resolved_skills_xml_for_workspace( &self, workspace_root: Option<&Path>, diff --git a/src/crates/assembly/core/src/agentic/tools/pipeline/tool_pipeline.rs b/src/crates/assembly/core/src/agentic/tools/pipeline/tool_pipeline.rs index 1e09dc56e..33b2f94d4 100644 --- a/src/crates/assembly/core/src/agentic/tools/pipeline/tool_pipeline.rs +++ b/src/crates/assembly/core/src/agentic/tools/pipeline/tool_pipeline.rs @@ -24,9 +24,9 @@ use bitfun_agent_tools::{ build_invalid_tool_call_error_message, build_tool_call_truncation_recovery_notice, build_tool_execution_error_presentation, build_user_steering_interrupted_presentation, render_tool_result_for_assistant, truncate_raw_tool_arguments_preview, - truncate_tool_arguments_preview, validate_tool_execution_admission, ToolCallLoopDecision, - ToolCallLoopHistory, ToolExecutionAdmissionRejection, ToolExecutionAdmissionRequest, - GET_TOOL_SPEC_TOOL_NAME, USER_STEERING_INTERRUPTED_MESSAGE, + truncate_tool_arguments_preview, validate_tool_execution_admission, + ToolExecutionAdmissionRejection, ToolExecutionAdmissionRequest, GET_TOOL_SPEC_TOOL_NAME, + USER_STEERING_INTERRUPTED_MESSAGE, }; use dashmap::DashMap; use futures::future::join_all; @@ -257,10 +257,6 @@ pub struct ToolPipeline { confirmation_channels: Arc>>, /// Cancellation token management (tool_id -> CancellationToken) cancellation_tokens: Arc>, - /// Per-session ring buffer of recent tool calls for loop detection. - /// Keyed by session_id; entries store (tool_name, arguments) so that - /// "same tool with deep-equal arguments" can be recognized across rounds. - recent_tool_calls: Arc>, computer_use_host: Option, } @@ -275,31 +271,10 @@ impl ToolPipeline { state_manager, confirmation_channels: Arc::new(DashMap::new()), cancellation_tokens: Arc::new(DashMap::new()), - recent_tool_calls: Arc::new(DashMap::new()), computer_use_host, } } - fn check_and_record_tool_call( - &self, - session_id: &str, - tool_name: &str, - arguments: &serde_json::Value, - ) -> ToolCallLoopDecision { - let mut entry = self - .recent_tool_calls - .entry(session_id.to_string()) - .or_default(); - entry.value_mut().check_and_record(tool_name, arguments) - } - - /// Drop the loop-detection history for a session that is ending. Bounded - /// memory either way (max 10 entries per session) but this prevents - /// long-lived processes from accumulating stale sessions. - pub fn clear_session_tool_call_history(&self, session_id: &str) { - self.recent_tool_calls.remove(session_id); - } - pub fn computer_use_host(&self) -> Option { self.computer_use_host.clone() } @@ -584,36 +559,9 @@ impl ToolPipeline { return Err(BitFunError::Validation(error_msg)); } - // Loop detection: refuse to execute the same tool call repeatedly with - // identical arguments. Triggered on the (THRESHOLD + 1)-th consecutive - // identical call within the per-session sliding window. - if let ToolCallLoopDecision::Blocked(block) = - self.check_and_record_tool_call(&task.context.session_id, &tool_name, &tool_args) - { - let error_msg = block.message; - warn!( - "Tool-call loop blocked: tool_name={}, tool_id={}, session_id={}, threshold={}", - tool_name, tool_id, task.context.session_id, block.threshold - ); - - self.state_manager - .update_state( - &tool_id, - ToolExecutionState::Failed { - error: error_msg.clone(), - is_retryable: false, - duration_ms: None, - queue_wait_ms: None, - preflight_ms: None, - confirmation_wait_ms: None, - execution_ms: None, - }, - ) - .await; - - return Err(BitFunError::Validation(error_msg)); - } - + // Repetition alone is not execution failure: polling and status checks + // may legitimately reuse identical arguments. The execution engine + // evaluates repeated patterns only after observing actual tool results. if let Err(err) = validate_tool_execution_admission(ToolExecutionAdmissionRequest { tool_name: &tool_name, allowed_tools: &task.context.allowed_tools, diff --git a/src/crates/contracts/product-domains/src/miniapp/builtin.rs b/src/crates/contracts/product-domains/src/miniapp/builtin.rs index 2c4857d5d..36a68370e 100644 --- a/src/crates/contracts/product-domains/src/miniapp/builtin.rs +++ b/src/crates/contracts/product-domains/src/miniapp/builtin.rs @@ -1,4 +1,8 @@ //! Built-in MiniApp bundle contracts and pure seed policy. +//! +//! Seed skip requires both a matching content hash and an installed marker version +//! that is at least the bundled version. Do not hardcode bundle version numbers in +//! tests — bumping a MiniApp version should not require shotgun edits across tests. use crate::miniapp::storage::{ build_package_json, ESM_DEPS_JSON, INDEX_HTML, STYLE_CSS, UI_JS, WORKER_JS, @@ -108,7 +112,7 @@ pub const BUILTIN_APPS: &[BuiltinMiniAppBundle] = &[ }, BuiltinMiniAppBundle { id: "builtin-ppt-live", - version: 150, + version: 167, meta_json: include_str!("builtin/assets/ppt-live/meta.json"), html: include_str!("builtin/assets/ppt-live/index.html"), css: include_str!("builtin/assets/ppt-live/style.css"), @@ -252,6 +256,9 @@ fn hex_encode(bytes: &[u8]) -> String { #[cfg(test)] mod tests { + // Do not assert hardcoded BUILTIN_APPS[i].version or meta["version"] values here. + // Version bumps should only touch bundle registration and seed runtime, not tests. + use super::{builtin_content_hash, BUILTIN_APPS}; #[test] @@ -269,11 +276,6 @@ mod tests { "builtin-ppt-live", ] ); - assert_eq!(BUILTIN_APPS[0].version, 11); - assert_eq!(BUILTIN_APPS[1].version, 21); - assert_eq!(BUILTIN_APPS[2].version, 16); - assert_eq!(BUILTIN_APPS[3].version, 28); - assert_eq!(BUILTIN_APPS[4].version, 3); for app in BUILTIN_APPS { assert!(!app.meta_json.trim().is_empty()); @@ -293,24 +295,87 @@ mod tests { .expect("PPT Live should be registered"); let meta: serde_json::Value = serde_json::from_str(app.meta_json).expect("PPT Live metadata should be valid"); + let bundle: serde_json::Value = + serde_json::from_str(include_str!("builtin/assets/ppt-live/bundle.json")) + .expect("PPT Live bundle metadata should be valid"); + assert_eq!(meta["version"].as_u64(), Some(u64::from(app.version))); + assert_eq!(bundle["version"].as_u64(), Some(u64::from(app.version))); assert_eq!(meta["permissions"]["node"]["enabled"], false); - assert_eq!(meta["permissions"]["ai"]["enabled"], true); - assert_eq!(meta["permissions"]["ai"]["allowed_models"][0], "primary"); + assert_eq!(meta["permissions"]["ai"]["enabled"], false); assert_eq!(meta["permissions"]["agent"]["enabled"], true); - assert_eq!(meta["permissions"]["net"]["allow"][0], "*"); + assert_eq!(meta["permissions"]["agent"]["rate_limit_per_minute"], 120); + // Research happens inside hidden agent turns (WebSearch/WebFetch via + // the agent permission); the app itself no longer fetches URLs. + assert_eq!( + meta["permissions"]["net"]["allow"].as_array().map(Vec::len), + Some(0) + ); assert!(app.ui_js.contains("Unsupported PPT Live action")); - assert!(app - .ui_js - .contains("presentation design engine embedded in BitFun")); + // Render, audit, and continuation turns reuse the hidden planning + // session and its pinned skill-derived project contract. The + // bundle is minified, so structural checks read the source. + let adapter_source = include_str!("builtin/assets/ppt-live/src/bitfun-backend-adapter.js"); + assert!(adapter_source.contains("sessionId: options.sessionId")); + assert!(adapter_source.contains("user::bitfun-system::ppt-design")); + assert!(adapter_source.contains("references/editable-pptx.md")); + assert!(adapter_source.contains("references/slide-decks.md")); + assert!(adapter_source.contains("buildRepairPrompt")); + assert!(adapter_source.contains("buildAuditPrompt")); + assert!(adapter_source.contains("AUTOMATIC COMPLETION CONTINUATION")); + assert!(adapter_source.contains("buildAuditVerificationFeedback")); + assert!(adapter_source.contains("do not merely explain what remains")); + assert!(adapter_source.contains("quality-report.json")); + assert!(!adapter_source.contains("app.ai")); + assert!(!adapter_source.contains("installFallbackBackend")); + assert!(app.ui_js.contains("SAME deck Agent Session")); + assert!(app.ui_js.contains("interrupted before it finished")); + assert!(app.ui_js.contains("Unknown MiniApp agent session")); + // Staged generation follows the ppt-design skill's native file + // protocol: the agent works inside a deck project directory under the + // app's appdata storage, writes project.json and slides/slide-NN.html, + // and ui.js reads the files back instead of parsing giant JSON text. + assert!(adapter_source.contains("protocol: 'files'")); + assert!(adapter_source.contains("appDataWorkspace: options.appDataWorkspace")); + assert!(app.ui_js.contains("project.json")); + assert!(app.ui_js.contains("slides/slide-")); + let ui_source = include_str!("builtin/assets/ppt-live/ui.js"); + assert!(ui_source.contains("backendUsesFileProtocol")); + assert!(ui_source.contains("tryReadDeckSlideFile")); + assert!(meta["permissions"]["fs"]["read"] + .as_array() + .is_some_and(|scopes| scopes.iter().any(|scope| scope == "{appdata}"))); + assert!(meta["permissions"]["fs"]["write"] + .as_array() + .is_some_and(|scopes| scopes.iter().any(|scope| scope == "{appdata}"))); assert!(!app.ui_js.contains("Sparo")); assert!( include_str!("builtin/assets/ppt-live/ui.js").contains("installBitFunBackendAdapter") ); - assert!( - include_str!("builtin/assets/ppt-live/src/bitfun-backend-adapter.js") - .contains("app.ai") - ); + assert!(!meta["permissions"]["ai"]["enabled"] + .as_bool() + .unwrap_or(true)); + assert!(adapter_source.contains("data-information-visualization.md")); + assert!(adapter_source.contains("references/content-guidelines.md")); + assert!(adapter_source.contains("comparisons -> tables/matrices")); + // The standalone fallback render prompt (used when the planning + // session is lost) must reload the design skill itself. + assert!(app.ui_js.contains("user::bitfun-system::ppt-design")); + let ppt_live_source = include_str!("builtin/assets/ppt-live/ui.js"); + assert!(ppt_live_source.contains("for (const slidePlan of renderPlans)")); + assert!(ppt_live_source.contains("validateSlideForPptxGeneration")); + assert!(ppt_live_source.contains("planningEvidenceIssues")); + assert!(ppt_live_source.contains("runFinalDeckAudit")); + assert!(ppt_live_source.contains("completedById")); + assert!(ppt_live_source.contains("quality-report.json")); + assert!(ppt_live_source.contains("PPT_BACKEND_CONTINUATION_MAX_ATTEMPTS")); + assert!(ppt_live_source.contains("completionRecoveryInput")); + assert!(ppt_live_source.contains("inspectDeckJsonFile")); + assert!(ppt_live_source.contains("auditWriteEvidenceIssues")); + assert!(ppt_live_source.contains("recoveryExhaustedError")); + assert!(!ppt_live_source.contains("PPT_PARALLEL_SLIDE_WORKERS")); + assert!(!ppt_live_source.contains("runWithConcurrencyLimit")); + assert!(!ppt_live_source.contains("enrichSources(state)")); assert!(app.html.contains("exportPptx")); assert!(!app.html.contains("src=\"./ui.js\"")); assert!(!app.html.contains("href=\"./style.css\"")); diff --git a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/build-bitfun.mjs b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/build-bitfun.mjs index 5b91ad427..50e8456dd 100644 --- a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/build-bitfun.mjs +++ b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/build-bitfun.mjs @@ -1,12 +1,14 @@ import { build } from 'esbuild'; +import { readFile, writeFile } from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; import path from 'node:path'; const appDir = path.dirname(fileURLToPath(import.meta.url)); +const outfile = path.join(appDir, 'dist', 'ui.bundle.js'); await build({ entryPoints: [path.join(appDir, 'ui.js')], - outfile: path.join(appDir, 'dist', 'ui.bundle.js'), + outfile, bundle: true, format: 'esm', platform: 'browser', @@ -14,3 +16,8 @@ await build({ minify: true, legalComments: 'none', }); + +// pdf-lib emits a template literal whose meaningful space lands at end-of-line. +// Keep the PDF xref bytes unchanged while avoiding trailing whitespace in source. +const bundledSource = await readFile(outfile, 'utf8'); +await writeFile(outfile, bundledSource.replaceAll('` \n`', '" \\n"')); diff --git a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/bundle.json b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/bundle.json index 9d4f86c24..f7815fc4e 100644 --- a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/bundle.json +++ b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/bundle.json @@ -1,5 +1,5 @@ { "schemaVersion": 1, "id": "builtin-ppt-live", - "version": 153 + "version": 167 } diff --git a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/dist/ui.bundle.js b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/dist/ui.bundle.js index 9954c1ebf..5f9946902 100644 --- a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/dist/ui.bundle.js +++ b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/dist/ui.bundle.js @@ -1,79 +1,79 @@ -var Ln=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Yo={"en-US":{eyebrow:"AI Deck Studio",title:"PPT Live",newDeck:"New",newTopic:"New topic",blankDeckTitle:"Untitled deck",blankDeckReady:"Blank deck ready.",clusterDraft:"Draft",clusterReview:"Review",clusterExport:"Export",generateOutline:"Outline",generateDeck:"Generate deck",preview:"Preview",exportHtml:"HTML",exportPptx:"PPTX",workflowPrompt:"Prompt",workflowGenerate:"Generate",workflowEdit:"Edit",workflowExport:"Export",slidesPanelTitle:"Slides",slidesPanelSubcopy:"Click a page to edit text directly on canvas.",agentCommandTitle:"Create or edit by prompt",agentCommandSubcopy:"Generate a deck, revise one page, edit the whole deck, insert, or delete.",briefTitle:"Brief",agentRequestTitle:"What should this deck say?",oneBoxTitle:"Describe the deck. Then keep editing by prompt.",oneBoxSubtitle:"One command box handles drafting, page edits, deck edits, insertion, and deletion.",oneBoxPlaceholder:"Example: Build a 10-page AI product strategy deck for executives. Later: make this page more visual, rewrite the whole deck for investors, insert a risk page, or delete this page.",sendPrompt:"Send",promptRequired:"Type what you want PPT Live to do.",topicLabel:"Goal",topicPlaceholder:"Describe the deck you want. Mention page count or URLs only when you need them.",audienceLabel:"Audience",audiencePlaceholder:"Executives, customers, students...",slidesLabel:"Slides",deckTypeLabel:"Deck type",deckTypeStrategy:"Strategy",deckTypeSales:"Sales pitch",deckTypeReport:"Business report",deckTypeTeaching:"Teaching",deckTypeFundraising:"Fundraising",toneLabel:"Tone",toneExecutive:"Executive",toneConcise:"Concise",tonePersuasive:"Persuasive",toneEducational:"Educational",materialLabel:"Source material",materialPlaceholder:"Paste notes, article excerpts, data points, meeting notes, or rough slide requirements.",advancedBrief:"Optional context",processTitle:"Generation process",processSubcopy:"Track the current deck build at a glance.",historyTitle:"History",historySubcopy:"Restore a deck session and continue editing.",historyEmpty:"Generated decks and edits will appear here.",historyMeta:"{{count}} slides \xB7 {{time}}",historyRestored:"Deck session restored.",stopGeneration:"Stop",generationStopped:"Generation stopped. Kept the current view.",generationTimedOut:"Generation took too long, so PPT Live stopped this run.",generationDraftReady:"Preparing the final slides\u2026",generationAgentWorking:"Building your presentation\u2026",backendGenerationFailed:"Generation did not finish. Please retry, or stop and start a new topic.",backendGenerationFailedWithReason:"Generation did not finish: {{reason}}",generationRoundBudgetFailed:"Generation ran out of steps before the deck was ready.",generationRoundBudgetHint:"Try a shorter prompt, fewer pages, or remove extra reference links, then send again.",generationRetrying:"Generation hit an error; retrying automatically ({{attempt}}/{{max}})\u2026",generationRetryAttempt:"Retry attempt {{attempt}}/{{max}}.",agentOnlyRetryHint:"Check your connection and try again in a moment.",generationPlanPhase:"Stage 1/2 \xB7 Research and slide planning",generationPlanningSlides:"Writing per-slide briefs\u2026",generationPlanProgress:"Planning in progress: {{count}} slide briefs written\u2026",generationPlanReady:"Plan ready: {{count}} slides outlined.",generationPlanRetry:"Planning hit an error; retrying the planning stage only ({{attempt}}/{{max}})\u2026",generationSlidesPhase:"Stage 2/2 \xB7 Rendering {{count}} slides in {{batches}} batches, {{workers}} in parallel",generationSlideReady:"Slide {{slide}}/{{total}} ready.",generationBatchRetry:"Batch {{batch}} hit an error; retrying its unfinished slides only ({{attempt}}/{{max}})\u2026",generationResumeFrom:"Resuming from slide {{slide}} \u2014 finished slides are kept.",generationPartialDeck:"Slides {{missing}} did not finish. The finished slides are kept \u2014 send a follow-up prompt to fill the missing pages.",agentWorkingTitle:"Building your deck",agentWorkingKicker:"In progress",agentWorkingClaim:"Your slides will appear in the canvas when generation finishes.",agentWorkingProof:"Progress",agentWorkingDetail:"This is a live preview area while your deck is being created.",agentWorkingSourceNote:"Content is generated from your prompt.",agentWorkingMetric:"Live",agentWorkingMetricLabel:"Waiting for slides",processEventStarted:"Generation started.",processEventWaiting:"Getting ready\u2026",processEventRound:"Organizing structure and copy.",processEventTool:"Reading sources and applying design rules.",processEventText:"Drafting slide layouts.",processEventDone:"Deck received.",generationParsingDeck:"Loading slides into the editor\u2026",processWaitingForEventsTitle:"Ready to generate",processWaitingForEvents:"Send a prompt to start. Progress will show up here.",processEventUnknown:"Update",eventTurnStarted:"Generation started",eventTurnFailed:"Generation failed",eventTurnCancelled:"Generation cancelled",eventRoundCompleted:"Step completed",eventThinkingChunk:"Thinking stream",eventTokenUsage:"Token usage updated",eventUnknownTool:"tool",eventToolDetected:"Detected tool",eventToolParams:"Reading tool input",eventToolQueued:"Queued tool",eventToolWaiting:"Waiting for tool",eventToolStarted:"Started tool",eventToolProgress:"Tool progress",eventToolStreaming:"Tool streaming",eventToolStreamChunk:"Tool output chunk",eventToolConfirmation:"Tool needs confirmation",eventToolConfirmed:"Tool confirmed",eventToolRejected:"Tool rejected",eventToolCompleted:"Completed tool",eventToolFailed:"Tool failed",eventToolCancelled:"Tool cancelled",eventToolQueuePosition:"queue",eventToolSkillName:"PPT design skill",eventToolWebSearchName:"Web search",eventToolWebFetchName:"Web page fetch",eventToolSkillReady:"Design skill loaded",generationProgressPulse:"Still generating\u2026",generationPageProgress:"Generating page {{current}}",generationSlideProgress:"{{count}} slides drafted",generationStepBrief:"Assumptions",generationStepBriefDetail:"Read the prompt and plan the deck.",generationStepSpine:"Outline",generationStepSpineDetail:"Create assertion-led slide titles from the request.",generationStepProof:"Slide copy",generationStepProofDetail:"Ground each page in source facts or clear assumptions.",generationStepDesign:"Visual design",generationStepDesignDetail:"Apply theme, layout, and visual hierarchy.",generationStepCompile:"Load slides",generationStepCompileDetail:"Load the generated deck into the editor.",generationReadingBrief:"Reading your prompt...",generationWritingClaims:"Building the outline...",generationChoosingProof:"Writing slide copy...",generationDesigningLayouts:"Designing slide layouts...",generationCompiled:"Your deck is ready.",generationSpineReady:"Claim spine ready.",generationLocalSpine:"Generation is unavailable. Please try again later.",generationLocalCompiler:"Generation is unavailable. Please try again later.",agentPlanning:"Planning the deck task...",agentPlanningFallback:"Planning is unavailable. Please try again.",outlineTitle:"Outline",outlineSubcopy:"Review the story spine before the deck is composed.",addOutlineItem:"Add outline item",syncOutline:"Sync slides from outline",modeEdit:"Edit",modeSort:"Sort",modePresent:"Present",inspectorTitle:"Inspector",addText:"Text",addList:"List",addShape:"Shape",addMetric:"Metric",addChart:"Chart",addMedia:"Media",addSlide:"Add slide",deleteSlide:"Delete slide",deleteElement:"Delete element",aiTitle:"AI design",aiSubcopy:"Prompt the agent to revise one page, the whole deck, or add a page.",instructionPlaceholder:"Example: make this page more visual, add a competition page, rewrite the whole deck for investors, or delete repetition.",reviseSlide:"Revise this page",reviseDeck:"Revise all",insertSlide:"Insert page",aiRewrite:"Rewrite",aiCondense:"Condense",aiProfessional:"Professional",aiMoreVisual:"More visual",aiNotes:"Speaker notes",aiRedesign:"Redesign slide",aiRestyleDeck:"Restyle deck",styleTitle:"Style",themeLabel:"Theme",themeExecutive:"Executive",themeMarket:"Market",themeMinimal:"Minimal",themeStudio:"Studio",densityLabel:"Density",densityCompact:"Compact",densityStandard:"Standard",densitySpacious:"Spacious",brandPrimaryLabel:"Primary",brandAccentLabel:"Accent",imagePolicyLabel:"Image policy",imagePolicyPlaceholders:"Editable placeholders",imagePolicyNone:"No images",ready:"Ready.",statusPillReady:"Ready",statusPillBusy:"AI",exportReady:"HTML and PPTX export ready after generation.",working:"Working with AI...",outlineReady:"Outline ready. Edit it, then generate the designed deck.",deckReady:"Designed deck generated.",aiUnavailable:"Generation is unavailable right now. Please try again later.",sourceGroundingRequired:"Source could not be verified. Generated a verification-first deck instead of inventing facts.",saved:"Saved.",slideUpdated:"Slide updated.",deckUpdated:"Deck updated.",slideInserted:"Page inserted.",deckRestyled:"Deck restyled.",cannotDelete:"Keep at least one slide.",noSelection:"Select a slide object to edit its content and layout.",elementTypeLabel:"Type",elementTextLabel:"Text",elementItemsLabel:"Items",elementDataLabel:"Chart data",geometryLabel:"Geometry",styleLabel:"Style",speakerNotesLabel:"Speaker notes",kickerLabel:"Kicker",claimLabel:"Claim",proofObjectLabel:"Proof object",supportNoteLabel:"Support note",sourceNoteLabel:"Source note",newSlideTitle:"New slide",defaultDeckTitle:"AI Product Strategy",slidesMeta:"{{count}} slides",exportHtmlDone:"HTML deck downloaded.",exportHtmlWorking:"Exporting HTML...",exportHtmlFailed:"HTML export failed:",exportSavedTo:"Exported to {{path}}",exportPptxWorking:"Rendering editable PPTX...",exportPptxDone:"Editable PPTX downloaded.",exportPptxFailed:"PPTX export failed:",exportPdfWorking:"Rendering PDF...",exportPdfDone:"PDF downloaded.",exportPdfFailed:"PDF export failed:",exportPngWorking:"Rendering PNG slides...",exportPngDone:"PNG slide archive downloaded.",exportPngFailed:"PNG export failed:",exportDeckEmpty:"Generate slides before exporting.",slidesEmptyHint:"Slides appear here after generation.",welcomeTitle:"Describe your deck to get started",welcomeSubcopy:"One prompt creates the outline, designed slides, and an editable deck you can refine page by page.",welcomeTip1:"10-page strategy deck",welcomeTip2:"Investor pitch rewrite",welcomeTip3:"Make this page more visual",deleteSlideDefaultPrompt:"Delete the current slide and keep the deck coherent.",prev:"Previous",next:"Next",assistantHello:"Describe the deck you need. I will build an outline first, then turn it into editable slides.",aiChatApplied:"I applied the instruction to the current slide.",localMetricLabel:"signal to remember",mediaPlaceholder:"Image placeholder",slidesUnit:"slides",closeConfirm:"Confirm the direction",closeOwner:"Choose the owner",closeIteration:"Start the next iteration",pointClaimPrefix:"Claim:",pointProofPrefix:"Proof object:",pointAudiencePrefix:"Audience relevance:",pointEvidenceRule:"Evidence rule: mark assumptions clearly",pointDesignRule:"Design rule: one visual plus one support rail",pointCloseRule:"Close: name the next action",claimCover:"{{topic}} needs a clear decision narrative, not another collection of slides.",claimPressure:"{{title}} is the pressure point the audience must resolve.",claimDecision:"{{title}} changes the decision because it connects evidence to action.",claimProof:"{{title}} becomes credible when the proof object carries the argument.",claimAction:"{{title}} should end with one named decision, owner, or next move.",supportWithSource:"Use the supplied source material to substantiate this claim; make the {{proof}} the dominant evidence.",supportWithAssumption:"Add one concrete example or metric so the {{proof}} can support the claim without filler.",sourceUserMaterial:"Source: user-provided material",sourceDraftAssumption:"Source: draft assumption; verify before external use",defaultSpeakerNote:'Open with the conclusion for "{{title}}", then support it with one concrete example.',proofMarketMap:"market map",proofOperatingModel:"operating model",proofRiskBridge:"risk bridge",proofDecisionTable:"decision table",proofBeforeAfter:"before/after workflow",proofValueBridge:"value bridge",proofCustomerProof:"customer proof",proofImplementationPlan:"implementation plan",proofMetricBridge:"metric bridge",proofTrendChart:"trend chart",proofSourceSummary:"source summary",proofVerificationPlan:"verification plan",proofCapabilityMatrix:"capability matrix",proofEvidenceList:"evidence list",proofVarianceTable:"variance table",proofRiskRegister:"risk register",proofConceptMap:"concept map",proofWorkedExample:"worked example",proofComparison:"comparison",proofPracticePrompt:"practice prompt",proofMarketWedge:"market wedge",proofProductDiagram:"product diagram",proofTractionChart:"traction chart",proofMilestonePlan:"milestone plan",proofVisualProof:"visual proof",sourceManualTitle:"User brief",sourceDigestTitle:"Source digest",sourceFetchFailed:"Could not read URL: {{url}}",sourceMissingWarning:"No source material was provided. Treat content as a draft, not verified facts.",sourceFetchedNote:"Sources: {{count}} fetched URL(s)",bpContextTitle:"{{topic}} must be grounded in source facts before claims are made.",bpSourceNeededTitle:"{{topic}} needs source material before factual claims can be made.",bpProblemTitle:"The current question is what the audience can safely believe.",bpSolutionTitle:"{{topic}} should be explained through capabilities, workflow, and evidence.",bpWorkflowTitle:"The workflow shows how the product creates value step by step.",bpProofTitle:"Source-backed evidence should carry the credibility of the deck.",bpVerificationTitle:"Verification gaps must be visible instead of hidden behind fake charts.",bpRiskTitle:"The main risk is overclaiming beyond the available source material.",bpDecisionTitle:"The next step is to verify the claims and choose the strongest story path.",bpSupportSource:"Built from fetched or pasted source material; verify exact wording before external use.",bpSupportMissing:"Source material is insufficient; keep this slide as a verification prompt.",bpMissingFact1:"Paste source notes, a README, metrics, or product description to ground this slide.",bpMissingFact2:"Do not use invented metrics; replace placeholders with verified evidence.",bpMissingFact3:"Use this page to decide what needs to be researched next.",qualityOutOfBounds:"An element extends outside the slide safe area.",qualityTextDense:"Visible text may be too dense for this layout.",qualityChartUngrounded:"Chart data was removed or flagged because it is not grounded in source numbers.",qualityOverlap:"Text or chart elements may overlap.",qualityMissingClaim:"This slide needs one clear claim.",qualityReportTitle:"Quality report",qualityNeedsReview:"Review required",qualityHasWarnings:"Quality warning",exportFormatUnavailable:"This export format is not available yet.",exportTitle:"Export",exportCancel:"Cancel",exportConfirm:"Export file",exportPreviewPrevAria:"Previous slide",exportPreviewNextAria:"Next slide",exportFormat:"Format",exportQuality:"Quality",exportDpi:"Image DPI",exportRange:"Slide range",exportShare:"Share",propertiesStyle:"Style",propertiesLayout:"Layout",propertiesAnimation:"Animation",propertiesThemeColor:"Theme color",propertiesFont:"Font",propertiesColorMode:"Slide colors",propertiesStylePreset:"Style preset",colorModeLight:"Light",colorModeDark:"Dark",fontSansSerif:"Sans-serif",fontSerif:"Serif",propertiesDensity:"Density",propertiesSmartAlign:"Smart align",propertiesPageTransition:"Page transition",propertiesElementAnimation:"Element animation",densityLoose:"Loose"},"zh-CN":{eyebrow:"AI \u6F14\u793A\u5DE5\u574A",title:"PPT Live",newDeck:"\u65B0\u5EFA",newTopic:"\u65B0\u4E3B\u9898",blankDeckTitle:"\u672A\u547D\u540D PPT",blankDeckReady:"\u7A7A\u767D PPT \u5DF2\u5C31\u7EEA\u3002",clusterDraft:"\u521B\u4F5C",clusterReview:"\u5BA1\u9605",clusterExport:"\u4EA4\u4ED8",generateOutline:"\u751F\u6210\u5927\u7EB2",generateDeck:"\u751F\u6210\u6574\u5957",preview:"\u6F14\u793A\u9884\u89C8",exportHtml:"\u5BFC\u51FA HTML",exportPptx:"\u5BFC\u51FA PPTX",workflowPrompt:"\u8F93\u5165",workflowGenerate:"\u751F\u6210",workflowEdit:"\u7F16\u8F91",workflowExport:"\u5BFC\u51FA",slidesPanelTitle:"\u9875\u9762",slidesPanelSubcopy:"\u70B9\u51FB\u9875\u9762\u540E\uFF0C\u53EF\u76F4\u63A5\u5728\u753B\u5E03\u4E0A\u6539\u6587\u5B57\u3002",agentCommandTitle:"\u7528 Prompt \u751F\u6210\u6216\u4FEE\u6539",agentCommandSubcopy:"\u751F\u6210\u6574\u5957 PPT\u3001\u4FEE\u6539\u5355\u9875\u3001\u5168\u5C40\u6539\u5199\u3001\u63D2\u5165\u6216\u5220\u9664\u9875\u9762\u3002",briefTitle:"\u521B\u4F5C\u7B80\u62A5",agentRequestTitle:"\u4F60\u60F3\u505A\u4E00\u4EFD\u4EC0\u4E48 PPT\uFF1F",oneBoxTitle:"\u63CF\u8FF0 PPT\uFF0C\u7136\u540E\u7EE7\u7EED\u7528 Prompt \u4FEE\u6539",oneBoxSubtitle:"\u9996\u7A3F\u3001\u6539\u5355\u9875\u3001\u6539\u6574\u5957\u3001\u63D2\u5165\u548C\u5220\u9664\uFF0C\u90FD\u7531\u8FD9\u4E00\u4E2A\u8F93\u5165\u6846\u5904\u7406\u3002",oneBoxPlaceholder:"\u4F8B\u5982\uFF1A\u4E3A\u9AD8\u7BA1\u751F\u6210 10 \u9875 AI \u4EA7\u54C1\u6218\u7565 PPT\u3002\u4E4B\u540E\u53EF\u4EE5\u5199\uFF1A\u628A\u672C\u9875\u6539\u5F97\u66F4\u89C6\u89C9\u5316\u3001\u6574\u5957\u6539\u6210\u6295\u8D44\u4EBA\u7248\u672C\u3001\u63D2\u5165\u4E00\u9875\u98CE\u9669\u5206\u6790\u3001\u5220\u9664\u672C\u9875\u3002",sendPrompt:"\u53D1\u9001",promptRequired:"\u8BF7\u8F93\u5165\u4F60\u5E0C\u671B PPT Live \u505A\u4EC0\u4E48\u3002",topicLabel:"\u76EE\u6807",topicPlaceholder:"\u76F4\u63A5\u63CF\u8FF0\u4F60\u60F3\u8981\u7684\u6F14\u793A\u7A3F\uFF1B\u4EC5\u5728\u9700\u8981\u65F6\u8BF4\u660E\u9875\u6570\u6216\u53C2\u8003 URL\u3002",audienceLabel:"\u53D7\u4F17",audiencePlaceholder:"\u9AD8\u7BA1\u3001\u5BA2\u6237\u3001\u5B66\u751F\u3001\u56E2\u961F\u6210\u5458...",slidesLabel:"\u9875\u6570",deckTypeLabel:"\u7C7B\u578B",deckTypeStrategy:"\u6218\u7565\u65B9\u6848",deckTypeSales:"\u9500\u552E\u63D0\u6848",deckTypeReport:"\u4E1A\u52A1\u6C47\u62A5",deckTypeTeaching:"\u6559\u5B66\u8BFE\u4EF6",deckTypeFundraising:"\u878D\u8D44\u8DEF\u6F14",toneLabel:"\u8BED\u6C14",toneExecutive:"\u9AD8\u7BA1\u98CE",toneConcise:"\u7CBE\u7B80",tonePersuasive:"\u6709\u8BF4\u670D\u529B",toneEducational:"\u6559\u5B66\u578B",materialLabel:"\u7D20\u6750",materialPlaceholder:"\u7C98\u8D34\u7B14\u8BB0\u3001\u6587\u7AE0\u7247\u6BB5\u3001\u6570\u636E\u70B9\u3001\u4F1A\u8BAE\u8BB0\u5F55\u6216\u7C97\u7565\u9875\u9762\u8981\u6C42\u3002",advancedBrief:"\u53EF\u9009\u4E0A\u4E0B\u6587",processTitle:"\u751F\u6210\u8FC7\u7A0B",processSubcopy:"\u67E5\u770B\u5F53\u524D\u6F14\u793A\u7A3F\u7684\u751F\u6210\u8FDB\u5EA6\u3002",historyTitle:"\u5386\u53F2\u8BB0\u5F55",historySubcopy:"\u6062\u590D\u4E4B\u524D\u7684 PPT \u4F1A\u8BDD\uFF0C\u5E76\u7EE7\u7EED\u4FEE\u6539\u3002",historyEmpty:"\u751F\u6210\u548C\u4FEE\u6539\u8FC7\u7684 PPT \u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002",historyMeta:"{{count}} \u9875 \xB7 {{time}}",historyRestored:"\u5DF2\u6062\u590D PPT \u4F1A\u8BDD\u3002",stopGeneration:"\u505C\u6B62",generationStopped:"\u5DF2\u505C\u6B62\u751F\u6210\uFF0C\u4FDD\u7559\u5F53\u524D\u89C6\u56FE\u3002",generationTimedOut:"\u751F\u6210\u8017\u65F6\u8FC7\u957F\uFF0C\u672C\u6B21\u8FD0\u884C\u5DF2\u505C\u6B62\u3002",generationDraftReady:"\u6B63\u5728\u6574\u7406\u6700\u7EC8\u9875\u9762\u2026",generationAgentWorking:"\u6B63\u5728\u751F\u6210\u4F60\u7684\u6F14\u793A\u7A3F\u2026",backendGenerationFailed:"\u751F\u6210\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u6216\u505C\u6B62\u540E\u91CD\u65B0\u5F00\u59CB\u3002",backendGenerationFailedWithReason:"\u751F\u6210\u672A\u5B8C\u6210\uFF1A{{reason}}",generationRoundBudgetFailed:"\u751F\u6210\u6B65\u9AA4\u8FC7\u591A\uFF0C\u6F14\u793A\u7A3F\u5C1A\u672A\u5B8C\u6210\u3002",generationRoundBudgetHint:"\u53EF\u5C1D\u8BD5\u7F29\u77ED\u63CF\u8FF0\u3001\u51CF\u5C11\u9875\u6570\u6216\u53BB\u6389\u591A\u4F59\u53C2\u8003\u94FE\u63A5\uFF0C\u7136\u540E\u91CD\u65B0\u53D1\u9001\u3002",generationRetrying:"\u751F\u6210\u51FA\u73B0\u9519\u8BEF\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationRetryAttempt:"\u7B2C {{attempt}}/{{max}} \u6B21\u5C1D\u8BD5\u3002",agentOnlyRetryHint:"\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\uFF0C\u7A0D\u540E\u518D\u8BD5\u3002",generationPlanPhase:"\u9636\u6BB5 1/2 \xB7 \u7814\u7A76\u4E0E\u5168\u7BC7\u89C4\u5212",generationPlanningSlides:"\u6B63\u5728\u7F16\u5199\u6BCF\u9875\u5185\u5BB9\u7B80\u62A5\u2026",generationPlanProgress:"\u89C4\u5212\u8FDB\u884C\u4E2D\uFF1A\u5DF2\u5199\u5B8C {{count}} \u9875\u7B80\u62A5\u2026",generationPlanReady:"\u89C4\u5212\u5B8C\u6210\uFF1A\u5171 {{count}} \u9875\u3002",generationPlanRetry:"\u89C4\u5212\u9636\u6BB5\u51FA\u9519\uFF0C\u4EC5\u91CD\u8BD5\u89C4\u5212\u9636\u6BB5\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationSlidesPhase:"\u9636\u6BB5 2/2 \xB7 \u5171 {{batches}} \u6279\u6E32\u67D3 {{count}} \u9875\uFF0C{{workers}} \u8DEF\u5E76\u884C",generationSlideReady:"\u7B2C {{slide}}/{{total}} \u9875\u5DF2\u5B8C\u6210\u3002",generationBatchRetry:"\u6279\u6B21 {{batch}} \u51FA\u9519\uFF0C\u4EC5\u91CD\u8BD5\u672A\u5B8C\u6210\u7684\u9875\u9762\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationResumeFrom:"\u4ECE\u7B2C {{slide}} \u9875\u7EE7\u7EED\u751F\u6210\uFF0C\u5DF2\u5B8C\u6210\u7684\u9875\u9762\u4FDD\u7559\u3002",generationPartialDeck:"\u7B2C {{missing}} \u9875\u672A\u5B8C\u6210\u3002\u5DF2\u5B8C\u6210\u7684\u9875\u9762\u5DF2\u4FDD\u7559\uFF0C\u53EF\u7EE7\u7EED\u53D1\u9001\u6307\u4EE4\u8865\u5168\u7F3A\u5931\u9875\u3002",agentWorkingTitle:"\u6B63\u5728\u751F\u6210\u6F14\u793A\u7A3F",agentWorkingKicker:"\u751F\u6210\u4E2D",agentWorkingClaim:"\u5B8C\u6210\u540E\uFF0C\u6700\u7EC8\u9875\u9762\u4F1A\u51FA\u73B0\u5728\u4E2D\u95F4\u753B\u5E03\u3002",agentWorkingProof:"\u8FDB\u5EA6",agentWorkingDetail:"\u8FD9\u662F\u751F\u6210\u8FC7\u7A0B\u4E2D\u7684\u9884\u89C8\u533A\u57DF\u3002",agentWorkingSourceNote:"\u5185\u5BB9\u5C06\u6839\u636E\u4F60\u7684 Prompt \u81EA\u52A8\u751F\u6210\u3002",agentWorkingMetric:"Live",agentWorkingMetricLabel:"\u7B49\u5F85\u9875\u9762\u751F\u6210",processEventStarted:"\u5DF2\u5F00\u59CB\u751F\u6210\u3002",processEventWaiting:"\u51C6\u5907\u5F00\u59CB\u2026",processEventRound:"\u6B63\u5728\u7EC4\u7EC7\u5185\u5BB9\u4E0E\u7ED3\u6784\u3002",processEventTool:"\u6B63\u5728\u8BFB\u53D6\u7D20\u6750\u5E76\u5E94\u7528\u8BBE\u8BA1\u89C4\u5219\u3002",processEventText:"\u6B63\u5728\u64B0\u5199\u9875\u9762\u5E03\u5C40\u3002",processEventDone:"\u6F14\u793A\u7A3F\u5DF2\u751F\u6210\u3002",generationParsingDeck:"\u6B63\u5728\u52A0\u8F7D\u9875\u9762\u5230\u7F16\u8F91\u5668\u2026",processWaitingForEventsTitle:"\u7B49\u5F85\u5F00\u59CB",processWaitingForEvents:"\u53D1\u9001 Prompt \u540E\uFF0C\u8FD9\u91CC\u4F1A\u663E\u793A\u751F\u6210\u8FDB\u5EA6\u3002",processEventUnknown:"\u8FDB\u5EA6\u66F4\u65B0",eventTurnStarted:"\u5F00\u59CB\u751F\u6210",eventTurnFailed:"\u751F\u6210\u5931\u8D25",eventTurnCancelled:"\u751F\u6210\u5DF2\u53D6\u6D88",eventRoundCompleted:"\u672C\u9636\u6BB5\u5DF2\u5B8C\u6210",eventThinkingChunk:"\u601D\u8003\u6D41",eventTokenUsage:"Token \u7528\u91CF\u66F4\u65B0",eventUnknownTool:"\u5DE5\u5177",eventToolDetected:"\u68C0\u6D4B\u5230\u5DE5\u5177",eventToolParams:"\u6B63\u5728\u8BFB\u53D6\u5DE5\u5177\u53C2\u6570",eventToolQueued:"\u5DE5\u5177\u5DF2\u6392\u961F",eventToolWaiting:"\u7B49\u5F85\u5DE5\u5177\u6267\u884C",eventToolStarted:"\u5F00\u59CB\u8C03\u7528\u5DE5\u5177",eventToolProgress:"\u5DE5\u5177\u8FDB\u5EA6",eventToolStreaming:"\u5DE5\u5177\u6D41\u5F0F\u8F93\u51FA",eventToolStreamChunk:"\u5DE5\u5177\u8F93\u51FA\u7247\u6BB5",eventToolConfirmation:"\u5DE5\u5177\u9700\u8981\u786E\u8BA4",eventToolConfirmed:"\u5DE5\u5177\u5DF2\u786E\u8BA4",eventToolRejected:"\u5DE5\u5177\u5DF2\u62D2\u7EDD",eventToolCompleted:"\u5DE5\u5177\u6267\u884C\u5B8C\u6210",eventToolFailed:"\u5DE5\u5177\u6267\u884C\u5931\u8D25",eventToolCancelled:"\u5DE5\u5177\u5DF2\u53D6\u6D88",eventToolQueuePosition:"\u961F\u5217\u4F4D\u7F6E",eventToolSkillName:"PPT \u8BBE\u8BA1\u89C4\u8303",eventToolWebSearchName:"\u7F51\u9875\u641C\u7D22",eventToolWebFetchName:"\u7F51\u9875\u8BFB\u53D6",eventToolSkillReady:"\u8BBE\u8BA1\u89C4\u8303\u5DF2\u5C31\u7EEA",generationProgressPulse:"\u4ECD\u5728\u751F\u6210\u4E2D\u2026",generationPageProgress:"\u6B63\u5728\u751F\u6210\u7B2C {{current}} \u9875",generationSlideProgress:"\u5DF2\u8D77\u8349 {{count}} \u9875",generationStepBrief:"\u53D1\u5E03\u5047\u8BBE",generationStepBriefDetail:"\u9605\u8BFB Prompt \u5E76\u89C4\u5212\u6F14\u793A\u7A3F\u3002",generationStepSpine:"\u751F\u6210\u5927\u7EB2",generationStepSpineDetail:"\u628A\u9700\u6C42\u8F6C\u6210\u65AD\u8A00\u5F0F\u9875\u9762\u6807\u9898\u3002",generationStepProof:"\u9875\u9762\u6587\u6848",generationStepProofDetail:"\u7528\u7D20\u6750\u4E8B\u5B9E\u6216\u660E\u786E\u5047\u8BBE\u652F\u6491\u6BCF\u9875\u3002",generationStepDesign:"\u8BBE\u8BA1\u6392\u7248",generationStepDesignDetail:"\u5E94\u7528\u4E3B\u9898\u3001\u7248\u5F0F\u4E0E\u89C6\u89C9\u5C42\u6B21\u3002",generationStepCompile:"\u52A0\u8F7D\u9875\u9762",generationStepCompileDetail:"\u5C06\u751F\u6210\u7ED3\u679C\u52A0\u8F7D\u4E3A\u53EF\u7F16\u8F91\u9875\u9762\u3002",generationReadingBrief:"\u6B63\u5728\u7406\u89E3\u4F60\u7684 Prompt\u2026",generationWritingClaims:"\u6B63\u5728\u751F\u6210\u5927\u7EB2\u2026",generationChoosingProof:"\u6B63\u5728\u64B0\u5199\u9875\u9762\u6587\u6848\u2026",generationDesigningLayouts:"\u6B63\u5728\u8BBE\u8BA1\u9875\u9762\u7248\u5F0F\u2026",generationCompiled:"\u6F14\u793A\u7A3F\u5DF2\u5C31\u7EEA\u3002",generationSpineReady:"\u8BBA\u70B9\u4E3B\u7EBF\u5DF2\u751F\u6210\u3002",generationLocalSpine:"\u751F\u6210\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",generationLocalCompiler:"\u751F\u6210\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",agentPlanning:"\u6B63\u5728\u89C4\u5212\u6F14\u793A\u7A3F\u2026",agentPlanningFallback:"\u89C4\u5212\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",outlineTitle:"\u5927\u7EB2",outlineSubcopy:"\u5148\u786E\u8BA4\u6BCF\u4E00\u9875\u7684\u6545\u4E8B\u4E3B\u7EBF\uFF0C\u518D\u751F\u6210\u5B8C\u6574\u9875\u9762\u3002",addOutlineItem:"\u6DFB\u52A0\u5927\u7EB2\u9879",syncOutline:"\u7528\u5927\u7EB2\u540C\u6B65\u9875\u9762",modeEdit:"\u7F16\u8F91",modeSort:"\u6392\u5E8F",modePresent:"\u6F14\u793A",inspectorTitle:"\u68C0\u67E5\u5668",addText:"\u6587\u5B57",addList:"\u5217\u8868",addShape:"\u5F62\u72B6",addMetric:"\u6307\u6807",addChart:"\u56FE\u8868",addMedia:"\u5A92\u4F53",addSlide:"\u6DFB\u52A0\u9875\u9762",deleteSlide:"\u5220\u9664\u9875\u9762",deleteElement:"\u5220\u9664\u5143\u7D20",aiTitle:"AI \u8BBE\u8BA1",aiSubcopy:"\u7528 Prompt \u4FEE\u6539\u5F53\u524D\u9875\u3001\u6574\u5957 PPT\uFF0C\u6216\u63D2\u5165\u65B0\u9875\u3002",instructionPlaceholder:"\u4F8B\u5982\uFF1A\u8BA9\u672C\u9875\u66F4\u89C6\u89C9\u5316\uFF1B\u589E\u52A0\u4E00\u9875\u7ADE\u54C1\u5BF9\u6BD4\uFF1B\u6574\u5957\u6539\u6210\u878D\u8D44\u8DEF\u6F14\u98CE\u683C\uFF1B\u5220\u9664\u91CD\u590D\u5185\u5BB9\u3002",reviseSlide:"\u4FEE\u6539\u672C\u9875",reviseDeck:"\u4FEE\u6539\u6574\u5957",insertSlide:"\u63D2\u5165\u65B0\u9875",aiRewrite:"\u6539\u5199",aiCondense:"\u538B\u7F29",aiProfessional:"\u4E13\u4E1A\u5316",aiMoreVisual:"\u66F4\u89C6\u89C9\u5316",aiNotes:"\u6F14\u8BB2\u5907\u6CE8",aiRedesign:"\u91CD\u6392\u672C\u9875",aiRestyleDeck:"\u91CD\u5851\u6574\u5957\u98CE\u683C",styleTitle:"\u98CE\u683C",themeLabel:"\u4E3B\u9898",themeExecutive:"\u9AD8\u7BA1",themeMarket:"\u5E02\u573A",themeMinimal:"\u6781\u7B80",themeStudio:"\u521B\u610F",densityLabel:"\u5BC6\u5EA6",densityCompact:"\u7D27\u51D1",densityStandard:"\u6807\u51C6",densitySpacious:"\u8212\u5C55",brandPrimaryLabel:"\u4E3B\u8272",brandAccentLabel:"\u5F3A\u8C03\u8272",imagePolicyLabel:"\u56FE\u7247\u7B56\u7565",imagePolicyPlaceholders:"\u53EF\u7F16\u8F91\u5360\u4F4D",imagePolicyNone:"\u4E0D\u4F7F\u7528\u56FE\u7247",ready:"\u51C6\u5907\u5C31\u7EEA\u3002",statusPillReady:"\u5C31\u7EEA",statusPillBusy:"AI",exportReady:"\u751F\u6210\u540E\u53EF\u5BFC\u51FA HTML \u548C\u53EF\u7F16\u8F91 PPTX\u3002",working:"AI \u6B63\u5728\u5904\u7406...",outlineReady:"\u5927\u7EB2\u5DF2\u751F\u6210\u3002\u53EF\u5148\u8C03\u6574\u5927\u7EB2\uFF0C\u518D\u751F\u6210\u8BBE\u8BA1\u7A3F\u3002",deckReady:"\u8BBE\u8BA1\u7A3F\u5DF2\u751F\u6210\u3002",aiUnavailable:"\u751F\u6210\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",sourceGroundingRequired:"\u6765\u6E90\u65E0\u6CD5\u9A8C\u8BC1\u3002\u5DF2\u751F\u6210\u201C\u5148\u9A8C\u8BC1\u201D\u7684\u6F14\u793A\u7A3F\uFF0C\u800C\u4E0D\u662F\u7F16\u9020\u4E8B\u5B9E\u3002",saved:"\u5DF2\u4FDD\u5B58\u3002",slideUpdated:"\u9875\u9762\u5DF2\u66F4\u65B0\u3002",deckUpdated:"\u6574\u5957\u5DF2\u66F4\u65B0\u3002",slideInserted:"\u65B0\u9875\u9762\u5DF2\u63D2\u5165\u3002",deckRestyled:"\u6574\u5957\u98CE\u683C\u5DF2\u66F4\u65B0\u3002",cannotDelete:"\u81F3\u5C11\u4FDD\u7559\u4E00\u9875\u3002",noSelection:"\u9009\u62E9\u4E00\u4E2A\u9875\u9762\u5143\u7D20\u540E\u53EF\u7F16\u8F91\u5185\u5BB9\u548C\u5E03\u5C40\u3002",elementTypeLabel:"\u7C7B\u578B",elementTextLabel:"\u6587\u5B57",elementItemsLabel:"\u6761\u76EE",elementDataLabel:"\u56FE\u8868\u6570\u636E",geometryLabel:"\u4F4D\u7F6E\u5C3A\u5BF8",styleLabel:"\u6837\u5F0F",speakerNotesLabel:"\u6F14\u8BB2\u5907\u6CE8",kickerLabel:"\u7709\u6807",claimLabel:"\u8BBA\u70B9",proofObjectLabel:"\u8BC1\u636E\u5BF9\u8C61",supportNoteLabel:"\u652F\u6491\u8BF4\u660E",sourceNoteLabel:"\u6765\u6E90\u8BF4\u660E",newSlideTitle:"\u65B0\u9875\u9762",defaultDeckTitle:"AI \u4EA7\u54C1\u6218\u7565",slidesMeta:"{{count}} \u9875",exportHtmlDone:"HTML \u6F14\u793A\u7A3F\u5DF2\u4E0B\u8F7D\u3002",exportHtmlWorking:"\u6B63\u5728\u5BFC\u51FA HTML...",exportHtmlFailed:"HTML \u5BFC\u51FA\u5931\u8D25\uFF1A",exportSavedTo:"\u5DF2\u5BFC\u51FA\u5230 {{path}}",exportPptxWorking:"\u6B63\u5728\u6E32\u67D3\u53EF\u7F16\u8F91 PPTX...",exportPptxDone:"\u53EF\u7F16\u8F91 PPTX \u5DF2\u4E0B\u8F7D\u3002",exportPptxFailed:"PPTX \u5BFC\u51FA\u5931\u8D25\uFF1A",exportPdfWorking:"\u6B63\u5728\u6E32\u67D3 PDF...",exportPdfDone:"PDF \u5DF2\u4E0B\u8F7D\u3002",exportPdfFailed:"PDF \u5BFC\u51FA\u5931\u8D25\uFF1A",exportPngWorking:"\u6B63\u5728\u6E32\u67D3 PNG \u9875\u9762...",exportPngDone:"PNG \u9875\u9762\u538B\u7F29\u5305\u5DF2\u4E0B\u8F7D\u3002",exportPngFailed:"PNG \u5BFC\u51FA\u5931\u8D25\uFF1A",exportDeckEmpty:"\u8BF7\u5148\u751F\u6210\u5E7B\u706F\u7247\u540E\u518D\u5BFC\u51FA\u3002",slidesEmptyHint:"\u751F\u6210\u540E\u9875\u9762\u7F29\u7565\u56FE\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002",welcomeTitle:"\u63CF\u8FF0\u4F60\u7684 PPT\uFF0C\u4E00\u952E\u5F00\u59CB",welcomeSubcopy:"\u4E00\u6761 Prompt \u5373\u53EF\u751F\u6210\u5927\u7EB2\u3001\u8BBE\u8BA1\u9875\u9762\u548C\u53EF\u7F16\u8F91\u6F14\u793A\u7A3F\uFF0C\u4E4B\u540E\u53EF\u9010\u9875\u7EE7\u7EED\u4FEE\u6539\u3002",welcomeTip1:"10 \u9875\u6218\u7565\u65B9\u6848",welcomeTip2:"\u6539\u6210\u6295\u8D44\u4EBA\u7248\u672C",welcomeTip3:"\u672C\u9875\u66F4\u89C6\u89C9\u5316",deleteSlideDefaultPrompt:"\u5220\u9664\u5F53\u524D\u9875\u9762\uFF0C\u5E76\u4FDD\u6301\u6574\u5957 PPT \u7ED3\u6784\u8FDE\u8D2F\u3002",prev:"\u4E0A\u4E00\u9875",next:"\u4E0B\u4E00\u9875",assistantHello:"\u544A\u8BC9\u6211\u4F60\u8981\u505A\u4EC0\u4E48 PPT\u3002\u6211\u4F1A\u5148\u751F\u6210\u5927\u7EB2\uFF0C\u518D\u53D8\u6210\u53EF\u7F16\u8F91\u9875\u9762\u3002",aiChatApplied:"\u5DF2\u628A\u6307\u4EE4\u5E94\u7528\u5230\u5F53\u524D\u9875\u9762\u3002",localMetricLabel:"\u9700\u8981\u8BB0\u4F4F\u7684\u4FE1\u53F7",mediaPlaceholder:"\u56FE\u7247\u5360\u4F4D",slidesUnit:"\u9875",closeConfirm:"\u786E\u8BA4\u65B9\u5411",closeOwner:"\u660E\u786E\u8D1F\u8D23\u4EBA",closeIteration:"\u542F\u52A8\u4E0B\u4E00\u8F6E\u8FED\u4EE3",pointClaimPrefix:"\u8BBA\u70B9\uFF1A",pointProofPrefix:"\u8BC1\u636E\u5BF9\u8C61\uFF1A",pointAudiencePrefix:"\u53D7\u4F17\u5173\u8054\uFF1A",pointEvidenceRule:"\u8BC1\u636E\u89C4\u5219\uFF1A\u660E\u786E\u6807\u6CE8\u5047\u8BBE",pointDesignRule:"\u8BBE\u8BA1\u89C4\u5219\uFF1A\u4E00\u4E2A\u4E3B\u89C6\u89C9\u52A0\u4E00\u4E2A\u652F\u6491\u680F",pointCloseRule:"\u6536\u675F\uFF1A\u8BF4\u6E05\u4E0B\u4E00\u6B65\u884C\u52A8",claimCover:"{{topic}} \u9700\u8981\u4E00\u6761\u6E05\u6670\u7684\u51B3\u7B56\u4E3B\u7EBF\uFF0C\u800C\u4E0D\u662F\u4FE1\u606F\u5806\u780C\u3002",claimPressure:"{{title}} \u662F\u53D7\u4F17\u5FC5\u987B\u89E3\u51B3\u7684\u5173\u952E\u538B\u529B\u70B9\u3002",claimDecision:"{{title}} \u4E4B\u6240\u4EE5\u91CD\u8981\uFF0C\u662F\u56E0\u4E3A\u5B83\u628A\u8BC1\u636E\u8FDE\u63A5\u5230\u884C\u52A8\u3002",claimProof:"{{title}} \u5FC5\u987B\u7531\u9875\u9762\u91CC\u7684\u4E3B\u8BC1\u636E\u5BF9\u8C61\u6765\u627F\u62C5\u8BBA\u8BC1\u3002",claimAction:"{{title}} \u6700\u540E\u8981\u843D\u5230\u4E00\u4E2A\u660E\u786E\u51B3\u7B56\u3001\u8D1F\u8D23\u4EBA\u6216\u4E0B\u4E00\u6B65\u3002",supportWithSource:"\u7528\u5DF2\u63D0\u4F9B\u7D20\u6750\u652F\u6491\u8FD9\u4E2A\u8BBA\u70B9\uFF0C\u5E76\u8BA9\u201C{{proof}}\u201D\u6210\u4E3A\u4E3B\u8BC1\u636E\u3002",supportWithAssumption:"\u8865\u5145\u4E00\u4E2A\u5177\u4F53\u4F8B\u5B50\u6216\u6307\u6807\uFF0C\u8BA9\u201C{{proof}}\u201D\u652F\u6491\u8BBA\u70B9\uFF0C\u800C\u4E0D\u662F\u586B\u5145\u6587\u5B57\u3002",sourceUserMaterial:"\u6765\u6E90\uFF1A\u7528\u6237\u63D0\u4F9B\u7D20\u6750",sourceDraftAssumption:"\u6765\u6E90\uFF1A\u8349\u7A3F\u5047\u8BBE\uFF1B\u5BF9\u5916\u4F7F\u7528\u524D\u9700\u786E\u8BA4",defaultSpeakerNote:"\u5148\u8BB2\u201C{{title}}\u201D\u7684\u7ED3\u8BBA\uFF0C\u518D\u7528\u4E00\u4E2A\u5177\u4F53\u4F8B\u5B50\u6216\u6570\u636E\u652F\u6491\u3002",proofMarketMap:"\u5E02\u573A\u5730\u56FE",proofOperatingModel:"\u8FD0\u8425\u6A21\u578B",proofRiskBridge:"\u98CE\u9669\u6865",proofDecisionTable:"\u51B3\u7B56\u8868",proofBeforeAfter:"\u524D\u540E\u5BF9\u6BD4\u6D41\u7A0B",proofValueBridge:"\u4EF7\u503C\u6865",proofCustomerProof:"\u5BA2\u6237\u8BC1\u636E",proofImplementationPlan:"\u5B9E\u65BD\u8BA1\u5212",proofMetricBridge:"\u6307\u6807\u6865",proofTrendChart:"\u8D8B\u52BF\u56FE",proofSourceSummary:"\u6765\u6E90\u6458\u8981",proofVerificationPlan:"\u9A8C\u8BC1\u8BA1\u5212",proofCapabilityMatrix:"\u80FD\u529B\u77E9\u9635",proofEvidenceList:"\u8BC1\u636E\u5217\u8868",proofVarianceTable:"\u5DEE\u5F02\u8868",proofRiskRegister:"\u98CE\u9669\u6E05\u5355",proofConceptMap:"\u6982\u5FF5\u56FE",proofWorkedExample:"\u6848\u4F8B\u6F14\u7B97",proofComparison:"\u5BF9\u6BD4",proofPracticePrompt:"\u7EC3\u4E60\u63D0\u793A",proofMarketWedge:"\u5E02\u573A\u5207\u5165\u70B9",proofProductDiagram:"\u4EA7\u54C1\u56FE",proofTractionChart:"\u7275\u5F15\u529B\u56FE\u8868",proofMilestonePlan:"\u91CC\u7A0B\u7891\u8BA1\u5212",proofVisualProof:"\u89C6\u89C9\u8BC1\u636E",sourceManualTitle:"\u7528\u6237\u7B80\u62A5",sourceDigestTitle:"\u6765\u6E90\u6458\u8981",sourceFetchFailed:"\u672A\u80FD\u8BFB\u53D6 URL\uFF1A{{url}}",sourceMissingWarning:"\u672A\u63D0\u4F9B\u53EF\u9A8C\u8BC1\u7D20\u6750\u3002\u5185\u5BB9\u53EA\u80FD\u4F5C\u4E3A\u8349\u7A3F\uFF0C\u4E0D\u80FD\u5F53\u4F5C\u4E8B\u5B9E\u3002",sourceFetchedNote:"\u6765\u6E90\uFF1A\u5DF2\u8BFB\u53D6 {{count}} \u4E2A URL",bpContextTitle:"{{topic}} \u9700\u8981\u5148\u5EFA\u7ACB\u5728\u6765\u6E90\u4E8B\u5B9E\u4E4B\u4E0A\uFF0C\u518D\u63D0\u51FA\u5224\u65AD\u3002",bpSourceNeededTitle:"{{topic}} \u9700\u8981\u8865\u5145\u6765\u6E90\u7D20\u6750\u540E\u624D\u80FD\u63D0\u51FA\u4E8B\u5B9E\u6027\u7ED3\u8BBA\u3002",bpProblemTitle:"\u5F53\u524D\u5173\u952E\u95EE\u9898\u662F\uFF1A\u53D7\u4F17\u53EF\u4EE5\u5B89\u5168\u76F8\u4FE1\u4EC0\u4E48\u3002",bpSolutionTitle:"{{topic}} \u5E94\u901A\u8FC7\u80FD\u529B\u3001\u6D41\u7A0B\u548C\u8BC1\u636E\u6765\u89E3\u91CA\u3002",bpWorkflowTitle:"\u5DE5\u4F5C\u6D41\u9700\u8981\u5C55\u793A\u4EA7\u54C1\u5982\u4F55\u4E00\u6B65\u6B65\u521B\u9020\u4EF7\u503C\u3002",bpProofTitle:"\u53EF\u4FE1\u5EA6\u5E94\u8BE5\u7531\u6765\u6E90\u8BC1\u636E\u627F\u62C5\uFF0C\u800C\u4E0D\u662F\u7531\u5047\u56FE\u8868\u627F\u62C5\u3002",bpVerificationTitle:"\u9A8C\u8BC1\u7F3A\u53E3\u5FC5\u987B\u663E\u6027\u5C55\u793A\uFF0C\u4E0D\u80FD\u85CF\u5728\u865A\u6784\u56FE\u8868\u540E\u9762\u3002",bpRiskTitle:"\u6700\u5927\u98CE\u9669\u662F\u8D85\u51FA\u5DF2\u6709\u7D20\u6750\u8FC7\u5EA6\u58F0\u79F0\u3002",bpDecisionTitle:"\u4E0B\u4E00\u6B65\u662F\u9A8C\u8BC1\u5173\u952E\u8BBA\u70B9\uFF0C\u5E76\u9009\u62E9\u6700\u5F3A\u53D9\u4E8B\u8DEF\u5F84\u3002",bpSupportSource:"\u57FA\u4E8E\u5DF2\u8BFB\u53D6\u6216\u7C98\u8D34\u7D20\u6750\u751F\u6210\uFF1B\u5BF9\u5916\u4F7F\u7528\u524D\u8BF7\u6838\u5BF9\u539F\u6587\u3002",bpSupportMissing:"\u7D20\u6750\u4E0D\u8DB3\uFF1B\u672C\u9875\u5E94\u4F5C\u4E3A\u9A8C\u8BC1\u63D0\u793A\uFF0C\u800C\u4E0D\u662F\u4E8B\u5B9E\u7ED3\u8BBA\u3002",bpMissingFact1:"\u8BF7\u7C98\u8D34\u6765\u6E90\u7B14\u8BB0\u3001README\u3001\u6307\u6807\u6216\u4EA7\u54C1\u63CF\u8FF0\u6765\u652F\u6491\u672C\u9875\u3002",bpMissingFact2:"\u4E0D\u8981\u4F7F\u7528\u865A\u6784\u6307\u6807\uFF1B\u7528\u5DF2\u9A8C\u8BC1\u8BC1\u636E\u66FF\u6362\u5360\u4F4D\u5185\u5BB9\u3002",bpMissingFact3:"\u7528\u672C\u9875\u51B3\u5B9A\u4E0B\u4E00\u6B65\u9700\u8981\u8865\u5145\u7814\u7A76\u4EC0\u4E48\u3002",qualityOutOfBounds:"\u6709\u5143\u7D20\u8D85\u51FA\u5E7B\u706F\u7247\u5B89\u5168\u533A\u57DF\u3002",qualityTextDense:"\u5F53\u524D\u7248\u5F0F\u4E2D\u7684\u53EF\u89C1\u6587\u5B57\u53EF\u80FD\u8FC7\u5BC6\u3002",qualityChartUngrounded:"\u56FE\u8868\u6570\u636E\u7F3A\u5C11\u6765\u6E90\u6570\u5B57\uFF0C\u5DF2\u79FB\u9664\u6216\u6807\u8BB0\u3002",qualityOverlap:"\u6587\u5B57\u6216\u56FE\u8868\u5143\u7D20\u53EF\u80FD\u53D1\u751F\u91CD\u53E0\u3002",qualityMissingClaim:"\u672C\u9875\u9700\u8981\u4E00\u4E2A\u6E05\u6670\u8BBA\u70B9\u3002",qualityReportTitle:"\u8D28\u91CF\u62A5\u544A",qualityNeedsReview:"\u9700\u8981\u590D\u6838",qualityHasWarnings:"\u8D28\u91CF\u63D0\u9192",exportFormatUnavailable:"\u8BE5\u5BFC\u51FA\u683C\u5F0F\u5C1A\u672A\u652F\u6301\u3002",exportTitle:"\u5BFC\u51FA",exportCancel:"\u53D6\u6D88",exportConfirm:"\u5BFC\u51FA\u6587\u4EF6",exportPreviewPrevAria:"\u4E0A\u4E00\u9875",exportPreviewNextAria:"\u4E0B\u4E00\u9875",exportFormat:"\u683C\u5F0F",exportQuality:"\u8D28\u91CF",exportDpi:"\u56FE\u7247 DPI",exportRange:"\u5E7B\u706F\u7247\u8303\u56F4",exportShare:"\u5206\u4EAB",propertiesStyle:"\u6837\u5F0F",propertiesLayout:"\u5E03\u5C40",propertiesAnimation:"\u52A8\u753B",propertiesThemeColor:"\u4E3B\u9898\u8272",propertiesFont:"\u5B57\u4F53",propertiesColorMode:"\u5E7B\u706F\u7247\u914D\u8272",propertiesStylePreset:"\u98CE\u683C\u9884\u8BBE",colorModeLight:"\u6D45\u8272",colorModeDark:"\u6DF1\u8272",fontSansSerif:"\u975E\u886C\u7EBF",fontSerif:"\u886C\u7EBF",propertiesDensity:"\u5BC6\u5EA6",propertiesSmartAlign:"\u667A\u80FD\u5BF9\u9F50",propertiesPageTransition:"\u9875\u9762\u8FC7\u6E21",propertiesElementAnimation:"\u5143\u7D20\u52A8\u753B",densityLoose:"\u5BBD\u677E"}};function Mr(){let e=window.app?.locale||document.documentElement.lang||"";return e==="zh-CN"||String(e).startsWith("zh")?"zh-CN":"en-US"}function U(e,t={}){let r=Yo[Mr()]||Yo["en-US"],n=Yo["en-US"][e]||e,i=r[e]||n;return Object.entries(t).forEach(([a,o])=>{i=i.replaceAll(`{{${a}}}`,String(o))}),i}var ya={"clean-business":{styleKey:"clean-business",names:{"en-US":"Clean Business","zh-CN":"\u7B80\u6D01\u5546\u52A1"},descriptions:{"en-US":"Pure white background, calm blue accent, minimal and professional","zh-CN":"\u7EAF\u767D\u80CC\u666F\uFF0C\u84DD\u8272\u5F3A\u8C03\uFF0C\u6781\u7B80\u901A\u900F\u7684\u5546\u52A1\u98CE\u683C"},colorMode:"light",palette:{background:"#ffffff",ink:"#1a1a1a",muted:"#6b7280",primary:"#2563eb",accent:"#3b82f6",panel:"#f8fafc"},fontFamily:"sans",density:"spacious",keywords:/business|clean|professional|商务|简洁|专业|企业/},"insight-report":{styleKey:"insight-report",names:{"en-US":"Insight Report","zh-CN":"\u6D1E\u5BDF\u6C47\u62A5"},descriptions:{"en-US":"Consulting-grade dense pages: action titles, full tables, flowcharts, detailed breakdowns","zh-CN":"\u54A8\u8BE2\u7EA7\u9AD8\u5BC6\u5EA6\u9875\u9762\uFF1A\u884C\u52A8\u5F0F\u7ED3\u8BBA\u6807\u9898\uFF0C\u6EE1\u7248\u8868\u683C\u56FE\u793A\uFF0C\u8BE6\u5C3D\u903B\u8F91\u62C6\u89E3"},colorMode:"light",palette:{background:"#ffffff",ink:"#1f2937",muted:"#64748b",primary:"#1e3a8a",accent:"#dc2626",panel:"#f1f5f9"},fontFamily:"sans",density:"compact",keywords:/insight|consult|academic|research|whitepaper|due.*diligence|洞察|咨询|学术|调研|详尽|深度分析|尽调/},"minimal-gallery":{styleKey:"minimal-gallery",names:{"en-US":"Monochrome Minimal","zh-CN":"\u9ED1\u767D\u6781\u7B80"},descriptions:{"en-US":"Strict grid, monochrome palette, gallery-grade whitespace","zh-CN":"\u4E25\u683C\u7F51\u683C\uFF0C\u9ED1\u767D\u7070\u5C42\u7EA7\uFF0C\u753B\u518C\u7EA7\u7559\u767D"},colorMode:"light",palette:{background:"#fafafa",ink:"#171717",muted:"#737373",primary:"#171717",accent:"#525252",panel:"#ffffff"},fontFamily:"sans",density:"spacious",keywords:/minimal|gallery|portfolio|grid|swiss|photo.*book|origami|极简|画廊|作品集|网格|画册|摄影|折纸/},"bold-editorial":{styleKey:"bold-editorial",names:{"en-US":"Black-White-Red","zh-CN":"\u9ED1\u767D\u7EA2\u5927\u5B57"},descriptions:{"en-US":"Oversized black type on white, red accents, asymmetric editorial grid","zh-CN":"\u767D\u5E95\u9ED1\u8272\u5927\u5B57\uFF0C\u7EA2\u8272\u70B9\u7F00\uFF0C\u975E\u5BF9\u79F0\u7F16\u8F91\u6392\u7248"},colorMode:"light",palette:{background:"#ffffff",ink:"#000000",muted:"#525252",primary:"#dc2626",accent:"#ef4444",panel:"#fafafa"},fontFamily:"sans",density:"spacious",keywords:/editorial|newspaper|bold.*type|fashion|headline|black.*white.*red|报纸|编辑|大字|头条|时尚|黑白红/},"yellow-magazine":{styleKey:"yellow-magazine",names:{"en-US":"Yellow Magazine","zh-CN":"\u9EC4\u5E95\u9ED1\u5B57\u6742\u5FD7"},descriptions:{"en-US":"High-impact yellow background, black type, handwritten accents","zh-CN":"\u9AD8\u8BC6\u522B\u5EA6\u9EC4\u5E95\u9ED1\u5B57\uFF0C\u624B\u5199\u70B9\u7F00\uFF0C\u5F3A\u70C8\u6742\u5FD7\u611F"},colorMode:"light",palette:{background:"#facc15",ink:"#171717",muted:"#525252",primary:"#171717",accent:"#ffffff",panel:"#fef08a"},fontFamily:"sans",density:"standard",keywords:/yellow|handwritten|magazine|黄黑|黄底|手写|杂志/},"pink-pop":{styleKey:"pink-pop",names:{"en-US":"Pink Pop","zh-CN":"\u7C89\u8272\u6CE2\u666E"},descriptions:{"en-US":"Matte pink canvas, refined magazine or street pop energy","zh-CN":"\u54D1\u5149\u7C89\u5E95\uFF0C\u7CBE\u81F4\u6742\u5FD7\u6216\u8857\u5934\u6CE2\u666E\u4E24\u79CD\u529B\u5EA6"},colorMode:"light",palette:{background:"#fce7f3",ink:"#831843",muted:"#be185d",primary:"#db2777",accent:"#f472b6",panel:"#fdf2f8"},fontFamily:"sans",density:"standard",keywords:/pink|feminine|cute|street.*pop|粉色|粉底|女性|街头|潮流/},"creative-studio":{styleKey:"creative-studio",names:{"en-US":"Black-Orange Studio","zh-CN":"\u9ED1\u6A59\u521B\u610F"},descriptions:{"en-US":"White canvas, black type, blood-orange accents, agency sharpness","zh-CN":"\u767D\u5E95\u9ED1\u5B57\u8840\u6A59\u5F3A\u8C03\uFF0C\u5E72\u7EC3\u65F6\u5C1A\u7684\u521B\u610F\u673A\u6784\u98CE"},colorMode:"light",palette:{background:"#ffffff",ink:"#171717",muted:"#525252",primary:"#ea580c",accent:"#c2410c",panel:"#fafafa"},fontFamily:"sans",density:"standard",keywords:/studio|creative|agency|orange|黑橙|创意|机构/},"retro-pop":{styleKey:"retro-pop",names:{"en-US":"Retro Poster Pop","zh-CN":"\u590D\u53E4\u6D77\u62A5\u6CE2\u666E"},descriptions:{"en-US":"Vintage tones, poster-grade type, playful pop-art collage","zh-CN":"\u590D\u53E4\u8272\u8C03\uFF0C\u6D77\u62A5\u7EA7\u6392\u7248\uFF0C\u5927\u80C6\u6CE2\u666E\u62FC\u8D34"},colorMode:"light",palette:{background:"#fef3c7",ink:"#451a03",muted:"#92400e",primary:"#dc2626",accent:"#f59e0b",panel:"#fffbeb"},fontFamily:"sans",density:"standard",keywords:/retro|poster|pop.*art|vintage|sculpture|classical|复古|海报|波普|怀旧|雕塑|古典/},"dark-neon":{styleKey:"dark-neon",names:{"en-US":"Dark Neon","zh-CN":"\u6697\u9ED1\u9713\u8679"},descriptions:{"en-US":"Deep dark canvas with neon accents: glitch art or neon blueprint","zh-CN":"\u6DF1\u8272\u80CC\u666F\u9713\u8679\u5F3A\u8C03\uFF0C\u6545\u969C\u827A\u672F\u6216\u9713\u8679\u5236\u56FE"},colorMode:"dark",palette:{background:"#0a0a0a",ink:"#e5e5e5",muted:"#737373",primary:"#22d3ee",accent:"#f472b6",panel:"#171717"},fontFamily:"sans",density:"standard",keywords:/dark|glitch|cyber|neon|tech.*art|blueprint|暗黑|故障|赛博|霓虹|科技|制图/},"pop-infographic":{styleKey:"pop-infographic",names:{"en-US":"Pop Infographic","zh-CN":"\u6CE2\u666E\u4FE1\u606F\u56FE"},descriptions:{"en-US":"Vivid pink and cyan, organic shapes or retro pixels, data-forward","zh-CN":"\u9C9C\u8273\u7C89\u9752\u914D\u8272\uFF0C\u6709\u673A\u5F62\u6001\u6216\u590D\u53E4\u50CF\u7D20\uFF0C\u4FE1\u606F\u56FE\u8BED\u6C47"},colorMode:"light",palette:{background:"#ffffff",ink:"#171717",muted:"#525252",primary:"#ec4899",accent:"#06b6d4",panel:"#f0fdfa"},fontFamily:"sans",density:"standard",keywords:/infographic|data|pixel|dev|vitamin|pop|信息图|数据|像素|开发者|波普/}},on="clean-business";function Jo(e){return e&&ya[e]?e:on}function $o(e){return ya[Jo(e)]}function Kf(e){return e==="zh-CN"?"zh-CN":"en-US"}function nc(e){let t=Kf(e);return Object.entries(ya).map(([r,n])=>({key:r,displayName:n.names[t]||n.names["en-US"],description:n.descriptions[t]||n.descriptions["en-US"],colorMode:n.colorMode}))}var ki="pptLiveStudioStateV6",ns="pptLiveDeckHistoryV1",sc=5,is=["text","list","shape","metric","chart","media"],ts={executive:{name:"Executive",background:"#fbfcff",ink:"#111827",muted:"#5b6575",primary:"#0f766e",accent:"#f97316",panel:"#ffffff"},market:{name:"Market",background:"#fffdf7",ink:"#1f2937",muted:"#6b5f50",primary:"#2563eb",accent:"#d97706",panel:"#ffffff"},minimal:{name:"Minimal",background:"#f8fafc",ink:"#0f172a",muted:"#64748b",primary:"#334155",accent:"#0f766e",panel:"#ffffff"},studio:{name:"Studio",background:"#fcfbff",ink:"#1f1630",muted:"#6c607a",primary:"#7c3aed",accent:"#db2777",panel:"#ffffff"}};function or(e="id"){return`${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function zr(e){return JSON.parse(JSON.stringify(e))}function mt(e,t,r){return Math.max(t,Math.min(r,e))}function Le(e){return String(e??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function as(){return{topic:"",slideTarget:0}}function lc(e="strategy"){let t={strategy:{profile:"strategy-leadership",thesis:"Decision-led transformation narrative",proofObjects:["market map","operating model","risk bridge","decision table"],arc:["thesis","context","friction","strategic bet","operating model","proof","risks","decision"]},sales:{profile:"gtm-growth",thesis:"Buyer pain to differentiated value narrative",proofObjects:["before/after workflow","value bridge","customer proof","implementation plan"],arc:["outcome","market shift","pain","solution","proof","commercial case","rollout","call to action"]},report:{profile:"finance-ir",thesis:"Executive performance narrative with decisions attached",proofObjects:["metric bridge","trend chart","variance table","risk register"],arc:["summary","scorecard","movement","root cause","metric proof","risk","plan","decision"]},teaching:{profile:"education",thesis:"Concept to application learning journey",proofObjects:["concept map","worked example","comparison","practice prompt"],arc:["goal","map","concept","example","mistakes","practice","summary","next step"]},fundraising:{profile:"fundraising",thesis:"Venture-scale opportunity supported by traction evidence",proofObjects:["market wedge","product diagram","traction chart","milestone plan"],arc:["thesis","problem","solution","market","product","traction","model","ask"]}};return t[e]||t.strategy}function Nn(e="standard"){let t=String(e||"standard");return t==="loose"?"spacious":["compact","standard","spacious"].includes(t)?t:"standard"}var rs=["spacious","standard","compact"];function xa(e="standard"){let t=Nn(e),r=rs.indexOf(t);return r>=0?r:1}function cc(e=1){let t=Math.min(Math.max(Math.round(Number(e)),0),rs.length-1);return rs[t]||"standard"}function dc(e="standard"){let t=Nn(e),r={spacious:{bulletLimit:4,cardColumns:3,cardGap:2},standard:{bulletLimit:5,cardColumns:4,cardGap:1.8},compact:{bulletLimit:6,cardColumns:4,cardGap:1.2}};return r[t]||r.standard}function ic(e=0){let t=Number(e);return!Number.isFinite(t)||t<=0?0:mt(t,3,24)}function os(){return{theme:"executive",density:"standard",fontFamily:"sans",colorMode:"light",stylePreset:"clean-business"}}function uc(){return[U("defaultDeckTitle"),"Why now","Current friction","Strategic answer","Core workflow","Proof and impact","Rollout plan","Decision and next steps"]}function In(){return{schemaVersion:sc,sessionId:or("deck"),title:U("blankDeckTitle"),brief:as(),promptDraft:"",lastSubmittedPrompt:"",style:os(),outline:[],sources:{items:[],facts:[],warnings:[],summary:"",fetchedAt:0},slides:[],activeSlideId:"",selectedElementId:"",mode:"edit",presentIndex:0,status:"ready",generation:{active:!1,current:"idle",steps:fc().map(t=>({...t,status:"pending"})),events:[]},chatMessages:[{role:"assistant",text:U("assistantHello")}],updatedAt:Date.now()}}function ln(e){let t={...In(),...e||{}};t.schemaVersion=sc;let r=t.brief||{};t.brief={...as(),topic:String(r.topic||t.promptDraft||"").trim(),slideTarget:ic(r.slideTarget)},t.promptDraft=typeof t.promptDraft=="string"?t.promptDraft:"",t.lastSubmittedPrompt=typeof t.lastSubmittedPrompt=="string"?t.lastSubmittedPrompt:"",t.style={...os(),...t.style||{}},delete t.style.brandPrimary,delete t.style.brandAccent,Object.keys(ts).includes(t.style.theme)||(t.style.theme="executive"),["compact","standard","spacious","loose"].includes(t.style.density)||(t.style.density="standard"),t.style.density=Nn(t.style.density),["sans","serif"].includes(t.style.fontFamily)||(t.style.fontFamily=t.style.fontFamily==="serif"?"serif":"sans"),["light","dark"].includes(t.style.colorMode)||(t.style.colorMode="light"),t.style.stylePreset=Jo(typeof t.style.stylePreset=="string"?t.style.stylePreset:""),t.generation=Sa(t.generation),t.sources=_f(t.sources),t.brief.slideTarget=ic(t.brief.slideTarget);let n=t.generation.active&&Array.isArray(t.slides)&&t.slides.length===0;t.outline=n?[]:Array.isArray(t.outline)?t.outline.map(a=>String(a||U("newSlideTitle"))):[],t.slides=n?[]:Array.isArray(t.slides)&&t.slides.length>0?t.slides.map((a,o)=>Or(a,o,t)):t.outline.length>0?t.outline.map((a,o)=>ka(a,o,t.outline.length,t)):[],t.slides.some(a=>a.id===t.activeSlideId)||(t.activeSlideId=t.slides[0]?.id||"");let i=Kt(t);return i?.elements.some(a=>a.id===t.selectedElementId)||(t.selectedElementId=i?.elements[0]?.id||""),t.title=t.title||t.slides[0]?.title||U("defaultDeckTitle"),t.updatedAt=Date.now(),t}function _f(e={}){return{items:Array.isArray(e.items)?e.items:[],facts:Array.isArray(e.facts)?e.facts:[],warnings:Array.isArray(e.warnings)?e.warnings:[],summary:typeof e.summary=="string"?e.summary:"",fetchedAt:Number(e.fetchedAt||0)}}function fc(){return[{id:"brief",label:U("generationStepBrief"),detail:U("generationStepBriefDetail")},{id:"spine",label:U("generationStepSpine"),detail:U("generationStepSpineDetail")},{id:"proof",label:U("generationStepProof"),detail:U("generationStepProofDetail")},{id:"design",label:U("generationStepDesign"),detail:U("generationStepDesignDetail")},{id:"compile",label:U("generationStepCompile"),detail:U("generationStepCompileDetail")}]}var Qf=80;function Zf(e={}){let t=typeof e=="string"?{title:e}:e||{},r=String(t.title||t.label||t.message||U("processEventUnknown")).trim()||U("processEventUnknown"),n=String(t.kind||"info").toLowerCase().replace(/[^a-z0-9-]/g,"")||"info",i=Number(t.timestamp||t.time||0)||Date.now();return{id:String(t.id||or("generation-event")),seq:Number(t.seq)||0,title:r,detail:String(t.detail||t.description||"").trim(),kind:n,timestamp:i}}function Sa(e={}){let t=new Map((Array.isArray(e.steps)?e.steps:[]).map(i=>[i.id,i])),r=Array.isArray(e.events)?e.events.map(Zf).slice(-Qf):[],n=r.reduce((i,a)=>Math.max(i,Number(a.seq)||0),0);return{active:!!e.active,current:e.current||"idle",draftedCount:Number(e.draftedCount)||0,slideTarget:Number(e.slideTarget)||0,eventSeq:Math.max(Number(e.eventSeq)||0,n),steps:fc().map(i=>({...i,status:t.get(i.id)?.status||"pending"})),events:r}}function Kt(e){return e.slides.find(t=>t.id===e.activeSlideId)||e.slides[0]}function $t(e){return Math.max(0,e.slides.findIndex(t=>t.id===e.activeSlideId))}function Mn(e){return Kt(e)?.elements.find(r=>r.id===e.selectedElementId)||null}function ka(e,t,r,n={brief:as(),style:os(),slides:[]}){let i=hc(n,t),a={id:or("slide"),title:e||`${U("newSlideTitle")} ${t+1}`,subtitle:"",kicker:Ac(t,n),claim:ls(e,t,n),proofObject:Fa(t,n),supportNote:gc(e,t,n),sourceNote:mc(n),notes:U("defaultSpeakerNote",{title:e}),layout:pc(t,r),theme:i,elements:[]};return a.elements=vc(a,t,r,n),Or(a,t,n)}function Or(e,t,r){let n=e?.title||`${U("newSlideTitle")} ${t+1}`,i={id:e?.id||or("slide"),title:n,subtitle:e?.subtitle||"",kicker:String(e?.kicker||Ac(t,r)),claim:String(e?.claim||ls(n,t,r)),proofObject:String(e?.proofObject||Fa(t,r)),supportNote:String(e?.supportNote||gc(n,t,r)),sourceNote:String(e?.sourceNote||mc(r)),notes:e?.notes||"",layout:e?.layout||pc(t,r?.slides?.length||1),theme:{...hc(r,t),...e?.theme||e?.style||{}},html:typeof e?.html=="string"?e.html:"",quality:Yf(e?.quality),elements:[]},a=Array.isArray(e?.elements)&&e.elements.length>0?e.elements:vc(i,t,r?.slides?.length||1,r);if(i.elements=a.map(o=>ss(o)),i.html){let o=Pa(i.html);o&&(i.theme.background=o)}return i}function Yf(e={}){let t=Array.isArray(e?.issues)?e.issues:[];return{score:mt(Number(e?.score??100),0,100),issues:t.slice(0,12).map(r=>({id:String(r?.id||or("quality")),severity:["high","medium","low"].includes(r?.severity)?r.severity:"low",type:String(r?.type||"quality"),message:String(r?.message||"")})).filter(r=>r.message)}}function ss(e={}){let t=is.includes(e.type)?e.type:"text",r=Ca(t);return{...r,...e,id:e.id||or("el"),type:t,x:mt(Number(e.x??r.x),0,98),y:mt(Number(e.y??r.y),0,98),w:mt(Number(e.w??r.w),3,100),h:mt(Number(e.h??r.h),3,100),text:typeof e.text=="string"?e.text:r.text,label:typeof e.label=="string"?e.label:r.label,items:Array.isArray(e.items)?e.items.map(String):r.items,data:Array.isArray(e.data)?e.data.map(Jf):r.data,style:$f({...r.style,...e.style||{}})}}function Jf(e,t){return typeof e=="number"?{label:`Q${t+1}`,value:e}:{label:String(e?.label||`Item ${t+1}`),value:Number(e?.value||0)}}function $f(e={}){return{fontSize:mt(Number(e.fontSize||24),8,88),fontWeight:mt(Number(e.fontWeight||600),100,900),color:e.color||"ink",background:e.background||"transparent",opacity:mt(Number(e.opacity??1),0,1),borderRadius:mt(Number(e.borderRadius||0),0,99),align:e.align||"left"}}function Ca(e){let t={text:{text:"Key message",label:"",items:[],data:[],x:8,y:12,w:60,h:16,style:{fontSize:38,fontWeight:780,color:"ink",background:"transparent",borderRadius:0,opacity:1,align:"left"}},list:{text:"",label:"",items:["First point","Second point","Third point"],data:[],x:9,y:36,w:48,h:40,style:{fontSize:20,fontWeight:500,color:"ink",background:"transparent",borderRadius:8,opacity:1,align:"left"}},shape:{text:"",label:"",items:[],data:[],x:66,y:14,w:24,h:62,style:{fontSize:18,fontWeight:600,color:"accent",background:"primary",borderRadius:22,opacity:.12,align:"center"}},metric:{text:"3x",label:"Faster first draft",items:[],data:[],x:63,y:42,w:26,h:26,style:{fontSize:44,fontWeight:820,color:"primary",background:"panel",borderRadius:14,opacity:1,align:"left"}},chart:{text:"Signal trend",label:"",items:[],data:[{label:"Now",value:42},{label:"Next",value:68},{label:"Target",value:86}],x:52,y:36,w:36,h:32,style:{fontSize:18,fontWeight:700,color:"ink",background:"panel",borderRadius:14,opacity:1,align:"left"}},media:{text:U("mediaPlaceholder"),label:"",items:[],data:[],x:58,y:18,w:32,h:42,style:{fontSize:16,fontWeight:650,color:"muted",background:"soft",borderRadius:16,opacity:1,align:"center"}}};return{...zr(t[e]||t.text),type:t[e]?e:"text"}}function hc(e,t=0){let r=e?.deckPalette;if(r&&typeof r=="object"){let o=r.primary||"#111111",l=r.accent||"#c84b31";return ac({name:"deck",background:r.background||"#111111",ink:r.ink||"#f8fafc",muted:r.muted||"#cbd5e1",primary:t%2?l:o,accent:t%2?o:l,panel:r.panel||"#1f2937"})}let n=ts[e?.style?.theme||"executive"]||ts.executive,i=n.primary,a=n.accent;return ac({...n,primary:t%2?a:i,accent:t%2?i:a})}function Pa(e){let t=String(e||""),r=[/body\s*\{[^}]*background(?:-color)?\s*:\s*([^;}\n]+)/i,/]*style="[^"]*background(?:-color)?\s*:\s*([^;"']+)/i,/html\s*\{[^}]*background(?:-color)?\s*:\s*([^;}\n]+)/i,/:root\s*\{[^}]*background(?:-color)?\s*:\s*([^;}\n]+)/i,/background(?:-color)?\s*:\s*(#[0-9a-f]{3,8}|rgb[a]?\([^)]+\)|hsl[a]?\([^)]+\)|black|white)/i];for(let n of r){let i=t.match(n);if(!i)continue;let a=eh(i[1]);if(a)return a}return null}function eh(e){let t=String(e||"").trim().replace(/\s+!important$/i,"");if(!t||/^transparent$/i.test(t))return null;if(/^#[0-9a-f]{3,8}$/i.test(t))return sn(t,t);if(/^rgb/i.test(t)||/^hsl/i.test(t))return t;let r={black:"#000000",white:"#ffffff",transparent:null};return Object.prototype.hasOwnProperty.call(r,t.toLowerCase())?r[t.toLowerCase()]:t}function ac(e){let t=sn(e.background,"#ffffff"),r=sn(e.panel,"#ffffff");return{...e,background:t,panel:r,ink:ba(t,e.ink,"#111827","#f8fafc",7),muted:ba(t,e.muted,"#4b5563","#cbd5e1",4.5),primary:ba(r,e.primary,"#0f766e","#5eead4",4.5),accent:ba(r,e.accent,"#c2410c","#fdba74",4.5)}}function ba(e,t,r,n,i){let a=sn(e,"#ffffff"),o=sn(t,r);if(es(a,o)>=i)return o;let l=sn(r,"#111827"),c=sn(n,"#f8fafc");return es(a,l)>=es(a,c)?l:c}function es(e,t){let r=oc(e),n=oc(t),i=Math.max(r,n),a=Math.min(r,n);return(i+.05)/(a+.05)}function oc(e){let{r:t,g:r,b:n}=th(e);return[t,r,n].map(i=>{let a=i/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4}).reduce((i,a,o)=>i+a*[.2126,.7152,.0722][o],0)}function sn(e,t){let r=String(e||"").trim(),n=r.match(/^#([0-9a-f]{3})$/i);return n?`#${n[1].split("").map(i=>i+i).join("")}`.toLowerCase():/^#[0-9a-f]{6}$/i.test(r)?r.toLowerCase():t}function th(e){let t=sn(e,"#000000").slice(1),r=parseInt(t,16);return{r:r>>16&255,g:r>>8&255,b:r&255}}function pc(e,t){return e===0?"cover":e===t-1?"closing":["split","metric","process","comparison"][e%4]}function Ac(e,t){let r=lc();return(r.arc[e%r.arc.length]||"proof").replace(/[-_]/g," ").toUpperCase()}function Fa(e,t){let r=lc(),n=r.proofObjects[e%r.proofObjects.length]||"visual proof";return{"market map":U("proofMarketMap"),"operating model":U("proofOperatingModel"),"risk bridge":U("proofRiskBridge"),"decision table":U("proofDecisionTable"),"before/after workflow":U("proofBeforeAfter"),"value bridge":U("proofValueBridge"),"customer proof":U("proofCustomerProof"),"implementation plan":U("proofImplementationPlan"),"metric bridge":U("proofMetricBridge"),"trend chart":U("proofTrendChart"),"variance table":U("proofVarianceTable"),"risk register":U("proofRiskRegister"),"concept map":U("proofConceptMap"),"worked example":U("proofWorkedExample"),comparison:U("proofComparison"),"practice prompt":U("proofPracticePrompt"),"market wedge":U("proofMarketWedge"),"product diagram":U("proofProductDiagram"),"traction chart":U("proofTractionChart"),"milestone plan":U("proofMilestonePlan"),"visual proof":U("proofVisualProof")}[n]||n}function ls(e,t,r){let n=r?.brief?.topic||r?.title||e;if(t===0)return U("claimCover",{topic:n});if(e&&/[.!?。!?]$/.test(e.trim()))return e;let i=[U("claimPressure",{title:e}),U("claimDecision",{title:e}),U("claimProof",{title:e}),U("claimAction",{title:e})];return i[t%i.length]}function gc(e,t,r){let n=Fa(t,r);return U("supportWithAssumption",{proof:n})}function mc(e){return U("sourceDraftAssumption")}function vc(e,t,r,n){let i=e.title,a=dc(n?.style?.density),o=nh(i,t,n).slice(0,a.bulletLimit).map(c=>String(c).slice(0,90)),l=rh(e,t,r);return l==="cover"?[Tt("shape",{x:6,y:9,w:88,h:76,style:{background:"soft",opacity:1,borderRadius:28}}),Tt("shape",{x:9,y:15,w:1.2,h:55,style:{background:"primary",opacity:1,borderRadius:99}}),Tt("text",{text:e.kicker,x:13,y:15,w:22,h:5,style:{fontSize:10,fontWeight:760,color:"primary"}}),Tt("text",{text:i,x:13,y:23,w:58,h:25,style:{fontSize:i.length>48?34:44,fontWeight:840}}),Tt("text",{text:e.claim,x:14,y:55,w:45,h:11,style:{fontSize:18,fontWeight:520,color:"muted"}}),Tt("metric",{text:String(r),label:U("slidesUnit"),x:75,y:54,w:14,h:17,style:{fontSize:34}})]:l==="closing"?[Tt("text",{text:i,x:9,y:15,w:65,h:15,style:{fontSize:i.length>48?30:38,fontWeight:820}}),Tt("text",{text:e.claim,x:10,y:33,w:46,h:9,style:{fontSize:17,fontWeight:540,color:"muted"}}),...wa([U("closeConfirm"),U("closeOwner"),U("closeIteration")],10,50,52,22,3),Tt("text",{text:o[0]||e.supportNote,x:67,y:48,w:22,h:20,style:{fontSize:18,fontWeight:720,color:"primary",background:"soft",borderRadius:20}})]:l==="process"?[Tt("text",{text:i,x:8,y:10,w:68,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:9,y:25,w:54,h:7,style:{fontSize:15,fontWeight:520,color:"muted"}}),Tt("shape",{x:10,y:50,w:78,h:1.2,style:{background:"primary",opacity:.25,borderRadius:99}}),...wa(o.map((c,s)=>`0${s+1} ${c}`),10,37,78,28,Math.min(a.cardColumns,Math.max(2,o.length)),a.cardGap)]:l==="comparison"?[Tt("text",{text:i,x:7,y:10,w:72,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:8,y:25,w:48,h:7,style:{fontSize:15,fontWeight:520,color:"muted"}}),...wa(o,8,37,82,30,2,a.cardGap)]:l==="data"?[Tt("text",{text:i,x:8,y:10,w:66,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:9,y:25,w:47,h:7,style:{fontSize:15,fontWeight:520,color:"muted"}}),Tt("metric",{text:String(t).padStart(2,"0"),label:e.proofObject,x:10,y:40,w:34,h:28,style:{fontSize:44}}),Tt("text",{text:o[0]||e.supportNote,x:69,y:41,w:20,h:24,style:{fontSize:17,fontWeight:700,color:"primary",background:"soft",borderRadius:18}})]:l==="cards"?[Tt("text",{text:i,x:8,y:10,w:68,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:9,y:25,w:51,h:8,style:{fontSize:15,fontWeight:520,color:"muted"}}),...wa(o,9,38,78,28,a.cardColumns,a.cardGap)]:[Tt("text",{text:i,x:10,y:15,w:62,h:15,style:{fontSize:i.length>48?30:38,fontWeight:820}}),Tt("text",{text:e.claim,x:11,y:34,w:42,h:10,style:{fontSize:17,fontWeight:520,color:"muted"}}),Tt("text",{text:o[0]||e.supportNote,x:58,y:38,w:28,h:24,style:{fontSize:22,fontWeight:760,color:"primary",background:"soft",borderRadius:22}}),Tt("shape",{x:10,y:72,w:18,h:.6,style:{background:"primary",opacity:1,borderRadius:99}})]}function rh(e,t,r){let n=[e.layout,e.kicker,e.proofObject,e.claim,e.title].join(" ").toLowerCase();return t===0||e.layout==="cover"?"cover":t===r-1||e.layout==="closing"?"closing":/process|workflow|timeline|roadmap|journey|steps|architecture|flow|流程|步骤|路线|架构/.test(n)?"process":/compare|comparison|versus|matrix|before|after|risk|对比|比较|矩阵|风险/.test(n)?"comparison":/data|metric|trend|scorecard|chart|number|数据|指标|趋势/.test(n)?"data":t%3===1?"cards":"spotlight"}function wa(e,t,r,n,i,a,o=2.5){let l=e.filter(Boolean),c=Math.max(1,Math.min(a||1,l.length||1)),s=Number.isFinite(o)?o:2.5,d=Math.max(1,Math.ceil((l.length||1)/c)),u=(n-s*(c-1))/c,f=(i-s*(d-1))/d;return l.map((h,p)=>Tt("text",{text:h,x:t+p%c*(u+s),y:r+Math.floor(p/c)*(f+s),w:u,h:f,style:{fontSize:17,fontWeight:p===0?760:620,color:p===0?"primary":"ink",background:p===0?"soft":"panel",borderRadius:18}}))}function Tt(e,t){let r=Ca(e);return{...r,...t,style:{...r.style,...t.style||{}}}}function nh(e,t,r){let n=r?.brief?.topic||e,i=Fa(t,r),a=[`${U("pointClaimPrefix")} ${ls(e,t,r)}`,`${U("pointProofPrefix")} ${i}`,`${U("pointAudiencePrefix")} ${n}`,U("pointEvidenceRule"),U("pointDesignRule"),U("pointCloseRule")],o=dc(r?.style?.density).bulletLimit,l=[];for(let c=0;c{t!==e&&Ta(t)})}function cs(e){let t=e.querySelector(".ppt-flat-select__menu"),r=e.querySelector(".ppt-flat-select__trigger");if(!t||!r)return;let n=r.getBoundingClientRect(),i=Math.min(220,t.scrollHeight||220),a=window.innerHeight-n.bottom,o=aa;t.style.left=`${Math.max(8,n.left)}px`,t.style.width=`${n.width}px`,o?(t.style.top="auto",t.style.bottom=`${window.innerHeight-n.top+4}px`):(t.style.top=`${n.bottom+4}px`,t.style.bottom="auto")}function yc(e){let t=e.querySelector(".ppt-flat-select__menu"),r=e.querySelector(".ppt-flat-select__trigger");if(!t||!r)return;Da(null),t.hidden=!1,cs(e),r.setAttribute("aria-expanded","true"),e.classList.add("is-open"),Yn.add(e),t.querySelector(".ppt-flat-select__option.is-selected")?.scrollIntoView({block:"nearest"})}function ih(e,t){let r=e.querySelector(".ppt-flat-select__menu");if(!r||r.hidden)return;let n=[...r.querySelectorAll(".ppt-flat-select__option")];if(!n.length)return;let i=n.indexOf(document.activeElement),a=i>=0?i:n.findIndex(l=>l.classList.contains("is-selected")),o=Math.min(n.length-1,Math.max(0,(a<0?-t:a)+t));n[o]?.focus(),n[o]?.scrollIntoView({block:"nearest"})}function ds(e){let t=e.closest(".ppt-flat-select");if(!t)return;let r=t.querySelector(".ppt-flat-select__label"),n=t.querySelector(".ppt-flat-select__menu"),i=e.options[e.selectedIndex];if(r&&(r.textContent=i?.textContent?.trim()||""),!n)return;let a=new Map([...n.querySelectorAll(".ppt-flat-select__option")].map(o=>[o.dataset.value,o]));[...e.options].forEach(o=>{let l=a.get(o.value);l||(l=document.createElement("button"),l.type="button",l.className="ppt-flat-select__option",l.setAttribute("role","option"),l.dataset.value=o.value,l.addEventListener("click",()=>{e.value=o.value,ds(e),Ta(t),e.dispatchEvent(new Event("change",{bubbles:!0}))}),n.append(l)),l.textContent=o.textContent,o.title&&(l.title=o.title);let c=o.value===e.value;l.classList.toggle("is-selected",c),l.setAttribute("aria-selected",c?"true":"false")}),[...n.querySelectorAll(".ppt-flat-select__option")].forEach(o=>{[...e.options].some(l=>l.value===o.dataset.value)||o.remove()}),t.classList.contains("is-open")&&cs(t)}function ah(e){if(!(e instanceof Node))return!1;for(let t of Yn){let r=t.querySelector(".ppt-flat-select__menu");if(r&&(r===e||r.contains(e)))return!0}return!1}function oh(e){ah(e.target)||Da(null)}function sh(e){let t=e.target;if(t instanceof Node){for(let r of Yn)if(r.contains(t))return}Da(null)}function bc(e){if(!e||e.dataset.flatSelect==="true")return;e.dataset.flatSelect="true",e.classList.remove("ppt-flat-select"),e.classList.add("ppt-flat-select__native"),e.tabIndex=-1,e.setAttribute("aria-hidden","true");let t=document.createElement("div");t.className="ppt-flat-select";let r=document.createElement("button");r.type="button",r.className="ppt-flat-select__trigger",r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let n=document.createElement("span");n.className="ppt-flat-select__label",r.append(n);let i=document.createElement("div");i.className="ppt-flat-select__menu",i.hidden=!0,i.setAttribute("role","listbox"),i.addEventListener("wheel",o=>o.stopPropagation(),{passive:!0}),i.addEventListener("mousedown",o=>o.stopPropagation()),r.addEventListener("click",o=>{if(o.stopPropagation(),t.classList.contains("is-open")){Ta(t);return}yc(t)}),t.addEventListener("keydown",o=>{o.key==="ArrowDown"||o.key==="ArrowUp"?(o.preventDefault(),t.classList.contains("is-open")||yc(t),ih(t,o.key==="ArrowDown"?1:-1)):o.key==="Escape"&&t.classList.contains("is-open")&&(o.stopPropagation(),Ta(t),r.focus())}),e.parentNode.insertBefore(t,e),t.append(r,i,e),ds(e)}function Ci(e){ds(e)}window.__pptLiveFlatSelectBound||(window.__pptLiveFlatSelectBound=!0,document.addEventListener("click",sh),document.addEventListener("keydown",e=>{e.key==="Escape"&&Da(null)}),window.addEventListener("resize",()=>{Yn.forEach(e=>cs(e))}),document.addEventListener("scroll",oh,!0));function Tc(){document.documentElement.lang=Mr(),document.querySelectorAll("[data-i18n]").forEach(e=>{e.textContent=U(e.dataset.i18n)}),document.querySelectorAll("[data-i18n-placeholder]").forEach(e=>{e.placeholder=U(e.dataset.i18nPlaceholder)}),document.querySelectorAll("[data-i18n-aria]").forEach(e=>{e.setAttribute("aria-label",U(e.dataset.i18nAria))})}function Dc(e,t){kh(e),Tr(e),Dr(e),Ph(e,t),On(e,t),cn(e,t),Ia(e,t),zn(),document.querySelector(".ppt-live")?.setAttribute("data-density",e.style.density),document.querySelectorAll(".segment").forEach(i=>{i.classList.toggle("is-active",i.dataset.mode===e.mode)});let r=$t(e),n=Ft("slidePosition");n&&(n.textContent=`${r+1} / ${e.slides?.length||1}`)}var wc="",Pi=0,Ec=120,lh=20;function ch(e){return{x:(parseFloat(e.paddingLeft)||0)+(parseFloat(e.paddingRight)||0),y:(parseFloat(e.paddingTop)||0)+(parseFloat(e.paddingBottom)||0)}}function Bc(e,t={}){if(!e)return{width:0,height:0};let r=getComputedStyle(e),n=ch(r),i=Math.max(0,(e.clientWidth||0)-n.x),a=Math.max(0,(e.clientHeight||0)-n.y),o=e.getBoundingClientRect();o.width>0&&(i=Math.max(i,o.width-n.x)),o.height>0&&(a=Math.max(a,o.height-n.y));let l=t.minHeight??Ec,c=t.fallback;if(c&&a0&&(i=Math.max(i,s.width-n.x)),s.height>0&&(a=Math.max(a,s.height-n.y))}return{width:Math.max(0,i),height:Math.max(0,a)}}function dh(e){if(!e)return 0;let t=e.getBoundingClientRect();return Math.max(e.clientWidth||0,e.offsetWidth||0,t.width||0)}function zn(){Pi&&cancelAnimationFrame(Pi);let e=(t=0)=>{Pi=0,Jn(),ms(),Na(),Oc();let r=Ft("slideCanvas")?.closest(".canvas-area");if(!r||t>=lh)return;let{height:n}=Bc(r,{fallback:r.closest(".stage-shell")});ne(t+1)))};Pi=requestAnimationFrame(()=>e(0))}function Jn(){let e=Ft("slideCanvas"),t=e?.closest(".canvas-area"),r=e?.closest(".canvas-stage");if(!e||!t||!r)return;let{width:n,height:i}=Bc(t,{fallback:t.closest(".stage-shell")}),a=Math.max(160,n),o=Math.max(90,i),l=a,c=l*9/16;c>o&&(c=o,l=c*16/9);let s=Math.floor(l),d=Math.floor(c),u=`${a}x${o}`;if(u===wc&&r.style.width===`${s}px`&&r.style.height===`${d}px`){let p=e.querySelector(`.${gr}`);p&&mr(p);return}wc=u,r.style.width=`${s}px`,r.style.height=`${d}px`,e.style.width="100%",e.style.height="100%";let f=Ft("presentSlide");f&&(f.style.width=`${s}px`,f.style.height=`${d}px`);let h=e.querySelector(`.${gr}`);h&&mr(h)}function uh(e){let t=Ft("floatingToolbar"),r=Ft("slideCanvas");if(!t||!r||!e){t&&t.classList.remove("is-visible");return}let n=r.getBoundingClientRect(),i=e.x/100*n.width,a=e.y/100*n.height,o=e.w/100*n.width;t.style.left=`${n.left+i+o/2-t.offsetWidth/2}px`,t.style.top=`${n.top+a-t.offsetHeight-8}px`,t.classList.add("is-visible")}function us(e,t){let r=String(e||"").trim(),n=parseFloat(r);return Number.isFinite(n)?r.endsWith("pt")?n*(96/72):(r.endsWith("px"),n):t}function hs(e,t,r){return String(e||"").replace(/(^|[^-.\w]):root(?![\w-])/gi,`$1${t}`).replace(/(^|[^-.\w])html(?![\w-])/gi,`$1${t}`).replace(/(^|[^-.\w])body(?![\w-])/gi,`$1${r}`)}var gr="html-slide-preview-host",Rc="html-slide-preview-scaler",ps={width:1280,height:720};function fh(e){let t=String(e||""),r=t.match(/(?:^|[{;\s])width\s*:\s*([\d.]+)\s*pt/i),n=t.match(/(?:^|[{;\s])height\s*:\s*([\d.]+)\s*pt/i);if(r?.[1]&&n?.[1])return{width:Math.round(parseFloat(r[1])*(96/72)),height:Math.round(parseFloat(n[1])*(96/72))};let i=t.match(/(?:^|[{;\s])width\s*:\s*([\d.]+)\s*px/i),a=t.match(/(?:^|[{;\s])height\s*:\s*([\d.]+)\s*px/i);return i?.[1]&&a?.[1]?{width:Math.round(parseFloat(i[1])),height:Math.round(parseFloat(a[1]))}:{...ps}}function hh(e){let t=Number(e?.dataset?.designW),r=Number(e?.dataset?.designH);return Number.isFinite(t)&&t>=320&&Number.isFinite(r)&&r>=180?{width:t,height:r}:null}function ph(e){let t=e?.body,r=e?.documentElement,n=e?.defaultView;if(!t||!r||!n)return{...ps};let i=n.getComputedStyle(t),a=us(i.width,0),o=us(i.height,0)||us(i.minHeight,0);if(a>=320&&o>=180)return{width:a,height:o};let l=Math.max(t.scrollWidth||0,t.offsetWidth||0,r.clientWidth||0,1280),c=Math.max(t.scrollHeight||0,t.offsetHeight||0,r.clientHeight||0,720);return l=Math.min(Math.max(l,320),3840),c=Math.min(Math.max(c,180),3840),{width:l,height:c}}function Ah(e,t){let r=hh(t);return r||(e?.body?ph(e):{...ps})}function As(e){if(!e)return{width:0,height:0};let t=e.getBoundingClientRect();return{width:Math.max(e.clientWidth||0,e.offsetWidth||0,t.width||0),height:Math.max(e.clientHeight||0,e.offsetHeight||0,t.height||0)}}function Lc(e,t){let r=fh(t);return e.dataset.designW=String(r.width),e.dataset.designH=String(r.height),r}var xc="data-ppt-live-editing-style",$n="data-ppt-live-editable";function gh(e,t){!e||e._pptLiveOriginalInline||!t?.documentElement||!t.body||(e._pptLiveOriginalInline={root:t.documentElement.getAttribute("style"),body:t.body.getAttribute("style")})}function mh(e,t,r){if(!e?.documentElement||!e.body)return;let n=e.documentElement,i=e.body;n.style.margin="0",n.style.padding="0",n.style.width=`${t}px`,n.style.height=`${r}px`,n.style.overflow="hidden",i.style.margin="0",i.style.boxSizing="border-box",i.style.width=`${t}px`,i.style.height=`${r}px`,i.style.minHeight="",i.style.maxWidth="",i.style.overflow="hidden",i.style.transform="none"}function mr(e){let t=e?.classList?.contains(gr)?e:e?.closest?.(`.${gr}`);if(!t)return!1;let r=t.querySelector(`.${Rc}`),n=r?.querySelector("iframe, [data-slide-stage]");if(!r||!n)return!1;let{width:i,height:a}=As(t);if(!i||!a)return!1;let o=n.tagName==="IFRAME",l=null;if(o)try{l=n.contentDocument}catch{l=null}let{width:c,height:s}=Ah(l,n),d=Math.min(i/c,a/s),u=c*d,f=s*d;return l&&(gh(n,l),mh(l,c,s)),r.style.width=`${u}px`,r.style.height=`${f}px`,r.style.overflow="hidden",r.style.position="relative",r.style.flexShrink="0",n.style.display="block",n.style.width=`${c}px`,n.style.height=`${s}px`,n.style.border="0",n.style.margin="0",n.style.padding="0",n.style.maxWidth="none",n.style.maxHeight="none",n.style.transformOrigin="top left",n.style.transform=`scale(${d})`,!0}var Sc="ppt-slide-shadow-root",fs="ppt-slide-shadow-body";function vh(e){return e.querySelectorAll('script, iframe, object, embed, meta[http-equiv="refresh" i]').forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(let r of[...t.attributes]){let n=r.name.toLowerCase();(n.startsWith("on")||(n==="href"||n==="src"||n==="xlink:href")&&/^\s*javascript:/i.test(r.value))&&t.removeAttribute(r.name)}}),e}function yh(e,t){let r=document.createElement("div");r.className=t,r.dataset.slideStage="true",Lc(r,e);let n=Number(r.dataset.designW),i=Number(r.dataset.designH),a=vh(new DOMParser().parseFromString(Wr(e),"text/html")),o=r.attachShadow({mode:"open"}),l=document.createElement("div");l.className=Sc,l.style.cssText=["all:initial","display:block","position:relative",`width:${n}px`,`height:${i}px`,"margin:0","padding:0","overflow:hidden",'font-family:system-ui, -apple-system, "PingFang SC", "Source Han Sans SC", sans-serif',"font-size:16px","line-height:normal","color:#000","background:#fff"].join(";"),a.querySelectorAll("style").forEach(s=>{let d=document.createElement("style");d.textContent=hs(s.textContent||"",`.${Sc}`,`.${fs}`),o.appendChild(d)});let c=document.createElement("div");if(c.className=fs,a.body){for(let s of a.body.attributes)s.name==="class"?c.classList.add(...s.value.split(/\s+/).filter(Boolean)):s.name==="style"?c.style.cssText+=`;${s.value}`:s.name.toLowerCase().startsWith("on")||c.setAttribute(s.name,s.value);c.innerHTML=a.body.innerHTML}return c.style.boxSizing="border-box",/\bwidth\s*:/i.test(c.style.cssText)||(c.style.width=`${n}px`),/\bheight\s*:/i.test(c.style.cssText)||(c.style.height=`${i}px`),c.style.overflow="hidden",c.style.margin="0",l.appendChild(c),o.appendChild(l),r._pptLiveSourceHtml=String(e||""),r}function gs({hostClass:e="",frameClass:t,html:r,onReady:n,interactive:i=!1}){let a=document.createElement("div");a.className=[gr,e].filter(Boolean).join(" ");let o=document.createElement("div");if(o.className=Rc,i){let s=yh(r,t);return o.appendChild(s),a.appendChild(o),requestAnimationFrame(()=>{mr(a),n?.(s,a)}),{host:a,scaler:o,frame:s}}let l=document.createElement("iframe");l.className=t,l.setAttribute("sandbox","allow-same-origin"),l.setAttribute("loading","lazy"),Lc(l,r),l.srcdoc=Wr(r);let c=()=>{mr(a),n?.(l,a)};return l.addEventListener("load",c,{once:!0}),o.appendChild(l),a.appendChild(o),{host:a,scaler:o,frame:l}}function Nc(e){let{host:t}=gs({hostClass:"export-preview__html-stage",frameClass:"export-preview__html-frame",html:e,onReady:()=>{t.closest(".export-preview__viewport")&&mr(t)}});return t}function Ic(e){if(!e)return;let t=e.querySelector(".export-preview__viewport")||e,r=t.querySelector(".export-preview__scale");if(!r)return;let n=r.querySelector(`.${gr}`);if(n){r.style.width="100%",r.style.height="100%",mr(n);return}let i=r.querySelector(".export-preview__element-stage");if(!i)return;let{width:a,height:o}=As(t);if(!a||!o)return;let l=960,c=540,s=Math.min(a/l,o/c);i.style.width=`${l}px`,i.style.height=`${c}px`,i.style.transform=`scale(${s})`,i.style.transformOrigin="top left",r.style.width=`${Math.floor(l*s)}px`,r.style.height=`${Math.floor(c*s)}px`}function bh(e){if(!e||new Set(["turn","round","round-done","tokens","text","thinking"]).has(e.kind||""))return"";let r=String(e.detail||"").trim();return!r||/^[0-9a-f-]{8,}/i.test(r)?"":r}function Mc(e){let t=Number(e.generation?.draftedCount)||0;return t<=0?"":U("generationPageProgress",{current:t})}function wh(e){if(!e)return;(typeof requestAnimationFrame=="function"?requestAnimationFrame:r=>setTimeout(r,0))(()=>{e.scrollTop=e.scrollHeight})}function Tr(e){let t=Ft("generationSteps"),r=e.generation?.steps||[],n=Array.isArray(e.generation?.events)?e.generation.events:[],i=r.find(f=>f.id===e.generation?.current)||r.find(f=>f.status==="running")||r.find(f=>f.status==="error")||null,a=r.filter(f=>f.status==="done").length,o=!!(e.generation?.active||r.some(f=>f.status==="running")),l=r.some(f=>f.status==="error"),c=!o&&!l&&r.length>0&&a===r.length,s=r.length?Math.round(a/r.length*100):0,d=Mc(e),u=Ft("topProgress");if(u&&u.classList.toggle("is-step-progress",o&&!d),document.querySelector(".ppt-live")?.classList.toggle("is-generating",o),document.querySelector(".ppt-live")?.classList.toggle("has-generation-error",l),c?(Ur("topProgressText",U("deckReady")),Ft("topProgressMeter")?.style.setProperty("--progress","100%")):o&&d?(Ur("topProgressText",d),Ft("topProgressMeter")?.style.setProperty("--progress",`${s}%`)):o&&i?(Ur("topProgressText",`${i.label}: ${i.detail}`),Ft("topProgressMeter")?.style.setProperty("--progress",`${s}%`)):i?(Ur("topProgressText",`${i.label}: ${i.detail}`),Ft("topProgressMeter")?.style.setProperty("--progress",`${s}%`)):(Ur("topProgressText",U("ready")),Ft("topProgressMeter")?.style.setProperty("--progress",`${s}%`)),!!t){if(t.innerHTML="",n.length)n.forEach((f,h)=>{let p=bh(f),A=document.createElement("li");A.className=`generation-event is-${f.kind||"info"}`,A.innerHTML=` - ${Number(f.seq)||h+1} +var Mn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var fs={"en-US":{eyebrow:"AI Deck Studio",title:"PPT Live",newDeck:"New",newTopic:"New topic",blankDeckTitle:"Untitled deck",blankDeckReady:"Blank deck ready.",clusterDraft:"Draft",clusterReview:"Review",clusterExport:"Export",generateOutline:"Outline",generateDeck:"Generate deck",preview:"Preview",exportHtml:"HTML",exportPptx:"PPTX",workflowPrompt:"Prompt",workflowGenerate:"Generate",workflowEdit:"Edit",workflowExport:"Export",slidesPanelTitle:"Slides",slidesPanelSubcopy:"Click a page to edit text directly on canvas.",agentCommandTitle:"Create or edit by prompt",agentCommandSubcopy:"Generate a deck, revise one page, edit the whole deck, insert, or delete.",briefTitle:"Brief",agentRequestTitle:"What should this deck say?",oneBoxTitle:"Describe the deck. Then keep editing by prompt.",oneBoxSubtitle:"One command box handles drafting, page edits, deck edits, insertion, and deletion.",oneBoxPlaceholder:"Example: Build a 10-page AI product strategy deck for executives. Later: make this page more visual, rewrite the whole deck for investors, insert a risk page, or delete this page.",sendPrompt:"Send",promptRequired:"Type what you want PPT Live to do.",topicLabel:"Goal",topicPlaceholder:"Describe the deck you want. Mention page count or URLs only when you need them.",audienceLabel:"Audience",audiencePlaceholder:"Executives, customers, students...",slidesLabel:"Slides",deckTypeLabel:"Deck type",deckTypeStrategy:"Strategy",deckTypeSales:"Sales pitch",deckTypeReport:"Business report",deckTypeTeaching:"Teaching",deckTypeFundraising:"Fundraising",toneLabel:"Tone",toneExecutive:"Executive",toneConcise:"Concise",tonePersuasive:"Persuasive",toneEducational:"Educational",materialLabel:"Source material",materialPlaceholder:"Paste notes, article excerpts, data points, meeting notes, or rough slide requirements.",advancedBrief:"Optional context",processTitle:"Generation process",processSubcopy:"Track the current deck build at a glance.",historyTitle:"History",historySubcopy:"Restore a deck session and continue editing.",historyEmpty:"Generated decks and edits will appear here.",historyMeta:"{{count}} slides \xB7 {{time}}",historyRestored:"Deck session restored.",stopGeneration:"Stop",generationStopped:"Generation stopped. Kept the current view.",generationTimedOut:"Generation took too long, so PPT Live stopped this run.",generationDraftReady:"Preparing the final slides\u2026",generationAgentWorking:"Building your presentation\u2026",backendGenerationFailed:"Generation did not finish. Please retry, or stop and start a new topic.",backendGenerationFailedWithReason:"Generation did not finish: {{reason}}",generationRoundBudgetFailed:"Generation ran out of steps before the deck was ready.",generationRoundBudgetHint:"Try a shorter prompt, fewer pages, or remove extra reference links, then send again.",generationRetrying:"Generation hit an error; retrying automatically ({{attempt}}/{{max}})\u2026",generationRetryAttempt:"Retry attempt {{attempt}}/{{max}}.",generationRecoveryContinuing:"{{stage}} is still incomplete; asking the same Agent Session to continue ({{attempt}}/{{max}})\u2026",generationRecoveryExhausted:"{{stage}} did not finish after {{retries}} retries and {{continuations}} continuation turns.",generationRecoveryFailureDetail:"Last verified reason: {{reason}}",generationStagePlanning:"Planning",generationStageSlide:"Slide {{slide}}",generationStageAudit:"Final audit",agentOnlyRetryHint:"Check your connection and try again in a moment.",generationPlanPhase:"Stage 1/3 \xB7 Research and slide planning",generationPlanningSlides:"Writing per-slide briefs\u2026",generationPlanProgress:"Planning in progress: {{count}} slide briefs written\u2026",generationPlanReady:"Plan ready: {{count}} slides outlined.",generationPlanRetry:"Planning hit an error; retrying the planning stage only ({{attempt}}/{{max}})\u2026",generationAuditRetry:"Final audit is incomplete; retrying the audit stage ({{attempt}}/{{max}})\u2026",generationSlidesPhase:"Stage 2/3 \xB7 Rendering {{count}} slides serially, one Agent turn per page",generationAuditPhase:"Stage 3/3 \xB7 Auditing the full deck against the design skill and style contract",generationRenderingSlide:"Rendering slide {{slide}}/{{total}}\u2026",generationSlideReady:"Slide {{slide}}/{{total}} ready.",generationSlideRetry:"Slide {{slide}} hit an error; retrying it ({{attempt}}/{{max}})\u2026",generationSlideRepair:"Slide {{slide}} failed validation; agent repair ({{attempt}}/{{max}})\u2026",generationResumeFrom:"Resuming from slide {{slide}} \u2014 finished slides are kept.",generationPartialDeck:"Slides {{missing}} did not finish. The finished slides are kept \u2014 send a follow-up prompt to fill the missing pages.",agentWorkingTitle:"Building your deck",agentWorkingKicker:"In progress",agentWorkingClaim:"Your slides will appear in the canvas when generation finishes.",agentWorkingProof:"Progress",agentWorkingDetail:"This is a live preview area while your deck is being created.",agentWorkingSourceNote:"Content is generated from your prompt.",agentWorkingMetric:"Live",agentWorkingMetricLabel:"Waiting for slides",processEventStarted:"Generation started.",processEventWaiting:"Getting ready\u2026",processEventRound:"Organizing structure and copy.",processEventTool:"Reading sources and applying design rules.",processEventText:"Drafting slide layouts.",processEventDone:"Deck received.",generationParsingDeck:"Loading slides into the editor\u2026",processWaitingForEventsTitle:"Ready to generate",processWaitingForEvents:"Send a prompt to start. Progress will show up here.",processEventUnknown:"Update",eventTurnStarted:"Generation started",eventTurnFailed:"Generation failed",eventTurnCancelled:"Generation cancelled",eventRoundCompleted:"Step completed",eventThinkingChunk:"Thinking stream",eventTokenUsage:"Token usage updated",eventUnknownTool:"tool",eventToolDetected:"Detected tool",eventToolParams:"Reading tool input",eventToolQueued:"Queued tool",eventToolWaiting:"Waiting for tool",eventToolStarted:"Started tool",eventToolProgress:"Tool progress",eventToolStreaming:"Tool streaming",eventToolStreamChunk:"Tool output chunk",eventToolConfirmation:"Tool needs confirmation",eventToolConfirmed:"Tool confirmed",eventToolRejected:"Tool rejected",eventToolCompleted:"Completed tool",eventToolFailed:"Tool failed",eventToolCancelled:"Tool cancelled",eventToolQueuePosition:"queue",eventToolSkillName:"PPT design skill",eventToolWebSearchName:"Web search",eventToolWebFetchName:"Web page fetch",eventToolSkillReady:"Design skill loaded",generationProgressPulse:"Still generating\u2026",generationPageProgress:"Generating page {{current}}",generationSlideProgress:"{{count}} slides drafted",generationStepBrief:"Assumptions",generationStepBriefDetail:"Read the prompt and plan the deck.",generationStepSpine:"Outline",generationStepSpineDetail:"Create assertion-led slide titles from the request.",generationStepProof:"Slide copy",generationStepProofDetail:"Ground each page in source facts or clear assumptions.",generationStepDesign:"Visual design",generationStepDesignDetail:"Apply theme, layout, and visual hierarchy.",generationStepCompile:"Load slides",generationStepCompileDetail:"Load the generated deck into the editor.",generationReadingBrief:"Reading your prompt...",generationWritingClaims:"Building the outline...",generationChoosingProof:"Writing slide copy...",generationDesigningLayouts:"Designing slide layouts...",generationCompiled:"Your deck is ready.",generationSpineReady:"Claim spine ready.",generationLocalSpine:"Generation is unavailable. Please try again later.",generationLocalCompiler:"Generation is unavailable. Please try again later.",agentPlanning:"Planning the deck task...",agentPlanningFallback:"Planning is unavailable. Please try again.",outlineTitle:"Outline",outlineSubcopy:"Review the story spine before the deck is composed.",addOutlineItem:"Add outline item",syncOutline:"Sync slides from outline",modeEdit:"Edit",modeSort:"Sort",modePresent:"Present",inspectorTitle:"Inspector",addText:"Text",addList:"List",addShape:"Shape",addMetric:"Metric",addChart:"Chart",addMedia:"Media",addSlide:"Add slide",deleteSlide:"Delete slide",deleteElement:"Delete element",aiTitle:"AI design",aiSubcopy:"Prompt the agent to revise one page, the whole deck, or add a page.",instructionPlaceholder:"Example: make this page more visual, add a competition page, rewrite the whole deck for investors, or delete repetition.",reviseSlide:"Revise this page",reviseDeck:"Revise all",insertSlide:"Insert page",aiRewrite:"Rewrite",aiCondense:"Condense",aiProfessional:"Professional",aiMoreVisual:"More visual",aiNotes:"Speaker notes",aiRedesign:"Redesign slide",aiRestyleDeck:"Restyle deck",styleTitle:"Style",themeLabel:"Theme",themeExecutive:"Executive",themeMarket:"Market",themeMinimal:"Minimal",themeStudio:"Studio",densityLabel:"Density",densityCompact:"Compact",densityStandard:"Standard",densitySpacious:"Spacious",brandPrimaryLabel:"Primary",brandAccentLabel:"Accent",imagePolicyLabel:"Image policy",imagePolicyPlaceholders:"Editable placeholders",imagePolicyNone:"No images",ready:"Ready.",statusPillReady:"Ready",statusPillBusy:"AI",exportReady:"HTML and PPTX export ready after generation.",working:"Working with AI...",outlineReady:"Outline ready. Edit it, then generate the designed deck.",deckReady:"Designed deck generated.",aiUnavailable:"Generation is unavailable right now. Please try again later.",sourceGroundingRequired:"Source could not be verified. Generated a verification-first deck instead of inventing facts.",saved:"Saved.",slideUpdated:"Slide updated.",deckUpdated:"Deck updated.",slideInserted:"Page inserted.",deckRestyled:"Deck restyled.",cannotDelete:"Keep at least one slide.",noSelection:"Select a slide object to edit its content and layout.",elementTypeLabel:"Type",elementTextLabel:"Text",elementItemsLabel:"Items",elementDataLabel:"Chart data",geometryLabel:"Geometry",styleLabel:"Style",speakerNotesLabel:"Speaker notes",kickerLabel:"Kicker",claimLabel:"Claim",proofObjectLabel:"Proof object",supportNoteLabel:"Support note",sourceNoteLabel:"Source note",newSlideTitle:"New slide",defaultDeckTitle:"AI Product Strategy",slidesMeta:"{{count}} slides",exportHtmlDone:"HTML deck downloaded.",exportHtmlWorking:"Exporting HTML...",exportHtmlFailed:"HTML export failed:",exportSavedTo:"Exported to {{path}}",exportPptxWorking:"Rendering editable PPTX...",exportPptxDone:"Editable PPTX downloaded.",exportPptxFailed:"PPTX export failed:",exportPdfWorking:"Rendering PDF...",exportPdfDone:"PDF downloaded.",exportPdfFailed:"PDF export failed:",exportPngWorking:"Rendering PNG slides...",exportPngDone:"PNG slide archive downloaded.",exportPngFailed:"PNG export failed:",exportDeckEmpty:"Generate slides before exporting.",slidesEmptyHint:"Slides appear here after generation.",welcomeTitle:"Describe your deck to get started",welcomeSubcopy:"One prompt creates the outline, designed slides, and an editable deck you can refine page by page.",welcomeTip1:"10-page strategy deck",welcomeTip2:"Investor pitch rewrite",welcomeTip3:"Make this page more visual",deleteSlideDefaultPrompt:"Delete the current slide and keep the deck coherent.",prev:"Previous",next:"Next",assistantHello:"Describe the deck you need. I will build an outline first, then turn it into editable slides.",aiChatApplied:"I applied the instruction to the current slide.",localMetricLabel:"signal to remember",mediaPlaceholder:"Image placeholder",slidesUnit:"slides",closeConfirm:"Confirm the direction",closeOwner:"Choose the owner",closeIteration:"Start the next iteration",pointClaimPrefix:"Claim:",pointProofPrefix:"Proof object:",pointAudiencePrefix:"Audience relevance:",pointEvidenceRule:"Evidence rule: mark assumptions clearly",pointDesignRule:"Design rule: one visual plus one support rail",pointCloseRule:"Close: name the next action",claimCover:"{{topic}} needs a clear decision narrative, not another collection of slides.",claimPressure:"{{title}} is the pressure point the audience must resolve.",claimDecision:"{{title}} changes the decision because it connects evidence to action.",claimProof:"{{title}} becomes credible when the proof object carries the argument.",claimAction:"{{title}} should end with one named decision, owner, or next move.",supportWithSource:"Use the supplied source material to substantiate this claim; make the {{proof}} the dominant evidence.",supportWithAssumption:"Add one concrete example or metric so the {{proof}} can support the claim without filler.",sourceUserMaterial:"Source: user-provided material",sourceDraftAssumption:"Source: draft assumption; verify before external use",defaultSpeakerNote:'Open with the conclusion for "{{title}}", then support it with one concrete example.',proofMarketMap:"market map",proofOperatingModel:"operating model",proofRiskBridge:"risk bridge",proofDecisionTable:"decision table",proofBeforeAfter:"before/after workflow",proofValueBridge:"value bridge",proofCustomerProof:"customer proof",proofImplementationPlan:"implementation plan",proofMetricBridge:"metric bridge",proofTrendChart:"trend chart",proofSourceSummary:"source summary",proofVerificationPlan:"verification plan",proofCapabilityMatrix:"capability matrix",proofEvidenceList:"evidence list",proofVarianceTable:"variance table",proofRiskRegister:"risk register",proofConceptMap:"concept map",proofWorkedExample:"worked example",proofComparison:"comparison",proofPracticePrompt:"practice prompt",proofMarketWedge:"market wedge",proofProductDiagram:"product diagram",proofTractionChart:"traction chart",proofMilestonePlan:"milestone plan",proofVisualProof:"visual proof",sourceFetchedNote:"Sources: {{count}} fetched URL(s)",bpContextTitle:"{{topic}} must be grounded in source facts before claims are made.",bpSourceNeededTitle:"{{topic}} needs source material before factual claims can be made.",bpProblemTitle:"The current question is what the audience can safely believe.",bpSolutionTitle:"{{topic}} should be explained through capabilities, workflow, and evidence.",bpWorkflowTitle:"The workflow shows how the product creates value step by step.",bpProofTitle:"Source-backed evidence should carry the credibility of the deck.",bpVerificationTitle:"Verification gaps must be visible instead of hidden behind fake charts.",bpRiskTitle:"The main risk is overclaiming beyond the available source material.",bpDecisionTitle:"The next step is to verify the claims and choose the strongest story path.",bpSupportSource:"Built from fetched or pasted source material; verify exact wording before external use.",bpSupportMissing:"Source material is insufficient; keep this slide as a verification prompt.",bpMissingFact1:"Paste source notes, a README, metrics, or product description to ground this slide.",bpMissingFact2:"Do not use invented metrics; replace placeholders with verified evidence.",bpMissingFact3:"Use this page to decide what needs to be researched next.",qualityOutOfBounds:"An element extends outside the slide safe area.",qualityTextDense:"Visible text may be too dense for this layout.",qualityChartUngrounded:"Chart data was removed or flagged because it is not grounded in source numbers.",qualityOverlap:"Text or chart elements may overlap.",qualityMissingClaim:"This slide needs one clear claim.",qualityReportTitle:"Quality report",qualityNeedsReview:"Review required",qualityHasWarnings:"Quality warning",exportFormatUnavailable:"This export format is not available yet.",exportTitle:"Export",exportCancel:"Cancel",exportConfirm:"Export file",exportPreviewPrevAria:"Previous slide",exportPreviewNextAria:"Next slide",exportFormat:"Format",exportQuality:"Quality",exportDpi:"Image DPI",exportRange:"Slide range",exportShare:"Share",propertiesStyle:"Style",propertiesLayout:"Layout",propertiesAnimation:"Animation",propertiesThemeColor:"Theme color",propertiesFont:"Font",propertiesColorMode:"Slide colors",propertiesStylePreset:"Style preset",colorModeLight:"Light",colorModeDark:"Dark",fontSansSerif:"Sans-serif",fontSerif:"Serif",propertiesDensity:"Density",propertiesSmartAlign:"Smart align",propertiesPageTransition:"Page transition",propertiesElementAnimation:"Element animation",densityLoose:"Loose"},"zh-CN":{eyebrow:"AI \u6F14\u793A\u5DE5\u574A",title:"PPT Live",newDeck:"\u65B0\u5EFA",newTopic:"\u65B0\u4E3B\u9898",blankDeckTitle:"\u672A\u547D\u540D PPT",blankDeckReady:"\u7A7A\u767D PPT \u5DF2\u5C31\u7EEA\u3002",clusterDraft:"\u521B\u4F5C",clusterReview:"\u5BA1\u9605",clusterExport:"\u4EA4\u4ED8",generateOutline:"\u751F\u6210\u5927\u7EB2",generateDeck:"\u751F\u6210\u6574\u5957",preview:"\u6F14\u793A\u9884\u89C8",exportHtml:"\u5BFC\u51FA HTML",exportPptx:"\u5BFC\u51FA PPTX",workflowPrompt:"\u8F93\u5165",workflowGenerate:"\u751F\u6210",workflowEdit:"\u7F16\u8F91",workflowExport:"\u5BFC\u51FA",slidesPanelTitle:"\u9875\u9762",slidesPanelSubcopy:"\u70B9\u51FB\u9875\u9762\u540E\uFF0C\u53EF\u76F4\u63A5\u5728\u753B\u5E03\u4E0A\u6539\u6587\u5B57\u3002",agentCommandTitle:"\u7528 Prompt \u751F\u6210\u6216\u4FEE\u6539",agentCommandSubcopy:"\u751F\u6210\u6574\u5957 PPT\u3001\u4FEE\u6539\u5355\u9875\u3001\u5168\u5C40\u6539\u5199\u3001\u63D2\u5165\u6216\u5220\u9664\u9875\u9762\u3002",briefTitle:"\u521B\u4F5C\u7B80\u62A5",agentRequestTitle:"\u4F60\u60F3\u505A\u4E00\u4EFD\u4EC0\u4E48 PPT\uFF1F",oneBoxTitle:"\u63CF\u8FF0 PPT\uFF0C\u7136\u540E\u7EE7\u7EED\u7528 Prompt \u4FEE\u6539",oneBoxSubtitle:"\u9996\u7A3F\u3001\u6539\u5355\u9875\u3001\u6539\u6574\u5957\u3001\u63D2\u5165\u548C\u5220\u9664\uFF0C\u90FD\u7531\u8FD9\u4E00\u4E2A\u8F93\u5165\u6846\u5904\u7406\u3002",oneBoxPlaceholder:"\u4F8B\u5982\uFF1A\u4E3A\u9AD8\u7BA1\u751F\u6210 10 \u9875 AI \u4EA7\u54C1\u6218\u7565 PPT\u3002\u4E4B\u540E\u53EF\u4EE5\u5199\uFF1A\u628A\u672C\u9875\u6539\u5F97\u66F4\u89C6\u89C9\u5316\u3001\u6574\u5957\u6539\u6210\u6295\u8D44\u4EBA\u7248\u672C\u3001\u63D2\u5165\u4E00\u9875\u98CE\u9669\u5206\u6790\u3001\u5220\u9664\u672C\u9875\u3002",sendPrompt:"\u53D1\u9001",promptRequired:"\u8BF7\u8F93\u5165\u4F60\u5E0C\u671B PPT Live \u505A\u4EC0\u4E48\u3002",topicLabel:"\u76EE\u6807",topicPlaceholder:"\u76F4\u63A5\u63CF\u8FF0\u4F60\u60F3\u8981\u7684\u6F14\u793A\u7A3F\uFF1B\u4EC5\u5728\u9700\u8981\u65F6\u8BF4\u660E\u9875\u6570\u6216\u53C2\u8003 URL\u3002",audienceLabel:"\u53D7\u4F17",audiencePlaceholder:"\u9AD8\u7BA1\u3001\u5BA2\u6237\u3001\u5B66\u751F\u3001\u56E2\u961F\u6210\u5458...",slidesLabel:"\u9875\u6570",deckTypeLabel:"\u7C7B\u578B",deckTypeStrategy:"\u6218\u7565\u65B9\u6848",deckTypeSales:"\u9500\u552E\u63D0\u6848",deckTypeReport:"\u4E1A\u52A1\u6C47\u62A5",deckTypeTeaching:"\u6559\u5B66\u8BFE\u4EF6",deckTypeFundraising:"\u878D\u8D44\u8DEF\u6F14",toneLabel:"\u8BED\u6C14",toneExecutive:"\u9AD8\u7BA1\u98CE",toneConcise:"\u7CBE\u7B80",tonePersuasive:"\u6709\u8BF4\u670D\u529B",toneEducational:"\u6559\u5B66\u578B",materialLabel:"\u7D20\u6750",materialPlaceholder:"\u7C98\u8D34\u7B14\u8BB0\u3001\u6587\u7AE0\u7247\u6BB5\u3001\u6570\u636E\u70B9\u3001\u4F1A\u8BAE\u8BB0\u5F55\u6216\u7C97\u7565\u9875\u9762\u8981\u6C42\u3002",advancedBrief:"\u53EF\u9009\u4E0A\u4E0B\u6587",processTitle:"\u751F\u6210\u8FC7\u7A0B",processSubcopy:"\u67E5\u770B\u5F53\u524D\u6F14\u793A\u7A3F\u7684\u751F\u6210\u8FDB\u5EA6\u3002",historyTitle:"\u5386\u53F2\u8BB0\u5F55",historySubcopy:"\u6062\u590D\u4E4B\u524D\u7684 PPT \u4F1A\u8BDD\uFF0C\u5E76\u7EE7\u7EED\u4FEE\u6539\u3002",historyEmpty:"\u751F\u6210\u548C\u4FEE\u6539\u8FC7\u7684 PPT \u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002",historyMeta:"{{count}} \u9875 \xB7 {{time}}",historyRestored:"\u5DF2\u6062\u590D PPT \u4F1A\u8BDD\u3002",stopGeneration:"\u505C\u6B62",generationStopped:"\u5DF2\u505C\u6B62\u751F\u6210\uFF0C\u4FDD\u7559\u5F53\u524D\u89C6\u56FE\u3002",generationTimedOut:"\u751F\u6210\u8017\u65F6\u8FC7\u957F\uFF0C\u672C\u6B21\u8FD0\u884C\u5DF2\u505C\u6B62\u3002",generationDraftReady:"\u6B63\u5728\u6574\u7406\u6700\u7EC8\u9875\u9762\u2026",generationAgentWorking:"\u6B63\u5728\u751F\u6210\u4F60\u7684\u6F14\u793A\u7A3F\u2026",backendGenerationFailed:"\u751F\u6210\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u6216\u505C\u6B62\u540E\u91CD\u65B0\u5F00\u59CB\u3002",backendGenerationFailedWithReason:"\u751F\u6210\u672A\u5B8C\u6210\uFF1A{{reason}}",generationRoundBudgetFailed:"\u751F\u6210\u6B65\u9AA4\u8FC7\u591A\uFF0C\u6F14\u793A\u7A3F\u5C1A\u672A\u5B8C\u6210\u3002",generationRoundBudgetHint:"\u53EF\u5C1D\u8BD5\u7F29\u77ED\u63CF\u8FF0\u3001\u51CF\u5C11\u9875\u6570\u6216\u53BB\u6389\u591A\u4F59\u53C2\u8003\u94FE\u63A5\uFF0C\u7136\u540E\u91CD\u65B0\u53D1\u9001\u3002",generationRetrying:"\u751F\u6210\u51FA\u73B0\u9519\u8BEF\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationRetryAttempt:"\u7B2C {{attempt}}/{{max}} \u6B21\u5C1D\u8BD5\u3002",generationRecoveryContinuing:"{{stage}}\u4ECD\u672A\u5B8C\u6210\uFF0C\u6B63\u5728\u8BA9\u540C\u4E00\u4E2A Agent Session \u7EE7\u7EED\u6267\u884C\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationRecoveryExhausted:"{{stage}}\u5728 {{retries}} \u6B21\u91CD\u8BD5\u548C {{continuations}} \u6B21\u7EE7\u7EED\u6267\u884C\u540E\u4ECD\u672A\u5B8C\u6210\u3002",generationRecoveryFailureDetail:"\u6700\u540E\u4E00\u6B21\u53EF\u9A8C\u8BC1\u7684\u5931\u8D25\u539F\u56E0\uFF1A{{reason}}",generationStagePlanning:"\u89C4\u5212\u9636\u6BB5",generationStageSlide:"\u7B2C {{slide}} \u9875",generationStageAudit:"\u6700\u7EC8\u5BA1\u8BA1",agentOnlyRetryHint:"\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\uFF0C\u7A0D\u540E\u518D\u8BD5\u3002",generationPlanPhase:"\u9636\u6BB5 1/3 \xB7 \u7814\u7A76\u4E0E\u5168\u7BC7\u89C4\u5212",generationPlanningSlides:"\u6B63\u5728\u7F16\u5199\u6BCF\u9875\u5185\u5BB9\u7B80\u62A5\u2026",generationPlanProgress:"\u89C4\u5212\u8FDB\u884C\u4E2D\uFF1A\u5DF2\u5199\u5B8C {{count}} \u9875\u7B80\u62A5\u2026",generationPlanReady:"\u89C4\u5212\u5B8C\u6210\uFF1A\u5171 {{count}} \u9875\u3002",generationPlanRetry:"\u89C4\u5212\u9636\u6BB5\u51FA\u9519\uFF0C\u4EC5\u91CD\u8BD5\u89C4\u5212\u9636\u6BB5\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationAuditRetry:"\u6700\u7EC8\u5BA1\u8BA1\u5C1A\u672A\u5B8C\u6210\uFF0C\u6B63\u5728\u91CD\u8BD5\u5BA1\u8BA1\u9636\u6BB5\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationSlidesPhase:"\u9636\u6BB5 2/3 \xB7 \u4E32\u884C\u6E32\u67D3 {{count}} \u9875\uFF0C\u6BCF\u9875\u4E00\u6B21 Agent \u8C03\u7528",generationAuditPhase:"\u9636\u6BB5 3/3 \xB7 \u6309\u8BBE\u8BA1 Skill \u4E0E\u6837\u5F0F\u5951\u7EA6\u5BA1\u8BA1\u6574\u5957\u5E7B\u706F\u7247",generationRenderingSlide:"\u6B63\u5728\u6E32\u67D3\u7B2C {{slide}}/{{total}} \u9875\u2026",generationSlideReady:"\u7B2C {{slide}}/{{total}} \u9875\u5DF2\u5B8C\u6210\u3002",generationSlideRetry:"\u7B2C {{slide}} \u9875\u51FA\u9519\uFF0C\u6B63\u5728\u91CD\u8BD5\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationSlideRepair:"\u7B2C {{slide}} \u9875\u6821\u9A8C\u672A\u901A\u8FC7\uFF0CAgent \u4FEE\u590D\u4E2D\uFF08{{attempt}}/{{max}}\uFF09\u2026",generationResumeFrom:"\u4ECE\u7B2C {{slide}} \u9875\u7EE7\u7EED\u751F\u6210\uFF0C\u5DF2\u5B8C\u6210\u7684\u9875\u9762\u4FDD\u7559\u3002",generationPartialDeck:"\u7B2C {{missing}} \u9875\u672A\u5B8C\u6210\u3002\u5DF2\u5B8C\u6210\u7684\u9875\u9762\u5DF2\u4FDD\u7559\uFF0C\u53EF\u7EE7\u7EED\u53D1\u9001\u6307\u4EE4\u8865\u5168\u7F3A\u5931\u9875\u3002",agentWorkingTitle:"\u6B63\u5728\u751F\u6210\u6F14\u793A\u7A3F",agentWorkingKicker:"\u751F\u6210\u4E2D",agentWorkingClaim:"\u5B8C\u6210\u540E\uFF0C\u6700\u7EC8\u9875\u9762\u4F1A\u51FA\u73B0\u5728\u4E2D\u95F4\u753B\u5E03\u3002",agentWorkingProof:"\u8FDB\u5EA6",agentWorkingDetail:"\u8FD9\u662F\u751F\u6210\u8FC7\u7A0B\u4E2D\u7684\u9884\u89C8\u533A\u57DF\u3002",agentWorkingSourceNote:"\u5185\u5BB9\u5C06\u6839\u636E\u4F60\u7684 Prompt \u81EA\u52A8\u751F\u6210\u3002",agentWorkingMetric:"Live",agentWorkingMetricLabel:"\u7B49\u5F85\u9875\u9762\u751F\u6210",processEventStarted:"\u5DF2\u5F00\u59CB\u751F\u6210\u3002",processEventWaiting:"\u51C6\u5907\u5F00\u59CB\u2026",processEventRound:"\u6B63\u5728\u7EC4\u7EC7\u5185\u5BB9\u4E0E\u7ED3\u6784\u3002",processEventTool:"\u6B63\u5728\u8BFB\u53D6\u7D20\u6750\u5E76\u5E94\u7528\u8BBE\u8BA1\u89C4\u5219\u3002",processEventText:"\u6B63\u5728\u64B0\u5199\u9875\u9762\u5E03\u5C40\u3002",processEventDone:"\u6F14\u793A\u7A3F\u5DF2\u751F\u6210\u3002",generationParsingDeck:"\u6B63\u5728\u52A0\u8F7D\u9875\u9762\u5230\u7F16\u8F91\u5668\u2026",processWaitingForEventsTitle:"\u7B49\u5F85\u5F00\u59CB",processWaitingForEvents:"\u53D1\u9001 Prompt \u540E\uFF0C\u8FD9\u91CC\u4F1A\u663E\u793A\u751F\u6210\u8FDB\u5EA6\u3002",processEventUnknown:"\u8FDB\u5EA6\u66F4\u65B0",eventTurnStarted:"\u5F00\u59CB\u751F\u6210",eventTurnFailed:"\u751F\u6210\u5931\u8D25",eventTurnCancelled:"\u751F\u6210\u5DF2\u53D6\u6D88",eventRoundCompleted:"\u672C\u9636\u6BB5\u5DF2\u5B8C\u6210",eventThinkingChunk:"\u601D\u8003\u6D41",eventTokenUsage:"Token \u7528\u91CF\u66F4\u65B0",eventUnknownTool:"\u5DE5\u5177",eventToolDetected:"\u68C0\u6D4B\u5230\u5DE5\u5177",eventToolParams:"\u6B63\u5728\u8BFB\u53D6\u5DE5\u5177\u53C2\u6570",eventToolQueued:"\u5DE5\u5177\u5DF2\u6392\u961F",eventToolWaiting:"\u7B49\u5F85\u5DE5\u5177\u6267\u884C",eventToolStarted:"\u5F00\u59CB\u8C03\u7528\u5DE5\u5177",eventToolProgress:"\u5DE5\u5177\u8FDB\u5EA6",eventToolStreaming:"\u5DE5\u5177\u6D41\u5F0F\u8F93\u51FA",eventToolStreamChunk:"\u5DE5\u5177\u8F93\u51FA\u7247\u6BB5",eventToolConfirmation:"\u5DE5\u5177\u9700\u8981\u786E\u8BA4",eventToolConfirmed:"\u5DE5\u5177\u5DF2\u786E\u8BA4",eventToolRejected:"\u5DE5\u5177\u5DF2\u62D2\u7EDD",eventToolCompleted:"\u5DE5\u5177\u6267\u884C\u5B8C\u6210",eventToolFailed:"\u5DE5\u5177\u6267\u884C\u5931\u8D25",eventToolCancelled:"\u5DE5\u5177\u5DF2\u53D6\u6D88",eventToolQueuePosition:"\u961F\u5217\u4F4D\u7F6E",eventToolSkillName:"PPT \u8BBE\u8BA1\u89C4\u8303",eventToolWebSearchName:"\u7F51\u9875\u641C\u7D22",eventToolWebFetchName:"\u7F51\u9875\u8BFB\u53D6",eventToolSkillReady:"\u8BBE\u8BA1\u89C4\u8303\u5DF2\u5C31\u7EEA",generationProgressPulse:"\u4ECD\u5728\u751F\u6210\u4E2D\u2026",generationPageProgress:"\u6B63\u5728\u751F\u6210\u7B2C {{current}} \u9875",generationSlideProgress:"\u5DF2\u8D77\u8349 {{count}} \u9875",generationStepBrief:"\u53D1\u5E03\u5047\u8BBE",generationStepBriefDetail:"\u9605\u8BFB Prompt \u5E76\u89C4\u5212\u6F14\u793A\u7A3F\u3002",generationStepSpine:"\u751F\u6210\u5927\u7EB2",generationStepSpineDetail:"\u628A\u9700\u6C42\u8F6C\u6210\u65AD\u8A00\u5F0F\u9875\u9762\u6807\u9898\u3002",generationStepProof:"\u9875\u9762\u6587\u6848",generationStepProofDetail:"\u7528\u7D20\u6750\u4E8B\u5B9E\u6216\u660E\u786E\u5047\u8BBE\u652F\u6491\u6BCF\u9875\u3002",generationStepDesign:"\u8BBE\u8BA1\u6392\u7248",generationStepDesignDetail:"\u5E94\u7528\u4E3B\u9898\u3001\u7248\u5F0F\u4E0E\u89C6\u89C9\u5C42\u6B21\u3002",generationStepCompile:"\u52A0\u8F7D\u9875\u9762",generationStepCompileDetail:"\u5C06\u751F\u6210\u7ED3\u679C\u52A0\u8F7D\u4E3A\u53EF\u7F16\u8F91\u9875\u9762\u3002",generationReadingBrief:"\u6B63\u5728\u7406\u89E3\u4F60\u7684 Prompt\u2026",generationWritingClaims:"\u6B63\u5728\u751F\u6210\u5927\u7EB2\u2026",generationChoosingProof:"\u6B63\u5728\u64B0\u5199\u9875\u9762\u6587\u6848\u2026",generationDesigningLayouts:"\u6B63\u5728\u8BBE\u8BA1\u9875\u9762\u7248\u5F0F\u2026",generationCompiled:"\u6F14\u793A\u7A3F\u5DF2\u5C31\u7EEA\u3002",generationSpineReady:"\u8BBA\u70B9\u4E3B\u7EBF\u5DF2\u751F\u6210\u3002",generationLocalSpine:"\u751F\u6210\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",generationLocalCompiler:"\u751F\u6210\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",agentPlanning:"\u6B63\u5728\u89C4\u5212\u6F14\u793A\u7A3F\u2026",agentPlanningFallback:"\u89C4\u5212\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",outlineTitle:"\u5927\u7EB2",outlineSubcopy:"\u5148\u786E\u8BA4\u6BCF\u4E00\u9875\u7684\u6545\u4E8B\u4E3B\u7EBF\uFF0C\u518D\u751F\u6210\u5B8C\u6574\u9875\u9762\u3002",addOutlineItem:"\u6DFB\u52A0\u5927\u7EB2\u9879",syncOutline:"\u7528\u5927\u7EB2\u540C\u6B65\u9875\u9762",modeEdit:"\u7F16\u8F91",modeSort:"\u6392\u5E8F",modePresent:"\u6F14\u793A",inspectorTitle:"\u68C0\u67E5\u5668",addText:"\u6587\u5B57",addList:"\u5217\u8868",addShape:"\u5F62\u72B6",addMetric:"\u6307\u6807",addChart:"\u56FE\u8868",addMedia:"\u5A92\u4F53",addSlide:"\u6DFB\u52A0\u9875\u9762",deleteSlide:"\u5220\u9664\u9875\u9762",deleteElement:"\u5220\u9664\u5143\u7D20",aiTitle:"AI \u8BBE\u8BA1",aiSubcopy:"\u7528 Prompt \u4FEE\u6539\u5F53\u524D\u9875\u3001\u6574\u5957 PPT\uFF0C\u6216\u63D2\u5165\u65B0\u9875\u3002",instructionPlaceholder:"\u4F8B\u5982\uFF1A\u8BA9\u672C\u9875\u66F4\u89C6\u89C9\u5316\uFF1B\u589E\u52A0\u4E00\u9875\u7ADE\u54C1\u5BF9\u6BD4\uFF1B\u6574\u5957\u6539\u6210\u878D\u8D44\u8DEF\u6F14\u98CE\u683C\uFF1B\u5220\u9664\u91CD\u590D\u5185\u5BB9\u3002",reviseSlide:"\u4FEE\u6539\u672C\u9875",reviseDeck:"\u4FEE\u6539\u6574\u5957",insertSlide:"\u63D2\u5165\u65B0\u9875",aiRewrite:"\u6539\u5199",aiCondense:"\u538B\u7F29",aiProfessional:"\u4E13\u4E1A\u5316",aiMoreVisual:"\u66F4\u89C6\u89C9\u5316",aiNotes:"\u6F14\u8BB2\u5907\u6CE8",aiRedesign:"\u91CD\u6392\u672C\u9875",aiRestyleDeck:"\u91CD\u5851\u6574\u5957\u98CE\u683C",styleTitle:"\u98CE\u683C",themeLabel:"\u4E3B\u9898",themeExecutive:"\u9AD8\u7BA1",themeMarket:"\u5E02\u573A",themeMinimal:"\u6781\u7B80",themeStudio:"\u521B\u610F",densityLabel:"\u5BC6\u5EA6",densityCompact:"\u7D27\u51D1",densityStandard:"\u6807\u51C6",densitySpacious:"\u8212\u5C55",brandPrimaryLabel:"\u4E3B\u8272",brandAccentLabel:"\u5F3A\u8C03\u8272",imagePolicyLabel:"\u56FE\u7247\u7B56\u7565",imagePolicyPlaceholders:"\u53EF\u7F16\u8F91\u5360\u4F4D",imagePolicyNone:"\u4E0D\u4F7F\u7528\u56FE\u7247",ready:"\u51C6\u5907\u5C31\u7EEA\u3002",statusPillReady:"\u5C31\u7EEA",statusPillBusy:"AI",exportReady:"\u751F\u6210\u540E\u53EF\u5BFC\u51FA HTML \u548C\u53EF\u7F16\u8F91 PPTX\u3002",working:"AI \u6B63\u5728\u5904\u7406...",outlineReady:"\u5927\u7EB2\u5DF2\u751F\u6210\u3002\u53EF\u5148\u8C03\u6574\u5927\u7EB2\uFF0C\u518D\u751F\u6210\u8BBE\u8BA1\u7A3F\u3002",deckReady:"\u8BBE\u8BA1\u7A3F\u5DF2\u751F\u6210\u3002",aiUnavailable:"\u751F\u6210\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",sourceGroundingRequired:"\u6765\u6E90\u65E0\u6CD5\u9A8C\u8BC1\u3002\u5DF2\u751F\u6210\u201C\u5148\u9A8C\u8BC1\u201D\u7684\u6F14\u793A\u7A3F\uFF0C\u800C\u4E0D\u662F\u7F16\u9020\u4E8B\u5B9E\u3002",saved:"\u5DF2\u4FDD\u5B58\u3002",slideUpdated:"\u9875\u9762\u5DF2\u66F4\u65B0\u3002",deckUpdated:"\u6574\u5957\u5DF2\u66F4\u65B0\u3002",slideInserted:"\u65B0\u9875\u9762\u5DF2\u63D2\u5165\u3002",deckRestyled:"\u6574\u5957\u98CE\u683C\u5DF2\u66F4\u65B0\u3002",cannotDelete:"\u81F3\u5C11\u4FDD\u7559\u4E00\u9875\u3002",noSelection:"\u9009\u62E9\u4E00\u4E2A\u9875\u9762\u5143\u7D20\u540E\u53EF\u7F16\u8F91\u5185\u5BB9\u548C\u5E03\u5C40\u3002",elementTypeLabel:"\u7C7B\u578B",elementTextLabel:"\u6587\u5B57",elementItemsLabel:"\u6761\u76EE",elementDataLabel:"\u56FE\u8868\u6570\u636E",geometryLabel:"\u4F4D\u7F6E\u5C3A\u5BF8",styleLabel:"\u6837\u5F0F",speakerNotesLabel:"\u6F14\u8BB2\u5907\u6CE8",kickerLabel:"\u7709\u6807",claimLabel:"\u8BBA\u70B9",proofObjectLabel:"\u8BC1\u636E\u5BF9\u8C61",supportNoteLabel:"\u652F\u6491\u8BF4\u660E",sourceNoteLabel:"\u6765\u6E90\u8BF4\u660E",newSlideTitle:"\u65B0\u9875\u9762",defaultDeckTitle:"AI \u4EA7\u54C1\u6218\u7565",slidesMeta:"{{count}} \u9875",exportHtmlDone:"HTML \u6F14\u793A\u7A3F\u5DF2\u4E0B\u8F7D\u3002",exportHtmlWorking:"\u6B63\u5728\u5BFC\u51FA HTML...",exportHtmlFailed:"HTML \u5BFC\u51FA\u5931\u8D25\uFF1A",exportSavedTo:"\u5DF2\u5BFC\u51FA\u5230 {{path}}",exportPptxWorking:"\u6B63\u5728\u6E32\u67D3\u53EF\u7F16\u8F91 PPTX...",exportPptxDone:"\u53EF\u7F16\u8F91 PPTX \u5DF2\u4E0B\u8F7D\u3002",exportPptxFailed:"PPTX \u5BFC\u51FA\u5931\u8D25\uFF1A",exportPdfWorking:"\u6B63\u5728\u6E32\u67D3 PDF...",exportPdfDone:"PDF \u5DF2\u4E0B\u8F7D\u3002",exportPdfFailed:"PDF \u5BFC\u51FA\u5931\u8D25\uFF1A",exportPngWorking:"\u6B63\u5728\u6E32\u67D3 PNG \u9875\u9762...",exportPngDone:"PNG \u9875\u9762\u538B\u7F29\u5305\u5DF2\u4E0B\u8F7D\u3002",exportPngFailed:"PNG \u5BFC\u51FA\u5931\u8D25\uFF1A",exportDeckEmpty:"\u8BF7\u5148\u751F\u6210\u5E7B\u706F\u7247\u540E\u518D\u5BFC\u51FA\u3002",slidesEmptyHint:"\u751F\u6210\u540E\u9875\u9762\u7F29\u7565\u56FE\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002",welcomeTitle:"\u63CF\u8FF0\u4F60\u7684 PPT\uFF0C\u4E00\u952E\u5F00\u59CB",welcomeSubcopy:"\u4E00\u6761 Prompt \u5373\u53EF\u751F\u6210\u5927\u7EB2\u3001\u8BBE\u8BA1\u9875\u9762\u548C\u53EF\u7F16\u8F91\u6F14\u793A\u7A3F\uFF0C\u4E4B\u540E\u53EF\u9010\u9875\u7EE7\u7EED\u4FEE\u6539\u3002",welcomeTip1:"10 \u9875\u6218\u7565\u65B9\u6848",welcomeTip2:"\u6539\u6210\u6295\u8D44\u4EBA\u7248\u672C",welcomeTip3:"\u672C\u9875\u66F4\u89C6\u89C9\u5316",deleteSlideDefaultPrompt:"\u5220\u9664\u5F53\u524D\u9875\u9762\uFF0C\u5E76\u4FDD\u6301\u6574\u5957 PPT \u7ED3\u6784\u8FDE\u8D2F\u3002",prev:"\u4E0A\u4E00\u9875",next:"\u4E0B\u4E00\u9875",assistantHello:"\u544A\u8BC9\u6211\u4F60\u8981\u505A\u4EC0\u4E48 PPT\u3002\u6211\u4F1A\u5148\u751F\u6210\u5927\u7EB2\uFF0C\u518D\u53D8\u6210\u53EF\u7F16\u8F91\u9875\u9762\u3002",aiChatApplied:"\u5DF2\u628A\u6307\u4EE4\u5E94\u7528\u5230\u5F53\u524D\u9875\u9762\u3002",localMetricLabel:"\u9700\u8981\u8BB0\u4F4F\u7684\u4FE1\u53F7",mediaPlaceholder:"\u56FE\u7247\u5360\u4F4D",slidesUnit:"\u9875",closeConfirm:"\u786E\u8BA4\u65B9\u5411",closeOwner:"\u660E\u786E\u8D1F\u8D23\u4EBA",closeIteration:"\u542F\u52A8\u4E0B\u4E00\u8F6E\u8FED\u4EE3",pointClaimPrefix:"\u8BBA\u70B9\uFF1A",pointProofPrefix:"\u8BC1\u636E\u5BF9\u8C61\uFF1A",pointAudiencePrefix:"\u53D7\u4F17\u5173\u8054\uFF1A",pointEvidenceRule:"\u8BC1\u636E\u89C4\u5219\uFF1A\u660E\u786E\u6807\u6CE8\u5047\u8BBE",pointDesignRule:"\u8BBE\u8BA1\u89C4\u5219\uFF1A\u4E00\u4E2A\u4E3B\u89C6\u89C9\u52A0\u4E00\u4E2A\u652F\u6491\u680F",pointCloseRule:"\u6536\u675F\uFF1A\u8BF4\u6E05\u4E0B\u4E00\u6B65\u884C\u52A8",claimCover:"{{topic}} \u9700\u8981\u4E00\u6761\u6E05\u6670\u7684\u51B3\u7B56\u4E3B\u7EBF\uFF0C\u800C\u4E0D\u662F\u4FE1\u606F\u5806\u780C\u3002",claimPressure:"{{title}} \u662F\u53D7\u4F17\u5FC5\u987B\u89E3\u51B3\u7684\u5173\u952E\u538B\u529B\u70B9\u3002",claimDecision:"{{title}} \u4E4B\u6240\u4EE5\u91CD\u8981\uFF0C\u662F\u56E0\u4E3A\u5B83\u628A\u8BC1\u636E\u8FDE\u63A5\u5230\u884C\u52A8\u3002",claimProof:"{{title}} \u5FC5\u987B\u7531\u9875\u9762\u91CC\u7684\u4E3B\u8BC1\u636E\u5BF9\u8C61\u6765\u627F\u62C5\u8BBA\u8BC1\u3002",claimAction:"{{title}} \u6700\u540E\u8981\u843D\u5230\u4E00\u4E2A\u660E\u786E\u51B3\u7B56\u3001\u8D1F\u8D23\u4EBA\u6216\u4E0B\u4E00\u6B65\u3002",supportWithSource:"\u7528\u5DF2\u63D0\u4F9B\u7D20\u6750\u652F\u6491\u8FD9\u4E2A\u8BBA\u70B9\uFF0C\u5E76\u8BA9\u201C{{proof}}\u201D\u6210\u4E3A\u4E3B\u8BC1\u636E\u3002",supportWithAssumption:"\u8865\u5145\u4E00\u4E2A\u5177\u4F53\u4F8B\u5B50\u6216\u6307\u6807\uFF0C\u8BA9\u201C{{proof}}\u201D\u652F\u6491\u8BBA\u70B9\uFF0C\u800C\u4E0D\u662F\u586B\u5145\u6587\u5B57\u3002",sourceUserMaterial:"\u6765\u6E90\uFF1A\u7528\u6237\u63D0\u4F9B\u7D20\u6750",sourceDraftAssumption:"\u6765\u6E90\uFF1A\u8349\u7A3F\u5047\u8BBE\uFF1B\u5BF9\u5916\u4F7F\u7528\u524D\u9700\u786E\u8BA4",defaultSpeakerNote:"\u5148\u8BB2\u201C{{title}}\u201D\u7684\u7ED3\u8BBA\uFF0C\u518D\u7528\u4E00\u4E2A\u5177\u4F53\u4F8B\u5B50\u6216\u6570\u636E\u652F\u6491\u3002",proofMarketMap:"\u5E02\u573A\u5730\u56FE",proofOperatingModel:"\u8FD0\u8425\u6A21\u578B",proofRiskBridge:"\u98CE\u9669\u6865",proofDecisionTable:"\u51B3\u7B56\u8868",proofBeforeAfter:"\u524D\u540E\u5BF9\u6BD4\u6D41\u7A0B",proofValueBridge:"\u4EF7\u503C\u6865",proofCustomerProof:"\u5BA2\u6237\u8BC1\u636E",proofImplementationPlan:"\u5B9E\u65BD\u8BA1\u5212",proofMetricBridge:"\u6307\u6807\u6865",proofTrendChart:"\u8D8B\u52BF\u56FE",proofSourceSummary:"\u6765\u6E90\u6458\u8981",proofVerificationPlan:"\u9A8C\u8BC1\u8BA1\u5212",proofCapabilityMatrix:"\u80FD\u529B\u77E9\u9635",proofEvidenceList:"\u8BC1\u636E\u5217\u8868",proofVarianceTable:"\u5DEE\u5F02\u8868",proofRiskRegister:"\u98CE\u9669\u6E05\u5355",proofConceptMap:"\u6982\u5FF5\u56FE",proofWorkedExample:"\u6848\u4F8B\u6F14\u7B97",proofComparison:"\u5BF9\u6BD4",proofPracticePrompt:"\u7EC3\u4E60\u63D0\u793A",proofMarketWedge:"\u5E02\u573A\u5207\u5165\u70B9",proofProductDiagram:"\u4EA7\u54C1\u56FE",proofTractionChart:"\u7275\u5F15\u529B\u56FE\u8868",proofMilestonePlan:"\u91CC\u7A0B\u7891\u8BA1\u5212",proofVisualProof:"\u89C6\u89C9\u8BC1\u636E",sourceFetchedNote:"\u6765\u6E90\uFF1A\u5DF2\u8BFB\u53D6 {{count}} \u4E2A URL",bpContextTitle:"{{topic}} \u9700\u8981\u5148\u5EFA\u7ACB\u5728\u6765\u6E90\u4E8B\u5B9E\u4E4B\u4E0A\uFF0C\u518D\u63D0\u51FA\u5224\u65AD\u3002",bpSourceNeededTitle:"{{topic}} \u9700\u8981\u8865\u5145\u6765\u6E90\u7D20\u6750\u540E\u624D\u80FD\u63D0\u51FA\u4E8B\u5B9E\u6027\u7ED3\u8BBA\u3002",bpProblemTitle:"\u5F53\u524D\u5173\u952E\u95EE\u9898\u662F\uFF1A\u53D7\u4F17\u53EF\u4EE5\u5B89\u5168\u76F8\u4FE1\u4EC0\u4E48\u3002",bpSolutionTitle:"{{topic}} \u5E94\u901A\u8FC7\u80FD\u529B\u3001\u6D41\u7A0B\u548C\u8BC1\u636E\u6765\u89E3\u91CA\u3002",bpWorkflowTitle:"\u5DE5\u4F5C\u6D41\u9700\u8981\u5C55\u793A\u4EA7\u54C1\u5982\u4F55\u4E00\u6B65\u6B65\u521B\u9020\u4EF7\u503C\u3002",bpProofTitle:"\u53EF\u4FE1\u5EA6\u5E94\u8BE5\u7531\u6765\u6E90\u8BC1\u636E\u627F\u62C5\uFF0C\u800C\u4E0D\u662F\u7531\u5047\u56FE\u8868\u627F\u62C5\u3002",bpVerificationTitle:"\u9A8C\u8BC1\u7F3A\u53E3\u5FC5\u987B\u663E\u6027\u5C55\u793A\uFF0C\u4E0D\u80FD\u85CF\u5728\u865A\u6784\u56FE\u8868\u540E\u9762\u3002",bpRiskTitle:"\u6700\u5927\u98CE\u9669\u662F\u8D85\u51FA\u5DF2\u6709\u7D20\u6750\u8FC7\u5EA6\u58F0\u79F0\u3002",bpDecisionTitle:"\u4E0B\u4E00\u6B65\u662F\u9A8C\u8BC1\u5173\u952E\u8BBA\u70B9\uFF0C\u5E76\u9009\u62E9\u6700\u5F3A\u53D9\u4E8B\u8DEF\u5F84\u3002",bpSupportSource:"\u57FA\u4E8E\u5DF2\u8BFB\u53D6\u6216\u7C98\u8D34\u7D20\u6750\u751F\u6210\uFF1B\u5BF9\u5916\u4F7F\u7528\u524D\u8BF7\u6838\u5BF9\u539F\u6587\u3002",bpSupportMissing:"\u7D20\u6750\u4E0D\u8DB3\uFF1B\u672C\u9875\u5E94\u4F5C\u4E3A\u9A8C\u8BC1\u63D0\u793A\uFF0C\u800C\u4E0D\u662F\u4E8B\u5B9E\u7ED3\u8BBA\u3002",bpMissingFact1:"\u8BF7\u7C98\u8D34\u6765\u6E90\u7B14\u8BB0\u3001README\u3001\u6307\u6807\u6216\u4EA7\u54C1\u63CF\u8FF0\u6765\u652F\u6491\u672C\u9875\u3002",bpMissingFact2:"\u4E0D\u8981\u4F7F\u7528\u865A\u6784\u6307\u6807\uFF1B\u7528\u5DF2\u9A8C\u8BC1\u8BC1\u636E\u66FF\u6362\u5360\u4F4D\u5185\u5BB9\u3002",bpMissingFact3:"\u7528\u672C\u9875\u51B3\u5B9A\u4E0B\u4E00\u6B65\u9700\u8981\u8865\u5145\u7814\u7A76\u4EC0\u4E48\u3002",qualityOutOfBounds:"\u6709\u5143\u7D20\u8D85\u51FA\u5E7B\u706F\u7247\u5B89\u5168\u533A\u57DF\u3002",qualityTextDense:"\u5F53\u524D\u7248\u5F0F\u4E2D\u7684\u53EF\u89C1\u6587\u5B57\u53EF\u80FD\u8FC7\u5BC6\u3002",qualityChartUngrounded:"\u56FE\u8868\u6570\u636E\u7F3A\u5C11\u6765\u6E90\u6570\u5B57\uFF0C\u5DF2\u79FB\u9664\u6216\u6807\u8BB0\u3002",qualityOverlap:"\u6587\u5B57\u6216\u56FE\u8868\u5143\u7D20\u53EF\u80FD\u53D1\u751F\u91CD\u53E0\u3002",qualityMissingClaim:"\u672C\u9875\u9700\u8981\u4E00\u4E2A\u6E05\u6670\u8BBA\u70B9\u3002",qualityReportTitle:"\u8D28\u91CF\u62A5\u544A",qualityNeedsReview:"\u9700\u8981\u590D\u6838",qualityHasWarnings:"\u8D28\u91CF\u63D0\u9192",exportFormatUnavailable:"\u8BE5\u5BFC\u51FA\u683C\u5F0F\u5C1A\u672A\u652F\u6301\u3002",exportTitle:"\u5BFC\u51FA",exportCancel:"\u53D6\u6D88",exportConfirm:"\u5BFC\u51FA\u6587\u4EF6",exportPreviewPrevAria:"\u4E0A\u4E00\u9875",exportPreviewNextAria:"\u4E0B\u4E00\u9875",exportFormat:"\u683C\u5F0F",exportQuality:"\u8D28\u91CF",exportDpi:"\u56FE\u7247 DPI",exportRange:"\u5E7B\u706F\u7247\u8303\u56F4",exportShare:"\u5206\u4EAB",propertiesStyle:"\u6837\u5F0F",propertiesLayout:"\u5E03\u5C40",propertiesAnimation:"\u52A8\u753B",propertiesThemeColor:"\u4E3B\u9898\u8272",propertiesFont:"\u5B57\u4F53",propertiesColorMode:"\u5E7B\u706F\u7247\u914D\u8272",propertiesStylePreset:"\u98CE\u683C\u9884\u8BBE",colorModeLight:"\u6D45\u8272",colorModeDark:"\u6DF1\u8272",fontSansSerif:"\u975E\u886C\u7EBF",fontSerif:"\u886C\u7EBF",propertiesDensity:"\u5BC6\u5EA6",propertiesSmartAlign:"\u667A\u80FD\u5BF9\u9F50",propertiesPageTransition:"\u9875\u9762\u8FC7\u6E21",propertiesElementAnimation:"\u5143\u7D20\u52A8\u753B",densityLoose:"\u5BBD\u677E"}};function lr(){let e=window.app?.locale||document.documentElement.lang||"";return e==="zh-CN"||String(e).startsWith("zh")?"zh-CN":"en-US"}function O(e,t={}){let r=fs[lr()]||fs["en-US"],n=fs["en-US"][e]||e,i=r[e]||n;return Object.entries(t).forEach(([a,o])=>{i=i.replaceAll(`{{${a}}}`,String(o))}),i}var xh=["clean-business","insight-report"],Fa={"clean-business":{styleKey:"clean-business",names:{"en-US":"Clean Business","zh-CN":"\u7B80\u6D01\u5546\u52A1"},descriptions:{"en-US":"Calm editorial product-doc: warm canvas, charcoal type, one restrained accent, typography-led","zh-CN":"\u5E73\u9759\u7F16\u8F91\u611F\u4EA7\u54C1\u6587\u6863\uFF1A\u6696\u767D\u753B\u5E03\u3001\u70AD\u9ED1\u5B57\u9636\u3001\u5355\u4E00\u514B\u5236\u5F3A\u8C03\u8272\uFF0C\u6392\u7248\u5373\u89C6\u89C9"},colorMode:"light",palette:{background:"#FAFAF7",ink:"#111111",muted:"#787774",primary:"#1E293B",accent:"#0f766e",panel:"#F3F2EF"},fontFamily:"sans",density:"spacious",keywords:/business|clean|professional|商务|简洁|专业|企业/},"insight-report":{styleKey:"insight-report",names:{"en-US":"Insight Report","zh-CN":"\u6D1E\u5BDF\u6C47\u62A5"},descriptions:{"en-US":"Analytical memo on a slide: full sentences, explicit frameworks, evidence-dense tables","zh-CN":"\u5206\u6790\u5907\u5FD8\u5F55\u4E0A\u5899\uFF1A\u5B8C\u6574\u8BBA\u8BC1\u3001\u663E\u6027\u6846\u67B6\u3001\u6EE1\u7248\u8BC1\u636E\uFF0C\u50CF\u5C3D\u8C03\u9644\u5F55\u800C\u975E bullet \u6F14\u8BB2"},colorMode:"light",palette:{background:"#ffffff",ink:"#1f2937",muted:"#64748b",primary:"#1e3a8a",accent:"#dc2626",panel:"#f1f5f9"},fontFamily:"sans",density:"compact",keywords:/insight|consult|academic|research|whitepaper|due.*diligence|洞察|咨询|学术|调研|详尽|深度分析|尽调/}},un="clean-business";function hs(e){return e&&Fa[e]?e:un}function ps(e){return Fa[hs(e)]}var ai={background:"#111111",ink:"#F5F5F4",muted:"#A8A29E",primary:"#93C5FD",accent:"#2DD4BF",panel:"#1C1C1C"};function Cc(e,t="light"){let r=e?.palette||{};return t!=="dark"?{...r}:e?.paletteDark&&typeof e.paletteDark=="object"?{...e.paletteDark}:{background:ai.background,ink:ai.ink,muted:ai.muted,primary:r.primary||ai.primary,accent:r.accent||ai.accent,panel:ai.panel}}function Sh(e){return e==="zh-CN"?"zh-CN":"en-US"}function kc(e){let t=Sh(e);return xh.filter(r=>Fa[r]).map(r=>{let n=Fa[r];return{key:r,displayName:n.names[t]||n.names["en-US"],description:n.descriptions[t]||n.descriptions["en-US"],colorMode:n.colorMode}})}var Bi="pptLiveStudioStateV6",vs="pptLiveDeckHistoryV1",Dc=6,ys=["text","list","shape","metric","chart","media"],gs={executive:{name:"Executive",background:"#fbfcff",ink:"#111827",muted:"#5b6575",primary:"#0f766e",accent:"#f97316",panel:"#ffffff"},market:{name:"Market",background:"#fffdf7",ink:"#1f2937",muted:"#6b5f50",primary:"#2563eb",accent:"#d97706",panel:"#ffffff"},minimal:{name:"Minimal",background:"#f8fafc",ink:"#0f172a",muted:"#64748b",primary:"#334155",accent:"#0f766e",panel:"#ffffff"},studio:{name:"Studio",background:"#fcfbff",ink:"#1f1630",muted:"#6c607a",primary:"#7c3aed",accent:"#db2777",panel:"#ffffff"}};function yr(e="id"){return`${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Xr(e){return JSON.parse(JSON.stringify(e))}function mt(e,t,r){return Math.max(t,Math.min(r,e))}function Be(e){return String(e??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function bs(){return{topic:"",slideTarget:0}}function Ec(e="strategy"){let t={strategy:{profile:"strategy-leadership",thesis:"Decision-led transformation narrative",proofObjects:["market map","operating model","risk bridge","decision table"],arc:["thesis","context","friction","strategic bet","operating model","proof","risks","decision"]},sales:{profile:"gtm-growth",thesis:"Buyer pain to differentiated value narrative",proofObjects:["before/after workflow","value bridge","customer proof","implementation plan"],arc:["outcome","market shift","pain","solution","proof","commercial case","rollout","call to action"]},report:{profile:"finance-ir",thesis:"Executive performance narrative with decisions attached",proofObjects:["metric bridge","trend chart","variance table","risk register"],arc:["summary","scorecard","movement","root cause","metric proof","risk","plan","decision"]},teaching:{profile:"education",thesis:"Concept to application learning journey",proofObjects:["concept map","worked example","comparison","practice prompt"],arc:["goal","map","concept","example","mistakes","practice","summary","next step"]},fundraising:{profile:"fundraising",thesis:"Venture-scale opportunity supported by traction evidence",proofObjects:["market wedge","product diagram","traction chart","milestone plan"],arc:["thesis","problem","solution","market","product","traction","model","ask"]}};return t[e]||t.strategy}function zn(e="standard"){let t=String(e||"standard");return t==="loose"?"spacious":["compact","standard","spacious"].includes(t)?t:"standard"}var ms=["spacious","standard","compact"];function Ea(e="standard"){let t=zn(e),r=ms.indexOf(t);return r>=0?r:1}function Rc(e=1){let t=Math.min(Math.max(Math.round(Number(e)),0),ms.length-1);return ms[t]||"standard"}function Lc(e="standard"){let t=zn(e),r={spacious:{bulletLimit:4,cardColumns:3,cardGap:2},standard:{bulletLimit:5,cardColumns:4,cardGap:1.8},compact:{bulletLimit:6,cardColumns:4,cardGap:1.2}};return r[t]||r.standard}function Pc(e=0){let t=Number(e);return!Number.isFinite(t)||t<=0?0:mt(t,3,24)}function ws(){return{theme:"executive",density:"standard",fontFamily:"sans",colorMode:"light",stylePreset:"clean-business"}}function Bc(){return[O("defaultDeckTitle"),"Why now","Current friction","Strategic answer","Core workflow","Proof and impact","Rollout plan","Decision and next steps"]}function On(){return{schemaVersion:Dc,sessionId:yr("deck"),title:O("blankDeckTitle"),brief:bs(),promptDraft:"",lastSubmittedPrompt:"",agentSession:{id:"",workspaceSubdir:"",runId:"",skillKey:""},style:ws(),outline:[],sources:{items:[],facts:[],warnings:[],summary:"",fetchedAt:0},slides:[],activeSlideId:"",selectedElementId:"",mode:"edit",presentIndex:0,status:"ready",generation:{active:!1,current:"idle",steps:Nc().map(t=>({...t,status:"pending"})),events:[]},chatMessages:[{role:"assistant",text:O("assistantHello")}],updatedAt:Date.now()}}function Un(e){let t={...On(),...e||{}};t.schemaVersion=Dc;let r=t.brief||{};t.brief={...bs(),topic:String(r.topic||t.promptDraft||"").trim(),slideTarget:Pc(r.slideTarget)},t.promptDraft=typeof t.promptDraft=="string"?t.promptDraft:"",t.lastSubmittedPrompt=typeof t.lastSubmittedPrompt=="string"?t.lastSubmittedPrompt:"",t.agentSession={id:String(t.agentSession?.id||""),workspaceSubdir:String(t.agentSession?.workspaceSubdir||""),runId:String(t.agentSession?.runId||""),skillKey:String(t.agentSession?.skillKey||"")},t.style={...ws(),...t.style||{}},delete t.style.brandPrimary,delete t.style.brandAccent,Object.keys(gs).includes(t.style.theme)||(t.style.theme="executive"),["compact","standard","spacious","loose"].includes(t.style.density)||(t.style.density="standard"),t.style.density=zn(t.style.density),["sans","serif"].includes(t.style.fontFamily)||(t.style.fontFamily=t.style.fontFamily==="serif"?"serif":"sans"),["light","dark"].includes(t.style.colorMode)||(t.style.colorMode="light"),t.style.stylePreset=hs(typeof t.style.stylePreset=="string"?t.style.stylePreset:""),t.generation=Ra(t.generation),t.sources=Ch(t.sources),t.brief.slideTarget=Pc(t.brief.slideTarget);let n=t.generation.active&&Array.isArray(t.slides)&&t.slides.length===0;t.outline=n?[]:Array.isArray(t.outline)?t.outline.map(a=>String(a||O("newSlideTitle"))):[],t.slides=n?[]:Array.isArray(t.slides)&&t.slides.length>0?t.slides.map((a,o)=>Hr(a,o,t)):t.outline.length>0?t.outline.map((a,o)=>xs(a,o,t.outline.length,t)):[],t.slides.some(a=>a.id===t.activeSlideId)||(t.activeSlideId=t.slides[0]?.id||"");let i=_t(t);return i?.elements.some(a=>a.id===t.selectedElementId)||(t.selectedElementId=i?.elements[0]?.id||""),t.title=t.title||t.slides[0]?.title||O("defaultDeckTitle"),t.updatedAt=Date.now(),t}function Ch(e={}){return{items:Array.isArray(e.items)?e.items:[],facts:Array.isArray(e.facts)?e.facts:[],warnings:Array.isArray(e.warnings)?e.warnings:[],summary:typeof e.summary=="string"?e.summary:"",fetchedAt:Number(e.fetchedAt||0)}}function Nc(){return[{id:"brief",label:O("generationStepBrief"),detail:O("generationStepBriefDetail")},{id:"spine",label:O("generationStepSpine"),detail:O("generationStepSpineDetail")},{id:"proof",label:O("generationStepProof"),detail:O("generationStepProofDetail")},{id:"design",label:O("generationStepDesign"),detail:O("generationStepDesignDetail")},{id:"compile",label:O("generationStepCompile"),detail:O("generationStepCompileDetail")}]}var kh=80;function Ph(e={}){let t=typeof e=="string"?{title:e}:e||{},r=String(t.title||t.label||t.message||O("processEventUnknown")).trim()||O("processEventUnknown"),n=String(t.kind||"info").toLowerCase().replace(/[^a-z0-9-]/g,"")||"info",i=Number(t.timestamp||t.time||0)||Date.now();return{id:String(t.id||yr("generation-event")),seq:Number(t.seq)||0,title:r,detail:String(t.detail||t.description||"").trim(),kind:n,timestamp:i}}function Ra(e={}){let t=new Map((Array.isArray(e.steps)?e.steps:[]).map(i=>[i.id,i])),r=Array.isArray(e.events)?e.events.map(Ph).slice(-kh):[],n=r.reduce((i,a)=>Math.max(i,Number(a.seq)||0),0);return{active:!!e.active,current:e.current||"idle",draftedCount:Number(e.draftedCount)||0,slideTarget:Number(e.slideTarget)||0,eventSeq:Math.max(Number(e.eventSeq)||0,n),steps:Nc().map(i=>({...i,status:t.get(i.id)?.status||"pending"})),events:r}}function _t(e){return e.slides.find(t=>t.id===e.activeSlideId)||e.slides[0]}function er(e){return Math.max(0,e.slides.findIndex(t=>t.id===e.activeSlideId))}function Wn(e){return _t(e)?.elements.find(r=>r.id===e.selectedElementId)||null}function xs(e,t,r,n={brief:bs(),style:ws(),slides:[]}){let i=Ic(n,t),a={id:yr("slide"),title:e||`${O("newSlideTitle")} ${t+1}`,subtitle:"",kicker:zc(t,n),claim:Cs(e,t,n),proofObject:Na(t,n),supportNote:Oc(e,t,n),sourceNote:Uc(n),notes:O("defaultSpeakerNote",{title:e}),layout:Mc(t,r),theme:i,elements:[]};return a.elements=Wc(a,t,r,n),Hr(a,t,n)}function Hr(e,t,r){let n=e?.title||`${O("newSlideTitle")} ${t+1}`,i={id:e?.id||yr("slide"),title:n,subtitle:e?.subtitle||"",kicker:String(e?.kicker||zc(t,r)),claim:String(e?.claim||Cs(n,t,r)),proofObject:String(e?.proofObject||Na(t,r)),supportNote:String(e?.supportNote||Oc(n,t,r)),sourceNote:String(e?.sourceNote||Uc(r)),notes:e?.notes||"",layout:e?.layout||Mc(t,r?.slides?.length||1),theme:{...Ic(r,t),...e?.theme||e?.style||{}},html:typeof e?.html=="string"?e.html:"",quality:Fh(e?.quality),elements:[]},a=Array.isArray(e?.elements)&&e.elements.length>0?e.elements:Wc(i,t,r?.slides?.length||1,r);if(i.elements=a.map(o=>Ss(o)),i.html){let o=Ba(i.html);o&&(i.theme.background=o)}return i}function Fh(e={}){let t=Array.isArray(e?.issues)?e.issues:[];return{score:mt(Number(e?.score??100),0,100),issues:t.slice(0,12).map(r=>({id:String(r?.id||yr("quality")),severity:["high","medium","low"].includes(r?.severity)?r.severity:"low",type:String(r?.type||"quality"),message:String(r?.message||"")})).filter(r=>r.message)}}function Ss(e={}){let t=ys.includes(e.type)?e.type:"text",r=La(t);return{...r,...e,id:e.id||yr("el"),type:t,x:mt(Number(e.x??r.x),0,98),y:mt(Number(e.y??r.y),0,98),w:mt(Number(e.w??r.w),3,100),h:mt(Number(e.h??r.h),3,100),text:typeof e.text=="string"?e.text:r.text,label:typeof e.label=="string"?e.label:r.label,items:Array.isArray(e.items)?e.items.map(String):r.items,data:Array.isArray(e.data)?e.data.map(Th):r.data,style:Dh({...r.style,...e.style||{}})}}function Th(e,t){return typeof e=="number"?{label:`Q${t+1}`,value:e}:{label:String(e?.label||`Item ${t+1}`),value:Number(e?.value||0)}}function Dh(e={}){return{fontSize:mt(Number(e.fontSize||24),8,88),fontWeight:mt(Number(e.fontWeight||600),100,900),color:e.color||"ink",background:e.background||"transparent",opacity:mt(Number(e.opacity??1),0,1),borderRadius:mt(Number(e.borderRadius||0),0,99),align:e.align||"left"}}function La(e){let t={text:{text:"Key message",label:"",items:[],data:[],x:8,y:12,w:60,h:16,style:{fontSize:38,fontWeight:780,color:"ink",background:"transparent",borderRadius:0,opacity:1,align:"left"}},list:{text:"",label:"",items:["First point","Second point","Third point"],data:[],x:9,y:36,w:48,h:40,style:{fontSize:20,fontWeight:500,color:"ink",background:"transparent",borderRadius:8,opacity:1,align:"left"}},shape:{text:"",label:"",items:[],data:[],x:66,y:14,w:24,h:62,style:{fontSize:18,fontWeight:600,color:"accent",background:"primary",borderRadius:22,opacity:.12,align:"center"}},metric:{text:"3x",label:"Faster first draft",items:[],data:[],x:63,y:42,w:26,h:26,style:{fontSize:44,fontWeight:820,color:"primary",background:"panel",borderRadius:14,opacity:1,align:"left"}},chart:{text:"Signal trend",label:"",items:[],data:[{label:"Now",value:42},{label:"Next",value:68},{label:"Target",value:86}],x:52,y:36,w:36,h:32,style:{fontSize:18,fontWeight:700,color:"ink",background:"panel",borderRadius:14,opacity:1,align:"left"}},media:{text:O("mediaPlaceholder"),label:"",items:[],data:[],x:58,y:18,w:32,h:42,style:{fontSize:16,fontWeight:650,color:"muted",background:"soft",borderRadius:16,opacity:1,align:"center"}}};return{...Xr(t[e]||t.text),type:t[e]?e:"text"}}function Ic(e,t=0){let r=e?.deckPalette;if(r&&typeof r=="object"){let o=r.primary||"#111111",l=r.accent||"#c84b31";return Fc({name:"deck",background:r.background||"#111111",ink:r.ink||"#f8fafc",muted:r.muted||"#cbd5e1",primary:t%2?l:o,accent:t%2?o:l,panel:r.panel||"#1f2937"})}let n=gs[e?.style?.theme||"executive"]||gs.executive,i=n.primary,a=n.accent;return Fc({...n,primary:t%2?a:i,accent:t%2?i:a})}function Ba(e){let t=String(e||""),r=[/body\s*\{[^}]*background(?:-color)?\s*:\s*([^;}\n]+)/i,/]*style="[^"]*background(?:-color)?\s*:\s*([^;"']+)/i,/html\s*\{[^}]*background(?:-color)?\s*:\s*([^;}\n]+)/i,/:root\s*\{[^}]*background(?:-color)?\s*:\s*([^;}\n]+)/i,/background(?:-color)?\s*:\s*(#[0-9a-f]{3,8}|rgb[a]?\([^)]+\)|hsl[a]?\([^)]+\)|black|white)/i];for(let n of r){let i=t.match(n);if(!i)continue;let a=Eh(i[1]);if(a)return a}return null}function Eh(e){let t=String(e||"").trim().replace(/\s+!important$/i,"");if(!t||/^transparent$/i.test(t))return null;if(/^#[0-9a-f]{3,8}$/i.test(t))return fn(t,t);if(/^rgb/i.test(t)||/^hsl/i.test(t))return t;let r={black:"#000000",white:"#ffffff",transparent:null};return Object.prototype.hasOwnProperty.call(r,t.toLowerCase())?r[t.toLowerCase()]:t}function Fc(e){let t=fn(e.background,"#ffffff"),r=fn(e.panel,"#ffffff");return{...e,background:t,panel:r,ink:Ta(t,e.ink,"#111827","#f8fafc",7),muted:Ta(t,e.muted,"#4b5563","#cbd5e1",4.5),primary:Ta(r,e.primary,"#0f766e","#5eead4",4.5),accent:Ta(r,e.accent,"#c2410c","#fdba74",4.5)}}function Ta(e,t,r,n,i){let a=fn(e,"#ffffff"),o=fn(t,r);if(As(a,o)>=i)return o;let l=fn(r,"#111827"),c=fn(n,"#f8fafc");return As(a,l)>=As(a,c)?l:c}function As(e,t){let r=Tc(e),n=Tc(t),i=Math.max(r,n),a=Math.min(r,n);return(i+.05)/(a+.05)}function Tc(e){let{r:t,g:r,b:n}=Rh(e);return[t,r,n].map(i=>{let a=i/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4}).reduce((i,a,o)=>i+a*[.2126,.7152,.0722][o],0)}function fn(e,t){let r=String(e||"").trim(),n=r.match(/^#([0-9a-f]{3})$/i);return n?`#${n[1].split("").map(i=>i+i).join("")}`.toLowerCase():/^#[0-9a-f]{6}$/i.test(r)?r.toLowerCase():t}function Rh(e){let t=fn(e,"#000000").slice(1),r=parseInt(t,16);return{r:r>>16&255,g:r>>8&255,b:r&255}}function Mc(e,t){return e===0?"cover":e===t-1?"closing":["split","metric","process","comparison"][e%4]}function zc(e,t){let r=Ec();return(r.arc[e%r.arc.length]||"proof").replace(/[-_]/g," ").toUpperCase()}function Na(e,t){let r=Ec(),n=r.proofObjects[e%r.proofObjects.length]||"visual proof";return{"market map":O("proofMarketMap"),"operating model":O("proofOperatingModel"),"risk bridge":O("proofRiskBridge"),"decision table":O("proofDecisionTable"),"before/after workflow":O("proofBeforeAfter"),"value bridge":O("proofValueBridge"),"customer proof":O("proofCustomerProof"),"implementation plan":O("proofImplementationPlan"),"metric bridge":O("proofMetricBridge"),"trend chart":O("proofTrendChart"),"variance table":O("proofVarianceTable"),"risk register":O("proofRiskRegister"),"concept map":O("proofConceptMap"),"worked example":O("proofWorkedExample"),comparison:O("proofComparison"),"practice prompt":O("proofPracticePrompt"),"market wedge":O("proofMarketWedge"),"product diagram":O("proofProductDiagram"),"traction chart":O("proofTractionChart"),"milestone plan":O("proofMilestonePlan"),"visual proof":O("proofVisualProof")}[n]||n}function Cs(e,t,r){let n=r?.brief?.topic||r?.title||e;if(t===0)return O("claimCover",{topic:n});if(e&&/[.!?。!?]$/.test(e.trim()))return e;let i=[O("claimPressure",{title:e}),O("claimDecision",{title:e}),O("claimProof",{title:e}),O("claimAction",{title:e})];return i[t%i.length]}function Oc(e,t,r){let n=Na(t,r);return O("supportWithAssumption",{proof:n})}function Uc(e){return O("sourceDraftAssumption")}function Wc(e,t,r,n){let i=e.title,a=Lc(n?.style?.density),o=Bh(i,t,n).slice(0,a.bulletLimit).map(c=>String(c).slice(0,90)),l=Lh(e,t,r);return l==="cover"?[Tt("shape",{x:6,y:9,w:88,h:76,style:{background:"soft",opacity:1,borderRadius:28}}),Tt("shape",{x:9,y:15,w:1.2,h:55,style:{background:"primary",opacity:1,borderRadius:99}}),Tt("text",{text:e.kicker,x:13,y:15,w:22,h:5,style:{fontSize:10,fontWeight:760,color:"primary"}}),Tt("text",{text:i,x:13,y:23,w:58,h:25,style:{fontSize:i.length>48?34:44,fontWeight:840}}),Tt("text",{text:e.claim,x:14,y:55,w:45,h:11,style:{fontSize:18,fontWeight:520,color:"muted"}}),Tt("metric",{text:String(r),label:O("slidesUnit"),x:75,y:54,w:14,h:17,style:{fontSize:34}})]:l==="closing"?[Tt("text",{text:i,x:9,y:15,w:65,h:15,style:{fontSize:i.length>48?30:38,fontWeight:820}}),Tt("text",{text:e.claim,x:10,y:33,w:46,h:9,style:{fontSize:17,fontWeight:540,color:"muted"}}),...Da([O("closeConfirm"),O("closeOwner"),O("closeIteration")],10,50,52,22,3),Tt("text",{text:o[0]||e.supportNote,x:67,y:48,w:22,h:20,style:{fontSize:18,fontWeight:720,color:"primary",background:"soft",borderRadius:20}})]:l==="process"?[Tt("text",{text:i,x:8,y:10,w:68,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:9,y:25,w:54,h:7,style:{fontSize:15,fontWeight:520,color:"muted"}}),Tt("shape",{x:10,y:50,w:78,h:1.2,style:{background:"primary",opacity:.25,borderRadius:99}}),...Da(o.map((c,s)=>`0${s+1} ${c}`),10,37,78,28,Math.min(a.cardColumns,Math.max(2,o.length)),a.cardGap)]:l==="comparison"?[Tt("text",{text:i,x:7,y:10,w:72,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:8,y:25,w:48,h:7,style:{fontSize:15,fontWeight:520,color:"muted"}}),...Da(o,8,37,82,30,2,a.cardGap)]:l==="data"?[Tt("text",{text:i,x:8,y:10,w:66,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:9,y:25,w:47,h:7,style:{fontSize:15,fontWeight:520,color:"muted"}}),Tt("metric",{text:String(t).padStart(2,"0"),label:e.proofObject,x:10,y:40,w:34,h:28,style:{fontSize:44}}),Tt("text",{text:o[0]||e.supportNote,x:69,y:41,w:20,h:24,style:{fontSize:17,fontWeight:700,color:"primary",background:"soft",borderRadius:18}})]:l==="cards"?[Tt("text",{text:i,x:8,y:10,w:68,h:12,style:{fontSize:32,fontWeight:820}}),Tt("text",{text:e.claim,x:9,y:25,w:51,h:8,style:{fontSize:15,fontWeight:520,color:"muted"}}),...Da(o,9,38,78,28,a.cardColumns,a.cardGap)]:[Tt("text",{text:i,x:10,y:15,w:62,h:15,style:{fontSize:i.length>48?30:38,fontWeight:820}}),Tt("text",{text:e.claim,x:11,y:34,w:42,h:10,style:{fontSize:17,fontWeight:520,color:"muted"}}),Tt("text",{text:o[0]||e.supportNote,x:58,y:38,w:28,h:24,style:{fontSize:22,fontWeight:760,color:"primary",background:"soft",borderRadius:22}}),Tt("shape",{x:10,y:72,w:18,h:.6,style:{background:"primary",opacity:1,borderRadius:99}})]}function Lh(e,t,r){let n=[e.layout,e.kicker,e.proofObject,e.claim,e.title].join(" ").toLowerCase();return t===0||e.layout==="cover"?"cover":t===r-1||e.layout==="closing"?"closing":/process|workflow|timeline|roadmap|journey|steps|architecture|flow|流程|步骤|路线|架构/.test(n)?"process":/compare|comparison|versus|matrix|before|after|risk|对比|比较|矩阵|风险/.test(n)?"comparison":/data|metric|trend|scorecard|chart|number|数据|指标|趋势/.test(n)?"data":t%3===1?"cards":"spotlight"}function Da(e,t,r,n,i,a,o=2.5){let l=e.filter(Boolean),c=Math.max(1,Math.min(a||1,l.length||1)),s=Number.isFinite(o)?o:2.5,d=Math.max(1,Math.ceil((l.length||1)/c)),u=(n-s*(c-1))/c,p=(i-s*(d-1))/d;return l.map((f,h)=>Tt("text",{text:f,x:t+h%c*(u+s),y:r+Math.floor(h/c)*(p+s),w:u,h:p,style:{fontSize:17,fontWeight:h===0?760:620,color:h===0?"primary":"ink",background:h===0?"soft":"panel",borderRadius:18}}))}function Tt(e,t){let r=La(e);return{...r,...t,style:{...r.style,...t.style||{}}}}function Bh(e,t,r){let n=r?.brief?.topic||e,i=Na(t,r),a=[`${O("pointClaimPrefix")} ${Cs(e,t,r)}`,`${O("pointProofPrefix")} ${i}`,`${O("pointAudiencePrefix")} ${n}`,O("pointEvidenceRule"),O("pointDesignRule"),O("pointCloseRule")],o=Lc(r?.style?.density).bulletLimit,l=[];for(let c=0;c{t!==e&&Ia(t)})}function ks(e){let t=e.querySelector(".ppt-flat-select__menu"),r=e.querySelector(".ppt-flat-select__trigger");if(!t||!r)return;let n=r.getBoundingClientRect(),i=Math.min(220,t.scrollHeight||220),a=window.innerHeight-n.bottom,o=aa;t.style.left=`${Math.max(8,n.left)}px`,t.style.width=`${n.width}px`,o?(t.style.top="auto",t.style.bottom=`${window.innerHeight-n.top+4}px`):(t.style.top=`${n.bottom+4}px`,t.style.bottom="auto")}function Gc(e){let t=e.querySelector(".ppt-flat-select__menu"),r=e.querySelector(".ppt-flat-select__trigger");if(!t||!r)return;Ma(null),t.hidden=!1,ks(e),r.setAttribute("aria-expanded","true"),e.classList.add("is-open"),oi.add(e),t.querySelector(".ppt-flat-select__option.is-selected")?.scrollIntoView({block:"nearest"})}function Nh(e,t){let r=e.querySelector(".ppt-flat-select__menu");if(!r||r.hidden)return;let n=[...r.querySelectorAll(".ppt-flat-select__option")];if(!n.length)return;let i=n.indexOf(document.activeElement),a=i>=0?i:n.findIndex(l=>l.classList.contains("is-selected")),o=Math.min(n.length-1,Math.max(0,(a<0?-t:a)+t));n[o]?.focus(),n[o]?.scrollIntoView({block:"nearest"})}function Ps(e){let t=e.closest(".ppt-flat-select");if(!t)return;let r=t.querySelector(".ppt-flat-select__label"),n=t.querySelector(".ppt-flat-select__menu"),i=e.options[e.selectedIndex];if(r&&(r.textContent=i?.textContent?.trim()||""),!n)return;let a=new Map([...n.querySelectorAll(".ppt-flat-select__option")].map(o=>[o.dataset.value,o]));[...e.options].forEach(o=>{let l=a.get(o.value);l||(l=document.createElement("button"),l.type="button",l.className="ppt-flat-select__option",l.setAttribute("role","option"),l.dataset.value=o.value,l.addEventListener("click",()=>{e.value=o.value,Ps(e),Ia(t),e.dispatchEvent(new Event("change",{bubbles:!0}))}),n.append(l)),l.textContent=o.textContent,o.title&&(l.title=o.title);let c=o.value===e.value;l.classList.toggle("is-selected",c),l.setAttribute("aria-selected",c?"true":"false")}),[...n.querySelectorAll(".ppt-flat-select__option")].forEach(o=>{[...e.options].some(l=>l.value===o.dataset.value)||o.remove()}),t.classList.contains("is-open")&&ks(t)}function Ih(e){if(!(e instanceof Node))return!1;for(let t of oi){let r=t.querySelector(".ppt-flat-select__menu");if(r&&(r===e||r.contains(e)))return!0}return!1}function Mh(e){Ih(e.target)||Ma(null)}function zh(e){let t=e.target;if(t instanceof Node){for(let r of oi)if(r.contains(t))return}Ma(null)}function qc(e){if(!e||e.dataset.flatSelect==="true")return;e.dataset.flatSelect="true",e.classList.remove("ppt-flat-select"),e.classList.add("ppt-flat-select__native"),e.tabIndex=-1,e.setAttribute("aria-hidden","true");let t=document.createElement("div");t.className="ppt-flat-select";let r=document.createElement("button");r.type="button",r.className="ppt-flat-select__trigger",r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let n=document.createElement("span");n.className="ppt-flat-select__label",r.append(n);let i=document.createElement("div");i.className="ppt-flat-select__menu",i.hidden=!0,i.setAttribute("role","listbox"),i.addEventListener("wheel",o=>o.stopPropagation(),{passive:!0}),i.addEventListener("mousedown",o=>o.stopPropagation()),r.addEventListener("click",o=>{if(o.stopPropagation(),t.classList.contains("is-open")){Ia(t);return}Gc(t)}),t.addEventListener("keydown",o=>{o.key==="ArrowDown"||o.key==="ArrowUp"?(o.preventDefault(),t.classList.contains("is-open")||Gc(t),Nh(t,o.key==="ArrowDown"?1:-1)):o.key==="Escape"&&t.classList.contains("is-open")&&(o.stopPropagation(),Ia(t),r.focus())}),e.parentNode.insertBefore(t,e),t.append(r,i,e),Ps(e)}function Ni(e){Ps(e)}window.__pptLiveFlatSelectBound||(window.__pptLiveFlatSelectBound=!0,document.addEventListener("click",zh),document.addEventListener("keydown",e=>{e.key==="Escape"&&Ma(null)}),window.addEventListener("resize",()=>{oi.forEach(e=>ks(e))}),document.addEventListener("scroll",Mh,!0));function Zc(){document.documentElement.lang=lr(),document.querySelectorAll("[data-i18n]").forEach(e=>{e.textContent=O(e.dataset.i18n)}),document.querySelectorAll("[data-i18n-placeholder]").forEach(e=>{e.placeholder=O(e.dataset.i18nPlaceholder)}),document.querySelectorAll("[data-i18n-aria]").forEach(e=>{e.setAttribute("aria-label",O(e.dataset.i18nAria))})}function Yc(e,t){ep(e),Lr(e),Br(e),rp(e,t),qn(e,t),hn(e,t),qa(e,t),Gn(),document.querySelector(".ppt-live")?.setAttribute("data-density",e.style.density),document.querySelectorAll(".segment").forEach(i=>{i.classList.toggle("is-active",i.dataset.mode===e.mode)});let r=er(e),n=Nt("slidePosition");n&&(n.textContent=`${r+1} / ${e.slides?.length||1}`)}var jc="",Ii=0,Jc=120,Oh=20;function Uh(e){return{x:(parseFloat(e.paddingLeft)||0)+(parseFloat(e.paddingRight)||0),y:(parseFloat(e.paddingTop)||0)+(parseFloat(e.paddingBottom)||0)}}function $c(e,t={}){if(!e)return{width:0,height:0};let r=getComputedStyle(e),n=Uh(r),i=Math.max(0,(e.clientWidth||0)-n.x),a=Math.max(0,(e.clientHeight||0)-n.y),o=e.getBoundingClientRect();o.width>0&&(i=Math.max(i,o.width-n.x)),o.height>0&&(a=Math.max(a,o.height-n.y));let l=t.minHeight??Jc,c=t.fallback;if(c&&a0&&(i=Math.max(i,s.width-n.x)),s.height>0&&(a=Math.max(a,s.height-n.y))}return{width:Math.max(0,i),height:Math.max(0,a)}}function Wh(e){if(!e)return 0;let t=e.getBoundingClientRect();return Math.max(e.clientWidth||0,e.offsetWidth||0,t.width||0)}function Gn(){Ii&&cancelAnimationFrame(Ii);let e=(t=0)=>{Ii=0,si(),Ns(),Ga(),ad();let r=Nt("slideCanvas")?.closest(".canvas-area");if(!r||t>=Oh)return;let{height:n}=$c(r,{fallback:r.closest(".stage-shell")});ne(t+1)))};Ii=requestAnimationFrame(()=>e(0))}function si(){let e=Nt("slideCanvas"),t=e?.closest(".canvas-area"),r=e?.closest(".canvas-stage");if(!e||!t||!r)return;let{width:n,height:i}=$c(t,{fallback:t.closest(".stage-shell")}),a=Math.max(160,n),o=Math.max(90,i),l=a,c=l*9/16;c>o&&(c=o,l=c*16/9);let s=Math.floor(l),d=Math.floor(c),u=`${a}x${o}`;if(u===jc&&r.style.width===`${s}px`&&r.style.height===`${d}px`){let h=e.querySelector(`.${br}`);h&&wr(h);return}jc=u,r.style.width=`${s}px`,r.style.height=`${d}px`,e.style.width="100%",e.style.height="100%";let p=Nt("presentSlide");p&&(p.style.width=`${s}px`,p.style.height=`${d}px`);let f=e.querySelector(`.${br}`);f&&wr(f)}function Gh(e){let t=Nt("floatingToolbar"),r=Nt("slideCanvas");if(!t||!r||!e){t&&t.classList.remove("is-visible");return}let n=r.getBoundingClientRect(),i=e.x/100*n.width,a=e.y/100*n.height,o=e.w/100*n.width;t.style.left=`${n.left+i+o/2-t.offsetWidth/2}px`,t.style.top=`${n.top+a-t.offsetHeight-8}px`,t.classList.add("is-visible")}function Fs(e,t){let r=String(e||"").trim(),n=parseFloat(r);return Number.isFinite(n)?r.endsWith("pt")?n*(96/72):(r.endsWith("px"),n):t}function Es(e,t,r){return String(e||"").replace(/(^|[^-.\w]):root(?![\w-])/gi,`$1${t}`).replace(/(^|[^-.\w])html(?![\w-])/gi,`$1${t}`).replace(/(^|[^-.\w])body(?![\w-])/gi,`$1${r}`)}var br="html-slide-preview-host",ed="html-slide-preview-scaler",Rs={width:1280,height:720};function qh(e){let t=String(e||""),r=t.match(/(?:^|[{;\s])width\s*:\s*([\d.]+)\s*pt/i),n=t.match(/(?:^|[{;\s])height\s*:\s*([\d.]+)\s*pt/i);if(r?.[1]&&n?.[1])return{width:Math.round(parseFloat(r[1])*(96/72)),height:Math.round(parseFloat(n[1])*(96/72))};let i=t.match(/(?:^|[{;\s])width\s*:\s*([\d.]+)\s*px/i),a=t.match(/(?:^|[{;\s])height\s*:\s*([\d.]+)\s*px/i);return i?.[1]&&a?.[1]?{width:Math.round(parseFloat(i[1])),height:Math.round(parseFloat(a[1]))}:{...Rs}}function jh(e){let t=Number(e?.dataset?.designW),r=Number(e?.dataset?.designH);return Number.isFinite(t)&&t>=320&&Number.isFinite(r)&&r>=180?{width:t,height:r}:null}function Vh(e){let t=e?.body,r=e?.documentElement,n=e?.defaultView;if(!t||!r||!n)return{...Rs};let i=n.getComputedStyle(t),a=Fs(i.width,0),o=Fs(i.height,0)||Fs(i.minHeight,0);if(a>=320&&o>=180)return{width:a,height:o};let l=Math.max(t.scrollWidth||0,t.offsetWidth||0,r.clientWidth||0,1280),c=Math.max(t.scrollHeight||0,t.offsetHeight||0,r.clientHeight||0,720);return l=Math.min(Math.max(l,320),3840),c=Math.min(Math.max(c,180),3840),{width:l,height:c}}function Xh(e,t){let r=jh(t);return r||(e?.body?Vh(e):{...Rs})}function Ls(e){if(!e)return{width:0,height:0};let t=e.getBoundingClientRect();return{width:Math.max(e.clientWidth||0,e.offsetWidth||0,t.width||0),height:Math.max(e.clientHeight||0,e.offsetHeight||0,t.height||0)}}function td(e,t){let r=qh(t);return e.dataset.designW=String(r.width),e.dataset.designH=String(r.height),r}var Vc="data-ppt-live-editing-style",li="data-ppt-live-editable";function Hh(e,t){!e||e._pptLiveOriginalInline||!t?.documentElement||!t.body||(e._pptLiveOriginalInline={root:t.documentElement.getAttribute("style"),body:t.body.getAttribute("style")})}function _h(e,t,r){if(!e?.documentElement||!e.body)return;let n=e.documentElement,i=e.body;n.style.margin="0",n.style.padding="0",n.style.width=`${t}px`,n.style.height=`${r}px`,n.style.overflow="hidden",i.style.margin="0",i.style.boxSizing="border-box",i.style.width=`${t}px`,i.style.height=`${r}px`,i.style.minHeight="",i.style.maxWidth="",i.style.overflow="hidden",i.style.transform="none"}function wr(e){let t=e?.classList?.contains(br)?e:e?.closest?.(`.${br}`);if(!t)return!1;let r=t.querySelector(`.${ed}`),n=r?.querySelector("iframe, [data-slide-stage]");if(!r||!n)return!1;let{width:i,height:a}=Ls(t);if(!i||!a)return!1;let o=n.tagName==="IFRAME",l=null;if(o)try{l=n.contentDocument}catch{l=null}let{width:c,height:s}=Xh(l,n),d=Math.min(i/c,a/s),u=c*d,p=s*d;return l&&(Hh(n,l),_h(l,c,s)),r.style.width=`${u}px`,r.style.height=`${p}px`,r.style.overflow="hidden",r.style.position="relative",r.style.flexShrink="0",n.style.display="block",n.style.width=`${c}px`,n.style.height=`${s}px`,n.style.border="0",n.style.margin="0",n.style.padding="0",n.style.maxWidth="none",n.style.maxHeight="none",n.style.transformOrigin="top left",n.style.transform=`scale(${d})`,!0}var Xc="ppt-slide-shadow-root",Ds="ppt-slide-shadow-body";function Kh(e){return e.querySelectorAll('script, iframe, object, embed, meta[http-equiv="refresh" i]').forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(let r of[...t.attributes]){let n=r.name.toLowerCase();(n.startsWith("on")||(n==="href"||n==="src"||n==="xlink:href")&&/^\s*javascript:/i.test(r.value))&&t.removeAttribute(r.name)}}),e}function Qh(e,t){let r=document.createElement("div");r.className=t,r.dataset.slideStage="true",td(r,e);let n=Number(r.dataset.designW),i=Number(r.dataset.designH),a=Kh(new DOMParser().parseFromString(Ur(e),"text/html")),o=r.attachShadow({mode:"open"}),l=document.createElement("div");l.className=Xc,l.style.cssText=["all:initial","display:block","position:relative",`width:${n}px`,`height:${i}px`,"margin:0","padding:0","overflow:hidden",'font-family:system-ui, -apple-system, "PingFang SC", "Source Han Sans SC", sans-serif',"font-size:16px","line-height:normal","color:#000","background:#fff"].join(";"),a.querySelectorAll("style").forEach(s=>{let d=document.createElement("style");d.textContent=Es(s.textContent||"",`.${Xc}`,`.${Ds}`),o.appendChild(d)});let c=document.createElement("div");if(c.className=Ds,a.body){for(let s of a.body.attributes)s.name==="class"?c.classList.add(...s.value.split(/\s+/).filter(Boolean)):s.name==="style"?c.style.cssText+=`;${s.value}`:s.name.toLowerCase().startsWith("on")||c.setAttribute(s.name,s.value);c.innerHTML=a.body.innerHTML}return c.style.boxSizing="border-box",/\bwidth\s*:/i.test(c.style.cssText)||(c.style.width=`${n}px`),/\bheight\s*:/i.test(c.style.cssText)||(c.style.height=`${i}px`),c.style.overflow="hidden",c.style.margin="0",l.appendChild(c),o.appendChild(l),r._pptLiveSourceHtml=String(e||""),r}function Bs({hostClass:e="",frameClass:t,html:r,onReady:n,interactive:i=!1}){let a=document.createElement("div");a.className=[br,e].filter(Boolean).join(" ");let o=document.createElement("div");if(o.className=ed,i){let s=Qh(r,t);return o.appendChild(s),a.appendChild(o),requestAnimationFrame(()=>{wr(a),n?.(s,a)}),{host:a,scaler:o,frame:s}}let l=document.createElement("iframe");l.className=t,l.setAttribute("sandbox","allow-same-origin"),l.setAttribute("loading","lazy"),td(l,r),l.srcdoc=Ur(r);let c=()=>{wr(a),n?.(l,a)};return l.addEventListener("load",c,{once:!0}),o.appendChild(l),a.appendChild(o),{host:a,scaler:o,frame:l}}function rd(e){let{host:t}=Bs({hostClass:"export-preview__html-stage",frameClass:"export-preview__html-frame",html:e,onReady:()=>{t.closest(".export-preview__viewport")&&wr(t)}});return t}function nd(e){if(!e)return;let t=e.querySelector(".export-preview__viewport")||e,r=t.querySelector(".export-preview__scale");if(!r)return;let n=r.querySelector(`.${br}`);if(n){r.style.width="100%",r.style.height="100%",wr(n);return}let i=r.querySelector(".export-preview__element-stage");if(!i)return;let{width:a,height:o}=Ls(t);if(!a||!o)return;let l=960,c=540,s=Math.min(a/l,o/c);i.style.width=`${l}px`,i.style.height=`${c}px`,i.style.transform=`scale(${s})`,i.style.transformOrigin="top left",r.style.width=`${Math.floor(l*s)}px`,r.style.height=`${Math.floor(c*s)}px`}function Zh(e){if(!e||new Set(["turn","round","round-done","tokens","text","thinking"]).has(e.kind||""))return"";let r=String(e.detail||"").trim();return!r||/^[0-9a-f-]{8,}/i.test(r)?"":r}function Yh(e){if(!e)return;(typeof requestAnimationFrame=="function"?requestAnimationFrame:r=>setTimeout(r,0))(()=>{e.scrollTop=e.scrollHeight})}function Lr(e){let t=Nt("generationSteps"),r=e.generation?.steps||[],n=Array.isArray(e.generation?.events)?e.generation.events:[],i=!!(e.generation?.active||r.some(o=>o.status==="running")),a=r.some(o=>o.status==="error");if(document.querySelector(".ppt-live")?.classList.toggle("is-generating",i),document.querySelector(".ppt-live")?.classList.toggle("has-generation-error",a),!!t){if(t.innerHTML="",n.length)n.forEach((o,l)=>{let c=Zh(o),s=document.createElement("li");s.className=`generation-event is-${o.kind||"info"}`,s.innerHTML=` + ${Number(o.seq)||l+1} - ${Le(f.title||U("processEventUnknown"))} - ${p?`${Le(p)}`:""} + ${Be(o.title||O("processEventUnknown"))} + ${c?`${Be(c)}`:""} - `,t.append(A)});else{let f=document.createElement("li");f.className="generation-event is-empty",f.innerHTML=` + `,t.append(s)});else{let o=document.createElement("li");o.className="generation-event is-empty",o.innerHTML=` -- - ${Le(U("processWaitingForEventsTitle"))} - ${Le(U("processWaitingForEvents"))} + ${Be(O("processWaitingForEventsTitle"))} + ${Be(O("processWaitingForEvents"))} - `,t.append(f)}wh(t)}}function Dr(e){let t=Ft("generationOverlay");if(!t)return;let r=e.generation?.steps||[],n=!!(e.generation?.active||r.some(o=>o.status==="running"));if(t.hidden=!n,!n)return;let i=r.find(o=>o.id===e.generation?.current)||r.find(o=>o.status==="running")||null,a=Mc(e);Ur("generationOverlayTitle",i?.label||U("generationAgentWorking")),Ur("generationOverlayProgress",a||i?.detail||U("generationProgressPulse"))}function xh(e="sans"){let t=e==="serif"?"serif":"sans";document.querySelectorAll("[data-font-family]").forEach(r=>{let n=r.dataset.fontFamily===t;r.classList.toggle("is-active",n),r.setAttribute("aria-pressed",n?"true":"false")})}function Sh(e="light"){let t=e==="dark"?"dark":"light";document.querySelectorAll("[data-color-mode]").forEach(r=>{let n=r.dataset.colorMode===t;r.classList.toggle("is-active",n),r.setAttribute("aria-pressed",n?"true":"false")})}function Di(e="standard"){let t=Nn(e),r=xa(t),n=document.getElementById("densitySlider");if(n){n.style.setProperty("--density-index",String(r)),n.dataset.index=String(r),n.setAttribute("aria-valuenow",String(r));let i=`density${t.charAt(0).toUpperCase()}${t.slice(1)}`;n.setAttribute("aria-valuetext",U(i)),n.querySelectorAll("[data-density-index]").forEach(a=>{let o=Number(a.dataset.densityIndex)===r;a.classList.toggle("is-active",o)})}document.querySelector(".ppt-live")?.setAttribute("data-density",t)}function kh(e){let t=typeof e.promptDraft=="string"?e.promptDraft:"",r=Array.isArray(e.slides)&&e.slides.length>0;Oh("topicInput",r?t:t||e.brief.topic),xh(e.style.fontFamily),Sh(e.style.colorMode),Di(e.style.density);let n=document.getElementById("stylePresetSelect");n&&(n.value=e.style?.stylePreset||on,Ci(n)),Ur("deckTitle",e.title||U("defaultDeckTitle")),Ur("deckMeta",U("slidesMeta",{count:e.slides.length})),Ur("currentSlideIndex",String($t(e)+1))}function zc(e,t={}){t.includeTopic!==!1&&(e.brief.topic=Uh("topicInput"),e.promptDraft=e.brief.topic,Ch(e))}function Ch(e){let t=String(e.brief.topic||""),r=t.match(/(\d{1,2})\s*(?:页|页面|张|slides?|pages?)/i)||t.match(/(?:页数|slides?|pages?)\D{0,8}(\d{1,2})/i);r?e.brief.slideTarget=Math.max(3,Math.min(24,Number(r[1]))):e.brief.slideTarget=0}function Ph(e,t){let r=Ft("outlineList");r&&(r.innerHTML="",e.outline.forEach((n,i)=>{let a=document.createElement("li"),o=e.slides[i];a.className=`outline-row${o?.id===e.activeSlideId?" is-active":""}`,a.innerHTML=` + `,t.append(o)}Yh(t)}}function Br(e){let t=e.generation?.steps||[],r=!!(e.generation?.active||t.some(i=>i.status==="running")),n=Nt("statusSpinner");n&&(n.hidden=!r,n.setAttribute("aria-hidden",r?"false":"true"))}function Jh(e="sans"){let t=e==="serif"?"serif":"sans";document.querySelectorAll("[data-font-family]").forEach(r=>{let n=r.dataset.fontFamily===t;r.classList.toggle("is-active",n),r.setAttribute("aria-pressed",n?"true":"false")})}function $h(e="light"){let t=e==="dark"?"dark":"light";document.querySelectorAll("[data-color-mode]").forEach(r=>{let n=r.dataset.colorMode===t;r.classList.toggle("is-active",n),r.setAttribute("aria-pressed",n?"true":"false")})}function Oi(e="standard"){let t=zn(e),r=Ea(t),n=document.getElementById("densitySlider");if(n){n.style.setProperty("--density-index",String(r)),n.dataset.index=String(r),n.setAttribute("aria-valuenow",String(r));let i=`density${t.charAt(0).toUpperCase()}${t.slice(1)}`;n.setAttribute("aria-valuetext",O(i)),n.querySelectorAll("[data-density-index]").forEach(a=>{let o=Number(a.dataset.densityIndex)===r;a.classList.toggle("is-active",o)})}document.querySelector(".ppt-live")?.setAttribute("data-density",t)}function ep(e){let t=typeof e.promptDraft=="string"?e.promptDraft:"",r=Array.isArray(e.slides)&&e.slides.length>0;pp("topicInput",r?t:t||e.brief.topic),Jh(e.style.fontFamily),$h(e.style.colorMode),Oi(e.style.density);let n=document.getElementById("stylePresetSelect");n&&(n.value=e.style?.stylePreset||un,Ni(n)),Ts("deckTitle",e.title||O("defaultDeckTitle")),Ts("deckMeta",O("slidesMeta",{count:e.slides.length})),Ts("currentSlideIndex",String(er(e)+1))}function id(e,t={}){t.includeTopic!==!1&&(e.brief.topic=Ap("topicInput"),e.promptDraft=e.brief.topic,tp(e))}function tp(e){let t=String(e.brief.topic||""),r=t.match(/(\d{1,2})\s*(?:页|页面|张|slides?|pages?)/i)||t.match(/(?:页数|slides?|pages?)\D{0,8}(\d{1,2})/i);r?e.brief.slideTarget=Math.max(3,Math.min(24,Number(r[1]))):e.brief.slideTarget=0}function rp(e,t){let r=Nt("outlineList");r&&(r.innerHTML="",e.outline.forEach((n,i)=>{let a=document.createElement("li"),o=e.slides[i];a.className=`outline-row${o?.id===e.activeSlideId?" is-active":""}`,a.innerHTML=` ${i+1} - `,a.querySelector(".outline-card").addEventListener("click",()=>{o?.id&&t.selectSlide(o.id)}),r.append(a)}))}function On(e,t){let r=Ft("slideThumbs");if(r){if(r.innerHTML="",!e.slides.length){let n=document.createElement("div");n.className="thumbs-empty",n.textContent=U("slidesEmptyHint"),r.append(n);return}e.slides.forEach((n,i)=>{let a=n.html?Pa(n.html):null,o=n.theme||{},l=a||o.background||"var(--studio-slide-chrome)",c=document.createElement("button");c.className=`thumb${n.id===e.activeSlideId?" is-active":""}`,c.type="button",c.style.setProperty("--thumb-bg",l),c.style.setProperty("--thumb-primary",o.primary||"var(--studio-accent)");let s=document.createElement("div");if(s.className="thumb-preview",s.style.background=l,n.html)s.appendChild(Fh(n.html));else{let f=document.createElement("div");f.className="thumb-preview-slide",f.innerHTML=dn(n),s.appendChild(f)}c.appendChild(s);let d=document.createElement("div");d.className="thumb-copy",d.innerHTML=` - ${Le(n.kicker||"")} - ${Le(n.title)} - `,c.appendChild(d);let u=document.createElement("span");u.className="thumb-number",u.textContent=String(i+1),c.appendChild(u),c.addEventListener("click",()=>t.selectSlide(n.id)),r.append(c)}),requestAnimationFrame(()=>{ms(),Na()})}}var Ra=960,La=540;function Fh(e){let{host:t}=gs({hostClass:"thumb-preview-html",frameClass:"thumb-preview-frame",html:e,onReady:()=>mr(t)});return t}function Th(e,t){let r=e?.closest?.(`.${gr}`)||t?.querySelector?.(`.${gr}`);if(r){mr(r);return}if(!e||!t)return;let{width:n,height:i}=As(t);if(!n||!i)return;let a=Math.min(n/Ra,i/La);e.style.width=`${Ra}px`,e.style.height=`${La}px`,e.style.transform=`scale(${a})`,e.style.transformOrigin="top left"}function Dh(e){let t=e.querySelector(".thumb-preview-frame");if(t){Th(t,e);return}let r=e.querySelector(".thumb-preview-html, .thumb-preview-slide");if(!r)return;let n=dh(e);if(!n)return;let i=n/Ra,a=La*i;r.style.width=`${Ra}px`,r.style.height=`${La}px`,r.style.transform=`scale(${i})`,r.style.transformOrigin="top left",e.style.height=`${a}px`}function ms(){let e=Ft("slideThumbs");e&&(e.querySelectorAll(`.${gr}`).forEach(t=>{mr(t)}),e.querySelectorAll(".thumb-preview").forEach(t=>{t.querySelector(`.${gr}`)||Dh(t)}))}var Fi=null,Ti=null;function Oc(){if(typeof ResizeObserver>"u")return;Ti||(Ti=new ResizeObserver(()=>{document.querySelectorAll(`.${gr}`).forEach(t=>{mr(t)})})),Ti.disconnect(),document.querySelectorAll(`.${gr}`).forEach(t=>{Ti.observe(t)});let e=Ft("slideCanvas");e&&Ti.observe(e)}function Na(){let e=Ft("slideThumbs");!e||typeof ResizeObserver>"u"||(Fi||(Fi=new ResizeObserver(()=>ms())),Fi.disconnect(),Fi.observe(e),e.querySelectorAll(".thumb-preview").forEach(t=>{Fi.observe(t)}),Oc())}function Eh(e){if(!String(e.brief?.topic||"").trim()){let n=String(e.title||"").trim();if(n===U("blankDeckTitle")||n===U("defaultDeckTitle")||n===U("newSlideTitle"))return!0}if(!e.slides?.length)return!0;let t=String(e.title||"").trim();return e.slides.length===1&&e.outline.length===1&&e.outline[0]===U("newSlideTitle")&&(t===U("blankDeckTitle")||t===U("newSlideTitle"))}function Ea(e,t){if(!e)return;if(!t){e.style.background="";return}let r=t.theme||{},i=(t.html?Pa(t.html):null)||r.background||"";e.style.background=i||""}function cn(e,t){let r=Ft("slideCanvas");if(!r)return;let n=Kt(e),i=!!(e.generation?.active||e.generation?.steps?.some(o=>o.status==="running"));if(!n){r.classList.remove("is-html-slide"),r.classList.add("is-empty"),r.innerHTML=i?`
${Le(U("generationAgentWorking"))}

${Le(U("agentWorkingDetail"))}

`:`

${Le(U("welcomeTitle"))}

${Le(U("welcomeSubcopy"))}

`,Pc(r),Ea(r,null),Jn();return}if(Eh(e)&&!n.html&&!i){r.classList.remove("is-html-slide"),r.classList.add("is-empty"),r.innerHTML=` + `,a.querySelector(".outline-card").addEventListener("click",()=>{o?.id&&t.selectSlide(o.id)}),r.append(a)}))}function qn(e,t){let r=Nt("slideThumbs");if(r){if(r.innerHTML="",!e.slides.length){let n=document.createElement("div");n.className="thumbs-empty",n.textContent=O("slidesEmptyHint"),r.append(n);return}e.slides.forEach((n,i)=>{let a=n.html?Ba(n.html):null,o=n.theme||{},l=a||o.background||"var(--studio-slide-chrome)",c=document.createElement("button");c.className=`thumb${n.id===e.activeSlideId?" is-active":""}`,c.type="button",c.style.setProperty("--thumb-bg",l),c.style.setProperty("--thumb-primary",o.primary||"var(--studio-accent)");let s=document.createElement("div");if(s.className="thumb-preview",s.style.background=l,n.html)s.appendChild(np(n.html));else{let p=document.createElement("div");p.className="thumb-preview-slide",p.innerHTML=pn(n),s.appendChild(p)}c.appendChild(s);let d=document.createElement("div");d.className="thumb-copy",d.innerHTML=` + ${Be(n.kicker||"")} + ${Be(n.title)} + `,c.appendChild(d);let u=document.createElement("span");u.className="thumb-number",u.textContent=String(i+1),c.appendChild(u),c.addEventListener("click",()=>t.selectSlide(n.id)),r.append(c)}),requestAnimationFrame(()=>{Ns(),Ga()})}}var Ua=960,Wa=540;function np(e){let{host:t}=Bs({hostClass:"thumb-preview-html",frameClass:"thumb-preview-frame",html:e,onReady:()=>wr(t)});return t}function ip(e,t){let r=e?.closest?.(`.${br}`)||t?.querySelector?.(`.${br}`);if(r){wr(r);return}if(!e||!t)return;let{width:n,height:i}=Ls(t);if(!n||!i)return;let a=Math.min(n/Ua,i/Wa);e.style.width=`${Ua}px`,e.style.height=`${Wa}px`,e.style.transform=`scale(${a})`,e.style.transformOrigin="top left"}function ap(e){let t=e.querySelector(".thumb-preview-frame");if(t){ip(t,e);return}let r=e.querySelector(".thumb-preview-html, .thumb-preview-slide");if(!r)return;let n=Wh(e);if(!n)return;let i=n/Ua,a=Wa*i;r.style.width=`${Ua}px`,r.style.height=`${Wa}px`,r.style.transform=`scale(${i})`,r.style.transformOrigin="top left",e.style.height=`${a}px`}function Ns(){let e=Nt("slideThumbs");e&&(e.querySelectorAll(`.${br}`).forEach(t=>{wr(t)}),e.querySelectorAll(".thumb-preview").forEach(t=>{t.querySelector(`.${br}`)||ap(t)}))}var Mi=null,zi=null;function ad(){if(typeof ResizeObserver>"u")return;zi||(zi=new ResizeObserver(()=>{document.querySelectorAll(`.${br}`).forEach(t=>{wr(t)})})),zi.disconnect(),document.querySelectorAll(`.${br}`).forEach(t=>{zi.observe(t)});let e=Nt("slideCanvas");e&&zi.observe(e)}function Ga(){let e=Nt("slideThumbs");!e||typeof ResizeObserver>"u"||(Mi||(Mi=new ResizeObserver(()=>Ns())),Mi.disconnect(),Mi.observe(e),e.querySelectorAll(".thumb-preview").forEach(t=>{Mi.observe(t)}),ad())}function op(e){if(!String(e.brief?.topic||"").trim()){let n=String(e.title||"").trim();if(n===O("blankDeckTitle")||n===O("defaultDeckTitle")||n===O("newSlideTitle"))return!0}if(!e.slides?.length)return!0;let t=String(e.title||"").trim();return e.slides.length===1&&e.outline.length===1&&e.outline[0]===O("newSlideTitle")&&(t===O("blankDeckTitle")||t===O("newSlideTitle"))}function za(e,t){if(!e)return;if(!t){e.style.background="";return}let r=t.theme||{},i=(t.html?Ba(t.html):null)||r.background||"";e.style.background=i||""}function hn(e,t){let r=Nt("slideCanvas");if(!r)return;let n=_t(e),i=!!(e.generation?.active||e.generation?.steps?.some(o=>o.status==="running"));if(!n){r.classList.remove("is-html-slide"),r.classList.add("is-empty"),r.innerHTML=i?`
${Be(O("generationAgentWorking"))}

${Be(O("agentWorkingDetail"))}

`:`

${Be(O("welcomeTitle"))}

${Be(O("welcomeSubcopy"))}

`,Kc(r),za(r,null),si();return}if(op(e)&&!n.html&&!i){r.classList.remove("is-html-slide"),r.classList.add("is-empty"),r.innerHTML=`
-

${Le(U("welcomeTitle"))}

-

${Le(U("welcomeSubcopy"))}

+

${Be(O("welcomeTitle"))}

+

${Be(O("welcomeSubcopy"))}

- - - + + +
- `,Pc(r),Ea(r,null),Jn();return}if(r.classList.remove("is-empty"),n?.html){r.innerHTML="",r.classList.add("is-html-slide");let{host:o,frame:l}=gs({frameClass:"html-slide-frame",html:n.html,interactive:!0,onReady:c=>{Lh(c,n.id,t),Jn(),mr(o),requestAnimationFrame(()=>mr(o))}});r.append(o),Ea(r,n),r.classList.remove("is-entering"),r.offsetWidth,r.classList.add("is-entering"),Jn();return}r.classList.remove("is-html-slide"),r.innerHTML=n?dn(n,{selectedElementId:e.selectedElementId,editable:!0}):"",r.querySelectorAll(".slide-element").forEach(o=>{let l=o.dataset.elementId;o.addEventListener("click",c=>{c.stopPropagation(),t.selectElement(l)}),o.addEventListener("pointerdown",c=>{c.target?.isContentEditable&&!c.target.classList.contains("resize-handle")||t.beginDrag(c,l)})}),r.querySelectorAll("[data-edit-text]").forEach(o=>{o.addEventListener("blur",()=>{t.updateElementTextDirect(o.dataset.editText,o.textContent||"")}),o.addEventListener("keydown",l=>{(l.metaKey||l.ctrlKey)&&l.key==="Enter"&&o.blur()})}),r.querySelectorAll("[data-edit-list]").forEach(o=>{o.addEventListener("blur",()=>{t.updateElementListItemDirect(o.dataset.editList,Number(o.dataset.itemIndex),o.textContent||"")}),o.addEventListener("keydown",l=>{(l.metaKey||l.ctrlKey)&&l.key==="Enter"&&o.blur()})}),r.classList.remove("is-entering"),r.offsetWidth,r.classList.add("is-entering");let a=Mn(e);if(a)uh(a);else{let o=Ft("floatingToolbar");o&&o.classList.remove("is-visible")}Ea(r,n),Jn()}function Ia(e,t){let r=Ft("elementInspector"),n=Mn(e),i=Kt(e);if(!(!r||!i)){if(r.hidden){r.innerHTML="";return}if(!n){r.innerHTML=`${kc(i)}

${U("noSelection")}

`,Cc(r,t),r.querySelector("#slideNotesInput")?.addEventListener("input",a=>t.updateSlideNotes(a.target.value));return}r.innerHTML=` - ${kc(i)} - - - `,_c(r,t),r.querySelector("#slideNotesInput")?.addEventListener("input",a=>t.updateSlideNotes(a.target.value));return}r.innerHTML=` + ${Hc(i)} + + + -
- - - - + + + +
- - + +
- - `,["elementTextInput","elementItemsInput","elementDataInput","elementXInput","elementYInput","elementWInput","elementHInput","elementFontInput","elementWeightInput","elementColorInput","elementBgInput","slideNotesInput"].forEach(a=>r.querySelector(`#${a}`)?.addEventListener("input",()=>t.updateElementFromInspector())),Cc(r,t)}}function kc(e){return` + + `,["elementTextInput","elementItemsInput","elementDataInput","elementXInput","elementYInput","elementWInput","elementHInput","elementFontInput","elementWeightInput","elementColorInput","elementBgInput","slideNotesInput"].forEach(a=>r.querySelector(`#${a}`)?.addEventListener("input",()=>t.updateElementFromInspector())),_c(r,t)}}function Hc(e){return`
- - - - - + + + + +
- ${Bh(e)} - `}function Bh(e){let t=Array.isArray(e.quality?.issues)?e.quality.issues:[];return t.length?` + ${sp(e)} + `}function sp(e){let t=Array.isArray(e.quality?.issues)?e.quality.issues:[];return t.length?`
- ${Le(U("qualityReportTitle"))}: ${Math.round(Number(e.quality?.score??100))}/100 -
    ${t.map(r=>`
  • ${Le(r.message)}
  • `).join("")}
+ ${Be(O("qualityReportTitle"))}: ${Math.round(Number(e.quality?.score??100))}/100 +
    ${t.map(r=>`
  • ${Be(r.message)}
  • `).join("")}
- `:""}function Cc(e,t){["slideKickerInput","slideClaimInput","slideProofInput","slideSupportInput","slideSourceInput"].forEach(r=>{e.querySelector(`#${r}`)?.addEventListener("input",()=>t.updateSlideMethodology())})}function dn(e,t={}){if(e?.html)return``;let r=!!t.editable,n=t.selectedElementId||"",i=[`--slide-bg:${e.theme.background}`,`--slide-ink:${e.theme.ink}`,`--slide-muted:${e.theme.muted}`,`--slide-primary:${e.theme.primary}`,`--slide-accent:${e.theme.accent}`,`--slide-panel:${e.theme.panel||"#ffffff"}`].join(";");return`
- ${e.kicker?`
${Le(e.kicker)}
`:""} - ${e.proofObject?`
${Le(e.proofObject)}
`:""} - ${Rh(e)} - ${(e.elements||[]).map(a=>Ih(a,e.theme,r,n)).join("")} - ${e.sourceNote?`
${Le(e.sourceNote)}
`:""} -
`}function Rh(e){let t=Array.isArray(e.quality?.issues)?e.quality.issues:[];if(!t.length)return"";let r=t.filter(i=>i.severity==="high").length,n=r?U("qualityNeedsReview"):U("qualityHasWarnings");return`
${Le(n)}
`}function Pc(e){e.querySelectorAll("[data-welcome-prompt]").forEach(t=>{t.addEventListener("click",()=>{let r=Ft("topicInput");r&&(r.value=t.dataset.welcomePrompt||t.textContent||"",r.focus())})})}function Lh(e,t,r){if(!r?.updateSlideHtmlDirect)return;let n=e?.shadowRoot,i=n?.querySelector(`.${fs}`);if(!n||!i)return;if(!n.querySelector(`style[${xc}]`)){let c=document.createElement("style");c.setAttribute(xc,"true"),c.textContent=[`[${$n}] { cursor: text; -webkit-user-select: text !important; user-select: text !important; }`,`[${$n}]:hover { outline: 1.5px dashed rgba(37, 99, 235, 0.55); outline-offset: 1px; }`,`[${$n}]:focus { outline: 2px solid rgba(37, 99, 235, 0.85); outline-offset: 1px; }`].join(` -`),n.appendChild(c)}n.addEventListener("click",c=>{c.target?.closest?.("a[href]")&&c.preventDefault()},!0);let a=()=>{let c=Nh(e,i);c&&r.updateSlideHtmlDirect(t,c)},o=i.querySelectorAll("h1,h2,h3,h4,h5,h6,p,li,span,strong,em,b,i,u,small,code,a,label,blockquote,td,th,dt,dd,figcaption,div"),l=0;o.forEach(c=>{Array.from(c.childNodes).some(d=>d.nodeType===Node.TEXT_NODE&&String(d.textContent||"").trim())&&(l+=1,c.setAttribute("contenteditable","true"),c.setAttribute("spellcheck","false"),c.setAttribute($n,"true"),c.addEventListener("blur",a),c.addEventListener("keydown",d=>{((d.metaKey||d.ctrlKey)&&d.key==="Enter"||d.key==="Escape")&&(d.preventDefault(),c.blur())}))}),l||console.warn("[ppt-live] no editable nodes bound for slide",{slideId:t,candidates:o.length})}function Nh(e,t){let r=String(e?._pptLiveSourceHtml||"");if(!r)return"";let n=new DOMParser().parseFromString(Wr(r),"text/html");if(!n.body)return"";let i=t.cloneNode(!0);i.querySelectorAll(`[${$n}]`).forEach(o=>{o.removeAttribute("contenteditable"),o.removeAttribute("spellcheck"),o.removeAttribute($n)}),n.body.innerHTML=i.innerHTML;let a=` -${n.documentElement.outerHTML}`;return e._pptLiveSourceHtml=a,a}function Wr(e){let t=String(e||"").trim();return t?/]/i.test(t)?t:`${t}`:''}function Ih(e,t,r,n){let i=r&&n===e.id,a=[`left:${e.x}%`,`top:${e.y}%`,`width:${e.w}%`,`height:${e.h}%`,`font-size:${zh(e.style.fontSize)}`,`font-weight:${e.style.fontWeight}`,`color:${Fc(e.style.color,t)}`,`text-align:${e.style.align||"left"}`,`background:${Fc(e.style.background,t)}`,`opacity:${e.style.opacity}`,`border-radius:${e.style.borderRadius}px`].join(";"),o="";if(e.type==="list")o=`
    ${(e.items||[]).map((l,c)=>r?`
  • ${Le(l)}
  • `:`
  • ${Le(l)}
  • `).join("")}
`;else if(e.type==="metric")o=`${Le(e.text)}${Le(e.label)}`;else if(e.type==="chart"){let l=Math.max(1,...(e.data||[]).map(c=>Number(c.value)||0));o=`${Le(e.text)}
${(e.data||[]).map(c=>`${Le(c.label)}`).join("")}
`}else e.type==="media"?o=`${Le(e.text||U("mediaPlaceholder"))}`:o=r?`${Le(e.text||"")}`:Le(e.text||"");return`
${o}${i?'':""}
`}function Fc(e,t){return!e||e==="transparent"?"transparent":e==="ink"?t.ink:e==="muted"?t.muted:e==="primary"?t.primary:e==="accent"?t.accent:e==="panel"?t.panel||"#ffffff":e==="soft"?Mh(t.primary,.1):e==="background"?t.background:e}function Mh(e,t){let r=String(e||"#0f766e").replace("#",""),n=parseInt(r.length===3?r.split("").map(l=>l+l).join(""):r,16),i=n>>16&255,a=n>>8&255,o=n&255;return`rgba(${i}, ${a}, ${o}, ${t})`}function zh(e){let t=Math.max(8,Number(e)||24);return`clamp(8px, ${Math.round(t/10.2*1e3)/1e3}cqw, ${t}px)`}function Ft(e){return document.getElementById(e)}function Oh(e,t){let r=Ft(e);r&&document.activeElement!==r&&(r.value=t??"")}function Uh(e){return Ft(e)?.value||""}function Ur(e,t){let r=Ft(e);r&&(r.textContent=String(t??""))}function Ba(e){return Math.round(Number(e)*10)/10}function Uc(e=document,t=!1){let r=e,n=r.defaultView||window,i=new Set(["SCRIPT","STYLE","PRE","CODE","SVG","TEXTAREA"]),a="strong,b,em,i,u,span,a,small,mark,sub,sup,code",o="p,h1,h2,h3,h4,h5,h6,li";function l(R){let B=String(R.className||"").toLowerCase(),P=String(R.getAttribute?.("role")||"").toLowerCase();return/h1|title|headline|hero/.test(B)||P==="heading"?"h1":/h2|subtitle|subhead|section-title/.test(B)?"h2":/h3|kicker|eyebrow|label|caption/.test(B)?"h3":"p"}function c(R){return!R||R==="transparent"||R==="rgba(0, 0, 0, 0)"}function s(){let R=r.body;if(!R)return;let B=n.getComputedStyle(R),P=parseFloat(B.width),z=parseFloat(B.height);R.style.width=P>0?`${P}px`:"1280px",R.style.height=z>0?`${z}px`:"720px",R.style.margin="0",R.style.padding=B.padding||"0",R.style.overflow="hidden",R.style.position=B.position==="static"?"relative":B.position,c(B.backgroundColor)||(R.style.backgroundColor=B.backgroundColor),B.color&&(R.style.color=B.color),r.documentElement.style.margin="0",r.documentElement.style.padding="0";let q=n.getComputedStyle(r.documentElement).backgroundColor;!c(q)&&c(B.backgroundColor)&&(R.style.backgroundColor=q)}function d(R){R.querySelectorAll("div").forEach(B=>{i.has(B.tagName)||[...B.childNodes].forEach(P=>{if(P.nodeType!==Node.TEXT_NODE)return;let z=P.textContent.replace(/\s+/g," ").trim();if(!z){P.remove();return}let q=r.createElement(l(B));q.textContent=z,B.replaceChild(q,P)})})}function u(R){R.querySelectorAll("span").forEach(B=>{let P=n.getComputedStyle(B),z=P.backgroundColor&&P.backgroundColor!=="rgba(0, 0, 0, 0)",q=h(P);if(!z&&!q)return;let S=r.createElement("p");B.className&&(S.className=B.className),B.getAttribute("style")&&S.setAttribute("style",B.getAttribute("style")),S.textContent=B.textContent,B.replaceWith(S)})}function f(R){R.querySelectorAll("div").forEach(B=>{let P=[...B.children].length>0&&[...B.children].every(S=>S.tagName==="SPAN"||S.tagName==="BR"),z=B.textContent.replace(/\s+/g," ").trim();if(!P||!z||B.querySelector("ul,ol,p,h1,h2,h3,h4,h5,h6"))return;let q=z.split(/\s*[•·▪-]\s+/).map(S=>S.trim()).filter(Boolean);if(q.length>=2){let S=r.createElement("ul");q.forEach(V=>{let v=r.createElement("li");v.textContent=V,S.appendChild(v)}),B.replaceChildren(S)}})}function h(R){return["Top","Right","Bottom","Left"].some(B=>parseFloat(R[`border${B}Width`]||0)>0)}function p(R){R.querySelectorAll(o).forEach(B=>{let P=n.getComputedStyle(B),z=P.backgroundColor&&P.backgroundColor!=="rgba(0, 0, 0, 0)",q=P.backgroundImage&&P.backgroundImage!=="none",S=h(P),V=P.boxShadow&&P.boxShadow!=="none";if(!z&&!q&&!S&&!V)return;let v=r.createElement("div");(z||q)&&(v.style.background=P.background,v.style.backgroundColor=P.backgroundColor),q&&!String(P.backgroundImage||"").includes("gradient")&&(v.style.backgroundImage="none"),S&&(v.style.border=P.border),P.borderRadius&&(v.style.borderRadius=P.borderRadius),V&&(v.style.boxShadow=P.boxShadow),P.padding&&(v.style.padding=P.padding),B.style.background="transparent",B.style.backgroundColor="transparent",B.style.backgroundImage="none",B.style.border="none",B.style.boxShadow="none",B.style.padding="0",B.parentNode.insertBefore(v,B),v.appendChild(B)})}function A(R){R.querySelectorAll("*").forEach(B=>{let P=n.getComputedStyle(B),z=P.backgroundImage||"";if(!z.includes("gradient"))return;let q=z.match(/#[0-9a-f]{3,8}|rgba?\([^)]+\)/i);B.style.backgroundImage="none",q?B.style.backgroundColor=q[0]:P.backgroundColor&&P.backgroundColor!=="rgba(0, 0, 0, 0)"&&(B.style.backgroundColor=P.backgroundColor)})}function y(R){R.querySelectorAll("div").forEach(B=>{let P=n.getComputedStyle(B),z=P.backgroundImage;!z||z==="none"||(B.style.backgroundImage="none",P.backgroundColor&&P.backgroundColor!=="rgba(0, 0, 0, 0)"&&(B.style.backgroundColor=P.backgroundColor))})}function m(R){R.querySelectorAll(a).forEach(B=>{B.style.setProperty("margin","0","important"),B.style.setProperty("padding","0","important"),B.style.setProperty("border","none","important"),B.style.setProperty("box-shadow","none","important"),B.style.setProperty("background","transparent","important"),B.style.setProperty("background-color","transparent","important"),B.style.setProperty("background-image","none","important"),n.getComputedStyle(B).display==="block"&&B.style.setProperty("display","inline","important")})}function w(R){R.querySelectorAll(a).forEach(B=>{B.removeAttribute("class"),B.removeAttribute("style")})}function x(R){R.querySelectorAll('link[rel="stylesheet"], style').forEach(B=>{B.id!=="ppt-live-export-safe-styles"&&B.remove()})}function C(R){R.querySelectorAll(a).forEach(B=>{let P=n.getComputedStyle(B),z=["marginTop","marginRight","marginBottom","marginLeft"].some(K=>parseFloat(P[K])>0),q=["paddingTop","paddingRight","paddingBottom","paddingLeft"].some(K=>parseFloat(P[K])>0),S=h(P),V=P.backgroundColor&&P.backgroundColor!=="rgba(0, 0, 0, 0)",v=P.backgroundImage&&P.backgroundImage!=="none";if(!z&&!q&&!S&&!V&&!v)return;let W=B.tagName.toLowerCase(),le=r.createElement(W);le.textContent=B.textContent,B.replaceWith(le)})}function T(R){let B=R.body||R.querySelector(".ppt-export-body");(B?[B,...B.querySelectorAll("*")]:[...R.querySelectorAll("body, body *")]).forEach(z=>{if(i.has(z.tagName))return;let q=n.getComputedStyle(z),S=z.style;q.position&&q.position!=="static"&&(S.position=q.position),q.display&&q.display!=="inline"&&(S.display=q.display),["left","top","right","bottom","width","height","maxWidth","maxHeight"].forEach(v=>{let W=q[v];W&&W!=="auto"&&W!=="none"&&W!=="0px"&&(S[v]=W)}),q.zIndex&&q.zIndex!=="auto"&&(S.zIndex=q.zIndex),q.color&&(S.color=q.color),q.fontSize&&(S.fontSize=q.fontSize),q.fontWeight&&(S.fontWeight=q.fontWeight),q.fontFamily&&(S.fontFamily=q.fontFamily),q.lineHeight&&q.lineHeight!=="normal"&&(S.lineHeight=q.lineHeight),q.textAlign&&(S.textAlign=q.textAlign);let V=q.backgroundColor;V&&V!=="rgba(0, 0, 0, 0)"&&(S.backgroundColor=V),q.border&&q.border!=="none"&&h(q)&&(S.border=q.border),q.borderRadius&&q.borderRadius!=="0px"&&(S.borderRadius=q.borderRadius),q.padding&&q.padding!=="0px"&&(S.padding=q.padding),q.gap&&q.gap!=="normal"&&(S.gap=q.gap),q.flexDirection&&q.flexDirection!=="row"&&(S.flexDirection=q.flexDirection),q.alignItems&&q.alignItems!=="normal"&&(S.alignItems=q.alignItems),q.justifyContent&&q.justifyContent!=="normal"&&(S.justifyContent=q.justifyContent)})}function I(R){let B="ppt-live-export-safe-styles";R.getElementById(B)?.remove();let P=r.createElement("style");P.id=B,P.textContent=` + `:""}function _c(e,t){["slideKickerInput","slideClaimInput","slideProofInput","slideSupportInput","slideSourceInput"].forEach(r=>{e.querySelector(`#${r}`)?.addEventListener("input",()=>t.updateSlideMethodology())})}function pn(e,t={}){if(e?.html)return``;let r=!!t.editable,n=t.selectedElementId||"",i=[`--slide-bg:${e.theme.background}`,`--slide-ink:${e.theme.ink}`,`--slide-muted:${e.theme.muted}`,`--slide-primary:${e.theme.primary}`,`--slide-accent:${e.theme.accent}`,`--slide-panel:${e.theme.panel||"#ffffff"}`].join(";");return`
+ ${e.kicker?`
${Be(e.kicker)}
`:""} + ${e.proofObject?`
${Be(e.proofObject)}
`:""} + ${lp(e)} + ${(e.elements||[]).map(a=>up(a,e.theme,r,n)).join("")} + ${e.sourceNote?`
${Be(e.sourceNote)}
`:""} +
`}function lp(e){let t=Array.isArray(e.quality?.issues)?e.quality.issues:[];if(!t.length)return"";let r=t.filter(i=>i.severity==="high").length,n=r?O("qualityNeedsReview"):O("qualityHasWarnings");return`
${Be(n)}
`}function Kc(e){e.querySelectorAll("[data-welcome-prompt]").forEach(t=>{t.addEventListener("click",()=>{let r=Nt("topicInput");r&&(r.value=t.dataset.welcomePrompt||t.textContent||"",r.focus())})})}function cp(e,t,r){if(!r?.updateSlideHtmlDirect)return;let n=e?.shadowRoot,i=n?.querySelector(`.${Ds}`);if(!n||!i)return;if(!n.querySelector(`style[${Vc}]`)){let c=document.createElement("style");c.setAttribute(Vc,"true"),c.textContent=[`[${li}] { cursor: text; -webkit-user-select: text !important; user-select: text !important; }`,`[${li}]:hover { outline: 1.5px dashed rgba(37, 99, 235, 0.55); outline-offset: 1px; }`,`[${li}]:focus { outline: 2px solid rgba(37, 99, 235, 0.85); outline-offset: 1px; }`].join(` +`),n.appendChild(c)}n.addEventListener("click",c=>{c.target?.closest?.("a[href]")&&c.preventDefault()},!0);let a=()=>{let c=dp(e,i);c&&r.updateSlideHtmlDirect(t,c)},o=i.querySelectorAll("h1,h2,h3,h4,h5,h6,p,li,span,strong,em,b,i,u,small,code,a,label,blockquote,td,th,dt,dd,figcaption,div"),l=0;o.forEach(c=>{Array.from(c.childNodes).some(d=>d.nodeType===Node.TEXT_NODE&&String(d.textContent||"").trim())&&(l+=1,c.setAttribute("contenteditable","true"),c.setAttribute("spellcheck","false"),c.setAttribute(li,"true"),c.addEventListener("blur",a),c.addEventListener("keydown",d=>{((d.metaKey||d.ctrlKey)&&d.key==="Enter"||d.key==="Escape")&&(d.preventDefault(),c.blur())}))}),l||console.warn("[ppt-live] no editable nodes bound for slide",{slideId:t,candidates:o.length})}function dp(e,t){let r=String(e?._pptLiveSourceHtml||"");if(!r)return"";let n=new DOMParser().parseFromString(Ur(r),"text/html");if(!n.body)return"";let i=t.cloneNode(!0);i.querySelectorAll(`[${li}]`).forEach(o=>{o.removeAttribute("contenteditable"),o.removeAttribute("spellcheck"),o.removeAttribute(li)}),n.body.innerHTML=i.innerHTML;let a=` +${n.documentElement.outerHTML}`;return e._pptLiveSourceHtml=a,a}function Ur(e){let t=String(e||"").trim();return t?/]/i.test(t)?t:`${t}`:''}function up(e,t,r,n){let i=r&&n===e.id,a=[`left:${e.x}%`,`top:${e.y}%`,`width:${e.w}%`,`height:${e.h}%`,`font-size:${hp(e.style.fontSize)}`,`font-weight:${e.style.fontWeight}`,`color:${Qc(e.style.color,t)}`,`text-align:${e.style.align||"left"}`,`background:${Qc(e.style.background,t)}`,`opacity:${e.style.opacity}`,`border-radius:${e.style.borderRadius}px`].join(";"),o="";if(e.type==="list")o=`
    ${(e.items||[]).map((l,c)=>r?`
  • ${Be(l)}
  • `:`
  • ${Be(l)}
  • `).join("")}
`;else if(e.type==="metric")o=`${Be(e.text)}${Be(e.label)}`;else if(e.type==="chart"){let l=Math.max(1,...(e.data||[]).map(c=>Number(c.value)||0));o=`${Be(e.text)}
${(e.data||[]).map(c=>`${Be(c.label)}`).join("")}
`}else e.type==="media"?o=`${Be(e.text||O("mediaPlaceholder"))}`:o=r?`${Be(e.text||"")}`:Be(e.text||"");return`
${o}${i?'':""}
`}function Qc(e,t){return!e||e==="transparent"?"transparent":e==="ink"?t.ink:e==="muted"?t.muted:e==="primary"?t.primary:e==="accent"?t.accent:e==="panel"?t.panel||"#ffffff":e==="soft"?fp(t.primary,.1):e==="background"?t.background:e}function fp(e,t){let r=String(e||"#0f766e").replace("#",""),n=parseInt(r.length===3?r.split("").map(l=>l+l).join(""):r,16),i=n>>16&255,a=n>>8&255,o=n&255;return`rgba(${i}, ${a}, ${o}, ${t})`}function hp(e){let t=Math.max(8,Number(e)||24);return`clamp(8px, ${Math.round(t/10.2*1e3)/1e3}cqw, ${t}px)`}function Nt(e){return document.getElementById(e)}function pp(e,t){let r=Nt(e);r&&document.activeElement!==r&&(r.value=t??"")}function Ap(e){return Nt(e)?.value||""}function Ts(e,t){let r=Nt(e);r&&(r.textContent=String(t??""))}function Oa(e){return Math.round(Number(e)*10)/10}function od(e=document,t=!1){let r=e,n=r.defaultView||window,i=new Set(["SCRIPT","STYLE","PRE","CODE","SVG","TEXTAREA"]),a="strong,b,em,i,u,span,a,small,mark,sub,sup,code",o="p,h1,h2,h3,h4,h5,h6,li";function l(L){let D=String(L.className||"").toLowerCase(),T=String(L.getAttribute?.("role")||"").toLowerCase();return/h1|title|headline|hero/.test(D)||T==="heading"?"h1":/h2|subtitle|subhead|section-title/.test(D)?"h2":/h3|kicker|eyebrow|label|caption/.test(D)?"h3":"p"}function c(L){return!L||L==="transparent"||L==="rgba(0, 0, 0, 0)"}function s(){let L=r.body;if(!L)return;let D=n.getComputedStyle(L),T=parseFloat(D.width),G=parseFloat(D.height);L.style.width=T>0?`${T}px`:"1280px",L.style.height=G>0?`${G}px`:"720px",L.style.margin="0",L.style.padding=D.padding||"0",L.style.overflow="hidden",L.style.position=D.position==="static"?"relative":D.position,c(D.backgroundColor)||(L.style.backgroundColor=D.backgroundColor),D.color&&(L.style.color=D.color),r.documentElement.style.margin="0",r.documentElement.style.padding="0";let V=n.getComputedStyle(r.documentElement).backgroundColor;!c(V)&&c(D.backgroundColor)&&(L.style.backgroundColor=V)}function d(L){L.querySelectorAll("div").forEach(D=>{i.has(D.tagName)||[...D.childNodes].forEach(T=>{if(T.nodeType!==Node.TEXT_NODE)return;let G=T.textContent.replace(/\s+/g," ").trim();if(!G){T.remove();return}let V=r.createElement(l(D));V.textContent=G,D.replaceChild(V,T)})})}function u(L){L.querySelectorAll("span").forEach(D=>{let T=n.getComputedStyle(D),G=T.backgroundColor&&T.backgroundColor!=="rgba(0, 0, 0, 0)",V=f(T);if(!G&&!V)return;let C=r.createElement("p");D.className&&(C.className=D.className),D.getAttribute("style")&&C.setAttribute("style",D.getAttribute("style")),C.textContent=D.textContent,D.replaceWith(C)})}function p(L){L.querySelectorAll("div").forEach(D=>{let T=[...D.children].length>0&&[...D.children].every(C=>C.tagName==="SPAN"||C.tagName==="BR"),G=D.textContent.replace(/\s+/g," ").trim();if(!T||!G||D.querySelector("ul,ol,p,h1,h2,h3,h4,h5,h6"))return;let V=G.split(/\s*[•·▪-]\s+/).map(C=>C.trim()).filter(Boolean);if(V.length>=2){let C=r.createElement("ul");V.forEach(q=>{let y=r.createElement("li");y.textContent=q,C.appendChild(y)}),D.replaceChildren(C)}})}function f(L){return["Top","Right","Bottom","Left"].some(D=>parseFloat(L[`border${D}Width`]||0)>0)}function h(L){L.querySelectorAll(o).forEach(D=>{let T=n.getComputedStyle(D),G=T.backgroundColor&&T.backgroundColor!=="rgba(0, 0, 0, 0)",V=T.backgroundImage&&T.backgroundImage!=="none",C=f(T),q=T.boxShadow&&T.boxShadow!=="none";if(!G&&!V&&!C&&!q)return;let y=r.createElement("div");(G||V)&&(y.style.background=T.background,y.style.backgroundColor=T.backgroundColor),V&&!String(T.backgroundImage||"").includes("gradient")&&(y.style.backgroundImage="none"),C&&(y.style.border=T.border),T.borderRadius&&(y.style.borderRadius=T.borderRadius),q&&(y.style.boxShadow=T.boxShadow),T.padding&&(y.style.padding=T.padding),D.style.background="transparent",D.style.backgroundColor="transparent",D.style.backgroundImage="none",D.style.border="none",D.style.boxShadow="none",D.style.padding="0",D.parentNode.insertBefore(y,D),y.appendChild(D)})}function A(L){L.querySelectorAll("*").forEach(D=>{let T=n.getComputedStyle(D),G=T.backgroundImage||"";if(!G.includes("gradient"))return;let V=G.match(/#[0-9a-f]{3,8}|rgba?\([^)]+\)/i);D.style.backgroundImage="none",V?D.style.backgroundColor=V[0]:T.backgroundColor&&T.backgroundColor!=="rgba(0, 0, 0, 0)"&&(D.style.backgroundColor=T.backgroundColor)})}function v(L){L.querySelectorAll("div").forEach(D=>{let T=n.getComputedStyle(D),G=T.backgroundImage;!G||G==="none"||(D.style.backgroundImage="none",T.backgroundColor&&T.backgroundColor!=="rgba(0, 0, 0, 0)"&&(D.style.backgroundColor=T.backgroundColor))})}function g(L){L.querySelectorAll(a).forEach(D=>{D.style.setProperty("margin","0","important"),D.style.setProperty("padding","0","important"),D.style.setProperty("border","none","important"),D.style.setProperty("box-shadow","none","important"),D.style.setProperty("background","transparent","important"),D.style.setProperty("background-color","transparent","important"),D.style.setProperty("background-image","none","important"),n.getComputedStyle(D).display==="block"&&D.style.setProperty("display","inline","important")})}function b(L){L.querySelectorAll(a).forEach(D=>{D.removeAttribute("class"),D.removeAttribute("style")})}function x(L){L.querySelectorAll('link[rel="stylesheet"], style').forEach(D=>{D.id!=="ppt-live-export-safe-styles"&&D.remove()})}function S(L){L.querySelectorAll(a).forEach(D=>{let T=n.getComputedStyle(D),G=["marginTop","marginRight","marginBottom","marginLeft"].some(_=>parseFloat(T[_])>0),V=["paddingTop","paddingRight","paddingBottom","paddingLeft"].some(_=>parseFloat(T[_])>0),C=f(T),q=T.backgroundColor&&T.backgroundColor!=="rgba(0, 0, 0, 0)",y=T.backgroundImage&&T.backgroundImage!=="none";if(!G&&!V&&!C&&!q&&!y)return;let M=D.tagName.toLowerCase(),ne=r.createElement(M);ne.textContent=D.textContent,D.replaceWith(ne)})}function F(L){let D=L.body||L.querySelector(".ppt-export-body");(D?[D,...D.querySelectorAll("*")]:[...L.querySelectorAll("body, body *")]).forEach(G=>{if(i.has(G.tagName))return;let V=n.getComputedStyle(G),C=G.style;V.position&&V.position!=="static"&&(C.position=V.position),V.display&&V.display!=="inline"&&(C.display=V.display),["left","top","right","bottom","width","height","maxWidth","maxHeight"].forEach(y=>{let M=V[y];M&&M!=="auto"&&M!=="none"&&M!=="0px"&&(C[y]=M)}),V.zIndex&&V.zIndex!=="auto"&&(C.zIndex=V.zIndex),V.color&&(C.color=V.color),V.fontSize&&(C.fontSize=V.fontSize),V.fontWeight&&(C.fontWeight=V.fontWeight),V.fontFamily&&(C.fontFamily=V.fontFamily),V.lineHeight&&V.lineHeight!=="normal"&&(C.lineHeight=V.lineHeight),V.textAlign&&(C.textAlign=V.textAlign);let q=V.backgroundColor;q&&q!=="rgba(0, 0, 0, 0)"&&(C.backgroundColor=q),V.border&&V.border!=="none"&&f(V)&&(C.border=V.border),V.borderRadius&&V.borderRadius!=="0px"&&(C.borderRadius=V.borderRadius),V.padding&&V.padding!=="0px"&&(C.padding=V.padding),V.gap&&V.gap!=="normal"&&(C.gap=V.gap),V.flexDirection&&V.flexDirection!=="row"&&(C.flexDirection=V.flexDirection),V.alignItems&&V.alignItems!=="normal"&&(C.alignItems=V.alignItems),V.justifyContent&&V.justifyContent!=="normal"&&(C.justifyContent=V.justifyContent)})}function N(L){let D="ppt-live-export-safe-styles";L.getElementById(D)?.remove();let T=r.createElement("style");T.id=D,T.textContent=` ${a}, [class] ${a.split(",").join(", [class] ")} { margin: 0 !important; padding: 0 !important; @@ -86,19 +86,19 @@ ${n.documentElement.outerHTML}`;return e._pptLiveSourceHtml=a,a}function Wr(e){l p, h1, h2, h3, h4, h5, h6, li { box-shadow: none !important; } - `,(R.head||R.documentElement).appendChild(P)}s(),d(r),u(r),f(r),A(r),y(r),t?(p(r),m(r),C(r),I(r),C(r),T(r),r.querySelectorAll("[class]").forEach(R=>R.removeAttribute("class")),x(r),w(r),m(r),C(r),I(r)):T(r)}function Wc(e=document){let t=e.defaultView||window,r=e.body,n=t.getComputedStyle(r),i={width:parseFloat(n.width),height:parseFloat(n.height),scrollWidth:r.scrollWidth,scrollHeight:r.scrollHeight},a=[],o=Math.max(0,i.scrollWidth-i.width-1),l=Math.max(0,i.scrollHeight-i.height-1),c=o*.75,s=l*.75;if(c>0||s>0){let d=[];c>0&&d.push(`${c.toFixed(1)}pt horizontally`),s>0&&d.push(`${s.toFixed(1)}pt vertically`);let u=s>0?' (Remember: leave 0.5" margin at bottom of slide)':"";a.push(`HTML content overflows body by ${d.join(" and ")}${u}`)}return{...i,errors:a}}function Gc(e=document){let t=e,r=t.defaultView||window,n=.75,i=96,a=["impact"],o=j=>{if(!j)return!1;let $=j.toLowerCase().replace(/['"]/g,"").split(",")[0].trim();return a.includes($)},l=j=>j/i,c=j=>parseFloat(j)*n,s=j=>{if(j==="rgba(0, 0, 0, 0)"||j==="transparent")return"FFFFFF";let $=j.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return $?$.slice(1).map(Y=>parseInt(Y).toString(16).padStart(2,"0")).join(""):"FFFFFF"},d=j=>{let $=j.match(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/);if(!$||!$[4])return null;let Y=parseFloat($[4]);return Math.round((1-Y)*100)},u=j=>{let $=String(j||"").match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);return $?{r:parseInt($[1],10),g:parseInt($[2],10),b:parseInt($[3],10),a:$[4]!=null?parseFloat($[4]):1}:null},f=j=>{let $=String(j||"0E0E12").replace("#","");return{r:parseInt($.slice(0,2),16),g:parseInt($.slice(2,4),16),b:parseInt($.slice(4,6),16)}},h=(j,$="0E0E12")=>{let Y=u(j);if(!Y)return{fill:s(j),transparency:d(j)};if(Y.a>=.98)return{fill:s(j),transparency:null};let Se=f($),ye=Math.round(Se.r*(1-Y.a)+Y.r*Y.a),ae=Math.round(Se.g*(1-Y.a)+Y.g*Y.a),ve=Math.round(Se.b*(1-Y.a)+Y.b*Y.a);return{fill:[ye,ae,ve].map(Me=>Me.toString(16).padStart(2,"0")).join("").toUpperCase(),transparency:null}},p=(j,$)=>$==="uppercase"?j.toUpperCase():$==="lowercase"?j.toLowerCase():$==="capitalize"?j.replace(/\b\w/g,Y=>Y.toUpperCase()):j,A=(j,$)=>{let Y=0;if($==="vertical-rl"?Y=90:$==="vertical-lr"&&(Y=270),j&&j!=="none"){let Se=j.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);if(Se)Y+=parseFloat(Se[1]);else{let ye=j.match(/matrix\(([^)]+)\)/);if(ye){let ae=ye[1].split(",").map(parseFloat),ve=Math.atan2(ae[1],ae[0])*(180/Math.PI);Y+=Math.round(ve)}}}return Y=Y%360,Y<0&&(Y+=360),Y===0?null:Y},y=(j,$,Y)=>{if(Y===null)return{x:$.left,y:$.top,w:$.width,h:$.height};if(Y===90||Y===270){let ve=$.left+$.width/2,Me=$.top+$.height/2;return{x:ve-$.height/2,y:Me-$.width/2,w:$.height,h:$.width}}let ye=$.left+$.width/2,ae=$.top+$.height/2;return{x:ye-j.offsetWidth/2,y:ae-j.offsetHeight/2,w:j.offsetWidth,h:j.offsetHeight}},m=j=>{if(!j||j==="none"||j.match(/inset/))return null;let Y=j.match(/rgba?\([^)]+\)/),Se=j.match(/([-\d.]+)(px|pt)/g);if(!Se||Se.length<2)return null;let ye=parseFloat(Se[0]),ae=parseFloat(Se[1]),ve=Se.length>2?parseFloat(Se[2]):0,Me=0;(ye!==0||ae!==0)&&(Me=Math.atan2(ae,ye)*(180/Math.PI),Me<0&&(Me+=360));let be=Math.sqrt(ye*ye+ae*ae)*n,Ie=.5;if(Y){let Ee=Y[0].match(/[\d.]+\)$/);Ee&&(Ie=parseFloat(Ee[0].replace(")","")))}return{type:"outer",angle:Math.round(Me),blur:ve*.75,color:Y?s(Y[0]):"000000",offset:be,opacity:Ie}},w=(j,$={},Y=[],Se=ye=>ye)=>{let ye=!1;return j.childNodes.forEach(ae=>{let ve=Se,Me=ae.nodeType===Node.TEXT_NODE||ae.tagName==="BR";if(Me){let be=ae.tagName==="BR"?` -`:ve(ae.textContent.replace(/\s+/g," ")),Ie=Y[Y.length-1];ye&&Ie?Ie.text+=be:Y.push({text:be,options:{...$}})}else if(ae.nodeType===Node.ELEMENT_NODE&&ae.textContent.trim()){let be={...$},Ie=r.getComputedStyle(ae);if(ae.tagName==="SPAN"||ae.tagName==="B"||ae.tagName==="STRONG"||ae.tagName==="I"||ae.tagName==="EM"||ae.tagName==="U"){if((Ie.fontWeight==="bold"||parseInt(Ie.fontWeight)>=600)&&!o(Ie.fontFamily)&&(be.bold=!0),Ie.fontStyle==="italic"&&(be.italic=!0),Ie.textDecoration&&Ie.textDecoration.includes("underline")&&(be.underline=!0),Ie.color&&Ie.color!=="rgb(0, 0, 0)"){be.color=s(Ie.color);let b=d(Ie.color);b!==null&&(be.transparency=b)}if(Ie.fontSize&&(be.fontSize=c(Ie.fontSize)),Ie.textTransform&&Ie.textTransform!=="none"){let b=Ie.textTransform;ve=de=>p(de,b)}Ie.marginLeft&&parseFloat(Ie.marginLeft)>0&&v.push(`Inline element <${ae.tagName.toLowerCase()}> has margin-left which is not supported in PowerPoint. Remove margin from inline elements.`),Ie.marginRight&&parseFloat(Ie.marginRight)>0&&v.push(`Inline element <${ae.tagName.toLowerCase()}> has margin-right which is not supported in PowerPoint. Remove margin from inline elements.`),Ie.marginTop&&parseFloat(Ie.marginTop)>0&&v.push(`Inline element <${ae.tagName.toLowerCase()}> has margin-top which is not supported in PowerPoint. Remove margin from inline elements.`),Ie.marginBottom&&parseFloat(Ie.marginBottom)>0&&v.push(`Inline element <${ae.tagName.toLowerCase()}> has margin-bottom which is not supported in PowerPoint. Remove margin from inline elements.`),w(ae,be,Y,ve)}}ye=Me}),Y.length>0&&(Y[0].text=Y[0].text.replace(/^\s+/,""),Y[Y.length-1].text=Y[Y.length-1].text.replace(/\s+$/,"")),Y.filter(ae=>ae.text.length>0)},x=j=>!j||j==="transparent"||j==="rgba(0, 0, 0, 0)",C=j=>{let $=[j,t.documentElement,j?.querySelector?.(":scope > section, :scope > div, :scope > main")].filter(Boolean);for(let Y of $){let Se=r.getComputedStyle(Y),ye=Se.backgroundImage||"";if(ye.includes("linear-gradient")||ye.includes("radial-gradient"))return{gradient:!0};if(ye&&ye!=="none"){let ve=ye.match(/url\(["']?([^"')]+)["']?\)/);if(ve)return{type:"image",path:ve[1]}}let ae=Se.backgroundColor;if(!x(ae))return{type:"color",value:s(ae)}}return{type:"color",value:"FFFFFF"}},T=t.body,I=T.getBoundingClientRect(),R=j=>({left:j.left-I.left,top:j.top-I.top,width:j.width,height:j.height}),B=j=>R(j.getBoundingClientRect()),P=(j,$)=>{let Y=u(j.color);return!Y||Y.a>=.2||!$.textContent.trim()?s(j.color):"E8E8E8"},z=(j,$,Y)=>{let{x:Se,y:ye,w:ae,h:ve}=y(j,$,Y),Me=I.width,be=I.height,Ie=Math.max(8,Me-Se-4),Ee=j.scrollHeight||0,b=/^H[1-6]$/.test(j.tagName),de=b?Math.min(Math.max(8,ae*.05),32):Math.min(Math.max(2,ae*.02),12);b?ae=Math.max(ae+de,Me*.92-Se):ae=Math.min(ae+de,Ie),ae=Math.min(ae,Ie);let te=Math.max(6,ve*(b?.18:.12)),O=Math.max(8,be-ye-4);return Ee>ve+2?ve=Math.min(Ee+te,O):ve=Math.min(ve+te,O),{x:Se,y:ye,w:ae,h:ve}},q=j=>{let $=r.getComputedStyle(j).zIndex;if(!$||$==="auto")return 0;let Y=parseInt($,10);return Number.isFinite(Y)?Y:0},S=(j,$)=>{$&&(j.zIndex=q($)),ce.push(j)},V=(j,$,Y)=>{let ye=r.getComputedStyle(j).listStyleColor;if(ye&&ye!=="rgba(0, 0, 0, 0)"){let ae=s(ye);if(ae&&ae!==Y)return ae}for(let ae of $)try{let ve=r.getComputedStyle(ae,"::marker");if(ve?.color){let Me=s(ve.color);if(Me&&Me!==Y)return Me}}catch{}return null},v=[],W=C(T);W.gradient&&v.push("CSS gradients are not supported. Use Sharp to rasterize gradients as PNG images first, then reference with background-image: url('gradient.png')");let le=W.gradient?{type:"color",value:"FFFFFF"}:{type:W.type,...W.path?{path:W.path}:{value:W.value}},K=le.value||"0E0E12",ce=[],ie=[],Te=["P","H1","H2","H3","H4","H5","H6","UL","OL","LI"],Q=new Set;t.querySelectorAll("*").forEach(j=>{if(Q.has(j))return;if(j.tagName==="DIV"&&j.dataset&&j.dataset.pptxMerge==="true"){let F=B(j);if(F.width===0||F.height===0){Q.add(j);return}if(j.querySelector('[data-pptx-merge="true"]')){v.push("data-pptx-merge container cannot contain another data-pptx-merge container. Nested merge is not supported."),Q.add(j);return}let G=r.getComputedStyle(j);if(G.backgroundImage&&G.backgroundImage!=="none"){v.push("Background images on data-pptx-merge container are not supported. Use solid colors or borders, or layer images via slide.addImage().");return}let se=G.backgroundColor&&G.backgroundColor!=="rgba(0, 0, 0, 0)",he=[G.borderTopWidth,G.borderRightWidth,G.borderBottomWidth,G.borderLeftWidth].map(Be=>parseFloat(Be)||0),pe=he.some(Be=>Be>0)&&he.every(Be=>Be===he[0]);(se||pe)&&ce.push({type:"shape",text:"",position:{x:l(F.left),y:l(F.top),w:l(F.width),h:l(F.height)},shape:{fill:se?s(G.backgroundColor):null,transparency:se?d(G.backgroundColor):null,line:pe?{color:s(G.borderColor),width:c(G.borderWidth)}:null,rectRadius:(()=>{let Be=G.borderRadius,at=parseFloat(Be);if(at===0)return 0;if(Be.includes("%")){if(at>=50)return 1;let ht=Math.min(F.width,F.height);return at/100*l(ht)}return Be.includes("pt")?at/72:at/i})(),shadow:m(G.boxShadow)}});let ke=Array.from(j.querySelectorAll("p, h1, h2, h3, h4, h5, h6"));if(ke.length===0){v.push("data-pptx-merge container has no

/ children to merge. Remove the data-pptx-merge attribute or add text elements."),Q.add(j);return}let fe=r.getComputedStyle(ke[0]),De={fontSize:c(fe.fontSize),fontFace:fe.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),color:s(fe.color),align:fe.textAlign==="start"?"left":fe.textAlign,lineSpacing:fe.lineHeight&&fe.lineHeight!=="normal"?c(fe.lineHeight):null,paraSpaceBefore:0,paraSpaceAfter:0,margin:[c(G.paddingLeft),c(G.paddingRight),c(G.paddingBottom),c(G.paddingTop)]},qe=d(fe.color);qe!==null&&(De.transparency=qe);let ze=[];if(ke.forEach((Be,at)=>{let ht=at===ke.length-1,E=r.getComputedStyle(Be),oe=E.textTransform,Ae=c(E.fontSize),Pe=E.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),H=s(E.color),ue=E.fontWeight==="bold"||parseInt(E.fontWeight)>=600,k=E.fontStyle==="italic",ge=E.textDecoration.includes("underline"),Oe={};Ae!==De.fontSize&&(Oe.fontSize=Ae),Pe!==De.fontFace&&(Oe.fontFace=Pe),H!==De.color&&(Oe.color=H),ue&&!o(E.fontFamily)&&(Oe.bold=!0),k&&(Oe.italic=!0),ge&&(Oe.underline=!0);let g=Be.querySelector("b, i, u, strong, em, span, br"),ee;if(g)ee=w(Be,Oe,[],ne=>p(ne,oe));else{let ne=p(Be.textContent.trim(),oe);if(!ne)return;ee=[{text:ne,options:{...Oe}}]}ee.length>0&&!ht&&(ee[ee.length-1].options.breakLine=!0),ze.push(...ee),Q.add(Be)}),ze.length===0){Q.add(j);return}ce.push({type:"merged-text",items:ze,position:{x:l(F.left),y:l(F.top),w:l(F.width),h:l(F.height)},style:De}),Q.add(j);return}if(Te.includes(j.tagName)){let F=r.getComputedStyle(j),G=F.backgroundColor&&F.backgroundColor!=="rgba(0, 0, 0, 0)",se=F.borderWidth&&parseFloat(F.borderWidth)>0||F.borderTopWidth&&parseFloat(F.borderTopWidth)>0||F.borderRightWidth&&parseFloat(F.borderRightWidth)>0||F.borderBottomWidth&&parseFloat(F.borderBottomWidth)>0||F.borderLeftWidth&&parseFloat(F.borderLeftWidth)>0,he=F.boxShadow&&F.boxShadow!=="none";if(G||se||he){let _=B(j);if(_.width>0&&_.height>0){let pe=[F.borderTopWidth,F.borderRightWidth,F.borderBottomWidth,F.borderLeftWidth].map(De=>parseFloat(De)||0),ke=pe.some(De=>De>0)&&pe.every(De=>De===pe[0]),fe=G?h(F.backgroundColor,K):{fill:null,transparency:null};if(fe.fill||ke){let De=F.borderRadius,qe=parseFloat(De);S({type:"shape",text:"",position:{x:l(_.left),y:l(_.top),w:l(_.width),h:l(_.height)},shape:{fill:fe.fill,transparency:fe.transparency,line:ke?{color:s(F.borderColor),width:c(F.borderWidth)}:null,rectRadius:(()=>{if(!qe)return 0;if(De.includes("%")){if(qe>=50)return 1;let ze=Math.min(_.width,_.height);return qe/100*l(ze)}return De.includes("pt")?qe/72:qe/i})(),shadow:m(F.boxShadow)}},j)}}}}if(j.className&&j.className.includes("placeholder")){let F=B(j);F.width===0||F.height===0?v.push(`Placeholder "${j.id||"unnamed"}" has ${F.width===0?"width: 0":"height: 0"}. Check the layout CSS.`):ie.push({id:j.id||`placeholder-${ie.length}`,x:l(F.left),y:l(F.top),w:l(F.width),h:l(F.height)}),Q.add(j);return}if(j.tagName==="IMG"){let F=B(j);if(F.width>0&&F.height>0){ce.push({type:"image",src:j.src,position:{x:l(F.left),y:l(F.top),w:l(F.width),h:l(F.height)}}),Q.add(j);return}}if(new Set(["DIV","SECTION","ARTICLE","ASIDE"]).has(j.tagName)){let F=r.getComputedStyle(j),G=F.backgroundColor&&F.backgroundColor!=="rgba(0, 0, 0, 0)";for(let Be of j.childNodes)if(Be.nodeType===Node.TEXT_NODE){let at=Be.textContent.trim();at&&v.push(`DIV element contains unwrapped text "${at.substring(0,50)}${at.length>50?"...":""}". All text must be wrapped in

,

-

,
    , or
      tags to appear in PowerPoint.`)}let se=F.backgroundImage;if(se&&se!=="none"){v.push("Background images on DIV elements are not supported. Use solid colors or borders for shapes, or use slide.addImage() in PptxGenJS to layer images.");return}let he=F.borderTopWidth,_=F.borderRightWidth,pe=F.borderBottomWidth,ke=F.borderLeftWidth,fe=[he,_,pe,ke].map(Be=>parseFloat(Be)||0),De=fe.some(Be=>Be>0),qe=De&&fe.every(Be=>Be===fe[0]),ze=[];if(De&&!qe){let Be=B(j),at=l(Be.left),ht=l(Be.top),E=l(Be.width),oe=l(Be.height);if(parseFloat(he)>0){let Ae=c(he),Pe=Ae/72/2;ze.push({type:"line",x1:at,y1:ht+Pe,x2:at+E,y2:ht+Pe,width:Ae,color:s(F.borderTopColor)})}if(parseFloat(_)>0){let Ae=c(_),Pe=Ae/72/2;ze.push({type:"line",x1:at+E-Pe,y1:ht,x2:at+E-Pe,y2:ht+oe,width:Ae,color:s(F.borderRightColor)})}if(parseFloat(pe)>0){let Ae=c(pe),Pe=Ae/72/2;ze.push({type:"line",x1:at,y1:ht+oe-Pe,x2:at+E,y2:ht+oe-Pe,width:Ae,color:s(F.borderBottomColor)})}if(parseFloat(ke)>0){let Ae=c(ke),Pe=Ae/72/2;ze.push({type:"line",x1:at+Pe,y1:ht,x2:at+Pe,y2:ht+oe,width:Ae,color:s(F.borderLeftColor)})}}if(G||De){let Be=B(j);if(Be.width>=I.width*.97&&Be.height>=I.height*.97&&G){Q.add(j);return}if(Be.width>0&&Be.height>0){let ht=m(F.boxShadow);if(G||qe){let E=G?h(F.backgroundColor,K):{fill:null,transparency:null},oe=E.fill,Ae=E.transparency;!oe&&qe&&(oe=s(F.borderColor)||"2A2A30",Ae=Ae??88),S({type:"shape",text:"",position:{x:l(Be.left),y:l(Be.top),w:l(Be.width),h:l(Be.height)},shape:{fill:oe,transparency:Ae,line:qe?{color:s(F.borderColor),width:c(F.borderWidth)}:null,rectRadius:(()=>{let Pe=F.borderRadius,H=parseFloat(Pe);if(H===0)return 0;if(Pe.includes("%")){if(H>=50)return 1;let ue=Math.min(Be.width,Be.height);return H/100*l(ue)}return Pe.includes("pt")?H/72:H/i})(),shadow:ht}},j)}ze.forEach(E=>S(E,j)),Q.add(j);return}}}if(j.tagName==="UL"||j.tagName==="OL"){let F=B(j);if(F.width===0||F.height===0)return;let G=Array.from(j.querySelectorAll("li")),se=[],he=r.getComputedStyle(j),_=c(he.paddingLeft),pe=_*.5,ke=_*.5,fe=r.getComputedStyle(G[0]||j),De=s(fe.color),qe=V(j,G,De);G.forEach((Be,at)=>{let ht=at===G.length-1,E=w(Be,{breakLine:!1});E.length>0&&(E[0].text=E[0].text.replace(/^[•\-\*▪▸]\s*/,""),E[0].options.bullet={indent:ke}),E.length>0&&qe&&qe!==De&&E.unshift({text:"\u200B",options:{bullet:{indent:ke},color:qe,fontSize:E[0]?.options?.fontSize||c(fe.fontSize),breakLine:!1}}),E.length>0&&!ht&&(E[E.length-1].options.breakLine=!0),se.push(...E)});let ze=z(j,F,null);S({type:"list",items:se,position:{x:l(ze.x),y:l(ze.y),w:l(ze.w),h:l(ze.h)},style:{fontSize:c(fe.fontSize),fontFace:fe.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),color:De,bulletColor:qe,transparency:d(fe.color),align:fe.textAlign==="start"?"left":fe.textAlign,lineSpacing:fe.lineHeight&&fe.lineHeight!=="normal"?c(fe.lineHeight):null,paraSpaceBefore:0,paraSpaceAfter:c(fe.marginBottom),margin:[pe,0,0,0]}},j),G.forEach(Be=>Q.add(Be)),Q.add(j);return}if(!Te.includes(j.tagName))return;let Se=B(j),ye=j.textContent.trim();if(Se.width===0||Se.height===0||!ye)return;if(j.tagName!=="LI"&&/^[•\-\*▪▸○●◆◇■□]\s/.test(ye.trimStart())){v.push(`Text element <${j.tagName.toLowerCase()}> starts with bullet symbol "${ye.substring(0,20)}...". Use
        or
          lists instead of manual bullet symbols.`);return}let ae=r.getComputedStyle(j),ve=A(ae.transform,ae.writingMode),{x:Me,y:be,w:Ie,h:Ee}=z(j,Se,ve),b=ae.fontWeight==="bold"||parseInt(ae.fontWeight,10)>=600,de={fontSize:c(ae.fontSize),fontFace:ae.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),color:P(ae,j),align:ae.textAlign==="start"?"left":ae.textAlign,lineSpacing:c(ae.lineHeight),paraSpaceBefore:c(ae.marginTop),paraSpaceAfter:c(ae.marginBottom),margin:[c(ae.paddingLeft),c(ae.paddingRight),c(ae.paddingBottom),c(ae.paddingTop)]},te=d(ae.color);if(te!==null&&(de.transparency=te),ve!==null&&(de.rotate=ve),j.querySelector("b, i, u, strong, em, span, br")){let F=ae.textTransform,G={};b&&!o(ae.fontFamily)&&(G.bold=!0);let se=w(j,G,[],pe=>p(pe,F));!se.map(pe=>pe.text).join("").trim()&&ye&&(se=[{text:p(ye,F),options:{...G}}]);let _={...de};if(_.lineSpacing){let pe=Math.max(_.fontSize,...se.map(ke=>ke.options?.fontSize||0));if(pe>_.fontSize){let ke=_.lineSpacing/_.fontSize;_.lineSpacing=pe*ke}}S({type:j.tagName.toLowerCase(),text:se,position:{x:l(Me),y:l(be),w:l(Ie),h:l(Ee)},style:_},j)}else{let F=ae.textTransform,G=p(ye,F);S({type:j.tagName.toLowerCase(),text:G,position:{x:l(Me),y:l(be),w:l(Ie),h:l(Ee)},style:{...de,bold:b&&!o(ae.fontFamily),italic:ae.fontStyle==="italic",underline:ae.textDecoration.includes("underline")}},j)}Q.add(j)});let Z=j=>j==="shape"?0:j==="line"?1:j==="image"?2:3;return ce.sort((j,$)=>{let Y=(j.zIndex??0)-($.zIndex??0);return Y!==0?Y:Z(j.type)-Z($.type)}),{background:le,elements:ce,placeholders:ie,errors:v}}var sr={width:1280,height:720},Wh={p:["p"],h1:["h1"],h2:["h2"],h3:["h3"],h4:["h4"],h5:["h5"],h6:["h6"],list:["li"],"merged-text":["span","em","strong","b","i","p","h1","h2","h3","h4","h5","h6"]};function jc(e){return(e?.elements||[]).filter(t=>Vc.has(t.type)).length}function Gh(e){let t=new Set;for(let n of e?.elements||[])if(Vc.has(n.type))for(let i of Wh[n.type]||[n.type])t.add(i);return t.size?[...t].map(n=>`body[data-pptx-raster="1"] ${n} { + `,(L.head||L.documentElement).appendChild(T)}s(),d(r),u(r),p(r),A(r),v(r),t?(h(r),g(r),S(r),N(r),S(r),F(r),r.querySelectorAll("[class]").forEach(L=>L.removeAttribute("class")),x(r),b(r),g(r),S(r),N(r)):F(r)}function Is(e=document){let t=e.defaultView||window,r=e.body,n=t.getComputedStyle(r),i={width:parseFloat(n.width),height:parseFloat(n.height),scrollWidth:r.scrollWidth,scrollHeight:r.scrollHeight},a=[],o=Math.max(0,i.scrollWidth-i.width-1),l=Math.max(0,i.scrollHeight-i.height-1),c=o*.75,s=l*.75;if(c>0||s>0){let d=[];c>0&&d.push(`${c.toFixed(1)}pt horizontally`),s>0&&d.push(`${s.toFixed(1)}pt vertically`);let u=s>0?' (Remember: leave 0.5" margin at bottom of slide)':"";a.push(`HTML content overflows body by ${d.join(" and ")}${u}`)}return{...i,errors:a}}function Ms(e=document){let t=e,r=t.defaultView||window,n=.75,i=96,a=["impact"],o=j=>{if(!j)return!1;let $=j.toLowerCase().replace(/['"]/g,"").split(",")[0].trim();return a.includes($)},l=j=>j/i,c=j=>parseFloat(j)*n,s=j=>{if(j==="rgba(0, 0, 0, 0)"||j==="transparent")return"FFFFFF";let $=j.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return $?$.slice(1).map(Y=>parseInt(Y).toString(16).padStart(2,"0")).join(""):"FFFFFF"},d=j=>{let $=j.match(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/);if(!$||!$[4])return null;let Y=parseFloat($[4]);return Math.round((1-Y)*100)},u=j=>{let $=String(j||"").match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);return $?{r:parseInt($[1],10),g:parseInt($[2],10),b:parseInt($[3],10),a:$[4]!=null?parseFloat($[4]):1}:null},p=j=>{let $=String(j||"0E0E12").replace("#","");return{r:parseInt($.slice(0,2),16),g:parseInt($.slice(2,4),16),b:parseInt($.slice(4,6),16)}},f=(j,$="0E0E12")=>{let Y=u(j);if(!Y)return{fill:s(j),transparency:d(j)};if(Y.a>=.98)return{fill:s(j),transparency:null};let Se=p($),ye=Math.round(Se.r*(1-Y.a)+Y.r*Y.a),oe=Math.round(Se.g*(1-Y.a)+Y.g*Y.a),ve=Math.round(Se.b*(1-Y.a)+Y.b*Y.a);return{fill:[ye,oe,ve].map(Me=>Me.toString(16).padStart(2,"0")).join("").toUpperCase(),transparency:null}},h=(j,$)=>$==="uppercase"?j.toUpperCase():$==="lowercase"?j.toLowerCase():$==="capitalize"?j.replace(/\b\w/g,Y=>Y.toUpperCase()):j,A=(j,$)=>{let Y=0;if($==="vertical-rl"?Y=90:$==="vertical-lr"&&(Y=270),j&&j!=="none"){let Se=j.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);if(Se)Y+=parseFloat(Se[1]);else{let ye=j.match(/matrix\(([^)]+)\)/);if(ye){let oe=ye[1].split(",").map(parseFloat),ve=Math.atan2(oe[1],oe[0])*(180/Math.PI);Y+=Math.round(ve)}}}return Y=Y%360,Y<0&&(Y+=360),Y===0?null:Y},v=(j,$,Y)=>{if(Y===null)return{x:$.left,y:$.top,w:$.width,h:$.height};if(Y===90||Y===270){let ve=$.left+$.width/2,Me=$.top+$.height/2;return{x:ve-$.height/2,y:Me-$.width/2,w:$.height,h:$.width}}let ye=$.left+$.width/2,oe=$.top+$.height/2;return{x:ye-j.offsetWidth/2,y:oe-j.offsetHeight/2,w:j.offsetWidth,h:j.offsetHeight}},g=j=>{if(!j||j==="none"||j.match(/inset/))return null;let Y=j.match(/rgba?\([^)]+\)/),Se=j.match(/([-\d.]+)(px|pt)/g);if(!Se||Se.length<2)return null;let ye=parseFloat(Se[0]),oe=parseFloat(Se[1]),ve=Se.length>2?parseFloat(Se[2]):0,Me=0;(ye!==0||oe!==0)&&(Me=Math.atan2(oe,ye)*(180/Math.PI),Me<0&&(Me+=360));let be=Math.sqrt(ye*ye+oe*oe)*n,Ie=.5;if(Y){let Ee=Y[0].match(/[\d.]+\)$/);Ee&&(Ie=parseFloat(Ee[0].replace(")","")))}return{type:"outer",angle:Math.round(Me),blur:ve*.75,color:Y?s(Y[0]):"000000",offset:be,opacity:Ie}},b=(j,$={},Y=[],Se=ye=>ye)=>{let ye=!1;return j.childNodes.forEach(oe=>{let ve=Se,Me=oe.nodeType===Node.TEXT_NODE||oe.tagName==="BR";if(Me){let be=oe.tagName==="BR"?` +`:ve(oe.textContent.replace(/\s+/g," ")),Ie=Y[Y.length-1];ye&&Ie?Ie.text+=be:Y.push({text:be,options:{...$}})}else if(oe.nodeType===Node.ELEMENT_NODE&&oe.textContent.trim()){let be={...$},Ie=r.getComputedStyle(oe);if(oe.tagName==="SPAN"||oe.tagName==="B"||oe.tagName==="STRONG"||oe.tagName==="I"||oe.tagName==="EM"||oe.tagName==="U"){if((Ie.fontWeight==="bold"||parseInt(Ie.fontWeight)>=600)&&!o(Ie.fontFamily)&&(be.bold=!0),Ie.fontStyle==="italic"&&(be.italic=!0),Ie.textDecoration&&Ie.textDecoration.includes("underline")&&(be.underline=!0),Ie.color&&Ie.color!=="rgb(0, 0, 0)"){be.color=s(Ie.color);let w=d(Ie.color);w!==null&&(be.transparency=w)}if(Ie.fontSize&&(be.fontSize=c(Ie.fontSize)),Ie.textTransform&&Ie.textTransform!=="none"){let w=Ie.textTransform;ve=de=>h(de,w)}Ie.marginLeft&&parseFloat(Ie.marginLeft)>0&&y.push(`Inline element <${oe.tagName.toLowerCase()}> has margin-left which is not supported in PowerPoint. Remove margin from inline elements.`),Ie.marginRight&&parseFloat(Ie.marginRight)>0&&y.push(`Inline element <${oe.tagName.toLowerCase()}> has margin-right which is not supported in PowerPoint. Remove margin from inline elements.`),Ie.marginTop&&parseFloat(Ie.marginTop)>0&&y.push(`Inline element <${oe.tagName.toLowerCase()}> has margin-top which is not supported in PowerPoint. Remove margin from inline elements.`),Ie.marginBottom&&parseFloat(Ie.marginBottom)>0&&y.push(`Inline element <${oe.tagName.toLowerCase()}> has margin-bottom which is not supported in PowerPoint. Remove margin from inline elements.`),b(oe,be,Y,ve)}}ye=Me}),Y.length>0&&(Y[0].text=Y[0].text.replace(/^\s+/,""),Y[Y.length-1].text=Y[Y.length-1].text.replace(/\s+$/,"")),Y.filter(oe=>oe.text.length>0)},x=j=>!j||j==="transparent"||j==="rgba(0, 0, 0, 0)",S=j=>{let $=[j,t.documentElement,j?.querySelector?.(":scope > section, :scope > div, :scope > main")].filter(Boolean);for(let Y of $){let Se=r.getComputedStyle(Y),ye=Se.backgroundImage||"";if(ye.includes("linear-gradient")||ye.includes("radial-gradient"))return{gradient:!0};if(ye&&ye!=="none"){let ve=ye.match(/url\(["']?([^"')]+)["']?\)/);if(ve)return{type:"image",path:ve[1]}}let oe=Se.backgroundColor;if(!x(oe))return{type:"color",value:s(oe)}}return{type:"color",value:"FFFFFF"}},F=t.body,N=F.getBoundingClientRect(),L=j=>({left:j.left-N.left,top:j.top-N.top,width:j.width,height:j.height}),D=j=>L(j.getBoundingClientRect()),T=(j,$)=>{let Y=u(j.color);return!Y||Y.a>=.2||!$.textContent.trim()?s(j.color):"E8E8E8"},G=(j,$,Y)=>{let{x:Se,y:ye,w:oe,h:ve}=v(j,$,Y),Me=N.width,be=N.height,Ie=Math.max(8,Me-Se-4),Ee=j.scrollHeight||0,w=/^H[1-6]$/.test(j.tagName),de=w?Math.min(Math.max(8,oe*.05),32):Math.min(Math.max(2,oe*.02),12);w?oe=Math.max(oe+de,Me*.92-Se):oe=Math.min(oe+de,Ie),oe=Math.min(oe,Ie);let te=Math.max(6,ve*(w?.18:.12)),U=Math.max(8,be-ye-4);return Ee>ve+2?ve=Math.min(Ee+te,U):ve=Math.min(ve+te,U),{x:Se,y:ye,w:oe,h:ve}},V=j=>{let $=r.getComputedStyle(j).zIndex;if(!$||$==="auto")return 0;let Y=parseInt($,10);return Number.isFinite(Y)?Y:0},C=(j,$)=>{$&&(j.zIndex=V($)),ce.push(j)},q=(j,$,Y)=>{let ye=r.getComputedStyle(j).listStyleColor;if(ye&&ye!=="rgba(0, 0, 0, 0)"){let oe=s(ye);if(oe&&oe!==Y)return oe}for(let oe of $)try{let ve=r.getComputedStyle(oe,"::marker");if(ve?.color){let Me=s(ve.color);if(Me&&Me!==Y)return Me}}catch{}return null},y=[],M=S(F);M.gradient&&y.push("CSS gradients are not supported. Use Sharp to rasterize gradients as PNG images first, then reference with background-image: url('gradient.png')");let ne=M.gradient?{type:"color",value:"FFFFFF"}:{type:M.type,...M.path?{path:M.path}:{value:M.value}},_=ne.value||"0E0E12",ce=[],ae=[],Te=["P","H1","H2","H3","H4","H5","H6","UL","OL","LI"],Q=new Set;t.querySelectorAll("*").forEach(j=>{if(Q.has(j))return;if(j.tagName==="DIV"&&j.dataset&&j.dataset.pptxMerge==="true"){let P=D(j);if(P.width===0||P.height===0){Q.add(j);return}if(j.querySelector('[data-pptx-merge="true"]')){y.push("data-pptx-merge container cannot contain another data-pptx-merge container. Nested merge is not supported."),Q.add(j);return}let W=r.getComputedStyle(j);if(W.backgroundImage&&W.backgroundImage!=="none"){y.push("Background images on data-pptx-merge container are not supported. Use solid colors or borders, or layer images via slide.addImage().");return}let le=W.backgroundColor&&W.backgroundColor!=="rgba(0, 0, 0, 0)",he=[W.borderTopWidth,W.borderRightWidth,W.borderBottomWidth,W.borderLeftWidth].map(Re=>parseFloat(Re)||0),pe=he.some(Re=>Re>0)&&he.every(Re=>Re===he[0]);(le||pe)&&ce.push({type:"shape",text:"",position:{x:l(P.left),y:l(P.top),w:l(P.width),h:l(P.height)},shape:{fill:le?s(W.backgroundColor):null,transparency:le?d(W.backgroundColor):null,line:pe?{color:s(W.borderColor),width:c(W.borderWidth)}:null,rectRadius:(()=>{let Re=W.borderRadius,ot=parseFloat(Re);if(ot===0)return 0;if(Re.includes("%")){if(ot>=50)return 1;let pt=Math.min(P.width,P.height);return ot/100*l(pt)}return Re.includes("pt")?ot/72:ot/i})(),shadow:g(W.boxShadow)}});let Ce=Array.from(j.querySelectorAll("p, h1, h2, h3, h4, h5, h6"));if(Ce.length===0){y.push("data-pptx-merge container has no

          / children to merge. Remove the data-pptx-merge attribute or add text elements."),Q.add(j);return}let fe=r.getComputedStyle(Ce[0]),De={fontSize:c(fe.fontSize),fontFace:fe.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),color:s(fe.color),align:fe.textAlign==="start"?"left":fe.textAlign,lineSpacing:fe.lineHeight&&fe.lineHeight!=="normal"?c(fe.lineHeight):null,paraSpaceBefore:0,paraSpaceAfter:0,margin:[c(W.paddingLeft),c(W.paddingRight),c(W.paddingBottom),c(W.paddingTop)]},qe=d(fe.color);qe!==null&&(De.transparency=qe);let ze=[];if(Ce.forEach((Re,ot)=>{let pt=ot===Ce.length-1,R=r.getComputedStyle(Re),se=R.textTransform,Ae=c(R.fontSize),Pe=R.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),H=s(R.color),ue=R.fontWeight==="bold"||parseInt(R.fontWeight)>=600,k=R.fontStyle==="italic",ge=R.textDecoration.includes("underline"),Oe={};Ae!==De.fontSize&&(Oe.fontSize=Ae),Pe!==De.fontFace&&(Oe.fontFace=Pe),H!==De.color&&(Oe.color=H),ue&&!o(R.fontFamily)&&(Oe.bold=!0),k&&(Oe.italic=!0),ge&&(Oe.underline=!0);let m=Re.querySelector("b, i, u, strong, em, span, br"),ee;if(m)ee=b(Re,Oe,[],ie=>h(ie,se));else{let ie=h(Re.textContent.trim(),se);if(!ie)return;ee=[{text:ie,options:{...Oe}}]}ee.length>0&&!pt&&(ee[ee.length-1].options.breakLine=!0),ze.push(...ee),Q.add(Re)}),ze.length===0){Q.add(j);return}ce.push({type:"merged-text",items:ze,position:{x:l(P.left),y:l(P.top),w:l(P.width),h:l(P.height)},style:De}),Q.add(j);return}if(Te.includes(j.tagName)){let P=r.getComputedStyle(j),W=P.backgroundColor&&P.backgroundColor!=="rgba(0, 0, 0, 0)",le=P.borderWidth&&parseFloat(P.borderWidth)>0||P.borderTopWidth&&parseFloat(P.borderTopWidth)>0||P.borderRightWidth&&parseFloat(P.borderRightWidth)>0||P.borderBottomWidth&&parseFloat(P.borderBottomWidth)>0||P.borderLeftWidth&&parseFloat(P.borderLeftWidth)>0,he=P.boxShadow&&P.boxShadow!=="none";if(W||le||he){let K=D(j);if(K.width>0&&K.height>0){let pe=[P.borderTopWidth,P.borderRightWidth,P.borderBottomWidth,P.borderLeftWidth].map(De=>parseFloat(De)||0),Ce=pe.some(De=>De>0)&&pe.every(De=>De===pe[0]),fe=W?f(P.backgroundColor,_):{fill:null,transparency:null};if(fe.fill||Ce){let De=P.borderRadius,qe=parseFloat(De);C({type:"shape",text:"",position:{x:l(K.left),y:l(K.top),w:l(K.width),h:l(K.height)},shape:{fill:fe.fill,transparency:fe.transparency,line:Ce?{color:s(P.borderColor),width:c(P.borderWidth)}:null,rectRadius:(()=>{if(!qe)return 0;if(De.includes("%")){if(qe>=50)return 1;let ze=Math.min(K.width,K.height);return qe/100*l(ze)}return De.includes("pt")?qe/72:qe/i})(),shadow:g(P.boxShadow)}},j)}}}}if(j.className&&j.className.includes("placeholder")){let P=D(j);P.width===0||P.height===0?y.push(`Placeholder "${j.id||"unnamed"}" has ${P.width===0?"width: 0":"height: 0"}. Check the layout CSS.`):ae.push({id:j.id||`placeholder-${ae.length}`,x:l(P.left),y:l(P.top),w:l(P.width),h:l(P.height)}),Q.add(j);return}if(j.tagName==="IMG"){let P=D(j);if(P.width>0&&P.height>0){ce.push({type:"image",src:j.src,position:{x:l(P.left),y:l(P.top),w:l(P.width),h:l(P.height)}}),Q.add(j);return}}if(new Set(["DIV","SECTION","ARTICLE","ASIDE"]).has(j.tagName)){let P=r.getComputedStyle(j),W=P.backgroundColor&&P.backgroundColor!=="rgba(0, 0, 0, 0)";for(let Re of j.childNodes)if(Re.nodeType===Node.TEXT_NODE){let ot=Re.textContent.trim();ot&&y.push(`DIV element contains unwrapped text "${ot.substring(0,50)}${ot.length>50?"...":""}". All text must be wrapped in

          ,

          -

          ,
            , or
              tags to appear in PowerPoint.`)}let le=P.backgroundImage;if(le&&le!=="none"){y.push("Background images on DIV elements are not supported. Use solid colors or borders for shapes, or use slide.addImage() in PptxGenJS to layer images.");return}let he=P.borderTopWidth,K=P.borderRightWidth,pe=P.borderBottomWidth,Ce=P.borderLeftWidth,fe=[he,K,pe,Ce].map(Re=>parseFloat(Re)||0),De=fe.some(Re=>Re>0),qe=De&&fe.every(Re=>Re===fe[0]),ze=[];if(De&&!qe){let Re=D(j),ot=l(Re.left),pt=l(Re.top),R=l(Re.width),se=l(Re.height);if(parseFloat(he)>0){let Ae=c(he),Pe=Ae/72/2;ze.push({type:"line",x1:ot,y1:pt+Pe,x2:ot+R,y2:pt+Pe,width:Ae,color:s(P.borderTopColor)})}if(parseFloat(K)>0){let Ae=c(K),Pe=Ae/72/2;ze.push({type:"line",x1:ot+R-Pe,y1:pt,x2:ot+R-Pe,y2:pt+se,width:Ae,color:s(P.borderRightColor)})}if(parseFloat(pe)>0){let Ae=c(pe),Pe=Ae/72/2;ze.push({type:"line",x1:ot,y1:pt+se-Pe,x2:ot+R,y2:pt+se-Pe,width:Ae,color:s(P.borderBottomColor)})}if(parseFloat(Ce)>0){let Ae=c(Ce),Pe=Ae/72/2;ze.push({type:"line",x1:ot+Pe,y1:pt,x2:ot+Pe,y2:pt+se,width:Ae,color:s(P.borderLeftColor)})}}if(W||De){let Re=D(j);if(Re.width>=N.width*.97&&Re.height>=N.height*.97&&W){Q.add(j);return}if(Re.width>0&&Re.height>0){let pt=g(P.boxShadow);if(W||qe){let R=W?f(P.backgroundColor,_):{fill:null,transparency:null},se=R.fill,Ae=R.transparency;!se&&qe&&(se=s(P.borderColor)||"2A2A30",Ae=Ae??88),C({type:"shape",text:"",position:{x:l(Re.left),y:l(Re.top),w:l(Re.width),h:l(Re.height)},shape:{fill:se,transparency:Ae,line:qe?{color:s(P.borderColor),width:c(P.borderWidth)}:null,rectRadius:(()=>{let Pe=P.borderRadius,H=parseFloat(Pe);if(H===0)return 0;if(Pe.includes("%")){if(H>=50)return 1;let ue=Math.min(Re.width,Re.height);return H/100*l(ue)}return Pe.includes("pt")?H/72:H/i})(),shadow:pt}},j)}ze.forEach(R=>C(R,j)),Q.add(j);return}}}if(j.tagName==="UL"||j.tagName==="OL"){let P=D(j);if(P.width===0||P.height===0)return;let W=Array.from(j.querySelectorAll("li")),le=[],he=r.getComputedStyle(j),K=c(he.paddingLeft),pe=K*.5,Ce=K*.5,fe=r.getComputedStyle(W[0]||j),De=s(fe.color),qe=q(j,W,De);W.forEach((Re,ot)=>{let pt=ot===W.length-1,R=b(Re,{breakLine:!1});R.length>0&&(R[0].text=R[0].text.replace(/^[•\-\*▪▸]\s*/,""),R[0].options.bullet={indent:Ce}),R.length>0&&qe&&qe!==De&&R.unshift({text:"\u200B",options:{bullet:{indent:Ce},color:qe,fontSize:R[0]?.options?.fontSize||c(fe.fontSize),breakLine:!1}}),R.length>0&&!pt&&(R[R.length-1].options.breakLine=!0),le.push(...R)});let ze=G(j,P,null);C({type:"list",items:le,position:{x:l(ze.x),y:l(ze.y),w:l(ze.w),h:l(ze.h)},style:{fontSize:c(fe.fontSize),fontFace:fe.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),color:De,bulletColor:qe,transparency:d(fe.color),align:fe.textAlign==="start"?"left":fe.textAlign,lineSpacing:fe.lineHeight&&fe.lineHeight!=="normal"?c(fe.lineHeight):null,paraSpaceBefore:0,paraSpaceAfter:c(fe.marginBottom),margin:[pe,0,0,0]}},j),W.forEach(Re=>Q.add(Re)),Q.add(j);return}if(!Te.includes(j.tagName))return;let Se=D(j),ye=j.textContent.trim();if(Se.width===0||Se.height===0||!ye)return;if(j.tagName!=="LI"&&/^[•\-\*▪▸○●◆◇■□]\s/.test(ye.trimStart())){y.push(`Text element <${j.tagName.toLowerCase()}> starts with bullet symbol "${ye.substring(0,20)}...". Use
                or
                  lists instead of manual bullet symbols.`);return}let oe=r.getComputedStyle(j),ve=A(oe.transform,oe.writingMode),{x:Me,y:be,w:Ie,h:Ee}=G(j,Se,ve),w=oe.fontWeight==="bold"||parseInt(oe.fontWeight,10)>=600,de={fontSize:c(oe.fontSize),fontFace:oe.fontFamily.split(",")[0].replace(/['"]/g,"").trim(),color:T(oe,j),align:oe.textAlign==="start"?"left":oe.textAlign,lineSpacing:c(oe.lineHeight),paraSpaceBefore:c(oe.marginTop),paraSpaceAfter:c(oe.marginBottom),margin:[c(oe.paddingLeft),c(oe.paddingRight),c(oe.paddingBottom),c(oe.paddingTop)]},te=d(oe.color);if(te!==null&&(de.transparency=te),ve!==null&&(de.rotate=ve),j.querySelector("b, i, u, strong, em, span, br")){let P=oe.textTransform,W={};w&&!o(oe.fontFamily)&&(W.bold=!0);let le=b(j,W,[],pe=>h(pe,P));!le.map(pe=>pe.text).join("").trim()&&ye&&(le=[{text:h(ye,P),options:{...W}}]);let K={...de};if(K.lineSpacing){let pe=Math.max(K.fontSize,...le.map(Ce=>Ce.options?.fontSize||0));if(pe>K.fontSize){let Ce=K.lineSpacing/K.fontSize;K.lineSpacing=pe*Ce}}C({type:j.tagName.toLowerCase(),text:le,position:{x:l(Me),y:l(be),w:l(Ie),h:l(Ee)},style:K},j)}else{let P=oe.textTransform,W=h(ye,P);C({type:j.tagName.toLowerCase(),text:W,position:{x:l(Me),y:l(be),w:l(Ie),h:l(Ee)},style:{...de,bold:w&&!o(oe.fontFamily),italic:oe.fontStyle==="italic",underline:oe.textDecoration.includes("underline")}},j)}Q.add(j)});let Z=j=>j==="shape"?0:j==="line"?1:j==="image"?2:3;return ce.sort((j,$)=>{let Y=(j.zIndex??0)-($.zIndex??0);return Y!==0?Y:Z(j.type)-Z($.type)}),{background:ne,elements:ce,placeholders:ae,errors:y}}var tr={width:1280,height:720},gp={p:["p"],h1:["h1"],h2:["h2"],h3:["h3"],h4:["h4"],h5:["h5"],h6:["h6"],list:["li"],"merged-text":["span","em","strong","b","i","p","h1","h2","h3","h4","h5","h6"]};function dd(e){return(e?.elements||[]).filter(t=>ud.has(t.type)).length}function mp(e){let t=new Set;for(let n of e?.elements||[])if(ud.has(n.type))for(let i of gp[n.type]||[n.type])t.add(i);return t.size?[...t].map(n=>`body[data-pptx-raster="1"] ${n} { color: transparent !important; -webkit-text-fill-color: transparent !important; text-shadow: none !important; }`).join(` -`):""}function qh(e,t=null){let r=Wr(e);if(!t||jc(t)===0)return r;let n=Gh(t);if(!n||r.includes('data-pptx-raster="1"')&&r.includes("pptx-raster-hide-text"))return r;let i=``;return/<\/head>/i.test(r)?r.replace(/<\/head>/i,`${i}`).replace(/e.querySelectorAll(r),createElement:r=>document.createElement(r),getElementById:r=>e.querySelector(`#${r}`),head:e.querySelector("style")?.parentElement||e,_exportRoot:e}}function Kh(){let e=document.createElement("div");e.className="ppt-export-root-host",e.setAttribute("aria-hidden","true"),e.style.cssText=[`width:${sr.width}px`,`height:${sr.height}px`,"overflow:hidden"].join(";"),jh().appendChild(e);let t=e.attachShadow({mode:"open"}),r=document.createElement("div");return r.className="ppt-export-root",r.style.cssText=[`width:${sr.width}px`,`height:${sr.height}px`,"overflow:hidden"].join(";"),t.appendChild(r),r._exportHost=e,r}function _h(e){let t=e?._exportHost||e;t?.isConnected&&t.remove()}async function Xc(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(e))})}function Qh(e,t){let r=new DOMParser().parseFromString(t,"text/html");e.replaceChildren(),r.querySelectorAll("style").forEach(i=>{let a=document.createElement("style");a.textContent=Xh(i.textContent||""),e.appendChild(a)});let n=document.createElement("div");if(n.className="ppt-export-body",r.body){for(let i of r.body.attributes)i.name==="class"?n.classList.add(...i.value.split(/\s+/).filter(Boolean)):i.name==="style"?n.style.cssText+=`;${i.value}`:n.setAttribute(i.name,i.value);n.innerHTML=r.body.innerHTML}return n.style.boxSizing="border-box",/\bwidth\s*:/i.test(n.style.cssText)||(n.style.width=`${sr.width}px`),/\bheight\s*:/i.test(n.style.cssText)||(n.style.height=`${sr.height}px`),e.appendChild(n),n}async function Zh(e){let t=Wr(e),r=Kh(),n=Qh(r,t);return await Xc(),Hh(r,n)}async function qc(e,t,r={}){let n=null;try{let i=await Zh(e);n=i._exportRoot,Uc(i,t),await Xc();let a=Wc(i),o=Gc(i),l=a.errors||[];l.length&&console.warn("[ppt-live-export] slide overflows canvas; exporting anyway:",l.join("; "));let c={...a,errors:[]},s=o.errors||[];return!s.length||r.allowValidationErrors?{slideData:o,bodyDimensions:c,aggressive:t,warnings:l}:{error:new Error(s.join(` -`))}}finally{n&&_h(n)}}async function Yh(e,t={}){let r=await qc(e,!1,t);if(r?.slideData)return r;let n=await qc(e,!0,t);if(n?.slideData)return n;throw n?.error||r?.error||new Error("PPT Live slide preparation failed")}async function Hc(e,t={}){let r=[];try{for(let[n,i]of e.entries()){if(!i?.html)continue;let a=await Yh(i.html,t),o=null,c=jc(a.slideData)===0;if(typeof t.renderRaster=="function")try{typeof t.onRasterProgress=="function"&&t.onRasterProgress(n,i);let s=c?vs(i):qh(i.html,a.slideData);o=await t.renderRaster(s,n)}catch{o=null}r.push({index:n,slideId:i.id,notes:i,...a,rasterBase64:o,rasterOnly:!!(o&&c)})}return r}finally{Vh()}}function Jh(e={}){let t=e.theme||{},r=String(e.title||"Slide").replace(/[<>&]/g,l=>({"<":"<",">":">","&":"&"})[l]||l),n=String(e.subtitle||e.claim||"").replace(/[<>&]/g,l=>({"<":"<",">":">","&":"&"})[l]||l),i=t.background||"#ffffff",a=t.ink||"#111111",o=t.muted||"#666666";return` +`):""}function vp(e,t=null){let r=Ur(e);if(!t||dd(t)===0)return r;let n=mp(t);if(!n||r.includes('data-pptx-raster="1"')&&r.includes("pptx-raster-hide-text"))return r;let i=``;return/<\/head>/i.test(r)?r.replace(/<\/head>/i,`${i}`).replace(/e.querySelectorAll(r),createElement:r=>document.createElement(r),getElementById:r=>e.querySelector(`#${r}`),head:e.querySelector("style")?.parentElement||e,_exportRoot:e}}function Sp(){let e=document.createElement("div");e.className="ppt-export-root-host",e.setAttribute("aria-hidden","true"),e.style.cssText=[`width:${tr.width}px`,`height:${tr.height}px`,"overflow:hidden"].join(";"),yp().appendChild(e);let t=e.attachShadow({mode:"open"}),r=document.createElement("div");return r.className="ppt-export-root",r.style.cssText=[`width:${tr.width}px`,`height:${tr.height}px`,"overflow:hidden"].join(";"),t.appendChild(r),r._exportHost=e,r}function fd(e){let t=e?._exportHost||e;t?.isConnected&&t.remove()}async function hd(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(e))})}function Cp(e,t){let r=new DOMParser().parseFromString(t,"text/html");e.replaceChildren(),r.querySelectorAll("style").forEach(i=>{let a=document.createElement("style");a.textContent=wp(i.textContent||""),e.appendChild(a)});let n=document.createElement("div");if(n.className="ppt-export-body",r.body){for(let i of r.body.attributes)i.name==="class"?n.classList.add(...i.value.split(/\s+/).filter(Boolean)):i.name==="style"?n.style.cssText+=`;${i.value}`:n.setAttribute(i.name,i.value);n.innerHTML=r.body.innerHTML}return n.style.boxSizing="border-box",/\bwidth\s*:/i.test(n.style.cssText)||(n.style.width=`${tr.width}px`),/\bheight\s*:/i.test(n.style.cssText)||(n.style.height=`${tr.height}px`),e.appendChild(n),n}async function pd(e){let t=Ur(e),r=Sp(),n=Cp(r,t);return await hd(),xp(r,n)}function sd(e){return["Top","Right","Bottom","Left"].some(t=>parseFloat(e[`border${t}Width`]||0)>0)}function ld(e){return!e||e==="transparent"||e==="rgba(0, 0, 0, 0)"}function kp(e){let t=e.id?`#${e.id}`:"",r=typeof e.className=="string"?e.className.trim().split(/\s+/).filter(Boolean).slice(0,2).map(n=>`.${n}`).join(""):"";return`${e.tagName.toLowerCase()}${t}${r}`}async function Ad(e){let t=String(e||"").trim(),r=[],n=new Set,i=(o,l,c=null)=>{let s=c?` (${kp(c)})`:"",d=`${o}:${l}${s}`;n.has(d)||(n.add(d),r.push({code:o,message:`${l}${s}`}))};(!t||!/<\/html>\s*$/i.test(t))&&i("incomplete_html","The slide must be a complete HTML document ending with ."),/i("canvas_overflow",h));let u=tr.width,p=tr.height;(Math.abs(s.width-u)>2||Math.abs(s.height-p)>2)&&i("canvas_size",`Computed canvas must be 960pt x 540pt (${u}px x ${p}px); got ${s.width.toFixed(1)}px x ${s.height.toFixed(1)}px.`),c.querySelectorAll("div").forEach(h=>{[...h.childNodes].forEach(v=>{v.nodeType===Node.TEXT_NODE&&v.textContent.replace(/\s+/g," ").trim()&&i("direct_div_text","Visible DIV text must be wrapped in p, h1-h6, or li.",h)});let A=l.getComputedStyle(h);A.backgroundImage&&A.backgroundImage!=="none"&&i("div_background_image","DIV background-image is unsupported; use an img element.",h)}),c.querySelectorAll("p,h1,h2,h3,h4,h5,h6,li").forEach(h=>{let A=l.getComputedStyle(h);(!ld(A.backgroundColor)||A.backgroundImage&&A.backgroundImage!=="none"||sd(A)||A.boxShadow&&A.boxShadow!=="none")&&i("decorated_text_element","Background, border, image, and shadow styling must be on an enclosing DIV shape.",h);let v=h.getBoundingClientRect();v.width<=0||v.height<=0||((v.lefts.right+1||v.bottom>s.bottom+1)&&i("text_out_of_bounds","A text element extends outside the slide canvas.",h),parseFloat(A.fontSize||0)>12&&v.bottom>s.bottom-48&&i("bottom_safety_margin","Text larger than 12px must keep a 36pt bottom safety margin.",h))}),c.querySelectorAll("span,em,strong,b,i,u,a,small,mark,sub,sup,code").forEach(h=>{let A=l.getComputedStyle(h);(["marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft"].some(g=>parseFloat(A[g]||0)>0)||!ld(A.backgroundColor)||A.backgroundImage&&A.backgroundImage!=="none"||sd(A)||A.boxShadow&&A.boxShadow!=="none")&&i("unsafe_inline_style","Inline text elements cannot carry box spacing, fills, borders, or shadows.",h)}),c.querySelectorAll("*").forEach(h=>{let A=l.getComputedStyle(h);String(A.backgroundImage||"").includes("gradient")&&i("computed_gradient","Computed CSS contains an unsupported gradient.",h);for(let v of["::before","::after"])try{let g=l.getComputedStyle(h,v)?.content;g&&g!=="none"&&g!=="normal"&&g!=='""'&&i("generated_content",`${v} generated text/content is unsupported for editable PPTX.`,h)}catch{}});try{(Ms(o).errors||[]).forEach(A=>i("pptx_conversion",A))}catch(h){i("pptx_conversion",String(h?.message||h||"PPTX conversion validation failed."))}}finally{a&&fd(a)}return{valid:r.length===0,issues:r.slice(0,32)}}async function cd(e,t,r={}){let n=null;try{let i=await pd(e);n=i._exportRoot,od(i,t),await hd();let a=Is(i),o=Ms(i),l=a.errors||[];l.length&&console.warn("[ppt-live-export] slide overflows canvas; exporting anyway:",l.join("; "));let c={...a,errors:[]},s=o.errors||[];return!s.length||r.allowValidationErrors?{slideData:o,bodyDimensions:c,aggressive:t,warnings:l}:{error:new Error(s.join(` +`))}}finally{n&&fd(n)}}async function Pp(e,t={}){let r=await cd(e,!1,t);if(r?.slideData)return r;let n=await cd(e,!0,t);if(n?.slideData)return n;throw n?.error||r?.error||new Error("PPT Live slide preparation failed")}async function gd(e,t={}){let r=[];try{for(let[n,i]of e.entries()){if(!i?.html)continue;let a=await Pp(i.html,t),o=null,c=dd(a.slideData)===0;if(typeof t.renderRaster=="function")try{typeof t.onRasterProgress=="function"&&t.onRasterProgress(n,i);let s=c?zs(i):vp(i.html,a.slideData);o=await t.renderRaster(s,n)}catch{o=null}r.push({index:n,slideId:i.id,notes:i,...a,rasterBase64:o,rasterOnly:!!(o&&c)})}return r}finally{bp()}}function Fp(e={}){let t=e.theme||{},r=String(e.title||"Slide").replace(/[<>&]/g,l=>({"<":"<",">":">","&":"&"})[l]||l),n=String(e.subtitle||e.claim||"").replace(/[<>&]/g,l=>({"<":"<",">":">","&":"&"})[l]||l),i=t.background||"#ffffff",a=t.ink||"#111111",o=t.muted||"#666666";return`
                  ${t}
                  -`}function ly(e){let t=(e.slides||[]).map((r,n)=>`
                  - +`}function zy(e){let t=(e.slides||[]).map((r,n)=>`
                  +
                  `).join(` `);return` - + -${Le(e.title||"PPT Live")} +${Be(e.title||"PPT Live")} ..." - }`;function Ml(e){try{return JSON.stringify(e??{},null,2)}catch{return"{}"}}function pf(e){return Array.isArray(e?.currentDeck?.slides)&&e.currentDeck.slides.length>0}function gy(e){let t=e?.operation||"auto";return pf(e)?` + }`;function Dn(e){try{return JSON.stringify(e??{},null,2)}catch{return"{}"}}function Gy(e){return Array.isArray(e?.currentDeck?.slides)&&e.currentDeck.slides.length>0}function qy(e){let t=e?.operation||"auto";return Gy(e)?` ## Current operation @@ -408,7 +404,7 @@ Patch rules: - Operation: ${t} - No current deck was provided. This is a first-pass deck generation run. Return a complete \`slides\` array. -`}function zl(e){let t=e?.style||{},r=t.fontFamily||"sans",n=t.density||"standard",i=n==="loose"?"spacious":n,a=t.colorMode||"light",o=t.stylePreset||"",l=t.palette,c=r==="serif"?'serif \u2014 use serif typography in every slide HTML (for example Georgia, "Songti SC", "Times New Roman", Cambria). Avoid sans-serif body copy.':'sans-serif \u2014 use clean sans-serif typography in every slide HTML (for example system-ui, "PingFang SC", "Microsoft YaHei", Arial, Helvetica). Avoid serif body copy.',s;i==="compact"?s="compact \u2014 information-forward: body padding 24-32px, line-height 1.2-1.28, and 4-6 concise bullets, metrics, or a two-column grid when the content supports it. Prefer readable tightness over decorative whitespace; never overflow the slide.":i==="spacious"?s="spacious \u2014 the loosest tier, still content-rich: body padding 44-52px, line-height 1.32-1.4, and 2-4 concise bullets or 2-3 short content blocks per slide. Keep clear hierarchy without leaving large empty regions.":s="standard \u2014 balanced professional density: body padding 34-42px, line-height 1.26-1.34, and 3-5 bullets, metrics, or paired columns when useful. Use whitespace to separate sections, not to leave half the slide blank.";let u=` +`}function ti(e){let t=e?.style||{},r=t.fontFamily||"sans",n=t.density||"standard",i=n==="loose"?"spacious":n,a=t.colorMode||t.theme||"light",o=t.stylePreset||"",l=t.palette,c=r==="serif"?'serif \u2014 use serif typography in every slide HTML (for example Georgia, "Songti SC", "Times New Roman", Cambria). Avoid sans-serif body copy.':'sans-serif \u2014 use clean sans-serif typography in every slide HTML (for example system-ui, "PingFang SC", "Microsoft YaHei", Arial, Helvetica). Avoid serif body copy.',s;i==="compact"?s="compact \u2014 information-forward: body padding 24-32px, line-height 1.2-1.28, and 4-6 concise bullets, metrics, or a two-column grid when the content supports it. Prefer readable tightness over decorative whitespace; never overflow the slide.":i==="spacious"?s="spacious \u2014 the loosest tier, still content-rich: body padding 44-52px, line-height 1.32-1.4, and 2-4 concise bullets or 2-3 short content blocks per slide. Keep clear hierarchy without leaving large empty regions.":s="standard \u2014 balanced professional density: body padding 34-42px, line-height 1.26-1.34, and 3-5 bullets, metrics, or paired columns when useful. Use whitespace to separate sections, not to leave half the slide blank.";let u=` ## Presentation style preferences (must follow in slides[].html) @@ -426,18 +422,90 @@ Patch rules: `,l)try{u+=`- Style palette (matches the preset; use these exact colors for backgrounds, text, accents, and panels in every slide HTML): ${JSON.stringify(l)} `}catch{}u+=`- The preset does not suspend the ppt-design core rules: assertion-led titles, one core message per slide, anti-AI-slop rules, the 960pt x 540pt canvas, editable-PPTX constraints, and zero content overflow all still apply. - Pick the closest of the skill's five design philosophies as the structural grammar for layout, then skin it with the preset. If the preset file cannot be read, keep the palette above and fall back to that philosophy. -`}return u}function my(e){return`Plan a PPT Live deck. This is the PLANNING phase of a staged pipeline: research the topic, lock the narrative, and write a per-slide brief. Slide HTML is produced later by separate render runs that follow your plan exactly, so the plan must be complete and self-sufficient. +`}return u}var jy=`Your previous response in this session was interrupted before it finished. Continue the task now. If your deliverable is a project file, first inspect what you already wrote (Read it) and rewrite that file completely if it could be incomplete. If your deliverable is a final JSON message, re-emit the complete JSON from scratch \u2014 do not assume any part of the interrupted output was received. -1. Call \`Skill('ppt-design')\` \u2014 the BitFun built-in PPT design skill \u2014 and follow its narrative, density, and design-system rules when planning. Never substitute any other presentation or PPT skill. -2. Use any BitFun tools you need (WebFetch, WebSearch, Read, etc.) when the user's prompt requires external facts. All research happens NOW; render runs are forbidden from re-researching. -3. Finish with **only** one strict JSON object \u2014 no Markdown fences, no commentary, no tool calls in the final message. -4. Do NOT generate any slide HTML in this phase. +`;function Vy(e){let t=Array.isArray(e?.issues)?e.issues.map(String).filter(Boolean):[],r=String(e?.previousFailure||"").trim();return`AUTOMATIC COMPLETION CONTINUATION ${e?.attempt||1}/${e?.maxAttempts||1}. -Return JSON matching this shape: +The host has verified that the "${e?.stage||"current"}" stage is still incomplete after its normal retry budget. Continue the unfinished task in this user turn; do not restart completed work and do not merely explain what remains. +- Inspect the durable project files first and reuse every valid artifact already present. +- Perform the missing tool calls or rewrites now. +- Do not claim completion until the required artifact exists and satisfies the host checks. +${r?`- Previous verified failure: ${r} +`:""}${t.length?`- Host verification issues: + - ${t.join(` + - `)} +`:""} +`}function Bf(e){let t=Array.isArray(e?.auditIssues)?e.auditIssues.map(String).filter(Boolean):[];return t.length?`The host rejected the previous audit turn because the audit artifact was not complete: +- ${t.join(` +- `)} + +Resolve every issue above in this turn. In particular, use the Write tool to create or completely rewrite \`quality-report.json\`; do not answer "DECK AUDIT PASSED" unless that file has been successfully written and covers every slide id. + +`:""}function Xy(e){let t=e?.style?.palette||{};return JSON.stringify(t,null,2).split(` +`).map(r=>` ${r}`).join(` +`)}function Hy(e){let t=e?.style?.stylePreset||"",r=e?.style?.colorMode||e?.style?.theme||"light",n=t?`references/style-presets/${t}.md`:"",i=Array.isArray(e?.complianceIssues)&&e.complianceIssues.length?`The host rejected the previous plan because required Skill evidence was missing. Complete these exact missing actions before accepting or rewriting project.json: +- ${e.complianceIssues.join(` +- `)} + +`:"",a=`Plan a PPT Live deck. This is the PLANNING phase of a staged pipeline running in a dedicated deck project directory: the workspace root of this session is the deck's \`{{ppt_project_dir}}\`. Research the topic, lock the narrative, design the visual system, write a per-slide brief, and SAVE the complete plan to \`project.json\` at the workspace root. Later turns run in THIS SAME session, but must be able to recover from context compression using the self-contained generation contract in that file. + +1. Call \`Skill('${ir}')\`. This exact stable key is mandatory. Check the tool result reports \`skill_key="${ir}"\`; if it does not, stop with an error. Never invoke or substitute a different PPT/presentation skill. +2. From the skill directory returned by Skill, \`Read\` all mandatory references: \`${$n.join("`, `")}\`. +${n?`3. \`Read\` the selected style preset \`${n}\` and apply its visual rules when planning.`:"3. No named style preset was supplied; derive one coherent visual system from the user intent and skill."} +4. If the deck is data-heavy, analytical, explanatory, or structurally complex, \`Read\` \`references/data-information-visualization.md\` before drafting slide plans. +5. Use any BitFun research tools needed by the user's prompt. All external research happens NOW; render runs must not re-research. +6. When the plan is final, \`Write\` it to \`project.json\` as one strict JSON object matching the schema below. Do not generate slide HTML in this phase. +7. For a deck with at least 5 pages, choose two visually different \`showcaseSlideNumbers\` that later render first and establish the grammar for the remaining pages. +8. End with one short status line such as "PLAN READY: N slides". Do not paste the JSON into the reply. + +\`project.json\` schema: { "title": "deck title", "language": "zh-CN or en-US", - "outline": ["slide title"], + "outline": [ + { "id": "slide-01", "title": "slide title", "bullets": [], "slide_id": "slide-01" } + ], + "slide_order": ["slide-01"], + "style": { + "stylePreset": "${t}", + "fontFamily": "exact input value", + "density": "exact input value", + "colorMode": "exact input value", + "palette": {} + }, + "assumptions": ["one-shot assumptions"], + "generationContract": { + "version": 1, + "skillKey": "${ir}", + "skillName": "ppt-design", + "requiredReferences": [ + ${$n.map(o=>`"${o}"`).join(`, + `)}${n?`, + "${n}"`:""} + ], + "deliveryTarget": "editable-pptx", + "userPrompt": "copy input.instruction exactly", + "userBrief": {}, + "userStyle": {}, + "hardRules": ["compact exact rules distilled from editable-pptx.md"], + "visualGrammar": { + "designRead": "one-line audience, task, visual language, structural grammar", + "visualThesis": "why this brief should look this way; not generic adjectives", + "signatureMove": "one theme-specific device used sparingly across the deck", + "typography": "hierarchy via weight, size, spacing \u2014 not decoration", + "paletteRoles": "semantic role of every supplied color", + "composition": "grid, margins, edge discipline, and dominant visual masses", + "layoutFamilies": ["deck-specific families with different silhouettes"], + "objectStyles": "tables, charts, diagrams, images, quotes, annotations, and sources", + "surfaces": "lines and whitespace first; cards and shadow only when hierarchy requires", + "dataAndDiagrams": "semantics over template shapes", + "densityCurve": "where the deck opens, builds, peaks, releases, and closes", + "copyRegister": "language tone, sentence style, label discipline, and evidence standard", + "antiDefaults": ["brief-specific defaults that would make this deck generic"], + "pageRhythm": "showcase grammar, adjacent-page contrast, and accent discipline" + } + }, + "showcaseSlideNumbers": [1, 3], "researchReport": { "summary": "short internal summary safe to show as a product status detail", "verifiedFacts": ["fact with source note when available"], @@ -446,14 +514,9 @@ Return JSON matching this shape: }, "design": { "stylePhilosophy": "pentagram|muller-brockmann|build|kenya-hara|takram", - "theme": "light|dark", + "theme": "${r==="dark"?"dark":"light"}", "palette": { - "background": "#FAFAF7", - "ink": "#1A1A1A", - "muted": "#666666", - "primary": "#111111", - "accent": "#C84B31", - "panel": "#FFFFFF" +${Xy(e)} }, "layoutPrinciples": ["specific visual rules every slide of this deck must share"] }, @@ -482,51 +545,129 @@ Return JSON matching this shape: Plan rules: - \`slidePlans\` must cover the full deck in final order; \`slideNumber\` is one-based and contiguous. +- \`outline[].slide_id\`, \`slide_order[]\`, and \`slides/slide-XX.html\` numbering must agree. +- Copy the user's original instruction, brief, and all style settings into \`generationContract\`; do not paraphrase away explicit requirements. - Every \`contentBrief\` must be concrete enough that a render run with no research access can produce an audience-ready slide from it. Put real numbers, names, and source notes into the briefs, not vague directions. -- \`design.layoutPrinciples\` and \`design.palette\` are the consistency contract across parallel render runs \u2014 make them specific. +- \`design.layoutPrinciples\` and \`design.palette\` are the consistency contract across render runs \u2014 make them specific. +- Distill the skill, mandatory references, selected preset, and user style into \`generationContract.hardRules\` and \`generationContract.visualGrammar\` so later turns can recover after context compression. +- The editable PPTX rules below are non-negotiable and must appear compactly in \`generationContract.hardRules\`: +${ei} -Output budget (hard limits \u2014 the plan JSON is streamed over a connection that gets cut after several minutes, so an oversized plan ALWAYS fails and wastes the entire run): +Plan density (quality bar, not a protocol limit): - Write dense, telegraphic notes, never prose paragraphs. Pack facts, numbers, and names; drop filler words. - \`contentBrief\`: at most ~400 characters per slide. - \`facts\`: at most 4 items; \`bullets\`: at most 4 items; each item one short line. - \`proofObject\`, \`supportNote\`, \`sourceNote\`, \`notes\`: one short sentence each. - \`researchReport.summary\`: at most ~600 characters; \`verifiedFacts\`/\`assumptions\`/\`warnings\`: at most 12 short items combined. -- Total plan JSON must stay under ~25,000 characters even for large decks. If the deck is big, make each brief tighter instead of dropping slides. Input JSON: \`\`\`json -${Ml(e)} -\`\`\``+zl(e)}function vy(e){return`Render PPT Live slides. This is the RENDER phase of a staged pipeline. The plan (research, outline, design system, per-slide briefs) is already final and is provided in the input JSON as \`plan\`. Your batch must render ONLY the slides listed in \`assignedSlides\` (slide numbers: ${(e?.assignedSlides||[]).map(n=>n?.slideNumber).filter(n=>n!=null).join(", ")}). +${Dn(e)} +\`\`\``;return i+a+ti(e)}function ec(e){return`slides/slide-${String(e).padStart(2,"0")}.html`}function _y(e){let t=(e?.assignedSlides||[])[0]||{},r=t?.slideNumber??"?",n=ec(t?.slideNumber||0);return`Render PPT Live slide ${r}. This turn runs in the SAME deck Agent Session as planning, but you must rely on the durable project contract rather than assuming old context is still present. -1. Call \`Skill('ppt-design')\` \u2014 the BitFun built-in PPT design skill \u2014 and follow it end-to-end for slide HTML quality. Never substitute any other presentation or PPT skill. -2. Do NOT re-research. Do not call WebSearch or WebFetch. Trust \`plan.researchReport\` and each slide's \`contentBrief\` completely; they contain all verified facts. -3. Do NOT change the plan: keep each assigned slide's \`slideNumber\`, title, claim, layout, and narrative role as planned. Apply \`plan.design\` (philosophy, theme, palette, layoutPrinciples) to every slide so parallel batches stay visually identical. -4. Finish with **only** one strict JSON object \u2014 no Markdown fences, no commentary, no tool calls in the final message. +1. \`Read\` \`project.json\` on every page turn. Verify \`generationContract.skillKey\` is exactly \`${ir}\`, then follow its userPrompt, userBrief, userStyle, hardRules, visualGrammar, design system, and assigned slide plan together. +2. If \`showcaseSlideNumbers\` contains already-rendered pages, \`Read\` those slide files before rendering a non-showcase page and reuse their visual grammar without copying their layout mechanically. +3. Do not re-run research or change the planned title, claim, layout, or narrative role. Apply \`plan.design\` and the assigned slide plan together. +4. \`Write\` exactly one complete document to \`${n}\`. Do not modify any other slide. +5. End with "SLIDE ${r} READY"; do not paste HTML into the reply. -Every slide must include complete \`html\`: self-contained 960pt \xD7 540pt HTML with inline CSS (ppt-design editable PPTX rules). Slide copy must be audience-ready, never placeholder instructions. +Hard HTML/PPTX constraints: +- The file must be a complete self-contained 960pt \xD7 540pt document with inline CSS only and no remote assets. +- \`body { overflow: hidden; }\`, flex-column root with \`height: 540pt\`, stretchable areas \`flex:1; min-height:0; overflow:hidden;\`. +- Budget the vertical space before writing; body text >= 10px; keep a >=36pt bottom safety margin; never overflow the canvas. +${ei} +- Slide copy must be audience-ready, never placeholder instructions. +${ti(e)} -Return JSON matching this shape: -{ - "slides": [ - ${hf} - ] -} +Current page contract: +\`\`\`json +${Dn({generationContract:e?.generationContract||{},design:e?.design||{},style:e?.style||{},showcaseSlideNumbers:e?.showcaseSlideNumbers||[],assignedSlide:t})} +\`\`\``}function Ky(e){let t=(e?.assignedSlides||[])[0]||{},r=t?.slideNumber??"?",n=ec(t?.slideNumber||0);return`Render one PPT Live slide. This is the RENDER phase of a staged pipeline running in a dedicated deck project directory: the workspace root of this session is the deck's \`{{ppt_project_dir}}\`. The plan (research, outline, design system, render guide, and per-slide briefs) is already final and is provided in the input JSON as \`plan\`. This turn must render ONLY slide ${r}. + +1. Call \`Skill('${ir}')\`; verify the result reports the exact stable key. Never substitute another skill. +2. \`Read\` every path in \`plan.generationContract.requiredReferences\`, including mandatory references \`${$n.join("`, `")}\`, plus the selected style preset when listed. +3. \`Read\` \`project.json\`, then follow \`generationContract\`, \`plan.design\`, and the assigned slide together. Do not re-research or change the planned title, claim, layout, or narrative role. +4. \`Write\` exactly one complete document to \`${n}\`: self-contained 960pt \xD7 540pt HTML with inline CSS and audience-ready copy. +5. End with "SLIDE ${r} READY"; do not paste HTML into the reply. Render rules: -- Return exactly the slides listed in \`assignedSlides\`, in ascending \`slideNumber\` order, and no others. If \`completedSlides\` is present in the input, those slides are already done \u2014 never regenerate them. -- Emit each slide's JSON object completely before starting the next one, so partial output remains recoverable. -- Keep the HTML compact: no HTML comments, no unused CSS rules, minimal whitespace and indentation. The response is streamed over a connection that gets cut after several minutes, so wasted characters risk failing the whole batch. Density of CONTENT is good; padding of MARKUP is not. +- Apply every explicit user style setting from \`generationContract.userStyle\`. +- Keep the HTML compact: no HTML comments, no unused CSS rules, minimal whitespace and indentation. Density of CONTENT is good; padding of MARKUP is not. +${ei} Input JSON: \`\`\`json -${Ml(e)} -\`\`\``+zl(e)}function yy(e){return`Generate or revise a PPT Live deck. The user only sees the PPT Live app UI. +${Dn(e)} +\`\`\``+ti(e)}function Qy(e){let t=e?.assignedSlide||(e?.assignedSlides||[])[0]||{},r=t?.slideNumber??"?",n=ec(t?.slideNumber||0);return`Repair PPT Live slide ${r} in the existing deck Agent Session. + +The host validated \`${n}\` and rejected it for editable-PPTX export. Fix the slide on disk. Do not regenerate the deck, re-research, or replace the page with a generic template. + +You choose how to repair: +1. \`Read\` \`project.json\` and \`${n}\` first. +2. Treat the validator findings below as the acceptance checklist. Keep the planned content, claim, evidence, visual identity, and layout unless a finding requires a structural change. +3. Make the smallest change that clears every finding. Prefer targeted \`Edit\` on \`${n}\` when a finding points at a specific element or block (for example move background/border/shadow from a text tag onto an enclosing DIV, fix one rule, adjust one section). Use \`Write\` for the whole file only when localized edits are impractical or would leave the file inconsistent. +4. Do not call Skill again, do not re-read reference markdown, and do not modify other slides. +5. When \`${n}\` satisfies every finding, end with "SLIDE ${r} REPAIRED". + +Editable-PPTX rules the validator enforces: +${ei} +${ti(e)} + +Validator findings: +\`\`\`json +${Dn(e?.validationIssues||[])} +\`\`\` + +Assigned slide and contract: +\`\`\`json +${Dn({generationContract:e?.generationContract||{},design:e?.design||{},style:e?.style||{},assignedSlide:t})} +\`\`\``}function Zy(e){return`Perform the FINAL whole-deck audit for this PPT Live project in the SAME deck Agent Session where planning and rendering already loaded Skill('${ir}') and distilled rules into \`project.json\`. + +Do NOT call Skill again and do NOT re-read reference markdown unless you must verify one specific rule. Treat \`generationContract.hardRules\`, \`visualGrammar\`, and \`design.renderGuide\` as authoritative. + +${Bf(e)} +1. \`Read\` \`project.json\` and every \`slides/slide-XX.html\` listed in \`slide_order\`. +2. Check every page against the generation contract, user prompt/style, narrative role, evidence, editable PPTX constraints, and taste guardrails already captured in the contract. +3. Check deck-level quality using a thumbnail/contact-sheet pass: visual thesis, signature move discipline, distinct adjacent silhouettes, deliberate density curve, one dominant element per page, no SaaS card-template repetition, no filler labels or fake UI, no missed high-value visual explanation, accurate sources, readable density, and consistent typography/palette/object styles. +4. Rewrite only slide files that need improvement. Preserve correct content and never invent facts. +5. Write \`quality-report.json\` containing \`{"status":"passed","checkedSlides":["every slide_id from slide_order"],"fixedSlides":["only slide_ids you rewrote"],"notes":["specific deck-level findings and fixes, or a concise reason no fixes were needed"]}\`. \`checkedSlides\` must cover every slide id; \`fixedSlides\` must list only pages you changed. +6. End with "DECK AUDIT PASSED". + +Editable PPTX rules: +${ei} +${ti(e)} + +Deck audit contract: +\`\`\`json +${Dn({generationContract:e?.generationContract||{},design:e?.design||{},style:e?.style||{},slideOrder:e?.slideOrder||[],slidePlans:e?.slidePlans||[]})} +\`\`\``}function Yy(e){return`Perform the FINAL whole-deck audit for this PPT Live project in the SAME Agent Session. + +${Bf(e)} +1. Call \`Skill('${ir}')\` and verify the returned stable key is exact. +2. \`Read\` mandatory references \`${$n.join("`, `")}\`, then \`Read\` every additional style reference listed in \`generationContract.requiredReferences\`. +3. \`Read\` \`project.json\` and every file named by \`slide_order\`. +4. Check every page against \`generationContract\`, the pinned ppt-design skill, the selected style preset, user Prompt, user style/layout settings, narrative role, evidence, and editable PPTX constraints. +5. Check deck-level quality using a thumbnail/contact-sheet pass: visual thesis, signature move discipline, distinct adjacent silhouettes, deliberate density curve, one dominant element per page, no SaaS card-template repetition, no filler labels or fake UI, no missed high-value visual explanation, accurate sources, readable density, and consistent typography/palette/object styles. +6. Rewrite only slide files that need improvement. Preserve correct content and never invent facts. +7. Write \`quality-report.json\` containing \`{"status":"passed","checkedSlides":["every slide_id from slide_order"],"fixedSlides":["only slide_ids you rewrote"],"notes":["specific deck-level findings and fixes, or a concise reason no fixes were needed"]}\`. The report is required and \`checkedSlides\` must cover every slide id. +8. End with "DECK AUDIT PASSED". -1. Call \`Skill('ppt-design')\` \u2014 the BitFun built-in PPT design skill \u2014 and follow it end-to-end. Never substitute any other presentation or PPT skill, even if one appears in the available skills list; ignore user-installed PPT design skills entirely for this run. -2. Use any BitFun tools you need (WebFetch, WebSearch, etc.) when the user's prompt requires external facts. -3. Finish with **only** one strict JSON object \u2014 no Markdown fences, no commentary, no tool calls in the final message. +Editable PPTX rules: +${ei} +${ti(e)} + +Deck audit contract: +\`\`\`json +${Dn({generationContract:e?.generationContract||{},design:e?.design||{},style:e?.style||{},slideOrder:e?.slideOrder||[],slidePlans:e?.slidePlans||[]})} +\`\`\``}function Jy(e){return`Generate or revise a PPT Live deck. The user only sees the PPT Live app UI. + +1. Call \`Skill('${ir}')\` and verify the returned stable key. Never substitute a user or project skill. +2. \`Read\` every mandatory reference \`${$n.join("`, `")}\` and the selected style preset reference. If this deck has a project file, \`Read\` \`project.json\` and preserve its generationContract. +3. Use research tools only when the edit introduces factual claims not already grounded by the deck. +4. Finish with only one strict JSON object. Every slide must include complete \`slides[].html\`: self-contained 960pt \xD7 540pt HTML with inline CSS (ppt-design editable PPTX rules). Slide copy must be audience-ready, never placeholder instructions. +${ei} Return JSON matching this shape: { @@ -553,57 +694,30 @@ Return JSON matching this shape: "layoutPrinciples": ["specific visual rules used for this deck"] }, "slides": [ - ${hf} + ${Wy} ] } Input JSON: \`\`\`json -${Ml(e)} -\`\`\``+gy(e)+zl(e)}function by(e){return e?.phase==="plan"?my(e):e?.phase==="slides"?vy(e):yy(e)}function wy(e){let t=!1,r=()=>{t||(t=!0,e.agent.onEvent(n=>{!n||typeof n!="object"||ff(n)}))};e.backend={async call(n,i,a={}){if(n!=="ppt.generate")throw new Error(`Unsupported PPT Live action: ${n}`);r();let o=by(i),l=await e.agent.run(o,{runId:a.idempotencyKey,sessionName:"PPT Live"});if(!l?.sessionId||!l?.turnId)throw new Error("PPT Live agent backend did not return sessionId/turnId");return{sessionId:l.sessionId,turnId:l.turnId,actionRunId:l.actionRunId||l.turnId}},onEvent(n){ua.add(n)},offEvent(n){ua.delete(n)},async cancel(n,i){await e.agent.cancel(n,i)},async turnText(n,i){return{text:(await e.agent.turnText(n,i))?.text||""}},async cancelStaleRuns(){await e.agent.cancelStaleRuns()}}}var Nl=`You are PPT Live, a presentation design engine embedded in BitFun. -Return strict JSON only, without markdown fences or commentary. -Use only the user brief, supplied source material, and clearly marked assumptions. -Every rendered slide must be a self-contained HTML document sized for a 960pt by 540pt canvas. -Do not use remote scripts, stylesheets, fonts, images, or other network assets in slide HTML. -Prefer concise assertion-led copy, strong hierarchy, generous whitespace, and content-aware layouts. -Avoid purple gradients, decorative emoji, generic illustration filler, fake citations, and text-heavy pages. -Keep body text at least 10px and reserve a 36pt bottom safety margin.`;function Pn(e,t,r={}){ff({sessionId:e.sessionId,turnId:e.turnId,sourceEvent:t,...r})}function Il(e){let t=e?.style||{};return[`Color mode: ${t.colorMode||"light"}.`,`Font family: ${t.fontFamily||"sans"}.`,`Density: ${t.density||"standard"}.`,`Style preset: ${t.stylePreset||"editorial"}.`,`Palette: ${JSON.stringify(t.palette||{})}.`,"Use flex or grid with min-height:0 and overflow:hidden.","Choose structure from the content: comparison, data, process, timeline, KPI, quote, or structured text.","Label quantitative visuals with values."].join(` -`)}function xy(e){let t=JSON.stringify(e);if(e?.phase==="plan")return{systemPrompt:`${Nl} -This is the planning phase. Do not generate slide HTML. -Return: -{"title":"","language":"zh-CN|en-US","outline":[],"researchReport":{"summary":"","verifiedFacts":[],"assumptions":[],"warnings":[]},"design":{"stylePhilosophy":"pentagram|muller-brockmann|build|kenya-hara|takram","theme":"light|dark","palette":{},"layoutPrinciples":[]},"slidePlans":[{"slideNumber":1,"role":"cover|content|data|transition|closing","narrativeStage":"hook|progression|climax|landing","title":"","kicker":"","claim":"","proofObject":"","supportNote":"","sourceNote":"","facts":[],"bullets":[],"metric":{"value":"","label":""},"chartData":[],"notes":"","layout":"cover|brief|evidence|process|comparison|quote|data|closing","visualTreatment":"typographic|grid|editorial|white-space|soft-tech|data|process|comparison","contentBrief":""}]}. -slidePlans must be one-based, contiguous, complete, and in final order. Each contentBrief must contain exact copy direction, facts, visual form, and layout intent. Keep the JSON compact.`,prompt:`Plan this deck from the supplied brief and source material. -${Il(e)} -Input JSON: -${t}`};if(e?.phase==="slides"){let n=(e.assignedSlides||[]).map(i=>i.slideNumber).join(", ");return{systemPrompt:`${Nl} -This is the render phase. Render only assigned slide numbers ${n}; do not research or change the plan. -Return: -{"slides":[{"slideNumber":1,"role":"cover|content|data|transition|closing","narrativeStage":"hook|progression|climax|landing","title":"","kicker":"","claim":"","proofObject":"","supportNote":"","sourceNote":"","facts":[],"bullets":[],"metric":{"value":"","label":""},"chartData":[],"notes":"","layout":"cover|brief|evidence|process|comparison|quote|data|closing","visualTreatment":"typographic|grid|editorial|white-space|soft-tech|data|process|comparison","html":"..."}]}. -Return exactly the assigned slides in ascending order. Preserve each planned title, claim, role, and slideNumber. Apply plan.design consistently and complete each slide object before starting the next.`,prompt:`Render the assigned slides. -${Il(e)} -Input JSON: -${t}`}}let r=pf(e)?`The current deck is supplied. Prefer a minimal deckPatch: -{"title":"","language":"zh-CN|en-US","outline":[],"researchReport":{"summary":"","verifiedFacts":[],"assumptions":[],"warnings":[]},"design":{"stylePhilosophy":"","theme":"light|dark","palette":{},"layoutPrinciples":[]},"deckPatch":{"rationale":"","changedSlideIndexes":[0],"changes":[{"op":"replace_slide|insert_slide|delete_slide","slideId":"","slideIndex":0,"slideNumber":1,"afterSlideId":"","slide":{"id":"","title":"","claim":"","notes":"","html":"..."}}]}}. -For replace_slide, reuse the existing id and return a complete replacement slide. For delete_slide, omit slide. Return a full slides array only for whole-deck rewrites.`:"This is a first-pass generation. Return a complete slides array using the render-phase slide shape.";return{systemPrompt:`${Nl} -${r}`,prompt:`Generate or revise the deck. -${Il(e)} -Input JSON: -${t}`}}function Sy(){let e=`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,t={sessionId:`bitfun-ppt-${e}`,turnId:`bitfun-turn-${e}`,text:"",thinking:"",handle:null,cancelled:!1,settled:!1};return Oo.set(t.turnId,t),t}function ky(e,t,r){if(t.cancelled)return;let n=xy(r);Pn(t,"bitfun:model-round-started"),e.ai.chat([{role:"user",content:n.prompt}],{systemPrompt:n.systemPrompt,model:"primary",maxTokens:16e3,temperature:.35,onChunk:(i={})=>{if(t.cancelled||t.settled)return;let a=typeof i=="string"?i:i.text,o=typeof i=="object"?i.reasoningContent:"";a&&(t.text+=String(a),Pn(t,"bitfun:text-chunk",{text:String(a),contentType:"answer"})),o&&(t.thinking+=String(o),Pn(t,"bitfun:text-chunk",{text:String(o),contentType:"thinking"}))},onDone:(i={})=>{if(t.cancelled||t.settled)return;let a=String(i.fullText||"").trim();a&&(t.text=a),t.settled=!0,Pn(t,"bitfun:model-round-completed"),Pn(t,"bitfun:dialog-turn-completed")},onError:(i={})=>{t.cancelled||t.settled||(t.settled=!0,Pn(t,"bitfun:dialog-turn-failed",{error:String(i.message||i||"PPT Live AI request failed")}))}}).then(i=>{if(t.handle=i,t.cancelled)return i?.cancel?.()}).catch(i=>{t.cancelled||t.settled||(t.settled=!0,Pn(t,"bitfun:dialog-turn-failed",{error:String(i?.message||i||"PPT Live AI request failed")}))})}async function uf(e,t){if(!(!t||t.cancelled||t.settled)){t.cancelled=!0;try{t.handle?.cancel?await t.handle.cancel():t.handle?.streamId&&e.ai?.cancel&&await e.ai.cancel(t.handle.streamId)}finally{t.settled=!0,Pn(t,"bitfun:dialog-turn-cancelled")}}}function Cy(e){e.backend={call(t,r){if(t!=="ppt.generate")return Promise.reject(new Error(`Unsupported PPT Live action: ${t}`));let n=Sy();return setTimeout(()=>ky(e,n,r),0),Promise.resolve({sessionId:n.sessionId,turnId:n.turnId,actionRunId:n.turnId})},onEvent(t){ua.add(t)},offEvent(t){ua.delete(t)},async cancel(t,r){let n=Oo.get(r);n?.sessionId===t&&await uf(e,n)},async turnText(t,r){let n=Oo.get(r);return!n||n.sessionId!==t?{text:""}:{text:n.text||n.thinking||""}},async cancelStaleRuns(){await Promise.all([...Oo.values()].filter(t=>!t.settled).map(t=>uf(e,t)))}}}function Af(e=window.app){if(!(!e||e.backend?.call)){if(e.agent?.run){wy(e);return}e.ai?.chat&&Cy(e)}}var N=In(),Fn=!1,Fr=null,Dn=[],Bn=0,Wo=!1,ha=!1,Zn=[],Ol=0,xe=e=>document.getElementById(e),yt=()=>window.app||{};Af(yt());var Df=2500,Ho=new Map;function Ul(e){try{return localStorage.getItem(e)}catch{return Ho.has(e)?Ho.get(e):null}}function Wl(e,t){try{localStorage.setItem(e,t)}catch{Ho.set(e,t)}}var pa={get:async e=>JSON.parse(Ul(e)||"null"),set:async(e,t)=>Wl(e,JSON.stringify(t))};function Ef(){let e=yt();return e.storage?e.storage:pa}async function Bf(e){let t=Ef();if(t===pa||!yt().storage)return t.get(e);try{return await Promise.race([t.get(e),new Promise((r,n)=>setTimeout(()=>n(new Error("storage-timeout")),Df))])}catch(r){return yt().log?.warn?.("Host storage read timed out, using local fallback",{key:e,error:String(r)}),pa.get(e)}}async function _o(e,t){let r=Ef();if(r===pa||!yt().storage){await r.set(e,t);return}try{await Promise.race([r.set(e,t),new Promise((n,i)=>setTimeout(()=>i(new Error("storage-timeout")),Df))])}catch(n){yt().log?.warn?.("Host storage write timed out, using local fallback",{key:e,error:String(n)}),await pa.set(e,t)}}async function Py(){try{Zn=await Fy();let e=await Bf(ki);if(e){N=ln(e),Xl(N)&&(N=In(),await _o(ki,{...N,updatedAt:Date.now()}));return}N=In(),await At(!0)}catch(e){yt().log?.warn?.("Failed to load PPT Live state",{error:String(e)}),N=In()}}async function At(e=!1){N=ln(N),await _o(ki,{...N,updatedAt:Date.now()}),await Qo(e?"autosave":"manual"),e||jt(U("saved"))}async function Fy(){try{let e=await Bf(ns);return Array.isArray(e)?e.map(Rf).filter(Boolean).slice(0,40):[]}catch(e){return yt().log?.warn?.("Failed to load PPT Live history",{error:String(e)}),[]}}async function Qo(e="autosave"){if(!N?.slides?.length||Xl(N))return;let t=Date.now();if(e==="autosave"&&Ol&&t-Ol<15e3)return;Ol=t;let r=Rf({id:N.sessionId||or("deck"),title:N.title||U("blankDeckTitle"),updatedAt:t,slideCount:N.slides.length,reason:e,prompt:N.promptDraft||N.brief?.topic||"",state:zr({...N,generation:{...N.generation,active:!1}})});r&&(Zn=[r,...Zn.filter(n=>n.id!==r.id)].slice(0,40),await _o(ns,Zn),Lf())}function Xl(e){let t=Array.isArray(e?.slides)?e.slides:[];return t.length===1&&!t[0]?.html&&String(t[0]?.id||"").startsWith("agent-working-slide")&&String(e?.title||"")===U("agentWorkingTitle")&&!e?.generation?.active}function Rf(e){return!e?.id||!e?.state?null:{id:String(e.id),title:String(e.title||e.state?.title||U("blankDeckTitle")),updatedAt:Number(e.updatedAt||Date.now()),slideCount:Number(e.slideCount||e.state?.slides?.length||0),reason:String(e.reason||"autosave"),prompt:String(e.prompt||e.state?.brief?.topic||""),state:e.state}}function Lf(){let e=xe("historyList");if(e){if(e.innerHTML="",!Zn.length){let t=document.createElement("div");t.className="history-empty",t.textContent=U("historyEmpty"),e.append(t);return}Zn.slice(0,12).forEach(t=>{let r=document.createElement("button");r.type="button",r.className=`history-card${t.id===N.sessionId?" is-active":""}`,r.innerHTML=` - ${gf(t.title)} - ${U("historyMeta",{count:t.slideCount,time:Dy(t.updatedAt)})} - ${t.prompt?`${gf(t.prompt)}`:""} - `,r.addEventListener("click",()=>{Ty(t.id)}),e.append(r)})}}async function Ty(e){let t=Zn.find(r=>r.id===e);t&&(Bn+=1,await ec(),N=ln(zr(t.state)),N.generation.active=!1,ga(),qt(),jt(U("historyRestored")),await _o(ki,{...N,updatedAt:Date.now()}))}function Dy(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return`${r}/${n} ${i}:${a}`}function gf(e){return String(e??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function jt(e){let t=xe("statusLine");t&&(t.textContent=e)}function xi(e){let t=xe("exportStatus");t&&(t.textContent=e)}function En(e,t){Fn=e,document.querySelector(".ppt-live")?.classList.toggle("is-busy",Fn),document.querySelectorAll("button, input, select, textarea").forEach(n=>{if(!["closePreview","prevPresent","nextPresent"].includes(n.id)){if(n.id==="cancelGeneration"){n.disabled=!Fn,n.hidden=!Fn;return}n.id!=="newDeck"&&(n.disabled=Fn)}});let r=xe("aiStatusPill");r&&(r.textContent=Fn?U("statusPillBusy"):U("statusPillReady"),r.classList.toggle("is-busy",Fn)),t&&jt(t)}function Dt(e,t,r){N.generation.current=e,N.generation.steps=N.generation.steps.map(n=>({...n,status:n.id===e?t:n.status})),N.generation.active=t==="running"||N.generation.steps.some(n=>n.status==="running"),Tr(N),Dr(N),r&&jt(r)}function ga(){N.generation.active=!1,N.generation.current="idle",N.generation.draftedCount=0,N.generation.slideTarget=0,N.generation.eventSeq=0,N.generation.steps=N.generation.steps.map(e=>({...e,status:"pending"})),N.generation.events=[],Tr(N),Dr(N)}function Nt(e,t="",r="info"){N.generation=Sa(N.generation||{});let n=typeof e=="string"?{title:e,detail:t,kind:r}:{...e||{}},i=Nr(n.title||n.label||n.message||U("processEventUnknown"),160),a=Nr(n.detail??t??"",260),o=String(n.kind||r||"info").toLowerCase().replace(/[^a-z0-9-]/g,"")||"info";if(!i&&!a)return;let l=Array.isArray(N.generation.events)?N.generation.events:[],c=l[l.length-1];if(c&&c.title===i&&c.detail===a&&c.kind===o)c.timestamp=Date.now(),N.generation.events=l;else{let s=l.reduce((u,f)=>Math.max(u,Number(f.seq)||0),0),d=Math.max(Number(N.generation.eventSeq)||0,s)+1;N.generation.eventSeq=d,N.generation.events=[...l,{id:or("generation-event"),seq:d,title:i||U("processEventUnknown"),detail:a,kind:o,timestamp:Date.now()}].slice(-80)}Tr(N),Dr(N)}function qt(){N=ln(N),Dc(N,Jt),Lf()}function an(e={}){zc(N,e),N=ln(N)}function Nf(){return xe("topicInput")?.value.trim()||""}function Hl(){let e=uc().join(` -`);return!N.outline.length||N.outline.join(` -`)===e||N.title===U("defaultDeckTitle")||Zo()}function Zo(){let e=String(N.title||"").trim();return N.slides.length===1&&N.outline.length===1&&N.outline[0]===U("newSlideTitle")&&(e===U("blankDeckTitle")||e===U("newSlideTitle"))}function Rn(){return Array.isArray(N.slides)&&N.slides.length>0&&!Hl()&&!Zo()&&!Xl(N)}async function Ey(){await Kl()}async function By(){await Kl()}async function Kl(){if(Wo||ha)return;let e=Nf();if(!e){jt(U("promptRequired"));return}Wo=!0;let t=Rn();N.promptDraft=e,N.lastSubmittedPrompt=e,an({includeTopic:!t}),t||(N.brief.topic=e);try{await Mf("auto",e,{includeTopic:!t});return}catch(r){if(tc(r))return;yt().log?.warn?.("PPT Live backend generation failed",{error:String(r)}),If(r),qt(),await At(!0)}finally{Wo=!1}}function _l(e=U("deckReady")){N.generation.active=!1,N.generation.draftedCount=N.slides.length,N.generation.slideTarget=0,N.generation.steps=(N.generation.steps||[]).map(t=>({...t,status:t.status==="error"?"error":"done"})),jt(e),Tr(N),Dr(N)}function Ry(e=U("backendGenerationFailed"),t=""){N.generation.active=!1,N.generation.steps=(N.generation.steps||[]).map(r=>({...r,status:r.status==="done"?"done":"error"})),jt(e),Nt({title:e,detail:t||U("agentOnlyRetryHint"),kind:"error"}),En(!1),Tr(N),Dr(N)}function Ql(e){let t=String(e?.message||e||"").trim();return t?Nr(t.replace(/^Error:\s*/i,"").replace(/^Tauri command .*? failed:\s*/i,"").replace(/^live_app_backend_call:\s*/i,"").replace(/^Failed to start PPT Live generation:\s*/i,"").trim(),220):""}function If(e){let t=Ql(e),r,n=t;gb(e)?r=U("generationTimedOut"):Ab(e)?(r=U("generationRoundBudgetFailed"),n=U("generationRoundBudgetHint")):t?r=U("backendGenerationFailedWithReason",{reason:t}):r=U("backendGenerationFailed"),Ry(r,n||U("agentOnlyRetryHint"))}function Ly(){let e={topic:String(N.brief?.topic||N.promptDraft||"").trim(),audience:String(N.brief?.audience||"").trim(),material:String(N.brief?.material||"").trim().slice(0,12e3),sources:N.sources?{summary:String(N.sources.summary||"").slice(0,4e3),facts:(N.sources.facts||[]).slice(0,16),warnings:(N.sources.warnings||[]).slice(0,8),items:(N.sources.items||[]).slice(0,6).map(r=>({kind:r.kind,title:r.title,url:r.url,text:String(r.text||"").slice(0,6e3)}))}:null},t=Number(N.brief?.slideTarget)||0;return t>0&&(e.slideTarget=t),e}function Ny(){let e=$o(N.style?.stylePreset);return{fontFamily:N.style?.fontFamily==="serif"?"serif":"sans",density:Nn(N.style?.density),colorMode:N.style?.colorMode==="dark"?"dark":"light",stylePreset:N.style?.stylePreset||on,palette:e.palette||{}}}function Iy(e){let t=String(e||"").trim();if(!t)return"";try{let r=new DOMParser().parseFromString(t,"text/html");return r.querySelectorAll("style,script,svg").forEach(n=>n.remove()),Nr(r.body?.textContent||r.documentElement?.textContent||"",1800)}catch{return Nr(t.replace(/<[^>]+>/g," "),1800)}}function My(e){let t=new Set,r=String(e||""),n=$t(N);return/(当前|本页|这一页|此页|current\s+(slide|page)|this\s+(slide|page))/i.test(r)&&t.add(n),[/第\s*(\d{1,2})\s*(页|頁|张|張)/gi,/\b(?:slide|page)\s*(\d{1,2})\b/gi,/\b(\d{1,2})\s*(?:slide|slides|page|pages)\b/gi].forEach(a=>{let o=a.exec(r);for(;o;){let l=Number(o[1])-1;l>=0&&la-o)}function zy(e){let t=My(e),r=$t(N),n=new Set(t.length?t:[r]);return{title:N.title,outline:zr(N.outline||[]),slideCount:N.slides.length,activeSlideIndex:r,activeSlideId:N.slides[r]?.id||"",targetHints:t.map(i=>({slideIndex:i,slideNumber:i+1,slideId:N.slides[i]?.id||"",title:N.slides[i]?.title||""})),slides:N.slides.map((i,a)=>{let o=i.html?Iy(i.html):Nr((i.elements||[]).flatMap(c=>[c.text,c.label,...Array.isArray(c.items)?c.items:[]]).filter(Boolean).join(` -`),1800),l={slideIndex:a,slideNumber:a+1,id:i.id,title:i.title,kicker:i.kicker,claim:i.claim,proofObject:i.proofObject,supportNote:i.supportNote,sourceNote:i.sourceNote,notes:i.notes,layout:i.layout,visibleText:o,hasHtml:!!i.html};return n.has(a)&&i.html&&(l.html=String(i.html).slice(0,12e3)),l})}}function mf(e,t){let r=t.getBoundingClientRect(),n=mt((e-r.left)/r.width,0,1);return Math.round(n*2)}function Qn(e,{save:t=!0}={}){let r=mt(Math.round(Number(e)),0,2);N.style.density=cc(r),Di(N.style.density),qt(),t&&At(!0)}var rr=3;function Zl(e){let t=String(e?.message||e||"");return!(tc(e)||/Generation stopped/i.test(t)||/backend is unavailable|did not return sessionId/i.test(t))}async function Mf(e,t,r={}){if(!yt().backend?.call)throw new Error("PPT Live backend is unavailable");if(!ha){ha=!0;try{if(an({includeTopic:r.includeTopic!==!1}),e==="auto"&&(Hl()||Zo())){await Hy(e,t);return}await Oy(e,t)}finally{ha=!1}}}async function Oy(e,t){let r=null;for(let n=1;n<=rr;n+=1)try{await Uy(e,t,n);return}catch(i){if(r=i,!Zl(i)||n>=rr)throw i;yt().log?.warn?.("PPT Live backend attempt failed, retrying",{attempt:n,maxAttempts:rr,error:String(i)}),Nt({title:U("generationRetrying",{attempt:n+1,max:rr}),detail:Ql(i),kind:"error"}),jt(U("generationRetrying",{attempt:n+1,max:rr})),await new Promise(a=>setTimeout(a,1500*n))}if(r)throw r}async function Yl(e,t={}){let r=yt(),n=Bn,i=null,a=null,o="",l="",c=!1,s=0,d=[],u=new Set,f=Qy(),h={lastEventAt:Date.now()};try{let p=await r.backend.call("ppt.generate",e,{entityId:"deck",idempotencyKey:`ppt-live-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});if(i=p?.sessionId||null,a=p?.turnId||p?.actionRunId||null,!i||!a)throw new Error("PPT Live backend did not return sessionId/turnId");if(ab(i,a),Tn(n))throw new Error("Generation stopped");let A=new Promise((T,I)=>{let R=P=>{if(P.sessionId!==i||P.turnId&&P.turnId!==a)return;h.lastEventAt=Date.now();let z=String(P.sourceEvent||"");if(z.endsWith("dialog-turn-started"))f.note(U("eventTurnStarted"),"","turn");else if(z.endsWith("model-round-started"))t.onToolPhase?.("round"),f.note(U("processEventRound"),"","phase");else if(z.endsWith("model-round-completed"))f.note(U("eventRoundCompleted"),"","phase");else if(z.endsWith("tool-event")){let q=$l(P.toolEvent||{}),S=q.event_type||q.eventType||"";if(_y(q,u)&&(Nt(nb(P)),f.touch()),S==="EarlyDetected"||S==="Started")t.onToolPhase?.("detected");else if(S==="Completed"){let V=String(q.tool_name||q.toolName||"").trim().toLowerCase();t.onToolPhase?.("completed"),V==="skill"?f.note(U("eventToolSkillReady"),Of(q.tool_name||q.toolName),"phase"):(V==="websearch"||V==="webfetch")&&t.onToolPhase?.("research")}}else if(z.endsWith("text-chunk")){let q=String(P.text||"");if(P.contentType==="thinking")l+=q;else{o+=q,f.touch();let V=Date.now();V-s>=500&&(s=V,t.onTextProgress?.(o))}}else if(!z.endsWith("token-usage-updated")){if(z.endsWith("dialog-turn-completed"))c=!0,T({answer:o,thinking:l});else if(z.endsWith("dialog-turn-failed")||z.endsWith("dialog-turn-cancelled")){c=!0,o&&t.onTextProgress?.(o);let q=Nr(P.error||P.message||"");Nt({title:z.endsWith("dialog-turn-cancelled")?U("eventTurnCancelled"):U("eventTurnFailed"),detail:q,kind:"error"}),I(new Error(q||z))}}};r.backend.onEvent(R),d.push(()=>r.backend.offEvent?.(R));let B=setInterval(()=>{if(c||Date.now()-f.lastProgressLogAt<12e3)return;let z=(N.generation?.steps||[]).find(q=>q.status==="running");f.note(z?.label?`${z.label}\u2026`:U("generationProgressPulse"),z?.detail||"","pulse",0)},12e3);d.push(()=>clearInterval(B))}),y=await hb(A,i,a,h),m=typeof y=="string"?y:y?.answer||"",w=typeof y=="string"?"":y?.thinking||"";if(Tn(n))throw new Error("Generation stopped");let x=await pb(i,a,m,w);if(Tn(n))throw new Error("Generation stopped");let C=Aa(x);if(Tn(n))throw new Error("Generation stopped");return C}catch(p){if(!c&&i&&a&&r.backend?.cancel)try{await r.backend.cancel(i,a)}catch(A){yt().log?.warn?.("PPT Live backend cancel after failure failed",{sessionId:i,turnId:a,error:String(A)})}throw p}finally{d.forEach(p=>p()),i&&a&&ob(i,a)}}function Jl(e,t){return{operation:e,instruction:t,locale:Mr(),brief:Ly(),style:Ny()}}async function Uy(e,t,r=1){let n=Bn;En(!0,U("working")),ga(),Dt("brief","running",U("generationReadingBrief")),Nt({title:U("processEventStarted"),detail:U("processEventWaiting"),kind:"start"}),r>1&&Nt({title:U("generationRetryAttempt",{attempt:r,max:rr}),detail:"",kind:"start"}),zf(e,t);let i=!1,a={value:""},o={touch:()=>{},note:()=>{},lastProgressLogAt:0};try{let l=await Yl({...Jl(e,t),title:N.title,outline:zr(N.outline),currentSlideIndex:$t(N),currentDeck:zy(t)},{onToolPhase:c=>{c==="detected"?Dt("brief","running",U("generationReadingBrief")):c==="completed"?(Dt("brief","done"),Dt("spine","running",U("generationWritingClaims"))):c==="research"?Dt("proof","running",U("generationChoosingProof")):c==="round"&&Dt("spine","running",U("generationWritingClaims"))},onTextProgress:c=>rb(c,o,a)});Nt({title:U("generationParsingDeck"),detail:"",kind:"parsing"}),jt(U("generationParsingDeck")),Uf(l),await Qo(`agent:${e}`),Nt({title:U("processEventDone"),detail:"",kind:"done"}),Dt("spine","done"),Dt("proof","done"),Dt("design","done"),Dt("compile","done",U("generationCompiled")),_l(U("deckReady")),i=!0,qt(),await At(!0)}finally{!Tn(n)&&(N.generation.active&&!i&&(N.generation.active=!1),En(!1)),Tr(N),Dr(N)}}var Wy=2,vf=2;function Gy(e){let t=String(e||""),r=t.indexOf('"slides"');if(r<0)return[];let n=t.indexOf("[",r);if(n<0)return[];let i=[],a=n+1,o=t.length;for(;a=o||t[a]==="]")break;let l=0,c=!1,s=!1,d=-1;for(let u=a;u{for(;n0?Math.round(r):t}async function Vy(e,t){let r=null;for(let n=1;n<=rr;n+=1)try{n>1&&(Nt({title:U("generationPlanRetry",{attempt:n,max:rr}),detail:Ql(r),kind:"error"}),jt(U("generationPlanRetry",{attempt:n,max:rr})),await new Promise(o=>setTimeout(o,1500*n)));let i=await Yl({...Jl(e,t),phase:"plan",title:N.title,outline:[]},{onToolPhase:o=>{o==="detected"?Dt("brief","running",U("generationReadingBrief")):o==="completed"||o==="round"?(Dt("brief","done"),Dt("spine","running",U("generationWritingClaims"))):o==="research"&&Dt("proof","running",U("generationChoosingProof"))},onTextProgress:o=>{if(!o.includes('"slidePlans"'))return;let l=(o.match(/"slideNumber"/g)||[]).length;l>0?(Dt("proof","running",U("generationPlanProgress",{count:l})),jt(U("generationPlanProgress",{count:l}))):Dt("proof","running",U("generationPlanningSlides"))}}),a=Array.isArray(i?.slidePlans)?i.slidePlans.filter(o=>o&&typeof o=="object"):[];if(!a.length)throw new Error("PPT Live plan phase returned no slidePlans");return{payload:i,slidePlans:a}}catch(i){if(r=i,!Zl(i)||n>=rr)throw i;yt().log?.warn?.("PPT Live plan phase failed, retrying",{attempt:n,maxAttempts:rr,error:String(i)})}throw r}async function Xy({operation:e,instruction:t,planContext:r,batch:n,batchNumber:i,checkpoint:a,onSlideCheckpoint:o}){let l=n.map((d,u)=>Go(d,u+1)),c=d=>!a.has(d),s=null;for(let d=1;d<=rr;d+=1){let u=n.filter((f,h)=>c(l[h]));if(!u.length)return;try{if(d>1){let A=Math.min(...l.filter(c));Nt({title:U("generationBatchRetry",{batch:i,attempt:d,max:rr}),detail:U("generationResumeFrom",{slide:A}),kind:"error"}),jt(U("generationResumeFrom",{slide:A})),await new Promise(y=>setTimeout(y,1500*d))}let f=[...a.values()].filter(A=>l.includes(Number(A.slideNumber))).map(A=>({slideNumber:A.slideNumber,title:A.title||""})),h=await Yl({...Jl(e,t),phase:"slides",plan:r,assignedSlides:u,completedSlides:f},{onTextProgress:A=>{Gy(A).forEach(y=>{let m=Number(y.slideNumber);Number.isFinite(m)&&l.includes(m)&&!a.has(m)&&(a.set(m,y),o?.(m))})}});if((Array.isArray(h?.slides)?h.slides:[]).forEach((A,y)=>{if(!A||typeof A!="object"||!String(A.html||"").trim())return;let m=Go(A,u[y]?Go(u[y],NaN):NaN);Number.isFinite(m)&&l.includes(m)&&!a.has(m)&&(a.set(m,A),o?.(m))}),l.every(A=>a.has(A)))return;throw new Error(`PPT Live batch ${i} is missing slides: ${l.filter(c).join(", ")}`)}catch(f){if(s=f,!Zl(f)||d>=rr)throw f;yt().log?.warn?.("PPT Live slide batch failed, retrying remaining slides",{batch:i,attempt:d,maxAttempts:rr,missing:l.filter(c),error:String(f)})}}throw s}async function Hy(e,t){let r=Bn;En(!0,U("working")),ga(),Dt("brief","running",U("generationReadingBrief")),Nt({title:U("processEventStarted"),detail:U("processEventWaiting"),kind:"start"}),Nt({title:U("generationPlanPhase"),detail:"",kind:"phase"}),zf(e,t);let n=!1;try{try{await cf(N)}catch(A){yt().log?.warn?.("PPT Live source preparation failed",{error:String(A)})}let{payload:i,slidePlans:a}=await Vy(e,t);if(Tn(r))throw new Error("Generation stopped");Dt("brief","done"),Dt("spine","done"),Dt("proof","done"),Dt("design","running",U("generationDesigningLayouts")),N.generation.slideTarget=a.length,N.generation.draftedCount=0,Nt({title:U("generationPlanReady",{count:a.length}),detail:Nr((i.outline||[]).join(" / "),200),kind:"phase"}),i.title&&(N.title=String(i.title),qt());let o={title:i.title||"",language:i.language||"",outline:i.outline||[],researchReport:i.researchReport||{},design:i.design||{}},l=a.map((A,y)=>({...A,slideNumber:Go(A,y+1)})),c=qy(l,Wy);Nt({title:U("generationSlidesPhase",{batches:c.length,count:l.length,workers:Math.min(vf,c.length)}),detail:"",kind:"phase"});let s=new Map,d=A=>{N.generation.draftedCount=s.size,Dt("design","running",U("generationSlideReady",{slide:A,total:l.length})),Nt({title:U("generationSlideReady",{slide:A,total:l.length}),detail:"",kind:"slide"})},u=await jy(c.map((A,y)=>()=>Xy({operation:e,instruction:t,planContext:o,batch:A,batchNumber:y+1,checkpoint:s,onSlideCheckpoint:d})),vf);if(Tn(r))throw new Error("Generation stopped");let f=u.filter(A=>A.status==="rejected"),h=[...s.entries()].sort((A,y)=>A[0]-y[0]).map(([,A])=>A);if(f.length&&!h.length)throw f[0].reason;let p={title:i.title,language:i.language,outline:f.length?[]:i.outline,researchReport:i.researchReport,design:i.design,slides:h};if(Nt({title:U("generationParsingDeck"),detail:"",kind:"parsing"}),jt(U("generationParsingDeck")),Uf(p),await Qo(`agent:${e}`),f.length){let A=l.map(m=>m.slideNumber).filter(m=>!s.has(m));qt(),await At(!0);let y=new Error(U("generationPartialDeck",{missing:A.join(", ")}));throw y.pptLivePartialDeck=!0,y}Nt({title:U("processEventDone"),detail:"",kind:"done"}),Dt("design","done"),Dt("compile","done",U("generationCompiled")),_l(U("deckReady")),n=!0,qt(),await At(!0)}finally{!Tn(r)&&(N.generation.active&&!n&&(N.generation.active=!1),En(!1)),Tr(N),Dr(N)}}function zf(e,t){jt(U("generationAgentWorking")),Nt({title:U("generationAgentWorking"),detail:Nr(t||""),kind:"start"}),e==="auto"&&(Hl()||Zo())&&(N.title=U("agentWorkingTitle")),qt()}var Ky=new Set(["ParamsPartial","Queued","Waiting","Progress","Streaming","StreamChunk","Confirmed","Rejected"]);function Of(e){let t=String(e||"").trim();return t?/^skill$/i.test(t)?U("eventToolSkillName"):/^websearch$/i.test(t)?U("eventToolWebSearchName"):/^webfetch$/i.test(t)?U("eventToolWebFetchName"):t:U("eventUnknownTool")}function _y(e,t){let r=$l(e),n=r.event_type||r.eventType||"";if(Ky.has(n))return!1;let a=`${r.tool_id||r.toolId||r.tool_name||r.toolName||"tool"}:${n}`;return t.has(a)?!1:(t.add(a),!0)}function Qy(){let e=0,t="";return{get lastProgressLogAt(){return e},touch(){e=Date.now()},note(r,n="",i="phase",a=0){let o=Date.now(),l=r===t;return a>0&&l&&o-e0&&(N.generation.draftedCount=r),Tr(N),Dr(N)}function rb(e,t,r){let n=Zy(e),i=Yy(n);Dt(n,"running",i),tb(e,n),t.touch()}function nb(e){let t=$l(e.toolEvent||{}),r=t.event_type||t.eventType||"ToolEvent",n=Of(t.tool_name||t.toolName),i={EarlyDetected:U("eventToolDetected"),ParamsPartial:U("eventToolParams"),Queued:U("eventToolQueued"),Waiting:U("eventToolWaiting"),Started:U("eventToolStarted"),Progress:U("eventToolProgress"),Streaming:U("eventToolStreaming"),StreamChunk:U("eventToolStreamChunk"),ConfirmationNeeded:U("eventToolConfirmation"),Confirmed:U("eventToolConfirmed"),Rejected:U("eventToolRejected"),Completed:U("eventToolCompleted"),Failed:U("eventToolFailed"),Cancelled:U("eventToolCancelled")},a=new Set(["EarlyDetected","Started","Completed","Failed","Cancelled","ConfirmationNeeded"]);return{title:i[r]||U("processEventTool"),detail:a.has(r)?n:ib(r,t),kind:r==="Failed"||r==="Cancelled"||r==="Rejected"?"error":"tool"}}function ib(e,t){return e==="Failed"?Nr(t.error||U("backendGenerationFailed")):e==="Completed"?"":e==="Progress"?Nr(t.message||""):""}function $l(e){if(e.event_type||e.eventType||e.tool_name||e.toolName)return e;let r=["EarlyDetected","ParamsPartial","Queued","Waiting","Started","Progress","Streaming","StreamChunk","ConfirmationNeeded","Confirmed","Rejected","Completed","Failed","Cancelled"].find(i=>e&&Object.prototype.hasOwnProperty.call(e,i));return r?{...e[r]||{},event_type:r}:e||{}}function Nr(e,t=180){let r=String(e||"").replace(/\s+/g," ").trim();return r?r.length>t?`${r.slice(0,t-1)}...`:r:""}function ab(e,t){if(!e||!t)return;Dn.some(n=>n.sessionId===e&&n.turnId===t)||Dn.push({sessionId:e,turnId:t})}function ob(e,t){Dn=Dn.filter(r=>!(r.sessionId===e&&r.turnId===t))}function Tn(e){return e!==Bn}async function ec(){let e=[...Dn];Dn=[],!(!e.length||!yt().backend?.cancel)&&await Promise.all(e.map(async t=>{try{await yt().backend.cancel(t.sessionId,t.turnId)}catch(r){yt().log?.warn?.("PPT Live backend cancel failed",{sessionId:t.sessionId,turnId:t.turnId,error:String(r)})}}))}async function sb(e=!1,t={}){let r=Dn.length>0;Bn+=1,await ec(),N.generation.active=!1,N.generation.steps=N.generation.steps.map(n=>n.status==="running"?{...n,status:"error"}:n),!t.silent&&r&&(jt(e?U("generationTimedOut"):U("generationStopped")),Nt(e?U("generationTimedOut"):U("generationStopped"))),En(!1),Tr(N),Dr(N),t.silent||await At(!0)}async function lb(e=!1){await sb(e)}function Uf(e){if(ub(e)){e.researchReport&&bf(e.researchReport),e.design?.palette&&typeof e.design.palette=="object"&&(N.deckPalette=e.design.palette);return}let t=fb(e);if(t.length)N.title=String(e.title||N.title||U("blankDeckTitle")),N.slides=t.map((r,n)=>Or(r,n,{...N,slides:t})),N.outline=N.slides.map(r=>r.title),N.activeSlideId=N.slides[0]?.id||"",N.selectedElementId="";else{if(!Array.isArray(e?.slides)||e.slides.length===0)throw new Error("PPT Live deck payload has no slides");N.title=String(e.title||N.title||U("blankDeckTitle")),N.slides=e.slides.map((r,n)=>Or({...r,html:r.html||r.sourceHtml||r.slideHtml||""},n,{...N,slides:e.slides})),N.outline=N.slides.map(r=>r.title),N.activeSlideId=N.slides[0]?.id||"",N.selectedElementId=N.slides[0]?.elements[0]?.id||""}Array.isArray(e.outline)&&e.outline.length&&(N.outline=e.outline.map(String)),e.researchReport&&bf(e.researchReport),e.design?.palette&&typeof e.design.palette=="object"&&(N.deckPalette=e.design.palette)}function bf(e){N.sources={...N.sources,facts:e.verifiedFacts||N.sources?.facts||[],warnings:e.warnings||N.sources?.warnings||[],summary:e.summary||N.sources?.summary||"",fetchedAt:Date.now()}}function cb(e){return Array.isArray(e?.deckPatch?.changes)?e.deckPatch.changes:Array.isArray(e?.patch?.changes)?e.patch.changes:Array.isArray(e?.changes)?e.changes:Array.isArray(e?.patches)?e.patches:[]}function wf(e,t,r=0){let n=String(e?.slideId||e?.id||e?.targetSlideId||e?.targetId||"").trim();if(n){let o=t.findIndex(l=>l.id===n);if(o>=0)return o}let i=Number(e?.slideNumber??e?.pageNumber);if(Number.isFinite(i)&&i>0)return mt(Math.round(i)-1,0,Math.max(0,t.length-1));let a=Number(e?.slideIndex??e?.index??e?.targetSlideIndex);return Number.isFinite(a)?a>=t.length&&a-1>=0&&a-1a.id===r);if(i>=0)return i+1}let n=String(e?.beforeSlideId||"").trim();if(n){let i=t.findIndex(a=>a.id===n);if(i>=0)return i}return e?.afterSlideNumber?mt(Number(e.afterSlideNumber),0,t.length):e?.beforeSlideNumber?mt(Number(e.beforeSlideNumber)-1,0,t.length):e?.slideNumber?mt(Number(e.slideNumber)-1,0,t.length):e?.slideIndex!==void 0?mt(Number(e.slideIndex),0,t.length):Math.min(t.length,$t(N)+1)}function xf(e,t,r,n){let i=e?.slide||e?.replacement||e?.newSlide||e?.payload||e;if(!i||typeof i!="object")return null;let a={...t||{},...i,id:i.id||i.slideId||t?.id||or("html-slide"),html:i.html||i.sourceHtml||i.slideHtml||t?.html||""};return Or(a,r,{...N,slides:n})}function ub(e){let t=cb(e);if(!t.length)return!1;let r=zr(N.slides||[]),n=[],i=0;if(t.forEach(o=>{let l=String(o?.op||o?.operation||o?.type||"replace_slide").toLowerCase();if(l==="delete_slide"||l==="delete"||l==="remove_slide"||l==="remove"){if(!r.length)return;let u=wf(o,r,$t(N)),[f]=r.splice(u,1);f?.id&&n.push(f.id),i+=1;return}if(l==="insert_slide"||l==="insert"||l==="add_slide"||l==="add"){let u=db(o,r),f=xf(o,null,u,r);if(!f)return;r.splice(u,0,f),n.push(f.id),i+=1;return}let c=wf(o,r,$t(N)),s=r[c],d=xf(o,s,c,r);d&&(r[c]=d,n.push(d.id),i+=1)}),!i)throw new Error("PPT Live deck patch had no applicable changes");N.title=String(e.deckPatch?.title||e.patch?.title||e.title||N.title||U("blankDeckTitle")),N.slides=r.map((o,l)=>Or(o,l,{...N,slides:r})),N.outline=Array.isArray(e.outline)&&e.outline.length?e.outline.map(String):N.slides.map(o=>o.title);let a=n.find(o=>N.slides.some(l=>l.id===o));return N.activeSlideId=a||N.slides[Math.min($t(N),N.slides.length-1)]?.id||N.slides[0]?.id||"",N.selectedElementId=Kt(N)?.elements?.[0]?.id||"",!0}function fb(e){let t=[];return Array.isArray(e?.htmlSlides)&&t.push(...e.htmlSlides),Array.isArray(e?.slides)&&t.push(...e.slides.filter(r=>r?.html||r?.sourceHtml||r?.slideHtml)),t.map((r,n)=>{let i=String(r?.html||r?.sourceHtml||r?.slideHtml||"").trim();return i?{id:r.id||r.slideId||or("html-slide"),title:String(r.title||r.label||`${U("newSlideTitle")} ${n+1}`),subtitle:String(r.subtitle||""),kicker:String(r.kicker||""),claim:String(r.claim||r.title||""),proofObject:String(r.proofObject||""),supportNote:String(r.supportNote||""),sourceNote:String(r.sourceNote||""),notes:String(r.notes||""),layout:"html",theme:r.theme||{},html:i,elements:[]}:null}).filter(Boolean)}function Sf(...e){for(let t of e){let r=String(t||"").trim();if(r)try{return Aa(r),r}catch{}}return String(e.find(t=>String(t||"").trim())||"").trim()}async function hb(e,t,r,n=null){let i=yt();if(!t||!r||!i.backend?.turnText)return e;let a=!1,o=Promise.resolve(e).finally(()=>{a=!0}),l=new Promise((c,s)=>{let d=Date.now(),u=300*1e3,f=3600*1e3,h=()=>Number(n?.lastEventAt||d);(async()=>{for(;!a&&Date.now()-du);){try{let A=await i.backend.turnText(t,r),y=String(A?.text||"").trim();if(y)try{Aa(y),c({answer:y,thinking:""});return}catch{}}catch{}await new Promise(A=>setTimeout(A,1e3))}a||s(new Error("PPT Live backend did not publish a final deck JSON"))})()});return Promise.race([o,l])}async function pb(e,t,r,n=""){let i=Date.now(),a=25e3,o=String(r||"").trim(),l=String(n||"").trim(),s=Sf(o,l,`${o} -${l}`.trim());if(s)try{return Aa(s),s}catch{}let d=yt();if(!e||!t||!d.backend?.turnText){if(!s)throw new Error("PPT Live backend produced no text");return s}let u=0;for(;Date.now()-i{setTimeout(()=>A(new Error("turnText timeout")),4e3)})]),h=String(f?.text||"").trim();if(s=Sf(h,s,l,o),s)return Aa(s),s}catch{}await new Promise(f=>setTimeout(f,500))}if(!s)throw new Error("PPT Live backend produced no text");return s}function Aa(e){let t=String(e||"").trim();if(!t)throw new Error("PPT Live backend produced no text");try{return JSON.parse(t)}catch{let r=t.match(/```(?:json)?\s*([\s\S]*?)```/i);if(r)return JSON.parse(r[1]);let n=t.indexOf("{"),i=t.lastIndexOf("}");if(n>=0&&i>n)return JSON.parse(t.slice(n,i+1));throw new Error("PPT Live backend returned invalid JSON")}}function Ab(e){let t=String(e?.message||e||"");return/ppt_live:\/\/round-budget-exhausted|exhausted its \d+-round tool budget|tool budget before producing deck JSON/i.test(t)}function gb(e){return String(e||"").includes("timed out")}function tc(e){let t=String(e||"");return t.includes("dialog-turn-cancelled")||t.includes("Generation stopped")}async function mb(e,t={}){let r=Rn();t.readBrief!==!1&&an({includeTopic:!r});let n=[e,Nf()].filter(Boolean).join(": ");if(!n){jt(U("promptRequired"));return}try{await Mf("revise_slide",n,{includeTopic:!r})}catch(i){if(tc(i))return;yt().log?.warn?.("PPT Live backend slide revision failed",{action:e,error:String(i)}),If(i),await At(!0)}}function Gl(){an({includeTopic:!Rn()}),N.slides=N.slides.map((e,t)=>Or({...e,theme:void 0},t,N)),jt(U("deckRestyled")),qt(),At(!0)}function ql(){an({includeTopic:!Rn()});let e=new Map(N.slides.map(t=>[t.title,t]));N.slides=N.outline.map((t,r)=>{let n=e.get(t);return n?Or(n,r,N):ka(t,r,N.outline.length,N)}),N.activeSlideId=N.slides[0]?.id||"",N.selectedElementId=N.slides[0]?.elements[0]?.id||"",qt(),At(!0)}async function vb(){Bn+=1,await Qo("before-new"),await ec(),N.generation.active=!1,En(!1),N=yb(),ga(),qt(),jt(U("blankDeckReady")),await At(!0)}function yb(){return ln(In())}function bb(e){if(!is.includes(e))return;let t=Kt(N);if(!t)return;let r=ss({...Ca(e),x:10+t.elements.length%5*4,y:14+t.elements.length%5*4});t.elements.push(r),N.selectedElementId=r.id,qt(),At(!0)}function wb(){let e=Kt(N);!e||!N.selectedElementId||(e.elements=e.elements.filter(t=>t.id!==N.selectedElementId),N.selectedElementId=e.elements[0]?.id||"",qt(),At(!0))}function kf(e){let t=e.elements.find(r=>r.type==="text"&&r.text);t&&(e.title=t.text.slice(0,90),N.outline[$t(N)]=e.title,$t(N)===0&&(N.title=e.title))}function Cf(){N.presentIndex=$t(N),Wf(),xe("previewDialog")?.showModal()}function Wf(){let e=N.slides[N.presentIndex]||N.slides[0];xe("presentSlide")&&(xe("presentSlide").innerHTML=e?dn(e):""),xe("presentCounter")&&(xe("presentCounter").textContent=`${Math.max(1,N.presentIndex+1)} / ${Math.max(1,N.slides.length)}`),zn()}function Uo(e){N.presentIndex=mt(N.presentIndex+e,0,N.slides.length-1),Wf()}function xb(){if(!(N.slides||[]).length)return xi(U("exportDeckEmpty")),null;an({includeTopic:!Rn()});let e=Rl(N);return xi(U("exportSavedTo",{path:e})),e}function Sb(){return an({includeTopic:!Rn()}),(N.slides||[]).length?!0:(xi(U("exportDeckEmpty")),!1)}function Gf(e){return{html:{working:U("exportHtmlWorking"),done:U("exportHtmlDone"),failed:U("exportHtmlFailed")},pptx:{working:U("exportPptxWorking"),done:U("exportPptxDone"),failed:U("exportPptxFailed")},pdf:{working:U("exportPdfWorking"),done:U("exportPdfDone"),failed:U("exportPdfFailed")},png:{working:U("exportPngWorking"),done:U("exportPngDone"),failed:U("exportPngFailed")}}[e]||null}function jl(e,t,r){let n=Gf(r==="pptx"?"pptx":r);if(!n||t<=0)return;let i=Math.min(t,Math.max(1,e+1));jo("loading",`${n.working} (${i}/${t})`)}async function Pf(e,t){let r=yt();if(!r?.deck?.renderPage)throw new Error("Host WebView export is unavailable in this runtime.");let n=[],i=e.length;for(let[a,o]of e.entries()){jl(a,i,t);let l=await r.deck.renderPage({html:vs(o),format:t,width:sr.width,height:sr.height});if(!l)throw new Error(`Host WebView returned empty ${t} for slide ${a+1}`);n.push({index:a,base64:String(l).replace(/^data:.*;base64,/,"")})}return n}async function kb(e){if(e==="html"){an({includeTopic:!Rn()});let o=Rl(N);if(!o)throw new Error(U("exportDeckEmpty"));return{filename:o}}let t=N.slides||[];if(!t.length)throw new Error(U("exportDeckEmpty"));let r,n=zr(N);if(e==="pptx")if(t.some(o=>o?.html)){let o=yt(),l=typeof o?.deck?.renderPage=="function"?async(s,d)=>{jl(d,t.length,"pptx");let u=await o.deck.renderPage({html:s,format:"png",width:sr.width,height:sr.height});return String(u||"").replace(/^data:.*;base64,/,"")}:null,c=await Hc(t,{renderRaster:l,onRasterProgress:s=>jl(s,t.length,"pptx")});r=await Dl(n,c)}else r=await Tl(n);else if(e==="pdf"){let o=await Pf(t,"pdf");r=await El(n,o.map(l=>l.base64))}else if(e==="png"){let o=await Pf(t,"png");r=await Bl(n,o)}else throw new Error(U("exportFormatUnavailable"));let i=typeof r?.base64=="string"?r.base64.replace(/^data:.*;base64,/,""):"";if(!i)throw new Error(`export${e} returned no data`);let a=r.filename||`${Ll(N.title||"ppt-live")}`;return af(i,a,r.mimeType||"application/octet-stream"),{filename:a}}var qo=!1,Jt={updateOutline(e,t){N.outline[e]=t,N.slides[e]&&(N.slides[e].title=t),qt(),At(!0)},moveOutline(e,t){let r=e+t;r<0||r>=N.outline.length||([N.outline[e],N.outline[r]]=[N.outline[r],N.outline[e]],ql())},removeOutline(e){N.outline.length<=1||(N.outline.splice(e,1),ql())},selectSlide(e){N.activeSlideId=e,N.selectedElementId=Kt(N)?.elements[0]?.id||"",qt(),At(!0)},selectElement(e){N.selectedElementId=e,cn(N,Jt),Ia(N,Jt),At(!0)},updateElementTextDirect(e,t){let r=Kt(N),n=r?.elements.find(i=>i.id===e);n&&(n.text=String(t||"").trim(),kf(r),On(N,Jt),renderOutline(N,Jt),At(!1))},updateElementListItemDirect(e,t,r){let i=Kt(N)?.elements.find(a=>a.id===e);!i||!Array.isArray(i.items)||(i.items[t]=String(r||"").trim(),i.items=i.items.filter(Boolean),cn(N,Jt),On(N,Jt),At(!1))},updateSlideHtmlDirect(e,t){let r=N.slides.find(i=>i.id===e);if(!r)return;let n=String(t||"");r.html!==n&&(r.html=n,On(N,Jt),At(!1))},updateSlideNotes(e){let t=Kt(N);t&&(t.notes=e),At(!0)},updateSlideMethodology(){let e=Kt(N);e&&(e.kicker=xe("slideKickerInput")?.value||e.kicker,e.claim=xe("slideClaimInput")?.value||e.claim,e.proofObject=xe("slideProofInput")?.value||e.proofObject,e.supportNote=xe("slideSupportInput")?.value||e.supportNote,e.sourceNote=xe("slideSourceInput")?.value||e.sourceNote,cn(N,Jt),On(N,Jt),At(!0))},updateElementFromInspector(){let e=Kt(N),t=Mn(N);!e||!t||(t.text=xe("elementTextInput")?.value||"",t.items=(xe("elementItemsInput")?.value||"").split(` -`).map(r=>r.trim()).filter(Boolean),t.data=Pb(xe("elementDataInput")?.value||""),t.x=mt(Number(xe("elementXInput")?.value??t.x),0,100),t.y=mt(Number(xe("elementYInput")?.value??t.y),0,100),t.w=mt(Number(xe("elementWInput")?.value??t.w),3,100),t.h=mt(Number(xe("elementHInput")?.value??t.h),3,100),t.style.fontSize=mt(Number(xe("elementFontInput")?.value??t.style.fontSize),8,88),t.style.fontWeight=mt(Number(xe("elementWeightInput")?.value??t.style.fontWeight),100,900),t.style.color=xe("elementColorInput")?.value||t.style.color,t.style.background=xe("elementBgInput")?.value||t.style.background,Jt.updateSlideMethodology(),e.notes=xe("slideNotesInput")?.value||e.notes,kf(e),cn(N,Jt),At(!0))},beginDrag(e,t){if(e.button!==0)return;let n=Kt(N)?.elements.find(a=>a.id===t);if(!n)return;N.selectedElementId=n.id;let i=xe("slideCanvas").getBoundingClientRect();Fr={resizing:e.target.classList.contains("resize-handle"),startX:e.clientX,startY:e.clientY,rect:i,start:{x:n.x,y:n.y,w:n.w,h:n.h}},e.currentTarget.setPointerCapture?.(e.pointerId),window.addEventListener("pointermove",qf),window.addEventListener("pointerup",Cb,{once:!0})}};function qf(e){if(!Fr)return;let t=Mn(N);if(!t)return;let r=(e.clientX-Fr.startX)/Fr.rect.width*100,n=(e.clientY-Fr.startY)/Fr.rect.height*100;Fr.resizing?(t.w=mt(Fr.start.w+r,3,100-t.x),t.h=mt(Fr.start.h+n,3,100-t.y)):(t.x=mt(Fr.start.x+r,0,100-t.w),t.y=mt(Fr.start.y+n,0,100-t.h)),cn(N,Jt),Ia(N,Jt)}function Cb(){Fr=null,window.removeEventListener("pointermove",qf),At(!0)}function Pb(e){return e.split(` -`).map((t,r)=>{let[n,i]=t.split(":");return{label:(n||`Item ${r+1}`).trim(),value:Number(i||0)}}).filter(t=>t.label)}function Fb(){let e=document.querySelector(".studio-shell");if(!e)return;let t=document.documentElement,r=Number(Ul("pptLiveFilmstripWidth")||0),n=Number(Ul("pptLiveAgentWidth")||0);r>=128&&r<=360&&t.style.setProperty("--filmstrip-width",`${r}px`),n>=240&&n<=460&&t.style.setProperty("--agent-width",`${n}px`);let i=(a,o)=>{let l=e.getBoundingClientRect(),c=128,s=Math.min(360,l.width*.34),d=240,u=Math.min(460,l.width*.42),f=360,h=A=>{if(a==="filmstrip"){let y=Math.max(c,Math.min(s,A.clientX-l.left));if(l.width-y-parseFloat(getComputedStyle(t).getPropertyValue("--agent-width"))-12{e.classList.remove("is-resizing"),document.querySelectorAll(".panel-resizer.is-dragging").forEach(A=>A.classList.remove("is-dragging")),window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),Wl("pptLiveFilmstripWidth",String(parseFloat(getComputedStyle(t).getPropertyValue("--filmstrip-width"))||"")),Wl("pptLiveAgentWidth",String(parseFloat(getComputedStyle(t).getPropertyValue("--agent-width"))||"")),zn()};e.classList.add("is-resizing"),window.addEventListener("pointermove",h),window.addEventListener("pointerup",p,{once:!0}),window.addEventListener("pointercancel",p,{once:!0}),h({clientX:o})};xe("filmstripResizer")?.addEventListener("pointerdown",a=>{a.button===0&&(a.preventDefault(),a.currentTarget.classList.add("is-dragging"),i("filmstrip",a.clientX))}),xe("agentResizer")?.addEventListener("pointerdown",a=>{a.button===0&&(a.preventDefault(),a.currentTarget.classList.add("is-dragging"),i("agent",a.clientX))})}function Tb(){let e=null,t=()=>{e&&clearTimeout(e),e=setTimeout(()=>{zn()},60)};window.addEventListener("resize",t),xe("toggleHistory")?.addEventListener("click",()=>{let r=xe("historyDrawer");r&&(r.hidden=!r.hidden)}),xe("closeHistory")?.addEventListener("click",()=>{let r=xe("historyDrawer");r&&(r.hidden=!0)}),document.querySelectorAll("[data-sidebar-tab]").forEach(r=>{r.addEventListener("click",()=>{let n=r.dataset.sidebarTab;document.querySelectorAll("[data-sidebar-tab]").forEach(i=>{i.classList.toggle("is-active",i.dataset.sidebarTab===n)}),document.querySelectorAll("[data-sidebar-panel]").forEach(i=>{i.classList.toggle("is-active",i.dataset.sidebarPanel===n)})})}),xe("topicInput")?.addEventListener("input",()=>{if(Rn()){N.promptDraft=xe("topicInput")?.value||"",At(!0);return}an({includeTopic:!0}),At(!0)}),xe("newDeck")?.addEventListener("click",()=>{vb()}),xe("cancelGeneration")?.addEventListener("click",()=>{lb(!1)}),xe("sendPrompt")?.addEventListener("click",()=>{Kl()}),xe("generateOutline")?.addEventListener("click",()=>{Ey()}),xe("generateDeck")?.addEventListener("click",()=>{By()}),xe("addOutlineItem")?.addEventListener("click",()=>{N.outline.push(U("newSlideTitle")),qt(),At(!0)}),xe("syncSlidesFromOutline")?.addEventListener("click",ql),xe("deleteElement")?.addEventListener("click",wb),xe("previewDeck")?.addEventListener("click",Cf),xe("closePreview")?.addEventListener("click",()=>xe("previewDialog")?.close()),xe("prevPresent")?.addEventListener("click",()=>Uo(-1)),xe("nextPresent")?.addEventListener("click",()=>Uo(1)),xe("exportHtml")?.addEventListener("click",xb),xe("restyleDeck")?.addEventListener("click",Gl),document.querySelectorAll("[data-add-element]").forEach(r=>{r.addEventListener("click",()=>bb(r.dataset.addElement))}),document.querySelectorAll(".ai-action").forEach(r=>{r.addEventListener("click",()=>{mb(r.dataset.action)})}),document.querySelectorAll(".segment").forEach(r=>{r.addEventListener("click",()=>{N.mode=r.dataset.mode,N.mode==="present"&&Cf(),qt(),At(!0)})}),document.addEventListener("keydown",r=>{xe("previewDialog")?.open&&((r.key==="ArrowRight"||r.key==="PageDown")&&Uo(1),(r.key==="ArrowLeft"||r.key==="PageUp")&&Uo(-1),r.key==="Escape"&&xe("previewDialog")?.close())});try{Fb()}catch(r){yt().log?.warn?.("Failed to bind PPT Live panel resizers",{error:String(r)})}if(typeof ResizeObserver<"u"){let r=[document.querySelector(".ppt-live"),document.querySelector(".studio-shell"),document.querySelector(".stage-shell"),document.querySelector(".canvas-area")].filter(Boolean),n=new ResizeObserver(t);r.forEach(i=>n.observe(i))}Bb(),Rb(),Lb(),Ob(),Wb()}var rn=1,wi=.25,Db=.25,Eb=2;function fa(e){rn=mt(e,Db,Eb);let t=document.querySelector(".canvas-stage");t&&(t.style.transform=rn===1?"":`scale(${rn})`);let r=xe("zoomValue"),n=xe("statusZoomValue"),i=Math.round(rn*100)+"%";r&&(r.textContent=i),n&&(n.textContent=i)}function Bb(){xe("zoomIn")?.addEventListener("click",()=>fa(rn+wi)),xe("zoomOut")?.addEventListener("click",()=>fa(rn-wi)),xe("statusZoomIn")?.addEventListener("click",()=>fa(rn+wi)),xe("statusZoomOut")?.addEventListener("click",()=>fa(rn-wi)),document.querySelector(".canvas-area")?.addEventListener("wheel",e=>{if(e.ctrlKey||e.metaKey){e.preventDefault();let t=e.deltaY>0?-wi:wi;fa(rn+t)}},{passive:!1})}function Rb(){xe("floatingToolbar")&&document.querySelectorAll(".floating-toolbar-btn").forEach(t=>{t.addEventListener("click",()=>{let r=t.dataset.tool;if(!r)return;let n=Kt(N),i=Mn(N);if(!(!n||!i)){switch(r){case"bold":i.fontWeight=i.fontWeight==="700"?"400":"700";break;case"italic":i.fontStyle=i.fontStyle==="italic"?"normal":"italic";break;case"underline":i.textDecoration=i.textDecoration==="underline"?"none":"underline";break;case"align-left":i.align="left";break;case"align-center":i.align="center";break;case"align-right":i.align="right";break;case"duplicate":n.elements.push({...zr(i),id:or("el"),x:i.x+5,y:i.y+5});break;case"delete":n.elements=n.elements.filter(a=>a.id!==i.id),N.selectedElementId=null;break}cn(N,Jt),On(N,Jt),At(!0)}})})}function Lb(){document.querySelectorAll(".property-section__header").forEach(n=>{let i=n.closest(".property-section");if(!i)return;let a=()=>{i.classList.toggle("is-collapsed");let o=!i.classList.contains("is-collapsed");n.setAttribute("aria-expanded",String(o))};n.addEventListener("click",a),n.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),a())})});let e=xe("densitySlider"),t=e?.querySelector(".density-slider__track");e&&t&&(t.addEventListener("pointerdown",n=>{n.preventDefault(),Qn(mf(n.clientX,t)),t.setPointerCapture(n.pointerId)}),t.addEventListener("pointermove",n=>{t.hasPointerCapture(n.pointerId)&&Qn(mf(n.clientX,t),{save:!1})}),t.addEventListener("pointerup",n=>{t.hasPointerCapture(n.pointerId)&&(t.releasePointerCapture(n.pointerId),At(!0))}),t.addEventListener("pointercancel",n=>{t.hasPointerCapture(n.pointerId)&&(t.releasePointerCapture(n.pointerId),At(!0))}),e.querySelectorAll("[data-density-index]").forEach(n=>{n.addEventListener("click",i=>{i.stopPropagation(),Qn(n.dataset.densityIndex)})}),e.addEventListener("keydown",n=>{let i=xa(N.style.density);n.key==="ArrowLeft"||n.key==="ArrowDown"?(n.preventDefault(),Qn(i-1)):n.key==="ArrowRight"||n.key==="ArrowUp"?(n.preventDefault(),Qn(i+1)):n.key==="Home"?(n.preventDefault(),Qn(0)):n.key==="End"&&(n.preventDefault(),Qn(2))})),document.querySelectorAll("[data-font-family]").forEach(n=>{n.addEventListener("click",()=>{N.style.fontFamily=n.dataset.fontFamily==="serif"?"serif":"sans",document.querySelectorAll("[data-font-family]").forEach(i=>{let a=i===n;i.classList.toggle("is-active",a),i.setAttribute("aria-pressed",a?"true":"false")}),Gl(),At(!0)})}),document.querySelectorAll("[data-color-mode]").forEach(n=>{n.addEventListener("click",()=>{N.style.colorMode=n.dataset.colorMode==="dark"?"dark":"light",document.querySelectorAll("[data-color-mode]").forEach(i=>{let a=i===n;i.classList.toggle("is-active",a),i.setAttribute("aria-pressed",a?"true":"false")}),At(!0)})});let r=xe("stylePresetSelect");r&&(Hf(),bc(r),r.value=N.style?.stylePreset||on,Ci(r),r.addEventListener("change",()=>{let n=r.value;if(n){N.style.stylePreset=n;let i=$o(n);i&&(N.style.colorMode=i.colorMode||"light",N.style.fontFamily=i.fontFamily||"sans",N.style.density=i.density||"standard",document.querySelectorAll("[data-color-mode]").forEach(a=>{let o=a.dataset.colorMode===N.style.colorMode;a.classList.toggle("is-active",o),a.setAttribute("aria-pressed",o?"true":"false")}),document.querySelectorAll("[data-font-family]").forEach(a=>{let o=a.dataset.fontFamily===N.style.fontFamily;a.classList.toggle("is-active",o),a.setAttribute("aria-pressed",o?"true":"false")}),Di(N.style.density)),Gl(),At(!0)}}))}var nn=0;function jf(){return xe("formatGrid")?.querySelector(".format-card.is-selected")?.dataset.format||"pptx"}function Nb(){let e=xe("exportOverlay");e&&(Vf(),nn=Math.max(0,$t(N)),e.classList.add("is-visible"),e.setAttribute("aria-hidden","false"),Ib(),Ko(),requestAnimationFrame(()=>Si()))}function Si(){Ic(xe("exportPreviewFrame"))}function Vf(){let e=xe("exportModalFeedback"),t=xe("exportModalFeedbackText"),r=xe("exportModalSpinner");xe("exportOverlay")?.classList.remove("is-exporting"),e&&(e.hidden=!0,e.classList.remove("is-success","is-error")),t&&(t.textContent=""),r&&(r.hidden=!1),Vl(!1)}function Vl(e){["exportCancel","exportConfirm","closeExport"].forEach(t=>{let r=xe(t);r&&(r.disabled=e)}),xe("formatGrid")?.querySelectorAll(".format-card").forEach(t=>{t.tabIndex=e?-1:0,t.style.pointerEvents=e?"none":""}),["exportPreviewPrev","exportPreviewNext"].forEach(t=>{let r=xe(t);r&&(r.disabled=e)})}function jo(e,t){let r=xe("exportModalFeedback"),n=xe("exportModalFeedbackText"),i=xe("exportModalSpinner");!r||!n||(r.hidden=!1,r.classList.toggle("is-success",e==="success"),r.classList.toggle("is-error",e==="error"),i&&(i.hidden=e!=="loading"),n.textContent=t)}function Vo(){let e=xe("exportOverlay");e&&(e.classList.remove("is-visible"),e.setAttribute("aria-hidden","true"),Vf())}function Ib(){let e=xe("formatGrid");if(!e)return;let t=[{id:"pptx",name:"PPTX",desc:"Editable PowerPoint"},{id:"pdf",name:"PDF",desc:"Universal format"},{id:"html",name:"HTML",desc:"Interactive web deck"},{id:"png",name:"PNG",desc:"Image sequence"}];e.innerHTML=t.map((r,n)=>` +${Dn(e)} +\`\`\``+qy(e)+ti(e)}function $y(e){let t;return e?.phase==="plan"?t=Hy(e):e?.phase==="slides"?t=e?.inSession?_y(e):Ky(e):e?.phase==="repair"?t=Qy(e):e?.phase==="audit"?t=e?.inSession?Zy(e):Yy(e):t=Jy(e),e?.completionRecovery?t=Vy(e.completionRecovery)+t:e?.continueAfterInterruption&&(t=jy+t),t}function eb(e){let t=!1,r=()=>{t||(t=!0,e.agent.onEvent(n=>{!n||typeof n!="object"||Uy(n)}))};e.backend={protocol:"files",async call(n,i,a={}){if(n!=="ppt.generate")throw new Error(`Unsupported PPT Live action: ${n}`);r();let o=$y(i),l=await e.agent.run(o,{runId:a.idempotencyKey,sessionName:"PPT Live",sessionId:a.sessionId,appDataWorkspace:a.appDataWorkspace});if(!l?.sessionId||!l?.turnId)throw new Error("PPT Live agent backend did not return sessionId/turnId");return{sessionId:l.sessionId,turnId:l.turnId,actionRunId:l.actionRunId||l.turnId}},onEvent(n){$l.add(n)},offEvent(n){$l.delete(n)},async cancel(n,i){await e.agent.cancel(n,i)},async turnText(n,i){return{text:(await e.agent.turnText(n,i))?.text||""}},async cancelStaleRuns(){await e.agent.cancelStaleRuns()}}}function Nf(e=window.app){!e||e.backend?.call||e.agent?.run&&eb(e)}var B=On(),En=!1,Rr=null,Ln=[],Nn=0,Ho=!1,wa=!1,ni=[],tc=0,xe=e=>document.getElementById(e),at=()=>window.app||{};Nf(at());var Kf=2500,Jo=new Map;function rc(e){try{return localStorage.getItem(e)}catch{return Jo.has(e)?Jo.get(e):null}}function nc(e,t){try{localStorage.setItem(e,t)}catch{Jo.set(e,t)}}var xa={get:async e=>JSON.parse(rc(e)||"null"),set:async(e,t)=>nc(e,JSON.stringify(t))};function Qf(){let e=at();return e.storage?e.storage:xa}async function Zf(e){let t=Qf();if(t===xa||!at().storage)return t.get(e);try{return await Promise.race([t.get(e),new Promise((r,n)=>setTimeout(()=>n(new Error("storage-timeout")),Kf))])}catch(r){return at().log?.warn?.("Host storage read timed out, using local fallback",{key:e,error:String(r)}),xa.get(e)}}async function is(e,t){let r=Qf();if(r===xa||!at().storage){await r.set(e,t);return}try{await Promise.race([r.set(e,t),new Promise((n,i)=>setTimeout(()=>i(new Error("storage-timeout")),Kf))])}catch(n){at().log?.warn?.("Host storage write timed out, using local fallback",{key:e,error:String(n)}),await xa.set(e,t)}}async function tb(){try{ni=await rb();let e=await Zf(Bi);if(e){B=Un(e),cc(B)&&(B=On(),await is(Bi,{...B,updatedAt:Date.now()}));return}B=On(),await yt(!0)}catch(e){at().log?.warn?.("Failed to load PPT Live state",{error:String(e)}),B=On()}}async function yt(e=!1){B=Un(B),await is(Bi,{...B,updatedAt:Date.now()}),await as(e?"autosave":"manual"),e||Lt(O("saved"))}async function rb(){try{let e=await Zf(vs);return Array.isArray(e)?e.map(Yf).filter(Boolean).slice(0,40):[]}catch(e){return at().log?.warn?.("Failed to load PPT Live history",{error:String(e)}),[]}}async function as(e="autosave"){if(!B?.slides?.length||cc(B))return;let t=Date.now();if(e==="autosave"&&tc&&t-tc<15e3)return;tc=t;let r=Yf({id:B.sessionId||yr("deck"),title:B.title||O("blankDeckTitle"),updatedAt:t,slideCount:B.slides.length,reason:e,prompt:B.promptDraft||B.brief?.topic||"",state:Xr({...B,generation:{...B.generation,active:!1}})});r&&(ni=[r,...ni.filter(n=>n.id!==r.id)].slice(0,40),await is(vs,ni),Jf())}function cc(e){let t=Array.isArray(e?.slides)?e.slides:[];return t.length===1&&!t[0]?.html&&String(t[0]?.id||"").startsWith("agent-working-slide")&&String(e?.title||"")===O("agentWorkingTitle")&&!e?.generation?.active}function Yf(e){return!e?.id||!e?.state?null:{id:String(e.id),title:String(e.title||e.state?.title||O("blankDeckTitle")),updatedAt:Number(e.updatedAt||Date.now()),slideCount:Number(e.slideCount||e.state?.slides?.length||0),reason:String(e.reason||"autosave"),prompt:String(e.prompt||e.state?.brief?.topic||""),state:e.state}}function Jf(){let e=xe("historyList");if(e){if(e.innerHTML="",!ni.length){let t=document.createElement("div");t.className="history-empty",t.textContent=O("historyEmpty"),e.append(t);return}ni.slice(0,12).forEach(t=>{let r=document.createElement("button");r.type="button",r.className=`history-card${t.id===B.sessionId?" is-active":""}`,r.innerHTML=` + ${If(t.title)} + ${O("historyMeta",{count:t.slideCount,time:ib(t.updatedAt)})} + ${t.prompt?`${If(t.prompt)}`:""} + `,r.addEventListener("click",()=>{nb(t.id)}),e.append(r)})}}async function nb(e){let t=ni.find(r=>r.id===e);t&&(Nn+=1,await xc(),B=Un(Xr(t.state)),B.generation.active=!1,Sa(),Mt(),Lt(O("historyRestored")),await is(Bi,{...B,updatedAt:Date.now()}))}function ib(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return`${r}/${n} ${i}:${a}`}function If(e){return String(e??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Lt(e){let t=xe("statusLine");t&&(t.textContent=e)}function Ri(e){let t=xe("exportStatus");t&&(t.textContent=e)}function Bn(e,t){En=e,document.querySelector(".ppt-live")?.classList.toggle("is-busy",En),document.querySelectorAll("button, input, select, textarea").forEach(n=>{if(!["closePreview","prevPresent","nextPresent"].includes(n.id)){if(n.id==="cancelGeneration"){n.disabled=!En,n.hidden=!En;return}n.id!=="newDeck"&&(n.disabled=En)}});let r=xe("aiStatusPill");r&&(r.textContent=En?O("statusPillBusy"):O("statusPillReady"),r.classList.toggle("is-busy",En)),t&&Lt(t)}function Ft(e,t,r){B.generation.current=e,B.generation.steps=B.generation.steps.map(n=>({...n,status:n.id===e?t:n.status})),B.generation.active=t==="running"||B.generation.steps.some(n=>n.status==="running"),Lr(B),Br(B),r&&Lt(r)}function Sa(){B.generation.active=!1,B.generation.current="idle",B.generation.draftedCount=0,B.generation.slideTarget=0,B.generation.eventSeq=0,B.generation.steps=B.generation.steps.map(e=>({...e,status:"pending"})),B.generation.events=[],rh(""),Lr(B),Br(B)}function Et(e,t="",r="info"){B.generation=Ra(B.generation||{});let n=typeof e=="string"?{title:e,detail:t,kind:r}:{...e||{}},i=mr(n.title||n.label||n.message||O("processEventUnknown"),160),a=mr(n.detail??t??"",260),o=String(n.kind||r||"info").toLowerCase().replace(/[^a-z0-9-]/g,"")||"info";if(!i&&!a)return;let l=Array.isArray(B.generation.events)?B.generation.events:[],c=l[l.length-1];if(c&&c.title===i&&c.detail===a&&c.kind===o)c.timestamp=Date.now(),B.generation.events=l;else{let s=l.reduce((u,p)=>Math.max(u,Number(p.seq)||0),0),d=Math.max(Number(B.generation.eventSeq)||0,s)+1;B.generation.eventSeq=d,B.generation.events=[...l,{id:yr("generation-event"),seq:d,title:i||O("processEventUnknown"),detail:a,kind:o,timestamp:Date.now()}].slice(-80)}Lr(B),Br(B)}function Mt(){B=Un(B),Yc(B,Jt),Jf()}function cn(e={}){id(B,e),B=Un(B)}function $f(){return xe("topicInput")?.value.trim()||""}function dc(){let e=Bc().join(` +`);return!B.outline.length||B.outline.join(` +`)===e||B.title===O("defaultDeckTitle")||os()}function os(){let e=String(B.title||"").trim();return B.slides.length===1&&B.outline.length===1&&B.outline[0]===O("newSlideTitle")&&(e===O("blankDeckTitle")||e===O("newSlideTitle"))}function In(){return Array.isArray(B.slides)&&B.slides.length>0&&!dc()&&!os()&&!cc(B)}async function ab(){await uc()}async function ob(){await uc()}async function uc(){if(Ho||wa)return;let e=$f();if(!e){Lt(O("promptRequired"));return}Ho=!0;let t=In();B.promptDraft=e,B.lastSubmittedPrompt=e,cn({includeTopic:!t}),t||(B.brief.topic=e);try{await yc("auto",e,{includeTopic:!t});return}catch(r){if(us(r))return;at().log?.warn?.("PPT Live backend generation failed",{error:String(r)}),hc(r),Mt(),await yt(!0)}finally{Ho=!1}}function fc(e=O("deckReady")){B.generation.active=!1,B.generation.draftedCount=B.slides.length,B.generation.slideTarget=0,B.generation.steps=(B.generation.steps||[]).map(t=>({...t,status:t.status==="error"?"error":"done"})),Lt(e),Lr(B),Br(B)}function sb(e=O("backendGenerationFailed"),t=""){B.generation.active=!1,B.generation.steps=(B.generation.steps||[]).map(r=>({...r,status:r.status==="done"?"done":"error"})),Lt(e),Et({title:e,detail:t||O("agentOnlyRetryHint"),kind:"error"}),Bn(!1),Lr(B),Br(B)}function lb(e,t=5){let r=[],n=new Set,i=e;for(let a=0;i&&a({kind:n.kind,title:n.title,url:n.url,text:String(n.text||"").slice(0,6e3)}))}:null);let r=Number(B.brief?.slideTarget)||0;return r>0&&(t.slideTarget=r),t}function dn({includePreset:e=!0}={}){let t=ps(B.style?.stylePreset),r=B.style?.colorMode==="dark"?"dark":"light",n={fontFamily:B.style?.fontFamily==="serif"?"serif":"sans",density:zn(B.style?.density),colorMode:r,theme:r,palette:Cc(t,r)};return e&&(n.stylePreset=B.style?.stylePreset||un),n}function $o(e={}){let t=dn();return{...e.style||{},...t}}function es(e={}){let t=dn();return{...e.design||{},theme:t.colorMode==="dark"?"dark":"light",palette:{...e.design?.palette||{},...t.palette}}}function ts(e={}){let t=dn();return{...e.generationContract||{},userStyle:t}}function cb(e){let t=String(e||"").trim();if(!t)return"";try{let r=new DOMParser().parseFromString(t,"text/html");return r.querySelectorAll("style,script,svg").forEach(n=>n.remove()),mr(r.body?.textContent||r.documentElement?.textContent||"",1800)}catch{return mr(t.replace(/<[^>]+>/g," "),1800)}}function db(e){let t=new Set,r=String(e||""),n=er(B);return/(当前|本页|这一页|此页|current\s+(slide|page)|this\s+(slide|page))/i.test(r)&&t.add(n),[/第\s*(\d{1,2})\s*(页|頁|张|張)/gi,/\b(?:slide|page)\s*(\d{1,2})\b/gi,/\b(\d{1,2})\s*(?:slide|slides|page|pages)\b/gi].forEach(a=>{let o=a.exec(r);for(;o;){let l=Number(o[1])-1;l>=0&&la-o)}function ub(e){let t=db(e),r=er(B),n=new Set(t.length?t:[r]);return{title:B.title,outline:Xr(B.outline||[]),slideCount:B.slides.length,activeSlideIndex:r,activeSlideId:B.slides[r]?.id||"",targetHints:t.map(i=>({slideIndex:i,slideNumber:i+1,slideId:B.slides[i]?.id||"",title:B.slides[i]?.title||""})),slides:B.slides.map((i,a)=>{let o=i.html?cb(i.html):mr((i.elements||[]).flatMap(c=>[c.text,c.label,...Array.isArray(c.items)?c.items:[]]).filter(Boolean).join(` +`),1800),l={slideIndex:a,slideNumber:a+1,id:i.id,title:i.title,kicker:i.kicker,claim:i.claim,proofObject:i.proofObject,supportNote:i.supportNote,sourceNote:i.sourceNote,notes:i.notes,layout:i.layout,visibleText:o,hasHtml:!!i.html};return n.has(a)&&i.html&&(l.html=String(i.html).slice(0,12e3)),l})}}function Mf(e,t){let r=t.getBoundingClientRect(),n=mt((e-r.left)/r.width,0,1);return Math.round(n*2)}function ri(e,{save:t=!0}={}){let r=mt(Math.round(Number(e)),0,2);B.style.density=Rc(r),Oi(B.style.density),Mt(),t&&yt(!0)}var $t=4,ln=8,sn=$t+ln,fb=!1,hb=750;function ss(e){let t=e>$t;return{continuation:t,continuationAttempt:t?e-$t:0}}function Ac(e,t,r,n=[]){let i=ss(t);return i.continuation?{stage:e,attempt:i.continuationAttempt,maxAttempts:ln,previousFailure:gr(r),issues:[...new Set((n||[]).map(String).filter(Boolean))]}:null}function gc(e,t,r=[],n={}){let i=[...new Set(r.map(c=>gr(c)).filter(Boolean))],o=gr(t)||i.at(-1)||"The Agent did not produce the required artifact.",l=new Error(`PPT Live recovery exhausted after ${$t} stage attempts and ${ln} continuation turns. Last verified reason: ${o}`,{cause:t||void 0});return l.pptLiveRecoveryExhausted={stageKey:e,stageVars:n,stepAttempts:$t,continuationAttempts:ln,reasons:i},l}var mc=new Map,eh="";function th(e){let t=String(e||""),r=0;for(let n=0;n({...c,slideNumber:bc(c,s+1),slideId:String(c?.slideId||`slide-${String(s+1).padStart(2,"0")}`)})),n=dn(),i=pc(),a=r.map(c=>({id:c.slideId,title:String(c.title||""),bullets:Array.isArray(c.bullets)?c.bullets.map(String):[],slide_id:c.slideId})),o=Array.isArray(e?.showcaseSlideNumbers)?e.showcaseSlideNumbers.map(Number):[],l=[...new Set(o)].filter(c=>Number.isInteger(c)&&c>=1&&c<=r.length).slice(0,2);if(r.length>=5&&l.length<2){for(let c of[1,Math.min(3,r.length),r.length])if(l.includes(c)||l.push(c),l.length===2)break}return{...e,outline:a,slide_order:a.map(c=>c.slide_id),style:n,design:{...e?.design||{},theme:n.colorMode==="dark"?"dark":"light",palette:{...e?.design?.palette||{},...n.palette}},assumptions:Array.isArray(e?.assumptions)?e.assumptions.map(String):(e?.researchReport?.assumptions||[]).map(String),generationContract:{...e?.generationContract||{},version:1,skillKey:ir,skillName:"ppt-design",requiredReferences:lh(n),deliveryTarget:"editable-pptx",userPrompt:String(t||""),userBrief:i,userStyle:n,hardRules:vb,visualGrammar:{...e?.generationContract?.visualGrammar||{},...e?.design?.renderGuide||{}}},showcaseSlideNumbers:r.length>=5?l:[],slidePlans:r}}async function bb(e,t){let r=at().fs;!e||!r?.writeFile||await r.writeFile(`${e.dir}/project.json`,`${JSON.stringify(t,null,2)} +`)}async function vc(e,t){let r=at().fs;if(!r?.readFile)throw new Error("PPT Live fs API is unavailable");return await r.readFile(`${e.dir}/${t}`)}async function wb(e,t){try{let r=String(await vc(e,t)||"");return r.trim()?ii(r):null}catch{return null}}async function xb(e,t){try{let r=String(await vc(e,t)||"");if(!r.trim())return{status:"empty",value:null,reason:`${t} exists but is empty.`};try{return{status:"valid",value:ii(r),reason:""}}catch(n){return{status:"invalid",value:null,reason:`${t} is not valid JSON: ${gr(n)||"parse failed"}.`}}}catch(r){return{status:"missing",value:null,reason:`${t} was not created or could not be read: ${gr(r)||"file unavailable"}.`}}}async function Sb(e){return await wb(e,"project.json")}async function rs(e,t){try{let r=String(await vc(e,mb(t))||"").trim();return!r||!/<\/html>\s*$/i.test(r)?null:r}catch{return null}}function ic(e){return e?.params&&typeof e.params=="object"?e.params:{}}function Cb(e){let t=String(e||"").trim();return t===ir||t==="ppt-design"}function kb(e){if(!e||String(e.toolName||"").toLowerCase()!=="skill")return!1;let t=e.result||{};return!!(JSON.stringify(t).includes(ir)||t?.success===!0&&String(t?.skill_name||"").toLowerCase()==="ppt-design")}function ch(e,t){let r=(e||[]).filter(s=>s.eventType==="Started"),n=(e||[]).filter(s=>s.eventType==="Completed"),i=new Map(n.filter(s=>s.toolId).map(s=>[s.toolId,s])),a=[],o=r.filter(s=>String(s.toolName||"").toLowerCase()==="skill"&&Cb(ic(s).command)),l=o.some(s=>kb(i.get(s.toolId)));(!o.length||!l)&&a.push(`The exact built-in Skill key ${ir} was not successfully loaded.`);let c=r.filter(s=>String(s.toolName||"").toLowerCase()==="read"&&i.has(s.toolId)).map(s=>{let d=ic(s);return String(d.file_path||d.path||"")});return lh(t).forEach(s=>{c.some(d=>d.endsWith(s))||a.push(`Required reference was not read: ${s}`)}),a}function Pb(e){let t=Array.isArray(e)?e:[],r=t.filter(o=>{if(o.eventType!=="Started")return!1;let l=String(o.toolName||"").toLowerCase(),c=ic(o),s=String(c.file_path||c.path||"");return(l==="write"||l==="filewrite")&&s.endsWith("quality-report.json")});if(!r.length)return["The Agent turn ended without calling Write for quality-report.json."];let n=new Map(t.filter(o=>o.toolId&&["Completed","Failed","Cancelled"].includes(o.eventType)).map(o=>[o.toolId,o]));if(r.some(o=>n.get(o.toolId)?.eventType==="Completed"))return[];let a=r.map(o=>n.get(o.toolId)).find(o=>o?.eventType==="Failed"||o?.eventType==="Cancelled");return a?[`The quality-report.json Write tool did not complete: ${gr(a.error)||a.eventType}.`]:["The quality-report.json Write tool started but no completion event was observed."]}function Fb(e){if(!e)return"";let t=String(e.finishReason||"").trim(),r=String(e.partialRecoveryReason||"").trim();return e.success===!1?`The Agent turn reported success=false${t?` (${t})`:""}.`:r?`The Agent turn ended after partial recovery: ${r}.`:t&&!["complete","completed","final_answer"].includes(t.toLowerCase())?`The Agent turn stopped with finish reason "${t}".`:""}async function dh(e){let t=at().fs;if(!(!t?.readdir||!t?.rm))try{let r=`${at().appDataDir}/decks`,n=await t.readdir(r),i=(Array.isArray(n)?n:[]).map(a=>typeof a=="string"?a:a?.name).filter(a=>typeof a=="string"&&a.startsWith("deck-")&&a!==e);for(let a of i)await t.rm(`${r}/${a}`,{recursive:!0})}catch{}}async function yc(e,t,r={}){if(!at().backend?.call)throw new Error("PPT Live backend is unavailable");if(!wa){wa=!0;try{if(cn({includeTopic:r.includeTopic!==!1}),e==="auto"&&(dc()||os())){await Nb(e,t);return}await Tb(e,t)}finally{wa=!1}}}async function Tb(e,t){let r=null,n=gb()||(ah()?oh():null);n&&!B.agentSession?.workspaceSubdir&&await dh(n.runId);let i={id:B.agentSession?.id||null,project:n};for(let a=1;a<=$t;a+=1)try{await Eb(e,t,a,i);return}catch(o){if(r=o,ds(o)?i.id=null:o?.pptLiveSessionId&&(i.id=o.pptLiveSessionId),!ls(o)||a>=$t)throw o;at().log?.warn?.("PPT Live backend attempt failed, retrying",{attempt:a,maxAttempts:$t,continueInSession:!!i.id,error:String(o)}),Et({title:O("generationRetrying",{attempt:a+1,max:$t}),detail:gr(o),kind:"error"}),Lt(O("generationRetrying",{attempt:a+1,max:$t})),await new Promise(l=>setTimeout(l,cs(o,a)))}if(r)throw r}async function Ca(e,t={},r={}){let n=at(),i=Nn,a=null,o=null,l="",c="",s=!1,d=0,u=null,p=[],f=new Set,h=[],A=zb(),v={lastEventAt:Date.now()};try{let g=await n.backend.call("ppt.generate",e,{entityId:"deck",idempotencyKey:`ppt-live-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,sessionId:r.sessionId||void 0,appDataWorkspace:r.appDataWorkspace||void 0});if(a=g?.sessionId||null,o=g?.turnId||g?.actionRunId||null,!a||!o)throw new Error("PPT Live backend did not return sessionId/turnId");if(_b(a,o),Rn(i))throw new Error("Generation stopped");let b=new Promise((T,G)=>{let V=q=>{if(q.sessionId!==a||q.turnId&&q.turnId!==o)return;v.lastEventAt=Date.now();let y=String(q.sourceEvent||"");if(y.endsWith("dialog-turn-started"))A.note(O("eventTurnStarted"),"","turn");else if(y.endsWith("model-round-started"))t.onToolPhase?.("round"),A.touch();else if(y.endsWith("model-round-completed"))A.touch();else if(y.endsWith("tool-event")){let M=wc(q.toolEvent||{}),ne=M.event_type||M.eventType||"";if(ne==="Started"?h.push({eventType:ne,toolId:M.tool_id||M.toolId||"",toolName:M.tool_name||M.toolName||"",params:M.params||{}}):ne==="Completed"?h.push({eventType:ne,toolId:M.tool_id||M.toolId||"",toolName:M.tool_name||M.toolName||"",result:M.result||{}}):(ne==="Failed"||ne==="Cancelled")&&h.push({eventType:ne,toolId:M.tool_id||M.toolId||"",toolName:M.tool_name||M.toolName||"",error:M.error||M.message||ne}),Mb(M,f)&&(Et(Xb(q)),A.touch()),ne==="EarlyDetected"||ne==="Started")t.onToolPhase?.("detected");else if(ne==="Completed"){let _=String(M.tool_name||M.toolName||"").trim().toLowerCase();t.onToolPhase?.("completed"),_==="skill"?A.note(O("eventToolSkillReady"),ph(M.tool_name||M.toolName),"phase"):(_==="websearch"||_==="webfetch")&&t.onToolPhase?.("research")}}else if(y.endsWith("text-chunk")){let M=String(q.text||"");if(q.contentType==="thinking")c+=M;else{l+=M,A.touch();let _=Date.now();_-d>=500&&(d=_,t.onTextProgress?.(l))}}else if(!y.endsWith("token-usage-updated")){if(y.endsWith("dialog-turn-completed"))s=!0,u={success:q.success,finishReason:q.finishReason||q.finish_reason||"",partialRecoveryReason:q.partialRecoveryReason||q.partial_recovery_reason||""},T({answer:l,thinking:c});else if(y.endsWith("dialog-turn-failed")||y.endsWith("dialog-turn-cancelled")){s=!0,l&&t.onTextProgress?.(l);let M=mr(q.error||q.message||"");Et({title:y.endsWith("dialog-turn-cancelled")?O("eventTurnCancelled"):O("eventTurnFailed"),detail:M,kind:"error"}),G(new Error(M||y))}}};n.backend.onEvent(V),p.push(()=>n.backend.offEvent?.(V));let C=setInterval(()=>{if(s||Date.now()-A.lastProgressLogAt<12e3)return;let y=(B.generation?.steps||[]).find(M=>M.status==="running");A.note(y?.label?`${y.label}\u2026`:O("generationProgressPulse"),y?.detail||"","pulse",0)},12e3);p.push(()=>clearInterval(C))}),x=r.resultKind!=="text",S=await t1(b,a,o,v,{expectJson:x}),F=typeof S=="string"?S:S?.answer||"",N=typeof S=="string"?"":S?.thinking||"";if(Rn(i))throw new Error("Generation stopped");if(!x)return{payload:null,text:F,sessionId:a,toolTrace:h,completion:u};let L=await r1(a,o,F,N);if(Rn(i))throw new Error("Generation stopped");let D=ii(L);if(Rn(i))throw new Error("Generation stopped");return{payload:D,sessionId:a,toolTrace:h,completion:u}}catch(g){if(g&&typeof g=="object"&&a&&(g.pptLiveSessionId=a,g.pptLiveToolTrace=h),!s&&a&&o&&n.backend?.cancel)try{await n.backend.cancel(a,o)}catch(b){at().log?.warn?.("PPT Live backend cancel after failure failed",{sessionId:a,turnId:o,error:String(b)})}throw g}finally{p.forEach(g=>g()),a&&o&&Kb(a,o)}}function uh(e,t){return{operation:e,instruction:t,locale:lr(),brief:pc(),style:dn()}}function Db(e){return{operation:e,locale:lr(),brief:pc({includeEvidence:!1}),style:dn({includePreset:!1})}}async function Eb(e,t,r=1,n={id:null}){let i=Nn;Bn(!0,O("working")),Sa(),Ft("brief","running",O("generationReadingBrief")),Et({title:O("processEventStarted"),detail:O("processEventWaiting"),kind:"start"}),r>1&&Et({title:O("generationRetryAttempt",{attempt:r,max:$t}),detail:"",kind:"start"}),hh(e,t);let a=!1,o={value:""},l={touch:()=>{},note:()=>{},lastProgressLogAt:0};try{let{payload:c,sessionId:s}=await Ca({...uh(e,t),title:B.title,outline:Xr(B.outline),currentSlideIndex:er(B),currentDeck:ub(t),...n?.id?{continueAfterInterruption:!0}:{}},{onToolPhase:d=>{d==="detected"?Ft("brief","running",O("generationReadingBrief")):d==="completed"?(Ft("brief","done"),Ft("spine","running",O("generationWritingClaims"))):d==="research"?Ft("proof","running",O("generationChoosingProof")):d==="round"&&Ft("spine","running",O("generationWritingClaims"))},onTextProgress:d=>Vb(d,l,o)},{sessionId:n?.id||void 0,appDataWorkspace:n?.project?.workspaceSubdir});n.id=s||n.id,B.agentSession={id:n.id||"",workspaceSubdir:n?.project?.workspaceSubdir||"",runId:n?.project?.runId||"",skillKey:ir},Et({title:O("generationParsingDeck"),detail:"",kind:"parsing"}),Lt(O("generationParsingDeck")),_o(c),await as(`agent:${e}`),Et({title:O("processEventDone"),detail:"",kind:"done"}),Ft("spine","done"),Ft("proof","done"),Ft("design","done"),Ft("compile","done",O("generationCompiled")),fc(O("deckReady")),a=!0,Mt(),await yt(!0)}finally{!Rn(i)&&(B.generation.active&&!a&&(B.generation.active=!1),Bn(!1)),Lr(B),Br(B)}}function bc(e,t){let r=Number(e?.slideNumber);return Number.isFinite(r)&&r>0?Math.round(r):t}function fh(e){return Array.isArray(e?.slidePlans)?e.slidePlans.filter(t=>t&&typeof t=="object"):[]}async function Rb(e,t,r=null){let n=null,i=null,a=[],o=[],l=[];for(let c=1;c<=sn;c+=1)try{let s=ss(c);c>1&&(Et({title:s.continuation?O("generationRecoveryContinuing",{stage:O("generationStagePlanning"),attempt:s.continuationAttempt,max:ln}):O("generationPlanRetry",{attempt:c,max:$t}),detail:l.join(" ")||gr(n),kind:"error"}),Lt(s.continuation?O("generationRecoveryContinuing",{stage:O("generationStagePlanning"),attempt:s.continuationAttempt,max:ln}):O("generationPlanRetry",{attempt:c,max:$t})),await new Promise(A=>setTimeout(A,cs(n,c))));let d=Ac("plan",c,n,l),u=await Ca({...uh(e,t),phase:"plan",title:B.title,outline:[],...l.length?{complianceIssues:l}:{},...c>1&&!d&&i?{continueAfterInterruption:!0}:{},...d?{completionRecovery:d}:{}},{onToolPhase:A=>{A==="detected"?Ft("brief","running",O("generationReadingBrief")):A==="completed"||A==="round"?(Ft("brief","done"),Ft("spine","running",O("generationWritingClaims"))):A==="research"&&Ft("proof","running",O("generationChoosingProof"))},onTextProgress:A=>{if(!A.includes('"slidePlans"'))return;let v=(A.match(/"slideNumber"/g)||[]).length;v>0?(Ft("proof","running",O("generationPlanProgress",{count:v})),Lt(O("generationPlanProgress",{count:v}))):Ft("proof","running",O("generationPlanningSlides"))}},{sessionId:i||void 0,appDataWorkspace:r?.workspaceSubdir,resultKind:r?"text":void 0});i=u.sessionId||i,a.push(...u.toolTrace||[]);let p=r?await Sb(r):u.payload;if(r&&!p)throw new Error("PPT Live plan turn finished without a valid project.json");if(l=ch(a,dn()),l.length){let A=new Error(`PPT Live planning compliance failed: ${l.join(" ")}`);throw A.pptLivePlanCompliance=!0,A.pptLiveSessionId=u.sessionId||i||null,A}let f=yb(p,t),h=fh(f);if(!h.length)throw new Error("PPT Live plan phase returned no slidePlans");return await bb(r,f),{payload:f,slidePlans:h,sessionId:u.sessionId||i||null,project:r}}catch(s){if(n=s,o.push(s),Array.isArray(s?.pptLiveToolTrace)&&a.push(...s.pptLiveToolTrace),ds(s)?i=null:s?.pptLiveSessionId&&(i=s.pptLiveSessionId),!ls(s))throw s;if(c>=sn)throw gc("generationStagePlanning",s,o);at().log?.warn?.("PPT Live plan phase failed, retrying",{attempt:c,maxAttempts:sn,continueInSession:!!i,error:String(s)})}throw n}async function ac({operation:e,planContext:t,slidePlan:r,slideNumber:n,session:i,project:a,html:o}){let l=o,c=2;if(ih(n,l))return{html:l,quality:{score:100,issues:[]}};for(let s=0;s<=c;s+=1){let d=await Ad(l);if(d.valid)return pb(n,l),{html:l,quality:{score:100,issues:[]}};if(s>=c)throw new Error(`PPT Live slide ${n} failed editable-PPTX validation: ${d.issues.map(p=>p.message).join(" ")}`);Et({title:O("generationSlideRepair",{slide:n,attempt:s+1,max:c}),detail:mr(d.issues.map(p=>p.message).join(" "),260),kind:"error"});let u=await Ca({operation:e,locale:lr(),phase:"repair",assignedSlide:r,validationIssues:d.issues,generationContract:ts(t),design:es(t),style:$o(t)},{},{sessionId:i?.id||void 0,appDataWorkspace:a?.workspaceSubdir,resultKind:"text"});if(i&&u.sessionId&&(i.id=u.sessionId),l=await rs(a,n),!l)throw new Error(`PPT Live repair turn did not rewrite slide ${n}`)}throw new Error(`PPT Live slide ${n} validation did not finish`)}async function Lb({operation:e,planContext:t,slidePlan:r,slideNumber:n,session:i,project:a}){let o=null,l=[],c=(s,d={score:100,issues:[]})=>({...r,html:s,quality:d,id:`ppt-live-slide-${n}`,slideNumber:n});for(let s=1;s<=sn;s+=1)try{let d=ss(s);if(s>1){if(a){let b=await rs(a,n);if(b){let x=await ac({operation:e,planContext:t,slidePlan:r,slideNumber:n,session:i,project:a,html:b});return c(x.html,x.quality)}}Et({title:d.continuation?O("generationRecoveryContinuing",{stage:O("generationStageSlide",{slide:n}),attempt:d.continuationAttempt,max:ln}):O("generationSlideRetry",{slide:n,attempt:s,max:$t}),detail:gr(o),kind:"error"}),Lt(d.continuation?O("generationRecoveryContinuing",{stage:O("generationStageSlide",{slide:n}),attempt:d.continuationAttempt,max:ln}):O("generationSlideRetry",{slide:n,attempt:s,max:$t})),await new Promise(b=>setTimeout(b,cs(o,s)))}let u=Ac("slides",s,o,o?[gr(o)]:[]),f=!!i?.id?{operation:e,locale:lr(),phase:"slides",inSession:!0,assignedSlides:[r],generationContract:ts(t),design:es(t),style:$o(t),showcaseSlideNumbers:t.showcaseSlideNumbers,...s>1&&!u?{continueAfterInterruption:!0}:{},...u?{completionRecovery:u}:{}}:{...Db(e),phase:"slides",plan:{...t,style:$o(t),design:es(t),generationContract:ts(t)},assignedSlides:[r],...u?{completionRecovery:u}:{}},h=await Ca(f,{},{sessionId:i?.id||void 0,appDataWorkspace:a?.workspaceSubdir,resultKind:a?"text":void 0});i&&h.sessionId&&(i.id=h.sessionId);let{payload:A}=h;if(a){let b=await rs(a,n);if(!b)throw new Error(`PPT Live slide ${n} file is missing or incomplete`);let x=await ac({operation:e,planContext:t,slidePlan:r,slideNumber:n,session:i,project:a,html:b});return c(x.html,x.quality)}let v=Array.isArray(A?.slides)?A.slides:[],g=v.find(b=>bc(b,NaN)===n)||v[0];if(!g||typeof g!="object"||!String(g.html||"").trim())throw new Error(`PPT Live slide ${n} is missing complete HTML`);return{...g,id:g.id||`ppt-live-slide-${n}`,slideNumber:n}}catch(d){if(o=d,l.push(d),i&&ds(d)&&(i.id=null,at().log?.warn?.("PPT Live planning session lost, falling back to standalone render turns",{slide:n})),!ls(d))throw d;if(s>=sn)throw gc("generationStageSlide",d,l,{slide:n});at().log?.warn?.("PPT Live slide render failed, retrying page",{slide:n,attempt:s,maxAttempts:sn,continueInSession:!!i?.id,error:String(d)})}throw o}async function Bb({operation:e,planContext:t,slidePlans:r,session:n,project:i}){let a=!1,o=null,l=null,c=[],s=[];for(let p=1;p<=sn;p+=1)try{let f=ss(p);if(p>1){let S=f.continuation?O("generationRecoveryContinuing",{stage:O("generationStageAudit"),attempt:f.continuationAttempt,max:ln}):O("generationAuditRetry",{attempt:p,max:$t});Et({title:S,detail:c.join(" ")||gr(o),kind:"error"}),Lt(S),await new Promise(F=>setTimeout(F,cs(o,p)))}let h=Ac("audit",p,o,c),A=await Ca({operation:e,locale:lr(),phase:"audit",inSession:!!n?.id,generationContract:ts(t),design:es(t),style:$o(t),slideOrder:t.slideOrder,slidePlans:r,...c.length?{auditIssues:c}:{},...h?{completionRecovery:h}:{}},{},{sessionId:n?.id||void 0,appDataWorkspace:i?.workspaceSubdir,resultKind:"text"});if(n&&A.sessionId&&(n.id=A.sessionId),!n?.id){let S=ch(A.toolTrace,t.style);if(S.length)throw new Error(`PPT Live final audit compliance failed: ${S.join(" ")}`)}let v=await xb(i,"quality-report.json");l=v.value;let g=new Set(Array.isArray(l?.checkedSlides)?l.checkedSlides.map(String):[]),b=(t.slideOrder||[]).map(String).filter(S=>!g.has(S)),x=[];if(v.status!=="valid"?x.push(v.reason):l?.status!=="passed"&&x.push(`quality-report.json status is "${String(l?.status||"missing")}", not "passed".`),b.length&&x.push(`quality-report.json did not confirm these slide ids: ${b.join(", ")}.`),x.length){x.push(...Pb(A.toolTrace));let S=Fb(A.completion);S&&x.push(S);let F=mr(A.text||"",180);F&&x.push(`Agent reply: ${F}`);let N=new Error(`PPT Live final audit verification failed: ${x.join(" ")}`);throw N.pptLiveAuditIssues=x,N}a=!0;break}catch(f){if(o=f,s.push(f),c=Array.isArray(f?.pptLiveAuditIssues)?f.pptLiveAuditIssues:[gr(f)].filter(Boolean),n&&ds(f)&&(n.id=null),!ls(f))throw f;if(p>=sn)throw gc("generationStageAudit",f,s);at().log?.warn?.("PPT Live final deck audit failed, retrying",{attempt:p,maxAttempts:sn,continueInSession:!!n?.id,error:String(f)})}if(!a)throw o||new Error("PPT Live final audit did not finish");let d=new Set(Array.isArray(l?.fixedSlides)?l.fixedSlides.map(String):[]),u=[];for(let p of r){let f=p.slideNumber,h=await rs(i,f);if(!h)throw new Error(`PPT Live final audit lost slide ${f}`);let A=Ab(p,f);if(!d.has(A)&&ih(f,h)){u.push({...p,id:`ppt-live-slide-${f}`,slideNumber:f,html:h,quality:{score:100,issues:[]}});continue}let v=await ac({operation:e,planContext:t,slidePlan:p,slideNumber:f,session:n,project:i,html:h});u.push({...p,id:`ppt-live-slide-${f}`,slideNumber:f,html:v.html,quality:v.quality})}return u}async function Nb(e,t){let r=Nn;Bn(!0,O("working")),Sa(),Ft("brief","running",O("generationReadingBrief")),Et({title:O("processEventStarted"),detail:O("processEventWaiting"),kind:"start"}),Et({title:O("generationPlanPhase"),detail:"",kind:"phase"}),hh(e,t);let n=!1,i=ah()?oh():null;i&&(rh(i.runId),await dh(i.runId));try{let{payload:a,slidePlans:o,sessionId:l}=await Rb(e,t,i);if(Rn(r))throw new Error("Generation stopped");Ft("brief","done"),Ft("spine","done"),Ft("proof","done"),Ft("design","running",O("generationDesigningLayouts")),B.generation.slideTarget=o.length,B.generation.draftedCount=0,Et({title:O("generationPlanReady",{count:o.length}),detail:mr(zf(a).join(" / "),200),kind:"phase"}),a.title&&(B.title=String(a.title),Mt());let c={id:l||null};B.agentSession={id:c.id||"",workspaceSubdir:i?.workspaceSubdir||"",runId:i?.runId||"",skillKey:ir};let s={title:a.title||"",language:a.language||"",outline:a.outline||[],researchReport:a.researchReport||"",design:a.design||{},style:a.style||dn(),generationContract:a.generationContract||{},showcaseSlideNumbers:a.showcaseSlideNumbers||[],slideOrder:a.slide_order||[]},d=o.map((v,g)=>({...v,slideNumber:bc(v,g+1)})),u=new Set(s.showcaseSlideNumbers),p=[...d.filter(v=>u.has(v.slideNumber)),...d.filter(v=>!u.has(v.slideNumber))];Et({title:O("generationSlidesPhase",{count:d.length}),detail:"",kind:"phase"});let f=[];for(let v of p){if(Rn(r))throw new Error("Generation stopped");let g=v.slideNumber;Ft("design","running",O("generationRenderingSlide",{slide:g,total:d.length})),Lt(O("generationRenderingSlide",{slide:g,total:d.length}));try{let x=await Lb({operation:e,planContext:s,slidePlan:v,slideNumber:g,session:c,project:i});f.push(x)}catch(x){if(!f.length)throw x;let S=[...f].sort((D,T)=>D.slideNumber-T.slideNumber);_o({title:a.title,language:a.language,outline:[],researchReport:a.researchReport,design:a.design,slides:S}),B.activeSlideId=B.slides[B.slides.length-1]?.id||B.activeSlideId,B.selectedElementId="",Mt(),await yt(!0);let F=new Set(f.map(D=>D.slideNumber)),N=d.filter(D=>!F.has(D.slideNumber)).map(D=>D.slideNumber),L=new Error(O("generationPartialDeck",{missing:N.join(", ")}));throw L.pptLivePartialDeck=!0,L.cause=x,x?.pptLiveRecoveryExhausted&&(L.pptLiveRecoveryExhausted=x.pptLiveRecoveryExhausted),L}B.generation.draftedCount=f.length,Ft("design","running",O("generationSlideReady",{slide:g,total:d.length})),Et({title:O("generationSlideReady",{slide:g,total:d.length}),detail:"",kind:"slide"});let b=[...f].sort((x,S)=>x.slideNumber-S.slideNumber);_o({title:a.title,language:a.language,outline:b.map(x=>x.title||""),researchReport:a.researchReport,design:a.design,slides:b}),B.activeSlideId=`ppt-live-slide-${g}`,B.selectedElementId="",Mt()}let A=[...f].sort((v,g)=>v.slideNumber-g.slideNumber);fb&&(Et({title:O("generationAuditPhase"),detail:"",kind:"phase"}),Ft("design","running",O("generationAuditPhase")),Lt(O("generationAuditPhase")),A=await Bb({operation:e,planContext:s,slidePlans:d,session:c,project:i})),B.agentSession.id=c.id||B.agentSession.id,Et({title:O("generationParsingDeck"),detail:"",kind:"parsing"}),Lt(O("generationParsingDeck")),_o({title:a.title,language:a.language,outline:zf(a),researchReport:a.researchReport,design:a.design,slides:A}),await as(`agent:${e}`),Et({title:O("processEventDone"),detail:"",kind:"done"}),Ft("design","done"),Ft("compile","done",O("generationCompiled")),fc(O("deckReady")),n=!0,Mt(),await yt(!0)}finally{!Rn(r)&&(B.generation.active&&!n&&(B.generation.active=!1),Bn(!1)),Lr(B),Br(B)}}function hh(e,t){Lt(O("generationAgentWorking")),Et({title:O("generationAgentWorking"),detail:mr(t||""),kind:"start"}),e==="auto"&&(dc()||os())&&(B.title=O("agentWorkingTitle")),Mt()}var Ib=new Set(["ParamsPartial","Queued","Waiting","Progress","Streaming","StreamChunk","Confirmed","Rejected"]);function ph(e){let t=String(e||"").trim();return t?/^skill$/i.test(t)?O("eventToolSkillName"):/^websearch$/i.test(t)?O("eventToolWebSearchName"):/^webfetch$/i.test(t)?O("eventToolWebFetchName"):t:O("eventUnknownTool")}function Mb(e,t){let r=wc(e),n=r.event_type||r.eventType||"";if(Ib.has(n)||n==="Started"||n==="EarlyDetected")return!1;let i=String(r.tool_name||r.toolName||"tool").toLowerCase(),a=r.params&&typeof r.params=="object"?r.params:{},o=String(a.file_path||a.path||a.command||"").trim(),l=o?`${i}:${o}:${n}`:`${i}:${n}`;return t.has(l)?!1:(t.add(l),n==="Completed"||n==="Failed"||n==="Cancelled"||n==="ConfirmationNeeded")}function zb(){let e=0,t="";return{get lastProgressLogAt(){return e},touch(){e=Date.now()},note(r,n="",i="phase",a=0){let o=Date.now(),l=r===t;return a>0&&l&&o-e0&&(B.generation.draftedCount=r),Lr(B),Br(B)}function Vb(e,t,r){let n=Ob(e),i=Ub(n);Ft(n,"running",i),jb(e,n),t.touch()}function Xb(e){let t=wc(e.toolEvent||{}),r=t.event_type||t.eventType||"ToolEvent",n=ph(t.tool_name||t.toolName),i={EarlyDetected:O("eventToolDetected"),ParamsPartial:O("eventToolParams"),Queued:O("eventToolQueued"),Waiting:O("eventToolWaiting"),Started:O("eventToolStarted"),Progress:O("eventToolProgress"),Streaming:O("eventToolStreaming"),StreamChunk:O("eventToolStreamChunk"),ConfirmationNeeded:O("eventToolConfirmation"),Confirmed:O("eventToolConfirmed"),Rejected:O("eventToolRejected"),Completed:O("eventToolCompleted"),Failed:O("eventToolFailed"),Cancelled:O("eventToolCancelled")},a=new Set(["EarlyDetected","Started","Completed","Failed","Cancelled","ConfirmationNeeded"]);return{title:i[r]||O("processEventTool"),detail:a.has(r)?n:Hb(r,t),kind:r==="Failed"||r==="Cancelled"||r==="Rejected"?"error":"tool"}}function Hb(e,t){return e==="Failed"?mr(t.error||O("backendGenerationFailed")):e==="Completed"?"":e==="Progress"?mr(t.message||""):""}function wc(e){if(e.event_type||e.eventType||e.tool_name||e.toolName)return e;let r=["EarlyDetected","ParamsPartial","Queued","Waiting","Started","Progress","Streaming","StreamChunk","ConfirmationNeeded","Confirmed","Rejected","Completed","Failed","Cancelled"].find(i=>e&&Object.prototype.hasOwnProperty.call(e,i));return r?{...e[r]||{},event_type:r}:e||{}}function mr(e,t=180){let r=String(e||"").replace(/\s+/g," ").trim();return r?r.length>t?`${r.slice(0,t-1)}...`:r:""}function _b(e,t){if(!e||!t)return;Ln.some(n=>n.sessionId===e&&n.turnId===t)||Ln.push({sessionId:e,turnId:t})}function Kb(e,t){Ln=Ln.filter(r=>!(r.sessionId===e&&r.turnId===t))}function Rn(e){return e!==Nn}async function xc(){let e=[...Ln];Ln=[],!(!e.length||!at().backend?.cancel)&&await Promise.all(e.map(async t=>{try{await at().backend.cancel(t.sessionId,t.turnId)}catch(r){at().log?.warn?.("PPT Live backend cancel failed",{sessionId:t.sessionId,turnId:t.turnId,error:String(r)})}}))}async function Qb(e=!1,t={}){let r=Ln.length>0;Nn+=1,await xc(),B.generation.active=!1,B.generation.steps=B.generation.steps.map(n=>n.status==="running"?{...n,status:"error"}:n),!t.silent&&r&&(Lt(e?O("generationTimedOut"):O("generationStopped")),Et(e?O("generationTimedOut"):O("generationStopped"))),Bn(!1),Lr(B),Br(B),t.silent||await yt(!0)}async function Zb(e=!1){await Qb(e)}function _o(e){if($b(e)){e.researchReport&&Uf(e.researchReport),e.design?.palette&&typeof e.design.palette=="object"&&(B.deckPalette=e.design.palette);return}let t=e1(e);if(t.length)B.title=String(e.title||B.title||O("blankDeckTitle")),B.slides=t.map((r,n)=>Hr(r,n,{...B,slides:t})),B.outline=B.slides.map(r=>r.title),B.activeSlideId=B.slides[0]?.id||"",B.selectedElementId="";else{if(!Array.isArray(e?.slides)||e.slides.length===0)throw new Error("PPT Live deck payload has no slides");B.title=String(e.title||B.title||O("blankDeckTitle")),B.slides=e.slides.map((r,n)=>Hr({...r,html:r.html||r.sourceHtml||r.slideHtml||""},n,{...B,slides:e.slides})),B.outline=B.slides.map(r=>r.title),B.activeSlideId=B.slides[0]?.id||"",B.selectedElementId=B.slides[0]?.elements[0]?.id||""}Array.isArray(e.outline)&&e.outline.length&&(B.outline=e.outline.map(sh).filter(Boolean)),e.researchReport&&Uf(e.researchReport),e.design?.palette&&typeof e.design.palette=="object"&&(B.deckPalette=e.design.palette)}function Uf(e){B.sources={...B.sources,facts:e.verifiedFacts||B.sources?.facts||[],warnings:e.warnings||B.sources?.warnings||[],summary:e.summary||B.sources?.summary||"",fetchedAt:Date.now()}}function Yb(e){return Array.isArray(e?.deckPatch?.changes)?e.deckPatch.changes:Array.isArray(e?.patch?.changes)?e.patch.changes:Array.isArray(e?.changes)?e.changes:Array.isArray(e?.patches)?e.patches:[]}function Wf(e,t,r=0){let n=String(e?.slideId||e?.id||e?.targetSlideId||e?.targetId||"").trim();if(n){let o=t.findIndex(l=>l.id===n);if(o>=0)return o}let i=Number(e?.slideNumber??e?.pageNumber);if(Number.isFinite(i)&&i>0)return mt(Math.round(i)-1,0,Math.max(0,t.length-1));let a=Number(e?.slideIndex??e?.index??e?.targetSlideIndex);return Number.isFinite(a)?a>=t.length&&a-1>=0&&a-1a.id===r);if(i>=0)return i+1}let n=String(e?.beforeSlideId||"").trim();if(n){let i=t.findIndex(a=>a.id===n);if(i>=0)return i}return e?.afterSlideNumber?mt(Number(e.afterSlideNumber),0,t.length):e?.beforeSlideNumber?mt(Number(e.beforeSlideNumber)-1,0,t.length):e?.slideNumber?mt(Number(e.slideNumber)-1,0,t.length):e?.slideIndex!==void 0?mt(Number(e.slideIndex),0,t.length):Math.min(t.length,er(B)+1)}function Gf(e,t,r,n){let i=e?.slide||e?.replacement||e?.newSlide||e?.payload||e;if(!i||typeof i!="object")return null;let a={...t||{},...i,id:i.id||i.slideId||t?.id||yr("html-slide"),html:i.html||i.sourceHtml||i.slideHtml||t?.html||""};return Hr(a,r,{...B,slides:n})}function $b(e){let t=Yb(e);if(!t.length)return!1;let r=Xr(B.slides||[]),n=[],i=0;if(t.forEach(o=>{let l=String(o?.op||o?.operation||o?.type||"replace_slide").toLowerCase();if(l==="delete_slide"||l==="delete"||l==="remove_slide"||l==="remove"){if(!r.length)return;let u=Wf(o,r,er(B)),[p]=r.splice(u,1);p?.id&&n.push(p.id),i+=1;return}if(l==="insert_slide"||l==="insert"||l==="add_slide"||l==="add"){let u=Jb(o,r),p=Gf(o,null,u,r);if(!p)return;r.splice(u,0,p),n.push(p.id),i+=1;return}let c=Wf(o,r,er(B)),s=r[c],d=Gf(o,s,c,r);d&&(r[c]=d,n.push(d.id),i+=1)}),!i)throw new Error("PPT Live deck patch had no applicable changes");B.title=String(e.deckPatch?.title||e.patch?.title||e.title||B.title||O("blankDeckTitle")),B.slides=r.map((o,l)=>Hr(o,l,{...B,slides:r})),B.outline=Array.isArray(e.outline)&&e.outline.length?e.outline.map(String):B.slides.map(o=>o.title);let a=n.find(o=>B.slides.some(l=>l.id===o));return B.activeSlideId=a||B.slides[Math.min(er(B),B.slides.length-1)]?.id||B.slides[0]?.id||"",B.selectedElementId=_t(B)?.elements?.[0]?.id||"",!0}function e1(e){let t=[];return Array.isArray(e?.htmlSlides)&&t.push(...e.htmlSlides),Array.isArray(e?.slides)&&t.push(...e.slides.filter(r=>r?.html||r?.sourceHtml||r?.slideHtml)),t.map((r,n)=>{let i=String(r?.html||r?.sourceHtml||r?.slideHtml||"").trim();return i?{id:r.id||r.slideId||yr("html-slide"),title:String(r.title||r.label||`${O("newSlideTitle")} ${n+1}`),subtitle:String(r.subtitle||""),kicker:String(r.kicker||""),claim:String(r.claim||r.title||""),proofObject:String(r.proofObject||""),supportNote:String(r.supportNote||""),sourceNote:String(r.sourceNote||""),notes:String(r.notes||""),layout:"html",theme:r.theme||{},html:i,elements:[]}:null}).filter(Boolean)}function qf(...e){for(let t of e){let r=String(t||"").trim();if(r)try{return ii(r),r}catch{}}return String(e.find(t=>String(t||"").trim())||"").trim()}async function t1(e,t,r,n=null,i={}){let a=at(),o=i.expectJson!==!1;if(!t||!r||!a.backend?.turnText)return e;let l=!1,c=Promise.resolve(e).finally(()=>{l=!0}),s=new Promise((d,u)=>{let p=Date.now(),f=300*1e3,h=10*1e3,A=3600*1e3,v=()=>Number(n?.lastEventAt||p);(async()=>{for(;!l&&Date.now()-pf)break;if(bsetTimeout(x,Math.min(1e3,h-b)));continue}try{let x=await a.backend.turnText(t,r),S=String(x?.text||"").trim();if(S){if(!o){d({answer:S,thinking:""});return}try{ii(S),d({answer:S,thinking:""});return}catch{}}}catch{}await new Promise(x=>setTimeout(x,2e3))}l||u(new Error("PPT Live backend did not publish a final deck JSON"))})()});return Promise.race([c,s])}async function r1(e,t,r,n=""){let i=Date.now(),a=25e3,o=String(r||"").trim(),l=String(n||"").trim(),s=qf(o,l,`${o} +${l}`.trim());if(s)try{return ii(s),s}catch{}let d=at();if(!e||!t||!d.backend?.turnText){if(!s)throw new Error("PPT Live backend produced no text");return s}let u=0;for(;Date.now()-i{setTimeout(()=>A(new Error("turnText timeout")),4e3)})]),f=String(p?.text||"").trim();if(s=qf(f,s,l,o),s)return ii(s),s}catch{}await new Promise(p=>setTimeout(p,500))}if(!s)throw new Error("PPT Live backend produced no text");return s}function ii(e){let t=String(e||"").trim();if(!t)throw new Error("PPT Live backend produced no text");try{return JSON.parse(t)}catch{let r=t.match(/```(?:json)?\s*([\s\S]*?)```/i);if(r)return JSON.parse(r[1]);let n=t.indexOf("{"),i=t.lastIndexOf("}");if(n>=0&&i>n)return JSON.parse(t.slice(n,i+1));throw new Error("PPT Live backend returned invalid JSON")}}function n1(e){let t=String(e?.message||e||"");return/ppt_live:\/\/round-budget-exhausted|exhausted its \d+-round tool budget|tool budget before producing deck JSON/i.test(t)}function i1(e){return String(e||"").includes("timed out")}function us(e){let t=String(e||"");return t.includes("dialog-turn-cancelled")||t.includes("Generation stopped")}async function a1(e,t={}){let r=In();t.readBrief!==!1&&cn({includeTopic:!r});let n=[e,$f()].filter(Boolean).join(": ");if(!n){Lt(O("promptRequired"));return}try{await yc("revise_slide",n,{includeTopic:!r})}catch(i){if(us(i))return;at().log?.warn?.("PPT Live backend slide revision failed",{action:e,error:String(i)}),hc(i),await yt(!0)}}async function qr(){if(cn({includeTopic:!In()}),(B.slides||[]).some(e=>String(e?.html||"").trim())){let e=`Restyle the existing deck without changing its facts or narrative. Apply these exact settings to every slide HTML: ${JSON.stringify(dn())}. Preserve each page's informationIntent and visualStrategy while making the deck visually coherent.`;try{await yc("revise_deck",e,{includeTopic:!1});return}catch(t){if(us(t))return;at().log?.warn?.("PPT Live Agent restyle failed",{error:String(t)}),hc(t),await yt(!0);return}}B.slides=B.slides.map((e,t)=>Hr({...e,theme:void 0},t,B)),Lt(O("deckRestyled")),Mt(),await yt(!0)}function oc(){cn({includeTopic:!In()});let e=new Map(B.slides.map(t=>[t.title,t]));B.slides=B.outline.map((t,r)=>{let n=e.get(t);return n?Hr(n,r,B):xs(t,r,B.outline.length,B)}),B.activeSlideId=B.slides[0]?.id||"",B.selectedElementId=B.slides[0]?.elements[0]?.id||"",Mt(),yt(!0)}async function o1(){Nn+=1,await as("before-new"),await xc(),B.generation.active=!1,Bn(!1),B=s1(),Sa(),Mt(),Lt(O("blankDeckReady")),await yt(!0)}function s1(){return Un(On())}function l1(e){if(!ys.includes(e))return;let t=_t(B);if(!t)return;let r=Ss({...La(e),x:10+t.elements.length%5*4,y:14+t.elements.length%5*4});t.elements.push(r),B.selectedElementId=r.id,Mt(),yt(!0)}function c1(){let e=_t(B);!e||!B.selectedElementId||(e.elements=e.elements.filter(t=>t.id!==B.selectedElementId),B.selectedElementId=e.elements[0]?.id||"",Mt(),yt(!0))}function jf(e){let t=e.elements.find(r=>r.type==="text"&&r.text);t&&(e.title=t.text.slice(0,90),B.outline[er(B)]=e.title,er(B)===0&&(B.title=e.title))}function Vf(){B.presentIndex=er(B),Ah(),xe("previewDialog")?.showModal()}function Ah(){let e=B.slides[B.presentIndex]||B.slides[0];xe("presentSlide")&&(xe("presentSlide").innerHTML=e?pn(e):""),xe("presentCounter")&&(xe("presentCounter").textContent=`${Math.max(1,B.presentIndex+1)} / ${Math.max(1,B.slides.length)}`),Gn()}function Xo(e){B.presentIndex=mt(B.presentIndex+e,0,B.slides.length-1),Ah()}function d1(){if(!(B.slides||[]).length)return Ri(O("exportDeckEmpty")),null;cn({includeTopic:!In()});let e=Yl(B);return Ri(O("exportSavedTo",{path:e})),e}function u1(){return cn({includeTopic:!In()}),(B.slides||[]).length?!0:(Ri(O("exportDeckEmpty")),!1)}function gh(e){return{html:{working:O("exportHtmlWorking"),done:O("exportHtmlDone"),failed:O("exportHtmlFailed")},pptx:{working:O("exportPptxWorking"),done:O("exportPptxDone"),failed:O("exportPptxFailed")},pdf:{working:O("exportPdfWorking"),done:O("exportPdfDone"),failed:O("exportPdfFailed")},png:{working:O("exportPngWorking"),done:O("exportPngDone"),failed:O("exportPngFailed")}}[e]||null}function sc(e,t,r){let n=gh(r==="pptx"?"pptx":r);if(!n||t<=0)return;let i=Math.min(t,Math.max(1,e+1));Qo("loading",`${n.working} (${i}/${t})`)}async function Xf(e,t){let r=at();if(!r?.deck?.renderPage)throw new Error("Host WebView export is unavailable in this runtime.");let n=[],i=e.length;for(let[a,o]of e.entries()){sc(a,i,t);let l=await r.deck.renderPage({html:zs(o),format:t,width:tr.width,height:tr.height});if(!l)throw new Error(`Host WebView returned empty ${t} for slide ${a+1}`);n.push({index:a,base64:String(l).replace(/^data:.*;base64,/,"")})}return n}async function f1(e){if(e==="html"){cn({includeTopic:!In()});let o=Yl(B);if(!o)throw new Error(O("exportDeckEmpty"));return{filename:o}}let t=B.slides||[];if(!t.length)throw new Error(O("exportDeckEmpty"));let r,n=Xr(B);if(e==="pptx")if(t.some(o=>o?.html)){let o=at(),l=typeof o?.deck?.renderPage=="function"?async(s,d)=>{sc(d,t.length,"pptx");let u=await o.deck.renderPage({html:s,format:"png",width:tr.width,height:tr.height});return String(u||"").replace(/^data:.*;base64,/,"")}:null,c=await gd(t,{renderRaster:l,onRasterProgress:s=>sc(s,t.length,"pptx")});r=await Kl(n,c)}else r=await _l(n);else if(e==="pdf"){let o=await Xf(t,"pdf");r=await Ql(n,o.map(l=>l.base64))}else if(e==="png"){let o=await Xf(t,"png");r=await Zl(n,o)}else throw new Error(O("exportFormatUnavailable"));let i=typeof r?.base64=="string"?r.base64.replace(/^data:.*;base64,/,""):"";if(!i)throw new Error(`export${e} returned no data`);let a=r.filename||`${Jl(B.title||"ppt-live")}`;return Df(i,a,r.mimeType||"application/octet-stream"),{filename:a}}var Ko=!1,Jt={updateOutline(e,t){B.outline[e]=t,B.slides[e]&&(B.slides[e].title=t),Mt(),yt(!0)},moveOutline(e,t){let r=e+t;r<0||r>=B.outline.length||([B.outline[e],B.outline[r]]=[B.outline[r],B.outline[e]],oc())},removeOutline(e){B.outline.length<=1||(B.outline.splice(e,1),oc())},selectSlide(e){B.activeSlideId=e,B.selectedElementId=_t(B)?.elements[0]?.id||"",Mt(),yt(!0)},selectElement(e){B.selectedElementId=e,hn(B,Jt),qa(B,Jt),yt(!0)},updateElementTextDirect(e,t){let r=_t(B),n=r?.elements.find(i=>i.id===e);n&&(n.text=String(t||"").trim(),jf(r),qn(B,Jt),renderOutline(B,Jt),yt(!1))},updateElementListItemDirect(e,t,r){let i=_t(B)?.elements.find(a=>a.id===e);!i||!Array.isArray(i.items)||(i.items[t]=String(r||"").trim(),i.items=i.items.filter(Boolean),hn(B,Jt),qn(B,Jt),yt(!1))},updateSlideHtmlDirect(e,t){let r=B.slides.find(i=>i.id===e);if(!r)return;let n=String(t||"");r.html!==n&&(r.html=n,qn(B,Jt),yt(!1))},updateSlideNotes(e){let t=_t(B);t&&(t.notes=e),yt(!0)},updateSlideMethodology(){let e=_t(B);e&&(e.kicker=xe("slideKickerInput")?.value||e.kicker,e.claim=xe("slideClaimInput")?.value||e.claim,e.proofObject=xe("slideProofInput")?.value||e.proofObject,e.supportNote=xe("slideSupportInput")?.value||e.supportNote,e.sourceNote=xe("slideSourceInput")?.value||e.sourceNote,hn(B,Jt),qn(B,Jt),yt(!0))},updateElementFromInspector(){let e=_t(B),t=Wn(B);!e||!t||(t.text=xe("elementTextInput")?.value||"",t.items=(xe("elementItemsInput")?.value||"").split(` +`).map(r=>r.trim()).filter(Boolean),t.data=p1(xe("elementDataInput")?.value||""),t.x=mt(Number(xe("elementXInput")?.value??t.x),0,100),t.y=mt(Number(xe("elementYInput")?.value??t.y),0,100),t.w=mt(Number(xe("elementWInput")?.value??t.w),3,100),t.h=mt(Number(xe("elementHInput")?.value??t.h),3,100),t.style.fontSize=mt(Number(xe("elementFontInput")?.value??t.style.fontSize),8,88),t.style.fontWeight=mt(Number(xe("elementWeightInput")?.value??t.style.fontWeight),100,900),t.style.color=xe("elementColorInput")?.value||t.style.color,t.style.background=xe("elementBgInput")?.value||t.style.background,Jt.updateSlideMethodology(),e.notes=xe("slideNotesInput")?.value||e.notes,jf(e),hn(B,Jt),yt(!0))},beginDrag(e,t){if(e.button!==0)return;let n=_t(B)?.elements.find(a=>a.id===t);if(!n)return;B.selectedElementId=n.id;let i=xe("slideCanvas").getBoundingClientRect();Rr={resizing:e.target.classList.contains("resize-handle"),startX:e.clientX,startY:e.clientY,rect:i,start:{x:n.x,y:n.y,w:n.w,h:n.h}},e.currentTarget.setPointerCapture?.(e.pointerId),window.addEventListener("pointermove",mh),window.addEventListener("pointerup",h1,{once:!0})}};function mh(e){if(!Rr)return;let t=Wn(B);if(!t)return;let r=(e.clientX-Rr.startX)/Rr.rect.width*100,n=(e.clientY-Rr.startY)/Rr.rect.height*100;Rr.resizing?(t.w=mt(Rr.start.w+r,3,100-t.x),t.h=mt(Rr.start.h+n,3,100-t.y)):(t.x=mt(Rr.start.x+r,0,100-t.w),t.y=mt(Rr.start.y+n,0,100-t.h)),hn(B,Jt),qa(B,Jt)}function h1(){Rr=null,window.removeEventListener("pointermove",mh),yt(!0)}function p1(e){return e.split(` +`).map((t,r)=>{let[n,i]=t.split(":");return{label:(n||`Item ${r+1}`).trim(),value:Number(i||0)}}).filter(t=>t.label)}function A1(){let e=document.querySelector(".studio-shell");if(!e)return;let t=document.documentElement,r=Number(rc("pptLiveFilmstripWidth")||0),n=Number(rc("pptLiveAgentWidth")||0);r>=128&&r<=360&&t.style.setProperty("--filmstrip-width",`${r}px`),n>=240&&n<=460&&t.style.setProperty("--agent-width",`${n}px`);let i=(a,o)=>{let l=e.getBoundingClientRect(),c=128,s=Math.min(360,l.width*.34),d=240,u=Math.min(460,l.width*.42),p=360,f=A=>{if(a==="filmstrip"){let v=Math.max(c,Math.min(s,A.clientX-l.left));if(l.width-v-parseFloat(getComputedStyle(t).getPropertyValue("--agent-width"))-12{e.classList.remove("is-resizing"),document.querySelectorAll(".panel-resizer.is-dragging").forEach(A=>A.classList.remove("is-dragging")),window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),nc("pptLiveFilmstripWidth",String(parseFloat(getComputedStyle(t).getPropertyValue("--filmstrip-width"))||"")),nc("pptLiveAgentWidth",String(parseFloat(getComputedStyle(t).getPropertyValue("--agent-width"))||"")),Gn()};e.classList.add("is-resizing"),window.addEventListener("pointermove",f),window.addEventListener("pointerup",h,{once:!0}),window.addEventListener("pointercancel",h,{once:!0}),f({clientX:o})};xe("filmstripResizer")?.addEventListener("pointerdown",a=>{a.button===0&&(a.preventDefault(),a.currentTarget.classList.add("is-dragging"),i("filmstrip",a.clientX))}),xe("agentResizer")?.addEventListener("pointerdown",a=>{a.button===0&&(a.preventDefault(),a.currentTarget.classList.add("is-dragging"),i("agent",a.clientX))})}function g1(){let e=null,t=()=>{e&&clearTimeout(e),e=setTimeout(()=>{Gn()},60)};window.addEventListener("resize",t),xe("toggleHistory")?.addEventListener("click",()=>{let r=xe("historyDrawer");r&&(r.hidden=!r.hidden)}),xe("closeHistory")?.addEventListener("click",()=>{let r=xe("historyDrawer");r&&(r.hidden=!0)}),document.querySelectorAll("[data-sidebar-tab]").forEach(r=>{r.addEventListener("click",()=>{let n=r.dataset.sidebarTab;document.querySelectorAll("[data-sidebar-tab]").forEach(i=>{i.classList.toggle("is-active",i.dataset.sidebarTab===n)}),document.querySelectorAll("[data-sidebar-panel]").forEach(i=>{i.classList.toggle("is-active",i.dataset.sidebarPanel===n)})})}),xe("topicInput")?.addEventListener("input",()=>{if(In()){B.promptDraft=xe("topicInput")?.value||"",yt(!0);return}cn({includeTopic:!0}),yt(!0)}),xe("newDeck")?.addEventListener("click",()=>{o1()}),xe("cancelGeneration")?.addEventListener("click",()=>{Zb(!1)}),xe("sendPrompt")?.addEventListener("click",()=>{uc()}),xe("generateOutline")?.addEventListener("click",()=>{ab()}),xe("generateDeck")?.addEventListener("click",()=>{ob()}),xe("addOutlineItem")?.addEventListener("click",()=>{B.outline.push(O("newSlideTitle")),Mt(),yt(!0)}),xe("syncSlidesFromOutline")?.addEventListener("click",oc),xe("deleteElement")?.addEventListener("click",c1),xe("previewDeck")?.addEventListener("click",Vf),xe("closePreview")?.addEventListener("click",()=>xe("previewDialog")?.close()),xe("prevPresent")?.addEventListener("click",()=>Xo(-1)),xe("nextPresent")?.addEventListener("click",()=>Xo(1)),xe("exportHtml")?.addEventListener("click",d1),xe("restyleDeck")?.addEventListener("click",qr),document.querySelectorAll("[data-add-element]").forEach(r=>{r.addEventListener("click",()=>l1(r.dataset.addElement))}),document.querySelectorAll(".ai-action").forEach(r=>{r.addEventListener("click",()=>{a1(r.dataset.action)})}),document.querySelectorAll(".segment").forEach(r=>{r.addEventListener("click",()=>{B.mode=r.dataset.mode,B.mode==="present"&&Vf(),Mt(),yt(!0)})}),document.addEventListener("keydown",r=>{xe("previewDialog")?.open&&((r.key==="ArrowRight"||r.key==="PageDown")&&Xo(1),(r.key==="ArrowLeft"||r.key==="PageUp")&&Xo(-1),r.key==="Escape"&&xe("previewDialog")?.close())});try{A1()}catch(r){at().log?.warn?.("Failed to bind PPT Live panel resizers",{error:String(r)})}if(typeof ResizeObserver<"u"){let r=[document.querySelector(".ppt-live"),document.querySelector(".studio-shell"),document.querySelector(".stage-shell"),document.querySelector(".canvas-area")].filter(Boolean),n=new ResizeObserver(t);r.forEach(i=>n.observe(i))}y1(),b1(),w1(),P1(),T1()}var an=1,Ei=.25,m1=.25,v1=2;function ba(e){an=mt(e,m1,v1);let t=document.querySelector(".canvas-stage");t&&(t.style.transform=an===1?"":`scale(${an})`);let r=xe("zoomValue"),n=xe("statusZoomValue"),i=Math.round(an*100)+"%";r&&(r.textContent=i),n&&(n.textContent=i)}function y1(){xe("zoomIn")?.addEventListener("click",()=>ba(an+Ei)),xe("zoomOut")?.addEventListener("click",()=>ba(an-Ei)),xe("statusZoomIn")?.addEventListener("click",()=>ba(an+Ei)),xe("statusZoomOut")?.addEventListener("click",()=>ba(an-Ei)),document.querySelector(".canvas-area")?.addEventListener("wheel",e=>{if(e.ctrlKey||e.metaKey){e.preventDefault();let t=e.deltaY>0?-Ei:Ei;ba(an+t)}},{passive:!1})}function b1(){xe("floatingToolbar")&&document.querySelectorAll(".floating-toolbar-btn").forEach(t=>{t.addEventListener("click",()=>{let r=t.dataset.tool;if(!r)return;let n=_t(B),i=Wn(B);if(!(!n||!i)){switch(r){case"bold":i.fontWeight=i.fontWeight==="700"?"400":"700";break;case"italic":i.fontStyle=i.fontStyle==="italic"?"normal":"italic";break;case"underline":i.textDecoration=i.textDecoration==="underline"?"none":"underline";break;case"align-left":i.align="left";break;case"align-center":i.align="center";break;case"align-right":i.align="right";break;case"duplicate":n.elements.push({...Xr(i),id:yr("el"),x:i.x+5,y:i.y+5});break;case"delete":n.elements=n.elements.filter(a=>a.id!==i.id),B.selectedElementId=null;break}hn(B,Jt),qn(B,Jt),yt(!0)}})})}function w1(){document.querySelectorAll(".property-section__header").forEach(n=>{let i=n.closest(".property-section");if(!i)return;let a=()=>{i.classList.toggle("is-collapsed");let o=!i.classList.contains("is-collapsed");n.setAttribute("aria-expanded",String(o))};n.addEventListener("click",a),n.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),a())})});let e=xe("densitySlider"),t=e?.querySelector(".density-slider__track");e&&t&&(t.addEventListener("pointerdown",n=>{n.preventDefault(),ri(Mf(n.clientX,t),{save:!1}),t.setPointerCapture(n.pointerId)}),t.addEventListener("pointermove",n=>{t.hasPointerCapture(n.pointerId)&&ri(Mf(n.clientX,t),{save:!1})}),t.addEventListener("pointerup",n=>{t.hasPointerCapture(n.pointerId)&&(t.releasePointerCapture(n.pointerId),qr())}),t.addEventListener("pointercancel",n=>{t.hasPointerCapture(n.pointerId)&&(t.releasePointerCapture(n.pointerId),yt(!0))}),e.querySelectorAll("[data-density-index]").forEach(n=>{n.addEventListener("click",i=>{i.stopPropagation(),ri(n.dataset.densityIndex),qr()})}),e.addEventListener("keydown",n=>{let i=Ea(B.style.density);n.key==="ArrowLeft"||n.key==="ArrowDown"?(n.preventDefault(),ri(i-1),qr()):n.key==="ArrowRight"||n.key==="ArrowUp"?(n.preventDefault(),ri(i+1),qr()):n.key==="Home"?(n.preventDefault(),ri(0),qr()):n.key==="End"&&(n.preventDefault(),ri(2),qr())})),document.querySelectorAll("[data-font-family]").forEach(n=>{n.addEventListener("click",()=>{B.style.fontFamily=n.dataset.fontFamily==="serif"?"serif":"sans",document.querySelectorAll("[data-font-family]").forEach(i=>{let a=i===n;i.classList.toggle("is-active",a),i.setAttribute("aria-pressed",a?"true":"false")}),qr(),yt(!0)})}),document.querySelectorAll("[data-color-mode]").forEach(n=>{n.addEventListener("click",()=>{B.style.colorMode=n.dataset.colorMode==="dark"?"dark":"light",document.querySelectorAll("[data-color-mode]").forEach(i=>{let a=i===n;i.classList.toggle("is-active",a),i.setAttribute("aria-pressed",a?"true":"false")}),qr()})});let r=xe("stylePresetSelect");r&&(wh(),qc(r),r.value=B.style?.stylePreset||un,Ni(r),r.addEventListener("change",()=>{let n=r.value;if(n){B.style.stylePreset=n;let i=ps(n);i&&(B.style.colorMode=i.colorMode||"light",B.style.fontFamily=i.fontFamily||"sans",B.style.density=i.density||"standard",document.querySelectorAll("[data-color-mode]").forEach(a=>{let o=a.dataset.colorMode===B.style.colorMode;a.classList.toggle("is-active",o),a.setAttribute("aria-pressed",o?"true":"false")}),document.querySelectorAll("[data-font-family]").forEach(a=>{let o=a.dataset.fontFamily===B.style.fontFamily;a.classList.toggle("is-active",o),a.setAttribute("aria-pressed",o?"true":"false")}),Oi(B.style.density)),qr(),yt(!0)}}))}var on=0;function vh(){return xe("formatGrid")?.querySelector(".format-card.is-selected")?.dataset.format||"pptx"}function x1(){let e=xe("exportOverlay");e&&(yh(),on=Math.max(0,er(B)),e.classList.add("is-visible"),e.setAttribute("aria-hidden","false"),S1(),ns(),requestAnimationFrame(()=>Li()))}function Li(){nd(xe("exportPreviewFrame"))}function yh(){let e=xe("exportModalFeedback"),t=xe("exportModalFeedbackText"),r=xe("exportModalSpinner");xe("exportOverlay")?.classList.remove("is-exporting"),e&&(e.hidden=!0,e.classList.remove("is-success","is-error")),t&&(t.textContent=""),r&&(r.hidden=!1),lc(!1)}function lc(e){["exportCancel","exportConfirm","closeExport"].forEach(t=>{let r=xe(t);r&&(r.disabled=e)}),xe("formatGrid")?.querySelectorAll(".format-card").forEach(t=>{t.tabIndex=e?-1:0,t.style.pointerEvents=e?"none":""}),["exportPreviewPrev","exportPreviewNext"].forEach(t=>{let r=xe(t);r&&(r.disabled=e)})}function Qo(e,t){let r=xe("exportModalFeedback"),n=xe("exportModalFeedbackText"),i=xe("exportModalSpinner");!r||!n||(r.hidden=!1,r.classList.toggle("is-success",e==="success"),r.classList.toggle("is-error",e==="error"),i&&(i.hidden=e!=="loading"),n.textContent=t)}function Zo(){let e=xe("exportOverlay");e&&(e.classList.remove("is-visible"),e.setAttribute("aria-hidden","true"),yh())}function S1(){let e=xe("formatGrid");if(!e)return;let t=[{id:"pptx",name:"PPTX",desc:"Editable PowerPoint"},{id:"pdf",name:"PDF",desc:"Universal format"},{id:"html",name:"HTML",desc:"Interactive web deck"},{id:"png",name:"PNG",desc:"Image sequence"}];e.innerHTML=t.map((r,n)=>`
                  -
                  ${sf(r.id)}
                  +
                  ${Rf(r.id)}
                  ${r.name} ${r.desc}
                  - `).join(""),e.querySelectorAll(".format-card").forEach(r=>{let n=()=>{e.querySelectorAll(".format-card").forEach(i=>i.classList.remove("is-selected")),r.classList.add("is-selected"),Ko()};r.addEventListener("click",n),r.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),n())})})}function Mb(e,t){if(!e||!t)return;e.innerHTML="";let r=document.createElement("div");r.className="export-preview__viewport";let n=document.createElement("div");if(n.className="export-preview__scale",t.html)n.appendChild(Nc(t.html));else{let i=document.createElement("div");i.className="export-preview__element-stage",i.innerHTML=dn(t),n.append(i)}r.append(n),e.append(r),requestAnimationFrame(()=>{Si(),requestAnimationFrame(()=>Si())})}function Ko(){let e=xe("exportPreviewInfo"),t=xe("exportPreviewCounter"),r=xe("exportPreviewFrame"),n=N.slides||[],i=jf().toUpperCase(),a=Math.max(1,n.length);if(nn=mt(nn,0,Math.max(0,n.length-1)),e&&(e.textContent=`${i} \xB7 ${n.length} slides`),t&&(t.textContent=`${nn+1} / ${a}`),!r)return;let o=n[nn];if(!o){r.innerHTML=`
                  ${Le(U("slidesEmptyHint"))}
                  `;return}Mb(r,o)}async function zb(){if(qo||!Sb())return;let e=jf(),t=Gf(e);if(!t){xi(U("exportFormatUnavailable"));return}qo=!0,xe("exportOverlay")?.classList.add("is-exporting"),Vl(!0),jo("loading",t.working);let r=xe("exportPreviewFrame"),n=r?.innerHTML||"";try{let{filename:i}=await kb(e),a=U("exportSavedTo",{path:i});xe("exportOverlay")?.classList.remove("is-exporting"),jo("success",a),xi(a),await new Promise(o=>setTimeout(o,1600)),Vo()}catch(i){let a=i instanceof Error?i.message:String(i);yt().log?.error?.(`PPT Live ${e} export failed`,{error:a}),xe("exportOverlay")?.classList.remove("is-exporting"),jo("error",`${t.failed} ${a}`),xi(`${t.failed} ${a}`)}finally{r&&n&&(r.innerHTML=n),Vl(!1),qo=!1}}function Ob(){if(xe("exportPptx")?.addEventListener("click",()=>Nb()),xe("closeExport")?.addEventListener("click",Vo),xe("exportCancel")?.addEventListener("click",Vo),xe("exportConfirm")?.addEventListener("click",()=>{zb()}),xe("exportOverlay")?.addEventListener("click",e=>{e.target===xe("exportOverlay")&&!qo&&Vo()}),xe("exportPreviewPrev")?.addEventListener("click",()=>{nn=Math.max(0,nn-1),Ko(),requestAnimationFrame(()=>Si())}),xe("exportPreviewNext")?.addEventListener("click",()=>{let e=(N.slides||[]).length-1;nn=Math.min(e,nn+1),Ko(),requestAnimationFrame(()=>Si())}),typeof ResizeObserver<"u"){let e=xe("exportPreviewFrame");e&&new ResizeObserver(()=>{xe("exportOverlay")?.classList.contains("is-visible")&&Si()}).observe(e)}}var Ff="pptLiveTheme";function Xf(e){return e==="dark"||e==="light"?e:window.matchMedia?.("(prefers-color-scheme: dark)")?.matches?"dark":"light"}function Ub(){let e=document.documentElement.getAttribute("data-theme-type")||document.documentElement.getAttribute("data-theme");if(e==="dark"||e==="light")return e;let t=yt().theme;return t==="dark"||t==="light"?t:Xf()}function Tf(e){let t=Xf(e),r=document.documentElement;r.setAttribute("data-theme",t),r.setAttribute("data-theme-type",t),r.style.colorScheme=t,zn(),qt()}function Wb(){try{localStorage.removeItem(Ff)}catch{Ho.delete(Ff)}Tf(Ub()),yt().onThemeChange?.(e=>{let t=e?.type==="dark"?"dark":"light";Tf(t)})}async function Gb(){Bn+=1,Dn=[],ha=!1,Wo=!1,(N.generation?.active||N.generation?.steps?.some(t=>t.status==="running"))&&(_l(U("generationStopped")),ga()),En(!1);let e=yt();e.backend?.cancelStaleRuns&&e.backend.cancelStaleRuns().catch(t=>{yt().log?.warn?.("Failed to cancel stale PPT Live backend runs",{error:String(t)})})}function Hf(){let e=xe("stylePresetSelect");if(!e)return;let t=e.value||N.style?.stylePreset||on;e.textContent="",nc(Mr()).forEach(({key:r,displayName:n,description:i})=>{let a=document.createElement("option");a.value=r,a.textContent=n,i&&(a.title=i),e.append(a)}),e.value=t,e.selectedIndex<0&&(e.value=on),Ci(e)}function Xo(){N.generation=Sa(N.generation),Tc(),Hf(),Di(N.style?.density);let e=xe("aiStatusPill");e&&(e.textContent=Fn?U("statusPillBusy"):U("statusPillReady")),qt()}async function qb(){Xo();try{await Py(),await Gb(),Xo(),await At(!0)}catch(e){yt().log?.error?.("PPT Live init failed",{error:String(e)}),jt(U("ready")),Xo()}finally{zn()}}Tb();Na();yt().onLocaleChange?.(()=>Xo());qb(); + `).join(""),e.querySelectorAll(".format-card").forEach(r=>{let n=()=>{e.querySelectorAll(".format-card").forEach(i=>i.classList.remove("is-selected")),r.classList.add("is-selected"),ns()};r.addEventListener("click",n),r.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),n())})})}function C1(e,t){if(!e||!t)return;e.innerHTML="";let r=document.createElement("div");r.className="export-preview__viewport";let n=document.createElement("div");if(n.className="export-preview__scale",t.html)n.appendChild(rd(t.html));else{let i=document.createElement("div");i.className="export-preview__element-stage",i.innerHTML=pn(t),n.append(i)}r.append(n),e.append(r),requestAnimationFrame(()=>{Li(),requestAnimationFrame(()=>Li())})}function ns(){let e=xe("exportPreviewInfo"),t=xe("exportPreviewCounter"),r=xe("exportPreviewFrame"),n=B.slides||[],i=vh().toUpperCase(),a=Math.max(1,n.length);if(on=mt(on,0,Math.max(0,n.length-1)),e&&(e.textContent=`${i} \xB7 ${n.length} slides`),t&&(t.textContent=`${on+1} / ${a}`),!r)return;let o=n[on];if(!o){r.innerHTML=`
                  ${Be(O("slidesEmptyHint"))}
                  `;return}C1(r,o)}async function k1(){if(Ko||!u1())return;let e=vh(),t=gh(e);if(!t){Ri(O("exportFormatUnavailable"));return}Ko=!0,xe("exportOverlay")?.classList.add("is-exporting"),lc(!0),Qo("loading",t.working);let r=xe("exportPreviewFrame"),n=r?.innerHTML||"";try{let{filename:i}=await f1(e),a=O("exportSavedTo",{path:i});xe("exportOverlay")?.classList.remove("is-exporting"),Qo("success",a),Ri(a),await new Promise(o=>setTimeout(o,1600)),Zo()}catch(i){let a=i instanceof Error?i.message:String(i);at().log?.error?.(`PPT Live ${e} export failed`,{error:a}),xe("exportOverlay")?.classList.remove("is-exporting"),Qo("error",`${t.failed} ${a}`),Ri(`${t.failed} ${a}`)}finally{r&&n&&(r.innerHTML=n),lc(!1),Ko=!1}}function P1(){if(xe("exportPptx")?.addEventListener("click",()=>x1()),xe("closeExport")?.addEventListener("click",Zo),xe("exportCancel")?.addEventListener("click",Zo),xe("exportConfirm")?.addEventListener("click",()=>{k1()}),xe("exportOverlay")?.addEventListener("click",e=>{e.target===xe("exportOverlay")&&!Ko&&Zo()}),xe("exportPreviewPrev")?.addEventListener("click",()=>{on=Math.max(0,on-1),ns(),requestAnimationFrame(()=>Li())}),xe("exportPreviewNext")?.addEventListener("click",()=>{let e=(B.slides||[]).length-1;on=Math.min(e,on+1),ns(),requestAnimationFrame(()=>Li())}),typeof ResizeObserver<"u"){let e=xe("exportPreviewFrame");e&&new ResizeObserver(()=>{xe("exportOverlay")?.classList.contains("is-visible")&&Li()}).observe(e)}}var Hf="pptLiveTheme";function bh(e){return e==="dark"||e==="light"?e:window.matchMedia?.("(prefers-color-scheme: dark)")?.matches?"dark":"light"}function F1(){let e=document.documentElement.getAttribute("data-theme-type")||document.documentElement.getAttribute("data-theme");if(e==="dark"||e==="light")return e;let t=at().theme;return t==="dark"||t==="light"?t:bh()}function _f(e){let t=bh(e),r=document.documentElement;r.setAttribute("data-theme",t),r.setAttribute("data-theme-type",t),r.style.colorScheme=t,Gn(),Mt()}function T1(){try{localStorage.removeItem(Hf)}catch{Jo.delete(Hf)}_f(F1()),at().onThemeChange?.(e=>{let t=e?.type==="dark"?"dark":"light";_f(t)})}async function D1(){Nn+=1,Ln=[],wa=!1,Ho=!1,(B.generation?.active||B.generation?.steps?.some(t=>t.status==="running"))&&(fc(O("generationStopped")),Sa()),Bn(!1);let e=at();e.backend?.cancelStaleRuns&&e.backend.cancelStaleRuns().catch(t=>{at().log?.warn?.("Failed to cancel stale PPT Live backend runs",{error:String(t)})})}function wh(){let e=xe("stylePresetSelect");if(!e)return;let t=e.value||B.style?.stylePreset||un;e.textContent="",kc(lr()).forEach(({key:r,displayName:n,description:i})=>{let a=document.createElement("option");a.value=r,a.textContent=n,i&&(a.title=i),e.append(a)}),e.value=t,e.selectedIndex<0&&(e.value=un),Ni(e)}function Yo(){B.generation=Ra(B.generation),Zc(),wh(),Oi(B.style?.density);let e=xe("aiStatusPill");e&&(e.textContent=En?O("statusPillBusy"):O("statusPillReady")),Mt()}async function E1(){Yo();try{await tb(),await D1(),Yo(),await yt(!0)}catch(e){at().log?.error?.("PPT Live init failed",{error:String(e)}),Lt(O("ready")),Yo()}finally{Gn()}}g1();Ga();at().onLocaleChange?.(()=>Yo());E1(); diff --git a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/index.html b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/index.html index 3e04cb476..54c109f42 100644 --- a/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/index.html +++ b/src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/index.html @@ -20,14 +20,6 @@

                  PPT Live

                  -
                  -
                  - - Ready. - -
                  -
                  -
                  @@ -79,18 +71,6 @@

                  PPT Live

                  AI has auto-adapted template
                  - -
                  @@ -213,6 +193,7 @@

                  History