@doderasoftware/restify-ai 0.1.0-beta.1 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,63 +1,63 @@
1
- (function(B,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],t):(B=typeof globalThis<"u"?globalThis:B||self,t(B.RestifyAi={},B.Vue,B.Pinia))})(this,function(B,t,Ie){"use strict";var va=Object.defineProperty;var ja=(B,t,Ie)=>t in B?va(B,t,{enumerable:!0,configurable:!0,writable:!0,value:Ie}):B[t]=Ie;var P=(B,t,Ie)=>ja(B,typeof t!="symbol"?t+"":t,Ie);let Ce=null;const wo=t.ref(null),Et={title:"AI Assistant",aiName:"AI Assistant",you:"You",newChat:"New chat",placeholder:"Ask me anything...",inputPlaceholder:"Ask me anything...",supportPlaceholder:"Describe your support request...",loadingText:"Thinking...",analyzingText:"Analyzing...",craftingText:"Crafting response...",quotaRemaining:"{count} questions remaining",noQuota:"No AI credit available",contactSupport:"Contact Support",close:"Close",minimize:"Minimize",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",copyToClipboard:"Copy to clipboard",copied:"Copied!",showMore:"Show more",showLess:"Show less",retry:"Retry",attachFiles:"Attach files",emptyStateTitle:"How can I help you today?",emptyStateDescription:"Ask me anything or choose a suggestion below",keyboardShortcutHint:"Press ⌘G to toggle",sendMessage:"Send message",attachFile:"Attach file",closeConfirmTitle:"Close conversation?",closeConfirmMessage:"This will clear your chat history. Are you sure you want to close?",confirmClose:"Close & Clear",cancel:"Cancel",toggleSupportMode:"Toggle support mode",exitSupportMode:"Exit support mode",historyLimitWarningTitle:"Approaching Chat Limit",historyLimitWarningMessage:"You are approaching the maximum number of messages in this conversation.",historyLimitReachedTitle:"Chat Limit Reached",historyLimitReachedMessage:"You have reached the maximum number of messages. Start a new chat to continue.",startNewChat:"Start New Chat",continueChat:"Continue",setupWelcomeTitle:"Welcome to AI Assistant",setupWelcomeDescription:"Let's get you set up to start using AI features.",setupApiKeyTitle:"API Key Configuration",setupApiKeyDescription:"Enter your API key to test the connection",setupTestingTitle:"Testing Connection...",setupBackendTitle:"Backend Configuration",setupBackendDescription:"Configure your backend endpoint",setupCompleteTitle:"Setup Complete!"};function en(r){Ce=r,wo.value=r}function q(){return Ce}function bo(){if(!Ce)throw new Error("[@doderasoftware/restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Ce}function Ct(){return Ce!==null}function J(r,e){const n=Ce,o=(n==null?void 0:n.labels)||{},s=n==null?void 0:n.translate;if(s){const i=s(r,e);if(i!==r)return i}let a=o[r]||Et[r];return e&&Object.entries(e).forEach(([i,l])=>{a=a.replace(`{${i}}`,String(l))}),a}function tn(r){return{chatHistoryLimit:15,maxAttachments:5,maxFileSize:10485760,acceptedFileTypes:"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",chatHistoryKey:"restify_ai_chat_history",drawerStateKey:"restify_ai_drawer_open",keyboardShortcut:"cmd+g",enableSupportMode:!1}[r]}function Se(r){const e=Ce;return e?e[r]??tn(r):tn(r)}const Te={Assistant:"assistant",User:"user",System:"system"};async function Eo(r,e){const n=r.getReader();let o;for(;!(o=await n.read()).done;)e(o.value)}function Co(r){let e,n,o,s=!1;return function(i){e===void 0?(e=i,n=0,o=-1):e=To(e,i);const l=e.length;let d=0;for(;n<l;){s&&(e[n]===10&&(d=++n),s=!1);let u=-1;for(;n<l&&u===-1;++n)switch(e[n]){case 58:o===-1&&(o=n-d);break;case 13:s=!0;case 10:u=n;break}if(u===-1)break;r(e.subarray(d,u),o),d=n,o=-1}d===l?e=void 0:d!==0&&(e=e.subarray(d),n-=d)}}function So(r,e,n){let o=nn();const s=new TextDecoder;return function(i,l){if(i.length===0)n==null||n(o),o=nn();else if(l>0){const d=s.decode(i.subarray(0,l)),u=l+(i[l+1]===32?2:1),p=s.decode(i.subarray(u));switch(d){case"data":o.data=o.data?o.data+`
2
- `+p:p;break;case"event":o.event=p;break;case"id":r(o.id=p);break;case"retry":const g=parseInt(p,10);isNaN(g)||e(o.retry=g);break}}}}function To(r,e){const n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}function nn(){return{data:"",event:"",id:"",retry:void 0}}var Ao=function(r,e){var n={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&e.indexOf(o)<0&&(n[o]=r[o]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(r);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(r,o[s])&&(n[o[s]]=r[o[s]]);return n};const St="text/event-stream",Mo=1e3,on="last-event-id";function No(r,e){var{signal:n,headers:o,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:d,fetch:u}=e,p=Ao(e,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((g,x)=>{const y=Object.assign({},o);y.accept||(y.accept=St);let f;function E(){f.abort(),document.hidden||$()}d||document.addEventListener("visibilitychange",E);let h=Mo,m=0;function b(){document.removeEventListener("visibilitychange",E),window.clearTimeout(m),f.abort()}n==null||n.addEventListener("abort",()=>{b(),g()});const C=u??window.fetch,w=s??Ro;async function $(){var z;f=new AbortController;try{const F=await C(r,Object.assign(Object.assign({},p),{headers:y,signal:f.signal}));await w(F),await Eo(F.body,Co(So(S=>{S?y[on]=S:delete y[on]},S=>{h=S},a))),i==null||i(),b(),g()}catch(F){if(!f.signal.aborted)try{const S=(z=l==null?void 0:l(F))!==null&&z!==void 0?z:h;window.clearTimeout(m),m=window.setTimeout($,S)}catch(S){b(),x(S)}}}$()})}function Ro(r){const e=r.headers.get("content-type");if(!(e!=null&&e.startsWith(St)))throw new Error(`Expected content-type to be ${St}, Actual: ${e}`)}let He=new AbortController;function nt(r){const e=q(),n=(e==null?void 0:e.baseUrl)||"";if(!n||r.startsWith("http://")||r.startsWith("https://"))return r;const o=n.endsWith("/")?n.slice(0,-1):n,s=r.startsWith("/")?r:`/${r}`;return`${o}${s}`}function Bo(r){var e,n,o;try{if(r==="[DONE]")return"[DONE]";const s=JSON.parse(r);return((o=(n=(e=s==null?void 0:s.choices)==null?void 0:e[0])==null?void 0:n.delta)==null?void 0:o.content)||""}catch{return null}}function Lo(r){return new Promise(e=>setTimeout(e,r))}function Ee(r){const e=q();return r==="chatHistory"?(e==null?void 0:e.chatHistoryKey)||"restify_ai_chat_history":r==="setupComplete"?"restify_ai_setup_complete":(e==null?void 0:e.drawerStateKey)||"restify_ai_drawer_open"}function ot(r){try{sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(r))}catch(e){console.warn("[RestifyAi] Failed to save chat history:",e)}}function Do(r){try{r.message||r.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(r)):sessionStorage.removeItem("restify_ai_error_state")}catch(e){console.warn("[RestifyAi] Failed to save error state:",e)}}function Io(){try{const r=sessionStorage.getItem("restify_ai_error_state");if(r)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load error state:",r)}return null}function $o(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(r){console.warn("[RestifyAi] Failed to clear error state:",r)}}function zo(){try{const r=sessionStorage.getItem(Ee("chatHistory"));if(r){const e=JSON.parse(r),n=e.filter(a=>{var i;return!(a.role===Te.Assistant&&a.loading||a.role===Te.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==e.length&&sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(n));const o=n[n.length-1],s=(o==null?void 0:o.role)===Te.User;return{history:n,hasOrphanedUserMessage:s,orphanedMessage:s?{question:o.message,attachments:o.attachments||[]}:void 0}}}catch(r){console.warn("[RestifyAi] Failed to load chat history:",r)}return{history:[],hasOrphanedUserMessage:!1}}function _o(){try{sessionStorage.removeItem(Ee("chatHistory"))}catch(r){console.warn("[RestifyAi] Failed to clear chat history:",r)}}function Tt(r){try{localStorage.setItem(Ee("drawerState"),JSON.stringify(r))}catch(e){console.warn("[RestifyAi] Failed to save drawer state:",e)}}function Oo(){try{const r=localStorage.getItem(Ee("drawerState"));if(r!==null)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load drawer state:",r)}return!1}function Po(){try{return localStorage.getItem(Ee("setupComplete"))==="true"}catch{return!1}}function rn(){try{localStorage.setItem(Ee("setupComplete"),"true")}catch(r){console.warn("[RestifyAi] Failed to mark setup complete:",r)}}function Vo(r){const e={};return r.forEach(n=>{var o;(o=n.attachments)==null||o.forEach(s=>{s!=null&&s.id&&(e[s.id]=s)})}),e}function sn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}const Ae=Ie.defineStore("restifyAiStore",{state:()=>{const r=zo(),e=Io();let n={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1};return e!=null&&e.message?n={message:e.message,failedQuestion:e.failedQuestion,failedAttachments:e.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:r.hasOrphanedUserMessage&&r.orphanedMessage&&(n={message:"Previous request failed. Click retry to try again.",failedQuestion:r.orphanedMessage.question,failedAttachments:r.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}),{chatHistoryLimit:Se("chatHistoryLimit")||15,chatHistory:r.history,uploadedFiles:Vo(r.history),loading:!1,showChat:Oo(),isFullscreen:!1,sending:!1,pageContext:null,quota:{limit:100,used:0,remaining:100},error:n,supportRequestMode:!1,setupState:!Ct()&&!Po()?{...sn(),isActive:!0}:sn()}},getters:{hasMessages:r=>r.chatHistory.length>0,isInSetupMode:r=>r.setupState.isActive,canChat:r=>!r.setupState.isActive||r.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(){await t.nextTick();const r=document.getElementById("rai-chat-bottom");r&&r.scrollIntoView({behavior:"smooth"})},parseStreamContent(r){const e=q(),n=e==null?void 0:e.parseStreamContent;return n?n(r.data):Bo(r.data)},async askQuestion(r,e=[],n=[],o=!1){var y;const s=q();if(!s)return console.warn("[RestifyAi] Cannot ask question - plugin not configured"),!1;let a="",i=!1;const l=s.retry||{},d=l.maxRetries??0,u=l.retryDelay??1e3;let p=0;const g=e.map(f=>({id:f.id,name:f.name,url:f.url,type:f.type,size:f.size,extractedText:f.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Te.User,message:r,loading:!1,attachments:g,mentions:n,timestamp:Date.now()}),g.forEach(f=>this.registerUploadedFile(f)),ot(this.chatHistory),this.sending=!0,this.chatHistory.length>=this.chatHistoryLimit&&((y=s.onError)==null||y.call(s,new Error("Chat history limit reached")));const x=async()=>{var f,E,h;try{const m=this.chatHistory.map(M=>({role:M.role,message:M.message,attachments:M.attachments??[]})),b={},C=M=>{M!=null&&M.id&&(b[M.id]={extracted_text:M.extractedText||"",file_name:M.name,mime_type:M.type||"",...M.size?{file_size:M.size}:{},...M.url?{file_url:M.url}:{}})};Object.values(this.uploadedFiles).forEach(C),this.chatHistory.forEach(M=>{var Q;(Q=M.attachments)==null||Q.forEach(C)}),g.forEach(C);const w=Object.values(b),$=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Te.Assistant,message:"",loading:!0,timestamp:Date.now()}),ot(this.chatHistory),He=new AbortController;const z=await s.getAuthToken();let S={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?S["X-Test-Api-Key"]=this.setupState.testApiKey:z&&(S.Authorization=`Bearer ${z}`);let T={question:r,history:m,stream:!0,...w.length>0&&{files:w},...n.length>0&&{mentions:n},...this.supportRequestMode&&{contact_support:!0}};s.beforeSend&&(T=await s.beforeSend(T)),s.buildRequest&&(T=await s.buildRequest(T)),(f=s.onMessageSent)==null||f.call(s,this.chatHistory[$-1]);const N=nt(s.endpoints.ask);let D={method:"POST",body:JSON.stringify(T),headers:S};return s.requestInterceptor&&(D=await s.requestInterceptor(N,D)),(E=s.onStreamStart)==null||E.call(s),await No(N,{method:"POST",body:JSON.stringify(T),signal:He.signal,headers:D.headers,openWhenHidden:!0,async onopen(M){if(!M.ok){if(M.status===429){const Q=Ae();throw Q.error={message:J("noQuota"),failedQuestion:r,failedAttachments:g,timestamp:Date.now(),quotaExceeded:!0},await Q.fetchQuota(),new Error("Quota exceeded")}throw new Error(`Failed to connect: ${M.status}`)}},onmessage:async M=>{var Re,ye,Be;const Q=this.parseStreamContent(M);if(!Q)return;this.chatHistory[$].loading=!1;const fe={content:Q,done:Q==="[DONE]",raw:M.data};(Re=s.onStreamChunk)==null||Re.call(s,fe),a?Q==="[DONE]"?(this.chatHistory[$].streaming=!1,ot(this.chatHistory),(ye=s.onStreamEnd)==null||ye.call(s,a),this.quota.remaining>0&&!this.supportRequestMode&&(this.quota.remaining--,this.quota.used++,this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0)),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[$]),(Be=s.onResponseReceived)==null||Be.call(s,this.chatHistory[$])):(a+=Q,this.chatHistory[$].message=a):(a=Q,this.chatHistory[$].message=a,this.chatHistory[$].streaming=!0),await this.scrollToBottom()},onerror(M){throw i=!0,M}}),!0}catch(m){i=!0;const b=this.chatHistory.length-1;return this.chatHistory.splice(b,1),m.name==="AbortError"?!0:p<d&&(l.shouldRetry?l.shouldRetry(m,p):!0)?(p++,await Lo(u*p),x()):(this.error={message:m.message||"Network error occurred. Please try again.",failedQuestion:r,failedAttachments:g,timestamp:Date.now()},Do({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(h=s.onError)==null||h.call(s,m),!1)}finally{this.sending=!1}};return x()},cancelRequest(){He==null||He.abort(),this.chatHistory=this.chatHistory.map(r=>({...r,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var e;const r=q();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1),_o(),(e=r==null?void 0:r.onNewChat)==null||e.call(r)},async retry(){if(!this.error.failedQuestion)return!1;const r=this.error.failedQuestion,e=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Te.User&&n.message===r&&(this.chatHistory.pop(),ot(this.chatHistory)),this.clearError(),await this.askQuestion(r,e)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},$o()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var e,n;const r=q();if((e=r==null?void 0:r.endpoints)!=null&&e.quota)try{const o=await r.getAuthToken(),s=r.getCustomHeaders?await r.getCustomHeaders():{},a=nt(r.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...o?{Authorization:`Bearer ${o}`}:{},...s}});if(i.ok){const l=await i.json(),d=l.data??l;this.quota={limit:d.limit??this.quota.limit,used:d.used??this.quota.used,remaining:d.remaining??this.quota.remaining},this.quota.remaining===0&&r.enableSupportMode!==!1&&(this.supportRequestMode=!0),(n=r.onQuotaFetched)==null||n.call(r,this.quota)}}catch(o){console.error("[RestifyAi] Failed to fetch quota:",o)}},async uploadFile(r){var s,a,i,l,d;const e=q();if(!((s=e==null?void 0:e.endpoints)!=null&&s.uploadFile))return console.warn("[RestifyAi] No uploadFile endpoint configured"),null;const o={id:crypto.randomUUID(),name:r.name,type:r.type,size:r.size,uploading:!0,progress:0};(a=e.onFileUploadStart)==null||a.call(e,o);try{const u=await e.getAuthToken(),p=e.getCustomHeaders?await e.getCustomHeaders():{},g=nt(e.endpoints.uploadFile),x=new FormData;x.append("file",r);const y=await new Promise((f,E)=>{const h=new XMLHttpRequest;h.upload.addEventListener("progress",m=>{var b;if(m.lengthComputable){const C=Math.round(m.loaded/m.total*100);o.progress=C,(b=e.onFileUploadProgress)==null||b.call(e,o,C)}}),h.addEventListener("load",()=>{var m,b;if(h.status>=200&&h.status<300)try{const C=JSON.parse(h.responseText),w={...o,url:C.url||((m=C.data)==null?void 0:m.url),extractedText:C.extracted_text||((b=C.data)==null?void 0:b.extracted_text),uploading:!1,progress:100};f(w)}catch{E(new Error("Failed to parse upload response"))}else E(new Error(`Upload failed: ${h.status}`))}),h.addEventListener("error",()=>{E(new Error("Upload failed"))}),h.open("POST",g),u&&h.setRequestHeader("Authorization",`Bearer ${u}`),Object.entries(p).forEach(([m,b])=>{h.setRequestHeader(m,b)}),h.send(x)});return(i=e.onFileUploadComplete)==null||i.call(e,y),y}catch(u){const p={...o,uploading:!1};return(l=e.onFileUploadError)==null||l.call(e,p,u),(d=e.onError)==null||d.call(e,u),null}},setPageContext(r){this.pageContext=r},toggleDrawer(){var r,e;this.showChat=!this.showChat,Tt(this.showChat),(e=(r=q())==null?void 0:r.onDrawerToggle)==null||e.call(r,this.showChat)},openDrawer(){var r,e;this.showChat=!0,Tt(!0),(e=(r=q())==null?void 0:r.onDrawerToggle)==null||e.call(r,!0)},closeDrawer(){var r,e;this.showChat=!1,Tt(!1),(e=(r=q())==null?void 0:r.onDrawerToggle)==null||e.call(r,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(r){r!=null&&r.id&&(this.uploadedFiles[r.id]={...r})},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(r){this.setupState.currentStep=r},setTestApiKey(r){this.setupState.testApiKey=r},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const r=q();if(!r)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const e={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(e["X-Test-Api-Key"]=this.setupState.testApiKey);const n=r.endpoints.quota||r.endpoints.ask,o=nt(n),s=await fetch(o,{method:r.endpoints.quota?"GET":"POST",headers:e,...r.endpoints.quota?{}:{body:JSON.stringify({question:"test",stream:!1})}});return s.ok?(this.setupState.connectionStatus="connected",this.setupState.backendConfigured=!0,!0):(this.setupState.connectionStatus="failed",this.setupState.lastError=`Connection failed: ${s.status} ${s.statusText}`,!1)}catch(e){return this.setupState.connectionStatus="failed",this.setupState.lastError=e.message||"Connection failed",!1}},completeSetup(){var r,e;this.setupState.isActive=!1,this.setupState.currentStep="complete",rn(),(e=(r=q())==null?void 0:r.onSetupComplete)==null||e.call(r)},skipSetup(){this.setupState.isActive=!1,rn()}}});function an(r){const e=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let o=r,s;for(;(s=e.exec(r))!==null;){const[a,i,l]=s,[d,u]=l.includes(":")?l.split(":"):["default",l];n.push({id:u,name:i,type:d}),o=o.replace(a,i)}return{cleanText:o,mentions:n}}function Fo(r){const{cleanText:e}=an(r);return e}function ln(r){return r.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function cn(r,e){const o=r.substring(0,e).match(/@(\w*)$/);return o?{inMention:!0,query:o[1],startPos:e-o[0].length}:{inMention:!1,query:"",startPos:-1}}function At(r,e){var n,o;return e!=null&&e.getDisplayName?e.getDisplayName(r):r.name||r.title||((n=r.attributes)==null?void 0:n.name)||((o=r.attributes)==null?void 0:o.title)||"Unknown"}function un(r,e){var n,o;return e!=null&&e.getSubtitle?e.getSubtitle(r):((n=r.attributes)==null?void 0:n.email)||((o=r.attributes)==null?void 0:o.description)||null}function Ho(r,e){return e!=null&&e.buildMentionText?e.buildMentionText(r):`@[${At(r,e)}](${r.type}:${r.id})`}function dn(r){var n;const e=q();return(n=e==null?void 0:e.mentionProviders)==null?void 0:n.find(o=>o.type===r)}function pn(r){const e=q(),n=(e==null?void 0:e.mentionProviders)||[];return r?n.filter(o=>o.routes?o.routes.some(s=>s.endsWith("*")?r.startsWith(s.slice(0,-1)):r===s||r.startsWith(s+"/")):!0):n}function fn(r){return r.map(e=>({type:e.type,id:e.id,name:e.name}))}function mn(r){return r.reduce((e,n)=>{const o=n.type||"default";return e[o]||(e[o]=[]),e[o].push(n),e},{})}function Uo(){return{extractMentions:an,parseAndCleanMessage:Fo,renderMentionsInHtml:ln,detectMentionContext:cn,getMentionDisplayName:At,getMentionSubtitle:un,buildMentionText:Ho,getMentionProvider:dn,getActiveMentionProviders:pn,formatMentionsForApi:fn,groupMentionsByType:mn}}function Mt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Me=Mt();function hn(r){Me=r}const gn=/[&<>"']/,qo=new RegExp(gn.source,"g"),yn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vo=new RegExp(yn.source,"g"),jo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},kn=r=>jo[r];function ie(r,e){if(e){if(gn.test(r))return r.replace(qo,kn)}else if(yn.test(r))return r.replace(vo,kn);return r}const Wo=/(^|[^\[])\^/g;function O(r,e){let n=typeof r=="string"?r:r.source;e=e||"";const o={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Wo,"$1"),n=n.replace(s,i),o},getRegex:()=>new RegExp(n,e)};return o}function xn(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const Ue={exec:()=>null};function wn(r,e){const n=r.replace(/\|/g,(a,i,l)=>{let d=!1,u=i;for(;--u>=0&&l[u]==="\\";)d=!d;return d?"|":" |"}),o=n.split(/ \|/);let s=0;if(o[0].trim()||o.shift(),o.length>0&&!o[o.length-1].trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;s<o.length;s++)o[s]=o[s].trim().replace(/\\\|/g,"|");return o}function qe(r,e,n){const o=r.length;if(o===0)return"";let s=0;for(;s<o&&r.charAt(o-s-1)===e;)s++;return r.slice(0,o-s)}function Go(r,e){if(r.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<r.length;o++)if(r[o]==="\\")o++;else if(r[o]===e[0])n++;else if(r[o]===e[1]&&(n--,n<0))return o;return-1}function bn(r,e,n,o){const s=e.href,a=e.title?ie(e.title):null,i=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){o.state.inLink=!0;const l={type:"link",raw:n,href:s,title:a,text:i,tokens:o.inlineTokens(i)};return o.state.inLink=!1,l}return{type:"image",raw:n,href:s,title:a,text:ie(i)}}function Ko(r,e){const n=r.match(/^(\s+)(?:```)/);if(n===null)return e;const o=n[1];return e.split(`
3
- `).map(s=>{const a=s.match(/^\s+/);if(a===null)return s;const[i]=a;return i.length>=o.length?s.slice(o.length):s}).join(`
4
- `)}class rt{constructor(e){P(this,"options");P(this,"rules");P(this,"lexer");this.options=e||Me}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const o=n[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?o:qe(o,`
5
- `)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const o=n[0],s=Ko(o,n[3]||"");return{type:"code",raw:o,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:s}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let o=n[2].trim();if(/#$/.test(o)){const s=qe(o,"#");(this.options.pedantic||!s||/ $/.test(s))&&(o=s.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:o,tokens:this.lexer.inline(o)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:qe(n[0],`
6
- `)}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){let o=qe(n[0],`
1
+ (function(B,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],t):(B=typeof globalThis<"u"?globalThis:B||self,t(B.RestifyAi={},B.Vue,B.Pinia))})(this,function(B,t,Ie){"use strict";var va=Object.defineProperty;var ja=(B,t,Ie)=>t in B?va(B,t,{enumerable:!0,configurable:!0,writable:!0,value:Ie}):B[t]=Ie;var P=(B,t,Ie)=>ja(B,typeof t!="symbol"?t+"":t,Ie);let Se=null;const wo=t.ref(null),Et={title:"AI Assistant",aiName:"AI Assistant",you:"You",newChat:"New chat",placeholder:"Ask me anything...",inputPlaceholder:"Ask me anything...",supportPlaceholder:"Describe your support request...",loadingText:"Thinking...",analyzingText:"Analyzing...",craftingText:"Crafting response...",quotaRemaining:"{count} questions remaining",noQuota:"No AI credit available",contactSupport:"Contact Support",close:"Close",minimize:"Minimize",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",copyToClipboard:"Copy to clipboard",copied:"Copied!",showMore:"Show more",showLess:"Show less",retry:"Retry",attachFiles:"Attach files",emptyStateTitle:"How can I help you today?",emptyStateDescription:"Ask me anything or choose a suggestion below",keyboardShortcutHint:"Press ⌘G to toggle",sendMessage:"Send message",attachFile:"Attach file",closeConfirmTitle:"Close conversation?",closeConfirmMessage:"This will clear your chat history. Are you sure you want to close?",confirmClose:"Close & Clear",cancel:"Cancel",toggleSupportMode:"Toggle support mode",exitSupportMode:"Exit support mode",historyLimitWarningTitle:"Approaching Chat Limit",historyLimitWarningMessage:"You are approaching the maximum number of messages in this conversation.",historyLimitReachedTitle:"Chat Limit Reached",historyLimitReachedMessage:"You have reached the maximum number of messages. Start a new chat to continue.",startNewChat:"Start New Chat",continueChat:"Continue",setupWelcomeTitle:"Welcome to AI Assistant",setupWelcomeDescription:"Let's get you set up to start using AI features.",setupApiKeyTitle:"API Key Configuration",setupApiKeyDescription:"Enter your API key to test the connection",setupTestingTitle:"Testing Connection...",setupBackendTitle:"Backend Configuration",setupBackendDescription:"Configure your backend endpoint",setupCompleteTitle:"Setup Complete!"};function en(o){Se=o,wo.value=o}function q(){return Se}function bo(){if(!Se)throw new Error("[@doderasoftware/restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Se}function Ct(){return Se!==null}function J(o,e){const n=Se,r=(n==null?void 0:n.labels)||{},s=n==null?void 0:n.translate;if(s){const i=s(o,e);if(i!==o)return i}let a=r[o]||Et[o];return e&&Object.entries(e).forEach(([i,l])=>{a=a.replace(`{${i}}`,String(l))}),a}function tn(o){return{chatHistoryLimit:15,maxAttachments:5,maxFileSize:10485760,acceptedFileTypes:"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",chatHistoryKey:"restify_ai_chat_history",drawerStateKey:"restify_ai_drawer_open",keyboardShortcut:"cmd+g",enableSupportMode:!1}[o]}function Te(o){const e=Se;return e?e[o]??tn(o):tn(o)}const Ae={Assistant:"assistant",User:"user",System:"system"};async function Eo(o,e){const n=o.getReader();let r;for(;!(r=await n.read()).done;)e(r.value)}function Co(o){let e,n,r,s=!1;return function(i){e===void 0?(e=i,n=0,r=-1):e=To(e,i);const l=e.length;let d=0;for(;n<l;){s&&(e[n]===10&&(d=++n),s=!1);let u=-1;for(;n<l&&u===-1;++n)switch(e[n]){case 58:r===-1&&(r=n-d);break;case 13:s=!0;case 10:u=n;break}if(u===-1)break;o(e.subarray(d,u),r),d=n,r=-1}d===l?e=void 0:d!==0&&(e=e.subarray(d),n-=d)}}function So(o,e,n){let r=nn();const s=new TextDecoder;return function(i,l){if(i.length===0)n==null||n(r),r=nn();else if(l>0){const d=s.decode(i.subarray(0,l)),u=l+(i[l+1]===32?2:1),p=s.decode(i.subarray(u));switch(d){case"data":r.data=r.data?r.data+`
2
+ `+p:p;break;case"event":r.event=p;break;case"id":o(r.id=p);break;case"retry":const h=parseInt(p,10);isNaN(h)||e(r.retry=h);break}}}}function To(o,e){const n=new Uint8Array(o.length+e.length);return n.set(o),n.set(e,o.length),n}function nn(){return{data:"",event:"",id:"",retry:void 0}}var Ao=function(o,e){var n={};for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&e.indexOf(r)<0&&(n[r]=o[r]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(o);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(o,r[s])&&(n[r[s]]=o[r[s]]);return n};const St="text/event-stream",Mo=1e3,on="last-event-id";function No(o,e){var{signal:n,headers:r,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:d,fetch:u}=e,p=Ao(e,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((h,x)=>{const y=Object.assign({},r);y.accept||(y.accept=St);let f;function E(){f.abort(),document.hidden||z()}d||document.addEventListener("visibilitychange",E);let g=Mo,m=0;function b(){document.removeEventListener("visibilitychange",E),window.clearTimeout(m),f.abort()}n==null||n.addEventListener("abort",()=>{b(),h()});const C=u??window.fetch,w=s??Ro;async function z(){var $;f=new AbortController;try{const F=await C(o,Object.assign(Object.assign({},p),{headers:y,signal:f.signal}));await w(F),await Eo(F.body,Co(So(S=>{S?y[on]=S:delete y[on]},S=>{g=S},a))),i==null||i(),b(),h()}catch(F){if(!f.signal.aborted)try{const S=($=l==null?void 0:l(F))!==null&&$!==void 0?$:g;window.clearTimeout(m),m=window.setTimeout(z,S)}catch(S){b(),x(S)}}}z()})}function Ro(o){const e=o.headers.get("content-type");if(!(e!=null&&e.startsWith(St)))throw new Error(`Expected content-type to be ${St}, Actual: ${e}`)}let He=new AbortController;function nt(o){const e=q(),n=(e==null?void 0:e.baseUrl)||"";if(!n||o.startsWith("http://")||o.startsWith("https://"))return o;const r=n.endsWith("/")?n.slice(0,-1):n,s=o.startsWith("/")?o:`/${o}`;return`${r}${s}`}function Bo(o){var e,n,r;try{if(o==="[DONE]")return"[DONE]";const s=JSON.parse(o);return((r=(n=(e=s==null?void 0:s.choices)==null?void 0:e[0])==null?void 0:n.delta)==null?void 0:r.content)||""}catch{return null}}function Lo(o){return new Promise(e=>setTimeout(e,o))}function Ee(o){const e=q();return o==="chatHistory"?(e==null?void 0:e.chatHistoryKey)||"restify_ai_chat_history":o==="setupComplete"?"restify_ai_setup_complete":(e==null?void 0:e.drawerStateKey)||"restify_ai_drawer_open"}function ot(o){try{sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(o))}catch(e){console.warn("[RestifyAi] Failed to save chat history:",e)}}function Do(o){try{o.message||o.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(o)):sessionStorage.removeItem("restify_ai_error_state")}catch(e){console.warn("[RestifyAi] Failed to save error state:",e)}}function Io(){try{const o=sessionStorage.getItem("restify_ai_error_state");if(o)return JSON.parse(o)}catch(o){console.warn("[RestifyAi] Failed to load error state:",o)}return null}function zo(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(o){console.warn("[RestifyAi] Failed to clear error state:",o)}}function $o(){try{const o=sessionStorage.getItem(Ee("chatHistory"));if(o){const e=JSON.parse(o),n=e.filter(a=>{var i;return!(a.role===Ae.Assistant&&a.loading||a.role===Ae.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==e.length&&sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(n));const r=n[n.length-1],s=(r==null?void 0:r.role)===Ae.User;return{history:n,hasOrphanedUserMessage:s,orphanedMessage:s?{question:r.message,attachments:r.attachments||[]}:void 0}}}catch(o){console.warn("[RestifyAi] Failed to load chat history:",o)}return{history:[],hasOrphanedUserMessage:!1}}function _o(){try{sessionStorage.removeItem(Ee("chatHistory"))}catch(o){console.warn("[RestifyAi] Failed to clear chat history:",o)}}function Tt(o){try{localStorage.setItem(Ee("drawerState"),JSON.stringify(o))}catch(e){console.warn("[RestifyAi] Failed to save drawer state:",e)}}function Oo(){try{const o=localStorage.getItem(Ee("drawerState"));if(o!==null)return JSON.parse(o)}catch(o){console.warn("[RestifyAi] Failed to load drawer state:",o)}return!1}function Po(){try{return localStorage.getItem(Ee("setupComplete"))==="true"}catch{return!1}}function rn(){try{localStorage.setItem(Ee("setupComplete"),"true")}catch(o){console.warn("[RestifyAi] Failed to mark setup complete:",o)}}function Vo(o){const e={};return o.forEach(n=>{var r;(r=n.attachments)==null||r.forEach(s=>{s!=null&&s.id&&(e[s.id]=s)})}),e}function sn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}const Ce=Ie.defineStore("restifyAiStore",{state:()=>{const o=$o(),e=Io();let n={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1};return e!=null&&e.message?n={message:e.message,failedQuestion:e.failedQuestion,failedAttachments:e.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:o.hasOrphanedUserMessage&&o.orphanedMessage&&(n={message:"Previous request failed. Click retry to try again.",failedQuestion:o.orphanedMessage.question,failedAttachments:o.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}),{chatHistoryLimit:Te("chatHistoryLimit")||15,chatHistory:o.history,uploadedFiles:Vo(o.history),loading:!1,showChat:Oo(),isFullscreen:!1,sending:!1,pageContext:null,quota:{limit:100,used:0,remaining:100},error:n,supportRequestMode:!1,setupState:!Ct()&&!Po()?{...sn(),isActive:!0}:sn()}},getters:{hasMessages:o=>o.chatHistory.length>0,isInSetupMode:o=>o.setupState.isActive,canChat:o=>!o.setupState.isActive||o.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(){await t.nextTick();const o=document.getElementById("rai-chat-bottom");o&&o.scrollIntoView({behavior:"smooth"})},parseStreamContent(o){const e=q(),n=e==null?void 0:e.parseStreamContent;return n?n(o.data):Bo(o.data)},async askQuestion(o,e=[],n=[],r=!1){var y;const s=q();if(!s)return console.warn("[RestifyAi] Cannot ask question - plugin not configured"),!1;let a="",i=!1;const l=s.retry||{},d=l.maxRetries??0,u=l.retryDelay??1e3;let p=0;const h=e.map(f=>({id:f.id,name:f.name,url:f.url,type:f.type,size:f.size,extractedText:f.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Ae.User,message:o,loading:!1,attachments:h,mentions:n,timestamp:Date.now()}),h.forEach(f=>this.registerUploadedFile(f)),ot(this.chatHistory),this.sending=!0,this.chatHistory.length>=this.chatHistoryLimit&&((y=s.onError)==null||y.call(s,new Error("Chat history limit reached")));const x=async()=>{var f,E,g;try{const m=this.chatHistory.map(M=>({role:M.role,message:M.message,attachments:M.attachments??[]})),b={},C=M=>{M!=null&&M.id&&(b[M.id]={extracted_text:M.extractedText||"",file_name:M.name,mime_type:M.type||"",...M.size?{file_size:M.size}:{},...M.url?{file_url:M.url}:{}})};Object.values(this.uploadedFiles).forEach(C),this.chatHistory.forEach(M=>{var Q;(Q=M.attachments)==null||Q.forEach(C)}),h.forEach(C);const w=Object.values(b),z=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Ae.Assistant,message:"",loading:!0,timestamp:Date.now()}),ot(this.chatHistory),He=new AbortController;const $=await s.getAuthToken();let S={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?S["X-Test-Api-Key"]=this.setupState.testApiKey:$&&(S.Authorization=`Bearer ${$}`);let T={question:o,history:m,stream:!0,...w.length>0&&{files:w},...n.length>0&&{mentions:n},...this.supportRequestMode&&{contact_support:!0}};s.beforeSend&&(T=await s.beforeSend(T)),s.buildRequest&&(T=await s.buildRequest(T)),(f=s.onMessageSent)==null||f.call(s,this.chatHistory[z-1]);const N=nt(s.endpoints.ask);let D={method:"POST",body:JSON.stringify(T),headers:S};return s.requestInterceptor&&(D=await s.requestInterceptor(N,D)),(E=s.onStreamStart)==null||E.call(s),await No(N,{method:"POST",body:JSON.stringify(T),signal:He.signal,headers:D.headers,openWhenHidden:!0,async onopen(M){if(!M.ok){if(M.status===429){const Q=Ce();throw Q.error={message:J("noQuota"),failedQuestion:o,failedAttachments:h,timestamp:Date.now(),quotaExceeded:!0},await Q.fetchQuota(),new Error("Quota exceeded")}throw new Error(`Failed to connect: ${M.status}`)}},onmessage:async M=>{var Re,ye,Be;const Q=this.parseStreamContent(M);if(!Q)return;this.chatHistory[z].loading=!1;const fe={content:Q,done:Q==="[DONE]",raw:M.data};(Re=s.onStreamChunk)==null||Re.call(s,fe),a?Q==="[DONE]"?(this.chatHistory[z].streaming=!1,ot(this.chatHistory),(ye=s.onStreamEnd)==null||ye.call(s,a),this.quota.remaining>0&&!this.supportRequestMode&&(this.quota.remaining--,this.quota.used++,this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0)),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[z]),(Be=s.onResponseReceived)==null||Be.call(s,this.chatHistory[z])):(a+=Q,this.chatHistory[z].message=a):(a=Q,this.chatHistory[z].message=a,this.chatHistory[z].streaming=!0),await this.scrollToBottom()},onerror(M){throw i=!0,M}}),!0}catch(m){i=!0;const b=this.chatHistory.length-1;return this.chatHistory.splice(b,1),m.name==="AbortError"?!0:p<d&&(l.shouldRetry?l.shouldRetry(m,p):!0)?(p++,await Lo(u*p),x()):(this.error={message:m.message||"Network error occurred. Please try again.",failedQuestion:o,failedAttachments:h,timestamp:Date.now()},Do({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(g=s.onError)==null||g.call(s,m),!1)}finally{this.sending=!1}};return x()},cancelRequest(){He==null||He.abort(),this.chatHistory=this.chatHistory.map(o=>({...o,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var e;const o=q();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1),_o(),(e=o==null?void 0:o.onNewChat)==null||e.call(o)},async retry(){if(!this.error.failedQuestion)return!1;const o=this.error.failedQuestion,e=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Ae.User&&n.message===o&&(this.chatHistory.pop(),ot(this.chatHistory)),this.clearError(),await this.askQuestion(o,e)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},zo()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var e,n;const o=q();if((e=o==null?void 0:o.endpoints)!=null&&e.quota)try{const r=await o.getAuthToken(),s=o.getCustomHeaders?await o.getCustomHeaders():{},a=nt(o.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...r?{Authorization:`Bearer ${r}`}:{},...s}});if(i.ok){const l=await i.json(),d=l.data??l;this.quota={limit:d.limit??this.quota.limit,used:d.used??this.quota.used,remaining:d.remaining??this.quota.remaining},this.quota.remaining===0&&o.enableSupportMode!==!1&&(this.supportRequestMode=!0),(n=o.onQuotaFetched)==null||n.call(o,this.quota)}}catch(r){console.error("[RestifyAi] Failed to fetch quota:",r)}},async uploadFile(o){var s,a,i,l,d;const e=q();if(!((s=e==null?void 0:e.endpoints)!=null&&s.uploadFile))return console.warn("[RestifyAi] No uploadFile endpoint configured"),null;const r={id:crypto.randomUUID(),name:o.name,type:o.type,size:o.size,uploading:!0,progress:0};(a=e.onFileUploadStart)==null||a.call(e,r);try{const u=await e.getAuthToken(),p=e.getCustomHeaders?await e.getCustomHeaders():{},h=nt(e.endpoints.uploadFile),x=new FormData;x.append("file",o);const y=await new Promise((f,E)=>{const g=new XMLHttpRequest;g.upload.addEventListener("progress",m=>{var b;if(m.lengthComputable){const C=Math.round(m.loaded/m.total*100);r.progress=C,(b=e.onFileUploadProgress)==null||b.call(e,r,C)}}),g.addEventListener("load",()=>{var m,b;if(g.status>=200&&g.status<300)try{const C=JSON.parse(g.responseText),w={...r,url:C.url||((m=C.data)==null?void 0:m.url),extractedText:C.extracted_text||((b=C.data)==null?void 0:b.extracted_text),uploading:!1,progress:100};f(w)}catch{E(new Error("Failed to parse upload response"))}else E(new Error(`Upload failed: ${g.status}`))}),g.addEventListener("error",()=>{E(new Error("Upload failed"))}),g.open("POST",h),u&&g.setRequestHeader("Authorization",`Bearer ${u}`),Object.entries(p).forEach(([m,b])=>{g.setRequestHeader(m,b)}),g.send(x)});return(i=e.onFileUploadComplete)==null||i.call(e,y),y}catch(u){const p={...r,uploading:!1};return(l=e.onFileUploadError)==null||l.call(e,p,u),(d=e.onError)==null||d.call(e,u),null}},setPageContext(o){this.pageContext=o},toggleDrawer(){var o,e;this.showChat=!this.showChat,Tt(this.showChat),(e=(o=q())==null?void 0:o.onDrawerToggle)==null||e.call(o,this.showChat)},openDrawer(){var o,e;this.showChat=!0,Tt(!0),(e=(o=q())==null?void 0:o.onDrawerToggle)==null||e.call(o,!0)},closeDrawer(){var o,e;this.showChat=!1,Tt(!1),(e=(o=q())==null?void 0:o.onDrawerToggle)==null||e.call(o,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(o){o!=null&&o.id&&(this.uploadedFiles[o.id]={...o})},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(o){this.setupState.currentStep=o},setTestApiKey(o){this.setupState.testApiKey=o},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const o=q();if(!o)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const e={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(e["X-Test-Api-Key"]=this.setupState.testApiKey);const n=o.endpoints.quota||o.endpoints.ask,r=nt(n),s=await fetch(r,{method:o.endpoints.quota?"GET":"POST",headers:e,...o.endpoints.quota?{}:{body:JSON.stringify({question:"test",stream:!1})}});return s.ok?(this.setupState.connectionStatus="connected",this.setupState.backendConfigured=!0,!0):(this.setupState.connectionStatus="failed",this.setupState.lastError=`Connection failed: ${s.status} ${s.statusText}`,!1)}catch(e){return this.setupState.connectionStatus="failed",this.setupState.lastError=e.message||"Connection failed",!1}},completeSetup(){var o,e;this.setupState.isActive=!1,this.setupState.currentStep="complete",rn(),(e=(o=q())==null?void 0:o.onSetupComplete)==null||e.call(o)},skipSetup(){this.setupState.isActive=!1,rn()}}});function an(o){const e=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let r=o,s;for(;(s=e.exec(o))!==null;){const[a,i,l]=s,[d,u]=l.includes(":")?l.split(":"):["default",l];n.push({id:u,name:i,type:d}),r=r.replace(a,i)}return{cleanText:r,mentions:n}}function Fo(o){const{cleanText:e}=an(o);return e}function ln(o){return o.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function cn(o,e){const r=o.substring(0,e).match(/@(\w*)$/);return r?{inMention:!0,query:r[1],startPos:e-r[0].length}:{inMention:!1,query:"",startPos:-1}}function At(o,e){var n,r;return e!=null&&e.getDisplayName?e.getDisplayName(o):o.name||o.title||((n=o.attributes)==null?void 0:n.name)||((r=o.attributes)==null?void 0:r.title)||"Unknown"}function un(o,e){var n,r;return e!=null&&e.getSubtitle?e.getSubtitle(o):((n=o.attributes)==null?void 0:n.email)||((r=o.attributes)==null?void 0:r.description)||null}function Ho(o,e){return e!=null&&e.buildMentionText?e.buildMentionText(o):`@[${At(o,e)}](${o.type}:${o.id})`}function dn(o){var n;const e=q();return(n=e==null?void 0:e.mentionProviders)==null?void 0:n.find(r=>r.type===o)}function pn(o){const e=q(),n=(e==null?void 0:e.mentionProviders)||[];return o?n.filter(r=>r.routes?r.routes.some(s=>s.endsWith("*")?o.startsWith(s.slice(0,-1)):o===s||o.startsWith(s+"/")):!0):n}function fn(o){return o.map(e=>({type:e.type,id:e.id,name:e.name}))}function mn(o){return o.reduce((e,n)=>{const r=n.type||"default";return e[r]||(e[r]=[]),e[r].push(n),e},{})}function Uo(){return{extractMentions:an,parseAndCleanMessage:Fo,renderMentionsInHtml:ln,detectMentionContext:cn,getMentionDisplayName:At,getMentionSubtitle:un,buildMentionText:Ho,getMentionProvider:dn,getActiveMentionProviders:pn,formatMentionsForApi:fn,groupMentionsByType:mn}}function Mt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Me=Mt();function hn(o){Me=o}const gn=/[&<>"']/,qo=new RegExp(gn.source,"g"),yn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vo=new RegExp(yn.source,"g"),jo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},kn=o=>jo[o];function ie(o,e){if(e){if(gn.test(o))return o.replace(qo,kn)}else if(yn.test(o))return o.replace(vo,kn);return o}const Wo=/(^|[^\[])\^/g;function O(o,e){let n=typeof o=="string"?o:o.source;e=e||"";const r={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Wo,"$1"),n=n.replace(s,i),r},getRegex:()=>new RegExp(n,e)};return r}function xn(o){try{o=encodeURI(o).replace(/%25/g,"%")}catch{return null}return o}const Ue={exec:()=>null};function wn(o,e){const n=o.replace(/\|/g,(a,i,l)=>{let d=!1,u=i;for(;--u>=0&&l[u]==="\\";)d=!d;return d?"|":" |"}),r=n.split(/ \|/);let s=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(/\\\|/g,"|");return r}function qe(o,e,n){const r=o.length;if(r===0)return"";let s=0;for(;s<r&&o.charAt(r-s-1)===e;)s++;return o.slice(0,r-s)}function Ko(o,e){if(o.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<o.length;r++)if(o[r]==="\\")r++;else if(o[r]===e[0])n++;else if(o[r]===e[1]&&(n--,n<0))return r;return-1}function bn(o,e,n,r){const s=e.href,a=e.title?ie(e.title):null,i=o[1].replace(/\\([\[\]])/g,"$1");if(o[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:s,title:a,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:s,title:a,text:ie(i)}}function Go(o,e){const n=o.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(`
3
+ `).map(s=>{const a=s.match(/^\s+/);if(a===null)return s;const[i]=a;return i.length>=r.length?s.slice(r.length):s}).join(`
4
+ `)}class rt{constructor(e){P(this,"options");P(this,"rules");P(this,"lexer");this.options=e||Me}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:qe(r,`
5
+ `)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],s=Go(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:s}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const s=qe(r,"#");(this.options.pedantic||!s||/ $/.test(s))&&(r=s.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:qe(n[0],`
6
+ `)}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){let r=qe(n[0],`
7
7
  `).split(`
8
- `),s="",a="";const i=[];for(;o.length>0;){let l=!1;const d=[];let u;for(u=0;u<o.length;u++)if(/^ {0,3}>/.test(o[u]))d.push(o[u]),l=!0;else if(!l)d.push(o[u]);else break;o=o.slice(u);const p=d.join(`
9
- `),g=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
8
+ `),s="",a="";const i=[];for(;r.length>0;){let l=!1;const d=[];let u;for(u=0;u<r.length;u++)if(/^ {0,3}>/.test(r[u]))d.push(r[u]),l=!0;else if(!l)d.push(r[u]);else break;r=r.slice(u);const p=d.join(`
9
+ `),h=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
10
10
  $1`).replace(/^ {0,3}>[ \t]?/gm,"");s=s?`${s}
11
11
  ${p}`:p,a=a?`${a}
12
- ${g}`:g;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(g,i,!0),this.lexer.state.top=x,o.length===0)break;const y=i[i.length-1];if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){const f=y,E=f.raw+`
13
- `+o.join(`
14
- `),h=this.blockquote(E);i[i.length-1]=h,s=s.substring(0,s.length-f.raw.length)+h.raw,a=a.substring(0,a.length-f.text.length)+h.text;break}else if((y==null?void 0:y.type)==="list"){const f=y,E=f.raw+`
15
- `+o.join(`
16
- `),h=this.list(E);i[i.length-1]=h,s=s.substring(0,s.length-y.raw.length)+h.raw,a=a.substring(0,a.length-f.raw.length)+h.raw,o=E.substring(i[i.length-1].raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(e){let n=this.rules.block.list.exec(e);if(n){let o=n[1].trim();const s=o.length>1,a={type:"list",raw:"",ordered:s,start:s?+o.slice(0,-1):"",loose:!1,items:[]};o=s?`\\d{1,9}\\${o.slice(-1)}`:`\\${o}`,this.options.pedantic&&(o=s?o:"[*+-]");const i=new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;e;){let d=!1,u="",p="";if(!(n=i.exec(e))||this.rules.block.hr.test(e))break;u=n[0],e=e.substring(u.length);let g=n[2].split(`
12
+ ${h}`:h;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=x,r.length===0)break;const y=i[i.length-1];if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){const f=y,E=f.raw+`
13
+ `+r.join(`
14
+ `),g=this.blockquote(E);i[i.length-1]=g,s=s.substring(0,s.length-f.raw.length)+g.raw,a=a.substring(0,a.length-f.text.length)+g.text;break}else if((y==null?void 0:y.type)==="list"){const f=y,E=f.raw+`
15
+ `+r.join(`
16
+ `),g=this.list(E);i[i.length-1]=g,s=s.substring(0,s.length-y.raw.length)+g.raw,a=a.substring(0,a.length-f.raw.length)+g.raw,r=E.substring(i[i.length-1].raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r=n[1].trim();const s=r.length>1,a={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");const i=new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;e;){let d=!1,u="",p="";if(!(n=i.exec(e))||this.rules.block.hr.test(e))break;u=n[0],e=e.substring(u.length);let h=n[2].split(`
18
18
  `,1)[0].replace(/^\t+/,m=>" ".repeat(3*m.length)),x=e.split(`
19
- `,1)[0],y=!g.trim(),f=0;if(this.options.pedantic?(f=2,p=g.trimStart()):y?f=n[1].length+1:(f=n[2].search(/[^ ]/),f=f>4?1:f,p=g.slice(f),f+=n[1].length),y&&/^[ \t]*$/.test(x)&&(u+=x+`
20
- `,e=e.substring(x.length+1),d=!0),!d){const m=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),w=new RegExp(`^ {0,${Math.min(3,f-1)}}#`),$=new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i");for(;e;){const z=e.split(`
21
- `,1)[0];let F;if(x=z,this.options.pedantic?(x=x.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),F=x):F=x.replace(/\t/g," "),C.test(x)||w.test(x)||$.test(x)||m.test(x)||b.test(x))break;if(F.search(/[^ ]/)>=f||!x.trim())p+=`
22
- `+F.slice(f);else{if(y||g.replace(/\t/g," ").search(/[^ ]/)>=4||C.test(g)||w.test(g)||b.test(g))break;p+=`
23
- `+x}!y&&!x.trim()&&(y=!0),u+=z+`
24
- `,e=e.substring(z.length+1),g=F.slice(f)}}a.loose||(l?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(u)&&(l=!0));let E=null,h;this.options.gfm&&(E=/^\[[ xX]\] /.exec(p),E&&(h=E[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:u,task:!!E,checked:h,loose:!1,text:p,tokens:[]}),a.raw+=u}a.items[a.items.length-1].raw=a.items[a.items.length-1].raw.trimEnd(),a.items[a.items.length-1].text=a.items[a.items.length-1].text.trimEnd(),a.raw=a.raw.trimEnd();for(let d=0;d<a.items.length;d++)if(this.lexer.state.top=!1,a.items[d].tokens=this.lexer.blockTokens(a.items[d].text,[]),!a.loose){const u=a.items[d].tokens.filter(g=>g.type==="space"),p=u.length>0&&u.some(g=>/\n.*\n/.test(g.raw));a.loose=p}if(a.loose)for(let d=0;d<a.items.length;d++)a.items[d].loose=!0;return a}}html(e){const n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:n[0]}}def(e){const n=this.rules.block.def.exec(e);if(n){const o=n[1].toLowerCase().replace(/\s+/g," "),s=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:o,raw:n[0],href:s,title:a}}}table(e){const n=this.rules.block.table.exec(e);if(!n||!/[:|]/.test(n[2]))return;const o=wn(n[1]),s=n[2].replace(/^\||\| *$/g,"").split("|"),a=n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
25
- `):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(o.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?i.align.push("right"):/^ *:-+: *$/.test(l)?i.align.push("center"):/^ *:-+ *$/.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<o.length;l++)i.header.push({text:o[l],tokens:this.lexer.inline(o[l]),header:!0,align:i.align[l]});for(const l of a)i.rows.push(wn(l,i.header.length).map((d,u)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:i.align[u]})));return i}}lheading(e){const n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){const n=this.rules.block.paragraph.exec(e);if(n){const o=n[1].charAt(n[1].length-1)===`
26
- `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:o,tokens:this.lexer.inline(o)}}}text(e){const n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){const n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:ie(n[1])}}tag(e){const n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const o=n[2].trim();if(!this.options.pedantic&&/^</.test(o)){if(!/>$/.test(o))return;const i=qe(o.slice(0,-1),"\\");if((o.length-i.length)%2===0)return}else{const i=Go(n[2],"()");if(i>-1){const d=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,d).trim(),n[3]=""}}let s=n[2],a="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);i&&(s=i[1],a=i[3])}else a=n[3]?n[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(o)?s=s.slice(1):s=s.slice(1,-1)),bn(n,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer)}}reflink(e,n){let o;if((o=this.rules.inline.reflink.exec(e))||(o=this.rules.inline.nolink.exec(e))){const s=(o[2]||o[1]).replace(/\s+/g," "),a=n[s.toLowerCase()];if(!a){const i=o[0].charAt(0);return{type:"text",raw:i,text:i}}return bn(o,a,o[0],this.lexer)}}emStrong(e,n,o=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||s[3]&&o.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!o||this.rules.inline.punctuation.exec(o)){const i=[...s[0]].length-1;let l,d,u=i,p=0;const g=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,n=n.slice(-1*e.length+i);(s=g.exec(n))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(d=[...l].length,s[3]||s[4]){u+=d;continue}else if((s[5]||s[6])&&i%3&&!((i+d)%3)){p+=d;continue}if(u-=d,u>0)continue;d=Math.min(d,d+u+p);const x=[...s[0]][0].length,y=e.slice(0,i+s.index+x+d);if(Math.min(i,d)%2){const E=y.slice(1,-1);return{type:"em",raw:y,text:E,tokens:this.lexer.inlineTokens(E)}}const f=y.slice(2,-2);return{type:"strong",raw:y,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let o=n[2].replace(/\n/g," ");const s=/[^ ]/.test(o),a=/^ /.test(o)&&/ $/.test(o);return s&&a&&(o=o.substring(1,o.length-1)),o=ie(o,!0),{type:"codespan",raw:n[0],text:o}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){const n=this.rules.inline.autolink.exec(e);if(n){let o,s;return n[2]==="@"?(o=ie(n[1]),s="mailto:"+o):(o=ie(n[1]),s=o),{type:"link",raw:n[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(e){var o;let n;if(n=this.rules.inline.url.exec(e)){let s,a;if(n[2]==="@")s=ie(n[0]),a="mailto:"+s;else{let i;do i=n[0],n[0]=((o=this.rules.inline._backpedal.exec(n[0]))==null?void 0:o[0])??"";while(i!==n[0]);s=ie(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){const n=this.rules.inline.text.exec(e);if(n){let o;return this.lexer.state.inRawBlock?o=n[0]:o=ie(n[0]),{type:"text",raw:n[0],text:o}}}}const Qo=/^(?:[ \t]*(?:\n|$))+/,Zo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ve=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,En=/(?:[*+-]|\d{1,9}[.)])/,Cn=O(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,En).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Nt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Jo=/^[^\n]+/,Rt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,er=O(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),tr=O(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,En).getRegex(),st="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Bt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nr=O("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Bt).replace("tag",st).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sn=O(Nt).replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex(),Lt={blockquote:O(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Sn).getRegex(),code:Zo,def:er,fences:Yo,heading:Xo,hr:ve,html:nr,lheading:Cn,list:tr,newline:Qo,paragraph:Sn,table:Ue,text:Jo},Tn=O("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex(),or={...Lt,table:Tn,paragraph:O(Nt).replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Tn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex()},rr={...Lt,html:O(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ue,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:O(Nt).replace("hr",ve).replace("heading",` *#{1,6} *[^
19
+ `,1)[0],y=!h.trim(),f=0;if(this.options.pedantic?(f=2,p=h.trimStart()):y?f=n[1].length+1:(f=n[2].search(/[^ ]/),f=f>4?1:f,p=h.slice(f),f+=n[1].length),y&&/^[ \t]*$/.test(x)&&(u+=x+`
20
+ `,e=e.substring(x.length+1),d=!0),!d){const m=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),w=new RegExp(`^ {0,${Math.min(3,f-1)}}#`),z=new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i");for(;e;){const $=e.split(`
21
+ `,1)[0];let F;if(x=$,this.options.pedantic?(x=x.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),F=x):F=x.replace(/\t/g," "),C.test(x)||w.test(x)||z.test(x)||m.test(x)||b.test(x))break;if(F.search(/[^ ]/)>=f||!x.trim())p+=`
22
+ `+F.slice(f);else{if(y||h.replace(/\t/g," ").search(/[^ ]/)>=4||C.test(h)||w.test(h)||b.test(h))break;p+=`
23
+ `+x}!y&&!x.trim()&&(y=!0),u+=$+`
24
+ `,e=e.substring($.length+1),h=F.slice(f)}}a.loose||(l?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(u)&&(l=!0));let E=null,g;this.options.gfm&&(E=/^\[[ xX]\] /.exec(p),E&&(g=E[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:u,task:!!E,checked:g,loose:!1,text:p,tokens:[]}),a.raw+=u}a.items[a.items.length-1].raw=a.items[a.items.length-1].raw.trimEnd(),a.items[a.items.length-1].text=a.items[a.items.length-1].text.trimEnd(),a.raw=a.raw.trimEnd();for(let d=0;d<a.items.length;d++)if(this.lexer.state.top=!1,a.items[d].tokens=this.lexer.blockTokens(a.items[d].text,[]),!a.loose){const u=a.items[d].tokens.filter(h=>h.type==="space"),p=u.length>0&&u.some(h=>/\n.*\n/.test(h.raw));a.loose=p}if(a.loose)for(let d=0;d<a.items.length;d++)a.items[d].loose=!0;return a}}html(e){const n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:n[0]}}def(e){const n=this.rules.block.def.exec(e);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),s=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:s,title:a}}}table(e){const n=this.rules.block.table.exec(e);if(!n||!/[:|]/.test(n[2]))return;const r=wn(n[1]),s=n[2].replace(/^\||\| *$/g,"").split("|"),a=n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
25
+ `):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?i.align.push("right"):/^ *:-+: *$/.test(l)?i.align.push("center"):/^ *:-+ *$/.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<r.length;l++)i.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:i.align[l]});for(const l of a)i.rows.push(wn(l,i.header.length).map((d,u)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:i.align[u]})));return i}}lheading(e){const n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){const n=this.rules.block.paragraph.exec(e);if(n){const r=n[1].charAt(n[1].length-1)===`
26
+ `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(e){const n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){const n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:ie(n[1])}}tag(e){const n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=qe(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Ko(n[2],"()");if(i>-1){const d=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,d).trim(),n[3]=""}}let s=n[2],a="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);i&&(s=i[1],a=i[3])}else a=n[3]?n[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(r)?s=s.slice(1):s=s.slice(1,-1)),bn(n,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){const s=(r[2]||r[1]).replace(/\s+/g," "),a=n[s.toLowerCase()];if(!a){const i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return bn(r,a,r[0],this.lexer)}}emStrong(e,n,r=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||s[3]&&r.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const i=[...s[0]].length-1;let l,d,u=i,p=0;const h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,n=n.slice(-1*e.length+i);(s=h.exec(n))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(d=[...l].length,s[3]||s[4]){u+=d;continue}else if((s[5]||s[6])&&i%3&&!((i+d)%3)){p+=d;continue}if(u-=d,u>0)continue;d=Math.min(d,d+u+p);const x=[...s[0]][0].length,y=e.slice(0,i+s.index+x+d);if(Math.min(i,d)%2){const E=y.slice(1,-1);return{type:"em",raw:y,text:E,tokens:this.lexer.inlineTokens(E)}}const f=y.slice(2,-2);return{type:"strong",raw:y,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const s=/[^ ]/.test(r),a=/^ /.test(r)&&/ $/.test(r);return s&&a&&(r=r.substring(1,r.length-1)),r=ie(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){const n=this.rules.inline.autolink.exec(e);if(n){let r,s;return n[2]==="@"?(r=ie(n[1]),s="mailto:"+r):(r=ie(n[1]),s=r),{type:"link",raw:n[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(e){var r;let n;if(n=this.rules.inline.url.exec(e)){let s,a;if(n[2]==="@")s=ie(n[0]),a="mailto:"+s;else{let i;do i=n[0],n[0]=((r=this.rules.inline._backpedal.exec(n[0]))==null?void 0:r[0])??"";while(i!==n[0]);s=ie(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){const n=this.rules.inline.text.exec(e);if(n){let r;return this.lexer.state.inRawBlock?r=n[0]:r=ie(n[0]),{type:"text",raw:n[0],text:r}}}}const Qo=/^(?:[ \t]*(?:\n|$))+/,Zo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ve=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,En=/(?:[*+-]|\d{1,9}[.)])/,Cn=O(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,En).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Nt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Jo=/^[^\n]+/,Rt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,er=O(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),tr=O(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,En).getRegex(),st="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Bt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nr=O("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Bt).replace("tag",st).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sn=O(Nt).replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex(),Lt={blockquote:O(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Sn).getRegex(),code:Zo,def:er,fences:Yo,heading:Xo,hr:ve,html:nr,lheading:Cn,list:tr,newline:Qo,paragraph:Sn,table:Ue,text:Jo},Tn=O("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex(),or={...Lt,table:Tn,paragraph:O(Nt).replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Tn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex()},rr={...Lt,html:O(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ue,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:O(Nt).replace("hr",ve).replace("heading",` *#{1,6} *[^
27
27
  ]`).replace("lheading",Cn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},An=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,sr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mn=/^( {2,}|\\)\n(?!\s*$)/,ar=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,je="\\p{P}\\p{S}",ir=O(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,je).getRegex(),lr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,cr=O(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,je).getRegex(),ur=O("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,je).getRegex(),dr=O("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,je).getRegex(),pr=O(/\\([punct])/,"gu").replace(/punct/g,je).getRegex(),fr=O(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),mr=O(Bt).replace("(?:-->|$)","-->").getRegex(),hr=O("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",mr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),at=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,gr=O(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",at).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nn=O(/^!?\[(label)\]\[(ref)\]/).replace("label",at).replace("ref",Rt).getRegex(),Rn=O(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rt).getRegex(),yr=O("reflink|nolink(?!\\()","g").replace("reflink",Nn).replace("nolink",Rn).getRegex(),Dt={_backpedal:Ue,anyPunctuation:pr,autolink:fr,blockSkip:lr,br:Mn,code:sr,del:Ue,emStrongLDelim:cr,emStrongRDelimAst:ur,emStrongRDelimUnd:dr,escape:An,link:gr,nolink:Rn,punctuation:ir,reflink:Nn,reflinkSearch:yr,tag:hr,text:ar,url:Ue},kr={...Dt,link:O(/^!?\[(label)\]\((.*?)\)/).replace("label",at).getRegex(),reflink:O(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",at).getRegex()},It={...Dt,escape:O(An).replace("])","~|])").getRegex(),url:O(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},xr={...It,br:O(Mn).replace("{2,}","*").getRegex(),text:O(It.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},it={normal:Lt,gfm:or,pedantic:rr},We={normal:Dt,gfm:It,breaks:xr,pedantic:kr};class le{constructor(e){P(this,"tokens");P(this,"options");P(this,"state");P(this,"tokenizer");P(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Me,this.options.tokenizer=this.options.tokenizer||new rt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:it.normal,inline:We.normal};this.options.pedantic?(n.block=it.pedantic,n.inline=We.pedantic):this.options.gfm&&(n.block=it.gfm,this.options.breaks?n.inline=We.breaks:n.inline=We.gfm),this.tokenizer.rules=n}static get rules(){return{block:it,inline:We}}static lex(e,n){return new le(n).lex(e)}static lexInline(e,n){return new le(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
28
- `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],o=!1){this.options.pedantic&&(e=e.replace(/\t/g," ").replace(/^ +$/gm,""));let s,a,i;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(s=l.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))){if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length),s.raw.length===1&&n.length>0?n[n.length-1].raw+=`
28
+ `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.options.pedantic&&(e=e.replace(/\t/g," ").replace(/^ +$/gm,""));let s,a,i;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(s=l.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))){if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length),s.raw.length===1&&n.length>0?n[n.length-1].raw+=`
29
29
  `:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
30
30
  `+s.raw,a.text+=`
31
31
  `+s.text,this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
32
32
  `+s.raw,a.text+=`
33
- `+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(i=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const d=e.slice(1);let u;this.options.extensions.startBlock.forEach(p=>{u=p.call({lexer:this},d),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(i=e.substring(0,l+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){a=n[n.length-1],o&&(a==null?void 0:a.type)==="paragraph"?(a.raw+=`
33
+ `+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(i=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const d=e.slice(1);let u;this.options.extensions.startBlock.forEach(p=>{u=p.call({lexer:this},d),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(i=e.substring(0,l+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){a=n[n.length-1],r&&(a==null?void 0:a.type)==="paragraph"?(a.raw+=`
34
34
  `+s.raw,a.text+=`
35
- `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s),o=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length),a=n[n.length-1],a&&a.type==="text"?(a.raw+=`
35
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s),r=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length),a=n[n.length-1],a&&a.type==="text"?(a.raw+=`
36
36
  `+s.raw,a.text+=`
37
- `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let o,s,a,i=e,l,d,u;if(this.tokens.links){const p=Object.keys(this.tokens.links);if(p.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)p.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,l.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(d||(u=""),d=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(o=p.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))){if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),s=n[n.length-1],s&&o.type==="text"&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length),s=n[n.length-1],s&&o.type==="text"&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(o=this.tokenizer.emStrong(e,i,u)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),n.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),n.push(o);continue}if(a=e,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const g=e.slice(1);let x;this.options.extensions.startInline.forEach(y=>{x=y.call({lexer:this},g),typeof x=="number"&&x>=0&&(p=Math.min(p,x))}),p<1/0&&p>=0&&(a=e.substring(0,p+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(u=o.raw.slice(-1)),d=!0,s=n[n.length-1],s&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(e){const p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return n}}class lt{constructor(e){P(this,"options");P(this,"parser");this.options=e||Me}space(e){return""}code({text:e,lang:n,escaped:o}){var i;const s=(i=(n||"").match(/^\S*/))==null?void 0:i[0],a=e.replace(/\n$/,"")+`
38
- `;return s?'<pre><code class="language-'+ie(s)+'">'+(o?a:ie(a,!0))+`</code></pre>
39
- `:"<pre><code>"+(o?a:ie(a,!0))+`</code></pre>
37
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,s,a,i=e,l,d,u;if(this.tokens.links){const p=Object.keys(this.tokens.links);if(p.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)p.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,l.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(d||(u=""),d=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(r=p.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),s=n[n.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),s=n[n.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,i,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),n.push(r);continue}if(a=e,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const h=e.slice(1);let x;this.options.extensions.startInline.forEach(y=>{x=y.call({lexer:this},h),typeof x=="number"&&x>=0&&(p=Math.min(p,x))}),p<1/0&&p>=0&&(a=e.substring(0,p+1))}if(r=this.tokenizer.inlineText(a)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),d=!0,s=n[n.length-1],s&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(e){const p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return n}}class lt{constructor(e){P(this,"options");P(this,"parser");this.options=e||Me}space(e){return""}code({text:e,lang:n,escaped:r}){var i;const s=(i=(n||"").match(/^\S*/))==null?void 0:i[0],a=e.replace(/\n$/,"")+`
38
+ `;return s?'<pre><code class="language-'+ie(s)+'">'+(r?a:ie(a,!0))+`</code></pre>
39
+ `:"<pre><code>"+(r?a:ie(a,!0))+`</code></pre>
40
40
  `}blockquote({tokens:e}){return`<blockquote>
41
41
  ${this.parser.parse(e)}</blockquote>
42
42
  `}html({text:e}){return e}heading({tokens:e,depth:n}){return`<h${n}>${this.parser.parseInline(e)}</h${n}>
43
43
  `}hr(e){return`<hr>
44
- `}list(e){const n=e.ordered,o=e.start;let s="";for(let l=0;l<e.items.length;l++){const d=e.items[l];s+=this.listitem(d)}const a=n?"ol":"ul",i=n&&o!==1?' start="'+o+'"':"";return"<"+a+i+`>
44
+ `}list(e){const n=e.ordered,r=e.start;let s="";for(let l=0;l<e.items.length;l++){const d=e.items[l];s+=this.listitem(d)}const a=n?"ol":"ul",i=n&&r!==1?' start="'+r+'"':"";return"<"+a+i+`>
45
45
  `+s+"</"+a+`>
46
- `}listitem(e){let n="";if(e.task){const o=this.checkbox({checked:!!e.checked});e.loose?e.tokens.length>0&&e.tokens[0].type==="paragraph"?(e.tokens[0].text=o+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=o+" "+e.tokens[0].tokens[0].text)):e.tokens.unshift({type:"text",raw:o+" ",text:o+" "}):n+=o+" "}return n+=this.parser.parse(e.tokens,!!e.loose),`<li>${n}</li>
46
+ `}listitem(e){let n="";if(e.task){const r=this.checkbox({checked:!!e.checked});e.loose?e.tokens.length>0&&e.tokens[0].type==="paragraph"?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=r+" "+e.tokens[0].tokens[0].text)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" "}):n+=r+" "}return n+=this.parser.parse(e.tokens,!!e.loose),`<li>${n}</li>
47
47
  `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
48
- `}table(e){let n="",o="";for(let a=0;a<e.header.length;a++)o+=this.tablecell(e.header[a]);n+=this.tablerow({text:o});let s="";for(let a=0;a<e.rows.length;a++){const i=e.rows[a];o="";for(let l=0;l<i.length;l++)o+=this.tablecell(i[l]);s+=this.tablerow({text:o})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
48
+ `}table(e){let n="",r="";for(let a=0;a<e.header.length;a++)r+=this.tablecell(e.header[a]);n+=this.tablerow({text:r});let s="";for(let a=0;a<e.rows.length;a++){const i=e.rows[a];r="";for(let l=0;l<i.length;l++)r+=this.tablecell(i[l]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
49
49
  <thead>
50
50
  `+n+`</thead>
51
51
  `+s+`</table>
52
52
  `}tablerow({text:e}){return`<tr>
53
53
  ${e}</tr>
54
- `}tablecell(e){const n=this.parser.parseInline(e.tokens),o=e.header?"th":"td";return(e.align?`<${o} align="${e.align}">`:`<${o}>`)+n+`</${o}>
55
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${e}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:o}){const s=this.parser.parseInline(o),a=xn(e);if(a===null)return s;e=a;let i='<a href="'+e+'"';return n&&(i+=' title="'+n+'"'),i+=">"+s+"</a>",i}image({href:e,title:n,text:o}){const s=xn(e);if(s===null)return o;e=s;let a=`<img src="${e}" alt="${o}"`;return n&&(a+=` title="${n}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):e.text}}class $t{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class ce{constructor(e){P(this,"options");P(this,"renderer");P(this,"textRenderer");this.options=e||Me,this.options.renderer=this.options.renderer||new lt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $t}static parse(e,n){return new ce(n).parse(e)}static parseInline(e,n){return new ce(n).parseInline(e)}parse(e,n=!0){let o="";for(let s=0;s<e.length;s++){const a=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=a,d=this.options.extensions.renderers[l.type].call({parser:this},l);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){o+=d||"";continue}}const i=a;switch(i.type){case"space":{o+=this.renderer.space(i);continue}case"hr":{o+=this.renderer.hr(i);continue}case"heading":{o+=this.renderer.heading(i);continue}case"code":{o+=this.renderer.code(i);continue}case"table":{o+=this.renderer.table(i);continue}case"blockquote":{o+=this.renderer.blockquote(i);continue}case"list":{o+=this.renderer.list(i);continue}case"html":{o+=this.renderer.html(i);continue}case"paragraph":{o+=this.renderer.paragraph(i);continue}case"text":{let l=i,d=this.renderer.text(l);for(;s+1<e.length&&e[s+1].type==="text";)l=e[++s],d+=`
56
- `+this.renderer.text(l);n?o+=this.renderer.paragraph({type:"paragraph",raw:d,text:d,tokens:[{type:"text",raw:d,text:d}]}):o+=d;continue}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}parseInline(e,n){n=n||this.renderer;let o="";for(let s=0;s<e.length;s++){const a=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){o+=l||"";continue}}const i=a;switch(i.type){case"escape":{o+=n.text(i);break}case"html":{o+=n.html(i);break}case"link":{o+=n.link(i);break}case"image":{o+=n.image(i);break}case"strong":{o+=n.strong(i);break}case"em":{o+=n.em(i);break}case"codespan":{o+=n.codespan(i);break}case"br":{o+=n.br(i);break}case"del":{o+=n.del(i);break}case"text":{o+=n.text(i);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}}class Ge{constructor(e){P(this,"options");P(this,"block");this.options=e||Me}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?le.lex:le.lexInline}provideParser(){return this.block?ce.parse:ce.parseInline}}P(Ge,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class wr{constructor(...e){P(this,"defaults",Mt());P(this,"options",this.setOptions);P(this,"parse",this.parseMarkdown(!0));P(this,"parseInline",this.parseMarkdown(!1));P(this,"Parser",ce);P(this,"Renderer",lt);P(this,"TextRenderer",$t);P(this,"Lexer",le);P(this,"Tokenizer",rt);P(this,"Hooks",Ge);this.use(...e)}walkTokens(e,n){var s,a;let o=[];for(const i of e)switch(o=o.concat(n.call(this,i)),i.type){case"table":{const l=i;for(const d of l.header)o=o.concat(this.walkTokens(d.tokens,n));for(const d of l.rows)for(const u of d)o=o.concat(this.walkTokens(u.tokens,n));break}case"list":{const l=i;o=o.concat(this.walkTokens(l.items,n));break}default:{const l=i;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[l.type]?this.defaults.extensions.childTokens[l.type].forEach(d=>{const u=l[d].flat(1/0);o=o.concat(this.walkTokens(u,n))}):l.tokens&&(o=o.concat(this.walkTokens(l.tokens,n)))}}return o}use(...e){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(o=>{const s={...o};if(s.async=this.defaults.async||s.async||!1,o.extensions&&(o.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=n.renderers[a.name];i?n.renderers[a.name]=function(...l){let d=a.renderer.apply(this,l);return d===!1&&(d=i.apply(this,l)),d}:n.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=n[a.level];i?i.unshift(a.tokenizer):n[a.level]=[a.tokenizer],a.start&&(a.level==="block"?n.startBlock?n.startBlock.push(a.start):n.startBlock=[a.start]:a.level==="inline"&&(n.startInline?n.startInline.push(a.start):n.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(n.childTokens[a.name]=a.childTokens)}),s.extensions=n),o.renderer){const a=this.defaults.renderer||new lt(this.defaults);for(const i in o.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const l=i,d=o.renderer[l],u=a[l];a[l]=(...p)=>{let g=d.apply(a,p);return g===!1&&(g=u.apply(a,p)),g||""}}s.renderer=a}if(o.tokenizer){const a=this.defaults.tokenizer||new rt(this.defaults);for(const i in o.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const l=i,d=o.tokenizer[l],u=a[l];a[l]=(...p)=>{let g=d.apply(a,p);return g===!1&&(g=u.apply(a,p)),g}}s.tokenizer=a}if(o.hooks){const a=this.defaults.hooks||new Ge;for(const i in o.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const l=i,d=o.hooks[l],u=a[l];Ge.passThroughHooks.has(i)?a[l]=p=>{if(this.defaults.async)return Promise.resolve(d.call(a,p)).then(x=>u.call(a,x));const g=d.call(a,p);return u.call(a,g)}:a[l]=(...p)=>{let g=d.apply(a,p);return g===!1&&(g=u.apply(a,p)),g}}s.hooks=a}if(o.walkTokens){const a=this.defaults.walkTokens,i=o.walkTokens;s.walkTokens=function(l){let d=[];return d.push(i.call(this,l)),a&&(d=d.concat(a.call(this,l))),d}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return le.lex(e,n??this.defaults)}parser(e,n){return ce.parse(e,n??this.defaults)}parseMarkdown(e){return(o,s)=>{const a={...s},i={...this.defaults,...a},l=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&a.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof o>"u"||o===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const d=i.hooks?i.hooks.provideLexer():e?le.lex:le.lexInline,u=i.hooks?i.hooks.provideParser():e?ce.parse:ce.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(o):o).then(p=>d(p,i)).then(p=>i.hooks?i.hooks.processAllTokens(p):p).then(p=>i.walkTokens?Promise.all(this.walkTokens(p,i.walkTokens)).then(()=>p):p).then(p=>u(p,i)).then(p=>i.hooks?i.hooks.postprocess(p):p).catch(l);try{i.hooks&&(o=i.hooks.preprocess(o));let p=d(o,i);i.hooks&&(p=i.hooks.processAllTokens(p)),i.walkTokens&&this.walkTokens(p,i.walkTokens);let g=u(p,i);return i.hooks&&(g=i.hooks.postprocess(g)),g}catch(p){return l(p)}}}onError(e,n){return o=>{if(o.message+=`
57
- Please report this to https://github.com/markedjs/marked.`,e){const s="<p>An error occurred:</p><pre>"+ie(o.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(o);throw o}}}const Ne=new wr;function _(r,e){return Ne.parse(r,e)}_.options=_.setOptions=function(r){return Ne.setOptions(r),_.defaults=Ne.defaults,hn(_.defaults),_},_.getDefaults=Mt,_.defaults=Me,_.use=function(...r){return Ne.use(...r),_.defaults=Ne.defaults,hn(_.defaults),_},_.walkTokens=function(r,e){return Ne.walkTokens(r,e)},_.parseInline=Ne.parseInline,_.Parser=ce,_.parser=ce.parse,_.Renderer=lt,_.TextRenderer=$t,_.Lexer=le,_.lexer=le.lex,_.Tokenizer=rt,_.Hooks=Ge,_.parse=_,_.options,_.setOptions,_.use,_.walkTokens,_.parseInline,ce.parse,le.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:Bn,setPrototypeOf:Ln,isFrozen:br,getPrototypeOf:Er,getOwnPropertyDescriptor:Cr}=Object;let{freeze:ne,seal:ue,create:zt}=Object,{apply:_t,construct:Ot}=typeof Reflect<"u"&&Reflect;ne||(ne=function(e){return e}),ue||(ue=function(e){return e}),_t||(_t=function(e,n){for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];return e.apply(n,s)}),Ot||(Ot=function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return new e(...o)});const ct=re(Array.prototype.forEach),Sr=re(Array.prototype.lastIndexOf),Dn=re(Array.prototype.pop),Ke=re(Array.prototype.push),Tr=re(Array.prototype.splice),ut=re(String.prototype.toLowerCase),Pt=re(String.prototype.toString),Vt=re(String.prototype.match),Qe=re(String.prototype.replace),Ar=re(String.prototype.indexOf),Mr=re(String.prototype.trim),de=re(Object.prototype.hasOwnProperty),oe=re(RegExp.prototype.test),Ze=Nr(TypeError);function re(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return _t(r,e,o)}}function Nr(r){return function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return Ot(r,n)}}function I(r,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ut;Ln&&Ln(r,null);let o=e.length;for(;o--;){let s=e[o];if(typeof s=="string"){const a=n(s);a!==s&&(br(e)||(e[o]=a),s=a)}r[s]=!0}return r}function Rr(r){for(let e=0;e<r.length;e++)de(r,e)||(r[e]=null);return r}function ge(r){const e=zt(null);for(const[n,o]of Bn(r))de(r,n)&&(Array.isArray(o)?e[n]=Rr(o):o&&typeof o=="object"&&o.constructor===Object?e[n]=ge(o):e[n]=o);return e}function Ye(r,e){for(;r!==null;){const o=Cr(r,e);if(o){if(o.get)return re(o.get);if(typeof o.value=="function")return re(o.value)}r=Er(r)}function n(){return null}return n}const In=ne(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ft=ne(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ht=ne(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Br=ne(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ut=ne(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Lr=ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),$n=ne(["#text"]),zn=ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),qt=ne(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),_n=ne(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),dt=ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Dr=ue(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ir=ue(/<%[\w\W]*|[\w\W]*%>/gm),$r=ue(/\$\{[\w\W]*/gm),zr=ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),_r=ue(/^aria-[\-\w]+$/),On=ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Or=ue(/^(?:\w+script|data):/i),Pr=ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pn=ue(/^html$/i),Vr=ue(/^[a-z][.\w]*(-[.\w]+)+$/i);var Vn=Object.freeze({__proto__:null,ARIA_ATTR:_r,ATTR_WHITESPACE:Pr,CUSTOM_ELEMENT:Vr,DATA_ATTR:zr,DOCTYPE_NAME:Pn,ERB_EXPR:Ir,IS_ALLOWED_URI:On,IS_SCRIPT_OR_DATA:Or,MUSTACHE_EXPR:Dr,TMPLIT_EXPR:$r});const Xe={element:1,text:3,progressingInstruction:7,comment:8,document:9},Fr=function(){return typeof window>"u"?null:window},Hr=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(o=n.getAttribute(s));const a="dompurify"+(o?"#"+o:"");try{return e.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Fn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hn(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fr();const e=R=>Hn(R);if(e.version="3.3.0",e.removed=[],!r||!r.document||r.document.nodeType!==Xe.document||!r.Element)return e.isSupported=!1,e;let{document:n}=r;const o=n,s=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:d,NodeFilter:u,NamedNodeMap:p=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:g,DOMParser:x,trustedTypes:y}=r,f=d.prototype,E=Ye(f,"cloneNode"),h=Ye(f,"remove"),m=Ye(f,"nextSibling"),b=Ye(f,"childNodes"),C=Ye(f,"parentNode");if(typeof i=="function"){const R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let w,$="";const{implementation:z,createNodeIterator:F,createDocumentFragment:S,getElementsByTagName:T}=n,{importNode:N}=o;let D=Fn();e.isSupported=typeof Bn=="function"&&typeof C=="function"&&z&&z.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:Q,TMPLIT_EXPR:fe,DATA_ATTR:Re,ARIA_ATTR:ye,IS_SCRIPT_OR_DATA:Be,ATTR_WHITESPACE:pt,CUSTOM_ELEMENT:Wt}=Vn;let{IS_ALLOWED_URI:ft}=Vn,j=null;const Je=I({},[...In,...Ft,...Ht,...Ut,...$n]);let Z=null;const mt=I({},[...zn,...qt,..._n,...dt]);let v=Object.seal(zt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Le=null,$e=null;const ke=Object.seal(zt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ht=!0,ze=!0,L=!1,V=!0,H=!1,K=!0,W=!1,G=!1,se=!1,me=!1,gt=!1,yt=!1,to=!0,no=!1;const _a="user-content-";let Gt=!0,et=!1,_e={},Oe=null;const oo=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ro=null;const so=I({},["audio","video","img","source","image","track"]);let Kt=null;const ao=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let Pe=xe,Qt=!1,Zt=null;const Oa=I({},[kt,xt,xe],Pt);let wt=I({},["mi","mo","mn","ms","mtext"]),bt=I({},["annotation-xml"]);const Pa=I({},["title","style","font","a","script"]);let tt=null;const Va=["application/xhtml+xml","text/html"],Fa="text/html";let X=null,Ve=null;const Ha=n.createElement("form"),io=function(c){return c instanceof RegExp||c instanceof Function},Yt=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ve&&Ve===c)){if((!c||typeof c!="object")&&(c={}),c=ge(c),tt=Va.indexOf(c.PARSER_MEDIA_TYPE)===-1?Fa:c.PARSER_MEDIA_TYPE,X=tt==="application/xhtml+xml"?Pt:ut,j=de(c,"ALLOWED_TAGS")?I({},c.ALLOWED_TAGS,X):Je,Z=de(c,"ALLOWED_ATTR")?I({},c.ALLOWED_ATTR,X):mt,Zt=de(c,"ALLOWED_NAMESPACES")?I({},c.ALLOWED_NAMESPACES,Pt):Oa,Kt=de(c,"ADD_URI_SAFE_ATTR")?I(ge(ao),c.ADD_URI_SAFE_ATTR,X):ao,ro=de(c,"ADD_DATA_URI_TAGS")?I(ge(so),c.ADD_DATA_URI_TAGS,X):so,Oe=de(c,"FORBID_CONTENTS")?I({},c.FORBID_CONTENTS,X):oo,Le=de(c,"FORBID_TAGS")?I({},c.FORBID_TAGS,X):ge({}),$e=de(c,"FORBID_ATTR")?I({},c.FORBID_ATTR,X):ge({}),_e=de(c,"USE_PROFILES")?c.USE_PROFILES:!1,ht=c.ALLOW_ARIA_ATTR!==!1,ze=c.ALLOW_DATA_ATTR!==!1,L=c.ALLOW_UNKNOWN_PROTOCOLS||!1,V=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=c.SAFE_FOR_TEMPLATES||!1,K=c.SAFE_FOR_XML!==!1,W=c.WHOLE_DOCUMENT||!1,me=c.RETURN_DOM||!1,gt=c.RETURN_DOM_FRAGMENT||!1,yt=c.RETURN_TRUSTED_TYPE||!1,se=c.FORCE_BODY||!1,to=c.SANITIZE_DOM!==!1,no=c.SANITIZE_NAMED_PROPS||!1,Gt=c.KEEP_CONTENT!==!1,et=c.IN_PLACE||!1,ft=c.ALLOWED_URI_REGEXP||On,Pe=c.NAMESPACE||xe,wt=c.MATHML_TEXT_INTEGRATION_POINTS||wt,bt=c.HTML_INTEGRATION_POINTS||bt,v=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(v.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(v.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(v.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),H&&(ze=!1),gt&&(me=!0),_e&&(j=I({},$n),Z=[],_e.html===!0&&(I(j,In),I(Z,zn)),_e.svg===!0&&(I(j,Ft),I(Z,qt),I(Z,dt)),_e.svgFilters===!0&&(I(j,Ht),I(Z,qt),I(Z,dt)),_e.mathMl===!0&&(I(j,Ut),I(Z,_n),I(Z,dt))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?ke.tagCheck=c.ADD_TAGS:(j===Je&&(j=ge(j)),I(j,c.ADD_TAGS,X))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?ke.attributeCheck=c.ADD_ATTR:(Z===mt&&(Z=ge(Z)),I(Z,c.ADD_ATTR,X))),c.ADD_URI_SAFE_ATTR&&I(Kt,c.ADD_URI_SAFE_ATTR,X),c.FORBID_CONTENTS&&(Oe===oo&&(Oe=ge(Oe)),I(Oe,c.FORBID_CONTENTS,X)),Gt&&(j["#text"]=!0),W&&I(j,["html","head","body"]),j.table&&(I(j,["tbody"]),delete Le.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=c.TRUSTED_TYPES_POLICY,$=w.createHTML("")}else w===void 0&&(w=Hr(y,s)),w!==null&&typeof $=="string"&&($=w.createHTML(""));ne&&ne(c),Ve=c}},lo=I({},[...Ft,...Ht,...Br]),co=I({},[...Ut,...Lr]),Ua=function(c){let k=C(c);(!k||!k.tagName)&&(k={namespaceURI:Pe,tagName:"template"});const A=ut(c.tagName),U=ut(k.tagName);return Zt[c.namespaceURI]?c.namespaceURI===xt?k.namespaceURI===xe?A==="svg":k.namespaceURI===kt?A==="svg"&&(U==="annotation-xml"||wt[U]):!!lo[A]:c.namespaceURI===kt?k.namespaceURI===xe?A==="math":k.namespaceURI===xt?A==="math"&&bt[U]:!!co[A]:c.namespaceURI===xe?k.namespaceURI===xt&&!bt[U]||k.namespaceURI===kt&&!wt[U]?!1:!co[A]&&(Pa[A]||!lo[A]):!!(tt==="application/xhtml+xml"&&Zt[c.namespaceURI]):!1},he=function(c){Ke(e.removed,{element:c});try{C(c).removeChild(c)}catch{h(c)}},De=function(c,k){try{Ke(e.removed,{attribute:k.getAttributeNode(c),from:k})}catch{Ke(e.removed,{attribute:null,from:k})}if(k.removeAttribute(c),c==="is")if(me||gt)try{he(k)}catch{}else try{k.setAttribute(c,"")}catch{}},uo=function(c){let k=null,A=null;if(se)c="<remove></remove>"+c;else{const Y=Vt(c,/^[\r\n\t ]+/);A=Y&&Y[0]}tt==="application/xhtml+xml"&&Pe===xe&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const U=w?w.createHTML(c):c;if(Pe===xe)try{k=new x().parseFromString(U,tt)}catch{}if(!k||!k.documentElement){k=z.createDocument(Pe,"template",null);try{k.documentElement.innerHTML=Qt?$:U}catch{}}const te=k.body||k.documentElement;return c&&A&&te.insertBefore(n.createTextNode(A),te.childNodes[0]||null),Pe===xe?T.call(k,W?"html":"body")[0]:W?k.documentElement:te},po=function(c){return F.call(c.ownerDocument||c,c,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Xt=function(c){return c instanceof g&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof p)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},fo=function(c){return typeof l=="function"&&c instanceof l};function we(R,c,k){ct(R,A=>{A.call(e,c,k,Ve)})}const mo=function(c){let k=null;if(we(D.beforeSanitizeElements,c,null),Xt(c))return he(c),!0;const A=X(c.nodeName);if(we(D.uponSanitizeElement,c,{tagName:A,allowedTags:j}),K&&c.hasChildNodes()&&!fo(c.firstElementChild)&&oe(/<[/\w!]/g,c.innerHTML)&&oe(/<[/\w!]/g,c.textContent)||c.nodeType===Xe.progressingInstruction||K&&c.nodeType===Xe.comment&&oe(/<[/\w]/g,c.data))return he(c),!0;if(!(ke.tagCheck instanceof Function&&ke.tagCheck(A))&&(!j[A]||Le[A])){if(!Le[A]&&go(A)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A)))return!1;if(Gt&&!Oe[A]){const U=C(c)||c.parentNode,te=b(c)||c.childNodes;if(te&&U){const Y=te.length;for(let ae=Y-1;ae>=0;--ae){const be=E(te[ae],!0);be.__removalCount=(c.__removalCount||0)+1,U.insertBefore(be,m(c))}}}return he(c),!0}return c instanceof d&&!Ua(c)||(A==="noscript"||A==="noembed"||A==="noframes")&&oe(/<\/no(script|embed|frames)/i,c.innerHTML)?(he(c),!0):(H&&c.nodeType===Xe.text&&(k=c.textContent,ct([M,Q,fe],U=>{k=Qe(k,U," ")}),c.textContent!==k&&(Ke(e.removed,{element:c.cloneNode()}),c.textContent=k)),we(D.afterSanitizeElements,c,null),!1)},ho=function(c,k,A){if(to&&(k==="id"||k==="name")&&(A in n||A in Ha))return!1;if(!(ze&&!$e[k]&&oe(Re,k))){if(!(ht&&oe(ye,k))){if(!(ke.attributeCheck instanceof Function&&ke.attributeCheck(k,c))){if(!Z[k]||$e[k]){if(!(go(c)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,c)||v.tagNameCheck instanceof Function&&v.tagNameCheck(c))&&(v.attributeNameCheck instanceof RegExp&&oe(v.attributeNameCheck,k)||v.attributeNameCheck instanceof Function&&v.attributeNameCheck(k,c))||k==="is"&&v.allowCustomizedBuiltInElements&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A))))return!1}else if(!Kt[k]){if(!oe(ft,Qe(A,pt,""))){if(!((k==="src"||k==="xlink:href"||k==="href")&&c!=="script"&&Ar(A,"data:")===0&&ro[c])){if(!(L&&!oe(Be,Qe(A,pt,"")))){if(A)return!1}}}}}}}return!0},go=function(c){return c!=="annotation-xml"&&Vt(c,Wt)},yo=function(c){we(D.beforeSanitizeAttributes,c,null);const{attributes:k}=c;if(!k||Xt(c))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0};let U=k.length;for(;U--;){const te=k[U],{name:Y,namespaceURI:ae,value:be}=te,Fe=X(Y),Jt=be;let ee=Y==="value"?Jt:Mr(Jt);if(A.attrName=Fe,A.attrValue=ee,A.keepAttr=!0,A.forceKeepAttr=void 0,we(D.uponSanitizeAttribute,c,A),ee=A.attrValue,no&&(Fe==="id"||Fe==="name")&&(De(Y,c),ee=_a+ee),K&&oe(/((--!?|])>)|<\/(style|title|textarea)/i,ee)){De(Y,c);continue}if(Fe==="attributename"&&Vt(ee,"href")){De(Y,c);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){De(Y,c);continue}if(!V&&oe(/\/>/i,ee)){De(Y,c);continue}H&&ct([M,Q,fe],xo=>{ee=Qe(ee,xo," ")});const ko=X(c.nodeName);if(!ho(ko,Fe,ee)){De(Y,c);continue}if(w&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!ae)switch(y.getAttributeType(ko,Fe)){case"TrustedHTML":{ee=w.createHTML(ee);break}case"TrustedScriptURL":{ee=w.createScriptURL(ee);break}}if(ee!==Jt)try{ae?c.setAttributeNS(ae,Y,ee):c.setAttribute(Y,ee),Xt(c)?he(c):Dn(e.removed)}catch{De(Y,c)}}we(D.afterSanitizeAttributes,c,null)},qa=function R(c){let k=null;const A=po(c);for(we(D.beforeSanitizeShadowDOM,c,null);k=A.nextNode();)we(D.uponSanitizeShadowNode,k,null),mo(k),yo(k),k.content instanceof a&&R(k.content);we(D.afterSanitizeShadowDOM,c,null)};return e.sanitize=function(R){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=null,A=null,U=null,te=null;if(Qt=!R,Qt&&(R="<!-->"),typeof R!="string"&&!fo(R))if(typeof R.toString=="function"){if(R=R.toString(),typeof R!="string")throw Ze("dirty is not a string, aborting")}else throw Ze("toString is not a function");if(!e.isSupported)return R;if(G||Yt(c),e.removed=[],typeof R=="string"&&(et=!1),et){if(R.nodeName){const be=X(R.nodeName);if(!j[be]||Le[be])throw Ze("root node is forbidden and cannot be sanitized in-place")}}else if(R instanceof l)k=uo("<!---->"),A=k.ownerDocument.importNode(R,!0),A.nodeType===Xe.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?k=A:k.appendChild(A);else{if(!me&&!H&&!W&&R.indexOf("<")===-1)return w&&yt?w.createHTML(R):R;if(k=uo(R),!k)return me?null:yt?$:""}k&&se&&he(k.firstChild);const Y=po(et?R:k);for(;U=Y.nextNode();)mo(U),yo(U),U.content instanceof a&&qa(U.content);if(et)return R;if(me){if(gt)for(te=S.call(k.ownerDocument);k.firstChild;)te.appendChild(k.firstChild);else te=k;return(Z.shadowroot||Z.shadowrootmode)&&(te=N.call(o,te,!0)),te}let ae=W?k.outerHTML:k.innerHTML;return W&&j["!doctype"]&&k.ownerDocument&&k.ownerDocument.doctype&&k.ownerDocument.doctype.name&&oe(Pn,k.ownerDocument.doctype.name)&&(ae="<!DOCTYPE "+k.ownerDocument.doctype.name+`>
58
- `+ae),H&&ct([M,Q,fe],be=>{ae=Qe(ae,be," ")}),w&&yt?w.createHTML(ae):ae},e.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(R),G=!0},e.clearConfig=function(){Ve=null,G=!1},e.isValidAttribute=function(R,c,k){Ve||Yt({});const A=X(R),U=X(c);return ho(A,U,k)},e.addHook=function(R,c){typeof c=="function"&&Ke(D[R],c)},e.removeHook=function(R,c){if(c!==void 0){const k=Sr(D[R],c);return k===-1?void 0:Tr(D[R],k,1)[0]}return Dn(D[R])},e.removeHooks=function(R){D[R]=[]},e.removeAllHooks=function(){D=Fn()},e}var Ur=Hn();function Un(){return{parseMarkdown:e=>{if(!e||typeof e!="string")return"";const n=ln(e),o=_.parse(n,{async:!1,breaks:!0,gfm:!0});return Ur.sanitize(o,{ALLOWED_TAGS:["p","br","strong","em","b","i","code","pre","ul","ol","li","h1","h2","h3","h4","h5","h6","a","blockquote","span","div","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","target","rel","data-mention-id","data-mention-type"],ALLOW_UNKNOWN_PROTOCOLS:!1,FORBID_ATTR:["onerror","onload","onclick","onmouseover"],KEEP_CONTENT:!0})}}}function qr(){let r=null;function e(a){const i=a||document.querySelector("[data-rai-chat-container]");i&&requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})}function n(a,i=100){const{scrollTop:l,scrollHeight:d,clientHeight:u}=a;return d-l-u<i}function o(a){a&&(s(),r=new MutationObserver(()=>{(a.scrollTop===0||n(a))&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}),r.observe(a,{childList:!0,subtree:!0}))}function s(){r&&(r.disconnect(),r=null)}return t.onUnmounted(()=>{s()}),{scrollToBottom:e,setupAutoScroll:o,cleanupAutoScroll:s}}function vr(){const r=Ae(),e=t.computed(()=>r.error),n=t.computed(()=>{var a,i;return((a=e.value)==null?void 0:a.message)!==null&&((i=e.value)==null?void 0:i.message)!==void 0});return{errorState:e,hasError:n,retry:async()=>await r.retry(),clearError:()=>{r.clearError()}}}function vt(){const r=Ae(),e=t.computed(()=>r.pageContext);function n(a){r.setPageContext(a)}function o(){r.setPageContext(null)}function s(a){const i=r.pageContext;i&&r.setPageContext({...i,...a,metadata:{...i.metadata,...a.metadata}})}return{context:e,setContext:n,clearContext:o,updateContext:s}}const pe=[],qn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const r=q();return(r==null?void 0:r.defaultSuggestions)||[]}};function jr(){pe.length=0;const r=q();r!=null&&r.suggestionProviders&&pe.push(...r.suggestionProviders),pe.push(qn)}function Wr(r,e){const n=[...pe].sort((o,s)=>(s.priority||0)-(o.priority||0));for(const o of n)if(o.matcher&&o.matcher(r,e)||o.routes&&o.routes.some(a=>a.endsWith("*")?r.startsWith(a.slice(0,-1)):r===a||r.startsWith(a+"/")))return o;return qn}function vn(r,e){pe.length===0&&jr();const n=Wr(r,e),o=e||{pageType:"default",routePath:r};return n.extractContext&&(o.metadata={...o.metadata,...n.extractContext(r)}),n.getSuggestions(o)||[]}function Gr(r){const e=pe.findIndex(n=>n.id===r.id);if(e>=0)pe[e]=r;else{const n=pe.findIndex(o=>o.id==="default");n>=0?pe.splice(n,0,r):pe.push(r)}}const Kr=Gr;function jt(){const{context:r}=vt(),e=Ae(),n=t.computed(()=>{var d;if(e.quota.remaining===0){const u=q();return(u==null?void 0:u.enableSupportMode)!==!1?[{id:"contact-support-quota",title:J("contactSupport"),description:J("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[]}const a=((d=r.value)==null?void 0:d.routePath)||(typeof window<"u"?window.location.pathname:"/"),i=vn(a,r.value)||[],l=q();return l!=null&&l.can?i.filter(u=>!(u.permission&&!l.can(u.permission))):i}),o=t.computed(()=>r.value!==null&&r.value.pageType!=="default");function s(a){return typeof a.prompt=="function"?a.prompt(r.value||{pageType:"default"}):a.prompt}return{suggestions:n,hasContextualSuggestions:o,resolvePrompt:s}}function Qr(r,e){const{setContext:n,clearContext:o,updateContext:s}=vt();function a(){if(!e)return{};const l={};for(const[d,u]of Object.entries(e))l[d]=t.isRef(u)?u.value:u;return l}function i(){const l={pageType:r,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return t.onMounted(()=>{i()}),t.onUnmounted(()=>{o()}),e&&t.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function Zr(r){const e=r.toLowerCase().split("+");return{key:e.pop()||"",meta:e.includes("cmd")||e.includes("meta")||e.includes("command"),ctrl:e.includes("ctrl")||e.includes("control"),shift:e.includes("shift"),alt:e.includes("alt")||e.includes("option")}}function Yr(r,e){const n=r.key.toLowerCase(),o=e.meta?r.metaKey:!r.metaKey,s=e.ctrl?r.ctrlKey:!r.ctrlKey,a=e.shift?r.shiftKey:!r.shiftKey,i=e.alt?r.altKey:!r.altKey;let l=o&&s&&a&&i;return(e.meta&&!e.ctrl||!e.meta&&e.ctrl)&&(l=(r.metaKey||r.ctrlKey)&&a&&i),n===e.key&&l}function jn(r){const{onToggle:e,enabled:n=!0}=r,o=t.ref(!1),s=r.shortcut!==void 0?r.shortcut:Se("keyboardShortcut")??"cmd+g";if(s===null)return{isActive:o};const a=Zr(s);function i(l){if(!n)return;const d=l.target,u=d.tagName==="INPUT"||d.tagName==="TEXTAREA",p=d.isContentEditable,g=d.closest("[data-ai-input]");if(!((u||p)&&!g)&&Yr(l,a)){l.preventDefault(),l.stopPropagation();const x=q();if(x!=null&&x.canToggle&&!x.canToggle())return;o.value=!o.value,e()}}return t.onMounted(()=>{window.addEventListener("keydown",i,!0)}),t.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:o}}function Xr(r){return jn({onToggle:()=>{r.value=!r.value}})}function Jr(r,e){const n=t.ref(J("loadingText"));let o=[];function s(){return[J("loadingText"),J("analyzingText"),J("craftingText")]}function a(){return[0,2e3,5e3]}function i(){o.forEach(u=>clearTimeout(u)),o=[]}function l(){i();const u=e==null?void 0:e(),p=(u==null?void 0:u.messages)??s();n.value=p[0]||J("loadingText")}function d(){i();const u=e==null?void 0:e(),p=(u==null?void 0:u.messages)??s(),g=(u==null?void 0:u.intervals)??a();n.value=p[0]||J("loadingText");let x=0;for(let y=1;y<p.length;y++){x+=g[y]||2e3;const f=y,E=window.setTimeout(()=>{r()&&(n.value=p[f])},x);o.push(E)}}return t.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:d,resetLoadingText:l,clearLoadingTextTimers:i}}function es(r){const{getHistoryLength:e,getStoreLimit:n,getConfig:o,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=r,l=t.ref({showWarning:!1,isReached:!1,pendingMessage:null}),d=t.computed(()=>{var C;return((C=o())==null?void 0:C.limit)??n()}),u=t.computed(()=>{var C;return((C=o())==null?void 0:C.showWarningAt)??d.value-2}),p=t.computed(()=>Math.max(0,d.value-e())),g=t.computed(()=>p.value<=d.value-u.value&&p.value>0),x=t.computed(()=>p.value===0),y=t.computed(()=>{var C,w;return l.value.isReached?((C=s())==null?void 0:C.historyLimitReachedTitle)??"Chat Limit Reached":((w=s())==null?void 0:w.historyLimitWarningTitle)??"Approaching Chat Limit"}),f=t.computed(()=>{var C,w,$,z;return l.value.isReached?((C=o())==null?void 0:C.limitMessage)??((w=s())==null?void 0:w.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":(($=o())==null?void 0:$.warningMessage)??((z=s())==null?void 0:z.historyLimitWarningMessage)??`You have ${p.value} message${p.value===1?"":"s"} remaining in this conversation.`});function E(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function h(){l.value.showWarning=!1;const C=o();if(C!=null&&C.onLimitReached&&!await C.onLimitReached())return l.value.isReached=!1,null;if(a(),i(),l.value.isReached=!1,l.value.pendingMessage){const w=l.value.pendingMessage;return l.value.pendingMessage=null,w}return null}function m(){return x.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(g.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function b(C){l.value.pendingMessage=C}return{showHistoryLimitWarning:t.computed(()=>l.value.showWarning),historyLimitReached:t.computed(()=>l.value.isReached),historyLimit:d,remainingMessages:p,historyLimitDialogTitle:y,historyLimitDialogMessage:f,dismissHistoryLimitWarning:E,handleHistoryLimitAction:h,checkHistoryLimit:m,setPendingMessage:b}}function ts(){const r=Ae(),e=t.ref([]),n=t.ref(!1),o=t.ref(0),s=Se("maxAttachments")||5,a=Se("maxFileSize")||10*1024*1024,i=Se("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=t.computed(()=>e.value.length>0),d=t.computed(()=>e.value.some(S=>S.uploading)),u=t.computed(()=>e.value.length<s);function p(S){return(S.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(S.name)}function g(S){if(S==null)return"";const T=typeof S=="string"?parseInt(S,10):S;return Number.isNaN(T)?"":T>=1024*1024?`${(T/(1024*1024)).toFixed(1)} MB`:T>=1024?`${Math.round(T/1024)} KB`:`${T} B`}function x(S){var fe;const T=crypto.randomUUID(),N=S.type.startsWith("image/")?URL.createObjectURL(S):void 0,D=q(),M=!!((fe=D==null?void 0:D.endpoints)!=null&&fe.uploadFile),Q={id:T,name:S.name,type:S.type,size:S.size,uploading:M,progress:M?0:100,previewUrl:N};e.value.push(Q),M&&y(S,T)}async function y(S,T){try{const N=await r.uploadFile(S),D=e.value.findIndex(M=>M.id===T);if(D===-1)return;if(N){const M=e.value[D].previewUrl;e.value[D]={...e.value[D],id:N.id||T,url:N.url,extractedText:N.extractedText,uploading:!1,progress:100,previewUrl:M||N.previewUrl}}else f(T)}catch{f(T)}}function f(S){const T=e.value.findIndex(D=>D.id===S);if(T===-1)return;const[N]=e.value.splice(T,1);N!=null&&N.previewUrl&&URL.revokeObjectURL(N.previewUrl)}function E(){e.value.forEach(S=>{S.previewUrl&&URL.revokeObjectURL(S.previewUrl)}),e.value=[]}function h(){return e.value.filter(S=>!S.uploading).map(S=>({id:S.id,name:S.name,url:S.url,type:S.type,size:S.size}))}function m(S){if(!S)return;const T=Array.from(S);for(const N of T){if(e.value.length>=s)break;N.size>a||x(N)}}function b(S){var T;return Array.from(((T=S.dataTransfer)==null?void 0:T.types)||[]).includes("Files")}function C(S){b(S)&&(o.value+=1,n.value=!0)}function w(S){b(S)||S.preventDefault()}function $(S){b(S)&&(o.value=Math.max(0,o.value-1),o.value===0&&(n.value=!1))}function z(S){var T;b(S)&&(o.value=0,n.value=!1,m(((T=S.dataTransfer)==null?void 0:T.files)||null))}function F(S){const T=S.target,N=T.files;N&&N.length&&m(N),T.value=""}return t.onBeforeUnmount(()=>{E()}),{attachments:e,isDraggingFiles:n,hasAttachments:l,isUploading:d,canAddMore:u,acceptedFileTypes:i,isImage:p,formatFileSize:g,removeAttachment:f,clearAttachments:E,buildPayload:h,processFiles:m,handleFileSelect:F,handleDragEnter:C,handleDragOver:w,handleDragLeave:$,handleDrop:z}}function ns(r,e,n){const o=t.ref(!1),s=t.ref([]),a=t.ref(0),i=t.ref({inMention:!1,query:"",startPos:0}),l=t.ref([]),d=t.computed(()=>{const E=q();return(E==null?void 0:E.mentionProviders)||[]});function u(E){const h=n();if(!h)return;const m=h.selectionStart,b=cn(E,m);i.value=b,b.inMention&&b.query.length>=0?p(b.query):(o.value=!1,s.value=[])}async function p(E){const h=pn();if(h.length===0){o.value=!1;return}const m=[];for(const b of h)try{const C=await b.search(E);m.push(...C.map(w=>({...w,type:b.type})))}catch(C){console.warn(`Mention provider ${b.type} failed:`,C)}s.value=m.slice(0,10),o.value=m.length>0,a.value=0}function g(E){const{startPos:h}=i.value,m=r(),b=n(),C=m.slice(0,h),w=m.slice((b==null?void 0:b.selectionStart)||h),$=E.name||E.label||E.title||E.id;e(`${C}@${$} ${w}`),l.value.push({id:E.id,name:$,type:E.type,metadata:E.attributes}),o.value=!1,s.value=[],setTimeout(()=>{const z=n();z==null||z.focus();const F=C.length+$.length+2;z==null||z.setSelectionRange(F,F)},0)}function x(E){if(!o.value||s.value.length===0)return!1;if(E.key==="ArrowDown")return E.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(E.key==="ArrowUp")return E.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(E.key==="Enter"||E.key==="Tab"){E.preventDefault();const h=s.value[a.value];return h&&g(h),!0}return E.key==="Escape"?(E.preventDefault(),o.value=!1,!0):!1}function y(){l.value=[]}function f(){return[...l.value]}return{showMentions:o,mentionItems:s,selectedMentionIndex:a,mentionProviders:d,checkForMentions:u,handleMentionSelect:g,handleMentionKeyDown:x,clearMentions:y,getMentions:f}}function os(r,e,n,o,s){const a=t.ref(!1),i=t.ref(-1),l=t.ref(null);function d(){setTimeout(()=>{const y=l.value;if(!y)return;const f=y.querySelector(`li:nth-child(${i.value+1})`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function u(y){const f=r();if(!a.value||f.length===0)return!1;if(y.key==="ArrowDown")return y.preventDefault(),i.value=Math.min(i.value+1,f.length-1),d(),!0;if(y.key==="ArrowUp")return y.preventDefault(),i.value=Math.max(i.value-1,0),d(),!0;if(y.key==="Enter"&&i.value>=0){y.preventDefault();const E=f[i.value];return E&&p(E),!0}return y.key==="Escape"?(y.preventDefault(),a.value=!1,i.value=-1,!0):!1}function p(y){s(y),a.value=!1,i.value=-1}function g(){const y=o(),f=e(),E=n(),h=r();y&&!f&&E&&h.length>0?a.value=!0:a.value=!1}function x(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:u,handleSuggestionClick:p,updateSuggestionsVisibility:g,hideSuggestions:x}}function rs(r,e=300){function n(){const o=r();if(!o)return;o.style.height="auto";const s=Math.min(o.scrollHeight,e);o.style.height=`${s}px`,o.style.overflowY=o.scrollHeight>e?"auto":"hidden"}return t.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const Wn=t.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(r){return(e,n)=>{var o;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["w-6 h-6 min-w-[24px] flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-600",(o=r.ui)==null?void 0:o.container])},[t.renderSlot(e.$slots,"default",{},()=>{var s;return[(t.openBlock(),t.createElementBlock("svg",{class:t.normalizeClass(["w-4 h-4 text-gray-400 dark:text-gray-500",(s=r.ui)==null?void 0:s.icon]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...n[0]||(n[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))]})],2)}}}),ss=t.defineComponent({__name:"UserAvatar",props:{ui:{}},setup(r){return(e,n)=>{var o;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(o=r.ui)==null?void 0:o.container])},[t.renderSlot(e.$slots,"default",{},()=>{var s;return[(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:t.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},[...n[0]||(n[0]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])],2))]})],2)}}}),as=["onClick","onMouseenter"],Gn=t.defineComponent({__name:"MentionList",props:{items:{},selectedIndex:{default:0},providers:{default:()=>[]},ui:{},texts:{}},emits:["select","update:selectedIndex"],setup(r,{emit:e}){const n=r,o=t.computed(()=>n.ui||{}),s=e,a=t.ref(n.selectedIndex);t.watch(()=>n.selectedIndex,h=>{a.value=h}),t.watch(a,h=>{s("update:selectedIndex",h)});const i=t.computed(()=>{const h={};return n.items.forEach(m=>{const b=m.type||"default";h[b]||(h[b]=[]),h[b].push(m)}),h});function l(h){return n.providers.find(m=>m.type===h)||dn(h)}function d(h){const m=l(h);return(m==null?void 0:m.label)||h.charAt(0).toUpperCase()+h.slice(1)+"s"}function u(h,m){let b=0;const C=Object.keys(i.value);for(const w of C){if(w===h)return b+m;b+=i.value[w].length}return b}function p(h){s("select",h)}function g(h){a.value=h,s("update:selectedIndex",h)}function x(h){const m=l(h.type);return At(h,m)}function y(h){const m=l(h.type);return un(h,m)}function f(h){const m={employee:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",job:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",candidate:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",project:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400",default:"bg-primary/10 text-primary"};return m[h]||m.default}function E(h){return h.split(" ").map(m=>m[0]).join("").slice(0,2).toUpperCase()}return(h,m)=>r.items.length>0?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-60 overflow-y-auto z-50",o.value.root])},[t.createElementVNode("div",{class:t.normalizeClass(["p-2",o.value.container])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value,(b,C)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:C},[Object.keys(i.value).length>1?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",o.value.groupHeader])},t.toDisplayString(d(C)),3)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(b,(w,$)=>(t.openBlock(),t.createElementBlock("button",{key:w.id,type:"button",class:t.normalizeClass(["w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors mb-0.5",[o.value.item,{[o.value.itemSelected||"bg-primary/10"]:u(C,$)===a.value,"hover:bg-gray-50 dark:hover:bg-gray-700":u(C,$)!==a.value}]]),onClick:z=>p(w),onMouseenter:z=>g(u(C,$))},[t.renderSlot(h.$slots,"item-icon",{item:w,type:C},()=>[t.createElementVNode("span",{class:t.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[o.value.itemIcon,f(w.type)]])},t.toDisplayString(E(x(w))),3)]),t.createElementVNode("div",{class:t.normalizeClass(["flex-1 min-w-0",o.value.itemContent])},[t.createElementVNode("p",{class:t.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",o.value.itemName])},t.toDisplayString(x(w)),3),y(w)?(t.openBlock(),t.createElementBlock("p",{key:0,class:t.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",o.value.itemSubtitle])},t.toDisplayString(y(w)),3)):t.createCommentVNode("",!0)],2)],42,as))),128))],64))),128))],2)],2)):t.createCommentVNode("",!0)}}),is=["title"],ls={key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Kn=t.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(r,{emit:e}){const n=r,o=e,s=d=>{var p;return(p=n.texts)!=null&&p[d]?n.texts[d]:J({copyToClipboard:"copyToClipboard",copied:"copied"}[d])},a=t.computed(()=>n.ui||{}),i=t.ref(!1);async function l(){try{await navigator.clipboard.writeText(n.message.message),i.value=!0,o("copy",n.message),setTimeout(()=>{i.value=!1},2e3)}catch(d){console.error("Failed to copy:",d)}}return(d,u)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",a.value.container])},[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",[a.value.button,a.value.copyButton]]),title:i.value?s("copied"):s("copyToClipboard"),onClick:l},[i.value?(t.openBlock(),t.createElementBlock("svg",{key:1,class:t.normalizeClass(["w-4 h-4 text-green-500",a.value.successState]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[...u[1]||(u[1]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])],2)):(t.openBlock(),t.createElementBlock("svg",ls,[...u[0]||(u[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M15.666 3.888A2.25 2.25 0 0013.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 01-.75.75H9a.75.75 0 01-.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 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"},null,-1)])]))],10,is)],2))}}),cs={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},us=["src"],ds={key:1,class:"w-5 h-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ps={class:"flex-1 min-w-0"},fs={class:"text-sm font-semibold text-white truncate"},ms={class:"text-xs text-white/70"},hs={key:0,class:"text-xs font-medium text-white/90"},gs=["src"],ys={key:1,class:"h-4 w-4 text-white",viewBox:"0 0 24 24",fill:"currentColor"},ks={class:"flex-shrink-0 mt-0.5"},xs={class:"text-gray-600 dark:text-gray-400"},ws=["id","innerHTML"],bs={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white dark:bg-gray-800 overflow-hidden border border-gray-200 dark:border-gray-600"},Es=["src"],Cs={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ss={class:"flex-1 min-w-0"},Ts={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},As={class:"text-xs text-gray-500 dark:text-gray-400"},Ms={key:0,class:"text-xs font-medium text-primary"},Ns=t.defineComponent({__name:"ChatMessage",props:{message:{},showActions:{type:Boolean,default:!0},loadingText:{default:"Gathering data..."},ui:{},texts:{}},emits:["copy"],setup(r,{emit:e}){const n=r,o=e,s=m=>{var C;return(C=n.texts)!=null&&C[m]?n.texts[m]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[m]||m},a=t.computed(()=>n.ui||{}),{parseMarkdown:i}=Un(),l=t.ref(!1),d=t.computed(()=>n.message.attachments??[]),u=t.computed(()=>d.value.length>0),p=t.computed(()=>{if(n.message.role!=="user")return!1;const m=n.message.message||"",b=m.split(`
59
- `).length;return m.length>200||b>4});function g(){l.value=!l.value}function x(m){return(m.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(m.name||"")}const y=t.computed(()=>{const m=q();return m!=null&&m.userAvatar?typeof m.userAvatar=="string"?m.userAvatar:typeof m.userAvatar=="function"?m.userAvatar():null:null});function f(m){if(m==null)return"";const b=typeof m=="string"?parseInt(m,10):m;return Number.isNaN(b)?"":b>=1024*1024?`${(b/(1024*1024)).toFixed(1)} MB`:b>=1024?`${Math.round(b/1024)} KB`:`${b} B`}const E=t.computed(()=>{if(n.message.role==="assistant"){let m=n.message.message;return m=m.replace(/\\n/g,`
60
- `),i(m)}return n.message.message});function h(m){o("copy",m)}return(m,b)=>{var C;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[a.value.root,{"flex justify-end":r.message.role==="user","flex justify-start":r.message.role==="assistant"}]])},[r.message.role==="user"?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["flex gap-3 justify-end",a.value.userMessage])},[t.createElementVNode("div",{class:t.normalizeClass(["rounded-2xl px-4 py-3 bg-primary text-white max-w-fit",a.value.userBubble])},[r.message.message?(t.openBlock(),t.createElementBlock("p",{key:0,class:t.normalizeClass(["text-sm whitespace-pre-wrap",[a.value.content,{"line-clamp-4":!l.value&&p.value}]])},t.toDisplayString(r.message.message),3)):t.createCommentVNode("",!0),p.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:t.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",a.value.showMoreButton]),onClick:g},t.toDisplayString(l.value?s("showLess"):s("showMore")),3)):t.createCommentVNode("",!0),u.value?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["mt-3 space-y-2",a.value.attachmentsContainer])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,w=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:t.normalizeClass(["flex items-center gap-3 rounded-xl border border-white/20 bg-white/10 p-2 transition",[a.value.attachmentItem,w.url?"hover:bg-white/20 cursor-pointer":""]])},{default:t.withCtx(()=>[t.createElementVNode("div",cs,[w.url&&x(w)?(t.openBlock(),t.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,us)):(t.openBlock(),t.createElementBlock("svg",ds,[...b[0]||(b[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),t.createElementVNode("div",ps,[t.createElementVNode("p",fs,t.toDisplayString(w.name||s("attachment")),1),t.createElementVNode("p",ms,t.toDisplayString(f(w.size)),1)]),w.url?(t.openBlock(),t.createElementBlock("span",hs,t.toDisplayString(s("openAttachment")),1)):t.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):t.createCommentVNode("",!0)],2),t.createElementVNode("div",{class:t.normalizeClass(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary overflow-hidden",a.value.userAvatar])},[y.value?(t.openBlock(),t.createElementBlock("img",{key:0,src:y.value,alt:"User",class:"h-full w-full object-cover"},null,8,gs)):(t.openBlock(),t.createElementBlock("svg",ys,[...b[1]||(b[1]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])]))],2)],2)):(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["flex items-start gap-3",a.value.assistantMessage])},[t.createElementVNode("div",ks,[t.createVNode(Wn)]),t.createElementVNode("div",{class:t.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-5 py-4 shadow-sm rounded-2xl transition-all duration-200 flex-1",a.value.assistantBubble])},[r.message.loading?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",a.value.loadingIndicator])},[t.createElementVNode("div",{class:t.normalizeClass(["flex space-x-1",a.value.loadingDots])},[...b[2]||(b[2]=[t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"0ms"}},null,-1),t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"150ms"}},null,-1),t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"300ms"}},null,-1)])],2),t.createElementVNode("span",xs,t.toDisplayString(((C=r.texts)==null?void 0:C.loadingText)||r.loadingText),1)],2)):r.message.message?(t.openBlock(),t.createElementBlock("div",{key:1,id:r.message.id,class:t.normalizeClass(["prose prose-sm max-w-none prose-gray dark:prose-invert",a.value.content]),innerHTML:E.value},null,10,ws)):t.createCommentVNode("",!0),!r.message.loading&&u.value?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["mt-4 space-y-2",a.value.attachmentsContainer])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,w=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:t.normalizeClass(["flex items-center gap-3 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 p-3 transition",[a.value.attachmentItem,w.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:t.withCtx(()=>[t.createElementVNode("div",bs,[w.url&&x(w)?(t.openBlock(),t.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,Es)):(t.openBlock(),t.createElementBlock("svg",Cs,[...b[3]||(b[3]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),t.createElementVNode("div",Ss,[t.createElementVNode("p",Ts,t.toDisplayString(w.name||s("attachment")),1),t.createElementVNode("p",As,t.toDisplayString(f(w.size)),1)]),w.url?(t.openBlock(),t.createElementBlock("span",Ms,t.toDisplayString(s("openAttachment")),1)):t.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):t.createCommentVNode("",!0)],2)],2)),r.message.role==="assistant"&&!r.message.loading&&!r.message.streaming&&r.showActions?(t.openBlock(),t.createBlock(Kn,{key:2,message:r.message,class:t.normalizeClass(["absolute -bottom-8 left-14",a.value.actionsContainer]),onCopy:h},null,8,["message","class"])):t.createCommentVNode("",!0)],2)}}}),Qn=(r,e)=>{const n=r.__vccOpts||r;for(const[o,s]of e)n[o]=s;return n},Zn=Qn(Ns,[["__scopeId","data-v-df348786"]]),Rs={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},Bs={class:"space-y-2"},Ls=["src"],Ds={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Is={class:"flex-1 min-w-0"},$s={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},zs={class:"text-xs text-gray-500 dark:text-gray-400"},_s={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Os={key:0,class:"text-xs text-gray-400"},Ps=["disabled","onClick"],Vs=t.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(r){return(e,n)=>{var o;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",r.ui.attachmentsContainer])},[t.createElementVNode("p",Rs,t.toDisplayString(((o=r.texts)==null?void 0:o.attachedFiles)||"Attached files"),1),t.createElementVNode("ul",Bs,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.attachments,s=>(t.openBlock(),t.createElementBlock("li",{key:s.id,class:t.normalizeClass(["flex items-center gap-3 rounded-xl bg-white dark:bg-gray-700 p-2 shadow-sm border border-gray-100 dark:border-gray-600",r.ui.attachmentItem])},[t.createElementVNode("div",{class:t.normalizeClass(["h-10 w-10 flex items-center justify-center rounded-lg bg-gray-100 dark:bg-gray-600 overflow-hidden",r.ui.attachmentThumbnail])},[r.isImage(s)?(t.openBlock(),t.createElementBlock("img",{key:0,src:s.previewUrl||s.url,class:"object-cover h-full w-full",alt:""},null,8,Ls)):(t.openBlock(),t.createElementBlock("svg",Ds,[...n[0]||(n[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))],2),t.createElementVNode("div",Is,[t.createElementVNode("p",$s,t.toDisplayString(s.name),1),t.createElementVNode("p",zs,t.toDisplayString(r.formatFileSize(s.size)),1),s.uploading?(t.openBlock(),t.createElementBlock("div",_s,[t.createElementVNode("div",{class:"h-full bg-primary transition-all",style:t.normalizeStyle({width:`${s.progress??10}%`})},null,4)])):t.createCommentVNode("",!0)]),s.uploading?(t.openBlock(),t.createElementBlock("span",Os,t.toDisplayString(Math.round(s.progress??0))+"% ",1)):t.createCommentVNode("",!0),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",r.ui.attachmentRemove]),disabled:s.uploading,onClick:a=>e.$emit("remove",s.id)},[...n[1]||(n[1]=[t.createElementVNode("svg",{class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,Ps)],2))),128))])],2)}}}),Fs={class:"py-1"},Hs=["onClick","onMouseenter"],Us={class:"flex items-start gap-3"},qs={class:"flex-1 min-w-0"},vs={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},js={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Ws=t.defineComponent({__name:"SuggestionsDropdown",props:{suggestions:{},selectedIndex:{},ui:{}},emits:["select","hover"],setup(r,{expose:e}){const n=t.ref(null);return e({dropdownRef:n}),(o,s)=>(t.openBlock(),t.createBlock(t.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:t.withCtx(()=>[t.createElementVNode("div",{ref_key:"dropdownRef",ref:n,class:t.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-80 overflow-y-auto z-10",r.ui.suggestionsDropdown])},[t.createElementVNode("ul",Fs,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.suggestions,(a,i)=>(t.openBlock(),t.createElementBlock("li",{key:a.id,class:t.normalizeClass(["px-4 py-3 cursor-pointer transition-colors border-b border-gray-100 dark:border-gray-700 last:border-b-0",[r.ui.suggestionItem,{[r.ui.suggestionItemSelected||"bg-primary/10"]:i===r.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":i!==r.selectedIndex}]]),onClick:l=>o.$emit("select",a),onMouseenter:l=>o.$emit("hover",i)},[t.createElementVNode("div",Us,[t.createElementVNode("div",qs,[t.createElementVNode("p",vs,t.toDisplayString(a.title),1),t.createElementVNode("p",js,t.toDisplayString(a.description),1)])])],42,Hs))),128))])],2)]),_:1}))}}),Gs={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},Ks=["title"],Qs=["title"],Zs=["disabled"],Ys={key:0,class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Xs={key:1,class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},Js=t.defineComponent({__name:"InputActions",props:{sending:{type:Boolean},canSend:{type:Boolean},supportRequestMode:{type:Boolean},showSupportModeToggle:{type:Boolean},ui:{},texts:{}},emits:["toggle-support-mode","click"],setup(r){const e=r,n=t.computed(()=>e.sending?[e.ui.stopButton||"bg-red-500 text-white hover:bg-red-600"]:e.canSend?[e.ui.sendButtonActive||"bg-primary text-white hover:bg-primary/90"]:[e.ui.sendButtonDisabled||"bg-gray-200 dark:bg-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed opacity-60"]);return(o,s)=>{var a,i,l;return t.openBlock(),t.createElementBlock("div",Gs,[r.showSupportModeToggle&&!r.supportRequestMode?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center text-gray-400 hover:text-primary hover:bg-gray-100 dark:hover:bg-gray-700 transition flex-shrink-0",r.ui.supportToggle]),title:((a=r.texts)==null?void 0:a.toggleSupportMode)||"Toggle support mode",onClick:s[0]||(s[0]=d=>o.$emit("toggle-support-mode"))},[...s[3]||(s[3]=[t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",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 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)])],10,Ks)):t.createCommentVNode("",!0),r.showSupportModeToggle&&r.supportRequestMode?(t.openBlock(),t.createElementBlock("button",{key:1,type:"button",class:t.normalizeClass(["h-7 px-2 rounded-lg flex items-center gap-1 text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 hover:bg-amber-200 dark:hover:bg-amber-900/50 transition flex-shrink-0",r.ui.supportBadge]),title:((i=r.texts)==null?void 0:i.exitSupportMode)||"Exit support mode",onClick:s[1]||(s[1]=d=>o.$emit("toggle-support-mode"))},[s[4]||(s[4]=t.createElementVNode("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",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 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(((l=r.texts)==null?void 0:l.supportLabel)||"Support"),1),s[5]||(s[5]=t.createElementVNode("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1))],10,Qs)):t.createCommentVNode("",!0),t.createElementVNode("button",{disabled:!r.canSend&&!r.sending,class:t.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center transition-all duration-200 flex-shrink-0",n.value]),type:"button",onClick:s[2]||(s[2]=t.withModifiers(d=>o.$emit("click"),["prevent"]))},[r.sending?(t.openBlock(),t.createElementBlock("svg",Xs,[...s[7]||(s[7]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.5 7.5a3 3 0 013-3h9a3 3 0 013 3v9a3 3 0 01-3 3h-9a3 3 0 01-3-3v-9z","clip-rule":"evenodd"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",Ys,[...s[6]||(s[6]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"},null,-1)])]))],10,Zs)])}}}),ea={class:"max-w-3xl mx-auto space-y-3"},ta=["accept"],na=["title"],oa={class:"flex items-center"},ra=["placeholder","disabled"],sa={key:0,class:"flex justify-center"},Yn=t.defineComponent({__name:"ChatInput",props:{modelValue:{},disabled:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},placeholder:{default:"Ask me anything..."},supportPlaceholder:{default:"Describe your support request..."},minLength:{default:3},suggestions:{default:()=>[]},hasHistory:{type:Boolean,default:!1},supportRequestMode:{type:Boolean,default:!1},showSupportModeToggle:{type:Boolean,default:!1},contextLinkText:{default:""},ui:{},texts:{}},emits:["update:modelValue","submit","cancel","suggestion-select","toggle-support-mode","context-link-click"],setup(r,{emit:e}){const n=r,o=t.computed(()=>n.ui||{}),s=e,a=t.ref(n.modelValue),i=t.ref(null),l=t.ref(null),d=t.ref(!1),u=ts(),p=ns(()=>a.value,T=>{a.value=T},()=>i.value),g=os(()=>n.suggestions,()=>n.hasHistory,()=>d.value,()=>a.value,T=>{s("suggestion-select",T),t.nextTick(()=>{var N;return(N=i.value)==null?void 0:N.focus()})}),{adjustTextareaHeight:x}=rs(()=>i.value),y=t.computed(()=>n.supportRequestMode?n.supportPlaceholder:n.placeholder),f=t.computed(()=>n.showSupportModeToggle?n.supportRequestMode?"pr-32":"pr-24":"pr-14"),E=t.computed(()=>{var N;return(((N=a.value)==null?void 0:N.trim())??"").length>=n.minLength?!0:u.hasAttachments.value}),h=t.computed(()=>!n.disabled&&!n.sending&&E.value&&!u.isUploading.value);t.watch(()=>n.modelValue,T=>{a.value=T,t.nextTick(x)}),t.watch(a,T=>{s("update:modelValue",T),t.nextTick(x),p.checkForMentions(T),g.updateSuggestionsVisibility()}),t.watch(()=>n.suggestions,()=>{g.updateSuggestionsVisibility()});function m(){x()}function b(T){if(!p.handleMentionKeyDown(T)&&!g.handleSuggestionKeyDown(T)&&T.key==="Enter"){if(T.shiftKey)return;!n.sending&&h.value&&(T.preventDefault(),C())}}function C(){if(!h.value)return;const T=u.buildPayload(),N=a.value.trim(),D=p.getMentions();s("submit",{message:N,attachments:T,mentions:D,isSupportRequest:n.supportRequestMode}),a.value="",u.clearAttachments(),p.clearMentions(),t.nextTick(x)}function w(){n.sending?s("cancel"):h.value&&C()}function $(){var T;n.disabled||n.sending||u.canAddMore.value&&((T=l.value)==null||T.click())}function z(T){g.handleSuggestionClick(T)}function F(){d.value=!0,g.updateSuggestionsVisibility()}function S(){d.value=!1,setTimeout(()=>{g.hideSuggestions(),p.showMentions.value=!1},200)}return t.onMounted(()=>{t.nextTick(x)}),(T,N)=>{var D;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",o.value.root]),onDragenter:N[6]||(N[6]=t.withModifiers((...M)=>t.unref(u).handleDragEnter&&t.unref(u).handleDragEnter(...M),["prevent"])),onDragover:N[7]||(N[7]=t.withModifiers((...M)=>t.unref(u).handleDragOver&&t.unref(u).handleDragOver(...M),["prevent"])),onDragleave:N[8]||(N[8]=t.withModifiers((...M)=>t.unref(u).handleDragLeave&&t.unref(u).handleDragLeave(...M),["prevent"])),onDrop:N[9]||(N[9]=t.withModifiers((...M)=>t.unref(u).handleDrop&&t.unref(u).handleDrop(...M),["prevent"]))},[t.createElementVNode("form",{onSubmit:t.withModifiers(C,["prevent"]),class:t.normalizeClass(o.value.form)},[t.createElementVNode("div",ea,[t.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:t.unref(u).acceptedFileTypes,onChange:N[0]||(N[0]=(...M)=>t.unref(u).handleFileSelect&&t.unref(u).handleFileSelect(...M))},null,40,ta),t.unref(u).hasAttachments.value?(t.openBlock(),t.createBlock(Vs,{key:0,attachments:t.unref(u).attachments.value,ui:o.value,texts:r.texts,"is-image":t.unref(u).isImage,"format-file-size":t.unref(u).formatFileSize,onRemove:t.unref(u).removeAttachment},null,8,["attachments","ui","texts","is-image","format-file-size","onRemove"])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["relative",o.value.inputContainer])},[t.unref(g).showSuggestions.value&&r.suggestions.length>0?(t.openBlock(),t.createBlock(Ws,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:r.suggestions,"selected-index":t.unref(g).selectedSuggestionIndex.value,ui:o.value,onSelect:z,onHover:N[1]||(N[1]=M=>t.unref(g).selectedSuggestionIndex.value=M)},null,8,["suggestions","selected-index","ui"])):t.createCommentVNode("",!0),t.createVNode(t.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:t.withCtx(()=>[t.unref(p).showMentions.value&&t.unref(p).mentionItems.value.length>0?(t.openBlock(),t.createBlock(Gn,{key:0,items:t.unref(p).mentionItems.value,"selected-index":t.unref(p).selectedMentionIndex.value,providers:t.unref(p).mentionProviders.value,onSelect:t.unref(p).handleMentionSelect,"onUpdate:selectedIndex":N[2]||(N[2]=M=>t.unref(p).selectedMentionIndex.value=M)},null,8,["items","selected-index","providers","onSelect"])):t.createCommentVNode("",!0)]),_:1}),t.createElementVNode("div",{class:t.normalizeClass(["rounded-2xl border shadow-lg transition-all duration-200 bg-white dark:bg-gray-800",[o.value.inputWrapper,{"border-primary shadow-primary/30":d.value||t.unref(u).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!d.value&&!t.unref(u).isDraggingFiles.value}]])},[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["absolute left-3 top-1/2 -translate-y-1/2 h-9 w-9 rounded-xl flex items-center justify-center text-gray-500 dark:text-gray-400 hover:text-primary transition z-10",o.value.attachButton]),title:((D=r.texts)==null?void 0:D.attachFiles)||"Attach files",onClick:$},[...N[10]||(N[10]=[t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M18.375 12.739l-7.693 7.693a4.5 4.5 0 01-6.364-6.364l10.94-10.94A3 3 0 1119.5 7.372L8.552 18.32m.009-.01l-.01.01m5.699-9.941l-7.81 7.81a1.5 1.5 0 002.112 2.13"})],-1)])],10,na),t.createElementVNode("div",oa,[t.withDirectives(t.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":N[3]||(N[3]=M=>a.value=M),rows:"1","data-ai-input":"",placeholder:y.value,disabled:r.disabled,class:t.normalizeClass(["block w-full bg-transparent py-3 text-sm leading-5 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 dark:placeholder:text-gray-500 border-0 focus:outline-none focus-visible:outline-none resize-none pl-12",[o.value.textarea,f.value]]),onInput:m,onKeydown:b,onFocus:F,onBlur:S},null,42,ra),[[t.vModelText,a.value]])]),t.createVNode(Js,{sending:r.sending,"can-send":h.value,"support-request-mode":r.supportRequestMode,"show-support-mode-toggle":r.showSupportModeToggle,ui:o.value,texts:r.texts,onToggleSupportMode:N[4]||(N[4]=M=>T.$emit("toggle-support-mode")),onClick:w},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),t.renderSlot(T.$slots,"context-link",{},()=>[r.contextLinkText?(t.openBlock(),t.createElementBlock("div",sa,[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",o.value.contextLink]),onClick:N[5]||(N[5]=M=>T.$emit("context-link-click"))},t.toDisplayString(r.contextLinkText),3)])):t.createCommentVNode("",!0)])])],34)],34)}}}),aa=["onClick"],Xn=t.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(r,{emit:e}){const n=r,o=e,s=x=>{var f;return(f=n.texts)!=null&&f[x]?n.texts[x]:J({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[x])},a=t.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=jt();function d(x){const y={...x,prompt:l(x)};o("item-click",y)}function u(x){return x.gradientClass?x.gradientClass:x.className?x.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function p(x){const y=x.category||"default",f={hr:"bg-blue-100 dark:bg-blue-900/30",finance:"bg-green-100 dark:bg-green-900/30",analytics:"bg-purple-100 dark:bg-purple-900/30",support:"bg-amber-100 dark:bg-amber-900/30",default:"bg-primary/10"};return f[y]||f.default}function g(x){const y=x.category||"default",f={hr:"text-blue-600 dark:text-blue-400",finance:"text-green-600 dark:text-green-400",analytics:"text-purple-600 dark:text-purple-400",support:"text-amber-600 dark:text-amber-400",default:"text-primary"};return f[y]||f.default}return(x,y)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center justify-center p-4 h-full",a.value.root])},[t.createElementVNode("div",{class:t.normalizeClass(["w-full max-w-4xl",a.value.content])},[t.createElementVNode("div",{class:t.normalizeClass(["mb-8 text-center",a.value.header])},[t.createElementVNode("div",{class:t.normalizeClass(["mb-3 inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary",a.value.badge])},[y[0]||(y[0]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(s("aiName")),1)],2),t.createElementVNode("h1",{class:t.normalizeClass(["mb-3 text-4xl font-bold tracking-tight text-gray-900 dark:text-white",a.value.title])},t.toDisplayString(s("title")),3),t.createElementVNode("p",{class:t.normalizeClass(["text-gray-600 dark:text-gray-400",a.value.description])},t.toDisplayString(s("description")),3)],2),t.createElementVNode("div",{class:t.normalizeClass(["mb-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",a.value.grid])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(i),(f,E)=>(t.openBlock(),t.createElementBlock("button",{key:f.id||E,class:t.normalizeClass(["group relative overflow-hidden rounded-xl border border-gray-300 dark:border-gray-600 p-4 text-left transition-all hover:shadow-md hover:scale-[1.02]",[a.value.suggestionCard,u(f)]]),onClick:h=>d(f)},[t.createElementVNode("div",{class:t.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,p(f)]])},[f.icon?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(f.icon),{key:0,class:t.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,g(f)]])},null,8,["class"])):(t.openBlock(),t.createElementBlock("svg",{key:1,class:t.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,g(f)]]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...y[1]||(y[1]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))],2),t.createElementVNode("h3",{class:t.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",a.value.suggestionTitle])},t.toDisplayString(f.title),3),t.createElementVNode("p",{class:t.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},t.toDisplayString(f.description),3)],10,aa))),128))],2)],2)],2))}}),ia={class:"flex items-center gap-3"},la={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},ca={key:1,class:"flex items-center gap-2"},ua={key:0,class:"flex items-center gap-2 ml-auto mr-3"},da=["title"],pa=["title"],fa=["title"],ma={key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ha={key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ga=t.defineComponent({__name:"DrawerHeader",props:{ui:{},isSetupMode:{type:Boolean},showNewChatButton:{type:Boolean},hasHistory:{type:Boolean},showQuota:{type:Boolean},quota:{},showCloseButton:{type:Boolean},showMinimizeButton:{type:Boolean},showFullscreenToggle:{type:Boolean},isFullscreen:{type:Boolean},t:{type:Function}},emits:["new-chat","close","minimize","toggle-fullscreen"],setup(r){return(e,n)=>{var o,s,a,i,l,d;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center justify-between px-4 sm:px-6 pt-4 border-b border-gray-200 dark:border-gray-700 pb-4",(o=r.ui)==null?void 0:o.header])},[t.createElementVNode("div",ia,[r.isSetupMode?(t.openBlock(),t.createElementBlock("div",ca,[...n[5]||(n[5]=[t.createElementVNode("span",{class:"flex h-2 w-2 rounded-full bg-amber-500 animate-pulse"},null,-1),t.createElementVNode("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Setup Required",-1)])])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[r.showNewChatButton&&r.hasHistory?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 transition-all duration-200 shadow-sm",(s=r.ui)==null?void 0:s.newChatButton]),onClick:n[0]||(n[0]=u=>e.$emit("new-chat"))},[n[4]||(n[4]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(r.t("newChat")),1)],2)):(t.openBlock(),t.createElementBlock("span",la,t.toDisplayString(r.t("keyboardShortcutHint")),1))],64))]),r.showQuota&&!r.isSetupMode?(t.openBlock(),t.createElementBlock("div",ua,[t.renderSlot(e.$slots,"quota",{},()=>{var u,p;return[r.quota.remaining>0?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["text-xs text-green-600 dark:text-green-400",(u=r.ui)==null?void 0:u.quotaDisplay])},t.toDisplayString(r.quota.remaining)+" "+t.toDisplayString(r.t("quotaRemaining")),3)):r.quota.remaining===0?(t.openBlock(),t.createElementBlock("span",{key:1,class:t.normalizeClass(["text-xs text-red-600 dark:text-red-400",(p=r.ui)==null?void 0:p.quotaDisplay])},t.toDisplayString(r.t("noQuota")),3)):t.createCommentVNode("",!0)]})])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["flex items-center gap-1",(a=r.ui)==null?void 0:a.headerActions])},[r.showCloseButton?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(i=r.ui)==null?void 0:i.headerActionButton]),title:r.t("close"),onClick:n[1]||(n[1]=u=>e.$emit("close"))},[...n[6]||(n[6]=[t.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,da)):t.createCommentVNode("",!0),r.showMinimizeButton?(t.openBlock(),t.createElementBlock("button",{key:1,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(l=r.ui)==null?void 0:l.headerActionButton]),title:r.t("minimize"),onClick:n[2]||(n[2]=u=>e.$emit("minimize"))},[...n[7]||(n[7]=[t.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"})],-1)])],10,pa)):t.createCommentVNode("",!0),r.showFullscreenToggle?(t.openBlock(),t.createElementBlock("button",{key:2,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(d=r.ui)==null?void 0:d.headerActionButton]),title:r.isFullscreen?r.t("exitFullscreen"):r.t("fullscreen"),onClick:n[3]||(n[3]=u=>e.$emit("toggle-fullscreen"))},[r.isFullscreen?(t.openBlock(),t.createElementBlock("svg",ha,[...n[9]||(n[9]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",ma,[...n[8]||(n[8]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"},null,-1)])]))],10,fa)):t.createCommentVNode("",!0)],2)],2)}}}),ya={class:"max-w-3xl mx-auto px-4 space-y-6"},ka={class:"flex justify-center"},xa={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},wa={key:0,class:"flex justify-center"},ba=["title"],Ea=t.defineComponent({__name:"DrawerMessageList",props:{messages:{},loadingMessage:{},quota:{},error:{},ui:{},t:{type:Function}},emits:["copy","contact-support","retry"],setup(r){return(e,n)=>{var o,s,a;return t.openBlock(),t.createElementBlock("div",ya,[t.createElementVNode("div",ka,[t.createElementVNode("div",xa,[n[3]||(n[3]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(r.t("title")||t.unref(J)("aiName")),1)])]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.messages,(i,l)=>t.renderSlot(e.$slots,"message",{key:i.id||l,message:i,isUser:i.role==="user",isLoading:i.loading,isStreaming:i.streaming},()=>[t.createVNode(Zn,{message:i,"loading-text":r.loadingMessage,onCopy:n[0]||(n[0]=d=>e.$emit("copy",d))},null,8,["message","loading-text"])])),128)),r.quota.remaining===0?(t.openBlock(),t.createElementBlock("div",wa,[t.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 px-6 py-3 bg-primary text-white rounded-lg hover:bg-primary/90 transition-all shadow-sm",onClick:n[1]||(n[1]=i=>e.$emit("contact-support"))},[n[4]||(n[4]=t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(t.unref(J)("contactSupport")),1)])])):t.createCommentVNode("",!0),r.error.message?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["flex items-center gap-2 text-sm text-red-600 dark:text-red-400 px-2 py-1 pb-6",(o=r.ui)==null?void 0:o.errorContainer])},[t.createElementVNode("span",{class:t.normalizeClass((s=r.ui)==null?void 0:s.errorMessage)},t.toDisplayString(r.error.message),3),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["inline-flex items-center gap-1 text-red-700 dark:text-red-300 hover:text-red-800 dark:hover:text-red-200 font-medium",(a=r.ui)==null?void 0:a.retryButton]),title:r.t("retry"),onClick:n[2]||(n[2]=i=>e.$emit("retry"))},[...n[5]||(n[5]=[t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1)])],10,ba)],2)):t.createCommentVNode("",!0)])}}}),Ca={class:"w-full max-w-md"},Sa={class:"bg-gray-900 rounded-xl overflow-hidden"},Ta={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},Aa=t.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(r){return(e,n)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[n[4]||(n[4]=t.createStaticVNode('<div class="w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"><svg class="w-7 h-7 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"></path></svg></div><h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-1"> Almost there! </h2><p class="text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-sm text-center"> Configure the plugin in your app entry file to start using AI. </p>',3)),t.createElementVNode("div",Ca,[t.createElementVNode("div",Sa,[t.createElementVNode("div",Ta,[n[1]||(n[1]=t.createElementVNode("span",{class:"text-xs text-gray-400"},"main.ts",-1)),t.createElementVNode("button",{type:"button",class:"text-xs text-gray-400 hover:text-white transition-colors",onClick:n[0]||(n[0]=o=>e.$emit("copy"))},t.toDisplayString(r.copied?"✓ Copied":"Copy"),1)]),n[2]||(n[2]=t.createStaticVNode(`<pre class="text-xs text-gray-100 p-4 overflow-x-auto leading-relaxed"><code class="language-typescript"><span class="text-purple-400">import</span> { RestifyAiPlugin } <span class="text-purple-400">from</span> <span class="text-green-400">&#39;@doderasoftware/restify-ai&#39;</span>
54
+ `}tablecell(e){const n=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+n+`</${r}>
55
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${e}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:r}){const s=this.parser.parseInline(r),a=xn(e);if(a===null)return s;e=a;let i='<a href="'+e+'"';return n&&(i+=' title="'+n+'"'),i+=">"+s+"</a>",i}image({href:e,title:n,text:r}){const s=xn(e);if(s===null)return r;e=s;let a=`<img src="${e}" alt="${r}"`;return n&&(a+=` title="${n}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):e.text}}class zt{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class ce{constructor(e){P(this,"options");P(this,"renderer");P(this,"textRenderer");this.options=e||Me,this.options.renderer=this.options.renderer||new lt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new zt}static parse(e,n){return new ce(n).parse(e)}static parseInline(e,n){return new ce(n).parseInline(e)}parse(e,n=!0){let r="";for(let s=0;s<e.length;s++){const a=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=a,d=this.options.extensions.renderers[l.type].call({parser:this},l);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){r+=d||"";continue}}const i=a;switch(i.type){case"space":{r+=this.renderer.space(i);continue}case"hr":{r+=this.renderer.hr(i);continue}case"heading":{r+=this.renderer.heading(i);continue}case"code":{r+=this.renderer.code(i);continue}case"table":{r+=this.renderer.table(i);continue}case"blockquote":{r+=this.renderer.blockquote(i);continue}case"list":{r+=this.renderer.list(i);continue}case"html":{r+=this.renderer.html(i);continue}case"paragraph":{r+=this.renderer.paragraph(i);continue}case"text":{let l=i,d=this.renderer.text(l);for(;s+1<e.length&&e[s+1].type==="text";)l=e[++s],d+=`
56
+ `+this.renderer.text(l);n?r+=this.renderer.paragraph({type:"paragraph",raw:d,text:d,tokens:[{type:"text",raw:d,text:d}]}):r+=d;continue}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}parseInline(e,n){n=n||this.renderer;let r="";for(let s=0;s<e.length;s++){const a=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=l||"";continue}}const i=a;switch(i.type){case"escape":{r+=n.text(i);break}case"html":{r+=n.html(i);break}case"link":{r+=n.link(i);break}case"image":{r+=n.image(i);break}case"strong":{r+=n.strong(i);break}case"em":{r+=n.em(i);break}case"codespan":{r+=n.codespan(i);break}case"br":{r+=n.br(i);break}case"del":{r+=n.del(i);break}case"text":{r+=n.text(i);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}}class Ke{constructor(e){P(this,"options");P(this,"block");this.options=e||Me}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?le.lex:le.lexInline}provideParser(){return this.block?ce.parse:ce.parseInline}}P(Ke,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class wr{constructor(...e){P(this,"defaults",Mt());P(this,"options",this.setOptions);P(this,"parse",this.parseMarkdown(!0));P(this,"parseInline",this.parseMarkdown(!1));P(this,"Parser",ce);P(this,"Renderer",lt);P(this,"TextRenderer",zt);P(this,"Lexer",le);P(this,"Tokenizer",rt);P(this,"Hooks",Ke);this.use(...e)}walkTokens(e,n){var s,a;let r=[];for(const i of e)switch(r=r.concat(n.call(this,i)),i.type){case"table":{const l=i;for(const d of l.header)r=r.concat(this.walkTokens(d.tokens,n));for(const d of l.rows)for(const u of d)r=r.concat(this.walkTokens(u.tokens,n));break}case"list":{const l=i;r=r.concat(this.walkTokens(l.items,n));break}default:{const l=i;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[l.type]?this.defaults.extensions.childTokens[l.type].forEach(d=>{const u=l[d].flat(1/0);r=r.concat(this.walkTokens(u,n))}):l.tokens&&(r=r.concat(this.walkTokens(l.tokens,n)))}}return r}use(...e){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{const s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=n.renderers[a.name];i?n.renderers[a.name]=function(...l){let d=a.renderer.apply(this,l);return d===!1&&(d=i.apply(this,l)),d}:n.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=n[a.level];i?i.unshift(a.tokenizer):n[a.level]=[a.tokenizer],a.start&&(a.level==="block"?n.startBlock?n.startBlock.push(a.start):n.startBlock=[a.start]:a.level==="inline"&&(n.startInline?n.startInline.push(a.start):n.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(n.childTokens[a.name]=a.childTokens)}),s.extensions=n),r.renderer){const a=this.defaults.renderer||new lt(this.defaults);for(const i in r.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const l=i,d=r.renderer[l],u=a[l];a[l]=(...p)=>{let h=d.apply(a,p);return h===!1&&(h=u.apply(a,p)),h||""}}s.renderer=a}if(r.tokenizer){const a=this.defaults.tokenizer||new rt(this.defaults);for(const i in r.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const l=i,d=r.tokenizer[l],u=a[l];a[l]=(...p)=>{let h=d.apply(a,p);return h===!1&&(h=u.apply(a,p)),h}}s.tokenizer=a}if(r.hooks){const a=this.defaults.hooks||new Ke;for(const i in r.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const l=i,d=r.hooks[l],u=a[l];Ke.passThroughHooks.has(i)?a[l]=p=>{if(this.defaults.async)return Promise.resolve(d.call(a,p)).then(x=>u.call(a,x));const h=d.call(a,p);return u.call(a,h)}:a[l]=(...p)=>{let h=d.apply(a,p);return h===!1&&(h=u.apply(a,p)),h}}s.hooks=a}if(r.walkTokens){const a=this.defaults.walkTokens,i=r.walkTokens;s.walkTokens=function(l){let d=[];return d.push(i.call(this,l)),a&&(d=d.concat(a.call(this,l))),d}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return le.lex(e,n??this.defaults)}parser(e,n){return ce.parse(e,n??this.defaults)}parseMarkdown(e){return(r,s)=>{const a={...s},i={...this.defaults,...a},l=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&a.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const d=i.hooks?i.hooks.provideLexer():e?le.lex:le.lexInline,u=i.hooks?i.hooks.provideParser():e?ce.parse:ce.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(r):r).then(p=>d(p,i)).then(p=>i.hooks?i.hooks.processAllTokens(p):p).then(p=>i.walkTokens?Promise.all(this.walkTokens(p,i.walkTokens)).then(()=>p):p).then(p=>u(p,i)).then(p=>i.hooks?i.hooks.postprocess(p):p).catch(l);try{i.hooks&&(r=i.hooks.preprocess(r));let p=d(r,i);i.hooks&&(p=i.hooks.processAllTokens(p)),i.walkTokens&&this.walkTokens(p,i.walkTokens);let h=u(p,i);return i.hooks&&(h=i.hooks.postprocess(h)),h}catch(p){return l(p)}}}onError(e,n){return r=>{if(r.message+=`
57
+ Please report this to https://github.com/markedjs/marked.`,e){const s="<p>An error occurred:</p><pre>"+ie(r.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(r);throw r}}}const Ne=new wr;function _(o,e){return Ne.parse(o,e)}_.options=_.setOptions=function(o){return Ne.setOptions(o),_.defaults=Ne.defaults,hn(_.defaults),_},_.getDefaults=Mt,_.defaults=Me,_.use=function(...o){return Ne.use(...o),_.defaults=Ne.defaults,hn(_.defaults),_},_.walkTokens=function(o,e){return Ne.walkTokens(o,e)},_.parseInline=Ne.parseInline,_.Parser=ce,_.parser=ce.parse,_.Renderer=lt,_.TextRenderer=zt,_.Lexer=le,_.lexer=le.lex,_.Tokenizer=rt,_.Hooks=Ke,_.parse=_,_.options,_.setOptions,_.use,_.walkTokens,_.parseInline,ce.parse,le.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:Bn,setPrototypeOf:Ln,isFrozen:br,getPrototypeOf:Er,getOwnPropertyDescriptor:Cr}=Object;let{freeze:ne,seal:ue,create:$t}=Object,{apply:_t,construct:Ot}=typeof Reflect<"u"&&Reflect;ne||(ne=function(e){return e}),ue||(ue=function(e){return e}),_t||(_t=function(e,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),a=2;a<r;a++)s[a-2]=arguments[a];return e.apply(n,s)}),Ot||(Ot=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new e(...r)});const ct=re(Array.prototype.forEach),Sr=re(Array.prototype.lastIndexOf),Dn=re(Array.prototype.pop),Ge=re(Array.prototype.push),Tr=re(Array.prototype.splice),ut=re(String.prototype.toLowerCase),Pt=re(String.prototype.toString),Vt=re(String.prototype.match),Qe=re(String.prototype.replace),Ar=re(String.prototype.indexOf),Mr=re(String.prototype.trim),de=re(Object.prototype.hasOwnProperty),oe=re(RegExp.prototype.test),Ze=Nr(TypeError);function re(o){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return _t(o,e,r)}}function Nr(o){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Ot(o,n)}}function I(o,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ut;Ln&&Ln(o,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const a=n(s);a!==s&&(br(e)||(e[r]=a),s=a)}o[s]=!0}return o}function Rr(o){for(let e=0;e<o.length;e++)de(o,e)||(o[e]=null);return o}function ge(o){const e=$t(null);for(const[n,r]of Bn(o))de(o,n)&&(Array.isArray(r)?e[n]=Rr(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ge(r):e[n]=r);return e}function Ye(o,e){for(;o!==null;){const r=Cr(o,e);if(r){if(r.get)return re(r.get);if(typeof r.value=="function")return re(r.value)}o=Er(o)}function n(){return null}return n}const In=ne(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ft=ne(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ht=ne(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Br=ne(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ut=ne(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Lr=ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zn=ne(["#text"]),$n=ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),qt=ne(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),_n=ne(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),dt=ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Dr=ue(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ir=ue(/<%[\w\W]*|[\w\W]*%>/gm),zr=ue(/\$\{[\w\W]*/gm),$r=ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),_r=ue(/^aria-[\-\w]+$/),On=ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Or=ue(/^(?:\w+script|data):/i),Pr=ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pn=ue(/^html$/i),Vr=ue(/^[a-z][.\w]*(-[.\w]+)+$/i);var Vn=Object.freeze({__proto__:null,ARIA_ATTR:_r,ATTR_WHITESPACE:Pr,CUSTOM_ELEMENT:Vr,DATA_ATTR:$r,DOCTYPE_NAME:Pn,ERB_EXPR:Ir,IS_ALLOWED_URI:On,IS_SCRIPT_OR_DATA:Or,MUSTACHE_EXPR:Dr,TMPLIT_EXPR:zr});const Xe={element:1,text:3,progressingInstruction:7,comment:8,document:9},Fr=function(){return typeof window>"u"?null:window},Hr=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const a="dompurify"+(r?"#"+r:"");try{return e.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Fn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hn(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fr();const e=R=>Hn(R);if(e.version="3.3.0",e.removed=[],!o||!o.document||o.document.nodeType!==Xe.document||!o.Element)return e.isSupported=!1,e;let{document:n}=o;const r=n,s=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:d,NodeFilter:u,NamedNodeMap:p=o.NamedNodeMap||o.MozNamedAttrMap,HTMLFormElement:h,DOMParser:x,trustedTypes:y}=o,f=d.prototype,E=Ye(f,"cloneNode"),g=Ye(f,"remove"),m=Ye(f,"nextSibling"),b=Ye(f,"childNodes"),C=Ye(f,"parentNode");if(typeof i=="function"){const R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let w,z="";const{implementation:$,createNodeIterator:F,createDocumentFragment:S,getElementsByTagName:T}=n,{importNode:N}=r;let D=Fn();e.isSupported=typeof Bn=="function"&&typeof C=="function"&&$&&$.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:Q,TMPLIT_EXPR:fe,DATA_ATTR:Re,ARIA_ATTR:ye,IS_SCRIPT_OR_DATA:Be,ATTR_WHITESPACE:pt,CUSTOM_ELEMENT:Wt}=Vn;let{IS_ALLOWED_URI:ft}=Vn,j=null;const Je=I({},[...In,...Ft,...Ht,...Ut,...zn]);let Z=null;const mt=I({},[...$n,...qt,..._n,...dt]);let v=Object.seal($t(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Le=null,ze=null;const ke=Object.seal($t(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ht=!0,$e=!0,L=!1,V=!0,H=!1,G=!0,W=!1,K=!1,se=!1,me=!1,gt=!1,yt=!1,to=!0,no=!1;const _a="user-content-";let Kt=!0,et=!1,_e={},Oe=null;const oo=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ro=null;const so=I({},["audio","video","img","source","image","track"]);let Gt=null;const ao=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let Pe=xe,Qt=!1,Zt=null;const Oa=I({},[kt,xt,xe],Pt);let wt=I({},["mi","mo","mn","ms","mtext"]),bt=I({},["annotation-xml"]);const Pa=I({},["title","style","font","a","script"]);let tt=null;const Va=["application/xhtml+xml","text/html"],Fa="text/html";let X=null,Ve=null;const Ha=n.createElement("form"),io=function(c){return c instanceof RegExp||c instanceof Function},Yt=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ve&&Ve===c)){if((!c||typeof c!="object")&&(c={}),c=ge(c),tt=Va.indexOf(c.PARSER_MEDIA_TYPE)===-1?Fa:c.PARSER_MEDIA_TYPE,X=tt==="application/xhtml+xml"?Pt:ut,j=de(c,"ALLOWED_TAGS")?I({},c.ALLOWED_TAGS,X):Je,Z=de(c,"ALLOWED_ATTR")?I({},c.ALLOWED_ATTR,X):mt,Zt=de(c,"ALLOWED_NAMESPACES")?I({},c.ALLOWED_NAMESPACES,Pt):Oa,Gt=de(c,"ADD_URI_SAFE_ATTR")?I(ge(ao),c.ADD_URI_SAFE_ATTR,X):ao,ro=de(c,"ADD_DATA_URI_TAGS")?I(ge(so),c.ADD_DATA_URI_TAGS,X):so,Oe=de(c,"FORBID_CONTENTS")?I({},c.FORBID_CONTENTS,X):oo,Le=de(c,"FORBID_TAGS")?I({},c.FORBID_TAGS,X):ge({}),ze=de(c,"FORBID_ATTR")?I({},c.FORBID_ATTR,X):ge({}),_e=de(c,"USE_PROFILES")?c.USE_PROFILES:!1,ht=c.ALLOW_ARIA_ATTR!==!1,$e=c.ALLOW_DATA_ATTR!==!1,L=c.ALLOW_UNKNOWN_PROTOCOLS||!1,V=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=c.SAFE_FOR_TEMPLATES||!1,G=c.SAFE_FOR_XML!==!1,W=c.WHOLE_DOCUMENT||!1,me=c.RETURN_DOM||!1,gt=c.RETURN_DOM_FRAGMENT||!1,yt=c.RETURN_TRUSTED_TYPE||!1,se=c.FORCE_BODY||!1,to=c.SANITIZE_DOM!==!1,no=c.SANITIZE_NAMED_PROPS||!1,Kt=c.KEEP_CONTENT!==!1,et=c.IN_PLACE||!1,ft=c.ALLOWED_URI_REGEXP||On,Pe=c.NAMESPACE||xe,wt=c.MATHML_TEXT_INTEGRATION_POINTS||wt,bt=c.HTML_INTEGRATION_POINTS||bt,v=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(v.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(v.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(v.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),H&&($e=!1),gt&&(me=!0),_e&&(j=I({},zn),Z=[],_e.html===!0&&(I(j,In),I(Z,$n)),_e.svg===!0&&(I(j,Ft),I(Z,qt),I(Z,dt)),_e.svgFilters===!0&&(I(j,Ht),I(Z,qt),I(Z,dt)),_e.mathMl===!0&&(I(j,Ut),I(Z,_n),I(Z,dt))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?ke.tagCheck=c.ADD_TAGS:(j===Je&&(j=ge(j)),I(j,c.ADD_TAGS,X))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?ke.attributeCheck=c.ADD_ATTR:(Z===mt&&(Z=ge(Z)),I(Z,c.ADD_ATTR,X))),c.ADD_URI_SAFE_ATTR&&I(Gt,c.ADD_URI_SAFE_ATTR,X),c.FORBID_CONTENTS&&(Oe===oo&&(Oe=ge(Oe)),I(Oe,c.FORBID_CONTENTS,X)),Kt&&(j["#text"]=!0),W&&I(j,["html","head","body"]),j.table&&(I(j,["tbody"]),delete Le.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=c.TRUSTED_TYPES_POLICY,z=w.createHTML("")}else w===void 0&&(w=Hr(y,s)),w!==null&&typeof z=="string"&&(z=w.createHTML(""));ne&&ne(c),Ve=c}},lo=I({},[...Ft,...Ht,...Br]),co=I({},[...Ut,...Lr]),Ua=function(c){let k=C(c);(!k||!k.tagName)&&(k={namespaceURI:Pe,tagName:"template"});const A=ut(c.tagName),U=ut(k.tagName);return Zt[c.namespaceURI]?c.namespaceURI===xt?k.namespaceURI===xe?A==="svg":k.namespaceURI===kt?A==="svg"&&(U==="annotation-xml"||wt[U]):!!lo[A]:c.namespaceURI===kt?k.namespaceURI===xe?A==="math":k.namespaceURI===xt?A==="math"&&bt[U]:!!co[A]:c.namespaceURI===xe?k.namespaceURI===xt&&!bt[U]||k.namespaceURI===kt&&!wt[U]?!1:!co[A]&&(Pa[A]||!lo[A]):!!(tt==="application/xhtml+xml"&&Zt[c.namespaceURI]):!1},he=function(c){Ge(e.removed,{element:c});try{C(c).removeChild(c)}catch{g(c)}},De=function(c,k){try{Ge(e.removed,{attribute:k.getAttributeNode(c),from:k})}catch{Ge(e.removed,{attribute:null,from:k})}if(k.removeAttribute(c),c==="is")if(me||gt)try{he(k)}catch{}else try{k.setAttribute(c,"")}catch{}},uo=function(c){let k=null,A=null;if(se)c="<remove></remove>"+c;else{const Y=Vt(c,/^[\r\n\t ]+/);A=Y&&Y[0]}tt==="application/xhtml+xml"&&Pe===xe&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const U=w?w.createHTML(c):c;if(Pe===xe)try{k=new x().parseFromString(U,tt)}catch{}if(!k||!k.documentElement){k=$.createDocument(Pe,"template",null);try{k.documentElement.innerHTML=Qt?z:U}catch{}}const te=k.body||k.documentElement;return c&&A&&te.insertBefore(n.createTextNode(A),te.childNodes[0]||null),Pe===xe?T.call(k,W?"html":"body")[0]:W?k.documentElement:te},po=function(c){return F.call(c.ownerDocument||c,c,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Xt=function(c){return c instanceof h&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof p)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},fo=function(c){return typeof l=="function"&&c instanceof l};function we(R,c,k){ct(R,A=>{A.call(e,c,k,Ve)})}const mo=function(c){let k=null;if(we(D.beforeSanitizeElements,c,null),Xt(c))return he(c),!0;const A=X(c.nodeName);if(we(D.uponSanitizeElement,c,{tagName:A,allowedTags:j}),G&&c.hasChildNodes()&&!fo(c.firstElementChild)&&oe(/<[/\w!]/g,c.innerHTML)&&oe(/<[/\w!]/g,c.textContent)||c.nodeType===Xe.progressingInstruction||G&&c.nodeType===Xe.comment&&oe(/<[/\w]/g,c.data))return he(c),!0;if(!(ke.tagCheck instanceof Function&&ke.tagCheck(A))&&(!j[A]||Le[A])){if(!Le[A]&&go(A)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A)))return!1;if(Kt&&!Oe[A]){const U=C(c)||c.parentNode,te=b(c)||c.childNodes;if(te&&U){const Y=te.length;for(let ae=Y-1;ae>=0;--ae){const be=E(te[ae],!0);be.__removalCount=(c.__removalCount||0)+1,U.insertBefore(be,m(c))}}}return he(c),!0}return c instanceof d&&!Ua(c)||(A==="noscript"||A==="noembed"||A==="noframes")&&oe(/<\/no(script|embed|frames)/i,c.innerHTML)?(he(c),!0):(H&&c.nodeType===Xe.text&&(k=c.textContent,ct([M,Q,fe],U=>{k=Qe(k,U," ")}),c.textContent!==k&&(Ge(e.removed,{element:c.cloneNode()}),c.textContent=k)),we(D.afterSanitizeElements,c,null),!1)},ho=function(c,k,A){if(to&&(k==="id"||k==="name")&&(A in n||A in Ha))return!1;if(!($e&&!ze[k]&&oe(Re,k))){if(!(ht&&oe(ye,k))){if(!(ke.attributeCheck instanceof Function&&ke.attributeCheck(k,c))){if(!Z[k]||ze[k]){if(!(go(c)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,c)||v.tagNameCheck instanceof Function&&v.tagNameCheck(c))&&(v.attributeNameCheck instanceof RegExp&&oe(v.attributeNameCheck,k)||v.attributeNameCheck instanceof Function&&v.attributeNameCheck(k,c))||k==="is"&&v.allowCustomizedBuiltInElements&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A))))return!1}else if(!Gt[k]){if(!oe(ft,Qe(A,pt,""))){if(!((k==="src"||k==="xlink:href"||k==="href")&&c!=="script"&&Ar(A,"data:")===0&&ro[c])){if(!(L&&!oe(Be,Qe(A,pt,"")))){if(A)return!1}}}}}}}return!0},go=function(c){return c!=="annotation-xml"&&Vt(c,Wt)},yo=function(c){we(D.beforeSanitizeAttributes,c,null);const{attributes:k}=c;if(!k||Xt(c))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0};let U=k.length;for(;U--;){const te=k[U],{name:Y,namespaceURI:ae,value:be}=te,Fe=X(Y),Jt=be;let ee=Y==="value"?Jt:Mr(Jt);if(A.attrName=Fe,A.attrValue=ee,A.keepAttr=!0,A.forceKeepAttr=void 0,we(D.uponSanitizeAttribute,c,A),ee=A.attrValue,no&&(Fe==="id"||Fe==="name")&&(De(Y,c),ee=_a+ee),G&&oe(/((--!?|])>)|<\/(style|title|textarea)/i,ee)){De(Y,c);continue}if(Fe==="attributename"&&Vt(ee,"href")){De(Y,c);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){De(Y,c);continue}if(!V&&oe(/\/>/i,ee)){De(Y,c);continue}H&&ct([M,Q,fe],xo=>{ee=Qe(ee,xo," ")});const ko=X(c.nodeName);if(!ho(ko,Fe,ee)){De(Y,c);continue}if(w&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!ae)switch(y.getAttributeType(ko,Fe)){case"TrustedHTML":{ee=w.createHTML(ee);break}case"TrustedScriptURL":{ee=w.createScriptURL(ee);break}}if(ee!==Jt)try{ae?c.setAttributeNS(ae,Y,ee):c.setAttribute(Y,ee),Xt(c)?he(c):Dn(e.removed)}catch{De(Y,c)}}we(D.afterSanitizeAttributes,c,null)},qa=function R(c){let k=null;const A=po(c);for(we(D.beforeSanitizeShadowDOM,c,null);k=A.nextNode();)we(D.uponSanitizeShadowNode,k,null),mo(k),yo(k),k.content instanceof a&&R(k.content);we(D.afterSanitizeShadowDOM,c,null)};return e.sanitize=function(R){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=null,A=null,U=null,te=null;if(Qt=!R,Qt&&(R="<!-->"),typeof R!="string"&&!fo(R))if(typeof R.toString=="function"){if(R=R.toString(),typeof R!="string")throw Ze("dirty is not a string, aborting")}else throw Ze("toString is not a function");if(!e.isSupported)return R;if(K||Yt(c),e.removed=[],typeof R=="string"&&(et=!1),et){if(R.nodeName){const be=X(R.nodeName);if(!j[be]||Le[be])throw Ze("root node is forbidden and cannot be sanitized in-place")}}else if(R instanceof l)k=uo("<!---->"),A=k.ownerDocument.importNode(R,!0),A.nodeType===Xe.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?k=A:k.appendChild(A);else{if(!me&&!H&&!W&&R.indexOf("<")===-1)return w&&yt?w.createHTML(R):R;if(k=uo(R),!k)return me?null:yt?z:""}k&&se&&he(k.firstChild);const Y=po(et?R:k);for(;U=Y.nextNode();)mo(U),yo(U),U.content instanceof a&&qa(U.content);if(et)return R;if(me){if(gt)for(te=S.call(k.ownerDocument);k.firstChild;)te.appendChild(k.firstChild);else te=k;return(Z.shadowroot||Z.shadowrootmode)&&(te=N.call(r,te,!0)),te}let ae=W?k.outerHTML:k.innerHTML;return W&&j["!doctype"]&&k.ownerDocument&&k.ownerDocument.doctype&&k.ownerDocument.doctype.name&&oe(Pn,k.ownerDocument.doctype.name)&&(ae="<!DOCTYPE "+k.ownerDocument.doctype.name+`>
58
+ `+ae),H&&ct([M,Q,fe],be=>{ae=Qe(ae,be," ")}),w&&yt?w.createHTML(ae):ae},e.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(R),K=!0},e.clearConfig=function(){Ve=null,K=!1},e.isValidAttribute=function(R,c,k){Ve||Yt({});const A=X(R),U=X(c);return ho(A,U,k)},e.addHook=function(R,c){typeof c=="function"&&Ge(D[R],c)},e.removeHook=function(R,c){if(c!==void 0){const k=Sr(D[R],c);return k===-1?void 0:Tr(D[R],k,1)[0]}return Dn(D[R])},e.removeHooks=function(R){D[R]=[]},e.removeAllHooks=function(){D=Fn()},e}var Ur=Hn();function Un(){return{parseMarkdown:e=>{if(!e||typeof e!="string")return"";const n=ln(e),r=_.parse(n,{async:!1,breaks:!0,gfm:!0});return Ur.sanitize(r,{ALLOWED_TAGS:["p","br","strong","em","b","i","code","pre","ul","ol","li","h1","h2","h3","h4","h5","h6","a","blockquote","span","div","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","target","rel","data-mention-id","data-mention-type"],ALLOW_UNKNOWN_PROTOCOLS:!1,FORBID_ATTR:["onerror","onload","onclick","onmouseover"],KEEP_CONTENT:!0})}}}function qr(){let o=null;function e(a){const i=a||document.querySelector("[data-rai-chat-container]");i&&requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})}function n(a,i=100){const{scrollTop:l,scrollHeight:d,clientHeight:u}=a;return d-l-u<i}function r(a){a&&(s(),o=new MutationObserver(()=>{(a.scrollTop===0||n(a))&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}),o.observe(a,{childList:!0,subtree:!0}))}function s(){o&&(o.disconnect(),o=null)}return t.onUnmounted(()=>{s()}),{scrollToBottom:e,setupAutoScroll:r,cleanupAutoScroll:s}}function vr(){const o=Ce(),e=t.computed(()=>o.error),n=t.computed(()=>{var a,i;return((a=e.value)==null?void 0:a.message)!==null&&((i=e.value)==null?void 0:i.message)!==void 0});return{errorState:e,hasError:n,retry:async()=>await o.retry(),clearError:()=>{o.clearError()}}}function vt(){const o=Ce(),e=t.computed(()=>o.pageContext);function n(a){o.setPageContext(a)}function r(){o.setPageContext(null)}function s(a){const i=o.pageContext;i&&o.setPageContext({...i,...a,metadata:{...i.metadata,...a.metadata}})}return{context:e,setContext:n,clearContext:r,updateContext:s}}const pe=[],qn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const o=q();return(o==null?void 0:o.defaultSuggestions)||[]}};function jr(){pe.length=0;const o=q();o!=null&&o.suggestionProviders&&pe.push(...o.suggestionProviders),pe.push(qn)}function Wr(o,e){const n=[...pe].sort((r,s)=>(s.priority||0)-(r.priority||0));for(const r of n)if(r.matcher&&r.matcher(o,e)||r.routes&&r.routes.some(a=>a.endsWith("*")?o.startsWith(a.slice(0,-1)):o===a||o.startsWith(a+"/")))return r;return qn}function vn(o,e){pe.length===0&&jr();const n=Wr(o,e),r=e||{pageType:"default",routePath:o};return n.extractContext&&(r.metadata={...r.metadata,...n.extractContext(o)}),n.getSuggestions(r)||[]}function Kr(o){const e=pe.findIndex(n=>n.id===o.id);if(e>=0)pe[e]=o;else{const n=pe.findIndex(r=>r.id==="default");n>=0?pe.splice(n,0,o):pe.push(o)}}const Gr=Kr;function jt(){const{context:o}=vt(),e=Ce(),n=t.computed(()=>{var d;if(e.quota.remaining===0){const u=q();return(u==null?void 0:u.enableSupportMode)!==!1?[{id:"contact-support-quota",title:J("contactSupport"),description:J("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[]}const a=((d=o.value)==null?void 0:d.routePath)||(typeof window<"u"?window.location.pathname:"/"),i=vn(a,o.value)||[],l=q();return l!=null&&l.can?i.filter(u=>!(u.permission&&!l.can(u.permission))):i}),r=t.computed(()=>o.value!==null&&o.value.pageType!=="default");function s(a){return typeof a.prompt=="function"?a.prompt(o.value||{pageType:"default"}):a.prompt}return{suggestions:n,hasContextualSuggestions:r,resolvePrompt:s}}function Qr(o,e){const{setContext:n,clearContext:r,updateContext:s}=vt();function a(){if(!e)return{};const l={};for(const[d,u]of Object.entries(e))l[d]=t.isRef(u)?u.value:u;return l}function i(){const l={pageType:o,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return t.onMounted(()=>{i()}),t.onUnmounted(()=>{r()}),e&&t.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function Zr(o){const e=o.toLowerCase().split("+");return{key:e.pop()||"",meta:e.includes("cmd")||e.includes("meta")||e.includes("command"),ctrl:e.includes("ctrl")||e.includes("control"),shift:e.includes("shift"),alt:e.includes("alt")||e.includes("option"),mod:e.includes("mod")}}function Yr(o,e){const n=o.key.toLowerCase();if(e.mod){const u=navigator.platform.toUpperCase().indexOf("MAC")>=0||navigator.userAgent.toUpperCase().indexOf("MAC")>=0?o.metaKey:o.ctrlKey,p=e.shift?o.shiftKey:!o.shiftKey,h=e.alt?o.altKey:!o.altKey;return n===e.key&&u&&p&&h}const r=e.meta?o.metaKey:!o.metaKey,s=e.ctrl?o.ctrlKey:!o.ctrlKey,a=e.shift?o.shiftKey:!o.shiftKey,i=e.alt?o.altKey:!o.altKey;let l=r&&s&&a&&i;return(e.meta&&!e.ctrl||!e.meta&&e.ctrl)&&(l=(o.metaKey||o.ctrlKey)&&a&&i),n===e.key&&l}function jn(o){const{onToggle:e,enabled:n=!0}=o,r=t.ref(!1),s=o.shortcut!==void 0?o.shortcut:Te("keyboardShortcut")??"mod+g";if(s===null)return{isActive:r};const a=Zr(s);function i(l){if(!n)return;const d=l.target,u=d.tagName==="INPUT"||d.tagName==="TEXTAREA",p=d.isContentEditable,h=d.closest("[data-ai-input]");if(!((u||p)&&!h)&&Yr(l,a)){l.preventDefault(),l.stopPropagation();const x=q();if(x!=null&&x.canToggle&&!x.canToggle())return;r.value=!r.value,e()}}return t.onMounted(()=>{window.addEventListener("keydown",i,!0)}),t.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:r}}function Xr(o){const e=Ce();return jn({onToggle:()=>{o?o.value=!o.value:e.showChat=!e.showChat}})}function Jr(o,e){const n=t.ref(J("loadingText"));let r=[];function s(){return[J("loadingText"),J("analyzingText"),J("craftingText")]}function a(){return[0,2e3,5e3]}function i(){r.forEach(u=>clearTimeout(u)),r=[]}function l(){i();const u=e==null?void 0:e(),p=(u==null?void 0:u.messages)??s();n.value=p[0]||J("loadingText")}function d(){i();const u=e==null?void 0:e(),p=(u==null?void 0:u.messages)??s(),h=(u==null?void 0:u.intervals)??a();n.value=p[0]||J("loadingText");let x=0;for(let y=1;y<p.length;y++){x+=h[y]||2e3;const f=y,E=window.setTimeout(()=>{o()&&(n.value=p[f])},x);r.push(E)}}return t.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:d,resetLoadingText:l,clearLoadingTextTimers:i}}function es(o){const{getHistoryLength:e,getStoreLimit:n,getConfig:r,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=o,l=t.ref({showWarning:!1,isReached:!1,pendingMessage:null}),d=t.computed(()=>{var C;return((C=r())==null?void 0:C.limit)??n()}),u=t.computed(()=>{var C;return((C=r())==null?void 0:C.showWarningAt)??d.value-2}),p=t.computed(()=>Math.max(0,d.value-e())),h=t.computed(()=>p.value<=d.value-u.value&&p.value>0),x=t.computed(()=>p.value===0),y=t.computed(()=>{var C,w;return l.value.isReached?((C=s())==null?void 0:C.historyLimitReachedTitle)??"Chat Limit Reached":((w=s())==null?void 0:w.historyLimitWarningTitle)??"Approaching Chat Limit"}),f=t.computed(()=>{var C,w,z,$;return l.value.isReached?((C=r())==null?void 0:C.limitMessage)??((w=s())==null?void 0:w.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":((z=r())==null?void 0:z.warningMessage)??(($=s())==null?void 0:$.historyLimitWarningMessage)??`You have ${p.value} message${p.value===1?"":"s"} remaining in this conversation.`});function E(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function g(){l.value.showWarning=!1;const C=r();if(C!=null&&C.onLimitReached&&!await C.onLimitReached())return l.value.isReached=!1,null;if(a(),i(),l.value.isReached=!1,l.value.pendingMessage){const w=l.value.pendingMessage;return l.value.pendingMessage=null,w}return null}function m(){return x.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(h.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function b(C){l.value.pendingMessage=C}return{showHistoryLimitWarning:t.computed(()=>l.value.showWarning),historyLimitReached:t.computed(()=>l.value.isReached),historyLimit:d,remainingMessages:p,historyLimitDialogTitle:y,historyLimitDialogMessage:f,dismissHistoryLimitWarning:E,handleHistoryLimitAction:g,checkHistoryLimit:m,setPendingMessage:b}}function ts(){const o=Ce(),e=t.ref([]),n=t.ref(!1),r=t.ref(0),s=Te("maxAttachments")||5,a=Te("maxFileSize")||10*1024*1024,i=Te("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=t.computed(()=>e.value.length>0),d=t.computed(()=>e.value.some(S=>S.uploading)),u=t.computed(()=>e.value.length<s);function p(S){return(S.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(S.name)}function h(S){if(S==null)return"";const T=typeof S=="string"?parseInt(S,10):S;return Number.isNaN(T)?"":T>=1024*1024?`${(T/(1024*1024)).toFixed(1)} MB`:T>=1024?`${Math.round(T/1024)} KB`:`${T} B`}function x(S){var fe;const T=crypto.randomUUID(),N=S.type.startsWith("image/")?URL.createObjectURL(S):void 0,D=q(),M=!!((fe=D==null?void 0:D.endpoints)!=null&&fe.uploadFile),Q={id:T,name:S.name,type:S.type,size:S.size,uploading:M,progress:M?0:100,previewUrl:N};e.value.push(Q),M&&y(S,T)}async function y(S,T){try{const N=await o.uploadFile(S),D=e.value.findIndex(M=>M.id===T);if(D===-1)return;if(N){const M=e.value[D].previewUrl;e.value[D]={...e.value[D],id:N.id||T,url:N.url,extractedText:N.extractedText,uploading:!1,progress:100,previewUrl:M||N.previewUrl}}else f(T)}catch{f(T)}}function f(S){const T=e.value.findIndex(D=>D.id===S);if(T===-1)return;const[N]=e.value.splice(T,1);N!=null&&N.previewUrl&&URL.revokeObjectURL(N.previewUrl)}function E(){e.value.forEach(S=>{S.previewUrl&&URL.revokeObjectURL(S.previewUrl)}),e.value=[]}function g(){return e.value.filter(S=>!S.uploading).map(S=>({id:S.id,name:S.name,url:S.url,type:S.type,size:S.size}))}function m(S){if(!S)return;const T=Array.from(S);for(const N of T){if(e.value.length>=s)break;N.size>a||x(N)}}function b(S){var T;return Array.from(((T=S.dataTransfer)==null?void 0:T.types)||[]).includes("Files")}function C(S){b(S)&&(r.value+=1,n.value=!0)}function w(S){b(S)||S.preventDefault()}function z(S){b(S)&&(r.value=Math.max(0,r.value-1),r.value===0&&(n.value=!1))}function $(S){var T;b(S)&&(r.value=0,n.value=!1,m(((T=S.dataTransfer)==null?void 0:T.files)||null))}function F(S){const T=S.target,N=T.files;N&&N.length&&m(N),T.value=""}return t.onBeforeUnmount(()=>{E()}),{attachments:e,isDraggingFiles:n,hasAttachments:l,isUploading:d,canAddMore:u,acceptedFileTypes:i,isImage:p,formatFileSize:h,removeAttachment:f,clearAttachments:E,buildPayload:g,processFiles:m,handleFileSelect:F,handleDragEnter:C,handleDragOver:w,handleDragLeave:z,handleDrop:$}}function ns(o,e,n){const r=t.ref(!1),s=t.ref([]),a=t.ref(0),i=t.ref({inMention:!1,query:"",startPos:0}),l=t.ref([]),d=t.computed(()=>{const E=q();return(E==null?void 0:E.mentionProviders)||[]});function u(E){const g=n();if(!g)return;const m=g.selectionStart,b=cn(E,m);i.value=b,b.inMention&&b.query.length>=0?p(b.query):(r.value=!1,s.value=[])}async function p(E){const g=pn();if(g.length===0){r.value=!1;return}const m=[];for(const b of g)try{const C=await b.search(E);m.push(...C.map(w=>({...w,type:b.type})))}catch(C){console.warn(`Mention provider ${b.type} failed:`,C)}s.value=m.slice(0,10),r.value=m.length>0,a.value=0}function h(E){const{startPos:g}=i.value,m=o(),b=n(),C=m.slice(0,g),w=m.slice((b==null?void 0:b.selectionStart)||g),z=E.name||E.label||E.title||E.id;e(`${C}@${z} ${w}`),l.value.push({id:E.id,name:z,type:E.type,metadata:E.attributes}),r.value=!1,s.value=[],setTimeout(()=>{const $=n();$==null||$.focus();const F=C.length+z.length+2;$==null||$.setSelectionRange(F,F)},0)}function x(E){if(!r.value||s.value.length===0)return!1;if(E.key==="ArrowDown")return E.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(E.key==="ArrowUp")return E.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(E.key==="Enter"||E.key==="Tab"){E.preventDefault();const g=s.value[a.value];return g&&h(g),!0}return E.key==="Escape"?(E.preventDefault(),r.value=!1,!0):!1}function y(){l.value=[]}function f(){return[...l.value]}return{showMentions:r,mentionItems:s,selectedMentionIndex:a,mentionProviders:d,checkForMentions:u,handleMentionSelect:h,handleMentionKeyDown:x,clearMentions:y,getMentions:f}}function os(o,e,n,r,s){const a=t.ref(!1),i=t.ref(-1),l=t.ref(null);function d(){setTimeout(()=>{const y=l.value;if(!y)return;const f=y.querySelector(`li:nth-child(${i.value+1})`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function u(y){const f=o();if(!a.value||f.length===0)return!1;if(y.key==="ArrowDown")return y.preventDefault(),i.value=Math.min(i.value+1,f.length-1),d(),!0;if(y.key==="ArrowUp")return y.preventDefault(),i.value=Math.max(i.value-1,0),d(),!0;if(y.key==="Enter"&&i.value>=0){y.preventDefault();const E=f[i.value];return E&&p(E),!0}return y.key==="Escape"?(y.preventDefault(),a.value=!1,i.value=-1,!0):!1}function p(y){s(y),a.value=!1,i.value=-1}function h(){const y=r(),f=e(),E=n(),g=o();y&&!f&&E&&g.length>0?a.value=!0:a.value=!1}function x(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:u,handleSuggestionClick:p,updateSuggestionsVisibility:h,hideSuggestions:x}}function rs(o,e=300){function n(){const r=o();if(!r)return;r.style.height="auto";const s=Math.min(r.scrollHeight,e);r.style.height=`${s}px`,r.style.overflowY=r.scrollHeight>e?"auto":"hidden"}return t.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const Wn=t.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(o){return(e,n)=>{var r;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["w-6 h-6 min-w-[24px] flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-600",(r=o.ui)==null?void 0:r.container])},[t.renderSlot(e.$slots,"default",{},()=>{var s;return[(t.openBlock(),t.createElementBlock("svg",{class:t.normalizeClass(["w-4 h-4 text-gray-400 dark:text-gray-500",(s=o.ui)==null?void 0:s.icon]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...n[0]||(n[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))]})],2)}}}),ss=t.defineComponent({__name:"UserAvatar",props:{ui:{}},setup(o){return(e,n)=>{var r;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(r=o.ui)==null?void 0:r.container])},[t.renderSlot(e.$slots,"default",{},()=>{var s;return[(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:t.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=o.ui)==null?void 0:s.icon])},[...n[0]||(n[0]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])],2))]})],2)}}}),as=["onClick","onMouseenter"],Kn=t.defineComponent({__name:"MentionList",props:{items:{},selectedIndex:{default:0},providers:{default:()=>[]},ui:{},texts:{}},emits:["select","update:selectedIndex"],setup(o,{emit:e}){const n=o,r=t.computed(()=>n.ui||{}),s=e,a=t.ref(n.selectedIndex);t.watch(()=>n.selectedIndex,g=>{a.value=g}),t.watch(a,g=>{s("update:selectedIndex",g)});const i=t.computed(()=>{const g={};return n.items.forEach(m=>{const b=m.type||"default";g[b]||(g[b]=[]),g[b].push(m)}),g});function l(g){return n.providers.find(m=>m.type===g)||dn(g)}function d(g){const m=l(g);return(m==null?void 0:m.label)||g.charAt(0).toUpperCase()+g.slice(1)+"s"}function u(g,m){let b=0;const C=Object.keys(i.value);for(const w of C){if(w===g)return b+m;b+=i.value[w].length}return b}function p(g){s("select",g)}function h(g){a.value=g,s("update:selectedIndex",g)}function x(g){const m=l(g.type);return At(g,m)}function y(g){const m=l(g.type);return un(g,m)}function f(g){const m={employee:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",job:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",candidate:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",project:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400",default:"bg-primary/10 text-primary"};return m[g]||m.default}function E(g){return g.split(" ").map(m=>m[0]).join("").slice(0,2).toUpperCase()}return(g,m)=>o.items.length>0?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-60 overflow-y-auto z-50",r.value.root])},[t.createElementVNode("div",{class:t.normalizeClass(["p-2",r.value.container])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value,(b,C)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:C},[Object.keys(i.value).length>1?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",r.value.groupHeader])},t.toDisplayString(d(C)),3)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(b,(w,z)=>(t.openBlock(),t.createElementBlock("button",{key:w.id,type:"button",class:t.normalizeClass(["w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors mb-0.5",[r.value.item,{[r.value.itemSelected||"bg-primary/10"]:u(C,z)===a.value,"hover:bg-gray-50 dark:hover:bg-gray-700":u(C,z)!==a.value}]]),onClick:$=>p(w),onMouseenter:$=>h(u(C,z))},[t.renderSlot(g.$slots,"item-icon",{item:w,type:C},()=>[t.createElementVNode("span",{class:t.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[r.value.itemIcon,f(w.type)]])},t.toDisplayString(E(x(w))),3)]),t.createElementVNode("div",{class:t.normalizeClass(["flex-1 min-w-0",r.value.itemContent])},[t.createElementVNode("p",{class:t.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",r.value.itemName])},t.toDisplayString(x(w)),3),y(w)?(t.openBlock(),t.createElementBlock("p",{key:0,class:t.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",r.value.itemSubtitle])},t.toDisplayString(y(w)),3)):t.createCommentVNode("",!0)],2)],42,as))),128))],64))),128))],2)],2)):t.createCommentVNode("",!0)}}),is=["title"],ls={key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Gn=t.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(o,{emit:e}){const n=o,r=e,s=d=>{var p;return(p=n.texts)!=null&&p[d]?n.texts[d]:J({copyToClipboard:"copyToClipboard",copied:"copied"}[d])},a=t.computed(()=>n.ui||{}),i=t.ref(!1);async function l(){try{await navigator.clipboard.writeText(n.message.message),i.value=!0,r("copy",n.message),setTimeout(()=>{i.value=!1},2e3)}catch(d){console.error("Failed to copy:",d)}}return(d,u)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",a.value.container])},[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",[a.value.button,a.value.copyButton]]),title:i.value?s("copied"):s("copyToClipboard"),onClick:l},[i.value?(t.openBlock(),t.createElementBlock("svg",{key:1,class:t.normalizeClass(["w-4 h-4 text-green-500",a.value.successState]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[...u[1]||(u[1]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])],2)):(t.openBlock(),t.createElementBlock("svg",ls,[...u[0]||(u[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M15.666 3.888A2.25 2.25 0 0013.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 01-.75.75H9a.75.75 0 01-.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 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"},null,-1)])]))],10,is)],2))}}),cs={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},us=["src"],ds={key:1,class:"w-5 h-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ps={class:"flex-1 min-w-0"},fs={class:"text-sm font-semibold text-white truncate"},ms={class:"text-xs text-white/70"},hs={key:0,class:"text-xs font-medium text-white/90"},gs=["src"],ys={key:1,class:"h-4 w-4 text-white",viewBox:"0 0 24 24",fill:"currentColor"},ks={class:"flex-shrink-0 mt-0.5"},xs={class:"text-gray-600 dark:text-gray-400"},ws=["id","innerHTML"],bs={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white dark:bg-gray-800 overflow-hidden border border-gray-200 dark:border-gray-600"},Es=["src"],Cs={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ss={class:"flex-1 min-w-0"},Ts={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},As={class:"text-xs text-gray-500 dark:text-gray-400"},Ms={key:0,class:"text-xs font-medium text-primary"},Ns=t.defineComponent({__name:"ChatMessage",props:{message:{},showActions:{type:Boolean,default:!0},loadingText:{default:"Gathering data..."},ui:{},texts:{}},emits:["copy"],setup(o,{emit:e}){const n=o,r=e,s=m=>{var C;return(C=n.texts)!=null&&C[m]?n.texts[m]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[m]||m},a=t.computed(()=>n.ui||{}),{parseMarkdown:i}=Un(),l=t.ref(!1),d=t.computed(()=>n.message.attachments??[]),u=t.computed(()=>d.value.length>0),p=t.computed(()=>{if(n.message.role!=="user")return!1;const m=n.message.message||"",b=m.split(`
59
+ `).length;return m.length>200||b>4});function h(){l.value=!l.value}function x(m){return(m.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(m.name||"")}const y=t.computed(()=>{const m=q();return m!=null&&m.userAvatar?typeof m.userAvatar=="string"?m.userAvatar:typeof m.userAvatar=="function"?m.userAvatar():null:null});function f(m){if(m==null)return"";const b=typeof m=="string"?parseInt(m,10):m;return Number.isNaN(b)?"":b>=1024*1024?`${(b/(1024*1024)).toFixed(1)} MB`:b>=1024?`${Math.round(b/1024)} KB`:`${b} B`}const E=t.computed(()=>{if(n.message.role==="assistant"){let m=n.message.message;return m=m.replace(/\\n/g,`
60
+ `),i(m)}return n.message.message});function g(m){r("copy",m)}return(m,b)=>{var C;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[a.value.root,{"flex justify-end":o.message.role==="user","flex justify-start":o.message.role==="assistant"}]])},[o.message.role==="user"?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["flex gap-3 justify-end",a.value.userMessage])},[t.createElementVNode("div",{class:t.normalizeClass(["rounded-2xl px-4 py-3 bg-primary text-white max-w-fit",a.value.userBubble])},[o.message.message?(t.openBlock(),t.createElementBlock("p",{key:0,class:t.normalizeClass(["text-sm whitespace-pre-wrap",[a.value.content,{"line-clamp-4":!l.value&&p.value}]])},t.toDisplayString(o.message.message),3)):t.createCommentVNode("",!0),p.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:t.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",a.value.showMoreButton]),onClick:h},t.toDisplayString(l.value?s("showLess"):s("showMore")),3)):t.createCommentVNode("",!0),u.value?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["mt-3 space-y-2",a.value.attachmentsContainer])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,w=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:t.normalizeClass(["flex items-center gap-3 rounded-xl border border-white/20 bg-white/10 p-2 transition",[a.value.attachmentItem,w.url?"hover:bg-white/20 cursor-pointer":""]])},{default:t.withCtx(()=>[t.createElementVNode("div",cs,[w.url&&x(w)?(t.openBlock(),t.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,us)):(t.openBlock(),t.createElementBlock("svg",ds,[...b[0]||(b[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),t.createElementVNode("div",ps,[t.createElementVNode("p",fs,t.toDisplayString(w.name||s("attachment")),1),t.createElementVNode("p",ms,t.toDisplayString(f(w.size)),1)]),w.url?(t.openBlock(),t.createElementBlock("span",hs,t.toDisplayString(s("openAttachment")),1)):t.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):t.createCommentVNode("",!0)],2),t.createElementVNode("div",{class:t.normalizeClass(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary overflow-hidden",a.value.userAvatar])},[y.value?(t.openBlock(),t.createElementBlock("img",{key:0,src:y.value,alt:"User",class:"h-full w-full object-cover"},null,8,gs)):(t.openBlock(),t.createElementBlock("svg",ys,[...b[1]||(b[1]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])]))],2)],2)):(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["flex items-start gap-3",a.value.assistantMessage])},[t.createElementVNode("div",ks,[t.createVNode(Wn)]),t.createElementVNode("div",{class:t.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-5 py-4 shadow-sm rounded-2xl transition-all duration-200 flex-1",a.value.assistantBubble])},[o.message.loading?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",a.value.loadingIndicator])},[t.createElementVNode("div",{class:t.normalizeClass(["flex space-x-1",a.value.loadingDots])},[...b[2]||(b[2]=[t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"0ms"}},null,-1),t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"150ms"}},null,-1),t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"300ms"}},null,-1)])],2),t.createElementVNode("span",xs,t.toDisplayString(((C=o.texts)==null?void 0:C.loadingText)||o.loadingText),1)],2)):o.message.message?(t.openBlock(),t.createElementBlock("div",{key:1,id:o.message.id,class:t.normalizeClass(["prose prose-sm max-w-none prose-gray dark:prose-invert",a.value.content]),innerHTML:E.value},null,10,ws)):t.createCommentVNode("",!0),!o.message.loading&&u.value?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["mt-4 space-y-2",a.value.attachmentsContainer])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,w=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:t.normalizeClass(["flex items-center gap-3 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 p-3 transition",[a.value.attachmentItem,w.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:t.withCtx(()=>[t.createElementVNode("div",bs,[w.url&&x(w)?(t.openBlock(),t.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,Es)):(t.openBlock(),t.createElementBlock("svg",Cs,[...b[3]||(b[3]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),t.createElementVNode("div",Ss,[t.createElementVNode("p",Ts,t.toDisplayString(w.name||s("attachment")),1),t.createElementVNode("p",As,t.toDisplayString(f(w.size)),1)]),w.url?(t.openBlock(),t.createElementBlock("span",Ms,t.toDisplayString(s("openAttachment")),1)):t.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):t.createCommentVNode("",!0)],2)],2)),o.message.role==="assistant"&&!o.message.loading&&!o.message.streaming&&o.showActions?(t.openBlock(),t.createBlock(Gn,{key:2,message:o.message,class:t.normalizeClass(["absolute -bottom-8 left-14",a.value.actionsContainer]),onCopy:g},null,8,["message","class"])):t.createCommentVNode("",!0)],2)}}}),Qn=(o,e)=>{const n=o.__vccOpts||o;for(const[r,s]of e)n[r]=s;return n},Zn=Qn(Ns,[["__scopeId","data-v-df348786"]]),Rs={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},Bs={class:"space-y-2"},Ls=["src"],Ds={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Is={class:"flex-1 min-w-0"},zs={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},$s={class:"text-xs text-gray-500 dark:text-gray-400"},_s={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Os={key:0,class:"text-xs text-gray-400"},Ps=["disabled","onClick"],Vs=t.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(o){return(e,n)=>{var r;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",o.ui.attachmentsContainer])},[t.createElementVNode("p",Rs,t.toDisplayString(((r=o.texts)==null?void 0:r.attachedFiles)||"Attached files"),1),t.createElementVNode("ul",Bs,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.attachments,s=>(t.openBlock(),t.createElementBlock("li",{key:s.id,class:t.normalizeClass(["flex items-center gap-3 rounded-xl bg-white dark:bg-gray-700 p-2 shadow-sm border border-gray-100 dark:border-gray-600",o.ui.attachmentItem])},[t.createElementVNode("div",{class:t.normalizeClass(["h-10 w-10 flex items-center justify-center rounded-lg bg-gray-100 dark:bg-gray-600 overflow-hidden",o.ui.attachmentThumbnail])},[o.isImage(s)?(t.openBlock(),t.createElementBlock("img",{key:0,src:s.previewUrl||s.url,class:"object-cover h-full w-full",alt:""},null,8,Ls)):(t.openBlock(),t.createElementBlock("svg",Ds,[...n[0]||(n[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))],2),t.createElementVNode("div",Is,[t.createElementVNode("p",zs,t.toDisplayString(s.name),1),t.createElementVNode("p",$s,t.toDisplayString(o.formatFileSize(s.size)),1),s.uploading?(t.openBlock(),t.createElementBlock("div",_s,[t.createElementVNode("div",{class:"h-full bg-primary transition-all",style:t.normalizeStyle({width:`${s.progress??10}%`})},null,4)])):t.createCommentVNode("",!0)]),s.uploading?(t.openBlock(),t.createElementBlock("span",Os,t.toDisplayString(Math.round(s.progress??0))+"% ",1)):t.createCommentVNode("",!0),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",o.ui.attachmentRemove]),disabled:s.uploading,onClick:a=>e.$emit("remove",s.id)},[...n[1]||(n[1]=[t.createElementVNode("svg",{class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,Ps)],2))),128))])],2)}}}),Fs={class:"py-1"},Hs=["onClick","onMouseenter"],Us={class:"flex items-start gap-3"},qs={class:"flex-1 min-w-0"},vs={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},js={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Ws=t.defineComponent({__name:"SuggestionsDropdown",props:{suggestions:{},selectedIndex:{},ui:{}},emits:["select","hover"],setup(o,{expose:e}){const n=t.ref(null);return e({dropdownRef:n}),(r,s)=>(t.openBlock(),t.createBlock(t.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:t.withCtx(()=>[t.createElementVNode("div",{ref_key:"dropdownRef",ref:n,class:t.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-80 overflow-y-auto z-10",o.ui.suggestionsDropdown])},[t.createElementVNode("ul",Fs,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.suggestions,(a,i)=>(t.openBlock(),t.createElementBlock("li",{key:a.id,class:t.normalizeClass(["px-4 py-3 cursor-pointer transition-colors border-b border-gray-100 dark:border-gray-700 last:border-b-0",[o.ui.suggestionItem,{[o.ui.suggestionItemSelected||"bg-primary/10"]:i===o.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":i!==o.selectedIndex}]]),onClick:l=>r.$emit("select",a),onMouseenter:l=>r.$emit("hover",i)},[t.createElementVNode("div",Us,[t.createElementVNode("div",qs,[t.createElementVNode("p",vs,t.toDisplayString(a.title),1),t.createElementVNode("p",js,t.toDisplayString(a.description),1)])])],42,Hs))),128))])],2)]),_:1}))}}),Ks={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},Gs=["title"],Qs=["title"],Zs=["disabled"],Ys={key:0,class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Xs={key:1,class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},Js=t.defineComponent({__name:"InputActions",props:{sending:{type:Boolean},canSend:{type:Boolean},supportRequestMode:{type:Boolean},showSupportModeToggle:{type:Boolean},ui:{},texts:{}},emits:["toggle-support-mode","click"],setup(o){const e=o,n=t.computed(()=>e.sending?[e.ui.stopButton||"bg-red-500 text-white hover:bg-red-600"]:e.canSend?[e.ui.sendButtonActive||"bg-primary text-white hover:bg-primary/90"]:[e.ui.sendButtonDisabled||"bg-gray-200 dark:bg-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed opacity-60"]);return(r,s)=>{var a,i,l;return t.openBlock(),t.createElementBlock("div",Ks,[o.showSupportModeToggle&&!o.supportRequestMode?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center text-gray-400 hover:text-primary hover:bg-gray-100 dark:hover:bg-gray-700 transition flex-shrink-0",o.ui.supportToggle]),title:((a=o.texts)==null?void 0:a.toggleSupportMode)||"Toggle support mode",onClick:s[0]||(s[0]=d=>r.$emit("toggle-support-mode"))},[...s[3]||(s[3]=[t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",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 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)])],10,Gs)):t.createCommentVNode("",!0),o.showSupportModeToggle&&o.supportRequestMode?(t.openBlock(),t.createElementBlock("button",{key:1,type:"button",class:t.normalizeClass(["h-7 px-2 rounded-lg flex items-center gap-1 text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 hover:bg-amber-200 dark:hover:bg-amber-900/50 transition flex-shrink-0",o.ui.supportBadge]),title:((i=o.texts)==null?void 0:i.exitSupportMode)||"Exit support mode",onClick:s[1]||(s[1]=d=>r.$emit("toggle-support-mode"))},[s[4]||(s[4]=t.createElementVNode("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",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 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(((l=o.texts)==null?void 0:l.supportLabel)||"Support"),1),s[5]||(s[5]=t.createElementVNode("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1))],10,Qs)):t.createCommentVNode("",!0),t.createElementVNode("button",{disabled:!o.canSend&&!o.sending,class:t.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center transition-all duration-200 flex-shrink-0",n.value]),type:"button",onClick:s[2]||(s[2]=t.withModifiers(d=>r.$emit("click"),["prevent"]))},[o.sending?(t.openBlock(),t.createElementBlock("svg",Xs,[...s[7]||(s[7]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.5 7.5a3 3 0 013-3h9a3 3 0 013 3v9a3 3 0 01-3 3h-9a3 3 0 01-3-3v-9z","clip-rule":"evenodd"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",Ys,[...s[6]||(s[6]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"},null,-1)])]))],10,Zs)])}}}),ea={class:"max-w-3xl mx-auto space-y-3"},ta=["accept"],na=["title"],oa={class:"flex items-center"},ra=["placeholder","disabled"],sa={key:0,class:"flex justify-center"},Yn=t.defineComponent({__name:"ChatInput",props:{modelValue:{},disabled:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},placeholder:{default:"Ask me anything..."},supportPlaceholder:{default:"Describe your support request..."},minLength:{default:3},suggestions:{default:()=>[]},hasHistory:{type:Boolean,default:!1},supportRequestMode:{type:Boolean,default:!1},showSupportModeToggle:{type:Boolean,default:!1},contextLinkText:{default:""},ui:{},texts:{}},emits:["update:modelValue","submit","cancel","suggestion-select","toggle-support-mode","context-link-click"],setup(o,{emit:e}){const n=o,r=t.computed(()=>n.ui||{}),s=e,a=t.ref(n.modelValue),i=t.ref(null),l=t.ref(null),d=t.ref(!1),u=ts(),p=ns(()=>a.value,T=>{a.value=T},()=>i.value),h=os(()=>n.suggestions,()=>n.hasHistory,()=>d.value,()=>a.value,T=>{s("suggestion-select",T),t.nextTick(()=>{var N;return(N=i.value)==null?void 0:N.focus()})}),{adjustTextareaHeight:x}=rs(()=>i.value),y=t.computed(()=>n.supportRequestMode?n.supportPlaceholder:n.placeholder),f=t.computed(()=>n.showSupportModeToggle?n.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),E=t.computed(()=>{var N;return(((N=a.value)==null?void 0:N.trim())??"").length>=n.minLength?!0:u.hasAttachments.value}),g=t.computed(()=>!n.disabled&&!n.sending&&E.value&&!u.isUploading.value);t.watch(()=>n.modelValue,T=>{a.value=T,t.nextTick(x)}),t.watch(a,T=>{s("update:modelValue",T),t.nextTick(x),p.checkForMentions(T),h.updateSuggestionsVisibility()}),t.watch(()=>n.suggestions,()=>{h.updateSuggestionsVisibility()});function m(){x()}function b(T){if(!p.handleMentionKeyDown(T)&&!h.handleSuggestionKeyDown(T)&&T.key==="Enter"){if(T.shiftKey)return;!n.sending&&g.value&&(T.preventDefault(),C())}}function C(){if(!g.value)return;const T=u.buildPayload(),N=a.value.trim(),D=p.getMentions();s("submit",{message:N,attachments:T,mentions:D,isSupportRequest:n.supportRequestMode}),a.value="",u.clearAttachments(),p.clearMentions(),t.nextTick(x)}function w(){n.sending?s("cancel"):g.value&&C()}function z(){var T;n.disabled||n.sending||u.canAddMore.value&&((T=l.value)==null||T.click())}function $(T){h.handleSuggestionClick(T)}function F(){d.value=!0,h.updateSuggestionsVisibility()}function S(){d.value=!1,setTimeout(()=>{h.hideSuggestions(),p.showMentions.value=!1},200)}return t.onMounted(()=>{t.nextTick(x)}),(T,N)=>{var D;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",r.value.root]),onDragenter:N[6]||(N[6]=t.withModifiers((...M)=>t.unref(u).handleDragEnter&&t.unref(u).handleDragEnter(...M),["prevent"])),onDragover:N[7]||(N[7]=t.withModifiers((...M)=>t.unref(u).handleDragOver&&t.unref(u).handleDragOver(...M),["prevent"])),onDragleave:N[8]||(N[8]=t.withModifiers((...M)=>t.unref(u).handleDragLeave&&t.unref(u).handleDragLeave(...M),["prevent"])),onDrop:N[9]||(N[9]=t.withModifiers((...M)=>t.unref(u).handleDrop&&t.unref(u).handleDrop(...M),["prevent"]))},[t.createElementVNode("form",{onSubmit:t.withModifiers(C,["prevent"]),class:t.normalizeClass(r.value.form)},[t.createElementVNode("div",ea,[t.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:t.unref(u).acceptedFileTypes,onChange:N[0]||(N[0]=(...M)=>t.unref(u).handleFileSelect&&t.unref(u).handleFileSelect(...M))},null,40,ta),t.unref(u).hasAttachments.value?(t.openBlock(),t.createBlock(Vs,{key:0,attachments:t.unref(u).attachments.value,ui:r.value,texts:o.texts,"is-image":t.unref(u).isImage,"format-file-size":t.unref(u).formatFileSize,onRemove:t.unref(u).removeAttachment},null,8,["attachments","ui","texts","is-image","format-file-size","onRemove"])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["relative",r.value.inputContainer])},[t.unref(h).showSuggestions.value&&o.suggestions.length>0?(t.openBlock(),t.createBlock(Ws,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:o.suggestions,"selected-index":t.unref(h).selectedSuggestionIndex.value,ui:r.value,onSelect:$,onHover:N[1]||(N[1]=M=>t.unref(h).selectedSuggestionIndex.value=M)},null,8,["suggestions","selected-index","ui"])):t.createCommentVNode("",!0),t.createVNode(t.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:t.withCtx(()=>[t.unref(p).showMentions.value&&t.unref(p).mentionItems.value.length>0?(t.openBlock(),t.createBlock(Kn,{key:0,items:t.unref(p).mentionItems.value,"selected-index":t.unref(p).selectedMentionIndex.value,providers:t.unref(p).mentionProviders.value,onSelect:t.unref(p).handleMentionSelect,"onUpdate:selectedIndex":N[2]||(N[2]=M=>t.unref(p).selectedMentionIndex.value=M)},null,8,["items","selected-index","providers","onSelect"])):t.createCommentVNode("",!0)]),_:1}),t.createElementVNode("div",{class:t.normalizeClass(["rounded-2xl border shadow-lg transition-all duration-200 bg-white dark:bg-gray-800",[r.value.inputWrapper,{"border-primary shadow-primary/30":d.value||t.unref(u).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!d.value&&!t.unref(u).isDraggingFiles.value}]])},[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["absolute left-3 top-1/2 -translate-y-1/2 h-9 w-9 rounded-xl flex items-center justify-center text-gray-500 dark:text-gray-400 hover:text-primary transition z-10",r.value.attachButton]),title:((D=o.texts)==null?void 0:D.attachFiles)||"Attach files",onClick:z},[...N[10]||(N[10]=[t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M18.375 12.739l-7.693 7.693a4.5 4.5 0 01-6.364-6.364l10.94-10.94A3 3 0 1119.5 7.372L8.552 18.32m.009-.01l-.01.01m5.699-9.941l-7.81 7.81a1.5 1.5 0 002.112 2.13"})],-1)])],10,na),t.createElementVNode("div",oa,[t.withDirectives(t.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":N[3]||(N[3]=M=>a.value=M),rows:"1","data-ai-input":"",placeholder:y.value,disabled:o.disabled,class:t.normalizeClass(["block w-full bg-transparent py-3 text-sm leading-5 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 dark:placeholder:text-gray-500 border-0 focus:outline-none focus-visible:outline-none resize-none",r.value.textarea]),style:t.normalizeStyle(f.value),onInput:m,onKeydown:b,onFocus:F,onBlur:S},null,46,ra),[[t.vModelText,a.value]])]),t.createVNode(Js,{sending:o.sending,"can-send":g.value,"support-request-mode":o.supportRequestMode,"show-support-mode-toggle":o.showSupportModeToggle,ui:r.value,texts:o.texts,onToggleSupportMode:N[4]||(N[4]=M=>T.$emit("toggle-support-mode")),onClick:w},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),t.renderSlot(T.$slots,"context-link",{},()=>[o.contextLinkText?(t.openBlock(),t.createElementBlock("div",sa,[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",r.value.contextLink]),onClick:N[5]||(N[5]=M=>T.$emit("context-link-click"))},t.toDisplayString(o.contextLinkText),3)])):t.createCommentVNode("",!0)])])],34)],34)}}}),aa=["onClick"],Xn=t.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(o,{emit:e}){const n=o,r=e,s=x=>{var f;return(f=n.texts)!=null&&f[x]?n.texts[x]:J({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[x])},a=t.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=jt();function d(x){const y={...x,prompt:l(x)};r("item-click",y)}function u(x){return x.gradientClass?x.gradientClass:x.className?x.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function p(x){const y=x.category||"default",f={hr:"bg-blue-100 dark:bg-blue-900/30",finance:"bg-green-100 dark:bg-green-900/30",analytics:"bg-purple-100 dark:bg-purple-900/30",support:"bg-amber-100 dark:bg-amber-900/30",default:"bg-primary/10"};return f[y]||f.default}function h(x){const y=x.category||"default",f={hr:"text-blue-600 dark:text-blue-400",finance:"text-green-600 dark:text-green-400",analytics:"text-purple-600 dark:text-purple-400",support:"text-amber-600 dark:text-amber-400",default:"text-primary"};return f[y]||f.default}return(x,y)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center justify-center p-4 h-full",a.value.root])},[t.createElementVNode("div",{class:t.normalizeClass(["w-full max-w-4xl",a.value.content])},[t.createElementVNode("div",{class:t.normalizeClass(["mb-8 text-center",a.value.header])},[t.createElementVNode("div",{class:t.normalizeClass(["mb-3 inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary",a.value.badge])},[y[0]||(y[0]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(s("aiName")),1)],2),t.createElementVNode("h1",{class:t.normalizeClass(["mb-3 text-4xl font-bold tracking-tight text-gray-900 dark:text-white",a.value.title])},t.toDisplayString(s("title")),3),t.createElementVNode("p",{class:t.normalizeClass(["text-gray-600 dark:text-gray-400",a.value.description])},t.toDisplayString(s("description")),3)],2),t.createElementVNode("div",{class:t.normalizeClass(["mb-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",a.value.grid])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(i),(f,E)=>(t.openBlock(),t.createElementBlock("button",{key:f.id||E,class:t.normalizeClass(["group relative overflow-hidden rounded-xl border border-gray-300 dark:border-gray-600 p-4 text-left transition-all hover:shadow-md hover:scale-[1.02]",[a.value.suggestionCard,u(f)]]),onClick:g=>d(f)},[t.createElementVNode("div",{class:t.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,p(f)]])},[f.icon?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(f.icon),{key:0,class:t.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]])},null,8,["class"])):(t.openBlock(),t.createElementBlock("svg",{key:1,class:t.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...y[1]||(y[1]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))],2),t.createElementVNode("h3",{class:t.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",a.value.suggestionTitle])},t.toDisplayString(f.title),3),t.createElementVNode("p",{class:t.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},t.toDisplayString(f.description),3)],10,aa))),128))],2)],2)],2))}}),ia={class:"flex items-center gap-3"},la={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},ca={key:1,class:"flex items-center gap-2"},ua={key:0,class:"flex items-center gap-2 ml-auto mr-3"},da=["title"],pa=["title"],fa=["title"],ma={key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ha={key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ga=t.defineComponent({__name:"DrawerHeader",props:{ui:{},isSetupMode:{type:Boolean},showNewChatButton:{type:Boolean},hasHistory:{type:Boolean},showQuota:{type:Boolean},quota:{},showCloseButton:{type:Boolean},showMinimizeButton:{type:Boolean},showFullscreenToggle:{type:Boolean},isFullscreen:{type:Boolean},t:{type:Function}},emits:["new-chat","close","minimize","toggle-fullscreen"],setup(o){return(e,n)=>{var r,s,a,i,l,d;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center justify-between px-4 sm:px-6 pt-4 border-b border-gray-200 dark:border-gray-700 pb-4",(r=o.ui)==null?void 0:r.header])},[t.createElementVNode("div",ia,[o.isSetupMode?(t.openBlock(),t.createElementBlock("div",ca,[...n[5]||(n[5]=[t.createElementVNode("span",{class:"flex h-2 w-2 rounded-full bg-amber-500 animate-pulse"},null,-1),t.createElementVNode("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Setup Required",-1)])])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[o.showNewChatButton&&o.hasHistory?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 transition-all duration-200 shadow-sm",(s=o.ui)==null?void 0:s.newChatButton]),onClick:n[0]||(n[0]=u=>e.$emit("new-chat"))},[n[4]||(n[4]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(o.t("newChat")),1)],2)):(t.openBlock(),t.createElementBlock("span",la,t.toDisplayString(o.t("keyboardShortcutHint")),1))],64))]),o.showQuota&&!o.isSetupMode?(t.openBlock(),t.createElementBlock("div",ua,[t.renderSlot(e.$slots,"quota",{},()=>{var u,p;return[o.quota.remaining>0?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["text-xs text-green-600 dark:text-green-400",(u=o.ui)==null?void 0:u.quotaDisplay])},t.toDisplayString(o.quota.remaining)+" "+t.toDisplayString(o.t("quotaRemaining")),3)):o.quota.remaining===0?(t.openBlock(),t.createElementBlock("span",{key:1,class:t.normalizeClass(["text-xs text-red-600 dark:text-red-400",(p=o.ui)==null?void 0:p.quotaDisplay])},t.toDisplayString(o.t("noQuota")),3)):t.createCommentVNode("",!0)]})])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["flex items-center gap-1",(a=o.ui)==null?void 0:a.headerActions])},[o.showCloseButton?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(i=o.ui)==null?void 0:i.headerActionButton]),title:o.t("close"),onClick:n[1]||(n[1]=u=>e.$emit("close"))},[...n[6]||(n[6]=[t.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,da)):t.createCommentVNode("",!0),o.showMinimizeButton?(t.openBlock(),t.createElementBlock("button",{key:1,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(l=o.ui)==null?void 0:l.headerActionButton]),title:o.t("minimize"),onClick:n[2]||(n[2]=u=>e.$emit("minimize"))},[...n[7]||(n[7]=[t.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"})],-1)])],10,pa)):t.createCommentVNode("",!0),o.showFullscreenToggle?(t.openBlock(),t.createElementBlock("button",{key:2,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(d=o.ui)==null?void 0:d.headerActionButton]),title:o.isFullscreen?o.t("exitFullscreen"):o.t("fullscreen"),onClick:n[3]||(n[3]=u=>e.$emit("toggle-fullscreen"))},[o.isFullscreen?(t.openBlock(),t.createElementBlock("svg",ha,[...n[9]||(n[9]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",ma,[...n[8]||(n[8]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"},null,-1)])]))],10,fa)):t.createCommentVNode("",!0)],2)],2)}}}),ya={class:"max-w-3xl mx-auto px-4 space-y-6"},ka={class:"flex justify-center"},xa={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},wa={key:0,class:"flex justify-center"},ba=["title"],Ea=t.defineComponent({__name:"DrawerMessageList",props:{messages:{},loadingMessage:{},quota:{},error:{},ui:{},t:{type:Function}},emits:["copy","contact-support","retry"],setup(o){return(e,n)=>{var r,s,a;return t.openBlock(),t.createElementBlock("div",ya,[t.createElementVNode("div",ka,[t.createElementVNode("div",xa,[n[3]||(n[3]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(o.t("title")||t.unref(J)("aiName")),1)])]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.messages,(i,l)=>t.renderSlot(e.$slots,"message",{key:i.id||l,message:i,isUser:i.role==="user",isLoading:i.loading,isStreaming:i.streaming},()=>[t.createVNode(Zn,{message:i,"loading-text":o.loadingMessage,onCopy:n[0]||(n[0]=d=>e.$emit("copy",d))},null,8,["message","loading-text"])])),128)),o.quota.remaining===0?(t.openBlock(),t.createElementBlock("div",wa,[t.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 px-6 py-3 bg-primary text-white rounded-lg hover:bg-primary/90 transition-all shadow-sm",onClick:n[1]||(n[1]=i=>e.$emit("contact-support"))},[n[4]||(n[4]=t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(t.unref(J)("contactSupport")),1)])])):t.createCommentVNode("",!0),o.error.message?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["flex items-center gap-2 text-sm text-red-600 dark:text-red-400 px-2 py-1 pb-6",(r=o.ui)==null?void 0:r.errorContainer])},[t.createElementVNode("span",{class:t.normalizeClass((s=o.ui)==null?void 0:s.errorMessage)},t.toDisplayString(o.error.message),3),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["inline-flex items-center gap-1 text-red-700 dark:text-red-300 hover:text-red-800 dark:hover:text-red-200 font-medium",(a=o.ui)==null?void 0:a.retryButton]),title:o.t("retry"),onClick:n[2]||(n[2]=i=>e.$emit("retry"))},[...n[5]||(n[5]=[t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1)])],10,ba)],2)):t.createCommentVNode("",!0)])}}}),Ca={class:"w-full max-w-md"},Sa={class:"bg-gray-900 rounded-xl overflow-hidden"},Ta={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},Aa=t.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(o){return(e,n)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[n[4]||(n[4]=t.createStaticVNode('<div class="w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"><svg class="w-7 h-7 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"></path></svg></div><h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-1"> Almost there! </h2><p class="text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-sm text-center"> Configure the plugin in your app entry file to start using AI. </p>',3)),t.createElementVNode("div",Ca,[t.createElementVNode("div",Sa,[t.createElementVNode("div",Ta,[n[1]||(n[1]=t.createElementVNode("span",{class:"text-xs text-gray-400"},"main.ts",-1)),t.createElementVNode("button",{type:"button",class:"text-xs text-gray-400 hover:text-white transition-colors",onClick:n[0]||(n[0]=r=>e.$emit("copy"))},t.toDisplayString(o.copied?"✓ Copied":"Copy"),1)]),n[2]||(n[2]=t.createStaticVNode(`<pre class="text-xs text-gray-100 p-4 overflow-x-auto leading-relaxed"><code class="language-typescript"><span class="text-purple-400">import</span> { RestifyAiPlugin } <span class="text-purple-400">from</span> <span class="text-green-400">&#39;@doderasoftware/restify-ai&#39;</span>
61
61
 
62
62
  app.<span class="text-yellow-300">use</span>(RestifyAiPlugin, {
63
63
  <span class="text-blue-300">endpoints</span>: {
@@ -65,7 +65,7 @@ app.<span class="text-yellow-300">use</span>(RestifyAiPlugin, {
65
65
  <span class="text-blue-300">quota</span>: <span class="text-green-400">&#39;/api/ai/quota&#39;</span>, <span class="text-gray-500">// optional</span>
66
66
  },
67
67
  <span class="text-blue-300">getAuthToken</span>: () =&gt; <span class="text-yellow-300">getToken</span>(),
68
- })</code></pre>`,1))]),n[3]||(n[3]=t.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[t.createTextVNode(" Need help? Check the "),t.createElementVNode("a",{href:"https://github.com/doderasoftware/restify-ai",target:"_blank",class:"text-primary hover:underline"},"documentation")],-1))])],64))}}),Ma={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center z-10"},Na={key:0,class:"flex items-center gap-3 mb-4"},Ra={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ba={key:1,class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"},La={class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},Da={class:"flex justify-end gap-3"},Jn=t.defineComponent({__name:"ConfirmDialog",props:{show:{type:Boolean},title:{},message:{},confirmText:{},cancelText:{},ui:{},icon:{default:null},confirmVariant:{default:"danger"}},emits:["confirm","cancel"],setup(r){const e=r,n=t.computed(()=>{var s,a;return e.icon==="warning"?(s=e.ui)==null?void 0:s.historyLimitModal:(a=e.ui)==null?void 0:a.closeConfirmModal}),o=t.computed(()=>{var i,l;const s=e.confirmVariant==="danger"?"bg-red-600 hover:bg-red-700":"bg-primary hover:bg-primary/90",a=e.confirmVariant==="danger"?(i=e.ui)==null?void 0:i.closeConfirmButton:(l=e.ui)==null?void 0:l.historyLimitButton;return[s,a]});return(s,a)=>(t.openBlock(),t.createBlock(t.Transition,{"enter-active-class":"transition ease-out duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition ease-in duration-150","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:t.withCtx(()=>{var i;return[r.show?(t.openBlock(),t.createElementBlock("div",Ma,[t.createElementVNode("div",{class:t.normalizeClass(["bg-white dark:bg-gray-800 rounded-xl p-6 m-4 max-w-sm w-full shadow-xl",n.value])},[r.icon==="warning"?(t.openBlock(),t.createElementBlock("div",Na,[a[2]||(a[2]=t.createElementVNode("div",{class:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center"},[t.createElementVNode("svg",{class:"w-5 h-5 text-amber-600 dark:text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})])],-1)),t.createElementVNode("h3",Ra,t.toDisplayString(r.title),1)])):(t.openBlock(),t.createElementBlock("h3",Ba,t.toDisplayString(r.title),1)),t.createElementVNode("p",La,t.toDisplayString(r.message),1),t.createElementVNode("div",Da,[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",(i=r.ui)==null?void 0:i.cancelButton]),onClick:a[0]||(a[0]=l=>s.$emit("cancel"))},t.toDisplayString(r.cancelText),3),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",o.value]),onClick:a[1]||(a[1]=l=>s.$emit("confirm"))},t.toDisplayString(r.confirmText),3)])],2)])):t.createCommentVNode("",!0)]}),_:1}))}}),Ia={key:0,class:"flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto"},$a={key:0,class:"flex-1 flex flex-col overflow-y-auto"},za=Qn(t.defineComponent({__name:"AiChatDrawer",props:{modelValue:{type:Boolean},ui:{},texts:{},width:{default:"600px"},fullscreenWidth:{default:"90vw"},topOffset:{default:"0"},position:{default:"right"},showBackdrop:{type:Boolean,default:!1},closeOnBackdropClick:{type:Boolean,default:!1},closeOnEscape:{type:Boolean,default:!0},showQuota:{type:Boolean,default:!0},showFullscreenToggle:{type:Boolean,default:!0},showMinimizeButton:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0},showNewChatButton:{type:Boolean,default:!0},confirmClose:{type:Boolean,default:!0},historyLimit:{},loadingText:{},autoFetchQuota:{type:Boolean,default:!0}},emits:["update:modelValue","close","contact-support","new-chat"],setup(r,{emit:e}){const n=r,o=e,s=t.computed({get:()=>n.modelValue,set:L=>o("update:modelValue",L)});function a(L,V){var K;const H=(K=n.texts)==null?void 0:K[L];if(H){let W=H;if(V)for(const[G,se]of Object.entries(V))W=W.replace(`{${G}}`,String(se));return W}return J(L,V)}const i=Ae(),l=t.ref(""),d=t.ref(null),u=t.ref(!1),p=t.ref(!1),g=t.ref(!1),{loadingMessage:x,startLoadingText:y,resetLoadingText:f}=Jr(()=>i.sending,()=>n.loadingText),{showHistoryLimitWarning:E,historyLimitReached:h,historyLimitDialogTitle:m,historyLimitDialogMessage:b,dismissHistoryLimitWarning:C,handleHistoryLimitAction:w,checkHistoryLimit:$,setPendingMessage:z}=es({getHistoryLength:()=>i.chatHistory.length,getStoreLimit:()=>i.chatHistoryLimit,getConfig:()=>n.historyLimit,getTexts:()=>n.texts,onStartNewChat:()=>i.clearChatHistory(),onNewChatEmit:()=>o("new-chat")}),F=t.computed(()=>!Ct()),S=t.computed(()=>Se("enableSupportMode")??!1),{suggestions:T,resolvePrompt:N}=jt(),D=t.computed(()=>{if(F.value)return[];const L=l.value.toLowerCase().trim(),V=T.value||[];let H=V;if(L){const K=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]),W=L.split(/\s+/).filter(G=>!K.has(G));W.length>0&&(H=V.filter(G=>{const se=`${G.title} ${G.description||""}`.toLowerCase();return W.every(me=>se.includes(me))}))}return H.slice(0,5).map(K=>({id:K.id,title:K.title,description:K.description||""}))}),M=t.computed(()=>({quota:i.quota,isFullscreen:u.value,hasHistory:i.chatHistory.length>0,onNewChat:Z,onClose:Be,onMinimize:ye,onToggleFullscreen:Re})),Q=t.computed(()=>({modelValue:l.value,sending:i.sending,disabled:!1,onSubmit:ke,onCancel:()=>i.cancelRequest()}));function fe(L){const V=(T.value||[]).find(H=>H.id===L.id);V&&(l.value=N(V))}function Re(){u.value=!u.value}function ye(){s.value=!1}function Be(){n.confirmClose&&!F.value&&i.chatHistory.length>0?g.value=!0:(s.value=!1,o("close"))}function pt(){g.value=!1,i.clearChatHistory(),s.value=!1,o("close")}function Wt(){o("contact-support")}function ft(){i.toggleSupportMode()}async function j(){await t.nextTick();const L=document.getElementById("rai-chat-bottom");L&&L.scrollIntoView({behavior:"smooth",block:"end"})}function Je(L){l.value=L.prompt,i.clearError()}function Z(){i.clearChatHistory(),o("new-chat")}function mt(L){}function v(){navigator.clipboard.writeText(`import { RestifyAiPlugin } from '@doderasoftware/restify-ai'
68
+ })</code></pre>`,1))]),n[3]||(n[3]=t.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[t.createTextVNode(" Need help? Check the "),t.createElementVNode("a",{href:"https://github.com/doderasoftware/restify-ai",target:"_blank",class:"text-primary hover:underline"},"documentation")],-1))])],64))}}),Ma={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center z-10"},Na={key:0,class:"flex items-center gap-3 mb-4"},Ra={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ba={key:1,class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"},La={class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},Da={class:"flex justify-end gap-3"},Jn=t.defineComponent({__name:"ConfirmDialog",props:{show:{type:Boolean},title:{},message:{},confirmText:{},cancelText:{},ui:{},icon:{default:null},confirmVariant:{default:"danger"}},emits:["confirm","cancel"],setup(o){const e=o,n=t.computed(()=>{var s,a;return e.icon==="warning"?(s=e.ui)==null?void 0:s.historyLimitModal:(a=e.ui)==null?void 0:a.closeConfirmModal}),r=t.computed(()=>{var i,l;const s=e.confirmVariant==="danger"?"bg-red-600 hover:bg-red-700":"bg-primary hover:bg-primary/90",a=e.confirmVariant==="danger"?(i=e.ui)==null?void 0:i.closeConfirmButton:(l=e.ui)==null?void 0:l.historyLimitButton;return[s,a]});return(s,a)=>(t.openBlock(),t.createBlock(t.Transition,{"enter-active-class":"transition ease-out duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition ease-in duration-150","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:t.withCtx(()=>{var i;return[o.show?(t.openBlock(),t.createElementBlock("div",Ma,[t.createElementVNode("div",{class:t.normalizeClass(["bg-white dark:bg-gray-800 rounded-xl p-6 m-4 max-w-sm w-full shadow-xl",n.value])},[o.icon==="warning"?(t.openBlock(),t.createElementBlock("div",Na,[a[2]||(a[2]=t.createElementVNode("div",{class:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center"},[t.createElementVNode("svg",{class:"w-5 h-5 text-amber-600 dark:text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})])],-1)),t.createElementVNode("h3",Ra,t.toDisplayString(o.title),1)])):(t.openBlock(),t.createElementBlock("h3",Ba,t.toDisplayString(o.title),1)),t.createElementVNode("p",La,t.toDisplayString(o.message),1),t.createElementVNode("div",Da,[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",(i=o.ui)==null?void 0:i.cancelButton]),onClick:a[0]||(a[0]=l=>s.$emit("cancel"))},t.toDisplayString(o.cancelText),3),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",r.value]),onClick:a[1]||(a[1]=l=>s.$emit("confirm"))},t.toDisplayString(o.confirmText),3)])],2)])):t.createCommentVNode("",!0)]}),_:1}))}}),Ia={key:0,class:"flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto"},za={key:0,class:"flex-1 flex flex-col overflow-y-auto"},$a=Qn(t.defineComponent({__name:"AiChatDrawer",props:{modelValue:{type:Boolean},ui:{},texts:{},width:{default:"600px"},fullscreenWidth:{default:"90vw"},topOffset:{default:"0"},position:{default:"right"},showBackdrop:{type:Boolean,default:!1},closeOnBackdropClick:{type:Boolean,default:!1},closeOnEscape:{type:Boolean,default:!0},showQuota:{type:Boolean,default:!0},showFullscreenToggle:{type:Boolean,default:!0},showMinimizeButton:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0},showNewChatButton:{type:Boolean,default:!0},confirmClose:{type:Boolean,default:!0},historyLimit:{},loadingText:{},autoFetchQuota:{type:Boolean,default:!0}},emits:["update:modelValue","close","contact-support","new-chat"],setup(o,{emit:e}){const n=o,r=e,s=t.computed({get:()=>n.modelValue,set:L=>r("update:modelValue",L)});function a(L,V){var G;const H=(G=n.texts)==null?void 0:G[L];if(H){let W=H;if(V)for(const[K,se]of Object.entries(V))W=W.replace(`{${K}}`,String(se));return W}return J(L,V)}const i=Ce(),l=t.ref(""),d=t.ref(null),u=t.ref(!1),p=t.ref(!1),h=t.ref(!1),{loadingMessage:x,startLoadingText:y,resetLoadingText:f}=Jr(()=>i.sending,()=>n.loadingText),{showHistoryLimitWarning:E,historyLimitReached:g,historyLimitDialogTitle:m,historyLimitDialogMessage:b,dismissHistoryLimitWarning:C,handleHistoryLimitAction:w,checkHistoryLimit:z,setPendingMessage:$}=es({getHistoryLength:()=>i.chatHistory.length,getStoreLimit:()=>i.chatHistoryLimit,getConfig:()=>n.historyLimit,getTexts:()=>n.texts,onStartNewChat:()=>i.clearChatHistory(),onNewChatEmit:()=>r("new-chat")}),F=t.computed(()=>!Ct()),S=t.computed(()=>Te("enableSupportMode")??!1),{suggestions:T,resolvePrompt:N}=jt(),D=t.computed(()=>{if(F.value)return[];const L=l.value.toLowerCase().trim(),V=T.value||[];let H=V;if(L){const G=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]),W=L.split(/\s+/).filter(K=>!G.has(K));W.length>0&&(H=V.filter(K=>{const se=`${K.title} ${K.description||""}`.toLowerCase();return W.every(me=>se.includes(me))}))}return H.slice(0,5).map(G=>({id:G.id,title:G.title,description:G.description||""}))}),M=t.computed(()=>({quota:i.quota,isFullscreen:u.value,hasHistory:i.chatHistory.length>0,onNewChat:Z,onClose:Be,onMinimize:ye,onToggleFullscreen:Re})),Q=t.computed(()=>({modelValue:l.value,sending:i.sending,disabled:!1,onSubmit:ke,onCancel:()=>i.cancelRequest()}));function fe(L){const V=(T.value||[]).find(H=>H.id===L.id);V&&(l.value=N(V))}function Re(){u.value=!u.value}function ye(){s.value=!1}function Be(){n.confirmClose&&!F.value&&i.chatHistory.length>0?h.value=!0:(s.value=!1,r("close"))}function pt(){h.value=!1,i.clearChatHistory(),s.value=!1,r("close")}function Wt(){r("contact-support")}function ft(){i.toggleSupportMode()}async function j(){await t.nextTick();const L=document.getElementById("rai-chat-bottom");L&&L.scrollIntoView({behavior:"smooth",block:"end"})}function Je(L){l.value=L.prompt,i.clearError()}function Z(){i.clearChatHistory(),r("new-chat")}function mt(L){}function v(){navigator.clipboard.writeText(`import { RestifyAiPlugin } from '@doderasoftware/restify-ai'
69
69
 
70
70
  app.use(RestifyAiPlugin, {
71
71
  endpoints: {
@@ -73,4 +73,4 @@ app.use(RestifyAiPlugin, {
73
73
  quota: '/api/ai/quota', // optional
74
74
  },
75
75
  getAuthToken: () => getToken(),
76
- })`),p.value=!0,setTimeout(()=>{p.value=!1},2e3)}async function Le(){const L=await w();L&&(await t.nextTick(),await $e(L.message,L.attachments,L.mentions,L.isSupportRequest))}async function $e(L,V,H,K){i.clearError(),y(),await t.nextTick(),j();const W=await i.askQuestion(L,V,H,K);f(),W&&j()}async function ke(L){const{message:V,attachments:H,mentions:K,isSupportRequest:W}=L;if(i.sending)return;const G=K.map(se=>({id:se.id,name:se.name,type:se.type||"unknown",metadata:se.metadata}));if(!$()){z({message:V,attachments:H,mentions:G,isSupportRequest:W});return}await $e(V,H,G,W)}async function ht(){y();const L=await i.retry();f(),L&&j()}function ze(L){n.closeOnEscape&&L.key==="Escape"&&s.value&&(g.value?g.value=!1:ye())}return t.watch(()=>n.modelValue,L=>{L&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),t.onMounted(()=>{window.addEventListener("keydown",ze)}),t.onUnmounted(()=>{window.removeEventListener("keydown",ze)}),(L,V)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.Transition,{name:"rai-fade"},{default:t.withCtx(()=>{var H;return[s.value&&r.showBackdrop?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["fixed inset-0 bg-black/30 z-40",(H=r.ui)==null?void 0:H.backdrop]),onClick:V[0]||(V[0]=K=>r.closeOnBackdropClick&&ye())},null,2)):t.createCommentVNode("",!0)]}),_:1}),t.createVNode(t.Transition,{name:r.position==="left"?"rai-slide-right":"rai-slide-left"},{default:t.withCtx(()=>{var H,K,W;return[s.value?(t.openBlock(),t.createElementBlock("aside",{key:0,class:t.normalizeClass(["fixed bottom-0 z-50 flex-shrink-0 border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-2xl will-change-transform",[r.position==="left"?"left-0 border-r":"right-0 border-l",(H=r.ui)==null?void 0:H.drawer]]),style:t.normalizeStyle({width:u.value?r.fullscreenWidth:r.width,top:r.topOffset,height:`calc(100vh - ${r.topOffset})`})},[t.createElementVNode("div",{class:t.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(K=r.ui)==null?void 0:K.panel])},[t.renderSlot(L.$slots,"header",t.normalizeProps(t.guardReactiveProps(M.value)),()=>[t.createVNode(ga,{ui:r.ui,"is-setup-mode":F.value,"show-new-chat-button":r.showNewChatButton,"has-history":t.unref(i).chatHistory.length>0,"show-quota":r.showQuota,quota:t.unref(i).quota,"show-close-button":r.showCloseButton,"show-minimize-button":r.showMinimizeButton,"show-fullscreen-toggle":r.showFullscreenToggle,"is-fullscreen":u.value,t:a,onNewChat:Z,onClose:Be,onMinimize:ye,onToggleFullscreen:Re},{quota:t.withCtx(()=>[t.renderSlot(L.$slots,"quota",{quota:t.unref(i).quota},void 0,!0)]),_:3},8,["ui","is-setup-mode","show-new-chat-button","has-history","show-quota","quota","show-close-button","show-minimize-button","show-fullscreen-toggle","is-fullscreen"])],!0),t.createElementVNode("div",{class:t.normalizeClass(["h-full flex flex-col mx-auto w-full overflow-hidden",[{"max-w-5xl":u.value},(W=r.ui)==null?void 0:W.body]])},[F.value?(t.openBlock(),t.createElementBlock("div",Ia,[t.renderSlot(L.$slots,"setup",{},()=>[t.createVNode(Aa,{copied:p.value,onCopy:v},null,8,["copied"])],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.unref(i).chatHistory.length===0?(t.openBlock(),t.createElementBlock("div",$a,[t.renderSlot(L.$slots,"empty-state",{suggestions:D.value,onClick:Je},()=>[t.createVNode(Xn,{onItemClick:Je})],!0)])):(t.openBlock(),t.createElementBlock("div",{key:1,ref_key:"chatContainer",ref:d,class:"flex-1 overflow-y-auto py-6 pb-24"},[t.createVNode(Ea,{messages:t.unref(i).chatHistory,"loading-message":t.unref(x),quota:t.unref(i).quota,error:t.unref(i).error,ui:r.ui,t:a,onCopy:mt,onContactSupport:Wt,onRetry:ht},{message:t.withCtx(G=>[t.renderSlot(L.$slots,"message",{message:G.message,isUser:G.isUser,isLoading:G.isLoading,isStreaming:G.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),V[3]||(V[3]=t.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),t.renderSlot(L.$slots,"input",t.normalizeProps(t.guardReactiveProps(Q.value)),()=>{var G,se;return[t.createVNode(Yn,{modelValue:l.value,"onUpdate:modelValue":V[1]||(V[1]=me=>l.value=me),sending:t.unref(i).sending,placeholder:((G=n.texts)==null?void 0:G.placeholder)||t.unref(J)("inputPlaceholder"),"support-placeholder":((se=n.texts)==null?void 0:se.supportPlaceholder)||t.unref(J)("supportPlaceholder"),suggestions:D.value,"has-history":t.unref(i).chatHistory.length>0,"support-request-mode":t.unref(i).supportRequestMode,"show-support-mode-toggle":S.value,onSubmit:ke,onCancel:t.unref(i).cancelRequest,onSuggestionSelect:fe,onToggleSupportMode:ft},{"context-link":t.withCtx(()=>[t.renderSlot(L.$slots,"context-link",{},void 0,!0)]),_:3},8,["modelValue","sending","placeholder","support-placeholder","suggestions","has-history","support-request-mode","show-support-mode-toggle","onCancel"])]},!0)],64))],2)],2),t.createVNode(Jn,{show:g.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:r.ui,"confirm-variant":"danger",onConfirm:pt,onCancel:V[2]||(V[2]=G=>g.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),t.createVNode(Jn,{show:t.unref(E),title:t.unref(m),message:t.unref(b),"confirm-text":a("startNewChat"),"cancel-text":t.unref(h)?a("continueChat"):a("cancel"),ui:r.ui,icon:"warning","confirm-variant":"primary",onConfirm:Le,onCancel:t.unref(C)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):t.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-e286ec63"]]),eo={install(r,e){if(!e.endpoints||!e.getAuthToken){console.warn("[@doderasoftware/restify-ai] Plugin requires endpoints and getAuthToken options.");return}const n={endpoints:e.endpoints,baseUrl:e.baseUrl,getAuthToken:e.getAuthToken,getCustomHeaders:e.getCustomHeaders,buildRequest:e.buildRequest,parseStreamContent:e.parseStreamContent,requestInterceptor:e.requestInterceptor,responseInterceptor:e.responseInterceptor,retry:e.retry,translate:e.translate,can:e.can,labels:{...Et,...e.labels},mentionProviders:e.mentionProviders,suggestionProviders:e.suggestionProviders,defaultSuggestions:e.defaultSuggestions,theme:e.theme,chatHistoryLimit:e.chatHistoryLimit,maxAttachments:e.maxAttachments,maxFileSize:e.maxFileSize,acceptedFileTypes:e.acceptedFileTypes,chatHistoryKey:e.chatHistoryKey,drawerStateKey:e.drawerStateKey,keyboardShortcut:e.keyboardShortcut,enableSupportMode:e.enableSupportMode,canToggle:e.canToggle,assistantAvatar:e.assistantAvatar,userAvatar:e.userAvatar,onQuotaFetched:e.onQuotaFetched,onError:e.onError,onMessageSent:e.onMessageSent,onResponseReceived:e.onResponseReceived,onDrawerToggle:e.onDrawerToggle,onNewChat:e.onNewChat,onStreamStart:e.onStreamStart,onStreamEnd:e.onStreamEnd,onStreamChunk:e.onStreamChunk,beforeSend:e.beforeSend,afterResponse:e.afterResponse,onFileUploadStart:e.onFileUploadStart,onFileUploadProgress:e.onFileUploadProgress,onFileUploadComplete:e.onFileUploadComplete,onFileUploadError:e.onFileUploadError};en(n),r.provide("restify-ai-config",n)}};B.AiAvatar=Wn,B.AiChatDrawer=za,B.AiEmptyState=Xn,B.ChatInput=Yn,B.ChatMessage=Zn,B.ChatMessageActions=Kn,B.ChatRoles=Te,B.MentionList=Gn,B.RestifyAiPlugin=eo,B.UserAvatar=ss,B.default=eo,B.defaultLabels=Et,B.formatMentionsForApi=fn,B.getConfigValue=Se,B.getLabel=J,B.getRestifyAiConfig=q,B.getRestifyAiConfigOrThrow=bo,B.getSuggestionsForPath=vn,B.groupMentionsByType=mn,B.isConfigured=Ct,B.registerSuggestionProvider=Kr,B.setRestifyAiConfig=en,B.useAiContext=vt,B.useAiDrawerShortcut=Xr,B.useAiSuggestions=jt,B.useChatErrorHandling=vr,B.useChatMarkdown=Un,B.useChatScroll=qr,B.useKeyboardShortcut=jn,B.useMentionParsing=Uo,B.usePageAiContext=Qr,B.useRestifyAiStore=Ae,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
76
+ })`),p.value=!0,setTimeout(()=>{p.value=!1},2e3)}async function Le(){const L=await w();L&&(await t.nextTick(),await ze(L.message,L.attachments,L.mentions,L.isSupportRequest))}async function ze(L,V,H,G){i.clearError(),y(),await t.nextTick(),j();const W=await i.askQuestion(L,V,H,G);f(),W&&j()}async function ke(L){const{message:V,attachments:H,mentions:G,isSupportRequest:W}=L;if(i.sending)return;const K=G.map(se=>({id:se.id,name:se.name,type:se.type||"unknown",metadata:se.metadata}));if(!z()){$({message:V,attachments:H,mentions:K,isSupportRequest:W});return}await ze(V,H,K,W)}async function ht(){y();const L=await i.retry();f(),L&&j()}function $e(L){n.closeOnEscape&&L.key==="Escape"&&s.value&&(h.value?h.value=!1:ye())}return t.watch(()=>n.modelValue,L=>{L&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),t.onMounted(()=>{window.addEventListener("keydown",$e)}),t.onUnmounted(()=>{window.removeEventListener("keydown",$e)}),(L,V)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.Transition,{name:"rai-fade"},{default:t.withCtx(()=>{var H;return[s.value&&o.showBackdrop?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["fixed inset-0 bg-black/30 z-40",(H=o.ui)==null?void 0:H.backdrop]),onClick:V[0]||(V[0]=G=>o.closeOnBackdropClick&&ye())},null,2)):t.createCommentVNode("",!0)]}),_:1}),t.createVNode(t.Transition,{name:o.position==="left"?"rai-slide-right":"rai-slide-left"},{default:t.withCtx(()=>{var H,G,W;return[s.value?(t.openBlock(),t.createElementBlock("aside",{key:0,class:t.normalizeClass(["fixed bottom-0 z-50 flex-shrink-0 border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-2xl will-change-transform",[o.position==="left"?"left-0 border-r":"right-0 border-l",(H=o.ui)==null?void 0:H.drawer]]),style:t.normalizeStyle({width:u.value?o.fullscreenWidth:o.width,top:o.topOffset,height:`calc(100vh - ${o.topOffset})`})},[t.createElementVNode("div",{class:t.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(G=o.ui)==null?void 0:G.panel])},[t.renderSlot(L.$slots,"header",t.normalizeProps(t.guardReactiveProps(M.value)),()=>[t.createVNode(ga,{ui:o.ui,"is-setup-mode":F.value,"show-new-chat-button":o.showNewChatButton,"has-history":t.unref(i).chatHistory.length>0,"show-quota":o.showQuota,quota:t.unref(i).quota,"show-close-button":o.showCloseButton,"show-minimize-button":o.showMinimizeButton,"show-fullscreen-toggle":o.showFullscreenToggle,"is-fullscreen":u.value,t:a,onNewChat:Z,onClose:Be,onMinimize:ye,onToggleFullscreen:Re},{quota:t.withCtx(()=>[t.renderSlot(L.$slots,"quota",{quota:t.unref(i).quota},void 0,!0)]),_:3},8,["ui","is-setup-mode","show-new-chat-button","has-history","show-quota","quota","show-close-button","show-minimize-button","show-fullscreen-toggle","is-fullscreen"])],!0),t.createElementVNode("div",{class:t.normalizeClass(["h-full flex flex-col mx-auto w-full overflow-hidden",[{"max-w-5xl":u.value},(W=o.ui)==null?void 0:W.body]])},[F.value?(t.openBlock(),t.createElementBlock("div",Ia,[t.renderSlot(L.$slots,"setup",{},()=>[t.createVNode(Aa,{copied:p.value,onCopy:v},null,8,["copied"])],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.unref(i).chatHistory.length===0?(t.openBlock(),t.createElementBlock("div",za,[t.renderSlot(L.$slots,"empty-state",{suggestions:D.value,onClick:Je},()=>[t.createVNode(Xn,{onItemClick:Je})],!0)])):(t.openBlock(),t.createElementBlock("div",{key:1,ref_key:"chatContainer",ref:d,class:"flex-1 overflow-y-auto py-6 pb-24"},[t.createVNode(Ea,{messages:t.unref(i).chatHistory,"loading-message":t.unref(x),quota:t.unref(i).quota,error:t.unref(i).error,ui:o.ui,t:a,onCopy:mt,onContactSupport:Wt,onRetry:ht},{message:t.withCtx(K=>[t.renderSlot(L.$slots,"message",{message:K.message,isUser:K.isUser,isLoading:K.isLoading,isStreaming:K.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),V[3]||(V[3]=t.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),t.renderSlot(L.$slots,"input",t.normalizeProps(t.guardReactiveProps(Q.value)),()=>{var K,se;return[t.createVNode(Yn,{modelValue:l.value,"onUpdate:modelValue":V[1]||(V[1]=me=>l.value=me),sending:t.unref(i).sending,placeholder:((K=n.texts)==null?void 0:K.placeholder)||t.unref(J)("inputPlaceholder"),"support-placeholder":((se=n.texts)==null?void 0:se.supportPlaceholder)||t.unref(J)("supportPlaceholder"),suggestions:D.value,"has-history":t.unref(i).chatHistory.length>0,"support-request-mode":t.unref(i).supportRequestMode,"show-support-mode-toggle":S.value,onSubmit:ke,onCancel:t.unref(i).cancelRequest,onSuggestionSelect:fe,onToggleSupportMode:ft},{"context-link":t.withCtx(()=>[t.renderSlot(L.$slots,"context-link",{},void 0,!0)]),_:3},8,["modelValue","sending","placeholder","support-placeholder","suggestions","has-history","support-request-mode","show-support-mode-toggle","onCancel"])]},!0)],64))],2)],2),t.createVNode(Jn,{show:h.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:o.ui,"confirm-variant":"danger",onConfirm:pt,onCancel:V[2]||(V[2]=K=>h.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),t.createVNode(Jn,{show:t.unref(E),title:t.unref(m),message:t.unref(b),"confirm-text":a("startNewChat"),"cancel-text":t.unref(g)?a("continueChat"):a("cancel"),ui:o.ui,icon:"warning","confirm-variant":"primary",onConfirm:Le,onCancel:t.unref(C)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):t.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-e286ec63"]]),eo={install(o,e){if(!e.endpoints||!e.getAuthToken){console.warn("[@doderasoftware/restify-ai] Plugin requires endpoints and getAuthToken options.");return}const n={endpoints:e.endpoints,baseUrl:e.baseUrl,getAuthToken:e.getAuthToken,getCustomHeaders:e.getCustomHeaders,buildRequest:e.buildRequest,parseStreamContent:e.parseStreamContent,requestInterceptor:e.requestInterceptor,responseInterceptor:e.responseInterceptor,retry:e.retry,translate:e.translate,can:e.can,labels:{...Et,...e.labels},mentionProviders:e.mentionProviders,suggestionProviders:e.suggestionProviders,defaultSuggestions:e.defaultSuggestions,theme:e.theme,chatHistoryLimit:e.chatHistoryLimit,maxAttachments:e.maxAttachments,maxFileSize:e.maxFileSize,acceptedFileTypes:e.acceptedFileTypes,chatHistoryKey:e.chatHistoryKey,drawerStateKey:e.drawerStateKey,keyboardShortcut:e.keyboardShortcut,enableSupportMode:e.enableSupportMode,canToggle:e.canToggle,assistantAvatar:e.assistantAvatar,userAvatar:e.userAvatar,onQuotaFetched:e.onQuotaFetched,onError:e.onError,onMessageSent:e.onMessageSent,onResponseReceived:e.onResponseReceived,onDrawerToggle:e.onDrawerToggle,onNewChat:e.onNewChat,onStreamStart:e.onStreamStart,onStreamEnd:e.onStreamEnd,onStreamChunk:e.onStreamChunk,beforeSend:e.beforeSend,afterResponse:e.afterResponse,onFileUploadStart:e.onFileUploadStart,onFileUploadProgress:e.onFileUploadProgress,onFileUploadComplete:e.onFileUploadComplete,onFileUploadError:e.onFileUploadError};en(n),o.provide("restify-ai-config",n)}};B.AiAvatar=Wn,B.AiChatDrawer=$a,B.AiEmptyState=Xn,B.ChatInput=Yn,B.ChatMessage=Zn,B.ChatMessageActions=Gn,B.ChatRoles=Ae,B.MentionList=Kn,B.RestifyAiPlugin=eo,B.UserAvatar=ss,B.default=eo,B.defaultLabels=Et,B.formatMentionsForApi=fn,B.getConfigValue=Te,B.getLabel=J,B.getRestifyAiConfig=q,B.getRestifyAiConfigOrThrow=bo,B.getSuggestionsForPath=vn,B.groupMentionsByType=mn,B.isConfigured=Ct,B.registerSuggestionProvider=Gr,B.setRestifyAiConfig=en,B.useAiContext=vt,B.useAiDrawerShortcut=Xr,B.useAiSuggestions=jt,B.useChatErrorHandling=vr,B.useChatMarkdown=Un,B.useChatScroll=qr,B.useKeyboardShortcut=jn,B.useMentionParsing=Uo,B.usePageAiContext=Qr,B.useRestifyAiStore=Ce,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});