function calculateSelector(element) {
let selector = '';
for(let current = element; current?.nodeType === 1; current = current.parentElement) {
if(current.id) {
selector = `#${current.id}>${selector}`;
break;
}
const tag = current.tagName.toLowerCase();
const classes = Array.from(current.classList, cls => `.${cls}`).join('');
selector = `${tag}${classes}>${selector}`;
}
return selector.slice(0, -1);
}