function flattenRuleRanges(e){const n=[],t=e.media||[];for(let s=0;s<t.length;++s){const e=t[s];e.range&&n.push({range:e.range,name:"media #"+s})}for(let s=0;s<e.selectors.length;++s){const t=e.selectors[s];t.range&&n.push({range:t.range,name:"selector #"+s})}e.style.range&&n.push({range:e.style.range,name:"style range"});const r=e.style.allProperties();for(let s=0;s<r.length;++s){const e=r[s];e.range&&n.push({range:e.range,name:"property >>"+e.text+"<<"})}return n}function compareRuleRanges(e,n){if(e.selectorText!==n.selectorText)return TestRunner.addResult("Error: rule selectors are not equal: "+e.selectorText+" != "+n.selectorText),!1;const t=flattenRuleRanges(e),r=flattenRuleRanges(n);if(t.length!==r.length)return TestRunner.addResult("Error: rule range amount is not equal: "+t.length+" != "+r.length),!1;for(let s=0;s<t.length;++s){const e=t[s],n=r[s];if(e.name!==n.name)return TestRunner.addResult("Error: rule names are not equal: "+e.name+" != "+n.name),!1;if(!e.range.equal(n.range))return TestRunner.addResult("Error: ranges '"+e.name+"' are not equal: "+e.range.toString()+" != "+n.range.toString()),!1}return TestRunner.addResult(t.length+" rule ranges are equal."),!0}self.ElementsTestRunner=self.ElementsTestRunner||{},ElementsTestRunner.validateRuleRanges=function(e,n,t){function r(){const e=ElementsTestRunner.getMatchedRules();if(e.length!==n.length)return TestRunner.addResult(String.sprintf("Error: rules sizes are not equal! Expected: %d, actual: %d",e.length,n.length)),void TestRunner.completeTest();for(let t=0;t<e.length;++t)if(!compareRuleRanges(n[t],e[t]))return void TestRunner.completeTest();t()}ElementsTestRunner.selectNodeAndWaitForStyles("other",(function(){ElementsTestRunner.selectNodeAndWaitForStyles(e,r)}))},ElementsTestRunner.getMatchedRules=function(){const e=[];for(const n of UI.panels.elements._stylesWidget._sectionBlocks)for(const t of n.sections){const n=t.style().parentRule;n&&e.push(n)}return e};