import{R as u,bX as h,bY as T,a as w}from"./index-D92x6h1h.js";function $(t){return t.subtitle?.trim()||t.summary?.trim()||t.description?.trim()||void 0}const m=/\[(\/?)([A-Z]+)(?:\s+([\w#]+))?\]/gi,P=new Set(["B","I","COLOR"]),C=new Set(["UPPERCASE","LOWERCASE","CAPITALIZE"]);function O(t){return t.replaceAll(/\b\w/g,e=>e.toUpperCase())}function p(t,e){return t.map(n=>{if(typeof n=="string")return e(n);const r=n.children??[];if(Array.isArray(r)){const o=p(r,e);return u(n.type,n.props??null,o)}return n})}function E(t){return t==="UPPERCASE"?e=>e.toUpperCase():t==="LOWERCASE"?e=>e.toLowerCase():O}function N(t,e,n){return t==="B"?u("span",{style:{fontWeight:"bold"}},n):t==="I"?u("span",{style:{fontStyle:"italic"}},n):t==="COLOR"?u("span",{style:{color:e}},n):null}function x(t,e,n,r,o){if(r==="COLOR"&&(!o||!/^[\w#]+$/.test(o)))return{nodes:[t.slice(e,n)],nextPos:n};const s=l(t,n,r),i=N(r,o,s.nodes);return{nodes:i?[i]:[],nextPos:s.end}}function b(t,e,n){const r=l(t,e,n);return{nodes:p(r.nodes,E(n)),nextPos:r.end}}function R(t,e,n,r,o,s){return o==="CR"&&!r?{nodes:[u("br")],nextPos:n}:!r&&P.has(o)?x(t,e,n,o,s):!r&&C.has(o)?b(t,n,o):{nodes:[t.slice(e,n)],nextPos:n}}function l(t,e,n){const r=[];let o=e;for(;o<t.length;){m.lastIndex=o;const s=m.exec(t);if(!s)return r.push(t.slice(o)),{nodes:r,end:t.length};const i=s.index,a=i+s[0].length,f=s[1]==="/",g=s[2].toUpperCase(),L=s[3];if(i>o&&r.push(t.slice(o,i)),f&&g===n)return{nodes:r,end:a};const d=R(t,i,a,f,g,L);r.push(...d.nodes),o=d.nextPos}return{nodes:r,end:t.length}}function F(t){return l(t,0,null).nodes}function k(t){return D(F(t))}function D(t){let e="";for(const n of t)typeof n=="string"?e+=n:n.type==="br"?e+=`
`:Array.isArray(n.children)&&(e+=D(n.children));return e}function G(t){return e=>{const n=typeof e=="string"?e:"";return n&&t()?k(n):n}}const Y=/(%[MmsSyYdhHIpPq]+)/,I={month:"2-digit",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1};function S(t,e,n){if(!e||!Y.test(e))return t.toLocaleString(n,I);let r=e.replaceAll("%MMMM",t.toLocaleDateString(n,{month:"long"})).replaceAll("%MMM",t.toLocaleDateString(n,{month:"short"})).replaceAll("%dddd",t.toLocaleDateString(n,{weekday:"long"})).replaceAll("%ddd",t.toLocaleDateString(n,{weekday:"short"}));const o=[[/%[yY]+/g,t.getFullYear()],[/%M+/g,t.getMonth()+1],[/%d+/g,t.getDate()],[/%[hH]+/g,t.getHours()],[/%I+/g,t.getHours()%12||12],[/%p/g,t.getHours()>=12?"PM":"AM"],[/%P/g,t.getHours()>=12?"pm":"am"],[/%m+/g,t.getMinutes()],[/%s+/g,t.getSeconds()],[/%q+/g,Math.floor((t.getMonth()+3)/3)],[/%S/g,t.getMilliseconds()]];for(const[s,i]of o)r=r.replace(s,a=>typeof i=="string"?i:a.length===2?String(i):String(i).padStart(4,"0").slice(1-a.length));return r}function c(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function y(t){return t.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function A(t,e){if(c(t,e))return y(t);const n=new Date(e);n.setDate(e.getDate()-1);const r=new Date(e);if(r.setDate(e.getDate()+1),c(t,n)||c(t,r)){const o=c(t,r)?1:-1,s=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(o,"day");return`${s.charAt(0).toUpperCase()+s.slice(1)} ${y(t)}`}return t.getFullYear()===e.getFullYear()?t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"2-digit"})}function M(){return T()?w().data?.date_mask??"":""}const z=t=>{if(typeof t!="number"||t<=0||Number.isNaN(t))return"";const e=new Date(t*1e3);if(h())return A(e,new Date);const n=M();return n?S(e,n):e.toLocaleString(void 0,{weekday:"short",day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})},_=/%(?:HH|hh|mm|ss|aa)/,B=t=>{let e;if(typeof t=="number"?e=t:typeof t=="string"?e=Number(t):e=Number.NaN,!Number.isFinite(e)||e<=0)return"";const n=new Date(e*1e3),r=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0");return`${r}-${o}-${s}`},W=t=>{if(typeof t!="number"||t<=0||Number.isNaN(t))return"";const e=new Date(t*1e3);if(h())return A(e,new Date);const n=M();return n&&!_.test(n)?S(e,n):e.toLocaleDateString(void 0,{weekday:"short",day:"2-digit",month:"2-digit",year:"numeric"})},H=864e5;function K(t){const e=new Date(t);return e.setHours(0,0,0,0),e.getTime()}function q(t){return Math.floor(K(t*1e3)/1e3)}function Z(t,e){const n=new Date(t*1e3);return n.setDate(n.getDate()+e),Math.floor(n.getTime()/1e3)}function X(t,e){return Math.round((t-e)/H)}export{B as a,k as b,q as c,Z as d,$ as e,z as f,W as g,X as l,G as m,F as p,K as s};
