function n(n,r){for(const o of n??[]){const c=new Set(e(o));function f(n){return!c.has(n)&&(r(n)||(n.children??[]).some(f))}if(f(o))return[]}return t(n,r)}function t(n,t){const o=new Set;for(const c of n??[])for(const n of e(c))r(n,t)&&o.add(n.key);return[...o]}function e(n){return((n.children?.find(n=>"main"===n.type))?.children??[]).filter(n=>"step"===n.type)}function r(n,t){return t(n)||(n.children??[]).some(n=>r(n,t))}export{n,t};