import{List as n}from"../utils/List.mjs";function t(n){return"node"in n?n.node:t(n.match[0])}function a(n){return"node"in n?n.node:a(n.match[n.match.length-1])}function e(e,o,c,r,i){const s=[];return null!==c.matched&&function c(u){if(null!==u.syntax&&u.syntax.type===r&&u.syntax.name===i){const c=t(u),r=a(u);e.syntax.walk(o,function(t,a,e){if(t===c){const t=new n;do{if(t.appendData(a.data),a.data===r)break;a=a.next}while(null!==a);s.push({parent:e,nodes:t})}})}Array.isArray(u.match)&&u.match.forEach(c)}(c.matched),s}export{e as matchFragments};