File size: 6,893 Bytes
41ddeab
 
1
2
3
import{S as Z,i as A,s as D,w as R,b as d,f as v,g as b,x as H,n as h,B as z,e as g,a as j,t as N,Y as S,h as E,C as K,d as C,P as O,c as L,m as M,j as k,k as p,o as B,F as Q,R as W,T as X,U as x,V as $,D as T,E as Y}from"./index.396f4a72.js";import{B as ee}from"./BlockLabel.37da86a3.js";function le(a){let e,n;return{c(){e=R("svg"),n=R("path"),d(n,"fill","currentColor"),d(n,"d","M4 2H2v26a2 2 0 0 0 2 2h26v-2H4v-3h22v-8H4v-4h14V5H4Zm20 17v4H4v-4ZM16 7v4H4V7Z"),d(e,"xmlns","http://www.w3.org/2000/svg"),d(e,"xmlns:xlink","http://www.w3.org/1999/xlink"),d(e,"aria-hidden","true"),d(e,"role","img"),d(e,"class","iconify iconify--carbon"),d(e,"width","100%"),d(e,"height","100%"),d(e,"preserveAspectRatio","xMidYMid meet"),d(e,"viewBox","0 0 32 32")},m(l,t){v(l,e,t),b(e,n)},p:H,i:H,o:H,d(l){l&&h(e)}}}class G extends Z{constructor(e){super(),A(this,e,null,le,D,{})}}function q(a,e,n){const l=a.slice();return l[3]=e[n],l}function F(a){let e,n=a[0].confidences,l=[];for(let t=0;t<n.length;t+=1)l[t]=P(q(a,n,t));return{c(){for(let t=0;t<l.length;t+=1)l[t].c();e=z()},m(t,o){for(let i=0;i<l.length;i+=1)l[i].m(t,o);v(t,e,o)},p(t,o){if(o&1){n=t[0].confidences;let i;for(i=0;i<n.length;i+=1){const s=q(t,n,i);l[i]?l[i].p(s,o):(l[i]=P(s),l[i].c(),l[i].m(e.parentNode,e))}for(;i<l.length;i+=1)l[i].d(1);l.length=n.length}},d(t){K(l,t),t&&h(e)}}}function I(a){let e,n,l,t=Math.round(a[3].confidence*100)+"",o,i;return{c(){e=g("div"),n=j(),l=g("div"),o=N(t),i=N("%"),d(e,"class","flex-1 border border-dashed border-gray-100 px-4"),d(l,"class","text-right ml-auto")},m(s,c){v(s,e,c),v(s,n,c),v(s,l,c),b(l,o),b(l,i)},p(s,c){c&1&&t!==(t=Math.round(s[3].confidence*100)+"")&&E(o,t)},d(s){s&&h(e),s&&h(n),s&&h(l)}}}function P(a){let e,n,l,t,o,i,s=a[3].label+"",c,w,u,_=a[0].confidences&&I(a);return{c(){e=g("div"),n=g("div"),l=g("div"),t=j(),o=g("div"),i=g("div"),c=N(s),w=j(),_&&_.c(),u=j(),d(l,"class","h-1 mb-1 rounded bg-gradient-to-r group-hover:from-orange-500 from-orange-400 to-orange-200 dark:from-orange-400 dark:to-orange-600"),S(l,"width",a[3].confidence*100+"%"),d(i,"class","leading-snug"),d(o,"class","flex items-baseline space-x-2 group-hover:text-orange-500"),d(n,"class","flex-1"),d(e,"class","flex items-start justify-between font-mono text-sm leading-none group mb-2 last:mb-0 dark:text-slate-300")},m(f,y){v(f,e,y),b(e,n),b(n,l),b(n,t),b(n,o),b(o,i),b(i,c),b(o,w),_&&_.m(o,null),b(e,u)},p(f,y){y&1&&S(l,"width",f[3].confidence*100+"%"),y&1&&s!==(s=f[3].label+"")&&E(c,s),f[0].confidences?_?_.p(f,y):(_=I(f),_.c(),_.m(o,null)):_&&(_.d(1),_=null)},d(f){f&&h(e),_&&_.d()}}}function te(a){let e,n,l=a[0].label+"",t,o,i=typeof a[0]=="object"&&a[0].confidences&&F(a);return{c(){e=g("div"),n=g("div"),t=N(l),o=j(),i&&i.c(),d(n,"class","output-class font-bold text-2xl py-6 px-4 flex-grow flex items-center justify-center dark:text-slate-200"),C(n,"sr-only",!a[1]),C(n,"no-confidence",!("confidences"in a[0])),S(n,"background-color",a[2]||"transparent",!1),d(e,"class","output-label")},m(s,c){v(s,e,c),b(e,n),b(n,t),b(e,o),i&&i.m(e,null)},p(s,[c]){c&1&&l!==(l=s[0].label+"")&&E(t,l),c&2&&C(n,"sr-only",!s[1]),c&1&&C(n,"no-confidence",!("confidences"in s[0])),c&4&&S(n,"background-color",s[2]||"transparent",!1),typeof s[0]=="object"&&s[0].confidences?i?i.p(s,c):(i=F(s),i.c(),i.m(e,null)):i&&(i.d(1),i=null)},i:H,o:H,d(s){s&&h(e),i&&i.d()}}}function ne(a,e,n){let{value:l}=e,{show_label:t}=e,{color:o}=e;return a.$$set=i=>{"value"in i&&n(0,l=i.value),"show_label"in i&&n(1,t=i.show_label),"color"in i&&n(2,o=i.color)},[l,t,o]}class oe extends Z{constructor(e){super(),A(this,e,ne,te,D,{value:0,show_label:1,color:2})}}function U(a){let e,n;return e=new ee({props:{Icon:G,label:a[4],disable:typeof a[5].container=="boolean"&&!a[5].container}}),{c(){L(e.$$.fragment)},m(l,t){M(e,l,t),n=!0},p(l,t){const o={};t&16&&(o.label=l[4]),t&32&&(o.disable=typeof l[5].container=="boolean"&&!l[5].container),e.$set(o)},i(l){n||(k(e.$$.fragment,l),n=!0)},o(l){p(e.$$.fragment,l),n=!1},d(l){B(e,l)}}}function ie(a){let e,n,l,t;return l=new G({}),{c(){e=g("div"),n=g("div"),L(l.$$.fragment),d(n,"class","h-5 dark:text-white opacity-50"),d(e,"class","h-full min-h-[6rem] flex justify-center items-center")},m(o,i){v(o,e,i),b(e,n),M(l,n,null),t=!0},p:H,i(o){t||(k(l.$$.fragment,o),t=!0)},o(o){p(l.$$.fragment,o),t=!1},d(o){o&&h(e),B(l)}}}function ae(a){let e,n;return e=new oe({props:{value:a[3],show_label:a[7],color:a[2]}}),{c(){L(e.$$.fragment)},m(l,t){M(e,l,t),n=!0},p(l,t){const o={};t&8&&(o.value=l[3]),t&128&&(o.show_label=l[7]),t&4&&(o.color=l[2]),e.$set(o)},i(l){n||(k(e.$$.fragment,l),n=!0)},o(l){p(e.$$.fragment,l),n=!1},d(l){B(e,l)}}}function se(a){let e,n,l,t,o,i,s;const c=[a[6]];let w={};for(let r=0;r<c.length;r+=1)w=W(w,c[r]);e=new X({props:w});let u=a[7]&&U(a);const _=[ae,ie],f=[];function y(r,m){return typeof r[3]=="object"&&r[3]!==void 0&&r[3]!==null?0:1}return t=y(a),o=f[t]=_[t](a),{c(){L(e.$$.fragment),n=j(),u&&u.c(),l=j(),o.c(),i=z()},m(r,m){M(e,r,m),v(r,n,m),u&&u.m(r,m),v(r,l,m),f[t].m(r,m),v(r,i,m),s=!0},p(r,m){const J=m&64?x(c,[$(r[6])]):{};e.$set(J),r[7]?u?(u.p(r,m),m&128&&k(u,1)):(u=U(r),u.c(),k(u,1),u.m(l.parentNode,l)):u&&(T(),p(u,1,1,()=>{u=null}),Y());let V=t;t=y(r),t===V?f[t].p(r,m):(T(),p(f[V],1,1,()=>{f[V]=null}),Y(),o=f[t],o?o.p(r,m):(o=f[t]=_[t](r),o.c()),k(o,1),o.m(i.parentNode,i))},i(r){s||(k(e.$$.fragment,r),k(u),k(o),s=!0)},o(r){p(e.$$.fragment,r),p(u),p(o),s=!1},d(r){B(e,r),r&&h(n),u&&u.d(r),r&&h(l),f[t].d(r),r&&h(i)}}}function fe(a){let e,n;return e=new O({props:{test_id:"label",visible:a[1],elem_id:a[0],disable:typeof a[5].container=="boolean"&&!a[5].container,$$slots:{default:[se]},$$scope:{ctx:a}}}),{c(){L(e.$$.fragment)},m(l,t){M(e,l,t),n=!0},p(l,[t]){const o={};t&2&&(o.visible=l[1]),t&1&&(o.elem_id=l[0]),t&32&&(o.disable=typeof l[5].container=="boolean"&&!l[5].container),t&764&&(o.$$scope={dirty:t,ctx:l}),e.$set(o)},i(l){n||(k(e.$$.fragment,l),n=!0)},o(l){p(e.$$.fragment,l),n=!1},d(l){B(e,l)}}}function re(a,e,n){let{elem_id:l=""}=e,{visible:t=!0}=e,{color:o=void 0}=e,{value:i}=e,{label:s="Label"}=e,{style:c={}}=e,{loading_status:w}=e,{show_label:u}=e;const _=Q();return a.$$set=f=>{"elem_id"in f&&n(0,l=f.elem_id),"visible"in f&&n(1,t=f.visible),"color"in f&&n(2,o=f.color),"value"in f&&n(3,i=f.value),"label"in f&&n(4,s=f.label),"style"in f&&n(5,c=f.style),"loading_status"in f&&n(6,w=f.loading_status),"show_label"in f&&n(7,u=f.show_label)},a.$$.update=()=>{a.$$.dirty&8&&_("change")},[l,t,o,i,s,c,w,u]}class ce extends Z{constructor(e){super(),A(this,e,re,fe,D,{elem_id:0,visible:1,color:2,value:3,label:4,style:5,loading_status:6,show_label:7})}}var _e=ce;const be=["static"],me=a=>({type:"{ label: string; confidences?: Array<{ label: string; confidence: number }>",description:"output label and optional set of confidences per label"});export{_e as Component,me as document,be as modes};
//# sourceMappingURL=index.5cfaf6ac.js.map