import{isNumber as n}from"../utils/validateTypes.mjs";import e from"./preprocessWarnings.mjs";function o(o){const t=["TAP version 14",`1..${o.length}`];for(const[r,i]of o.entries()){e(i);const o=i.ignored?" # SKIP ignored":"",u=i.errored?"not ":"";if(t.push(`${u}ok ${r+1} - ${s(i.source)}${o}`),u){t.push("  ---");const e={};for(const{rule:n,...o}of i.warnings){const s=n||"unknown";(e[s]??=[]).push(o)}for(const[o,s]of Object.entries(e)){t.push(`  ${o}:`);for(const{text:e,severity:o,line:r,column:i,endLine:u,endColumn:c}of s)t.push(`    - message: ${JSON.stringify(e)}`,`      severity: ${o}`,`      line: ${r}`,`      column: ${i}`),n(u)&&t.push(`      endLine: ${u}`),n(c)&&t.push(`      endColumn: ${c}`)}t.push("  ...")}}return t.push(""),t.join("\n")}function s(n){if(!n)return n;let e="";for(const o of n)switch(o.codePointAt(0)){case 92:case 35:e+="\\",e+=o;break;default:e+=o}return e}export{o as default};