function operatorFunctions(p, operator) {
var selectedHidden = selection.hid(p);
var res = selectedHidden[0];
for (let i = 1; i < selectedHidden.length; i++) {
var tmp = res;
res = res[operator](selectedHidden[i]);
tmp.remove();
}
for (const hiddenItem of selectedHidden) {
hiddenItem.remove();
var mainItem = mainKids(p)[hiddenItem.name.replace("hidden", "main")];
mainItem.remove();
Inv.deletePath(mainItem, p, false);
}
selection.clear(p);
var success = false;
if (
(res instanceof p.Path && res.segments.length > 0) ||
(res instanceof p.CompoundPath && res.children.length > 0)
) {
res.name = `$hiddenCompoundPath${Date.now()}`;
var mainRes = createMainFromHidden(p, res, canvVals.gridScale);
selection.clear(p);
selection.push(mainKids(p)[res.name.replace("hidden", "main")]);
Inv.addPath(mainRes, p);
}
Inv.recalcIntersections(p);
document.dispatchEvent(new CustomEvent("formChange"));
p.view.draw();
}