import{s as Se,r as dt,v as ht,w as mt,x as gt,j as se,l as Le,i as W,d as b,T as _t,U as Qe,V as nn,B as Be,e as O,c as H,a as T,a1 as Pt,X as Ut,u as he,F as At,H as xn,O as qn,$ as le,q as un,a0 as pl,ai as Nr,p as Lt,S as Xt,n as we,G as en,t as De,k as te,b as ze,o as ne,f as m,g as I,h as Oe,A as ut,y as Pe,z as Ve,E as nt,J as Cn,Z as Ze,N as Je,L as Gn,C as In,D as Or,ag as et,aj as io,ah as Hr,_ as ro,ak as at,al as Xa,am as Ka,R as fs,an as ds,I as ql,K as hs,m as Za}from"./scheduler.DB3Sqaa-.js";import{S as ke,i as Ee,t as P,a as B,g as je,c as Ye,j as Lr,h as Go,k as ao,f as lt,b as re,d as ce,m as ae,e as ue}from"./index.CidI1d1E.js";import{g as Ar}from"./globals.D0QH3NT1.js";import{e as pt,u as qo,o as Jo}from"./each.cN4tVpvB.js";import{t as $e}from"./Toaster.svelte_svelte_type_style_lang.C-7zrEBl.js";import{h as Pn,b6 as Br,b7 as Qo,b8 as zo,b9 as Mo,ba as Rr,bb as Ga,bc as oo,bd as Ur,be as qa,M as Ja}from"./Messages.B-ODG6LJ.js";import"./dayjs.min.CnqrW7zs.js";import{T as pn}from"./create.DJSy4-Dz.js";import{g as $t,a as Ol}from"./spread.CgU5AtxT.js";import{d as Sn,w as Ae,a as Tn}from"./index.DyGhRlyv.js";import{s as Qa,c as xa,u as $a,d as eu,n as tu,b as po}from"./menu-trigger.Syw7IYi9.js";import{g as To}from"./entry.JtQ7vg2d.js";import{p as nu}from"./stores.m3IJIQGn.js";import{d as El,j as Fn,s as uo,p as lu,n as ou,m as Sl,t as Wr,u as Il,k as vo,g as Nl,G as rl,b as su,S as iu,o as ru,H as qt,I as Hl,W as Fr,h as ol,E as au,f as uu,C as cu,v as nl,l as fu,e as du,D as Jl,z as hu,w as ll}from"./index.DPWiq6NR.js";import{h as xo,d as mu,n as gu,o as _u,p as bu,q as pu,r as vu,w as jr,x as so,y as ms,z as gs,i as Uo,v as Ql,A as _s,s as yu,B as xl,a as wu}from"./index.DYGdzELC.js";import{i as ku}from"./index.BDkw09Wf.js";import{A as Eu,F as bs,h as cl,G as ps,u as $l,z as Su,i as Iu,b as Cu}from"./index.CKAPQz6-.js";import{g as Du}from"./index.UmLAXRwf.js";import{j as zu,k as Mu,u as Tu,p as Pu,l as Vu}from"./index.q-TwC8Md.js";import{X as $o,T as Nu,S as Ou,U as Hu,q as Lu}from"./XMark.DPj80KMq.js";import{r as Au,s as Bu,t as Ru,v as Uu,w as Wu,x as Fu}from"./index.BS8UhGmM.js";import{f as vs,a as ju}from"./index.BronEFe7.js";import{t as es,s as Yu}from"./index.FhJ0HtJK.js";import{D as yo,M as Nn}from"./Dropdown.6Kb6OfAV.js";import{f as Wl}from"./index.DMdt0oYD.js";import{S as Yr}from"./Switch.C2EOWhLk.js";import{A as Xu}from"./AddFilesPlaceholder.BUionvZc.js";import{S as Ku}from"./Selector.Bqb2boTp.js";import{c as Xr,d as Zu}from"./updater.CmbHqgbQ.js";import{f as Gu}from"./FileSaver.min.CimDdHIv.js";import{b as qu}from"./index.BRB3dUu5.js";import{M as Ju}from"./MenuLines.CMXNxLEP.js";import{M as Qu}from"./Modal.DcRcsIox.js";import{A as xu}from"./AdvancedParams.DH6VGWxz.js";import{i as $u,j as ec,k as tc}from"./index.DPxQAFah.js";import{j as nc,k as lc,l as oc}from"./index.McBTOAZM.js";import{S as sc}from"./Spinner.zSvxKTtJ.js";import{V as ic,H as rc}from"./Heart.DnYgkWAI.js";import{C as ac}from"./ConfirmDialog.BhA26OgX.js";function uc(n){let e;for(;e=n.sourceEvent;)n=e;return n}function Wn(n,e){if(n=uc(n),e===void 0&&(e=n.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var l=t.createSVGPoint();return l.x=n.clientX,l.y=n.clientY,l=l.matrixTransform(e.getScreenCTM().inverse()),[l.x,l.y]}if(e.getBoundingClientRect){var o=e.getBoundingClientRect();return[n.clientX-o.left-e.clientLeft,n.clientY-o.top-e.clientTop]}}return[n.pageX,n.pageY]}const cc={passive:!1},Ll={capture:!0,passive:!1};function Po(n){n.stopImmediatePropagation()}function _l(n){n.preventDefault(),n.stopImmediatePropagation()}function Kr(n){var e=n.document.documentElement,t=Pn(n).on("dragstart.drag",_l,Ll);"onselectstart"in e?t.on("selectstart.drag",_l,Ll):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Zr(n,e){var t=n.document.documentElement,l=Pn(n).on("dragstart.drag",null);e&&(l.on("click.drag",_l,Ll),setTimeout(function(){l.on("click.drag",null)},0)),"onselectstart"in t?l.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}const eo=n=>()=>n;function Wo(n,{sourceEvent:e,subject:t,target:l,identifier:o,active:s,x:r,y:i,dx:a,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:t,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:r,enumerable:!0,configurable:!0},y:{value:i,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Wo.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function fc(n){return!n.ctrlKey&&!n.button}function dc(){return this.parentNode}function hc(n,e){return e??{x:n.x,y:n.y}}function mc(){return navigator.maxTouchPoints||"ontouchstart"in this}function gc(){var n=fc,e=dc,t=hc,l=mc,o={},s=Br("start","drag","end"),r=0,i,a,u,c,f=0;function h(w){w.on("mousedown.drag",d).filter(l).on("touchstart.drag",p).on("touchmove.drag",g,cc).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(w,N){if(!(c||!n.call(this,w,N))){var S=k(this,e.call(this,w,N),w,N,"mouse");S&&(Pn(w.view).on("mousemove.drag",_,Ll).on("mouseup.drag",v,Ll),Kr(w.view),Po(w),u=!1,i=w.clientX,a=w.clientY,S("start",w))}}function _(w){if(_l(w),!u){var N=w.clientX-i,S=w.clientY-a;u=N*N+S*S>f}o.mouse("drag",w)}function v(w){Pn(w.view).on("mousemove.drag mouseup.drag",null),Zr(w.view,u),_l(w),o.mouse("end",w)}function p(w,N){if(n.call(this,w,N)){var S=w.changedTouches,A=e.call(this,w,N),z=S.length,M,V;for(M=0;M()=>n;function yc(n,{sourceEvent:e,target:t,transform:l,dispatch:o}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:o}})}function Vo(n){n.stopImmediatePropagation()}function Ml(n){n.preventDefault(),n.stopImmediatePropagation()}function wc(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function kc(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function ws(){return this.__zoom||Qo}function Ec(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function Sc(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ic(n,e,t){var l=n.invertX(e[0][0])-t[0][0],o=n.invertX(e[1][0])-t[1][0],s=n.invertY(e[0][1])-t[0][1],r=n.invertY(e[1][1])-t[1][1];return n.translate(o>l?(l+o)/2:Math.min(0,l)||Math.max(0,o),r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r))}function Cc(){var n=wc,e=kc,t=Ic,l=Ec,o=Sc,s=[0,1/0],r=[[-1/0,-1/0],[1/0,1/0]],i=250,a=vc,u=Br("start","zoom","end"),c,f,h,d=500,_=150,v=0,p=10;function g(E){E.property("__zoom",ws).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",V).filter(o).on("touchstart.zoom",L).on("touchmove.zoom",Y).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(E,q,D,U){var F=E.selection?E.selection():E;F.property("__zoom",ws),E!==F?N(E,q,D,U):F.interrupt().each(function(){S(this,arguments).event(U).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},g.scaleBy=function(E,q,D,U){g.scaleTo(E,function(){var F=this.__zoom.k,C=typeof q=="function"?q.apply(this,arguments):q;return F*C},D,U)},g.scaleTo=function(E,q,D,U){g.transform(E,function(){var F=e.apply(this,arguments),C=this.__zoom,R=D==null?w(F):typeof D=="function"?D.apply(this,arguments):D,G=C.invert(R),J=typeof q=="function"?q.apply(this,arguments):q;return t(k(y(C,J),R,G),F,r)},D,U)},g.translateBy=function(E,q,D,U){g.transform(E,function(){return t(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof D=="function"?D.apply(this,arguments):D),e.apply(this,arguments),r)},null,U)},g.translateTo=function(E,q,D,U,F){g.transform(E,function(){var C=e.apply(this,arguments),R=this.__zoom,G=U==null?w(C):typeof U=="function"?U.apply(this,arguments):U;return t(Qo.translate(G[0],G[1]).scale(R.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof D=="function"?-D.apply(this,arguments):-D),C,r)},U,F)};function y(E,q){return q=Math.max(s[0],Math.min(s[1],q)),q===E.k?E:new zo(q,E.x,E.y)}function k(E,q,D){var U=q[0]-D[0]*E.k,F=q[1]-D[1]*E.k;return U===E.x&&F===E.y?E:new zo(E.k,U,F)}function w(E){return[(+E[0][0]+ +E[1][0])/2,(+E[0][1]+ +E[1][1])/2]}function N(E,q,D,U){E.on("start.zoom",function(){S(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(U).end()}).tween("zoom",function(){var F=this,C=arguments,R=S(F,C).event(U),G=e.apply(F,C),J=D==null?w(G):typeof D=="function"?D.apply(F,C):D,oe=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),ee=F.__zoom,j=typeof q=="function"?q.apply(F,C):q,ge=a(ee.invert(J).concat(oe/ee.k),j.invert(J).concat(oe/j.k));return function(x){if(x===1)x=j;else{var ye=ge(x),ie=oe/ye[2];x=new zo(ie,J[0]-ye[0]*ie,J[1]-ye[1]*ie)}R.zoom(null,x)}})}function S(E,q,D){return!D&&E.__zooming||new A(E,q)}function A(E,q){this.that=E,this.args=q,this.active=0,this.sourceEvent=null,this.extent=e.apply(E,q),this.taps=0}A.prototype={event:function(E){return E&&(this.sourceEvent=E),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(E,q){return this.mouse&&E!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&E!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&E!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(E){var q=Pn(this.that).datum();u.call(E,this.that,new yc(E,{sourceEvent:this.sourceEvent,target:g,type:E,transform:this.that.__zoom,dispatch:u}),q)}};function z(E,...q){if(!n.apply(this,arguments))return;var D=S(this,q).event(E),U=this.__zoom,F=Math.max(s[0],Math.min(s[1],U.k*Math.pow(2,l.apply(this,arguments)))),C=Wn(E);if(D.wheel)(D.mouse[0][0]!==C[0]||D.mouse[0][1]!==C[1])&&(D.mouse[1]=U.invert(D.mouse[0]=C)),clearTimeout(D.wheel);else{if(U.k===F)return;D.mouse=[C,U.invert(C)],Mo(this),D.start()}Ml(E),D.wheel=setTimeout(R,_),D.zoom("mouse",t(k(y(U,F),D.mouse[0],D.mouse[1]),D.extent,r));function R(){D.wheel=null,D.end()}}function M(E,...q){if(h||!n.apply(this,arguments))return;var D=E.currentTarget,U=S(this,q,!0).event(E),F=Pn(E.view).on("mousemove.zoom",J,!0).on("mouseup.zoom",oe,!0),C=Wn(E,D),R=E.clientX,G=E.clientY;Kr(E.view),Vo(E),U.mouse=[C,this.__zoom.invert(C)],Mo(this),U.start();function J(ee){if(Ml(ee),!U.moved){var j=ee.clientX-R,ge=ee.clientY-G;U.moved=j*j+ge*ge>v}U.event(ee).zoom("mouse",t(k(U.that.__zoom,U.mouse[0]=Wn(ee,D),U.mouse[1]),U.extent,r))}function oe(ee){F.on("mousemove.zoom mouseup.zoom",null),Zr(ee.view,U.moved),Ml(ee),U.event(ee).end()}}function V(E,...q){if(n.apply(this,arguments)){var D=this.__zoom,U=Wn(E.changedTouches?E.changedTouches[0]:E,this),F=D.invert(U),C=D.k*(E.shiftKey?.5:2),R=t(k(y(D,C),U,F),e.apply(this,q),r);Ml(E),i>0?Pn(this).transition().duration(i).call(N,R,U,E):Pn(this).call(g.transform,R,U,E)}}function L(E,...q){if(n.apply(this,arguments)){var D=E.touches,U=D.length,F=S(this,q,E.changedTouches.length===U).event(E),C,R,G,J;for(Vo(E),R=0;R({subIds:n&1}),ks=n=>({subIds:n[0]});function zc(n){let e;const t=n[6].default,l=dt(t,n,n[5],ks);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,[s]){l&&l.p&&(!e||s&33)&&ht(l,t,o,o[5],e?gt(t,o[5],s,Dc):mt(o[5]),ks)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function Mc(n,e,t){let l,{$$slots:o={},$$scope:s}=e,{disabled:r=void 0}=e,{open:i=void 0}=e,{onOpenChange:a=void 0}=e;const{updateOption:u,ids:c,states:{subOpen:f}}=Qa({disabled:r,onOpenChange:({next:d})=>(i!==d&&(a==null||a(d),t(2,i=d)),d)}),h=Sn([c.menu,c.trigger],([d,_])=>({menu:d,trigger:_}));return se(n,h,d=>t(0,l=d)),n.$$set=d=>{"disabled"in d&&t(3,r=d.disabled),"open"in d&&t(2,i=d.open),"onOpenChange"in d&&t(4,a=d.onOpenChange),"$$scope"in d&&t(5,s=d.$$scope)},n.$$.update=()=>{n.$$.dirty&4&&i!==void 0&&f.set(i),n.$$.dirty&8&&u("disabled",r)},[l,h,i,r,a,s,o]}class Tc extends ke{constructor(e){super(),Ee(this,e,Mc,zc,Se,{disabled:3,open:2,onOpenChange:4})}}const Pc=n=>({builder:n[0]&256}),Es=n=>({builder:n[8]}),Vc=n=>({builder:n[0]&256}),Ss=n=>({builder:n[8]}),Nc=n=>({builder:n[0]&256}),Is=n=>({builder:n[8]}),Oc=n=>({builder:n[0]&256}),Cs=n=>({builder:n[8]}),Hc=n=>({builder:n[0]&256}),Ds=n=>({builder:n[8]}),Lc=n=>({builder:n[0]&256}),zs=n=>({builder:n[8]});function Ac(n){let e,t,l,o;const s=n[28].default,r=dt(s,n,n[27],Es);let i=[n[8],n[13]],a={};for(let u=0;u{t=Go(e,n[3],n[4]),t.start()})),l=!0)},o(c){B(i,c),l=!1},d(c){c&&b(e),i&&i.d(c),n[31](null),o=!1,At(s)}}}function Uc(n){let e,t,l,o,s,r;const i=n[28].default,a=dt(i,n,n[27],Cs);let u=[n[8],n[13]],c={};for(let f=0;f{o&&(l&&l.end(1),t=Go(e,n[3],n[4]),t.start())}),o=!0)},o(f){B(a,f),t&&t.invalidate(),f&&(l=Lr(e,n[5],n[6])),o=!1},d(f){f&&b(e),a&&a.d(f),n[30](null),f&&l&&l.end(),s=!1,At(r)}}}function Wc(n){let e,t,l,o,s;const r=n[28].default,i=dt(r,n,n[27],Ds);let a=[n[8],n[13]],u={};for(let c=0;c{l&&(t||(t=ao(e,n[1],n[2],!0)),t.run(1))}),l=!0)},o(c){B(i,c),c&&(t||(t=ao(e,n[1],n[2],!1)),t.run(0)),l=!1},d(c){c&&b(e),i&&i.d(c),n[29](null),c&&t&&t.end(),o=!1,At(s)}}}function Fc(n){let e;const t=n[28].default,l=dt(t,n,n[27],zs);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,s){l&&l.p&&(!e||s[0]&134217984)&&ht(l,t,o,o[27],e?gt(t,o[27],s,Lc):mt(o[27]),zs)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function jc(n){let e,t,l,o;const s=[Fc,Wc,Uc,Rc,Bc,Ac],r=[];function i(a,u){return a[7]&&a[9]?0:a[1]&&a[9]?1:a[3]&&a[5]&&a[9]?2:a[3]&&a[9]?3:a[5]&&a[9]?4:a[9]?5:-1}return~(e=i(n))&&(t=r[e]=s[e](n)),{c(){t&&t.c(),l=Le()},l(a){t&&t.l(a),l=Le()},m(a,u){~e&&r[e].m(a,u),W(a,l,u),o=!0},p(a,u){let c=e;e=i(a),e===c?~e&&r[e].p(a,u):(t&&(je(),B(r[c],1,1,()=>{r[c]=null}),Ye()),~e?(t=r[e],t?t.p(a,u):(t=r[e]=s[e](a),t.c()),P(t,1),t.m(l.parentNode,l)):t=null)},i(a){o||(P(t),o=!0)},o(a){B(t),o=!1},d(a){a&&b(l),~e&&r[e].d(a)}}}function Yc(n,e,t){let l;const o=["transition","transitionConfig","inTransition","inTransitionConfig","outTransition","outTransitionConfig","asChild","id","side","align","sideOffset","alignOffset","collisionPadding","avoidCollisions","collisionBoundary","sameWidth","fitViewport","strategy","overlap","el"];let s=_t(e,o),r,i,{$$slots:a={},$$scope:u}=e,{transition:c=void 0}=e,{transitionConfig:f=void 0}=e,{inTransition:h=void 0}=e,{inTransitionConfig:d=void 0}=e,{outTransition:_=void 0}=e,{outTransitionConfig:v=void 0}=e,{asChild:p=!1}=e,{id:g=void 0}=e,{side:y="right"}=e,{align:k="start"}=e,{sideOffset:w=0}=e,{alignOffset:N=0}=e,{collisionPadding:S=8}=e,{avoidCollisions:A=!0}=e,{collisionBoundary:z=void 0}=e,{sameWidth:M=!1}=e,{fitViewport:V=!1}=e,{strategy:L="absolute"}=e,{overlap:Y=!1}=e,{el:K=void 0}=e;const{elements:{subMenu:E},states:{subOpen:q},ids:D,getAttrs:U}=xa();se(n,E,j=>t(26,r=j)),se(n,q,j=>t(9,i=j));const F=Xr(),C=U("sub-content");function R(j){Be[j?"unshift":"push"](()=>{K=j,t(0,K)})}function G(j){Be[j?"unshift":"push"](()=>{K=j,t(0,K)})}function J(j){Be[j?"unshift":"push"](()=>{K=j,t(0,K)})}function oe(j){Be[j?"unshift":"push"](()=>{K=j,t(0,K)})}function ee(j){Be[j?"unshift":"push"](()=>{K=j,t(0,K)})}return n.$$set=j=>{e=Qe(Qe({},e),nn(j)),t(13,s=_t(e,o)),"transition"in j&&t(1,c=j.transition),"transitionConfig"in j&&t(2,f=j.transitionConfig),"inTransition"in j&&t(3,h=j.inTransition),"inTransitionConfig"in j&&t(4,d=j.inTransitionConfig),"outTransition"in j&&t(5,_=j.outTransition),"outTransitionConfig"in j&&t(6,v=j.outTransitionConfig),"asChild"in j&&t(7,p=j.asChild),"id"in j&&t(14,g=j.id),"side"in j&&t(15,y=j.side),"align"in j&&t(16,k=j.align),"sideOffset"in j&&t(17,w=j.sideOffset),"alignOffset"in j&&t(18,N=j.alignOffset),"collisionPadding"in j&&t(19,S=j.collisionPadding),"avoidCollisions"in j&&t(20,A=j.avoidCollisions),"collisionBoundary"in j&&t(21,z=j.collisionBoundary),"sameWidth"in j&&t(22,M=j.sameWidth),"fitViewport"in j&&t(23,V=j.fitViewport),"strategy"in j&&t(24,L=j.strategy),"overlap"in j&&t(25,Y=j.overlap),"el"in j&&t(0,K=j.el),"$$scope"in j&&t(27,u=j.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&16384&&g&&D.menu.set(g),n.$$.dirty[0]&67108864&&t(8,l=r),n.$$.dirty[0]&256&&Object.assign(l,C),n.$$.dirty[0]&67076096&&$a({side:y,align:k,sideOffset:w,alignOffset:N,collisionPadding:S,avoidCollisions:A,collisionBoundary:z,sameWidth:M,fitViewport:V,strategy:L,overlap:Y})},[K,c,f,h,d,_,v,p,l,i,E,q,F,s,g,y,k,w,N,S,A,z,M,V,L,Y,r,u,a,R,G,J,oe,ee]}class Xc extends ke{constructor(e){super(),Ee(this,e,Yc,jc,Se,{transition:1,transitionConfig:2,inTransition:3,inTransitionConfig:4,outTransition:5,outTransitionConfig:6,asChild:7,id:14,side:15,align:16,sideOffset:17,alignOffset:18,collisionPadding:19,avoidCollisions:20,collisionBoundary:21,sameWidth:22,fitViewport:23,strategy:24,overlap:25,el:0},null,[-1,-1])}}const Kc=n=>({builder:n&4}),Ms=n=>({builder:n[2]}),Zc=n=>({builder:n&4}),Ts=n=>({builder:n[2]});function Gc(n){let e,t,l,o;const s=n[13].default,r=dt(s,n,n[12],Ms);let i=[n[2],n[6]],a={};for(let u=0;u{r[c]=null}),Ye(),t=r[e],t?t.p(a,u):(t=r[e]=s[e](a),t.c()),P(t,1),t.m(l.parentNode,l))},i(a){o||(P(t),o=!0)},o(a){B(t),o=!1},d(a){a&&b(l),r[e].d(a)}}}function Qc(n,e,t){let l,o;const s=["disabled","asChild","id","el"];let r=_t(e,s),i,a,{$$slots:u={},$$scope:c}=e,{disabled:f=!1}=e,{asChild:h=!1}=e,{id:d=void 0}=e,{el:_=void 0}=e;const{elements:{subTrigger:v},ids:p,getAttrs:g,options:y}=eu();se(n,v,S=>t(11,a=S));const{disabled:k}=y;se(n,k,S=>t(10,i=S));const w=Xr();function N(S){Be[S?"unshift":"push"](()=>{_=S,t(0,_)})}return n.$$set=S=>{e=Qe(Qe({},e),nn(S)),t(6,r=_t(e,s)),"disabled"in S&&t(7,f=S.disabled),"asChild"in S&&t(1,h=S.asChild),"id"in S&&t(8,d=S.id),"el"in S&&t(0,_=S.el),"$$scope"in S&&t(12,c=S.$$scope)},n.$$.update=()=>{n.$$.dirty&256&&d&&p.trigger.set(d),n.$$.dirty&2048&&t(2,l=a),n.$$.dirty&1152&&t(9,o={...g("sub-trigger"),...Zu(f||i)}),n.$$.dirty&516&&Object.assign(l,o)},[_,h,l,v,k,w,r,f,d,o,i,a,c,u,N]}class xc extends ke{constructor(e){super(),Ee(this,e,Qc,Jc,Se,{disabled:7,asChild:1,id:8,el:0})}}function Gr(n){try{qn(n)}catch{return n()}}function $c(n,e){let t=[];const l=i=>{t.push(i)},o=()=>{t.forEach(i=>i()),t=[]},s=Sn(n,i=>(o(),e(i,l)));return Gr(o),{...s,subscribe:(...i)=>{const a=s.subscribe(...i);return()=>{a(),o()}}}}function No(n,e){if(!Fl)return()=>{};const t=$c(n,(l,o)=>({stores:l,onUnsubscribe:o})).subscribe(({stores:l,onUnsubscribe:o})=>{const s=e(l);s&&o(s)});return Gr(t),t}function ef(n){const e={};return Object.keys(n).forEach(t=>{const l=t,o=n[l];e[l]=Ae(o)}),e}function tf(n){return function(e,t){if(t===void 0)return;const l=n[e];l&&l.set(t)}}function ts(n){return Object.keys(n).reduce((e,t)=>n[t]===void 0?e:e+`${t}:${n[t]};`,"")}let Fo=null,il=null;function qr(n){switch(n){case"horizontal":return"ew-resize";case"horizontal-max":return"w-resize";case"horizontal-min":return"e-resize";case"vertical":return"ns-resize";case"vertical-max":return"n-resize";case"vertical-min":return"s-resize"}}function nf(){il!==null&&(document.head.removeChild(il),Fo=null,il=null)}function Oo(n){if(Fo===n)return;Fo=n;const e=qr(n);il===null&&(il=document.createElement("style"),document.head.appendChild(il)),il.innerHTML=`*{cursor: ${e}!important;}`}function lf({defaultSize:n,dragState:e,layout:t,paneData:l,paneIndex:o,precision:s=3}){const r=t[o];let i;return r==null?i=n??"1":l.length===1?i="1":i=r.toPrecision(s),ts({"flex-basis":0,"flex-grow":i,"flex-shrink":1,overflow:"hidden","pointer-events":e!==null?"none":void 0})}function of({layout:n,panesArray:e,pivotIndices:t}){let l=0,o=100,s=0,r=0;const i=t[0];for(let f=0;f"u")throw new Error("localStorage is not supported in this environment");n.getItem=e=>localStorage.getItem(e),n.setItem=(e,t)=>localStorage.setItem(e,t)}catch(e){console.error(e),n.getItem=()=>null,n.setItem=()=>{}}}function Jr(n){return`paneforge:${n}`}function Qr(n){return n.map(t=>{const{constraints:l,id:o,idIsFromProps:s,order:r}=t;return s?o:r?`${r}:${JSON.stringify(l)}`:JSON.stringify(l)}).sort().join(",")}function xr(n,e){try{const t=Jr(n),l=e.getItem(t),o=JSON.parse(l||"");if(typeof o=="object"&&o!==null)return o}catch{}return null}function rf(n,e,t){const l=xr(n,t)||{},o=Qr(e);return l[o]||null}function af(n,e,t,l,o){const s=Jr(n),r=Qr(e),i=xr(n,o)||{};i[r]={expandToSizes:Object.fromEntries(t.entries()),layout:l};try{o.setItem(s,JSON.stringify(i))}catch(a){console.error(a)}}const Vs={};function uf(n,e=10){let t=null;return(...o)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{n(...o)},e)}}function cf({autoSaveId:n,layout:e,storage:t,paneDataArrayStore:l,paneSizeBeforeCollapseStore:o}){const s=le(l);if(e.length===0||e.length!==s.length)return;let r=Vs[n];r==null&&(r=uf(af,sf),Vs[n]=r);const i=[...s],a=le(o),u=new Map(a);r(n,i,u,e,t)}function $r(n){const e={};for(const t in n){const l=n[t];l!==void 0&&(e[t]=l)}return e}function ff(...n){return(...e)=>{for(const t of n)typeof t=="function"&&t(...e)}}function sl(n,e,t,l){const o=Array.isArray(e)?e:[e];return o.forEach(s=>n.addEventListener(s,t,l)),()=>{o.forEach(s=>n.removeEventListener(s,t,l))}}function bn(n,e,t=ls){return Al(n,e,t)===0}function Al(n,e,t=ls){const l=Ns(n,t),o=Ns(e,t);return Math.sign(l-o)}function Tl(n,e){if(n.length!==e.length)return!1;for(let t=0;t0&&(n=n<0?0-p:p)}}}{const c=n<0?r:i,f=t[c];zt(f);const{collapsible:h}=f;if(h){const d=e[c];zt(d!=null);const _=t[c];zt(_);const{collapsedSize:v=0,minSize:p=0}=_;if(bn(d,p)){const g=d-v;Al(g,Math.abs(n))>0&&(n=n<0?0-g:g)}}}}{const c=n<0?1:-1;let f=n<0?i:r,h=0;for(;;){const _=e[f];zt(_!=null);const p=hl({paneConstraints:t,paneIndex:f,initialSize:100})-_;if(h+=p,f+=c,f<0||f>=t.length)break}const d=Math.min(Math.abs(n),Math.abs(h));n=n<0?0-d:d}{let f=n<0?r:i;for(;f>=0&&f=0))break;n<0?f--:f++}}if(bn(a,0))return e;{const c=n<0?i:r,f=e[c];zt(f!=null);const h=f+a,d=hl({paneConstraints:t,paneIndex:c,initialSize:h});if(s[c]=d,!bn(d,h)){let _=h-d,p=n<0?i:r;for(;p>=0&&p0?p--:p++}}}const u=s.reduce((c,f)=>f+c,0);return bn(u,100)?s:e}const Fl=typeof document<"u";function hf(n){return n instanceof HTMLElement}function ea(n){return n.type==="keydown"}function ta(n){return n.type.startsWith("mouse")}function na(n){return n.type.startsWith("touch")}const ml={getItem:n=>(Ps(ml),ml.getItem(n)),setItem:(n,e)=>{Ps(ml),ml.setItem(n,e)}},mf={id:null,onLayout:null,keyboardResizeBy:null,autoSaveId:null,direction:"horizontal",storage:ml};function gf(n){const e={...mf,...$r(n)},t=ef(e),{autoSaveId:l,direction:o,keyboardResizeBy:s,storage:r,onLayout:i}=t,a=Ae(ns()),u=Ae(null),c=Ae([]),f=Ae([]),h=Ae(!1),d=Ae({}),_=Ae(new Map),v=Ae(0);No([a,c,f],([F,C,R])=>_f({groupId:F,layout:C,paneDataArray:R})),un(()=>q()),No([l,c,r],([F,C,R])=>{F&&cf({autoSaveId:F,layout:C,storage:R,paneDataArrayStore:f,paneSizeBeforeCollapseStore:_})});function p(F){const C=le(c),R=le(f);if(!F.constraints.collapsible)return;const G=R.map(ie=>ie.constraints),{collapsedSize:J=0,paneSize:oe,pivotIndices:ee}=fl(R,F,C);if(zt(oe!=null),oe===J)return;_.update(ie=>(ie.set(F.id,oe),ie));const ge=dl(R,F)===R.length-1?oe-J:J-oe,x=Pl({delta:ge,layout:C,paneConstraints:G,pivotIndices:ee,trigger:"imperative-api"});if(Tl(C,x))return;c.set(x);const ye=le(i);ye&&ye(x),Vl(R,x,le(d))}function g(F){const C=le(c),R=le(f),{paneSize:G}=fl(R,F,C);return G}const y=Sn([f,c,u],([F,C,R])=>(G,J)=>{const oe=dl(F,G);return lf({defaultSize:J,dragState:R,layout:C,paneData:F,paneIndex:oe})});function k(F){const C=le(f),R=le(c),{collapsedSize:G=0,collapsible:J,paneSize:oe}=fl(C,F,R);return!J||oe>G}function w(F){f.update(C=>{const R=[...C,F];return R.sort((G,J)=>{const oe=G.order,ee=J.order;return oe==null&&ee==null?0:oe==null?-1:ee==null?1:oe-ee}),R}),h.set(!0)}No([h],([F])=>{if(!F)return;h.set(!1);const C=le(l),R=le(r),G=le(c),J=le(f);let oe=null;if(C){const ge=rf(C,J,R);ge&&(_.set(new Map(Object.entries(ge.expandToSizes))),oe=ge.layout)}oe==null&&(oe=vf({paneDataArray:J}));const ee=yf({layout:oe,paneConstraints:J.map(ge=>ge.constraints)});if(Tl(G,ee))return;c.set(ee);const j=le(i);j&&j(ee),Vl(J,ee,le(d))});function N(F){return function(R){R.preventDefault();const G=le(o),J=le(u),oe=le(a),ee=le(s),j=le(c),ge=le(f),{initialLayout:x}=J??{},ye=Hs(oe,F);let ie=wf(R,F,G,J,ee);if(ie===0)return;const Ie=G==="horizontal";document.dir==="rtl"&&Ie&&(ie=-ie);const Te=ge.map(de=>de.constraints),Fe=Pl({delta:ie,layout:x??j,paneConstraints:Te,pivotIndices:ye,trigger:ea(R)?"keyboard":"mouse-or-touch"}),rt=!Tl(j,Fe);if((ta(R)||na(R))&&le(v)!=ie&&(v.set(ie),Oo(rt?Ie?"horizontal":"vertical":Ie?ie<0?"horizontal-min":"horizontal-max":ie<0?"vertical-min":"vertical-max")),rt){c.set(Fe);const de=le(i);de&&de(Fe),Vl(ge,Fe,le(d))}}}function S(F,C){const R=le(c),G=le(f),J=G.map(ie=>ie.constraints),{paneSize:oe,pivotIndices:ee}=fl(G,F,R);zt(oe!=null);const ge=dl(G,F)===G.length-1?oe-C:C-oe,x=Pl({delta:ge,layout:R,paneConstraints:J,pivotIndices:ee,trigger:"imperative-api"});if(Tl(R,x))return;c.set(x);const ye=le(i);ye==null||ye(x),Vl(G,x,le(d))}function A(F,C){const R=le(o),G=le(c),J=os(F);zt(J);const oe=oa(R,C);u.set({dragHandleId:F,dragHandleRect:J.getBoundingClientRect(),initialCursorPosition:oe,initialLayout:G})}function z(){nf(),u.set(null)}function M(F){const C=le(f),R=dl(C,F);R<0||f.update(G=>(G.splice(R,1),d.update(J=>(delete J[F.id],J)),h.set(!0),G))}function V(F){const C=le(f),R=le(c),{collapsedSize:G=0,collapsible:J,paneSize:oe}=fl(C,F,R);return J===!0&&oe===G}function L(F){const C=le(c),R=le(f);if(!F.constraints.collapsible)return;const G=R.map(Fe=>Fe.constraints),{collapsedSize:J=0,paneSize:oe,minSize:ee=0,pivotIndices:j}=fl(R,F,C);if(oe!==J)return;const ge=le(_).get(F.id),x=ge!=null&&ge>=ee?ge:ee,ie=dl(R,F)===R.length-1?oe-x:x-oe,Ie=Pl({delta:ie,layout:C,paneConstraints:G,pivotIndices:j,trigger:"imperative-api"});if(Tl(C,Ie))return;c.set(Ie);const Te=le(i);Te==null||Te(Ie),Vl(R,Ie,le(d))}const Y=Sn([o],([F])=>ts({display:"flex","flex-direction":F==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"})),K=Sn([o,a],([F,C])=>({"data-pane-group":"","data-direction":F,"data-pane-group-id":C})),E=Sn([Y,K],([F,C])=>({style:F,...C}));function q(){const F=le(a),R=jl(F).map(G=>{const J=G.getAttribute("data-pane-resizer-id");if(!J)return Os;const[oe,ee]=pf(F,J,le(f));if(oe==null||ee==null)return Os;const ge=sl(G,"keydown",x=>{if(x.defaultPrevented||x.key!=="Enter")return;x.preventDefault();const ye=le(f),ie=ye.findIndex(Vt=>Vt.id===oe);if(ie<0)return;const Ie=ye[ie];zt(Ie);const Te=le(c),Fe=Te[ie],{collapsedSize:rt=0,collapsible:de,minSize:Ge=0}=Ie.constraints;if(!(Fe!=null&&de))return;const Ke=Pl({delta:bn(Fe,rt)?Ge-Fe:rt-Fe,layout:Te,paneConstraints:ye.map(Vt=>Vt.constraints),pivotIndices:Hs(F,J),trigger:"keyboard"});Te!==Ke&&c.set(Ke)});return()=>{ge()}});return()=>{R.forEach(G=>G())}}function D(F){c.set(F)}function U(){return le(c)}return{methods:{collapsePane:p,expandPane:L,getSize:g,getPaneStyle:y,isCollapsed:V,isExpanded:k,registerPane:w,registerResizeHandle:N,resizePane:S,startDragging:A,stopDragging:z,unregisterPane:M,setLayout:D,getLayout:U},states:{direction:o,dragState:u,groupId:a,paneGroupAttrs:E,paneGroupSelectors:K,paneGroupStyle:Y,layout:c},options:t}}function _f({groupId:n,layout:e,paneDataArray:t}){const l=jl(n);for(let o=0;o{l.forEach(o=>{o.removeAttribute("aria-controls"),o.removeAttribute("aria-valuemax"),o.removeAttribute("aria-valuemin"),o.removeAttribute("aria-valuenow")})}}function jl(n){return Fl?Array.from(document.querySelectorAll(`[data-pane-resizer-id][data-pane-group-id="${n}"]`)):[]}function bf(n){if(!Fl)return null;const e=document.querySelector(`[data-pane-group][data-pane-group-id="${n}"]`);return e||null}function Os(){}function pf(n,e,t){var a,u;const l=os(e),o=jl(n),s=l?o.indexOf(l):-1,r=((a=t[s])==null?void 0:a.id)??null,i=((u=t[s+1])==null?void 0:u.id)??null;return[r,i]}function os(n){if(!Fl)return null;const e=document.querySelector(`[data-pane-resizer-id="${n}"]`);return e||null}function la(n,e){return Fl?jl(n).findIndex(o=>o.getAttribute("data-pane-resizer-id")===e)??null:null}function Hs(n,e){const t=la(n,e);return t!=null?[t,t+1]:[-1,-1]}function fl(n,e,t){const l=n.map(u=>u.constraints),o=dl(n,e),s=l[o],i=o===n.length-1?[o-1,o]:[o,o+1],a=t[o];return{...s,paneSize:a,pivotIndices:i}}function dl(n,e){return n.findIndex(t=>t.id===e.id)}function Vl(n,e,t){e.forEach((l,o)=>{const s=n[o];zt(s);const{callbacks:r,constraints:i,id:a}=s,{collapsedSize:u=0,collapsible:c}=i,f=t[a];if(!(f==null||l!==f))return;t[a]=l;const{onCollapse:h,onExpand:d,onResize:_}=r;_==null||_(l,f),c&&(h||d)&&(d&&(f==null||f===u)&&l!==u&&d(),h&&(f==null||f!==u)&&l===u&&h())})}function vf({paneDataArray:n}){const e=Array(n.length),t=n.map(s=>s.constraints);let l=0,o=100;for(let s=0;ss+r,0);if(t.length!==e.length)throw Error(`Invalid ${e.length} pane layout: ${t.map(s=>`${s}%`).join(", ")}`);if(!bn(l,100))for(let s=0;s container`);return Lt(jo)}function Sf(n){let e,t;const l=n[18].default,o=dt(l,n,n[17],null);let s=[{id:n[2]},n[3],{style:n[1]},n[7]],r={};for(let i=0;it(16,r=L)),se(n,N,L=>t(3,a=L)),se(n,S,L=>t(2,i=L)),y={getLayout:z,setLayout:A,getId:()=>i};function V(L){Be[L?"unshift":"push"](()=>{g=L,t(0,g)})}return n.$$set=L=>{e=Qe(Qe({},e),nn(L)),t(7,s=_t(e,o)),"autoSaveId"in L&&t(9,f=L.autoSaveId),"direction"in L&&t(10,h=L.direction),"id"in L&&t(11,d=L.id),"keyboardResizeBy"in L&&t(12,_=L.keyboardResizeBy),"onLayoutChange"in L&&t(13,v=L.onLayoutChange),"storage"in L&&t(14,p=L.storage),"el"in L&&t(0,g=L.el),"paneGroup"in L&&t(8,y=L.paneGroup),"style"in L&&t(15,k=L.style),"$$scope"in L&&t(17,c=L.$$scope)},n.$$.update=()=>{n.$$.dirty&512&&M("autoSaveId",f),n.$$.dirty&1024&&M("direction",h),n.$$.dirty&2048&&M("id",d),n.$$.dirty&4096&&M("keyboardResizeBy",_),n.$$.dirty&8192&&M("onLayout",v),n.$$.dirty&16384&&M("storage",p),n.$$.dirty&98304&&t(1,l=r+(k??""))},[g,l,i,a,w,N,S,s,y,f,h,d,_,v,p,k,r,c,u,V]}class Cf extends ke{constructor(e){super(),Ee(this,e,If,Sf,Se,{autoSaveId:9,direction:10,id:11,keyboardResizeBy:12,onLayoutChange:13,storage:14,el:0,paneGroup:8,style:15})}}function Df(n){let e,t;const l=n[22].default,o=dt(l,n,n[21],null);let s=[{style:n[2]},n[1],n[5]],r={};for(let i=0;it(20,a=G)),se(n,U,G=>t(19,i=G));const F=ns(S);let C;N={collapse:()=>{L(C)},expand:()=>Y(C),getSize:()=>K(C),isCollapsed:()=>E(C),isExpanded:()=>q(C),resize:G=>D(C,G),getId:()=>F},un(()=>(M(C),()=>{V(C)}));function R(G){Be[G?"unshift":"push"](()=>{w=G,t(0,w)})}return n.$$set=G=>{e=Qe(Qe({},e),nn(G)),t(5,r=_t(e,s)),"collapsedSize"in G&&t(7,f=G.collapsedSize),"collapsible"in G&&t(8,h=G.collapsible),"defaultSize"in G&&t(9,d=G.defaultSize),"maxSize"in G&&t(10,_=G.maxSize),"minSize"in G&&t(11,v=G.minSize),"onCollapse"in G&&t(12,p=G.onCollapse),"onExpand"in G&&t(13,g=G.onExpand),"onResize"in G&&t(14,y=G.onResize),"order"in G&&t(15,k=G.order),"el"in G&&t(0,w=G.el),"pane"in G&&t(6,N=G.pane),"id"in G&&t(16,S=G.id),"style"in G&&t(17,A=G.style),"$$scope"in G&&t(21,c=G.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&130944&&t(18,C={callbacks:{onCollapse:p,onExpand:g,onResize:y},constraints:{collapsedSize:f,collapsible:h,defaultSize:d,maxSize:_,minSize:v},id:F,idIsFromProps:S!==void 0,order:k}),n.$$.dirty[0]&1442304&&t(2,l=a(C,d)+(A??"")),n.$$.dirty[0]&524288&&t(1,o={"data-pane":"","data-pane-id":F,"data-pane-group-id":i})},[w,o,l,z,U,r,N,f,h,d,_,v,p,g,y,k,S,A,C,i,a,c,u,R]}let ia=class extends ke{constructor(e){super(),Ee(this,e,zf,Df,Se,{collapsedSize:7,collapsible:8,defaultSize:9,maxSize:10,minSize:11,onCollapse:12,onExpand:13,onResize:14,order:15,el:0,pane:6,id:16,style:17},null,[-1,-1])}};function Mf(n,e){let t=()=>{};function l(o){t();const{disabled:s,resizeHandler:r,isDragging:i,stopDragging:a,onDragging:u=void 0}=o;if(s||r===null||!i)return;const c=d=>{r(d)},f=d=>{r(d)},h=()=>{n.blur(),a(),u&&u(!1)};t=ff(sl(document.body,"contextmenu",h),sl(document.body,"mousemove",c),sl(document.body,"touchmove",c,{passive:!1}),sl(document.body,"mouseleave",f),sl(window,"mouseup",h),sl(window,"touchend",h))}return l(e),{update:l,onDestroy(){t()}}}function Tf(n){let e,t,l,o,s;const r=n[24].default,i=dt(r,n,n[23],null);let a=[{role:"separator"},{style:n[8]},{tabindex:n[3]},n[7],n[17]],u={};for(let c=0;ct(21,u=C)),se(n,A,C=>t(22,c=C)),se(n,z,C=>t(20,a=C));const M=ns(g);let V=!1,L=null;function Y(){const C=p;C&&(C.blur(),N(),_==null||_(!1))}un(()=>{d?t(6,L=null):t(6,L=k(M))});function K(C){if(d||!L||C.defaultPrevented)return;if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home"].includes(C.key)){C.preventDefault(),L(C);return}if(C.key!=="F6")return;C.preventDefault();const G=jl(a),J=la(a,M);if(J===null)return;const oe=C.shiftKey?J>0?J-1:G.length-1:J+1{p=C,t(0,p)})}const q=()=>t(4,V=!1),D=()=>t(4,V=!0),U=C=>{C.preventDefault(),w(M,C),_==null||_(!0)},F=C=>{C.preventDefault(),w(M,C),_==null||_(!0)};return n.$$set=C=>{e=Qe(Qe({},e),nn(C)),t(17,i=_t(e,r)),"disabled"in C&&t(1,d=C.disabled),"onDraggingChange"in C&&t(2,_=C.onDraggingChange),"tabIndex"in C&&t(3,v=C.tabIndex),"el"in C&&t(0,p=C.el),"id"in C&&t(18,g=C.id),"style"in C&&t(19,y=C.style),"$$scope"in C&&t(23,h=C.$$scope)},n.$$.update=()=>{n.$$.dirty&4194304&&t(5,l=(c==null?void 0:c.dragHandleId)===M),n.$$.dirty&2&&(d?t(6,L=null):t(6,L=k(M))),n.$$.dirty&2621440&&t(8,o=ts({cursor:qr(u),"touch-action":"none","user-select":"none","-webkit-user-select":"none","-webkit-touch-callout":"none"})+y),n.$$.dirty&3145778&&t(7,s={"data-direction":u,"data-pane-group-id":a,"data-active":l?"pointer":V?"keyboard":void 0,"data-enabled":!d,"data-pane-resizer-id":M,"data-pane-resizer":""})},[p,d,_,v,V,l,L,s,o,w,N,S,A,z,M,Y,K,i,g,y,a,u,c,h,f,E,q,D,U,F]}class Vf extends ke{constructor(e){super(),Ee(this,e,Pf,Tf,Se,{disabled:1,onDraggingChange:2,tabIndex:3,el:0,id:18,style:19})}}function Nf(n){let e,t,l,o,s,r,i;return a(),{feed:u,reset:a};function a(){e=!0,t="",l=0,o=-1,s=void 0,r=void 0,i=""}function u(f){t=t?t+f:f,e&&Of(t)&&(t=t.slice(ra.length)),e=!1;const h=t.length;let d=0,_=!1;for(;d0&&(t=t.slice(d))}function c(f,h,d,_){if(_===0){i.length>0&&(n({type:"event",id:s,event:r||void 0,data:i.slice(0,-1)}),i="",s=void 0),r=void 0;return}const v=d<0,p=f.slice(h,h+(v?_:d));let g=0;v?g=_:f[h+d+1]===" "?g=d+2:g=d+1;const y=h+g,k=_-g,w=f.slice(y,y+k).toString();if(p==="data")i+=w?"".concat(w,` `):` `;else if(p==="event")r=w;else if(p==="id"&&!w.includes("\0"))s=w;else if(p==="retry"){const N=parseInt(w,10);Number.isNaN(N)||n({type:"reconnect-interval",value:N})}}}const ra=[239,187,191];function Of(n){return ra.every((e,t)=>n.charCodeAt(t)===e)}class Hf extends TransformStream{constructor(){let e;super({start(t){e=Nf(l=>{l.type==="event"&&t.enqueue(l)})},transform(t){e.feed(t)}})}}async function Ls(n,e){const t=n.pipeThrough(new TextDecoderStream).pipeThrough(new Hf).getReader();let l=Lf(t);return e&&(l=Af(l)),l}async function*Lf(n){var e,t,l;for(;;){const{value:o,done:s}=await n.read();if(s){yield{done:!0,value:""};break}if(!o)continue;const r=o.data;if(r.startsWith("[DONE]")){yield{done:!0,value:""};break}try{const i=JSON.parse(r);if(console.log(i),i.error){yield{done:!0,value:"",error:i.error};break}if(i.citations){yield{done:!1,value:"",citations:i.citations};continue}yield{done:!1,value:((l=(t=(e=i.choices)==null?void 0:e[0])==null?void 0:t.delta)==null?void 0:l.content)??"",usage:i.usage}}catch(i){console.error("Error extracting delta from SSE event:",i)}}}async function*Af(n){for await(const e of n){if(e.done){yield e;return}if(e.citations){yield e;continue}let t=e.value;if(t.length<5){yield{done:!1,value:t};continue}for(;t!="";){const l=Math.min(Math.floor(Math.random()*3)+1,t.length);yield{done:!1,value:t.slice(0,l)},(document==null?void 0:document.visibilityState)!=="hidden"&&await Bf(5),t=t.slice(l)}}}const Bf=n=>new Promise(e=>setTimeout(e,n));function As(n){let e,t=n[2]&&Bs(n);return{c(){t&&t.c(),e=Le()},l(l){t&&t.l(l),e=Le()},m(l,o){t&&t.m(l,o),W(l,e,o)},p(l,o){l[2]?t?(t.p(l,o),o&4&&P(t,1)):(t=Bs(l),t.c(),P(t,1),t.m(e.parentNode,e)):t&&(je(),B(t,1,1,()=>{t=null}),Ye())},d(l){l&&b(e),t&&t.d(l)}}}function Bs(n){let e,t,l,o,s=n[1].type+"",r,i,a,u,c,f=n[1].content+"",h,d,_,v,p,g,y=n[1].url&&Rs(),k=n[1].url&&Us(),w=n[1].dismissible&&Ws(n);return{c(){e=O("div"),t=O("div"),l=O("div"),o=O("div"),r=De(s),a=te(),y&&y.c(),u=te(),c=O("div"),h=De(f),d=te(),k&&k.c(),_=te(),v=O("div"),w&&w.c(),this.h()},l(N){e=H(N,"DIV",{class:!0});var S=T(e);t=H(S,"DIV",{class:!0});var A=T(t);l=H(A,"DIV",{class:!0});var z=T(l);o=H(z,"DIV",{class:!0});var M=T(o);r=ze(M,s),M.forEach(b),a=ne(z),y&&y.l(z),z.forEach(b),u=ne(A),c=H(A,"DIV",{class:!0});var V=T(c);h=ze(V,f),V.forEach(b),A.forEach(b),d=ne(S),k&&k.l(S),_=ne(S),v=H(S,"DIV",{class:!0});var L=T(v);w&&w.l(L),L.forEach(b),S.forEach(b),this.h()},h(){m(o,"class",i="text-xs font-bold "+(n[3][n[1].type]??n[3].info)+" w-fit px-2 rounded uppercase line-clamp-1 mr-0.5"),m(l,"class","flex justify-between self-start"),m(c,"class","flex-1 text-xs text-gray-700 dark:text-white"),m(t,"class","flex flex-col md:flex-row md:items-center flex-1 text-sm w-fit gap-1.5"),m(v,"class","flex self-start"),m(e,"class","top-0 left-0 right-0 p-2 mx-4 px-3 flex justify-center items-center relative rounded-xl border border-gray-50 dark:border-gray-850 text-gray-800 dark:text-gary-100 bg-white dark:bg-gray-900 backdrop-blur-xl z-30")},m(N,S){W(N,e,S),I(e,t),I(t,l),I(l,o),I(o,r),I(l,a),y&&y.m(l,null),I(t,u),I(t,c),I(c,h),I(e,d),k&&k.m(e,null),I(e,_),I(e,v),w&&w.m(v,null),g=!0},p(N,S){(!g||S&2)&&s!==(s=N[1].type+"")&&Oe(r,s),(!g||S&2&&i!==(i="text-xs font-bold "+(N[3][N[1].type]??N[3].info)+" w-fit px-2 rounded uppercase line-clamp-1 mr-0.5"))&&m(o,"class",i),N[1].url?y||(y=Rs(),y.c(),y.m(l,null)):y&&(y.d(1),y=null),(!g||S&2)&&f!==(f=N[1].content+"")&&Oe(h,f),N[1].url?k||(k=Us(),k.c(),k.m(e,_)):k&&(k.d(1),k=null),N[1].dismissible?w?w.p(N,S):(w=Ws(N),w.c(),w.m(v,null)):w&&(w.d(1),w=null)},i(N){g||(N&&xn(()=>{g&&(p||(p=ao(e,vs,{delay:100,duration:300},!0)),p.run(1))}),g=!0)},o(N){N&&(p||(p=ao(e,vs,{delay:100,duration:300},!1)),p.run(0)),g=!1},d(N){N&&b(e),y&&y.d(),k&&k.d(),w&&w.d(),N&&p&&p.end()}}}function Rs(n){let e,t='Learn More
';return{c(){e=O("div"),e.innerHTML=t,this.h()},l(l){e=H(l,"DIV",{class:!0,"data-svelte-h":!0}),ut(e)!=="svelte-o2pz5m"&&(e.innerHTML=t),this.h()},h(){m(e,"class","flex md:hidden group w-fit md:items-center")},m(l,o){W(l,e,o)},d(l){l&&b(e)}}}function Us(n){let e,t='Learn More
';return{c(){e=O("div"),e.innerHTML=t,this.h()},l(l){e=H(l,"DIV",{class:!0,"data-svelte-h":!0}),ut(e)!=="svelte-1wr7se3"&&(e.innerHTML=t),this.h()},h(){m(e,"class","hidden md:flex group w-fit md:items-center")},m(l,o){W(l,e,o)},d(l){l&&b(e)}}}function Ws(n){let e,t="×",l,o;return{c(){e=O("button"),e.textContent=t,this.h()},l(s){e=H(s,"BUTTON",{class:!0,"data-svelte-h":!0}),ut(e)!=="svelte-o8kh4p"&&(e.textContent=t),this.h()},h(){m(e,"class","-mt-1 -mb-2 -translate-y-[1px] ml-1.5 mr-1 text-gray-400 dark:hover:text-white")},m(s,r){W(s,e,r),l||(o=he(e,"click",n[5]),l=!0)},p:we,d(s){s&&b(e),l=!1,o()}}}function Rf(n){let e,t=!n[0]&&As(n);return{c(){t&&t.c(),e=Le()},l(l){t&&t.l(l),e=Le()},m(l,o){t&&t.m(l,o),W(l,e,o)},p(l,[o]){l[0]?t&&(t.d(1),t=null):t?t.p(l,o):(t=As(l),t.c(),t.m(e.parentNode,e))},i:we,o:we,d(l){l&&b(e),t&&t.d(l)}}}function Uf(n,e,t){const l=en();let{banner:o={id:"",type:"info",title:"",content:"",url:"",dismissable:!0,timestamp:Math.floor(Date.now()/1e3)}}=e,{dismissed:s=!1}=e,r=!1;const i={info:"bg-blue-500/20 text-blue-700 dark:text-blue-200 ",success:"bg-green-500/20 text-green-700 dark:text-green-200",warning:"bg-yellow-500/20 text-yellow-700 dark:text-yellow-200",error:"bg-red-500/20 text-red-700 dark:text-red-200"},a=c=>{t(0,s=!0),l("dismiss",c)};un(()=>{t(2,r=!0)});const u=()=>{a(o.id)};return n.$$set=c=>{"banner"in c&&t(1,o=c.banner),"dismissed"in c&&t(0,s=c.dismissed)},[s,o,r,i,a,u]}class Wf extends ke{constructor(e){super(),Ee(this,e,Uf,Rf,Se,{banner:1,dismissed:0})}}function Ff(n){let e,t,l;return{c(){e=Pe("svg"),t=Pe("path"),l=Pe("path"),this.h()},l(o){e=Ve(o,"svg",{xmlns:!0,viewBox:!0,fill:!0,class:!0});var s=T(e);t=Ve(s,"path",{"fill-rule":!0,d:!0,"clip-rule":!0}),T(t).forEach(b),l=Ve(s,"path",{d:!0}),T(l).forEach(b),s.forEach(b),this.h()},h(){m(t,"fill-rule","evenodd"),m(t,"d","M5.625 1.5H9a3.75 3.75 0 0 1 3.75 3.75v1.875c0 1.036.84 1.875 1.875 1.875H16.5a3.75 3.75 0 0 1 3.75 3.75v7.875c0 1.035-.84 1.875-1.875 1.875H5.625a1.875 1.875 0 0 1-1.875-1.875V3.375c0-1.036.84-1.875 1.875-1.875Zm6.905 9.97a.75.75 0 0 0-1.06 0l-3 3a.75.75 0 1 0 1.06 1.06l1.72-1.72V18a.75.75 0 0 0 1.5 0v-4.19l1.72 1.72a.75.75 0 1 0 1.06-1.06l-3-3Z"),m(t,"clip-rule","evenodd"),m(l,"d","M14.25 5.25a5.23 5.23 0 0 0-1.279-3.434 9.768 9.768 0 0 1 6.963 6.963A5.23 5.23 0 0 0 16.5 7.5h-1.875a.375.375 0 0 1-.375-.375V5.25Z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 24 24"),m(e,"fill","currentColor"),m(e,"class",n[0])},m(o,s){W(o,e,s),I(e,t),I(e,l)},p(o,[s]){s&1&&m(e,"class",o[0])},i:we,o:we,d(o){o&&b(e)}}}function jf(n,e,t){let{className:l="size-4"}=e;return n.$$set=o=>{"className"in o&&t(0,l=o.className)},[l]}class Yf extends ke{constructor(e){super(),Ee(this,e,jf,Ff,Se,{className:0})}}function Xf(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0,fill:!0,class:!0});var o=T(e);t=Ve(o,"path",{d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"d","M21.721 12.752a9.711 9.711 0 0 0-.945-5.003 12.754 12.754 0 0 1-4.339 2.708 18.991 18.991 0 0 1-.214 4.772 17.165 17.165 0 0 0 5.498-2.477ZM14.634 15.55a17.324 17.324 0 0 0 .332-4.647c-.952.227-1.945.347-2.966.347-1.021 0-2.014-.12-2.966-.347a17.515 17.515 0 0 0 .332 4.647 17.385 17.385 0 0 0 5.268 0ZM9.772 17.119a18.963 18.963 0 0 0 4.456 0A17.182 17.182 0 0 1 12 21.724a17.18 17.18 0 0 1-2.228-4.605ZM7.777 15.23a18.87 18.87 0 0 1-.214-4.774 12.753 12.753 0 0 1-4.34-2.708 9.711 9.711 0 0 0-.944 5.004 17.165 17.165 0 0 0 5.498 2.477ZM21.356 14.752a9.765 9.765 0 0 1-7.478 6.817 18.64 18.64 0 0 0 1.988-4.718 18.627 18.627 0 0 0 5.49-2.098ZM2.644 14.752c1.682.971 3.53 1.688 5.49 2.099a18.64 18.64 0 0 0 1.988 4.718 9.765 9.765 0 0 1-7.478-6.816ZM13.878 2.43a9.755 9.755 0 0 1 6.116 3.986 11.267 11.267 0 0 1-3.746 2.504 18.63 18.63 0 0 0-2.37-6.49ZM12 2.276a17.152 17.152 0 0 1 2.805 7.121c-.897.23-1.837.353-2.805.353-.968 0-1.908-.122-2.805-.353A17.151 17.151 0 0 1 12 2.276ZM10.122 2.43a18.629 18.629 0 0 0-2.37 6.49 11.266 11.266 0 0 1-3.746-2.504 9.754 9.754 0 0 1 6.116-3.985Z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 24 24"),m(e,"fill","currentColor"),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function Kf(n,e,t){let{className:l="size-4"}=e;return n.$$set=o=>{"className"in o&&t(0,l=o.className)},[l]}class Zf extends ke{constructor(e){super(),Ee(this,e,Kf,Xf,Se,{className:0})}}function Gf(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0,fill:!0,class:!0});var o=T(e);t=Ve(o,"path",{"fill-rule":!0,d:!0,"clip-rule":!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"fill-rule","evenodd"),m(t,"d","M12 6.75a5.25 5.25 0 0 1 6.775-5.025.75.75 0 0 1 .313 1.248l-3.32 3.319c.063.475.276.934.641 1.299.365.365.824.578 1.3.64l3.318-3.319a.75.75 0 0 1 1.248.313 5.25 5.25 0 0 1-5.472 6.756c-1.018-.086-1.87.1-2.309.634L7.344 21.3A3.298 3.298 0 1 1 2.7 16.657l8.684-7.151c.533-.44.72-1.291.634-2.309A5.342 5.342 0 0 1 12 6.75ZM4.117 19.125a.75.75 0 0 1 .75-.75h.008a.75.75 0 0 1 .75.75v.008a.75.75 0 0 1-.75.75h-.008a.75.75 0 0 1-.75-.75v-.008Z"),m(t,"clip-rule","evenodd"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 24 24"),m(e,"fill","currentColor"),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function qf(n,e,t){let{className:l="size-4"}=e;return n.$$set=o=>{"className"in o&&t(0,l=o.className)},[l]}class Jf extends ke{constructor(e){super(),Ee(this,e,qf,Gf,Se,{className:0})}}function Fs(n,e,t){const l=n.slice();return l[17]=e[t],l[18]=e,l[19]=t,l}function Qf(n){let e;const t=n[9].default,l=dt(t,n,n[16],null);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,s){l&&l.p&&(!e||s&65536)&&ht(l,t,o,o[16],e?gt(t,o[16],s,null):mt(o[16]),null)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function xf(n){let e,t;return e=new pn({props:{content:n[7].t("More"),$$slots:{default:[Qf]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&128&&(s.content=l[7].t("More")),o&65536&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function js(n){let e,t,l,o,s=pt(Object.keys(n[1])),r=[];for(let a=0;aB(r[a],1,1,()=>{r[a]=null});return{c(){e=O("div");for(let a=0;alt(i,"state",f)),i.$on("change",h),{c(){e=O("div"),t=O("div"),re(l.$$.fragment),o=te(),re(s.$$.fragment),r=te(),re(i.$$.fragment),u=te(),this.h()},l(v){e=H(v,"DIV",{class:!0});var p=T(e);t=H(p,"DIV",{class:!0});var g=T(t);ce(l.$$.fragment,g),o=ne(g),ce(s.$$.fragment,g),g.forEach(b),r=ne(p),ce(i.$$.fragment,p),u=ne(p),p.forEach(b),this.h()},h(){m(t,"class","flex-1 flex items-center gap-2"),m(e,"class","flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer rounded-xl")},m(v,p){W(v,e,p),I(e,t),ae(l,t,null),I(t,o),ae(s,t,null),I(e,r),ae(i,e,null),I(e,u),c=!0},p(v,p){var k;n=v;const g={};p&2&&(g.content=((k=n[1][n[17]])==null?void 0:k.description)??""),p&65538&&(g.$$scope={dirty:p,ctx:n}),s.$set(g);const y={};!a&&p&2&&(a=!0,y.state=n[1][n[17]].enabled,nt(()=>a=!1)),i.$set(y)},i(v){c||(P(l.$$.fragment,v),P(s.$$.fragment,v),P(i.$$.fragment,v),c=!0)},o(v){B(l.$$.fragment,v),B(s.$$.fragment,v),B(i.$$.fragment,v),c=!1},d(v){v&&b(e),ue(l),ue(s),ue(i)}}}function Xs(n){let e,t,l,o,s,r=n[7].t("Web Search")+"",i,a,u,c,f,h,d;l=new Zf({});function _(p){n[12](p)}let v={};return n[2]!==void 0&&(v.state=n[2]),u=new Yr({props:v}),Be.push(()=>lt(u,"state",_)),{c(){e=O("div"),t=O("div"),re(l.$$.fragment),o=te(),s=O("div"),i=De(r),a=te(),re(u.$$.fragment),f=te(),h=O("hr"),this.h()},l(p){e=H(p,"DIV",{class:!0});var g=T(e);t=H(g,"DIV",{class:!0});var y=T(t);ce(l.$$.fragment,y),o=ne(y),s=H(y,"DIV",{class:!0});var k=T(s);i=ze(k,r),k.forEach(b),y.forEach(b),a=ne(g),ce(u.$$.fragment,g),g.forEach(b),f=ne(p),h=H(p,"HR",{class:!0}),this.h()},h(){m(s,"class","line-clamp-1"),m(t,"class","flex-1 flex items-center gap-2"),m(e,"class","flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer rounded-xl"),m(h,"class","border-gray-100 dark:border-gray-800 my-1")},m(p,g){W(p,e,g),I(e,t),ae(l,t,null),I(t,o),I(t,s),I(s,i),I(e,a),ae(u,e,null),W(p,f,g),W(p,h,g),d=!0},p(p,g){(!d||g&128)&&r!==(r=p[7].t("Web Search")+"")&&Oe(i,r);const y={};!c&&g&4&&(c=!0,y.state=p[2],nt(()=>c=!1)),u.$set(y)},i(p){d||(P(l.$$.fragment,p),P(u.$$.fragment,p),d=!0)},o(p){B(l.$$.fragment,p),B(u.$$.fragment,p),d=!1},d(p){p&&(b(e),b(f),b(h)),ue(l),ue(u)}}}function ed(n){let e,t,l,o=n[7].t("Upload Files")+"",s,r;return e=new Yf({}),{c(){re(e.$$.fragment),t=te(),l=O("div"),s=De(o),this.h()},l(i){ce(e.$$.fragment,i),t=ne(i),l=H(i,"DIV",{class:!0});var a=T(l);s=ze(a,o),a.forEach(b),this.h()},h(){m(l,"class","line-clamp-1")},m(i,a){ae(e,i,a),W(i,t,a),W(i,l,a),I(l,s),r=!0},p(i,a){(!r||a&128)&&o!==(o=i[7].t("Upload Files")+"")&&Oe(s,o)},i(i){r||(P(e.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),r=!1},d(i){i&&(b(t),b(l)),ue(e,i)}}}function td(n){var a,u;let e=Object.keys(n[1]).length>0,t,l,o,s,r=e&&js(n),i=((u=(a=n[6])==null?void 0:a.features)==null?void 0:u.enable_web_search)&&Xs(n);return o=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl",$$slots:{default:[ed]},$$scope:{ctx:n}}}),o.$on("click",n[13]),{c(){r&&r.c(),t=te(),i&&i.c(),l=te(),re(o.$$.fragment)},l(c){r&&r.l(c),t=ne(c),i&&i.l(c),l=ne(c),ce(o.$$.fragment,c)},m(c,f){r&&r.m(c,f),W(c,t,f),i&&i.m(c,f),W(c,l,f),ae(o,c,f),s=!0},p(c,f){var d,_;f&2&&(e=Object.keys(c[1]).length>0),e?r?(r.p(c,f),f&2&&P(r,1)):(r=js(c),r.c(),P(r,1),r.m(t.parentNode,t)):r&&(je(),B(r,1,1,()=>{r=null}),Ye()),(_=(d=c[6])==null?void 0:d.features)!=null&&_.enable_web_search?i?(i.p(c,f),f&64&&P(i,1)):(i=Xs(c),i.c(),P(i,1),i.m(l.parentNode,l)):i&&(je(),B(i,1,1,()=>{i=null}),Ye());const h={};f&65664&&(h.$$scope={dirty:f,ctx:c}),o.$set(h)},i(c){s||(P(r),P(i),P(o.$$.fragment,c),s=!0)},o(c){B(r),B(i),B(o.$$.fragment,c),s=!1},d(c){c&&(b(t),b(l)),r&&r.d(c),i&&i.d(c),ue(o,c)}}}function nd(n){let e,t,l;return t=new po({props:{class:"w-full max-w-[200px] rounded-xl px-1 py-1 border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow",sideOffset:15,alignOffset:-8,side:"top",align:"start",transition:Wl,$$slots:{default:[td]},$$scope:{ctx:n}}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{slot:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"slot","content")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p(o,s){const r={};s&65743&&(r.$$scope={dirty:s,ctx:o}),t.$set(r)},i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function ld(n){let e,t,l;function o(r){n[14](r)}let s={$$slots:{content:[nd],default:[xf]},$$scope:{ctx:n}};return n[5]!==void 0&&(s.show=n[5]),e=new yo({props:s}),Be.push(()=>lt(e,"show",o)),e.$on("change",n[15]),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),l=!0},p(r,[i]){const a={};i&65743&&(a.$$scope={dirty:i,ctx:r}),!t&&i&32&&(t=!0,a.show=r[5],nt(()=>t=!1)),e.$set(a)},i(r){l||(P(e.$$.fragment,r),l=!0)},o(r){B(e.$$.fragment,r),l=!1},d(r){ue(e,r)}}}function od(n,e,t){let l,o;se(n,El,w=>t(6,l=w));let{$$slots:s={},$$scope:r}=e;const i=Lt("i18n");se(n,i,w=>t(7,o=w));let{uploadFilesHandler:a}=e,{selectedToolIds:u=[]}=e,{webSearchEnabled:c}=e,{tools:f={}}=e,{onClose:h}=e,d=!1;function _(w,N){n.$$.not_equal(f[N].enabled,w)&&(f[N].enabled=w,t(1,f),t(0,u))}const v=(w,N)=>{t(0,u=N.detail?[...u,w]:u.filter(S=>S!==w))};function p(w){c=w,t(2,c)}const g=()=>{a()};function y(w){d=w,t(5,d)}const k=w=>{w.detail===!1&&h()};return n.$$set=w=>{"uploadFilesHandler"in w&&t(3,a=w.uploadFilesHandler),"selectedToolIds"in w&&t(0,u=w.selectedToolIds),"webSearchEnabled"in w&&t(2,c=w.webSearchEnabled),"tools"in w&&t(1,f=w.tools),"onClose"in w&&t(4,h=w.onClose),"$$scope"in w&&t(16,r=w.$$scope)},n.$$.update=()=>{n.$$.dirty&3&&t(1,f=Object.fromEntries(Object.keys(f).map(w=>[w,{...f[w],enabled:u.includes(w)}])))},[u,f,c,a,h,d,l,o,i,s,_,v,p,g,y,k,r]}class sd extends ke{constructor(e){super(),Ee(this,e,od,ld,Se,{uploadFilesHandler:3,selectedToolIds:0,webSearchEnabled:2,tools:1,onClose:4})}}function id(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{"aria-hidden":!0,xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var o=T(e);t=Ve(o,"path",{"fill-rule":!0,d:!0,"clip-rule":!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"fill-rule","evenodd"),m(t,"d","M12 5a7 7 0 0 0-7 7v1.17c.313-.11.65-.17 1-.17h2a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H6a3 3 0 0 1-3-3v-6a9 9 0 0 1 18 0v6a3 3 0 0 1-3 3h-2a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h2c.35 0 .687.06 1 .17V12a7 7 0 0 0-7-7Z"),m(t,"clip-rule","evenodd"),m(e,"aria-hidden","true"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"fill","currentColor"),m(e,"viewBox","0 0 24 24"),m(e,"stroke-width",n[1]),m(e,"stroke","currentColor"),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&2&&m(e,"stroke-width",l[1]),o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function rd(n,e,t){let{className:l="w-4 h-4"}=e,{strokeWidth:o="0"}=e;return n.$$set=s=>{"className"in s&&t(0,l=s.className),"strokeWidth"in s&&t(1,o=s.strokeWidth)},[l,o]}class ad extends ke{constructor(e){super(),Ee(this,e,rd,id,Se,{className:0,strokeWidth:1})}}function Ks(n,e,t){const l=n.slice();return l[30]=e[t],l}function Zs(n){let e,t;return{c(){e=O("div"),this.h()},l(l){e=H(l,"DIV",{class:!0,style:!0}),T(e).forEach(b),this.h()},h(){m(e,"class",t="w-[2px] "+(n[0]?" bg-gray-500 dark:bg-gray-400 ":"bg-indigo-500 dark:bg-indigo-400 ")+" inline-block h-full"),Ze(e,"height",Math.min(100,Math.max(14,n[30]*100))+"%")},m(l,o){W(l,e,o)},p(l,o){o[0]&1&&t!==(t="w-[2px] "+(l[0]?" bg-gray-500 dark:bg-gray-400 ":"bg-indigo-500 dark:bg-indigo-400 ")+" inline-block h-full")&&m(e,"class",t),o[0]&4&&Ze(e,"height",Math.min(100,Math.max(14,l[30]*100))+"%")},d(l){l&&b(e)}}}function ud(n){let e,t='',l,o;return{c(){e=O("button"),e.innerHTML=t,this.h()},l(s){e=H(s,"BUTTON",{type:!0,class:!0,"data-svelte-h":!0}),ut(e)!=="svelte-1qzkal"&&(e.innerHTML=t),this.h()},h(){m(e,"type","button"),m(e,"class","p-1.5 bg-indigo-500 text-white dark:bg-indigo-500 dark:text-blue-950 rounded-full")},m(s,r){W(s,e,r),l||(o=he(e,"click",n[10]),l=!0)},p:we,d(s){s&&b(e),l=!1,o()}}}function cd(n){let e,t=``;return{c(){e=O("div"),e.innerHTML=t,this.h()},l(l){e=H(l,"DIV",{class:!0,"data-svelte-h":!0}),ut(e)!=="svelte-otpw2s"&&(e.innerHTML=t),this.h()},h(){m(e,"class","text-gray-500 rounded-full cursor-not-allowed")},m(l,o){W(l,e,o)},p:we,d(l){l&&b(e)}}}function fd(n){let e,t,l,o,s,r,i,a,u,c,f,h,d=n[5](n[1])+"",_,v,p,g,y,k,w,N=pt(n[2].slice().reverse()),S=[];for(let V=0;Vt(19,o=D)),se(n,El,D=>t(20,s=D));const r=Lt("i18n");se(n,r,D=>t(18,l=D));const i=en();let{recording:a=!1}=e,u=!1,c=!1,f=0,h=null,d="";const _=()=>{h=setInterval(()=>{t(1,f++,f)},1e3)},v=()=>{clearInterval(h),t(1,f=0)},p=D=>{const U=Math.floor(D/60),F=D%60,C=F<10?`0${F}`:F;return`${U}:${C}`};let g,y,k,w=[];const N=-45;let S=Array(Gs).fill(0);const A=D=>{let U=0;for(let F=0;F{D=D*10;const F=Math.pow(D,1.5);return Math.min(1,Math.max(.01,F))},M=D=>{const U=new AudioContext,F=U.createMediaStreamSource(D),C=U.createAnalyser();C.minDecibels=N,F.connect(C);const R=C.frequencyBinCount,G=new Uint8Array(R),J=new Uint8Array(C.fftSize);(()=>{const ee=()=>{if(!(!a||u)){if(a&&!u){C.getByteTimeDomainData(J),C.getByteFrequencyData(G);const j=A(J);S.push(z(j)),S.length>=Gs&&S.shift(),t(2,S)}window.requestAnimationFrame(ee)}};window.requestAnimationFrame(ee)})()},V=async D=>{await Je();const U=xo(D,"recording.wav"),F=await es(localStorage.token,U).catch(C=>($e.error(C),null));F&&(console.log(F.text),i("confirm",F.text))},L=async()=>{var D,U;if(_(),g=await navigator.mediaDevices.getUserMedia({audio:!0}),k=new MediaRecorder(g),k.onstart=()=>{console.log("Recording started"),w=[],M(g)},k.ondataavailable=F=>w.push(F.data),k.onstop=async()=>{var F,C;if(console.log("Recording stopped"),(((C=(F=o==null?void 0:o.audio)==null?void 0:F.stt)==null?void 0:C.engine)??"")==="web")w=[];else{if(c){const R=new Blob(w,{type:"audio/wav"});await V(R),c=!1,t(0,u=!1)}w=[],t(8,a=!1)}},k.start(),(s.audio.stt.engine==="web"||(((U=(D=o==null?void 0:o.audio)==null?void 0:D.stt)==null?void 0:U.engine)??"")==="web")&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){y=new(window.SpeechRecognition||window.webkitSpeechRecognition),y.continuous=!0;const F=2e3;let C;y.start(),y.onresult=async R=>{var J;clearTimeout(C),console.log(R);const G=R.results[Object.keys(R.results).length-1][0].transcript;d=`${d}${G}`,await Je(),(J=document.getElementById("chat-textarea"))==null||J.focus(),C=setTimeout(()=>{console.log("Speech recognition turned off due to inactivity."),y.stop()},F)},y.onend=function(){console.log("recognition ended"),K(),i("confirm",d),c=!1,t(0,u=!1)},y.onerror=function(R){console.log(R),$e.error(l.t("Speech recognition error: {{error}}",{error:R.error})),i("cancel"),Y()}}},Y=async()=>{a&&k&&await k.stop(),v(),w=[],g&&g.getTracks().forEach(U=>U.stop()),g=null},K=async()=>{t(0,u=!0),c=!0,a&&k&&await k.stop(),clearInterval(h)},E=async()=>{i("cancel"),Y()},q=async()=>{await K()};return n.$$set=D=>{"recording"in D&&t(8,a=D.recording)},n.$$.update=()=>{n.$$.dirty[0]&256&&(a?L():Y())},[u,f,S,r,i,p,Y,K,a,E,q]}class hd extends ke{constructor(e){super(),Ee(this,e,dd,fd,Se,{recording:8},null,[-1,-1])}}function qs(n){let e,t,l,o,s,r,i;return s=new Xu({}),{c(){e=O("div"),t=O("div"),l=O("div"),o=O("div"),re(s.$$.fragment),this.h()},l(a){e=H(a,"DIV",{class:!0,id:!0,role:!0,"aria-label":!0});var u=T(e);t=H(u,"DIV",{class:!0});var c=T(t);l=H(c,"DIV",{class:!0});var f=T(l);o=H(f,"DIV",{class:!0});var h=T(o);ce(s.$$.fragment,h),h.forEach(b),f.forEach(b),c.forEach(b),u.forEach(b),this.h()},h(){m(o,"class","max-w-md"),m(l,"class","m-auto pt-64 flex flex-col justify-center"),m(t,"class","absolute w-full h-full backdrop-blur bg-gray-800/40 flex justify-center"),m(e,"class",r="fixed "+(n[2]?"left-0 md:left-[260px] md:w-[calc(100%-260px)]":"left-0")+" fixed top-0 right-0 bottom-0 w-full h-full flex z-[9999] touch-none pointer-events-none"),m(e,"id","dropzone"),m(e,"role","region"),m(e,"aria-label","Drag and Drop Container")},m(a,u){W(a,e,u),I(e,t),I(t,l),I(l,o),ae(s,o,null),n[3](e),i=!0},p(a,u){(!i||u&4&&r!==(r="fixed "+(a[2]?"left-0 md:left-[260px] md:w-[calc(100%-260px)]":"left-0")+" fixed top-0 right-0 bottom-0 w-full h-full flex z-[9999] touch-none pointer-events-none"))&&m(e,"class",r)},i(a){i||(P(s.$$.fragment,a),i=!0)},o(a){B(s.$$.fragment,a),i=!1},d(a){a&&b(e),ue(s),n[3](null)}}}function md(n){let e,t,l=n[0]&&qs(n);return{c(){l&&l.c(),e=Le()},l(o){l&&l.l(o),e=Le()},m(o,s){l&&l.m(o,s),W(o,e,s),t=!0},p(o,[s]){o[0]?l?(l.p(o,s),s&1&&P(l,1)):(l=qs(o),l.c(),P(l,1),l.m(e.parentNode,e)):l&&(je(),B(l,1,1,()=>{l=null}),Ye())},i(o){t||(P(l),t=!0)},o(o){B(l),t=!1},d(o){o&&b(e),l&&l.d(o)}}}function gd(n,e,t){let l;se(n,uo,i=>t(2,l=i));let{show:o=!1}=e,s=null;function r(i){Be[i?"unshift":"push"](()=>{s=i,t(1,s)})}return n.$$set=i=>{"show"in i&&t(0,o=i.show)},n.$$.update=()=>{n.$$.dirty&3&&(o&&s?(document.body.appendChild(s),document.body.style.overflow="hidden"):s&&(document.body.removeChild(s),document.body.style.overflow="unset"))},[o,s,l,r]}class _d extends ke{constructor(e){super(),Ee(this,e,gd,md,Se,{show:0})}}function Js(n,e,t){const l=n.slice();return l[0]=e[t],l[14]=t,l}function Qs(n){let e,t,l,o='
/
',s,r,i,a,u,c,f='',h,d,_=n[3].t("Tip: Update multiple variable slots consecutively by pressing the tab key in the chat input after each replacement.")+"",v,p=pt(n[2]),g=[];for(let y=0;y0&&Qs(n);return{c(){t&&t.c(),e=Le()},l(l){t&&t.l(l),e=Le()},m(l,o){t&&t.m(l,o),W(l,e,o)},p(l,[o]){l[2].length>0?t?t.p(l,o):(t=Qs(l),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:we,o:we,d(l){l&&b(e),t&&t.d(l)}}}const pd=()=>{};function vd(n,e,t){let l,o;se(n,lu,p=>t(10,o=p));const s=Lt("i18n");se(n,s,p=>t(3,l=p));let{files:r}=e,{prompt:i=""}=e,{command:a=""}=e,u=0,c=[];const f=()=>{t(1,u=Math.max(0,u-1))},h=()=>{t(1,u=Math.min(u+1,c.length-1))},d=async p=>{let g=p.content;if(p.content.includes("{{CLIPBOARD}}")){const w=await navigator.clipboard.readText().catch(A=>($e.error(l.t("Failed to read clipboard contents")),"{{CLIPBOARD}}")),N=await navigator.clipboard.read();let S=null;for(const A of N)for(const z of A.types)if(z.startsWith("image/")){const M=await A.getType(z);S=URL.createObjectURL(M)}S&&t(6,r=[...r,{type:"image",url:S}]),g=g.replaceAll("{{CLIPBOARD}}",w)}if(p.content.includes("{{USER_LOCATION}}")){const w=await mu();g=g.replaceAll("{{USER_LOCATION}}",String(w))}if(p.content.includes("{{USER_LANGUAGE}}")){const w=localStorage.getItem("locale")||"en-US";g=g.replaceAll("{{USER_LANGUAGE}}",w)}if(p.content.includes("{{CURRENT_DATE}}")){const w=gu();g=g.replaceAll("{{CURRENT_DATE}}",w)}if(p.content.includes("{{CURRENT_TIME}}")){const w=_u();g=g.replaceAll("{{CURRENT_TIME}}",w)}if(p.content.includes("{{CURRENT_DATETIME}}")){const w=bu();g=g.replaceAll("{{CURRENT_DATETIME}}",w)}if(p.content.includes("{{CURRENT_TIMEZONE}}")){const w=pu();g=g.replaceAll("{{CURRENT_TIMEZONE}}",w)}if(p.content.includes("{{CURRENT_WEEKDAY}}")){const w=vu();g=g.replaceAll("{{CURRENT_WEEKDAY}}",w)}t(0,i=g);const y=document.getElementById("chat-textarea");await Je(),y.style.height="",y.style.height=Math.min(y.scrollHeight,200)+"px",y==null||y.focus(),await Je();const k=jr(i);if(k.length>0){const w=k.at(0);y.setSelectionRange(w==null?void 0:w.startIndex,w.endIndex+1)}},_=p=>{d(p)},v=p=>{t(1,u=p)};return n.$$set=p=>{"files"in p&&t(6,r=p.files),"prompt"in p&&t(0,i=p.prompt),"command"in p&&t(7,a=p.command)},n.$$.update=()=>{n.$$.dirty&1152&&t(2,c=o.filter(p=>p.command.toLowerCase().includes(a.toLowerCase())).sort((p,g)=>p.title.localeCompare(g.title))),n.$$.dirty&128&&a&&t(1,u=0)},[i,u,c,l,s,d,r,a,f,h,o,_,v]}class yd extends ke{constructor(e){super(),Ee(this,e,vd,bd,Se,{files:6,prompt:0,command:7,selectUp:8,selectDown:9})}get selectUp(){return this.$$.ctx[8]}get selectDown(){return this.$$.ctx[9]}}function $s(n,e,t){const l=n.slice();return l[21]=e[t],l[23]=t,l}function ei(n){let e,t,l,o='
#
',s,r,i,a,u,c,f=pt(n[3]),h=[];for(let p=0;p0||((s=(o=n[0].split(" "))==null?void 0:o.at(0))==null?void 0:s.substring(1).startsWith("http")),t,l=e&&ei(n);return{c(){l&&l.c(),t=Le()},l(r){l&&l.l(r),t=Le()},m(r,i){l&&l.m(r,i),W(r,t,i)},p(r,[i]){var a,u;i&9&&(e=r[3].length>0||((u=(a=r[0].split(" "))==null?void 0:a.at(0))==null?void 0:u.substring(1).startsWith("http"))),e?l?l.p(r,i):(l=ei(r),l.c(),l.m(t.parentNode,t)):l&&(l.d(1),l=null)},i:we,o:we,d(r){r&&b(t),l&&l.d(r)}}}const Cd=n=>n.substring(1).startsWith("https://www.youtube.com")||n.substring(1).startsWith("https://youtu.be"),Dd=()=>{};function zd(n,e,t){let l,o,s;se(n,ou,z=>t(14,o=z));const r=Lt("i18n");se(n,r,z=>t(1,s=z));let{prompt:i=""}=e,{command:a=""}=e;const u=en();let c=0,f=[],h=[],d=[];const _=(z,M)=>{var L,Y;return z.name.toLowerCase().includes(((Y=(L=M.toLowerCase().split(" "))==null?void 0:L.at(0))==null?void 0:Y.substring(1))??"")},v=()=>{t(2,c=Math.max(0,c-1))},p=()=>{t(2,c=Math.min(c+1,f.length-1))},g=async z=>{u("select",z),t(0,i=so(i,a));const M=document.getElementById("chat-textarea");await Je(),M==null||M.focus(),await Je()},y=async z=>{u("url",z),t(0,i=so(i,a));const M=document.getElementById("chat-textarea");await Je(),M==null||M.focus(),await Je()},k=async z=>{u("youtube",z),t(0,i=so(i,a));const M=document.getElementById("chat-textarea");await Je(),M==null||M.focus(),await Je()},w=z=>{console.log(z),g(z)},N=z=>{t(2,c=z)},S=()=>{var M,V;const z=(V=(M=i.split(" "))==null?void 0:M.at(0))==null?void 0:V.substring(1);ms(z)?k(z):$e.error(s.t("Oops! Looks like the URL is invalid. Please double-check and try again."))},A=()=>{var M,V;const z=(V=(M=i.split(" "))==null?void 0:M.at(0))==null?void 0:V.substring(1);ms(z)?y(z):$e.error(s.t("Oops! Looks like the URL is invalid. Please double-check and try again."))};return n.$$set=z=>{"prompt"in z&&t(0,i=z.prompt),"command"in z&&t(8,a=z.command)},n.$$.update=()=>{n.$$.dirty&16386&&t(12,d=[...o.length>0?[{name:"All Documents",type:"collection",title:s.t("All Documents"),collection_names:o.map(z=>z.collection_name)}]:[],...o.reduce((z,M,V,L)=>{var Y;return[...new Set([...z,...(((Y=M==null?void 0:M.content)==null?void 0:Y.tags)??[]).map(K=>K.name)])]},[]).map(z=>({name:z,type:"collection",collection_names:o.filter(M=>{var V;return(((V=M==null?void 0:M.content)==null?void 0:V.tags)??[]).map(L=>L.name).includes(z)}).map(M=>M.collection_name)}))]),n.$$.dirty&4352&&t(13,l=d.filter(z=>_(z,a)).sort((z,M)=>z.name.localeCompare(M.name))),n.$$.dirty&16640&&t(11,h=o.filter(z=>_(z,a)).sort((z,M)=>z.title.localeCompare(M.title))),n.$$.dirty&10240&&t(3,f=[...l,...h]),n.$$.dirty&8448&&a&&(t(2,c=0),console.log(l))},[i,s,c,f,r,g,y,k,a,v,p,h,d,l,o,w,N,S,A]}class Md extends ke{constructor(e){super(),Ee(this,e,zd,Id,Se,{prompt:0,command:8,selectUp:9,selectDown:10})}get selectUp(){return this.$$.ctx[9]}get selectDown(){return this.$$.ctx[10]}}function ni(n,e,t){const l=n.slice();return l[11]=e[t],l[13]=t,l}function li(n){let e,t,l,o='
@
',s,r,i,a=pt(n[1]),u=[];for(let c=0;c0&&li(n);return{c(){t&&t.c(),e=Le()},l(l){t&&t.l(l),e=Le()},m(l,o){t&&t.m(l,o),W(l,e,o)},p(l,[o]){l[1].length>0?t?t.p(l,o):(t=li(l),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:we,o:we,d(l){l&&b(e),t&&t.d(l)}}}const Pd=()=>{};function Vd(n,e,t){let l;se(n,Sl,d=>t(6,l=d)),Lt("i18n");const o=en();let{command:s=""}=e,r=0,i=[];const a=()=>{t(0,r=Math.max(0,r-1))},u=()=>{t(0,r=Math.min(r+1,i.length-1))},c=async d=>{t(3,s=""),o("select",d)};un(async()=>{await Je();const d=document.getElementById("chat-textarea");await Je(),d==null||d.focus(),await Je()});const f=d=>{c(d)},h=d=>{t(0,r=d)};return n.$$set=d=>{"command"in d&&t(3,s=d.command)},n.$$.update=()=>{n.$$.dirty&72&&t(1,i=l.filter(d=>{var _,v;return d.name.toLowerCase().includes(((v=(_=s.toLowerCase().split(" "))==null?void 0:_.at(0))==null?void 0:v.substring(1))??"")}).sort((d,_)=>d.name.localeCompare(_.name))),n.$$.dirty&8&&s&&t(0,r=0)},[r,i,c,s,a,u,l,f,h]}class Nd extends ke{constructor(e){super(),Ee(this,e,Vd,Td,Se,{command:3,selectUp:4,selectDown:5})}get selectUp(){return this.$$.ctx[4]}get selectDown(){return this.$$.ctx[5]}}function si(n){let e,t,l,o,s,r,i;const a=[Ld,Hd,Od],u=[];function c(f,h){var d,_,v;return h&8&&(e=null),h&8&&(t=null),h&8&&(l=null),e==null&&(e=((d=f[3])==null?void 0:d.charAt(0))==="/"),e?0:(t==null&&(t=((_=f[3])==null?void 0:_.charAt(0))==="#"),t?1:(l==null&&(l=((v=f[3])==null?void 0:v.charAt(0))==="@"),l?2:-1))}return~(o=c(n,-1))&&(s=u[o]=a[o](n)),{c(){s&&s.c(),r=Le()},l(f){s&&s.l(f),r=Le()},m(f,h){~o&&u[o].m(f,h),W(f,r,h),i=!0},p(f,h){let d=o;o=c(f,h),o===d?~o&&u[o].p(f,h):(s&&(je(),B(u[d],1,1,()=>{u[d]=null}),Ye()),~o?(s=u[o],s?s.p(f,h):(s=u[o]=a[o](f),s.c()),P(s,1),s.m(r.parentNode,r)):s=null)},i(f){i||(P(s),i=!0)},o(f){B(s),i=!1},d(f){f&&b(r),~o&&u[o].d(f)}}}function Od(n){let e,t,l={command:n[3]};return e=new Nd({props:l}),n[17](e),e.$on("select",n[18]),{c(){re(e.$$.fragment)},l(o){ce(e.$$.fragment,o)},m(o,s){ae(e,o,s),t=!0},p(o,s){const r={};s&8&&(r.command=o[3]),e.$set(r)},i(o){t||(P(e.$$.fragment,o),t=!0)},o(o){B(e.$$.fragment,o),t=!1},d(o){n[17](null),ue(e,o)}}}function Hd(n){let e,t,l;function o(r){n[13](r)}let s={command:n[3]};return n[0]!==void 0&&(s.prompt=n[0]),e=new Md({props:s}),n[12](e),Be.push(()=>lt(e,"prompt",o)),e.$on("youtube",n[14]),e.$on("url",n[15]),e.$on("select",n[16]),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),l=!0},p(r,i){const a={};i&8&&(a.command=r[3]),!t&&i&1&&(t=!0,a.prompt=r[0],nt(()=>t=!1)),e.$set(a)},i(r){l||(P(e.$$.fragment,r),l=!0)},o(r){B(e.$$.fragment,r),l=!1},d(r){n[12](null),ue(e,r)}}}function Ld(n){let e,t,l,o;function s(a){n[10](a)}function r(a){n[11](a)}let i={command:n[3]};return n[0]!==void 0&&(i.prompt=n[0]),n[1]!==void 0&&(i.files=n[1]),e=new yd({props:i}),n[9](e),Be.push(()=>lt(e,"prompt",s)),Be.push(()=>lt(e,"files",r)),{c(){re(e.$$.fragment)},l(a){ce(e.$$.fragment,a)},m(a,u){ae(e,a,u),o=!0},p(a,u){const c={};u&8&&(c.command=a[3]),!t&&u&1&&(t=!0,c.prompt=a[0],nt(()=>t=!1)),!l&&u&2&&(l=!0,c.files=a[1],nt(()=>l=!1)),e.$set(c)},i(a){o||(P(e.$$.fragment,a),o=!0)},o(a){B(e.$$.fragment,a),o=!1},d(a){n[9](null),ue(e,a)}}}function Ad(n){var s;let e=["/","#","@"].includes((s=n[3])==null?void 0:s.charAt(0)),t,l,o=e&&si(n);return{c(){o&&o.c(),t=Le()},l(r){o&&o.l(r),t=Le()},m(r,i){o&&o.m(r,i),W(r,t,i),l=!0},p(r,[i]){var a;i&8&&(e=["/","#","@"].includes((a=r[3])==null?void 0:a.charAt(0))),e?o?(o.p(r,i),i&8&&P(o,1)):(o=si(r),o.c(),P(o,1),o.m(t.parentNode,t)):o&&(je(),B(o,1,1,()=>{o=null}),Ye())},i(r){l||(P(o),l=!0)},o(r){B(o),l=!1},d(r){r&&b(t),o&&o.d(r)}}}function Bd(n,e,t){const l=en();let{prompt:o=""}=e,{files:s=[]}=e,r=null;const i=()=>{r==null||r.selectUp()},a=()=>{r==null||r.selectDown()};let u="";const c=async S=>{console.log(S);const A={type:"doc",name:S,collection_name:"",status:!1,url:S,error:""};try{t(1,s=[...s,A]);const z=await zu(localStorage.token,"",S);z&&(A.status="processed",A.collection_name=z.collection_name,t(1,s))}catch(z){t(1,s=s.filter(M=>M.name!==S)),$e.error(z)}},f=async S=>{console.log(S);const A={type:"doc",name:S,collection_name:"",status:!1,url:S,error:""};try{t(1,s=[...s,A]);const z=await Mu(localStorage.token,S);z&&(A.status="processed",A.collection_name=z.collection_name,t(1,s))}catch(z){t(1,s=s.filter(M=>M.name!==S)),$e.error(z)}};function h(S){Be[S?"unshift":"push"](()=>{r=S,t(2,r)})}function d(S){o=S,t(0,o)}function _(S){s=S,t(1,s)}function v(S){Be[S?"unshift":"push"](()=>{r=S,t(2,r)})}function p(S){o=S,t(0,o)}const g=S=>{console.log(S),f(S.detail)},y=S=>{console.log(S),c(S.detail)},k=S=>{var A;console.log(S),t(1,s=[...s,{type:((A=S==null?void 0:S.detail)==null?void 0:A.type)??"file",...S.detail,status:"processed"}]),l("select")};function w(S){Be[S?"unshift":"push"](()=>{r=S,t(2,r)})}const N=S=>{t(0,o=so(o,u)),l("select",{type:"model",data:S.detail})};return n.$$set=S=>{"prompt"in S&&t(0,o=S.prompt),"files"in S&&t(1,s=S.files)},n.$$.update=()=>{var S;n.$$.dirty&1&&t(3,u=((S=((o==null?void 0:o.trim())??"").split(" "))==null?void 0:S.at(-1))??"")},[o,s,r,u,l,c,f,i,a,h,d,_,v,p,g,y,k,w,N]}class Rd extends ke{constructor(e){super(),Ee(this,e,Bd,Ad,Se,{prompt:0,files:1,selectUp:7,selectDown:8})}get selectUp(){return this.$$.ctx[7]}get selectDown(){return this.$$.ctx[8]}}function ii(n,e,t){const l=n.slice();return l[66]=e[t],l[68]=t,l}function ri(n){let e,t,l='',o,s;return{c(){e=O("div"),t=O("button"),t.innerHTML=l,this.h()},l(r){e=H(r,"DIV",{class:!0});var i=T(e);t=H(i,"BUTTON",{class:!0,"data-svelte-h":!0}),ut(t)!=="svelte-txgoc3"&&(t.innerHTML=l),i.forEach(b),this.h()},h(){m(t,"class","bg-white border border-gray-100 dark:border-none dark:bg-white/20 p-1.5 rounded-full pointer-events-auto"),m(e,"class","absolute -top-12 left-0 right-0 flex justify-center z-30 pointer-events-none")},m(r,i){W(r,e,i),I(e,t),o||(s=he(t,"click",n[32]),o=!0)},p:we,d(r){r&&b(e),o=!1,s()}}}function ai(n){let e,t,l,o,s,r,i,a,u=n[0].name+"",c,f,h,d,_,v,p,g;return _=new $o({}),{c(){e=O("div"),t=O("div"),l=O("img"),s=te(),r=O("div"),i=De("Talking to "),a=O("span"),c=De(u),f=te(),h=O("div"),d=O("button"),re(_.$$.fragment),this.h()},l(y){e=H(y,"DIV",{class:!0});var k=T(e);t=H(k,"DIV",{class:!0});var w=T(t);l=H(w,"IMG",{crossorigin:!0,alt:!0,class:!0,src:!0}),s=ne(w),r=H(w,"DIV",{});var N=T(r);i=ze(N,"Talking to "),a=H(N,"SPAN",{class:!0});var S=T(a);c=ze(S,u),S.forEach(b),N.forEach(b),w.forEach(b),f=ne(k),h=H(k,"DIV",{});var A=T(h);d=H(A,"BUTTON",{class:!0});var z=T(d);ce(_.$$.fragment,z),z.forEach(b),A.forEach(b),k.forEach(b),this.h()},h(){var y,k,w;m(l,"crossorigin","anonymous"),m(l,"alt","model profile"),m(l,"class","size-5 max-w-[28px] object-cover rounded-full"),Gn(l.src,o=((w=(k=(y=n[14].find(n[33]))==null?void 0:y.info)==null?void 0:k.meta)==null?void 0:w.profile_image_url)??(n[22].language==="dg-DG"?"/doge.png":`${Nl}/static/favicon.png`))||m(l,"src",o),m(a,"class","font-medium"),m(t,"class","flex items-center gap-2 text-sm dark:text-gray-500"),m(d,"class","flex items-center"),m(e,"class","px-3 py-2.5 text-left w-full flex justify-between items-center absolute bottom-0.5 left-0 right-0 bg-gradient-to-t from-50% from-white dark:from-gray-900 z-10")},m(y,k){W(y,e,k),I(e,t),I(t,l),I(t,s),I(t,r),I(r,i),I(r,a),I(a,c),I(e,f),I(e,h),I(h,d),ae(_,d,null),v=!0,p||(g=he(d,"click",n[34]),p=!0)},p(y,k){var w,N,S;(!v||k[0]&4210689&&!Gn(l.src,o=((S=(N=(w=y[14].find(y[33]))==null?void 0:w.info)==null?void 0:N.meta)==null?void 0:S.profile_image_url)??(y[22].language==="dg-DG"?"/doge.png":`${Nl}/static/favicon.png`)))&&m(l,"src",o),(!v||k[0]&1)&&u!==(u=y[0].name+"")&&Oe(c,u)},i(y){v||(P(_.$$.fragment,y),v=!0)},o(y){B(_.$$.fragment,y),v=!1},d(y){y&&b(e),ue(_),p=!1,g()}}}function Ud(n){var E,q;let e,t,l,o,s,r,i,a,u,c,f,h,d,_,v,p,g,y,k,w,N,S=n[3].length>0&&ui(n);function A(D){n[51](D)}function z(D){n[52](D)}let M={tools:n[25].reduce(n[48],{}),uploadFilesHandler:n[49],onClose:n[50],$$slots:{default:[Xd]},$$scope:{ctx:n}};n[5]!==void 0&&(M.webSearchEnabled=n[5]),n[4]!==void 0&&(M.selectedToolIds=n[4]),r=new sd({props:M}),Be.push(()=>lt(r,"webSearchEnabled",A)),Be.push(()=>lt(r,"selectedToolIds",z));let V=(!((E=n[11])!=null&&E.currentId)||((q=n[11].messages[n[11].currentId])==null?void 0:q.done)==!0)&&di(n);const L=[Gd,Zd],Y=[];function K(D,U){var F;return!D[11].currentId||((F=D[11].messages[D[11].currentId])==null?void 0:F.done)==!0?0:1}return g=K(n),y=Y[g]=L[g](n),{c(){e=O("form"),t=O("div"),S&&S.c(),l=te(),o=O("div"),s=O("div"),re(r.$$.fragment),u=te(),c=O("textarea"),h=te(),d=O("div"),V&&V.c(),v=te(),p=O("div"),y.c(),this.h()},l(D){e=H(D,"FORM",{class:!0});var U=T(e);t=H(U,"DIV",{class:!0,dir:!0});var F=T(t);S&&S.l(F),l=ne(F),o=H(F,"DIV",{class:!0});var C=T(o);s=H(C,"DIV",{class:!0});var R=T(s);ce(r.$$.fragment,R),R.forEach(b),u=ne(C),c=H(C,"TEXTAREA",{id:!0,class:!0,placeholder:!0,rows:!0}),T(c).forEach(b),h=ne(C),d=H(C,"DIV",{class:!0});var G=T(d);V&&V.l(G),G.forEach(b),C.forEach(b),F.forEach(b),v=ne(U),p=H(U,"DIV",{class:!0});var J=T(p);y.l(J),J.forEach(b),U.forEach(b),this.h()},h(){var D;m(s,"class","ml-0.5 self-end mb-1.5 flex space-x-1"),m(c,"id","chat-textarea"),m(c,"class","scrollbar-hidden bg-gray-50 dark:bg-gray-850 dark:text-gray-100 outline-none w-full py-3 px-1 rounded-xl resize-none h-[48px] svelte-141e0sl"),m(c,"placeholder",f=n[22].t("Send a Message")),m(c,"rows","1"),m(d,"class","self-end mb-2 flex space-x-1 mr-1"),m(o,"class","flex"),m(t,"class","flex-1 flex flex-col relative w-full rounded-3xl px-1.5 bg-gray-50 dark:bg-gray-850 dark:text-gray-100"),m(t,"dir",_=((D=n[24])==null?void 0:D.chatDirection)??"LTR"),m(p,"class","flex items-end w-10"),m(e,"class","w-full flex gap-1.5")},m(D,U){W(D,e,U),I(e,t),S&&S.m(t,null),I(t,l),I(t,o),I(o,s),ae(r,s,null),I(o,u),I(o,c),n[53](c),In(c,n[1]),I(o,h),I(o,d),V&&V.m(d,null),I(e,v),I(e,p),Y[g].m(p,null),k=!0,w||(N=[he(c,"input",n[54]),he(c,"keypress",n[55]),he(c,"keydown",n[56]),he(c,"input",n[57]),he(c,"focus",n[58]),he(c,"paste",n[59]),he(e,"submit",Or(n[63]))],w=!0)},p(D,U){var R,G,J;D[3].length>0?S?(S.p(D,U),U[0]&8&&P(S,1)):(S=ui(D),S.c(),P(S,1),S.m(t,l)):S&&(je(),B(S,1,1,()=>{S=null}),Ye());const F={};U[0]&100667392&&(F.tools=D[25].reduce(D[48],{})),U[0]&65536&&(F.uploadFilesHandler=D[49]),U[0]&8192&&(F.onClose=D[50]),U[2]&128&&(F.$$scope={dirty:U,ctx:D}),!i&&U[0]&32&&(i=!0,F.webSearchEnabled=D[5],nt(()=>i=!1)),!a&&U[0]&16&&(a=!0,F.selectedToolIds=D[4],nt(()=>a=!1)),r.$set(F),(!k||U[0]&4194304&&f!==(f=D[22].t("Send a Message")))&&m(c,"placeholder",f),U[0]&2&&In(c,D[1]),!((R=D[11])!=null&&R.currentId)||((G=D[11].messages[D[11].currentId])==null?void 0:G.done)==!0?V?(V.p(D,U),U[0]&2048&&P(V,1)):(V=di(D),V.c(),P(V,1),V.m(d,null)):V&&(je(),B(V,1,1,()=>{V=null}),Ye()),(!k||U[0]&16777216&&_!==(_=((J=D[24])==null?void 0:J.chatDirection)??"LTR"))&&m(t,"dir",_);let C=g;g=K(D),g===C?Y[g].p(D,U):(je(),B(Y[C],1,1,()=>{Y[C]=null}),Ye(),y=Y[g],y?y.p(D,U):(y=Y[g]=L[g](D),y.c()),P(y,1),y.m(p,null))},i(D){k||(P(S),P(r.$$.fragment,D),P(V),P(y),k=!0)},o(D){B(S),B(r.$$.fragment,D),B(V),B(y),k=!1},d(D){D&&b(e),S&&S.d(),ue(r),n[53](null),V&&V.d(),Y[g].d(),w=!1,At(N)}}}function Wd(n){let e,t,l;function o(r){n[42](r)}let s={};return n[15]!==void 0&&(s.recording=n[15]),e=new hd({props:s}),Be.push(()=>lt(e,"recording",o)),e.$on("cancel",n[43]),e.$on("confirm",n[44]),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),l=!0},p(r,i){const a={};!t&&i[0]&32768&&(t=!0,a.recording=r[15],nt(()=>t=!1)),e.$set(a)},i(r){l||(P(e.$$.fragment,r),l=!0)},o(r){B(e.$$.fragment,r),l=!1},d(r){ue(e,r)}}}function ui(n){let e,t,l=pt(n[3]),o=[];for(let r=0;rB(o[r],1,1,()=>{o[r]=null});return{c(){e=O("div");for(let r=0;r{_=null}),Ye())},i(p){f||(P(_),f=!0)},o(p){B(_),f=!1},d(p){p&&b(e),_&&_.d(),h=!1,d()}}}function ci(n){let e,t;return e=new pn({props:{className:" absolute top-1 left-1",content:n[22].t("{{ models }}",{models:[...n[0]?[n[0]]:n[10]].filter(n[45]).join(", ")}),$$slots:{default:[Yd]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&6292481&&(s.content=l[22].t("{{ models }}",{models:[...l[0]?[l[0]]:l[10]].filter(l[45]).join(", ")})),o[2]&128&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function Yd(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0,fill:!0,class:!0});var o=T(e);t=Ve(o,"path",{"fill-rule":!0,d:!0,"clip-rule":!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"fill-rule","evenodd"),m(t,"d","M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003ZM12 8.25a.75.75 0 0 1 .75.75v3.75a.75.75 0 0 1-1.5 0V9a.75.75 0 0 1 .75-.75Zm0 8.25a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z"),m(t,"clip-rule","evenodd"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 24 24"),m(e,"fill","currentColor"),m(e,"class","size-4 fill-yellow-300")},m(l,o){W(l,e,o),I(e,t)},p:we,d(l){l&&b(e)}}}function fi(n){let e,t,l,o;const s=[jd,Fd],r=[];function i(a,u){return a[66].type==="image"?0:1}return e=i(n),t=r[e]=s[e](n),{c(){t.c(),l=Le()},l(a){t.l(a),l=Le()},m(a,u){r[e].m(a,u),W(a,l,u),o=!0},p(a,u){let c=e;e=i(a),e===c?r[e].p(a,u):(je(),B(r[c],1,1,()=>{r[c]=null}),Ye(),t=r[e],t?t.p(a,u):(t=r[e]=s[e](a),t.c()),P(t,1),t.m(l.parentNode,l))},i(a){o||(P(t),o=!0)},o(a){B(t),o=!1},d(a){a&&b(l),r[e].d(a)}}}function Xd(n){let e,t='';return{c(){e=O("button"),e.innerHTML=t,this.h()},l(l){e=H(l,"BUTTON",{class:!0,type:!0,"aria-label":!0,"data-svelte-h":!0}),ut(e)!=="svelte-d8rhv1"&&(e.innerHTML=t),this.h()},h(){m(e,"class","bg-gray-50 hover:bg-gray-100 text-gray-800 dark:bg-gray-850 dark:text-white dark:hover:bg-gray-800 transition rounded-full p-2 outline-none focus:outline-none"),m(e,"type","button"),m(e,"aria-label","More")},m(l,o){W(l,e,o)},p:we,d(l){l&&b(e)}}}function di(n){let e,t;return e=new pn({props:{content:n[22].t("Record voice"),$$slots:{default:[Kd]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&4194304&&(s.content=l[22].t("Record voice")),o[0]&4227072|o[2]&128&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function Kd(n){let e,t='',l,o;return{c(){e=O("button"),e.innerHTML=t,this.h()},l(s){e=H(s,"BUTTON",{id:!0,class:!0,type:!0,"aria-label":!0,"data-svelte-h":!0}),ut(e)!=="svelte-l9ga2d"&&(e.innerHTML=t),this.h()},h(){m(e,"id","voice-input-button"),m(e,"class","text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-850 transition rounded-full p-1.5 mr-0.5 self-center"),m(e,"type","button"),m(e,"aria-label","Voice Input")},m(s,r){W(s,e,r),l||(o=he(e,"click",n[60]),l=!0)},p:we,d(s){s&&b(e),l=!1,o()}}}function Zd(n){let e,t,l='',o,s;return{c(){e=O("div"),t=O("button"),t.innerHTML=l,this.h()},l(r){e=H(r,"DIV",{class:!0});var i=T(e);t=H(i,"BUTTON",{class:!0,"data-svelte-h":!0}),ut(t)!=="svelte-5uu99u"&&(t.innerHTML=l),i.forEach(b),this.h()},h(){m(t,"class","bg-white hover:bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-800 transition rounded-full p-1.5"),m(e,"class","flex items-center mb-1.5")},m(r,i){W(r,e,i),I(e,t),o||(s=he(t,"click",n[62]),o=!0)},p:we,i:we,o:we,d(r){r&&b(e),o=!1,s()}}}function Gd(n){let e,t,l,o;const s=[Jd,qd],r=[];function i(a,u){return a[1]===""?0:1}return e=i(n),t=r[e]=s[e](n),{c(){t.c(),l=Le()},l(a){t.l(a),l=Le()},m(a,u){r[e].m(a,u),W(a,l,u),o=!0},p(a,u){let c=e;e=i(a),e===c?r[e].p(a,u):(je(),B(r[c],1,1,()=>{r[c]=null}),Ye(),t=r[e],t?t.p(a,u):(t=r[e]=s[e](a),t.c()),P(t,1),t.m(l.parentNode,l))},i(a){o||(P(t),o=!0)},o(a){B(t),o=!1},d(a){a&&b(l),r[e].d(a)}}}function qd(n){let e,t,l;return t=new pn({props:{content:n[22].t("Send message"),$$slots:{default:[Qd]},$$scope:{ctx:n}}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"class","flex items-center mb-1")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p(o,s){const r={};s[0]&4194304&&(r.content=o[22].t("Send message")),s[0]&2|s[2]&128&&(r.$$scope={dirty:s,ctx:o}),t.$set(r)},i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function Jd(n){let e,t,l;return t=new pn({props:{content:n[22].t("Call"),$$slots:{default:[xd]},$$scope:{ctx:n}}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"class","flex items-center mb-1")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p(o,s){const r={};s[0]&4194304&&(r.content=o[22].t("Call")),s[0]&12583936|s[2]&128&&(r.$$scope={dirty:s,ctx:o}),t.$set(r)},i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function Qd(n){let e,t,l,o,s;return{c(){e=O("button"),t=Pe("svg"),l=Pe("path"),this.h()},l(r){e=H(r,"BUTTON",{id:!0,class:!0,type:!0});var i=T(e);t=Ve(i,"svg",{xmlns:!0,viewBox:!0,fill:!0,class:!0});var a=T(t);l=Ve(a,"path",{"fill-rule":!0,d:!0,"clip-rule":!0}),T(l).forEach(b),a.forEach(b),i.forEach(b),this.h()},h(){m(l,"fill-rule","evenodd"),m(l,"d","M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z"),m(l,"clip-rule","evenodd"),m(t,"xmlns","http://www.w3.org/2000/svg"),m(t,"viewBox","0 0 16 16"),m(t,"fill","currentColor"),m(t,"class","size-6"),m(e,"id","send-message-button"),m(e,"class",o=(n[1]!==""?"bg-black text-white hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100 ":"text-white bg-gray-200 dark:text-gray-900 dark:bg-gray-700 disabled")+" transition rounded-full p-1.5 m-0.5 self-center"),m(e,"type","submit"),e.disabled=s=n[1]===""},m(r,i){W(r,e,i),I(e,t),I(t,l)},p(r,i){i[0]&2&&o!==(o=(r[1]!==""?"bg-black text-white hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100 ":"text-white bg-gray-200 dark:text-gray-900 dark:bg-gray-700 disabled")+" transition rounded-full p-1.5 m-0.5 self-center")&&m(e,"class",o),i[0]&2&&s!==(s=r[1]==="")&&(e.disabled=s)},d(r){r&&b(e)}}}function xd(n){let e,t,l,o,s;return t=new ad({props:{className:"size-6"}}),{c(){e=O("button"),re(t.$$.fragment),this.h()},l(r){e=H(r,"BUTTON",{class:!0,type:!0,"aria-label":!0});var i=T(e);ce(t.$$.fragment,i),i.forEach(b),this.h()},h(){m(e,"class","text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-850 transition rounded-full p-2 self-center"),m(e,"type","button"),m(e,"aria-label","Call")},m(r,i){W(r,e,i),ae(t,e,null),l=!0,o||(s=he(e,"click",n[61]),o=!0)},p:we,i(r){l||(P(t.$$.fragment,r),l=!0)},o(r){B(t.$$.fragment,r),l=!1},d(r){r&&b(e),ue(t),o=!1,s()}}}function $d(n){var G;let e,t,l,o,s,r,i,a,u,c,f,h,d,_,v,p,g,y,k,w,N,S,A=n[22].t("LLMs can make mistakes. Verify important information.")+"",z,M,V,L,Y;e=new _d({props:{show:n[19]}});let K=n[2]===!1&&((G=n[11])==null?void 0:G.currentId)&&ri(n),E=n[0]!==void 0&&ai(n);function q(J){n[36](J)}function D(J){n[37](J)}let U={};n[1]!==void 0&&(U.prompt=n[1]),n[3]!==void 0&&(U.files=n[3]),c=new Rd({props:U}),n[35](c),Be.push(()=>lt(c,"prompt",q)),Be.push(()=>lt(c,"files",D)),c.$on("select",n[38]);const F=[Wd,Ud],C=[];function R(J,oe){return J[15]?0:1}return k=R(n),w=C[k]=F[k](n),{c(){re(e.$$.fragment),t=te(),l=O("div"),o=O("div"),s=O("div"),r=O("div"),K&&K.c(),i=te(),a=O("div"),E&&E.c(),u=te(),re(c.$$.fragment),d=te(),_=O("div"),v=O("div"),p=O("div"),g=O("input"),y=te(),w.c(),N=te(),S=O("div"),z=De(A),this.h()},l(J){ce(e.$$.fragment,J),t=ne(J),l=H(J,"DIV",{class:!0});var oe=T(l);o=H(oe,"DIV",{class:!0});var ee=T(o);s=H(ee,"DIV",{class:!0});var j=T(s);r=H(j,"DIV",{class:!0});var ge=T(r);K&&K.l(ge),ge.forEach(b),i=ne(j),a=H(j,"DIV",{class:!0});var x=T(a);E&&E.l(x),u=ne(x),ce(c.$$.fragment,x),x.forEach(b),j.forEach(b),ee.forEach(b),d=ne(oe),_=H(oe,"DIV",{class:!0});var ye=T(_);v=H(ye,"DIV",{class:!0});var ie=T(v);p=H(ie,"DIV",{class:!0});var Ie=T(p);g=H(Ie,"INPUT",{type:!0}),y=ne(Ie),w.l(Ie),N=ne(Ie),S=H(Ie,"DIV",{class:!0});var Te=T(S);z=ze(Te,A),Te.forEach(b),Ie.forEach(b),ie.forEach(b),ye.forEach(b),oe.forEach(b),this.h()},h(){m(r,"class","relative"),m(a,"class","w-full relative"),m(s,"class","flex flex-col max-w-6xl px-2.5 md:px-6 w-full"),m(o,"class","-mb-0.5 mx-auto inset-x-0 bg-transparent flex justify-center"),m(g,"type","file"),g.hidden=!0,g.multiple=!0,m(S,"class","mt-1.5 text-xs text-gray-500 text-center line-clamp-1"),m(p,"class","pb-2"),m(v,"class","max-w-6xl px-2.5 md:px-6 mx-auto inset-x-0 pb-safe-bottom"),m(_,"class",M=n[6]?"bg-transparent":"bg-white dark:bg-gray-900"),m(l,"class","w-full font-primary")},m(J,oe){ae(e,J,oe),W(J,t,oe),W(J,l,oe),I(l,o),I(o,s),I(s,r),K&&K.m(r,null),I(s,i),I(s,a),E&&E.m(a,null),I(a,u),ae(c,a,null),I(l,d),I(l,_),I(_,v),I(v,p),I(p,g),n[39](g),I(p,y),C[k].m(p,null),I(p,N),I(p,S),I(S,z),V=!0,L||(Y=[he(g,"change",n[40]),he(g,"change",n[41])],L=!0)},p(J,oe){var x;const ee={};oe[0]&524288&&(ee.show=J[19]),e.$set(ee),J[2]===!1&&((x=J[11])!=null&&x.currentId)?K?K.p(J,oe):(K=ri(J),K.c(),K.m(r,null)):K&&(K.d(1),K=null),J[0]!==void 0?E?(E.p(J,oe),oe[0]&1&&P(E,1)):(E=ai(J),E.c(),P(E,1),E.m(a,u)):E&&(je(),B(E,1,1,()=>{E=null}),Ye());const j={};!f&&oe[0]&2&&(f=!0,j.prompt=J[1],nt(()=>f=!1)),!h&&oe[0]&8&&(h=!0,j.files=J[3],nt(()=>h=!1)),c.$set(j);let ge=k;k=R(J),k===ge?C[k].p(J,oe):(je(),B(C[ge],1,1,()=>{C[ge]=null}),Ye(),w=C[k],w?w.p(J,oe):(w=C[k]=F[k](J),w.c()),P(w,1),w.m(p,N)),(!V||oe[0]&4194304)&&A!==(A=J[22].t("LLMs can make mistakes. Verify important information.")+"")&&Oe(z,A),(!V||oe[0]&64&&M!==(M=J[6]?"bg-transparent":"bg-white dark:bg-gray-900"))&&m(_,"class",M)},i(J){V||(P(e.$$.fragment,J),P(E),P(c.$$.fragment,J),P(w),V=!0)},o(J){B(e.$$.fragment,J),B(E),B(c.$$.fragment,J),B(w),V=!1},d(J){J&&(b(t),b(l)),ue(e,J),K&&K.d(),E&&E.d(),n[35](null),ue(c),n[39](null),C[k].d(),L=!1,At(Y)}}}function eh(n,e,t){let l,o,s,r,i,a,u;se(n,El,X=>t(23,o=X)),se(n,Sl,X=>t(14,s=X)),se(n,Fn,X=>t(24,r=X)),se(n,Wr,X=>t(25,i=X)),se(n,Il,X=>t(26,a=X)),se(n,vo,X=>t(27,u=X));const c=en(),f=Lt("i18n");se(n,f,X=>t(22,l=X));let{transparentBackground:h=!1}=e,{submitPrompt:d}=e,{createMessagePair:_}=e,{stopResponse:v}=e,{autoScroll:p=!1}=e,{atSelectedModel:g}=e,{selectedModels:y}=e,k=!1,w,N,S,A,z=!1,M=null,{history:V}=e,{prompt:L=""}=e,{files:Y=[]}=e,{availableToolIds:K=[]}=e,{selectedToolIds:E=[]}=e,{webSearchEnabled:q=!1}=e,D=[];const U=()=>{const X=document.getElementById("messages-container");X.scrollTo({top:X.scrollHeight,behavior:"smooth"})},F=async X=>{console.log(X);const me={type:"file",file:"",id:null,url:"",name:X.name,collection_name:"",status:"",size:X.size,error:""};if(t(3,Y=[...Y,me]),["audio/mpeg","audio/wav","audio/ogg","audio/x-m4a"].includes(X.type)){const He=await es(localStorage.token,X).catch(Xe=>($e.error(Xe),null));if(He){console.log(He);const Xe=new Blob([He.text],{type:"text/plain"});X=xo(Xe,`${X.name}.txt`),me.name=X.name,me.size=X.size}}try{const He=await Tu(localStorage.token,X);He?(me.status="uploaded",me.file=He,me.id=He.id,me.url=`${su}/files/${He.id}`,iu.includes(X.type)||ru.includes(X.name.split(".").at(-1))||$e.error(l.t("Unknown file type '{{file_type}}'. Proceeding with the file upload anyway.",{file_type:X.type})),C(me)):t(3,Y=Y.filter(Xe=>Xe.status!==null))}catch(He){$e.error(He),t(3,Y=Y.filter(Xe=>Xe.status!==null))}},C=async X=>{try{const me=await Pu(localStorage.token,X.id);me&&(X.status="processed",X.collection_name=me.collection_name,t(3,Y))}catch(me){$e.error(me),X.status="processed",t(3,Y)}},R=async X=>{X.forEach(me=>{var He,Xe,Ue;if(console.log(me,me.name.split(".").at(-1)),(((He=o==null?void 0:o.file)==null?void 0:He.max_size)??null)!==null&&me.size>(((Xe=o==null?void 0:o.file)==null?void 0:Xe.max_size)??0)*1024*1024){$e.error(l.t("File size should not exceed {{maxSize}} MB.",{maxSize:(Ue=o==null?void 0:o.file)==null?void 0:Ue.max_size}));return}if(["image/gif","image/webp","image/jpeg","image/png"].includes(me.type)){if(D.length===0){$e.error(l.t("Selected model(s) do not support image inputs"));return}let qe=new FileReader;qe.onload=It=>{t(3,Y=[...Y,{type:"image",url:`${It.target.result}`}])},qe.readAsDataURL(me)}else F(me)})};un(()=>{window.setTimeout(()=>w==null?void 0:w.focus(),0);const X=document.querySelector("body"),me=qe=>{qe.key==="Escape"&&(console.log("Escape"),t(19,z=!1))},He=qe=>{qe.preventDefault(),t(19,z=!0)},Xe=()=>{t(19,z=!1)},Ue=async qe=>{var It,Zt;if(qe.preventDefault(),console.log(qe),(It=qe.dataTransfer)!=null&&It.files){const Gt=Array.from((Zt=qe.dataTransfer)==null?void 0:Zt.files);Gt&&Gt.length>0?(console.log(Gt),R(Gt)):$e.error(l.t("File not found."))}t(19,z=!1)};return window.addEventListener("keydown",me),X==null||X.addEventListener("dragover",He),X==null||X.addEventListener("drop",Ue),X==null||X.addEventListener("dragleave",Xe),()=>{window.removeEventListener("keydown",me),X==null||X.removeEventListener("dragover",He),X==null||X.removeEventListener("drop",Ue),X==null||X.removeEventListener("dragleave",Xe)}});const G=()=>{t(2,p=!0),U()},J=X=>X.id===g.id,oe=()=>{t(0,g=void 0)};function ee(X){Be[X?"unshift":"push"](()=>{S=X,t(17,S)})}function j(X){L=X,t(1,L)}function ge(X){Y=X,t(3,Y)}const x=X=>{const me=X.detail;(me==null?void 0:me.type)==="model"&&t(0,g=me.data),w==null||w.focus()};function ye(X){Be[X?"unshift":"push"](()=>{N=X,t(16,N)})}function ie(){A=this.files,t(18,A)}const Ie=async()=>{if(A&&A.length>0){const X=Array.from(A);R(X)}else $e.error(l.t("File not found."));t(16,N.value="",N)};function Te(X){k=X,t(15,k)}const Fe=async()=>{var X;t(15,k=!1),await Je(),(X=document.getElementById("chat-textarea"))==null||X.focus()},rt=async X=>{var He;const me=X.detail;t(1,L=`${L}${me} `),t(15,k=!1),await Je(),(He=document.getElementById("chat-textarea"))==null||He.focus(),((r==null?void 0:r.speechAutoSend)??!1)&&d(L)},de=X=>!D.includes(X),Ge=X=>{Y.splice(X,1),t(3,Y)},Ke=X=>{Y.splice(X,1),t(3,Y)},Vt=(X,me,He,Xe)=>((K.includes(me.id)||((a==null?void 0:a.role)??"user")==="admin")&&(X[me.id]={name:me.name,description:me.meta.description,enabled:!1}),X),Bt=()=>{N.click()},yt=async()=>{await Je(),w==null||w.focus()};function Yt(X){q=X,t(5,q)}function Nt(X){E=X,t(4,E)}function Ot(X){Be[X?"unshift":"push"](()=>{w=X,t(13,w),t(1,L)})}function Dt(){L=this.value,t(1,L)}const Kt=X=>{(!u||!("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0))&&(X.key==="Enter"&&!X.shiftKey&&X.preventDefault(),L!==""&&X.key==="Enter"&&!X.shiftKey&&d(L))},_e=async X=>{var Xe;const me=X.ctrlKey||X.metaKey,He=document.getElementById("commands-container");if(me&&X.key==="Enter"&&X.shiftKey&&(X.preventDefault(),_(L)),L===""&&me&&X.key.toLowerCase()==="r"){X.preventDefault(),console.log("regenerate");const Ue=[...document.getElementsByClassName("regenerate-response-button")].at(-1);Ue==null||Ue.click()}if(L===""&&X.key=="ArrowUp"){X.preventDefault();const Ue=[...document.getElementsByClassName("user-message")].at(-1),qe=[...document.getElementsByClassName("edit-user-message-button")].at(-1);console.log(Ue),Ue.scrollIntoView({block:"center"}),qe==null||qe.click()}if(He&&X.key==="ArrowUp"&&(X.preventDefault(),S.selectUp(),[...document.getElementsByClassName("selected-command-option-button")].at(-1).scrollIntoView({block:"center"})),He&&X.key==="ArrowDown"&&(X.preventDefault(),S.selectDown(),[...document.getElementsByClassName("selected-command-option-button")].at(-1).scrollIntoView({block:"center"})),He&&X.key==="Enter"){X.preventDefault();const Ue=[...document.getElementsByClassName("selected-command-option-button")].at(-1);X.shiftKey?t(1,L=`${L} `):Ue?Ue==null||Ue.click():(Xe=document.getElementById("send-message-button"))==null||Xe.click()}if(He&&X.key==="Tab"){X.preventDefault();const Ue=[...document.getElementsByClassName("selected-command-option-button")].at(-1);Ue==null||Ue.click()}else if(X.key==="Tab"){const Ue=jr(L);if(Ue.length>0){const qe=Ue.at(0),It=L;t(1,L=L.substring(0,(qe==null?void 0:qe.endIndex)+1)),await Je(),X.target.scrollTop=X.target.scrollHeight,t(1,L=It),await Je(),X.preventDefault(),X.target.setSelectionRange(qe==null?void 0:qe.startIndex,qe.endIndex+1)}X.target.style.height="",X.target.style.height=Math.min(X.target.scrollHeight,200)+"px"}X.key==="Escape"&&(console.log("Escape"),t(0,g=void 0))},Ht=async X=>{X.target.style.height="",X.target.style.height=Math.min(X.target.scrollHeight,200)+"px",t(20,M=null)},wt=async X=>{X.target.style.height="",X.target.style.height=Math.min(X.target.scrollHeight,200)+"px"},St=async X=>{const me=X.clipboardData||window.clipboardData;if(me&&me.items){for(const He of me.items)if(He.type.indexOf("image")!==-1){const Xe=He.getAsFile(),Ue=new FileReader;Ue.onload=function(qe){t(3,Y=[...Y,{type:"image",url:`${qe.target.result}`}])},Ue.readAsDataURL(Xe)}}},Ce=async()=>{try{let X=await navigator.mediaDevices.getUserMedia({audio:!0}).catch(function(me){return $e.error(l.t("Permission denied when accessing microphone: {{error}}",{error:me})),null});X&&(t(15,k=!0),X.getTracks().forEach(He=>He.stop())),X=null}catch{$e.error(l.t("Permission denied when accessing microphone"))}},Wt=async()=>{if(y.length>1){$e.error(l.t("Select only one model to call"));return}if(o.audio.stt.engine==="web"){$e.error(l.t("Call feature is not supported when using Web STT engine"));return}try{let X=await navigator.mediaDevices.getUserMedia({audio:!0});X&&X.getTracks().forEach(He=>He.stop()),X=null,rl.set(!0),c("call")}catch{$e.error(l.t("Permission denied when accessing media devices"))}},fe=()=>{v()},Ne=()=>{d(L)};return n.$$set=X=>{"transparentBackground"in X&&t(6,h=X.transparentBackground),"submitPrompt"in X&&t(7,d=X.submitPrompt),"createMessagePair"in X&&t(8,_=X.createMessagePair),"stopResponse"in X&&t(9,v=X.stopResponse),"autoScroll"in X&&t(2,p=X.autoScroll),"atSelectedModel"in X&&t(0,g=X.atSelectedModel),"selectedModels"in X&&t(10,y=X.selectedModels),"history"in X&&t(11,V=X.history),"prompt"in X&&t(1,L=X.prompt),"files"in X&&t(3,Y=X.files),"availableToolIds"in X&&t(12,K=X.availableToolIds),"selectedToolIds"in X&&t(4,E=X.selectedToolIds),"webSearchEnabled"in X&&t(5,q=X.webSearchEnabled)},n.$$.update=()=>{n.$$.dirty[0]&17409&&t(21,D=[...g?[g]:y].filter(X=>{var me,He,Xe,Ue;return((Ue=(Xe=(He=(me=s.find(qe=>qe.id===X))==null?void 0:me.info)==null?void 0:He.meta)==null?void 0:Xe.capabilities)==null?void 0:Ue.vision)??!0})),n.$$.dirty[0]&8194&&L&&w&&(t(13,w.style.height="",w),t(13,w.style.height=Math.min(w.scrollHeight,200)+"px",w))},[g,L,p,Y,E,q,h,d,_,v,y,V,K,w,s,k,N,S,A,z,M,D,l,o,r,i,a,u,c,f,U,R,G,J,oe,ee,j,ge,x,ye,ie,Ie,Te,Fe,rt,de,Ge,Ke,Vt,Bt,yt,Yt,Nt,Ot,Dt,Kt,_e,Ht,wt,St,Ce,Wt,fe,Ne]}class th extends ke{constructor(e){super(),Ee(this,e,eh,$d,Se,{transparentBackground:6,submitPrompt:7,createMessagePair:8,stopResponse:9,autoScroll:2,atSelectedModel:0,selectedModels:10,history:11,prompt:1,files:3,availableToolIds:12,selectedToolIds:4,webSearchEnabled:5},null,[-1,-1,-1])}}function hi(n,e,t){const l=n.slice();return l[13]=e[t],l[14]=e,l[15]=t,l}function nh(n){let e,t,l;return t=new pn({props:{content:n[4].t("Remove Model"),$$slots:{default:[oh]},$$scope:{ctx:n}}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"class","self-center mx-1 disabled:text-gray-600 disabled:hover:text-gray-600 -translate-y-[0.5px]")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p(o,s){const r={};s&16&&(r.content=o[4].t("Remove Model")),s&65539&&(r.$$scope={dirty:s,ctx:o}),t.$set(r)},i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function lh(n){let e,t,l;return t=new pn({props:{content:n[4].t("Add Model"),$$slots:{default:[sh]},$$scope:{ctx:n}}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"class","self-center mx-1 disabled:text-gray-600 disabled:hover:text-gray-600 -translate-y-[0.5px]")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p(o,s){const r={};s&16&&(r.content=o[4].t("Add Model")),s&65539&&(r.$$scope={dirty:s,ctx:o}),t.$set(r)},i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function oh(n){let e,t,l,o,s;function r(){return n[11](n[15])}return{c(){e=O("button"),t=Pe("svg"),l=Pe("path"),this.h()},l(i){e=H(i,"BUTTON",{"aria-label":!0});var a=T(e);t=Ve(a,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var u=T(t);l=Ve(u,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),T(l).forEach(b),u.forEach(b),a.forEach(b),this.h()},h(){m(l,"stroke-linecap","round"),m(l,"stroke-linejoin","round"),m(l,"d","M19.5 12h-15"),m(t,"xmlns","http://www.w3.org/2000/svg"),m(t,"fill","none"),m(t,"viewBox","0 0 24 24"),m(t,"stroke-width","2"),m(t,"stroke","currentColor"),m(t,"class","size-3"),e.disabled=n[1],m(e,"aria-label","Remove Model")},m(i,a){W(i,e,a),I(e,t),I(t,l),o||(s=he(e,"click",r),o=!0)},p(i,a){n=i,a&2&&(e.disabled=n[1])},d(i){i&&b(e),o=!1,s()}}}function sh(n){let e,t,l,o,s;return{c(){e=O("button"),t=Pe("svg"),l=Pe("path"),this.h()},l(r){e=H(r,"BUTTON",{class:!0,"aria-label":!0});var i=T(e);t=Ve(i,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var a=T(t);l=Ve(a,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),T(l).forEach(b),a.forEach(b),i.forEach(b),this.h()},h(){m(l,"stroke-linecap","round"),m(l,"stroke-linejoin","round"),m(l,"d","M12 6v12m6-6H6"),m(t,"xmlns","http://www.w3.org/2000/svg"),m(t,"fill","none"),m(t,"viewBox","0 0 24 24"),m(t,"stroke-width","2"),m(t,"stroke","currentColor"),m(t,"class","size-3.5"),m(e,"class",""),e.disabled=n[1],m(e,"aria-label","Add Model")},m(r,i){W(r,e,i),I(e,t),I(t,l),o||(s=he(e,"click",n[10]),o=!0)},p(r,i){i&2&&(e.disabled=r[1])},d(r){r&&b(e),o=!1,s()}}}function mi(n){var p,g,y;let e,t,l,o,s,r,i,a,u,c;function f(k){n[9](k,n[13],n[14],n[15])}let h={placeholder:n[4].t("Select a model"),items:n[3].map(_i),showTemporaryChatControl:n[5].role==="user"?((y=(g=(p=n[6])==null?void 0:p.permissions)==null?void 0:g.chat)==null?void 0:y.temporary)??!0:!0};n[13]!==void 0&&(h.value=n[13]),o=new Ku({props:h}),Be.push(()=>lt(o,"value",f));const d=[lh,nh],_=[];function v(k,w){return k[15]===0?0:1}return i=v(n),a=_[i]=d[i](n),{c(){e=O("div"),t=O("div"),l=O("div"),re(o.$$.fragment),r=te(),a.c(),u=te(),this.h()},l(k){e=H(k,"DIV",{class:!0});var w=T(e);t=H(w,"DIV",{class:!0});var N=T(t);l=H(N,"DIV",{class:!0});var S=T(l);ce(o.$$.fragment,S),S.forEach(b),N.forEach(b),r=ne(w),a.l(w),u=ne(w),w.forEach(b),this.h()},h(){m(l,"class","mr-1 max-w-full"),m(t,"class","overflow-hidden w-full"),m(e,"class","flex w-full max-w-fit")},m(k,w){W(k,e,w),I(e,t),I(t,l),ae(o,l,null),I(e,r),_[i].m(e,null),I(e,u),c=!0},p(k,w){var S,A,z;n=k;const N={};w&16&&(N.placeholder=n[4].t("Select a model")),w&8&&(N.items=n[3].map(_i)),w&96&&(N.showTemporaryChatControl=n[5].role==="user"?((z=(A=(S=n[6])==null?void 0:S.permissions)==null?void 0:A.chat)==null?void 0:z.temporary)??!0:!0),!s&&w&1&&(s=!0,N.value=n[13],nt(()=>s=!1)),o.$set(N),a.p(n,w)},i(k){c||(P(o.$$.fragment,k),P(a),c=!0)},o(k){B(o.$$.fragment,k),B(a),c=!1},d(k){k&&b(e),ue(o),_[i].d()}}}function gi(n){let e,t,l=n[4].t("Set as default")+"",o,s,r;return{c(){e=O("div"),t=O("button"),o=De(l),this.h()},l(i){e=H(i,"DIV",{class:!0});var a=T(e);t=H(a,"BUTTON",{});var u=T(t);o=ze(u,l),u.forEach(b),a.forEach(b),this.h()},h(){m(e,"class","absolute text-left mt-[1px] ml-1 text-[0.7rem] text-gray-500 font-primary")},m(i,a){W(i,e,a),I(e,t),I(t,o),s||(r=he(t,"click",n[8]),s=!0)},p(i,a){a&16&&l!==(l=i[4].t("Set as default")+"")&&Oe(o,l)},d(i){i&&b(e),s=!1,r()}}}function ih(n){let e,t,l,o,s=pt(n[0]),r=[];for(let u=0;uB(r[u],1,1,()=>{r[u]=null});let a=n[2]&&gi(n);return{c(){e=O("div");for(let u=0;u({value:n.id,label:n.name,model:n});function rh(n,e,t){let l,o,s,r,i;se(n,Sl,p=>t(3,l=p)),se(n,Fn,p=>t(12,s=p)),se(n,Il,p=>t(5,r=p)),se(n,El,p=>t(6,i=p));const a=Lt("i18n");se(n,a,p=>t(4,o=p));let{selectedModels:u=[""]}=e,{disabled:c=!1}=e,{showSetDefault:f=!0}=e;const h=async()=>{if(u.filter(g=>g==="").length){$e.error(o.t("Choose a model before saving..."));return}Fn.set({...s,models:u}),await Eu(localStorage.token,{ui:s}),$e.success(o.t("Default model updated"))};function d(p,g,y,k){y[k]=p,t(0,u),t(3,l)}const _=()=>{t(0,u=[...u,""])},v=p=>{u.splice(p,1),t(0,u),t(3,l)};return n.$$set=p=>{"selectedModels"in p&&t(0,u=p.selectedModels),"disabled"in p&&t(1,c=p.disabled),"showSetDefault"in p&&t(2,f=p.showSetDefault)},n.$$.update=()=>{n.$$.dirty&9&&u.length>0&&l.length>0&&t(0,u=u.map(p=>l.map(g=>g.id).includes(p)?p:""))},[u,c,f,l,o,r,i,a,h,d,_,v]}class ah extends ke{constructor(e){super(),Ee(this,e,rh,ih,Se,{selectedModels:0,disabled:1,showSetDefault:2})}}function uh(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var o=T(e);t=Ve(o,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"stroke-linecap","round"),m(t,"stroke-linejoin","round"),m(t,"d","M9 6.75V15m6-6v8.25m.503 3.498 4.875-2.437c.381-.19.622-.58.622-1.006V4.82c0-.836-.88-1.38-1.628-1.006l-3.869 1.934c-.317.159-.69.159-1.006 0L9.503 3.252a1.125 1.125 0 0 0-1.006 0L3.622 5.689C3.24 5.88 3 6.27 3 6.695V19.18c0 .836.88 1.38 1.628 1.006l3.869-1.934c.317-.159.69-.159 1.006 0l4.994 2.497c.317.158.69.158 1.006 0Z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"fill","none"),m(e,"viewBox","0 0 24 24"),m(e,"stroke-width",n[1]),m(e,"stroke","currentColor"),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&2&&m(e,"stroke-width",l[1]),o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function ch(n,e,t){let{className:l="size-4"}=e,{strokeWidth:o="2"}=e;return n.$$set=s=>{"className"in s&&t(0,l=s.className),"strokeWidth"in s&&t(1,o=s.strokeWidth)},[l,o]}let fh=class extends ke{constructor(e){super(),Ee(this,e,ch,uh,Se,{className:0,strokeWidth:1})}};function dh(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var o=T(e);t=Ve(o,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"stroke-linecap","round"),m(t,"stroke-linejoin","round"),m(t,"d","M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"fill","none"),m(e,"viewBox","0 0 24 24"),m(e,"stroke-width",n[1]),m(e,"stroke","currentColor"),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&2&&m(e,"stroke-width",l[1]),o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function hh(n,e,t){let{className:l="size-4"}=e,{strokeWidth:o="2"}=e;return n.$$set=s=>{"className"in s&&t(0,l=s.className),"strokeWidth"in s&&t(1,o=s.strokeWidth)},[l,o]}class mh extends ke{constructor(e){super(),Ee(this,e,hh,dh,Se,{className:0,strokeWidth:1})}}function gh(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0,stroke:!0,fill:!0,class:!0,"stroke-width":!0});var o=T(e);t=Ve(o,"path",{d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"d","M18.75 12.75h1.5a.75.75 0 0 0 0-1.5h-1.5a.75.75 0 0 0 0 1.5ZM12 6a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 12 6ZM12 18a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 12 18ZM3.75 6.75h1.5a.75.75 0 1 0 0-1.5h-1.5a.75.75 0 0 0 0 1.5ZM5.25 18.75h-1.5a.75.75 0 0 1 0-1.5h1.5a.75.75 0 0 1 0 1.5ZM3 12a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 3 12ZM9 3.75a2.25 2.25 0 1 0 0 4.5 2.25 2.25 0 0 0 0-4.5ZM12.75 12a2.25 2.25 0 1 1 4.5 0 2.25 2.25 0 0 1-4.5 0ZM9 15.75a2.25 2.25 0 1 0 0 4.5 2.25 2.25 0 0 0 0-4.5Z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 24 24"),m(e,"stroke","currentColor"),m(e,"fill","currentColor"),m(e,"class",n[0]),m(e,"stroke-width",n[1])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&1&&m(e,"class",l[0]),o&2&&m(e,"stroke-width",l[1])},i:we,o:we,d(l){l&&b(e)}}}function _h(n,e,t){let{className:l="w-4 h-4"}=e,{strokeWidth:o="1.5"}=e;return n.$$set=s=>{"className"in s&&t(0,l=s.className),"strokeWidth"in s&&t(1,o=s.strokeWidth)},[l,o]}class aa extends ke{constructor(e){super(),Ee(this,e,_h,gh,Se,{className:0,strokeWidth:1})}}function bh(n){let e;const t=n[12].default,l=dt(t,n,n[21],null);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,s){l&&l.p&&(!e||s&2097152)&&ht(l,t,o,o[21],e?gt(t,o[21],s,null):mt(o[21]),null)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function bi(n){let e,t;return e=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",id:"chat-controls-button",$$slots:{default:[ph]},$$scope:{ctx:n}}}),e.$on("click",n[13]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&2097168&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function ph(n){let e,t,l,o=n[4].t("Controls")+"",s,r;return e=new aa({props:{className:" size-4",strokeWidth:"0.5"}}),{c(){re(e.$$.fragment),t=te(),l=O("div"),s=De(o),this.h()},l(i){ce(e.$$.fragment,i),t=ne(i),l=H(i,"DIV",{class:!0});var a=T(l);s=ze(a,o),a.forEach(b),this.h()},h(){m(l,"class","flex items-center")},m(i,a){ae(e,i,a),W(i,t,a),W(i,l,a),I(l,s),r=!0},p(i,a){(!r||a&16)&&o!==(o=i[4].t("Controls")+"")&&Oe(s,o)},i(i){r||(P(e.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),r=!1},d(i){i&&(b(t),b(l)),ue(e,i)}}}function vh(n){let e,t,l,o=n[4].t("Overview")+"",s,r;return e=new fh({props:{className:" size-4",strokeWidth:"1.5"}}),{c(){re(e.$$.fragment),t=te(),l=O("div"),s=De(o),this.h()},l(i){ce(e.$$.fragment,i),t=ne(i),l=H(i,"DIV",{class:!0});var a=T(l);s=ze(a,o),a.forEach(b),this.h()},h(){m(l,"class","flex items-center")},m(i,a){ae(e,i,a),W(i,t,a),W(i,l,a),I(l,s),r=!0},p(i,a){(!r||a&16)&&o!==(o=i[4].t("Overview")+"")&&Oe(s,o)},i(i){r||(P(e.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),r=!1},d(i){i&&(b(t),b(l)),ue(e,i)}}}function yh(n){let e,t,l,o=n[4].t("Copy")+"",s,r;return e=new mh({props:{className:" size-4",strokeWidth:"1.5"}}),{c(){re(e.$$.fragment),t=te(),l=O("div"),s=De(o),this.h()},l(i){ce(e.$$.fragment,i),t=ne(i),l=H(i,"DIV",{class:!0});var a=T(l);s=ze(a,o),a.forEach(b),this.h()},h(){m(l,"class","flex items-center")},m(i,a){ae(e,i,a),W(i,t,a),W(i,l,a),I(l,s),r=!0},p(i,a){(!r||a&16)&&o!==(o=i[4].t("Copy")+"")&&Oe(s,o)},i(i){r||(P(e.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),r=!1},d(i){i&&(b(t),b(l)),ue(e,i)}}}function wh(n){let e,t,l,o,s=n[4].t("Share")+"",r;return{c(){e=Pe("svg"),t=Pe("path"),l=te(),o=O("div"),r=De(s),this.h()},l(i){e=Ve(i,"svg",{xmlns:!0,viewBox:!0,fill:!0,class:!0});var a=T(e);t=Ve(a,"path",{"fill-rule":!0,d:!0,"clip-rule":!0}),T(t).forEach(b),a.forEach(b),l=ne(i),o=H(i,"DIV",{class:!0});var u=T(o);r=ze(u,s),u.forEach(b),this.h()},h(){m(t,"fill-rule","evenodd"),m(t,"d","M15.75 4.5a3 3 0 1 1 .825 2.066l-8.421 4.679a3.002 3.002 0 0 1 0 1.51l8.421 4.679a3 3 0 1 1-.729 1.31l-8.421-4.678a3 3 0 1 1 0-4.132l8.421-4.679a3 3 0 0 1-.096-.755Z"),m(t,"clip-rule","evenodd"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 24 24"),m(e,"fill","currentColor"),m(e,"class","size-4"),m(o,"class","flex items-center")},m(i,a){W(i,e,a),I(e,t),W(i,l,a),W(i,o,a),I(o,r)},p(i,a){a&16&&s!==(s=i[4].t("Share")+"")&&Oe(r,s)},d(i){i&&(b(e),b(l),b(o))}}}function kh(n){let e,t,l,o,s=n[4].t("Download")+"",r;return{c(){e=Pe("svg"),t=Pe("path"),l=te(),o=O("div"),r=De(s),this.h()},l(i){e=Ve(i,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var a=T(e);t=Ve(a,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),T(t).forEach(b),a.forEach(b),l=ne(i),o=H(i,"DIV",{class:!0});var u=T(o);r=ze(u,s),u.forEach(b),this.h()},h(){m(t,"stroke-linecap","round"),m(t,"stroke-linejoin","round"),m(t,"d","M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"fill","none"),m(e,"viewBox","0 0 24 24"),m(e,"stroke-width","1.5"),m(e,"stroke","currentColor"),m(e,"class","size-4"),m(o,"class","flex items-center")},m(i,a){W(i,e,a),I(e,t),W(i,l,a),W(i,o,a),I(o,r)},p(i,a){a&16&&s!==(s=i[4].t("Download")+"")&&Oe(r,s)},d(i){i&&(b(e),b(l),b(o))}}}function Eh(n){let e,t=n[4].t("Export chat (.json)")+"",l;return{c(){e=O("div"),l=De(t),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);l=ze(s,t),s.forEach(b),this.h()},h(){m(e,"class","flex items-center line-clamp-1")},m(o,s){W(o,e,s),I(e,l)},p(o,s){s&16&&t!==(t=o[4].t("Export chat (.json)")+"")&&Oe(l,t)},d(o){o&&b(e)}}}function Sh(n){let e,t=n[4].t("Plain text (.txt)")+"",l;return{c(){e=O("div"),l=De(t),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);l=ze(s,t),s.forEach(b),this.h()},h(){m(e,"class","flex items-center line-clamp-1")},m(o,s){W(o,e,s),I(e,l)},p(o,s){s&16&&t!==(t=o[4].t("Plain text (.txt)")+"")&&Oe(l,t)},d(o){o&&b(e)}}}function Ih(n){let e,t=n[4].t("PDF document (.pdf)")+"",l;return{c(){e=O("div"),l=De(t),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);l=ze(s,t),s.forEach(b),this.h()},h(){m(e,"class","flex items-center line-clamp-1")},m(o,s){W(o,e,s),I(e,l)},p(o,s){s&16&&t!==(t=o[4].t("PDF document (.pdf)")+"")&&Oe(l,t)},d(o){o&&b(e)}}}function Ch(n){let e,t,l,o,s,r;return e=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",$$slots:{default:[Eh]},$$scope:{ctx:n}}}),e.$on("click",n[17]),l=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",$$slots:{default:[Sh]},$$scope:{ctx:n}}}),l.$on("click",n[18]),s=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",$$slots:{default:[Ih]},$$scope:{ctx:n}}}),s.$on("click",n[19]),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment),o=te(),re(s.$$.fragment)},l(i){ce(e.$$.fragment,i),t=ne(i),ce(l.$$.fragment,i),o=ne(i),ce(s.$$.fragment,i)},m(i,a){ae(e,i,a),W(i,t,a),ae(l,i,a),W(i,o,a),ae(s,i,a),r=!0},p(i,a){const u={};a&2097168&&(u.$$scope={dirty:a,ctx:i}),e.$set(u);const c={};a&2097168&&(c.$$scope={dirty:a,ctx:i}),l.$set(c);const f={};a&2097168&&(f.$$scope={dirty:a,ctx:i}),s.$set(f)},i(i){r||(P(e.$$.fragment,i),P(l.$$.fragment,i),P(s.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),B(l.$$.fragment,i),B(s.$$.fragment,i),r=!1},d(i){i&&(b(t),b(o)),ue(e,i),ue(l,i),ue(s,i)}}}function Dh(n){let e,t,l,o;return e=new xc({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",$$slots:{default:[kh]},$$scope:{ctx:n}}}),l=new Xc({props:{class:"w-full rounded-lg px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow-lg",transition:Wl,sideOffset:8,$$slots:{default:[Ch]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment)},l(s){ce(e.$$.fragment,s),t=ne(s),ce(l.$$.fragment,s)},m(s,r){ae(e,s,r),W(s,t,r),ae(l,s,r),o=!0},p(s,r){const i={};r&2097168&&(i.$$scope={dirty:r,ctx:s}),e.$set(i);const a={};r&2097168&&(a.$$scope={dirty:r,ctx:s}),l.$set(a)},i(s){o||(P(e.$$.fragment,s),P(l.$$.fragment,s),o=!0)},o(s){B(e.$$.fragment,s),B(l.$$.fragment,s),o=!1},d(s){s&&b(t),ue(e,s),ue(l,s)}}}function zh(n){let e,t,l,o,s,r,i,a,u,c,f,h,d,_,v=n[3]&&bi(n);return t=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",id:"chat-overview-button",$$slots:{default:[vh]},$$scope:{ctx:n}}}),t.$on("click",n[14]),o=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",id:"chat-copy-button",$$slots:{default:[yh]},$$scope:{ctx:n}}}),o.$on("click",n[15]),r=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",id:"chat-share-button",$$slots:{default:[wh]},$$scope:{ctx:n}}}),r.$on("click",n[16]),a=new Tc({props:{$$slots:{default:[Dh]},$$scope:{ctx:n}}}),d=new Nu({props:{chatId:n[1].id}}),{c(){v&&v.c(),e=te(),re(t.$$.fragment),l=te(),re(o.$$.fragment),s=te(),re(r.$$.fragment),i=te(),re(a.$$.fragment),u=te(),c=O("hr"),f=te(),h=O("div"),re(d.$$.fragment),this.h()},l(p){v&&v.l(p),e=ne(p),ce(t.$$.fragment,p),l=ne(p),ce(o.$$.fragment,p),s=ne(p),ce(r.$$.fragment,p),i=ne(p),ce(a.$$.fragment,p),u=ne(p),c=H(p,"HR",{class:!0}),f=ne(p),h=H(p,"DIV",{class:!0});var g=T(h);ce(d.$$.fragment,g),g.forEach(b),this.h()},h(){m(c,"class","border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5"),m(h,"class","flex p-1")},m(p,g){v&&v.m(p,g),W(p,e,g),ae(t,p,g),W(p,l,g),ae(o,p,g),W(p,s,g),ae(r,p,g),W(p,i,g),ae(a,p,g),W(p,u,g),W(p,c,g),W(p,f,g),W(p,h,g),ae(d,h,null),_=!0},p(p,g){p[3]?v?(v.p(p,g),g&8&&P(v,1)):(v=bi(p),v.c(),P(v,1),v.m(e.parentNode,e)):v&&(je(),B(v,1,1,()=>{v=null}),Ye());const y={};g&2097168&&(y.$$scope={dirty:g,ctx:p}),t.$set(y);const k={};g&2097168&&(k.$$scope={dirty:g,ctx:p}),o.$set(k);const w={};g&2097168&&(w.$$scope={dirty:g,ctx:p}),r.$set(w);const N={};g&2097168&&(N.$$scope={dirty:g,ctx:p}),a.$set(N);const S={};g&2&&(S.chatId=p[1].id),d.$set(S)},i(p){_||(P(v),P(t.$$.fragment,p),P(o.$$.fragment,p),P(r.$$.fragment,p),P(a.$$.fragment,p),P(d.$$.fragment,p),_=!0)},o(p){B(v),B(t.$$.fragment,p),B(o.$$.fragment,p),B(r.$$.fragment,p),B(a.$$.fragment,p),B(d.$$.fragment,p),_=!1},d(p){p&&(b(e),b(l),b(s),b(i),b(u),b(c),b(f),b(h)),v&&v.d(p),ue(t,p),ue(o,p),ue(r,p),ue(a,p),ue(d)}}}function Mh(n){let e,t,l;return t=new po({props:{class:"w-full max-w-[200px] rounded-xl px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow-lg",sideOffset:8,side:"bottom",align:"end",transition:Wl,$$slots:{default:[zh]},$$scope:{ctx:n}}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{slot:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"slot","content")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p(o,s){const r={};s&2097179&&(r.$$scope={dirty:s,ctx:o}),t.$set(r)},i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function Th(n){let e,t;return e=new yo({props:{$$slots:{content:[Mh],default:[bh]},$$scope:{ctx:n}}}),e.$on("change",n[20]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&2097179&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function Ph(n,e,t){let l,o;se(n,vo,V=>t(3,l=V));let{$$slots:s={},$$scope:r}=e;const{saveAs:i}=Gu,a=Lt("i18n");se(n,a,V=>t(4,o=V));let{shareEnabled:u=!1}=e,{shareHandler:c}=e,{downloadHandler:f}=e,{chat:h}=e,{onClose:d=()=>{}}=e;const _=async()=>{const V=h.chat;return gs(V.history,V.history.currentId).reduce((K,E,q,D)=>`${K}### ${E.role.toUpperCase()} ${E.content} `,"").trim()},v=async()=>{const V=await _();let L=new Blob([V],{type:"text/plain"});i(L,`chat-${h.chat.title}.txt`)},p=async()=>{const V=h.chat,L=gs(V.history,V.history.currentId);console.log("download",h);const Y=await qu(V.title,L),K=window.URL.createObjectURL(Y),E=document.createElement("a");E.href=K,E.download=`chat-${V.title}.pdf`,document.body.appendChild(E),E.click(),document.body.removeChild(E),window.URL.revokeObjectURL(K)},g=async()=>{let V=new Blob([JSON.stringify([h])],{type:"application/json"});i(V,`chat-export-${Date.now()}.json`)},y=async()=>{await qt.set(!0)},k=async()=>{await qt.set(!0),await Hl.set(!0)},w=async()=>{await Uo(await _()).catch(L=>{console.error(L)})&&$e.success(o.t("Copied to clipboard"))},N=()=>{c()},S=()=>{g()},A=()=>{v()},z=()=>{p()},M=V=>{V.detail===!1&&d()};return n.$$set=V=>{"shareEnabled"in V&&t(10,u=V.shareEnabled),"shareHandler"in V&&t(0,c=V.shareHandler),"downloadHandler"in V&&t(11,f=V.downloadHandler),"chat"in V&&t(1,h=V.chat),"onClose"in V&&t(2,d=V.onClose),"$$scope"in V&&t(21,r=V.$$scope)},[c,h,d,l,o,a,_,v,p,g,u,f,s,y,k,w,N,S,A,z,M,r]}class Vh extends ke{constructor(e){super(),Ee(this,e,Ph,Th,Se,{shareEnabled:10,shareHandler:0,downloadHandler:11,chat:1,onClose:2})}}function pi(n){let e,t,l;function o(r){n[17](r)}let s={showSetDefault:!n[2]};return n[0]!==void 0&&(s.selectedModels=n[0]),e=new ah({props:s}),Be.push(()=>lt(e,"selectedModels",o)),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),l=!0},p(r,i){const a={};i&4&&(a.showSetDefault=!r[2]),!t&&i&1&&(t=!0,a.selectedModels=r[0],nt(()=>t=!1)),e.$set(a)},i(r){l||(P(e.$$.fragment,r),l=!0)},o(r){B(e.$$.fragment,r),l=!1},d(r){ue(e,r)}}}function vi(n){let e,t;return e=new Vh({props:{chat:n[3],shareEnabled:n[2],shareHandler:n[18],downloadHandler:n[19],$$slots:{default:[Nh]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&8&&(s.chat=l[3]),o&4&&(s.shareEnabled=l[2]),o&32&&(s.shareHandler=l[18]),o&64&&(s.downloadHandler=l[19]),o&16777216&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function Nh(n){let e,t='
';return{c(){e=O("button"),e.innerHTML=t,this.h()},l(l){e=H(l,"BUTTON",{class:!0,id:!0,"data-svelte-h":!0}),ut(e)!=="svelte-xd5mtd"&&(e.innerHTML=t),this.h()},h(){m(e,"class","flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"),m(e,"id","chat-context-menu-button")},m(l,o){W(l,e,o)},p:we,d(l){l&&b(e)}}}function yi(n){let e,t;return e=new pn({props:{content:n[10].t("Controls"),$$slots:{default:[Oh]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&1024&&(s.content=l[10].t("Controls")),o&16779264&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function Oh(n){let e,t,l,o,s,r;return l=new aa({props:{className:" size-5",strokeWidth:"0.5"}}),{c(){e=O("button"),t=O("div"),re(l.$$.fragment),this.h()},l(i){e=H(i,"BUTTON",{class:!0,"aria-label":!0});var a=T(e);t=H(a,"DIV",{class:!0});var u=T(t);ce(l.$$.fragment,u),u.forEach(b),a.forEach(b),this.h()},h(){m(t,"class","m-auto self-center"),m(e,"class","flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"),m(e,"aria-label","Controls")},m(i,a){W(i,e,a),I(e,t),ae(l,t,null),o=!0,s||(r=he(e,"click",n[20]),s=!0)},p:we,i(i){o||(P(l.$$.fragment,i),o=!0)},o(i){B(l.$$.fragment,i),o=!1},d(i){i&&b(e),ue(l),s=!1,r()}}}function Hh(n){let e,t,l='',o,s,r;return{c(){e=O("button"),t=O("div"),t.innerHTML=l,this.h()},l(i){e=H(i,"BUTTON",{id:!0,class:!0,"aria-label":!0});var a=T(e);t=H(a,"DIV",{class:!0,"data-svelte-h":!0}),ut(t)!=="svelte-1fcii9y"&&(t.innerHTML=l),a.forEach(b),this.h()},h(){m(t,"class","m-auto self-center"),m(e,"id","new-chat-button"),m(e,"class",o="flex "+(n[8]?"md:hidden":"")+" cursor-pointer px-2 py-2 rounded-xl text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-850 transition"),m(e,"aria-label","New Chat")},m(i,a){W(i,e,a),I(e,t),s||(r=he(e,"click",n[21]),s=!0)},p(i,a){a&256&&o!==(o="flex "+(i[8]?"md:hidden":"")+" cursor-pointer px-2 py-2 rounded-xl text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-850 transition")&&m(e,"class",o)},d(i){i&&b(e),s=!1,r()}}}function wi(n){let e,t;return e=new Hu({props:{className:"max-w-[200px]",role:n[12].role,$$slots:{default:[Lh]},$$scope:{ctx:n}}}),e.$on("show",n[22]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&4096&&(s.role=l[12].role),o&16781312&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function Lh(n){let e,t,l,o;return{c(){e=O("button"),t=O("div"),l=O("img"),this.h()},l(s){e=H(s,"BUTTON",{class:!0,"aria-label":!0});var r=T(e);t=H(r,"DIV",{class:!0});var i=T(t);l=H(i,"IMG",{src:!0,class:!0,alt:!0,draggable:!0}),i.forEach(b),r.forEach(b),this.h()},h(){Gn(l.src,o=n[12].profile_image_url)||m(l,"src",o),m(l,"class","size-6 object-cover rounded-full"),m(l,"alt","User profile"),m(l,"draggable","false"),m(t,"class","self-center"),m(e,"class","select-none flex rounded-xl p-1.5 w-full hover:bg-gray-50 dark:hover:bg-gray-850 transition"),m(e,"aria-label","User Menu")},m(s,r){W(s,e,r),I(e,t),I(t,l)},p(s,r){r&4096&&!Gn(l.src,o=s[12].profile_image_url)&&m(l,"src",o)},d(s){s&&b(e)}}}function Ah(n){let e,t,l,o,s,r,i,a,u,c,f,h,d,_,v,p,g,y,k,w,N,S;function A(K){n[15](K)}let z={chatId:n[7]};n[5]!==void 0&&(z.show=n[5]),e=new Ou({props:z}),Be.push(()=>lt(e,"show",A)),c=new Ju({});let M=n[4]&&pi(n),V=n[2]&&n[3]&&n[3].id&&vi(n),L=!n[9]&&yi(n);y=new pn({props:{content:n[10].t("New Chat"),$$slots:{default:[Hh]},$$scope:{ctx:n}}});let Y=n[12]!==void 0&&wi(n);return{c(){re(e.$$.fragment),l=te(),o=O("nav"),s=O("div"),r=O("div"),i=O("div"),a=O("button"),u=O("div"),re(c.$$.fragment),h=te(),d=O("div"),M&&M.c(),_=te(),v=O("div"),V&&V.c(),p=te(),L&&L.c(),g=te(),re(y.$$.fragment),k=te(),Y&&Y.c(),this.h()},l(K){ce(e.$$.fragment,K),l=ne(K),o=H(K,"NAV",{id:!0,class:!0});var E=T(o);s=H(E,"DIV",{class:!0});var q=T(s);r=H(q,"DIV",{class:!0});var D=T(r);i=H(D,"DIV",{class:!0});var U=T(i);a=H(U,"BUTTON",{id:!0,class:!0,"aria-label":!0});var F=T(a);u=H(F,"DIV",{class:!0});var C=T(u);ce(c.$$.fragment,C),C.forEach(b),F.forEach(b),U.forEach(b),h=ne(D),d=H(D,"DIV",{class:!0});var R=T(d);M&&M.l(R),R.forEach(b),_=ne(D),v=H(D,"DIV",{class:!0});var G=T(v);V&&V.l(G),p=ne(G),L&&L.l(G),g=ne(G),ce(y.$$.fragment,G),k=ne(G),Y&&Y.l(G),G.forEach(b),D.forEach(b),q.forEach(b),E.forEach(b),this.h()},h(){m(u,"class","m-auto self-center"),m(a,"id","sidebar-toggle-button"),m(a,"class","cursor-pointer px-2 py-2 flex rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"),m(a,"aria-label","Toggle Sidebar"),m(i,"class",f=(n[8]?"md:hidden":"")+" mr-3 self-start flex flex-none items-center text-gray-600 dark:text-gray-400"),m(d,"class","flex-1 overflow-hidden max-w-full"),m(v,"class","self-start flex flex-none items-center text-gray-600 dark:text-gray-400"),m(r,"class","flex items-center w-full max-w-full"),m(s,"class","flex max-w-full w-full mx-auto px-5 pt-0.5 md:px-[1rem]"),m(o,"id","nav"),m(o,"class","sticky py-2.5 top-0 flex flex-row justify-center z-10")},m(K,E){ae(e,K,E),W(K,l,E),W(K,o,E),I(o,s),I(s,r),I(r,i),I(i,a),I(a,u),ae(c,u,null),I(r,h),I(r,d),M&&M.m(d,null),I(r,_),I(r,v),V&&V.m(v,null),I(v,p),L&&L.m(v,null),I(v,g),ae(y,v,null),I(v,k),Y&&Y.m(v,null),w=!0,N||(S=he(a,"click",n[16]),N=!0)},p(K,[E]){const q={};E&128&&(q.chatId=K[7]),!t&&E&32&&(t=!0,q.show=K[5],nt(()=>t=!1)),e.$set(q),(!w||E&256&&f!==(f=(K[8]?"md:hidden":"")+" mr-3 self-start flex flex-none items-center text-gray-600 dark:text-gray-400"))&&m(i,"class",f),K[4]?M?(M.p(K,E),E&16&&P(M,1)):(M=pi(K),M.c(),P(M,1),M.m(d,null)):M&&(je(),B(M,1,1,()=>{M=null}),Ye()),K[2]&&K[3]&&K[3].id?V?(V.p(K,E),E&12&&P(V,1)):(V=vi(K),V.c(),P(V,1),V.m(v,p)):V&&(je(),B(V,1,1,()=>{V=null}),Ye()),K[9]?L&&(je(),B(L,1,1,()=>{L=null}),Ye()):L?(L.p(K,E),E&512&&P(L,1)):(L=yi(K),L.c(),P(L,1),L.m(v,g));const D={};E&1024&&(D.content=K[10].t("New Chat")),E&16777474&&(D.$$scope={dirty:E,ctx:K}),y.$set(D),K[12]!==void 0?Y?(Y.p(K,E),E&4096&&P(Y,1)):(Y=wi(K),Y.c(),P(Y,1),Y.m(v,null)):Y&&(je(),B(Y,1,1,()=>{Y=null}),Ye())},i(K){w||(P(e.$$.fragment,K),P(c.$$.fragment,K),P(M),P(V),P(L),P(y.$$.fragment,K),P(Y),w=!0)},o(K){B(e.$$.fragment,K),B(c.$$.fragment,K),B(M),B(V),B(L),B(y.$$.fragment,K),B(Y),w=!1},d(K){K&&(b(l),b(o)),ue(e,K),ue(c),M&&M.d(),V&&V.d(),L&&L.d(),ue(y),Y&&Y.d(),N=!1,S()}}}function Bh(n,e,t){let l,o,s,r,i,a,u;se(n,Fr,L=>t(23,l=L)),se(n,ol,L=>t(7,o=L)),se(n,uo,L=>t(8,s=L)),se(n,vo,L=>t(9,r=L)),se(n,qt,L=>t(11,a=L)),se(n,Il,L=>t(12,u=L));const c=Lt("i18n");se(n,c,L=>t(10,i=L));let{initNewChat:f}=e,{title:h=l}=e,{shareEnabled:d=!1}=e,{chat:_}=e,{selectedModels:v}=e,{showModelSelector:p=!0}=e,g=!1,y=!1;function k(L){g=L,t(5,g)}const w=()=>{uo.set(!s)};function N(L){v=L,t(0,v)}const S=()=>{t(5,g=!g)},A=()=>{t(6,y=!y)},z=async()=>{await qt.set(!a)},M=()=>{f()},V=L=>{L.detail==="archived-chat"&&au.set(!0)};return n.$$set=L=>{"initNewChat"in L&&t(1,f=L.initNewChat),"title"in L&&t(14,h=L.title),"shareEnabled"in L&&t(2,d=L.shareEnabled),"chat"in L&&t(3,_=L.chat),"selectedModels"in L&&t(0,v=L.selectedModels),"showModelSelector"in L&&t(4,p=L.showModelSelector)},[v,f,d,_,p,g,y,o,s,r,i,a,u,c,h,k,w,N,S,A,z,M,V]}class Rh extends ke{constructor(e){super(),Ee(this,e,Bh,Ah,Se,{initNewChat:1,title:14,shareEnabled:2,chat:3,selectedModels:0,showModelSelector:4})}}function Mt(n){if(typeof n=="string"||typeof n=="number")return""+n;let e="";if(Array.isArray(n))for(let t=0,l;t"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:n=>`Node type "${n}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:n=>`The old edge with id=${n} does not exist.`,error009:n=>`Marker type "${n}" doesn't exist.`,error008:(n,{id:e,sourceHandle:t,targetHandle:l})=>`Couldn't create edge for ${n} handle id: "${n==="source"?t:l}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:n=>`Edge type "${n}" not found. Using fallback type "default".`,error012:n=>`Node with id "${n}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(n="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${n}/dist/style.css' or base.css to make sure everything is working properly.`},co=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var al;(function(n){n.Strict="strict",n.Loose="loose"})(al||(al={}));var jn;(function(n){n.Free="free",n.Vertical="vertical",n.Horizontal="horizontal"})(jn||(jn={}));var fo;(function(n){n.Partial="partial",n.Full="full"})(fo||(fo={}));const Yo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var bl;(function(n){n.Bezier="default",n.Straight="straight",n.Step="step",n.SmoothStep="smoothstep",n.SimpleBezier="simplebezier"})(bl||(bl={}));var ho;(function(n){n.Arrow="arrow",n.ArrowClosed="arrowclosed"})(ho||(ho={}));var tt;(function(n){n.Left="left",n.Top="top",n.Right="right",n.Bottom="bottom"})(tt||(tt={}));const ki={[tt.Left]:tt.Right,[tt.Right]:tt.Left,[tt.Top]:tt.Bottom,[tt.Bottom]:tt.Top};function Uh(n,e){if(!n&&!e)return!0;if(!n||!e||n.size!==e.size)return!1;if(!n.size&&!e.size)return!0;for(const t of n.keys())if(!e.has(t))return!1;return!0}function Ei(n,e,t){if(!t)return;const l=[];n.forEach((o,s)=>{e!=null&&e.has(s)||l.push(o)}),l.length&&t(l)}function Si(n){return n===null?null:n?"valid":"invalid"}const Wh=n=>"id"in n&&"source"in n&&"target"in n,Fh=n=>"id"in n&&"position"in n&&!("source"in n)&&!("target"in n),ss=n=>"id"in n&&"internals"in n&&!("source"in n)&&!("target"in n),wo=(n,e=[0,0])=>{const{width:t,height:l}=Cl(n),o=n.origin??e,s=t*o[0],r=l*o[1];return{x:n.position.x-s,y:n.position.y-r}},jh=(n,e={nodeOrigin:[0,0],nodeLookup:void 0})=>{if(n.length===0)return{x:0,y:0,width:0,height:0};const t=n.reduce((l,o)=>{const s=typeof o=="string";let r=!e.nodeLookup&&!s?o:void 0;e.nodeLookup&&(r=s?e.nodeLookup.get(o):ss(o)?o:e.nodeLookup.get(o.id));const i=r?mo(r,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Eo(l,i)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return So(t)},ko=(n,e={})=>{if(n.size===0)return{x:0,y:0,width:0,height:0};let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return n.forEach(l=>{if(e.filter===void 0||e.filter(l)){const o=mo(l);t=Eo(t,o)}}),So(t)},ua=(n,e,[t,l,o]=[0,0,1],s=!1,r=!1)=>{const i={...Xl(e,[t,l,o]),width:e.width/o,height:e.height/o},a=[];for(const u of n.values()){const{measured:c,selectable:f=!0,hidden:h=!1}=u;if(r&&!f||h)continue;const d=c.width??u.width??u.initialWidth??null,_=c.height??u.height??u.initialHeight??null,v=Bl(i,wl(u)),p=(d??0)*(_??0),g=s&&v>0;(!u.internals.handleBounds||g||v>=p||u.dragging)&&a.push(u)}return a},Xo=(n,e)=>{const t=new Set;return n.forEach(l=>{t.add(l.id)}),e.filter(l=>t.has(l.source)||t.has(l.target))};function Ii(n,e){const t=new Map,l=e!=null&&e.nodes?new Set(e.nodes.map(o=>o.id)):null;return n.forEach(o=>{o.measured.width&&o.measured.height&&((e==null?void 0:e.includeHiddenNodes)||!o.hidden)&&(!l||l.has(o.id))&&t.set(o.id,o)}),t}async function Ci({nodes:n,width:e,height:t,panZoom:l,minZoom:o,maxZoom:s},r){if(n.size===0)return Promise.resolve(!1);const i=ko(n),a=rs(i,e,t,(r==null?void 0:r.minZoom)??o,(r==null?void 0:r.maxZoom)??s,(r==null?void 0:r.padding)??.1);return await l.setViewport(a,{duration:r==null?void 0:r.duration}),Promise.resolve(!0)}function Yh({nodeId:n,nextPosition:e,nodeLookup:t,nodeOrigin:l=[0,0],nodeExtent:o,onError:s}){const r=t.get(n),i=r.parentId?t.get(r.parentId):void 0,{x:a,y:u}=i?i.internals.positionAbsolute:{x:0,y:0},c=r.origin??l;let f=o;if(r.extent==="parent"&&!r.expandParent)if(!i)s==null||s("005",Yl.error005());else{const d=i.measured.width,_=i.measured.height;d&&_&&(f=[[a,u],[a+d,u+_]])}else i&&Rl(r.extent)&&(f=[[r.extent[0][0]+a,r.extent[0][1]+u],[r.extent[1][0]+a,r.extent[1][1]+u]]);const h=Rl(f)?yl(e,f,r.measured):e;return{position:{x:h.x-a+r.measured.width*c[0],y:h.y-u+r.measured.height*c[1]},positionAbsolute:h}}async function ca({nodesToRemove:n=[],edgesToRemove:e=[],nodes:t,edges:l,onBeforeDelete:o}){const s=new Set(n.map(h=>h.id)),r=[];for(const h of t){if(h.deletable===!1)continue;const d=s.has(h.id),_=!d&&h.parentId&&r.find(v=>v.id===h.parentId);(d||_)&&r.push(h)}const i=new Set(e.map(h=>h.id)),a=l.filter(h=>h.deletable!==!1),c=Xo(r,a);for(const h of a)i.has(h.id)&&!c.find(_=>_.id===h.id)&&c.push(h);if(!o)return{edges:c,nodes:r};const f=await o({nodes:r,edges:c});return typeof f=="boolean"?f?{edges:c,nodes:r}:{edges:[],nodes:[]}:f}const vl=(n,e=0,t=1)=>Math.min(Math.max(n,e),t),yl=(n={x:0,y:0},e,t)=>({x:vl(n.x,e[0][0],e[1][0]-((t==null?void 0:t.width)??0)),y:vl(n.y,e[0][1],e[1][1]-((t==null?void 0:t.height)??0))});function fa(n,e,t){const{width:l,height:o}=Cl(t),{x:s,y:r}=t.internals.positionAbsolute;return yl(n,[[s,r],[s+l,r+o]],e)}const Di=(n,e,t)=>nt?-vl(Math.abs(n-t),1,e)/e:0,da=(n,e,t=15,l=40)=>{const o=Di(n.x,l,e.width-l)*t,s=Di(n.y,l,e.height-l)*t;return[o,s]},Eo=(n,e)=>({x:Math.min(n.x,e.x),y:Math.min(n.y,e.y),x2:Math.max(n.x2,e.x2),y2:Math.max(n.y2,e.y2)}),Ko=({x:n,y:e,width:t,height:l})=>({x:n,y:e,x2:n+t,y2:e+l}),So=({x:n,y:e,x2:t,y2:l})=>({x:n,y:e,width:t-n,height:l-e}),wl=(n,e=[0,0])=>{var o,s;const{x:t,y:l}=ss(n)?n.internals.positionAbsolute:wo(n,e);return{x:t,y:l,width:((o=n.measured)==null?void 0:o.width)??n.width??n.initialWidth??0,height:((s=n.measured)==null?void 0:s.height)??n.height??n.initialHeight??0}},mo=(n,e=[0,0])=>{var o,s;const{x:t,y:l}=ss(n)?n.internals.positionAbsolute:wo(n,e);return{x:t,y:l,x2:t+(((o=n.measured)==null?void 0:o.width)??n.width??n.initialWidth??0),y2:l+(((s=n.measured)==null?void 0:s.height)??n.height??n.initialHeight??0)}},Xh=(n,e)=>So(Eo(Ko(n),Ko(e))),Bl=(n,e)=>{const t=Math.max(0,Math.min(n.x+n.width,e.x+e.width)-Math.max(n.x,e.x)),l=Math.max(0,Math.min(n.y+n.height,e.y+e.height)-Math.max(n.y,e.y));return Math.ceil(t*l)},zi=n=>Vn(n.width)&&Vn(n.height)&&Vn(n.x)&&Vn(n.y),Vn=n=>!isNaN(n)&&isFinite(n),Kh=(n,e)=>{},is=(n,e=[1,1])=>({x:e[0]*Math.round(n.x/e[0]),y:e[1]*Math.round(n.y/e[1])}),Xl=({x:n,y:e},[t,l,o],s=!1,r=[1,1])=>{const i={x:(n-t)/o,y:(e-l)/o};return s?is(i,r):i},ha=({x:n,y:e},[t,l,o])=>({x:n*o+t,y:e*o+l}),rs=(n,e,t,l,o,s)=>{const r=e/(n.width*(1+s)),i=t/(n.height*(1+s)),a=Math.min(r,i),u=vl(a,l,o),c=n.x+n.width/2,f=n.y+n.height/2,h=e/2-c*u,d=t/2-f*u;return{x:h,y:d,zoom:u}},go=()=>{var n;return typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)==null?void 0:n.indexOf("Mac"))>=0};function Rl(n){return n!==void 0&&n!=="parent"}function Cl(n){var e,t;return{width:((e=n.measured)==null?void 0:e.width)??n.width??n.initialWidth??0,height:((t=n.measured)==null?void 0:t.height)??n.height??n.initialHeight??0}}function Mi(n){var e,t;return(((e=n.measured)==null?void 0:e.width)??n.width??n.initialWidth)!==void 0&&(((t=n.measured)==null?void 0:t.height)??n.height??n.initialHeight)!==void 0}function Zh(n,e={width:0,height:0},t,l,o){let s=t;const r={...n};for(;s;){const i=l.get(s);if(s=i==null?void 0:i.parentId,i){const a=i.origin||o;r.x+=i.internals.positionAbsolute.x-(e.width??0)*a[0],r.y+=i.internals.positionAbsolute.y-(e.height??0)*a[1]}}return r}function Ho(n,{snapGrid:e=[0,0],snapToGrid:t=!1,transform:l}){const{x:o,y:s}=Kn(n),r=Xl({x:o,y:s},l),{x:i,y:a}=t?is(r,e):r;return{xSnapped:i,ySnapped:a,...r}}const ma=n=>({width:n.offsetWidth,height:n.offsetHeight}),Gh=n=>{var e;return((e=n.getRootNode)==null?void 0:e.call(n))||(window==null?void 0:window.document)},qh=["INPUT","SELECT","TEXTAREA"];function Jh(n){var l,o;const e=((o=(l=n.composedPath)==null?void 0:l.call(n))==null?void 0:o[0])||n.target;return qh.includes(e==null?void 0:e.nodeName)||(e==null?void 0:e.hasAttribute("contenteditable"))||!!(e!=null&&e.closest(".nokey"))}const ga=n=>"clientX"in n,Kn=(n,e)=>{var s,r;const t=ga(n),l=t?n.clientX:(s=n.touches)==null?void 0:s[0].clientX,o=t?n.clientY:(r=n.touches)==null?void 0:r[0].clientY;return{x:l-((e==null?void 0:e.left)??0),y:o-((e==null?void 0:e.top)??0)}},Ti=(n,e,t,l,o)=>{const s=e.querySelectorAll(`.${n}`);return!s||!s.length?null:Array.from(s).map(r=>{const i=r.getBoundingClientRect();return{id:r.getAttribute("data-handleid"),type:n,nodeId:o,position:r.getAttribute("data-handlepos"),x:(i.left-t.left)/l,y:(i.top-t.top)/l,...ma(r)}})};function Qh({sourceX:n,sourceY:e,targetX:t,targetY:l,sourceControlX:o,sourceControlY:s,targetControlX:r,targetControlY:i}){const a=n*.125+o*.375+r*.375+t*.125,u=e*.125+s*.375+i*.375+l*.125,c=Math.abs(a-n),f=Math.abs(u-e);return[a,u,c,f]}function no(n,e){return n>=0?.5*n:e*25*Math.sqrt(-n)}function Pi({pos:n,x1:e,y1:t,x2:l,y2:o,c:s}){switch(n){case tt.Left:return[e-no(e-l,s),t];case tt.Right:return[e+no(l-e,s),t];case tt.Top:return[e,t-no(t-o,s)];case tt.Bottom:return[e,t+no(o-t,s)]}}function _a({sourceX:n,sourceY:e,sourcePosition:t=tt.Bottom,targetX:l,targetY:o,targetPosition:s=tt.Top,curvature:r=.25}){const[i,a]=Pi({pos:t,x1:n,y1:e,x2:l,y2:o,c:r}),[u,c]=Pi({pos:s,x1:l,y1:o,x2:n,y2:e,c:r}),[f,h,d,_]=Qh({sourceX:n,sourceY:e,targetX:l,targetY:o,sourceControlX:i,sourceControlY:a,targetControlX:u,targetControlY:c});return[`M${n},${e} C${i},${a} ${u},${c} ${l},${o}`,f,h,d,_]}function ba({sourceX:n,sourceY:e,targetX:t,targetY:l}){const o=Math.abs(t-n)/2,s=t0}const e1=({source:n,sourceHandle:e,target:t,targetHandle:l})=>`xy-edge__${n}${e||""}-${t}${l||""}`,t1=(n,e)=>e.some(t=>t.source===n.source&&t.target===n.target&&(t.sourceHandle===n.sourceHandle||!t.sourceHandle&&!n.sourceHandle)&&(t.targetHandle===n.targetHandle||!t.targetHandle&&!n.targetHandle)),n1=(n,e)=>{if(!n.source||!n.target)return e;let t;return Wh(n)?t={...n}:t={...n,id:e1(n)},t1(t,e)?e:(t.sourceHandle===null&&delete t.sourceHandle,t.targetHandle===null&&delete t.targetHandle,e.concat(t))};function pa({sourceX:n,sourceY:e,targetX:t,targetY:l}){const[o,s,r,i]=ba({sourceX:n,sourceY:e,targetX:t,targetY:l});return[`M ${n},${e}L ${t},${l}`,o,s,r,i]}const Vi={[tt.Left]:{x:-1,y:0},[tt.Right]:{x:1,y:0},[tt.Top]:{x:0,y:-1},[tt.Bottom]:{x:0,y:1}},l1=({source:n,sourcePosition:e=tt.Bottom,target:t})=>e===tt.Left||e===tt.Right?n.xMath.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));function o1({source:n,sourcePosition:e=tt.Bottom,target:t,targetPosition:l=tt.Top,center:o,offset:s}){const r=Vi[e],i=Vi[l],a={x:n.x+r.x*s,y:n.y+r.y*s},u={x:t.x+i.x*s,y:t.y+i.y*s},c=l1({source:a,sourcePosition:e,target:u}),f=c.x!==0?"x":"y",h=c[f];let d=[],_,v;const p={x:0,y:0},g={x:0,y:0},[y,k,w,N]=ba({sourceX:n.x,sourceY:n.y,targetX:t.x,targetY:t.y});if(r[f]*i[f]===-1){_=o.x??y,v=o.y??k;const A=[{x:_,y:a.y},{x:_,y:u.y}],z=[{x:a.x,y:v},{x:u.x,y:v}];r[f]===h?d=f==="x"?A:z:d=f==="x"?z:A}else{const A=[{x:a.x,y:u.y}],z=[{x:u.x,y:a.y}];if(f==="x"?d=r.x===h?z:A:d=r.y===h?A:z,e===l){const K=Math.abs(n[f]-t[f]);if(K<=s){const E=Math.min(s-1,s-K);r[f]===h?p[f]=(a[f]>n[f]?-1:1)*E:g[f]=(u[f]>t[f]?-1:1)*E}}if(e!==l){const K=f==="x"?"y":"x",E=r[f]===i[K],q=a[K]>u[K],D=a[K]=Y?(_=(M.x+V.x)/2,v=d[0].y):(_=d[0].x,v=(M.y+V.y)/2)}return[[n,{x:a.x+p.x,y:a.y+p.y},...d,{x:u.x+g.x,y:u.y+g.y},t],_,v,w,N]}function s1(n,e,t,l){const o=Math.min(Ni(n,e)/2,Ni(e,t)/2,l),{x:s,y:r}=e;if(n.x===s&&s===t.x||n.y===r&&r===t.y)return`L${s} ${r}`;if(n.y===r){const u=n.x{let k="";return y>0&&yt.id===e):n[0])||null}function Zo(n,e){return n?typeof n=="string"?n:`${e?`${e}__`:""}${Object.keys(n).sort().map(l=>`${l}=${n[l]}`).join("&")}`:""}function r1(n,{id:e,defaultColor:t,defaultMarkerStart:l,defaultMarkerEnd:o}){const s=new Set;return n.reduce((r,i)=>([i.markerStart||l,i.markerEnd||o].forEach(a=>{if(a&&typeof a=="object"){const u=Zo(a,e);s.has(u)||(r.push({id:u,color:a.color||t,...a}),s.add(u))}}),r),[]).sort((r,i)=>r.id.localeCompare(i.id))}const va={nodeOrigin:[0,0],nodeExtent:co,elevateNodesOnSelect:!0,defaults:{}},a1={...va,checkEquality:!0};function ya(n,e){const t={...n};for(const l in e)e[l]!==void 0&&(t[l]=e[l]);return t}function wa(n,e,t,l){var i,a;const o=ya(a1,l),s=new Map(e),r=o!=null&&o.elevateNodesOnSelect?1e3:0;e.clear(),t.clear();for(const u of n){let c=s.get(u.id);if(o.checkEquality&&u===(c==null?void 0:c.internals.userNode))e.set(u.id,c);else{const f=wo(u,o.nodeOrigin),h=Rl(u.extent)?u.extent:o.nodeExtent,d=yl(f,h,Cl(u));c={...o.defaults,...u,measured:{width:(i=u.measured)==null?void 0:i.width,height:(a=u.measured)==null?void 0:a.height},internals:{positionAbsolute:d,handleBounds:u.measured?c==null?void 0:c.internals.handleBounds:void 0,z:Ea(u,r),userNode:u}},e.set(u.id,c)}u.parentId&&ka(c,e,t,l)}}function u1(n,e){if(!n.parentId)return;const t=e.get(n.parentId);t?t.set(n.id,n):e.set(n.parentId,new Map([[n.id,n]]))}function ka(n,e,t,l){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:r}=ya(va,l),i=n.parentId,a=e.get(i);if(!a){console.warn(`Parent node ${i} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}u1(n,t);const u=o?1e3:0,{x:c,y:f,z:h}=c1(n,a,s,r,u),{positionAbsolute:d}=n.internals,_=c!==d.x||f!==d.y;(_||h!==n.internals.z)&&(n.internals={...n.internals,positionAbsolute:_?{x:c,y:f}:d,z:h})}function Ea(n,e){return(Vn(n.zIndex)?n.zIndex:0)+(n.selected?e:0)}function c1(n,e,t,l,o){const{x:s,y:r}=e.internals.positionAbsolute,i=Cl(n),a=wo(n,t),u=Rl(n.extent)?yl(a,n.extent,i):a;let c=yl({x:s+u.x,y:r+u.y},l,i);n.extent==="parent"&&(c=fa(c,i,e));const f=Ea(n,o),h=e.internals.z??0;return{x:c.x,y:c.y,z:h>f?h:f}}function f1(n,e,t,l=[0,0]){var r;const o=[],s=new Map;for(const i of n){const a=e.get(i.parentId);if(!a)continue;const u=((r=s.get(i.parentId))==null?void 0:r.expandedRect)??wl(a),c=Xh(u,i.rect);s.set(i.parentId,{expandedRect:c,parent:a})}return s.size>0&&s.forEach(({expandedRect:i,parent:a},u)=>{var k;const c=a.internals.positionAbsolute,f=Cl(a),h=a.origin??l,d=i.x0||_>0||g||y)&&(o.push({id:u,type:"position",position:{x:a.position.x-d+g,y:a.position.y-_+y}}),(k=t.get(u))==null||k.forEach(w=>{n.some(N=>N.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+d,y:w.position.y+_}})})),(f.width0){const h=f1(f,e,t,o);a.push(...h)}return{changes:a,updatedInternals:i}}async function h1({delta:n,panZoom:e,transform:t,translateExtent:l,width:o,height:s}){if(!e||!n.x&&!n.y)return Promise.resolve(!1);const r=await e.setViewportConstrained({x:t[0]+n.x,y:t[1]+n.y,zoom:t[2]},[[0,0],[o,s]],l),i=!!r&&(r.x!==t[0]||r.y!==t[1]||r.k!==t[2]);return Promise.resolve(i)}function Sa(n,e,t){n.clear(),e.clear();for(const l of t){const{source:o,target:s,sourceHandle:r=null,targetHandle:i=null}=l,a=`${o}-source-${r}`,u=`${s}-target-${i}`,c=n.get(a)||new Map,f=n.get(u)||new Map,h={edgeId:l.id,source:o,target:s,sourceHandle:r,targetHandle:i};e.set(l.id,l),n.set(a,c.set(`${s}-${i}`,h)),n.set(u,f.set(`${o}-${r}`,h))}}function Ia(n,e){if(!n.parentId)return!1;const t=e.get(n.parentId);return t?t.selected?!0:Ia(t,e):!1}function Ai(n,e,t){let l=n;do{if(l!=null&&l.matches(e))return!0;if(l===t)return!1;l=l.parentElement}while(l);return!1}function m1(n,e,t,l){const o=new Map;for(const[s,r]of n)if((r.selected||r.id===l)&&(!r.parentId||!Ia(r,n))&&(r.draggable||e&&typeof r.draggable>"u")){const i=n.get(s);i&&o.set(s,{id:s,position:i.position||{x:0,y:0},distance:{x:t.x-i.internals.positionAbsolute.x,y:t.y-i.internals.positionAbsolute.y},extent:i.extent,parentId:i.parentId,origin:i.origin,expandParent:i.expandParent,internals:{positionAbsolute:i.internals.positionAbsolute||{x:0,y:0}},measured:{width:i.measured.width??0,height:i.measured.height??0}})}return o}function Lo({nodeId:n,dragItems:e,nodeLookup:t,dragging:l=!0}){var r,i;const o=[];for(const[a,u]of e){const c=(r=t.get(a))==null?void 0:r.internals.userNode;c&&o.push({...c,position:u.position,dragging:l})}if(!n)return[o[0],o];const s=t.get(n).internals.userNode;return[{...s,position:((i=e.get(n))==null?void 0:i.position)||s.position,dragging:l},o]}function g1({onNodeMouseDown:n,getStoreItems:e,onDragStart:t,onDrag:l,onDragStop:o}){let s={x:null,y:null},r=0,i=new Map,a=!1,u={x:0,y:0},c=null,f=!1,h=null,d=!1;function _({noDragClassName:p,handleSelector:g,domNode:y,isSelectable:k,nodeId:w,nodeClickDistance:N=0}){h=Pn(y);function S({x:V,y:L},Y){const{nodeLookup:K,nodeExtent:E,snapGrid:q,snapToGrid:D,nodeOrigin:U,onNodeDrag:F,onSelectionDrag:C,onError:R,updateNodePositions:G}=e();s={x:V,y:L};let J=!1,oe={x:0,y:0,x2:0,y2:0};if(i.size>1&&E){const ee=ko(i);oe=Ko(ee)}for(const[ee,j]of i){let ge={x:V-j.distance.x,y:L-j.distance.y};D&&(ge=is(ge,q));let x=[[E[0][0],E[0][1]],[E[1][0],E[1][1]]];if(i.size>1&&E&&!j.extent){const{positionAbsolute:Ie}=j.internals,Te=Ie.x-oe.x+E[0][0],Fe=Ie.x+j.measured.width-oe.x2+E[1][0],rt=Ie.y-oe.y+E[0][1],de=Ie.y+j.measured.height-oe.y2+E[1][1];x=[[Te,rt],[Fe,de]]}const{position:ye,positionAbsolute:ie}=Yh({nodeId:ee,nextPosition:ge,nodeLookup:K,nodeExtent:x,nodeOrigin:U,onError:R});J=J||j.position.x!==ye.x||j.position.y!==ye.y,j.position=ye,j.internals.positionAbsolute=ie}if(J&&(G(i,!0),Y&&(l||F||!w&&C))){const[ee,j]=Lo({nodeId:w,dragItems:i,nodeLookup:K});l==null||l(Y,i,ee,j),F==null||F(Y,ee,j),w||C==null||C(Y,j)}}async function A(){if(!c)return;const{transform:V,panBy:L,autoPanSpeed:Y}=e(),[K,E]=da(u,c,Y);(K!==0||E!==0)&&(s.x=(s.x??0)-K/V[2],s.y=(s.y??0)-E/V[2],await L({x:K,y:E})&&S(s,null)),r=requestAnimationFrame(A)}function z(V){var J;const{nodeLookup:L,multiSelectionActive:Y,nodesDraggable:K,transform:E,snapGrid:q,snapToGrid:D,selectNodesOnDrag:U,onNodeDragStart:F,onSelectionDragStart:C,unselectNodesAndEdges:R}=e();f=!0,(!U||!k)&&!Y&&w&&((J=L.get(w))!=null&&J.selected||R()),k&&U&&w&&(n==null||n(w));const G=Ho(V.sourceEvent,{transform:E,snapGrid:q,snapToGrid:D});if(s=G,i=m1(L,K,G,w),i.size>0&&(t||F||!w&&C)){const[oe,ee]=Lo({nodeId:w,dragItems:i,nodeLookup:L});t==null||t(V.sourceEvent,i,oe,ee),F==null||F(V.sourceEvent,oe,ee),w||C==null||C(V.sourceEvent,ee)}}const M=gc().clickDistance(N).on("start",V=>{const{domNode:L,nodeDragThreshold:Y,transform:K,snapGrid:E,snapToGrid:q}=e();d=!1,Y===0&&z(V),s=Ho(V.sourceEvent,{transform:K,snapGrid:E,snapToGrid:q}),c=(L==null?void 0:L.getBoundingClientRect())||null,u=Kn(V.sourceEvent,c)}).on("drag",V=>{const{autoPanOnNodeDrag:L,transform:Y,snapGrid:K,snapToGrid:E,nodeDragThreshold:q}=e(),D=Ho(V.sourceEvent,{transform:Y,snapGrid:K,snapToGrid:E});if(V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1&&(d=!0),!d){if(!a&&L&&f&&(a=!0,A()),!f){const U=D.xSnapped-(s.x??0),F=D.ySnapped-(s.y??0);Math.sqrt(U*U+F*F)>q&&z(V)}(s.x!==D.xSnapped||s.y!==D.ySnapped)&&i&&f&&(u=Kn(V.sourceEvent,c),S(D,V.sourceEvent))}}).on("end",V=>{if(!(!f||d)&&(a=!1,f=!1,cancelAnimationFrame(r),i.size>0)){const{nodeLookup:L,updateNodePositions:Y,onNodeDragStop:K,onSelectionDragStop:E}=e();if(Y(i,!1),o||K||!w&&E){const[q,D]=Lo({nodeId:w,dragItems:i,nodeLookup:L,dragging:!1});o==null||o(V.sourceEvent,i,q,D),K==null||K(V.sourceEvent,q,D),w||E==null||E(V.sourceEvent,D)}}}).filter(V=>{const L=V.target;return!V.button&&(!p||!Ai(L,`.${p}`,y))&&(!g||Ai(L,g,y))});h.call(M)}function v(){h==null||h.on(".drag",null)}return{update:_,destroy:v}}function _1(n,e,t){const l=[],o={x:n.x-t,y:n.y-t,width:t*2,height:t*2};for(const s of e.values())Bl(o,wl(s))>0&&l.push(s);return l}const b1=250;function p1(n,e,t,l){var i,a;let o=[],s=1/0;const r=_1(n,t,e+b1);for(const u of r){const c=[...((i=u.internals.handleBounds)==null?void 0:i.source)??[],...((a=u.internals.handleBounds)==null?void 0:a.target)??[]];for(const f of c){if(l.nodeId===f.nodeId&&l.type===f.type&&l.id===f.id)continue;const{x:h,y:d}=Ul(u,f,f.position,!0),_=Math.sqrt(Math.pow(h-n.x,2)+Math.pow(d-n.y,2));_>e||(_1){const u=l.type==="source"?"target":"source";return o.find(c=>c.type===u)??o[0]}return o[0]}function Ca(n,e,t,l,o,s=!1){var u,c,f;const r=l.get(n);if(!r)return null;const i=o==="strict"?(u=r.internals.handleBounds)==null?void 0:u[e]:[...((c=r.internals.handleBounds)==null?void 0:c.source)??[],...((f=r.internals.handleBounds)==null?void 0:f.target)??[]],a=(t?i==null?void 0:i.find(h=>h.id===t):i==null?void 0:i[0])??null;return a&&s?{...a,...Ul(r,a,a.position,!0)}:a}function Da(n,e){return n||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function v1(n,e){let t=null;return e?t=!0:n&&!e&&(t=!1),t}const za=()=>!0;function y1(n,{connectionMode:e,connectionRadius:t,handleId:l,nodeId:o,edgeUpdaterType:s,isTarget:r,domNode:i,nodeLookup:a,lib:u,autoPanOnConnect:c,flowId:f,panBy:h,cancelConnection:d,onConnectStart:_,onConnect:v,onConnectEnd:p,isValidConnection:g=za,onReconnectEnd:y,updateConnection:k,getTransform:w,getFromHandle:N,autoPanSpeed:S}){const A=Gh(n.target);let z=0,M;const{x:V,y:L}=Kn(n),Y=A==null?void 0:A.elementFromPoint(V,L),K=Da(s,Y),E=i==null?void 0:i.getBoundingClientRect();if(!E||!K)return;const q=Ca(o,K,l,a,e);if(!q)return;let D=Kn(n,E),U=!1,F=null,C=!1,R=null;function G(){if(!c||!E)return;const[ie,Ie]=da(D,E,S);h({x:ie,y:Ie}),z=requestAnimationFrame(G)}const J={...q,nodeId:o,type:K,position:q.position},oe=a.get(o),j={inProgress:!0,isValid:null,from:Ul(oe,J,tt.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:oe,to:D,toHandle:null,toPosition:ki[J.position],toNode:null};k(j);let ge=j;_==null||_(n,{nodeId:o,handleId:l,handleType:K});function x(ie){if(!N()||!J){ye(ie);return}const Ie=w();D=Kn(ie,E),M=p1(Xl(D,Ie,!1,[1,1]),t,a,J),U||(G(),U=!0);const Te=Ma(ie,{handle:M,connectionMode:e,fromNodeId:o,fromHandleId:l,fromType:r?"target":"source",isValidConnection:g,doc:A,lib:u,flowId:f,nodeLookup:a});R=Te.handleDomNode,F=Te.connection,C=v1(!!M,Te.isValid);const Fe={...ge,isValid:C,to:M&&C?ha({x:M.x,y:M.y},Ie):D,toHandle:Te.toHandle,toPosition:C&&Te.toHandle?Te.toHandle.position:ki[J.position],toNode:Te.toHandle?a.get(Te.toHandle.nodeId):null};C&&M&&ge.toHandle&&Fe.toHandle&&ge.toHandle.type===Fe.toHandle.type&&ge.toHandle.nodeId===Fe.toHandle.nodeId&&ge.toHandle.id===Fe.toHandle.id&&ge.to.x===Fe.to.x&&ge.to.y===Fe.to.y||(k(Fe),ge=Fe)}function ye(ie){(M||R)&&F&&C&&(v==null||v(F));const{inProgress:Ie,...Te}=ge,Fe={...Te,toPosition:ge.toHandle?ge.toPosition:null};p==null||p(ie,Fe),s&&(y==null||y(ie,Fe)),d(),cancelAnimationFrame(z),U=!1,C=!1,F=null,R=null,A.removeEventListener("mousemove",x),A.removeEventListener("mouseup",ye),A.removeEventListener("touchmove",x),A.removeEventListener("touchend",ye)}A.addEventListener("mousemove",x),A.addEventListener("mouseup",ye),A.addEventListener("touchmove",x),A.addEventListener("touchend",ye)}function Ma(n,{handle:e,connectionMode:t,fromNodeId:l,fromHandleId:o,fromType:s,doc:r,lib:i,flowId:a,isValidConnection:u=za,nodeLookup:c}){const f=s==="target",h=e?r.querySelector(`.${i}-flow__handle[data-id="${a}-${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`):null,{x:d,y:_}=Kn(n),v=r.elementFromPoint(d,_),p=v!=null&&v.classList.contains(`${i}-flow__handle`)?v:h,g={handleDomNode:p,isValid:!1,connection:null,toHandle:null};if(p){const y=Da(void 0,p),k=p.getAttribute("data-nodeid"),w=p.getAttribute("data-handleid"),N=p.classList.contains("connectable"),S=p.classList.contains("connectableend");if(!k||!y)return g;const A={source:f?k:l,sourceHandle:f?w:o,target:f?l:k,targetHandle:f?o:w};g.connection=A;const M=N&&S&&(t===al.Strict?f&&y==="source"||!f&&y==="target":k!==l||w!==o);g.isValid=M&&u(A),g.toHandle=Ca(k,y,w,c,t,!1)}return g}const w1={onPointerDown:y1,isValid:Ma},k1=(n,e)=>n.x!==e.x||n.y!==e.y||n.zoom!==e.k,Io=n=>({x:n.x,y:n.y,zoom:n.k}),Ao=({x:n,y:e,zoom:t})=>Qo.translate(n,e).scale(t),gl=(n,e)=>n.target.closest(`.${e}`),Ta=(n,e)=>e===2&&Array.isArray(n)&&n.includes(2),Bo=(n,e=0,t=()=>{})=>{const l=typeof e=="number"&&e>0;return l||t(),l?n.transition().duration(e).on("end",t):n},Pa=n=>{const e=n.ctrlKey&&go()?10:1;return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*e};function E1({zoomPanValues:n,noWheelClassName:e,d3Selection:t,d3Zoom:l,panOnScrollMode:o,panOnScrollSpeed:s,zoomOnPinch:r,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:u}){return c=>{if(gl(c,e))return!1;c.preventDefault(),c.stopImmediatePropagation();const f=t.property("__zoom").k||1;if(c.ctrlKey&&r){const p=Wn(c),g=Pa(c),y=f*Math.pow(2,g);l.scaleTo(t,y,p,c);return}const h=c.deltaMode===1?20:1;let d=o===jn.Vertical?0:c.deltaX*h,_=o===jn.Horizontal?0:c.deltaY*h;!go()&&c.shiftKey&&o!==jn.Vertical&&(d=c.deltaY*h,_=0),l.translateBy(t,-(d/f)*s,-(_/f)*s,{internal:!0});const v=Io(t.property("__zoom"));clearTimeout(n.panScrollTimeout),n.isPanScrolling||(n.isPanScrolling=!0,i==null||i(c,v)),n.isPanScrolling&&(a==null||a(c,v),n.panScrollTimeout=setTimeout(()=>{u==null||u(c,v),n.isPanScrolling=!1},150))}}function S1({noWheelClassName:n,preventScrolling:e,d3ZoomHandler:t}){return function(l,o){if(!e&&l.type==="wheel"&&!l.ctrlKey||gl(l,n))return null;l.preventDefault(),t.call(this,l,o)}}function I1({zoomPanValues:n,onDraggingChange:e,onPanZoomStart:t}){return l=>{var s,r,i;if((s=l.sourceEvent)!=null&&s.internal)return;const o=Io(l.transform);n.mouseButton=((r=l.sourceEvent)==null?void 0:r.button)||0,n.isZoomingOrPanning=!0,n.prevViewport=o,((i=l.sourceEvent)==null?void 0:i.type)==="mousedown"&&e(!0),t&&(t==null||t(l.sourceEvent,o))}}function C1({zoomPanValues:n,panOnDrag:e,onPaneContextMenu:t,onTransformChange:l,onPanZoom:o}){return s=>{var r,i;n.usedRightMouseButton=!!(t&&Ta(e,n.mouseButton??0)),(r=s.sourceEvent)!=null&&r.sync||l([s.transform.x,s.transform.y,s.transform.k]),o&&!((i=s.sourceEvent)!=null&&i.internal)&&(o==null||o(s.sourceEvent,Io(s.transform)))}}function D1({zoomPanValues:n,panOnDrag:e,panOnScroll:t,onDraggingChange:l,onPanZoomEnd:o,onPaneContextMenu:s}){return r=>{var i;if(!((i=r.sourceEvent)!=null&&i.internal)&&(n.isZoomingOrPanning=!1,s&&Ta(e,n.mouseButton??0)&&!n.usedRightMouseButton&&r.sourceEvent&&s(r.sourceEvent),n.usedRightMouseButton=!1,l(!1),o&&k1(n.prevViewport,r.transform))){const a=Io(r.transform);n.prevViewport=a,clearTimeout(n.timerId),n.timerId=setTimeout(()=>{o==null||o(r.sourceEvent,a)},t?150:0)}}}function z1({zoomActivationKeyPressed:n,zoomOnScroll:e,zoomOnPinch:t,panOnDrag:l,panOnScroll:o,zoomOnDoubleClick:s,userSelectionActive:r,noWheelClassName:i,noPanClassName:a,lib:u}){return c=>{var _;const f=n||e,h=t&&c.ctrlKey;if(c.button===1&&c.type==="mousedown"&&(gl(c,`${u}-flow__node`)||gl(c,`${u}-flow__edge`)))return!0;if(!l&&!f&&!o&&!s&&!t||r||gl(c,i)&&c.type==="wheel"||gl(c,a)&&(c.type!=="wheel"||o&&c.type==="wheel"&&!n)||!t&&c.ctrlKey&&c.type==="wheel")return!1;if(!t&&c.type==="touchstart"&&((_=c.touches)==null?void 0:_.length)>1)return c.preventDefault(),!1;if(!f&&!o&&!h&&c.type==="wheel"||!l&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(l)&&!l.includes(c.button)&&c.type==="mousedown")return!1;const d=Array.isArray(l)&&l.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||c.type==="wheel")&&d}}function M1({domNode:n,minZoom:e,maxZoom:t,paneClickDistance:l,translateExtent:o,viewport:s,onPanZoom:r,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:u}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=n.getBoundingClientRect(),h=Cc().clickDistance(!Vn(l)||l<0?0:l).scaleExtent([e,t]).translateExtent(o),d=Pn(n).call(h);k({x:s.x,y:s.y,zoom:vl(s.zoom,e,t)},[[0,0],[f.width,f.height]],o);const _=d.on("wheel.zoom"),v=d.on("dblclick.zoom");h.wheelDelta(Pa);function p(Y,K){return d?new Promise(E=>{h==null||h.transform(Bo(d,K==null?void 0:K.duration,()=>E(!0)),Y)}):Promise.resolve(!1)}function g({noWheelClassName:Y,noPanClassName:K,onPaneContextMenu:E,userSelectionActive:q,panOnScroll:D,panOnDrag:U,panOnScrollMode:F,panOnScrollSpeed:C,preventScrolling:R,zoomOnPinch:G,zoomOnScroll:J,zoomOnDoubleClick:oe,zoomActivationKeyPressed:ee,lib:j,onTransformChange:ge}){q&&!c.isZoomingOrPanning&&y();const ye=D&&!ee&&!q?E1({zoomPanValues:c,noWheelClassName:Y,d3Selection:d,d3Zoom:h,panOnScrollMode:F,panOnScrollSpeed:C,zoomOnPinch:G,onPanZoomStart:i,onPanZoom:r,onPanZoomEnd:a}):S1({noWheelClassName:Y,preventScrolling:R,d3ZoomHandler:_});if(d.on("wheel.zoom",ye,{passive:!1}),!q){const Ie=I1({zoomPanValues:c,onDraggingChange:u,onPanZoomStart:i});h.on("start",Ie);const Te=C1({zoomPanValues:c,panOnDrag:U,onPaneContextMenu:!!E,onPanZoom:r,onTransformChange:ge});h.on("zoom",Te);const Fe=D1({zoomPanValues:c,panOnDrag:U,panOnScroll:D,onPaneContextMenu:E,onPanZoomEnd:a,onDraggingChange:u});h.on("end",Fe)}const ie=z1({zoomActivationKeyPressed:ee,panOnDrag:U,zoomOnScroll:J,panOnScroll:D,zoomOnDoubleClick:oe,zoomOnPinch:G,userSelectionActive:q,noPanClassName:K,noWheelClassName:Y,lib:j});h.filter(ie),oe?d.on("dblclick.zoom",v):d.on("dblclick.zoom",null)}function y(){h.on("zoom",null)}async function k(Y,K,E){const q=Ao(Y),D=h==null?void 0:h.constrain()(q,K,E);return D&&await p(D),new Promise(U=>U(D))}async function w(Y,K){const E=Ao(Y);return await p(E,K),new Promise(q=>q(E))}function N(Y){if(d){const K=Ao(Y),E=d.property("__zoom");(E.k!==Y.zoom||E.x!==Y.x||E.y!==Y.y)&&(h==null||h.transform(d,K,null,{sync:!0}))}}function S(){const Y=d?Ga(d.node()):{x:0,y:0,k:1};return{x:Y.x,y:Y.y,zoom:Y.k}}function A(Y,K){return d?new Promise(E=>{h==null||h.scaleTo(Bo(d,K==null?void 0:K.duration,()=>E(!0)),Y)}):Promise.resolve(!1)}function z(Y,K){return d?new Promise(E=>{h==null||h.scaleBy(Bo(d,K==null?void 0:K.duration,()=>E(!0)),Y)}):Promise.resolve(!1)}function M(Y){h==null||h.scaleExtent(Y)}function V(Y){h==null||h.translateExtent(Y)}function L(Y){const K=!Vn(Y)||Y<0?0:Y;h==null||h.clickDistance(K)}return{update:g,destroy:y,setViewport:w,setViewportConstrained:k,getViewport:S,scaleTo:A,scaleBy:z,setScaleExtent:M,setTranslateExtent:V,syncViewport:N,setClickDistance:L}}var Bi;(function(n){n.Line="line",n.Handle="handle"})(Bi||(Bi={}));function T1(n){let e,t,l,o,s,r;const i=n[45].default,a=dt(i,n,n[44],null);return{c(){e=O("div"),a&&a.c(),this.h()},l(u){e=H(u,"DIV",{"data-handleid":!0,"data-nodeid":!0,"data-handlepos":!0,"data-id":!0,class:!0,style:!0,role:!0,tabindex:!0});var c=T(e);a&&a.l(c),c.forEach(b),this.h()},h(){m(e,"data-handleid",n[6]),m(e,"data-nodeid",n[14]),m(e,"data-handlepos",n[2]),m(e,"data-id",t=n[13]+"-"+n[14]+"-"+(n[0]||null)+"-"+n[1]),m(e,"class",l=Mt(["svelte-flow__handle",`svelte-flow__handle-${n[2]}`,"nodrag","nopan",n[2],n[4]])),m(e,"style",n[3]),m(e,"role","button"),m(e,"tabindex","-1"),et(e,"valid",n[7]),et(e,"connectingto",n[5]),et(e,"connectingfrom",n[9]),et(e,"source",!n[11]),et(e,"target",n[11]),et(e,"connectablestart",n[12]),et(e,"connectableend",n[12]),et(e,"connectable",n[12]),et(e,"connectionindicator",n[12]&&(!n[10]||n[8]))},m(u,c){W(u,e,c),a&&a.m(e,null),o=!0,s||(r=[he(e,"mousedown",n[32]),he(e,"touchstart",n[32])],s=!0)},p(u,c){a&&a.p&&(!o||c[1]&8192)&&ht(a,i,u,u[44],o?gt(i,u[44],c,null):mt(u[44]),null),(!o||c[0]&64)&&m(e,"data-handleid",u[6]),(!o||c[0]&4)&&m(e,"data-handlepos",u[2]),(!o||c[0]&8195&&t!==(t=u[13]+"-"+u[14]+"-"+(u[0]||null)+"-"+u[1]))&&m(e,"data-id",t),(!o||c[0]&20&&l!==(l=Mt(["svelte-flow__handle",`svelte-flow__handle-${u[2]}`,"nodrag","nopan",u[2],u[4]])))&&m(e,"class",l),(!o||c[0]&8)&&m(e,"style",u[3]),(!o||c[0]&148)&&et(e,"valid",u[7]),(!o||c[0]&52)&&et(e,"connectingto",u[5]),(!o||c[0]&532)&&et(e,"connectingfrom",u[9]),(!o||c[0]&2068)&&et(e,"source",!u[11]),(!o||c[0]&2068)&&et(e,"target",u[11]),(!o||c[0]&4116)&&et(e,"connectablestart",u[12]),(!o||c[0]&4116)&&et(e,"connectableend",u[12]),(!o||c[0]&4116)&&et(e,"connectable",u[12]),(!o||c[0]&5396)&&et(e,"connectionindicator",u[12]&&(!u[10]||u[8]))},i(u){o||(P(a,u),o=!0)},o(u){B(a,u),o=!1},d(u){u&&b(e),a&&a.d(u),s=!1,At(r)}}}function P1(n,e,t){let l,o,s,r,i,a,u,c,f,h,d,_,v,p,g,y,k,w,N,S,A,z,M,V,L,{$$slots:Y={},$$scope:K}=e,{id:E=void 0}=e,{type:q="source"}=e,{position:D=tt.Top}=e,{style:U=void 0}=e,{isValidConnection:F=void 0}=e,{onconnect:C=void 0}=e,{ondisconnect:R=void 0}=e,{isConnectable:G=void 0}=e,{class:J=void 0}=e;const oe=Lt("svelteflow__node_id"),ee=Lt("svelteflow__node_connectable");se(n,ee,Ce=>t(43,L=Ce));const j=Rt(),{connectionMode:ge,domNode:x,nodeLookup:ye,connectionRadius:ie,viewport:Ie,isValidConnection:Te,lib:Fe,addEdge:rt,onedgecreate:de,panBy:Ge,cancelConnection:Ke,updateConnection:Vt,autoPanOnConnect:Bt,edges:yt,connectionLookup:Yt,onconnect:Nt,onconnectstart:Ot,onconnectend:Dt,flowId:Kt,connection:_e}=j;se(n,ge,Ce=>t(40,h=Ce)),se(n,x,Ce=>t(55,M=Ce)),se(n,ye,Ce=>t(54,z=Ce)),se(n,ie,Ce=>t(56,V=Ce)),se(n,Ie,Ce=>t(46,v=Ce)),se(n,Te,Ce=>t(51,w=Ce)),se(n,Fe,Ce=>t(53,A=Ce)),se(n,de,Ce=>t(50,k=Ce)),se(n,Bt,Ce=>t(52,S=Ce)),se(n,yt,Ce=>t(42,_=Ce)),se(n,Yt,Ce=>t(41,d=Ce)),se(n,Nt,Ce=>t(49,y=Ce)),se(n,Ot,Ce=>t(48,g=Ce)),se(n,Dt,Ce=>t(47,p=Ce)),se(n,Kt,Ce=>t(13,N=Ce)),se(n,_e,Ce=>t(39,f=Ce));function Ht(Ce){const Wt=ga(Ce);(Wt&&Ce.button===0||!Wt)&&w1.onPointerDown(Ce,{handleId:s,nodeId:oe,isTarget:l,connectionRadius:V,domNode:M,nodeLookup:z,connectionMode:h,lib:A,autoPanOnConnect:S,flowId:N,isValidConnection:F??w,updateConnection:Vt,cancelConnection:Ke,panBy:Ge,onConnect:fe=>{const Ne=k?k(fe):fe;Ne&&(rt(Ne),y==null||y(fe))},onConnectStart:(fe,Ne)=>{g==null||g(fe,{nodeId:Ne.nodeId,handleId:Ne.handleId,handleType:Ne.handleType})},onConnectEnd:(fe,Ne)=>{p==null||p(fe,Ne)},getTransform:()=>[v.x,v.y,v.zoom],getFromHandle:()=>f.fromHandle})}let wt=null,St;return n.$$set=Ce=>{"id"in Ce&&t(0,E=Ce.id),"type"in Ce&&t(1,q=Ce.type),"position"in Ce&&t(2,D=Ce.position),"style"in Ce&&t(3,U=Ce.style),"isValidConnection"in Ce&&t(33,F=Ce.isValidConnection),"onconnect"in Ce&&t(34,C=Ce.onconnect),"ondisconnect"in Ce&&t(35,R=Ce.ondisconnect),"isConnectable"in Ce&&t(36,G=Ce.isConnectable),"class"in Ce&&t(4,J=Ce.class),"$$scope"in Ce&&t(44,K=Ce.$$scope)},n.$$.update=()=>{var Ce,Wt,fe,Ne,X,me,He,Xe,Ue;if(n.$$.dirty[0]&2&&t(11,l=q==="target"),n.$$.dirty[1]&4128&&t(12,o=G!==void 0?G:L),n.$$.dirty[0]&1&&t(6,s=E||null),n.$$.dirty[0]&3|n.$$.dirty[1]&3096&&(C||R)&&t(38,St=d.get(`${oe}-${q}-${E||null}`)),n.$$.dirty[1]&216){if(wt&&!Uh(St,wt)){const qe=St??new Map;Ei(wt,qe,R),Ei(qe,wt,C)}t(37,wt=St??new Map)}n.$$.dirty[1]&256&&t(10,r=!!f.fromHandle),n.$$.dirty[0]&66|n.$$.dirty[1]&256&&t(9,i=((Ce=f.fromHandle)==null?void 0:Ce.nodeId)===oe&&((Wt=f.fromHandle)==null?void 0:Wt.type)===q&&((fe=f.fromHandle)==null?void 0:fe.id)===s),n.$$.dirty[0]&66|n.$$.dirty[1]&256&&t(5,a=((Ne=f.toHandle)==null?void 0:Ne.nodeId)===oe&&((X=f.toHandle)==null?void 0:X.type)===q&&((me=f.toHandle)==null?void 0:me.id)===s),n.$$.dirty[0]&66|n.$$.dirty[1]&768&&t(8,u=h===al.Strict?((He=f.fromHandle)==null?void 0:He.type)!==q:oe!==((Xe=f.fromHandle)==null?void 0:Xe.nodeId)||s!==((Ue=f.fromHandle)==null?void 0:Ue.id)),n.$$.dirty[0]&32|n.$$.dirty[1]&256&&t(7,c=a&&f.isValid)},[E,q,D,U,J,a,s,c,u,i,r,l,o,N,oe,ee,ge,x,ye,ie,Ie,Te,Fe,de,Bt,yt,Yt,Nt,Ot,Dt,Kt,_e,Ht,F,C,R,G,wt,St,f,h,d,_,L,K,Y]}class kl extends ke{constructor(e){super(),Ee(this,e,P1,T1,Se,{id:0,type:1,position:2,style:3,isValidConnection:33,onconnect:34,ondisconnect:35,isConnectable:36,class:4},null,[-1,-1])}}function V1(n){var a;let e,t,l=((a=n[0])==null?void 0:a.label)+"",o,s,r,i;return e=new kl({props:{type:"target",position:n[1]??tt.Top}}),r=new kl({props:{type:"source",position:n[2]??tt.Bottom}}),{c(){re(e.$$.fragment),t=te(),o=De(l),s=te(),re(r.$$.fragment)},l(u){ce(e.$$.fragment,u),t=ne(u),o=ze(u,l),s=ne(u),ce(r.$$.fragment,u)},m(u,c){ae(e,u,c),W(u,t,c),W(u,o,c),W(u,s,c),ae(r,u,c),i=!0},p(u,[c]){var d;const f={};c&2&&(f.position=u[1]??tt.Top),e.$set(f),(!i||c&1)&&l!==(l=((d=u[0])==null?void 0:d.label)+"")&&Oe(o,l);const h={};c&4&&(h.position=u[2]??tt.Bottom),r.$set(h)},i(u){i||(P(e.$$.fragment,u),P(r.$$.fragment,u),i=!0)},o(u){B(e.$$.fragment,u),B(r.$$.fragment,u),i=!1},d(u){u&&(b(t),b(o),b(s)),ue(e,u),ue(r,u)}}}function N1(n,e,t){const l=["data","targetPosition","sourcePosition"];_t(e,l);let{data:o={label:"Node"}}=e,{targetPosition:s=void 0}=e,{sourcePosition:r=void 0}=e;return n.$$set=i=>{e=Qe(Qe({},e),nn(i)),t(3,_t(e,l)),"data"in i&&t(0,o=i.data),"targetPosition"in i&&t(1,s=i.targetPosition),"sourcePosition"in i&&t(2,r=i.sourcePosition)},[o,s,r]}class Va extends ke{constructor(e){super(),Ee(this,e,N1,V1,Se,{data:0,targetPosition:1,sourcePosition:2})}}function O1(n){var r;let e=((r=n[0])==null?void 0:r.label)+"",t,l,o,s;return o=new kl({props:{type:"source",position:n[1]??tt.Bottom}}),{c(){t=De(e),l=te(),re(o.$$.fragment)},l(i){t=ze(i,e),l=ne(i),ce(o.$$.fragment,i)},m(i,a){W(i,t,a),W(i,l,a),ae(o,i,a),s=!0},p(i,[a]){var c;(!s||a&1)&&e!==(e=((c=i[0])==null?void 0:c.label)+"")&&Oe(t,e);const u={};a&2&&(u.position=i[1]??tt.Bottom),o.$set(u)},i(i){s||(P(o.$$.fragment,i),s=!0)},o(i){B(o.$$.fragment,i),s=!1},d(i){i&&(b(t),b(l)),ue(o,i)}}}function H1(n,e,t){const l=["data","sourcePosition"];_t(e,l);let{data:o={label:"Node"}}=e,{sourcePosition:s=void 0}=e;return n.$$set=r=>{e=Qe(Qe({},e),nn(r)),t(2,_t(e,l)),"data"in r&&t(0,o=r.data),"sourcePosition"in r&&t(1,s=r.sourcePosition)},[o,s]}class L1 extends ke{constructor(e){super(),Ee(this,e,H1,O1,Se,{data:0,sourcePosition:1})}}function A1(n){var r;let e=((r=n[0])==null?void 0:r.label)+"",t,l,o,s;return o=new kl({props:{type:"target",position:n[1]??tt.Top}}),{c(){t=De(e),l=te(),re(o.$$.fragment)},l(i){t=ze(i,e),l=ne(i),ce(o.$$.fragment,i)},m(i,a){W(i,t,a),W(i,l,a),ae(o,i,a),s=!0},p(i,[a]){var c;(!s||a&1)&&e!==(e=((c=i[0])==null?void 0:c.label)+"")&&Oe(t,e);const u={};a&2&&(u.position=i[1]??tt.Top),o.$set(u)},i(i){s||(P(o.$$.fragment,i),s=!0)},o(i){B(o.$$.fragment,i),s=!1},d(i){i&&(b(t),b(l)),ue(o,i)}}}function B1(n,e,t){const l=["data","targetPosition"];_t(e,l);let{data:o={label:"Node"}}=e,{targetPosition:s=void 0}=e;return n.$$set=r=>{e=Qe(Qe({},e),nn(r)),t(2,_t(e,l)),"data"in r&&t(0,o=r.data),"targetPosition"in r&&t(1,s=r.targetPosition)},[o,s]}class R1 extends ke{constructor(e){super(),Ee(this,e,B1,A1,Se,{data:0,targetPosition:1})}}function U1(n,e,t){const l=[];return _t(e,l),n.$$set=o=>{e=Qe(Qe({},e),nn(o)),t(0,_t(e,l))},[]}class W1 extends ke{constructor(e){super(),Ee(this,e,U1,null,Se,{})}}function Ri(n,e,t){if(!e)return;const l=t?e.querySelector(t):e;l&&l.appendChild(n)}function F1(n,{target:e,domNode:t}){return Ri(n,t,e),{async update({target:l,domNode:o}){Ri(n,o,l)},destroy(){n.parentNode&&n.parentNode.removeChild(n)}}}function j1(n){let e,t,l,o,s;const r=n[3].default,i=dt(r,n,n[2],null);return{c(){e=O("div"),i&&i.c()},l(a){e=H(a,"DIV",{});var u=T(e);i&&i.l(u),u.forEach(b)},m(a,u){W(a,e,u),i&&i.m(e,null),l=!0,o||(s=Ut(t=F1.call(null,e,{target:".svelte-flow__edgelabel-renderer",domNode:n[0]})),o=!0)},p(a,[u]){i&&i.p&&(!l||u&4)&&ht(i,r,a,a[2],l?gt(r,a[2],u,null):mt(a[2]),null),t&&Xt(t.update)&&u&1&&t.update.call(null,{target:".svelte-flow__edgelabel-renderer",domNode:a[0]})},i(a){l||(P(i,a),l=!0)},o(a){B(i,a),l=!1},d(a){a&&b(e),i&&i.d(a),o=!1,s()}}}function Y1(n,e,t){let l,{$$slots:o={},$$scope:s}=e;const{domNode:r}=Rt();return se(n,r,i=>t(0,l=i)),n.$$set=i=>{"$$scope"in i&&t(2,s=i.$$scope)},[l,r,s,o]}class X1 extends ke{constructor(e){super(),Ee(this,e,Y1,j1,Se,{})}}function Na(){const{edgeLookup:n,selectionRect:e,selectionRectMode:t,multiselectionKeyPressed:l,addSelectedEdges:o,unselectNodesAndEdges:s,elementsSelectable:r}=Rt();return i=>{const a=le(n).get(i);if(!a){console.warn("012",Yl.error012(i));return}(a.selectable||le(r)&&typeof a.selectable>"u")&&(e.set(null),t.set(null),a.selected?a.selected&&le(l)&&s({nodes:[],edges:[a]}):o([i]))}}function K1(n){let e,t,l=`translate(-50%, -50%) translate(${n[1]}px,${n[2]}px)`,o,s,r;const i=n[5].default,a=dt(i,n,n[7],null);return{c(){e=O("div"),a&&a.c(),this.h()},l(u){e=H(u,"DIV",{class:!0,style:!0,role:!0,tabindex:!0});var c=T(e);a&&a.l(c),c.forEach(b),this.h()},h(){m(e,"class","svelte-flow__edge-label"),m(e,"style",t="pointer-events: all;"+n[0]),m(e,"role","button"),m(e,"tabindex","-1"),Ze(e,"transform",l)},m(u,c){W(u,e,c),a&&a.m(e,null),o=!0,s||(r=[he(e,"keyup",G1),he(e,"click",n[6])],s=!0)},p(u,c){a&&a.p&&(!o||c&128)&&ht(a,i,u,u[7],o?gt(i,u[7],c,null):mt(u[7]),null),(!o||c&1&&t!==(t="pointer-events: all;"+u[0]))&&m(e,"style",t);const f=c&1;(c&7&&l!==(l=`translate(-50%, -50%) translate(${u[1]}px,${u[2]}px)`)||f)&&Ze(e,"transform",l)},i(u){o||(P(a,u),o=!0)},o(u){B(a,u),o=!1},d(u){u&&b(e),a&&a.d(u),s=!1,At(r)}}}function Z1(n){let e,t;return e=new X1({props:{$$slots:{default:[K1]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&135&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}const G1=()=>{};function q1(n,e,t){let{$$slots:l={},$$scope:o}=e,{style:s=void 0}=e,{x:r=void 0}=e,{y:i=void 0}=e;const a=Na(),u=Lt("svelteflow__edge_id"),c=()=>{u&&a(u)};return n.$$set=f=>{"style"in f&&t(0,s=f.style),"x"in f&&t(1,r=f.x),"y"in f&&t(2,i=f.y),"$$scope"in f&&t(7,o=f.$$scope)},[s,r,i,a,u,l,c,o]}class J1 extends ke{constructor(e){super(),Ee(this,e,q1,Z1,Se,{style:0,x:1,y:2})}}function Q1(n){let e;return{c(){e=Pe("path"),this.h()},l(t){e=Ve(t,"path",{d:!0,"stroke-opacity":!0,"stroke-width":!0,fill:!0,class:!0}),T(e).forEach(b),this.h()},h(){m(e,"d",n[1]),m(e,"stroke-opacity",0),m(e,"stroke-width",n[10]),m(e,"fill","none"),m(e,"class","svelte-flow__edge-interaction")},m(t,l){W(t,e,l)},p(t,l){l&2&&m(e,"d",t[1])},d(t){t&&b(e)}}}function Ui(n){let e,t;return e=new J1({props:{x:n[3],y:n[4],style:n[5],$$slots:{default:[x1]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&8&&(s.x=l[3]),o&16&&(s.y=l[4]),o&32&&(s.style=l[5]),o&4100&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function x1(n){let e;return{c(){e=De(n[2])},l(t){e=ze(t,n[2])},m(t,l){W(t,e,l)},p(t,l){l&4&&Oe(e,t[2])},d(t){t&&b(e)}}}function $1(n){let e,t,l,o,s,r,i=n[10]&&Q1(n),a=n[2]&&Ui(n);return{c(){e=Pe("path"),l=te(),i&&i.c(),o=te(),a&&a.c(),s=Le(),this.h()},l(u){e=Ve(u,"path",{id:!0,d:!0,class:!0,"marker-start":!0,"marker-end":!0,fill:!0,style:!0}),T(e).forEach(b),l=ne(u),i&&i.l(u),o=ne(u),a&&a.l(u),s=Le(),this.h()},h(){m(e,"id",n[0]),m(e,"d",n[1]),m(e,"class",t=Mt(["svelte-flow__edge-path",n[9]])),m(e,"marker-start",n[6]),m(e,"marker-end",n[7]),m(e,"fill","none"),m(e,"style",n[8])},m(u,c){W(u,e,c),W(u,l,c),i&&i.m(u,c),W(u,o,c),a&&a.m(u,c),W(u,s,c),r=!0},p(u,[c]){(!r||c&1)&&m(e,"id",u[0]),(!r||c&2)&&m(e,"d",u[1]),(!r||c&512&&t!==(t=Mt(["svelte-flow__edge-path",u[9]])))&&m(e,"class",t),(!r||c&64)&&m(e,"marker-start",u[6]),(!r||c&128)&&m(e,"marker-end",u[7]),(!r||c&256)&&m(e,"style",u[8]),u[10]&&i.p(u,c),u[2]?a?(a.p(u,c),c&4&&P(a,1)):(a=Ui(u),a.c(),P(a,1),a.m(s.parentNode,s)):a&&(je(),B(a,1,1,()=>{a=null}),Ye())},i(u){r||(P(a),r=!0)},o(u){B(a),r=!1},d(u){u&&(b(e),b(l),b(o),b(s)),i&&i.d(u),a&&a.d(u)}}}function em(n,e,t){let{id:l=void 0}=e,{path:o}=e,{label:s=void 0}=e,{labelX:r=void 0}=e,{labelY:i=void 0}=e,{labelStyle:a=void 0}=e,{markerStart:u=void 0}=e,{markerEnd:c=void 0}=e,{style:f=void 0}=e,{interactionWidth:h=20}=e,{class:d=void 0}=e,_=h===void 0?20:h;return n.$$set=v=>{"id"in v&&t(0,l=v.id),"path"in v&&t(1,o=v.path),"label"in v&&t(2,s=v.label),"labelX"in v&&t(3,r=v.labelX),"labelY"in v&&t(4,i=v.labelY),"labelStyle"in v&&t(5,a=v.labelStyle),"markerStart"in v&&t(6,u=v.markerStart),"markerEnd"in v&&t(7,c=v.markerEnd),"style"in v&&t(8,f=v.style),"interactionWidth"in v&&t(11,h=v.interactionWidth),"class"in v&&t(9,d=v.class)},[l,o,s,r,i,a,u,c,f,d,_,h]}class Co extends ke{constructor(e){super(),Ee(this,e,em,$1,Se,{id:0,path:1,label:2,labelX:3,labelY:4,labelStyle:5,markerStart:6,markerEnd:7,style:8,interactionWidth:11,class:9})}}function tm(n){let e,t;return e=new Co({props:{path:n[8],labelX:n[7],labelY:n[6],label:n[0],labelStyle:n[1],markerStart:n[3],markerEnd:n[4],interactionWidth:n[5],style:n[2]}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&256&&(s.path=l[8]),o&128&&(s.labelX=l[7]),o&64&&(s.labelY=l[6]),o&1&&(s.label=l[0]),o&2&&(s.labelStyle=l[1]),o&8&&(s.markerStart=l[3]),o&16&&(s.markerEnd=l[4]),o&32&&(s.interactionWidth=l[5]),o&4&&(s.style=l[2]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function nm(n,e,t){let l,o,s;const r=["label","labelStyle","style","markerStart","markerEnd","interactionWidth","sourceX","sourceY","sourcePosition","targetX","targetY","targetPosition"];_t(e,r);let{label:i=void 0}=e,{labelStyle:a=void 0}=e,{style:u=void 0}=e,{markerStart:c=void 0}=e,{markerEnd:f=void 0}=e,{interactionWidth:h=void 0}=e,{sourceX:d}=e,{sourceY:_}=e,{sourcePosition:v}=e,{targetX:p}=e,{targetY:g}=e,{targetPosition:y}=e;return n.$$set=k=>{e=Qe(Qe({},e),nn(k)),t(15,_t(e,r)),"label"in k&&t(0,i=k.label),"labelStyle"in k&&t(1,a=k.labelStyle),"style"in k&&t(2,u=k.style),"markerStart"in k&&t(3,c=k.markerStart),"markerEnd"in k&&t(4,f=k.markerEnd),"interactionWidth"in k&&t(5,h=k.interactionWidth),"sourceX"in k&&t(9,d=k.sourceX),"sourceY"in k&&t(10,_=k.sourceY),"sourcePosition"in k&&t(11,v=k.sourcePosition),"targetX"in k&&t(12,p=k.targetX),"targetY"in k&&t(13,g=k.targetY),"targetPosition"in k&&t(14,y=k.targetPosition)},n.$$.update=()=>{n.$$.dirty&32256&&t(8,[l,o,s]=_a({sourceX:d,sourceY:_,targetX:p,targetY:g,sourcePosition:v,targetPosition:y}),l,(t(7,o),t(9,d),t(10,_),t(12,p),t(13,g),t(11,v),t(14,y)),(t(6,s),t(9,d),t(10,_),t(12,p),t(13,g),t(11,v),t(14,y)))},[i,a,u,c,f,h,s,o,l,d,_,v,p,g,y]}class Oa extends ke{constructor(e){super(),Ee(this,e,nm,tm,Se,{label:0,labelStyle:1,style:2,markerStart:3,markerEnd:4,interactionWidth:5,sourceX:9,sourceY:10,sourcePosition:11,targetX:12,targetY:13,targetPosition:14})}}function lm(n){let e,t;return e=new Co({props:{path:n[8],labelX:n[7],labelY:n[6],label:n[0],labelStyle:n[1],markerStart:n[3],markerEnd:n[4],interactionWidth:n[5],style:n[2]}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&256&&(s.path=l[8]),o&128&&(s.labelX=l[7]),o&64&&(s.labelY=l[6]),o&1&&(s.label=l[0]),o&2&&(s.labelStyle=l[1]),o&8&&(s.markerStart=l[3]),o&16&&(s.markerEnd=l[4]),o&32&&(s.interactionWidth=l[5]),o&4&&(s.style=l[2]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function om(n,e,t){let l,o,s;const r=["label","labelStyle","style","markerStart","markerEnd","interactionWidth","sourceX","sourceY","sourcePosition","targetX","targetY","targetPosition"];_t(e,r);let{label:i=void 0}=e,{labelStyle:a=void 0}=e,{style:u=void 0}=e,{markerStart:c=void 0}=e,{markerEnd:f=void 0}=e,{interactionWidth:h=void 0}=e,{sourceX:d}=e,{sourceY:_}=e,{sourcePosition:v}=e,{targetX:p}=e,{targetY:g}=e,{targetPosition:y}=e;return n.$$set=k=>{e=Qe(Qe({},e),nn(k)),t(15,_t(e,r)),"label"in k&&t(0,i=k.label),"labelStyle"in k&&t(1,a=k.labelStyle),"style"in k&&t(2,u=k.style),"markerStart"in k&&t(3,c=k.markerStart),"markerEnd"in k&&t(4,f=k.markerEnd),"interactionWidth"in k&&t(5,h=k.interactionWidth),"sourceX"in k&&t(9,d=k.sourceX),"sourceY"in k&&t(10,_=k.sourceY),"sourcePosition"in k&&t(11,v=k.sourcePosition),"targetX"in k&&t(12,p=k.targetX),"targetY"in k&&t(13,g=k.targetY),"targetPosition"in k&&t(14,y=k.targetPosition)},n.$$.update=()=>{n.$$.dirty&32256&&t(8,[l,o,s]=_o({sourceX:d,sourceY:_,targetX:p,targetY:g,sourcePosition:v,targetPosition:y}),l,(t(7,o),t(9,d),t(10,_),t(12,p),t(13,g),t(11,v),t(14,y)),(t(6,s),t(9,d),t(10,_),t(12,p),t(13,g),t(11,v),t(14,y)))},[i,a,u,c,f,h,s,o,l,d,_,v,p,g,y]}class sm extends ke{constructor(e){super(),Ee(this,e,om,lm,Se,{label:0,labelStyle:1,style:2,markerStart:3,markerEnd:4,interactionWidth:5,sourceX:9,sourceY:10,sourcePosition:11,targetX:12,targetY:13,targetPosition:14})}}function im(n){let e,t;return e=new Co({props:{path:n[8],labelX:n[7],labelY:n[6],label:n[0],labelStyle:n[1],markerStart:n[3],markerEnd:n[4],interactionWidth:n[5],style:n[2]}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&256&&(s.path=l[8]),o&128&&(s.labelX=l[7]),o&64&&(s.labelY=l[6]),o&1&&(s.label=l[0]),o&2&&(s.labelStyle=l[1]),o&8&&(s.markerStart=l[3]),o&16&&(s.markerEnd=l[4]),o&32&&(s.interactionWidth=l[5]),o&4&&(s.style=l[2]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function rm(n,e,t){let l,o,s;const r=["label","labelStyle","style","markerStart","markerEnd","interactionWidth","sourceX","sourceY","targetX","targetY"];_t(e,r);let{label:i=void 0}=e,{labelStyle:a=void 0}=e,{style:u=void 0}=e,{markerStart:c=void 0}=e,{markerEnd:f=void 0}=e,{interactionWidth:h=void 0}=e,{sourceX:d}=e,{sourceY:_}=e,{targetX:v}=e,{targetY:p}=e;return n.$$set=g=>{e=Qe(Qe({},e),nn(g)),t(13,_t(e,r)),"label"in g&&t(0,i=g.label),"labelStyle"in g&&t(1,a=g.labelStyle),"style"in g&&t(2,u=g.style),"markerStart"in g&&t(3,c=g.markerStart),"markerEnd"in g&&t(4,f=g.markerEnd),"interactionWidth"in g&&t(5,h=g.interactionWidth),"sourceX"in g&&t(9,d=g.sourceX),"sourceY"in g&&t(10,_=g.sourceY),"targetX"in g&&t(11,v=g.targetX),"targetY"in g&&t(12,p=g.targetY)},n.$$.update=()=>{n.$$.dirty&7680&&t(8,[l,o,s]=pa({sourceX:d,sourceY:_,targetX:v,targetY:p}),l,(t(7,o),t(9,d),t(10,_),t(11,v),t(12,p)),(t(6,s),t(9,d),t(10,_),t(11,v),t(12,p)))},[i,a,u,c,f,h,s,o,l,d,_,v,p]}class am extends ke{constructor(e){super(),Ee(this,e,rm,im,Se,{label:0,labelStyle:1,style:2,markerStart:3,markerEnd:4,interactionWidth:5,sourceX:9,sourceY:10,targetX:11,targetY:12})}}function um(n){let e,t;return e=new Co({props:{path:n[8],labelX:n[7],labelY:n[6],label:n[0],labelStyle:n[1],markerStart:n[3],markerEnd:n[4],interactionWidth:n[5],style:n[2]}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&256&&(s.path=l[8]),o&128&&(s.labelX=l[7]),o&64&&(s.labelY=l[6]),o&1&&(s.label=l[0]),o&2&&(s.labelStyle=l[1]),o&8&&(s.markerStart=l[3]),o&16&&(s.markerEnd=l[4]),o&32&&(s.interactionWidth=l[5]),o&4&&(s.style=l[2]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function cm(n,e,t){let l,o,s;const r=["label","labelStyle","style","markerStart","markerEnd","interactionWidth","sourceX","sourceY","sourcePosition","targetX","targetY","targetPosition"];_t(e,r);let{label:i=void 0}=e,{labelStyle:a=void 0}=e,{style:u=void 0}=e,{markerStart:c=void 0}=e,{markerEnd:f=void 0}=e,{interactionWidth:h=void 0}=e,{sourceX:d}=e,{sourceY:_}=e,{sourcePosition:v}=e,{targetX:p}=e,{targetY:g}=e,{targetPosition:y}=e;return n.$$set=k=>{e=Qe(Qe({},e),nn(k)),t(15,_t(e,r)),"label"in k&&t(0,i=k.label),"labelStyle"in k&&t(1,a=k.labelStyle),"style"in k&&t(2,u=k.style),"markerStart"in k&&t(3,c=k.markerStart),"markerEnd"in k&&t(4,f=k.markerEnd),"interactionWidth"in k&&t(5,h=k.interactionWidth),"sourceX"in k&&t(9,d=k.sourceX),"sourceY"in k&&t(10,_=k.sourceY),"sourcePosition"in k&&t(11,v=k.sourcePosition),"targetX"in k&&t(12,p=k.targetX),"targetY"in k&&t(13,g=k.targetY),"targetPosition"in k&&t(14,y=k.targetPosition)},n.$$.update=()=>{n.$$.dirty&32256&&t(8,[l,o,s]=_o({sourceX:d,sourceY:_,targetX:p,targetY:g,sourcePosition:v,targetPosition:y,borderRadius:0}),l,(t(7,o),t(9,d),t(10,_),t(12,p),t(13,g),t(11,v),t(14,y)),(t(6,s),t(9,d),t(10,_),t(12,p),t(13,g),t(11,v),t(14,y)))},[i,a,u,c,f,h,s,o,l,d,_,v,p,g,y]}class fm extends ke{constructor(e){super(),Ee(this,e,cm,um,Se,{label:0,labelStyle:1,style:2,markerStart:3,markerEnd:4,interactionWidth:5,sourceX:9,sourceY:10,sourcePosition:11,targetX:12,targetY:13,targetPosition:14})}}function dm(n,e){const t=n.set,l=e.set,o=le(n),s=le(e);let i=o.length===0&&s.length>0?s:o;n.set(i);const a=u=>{const c=t(u);return i=c,l(i),c};n.set=e.set=a,n.update=e.update=u=>a(u(i))}function hm(n,e){const t=n.set,l=e.set;let o=le(e);n.set(o);const s=r=>{t(r),l(r),o=r};n.set=e.set=s,n.update=e.update=r=>s(r(o))}const mm=(n,e,t)=>{if(!t)return;const l=le(n),o=e.set,s=t.set;let r=t?le(t):{x:0,y:0,zoom:1};e.set(r),e.set=i=>(o(i),s(i),r=i,i),t.set=i=>(l==null||l.syncViewport(i),o(i),s(i),r=i,i),e.update=i=>{e.set(i(r))},t.update=i=>{t.set(i(r))}},gm=(n,e,t,l=[0,0],o=co)=>{const{subscribe:s,set:r,update:i}=Ae([]);let a=n,u={},c=!0;const f=v=>(wa(v,e,t,{elevateNodesOnSelect:c,nodeOrigin:l,nodeExtent:o,defaults:u,checkEquality:!1}),a=v,r(a),a),h=v=>f(v(a)),d=v=>{u=v},_=v=>{c=v.elevateNodesOnSelect??c};return f(a),{subscribe:s,set:f,update:h,setDefaultOptions:d,setOptions:_}},_m=(n,e,t,l)=>{const{subscribe:o,set:s,update:r}=Ae([]);let i=n,a={};const u=h=>{const d=a?h.map(_=>({...a,..._})):h;Sa(e,t,d),i=d,s(i)},c=h=>u(h(i)),f=h=>{a=h};return u(i),{subscribe:o,set:u,update:c,setDefaultOptions:f}},Ha={input:L1,output:R1,default:Va,group:W1},La={straight:am,smoothstep:sm,default:Oa,step:fm},bm=({nodes:n=[],edges:e=[],width:t,height:l,fitView:o,nodeOrigin:s,nodeExtent:r})=>{const i=new Map,a=new Map,u=new Map,c=new Map,f=s??[0,0],h=r??co;wa(n,i,a,{nodeExtent:h,nodeOrigin:f,elevateNodesOnSelect:!1,checkEquality:!1}),Sa(u,c,e);let d={x:0,y:0,zoom:1};if(o&&t&&l){const _=ko(i,{filter:v=>!!((v.width||v.initialWidth)&&(v.height||v.initialHeight))});d=rs(_,t,l,.5,2,.1)}return{flowId:Ae(null),nodes:gm(n,i,a,f,h),nodeLookup:Tn(i),parentLookup:Tn(a),edgeLookup:Tn(c),visibleNodes:Tn([]),edges:_m(e,u,c),visibleEdges:Tn([]),connectionLookup:Tn(u),height:Ae(500),width:Ae(500),minZoom:Ae(.5),maxZoom:Ae(2),nodeOrigin:Ae(f),nodeDragThreshold:Ae(1),nodeExtent:Ae(h),translateExtent:Ae(co),autoPanOnNodeDrag:Ae(!0),autoPanOnConnect:Ae(!0),fitViewOnInit:Ae(!1),fitViewOnInitDone:Ae(!1),fitViewOptions:Ae(void 0),panZoom:Ae(null),snapGrid:Ae(null),dragging:Ae(!1),selectionRect:Ae(null),selectionKeyPressed:Ae(!1),multiselectionKeyPressed:Ae(!1),deleteKeyPressed:Ae(!1),panActivationKeyPressed:Ae(!1),zoomActivationKeyPressed:Ae(!1),selectionRectMode:Ae(null),selectionMode:Ae(fo.Partial),nodeTypes:Ae(Ha),edgeTypes:Ae(La),viewport:Ae(d),connectionMode:Ae(al.Strict),domNode:Ae(null),connection:Tn(Yo),connectionLineType:Ae(bl.Bezier),connectionRadius:Ae(20),isValidConnection:Ae(()=>!0),nodesDraggable:Ae(!0),nodesConnectable:Ae(!0),elementsSelectable:Ae(!0),selectNodesOnDrag:Ae(!0),markers:Tn([]),defaultMarkerColor:Ae("#b1b1b7"),lib:Tn("svelte"),onlyRenderVisibleElements:Ae(!1),onerror:Ae(Kh),ondelete:Ae(void 0),onedgecreate:Ae(void 0),onconnect:Ae(void 0),onconnectstart:Ae(void 0),onconnectend:Ae(void 0),onbeforedelete:Ae(void 0),nodesInitialized:Ae(!1),edgesInitialized:Ae(!1),viewportInitialized:Ae(!1),initialized:Tn(!1)}};function pm(n){const e=Sn([n.edges,n.nodes,n.nodeLookup,n.onlyRenderVisibleElements,n.viewport,n.width,n.height],([t,,l,o,s,r,i])=>o&&r&&i?t.filter(u=>{const c=l.get(u.source),f=l.get(u.target);return c&&f&&$h({sourceNode:c,targetNode:f,width:r,height:i,transform:[s.x,s.y,s.zoom]})}):t);return Sn([e,n.nodes,n.nodeLookup,n.connectionMode,n.onerror],([t,,l,o,s])=>t.reduce((i,a)=>{const u=l.get(a.source),c=l.get(a.target);if(!u||!c)return i;const f=i1({id:a.id,sourceNode:u,targetNode:c,sourceHandle:a.sourceHandle||null,targetHandle:a.targetHandle||null,connectionMode:o,onError:s});return f&&i.push({...a,zIndex:xh({selected:a.selected,zIndex:a.zIndex,sourceNode:u,targetNode:c,elevateOnSelect:!1}),...f}),i},[]))}function vm(n){return Sn([n.nodeLookup,n.onlyRenderVisibleElements,n.width,n.height,n.viewport,n.nodes],([e,t,l,o,s])=>{const r=[s.x,s.y,s.zoom];return t?ua(e,{x:0,y:0,width:l,height:o},r,!0):Array.from(e.values())})}const Do=Symbol();function Aa({nodes:n,edges:e,width:t,height:l,fitView:o,nodeOrigin:s,nodeExtent:r}){const i=bm({nodes:n,edges:e,width:t,height:l,fitView:o,nodeOrigin:s,nodeExtent:r});function a(D){i.nodeTypes.set({...Ha,...D})}function u(D){i.edgeTypes.set({...La,...D})}function c(D){const U=le(i.edges);i.edges.set(n1(D,U))}const f=(D,U=!1)=>{var C;const F=le(i.nodeLookup);for(const[R,G]of D){const J=(C=F.get(R))==null?void 0:C.internals.userNode;J&&(J.position=G.position,J.dragging=U)}i.nodes.update(R=>R)};function h(D){var R,G,J;const U=le(i.nodeLookup),{changes:F,updatedInternals:C}=d1(D,U,le(i.parentLookup),le(i.domNode),le(i.nodeOrigin));if(C){if(!le(i.fitViewOnInitDone)&&le(i.fitViewOnInit)){const oe=le(i.fitViewOptions),ee=_({...oe,nodes:oe==null?void 0:oe.nodes});i.fitViewOnInitDone.set(ee)}for(const oe of F){const ee=(R=U.get(oe.id))==null?void 0:R.internals.userNode;if(ee)switch(oe.type){case"dimensions":{const j={...ee.measured,...oe.dimensions};oe.setAttributes&&(ee.width=((G=oe.dimensions)==null?void 0:G.width)??ee.width,ee.height=((J=oe.dimensions)==null?void 0:J.height)??ee.height),ee.measured=j;break}case"position":ee.position=oe.position??ee.position;break}}i.nodes.update(oe=>oe),le(i.nodesInitialized)||i.nodesInitialized.set(!0)}}function d(D){const U=le(i.panZoom);if(!U)return Promise.resolve(!1);const F=Ii(le(i.nodeLookup),D);return Ci({nodes:F,width:le(i.width),height:le(i.height),minZoom:le(i.minZoom),maxZoom:le(i.maxZoom),panZoom:U},D)}function _(D){const U=le(i.panZoom);if(!U)return!1;const F=Ii(le(i.nodeLookup),D);return Ci({nodes:F,width:le(i.width),height:le(i.height),minZoom:le(i.minZoom),maxZoom:le(i.maxZoom),panZoom:U},D),F.size>0}function v(D,U){const F=le(i.panZoom);return F?F.scaleBy(D,U):Promise.resolve(!1)}function p(D){return v(1.2,D)}function g(D){return v(1/1.2,D)}function y(D){const U=le(i.panZoom);U&&(U.setScaleExtent([D,le(i.maxZoom)]),i.minZoom.set(D))}function k(D){const U=le(i.panZoom);U&&(U.setScaleExtent([le(i.minZoom),D]),i.maxZoom.set(D))}function w(D){const U=le(i.panZoom);U&&(U.setTranslateExtent(D),i.translateExtent.set(D))}function N(D){let U=!1;return D.forEach(F=>{F.selected&&(F.selected=!1,U=!0)}),U}function S(D){var U;(U=le(i.panZoom))==null||U.setClickDistance(D)}function A(D){N((D==null?void 0:D.nodes)||le(i.nodes))&&i.nodes.set(le(i.nodes)),N((D==null?void 0:D.edges)||le(i.edges))&&i.edges.set(le(i.edges))}i.deleteKeyPressed.subscribe(async D=>{var U;if(D){const F=le(i.nodes),C=le(i.edges),R=F.filter(ee=>ee.selected),G=C.filter(ee=>ee.selected),{nodes:J,edges:oe}=await ca({nodesToRemove:R,edgesToRemove:G,nodes:F,edges:C,onBeforeDelete:le(i.onbeforedelete)});(J.length||oe.length)&&(i.nodes.update(ee=>ee.filter(j=>!J.some(ge=>ge.id===j.id))),i.edges.update(ee=>ee.filter(j=>!oe.some(ge=>ge.id===j.id))),(U=le(i.ondelete))==null||U({nodes:J,edges:oe}))}});function z(D){const U=le(i.multiselectionKeyPressed);i.nodes.update(F=>F.map(C=>{const R=D.includes(C.id),G=U&&C.selected||R;return C.selected=G,C})),U||i.edges.update(F=>F.map(C=>(C.selected=!1,C)))}function M(D){const U=le(i.multiselectionKeyPressed);i.edges.update(F=>F.map(C=>{const R=D.includes(C.id),G=U&&C.selected||R;return C.selected=G,C})),U||i.nodes.update(F=>F.map(C=>(C.selected=!1,C)))}function V(D){var F;const U=(F=le(i.nodes))==null?void 0:F.find(C=>C.id===D);if(!U){console.warn("012",Yl.error012(D));return}i.selectionRect.set(null),i.selectionRectMode.set(null),U.selected?U.selected&&le(i.multiselectionKeyPressed)&&A({nodes:[U],edges:[]}):z([D])}function L(D){const U=le(i.viewport);return h1({delta:D,panZoom:le(i.panZoom),transform:[U.x,U.y,U.zoom],translateExtent:le(i.translateExtent),width:le(i.width),height:le(i.height)})}const Y=Ae(Yo),K=D=>{Y.set({...D})};function E(){Y.set(Yo)}function q(){i.fitViewOnInitDone.set(!1),i.selectionRect.set(null),i.selectionRectMode.set(null),i.snapGrid.set(null),i.isValidConnection.set(()=>!0),A(),E()}return{...i,visibleEdges:pm(i),visibleNodes:vm(i),connection:Sn([Y,i.viewport],([D,U])=>D.inProgress?{...D,to:Xl(D.to,[U.x,U.y,U.zoom])}:{...D}),markers:Sn([i.edges,i.defaultMarkerColor,i.flowId],([D,U,F])=>r1(D,{defaultColor:U,id:F})),initialized:(()=>{let D=!1;const U=le(i.nodes).length,F=le(i.edges).length;return Sn([i.nodesInitialized,i.edgesInitialized,i.viewportInitialized],([C,R,G])=>D||(U===0?D=G:F===0?D=G&&C:D=G&&C&&R,D))})(),syncNodeStores:D=>dm(i.nodes,D),syncEdgeStores:D=>hm(i.edges,D),syncViewport:D=>mm(i.panZoom,i.viewport,D),setNodeTypes:a,setEdgeTypes:u,addEdge:c,updateNodePositions:f,updateNodeInternals:h,zoomIn:p,zoomOut:g,fitView:D=>d(D),setMinZoom:y,setMaxZoom:k,setTranslateExtent:w,setPaneClickDistance:S,unselectNodesAndEdges:A,addSelectedNodes:z,addSelectedEdges:M,handleNodeSelection:V,panBy:L,updateConnection:K,cancelConnection:E,reset:q}}function Rt(){const n=Lt(Do);if(!n)throw new Error("In order to use useStore you need to wrap your component in a ");return n.getStore()}function ym({nodes:n,edges:e,width:t,height:l,fitView:o,nodeOrigin:s,nodeExtent:r}){const i=Aa({nodes:n,edges:e,width:t,height:l,fitView:o,nodeOrigin:s,nodeExtent:r});return pl(Do,{getStore:()=>i}),i}function wm(n,e){const{panZoom:t,minZoom:l,maxZoom:o,initialViewport:s,viewport:r,dragging:i,translateExtent:a,paneClickDistance:u}=e,c=M1({domNode:n,minZoom:l,maxZoom:o,translateExtent:a,viewport:s,paneClickDistance:u,onDraggingChange:i.set}),f=c.getViewport();return r.set(f),t.set(c),c.update(e),{update(h){c.update(h)}}}function km(n){let e,t,l,o,s;const r=n[35].default,i=dt(r,n,n[34],null);return{c(){e=O("div"),i&&i.c(),this.h()},l(a){e=H(a,"DIV",{class:!0});var u=T(e);i&&i.l(u),u.forEach(b),this.h()},h(){m(e,"class","svelte-flow__zoom svelte-4xkw84")},m(a,u){W(a,e,u),i&&i.m(e,null),l=!0,o||(s=Ut(t=wm.call(null,e,{viewport:n[18],minZoom:n[12],maxZoom:n[13],initialViewport:n[11],dragging:n[23],panZoom:n[19],onPanZoomStart:n[0],onPanZoom:n[1],onPanZoomEnd:n[2],zoomOnScroll:n[5],zoomOnDoubleClick:n[6],zoomOnPinch:n[7],panOnScroll:n[9],panOnDrag:n[10],panOnScrollSpeed:.5,panOnScrollMode:n[3]||jn.Free,zoomActivationKeyPressed:n[14],preventScrolling:typeof n[4]=="boolean"?n[4]:!0,noPanClassName:"nopan",noWheelClassName:"nowheel",userSelectionActive:!!n[15],translateExtent:n[16],lib:n[17],paneClickDistance:n[8],onTransformChange:n[29]})),o=!0)},p(a,u){i&&i.p&&(!l||u[1]&8)&&ht(i,r,a,a[34],l?gt(r,a[34],u,null):mt(a[34]),null),t&&Xt(t.update)&&u[0]&262143&&t.update.call(null,{viewport:a[18],minZoom:a[12],maxZoom:a[13],initialViewport:a[11],dragging:a[23],panZoom:a[19],onPanZoomStart:a[0],onPanZoom:a[1],onPanZoomEnd:a[2],zoomOnScroll:a[5],zoomOnDoubleClick:a[6],zoomOnPinch:a[7],panOnScroll:a[9],panOnDrag:a[10],panOnScrollSpeed:.5,panOnScrollMode:a[3]||jn.Free,zoomActivationKeyPressed:a[14],preventScrolling:typeof a[4]=="boolean"?a[4]:!0,noPanClassName:"nopan",noWheelClassName:"nowheel",userSelectionActive:!!a[15],translateExtent:a[16],lib:a[17],paneClickDistance:a[8],onTransformChange:a[29]})},i(a){l||(P(i,a),l=!0)},o(a){B(i,a),l=!1},d(a){a&&b(e),i&&i.d(a),o=!1,s()}}}function Em(n,e,t){let l,o,s,r,i,a,u,c,f,h,d,{$$slots:_={},$$scope:v}=e,{initialViewport:p=void 0}=e,{onMoveStart:g=void 0}=e,{onMove:y=void 0}=e,{onMoveEnd:k=void 0}=e,{panOnScrollMode:w}=e,{preventScrolling:N}=e,{zoomOnScroll:S}=e,{zoomOnDoubleClick:A}=e,{zoomOnPinch:z}=e,{panOnDrag:M}=e,{panOnScroll:V}=e,{paneClickDistance:L}=e;const{viewport:Y,panZoom:K,selectionRect:E,minZoom:q,maxZoom:D,dragging:U,translateExtent:F,lib:C,panActivationKeyPressed:R,zoomActivationKeyPressed:G,viewportInitialized:J}=Rt();se(n,E,ee=>t(15,f=ee)),se(n,q,ee=>t(12,a=ee)),se(n,D,ee=>t(13,u=ee)),se(n,F,ee=>t(16,h=ee)),se(n,C,ee=>t(17,d=ee)),se(n,R,ee=>t(33,i=ee)),se(n,G,ee=>t(14,c=ee)),se(n,J,ee=>t(36,r=ee));const oe=ee=>Y.set({x:ee[0],y:ee[1],zoom:ee[2]});return un(()=>{io(J,r=!0,r)}),n.$$set=ee=>{"initialViewport"in ee&&t(30,p=ee.initialViewport),"onMoveStart"in ee&&t(0,g=ee.onMoveStart),"onMove"in ee&&t(1,y=ee.onMove),"onMoveEnd"in ee&&t(2,k=ee.onMoveEnd),"panOnScrollMode"in ee&&t(3,w=ee.panOnScrollMode),"preventScrolling"in ee&&t(4,N=ee.preventScrolling),"zoomOnScroll"in ee&&t(5,S=ee.zoomOnScroll),"zoomOnDoubleClick"in ee&&t(6,A=ee.zoomOnDoubleClick),"zoomOnPinch"in ee&&t(7,z=ee.zoomOnPinch),"panOnDrag"in ee&&t(31,M=ee.panOnDrag),"panOnScroll"in ee&&t(32,V=ee.panOnScroll),"paneClickDistance"in ee&&t(8,L=ee.paneClickDistance),"$$scope"in ee&&t(34,v=ee.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&1073741824&&t(11,l=p||{x:0,y:0,zoom:1}),n.$$.dirty[1]&5&&t(10,o=i||M),n.$$.dirty[1]&6&&t(9,s=i||V)},[g,y,k,w,N,S,A,z,L,s,o,l,a,u,c,f,h,d,Y,K,E,q,D,U,F,C,R,G,J,oe,p,M,V,i,v,_]}class Sm extends ke{constructor(e){super(),Ee(this,e,Em,km,Se,{initialViewport:30,onMoveStart:0,onMove:1,onMoveEnd:2,panOnScrollMode:3,preventScrolling:4,zoomOnScroll:5,zoomOnDoubleClick:6,zoomOnPinch:7,panOnDrag:31,panOnScroll:32,paneClickDistance:8},null,[-1,-1])}}function Im(n){let e,t,l,o;const s=n[28].default,r=dt(s,n,n[27],null);return{c(){e=O("div"),r&&r.c(),this.h()},l(i){e=H(i,"DIV",{class:!0});var a=T(e);r&&r.l(a),a.forEach(b),this.h()},h(){m(e,"class","svelte-flow__pane svelte-1esy7hx"),et(e,"draggable",n[0]===!0||Array.isArray(n[0])&&n[0].includes(0)),et(e,"dragging",n[4]),et(e,"selection",n[1])},m(i,a){W(i,e,a),r&&r.m(e,null),n[29](e),t=!0,l||(o=[he(e,"click",function(){Xt(n[3]?void 0:lo(n[15],n[2]))&&(n[3]?void 0:lo(n[15],n[2])).apply(this,arguments)}),he(e,"pointerdown",function(){Xt(n[3]?n[16]:void 0)&&(n[3]?n[16]:void 0).apply(this,arguments)}),he(e,"pointermove",function(){Xt(n[3]?n[17]:void 0)&&(n[3]?n[17]:void 0).apply(this,arguments)}),he(e,"pointerup",function(){Xt(n[3]?n[18]:void 0)&&(n[3]?n[18]:void 0).apply(this,arguments)}),he(e,"contextmenu",function(){Xt(lo(n[19],n[2]))&&lo(n[19],n[2]).apply(this,arguments)})],l=!0)},p(i,a){n=i,r&&r.p&&(!t||a[0]&134217728)&&ht(r,s,n,n[27],t?gt(s,n[27],a,null):mt(n[27]),null),(!t||a[0]&1)&&et(e,"draggable",n[0]===!0||Array.isArray(n[0])&&n[0].includes(0)),(!t||a[0]&16)&&et(e,"dragging",n[4]),(!t||a[0]&2)&&et(e,"selection",n[1])},i(i){t||(P(r,i),t=!0)},o(i){B(r,i),t=!1},d(i){i&&b(e),r&&r.d(i),n[29](null),l=!1,At(o)}}}function lo(n,e){return t=>{t.target===e&&(n==null||n(t))}}function Wi(n){return e=>{const t=n.includes(e.id);return e.selected!==t&&(e.selected=t),e}}function Cm(n,e,t){let l,o,s,r,i,a,u,c,f,h,d,_,v,{$$slots:p={},$$scope:g}=e,{panOnDrag:y=void 0}=e,{selectionOnDrag:k=void 0}=e;const w=en(),{nodes:N,nodeLookup:S,edges:A,viewport:z,dragging:M,elementsSelectable:V,selectionRect:L,selectionRectMode:Y,selectionKeyPressed:K,selectionMode:E,panActivationKeyPressed:q,unselectNodesAndEdges:D}=Rt();se(n,S,x=>t(36,f=x)),se(n,A,x=>t(33,a=x)),se(n,z,x=>t(35,c=x)),se(n,M,x=>t(4,v=x)),se(n,V,x=>t(25,d=x)),se(n,L,x=>t(24,h=x)),se(n,Y,x=>t(23,i=x)),se(n,K,x=>t(22,r=x)),se(n,E,x=>t(34,u=x)),se(n,q,x=>t(26,_=x));let U,F=null,C=[],R=!1;function G(x){if(R){R=!1;return}w("paneclick",{event:x}),D(),Y.set(null)}function J(x){var Ie,Te;if(F=U.getBoundingClientRect(),!V||!o||x.button!==0||x.target!==U||!F)return;(Te=(Ie=x.target)==null?void 0:Ie.setPointerCapture)==null||Te.call(Ie,x.pointerId);const{x:ye,y:ie}=Kn(x,F);D(),L.set({width:0,height:0,startX:ye,startY:ie,x:ye,y:ie})}function oe(x){if(!o||!F||!h)return;R=!0;const ye=Kn(x,F),ie=h.startX??0,Ie=h.startY??0,Te={...h,x:ye.xKe.id),rt=Xo(C,a).map(Ke=>Ke.id);C=ua(f,Te,[c.x,c.y,c.zoom],u===fo.Partial,!0);const de=Xo(C,a).map(Ke=>Ke.id),Ge=C.map(Ke=>Ke.id);(Fe.length!==Ge.length||Ge.some(Ke=>!Fe.includes(Ke)))&&N.update(Ke=>Ke.map(Wi(Ge))),(rt.length!==de.length||de.some(Ke=>!rt.includes(Ke)))&&A.update(Ke=>Ke.map(Wi(de))),Y.set("user"),L.set(Te)}function ee(x){var ye,ie;x.button===0&&((ie=(ye=x.target)==null?void 0:ye.releasePointerCapture)==null||ie.call(ye,x.pointerId),!o&&i==="user"&&x.target===U&&(G==null||G(x)),L.set(null),C.length>0&&io(Y,i="nodes",i),r&&(R=!1))}const j=x=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){x.preventDefault();return}w("panecontextmenu",{event:x})};function ge(x){Be[x?"unshift":"push"](()=>{U=x,t(2,U)})}return n.$$set=x=>{"panOnDrag"in x&&t(0,y=x.panOnDrag),"selectionOnDrag"in x&&t(20,k=x.selectionOnDrag),"$$scope"in x&&t(27,g=x.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&67108865&&t(21,l=_||y),n.$$.dirty[0]&24117248&&t(1,o=r||h||k&&l!==!0),n.$$.dirty[0]&41943042&&t(3,s=d&&(o||i==="user"))},[y,o,U,s,v,S,A,z,M,V,L,Y,K,E,q,G,J,oe,ee,j,k,l,r,i,h,d,_,g,p,ge]}class Dm extends ke{constructor(e){super(),Ee(this,e,Cm,Im,Se,{panOnDrag:0,selectionOnDrag:20},null,[-1,-1])}}function zm(n){let e,t;const l=n[3].default,o=dt(l,n,n[2],null);return{c(){e=O("div"),o&&o.c(),this.h()},l(s){e=H(s,"DIV",{class:!0,style:!0});var r=T(e);o&&o.l(r),r.forEach(b),this.h()},h(){m(e,"class","svelte-flow__viewport xyflow__viewport svelte-1floaup"),Ze(e,"transform","translate("+n[0].x+"px, "+n[0].y+"px) scale("+n[0].zoom+")")},m(s,r){W(s,e,r),o&&o.m(e,null),t=!0},p(s,[r]){o&&o.p&&(!t||r&4)&&ht(o,l,s,s[2],t?gt(l,s[2],r,null):mt(s[2]),null),(!t||r&1)&&Ze(e,"transform","translate("+s[0].x+"px, "+s[0].y+"px) scale("+s[0].zoom+")")},i(s){t||(P(o,s),t=!0)},o(s){B(o,s),t=!1},d(s){s&&b(e),o&&o.d(s)}}}function Mm(n,e,t){let l,{$$slots:o={},$$scope:s}=e;const{viewport:r}=Rt();return se(n,r,i=>t(0,l=i)),n.$$set=i=>{"$$scope"in i&&t(2,s=i.$$scope)},[l,r,s,o]}class Tm extends ke{constructor(e){super(),Ee(this,e,Mm,zm,Se,{})}}function Ba(n,e){const{store:t,onDrag:l,onDragStart:o,onDragStop:s,onNodeMouseDown:r}=e,i=g1({onDrag:l,onDragStart:o,onDragStop:s,onNodeMouseDown:r,getStoreItems:()=>{const u=le(t.snapGrid),c=le(t.viewport);return{nodes:le(t.nodes),nodeLookup:le(t.nodeLookup),edges:le(t.edges),nodeExtent:le(t.nodeExtent),snapGrid:u||[0,0],snapToGrid:!!u,nodeOrigin:le(t.nodeOrigin),multiSelectionActive:le(t.multiselectionKeyPressed),domNode:le(t.domNode),transform:[c.x,c.y,c.zoom],autoPanOnNodeDrag:le(t.autoPanOnNodeDrag),nodesDraggable:le(t.nodesDraggable),selectNodesOnDrag:le(t.selectNodesOnDrag),nodeDragThreshold:le(t.nodeDragThreshold),unselectNodesAndEdges:t.unselectNodesAndEdges,updateNodePositions:t.updateNodePositions,panBy:t.panBy}}});function a(u,c){if(c.disabled){i.destroy();return}i.update({domNode:u,noDragClassName:c.noDragClass,handleSelector:c.handleSelector,nodeId:c.nodeId,isSelectable:c.isSelectable,nodeClickDistance:c.nodeClickDistance})}return a(n,e),{update(u){a(n,u)},destroy(){i.destroy()}}}function Pm({width:n,height:e,initialWidth:t,initialHeight:l,measuredWidth:o,measuredHeight:s}){if(o===void 0&&s===void 0){const r=n??t,i=e??l;return{width:r?`width:${r}px;`:"",height:i?`height:${i}px;`:""}}return{width:n?`width:${n}px;`:"",height:e?`height:${e}px;`:""}}function Fi(n){let e,t,l,o,s,r=`translate(${n[12]}px, ${n[13]}px)`,i,a,u;var c=n[27];function f(h,d){return{props:{data:h[2],id:h[1],selected:h[3],selectable:h[5],deletable:h[7],sourcePosition:h[14],targetPosition:h[15],zIndex:h[16],dragging:h[9],draggable:h[4],dragHandle:h[19],parentId:h[21],type:h[25],isConnectable:h[28],positionAbsoluteX:h[12],positionAbsoluteY:h[13],width:h[17],height:h[18]}}}return c&&(t=ro(c,f(n))),{c(){e=O("div"),t&&re(t.$$.fragment),this.h()},l(h){e=H(h,"DIV",{"data-id":!0,class:!0,style:!0});var d=T(e);t&&ce(t.$$.fragment,d),d.forEach(b),this.h()},h(){m(e,"data-id",n[1]),m(e,"class",l=Mt(["svelte-flow__node",`svelte-flow__node-${n[25]}`,n[23]])),m(e,"style",o=(n[10]??"")+";"+n[26].width+n[26].height),et(e,"dragging",n[9]),et(e,"selected",n[3]),et(e,"draggable",n[4]),et(e,"connectable",n[6]),et(e,"selectable",n[5]),et(e,"nopan",n[4]),et(e,"parent",n[11]),Ze(e,"z-index",n[16]),Ze(e,"transform",r),Ze(e,"visibility",n[20]?"visible":"hidden")},m(h,d){W(h,e,d),t&&ae(t,e,null),n[50](e),i=!0,a||(u=[Ut(s=Ba.call(null,e,{nodeId:n[1],isSelectable:n[5],disabled:!1,handleSelector:n[19],noDragClass:"nodrag",nodeClickDistance:n[22],onNodeMouseDown:n[31],onDrag:n[47],onDragStart:n[48],onDragStop:n[49],store:n[29]})),he(e,"click",n[34]),he(e,"mouseenter",n[51]),he(e,"mouseleave",n[52]),he(e,"mousemove",n[53]),he(e,"contextmenu",n[54])],a=!0)},p(h,d){if(d[0]&134217728&&c!==(c=h[27])){if(t){je();const v=t;B(v.$$.fragment,1,0,()=>{ue(v,1)}),Ye()}c?(t=ro(c,f(h)),re(t.$$.fragment),P(t.$$.fragment,1),ae(t,e,null)):t=null}else if(c){const v={};d[0]&4&&(v.data=h[2]),d[0]&2&&(v.id=h[1]),d[0]&8&&(v.selected=h[3]),d[0]&32&&(v.selectable=h[5]),d[0]&128&&(v.deletable=h[7]),d[0]&16384&&(v.sourcePosition=h[14]),d[0]&32768&&(v.targetPosition=h[15]),d[0]&65536&&(v.zIndex=h[16]),d[0]&512&&(v.dragging=h[9]),d[0]&16&&(v.draggable=h[4]),d[0]&524288&&(v.dragHandle=h[19]),d[0]&2097152&&(v.parentId=h[21]),d[0]&33554432&&(v.type=h[25]),d[0]&268435456&&(v.isConnectable=h[28]),d[0]&4096&&(v.positionAbsoluteX=h[12]),d[0]&8192&&(v.positionAbsoluteY=h[13]),d[0]&131072&&(v.width=h[17]),d[0]&262144&&(v.height=h[18]),t.$set(v)}(!i||d[0]&2)&&m(e,"data-id",h[1]),(!i||d[0]&41943040&&l!==(l=Mt(["svelte-flow__node",`svelte-flow__node-${h[25]}`,h[23]])))&&m(e,"class",l),(!i||d[0]&67109888&&o!==(o=(h[10]??"")+";"+h[26].width+h[26].height))&&m(e,"style",o),s&&Xt(s.update)&&d[0]&4718626&&s.update.call(null,{nodeId:h[1],isSelectable:h[5],disabled:!1,handleSelector:h[19],noDragClass:"nodrag",nodeClickDistance:h[22],onNodeMouseDown:h[31],onDrag:h[47],onDragStart:h[48],onDragStop:h[49],store:h[29]}),(!i||d[0]&41943552)&&et(e,"dragging",h[9]),(!i||d[0]&41943048)&&et(e,"selected",h[3]),(!i||d[0]&41943056)&&et(e,"draggable",h[4]),(!i||d[0]&41943104)&&et(e,"connectable",h[6]),(!i||d[0]&41943072)&&et(e,"selectable",h[5]),(!i||d[0]&41943056)&&et(e,"nopan",h[4]),(!i||d[0]&41945088)&&et(e,"parent",h[11]);const _=d[0]&67109888;(d[0]&67175424||_)&&Ze(e,"z-index",h[16]),(d[0]&67122176&&r!==(r=`translate(${h[12]}px, ${h[13]}px)`)||_)&&Ze(e,"transform",r),(d[0]&68158464||_)&&Ze(e,"visibility",h[20]?"visible":"hidden")},i(h){i||(t&&P(t.$$.fragment,h),i=!0)},o(h){t&&B(t.$$.fragment,h),i=!1},d(h){h&&b(e),t&&ue(t),n[50](null),a=!1,At(u)}}}function Vm(n){let e,t,l=!n[8]&&Fi(n);return{c(){l&&l.c(),e=Le()},l(o){l&&l.l(o),e=Le()},m(o,s){l&&l.m(o,s),W(o,e,s),t=!0},p(o,s){o[8]?l&&(je(),B(l,1,1,()=>{l=null}),Ye()):l?(l.p(o,s),s[0]&256&&P(l,1)):(l=Fi(o),l.c(),P(l,1),l.m(e.parentNode,e))},i(o){t||(P(l),t=!0)},o(o){B(l),t=!1},d(o){o&&b(e),l&&l.d(o)}}}function Nm(n,e,t){let l,o,s,r,i,a,{node:u}=e,{id:c}=e,{data:f={}}=e,{selected:h=!1}=e,{draggable:d=void 0}=e,{selectable:_=void 0}=e,{connectable:v=!0}=e,{deletable:p=!0}=e,{hidden:g=!1}=e,{dragging:y=!1}=e,{resizeObserver:k=null}=e,{style:w=void 0}=e,{type:N="default"}=e,{isParent:S=!1}=e,{positionX:A}=e,{positionY:z}=e,{sourcePosition:M=void 0}=e,{targetPosition:V=void 0}=e,{zIndex:L}=e,{measuredWidth:Y=void 0}=e,{measuredHeight:K=void 0}=e,{initialWidth:E=void 0}=e,{initialHeight:q=void 0}=e,{width:D=void 0}=e,{height:U=void 0}=e,{dragHandle:F=void 0}=e,{initialized:C=!1}=e,{parentId:R=void 0}=e,{nodeClickDistance:G=void 0}=e,{class:J=""}=e;const oe=Rt(),{nodeTypes:ee,nodeDragThreshold:j,selectNodesOnDrag:ge,handleNodeSelection:x,updateNodeInternals:ye}=oe;se(n,ee,_e=>t(46,i=_e));let ie,Ie=null;const Te=en(),Fe=Ae(v);se(n,Fe,_e=>t(28,a=_e));let rt,de,Ge;pl("svelteflow__node_id",c),pl("svelteflow__node_connectable",Fe),qn(()=>{Ie&&(k==null||k.unobserve(Ie))});function Ke(_e){_&&(!le(ge)||!d||le(j)>0)&&x(c),Te("nodeclick",{node:u.internals.userNode,event:_e})}const Vt=(_e,Ht,wt,St)=>{Te("nodedrag",{event:_e,targetNode:wt,nodes:St})},Bt=(_e,Ht,wt,St)=>{Te("nodedragstart",{event:_e,targetNode:wt,nodes:St})},yt=(_e,Ht,wt,St)=>{Te("nodedragstop",{event:_e,targetNode:wt,nodes:St})};function Yt(_e){Be[_e?"unshift":"push"](()=>{ie=_e,t(24,ie)})}const Nt=_e=>Te("nodemouseenter",{node:u,event:_e}),Ot=_e=>Te("nodemouseleave",{node:u,event:_e}),Dt=_e=>Te("nodemousemove",{node:u,event:_e}),Kt=_e=>Te("nodecontextmenu",{node:u,event:_e});return n.$$set=_e=>{"node"in _e&&t(0,u=_e.node),"id"in _e&&t(1,c=_e.id),"data"in _e&&t(2,f=_e.data),"selected"in _e&&t(3,h=_e.selected),"draggable"in _e&&t(4,d=_e.draggable),"selectable"in _e&&t(5,_=_e.selectable),"connectable"in _e&&t(6,v=_e.connectable),"deletable"in _e&&t(7,p=_e.deletable),"hidden"in _e&&t(8,g=_e.hidden),"dragging"in _e&&t(9,y=_e.dragging),"resizeObserver"in _e&&t(35,k=_e.resizeObserver),"style"in _e&&t(10,w=_e.style),"type"in _e&&t(36,N=_e.type),"isParent"in _e&&t(11,S=_e.isParent),"positionX"in _e&&t(12,A=_e.positionX),"positionY"in _e&&t(13,z=_e.positionY),"sourcePosition"in _e&&t(14,M=_e.sourcePosition),"targetPosition"in _e&&t(15,V=_e.targetPosition),"zIndex"in _e&&t(16,L=_e.zIndex),"measuredWidth"in _e&&t(37,Y=_e.measuredWidth),"measuredHeight"in _e&&t(38,K=_e.measuredHeight),"initialWidth"in _e&&t(39,E=_e.initialWidth),"initialHeight"in _e&&t(40,q=_e.initialHeight),"width"in _e&&t(17,D=_e.width),"height"in _e&&t(18,U=_e.height),"dragHandle"in _e&&t(19,F=_e.dragHandle),"initialized"in _e&&t(20,C=_e.initialized),"parentId"in _e&&t(21,R=_e.parentId),"nodeClickDistance"in _e&&t(22,G=_e.nodeClickDistance),"class"in _e&&t(23,J=_e.class)},n.$$.update=()=>{n.$$.dirty[1]&32&&t(25,l=N||"default"),n.$$.dirty[0]&33554432|n.$$.dirty[1]&32768&&t(45,o=!!i[l]),n.$$.dirty[0]&33554432|n.$$.dirty[1]&32768&&t(27,s=i[l]||Va),n.$$.dirty[1]&16416&&(o||console.warn("003",Yl.error003(N))),n.$$.dirty[0]&393216|n.$$.dirty[1]&960&&t(26,r=Pm({width:D,height:U,initialWidth:E,initialHeight:q,measuredWidth:Y,measuredHeight:K})),n.$$.dirty[0]&64&&Fe.set(!!v),n.$$.dirty[0]&50380802|n.$$.dirty[1]&14336&&((rt&&l!==rt||de&&M!==de||Ge&&V!==Ge)&&requestAnimationFrame(()=>ye(new Map([[c,{id:c,nodeElement:ie,force:!0}]]))),t(42,rt=l),t(43,de=M),t(44,Ge=V)),n.$$.dirty[0]&17825792|n.$$.dirty[1]&1040&&k&&(ie!==Ie||!C)&&(Ie&&k.unobserve(Ie),ie&&k.observe(ie),t(41,Ie=ie))},[u,c,f,h,d,_,v,p,g,y,w,S,A,z,M,V,L,D,U,F,C,R,G,J,ie,l,r,s,a,oe,ee,x,Te,Fe,Ke,k,N,Y,K,E,q,Ie,rt,de,Ge,o,i,Vt,Bt,yt,Yt,Nt,Ot,Dt,Kt]}class Om extends ke{constructor(e){super(),Ee(this,e,Nm,Vm,Hr,{node:0,id:1,data:2,selected:3,draggable:4,selectable:5,connectable:6,deletable:7,hidden:8,dragging:9,resizeObserver:35,style:10,type:36,isParent:11,positionX:12,positionY:13,sourcePosition:14,targetPosition:15,zIndex:16,measuredWidth:37,measuredHeight:38,initialWidth:39,initialHeight:40,width:17,height:18,dragHandle:19,initialized:20,parentId:21,nodeClickDistance:22,class:23},null,[-1,-1])}}const{Map:Hm}=Ar;function ji(n,e,t){const l=n.slice();return l[21]=e[t],l}function Yi(n,e){let t,l,o;return l=new Om({props:{node:e[21],id:e[21].id,data:e[21].data,selected:!!e[21].selected,hidden:!!e[21].hidden,draggable:!!(e[21].draggable||e[2]&&typeof e[21].draggable>"u"),selectable:!!(e[21].selectable||e[3]&&typeof e[21].selectable>"u"),connectable:!!(e[21].connectable||e[4]&&typeof e[21].connectable>"u"),deletable:e[21].deletable??!0,positionX:e[21].internals.positionAbsolute.x,positionY:e[21].internals.positionAbsolute.y,isParent:e[5].has(e[21].id),style:e[21].style,class:e[21].class,type:e[21].type??"default",sourcePosition:e[21].sourcePosition,targetPosition:e[21].targetPosition,dragging:e[21].dragging,zIndex:e[21].internals.z??0,dragHandle:e[21].dragHandle,initialized:Mi(e[21]),width:e[21].width,height:e[21].height,initialWidth:e[21].initialWidth,initialHeight:e[21].initialHeight,measuredWidth:e[21].measured.width,measuredHeight:e[21].measured.height,parentId:e[21].parentId,resizeObserver:e[11],nodeClickDistance:e[0]}}),l.$on("nodeclick",e[12]),l.$on("nodemouseenter",e[13]),l.$on("nodemousemove",e[14]),l.$on("nodemouseleave",e[15]),l.$on("nodedrag",e[16]),l.$on("nodedragstart",e[17]),l.$on("nodedragstop",e[18]),l.$on("nodecontextmenu",e[19]),{key:n,first:null,c(){t=Le(),re(l.$$.fragment),this.h()},l(s){t=Le(),ce(l.$$.fragment,s),this.h()},h(){this.first=t},m(s,r){W(s,t,r),ae(l,s,r),o=!0},p(s,r){e=s;const i={};r&2&&(i.node=e[21]),r&2&&(i.id=e[21].id),r&2&&(i.data=e[21].data),r&2&&(i.selected=!!e[21].selected),r&2&&(i.hidden=!!e[21].hidden),r&6&&(i.draggable=!!(e[21].draggable||e[2]&&typeof e[21].draggable>"u")),r&10&&(i.selectable=!!(e[21].selectable||e[3]&&typeof e[21].selectable>"u")),r&18&&(i.connectable=!!(e[21].connectable||e[4]&&typeof e[21].connectable>"u")),r&2&&(i.deletable=e[21].deletable??!0),r&2&&(i.positionX=e[21].internals.positionAbsolute.x),r&2&&(i.positionY=e[21].internals.positionAbsolute.y),r&34&&(i.isParent=e[5].has(e[21].id)),r&2&&(i.style=e[21].style),r&2&&(i.class=e[21].class),r&2&&(i.type=e[21].type??"default"),r&2&&(i.sourcePosition=e[21].sourcePosition),r&2&&(i.targetPosition=e[21].targetPosition),r&2&&(i.dragging=e[21].dragging),r&2&&(i.zIndex=e[21].internals.z??0),r&2&&(i.dragHandle=e[21].dragHandle),r&2&&(i.initialized=Mi(e[21])),r&2&&(i.width=e[21].width),r&2&&(i.height=e[21].height),r&2&&(i.initialWidth=e[21].initialWidth),r&2&&(i.initialHeight=e[21].initialHeight),r&2&&(i.measuredWidth=e[21].measured.width),r&2&&(i.measuredHeight=e[21].measured.height),r&2&&(i.parentId=e[21].parentId),r&1&&(i.nodeClickDistance=e[0]),l.$set(i)},i(s){o||(P(l.$$.fragment,s),o=!0)},o(s){B(l.$$.fragment,s),o=!1},d(s){s&&b(t),ue(l,s)}}}function Lm(n){let e,t=[],l=new Hm,o,s=pt(n[1]);const r=i=>i[21].id;for(let i=0;it(1,l=z)),se(n,c,z=>t(2,o=z)),se(n,f,z=>t(4,r=z)),se(n,h,z=>t(3,s=z)),se(n,_,z=>t(5,i=z));const v=typeof ResizeObserver>"u"?null:new ResizeObserver(z=>{const M=new Map;z.forEach(V=>{const L=V.target.getAttribute("data-id");M.set(L,{id:L,nodeElement:V.target,force:!0})}),d(M)});qn(()=>{v==null||v.disconnect()});function p(z){at.call(this,n,z)}function g(z){at.call(this,n,z)}function y(z){at.call(this,n,z)}function k(z){at.call(this,n,z)}function w(z){at.call(this,n,z)}function N(z){at.call(this,n,z)}function S(z){at.call(this,n,z)}function A(z){at.call(this,n,z)}return n.$$set=z=>{"nodeClickDistance"in z&&t(0,a=z.nodeClickDistance)},[a,l,o,s,r,i,u,c,f,h,_,v,p,g,y,k,w,N,S,A]}class Bm extends ke{constructor(e){super(),Ee(this,e,Am,Lm,Se,{nodeClickDistance:0})}}function Xi(n){let e,t,l,o,s,r,i,a;var u=n[27];function c(f,h){return{props:{id:f[0],source:f[1],target:f[2],sourceX:f[14],sourceY:f[15],targetX:f[16],targetY:f[17],sourcePosition:f[18],targetPosition:f[19],animated:f[6],selected:f[7],label:f[10],labelStyle:f[11],data:f[3],style:f[4],interactionWidth:f[21],selectable:f[24],deletable:f[8]??!0,type:f[23],sourceHandleId:f[12],targetHandleId:f[13],markerStart:f[26],markerEnd:f[25]}}}return u&&(l=ro(u,c(n))),{c(){e=Pe("svg"),t=Pe("g"),l&&re(l.$$.fragment),this.h()},l(f){e=Ve(f,"svg",{});var h=T(e);t=Ve(h,"g",{class:!0,"data-id":!0,"aria-label":!0,role:!0});var d=T(t);l&&ce(l.$$.fragment,d),d.forEach(b),h.forEach(b),this.h()},h(){m(t,"class",o=Mt(["svelte-flow__edge",n[22]])),m(t,"data-id",n[0]),m(t,"aria-label",s=n[20]===null?void 0:n[20]?n[20]:`Edge from ${n[1]} to ${n[2]}`),m(t,"role","img"),et(t,"animated",n[6]),et(t,"selected",n[7]),et(t,"selectable",n[24]),Ze(e,"z-index",n[5])},m(f,h){W(f,e,h),I(e,t),l&&ae(l,t,null),r=!0,i||(a=[he(t,"click",n[32]),he(t,"contextmenu",n[41]),he(t,"mouseenter",n[42]),he(t,"mouseleave",n[43])],i=!0)},p(f,h){if(h[0]&134217728&&u!==(u=f[27])){if(l){je();const d=l;B(d.$$.fragment,1,0,()=>{ue(d,1)}),Ye()}u?(l=ro(u,c(f)),re(l.$$.fragment),P(l.$$.fragment,1),ae(l,t,null)):l=null}else if(u){const d={};h[0]&1&&(d.id=f[0]),h[0]&2&&(d.source=f[1]),h[0]&4&&(d.target=f[2]),h[0]&16384&&(d.sourceX=f[14]),h[0]&32768&&(d.sourceY=f[15]),h[0]&65536&&(d.targetX=f[16]),h[0]&131072&&(d.targetY=f[17]),h[0]&262144&&(d.sourcePosition=f[18]),h[0]&524288&&(d.targetPosition=f[19]),h[0]&64&&(d.animated=f[6]),h[0]&128&&(d.selected=f[7]),h[0]&1024&&(d.label=f[10]),h[0]&2048&&(d.labelStyle=f[11]),h[0]&8&&(d.data=f[3]),h[0]&16&&(d.style=f[4]),h[0]&2097152&&(d.interactionWidth=f[21]),h[0]&16777216&&(d.selectable=f[24]),h[0]&256&&(d.deletable=f[8]??!0),h[0]&8388608&&(d.type=f[23]),h[0]&4096&&(d.sourceHandleId=f[12]),h[0]&8192&&(d.targetHandleId=f[13]),h[0]&67108864&&(d.markerStart=f[26]),h[0]&33554432&&(d.markerEnd=f[25]),l.$set(d)}(!r||h[0]&4194304&&o!==(o=Mt(["svelte-flow__edge",f[22]])))&&m(t,"class",o),(!r||h[0]&1)&&m(t,"data-id",f[0]),(!r||h[0]&1048582&&s!==(s=f[20]===null?void 0:f[20]?f[20]:`Edge from ${f[1]} to ${f[2]}`))&&m(t,"aria-label",s),(!r||h[0]&4194368)&&et(t,"animated",f[6]),(!r||h[0]&4194432)&&et(t,"selected",f[7]),(!r||h[0]&20971520)&&et(t,"selectable",f[24]),h[0]&32&&Ze(e,"z-index",f[5])},i(f){r||(l&&P(l.$$.fragment,f),r=!0)},o(f){l&&B(l.$$.fragment,f),r=!1},d(f){f&&b(e),l&&ue(l),i=!1,At(a)}}}function Rm(n){let e,t,l=!n[9]&&Xi(n);return{c(){l&&l.c(),e=Le()},l(o){l&&l.l(o),e=Le()},m(o,s){l&&l.m(o,s),W(o,e,s),t=!0},p(o,s){o[9]?l&&(je(),B(l,1,1,()=>{l=null}),Ye()):l?(l.p(o,s),s[0]&512&&P(l,1)):(l=Xi(o),l.c(),P(l,1),l.m(e.parentNode,e))},i(o){t||(P(l),t=!0)},o(o){B(l),t=!1},d(o){o&&b(e),l&&l.d(o)}}}function Um(n,e,t){let l,o,s,r,i,a,u,c,f,{id:h}=e,{type:d="default"}=e,{source:_=""}=e,{target:v=""}=e,{data:p={}}=e,{style:g=void 0}=e,{zIndex:y=void 0}=e,{animated:k=!1}=e,{selected:w=!1}=e,{selectable:N=void 0}=e,{deletable:S=void 0}=e,{hidden:A=!1}=e,{label:z=void 0}=e,{labelStyle:M=void 0}=e,{markerStart:V=void 0}=e,{markerEnd:L=void 0}=e,{sourceHandle:Y=void 0}=e,{targetHandle:K=void 0}=e,{sourceX:E}=e,{sourceY:q}=e,{targetX:D}=e,{targetY:U}=e,{sourcePosition:F}=e,{targetPosition:C}=e,{ariaLabel:R=void 0}=e,{interactionWidth:G=void 0}=e,{class:J=""}=e;pl("svelteflow__edge_id",h);const{edgeLookup:oe,edgeTypes:ee,flowId:j,elementsSelectable:ge}=Rt();se(n,oe,de=>t(44,a=de)),se(n,ee,de=>t(40,f=de)),se(n,j,de=>t(39,c=de)),se(n,ge,de=>t(38,u=de));const x=en(),ye=Na();function ie(de){const Ge=a.get(h);Ge&&(ye(h),x("edgeclick",{event:de,edge:Ge}))}function Ie(de,Ge){const Ke=a.get(h);Ke&&x(Ge,{event:de,edge:Ke})}const Te=de=>{Ie(de,"edgecontextmenu")},Fe=de=>{Ie(de,"edgemouseenter")},rt=de=>{Ie(de,"edgemouseleave")};return n.$$set=de=>{"id"in de&&t(0,h=de.id),"type"in de&&t(34,d=de.type),"source"in de&&t(1,_=de.source),"target"in de&&t(2,v=de.target),"data"in de&&t(3,p=de.data),"style"in de&&t(4,g=de.style),"zIndex"in de&&t(5,y=de.zIndex),"animated"in de&&t(6,k=de.animated),"selected"in de&&t(7,w=de.selected),"selectable"in de&&t(35,N=de.selectable),"deletable"in de&&t(8,S=de.deletable),"hidden"in de&&t(9,A=de.hidden),"label"in de&&t(10,z=de.label),"labelStyle"in de&&t(11,M=de.labelStyle),"markerStart"in de&&t(36,V=de.markerStart),"markerEnd"in de&&t(37,L=de.markerEnd),"sourceHandle"in de&&t(12,Y=de.sourceHandle),"targetHandle"in de&&t(13,K=de.targetHandle),"sourceX"in de&&t(14,E=de.sourceX),"sourceY"in de&&t(15,q=de.sourceY),"targetX"in de&&t(16,D=de.targetX),"targetY"in de&&t(17,U=de.targetY),"sourcePosition"in de&&t(18,F=de.sourcePosition),"targetPosition"in de&&t(19,C=de.targetPosition),"ariaLabel"in de&&t(20,R=de.ariaLabel),"interactionWidth"in de&&t(21,G=de.interactionWidth),"class"in de&&t(22,J=de.class)},n.$$.update=()=>{n.$$.dirty[1]&8&&t(23,l=d||"default"),n.$$.dirty[0]&8388608|n.$$.dirty[1]&512&&t(27,o=f[l]||Oa),n.$$.dirty[1]&288&&t(26,s=V?`url('#${Zo(V,c)}')`:void 0),n.$$.dirty[1]&320&&t(25,r=L?`url('#${Zo(L,c)}')`:void 0),n.$$.dirty[1]&144&&t(24,i=N??u)},[h,_,v,p,g,y,k,w,S,A,z,M,Y,K,E,q,D,U,F,C,R,G,J,l,i,r,s,o,oe,ee,j,ge,ie,Ie,d,N,V,L,u,c,f,Te,Fe,rt]}class Wm extends ke{constructor(e){super(),Ee(this,e,Um,Rm,Hr,{id:0,type:34,source:1,target:2,data:3,style:4,zIndex:5,animated:6,selected:7,selectable:35,deletable:8,hidden:9,label:10,labelStyle:11,markerStart:36,markerEnd:37,sourceHandle:12,targetHandle:13,sourceX:14,sourceY:15,targetX:16,targetY:17,sourcePosition:18,targetPosition:19,ariaLabel:20,interactionWidth:21,class:22},null,[-1,-1])}}function Fm(n,e,t){let{onMount:l=void 0}=e,{onDestroy:o=void 0}=e;return un(()=>(l==null||l(),o)),n.$$set=s=>{"onMount"in s&&t(0,l=s.onMount),"onDestroy"in s&&t(1,o=s.onDestroy)},[l,o]}class jm extends ke{constructor(e){super(),Ee(this,e,Fm,null,Se,{onMount:0,onDestroy:1})}}function Ki(n,e,t){const l=n.slice();return l[2]=e[t],l}function Zi(n,e){let t,l,o;const s=[e[2]];let r={};for(let i=0;ii[2].id;for(let i=0;it(0,l=s)),[l,o]}class Km extends ke{constructor(e){super(),Ee(this,e,Xm,Ym,Se,{})}}function Zm(n){let e;return{c(){e=Pe("polyline"),this.h()},l(t){e=Ve(t,"polyline",{stroke:!0,"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,fill:!0,points:!0}),T(e).forEach(b),this.h()},h(){m(e,"stroke",n[6]),m(e,"stroke-linecap","round"),m(e,"stroke-linejoin","round"),m(e,"stroke-width",n[7]),m(e,"fill",n[6]),m(e,"points","-5,-4 0,0 -5,4 -5,-4")},m(t,l){W(t,e,l)},p(t,l){l&64&&m(e,"stroke",t[6]),l&128&&m(e,"stroke-width",t[7]),l&64&&m(e,"fill",t[6])},d(t){t&&b(e)}}}function Gm(n){let e;return{c(){e=Pe("polyline"),this.h()},l(t){e=Ve(t,"polyline",{stroke:!0,"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,fill:!0,points:!0}),T(e).forEach(b),this.h()},h(){m(e,"stroke",n[6]),m(e,"stroke-linecap","round"),m(e,"stroke-linejoin","round"),m(e,"stroke-width",n[7]),m(e,"fill","none"),m(e,"points","-5,-4 0,0 -5,4")},m(t,l){W(t,e,l)},p(t,l){l&64&&m(e,"stroke",t[6]),l&128&&m(e,"stroke-width",t[7])},d(t){t&&b(e)}}}function qm(n){let e,t,l;function o(i,a){if(i[1]===ho.Arrow)return Gm;if(i[1]===ho.ArrowClosed)return Zm}let s=o(n),r=s&&s(n);return{c(){e=Pe("marker"),r&&r.c(),this.h()},l(i){e=Ve(i,"marker",{class:!0,id:!0,markerWidth:!0,markerHeight:!0,viewBox:!0,markerUnits:!0,orient:!0,refX:!0,refY:!0});var a=T(e);r&&r.l(a),a.forEach(b),this.h()},h(){m(e,"class","svelte-flow__arrowhead"),m(e,"id",n[0]),m(e,"markerWidth",t=`${n[2]}`),m(e,"markerHeight",l=`${n[3]}`),m(e,"viewBox","-10 -10 20 20"),m(e,"markerUnits",n[4]),m(e,"orient",n[5]),m(e,"refX","0"),m(e,"refY","0")},m(i,a){W(i,e,a),r&&r.m(e,null)},p(i,[a]){s===(s=o(i))&&r?r.p(i,a):(r&&r.d(1),r=s&&s(i),r&&(r.c(),r.m(e,null))),a&1&&m(e,"id",i[0]),a&4&&t!==(t=`${i[2]}`)&&m(e,"markerWidth",t),a&8&&l!==(l=`${i[3]}`)&&m(e,"markerHeight",l),a&16&&m(e,"markerUnits",i[4]),a&32&&m(e,"orient",i[5])},i:we,o:we,d(i){i&&b(e),r&&r.d()}}}function Jm(n,e,t){let{id:l}=e,{type:o}=e,{width:s=12.5}=e,{height:r=12.5}=e,{markerUnits:i="strokeWidth"}=e,{orient:a="auto-start-reverse"}=e,{color:u=void 0}=e,{strokeWidth:c=void 0}=e;return n.$$set=f=>{"id"in f&&t(0,l=f.id),"type"in f&&t(1,o=f.type),"width"in f&&t(2,s=f.width),"height"in f&&t(3,r=f.height),"markerUnits"in f&&t(4,i=f.markerUnits),"orient"in f&&t(5,a=f.orient),"color"in f&&t(6,u=f.color),"strokeWidth"in f&&t(7,c=f.strokeWidth)},[l,o,s,r,i,a,u,c]}class Qm extends ke{constructor(e){super(),Ee(this,e,Jm,qm,Se,{id:0,type:1,width:2,height:3,markerUnits:4,orient:5,color:6,strokeWidth:7})}}function Gi(n,e,t){const l=n.slice();return l[14]=e[t],l}function qi(n,e){let t,l,o;return l=new Wm({props:{id:e[14].id,source:e[14].source,target:e[14].target,data:e[14].data,style:e[14].style,animated:e[14].animated,selected:e[14].selected,selectable:e[14].selectable??e[1],deletable:e[14].deletable,hidden:e[14].hidden,label:e[14].label,labelStyle:e[14].labelStyle,markerStart:e[14].markerStart,markerEnd:e[14].markerEnd,sourceHandle:e[14].sourceHandle,targetHandle:e[14].targetHandle,sourceX:e[14].sourceX,sourceY:e[14].sourceY,targetX:e[14].targetX,targetY:e[14].targetY,sourcePosition:e[14].sourcePosition,targetPosition:e[14].targetPosition,ariaLabel:e[14].ariaLabel,interactionWidth:e[14].interactionWidth,class:e[14].class,type:e[14].type||"default",zIndex:e[14].zIndex}}),l.$on("edgeclick",e[7]),l.$on("edgecontextmenu",e[8]),l.$on("edgemouseenter",e[9]),l.$on("edgemouseleave",e[10]),{key:n,first:null,c(){t=Le(),re(l.$$.fragment),this.h()},l(s){t=Le(),ce(l.$$.fragment,s),this.h()},h(){this.first=t},m(s,r){W(s,t,r),ae(l,s,r),o=!0},p(s,r){e=s;const i={};r&1&&(i.id=e[14].id),r&1&&(i.source=e[14].source),r&1&&(i.target=e[14].target),r&1&&(i.data=e[14].data),r&1&&(i.style=e[14].style),r&1&&(i.animated=e[14].animated),r&1&&(i.selected=e[14].selected),r&3&&(i.selectable=e[14].selectable??e[1]),r&1&&(i.deletable=e[14].deletable),r&1&&(i.hidden=e[14].hidden),r&1&&(i.label=e[14].label),r&1&&(i.labelStyle=e[14].labelStyle),r&1&&(i.markerStart=e[14].markerStart),r&1&&(i.markerEnd=e[14].markerEnd),r&1&&(i.sourceHandle=e[14].sourceHandle),r&1&&(i.targetHandle=e[14].targetHandle),r&1&&(i.sourceX=e[14].sourceX),r&1&&(i.sourceY=e[14].sourceY),r&1&&(i.targetX=e[14].targetX),r&1&&(i.targetY=e[14].targetY),r&1&&(i.sourcePosition=e[14].sourcePosition),r&1&&(i.targetPosition=e[14].targetPosition),r&1&&(i.ariaLabel=e[14].ariaLabel),r&1&&(i.interactionWidth=e[14].interactionWidth),r&1&&(i.class=e[14].class),r&1&&(i.type=e[14].type||"default"),r&1&&(i.zIndex=e[14].zIndex),l.$set(i)},i(s){o||(P(l.$$.fragment,s),o=!0)},o(s){B(l.$$.fragment,s),o=!1},d(s){s&&b(t),ue(l,s)}}}function Ji(n){let e,t;return e=new jm({props:{onMount:n[11],onDestroy:n[12]}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&4&&(s.onMount=l[11]),o&4&&(s.onDestroy=l[12]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function xm(n){let e,t,l,o,s=[],r=new Map,i,a;l=new Km({});let u=pt(n[0]);const c=h=>h[14].id;for(let h=0;h0&&Ji(n);return{c(){e=O("div"),t=Pe("svg"),re(l.$$.fragment),o=te();for(let h=0;h0?f?(f.p(h,d),d&1&&P(f,1)):(f=Ji(h),f.c(),P(f,1),f.m(e,null)):f&&(je(),B(f,1,1,()=>{f=null}),Ye())},i(h){if(!a){P(l.$$.fragment,h);for(let d=0;dt(0,l=g)),se(n,a,g=>t(2,s=g)),se(n,c,g=>t(1,o=g)),un(()=>{r&&u(r)});function f(g){at.call(this,n,g)}function h(g){at.call(this,n,g)}function d(g){at.call(this,n,g)}function _(g){at.call(this,n,g)}const v=()=>{io(a,s=!0,s)},p=()=>{io(a,s=!1,s)};return n.$$set=g=>{"defaultEdgeOptions"in g&&t(6,r=g.defaultEdgeOptions)},[l,o,s,i,a,c,r,f,h,d,_,v,p]}class e0 extends ke{constructor(e){super(),Ee(this,e,$m,xm,Se,{defaultEdgeOptions:6})}}function Qi(n){let e;return{c(){e=O("div"),this.h()},l(t){e=H(t,"DIV",{class:!0}),T(e).forEach(b),this.h()},h(){m(e,"class","svelte-flow__selection svelte-1iugwpu"),Ze(e,"width",typeof n[2]=="string"?n[2]:`${n[2]}px`),Ze(e,"height",typeof n[3]=="string"?n[3]:`${n[3]}px`),Ze(e,"transform",`translate(${n[0]}px, ${n[1]}px)`)},m(t,l){W(t,e,l)},p(t,l){l&4&&Ze(e,"width",typeof t[2]=="string"?t[2]:`${t[2]}px`),l&8&&Ze(e,"height",typeof t[3]=="string"?t[3]:`${t[3]}px`),l&3&&Ze(e,"transform",`translate(${t[0]}px, ${t[1]}px)`)},d(t){t&&b(e)}}}function t0(n){let e,t=n[4]&&Qi(n);return{c(){t&&t.c(),e=Le()},l(l){t&&t.l(l),e=Le()},m(l,o){t&&t.m(l,o),W(l,e,o)},p(l,[o]){l[4]?t?t.p(l,o):(t=Qi(l),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:we,o:we,d(l){l&&b(e),t&&t.d(l)}}}function n0(n,e,t){let{x:l=0}=e,{y:o=0}=e,{width:s=0}=e,{height:r=0}=e,{isVisible:i=!0}=e;return n.$$set=a=>{"x"in a&&t(0,l=a.x),"y"in a&&t(1,o=a.y),"width"in a&&t(2,s=a.width),"height"in a&&t(3,r=a.height),"isVisible"in a&&t(4,i=a.isVisible)},[l,o,s,r,i]}class Ra extends ke{constructor(e){super(),Ee(this,e,n0,t0,Se,{x:0,y:1,width:2,height:3,isVisible:4})}}function l0(n){var l,o,s,r;let e,t;return e=new Ra({props:{isVisible:!!(n[0]&&n[1]==="user"),width:(l=n[0])==null?void 0:l.width,height:(o=n[0])==null?void 0:o.height,x:(s=n[0])==null?void 0:s.x,y:(r=n[0])==null?void 0:r.y}}),{c(){re(e.$$.fragment)},l(i){ce(e.$$.fragment,i)},m(i,a){ae(e,i,a),t=!0},p(i,[a]){var c,f,h,d;const u={};a&3&&(u.isVisible=!!(i[0]&&i[1]==="user")),a&1&&(u.width=(c=i[0])==null?void 0:c.width),a&1&&(u.height=(f=i[0])==null?void 0:f.height),a&1&&(u.x=(h=i[0])==null?void 0:h.x),a&1&&(u.y=(d=i[0])==null?void 0:d.y),e.$set(u)},i(i){t||(P(e.$$.fragment,i),t=!0)},o(i){B(e.$$.fragment,i),t=!1},d(i){ue(e,i)}}}function o0(n,e,t){let l,o;const{selectionRect:s,selectionRectMode:r}=Rt();return se(n,s,i=>t(0,l=i)),se(n,r,i=>t(1,o=i)),[l,o,s,r]}class s0 extends ke{constructor(e){super(),Ee(this,e,o0,l0,Se,{})}}function xi(n){let e,t,l,o,s;return t=new Ra({props:{width:"100%",height:"100%",x:0,y:0}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(r){e=H(r,"DIV",{class:!0,style:!0,role:!0,tabindex:!0});var i=T(e);ce(t.$$.fragment,i),i.forEach(b),this.h()},h(){m(e,"class","selection-wrapper nopan svelte-5pxri"),Ze(e,"width",n[1].width+"px"),Ze(e,"height",n[1].height+"px"),Ze(e,"transform","translate("+n[1].x+"px, "+n[1].y+"px)"),m(e,"role","button"),m(e,"tabindex","-1")},m(r,i){W(r,e,i),ae(t,e,null),l=!0,o||(s=[Ut(Ba.call(null,e,{disabled:!1,store:n[2],onDrag:n[11],onDragStart:n[12],onDragStop:n[13]})),he(e,"contextmenu",n[7]),he(e,"click",n[8]),he(e,"keyup",r0)],o=!0)},p(r,i){(!l||i&2)&&Ze(e,"width",r[1].width+"px"),(!l||i&2)&&Ze(e,"height",r[1].height+"px"),(!l||i&2)&&Ze(e,"transform","translate("+r[1].x+"px, "+r[1].y+"px)")},i(r){l||(P(t.$$.fragment,r),l=!0)},o(r){B(t.$$.fragment,r),l=!1},d(r){r&&b(e),ue(t),o=!1,At(s)}}}function i0(n){let e=n[0]==="nodes"&&n[1]&&Vn(n[1].x)&&Vn(n[1].y),t,l,o=e&&xi(n);return{c(){o&&o.c(),t=Le()},l(s){o&&o.l(s),t=Le()},m(s,r){o&&o.m(s,r),W(s,t,r),l=!0},p(s,[r]){r&3&&(e=s[0]==="nodes"&&s[1]&&Vn(s[1].x)&&Vn(s[1].y)),e?o?(o.p(s,r),r&3&&P(o,1)):(o=xi(s),o.c(),P(o,1),o.m(t.parentNode,t)):o&&(je(),B(o,1,1,()=>{o=null}),Ye())},i(s){l||(P(o),l=!0)},o(s){B(o),l=!1},d(s){s&&b(t),o&&o.d(s)}}}const r0=()=>{};function a0(n,e,t){let l,o,s;const r=Rt(),{selectionRectMode:i,nodes:a,nodeLookup:u}=r;se(n,i,g=>t(0,s=g)),se(n,a,g=>t(9,l=g)),se(n,u,g=>t(10,o=g));const c=en();let f=null;function h(g){const y=l.filter(k=>k.selected);c("selectioncontextmenu",{nodes:y,event:g})}function d(g){const y=l.filter(k=>k.selected);c("selectionclick",{nodes:y,event:g})}const _=(g,y,k,w)=>{c("nodedrag",{event:g,targetNode:null,nodes:w})},v=(g,y,k,w)=>{c("nodedragstart",{event:g,targetNode:null,nodes:w})},p=(g,y,k,w)=>{c("nodedragstop",{event:g,targetNode:null,nodes:w})};return n.$$.update=()=>{n.$$.dirty&1537&&s==="nodes"&&t(1,f=ko(o,{filter:g=>!!g.selected}))},[s,f,r,i,a,u,c,h,d,l,o,_,v,p]}class u0 extends ke{constructor(e){super(),Ee(this,e,a0,i0,Se,{})}}function Un(n,e){let{enabled:t=!0,trigger:l,type:o="keydown"}=e;function s(r){const i=Array.isArray(l)?l:[l],a={alt:r.altKey,ctrl:r.ctrlKey,shift:r.shiftKey,meta:r.metaKey};for(const u of i){const c={modifier:[],preventDefault:!1,enabled:!0,...u},{modifier:f,key:h,callback:d,preventDefault:_,enabled:v}=c;if(v){if(f.length&&!(Array.isArray(f)?f:[f]).map(y=>typeof y=="string"?[y]:y).some(y=>y.every(k=>a[k])))continue;if(r.key===h){_&&r.preventDefault();const p={node:n,trigger:c,originalEvent:r};n.dispatchEvent(new CustomEvent("shortcut",{detail:p})),d==null||d(p)}}}}return t&&n.addEventListener(o,s),{update:r=>{const{enabled:i=!0,type:a="keydown"}=r;t&&(!i||o!==a)?n.removeEventListener(o,s):!t&&i&&n.addEventListener(a,s),t=i,o=a,l=r.trigger},destroy:()=>{n.removeEventListener(o,s)}}}function c0(n){let e,t,l,o,s,r,i,a,u,c,f,h;return{c:we,l:we,m(d,_){f||(h=[Ut(e=Un.call(null,window,{trigger:jt(n[0],n[11]),type:"keydown"})),Ut(t=Un.call(null,window,{trigger:jt(n[0],n[12]),type:"keyup"})),Ut(l=Un.call(null,window,{trigger:jt(n[1],n[13]),type:"keydown"})),Ut(o=Un.call(null,window,{trigger:jt(n[1],n[14]),type:"keyup"})),Ut(s=Un.call(null,window,{trigger:jt(n[2],n[15]),type:"keydown"})),Ut(r=Un.call(null,window,{trigger:jt(n[2],n[16]),type:"keyup"})),Ut(i=Un.call(null,window,{trigger:jt(n[3],n[17]),type:"keydown"})),Ut(a=Un.call(null,window,{trigger:jt(n[3],n[18]),type:"keyup"})),Ut(u=Un.call(null,window,{trigger:jt(n[4],n[19]),type:"keydown"})),Ut(c=Un.call(null,window,{trigger:jt(n[4],n[20]),type:"keyup"})),he(window,"blur",n[10]),he(window,"contextmenu",n[10])],f=!0)},p(d,[_]){e&&Xt(e.update)&&_&1&&e.update.call(null,{trigger:jt(d[0],d[11]),type:"keydown"}),t&&Xt(t.update)&&_&1&&t.update.call(null,{trigger:jt(d[0],d[12]),type:"keyup"}),l&&Xt(l.update)&&_&2&&l.update.call(null,{trigger:jt(d[1],d[13]),type:"keydown"}),o&&Xt(o.update)&&_&2&&o.update.call(null,{trigger:jt(d[1],d[14]),type:"keyup"}),s&&Xt(s.update)&&_&4&&s.update.call(null,{trigger:jt(d[2],d[15]),type:"keydown"}),r&&Xt(r.update)&&_&4&&r.update.call(null,{trigger:jt(d[2],d[16]),type:"keyup"}),i&&Xt(i.update)&&_&8&&i.update.call(null,{trigger:jt(d[3],d[17]),type:"keydown"}),a&&Xt(a.update)&&_&8&&a.update.call(null,{trigger:jt(d[3],d[18]),type:"keyup"}),u&&Xt(u.update)&&_&16&&u.update.call(null,{trigger:jt(d[4],d[19]),type:"keydown"}),c&&Xt(c.update)&&_&16&&c.update.call(null,{trigger:jt(d[4],d[20]),type:"keyup"})},i:we,o:we,d(d){f=!1,At(h)}}}function Ua(n){return n!==null&&typeof n=="object"}function f0(n){return Ua(n)?n.modifier||[]:[]}function d0(n){return n==null?"":Ua(n)?n.key:n}function jt(n,e){return(Array.isArray(n)?n:[n]).map(l=>{const o=d0(l);return{key:o,modifier:f0(l),enabled:o!==null,callback:e}})}function h0(n,e,t){let{selectionKey:l="Shift"}=e,{multiSelectionKey:o=go()?"Meta":"Control"}=e,{deleteKey:s="Backspace"}=e,{panActivationKey:r=" "}=e,{zoomActivationKey:i=go()?"Meta":"Control"}=e;const{selectionKeyPressed:a,multiselectionKeyPressed:u,deleteKeyPressed:c,panActivationKeyPressed:f,zoomActivationKeyPressed:h,selectionRect:d}=Rt();function _(){d.set(null),a.set(!1),u.set(!1),c.set(!1),f.set(!1),h.set(!1)}const v=()=>a.set(!0),p=()=>a.set(!1),g=()=>u.set(!0),y=()=>u.set(!1),k=M=>{!(M.originalEvent.ctrlKey||M.originalEvent.metaKey||M.originalEvent.shiftKey)&&!Jh(M.originalEvent)&&c.set(!0)},w=()=>c.set(!1),N=()=>f.set(!0),S=()=>f.set(!1),A=()=>h.set(!0),z=()=>h.set(!1);return n.$$set=M=>{"selectionKey"in M&&t(0,l=M.selectionKey),"multiSelectionKey"in M&&t(1,o=M.multiSelectionKey),"deleteKey"in M&&t(2,s=M.deleteKey),"panActivationKey"in M&&t(3,r=M.panActivationKey),"zoomActivationKey"in M&&t(4,i=M.zoomActivationKey)},[l,o,s,r,i,a,u,c,f,h,_,v,p,g,y,k,w,N,S,A,z]}class m0 extends ke{constructor(e){super(),Ee(this,e,h0,c0,Se,{selectionKey:0,multiSelectionKey:1,deleteKey:2,panActivationKey:3,zoomActivationKey:4})}}const g0=n=>({}),$i=n=>({});function er(n){let e,t,l,o;const s=n[13].connectionLine,r=dt(s,n,n[12],$i);let i=!n[2]&&tr(n);return{c(){e=Pe("svg"),t=Pe("g"),r&&r.c(),i&&i.c(),this.h()},l(a){e=Ve(a,"svg",{width:!0,height:!0,class:!0,style:!0});var u=T(e);t=Ve(u,"g",{class:!0});var c=T(t);r&&r.l(c),i&&i.l(c),c.forEach(b),u.forEach(b),this.h()},h(){m(t,"class",l=Mt(["svelte-flow__connection",Si(n[3].isValid)])),m(e,"width",n[5]),m(e,"height",n[6]),m(e,"class","svelte-flow__connectionline"),m(e,"style",n[0])},m(a,u){W(a,e,u),I(e,t),r&&r.m(t,null),i&&i.m(t,null),o=!0},p(a,u){r&&r.p&&(!o||u&4096)&&ht(r,s,a,a[12],o?gt(s,a[12],u,g0):mt(a[12]),$i),a[2]?i&&(i.d(1),i=null):i?i.p(a,u):(i=tr(a),i.c(),i.m(t,null)),(!o||u&8&&l!==(l=Mt(["svelte-flow__connection",Si(a[3].isValid)])))&&m(t,"class",l),(!o||u&32)&&m(e,"width",a[5]),(!o||u&64)&&m(e,"height",a[6]),(!o||u&1)&&m(e,"style",a[0])},i(a){o||(P(r,a),o=!0)},o(a){B(r,a),o=!1},d(a){a&&b(e),r&&r.d(a),i&&i.d()}}}function tr(n){let e;return{c(){e=Pe("path"),this.h()},l(t){e=Ve(t,"path",{d:!0,style:!0,fill:!0,class:!0}),T(e).forEach(b),this.h()},h(){m(e,"d",n[4]),m(e,"style",n[1]),m(e,"fill","none"),m(e,"class","svelte-flow__connection-path")},m(t,l){W(t,e,l)},p(t,l){l&16&&m(e,"d",t[4]),l&2&&m(e,"style",t[1])},d(t){t&&b(e)}}}function _0(n){let e,t,l=n[3].inProgress&&er(n);return{c(){l&&l.c(),e=Le()},l(o){l&&l.l(o),e=Le()},m(o,s){l&&l.m(o,s),W(o,e,s),t=!0},p(o,[s]){o[3].inProgress?l?(l.p(o,s),s&8&&P(l,1)):(l=er(o),l.c(),P(l,1),l.m(e.parentNode,e)):l&&(je(),B(l,1,1,()=>{l=null}),Ye())},i(o){t||(P(l),t=!0)},o(o){B(l),t=!1},d(o){o&&b(e),l&&l.d(o)}}}function b0(n,e,t){let l,o,s,r,{$$slots:i={},$$scope:a}=e,{containerStyle:u=""}=e,{style:c=""}=e,{isCustomComponent:f=!1}=e;const{width:h,height:d,connection:_,connectionLineType:v}=Rt();se(n,h,g=>t(5,s=g)),se(n,d,g=>t(6,r=g)),se(n,_,g=>t(3,o=g)),se(n,v,g=>t(11,l=g));let p=null;return n.$$set=g=>{"containerStyle"in g&&t(0,u=g.containerStyle),"style"in g&&t(1,c=g.style),"isCustomComponent"in g&&t(2,f=g.isCustomComponent),"$$scope"in g&&t(12,a=g.$$scope)},n.$$.update=()=>{if(n.$$.dirty&2060&&o.inProgress&&!f){const{from:g,to:y,fromPosition:k,toPosition:w}=o,N={sourceX:g.x,sourceY:g.y,sourcePosition:k,targetX:y.x,targetY:y.y,targetPosition:w};switch(l){case bl.Bezier:t(4,[p]=_a(N),p);break;case bl.Step:t(4,[p]=_o({...N,borderRadius:0}),p);break;case bl.SmoothStep:t(4,[p]=_o(N),p);break;default:t(4,[p]=pa(N),p)}}},[u,c,f,o,p,s,r,h,d,_,v,l,a,i]}class p0 extends ke{constructor(e){super(),Ee(this,e,b0,_0,Se,{containerStyle:0,style:1,isCustomComponent:2})}}function v0(n){let e,t,l;const o=n[8].default,s=dt(o,n,n[7],null);let r=[{class:t=Mt(["svelte-flow__panel",n[1],...n[2]])},{style:n[0]},n[5]],i={};for(let a=0;at(3,r=d)),n.$$set=d=>{e=Qe(Qe({},e),nn(d)),t(5,s=_t(e,o)),"position"in d&&t(6,u=d.position),"style"in d&&t(0,c=d.style),"class"in d&&t(1,f=d.class),"$$scope"in d&&t(7,a=d.$$scope)},n.$$.update=()=>{n.$$.dirty&64&&t(2,l=`${u}`.split("-"))},[c,f,l,r,h,s,u,a,i]}class Wa extends ke{constructor(e){super(),Ee(this,e,y0,v0,Se,{position:6,style:0,class:1})}}function nr(n){let e,t;return e=new Wa({props:{position:n[1],class:"svelte-flow__attribution","data-message":"Feel free to remove the attribution or check out how you could support us: https://svelteflow.dev/support-us",$$slots:{default:[w0]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&2&&(s.position=l[1]),o&4&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function w0(n){let e,t="Svelte Flow";return{c(){e=O("a"),e.textContent=t,this.h()},l(l){e=H(l,"A",{href:!0,target:!0,rel:!0,"aria-label":!0,"data-svelte-h":!0}),ut(e)!=="svelte-2vm8e4"&&(e.textContent=t),this.h()},h(){m(e,"href","https://svelteflow.dev"),m(e,"target","_blank"),m(e,"rel","noopener noreferrer"),m(e,"aria-label","Svelte Flow attribution")},m(l,o){W(l,e,o)},p:we,d(l){l&&b(e)}}}function k0(n){var o;let e,t,l=!((o=n[0])!=null&&o.hideAttribution)&&nr(n);return{c(){l&&l.c(),e=Le()},l(s){l&&l.l(s),e=Le()},m(s,r){l&&l.m(s,r),W(s,e,r),t=!0},p(s,[r]){var i;(i=s[0])!=null&&i.hideAttribution?l&&(je(),B(l,1,1,()=>{l=null}),Ye()):l?(l.p(s,r),r&1&&P(l,1)):(l=nr(s),l.c(),P(l,1),l.m(e.parentNode,e))},i(s){t||(P(l),t=!0)},o(s){B(l),t=!1},d(s){s&&b(e),l&&l.d(s)}}}function E0(n,e,t){let{proOptions:l=void 0}=e,{position:o="bottom-right"}=e;return n.$$set=s=>{"proOptions"in s&&t(0,l=s.proOptions),"position"in s&&t(1,o=s.position)},[l,o]}class S0 extends ke{constructor(e){super(),Ee(this,e,E0,k0,Se,{proOptions:0,position:1})}}function lr(n,{nodeTypes:e,edgeTypes:t,minZoom:l,maxZoom:o,translateExtent:s,paneClickDistance:r}){e!==void 0&&n.setNodeTypes(e),t!==void 0&&n.setEdgeTypes(t),l!==void 0&&n.setMinZoom(l),o!==void 0&&n.setMaxZoom(o),s!==void 0&&n.setTranslateExtent(s),r!==void 0&&n.setPaneClickDistance(r)}const I0=n=>Object.keys(n);function C0(n,e){I0(e).forEach(t=>{const l=e[t];l!==void 0&&n[t].set(l)})}function D0(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function z0(n="light"){return Tn("light",t=>{if(n!=="system"){t(n);return}const l=D0(),o=()=>t(l!=null&&l.matches?"dark":"light");return t(l!=null&&l.matches?"dark":"light"),l==null||l.addEventListener("change",o),()=>{l==null||l.removeEventListener("change",o)}})}const M0=n=>({}),or=n=>({slot:"connectionLine"});function T0(n){let e;const t=n[75].connectionLine,l=dt(t,n,n[99],or);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,s){l&&l.p&&(!e||s[3]&64)&&ht(l,t,o,o[99],e?gt(t,o[99],s,M0):mt(o[99]),or)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function P0(n){let e,t,l,o,s,r,i,a,u,c,f,h;return e=new e0({props:{defaultEdgeOptions:n[21]}}),e.$on("edgeclick",n[78]),e.$on("edgecontextmenu",n[79]),e.$on("edgemouseenter",n[80]),e.$on("edgemouseleave",n[81]),l=new p0({props:{containerStyle:n[7],style:n[6],isCustomComponent:n[34].connectionLine,$$slots:{connectionLine:[T0]},$$scope:{ctx:n}}}),u=new Bm({props:{nodeClickDistance:n[23]}}),u.$on("nodeclick",n[82]),u.$on("nodemouseenter",n[83]),u.$on("nodemousemove",n[84]),u.$on("nodemouseleave",n[85]),u.$on("nodedragstart",n[86]),u.$on("nodedrag",n[87]),u.$on("nodedragstop",n[88]),u.$on("nodecontextmenu",n[89]),f=new u0({}),f.$on("selectionclick",n[90]),f.$on("selectioncontextmenu",n[91]),f.$on("nodedragstart",n[92]),f.$on("nodedrag",n[93]),f.$on("nodedragstop",n[94]),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment),o=te(),s=O("div"),r=te(),i=O("div"),a=te(),re(u.$$.fragment),c=te(),re(f.$$.fragment),this.h()},l(d){ce(e.$$.fragment,d),t=ne(d),ce(l.$$.fragment,d),o=ne(d),s=H(d,"DIV",{class:!0}),T(s).forEach(b),r=ne(d),i=H(d,"DIV",{class:!0}),T(i).forEach(b),a=ne(d),ce(u.$$.fragment,d),c=ne(d),ce(f.$$.fragment,d),this.h()},h(){m(s,"class","svelte-flow__edgelabel-renderer"),m(i,"class","svelte-flow__viewport-portal")},m(d,_){ae(e,d,_),W(d,t,_),ae(l,d,_),W(d,o,_),W(d,s,_),W(d,r,_),W(d,i,_),W(d,a,_),ae(u,d,_),W(d,c,_),ae(f,d,_),h=!0},p(d,_){const v={};_[0]&2097152&&(v.defaultEdgeOptions=d[21]),e.$set(v);const p={};_[0]&128&&(p.containerStyle=d[7]),_[0]&64&&(p.style=d[6]),_[1]&8&&(p.isCustomComponent=d[34].connectionLine),_[3]&64&&(p.$$scope={dirty:_,ctx:d}),l.$set(p);const g={};_[0]&8388608&&(g.nodeClickDistance=d[23]),u.$set(g)},i(d){h||(P(e.$$.fragment,d),P(l.$$.fragment,d),P(u.$$.fragment,d),P(f.$$.fragment,d),h=!0)},o(d){B(e.$$.fragment,d),B(l.$$.fragment,d),B(u.$$.fragment,d),B(f.$$.fragment,d),h=!1},d(d){d&&(b(t),b(o),b(s),b(r),b(i),b(a),b(c)),ue(e,d),ue(l,d),ue(u,d),ue(f,d)}}}function V0(n){let e,t,l,o;return e=new Tm({props:{$$slots:{default:[P0]},$$scope:{ctx:n}}}),l=new s0({}),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment)},l(s){ce(e.$$.fragment,s),t=ne(s),ce(l.$$.fragment,s)},m(s,r){ae(e,s,r),W(s,t,r),ae(l,s,r),o=!0},p(s,r){const i={};r[0]&10485952|r[1]&8|r[3]&64&&(i.$$scope={dirty:r,ctx:s}),e.$set(i)},i(s){o||(P(e.$$.fragment,s),P(l.$$.fragment,s),o=!0)},o(s){B(e.$$.fragment,s),B(l.$$.fragment,s),o=!1},d(s){s&&b(t),ue(e,s),ue(l,s)}}}function N0(n){let e,t;return e=new Dm({props:{panOnDrag:n[17]===void 0?!0:n[17],selectionOnDrag:n[18],$$slots:{default:[V0]},$$scope:{ctx:n}}}),e.$on("paneclick",n[95]),e.$on("panecontextmenu",n[96]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&131072&&(s.panOnDrag=l[17]===void 0?!0:l[17]),o[0]&262144&&(s.selectionOnDrag=l[18]),o[0]&10485952|o[1]&8|o[3]&64&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function O0(n){let e,t,l,o,s,r,i,a,u,c,f,h;t=new m0({props:{selectionKey:n[1],deleteKey:n[5],panActivationKey:n[2],multiSelectionKey:n[3],zoomActivationKey:n[4]}}),o=new Sm({props:{initialViewport:n[31],onMoveStart:n[8],onMove:n[9],onMoveEnd:n[10],panOnScrollMode:n[11]===void 0?jn.Free:n[11],preventScrolling:n[12]===void 0?!0:n[12],zoomOnScroll:n[13]===void 0?!0:n[13],zoomOnDoubleClick:n[14]===void 0?!0:n[14],zoomOnPinch:n[15]===void 0?!0:n[15],panOnScroll:n[16]===void 0?!1:n[16],panOnDrag:n[17]===void 0?!0:n[17],paneClickDistance:n[22]===void 0?0:n[22],$$slots:{default:[N0]},$$scope:{ctx:n}}}),r=new S0({props:{proOptions:n[20],position:n[19]}});const d=n[75].default,_=dt(d,n,n[99],null);let v=[{style:n[24]},{class:a=Mt(["svelte-flow",n[25],n[30]])},{"data-testid":"svelte-flow__wrapper"},n[33],{role:"application"}],p={};for(let g=0;gn[98].call(e)),et(e,"svelte-12wlba6",!0)},m(g,y){W(g,e,y),ae(t,e,null),I(e,l),ae(o,e,null),I(e,s),ae(r,e,null),I(e,i),_&&_.m(e,null),n[97](e),u=Xa(e,n[98].bind(e)),c=!0,f||(h=[he(e,"dragover",n[76]),he(e,"drop",n[77])],f=!0)},p(g,y){const k={};y[0]&2&&(k.selectionKey=g[1]),y[0]&32&&(k.deleteKey=g[5]),y[0]&4&&(k.panActivationKey=g[2]),y[0]&8&&(k.multiSelectionKey=g[3]),y[0]&16&&(k.zoomActivationKey=g[4]),t.$set(k);const w={};y[0]&256&&(w.onMoveStart=g[8]),y[0]&512&&(w.onMove=g[9]),y[0]&1024&&(w.onMoveEnd=g[10]),y[0]&2048&&(w.panOnScrollMode=g[11]===void 0?jn.Free:g[11]),y[0]&4096&&(w.preventScrolling=g[12]===void 0?!0:g[12]),y[0]&8192&&(w.zoomOnScroll=g[13]===void 0?!0:g[13]),y[0]&16384&&(w.zoomOnDoubleClick=g[14]===void 0?!0:g[14]),y[0]&32768&&(w.zoomOnPinch=g[15]===void 0?!0:g[15]),y[0]&65536&&(w.panOnScroll=g[16]===void 0?!1:g[16]),y[0]&131072&&(w.panOnDrag=g[17]===void 0?!0:g[17]),y[0]&4194304&&(w.paneClickDistance=g[22]===void 0?0:g[22]),y[0]&10879168|y[1]&8|y[3]&64&&(w.$$scope={dirty:y,ctx:g}),o.$set(w);const N={};y[0]&1048576&&(N.proOptions=g[20]),y[0]&524288&&(N.position=g[19]),r.$set(N),_&&_.p&&(!c||y[3]&64)&&ht(_,d,g,g[99],c?gt(d,g[99],y,null):mt(g[99]),null),Pt(e,p=$t(v,[(!c||y[0]&16777216)&&{style:g[24]},(!c||y[0]&1107296256&&a!==(a=Mt(["svelte-flow",g[25],g[30]])))&&{class:a},{"data-testid":"svelte-flow__wrapper"},y[1]&4&&g[33],{role:"application"}])),et(e,"svelte-12wlba6",!0)},i(g){c||(P(t.$$.fragment,g),P(o.$$.fragment,g),P(r.$$.fragment,g),P(_,g),c=!0)},o(g){B(t.$$.fragment,g),B(o.$$.fragment,g),B(r.$$.fragment,g),B(_,g),c=!1},d(g){g&&b(e),ue(t),ue(o),ue(r),_&&_.d(g),n[97](null),u(),f=!1,At(h)}}}function H0(n,e,t){let l;const o=["id","nodes","edges","fitView","fitViewOptions","minZoom","maxZoom","initialViewport","viewport","nodeTypes","edgeTypes","selectionKey","selectionMode","panActivationKey","multiSelectionKey","zoomActivationKey","nodesDraggable","nodesConnectable","nodeDragThreshold","elementsSelectable","snapGrid","deleteKey","connectionRadius","connectionLineType","connectionMode","connectionLineStyle","connectionLineContainerStyle","onMoveStart","onMove","onMoveEnd","isValidConnection","translateExtent","nodeExtent","onlyRenderVisibleElements","panOnScrollMode","preventScrolling","zoomOnScroll","zoomOnDoubleClick","zoomOnPinch","panOnScroll","panOnDrag","selectionOnDrag","autoPanOnConnect","autoPanOnNodeDrag","onerror","ondelete","onedgecreate","attributionPosition","proOptions","defaultEdgeOptions","width","height","colorMode","onconnect","onconnectstart","onconnectend","onbeforedelete","oninit","nodeOrigin","paneClickDistance","nodeClickDistance","defaultMarkerColor","style","class"];let s=_t(e,o),r,i,a=we,u=()=>(a(),a=fs(z,Q=>t(100,i=Q)),z),c,f=we,h=()=>(f(),f=fs(l,Q=>t(30,c=Q)),l);n.$$.on_destroy.push(()=>a()),n.$$.on_destroy.push(()=>f());let{$$slots:d={},$$scope:_}=e;const v=Ka(d);let{id:p="1"}=e,{nodes:g}=e,{edges:y}=e,{fitView:k=void 0}=e,{fitViewOptions:w=void 0}=e,{minZoom:N=void 0}=e,{maxZoom:S=void 0}=e,{initialViewport:A=void 0}=e,{viewport:z=void 0}=e;u();let{nodeTypes:M=void 0}=e,{edgeTypes:V=void 0}=e,{selectionKey:L=void 0}=e,{selectionMode:Y=void 0}=e,{panActivationKey:K=void 0}=e,{multiSelectionKey:E=void 0}=e,{zoomActivationKey:q=void 0}=e,{nodesDraggable:D=void 0}=e,{nodesConnectable:U=void 0}=e,{nodeDragThreshold:F=void 0}=e,{elementsSelectable:C=void 0}=e,{snapGrid:R=void 0}=e,{deleteKey:G=void 0}=e,{connectionRadius:J=void 0}=e,{connectionLineType:oe=void 0}=e,{connectionMode:ee=al.Strict}=e,{connectionLineStyle:j=""}=e,{connectionLineContainerStyle:ge=""}=e,{onMoveStart:x=void 0}=e,{onMove:ye=void 0}=e,{onMoveEnd:ie=void 0}=e,{isValidConnection:Ie=void 0}=e,{translateExtent:Te=void 0}=e,{nodeExtent:Fe=void 0}=e,{onlyRenderVisibleElements:rt=void 0}=e,{panOnScrollMode:de=jn.Free}=e,{preventScrolling:Ge=!0}=e,{zoomOnScroll:Ke=!0}=e,{zoomOnDoubleClick:Vt=!0}=e,{zoomOnPinch:Bt=!0}=e,{panOnScroll:yt=!1}=e,{panOnDrag:Yt=!0}=e,{selectionOnDrag:Nt=void 0}=e,{autoPanOnConnect:Ot=!0}=e,{autoPanOnNodeDrag:Dt=!0}=e,{onerror:Kt=void 0}=e,{ondelete:_e=void 0}=e,{onedgecreate:Ht=void 0}=e,{attributionPosition:wt=void 0}=e,{proOptions:St=void 0}=e,{defaultEdgeOptions:Ce=void 0}=e,{width:Wt=void 0}=e,{height:fe=void 0}=e,{colorMode:Ne="light"}=e,{onconnect:X=void 0}=e,{onconnectstart:me=void 0}=e,{onconnectend:He=void 0}=e,{onbeforedelete:Xe=void 0}=e,{oninit:Ue=void 0}=e,{nodeOrigin:qe=void 0}=e,{paneClickDistance:It=0}=e,{nodeClickDistance:Zt=0}=e,{defaultMarkerColor:Gt="#b1b1b7"}=e,{style:tn=void 0}=e,{class:cn=void 0}=e,vn,mn,yn;const On=i||A,Tt=Nr(Do)?Rt():ym({nodes:le(g),edges:le(y),width:Wt,height:fe,fitView:k,nodeOrigin:qe,nodeExtent:Fe});un(()=>(Tt.width.set(mn),Tt.height.set(yn),Tt.domNode.set(vn),Tt.syncNodeStores(g),Tt.syncEdgeStores(y),Tt.syncViewport(z),k!==void 0&&Tt.fitViewOnInit.set(k),w&&Tt.fitViewOptions.set(w),lr(Tt,{nodeTypes:M,edgeTypes:V,minZoom:N,maxZoom:S,translateExtent:Te,paneClickDistance:It}),()=>{Tt.reset()}));const{initialized:ln}=Tt;se(n,ln,Q=>t(74,r=Q));let fn=!1;function Hn(Q){at.call(this,n,Q)}function Yn(Q){at.call(this,n,Q)}function Jn(Q){at.call(this,n,Q)}function $n(Q){at.call(this,n,Q)}function Dn(Q){at.call(this,n,Q)}function ul(Q){at.call(this,n,Q)}function el(Q){at.call(this,n,Q)}function wn(Q){at.call(this,n,Q)}function Ln(Q){at.call(this,n,Q)}function Xn(Q){at.call(this,n,Q)}function Z(Q){at.call(this,n,Q)}function ve(Q){at.call(this,n,Q)}function pe(Q){at.call(this,n,Q)}function be(Q){at.call(this,n,Q)}function Me(Q){at.call(this,n,Q)}function $(Q){at.call(this,n,Q)}function We(Q){at.call(this,n,Q)}function Re(Q){at.call(this,n,Q)}function ft(Q){at.call(this,n,Q)}function st(Q){at.call(this,n,Q)}function Et(Q){at.call(this,n,Q)}function it(Q){Be[Q?"unshift":"push"](()=>{vn=Q,t(28,vn)})}function Ct(){mn=this.clientWidth,yn=this.clientHeight,t(26,mn),t(27,yn)}return n.$$set=Q=>{e=Qe(Qe({},e),nn(Q)),t(33,s=_t(e,o)),"id"in Q&&t(35,p=Q.id),"nodes"in Q&&t(36,g=Q.nodes),"edges"in Q&&t(37,y=Q.edges),"fitView"in Q&&t(38,k=Q.fitView),"fitViewOptions"in Q&&t(39,w=Q.fitViewOptions),"minZoom"in Q&&t(40,N=Q.minZoom),"maxZoom"in Q&&t(41,S=Q.maxZoom),"initialViewport"in Q&&t(42,A=Q.initialViewport),"viewport"in Q&&u(t(0,z=Q.viewport)),"nodeTypes"in Q&&t(43,M=Q.nodeTypes),"edgeTypes"in Q&&t(44,V=Q.edgeTypes),"selectionKey"in Q&&t(1,L=Q.selectionKey),"selectionMode"in Q&&t(45,Y=Q.selectionMode),"panActivationKey"in Q&&t(2,K=Q.panActivationKey),"multiSelectionKey"in Q&&t(3,E=Q.multiSelectionKey),"zoomActivationKey"in Q&&t(4,q=Q.zoomActivationKey),"nodesDraggable"in Q&&t(46,D=Q.nodesDraggable),"nodesConnectable"in Q&&t(47,U=Q.nodesConnectable),"nodeDragThreshold"in Q&&t(48,F=Q.nodeDragThreshold),"elementsSelectable"in Q&&t(49,C=Q.elementsSelectable),"snapGrid"in Q&&t(50,R=Q.snapGrid),"deleteKey"in Q&&t(5,G=Q.deleteKey),"connectionRadius"in Q&&t(51,J=Q.connectionRadius),"connectionLineType"in Q&&t(52,oe=Q.connectionLineType),"connectionMode"in Q&&t(53,ee=Q.connectionMode),"connectionLineStyle"in Q&&t(6,j=Q.connectionLineStyle),"connectionLineContainerStyle"in Q&&t(7,ge=Q.connectionLineContainerStyle),"onMoveStart"in Q&&t(8,x=Q.onMoveStart),"onMove"in Q&&t(9,ye=Q.onMove),"onMoveEnd"in Q&&t(10,ie=Q.onMoveEnd),"isValidConnection"in Q&&t(54,Ie=Q.isValidConnection),"translateExtent"in Q&&t(55,Te=Q.translateExtent),"nodeExtent"in Q&&t(56,Fe=Q.nodeExtent),"onlyRenderVisibleElements"in Q&&t(57,rt=Q.onlyRenderVisibleElements),"panOnScrollMode"in Q&&t(11,de=Q.panOnScrollMode),"preventScrolling"in Q&&t(12,Ge=Q.preventScrolling),"zoomOnScroll"in Q&&t(13,Ke=Q.zoomOnScroll),"zoomOnDoubleClick"in Q&&t(14,Vt=Q.zoomOnDoubleClick),"zoomOnPinch"in Q&&t(15,Bt=Q.zoomOnPinch),"panOnScroll"in Q&&t(16,yt=Q.panOnScroll),"panOnDrag"in Q&&t(17,Yt=Q.panOnDrag),"selectionOnDrag"in Q&&t(18,Nt=Q.selectionOnDrag),"autoPanOnConnect"in Q&&t(58,Ot=Q.autoPanOnConnect),"autoPanOnNodeDrag"in Q&&t(59,Dt=Q.autoPanOnNodeDrag),"onerror"in Q&&t(60,Kt=Q.onerror),"ondelete"in Q&&t(61,_e=Q.ondelete),"onedgecreate"in Q&&t(62,Ht=Q.onedgecreate),"attributionPosition"in Q&&t(19,wt=Q.attributionPosition),"proOptions"in Q&&t(20,St=Q.proOptions),"defaultEdgeOptions"in Q&&t(21,Ce=Q.defaultEdgeOptions),"width"in Q&&t(63,Wt=Q.width),"height"in Q&&t(64,fe=Q.height),"colorMode"in Q&&t(65,Ne=Q.colorMode),"onconnect"in Q&&t(66,X=Q.onconnect),"onconnectstart"in Q&&t(67,me=Q.onconnectstart),"onconnectend"in Q&&t(68,He=Q.onconnectend),"onbeforedelete"in Q&&t(69,Xe=Q.onbeforedelete),"oninit"in Q&&t(70,Ue=Q.oninit),"nodeOrigin"in Q&&t(71,qe=Q.nodeOrigin),"paneClickDistance"in Q&&t(22,It=Q.paneClickDistance),"nodeClickDistance"in Q&&t(23,Zt=Q.nodeClickDistance),"defaultMarkerColor"in Q&&t(72,Gt=Q.defaultMarkerColor),"style"in Q&&t(24,tn=Q.style),"class"in Q&&t(25,cn=Q.class),"$$scope"in Q&&t(99,_=Q.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&201326592&&mn!==void 0&&yn!==void 0&&(Tt.width.set(mn),Tt.height.set(yn)),n.$$.dirty[2]&6400&&!fn&&r&&(Ue==null||Ue(),t(73,fn=!0)),n.$$.dirty[1]&2097135632|n.$$.dirty[2]&1777&&C0(Tt,{flowId:p,connectionLineType:oe,connectionRadius:J,selectionMode:Y,snapGrid:R,defaultMarkerColor:Gt,nodesDraggable:D,nodesConnectable:U,elementsSelectable:C,onlyRenderVisibleElements:rt,isValidConnection:Ie,autoPanOnConnect:Ot,autoPanOnNodeDrag:Dt,onerror:Kt,ondelete:_e,onedgecreate:Ht,connectionMode:ee,nodeDragThreshold:F,onconnect:X,onconnectstart:me,onconnectend:He,onbeforedelete:Xe,nodeOrigin:qe}),n.$$.dirty[0]&4194304|n.$$.dirty[1]&16791040&&lr(Tt,{nodeTypes:M,edgeTypes:V,minZoom:N,maxZoom:S,translateExtent:Te,paneClickDistance:It}),n.$$.dirty[2]&8&&h(t(29,l=z0(Ne)))},[z,L,K,E,q,G,j,ge,x,ye,ie,de,Ge,Ke,Vt,Bt,yt,Yt,Nt,wt,St,Ce,It,Zt,tn,cn,mn,yn,vn,l,c,On,ln,s,v,p,g,y,k,w,N,S,A,M,V,Y,D,U,F,C,R,J,oe,ee,Ie,Te,Fe,rt,Ot,Dt,Kt,_e,Ht,Wt,fe,Ne,X,me,He,Xe,Ue,qe,Gt,fn,r,d,Hn,Yn,Jn,$n,Dn,ul,el,wn,Ln,Xn,Z,ve,pe,be,Me,$,We,Re,ft,st,Et,it,Ct,_]}class L0 extends ke{constructor(e){super(),Ee(this,e,H0,O0,Se,{id:35,nodes:36,edges:37,fitView:38,fitViewOptions:39,minZoom:40,maxZoom:41,initialViewport:42,viewport:0,nodeTypes:43,edgeTypes:44,selectionKey:1,selectionMode:45,panActivationKey:2,multiSelectionKey:3,zoomActivationKey:4,nodesDraggable:46,nodesConnectable:47,nodeDragThreshold:48,elementsSelectable:49,snapGrid:50,deleteKey:5,connectionRadius:51,connectionLineType:52,connectionMode:53,connectionLineStyle:6,connectionLineContainerStyle:7,onMoveStart:8,onMove:9,onMoveEnd:10,isValidConnection:54,translateExtent:55,nodeExtent:56,onlyRenderVisibleElements:57,panOnScrollMode:11,preventScrolling:12,zoomOnScroll:13,zoomOnDoubleClick:14,zoomOnPinch:15,panOnScroll:16,panOnDrag:17,selectionOnDrag:18,autoPanOnConnect:58,autoPanOnNodeDrag:59,onerror:60,ondelete:61,onedgecreate:62,attributionPosition:19,proOptions:20,defaultEdgeOptions:21,width:63,height:64,colorMode:65,onconnect:66,onconnectstart:67,onconnectend:68,onbeforedelete:69,oninit:70,nodeOrigin:71,paneClickDistance:22,nodeClickDistance:23,defaultMarkerColor:72,style:24,class:25},null,[-1,-1,-1,-1])}}function A0(n){let e;const t=n[7].default,l=dt(t,n,n[6],null);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,[s]){l&&l.p&&(!e||s&64)&&ht(l,t,o,o[6],e?gt(t,o[6],s,null):mt(o[6]),null)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function B0(n,e,t){let{$$slots:l={},$$scope:o}=e,{initialNodes:s=void 0}=e,{initialEdges:r=void 0}=e,{initialWidth:i=void 0}=e,{initialHeight:a=void 0}=e,{fitView:u=void 0}=e,{nodeOrigin:c=void 0}=e;const f=Aa({nodes:s,edges:r,width:i,height:a,nodeOrigin:c,fitView:u});return pl(Do,{getStore:()=>f}),qn(()=>{f.reset()}),n.$$set=h=>{"initialNodes"in h&&t(0,s=h.initialNodes),"initialEdges"in h&&t(1,r=h.initialEdges),"initialWidth"in h&&t(2,i=h.initialWidth),"initialHeight"in h&&t(3,a=h.initialHeight),"fitView"in h&&t(4,u=h.fitView),"nodeOrigin"in h&&t(5,c=h.nodeOrigin),"$$scope"in h&&t(6,o=h.$$scope)},[s,r,i,a,u,c,o,l]}class R0 extends ke{constructor(e){super(),Ee(this,e,B0,A0,Se,{initialNodes:0,initialEdges:1,initialWidth:2,initialHeight:3,fitView:4,nodeOrigin:5})}}const U0=n=>({}),sr=n=>({class:"button-svg"});function W0(n){let e,t,l,o,s;const r=n[8].default,i=dt(r,n,n[7],sr);let a=[{type:"button"},{class:t=Mt(["svelte-flow__controls-button",n[0]])},n[6]],u={};for(let c=0;c{e=Qe(Qe({},e),nn(_)),t(6,o=_t(e,l)),"class"in _&&t(0,i=_.class),"$$scope"in _&&t(7,r=_.$$scope)},[i,a,u,c,f,h,o,r,s,d]}class bo extends ke{constructor(e){super(),Ee(this,e,F0,W0,Se,{class:0})}}function j0(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0});var o=T(e);t=Ve(o,"path",{d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"d","M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 32 32")},m(l,o){W(l,e,o),I(e,t)},p:we,i:we,o:we,d(l){l&&b(e)}}}class Y0 extends ke{constructor(e){super(),Ee(this,e,null,j0,Se,{})}}function X0(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0});var o=T(e);t=Ve(o,"path",{d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"d","M0 0h32v4.2H0z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 32 5")},m(l,o){W(l,e,o),I(e,t)},p:we,i:we,o:we,d(l){l&&b(e)}}}class K0 extends ke{constructor(e){super(),Ee(this,e,null,X0,Se,{})}}function Z0(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0});var o=T(e);t=Ve(o,"path",{d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"d","M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 32 30")},m(l,o){W(l,e,o),I(e,t)},p:we,i:we,o:we,d(l){l&&b(e)}}}class G0 extends ke{constructor(e){super(),Ee(this,e,null,Z0,Se,{})}}function q0(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0});var o=T(e);t=Ve(o,"path",{d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"d","M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 25 32")},m(l,o){W(l,e,o),I(e,t)},p:we,i:we,o:we,d(l){l&&b(e)}}}class J0 extends ke{constructor(e){super(),Ee(this,e,null,q0,Se,{})}}function Q0(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,viewBox:!0});var o=T(e);t=Ve(o,"path",{d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"d","M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"viewBox","0 0 25 32")},m(l,o){W(l,e,o),I(e,t)},p:we,i:we,o:we,d(l){l&&b(e)}}}class x0 extends ke{constructor(e){super(),Ee(this,e,null,Q0,Se,{})}}const $0=n=>({}),ir=n=>({}),eg=n=>({}),rr=n=>({});function ar(n){let e,t,l,o;const s=[{class:"svelte-flow__controls-zoomin"},{title:"zoom in"},{"aria-label":"zoom in"},{disabled:n[9]},n[17]];let r={$$slots:{default:[tg]},$$scope:{ctx:n}};for(let u=0;u{r[c]=null}),Ye(),t=r[e],t||(t=r[e]=s[e](a),t.c()),P(t,1),t.m(l.parentNode,l))},i(a){o||(P(t),o=!0)},o(a){B(t),o=!1},d(a){a&&b(l),r[e].d(a)}}}function rg(n){let e,t,l,o,s,r;const i=n[35].before,a=dt(i,n,n[36],rr);let u=n[1]&&ar(n),c=n[2]&&ur(n),f=n[3]&&cr(n);const h=n[35].default,d=dt(h,n,n[36],null),_=n[35].after,v=dt(_,n,n[36],ir);return{c(){a&&a.c(),e=te(),u&&u.c(),t=te(),c&&c.c(),l=te(),f&&f.c(),o=te(),d&&d.c(),s=te(),v&&v.c()},l(p){a&&a.l(p),e=ne(p),u&&u.l(p),t=ne(p),c&&c.l(p),l=ne(p),f&&f.l(p),o=ne(p),d&&d.l(p),s=ne(p),v&&v.l(p)},m(p,g){a&&a.m(p,g),W(p,e,g),u&&u.m(p,g),W(p,t,g),c&&c.m(p,g),W(p,l,g),f&&f.m(p,g),W(p,o,g),d&&d.m(p,g),W(p,s,g),v&&v.m(p,g),r=!0},p(p,g){a&&a.p&&(!r||g[1]&32)&&ht(a,i,p,p[36],r?gt(i,p[36],g,eg):mt(p[36]),rr),p[1]?u?(u.p(p,g),g[0]&2&&P(u,1)):(u=ar(p),u.c(),P(u,1),u.m(t.parentNode,t)):u&&(je(),B(u,1,1,()=>{u=null}),Ye()),p[2]?c?(c.p(p,g),g[0]&4&&P(c,1)):(c=ur(p),c.c(),P(c,1),c.m(l.parentNode,l)):c&&(je(),B(c,1,1,()=>{c=null}),Ye()),p[3]?f?(f.p(p,g),g[0]&8&&P(f,1)):(f=cr(p),f.c(),P(f,1),f.m(o.parentNode,o)):f&&(je(),B(f,1,1,()=>{f=null}),Ye()),d&&d.p&&(!r||g[1]&32)&&ht(d,h,p,p[36],r?gt(h,p[36],g,null):mt(p[36]),null),v&&v.p&&(!r||g[1]&32)&&ht(v,_,p,p[36],r?gt(_,p[36],g,$0):mt(p[36]),ir)},i(p){r||(P(a,p),P(u),P(c),P(f),P(d,p),P(v,p),r=!0)},o(p){B(a,p),B(u),B(c),B(f),B(d,p),B(v,p),r=!1},d(p){p&&(b(e),b(t),b(l),b(o),b(s)),a&&a.d(p),u&&u.d(p),c&&c.d(p),f&&f.d(p),d&&d.d(p),v&&v.d(p)}}}function ag(n){let e,t;return e=new Wa({props:{class:Mt(["svelte-flow__controls",n[7],n[6]]),position:n[0],"data-testid":"svelte-flow__controls","aria-label":n[4]??"Svelte Flow controls",style:n[5],$$slots:{default:[rg]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&192&&(s.class=Mt(["svelte-flow__controls",l[7],l[6]])),o[0]&1&&(s.position=l[0]),o[0]&16&&(s["aria-label"]=l[4]??"Svelte Flow controls"),o[0]&32&&(s.style=l[5]),o[0]&1806|o[1]&32&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function ug(n,e,t){let l,o,s,r,i,a,u,c,f,h,{$$slots:d={},$$scope:_}=e,{position:v="bottom-left"}=e,{showZoom:p=!0}=e,{showFitView:g=!0}=e,{showLock:y=!0}=e,{buttonBgColor:k=void 0}=e,{buttonBgColorHover:w=void 0}=e,{buttonColor:N=void 0}=e,{buttonColorHover:S=void 0}=e,{buttonBorderColor:A=void 0}=e,{ariaLabel:z=void 0}=e,{style:M=void 0}=e,{orientation:V="vertical"}=e,{fitViewOptions:L=void 0}=e,{class:Y=""}=e;const{zoomIn:K,zoomOut:E,fitView:q,viewport:D,minZoom:U,maxZoom:F,nodesDraggable:C,nodesConnectable:R,elementsSelectable:G}=Rt();se(n,D,x=>t(30,a=x)),se(n,U,x=>t(31,u=x)),se(n,F,x=>t(29,i=x)),se(n,C,x=>t(34,h=x)),se(n,R,x=>t(33,f=x)),se(n,G,x=>t(32,c=x));const J={bgColor:k,bgColorHover:w,color:N,colorHover:S,borderColor:A},oe=()=>{K()},ee=()=>{E()},j=()=>{q(L)},ge=()=>{t(8,l=!l),C.set(l),R.set(l),G.set(l)};return n.$$set=x=>{"position"in x&&t(0,v=x.position),"showZoom"in x&&t(1,p=x.showZoom),"showFitView"in x&&t(2,g=x.showFitView),"showLock"in x&&t(3,y=x.showLock),"buttonBgColor"in x&&t(22,k=x.buttonBgColor),"buttonBgColorHover"in x&&t(23,w=x.buttonBgColorHover),"buttonColor"in x&&t(24,N=x.buttonColor),"buttonColorHover"in x&&t(25,S=x.buttonColorHover),"buttonBorderColor"in x&&t(26,A=x.buttonBorderColor),"ariaLabel"in x&&t(4,z=x.ariaLabel),"style"in x&&t(5,M=x.style),"orientation"in x&&t(27,V=x.orientation),"fitViewOptions"in x&&t(28,L=x.fitViewOptions),"class"in x&&t(6,Y=x.class),"$$scope"in x&&t(36,_=x.$$scope)},n.$$.update=()=>{n.$$.dirty[1]&14&&t(8,l=h||f||c),n.$$.dirty[0]&1073741824|n.$$.dirty[1]&1&&t(10,o=a.zoom<=u),n.$$.dirty[0]&1610612736&&t(9,s=a.zoom>=i),n.$$.dirty[0]&134217728&&t(7,r=V==="horizontal"?"horizontal":"vertical")},[v,p,g,y,z,M,Y,r,l,s,o,D,U,F,C,R,G,J,oe,ee,j,ge,k,w,N,S,A,V,L,i,a,u,c,f,h,d,_]}let cg=class extends ke{constructor(e){super(),Ee(this,e,ug,ag,Se,{position:0,showZoom:1,showFitView:2,showLock:3,buttonBgColor:22,buttonBgColorHover:23,buttonColor:24,buttonColorHover:25,buttonBorderColor:26,ariaLabel:4,style:5,orientation:27,fitViewOptions:28,class:6},null,[-1,-1])}};var Zn;(function(n){n.Lines="lines",n.Dots="dots",n.Cross="cross"})(Zn||(Zn={}));function fg(n){let e,t;return{c(){e=Pe("circle"),this.h()},l(l){e=Ve(l,"circle",{cx:!0,cy:!0,r:!0,class:!0}),T(e).forEach(b),this.h()},h(){m(e,"cx",n[0]),m(e,"cy",n[0]),m(e,"r",n[0]),m(e,"class",t=Mt(["svelte-flow__background-pattern","dots",n[1]]))},m(l,o){W(l,e,o)},p(l,[o]){o&1&&m(e,"cx",l[0]),o&1&&m(e,"cy",l[0]),o&1&&m(e,"r",l[0]),o&2&&t!==(t=Mt(["svelte-flow__background-pattern","dots",l[1]]))&&m(e,"class",t)},i:we,o:we,d(l){l&&b(e)}}}function dg(n,e,t){let{radius:l=5}=e,{class:o=""}=e;return n.$$set=s=>{"radius"in s&&t(0,l=s.radius),"class"in s&&t(1,o=s.class)},[l,o]}class hg extends ke{constructor(e){super(),Ee(this,e,dg,fg,Se,{radius:0,class:1})}}function mg(n){let e,t,l;return{c(){e=Pe("path"),this.h()},l(o){e=Ve(o,"path",{"stroke-width":!0,d:!0,class:!0}),T(e).forEach(b),this.h()},h(){m(e,"stroke-width",n[0]),m(e,"d",t=`M${n[1][0]/2} 0 V${n[1][1]} M0 ${n[1][1]/2} H${n[1][0]}`),m(e,"class",l=Mt(["svelte-flow__background-pattern",n[2],n[3]]))},m(o,s){W(o,e,s)},p(o,[s]){s&1&&m(e,"stroke-width",o[0]),s&2&&t!==(t=`M${o[1][0]/2} 0 V${o[1][1]} M0 ${o[1][1]/2} H${o[1][0]}`)&&m(e,"d",t),s&12&&l!==(l=Mt(["svelte-flow__background-pattern",o[2],o[3]]))&&m(e,"class",l)},i:we,o:we,d(o){o&&b(e)}}}function gg(n,e,t){let{lineWidth:l=1}=e,{dimensions:o}=e,{variant:s=void 0}=e,{class:r=""}=e;return n.$$set=i=>{"lineWidth"in i&&t(0,l=i.lineWidth),"dimensions"in i&&t(1,o=i.dimensions),"variant"in i&&t(2,s=i.variant),"class"in i&&t(3,r=i.class)},[l,o,s,r]}class _g extends ke{constructor(e){super(),Ee(this,e,gg,mg,Se,{lineWidth:0,dimensions:1,variant:2,class:3})}}function bg(n){let e,t;return e=new _g({props:{dimensions:n[6],variant:n[0],lineWidth:n[1],class:n[4]}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&64&&(s.dimensions=l[6]),o&1&&(s.variant=l[0]),o&2&&(s.lineWidth=l[1]),o&16&&(s.class=l[4]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function pg(n){let e,t;return e=new hg({props:{radius:n[7]/2,class:n[4]}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&128&&(s.radius=l[7]/2),o&16&&(s.class=l[4]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function vg(n){let e,t,l,o,s,r,i,a,u,c,f,h,d;const _=[pg,bg],v=[];function p(g,y){return g[14]?0:1}return l=p(n),o=v[l]=_[l](n),{c(){e=Pe("svg"),t=Pe("pattern"),o.c(),c=Pe("rect"),this.h()},l(g){e=Ve(g,"svg",{class:!0,"data-testid":!0});var y=T(e);t=Ve(y,"pattern",{id:!0,x:!0,y:!0,width:!0,height:!0,patternUnits:!0,patternTransform:!0});var k=T(t);o.l(k),k.forEach(b),c=Ve(y,"rect",{x:!0,y:!0,width:!0,height:!0,fill:!0}),T(c).forEach(b),y.forEach(b),this.h()},h(){m(t,"id",n[11]),m(t,"x",s=n[9].x%n[8][0]),m(t,"y",r=n[9].y%n[8][1]),m(t,"width",i=n[8][0]),m(t,"height",a=n[8][1]),m(t,"patternUnits","userSpaceOnUse"),m(t,"patternTransform",u=`translate(-${n[10][0]},-${n[10][1]})`),m(c,"x","0"),m(c,"y","0"),m(c,"width","100%"),m(c,"height","100%"),m(c,"fill",f=`url(#${n[11]})`),m(e,"class",h=ds(Mt(["svelte-flow__background",n[5]]))+" svelte-1r7pe8d"),m(e,"data-testid","svelte-flow__background"),Ze(e,"--xy-background-color-props",n[2]),Ze(e,"--xy-background-pattern-color-props",n[3])},m(g,y){W(g,e,y),I(e,t),v[l].m(t,null),I(e,c),d=!0},p(g,[y]){o.p(g,y),(!d||y&2048)&&m(t,"id",g[11]),(!d||y&768&&s!==(s=g[9].x%g[8][0]))&&m(t,"x",s),(!d||y&768&&r!==(r=g[9].y%g[8][1]))&&m(t,"y",r),(!d||y&256&&i!==(i=g[8][0]))&&m(t,"width",i),(!d||y&256&&a!==(a=g[8][1]))&&m(t,"height",a),(!d||y&1024&&u!==(u=`translate(-${g[10][0]},-${g[10][1]})`))&&m(t,"patternTransform",u),(!d||y&2048&&f!==(f=`url(#${g[11]})`))&&m(c,"fill",f),(!d||y&32&&h!==(h=ds(Mt(["svelte-flow__background",g[5]]))+" svelte-1r7pe8d"))&&m(e,"class",h),y&4&&Ze(e,"--xy-background-color-props",g[2]),y&8&&Ze(e,"--xy-background-pattern-color-props",g[3])},i(g){d||(P(o),d=!0)},o(g){B(o),d=!1},d(g){g&&b(e),v[l].d()}}}const yg={[Zn.Dots]:1,[Zn.Lines]:1,[Zn.Cross]:6};function wg(n,e,t){let l,o,s,r,i,a,u,{id:c=void 0}=e,{variant:f=Zn.Dots}=e,{gap:h=20}=e,{size:d=1}=e,{lineWidth:_=1}=e,{bgColor:v=void 0}=e,{patternColor:p=void 0}=e,{patternClass:g=void 0}=e,{class:y=""}=e;const{viewport:k,flowId:w}=Rt();se(n,k,M=>t(9,a=M)),se(n,w,M=>t(18,u=M));const N=d||yg[f],S=f===Zn.Dots,A=f===Zn.Cross,z=Array.isArray(h)?h:[h,h];return n.$$set=M=>{"id"in M&&t(15,c=M.id),"variant"in M&&t(0,f=M.variant),"gap"in M&&t(16,h=M.gap),"size"in M&&t(17,d=M.size),"lineWidth"in M&&t(1,_=M.lineWidth),"bgColor"in M&&t(2,v=M.bgColor),"patternColor"in M&&t(3,p=M.patternColor),"patternClass"in M&&t(4,g=M.patternClass),"class"in M&&t(5,y=M.class)},n.$$.update=()=>{n.$$.dirty&294912&&t(11,l=`background-pattern-${u}-${c||""}`),n.$$.dirty&512&&t(8,o=[z[0]*a.zoom||1,z[1]*a.zoom||1]),n.$$.dirty&512&&t(7,s=N*a.zoom),n.$$.dirty&384&&t(6,r=A?[s,s]:o),n.$$.dirty&192&&t(10,i=S?[s/2,s/2]:[r[0]/2,r[1]/2])},[f,_,v,p,g,y,r,s,o,a,i,l,k,w,S,c,h,d,u]}class kg extends ke{constructor(e){super(),Ee(this,e,wg,vg,Se,{id:15,variant:0,gap:16,size:17,lineWidth:1,bgColor:2,patternColor:3,patternClass:4,class:5})}}const fr=n=>Fh(n);function Eg(){const{zoomIn:n,zoomOut:e,fitView:t,onbeforedelete:l,snapGrid:o,viewport:s,width:r,height:i,minZoom:a,maxZoom:u,panZoom:c,nodes:f,edges:h,domNode:d,nodeLookup:_,nodeOrigin:v,edgeLookup:p,connectionLookup:g}=Rt(),y=N=>{var V,L;const S=le(_),A=fr(N)?N:S.get(N.id),z=A.parentId?Zh(A.position,A.measured,A.parentId,S,le(v)):A.position,M={id:A.id,position:z,width:((V=A.measured)==null?void 0:V.width)??A.width,height:((L=A.measured)==null?void 0:L.height)??A.height,data:A.data};return wl(M)},k=(N,S,A={replace:!1})=>{var V;const z=(V=le(_).get(N))==null?void 0:V.internals.userNode;if(!z)return;const M=typeof S=="function"?S(z):S;A.replace?f.update(L=>L.map(Y=>Y.id===N?fr(M)?M:{...Y,...M}:Y)):(Object.assign(z,M),f.update(L=>L))},w=N=>le(_).get(N);return{zoomIn:n,zoomOut:e,getInternalNode:w,getNode:N=>{var S;return(S=w(N))==null?void 0:S.internals.userNode},getNodes:N=>N===void 0?le(f):dr(le(_),N),getEdge:N=>le(p).get(N),getEdges:N=>N===void 0?le(h):dr(le(p),N),setZoom:(N,S)=>{const A=le(c);return A?A.scaleTo(N,{duration:S==null?void 0:S.duration}):Promise.resolve(!1)},getZoom:()=>le(s).zoom,setViewport:async(N,S)=>{const A=le(s),z=le(c);return z?(await z.setViewport({x:N.x??A.x,y:N.y??A.y,zoom:N.zoom??A.zoom},{duration:S==null?void 0:S.duration}),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>le(s),setCenter:async(N,S,A)=>{const z=typeof(A==null?void 0:A.zoom)<"u"?A.zoom:le(u),M=le(c);return M?(await M.setViewport({x:le(r)/2-N*z,y:le(i)/2-S*z,zoom:z},{duration:A==null?void 0:A.duration}),Promise.resolve(!0)):Promise.resolve(!1)},fitView:t,fitBounds:async(N,S)=>{const A=le(c);if(!A)return Promise.resolve(!1);const z=rs(N,le(r),le(i),le(a),le(u),(S==null?void 0:S.padding)??.1);return await A.setViewport(z,{duration:S==null?void 0:S.duration}),Promise.resolve(!0)},getIntersectingNodes:(N,S=!0,A)=>{const z=zi(N),M=z?N:y(N);return M?(A||le(f)).filter(V=>{const L=le(_).get(V.id);if(!L||!z&&V.id===N.id)return!1;const Y=wl(L),K=Bl(Y,M);return S&&K>0||K>=M.width*M.height}):[]},isNodeIntersecting:(N,S,A=!0)=>{const M=zi(N)?N:y(N);if(!M)return!1;const V=Bl(M,S);return A&&V>0||V>=M.width*M.height},deleteElements:async({nodes:N=[],edges:S=[]})=>{const{nodes:A,edges:z}=await ca({nodesToRemove:N,edgesToRemove:S,nodes:le(f),edges:le(h),onBeforeDelete:le(l)});return A&&f.update(M=>M.filter(V=>!A.some(({id:L})=>L===V.id))),z&&h.update(M=>M.filter(V=>!z.some(({id:L})=>L===V.id))),{deletedNodes:A,deletedEdges:z}},screenToFlowPosition:(N,S={snapToGrid:!0})=>{const A=le(d);if(!A)return N;const z=S.snapToGrid?le(o):!1,{x:M,y:V,zoom:L}=le(s),{x:Y,y:K}=A.getBoundingClientRect(),E={x:N.x-Y,y:N.y-K};return Xl(E,[M,V,L],z!==null,z||[1,1])},flowToScreenPosition:N=>{const S=le(d);if(!S)return N;const{x:A,y:z,zoom:M}=le(s),{x:V,y:L}=S.getBoundingClientRect(),Y=ha(N,[A,z,M]);return{x:Y.x+V,y:Y.y+L}},toObject:()=>({nodes:le(f).map(N=>({...N,position:{...N.position},data:{...N.data}})),edges:le(h).map(N=>({...N})),viewport:{...le(s)}}),updateNode:k,updateNodeData:(N,S,A)=>{var V;const z=(V=le(_).get(N))==null?void 0:V.internals.userNode;if(!z)return;const M=typeof S=="function"?S(z):S;z.data=A!=null&&A.replace?M:{...z.data,...M},f.update(L=>L)},getNodesBounds:N=>{const S=le(_),A=le(v);return jh(N,{nodeLookup:S,nodeOrigin:A})},getHandleConnections:({type:N,id:S,nodeId:A})=>{var z;return Array.from(((z=le(g).get(`${A}-${N}-${S??null}`))==null?void 0:z.values())??[])},viewport:s}}function dr(n,e){var l;const t=[];for(const o of e){const s=n.get(o);if(s){const r="internals"in s?(l=s.internals)==null?void 0:l.userNode:s;t.push(r)}}return t}function Sg(){const{nodesInitialized:n}=Rt();return{subscribe:n.subscribe}}function hr(n,e,t){const l=n.slice();return l[23]=e[t],l[25]=t,l}function mr(n,e,t){const l=n.slice();return l[20]=e[t],l[22]=t,l}function Ig(n){let e,t=n[5].t("Select a function")+"",l,o,s=pt(n[7]),r=[];for(let i=0;i{a[h]=null}),Ye(),s=a[o],s?s.p(c,f):(s=a[o]=i[o](c),s.c()),P(s,1),s.m(l,null))},i(c){r||(P(s),r=!0)},o(c){B(s),r=!1},d(c){c&&(b(e),b(t),b(l)),a[o].d()}}}function Dg(n){let e,t;return e=new sc({props:{className:"size-5"}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p:we,i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function zg(n){let e,t,l;function o(r){n[15](r)}let s={valvesSpec:n[3]};return n[4]!==void 0&&(s.valves=n[4]),e=new ic({props:s}),Be.push(()=>lt(e,"valves",o)),e.$on("change",n[16]),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),l=!0},p(r,i){const a={};i&8&&(a.valvesSpec=r[3]),!t&&i&16&&(t=!0,a.valves=r[4],nt(()=>t=!1)),e.$set(a)},i(r){l||(P(e.$$.fragment,r),l=!0)},o(r){B(e.$$.fragment,r),l=!1},d(r){ue(e,r)}}}function Mg(n){let e,t,l,o,s,r,i,a=n[5].t("Tools")+"",u,c,f=n[5].t("Functions")+"",h,d,_,v,p,g,y,k;function w(z,M){if(z[0]==="tools")return Cg;if(z[0]==="functions")return Ig}let N=w(n),S=N&&N(n),A=n[1]&&br(n);return{c(){e=O("form"),t=O("div"),l=O("div"),o=O("div"),s=O("div"),r=O("select"),i=O("option"),u=De(a),c=O("option"),h=De(f),d=te(),_=O("div"),v=O("select"),S&&S.c(),p=te(),A&&A.c(),this.h()},l(z){e=H(z,"FORM",{class:!0});var M=T(e);t=H(M,"DIV",{class:!0});var V=T(t);l=H(V,"DIV",{class:!0});var L=T(l);o=H(L,"DIV",{class:!0});var Y=T(o);s=H(Y,"DIV",{class:!0});var K=T(s);r=H(K,"SELECT",{class:!0,placeholder:!0});var E=T(r);i=H(E,"OPTION",{class:!0});var q=T(i);u=ze(q,a),q.forEach(b),c=H(E,"OPTION",{class:!0});var D=T(c);h=ze(D,f),D.forEach(b),E.forEach(b),K.forEach(b),d=ne(Y),_=H(Y,"DIV",{class:!0});var U=T(_);v=H(U,"SELECT",{class:!0});var F=T(v);S&&S.l(F),F.forEach(b),U.forEach(b),Y.forEach(b),L.forEach(b),p=ne(V),A&&A.l(V),V.forEach(b),M.forEach(b),this.h()},h(){i.__value="tools",In(i,i.__value),m(i,"class","bg-gray-100 dark:bg-gray-800"),c.__value="functions",In(c,c.__value),m(c,"class","bg-gray-100 dark:bg-gray-800"),m(r,"class","w-full rounded text-xs py-2 px-1 bg-transparent outline-none"),m(r,"placeholder","Select"),n[0]===void 0&&xn(()=>n[12].call(r)),m(s,"class","flex-1"),m(v,"class","w-full rounded py-2 px-1 text-xs bg-transparent outline-none"),n[1]===void 0&&xn(()=>n[13].call(v)),m(_,"class","flex-1"),m(o,"class","flex gap-2"),m(l,"class","space-y-1"),m(t,"class","flex flex-col"),m(e,"class","flex flex-col h-full justify-between space-y-3 text-sm")},m(z,M){W(z,e,M),I(e,t),I(t,l),I(l,o),I(o,s),I(s,r),I(r,i),I(i,u),I(r,c),I(c,h),ql(r,n[0],!0),I(o,d),I(o,_),I(_,v),S&&S.m(v,null),ql(v,n[1],!0),I(t,p),A&&A.m(t,null),g=!0,y||(k=[he(r,"change",n[12]),he(v,"change",n[13]),he(v,"change",n[14]),he(e,"submit",Or(n[17]))],y=!0)},p(z,[M]){(!g||M&32)&&a!==(a=z[5].t("Tools")+"")&&Oe(u,a),(!g||M&32)&&f!==(f=z[5].t("Functions")+"")&&Oe(h,f),M&1&&ql(r,z[0]),N===(N=w(z))&&S?S.p(z,M):(S&&S.d(1),S=N&&N(z),S&&(S.c(),S.m(v,null))),M&194&&ql(v,z[1]),z[1]?A?(A.p(z,M),M&2&&P(A,1)):(A=br(z),A.c(),P(A,1),A.m(t,null)):A&&(je(),B(A,1,1,()=>{A=null}),Ye())},i(z){g||(P(A),g=!0)},o(z){B(A),g=!1},d(z){z&&b(e),S&&S.d(),A&&A.d(),y=!1,At(k)}}}function Tg(n,e,t){let l,o,s;se(n,Wr,A=>t(6,o=A)),se(n,uu,A=>t(7,s=A));const r=en(),i=Lt("i18n");se(n,i,A=>t(5,l=A));let a="tools",u="",c=!1,f=null,h={},d;const _=async()=>{d&&clearTimeout(d),d=setTimeout(()=>{p()},500)},v=async()=>{var A;if(t(2,c=!0),a==="tools"?(t(4,h=await $u(localStorage.token,u)),t(3,f=await ec(localStorage.token,u))):a==="functions"&&(t(4,h=await nc(localStorage.token,u)),t(3,f=await lc(localStorage.token,u))),f)for(const z in f.properties)((A=f.properties[z])==null?void 0:A.type)==="array"&&t(4,h[z]=(h[z]??[]).join(","),h);t(2,c=!1)},p=async()=>{var A;if(f){for(const z in f.properties)((A=f.properties[z])==null?void 0:A.type)==="array"&&t(4,h[z]=(h[z]??"").split(",").map(M=>M.trim()),h);if(a==="tools"){const z=await tc(localStorage.token,u,h).catch(M=>($e.error(M),null));z&&($e.success(l.t("Valves updated")),t(4,h=z))}else if(a==="functions"){const z=await oc(localStorage.token,u,h).catch(M=>($e.error(M),null));z&&($e.success(l.t("Valves updated")),t(4,h=z))}}};function g(){a=hs(this),t(0,a)}function y(){u=hs(this),t(1,u),t(0,a)}const k=async()=>{await Je()};function w(A){h=A,t(4,h)}const N=()=>{_()},S=()=>{p(),r("save")};return n.$$.update=()=>{n.$$.dirty&1&&a&&t(1,u=""),n.$$.dirty&2&&u&&v()},[a,u,c,f,h,l,o,s,r,i,_,p,g,y,k,w,N,S]}class Pg extends ke{constructor(e){super(),Ee(this,e,Tg,Mg,Se,{})}}function pr(n,e,t){const l=n.slice();return l[11]=e[t],l[13]=t,l}function vr(n){let e,t,l,o;return e=new oo({props:{title:n[2].t("Files"),open:!0,$$slots:{content:[Vg]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment),t=te(),l=O("hr"),this.h()},l(s){ce(e.$$.fragment,s),t=ne(s),l=H(s,"HR",{class:!0}),this.h()},h(){m(l,"class","my-2 border-gray-100 dark:border-gray-800")},m(s,r){ae(e,s,r),W(s,t,r),W(s,l,r),o=!0},p(s,r){const i={};r&4&&(i.title=s[2].t("Files")),r&16385&&(i.$$scope={dirty:r,ctx:s}),e.$set(i)},i(s){o||(P(e.$$.fragment,s),o=!0)},o(s){B(e.$$.fragment,s),o=!1},d(s){s&&(b(t),b(l)),ue(e,s)}}}function yr(n){var o,s;let e,t;function l(){return n[8](n[13])}return e=new Rr({props:{className:"w-full",url:`${(o=n[11])==null?void 0:o.url}`,name:n[11].name,type:n[11].type,size:(s=n[11])==null?void 0:s.size,dismissible:!0}}),e.$on("dismiss",l),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),t=!0},p(r,i){var u,c;n=r;const a={};i&1&&(a.url=`${(u=n[11])==null?void 0:u.url}`),i&1&&(a.name=n[11].name),i&1&&(a.type=n[11].type),i&1&&(a.size=(c=n[11])==null?void 0:c.size),e.$set(a)},i(r){t||(P(e.$$.fragment,r),t=!0)},o(r){B(e.$$.fragment,r),t=!1},d(r){ue(e,r)}}}function Vg(n){let e,t,l=pt(n[0]),o=[];for(let r=0;rB(o[r],1,1,()=>{o[r]=null});return{c(){e=O("div");for(let r=0;rlt(l,"params",r)),{c(){e=O("div"),t=O("div"),re(l.$$.fragment),this.h()},l(u){e=H(u,"DIV",{class:!0,slot:!0});var c=T(e);t=H(c,"DIV",{});var f=T(t);ce(l.$$.fragment,f),f.forEach(b),c.forEach(b),this.h()},h(){m(e,"class","text-sm mt-1.5"),m(e,"slot","content")},m(u,c){W(u,e,c),I(e,t),ae(l,t,null),s=!0},p(u,c){var h;const f={};c&8&&(f.admin=((h=u[3])==null?void 0:h.role)==="admin"),!o&&c&2&&(o=!0,f.params=u[1],nt(()=>o=!1)),l.$set(f)},i(u){s||(P(l.$$.fragment,u),s=!0)},o(u){B(l.$$.fragment,u),s=!1},d(u){u&&b(e),ue(l)}}}function Lg(n){let e,t,l,o=n[2].t("Chat Controls")+"",s,r,i,a,u,c,f,h,d,_,v,p,g,y,k,w,N,S,A;a=new $o({props:{className:"size-4"}});let z=n[0].length>0&&vr(n);return h=new oo({props:{title:n[2].t("Valves"),$$slots:{content:[Ng]},$$scope:{ctx:n}}}),p=new oo({props:{title:n[2].t("System Prompt"),open:!0,$$slots:{content:[Og]},$$scope:{ctx:n}}}),w=new oo({props:{title:n[2].t("Advanced Params"),open:!0,$$slots:{content:[Hg]},$$scope:{ctx:n}}}),{c(){e=O("div"),t=O("div"),l=O("div"),s=De(o),r=te(),i=O("button"),re(a.$$.fragment),u=te(),c=O("div"),z&&z.c(),f=te(),re(h.$$.fragment),d=te(),_=O("hr"),v=te(),re(p.$$.fragment),g=te(),y=O("hr"),k=te(),re(w.$$.fragment),this.h()},l(M){e=H(M,"DIV",{class:!0});var V=T(e);t=H(V,"DIV",{class:!0});var L=T(t);l=H(L,"DIV",{class:!0});var Y=T(l);s=ze(Y,o),Y.forEach(b),r=ne(L),i=H(L,"BUTTON",{class:!0});var K=T(i);ce(a.$$.fragment,K),K.forEach(b),L.forEach(b),u=ne(V),c=H(V,"DIV",{class:!0});var E=T(c);z&&z.l(E),f=ne(E),ce(h.$$.fragment,E),d=ne(E),_=H(E,"HR",{class:!0}),v=ne(E),ce(p.$$.fragment,E),g=ne(E),y=H(E,"HR",{class:!0}),k=ne(E),ce(w.$$.fragment,E),E.forEach(b),V.forEach(b),this.h()},h(){m(l,"class","text-lg font-medium self-center font-primary"),m(i,"class","self-center"),m(t,"class","flex justify-between dark:text-gray-100 mb-2"),m(_,"class","my-2 border-gray-100 dark:border-gray-800"),m(y,"class","my-2 border-gray-100 dark:border-gray-800"),m(c,"class","dark:text-gray-200 text-sm font-primary py-0.5"),m(e,"class","dark:text-white")},m(M,V){W(M,e,V),I(e,t),I(t,l),I(l,s),I(t,r),I(t,i),ae(a,i,null),I(e,u),I(e,c),z&&z.m(c,null),I(c,f),ae(h,c,null),I(c,d),I(c,_),I(c,v),ae(p,c,null),I(c,g),I(c,y),I(c,k),ae(w,c,null),N=!0,S||(A=he(i,"click",n[7]),S=!0)},p(M,[V]){(!N||V&4)&&o!==(o=M[2].t("Chat Controls")+"")&&Oe(s,o),M[0].length>0?z?(z.p(M,V),V&1&&P(z,1)):(z=vr(M),z.c(),P(z,1),z.m(c,f)):z&&(je(),B(z,1,1,()=>{z=null}),Ye());const L={};V&4&&(L.title=M[2].t("Valves")),V&16384&&(L.$$scope={dirty:V,ctx:M}),h.$set(L);const Y={};V&4&&(Y.title=M[2].t("System Prompt")),V&16390&&(Y.$$scope={dirty:V,ctx:M}),p.$set(Y);const K={};V&4&&(K.title=M[2].t("Advanced Params")),V&16394&&(K.$$scope={dirty:V,ctx:M}),w.$set(K)},i(M){N||(P(a.$$.fragment,M),P(z),P(h.$$.fragment,M),P(p.$$.fragment,M),P(w.$$.fragment,M),N=!0)},o(M){B(a.$$.fragment,M),B(z),B(h.$$.fragment,M),B(p.$$.fragment,M),B(w.$$.fragment,M),N=!1},d(M){M&&b(e),ue(a),z&&z.d(),ue(h),ue(p),ue(w),S=!1,A()}}}function Ag(n,e,t){let l,o;se(n,Il,_=>t(3,o=_));const s=en(),r=Lt("i18n");se(n,r,_=>t(2,l=_));let{models:i=[]}=e,{chatFiles:a=[]}=e,{params:u={}}=e;const c=()=>{s("close")},f=_=>{a.splice(_,1),t(0,a)};function h(){u.system=this.value,t(1,u)}function d(_){u=_,t(1,u)}return n.$$set=_=>{"models"in _&&t(6,i=_.models),"chatFiles"in _&&t(0,a=_.chatFiles),"params"in _&&t(1,u=_.params)},[a,u,l,o,s,r,i,c,f,h,d]}class Fa extends ke{constructor(e){super(),Ee(this,e,Ag,Lg,Se,{models:6,chatFiles:0,params:1})}}function wr(n,e,t){const l=n.slice();return l[10]=e[t],l}function Bg(n){let e;const t=n[4].default,l=dt(t,n,n[8],null);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,s){l&&l.p&&(!e||s&256)&&ht(l,t,o,o[8],e?gt(t,o[8],s,null):mt(o[8]),null)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function Rg(n){var r;let e,t,l=(((r=n[10])==null?void 0:r.label)??"Camera")+"",o,s;return{c(){e=O("div"),t=O("div"),o=De(l),s=te(),this.h()},l(i){e=H(i,"DIV",{class:!0});var a=T(e);t=H(a,"DIV",{class:!0});var u=T(t);o=ze(u,l),u.forEach(b),a.forEach(b),s=ne(i),this.h()},h(){m(t,"class","line-clamp-1"),m(e,"class","flex items-center")},m(i,a){W(i,e,a),I(e,t),I(t,o),W(i,s,a)},p(i,a){var u;a&2&&l!==(l=(((u=i[10])==null?void 0:u.label)??"Camera")+"")&&Oe(o,l)},d(i){i&&(b(e),b(s))}}}function kr(n){let e,t;function l(){return n[5](n[10])}return e=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",$$slots:{default:[Rg]},$$scope:{ctx:n}}}),e.$on("click",l),{c(){re(e.$$.fragment)},l(o){ce(e.$$.fragment,o)},m(o,s){ae(e,o,s),t=!0},p(o,s){n=o;const r={};s&258&&(r.$$scope={dirty:s,ctx:n}),e.$set(r)},i(o){t||(P(e.$$.fragment,o),t=!0)},o(o){B(e.$$.fragment,o),t=!1},d(o){ue(e,o)}}}function Ug(n){let e,t,l=pt(n[1]),o=[];for(let r=0;rB(o[r],1,1,()=>{o[r]=null});return{c(){for(let r=0;rlt(e,"show",o)),e.$on("change",n[7]),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),l=!0},p(r,[i]){const a={};i&258&&(a.$$scope={dirty:i,ctx:r}),!t&&i&4&&(t=!0,a.show=r[2],nt(()=>t=!1)),e.$set(a)},i(r){l||(P(e.$$.fragment,r),l=!0)},o(r){B(e.$$.fragment,r),l=!1},d(r){ue(e,r)}}}function jg(n,e,t){let{$$slots:l={},$$scope:o}=e;Lt("i18n");const s=en();let{onClose:r=()=>{}}=e,{devices:i}=e,a=!1;const u=h=>{s("change",h.deviceId)};function c(h){a=h,t(2,a)}const f=h=>{h.detail===!1&&r()};return n.$$set=h=>{"onClose"in h&&t(0,r=h.onClose),"devices"in h&&t(1,i=h.devices),"$$scope"in h&&t(8,o=h.$$scope)},[r,i,a,s,l,u,c,f,o]}class Yg extends ke{constructor(e){super(),Ee(this,e,jg,Fg,Se,{onClose:0,devices:1})}}function Er(n){let e,t,l,o,s,r,i,a,u,c,f,h,d,_,v,p='',g,y,k,w=n[4]&&Sr(n);function N(E,q){return E[4]?Gg:qg}let S=N(n),A=S(n);const z=[e_,$g],M=[];function V(E,q){return E[4]?0:1}i=V(n),a=M[i]=z[i](n);function L(E,q){return E[1]?s_:E[2]?o_:l_}let Y=L(n),K=Y(n);return{c(){e=O("div"),w&&w.c(),t=te(),l=O("div"),A.c(),o=te(),s=O("div"),r=O("div"),a.c(),u=te(),c=O("div"),f=O("button"),h=O("div"),K.c(),d=te(),_=O("div"),v=O("button"),v.innerHTML=p,this.h()},l(E){e=H(E,"DIV",{class:!0});var q=T(e);w&&w.l(q),t=ne(q),l=H(q,"DIV",{class:!0});var D=T(l);A.l(D),D.forEach(b),o=ne(q),s=H(q,"DIV",{class:!0});var U=T(s);r=H(U,"DIV",{});var F=T(r);a.l(F),F.forEach(b),u=ne(U),c=H(U,"DIV",{});var C=T(c);f=H(C,"BUTTON",{type:!0});var R=T(f);h=H(R,"DIV",{class:!0});var G=T(h);K.l(G),G.forEach(b),R.forEach(b),C.forEach(b),d=ne(U),_=H(U,"DIV",{});var J=T(_);v=H(J,"BUTTON",{class:!0,type:!0,"data-svelte-h":!0}),ut(v)!=="svelte-1k5eavb"&&(v.innerHTML=p),J.forEach(b),U.forEach(b),q.forEach(b),this.h()},h(){m(l,"class","flex justify-center items-center flex-1 h-full w-full max-h-full"),m(h,"class","line-clamp-1 text-sm font-medium"),m(f,"type","button"),m(v,"class","p-3 rounded-full bg-gray-50 dark:bg-gray-900"),m(v,"type","button"),m(s,"class","flex justify-between items-center pb-2 w-full"),m(e,"class","max-w-lg w-full h-full max-h-[100dvh] flex flex-col justify-between p-3 md:p-6")},m(E,q){W(E,e,q),w&&w.m(e,null),I(e,t),I(e,l),A.m(l,null),I(e,o),I(e,s),I(s,r),M[i].m(r,null),I(s,u),I(s,c),I(c,f),I(f,h),K.m(h,null),I(s,d),I(s,_),I(_,v),g=!0,y||(k=[he(f,"click",n[31]),he(v,"click",n[32])],y=!0)},p(E,q){E[4]?w?w.p(E,q):(w=Sr(E),w.c(),w.m(e,t)):w&&(w.d(1),w=null),S===(S=N(E))&&A?A.p(E,q):(A.d(1),A=S(E),A&&(A.c(),A.m(l,null)));let D=i;i=V(E),i===D?M[i].p(E,q):(je(),B(M[D],1,1,()=>{M[D]=null}),Ye(),a=M[i],a?a.p(E,q):(a=M[i]=z[i](E),a.c()),P(a,1),a.m(r,null)),Y===(Y=L(E))&&K?K.p(E,q):(K.d(1),K=Y(E),K&&(K.c(),K.m(h,null)))},i(E){g||(P(a),g=!0)},o(E){B(a),g=!1},d(E){E&&b(e),w&&w.d(),A.d(),M[i].d(),K.d(),y=!1,At(k)}}}function Sr(n){let e,t,l;function o(i,a){return i[3]?Zg:i[1]||i[2]?Kg:Xg}let s=o(n),r=s(n);return{c(){e=O("button"),r.c(),this.h()},l(i){e=H(i,"BUTTON",{type:!0,class:!0});var a=T(e);r.l(a),a.forEach(b),this.h()},h(){m(e,"type","button"),m(e,"class","flex justify-center items-center w-full h-20 min-h-20")},m(i,a){W(i,e,a),r.m(e,null),t||(l=he(e,"click",n[26]),t=!0)},p(i,a){s===(s=o(i))&&r?r.p(i,a):(r.d(1),r=s(i),r&&(r.c(),r.m(e,null)))},d(i){i&&b(e),r.d(),t=!1,l()}}}function Xg(n){let e,t,l;return{c(){e=O("div"),this.h()},l(o){e=H(o,"DIV",{class:!0,style:!0}),T(e).forEach(b),this.h()},h(){var o,s,r,i,a,u,c,f,h;m(e,"class",t=(n[6]*100>4?" size-[4.5rem]":n[6]*100>2?" size-16":n[6]*100>1?"size-14":"size-12")+" transition-all rounded-full "+((((r=(s=(o=n[0])==null?void 0:o.info)==null?void 0:s.meta)==null?void 0:r.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?" bg-cover bg-center bg-no-repeat":"bg-black dark:bg-white")+" bg-black dark:bg-white"),m(e,"style",l=(((u=(a=(i=n[0])==null?void 0:i.info)==null?void 0:a.meta)==null?void 0:u.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?`background-image: url('${(h=(f=(c=n[0])==null?void 0:c.info)==null?void 0:f.meta)==null?void 0:h.profile_image_url}');`:"")},m(o,s){W(o,e,s)},p(o,s){var r,i,a,u,c,f,h,d,_;s[0]&65&&t!==(t=(o[6]*100>4?" size-[4.5rem]":o[6]*100>2?" size-16":o[6]*100>1?"size-14":"size-12")+" transition-all rounded-full "+((((a=(i=(r=o[0])==null?void 0:r.info)==null?void 0:i.meta)==null?void 0:a.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?" bg-cover bg-center bg-no-repeat":"bg-black dark:bg-white")+" bg-black dark:bg-white")&&m(e,"class",t),s[0]&1&&l!==(l=(((f=(c=(u=o[0])==null?void 0:u.info)==null?void 0:c.meta)==null?void 0:f.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?`background-image: url('${(_=(d=(h=o[0])==null?void 0:h.info)==null?void 0:d.meta)==null?void 0:_.profile_image_url}');`:"")&&m(e,"style",l)},d(o){o&&b(e)}}}function Kg(n){let e,t,l,o,s,r;return{c(){e=Pe("svg"),t=Pe("style"),l=De(`.spinner_qM83 { animation: spinner_8HQG 1.05s infinite; } .spinner_oXPr { animation-delay: 0.1s; } .spinner_ZTLf { animation-delay: 0.2s; } @keyframes spinner_8HQG { 0%, 57.14% { animation-timing-function: cubic-bezier(0.33, 0.66, 0.66, 1); transform: translate(0); } 28.57% { animation-timing-function: cubic-bezier(0.33, 0, 0.66, 0.33); transform: translateY(-6px); } 100% { transform: translate(0); } } `),o=Pe("circle"),s=Pe("circle"),r=Pe("circle"),this.h()},l(i){e=Ve(i,"svg",{class:!0,viewBox:!0,fill:!0,xmlns:!0});var a=T(e);t=Ve(a,"style",{});var u=T(t);l=ze(u,`.spinner_qM83 { animation: spinner_8HQG 1.05s infinite; } .spinner_oXPr { animation-delay: 0.1s; } .spinner_ZTLf { animation-delay: 0.2s; } @keyframes spinner_8HQG { 0%, 57.14% { animation-timing-function: cubic-bezier(0.33, 0.66, 0.66, 1); transform: translate(0); } 28.57% { animation-timing-function: cubic-bezier(0.33, 0, 0.66, 0.33); transform: translateY(-6px); } 100% { transform: translate(0); } } `),u.forEach(b),o=Ve(a,"circle",{class:!0,cx:!0,cy:!0,r:!0}),T(o).forEach(b),s=Ve(a,"circle",{class:!0,cx:!0,cy:!0,r:!0}),T(s).forEach(b),r=Ve(a,"circle",{class:!0,cx:!0,cy:!0,r:!0}),T(r).forEach(b),a.forEach(b),this.h()},h(){m(o,"class","spinner_qM83"),m(o,"cx","4"),m(o,"cy","12"),m(o,"r","3"),m(s,"class","spinner_qM83 spinner_oXPr"),m(s,"cx","12"),m(s,"cy","12"),m(s,"r","3"),m(r,"class","spinner_qM83 spinner_ZTLf"),m(r,"cx","20"),m(r,"cy","12"),m(r,"r","3"),m(e,"class","size-12 text-gray-900 dark:text-gray-400"),m(e,"viewBox","0 0 24 24"),m(e,"fill","currentColor"),m(e,"xmlns","http://www.w3.org/2000/svg")},m(i,a){W(i,e,a),I(e,t),I(t,l),I(e,o),I(e,s),I(e,r)},p:we,d(i){i&&b(e)}}}function Zg(n){let e,t;return{c(){e=O("div"),t=De(n[3]),this.h()},l(l){e=H(l,"DIV",{class:!0,style:!0});var o=T(e);t=ze(o,n[3]),o.forEach(b),this.h()},h(){m(e,"class","transition-all rounded-full"),Ze(e,"font-size",(n[6]*100>4?"4.5":n[6]*100>2?"4.25":n[6]*100>1?"3.75":"3.5")+"rem"),Ze(e,"width","100%"),Ze(e,"text-align","center")},m(l,o){W(l,e,o),I(e,t)},p(l,o){o[0]&8&&Oe(t,l[3]),o[0]&64&&Ze(e,"font-size",(l[6]*100>4?"4.5":l[6]*100>2?"4.25":l[6]*100>1?"3.75":"3.5")+"rem")},d(l){l&&b(e)}}}function Gg(n){let e,t,l,o,s,r,i,a='',u,c;return{c(){e=O("div"),t=O("video"),l=te(),o=O("canvas"),s=te(),r=O("div"),i=O("button"),i.innerHTML=a,this.h()},l(f){e=H(f,"DIV",{class:!0});var h=T(e);t=H(h,"VIDEO",{id:!0,class:!0}),T(t).forEach(b),l=ne(h),o=H(h,"CANVAS",{id:!0,style:!0}),T(o).forEach(b),s=ne(h),r=H(h,"DIV",{class:!0});var d=T(r);i=H(d,"BUTTON",{type:!0,class:!0,"data-svelte-h":!0}),ut(i)!=="svelte-16ul42n"&&(i.innerHTML=a),d.forEach(b),h.forEach(b),this.h()},h(){m(t,"id","camera-feed"),t.autoplay=!0,m(t,"class","rounded-2xl h-full min-w-full object-cover object-center"),t.playsInline=!0,m(o,"id","camera-canvas"),Ze(o,"display","none"),m(i,"type","button"),m(i,"class","p-1.5 text-white cursor-pointer backdrop-blur-xl bg-black/10 rounded-full"),m(r,"class","absolute top-4 md:top-8 left-4"),m(e,"class","relative flex video-container w-full max-h-full pt-2 pb-4 md:py-6 px-2 h-full")},m(f,h){W(f,e,h),I(e,t),I(e,l),I(e,o),I(e,s),I(e,r),I(r,i),u||(c=he(i,"click",n[28]),u=!0)},p:we,d(f){f&&b(e),u=!1,c()}}}function qg(n){let e,t,l;function o(i,a){return i[3]?xg:i[1]||i[2]?Qg:Jg}let s=o(n),r=s(n);return{c(){e=O("button"),r.c(),this.h()},l(i){e=H(i,"BUTTON",{type:!0});var a=T(e);r.l(a),a.forEach(b),this.h()},h(){m(e,"type","button")},m(i,a){W(i,e,a),r.m(e,null),t||(l=he(e,"click",n[27]),t=!0)},p(i,a){s===(s=o(i))&&r?r.p(i,a):(r.d(1),r=s(i),r&&(r.c(),r.m(e,null)))},d(i){i&&b(e),r.d(),t=!1,l()}}}function Jg(n){let e,t,l;return{c(){e=O("div"),this.h()},l(o){e=H(o,"DIV",{class:!0,style:!0}),T(e).forEach(b),this.h()},h(){var o,s,r,i,a,u,c,f,h;m(e,"class",t=(n[6]*100>4?" size-52":n[6]*100>2?"size-48":n[6]*100>1?"size-44":"size-40")+" transition-all rounded-full "+((((r=(s=(o=n[0])==null?void 0:o.info)==null?void 0:s.meta)==null?void 0:r.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?" bg-cover bg-center bg-no-repeat":"bg-black dark:bg-white")),m(e,"style",l=(((u=(a=(i=n[0])==null?void 0:i.info)==null?void 0:a.meta)==null?void 0:u.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?`background-image: url('${(h=(f=(c=n[0])==null?void 0:c.info)==null?void 0:f.meta)==null?void 0:h.profile_image_url}');`:"")},m(o,s){W(o,e,s)},p(o,s){var r,i,a,u,c,f,h,d,_;s[0]&65&&t!==(t=(o[6]*100>4?" size-52":o[6]*100>2?"size-48":o[6]*100>1?"size-44":"size-40")+" transition-all rounded-full "+((((a=(i=(r=o[0])==null?void 0:r.info)==null?void 0:i.meta)==null?void 0:a.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?" bg-cover bg-center bg-no-repeat":"bg-black dark:bg-white"))&&m(e,"class",t),s[0]&1&&l!==(l=(((f=(c=(u=o[0])==null?void 0:u.info)==null?void 0:c.meta)==null?void 0:f.profile_image_url)??"/static/favicon.png")!=="/static/favicon.png"?`background-image: url('${(_=(d=(h=o[0])==null?void 0:h.info)==null?void 0:d.meta)==null?void 0:_.profile_image_url}');`:"")&&m(e,"style",l)},d(o){o&&b(e)}}}function Qg(n){let e,t,l,o,s,r;return{c(){e=Pe("svg"),t=Pe("style"),l=De(`.spinner_qM83 { animation: spinner_8HQG 1.05s infinite; } .spinner_oXPr { animation-delay: 0.1s; } .spinner_ZTLf { animation-delay: 0.2s; } @keyframes spinner_8HQG { 0%, 57.14% { animation-timing-function: cubic-bezier(0.33, 0.66, 0.66, 1); transform: translate(0); } 28.57% { animation-timing-function: cubic-bezier(0.33, 0, 0.66, 0.33); transform: translateY(-6px); } 100% { transform: translate(0); } } `),o=Pe("circle"),s=Pe("circle"),r=Pe("circle"),this.h()},l(i){e=Ve(i,"svg",{class:!0,viewBox:!0,fill:!0,xmlns:!0});var a=T(e);t=Ve(a,"style",{});var u=T(t);l=ze(u,`.spinner_qM83 { animation: spinner_8HQG 1.05s infinite; } .spinner_oXPr { animation-delay: 0.1s; } .spinner_ZTLf { animation-delay: 0.2s; } @keyframes spinner_8HQG { 0%, 57.14% { animation-timing-function: cubic-bezier(0.33, 0.66, 0.66, 1); transform: translate(0); } 28.57% { animation-timing-function: cubic-bezier(0.33, 0, 0.66, 0.33); transform: translateY(-6px); } 100% { transform: translate(0); } } `),u.forEach(b),o=Ve(a,"circle",{class:!0,cx:!0,cy:!0,r:!0}),T(o).forEach(b),s=Ve(a,"circle",{class:!0,cx:!0,cy:!0,r:!0}),T(s).forEach(b),r=Ve(a,"circle",{class:!0,cx:!0,cy:!0,r:!0}),T(r).forEach(b),a.forEach(b),this.h()},h(){m(o,"class","spinner_qM83"),m(o,"cx","4"),m(o,"cy","12"),m(o,"r","3"),m(s,"class","spinner_qM83 spinner_oXPr"),m(s,"cx","12"),m(s,"cy","12"),m(s,"r","3"),m(r,"class","spinner_qM83 spinner_ZTLf"),m(r,"cx","20"),m(r,"cy","12"),m(r,"r","3"),m(e,"class","size-44 text-gray-900 dark:text-gray-400"),m(e,"viewBox","0 0 24 24"),m(e,"fill","currentColor"),m(e,"xmlns","http://www.w3.org/2000/svg")},m(i,a){W(i,e,a),I(e,t),I(t,l),I(e,o),I(e,s),I(e,r)},p:we,d(i){i&&b(e)}}}function xg(n){let e,t;return{c(){e=O("div"),t=De(n[3]),this.h()},l(l){e=H(l,"DIV",{class:!0,style:!0});var o=T(e);t=ze(o,n[3]),o.forEach(b),this.h()},h(){m(e,"class","transition-all rounded-full"),Ze(e,"font-size",(n[6]*100>4?"13":n[6]*100>2?"12":n[6]*100>1?"11.5":"11")+"rem"),Ze(e,"width","100%"),Ze(e,"text-align","center")},m(l,o){W(l,e,o),I(e,t)},p(l,o){o[0]&8&&Oe(t,l[3]),o[0]&64&&Ze(e,"font-size",(l[6]*100>4?"13":l[6]*100>2?"12":l[6]*100>1?"11.5":"11")+"rem")},d(l){l&&b(e)}}}function $g(n){let e,t;return e=new pn({props:{content:n[11].t("Camera"),$$slots:{default:[t_]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&2048&&(s.content=l[11].t("Camera")),o[2]&8&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function e_(n){let e,t;return e=new Yg({props:{devices:n[8],$$slots:{default:[n_]},$$scope:{ctx:n}}}),e.$on("change",n[29]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&256&&(s.devices=l[8]),o[2]&8&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function t_(n){let e,t='',l,o;return{c(){e=O("button"),e.innerHTML=t,this.h()},l(s){e=H(s,"BUTTON",{class:!0,type:!0,"data-svelte-h":!0}),ut(e)!=="svelte-1n1gs9g"&&(e.innerHTML=t),this.h()},h(){m(e,"class","p-3 rounded-full bg-gray-50 dark:bg-gray-900"),m(e,"type","button")},m(s,r){W(s,e,r),l||(o=he(e,"click",n[30]),l=!0)},p:we,d(s){s&&b(e),l=!1,o()}}}function n_(n){let e,t='';return{c(){e=O("button"),e.innerHTML=t,this.h()},l(l){e=H(l,"BUTTON",{class:!0,type:!0,"data-svelte-h":!0}),ut(e)!=="svelte-5e0pue"&&(e.innerHTML=t),this.h()},h(){m(e,"class","p-3 rounded-full bg-gray-50 dark:bg-gray-900"),m(e,"type","button")},m(l,o){W(l,e,o)},p:we,d(l){l&&b(e)}}}function l_(n){let e=n[11].t("Listening...")+"",t;return{c(){t=De(e)},l(l){t=ze(l,e)},m(l,o){W(l,t,o)},p(l,o){o[0]&2048&&e!==(e=l[11].t("Listening...")+"")&&Oe(t,e)},d(l){l&&b(t)}}}function o_(n){let e=n[11].t("Tap to interrupt")+"",t;return{c(){t=De(e)},l(l){t=ze(l,e)},m(l,o){W(l,t,o)},p(l,o){o[0]&2048&&e!==(e=l[11].t("Tap to interrupt")+"")&&Oe(t,e)},d(l){l&&b(t)}}}function s_(n){let e=n[11].t("Thinking...")+"",t;return{c(){t=De(e)},l(l){t=ze(l,e)},m(l,o){W(l,t,o)},p(l,o){o[0]&2048&&e!==(e=l[11].t("Thinking...")+"")&&Oe(t,e)},d(l){l&&b(t)}}}function i_(n){let e,t,l=n[10]&&Er(n);return{c(){l&&l.c(),e=Le()},l(o){l&&l.l(o),e=Le()},m(o,s){l&&l.m(o,s),W(o,e,s),t=!0},p(o,s){o[10]?l?(l.p(o,s),s[0]&1024&&P(l,1)):(l=Er(o),l.c(),P(l,1),l.m(e.parentNode,e)):l&&(je(),B(l,1,1,()=>{l=null}),Ye())},i(o){t||(P(l),t=!0)},o(o){B(l),t=!1},d(o){o&&b(e),l&&l.d(o)}}}function r_(n,e,t){let l,o,s,r,i;se(n,Sl,fe=>t(45,l=fe)),se(n,El,fe=>t(46,o=fe)),se(n,Fn,fe=>t(47,s=fe)),se(n,rl,fe=>t(10,r=fe));const a=en(),u=Lt("i18n");se(n,u,fe=>t(11,i=fe));let{eventTarget:c}=e,{submitPrompt:f}=e,{stopResponse:h}=e,{files:d}=e,{chatId:_}=e,{modelId:v}=e,p=null,g=null,y=!1,k=!1,w=!1,N=null,S=!1,A=null,z=!1,M=0,V=!1,L,Y=null,K=[],E=[],q=null;const D=async()=>{const fe=await navigator.mediaDevices.enumerateDevices();t(8,E=fe.filter(Ne=>Ne.kind==="videoinput")),navigator.mediaDevices.getDisplayMedia&&t(8,E=[...E,{deviceId:"screen",label:"Screen Share"}]),console.log(E),q===null&&E.length>0&&t(9,q=E[0].deviceId)},U=async()=>{if(await D(),A===null){t(4,S=!0),await Je();try{await F()}catch(fe){console.error("Error accessing webcam: ",fe)}}},F=async()=>{const fe=document.getElementById("camera-feed");fe&&(q==="screen"?t(5,A=await navigator.mediaDevices.getDisplayMedia({video:{cursor:"always"},audio:!1})):t(5,A=await navigator.mediaDevices.getUserMedia({video:{deviceId:q?{exact:q}:void 0}})),A&&(await D(),fe.srcObject=A,await fe.play()))},C=async()=>{A&&A.getTracks().forEach(Ne=>Ne.stop()),t(5,A=null)},R=()=>{const fe=document.getElementById("camera-feed"),Ne=document.getElementById("camera-canvas");if(!Ne)return;const X=Ne.getContext("2d");Ne.width=fe.videoWidth,Ne.height=fe.videoHeight,X.drawImage(fe,0,0,fe.videoWidth,fe.videoHeight);const me=Ne.toDataURL("image/png");return console.log(me),me},G=async()=>{await C(),t(4,S=!1)},J=-55,oe=async fe=>{await Je();const Ne=xo(fe,"recording.wav"),X=await es(localStorage.token,Ne).catch(me=>($e.error(me),null));if(X&&(console.log(X.text),X.text!=="")){const me=await f(X.text,{_raw:!0});console.log(me)}},ee=async(fe=!0)=>{if(r){console.log("%c%s","color: red; font-size: 20px;","🚨 stopRecordingCallback 🚨");const Ne=K.slice(0);if(K=[],L=!1,fe&&j(),k){if(t(1,y=!0),t(3,N=null),A){const me=R();t(20,d=[{type:"image",url:me}])}const X=new Blob(Ne,{type:"audio/wav"});await oe(X),k=!1,t(1,y=!1)}}else K=[],L=!1,Y&&Y.getTracks().forEach(X=>X.stop()),t(7,Y=null)},j=async()=>{Y||t(7,Y=await navigator.mediaDevices.getUserMedia({audio:!0})),L=new MediaRecorder(Y),L.onstart=()=>{console.log("Recording started"),K=[],ye(Y)},L.ondataavailable=fe=>{V&&K.push(fe.data)},L.onstop=fe=>{console.log("Recording stopped",Y,fe),ee()},L.start()},ge=async()=>{Y&&(Y.getAudioTracks().forEach(function(fe){fe.stop()}),t(7,Y=null))},x=fe=>{let Ne=0;for(let X=0;X{const Ne=new AudioContext,X=Ne.createMediaStreamSource(fe),me=Ne.createAnalyser();me.minDecibels=J,X.connect(me);const He=me.frequencyBinCount,Xe=new Uint8Array(He),Ue=new Uint8Array(me.fftSize);let qe=Date.now();V=!1,console.log("🔊 Sound detection started",qe,V),(()=>{const Zt=()=>{if(!L||!r)return;if(w&&!((s==null?void 0:s.voiceInterruption)??!1)?(me.maxDecibels=0,me.minDecibels=-1):(me.minDecibels=J,me.maxDecibels=-30),me.getByteTimeDomainData(Ue),me.getByteFrequencyData(Xe),t(6,M=x(Ue)),Xe.some(tn=>tn>0)&&(console.log("%c%s","color: red; font-size: 20px;","🔊 Sound detected"),V||(V=!0,de()),qe=Date.now()),V&&Date.now()-qe>2e3&&(k=!0,L)){console.log("%c%s","color: red; font-size: 20px;","🔇 Silence detected"),L.stop();return}window.requestAnimationFrame(Zt)};window.requestAnimationFrame(Zt)})()};let ie={},Ie=null,Te=null;const Fe=fe=>r?new Promise(Ne=>{let X=[];const me=setInterval(async()=>{var He,Xe,Ue;if(X=await speechSynthesis.getVoices(),X.length>0){clearInterval(me);const qe=((He=X==null?void 0:X.filter(It=>{var Zt,Gt,tn,cn;return It.voiceURI===(((Gt=(Zt=s==null?void 0:s.audio)==null?void 0:Zt.tts)==null?void 0:Gt.voice)??((cn=(tn=o==null?void 0:o.audio)==null?void 0:tn.tts)==null?void 0:cn.voice))}))==null?void 0:He.at(0))??void 0;Te=new SpeechSynthesisUtterance(fe),Te.rate=((Ue=(Xe=s.audio)==null?void 0:Xe.tts)==null?void 0:Ue.playbackRate)??1,qe&&(Te.voice=qe),speechSynthesis.speak(Te),Te.onend=async It=>{await new Promise(Zt=>setTimeout(Zt,200)),Ne(It)}}},100)}):Promise.resolve(),rt=fe=>r?new Promise(Ne=>{var me,He;const X=document.getElementById("audioElement");X&&(X.src=fe.src,X.muted=!0,X.playbackRate=((He=(me=s.audio)==null?void 0:me.tts)==null?void 0:He.playbackRate)??1,X.play().then(()=>{X.muted=!1}).catch(Xe=>{console.error(Xe)}),X.onended=async Xe=>{await new Promise(Ue=>setTimeout(Ue,100)),Ne(Xe)})}):Promise.resolve(),de=async()=>{t(2,w=!1),z&&h(),Te&&(speechSynthesis.cancel(),Te=null);const fe=document.getElementById("audioElement");fe&&(fe.muted=!0,fe.pause(),fe.currentTime=0)};let Ge=new AbortController;const Ke=new Map,Vt=new Map,Bt=async fe=>{var Ne,X,me,He;if(!Ke.has(fe))try{if((s==null?void 0:s.showEmojiInCall)??!1){const Xe=await Au(localStorage.token,v,fe,_);Xe&&Vt.set(fe,Xe)}if(o.audio.tts.engine!==""){const Xe=await Yu(localStorage.token,((X=(Ne=s==null?void 0:s.audio)==null?void 0:Ne.tts)==null?void 0:X.voice)??((He=(me=o==null?void 0:o.audio)==null?void 0:me.tts)==null?void 0:He.voice),fe).catch(Ue=>(console.error(Ue),null));if(Xe){const Ue=await Xe.blob(),qe=URL.createObjectURL(Ue);Ke.set(fe,new Audio(qe))}}else Ke.set(fe,!0)}catch(Xe){console.error("Error synthesizing speech:",Xe)}return Ke.get(fe)};let yt={};const Yt=async(fe,Ne)=>{for(;!Ne.aborted;)if(yt[fe]&&yt[fe].length>0){const X=yt[fe].shift();if(Ke.has(X))if(((s==null?void 0:s.showEmojiInCall)??!1)&&Vt.has(X)?t(3,N=Vt.get(X)):t(3,N=null),o.audio.tts.engine!=="")try{console.log("%c%s","color: red; font-size: 20px;",`Playing audio for content: ${X}`);const me=Ke.get(X);await rt(me),console.log(`Played audio for content: ${X}`),await new Promise(He=>setTimeout(He,200))}catch(me){console.error("Error playing audio:",me)}else await Fe(X);else yt[fe].unshift(X),console.log(`Audio for "${X}" not yet available in the cache, re-queued...`),await new Promise(me=>setTimeout(me,200))}else if(ie[fe]&&yt[fe]&&yt[fe].length===0){t(2,w=!1);break}else await new Promise(X=>setTimeout(X,200));console.log(`Audio monitoring and playing stopped for message ID ${fe}`)},Nt=async fe=>{const{id:Ne}=fe.detail;z=!0,Ie!==Ne&&(console.log(`Received chat start event for message ID ${Ne}`),Ie=Ne,Ge&&Ge.abort(),Ge=new AbortController,t(2,w=!0),Yt(Ne,Ge.signal))},Ot=async fe=>{const{id:Ne,content:X}=fe.detail;if(Ie===Ne){console.log(`Received chat event for message ID ${Ne}: ${X}`);try{yt[Ne]===void 0?yt[Ne]=[X]:yt[Ne].push(X),console.log(X),Bt(X)}catch(me){console.error("Failed to fetch or play audio:",me)}}},Dt=async fe=>{const{id:Ne,content:X}=fe.detail;ie[Ne]=!0,z=!1};un(async()=>{const fe=async()=>{try{p=await navigator.wakeLock.request("screen")}catch(Ne){console.log(Ne)}p&&p.addEventListener("release",()=>{console.log("Wake Lock released")})};return"wakeLock"in navigator&&(await fe(),document.addEventListener("visibilitychange",async()=>{p!==null&&document.visibilityState==="visible"&&await fe()})),t(0,g=l.find(Ne=>Ne.id===v)),j(),c.addEventListener("chat:start",Nt),c.addEventListener("chat",Ot),c.addEventListener("chat:finish",Dt),async()=>{await de(),ge(),c.removeEventListener("chat:start",Nt),c.removeEventListener("chat",Ot),c.removeEventListener("chat:finish",Dt),Ge.abort(),await Je(),await de(),await ee(!1),await G()}}),qn(async()=>{await de(),ge(),c.removeEventListener("chat:start",Nt),c.removeEventListener("chat",Ot),c.removeEventListener("chat:finish",Dt),Ge.abort(),await Je(),await de(),await ee(!1),await G()});const Kt=()=>{w&&de()},_e=()=>{w&&de()},Ht=()=>{G()},wt=async fe=>{console.log(fe.detail),t(9,q=fe.detail),await C(),await F()},St=async()=>{await navigator.mediaDevices.getUserMedia({video:!0}),U()},Ce=()=>{w&&de()},Wt=async()=>{await ge(),await C(),console.log(Y),console.log(A),rl.set(!1),a("close")};return n.$$set=fe=>{"eventTarget"in fe&&t(21,c=fe.eventTarget),"submitPrompt"in fe&&t(22,f=fe.submitPrompt),"stopResponse"in fe&&t(23,h=fe.stopResponse),"files"in fe&&t(20,d=fe.files),"chatId"in fe&&t(24,_=fe.chatId),"modelId"in fe&&t(25,v=fe.modelId)},[g,y,w,N,S,A,M,Y,E,q,r,i,a,u,U,F,C,G,ge,de,d,c,f,h,_,v,Kt,_e,Ht,wt,St,Ce,Wt]}class ja extends ke{constructor(e){super(),Ee(this,e,r_,i_,Se,{eventTarget:21,submitPrompt:22,stopResponse:23,files:20,chatId:24,modelId:25},null,[-1,-1,-1])}}function a_(n){let e,t,l,o,s,r;const i=n[4].default,a=dt(i,n,n[3],null);return{c(){e=O("div"),t=O("div"),a&&a.c(),this.h()},l(u){e=H(u,"DIV",{class:!0});var c=T(e);t=H(c,"DIV",{class:!0});var f=T(t);a&&a.l(f),f.forEach(b),c.forEach(b),this.h()},h(){m(t,"class","mt-auto max-w-full w-full bg-gray-50 dark:bg-gray-900 max-h-[100dvh] overflow-y-auto scrollbar-hidden"),m(e,"class","modal fixed right-0 left-0 bottom-0 bg-black/60 w-full h-screen max-h-[100dvh] flex justify-center z-[9999] overflow-hidden overscroll-contain")},m(u,c){W(u,e,c),I(e,t),a&&a.m(t,null),n[5](e),o=!0,s||(r=[he(t,"mousedown",u_),he(e,"mousedown",n[6])],s=!0)},p(u,[c]){a&&a.p&&(!o||c&8)&&ht(a,i,u,u[3],o?gt(i,u[3],c,null):mt(u[3]),null)},i(u){o||(P(a,u),u&&(l||xn(()=>{l=Go(e,ju,{y:100,duration:100}),l.start()})),o=!0)},o(u){B(a,u),o=!1},d(u){u&&b(e),a&&a.d(u),n[5](null),s=!1,At(r)}}}const u_=n=>{n.stopPropagation()};function c_(n,e,t){let{$$slots:l={},$$scope:o}=e;const s=en();let{show:r=!1}=e,{size:i="md"}=e,a=null;const u=d=>{d.key==="Escape"&&c()&&(console.log("Escape"),t(0,r=!1))},c=()=>{const d=document.getElementsByClassName("modal");return d.length&&d[d.length-1]===a};un(()=>{}),qn(()=>{t(0,r=!1),a&&document.body.contains(a)&&(document.body.removeChild(a),document.body.style.overflow="unset")});function f(d){Be[d?"unshift":"push"](()=>{a=d,t(1,a)})}const h=()=>{t(0,r=!1)};return n.$$set=d=>{"show"in d&&t(0,r=d.show),"size"in d&&t(2,i=d.size),"$$scope"in d&&t(3,o=d.$$scope)},n.$$.update=()=>{n.$$.dirty&3&&(r&&a?(document.body.appendChild(a),window.addEventListener("keydown",u),document.body.style.overflow="hidden"):a&&(s("close"),window.removeEventListener("keydown",u),document.body.contains(a)&&(document.body.removeChild(a),document.body.style.overflow="unset")))},[r,a,i,o,l,f,h]}class f_ extends ke{constructor(e){super(),Ee(this,e,c_,a_,Se,{show:0,size:2})}}function d_(n){var w,N,S,A,z,M,V,L,Y,K;let e,t,l,o,s,r,i=(((N=(w=n[0])==null?void 0:w.model)==null?void 0:N.name)??((A=(S=n[0])==null?void 0:S.message)==null?void 0:A.model)??"Assistant")+"",a,u,c,f,h,d,_,v,p;t=new Ur({props:{src:((L=(V=(M=(z=n[0])==null?void 0:z.model)==null?void 0:M.info)==null?void 0:V.meta)==null?void 0:L.profile_image_url)??"",className:"size-5 -translate-y-[1px]"}}),f=new rc({props:{className:"size-3 "+((K=(Y=n[0])==null?void 0:Y.message)!=null&&K.favorite?"fill-red-500 stroke-red-500":"hover:fill-red-500 hover:stroke-red-500")+" ",strokeWidth:"2.5"}});function g(E,q){var D,U;return(U=(D=E[0])==null?void 0:D.message)!=null&&U.error?g_:m_}let y=g(n),k=y(n);return{c(){e=O("div"),re(t.$$.fragment),l=te(),o=O("div"),s=O("div"),r=O("div"),a=De(i),u=te(),c=O("button"),re(f.$$.fragment),d=te(),k.c(),this.h()},l(E){e=H(E,"DIV",{class:!0});var q=T(e);ce(t.$$.fragment,q),l=ne(q),o=H(q,"DIV",{class:!0});var D=T(o);s=H(D,"DIV",{class:!0});var U=T(s);r=H(U,"DIV",{class:!0});var F=T(r);a=ze(F,i),F.forEach(b),u=ne(U),c=H(U,"BUTTON",{class:!0});var C=T(c);ce(f.$$.fragment,C),C.forEach(b),U.forEach(b),d=ne(D),k.l(D),D.forEach(b),q.forEach(b),this.h()},h(){var E,q;m(r,"class","text-xs text-black dark:text-white font-medium line-clamp-1"),m(c,"class",h=(q=(E=n[0])==null?void 0:E.message)!=null&&q.favorite?"":"invisible group-hover:visible"),m(s,"class","flex justify-between items-center"),m(o,"class","ml-2"),m(e,"class","flex w-full")},m(E,q){W(E,e,q),ae(t,e,null),I(e,l),I(e,o),I(o,s),I(s,r),I(r,a),I(s,u),I(s,c),ae(f,c,null),I(o,d),k.m(o,null),_=!0,v||(p=he(c,"click",n[1]),v=!0)},p(E,q){var F,C,R,G,J,oe,ee,j,ge,x,ye,ie;const D={};q&1&&(D.src=((G=(R=(C=(F=E[0])==null?void 0:F.model)==null?void 0:C.info)==null?void 0:R.meta)==null?void 0:G.profile_image_url)??""),t.$set(D),(!_||q&1)&&i!==(i=(((oe=(J=E[0])==null?void 0:J.model)==null?void 0:oe.name)??((j=(ee=E[0])==null?void 0:ee.message)==null?void 0:j.model)??"Assistant")+"")&&Oe(a,i);const U={};q&1&&(U.className="size-3 "+((x=(ge=E[0])==null?void 0:ge.message)!=null&&x.favorite?"fill-red-500 stroke-red-500":"hover:fill-red-500 hover:stroke-red-500")+" "),f.$set(U),(!_||q&1&&h!==(h=(ie=(ye=E[0])==null?void 0:ye.message)!=null&&ie.favorite?"":"invisible group-hover:visible"))&&m(c,"class",h),y===(y=g(E))&&k?k.p(E,q):(k.d(1),k=y(E),k&&(k.c(),k.m(o,null)))},i(E){_||(P(t.$$.fragment,E),P(f.$$.fragment,E),_=!0)},o(E){B(t.$$.fragment,E),B(f.$$.fragment,E),_=!1},d(E){E&&b(e),ue(t),ue(f),k.d(),v=!1,p()}}}function h_(n){var _,v,p;let e,t,l,o,s,r,i=(((v=(_=n[0])==null?void 0:_.user)==null?void 0:v.name)??"User")+"",a,u,c;t=new Ur({props:{src:((p=n[0].user)==null?void 0:p.profile_image_url)??"/user.png",className:"size-5 -translate-y-[1px]"}});function f(g,y){var k,w;return(w=(k=g[0])==null?void 0:k.message)!=null&&w.error?b_:__}let h=f(n),d=h(n);return{c(){e=O("div"),re(t.$$.fragment),l=te(),o=O("div"),s=O("div"),r=O("div"),a=De(i),u=te(),d.c(),this.h()},l(g){e=H(g,"DIV",{class:!0});var y=T(e);ce(t.$$.fragment,y),l=ne(y),o=H(y,"DIV",{class:!0});var k=T(o);s=H(k,"DIV",{class:!0});var w=T(s);r=H(w,"DIV",{class:!0});var N=T(r);a=ze(N,i),N.forEach(b),w.forEach(b),u=ne(k),d.l(k),k.forEach(b),y.forEach(b),this.h()},h(){m(r,"class","text-xs text-black dark:text-white font-medium line-clamp-1"),m(s,"class","flex justify-between items-center"),m(o,"class","ml-2"),m(e,"class","flex w-full")},m(g,y){W(g,e,y),ae(t,e,null),I(e,l),I(e,o),I(o,s),I(s,r),I(r,a),I(o,u),d.m(o,null),c=!0},p(g,y){var w,N,S;const k={};y&1&&(k.src=((w=g[0].user)==null?void 0:w.profile_image_url)??"/user.png"),t.$set(k),(!c||y&1)&&i!==(i=(((S=(N=g[0])==null?void 0:N.user)==null?void 0:S.name)??"User")+"")&&Oe(a,i),h===(h=f(g))&&d?d.p(g,y):(d.d(1),d=h(g),d&&(d.c(),d.m(o,null)))},i(g){c||(P(t.$$.fragment,g),c=!0)},o(g){B(t.$$.fragment,g),c=!1},d(g){g&&b(e),ue(t),d.d()}}}function m_(n){let e,t=n[0].message.content+"",l;return{c(){e=O("div"),l=De(t),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);l=ze(s,t),s.forEach(b),this.h()},h(){m(e,"class","text-gray-500 line-clamp-2 text-xs mt-0.5")},m(o,s){W(o,e,s),I(e,l)},p(o,s){s&1&&t!==(t=o[0].message.content+"")&&Oe(l,t)},d(o){o&&b(e)}}}function g_(n){let e,t=n[0].message.error.content+"",l;return{c(){e=O("div"),l=De(t),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);l=ze(s,t),s.forEach(b),this.h()},h(){m(e,"class","text-red-500 line-clamp-2 text-xs mt-0.5")},m(o,s){W(o,e,s),I(e,l)},p(o,s){s&1&&t!==(t=o[0].message.error.content+"")&&Oe(l,t)},d(o){o&&b(e)}}}function __(n){let e,t=n[0].message.content+"",l;return{c(){e=O("div"),l=De(t),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);l=ze(s,t),s.forEach(b),this.h()},h(){m(e,"class","text-gray-500 line-clamp-2 text-xs mt-0.5")},m(o,s){W(o,e,s),I(e,l)},p(o,s){s&1&&t!==(t=o[0].message.content+"")&&Oe(l,t)},d(o){o&&b(e)}}}function b_(n){let e,t=n[0].message.error.content+"",l;return{c(){e=O("div"),l=De(t),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);l=ze(s,t),s.forEach(b),this.h()},h(){m(e,"class","text-red-500 line-clamp-2 text-xs mt-0.5")},m(o,s){W(o,e,s),I(e,l)},p(o,s){s&1&&t!==(t=o[0].message.error.content+"")&&Oe(l,t)},d(o){o&&b(e)}}}function p_(n){let e,t,l,o;const s=[h_,d_],r=[];function i(a,u){return a[0].message.role==="user"?0:1}return e=i(n),t=r[e]=s[e](n),{c(){t.c(),l=Le()},l(a){t.l(a),l=Le()},m(a,u){r[e].m(a,u),W(a,l,u),o=!0},p(a,u){let c=e;e=i(a),e===c?r[e].p(a,u):(je(),B(r[c],1,1,()=>{r[c]=null}),Ye(),t=r[e],t?t.p(a,u):(t=r[e]=s[e](a),t.c()),P(t,1),t.m(l.parentNode,l))},i(a){o||(P(t),o=!0)},o(a){B(t),o=!1},d(a){a&&b(l),r[e].d(a)}}}function v_(n){var a,u;let e,t,l,o,s,r,i;return t=new pn({props:{content:(u=(a=n[0])==null?void 0:a.message)!=null&&u.error?n[0].message.error.content:n[0].message.content,class:"w-full",allowHTML:!1,$$slots:{default:[p_]},$$scope:{ctx:n}}}),o=new kl({props:{type:"target",position:tt.Top,class:"w-2 rounded-full dark:bg-gray-900"}}),r=new kl({props:{type:"source",position:tt.Bottom,class:"w-2 rounded-full dark:bg-gray-900"}}),{c(){e=O("div"),re(t.$$.fragment),l=te(),re(o.$$.fragment),s=te(),re(r.$$.fragment),this.h()},l(c){e=H(c,"DIV",{class:!0});var f=T(e);ce(t.$$.fragment,f),l=ne(f),ce(o.$$.fragment,f),s=ne(f),ce(r.$$.fragment,f),f.forEach(b),this.h()},h(){m(e,"class","px-4 py-3 shadow-md rounded-xl dark:bg-black bg-white border dark:border-gray-900 w-60 h-20 group")},m(c,f){W(c,e,f),ae(t,e,null),I(e,l),ae(o,e,null),I(e,s),ae(r,e,null),i=!0},p(c,[f]){var d,_;const h={};f&1&&(h.content=(_=(d=c[0])==null?void 0:d.message)!=null&&_.error?c[0].message.error.content:c[0].message.content),f&5&&(h.$$scope={dirty:f,ctx:c}),t.$set(h)},i(c){i||(P(t.$$.fragment,c),P(o.$$.fragment,c),P(r.$$.fragment,c),i=!0)},o(c){B(t.$$.fragment,c),B(o.$$.fragment,c),B(r.$$.fragment,c),i=!1},d(c){c&&b(e),ue(t),ue(o),ue(r)}}}function y_(n,e,t){let{data:l}=e;const o=()=>{var s;t(0,l.message.favorite=!(((s=l==null?void 0:l.message)==null?void 0:s.favorite)??!1),l)};return n.$$set=s=>{"data"in s&&t(0,l=s.data)},[l,o]}class w_ extends ke{constructor(e){super(),Ee(this,e,y_,v_,Se,{data:0})}}function k_(n){let e,t,l,o;return e=new cg({props:{showLock:!1}}),l=new kg({props:{variant:Zn.Dots}}),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment)},l(s){ce(e.$$.fragment,s),t=ne(s),ce(l.$$.fragment,s)},m(s,r){ae(e,s,r),W(s,t,r),ae(l,s,r),o=!0},p:we,i(s){o||(P(e.$$.fragment,s),P(l.$$.fragment,s),o=!0)},o(s){B(e.$$.fragment,s),B(l.$$.fragment,s),o=!1},d(s){s&&b(t),ue(e,s),ue(l,s)}}}function E_(n){let e,t;return e=new L0({props:{nodes:n[0],nodeTypes:n[1],edges:n[2],fitView:!0,minZoom:.001,colorMode:n[3].includes("dark")||n[3]==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",nodesConnectable:!1,nodesDraggable:!1,oninit:n[5],$$slots:{default:[k_]},$$scope:{ctx:n}}}),e.$on("nodeclick",n[6]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&1&&(s.nodes=l[0]),o&2&&(s.nodeTypes=l[1]),o&4&&(s.edges=l[2]),o&8&&(s.colorMode=l[3].includes("dark")||l[3]==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),o&128&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function S_(n,e,t){let l;se(n,cu,c=>t(3,l=c));const o=en();let{nodes:s}=e,{nodeTypes:r}=e,{edges:i}=e;const a=()=>{console.log("Flow initialized")},u=c=>o("nodeclick",c.detail);return n.$$set=c=>{"nodes"in c&&t(0,s=c.nodes),"nodeTypes"in c&&t(1,r=c.nodeTypes),"edges"in c&&t(2,i=c.edges)},[s,r,i,l,o,a,u]}class I_ extends ke{constructor(e){super(),Ee(this,e,S_,E_,Se,{nodes:0,nodeTypes:1,edges:2})}}function Ir(n){let e,t;return e=new I_({props:{nodes:n[6],nodeTypes:n[8],edges:n[7]}}),e.$on("nodeclick",n[11]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p:we,i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function C_(n){let e,t,l,o=n[1].t("Chat Overview")+"",s,r,i,a,u,c,f,h;a=new $o({props:{className:"size-4"}});let d=n[2].length>0&&Ir(n);return{c(){e=O("div"),t=O("div"),l=O("div"),s=De(o),r=te(),i=O("button"),re(a.$$.fragment),u=te(),d&&d.c(),this.h()},l(_){e=H(_,"DIV",{class:!0});var v=T(e);t=H(v,"DIV",{class:!0});var p=T(t);l=H(p,"DIV",{class:!0});var g=T(l);s=ze(g,o),g.forEach(b),r=ne(p),i=H(p,"BUTTON",{class:!0});var y=T(i);ce(a.$$.fragment,y),y.forEach(b),p.forEach(b),u=ne(v),d&&d.l(v),v.forEach(b),this.h()},h(){m(l,"class","text-lg font-medium self-center font-primary"),m(i,"class","self-center"),m(t,"class","absolute z-50 w-full flex justify-between dark:text-gray-100 px-5 py-4"),m(e,"class","w-full h-full relative")},m(_,v){W(_,e,v),I(e,t),I(t,l),I(l,s),I(t,r),I(t,i),ae(a,i,null),I(e,u),d&&d.m(e,null),c=!0,f||(h=he(i,"click",n[10]),f=!0)},p(_,[v]){(!c||v&2)&&o!==(o=_[1].t("Chat Overview")+"")&&Oe(s,o),_[2].length>0?d?(d.p(_,v),v&4&&P(d,1)):(d=Ir(_),d.c(),P(d,1),d.m(e,null)):d&&(je(),B(d,1,1,()=>{d=null}),Ye())},i(_){c||(P(a.$$.fragment,_),P(d),c=!0)},o(_){B(a.$$.fragment,_),B(d),c=!1},d(_){_&&b(e),ue(a),d&&d.d(),f=!1,h()}}}function D_(n,e,t){let l,o,s,r;se(n,Sl,z=>t(12,l=z)),se(n,Il,z=>t(13,o=z));const i=en(),a=Lt("i18n");se(n,a,z=>t(1,s=z));const{width:u,height:c}=Rt(),{fitView:f,getViewport:h}=Eg(),d=Sg();let{history:_}=e,v=null;const p=Ae([]);se(n,p,z=>t(2,r=z));const g=Ae([]),y={custom:w_},k=async()=>{v===null&&await f({nodes:[{id:_.currentId}]})},w=async()=>{const z=[],M=[];let Y=new Map,K={};Object.keys(_.messages).forEach(E=>{var U;const q=_.messages[E],D=q.parentId?(((U=Y.get(q.parentId))==null?void 0:U.level)??-1)+1:0;K[D]||(K[D]=0),Y.set(E,{id:q.id,level:D,position:K[D]++})}),Object.keys(_.messages).forEach(E=>{const q=Y.get(E),D=q.position*250,U=q.level*150,F=D;z.push({id:q.id,type:"custom",data:{user:o,message:_.messages[E],model:l.find(R=>R.id===_.messages[E].model)},position:{x:F,y:U}});const C=_.messages[E].parentId;C&&M.push({id:C+"-"+q.id,source:C,target:q.id,selectable:!1,class:" dark:fill-gray-300 fill-gray-300",type:"smoothstep",animated:_.currentId===E||N(E,_.currentId)})}),await g.set([...M]),await p.set([...z])},N=(z,M)=>{const V=_.messages[z];return V.childrenIds&&V.childrenIds.some(L=>L===M||N(L,M))};un(()=>{w(),d.subscribe(async z=>{z&&(await Je(),await f({nodes:[{id:_.currentId}]}))}),u.subscribe(z=>{z&&f({nodes:[{id:_.currentId}]})}),c.subscribe(z=>{z&&f({nodes:[{id:_.currentId}]})})}),qn(()=>{console.log("Overview destroyed"),p.set([]),g.set([])});const S=()=>{i("close"),Hl.set(!1)},A=z=>{console.log(z.detail.node.data),i("nodeclick",z.detail),t(0,v=z.detail.node.data.message.id),f({nodes:[{id:v}]})};return n.$$set=z=>{"history"in z&&t(9,_=z.history)},n.$$.update=()=>{n.$$.dirty&512&&_&&w(),n.$$.dirty&512&&_&&_.currentId&&(k(),t(0,v=null))},[v,s,r,i,a,f,p,g,y,_,S,A]}class Ya extends ke{constructor(e){super(),Ee(this,e,D_,C_,Se,{history:9})}}function z_(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var o=T(e);t=Ve(o,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"stroke-linecap","round"),m(t,"stroke-linejoin","round"),m(t,"d","M12 6.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 12.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 18.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5Z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"fill","none"),m(e,"viewBox","0 0 24 24"),m(e,"stroke-width",n[1]),m(e,"stroke","currentColor"),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&2&&m(e,"stroke-width",l[1]),o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function M_(n,e,t){let{className:l="w-4 h-4"}=e,{strokeWidth:o="1.5"}=e;return n.$$set=s=>{"className"in s&&t(0,l=s.className),"strokeWidth"in s&&t(1,o=s.strokeWidth)},[l,o]}class T_ extends ke{constructor(e){super(),Ee(this,e,M_,z_,Se,{className:0,strokeWidth:1})}}function P_(n){let e,t,l,o,s;e=new Vf({props:{class:"relative flex w-2 items-center justify-center bg-background group",$$slots:{default:[N_]},$$scope:{ctx:n}}});function r(a){n[32](a)}let i={defaultSize:n[13]?parseInt((localStorage==null?void 0:localStorage.chatControlsSize)??"30")?parseInt((localStorage==null?void 0:localStorage.chatControlsSize)??"30"):30:0,onResize:n[31],$$slots:{default:[A_]},$$scope:{ctx:n}};return n[4]!==void 0&&(i.pane=n[4]),l=new ia({props:i}),Be.push(()=>lt(l,"pane",r)),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment)},l(a){ce(e.$$.fragment,a),t=ne(a),ce(l.$$.fragment,a)},m(a,u){ae(e,a,u),W(a,t,u),ae(l,a,u),s=!0},p(a,u){const c={};u[1]&4&&(c.$$scope={dirty:u,ctx:a}),e.$set(c);const f={};u[0]&8192&&(f.defaultSize=a[13]?parseInt((localStorage==null?void 0:localStorage.chatControlsSize)??"30")?parseInt((localStorage==null?void 0:localStorage.chatControlsSize)??"30"):30:0),u[0]&8192&&(f.onResize=a[31]),u[0]&61423|u[1]&4&&(f.$$scope={dirty:u,ctx:a}),!o&&u[0]&16&&(o=!0,f.pane=a[4],nt(()=>o=!1)),l.$set(f)},i(a){s||(P(e.$$.fragment,a),P(l.$$.fragment,a),s=!0)},o(a){B(e.$$.fragment,a),B(l.$$.fragment,a),s=!1},d(a){a&&b(t),ue(e,a),ue(l,a)}}}function V_(n){let e,t,l=n[13]&&Dr(n);return{c(){l&&l.c(),e=Le()},l(o){l&&l.l(o),e=Le()},m(o,s){l&&l.m(o,s),W(o,e,s),t=!0},p(o,s){o[13]?l?(l.p(o,s),s[0]&8192&&P(l,1)):(l=Dr(o),l.c(),P(l,1),l.m(e.parentNode,e)):l&&(je(),B(l,1,1,()=>{l=null}),Ye())},i(o){t||(P(l),t=!0)},o(o){B(l),t=!1},d(o){o&&b(e),l&&l.d(o)}}}function N_(n){let e,t,l;return t=new T_({props:{className:"size-4 invisible group-hover:visible"}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{class:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"class","z-10 flex h-7 w-5 items-center justify-center rounded-sm")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p:we,i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function Cr(n){let e,t,l,o,s,r;const i=[L_,H_,O_],a=[];function u(c,f){return c[14]?0:c[15]?1:2}return l=u(n),o=a[l]=i[l](n),{c(){e=O("div"),t=O("div"),o.c(),this.h()},l(c){e=H(c,"DIV",{class:!0});var f=T(e);t=H(f,"DIV",{class:!0});var h=T(t);o.l(h),h.forEach(b),f.forEach(b),this.h()},h(){m(t,"class",s="w-full "+(n[15]&&!n[14]?" ":"px-5 py-4 bg-white dark:shadow-lg dark:bg-gray-850 border border-gray-50 dark:border-gray-800")+" rounded-lg z-50 pointer-events-auto overflow-y-auto scrollbar-hidden"),m(e,"class","pr-4 pb-8 flex max-h-full min-h-full")},m(c,f){W(c,e,f),I(e,t),a[l].m(t,null),r=!0},p(c,f){let h=l;l=u(c),l===h?a[l].p(c,f):(je(),B(a[h],1,1,()=>{a[h]=null}),Ye(),o=a[l],o?o.p(c,f):(o=a[l]=i[l](c),o.c()),P(o,1),o.m(t,null)),(!r||f[0]&49152&&s!==(s="w-full "+(c[15]&&!c[14]?" ":"px-5 py-4 bg-white dark:shadow-lg dark:bg-gray-850 border border-gray-50 dark:border-gray-800")+" rounded-lg z-50 pointer-events-auto overflow-y-auto scrollbar-hidden"))&&m(t,"class",s)},i(c){r||(P(o),r=!0)},o(c){B(o),r=!1},d(c){c&&b(e),a[l].d()}}}function O_(n){let e,t,l,o;function s(a){n[28](a)}function r(a){n[29](a)}let i={models:n[5]};return n[1]!==void 0&&(i.chatFiles=n[1]),n[2]!==void 0&&(i.params=n[2]),e=new Fa({props:i}),Be.push(()=>lt(e,"chatFiles",s)),Be.push(()=>lt(e,"params",r)),e.$on("close",n[30]),{c(){re(e.$$.fragment)},l(a){ce(e.$$.fragment,a)},m(a,u){ae(e,a,u),o=!0},p(a,u){const c={};u[0]&32&&(c.models=a[5]),!t&&u[0]&2&&(t=!0,c.chatFiles=a[1],nt(()=>t=!1)),!l&&u[0]&4&&(l=!0,c.params=a[2],nt(()=>l=!1)),e.$set(c)},i(a){o||(P(e.$$.fragment,a),o=!0)},o(a){B(e.$$.fragment,a),o=!1},d(a){ue(e,a)}}}function H_(n){let e,t;return e=new Ya({props:{history:n[0]}}),e.$on("nodeclick",n[26]),e.$on("close",n[27]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&1&&(s.history=l[0]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function L_(n){let e,t,l,o;function s(i){n[24](i)}let r={submitPrompt:n[8],stopResponse:n[9],modelId:n[11],chatId:n[6],eventTarget:n[7]};return n[3]!==void 0&&(r.files=n[3]),t=new ja({props:r}),Be.push(()=>lt(t,"files",s)),t.$on("close",n[25]),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(i){e=H(i,"DIV",{class:!0});var a=T(e);ce(t.$$.fragment,a),a.forEach(b),this.h()},h(){m(e,"class","w-full h-full flex justify-center")},m(i,a){W(i,e,a),ae(t,e,null),o=!0},p(i,a){const u={};a[0]&256&&(u.submitPrompt=i[8]),a[0]&512&&(u.stopResponse=i[9]),a[0]&2048&&(u.modelId=i[11]),a[0]&64&&(u.chatId=i[6]),a[0]&128&&(u.eventTarget=i[7]),!l&&a[0]&8&&(l=!0,u.files=i[3],nt(()=>l=!1)),t.$set(u)},i(i){o||(P(t.$$.fragment,i),o=!0)},o(i){B(t.$$.fragment,i),o=!1},d(i){i&&b(e),ue(t)}}}function A_(n){let e,t,l=n[13]&&Cr(n);return{c(){l&&l.c(),e=Le()},l(o){l&&l.l(o),e=Le()},m(o,s){l&&l.m(o,s),W(o,e,s),t=!0},p(o,s){o[13]?l?(l.p(o,s),s[0]&8192&&P(l,1)):(l=Cr(o),l.c(),P(l,1),l.m(e.parentNode,e)):l&&(je(),B(l,1,1,()=>{l=null}),Ye())},i(o){t||(P(l),t=!0)},o(o){B(l),t=!1},d(o){o&&b(e),l&&l.d(o)}}}function Dr(n){let e,t;return e=new f_({props:{show:n[13],$$slots:{default:[W_]},$$scope:{ctx:n}}}),e.$on("close",n[23]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&8192&&(s.show=l[13]),o[0]&53231|o[1]&4&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function B_(n){let e,t,l,o;function s(a){n[20](a)}function r(a){n[21](a)}let i={models:n[5]};return n[1]!==void 0&&(i.chatFiles=n[1]),n[2]!==void 0&&(i.params=n[2]),e=new Fa({props:i}),Be.push(()=>lt(e,"chatFiles",s)),Be.push(()=>lt(e,"params",r)),e.$on("close",n[22]),{c(){re(e.$$.fragment)},l(a){ce(e.$$.fragment,a)},m(a,u){ae(e,a,u),o=!0},p(a,u){const c={};u[0]&32&&(c.models=a[5]),!t&&u[0]&2&&(t=!0,c.chatFiles=a[1],nt(()=>t=!1)),!l&&u[0]&4&&(l=!0,c.params=a[2],nt(()=>l=!1)),e.$set(c)},i(a){o||(P(e.$$.fragment,a),o=!0)},o(a){B(e.$$.fragment,a),o=!1},d(a){ue(e,a)}}}function R_(n){let e,t;return e=new Ya({props:{history:n[0]}}),e.$on("nodeclick",n[18]),e.$on("close",n[19]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&1&&(s.history=l[0]),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function U_(n){let e,t,l,o;function s(i){n[16](i)}let r={submitPrompt:n[8],stopResponse:n[9],modelId:n[11],chatId:n[6],eventTarget:n[7]};return n[3]!==void 0&&(r.files=n[3]),t=new ja({props:r}),Be.push(()=>lt(t,"files",s)),t.$on("close",n[17]),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(i){e=H(i,"DIV",{class:!0});var a=T(e);ce(t.$$.fragment,a),a.forEach(b),this.h()},h(){m(e,"class","h-full max-h-[100dvh] bg-white text-gray-700 dark:bg-black dark:text-gray-300 flex justify-center")},m(i,a){W(i,e,a),ae(t,e,null),o=!0},p(i,a){const u={};a[0]&256&&(u.submitPrompt=i[8]),a[0]&512&&(u.stopResponse=i[9]),a[0]&2048&&(u.modelId=i[11]),a[0]&64&&(u.chatId=i[6]),a[0]&128&&(u.eventTarget=i[7]),!l&&a[0]&8&&(l=!0,u.files=i[3],nt(()=>l=!1)),t.$set(u)},i(i){o||(P(t.$$.fragment,i),o=!0)},o(i){B(t.$$.fragment,i),o=!1},d(i){i&&b(e),ue(t)}}}function W_(n){let e,t,l,o,s;const r=[U_,R_,B_],i=[];function a(u,c){return u[14]?0:u[15]?1:2}return t=a(n),l=i[t]=r[t](n),{c(){e=O("div"),l.c(),this.h()},l(u){e=H(u,"DIV",{class:!0});var c=T(e);l.l(c),c.forEach(b),this.h()},h(){m(e,"class",o=(n[14]||n[15]?" h-screen w-screen":"px-6 py-4")+" h-full")},m(u,c){W(u,e,c),i[t].m(e,null),s=!0},p(u,c){let f=t;t=a(u),t===f?i[t].p(u,c):(je(),B(i[f],1,1,()=>{i[f]=null}),Ye(),l=i[t],l?l.p(u,c):(l=i[t]=r[t](u),l.c()),P(l,1),l.m(e,null)),(!s||c[0]&49152&&o!==(o=(u[14]||u[15]?" h-screen w-screen":"px-6 py-4")+" h-full"))&&m(e,"class",o)},i(u){s||(P(l),s=!0)},o(u){B(l),s=!1},d(u){u&&b(e),i[t].d()}}}function F_(n){let e,t,l,o;const s=[V_,P_],r=[];function i(a,u){return a[12]?1:0}return e=i(n),t=r[e]=s[e](n),{c(){t.c(),l=Le()},l(a){t.l(a),l=Le()},m(a,u){r[e].m(a,u),W(a,l,u),o=!0},p(a,u){let c=e;e=i(a),e===c?r[e].p(a,u):(je(),B(r[c],1,1,()=>{r[c]=null}),Ye(),t=r[e],t?t.p(a,u):(t=r[e]=s[e](a),t.c()),P(t,1),t.m(l.parentNode,l))},i(a){o||(P(t),o=!0)},o(a){B(t),o=!1},d(a){a&&b(l),r[e].d(a)}}}function j_(n){let e,t;return e=new R0({props:{$$slots:{default:[F_]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o[0]&65535|o[1]&4&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function Y_(n,e,t){let l,o,s;se(n,qt,R=>t(13,l=R)),se(n,rl,R=>t(14,o=R)),se(n,Hl,R=>t(15,s=R));let{history:r}=e,{models:i=[]}=e,{chatId:a=null}=e,{chatFiles:u=[]}=e,{params:c={}}=e,{eventTarget:f}=e,{submitPrompt:h}=e,{stopResponse:d}=e,{showMessage:_}=e,{files:v}=e,{modelId:p}=e,{pane:g}=e,y=!1;un(()=>{const R=window.matchMedia("(min-width: 1024px)"),G=J=>{J.matches?t(12,y=!0):(t(12,y=!1),t(4,g=null))};return R.addEventListener("change",G),G(R),()=>{R.removeEventListener("change",G)}}),qn(()=>{qt.set(!1)});function k(R){v=R,t(3,v)}const w=()=>{qt.set(!1)},N=R=>{_(R.detail.node.data.message)},S=()=>{qt.set(!1)};function A(R){u=R,t(1,u)}function z(R){c=R,t(2,c)}const M=()=>{qt.set(!1)},V=()=>{qt.set(!1)};function L(R){v=R,t(3,v)}const Y=()=>{qt.set(!1)},K=R=>{R.detail.node.data.message.favorite?t(0,r.messages[R.detail.node.data.message.id].favorite=!0,r):t(0,r.messages[R.detail.node.data.message.id].favorite=null,r),_(R.detail.node.data.message)},E=()=>{qt.set(!1)};function q(R){u=R,t(1,u)}function D(R){c=R,t(2,c)}const U=()=>{qt.set(!1)},F=R=>{R===0?qt.set(!1):(l||qt.set(!0),localStorage.chatControlsSize=R)};function C(R){g=R,t(4,g)}return n.$$set=R=>{"history"in R&&t(0,r=R.history),"models"in R&&t(5,i=R.models),"chatId"in R&&t(6,a=R.chatId),"chatFiles"in R&&t(1,u=R.chatFiles),"params"in R&&t(2,c=R.params),"eventTarget"in R&&t(7,f=R.eventTarget),"submitPrompt"in R&&t(8,h=R.submitPrompt),"stopResponse"in R&&t(9,d=R.stopResponse),"showMessage"in R&&t(10,_=R.showMessage),"files"in R&&t(3,v=R.files),"modelId"in R&&t(11,p=R.modelId),"pane"in R&&t(4,g=R.pane)},n.$$.update=()=>{n.$$.dirty[0]&64&&(a||Hl.set(!1))},[r,u,c,v,g,i,a,f,h,d,_,p,y,l,o,s,k,w,N,S,A,z,M,V,L,Y,K,E,q,D,U,F,C]}class X_ extends ke{constructor(e){super(),Ee(this,e,Y_,j_,Se,{history:0,models:5,chatId:6,chatFiles:1,params:2,eventTarget:7,submitPrompt:8,stopResponse:9,showMessage:10,files:3,modelId:11,pane:4},null,[-1,-1])}}const{document:Ro}=Ar;function zr(n,e,t){const l=n.slice();return l[95]=e[t],l}function Mr(n){var h;let e,t,l,o,s,r,i,a,u=(((h=n[24])==null?void 0:h.backgroundImageUrl)??null)&&Tr(n);function c(d){n[45](d)}let f={chat:n[17],title:n[26],shareEnabled:!!n[18].currentId,initNewChat:n[33]};return n[1]!==void 0&&(f.selectedModels=n[1]),l=new Rh({props:f}),Be.push(()=>lt(l,"selectedModels",c)),r=new Cf({props:{direction:"horizontal",class:"w-full h-full",$$slots:{default:[Z_]},$$scope:{ctx:n}}}),{c(){e=O("div"),u&&u.c(),t=te(),re(l.$$.fragment),s=te(),re(r.$$.fragment),this.h()},l(d){e=H(d,"DIV",{class:!0});var _=T(e);u&&u.l(_),t=ne(_),ce(l.$$.fragment,_),s=ne(_),ce(r.$$.fragment,_),_.forEach(b),this.h()},h(){m(e,"class",i="h-screen max-h-[100dvh] "+(n[28]?"md:max-w-[calc(100%-260px)]":"")+" w-full max-w-full flex flex-col")},m(d,_){W(d,e,_),u&&u.m(e,null),I(e,t),ae(l,e,null),I(e,s),ae(r,e,null),a=!0},p(d,_){var g;((g=d[24])==null?void 0:g.backgroundImageUrl)??null?u?u.p(d,_):(u=Tr(d),u.c(),u.m(e,t)):u&&(u.d(1),u=null);const v={};_[0]&131072&&(v.chat=d[17]),_[0]&67108864&&(v.title=d[26]),_[0]&262144&&(v.shareEnabled=!!d[18].currentId),!o&&_[0]&2&&(o=!0,v.selectedModels=d[1],nt(()=>o=!1)),l.$set(v);const p={};_[0]&603832439|_[3]&32&&(p.$$scope={dirty:_,ctx:d}),r.$set(p),(!a||_[0]&268435456&&i!==(i="h-screen max-h-[100dvh] "+(d[28]?"md:max-w-[calc(100%-260px)]":"")+" w-full max-w-full flex flex-col"))&&m(e,"class",i)},i(d){a||(P(l.$$.fragment,d),P(r.$$.fragment,d),a=!0)},o(d){B(l.$$.fragment,d),B(r.$$.fragment,d),a=!1},d(d){d&&b(e),u&&u.d(),ue(l),ue(r)}}}function Tr(n){let e,t,l,o;return{c(){e=O("div"),l=te(),o=O("div"),this.h()},l(s){e=H(s,"DIV",{class:!0,style:!0}),T(e).forEach(b),l=ne(s),o=H(s,"DIV",{class:!0}),T(o).forEach(b),this.h()},h(){m(e,"class",t="absolute "+(n[28]?"md:max-w-[calc(100%-260px)] md:translate-x-[260px]":"")+" top-0 left-0 w-full h-full bg-cover bg-center bg-no-repeat"),Ze(e,"background-image","url("+n[24].backgroundImageUrl+")"),m(o,"class","absolute top-0 left-0 w-full h-full bg-gradient-to-t from-white to-white/85 dark:from-gray-900 dark:to-[#171717]/90 z-0")},m(s,r){W(s,e,r),W(s,l,r),W(s,o,r)},p(s,r){r[0]&268435456&&t!==(t="absolute "+(s[28]?"md:max-w-[calc(100%-260px)] md:translate-x-[260px]":"")+" top-0 left-0 w-full h-full bg-cover bg-center bg-no-repeat")&&m(e,"class",t),r[0]&16777216&&Ze(e,"background-image","url("+s[24].backgroundImageUrl+")")},d(s){s&&(b(e),b(l),b(o))}}}function Pr(n){let e,t,l,o=pt(n[29].filter(n[46])),s=[];for(let i=0;iB(s[i],1,1,()=>{s[i]=null});return{c(){e=O("div"),t=O("div");for(let i=0;i0&&!n[18].currentId&&!n[23]&&n[1].length<=1&&Pr(n);function A(C){n[48](C)}function z(C){n[49](C)}function M(C){n[50](C)}let V={chatId:n[23],selectedModels:n[1],sendPrompt:n[37],showMessage:n[32],continueResponse:n[40],regenerateResponse:n[39],mergeResponses:n[41],chatActionHandler:n[34],bottomPadding:n[21].length>0};n[18]!==void 0&&(V.history=n[18]),n[5]!==void 0&&(V.autoScroll=n[5]),n[19]!==void 0&&(V.prompt=n[19]),s=new Ja({props:V}),Be.push(()=>lt(s,"history",A)),Be.push(()=>lt(s,"autoScroll",z)),Be.push(()=>lt(s,"prompt",M));function L(C){n[54](C)}function Y(C){n[55](C)}function K(C){n[56](C)}function E(C){n[57](C)}function q(C){n[58](C)}function D(C){n[59](C)}let U={history:n[18],selectedModels:n[1],availableToolIds:n[14].reduce(n[53],[]),transparentBackground:((F=n[24])==null?void 0:F.backgroundImageUrl)??!1,submitPrompt:n[36],stopResponse:n[38],createMessagePair:n[35]};return n[21]!==void 0&&(U.files=n[21]),n[19]!==void 0&&(U.prompt=n[19]),n[5]!==void 0&&(U.autoScroll=n[5]),n[15]!==void 0&&(U.selectedToolIds=n[15]),n[16]!==void 0&&(U.webSearchEnabled=n[16]),n[2]!==void 0&&(U.atSelectedModel=n[2]),h=new th({props:U}),Be.push(()=>lt(h,"files",L)),Be.push(()=>lt(h,"prompt",Y)),Be.push(()=>lt(h,"autoScroll",K)),Be.push(()=>lt(h,"selectedToolIds",E)),Be.push(()=>lt(h,"webSearchEnabled",q)),Be.push(()=>lt(h,"atSelectedModel",D)),h.$on("call",n[60]),{c(){S&&S.c(),e=te(),t=O("div"),l=O("div"),o=O("div"),re(s.$$.fragment),c=te(),f=O("div"),re(h.$$.fragment),this.h()},l(C){S&&S.l(C),e=ne(C),t=H(C,"DIV",{class:!0});var R=T(t);l=H(R,"DIV",{class:!0,id:!0});var G=T(l);o=H(G,"DIV",{class:!0});var J=T(o);ce(s.$$.fragment,J),J.forEach(b),G.forEach(b),c=ne(R),f=H(R,"DIV",{class:!0});var oe=T(f);ce(h.$$.fragment,oe),oe.forEach(b),R.forEach(b),this.h()},h(){m(o,"class",u="h-full w-full flex flex-col "+(n[0]?"py-4":"pt-2 pb-4")),m(l,"class","pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0 max-w-full z-10 scrollbar-hidden"),m(l,"id","messages-container"),m(f,"class",""),m(t,"class","flex flex-col flex-auto z-10 w-full")},m(C,R){S&&S.m(C,R),W(C,e,R),W(C,t,R),I(t,l),I(l,o),ae(s,o,null),n[51](l),I(t,c),I(t,f),ae(h,f,null),k=!0,w||(N=he(l,"scroll",n[52]),w=!0)},p(C,R){var oe;C[29].length>0&&!C[18].currentId&&!C[23]&&C[1].length<=1?S?(S.p(C,R),R[0]&545521666&&P(S,1)):(S=Pr(C),S.c(),P(S,1),S.m(e.parentNode,e)):S&&(je(),B(S,1,1,()=>{S=null}),Ye());const G={};R[0]&8388608&&(G.chatId=C[23]),R[0]&2&&(G.selectedModels=C[1]),R[0]&2097152&&(G.bottomPadding=C[21].length>0),!r&&R[0]&262144&&(r=!0,G.history=C[18],nt(()=>r=!1)),!i&&R[0]&32&&(i=!0,G.autoScroll=C[5],nt(()=>i=!1)),!a&&R[0]&524288&&(a=!0,G.prompt=C[19],nt(()=>a=!1)),s.$set(G),(!k||R[0]&1&&u!==(u="h-full w-full flex flex-col "+(C[0]?"py-4":"pt-2 pb-4")))&&m(o,"class",u);const J={};R[0]&262144&&(J.history=C[18]),R[0]&2&&(J.selectedModels=C[1]),R[0]&33570816&&(J.availableToolIds=C[14].reduce(C[53],[])),R[0]&16777216&&(J.transparentBackground=((oe=C[24])==null?void 0:oe.backgroundImageUrl)??!1),!d&&R[0]&2097152&&(d=!0,J.files=C[21],nt(()=>d=!1)),!_&&R[0]&524288&&(_=!0,J.prompt=C[19],nt(()=>_=!1)),!v&&R[0]&32&&(v=!0,J.autoScroll=C[5],nt(()=>v=!1)),!p&&R[0]&32768&&(p=!0,J.selectedToolIds=C[15],nt(()=>p=!1)),!g&&R[0]&65536&&(g=!0,J.webSearchEnabled=C[16],nt(()=>g=!1)),!y&&R[0]&4&&(y=!0,J.atSelectedModel=C[2],nt(()=>y=!1)),h.$set(J)},i(C){k||(P(S),P(s.$$.fragment,C),P(h.$$.fragment,C),k=!0)},o(C){B(S),B(s.$$.fragment,C),B(h.$$.fragment,C),k=!1},d(C){C&&(b(e),b(t)),S&&S.d(C),ue(s),n[51](null),ue(h),w=!1,N()}}}function Z_(n){var p;let e,t,l,o,s,r,i,a,u;e=new ia({props:{defaultSize:50,class:"h-full flex w-full relative",$$slots:{default:[K_]},$$scope:{ctx:n}}});function c(g){n[62](g)}function f(g){n[63](g)}function h(g){n[64](g)}function d(g){n[65](g)}function _(g){n[66](g)}let v={chatId:n[23],modelId:((p=n[14])==null?void 0:p.at(0))??null,models:n[14].reduce(n[61],[]),submitPrompt:n[36],stopResponse:n[38],showMessage:n[32],eventTarget:n[31]};return n[18]!==void 0&&(v.history=n[18]),n[20]!==void 0&&(v.chatFiles=n[20]),n[22]!==void 0&&(v.params=n[22]),n[21]!==void 0&&(v.files=n[21]),n[4]!==void 0&&(v.pane=n[4]),l=new X_({props:v}),Be.push(()=>lt(l,"history",c)),Be.push(()=>lt(l,"chatFiles",f)),Be.push(()=>lt(l,"params",h)),Be.push(()=>lt(l,"files",d)),Be.push(()=>lt(l,"pane",_)),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment)},l(g){ce(e.$$.fragment,g),t=ne(g),ce(l.$$.fragment,g)},m(g,y){ae(e,g,y),W(g,t,y),ae(l,g,y),u=!0},p(g,y){var N;const k={};y[0]&598589543|y[3]&32&&(k.$$scope={dirty:y,ctx:g}),e.$set(k);const w={};y[0]&8388608&&(w.chatId=g[23]),y[0]&16384&&(w.modelId=((N=g[14])==null?void 0:N.at(0))??null),y[0]&33570816&&(w.models=g[14].reduce(g[61],[])),!o&&y[0]&262144&&(o=!0,w.history=g[18],nt(()=>o=!1)),!s&&y[0]&1048576&&(s=!0,w.chatFiles=g[20],nt(()=>s=!1)),!r&&y[0]&4194304&&(r=!0,w.params=g[22],nt(()=>r=!1)),!i&&y[0]&2097152&&(i=!0,w.files=g[21],nt(()=>i=!1)),!a&&y[0]&16&&(a=!0,w.pane=g[4],nt(()=>a=!1)),l.$set(w)},i(g){u||(P(e.$$.fragment,g),P(l.$$.fragment,g),u=!0)},o(g){B(e.$$.fragment,g),B(l.$$.fragment,g),u=!1},d(g){g&&b(t),ue(e,g),ue(l,g)}}}function G_(n){let e,t,l,o,s,r,i,a,u,c;Ro.title=e=` `+(n[26]?`${n[26].length>30?`${n[26].slice(0,30)}...`:n[26]} | ${n[27]}`:`${n[27]}`)+` `;function f(_){n[42](_)}let h={title:n[8],message:n[9],input:n[10],inputPlaceholder:n[11],inputValue:n[12]};n[7]!==void 0&&(h.show=n[7]),r=new ac({props:h}),Be.push(()=>lt(r,"show",f)),r.$on("confirm",n[43]),r.$on("cancel",n[44]);let d=(!n[0]||n[3]&&n[0])&&Mr(n);return{c(){t=te(),l=O("audio"),s=te(),re(r.$$.fragment),a=te(),d&&d.c(),u=Le(),this.h()},l(_){Za("svelte-8uu834",Ro.head).forEach(b),t=ne(_),l=H(_,"AUDIO",{id:!0,src:!0,style:!0}),T(l).forEach(b),s=ne(_),ce(r.$$.fragment,_),a=ne(_),d&&d.l(_),u=Le(),this.h()},h(){m(l,"id","audioElement"),Gn(l.src,o="")||m(l,"src",o),Ze(l,"display","none")},m(_,v){W(_,t,v),W(_,l,v),W(_,s,v),ae(r,_,v),W(_,a,v),d&&d.m(_,v),W(_,u,v),c=!0},p(_,v){(!c||v[0]&201326592)&&e!==(e=` `+(_[26]?`${_[26].length>30?`${_[26].slice(0,30)}...`:_[26]} | ${_[27]}`:`${_[27]}`)+` `)&&(Ro.title=e);const p={};v[0]&256&&(p.title=_[8]),v[0]&512&&(p.message=_[9]),v[0]&1024&&(p.input=_[10]),v[0]&2048&&(p.inputPlaceholder=_[11]),v[0]&4096&&(p.inputValue=_[12]),!i&&v[0]&128&&(i=!0,p.show=_[7],nt(()=>i=!1)),r.$set(p),!_[0]||_[3]&&_[0]?d?(d.p(_,v),v[0]&9&&P(d,1)):(d=Mr(_),d.c(),P(d,1),d.m(u.parentNode,u)):d&&(je(),B(d,1,1,()=>{d=null}),Ye())},i(_){c||(P(r.$$.fragment,_),P(d),c=!0)},o(_){B(r.$$.fragment,_),B(d),c=!1},d(_){_&&(b(t),b(l),b(s),b(a),b(u)),ue(r,_),d&&d.d(_)}}}function q_(n,e,t){let l,o,s,r,i,a,u,c,f,h,d,_,v,p,g,y;se(n,nl,Z=>t(70,l=Z)),se(n,fu,Z=>t(71,o=Z)),se(n,ol,Z=>t(23,s=Z)),se(n,Fn,Z=>t(24,r=Z)),se(n,Sl,Z=>t(25,a=Z)),se(n,El,Z=>t(73,u=Z)),se(n,rl,Z=>t(74,c=Z)),se(n,du,Z=>t(75,f=Z)),se(n,Il,Z=>t(76,h=Z)),se(n,nu,Z=>t(77,d=Z)),se(n,vo,Z=>t(78,_=Z)),se(n,Jl,Z=>t(26,v=Z)),se(n,Fr,Z=>t(27,p=Z)),se(n,uo,Z=>t(28,g=Z)),se(n,hu,Z=>t(29,y=Z));const k=Lt("i18n");se(n,k,Z=>t(72,i=Z));let{chatIdProp:w=""}=e,N=!1;const S=new EventTarget;let A,z=!1,M=!0,V,L=!1,Y="",K="",E=!1,q="",D="",U=null,F,C=[""],R,G=[],J=[],oe=!1,ee=null,j={messages:{},currentId:null},ge="",x=[],ye=[],ie={};const Ie=async Z=>{const ve=JSON.parse(JSON.stringify(s));let pe=JSON.parse(JSON.stringify(Z.id)),be=j.messages[pe].childrenIds;for(;be.length!==0;)pe=be.at(-1),be=j.messages[pe].childrenIds;t(18,j.currentId=pe,j),await Je(),await Je(),await Je();const Me=document.getElementById(`message-${Z.id}`);Me&&Me.scrollIntoView({behavior:"smooth"}),await Je(),He(ve)},Te=async(Z,ve)=>{var pe,be;if(Z.chat_id===s){await Je(),console.log(Z);let Me=j.messages[Z.message_id];const $=((pe=Z==null?void 0:Z.data)==null?void 0:pe.type)??null,We=((be=Z==null?void 0:Z.data)==null?void 0:be.data)??null;if($==="status")Me!=null&&Me.statusHistory?Me.statusHistory.push(We):Me.statusHistory=[We];else if($==="citation")Me!=null&&Me.citations?Me.citations.push(We):Me.citations=[We];else if($==="message")Me.content+=We.content;else if($==="replace")Me.content=We.content;else if($==="action"){if(We.action==="continue"){const Re=document.getElementById("continue-response-button");Re&&Re.click()}}else $==="confirmation"?(t(13,U=ve),t(10,E=!1),t(7,L=!0),t(8,Y=We.title),t(9,K=We.message)):$==="input"?(t(13,U=ve),t(10,E=!0),t(7,L=!0),t(8,Y=We.title),t(9,K=We.message),t(11,q=We.placeholder),t(12,D=(We==null?void 0:We.value)??"")):console.log("Unknown message type",We);t(18,j.messages[Z.message_id]=Me,j)}},Fe=async Z=>{if(Z.origin===window.origin){if(Z.data.type==="input:prompt"){console.debug(Z.data.text);const ve=document.getElementById("chat-textarea");ve&&(t(19,ge=Z.data.text),ve.focus())}Z.data.type==="action:submit"&&(console.debug(Z.data.text),ge!==""&&(await Je(),Nt(ge))),Z.data.type==="input:prompt:submit"&&(console.debug(Z.data.text),ge!==""&&(await Je(),Nt(Z.data.text)))}};un(async()=>{window.addEventListener("message",Fe),f==null||f.on("chat-events",Te),s?o&&await To("/"):F=ol.subscribe(async ve=>{ve||await rt()}),qt.subscribe(async ve=>{if(A&&!_)try{if(ve){if(A.getSize()===0){const be=parseInt((localStorage==null?void 0:localStorage.chatControlsSize)??"30");A.resize(be||30)}}else A.resize(0)}catch{}ve||(rl.set(!1),Hl.set(!1))});const Z=document.getElementById("chat-textarea");Z==null||Z.focus(),ll.subscribe(()=>{})}),qn(()=>{F==null||F(),window.removeEventListener("message",Fe),f==null||f.off("chat-events")});const rt=async()=>{var pe,be;d.url.pathname.includes("/c/")&&window.history.replaceState(j.state,"","/"),t(5,M=!0),await ol.set(""),await Jl.set(""),t(18,j={messages:{},currentId:null}),t(20,x=[]),t(22,ie={}),d.url.searchParams.get("models")?t(1,C=(pe=d.url.searchParams.get("models"))==null?void 0:pe.split(",")):d.url.searchParams.get("model")?t(1,C=(be=d.url.searchParams.get("model"))==null?void 0:be.split(",")):r!=null&&r.models?t(1,C=r==null?void 0:r.models):u!=null&&u.default_models?(console.log((u==null?void 0:u.default_models.split(","))??""),t(1,C=u==null?void 0:u.default_models.split(","))):t(1,C=[""]),d.url.searchParams.get("web-search")==="true"&&t(16,oe=!0),d.url.searchParams.get("q")&&(t(19,ge=d.url.searchParams.get("q")??""),t(15,J=(d.url.searchParams.get("tool_ids")??"").split(",").map(Me=>Me.trim()).filter(Me=>Me)),ge&&(await Je(),Nt(ge))),d.url.searchParams.get("call")==="true"&&(rl.set(!0),qt.set(!0)),t(1,C=C.map(Me=>a.map($=>$.id).includes(Me)?Me:""));const Z=await bs(localStorage.token);Z?Fn.set(Z.ui):Fn.set(JSON.parse(localStorage.getItem("settings")??"{}"));const ve=document.getElementById("chat-textarea");setTimeout(()=>ve==null?void 0:ve.focus(),0)},de=async()=>{if(ol.set(w),t(17,ee=await Iu(localStorage.token,s).catch(async Z=>(await To("/"),null))),ee){await X();const Z=ee.chat;if(Z){console.log(Z),t(1,C=((Z==null?void 0:Z.models)??void 0)!==void 0?Z.models:[Z.models??""]),t(18,j=((Z==null?void 0:Z.history)??void 0)!==void 0?Z.history:wu(Z.messages)),Jl.set(Z.title);const ve=await bs(localStorage.token);return ve?await Fn.set(ve.ui):await Fn.set(JSON.parse(localStorage.getItem("settings")??"{}")),t(22,ie=(Z==null?void 0:Z.params)??{}),t(20,x=(Z==null?void 0:Z.files)??[]),t(5,M=!0),await Je(),j.currentId&&t(18,j.messages[j.currentId].done=!0,j),await Je(),!0}else return null}},Ge=async()=>{await Je(),V&&t(6,V.scrollTop=V.scrollHeight,V)},Ke=Z=>{if(Z===null)return[];const ve=j.messages[Z];return ve!=null&&ve.parentId?[...Ke(ve.parentId),ve]:[ve]},Vt=async(Z,ve,pe,be)=>{await qa.run({querySelector:".mermaid"});const Me=await Uu(localStorage.token,{model:ve,messages:be.map($=>({id:$.id,role:$.role,content:$.content,info:$.info?$.info:void 0,timestamp:$.timestamp})),chat_id:Z,session_id:f==null?void 0:f.id,id:pe}).catch($=>($e.error($),be.at(-1).error={content:$},null));if(Me!==null)for(const $ of Me.messages)t(18,j.messages[$.id]={...j.messages[$.id],...j.messages[$.id].content!==$.content?{originalContent:j.messages[$.id].content}:{},...$},j);await Je(),s==Z&&(o||(t(17,ee=await $l(localStorage.token,Z,{models:C,messages:be,history:j,params:ie,files:x})),nl.set(1),await ll.set(await cl(localStorage.token,l))))},Bt=async(Z,ve,pe,be,Me=null)=>{const $=Ke(be),We=await Wu(localStorage.token,ve,{model:pe,messages:$.map(Re=>({id:Re.id,role:Re.role,content:Re.content,info:Re.info?Re.info:void 0,timestamp:Re.timestamp})),...Me?{event:Me}:{},chat_id:Z,session_id:f==null?void 0:f.id,id:be}).catch(Re=>($e.error(Re),$.at(-1).error={content:Re},null));if(We!==null)for(const Re of We.messages)t(18,j.messages[Re.id]={...j.messages[Re.id],...j.messages[Re.id].content!==Re.content?{originalContent:j.messages[Re.id].content}:{},...Re},j);s==Z&&(o||(t(17,ee=await $l(localStorage.token,Z,{models:C,messages:$,history:j,params:ie,files:x})),nl.set(1),await ll.set(await cl(localStorage.token,l))))},yt=async(Z,ve="")=>setInterval(()=>{f==null||f.emit("usage",{action:"chat",model:Z,chat_id:ve})},1e3),Yt=async Z=>{if(t(19,ge=""),C.length===0)$e.error(i.t("Model not selected"));else{const ve=C[0],pe=a.filter(st=>st.id===ve).at(0),be=Ke(j.currentId),Me=be.length!==0?be.at(-1):null,$=Ql(),We=Ql(),Re={id:$,parentId:Me?Me.id:null,childrenIds:[We],role:"user",content:Z||`[PROMPT] ${$}`,timestamp:Math.floor(Date.now()/1e3)},ft={id:We,parentId:$,childrenIds:[],role:"assistant",content:`[RESPONSE] ${We}`,done:!0,model:ve,modelName:pe.name??pe.id,modelIdx:0,timestamp:Math.floor(Date.now()/1e3)};Me&&(Me.childrenIds.push($),t(18,j.messages[Me.id]=Me,j)),t(18,j.messages[$]=Re,j),t(18,j.messages[We]=ft,j),t(18,j.currentId=We,j),await Je(),M&&Ge(),be.length===0?await me():await He(s)}},Nt=async(Z,{_raw:ve=!1}={})=>{var Me,$,We;let pe=[];console.log("submitPrompt",s);const be=Ke(j.currentId);if(t(1,C=C.map(Re=>a.map(ft=>ft.id).includes(Re)?Re:"")),C.includes(""))$e.error(i.t("Model not selected"));else if(be.length!=0&&be.at(-1).done!=!0)console.log("wait");else if(be.length!=0&&be.at(-1).error)$e.error(i.t("Oops! There was an error in the previous response. Please try again or contact admin."));else if(ye.length>0&&ye.filter(Re=>Re.type!=="image"&&Re.status!=="processed").length>0)$e.error(i.t("Oops! Hold tight! Your files are still in the processing oven. We're cooking them up to perfection. Please be patient and we'll let you know once they're ready."));else if((((Me=u==null?void 0:u.file)==null?void 0:Me.max_count)??null)!==null&&ye.length+x.length>(($=u==null?void 0:u.file)==null?void 0:$.max_count))console.log(x.length,ye.length),$e.error(i.t("You can only chat with a maximum of {{maxCount}} file(s) at a time.",{maxCount:(We=u==null?void 0:u.file)==null?void 0:We.max_count}));else{const Re=document.getElementById("chat-textarea");Re&&(Re.value="",Re.style.height="");const ft=JSON.parse(JSON.stringify(ye));x.push(...ft.filter(it=>["doc","file","collection"].includes(it.type))),t(20,x=x.filter((it,Ct,Q)=>Q.findIndex(bt=>JSON.stringify(bt)===JSON.stringify(it))===Ct)),t(21,ye=[]),t(19,ge="");let st=Ql(),Et={id:st,parentId:be.length!==0?be.at(-1).id:null,childrenIds:[],role:"user",content:Z,files:ft.length>0?ft:void 0,timestamp:Math.floor(Date.now()/1e3),models:C};t(18,j.messages[st]=Et,j),t(18,j.currentId=st,j),be.length!==0&&j.messages[be.at(-1).id].childrenIds.push(st),await Je(),pe=await Ot(Z,st,{newChat:!0})}return pe},Ot=async(Z,ve,{modelId:pe=null,modelIdx:be=null,newChat:Me=!1}={})=>{Me&&j.messages[j.currentId].parentId===null&&j.messages[j.currentId].role==="user"&&await me();let $=[],We=pe?[pe]:R!==void 0?[R.id]:C;const Re={};for(const[st,Et]of We.entries()){const it=a.filter(Ct=>Ct.id===Et).at(0);if(it){let Ct=Ql(),Q={parentId:ve,id:Ct,childrenIds:[],role:"assistant",content:"",model:it.id,modelName:it.name??it.id,modelIdx:be||st,userContext:null,timestamp:Math.floor(Date.now()/1e3)};t(18,j.messages[Ct]=Q,j),t(18,j.currentId=Ct,j),ve!==null&&t(18,j.messages[ve].childrenIds=[...j.messages[ve].childrenIds,Ct],j),Re[`${Et}-${be||st}`]=Ct}}await Je();const ft=JSON.parse(JSON.stringify(s));return await Promise.all(We.map(async(st,Et)=>{var Ct,Q,bt;console.log("modelId",st);const it=a.filter(ct=>ct.id===st).at(0);if(it){Ke(ve).some(sn=>{var Qt;return(Qt=sn.files)==null?void 0:Qt.some(kn=>kn.type==="image")})&&!(((bt=(Q=(Ct=it.info)==null?void 0:Ct.meta)==null?void 0:Q.capabilities)==null?void 0:bt.vision)??!0)&&$e.error(i.t("Model {{modelName}} is not vision capable",{modelName:it.name??it.id}));let gn=Re[`${st}-${be||Et}`],An=j.messages[gn],on=null;if(((r==null?void 0:r.memory)??!1)&&on===null){const sn=await Lu(localStorage.token,Z).catch(Qt=>($e.error(Qt),null));sn&&(sn.documents[0].length>0&&(on=sn.documents[0].reduce((Qt,kn,_n)=>{const Bn=sn.metadatas[0][_n].created_at,En=new Date(Bn*1e3).toISOString().split("T")[0];return`${Qt}${_n+1}. [${En}]. ${kn} `},"")),console.log(on))}An.userContext=on;const Jt=await yt(it.id,ft);Ge(),oe&&await Ne(it.id,ve,gn);let dn=null;(it==null?void 0:it.owned_by)==="openai"?dn=await Kt(it,Z,gn,ft):it&&(dn=await Dt(it,Z,gn,ft)),$.push(dn),Jt&&clearInterval(Jt)}else $e.error(i.t("Model {{modelId}} not found",{modelId:st}))})),nl.set(1),ll.set(await cl(localStorage.token,l)),$},Dt=async(Z,ve,pe,be)=>{var ct,zn,gn,An,on,Jt,dn,sn,Qt,kn,_n,Bn,En,Qn,hn,Rn;let Me=null;const $=j.messages[pe],We=j.messages[$.parentId];await Je(),Ge();const Re=[ie!=null&&ie.system||r.system||(($==null?void 0:$.userContext)??null)?{role:"system",content:`${_s((ie==null?void 0:ie.system)??(r==null?void 0:r.system)??"",h.name,r!=null&&r.userLocation?await ps(localStorage.token):void 0)}${($==null?void 0:$.userContext)??null?` User Context: ${($==null?void 0:$.userContext)??""}`:""}`}:void 0,...Ke(pe)].filter(xe=>{var kt;return(kt=xe==null?void 0:xe.content)==null?void 0:kt.trim()}).map(xe=>{var an;const kt={role:xe.role,content:xe.content},rn=(an=xe.files)==null?void 0:an.filter(ot=>ot.type==="image").map(ot=>ot.url.slice(ot.url.indexOf(",")+1));return rn&&rn.length>0&&xe.role==="user"&&(kt.images=rn),kt});let ft=-1;Re.forEach((xe,kt)=>{xe.images&&(ft=kt)}),Re.forEach((xe,kt)=>{kt!==ft&&delete xe.images});let st=JSON.parse(JSON.stringify(x));(((zn=(ct=Z==null?void 0:Z.info)==null?void 0:ct.meta)==null?void 0:zn.knowledge)??!1)&&($.statusHistory=[{action:"knowledge_search",description:i.t('Searching Knowledge for "{{searchQuery}}"',{searchQuery:We.content}),done:!1}],st.push(...Z.info.meta.knowledge),t(18,j.messages[pe]=$,j)),st.push(...((We==null?void 0:We.files)??[]).filter(xe=>["doc","file","collection"].includes(xe.type)),...(($==null?void 0:$.files)??[]).filter(xe=>["web_search_results"].includes(xe.type))),Ge(),S.dispatchEvent(new CustomEvent("chat:start",{detail:{id:pe}})),await Je();const Et=((An=(gn=Z==null?void 0:Z.info)==null?void 0:gn.params)==null?void 0:An.stream_response)??((on=r==null?void 0:r.params)==null?void 0:on.stream_response)??(ie==null?void 0:ie.stream_response)??!0,[it,Ct]=await ku(localStorage.token,{stream:Et,model:Z.id,messages:Re,options:{...(r==null?void 0:r.params)??{},...ie,stop:(ie==null?void 0:ie.stop)??((Jt=r==null?void 0:r.params)==null?void 0:Jt.stop)??void 0?((ie==null?void 0:ie.stop.split(",").map(xe=>xe.trim()))??r.params.stop).map(xe=>decodeURIComponent(JSON.parse('"'+xe.replace(/\"/g,'\\"')+'"'))):void 0,num_predict:(ie==null?void 0:ie.max_tokens)??((dn=r==null?void 0:r.params)==null?void 0:dn.max_tokens)??void 0,repeat_penalty:(ie==null?void 0:ie.frequency_penalty)??((sn=r==null?void 0:r.params)==null?void 0:sn.frequency_penalty)??void 0},format:r.requestFormat??void 0,keep_alive:r.keepAlive??void 0,tool_ids:J.length>0?J:void 0,files:st.length>0?st:void 0,session_id:f==null?void 0:f.id,chat_id:s,id:pe});if(it&&it.ok)if(Et){console.log("controller",Ct);const xe=it.body.pipeThrough(new TextDecoderStream).pipeThrough(yu(` `)).getReader();for(;;){const{value:kt,done:rn}=await xe.read();if(rn||z||be!==s){$.done=!0,t(18,j.messages[pe]=$,j),z&&Ct.abort("User: Stop Response"),Me=$.content;break}try{let an=kt.split(` `);for(const ot of an)if(ot!==""){console.log(ot);let vt=JSON.parse(ot);if("citations"in vt){$.citations=vt.citations,(((kn=(Qt=Z==null?void 0:Z.info)==null?void 0:Qt.meta)==null?void 0:kn.knowledge)??!1)&&($.statusHistory=$.statusHistory.filter(Ft=>Ft.action!=="knowledge_search"));continue}if("detail"in vt)throw vt;if(vt.done==!1){if($.content==""&&vt.message.content==` `)continue;{$.content+=vt.message.content,navigator.vibrate&&((r==null?void 0:r.hapticFeedback)??!1)&&navigator.vibrate(5);const Ft=xl($.content,((Bn=(_n=u==null?void 0:u.audio)==null?void 0:_n.tts)==null?void 0:Bn.split_on)??"punctuation");Ft.pop(),Ft.length>0&&Ft[Ft.length-1]!==$.lastSentence&&($.lastSentence=Ft[Ft.length-1],S.dispatchEvent(new CustomEvent("chat",{detail:{id:pe,content:Ft[Ft.length-1]}}))),t(18,j.messages[pe]=$,j)}}else{if($.done=!0,$.content==""&&($.error={code:400,content:"Oops! No text generated from Ollama, Please try again."}),$.context=vt.context??null,$.info={total_duration:vt.total_duration,load_duration:vt.load_duration,sample_count:vt.sample_count,sample_duration:vt.sample_duration,prompt_eval_count:vt.prompt_eval_count,prompt_eval_duration:vt.prompt_eval_duration,eval_count:vt.eval_count,eval_duration:vt.eval_duration},t(18,j.messages[pe]=$,j),r.notificationEnabled&&!document.hasFocus()){const Ft=new Notification(`${Z.id}`,{body:$.content,icon:`${Nl}/static/favicon.png`})}((r==null?void 0:r.responseAutoCopy)??!1)&&Uo($.content),r.responseAutoPlayback&&!c&&(await Je(),(En=document.getElementById(`speak-button-${$.id}`))==null||En.click())}}}catch(an){console.log(an),"detail"in an&&$e.error(an.detail);break}M&&Ge()}}else{const xe=await it.json();console.log(xe),$.content=xe.message.content,$.info={eval_count:xe.eval_count,eval_duration:xe.eval_duration,load_duration:xe.load_duration,prompt_eval_count:xe.prompt_eval_count,prompt_eval_duration:xe.prompt_eval_duration,total_duration:xe.total_duration},$.done=!0}else{if(it!==null){const xe=await it.json();console.log(xe),"detail"in xe?($e.error(xe.detail),$.error={content:xe.detail}):($e.error(xe.error),$.error={content:xe.error})}else $e.error(i.t("Uh-oh! There was an issue connecting to {{provider}}.",{provider:"Ollama"})),$.error={content:i.t("Uh-oh! There was an issue connecting to {{provider}}.",{provider:"Ollama"})};$.done=!0,$.statusHistory&&($.statusHistory=$.statusHistory.filter(xe=>xe.action!=="knowledge_search"))}await He(be),t(18,j.messages[pe]=$,j),await Vt(be,Z.id,pe,Ke(pe)),z=!1,await Je();let Q=((Rn=xl($.content,((hn=(Qn=u==null?void 0:u.audio)==null?void 0:Qn.tts)==null?void 0:hn.split_on)??"punctuation"))==null?void 0:Rn.at(-1))??"";Q&&S.dispatchEvent(new CustomEvent("chat",{detail:{id:pe,content:Q}})),S.dispatchEvent(new CustomEvent("chat:finish",{detail:{id:pe,content:$.content}})),M&&Ge();const bt=Ke(pe);if(bt.length==2&&bt.at(-1).content!==""&&C[0]===Z.id){window.history.replaceState(j.state,"",`/c/${be}`);const xe=await Wt(ve);await fe(be,xe)}return Me},Kt=async(Z,ve,pe,be)=>{var Et,it,Ct,Q,bt,ct,zn,gn,An,on,Jt,dn,sn,Qt,kn,_n,Bn,En,Qn,hn,Rn,xe;let Me=null;const $=j.messages[pe],We=j.messages[$.parentId];let Re=JSON.parse(JSON.stringify(x));(((it=(Et=Z==null?void 0:Z.info)==null?void 0:Et.meta)==null?void 0:it.knowledge)??!1)&&($.statusHistory=[{action:"knowledge_search",description:i.t('Searching Knowledge for "{{searchQuery}}"',{searchQuery:We.content}),done:!1}],Re.push(...Z.info.meta.knowledge),t(18,j.messages[pe]=$,j)),Re.push(...((We==null?void 0:We.files)??[]).filter(kt=>["doc","file","collection"].includes(kt.type)),...(($==null?void 0:$.files)??[]).filter(kt=>["web_search_results"].includes(kt.type))),Ge(),S.dispatchEvent(new CustomEvent("chat:start",{detail:{id:pe}})),await Je();try{const kt=((Q=(Ct=Z==null?void 0:Z.info)==null?void 0:Ct.params)==null?void 0:Q.stream_response)??((bt=r==null?void 0:r.params)==null?void 0:bt.stream_response)??(ie==null?void 0:ie.stream_response)??!0,[rn,an]=await Du(localStorage.token,{stream:kt,model:Z.id,...kt&&(((gn=(zn=(ct=Z.info)==null?void 0:ct.meta)==null?void 0:zn.capabilities)==null?void 0:gn.usage)??!1)?{stream_options:{include_usage:!0}}:{},messages:[ie!=null&&ie.system||r.system||(($==null?void 0:$.userContext)??null)?{role:"system",content:`${_s((ie==null?void 0:ie.system)??(r==null?void 0:r.system)??"",h.name,r!=null&&r.userLocation?await ps(localStorage.token):void 0)}${($==null?void 0:$.userContext)??null?` User Context: ${($==null?void 0:$.userContext)??""}`:""}`}:void 0,...Ke(pe)].filter(ot=>{var vt;return(vt=ot==null?void 0:ot.content)==null?void 0:vt.trim()}).map((ot,vt,Ft)=>{var tl;return{role:ot.role,...((tl=ot.files)==null?void 0:tl.filter(Mn=>Mn.type==="image").length)>0&&ot.role==="user"?{content:[{type:"text",text:Ft.length-1!==vt?ot.content:(ot==null?void 0:ot.raContent)??ot.content},...ot.files.filter(Mn=>Mn.type==="image").map(Mn=>({type:"image_url",image_url:{url:Mn.url}}))]}:{content:Ft.length-1!==vt?ot.content:(ot==null?void 0:ot.raContent)??ot.content}}}),seed:(ie==null?void 0:ie.seed)??((An=r==null?void 0:r.params)==null?void 0:An.seed)??void 0,stop:(ie==null?void 0:ie.stop)??((on=r==null?void 0:r.params)==null?void 0:on.stop)??void 0?((ie==null?void 0:ie.stop.split(",").map(ot=>ot.trim()))??r.params.stop).map(ot=>decodeURIComponent(JSON.parse('"'+ot.replace(/\"/g,'\\"')+'"'))):void 0,temperature:(ie==null?void 0:ie.temperature)??((Jt=r==null?void 0:r.params)==null?void 0:Jt.temperature)??void 0,top_p:(ie==null?void 0:ie.top_p)??((dn=r==null?void 0:r.params)==null?void 0:dn.top_p)??void 0,frequency_penalty:(ie==null?void 0:ie.frequency_penalty)??((sn=r==null?void 0:r.params)==null?void 0:sn.frequency_penalty)??void 0,max_tokens:(ie==null?void 0:ie.max_tokens)??((Qt=r==null?void 0:r.params)==null?void 0:Qt.max_tokens)??void 0,tool_ids:J.length>0?J:void 0,files:Re.length>0?Re:void 0,session_id:f==null?void 0:f.id,chat_id:s,id:pe},`${Nl}/api`);if(await Je(),Ge(),rn&&rn.ok&&rn.body){if(kt){const ot=await Ls(rn.body,r.splitLargeChunks);for await(const vt of ot){const{value:Ft,done:tl,citations:Mn,error:Dl,usage:zl}=vt;if(Dl){await _e(Dl,null,Z,$);break}if(tl||z||be!==s){$.done=!0,t(18,j.messages[pe]=$,j),z&&an.abort("User: Stop Response"),Me=$.content;break}if(zl&&($.info={...zl,openai:!0}),Mn){$.citations=Mn,(((_n=(kn=Z==null?void 0:Z.info)==null?void 0:kn.meta)==null?void 0:_n.knowledge)??!1)&&($.statusHistory=$.statusHistory.filter(xt=>xt.action!=="knowledge_search"));continue}if(!($.content==""&&Ft==` `)){{$.content+=Ft,navigator.vibrate&&((r==null?void 0:r.hapticFeedback)??!1)&&navigator.vibrate(5);const xt=xl($.content,((En=(Bn=u==null?void 0:u.audio)==null?void 0:Bn.tts)==null?void 0:En.split_on)??"punctuation");xt.pop(),xt.length>0&&xt[xt.length-1]!==$.lastSentence&&($.lastSentence=xt[xt.length-1],S.dispatchEvent(new CustomEvent("chat",{detail:{id:pe,content:xt[xt.length-1]}}))),t(18,j.messages[pe]=$,j)}M&&Ge()}}}else{const ot=await rn.json();console.log(ot),$.content=ot.choices[0].message.content,$.info={...ot.usage,openai:!0},$.done=!0}if(r.notificationEnabled&&!document.hasFocus()){const ot=new Notification(`${Z.id}`,{body:$.content,icon:`${Nl}/static/favicon.png`})}r.responseAutoCopy&&Uo($.content),r.responseAutoPlayback&&!c&&(await Je(),(Qn=document.getElementById(`speak-button-${$.id}`))==null||Qn.click())}else await _e(null,rn,Z,$)}catch(kt){await _e(kt,null,Z,$)}await He(be),t(18,j.messages[pe]=$,j),await Vt(be,Z.id,pe,Ke(pe)),z=!1,await Je();let ft=((xe=xl($.content,((Rn=(hn=u==null?void 0:u.audio)==null?void 0:hn.tts)==null?void 0:Rn.split_on)??"punctuation"))==null?void 0:xe.at(-1))??"";if(ft&&S.dispatchEvent(new CustomEvent("chat",{detail:{id:pe,content:ft}})),S.dispatchEvent(new CustomEvent("chat:finish",{detail:{id:pe,content:$.content}})),M&&Ge(),Ke(pe).length==2&&C[0]===Z.id){window.history.replaceState(j.state,"",`/c/${be}`);const kt=await Wt(ve);await fe(be,kt)}return Me},_e=async(Z,ve,pe,be)=>{let Me="",$;Z?$=Z:ve!==null&&($=await ve.json()),console.error($),"detail"in $?($e.error($.detail),Me=$.detail):"error"in $?"message"in $.error?($e.error($.error.message),Me=$.error.message):($e.error($.error),Me=$.error):"message"in $&&($e.error($.message),Me=$.message),be.error={content:i.t("Uh-oh! There was an issue connecting to {{provider}}.",{provider:pe.name??pe.id})+` `+Me},be.done=!0,be.statusHistory&&(be.statusHistory=be.statusHistory.filter(We=>We.action!=="knowledge_search")),t(18,j.messages[be.id]=be,j)},Ht=()=>{z=!0,console.log("stopResponse")},wt=async Z=>{if(console.log("regenerateResponse"),j.currentId){let ve=j.messages[Z.parentId],pe=ve.content;((ve==null?void 0:ve.models)??[...C]).length==1?await Ot(pe,ve.id):await Ot(pe,ve.id,{modelId:Z.model,modelIdx:Z.modelIdx})}},St=async()=>{console.log("continueResponse");const Z=JSON.parse(JSON.stringify(s));if(j.currentId&&j.messages[j.currentId].done==!0){const ve=j.messages[j.currentId];ve.done=!1,await Je();const pe=a.filter(be=>be.id===ve.model).at(0);pe&&((pe==null?void 0:pe.owned_by)==="openai"?await Kt(pe,j.messages[ve.parentId].content,ve.id,Z):await Dt(pe,j.messages[ve.parentId].content,ve.id,Z))}else $e.error(i.t("Model {{modelId}} not found",{modelId}))},Ce=async(Z,ve,pe)=>{console.log("mergeResponses",Z,ve);const be=j.messages[Z],Me={status:!0,content:""};be.merged=Me,t(18,j.messages[Z]=be,j);try{const[$,We]=await Fu(localStorage.token,be.model,j.messages[be.parentId].content,ve);if($&&$.ok&&$.body){const Re=await Ls($.body,r.splitLargeChunks);for await(const ft of Re){const{value:st,done:Et,citations:it,error:Ct,usage:Q}=ft;if(Ct||Et)break;Me.content==""&&st==` `||(Me.content+=st,t(18,j.messages[Z]=be,j),M&&Ge())}await He(pe)}else console.error($)}catch($){console.error($)}},Wt=async Z=>{var ve;return((ve=r==null?void 0:r.title)==null?void 0:ve.auto)??!0?await Bu(localStorage.token,C[0],Z,s).catch(be=>(console.error(be),"New Chat")):`${Z}`},fe=async(Z,ve)=>{Z===s&&Jl.set(ve),o||(t(17,ee=await $l(localStorage.token,Z,{title:ve})),nl.set(1),await ll.set(await cl(localStorage.token,l)))},Ne=async(Z,ve,pe)=>{const be=j.messages[pe],Me=j.messages[ve],$=Ke(j.currentId);be.statusHistory=[{done:!1,action:"web_search",description:i.t("Generating search query")}],t(18,j.messages[pe]=be,j);const We=Me.content;let Re=await Ru(localStorage.token,Z,$.filter(st=>{var Et;return(Et=st==null?void 0:st.content)==null?void 0:Et.trim()}),We).catch(st=>(console.log(st),We));if(!Re||Re==""){be.statusHistory.push({done:!0,error:!0,action:"web_search",description:i.t("No search query generated")}),t(18,j.messages[pe]=be,j);return}be.statusHistory.push({done:!1,action:"web_search",description:i.t('Searching "{{searchQuery}}"',{searchQuery:Re})}),t(18,j.messages[pe]=be,j);const ft=await Vu(localStorage.token,Re).catch(st=>(console.log(st),$e.error(st),null));ft?(be.statusHistory.push({done:!0,action:"web_search",description:i.t("Searched {{count}} sites",{count:ft.filenames.length}),query:Re,urls:ft.filenames}),((be==null?void 0:be.files)??!0)&&(be.files=[]),be.files.push({collection_name:ft.collection_name,name:Re,type:"web_search_results",urls:ft.filenames}),t(18,j.messages[pe]=be,j)):(be.statusHistory.push({done:!0,error:!0,action:"web_search",description:"No search results found"}),t(18,j.messages[pe]=be,j))},X=async()=>await Cu(localStorage.token,s).catch(async Z=>[]),me=async()=>{o?await ol.set("local"):(t(17,ee=await Su(localStorage.token,{id:s,title:i.t("New Chat"),models:C,system:r.system??void 0,params:ie,history:j,tags:[],timestamp:Date.now()})),nl.set(1),await ll.set(await cl(localStorage.token,l)),await ol.set(ee.id)),await Je()},He=async Z=>{s==Z&&(o||(t(17,ee=await $l(localStorage.token,Z,{models:C,history:j,messages:Ke(j.currentId),params:ie,files:x})),nl.set(1),await ll.set(await cl(localStorage.token,l))))};function Xe(Z){L=Z,t(7,L)}const Ue=Z=>{Z.detail?U(Z.detail):U(!0)},qe=()=>{U(!1)};function It(Z){C=Z,t(1,C)}const Zt=Z=>Z.dismissible?!JSON.parse(localStorage.getItem("dismissedBannerIds")??"[]").includes(Z.id):!0,Gt=Z=>{const ve=Z.detail;localStorage.setItem("dismissedBannerIds",JSON.stringify([ve,...JSON.parse(localStorage.getItem("dismissedBannerIds")??"[]")].filter(pe=>y.find(be=>be.id===pe))))};function tn(Z){j=Z,t(18,j)}function cn(Z){M=Z,t(5,M)}function vn(Z){ge=Z,t(19,ge)}function mn(Z){Be[Z?"unshift":"push"](()=>{V=Z,t(6,V)})}const yn=Z=>{t(5,M=V.scrollHeight-V.scrollTop<=V.clientHeight+5)},On=(Z,ve,pe,be)=>{var $,We;const Me=a.find(Re=>Re.id===ve);return((We=($=Me==null?void 0:Me.info)==null?void 0:$.meta)==null?void 0:We.toolIds)??!1?[...new Set([...Z,...Me.info.meta.toolIds])]:Z};function Tt(Z){ye=Z,t(21,ye)}function ln(Z){ge=Z,t(19,ge)}function fn(Z){M=Z,t(5,M)}function Hn(Z){J=Z,t(15,J)}function Yn(Z){oe=Z,t(16,oe)}function Jn(Z){R=Z,t(2,R)}const $n=async()=>{await qt.set(!0)},Dn=(Z,ve,pe,be)=>{const Me=a.find($=>$.id===ve);return Me?[...Z,Me]:Z};function ul(Z){j=Z,t(18,j)}function el(Z){x=Z,t(20,x)}function wn(Z){ie=Z,t(22,ie)}function Ln(Z){ye=Z,t(21,ye)}function Xn(Z){A=Z,t(4,A)}return n.$$set=Z=>{"chatIdProp"in Z&&t(0,w=Z.chatIdProp)},n.$$.update=()=>{n.$$.dirty[0]&6&&t(14,G=R!==void 0?[R.id]:C),n.$$.dirty[0]&1&&w&&(async()=>{if(console.log(w),w&&await de()){await Je(),t(3,N=!0),window.setTimeout(()=>Ge(),0);const Z=document.getElementById("chat-textarea");Z==null||Z.focus()}else await To("/")})()},[w,C,R,N,A,M,V,L,Y,K,E,q,D,U,G,J,oe,ee,j,ge,x,ye,ie,s,r,a,v,p,g,y,k,S,Ie,rt,Bt,Yt,Nt,Ot,Ht,wt,St,Ce,Xe,Ue,qe,It,Zt,Gt,tn,cn,vn,mn,yn,On,Tt,ln,fn,Hn,Yn,Jn,$n,Dn,ul,el,wn,Ln,Xn]}class ib extends ke{constructor(e){super(),Ee(this,e,q_,G_,Se,{chatIdProp:0},null,[-1,-1,-1,-1])}}function J_(n){let e,t,l,o=n[1].t("Keyboard shortcuts")+"",s,r,i,a='',u,c,f,h,d,_,v=n[1].t("Open new chat")+"",p,g,y,k='
Ctrl/⌘
Shift
O
',w,N,S,A=n[1].t("Focus chat input")+"",z,M,V,L='
Shift
Esc
',Y,K,E,q=n[1].t("Copy last code block")+"",D,U,F,C='
Ctrl/⌘
Shift
;
',R,G,J,oe=n[1].t("Copy last response")+"",ee,j,ge,x='
Ctrl/⌘
Shift
C
',ye,ie,Ie,Te,Fe=n[1].t("Toggle settings")+"",rt,de,Ge,Ke='
Ctrl/⌘
.
',Vt,Bt,yt,Yt=n[1].t("Toggle sidebar")+"",Nt,Ot,Dt,Kt='
Ctrl/⌘
Shift
S
',_e,Ht,wt,St=n[1].t("Delete chat")+"",Ce,Wt,fe,Ne='
Ctrl/⌘
Shift
',X,me,He,Xe=n[1].t("Show shortcuts")+"",Ue,qe,It,Zt='
Ctrl/⌘
/
',Gt,tn,cn,vn=n[1].t("Input commands")+"",mn,yn,On,Tt,ln,fn,Hn,Yn=n[1].t("Attach file")+"",Jn,$n,Dn,ul='
#
',el,wn,Ln,Xn=n[1].t("Add custom prompt")+"",Z,ve,pe,be='
/
',Me,$,We,Re=n[1].t("Select model")+"",ft,st,Et,it='
@
',Ct,Q;return{c(){e=O("div"),t=O("div"),l=O("div"),s=De(o),r=te(),i=O("button"),i.innerHTML=a,u=te(),c=O("div"),f=O("div"),h=O("div"),d=O("div"),_=O("div"),p=De(v),g=te(),y=O("div"),y.innerHTML=k,w=te(),N=O("div"),S=O("div"),z=De(A),M=te(),V=O("div"),V.innerHTML=L,Y=te(),K=O("div"),E=O("div"),D=De(q),U=te(),F=O("div"),F.innerHTML=C,R=te(),G=O("div"),J=O("div"),ee=De(oe),j=te(),ge=O("div"),ge.innerHTML=x,ye=te(),ie=O("div"),Ie=O("div"),Te=O("div"),rt=De(Fe),de=te(),Ge=O("div"),Ge.innerHTML=Ke,Vt=te(),Bt=O("div"),yt=O("div"),Nt=De(Yt),Ot=te(),Dt=O("div"),Dt.innerHTML=Kt,_e=te(),Ht=O("div"),wt=O("div"),Ce=De(St),Wt=te(),fe=O("div"),fe.innerHTML=Ne,X=te(),me=O("div"),He=O("div"),Ue=De(Xe),qe=te(),It=O("div"),It.innerHTML=Zt,Gt=te(),tn=O("div"),cn=O("div"),mn=De(vn),yn=te(),On=O("div"),Tt=O("div"),ln=O("div"),fn=O("div"),Hn=O("div"),Jn=De(Yn),$n=te(),Dn=O("div"),Dn.innerHTML=ul,el=te(),wn=O("div"),Ln=O("div"),Z=De(Xn),ve=te(),pe=O("div"),pe.innerHTML=be,Me=te(),$=O("div"),We=O("div"),ft=De(Re),st=te(),Et=O("div"),Et.innerHTML=it,this.h()},l(bt){e=H(bt,"DIV",{class:!0});var ct=T(e);t=H(ct,"DIV",{class:!0});var zn=T(t);l=H(zn,"DIV",{class:!0});var gn=T(l);s=ze(gn,o),gn.forEach(b),r=ne(zn),i=H(zn,"BUTTON",{class:!0,"data-svelte-h":!0}),ut(i)!=="svelte-745w2y"&&(i.innerHTML=a),zn.forEach(b),u=ne(ct),c=H(ct,"DIV",{class:!0});var An=T(c);f=H(An,"DIV",{class:!0});var on=T(f);h=H(on,"DIV",{class:!0});var Jt=T(h);d=H(Jt,"DIV",{class:!0});var dn=T(d);_=H(dn,"DIV",{class:!0});var sn=T(_);p=ze(sn,v),sn.forEach(b),g=ne(dn),y=H(dn,"DIV",{class:!0,"data-svelte-h":!0}),ut(y)!=="svelte-lcmjz9"&&(y.innerHTML=k),dn.forEach(b),w=ne(Jt),N=H(Jt,"DIV",{class:!0});var Qt=T(N);S=H(Qt,"DIV",{class:!0});var kn=T(S);z=ze(kn,A),kn.forEach(b),M=ne(Qt),V=H(Qt,"DIV",{class:!0,"data-svelte-h":!0}),ut(V)!=="svelte-1c7wvdz"&&(V.innerHTML=L),Qt.forEach(b),Y=ne(Jt),K=H(Jt,"DIV",{class:!0});var _n=T(K);E=H(_n,"DIV",{class:!0});var Bn=T(E);D=ze(Bn,q),Bn.forEach(b),U=ne(_n),F=H(_n,"DIV",{class:!0,"data-svelte-h":!0}),ut(F)!=="svelte-1vgtrzt"&&(F.innerHTML=C),_n.forEach(b),R=ne(Jt),G=H(Jt,"DIV",{class:!0});var En=T(G);J=H(En,"DIV",{class:!0});var Qn=T(J);ee=ze(Qn,oe),Qn.forEach(b),j=ne(En),ge=H(En,"DIV",{class:!0,"data-svelte-h":!0}),ut(ge)!=="svelte-m149u9"&&(ge.innerHTML=x),En.forEach(b),Jt.forEach(b),ye=ne(on),ie=H(on,"DIV",{class:!0});var hn=T(ie);Ie=H(hn,"DIV",{class:!0});var Rn=T(Ie);Te=H(Rn,"DIV",{class:!0});var xe=T(Te);rt=ze(xe,Fe),xe.forEach(b),de=ne(Rn),Ge=H(Rn,"DIV",{class:!0,"data-svelte-h":!0}),ut(Ge)!=="svelte-1lfzi34"&&(Ge.innerHTML=Ke),Rn.forEach(b),Vt=ne(hn),Bt=H(hn,"DIV",{class:!0});var kt=T(Bt);yt=H(kt,"DIV",{class:!0});var rn=T(yt);Nt=ze(rn,Yt),rn.forEach(b),Ot=ne(kt),Dt=H(kt,"DIV",{class:!0,"data-svelte-h":!0}),ut(Dt)!=="svelte-1egz3pd"&&(Dt.innerHTML=Kt),kt.forEach(b),_e=ne(hn),Ht=H(hn,"DIV",{class:!0});var an=T(Ht);wt=H(an,"DIV",{class:!0});var ot=T(wt);Ce=ze(ot,St),ot.forEach(b),Wt=ne(an),fe=H(an,"DIV",{class:!0,"data-svelte-h":!0}),ut(fe)!=="svelte-1b065vn"&&(fe.innerHTML=Ne),an.forEach(b),X=ne(hn),me=H(hn,"DIV",{class:!0});var vt=T(me);He=H(vt,"DIV",{class:!0});var Ft=T(He);Ue=ze(Ft,Xe),Ft.forEach(b),qe=ne(vt),It=H(vt,"DIV",{class:!0,"data-svelte-h":!0}),ut(It)!=="svelte-714lzr"&&(It.innerHTML=Zt),vt.forEach(b),hn.forEach(b),on.forEach(b),An.forEach(b),Gt=ne(ct),tn=H(ct,"DIV",{class:!0});var tl=T(tn);cn=H(tl,"DIV",{class:!0});var Mn=T(cn);mn=ze(Mn,vn),Mn.forEach(b),tl.forEach(b),yn=ne(ct),On=H(ct,"DIV",{class:!0});var Dl=T(On);Tt=H(Dl,"DIV",{class:!0});var zl=T(Tt);ln=H(zl,"DIV",{class:!0});var xt=T(ln);fn=H(xt,"DIV",{class:!0});var Kl=T(fn);Hn=H(Kl,"DIV",{class:!0});var as=T(Hn);Jn=ze(as,Yn),as.forEach(b),$n=ne(Kl),Dn=H(Kl,"DIV",{class:!0,"data-svelte-h":!0}),ut(Dn)!=="svelte-11t0lmd"&&(Dn.innerHTML=ul),Kl.forEach(b),el=ne(xt),wn=H(xt,"DIV",{class:!0});var Zl=T(wn);Ln=H(Zl,"DIV",{class:!0});var us=T(Ln);Z=ze(us,Xn),us.forEach(b),ve=ne(Zl),pe=H(Zl,"DIV",{class:!0,"data-svelte-h":!0}),ut(pe)!=="svelte-1s9pky1"&&(pe.innerHTML=be),Zl.forEach(b),Me=ne(xt),$=H(xt,"DIV",{class:!0});var Gl=T($);We=H(Gl,"DIV",{class:!0});var cs=T(We);ft=ze(cs,Re),cs.forEach(b),st=ne(Gl),Et=H(Gl,"DIV",{class:!0,"data-svelte-h":!0}),ut(Et)!=="svelte-oivy56"&&(Et.innerHTML=it),Gl.forEach(b),xt.forEach(b),zl.forEach(b),Dl.forEach(b),ct.forEach(b),this.h()},h(){m(l,"class","text-lg font-medium self-center"),m(i,"class","self-center"),m(t,"class","flex justify-between dark:text-gray-300 px-5 pt-4"),m(_,"class","text-sm"),m(y,"class","flex space-x-1 text-xs"),m(d,"class","w-full flex justify-between items-center"),m(S,"class","text-sm"),m(V,"class","flex space-x-1 text-xs"),m(N,"class","w-full flex justify-between items-center"),m(E,"class","text-sm"),m(F,"class","flex space-x-1 text-xs"),m(K,"class","w-full flex justify-between items-center"),m(J,"class","text-sm"),m(ge,"class","flex space-x-1 text-xs"),m(G,"class","w-full flex justify-between items-center"),m(h,"class","flex flex-col space-y-3 w-full self-start"),m(Te,"class","text-sm"),m(Ge,"class","flex space-x-1 text-xs"),m(Ie,"class","w-full flex justify-between items-center"),m(yt,"class","text-sm"),m(Dt,"class","flex space-x-1 text-xs"),m(Bt,"class","w-full flex justify-between items-center"),m(wt,"class","text-sm"),m(fe,"class","flex space-x-1 text-xs"),m(Ht,"class","w-full flex justify-between items-center"),m(He,"class","text-sm"),m(It,"class","flex space-x-1 text-xs"),m(me,"class","w-full flex justify-between items-center"),m(ie,"class","flex flex-col space-y-3 w-full self-start"),m(f,"class","flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6"),m(c,"class","flex flex-col md:flex-row w-full p-5 md:space-x-4 dark:text-gray-200"),m(cn,"class","text-lg font-medium self-center"),m(tn,"class","flex justify-between dark:text-gray-300 px-5"),m(Hn,"class","text-sm"),m(Dn,"class","flex space-x-1 text-xs"),m(fn,"class","w-full flex justify-between items-center"),m(Ln,"class","text-sm"),m(pe,"class","flex space-x-1 text-xs"),m(wn,"class","w-full flex justify-between items-center"),m(We,"class","text-sm"),m(Et,"class","flex space-x-1 text-xs"),m($,"class","w-full flex justify-between items-center"),m(ln,"class","flex flex-col space-y-3 w-full self-start"),m(Tt,"class","flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6"),m(On,"class","flex flex-col md:flex-row w-full p-5 md:space-x-4 dark:text-gray-200"),m(e,"class","text-gray-700 dark:text-gray-100")},m(bt,ct){W(bt,e,ct),I(e,t),I(t,l),I(l,s),I(t,r),I(t,i),I(e,u),I(e,c),I(c,f),I(f,h),I(h,d),I(d,_),I(_,p),I(d,g),I(d,y),I(h,w),I(h,N),I(N,S),I(S,z),I(N,M),I(N,V),I(h,Y),I(h,K),I(K,E),I(E,D),I(K,U),I(K,F),I(h,R),I(h,G),I(G,J),I(J,ee),I(G,j),I(G,ge),I(f,ye),I(f,ie),I(ie,Ie),I(Ie,Te),I(Te,rt),I(Ie,de),I(Ie,Ge),I(ie,Vt),I(ie,Bt),I(Bt,yt),I(yt,Nt),I(Bt,Ot),I(Bt,Dt),I(ie,_e),I(ie,Ht),I(Ht,wt),I(wt,Ce),I(Ht,Wt),I(Ht,fe),I(ie,X),I(ie,me),I(me,He),I(He,Ue),I(me,qe),I(me,It),I(e,Gt),I(e,tn),I(tn,cn),I(cn,mn),I(e,yn),I(e,On),I(On,Tt),I(Tt,ln),I(ln,fn),I(fn,Hn),I(Hn,Jn),I(fn,$n),I(fn,Dn),I(ln,el),I(ln,wn),I(wn,Ln),I(Ln,Z),I(wn,ve),I(wn,pe),I(ln,Me),I(ln,$),I($,We),I(We,ft),I($,st),I($,Et),Ct||(Q=he(i,"click",n[3]),Ct=!0)},p(bt,ct){ct&2&&o!==(o=bt[1].t("Keyboard shortcuts")+"")&&Oe(s,o),ct&2&&v!==(v=bt[1].t("Open new chat")+"")&&Oe(p,v),ct&2&&A!==(A=bt[1].t("Focus chat input")+"")&&Oe(z,A),ct&2&&q!==(q=bt[1].t("Copy last code block")+"")&&Oe(D,q),ct&2&&oe!==(oe=bt[1].t("Copy last response")+"")&&Oe(ee,oe),ct&2&&Fe!==(Fe=bt[1].t("Toggle settings")+"")&&Oe(rt,Fe),ct&2&&Yt!==(Yt=bt[1].t("Toggle sidebar")+"")&&Oe(Nt,Yt),ct&2&&St!==(St=bt[1].t("Delete chat")+"")&&Oe(Ce,St),ct&2&&Xe!==(Xe=bt[1].t("Show shortcuts")+"")&&Oe(Ue,Xe),ct&2&&vn!==(vn=bt[1].t("Input commands")+"")&&Oe(mn,vn),ct&2&&Yn!==(Yn=bt[1].t("Attach file")+"")&&Oe(Jn,Yn),ct&2&&Xn!==(Xn=bt[1].t("Add custom prompt")+"")&&Oe(Z,Xn),ct&2&&Re!==(Re=bt[1].t("Select model")+"")&&Oe(ft,Re)},d(bt){bt&&b(e),Ct=!1,Q()}}}function Q_(n){let e,t,l;function o(r){n[4](r)}let s={$$slots:{default:[J_]},$$scope:{ctx:n}};return n[0]!==void 0&&(s.show=n[0]),e=new Qu({props:s}),Be.push(()=>lt(e,"show",o)),{c(){re(e.$$.fragment)},l(r){ce(e.$$.fragment,r)},m(r,i){ae(e,r,i),l=!0},p(r,[i]){const a={};i&35&&(a.$$scope={dirty:i,ctx:r}),!t&&i&1&&(t=!0,a.show=r[0],nt(()=>t=!1)),e.$set(a)},i(r){l||(P(e.$$.fragment,r),l=!0)},o(r){B(e.$$.fragment,r),l=!1},d(r){ue(e,r)}}}function x_(n,e,t){let l;const o=Lt("i18n");se(n,o,a=>t(1,l=a));let{show:s=!1}=e;const r=()=>{t(0,s=!1)};function i(a){s=a,t(0,s)}return n.$$set=a=>{"show"in a&&t(0,s=a.show)},[s,l,o,r,i]}class $_ extends ke{constructor(e){super(),Ee(this,e,x_,Q_,Se,{show:0})}}function e2(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var o=T(e);t=Ve(o,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"stroke-linecap","round"),m(t,"stroke-linejoin","round"),m(t,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"fill","none"),m(e,"viewBox","0 0 24 24"),m(e,"stroke-width",n[1]),m(e,"stroke","currentColor"),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&2&&m(e,"stroke-width",l[1]),o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function t2(n,e,t){let{className:l="w-4 h-4"}=e,{strokeWidth:o="2"}=e;return n.$$set=s=>{"className"in s&&t(0,l=s.className),"strokeWidth"in s&&t(1,o=s.strokeWidth)},[l,o]}class n2 extends ke{constructor(e){super(),Ee(this,e,t2,e2,Se,{className:0,strokeWidth:1})}}function l2(n){let e,t;return{c(){e=Pe("svg"),t=Pe("path"),this.h()},l(l){e=Ve(l,"svg",{"aria-hidden":!0,xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,class:!0});var o=T(e);t=Ve(o,"path",{"fill-rule":!0,d:!0,"clip-rule":!0}),T(t).forEach(b),o.forEach(b),this.h()},h(){m(t,"fill-rule","evenodd"),m(t,"d","M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V7Zm5.01 1H5v2.01h2.01V8Zm3 0H8v2.01h2.01V8Zm3 0H11v2.01h2.01V8Zm3 0H14v2.01h2.01V8Zm3 0H17v2.01h2.01V8Zm-12 3H5v2.01h2.01V11Zm3 0H8v2.01h2.01V11Zm3 0H11v2.01h2.01V11Zm3 0H14v2.01h2.01V11Zm3 0H17v2.01h2.01V11Zm-12 3H5v2.01h2.01V14ZM8 14l-.001 2 8.011.01V14H8Zm11.01 0H17v2.01h2.01V14Z"),m(t,"clip-rule","evenodd"),m(e,"aria-hidden","true"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"fill","currentColor"),m(e,"viewBox","0 0 24 24"),m(e,"stroke-width",n[1]),m(e,"class",n[0])},m(l,o){W(l,e,o),I(e,t)},p(l,[o]){o&2&&m(e,"stroke-width",l[1]),o&1&&m(e,"class",l[0])},i:we,o:we,d(l){l&&b(e)}}}function o2(n,e,t){let{className:l="size-4"}=e,{strokeWidth:o="2"}=e;return n.$$set=s=>{"className"in s&&t(0,l=s.className),"strokeWidth"in s&&t(1,o=s.strokeWidth)},[l,o]}class s2 extends ke{constructor(e){super(),Ee(this,e,o2,l2,Se,{className:0,strokeWidth:1})}}function i2(n){let e;const t=n[5].default,l=dt(t,n,n[9],null);return{c(){l&&l.c()},l(o){l&&l.l(o)},m(o,s){l&&l.m(o,s),e=!0},p(o,s){l&&l.p&&(!e||s&512)&&ht(l,t,o,o[9],e?gt(t,o[9],s,null):mt(o[9]),null)},i(o){e||(P(l,o),e=!0)},o(o){B(l,o),e=!1},d(o){l&&l.d(o)}}}function r2(n){let e,t,l,o=n[2].t("Documentation")+"",s,r;return e=new n2({props:{className:"size-5"}}),{c(){re(e.$$.fragment),t=te(),l=O("div"),s=De(o),this.h()},l(i){ce(e.$$.fragment,i),t=ne(i),l=H(i,"DIV",{class:!0});var a=T(l);s=ze(a,o),a.forEach(b),this.h()},h(){m(l,"class","flex items-center")},m(i,a){ae(e,i,a),W(i,t,a),W(i,l,a),I(l,s),r=!0},p(i,a){(!r||a&4)&&o!==(o=i[2].t("Documentation")+"")&&Oe(s,o)},i(i){r||(P(e.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),r=!1},d(i){i&&(b(t),b(l)),ue(e,i)}}}function a2(n){let e,t,l,o=n[2].t("Keyboard shortcuts")+"",s,r;return e=new s2({props:{className:"size-5"}}),{c(){re(e.$$.fragment),t=te(),l=O("div"),s=De(o),this.h()},l(i){ce(e.$$.fragment,i),t=ne(i),l=H(i,"DIV",{class:!0});var a=T(l);s=ze(a,o),a.forEach(b),this.h()},h(){m(l,"class","flex items-center")},m(i,a){ae(e,i,a),W(i,t,a),W(i,l,a),I(l,s),r=!0},p(i,a){(!r||a&4)&&o!==(o=i[2].t("Keyboard shortcuts")+"")&&Oe(s,o)},i(i){r||(P(e.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),r=!1},d(i){i&&(b(t),b(l)),ue(e,i)}}}function u2(n){let e,t,l,o;return e=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",id:"chat-share-button",$$slots:{default:[r2]},$$scope:{ctx:n}}}),e.$on("click",n[6]),l=new Nn({props:{class:"flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md",id:"chat-share-button",$$slots:{default:[a2]},$$scope:{ctx:n}}}),l.$on("click",n[7]),{c(){re(e.$$.fragment),t=te(),re(l.$$.fragment)},l(s){ce(e.$$.fragment,s),t=ne(s),ce(l.$$.fragment,s)},m(s,r){ae(e,s,r),W(s,t,r),ae(l,s,r),o=!0},p(s,r){const i={};r&516&&(i.$$scope={dirty:r,ctx:s}),e.$set(i);const a={};r&516&&(a.$$scope={dirty:r,ctx:s}),l.$set(a)},i(s){o||(P(e.$$.fragment,s),P(l.$$.fragment,s),o=!0)},o(s){B(e.$$.fragment,s),B(l.$$.fragment,s),o=!1},d(s){s&&b(t),ue(e,s),ue(l,s)}}}function c2(n){let e,t,l;return t=new po({props:{class:"w-full max-w-[200px] rounded-xl px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow-lg",sideOffset:4,side:"top",align:"end",transition:Wl,$$slots:{default:[u2]},$$scope:{ctx:n}}}),{c(){e=O("div"),re(t.$$.fragment),this.h()},l(o){e=H(o,"DIV",{slot:!0});var s=T(e);ce(t.$$.fragment,s),s.forEach(b),this.h()},h(){m(e,"slot","content")},m(o,s){W(o,e,s),ae(t,e,null),l=!0},p(o,s){const r={};s&517&&(r.$$scope={dirty:s,ctx:o}),t.$set(r)},i(o){l||(P(t.$$.fragment,o),l=!0)},o(o){B(t.$$.fragment,o),l=!1},d(o){o&&b(e),ue(t)}}}function f2(n){let e,t;return e=new yo({props:{$$slots:{content:[c2],default:[i2]},$$scope:{ctx:n}}}),e.$on("change",n[8]),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,[o]){const s={};o&517&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function d2(n,e,t){let l,{$$slots:o={},$$scope:s}=e;const r=Lt("i18n");se(n,r,d=>t(2,l=d));let{showDocsHandler:i}=e,{showShortcutsHandler:a}=e,{onClose:u=()=>{}}=e;const c=()=>{window.open("https://docs.openwebui.com","_blank")},f=()=>{a()},h=d=>{d.detail===!1&&u()};return n.$$set=d=>{"showDocsHandler"in d&&t(4,i=d.showDocsHandler),"showShortcutsHandler"in d&&t(0,a=d.showShortcutsHandler),"onClose"in d&&t(1,u=d.onClose),"$$scope"in d&&t(9,s=d.$$scope)},[a,u,l,r,i,o,c,f,h,s]}class h2 extends ke{constructor(e){super(),Ee(this,e,d2,f2,Se,{showDocsHandler:4,showShortcutsHandler:0,onClose:1})}}function m2(n){let e,t="?";return{c(){e=O("button"),e.textContent=t,this.h()},l(l){e=H(l,"BUTTON",{class:!0,"data-svelte-h":!0}),ut(e)!=="svelte-oq3opr"&&(e.textContent=t),this.h()},h(){m(e,"class","text-gray-600 dark:text-gray-300 bg-gray-300/20 size-5 flex items-center justify-center text-[0.7rem] rounded-full")},m(l,o){W(l,e,o)},p:we,d(l){l&&b(e)}}}function g2(n){let e,t;return e=new pn({props:{content:n[1].t("Help"),placement:"left",$$slots:{default:[m2]},$$scope:{ctx:n}}}),{c(){re(e.$$.fragment)},l(l){ce(e.$$.fragment,l)},m(l,o){ae(e,l,o),t=!0},p(l,o){const s={};o&2&&(s.content=l[1].t("Help")),o&128&&(s.$$scope={dirty:o,ctx:l}),e.$set(s)},i(l){t||(P(e.$$.fragment,l),t=!0)},o(l){B(e.$$.fragment,l),t=!1},d(l){ue(e,l)}}}function _2(n){let e,t,l,o,s,r,i,a,u,c;o=new h2({props:{showDocsHandler:n[4],showShortcutsHandler:n[5],$$slots:{default:[g2]},$$scope:{ctx:n}}});function f(d){n[6](d)}let h={};return n[0]!==void 0&&(h.show=n[0]),r=new $_({props:h}),Be.push(()=>lt(r,"show",f)),{c(){e=O("div"),t=O("button"),l=te(),re(o.$$.fragment),s=te(),re(r.$$.fragment),this.h()},l(d){e=H(d,"DIV",{class:!0});var _=T(e);t=H(_,"BUTTON",{id:!0,class:!0}),T(t).forEach(b),l=ne(_),ce(o.$$.fragment,_),_.forEach(b),s=ne(d),ce(r.$$.fragment,d),this.h()},h(){m(t,"id","show-shortcuts-button"),m(t,"class","hidden"),m(e,"class","hidden lg:flex fixed bottom-0 right-0 px-2 py-2 z-20")},m(d,_){W(d,e,_),I(e,t),I(e,l),ae(o,e,null),W(d,s,_),ae(r,d,_),a=!0,u||(c=he(t,"click",n[3]),u=!0)},p(d,[_]){const v={};_&1&&(v.showDocsHandler=d[4]),_&1&&(v.showShortcutsHandler=d[5]),_&130&&(v.$$scope={dirty:_,ctx:d}),o.$set(v);const p={};!i&&_&1&&(i=!0,p.show=d[0],nt(()=>i=!1)),r.$set(p)},i(d){a||(P(o.$$.fragment,d),P(r.$$.fragment,d),a=!0)},o(d){B(o.$$.fragment,d),B(r.$$.fragment,d),a=!1},d(d){d&&(b(e),b(s)),ue(o),ue(r,d),u=!1,c()}}}function b2(n,e,t){let l;const o=Lt("i18n");se(n,o,c=>t(1,l=c));let s=!1;const r=()=>{t(0,s=!s)},i=()=>{t(0,s=!s)},a=()=>{t(0,s=!s)};function u(c){s=c,t(0,s)}return[s,l,o,r,i,a,u]}class rb extends ke{constructor(e){super(),Ee(this,e,b2,_2,Se,{})}}export{ib as C,rb as H}; //# sourceMappingURL=Help.Dgi2pre9.js.map