viewgate-wrapper 1.11.8 → 1.11.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7676,9 +7676,9 @@ const aw = (t) => {
7676
7676
  window.addEventListener("popstate", d);
7677
7677
  const H = window.history.pushState, C = window.history.replaceState;
7678
7678
  return window.history.pushState = function(...I) {
7679
- H.apply(this, I), d();
7679
+ H.apply(this, I), setTimeout(d, 0);
7680
7680
  }, window.history.replaceState = function(...I) {
7681
- C.apply(this, I), d();
7681
+ C.apply(this, I), setTimeout(d, 0);
7682
7682
  }, () => {
7683
7683
  window.removeEventListener("popstate", d), window.history.pushState = H, window.history.replaceState = C;
7684
7684
  };
@@ -9,7 +9,7 @@ React keys must be passed directly to JSX without using spread:
9
9
  display: none !important;
10
10
  }`,Tf=(t,A)=>{Kf(t,`.${fn}${Sf}${ga}
11
11
  .${hn}${Lf}${ga}`,A)},Kf=(t,A,e)=>{const r=t.ownerDocument;if(r){const s=r.createElement("style");s.textContent=A,e&&(s.nonce=e),t.appendChild(s)}},Df=(t,A)=>{const e=t.ownerDocument.createElement("base");e.href=A;const r=t.getElementsByTagName("head").item(0);r?.insertBefore(e,r?.firstChild??null)};class H{constructor(A,e){this.type=0,this.x=A,this.y=e}add(A,e){return new H(this.x+A,this.y+e)}}const it=(t,A,e)=>new H(t.x+(A.x-t.x)*e,t.y+(A.y-t.y)*e);class he{constructor(A,e,r,s){this.type=1,this.start=A,this.startControl=e,this.endControl=r,this.end=s}subdivide(A,e){const r=it(this.start,this.startControl,A),s=it(this.startControl,this.endControl,A),n=it(this.endControl,this.end,A),o=it(r,s,A),i=it(s,n,A),a=it(o,i,A);return e?new he(this.start,r,o,a):new he(a,i,n,this.end)}add(A,e){return new he(this.start.add(A,e),this.startControl.add(A,e),this.endControl.add(A,e),this.end.add(A,e))}reverse(){return new he(this.end,this.endControl,this.startControl,this.start)}}const GA=t=>t.type===1;class Of{constructor(A){const e=A.styles,r=A.bounds;let[s,n]=vt(e.borderTopLeftRadius,r.width,r.height),[o,i]=vt(e.borderTopRightRadius,r.width,r.height),[a,l]=vt(e.borderBottomRightRadius,r.width,r.height),[c,B]=vt(e.borderBottomLeftRadius,r.width,r.height);const f=[];f.push((s+o)/r.width),f.push((c+a)/r.width),f.push((n+B)/r.height),f.push((i+l)/r.height);const u=Math.max(...f);u>1&&(s/=u,n/=u,o/=u,i/=u,a/=u,l/=u,c/=u,B/=u);const h=r.width-o,w=r.height-l,U=r.width-a,y=r.height-B,p=e.borderTopWidth,x=e.borderRightWidth,T=e.borderBottomWidth,F=e.borderLeftWidth,K=O(e.paddingTop,A.bounds.width),_=O(e.paddingRight,A.bounds.width),AA=O(e.paddingBottom,A.bounds.width),S=O(e.paddingLeft,A.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||n>0?iA(r.left+F/3,r.top+p/3,s-F/3,n-p/3,J.TOP_LEFT):new H(r.left+F/3,r.top+p/3),this.topRightBorderDoubleOuterBox=s>0||n>0?iA(r.left+h,r.top+p/3,o-x/3,i-p/3,J.TOP_RIGHT):new H(r.left+r.width-x/3,r.top+p/3),this.bottomRightBorderDoubleOuterBox=a>0||l>0?iA(r.left+U,r.top+w,a-x/3,l-T/3,J.BOTTOM_RIGHT):new H(r.left+r.width-x/3,r.top+r.height-T/3),this.bottomLeftBorderDoubleOuterBox=c>0||B>0?iA(r.left+F/3,r.top+y,c-F/3,B-T/3,J.BOTTOM_LEFT):new H(r.left+F/3,r.top+r.height-T/3),this.topLeftBorderDoubleInnerBox=s>0||n>0?iA(r.left+F*2/3,r.top+p*2/3,s-F*2/3,n-p*2/3,J.TOP_LEFT):new H(r.left+F*2/3,r.top+p*2/3),this.topRightBorderDoubleInnerBox=s>0||n>0?iA(r.left+h,r.top+p*2/3,o-x*2/3,i-p*2/3,J.TOP_RIGHT):new H(r.left+r.width-x*2/3,r.top+p*2/3),this.bottomRightBorderDoubleInnerBox=a>0||l>0?iA(r.left+U,r.top+w,a-x*2/3,l-T*2/3,J.BOTTOM_RIGHT):new H(r.left+r.width-x*2/3,r.top+r.height-T*2/3),this.bottomLeftBorderDoubleInnerBox=c>0||B>0?iA(r.left+F*2/3,r.top+y,c-F*2/3,B-T*2/3,J.BOTTOM_LEFT):new H(r.left+F*2/3,r.top+r.height-T*2/3),this.topLeftBorderStroke=s>0||n>0?iA(r.left+F/2,r.top+p/2,s-F/2,n-p/2,J.TOP_LEFT):new H(r.left+F/2,r.top+p/2),this.topRightBorderStroke=s>0||n>0?iA(r.left+h,r.top+p/2,o-x/2,i-p/2,J.TOP_RIGHT):new H(r.left+r.width-x/2,r.top+p/2),this.bottomRightBorderStroke=a>0||l>0?iA(r.left+U,r.top+w,a-x/2,l-T/2,J.BOTTOM_RIGHT):new H(r.left+r.width-x/2,r.top+r.height-T/2),this.bottomLeftBorderStroke=c>0||B>0?iA(r.left+F/2,r.top+y,c-F/2,B-T/2,J.BOTTOM_LEFT):new H(r.left+F/2,r.top+r.height-T/2),this.topLeftBorderBox=s>0||n>0?iA(r.left,r.top,s,n,J.TOP_LEFT):new H(r.left,r.top),this.topRightBorderBox=o>0||i>0?iA(r.left+h,r.top,o,i,J.TOP_RIGHT):new H(r.left+r.width,r.top),this.bottomRightBorderBox=a>0||l>0?iA(r.left+U,r.top+w,a,l,J.BOTTOM_RIGHT):new H(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=c>0||B>0?iA(r.left,r.top+y,c,B,J.BOTTOM_LEFT):new H(r.left,r.top+r.height),this.topLeftPaddingBox=s>0||n>0?iA(r.left+F,r.top+p,Math.max(0,s-F),Math.max(0,n-p),J.TOP_LEFT):new H(r.left+F,r.top+p),this.topRightPaddingBox=o>0||i>0?iA(r.left+Math.min(h,r.width-x),r.top+p,h>r.width+x?0:Math.max(0,o-x),Math.max(0,i-p),J.TOP_RIGHT):new H(r.left+r.width-x,r.top+p),this.bottomRightPaddingBox=a>0||l>0?iA(r.left+Math.min(U,r.width-F),r.top+Math.min(w,r.height-T),Math.max(0,a-x),Math.max(0,l-T),J.BOTTOM_RIGHT):new H(r.left+r.width-x,r.top+r.height-T),this.bottomLeftPaddingBox=c>0||B>0?iA(r.left+F,r.top+Math.min(y,r.height-T),Math.max(0,c-F),Math.max(0,B-T),J.BOTTOM_LEFT):new H(r.left+F,r.top+r.height-T),this.topLeftContentBox=s>0||n>0?iA(r.left+F+S,r.top+p+K,Math.max(0,s-(F+S)),Math.max(0,n-(p+K)),J.TOP_LEFT):new H(r.left+F+S,r.top+p+K),this.topRightContentBox=o>0||i>0?iA(r.left+Math.min(h,r.width+F+S),r.top+p+K,h>r.width+F+S?0:o-F+S,i-(p+K),J.TOP_RIGHT):new H(r.left+r.width-(x+_),r.top+p+K),this.bottomRightContentBox=a>0||l>0?iA(r.left+Math.min(U,r.width-(F+S)),r.top+Math.min(w,r.height+p+K),Math.max(0,a-(x+_)),l-(T+AA),J.BOTTOM_RIGHT):new H(r.left+r.width-(x+_),r.top+r.height-(T+AA)),this.bottomLeftContentBox=c>0||B>0?iA(r.left+F+S,r.top+y,Math.max(0,c-(F+S)),B-(T+AA),J.BOTTOM_LEFT):new H(r.left+F+S,r.top+r.height-(T+AA))}}var J;(function(t){t[t.TOP_LEFT=0]="TOP_LEFT",t[t.TOP_RIGHT=1]="TOP_RIGHT",t[t.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",t[t.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(J||(J={}));const iA=(t,A,e,r,s)=>{const n=4*((Math.sqrt(2)-1)/3),o=e*n,i=r*n,a=t+e,l=A+r;switch(s){case J.TOP_LEFT:return new he(new H(t,l),new H(t,l-i),new H(a-o,A),new H(a,A));case J.TOP_RIGHT:return new he(new H(t,A),new H(t+o,A),new H(a,l-i),new H(a,l));case J.BOTTOM_RIGHT:return new he(new H(a,A),new H(a,A+i),new H(t+o,l),new H(t,l));case J.BOTTOM_LEFT:default:return new he(new H(a,l),new H(a-o,l),new H(t,A+i),new H(t,A))}},Pr=t=>[t.topLeftBorderBox,t.topRightBorderBox,t.bottomRightBorderBox,t.bottomLeftBorderBox],Rf=t=>[t.topLeftContentBox,t.topRightContentBox,t.bottomRightContentBox,t.bottomLeftContentBox],Xr=t=>[t.topLeftPaddingBox,t.topRightPaddingBox,t.bottomRightPaddingBox,t.bottomLeftPaddingBox];class ua{constructor(A,e,r){this.offsetX=A,this.offsetY=e,this.matrix=r,this.type=0,this.target=6}}class Wr{constructor(A,e){this.path=A,this.target=e,this.type=1}}class Mf{constructor(A){this.opacity=A,this.type=2,this.target=6}}class Gt{constructor(A){this.applyClip=A,this.type=3,this.target=6}}const Nf=t=>t.type===0,fa=t=>t.type===1,Gf=t=>t.type===2,Vf=t=>t.type===3,ha=(t,A)=>t.length===A.length?t.some((e,r)=>e===A[r]):!1,_f=(t,A,e,r,s)=>t.map((n,o)=>{switch(o){case 0:return n.add(A,e);case 1:return n.add(A+r,e);case 2:return n.add(A+r,e+s);case 3:return n.add(A,e+s)}return n});class wa{constructor(A){this.element=A,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}}class pa{constructor(A,e){if(this.container=A,this.parent=e,this.effects=[],this.curves=new Of(this.container),this.container.styles.opacity<1&&this.effects.push(new Mf(this.container.styles.opacity)),this.container.styles.rotate!==null){const r=this.container.styles.transformOrigin,s=this.container.bounds.left+O(r[0],this.container.bounds.width),n=this.container.bounds.top+O(r[1],this.container.bounds.height),i=this.container.styles.rotate*Math.PI/180,a=Math.cos(i),l=Math.sin(i),c=[a,l,-l,a,0,0];this.effects.push(new ua(s,n,c))}if(this.container.styles.transform!==null){const r=this.container.styles.transformOrigin,s=this.container.bounds.left+O(r[0],this.container.bounds.width),n=this.container.bounds.top+O(r[1],this.container.bounds.height),o=this.container.styles.transform;this.effects.push(new ua(s,n,o))}if(this.container.styles.overflowX!==0){const r=Pr(this.curves),s=Xr(this.curves);ha(r,s)?this.effects.push(new Wr(r,6)):(this.effects.push(new Wr(r,2)),this.effects.push(new Wr(s,4)))}if(this.container.styles.clipPath.type!==0){const r=kf(this.container.styles.clipPath,this.container.bounds);r&&this.effects.push(r)}}getEffects(A){let e=[2,3].indexOf(this.container.styles.position)===-1,r=this.parent;const s=this.effects.slice(0);for(;r;){const n=r.effects.filter(o=>!fa(o));if(e||r.container.styles.position!==0||!r.parent){if(e=[2,3].indexOf(r.container.styles.position)===-1,r.container.styles.overflowX!==0){const o=Pr(r.curves),i=Xr(r.curves);ha(o,i)||s.unshift(new Wr(i,6))}s.unshift(...n)}else s.unshift(...n);r=r.parent}return s.filter(n=>aA(n.target,A))}}const Qa=(t,A,e,r,s)=>t==="closest-side"?Math.min(A-e,r-A):t==="farthest-side"?Math.max(A-e,r-A):O(t,s),kf=(t,A)=>{const{left:e,top:r,width:s,height:n}=A;switch(t.type){case 1:{const o=O(t.left,s),i=O(t.top,n),a=e+o,l=r+i,c=Math.max(0,s-o-O(t.right,s)),B=Math.max(0,n-i-O(t.bottom,n));return new Gt(f=>{f.beginPath(),f.rect(a,l,c,B),f.clip()})}case 2:{const o=e+O(t.cx,s),i=r+O(t.cy,n);let a;return t.radius==="closest-side"?a=Math.min(o-e,i-r,e+s-o,r+n-i):t.radius==="farthest-side"?a=Math.max(o-e,i-r,e+s-o,r+n-i):a=O(t.radius,Math.sqrt(s*s+n*n)/Math.SQRT2),new Gt(l=>{l.beginPath(),l.arc(o,i,Math.max(0,a),0,Math.PI*2),l.clip()})}case 3:{const o=e+O(t.cx,s),i=r+O(t.cy,n),a=Qa(t.rx,o,e,e+s,s),l=Qa(t.ry,i,r,r+n,n);return new Gt(c=>{c.beginPath(),c.ellipse(o,i,Math.max(0,a),Math.max(0,l),0,0,Math.PI*2),c.clip()})}case 4:{const o=t.points.map(([i,a])=>[e+O(i,s),r+O(a,n)]);return new Gt(i=>{if(i.beginPath(),o.length>0){i.moveTo(o[0][0],o[0][1]);for(let a=1;a<o.length;a++)i.lineTo(o[a][0],o[a][1]);i.closePath()}i.clip()})}case 5:{const{d:o}=t;return new Gt(i=>{try{const a=i.getTransform();i.translate(e,r),i.clip(new Path2D(o)),i.setTransform(a)}catch{}})}case 0:return null;default:return null}},wn=(t,A,e,r)=>{t.container.elements.forEach(s=>{const n=aA(s.flags,4),o=aA(s.flags,2),i=new pa(s,t);aA(s.styles.display,2048)&&r.push(i);const a=aA(s.flags,8)?[]:r;if(n||o){const l=n||s.styles.isPositioned()?e:A,c=new wa(i);if(s.styles.isPositioned()||s.styles.opacity<1||s.styles.isTransformed()){const B=s.styles.zIndex.order;if(B<0){let f=0;l.negativeZIndex.some((u,h)=>B>u.element.container.styles.zIndex.order?(f=h,!1):f>0),l.negativeZIndex.splice(f,0,c)}else if(B>0){let f=0;l.positiveZIndex.some((u,h)=>B>=u.element.container.styles.zIndex.order?(f=h+1,!1):f>0),l.positiveZIndex.splice(f,0,c)}else l.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else s.styles.isFloating()?l.nonPositionedFloats.push(c):l.nonPositionedInlineLevel.push(c);wn(i,c,n?c:e,a)}else s.styles.isInlineLevel()?A.inlineLevel.push(i):A.nonInlineLevel.push(i),wn(i,A,e,a);aA(s.flags,8)&&Ca(s,a)})},Ca=(t,A)=>{let e=t instanceof an?t.start:1;const r=t instanceof an?t.reversed:!1;for(let s=0;s<A.length;s++){const n=A[s];n.container instanceof ji&&typeof n.container.value=="number"&&n.container.value!==0&&(e=n.container.value),n.listValue=Mt(e,n.container.styles.listStyleType,!0),e+=r?-1:1}},Pf=t=>{const A=new pa(t,null),e=new wa(A),r=[];return wn(A,e,e,r),Ca(A.container,r),e},ma=t=>{const A=t.bounds,e=t.styles;return A.add(e.borderLeftWidth,e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth),-(e.borderTopWidth+e.borderBottomWidth))},Vt=t=>{const A=t.styles,e=t.bounds,r=O(A.paddingLeft,e.width),s=O(A.paddingRight,e.width),n=O(A.paddingTop,e.width),o=O(A.paddingBottom,e.width);return e.add(r+A.borderLeftWidth,n+A.borderTopWidth,-(A.borderRightWidth+A.borderLeftWidth+r+s),-(A.borderTopWidth+A.borderBottomWidth+n+o))},Xf=(t,A)=>t===0?A.bounds:t===2?Vt(A):ma(A),Wf=(t,A)=>t===0?A.bounds:t===2?Vt(A):ma(A),pn=(t,A,e)=>{const r=Xf(ct(t.styles.backgroundOrigin,A),t),s=Wf(ct(t.styles.backgroundClip,A),t),n=Jf(ct(t.styles.backgroundSize,A),e,r);let[o,i]=n;const a=vt(ct(t.styles.backgroundPosition,A),r.width-o,r.height-i),l=jf(ct(t.styles.backgroundRepeat,A),a,n,r,s),c=Math.round(r.left+a[0]),B=Math.round(r.top+a[1]);return o=Math.max(1,o),i=Math.max(1,i),[l,c,B,o,i]},at=t=>R(t)&&t.value===rt.AUTO,Jr=t=>typeof t=="number",Jf=(t,[A,e,r],s)=>{const[n,o]=t;if(!n)return[0,0];if(Y(n)&&o&&Y(o))return[O(n,s.width),O(o,s.height)];const i=Jr(r);if(R(n)&&(n.value===rt.CONTAIN||n.value===rt.COVER))return Jr(r)?s.width/s.height<r!=(n.value===rt.COVER)?[s.width,s.width/r]:[s.height*r,s.height]:[s.width,s.height];const a=Jr(A),l=Jr(e),c=a||l;if(at(n)&&(!o||at(o))){if(a&&l)return[A,e];if(!i&&!c)return[s.width,s.height];if(c&&i){const w=a?A:e*r,U=l?e:A/r;return[w,U]}const u=a?A:s.width,h=l?e:s.height;return[u,h]}if(i){let u=0,h=0;return Y(n)?u=O(n,s.width):Y(o)&&(h=O(o,s.height)),at(n)?u=h*r:(!o||at(o))&&(h=u/r),[u,h]}let B=null,f=null;if(Y(n)?B=O(n,s.width):o&&Y(o)&&(f=O(o,s.height)),B!==null&&(!o||at(o))&&(f=a&&l?B/A*e:s.height),f!==null&&at(n)&&(B=a&&l?f/e*A:s.width),B!==null&&f!==null)return[B,f];throw new Error("Unable to calculate background-size for element")},ct=(t,A)=>{const e=t[A];return typeof e>"u"?t[0]:e},jf=(t,[A,e],[r,s],n,o)=>{switch(t){case 2:return[new H(Math.round(n.left),Math.round(n.top+e)),new H(Math.round(n.left+n.width),Math.round(n.top+e)),new H(Math.round(n.left+n.width),Math.round(s+n.top+e)),new H(Math.round(n.left),Math.round(s+n.top+e))];case 3:return[new H(Math.round(n.left+A),Math.round(n.top)),new H(Math.round(n.left+A+r),Math.round(n.top)),new H(Math.round(n.left+A+r),Math.round(n.height+n.top)),new H(Math.round(n.left+A),Math.round(n.height+n.top))];case 1:return[new H(Math.round(n.left+A),Math.round(n.top+e)),new H(Math.round(n.left+A+r),Math.round(n.top+e)),new H(Math.round(n.left+A+r),Math.round(n.top+e+s)),new H(Math.round(n.left+A),Math.round(n.top+e+s))];default:return[new H(Math.round(o.left),Math.round(o.top)),new H(Math.round(o.left+o.width),Math.round(o.top)),new H(Math.round(o.left+o.width),Math.round(o.height+o.top)),new H(Math.round(o.left),Math.round(o.height+o.top))]}},Yf="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",Ua="Hidden Text";class zf{constructor(A){this._data={},this._document=A}parseMetrics(A,e){const r=this._document.createElement("div"),s=this._document.createElement("img"),n=this._document.createElement("span"),o=this._document.body;r.style.visibility="hidden",r.style.fontFamily=A,r.style.fontSize=e,r.style.margin="0",r.style.padding="0",r.style.whiteSpace="nowrap",o.appendChild(r),s.src=Yf,s.width=1,s.height=1,s.style.margin="0",s.style.padding="0",s.style.verticalAlign="baseline",n.style.fontFamily=A,n.style.fontSize=e,n.style.margin="0",n.style.padding="0",n.appendChild(this._document.createTextNode(Ua)),r.appendChild(n),r.appendChild(s);const i=s.offsetTop-n.offsetTop+2;r.removeChild(n),r.appendChild(this._document.createTextNode(Ua)),r.style.lineHeight="normal",s.style.verticalAlign="super";const a=s.offsetTop-r.offsetTop+2;return o.removeChild(r),{baseline:i,middle:a}}getMetrics(A,e){const r=`${A} ${e}`;return typeof this._data[r]>"u"&&(this._data[r]=this.parseMetrics(A,e)),this._data[r]}}class Fa{constructor(A,e){this.context=A,this.options=e}}class Zf{constructor(A){this.ctx=A.ctx,this.context=A.context,this.canvas=A.canvas}async renderBackgroundImage(A){let e=A.styles.backgroundImage.length-1;for(const r of A.styles.backgroundImage.slice(0).reverse())r.type===0?await this.renderBackgroundURLImage(A,r,e):vd(r)?this.renderLinearGradient(A,r,e):Sd(r)&&this.renderRadialGradient(A,r,e),e--}async renderBackgroundURLImage(A,e,r){let s;const n=e.url;try{s=await this.context.cache.match(n)}catch{this.context.logger.error(`Error loading background-image ${n}`)}if(s){const o=isNaN(s.width)||s.width===0?1:s.width,i=isNaN(s.height)||s.height===0?1:s.height,[a,l,c,B,f]=pn(A,r,[o,i,o/i]),u=this.ctx.createPattern(this.resizeImage(s,B,f,A.styles.imageRendering),"repeat");this.renderRepeat(a,u,l,c)}}renderLinearGradient(A,e,r){const[s,n,o,i,a]=pn(A,r,[null,null,null]),[l,c,B,f,u]=Ed(e.angle,i,a),w=(this.canvas.ownerDocument??document).createElement("canvas");w.width=i,w.height=a;const U=w.getContext("2d"),y=U.createLinearGradient(c,f,B,u);if(Bi(e.stops,l||1).forEach(p=>y.addColorStop(p.stop,oA(p.color))),U.fillStyle=y,U.fillRect(0,0,i,a),i>0&&a>0){const p=this.ctx.createPattern(w,"repeat");this.renderRepeat(s,p,n,o)}}renderRadialGradient(A,e,r){const[s,n,o,i,a]=pn(A,r,[null,null,null]),l=e.position.length===0?[_e]:e.position,c=O(l[0],i),B=O(l[l.length-1],a);let[f,u]=yd(e,c,B,i,a);if((f===0||u===0)&&(f=Math.max(f,.01),u=Math.max(u,.01)),f>0&&u>0){const h=this.ctx.createRadialGradient(n+c,o+B,0,n+c,o+B,f);if(Bi(e.stops,f*2).forEach(w=>h.addColorStop(w.stop,oA(w.color))),this.path(s),this.ctx.fillStyle=h,f!==u){const w=A.bounds.left+.5*A.bounds.width,U=A.bounds.top+.5*A.bounds.height,y=u/f,p=1/y;this.ctx.save(),this.ctx.translate(w,U),this.ctx.transform(1,0,0,y,0,0),this.ctx.translate(-w,-U),this.ctx.fillRect(n,p*(o-U)+U,i,a*p),this.ctx.restore()}else this.ctx.fill()}}renderRepeat(A,e,r,s){this.path(A),this.ctx.fillStyle=e,this.ctx.translate(r,s),this.ctx.fill(),this.ctx.translate(-r,-s)}resizeImage(A,e,r,s){const o=(this.canvas.ownerDocument??document).createElement("canvas");o.width=Math.max(1,e),o.height=Math.max(1,r);const i=o.getContext("2d");return s===XA.PIXELATED||s===XA.CRISP_EDGES?(this.context.logger.debug("Disabling image smoothing for background image due to CSS image-rendering"),i.imageSmoothingEnabled=!1):s===XA.SMOOTH?(this.context.logger.debug("Enabling image smoothing for background image due to CSS image-rendering: smooth"),i.imageSmoothingEnabled=!0):i.imageSmoothingEnabled=this.ctx.imageSmoothingEnabled,this.ctx.imageSmoothingQuality&&(i.imageSmoothingQuality=this.ctx.imageSmoothingQuality),i.drawImage(A,0,0,A.width,A.height,0,0,e,r),o}path(A){this.ctx.beginPath(),this.formatPath(A),this.ctx.closePath()}formatPath(A){A.forEach((e,r)=>{const s=GA(e)?e.start:e;r===0?this.ctx.moveTo(s.x,s.y):this.ctx.lineTo(s.x,s.y),GA(e)&&this.ctx.bezierCurveTo(e.startControl.x,e.startControl.y,e.endControl.x,e.endControl.y,e.end.x,e.end.y)})}}const xa=(t,A)=>{switch(A){case 0:return YA(t.topLeftBorderBox,t.topLeftPaddingBox,t.topRightBorderBox,t.topRightPaddingBox);case 1:return YA(t.topRightBorderBox,t.topRightPaddingBox,t.bottomRightBorderBox,t.bottomRightPaddingBox);case 2:return YA(t.bottomRightBorderBox,t.bottomRightPaddingBox,t.bottomLeftBorderBox,t.bottomLeftPaddingBox);default:return YA(t.bottomLeftBorderBox,t.bottomLeftPaddingBox,t.topLeftBorderBox,t.topLeftPaddingBox)}},$f=(t,A)=>{switch(A){case 0:return YA(t.topLeftBorderBox,t.topLeftBorderDoubleOuterBox,t.topRightBorderBox,t.topRightBorderDoubleOuterBox);case 1:return YA(t.topRightBorderBox,t.topRightBorderDoubleOuterBox,t.bottomRightBorderBox,t.bottomRightBorderDoubleOuterBox);case 2:return YA(t.bottomRightBorderBox,t.bottomRightBorderDoubleOuterBox,t.bottomLeftBorderBox,t.bottomLeftBorderDoubleOuterBox);default:return YA(t.bottomLeftBorderBox,t.bottomLeftBorderDoubleOuterBox,t.topLeftBorderBox,t.topLeftBorderDoubleOuterBox)}},qf=(t,A)=>{switch(A){case 0:return YA(t.topLeftBorderDoubleInnerBox,t.topLeftPaddingBox,t.topRightBorderDoubleInnerBox,t.topRightPaddingBox);case 1:return YA(t.topRightBorderDoubleInnerBox,t.topRightPaddingBox,t.bottomRightBorderDoubleInnerBox,t.bottomRightPaddingBox);case 2:return YA(t.bottomRightBorderDoubleInnerBox,t.bottomRightPaddingBox,t.bottomLeftBorderDoubleInnerBox,t.bottomLeftPaddingBox);default:return YA(t.bottomLeftBorderDoubleInnerBox,t.bottomLeftPaddingBox,t.topLeftBorderDoubleInnerBox,t.topLeftPaddingBox)}},Ah=(t,A)=>{switch(A){case 0:return jr(t.topLeftBorderStroke,t.topRightBorderStroke);case 1:return jr(t.topRightBorderStroke,t.bottomRightBorderStroke);case 2:return jr(t.bottomRightBorderStroke,t.bottomLeftBorderStroke);default:return jr(t.bottomLeftBorderStroke,t.topLeftBorderStroke)}},jr=(t,A)=>{const e=[];return GA(t)?e.push(t.subdivide(.5,!1)):e.push(t),GA(A)?e.push(A.subdivide(.5,!0)):e.push(A),e},YA=(t,A,e,r)=>{const s=[];return GA(t)?s.push(t.subdivide(.5,!1)):s.push(t),GA(e)?s.push(e.subdivide(.5,!0)):s.push(e),GA(r)?s.push(r.subdivide(.5,!0).reverse()):s.push(r),GA(A)?s.push(A.subdivide(.5,!1).reverse()):s.push(A),s};class eh{constructor(A,e){this.ctx=A.ctx,this.pathCallbacks=e}async renderSolidBorder(A,e,r){this.pathCallbacks.path(xa(r,e)),this.ctx.fillStyle=oA(A),this.ctx.fill()}async renderDoubleBorder(A,e,r,s){if(e<3){await this.renderSolidBorder(A,r,s);return}const n=$f(s,r);this.pathCallbacks.path(n),this.ctx.fillStyle=oA(A),this.ctx.fill();const o=qf(s,r);this.pathCallbacks.path(o),this.ctx.fill()}async renderDashedDottedBorder(A,e,r,s,n){this.ctx.save();const o=Ah(s,r),i=xa(s,r);n===2&&(this.pathCallbacks.path(i),this.ctx.clip());let a,l,c,B;GA(i[0])?(a=i[0].start.x,l=i[0].start.y):(a=i[0].x,l=i[0].y),GA(i[1])?(c=i[1].end.x,B=i[1].end.y):(c=i[1].x,B=i[1].y);let f;r===0||r===2?f=Math.abs(a-c):f=Math.abs(l-B),this.ctx.beginPath(),n===3?this.pathCallbacks.formatPath(o):this.pathCallbacks.formatPath(i.slice(0,2));let u=e<3?e*3:e*2,h=e<3?e*2:e;n===3&&(u=e,h=e);let w=!0;if(f<=u*2)w=!1;else if(f<=u*2+h){const U=f/(2*u+h);u*=U,h*=U}else{const U=Math.floor((f+h)/(u+h)),y=(f-U*u)/(U-1),p=(f-(U+1)*u)/U;h=p<=0||Math.abs(h-y)<Math.abs(h-p)?y:p}if(w&&(n===3?this.ctx.setLineDash([0,u+h]):this.ctx.setLineDash([u,h])),n===3?(this.ctx.lineCap="round",this.ctx.lineWidth=e):this.ctx.lineWidth=e*2+1.1,this.ctx.strokeStyle=oA(A),this.ctx.stroke(),this.ctx.setLineDash([]),n===2){if(GA(i[0])){const U=i[3],y=i[0];this.ctx.beginPath(),this.pathCallbacks.formatPath([new H(U.end.x,U.end.y),new H(y.start.x,y.start.y)]),this.ctx.stroke()}if(GA(i[1])){const U=i[1],y=i[2];this.ctx.beginPath(),this.pathCallbacks.formatPath([new H(U.end.x,U.end.y),new H(y.start.x,y.start.y)]),this.ctx.stroke()}}this.ctx.restore()}}class th{constructor(A,e){this.activeEffects=[],this.ctx=A.ctx,this.pathCallback=e}applyEffects(A){for(;this.activeEffects.length;)this.popEffect();A.forEach(e=>this.applyEffect(e))}applyEffect(A){this.ctx.save(),Gf(A)?this.ctx.globalAlpha=A.opacity:Nf(A)?(this.ctx.translate(A.offsetX,A.offsetY),this.ctx.transform(A.matrix[0],A.matrix[1],A.matrix[2],A.matrix[3],A.matrix[4],A.matrix[5]),this.ctx.translate(-A.offsetX,-A.offsetY)):fa(A)?(this.pathCallback.path(A.path),this.ctx.clip()):Vf(A)&&A.applyClip(this.ctx),this.activeEffects.push(A)}popEffect(){this.activeEffects.pop(),this.ctx.restore()}getActiveEffectCount(){return this.activeEffects.length}hasActiveEffects(){return this.activeEffects.length>0}}const rh=["-apple-system","system-ui"],sh=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,nh=t=>sh.test(t),oh=()=>{if(typeof navigator>"u")return null;const t=navigator.userAgent,A=/iPhone|iPad|iPod/.test(t),e=/Macintosh/.test(t)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;if(!A&&!e)return null;const r=[/(?:iPhone|CPU(?:\siPhone)?)\sOS\s(\d+)[\._](\d+)/,/Version\/(\d+)\.(\d+)/];for(const s of r){const n=t.match(s);if(n&&n[1])return parseInt(n[1],10)}return null},ih=t=>{const A=oh();return A!==null&&A>=15&&A<17?t.map(e=>rh.indexOf(e)!==-1?'-apple-system, "Helvetica Neue", Arial, sans-serif':e):t};class ah{constructor(A){this.ctx=A.ctx,this.options=A.options}iterateLettersWithLetterSpacing(A,e,r,s){const n=Mr(A.text),o=A.bounds.top+r;let i=A.bounds.left;for(const a of n){if(nh(a)){const l=this.ctx.textBaseline;this.ctx.textBaseline="ideographic",s(a,i,o),this.ctx.textBaseline=l}else s(a,i,o);i+=this.ctx.measureText(a).width+e}}renderTextWithLetterSpacing(A,e,r){e===0?this.ctx.fillText(A.text,A.bounds.left,A.bounds.top+r):this.iterateLettersWithLetterSpacing(A,e,r,(s,n,o)=>{this.ctx.fillText(s,n,o)})}renderTextBoundWithPaintOrder(A,e,r){r.forEach(s=>{switch(s){case 0:this.ctx.fillStyle=oA(e.color),this.renderTextWithLetterSpacing(A,e.letterSpacing,e.fontSize.number);break;case 1:e.webkitTextStrokeWidth&&A.text.trim().length&&(this.ctx.strokeStyle=oA(e.webkitTextStrokeColor),this.ctx.lineWidth=e.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",e.letterSpacing===0?this.ctx.strokeText(A.text,A.bounds.left,A.bounds.top+e.fontSize.number):this.iterateLettersWithLetterSpacing(A,e.letterSpacing,e.fontSize.number,(n,o,i)=>this.ctx.strokeText(n,o,i)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter");break}})}renderTextDecoration(A,e){this.ctx.fillStyle=oA(e.textDecorationColor||e.color);let r=1;typeof e.textDecorationThickness=="number"?r=e.textDecorationThickness:e.textDecorationThickness==="from-font"&&(r=Math.max(1,Math.floor(e.fontSize.number*.05)));let s=0;typeof e.textUnderlineOffset=="number"&&(s=e.textUnderlineOffset);const n=e.textDecorationStyle;e.textDecorationLine.forEach(o=>{let i=0;switch(o){case 1:i=A.top+A.height-r+s;break;case 2:i=A.top;break;case 3:i=A.top+(A.height/2-r/2);break;default:return}this.drawDecorationLine(A.left,i,A.width,r,n)})}drawDecorationLine(A,e,r,s,n){switch(n){case 0:this.ctx.fillRect(A,e,r,s);break;case 1:const o=Math.max(1,s);this.ctx.fillRect(A,e,r,s),this.ctx.fillRect(A,e+s+o,r,s);break;case 2:this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash([s,s*2]),this.ctx.lineWidth=s,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(A,e+s/2),this.ctx.lineTo(A+r,e+s/2),this.ctx.stroke(),this.ctx.restore();break;case 3:this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash([s*3,s*2]),this.ctx.lineWidth=s,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(A,e+s/2),this.ctx.lineTo(A+r,e+s/2),this.ctx.stroke(),this.ctx.restore();break;case 4:this.ctx.save(),this.ctx.beginPath(),this.ctx.lineWidth=s,this.ctx.strokeStyle=this.ctx.fillStyle;const i=s*2,a=s*4;let l=A;for(this.ctx.moveTo(l,e+s/2);l<A+r;){const c=Math.min(l+a/2,A+r);if(this.ctx.quadraticCurveTo(l+a/4,e+s/2-i,c,e+s/2),l=c,l<A+r){const B=Math.min(l+a/2,A+r);this.ctx.quadraticCurveTo(l+a/4,e+s/2+i,B,e+s/2),l=B}}this.ctx.stroke(),this.ctx.restore();break;default:this.ctx.fillRect(A,e,r,s)}}truncateTextWithEllipsis(A,e,r){const n=this.ctx.measureText("…").width,o=Mr(A);if(r===0){const i=c=>this.ctx.measureText(o.slice(0,c).join("")).width+n<=e;let a=0,l=o.length;for(;a<l;){const c=a+l+1>>1;i(c)?a=c:l=c-1}return o.slice(0,a).join("")+"…"}else{let i=n;const a=[];for(const l of o){const c=this.ctx.measureText(l).width;if(i+c>e)break;a.push(l),i+=c+r}return a.join("")+"…"}}createFontStyle(A){const e=A.fontVariant.filter(n=>n==="normal"||n==="small-caps").join(""),r=ih(A.fontFamily).join(", "),s=ne(A.fontSize)?`${A.fontSize.number}${A.fontSize.unit}`:`${A.fontSize.number}px`;return[[A.fontStyle,e,A.fontWeight,s,r].join(" "),r,s]}async renderTextNode(A,e,r){const[s]=this.createFontStyle(e);this.ctx.font=s,this.ctx.direction=e.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic";const n=e.paintOrder,o=e.fontSize.number*1.5;if(e.webkitLineClamp>0&&(e.display&2)!==0&&e.overflowY===1&&A.textBounds.length>0){const B=[];let f=[],u=A.textBounds[0].bounds.top;A.textBounds.forEach(w=>{Math.abs(w.bounds.top-u)>=o*.5?(f.length>0&&B.push(f),f=[w],u=w.bounds.top):f.push(w)}),f.length>0&&B.push(f);const h=e.webkitLineClamp;if(B.length>h){for(let U=0;U<h-1;U++)B[U].forEach(y=>{this.renderTextBoundWithPaintOrder(y,e,n)});const w=B[h-1];if(w&&w.length>0&&r){const U=w.map(F=>F.text).join(""),y=w[0],p=r.width-(y.bounds.left-r.left),x=this.truncateTextWithEllipsis(U,p,e.letterSpacing),T=new Xe(x,y.bounds);n.forEach(F=>{switch(F){case 0:this.ctx.fillStyle=oA(e.color),e.letterSpacing===0?this.ctx.fillText(x,y.bounds.left,y.bounds.top+e.fontSize.number):this.iterateLettersWithLetterSpacing(T,e.letterSpacing,e.fontSize.number,(K,_,AA)=>this.ctx.fillText(K,_,AA));break;case 1:e.webkitTextStrokeWidth&&x.trim().length&&(this.ctx.strokeStyle=oA(e.webkitTextStrokeColor),this.ctx.lineWidth=e.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",e.letterSpacing===0?this.ctx.strokeText(x,y.bounds.left,y.bounds.top+e.fontSize.number):this.iterateLettersWithLetterSpacing(T,e.letterSpacing,e.fontSize.number,(K,_,AA)=>this.ctx.strokeText(K,_,AA)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter");break}})}return}}const a=e.textOverflow===1&&r&&e.overflowX===1&&A.textBounds.length>0;let l=!1,c="";if(a){const B=A.textBounds[0].bounds.top;if(A.textBounds.every(u=>Math.abs(u.bounds.top-B)<o*.5)){let u=A.textBounds.map(U=>U.text).join("");u=u.replace(/\s+/g," ").trim();const h=this.ctx.measureText(u).width,w=r.width;h>w&&(l=!0,c=this.truncateTextWithEllipsis(u,w,e.letterSpacing))}}if(l){const B=A.textBounds[0],f=new Xe(c,B.bounds);n.forEach(u=>{switch(u){case 0:{this.ctx.fillStyle=oA(e.color),e.letterSpacing===0?this.ctx.fillText(c,B.bounds.left,B.bounds.top+e.fontSize.number):this.iterateLettersWithLetterSpacing(f,e.letterSpacing,e.fontSize.number,(w,U,y)=>this.ctx.fillText(w,U,y));const h=e.textShadow;h.length&&c.trim().length&&(h.slice(0).reverse().forEach(w=>{this.ctx.shadowColor=oA(w.color),this.ctx.shadowOffsetX=w.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=w.offsetY.number*this.options.scale,this.ctx.shadowBlur=w.blur.number,e.letterSpacing===0?this.ctx.fillText(c,B.bounds.left,B.bounds.top+e.fontSize.number):this.iterateLettersWithLetterSpacing(f,e.letterSpacing,e.fontSize.number,(U,y,p)=>this.ctx.fillText(U,y,p))}),this.ctx.shadowColor="",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0);break}case 1:e.webkitTextStrokeWidth&&c.trim().length&&(this.ctx.strokeStyle=oA(e.webkitTextStrokeColor),this.ctx.lineWidth=e.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",e.letterSpacing===0?this.ctx.strokeText(c,B.bounds.left,B.bounds.top+e.fontSize.number):this.iterateLettersWithLetterSpacing(f,e.letterSpacing,e.fontSize.number,(h,w,U)=>this.ctx.strokeText(h,w,U)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter");break}});return}A.textBounds.forEach(B=>{n.forEach(f=>{switch(f){case 0:{this.ctx.fillStyle=oA(e.color),this.renderTextWithLetterSpacing(B,e.letterSpacing,e.fontSize.number);const u=e.textShadow;u.length&&B.text.trim().length&&(u.slice(0).reverse().forEach(h=>{this.ctx.shadowColor=oA(h.color),this.ctx.shadowOffsetX=h.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=h.offsetY.number*this.options.scale,this.ctx.shadowBlur=h.blur.number,this.renderTextWithLetterSpacing(B,e.letterSpacing,e.fontSize.number)}),this.ctx.shadowColor="",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0),e.textDecorationLine.length&&this.renderTextDecoration(B.bounds,e);break}case 1:{if(e.webkitTextStrokeWidth&&B.text.trim().length){this.ctx.strokeStyle=oA(e.webkitTextStrokeColor),this.ctx.lineWidth=e.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round";const u=e.fontSize.number;e.letterSpacing===0?this.ctx.strokeText(B.text,B.bounds.left,B.bounds.top+u):this.iterateLettersWithLetterSpacing(B,e.letterSpacing,u,(h,w,U)=>this.ctx.strokeText(h,w,U)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter"}break}}})})}}const ch=1e4;class Qn extends Fa{constructor(A,e){super(A,e),this.canvas=e.canvas?e.canvas:document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),e.canvas||(this.canvas.width=Math.floor(e.width*e.scale),this.canvas.height=Math.floor(e.height*e.scale),this.canvas.style.width=`${e.width}px`,this.canvas.style.height=`${e.height}px`),this.fontMetrics=new zf(document),this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-e.x,-e.y),this.ctx.textBaseline="bottom",e.imageSmoothing!==void 0&&(this.ctx.imageSmoothingEnabled=e.imageSmoothing),e.imageSmoothingQuality&&(this.ctx.imageSmoothingQuality=e.imageSmoothingQuality),this.backgroundRenderer=new Zf({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:e.width,height:e.height,scale:e.scale}}),this.borderRenderer=new eh({ctx:this.ctx},{path:r=>this.path(r),formatPath:r=>this.formatPath(r)}),this.effectsRenderer=new th({ctx:this.ctx},{path:r=>this.path(r)}),this.textRenderer=new ah({ctx:this.ctx,context:this.context,options:{scale:e.scale}}),this.context.logger.debug(`Canvas renderer initialized (${e.width}x${e.height}) with scale ${e.scale}`)}async renderStack(A){A.element.container.styles.isVisible()&&await this.renderStackContent(A)}async renderNode(A){if(aA(A.container.flags,16))debugger;A.container.styles.isVisible()&&(await this.renderNodeBackgroundAndBorders(A),await this.renderNodeContent(A))}renderReplacedElement(A,e,r){const s=r.naturalWidth||A.intrinsicWidth,n=r.naturalHeight||A.intrinsicHeight;if(r&&s>0&&n>0){const o=Vt(A),i=Xr(e);this.path(i),this.ctx.save(),this.ctx.clip();let a=0,l=0,c=s,B=n,f=o.left,u=o.top,h=o.width,w=o.height;const{objectFit:U}=A.styles,y=h/w,p=c/B;if(U===2)p>y?(w=h/p,u+=(o.height-w)/2):(h=w*p,f+=(o.width-h)/2);else if(U===4)p>y?(c=B*y,a+=(s-c)/2):(B=c/y,l+=(n-B)/2);else if(U===8)c>h?(a+=(c-h)/2,c=h):(f+=(h-c)/2,h=c),B>w?(l+=(B-w)/2,B=w):(u+=(w-B)/2,w=B);else if(U===16){const x=p>y?h:w*p,T=c>h?c:h;x<T?p>y?(w=h/p,u+=(o.height-w)/2):(h=w*p,f+=(o.width-h)/2):(c>h?(a+=(c-h)/2,c=h):(f+=(h-c)/2,h=c),B>w?(l+=(B-w)/2,B=w):(u+=(w-B)/2,w=B))}this.ctx.drawImage(r,a,l,c,B,f,u,h,w),this.ctx.restore()}}async renderNodeContent(A){this.effectsRenderer.applyEffects(A.getEffects(4));const e=A.container,r=A.curves,s=e.styles,n=Vt(e);for(const o of e.textNodes)await this.textRenderer.renderTextNode(o,s,n);if(e instanceof Xi)try{const o=await this.context.cache.match(e.src),i=this.ctx.imageSmoothingEnabled;s.imageRendering===XA.PIXELATED||s.imageRendering===XA.CRISP_EDGES?(this.context.logger.debug(`Disabling image smoothing for ${e.src} due to CSS image-rendering: ${s.imageRendering===XA.PIXELATED?"pixelated":"crisp-edges"}`),this.ctx.imageSmoothingEnabled=!1):s.imageRendering===XA.SMOOTH&&(this.context.logger.debug(`Enabling image smoothing for ${e.src} due to CSS image-rendering: smooth`),this.ctx.imageSmoothingEnabled=!0),this.renderReplacedElement(e,r,o),this.ctx.imageSmoothingEnabled=i}catch{this.context.logger.error(`Error loading image ${e.src}`)}if(e instanceof Wi&&this.renderReplacedElement(e,r,e.canvas),e instanceof Ji)try{const o=await this.context.cache.match(e.svg);this.renderReplacedElement(e,r,o)}catch{this.context.logger.error(`Error loading svg ${e.svg.substring(0,255)}`)}if(e instanceof $i&&e.tree){const i=await new Qn(this.context,{scale:this.options.scale,backgroundColor:e.backgroundColor,x:0,y:0,width:e.width,height:e.height}).render(e.tree);e.width&&e.height&&this.ctx.drawImage(i,0,0,e.width,e.height,e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height)}if(e instanceof Dt){const o=Math.min(e.bounds.width,e.bounds.height);e.type===Nr?e.checked&&(this.ctx.save(),this.path([new H(e.bounds.left+o*.39363,e.bounds.top+o*.79),new H(e.bounds.left+o*.16,e.bounds.top+o*.5549),new H(e.bounds.left+o*.27347,e.bounds.top+o*.44071),new H(e.bounds.left+o*.39694,e.bounds.top+o*.5649),new H(e.bounds.left+o*.72983,e.bounds.top+o*.23),new H(e.bounds.left+o*.84,e.bounds.top+o*.34085),new H(e.bounds.left+o*.39363,e.bounds.top+o*.79)]),this.ctx.fillStyle=oA(Yi),this.ctx.fill(),this.ctx.restore()):e.type===Gr&&e.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(e.bounds.left+o/2,e.bounds.top+o/2,o/4,0,Math.PI*2,!0),this.ctx.fillStyle=oA(Yi),this.ctx.fill(),this.ctx.restore())}if(lh(e)&&e.value.length){const[o,i,a]=this.textRenderer.createFontStyle(s),{baseline:l}=this.fontMetrics.getMetrics(i,a);this.ctx.font=o;const c=e instanceof Dt&&e.isPlaceholder;this.ctx.fillStyle=oA(c?gf:s.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=dh(e.styles.textAlign);const B=Vt(e);let f=0;switch(e.styles.textAlign){case 1:f+=B.width/2;break;case 2:f+=B.width;break}let u=0;if(e instanceof Dt){const w=O(s.fontSize,0);u=(B.height-w)/2}const h=B.add(f,u,0,0);this.ctx.save(),this.path([new H(B.left,B.top),new H(B.left+B.width,B.top),new H(B.left+B.width,B.top+B.height),new H(B.left,B.top+B.height)]),this.ctx.clip(),this.textRenderer.renderTextWithLetterSpacing(new Xe(e.value,h),s.letterSpacing,l),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(aA(e.styles.display,2048)){if(e.styles.listStyleImage!==null){const o=e.styles.listStyleImage;if(o.type===0){let i;const a=o.url;try{i=await this.context.cache.match(a),this.ctx.drawImage(i,e.bounds.left-(i.width+10),e.bounds.top)}catch{this.context.logger.error(`Error loading list-style-image ${a}`)}}}else if(A.listValue&&e.styles.listStyleType!==-1){const[o]=this.textRenderer.createFontStyle(s);this.ctx.font=o,this.ctx.fillStyle=oA(s.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right";const i=new LA(e.bounds.left,e.bounds.top+O(e.styles.paddingTop,e.bounds.width),e.bounds.width,Fi(s.lineHeight,s.fontSize.number)/2+1);this.textRenderer.renderTextWithLetterSpacing(new Xe(A.listValue,i),s.letterSpacing,Fi(s.lineHeight,s.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"}}}async renderStackContent(A){if(aA(A.element.container.flags,16))debugger;await this.renderNodeBackgroundAndBorders(A.element);for(const e of A.negativeZIndex)await this.renderStack(e);await this.renderNodeContent(A.element);for(const e of A.nonInlineLevel)await this.renderNode(e);for(const e of A.nonPositionedFloats)await this.renderStack(e);for(const e of A.nonPositionedInlineLevel)await this.renderStack(e);for(const e of A.inlineLevel)await this.renderNode(e);for(const e of A.zeroOrAutoZIndexOrTransformedOrOpacity)await this.renderStack(e);for(const e of A.positiveZIndex)await this.renderStack(e)}mask(A){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.options.width,0),this.ctx.lineTo(this.options.width,this.options.height),this.ctx.lineTo(0,this.options.height),this.ctx.lineTo(0,0),this.formatPath(A.slice(0).reverse()),this.ctx.closePath()}path(A){this.ctx.beginPath(),this.formatPath(A),this.ctx.closePath()}formatPath(A){A.forEach((e,r)=>{const s=GA(e)?e.start:e;r===0?this.ctx.moveTo(s.x,s.y):this.ctx.lineTo(s.x,s.y),GA(e)&&this.ctx.bezierCurveTo(e.startControl.x,e.startControl.y,e.endControl.x,e.endControl.y,e.end.x,e.end.y)})}async renderNodeBackgroundAndBorders(A){this.effectsRenderer.applyEffects(A.getEffects(2));const e=A.container.styles,r=!be(e.backgroundColor)||e.backgroundImage.length,s=[{style:e.borderTopStyle,color:e.borderTopColor,width:e.borderTopWidth},{style:e.borderRightStyle,color:e.borderRightColor,width:e.borderRightWidth},{style:e.borderBottomStyle,color:e.borderBottomColor,width:e.borderBottomWidth},{style:e.borderLeftStyle,color:e.borderLeftColor,width:e.borderLeftWidth}],n=Bh(ct(e.backgroundClip,0),A.curves);(r||e.boxShadow.length)&&(this.ctx.save(),this.path(n),this.ctx.clip(),be(e.backgroundColor)||(this.ctx.fillStyle=oA(e.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(A.container),this.ctx.restore(),e.boxShadow.slice(0).reverse().forEach(i=>{this.ctx.save();const a=Pr(A.curves),l=i.inset?0:ch,c=_f(a,-l+(i.inset?1:-1)*i.spread.number,(i.inset?1:-1)*i.spread.number,i.spread.number*(i.inset?-2:2),i.spread.number*(i.inset?-2:2));i.inset?(this.path(a),this.ctx.clip(),this.mask(c)):(this.mask(a),this.ctx.clip(),this.path(c)),this.ctx.shadowOffsetX=i.offsetX.number+l,this.ctx.shadowOffsetY=i.offsetY.number,this.ctx.shadowColor=oA(i.color),this.ctx.shadowBlur=i.blur.number,this.ctx.fillStyle=i.inset?oA(i.color):"rgba(0,0,0,1)",this.ctx.fill(),this.ctx.restore()}));let o=0;for(const i of s)i.style!==0&&!be(i.color)&&i.width>0&&(i.style===2?await this.borderRenderer.renderDashedDottedBorder(i.color,i.width,o,A.curves,2):i.style===3?await this.borderRenderer.renderDashedDottedBorder(i.color,i.width,o,A.curves,3):i.style===4?await this.borderRenderer.renderDoubleBorder(i.color,i.width,o,A.curves):await this.borderRenderer.renderSolidBorder(i.color,o,A.curves)),o++}async render(A){this.options.backgroundColor&&(this.ctx.fillStyle=oA(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));const e=Pf(A);return await this.renderStack(e),this.effectsRenderer.applyEffects([]),this.canvas}}const lh=t=>t instanceof Zi||t instanceof zi?!0:t instanceof Dt&&t.type!==Gr&&t.type!==Nr,Bh=(t,A)=>{switch(t){case 0:return Pr(A);case 2:return Rf(A);default:return Xr(A)}},dh=t=>{switch(t){case 1:return"center";case 2:return"right";default:return"left"}};class gh extends Fa{constructor(A,e){super(A,e),this.canvas=e.canvas?e.canvas:document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.options=e,this.canvas.width=Math.floor(e.width*e.scale),this.canvas.height=Math.floor(e.height*e.scale),this.canvas.style.width=`${e.width}px`,this.canvas.style.height=`${e.height}px`,this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-e.x,-e.y),this.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (${e.width}x${e.height} at ${e.x},${e.y}) with scale ${e.scale}`)}async render(A){const e=on(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,A),r=await uh(e);return this.options.backgroundColor&&(this.ctx.fillStyle=oA(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(r,-this.options.x*this.options.scale,-this.options.y*this.options.scale),this.canvas}}const uh=t=>new Promise((A,e)=>{const r=new Image;r.onload=()=>{A(r)},r.onerror=e,r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(t))}`});class Ea{constructor({id:A,enabled:e}){this.id=A,this.enabled=e,this.start=Date.now()}debug(...A){this.enabled&&(typeof window<"u"&&window.console&&typeof console.debug=="function"?console.debug(this.id,`${this.getTime()}ms`,...A):this.info(...A))}getTime(){return Date.now()-this.start}info(...A){this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info(this.id,`${this.getTime()}ms`,...A)}warn(...A){this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn(this.id,`${this.getTime()}ms`,...A):this.info(...A))}error(...A){this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error(this.id,`${this.getTime()}ms`,...A):this.info(...A))}}Ea.instances={};class fh{constructor(A,e){if(this.context=A,this._options=e,this._cache=new Map,this._pendingOperations=new Map,this.maxSize=e.maxCacheSize??100,this.maxSize<1)throw new Error("Cache maxSize must be at least 1");this.maxSize>1e4&&this.context.logger.warn(`Cache maxSize ${this.maxSize} is very large and may cause memory issues. Consider using a smaller value (recommended: 100-1000).`)}addImage(A){const e=this._pendingOperations.get(A);if(e)return e;if(this.has(A)){const r=this._cache.get(A);return r&&(r.lastAccessed=Date.now()),Promise.resolve()}if(mn(A)||Qh(A)){const r=this._addImageInternal(A);return this._pendingOperations.set(A,r),r.finally(()=>{this._pendingOperations.delete(A)}),r}return Promise.resolve()}async _addImageInternal(A){const e=this._options.imageTimeout??15e3,r=new Promise((n,o)=>{setTimeout(()=>{o(new Error(`Image load timeout after ${e}ms: ${A}`))},e)}),s=Promise.race([this.loadImage(A),r]);s.catch(n=>{this.context.logger.error(`Failed to load image ${A}: ${n instanceof Error?n.message:"Unknown error"}`)}),this.set(A,s)}match(A){const e=this._cache.get(A);if(e)return e.lastAccessed=Date.now(),e.value}set(A,e){if(this._cache.has(A)){const r=this._cache.get(A);r.value=e,r.lastAccessed=Date.now();return}this._cache.size>=this.maxSize&&this.evictLRU(),this._cache.set(A,{value:e,lastAccessed:Date.now()})}evictLRU(){let A=null,e=1/0;for(const[r,s]of this._cache.entries())s.lastAccessed<e&&(e=s.lastAccessed,A=r);A&&(this._cache.delete(A),this.context.logger.debug(`Cache: Evicted LRU entry: ${A}`))}size(){return this._cache.size}getMaxSize(){return this.maxSize}clear(){this._cache.clear()}async loadImage(A){const e=this.context.originChecker,r=a=>e.isSameOrigin(a),s=typeof this._options.customIsSameOrigin=="function"?await this._options.customIsSameOrigin(A,r):r(A),n=!Cn(A)&&this._options.useCORS===!0&&HA.SUPPORT_CORS_IMAGES&&!s,o=!Cn(A)&&!s&&!mn(A)&&typeof this._options.proxy=="string"&&HA.SUPPORT_CORS_XHR&&!n;if(!s&&this._options.allowTaint===!1&&!Cn(A)&&!mn(A)&&!o&&!n)return;let i=A;return o&&(i=await this.proxy(i)),this.context.logger.debug(`Added image ${A.substring(0,256)}`),await new Promise((a,l)=>{const c=new Image;c.onload=()=>a(c),c.onerror=l,(Ch(i)||n)&&(c.crossOrigin="anonymous"),c.src=i,c.complete===!0&&setTimeout(()=>a(c),500),this._options.imageTimeout>0&&setTimeout(()=>l(`Timed out (${this._options.imageTimeout}ms) loading image`),this._options.imageTimeout)})}has(A){return this._cache.has(A)}keys(){return Promise.resolve(Object.keys(this._cache))}proxy(A){const e=this._options.proxy;if(!e)throw new Error("No proxy defined");const r=A.substring(0,256);return new Promise((s,n)=>{const o=HA.SUPPORT_RESPONSE_TYPE?"blob":"text",i=new XMLHttpRequest;i.onload=()=>{if(i.status===200)if(o==="text")s(i.response);else{const l=new FileReader;l.addEventListener("load",()=>s(l.result),!1),l.addEventListener("error",c=>n(c),!1),l.readAsDataURL(i.response)}else n(`Failed to proxy resource ${r} with status code ${i.status}`)},i.onerror=n;const a=e.indexOf("?")>-1?"&":"?";if(i.open("GET",`${e}${a}url=${encodeURIComponent(A)}&responseType=${o}`),o!=="text"&&i instanceof XMLHttpRequest&&(i.responseType=o),this._options.imageTimeout){const l=this._options.imageTimeout;i.timeout=l,i.ontimeout=()=>n(`Timed out (${l}ms) proxying ${r}`)}i.send()})}}const hh=/^data:image\/svg\+xml/i,wh=/^data:image\/.*;base64,/i,ph=/^data:image\/.*/i,Qh=t=>HA.SUPPORT_SVG_DRAWING||!mh(t),Cn=t=>ph.test(t),Ch=t=>wh.test(t),mn=t=>t.substr(0,4)==="blob",mh=t=>t.substr(-3).toLowerCase()==="svg"||hh.test(t);class Uh{constructor(A){if(!A||!A.document)throw new Error("Valid window object required for OriginChecker");if(!A.location||!A.location.href)throw new Error("Window object must have valid location");this.link=A.document.createElement("a"),this.origin=this.getOrigin(A.location.href)}getOrigin(A){return this.link.href=A,this.link.href=this.link.href,this.link.protocol+this.link.hostname+this.link.port}isSameOrigin(A){return this.getOrigin(A)===this.origin}getContextOrigin(){return this.origin}}class Yr{constructor(A,e,r){this.windowBounds=e,this.instanceName=`#${Yr.instanceCount++}`,this.config=r,this.logger=new Ea({id:this.instanceName,enabled:A.logging}),this.originChecker=new Uh(r.window),this.cache=A.cache??r.cache??new fh(this,A)}}Yr.instanceCount=1;class _t{constructor(A={}){if(this.window=A.window||(typeof window<"u"?window:null),!this.window)throw new Error("Window object is required but not available");this.cspNonce=A.cspNonce,this.cache=A.cache}static fromElement(A,e={}){const r=A.ownerDocument;if(!r)throw new Error("Element is not attached to a document");const s=r.defaultView;if(!s)throw new Error("Document is not attached to a window");return new _t({window:s,...e})}clone(A={}){return new _t({window:A.window||this.window,cspNonce:A.cspNonce??this.cspNonce,cache:A.cache??this.cache})}}function Fh(t){console.warn("[html2canvas-pro] setDefaultConfig is deprecated. Pass configuration to html2canvas directly.")}class xh{constructor(A={}){this.config={maxImageTimeout:3e5,allowDataUrls:!0,...A}}validateUrl(A,e="general"){if(!A||typeof A!="string")return{valid:!1,error:"URL must be a non-empty string"};if(A.startsWith("data:"))return this.config.allowDataUrls?{valid:!0,sanitized:A}:{valid:!1,error:"Data URLs are not allowed"};if(A.startsWith("blob:"))return{valid:!0,sanitized:A};try{const r=new URL(A);if(!["http:","https:"].includes(r.protocol))return{valid:!1,error:`Protocol ${r.protocol} is not allowed. Only http and https are permitted.`};if(e==="proxy"&&this.config.allowedProxyDomains&&this.config.allowedProxyDomains.length>0){const s=r.hostname.toLowerCase();if(!this.config.allowedProxyDomains.some(o=>{const i=o.toLowerCase();return s===i||s.endsWith("."+i)}))return{valid:!1,error:`Proxy domain ${r.hostname} is not in the allowed list`}}if(e==="proxy"){if(!this.config.allowLocalhostProxy){const s=r.hostname.toLowerCase();if(s==="localhost"||s==="127.0.0.1"||s==="::1")return{valid:!1,error:"Localhost is not allowed for proxy URLs"};if(this.isPrivateIP(s))return{valid:!1,error:"Private IP addresses are not allowed for proxy URLs"};if(s.startsWith("169.254.")||s.startsWith("fe80:"))return{valid:!1,error:"Link-local addresses are not allowed for proxy URLs"}}return{valid:!0,sanitized:A,requiresRuntimeCheck:!0}}return{valid:!0,sanitized:A}}catch(r){return{valid:!1,error:`Invalid URL format: ${r instanceof Error?r.message:"Unknown error"}`}}}isPrivateIP(A){return[/^0\./,/^10\./,/^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\./,/^127\./,/^169\.254\./,/^172\.(1[6-9]|2[0-9]|3[0-1])\./,/^192\.0\.0\./,/^192\.0\.2\./,/^192\.168\./,/^198\.(1[8-9])\./,/^198\.51\.100\./,/^203\.0\.113\./,/^2(2[4-9]|3[0-9])\./,/^24[0-9]\./,/^255\.255\.255\.255$/].some(r=>r.test(A))?!0:A.includes(":")?this.isPrivateIPv6(A):!1}isPrivateIPv6(A){const s=A.toLowerCase().trim().replace(/^\[|\]$/g,"").split("%")[0];if(/^(0:){7}1$/.test(s)||s==="::1"||/^(0:){7}0$/.test(s)||s==="::")return!0;const n=this.expandIPv6(s);if(!n)return this.isPrivateIPv6Prefix(s);const o=parseInt(n.substring(0,2),16);if(o>=252&&o<=253)return!0;if(o===254){const i=parseInt(n.substring(2,4),16);if(i>=128&&i<=191)return!0}return o===255}expandIPv6(A){try{if(A.includes("::")){const e=A.split("::");if(e.length>2)return null;const r=e[0]?e[0].split(":"):[],s=e[1]?e[1].split(":"):[],n=8-r.length-s.length;if(n<0)return null;const o=Array(n).fill("0000");return[...r,...o,...s].map(a=>a.padStart(4,"0")).join(":")}else{const e=A.split(":");return e.length!==8?null:e.map(r=>r.padStart(4,"0")).join(":")}}catch{return null}}isPrivateIPv6Prefix(A){return!!(/^fc[0-9a-f]{0,2}:?/i.test(A)||/^fd[0-9a-f]{0,2}:?/i.test(A)||/^fe[89ab][0-9a-f]:?/i.test(A)||/^ff[0-9a-f]{0,2}:?/i.test(A))}validateCspNonce(A){return!A||typeof A!="string"?{valid:!1,error:"CSP nonce must be a non-empty string"}:A.length<16?{valid:!1,error:"CSP nonce is too short (minimum 16 characters recommended)"}:/^[A-Za-z0-9+/=_-]+$/.test(A)?{valid:!0,sanitized:A}:{valid:!1,error:"CSP nonce contains invalid characters"}}validateImageTimeout(A){return typeof A!="number"||isNaN(A)?{valid:!1,error:"Image timeout must be a number"}:A<0?{valid:!1,error:"Image timeout cannot be negative"}:this.config.maxImageTimeout&&A>this.config.maxImageTimeout?{valid:!1,error:`Image timeout ${A}ms exceeds maximum allowed ${this.config.maxImageTimeout}ms`}:{valid:!0,sanitized:A}}validateDimensions(A,e){if(typeof A!="number"||typeof e!="number")return{valid:!1,error:"Dimensions must be numbers"};if(isNaN(A)||isNaN(e))return{valid:!1,error:"Dimensions cannot be NaN"};if(A<=0||e<=0)return{valid:!1,error:"Dimensions must be positive"};const r=32767;return A>r||e>r?{valid:!1,error:`Dimensions exceed maximum allowed (${r}px)`}:{valid:!0,sanitized:{width:A,height:e}}}validateScale(A){return typeof A!="number"||isNaN(A)?{valid:!1,error:"Scale must be a number"}:A<=0?{valid:!1,error:"Scale must be positive"}:A>10?{valid:!1,error:"Scale factor too large (maximum 10x)"}:{valid:!0,sanitized:A}}validateElement(A){return A?typeof A!="object"?{valid:!1,error:"Element must be an object"}:typeof HTMLElement<"u"&&A instanceof HTMLElement?A.ownerDocument?{valid:!0}:{valid:!1,error:"Element must be attached to a document"}:A.ownerDocument?A.ownerDocument.defaultView?{valid:!0}:{valid:!1,error:"Document must be attached to a window (ownerDocument.defaultView required)"}:{valid:!1,error:"Element must be attached to a document (ownerDocument required)"}:{valid:!1,error:"Element is required"}}validateOptions(A){const e=[],r=A.proxy;if(r!=null&&typeof r=="string"&&r.length>0){const s=this.validateUrl(r,"proxy");s.valid||e.push(`Proxy: ${s.error}`)}if(A.imageTimeout!==void 0){const s=this.validateImageTimeout(A.imageTimeout);s.valid||e.push(`Image timeout: ${s.error}`)}if(A.width!==void 0||A.height!==void 0){const s=A.width??800,n=A.height??600,o=this.validateDimensions(s,n);o.valid||e.push(`Dimensions: ${o.error}`)}if(A.scale!==void 0){const s=this.validateScale(A.scale);s.valid||e.push(`Scale: ${s.error}`)}if(A.cspNonce!==void 0){const s=this.validateCspNonce(A.cspNonce);s.valid||e.push(`CSP nonce: ${s.error}`)}if(this.config.customValidator){const s=this.config.customValidator(A,"options");s.valid||e.push(`Custom validation: ${s.error}`)}return e.length>0?{valid:!1,error:e.join("; ")}:{valid:!0}}}function Eh(t={}){return new xh({allowDataUrls:!0,maxImageTimeout:3e5,...t})}class yh{constructor(A,e=!0){this.context=A,this.activeMetrics=new Map,this.completedMetrics=[],this.enabled=e,this.getTime=typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now()}start(A,e){this.enabled&&(this.activeMetrics.has(A)&&this.context?.logger.warn(`Performance metric '${A}' already started. Overwriting.`),this.activeMetrics.set(A,{name:A,startTime:this.getTime(),metadata:e}))}end(A){if(!this.enabled)return;const e=this.activeMetrics.get(A);if(!e){this.context?.logger.warn(`Performance metric '${A}' not found. Was start() called?`);return}return e.endTime=this.getTime(),e.duration=e.endTime-e.startTime,this.completedMetrics.push(e),this.activeMetrics.delete(A),this.context?.logger.debug(`⏱️ ${A}: ${e.duration.toFixed(2)}ms`,e.metadata),e}measure(A,e,r){this.start(A,r);try{const s=e();return this.end(A),s}catch(s){throw this.end(A),s}}async measureAsync(A,e,r){this.start(A,r);try{const s=await e();return this.end(A),s}catch(s){throw this.end(A),s}}getMetrics(){return[...this.completedMetrics]}getMetric(A){return this.completedMetrics.find(e=>e.name===A)}getSummary(){const A=this.completedMetrics.reduce((r,s)=>r+(s.duration||0),0),e=this.completedMetrics.map(r=>({name:r.name,duration:r.duration||0,percentage:A>0?((r.duration||0)/A*100).toFixed(1)+"%":"0%"}));return{totalDuration:A,metrics:this.getMetrics(),breakdown:e}}logSummary(){if(!this.enabled||this.completedMetrics.length===0||!this.context)return;const A=this.getSummary();this.context.logger.info(`
12
- 📊 Performance Summary (Total: ${A.totalDuration.toFixed(2)}ms):`),A.breakdown.sort((e,r)=>r.duration-e.duration).forEach(e=>{this.context.logger.info(` ${e.name.padEnd(20)} ${e.duration.toFixed(2).padStart(8)}ms ${e.percentage.padStart(6)}`)})}clear(){this.activeMetrics.clear(),this.completedMetrics.splice(0)}isEnabled(){return this.enabled}getActiveMetrics(){return Array.from(this.activeMetrics.keys())}}const ya=(t,A={},e)=>{const r=e||_t.fromElement(t,{cspNonce:A.cspNonce,cache:A.cache});return Ih(t,A,r)},Hh=t=>{console.warn('[html2canvas-pro] setCspNonce is deprecated. Pass cspNonce in options instead: html2canvas(element, { cspNonce: "..." })'),typeof window<"u"&&Fh(new _t({window,cspNonce:t}))};ya.setCspNonce=Hh;const bh=t=>{["scale","width","height","imageTimeout","x","y","windowWidth","windowHeight","scrollX","scrollY"].forEach(e=>{const r=t[e];if(r!=null&&typeof r!="number"){const s=Number(r);Number.isNaN(s)||(t[e]=s)}})},Ih=async(t,A,e)=>{if(bh(A),!A.skipValidation){const eA=A.validator||Eh(),cA=eA.validateElement(t);if(!cA.valid)throw new Error(cA.error);const tA=eA.validateOptions(A);if(!tA.valid)throw new Error(`Invalid options: ${tA.error}`)}if(!t||typeof t!="object")throw new Error("Invalid element provided as first argument");const r=t.ownerDocument;if(!r)throw new Error("Element is not attached to a Document");const s=r.defaultView;if(!s)throw new Error("Document is not attached to a Window");const n={allowTaint:A.allowTaint??!1,imageTimeout:A.imageTimeout??15e3,proxy:A.proxy,useCORS:A.useCORS??!1,customIsSameOrigin:A.customIsSameOrigin},o={logging:A.logging??!0,cache:A.cache??e.cache,...n},i=800,a=600,l=0,c=s,B={windowWidth:A.windowWidth??c.innerWidth??i,windowHeight:A.windowHeight??c.innerHeight??a,scrollX:A.scrollX??c.pageXOffset??l,scrollY:A.scrollY??c.pageYOffset??l},f=new LA(B.scrollX,B.scrollY,B.windowWidth,B.windowHeight),u=new Yr(o,f,e),h=A.enablePerformanceMonitoring??A.logging??!1,w=new yh(u,h);w.start("total",{width:B.windowWidth,height:B.windowHeight});const U=A.foreignObjectRendering??!1,y={allowTaint:A.allowTaint??!1,onclone:A.onclone,ignoreElements:A.ignoreElements,iframeContainer:A.iframeContainer,inlineImages:U,copyStyles:U,cspNonce:A.cspNonce??e.cspNonce};u.logger.debug(`Starting document clone with size ${f.width}x${f.height} scrolled to ${-f.left},${-f.top}`),w.start("clone");const p=new da(u,t,y),x=p.clonedReferenceElement;if(!x)throw new Error("Unable to find element in cloned iframe");const T=await p.toIFrame(r,f);w.end("clone");const{width:F,height:K,left:_,top:AA}=cn(x)||pf(x)?Mc(x.ownerDocument):Ar(u,x),S=vh(u,x,A.backgroundColor),FA={canvas:A.canvas,backgroundColor:S,scale:A.scale??s.devicePixelRatio??1,x:(A.x??0)+_,y:(A.y??0)+AA,width:A.width??Math.ceil(F),height:A.height??Math.ceil(K),imageSmoothing:A.imageSmoothing,imageSmoothingQuality:A.imageSmoothingQuality};let UA,QA;try{return U?(u.logger.debug("Document cloned, using foreign object rendering"),w.start("render-foreignobject"),UA=await new gh(u,FA).render(x),w.end("render-foreignobject")):(u.logger.debug(`Document cloned, element located at ${_},${AA} with size ${F}x${K} using computed rendering`),u.logger.debug("Starting DOM parsing"),w.start("parse"),QA=Aa(u,x),w.end("parse"),S===QA.styles.backgroundColor&&(QA.styles.backgroundColor=ie.TRANSPARENT),u.logger.debug(`Starting renderer for element at ${FA.x},${FA.y} with size ${FA.width}x${FA.height}`),w.start("render"),UA=await new Qn(u,FA).render(QA),w.end("render")),w.start("cleanup"),(A.removeContainer??!0)&&(da.destroy(T)||u.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),w.end("cleanup"),w.end("total"),u.logger.debug("Finished rendering"),h&&w.logSummary(),UA}finally{QA&&QA.restoreTree()}},vh=(t,A,e)=>{const r=A.ownerDocument,s=r.documentElement?tt(t,getComputedStyle(r.documentElement).backgroundColor):ie.TRANSPARENT,n=r.body?tt(t,getComputedStyle(r.body).backgroundColor):ie.TRANSPARENT,o=typeof e=="string"?tt(t,e):e===null?ie.TRANSPARENT:4294967295;return A===r.documentElement?be(s)?be(n)?o:n:s:o},kt=2147483647,Un=kt-1,Fn=kt-1,Sh=kt-10,Lh=kt-5,Th=kt-15,ee="data-vg-pin-id",Kh=()=>{const t=window.innerWidth;return t<768?"mobile":t<1024?"tablet":"desktop"},Ha=(t,A)=>{if(!t)return"";try{const e=new Date(t);return isNaN(e.getTime())?"":new Intl.DateTimeFormat(A==="es"?"es-ES":"en-US",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}catch{return""}},ba=({url:t,className:A,style:e,tooltipStyle:r,onHover:s})=>{const n=C.useRef(null),o=()=>{if(!n.current||!s)return;const l=n.current.getBoundingClientRect(),c=l.top,B=window.innerHeight-l.bottom,f=c<140&&B>c?"bottom":"top";s({url:t,x:l.left+l.width/2,y:f==="top"?l.top:l.bottom,direction:f})},i=l=>l.toLowerCase().replace(/\/$/g,"").replace(/\/(?:[0-9]+|(?:[0-9a-f]{24}))(?=\/|$)/g,"/:id"),a=()=>{try{const l=i(window.location.pathname),c=new URL(t),B=i(c.pathname);return l===B||l.startsWith(B)||B.startsWith(l)}catch{return!1}};return d.jsxs("div",{ref:n,className:`vg-url-tag ${A||""}`,style:{...e,opacity:a()?1:.6,borderColor:a()?"var(--vg-primary)":"#e2e8f0"},onMouseEnter:o,onMouseMove:o,onMouseLeave:()=>s?.(null),children:[d.jsx(vc,{"data-source-path":"/src/components/ViewGateOverlay.tsx:141",size:e?.fontSize?parseInt(e.fontSize)+1:10}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:142",style:{maxWidth:e?.maxWidth||"150px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:new URL(t).pathname})]})},Pt=t=>{const A=[],e=[],r=[];let s=t;for(;s&&s.nodeType===Node.ELEMENT_NODE;){if(s.id&&!s.id.startsWith("vg-")&&!s.id.includes(":")){A.unshift(`#${s.id}`),r.unshift(`${s.localName}#${s.id}`);break}let n=s.localName;const o=Array.from(s.parentNode?.children||[]).indexOf(s),i=`${s.localName}[${o}]`;r.unshift(i);const a=s.getAttribute("data-testid")||s.getAttribute("data-qa");if(a&&e.push(`[data-testid="${a}"]`),s.getAttribute("placeholder"),s.getAttribute("aria-label"),s.getAttribute("role"),s.getAttribute("name"),s.getAttribute("title"),a){n=`[${s.hasAttribute("data-testid")?"data-testid":"data-qa"}="${a}"]`,A.unshift(n);break}const l=Array.from(s.parentNode?.children||[]).filter(c=>c.localName===s?.localName);if(l.length>1){const c=l.indexOf(s)+1;n+=`:nth-of-type(${c})`}A.unshift(n),s=s.parentElement}return{selector:A.join(" > "),fallbacks:e,vgPath:r.join(" > ")}},Dh=t=>{const{vgPath:A}=Pt(t);return{vgPath:A,classHash:t.className,parentTag:t.parentElement?.tagName.toLowerCase(),neighborCount:t.parentElement?.children.length,ariaLabel:t.getAttribute("aria-label")||void 0,role:t.getAttribute("role")||void 0,name:t.getAttribute("name")||void 0,type:t.getAttribute("type")||void 0,placeholder:t.getAttribute("placeholder")||void 0,textSnippet:(t.innerText||"").slice(0,30).trim()}},Oh=(()=>{let t=null,A=null;return e=>{if(!e||typeof window>"u"||typeof document>"u")return e;if(e.includes("oklch")||e.includes("oklab")||e.includes("lab(")||e.includes("lch(")||e.includes("color("))try{if(t||(t=document.createElement("canvas"),t.width=1,t.height=1),A||(A=t.getContext("2d",{willReadFrequently:!0})),A){A.fillStyle="#000000",A.fillStyle=e;const n=A.fillStyle;if(n&&!n.includes("oklch")&&!n.includes("oklab"))return n}const r=document.createElement("div");r.style.color=e,document.body.appendChild(r);const s=getComputedStyle(r).color;return document.body.removeChild(r),s&&!s.includes("oklch")?s:"rgb(0,0,0)"}catch{return"rgb(0,0,0)"}return e}})(),Rh=t=>{const A=window.getComputedStyle(t),e={};return["display","position","margin","padding","font-size","color","background-color","width","height","z-index"].forEach(s=>{const n=A.getPropertyValue(s);e[s]=Oh(n)}),e},Mh=t=>{const e=Object.keys(t).find(n=>n.startsWith("__reactFiber$")||n.startsWith("__reactInternalInstance$"));if(!e)return"";const r=[];let s=t[e];for(;s;){const n=s.type;if(typeof n=="function"){const o=n.displayName||n.name;o&&!o.includes("ViewGate")&&!r.includes(o)&&r.unshift(o)}s=s.return}return r.join(" > ")||"Generic Component"},xn=t=>{if(!t||t.id==="viewgate-ui"||t.id==="viewgate-shadow-host"||t.closest("#viewgate-shadow-host"))return!1;if(t.getAttribute("role")==="dialog"||t.getAttribute("aria-modal")==="true"||t.classList.contains("modal")||t.classList.contains("modal-content"))return!0;const A=window.getComputedStyle(t),e=t.getBoundingClientRect(),r=t.getAttribute("role");if(r&&["listbox","menu","combobox","tooltip","option"].includes(r)||e.width<120&&e.height<120)return!1;const n=parseInt(A.zIndex)||0,o=A.position==="fixed"||A.position==="absolute",i=e.width>window.innerWidth*.4&&e.height>window.innerHeight*.4,a=Math.abs(e.left+e.width/2-window.innerWidth/2)<50,l=t.getAttribute("class")||"",c=l.toLowerCase().includes("modal")||l.toLowerCase().includes("dialog");return!!(o&&n>=100&&(i||a||c))},Te=t=>{if(!t.isConnected)return!1;const A=window.getComputedStyle(t);if(A.display==="none"||A.visibility==="hidden"||A.opacity==="0")return t.tagName!=="BODY"&&t.tagName,!1;if(t.offsetWidth===0||t.offsetHeight===0)return!1;let e=t.parentElement;for(;e;){const s=window.getComputedStyle(e);if(s.display==="none"||s.visibility==="hidden"||s.opacity==="0")return!1;e=e.parentElement}const r=t.getBoundingClientRect();return!(r.width===0||r.height===0)},Ia=(t,A=document)=>{const e=A.querySelector(t);if(e)return e;const r=A.querySelectorAll("*");for(const s of Array.from(r)){const n=s.shadowRoot;if(n){const o=Ia(t,n);if(o)return o}}return null},va=(t,A)=>{let e=document.elementFromPoint(t,A);for(;e&&e.shadowRoot;){const r=e.shadowRoot.elementFromPoint(t,A);if(!r||r===e)break;e=r}return e},Nh=t=>{if(!t.tag)return null;const A=Array.from(document.getElementsByTagName(t.tag));let e=null,r=0;for(const s of A){if(!zr(s,t))continue;let n=0;const o=s.getAttribute("placeholder"),i=t.attributes?.placeholder||t.fingerprint?.placeholder;i&&o===i&&(n+=6);const a=s.getAttribute("type"),l=t.attributes?.type||t.fingerprint?.type;if(l&&a===l&&(n+=2),s.innerText?.trim()===t.text.trim()&&(n+=5),t.fingerprint?.vgPath){const{vgPath:c}=Pt(s);(c===t.vgPath||t.fingerprint?.vgPath===c)&&(n+=10)}n>r&&n>=7&&(r=n,e=s)}return e},zr=(t,A)=>{if(t.tagName.toLowerCase()!==A.tag.toLowerCase())return!1;const e=t.getAttribute("placeholder"),r=A.attributes?.placeholder||A.fingerprint?.placeholder;if(r&&e&&r!==e)return!1;const s=t.getAttribute("type"),n=A.attributes?.type||A.fingerprint?.type;return!(n&&s&&n!==s)},Sa=(t,A)=>{if(A){const o=Array.from(document.querySelectorAll(`[${ee}="${A}"]`));if(o.length>0){const i=o.filter(a=>zr(a,t));if(i.length===0)o.forEach(a=>a.removeAttribute(ee));else{const a=i.find(c=>{const{vgPath:B}=Pt(c);return B===t.vgPath||t.fingerprint?.vgPath===B}),l=a&&Te(a)?a:i.find(c=>!(!Te(c)||t.metadata?.isModal&&!c.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content')));return l?(o.forEach(c=>{c!==l&&c.removeAttribute(ee)}),l):null}}}const r=(t.selector?Array.from(document.querySelectorAll(t.selector)):[]).filter(o=>zr(o,t));let s=r.find(o=>{const{vgPath:i}=Pt(o);return i===t.vgPath||t.fingerprint?.vgPath===i})||r[0]||null;if(s&&Te(s))if(t.metadata?.isModal&&!s.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content'))s=null;else return s;if(t.fallbackSelectors)for(const o of t.fallbackSelectors){const i=Ia(o);if(i&&zr(i,t)&&Te(i)){if(t.metadata?.isModal&&!i.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content'))continue;return i}}const n=Nh(t);return n&&Te(n)?t.metadata?.isModal&&!n.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content')?null:n:null},En=t=>({tag:t.tagName.toLowerCase(),text:(t.innerText||t.getAttribute("placeholder")||"").slice(0,50).trim(),role:t.getAttribute("role")||void 0,type:t.getAttribute("type")||void 0}),Gh=t=>{const A=t.parentElement;if(!A)return;const e=Array.from(A.children).filter(o=>o!==t).slice(0,5).map(o=>En(o)),r=Array.from(A.children),s=r.indexOf(t);let n="middle";return s===0&&(n="start"),s===r.length-1&&(n="end"),{target:{...En(t),location:`${n} of ${A.tagName.toLowerCase()}`},parent:En(A),siblings:e}},La=(t,A)=>{let e="unknown:0",r=t;for(;r;){const f=r.getAttribute("data-source-path");if(f){e=f;break}r=r.parentElement}const s=Mh(t),{selector:n,fallbacks:o,vgPath:i}=Pt(t),a={};["placeholder","aria-label","name","type","alt","title","value","role"].forEach(f=>{const u=t.getAttribute(f);u&&(a[f]=u)});const l=(()=>{let f=t;for(;f&&f!==document.body;){if(xn(f))return!0;f=f.parentElement}return!1})();let c;l&&A&&!A.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content')&&(c=La(A));const B=`${t.tagName.toLowerCase()}-${(t.innerText||"").slice(0,20).replace(/\s+/g,"_")}-${n.split(" > ").slice(-1)}`;return{tag:t.tagName.toLowerCase(),id:t.id||"",classes:t.className||"",text:(t.innerText||"").slice(0,100).trim(),selector:n,vgPath:i,outerHtml:t.outerHTML,parentContext:t.parentElement?`<${t.parentElement.tagName.toLowerCase()} ${Array.from(t.parentElement.attributes).map(f=>`${f.name}="${f.value}"`).join(" ").slice(0,500)}>`:"N/A",componentPath:s,signature:B,source:e,attributes:a,fallbackSelectors:[...new Set(o)].slice(0,5),domPath:[],viewportSize:{width:window.innerWidth,height:window.innerHeight},uiContext:Gh(t),fingerprint:Dh(t),metadata:{hint:`Edit ${e.split(":")[0]} at line ${e.split(":")[1]||"?"}`,computedStyles:Rh(t),viewportBreakpoint:Kh(),outerHtml:t.outerHTML.slice(0,1500),scrollPosition:{x:window.scrollX,y:window.scrollY},isModal:l,triggerReference:c}}},Ta=()=>{const{addToast:t,language:A,t:e,apiKey:r,baseUrl:s,dashboardUrl:n,disableViewGate:o,hasActiveToasts:i}=uo(),a=C.useMemo(()=>typeof window>"u"?!1:window.location.href.includes("viewgate-backlog"),[]),[l,c]=C.useState(typeof window<"u"?window.location.pathname:"/");C.useEffect(()=>{const g=()=>c(window.location.pathname);window.addEventListener("popstate",g);const b=window.history.pushState,m=window.history.replaceState;return window.history.pushState=function(...v){b.apply(this,v),g()},window.history.replaceState=function(...v){m.apply(this,v),g()},()=>{window.removeEventListener("popstate",g),window.history.pushState=b,window.history.replaceState=m}},[]);const[B,f]=C.useState(!1),[u,h]=C.useState("medium"),[w,U]=C.useState("medium"),[y,p]=C.useState("all"),[x,T]=C.useState(null),[F,K]=C.useState(null),[_,AA]=C.useState(""),[S,FA]=C.useState(!1),[UA,QA]=C.useState(!1),[eA,cA]=C.useState(!1),[tA,zA]=C.useState([]),[OA,bA]=C.useState(null),[lt,ce]=C.useState(!1),[Q,D]=C.useState({}),[M,Z]=C.useState(null),[WA,te]=C.useState(!1),[k,VA]=C.useState(null),[Ke,Bt]=C.useState([]),[CA,Xt]=C.useState(()=>{if(typeof window>"u")return null;const g=localStorage.getItem("vg_selected_member");return g?JSON.parse(g):null});C.useEffect(()=>{!r||!s||fetch(`${s}/api/projects/members`,{headers:{"x-api-key":r}}).then(g=>g.json()).then(g=>{Array.isArray(g)&&Bt(g)}).catch(g=>console.error("Failed to fetch project members",g))},[r,s]);const Hn=g=>{Xt(g),localStorage.setItem("vg_selected_member",JSON.stringify(g))},De=C.useCallback(async g=>{const m=await fetch(g,{headers:{"x-api-key":r}});if(!m.ok){const v=await m.json().catch(()=>({}));throw new Error(v.message||v.error||"Fetch failed")}return m.json()},[r]),Zr=C.useMemo(()=>a?"backlog":"pending,todo,in_progress,review,ready_for_review,bug_fixing",[a]),{data:$r,isLoading:rA}=ro(r?`${s}/api/projects/active-sprint`:null,De,{refreshInterval:3e4,revalidateOnFocus:!0}),{data:sA,isLoading:z,mutate:$}=ro(r&&($r||a)?`${s}/api/annotations?status=${Zr}`:null,De,{refreshInterval:1e4,revalidateOnFocus:!0,dedupingInterval:2e3}),[xA,RA]=C.useState(null),BA=C.useRef(tA);BA.current=tA;const[q,le]=C.useState(null),Oe=C.useRef(null),[we,qr]=C.useState([]),KA=C.useMemo(()=>{let g=Array.isArray(tA)?tA:[];if(M){const m=we.find(v=>v.annotations&&Array.isArray(v.annotations)&&v.annotations.some(W=>W._id===M));m?g=m.annotations:g=g.filter(v=>v._id===M)}return g=g.filter(m=>m.status!=="completed"&&m.status!=="done"),window.location.href.includes("viewgate-backlog")||(q==="pending"?g=g.filter(m=>m.status!=="ready_for_review"):q==="ready"&&(g=g.filter(m=>m.status==="ready_for_review"))),y!=="all"&&(g=g.filter(m=>(m.priority||"medium")===y)),g},[M,tA,we,q,y]);C.useEffect(()=>{M&&KA.length===0&&!z&&Z(null)},[M,KA.length,z]);const[DA,Wt]=C.useState(()=>{if(typeof window>"u")return{top:24,right:24};const g=localStorage.getItem("vg-exit-pos");return g?JSON.parse(g):{top:24,right:24}}),[Je,dt]=C.useState(!1),pe=C.useRef(null),[gt,kh]=C.useState(()=>{if(typeof window>"u")return{bottom:30,right:30};const g=localStorage.getItem("vg-bar-pos");return g?JSON.parse(g):{bottom:30,right:30}}),[Jt,Ka]=C.useState(!1),Qe=C.useRef(null),Ph=g=>{g.preventDefault(),g.stopPropagation();const b=g.currentTarget.parentElement?.getBoundingClientRect();b&&(dt(!0),pe.current={x:g.clientX,y:g.clientY,top:DA.top,right:DA.right,width:b.width,height:b.height})},Xh=g=>{g.preventDefault(),g.stopPropagation();const b=g.currentTarget.parentElement?.getBoundingClientRect();b&&(Ka(!0),Qe.current={x:g.clientX,y:g.clientY,bottom:gt.bottom,right:gt.right,width:b.width,height:b.height})};C.useEffect(()=>{if(!Je&&!Jt)return;const g=m=>{if(Je&&pe.current){const v=m.clientX-pe.current.x,W=m.clientY-pe.current.y;let N=pe.current.top+W,P=pe.current.right-v;const L=10;N=Math.max(L,Math.min(window.innerHeight-pe.current.height-L,N)),P=Math.max(L,Math.min(window.innerWidth-pe.current.width-L,P)),Wt({top:N,right:P})}if(Jt&&Qe.current){const v=m.clientX-Qe.current.x,W=m.clientY-Qe.current.y;let N=Qe.current.bottom-W,P=Qe.current.right-v;const L=10;N=Math.max(L,Math.min(window.innerHeight-Qe.current.height-L,N)),P=Math.max(L,Math.min(window.innerWidth-Qe.current.width-L,P)),kh({bottom:N,right:P})}},b=()=>{Je&&(dt(!1),localStorage.setItem("vg-exit-pos",JSON.stringify(DA)),pe.current=null),Jt&&(Ka(!1),localStorage.setItem("vg-bar-pos",JSON.stringify(gt)),Qe.current=null)};return window.addEventListener("mousemove",g),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",b)}},[Je,Jt,DA,gt]);const[bn,In]=C.useState(null),[Da,Oa]=C.useState(""),[fw,hw]=C.useState({}),vn=C.useRef(null),ut=C.useRef(null),Sn=C.useRef(null),As=C.useRef(!1),Ra=C.useCallback(()=>{typeof window>"u"||As.current||(ut.current&&cancelAnimationFrame(ut.current),ut.current=requestAnimationFrame(()=>{ut.current=null,As.current=!0,Sn.current;const g=BA.current,b=Array.isArray(g)?g:[],m=new Set(b.map(j=>j._id));document.querySelectorAll(`[${ee}]`).forEach(j=>{const ZA=j.getAttribute(ee);ZA&&!m.has(ZA)&&j.removeAttribute(ee)});const W=Array.from(document.querySelectorAll('[role="dialog"], [aria-modal="true"], .modal, .modal-backdrop, .fixed.inset-0')).find(j=>xn(j)&&Te(j)),N=!!W,P=new Map,L=new Map;b.forEach(j=>{if(!j||!j.reference)return;try{const nA=()=>window.location.pathname.toLowerCase().replace(/\/$/g,"").replace(/\/(?:[0-9]+|(?:[0-9a-f]{24}))(?=\/|$)/g,"/:id"),vA=Re=>{try{return new URL(Re).pathname.toLowerCase().replace(/\/$/g,"").replace(/\/(?:[0-9]+|(?:[0-9a-f]{24}))(?=\/|$)/g,"/:id")}catch{return""}},me=nA(),jt=vA(j.url);if(me!==jt&&!j.url.includes(window.location.pathname))return}catch{return}const ZA=!!j.reference.metadata?.isModal,Ce=j.reference.metadata?.triggerReference;let fA=Sa(j.reference,j._id),hA=!1;if(Ce){const nA=Sa(Ce);nA&&Te(nA)&&(fA=nA,hA=!0)}if(!fA||!Te(fA))return;let mA=!1;if(N?mA=W.contains(fA):hA?mA=!0:mA=!ZA,!mA)return;const IA=fA.getAttribute(ee);IA!==j._id&&(document.querySelectorAll(`[${ee}="${j._id}"]`).forEach(nA=>{nA.removeAttribute(ee)}),IA||fA.setAttribute(ee,j._id));const X=hA?P:L;X.has(fA)||X.set(fA,{anns:[]}),X.get(fA).anns.push(j)});const dA=[],_A=(j,ZA)=>{j.forEach((Ce,fA)=>{const{anns:hA}=Ce,mA=fA.getBoundingClientRect(),IA=mA.left+mA.width/2,X=mA.top+mA.height/2;if(IA>=0&&IA<=window.innerWidth&&X>=0&&X<=window.innerHeight){const nA=document.elementFromPoint(IA,X),vA=document.getElementById("viewgate-shadow-host");if(nA&&!fA.contains(nA)&&nA!==vA&&!vA?.contains(nA))return}dA.push({id:hA[0]._id+(ZA?"_trig":""),element:fA,rect:mA,annotations:hA.sort((nA,vA)=>new Date(vA.timestamp||vA.createdAt).getTime()-new Date(nA.timestamp||nA.createdAt).getTime()),isModal:!!hA[0].reference?.metadata?.isModal,isTriggerPin:ZA})})};_A(P,!0),_A(L,!1),qr(dA),As.current=!1}))},[k]);C.useEffect(()=>{if(sA){const g=Array.isArray(sA)?sA:sA?.data||[];if(Array.isArray(g)){const b=g.reduce((m,v)=>m.find(N=>N._id===v._id)?m:m.concat([v]),[]);zA(b)}}else z||zA([])},[sA,z]),C.useEffect(()=>{VA($r||null)},[$r]),C.useEffect(()=>{eA&&tA.length===0&&!z&&cA(!1)},[eA,tA.length,z]),C.useEffect(()=>{let g=null;const b=()=>{As.current||Ra()},m=new MutationObserver(N=>{N.some(L=>L.type!=="attributes"||L.attributeName!==ee&&!L.target.parentElement?.closest("#viewgate-shadow-host"))&&(g&&clearTimeout(g),g=setTimeout(b,32))});Sn.current=m;const v=new ResizeObserver(()=>b()),W=()=>b();return b(),m.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),v.observe(document.documentElement),window.addEventListener("scroll",W,{capture:!0,passive:!0}),()=>{g&&clearTimeout(g),m.disconnect(),v.disconnect(),window.removeEventListener("scroll",W,!0),ut.current&&cancelAnimationFrame(ut.current),Sn.current=null}},[B,tA,Ra,eA,M,l]);const Ln=C.useCallback(g=>{let b=g;for(;b&&b!==document.body;){if(xn(b))return b;b=b.parentElement}return null},[]);C.useEffect(()=>{const g=b=>{const m=b.target;m&&(Ln(m)||(Oe.current=m))};return window.addEventListener("mousedown",g,!0),()=>window.removeEventListener("mousedown",g,!0)},[Ln]),C.useEffect(()=>{vn.current=document.getElementById("viewgate-shadow-host")},[]);const Tn=C.useCallback(g=>{if(!B||F)return;const b=va(g.clientX,g.clientY);if(!b||vn.current?.contains(b)||b.closest(".vg-no-capture")){T(null);return}const m=b.getBoundingClientRect();T({tag:b.tagName.toLowerCase(),source:b.getAttribute("data-source-path")||"unknown:0",rect:m,element:b,previewText:(b.innerText||"").slice(0,100)||(b.getAttribute("placeholder")||"").slice(0,100)||b.tagName.toLowerCase(),semanticReference:{...La(b,Oe.current),normalizedOffset:{x:(g.clientX-m.left)/m.width,y:(g.clientY-m.top)/m.height}}})},[B,F]),Kn=C.useCallback(async g=>{if(!B||F)return;const b=va(g.clientX,g.clientY);if(!(!b||vn.current?.contains(b)||b.closest(".vg-no-capture"))&&x){g.preventDefault(),g.stopPropagation(),QA(!0);try{await new Promise(X=>requestAnimationFrame(X)),await new Promise(X=>setTimeout(X,80));const m=x.element,v=m.getBoundingClientRect(),N=Ln(m)||document.documentElement,P=N.getBoundingClientRect(),L=window.devicePixelRatio||1,dA=Math.max(L,3),_A=Array.from(N.querySelectorAll("img"));await Promise.all(_A.map(X=>{const nA=X.getBoundingClientRect();return nA.bottom>-200&&nA.top<window.innerHeight+200&&(X.loading==="lazy"&&(X.loading="eager"),!X.complete)?new Promise(vA=>{X.onload=vA,X.onerror=vA}):Promise.resolve()})).catch(()=>{});const j=N===document.documentElement||N===document.body,ZA=v.left-P.left+(j?0:N.scrollLeft),Ce=v.top-P.top+(j?0:N.scrollTop),fA=await ya(N,{scale:dA,useCORS:!0,logging:!1,backgroundColor:null,allowTaint:!0,imageTimeout:2e4,scrollX:0,scrollY:0,windowWidth:document.documentElement.offsetWidth,windowHeight:document.documentElement.offsetHeight,onclone:X=>{const nA=X.getElementById("viewgate-shadow-host");nA&&nA.style.setProperty("display","none","important");const vA=X.querySelector(".vg-selection-overlay");vA&&vA.style.setProperty("display","none","important");const me=X.querySelector("[data-vg-root]");me&&(me.style.transform="none",me.style.perspective="none")},ignoreElements:X=>X.id==="viewgate-shadow-host"||X.classList.contains("vg-no-capture")||X.classList.contains("vg-selection-overlay")}),hA=document.createElement("canvas"),mA=hA.getContext("2d"),IA=24;if(hA.width=(v.width+IA*2)*dA,hA.height=(v.height+IA*2)*dA,mA){mA.imageSmoothingEnabled=!0,mA.imageSmoothingQuality="high";const X=(ZA-IA)*dA,nA=(Ce-IA)*dA,vA=(v.width+IA*2)*dA,me=(v.height+IA*2)*dA;mA.drawImage(fA,X,nA,vA,me,0,0,hA.width,hA.height),hA.toBlob(async jt=>{if(jt){const Re=new FileReader;Re.onloadend=()=>{K({...x,visualPreview:Re.result})},Re.readAsDataURL(jt)}else K(x)},"image/webp",.98)}}catch(m){console.error("ViewGate High-Fidelity Capture Error:",m),K(x)}finally{QA(!1),T(null)}}},[B,x,F]);C.useEffect(()=>{const g=b=>{if(b.key==="Escape"){F?K(null):eA?cA(!1):B&&f(!1);return}const v=(()=>{let P=document.activeElement;for(;P&&P.shadowRoot&&P.shadowRoot.activeElement;)P=P.shadowRoot.activeElement;return P})();if(["input","textarea"].includes((v?.tagName||"").toLowerCase())||v?.isContentEditable)return;const N=b.key.toLowerCase();if(N==="c"&&!F&&!eA){if(!(k&&k.status!=="closed")&&!a&&!B){t(A==="es"?"No hay un sprint activo. No se pueden generar comentarios.":"No active sprint found. Cannot generate comments.","error");return}f(L=>!L)}N==="v"&&!F&&(tA.length>0||eA)&&(cA(P=>!P),eA||f(!1))};return B&&!F?document.body.classList.add("vg-cursor-pointer"):document.body.classList.remove("vg-cursor-pointer"),window.addEventListener("keydown",g),window.addEventListener("mousemove",Tn,!0),window.addEventListener("click",Kn,!0),()=>{document.body.classList.remove("vg-cursor-pointer"),window.removeEventListener("keydown",g),window.removeEventListener("mousemove",Tn,!0),window.removeEventListener("click",Kn,!0)}},[B,F,eA,tA,Tn,Kn]);const Wh=async()=>{if(!F||!_.trim())return;if(!CA){t(A==="es"?"Selecciona un usuario para comentar":"Please select a user to comment","error");return}FA(!0);const{semanticReference:g}=F,[b,m]=(g.source||"").split(":"),W={filePath:b,line:parseInt(m||"0"),url:window.location.href,title:_.length>50?_.substring(0,50)+"...":_,message:_,status:a?"backlog":"pending",priority:u,screenshot:F.visualPreview,componentName:g.componentPath||F.tag,reference:{...g,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}};CA&&(W.creator={name:CA.name,email:CA.email,avatar:CA.avatar});try{const N=await fetch(`${s}/api/annotations`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(W)});if(!N.ok){const P=await N.json().catch(()=>({}));throw new Error(P.message||P.error||"Backend failed")}t(e.success,"success"),K(null),AA(""),f(!1),$()}catch(N){console.error(N);const P=N.message&&N.message!=="Backend failed"?N.message:e.error;t(P,"error")}finally{FA(!1)}};return d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1711",className:"vg-container",children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1712",className:"vg-no-capture",children:[!i&&d.jsxs("div",{style:{position:"fixed",top:`${DA.top}px`,right:`${DA.right}px`,zIndex:Un+10,display:"flex",alignItems:"center",gap:"8px",transition:Je?"none":"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:[d.jsx("div",{onMouseDown:Ph,style:{width:"20px",height:"32px",borderRadius:"6px",backgroundColor:"rgba(255, 255, 255, 0.85)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"grab",color:"#1e293b",opacity:B?0:1,visibility:B?"hidden":"visible",transition:"all 0.2s",border:"1px solid rgba(0,0,0,0.1)",boxShadow:"0 2px 8px rgba(0,0,0,0.05)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="white",g.currentTarget.style.color="#000000"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.85)",g.currentTarget.style.color="#1e293b"},children:d.jsx(ao,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1756",size:14})}),d.jsx("button",{onClick:g=>{g.stopPropagation(),bA({title:e.exitConfirmTitle||"Close ViewGate?",message:e.exitConfirmMessage||"Are you sure you want to close ViewGate?",type:"danger",onConfirm:()=>o()})},title:"Cerrar ViewGate",style:{width:"40px",height:"40px",borderRadius:"12px",backgroundColor:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid rgba(0,0,0,0.05)",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",cursor:"pointer",color:"#64748b",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},onMouseEnter:g=>{g.currentTarget.style.transform="scale(1.1) rotate(90deg)",g.currentTarget.style.color="#ef4444",g.currentTarget.style.backgroundColor="white"},onMouseLeave:g=>{g.currentTarget.style.transform="scale(1) rotate(0deg)",g.currentTarget.style.color="#64748b",g.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.9)"},children:d.jsx(Cs,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1796",size:20,strokeWidth:2.5})})]}),d.jsxs("div",{style:{position:"fixed",bottom:`${gt.bottom}px`,right:`${gt.right}px`,zIndex:Un,display:"flex",alignItems:"center",gap:"8px",transition:Jt?"none":"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)"},id:"viewgate-ui",children:[d.jsx("div",{onMouseDown:Xh,style:{width:"24px",height:"40px",borderRadius:"10px",backgroundColor:"rgba(255, 255, 255, 0.85)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"grab",color:"#1e293b",opacity:B?0:1,visibility:B?"hidden":"visible",transition:"all 0.2s",border:"1px solid rgba(0,0,0,0.1)",boxShadow:"0 2px 8px rgba(0,0,0,0.05)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="white",g.currentTarget.style.color="#000000"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.85)",g.currentTarget.style.color="#1e293b"},className:"vg-animate-slide-up",children:d.jsx(ao,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1845",size:16})}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1848",className:"vg-action-bar vg-animate-slide-up",style:{transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)"},children:[d.jsx("button",{onClick:()=>{if(!k&&!a&&!B){t(A==="es"?"No hay un sprint activo. No se pueden generar comentarios.":"No active sprint found. Cannot generate comments.","error");return}f(!B)},className:"vg-button-primary vg-animate-pop",style:{padding:"12px 24px",background:B?"#ef4444":!k&&!a?"#94a3b8":void 0,cursor:!k&&!a&&!B?"not-allowed":"pointer",opacity:!k&&!a&&!B?.7:1},title:!k&&!a&&!B?A==="es"?"Requiere sprint activo":"Requires active sprint":"",children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1866",style:{display:"flex",alignItems:"center",gap:"10px"},children:[B?d.jsx(Cs,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1867",size:20,className:"vg-animate-pop"}):d.jsx(qt,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1867",size:20,className:"vg-animate-pop"}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1868",children:B?e.exitMode:e.enterMode})]})}),tA.length>0&&d.jsxs("button",{onClick:()=>{cA(!eA),f(!1),K(null)},className:"vg-button-ghost vg-animate-pop",style:{animationDelay:"0.1s"},children:[d.jsx(Ic,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1881",size:20}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1882",children:e.viewComments})]})]})]}),UA&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1890",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:Un+1,cursor:"wait"},children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1896",className:"vg-glassmorphism",style:{padding:"30px 50px",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1897",className:"vg-spinner"}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1898",style:{fontWeight:600,fontSize:"14px",color:"#000000"},children:"Capturando..."})]})}),B&&!F&&d.jsx("div",{className:"vg-backdrop-blur",style:{opacity:1,clipPath:x?`polygon(
12
+ 📊 Performance Summary (Total: ${A.totalDuration.toFixed(2)}ms):`),A.breakdown.sort((e,r)=>r.duration-e.duration).forEach(e=>{this.context.logger.info(` ${e.name.padEnd(20)} ${e.duration.toFixed(2).padStart(8)}ms ${e.percentage.padStart(6)}`)})}clear(){this.activeMetrics.clear(),this.completedMetrics.splice(0)}isEnabled(){return this.enabled}getActiveMetrics(){return Array.from(this.activeMetrics.keys())}}const ya=(t,A={},e)=>{const r=e||_t.fromElement(t,{cspNonce:A.cspNonce,cache:A.cache});return Ih(t,A,r)},Hh=t=>{console.warn('[html2canvas-pro] setCspNonce is deprecated. Pass cspNonce in options instead: html2canvas(element, { cspNonce: "..." })'),typeof window<"u"&&Fh(new _t({window,cspNonce:t}))};ya.setCspNonce=Hh;const bh=t=>{["scale","width","height","imageTimeout","x","y","windowWidth","windowHeight","scrollX","scrollY"].forEach(e=>{const r=t[e];if(r!=null&&typeof r!="number"){const s=Number(r);Number.isNaN(s)||(t[e]=s)}})},Ih=async(t,A,e)=>{if(bh(A),!A.skipValidation){const eA=A.validator||Eh(),cA=eA.validateElement(t);if(!cA.valid)throw new Error(cA.error);const tA=eA.validateOptions(A);if(!tA.valid)throw new Error(`Invalid options: ${tA.error}`)}if(!t||typeof t!="object")throw new Error("Invalid element provided as first argument");const r=t.ownerDocument;if(!r)throw new Error("Element is not attached to a Document");const s=r.defaultView;if(!s)throw new Error("Document is not attached to a Window");const n={allowTaint:A.allowTaint??!1,imageTimeout:A.imageTimeout??15e3,proxy:A.proxy,useCORS:A.useCORS??!1,customIsSameOrigin:A.customIsSameOrigin},o={logging:A.logging??!0,cache:A.cache??e.cache,...n},i=800,a=600,l=0,c=s,B={windowWidth:A.windowWidth??c.innerWidth??i,windowHeight:A.windowHeight??c.innerHeight??a,scrollX:A.scrollX??c.pageXOffset??l,scrollY:A.scrollY??c.pageYOffset??l},f=new LA(B.scrollX,B.scrollY,B.windowWidth,B.windowHeight),u=new Yr(o,f,e),h=A.enablePerformanceMonitoring??A.logging??!1,w=new yh(u,h);w.start("total",{width:B.windowWidth,height:B.windowHeight});const U=A.foreignObjectRendering??!1,y={allowTaint:A.allowTaint??!1,onclone:A.onclone,ignoreElements:A.ignoreElements,iframeContainer:A.iframeContainer,inlineImages:U,copyStyles:U,cspNonce:A.cspNonce??e.cspNonce};u.logger.debug(`Starting document clone with size ${f.width}x${f.height} scrolled to ${-f.left},${-f.top}`),w.start("clone");const p=new da(u,t,y),x=p.clonedReferenceElement;if(!x)throw new Error("Unable to find element in cloned iframe");const T=await p.toIFrame(r,f);w.end("clone");const{width:F,height:K,left:_,top:AA}=cn(x)||pf(x)?Mc(x.ownerDocument):Ar(u,x),S=vh(u,x,A.backgroundColor),FA={canvas:A.canvas,backgroundColor:S,scale:A.scale??s.devicePixelRatio??1,x:(A.x??0)+_,y:(A.y??0)+AA,width:A.width??Math.ceil(F),height:A.height??Math.ceil(K),imageSmoothing:A.imageSmoothing,imageSmoothingQuality:A.imageSmoothingQuality};let UA,QA;try{return U?(u.logger.debug("Document cloned, using foreign object rendering"),w.start("render-foreignobject"),UA=await new gh(u,FA).render(x),w.end("render-foreignobject")):(u.logger.debug(`Document cloned, element located at ${_},${AA} with size ${F}x${K} using computed rendering`),u.logger.debug("Starting DOM parsing"),w.start("parse"),QA=Aa(u,x),w.end("parse"),S===QA.styles.backgroundColor&&(QA.styles.backgroundColor=ie.TRANSPARENT),u.logger.debug(`Starting renderer for element at ${FA.x},${FA.y} with size ${FA.width}x${FA.height}`),w.start("render"),UA=await new Qn(u,FA).render(QA),w.end("render")),w.start("cleanup"),(A.removeContainer??!0)&&(da.destroy(T)||u.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),w.end("cleanup"),w.end("total"),u.logger.debug("Finished rendering"),h&&w.logSummary(),UA}finally{QA&&QA.restoreTree()}},vh=(t,A,e)=>{const r=A.ownerDocument,s=r.documentElement?tt(t,getComputedStyle(r.documentElement).backgroundColor):ie.TRANSPARENT,n=r.body?tt(t,getComputedStyle(r.body).backgroundColor):ie.TRANSPARENT,o=typeof e=="string"?tt(t,e):e===null?ie.TRANSPARENT:4294967295;return A===r.documentElement?be(s)?be(n)?o:n:s:o},kt=2147483647,Un=kt-1,Fn=kt-1,Sh=kt-10,Lh=kt-5,Th=kt-15,ee="data-vg-pin-id",Kh=()=>{const t=window.innerWidth;return t<768?"mobile":t<1024?"tablet":"desktop"},Ha=(t,A)=>{if(!t)return"";try{const e=new Date(t);return isNaN(e.getTime())?"":new Intl.DateTimeFormat(A==="es"?"es-ES":"en-US",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}catch{return""}},ba=({url:t,className:A,style:e,tooltipStyle:r,onHover:s})=>{const n=C.useRef(null),o=()=>{if(!n.current||!s)return;const l=n.current.getBoundingClientRect(),c=l.top,B=window.innerHeight-l.bottom,f=c<140&&B>c?"bottom":"top";s({url:t,x:l.left+l.width/2,y:f==="top"?l.top:l.bottom,direction:f})},i=l=>l.toLowerCase().replace(/\/$/g,"").replace(/\/(?:[0-9]+|(?:[0-9a-f]{24}))(?=\/|$)/g,"/:id"),a=()=>{try{const l=i(window.location.pathname),c=new URL(t),B=i(c.pathname);return l===B||l.startsWith(B)||B.startsWith(l)}catch{return!1}};return d.jsxs("div",{ref:n,className:`vg-url-tag ${A||""}`,style:{...e,opacity:a()?1:.6,borderColor:a()?"var(--vg-primary)":"#e2e8f0"},onMouseEnter:o,onMouseMove:o,onMouseLeave:()=>s?.(null),children:[d.jsx(vc,{"data-source-path":"/src/components/ViewGateOverlay.tsx:141",size:e?.fontSize?parseInt(e.fontSize)+1:10}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:142",style:{maxWidth:e?.maxWidth||"150px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:new URL(t).pathname})]})},Pt=t=>{const A=[],e=[],r=[];let s=t;for(;s&&s.nodeType===Node.ELEMENT_NODE;){if(s.id&&!s.id.startsWith("vg-")&&!s.id.includes(":")){A.unshift(`#${s.id}`),r.unshift(`${s.localName}#${s.id}`);break}let n=s.localName;const o=Array.from(s.parentNode?.children||[]).indexOf(s),i=`${s.localName}[${o}]`;r.unshift(i);const a=s.getAttribute("data-testid")||s.getAttribute("data-qa");if(a&&e.push(`[data-testid="${a}"]`),s.getAttribute("placeholder"),s.getAttribute("aria-label"),s.getAttribute("role"),s.getAttribute("name"),s.getAttribute("title"),a){n=`[${s.hasAttribute("data-testid")?"data-testid":"data-qa"}="${a}"]`,A.unshift(n);break}const l=Array.from(s.parentNode?.children||[]).filter(c=>c.localName===s?.localName);if(l.length>1){const c=l.indexOf(s)+1;n+=`:nth-of-type(${c})`}A.unshift(n),s=s.parentElement}return{selector:A.join(" > "),fallbacks:e,vgPath:r.join(" > ")}},Dh=t=>{const{vgPath:A}=Pt(t);return{vgPath:A,classHash:t.className,parentTag:t.parentElement?.tagName.toLowerCase(),neighborCount:t.parentElement?.children.length,ariaLabel:t.getAttribute("aria-label")||void 0,role:t.getAttribute("role")||void 0,name:t.getAttribute("name")||void 0,type:t.getAttribute("type")||void 0,placeholder:t.getAttribute("placeholder")||void 0,textSnippet:(t.innerText||"").slice(0,30).trim()}},Oh=(()=>{let t=null,A=null;return e=>{if(!e||typeof window>"u"||typeof document>"u")return e;if(e.includes("oklch")||e.includes("oklab")||e.includes("lab(")||e.includes("lch(")||e.includes("color("))try{if(t||(t=document.createElement("canvas"),t.width=1,t.height=1),A||(A=t.getContext("2d",{willReadFrequently:!0})),A){A.fillStyle="#000000",A.fillStyle=e;const n=A.fillStyle;if(n&&!n.includes("oklch")&&!n.includes("oklab"))return n}const r=document.createElement("div");r.style.color=e,document.body.appendChild(r);const s=getComputedStyle(r).color;return document.body.removeChild(r),s&&!s.includes("oklch")?s:"rgb(0,0,0)"}catch{return"rgb(0,0,0)"}return e}})(),Rh=t=>{const A=window.getComputedStyle(t),e={};return["display","position","margin","padding","font-size","color","background-color","width","height","z-index"].forEach(s=>{const n=A.getPropertyValue(s);e[s]=Oh(n)}),e},Mh=t=>{const e=Object.keys(t).find(n=>n.startsWith("__reactFiber$")||n.startsWith("__reactInternalInstance$"));if(!e)return"";const r=[];let s=t[e];for(;s;){const n=s.type;if(typeof n=="function"){const o=n.displayName||n.name;o&&!o.includes("ViewGate")&&!r.includes(o)&&r.unshift(o)}s=s.return}return r.join(" > ")||"Generic Component"},xn=t=>{if(!t||t.id==="viewgate-ui"||t.id==="viewgate-shadow-host"||t.closest("#viewgate-shadow-host"))return!1;if(t.getAttribute("role")==="dialog"||t.getAttribute("aria-modal")==="true"||t.classList.contains("modal")||t.classList.contains("modal-content"))return!0;const A=window.getComputedStyle(t),e=t.getBoundingClientRect(),r=t.getAttribute("role");if(r&&["listbox","menu","combobox","tooltip","option"].includes(r)||e.width<120&&e.height<120)return!1;const n=parseInt(A.zIndex)||0,o=A.position==="fixed"||A.position==="absolute",i=e.width>window.innerWidth*.4&&e.height>window.innerHeight*.4,a=Math.abs(e.left+e.width/2-window.innerWidth/2)<50,l=t.getAttribute("class")||"",c=l.toLowerCase().includes("modal")||l.toLowerCase().includes("dialog");return!!(o&&n>=100&&(i||a||c))},Te=t=>{if(!t.isConnected)return!1;const A=window.getComputedStyle(t);if(A.display==="none"||A.visibility==="hidden"||A.opacity==="0")return t.tagName!=="BODY"&&t.tagName,!1;if(t.offsetWidth===0||t.offsetHeight===0)return!1;let e=t.parentElement;for(;e;){const s=window.getComputedStyle(e);if(s.display==="none"||s.visibility==="hidden"||s.opacity==="0")return!1;e=e.parentElement}const r=t.getBoundingClientRect();return!(r.width===0||r.height===0)},Ia=(t,A=document)=>{const e=A.querySelector(t);if(e)return e;const r=A.querySelectorAll("*");for(const s of Array.from(r)){const n=s.shadowRoot;if(n){const o=Ia(t,n);if(o)return o}}return null},va=(t,A)=>{let e=document.elementFromPoint(t,A);for(;e&&e.shadowRoot;){const r=e.shadowRoot.elementFromPoint(t,A);if(!r||r===e)break;e=r}return e},Nh=t=>{if(!t.tag)return null;const A=Array.from(document.getElementsByTagName(t.tag));let e=null,r=0;for(const s of A){if(!zr(s,t))continue;let n=0;const o=s.getAttribute("placeholder"),i=t.attributes?.placeholder||t.fingerprint?.placeholder;i&&o===i&&(n+=6);const a=s.getAttribute("type"),l=t.attributes?.type||t.fingerprint?.type;if(l&&a===l&&(n+=2),s.innerText?.trim()===t.text.trim()&&(n+=5),t.fingerprint?.vgPath){const{vgPath:c}=Pt(s);(c===t.vgPath||t.fingerprint?.vgPath===c)&&(n+=10)}n>r&&n>=7&&(r=n,e=s)}return e},zr=(t,A)=>{if(t.tagName.toLowerCase()!==A.tag.toLowerCase())return!1;const e=t.getAttribute("placeholder"),r=A.attributes?.placeholder||A.fingerprint?.placeholder;if(r&&e&&r!==e)return!1;const s=t.getAttribute("type"),n=A.attributes?.type||A.fingerprint?.type;return!(n&&s&&n!==s)},Sa=(t,A)=>{if(A){const o=Array.from(document.querySelectorAll(`[${ee}="${A}"]`));if(o.length>0){const i=o.filter(a=>zr(a,t));if(i.length===0)o.forEach(a=>a.removeAttribute(ee));else{const a=i.find(c=>{const{vgPath:B}=Pt(c);return B===t.vgPath||t.fingerprint?.vgPath===B}),l=a&&Te(a)?a:i.find(c=>!(!Te(c)||t.metadata?.isModal&&!c.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content')));return l?(o.forEach(c=>{c!==l&&c.removeAttribute(ee)}),l):null}}}const r=(t.selector?Array.from(document.querySelectorAll(t.selector)):[]).filter(o=>zr(o,t));let s=r.find(o=>{const{vgPath:i}=Pt(o);return i===t.vgPath||t.fingerprint?.vgPath===i})||r[0]||null;if(s&&Te(s))if(t.metadata?.isModal&&!s.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content'))s=null;else return s;if(t.fallbackSelectors)for(const o of t.fallbackSelectors){const i=Ia(o);if(i&&zr(i,t)&&Te(i)){if(t.metadata?.isModal&&!i.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content'))continue;return i}}const n=Nh(t);return n&&Te(n)?t.metadata?.isModal&&!n.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content')?null:n:null},En=t=>({tag:t.tagName.toLowerCase(),text:(t.innerText||t.getAttribute("placeholder")||"").slice(0,50).trim(),role:t.getAttribute("role")||void 0,type:t.getAttribute("type")||void 0}),Gh=t=>{const A=t.parentElement;if(!A)return;const e=Array.from(A.children).filter(o=>o!==t).slice(0,5).map(o=>En(o)),r=Array.from(A.children),s=r.indexOf(t);let n="middle";return s===0&&(n="start"),s===r.length-1&&(n="end"),{target:{...En(t),location:`${n} of ${A.tagName.toLowerCase()}`},parent:En(A),siblings:e}},La=(t,A)=>{let e="unknown:0",r=t;for(;r;){const f=r.getAttribute("data-source-path");if(f){e=f;break}r=r.parentElement}const s=Mh(t),{selector:n,fallbacks:o,vgPath:i}=Pt(t),a={};["placeholder","aria-label","name","type","alt","title","value","role"].forEach(f=>{const u=t.getAttribute(f);u&&(a[f]=u)});const l=(()=>{let f=t;for(;f&&f!==document.body;){if(xn(f))return!0;f=f.parentElement}return!1})();let c;l&&A&&!A.closest('[role="dialog"], [aria-modal="true"], .modal, .modal-content')&&(c=La(A));const B=`${t.tagName.toLowerCase()}-${(t.innerText||"").slice(0,20).replace(/\s+/g,"_")}-${n.split(" > ").slice(-1)}`;return{tag:t.tagName.toLowerCase(),id:t.id||"",classes:t.className||"",text:(t.innerText||"").slice(0,100).trim(),selector:n,vgPath:i,outerHtml:t.outerHTML,parentContext:t.parentElement?`<${t.parentElement.tagName.toLowerCase()} ${Array.from(t.parentElement.attributes).map(f=>`${f.name}="${f.value}"`).join(" ").slice(0,500)}>`:"N/A",componentPath:s,signature:B,source:e,attributes:a,fallbackSelectors:[...new Set(o)].slice(0,5),domPath:[],viewportSize:{width:window.innerWidth,height:window.innerHeight},uiContext:Gh(t),fingerprint:Dh(t),metadata:{hint:`Edit ${e.split(":")[0]} at line ${e.split(":")[1]||"?"}`,computedStyles:Rh(t),viewportBreakpoint:Kh(),outerHtml:t.outerHTML.slice(0,1500),scrollPosition:{x:window.scrollX,y:window.scrollY},isModal:l,triggerReference:c}}},Ta=()=>{const{addToast:t,language:A,t:e,apiKey:r,baseUrl:s,dashboardUrl:n,disableViewGate:o,hasActiveToasts:i}=uo(),a=C.useMemo(()=>typeof window>"u"?!1:window.location.href.includes("viewgate-backlog"),[]),[l,c]=C.useState(typeof window<"u"?window.location.pathname:"/");C.useEffect(()=>{const g=()=>c(window.location.pathname);window.addEventListener("popstate",g);const b=window.history.pushState,m=window.history.replaceState;return window.history.pushState=function(...v){b.apply(this,v),setTimeout(g,0)},window.history.replaceState=function(...v){m.apply(this,v),setTimeout(g,0)},()=>{window.removeEventListener("popstate",g),window.history.pushState=b,window.history.replaceState=m}},[]);const[B,f]=C.useState(!1),[u,h]=C.useState("medium"),[w,U]=C.useState("medium"),[y,p]=C.useState("all"),[x,T]=C.useState(null),[F,K]=C.useState(null),[_,AA]=C.useState(""),[S,FA]=C.useState(!1),[UA,QA]=C.useState(!1),[eA,cA]=C.useState(!1),[tA,zA]=C.useState([]),[OA,bA]=C.useState(null),[lt,ce]=C.useState(!1),[Q,D]=C.useState({}),[M,Z]=C.useState(null),[WA,te]=C.useState(!1),[k,VA]=C.useState(null),[Ke,Bt]=C.useState([]),[CA,Xt]=C.useState(()=>{if(typeof window>"u")return null;const g=localStorage.getItem("vg_selected_member");return g?JSON.parse(g):null});C.useEffect(()=>{!r||!s||fetch(`${s}/api/projects/members`,{headers:{"x-api-key":r}}).then(g=>g.json()).then(g=>{Array.isArray(g)&&Bt(g)}).catch(g=>console.error("Failed to fetch project members",g))},[r,s]);const Hn=g=>{Xt(g),localStorage.setItem("vg_selected_member",JSON.stringify(g))},De=C.useCallback(async g=>{const m=await fetch(g,{headers:{"x-api-key":r}});if(!m.ok){const v=await m.json().catch(()=>({}));throw new Error(v.message||v.error||"Fetch failed")}return m.json()},[r]),Zr=C.useMemo(()=>a?"backlog":"pending,todo,in_progress,review,ready_for_review,bug_fixing",[a]),{data:$r,isLoading:rA}=ro(r?`${s}/api/projects/active-sprint`:null,De,{refreshInterval:3e4,revalidateOnFocus:!0}),{data:sA,isLoading:z,mutate:$}=ro(r&&($r||a)?`${s}/api/annotations?status=${Zr}`:null,De,{refreshInterval:1e4,revalidateOnFocus:!0,dedupingInterval:2e3}),[xA,RA]=C.useState(null),BA=C.useRef(tA);BA.current=tA;const[q,le]=C.useState(null),Oe=C.useRef(null),[we,qr]=C.useState([]),KA=C.useMemo(()=>{let g=Array.isArray(tA)?tA:[];if(M){const m=we.find(v=>v.annotations&&Array.isArray(v.annotations)&&v.annotations.some(W=>W._id===M));m?g=m.annotations:g=g.filter(v=>v._id===M)}return g=g.filter(m=>m.status!=="completed"&&m.status!=="done"),window.location.href.includes("viewgate-backlog")||(q==="pending"?g=g.filter(m=>m.status!=="ready_for_review"):q==="ready"&&(g=g.filter(m=>m.status==="ready_for_review"))),y!=="all"&&(g=g.filter(m=>(m.priority||"medium")===y)),g},[M,tA,we,q,y]);C.useEffect(()=>{M&&KA.length===0&&!z&&Z(null)},[M,KA.length,z]);const[DA,Wt]=C.useState(()=>{if(typeof window>"u")return{top:24,right:24};const g=localStorage.getItem("vg-exit-pos");return g?JSON.parse(g):{top:24,right:24}}),[Je,dt]=C.useState(!1),pe=C.useRef(null),[gt,kh]=C.useState(()=>{if(typeof window>"u")return{bottom:30,right:30};const g=localStorage.getItem("vg-bar-pos");return g?JSON.parse(g):{bottom:30,right:30}}),[Jt,Ka]=C.useState(!1),Qe=C.useRef(null),Ph=g=>{g.preventDefault(),g.stopPropagation();const b=g.currentTarget.parentElement?.getBoundingClientRect();b&&(dt(!0),pe.current={x:g.clientX,y:g.clientY,top:DA.top,right:DA.right,width:b.width,height:b.height})},Xh=g=>{g.preventDefault(),g.stopPropagation();const b=g.currentTarget.parentElement?.getBoundingClientRect();b&&(Ka(!0),Qe.current={x:g.clientX,y:g.clientY,bottom:gt.bottom,right:gt.right,width:b.width,height:b.height})};C.useEffect(()=>{if(!Je&&!Jt)return;const g=m=>{if(Je&&pe.current){const v=m.clientX-pe.current.x,W=m.clientY-pe.current.y;let N=pe.current.top+W,P=pe.current.right-v;const L=10;N=Math.max(L,Math.min(window.innerHeight-pe.current.height-L,N)),P=Math.max(L,Math.min(window.innerWidth-pe.current.width-L,P)),Wt({top:N,right:P})}if(Jt&&Qe.current){const v=m.clientX-Qe.current.x,W=m.clientY-Qe.current.y;let N=Qe.current.bottom-W,P=Qe.current.right-v;const L=10;N=Math.max(L,Math.min(window.innerHeight-Qe.current.height-L,N)),P=Math.max(L,Math.min(window.innerWidth-Qe.current.width-L,P)),kh({bottom:N,right:P})}},b=()=>{Je&&(dt(!1),localStorage.setItem("vg-exit-pos",JSON.stringify(DA)),pe.current=null),Jt&&(Ka(!1),localStorage.setItem("vg-bar-pos",JSON.stringify(gt)),Qe.current=null)};return window.addEventListener("mousemove",g),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",b)}},[Je,Jt,DA,gt]);const[bn,In]=C.useState(null),[Da,Oa]=C.useState(""),[fw,hw]=C.useState({}),vn=C.useRef(null),ut=C.useRef(null),Sn=C.useRef(null),As=C.useRef(!1),Ra=C.useCallback(()=>{typeof window>"u"||As.current||(ut.current&&cancelAnimationFrame(ut.current),ut.current=requestAnimationFrame(()=>{ut.current=null,As.current=!0,Sn.current;const g=BA.current,b=Array.isArray(g)?g:[],m=new Set(b.map(j=>j._id));document.querySelectorAll(`[${ee}]`).forEach(j=>{const ZA=j.getAttribute(ee);ZA&&!m.has(ZA)&&j.removeAttribute(ee)});const W=Array.from(document.querySelectorAll('[role="dialog"], [aria-modal="true"], .modal, .modal-backdrop, .fixed.inset-0')).find(j=>xn(j)&&Te(j)),N=!!W,P=new Map,L=new Map;b.forEach(j=>{if(!j||!j.reference)return;try{const nA=()=>window.location.pathname.toLowerCase().replace(/\/$/g,"").replace(/\/(?:[0-9]+|(?:[0-9a-f]{24}))(?=\/|$)/g,"/:id"),vA=Re=>{try{return new URL(Re).pathname.toLowerCase().replace(/\/$/g,"").replace(/\/(?:[0-9]+|(?:[0-9a-f]{24}))(?=\/|$)/g,"/:id")}catch{return""}},me=nA(),jt=vA(j.url);if(me!==jt&&!j.url.includes(window.location.pathname))return}catch{return}const ZA=!!j.reference.metadata?.isModal,Ce=j.reference.metadata?.triggerReference;let fA=Sa(j.reference,j._id),hA=!1;if(Ce){const nA=Sa(Ce);nA&&Te(nA)&&(fA=nA,hA=!0)}if(!fA||!Te(fA))return;let mA=!1;if(N?mA=W.contains(fA):hA?mA=!0:mA=!ZA,!mA)return;const IA=fA.getAttribute(ee);IA!==j._id&&(document.querySelectorAll(`[${ee}="${j._id}"]`).forEach(nA=>{nA.removeAttribute(ee)}),IA||fA.setAttribute(ee,j._id));const X=hA?P:L;X.has(fA)||X.set(fA,{anns:[]}),X.get(fA).anns.push(j)});const dA=[],_A=(j,ZA)=>{j.forEach((Ce,fA)=>{const{anns:hA}=Ce,mA=fA.getBoundingClientRect(),IA=mA.left+mA.width/2,X=mA.top+mA.height/2;if(IA>=0&&IA<=window.innerWidth&&X>=0&&X<=window.innerHeight){const nA=document.elementFromPoint(IA,X),vA=document.getElementById("viewgate-shadow-host");if(nA&&!fA.contains(nA)&&nA!==vA&&!vA?.contains(nA))return}dA.push({id:hA[0]._id+(ZA?"_trig":""),element:fA,rect:mA,annotations:hA.sort((nA,vA)=>new Date(vA.timestamp||vA.createdAt).getTime()-new Date(nA.timestamp||nA.createdAt).getTime()),isModal:!!hA[0].reference?.metadata?.isModal,isTriggerPin:ZA})})};_A(P,!0),_A(L,!1),qr(dA),As.current=!1}))},[k]);C.useEffect(()=>{if(sA){const g=Array.isArray(sA)?sA:sA?.data||[];if(Array.isArray(g)){const b=g.reduce((m,v)=>m.find(N=>N._id===v._id)?m:m.concat([v]),[]);zA(b)}}else z||zA([])},[sA,z]),C.useEffect(()=>{VA($r||null)},[$r]),C.useEffect(()=>{eA&&tA.length===0&&!z&&cA(!1)},[eA,tA.length,z]),C.useEffect(()=>{let g=null;const b=()=>{As.current||Ra()},m=new MutationObserver(N=>{N.some(L=>L.type!=="attributes"||L.attributeName!==ee&&!L.target.parentElement?.closest("#viewgate-shadow-host"))&&(g&&clearTimeout(g),g=setTimeout(b,32))});Sn.current=m;const v=new ResizeObserver(()=>b()),W=()=>b();return b(),m.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),v.observe(document.documentElement),window.addEventListener("scroll",W,{capture:!0,passive:!0}),()=>{g&&clearTimeout(g),m.disconnect(),v.disconnect(),window.removeEventListener("scroll",W,!0),ut.current&&cancelAnimationFrame(ut.current),Sn.current=null}},[B,tA,Ra,eA,M,l]);const Ln=C.useCallback(g=>{let b=g;for(;b&&b!==document.body;){if(xn(b))return b;b=b.parentElement}return null},[]);C.useEffect(()=>{const g=b=>{const m=b.target;m&&(Ln(m)||(Oe.current=m))};return window.addEventListener("mousedown",g,!0),()=>window.removeEventListener("mousedown",g,!0)},[Ln]),C.useEffect(()=>{vn.current=document.getElementById("viewgate-shadow-host")},[]);const Tn=C.useCallback(g=>{if(!B||F)return;const b=va(g.clientX,g.clientY);if(!b||vn.current?.contains(b)||b.closest(".vg-no-capture")){T(null);return}const m=b.getBoundingClientRect();T({tag:b.tagName.toLowerCase(),source:b.getAttribute("data-source-path")||"unknown:0",rect:m,element:b,previewText:(b.innerText||"").slice(0,100)||(b.getAttribute("placeholder")||"").slice(0,100)||b.tagName.toLowerCase(),semanticReference:{...La(b,Oe.current),normalizedOffset:{x:(g.clientX-m.left)/m.width,y:(g.clientY-m.top)/m.height}}})},[B,F]),Kn=C.useCallback(async g=>{if(!B||F)return;const b=va(g.clientX,g.clientY);if(!(!b||vn.current?.contains(b)||b.closest(".vg-no-capture"))&&x){g.preventDefault(),g.stopPropagation(),QA(!0);try{await new Promise(X=>requestAnimationFrame(X)),await new Promise(X=>setTimeout(X,80));const m=x.element,v=m.getBoundingClientRect(),N=Ln(m)||document.documentElement,P=N.getBoundingClientRect(),L=window.devicePixelRatio||1,dA=Math.max(L,3),_A=Array.from(N.querySelectorAll("img"));await Promise.all(_A.map(X=>{const nA=X.getBoundingClientRect();return nA.bottom>-200&&nA.top<window.innerHeight+200&&(X.loading==="lazy"&&(X.loading="eager"),!X.complete)?new Promise(vA=>{X.onload=vA,X.onerror=vA}):Promise.resolve()})).catch(()=>{});const j=N===document.documentElement||N===document.body,ZA=v.left-P.left+(j?0:N.scrollLeft),Ce=v.top-P.top+(j?0:N.scrollTop),fA=await ya(N,{scale:dA,useCORS:!0,logging:!1,backgroundColor:null,allowTaint:!0,imageTimeout:2e4,scrollX:0,scrollY:0,windowWidth:document.documentElement.offsetWidth,windowHeight:document.documentElement.offsetHeight,onclone:X=>{const nA=X.getElementById("viewgate-shadow-host");nA&&nA.style.setProperty("display","none","important");const vA=X.querySelector(".vg-selection-overlay");vA&&vA.style.setProperty("display","none","important");const me=X.querySelector("[data-vg-root]");me&&(me.style.transform="none",me.style.perspective="none")},ignoreElements:X=>X.id==="viewgate-shadow-host"||X.classList.contains("vg-no-capture")||X.classList.contains("vg-selection-overlay")}),hA=document.createElement("canvas"),mA=hA.getContext("2d"),IA=24;if(hA.width=(v.width+IA*2)*dA,hA.height=(v.height+IA*2)*dA,mA){mA.imageSmoothingEnabled=!0,mA.imageSmoothingQuality="high";const X=(ZA-IA)*dA,nA=(Ce-IA)*dA,vA=(v.width+IA*2)*dA,me=(v.height+IA*2)*dA;mA.drawImage(fA,X,nA,vA,me,0,0,hA.width,hA.height),hA.toBlob(async jt=>{if(jt){const Re=new FileReader;Re.onloadend=()=>{K({...x,visualPreview:Re.result})},Re.readAsDataURL(jt)}else K(x)},"image/webp",.98)}}catch(m){console.error("ViewGate High-Fidelity Capture Error:",m),K(x)}finally{QA(!1),T(null)}}},[B,x,F]);C.useEffect(()=>{const g=b=>{if(b.key==="Escape"){F?K(null):eA?cA(!1):B&&f(!1);return}const v=(()=>{let P=document.activeElement;for(;P&&P.shadowRoot&&P.shadowRoot.activeElement;)P=P.shadowRoot.activeElement;return P})();if(["input","textarea"].includes((v?.tagName||"").toLowerCase())||v?.isContentEditable)return;const N=b.key.toLowerCase();if(N==="c"&&!F&&!eA){if(!(k&&k.status!=="closed")&&!a&&!B){t(A==="es"?"No hay un sprint activo. No se pueden generar comentarios.":"No active sprint found. Cannot generate comments.","error");return}f(L=>!L)}N==="v"&&!F&&(tA.length>0||eA)&&(cA(P=>!P),eA||f(!1))};return B&&!F?document.body.classList.add("vg-cursor-pointer"):document.body.classList.remove("vg-cursor-pointer"),window.addEventListener("keydown",g),window.addEventListener("mousemove",Tn,!0),window.addEventListener("click",Kn,!0),()=>{document.body.classList.remove("vg-cursor-pointer"),window.removeEventListener("keydown",g),window.removeEventListener("mousemove",Tn,!0),window.removeEventListener("click",Kn,!0)}},[B,F,eA,tA,Tn,Kn]);const Wh=async()=>{if(!F||!_.trim())return;if(!CA){t(A==="es"?"Selecciona un usuario para comentar":"Please select a user to comment","error");return}FA(!0);const{semanticReference:g}=F,[b,m]=(g.source||"").split(":"),W={filePath:b,line:parseInt(m||"0"),url:window.location.href,title:_.length>50?_.substring(0,50)+"...":_,message:_,status:a?"backlog":"pending",priority:u,screenshot:F.visualPreview,componentName:g.componentPath||F.tag,reference:{...g,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}};CA&&(W.creator={name:CA.name,email:CA.email,avatar:CA.avatar});try{const N=await fetch(`${s}/api/annotations`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(W)});if(!N.ok){const P=await N.json().catch(()=>({}));throw new Error(P.message||P.error||"Backend failed")}t(e.success,"success"),K(null),AA(""),f(!1),$()}catch(N){console.error(N);const P=N.message&&N.message!=="Backend failed"?N.message:e.error;t(P,"error")}finally{FA(!1)}};return d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1711",className:"vg-container",children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1712",className:"vg-no-capture",children:[!i&&d.jsxs("div",{style:{position:"fixed",top:`${DA.top}px`,right:`${DA.right}px`,zIndex:Un+10,display:"flex",alignItems:"center",gap:"8px",transition:Je?"none":"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:[d.jsx("div",{onMouseDown:Ph,style:{width:"20px",height:"32px",borderRadius:"6px",backgroundColor:"rgba(255, 255, 255, 0.85)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"grab",color:"#1e293b",opacity:B?0:1,visibility:B?"hidden":"visible",transition:"all 0.2s",border:"1px solid rgba(0,0,0,0.1)",boxShadow:"0 2px 8px rgba(0,0,0,0.05)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="white",g.currentTarget.style.color="#000000"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.85)",g.currentTarget.style.color="#1e293b"},children:d.jsx(ao,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1756",size:14})}),d.jsx("button",{onClick:g=>{g.stopPropagation(),bA({title:e.exitConfirmTitle||"Close ViewGate?",message:e.exitConfirmMessage||"Are you sure you want to close ViewGate?",type:"danger",onConfirm:()=>o()})},title:"Cerrar ViewGate",style:{width:"40px",height:"40px",borderRadius:"12px",backgroundColor:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid rgba(0,0,0,0.05)",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",cursor:"pointer",color:"#64748b",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},onMouseEnter:g=>{g.currentTarget.style.transform="scale(1.1) rotate(90deg)",g.currentTarget.style.color="#ef4444",g.currentTarget.style.backgroundColor="white"},onMouseLeave:g=>{g.currentTarget.style.transform="scale(1) rotate(0deg)",g.currentTarget.style.color="#64748b",g.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.9)"},children:d.jsx(Cs,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1796",size:20,strokeWidth:2.5})})]}),d.jsxs("div",{style:{position:"fixed",bottom:`${gt.bottom}px`,right:`${gt.right}px`,zIndex:Un,display:"flex",alignItems:"center",gap:"8px",transition:Jt?"none":"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)"},id:"viewgate-ui",children:[d.jsx("div",{onMouseDown:Xh,style:{width:"24px",height:"40px",borderRadius:"10px",backgroundColor:"rgba(255, 255, 255, 0.85)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"grab",color:"#1e293b",opacity:B?0:1,visibility:B?"hidden":"visible",transition:"all 0.2s",border:"1px solid rgba(0,0,0,0.1)",boxShadow:"0 2px 8px rgba(0,0,0,0.05)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="white",g.currentTarget.style.color="#000000"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.85)",g.currentTarget.style.color="#1e293b"},className:"vg-animate-slide-up",children:d.jsx(ao,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1845",size:16})}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1848",className:"vg-action-bar vg-animate-slide-up",style:{transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)"},children:[d.jsx("button",{onClick:()=>{if(!k&&!a&&!B){t(A==="es"?"No hay un sprint activo. No se pueden generar comentarios.":"No active sprint found. Cannot generate comments.","error");return}f(!B)},className:"vg-button-primary vg-animate-pop",style:{padding:"12px 24px",background:B?"#ef4444":!k&&!a?"#94a3b8":void 0,cursor:!k&&!a&&!B?"not-allowed":"pointer",opacity:!k&&!a&&!B?.7:1},title:!k&&!a&&!B?A==="es"?"Requiere sprint activo":"Requires active sprint":"",children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1866",style:{display:"flex",alignItems:"center",gap:"10px"},children:[B?d.jsx(Cs,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1867",size:20,className:"vg-animate-pop"}):d.jsx(qt,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1867",size:20,className:"vg-animate-pop"}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1868",children:B?e.exitMode:e.enterMode})]})}),tA.length>0&&d.jsxs("button",{onClick:()=>{cA(!eA),f(!1),K(null)},className:"vg-button-ghost vg-animate-pop",style:{animationDelay:"0.1s"},children:[d.jsx(Ic,{"data-source-path":"/src/components/ViewGateOverlay.tsx:1881",size:20}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1882",children:e.viewComments})]})]})]}),UA&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1890",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:Un+1,cursor:"wait"},children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1896",className:"vg-glassmorphism",style:{padding:"30px 50px",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1897",className:"vg-spinner"}),d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:1898",style:{fontWeight:600,fontSize:"14px",color:"#000000"},children:"Capturando..."})]})}),B&&!F&&d.jsx("div",{className:"vg-backdrop-blur",style:{opacity:1,clipPath:x?`polygon(
13
13
  0% 0%, 0% 100%, 100% 100%, 100% 0%, 0% 0%,
14
14
  ${x.rect.left}px ${x.rect.top}px,
15
15
  ${x.rect.right}px ${x.rect.top}px,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewgate-wrapper",
3
- "version": "1.11.8",
3
+ "version": "1.11.9",
4
4
  "type": "module",
5
5
  "main": "./dist/viewgate-wrapper.umd.cjs",
6
6
  "module": "./dist/viewgate-wrapper.js",