import{P as s,Q as e,S as t,U as r}from"./main-4ba31b39.js";import{g as l,i as n,u as o,m as i,h as a}from"./c.45a36679.js";const u=(s,e,t)=>{const r=new Map;for(let l=e;l<=t;l++)r.set(s[l],l);return r},f=s(class extends e{constructor(s){if(super(s),s.type!==t.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,e,t){let r;void 0===t?t=e:void 0!==e&&(r=e);const l=[],n=[];let o=0;for(const e of s)l[o]=r?r(e,o):o,n[o]=t(e,o),o++;return{values:n,keys:l}}render(s,e,t){return this.dt(s,e,t).values}update(s,[e,t,f]){var c;const d=l(s),{values:h,keys:p}=this.dt(e,t,f);if(!Array.isArray(d))return this.at=p,h;const v=null!==(c=this.at)&&void 0!==c?c:this.at=[],y=[];let m,g,x=0,b=d.length-1,j=0,k=h.length-1;for(;x<=b&&j<=k;)if(null===d[x])x++;else if(null===d[b])b--;else if(v[x]===p[j])y[j]=n(d[x],h[j]),x++,j++;else if(v[b]===p[k])y[k]=n(d[b],h[k]),b--,k--;else if(v[x]===p[k])y[k]=n(d[x],h[k]),o(s,y[k+1],d[x]),x++,k--;else if(v[b]===p[j])y[j]=n(d[b],h[j]),o(s,d[x],d[b]),b--,j++;else if(void 0===m&&(m=u(p,j,k),g=u(v,x,b)),m.has(v[x]))if(m.has(v[b])){const e=g.get(p[j]),t=void 0!==e?d[e]:null;if(null===t){const e=o(s,d[x]);n(e,h[j]),y[j]=e}else y[j]=n(t,h[j]),o(s,d[x],t),d[e]=null;j++}else i(d[b]),b--;else i(d[x]),x++;for(;j<=k;){const e=o(s,y[k+1]);n(e,h[j]),y[j++]=e}for(;x<=b;){const s=d[x++];null!==s&&i(s)}return this.at=p,a(s,y),r}});export{f as c};
