<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="includes">
    <meta charset="UTF-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="Referrer" content="origin"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>BUM'sPace</title>
    <script async th:src="@{https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9504446465764716}"  crossorigin="anonymous"></script>
    <script type="module" th:src="@{/js/common.js}"></script>
    <link th:href="@{/css/main.css}" rel="stylesheet" />
    <meta name="_csrf" th:content="${_csrf.token}"/>
    <meta name="_csrf_header" th:content="${_csrf.headerName}"/>
    <meta name="_csrf_parameter" th:content="${_csrf.parameterName}"/>
<!--    <th:block th:with="userTheme=${user != null ? user.theme : 'default'}">-->
<!--        <link rel="stylesheet" th:href="@{/css/themes/} + ${userTheme} + '.css'" />-->
<!--    </th:block>-->
    <script th:inline="javascript">
        /*
         * [Modified] This object must include all fields from the Post.kt model.
         * Any fields missing here will be initialized as null or 0 on the server upon saving after an edit.
         * (This block can remain in the <head>; it defines a global variable.)
         */
        var serverData = {
            // --- Key IDs ---
            id: [[${srcPost?.id}]], // (Using Thymeleaf 3.x's safe navigation operator '?')
        originId: [[${srcPost?.originId}]],

        // --- Core Content (already decoded in the controller) ---
        title: /*[[${srcPost?.title ?: ''}]]*/,
        content: /*[[${srcPost?.content ?: ''}]]*/,

        // === (Modified) Critically missing fields ===
        category: /*[[${srcPost?.category ?: 'none'}]]*/,
        tags: /*[[${srcPost?.tags ?: ''}]]*/,

        // --- Timestamps (required for data preservation) ---
        writeTime: [[${srcPost?.writeTime ?: 0}]],
        modifyTime: [[${srcPost?.modifyTime ?: 0}]],

        // --- Location Data (required for data preservation) ---
        firstPostLat: [[${srcPost?.firstPostLat ?: 0.0}]],
        firstPostLon: [[${srcPost?.firstPostLon ?: 0.0}]],
        firstAddress: /*[[${srcPost?.firstAddress ?: ''}]]*/,
        modifyLat: [[${srcPost?.modifyLat ?: 0.0}]],
        modifyLon: [[${srcPost?.modifyLon ?: 0.0}]],
        modifyAddress: /*[[${srcPost?.modifyAddress ?: ''}]]*/,

        // --- Metadata (required for data preservation) ---
        writer: /*[[${srcPost?.writer ?: ''}]]*/,
        posting: [[${srcPost?.posting ?: false}]],
        readCount: [[${srcPost?.readCount ?: 0}]],
        voteCount: [[${srcPost?.voteCount ?: 0}]],
        unlikeCount: [[${srcPost?.unlikeCount ?: 0}]],
        // --- Page-specific (not model data) ---
        enc: /*[[${enc ?: ''}]]*/,
        keyword: /*[[${keyword ?: ''}]]*/,
        // --- [핵심 추가] ---
        token: /*[[${jwtToken}]]*/,
        apiBaseUrl : /*[[${apiBaseUrl}]]*/,
        userTheme: [[${#authentication.principal != 'anonymousUser' ? user?.theme : null}]],
        };
    </script>
</th:block>
</html>