
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
 * AUTO-GENERATED FILE. DO NOT MODIFY.
 */

import { getBoundingRect } from 'tvrender/lib/contain/text.js';
import { getFont } from '../label/labelStyle.js';
import * as formatUtil from './format.js';
export function getLeftTextX(x, text, textStyle, ecModel) {
  var font = getFont(textStyle, ecModel);
  var textRect = getBoundingRect(text, font);
  var paddings = formatUtil.normalizeCssArray(textStyle.padding || 0);
  return x - textRect.width - paddings[1] - paddings[3] - (textStyle.borderWidth || 0) - 1;
}
// 定义时间单位常量（秒数）
var SECONDS_PER_HOUR = 3600;
var SECONDS_PER_DAY = 86400;
var SECONDS_PER_MONTH = 30 * SECONDS_PER_DAY; // 按30天近似月份
export function formatSeconds(seconds) {
  // 处理超大时间单位（月 > 天 > 小时）
  if (seconds >= SECONDS_PER_DAY) {
    var months = Math.floor(seconds / SECONDS_PER_MONTH);
    var remaining = seconds % SECONDS_PER_MONTH;
    var days = Math.floor(remaining / SECONDS_PER_DAY);
    remaining %= SECONDS_PER_DAY;
    var hours = Math.floor(remaining / SECONDS_PER_HOUR);
    // 动态构建非零单位部分
    return [months > 0 ? months + "m" : null, days > 0 ? days + "d" : null, hours > 0 && months === 0 ? hours + "h" : null].filter(Boolean).join(' ');
  }
  // 处理小时间单位（小时 > 分钟 > 秒）
  else {
    var hours = Math.floor(seconds / SECONDS_PER_HOUR);
    var minutes = Math.floor(seconds % SECONDS_PER_HOUR / 60);
    var secs = seconds % 60;
    // 按需隐藏小时部分
    return hours > 0 ? pad(hours) + ":" + pad(minutes) + ":" + pad(secs) : pad(minutes) + ":" + pad(secs);
  }
}
// 辅助函数：两位数补零
function pad(num) {
  return num.toString().padStart(2, '0');
}