0?h.coordinate-b*e:h.coordinate})}else a[d]=h=an(an({},h),{},{tickCoord:h.coordinate});var g=Nh(e,h.tickCoord,m,u,s);g&&(s=h.tickCoord-e*(m()/2+i),a[d]=an(an({},h),{},{isShow:!0}))},c=o-1;c>=0;c--)l(c);return a}function foe(e,t,n,r,i,a){var o=(r||[]).slice(),u=o.length,s=t.start,l=t.end;if(a){var c=r[u-1],f=n(c,u-1),d=e*(c.coordinate+e*f/2-l);o[u-1]=c=an(an({},c),{},{tickCoord:d>0?c.coordinate-d*e:c.coordinate});var h=Nh(e,c.tickCoord,function(){return f},s,l);h&&(l=c.tickCoord-e*(f/2+i),o[u-1]=an(an({},c),{},{isShow:!0}))}for(var p=a?u-1:u,m=function(v){var E=o[v],S,x=function(){return S===void 0&&(S=n(E,v)),S};if(v===0){var w=e*(E.coordinate-e*x()/2-s);o[v]=E=an(an({},E),{},{tickCoord:w<0?E.coordinate-w*e:E.coordinate})}else o[v]=E=an(an({},E),{},{tickCoord:E.coordinate});var T=Nh(e,E.tickCoord,x,s,l);T&&(s=E.tickCoord+e*(x()/2+i),o[v]=an(an({},E),{},{isShow:!0}))},b=0;b=2?kr(i[1].coordinate-i[0].coordinate):1,g=ioe(a,b,h);return s==="equidistantPreserveStart"?ooe(b,g,m,i,o):(s==="preserveStart"||s==="preserveStartEnd"?d=foe(b,g,m,i,o,s==="preserveStartEnd"):d=coe(b,g,m,i,o),d.filter(function(v){return v.isShow}))}var doe=["viewBox"],hoe=["viewBox"],poe=["ticks"];function ju(e){"@babel/helpers - typeof";return ju=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ju(e)}function Zo(){return Zo=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function moe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function goe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function oA(e,t){for(var n=0;n0?s(this.props):s(h)),o<=0||u<=0||!p||!p.length?null:M.createElement(St,{className:We("recharts-cartesian-axis",l),ref:function(b){r.layerReference=b}},a&&this.renderAxisLine(),this.renderTicks(p,this.state.fontSize,this.state.letterSpacing),un.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(r,i,a){var o;return M.isValidElement(r)?o=M.cloneElement(r,i):Ne(r)?o=r(i):o=M.createElement(th,Zo({},i,{className:"recharts-cartesian-axis-tick-value"}),a),o}}])}(C.Component);mE(fs,"displayName","CartesianAxis");mE(fs,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var Soe=["x1","y1","x2","y2","key"],Toe=["offset"];function po(e){"@babel/helpers - typeof";return po=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},po(e)}function uA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function sn(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Ooe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var Poe=function(t){var n=t.fill;if(!n||n==="none")return null;var r=t.fillOpacity,i=t.x,a=t.y,o=t.width,u=t.height,s=t.ry;return M.createElement("rect",{x:i,y:a,ry:s,width:o,height:u,stroke:"none",fill:n,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function YN(e,t){var n;if(M.isValidElement(e))n=M.cloneElement(e,t);else if(Ne(e))n=e(t);else{var r=t.x1,i=t.y1,a=t.x2,o=t.y2,u=t.key,s=sA(t,Soe),l=Fe(s,!1);l.offset;var c=sA(l,Toe);n=M.createElement("line",Ga({},c,{x1:r,y1:i,x2:a,y2:o,fill:"none",key:u}))}return n}function koe(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0?!0:r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(u,s){var l=sn(sn({},e),{},{x1:t,y1:u,x2:t+n,y2:u,key:"line-".concat(s),index:s});return YN(i,l)});return M.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function Ioe(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0?!0:r,a=e.verticalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(u,s){var l=sn(sn({},e),{},{x1:u,y1:t,x2:u,y2:t+n,key:"line-".concat(s),index:s});return YN(i,l)});return M.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function Noe(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,u=e.horizontalPoints,s=e.horizontal,l=s===void 0?!0:s;if(!l||!t||!t.length)return null;var c=u.map(function(d){return Math.round(d+i-i)}).sort(function(d,h){return d-h});i!==c[0]&&c.unshift(0);var f=c.map(function(d,h){var p=!c[h+1],m=p?i+o-d:c[h+1]-d;if(m<=0)return null;var b=h%t.length;return M.createElement("rect",{key:"react-".concat(h),y:d,x:r,height:m,width:a,stroke:"none",fill:t[b],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function Roe(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,u=e.width,s=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var c=l.map(function(d){return Math.round(d+a-a)}).sort(function(d,h){return d-h});a!==c[0]&&c.unshift(0);var f=c.map(function(d,h){var p=!c[h+1],m=p?a+u-d:c[h+1]-d;if(m<=0)return null;var b=h%r.length;return M.createElement("rect",{key:"react-".concat(h),x:d,y:o,width:m,height:s,stroke:"none",fill:r[b],fillOpacity:i,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var Doe=function(t,n){var r=t.xAxis,i=t.width,a=t.height,o=t.offset;return iN(pE(sn(sn(sn({},fs.defaultProps),r),{},{ticks:xi(r,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.left,o.left+o.width,n)},Loe=function(t,n){var r=t.yAxis,i=t.width,a=t.height,o=t.offset;return iN(pE(sn(sn(sn({},fs.defaultProps),r),{},{ticks:xi(r,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.top,o.top+o.height,n)},Lo={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function KN(e){var t,n,r,i,a,o,u=cE(),s=fE(),l=wae(),c=sn(sn({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:Lo.stroke,fill:(n=e.fill)!==null&&n!==void 0?n:Lo.fill,horizontal:(r=e.horizontal)!==null&&r!==void 0?r:Lo.horizontal,horizontalFill:(i=e.horizontalFill)!==null&&i!==void 0?i:Lo.horizontalFill,vertical:(a=e.vertical)!==null&&a!==void 0?a:Lo.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:Lo.verticalFill,x:de(e.x)?e.x:l.left,y:de(e.y)?e.y:l.top,width:de(e.width)?e.width:l.width,height:de(e.height)?e.height:l.height}),f=c.x,d=c.y,h=c.width,p=c.height,m=c.syncWithTicks,b=c.horizontalValues,g=c.verticalValues,v=bae(),E=Eae();if(!de(h)||h<=0||!de(p)||p<=0||!de(f)||f!==+f||!de(d)||d!==+d)return null;var S=c.verticalCoordinatesGenerator||Doe,x=c.horizontalCoordinatesGenerator||Loe,w=c.horizontalPoints,T=c.verticalPoints;if((!w||!w.length)&&Ne(x)){var O=b&&b.length,R=x({yAxis:E?sn(sn({},E),{},{ticks:O?b:E.ticks}):void 0,width:u,height:s,offset:l},O?!0:m);_i(Array.isArray(R),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(po(R),"]")),Array.isArray(R)&&(w=R)}if((!T||!T.length)&&Ne(S)){var A=g&&g.length,I=S({xAxis:v?sn(sn({},v),{},{ticks:A?g:v.ticks}):void 0,width:u,height:s,offset:l},A?!0:m);_i(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(po(I),"]")),Array.isArray(I)&&(T=I)}return M.createElement("g",{className:"recharts-cartesian-grid"},M.createElement(Poe,{fill:c.fill,fillOpacity:c.fillOpacity,x:c.x,y:c.y,width:c.width,height:c.height,ry:c.ry}),M.createElement(koe,Ga({},c,{offset:l,horizontalPoints:w,xAxis:v,yAxis:E})),M.createElement(Ioe,Ga({},c,{offset:l,verticalPoints:T,xAxis:v,yAxis:E})),M.createElement(Noe,Ga({},c,{horizontalPoints:w})),M.createElement(Roe,Ga({},c,{verticalPoints:T})))}KN.displayName="CartesianGrid";var Moe=["type","layout","connectNulls","ref"],$oe=["key"];function Fu(e){"@babel/helpers - typeof";return Fu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fu(e)}function lA(e,t){if(e==null)return{};var n=joe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function joe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function dl(){return dl=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);nf){h=[].concat(Mo(s.slice(0,p)),[f-m]);break}var b=h.length%2===0?[0,d]:[d];return[].concat(Mo(t.repeat(s,c)),Mo(h),b).map(function(g){return"".concat(g,"px")}).join(", ")}),Ar(n,"id",Fc("recharts-line-")),Ar(n,"pathRef",function(o){n.mainCurve=o}),Ar(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),Ar(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Yoe(t,e),Voe(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();this.setState({totalLength:r})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();r!==this.state.totalLength&&this.setState({totalLength:r})}}},{key:"getTotalLength",value:function(){var r=this.mainCurve;try{return r&&r.getTotalLength&&r.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(r,i){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.points,u=a.xAxis,s=a.yAxis,l=a.layout,c=a.children,f=pr(c,Wc);if(!f)return null;var d=function(m,b){return{x:m.x,y:m.y,value:m.value,errorVal:Kn(m.payload,b)}},h={clipPath:r?"url(#clipPath-".concat(i,")"):null};return M.createElement(St,h,f.map(function(p){return M.cloneElement(p,{key:"bar-".concat(p.props.dataKey),data:o,xAxis:u,yAxis:s,layout:l,dataPointFormatter:d})}))}},{key:"renderDots",value:function(r,i,a){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var u=this.props,s=u.dot,l=u.points,c=u.dataKey,f=Fe(this.props,!1),d=Fe(s,!0),h=l.map(function(m,b){var g=Ln(Ln(Ln({key:"dot-".concat(b),r:3},f),d),{},{index:b,cx:m.x,cy:m.y,value:m.value,dataKey:c,payload:m.payload,points:l});return t.renderDotItem(s,g)}),p={clipPath:r?"url(#clipPath-".concat(i?"":"dots-").concat(a,")"):null};return M.createElement(St,dl({className:"recharts-line-dots",key:"dots"},p),h)}},{key:"renderCurveStatically",value:function(r,i,a,o){var u=this.props,s=u.type,l=u.layout,c=u.connectNulls;u.ref;var f=lA(u,Moe),d=Ln(Ln(Ln({},Fe(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:i?"url(#clipPath-".concat(a,")"):null,points:r},o),{},{type:s,layout:l,connectNulls:c});return M.createElement(Qy,dl({},d,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(r,i){var a=this,o=this.props,u=o.points,s=o.strokeDasharray,l=o.isAnimationActive,c=o.animationBegin,f=o.animationDuration,d=o.animationEasing,h=o.animationId,p=o.animateNewValues,m=o.width,b=o.height,g=this.state,v=g.prevPoints,E=g.totalLength;return M.createElement(Li,{begin:c,duration:f,isActive:l,easing:d,from:{t:0},to:{t:1},key:"line-".concat(h),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(S){var x=S.t;if(v){var w=v.length/u.length,T=u.map(function(L,U){var j=Math.floor(U*w);if(v[j]){var B=v[j],z=Or(B.x,L.x),V=Or(B.y,L.y);return Ln(Ln({},L),{},{x:z(x),y:V(x)})}if(p){var F=Or(m*2,L.x),G=Or(b/2,L.y);return Ln(Ln({},L),{},{x:F(x),y:G(x)})}return Ln(Ln({},L),{},{x:L.x,y:L.y})});return a.renderCurveStatically(T,r,i)}var O=Or(0,E),R=O(x),A;if(s){var I="".concat(s).split(/[,\s]+/gim).map(function(L){return parseFloat(L)});A=a.getStrokeDasharray(R,E,I)}else A=a.generateSimpleStrokeDasharray(E,R);return a.renderCurveStatically(u,r,i,{strokeDasharray:A})})}},{key:"renderCurve",value:function(r,i){var a=this.props,o=a.points,u=a.isAnimationActive,s=this.state,l=s.prevPoints,c=s.totalLength;return u&&o&&o.length&&(!l&&c>0||!Gp(l,o))?this.renderCurveWithAnimation(r,i):this.renderCurveStatically(o,r,i)}},{key:"render",value:function(){var r,i=this.props,a=i.hide,o=i.dot,u=i.points,s=i.className,l=i.xAxis,c=i.yAxis,f=i.top,d=i.left,h=i.width,p=i.height,m=i.isAnimationActive,b=i.id;if(a||!u||!u.length)return null;var g=this.state.isAnimationFinished,v=u.length===1,E=We("recharts-line",s),S=l&&l.allowDataOverflow,x=c&&c.allowDataOverflow,w=S||x,T=je(b)?this.id:b,O=(r=Fe(o,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},R=O.r,A=R===void 0?3:R,I=O.strokeWidth,L=I===void 0?2:I,U=sB(o)?o:{},j=U.clipDot,B=j===void 0?!0:j,z=A*2+L;return M.createElement(St,{className:E},S||x?M.createElement("defs",null,M.createElement("clipPath",{id:"clipPath-".concat(T)},M.createElement("rect",{x:S?d:d-h/2,y:x?f:f-p/2,width:S?h:h*2,height:x?p:p*2})),!B&&M.createElement("clipPath",{id:"clipPath-dots-".concat(T)},M.createElement("rect",{x:d-z/2,y:f-z/2,width:h+z,height:p+z}))):null,!v&&this.renderCurve(w,T),this.renderErrorBar(w,T),(v||o)&&this.renderDots(w,B,T),(!m||g)&&pa.renderCallByParent(this.props,u))}}],[{key:"getDerivedStateFromProps",value:function(r,i){return r.animationId!==i.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:i.curPoints}:r.points!==i.curPoints?{curPoints:r.points}:null}},{key:"repeat",value:function(r,i){for(var a=r.length%2!==0?[].concat(Mo(r),[0]):r,o=[],u=0;ue.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function $ue(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function jue(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fue(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0?o:t&&t.length&&de(i)&&de(a)?t.slice(i,a+1):[]};function f3(e){return e==="number"?[0,"auto"]:void 0}var Pv=function(t,n,r,i){var a=t.graphicalItems,o=t.tooltipAxis,u=im(n,t);return r<0||!a||!a.length||r>=u.length?null:a.reduce(function(s,l){var c,f=(c=l.props.data)!==null&&c!==void 0?c:n;f&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(f=f.slice(t.dataStartIndex,t.dataEndIndex+1));var d;if(o.dataKey&&!o.allowDuplicatedCategory){var h=f===void 0?u:f;d=Fd(h,o.dataKey,i)}else d=f&&f[r]||u[r];return d?[].concat(zu(s),[oN(l,d)]):s},[])},yA=function(t,n,r,i){var a=i||{x:t.chartX,y:t.chartY},o=Que(a,r),u=t.orderedTooltipTicks,s=t.tooltipAxis,l=t.tooltipTicks,c=dJ(o,u,l,s);if(c>=0&&l){var f=l[c]&&l[c].value,d=Pv(t,n,c,f),h=Zue(r,u,c,a);return{activeTooltipIndex:c,activeLabel:f,activePayload:d,activeCoordinate:h}}return null},Jue=function(t,n){var r=n.axes,i=n.graphicalItems,a=n.axisType,o=n.axisIdKey,u=n.stackGroups,s=n.dataStartIndex,l=n.dataEndIndex,c=t.layout,f=t.children,d=t.stackOffset,h=rN(c,a);return r.reduce(function(p,m){var b,g=m.type.defaultProps!==void 0?Z(Z({},m.type.defaultProps),m.props):m.props,v=g.type,E=g.dataKey,S=g.allowDataOverflow,x=g.allowDuplicatedCategory,w=g.scale,T=g.ticks,O=g.includeHidden,R=g[o];if(p[R])return p;var A=im(t.data,{graphicalItems:i.filter(function(J){var P,ie=o in J.props?J.props[o]:(P=J.type.defaultProps)===null||P===void 0?void 0:P[o];return ie===R}),dataStartIndex:s,dataEndIndex:l}),I=A.length,L,U,j;_ue(g.domain,S,v)&&(L=Gy(g.domain,null,S),h&&(v==="number"||w!=="auto")&&(j=cl(A,E,"category")));var B=f3(v);if(!L||L.length===0){var z,V=(z=g.domain)!==null&&z!==void 0?z:B;if(E){if(L=cl(A,E,v),v==="category"&&h){var F=ZF(L);x&&F?(U=L,L=Th(0,I)):x||(L=KT(V,L,m).reduce(function(J,P){return J.indexOf(P)>=0?J:[].concat(zu(J),[P])},[]))}else if(v==="category")x?L=L.filter(function(J){return J!==""&&!je(J)}):L=KT(V,L,m).reduce(function(J,P){return J.indexOf(P)>=0||P===""||je(P)?J:[].concat(zu(J),[P])},[]);else if(v==="number"){var G=yJ(A,i.filter(function(J){var P,ie,re=o in J.props?J.props[o]:(P=J.type.defaultProps)===null||P===void 0?void 0:P[o],X="hide"in J.props?J.props.hide:(ie=J.type.defaultProps)===null||ie===void 0?void 0:ie.hide;return re===R&&(O||!X)}),E,a,c);G&&(L=G)}h&&(v==="number"||w!=="auto")&&(j=cl(A,E,"category"))}else h?L=Th(0,I):u&&u[R]&&u[R].hasStack&&v==="number"?L=d==="expand"?[0,1]:aN(u[R].stackGroups,s,l):L=nN(A,i.filter(function(J){var P=o in J.props?J.props[o]:J.type.defaultProps[o],ie="hide"in J.props?J.props.hide:J.type.defaultProps.hide;return P===R&&(O||!ie)}),v,c,!0);if(v==="number")L=Av(f,L,R,a,T),V&&(L=Gy(V,L,S));else if(v==="category"&&V){var k=V,ne=L.every(function(J){return k.indexOf(J)>=0});ne&&(L=k)}}return Z(Z({},p),{},xe({},R,Z(Z({},g),{},{axisType:a,domain:L,categoricalDomain:j,duplicateDomain:U,originalDomain:(b=g.domain)!==null&&b!==void 0?b:B,isCategorical:h,layout:c})))},{})},ese=function(t,n){var r=n.graphicalItems,i=n.Axis,a=n.axisType,o=n.axisIdKey,u=n.stackGroups,s=n.dataStartIndex,l=n.dataEndIndex,c=t.layout,f=t.children,d=im(t.data,{graphicalItems:r,dataStartIndex:s,dataEndIndex:l}),h=d.length,p=rN(c,a),m=-1;return r.reduce(function(b,g){var v=g.type.defaultProps!==void 0?Z(Z({},g.type.defaultProps),g.props):g.props,E=v[o],S=f3("number");if(!b[E]){m++;var x;return p?x=Th(0,h):u&&u[E]&&u[E].hasStack?(x=aN(u[E].stackGroups,s,l),x=Av(f,x,E,a)):(x=Gy(S,nN(d,r.filter(function(w){var T,O,R=o in w.props?w.props[o]:(T=w.type.defaultProps)===null||T===void 0?void 0:T[o],A="hide"in w.props?w.props.hide:(O=w.type.defaultProps)===null||O===void 0?void 0:O.hide;return R===E&&!A}),"number",c),i.defaultProps.allowDataOverflow),x=Av(f,x,E,a)),Z(Z({},b),{},xe({},E,Z(Z({axisType:a},i.defaultProps),{},{hide:!0,orientation:hr(Kue,"".concat(a,".").concat(m%2),null),domain:x,originalDomain:S,isCategorical:p,layout:c})))}return b},{})},tse=function(t,n){var r=n.axisType,i=r===void 0?"xAxis":r,a=n.AxisComp,o=n.graphicalItems,u=n.stackGroups,s=n.dataStartIndex,l=n.dataEndIndex,c=t.children,f="".concat(i,"Id"),d=pr(c,a),h={};return d&&d.length?h=Jue(t,{axes:d,graphicalItems:o,axisType:i,axisIdKey:f,stackGroups:u,dataStartIndex:s,dataEndIndex:l}):o&&o.length&&(h=ese(t,{Axis:a,graphicalItems:o,axisType:i,axisIdKey:f,stackGroups:u,dataStartIndex:s,dataEndIndex:l})),h},nse=function(t){var n=Qi(t),r=xi(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:Nb(r,function(i){return i.coordinate}),tooltipAxis:n,tooltipAxisBandSize:mh(n,r)}},vA=function(t){var n=t.children,r=t.defaultShowTooltip,i=Bn(n,Ru),a=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(o=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!r}},rse=function(t){return!t||!t.length?!1:t.some(function(n){var r=Ti(n&&n.type);return r&&r.indexOf("Bar")>=0})},bA=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},ise=function(t,n){var r=t.props,i=t.graphicalItems,a=t.xAxisMap,o=a===void 0?{}:a,u=t.yAxisMap,s=u===void 0?{}:u,l=r.width,c=r.height,f=r.children,d=r.margin||{},h=Bn(f,Ru),p=Bn(f,Qa),m=Object.keys(s).reduce(function(x,w){var T=s[w],O=T.orientation;return!T.mirror&&!T.hide?Z(Z({},x),{},xe({},O,x[O]+T.width)):x},{left:d.left||0,right:d.right||0}),b=Object.keys(o).reduce(function(x,w){var T=o[w],O=T.orientation;return!T.mirror&&!T.hide?Z(Z({},x),{},xe({},O,hr(x,"".concat(O))+T.height)):x},{top:d.top||0,bottom:d.bottom||0}),g=Z(Z({},b),m),v=g.bottom;h&&(g.bottom+=h.props.height||Ru.defaultProps.height),p&&n&&(g=mJ(g,i,r,n));var E=l-g.left-g.right,S=c-g.top-g.bottom;return Z(Z({brushBottom:v},g),{},{width:Math.max(E,0),height:Math.max(S,0)})},ase=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},ose=function(t){var n=t.chartName,r=t.GraphicalChild,i=t.defaultTooltipEventType,a=i===void 0?"axis":i,o=t.validateTooltipEventTypes,u=o===void 0?["axis"]:o,s=t.axisComponents,l=t.legendContent,c=t.formatAxisMap,f=t.defaultProps,d=function(g,v){var E=v.graphicalItems,S=v.stackGroups,x=v.offset,w=v.updateId,T=v.dataStartIndex,O=v.dataEndIndex,R=g.barSize,A=g.layout,I=g.barGap,L=g.barCategoryGap,U=g.maxBarSize,j=bA(A),B=j.numericAxisName,z=j.cateAxisName,V=rse(E),F=[];return E.forEach(function(G,k){var ne=im(g.data,{graphicalItems:[G],dataStartIndex:T,dataEndIndex:O}),J=G.type.defaultProps!==void 0?Z(Z({},G.type.defaultProps),G.props):G.props,P=J.dataKey,ie=J.maxBarSize,re=J["".concat(B,"Id")],X=J["".concat(z,"Id")],ee={},te=s.reduce(function(ct,bt){var Mt=v["".concat(bt.axisType,"Map")],Rn=J["".concat(bt.axisType,"Id")];Mt&&Mt[Rn]||bt.axisType==="zAxis"||ho();var Zn=Mt[Rn];return Z(Z({},ct),{},xe(xe({},bt.axisType,Zn),"".concat(bt.axisType,"Ticks"),xi(Zn)))},ee),W=te[z],Y=te["".concat(z,"Ticks")],ae=S&&S[re]&&S[re].hasStack&&PJ(G,S[re].stackGroups),q=Ti(G.type).indexOf("Bar")>=0,ve=mh(W,Y),he=[],ye=V&&hJ({barSize:R,stackGroups:S,totalSize:ase(te,z)});if(q){var be,De,ze=je(ie)?U:ie,$e=(be=(De=mh(W,Y,!0))!==null&&De!==void 0?De:ze)!==null&&be!==void 0?be:0;he=pJ({barGap:I,barCategoryGap:L,bandSize:$e!==ve?$e:ve,sizeList:ye[X],maxBarSize:ze}),$e!==ve&&(he=he.map(function(ct){return Z(Z({},ct),{},{position:Z(Z({},ct.position),{},{offset:ct.position.offset-$e/2})})}))}var Ce=G&&G.type&&G.type.getComposedData;Ce&&F.push({props:Z(Z({},Ce(Z(Z({},te),{},{displayedData:ne,props:g,dataKey:P,item:G,bandSize:ve,barPosition:he,offset:x,stackedData:ae,layout:A,dataStartIndex:T,dataEndIndex:O}))),{},xe(xe(xe({key:G.key||"item-".concat(k)},B,te[B]),z,te[z]),"animationId",w)),childIndex:fB(G,g.children),item:G})}),F},h=function(g,v){var E=g.props,S=g.dataStartIndex,x=g.dataEndIndex,w=g.updateId;if(!Hw({props:E}))return null;var T=E.children,O=E.layout,R=E.stackOffset,A=E.data,I=E.reverseStackOrder,L=bA(O),U=L.numericAxisName,j=L.cateAxisName,B=pr(T,r),z=AJ(A,B,"".concat(U,"Id"),"".concat(j,"Id"),R,I),V=s.reduce(function(J,P){var ie="".concat(P.axisType,"Map");return Z(Z({},J),{},xe({},ie,tse(E,Z(Z({},P),{},{graphicalItems:B,stackGroups:P.axisType===U&&z,dataStartIndex:S,dataEndIndex:x}))))},{}),F=ise(Z(Z({},V),{},{props:E,graphicalItems:B}),v==null?void 0:v.legendBBox);Object.keys(V).forEach(function(J){V[J]=c(E,V[J],F,J.replace("Map",""),n)});var G=V["".concat(j,"Map")],k=nse(G),ne=d(E,Z(Z({},V),{},{dataStartIndex:S,dataEndIndex:x,updateId:w,graphicalItems:B,stackGroups:z,offset:F}));return Z(Z({formattedGraphicalItems:ne,graphicalItems:B,offset:F,stackGroups:z},k),V)},p=function(b){function g(v){var E,S,x;return jue(this,g),x=Uue(this,g,[v]),xe(x,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),xe(x,"accessibilityManager",new Tue),xe(x,"handleLegendBBoxUpdate",function(w){if(w){var T=x.state,O=T.dataStartIndex,R=T.dataEndIndex,A=T.updateId;x.setState(Z({legendBBox:w},h({props:x.props,dataStartIndex:O,dataEndIndex:R,updateId:A},Z(Z({},x.state),{},{legendBBox:w}))))}}),xe(x,"handleReceiveSyncEvent",function(w,T,O){if(x.props.syncId===w){if(O===x.eventEmitterSymbol&&typeof x.props.syncMethod!="function")return;x.applySyncEvent(T)}}),xe(x,"handleBrushChange",function(w){var T=w.startIndex,O=w.endIndex;if(T!==x.state.dataStartIndex||O!==x.state.dataEndIndex){var R=x.state.updateId;x.setState(function(){return Z({dataStartIndex:T,dataEndIndex:O},h({props:x.props,dataStartIndex:T,dataEndIndex:O,updateId:R},x.state))}),x.triggerSyncEvent({dataStartIndex:T,dataEndIndex:O})}}),xe(x,"handleMouseEnter",function(w){var T=x.getMouseInfo(w);if(T){var O=Z(Z({},T),{},{isTooltipActive:!0});x.setState(O),x.triggerSyncEvent(O);var R=x.props.onMouseEnter;Ne(R)&&R(O,w)}}),xe(x,"triggeredAfterMouseMove",function(w){var T=x.getMouseInfo(w),O=T?Z(Z({},T),{},{isTooltipActive:!0}):{isTooltipActive:!1};x.setState(O),x.triggerSyncEvent(O);var R=x.props.onMouseMove;Ne(R)&&R(O,w)}),xe(x,"handleItemMouseEnter",function(w){x.setState(function(){return{isTooltipActive:!0,activeItem:w,activePayload:w.tooltipPayload,activeCoordinate:w.tooltipPosition||{x:w.cx,y:w.cy}}})}),xe(x,"handleItemMouseLeave",function(){x.setState(function(){return{isTooltipActive:!1}})}),xe(x,"handleMouseMove",function(w){w.persist(),x.throttleTriggeredAfterMouseMove(w)}),xe(x,"handleMouseLeave",function(w){x.throttleTriggeredAfterMouseMove.cancel();var T={isTooltipActive:!1};x.setState(T),x.triggerSyncEvent(T);var O=x.props.onMouseLeave;Ne(O)&&O(T,w)}),xe(x,"handleOuterEvent",function(w){var T=cB(w),O=hr(x.props,"".concat(T));if(T&&Ne(O)){var R,A;/.*touch.*/i.test(T)?A=x.getMouseInfo(w.changedTouches[0]):A=x.getMouseInfo(w),O((R=A)!==null&&R!==void 0?R:{},w)}}),xe(x,"handleClick",function(w){var T=x.getMouseInfo(w);if(T){var O=Z(Z({},T),{},{isTooltipActive:!0});x.setState(O),x.triggerSyncEvent(O);var R=x.props.onClick;Ne(R)&&R(O,w)}}),xe(x,"handleMouseDown",function(w){var T=x.props.onMouseDown;if(Ne(T)){var O=x.getMouseInfo(w);T(O,w)}}),xe(x,"handleMouseUp",function(w){var T=x.props.onMouseUp;if(Ne(T)){var O=x.getMouseInfo(w);T(O,w)}}),xe(x,"handleTouchMove",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&x.throttleTriggeredAfterMouseMove(w.changedTouches[0])}),xe(x,"handleTouchStart",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&x.handleMouseDown(w.changedTouches[0])}),xe(x,"handleTouchEnd",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&x.handleMouseUp(w.changedTouches[0])}),xe(x,"handleDoubleClick",function(w){var T=x.props.onDoubleClick;if(Ne(T)){var O=x.getMouseInfo(w);T(O,w)}}),xe(x,"handleContextMenu",function(w){var T=x.props.onContextMenu;if(Ne(T)){var O=x.getMouseInfo(w);T(O,w)}}),xe(x,"triggerSyncEvent",function(w){x.props.syncId!==void 0&&Pg.emit(kg,x.props.syncId,w,x.eventEmitterSymbol)}),xe(x,"applySyncEvent",function(w){var T=x.props,O=T.layout,R=T.syncMethod,A=x.state.updateId,I=w.dataStartIndex,L=w.dataEndIndex;if(w.dataStartIndex!==void 0||w.dataEndIndex!==void 0)x.setState(Z({dataStartIndex:I,dataEndIndex:L},h({props:x.props,dataStartIndex:I,dataEndIndex:L,updateId:A},x.state)));else if(w.activeTooltipIndex!==void 0){var U=w.chartX,j=w.chartY,B=w.activeTooltipIndex,z=x.state,V=z.offset,F=z.tooltipTicks;if(!V)return;if(typeof R=="function")B=R(F,w);else if(R==="value"){B=-1;for(var G=0;G=0){var ae,q;if(U.dataKey&&!U.allowDuplicatedCategory){var ve=typeof U.dataKey=="function"?Y:"payload.".concat(U.dataKey.toString());ae=Fd(G,ve,B),q=k&&ne&&Fd(ne,ve,B)}else ae=G==null?void 0:G[j],q=k&&ne&&ne[j];if(X||re){var he=w.props.activeIndex!==void 0?w.props.activeIndex:j;return[C.cloneElement(w,Z(Z(Z({},R.props),te),{},{activeIndex:he})),null,null]}if(!je(ae))return[W].concat(zu(x.renderActivePoints({item:R,activePoint:ae,basePoint:q,childIndex:j,isRange:k})))}else{var ye,be=(ye=x.getItemByXY(x.state.activeCoordinate))!==null&&ye!==void 0?ye:{graphicalItem:W},De=be.graphicalItem,ze=De.item,$e=ze===void 0?w:ze,Ce=De.childIndex,ct=Z(Z(Z({},R.props),te),{},{activeIndex:Ce});return[C.cloneElement($e,ct),null,null]}return k?[W,null,null]:[W,null]}),xe(x,"renderCustomized",function(w,T,O){return C.cloneElement(w,Z(Z({key:"recharts-customized-".concat(O)},x.props),x.state))}),xe(x,"renderMap",{CartesianGrid:{handler:Bf,once:!0},ReferenceArea:{handler:x.renderReferenceElement},ReferenceLine:{handler:Bf},ReferenceDot:{handler:x.renderReferenceElement},XAxis:{handler:Bf},YAxis:{handler:Bf},Brush:{handler:x.renderBrush,once:!0},Bar:{handler:x.renderGraphicChild},Line:{handler:x.renderGraphicChild},Area:{handler:x.renderGraphicChild},Radar:{handler:x.renderGraphicChild},RadialBar:{handler:x.renderGraphicChild},Scatter:{handler:x.renderGraphicChild},Pie:{handler:x.renderGraphicChild},Funnel:{handler:x.renderGraphicChild},Tooltip:{handler:x.renderCursor,once:!0},PolarGrid:{handler:x.renderPolarGrid,once:!0},PolarAngleAxis:{handler:x.renderPolarAxis},PolarRadiusAxis:{handler:x.renderPolarAxis},Customized:{handler:x.renderCustomized}}),x.clipPathId="".concat((E=v.id)!==null&&E!==void 0?E:Fc("recharts"),"-clip"),x.throttleTriggeredAfterMouseMove=Jk(x.triggeredAfterMouseMove,(S=v.throttleDelay)!==null&&S!==void 0?S:1e3/60),x.state={},x}return Vue(g,b),Bue(g,[{key:"componentDidMount",value:function(){var E,S;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(E=this.props.margin.left)!==null&&E!==void 0?E:0,top:(S=this.props.margin.top)!==null&&S!==void 0?S:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var E=this.props,S=E.children,x=E.data,w=E.height,T=E.layout,O=Bn(S,Yr);if(O){var R=O.props.defaultIndex;if(!(typeof R!="number"||R<0||R>this.state.tooltipTicks.length-1)){var A=this.state.tooltipTicks[R]&&this.state.tooltipTicks[R].value,I=Pv(this.state,x,R,A),L=this.state.tooltipTicks[R].coordinate,U=(this.state.offset.top+w)/2,j=T==="horizontal",B=j?{x:L,y:U}:{y:L,x:U},z=this.state.formattedGraphicalItems.find(function(F){var G=F.item;return G.type.name==="Scatter"});z&&(B=Z(Z({},B),z.props.points[R].tooltipPosition),I=z.props.points[R].tooltipPayload);var V={activeTooltipIndex:R,isTooltipActive:!0,activeLabel:A,activePayload:I,activeCoordinate:B};this.setState(V),this.renderCursor(O),this.accessibilityManager.setIndex(R)}}}},{key:"getSnapshotBeforeUpdate",value:function(E,S){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==S.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==E.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==E.margin){var x,w;this.accessibilityManager.setDetails({offset:{left:(x=this.props.margin.left)!==null&&x!==void 0?x:0,top:(w=this.props.margin.top)!==null&&w!==void 0?w:0}})}return null}},{key:"componentDidUpdate",value:function(E){uy([Bn(E.children,Yr)],[Bn(this.props.children,Yr)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var E=Bn(this.props.children,Yr);if(E&&typeof E.props.shared=="boolean"){var S=E.props.shared?"axis":"item";return u.indexOf(S)>=0?S:a}return a}},{key:"getMouseInfo",value:function(E){if(!this.container)return null;var S=this.container,x=S.getBoundingClientRect(),w=jY(x),T={chartX:Math.round(E.pageX-w.left),chartY:Math.round(E.pageY-w.top)},O=x.width/S.offsetWidth||1,R=this.inRange(T.chartX,T.chartY,O);if(!R)return null;var A=this.state,I=A.xAxisMap,L=A.yAxisMap,U=this.getTooltipEventType(),j=yA(this.state,this.props.data,this.props.layout,R);if(U!=="axis"&&I&&L){var B=Qi(I).scale,z=Qi(L).scale,V=B&&B.invert?B.invert(T.chartX):null,F=z&&z.invert?z.invert(T.chartY):null;return Z(Z({},T),{},{xValue:V,yValue:F},j)}return j?Z(Z({},T),j):null}},{key:"inRange",value:function(E,S){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,w=this.props.layout,T=E/x,O=S/x;if(w==="horizontal"||w==="vertical"){var R=this.state.offset,A=T>=R.left&&T<=R.left+R.width&&O>=R.top&&O<=R.top+R.height;return A?{x:T,y:O}:null}var I=this.state,L=I.angleAxisMap,U=I.radiusAxisMap;if(L&&U){var j=Qi(L);return ZT({x:T,y:O},j)}return null}},{key:"parseEventsOfWrapper",value:function(){var E=this.props.children,S=this.getTooltipEventType(),x=Bn(E,Yr),w={};x&&S==="axis"&&(x.props.trigger==="click"?w={onClick:this.handleClick}:w={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var T=Bd(this.props,this.handleOuterEvent);return Z(Z({},T),w)}},{key:"addListener",value:function(){Pg.on(kg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Pg.removeListener(kg,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(E,S,x){for(var w=this.state.formattedGraphicalItems,T=0,O=w.length;T_.jsx("div",{className:`flex items-center justify-center min-h-[${e}]`,children:_.jsx("span",{className:"loading loading-spinner loading-lg text-primary"})}),sse=({metrics:e,selectedMetric:t,onMetricChange:n})=>_.jsxs("fieldset",{className:"fieldset",children:[_.jsx("legend",{className:"fieldset-legend",children:"Metric"}),_.jsx("select",{id:"metric-selector",value:t||"",onChange:n,className:"select select-bordered w-full",children:[...e].map(r=>_.jsx("option",{value:r,children:r},r))})]}),lse=({attacks:e,selectedAttack:t,onAttackChange:n})=>_.jsxs("fieldset",{className:"fieldset mb-4",children:[_.jsx("legend",{className:"fieldset-legend",children:"Attack"}),_.jsx("select",{id:"attack-selector",value:t||"",onChange:n,className:"select select-bordered w-full",children:[...e].map(r=>_.jsx("option",{value:r,children:r},r))})]}),cse=e=>{const t=sp(),{active:n,payload:r,label:i,dataset:a,selectedAttack:o,datasetType:u}=e;if(n&&r&&r.length){let s="/image-examples";return u==="audio"&&(s="/audio-examples"),u==="video"&&(s="/video-examples"),_.jsxs("div",{style:{backgroundColor:"#2a303c",borderColor:"#374151",color:"white",padding:8},title:"Go to examples for this model and attack",children:[_.jsxs("div",{children:[_.jsx("b",{children:"Attack:"})," ",o]}),_.jsxs("div",{children:[_.jsx("b",{children:"Strength:"})," ",i]}),r.map((l,c)=>{const f=l.name,d=()=>{t(`${s}?model=${encodeURIComponent(f)}&attack=${encodeURIComponent(o||"")}&strength=${i}`)};return _.jsxs("div",{style:{color:l.color},children:[_.jsx("span",{style:{cursor:"pointer",textDecoration:"underline",marginTop:4},onClick:d,title:`Go to examples for ${f}`,children:_.jsx("b",{children:f})}),": ",Number(l.value).toFixed(3)]},c)})]})}return null},fse=({dataset:e,selectedModels:t,datasetType:n})=>{const[r,i]=C.useState([]),[a,o]=C.useState(!0),[u,s]=C.useState(null),[l,c]=C.useState(new Set),[f,d]=C.useState(new Set),[h,p]=C.useState(null),[m,b]=C.useState(null);C.useEffect(()=>{o(!0),Wn.fetchStaticFile(`data/${e}?dataset_type=attacks_variations`).then(S=>{const x=JSON.parse(S),w=x.all_attacks_df.map(T=>{const O={...T};return typeof O.strength=="string"&&(O.strength=parseFloat(O.strength)),O});p(x.metrics[0]),c(new Set(x.metrics)),b(x.attacks_with_variations[0]),d(new Set(x.attacks_with_variations)),i(w),o(!1)}).catch(S=>{s("Failed to fetch JSON: "+S.message),o(!1)})},[e]);const g=S=>{p(S.target.value)},v=S=>{b(S.target.value)},E=r.filter(S=>!m||S.attack===m).sort((S,x)=>S.strength-x.strength);return _.jsxs("div",{className:"rounded shadow p-4 overflow-auto mb-8",children:[a&&_.jsx(Yc,{}),u&&_.jsx("div",{className:"text-red-500",children:u}),!a&&!u&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"flex flex-col md:flex-row md:gap-x-4 mb-4",children:[_.jsx("div",{className:"w-full md:w-1/2",children:_.jsx(sse,{metrics:l,selectedMetric:h,onMetricChange:g})}),_.jsx("div",{className:"w-full md:w-1/2",children:_.jsx(lse,{attacks:f,selectedAttack:m,onAttackChange:v})})]}),r.length>0&&_.jsx("div",{className:"h-64 mb-4",children:_.jsx(IY,{width:"100%",height:"100%",children:_.jsxs(use,{data:E,margin:{top:5,right:30,left:20,bottom:5},children:[_.jsx(KN,{strokeDasharray:"3 3"}),_.jsx(nm,{dataKey:"strength",domain:[Math.min(...E.map(S=>Number(S.strength))),Math.max(...E.map(S=>Number(S.strength)))],type:"number",tickFormatter:S=>S.toFixed(3),label:{value:"Strength",position:"insideBottomRight",offset:-5}}),_.jsx(rm,{label:{value:h||"",angle:-90,position:"insideLeft",style:{textAnchor:"middle"}},tickFormatter:S=>S.toFixed(3)}),_.jsx(Yr,{wrapperStyle:{pointerEvents:"auto"},content:_.jsx(cse,{dataset:e,selectedAttack:m,datasetType:n})}),_.jsx(Qa,{}),(()=>{if(!h)return null;const S=new Set(E.filter(w=>t.has(w.model)).map(w=>w.model)),x=["#8884d8","#82ca9d","#ffc658","#ff8042","#0088fe","#00C49F"];return[...S].map((w,T)=>_.jsx(qc,{type:"monotone",dataKey:h,data:E.filter(O=>O.model===w),name:w,stroke:x[T%x.length],dot:!1},w))})()]})})})]})]})},dse=({className:e="h-4 w-4"})=>_.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:e,children:_.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})}),d3=({modelName:e})=>{const[t,n]=C.useState(!1),r=C.useRef(so.getInstance());C.useEffect(()=>{r.current.load().then(()=>n(!0))},[]);const i=r.current.getModelFullName(e)||e,a=r.current.getModelDescription(e),o=r.current.getModelPaperUrl(e),u=r.current.getModelGithubUrl(e);return _.jsxs(_.Fragment,{children:[_.jsx("span",{className:"ml-1 cursor-pointer","data-tooltip-id":`tooltip-${e}`,tabIndex:0,"aria-label":`Show info for ${e}`,role:"button",children:_.jsx(mP,{className:"h-4 w-4 text-blue-400 hover:text-blue-600"})}),_.jsx(hp,{id:`tooltip-${e}`,place:"top",className:"z-[10000] max-w-xs !opacity-100 bg-base-100 text-base-content",style:{boxShadow:"0 0 10px rgba(0,0,0,0.2)",zIndex:1e4},openOnClick:!1,clickable:!0,delayHide:200,positionStrategy:"fixed",children:_.jsxs("div",{className:"p-2 text-xs text-left relative z-[10000]",children:[_.jsx("div",{className:"font-semibold mb-1",children:i}),_.jsx("div",{className:"mb-2 whitespace-pre-line",children:a||"No description available."}),_.jsxs("div",{className:"flex space-x-4",children:[o&&_.jsx("div",{children:_.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline flex items-center",children:[_.jsx(pP,{className:"h-3 w-3 mr-1"}),"Paper"]})}),u&&_.jsx("div",{children:_.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline flex items-center",children:[_.jsx(dse,{className:"h-3 w-3 mr-1"}),"GitHub"]})})]})]})})]})},hse=({models:e,selectedModels:t,setSelectedModels:n})=>{const[r,i]=C.useState(!1),a=C.useRef(so.getInstance());C.useEffect(()=>{a.current.load().then(()=>i(!0))},[]);const o=u=>{const s=new Set(t);s.has(u)?s.delete(u):s.add(u),n(s)};return _.jsx("div",{className:"w-full",children:_.jsxs("fieldset",{className:"fieldset w-full p-4 rounded border border-gray-700 bg-base-200",children:[_.jsxs("legend",{className:"fieldset-legend font-semibold",children:["Models (",t.size,"/",e.length,")"]}),_.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-1 max-h-48 pr-2",children:e.map(u=>{const s=a.current.getModelFullName(u)||u;return a.current.getModelDescription(u),a.current.getModelPaperUrl(u),a.current.getModelGithubUrl(u),_.jsx("div",{className:"flex items-center gap-2 text-sm relative group",children:_.jsxs("label",{className:"flex items-center gap-2 flex-grow",children:[_.jsx("input",{type:"checkbox",className:"form-checkbox h-4 w-4",checked:t.has(u),onChange:()=>o(u)}),_.jsxs("div",{className:"flex items-center",children:[_.jsx("span",{className:"truncate",title:s,children:u}),_.jsx(d3,{modelName:u})]})]})},u)})})]})})},Ng=({datasetType:e})=>{const[t,n]=C.useState([]),[r,i]=C.useState(""),[a,o]=C.useState([]),[u,s]=C.useState(new Set),[l,c]=C.useState(!0),[f,d]=C.useState(null);return C.useEffect(()=>{c(!0),Wn.fetchDatasets().then(h=>{const p=h[e]||[];n(p),i(p[0]||""),c(!1)}).catch(h=>{console.error("Failed to fetch dataset names:",h),n([]),i(""),c(!1)})},[e]),C.useEffect(()=>{r&&(c(!0),Wn.fetchStaticFile(`data/${r}?dataset_type=benchmark`).then(h=>{const p=JSON.parse(h),m=p.rows,g=Array.from(new Set(m.flatMap(v=>Object.keys(v)))).filter(v=>v!=="metric");o(g),s(new Set(g)),d(p),c(!1)}).catch(h=>{console.error("Failed to fetch models:",h),c(!1)}))},[r]),_.jsx("div",{className:"",children:l?_.jsx(Yc,{}):_.jsxs(_.Fragment,{children:[_.jsx("div",{className:"flex flex-col gap-4",children:_.jsx(O4,{datasetNames:t,selectedDatasetName:r,onDatasetNameChange:i})}),a.length>0&&_.jsx(hse,{models:a,selectedModels:u,setSelectedModels:s}),_.jsxs("div",{className:"space-y-8",children:[_.jsx(E5,{benchmarkData:f,selectedModels:u}),_.jsx("div",{className:"mt-8 pt-4 border-t border-gray-200",children:_.jsx(fse,{datasetType:e,dataset:r,selectedModels:u})})]})]})})},kv={attacked_wmd:"attacked_wmd_",attacked:"attacked_",wmd:"wmd_"},hl={attacked_wmd:"Attacked + Watermarked",attacked:"Attacked",wmd:"Watermarked",original:"Original"};function pse(e){var t;return((t=Object.entries(kv).find(([,n])=>e.startsWith(n)))==null?void 0:t[0])||"original"}function mse(e,t){return t in kv?e.replace(kv[t],""):e}function gE(e){const t={};return e.forEach(n=>{const r=pse(n.name),i=mse(n.name,r);t[i]||(t[i]={}),t[i][r]=n}),t}const gse=["bit_acc","word_acc","log10_p_value"],yE=({variantMetadatas:e})=>{const t=Object.keys(e);if(t.length===0)return null;let n=Array.from(new Set(t.flatMap(o=>Object.keys(e[o]||{}))));const r=[...gse.filter(o=>n.includes(o))];n.includes("detected")&&r.unshift("detected");const i=n.filter(o=>!r.includes(o)&&o!=="detected"),a=(o,u,s)=>o.length===0?null:_.jsxs("div",{className:"overflow-x-auto mb-4",children:[_.jsx("div",{className:"mb-1 text-sm",children:u}),_.jsxs("table",{className:"table w-full min-w-max border-gray-700 border text-xs",children:[_.jsx("thead",{children:_.jsxs("tr",{children:[_.jsx("th",{className:"bg-base-100 border-gray-700 border",children:"Variant"}),o.map(l=>_.jsx("th",{className:"bg-base-100 border-gray-700 border text-center",children:_.jsxs("span",{className:"inline-flex items-center gap-1",children:[l,l!=="detected"&&_.jsx(pp,{metricName:l})]})},l))]})}),_.jsx("tbody",{children:s.map(l=>t.includes(l)?_.jsxs("tr",{className:"hover:bg-base-100",children:[_.jsx("td",{className:"font-mono border-gray-700 border",children:hl[l]||l}),o.map(c=>_.jsx("td",{className:"border-gray-700 border text-center",children:e[l]&&c in e[l]?String(e[l][c]):""},c))]},l):null)})]})]});return _.jsxs(_.Fragment,{children:[a(r,"Accuracy Metrics",["wmd","attacked_wmd"]),a(i,"Quality Metrics",["wmd"])]})},vE=({children:e})=>_.jsxs("fieldset",{className:"fieldset w-full p-4 pt-0 rounded border border-gray-700 bg-base-200 mt-6",children:[_.jsx("legend",{className:"fieldset-legend font-semibold",children:"Example"}),e]}),h3=({variantKeys:e,selectedVariant:t,setSelectedVariant:n})=>(M.useEffect(()=>{const r=i=>{if(document.activeElement&&document.activeElement.tagName==="INPUT")return;const a=parseInt(i.key,10);!isNaN(a)&&a>0&&a<=e.length&&n(e[a-1])};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,n]),_.jsxs("fieldset",{className:"fieldset w-full p-4 rounded border border-gray-700 bg-base-200 ",children:[_.jsx("legend",{className:"fieldset-legend font-semibold",children:"Variants"}),_.jsx("div",{className:"mb-2 flex gap-4 flex-wrap",children:e.map((r,i)=>_.jsxs("label",{className:"flex items-center gap-1 cursor-pointer","data-tooltip-id":"variant-selector-tooltip",children:[_.jsx("input",{type:"radio",name:"variant-selector",value:r,checked:t===r,onChange:()=>n(r)}),_.jsxs("span",{className:"text-xs font-semibold",children:[hl[r]||r," ",_.jsxs("span",{className:"opacity-60",children:["[",i+1,"]"]})]})]},r))})]}));function jh(e,t,n,r){e==="wmd"?t==="original"&&r.includes("wmd")?n("wmd"):n("original"):e==="attacked"&&t==="original"&&r.includes("attacked")?n("attacked"):n("original")}const p3=({toggleMode:e,setToggleMode:t,selectedVariant:n,setSelectedVariant:r,variantKeys:i})=>_.jsxs("div",{className:"my-2 flex gap-6",children:[_.jsx("button",{className:`btn ${e==="wmd"?"btn-primary":"btn-outline"}`,type:"button",onClick:()=>{t("wmd"),jh(e,n,r,i)},children:"Original ⇄ Watermarked"}),_.jsx("button",{className:`btn ${e==="attacked"?"btn-primary":"btn-outline"}`,type:"button",onClick:()=>{t("attacked"),jh(e,n,r,i)},children:"Original ⇄ Attacked"})]}),yse=({selectedModel:e,selectedAttack:t,examples:n})=>{const r=n[e][t],i=gE(r),a=Object.keys(i),[o,u]=M.useState(a[0]||""),s=i[o]||{},l=Object.keys(s),[c,f]=M.useState(l[0]||""),[d,h]=M.useState("wmd"),[p,m]=M.useState(null),b=M.useRef(null),g=300,[v,E]=M.useState(2),S=l.map(A=>{var I;return Wn.getProxiedUrl((I=s[A])==null?void 0:I.image_url)}).filter(Boolean),[x,w]=M.useState({width:0,height:0}),[T,O]=M.useState(!1);M.useEffect(()=>{let A=!0;return S.length>0&&Promise.all(S.map(I=>new Promise(L=>{const U=new window.Image;U.onload=()=>L({width:U.naturalWidth,height:U.naturalHeight}),U.src=I}))).then(I=>{if(!A)return;const L=I[0],U=I.every(j=>j.width===L.width&&j.height===L.height);O(!U),w(L)}),()=>{A=!1}},[S.join(","),o]);const R=_.jsxs("div",{className:"flex flex-col items-center mb-4 w-full",children:[_.jsxs("label",{className:"font-semibold text-xs mb-1",children:["Zoom Level: ",v,"x"]}),_.jsx("input",{type:"range",min:1,max:6,step:.1,value:v,onChange:A=>E(Number(A.target.value)),className:"range range-xs w-48"})]});return S.length?_.jsx("div",{className:"w-full overflow-auto",style:{minHeight:"100vh"},children:_.jsxs("div",{className:"example-display",children:[_.jsx("div",{className:"mb-4",children:_.jsxs("fieldset",{className:"fieldset",children:[_.jsx("legend",{className:"fieldset-legend",children:"Image"}),_.jsx("select",{className:"select select-bordered",value:o||"",onChange:A=>{u(A.target.value||"");const I=i[A.target.value]||{},L=Object.keys(I);f(L[0]||"")},children:a.map(A=>_.jsx("option",{value:A,children:A},A))})]})}),o&&c&&s[c]&&_.jsxs(_.Fragment,{children:[_.jsx(yE,{variantMetadatas:Object.fromEntries(l.map(A=>{var I;return[A,((I=s[A])==null?void 0:I.metadata)||{}]}))}),_.jsxs(vE,{children:[_.jsx(h3,{variantKeys:l,selectedVariant:c,setSelectedVariant:f}),_.jsx(hp,{id:"variant-selector-tooltip",place:"top",className:"z-[10000] max-w-xs !opacity-100 bg-base-100 text-base-content",style:{boxShadow:"0 0 10px rgba(0,0,0,0.2)",zIndex:1e4},positionStrategy:"fixed",children:_.jsxs("div",{className:"p-2 text-xs text-left relative z-[10000]",children:["You can also change the variant using keys ",_.jsx("b",{children:"1"}),", ",_.jsx("b",{children:"2"}),", ",_.jsx("b",{children:"3"}),", ",_.jsx("b",{children:"4"})," ","on your keyboard."]})}),_.jsx(p3,{toggleMode:d,setToggleMode:h,selectedVariant:c,setSelectedVariant:f,variantKeys:l}),R,_.jsx("div",{style:{width:"100%",display:"flex",flexDirection:"row",justifyContent:"center"},children:_.jsxs("div",{style:{position:"relative",flex:"none",display:"inline-block"},children:[T?_.jsx("div",{className:"text-red-500 font-bold text-center",children:"Image sizes do not match across variants"}):null,_.jsx("img",{ref:b,src:Wn.getProxiedUrl(s[c].image_url),alt:o,width:x.width,height:x.height,style:{display:"block",cursor:"zoom-in"},onMouseMove:A=>{const I=A.target.getBoundingClientRect(),L=A.clientX-I.left,U=A.clientY-I.top;m({x:L,y:U})},onMouseLeave:()=>m(null),onClick:()=>jh(d,c,f,l)}),p&&(()=>{var V;const{width:A,height:I}=x,L=g/(2*v);let U=p.x,j=p.y;U=Math.max(L,Math.min(A-L,U)),j=Math.max(L,Math.min(I-L,j));const B=U*v-g/2,z=j*v-g/2;return _.jsx("div",{style:{position:"absolute",left:p.x-g/2,top:p.y-g/2,width:g,height:g,boxSizing:"border-box",backgroundImage:`url(${Wn.getProxiedUrl((V=s[c])==null?void 0:V.image_url)})`,backgroundPosition:`-${B}px -${z}px`,backgroundSize:`${A*v}px ${I*v}px`,backgroundRepeat:"no-repeat",zIndex:10,pointerEvents:"none",cursor:"zoom-in"}})})()]})})]})]})]})}):_.jsx("div",{className:"w-full mt-12 flex items-center justify-center",children:_.jsx("div",{className:"text-gray-500",children:"No images available. Please select another model and attack."})})};function Kt(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(l){try{s(r.next(l))}catch(c){a(c)}}function u(l){try{s(r.throw(l))}catch(c){a(c)}}function s(l){var c;l.done?i(l.value):(c=l.value,c instanceof n?c:new n(function(f){f(c)})).then(o,u)}s((r=r.apply(e,t||[])).next())})}let Kc=class{constructor(){this.listeners={}}on(t,n,r){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(n),r==null?void 0:r.once){const i=()=>{this.un(t,i),this.un(t,n)};return this.on(t,i),i}return()=>this.un(t,n)}un(t,n){var r;(r=this.listeners[t])===null||r===void 0||r.delete(n)}once(t,n){return this.on(t,n,{once:!0})}unAll(){this.listeners={}}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}};const Uf={decode:function(e,t){return Kt(this,void 0,void 0,function*(){const n=new AudioContext({sampleRate:t});return n.decodeAudioData(e).finally(()=>n.close())})},createBuffer:function(e,t){return typeof e[0]=="number"&&(e=[e]),function(n){const r=n[0];if(r.some(i=>i>1||i<-1)){const i=r.length;let a=0;for(let o=0;oa&&(a=u)}for(const o of n)for(let u=0;ue==null?void 0:e[n],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function m3(e,t){const n=t.xmlns?document.createElementNS(t.xmlns,e):document.createElement(e);for(const[r,i]of Object.entries(t))if(r==="children")for(const[a,o]of Object.entries(t))typeof o=="string"?n.appendChild(document.createTextNode(o)):n.appendChild(m3(a,o));else r==="style"?Object.assign(n.style,i):r==="textContent"?n.textContent=i:n.setAttribute(r,i.toString());return n}function EA(e,t,n){const r=m3(e,t||{});return n==null||n.appendChild(r),r}var vse=Object.freeze({__proto__:null,createElement:EA,default:EA});const bse={fetchBlob:function(e,t,n){return Kt(this,void 0,void 0,function*(){const r=yield fetch(e,n);if(r.status>=400)throw new Error(`Failed to fetch ${e}: ${r.status} (${r.statusText})`);return function(i,a){Kt(this,void 0,void 0,function*(){if(!i.body||!i.headers)return;const o=i.body.getReader(),u=Number(i.headers.get("Content-Length"))||0;let s=0;const l=f=>Kt(this,void 0,void 0,function*(){s+=(f==null?void 0:f.length)||0;const d=Math.round(s/u*100);a(d)}),c=()=>Kt(this,void 0,void 0,function*(){let f;try{f=yield o.read()}catch{return}f.done||(l(f.value),yield c())});c()})}(r.clone(),t),r.blob()})}};class Ese extends Kc{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,n,r){return this.media.addEventListener(t,n,r),()=>this.media.removeEventListener(t,n,r)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,n){const r=this.getSrc();if(t&&r===t)return;this.revokeSrc();const i=n instanceof Blob&&(this.canPlayType(n.type)||!t)?URL.createObjectURL(n):t;r&&(this.media.src="");try{this.media.src=i}catch{this.media.src=t}}destroy(){this.isExternalMedia||(this.media.pause(),this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(t){this.media=t}play(){return Kt(this,void 0,void 0,function*(){return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,n){n!=null&&(this.media.preservesPitch=n),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}let Iv=class Nv extends Kc{constructor(t,n){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.subscriptions=[],this.options=t;const r=this.parentFromOptionsContainer(t.container);this.parent=r;const[i,a]=this.initHtml();r.appendChild(i),this.container=i,this.scrollContainer=a.querySelector(".scroll"),this.wrapper=a.querySelector(".wrapper"),this.canvasWrapper=a.querySelector(".canvases"),this.progressWrapper=a.querySelector(".progress"),this.cursor=a.querySelector(".cursor"),n&&a.appendChild(n),this.initEvents()}parentFromOptionsContainer(t){let n;if(typeof t=="string"?n=document.querySelector(t):t instanceof HTMLElement&&(n=t),!n)throw new Error("Container not found");return n}initEvents(){const t=n=>{const r=this.wrapper.getBoundingClientRect(),i=n.clientX-r.left,a=n.clientY-r.top;return[i/r.width,a/r.height]};if(this.wrapper.addEventListener("click",n=>{const[r,i]=t(n);this.emit("click",r,i)}),this.wrapper.addEventListener("dblclick",n=>{const[r,i]=t(n);this.emit("dblclick",r,i)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:n,scrollWidth:r,clientWidth:i}=this.scrollContainer,a=n/r,o=(n+i)/r;this.emit("scroll",a,o,n,n+i)}),typeof ResizeObserver=="function"){const n=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{n().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender())}initDrag(){this.subscriptions.push(function(t,n,r,i,a=3,o=0,u=100){if(!t)return()=>{};const s=matchMedia("(pointer: coarse)").matches;let l=()=>{};const c=f=>{if(f.button!==o)return;f.preventDefault(),f.stopPropagation();let d=f.clientX,h=f.clientY,p=!1;const m=Date.now(),b=x=>{if(x.preventDefault(),x.stopPropagation(),s&&Date.now()-ma||Math.abs(R)>a){const A=t.getBoundingClientRect(),{left:I,top:L}=A;p||(r==null||r(d-I,h-L),p=!0),n(O,R,w-I,T-L),d=w,h=T}},g=x=>{if(p){const w=x.clientX,T=x.clientY,O=t.getBoundingClientRect(),{left:R,top:A}=O;i==null||i(w-R,T-A)}l()},v=x=>{x.relatedTarget&&x.relatedTarget!==document.documentElement||g(x)},E=x=>{p&&(x.stopPropagation(),x.preventDefault())},S=x=>{p&&x.preventDefault()};document.addEventListener("pointermove",b),document.addEventListener("pointerup",g),document.addEventListener("pointerout",v),document.addEventListener("pointercancel",v),document.addEventListener("touchmove",S,{passive:!1}),document.addEventListener("click",E,{capture:!0}),l=()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",g),document.removeEventListener("pointerout",v),document.removeEventListener("pointercancel",v),document.removeEventListener("touchmove",S),setTimeout(()=>{document.removeEventListener("click",E,{capture:!0})},10)}};return t.addEventListener("pointerdown",c),()=>{l(),t.removeEventListener("pointerdown",c)}}(this.wrapper,(t,n,r)=>{this.emit("drag",Math.max(0,Math.min(1,r/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!0,this.emit("dragstart",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!1,this.emit("dragend",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))}))}getHeight(t,n){var r;const i=((r=this.audioData)===null||r===void 0?void 0:r.numberOfChannels)||1;if(t==null)return 128;if(!isNaN(Number(t)))return Number(t);if(t==="auto"){const a=this.parent.clientHeight||128;return n!=null&&n.every(o=>!o.overlay)?a/i:a}return 128}initHtml(){const t=document.createElement("div"),n=t.attachShadow({mode:"open"}),r=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return n.innerHTML=`
+
+
+
+ `,[t,n]}setOptions(t){if(this.options.container!==t.container){const n=this.parentFromOptionsContainer(t.container);n.appendChild(this.container),this.parent=n}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:n}=this.scrollContainer,r=n*t;this.setScroll(r)}destroy(){var t,n;this.subscriptions.forEach(r=>r()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.unsubscribeOnScroll)===null||n===void 0||n.forEach(r=>r()),this.unsubscribeOnScroll=[]}createDelay(t=10){let n,r;const i=()=>{n&&clearTimeout(n),r&&r()};return this.timeouts.push(i),()=>new Promise((a,o)=>{i(),r=o,n=setTimeout(()=>{n=void 0,r=void 0,a()},t)})}convertColorValues(t){if(!Array.isArray(t))return t||"";if(t.length<2)return t[0]||"";const n=document.createElement("canvas"),r=n.getContext("2d"),i=n.height*(window.devicePixelRatio||1),a=r.createLinearGradient(0,0,0,i),o=1/(t.length-1);return t.forEach((u,s)=>{const l=s*o;a.addColorStop(l,u)}),a}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,n,r,i){const a=t[0],o=t[1]||t[0],u=a.length,{width:s,height:l}=r.canvas,c=l/2,f=this.getPixelRatio(),d=n.barWidth?n.barWidth*f:1,h=n.barGap?n.barGap*f:n.barWidth?d/2:0,p=n.barRadius||0,m=s/(d+h)/u,b=p&&"roundRect"in r?"roundRect":"rect";r.beginPath();let g=0,v=0,E=0;for(let S=0;S<=u;S++){const x=Math.round(S*m);if(x>g){const O=Math.round(v*c*i),R=O+Math.round(E*c*i)||1;let A=c-O;n.barAlign==="top"?A=0:n.barAlign==="bottom"&&(A=l-R),r[b](g*(d+h),A,d,R,p),g=x,v=0,E=0}const w=Math.abs(a[S]||0),T=Math.abs(o[S]||0);w>v&&(v=w),T>E&&(E=T)}r.fill(),r.closePath()}renderLineWaveform(t,n,r,i){const a=o=>{const u=t[o]||t[0],s=u.length,{height:l}=r.canvas,c=l/2,f=r.canvas.width/s;r.moveTo(0,c);let d=0,h=0;for(let p=0;p<=s;p++){const m=Math.round(p*f);if(m>d){const g=c+(Math.round(h*c*i)||1)*(o===0?-1:1);r.lineTo(d,g),d=m,h=0}const b=Math.abs(u[p]||0);b>h&&(h=b)}r.lineTo(d,c)};r.beginPath(),a(0),a(1),r.fill(),r.closePath()}renderWaveform(t,n,r){if(r.fillStyle=this.convertColorValues(n.waveColor),n.renderFunction)return void n.renderFunction(t,r);let i=n.barHeight||1;if(n.normalize){const a=Array.from(t[0]).reduce((o,u)=>Math.max(o,Math.abs(u)),0);i=a?1/a:1}n.barWidth||n.barGap||n.barAlign?this.renderBarWaveform(t,n,r,i):this.renderLineWaveform(t,n,r,i)}renderSingleCanvas(t,n,r,i,a,o,u){const s=this.getPixelRatio(),l=document.createElement("canvas");l.width=Math.round(r*s),l.height=Math.round(i*s),l.style.width=`${r}px`,l.style.height=`${i}px`,l.style.left=`${Math.round(a)}px`,o.appendChild(l);const c=l.getContext("2d");if(this.renderWaveform(t,n,c),l.width>0&&l.height>0){const f=l.cloneNode(),d=f.getContext("2d");d.drawImage(l,0,0),d.globalCompositeOperation="source-in",d.fillStyle=this.convertColorValues(n.progressColor),d.fillRect(0,0,l.width,l.height),u.appendChild(f)}}renderMultiCanvas(t,n,r,i,a,o){const u=this.getPixelRatio(),{clientWidth:s}=this.scrollContainer,l=r/u;let c=Math.min(Nv.MAX_CANVAS_WIDTH,s,l),f={};if(c===0)return;if(n.barWidth||n.barGap){const b=n.barWidth||.5,g=b+(n.barGap||b/2);c%g!=0&&(c=Math.floor(c/g)*g)}const d=b=>{if(b<0||b>=h||f[b])return;f[b]=!0;const g=b*c,v=Math.min(l-g,c);if(v<=0)return;const E=t.map(S=>{const x=Math.floor(g/l*S.length),w=Math.floor((g+v)/l*S.length);return S.slice(x,w)});this.renderSingleCanvas(E,n,v,i,g,a,o)},h=Math.ceil(l/c);if(!this.isScrollable){for(let b=0;b1){const b=this.on("scroll",()=>{const{scrollLeft:g}=this.scrollContainer,v=Math.floor(g/l*h);Object.keys(f).length>Nv.MAX_NODES&&(a.innerHTML="",o.innerHTML="",f={}),d(v-1),d(v),d(v+1)});this.unsubscribeOnScroll.push(b)}}renderChannel(t,n,r,i){var{overlay:a}=n,o=function(c,f){var d={};for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&f.indexOf(h)<0&&(d[h]=c[h]);if(c!=null&&typeof Object.getOwnPropertySymbols=="function"){var p=0;for(h=Object.getOwnPropertySymbols(c);p0&&(u.style.marginTop=`-${s}px`),this.canvasWrapper.style.minHeight=`${s}px`,this.canvasWrapper.appendChild(u);const l=u.cloneNode();this.progressWrapper.appendChild(l),this.renderMultiCanvas(t,o,r,s,u,l)}render(t){return Kt(this,void 0,void 0,function*(){var n;this.timeouts.forEach(s=>s()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const r=this.getPixelRatio(),i=this.scrollContainer.clientWidth,a=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=a>i;const o=this.options.fillParent&&!this.isScrollable,u=(o?i:a)*r;if(this.wrapper.style.width=o?"100%":`${a}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let s=0;s1&&s.push(t.getChannelData(1)),this.renderChannel(s,this.options,u,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(r=>r()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:n}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:r}=this.progressWrapper.getBoundingClientRect();let i=r-n;i*=2,i=i<0?Math.floor(i):Math.ceil(i),i/=2,this.scrollContainer.scrollLeft+=i}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,n=!1){const{scrollLeft:r,scrollWidth:i,clientWidth:a}=this.scrollContainer,o=t*i,u=r,s=r+a,l=a/2;if(this.isDragging)o+30>s?this.scrollContainer.scrollLeft+=30:o-30s)&&(this.scrollContainer.scrollLeft=o-(this.options.autoCenter?l:0));const c=o-r-l;n&&this.options.autoCenter&&c>0&&(this.scrollContainer.scrollLeft+=Math.min(c,10))}{const c=this.scrollContainer.scrollLeft,f=c/i,d=(c+a)/i;this.emit("scroll",f,d,c,c+a)}}renderProgress(t,n){if(isNaN(t))return;const r=100*t;this.canvasWrapper.style.clipPath=`polygon(${r}% 0, 100% 0, 100% 100%, ${r}% 100%)`,this.progressWrapper.style.width=`${r}%`,this.cursor.style.left=`${r}%`,this.cursor.style.transform=`translateX(-${Math.round(r)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,n)}exportImage(t,n,r){return Kt(this,void 0,void 0,function*(){const i=this.canvasWrapper.querySelectorAll("canvas");if(!i.length)throw new Error("No waveform data");if(r==="dataURL"){const a=Array.from(i).map(o=>o.toDataURL(t,n));return Promise.resolve(a)}return Promise.all(Array.from(i).map(a=>new Promise((o,u)=>{a.toBlob(s=>{s?o(s):u(new Error("Could not export image"))},t,n)})))})}};Iv.MAX_CANVAS_WIDTH=8e3,Iv.MAX_NODES=10;class xse extends Kc{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class Rg extends Kc{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return Kt(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(n=>{if(n.status>=400)throw new Error(`Failed to fetch ${t}: ${n.status} (${n.statusText})`);return n.arrayBuffer()}).then(n=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(n)).then(n=>{this.currentSrc===t&&(this.buffer=n,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(t=this.bufferNode)===null||t===void 0||t.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let n=this.playedDuration*this._playbackRate;(n>=this.duration||n<0)&&(n=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,n),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return Kt(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const n=t-this.currentTime,r=this.bufferNode;r==null||r.stop(this.audioContext.currentTime+n),r==null||r.addEventListener("ended",()=>{r===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return Kt(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const n=!this.paused;n&&this._pause(),this.playedDuration=t/this._playbackRate,n&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,n;return(t=this._duration)!==null&&t!==void 0?t:((n=this.buffer)===null||n===void 0?void 0:n.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const n=this.buffer.numberOfChannels;for(let r=0;r{this.emit("init");const{peaks:a,duration:o}=this.options;(i||a&&o)&&this.load(i,a,o).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("emptied",()=>{this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("ended",()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,n)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,n))}),this.renderer.on("dblclick",(t,n)=>{this.emit("dblclick",t,n)}),this.renderer.on("scroll",(t,n,r,i)=>{const a=this.getDuration();this.emit("scroll",t*a,n*a,r,i)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}));{let t;this.subscriptions.push(this.renderer.on("drag",n=>{if(!this.options.interact)return;let r;this.renderer.renderProgress(n),clearTimeout(t),this.isPlaying()?r=0:this.options.dragToSeek===!0?r=200:typeof this.options.dragToSeek=="object"&&this.options.dragToSeek!==void 0&&(r=this.options.dragToSeek.debounceTime),t=setTimeout(()=>{this.seekTo(n)},r),this.emit("interaction",n*this.getDuration()),this.emit("drag",n)}))}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(n=>{this.registerPlugin(n)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=Uf.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=Uf.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){return t._init(this),this.plugins.push(t),this.subscriptions.push(t.once("destroy",()=>{this.plugins=this.plugins.filter(n=>n!==t)})),t}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const n=t/this.getDuration();this.renderer.setScrollPercentage(n)}getActivePlugins(){return this.plugins}loadAudio(t,n,r,i){return Kt(this,void 0,void 0,function*(){var a;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,!n&&!r){const u=this.options.fetchParams||{};window.AbortController&&!u.signal&&(this.abortController=new AbortController,u.signal=(a=this.abortController)===null||a===void 0?void 0:a.signal);const s=c=>this.emit("loading",c);n=yield bse.fetchBlob(t,s,u);const l=this.options.blobMimeType;l&&(n=new Blob([n],{type:l}))}this.setSrc(t,n);const o=yield new Promise(u=>{const s=i||this.getDuration();s?u(s):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>u(this.getDuration()),{once:!0}))});if(!t&&!n){const u=this.getMediaElement();u instanceof Rg&&(u.duration=o)}if(r)this.decodedData=Uf.createBuffer(r,o||0);else if(n){const u=yield n.arrayBuffer();this.decodedData=yield Uf.decode(u,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,n,r){return Kt(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,n,r)}catch(i){throw this.emit("error",i),i}})}loadBlob(t,n,r){return Kt(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,n,r)}catch(i){throw this.emit("error",i),i}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:n=8e3,precision:r=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const i=Math.min(t,this.decodedData.numberOfChannels),a=[];for(let o=0;oMath.abs(d)&&(d=p)}s.push(Math.round(d*r)/r)}a.push(s)}return a}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const n=this.getDuration()*t;this.setTime(n)}play(t,n){const r=Object.create(null,{play:{get:()=>super.play}});return Kt(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const i=yield r.play.call(this);return n!=null&&(this.media instanceof Rg?this.media.stopAt(n):this.stopAtPosition=n),i})}playPause(){return Kt(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return Kt(this,arguments,void 0,function*(t="image/png",n=1,r="dataURL"){return this.renderer.exportImage(t,n,r)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(n=>n.destroy()),this.subscriptions.forEach(n=>n()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}wc.BasePlugin=class extends Kc{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}_init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(e=>e())}},wc.dom=vse;class Sse{constructor(){this.listeners={}}on(t,n,r){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(n),r==null?void 0:r.once){const i=()=>{this.un(t,i),this.un(t,n)};return this.on(t,i),i}return()=>this.un(t,n)}un(t,n){var r;(r=this.listeners[t])===null||r===void 0||r.delete(n)}once(t,n){return this.on(t,n,{once:!0})}unAll(){this.listeners={}}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}}class Tse extends Sse{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}}function g3(e,t){const n=t.xmlns?document.createElementNS(t.xmlns,e):document.createElement(e);for(const[r,i]of Object.entries(t))if(r==="children")for(const[a,o]of Object.entries(t))typeof o=="string"?n.appendChild(document.createTextNode(o)):n.appendChild(g3(a,o));else r==="style"?Object.assign(n.style,i):r==="textContent"?n.textContent=i:n.setAttribute(r,i.toString());return n}function Dg(e,t,n){return g3(e,t||{})}const _se={height:20,timeOffset:0,formatTimeCallback:e=>e/60>1?`${Math.floor(e/60)}:${`${(e=Math.round(e%60))<10?"0":""}${e}`}`:`${Math.round(1e3*e)/1e3}`};class bE extends Tse{constructor(t){super(t||{}),this.options=Object.assign({},_se,t),this.timelineWrapper=this.initTimelineWrapper()}static create(t){return new bE(t)}onInit(){var t;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let n=this.wavesurfer.getWrapper();if(this.options.container instanceof HTMLElement)n=this.options.container;else if(typeof this.options.container=="string"){const r=document.querySelector(this.options.container);if(!r)throw Error(`No Timeline container found matching ${this.options.container}`);n=r}this.options.insertPosition?(n.firstElementChild||n).insertAdjacentElement(this.options.insertPosition,this.timelineWrapper):n.appendChild(this.timelineWrapper),this.subscriptions.push(this.wavesurfer.on("redraw",()=>this.initTimeline())),(!((t=this.wavesurfer)===null||t===void 0)&&t.getDuration()||this.options.duration)&&this.initTimeline()}destroy(){this.timelineWrapper.remove(),super.destroy()}initTimelineWrapper(){return Dg("div",{part:"timeline-wrapper",style:{pointerEvents:"none"}})}defaultTimeInterval(t){return t>=25?1:5*t>=25?5:15*t>=25?15:60*Math.ceil(.5/t)}defaultPrimaryLabelInterval(t){return t>=25?10:5*t>=25?6:4}defaultSecondaryLabelInterval(t){return t>=25?5:2}virtualAppend(t,n,r){let i=!1;const a=(s,l)=>{if(!this.wavesurfer)return;const c=r.clientWidth,f=t>s&&t+c{a(c,f)}))}initTimeline(){var t,n,r,i,a,o,u,s;const l=(r=(n=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDuration())!==null&&n!==void 0?n:this.options.duration)!==null&&r!==void 0?r:0,c=(((i=this.wavesurfer)===null||i===void 0?void 0:i.getWrapper().scrollWidth)||this.timelineWrapper.scrollWidth)/l,f=(a=this.options.timeInterval)!==null&&a!==void 0?a:this.defaultTimeInterval(c),d=(o=this.options.primaryLabelInterval)!==null&&o!==void 0?o:this.defaultPrimaryLabelInterval(c),h=this.options.primaryLabelSpacing,p=(u=this.options.secondaryLabelInterval)!==null&&u!==void 0?u:this.defaultSecondaryLabelInterval(c),m=this.options.secondaryLabelSpacing,b=this.options.insertPosition==="beforebegin",g=Dg("div",{style:Object.assign({height:`${this.options.height}px`,overflow:"hidden",fontSize:this.options.height/2+"px",whiteSpace:"nowrap"},b?{position:"absolute",top:"0",left:"0",right:"0",zIndex:"2"}:{position:"relative"})});g.setAttribute("part","timeline"),typeof this.options.style=="string"?g.setAttribute("style",g.getAttribute("style")+this.options.style):typeof this.options.style=="object"&&Object.assign(g.style,this.options.style);const v=Dg("div",{style:{width:"0",height:"50%",display:"flex",flexDirection:"column",justifyContent:b?"flex-start":"flex-end",top:b?"0":"auto",bottom:b?"auto":"0",overflow:"visible",borderLeft:"1px solid currentColor",opacity:`${(s=this.options.secondaryLabelOpacity)!==null&&s!==void 0?s:.25}`,position:"absolute",zIndex:"1"}});for(let E=0,S=0;E{const o=C.useRef(null),u=C.useRef(null);return C.useImperativeHandle(a,()=>({getCurrentTime:()=>{var s;return((s=u.current)==null?void 0:s.getCurrentTime())||0},setTime:s=>{var l;return(l=u.current)==null?void 0:l.setTime(s)},play:()=>{var s;return(s=u.current)==null?void 0:s.play()},pause:()=>{var s;return(s=u.current)==null?void 0:s.pause()}})),C.useEffect(()=>{u.current&&(t?u.current.play():u.current.pause())},[t]),C.useEffect(()=>{if(!o.current)return;u.current&&(u.current.destroy(),u.current=null);const s=bE.create({height:16,timeInterval:.1,primaryLabelInterval:1,style:{fontSize:"10px"}});return u.current=wc.create({container:o.current,waveColor:"rgb(200, 0, 200)",progressColor:"rgb(100, 0, 100)",url:e,minPxPerSec:100,mediaControls:!0,plugins:[s]}),u.current.on("play",n),u.current.on("pause",r),i&&u.current.on("audioprocess",i),()=>{var l;u.current&&i&&u.current.un("audioprocess",i),(l=u.current)==null||l.destroy(),u.current=null}},[e]),_.jsx("div",{className:"w-full",children:_.jsx("div",{ref:o})})}),Cse=({selectedModel:e,selectedAttack:t,examples:n})=>{var O,R,A;const r=n[e][t],i=gE(r),a=Object.keys(i),[o,u]=M.useState(a[0]||""),s=i[o]||{},l=Object.keys(s),[c,f]=M.useState(l[0]||""),[d,h]=M.useState("wmd"),p=M.useRef(0),[m,b]=M.useState(null),g=M.useMemo(()=>{const I={};return l.forEach(L=>{I[L]=M.createRef()}),I},[l.join(",")]),[v,E]=M.useState(.5),[S,x]=M.useState(!0),w=I=>{console.log(`Playing variant: ${I}`),b(I),l.forEach(L=>{var U,j,B;L!==I&&((U=g[L])!=null&&U.current)&&((B=(j=g[L])==null?void 0:j.current)==null||B.pause())})},T=I=>{console.log(`Pausing variant: ${I}`),m===I&&b(null)};return M.useEffect(()=>{f(l[0]||"")},[o]),M.useEffect(()=>{var I;(I=s[c])!=null&&I.image_url&&x(!0)},[c,(O=s[c])==null?void 0:O.image_url]),M.useEffect(()=>{c&&m!=null&&(p.current=Math.max(0,p.current-v),b(c),l.forEach(I=>{var L,U,j,B,z;I!==c&&((U=(L=g[I])==null?void 0:L.current)==null||U.pause()),(j=g[I])!=null&&j.current&&((z=(B=g[I])==null?void 0:B.current)==null||z.setTime(p.current))}))},[c]),console.log((A=(R=g[c])==null?void 0:R.current)==null?void 0:A.getCurrentTime()),a.length?_.jsx("div",{className:"w-full overflow-auto",style:{minHeight:"100vh"},children:_.jsxs("div",{className:"example-display",children:[_.jsx("div",{className:"mb-4",children:_.jsxs("fieldset",{className:"fieldset",children:[_.jsx("legend",{className:"fieldset-legend",children:"Audio"}),_.jsx("select",{className:"select select-bordered",value:o||"",onChange:I=>{u(I.target.value||"")},children:a.map(I=>_.jsx("option",{value:I,children:I},I))})]})}),o&&c&&s[c]&&_.jsxs(_.Fragment,{children:[_.jsx(yE,{variantMetadatas:Object.fromEntries(l.map(I=>{var L;return[I,((L=s[I])==null?void 0:L.metadata)||{}]}))}),_.jsxs(vE,{children:[_.jsx(h3,{variantKeys:l,selectedVariant:c,setSelectedVariant:f}),_.jsx(hp,{id:"variant-selector-tooltip",place:"top",className:"z-[10000] max-w-xs !opacity-100 bg-base-100 text-base-content",style:{boxShadow:"0 0 10px rgba(0,0,0,0.2)",zIndex:1e4},positionStrategy:"fixed",children:_.jsxs("div",{className:"p-2 text-xs text-left relative z-[10000]",children:["You can also change the variant using keys ",_.jsx("b",{children:"1"}),", ",_.jsx("b",{children:"2"}),", ",_.jsx("b",{children:"3"}),", ",_.jsx("b",{children:"4"})," ","on your keyboard."]})}),_.jsx(p3,{toggleMode:d,setToggleMode:h,selectedVariant:c,setSelectedVariant:f,variantKeys:l}),_.jsxs("fieldset",{className:"fieldset mt-2",children:[_.jsx("legend",{className:"fieldset-legend",children:"Rewind Seconds"}),_.jsx("input",{id:"rewind-seconds",type:"number",min:0,step:.1,value:v,onChange:I=>E(Math.max(0,Number(I.target.value))),className:"input input-bordered w-20",placeholder:"Seconds"})]}),_.jsxs("div",{className:"flex flex-col items-center gap-4",children:[l.map(I=>s[I].audio_url?_.jsxs("div",{style:{width:"100%",display:c===I?"block":"none"},children:[_.jsx("div",{className:"font-mono text-xs mb-1",children:I}),_.jsx(Ase,{ref:g[I],src:Wn.getProxiedUrl(s[I].audio_url,!0),playing:m===I,onPlay:()=>w(I),onPause:()=>T(I),onAudioProcess:L=>{p.current=L,l.forEach(U=>{var j,B,z;U!==I&&((j=g[U])!=null&&j.current)&&((z=(B=g[U])==null?void 0:B.current)==null||z.setTime(L))})}})]},I):null),s[c].image_url&&_.jsxs("div",{className:"relative",children:[S&&_.jsx(Yc,{}),_.jsx("img",{src:Wn.getProxiedUrl(s[c].image_url),alt:o,className:"example-image",style:{display:"block",opacity:S?0:1,transition:"opacity 0.3s"},onLoad:()=>x(!1),onError:()=>x(!1),onClick:()=>jh(d,c,f,l)},s[c].image_url)]})]})]})]})]})}):_.jsx("div",{className:"w-full mt-12 flex items-center justify-center",children:_.jsx("div",{className:"text-gray-500",children:"No audio examples available. Please select another model and attack."})})},Ose=({selectedModel:e,selectedAttack:t,examples:n})=>{var re,X;const r=n[e][t],i=gE(r),a=Object.keys(i),[o,u]=M.useState(a[0]||""),s=i[o]||{},l=Object.keys(s),c="original",[f,d]=M.useState("attacked"),[h,p]=M.useState(50),[m,b]=M.useState(1),g=M.useRef(0),v=M.useMemo(()=>{const ee={};return l.forEach(te=>{ee[te]=M.createRef()}),ee},[l.join(",")]),[E,S]=M.useState(!1),[x,w]=M.useState(!1),[T,O]=M.useState(!1),R=()=>{E?(l.forEach(ee=>{var te,W,Y;(te=v[ee])!=null&&te.current&&((Y=(W=v[ee])==null?void 0:W.current)==null||Y.pause())}),S(!1)):(l.forEach(ee=>{var te,W,Y;(te=v[ee])!=null&&te.current&&((Y=(W=v[ee])==null?void 0:W.current)==null||Y.play())}),S(!0))},A=()=>{S(!0)},I=()=>{S(!1)},L=ee=>{var W;const te=(W=v[ee])==null?void 0:W.current;te&&(g.current=te.currentTime,l.forEach(Y=>{var ae;if(Y!==ee&&((ae=v[Y])!=null&&ae.current)){const q=v[Y].current;Math.abs(q.currentTime-g.current)>.05&&(q.currentTime=g.current)}}))},U=ee=>{if(isNaN(ee))return"00:00.00";const te=Math.floor(ee/60),W=Math.floor(ee%60),Y=Math.floor(ee%1*100);return`${te.toString().padStart(2,"0")}:${W.toString().padStart(2,"0")}.${Y.toString().padStart(2,"0")}`},[j,B]=M.useState({width:0,height:0}),z=ee=>{const te=ee.currentTarget;B({width:te.videoWidth,height:te.videoHeight}),w(!0)},[V,F]=M.useState({current:0,duration:0}),G=()=>{var ee;if((ee=v[c])!=null&&ee.current){const te=v[c].current;F({current:te.currentTime,duration:te.duration||0})}},k=M.useMemo(()=>U(V.current),[V.current]),ne=M.useMemo(()=>U(V.duration),[V.duration]),J=M.useRef(null);if(M.useEffect(()=>{const ee=()=>{var te;if((te=v[c])!=null&&te.current){const W=v[c].current;F(Y=>({...Y,current:W.currentTime,duration:W.duration||0}))}J.current=requestAnimationFrame(ee)};return J.current=requestAnimationFrame(ee),()=>{J.current!==null&&(cancelAnimationFrame(J.current),J.current=null)}},[c]),!a.length)return _.jsx("div",{className:"w-full mt-12 flex items-center justify-center",children:_.jsx("div",{className:"text-gray-500",children:"No video examples available. Please select another model and attack."})});const P=`inset(0 ${100-h}% 0 0)`,ie=`inset(0 0 0 ${h}%)`;return _.jsx("div",{className:"w-full overflow-auto",style:{minHeight:"100vh"},children:_.jsxs("div",{className:"example-display",children:[_.jsx("div",{className:"mb-4",children:_.jsxs("fieldset",{className:"fieldset",children:[_.jsx("legend",{className:"fieldset-legend",children:"Video"}),_.jsx("select",{className:"select select-bordered",value:o||"",onChange:ee=>{u(ee.target.value||"")},children:a.map(ee=>_.jsx("option",{value:ee,children:ee},ee))})]})}),o&&s[c]&&s[f]&&_.jsxs(_.Fragment,{children:[_.jsx(yE,{variantMetadatas:Object.fromEntries(l.map(ee=>{var te;return[ee,((te=s[ee])==null?void 0:te.metadata)||{}]}))}),_.jsx(vE,{children:_.jsxs("div",{className:"flex flex-col gap-4",children:[_.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[_.jsx("label",{htmlFor:"comparison-variant",className:"font-mono text-xs",children:"Right Side:"}),_.jsx("select",{id:"comparison-variant",className:"select select-bordered select-xs",value:f,onChange:ee=>d(ee.target.value),children:l.filter(ee=>ee!==c).map(ee=>_.jsx("option",{value:ee,children:hl[ee]},ee))}),_.jsx("button",{onClick:R,className:"btn btn-xs btn-primary ml-4",children:E?"Pause":"Play"}),_.jsx("label",{htmlFor:"video-scale",className:"font-mono text-xs ml-4",children:"Scale:"}),_.jsx("input",{id:"video-scale",type:"range",min:.3,max:1,step:.01,value:m,onChange:ee=>b(Number(ee.target.value)),className:"range range-xs",style:{verticalAlign:"middle",width:"120px",accentColor:"#3b82f6"}}),_.jsxs("span",{className:"ml-2 font-mono text-xs",children:[(m*100).toFixed(0),"%"]})]}),_.jsx("div",{className:"mb-2",children:_.jsxs("div",{className:"flex justify-between text-xs font-mono",children:[_.jsxs("span",{className:"font-bold",children:["Left: ",hl[c]]}),_.jsxs("span",{className:"font-bold",children:["Right: ",hl[f]]})]})}),_.jsxs("div",{className:"relative w-full",style:{width:`${m*100}%`,margin:"0 auto",minHeight:"300px"},children:[_.jsx("video",{className:"w-full h-auto opacity-0",src:Wn.getProxiedUrl(s[c].video_url||"")}),((re=s[c])==null?void 0:re.video_url)&&_.jsx("div",{className:"absolute top-0 left-0 w-full h-full",style:{clipPath:P},children:_.jsx("video",{ref:v[c],controls:!1,src:Wn.getProxiedUrl(s[c].video_url),className:"w-full h-auto",onTimeUpdate:()=>L(c),onDurationChange:G,onPlay:A,onPause:I,onLoadedMetadata:z})}),((X=s[f])==null?void 0:X.video_url)&&_.jsx("div",{className:"absolute top-0 left-0 w-full h-full",style:{clipPath:ie},children:_.jsx("video",{ref:v[f],controls:!1,src:Wn.getProxiedUrl(s[f].video_url),className:"w-full h-auto",onTimeUpdate:()=>L(f),onDurationChange:G,onPlay:A,onPause:I,onLoadedMetadata:z})}),_.jsxs("div",{className:"absolute top-0 bottom-0 z-10 pointer-events-none",style:{left:`${h}%`,height:"100%",width:"4px",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[_.jsx("div",{className:"bg-white h-full w-1 opacity-80"}),_.jsx("div",{className:"absolute bg-white rounded-full p-1.5 opacity-90 shadow-md",style:{transform:"translate(-50%, 0)",left:"50%"},children:_.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_.jsx("path",{d:"M8 7L4 12L8 17M16 7L20 12L16 17",stroke:"black",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),_.jsxs("div",{className:"absolute top-0 left-0 w-full h-full z-20",style:{background:"transparent",display:"flex",flexDirection:"column",justifyContent:"flex-end"},children:[_.jsx("input",{type:"range",min:0,max:100,value:h,onChange:ee=>p(Number(ee.target.value)),className:"range range-xs w-full absolute top-1/2 left-0 right-0 z-30",style:{transform:"translateY(-50%)",margin:"0 auto",width:"100%",opacity:0,cursor:"ew-resize",height:"50px"}}),_.jsx("div",{className:"w-full h-full",onClick:R})]}),!E&&_.jsx("div",{className:`absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2
+ bg-black bg-opacity-60 rounded-full p-4 cursor-pointer z-40`,onClick:R,children:_.jsx("svg",{width:"30",height:"30",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_.jsx("path",{d:"M8 5V19L19 12L8 5Z",fill:"white"})})})]}),_.jsxs("div",{className:"w-full mt-2 flex flex-col gap-1",style:{width:"100%"},children:[_.jsx("input",{type:"range",min:0,max:V.duration||100,step:.01,value:V.current||0,onMouseDown:()=>{O(E),E&&(l.forEach(ee=>{var te;(te=v[ee])!=null&&te.current&&v[ee].current.pause()}),S(!1))},onChange:ee=>{const te=parseFloat(ee.target.value);F(W=>({...W,current:te}))},onInput:ee=>{const te=parseFloat(ee.target.value);l.forEach(W=>{var Y;(Y=v[W])!=null&&Y.current&&(v[W].current.currentTime=te)})},onMouseUp:ee=>{const te=parseFloat(ee.target.value);l.forEach(W=>{var Y;(Y=v[W])!=null&&Y.current&&(v[W].current.currentTime=te)}),document.activeElement===ee.target&&(ee.target.blur(),setTimeout(()=>{T&&(l.forEach(W=>{var Y;(Y=v[W])!=null&&Y.current&&v[W].current.play()}),S(!0))},100))},className:"range range-xs w-full",style:{width:"100%",height:"14px",borderRadius:"7px",accentColor:"#3b82f6",outline:"none",cursor:"pointer",appearance:"none",WebkitAppearance:"none",padding:"0",margin:"0",background:"#e5e7eb"}}),_.jsxs("div",{className:"flex justify-between text-xs font-mono",children:[_.jsx("span",{children:k}),_.jsx("span",{children:ne})]})]})]})})]})]})})},Lg=({fileType:e})=>{const[t,n]=C.useState({}),[r,i]=C.useState(!1),[a,o]=C.useState(null),[u,s]=C.useState(null),[l,c]=C.useState(null),[f,d]=C.useState(!1),h=C.useRef(so.getInstance());C.useEffect(()=>{h.current.load().then(()=>d(!0))},[]);const p=oi();return C.useEffect(()=>{const m=new URLSearchParams(p.search),b=m.get("model"),g=m.get("attack"),v=m.get("strength");b&&s(b),(g||v)&&c(E=>{if(!u||!t[u])return E;const S=Object.keys(t[u]);if(g&&v){const x=S.find(w=>w.includes(g)&&w.endsWith(v));if(x)return x}if(g){const x=S.find(w=>w.includes(g));if(x)return x}if(v){const x=S.find(w=>w.endsWith(v));if(x)return x}return E})},[p.search,u,t]),C.useEffect(()=>{i(!0),o(null),Wn.fetchExamplesByType(e).then(m=>{n(m);const b=Object.keys(m);if(b.length>0){s(v=>v&&m[v]?v:b[0]);const g=Object.keys(m[b[0]]);g.length>0?c(v=>v&&m[b[0]][v]?v:g[0]):c(null)}else s(null),c(null);i(!1)}).catch(m=>{o(m.message),i(!1)})},[e]),r?_.jsx(Yc,{}):_.jsxs("div",{className:"examples-container",children:[_.jsxs("div",{className:"selectors-container flex flex-col gap-4",children:[_.jsxs("fieldset",{className:"fieldset w-full p-4 rounded border border-gray-700 bg-base-200",children:[_.jsx("legend",{className:"fieldset-legend font-semibold",children:"Model"}),_.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-1 max-h-48 overflow-y-auto pr-2",children:Object.keys(t).map(m=>{const b=h.current.getModelFullName(m)||m;return _.jsx("div",{className:"flex items-center gap-2 text-sm relative group",children:_.jsxs("label",{className:"flex items-center gap-2 flex-grow",children:[_.jsx("input",{type:"radio",className:"radio radio-sm",checked:u===m,onChange:()=>s(m),name:"model-selection"}),_.jsxs("div",{className:"flex items-center",children:[_.jsx("span",{className:"truncate",title:b,children:m}),_.jsx(d3,{modelName:m})]})]})},m)})})]}),u&&_.jsxs("fieldset",{className:"fieldset",children:[_.jsx("legend",{className:"fieldset-legend",children:"Attack"}),_.jsx("select",{className:"select select-bordered",value:l||"",onChange:m=>c(m.target.value||null),children:Object.keys(t[u]).map(m=>_.jsx("option",{value:m,children:m},m))})]})]}),a&&_.jsxs("p",{className:"error",children:["Error: ",a]}),u&&l&&e==="image"&&_.jsx(yse,{selectedModel:u,selectedAttack:l,examples:t}),u&&l&&e==="audio"&&_.jsx(Cse,{selectedModel:u,selectedAttack:l,examples:t}),u&&l&&e==="video"&&_.jsx(Ose,{selectedModel:u,selectedAttack:l,examples:t})]})};function xA(e){const t=[],n=String(e||"");let r=n.indexOf(","),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);const o=n.slice(i,r).trim();(o||!a)&&t.push(o),i=r+1,r=n.indexOf(",",i)}return t}function y3(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Pse=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kse=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ise={};function wA(e,t){return(Ise.jsx?kse:Pse).test(e)}const Nse=/[ \t\n\f\r]/g;function Rse(e){return typeof e=="object"?e.type==="text"?SA(e.value):!1:SA(e)}function SA(e){return e.replace(Nse,"")===""}let Xc=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Xc.prototype.normal={};Xc.prototype.property={};Xc.prototype.space=void 0;function v3(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Xc(n,r,t)}function Sc(e){return e.toLowerCase()}let Nn=class{constructor(t,n){this.attribute=n,this.property=t}};Nn.prototype.attribute="";Nn.prototype.booleanish=!1;Nn.prototype.boolean=!1;Nn.prototype.commaOrSpaceSeparated=!1;Nn.prototype.commaSeparated=!1;Nn.prototype.defined=!1;Nn.prototype.mustUseProperty=!1;Nn.prototype.number=!1;Nn.prototype.overloadedBoolean=!1;Nn.prototype.property="";Nn.prototype.spaceSeparated=!1;Nn.prototype.space=void 0;let Dse=0;const Ie=So(),At=So(),Rv=So(),le=So(),nt=So(),fu=So(),Mn=So();function So(){return 2**++Dse}const Dv=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:At,commaOrSpaceSeparated:Mn,commaSeparated:fu,number:le,overloadedBoolean:Rv,spaceSeparated:nt},Symbol.toStringTag,{value:"Module"})),Mg=Object.keys(Dv);let EE=class extends Nn{constructor(t,n,r,i){let a=-1;if(super(t,n),TA(this,"space",i),typeof r=="number")for(;++a4&&n.slice(0,4)==="data"&&Fse.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(_A,Use);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!_A.test(a)){let o=a.replace(jse,Bse);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=EE}return new i(r,t)}function Bse(e){return"-"+e.toLowerCase()}function Use(e){return e.charAt(1).toUpperCase()}const am=v3([b3,Lse,w3,S3,T3],"html"),hs=v3([b3,Mse,w3,S3,T3],"svg");function AA(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function _3(e){return e.join(" ").trim()}var wE={},CA=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Hse=/\n/g,zse=/^\s*/,Vse=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Wse=/^:\s*/,Gse=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,qse=/^[;\s]*/,Yse=/^\s+|\s+$/g,Kse=`
+`,OA="/",PA="*",ja="",Xse="comment",Qse="declaration",Zse=function(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(p){var m=p.match(Hse);m&&(n+=m.length);var b=p.lastIndexOf(Kse);r=~b?p.length-b:r+p.length}function a(){var p={line:n,column:r};return function(m){return m.position=new o(p),l(),m}}function o(p){this.start=p,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function u(p){var m=new Error(t.source+":"+n+":"+r+": "+p);if(m.reason=p,m.filename=t.source,m.line=n,m.column=r,m.source=e,!t.silent)throw m}function s(p){var m=p.exec(e);if(m){var b=m[0];return i(b),e=e.slice(b.length),m}}function l(){s(zse)}function c(p){var m;for(p=p||[];m=f();)m!==!1&&p.push(m);return p}function f(){var p=a();if(!(OA!=e.charAt(0)||PA!=e.charAt(1))){for(var m=2;ja!=e.charAt(m)&&(PA!=e.charAt(m)||OA!=e.charAt(m+1));)++m;if(m+=2,ja===e.charAt(m-1))return u("End of comment missing");var b=e.slice(2,m-2);return r+=2,i(b),e=e.slice(m),r+=2,p({type:Xse,comment:b})}}function d(){var p=a(),m=s(Vse);if(m){if(f(),!s(Wse))return u("property missing ':'");var b=s(Gse),g=p({type:Qse,property:kA(m[0].replace(CA,ja)),value:b?kA(b[0].replace(CA,ja)):ja});return s(qse),g}}function h(){var p=[];c(p);for(var m;m=d();)m!==!1&&(p.push(m),c(p));return p}return l(),h()};function kA(e){return e?e.replace(Yse,ja):ja}var Jse=Zi&&Zi.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wE,"__esModule",{value:!0});wE.default=tle;var ele=Jse(Zse);function tle(e,t){var n=null;if(!e||typeof e!="string")return n;var r=(0,ele.default)(e),i=typeof t=="function";return r.forEach(function(a){if(a.type==="declaration"){var o=a.property,u=a.value;i?t(o,u,a):u&&(n=n||{},n[o]=u)}}),n}var om={};Object.defineProperty(om,"__esModule",{value:!0});om.camelCase=void 0;var nle=/^--[a-zA-Z0-9_-]+$/,rle=/-([a-z])/g,ile=/^[^-]+$/,ale=/^-(webkit|moz|ms|o|khtml)-/,ole=/^-(ms)-/,ule=function(e){return!e||ile.test(e)||nle.test(e)},sle=function(e,t){return t.toUpperCase()},IA=function(e,t){return"".concat(t,"-")},lle=function(e,t){return t===void 0&&(t={}),ule(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(ole,IA):e=e.replace(ale,IA),e.replace(rle,sle))};om.camelCase=lle;var cle=Zi&&Zi.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},fle=cle(wE),dle=om;function Lv(e,t){var n={};return!e||typeof e!="string"||(0,fle.default)(e,function(r,i){r&&i&&(n[(0,dle.camelCase)(r,t)]=i)}),n}Lv.default=Lv;var hle=Lv;const ple=Ye(hle),um=A3("end"),li=A3("start");function A3(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function C3(e){const t=li(e),n=um(e);if(t&&n)return{start:t,end:n}}function pl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?NA(e.position):"start"in e||"end"in e?NA(e):"line"in e||"column"in e?Mv(e):""}function Mv(e){return RA(e&&e.line)+":"+RA(e&&e.column)}function NA(e){return Mv(e&&e.start)+"-"+Mv(e&&e.end)}function RA(e){return e&&typeof e=="number"?e:1}class fn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const s=r.indexOf(":");s===-1?a.ruleId=r:(a.source=r.slice(0,s),a.ruleId=r.slice(s+1))}if(!a.place&&a.ancestors&&a.ancestors){const s=a.ancestors[a.ancestors.length-1];s&&(a.place=s.position)}const u=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=u?u.line:void 0,this.name=pl(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual,this.expected,this.note,this.url}}fn.prototype.file="";fn.prototype.name="";fn.prototype.reason="";fn.prototype.message="";fn.prototype.stack="";fn.prototype.column=void 0;fn.prototype.line=void 0;fn.prototype.ancestors=void 0;fn.prototype.cause=void 0;fn.prototype.fatal=void 0;fn.prototype.place=void 0;fn.prototype.ruleId=void 0;fn.prototype.source=void 0;const SE={}.hasOwnProperty,mle=new Map,gle=/[A-Z]/g,yle=new Set(["table","tbody","thead","tfoot","tr"]),vle=new Set(["td","th"]),O3="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ble(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Cle(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Ale(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?hs:am,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=P3(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function P3(e,t,n){if(t.type==="element")return Ele(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return xle(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Sle(e,t,n);if(t.type==="mdxjsEsm")return wle(e,t);if(t.type==="root")return Tle(e,t,n);if(t.type==="text")return _le(e,t)}function Ele(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=hs,e.schema=i),e.ancestors.push(t);const a=I3(e,t.tagName,!1),o=Ole(e,t);let u=_E(e,t);return yle.has(t.tagName)&&(u=u.filter(function(s){return typeof s=="string"?!Rse(s):!0})),k3(e,o,a,t),TE(o,u),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function xle(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Tc(e,t.position)}function wle(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Tc(e,t.position)}function Sle(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=hs,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:I3(e,t.name,!0),o=Ple(e,t),u=_E(e,t);return k3(e,o,a,t),TE(o,u),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Tle(e,t,n){const r={};return TE(r,_E(e,t)),e.create(t,e.Fragment,r,n)}function _le(e,t){return t.value}function k3(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function TE(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ale(e,t,n){return r;function r(i,a,o,u){const l=Array.isArray(o.children)?n:t;return u?l(a,o,u):l(a,o)}}function Cle(e,t){return n;function n(r,i,a,o){const u=Array.isArray(a.children),s=li(r);return t(i,a,o,u,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Ole(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&SE.call(t.properties,i)){const a=kle(e,i,t.properties[i]);if(a){const[o,u]=a;e.tableCellAlignToStyle&&o==="align"&&typeof u=="string"&&vle.has(t.tagName)?r=u:n[o]=u}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ple(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const u=o.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else Tc(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const u=r.value.data.estree.body[0];u.type,a=e.evaluater.evaluateExpression(u.expression)}else Tc(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function _E(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:mle;for(;++ri?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a0?(Gn(e,e.length,0,t),e):t}const MA={}.hasOwnProperty;function R3(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Dr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const yn=Ca(/[A-Za-z]/),ln=Ca(/[\dA-Za-z]/),Fle=Ca(/[#-'*+\--9=?A-Z^-~]/);function Fh(e){return e!==null&&(e<32||e===127)}const $v=Ca(/\d/),Ble=Ca(/[\dA-Fa-f]/),Ule=Ca(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function et(e){return e!==null&&(e<0||e===32)}function Le(e){return e===-2||e===-1||e===32}const sm=Ca(new RegExp("\\p{P}|\\p{S}","u")),mo=Ca(/\s/);function Ca(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ps(e){const t=[];let n=-1,r=0,i=0;for(;++n55295&&a<57344){const u=e.charCodeAt(n+1);a<56320&&u>56319&&u<57344?(o=String.fromCharCode(a,u),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function He(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(s){return Le(s)?(e.enter(n),u(s)):t(s)}function u(s){return Le(s)&&a++o))return;const T=t.events.length;let O=T,R,A;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){if(R){A=t.events[O][1].end;break}R=!0}for(g(r),w=T;wE;){const x=n[S];t.containerState=x[1],x[0].exit.call(t,e)}n.length=E}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Gle(e,t,n){return He(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vu(e){if(e===null||et(e)||mo(e))return 1;if(sm(e))return 2}function lm(e,t,n){const r=[];let i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},d={...e[n][1].start};jA(f,-s),jA(d,s),o={type:s>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},u={type:s>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},a={type:s>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:s>1?"strong":"emphasis",start:{...o.start},end:{...u.end}},e[r][1].end={...o.start},e[n][1].start={...u.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=sr(l,[["enter",e[r][1],t],["exit",e[r][1],t]])),l=sr(l,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),l=sr(l,lm(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=sr(l,[["exit",a,t],["enter",u,t],["exit",u,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(c=2,l=sr(l,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,Gn(e,r-1,n-r+3,l),n=r+l.length-c-2;break}}for(n=-1;++n0&&Le(w)?He(e,v,"linePrefix",a+1)(w):v(w)}function v(w){return w===null||Ee(w)?e.check(FA,m,S)(w):(e.enter("codeFlowValue"),E(w))}function E(w){return w===null||Ee(w)?(e.exit("codeFlowValue"),v(w)):(e.consume(w),E)}function S(w){return e.exit("codeFenced"),t(w)}function x(w,T,O){let R=0;return A;function A(B){return w.enter("lineEnding"),w.consume(B),w.exit("lineEnding"),I}function I(B){return w.enter("codeFencedFence"),Le(B)?He(w,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):L(B)}function L(B){return B===u?(w.enter("codeFencedFenceSequence"),U(B)):O(B)}function U(B){return B===u?(R++,w.consume(B),U):R>=o?(w.exit("codeFencedFenceSequence"),Le(B)?He(w,j,"whitespace")(B):j(B)):O(B)}function j(B){return B===null||Ee(B)?(w.exit("codeFencedFence"),T(B)):O(B)}}}function ice(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const jg={name:"codeIndented",tokenize:oce},ace={partial:!0,tokenize:uce};function oce(e,t,n){const r=this;return i;function i(l){return e.enter("codeIndented"),He(e,a,"linePrefix",5)(l)}function a(l){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?s(l):Ee(l)?e.attempt(ace,o,s)(l):(e.enter("codeFlowValue"),u(l))}function u(l){return l===null||Ee(l)?(e.exit("codeFlowValue"),o(l)):(e.consume(l),u)}function s(l){return e.exit("codeIndented"),t(l)}}function uce(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Ee(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):He(e,a,"linePrefix",5)(o)}function a(o){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(o):Ee(o)?i(o):n(o)}}const sce={name:"codeText",previous:cce,resolve:lce,tokenize:fce};function lce(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Hs(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Hs(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Hs(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function F3(e,t,n,r,i,a,o,u,s){const l=s||Number.POSITIVE_INFINITY;let c=0;return f;function f(g){return g===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(g),e.exit(a),d):g===null||g===32||g===41||Fh(g)?n(g):(e.enter(r),e.enter(o),e.enter(u),e.enter("chunkString",{contentType:"string"}),m(g))}function d(g){return g===62?(e.enter(a),e.consume(g),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(u),d(g)):g===null||g===60||Ee(g)?n(g):(e.consume(g),g===92?p:h)}function p(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function m(g){return!c&&(g===null||g===41||et(g))?(e.exit("chunkString"),e.exit(u),e.exit(o),e.exit(r),t(g)):c