UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

8 lines (7 loc) • 13.6 kB
import{l8 as w,l9 as p,la as K,lb as V,lc as W,ld as v,le as Y,lf as Z,lg as Q,lh as ee,li as re,du as D,l2 as O,b as te,bp as ae,r as ie,j as ne,l1 as oe,lj as le,dr as se,ds as ue,dt as de,lk as fe,l4 as ve,l5 as he,dw as ye}from"./index-Cikp5fMR.js";/*! * chartjs-plugin-datalabels v2.2.0 * https://chartjs-plugin-datalabels.netlify.app * (c) 2017-2022 chartjs-plugin-datalabels contributors * Released under the MIT license */var j=function(){if(typeof window<"u"){if(window.devicePixelRatio)return window.devicePixelRatio;var e=window.screen;if(e)return(e.deviceXDPI||1)/(e.logicalXDPI||1)}return 1}(),g={toTextLines:function(e){var a=[],r;for(e=[].concat(e);e.length;)r=e.pop(),typeof r=="string"?a.unshift.apply(a,r.split(` `)):Array.isArray(r)?e.push.apply(e,r):p(e)||a.unshift(""+r);return a},textSize:function(e,a,r){var t=[].concat(a),i=t.length,n=e.font,o=0,l;for(e.font=r.string,l=0;l<i;++l)o=Math.max(e.measureText(t[l]).width,o);return e.font=n,{height:i*r.lineHeight,width:o}},bound:function(e,a,r){return Math.max(e,Math.min(a,r))},arrayDiff:function(e,a){var r=e.slice(),t=[],i,n,o,l;for(i=0,o=a.length;i<o;++i)l=a[i],n=r.indexOf(l),n===-1?t.push([l,1]):r.splice(n,1);for(i=0,o=r.length;i<o;++i)t.push([r[i],-1]);return t},rasterize:function(e){return Math.round(e*j)/j}};function A(e,a){var r=a.x,t=a.y;if(r===null)return{x:0,y:-1};if(t===null)return{x:1,y:0};var i=e.x-r,n=e.y-t,o=Math.sqrt(i*i+n*n);return{x:o?i/o:0,y:o?n/o:-1}}function ce(e,a,r,t,i){switch(i){case"center":r=t=0;break;case"bottom":r=0,t=1;break;case"right":r=1,t=0;break;case"left":r=-1,t=0;break;case"top":r=0,t=-1;break;case"start":r=-r,t=-t;break;case"end":break;default:i*=Math.PI/180,r=Math.cos(i),t=Math.sin(i);break}return{x:e,y:a,vx:r,vy:t}}var xe=0,N=1,L=2,F=4,H=8;function M(e,a,r){var t=xe;return e<r.left?t|=N:e>r.right&&(t|=L),a<r.top?t|=H:a>r.bottom&&(t|=F),t}function be(e,a){for(var r=e.x0,t=e.y0,i=e.x1,n=e.y1,o=M(r,t,a),l=M(i,n,a),s,u,d;!(!(o|l)||o&l);)s=o||l,s&H?(u=r+(i-r)*(a.top-t)/(n-t),d=a.top):s&F?(u=r+(i-r)*(a.bottom-t)/(n-t),d=a.bottom):s&L?(d=t+(n-t)*(a.right-r)/(i-r),u=a.right):s&N&&(d=t+(n-t)*(a.left-r)/(i-r),u=a.left),s===o?(r=u,t=d,o=M(r,t,a)):(i=u,n=d,l=M(i,n,a));return{x0:r,x1:i,y0:t,y1:n}}function S(e,a){var r=a.anchor,t=e,i,n;return a.clamp&&(t=be(t,a.area)),r==="start"?(i=t.x0,n=t.y0):r==="end"?(i=t.x1,n=t.y1):(i=(t.x0+t.x1)/2,n=(t.y0+t.y1)/2),ce(i,n,e.vx,e.vy,a.align)}var C={arc:function(e,a){var r=(e.startAngle+e.endAngle)/2,t=Math.cos(r),i=Math.sin(r),n=e.innerRadius,o=e.outerRadius;return S({x0:e.x+t*n,y0:e.y+i*n,x1:e.x+t*o,y1:e.y+i*o,vx:t,vy:i},a)},point:function(e,a){var r=A(e,a.origin),t=r.x*e.options.radius,i=r.y*e.options.radius;return S({x0:e.x-t,y0:e.y-i,x1:e.x+t,y1:e.y+i,vx:r.x,vy:r.y},a)},bar:function(e,a){var r=A(e,a.origin),t=e.x,i=e.y,n=0,o=0;return e.horizontal?(t=Math.min(e.x,e.base),n=Math.abs(e.base-e.x)):(i=Math.min(e.y,e.base),o=Math.abs(e.base-e.y)),S({x0:t,y0:i+o,x1:t+n,y1:i,vx:r.x,vy:r.y},a)},fallback:function(e,a){var r=A(e,a.origin);return S({x0:e.x,y0:e.y,x1:e.x+(e.width||0),y1:e.y+(e.height||0),vx:r.x,vy:r.y},a)}},c=g.rasterize;function _e(e){var a=e.borderWidth||0,r=e.padding,t=e.size.height,i=e.size.width,n=-i/2,o=-t/2;return{frame:{x:n-r.left-a,y:o-r.top-a,w:i+r.width+a*2,h:t+r.height+a*2},text:{x:n,y:o,w:i,h:t}}}function pe(e,a){var r=a.chart.getDatasetMeta(a.datasetIndex).vScale;if(!r)return null;if(r.xCenter!==void 0&&r.yCenter!==void 0)return{x:r.xCenter,y:r.yCenter};var t=r.getBasePixel();return e.horizontal?{x:t,y:null}:{x:null,y:t}}function ge(e){return e instanceof re?C.arc:e instanceof D?C.point:e instanceof O?C.bar:C.fallback}function me(e,a,r,t,i,n){var o=Math.PI/2;if(n){var l=Math.min(n,i/2,t/2),s=a+l,u=r+l,d=a+t-l,f=r+i-l;e.moveTo(a,u),s<d&&u<f?(e.arc(s,u,l,-Math.PI,-o),e.arc(d,u,l,-o,0),e.arc(d,f,l,0,o),e.arc(s,f,l,o,Math.PI)):s<d?(e.moveTo(s,r),e.arc(d,u,l,-o,o),e.arc(s,u,l,o,Math.PI+o)):u<f?(e.arc(s,u,l,-Math.PI,0),e.arc(s,f,l,0,Math.PI)):e.arc(s,u,l,-Math.PI,Math.PI),e.closePath(),e.moveTo(a,r)}else e.rect(a,r,t,i)}function we(e,a,r){var t=r.backgroundColor,i=r.borderColor,n=r.borderWidth;!t&&(!i||!n)||(e.beginPath(),me(e,c(a.x)+n/2,c(a.y)+n/2,c(a.w)-n,c(a.h)-n,r.borderRadius),e.closePath(),t&&(e.fillStyle=t,e.fill()),i&&n&&(e.strokeStyle=i,e.lineWidth=n,e.lineJoin="miter",e.stroke()))}function ke(e,a,r){var t=r.lineHeight,i=e.w,n=e.x,o=e.y+t/2;return a==="center"?n+=i/2:(a==="end"||a==="right")&&(n+=i),{h:t,w:i,x:n,y:o}}function Me(e,a,r){var t=e.shadowBlur,i=r.stroked,n=c(r.x),o=c(r.y),l=c(r.w);i&&e.strokeText(a,n,o,l),r.filled&&(t&&i&&(e.shadowBlur=0),e.fillText(a,n,o,l),t&&i&&(e.shadowBlur=t))}function Se(e,a,r,t){var i=t.textAlign,n=t.color,o=!!n,l=t.font,s=a.length,u=t.textStrokeColor,d=t.textStrokeWidth,f=u&&d,y;if(!(!s||!o&&!f))for(r=ke(r,i,l),e.font=l.string,e.textAlign=i,e.textBaseline="middle",e.shadowBlur=t.textShadowBlur,e.shadowColor=t.textShadowColor,o&&(e.fillStyle=n),f&&(e.lineJoin="round",e.lineWidth=d,e.strokeStyle=u),y=0,s=a.length;y<s;++y)Me(e,a[y],{stroked:f,filled:o,w:r.w,x:r.x,y:r.y+r.h*y})}var G=function(e,a,r,t){var i=this;i._config=e,i._index=t,i._model=null,i._rects=null,i._ctx=a,i._el=r};w(G.prototype,{_modelize:function(e,a,r,t){var i=this,n=i._index,o=Z(v([r.font,{}],t,n)),l=v([r.color,Q.color],t,n);return{align:v([r.align,"center"],t,n),anchor:v([r.anchor,"center"],t,n),area:t.chart.chartArea,backgroundColor:v([r.backgroundColor,null],t,n),borderColor:v([r.borderColor,null],t,n),borderRadius:v([r.borderRadius,0],t,n),borderWidth:v([r.borderWidth,0],t,n),clamp:v([r.clamp,!1],t,n),clip:v([r.clip,!1],t,n),color:l,display:e,font:o,lines:a,offset:v([r.offset,4],t,n),opacity:v([r.opacity,1],t,n),origin:pe(i._el,t),padding:ee(v([r.padding,4],t,n)),positioner:ge(i._el),rotation:v([r.rotation,0],t,n)*(Math.PI/180),size:g.textSize(i._ctx,a,o),textAlign:v([r.textAlign,"start"],t,n),textShadowBlur:v([r.textShadowBlur,0],t,n),textShadowColor:v([r.textShadowColor,l],t,n),textStrokeColor:v([r.textStrokeColor,l],t,n),textStrokeWidth:v([r.textStrokeWidth,0],t,n)}},update:function(e){var a=this,r=null,t=null,i=a._index,n=a._config,o,l,s,u=v([n.display,!0],e,i);u&&(o=e.dataset.data[i],l=Y(W(n.formatter,[o,e]),o),s=p(l)?[]:g.toTextLines(l),s.length&&(r=a._modelize(u,s,n,e),t=_e(r))),a._model=r,a._rects=t},geometry:function(){return this._rects?this._rects.frame:{}},rotation:function(){return this._model?this._model.rotation:0},visible:function(){return this._model&&this._model.opacity},model:function(){return this._model},draw:function(e,a){var r=this,t=e.ctx,i=r._model,n=r._rects,o;this.visible()&&(t.save(),i.clip&&(o=i.area,t.beginPath(),t.rect(o.left,o.top,o.right-o.left,o.bottom-o.top),t.clip()),t.globalAlpha=g.bound(0,i.opacity,1),t.translate(c(a.x),c(a.y)),t.rotate(i.rotation),we(t,n.frame,i),Se(t,i.lines,n.text,i),t.restore())}});var Ce=Number.MIN_SAFE_INTEGER||-9007199254740991,Ee=Number.MAX_SAFE_INTEGER||9007199254740991;function _(e,a,r){var t=Math.cos(r),i=Math.sin(r),n=a.x,o=a.y;return{x:n+t*(e.x-n)-i*(e.y-o),y:o+i*(e.x-n)+t*(e.y-o)}}function B(e,a){var r=Ee,t=Ce,i=a.origin,n,o,l,s,u;for(n=0;n<e.length;++n)o=e[n],l=o.x-i.x,s=o.y-i.y,u=a.vx*l+a.vy*s,r=Math.min(r,u),t=Math.max(t,u);return{min:r,max:t}}function E(e,a){var r=a.x-e.x,t=a.y-e.y,i=Math.sqrt(r*r+t*t);return{vx:(a.x-e.x)/i,vy:(a.y-e.y)/i,origin:e,ln:i}}var U=function(){this._rotation=0,this._rect={x:0,y:0,w:0,h:0}};w(U.prototype,{center:function(){var e=this._rect;return{x:e.x+e.w/2,y:e.y+e.h/2}},update:function(e,a,r){this._rotation=r,this._rect={x:a.x+e.x,y:a.y+e.y,w:a.w,h:a.h}},contains:function(e){var a=this,r=1,t=a._rect;return e=_(e,a.center(),-a._rotation),!(e.x<t.x-r||e.y<t.y-r||e.x>t.x+t.w+r*2||e.y>t.y+t.h+r*2)},intersects:function(e){var a=this._points(),r=e._points(),t=[E(a[0],a[1]),E(a[0],a[3])],i,n,o;for(this._rotation!==e._rotation&&t.push(E(r[0],r[1]),E(r[0],r[3])),i=0;i<t.length;++i)if(n=B(a,t[i]),o=B(r,t[i]),n.max<o.min||o.max<n.min)return!1;return!0},_points:function(){var e=this,a=e._rect,r=e._rotation,t=e.center();return[_({x:a.x,y:a.y},t,r),_({x:a.x+a.w,y:a.y},t,r),_({x:a.x+a.w,y:a.y+a.h},t,r),_({x:a.x,y:a.y+a.h},t,r)]}});function X(e,a,r){var t=a.positioner(e,a),i=t.vx,n=t.vy;if(!i&&!n)return{x:t.x,y:t.y};var o=r.w,l=r.h,s=a.rotation,u=Math.abs(o/2*Math.cos(s))+Math.abs(l/2*Math.sin(s)),d=Math.abs(o/2*Math.sin(s))+Math.abs(l/2*Math.cos(s)),f=1/Math.max(Math.abs(i),Math.abs(n));return u*=i*f,d*=n*f,u+=a.offset*i,d+=a.offset*n,{x:t.x+u,y:t.y+d}}function Pe(e,a){var r,t,i,n;for(r=e.length-1;r>=0;--r)for(i=e[r].$layout,t=r-1;t>=0&&i._visible;--t)n=e[t].$layout,n._visible&&i._box.intersects(n._box)&&a(i,n);return e}function Ie(e){var a,r,t,i,n,o,l;for(a=0,r=e.length;a<r;++a)t=e[a],i=t.$layout,i._visible&&(l=new Proxy(t._el,{get:(s,u)=>s.getProps([u],!0)[u]}),n=t.geometry(),o=X(l,t.model(),n),i._box.update(o,n,t.rotation()));return Pe(e,function(s,u){var d=s._hidable,f=u._hidable;d&&f||f?u._visible=!1:d&&(s._visible=!1)})}var m={prepare:function(e){var a=[],r,t,i,n,o;for(r=0,i=e.length;r<i;++r)for(t=0,n=e[r].length;t<n;++t)o=e[r][t],a.push(o),o.$layout={_box:new U,_hidable:!1,_visible:!0,_set:r,_idx:o._index};return a.sort(function(l,s){var u=l.$layout,d=s.$layout;return u._idx===d._idx?d._set-u._set:d._idx-u._idx}),this.update(a),a},update:function(e){var a=!1,r,t,i,n,o;for(r=0,t=e.length;r<t;++r)i=e[r],n=i.model(),o=i.$layout,o._hidable=n&&n.display==="auto",o._visible=i.visible(),a|=o._hidable;a&&Ie(e)},lookup:function(e,a){var r,t;for(r=e.length-1;r>=0;--r)if(t=e[r].$layout,t&&t._visible&&t._box.contains(a))return e[r];return null},draw:function(e,a){var r,t,i,n,o,l;for(r=0,t=a.length;r<t;++r)i=a[r],n=i.$layout,n._visible&&(o=i.geometry(),l=X(i._el,i.model(),o),n._box.update(l,o,i.rotation()),i.draw(e,l))}},Ae=function(e){if(p(e))return null;var a=e,r,t,i;if(K(e))if(!p(e.label))a=e.label;else if(!p(e.r))a=e.r;else for(a="",r=Object.keys(e),i=0,t=r.length;i<t;++i)a+=(i!==0?", ":"")+r[i]+": "+e[r[i]];return""+a},Re={align:"center",anchor:"center",backgroundColor:null,borderColor:null,borderRadius:0,borderWidth:0,clamp:!1,clip:!1,color:void 0,display:!0,font:{family:void 0,lineHeight:1.2,size:void 0,style:void 0,weight:null},formatter:Ae,labels:void 0,listeners:{},offset:4,opacity:1,padding:{top:4,right:4,bottom:4,left:4},rotation:0,textAlign:"start",textStrokeColor:void 0,textStrokeWidth:0,textShadowBlur:0,textShadowColor:void 0},h="$datalabels",q="$default";function ze(e,a){var r=e.datalabels,t={},i=[],n,o;return r===!1?null:(r===!0&&(r={}),a=w({},[a,r]),n=a.labels||{},o=Object.keys(n),delete a.labels,o.length?o.forEach(function(l){n[l]&&i.push(w({},[a,n[l],{_key:l}]))}):i.push(a),t=i.reduce(function(l,s){return V(s.listeners||{},function(u,d){l[d]=l[d]||{},l[d][s._key||q]=u}),delete s.listeners,l},{}),{labels:i,listeners:t})}function R(e,a,r,t){if(a){var i=r.$context,n=r.$groups,o;a[n._set]&&(o=a[n._set][n._key],o&&W(o,[i,t])===!0&&(e[h]._dirty=!0,r.update(i)))}}function Te(e,a,r,t,i){var n,o;!r&&!t||(r?t?r!==t&&(o=n=!0):o=!0:n=!0,o&&R(e,a.leave,r,i),n&&R(e,a.enter,t,i))}function $e(e,a){var r=e[h],t=r._listeners,i,n;if(!(!t.enter&&!t.leave)){if(a.type==="mousemove")n=m.lookup(r._labels,a);else if(a.type!=="mouseout")return;i=r._hovered,r._hovered=n,Te(e,t,i,n,a)}}function je(e,a){var r=e[h],t=r._listeners.click,i=t&&m.lookup(r._labels,a);i&&R(e,t,i,a)}var Be={id:"datalabels",defaults:Re,beforeInit:function(e){e[h]={_actives:[]}},beforeUpdate:function(e){var a=e[h];a._listened=!1,a._listeners={},a._datasets=[],a._labels=[]},afterDatasetUpdate:function(e,a,r){var t=a.index,i=e[h],n=i._datasets[t]=[],o=e.isDatasetVisible(t),l=e.data.datasets[t],s=ze(l,r),u=a.meta.data||[],d=e.ctx,f,y,z,T,P,$,b,x;for(d.save(),f=0,z=u.length;f<z;++f)if(b=u[f],b[h]=[],o&&b&&e.getDataVisibility(f)&&!b.skip)for(y=0,T=s.labels.length;y<T;++y)P=s.labels[y],$=P._key,x=new G(P,d,b,f),x.$groups={_set:t,_key:$||q},x.$context={active:!1,chart:e,dataIndex:f,dataset:l,datasetIndex:t},x.update(x.$context),b[h].push(x),n.push(x);d.restore(),w(i._listeners,s.listeners,{merger:function(k,I,J){I[k]=I[k]||{},I[k][a.index]=J[k],i._listened=!0}})},afterUpdate:function(e){e[h]._labels=m.prepare(e[h]._datasets)},afterDatasetsDraw:function(e){m.draw(e,e[h]._labels)},beforeEvent:function(e,a){if(e[h]._listened){var r=a.event;switch(r.type){case"mousemove":case"mouseout":$e(e,r);break;case"click":je(e,r);break}}},afterEvent:function(e){var a=e[h],r=a._actives,t=a._actives=e.getActiveElements(),i=g.arrayDiff(r,t),n,o,l,s,u,d,f;for(n=0,o=i.length;n<o;++n)if(u=i[n],u[1])for(f=u[0].element[h]||[],l=0,s=f.length;l<s;++l)d=f[l],d.$context.active=u[1]===1,d.update(d.$context);(a._dirty||i.length)&&(m.update(a._labels),e.render()),delete a._dirty}};const We=e=>({plugins:{legend:{position:"right",maxWidth:150,align:"start",labels:{color:e.palette.text.secondary,usePointStyle:!0,padding:21,boxHeight:8,font:{size:10}}},datalabels:{color:e.palette.text.primary,font:{weight:"bold",size:10},anchor:"end",align:"top",offset:-6}},responsive:!0,maintainAspectRatio:!1,color:e.palette.text.secondary,scales:{y:{beginAtZero:!0,grid:{color:e.palette.divider,borderColor:e.palette.divider,drawBorder:!1},ticks:{stepSize:1,color:e.palette.text.disabled,font:{size:10}}},x:{grid:{display:!1},ticks:{color:e.palette.text.primary,font:{size:10}}}}});function De(e){return le.all(e.filter(a=>a))}const Ne=({data:e,ariaLabel:a,ariaDescription:r,overrideOptions:t})=>{const i=te(),{locationSettings:n}=ae(),o=ie.useMemo(()=>De([We(i)]),[i,n,t]);return ne.jsx(oe,{options:o,data:e,"aria-label":a,"aria-description":r,plugins:[Be]})};se.register(ue,de,D,O,fe,ve,he,ye);export{We as createOptions,Ne as default};