import{S as z,i as L,s as W,e as _,a as c,b as d,q as H,j as g,a4 as T,f as v,m as k,g as h,h as y,o as C,u as F,v as G,x as J,y as K,z as P,C as Q}from"./index.bbdd6a1e.js";function j(i,e){return Math.floor(Math.random()*(e-i)+i)}const U=(i,e=1)=>{let n=[[255,99,132],[54,162,235],[240,176,26],[153,102,255],[75,192,192],[255,159,64],[194,88,74],[44,102,219],[44,163,23],[191,46,217],[160,162,162],[163,151,27]];if(i<n.length)var l=n[i];else var l=[j(64,196),j(64,196),j(64,196)];return"rgba("+l[0]+", "+l[1]+", "+l[2]+", "+e+")"};function M(i,e,n){const l=i.slice();return l[8]=e[n][0],l[15]=e[n][1],l}function N(i,e,n){const l=i.slice();return l[8]=e[n][0],l[9]=e[n][1],l}function O(i,e,n){const l=i.slice();return l[9]=e[n][0],l[12]=e[n][1],l[14]=n,l}function V(i){let e,n,l=i[3]&&S(),a=i[1],o=[];for(let t=0;t<a.length;t+=1)o[t]=q(M(i,a,t));return{c(){l&&l.c(),e=k(),n=_("div");for(let t=0;t<o.length;t+=1)o[t].c();c(n,"class","textfield p-2 bg-white dark:bg-gray-800 rounded box-border max-w-full break-word")},m(t,s){l&&l.m(t,s),d(t,e,s),d(t,n,s);for(let r=0;r<o.length;r+=1)o[r].m(n,null)},p(t,s){if(t[3]?l||(l=S(),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null),s&2){a=t[1];let r;for(r=0;r<a.length;r+=1){const f=M(t,a,r);o[r]?o[r].p(f,s):(o[r]=q(f),o[r].c(),o[r].m(n,null))}for(;r<o.length;r+=1)o[r].d(1);o.length=a.length}},d(t){l&&l.d(t),t&&g(e),t&&g(n),C(o,t)}}}function X(i){let e,n,l=i[3]&&D(i),a=i[1],o=[];for(let t=0;t<a.length;t+=1)o[t]=R(N(i,a,t));return{c(){l&&l.c(),e=k(),n=_("div");for(let t=0;t<o.length;t+=1)o[t].c();c(n,"class","textfield bg-white dark:bg-gray-800 rounded box-border max-w-full break-word inline-flex flex-wrap gap-1")},m(t,s){l&&l.m(t,s),d(t,e,s),d(t,n,s);for(let r=0;r<o.length;r+=1)o[r].m(n,null)},p(t,s){if(t[3]?l?l.p(t,s):(l=D(t),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null),s&11){a=t[1];let r;for(r=0;r<a.length;r+=1){const f=N(t,a,r);o[r]?o[r].p(f,s):(o[r]=R(f),o[r].c(),o[r].m(n,null))}for(;r<o.length;r+=1)o[r].d(1);o.length=a.length}},d(t){l&&l.d(t),t&&g(e),t&&g(n),C(o,t)}}}function S(i){let e;return{c(){e=_("div"),e.innerHTML=`<span>-1</span> 
				<span>0</span> 
				<span>+1</span>`,c(e,"class","color_legend flex px-2 py-1 justify-between rounded mb-3 font-semibold"),T(e,"background","-webkit-linear-gradient(to right,#8d83d6,(255,255,255,0),#eb4d4b)"),T(e,"background","linear-gradient(to right,#8d83d6,rgba(255,255,255,0),#eb4d4b)")},m(n,l){d(n,e,l)},d(n){n&&g(e)}}}function q(i){let e,n,l=i[8]+"",a,o,t;return{c(){e=_("span"),n=_("span"),a=v(l),o=k(),c(n,"class","text dark:text-white"),c(e,"class","textspan p-1 mr-0.5 bg-opacity-20 dark:bg-opacity-80 rounded-sm"),c(e,"style",t="background-color: rgba("+(i[15]<0?"141, 131, 214,"+-i[15]:"235, 77, 75,"+i[15])+")")},m(s,r){d(s,e,r),h(e,n),h(n,a),h(e,o)},p(s,r){r&2&&l!==(l=s[8]+"")&&y(a,l),r&2&&t!==(t="background-color: rgba("+(s[15]<0?"141, 131, 214,"+-s[15]:"235, 77, 75,"+s[15])+")")&&c(e,"style",t)},d(s){s&&g(e)}}}function D(i){let e,n=Object.entries(i[0]),l=[];for(let a=0;a<n.length;a+=1)l[a]=E(O(i,n,a));return{c(){e=_("div");for(let a=0;a<l.length;a+=1)l[a].c();c(e,"class","category-legend flex flex-wrap gap-1 mb-2")},m(a,o){d(a,e,o);for(let t=0;t<l.length;t+=1)l[t].m(e,null)},p(a,o){if(o&1){n=Object.entries(a[0]);let t;for(t=0;t<n.length;t+=1){const s=O(a,n,t);l[t]?l[t].p(s,o):(l[t]=E(s),l[t].c(),l[t].m(e,null))}for(;t<l.length;t+=1)l[t].d(1);l.length=n.length}},d(a){a&&g(e),C(l,a)}}}function E(i){let e,n=i[9]+"",l,a,o;return{c(){e=_("div"),l=v(n),a=k(),c(e,"class","category-label px-2 rounded text-white font-semibold"),c(e,"style",o="background-color:"+i[12])},m(t,s){d(t,e,s),h(e,l),h(e,a)},p(t,s){s&1&&n!==(n=t[9]+"")&&y(l,n),s&1&&o!==(o="background-color:"+t[12])&&c(e,"style",o)},d(t){t&&g(e)}}}function I(i){let e,n=i[9]+"",l,a;return{c(){e=_("span"),l=v(n),c(e,"class","inline-category text-xs text-white rounded-sm px-1"),c(e,"style",a=i[9]===null?"":`background-color: ${i[0][i[9]]}`)},m(o,t){d(o,e,t),h(e,l)},p(o,t){t&2&&n!==(n=o[9]+"")&&y(l,n),t&3&&a!==(a=o[9]===null?"":`background-color: ${o[0][o[9]]}`)&&c(e,"style",a)},d(o){o&&g(e)}}}function R(i){let e,n,l=i[8]+"",a,o,t,s,r=!i[3]&&i[9]!==null&&I(i);return{c(){e=_("span"),n=_("span"),a=v(l),o=k(),r&&r.c(),t=k(),c(n,"class","text dark:text-white"),c(e,"class","textspan bg-opacity-10 rounded inline-flex items-center px-1.5 space-x-1.5"),c(e,"style",s=i[9]===null?"":`color: ${i[0][i[9]]}; background-color: ${i[0][i[9]].replace("1)","var(--tw-bg-opacity))")}`)},m(f,m){d(f,e,m),h(e,n),h(n,a),h(e,o),r&&r.m(e,null),h(e,t)},p(f,m){m&2&&l!==(l=f[8]+"")&&y(a,l),!f[3]&&f[9]!==null?r?r.p(f,m):(r=I(f),r.c(),r.m(e,t)):r&&(r.d(1),r=null),m&3&&s!==(s=f[9]===null?"":`color: ${f[0][f[9]]}; background-color: ${f[0][f[9]].replace("1)","var(--tw-bg-opacity))")}`)&&c(e,"style",s)},d(f){f&&g(e),r&&r.d()}}}function Y(i){let e;function n(o,t){return o[4]==="categories"?X:V}let l=n(i),a=l(i);return{c(){e=_("div"),a.c(),c(e,"class","border rounded-lg p-2"),c(e,"theme",i[2])},m(o,t){d(o,e,t),a.m(e,null)},p(o,[t]){l===(l=n(o))&&a?a.p(o,t):(a.d(1),a=l(o),a&&(a.c(),a.m(e,null))),t&4&&c(e,"theme",o[2])},i:H,o:H,d(o){o&&g(e),a.d()}}}function Z(i,e,n){let{value:l=[]}=e,{theme:a="default"}=e,{show_legend:o=!1}=e,{color_map:t={}}=e,{style:s=""}=e,r;function f(u){if(!r){var p=document.createElement("canvas");r=p.getContext("2d")}r.fillStyle=u,r.fillRect(0,0,1,1);const[b,w,A,B]=r.getImageData(0,0,1,1).data;return r.clearRect(0,0,1,1),`rgba(${b}, ${w}, ${A}, ${255/B})`}let m;return t===null&&(t={}),i.$$set=u=>{"value"in u&&n(1,l=u.value),"theme"in u&&n(2,a=u.theme),"show_legend"in u&&n(3,o=u.show_legend),"color_map"in u&&n(0,t=u.color_map),"style"in u&&n(5,s=u.style)},i.$$.update=()=>{if(i.$$.dirty&3){let u=function(){for(const p in t)t[p].trim().startsWith("rgba")?(n(0,t),n(1,l)):n(0,t[p]=f(t[p]),t)};if(l.length>0){for(let[p,b]of l)if(b!==null)if(typeof b=="string"){if(n(4,m="categories"),!(b in t)){let w=U(Object.keys(t).length);n(0,t[b]=w,t)}}else n(4,m="scores")}u()}},[t,l,a,o,m,s]}class x extends z{constructor(e){super(),L(this,e,Z,Y,W,{value:1,theme:2,show_legend:3,color_map:0,style:5})}}function $(i){let e,n;return e=new x({props:{value:i[0],style:i[1],show_legend:i[2],color_map:i[3]}}),{c(){F(e.$$.fragment)},m(l,a){G(e,l,a),n=!0},p(l,[a]){const o={};a&1&&(o.value=l[0]),a&2&&(o.style=l[1]),a&4&&(o.show_legend=l[2]),a&8&&(o.color_map=l[3]),e.$set(o)},i(l){n||(J(e.$$.fragment,l),n=!0)},o(l){K(e.$$.fragment,l),n=!1},d(l){P(e,l)}}}function ee(i,e,n){let{value:l}=e,{default_value:a}=e,{style:o=""}=e,{show_legend:t}=e,{color_map:s={}}=e;const r=Q();return a&&(l=a),i.$$set=f=>{"value"in f&&n(0,l=f.value),"default_value"in f&&n(4,a=f.default_value),"style"in f&&n(1,o=f.style),"show_legend"in f&&n(2,t=f.show_legend),"color_map"in f&&n(3,s=f.color_map)},i.$$.update=()=>{i.$$.dirty&1&&r("change")},[l,o,t,s,a]}class le extends z{constructor(e){super(),L(this,e,ee,$,W,{value:0,default_value:4,style:1,show_legend:2,color_map:3})}}var ne=le;const oe=["static"];export{ne as Component,oe as modes};
