#!/bin/bash

# Standard LibrePortal tag replacements for common configuration values
# Now uses universal tag manager instead of sed operations
tagsProcessorStandardReplacements()
{
    local full_file_path="$1"
    local domain_full="$2"
    local host_setup="$3"
    local domain_prefix="$4"
    local public_ip_v4="$5"
    local CFG_NETWORK_SUBNET="$6"
    local CFG_TIMEZONE="$7"
    local CFG_NETWORK_NAME="$8"
    local CFG_NETWORK_MTU="$9"
    local default_middleware="${10}"
    
    echo "Applying standard LibrePortal tag replacements using universal tag manager"
    
    # Use universal tag manager for all replacements - only update tags that exist
    tagsManagerUpdateUniversalTag "$full_file_path" "DOMAINSUBNAME_TAG" "$host_setup"
    tagsManagerUpdateUniversalTag "$full_file_path" "TIMEZONE_TAG" "$CFG_TIMEZONE"
    tagsManagerUpdateUniversalTag "$full_file_path" "DOCKER_NETWORK_TAG" "$CFG_NETWORK_NAME"
    # Host live-app-data root, passed into the WebUI container (only the
    # libreportal compose carries this tag; "only update tags that exist").
    tagsManagerUpdateUniversalTag "$full_file_path" "CONTAINERS_DIR_TAG" "${containers_dir%/}"
    # Host system-tree configs root — absolute bind-mount source for the WebUI's
    # configs/webui/* (the containers root is separate from the system tree now).
    tagsManagerUpdateUniversalTag "$full_file_path" "CONFIGS_DIR_TAG" "${configs_dir%/}"

    isSuccessful "Standard LibrePortal tag replacements applied using universal tag manager"
}
