#!/usr/bin/env python3
"""
Tab4内容生成器 - 金句提取
包含：script_type、hooks、golden_sentences
"""
import html as html_module
from typing import Dict, Any, List


def generate_tab4_content(data: Dict[str, Any]) -> str:
    """生成Tab4内容：金句提取"""
    html = '<div class="tab-content" id="tab4" style="display: none;">\n'
    html += '<div class="section">\n'
    html += '<h3>金句提取</h3>\n'
    
    golden_sentences = data.get("金句提取", {})
    
    if not golden_sentences:
        html += '<p>暂无数据</p>\n'
    else:
        card_id = "golden-sentences"
        
        html += f'<div class="point-card golden-card" data-card-id="{card_id}">\n'
        html += f'<div class="point-card-header" onclick="toggleCardDetails(\'{card_id}\')">\n'
        html += '<span class="point-text">金句提取结果</span>\n'
        html += '<span class="toggle-icon">▼</span>\n'
        html += '</div>\n'
        
        html += f'<div class="point-card-details" id="{card_id}-details">\n'
        
        # script_type
        script_type = golden_sentences.get("script_type", "")
        if script_type:
            html += '<div class="detail-section">\n'
            html += '<strong>脚本类型：</strong>\n'
            html += f'<div class="detail-text">{html_module.escape(script_type)}</div>\n'
            html += '</div>\n'
        
        # hooks
        hooks = golden_sentences.get("hooks", [])
        if hooks:
            html += '<div class="detail-section">\n'
            html += '<strong>Hooks（钩子）：</strong>\n'
            html += '<ul class="detail-list">\n'
            for hook in hooks:
                html += f'<li class="hook-item">{html_module.escape(str(hook))}</li>\n'
            html += '</ul>\n'
            html += '</div>\n'
        
        # golden_sentences
        sentences = golden_sentences.get("golden_sentences", [])
        if sentences:
            html += '<div class="detail-section">\n'
            html += '<strong>金句：</strong>\n'
            html += '<ul class="detail-list">\n'
            for sentence in sentences:
                html += f'<li class="golden-item">{html_module.escape(str(sentence))}</li>\n'
            html += '</ul>\n'
            html += '</div>\n'
        
        html += '</div>\n'
        html += '</div>\n'
    
    html += '</div>\n'
    html += '</div>\n'
    return html

