import{store,getContext}from"@wordpress/interactivity";store("frontend-admin/repeater",{actions:{addRow:()=>{const o=getContext();o.maxRows>0&&o.rows.length>=o.maxRows||(o.rows.push({id:o.rows.length>0?o.rows[o.rows.length-1].id+1:1}),o.activeRow=o.rows.length-1)},duplicateRow:()=>{const o=getContext();if(o.maxRows>0&&o.rows.length>=o.maxRows)return;const t=o.row.id,e=o.rows.findIndex((o=>o.id===t)),s={...o.rows[e],id:o.rows[o.rows.length-1].id+1};o.rows.splice(e+1,0,s),o.activeRow=e+1},removeRow:()=>{const o=getContext(),t=o.rows,e=o.row.id,s=t.findIndex((o=>o.id===e));o.rows.splice(s,1),o.activeRow>=o.rows.length&&(o.activeRow=o.rows.length-1)}}});