diff --git a/extension/dist/webview.es.js b/extension/dist/webview.es.js index e45a51e..5ad5173 100644 --- a/extension/dist/webview.es.js +++ b/extension/dist/webview.es.js @@ -50623,6 +50623,42 @@ class xe extends ke { } } function Vf(r) { + let e; + return { + c() { + e = b("div"), f(e, "class", "space-y-4 overflow-hidden highlighter svelte-1ieua60"); + }, + m(t, n) { + P(t, e, n), e.innerHTML = /*markup*/ + r[0]; + }, + p(t, [n]) { + n & /*markup*/ + 1 && (e.innerHTML = /*markup*/ + t[0]); + }, + i: Ee, + o: Ee, + d(t) { + t && w(e); + } + }; +} +function zf(r, e, t) { + let { code: n = "" } = e, a = ""; + return r.$$set = (o) => { + "code" in o && t(1, n = o.code); + }, r.$$.update = () => { + r.$$.dirty & /*code*/ + 2 && t(0, a = ve(n)); + }, [a, n]; +} +class Wf extends ke { + constructor(e) { + super(), Pe(this, e, zf, Vf, De, { code: 1 }); + } +} +function Kf(r) { let e, t, n, a, o, i = [ { xmlns: "http://www.w3.org/2000/svg" }, { width: "1em" }, @@ -50658,17 +50694,17 @@ function Vf(r) { } }; } -function zf(r, e, t) { +function Qf(r, e, t) { return r.$$set = (n) => { t(0, e = Xe(Xe({}, e), dt(n))); }, e = dt(e), [e]; } -class Wf extends ke { +class Xf extends ke { constructor(e) { - super(), Pe(this, e, zf, Vf, De, {}); + super(), Pe(this, e, Qf, Kf, De, {}); } } -function Kf(r) { +function Zf(r) { let e, t, n = [ { xmlns: "http://www.w3.org/2000/svg" }, { width: "1em" }, @@ -50704,55 +50740,19 @@ function Kf(r) { } }; } -function Qf(r, e, t) { +function Jf(r, e, t) { return r.$$set = (n) => { t(0, e = Xe(Xe({}, e), dt(n))); }, e = dt(e), [e]; } -class Xf extends ke { - constructor(e) { - super(), Pe(this, e, Qf, Kf, De, {}); - } -} -function Zf(r) { - let e; - return { - c() { - e = b("div"), f(e, "class", "space-y-4 overflow-hidden highlighter svelte-1ieua60"); - }, - m(t, n) { - P(t, e, n), e.innerHTML = /*markup*/ - r[0]; - }, - p(t, [n]) { - n & /*markup*/ - 1 && (e.innerHTML = /*markup*/ - t[0]); - }, - i: Ee, - o: Ee, - d(t) { - t && w(e); - } - }; -} -function Jf(r, e, t) { - let { code: n = "" } = e, a = ""; - return r.$$set = (o) => { - "code" in o && t(1, n = o.code); - }, r.$$.update = () => { - r.$$.dirty & /*code*/ - 2 && t(0, a = ve(n)); - }, [a, n]; -} class jf extends ke { constructor(e) { - super(), Pe(this, e, Jf, Zf, De, { code: 1 }); + super(), Pe(this, e, Jf, Zf, De, {}); } } function eT(r) { let e, t; - return e = new Wf({ props: { class: "w-6 h-6 mr-2" } }), { + return e = new Xf({ props: { class: "w-6 h-6 mr-2" } }), { c() { se(e.$$.fragment); }, @@ -50772,7 +50772,7 @@ function eT(r) { } function tT(r) { let e, t; - return e = new Xf({ props: { class: "w-6 h-6 mr-2" } }), { + return e = new jf({ props: { class: "w-6 h-6 mr-2" } }), { c() { se(e.$$.fragment); }, @@ -50816,7 +50816,7 @@ function nT(r) { ) ); } - ~(n = u(r)) && (a = m[n] = d[n](r)), l = new jf({ props: { code: ( + ~(n = u(r)) && (a = m[n] = d[n](r)), l = new Wf({ props: { code: ( /*message*/ r[1] ) } }); diff --git a/extension/dist/webview.umd.js b/extension/dist/webview.umd.js index 93b5518..272c956 100644 --- a/extension/dist/webview.umd.js +++ b/extension/dist/webview.umd.js @@ -54,7 +54,7 @@ ${e} `}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return"
"}del(e){return`${e}`}link(e,t,n){const a=w_(e);if(a===null)return n;e=a;let o='",o}image(e,t,n){const a=w_(e);if(a===null)return n;e=a;let o=`${n}0&&m.tokens[0].type==="paragraph"?(m.tokens[0].text=g+" "+m.tokens[0].text,m.tokens[0].tokens&&m.tokens[0].tokens.length>0&&m.tokens[0].tokens[0].type==="text"&&(m.tokens[0].tokens[0].text=g+" "+m.tokens[0].tokens[0].text)):m.tokens.unshift({type:"text",text:g+" "}):E+=g+" "}E+=this.parse(m.tokens,c),_+=this.renderer.listitem(E,p,!!u)}n+=this.renderer.list(_,s,l);continue}case"html":{const i=o;n+=this.renderer.html(i.text,i.block);continue}case"paragraph":{const i=o;n+=this.renderer.paragraph(this.parseInline(i.tokens));continue}case"text":{let i=o,s=i.tokens?this.parseInline(i.tokens):i.text;for(;a+1{n=n.concat(this.walkTokens(s[l],t))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const a={...n};if(a.async=this.defaults.async||a.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){const i=t.renderers[o.name];i?t.renderers[o.name]=function(...s){let l=o.renderer.apply(this,s);return l===!1&&(l=i.apply(this,s)),l}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=t[o.level];i?i.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),a.extensions=t),n.renderer){const o=this.defaults.renderer||new _n(this.defaults);for(const i in n.renderer){const s=n.renderer[i],l=i,c=o[l];o[l]=(..._)=>{let d=s.apply(o,_);return d===!1&&(d=c.apply(o,_)),d||""}}a.renderer=o}if(n.tokenizer){const o=this.defaults.tokenizer||new cn(this.defaults);for(const i in n.tokenizer){const s=n.tokenizer[i],l=i,c=o[l];o[l]=(..._)=>{let d=s.apply(o,_);return d===!1&&(d=c.apply(o,_)),d}}a.tokenizer=o}if(n.hooks){const o=this.defaults.hooks||new Vt;for(const i in n.hooks){const s=n.hooks[i],l=i,c=o[l];Vt.passThroughHooks.has(i)?o[l]=_=>{if(this.defaults.async)return Promise.resolve(s.call(o,_)).then(m=>c.call(o,m));const d=s.call(o,_);return c.call(o,d)}:o[l]=(..._)=>{let d=s.apply(o,_);return d===!1&&(d=c.apply(o,_)),d}}a.hooks=o}if(n.walkTokens){const o=this.defaults.walkTokens,i=n.walkTokens;a.walkTokens=function(s){let l=[];return l.push(i.call(this,s)),o&&(l=l.concat(o.call(this,s))),l}}this.defaults={...this.defaults,...a}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return at.lex(e,t??this.defaults)}parser(e,t){return it.parse(e,t??this.defaults)}}Wt=new WeakSet,To=function(e,t){return(n,a)=>{const o={...a},i={...this.defaults,...o};this.defaults.async===!0&&o.async===!1&&(i.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),i.async=!0);const s=mn(this,dn,au).call(this,!!i.silent,!!i.async);if(typeof n>"u"||n===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i),i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then(l=>e(l,i)).then(l=>i.walkTokens?Promise.all(this.walkTokens(l,i.walkTokens)).then(()=>l):l).then(l=>t(l,i)).then(l=>i.hooks?i.hooks.postprocess(l):l).catch(s);try{i.hooks&&(n=i.hooks.preprocess(n));const l=e(n,i);i.walkTokens&&this.walkTokens(l,i.walkTokens);let c=t(l,i);return i.hooks&&(c=i.hooks.postprocess(c)),c}catch(l){return s(l)}}},dn=new WeakSet,au=function(e,t){return n=>{if(n.message+=` Please report this to https://github.com/markedjs/marked.`,e){const a="

An error occurred:

"+Xe(n.message+"",!0)+"
";return t?Promise.resolve(a):a}if(t)return Promise.reject(n);throw n}};const Ct=new sS;function ve(r,e){return Ct.parse(r,e)}ve.options=ve.setOptions=function(r){return Ct.setOptions(r),ve.defaults=Ct.defaults,y_(ve.defaults),ve},ve.getDefaults=co,ve.defaults=Rt,ve.use=function(...r){return Ct.use(...r),ve.defaults=Ct.defaults,y_(ve.defaults),ve},ve.walkTokens=function(r,e){return Ct.walkTokens(r,e)},ve.parseInline=Ct.parseInline,ve.Parser=it,ve.parser=it.parse,ve.Renderer=_n,ve.TextRenderer=_o,ve.Lexer=at,ve.lexer=at.lex,ve.Tokenizer=cn,ve.Hooks=Vt,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,it.parse,at.lex;function lS(r){if(typeof r=="function"&&(r={highlight:r}),!r||typeof r.highlight!="function")throw new Error("Must provide highlight function");return typeof r.langPrefix!="string"&&(r.langPrefix="language-"),{async:!!r.async,walkTokens(e){if(e.type!=="code")return;const t=cS(e);if(r.async)return Promise.resolve(r.highlight(e.text,t)).then(k_(e));const n=r.highlight(e.text,t);if(n instanceof Promise)throw new Error("markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.");k_(e)(n)},renderer:{code(e,t,n){const a=(t||"").match(/\S*/)[0],o=a?` class="${r.langPrefix}${G_(a)}"`:"";return e=e.replace(/\n$/,""),`
${n?e:G_(e,!0)}
-
`}}}}function cS(r){return(r.lang||"").match(/\S*/)[0]}function k_(r){return e=>{typeof e=="string"&&e!==r.text&&(r.escaped=!0,r.text=e)}}const U_=/[&<>"']/,_S=new RegExp(U_.source,"g"),F_=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,dS=new RegExp(F_.source,"g"),uS={"&":"&","<":"<",">":">",'"':""","'":"'"},B_=r=>uS[r];function G_(r,e){if(e){if(U_.test(r))return r.replace(_S,B_)}else if(F_.test(r))return r.replace(dS,B_);return r}const Y_={subscribe:null,addNotification:null,removeNotification:null,clearNotifications:null},uo=()=>fu(Y_);function mS(r){let e,t,n;var a=r[0];function o(i,s){return{props:{notification:i[1],withoutStyles:i[2],onRemove:i[3]}}}return a&&(e=vo(a,o(r))),{c(){e&&le(e.$$.fragment),t=_t()},m(i,s){e&&ae(e,i,s),P(i,t,s),n=!0},p(i,[s]){if(s&1&&a!==(a=i[0])){if(e){Se();const l=e;D(l.$$.fragment,1,0,()=>{ie(l,1)}),fe()}a?(e=vo(a,o(i)),le(e.$$.fragment),N(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(a){const l={};s&2&&(l.notification=i[1]),s&4&&(l.withoutStyles=i[2]),e.$set(l)}},i(i){n||(e&&N(e.$$.fragment,i),n=!0)},o(i){e&&D(e.$$.fragment,i),n=!1},d(i){i&&w(t),e&&ie(e,i)}}}function pS(r,e,t){let{item:n}=e,{notification:a={}}=e,{withoutStyles:o=!1}=e;const{removeNotification:i}=uo(),{id:s,removeAfter:l}=a,c=()=>i(s);let _=null;return l&&(_=setTimeout(c,l)),gu(()=>{l&&_&&clearTimeout(_)}),r.$$set=d=>{"item"in d&&t(0,n=d.item),"notification"in d&&t(1,a=d.notification),"withoutStyles"in d&&t(2,o=d.withoutStyles)},[n,a,o,c]}class ES extends Le{constructor(e){super(),Me(this,e,pS,mS,De,{item:0,notification:1,withoutStyles:2})}}function ot(r,{delay:e=0,duration:t=400,easing:n=Fe}={}){const a=+getComputedStyle(r).opacity;return{delay:e,duration:t,easing:n,css:o=>`opacity: ${o*a}`}}function gS(r){let e,t,n,a,o,i,s,l,c,_;const d=r[6].default,m=ht(d,r,r[5],null),u=m||SS(r);return{c(){e=b("div"),t=b("div"),u&&u.c(),n=U(),a=b("button"),o=se("×"),f(t,"class",Ne(r[2]("content"))+" svelte-1jw51vr"),f(a,"class",Ne(r[2]("button"))+" svelte-1jw51vr"),f(a,"aria-label","delete notification"),f(e,"class",Ne(r[2]())+" svelte-1jw51vr"),f(e,"role","status"),f(e,"aria-live","polite")},m(p,E){P(p,e,E),S(e,t),u&&u.m(t,null),S(e,n),S(e,a),S(a,o),l=!0,c||(_=ge(a,"click",function(){Ot(r[0])&&r[0].apply(this,arguments)}),c=!0)},p(p,E){r=p,m&&m.p&&(!l||E&32)&&At(m,d,r,r[5],l?It(d,r[5],E,null):vt(r[5]),null)},i(p){l||(N(u,p),p&&We(()=>{l&&(s&&s.end(1),i=Ru(e,ot,{}),i.start())}),l=!0)},o(p){D(u,p),i&&i.invalidate(),p&&(s=Cu(e,ot,{})),l=!1},d(p){p&&w(e),u&&u.d(p),p&&s&&s.end(),c=!1,_()}}}function SS(r){let e;return{c(){e=se(r[1])},m(t,n){P(t,e,n)},p:oe,d(t){t&&w(e)}}}function fS(r){let e,t,n=r[1]&&gS(r);return{c(){n&&n.c(),e=_t()},m(a,o){n&&n.m(a,o),P(a,e,o),t=!0},p(a,[o]){a[1]&&n.p(a,o)},i(a){t||(N(n),t=!0)},o(a){D(n),t=!1},d(a){a&&w(e),n&&n.d(a)}}}function TS(r,e,t){let{$$slots:n={},$$scope:a}=e,{notification:o={}}=e,{withoutStyles:i=!1}=e,{onRemove:s=null}=e;const{text:l,type:c}=o,_=d=>{const m=d?`-${d}`:"",u=` default-notification-style${m}`,p=c&&!d?` default-notification-${c}`:"";return`notification${m}${i?"":u}${p}`};return r.$$set=d=>{"notification"in d&&t(3,o=d.notification),"withoutStyles"in d&&t(4,i=d.withoutStyles),"onRemove"in d&&t(0,s=d.onRemove),"$$scope"in d&&t(5,a=d.$$scope)},[s,l,_,o,i,a,n]}class q_ extends Le{constructor(e){super(),Me(this,e,TS,fS,De,{notification:3,withoutStyles:4,onRemove:0})}}const mo=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],bS=(r,e)=>{if(!r)return;const{update:t}=e,n={id:`${new Date().getTime()}-${Math.floor(Math.random()*9999)}`,position:"bottom-center",text:"",...r};mo.includes(r.position)&&t(a=>n.position.includes("top-")?[n,...a]:[...a,n])},RS=(r,{update:e})=>{r&&e(t=>t.filter(({id:n})=>n!==r))},CS=r=>r.set([]),$_=(()=>{const r=ft([]);return{subscribe:r.subscribe,addNotification:e=>bS(e,r),removeNotification:e=>RS(e,r),clearNotifications:()=>CS(r)}})();function H_(r,e,t){const n=r.slice();return n[7]=e[t],n}function V_(r,e,t){const n=r.slice();return n[10]=e[t],n}function z_(r){let e,t;return e=new ES({props:{notification:r[10],withoutStyles:r[1],item:r[0]||q_}}),{c(){le(e.$$.fragment)},m(n,a){ae(e,n,a),t=!0},p(n,a){const o={};a&8&&(o.notification=n[10]),a&2&&(o.withoutStyles=n[1]),a&1&&(o.item=n[0]||q_),e.$set(o)},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){D(e.$$.fragment,n),t=!1},d(n){ie(e,n)}}}function W_(r,e){let t,n,a,o=e[10].position===e[7]&&z_(e);return{key:r,first:null,c(){t=_t(),o&&o.c(),n=_t(),this.first=t},m(i,s){P(i,t,s),o&&o.m(i,s),P(i,n,s),a=!0},p(i,s){e=i,e[10].position===e[7]?o?(o.p(e,s),s&8&&N(o,1)):(o=z_(e),o.c(),N(o,1),o.m(n.parentNode,n)):o&&(Se(),D(o,1,1,()=>{o=null}),fe())},i(i){a||(N(o),a=!0)},o(i){D(o),a=!1},d(i){i&&(w(t),w(n)),o&&o.d(i)}}}function K_(r){let e,t=[],n=new Map,a,o,i=Oe(r[3]);const s=l=>l[10].id;for(let l=0;lD(s[c],1,1,()=>{s[c]=null});return{c(){o&&o.c(),e=U(),t=b("div");for(let c=0;ct(3,n=_));let{$$slots:a={},$$scope:o}=e,{item:i=null}=e,{withoutStyles:s=!1}=e,{zIndex:l=null}=e;const c=(_="")=>{const d=` default-position-style-${_}`;return`position-${_}${s?"":d}`};return Su(Y_,$_),r.$$set=_=>{"item"in _&&t(0,i=_.item),"withoutStyles"in _&&t(1,s=_.withoutStyles),"zIndex"in _&&t(2,l=_.zIndex),"$$scope"in _&&t(5,o=_.$$scope)},[i,s,l,n,c,o,a]}class hS extends Le{constructor(e){super(),Me(this,e,OS,NS,De,{item:0,withoutStyles:1,zIndex:2})}}const IS=()=>Math.random().toString(36).substring(2,15);var Et=(r=>(r.ChatInitiated="chatInitiated",r.ChatMessageSent="chatMessageSent",r.ChatMessageReceived="chatMessageReceived",r.ChatEnded="chatEnded",r))(Et||{});function AS(r){const{addNotification:e}=uo();return ce.on("notification",t=>{e({text:t.message,position:"top-right",type:"info",removeAfter:2e3})}),ce.on("notificationError",t=>{e({text:t.message,position:"top-right",type:"error",removeAfter:2e3})}),ce.on("notificationWarning",t=>{e({text:t.message,position:"top-right",type:"warning",removeAfter:2e3})}),ce.on("notificationSuccess",t=>{e({text:t.message,position:"top-right",type:"success",removeAfter:2e3})}),[]}class vS extends Le{constructor(e){super(),Me(this,e,AS,null,De,{})}}function yS(r){let e,t,n,a,o;const i=r[5].default,s=ht(i,r,r[4],null);return{c(){e=b("button"),s&&s.c(),f(e,"class",t=Ne(`bg-${r[0]} size-${r[1]} ${r[2]}`)+" svelte-jsk6qy")},m(l,c){P(l,e,c),s&&s.m(e,null),n=!0,a||(o=ge(e,"click",r[3]),a=!0)},p(l,[c]){s&&s.p&&(!n||c&16)&&At(s,i,l,l[4],n?It(i,l[4],c,null):vt(l[4]),null),(!n||c&7&&t!==(t=Ne(`bg-${l[0]} size-${l[1]} ${l[2]}`)+" svelte-jsk6qy"))&&f(e,"class",t)},i(l){n||(N(s,l),n=!0)},o(l){D(s,l),n=!1},d(l){l&&w(e),s&&s.d(l),a=!1,o()}}}function DS(r,e,t){let{$$slots:n={},$$scope:a}=e,{variant:o="primary"}=e,{size:i="md"}=e,{class:s=""}=e;const l=Je();function c(){l("click")}return r.$$set=_=>{"variant"in _&&t(0,o=_.variant),"size"in _&&t(1,i=_.size),"class"in _&&t(2,s=_.class),"$$scope"in _&&t(4,a=_.$$scope)},[o,i,s,c,a,n]}class we extends Le{constructor(e){super(),Me(this,e,DS,yS,De,{variant:0,size:1,class:2})}}function MS(r){let e,t,n,a,o,i=[{xmlns:"http://www.w3.org/2000/svg"},{width:"1em"},{height:"1em"},{viewBox:"0 0 14 14"},r[0]],s={};for(let l=0;l{t(0,e=Be(Be({},e),ct(n)))},e=ct(e),[e]}class wS extends Le{constructor(e){super(),Me(this,e,LS,MS,De,{})}}function xS(r){let e,t,n=[{xmlns:"http://www.w3.org/2000/svg"},{width:"1em"},{height:"1em"},{viewBox:"0 0 48 48"},r[0]],a={};for(let o=0;o{t(0,e=Be(Be({},e),ct(n)))},e=ct(e),[e]}class kS extends Le{constructor(e){super(),Me(this,e,PS,xS,De,{})}}function US(r){let e;return{c(){e=b("div"),f(e,"class","space-y-4 overflow-hidden highlighter svelte-1ieua60")},m(t,n){P(t,e,n),e.innerHTML=r[0]},p(t,[n]){n&1&&(e.innerHTML=t[0])},i:oe,o:oe,d(t){t&&w(e)}}}function FS(r,e,t){let{code:n=""}=e,a="";return r.$$set=o=>{"code"in o&&t(1,n=o.code)},r.$$.update=()=>{r.$$.dirty&2&&t(0,a=ve(n))},[a,n]}class BS extends Le{constructor(e){super(),Me(this,e,FS,US,De,{code:1})}}function GS(r){let e,t;return e=new wS({props:{class:"w-6 h-6 mr-2"}}),{c(){le(e.$$.fragment)},m(n,a){ae(e,n,a),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){D(e.$$.fragment,n),t=!1},d(n){ie(e,n)}}}function YS(r){let e,t;return e=new kS({props:{class:"w-6 h-6 mr-2"}}),{c(){le(e.$$.fragment)},m(n,a){ae(e,n,a),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){D(e.$$.fragment,n),t=!1},d(n){ie(e,n)}}}function Q_(r){let e,t,n;return{c(){e=ze("svg"),t=ze("circle"),n=ze("path"),f(t,"class","opacity-25"),f(t,"cx","12"),f(t,"cy","12"),f(t,"r","10"),f(t,"stroke","currentColor"),f(t,"stroke-width","4"),f(n,"class","opacity-75"),f(n,"fill","currentColor"),f(n,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),f(e,"class","mt-2 animate-spin h-6 w-6 foreground svelte-lnb535"),f(e,"xmlns","http://www.w3.org/2000/svg"),f(e,"fill","none"),f(e,"viewBox","0 0 24 24")},m(a,o){P(a,e,o),S(e,t),S(e,n)},d(a){a&&w(e)}}}function qS(r){let e,t,n,a,o,i,s,l,c,_;const d=[YS,GS],m=[];function u(E,g){return E[0]==="user"?0:E[0]==="assistant"?1:-1}~(n=u(r))&&(a=m[n]=d[n](r)),l=new BS({props:{code:r[1]}});let p=r[2]&&r[3]&&Q_();return{c(){e=b("div"),t=b("div"),a&&a.c(),o=U(),i=b("div"),s=b("div"),le(l.$$.fragment),c=U(),p&&p.c(),f(s,"class","message p-4 flex flex-col max-w-[768px] svelte-lnb535"),f(i,"class","flex-1 overflow-hidden"),f(t,"class","flex items-start"),f(e,"class","mb-4 w-full max-w-[768px]")},m(E,g){P(E,e,g),S(e,t),~n&&m[n].m(t,null),S(t,o),S(t,i),S(i,s),ae(l,s,null),S(s,c),p&&p.m(s,null),r[8](s),_=!0},p(E,[g]){let T=n;n=u(E),n!==T&&(a&&(Se(),D(m[T],1,1,()=>{m[T]=null}),fe()),~n?(a=m[n],a||(a=m[n]=d[n](E),a.c()),N(a,1),a.m(t,o)):a=null);const R={};g&2&&(R.code=E[1]),l.$set(R),E[2]&&E[3]?p||(p=Q_(),p.c(),p.m(s,null)):p&&(p.d(1),p=null)},i(E){_||(N(a),N(l.$$.fragment,E),_=!0)},o(E){D(a),D(l.$$.fragment,E),_=!1},d(E){E&&w(e),~n&&m[n].d(),ie(l),p&&p.d(),r[8](null)}}}function $S(r,e,t){let{from:n="user"}=e,{message:a=""}=e,{responseInProgress:o=!1}=e,{isLastMessage:i=!1}=e,{showCompareSource:s=!0}=e;const l=Je();let c,_=[],d=!1;const{addNotification:m}=uo();function u(p){nt[p?"unshift":"push"](()=>{c=p,t(4,c)})}return r.$$set=p=>{"from"in p&&t(0,n=p.from),"message"in p&&t(1,a=p.message),"responseInProgress"in p&&t(2,o=p.responseInProgress),"isLastMessage"in p&&t(3,i=p.isLastMessage),"showCompareSource"in p&&t(5,s=p.showCompareSource)},r.$$.update=()=>{if(r.$$.dirty&247&&(!o&&!d&&c&&a.length&&(t(7,d=!0),t(6,_=c.querySelectorAll("pre > code"))),_.length)){let p=!1;_.forEach(E=>{var T,R;if((T=E.parentElement)!=null&&T.querySelector("[data-actions]")){p=!0;return}const g=document.createElement("div");g.setAttribute("data-actions",""),(R=E.parentNode)==null||R.appendChild(g)}),p||(_.forEach(E=>{var T,R;const g=document.createElement("button");g.textContent="Copy",g.classList.add("action-button"),g.addEventListener("click",()=>{var v;navigator.clipboard.writeText(((v=E.textContent)==null?void 0:v.trim())||""),m({text:"Copied to clipboard",position:"top-center",type:"info",removeAfter:1e3})}),(R=(T=E.parentElement)==null?void 0:T.querySelector("[data-actions]"))==null||R.appendChild(g)}),n==="assistant"&&_.forEach(E=>{var T,R;const g=document.createElement("button");g.textContent="Compare with selection",g.classList.add("action-button"),g.addEventListener("click",()=>{var O;const v=((O=E.textContent)==null?void 0:O.trim())||"";ce.DIFF_SELECTION(v)}),(R=(T=E.parentElement)==null?void 0:T.querySelector("[data-actions]"))==null||R.appendChild(g)}),s&&n==="assistant"&&_.forEach(E=>{var T,R;const g=document.createElement("button");g.textContent="Compare with source",g.classList.add("action-button"),g.addEventListener("click",()=>{var O;const v=((O=E.textContent)==null?void 0:O.trim())||"";ce.DIFF(v)}),(R=(T=E.parentElement)==null?void 0:T.querySelector("[data-actions]"))==null||R.appendChild(g)}),_.forEach(E=>{var g,T;if(n==="assistant"){const R=document.createElement("button");R.textContent="Replace selection",R.classList.add("action-button"),R.addEventListener("click",()=>{var O;const v=((O=E.textContent)==null?void 0:O.trim())||"";ce.REPLACE_SELECTION(v)}),(T=(g=E.parentElement)==null?void 0:g.querySelector("[data-actions]"))==null||T.appendChild(R)}})),setTimeout(()=>{l("scrollToBottom")},50)}},[n,a,o,i,c,s,_,d,u]}class X_ extends Le{constructor(e){super(),Me(this,e,$S,qS,De,{from:0,message:1,responseInProgress:2,isLastMessage:3,showCompareSource:5})}}function Z_(r,e,t){const n=r.slice();return n[12]=e[t],n}function J_(r,e,t){const n=r.slice();return n[9]=e[t],n}function HS(r){let e,t,n,a,o,i,s,l,c;n=new we({props:{variant:"subtle",size:"lg",$$slots:{default:[zS]},$$scope:{ctx:r}}}),n.$on("click",r[5]);let _=Oe(r[1].messages),d=[];for(let u=0;u<_.length;u+=1)d[u]=j_(Z_(r,_,u));const m=u=>D(d[u],1,1,()=>{d[u]=null});return l=new we({props:{variant:"subtle",size:"lg",$$slots:{default:[WS]},$$scope:{ctx:r}}}),l.$on("click",r[6]),{c(){e=b("div"),t=b("div"),le(n.$$.fragment),a=U(),o=b("div");for(let u=0;uD(a[i],1,1,()=>{a[i]=null});return{c(){for(let i=0;i{i[_]=null}),fe(),n=i[t],n?n.p(l,c):(n=i[t]=o[t](l),n.c()),N(n,1),n.m(e,null))},i(l){a||(N(n),a=!0)},o(l){D(n),a=!1},d(l){l&&w(e),i[t].d()}}}function td(r){const e=Math.floor((new Date().getTime()-r.getTime())/1e3),t=Math.floor(e/31536e3),n=Math.floor(e/2592e3),a=Math.floor(e/86400),o=Math.floor(e/3600),i=Math.floor(e/60),s=(l,c)=>l>1?`${l} ${c}s ago`:l===1?`${l} ${c} ago`:"";return s(t,"year")||s(n,"month")||s(a,"day")||s(o,"hour")||s(i,"minute")||"just now"}function XS(r,e,t){let{chatHistory:n=[]}=e,a;const o=m=>{t(1,a=m),lt().then(()=>{s()})};let i;const s=()=>{i&&t(2,i.scrollTop=i.scrollHeight,i)},l=m=>o(m),c=()=>o(null),_=()=>o(null);function d(m){nt[m?"unshift":"push"](()=>{i=m,t(2,i)})}return r.$$set=m=>{"chatHistory"in m&&t(0,n=m.chatHistory)},[n,a,i,o,l,c,_,d]}class ZS extends Le{constructor(e){super(),Me(this,e,XS,QS,De,{chatHistory:0})}}function JS(r){let e,t,n,a,o,i,s;const l=r[3].default,c=ht(l,r,r[2],null);return{c(){e=b("div"),t=se(r[0]),a=U(),o=b("div"),c&&c.c(),f(e,"class",n=Ne(`font-semibold px-4 py-2 select-none border-b border-neutral-500/50 mb-2 ${r[1]?"opacity-30":""}`)+" svelte-1yi5wo6"),f(o,"class",i=Ne(`command-list pb-2 ${r[1]?"pointer-events-none opacity-30 cursor-not-allowed":""}`)+" svelte-1yi5wo6")},m(_,d){P(_,e,d),S(e,t),P(_,a,d),P(_,o,d),c&&c.m(o,null),s=!0},p(_,[d]){(!s||d&1)&&$e(t,_[0]),(!s||d&2&&n!==(n=Ne(`font-semibold px-4 py-2 select-none border-b border-neutral-500/50 mb-2 ${_[1]?"opacity-30":""}`)+" svelte-1yi5wo6"))&&f(e,"class",n),c&&c.p&&(!s||d&4)&&At(c,l,_,_[2],s?It(l,_[2],d,null):vt(_[2]),null),(!s||d&2&&i!==(i=Ne(`command-list pb-2 ${_[1]?"pointer-events-none opacity-30 cursor-not-allowed":""}`)+" svelte-1yi5wo6"))&&f(o,"class",i)},i(_){s||(N(c,_),s=!0)},o(_){D(c,_),s=!1},d(_){_&&(w(e),w(a),w(o)),c&&c.d(_)}}}function jS(r,e,t){let{$$slots:n={},$$scope:a}=e,{category:o="Category"}=e,{disabled:i=!1}=e;return r.$$set=s=>{"category"in s&&t(0,o=s.category),"disabled"in s&&t(1,i=s.disabled),"$$scope"in s&&t(2,a=s.$$scope)},[o,i,a,n]}class ef extends Le{constructor(e){super(),Me(this,e,jS,JS,De,{category:0,disabled:1})}}function nd(r){let e,t,n,a,o,i,s,l;const c=r[2].default,_=ht(c,r,r[4],null);return o=new we({props:{variant:"secondary",$$slots:{default:[tf]},$$scope:{ctx:r}}}),o.$on("click",r[1]),{c(){e=b("div"),t=b("div"),_&&_.c(),n=U(),a=b("div"),le(o.$$.fragment),f(a,"class","flex justify-end mt-4"),f(t,"class","bg-neutral-800 text-white p-4 rounded-md shadow-xl max-w-[75%]"),f(e,"role","dialog"),f(e,"class","fixed top-0 left-0 right-0 bottom-0 w-full h-full bg-neutral-500/50 flex items-center justify-center z-50")},m(d,m){P(d,e,m),S(e,t),_&&_.m(t,null),S(t,n),S(t,a),ae(o,a,null),i=!0,s||(l=[ge(t,"click",_u(r[3])),ge(e,"click",r[1])],s=!0)},p(d,m){_&&_.p&&(!i||m&16)&&At(_,c,d,d[4],i?It(c,d[4],m,null):vt(d[4]),null);const u={};m&16&&(u.$$scope={dirty:m,ctx:d}),o.$set(u)},i(d){i||(N(_,d),N(o.$$.fragment,d),i=!0)},o(d){D(_,d),D(o.$$.fragment,d),i=!1},d(d){d&&w(e),_&&_.d(d),ie(o),s=!1,He(l)}}}function tf(r){let e;return{c(){e=se("Close")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function nf(r){let e,t,n=r[0]&&nd(r);return{c(){n&&n.c(),e=_t()},m(a,o){n&&n.m(a,o),P(a,e,o),t=!0},p(a,[o]){a[0]?n?(n.p(a,o),o&1&&N(n,1)):(n=nd(a),n.c(),N(n,1),n.m(e.parentNode,e)):n&&(Se(),D(n,1,1,()=>{n=null}),fe())},i(a){t||(N(n),t=!0)},o(a){D(n),t=!1},d(a){a&&w(e),n&&n.d(a)}}}function rf(r,e,t){let{$$slots:n={},$$scope:a}=e,{open:o=!1}=e;const i=Je();function s(){t(0,o=!1),i("close")}function l(c){Yt.call(this,r,c)}return r.$$set=c=>{"open"in c&&t(0,o=c.open),"$$scope"in c&&t(4,a=c.$$scope)},[o,s,n,l,a]}class zt extends Le{constructor(e){super(),Me(this,e,rf,nf,De,{open:0})}}function rd(r,e,t){const n=r.slice();return n[8]=e[t],n}function ad(r){let e,t=Oe(r[0]),n=[];for(let a=0;a0&&ad(r);return{c(){e=b("div"),i&&i.c(),t=U(),n=b("input"),f(n,"name",r[1]),f(n,"type","text"),f(n,"placeholder","Add item"),f(n,"class","svelte-l3hrh8"),f(e,"class","tags-input svelte-l3hrh8")},m(s,l){P(s,e,l),i&&i.m(e,null),S(e,t),S(e,n),Re(n,r[2]),a||(o=[ge(n,"input",r[6]),ge(n,"keydown",r[3])],a=!0)},p(s,[l]){s[0].length>0?i?i.p(s,l):(i=ad(s),i.c(),i.m(e,t)):i&&(i.d(1),i=null),l&2&&f(n,"name",s[1]),l&4&&n.value!==s[2]&&Re(n,s[2])},i:oe,o:oe,d(s){s&&w(e),i&&i.d(),a=!1,He(o)}}}function of(r,e,t){let{value:n=[]}=e,{name:a=""}=e,o="";const i=Je();function s(d){d.key==="Enter"&&o.trim()&&(d.preventDefault(),t(0,n=[...n,o.trim()]),i("change",n),t(2,o=""))}function l(d){t(0,n=n.filter(m=>m!==d)),i("change",n)}const c=d=>l(d);function _(){o=this.value,t(2,o)}return r.$$set=d=>{"value"in d&&t(0,n=d.value),"name"in d&&t(1,a=d.name)},[n,a,o,s,l,c,_]}class sf extends Le{constructor(e){super(),Me(this,e,of,af,De,{value:0,name:1})}}function od(r,e,t){const n=r.slice();return n[25]=e[t][0],n[26]=e[t][1],n[27]=e,n[28]=t,n}function sd(r,e,t){const n=r.slice();return n[29]=e[t],n}function ld(r){let e,t,n,a,o,i,s,l,c,_,d,m,u,p,E,g,T,R,v,O,y,M,A,L,B,k,F,W,ee,ne,$,j,h,x,H,Z,K,ue,te,_e=Oe(r[3]),Q=[];for(let I=0;I<_e.length;I+=1)Q[I]=cd(sd(r,_e,I));let G=Oe(Object.entries(r[1].completionParams)),Y=[];for(let I=0;ID(Y[I],1,1,()=>{Y[I]=null});return ee=new we({props:{variant:"secondary",class:"mr-2",$$slots:{default:[pf]},$$scope:{ctx:r}}}),ee.$on("click",r[5]),$=new we({props:{variant:"secondary",$$slots:{default:[Ef]},$$scope:{ctx:r}}}),$.$on("click",r[6]),x=new we({props:{variant:"danger",$$slots:{default:[gf]},$$scope:{ctx:r}}}),x.$on("click",r[19]),Z=new zt({props:{open:r[4],$$slots:{default:[ff]},$$scope:{ctx:r}}}),Z.$on("close",r[20]),{c(){e=b("form"),t=b("div"),n=b("div"),a=b("label"),a.textContent="System message",o=U(),i=b("textarea"),s=U(),l=b("div"),c=b("div"),_=b("div"),d=b("label"),d.textContent="Preset name",m=U(),u=b("input"),p=U(),E=b("div"),g=b("label"),g.textContent="API Endpoint",T=U(),R=b("input"),v=U(),O=b("div"),y=b("label"),y.textContent="Provider API style",M=U(),A=b("select");for(let I=0;Ir[12].call(A)),f(O,"class","flex-1 flex flex-col"),f(c,"class","flex-1 space-y-2 mr-2"),f(B,"class","flex-1 space-y-2"),f(l,"class","w-full flex mt-2"),f(F,"class","flex justify-between mt-2"),f(e,"class","flex flex-1 flex-col")},m(I,V){P(I,e,V),S(e,t),S(t,n),S(n,a),S(n,o),S(n,i),Re(i,r[1].system),S(e,s),S(e,l),S(l,c),S(c,_),S(_,d),S(_,m),S(_,u),Re(u,r[1].name),S(c,p),S(c,E),S(E,g),S(E,T),S(E,R),Re(R,r[1].url),S(c,v),S(c,O),S(O,y),S(O,M),S(O,A);for(let me=0;meOn(e,"value",a)),{c(){le(e.$$.fragment)},m(i,s){ae(e,i,s),n=!0},p(i,s){r=i;const l={};s[0]&2&&(l.name=r[25]),!t&&s[0]&2&&(t=!0,l.value=r[1].completionParams[r[25]],bn(()=>t=!1)),e.$set(l)},i(i){n||(N(e.$$.fragment,i),n=!0)},o(i){D(e.$$.fragment,i),n=!1},d(i){ie(e,i)}}}function _f(r){let e,t,n,a;function o(){r[16].call(e,r[25])}return{c(){e=b("input"),f(e,"type","checkbox"),f(e,"name",t=r[25])},m(i,s){P(i,e,s),e.checked=r[1].completionParams[r[25]],n||(a=ge(e,"change",o),n=!0)},p(i,s){r=i,s[0]&10&&t!==(t=r[25])&&f(e,"name",t),s[0]&10&&(e.checked=r[1].completionParams[r[25]])},i:oe,o:oe,d(i){i&&w(e),n=!1,a()}}}function df(r){let e,t,n,a;function o(){r[15].call(e,r[25])}return{c(){e=b("input"),f(e,"type","number"),f(e,"step","any"),f(e,"class","w-full svelte-16936go"),f(e,"name",t=r[25])},m(i,s){P(i,e,s),Re(e,r[1].completionParams[r[25]]),n||(a=ge(e,"input",o),n=!0)},p(i,s){r=i,s[0]&10&&t!==(t=r[25])&&f(e,"name",t),s[0]&10&&Io(e.value)!==r[1].completionParams[r[25]]&&Re(e,r[1].completionParams[r[25]])},i:oe,o:oe,d(i){i&&w(e),n=!1,a()}}}function uf(r){let e,t,n,a;function o(){r[14].call(e,r[25])}return{c(){e=b("input"),f(e,"type","text"),f(e,"class","w-full svelte-16936go"),f(e,"name",t=r[25])},m(i,s){P(i,e,s),Re(e,r[1].completionParams[r[25]]),n||(a=ge(e,"input",o),n=!0)},p(i,s){r=i,s[0]&10&&t!==(t=r[25])&&f(e,"name",t),s[0]&10&&e.value!==r[1].completionParams[r[25]]&&Re(e,r[1].completionParams[r[25]])},i:oe,o:oe,d(i){i&&w(e),n=!1,a()}}}function mf(r){let e;return{c(){e=b("span"),e.textContent="Not included in request payload.",f(e,"class","italic opacity-70")},m(t,n){P(t,e,n)},p:oe,i:oe,o:oe,d(t){t&&w(e)}}}function _d(r){let e,t,n=r[25]+"",a,o,i,s,l,c,_,d,m,u,p,E,g,T,R;function v(){return r[13](r[25])}const O=[mf,uf,df,_f,cf,lf],y=[];function M(A,L){return L[0]&2&&(m=null),A[26]===null?0:typeof A[26]=="string"?1:typeof A[26]=="number"?2:typeof A[26]=="boolean"?3:(m==null&&(m=!!Array.isArray(A[26])),m?4:typeof A[26]=="object"?5:-1)}return~(u=M(r,[-1,-1]))&&(p=y[u]=O[u](r)),{c(){e=b("div"),t=b("label"),a=se(n),i=U(),s=b("div"),l=b("input"),_=U(),d=b("div"),p&&p.c(),E=U(),f(t,"for",o=r[25]),f(t,"class","svelte-16936go"),f(l,"type","checkbox"),l.checked=c=r[26]!==null,f(l,"class","mr-1"),f(d,"class","flex-1"),f(s,"class","flex items-center h-[20px]"),f(e,"class","flex-1 flex flex-col")},m(A,L){P(A,e,L),S(e,t),S(t,a),S(e,i),S(e,s),S(s,l),S(s,_),S(s,d),~u&&y[u].m(d,null),S(e,E),g=!0,T||(R=ge(l,"change",v),T=!0)},p(A,L){r=A,(!g||L[0]&2)&&n!==(n=r[25]+"")&&$e(a,n),(!g||L[0]&10&&o!==(o=r[25]))&&f(t,"for",o),(!g||L[0]&10&&c!==(c=r[26]!==null))&&(l.checked=c);let B=u;u=M(r,L),u===B?~u&&y[u].p(r,L):(p&&(Se(),D(y[B],1,1,()=>{y[B]=null}),fe()),~u?(p=y[u],p?p.p(r,L):(p=y[u]=O[u](r),p.c()),N(p,1),p.m(d,null)):p=null)},i(A){g||(N(p),g=!0)},o(A){D(p),g=!1},d(A){A&&w(e),~u&&y[u].d(),T=!1,R()}}}function pf(r){let e;return{c(){e=se("Save")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function Ef(r){let e;return{c(){e=se("Save As...")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function gf(r){let e;return{c(){e=se("Delete")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function Sf(r){let e;return{c(){e=se("Yes, delete")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function ff(r){let e,t,n,a,o;return a=new we({props:{variant:"danger",$$slots:{default:[Sf]},$$scope:{ctx:r}}}),a.$on("click",r[7]),{c(){e=b("p"),e.textContent="Are you sure you want to delete this preset? This action cannot be undone.",t=U(),n=b("div"),le(a.$$.fragment),f(n,"class","flex justify-center mt-4")},m(i,s){P(i,e,s),P(i,t,s),P(i,n,s),ae(a,n,null),o=!0},p(i,s){const l={};s[1]&2&&(l.$$scope={dirty:s,ctx:i}),a.$set(l)},i(i){o||(N(a.$$.fragment,i),o=!0)},o(i){D(a.$$.fragment,i),o=!1},d(i){i&&(w(e),w(t),w(n)),ie(a)}}}function Tf(r){let e,t,n=r[0]&&ld(r);return{c(){e=b("div"),n&&n.c(),f(e,"class","w-full flex-1 flex")},m(a,o){P(a,e,o),n&&n.m(e,null),t=!0},p(a,o){a[0]?n?(n.p(a,o),o[0]&1&&N(n,1)):(n=ld(a),n.c(),N(n,1),n.m(e,null)):n&&(Se(),D(n,1,1,()=>{n=null}),fe())},i(a){t||(N(n),t=!0)},o(a){D(n),t=!1},d(a){a&&w(e),n&&n.d()}}}const bf=()=>{};function Rf(r,e,t){let{preset:n}=e,a={...n},o,i=[];const s=Je(),l=()=>{s("getPresets")};mt.subscribe(k=>{ce.GET("activePreset").then(F=>{je.set(F)})}),ce.GET("providers").then(k=>{t(3,i=k)}),ce.GET("tokenizers").then(k=>{}),ce.GET("formats").then(k=>{}),je.subscribe(k=>{t(1,a={...k})});const c=()=>{ce.UPDATE("preset",a).then(()=>{l(),ce.GET("activePreset").then(k=>{je.set(k)})})},_=()=>{const k=IS(),F={...a,id:k};ce.CREATE("newPreset",F).then(()=>{l(),ce.GET("activePreset").then(W=>{je.set(W)})})};let d=!1;const m=()=>{t(4,d=!1),ce.DELETE("preset",a.id).then(()=>{l(),ce.GET("activePreset").then(k=>{je.set(k)})})},u=()=>{ce.GET("providerCompletionParams",a.provider).then(k=>{t(1,a.completionParams=k,a)})};gt(()=>{ce.GET("providerCompletionParams",a.provider).then(k=>{t(2,o=k)})});function p(){a.system=this.value,t(1,a),t(3,i)}function E(){a.name=this.value,t(1,a),t(3,i)}function g(){a.url=this.value,t(1,a),t(3,i)}function T(){a.provider=Sn(this),t(1,a),t(3,i)}const R=k=>a.completionParams[k]===null?t(1,a.completionParams[k]=o[k],a):t(1,a.completionParams[k]=null,a);function v(k){a.completionParams[k]=this.value,t(1,a),t(3,i)}function O(k){a.completionParams[k]=Io(this.value),t(1,a),t(3,i)}function y(k){a.completionParams[k]=this.checked,t(1,a),t(3,i)}function M(k,F){r.$$.not_equal(a.completionParams[F],k)&&(a.completionParams[F]=k,t(1,a))}function A(k){a.completionParams[k]=this.value,t(1,a),t(3,i)}const L=()=>t(4,d=!0),B=()=>t(4,d=!1);return r.$$set=k=>{"preset"in k&&t(0,n=k.preset)},[n,a,o,i,d,c,_,m,u,p,E,g,T,R,v,O,y,M,A,L,B]}class Cf extends Le{constructor(e){super(),Me(this,e,Rf,Tf,De,{preset:0},null,[-1,-1])}}function Nf(r){let e,t,n=[{xmlns:"http://www.w3.org/2000/svg"},{width:"1em"},{height:"1em"},{viewBox:"0 0 24 24"},r[0]],a={};for(let o=0;o{t(0,e=Be(Be({},e),ct(n)))},e=ct(e),[e]}class hf extends Le{constructor(e){super(),Me(this,e,Of,Nf,De,{})}}function dd(r,e,t){const n=r.slice();return n[2]=e[t],n}function ud(r){let e,t,n=Oe(r[0]),a=[];for(let i=0;iD(a[i],1,1,()=>{a[i]=null});return{c(){for(let i=0;i{m=null}),fe()),(!c||R&3&&l!==(l=Ne(`${((M=r[2])==null?void 0:M.id)===((A=r[1])==null?void 0:A.id)?"active":""} cursor-pointer opacity-50 flex justify-between`)+" svelte-1k1cx5"))&&f(e,"class",l)},i(T){c||(N(m),c=!0)},o(T){D(m),c=!1},d(T){T&&w(e),m&&m.d(),_=!1,d()}}}function If(r){let e,t,n,a,o,i,s,l,c,_=r[0]&&r[0].length&&ud(r);return l=new Cf({props:{preset:r[1]}}),l.$on("getPresets",r[3]),{c(){e=b("div"),t=b("div"),n=b("div"),n.textContent="Presets",a=U(),o=b("div"),_&&_.c(),i=U(),s=b("div"),le(l.$$.fragment),f(n,"class","font-semibold px-4 pt-2 select-none"),f(o,"class","flex flex-col"),f(t,"class","flex-0 border-r border-panel overflow-x-hidden overflow-y-auto"),f(s,"class","flex-1 p-2 flex flex-col overflow-x-hidden overflow-y-auto"),f(e,"class","flex flex-1 bg-neutral-500/10")},m(d,m){P(d,e,m),S(e,t),S(t,n),S(t,a),S(t,o),_&&_.m(o,null),S(e,i),S(e,s),ae(l,s,null),c=!0},p(d,[m]){d[0]&&d[0].length?_?(_.p(d,m),m&1&&N(_,1)):(_=ud(d),_.c(),N(_,1),_.m(o,null)):_&&(Se(),D(_,1,1,()=>{_=null}),fe());const u={};m&2&&(u.preset=d[1]),l.$set(u)},i(d){c||(N(_),N(l.$$.fragment,d),c=!0)},o(d){D(_),D(l.$$.fragment,d),c=!1},d(d){d&&w(e),_&&_.d(),ie(l)}}}function Af(r,e,t){let n,a;st(r,An,_=>t(0,n=_)),st(r,je,_=>t(1,a=_));const o=()=>{ce.GET("presets").then(_=>{An.set(_)})},i=()=>{ce.GET("activePreset").then(_=>{je.set(_)})};gt(()=>{o(),i()});let s;const l=_=>{ce.SET("activePreset",_).then(()=>{je.set(_)})};return je.subscribe(_=>{t(2,s=_)}),[n,a,s,o,l,_=>l(_)]}class vf extends Le{constructor(e){super(),Me(this,e,Af,If,De,{})}}function Ed(r,e,t){const n=r.slice();return n[20]=e[t],n}function yf(r){let e;return{c(){e=se("Close")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function gd(r){let e,t=r[20].label+"",n,a;return{c(){var o;e=b("option"),n=se(t),e.__value=a=(o=r[20])==null?void 0:o.id,Re(e,e.__value)},m(o,i){P(o,e,i),S(e,n)},p(o,i){var s;i&8&&t!==(t=o[20].label+"")&&$e(n,t),i&8&&a!==(a=(s=o[20])==null?void 0:s.id)&&(e.__value=a,Re(e,e.__value))},d(o){o&&w(e)}}}function Df(r){let e;return{c(){e=se("View supported interpolations")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function Mf(r){let e,t,n,a,o,i,s,l,c,_,d,m,u,p,E,g,T,R,v,O,y,M,A,L;return{c(){e=b("ul"),t=b("li"),n=b("code"),n.textContent="{{ft}}",a=se(` - Converts to the language ID of the active +`}}}}function cS(r){return(r.lang||"").match(/\S*/)[0]}function k_(r){return e=>{typeof e=="string"&&e!==r.text&&(r.escaped=!0,r.text=e)}}const U_=/[&<>"']/,_S=new RegExp(U_.source,"g"),F_=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,dS=new RegExp(F_.source,"g"),uS={"&":"&","<":"<",">":">",'"':""","'":"'"},B_=r=>uS[r];function G_(r,e){if(e){if(U_.test(r))return r.replace(_S,B_)}else if(F_.test(r))return r.replace(dS,B_);return r}const Y_={subscribe:null,addNotification:null,removeNotification:null,clearNotifications:null},uo=()=>fu(Y_);function mS(r){let e,t,n;var a=r[0];function o(i,s){return{props:{notification:i[1],withoutStyles:i[2],onRemove:i[3]}}}return a&&(e=vo(a,o(r))),{c(){e&&le(e.$$.fragment),t=_t()},m(i,s){e&&ae(e,i,s),P(i,t,s),n=!0},p(i,[s]){if(s&1&&a!==(a=i[0])){if(e){Se();const l=e;D(l.$$.fragment,1,0,()=>{ie(l,1)}),fe()}a?(e=vo(a,o(i)),le(e.$$.fragment),N(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(a){const l={};s&2&&(l.notification=i[1]),s&4&&(l.withoutStyles=i[2]),e.$set(l)}},i(i){n||(e&&N(e.$$.fragment,i),n=!0)},o(i){e&&D(e.$$.fragment,i),n=!1},d(i){i&&w(t),e&&ie(e,i)}}}function pS(r,e,t){let{item:n}=e,{notification:a={}}=e,{withoutStyles:o=!1}=e;const{removeNotification:i}=uo(),{id:s,removeAfter:l}=a,c=()=>i(s);let _=null;return l&&(_=setTimeout(c,l)),gu(()=>{l&&_&&clearTimeout(_)}),r.$$set=d=>{"item"in d&&t(0,n=d.item),"notification"in d&&t(1,a=d.notification),"withoutStyles"in d&&t(2,o=d.withoutStyles)},[n,a,o,c]}class ES extends Le{constructor(e){super(),Me(this,e,pS,mS,De,{item:0,notification:1,withoutStyles:2})}}function ot(r,{delay:e=0,duration:t=400,easing:n=Fe}={}){const a=+getComputedStyle(r).opacity;return{delay:e,duration:t,easing:n,css:o=>`opacity: ${o*a}`}}function gS(r){let e,t,n,a,o,i,s,l,c,_;const d=r[6].default,m=ht(d,r,r[5],null),u=m||SS(r);return{c(){e=b("div"),t=b("div"),u&&u.c(),n=U(),a=b("button"),o=se("×"),f(t,"class",Ne(r[2]("content"))+" svelte-1jw51vr"),f(a,"class",Ne(r[2]("button"))+" svelte-1jw51vr"),f(a,"aria-label","delete notification"),f(e,"class",Ne(r[2]())+" svelte-1jw51vr"),f(e,"role","status"),f(e,"aria-live","polite")},m(p,E){P(p,e,E),S(e,t),u&&u.m(t,null),S(e,n),S(e,a),S(a,o),l=!0,c||(_=ge(a,"click",function(){Ot(r[0])&&r[0].apply(this,arguments)}),c=!0)},p(p,E){r=p,m&&m.p&&(!l||E&32)&&At(m,d,r,r[5],l?It(d,r[5],E,null):vt(r[5]),null)},i(p){l||(N(u,p),p&&We(()=>{l&&(s&&s.end(1),i=Ru(e,ot,{}),i.start())}),l=!0)},o(p){D(u,p),i&&i.invalidate(),p&&(s=Cu(e,ot,{})),l=!1},d(p){p&&w(e),u&&u.d(p),p&&s&&s.end(),c=!1,_()}}}function SS(r){let e;return{c(){e=se(r[1])},m(t,n){P(t,e,n)},p:oe,d(t){t&&w(e)}}}function fS(r){let e,t,n=r[1]&&gS(r);return{c(){n&&n.c(),e=_t()},m(a,o){n&&n.m(a,o),P(a,e,o),t=!0},p(a,[o]){a[1]&&n.p(a,o)},i(a){t||(N(n),t=!0)},o(a){D(n),t=!1},d(a){a&&w(e),n&&n.d(a)}}}function TS(r,e,t){let{$$slots:n={},$$scope:a}=e,{notification:o={}}=e,{withoutStyles:i=!1}=e,{onRemove:s=null}=e;const{text:l,type:c}=o,_=d=>{const m=d?`-${d}`:"",u=` default-notification-style${m}`,p=c&&!d?` default-notification-${c}`:"";return`notification${m}${i?"":u}${p}`};return r.$$set=d=>{"notification"in d&&t(3,o=d.notification),"withoutStyles"in d&&t(4,i=d.withoutStyles),"onRemove"in d&&t(0,s=d.onRemove),"$$scope"in d&&t(5,a=d.$$scope)},[s,l,_,o,i,a,n]}class q_ extends Le{constructor(e){super(),Me(this,e,TS,fS,De,{notification:3,withoutStyles:4,onRemove:0})}}const mo=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],bS=(r,e)=>{if(!r)return;const{update:t}=e,n={id:`${new Date().getTime()}-${Math.floor(Math.random()*9999)}`,position:"bottom-center",text:"",...r};mo.includes(r.position)&&t(a=>n.position.includes("top-")?[n,...a]:[...a,n])},RS=(r,{update:e})=>{r&&e(t=>t.filter(({id:n})=>n!==r))},CS=r=>r.set([]),$_=(()=>{const r=ft([]);return{subscribe:r.subscribe,addNotification:e=>bS(e,r),removeNotification:e=>RS(e,r),clearNotifications:()=>CS(r)}})();function H_(r,e,t){const n=r.slice();return n[7]=e[t],n}function V_(r,e,t){const n=r.slice();return n[10]=e[t],n}function z_(r){let e,t;return e=new ES({props:{notification:r[10],withoutStyles:r[1],item:r[0]||q_}}),{c(){le(e.$$.fragment)},m(n,a){ae(e,n,a),t=!0},p(n,a){const o={};a&8&&(o.notification=n[10]),a&2&&(o.withoutStyles=n[1]),a&1&&(o.item=n[0]||q_),e.$set(o)},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){D(e.$$.fragment,n),t=!1},d(n){ie(e,n)}}}function W_(r,e){let t,n,a,o=e[10].position===e[7]&&z_(e);return{key:r,first:null,c(){t=_t(),o&&o.c(),n=_t(),this.first=t},m(i,s){P(i,t,s),o&&o.m(i,s),P(i,n,s),a=!0},p(i,s){e=i,e[10].position===e[7]?o?(o.p(e,s),s&8&&N(o,1)):(o=z_(e),o.c(),N(o,1),o.m(n.parentNode,n)):o&&(Se(),D(o,1,1,()=>{o=null}),fe())},i(i){a||(N(o),a=!0)},o(i){D(o),a=!1},d(i){i&&(w(t),w(n)),o&&o.d(i)}}}function K_(r){let e,t=[],n=new Map,a,o,i=Oe(r[3]);const s=l=>l[10].id;for(let l=0;lD(s[c],1,1,()=>{s[c]=null});return{c(){o&&o.c(),e=U(),t=b("div");for(let c=0;ct(3,n=_));let{$$slots:a={},$$scope:o}=e,{item:i=null}=e,{withoutStyles:s=!1}=e,{zIndex:l=null}=e;const c=(_="")=>{const d=` default-position-style-${_}`;return`position-${_}${s?"":d}`};return Su(Y_,$_),r.$$set=_=>{"item"in _&&t(0,i=_.item),"withoutStyles"in _&&t(1,s=_.withoutStyles),"zIndex"in _&&t(2,l=_.zIndex),"$$scope"in _&&t(5,o=_.$$scope)},[i,s,l,n,c,o,a]}class hS extends Le{constructor(e){super(),Me(this,e,OS,NS,De,{item:0,withoutStyles:1,zIndex:2})}}const IS=()=>Math.random().toString(36).substring(2,15);var Et=(r=>(r.ChatInitiated="chatInitiated",r.ChatMessageSent="chatMessageSent",r.ChatMessageReceived="chatMessageReceived",r.ChatEnded="chatEnded",r))(Et||{});function AS(r){const{addNotification:e}=uo();return ce.on("notification",t=>{e({text:t.message,position:"top-right",type:"info",removeAfter:2e3})}),ce.on("notificationError",t=>{e({text:t.message,position:"top-right",type:"error",removeAfter:2e3})}),ce.on("notificationWarning",t=>{e({text:t.message,position:"top-right",type:"warning",removeAfter:2e3})}),ce.on("notificationSuccess",t=>{e({text:t.message,position:"top-right",type:"success",removeAfter:2e3})}),[]}class vS extends Le{constructor(e){super(),Me(this,e,AS,null,De,{})}}function yS(r){let e,t,n,a,o;const i=r[5].default,s=ht(i,r,r[4],null);return{c(){e=b("button"),s&&s.c(),f(e,"class",t=Ne(`bg-${r[0]} size-${r[1]} ${r[2]}`)+" svelte-jsk6qy")},m(l,c){P(l,e,c),s&&s.m(e,null),n=!0,a||(o=ge(e,"click",r[3]),a=!0)},p(l,[c]){s&&s.p&&(!n||c&16)&&At(s,i,l,l[4],n?It(i,l[4],c,null):vt(l[4]),null),(!n||c&7&&t!==(t=Ne(`bg-${l[0]} size-${l[1]} ${l[2]}`)+" svelte-jsk6qy"))&&f(e,"class",t)},i(l){n||(N(s,l),n=!0)},o(l){D(s,l),n=!1},d(l){l&&w(e),s&&s.d(l),a=!1,o()}}}function DS(r,e,t){let{$$slots:n={},$$scope:a}=e,{variant:o="primary"}=e,{size:i="md"}=e,{class:s=""}=e;const l=Je();function c(){l("click")}return r.$$set=_=>{"variant"in _&&t(0,o=_.variant),"size"in _&&t(1,i=_.size),"class"in _&&t(2,s=_.class),"$$scope"in _&&t(4,a=_.$$scope)},[o,i,s,c,a,n]}class we extends Le{constructor(e){super(),Me(this,e,DS,yS,De,{variant:0,size:1,class:2})}}function MS(r){let e;return{c(){e=b("div"),f(e,"class","space-y-4 overflow-hidden highlighter svelte-1ieua60")},m(t,n){P(t,e,n),e.innerHTML=r[0]},p(t,[n]){n&1&&(e.innerHTML=t[0])},i:oe,o:oe,d(t){t&&w(e)}}}function LS(r,e,t){let{code:n=""}=e,a="";return r.$$set=o=>{"code"in o&&t(1,n=o.code)},r.$$.update=()=>{r.$$.dirty&2&&t(0,a=ve(n))},[a,n]}class wS extends Le{constructor(e){super(),Me(this,e,LS,MS,De,{code:1})}}function xS(r){let e,t,n,a,o,i=[{xmlns:"http://www.w3.org/2000/svg"},{width:"1em"},{height:"1em"},{viewBox:"0 0 14 14"},r[0]],s={};for(let l=0;l{t(0,e=Be(Be({},e),ct(n)))},e=ct(e),[e]}class kS extends Le{constructor(e){super(),Me(this,e,PS,xS,De,{})}}function US(r){let e,t,n=[{xmlns:"http://www.w3.org/2000/svg"},{width:"1em"},{height:"1em"},{viewBox:"0 0 48 48"},r[0]],a={};for(let o=0;o{t(0,e=Be(Be({},e),ct(n)))},e=ct(e),[e]}class BS extends Le{constructor(e){super(),Me(this,e,FS,US,De,{})}}function GS(r){let e,t;return e=new kS({props:{class:"w-6 h-6 mr-2"}}),{c(){le(e.$$.fragment)},m(n,a){ae(e,n,a),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){D(e.$$.fragment,n),t=!1},d(n){ie(e,n)}}}function YS(r){let e,t;return e=new BS({props:{class:"w-6 h-6 mr-2"}}),{c(){le(e.$$.fragment)},m(n,a){ae(e,n,a),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){D(e.$$.fragment,n),t=!1},d(n){ie(e,n)}}}function Q_(r){let e,t,n;return{c(){e=ze("svg"),t=ze("circle"),n=ze("path"),f(t,"class","opacity-25"),f(t,"cx","12"),f(t,"cy","12"),f(t,"r","10"),f(t,"stroke","currentColor"),f(t,"stroke-width","4"),f(n,"class","opacity-75"),f(n,"fill","currentColor"),f(n,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),f(e,"class","mt-2 animate-spin h-6 w-6 foreground svelte-lnb535"),f(e,"xmlns","http://www.w3.org/2000/svg"),f(e,"fill","none"),f(e,"viewBox","0 0 24 24")},m(a,o){P(a,e,o),S(e,t),S(e,n)},d(a){a&&w(e)}}}function qS(r){let e,t,n,a,o,i,s,l,c,_;const d=[YS,GS],m=[];function u(E,g){return E[0]==="user"?0:E[0]==="assistant"?1:-1}~(n=u(r))&&(a=m[n]=d[n](r)),l=new wS({props:{code:r[1]}});let p=r[2]&&r[3]&&Q_();return{c(){e=b("div"),t=b("div"),a&&a.c(),o=U(),i=b("div"),s=b("div"),le(l.$$.fragment),c=U(),p&&p.c(),f(s,"class","message p-4 flex flex-col max-w-[768px] svelte-lnb535"),f(i,"class","flex-1 overflow-hidden"),f(t,"class","flex items-start"),f(e,"class","mb-4 w-full max-w-[768px]")},m(E,g){P(E,e,g),S(e,t),~n&&m[n].m(t,null),S(t,o),S(t,i),S(i,s),ae(l,s,null),S(s,c),p&&p.m(s,null),r[8](s),_=!0},p(E,[g]){let T=n;n=u(E),n!==T&&(a&&(Se(),D(m[T],1,1,()=>{m[T]=null}),fe()),~n?(a=m[n],a||(a=m[n]=d[n](E),a.c()),N(a,1),a.m(t,o)):a=null);const R={};g&2&&(R.code=E[1]),l.$set(R),E[2]&&E[3]?p||(p=Q_(),p.c(),p.m(s,null)):p&&(p.d(1),p=null)},i(E){_||(N(a),N(l.$$.fragment,E),_=!0)},o(E){D(a),D(l.$$.fragment,E),_=!1},d(E){E&&w(e),~n&&m[n].d(),ie(l),p&&p.d(),r[8](null)}}}function $S(r,e,t){let{from:n="user"}=e,{message:a=""}=e,{responseInProgress:o=!1}=e,{isLastMessage:i=!1}=e,{showCompareSource:s=!0}=e;const l=Je();let c,_=[],d=!1;const{addNotification:m}=uo();function u(p){nt[p?"unshift":"push"](()=>{c=p,t(4,c)})}return r.$$set=p=>{"from"in p&&t(0,n=p.from),"message"in p&&t(1,a=p.message),"responseInProgress"in p&&t(2,o=p.responseInProgress),"isLastMessage"in p&&t(3,i=p.isLastMessage),"showCompareSource"in p&&t(5,s=p.showCompareSource)},r.$$.update=()=>{if(r.$$.dirty&247&&(!o&&!d&&c&&a.length&&(t(7,d=!0),t(6,_=c.querySelectorAll("pre > code"))),_.length)){let p=!1;_.forEach(E=>{var T,R;if((T=E.parentElement)!=null&&T.querySelector("[data-actions]")){p=!0;return}const g=document.createElement("div");g.setAttribute("data-actions",""),(R=E.parentNode)==null||R.appendChild(g)}),p||(_.forEach(E=>{var T,R;const g=document.createElement("button");g.textContent="Copy",g.classList.add("action-button"),g.addEventListener("click",()=>{var v;navigator.clipboard.writeText(((v=E.textContent)==null?void 0:v.trim())||""),m({text:"Copied to clipboard",position:"top-center",type:"info",removeAfter:1e3})}),(R=(T=E.parentElement)==null?void 0:T.querySelector("[data-actions]"))==null||R.appendChild(g)}),n==="assistant"&&_.forEach(E=>{var T,R;const g=document.createElement("button");g.textContent="Compare with selection",g.classList.add("action-button"),g.addEventListener("click",()=>{var O;const v=((O=E.textContent)==null?void 0:O.trim())||"";ce.DIFF_SELECTION(v)}),(R=(T=E.parentElement)==null?void 0:T.querySelector("[data-actions]"))==null||R.appendChild(g)}),s&&n==="assistant"&&_.forEach(E=>{var T,R;const g=document.createElement("button");g.textContent="Compare with source",g.classList.add("action-button"),g.addEventListener("click",()=>{var O;const v=((O=E.textContent)==null?void 0:O.trim())||"";ce.DIFF(v)}),(R=(T=E.parentElement)==null?void 0:T.querySelector("[data-actions]"))==null||R.appendChild(g)}),_.forEach(E=>{var g,T;if(n==="assistant"){const R=document.createElement("button");R.textContent="Replace selection",R.classList.add("action-button"),R.addEventListener("click",()=>{var O;const v=((O=E.textContent)==null?void 0:O.trim())||"";ce.REPLACE_SELECTION(v)}),(T=(g=E.parentElement)==null?void 0:g.querySelector("[data-actions]"))==null||T.appendChild(R)}})),setTimeout(()=>{l("scrollToBottom")},50)}},[n,a,o,i,c,s,_,d,u]}class X_ extends Le{constructor(e){super(),Me(this,e,$S,qS,De,{from:0,message:1,responseInProgress:2,isLastMessage:3,showCompareSource:5})}}function Z_(r,e,t){const n=r.slice();return n[12]=e[t],n}function J_(r,e,t){const n=r.slice();return n[9]=e[t],n}function HS(r){let e,t,n,a,o,i,s,l,c;n=new we({props:{variant:"subtle",size:"lg",$$slots:{default:[zS]},$$scope:{ctx:r}}}),n.$on("click",r[5]);let _=Oe(r[1].messages),d=[];for(let u=0;u<_.length;u+=1)d[u]=j_(Z_(r,_,u));const m=u=>D(d[u],1,1,()=>{d[u]=null});return l=new we({props:{variant:"subtle",size:"lg",$$slots:{default:[WS]},$$scope:{ctx:r}}}),l.$on("click",r[6]),{c(){e=b("div"),t=b("div"),le(n.$$.fragment),a=U(),o=b("div");for(let u=0;uD(a[i],1,1,()=>{a[i]=null});return{c(){for(let i=0;i{i[_]=null}),fe(),n=i[t],n?n.p(l,c):(n=i[t]=o[t](l),n.c()),N(n,1),n.m(e,null))},i(l){a||(N(n),a=!0)},o(l){D(n),a=!1},d(l){l&&w(e),i[t].d()}}}function td(r){const e=Math.floor((new Date().getTime()-r.getTime())/1e3),t=Math.floor(e/31536e3),n=Math.floor(e/2592e3),a=Math.floor(e/86400),o=Math.floor(e/3600),i=Math.floor(e/60),s=(l,c)=>l>1?`${l} ${c}s ago`:l===1?`${l} ${c} ago`:"";return s(t,"year")||s(n,"month")||s(a,"day")||s(o,"hour")||s(i,"minute")||"just now"}function XS(r,e,t){let{chatHistory:n=[]}=e,a;const o=m=>{t(1,a=m),lt().then(()=>{s()})};let i;const s=()=>{i&&t(2,i.scrollTop=i.scrollHeight,i)},l=m=>o(m),c=()=>o(null),_=()=>o(null);function d(m){nt[m?"unshift":"push"](()=>{i=m,t(2,i)})}return r.$$set=m=>{"chatHistory"in m&&t(0,n=m.chatHistory)},[n,a,i,o,l,c,_,d]}class ZS extends Le{constructor(e){super(),Me(this,e,XS,QS,De,{chatHistory:0})}}function JS(r){let e,t,n,a,o,i,s;const l=r[3].default,c=ht(l,r,r[2],null);return{c(){e=b("div"),t=se(r[0]),a=U(),o=b("div"),c&&c.c(),f(e,"class",n=Ne(`font-semibold px-4 py-2 select-none border-b border-neutral-500/50 mb-2 ${r[1]?"opacity-30":""}`)+" svelte-1yi5wo6"),f(o,"class",i=Ne(`command-list pb-2 ${r[1]?"pointer-events-none opacity-30 cursor-not-allowed":""}`)+" svelte-1yi5wo6")},m(_,d){P(_,e,d),S(e,t),P(_,a,d),P(_,o,d),c&&c.m(o,null),s=!0},p(_,[d]){(!s||d&1)&&$e(t,_[0]),(!s||d&2&&n!==(n=Ne(`font-semibold px-4 py-2 select-none border-b border-neutral-500/50 mb-2 ${_[1]?"opacity-30":""}`)+" svelte-1yi5wo6"))&&f(e,"class",n),c&&c.p&&(!s||d&4)&&At(c,l,_,_[2],s?It(l,_[2],d,null):vt(_[2]),null),(!s||d&2&&i!==(i=Ne(`command-list pb-2 ${_[1]?"pointer-events-none opacity-30 cursor-not-allowed":""}`)+" svelte-1yi5wo6"))&&f(o,"class",i)},i(_){s||(N(c,_),s=!0)},o(_){D(c,_),s=!1},d(_){_&&(w(e),w(a),w(o)),c&&c.d(_)}}}function jS(r,e,t){let{$$slots:n={},$$scope:a}=e,{category:o="Category"}=e,{disabled:i=!1}=e;return r.$$set=s=>{"category"in s&&t(0,o=s.category),"disabled"in s&&t(1,i=s.disabled),"$$scope"in s&&t(2,a=s.$$scope)},[o,i,a,n]}class ef extends Le{constructor(e){super(),Me(this,e,jS,JS,De,{category:0,disabled:1})}}function nd(r){let e,t,n,a,o,i,s,l;const c=r[2].default,_=ht(c,r,r[4],null);return o=new we({props:{variant:"secondary",$$slots:{default:[tf]},$$scope:{ctx:r}}}),o.$on("click",r[1]),{c(){e=b("div"),t=b("div"),_&&_.c(),n=U(),a=b("div"),le(o.$$.fragment),f(a,"class","flex justify-end mt-4"),f(t,"class","bg-neutral-800 text-white p-4 rounded-md shadow-xl max-w-[75%]"),f(e,"role","dialog"),f(e,"class","fixed top-0 left-0 right-0 bottom-0 w-full h-full bg-neutral-500/50 flex items-center justify-center z-50")},m(d,m){P(d,e,m),S(e,t),_&&_.m(t,null),S(t,n),S(t,a),ae(o,a,null),i=!0,s||(l=[ge(t,"click",_u(r[3])),ge(e,"click",r[1])],s=!0)},p(d,m){_&&_.p&&(!i||m&16)&&At(_,c,d,d[4],i?It(c,d[4],m,null):vt(d[4]),null);const u={};m&16&&(u.$$scope={dirty:m,ctx:d}),o.$set(u)},i(d){i||(N(_,d),N(o.$$.fragment,d),i=!0)},o(d){D(_,d),D(o.$$.fragment,d),i=!1},d(d){d&&w(e),_&&_.d(d),ie(o),s=!1,He(l)}}}function tf(r){let e;return{c(){e=se("Close")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function nf(r){let e,t,n=r[0]&&nd(r);return{c(){n&&n.c(),e=_t()},m(a,o){n&&n.m(a,o),P(a,e,o),t=!0},p(a,[o]){a[0]?n?(n.p(a,o),o&1&&N(n,1)):(n=nd(a),n.c(),N(n,1),n.m(e.parentNode,e)):n&&(Se(),D(n,1,1,()=>{n=null}),fe())},i(a){t||(N(n),t=!0)},o(a){D(n),t=!1},d(a){a&&w(e),n&&n.d(a)}}}function rf(r,e,t){let{$$slots:n={},$$scope:a}=e,{open:o=!1}=e;const i=Je();function s(){t(0,o=!1),i("close")}function l(c){Yt.call(this,r,c)}return r.$$set=c=>{"open"in c&&t(0,o=c.open),"$$scope"in c&&t(4,a=c.$$scope)},[o,s,n,l,a]}class zt extends Le{constructor(e){super(),Me(this,e,rf,nf,De,{open:0})}}function rd(r,e,t){const n=r.slice();return n[8]=e[t],n}function ad(r){let e,t=Oe(r[0]),n=[];for(let a=0;a0&&ad(r);return{c(){e=b("div"),i&&i.c(),t=U(),n=b("input"),f(n,"name",r[1]),f(n,"type","text"),f(n,"placeholder","Add item"),f(n,"class","svelte-l3hrh8"),f(e,"class","tags-input svelte-l3hrh8")},m(s,l){P(s,e,l),i&&i.m(e,null),S(e,t),S(e,n),Re(n,r[2]),a||(o=[ge(n,"input",r[6]),ge(n,"keydown",r[3])],a=!0)},p(s,[l]){s[0].length>0?i?i.p(s,l):(i=ad(s),i.c(),i.m(e,t)):i&&(i.d(1),i=null),l&2&&f(n,"name",s[1]),l&4&&n.value!==s[2]&&Re(n,s[2])},i:oe,o:oe,d(s){s&&w(e),i&&i.d(),a=!1,He(o)}}}function of(r,e,t){let{value:n=[]}=e,{name:a=""}=e,o="";const i=Je();function s(d){d.key==="Enter"&&o.trim()&&(d.preventDefault(),t(0,n=[...n,o.trim()]),i("change",n),t(2,o=""))}function l(d){t(0,n=n.filter(m=>m!==d)),i("change",n)}const c=d=>l(d);function _(){o=this.value,t(2,o)}return r.$$set=d=>{"value"in d&&t(0,n=d.value),"name"in d&&t(1,a=d.name)},[n,a,o,s,l,c,_]}class sf extends Le{constructor(e){super(),Me(this,e,of,af,De,{value:0,name:1})}}function od(r,e,t){const n=r.slice();return n[25]=e[t][0],n[26]=e[t][1],n[27]=e,n[28]=t,n}function sd(r,e,t){const n=r.slice();return n[29]=e[t],n}function ld(r){let e,t,n,a,o,i,s,l,c,_,d,m,u,p,E,g,T,R,v,O,y,M,A,L,B,k,F,W,ee,ne,$,j,h,x,H,Z,K,ue,te,_e=Oe(r[3]),Q=[];for(let I=0;I<_e.length;I+=1)Q[I]=cd(sd(r,_e,I));let G=Oe(Object.entries(r[1].completionParams)),Y=[];for(let I=0;ID(Y[I],1,1,()=>{Y[I]=null});return ee=new we({props:{variant:"secondary",class:"mr-2",$$slots:{default:[pf]},$$scope:{ctx:r}}}),ee.$on("click",r[5]),$=new we({props:{variant:"secondary",$$slots:{default:[Ef]},$$scope:{ctx:r}}}),$.$on("click",r[6]),x=new we({props:{variant:"danger",$$slots:{default:[gf]},$$scope:{ctx:r}}}),x.$on("click",r[19]),Z=new zt({props:{open:r[4],$$slots:{default:[ff]},$$scope:{ctx:r}}}),Z.$on("close",r[20]),{c(){e=b("form"),t=b("div"),n=b("div"),a=b("label"),a.textContent="System message",o=U(),i=b("textarea"),s=U(),l=b("div"),c=b("div"),_=b("div"),d=b("label"),d.textContent="Preset name",m=U(),u=b("input"),p=U(),E=b("div"),g=b("label"),g.textContent="API Endpoint",T=U(),R=b("input"),v=U(),O=b("div"),y=b("label"),y.textContent="Provider API style",M=U(),A=b("select");for(let I=0;Ir[12].call(A)),f(O,"class","flex-1 flex flex-col"),f(c,"class","flex-1 space-y-2 mr-2"),f(B,"class","flex-1 space-y-2"),f(l,"class","w-full flex mt-2"),f(F,"class","flex justify-between mt-2"),f(e,"class","flex flex-1 flex-col")},m(I,V){P(I,e,V),S(e,t),S(t,n),S(n,a),S(n,o),S(n,i),Re(i,r[1].system),S(e,s),S(e,l),S(l,c),S(c,_),S(_,d),S(_,m),S(_,u),Re(u,r[1].name),S(c,p),S(c,E),S(E,g),S(E,T),S(E,R),Re(R,r[1].url),S(c,v),S(c,O),S(O,y),S(O,M),S(O,A);for(let me=0;meOn(e,"value",a)),{c(){le(e.$$.fragment)},m(i,s){ae(e,i,s),n=!0},p(i,s){r=i;const l={};s[0]&2&&(l.name=r[25]),!t&&s[0]&2&&(t=!0,l.value=r[1].completionParams[r[25]],bn(()=>t=!1)),e.$set(l)},i(i){n||(N(e.$$.fragment,i),n=!0)},o(i){D(e.$$.fragment,i),n=!1},d(i){ie(e,i)}}}function _f(r){let e,t,n,a;function o(){r[16].call(e,r[25])}return{c(){e=b("input"),f(e,"type","checkbox"),f(e,"name",t=r[25])},m(i,s){P(i,e,s),e.checked=r[1].completionParams[r[25]],n||(a=ge(e,"change",o),n=!0)},p(i,s){r=i,s[0]&10&&t!==(t=r[25])&&f(e,"name",t),s[0]&10&&(e.checked=r[1].completionParams[r[25]])},i:oe,o:oe,d(i){i&&w(e),n=!1,a()}}}function df(r){let e,t,n,a;function o(){r[15].call(e,r[25])}return{c(){e=b("input"),f(e,"type","number"),f(e,"step","any"),f(e,"class","w-full svelte-16936go"),f(e,"name",t=r[25])},m(i,s){P(i,e,s),Re(e,r[1].completionParams[r[25]]),n||(a=ge(e,"input",o),n=!0)},p(i,s){r=i,s[0]&10&&t!==(t=r[25])&&f(e,"name",t),s[0]&10&&Io(e.value)!==r[1].completionParams[r[25]]&&Re(e,r[1].completionParams[r[25]])},i:oe,o:oe,d(i){i&&w(e),n=!1,a()}}}function uf(r){let e,t,n,a;function o(){r[14].call(e,r[25])}return{c(){e=b("input"),f(e,"type","text"),f(e,"class","w-full svelte-16936go"),f(e,"name",t=r[25])},m(i,s){P(i,e,s),Re(e,r[1].completionParams[r[25]]),n||(a=ge(e,"input",o),n=!0)},p(i,s){r=i,s[0]&10&&t!==(t=r[25])&&f(e,"name",t),s[0]&10&&e.value!==r[1].completionParams[r[25]]&&Re(e,r[1].completionParams[r[25]])},i:oe,o:oe,d(i){i&&w(e),n=!1,a()}}}function mf(r){let e;return{c(){e=b("span"),e.textContent="Not included in request payload.",f(e,"class","italic opacity-70")},m(t,n){P(t,e,n)},p:oe,i:oe,o:oe,d(t){t&&w(e)}}}function _d(r){let e,t,n=r[25]+"",a,o,i,s,l,c,_,d,m,u,p,E,g,T,R;function v(){return r[13](r[25])}const O=[mf,uf,df,_f,cf,lf],y=[];function M(A,L){return L[0]&2&&(m=null),A[26]===null?0:typeof A[26]=="string"?1:typeof A[26]=="number"?2:typeof A[26]=="boolean"?3:(m==null&&(m=!!Array.isArray(A[26])),m?4:typeof A[26]=="object"?5:-1)}return~(u=M(r,[-1,-1]))&&(p=y[u]=O[u](r)),{c(){e=b("div"),t=b("label"),a=se(n),i=U(),s=b("div"),l=b("input"),_=U(),d=b("div"),p&&p.c(),E=U(),f(t,"for",o=r[25]),f(t,"class","svelte-16936go"),f(l,"type","checkbox"),l.checked=c=r[26]!==null,f(l,"class","mr-1"),f(d,"class","flex-1"),f(s,"class","flex items-center h-[20px]"),f(e,"class","flex-1 flex flex-col")},m(A,L){P(A,e,L),S(e,t),S(t,a),S(e,i),S(e,s),S(s,l),S(s,_),S(s,d),~u&&y[u].m(d,null),S(e,E),g=!0,T||(R=ge(l,"change",v),T=!0)},p(A,L){r=A,(!g||L[0]&2)&&n!==(n=r[25]+"")&&$e(a,n),(!g||L[0]&10&&o!==(o=r[25]))&&f(t,"for",o),(!g||L[0]&10&&c!==(c=r[26]!==null))&&(l.checked=c);let B=u;u=M(r,L),u===B?~u&&y[u].p(r,L):(p&&(Se(),D(y[B],1,1,()=>{y[B]=null}),fe()),~u?(p=y[u],p?p.p(r,L):(p=y[u]=O[u](r),p.c()),N(p,1),p.m(d,null)):p=null)},i(A){g||(N(p),g=!0)},o(A){D(p),g=!1},d(A){A&&w(e),~u&&y[u].d(),T=!1,R()}}}function pf(r){let e;return{c(){e=se("Save")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function Ef(r){let e;return{c(){e=se("Save As...")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function gf(r){let e;return{c(){e=se("Delete")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function Sf(r){let e;return{c(){e=se("Yes, delete")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function ff(r){let e,t,n,a,o;return a=new we({props:{variant:"danger",$$slots:{default:[Sf]},$$scope:{ctx:r}}}),a.$on("click",r[7]),{c(){e=b("p"),e.textContent="Are you sure you want to delete this preset? This action cannot be undone.",t=U(),n=b("div"),le(a.$$.fragment),f(n,"class","flex justify-center mt-4")},m(i,s){P(i,e,s),P(i,t,s),P(i,n,s),ae(a,n,null),o=!0},p(i,s){const l={};s[1]&2&&(l.$$scope={dirty:s,ctx:i}),a.$set(l)},i(i){o||(N(a.$$.fragment,i),o=!0)},o(i){D(a.$$.fragment,i),o=!1},d(i){i&&(w(e),w(t),w(n)),ie(a)}}}function Tf(r){let e,t,n=r[0]&&ld(r);return{c(){e=b("div"),n&&n.c(),f(e,"class","w-full flex-1 flex")},m(a,o){P(a,e,o),n&&n.m(e,null),t=!0},p(a,o){a[0]?n?(n.p(a,o),o[0]&1&&N(n,1)):(n=ld(a),n.c(),N(n,1),n.m(e,null)):n&&(Se(),D(n,1,1,()=>{n=null}),fe())},i(a){t||(N(n),t=!0)},o(a){D(n),t=!1},d(a){a&&w(e),n&&n.d()}}}const bf=()=>{};function Rf(r,e,t){let{preset:n}=e,a={...n},o,i=[];const s=Je(),l=()=>{s("getPresets")};mt.subscribe(k=>{ce.GET("activePreset").then(F=>{je.set(F)})}),ce.GET("providers").then(k=>{t(3,i=k)}),ce.GET("tokenizers").then(k=>{}),ce.GET("formats").then(k=>{}),je.subscribe(k=>{t(1,a={...k})});const c=()=>{ce.UPDATE("preset",a).then(()=>{l(),ce.GET("activePreset").then(k=>{je.set(k)})})},_=()=>{const k=IS(),F={...a,id:k};ce.CREATE("newPreset",F).then(()=>{l(),ce.GET("activePreset").then(W=>{je.set(W)})})};let d=!1;const m=()=>{t(4,d=!1),ce.DELETE("preset",a.id).then(()=>{l(),ce.GET("activePreset").then(k=>{je.set(k)})})},u=()=>{ce.GET("providerCompletionParams",a.provider).then(k=>{t(1,a.completionParams=k,a)})};gt(()=>{ce.GET("providerCompletionParams",a.provider).then(k=>{t(2,o=k)})});function p(){a.system=this.value,t(1,a),t(3,i)}function E(){a.name=this.value,t(1,a),t(3,i)}function g(){a.url=this.value,t(1,a),t(3,i)}function T(){a.provider=Sn(this),t(1,a),t(3,i)}const R=k=>a.completionParams[k]===null?t(1,a.completionParams[k]=o[k],a):t(1,a.completionParams[k]=null,a);function v(k){a.completionParams[k]=this.value,t(1,a),t(3,i)}function O(k){a.completionParams[k]=Io(this.value),t(1,a),t(3,i)}function y(k){a.completionParams[k]=this.checked,t(1,a),t(3,i)}function M(k,F){r.$$.not_equal(a.completionParams[F],k)&&(a.completionParams[F]=k,t(1,a))}function A(k){a.completionParams[k]=this.value,t(1,a),t(3,i)}const L=()=>t(4,d=!0),B=()=>t(4,d=!1);return r.$$set=k=>{"preset"in k&&t(0,n=k.preset)},[n,a,o,i,d,c,_,m,u,p,E,g,T,R,v,O,y,M,A,L,B]}class Cf extends Le{constructor(e){super(),Me(this,e,Rf,Tf,De,{preset:0},null,[-1,-1])}}function Nf(r){let e,t,n=[{xmlns:"http://www.w3.org/2000/svg"},{width:"1em"},{height:"1em"},{viewBox:"0 0 24 24"},r[0]],a={};for(let o=0;o{t(0,e=Be(Be({},e),ct(n)))},e=ct(e),[e]}class hf extends Le{constructor(e){super(),Me(this,e,Of,Nf,De,{})}}function dd(r,e,t){const n=r.slice();return n[2]=e[t],n}function ud(r){let e,t,n=Oe(r[0]),a=[];for(let i=0;iD(a[i],1,1,()=>{a[i]=null});return{c(){for(let i=0;i{m=null}),fe()),(!c||R&3&&l!==(l=Ne(`${((M=r[2])==null?void 0:M.id)===((A=r[1])==null?void 0:A.id)?"active":""} cursor-pointer opacity-50 flex justify-between`)+" svelte-1k1cx5"))&&f(e,"class",l)},i(T){c||(N(m),c=!0)},o(T){D(m),c=!1},d(T){T&&w(e),m&&m.d(),_=!1,d()}}}function If(r){let e,t,n,a,o,i,s,l,c,_=r[0]&&r[0].length&&ud(r);return l=new Cf({props:{preset:r[1]}}),l.$on("getPresets",r[3]),{c(){e=b("div"),t=b("div"),n=b("div"),n.textContent="Presets",a=U(),o=b("div"),_&&_.c(),i=U(),s=b("div"),le(l.$$.fragment),f(n,"class","font-semibold px-4 pt-2 select-none"),f(o,"class","flex flex-col"),f(t,"class","flex-0 border-r border-panel overflow-x-hidden overflow-y-auto"),f(s,"class","flex-1 p-2 flex flex-col overflow-x-hidden overflow-y-auto"),f(e,"class","flex flex-1 bg-neutral-500/10")},m(d,m){P(d,e,m),S(e,t),S(t,n),S(t,a),S(t,o),_&&_.m(o,null),S(e,i),S(e,s),ae(l,s,null),c=!0},p(d,[m]){d[0]&&d[0].length?_?(_.p(d,m),m&1&&N(_,1)):(_=ud(d),_.c(),N(_,1),_.m(o,null)):_&&(Se(),D(_,1,1,()=>{_=null}),fe());const u={};m&2&&(u.preset=d[1]),l.$set(u)},i(d){c||(N(_),N(l.$$.fragment,d),c=!0)},o(d){D(_),D(l.$$.fragment,d),c=!1},d(d){d&&w(e),_&&_.d(),ie(l)}}}function Af(r,e,t){let n,a;st(r,An,_=>t(0,n=_)),st(r,je,_=>t(1,a=_));const o=()=>{ce.GET("presets").then(_=>{An.set(_)})},i=()=>{ce.GET("activePreset").then(_=>{je.set(_)})};gt(()=>{o(),i()});let s;const l=_=>{ce.SET("activePreset",_).then(()=>{je.set(_)})};return je.subscribe(_=>{t(2,s=_)}),[n,a,s,o,l,_=>l(_)]}class vf extends Le{constructor(e){super(),Me(this,e,Af,If,De,{})}}function Ed(r,e,t){const n=r.slice();return n[20]=e[t],n}function yf(r){let e;return{c(){e=se("Close")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function gd(r){let e,t=r[20].label+"",n,a;return{c(){var o;e=b("option"),n=se(t),e.__value=a=(o=r[20])==null?void 0:o.id,Re(e,e.__value)},m(o,i){P(o,e,i),S(e,n)},p(o,i){var s;i&8&&t!==(t=o[20].label+"")&&$e(n,t),i&8&&a!==(a=(s=o[20])==null?void 0:s.id)&&(e.__value=a,Re(e,e.__value))},d(o){o&&w(e)}}}function Df(r){let e;return{c(){e=se("View supported interpolations")},m(t,n){P(t,e,n)},d(t){t&&w(e)}}}function Mf(r){let e,t,n,a,o,i,s,l,c,_,d,m,u,p,E,g,T,R,v,O,y,M,A,L;return{c(){e=b("ul"),t=b("li"),n=b("code"),n.textContent="{{ft}}",a=se(` - Converts to the language ID of the active window, e.g. "cpp".`),o=U(),i=b("li"),s=b("code"),s.textContent="{{language}}",l=se(` - Takes the language ID of the active window, e.g. "cpp" and converts it to a human-readable language name, e.g. "C++". Works with all known VSCode language identifiers.`),c=U(),_=b("li"),d=b("code"),d.textContent="{{input}}",m=se(` - Prompts for, and is replaced by, user diff --git a/extension/src/random.txt b/extension/src/random.txt deleted file mode 100644 index 87bac02..0000000 --- a/extension/src/random.txt +++ /dev/null @@ -1 +0,0 @@ -The cat and dog, which was friends, goes to the park every day. In there, they seen many interesting things like birds, trees, and sometimes fishes in the small pond. The weather is always shiny and the grasses is green. They likes to play and runs around, but sometimes the dog barks loud and scares the cat. They always comes back home tired but happy. \ No newline at end of file diff --git a/webview/src/components/ConversationMessage.svelte b/webview/src/components/ConversationMessage.svelte index 7f65641..3f2283b 100644 --- a/webview/src/components/ConversationMessage.svelte +++ b/webview/src/components/ConversationMessage.svelte @@ -1,11 +1,10 @@