import{isAtRule as e,isRule as t,isDeclaration as r}from"../../utils/typeGuards.mjs";import o from"../../utils/blockString.mjs";import s from"../../utils/fixEmptyLinesBefore.mjs";import i from"../../utils/getPreviousNonSharedLineCommentNode.mjs";import m from"../../utils/hasEmptyLine.mjs";import n from"../../utils/isAfterComment.mjs";import p from"../../utils/isCustomProperty.mjs";import l from"../../utils/isFirstNested.mjs";import u from"../../utils/isSingleLineString.mjs";import a from"../../utils/isStandardSyntaxDeclaration.mjs";import f from"../../utils/optionsMatches.mjs";import c from"../../utils/report.mjs";import d from"../../utils/ruleMessages.mjs";import y from"../../utils/validateOptions.mjs";const g="custom-property-empty-line-before",j=d(g,{expected:"Expected empty line before custom property",rejected:"Unexpected empty line before custom property"}),x=(r,i,d)=>(x,w)=>{y(w,g,{actual:r,possible:["always","never"]},{actual:i,possible:{except:["after-comment","after-custom-property","first-nested"],ignore:["after-comment","after-custom-property","first-nested","inside-single-line-block"]},optional:!0})&&x.walkDecls(y=>{const x=y.prop,S=y.parent;if(!a(y))return;if(!p(x))return;if(f(i,"ignore","after-comment")&&n(y))return;if(f(i,"ignore","after-custom-property")&&b(y))return;if(f(i,"ignore","first-nested")&&l(y))return;if(f(i,"ignore","inside-single-line-block")&&null!=S&&(e(S)||t(S))&&u(o(S)))return;let N="always"===r;(f(i,"except","first-nested")&&l(y)||f(i,"except","after-comment")&&n(y)||f(i,"except","after-custom-property")&&b(y))&&(N=!N);if(N===m(y.raws.before))return;const h=N?j.expected:j.rejected,k=N?"add":"remove";c({message:h,messageArgs:[],node:y,result:w,ruleName:g,fix:{apply:()=>s({node:y,newline:d.newline,action:k}),node:y.parent}})})};function b(e){const t=i(e);return null!=t&&r(t)&&p(t.prop)}x.ruleName=g,x.messages=j,x.meta={url:"https://stylelint.io/user-guide/rules/custom-property-empty-line-before",fixable:!0};export{x as default};