import{escapeHtml as y}from"@mdit/helper";import{isSpace as B}from"markdown-it/lib/common/utils.mjs";const j=3,x="@tab",T=x+":active",q=x.length,I=T.length,R=(r,o,t)=>{if(r.src.charCodeAt(o)!==64)return!1;let a=1;for(;ah&&c(t,a,b,h)=>{if(o.state!==r)return!1;const c=t.bMarks[a]+t.tShift[a],p=t.eMarks[a],n=t.sCount[a],e=R(t,c,p);if(e===!1)return!1;if(h)return!0;let s=a+1,l=!1;for(;su;){if(t.src.charCodeAt(k)===35){for(m=k-1;t.src.charCodeAt(m)===92;)m--;if((k-m)%2===1)break}k--}let $,S="";k!==u?(S=t.src.slice(t.skipSpaces(k+1),C),$=t.src.slice(u,t.skipSpacesBack(k,u))):$=t.src.slice(u,C),f.block=!0,f.markup=x,f.info=$,f.meta={active:e.isActive},S&&(f.meta.id=S),f.map=[a,s-(l?1:0)],t.md.block.tokenize(t,a+1,s+(l?0:1));const A=t.push(`${r}_tab_close`,"",-1);return A.block=!0,A.markup="",t.parentType=v,t.lineMax=i,t.blkIndent=d,t.line=s+(l?0:1),!0},z=(r,o)=>(t,a,b,h)=>{const c=t.bMarks[a]+t.tShift[a],p=t.eMarks[a],n=t.sCount[a];if(t.src.charCodeAt(c)!==58)return!1;let e=c+1;for(;e<=p&&t.src.charCodeAt(e)===58;)e++;const s=e-c;if(s=s&&(e=t.skipSpaces(e),e>=M)){d=!0;break}}}const u=t.parentType,C=t.lineMax,k=t.blkIndent,m=o.state;t.parentType=`${r}_tabs`,t.lineMax=i-(d?1:0),t.blkIndent=n;const $=":".repeat(s);let S="";if(l){f=t.skipSpaces(f);const _=t.skipSpacesBack(p,f);f<_&&(S=t.src.slice(f,_))}const A=t.push(`${r}_tabs_open`,"",1);A.markup=$,A.block=!0,A.info=r,A.meta={id:S},A.map=[a,i-(d?1:0)],o.state=r,t.md.block.tokenize(t,a+1,i-(d?1:0)),o.state=m;const g=t.push(`${r}_tabs_close`,"",-1);return g.markup=$,g.block=!0,t.parentType=u,t.lineMax=C,t.blkIndent=k,t.line=i+(d?1:0),!0},O=r=>(o,t)=>{const a=[];let b=-1,h=!1,c=0;for(let p=t+1;p0)continue;if(s===`${r}_tab_open`){h=!0,e.index=a.length,e.active&&(b===-1?b=a.length:e.active=!1),a.push({title:l,index:a.length,id:e.id,isActive:e.active});continue}if(s===`${r}_tab_close`)continue;h||(o[p].type=`${r}_tabs_empty`,o[p].hidden=!0)}}return{active:b,data:a}},D=(r,o)=>{const{info:t,meta:a}=r[o];return{title:t,index:a.index,id:a.id,isActive:a.active}},J={state:null},E=(r,o)=>{const{name:t="tabs",openRender:a=(n,e,s,l,v,i)=>{const{active:d,data:f}=n,u=e[s];u.attrJoin("class",`${t}-tabs-wrapper`),u.meta.id&&u.attrJoin("data-id",u.meta.id);const C=f.map(({title:k,id:m},$)=>``);return`
${C.join(` `)}
`},closeRender:b=()=>`
`,tabOpenRender:h=(n,e,s,l,v,i)=>{const d=e[s];return d.attrJoin("class",`${t}-tab-content${n.isActive?" active":""}`),d.attrSet("data-index",n.index.toString()),n.id&&d.attrSet("data-id",n.id.toString()),n.isActive&&d.attrJoin("data-active",""),` `},tabCloseRender:c=()=>` `}=o??{},p=O(t);r.block.ruler.before("fence",`${t}_tabs`,z(t,J),{alt:["paragraph","reference","blockquote","list"]}),r.block.ruler.before("paragraph",`${t}_tab`,w(t,J),{alt:["paragraph","reference","blockquote","list"]}),r.renderer.rules[`${t}_tabs_open`]=(n,e,s,l,v)=>{const i=p(n,e);return a(i,n,e,s,l,v)},r.renderer.rules[`${t}_tabs_close`]=b,r.renderer.rules[`${t}_tab_open`]=(n,e,...s)=>{const l=D(n,e);return h(l,n,e,...s)},r.renderer.rules[`${t}_tab_close`]=c};export{E as tab}; //# sourceMappingURL=index.js.map