import{parse as t,TYPE as n}from"@formatjs/icu-messageformat-parser";import{T as e,a as r,b as s,c as o,d as u,e as i,f as c}from"./types-DqTLNw7x.js";function a(n){const e=f(t(n));return 0===e.length?"":1===e.length&&"string"==typeof e[0]?e[0]:e}function f(t){const n=[];for(const e of t){const t=p(e);"string"==typeof t&&n.length>0&&"string"==typeof n[n.length-1]?n[n.length-1]+=t:n.push(t)}return n}function l(t){const n=f(t);if(0===n.length)return"";if(1===n.length){const t=n[0];if("string"==typeof t||t===e)return t}return n}function p(t){switch(t.type){case n.literal:return t.value;case n.argument:return[t.value];case n.number:return function(t){const n=[t.value,r],e=function(t){if(!t)return;if("string"==typeof t)return t;if("parsedOptions"in t){const n=t.parsedOptions;return Object.keys(n).length>0?n:void 0}return}(t.style);void 0!==e&&n.push(e);return n}(t);case n.date:return function(t){const n=[t.value,s],e=g(t.style);void 0!==e&&n.push(e);return n}(t);case n.time:return function(t){const n=[t.value,o],e=g(t.style);void 0!==e&&n.push(e);return n}(t);case n.select:return function(t){const n={};for(const[e,r]of Object.entries(t.options))n[e]=l(r.value);return[t.value,u,n]}(t);case n.plural:return function(t){const n={};for(const[e,r]of Object.entries(t.options))n[e]=l(r.value);return[t.value,"ordinal"===t.pluralType?i:c,n]}(t);case n.pound:return e;case n.tag:return function(t){const n=f(t.children),e=[t.value];0===n.length?e.push(""):e.push(...n);return e}(t);default:throw new Error(`Unknown AST node type: ${t.type}`)}}function g(t){if(t){if("string"==typeof t)return t;if("parsedOptions"in t){const n=t.parsedOptions;return Object.keys(n).length>0?n:void 0}}}export{a as default};