import{SEVERITY_ERROR as e}from"./constants.mjs";import r from"node:process";function t(t,n){let s,i;if(t&&t.root){t.root.source&&(i=t.root.source.input.file,!i&&"id"in t.root.source.input&&(i=t.root.source.input.id));const e=(!r.noDeprecation?t.messages.filter(e=>"deprecation"===e.stylelintType):[]).map(e=>({text:e.text,reference:e.stylelintReference})),n=t.messages.filter(e=>"invalidOption"===e.stylelintType).map(e=>({text:e.text})),o=t.messages.filter(e=>"parseError"===e.stylelintType);t.messages=t.messages.filter(e=>"deprecation"!==e.stylelintType&&"invalidOption"!==e.stylelintType&&"parseError"!==e.stylelintType),s={source:i,deprecations:e,invalidOptionWarnings:n,parseErrors:o,errored:t.stylelint.stylelintError,warnings:t.messages.map(e=>({line:e.line,column:e.column,endLine:e.endLine,endColumn:e.endColumn,fix:e.fix,rule:e.rule,severity:e.severity,text:e.text,url:e.url})),ignored:t.stylelint.ignored,_postcssResult:t}}else{if(!n)throw new Error("createPartialStylelintResult must be called with either postcssResult or CssSyntaxError");if("CssSyntaxError"!==n.name)throw n;s={source:n.file||"<input css 1>",deprecations:[],invalidOptionWarnings:[],parseErrors:[],errored:!0,warnings:[{line:n.line,column:n.column,endLine:n.endLine,endColumn:n.endColumn,rule:n.name,severity:e,text:`${n.reason} (${n.name})`}]}}return s}export{t as default};