nsthorat's picture
Push
e4f9cbe
raw
history blame
14.8 kB
import{S as X,i as Z,s as ee,E as te,a2 as G,a3 as Q,m as w,h as v,n as y,a4 as ae,b as M,J as b,O as $e,$ as U,D as se,F as re,q as x,r as B,u as H,w as ke,U as we,k as T,y as V,a as L,l as D,z,c as j,A as O,V as Ee,g as C,v as Y,f as J,d as S,B as R,a0 as ge,C as Ce,K as le,R as W,e as oe,a5 as ye,H as ie,a6 as Se}from"../chunks/index.224851d7.js";import{g as Te}from"../chunks/navigation.6c9a524e.js";import{T as De,a as Ie,e as Ne,C as Ae,q as xe,d as Be,b as Me,t as Pe,c as Ve,f as ze,g as Oe}from"../chunks/Commands.7700196d.js";import{T as ve}from"../chunks/TrashCan.e59ed4ef.js";import{T as Re}from"../chunks/JSONSchemaForm.cab38fde.js";import{u as Le}from"../chunks/urlHashStore.b3058edb.js";import{c as ne,S as be}from"../chunks/utils.2fa053fd.js";import{I as ce}from"../chunks/InProgress.26146721.js";import{M as je}from"../chunks/Modal.67c6d9e8.js";function fe(a){let e,n;return{c(){e=G("title"),n=x(a[1])},l(t){e=Q(t,"title",{});var l=w(e);n=B(l,a[1]),l.forEach(v)},m(t,l){M(t,e,l),b(e,n)},p(t,l){l&2&&H(n,t[1])},d(t){t&&v(e)}}}function qe(a){let e,n,t,l=a[1]&&fe(a),m=[{xmlns:"http://www.w3.org/2000/svg"},{viewBox:"0 0 32 32"},{fill:"currentColor"},{preserveAspectRatio:"xMidYMid meet"},{width:a[0]},{height:a[0]},a[2],a[3]],d={};for(let c=0;c<m.length;c+=1)d=te(d,m[c]);return{c(){e=G("svg"),l&&l.c(),n=G("path"),t=G("path"),this.h()},l(c){e=Q(c,"svg",{xmlns:!0,viewBox:!0,fill:!0,preserveAspectRatio:!0,width:!0,height:!0});var f=w(e);l&&l.l(f),n=Q(f,"path",{d:!0}),w(n).forEach(v),t=Q(f,"path",{d:!0}),w(t).forEach(v),f.forEach(v),this.h()},h(){y(n,"d","M16,4c6.6,0,12,5.4,12,12s-5.4,12-12,12S4,22.6,4,16S9.4,4,16,4 M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14 S23.7,2,16,2z"),y(t,"d","M24 15L17 15 17 8 15 8 15 15 8 15 8 17 15 17 15 24 17 24 17 17 24 17z"),ae(e,d)},m(c,f){M(c,e,f),l&&l.m(e,null),b(e,n),b(e,t)},p(c,[f]){c[1]?l?l.p(c,f):(l=fe(c),l.c(),l.m(e,n)):l&&(l.d(1),l=null),ae(e,d=$e(m,[{xmlns:"http://www.w3.org/2000/svg"},{viewBox:"0 0 32 32"},{fill:"currentColor"},{preserveAspectRatio:"xMidYMid meet"},f&1&&{width:c[0]},f&1&&{height:c[0]},f&4&&c[2],f&8&&c[3]]))},i:U,o:U,d(c){c&&v(e),l&&l.d()}}}function He(a,e,n){let t,l;const m=["size","title"];let d=se(e,m),{size:c=16}=e,{title:f=void 0}=e;return a.$$set=i=>{n(5,e=te(te({},e),re(i))),n(3,d=se(e,m)),"size"in i&&n(0,c=i.size),"title"in i&&n(1,f=i.title)},a.$$.update=()=>{n(4,t=e["aria-label"]||e["aria-labelledby"]||f),n(2,l={"aria-hidden":t?void 0:!0,role:t?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})},e=re(e),[c,f,l,d,t]}class Ue extends X{constructor(e){super(),Z(this,e,He,qe,ee,{size:0,title:1})}}function ue(a,e,n){const t=a.slice();return t[6]=e[n],t}function me(a){let e,n,t=a[6].text+"",l,m,d,c,f,i,p,_;c=new ve({props:{size:16}});function r(){return a[5](a[6])}return{c(){e=T("div"),n=T("span"),l=x(t),m=L(),d=T("button"),V(c.$$.fragment),f=L(),this.h()},l(s){e=D(s,"DIV",{class:!0});var o=w(e);n=D(o,"SPAN",{class:!0});var h=w(n);l=B(h,t),h.forEach(v),m=j(o),d=D(o,"BUTTON",{title:!0,class:!0});var I=w(d);z(c.$$.fragment,I),I.forEach(v),f=j(o),o.forEach(v),this.h()},h(){y(n,"class","shrink"),y(d,"title","Remove sample"),y(d,"class","shrink-0 opacity-50 hover:text-red-400 hover:opacity-100"),y(e,"class","flex w-full justify-between gap-x-2 border-b border-gray-200 p-2 hover:bg-gray-50")},m(s,o){M(s,e,o),b(e,n),b(n,l),b(e,m),b(e,d),O(c,d,null),b(e,f),i=!0,p||(_=le(d,"click",r),p=!0)},p(s,o){a=s,(!i||o&1)&&t!==(t=a[6].text+"")&&H(l,t)},i(s){i||(C(c.$$.fragment,s),i=!0)},o(s){S(c.$$.fragment,s),i=!1},d(s){s&&v(e),R(c),p=!1,_()}}}function Fe(a){let e,n,t,l,m,d;function c(r){a[3](r)}let f={labelText:"Add example"};a[1]!==void 0&&(f.value=a[1]),n=new Re({props:f}),ke.push(()=>we(n,"value",c)),n.$on("keydown",a[4]);let i=[...a[0]].reverse(),p=[];for(let r=0;r<i.length;r+=1)p[r]=me(ue(a,i,r));const _=r=>S(p[r],1,1,()=>{p[r]=null});return{c(){e=T("div"),V(n.$$.fragment),l=L(),m=T("div");for(let r=0;r<p.length;r+=1)p[r].c();this.h()},l(r){e=D(r,"DIV",{class:!0});var s=w(e);z(n.$$.fragment,s),s.forEach(v),l=j(r),m=D(r,"DIV",{class:!0});var o=w(m);for(let h=0;h<p.length;h+=1)p[h].l(o);o.forEach(v),this.h()},h(){y(e,"class",""),y(m,"class","flex h-full w-full flex-col overflow-y-auto overflow-x-clip border border-gray-200")},m(r,s){M(r,e,s),O(n,e,null),M(r,l,s),M(r,m,s);for(let o=0;o<p.length;o+=1)p[o]&&p[o].m(m,null);d=!0},p(r,[s]){const o={};if(!t&&s&2&&(t=!0,o.value=r[1],Ee(()=>t=!1)),n.$set(o),s&5){i=[...r[0]].reverse();let h;for(h=0;h<i.length;h+=1){const I=ue(r,i,h);p[h]?(p[h].p(I,s),C(p[h],1)):(p[h]=me(I),p[h].c(),C(p[h],1),p[h].m(m,null))}for(Y(),h=i.length;h<p.length;h+=1)_(h);J()}},i(r){if(!d){C(n.$$.fragment,r);for(let s=0;s<i.length;s+=1)C(p[s]);d=!0}},o(r){S(n.$$.fragment,r),p=p.filter(Boolean);for(let s=0;s<p.length;s+=1)S(p[s]);d=!1},d(r){r&&v(e),R(n),r&&v(l),r&&v(m),ge(p,r)}}}function Ke(a,e,n){let{data:t}=e,l;const m=Ce();function d(i){l=i,n(1,l)}const c=i=>{i.key==="Enter"&&(m("add",l),n(1,l=""))},f=i=>m("remove",i.id);return a.$$set=i=>{"data"in i&&n(0,t=i.data)},[t,l,m,d,c,f]}class pe extends X{constructor(e){super(),Z(this,e,Ke,Fe,ee,{data:0})}}function Ye(a){let e,n,t,l,m,d=a[1].length+"",c,f,i,p,_,r,s,o,h,I=a[0].length+"",q,E,N,$,u;return l=new De({}),p=new pe({props:{data:a[1]}}),p.$on("remove",a[6]),p.$on("add",a[7]),o=new Ie({}),$=new pe({props:{data:a[0]}}),$.$on("remove",a[8]),$.$on("add",a[9]),{c(){e=T("div"),n=T("div"),t=T("span"),V(l.$$.fragment),m=x(" Positive ("),c=x(d),f=x(" examples)"),i=L(),V(p.$$.fragment),_=L(),r=T("div"),s=T("span"),V(o.$$.fragment),h=x("Negative ("),q=x(I),E=x(" examples)"),N=L(),V($.$$.fragment),this.h()},l(g){e=D(g,"DIV",{class:!0});var k=w(e);n=D(k,"DIV",{class:!0});var A=w(n);t=D(A,"SPAN",{class:!0});var P=w(t);z(l.$$.fragment,P),m=B(P," Positive ("),c=B(P,d),f=B(P," examples)"),P.forEach(v),i=j(A),z(p.$$.fragment,A),A.forEach(v),_=j(k),r=D(k,"DIV",{class:!0});var F=w(r);s=D(F,"SPAN",{class:!0});var K=w(s);z(o.$$.fragment,K),h=B(K,"Negative ("),q=B(K,I),E=B(K," examples)"),K.forEach(v),N=j(F),z($.$$.fragment,F),F.forEach(v),k.forEach(v),this.h()},h(){y(t,"class","flex items-center gap-x-2 text-lg"),y(n,"class","flex w-1/2 flex-col gap-y-4"),y(s,"class","flex items-center gap-x-2 text-lg"),y(r,"class","flex w-1/2 flex-col gap-y-4"),y(e,"class","flex h-full gap-x-4")},m(g,k){M(g,e,k),b(e,n),b(n,t),O(l,t,null),b(t,m),b(t,c),b(t,f),b(n,i),O(p,n,null),b(e,_),b(e,r),b(r,s),O(o,s,null),b(s,h),b(s,q),b(s,E),b(r,N),O($,r,null),u=!0},p(g,[k]){(!u||k&2)&&d!==(d=g[1].length+"")&&H(c,d);const A={};k&2&&(A.data=g[1]),p.$set(A),(!u||k&1)&&I!==(I=g[0].length+"")&&H(q,I);const P={};k&1&&(P.data=g[0]),$.$set(P)},i(g){u||(C(l.$$.fragment,g),C(p.$$.fragment,g),C(o.$$.fragment,g),C($.$$.fragment,g),u=!0)},o(g){S(l.$$.fragment,g),S(p.$$.fragment,g),S(o.$$.fragment,g),S($.$$.fragment,g),u=!1},d(g){g&&v(e),R(l),R(p),R(o),R($)}}}function Je(a,e,n){let t,l,m,{concept:d}=e;const c=Ne();W(a,c,o=>n(10,m=o));function f(o){!d.namespace||!d.concept_name||m.mutate([d.namespace,d.concept_name,{remove:[o]}])}function i(o,h){!d.namespace||!d.concept_name||m.mutate([d.namespace,d.concept_name,{insert:[{text:o,label:h}]}])}const p=o=>f(o.detail),_=o=>i(o.detail,!0),r=o=>f(o.detail),s=o=>i(o.detail,!1);return a.$$set=o=>{"concept"in o&&n(5,d=o.concept)},a.$$.update=()=>{a.$$.dirty&32&&n(1,t=Object.values(d.data).filter(o=>o.label==!0)),a.$$.dirty&32&&n(0,l=Object.values(d.data).filter(o=>o.label==!1))},[l,t,c,f,i,d,p,_,r,s]}class Ge extends X{constructor(e){super(),Z(this,e,Je,Ye,ee,{concept:5})}}function de(a,e,n){const t=a.slice();return t[16]=e[n],t}function Qe(a){let e,n,t,l,m,d,c,f=a[4].data,i=[];for(let _=0;_<f.length;_+=1)i[_]=_e(de(a,f,_));const p=_=>S(i[_],1,1,()=>{i[_]=null});return t=new Ue({}),{c(){for(let _=0;_<i.length;_+=1)i[_].c();e=L(),n=T("button"),V(t.$$.fragment),l=x(" Add Concept"),this.h()},l(_){for(let s=0;s<i.length;s+=1)i[s].l(_);e=j(_),n=D(_,"BUTTON",{class:!0});var r=w(n);z(t.$$.fragment,r),l=B(r," Add Concept"),r.forEach(v),this.h()},h(){y(n,"class","mt-4 flex w-full items-center gap-x-1 px-4 py-2 text-left text-sm text-gray-500 hover:text-blue-500")},m(_,r){for(let s=0;s<i.length;s+=1)i[s]&&i[s].m(_,r);M(_,e,r),M(_,n,r),O(t,n,null),b(n,l),m=!0,d||(c=le(n,"click",a[12]),d=!0)},p(_,r){if(r&19){f=_[4].data;let s;for(s=0;s<f.length;s+=1){const o=de(_,f,s);i[s]?(i[s].p(o,r),C(i[s],1)):(i[s]=_e(o),i[s].c(),C(i[s],1),i[s].m(e.parentNode,e))}for(Y(),s=f.length;s<i.length;s+=1)p(s);J()}},i(_){if(!m){for(let r=0;r<f.length;r+=1)C(i[r]);C(t.$$.fragment,_),m=!0}},o(_){i=i.filter(Boolean);for(let r=0;r<i.length;r+=1)S(i[r]);S(t.$$.fragment,_),m=!1},d(_){ge(i,_),_&&v(e),_&&v(n),R(t),d=!1,c()}}}function We(a){let e,n;return e=new be({}),{c(){V(e.$$.fragment)},l(t){z(e.$$.fragment,t)},m(t,l){O(e,t,l),n=!0},p:U,i(t){n||(C(e.$$.fragment,t),n=!0)},o(t){S(e.$$.fragment,t),n=!1},d(t){R(e,t)}}}function _e(a){let e,n,t,l=a[16].namespace+"",m,d,c,f=a[16].name+"",i,p,_,r,s,o,h,I;s=new ve({props:{size:16}});function q(){return a[11](a[16])}return{c(){e=T("div"),n=T("a"),t=T("span"),m=x(l),d=x(" / "),c=T("span"),i=x(f),_=L(),r=T("button"),V(s.$$.fragment),this.h()},l(E){e=D(E,"DIV",{class:!0});var N=w(e);n=D(N,"A",{href:!0,class:!0});var $=w(n);t=D($,"SPAN",{class:!0});var u=w(t);m=B(u,l),d=B(u," / "),u.forEach(v),c=D($,"SPAN",{});var g=w(c);i=B(g,f),g.forEach(v),$.forEach(v),_=j(N),r=D(N,"BUTTON",{title:!0,class:!0});var k=w(r);z(s.$$.fragment,k),k.forEach(v),N.forEach(v),this.h()},h(){y(t,"class","opacity-50"),y(n,"href",p=ne(a[16].namespace,a[16].name)),y(n,"class","flex w-full flex-row items-center whitespace-pre px-4 py-2"),y(r,"title","Remove concept"),y(r,"class","p-3 opacity-50 hover:text-red-400 hover:opacity-100"),y(e,"class","flex justify-between border-b border-gray-200 hover:bg-gray-100"),ie(e,"bg-blue-100",a[16].name===a[0])},m(E,N){M(E,e,N),b(e,n),b(n,t),b(t,m),b(t,d),b(n,c),b(c,i),b(e,_),b(e,r),O(s,r,null),o=!0,h||(I=le(r,"click",q),h=!0)},p(E,N){a=E,(!o||N&16)&&l!==(l=a[16].namespace+"")&&H(m,l),(!o||N&16)&&f!==(f=a[16].name+"")&&H(i,f),(!o||N&16&&p!==(p=ne(a[16].namespace,a[16].name)))&&y(n,"href",p),(!o||N&17)&&ie(e,"bg-blue-100",a[16].name===a[0])},i(E){o||(C(s.$$.fragment,E),o=!0)},o(E){S(s.$$.fragment,E),o=!1},d(E){E&&v(e),R(s),h=!1,I()}}}function Xe(a){let e,n;return e=new Ge({props:{concept:a[5].data}}),{c(){V(e.$$.fragment)},l(t){z(e.$$.fragment,t)},m(t,l){O(e,t,l),n=!0},p(t,l){const m={};l&32&&(m.concept=t[5].data),e.$set(m)},i(t){n||(C(e.$$.fragment,t),n=!0)},o(t){S(e.$$.fragment,t),n=!1},d(t){R(e,t)}}}function Ze(a){let e,n=a[5].error.message+"",t;return{c(){e=T("p"),t=x(n)},l(l){e=D(l,"P",{});var m=w(e);t=B(m,n),m.forEach(v)},m(l,m){M(l,e,m),b(e,t)},p(l,m){m&32&&n!==(n=l[5].error.message+"")&&H(t,n)},i:U,o:U,d(l){l&&v(e)}}}function et(a){let e,n;return e=new be({}),{c(){V(e.$$.fragment)},l(t){z(e.$$.fragment,t)},m(t,l){O(e,t,l),n=!0},p:U,i(t){n||(C(e.$$.fragment,t),n=!0)},o(t){S(e.$$.fragment,t),n=!1},d(t){R(e,t)}}}function he(a){let e,n;return e=new je({props:{danger:!0,open:!0,modalHeading:"Delete concept",primaryButtonText:"Delete",primaryButtonIcon:a[3].isLoading?ce:void 0,secondaryButtonText:"Cancel",$$slots:{default:[tt]},$$scope:{ctx:a}}}),e.$on("click:button--secondary",a[13]),e.$on("close",a[14]),e.$on("submit",a[15]),{c(){V(e.$$.fragment)},l(t){z(e.$$.fragment,t)},m(t,l){O(e,t,l),n=!0},p(t,l){const m={};l&8&&(m.primaryButtonIcon=t[3].isLoading?ce:void 0),l&524290&&(m.$$scope={dirty:l,ctx:t}),e.$set(m)},i(t){n||(C(e.$$.fragment,t),n=!0)},o(t){S(e.$$.fragment,t),n=!1},d(t){R(e,t)}}}function tt(a){let e,n,t,l=a[1].namespace+"",m,d,c=a[1].name+"",f,i,p,_,r;return{c(){e=T("p"),n=x("Confirm deleting "),t=T("code"),m=x(l),d=x("/"),f=x(c),i=x(" ?"),p=L(),_=T("p"),r=x("This is a permanent action and cannot be undone."),this.h()},l(s){e=D(s,"P",{class:!0});var o=w(e);n=B(o,"Confirm deleting "),t=D(o,"CODE",{});var h=w(t);m=B(h,l),d=B(h,"/"),f=B(h,c),h.forEach(v),i=B(o," ?"),o.forEach(v),p=j(s),_=D(s,"P",{class:!0});var I=w(_);r=B(I,"This is a permanent action and cannot be undone."),I.forEach(v),this.h()},h(){y(e,"class","!text-lg"),y(_,"class","mt-2")},m(s,o){M(s,e,o),b(e,n),b(e,t),b(t,m),b(t,d),b(t,f),b(e,i),M(s,p,o),M(s,_,o),b(_,r)},p(s,o){o&2&&l!==(l=s[1].namespace+"")&&H(m,l),o&2&&c!==(c=s[1].name+"")&&H(f,c)},d(s){s&&v(e),s&&v(p),s&&v(_)}}}function nt(a){let e,n,t,l,m,d,c,f,i,p,_,r,s;const o=[We,Qe],h=[];function I(u,g){return u[4].isLoading?0:u[4].isSuccess?1:-1}~(t=I(a))&&(l=h[t]=o[t](a));const q=[et,Ze,Xe],E=[];function N(u,g){var k,A,P;return(k=u[5])!=null&&k.isLoading?0:(A=u[5])!=null&&A.isError?1:(P=u[5])!=null&&P.isSuccess?2:-1}~(c=N(a))&&(f=E[c]=q[c](a)),p=new Ae({});let $=a[1]&&he(a);return{c(){e=T("div"),n=T("div"),l&&l.c(),m=L(),d=T("div"),f&&f.c(),i=L(),V(p.$$.fragment),_=L(),$&&$.c(),r=oe(),this.h()},l(u){e=D(u,"DIV",{class:!0});var g=w(e);n=D(g,"DIV",{class:!0});var k=w(n);l&&l.l(k),k.forEach(v),m=j(g),d=D(g,"DIV",{class:!0});var A=w(d);f&&f.l(A),A.forEach(v),g.forEach(v),i=j(u),z(p.$$.fragment,u),_=j(u),$&&$.l(u),r=oe(),this.h()},h(){y(n,"class","flex h-full w-72 flex-col border-r border-gray-200"),y(d,"class","h-full w-full p-4"),y(e,"class","flex h-full w-full")},m(u,g){M(u,e,g),b(e,n),~t&&h[t].m(n,null),b(e,m),b(e,d),~c&&E[c].m(d,null),M(u,i,g),O(p,u,g),M(u,_,g),$&&$.m(u,g),M(u,r,g),s=!0},p(u,[g]){let k=t;t=I(u),t===k?~t&&h[t].p(u,g):(l&&(Y(),S(h[k],1,1,()=>{h[k]=null}),J()),~t?(l=h[t],l?l.p(u,g):(l=h[t]=o[t](u),l.c()),C(l,1),l.m(n,null)):l=null);let A=c;c=N(u),c===A?~c&&E[c].p(u,g):(f&&(Y(),S(E[A],1,1,()=>{E[A]=null}),J()),~c?(f=E[c],f?f.p(u,g):(f=E[c]=q[c](u),f.c()),C(f,1),f.m(d,null)):f=null),u[1]?$?($.p(u,g),g&2&&C($,1)):($=he(u),$.c(),C($,1),$.m(r.parentNode,r)):$&&(Y(),S($,1,1,()=>{$=null}),J())},i(u){s||(C(l),C(f),C(p.$$.fragment,u),C($),s=!0)},o(u){S(l),S(f),S(p.$$.fragment,u),S($),s=!1},d(u){u&&v(e),~t&&h[t].d(),~c&&E[c].d(),u&&v(i),R(p,u),u&&v(_),$&&$.d(u),u&&v(r)}}}function lt(a,e,n){let t,l,m,d,c,f=U,i=()=>(f(),f=ye(t,u=>n(5,c=u)),t);W(a,Le,u=>n(10,m=u)),a.$$.on_destroy.push(()=>f());let p,_,r=null;const s=xe();W(a,s,u=>n(4,d=u));const o=Be();W(a,o,u=>n(3,l=u));function h(){if(r==null)return;const{namespace:u,name:g}=r;l.mutate([u,g],{onSuccess:()=>{var k;for(const[A,P]of Object.entries(ze)){const F=(k=Se(Oe[A]).selectRowsSchema)==null?void 0:k.data;P.deleteConcept(u,g,F)}n(1,r=null)}})}const I=u=>n(1,r={namespace:u.namespace,name:u.name}),q=()=>Pe({command:Ve.CreateConcept,onCreate:u=>Te(ne(u.detail.namespace,u.detail.name))}),E=()=>n(1,r=null),N=()=>n(1,r=null),$=()=>h();return a.$$.update=()=>{a.$$.dirty&1024&&m.onHashChange("/(?<namespace>.+)/(?<conceptName>.+)",u=>{n(9,p=u.namespace),n(0,_=u.conceptName)}),a.$$.dirty&513&&i(n(2,t=p&&_?Me(p,_):void 0))},[_,r,t,l,d,c,s,o,h,p,m,I,q,E,N,$]}class pt extends X{constructor(e){super(),Z(this,e,lt,nt,ee,{})}}export{pt as component};