@doderasoftware/restify-ai 0.2.0-beta.2 → 0.2.0-beta.3

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.
Files changed (46) hide show
  1. package/README.md +253 -14
  2. package/dist/components/AiChatDrawer.vue.d.ts +25 -3
  3. package/dist/components/AiChatDrawer.vue.d.ts.map +1 -1
  4. package/dist/components/ChatInput.vue.d.ts +10 -0
  5. package/dist/components/ChatInput.vue.d.ts.map +1 -1
  6. package/dist/components/ChatMessage.vue.d.ts.map +1 -1
  7. package/dist/components/drawer/ConversationHistory.vue.d.ts +3 -0
  8. package/dist/components/drawer/ConversationHistory.vue.d.ts.map +1 -0
  9. package/dist/components/drawer/DrawerHeader.vue.d.ts +4 -0
  10. package/dist/components/drawer/DrawerHeader.vue.d.ts.map +1 -1
  11. package/dist/components/drawer/DrawerMessageList.vue.d.ts.map +1 -1
  12. package/dist/components/icons/IconHistory.vue.d.ts +3 -0
  13. package/dist/components/icons/IconHistory.vue.d.ts.map +1 -0
  14. package/dist/components/icons/IconMicrophone.vue.d.ts +3 -0
  15. package/dist/components/icons/IconMicrophone.vue.d.ts.map +1 -0
  16. package/dist/components/icons/IconMicrophoneOff.vue.d.ts +3 -0
  17. package/dist/components/icons/IconMicrophoneOff.vue.d.ts.map +1 -0
  18. package/dist/components/icons/index.d.ts +3 -0
  19. package/dist/components/icons/index.d.ts.map +1 -1
  20. package/dist/components/input/AudioWave.vue.d.ts +29 -0
  21. package/dist/components/input/AudioWave.vue.d.ts.map +1 -0
  22. package/dist/components/input/InputActions.vue.d.ts +24 -3
  23. package/dist/components/input/InputActions.vue.d.ts.map +1 -1
  24. package/dist/composables/useChatInput.d.ts +2 -0
  25. package/dist/composables/useChatInput.d.ts.map +1 -1
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/index.d.ts +5 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/restify-ai.js +2962 -2388
  30. package/dist/restify-ai.umd.cjs +52 -52
  31. package/dist/store/storage.d.ts +10 -1
  32. package/dist/store/storage.d.ts.map +1 -1
  33. package/dist/store/store.d.ts +42 -0
  34. package/dist/store/store.d.ts.map +1 -1
  35. package/dist/style.css +1 -1
  36. package/dist/types/chat.d.ts +12 -0
  37. package/dist/types/chat.d.ts.map +1 -1
  38. package/dist/types/config.d.ts +28 -1
  39. package/dist/types/config.d.ts.map +1 -1
  40. package/dist/types/index.d.ts +2 -2
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/dist/types/texts.d.ts +8 -0
  43. package/dist/types/texts.d.ts.map +1 -1
  44. package/dist/types/ui.d.ts +11 -3
  45. package/dist/types/ui.d.ts.map +1 -1
  46. package/package.json +1 -1
@@ -1,63 +1,63 @@
1
- (function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R.RestifyAi={},R.Vue,R.Pinia))})(this,function(R,e,De){"use strict";var Oi=Object.defineProperty;var Pi=(R,e,De)=>e in R?Oi(R,e,{enumerable:!0,configurable:!0,writable:!0,value:De}):R[e]=De;var q=(R,e,De)=>Pi(R,typeof e!="symbol"?e+"":e,De);let Ne=null;const Mr=e.ref(null),Bt={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",rateLimitExceeded:"Rate limit exceeded. Please try again in a moment.",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 ln(r){Ne=r,Mr.value=r}function K(){return Ne}function Br(){if(!Ne)throw new Error("[restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Ne}function Nt(){return Ne!==null}function te(r,t){const n=Ne,o=(n==null?void 0:n.labels)||{},s=n==null?void 0:n.translate;if(s){const i=s(r,t);if(i!==r)return i}let a=o[r]||Bt[r];return t&&Object.entries(t).forEach(([i,l])=>{a=a.replace(`{${i}}`,String(l))}),a}function cn(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 ke(r){const t=Ne;return t?t[r]??cn(r):cn(r)}function it(r){return(r.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(r.name||"")}function lt(r){if(r==null)return"";const t=typeof r=="string"?parseInt(r,10):r;return Number.isNaN(t)?"":t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}const Re={Assistant:"assistant",User:"user",System:"system"};async function Nr(r,t){const n=r.getReader();let o;for(;!(o=await n.read()).done;)t(o.value)}function Rr(r){let t,n,o,s=!1;return function(i){t===void 0?(t=i,n=0,o=-1):t=Lr(t,i);const l=t.length;let u=0;for(;n<l;){s&&(t[n]===10&&(u=++n),s=!1);let d=-1;for(;n<l&&d===-1;++n)switch(t[n]){case 58:o===-1&&(o=n-u);break;case 13:s=!0;case 10:d=n;break}if(d===-1)break;r(t.subarray(u,d),o),u=n,o=-1}u===l?t=void 0:u!==0&&(t=t.subarray(u),n-=u)}}function _r(r,t,n){let o=un();const s=new TextDecoder;return function(i,l){if(i.length===0)n==null||n(o),o=un();else if(l>0){const u=s.decode(i.subarray(0,l)),d=l+(i[l+1]===32?2:1),m=s.decode(i.subarray(d));switch(u){case"data":o.data=o.data?o.data+`
2
- `+m:m;break;case"event":o.event=m;break;case"id":r(o.id=m);break;case"retry":const h=parseInt(m,10);isNaN(h)||t(o.retry=h);break}}}}function Lr(r,t){const n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),n}function un(){return{data:"",event:"",id:"",retry:void 0}}var Ir=function(r,t){var n={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&t.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++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(r,o[s])&&(n[o[s]]=r[o[s]]);return n};const Rt="text/event-stream",$r=1e3,dn="last-event-id";function Dr(r,t){var{signal:n,headers:o,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:u,fetch:d}=t,m=Ir(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((h,g)=>{const y=Object.assign({},o);y.accept||(y.accept=Rt);let f;function S(){f.abort(),document.hidden||I()}u||document.addEventListener("visibilitychange",S);let p=$r,w=0;function M(){document.removeEventListener("visibilitychange",S),window.clearTimeout(w),f.abort()}n==null||n.addEventListener("abort",()=>{M(),h()});const x=d??window.fetch,C=s??zr;async function I(){var b;f=new AbortController;try{const N=await x(r,Object.assign(Object.assign({},m),{headers:y,signal:f.signal}));await C(N),await Nr(N.body,Rr(_r(L=>{L?y[dn]=L:delete y[dn]},L=>{p=L},a))),i==null||i(),M(),h()}catch(N){if(!f.signal.aborted)try{const L=(b=l==null?void 0:l(N))!==null&&b!==void 0?b:p;window.clearTimeout(w),w=window.setTimeout(I,L)}catch(L){M(),g(L)}}}I()})}function zr(r){const t=r.headers.get("content-type");if(!(t!=null&&t.startsWith(Rt)))throw new Error(`Expected content-type to be ${Rt}, Actual: ${t}`)}function ct(r){if(!r)throw console.error("[RestifyAi] Endpoint is undefined. Check your endpoints configuration."),new Error("AI service endpoint is not configured. Please contact support.");const t=K(),n=(t==null?void 0:t.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 Or(r){const n=(r instanceof Error?r.message:String(r)).toLowerCase();return n.includes("failed to fetch")||n.includes("network")||n.includes("fetch")?"Unable to connect to the AI service. Please check your internet connection and try again.":n.includes("500")||n.includes("internal server error")?"The AI service is temporarily unavailable. Please try again in a few moments.":n.includes("timeout")||n.includes("timed out")?"The request took too long. Please try again.":n.includes("401")||n.includes("unauthorized")||n.includes("authentication")?"Your session has expired. Please refresh the page and try again.":n.includes("429")||n.includes("rate limit")||n.includes("too many requests")?"Too many requests. Please wait a moment before trying again.":n.includes("cors")||n.includes("cross-origin")?"Unable to connect to the AI service. Please contact support.":n.includes("endpoint is not configured")?"AI service endpoint is not configured. Please contact support.":"Something went wrong. Please try again later."}function Pr(r,t){var n,o,s;try{if(t==="done"||r==="[DONE]")return"[DONE]";const a=JSON.parse(r);return(a==null?void 0:a.content)!==void 0?a.content:((s=(o=(n=a==null?void 0:a.choices)==null?void 0:n[0])==null?void 0:o.delta)==null?void 0:s.content)||null}catch{return null}}function Vr(r){return new Promise(t=>setTimeout(t,r))}function Fr(r){const t={};return r.forEach(n=>{var o;(o=n.attachments)==null||o.forEach(s=>{s!=null&&s.id&&(t[s.id]=s)})}),t}function Te(r){const t=K();return r==="chatHistory"?(t==null?void 0:t.chatHistoryKey)||"restify_ai_chat_history":r==="setupComplete"?"restify_ai_setup_complete":(t==null?void 0:t.drawerStateKey)||"restify_ai_drawer_open"}function qe(r){try{sessionStorage.setItem(Te("chatHistory"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save chat history:",t)}}function Hr(){try{const r=sessionStorage.getItem(Te("chatHistory"));if(r){const t=JSON.parse(r),n=t.filter(a=>{var i;return!(a.role===Re.Assistant&&a.loading||a.role===Re.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==t.length&&sessionStorage.setItem(Te("chatHistory"),JSON.stringify(n));const o=n[n.length-1],s=(o==null?void 0:o.role)===Re.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 Ur(){try{sessionStorage.removeItem(Te("chatHistory"))}catch(r){console.warn("[RestifyAi] Failed to clear chat history:",r)}}function qr(r){try{r.message||r.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(r)):sessionStorage.removeItem("restify_ai_error_state")}catch(t){console.warn("[RestifyAi] Failed to save error state:",t)}}function jr(){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 Wr(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(r){console.warn("[RestifyAi] Failed to clear error state:",r)}}function _t(r){try{localStorage.setItem(Te("drawerState"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save drawer state:",t)}}function Kr(){try{const r=localStorage.getItem(Te("drawerState"));if(r!==null)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load drawer state:",r)}return!1}function Gr(){try{return localStorage.getItem(Te("setupComplete"))==="true"}catch{return!1}}function mn(){try{localStorage.setItem(Te("setupComplete"),"true")}catch(r){console.warn("[RestifyAi] Failed to mark setup complete:",r)}}function fn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}let je=new AbortController;function Qr(r,t){return r!=null&&r.message?{message:r.message,failedQuestion:r.failedQuestion,failedAttachments:r.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:t.hasOrphanedUserMessage&&t.orphanedMessage?{message:"Previous request failed. Click retry to try again.",failedQuestion:t.orphanedMessage.question,failedAttachments:t.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}:{message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1}}function Zr(r){const t=ke("chatHistoryLimit")||10;return{limit:t,used:r,remaining:Math.max(0,t-r)}}function Yr(){return!Nt()&&!Gr()?{...fn(),isActive:!0}:fn()}const Ae=De.defineStore("restifyAiStore",{state:()=>{const r=Hr(),t=jr(),n=r.history.filter(o=>o.role==="user").length;return{chatHistoryLimit:ke("chatHistoryLimit")||20,chatHistory:r.history,uploadedFiles:Fr(r.history),loading:!1,showChat:Kr(),isFullscreen:!1,sending:!1,pageContext:null,quota:Zr(n),error:Qr(t,r),supportRequestMode:!1,setupState:Yr()}},getters:{hasMessages:r=>r.chatHistory.length>0,isInSetupMode:r=>r.setupState.isActive,canChat:r=>!r.setupState.isActive||r.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(r=0){await e.nextTick(),r>0&&await new Promise(n=>setTimeout(n,r));const t=document.getElementById("rai-chat-bottom");t&&t.scrollIntoView({behavior:"smooth"})},parseStreamContent(r,t){const n=K(),o=n==null?void 0:n.parseStreamContent;return o?o(t,r):Pr(t,r)},async askQuestion(r,t=[],n=[],o=!1){var y;const s=K();if(!s)return console.warn("[RestifyAi] Cannot ask question - plugin not configured"),!1;let a="",i=!1;const l=s.retry||{},u=l.maxRetries??0,d=l.retryDelay??1e3;let m=0;const h=t.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:Re.User,message:r,loading:!1,attachments:h,mentions:n,timestamp:Date.now()}),h.forEach(f=>this.registerUploadedFile(f)),qe(this.chatHistory),this.sending=!0,this.quota.remaining>0&&!o&&(this.quota.remaining--,this.quota.used++),this.scrollToBottom(),this.chatHistory.length>=this.chatHistoryLimit&&((y=s.onError)==null||y.call(s,new Error("Chat history limit reached")));const g=async()=>{var f,S,p;try{const w=this.chatHistory.map(_=>({role:_.role,content:_.message})),M={},x=_=>{_!=null&&_.id&&(M[_.id]={extracted_text:_.extractedText||"",file_name:_.name,mime_type:_.type||"",..._.size?{file_size:_.size}:{},..._.url?{file_url:_.url}:{}})};Object.values(this.uploadedFiles).forEach(x),this.chatHistory.forEach(_=>{var O;return(O=_.attachments)==null?void 0:O.forEach(x)}),h.forEach(x);const C=Object.values(M),I=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Re.Assistant,message:"",loading:!0,timestamp:Date.now()}),qe(this.chatHistory),je=new AbortController,this.scrollToBottom();const b=await s.getAuthToken(),L={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?L["X-Test-Api-Key"]=this.setupState.testApiKey:b&&(L.Authorization=`Bearer ${b}`);const A={};if(typeof window<"u"){A.route=window.location.pathname;const _=new URLSearchParams(window.location.search),O={};_.forEach((z,ne)=>{O[ne]=z}),Object.keys(O).length>0&&(A.query=O),document.title&&(A.pageTitle=document.title)}n.length>0&&(A.mentionedEntities=n.map(_=>({type:_.type,id:_.id,displayName:_.name,metadata:_.metadata})));let B={message:r,history:w,stream:!0,...C.length>0&&{files:C},...Object.keys(A).length>0&&{context:A},...this.supportRequestMode&&{contact_support:!0},...s.model&&{model:s.model},...s.temperature&&{temperature:s.temperature},...s.maxTokens&&{max_tokens:s.maxTokens}};s.beforeSend&&(B=await s.beforeSend(B)),s.buildRequest&&(B=await s.buildRequest(B)),(f=s.onMessageSent)==null||f.call(s,this.chatHistory[I-1]);const V=ct(s.endpoints.ask);let G={method:"POST",body:JSON.stringify(B),headers:L};return s.requestInterceptor&&(G=await s.requestInterceptor(V,G)),(S=s.onStreamStart)==null||S.call(s),await Dr(V,{method:"POST",body:JSON.stringify(B),signal:je.signal,headers:G.headers,openWhenHidden:!0,async onopen(_){if(!_.ok){if(_.status===429){const O=Ae();throw O.error={message:te("rateLimitExceeded"),failedQuestion:r,failedAttachments:h,timestamp:Date.now(),quotaExceeded:!0,rateLimited:!0},s.useQuota!==!1&&await O.fetchQuota(),new Error("Rate limit exceeded")}throw new Error(`Failed to connect: ${_.status}`)}},onmessage:async _=>{var ne,be,U;const O=this.parseStreamContent(_.event,_.data);if(!O)return;this.chatHistory[I].loading=!1;const z={content:O,done:O==="[DONE]",raw:_.data};(ne=s.onStreamChunk)==null||ne.call(s,z),a?O==="[DONE]"?(this.chatHistory[I].streaming=!1,qe(this.chatHistory),(be=s.onStreamEnd)==null||be.call(s,a),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[I]),(U=s.onResponseReceived)==null||U.call(s,this.chatHistory[I])):(a+=O,this.chatHistory[I].message=a):(a=O,this.chatHistory[I].message=a,this.chatHistory[I].streaming=!0),await this.scrollToBottom()},onclose:()=>{var _,O;a&&!i&&(this.chatHistory[I].streaming=!1,this.chatHistory[I].loading=!1,qe(this.chatHistory),(_=s.onStreamEnd)==null||_.call(s,a),s.afterResponse&&s.afterResponse(this.chatHistory[I]),(O=s.onResponseReceived)==null||O.call(s,this.chatHistory[I]))},onerror:_=>{if(!a)throw i=!0,_}}),!0}catch(w){i=!0;const M=this.chatHistory.length-1;return this.chatHistory.splice(M,1),w.name==="AbortError"?!0:m<u&&(l.shouldRetry?l.shouldRetry(w,m):!0)?(m++,await Vr(d*m),g()):(this.error={message:Or(w),failedQuestion:r,failedAttachments:h,timestamp:Date.now()},qr({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(p=s.onError)==null||p.call(s,w),!1)}finally{this.sending=!1}};return g()},cancelRequest(){je==null||je.abort(),this.chatHistory=this.chatHistory.map(r=>({...r,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var n;const r=K();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1);const t=ke("chatHistoryLimit")||10;this.quota={limit:t,used:0,remaining:t},Ur(),(n=r==null?void 0:r.onNewChat)==null||n.call(r)},async retry(){if(!this.error.failedQuestion)return!1;const r=this.error.failedQuestion,t=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Re.User&&n.message===r&&(this.chatHistory.pop(),qe(this.chatHistory)),this.clearError(),await this.askQuestion(r,t)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},Wr()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var t,n;const r=K();if((r==null?void 0:r.useQuota)!==!1&&(t=r==null?void 0:r.endpoints)!=null&&t.quota)try{const o=await r.getAuthToken(),s=r.getCustomHeaders?await r.getCustomHeaders():{},a=ct(r.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...o?{Authorization:`Bearer ${o}`}:{},...s}});if(i.ok){const l=await i.json(),u=l.data??l;this.quota={limit:u.limit??this.quota.limit,used:u.used??this.quota.used,remaining:u.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,u;const t=K();if(!((s=t==null?void 0:t.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=t.onFileUploadStart)==null||a.call(t,o);try{const d=await t.getAuthToken(),m=t.getCustomHeaders?await t.getCustomHeaders():{},h=ct(t.endpoints.uploadFile),g=new FormData;g.append("file",r);const y=await new Promise((f,S)=>{const p=new XMLHttpRequest;p.upload.addEventListener("progress",w=>{var M;if(w.lengthComputable){const x=Math.round(w.loaded/w.total*100);o.progress=x,(M=t.onFileUploadProgress)==null||M.call(t,o,x)}}),p.addEventListener("load",()=>{var w,M;if(p.status>=200&&p.status<300)try{const x=JSON.parse(p.responseText),C={...o,url:x.url||((w=x.data)==null?void 0:w.url),extractedText:x.extracted_text||((M=x.data)==null?void 0:M.extracted_text),uploading:!1,progress:100};f(C)}catch{S(new Error("Failed to parse upload response"))}else S(new Error(`Upload failed: ${p.status}`))}),p.addEventListener("error",()=>S(new Error("Upload failed"))),p.open("POST",h),d&&p.setRequestHeader("Authorization",`Bearer ${d}`),Object.entries(m).forEach(([w,M])=>p.setRequestHeader(w,M)),p.send(g)});return(i=t.onFileUploadComplete)==null||i.call(t,y),y}catch(d){const m={...o,uploading:!1};return(l=t.onFileUploadError)==null||l.call(t,m,d),(u=t.onError)==null||u.call(t,d),null}},setPageContext(r){this.pageContext=r},toggleDrawer(){var r,t;this.showChat=!this.showChat,_t(this.showChat),(t=(r=K())==null?void 0:r.onDrawerToggle)==null||t.call(r,this.showChat),this.showChat&&this.scrollToBottom(100)},openDrawer(){var r,t;this.showChat=!0,_t(!0),(t=(r=K())==null?void 0:r.onDrawerToggle)==null||t.call(r,!0),this.scrollToBottom(100)},closeDrawer(){var r,t;this.showChat=!1,_t(!1),(t=(r=K())==null?void 0:r.onDrawerToggle)==null||t.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=K();if(!r)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const t={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(t["X-Test-Api-Key"]=this.setupState.testApiKey);const n=r.endpoints.quota||r.endpoints.ask,o=ct(n),s=await fetch(o,{method:r.endpoints.quota?"GET":"POST",headers:t,...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(t){return this.setupState.connectionStatus="failed",this.setupState.lastError=t.message||"Connection failed",!1}},completeSetup(){var r,t;this.setupState.isActive=!1,this.setupState.currentStep="complete",mn(),(t=(r=K())==null?void 0:r.onSetupComplete)==null||t.call(r)},skipSetup(){this.setupState.isActive=!1,mn()}}});function pn(r){const t=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let o=r,s;for(;(s=t.exec(r))!==null;){const[a,i,l]=s,[u,d]=l.includes(":")?l.split(":"):["default",l];n.push({id:d,name:i,type:u}),o=o.replace(a,i)}return{cleanText:o,mentions:n}}function Xr(r){const{cleanText:t}=pn(r);return t}function hn(r){return r.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function gn(r,t){const o=r.substring(0,t).match(/@(\w*)$/);return o?{inMention:!0,query:o[1],startPos:t-o[0].length}:{inMention:!1,query:"",startPos:-1}}function Lt(r,t){var n,o;return t!=null&&t.getDisplayName?t.getDisplayName(r):r.name||r.title||((n=r.attributes)==null?void 0:n.name)||((o=r.attributes)==null?void 0:o.title)||"Unknown"}function yn(r,t){var n,o;return t!=null&&t.getSubtitle?t.getSubtitle(r):((n=r.attributes)==null?void 0:n.email)||((o=r.attributes)==null?void 0:o.description)||null}function Jr(r,t){return t!=null&&t.buildMentionText?t.buildMentionText(r):`@[${Lt(r,t)}](${r.type}:${r.id})`}function kn(r){var n;const t=K();return(n=t==null?void 0:t.mentionProviders)==null?void 0:n.find(o=>o.type===r)}function xn(r){const t=K(),n=(t==null?void 0:t.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 bn(r){return r.map(t=>({type:t.type,id:t.id,name:t.name}))}function wn(r){return r.reduce((t,n)=>{const o=n.type||"default";return t[o]||(t[o]=[]),t[o].push(n),t},{})}function vr(){return{extractMentions:pn,parseAndCleanMessage:Xr,renderMentionsInHtml:hn,detectMentionContext:gn,getMentionDisplayName:Lt,getMentionSubtitle:yn,buildMentionText:Jr,getMentionProvider:kn,getActiveMentionProviders:xn,formatMentionsForApi:bn,groupMentionsByType:wn}}function It(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let _e=It();function Cn(r){_e=r}const En=/[&<>"']/,eo=new RegExp(En.source,"g"),Sn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,to=new RegExp(Sn.source,"g"),no={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Tn=r=>no[r];function de(r,t){if(t){if(En.test(r))return r.replace(eo,Tn)}else if(Sn.test(r))return r.replace(to,Tn);return r}const ro=/(^|[^\[])\^/g;function H(r,t){let n=typeof r=="string"?r:r.source;t=t||"";const o={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(ro,"$1"),n=n.replace(s,i),o},getRegex:()=>new RegExp(n,t)};return o}function An(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const We={exec:()=>null};function Mn(r,t){const n=r.replace(/\|/g,(a,i,l)=>{let u=!1,d=i;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),o=n.split(/ \|/);let s=0;if(o[0].trim()||o.shift(),o.length>0&&!o[o.length-1].trim()&&o.pop(),t)if(o.length>t)o.splice(t);else for(;o.length<t;)o.push("");for(;s<o.length;s++)o[s]=o[s].trim().replace(/\\\|/g,"|");return o}function Ke(r,t,n){const o=r.length;if(o===0)return"";let s=0;for(;s<o&&r.charAt(o-s-1)===t;)s++;return r.slice(0,o-s)}function oo(r,t){if(r.indexOf(t[1])===-1)return-1;let n=0;for(let o=0;o<r.length;o++)if(r[o]==="\\")o++;else if(r[o]===t[0])n++;else if(r[o]===t[1]&&(n--,n<0))return o;return-1}function Bn(r,t,n,o){const s=t.href,a=t.title?de(t.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:de(i)}}function so(r,t){const n=r.match(/^(\s+)(?:```)/);if(n===null)return t;const o=n[1];return t.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 ut{constructor(t){q(this,"options");q(this,"rules");q(this,"lexer");this.options=t||_e}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);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:Ke(o,`
5
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const o=n[0],s=so(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(t){const n=this.rules.block.heading.exec(t);if(n){let o=n[2].trim();if(/#$/.test(o)){const s=Ke(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(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:Ke(n[0],`
6
- `)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let o=Ke(n[0],`
1
+ (function(L,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],e):(L=typeof globalThis<"u"?globalThis:L||self,e(L.RestifyAi={},L.Vue,L.Pinia))})(this,function(L,e,Ve){"use strict";var El=Object.defineProperty;var Sl=(L,e,Ve)=>e in L?El(L,e,{enumerable:!0,configurable:!0,writable:!0,value:Ve}):L[e]=Ve;var q=(L,e,Ve)=>Sl(L,typeof e!="symbol"?e+"":e,Ve);let Ie=null;const Ho=e.ref(null),$t={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",rateLimitExceeded:"Rate limit exceeded. Please try again in a moment.",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!",conversationHistory:"History",noConversations:"No conversations yet",deleteConversation:"Delete conversation",renameConversation:"Rename conversation",untitledConversation:"New conversation"};function fn(n){Ie=n,Ho.value=n}function K(){return Ie}function Vo(){if(!Ie)throw new Error("[restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Ie}function Lt(){return Ie!==null}function j(n,t){const o=Ie,r=(o==null?void 0:o.labels)||{},s=o==null?void 0:o.translate;if(s){const a=s(n,t);if(a!==n)return a}let i=r[n]||$t[n];return t&&Object.entries(t).forEach(([a,l])=>{i=i.replace(`{${a}}`,String(l))}),i}function pn(n){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}[n]}function ke(n){const t=Ie;return t?t[n]??pn(n):pn(n)}function ut(n){return(n.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(n.name||"")}function mt(n){if(n==null)return"";const t=typeof n=="string"?parseInt(n,10):n;return Number.isNaN(t)?"":t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}const Me={Assistant:"assistant",User:"user",System:"system"};async function Oo(n,t){const o=n.getReader();let r;for(;!(r=await o.read()).done;)t(r.value)}function Po(n){let t,o,r,s=!1;return function(a){t===void 0?(t=a,o=0,r=-1):t=Uo(t,a);const l=t.length;let c=0;for(;o<l;){s&&(t[o]===10&&(c=++o),s=!1);let u=-1;for(;o<l&&u===-1;++o)switch(t[o]){case 58:r===-1&&(r=o-c);break;case 13:s=!0;case 10:u=o;break}if(u===-1)break;n(t.subarray(c,u),r),c=o,r=-1}c===l?t=void 0:c!==0&&(t=t.subarray(c),o-=c)}}function Fo(n,t,o){let r=gn();const s=new TextDecoder;return function(a,l){if(a.length===0)o==null||o(r),r=gn();else if(l>0){const c=s.decode(a.subarray(0,l)),u=l+(a[l+1]===32?2:1),m=s.decode(a.subarray(u));switch(c){case"data":r.data=r.data?r.data+`
2
+ `+m:m;break;case"event":r.event=m;break;case"id":n(r.id=m);break;case"retry":const p=parseInt(m,10);isNaN(p)||t(r.retry=p);break}}}}function Uo(n,t){const o=new Uint8Array(n.length+t.length);return o.set(n),o.set(t,n.length),o}function gn(){return{data:"",event:"",id:"",retry:void 0}}var qo=function(n,t){var o={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(o[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(o[r[s]]=n[r[s]]);return o};const Dt="text/event-stream",jo=1e3,yn="last-event-id";function Wo(n,t){var{signal:o,headers:r,onopen:s,onmessage:i,onclose:a,onerror:l,openWhenHidden:c,fetch:u}=t,m=qo(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((p,g)=>{const k=Object.assign({},r);k.accept||(k.accept=Dt);let h;function N(){h.abort(),document.hidden||S()}c||document.addEventListener("visibilitychange",N);let f=jo,y=0;function b(){document.removeEventListener("visibilitychange",N),window.clearTimeout(y),h.abort()}o==null||o.addEventListener("abort",()=>{b(),p()});const x=u??window.fetch,C=s??Ko;async function S(){var E;h=new AbortController;try{const R=await x(n,Object.assign(Object.assign({},m),{headers:k,signal:h.signal}));await C(R),await Oo(R.body,Po(Fo(D=>{D?k[yn]=D:delete k[yn]},D=>{f=D},i))),a==null||a(),b(),p()}catch(R){if(!h.signal.aborted)try{const D=(E=l==null?void 0:l(R))!==null&&E!==void 0?E:f;window.clearTimeout(y),y=window.setTimeout(S,D)}catch(D){b(),g(D)}}}S()})}function Ko(n){const t=n.headers.get("content-type");if(!(t!=null&&t.startsWith(Dt)))throw new Error(`Expected content-type to be ${Dt}, Actual: ${t}`)}function ht(n){if(!n)throw console.error("[RestifyAi] Endpoint is undefined. Check your endpoints configuration."),new Error("AI service endpoint is not configured. Please contact support.");const t=K(),o=(t==null?void 0:t.baseUrl)||"";if(!o||n.startsWith("http://")||n.startsWith("https://"))return n;const r=o.endsWith("/")?o.slice(0,-1):o,s=n.startsWith("/")?n:`/${n}`;return`${r}${s}`}function kn(n){const o=(n instanceof Error?n.message:String(n)).toLowerCase();return o.includes("failed to fetch")||o.includes("network")||o.includes("fetch")?"Unable to connect to the AI service. Please check your internet connection and try again.":o.includes("500")||o.includes("internal server error")?"The AI service is temporarily unavailable. Please try again in a few moments.":o.includes("timeout")||o.includes("timed out")?"The request took too long. Please try again.":o.includes("401")||o.includes("unauthorized")||o.includes("authentication")?"Your session has expired. Please refresh the page and try again.":o.includes("429")||o.includes("rate limit")||o.includes("too many requests")?"Too many requests. Please wait a moment before trying again.":o.includes("cors")||o.includes("cross-origin")?"Unable to connect to the AI service. Please contact support.":o.includes("endpoint is not configured")?"AI service endpoint is not configured. Please contact support.":"Something went wrong. Please try again later."}function Qo(n,t){var o,r,s;try{if(t==="done"||n==="[DONE]")return"[DONE]";const i=JSON.parse(n);return(i==null?void 0:i.content)!==void 0?i.content:((s=(r=(o=i==null?void 0:i.choices)==null?void 0:o[0])==null?void 0:r.delta)==null?void 0:s.content)||null}catch{return null}}function Go(n){return new Promise(t=>setTimeout(t,n))}function xn(n){const t={};return n.forEach(o=>{var r;(r=o.attachments)==null||r.forEach(s=>{s!=null&&s.id&&(t[s.id]=s)})}),t}const wn="restify_ai_conversation_history",Ge="restify_ai_conv_";function Re(n){const t=K();return n==="chatHistory"?(t==null?void 0:t.chatHistoryKey)||"restify_ai_chat_history":n==="setupComplete"?"restify_ai_setup_complete":(t==null?void 0:t.drawerStateKey)||"restify_ai_drawer_open"}function Oe(n){try{sessionStorage.setItem(Re("chatHistory"),JSON.stringify(n))}catch(t){console.warn("[RestifyAi] Failed to save chat history:",t)}}function vo(){try{const n=sessionStorage.getItem(Re("chatHistory"));if(n){const t=JSON.parse(n),o=t.filter(i=>{var a;return!(i.role===Me.Assistant&&i.loading||i.role===Me.Assistant&&!((a=i.message)!=null&&a.trim()))}).map(i=>({...i,streaming:!1,loading:!1}));o.length!==t.length&&sessionStorage.setItem(Re("chatHistory"),JSON.stringify(o));const r=o[o.length-1],s=(r==null?void 0:r.role)===Me.User;return{history:o,hasOrphanedUserMessage:s,orphanedMessage:s?{question:r.message,attachments:r.attachments||[]}:void 0}}}catch(n){console.warn("[RestifyAi] Failed to load chat history:",n)}return{history:[],hasOrphanedUserMessage:!1}}function Yo(){try{sessionStorage.removeItem(Re("chatHistory")),sessionStorage.removeItem("restify_ai_current_conversation")}catch(n){console.warn("[RestifyAi] Failed to clear chat history:",n)}}function bn(n){try{n?sessionStorage.setItem("restify_ai_current_conversation",n):sessionStorage.removeItem("restify_ai_current_conversation")}catch(t){console.warn("[RestifyAi] Failed to save current conversation:",t)}}function Zo(){try{return sessionStorage.getItem("restify_ai_current_conversation")}catch(n){console.warn("[RestifyAi] Failed to load current conversation:",n)}return null}function zt(n){try{n.message||n.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(n)):sessionStorage.removeItem("restify_ai_error_state")}catch(t){console.warn("[RestifyAi] Failed to save error state:",t)}}function Xo(){try{const n=sessionStorage.getItem("restify_ai_error_state");if(n)return JSON.parse(n)}catch(n){console.warn("[RestifyAi] Failed to load error state:",n)}return null}function Jo(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(n){console.warn("[RestifyAi] Failed to clear error state:",n)}}function Ht(n){try{localStorage.setItem(Re("drawerState"),JSON.stringify(n))}catch(t){console.warn("[RestifyAi] Failed to save drawer state:",t)}}function er(){try{const n=localStorage.getItem(Re("drawerState"));if(n!==null)return JSON.parse(n)}catch(n){console.warn("[RestifyAi] Failed to load drawer state:",n)}return!1}function tr(){try{return localStorage.getItem(Re("setupComplete"))==="true"}catch{return!1}}function Cn(){try{localStorage.setItem(Re("setupComplete"),"true")}catch(n){console.warn("[RestifyAi] Failed to mark setup complete:",n)}}function En(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}function ft(n){try{localStorage.setItem(wn,JSON.stringify(n))}catch(t){console.warn("[RestifyAi] Failed to save conversation history:",t)}}function nr(){try{const n=localStorage.getItem(wn);if(n)return JSON.parse(n)}catch(n){console.warn("[RestifyAi] Failed to load conversation history:",n)}return[]}function or(n,t){try{localStorage.setItem(Ge+n,JSON.stringify(t))}catch(o){console.warn("[RestifyAi] Failed to save conversation messages:",o)}}function rr(n){try{const t=localStorage.getItem(Ge+n);if(t)return JSON.parse(t)}catch(t){console.warn("[RestifyAi] Failed to load conversation messages:",t)}return[]}function Sn(n){try{localStorage.removeItem(Ge+n)}catch(t){console.warn("[RestifyAi] Failed to delete conversation messages:",t)}}function sr(n){try{const t=new Set(n),o=[];for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);if(s!=null&&s.startsWith(Ge)){const i=s.replace(Ge,"");t.has(i)||o.push(s)}}o.length>0&&o.forEach(r=>localStorage.removeItem(r))}catch(t){console.warn("[RestifyAi] Failed to cleanup orphaned conversations:",t)}}let ve=new AbortController;function ir(n,t){return n!=null&&n.message?{message:n.message,failedQuestion:n.failedQuestion,failedAttachments:n.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:t.hasOrphanedUserMessage&&t.orphanedMessage?{message:"Previous request failed. Click retry to try again.",failedQuestion:t.orphanedMessage.question,failedAttachments:t.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}:{message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1}}function ar(n){const t=ke("chatHistoryLimit")||10;return{limit:t,used:n,remaining:Math.max(0,t-n)}}function lr(){return!Lt()&&!tr()?{...En(),isActive:!0}:En()}const xe=Ve.defineStore("restifyAiStore",{state:()=>{const n=vo(),t=Xo(),o=n.history.filter(s=>s.role==="user").length,r=nr();return sr(r.map(s=>s.id)),{chatHistoryLimit:ke("chatHistoryLimit")||20,chatHistory:n.history,uploadedFiles:xn(n.history),loading:!1,showChat:er(),isFullscreen:!1,sending:!1,pageContext:null,quota:ar(o),error:ir(t,n),supportRequestMode:!1,setupState:lr(),conversationId:Zo(),conversationName:null,conversationHistory:r,showHistorySidebar:!1}},getters:{hasMessages:n=>n.chatHistory.length>0,isInSetupMode:n=>n.setupState.isActive,canChat:n=>!n.setupState.isActive||n.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(n=0){await e.nextTick(),n>0&&await new Promise(o=>setTimeout(o,n));const t=document.getElementById("rai-chat-bottom");t&&t.scrollIntoView({behavior:"smooth"})},parseStreamContent(n,t){const o=K(),r=o==null?void 0:o.parseStreamContent;return r?r(t,n):Qo(t,n)},async askQuestion(n,t=[],o=[],r=!1){var k;const s=K();if(!s)return console.warn("[RestifyAi] Cannot ask question - plugin not configured"),!1;this.clearError();let i="",a=!1;const l=s.retry||{},c=l.maxRetries??0,u=l.retryDelay??1e3;let m=0;const p=t.map(h=>({id:h.id,name:h.name,url:h.url,type:h.type,size:h.size,extractedText:h.extractedText,backendFileId:h.backendFileId}));this.chatHistory.push({id:crypto.randomUUID(),role:Me.User,message:n,loading:!1,attachments:p,mentions:o,timestamp:Date.now()}),p.forEach(h=>this.registerUploadedFile(h)),Oe(this.chatHistory),this.sending=!0,this.quota.remaining>0&&!r&&(this.quota.remaining--,this.quota.used++),this.scrollToBottom(),this.chatHistory.length>=this.chatHistoryLimit&&((k=s.onError)==null||k.call(s,new Error("Chat history limit reached")));const g=async()=>{var h,N,f;try{const y=this.chatHistory.map(T=>({role:T.role,content:T.message})),b={},x=T=>{T!=null&&T.id&&(b[T.id]={extracted_text:T.extractedText||"",file_name:T.name,mime_type:T.type||"",...T.size?{file_size:T.size}:{},...T.url?{file_url:T.url}:{},...T.backendFileId?{backendFileId:T.backendFileId}:{}})};Object.values(this.uploadedFiles).forEach(x),this.chatHistory.forEach(T=>{var I;return(I=T.attachments)==null?void 0:I.forEach(x)}),p.forEach(x);const C=Object.values(b),S=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Me.Assistant,message:"",loading:!0,timestamp:Date.now()}),Oe(this.chatHistory),ve=new AbortController,this.scrollToBottom();const E=await s.getAuthToken(),D={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?D["X-Test-Api-Key"]=this.setupState.testApiKey:E&&(D.Authorization=`Bearer ${E}`);const B={};if(typeof window<"u"){B.route=window.location.pathname;const T=new URLSearchParams(window.location.search),I={};T.forEach((Q,J)=>{I[J]=Q}),Object.keys(I).length>0&&(B.query=I),document.title&&(B.pageTitle=document.title)}o.length>0&&(B.mentionedEntities=o.map(T=>({type:T.type,id:T.id,displayName:T.name,metadata:T.metadata})));const _=[];C.forEach(T=>{T.backendFileId&&_.push(Number(T.backendFileId))});let V={message:n,history:y,stream:!0,...C.length>0&&{files:C},..._.length>0&&{attachment_ids:_},...Object.keys(B).length>0&&{context:B},...s.useConversationId&&this.conversationId&&{conversation_id:this.conversationId},...this.supportRequestMode&&{contact_support:!0},...s.model&&{model:s.model},...s.temperature&&{temperature:s.temperature},...s.maxTokens&&{max_tokens:s.maxTokens}};s.beforeSend&&(V=await s.beforeSend(V)),s.buildRequest&&(V=await s.buildRequest(V)),(h=s.onMessageSent)==null||h.call(s,this.chatHistory[S-1]);const X=ht(s.endpoints.ask);let le={method:"POST",body:JSON.stringify(V),headers:D};return s.requestInterceptor&&(le=await s.requestInterceptor(X,le)),(N=s.onStreamStart)==null||N.call(s),await Wo(X,{method:"POST",body:JSON.stringify(V),signal:ve.signal,headers:le.headers,openWhenHidden:!0,async onopen(T){var I;if(T.ok){if(s.useHeadersRateLimiter){const Q=T.headers.get("x-ratelimit-limit"),J=T.headers.get("x-ratelimit-remaining");if(Q&&J){const P=xe();P.quota={limit:parseInt(Q,10),used:parseInt(Q,10)-parseInt(J,10),remaining:parseInt(J,10)},(I=s.onQuotaFetched)==null||I.call(s,P.quota)}}return}if(T.status===429){const Q=xe(),J=s.useHeadersRateLimiter?"You have reached your message limit. Please try again later.":j("rateLimitExceeded");throw Q.error={message:J,failedQuestion:n,failedAttachments:p,timestamp:Date.now(),quotaExceeded:!0,rateLimited:!0},s.useQuota!==!1&&!s.useHeadersRateLimiter&&await Q.fetchQuota(),new Error("Rate limit exceeded")}throw new Error(`Failed to connect: ${T.status}`)},onmessage:async T=>{var J,P,Le,De;if(T.event==="error"){a=!0;let H="An error occurred";try{const pe=JSON.parse(T.data);H=pe.error||pe.message||H}catch{H=T.data||H}this.chatHistory[S]&&!this.chatHistory[S].message?this.chatHistory.splice(S,1):this.chatHistory[S]&&(this.chatHistory[S].loading=!1,this.chatHistory[S].streaming=!1),this.error={message:H,failedQuestion:n,failedAttachments:p,timestamp:Date.now()},zt({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),this.sending=!1,(J=s.onError)==null||J.call(s,new Error(H));return}if(T.event==="start"&&s.useConversationId)try{const H=JSON.parse(T.data);if(H.conversation_id){const pe=!this.conversationId;this.conversationId=H.conversation_id,bn(H.conversation_id),H.conversation_name&&(this.conversationName=H.conversation_name),s.useConversationHistory&&pe&&this.addToConversationHistory(H.conversation_id,H.conversation_name)}}catch{}const I=this.parseStreamContent(T.event,T.data);if(!I)return;this.chatHistory[S].loading=!1;const Q={content:I,done:I==="[DONE]",raw:T.data};(P=s.onStreamChunk)==null||P.call(s,Q),i?I==="[DONE]"?(this.chatHistory[S].streaming=!1,Oe(this.chatHistory),(Le=s.onStreamEnd)==null||Le.call(s,i),s.useConversationHistory&&this.conversationId&&this.saveCurrentConversation(),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[S]),(De=s.onResponseReceived)==null||De.call(s,this.chatHistory[S])):(i+=I,this.chatHistory[S].message=i):(i=I,this.chatHistory[S].message=i,this.chatHistory[S].streaming=!0),await this.scrollToBottom()},onclose:()=>{var T,I;i&&!a?(this.chatHistory[S].streaming=!1,this.chatHistory[S].loading=!1,Oe(this.chatHistory),(T=s.onStreamEnd)==null||T.call(s,i),s.afterResponse&&s.afterResponse(this.chatHistory[S]),(I=s.onResponseReceived)==null||I.call(s,this.chatHistory[S])):!i&&!a&&(this.chatHistory[S]&&!this.chatHistory[S].message?this.chatHistory.splice(S,1):this.chatHistory[S]&&(this.chatHistory[S].loading=!1,this.chatHistory[S].streaming=!1))},onerror:T=>{var I;a=!0,this.chatHistory[S]&&(this.chatHistory[S].loading=!1,this.chatHistory[S].streaming=!1),this.sending=!1,i||(this.chatHistory[S]&&!this.chatHistory[S].message&&this.chatHistory.splice(S,1),this.error={message:kn(T),failedQuestion:n,failedAttachments:p,timestamp:Date.now()},zt({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(I=s.onError)==null||I.call(s,T))}}),!0}catch(y){a=!0;const b=this.chatHistory.length-1;return this.chatHistory.splice(b,1),y.name==="AbortError"?!0:m<c&&(l.shouldRetry?l.shouldRetry(y,m):!0)?(m++,await Go(u*m),g()):(this.error={message:kn(y),failedQuestion:n,failedAttachments:p,timestamp:Date.now()},zt({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(f=s.onError)==null||f.call(s,y),!1)}finally{this.sending=!1}};return g()},cancelRequest(){ve==null||ve.abort(),this.chatHistory=this.chatHistory.map(n=>({...n,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var o;const n=K();n!=null&&n.useConversationHistory&&this.conversationId&&this.chatHistory.length>0&&this.saveCurrentConversation(),this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.conversationId=null,this.conversationName=null,this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1);const t=ke("chatHistoryLimit")||10;this.quota={limit:t,used:0,remaining:t},Yo(),(o=n==null?void 0:n.onNewChat)==null||o.call(n)},async retry(){if(!this.error.failedQuestion)return!1;const n=this.error.failedQuestion,t=this.error.failedAttachments||[],o=this.chatHistory[this.chatHistory.length-1];return(o==null?void 0:o.role)===Me.User&&o.message===n&&(this.chatHistory.pop(),Oe(this.chatHistory)),this.clearError(),await this.askQuestion(n,t)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},Jo()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var t,o;const n=K();if((n==null?void 0:n.useQuota)!==!1&&(t=n==null?void 0:n.endpoints)!=null&&t.quota)try{const r=await n.getAuthToken(),s=n.getCustomHeaders?await n.getCustomHeaders():{},i=ht(n.endpoints.quota),a=await fetch(i,{headers:{Accept:"application/json",...r?{Authorization:`Bearer ${r}`}:{},...s}});if(a.ok){const l=await a.json(),c=l.data??l;this.quota={limit:c.limit??this.quota.limit,used:c.used??this.quota.used,remaining:c.remaining??this.quota.remaining},this.quota.remaining===0&&n.enableSupportMode!==!1&&(this.supportRequestMode=!0),(o=n.onQuotaFetched)==null||o.call(n,this.quota)}}catch(r){console.error("[RestifyAi] Failed to fetch quota:",r)}},async uploadFile(n){var s,i,a,l,c;const t=K();if(!((s=t==null?void 0:t.endpoints)!=null&&s.uploadFile))return console.warn("[RestifyAi] No uploadFile endpoint configured"),null;const r={id:crypto.randomUUID(),name:n.name,type:n.type,size:n.size,uploading:!0,progress:0};(i=t.onFileUploadStart)==null||i.call(t,r);try{const u=await t.getAuthToken(),m=t.getCustomHeaders?await t.getCustomHeaders():{},p=ht(t.endpoints.uploadFile),g=t.fileUpload||{};let k=new FormData;if(g.buildFormData)k=await g.buildFormData(n,k);else{const N=g.fileFieldName||"file";if(k.append(N,n),g.additionalFields)for(const[f,y]of Object.entries(g.additionalFields)){const b=typeof y=="function"?await y():y;k.append(f,b)}}const h=await new Promise((N,f)=>{const y=new XMLHttpRequest;y.upload.addEventListener("progress",b=>{var x;if(b.lengthComputable){const C=Math.round(b.loaded/b.total*100);r.progress=C,(x=t.onFileUploadProgress)==null||x.call(t,r,C)}}),y.addEventListener("load",()=>{if(y.status>=200&&y.status<400)try{const b=JSON.parse(y.responseText);let x={};if(g.parseResponse)x=g.parseResponse(b);else{const S=b.data||b;x={url:S.url||S.file_url,extractedText:S.extracted_text||S.extractedText};const E=S.id||S.file_id||S.openai_file_id||S.attachment_id;E&&(x.backendFileId=E)}const C={...r,...x,uploading:!1,progress:100};N(C)}catch(b){console.error("[RestifyAi] Failed to parse upload response:",b),f(new Error("Failed to parse upload response"))}else console.error("[RestifyAi] Upload failed with status:",y.status,y.responseText),f(new Error(`Upload failed: ${y.status}`))}),y.addEventListener("error",()=>{console.error("[RestifyAi] Upload network error"),f(new Error("Upload failed"))}),y.open("POST",p),u&&y.setRequestHeader("Authorization",`Bearer ${u}`),Object.entries(m).forEach(([b,x])=>y.setRequestHeader(b,x)),y.send(k)});return(a=t.onFileUploadComplete)==null||a.call(t,h),h}catch(u){const m={...r,uploading:!1};return(l=t.onFileUploadError)==null||l.call(t,m,u),(c=t.onError)==null||c.call(t,u),null}},setPageContext(n){this.pageContext=n},toggleDrawer(){var n,t;this.showChat=!this.showChat,Ht(this.showChat),(t=(n=K())==null?void 0:n.onDrawerToggle)==null||t.call(n,this.showChat),this.showChat&&this.scrollToBottom(100)},openDrawer(){var n,t;this.showChat=!0,Ht(!0),(t=(n=K())==null?void 0:n.onDrawerToggle)==null||t.call(n,!0),this.scrollToBottom(100)},closeDrawer(){var n,t;this.showChat=!1,Ht(!1),(t=(n=K())==null?void 0:n.onDrawerToggle)==null||t.call(n,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(n){n!=null&&n.id&&(this.uploadedFiles[n.id]={...n})},toggleHistorySidebar(){this.showHistorySidebar=!this.showHistorySidebar},addToConversationHistory(n,t){const o=K(),r=(o==null?void 0:o.maxConversationHistory)||10,s=this.conversationHistory.findIndex(i=>i.id===n);if(s!==-1)this.conversationHistory[s].updatedAt=Date.now(),this.conversationHistory[s].messageCount=this.chatHistory.length,t&&(this.conversationHistory[s].title=t);else{const i=this.chatHistory.find(l=>l.role==="user"),a=i?i.message.slice(0,50)+(i.message.length>50?"...":""):"New conversation";if(this.conversationHistory.unshift({id:n,title:t||a,createdAt:Date.now(),updatedAt:Date.now(),messageCount:this.chatHistory.length}),this.conversationHistory.length>r){const l=this.conversationHistory.pop();l&&Sn(l.id)}}ft(this.conversationHistory)},saveCurrentConversation(){if(!this.conversationId)return;const n=this.conversationHistory.findIndex(t=>t.id===this.conversationId);if(n!==-1){if(this.conversationHistory[n].updatedAt=Date.now(),this.conversationHistory[n].messageCount=this.chatHistory.length,!this.conversationName){const t=this.chatHistory.find(o=>o.role==="user");t&&(this.conversationHistory[n].title=t.message.slice(0,50)+(t.message.length>50?"...":""))}ft(this.conversationHistory)}or(this.conversationId,this.chatHistory)},loadConversation(n){this.conversationId&&this.chatHistory.length>0&&this.saveCurrentConversation();const t=rr(n),o=this.conversationHistory.find(s=>s.id===n);this.conversationId=n,this.conversationName=(o==null?void 0:o.title)||null,this.chatHistory=t,this.uploadedFiles=xn(t),this.clearError();const r=t.filter(s=>s.role===Me.User).length;this.quota={limit:this.quota.limit,used:r,remaining:Math.max(0,this.quota.limit-r)},Oe(t),bn(n),this.scrollToBottom(100)},renameConversation(n,t){const o=this.conversationHistory.findIndex(r=>r.id===n);o!==-1&&(this.conversationHistory[o].title=t,this.conversationHistory[o].updatedAt=Date.now(),ft(this.conversationHistory),this.conversationId===n&&(this.conversationName=t))},deleteConversation(n){const t=this.conversationHistory.findIndex(o=>o.id===n);t!==-1&&(this.conversationHistory.splice(t,1),ft(this.conversationHistory)),Sn(n),this.conversationId===n&&this.clearChatHistory()},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(n){this.setupState.currentStep=n},setTestApiKey(n){this.setupState.testApiKey=n},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const n=K();if(!n)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const t={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(t["X-Test-Api-Key"]=this.setupState.testApiKey);const o=n.endpoints.quota||n.endpoints.ask,r=ht(o),s=await fetch(r,{method:n.endpoints.quota?"GET":"POST",headers:t,...n.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(t){return this.setupState.connectionStatus="failed",this.setupState.lastError=t.message||"Connection failed",!1}},completeSetup(){var n,t;this.setupState.isActive=!1,this.setupState.currentStep="complete",Cn(),(t=(n=K())==null?void 0:n.onSetupComplete)==null||t.call(n)},skipSetup(){this.setupState.isActive=!1,Cn()}}});function Tn(n){const t=/@\[([^\]]+)\]\(([^)]+)\)/g,o=[];let r=n,s;for(;(s=t.exec(n))!==null;){const[i,a,l]=s,[c,u]=l.includes(":")?l.split(":"):["default",l];o.push({id:u,name:a,type:c}),r=r.replace(i,a)}return{cleanText:r,mentions:o}}function cr(n){const{cleanText:t}=Tn(n);return t}function An(n){return n.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function Nn(n,t){const r=n.substring(0,t).match(/@(\w*)$/);return r?{inMention:!0,query:r[1],startPos:t-r[0].length}:{inMention:!1,query:"",startPos:-1}}function Vt(n,t){var o,r;return t!=null&&t.getDisplayName?t.getDisplayName(n):n.name||n.title||((o=n.attributes)==null?void 0:o.name)||((r=n.attributes)==null?void 0:r.title)||"Unknown"}function Bn(n,t){var o,r;return t!=null&&t.getSubtitle?t.getSubtitle(n):((o=n.attributes)==null?void 0:o.email)||((r=n.attributes)==null?void 0:r.description)||null}function dr(n,t){return t!=null&&t.buildMentionText?t.buildMentionText(n):`@[${Vt(n,t)}](${n.type}:${n.id})`}function Mn(n){var o;const t=K();return(o=t==null?void 0:t.mentionProviders)==null?void 0:o.find(r=>r.type===n)}function Rn(n){const t=K(),o=(t==null?void 0:t.mentionProviders)||[];return n?o.filter(r=>r.routes?r.routes.some(s=>s.endsWith("*")?n.startsWith(s.slice(0,-1)):n===s||n.startsWith(s+"/")):!0):o}function In(n){return n.map(t=>({type:t.type,id:t.id,name:t.name}))}function _n(n){return n.reduce((t,o)=>{const r=o.type||"default";return t[r]||(t[r]=[]),t[r].push(o),t},{})}function ur(){return{extractMentions:Tn,parseAndCleanMessage:cr,renderMentionsInHtml:An,detectMentionContext:Nn,getMentionDisplayName:Vt,getMentionSubtitle:Bn,buildMentionText:dr,getMentionProvider:Mn,getActiveMentionProviders:Rn,formatMentionsForApi:In,groupMentionsByType:_n}}function Ot(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let _e=Ot();function $n(n){_e=n}const Ln=/[&<>"']/,mr=new RegExp(Ln.source,"g"),Dn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,hr=new RegExp(Dn.source,"g"),fr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},zn=n=>fr[n];function ue(n,t){if(t){if(Ln.test(n))return n.replace(mr,zn)}else if(Dn.test(n))return n.replace(hr,zn);return n}const pr=/(^|[^\[])\^/g;function U(n,t){let o=typeof n=="string"?n:n.source;t=t||"";const r={replace:(s,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(pr,"$1"),o=o.replace(s,a),r},getRegex:()=>new RegExp(o,t)};return r}function Hn(n){try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Ye={exec:()=>null};function Vn(n,t){const o=n.replace(/\|/g,(i,a,l)=>{let c=!1,u=a;for(;--u>=0&&l[u]==="\\";)c=!c;return c?"|":" |"}),r=o.split(/ \|/);let s=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(/\\\|/g,"|");return r}function Ze(n,t,o){const r=n.length;if(r===0)return"";let s=0;for(;s<r&&n.charAt(r-s-1)===t;)s++;return n.slice(0,r-s)}function gr(n,t){if(n.indexOf(t[1])===-1)return-1;let o=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===t[0])o++;else if(n[r]===t[1]&&(o--,o<0))return r;return-1}function On(n,t,o,r){const s=t.href,i=t.title?ue(t.title):null,a=n[1].replace(/\\([\[\]])/g,"$1");if(n[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:o,href:s,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}return{type:"image",raw:o,href:s,title:i,text:ue(a)}}function yr(n,t){const o=n.match(/^(\s+)(?:```)/);if(o===null)return t;const r=o[1];return t.split(`
3
+ `).map(s=>{const i=s.match(/^\s+/);if(i===null)return s;const[a]=i;return a.length>=r.length?s.slice(r.length):s}).join(`
4
+ `)}class pt{constructor(t){q(this,"options");q(this,"rules");q(this,"lexer");this.options=t||_e}space(t){const o=this.rules.block.newline.exec(t);if(o&&o[0].length>0)return{type:"space",raw:o[0]}}code(t){const o=this.rules.block.code.exec(t);if(o){const r=o[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:o[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Ze(r,`
5
+ `)}}}fences(t){const o=this.rules.block.fences.exec(t);if(o){const r=o[0],s=yr(r,o[3]||"");return{type:"code",raw:r,lang:o[2]?o[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):o[2],text:s}}}heading(t){const o=this.rules.block.heading.exec(t);if(o){let r=o[2].trim();if(/#$/.test(r)){const s=Ze(r,"#");(this.options.pedantic||!s||/ $/.test(s))&&(r=s.trim())}return{type:"heading",raw:o[0],depth:o[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const o=this.rules.block.hr.exec(t);if(o)return{type:"hr",raw:Ze(o[0],`
6
+ `)}}blockquote(t){const o=this.rules.block.blockquote.exec(t);if(o){let r=Ze(o[0],`
7
7
  `).split(`
8
- `),s="",a="";const i=[];for(;o.length>0;){let l=!1;const u=[];let d;for(d=0;d<o.length;d++)if(/^ {0,3}>/.test(o[d]))u.push(o[d]),l=!0;else if(!l)u.push(o[d]);else break;o=o.slice(d);const m=u.join(`
9
- `),h=m.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
8
+ `),s="",i="";const a=[];for(;r.length>0;){let l=!1;const c=[];let u;for(u=0;u<r.length;u++)if(/^ {0,3}>/.test(r[u]))c.push(r[u]),l=!0;else if(!l)c.push(r[u]);else break;r=r.slice(u);const m=c.join(`
9
+ `),p=m.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
10
10
  $1`).replace(/^ {0,3}>[ \t]?/gm,"");s=s?`${s}
11
- ${m}`:m,a=a?`${a}
12
- ${h}`:h;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=g,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,S=f.raw+`
13
- `+o.join(`
14
- `),p=this.blockquote(S);i[i.length-1]=p,s=s.substring(0,s.length-f.raw.length)+p.raw,a=a.substring(0,a.length-f.text.length)+p.text;break}else if((y==null?void 0:y.type)==="list"){const f=y,S=f.raw+`
15
- `+o.join(`
16
- `),p=this.list(S);i[i.length-1]=p,s=s.substring(0,s.length-y.raw.length)+p.raw,a=a.substring(0,a.length-f.raw.length)+p.raw,o=S.substring(i[i.length-1].raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(t){let n=this.rules.block.list.exec(t);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(;t;){let u=!1,d="",m="";if(!(n=i.exec(t))||this.rules.block.hr.test(t))break;d=n[0],t=t.substring(d.length);let h=n[2].split(`
18
- `,1)[0].replace(/^\t+/,w=>" ".repeat(3*w.length)),g=t.split(`
19
- `,1)[0],y=!h.trim(),f=0;if(this.options.pedantic?(f=2,m=h.trimStart()):y?f=n[1].length+1:(f=n[2].search(/[^ ]/),f=f>4?1:f,m=h.slice(f),f+=n[1].length),y&&/^[ \t]*$/.test(g)&&(d+=g+`
20
- `,t=t.substring(g.length+1),u=!0),!u){const w=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),M=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),x=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),C=new RegExp(`^ {0,${Math.min(3,f-1)}}#`),I=new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const b=t.split(`
21
- `,1)[0];let N;if(g=b,this.options.pedantic?(g=g.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),N=g):N=g.replace(/\t/g," "),x.test(g)||C.test(g)||I.test(g)||w.test(g)||M.test(g))break;if(N.search(/[^ ]/)>=f||!g.trim())m+=`
22
- `+N.slice(f);else{if(y||h.replace(/\t/g," ").search(/[^ ]/)>=4||x.test(h)||C.test(h)||M.test(h))break;m+=`
23
- `+g}!y&&!g.trim()&&(y=!0),d+=b+`
24
- `,t=t.substring(b.length+1),h=N.slice(f)}}a.loose||(l?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(l=!0));let S=null,p;this.options.gfm&&(S=/^\[[ xX]\] /.exec(m),S&&(p=S[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:d,task:!!S,checked:p,loose:!1,text:m,tokens:[]}),a.raw+=d}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 u=0;u<a.items.length;u++)if(this.lexer.state.top=!1,a.items[u].tokens=this.lexer.blockTokens(a.items[u].text,[]),!a.loose){const d=a.items[u].tokens.filter(h=>h.type==="space"),m=d.length>0&&d.some(h=>/\n.*\n/.test(h.raw));a.loose=m}if(a.loose)for(let u=0;u<a.items.length;u++)a.items[u].loose=!0;return a}}html(t){const n=this.rules.block.html.exec(t);if(n)return{type:"html",block:!0,raw:n[0],pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:n[0]}}def(t){const n=this.rules.block.def.exec(t);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(t){const n=this.rules.block.table.exec(t);if(!n||!/[:|]/.test(n[2]))return;const o=Mn(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(Mn(l,i.header.length).map((u,d)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:i.align[d]})));return i}}lheading(t){const n=this.rules.block.lheading.exec(t);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(t){const n=this.rules.block.paragraph.exec(t);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(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:de(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);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(t){const n=this.rules.inline.link.exec(t);if(n){const o=n[2].trim();if(!this.options.pedantic&&/^</.test(o)){if(!/>$/.test(o))return;const i=Ke(o.slice(0,-1),"\\");if((o.length-i.length)%2===0)return}else{const i=oo(n[2],"()");if(i>-1){const u=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,u).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(t,n){let o;if((o=this.rules.inline.reflink.exec(t))||(o=this.rules.inline.nolink.exec(t))){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(t,n,o=""){let s=this.rules.inline.emStrongLDelim.exec(t);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,u,d=i,m=0;const h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,n=n.slice(-1*t.length+i);(s=h.exec(n))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(u=[...l].length,s[3]||s[4]){d+=u;continue}else if((s[5]||s[6])&&i%3&&!((i+u)%3)){m+=u;continue}if(d-=u,d>0)continue;u=Math.min(u,u+d+m);const g=[...s[0]][0].length,y=t.slice(0,i+s.index+g+u);if(Math.min(i,u)%2){const S=y.slice(1,-1);return{type:"em",raw:y,text:S,tokens:this.lexer.inlineTokens(S)}}const f=y.slice(2,-2);return{type:"strong",raw:y,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);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=de(o,!0),{type:"codespan",raw:n[0],text:o}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t){const n=this.rules.inline.autolink.exec(t);if(n){let o,s;return n[2]==="@"?(o=de(n[1]),s="mailto:"+o):(o=de(n[1]),s=o),{type:"link",raw:n[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t){var o;let n;if(n=this.rules.inline.url.exec(t)){let s,a;if(n[2]==="@")s=de(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=de(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(t){const n=this.rules.inline.text.exec(t);if(n){let o;return this.lexer.state.inRawBlock?o=n[0]:o=de(n[0]),{type:"text",raw:n[0],text:o}}}}const ao=/^(?:[ \t]*(?:\n|$))+/,io=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,lo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ge=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,co=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Nn=/(?:[*+-]|\d{1,9}[.)])/,Rn=H(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Nn).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(),$t=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,uo=/^[^\n]+/,Dt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,mo=H(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Dt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),fo=H(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Nn).getRegex(),dt="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",zt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,po=H("^ {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",zt).replace("tag",dt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_n=H($t).replace("hr",Ge).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",dt).getRegex(),Ot={blockquote:H(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_n).getRegex(),code:io,def:mo,fences:lo,heading:co,hr:Ge,html:po,lheading:Rn,list:fo,newline:ao,paragraph:_n,table:We,text:uo},Ln=H("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ge).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",dt).getRegex(),ho={...Ot,table:Ln,paragraph:H($t).replace("hr",Ge).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ln).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",dt).getRegex()},go={...Ot,html:H(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",zt).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:We,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H($t).replace("hr",Ge).replace("heading",` *#{1,6} *[^
27
- ]`).replace("lheading",Rn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},In=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,yo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$n=/^( {2,}|\\)\n(?!\s*$)/,ko=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Qe="\\p{P}\\p{S}",xo=H(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Qe).getRegex(),bo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,wo=H(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Qe).getRegex(),Co=H("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Qe).getRegex(),Eo=H("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Qe).getRegex(),So=H(/\\([punct])/,"gu").replace(/punct/g,Qe).getRegex(),To=H(/^<(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(),Ao=H(zt).replace("(?:-->|$)","-->").getRegex(),Mo=H("^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",Ao).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Bo=H(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",mt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Dn=H(/^!?\[(label)\]\[(ref)\]/).replace("label",mt).replace("ref",Dt).getRegex(),zn=H(/^!?\[(ref)\](?:\[\])?/).replace("ref",Dt).getRegex(),No=H("reflink|nolink(?!\\()","g").replace("reflink",Dn).replace("nolink",zn).getRegex(),Pt={_backpedal:We,anyPunctuation:So,autolink:To,blockSkip:bo,br:$n,code:yo,del:We,emStrongLDelim:wo,emStrongRDelimAst:Co,emStrongRDelimUnd:Eo,escape:In,link:Bo,nolink:zn,punctuation:xo,reflink:Dn,reflinkSearch:No,tag:Mo,text:ko,url:We},Ro={...Pt,link:H(/^!?\[(label)\]\((.*?)\)/).replace("label",mt).getRegex(),reflink:H(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",mt).getRegex()},Vt={...Pt,escape:H(In).replace("])","~|])").getRegex(),url:H(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},_o={...Vt,br:H($n).replace("{2,}","*").getRegex(),text:H(Vt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ft={normal:Ot,gfm:ho,pedantic:go},Ze={normal:Pt,gfm:Vt,breaks:_o,pedantic:Ro};class me{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"tokenizer");q(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||_e,this.options.tokenizer=this.options.tokenizer||new ut,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:ft.normal,inline:Ze.normal};this.options.pedantic?(n.block=ft.pedantic,n.inline=Ze.pedantic):this.options.gfm&&(n.block=ft.gfm,this.options.breaks?n.inline=Ze.breaks:n.inline=Ze.gfm),this.tokenizer.rules=n}static get rules(){return{block:ft,inline:Ze}}static lex(t,n){return new me(n).lex(t)}static lexInline(t,n){return new me(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
28
- `),this.blockTokens(t,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(t,n=[],o=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let s,a,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(s=l.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))){if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length),s.raw.length===1&&n.length>0?n[n.length-1].raw+=`
29
- `:n.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
30
- `+s.raw,a.text+=`
31
- `+s.text,this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(s=this.tokenizer.fences(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(t)){t=t.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
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(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(t)){t=t.substring(s.raw.length),n.push(s);continue}if(i=t,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const u=t.slice(1);let d;this.options.extensions.startBlock.forEach(m=>{d=m.call({lexer:this},u),typeof d=="number"&&d>=0&&(l=Math.min(l,d))}),l<1/0&&l>=0&&(i=t.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+=`
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!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length),a=n[n.length-1],a&&a.type==="text"?(a.raw+=`
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(t){const l="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let o,s,a,i=t,l,u,d;if(this.tokens.links){const m=Object.keys(this.tokens.links);if(m.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)m.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(;t;)if(u||(d=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(m=>(o=m.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))){if(o=this.tokenizer.escape(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.tag(t)){t=t.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(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.reflink(t,this.tokens.links)){t=t.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(t,i,d)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.codespan(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.br(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.del(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.autolink(t)){t=t.substring(o.raw.length),n.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(t))){t=t.substring(o.raw.length),n.push(o);continue}if(a=t,this.options.extensions&&this.options.extensions.startInline){let m=1/0;const h=t.slice(1);let g;this.options.extensions.startInline.forEach(y=>{g=y.call({lexer:this},h),typeof g=="number"&&g>=0&&(m=Math.min(m,g))}),m<1/0&&m>=0&&(a=t.substring(0,m+1))}if(o=this.tokenizer.inlineText(a)){t=t.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(d=o.raw.slice(-1)),u=!0,s=n[n.length-1],s&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(t){const m="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(m);break}else throw new Error(m)}}return n}}class pt{constructor(t){q(this,"options");q(this,"parser");this.options=t||_e}space(t){return""}code({text:t,lang:n,escaped:o}){var i;const s=(i=(n||"").match(/^\S*/))==null?void 0:i[0],a=t.replace(/\n$/,"")+`
38
- `;return s?'<pre><code class="language-'+de(s)+'">'+(o?a:de(a,!0))+`</code></pre>
39
- `:"<pre><code>"+(o?a:de(a,!0))+`</code></pre>
11
+ ${m}`:m,i=i?`${i}
12
+ ${p}`:p;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,a,!0),this.lexer.state.top=g,r.length===0)break;const k=a[a.length-1];if((k==null?void 0:k.type)==="code")break;if((k==null?void 0:k.type)==="blockquote"){const h=k,N=h.raw+`
13
+ `+r.join(`
14
+ `),f=this.blockquote(N);a[a.length-1]=f,s=s.substring(0,s.length-h.raw.length)+f.raw,i=i.substring(0,i.length-h.text.length)+f.text;break}else if((k==null?void 0:k.type)==="list"){const h=k,N=h.raw+`
15
+ `+r.join(`
16
+ `),f=this.list(N);a[a.length-1]=f,s=s.substring(0,s.length-k.raw.length)+f.raw,i=i.substring(0,i.length-h.raw.length)+f.raw,r=N.substring(a[a.length-1].raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:a,text:i}}}list(t){let o=this.rules.block.list.exec(t);if(o){let r=o[1].trim();const s=r.length>1,i={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 a=new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;t;){let c=!1,u="",m="";if(!(o=a.exec(t))||this.rules.block.hr.test(t))break;u=o[0],t=t.substring(u.length);let p=o[2].split(`
18
+ `,1)[0].replace(/^\t+/,y=>" ".repeat(3*y.length)),g=t.split(`
19
+ `,1)[0],k=!p.trim(),h=0;if(this.options.pedantic?(h=2,m=p.trimStart()):k?h=o[1].length+1:(h=o[2].search(/[^ ]/),h=h>4?1:h,m=p.slice(h),h+=o[1].length),k&&/^[ \t]*$/.test(g)&&(u+=g+`
20
+ `,t=t.substring(g.length+1),c=!0),!c){const y=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),x=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),C=new RegExp(`^ {0,${Math.min(3,h-1)}}#`),S=new RegExp(`^ {0,${Math.min(3,h-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const E=t.split(`
21
+ `,1)[0];let R;if(g=E,this.options.pedantic?(g=g.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),R=g):R=g.replace(/\t/g," "),x.test(g)||C.test(g)||S.test(g)||y.test(g)||b.test(g))break;if(R.search(/[^ ]/)>=h||!g.trim())m+=`
22
+ `+R.slice(h);else{if(k||p.replace(/\t/g," ").search(/[^ ]/)>=4||x.test(p)||C.test(p)||b.test(p))break;m+=`
23
+ `+g}!k&&!g.trim()&&(k=!0),u+=E+`
24
+ `,t=t.substring(E.length+1),p=R.slice(h)}}i.loose||(l?i.loose=!0:/\n[ \t]*\n[ \t]*$/.test(u)&&(l=!0));let N=null,f;this.options.gfm&&(N=/^\[[ xX]\] /.exec(m),N&&(f=N[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),i.items.push({type:"list_item",raw:u,task:!!N,checked:f,loose:!1,text:m,tokens:[]}),i.raw+=u}i.items[i.items.length-1].raw=i.items[i.items.length-1].raw.trimEnd(),i.items[i.items.length-1].text=i.items[i.items.length-1].text.trimEnd(),i.raw=i.raw.trimEnd();for(let c=0;c<i.items.length;c++)if(this.lexer.state.top=!1,i.items[c].tokens=this.lexer.blockTokens(i.items[c].text,[]),!i.loose){const u=i.items[c].tokens.filter(p=>p.type==="space"),m=u.length>0&&u.some(p=>/\n.*\n/.test(p.raw));i.loose=m}if(i.loose)for(let c=0;c<i.items.length;c++)i.items[c].loose=!0;return i}}html(t){const o=this.rules.block.html.exec(t);if(o)return{type:"html",block:!0,raw:o[0],pre:o[1]==="pre"||o[1]==="script"||o[1]==="style",text:o[0]}}def(t){const o=this.rules.block.def.exec(t);if(o){const r=o[1].toLowerCase().replace(/\s+/g," "),s=o[2]?o[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=o[3]?o[3].substring(1,o[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):o[3];return{type:"def",tag:r,raw:o[0],href:s,title:i}}}table(t){const o=this.rules.block.table.exec(t);if(!o||!/[:|]/.test(o[2]))return;const r=Vn(o[1]),s=o[2].replace(/^\||\| *$/g,"").split("|"),i=o[3]&&o[3].trim()?o[3].replace(/\n[ \t]*$/,"").split(`
25
+ `):[],a={type:"table",raw:o[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?a.align.push("right"):/^ *:-+: *$/.test(l)?a.align.push("center"):/^ *:-+ *$/.test(l)?a.align.push("left"):a.align.push(null);for(let l=0;l<r.length;l++)a.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:a.align[l]});for(const l of i)a.rows.push(Vn(l,a.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[u]})));return a}}lheading(t){const o=this.rules.block.lheading.exec(t);if(o)return{type:"heading",raw:o[0],depth:o[2].charAt(0)==="="?1:2,text:o[1],tokens:this.lexer.inline(o[1])}}paragraph(t){const o=this.rules.block.paragraph.exec(t);if(o){const r=o[1].charAt(o[1].length-1)===`
26
+ `?o[1].slice(0,-1):o[1];return{type:"paragraph",raw:o[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const o=this.rules.block.text.exec(t);if(o)return{type:"text",raw:o[0],text:o[0],tokens:this.lexer.inline(o[0])}}escape(t){const o=this.rules.inline.escape.exec(t);if(o)return{type:"escape",raw:o[0],text:ue(o[1])}}tag(t){const o=this.rules.inline.tag.exec(t);if(o)return!this.lexer.state.inLink&&/^<a /i.test(o[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(o[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(o[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(o[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:o[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:o[0]}}link(t){const o=this.rules.inline.link.exec(t);if(o){const r=o[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const a=Ze(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{const a=gr(o[2],"()");if(a>-1){const c=(o[0].indexOf("!")===0?5:4)+o[1].length+a;o[2]=o[2].substring(0,a),o[0]=o[0].substring(0,c).trim(),o[3]=""}}let s=o[2],i="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);a&&(s=a[1],i=a[3])}else i=o[3]?o[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(r)?s=s.slice(1):s=s.slice(1,-1)),On(o,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},o[0],this.lexer)}}reflink(t,o){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){const s=(r[2]||r[1]).replace(/\s+/g," "),i=o[s.toLowerCase()];if(!i){const a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return On(r,i,r[0],this.lexer)}}emStrong(t,o,r=""){let s=this.rules.inline.emStrongLDelim.exec(t);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 a=[...s[0]].length-1;let l,c,u=a,m=0;const p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,o=o.slice(-1*t.length+a);(s=p.exec(o))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(c=[...l].length,s[3]||s[4]){u+=c;continue}else if((s[5]||s[6])&&a%3&&!((a+c)%3)){m+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+m);const g=[...s[0]][0].length,k=t.slice(0,a+s.index+g+c);if(Math.min(a,c)%2){const N=k.slice(1,-1);return{type:"em",raw:k,text:N,tokens:this.lexer.inlineTokens(N)}}const h=k.slice(2,-2);return{type:"strong",raw:k,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){const o=this.rules.inline.code.exec(t);if(o){let r=o[2].replace(/\n/g," ");const s=/[^ ]/.test(r),i=/^ /.test(r)&&/ $/.test(r);return s&&i&&(r=r.substring(1,r.length-1)),r=ue(r,!0),{type:"codespan",raw:o[0],text:r}}}br(t){const o=this.rules.inline.br.exec(t);if(o)return{type:"br",raw:o[0]}}del(t){const o=this.rules.inline.del.exec(t);if(o)return{type:"del",raw:o[0],text:o[2],tokens:this.lexer.inlineTokens(o[2])}}autolink(t){const o=this.rules.inline.autolink.exec(t);if(o){let r,s;return o[2]==="@"?(r=ue(o[1]),s="mailto:"+r):(r=ue(o[1]),s=r),{type:"link",raw:o[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(t){var r;let o;if(o=this.rules.inline.url.exec(t)){let s,i;if(o[2]==="@")s=ue(o[0]),i="mailto:"+s;else{let a;do a=o[0],o[0]=((r=this.rules.inline._backpedal.exec(o[0]))==null?void 0:r[0])??"";while(a!==o[0]);s=ue(o[0]),o[1]==="www."?i="http://"+o[0]:i=o[0]}return{type:"link",raw:o[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){const o=this.rules.inline.text.exec(t);if(o){let r;return this.lexer.state.inRawBlock?r=o[0]:r=ue(o[0]),{type:"text",raw:o[0],text:r}}}}const kr=/^(?:[ \t]*(?:\n|$))+/,xr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,wr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Xe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,br=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pn=/(?:[*+-]|\d{1,9}[.)])/,Fn=U(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Pn).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(),Pt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Cr=/^[^\n]+/,Ft=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Er=U(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ft).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Sr=U(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pn).getRegex(),gt="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",Ut=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Tr=U("^ {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",Ut).replace("tag",gt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Un=U(Pt).replace("hr",Xe).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",gt).getRegex(),qt={blockquote:U(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Un).getRegex(),code:xr,def:Er,fences:wr,heading:br,hr:Xe,html:Tr,lheading:Fn,list:Sr,newline:kr,paragraph:Un,table:Ye,text:Cr},qn=U("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Xe).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",gt).getRegex(),Ar={...qt,table:qn,paragraph:U(Pt).replace("hr",Xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qn).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",gt).getRegex()},Nr={...qt,html:U(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ut).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:Ye,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:U(Pt).replace("hr",Xe).replace("heading",` *#{1,6} *[^
27
+ ]`).replace("lheading",Fn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},jn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Br=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wn=/^( {2,}|\\)\n(?!\s*$)/,Mr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Je="\\p{P}\\p{S}",Rr=U(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Je).getRegex(),Ir=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,_r=U(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Je).getRegex(),$r=U("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Je).getRegex(),Lr=U("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Je).getRegex(),Dr=U(/\\([punct])/,"gu").replace(/punct/g,Je).getRegex(),zr=U(/^<(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(),Hr=U(Ut).replace("(?:-->|$)","-->").getRegex(),Vr=U("^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",Hr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Or=U(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",yt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Kn=U(/^!?\[(label)\]\[(ref)\]/).replace("label",yt).replace("ref",Ft).getRegex(),Qn=U(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ft).getRegex(),Pr=U("reflink|nolink(?!\\()","g").replace("reflink",Kn).replace("nolink",Qn).getRegex(),jt={_backpedal:Ye,anyPunctuation:Dr,autolink:zr,blockSkip:Ir,br:Wn,code:Br,del:Ye,emStrongLDelim:_r,emStrongRDelimAst:$r,emStrongRDelimUnd:Lr,escape:jn,link:Or,nolink:Qn,punctuation:Rr,reflink:Kn,reflinkSearch:Pr,tag:Vr,text:Mr,url:Ye},Fr={...jt,link:U(/^!?\[(label)\]\((.*?)\)/).replace("label",yt).getRegex(),reflink:U(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yt).getRegex()},Wt={...jt,escape:U(jn).replace("])","~|])").getRegex(),url:U(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ur={...Wt,br:U(Wn).replace("{2,}","*").getRegex(),text:U(Wt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},kt={normal:qt,gfm:Ar,pedantic:Nr},et={normal:jt,gfm:Wt,breaks:Ur,pedantic:Fr};class me{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"tokenizer");q(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||_e,this.options.tokenizer=this.options.tokenizer||new pt,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 o={block:kt.normal,inline:et.normal};this.options.pedantic?(o.block=kt.pedantic,o.inline=et.pedantic):this.options.gfm&&(o.block=kt.gfm,this.options.breaks?o.inline=et.breaks:o.inline=et.gfm),this.tokenizer.rules=o}static get rules(){return{block:kt,inline:et}}static lex(t,o){return new me(o).lex(t)}static lexInline(t,o){return new me(o).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
28
+ `),this.blockTokens(t,this.tokens);for(let o=0;o<this.inlineQueue.length;o++){const r=this.inlineQueue[o];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,o=[],r=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let s,i,a;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(s=l.call({lexer:this},t,o))?(t=t.substring(s.raw.length),o.push(s),!0):!1))){if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length),s.raw.length===1&&o.length>0?o[o.length-1].raw+=`
29
+ `:o.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length),i=o[o.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
30
+ `+s.raw,i.text+=`
31
+ `+s.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):o.push(s);continue}if(s=this.tokenizer.fences(t)){t=t.substring(s.raw.length),o.push(s);continue}if(s=this.tokenizer.heading(t)){t=t.substring(s.raw.length),o.push(s);continue}if(s=this.tokenizer.hr(t)){t=t.substring(s.raw.length),o.push(s);continue}if(s=this.tokenizer.blockquote(t)){t=t.substring(s.raw.length),o.push(s);continue}if(s=this.tokenizer.list(t)){t=t.substring(s.raw.length),o.push(s);continue}if(s=this.tokenizer.html(t)){t=t.substring(s.raw.length),o.push(s);continue}if(s=this.tokenizer.def(t)){t=t.substring(s.raw.length),i=o[o.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
32
+ `+s.raw,i.text+=`
33
+ `+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(t)){t=t.substring(s.raw.length),o.push(s);continue}if(s=this.tokenizer.lheading(t)){t=t.substring(s.raw.length),o.push(s);continue}if(a=t,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const c=t.slice(1);let u;this.options.extensions.startBlock.forEach(m=>{u=m.call({lexer:this},c),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(a=t.substring(0,l+1))}if(this.state.top&&(s=this.tokenizer.paragraph(a))){i=o[o.length-1],r&&(i==null?void 0:i.type)==="paragraph"?(i.raw+=`
34
+ `+s.raw,i.text+=`
35
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):o.push(s),r=a.length!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length),i=o[o.length-1],i&&i.type==="text"?(i.raw+=`
36
+ `+s.raw,i.text+=`
37
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):o.push(s);continue}if(t){const l="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,o}inline(t,o=[]){return this.inlineQueue.push({src:t,tokens:o}),o}inlineTokens(t,o=[]){let r,s,i,a=t,l,c,u;if(this.tokens.links){const m=Object.keys(this.tokens.links);if(m.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)m.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,l.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(c||(u=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(m=>(r=m.call({lexer:this},t,o))?(t=t.substring(r.raw.length),o.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),o.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),s=o[o.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):o.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),o.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),s=o[o.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):o.push(r);continue}if(r=this.tokenizer.emStrong(t,a,u)){t=t.substring(r.raw.length),o.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),o.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),o.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),o.push(r);continue}if(r=this.tokenizer.autolink(t)){t=t.substring(r.raw.length),o.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t))){t=t.substring(r.raw.length),o.push(r);continue}if(i=t,this.options.extensions&&this.options.extensions.startInline){let m=1/0;const p=t.slice(1);let g;this.options.extensions.startInline.forEach(k=>{g=k.call({lexer:this},p),typeof g=="number"&&g>=0&&(m=Math.min(m,g))}),m<1/0&&m>=0&&(i=t.substring(0,m+1))}if(r=this.tokenizer.inlineText(i)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),c=!0,s=o[o.length-1],s&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):o.push(r);continue}if(t){const m="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(m);break}else throw new Error(m)}}return o}}class xt{constructor(t){q(this,"options");q(this,"parser");this.options=t||_e}space(t){return""}code({text:t,lang:o,escaped:r}){var a;const s=(a=(o||"").match(/^\S*/))==null?void 0:a[0],i=t.replace(/\n$/,"")+`
38
+ `;return s?'<pre><code class="language-'+ue(s)+'">'+(r?i:ue(i,!0))+`</code></pre>
39
+ `:"<pre><code>"+(r?i:ue(i,!0))+`</code></pre>
40
40
  `}blockquote({tokens:t}){return`<blockquote>
41
41
  ${this.parser.parse(t)}</blockquote>
42
- `}html({text:t}){return t}heading({tokens:t,depth:n}){return`<h${n}>${this.parser.parseInline(t)}</h${n}>
42
+ `}html({text:t}){return t}heading({tokens:t,depth:o}){return`<h${o}>${this.parser.parseInline(t)}</h${o}>
43
43
  `}hr(t){return`<hr>
44
- `}list(t){const n=t.ordered,o=t.start;let s="";for(let l=0;l<t.items.length;l++){const u=t.items[l];s+=this.listitem(u)}const a=n?"ol":"ul",i=n&&o!==1?' start="'+o+'"':"";return"<"+a+i+`>
45
- `+s+"</"+a+`>
46
- `}listitem(t){let n="";if(t.task){const o=this.checkbox({checked:!!t.checked});t.loose?t.tokens.length>0&&t.tokens[0].type==="paragraph"?(t.tokens[0].text=o+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=o+" "+t.tokens[0].tokens[0].text)):t.tokens.unshift({type:"text",raw:o+" ",text:o+" "}):n+=o+" "}return n+=this.parser.parse(t.tokens,!!t.loose),`<li>${n}</li>
44
+ `}list(t){const o=t.ordered,r=t.start;let s="";for(let l=0;l<t.items.length;l++){const c=t.items[l];s+=this.listitem(c)}const i=o?"ol":"ul",a=o&&r!==1?' start="'+r+'"':"";return"<"+i+a+`>
45
+ `+s+"</"+i+`>
46
+ `}listitem(t){let o="";if(t.task){const r=this.checkbox({checked:!!t.checked});t.loose?t.tokens.length>0&&t.tokens[0].type==="paragraph"?(t.tokens[0].text=r+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=r+" "+t.tokens[0].tokens[0].text)):t.tokens.unshift({type:"text",raw:r+" ",text:r+" "}):o+=r+" "}return o+=this.parser.parse(t.tokens,!!t.loose),`<li>${o}</li>
47
47
  `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
48
- `}table(t){let n="",o="";for(let a=0;a<t.header.length;a++)o+=this.tablecell(t.header[a]);n+=this.tablerow({text:o});let s="";for(let a=0;a<t.rows.length;a++){const i=t.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(t){let o="",r="";for(let i=0;i<t.header.length;i++)r+=this.tablecell(t.header[i]);o+=this.tablerow({text:r});let s="";for(let i=0;i<t.rows.length;i++){const a=t.rows[i];r="";for(let l=0;l<a.length;l++)r+=this.tablecell(a[l]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
49
49
  <thead>
50
- `+n+`</thead>
50
+ `+o+`</thead>
51
51
  `+s+`</table>
52
52
  `}tablerow({text:t}){return`<tr>
53
53
  ${t}</tr>
54
- `}tablecell(t){const n=this.parser.parseInline(t.tokens),o=t.header?"th":"td";return(t.align?`<${o} align="${t.align}">`:`<${o}>`)+n+`</${o}>
55
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:o}){const s=this.parser.parseInline(o),a=An(t);if(a===null)return s;t=a;let i='<a href="'+t+'"';return n&&(i+=' title="'+n+'"'),i+=">"+s+"</a>",i}image({href:t,title:n,text:o}){const s=An(t);if(s===null)return o;t=s;let a=`<img src="${t}" alt="${o}"`;return n&&(a+=` title="${n}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Ft{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class fe{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||_e,this.options.renderer=this.options.renderer||new pt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ft}static parse(t,n){return new fe(n).parse(t)}static parseInline(t,n){return new fe(n).parseInline(t)}parse(t,n=!0){let o="";for(let s=0;s<t.length;s++){const a=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=a,u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){o+=u||"";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,u=this.renderer.text(l);for(;s+1<t.length&&t[s+1].type==="text";)l=t[++s],u+=`
56
- `+this.renderer.text(l);n?o+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u}]}):o+=u;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(t,n){n=n||this.renderer;let o="";for(let s=0;s<t.length;s++){const a=t[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 Ye{constructor(t){q(this,"options");q(this,"block");this.options=t||_e}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?me.lex:me.lexInline}provideParser(){return this.block?fe.parse:fe.parseInline}}q(Ye,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class Lo{constructor(...t){q(this,"defaults",It());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",fe);q(this,"Renderer",pt);q(this,"TextRenderer",Ft);q(this,"Lexer",me);q(this,"Tokenizer",ut);q(this,"Hooks",Ye);this.use(...t)}walkTokens(t,n){var s,a;let o=[];for(const i of t)switch(o=o.concat(n.call(this,i)),i.type){case"table":{const l=i;for(const u of l.header)o=o.concat(this.walkTokens(u.tokens,n));for(const u of l.rows)for(const d of u)o=o.concat(this.walkTokens(d.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(u=>{const d=l[u].flat(1/0);o=o.concat(this.walkTokens(d,n))}):l.tokens&&(o=o.concat(this.walkTokens(l.tokens,n)))}}return o}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.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 u=a.renderer.apply(this,l);return u===!1&&(u=i.apply(this,l)),u}: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 pt(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,u=o.renderer[l],d=a[l];a[l]=(...m)=>{let h=u.apply(a,m);return h===!1&&(h=d.apply(a,m)),h||""}}s.renderer=a}if(o.tokenizer){const a=this.defaults.tokenizer||new ut(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,u=o.tokenizer[l],d=a[l];a[l]=(...m)=>{let h=u.apply(a,m);return h===!1&&(h=d.apply(a,m)),h}}s.tokenizer=a}if(o.hooks){const a=this.defaults.hooks||new Ye;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,u=o.hooks[l],d=a[l];Ye.passThroughHooks.has(i)?a[l]=m=>{if(this.defaults.async)return Promise.resolve(u.call(a,m)).then(g=>d.call(a,g));const h=u.call(a,m);return d.call(a,h)}:a[l]=(...m)=>{let h=u.apply(a,m);return h===!1&&(h=d.apply(a,m)),h}}s.hooks=a}if(o.walkTokens){const a=this.defaults.walkTokens,i=o.walkTokens;s.walkTokens=function(l){let u=[];return u.push(i.call(this,l)),a&&(u=u.concat(a.call(this,l))),u}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return me.lex(t,n??this.defaults)}parser(t,n){return fe.parse(t,n??this.defaults)}parseMarkdown(t){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=t);const u=i.hooks?i.hooks.provideLexer():t?me.lex:me.lexInline,d=i.hooks?i.hooks.provideParser():t?fe.parse:fe.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(o):o).then(m=>u(m,i)).then(m=>i.hooks?i.hooks.processAllTokens(m):m).then(m=>i.walkTokens?Promise.all(this.walkTokens(m,i.walkTokens)).then(()=>m):m).then(m=>d(m,i)).then(m=>i.hooks?i.hooks.postprocess(m):m).catch(l);try{i.hooks&&(o=i.hooks.preprocess(o));let m=u(o,i);i.hooks&&(m=i.hooks.processAllTokens(m)),i.walkTokens&&this.walkTokens(m,i.walkTokens);let h=d(m,i);return i.hooks&&(h=i.hooks.postprocess(h)),h}catch(m){return l(m)}}}onError(t,n){return o=>{if(o.message+=`
57
- Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+de(o.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(o);throw o}}}const Le=new Lo;function F(r,t){return Le.parse(r,t)}F.options=F.setOptions=function(r){return Le.setOptions(r),F.defaults=Le.defaults,Cn(F.defaults),F},F.getDefaults=It,F.defaults=_e,F.use=function(...r){return Le.use(...r),F.defaults=Le.defaults,Cn(F.defaults),F},F.walkTokens=function(r,t){return Le.walkTokens(r,t)},F.parseInline=Le.parseInline,F.Parser=fe,F.parser=fe.parse,F.Renderer=pt,F.TextRenderer=Ft,F.Lexer=me,F.lexer=me.lex,F.Tokenizer=ut,F.Hooks=Ye,F.parse=F,F.options,F.setOptions,F.use,F.walkTokens,F.parseInline,fe.parse,me.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:On,setPrototypeOf:Pn,isFrozen:Io,getPrototypeOf:$o,getOwnPropertyDescriptor:Do}=Object;let{freeze:se,seal:pe,create:Ht}=Object,{apply:Ut,construct:qt}=typeof Reflect<"u"&&Reflect;se||(se=function(t){return t}),pe||(pe=function(t){return t}),Ut||(Ut=function(t,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 t.apply(n,s)}),qt||(qt=function(t){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 t(...o)});const ht=ie(Array.prototype.forEach),zo=ie(Array.prototype.lastIndexOf),Vn=ie(Array.prototype.pop),Xe=ie(Array.prototype.push),Oo=ie(Array.prototype.splice),gt=ie(String.prototype.toLowerCase),jt=ie(String.prototype.toString),Wt=ie(String.prototype.match),Je=ie(String.prototype.replace),Po=ie(String.prototype.indexOf),Vo=ie(String.prototype.trim),he=ie(Object.prototype.hasOwnProperty),ae=ie(RegExp.prototype.test),ve=Fo(TypeError);function ie(r){return function(t){t instanceof RegExp&&(t.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 Ut(r,t,o)}}function Fo(r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return qt(r,n)}}function D(r,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gt;Pn&&Pn(r,null);let o=t.length;for(;o--;){let s=t[o];if(typeof s=="string"){const a=n(s);a!==s&&(Io(t)||(t[o]=a),s=a)}r[s]=!0}return r}function Ho(r){for(let t=0;t<r.length;t++)he(r,t)||(r[t]=null);return r}function xe(r){const t=Ht(null);for(const[n,o]of On(r))he(r,n)&&(Array.isArray(o)?t[n]=Ho(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=xe(o):t[n]=o);return t}function et(r,t){for(;r!==null;){const o=Do(r,t);if(o){if(o.get)return ie(o.get);if(typeof o.value=="function")return ie(o.value)}r=$o(r)}function n(){return null}return n}const Fn=se(["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"]),Kt=se(["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"]),Gt=se(["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"]),Uo=se(["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"]),Qt=se(["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"]),qo=se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hn=se(["#text"]),Un=se(["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"]),Zt=se(["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"]),qn=se(["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"]),yt=se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),jo=pe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Wo=pe(/<%[\w\W]*|[\w\W]*%>/gm),Ko=pe(/\$\{[\w\W]*/gm),Go=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qo=pe(/^aria-[\-\w]+$/),jn=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Zo=pe(/^(?:\w+script|data):/i),Yo=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wn=pe(/^html$/i),Xo=pe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Kn=Object.freeze({__proto__:null,ARIA_ATTR:Qo,ATTR_WHITESPACE:Yo,CUSTOM_ELEMENT:Xo,DATA_ATTR:Go,DOCTYPE_NAME:Wn,ERB_EXPR:Wo,IS_ALLOWED_URI:jn,IS_SCRIPT_OR_DATA:Zo,MUSTACHE_EXPR:jo,TMPLIT_EXPR:Ko});const tt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Jo=function(){return typeof window>"u"?null:window},vo=function(t,n){if(typeof t!="object"||typeof t.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 t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Gn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Qn(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Jo();const t=T=>Qn(T);if(t.version="3.3.0",t.removed=[],!r||!r.document||r.document.nodeType!==tt.document||!r.Element)return t.isSupported=!1,t;let{document:n}=r;const o=n,s=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:u,NodeFilter:d,NamedNodeMap:m=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:h,DOMParser:g,trustedTypes:y}=r,f=u.prototype,S=et(f,"cloneNode"),p=et(f,"remove"),w=et(f,"nextSibling"),M=et(f,"childNodes"),x=et(f,"parentNode");if(typeof i=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let C,I="";const{implementation:b,createNodeIterator:N,createDocumentFragment:L,getElementsByTagName:A}=n,{importNode:B}=o;let V=Gn();t.isSupported=typeof On=="function"&&typeof x=="function"&&b&&b.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:G,ERB_EXPR:_,TMPLIT_EXPR:O,DATA_ATTR:z,ARIA_ATTR:ne,IS_SCRIPT_OR_DATA:be,ATTR_WHITESPACE:U,CUSTOM_ELEMENT:nt}=Kn;let{IS_ALLOWED_URI:Ie}=Kn,Q=null;const xt=D({},[...Fn,...Kt,...Gt,...Qt,...Hn]);let Y=null;const bt=D({},[...Un,...Zt,...qn,...yt]);let j=Object.seal(Ht(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}})),Me=null,rt=null;const Be=Object.seal(Ht(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wt=!0,Oe=!0,ot=!1,Ct=!0,we=!1,$=!0,P=!1,X=!1,le=!1,J=!1,v=!1,ce=!1,Et=!0,ur=!1;const Ni="user-content-";let en=!0,st=!1,Pe={},Ve=null;const dr=D({},["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 mr=null;const fr=D({},["audio","video","img","source","image","track"]);let tn=null;const pr=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),St="http://www.w3.org/1998/Math/MathML",Tt="http://www.w3.org/2000/svg",Ce="http://www.w3.org/1999/xhtml";let Fe=Ce,nn=!1,rn=null;const Ri=D({},[St,Tt,Ce],jt);let At=D({},["mi","mo","mn","ms","mtext"]),Mt=D({},["annotation-xml"]);const _i=D({},["title","style","font","a","script"]);let at=null;const Li=["application/xhtml+xml","text/html"],Ii="text/html";let ee=null,He=null;const $i=n.createElement("form"),hr=function(c){return c instanceof RegExp||c instanceof Function},on=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(He&&He===c)){if((!c||typeof c!="object")&&(c={}),c=xe(c),at=Li.indexOf(c.PARSER_MEDIA_TYPE)===-1?Ii:c.PARSER_MEDIA_TYPE,ee=at==="application/xhtml+xml"?jt:gt,Q=he(c,"ALLOWED_TAGS")?D({},c.ALLOWED_TAGS,ee):xt,Y=he(c,"ALLOWED_ATTR")?D({},c.ALLOWED_ATTR,ee):bt,rn=he(c,"ALLOWED_NAMESPACES")?D({},c.ALLOWED_NAMESPACES,jt):Ri,tn=he(c,"ADD_URI_SAFE_ATTR")?D(xe(pr),c.ADD_URI_SAFE_ATTR,ee):pr,mr=he(c,"ADD_DATA_URI_TAGS")?D(xe(fr),c.ADD_DATA_URI_TAGS,ee):fr,Ve=he(c,"FORBID_CONTENTS")?D({},c.FORBID_CONTENTS,ee):dr,Me=he(c,"FORBID_TAGS")?D({},c.FORBID_TAGS,ee):xe({}),rt=he(c,"FORBID_ATTR")?D({},c.FORBID_ATTR,ee):xe({}),Pe=he(c,"USE_PROFILES")?c.USE_PROFILES:!1,wt=c.ALLOW_ARIA_ATTR!==!1,Oe=c.ALLOW_DATA_ATTR!==!1,ot=c.ALLOW_UNKNOWN_PROTOCOLS||!1,Ct=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,we=c.SAFE_FOR_TEMPLATES||!1,$=c.SAFE_FOR_XML!==!1,P=c.WHOLE_DOCUMENT||!1,J=c.RETURN_DOM||!1,v=c.RETURN_DOM_FRAGMENT||!1,ce=c.RETURN_TRUSTED_TYPE||!1,le=c.FORCE_BODY||!1,Et=c.SANITIZE_DOM!==!1,ur=c.SANITIZE_NAMED_PROPS||!1,en=c.KEEP_CONTENT!==!1,st=c.IN_PLACE||!1,Ie=c.ALLOWED_URI_REGEXP||jn,Fe=c.NAMESPACE||Ce,At=c.MATHML_TEXT_INTEGRATION_POINTS||At,Mt=c.HTML_INTEGRATION_POINTS||Mt,j=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&hr(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&hr(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),we&&(Oe=!1),v&&(J=!0),Pe&&(Q=D({},Hn),Y=[],Pe.html===!0&&(D(Q,Fn),D(Y,Un)),Pe.svg===!0&&(D(Q,Kt),D(Y,Zt),D(Y,yt)),Pe.svgFilters===!0&&(D(Q,Gt),D(Y,Zt),D(Y,yt)),Pe.mathMl===!0&&(D(Q,Qt),D(Y,qn),D(Y,yt))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?Be.tagCheck=c.ADD_TAGS:(Q===xt&&(Q=xe(Q)),D(Q,c.ADD_TAGS,ee))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?Be.attributeCheck=c.ADD_ATTR:(Y===bt&&(Y=xe(Y)),D(Y,c.ADD_ATTR,ee))),c.ADD_URI_SAFE_ATTR&&D(tn,c.ADD_URI_SAFE_ATTR,ee),c.FORBID_CONTENTS&&(Ve===dr&&(Ve=xe(Ve)),D(Ve,c.FORBID_CONTENTS,ee)),en&&(Q["#text"]=!0),P&&D(Q,["html","head","body"]),Q.table&&(D(Q,["tbody"]),delete Me.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw ve('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ve('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=c.TRUSTED_TYPES_POLICY,I=C.createHTML("")}else C===void 0&&(C=vo(y,s)),C!==null&&typeof I=="string"&&(I=C.createHTML(""));se&&se(c),He=c}},gr=D({},[...Kt,...Gt,...Uo]),yr=D({},[...Qt,...qo]),Di=function(c){let k=x(c);(!k||!k.tagName)&&(k={namespaceURI:Fe,tagName:"template"});const E=gt(c.tagName),W=gt(k.tagName);return rn[c.namespaceURI]?c.namespaceURI===Tt?k.namespaceURI===Ce?E==="svg":k.namespaceURI===St?E==="svg"&&(W==="annotation-xml"||At[W]):!!gr[E]:c.namespaceURI===St?k.namespaceURI===Ce?E==="math":k.namespaceURI===Tt?E==="math"&&Mt[W]:!!yr[E]:c.namespaceURI===Ce?k.namespaceURI===Tt&&!Mt[W]||k.namespaceURI===St&&!At[W]?!1:!yr[E]&&(_i[E]||!gr[E]):!!(at==="application/xhtml+xml"&&rn[c.namespaceURI]):!1},ye=function(c){Xe(t.removed,{element:c});try{x(c).removeChild(c)}catch{p(c)}},$e=function(c,k){try{Xe(t.removed,{attribute:k.getAttributeNode(c),from:k})}catch{Xe(t.removed,{attribute:null,from:k})}if(k.removeAttribute(c),c==="is")if(J||v)try{ye(k)}catch{}else try{k.setAttribute(c,"")}catch{}},kr=function(c){let k=null,E=null;if(le)c="<remove></remove>"+c;else{const Z=Wt(c,/^[\r\n\t ]+/);E=Z&&Z[0]}at==="application/xhtml+xml"&&Fe===Ce&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const W=C?C.createHTML(c):c;if(Fe===Ce)try{k=new g().parseFromString(W,at)}catch{}if(!k||!k.documentElement){k=b.createDocument(Fe,"template",null);try{k.documentElement.innerHTML=nn?I:W}catch{}}const oe=k.body||k.documentElement;return c&&E&&oe.insertBefore(n.createTextNode(E),oe.childNodes[0]||null),Fe===Ce?A.call(k,P?"html":"body")[0]:P?k.documentElement:oe},xr=function(c){return N.call(c.ownerDocument||c,c,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},sn=function(c){return c instanceof h&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof m)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},br=function(c){return typeof l=="function"&&c instanceof l};function Ee(T,c,k){ht(T,E=>{E.call(t,c,k,He)})}const wr=function(c){let k=null;if(Ee(V.beforeSanitizeElements,c,null),sn(c))return ye(c),!0;const E=ee(c.nodeName);if(Ee(V.uponSanitizeElement,c,{tagName:E,allowedTags:Q}),$&&c.hasChildNodes()&&!br(c.firstElementChild)&&ae(/<[/\w!]/g,c.innerHTML)&&ae(/<[/\w!]/g,c.textContent)||c.nodeType===tt.progressingInstruction||$&&c.nodeType===tt.comment&&ae(/<[/\w]/g,c.data))return ye(c),!0;if(!(Be.tagCheck instanceof Function&&Be.tagCheck(E))&&(!Q[E]||Me[E])){if(!Me[E]&&Er(E)&&(j.tagNameCheck instanceof RegExp&&ae(j.tagNameCheck,E)||j.tagNameCheck instanceof Function&&j.tagNameCheck(E)))return!1;if(en&&!Ve[E]){const W=x(c)||c.parentNode,oe=M(c)||c.childNodes;if(oe&&W){const Z=oe.length;for(let ue=Z-1;ue>=0;--ue){const Se=S(oe[ue],!0);Se.__removalCount=(c.__removalCount||0)+1,W.insertBefore(Se,w(c))}}}return ye(c),!0}return c instanceof u&&!Di(c)||(E==="noscript"||E==="noembed"||E==="noframes")&&ae(/<\/no(script|embed|frames)/i,c.innerHTML)?(ye(c),!0):(we&&c.nodeType===tt.text&&(k=c.textContent,ht([G,_,O],W=>{k=Je(k,W," ")}),c.textContent!==k&&(Xe(t.removed,{element:c.cloneNode()}),c.textContent=k)),Ee(V.afterSanitizeElements,c,null),!1)},Cr=function(c,k,E){if(Et&&(k==="id"||k==="name")&&(E in n||E in $i))return!1;if(!(Oe&&!rt[k]&&ae(z,k))){if(!(wt&&ae(ne,k))){if(!(Be.attributeCheck instanceof Function&&Be.attributeCheck(k,c))){if(!Y[k]||rt[k]){if(!(Er(c)&&(j.tagNameCheck instanceof RegExp&&ae(j.tagNameCheck,c)||j.tagNameCheck instanceof Function&&j.tagNameCheck(c))&&(j.attributeNameCheck instanceof RegExp&&ae(j.attributeNameCheck,k)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(k,c))||k==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&ae(j.tagNameCheck,E)||j.tagNameCheck instanceof Function&&j.tagNameCheck(E))))return!1}else if(!tn[k]){if(!ae(Ie,Je(E,U,""))){if(!((k==="src"||k==="xlink:href"||k==="href")&&c!=="script"&&Po(E,"data:")===0&&mr[c])){if(!(ot&&!ae(be,Je(E,U,"")))){if(E)return!1}}}}}}}return!0},Er=function(c){return c!=="annotation-xml"&&Wt(c,nt)},Sr=function(c){Ee(V.beforeSanitizeAttributes,c,null);const{attributes:k}=c;if(!k||sn(c))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let W=k.length;for(;W--;){const oe=k[W],{name:Z,namespaceURI:ue,value:Se}=oe,Ue=ee(Z),an=Se;let re=Z==="value"?an:Vo(an);if(E.attrName=Ue,E.attrValue=re,E.keepAttr=!0,E.forceKeepAttr=void 0,Ee(V.uponSanitizeAttribute,c,E),re=E.attrValue,ur&&(Ue==="id"||Ue==="name")&&($e(Z,c),re=Ni+re),$&&ae(/((--!?|])>)|<\/(style|title|textarea)/i,re)){$e(Z,c);continue}if(Ue==="attributename"&&Wt(re,"href")){$e(Z,c);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){$e(Z,c);continue}if(!Ct&&ae(/\/>/i,re)){$e(Z,c);continue}we&&ht([G,_,O],Ar=>{re=Je(re,Ar," ")});const Tr=ee(c.nodeName);if(!Cr(Tr,Ue,re)){$e(Z,c);continue}if(C&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!ue)switch(y.getAttributeType(Tr,Ue)){case"TrustedHTML":{re=C.createHTML(re);break}case"TrustedScriptURL":{re=C.createScriptURL(re);break}}if(re!==an)try{ue?c.setAttributeNS(ue,Z,re):c.setAttribute(Z,re),sn(c)?ye(c):Vn(t.removed)}catch{$e(Z,c)}}Ee(V.afterSanitizeAttributes,c,null)},zi=function T(c){let k=null;const E=xr(c);for(Ee(V.beforeSanitizeShadowDOM,c,null);k=E.nextNode();)Ee(V.uponSanitizeShadowNode,k,null),wr(k),Sr(k),k.content instanceof a&&T(k.content);Ee(V.afterSanitizeShadowDOM,c,null)};return t.sanitize=function(T){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=null,E=null,W=null,oe=null;if(nn=!T,nn&&(T="<!-->"),typeof T!="string"&&!br(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw ve("dirty is not a string, aborting")}else throw ve("toString is not a function");if(!t.isSupported)return T;if(X||on(c),t.removed=[],typeof T=="string"&&(st=!1),st){if(T.nodeName){const Se=ee(T.nodeName);if(!Q[Se]||Me[Se])throw ve("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)k=kr("<!---->"),E=k.ownerDocument.importNode(T,!0),E.nodeType===tt.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?k=E:k.appendChild(E);else{if(!J&&!we&&!P&&T.indexOf("<")===-1)return C&&ce?C.createHTML(T):T;if(k=kr(T),!k)return J?null:ce?I:""}k&&le&&ye(k.firstChild);const Z=xr(st?T:k);for(;W=Z.nextNode();)wr(W),Sr(W),W.content instanceof a&&zi(W.content);if(st)return T;if(J){if(v)for(oe=L.call(k.ownerDocument);k.firstChild;)oe.appendChild(k.firstChild);else oe=k;return(Y.shadowroot||Y.shadowrootmode)&&(oe=B.call(o,oe,!0)),oe}let ue=P?k.outerHTML:k.innerHTML;return P&&Q["!doctype"]&&k.ownerDocument&&k.ownerDocument.doctype&&k.ownerDocument.doctype.name&&ae(Wn,k.ownerDocument.doctype.name)&&(ue="<!DOCTYPE "+k.ownerDocument.doctype.name+`>
58
- `+ue),we&&ht([G,_,O],Se=>{ue=Je(ue,Se," ")}),C&&ce?C.createHTML(ue):ue},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};on(T),X=!0},t.clearConfig=function(){He=null,X=!1},t.isValidAttribute=function(T,c,k){He||on({});const E=ee(T),W=ee(c);return Cr(E,W,k)},t.addHook=function(T,c){typeof c=="function"&&Xe(V[T],c)},t.removeHook=function(T,c){if(c!==void 0){const k=zo(V[T],c);return k===-1?void 0:Oo(V[T],k,1)[0]}return Vn(V[T])},t.removeHooks=function(T){V[T]=[]},t.removeAllHooks=function(){V=Gn()},t}var es=Qn();function Zn(){return{parseMarkdown:t=>{if(!t||typeof t!="string")return"";const n=hn(t),o=F.parse(n,{async:!1,breaks:!0,gfm:!0});return es.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 ts(){let r=null;function t(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:u,clientHeight:d}=a;return u-l-d<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 e.onUnmounted(()=>{s()}),{scrollToBottom:t,setupAutoScroll:o,cleanupAutoScroll:s}}function ns(){const r=Ae(),t=e.computed(()=>r.error),n=e.computed(()=>{var a,i;return((a=t.value)==null?void 0:a.message)!==null&&((i=t.value)==null?void 0:i.message)!==void 0});return{errorState:t,hasError:n,retry:async()=>await r.retry(),clearError:()=>{r.clearError()}}}function Yt(){const r=Ae(),t=e.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:t,setContext:n,clearContext:o,updateContext:s}}const ge=[],Yn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const r=K();return(r==null?void 0:r.defaultSuggestions)||[]}};function rs(){ge.length=0;const r=K();r!=null&&r.suggestionProviders&&ge.push(...r.suggestionProviders),ge.push(Yn)}function os(r,t){const n=[...ge].sort((o,s)=>(s.priority||0)-(o.priority||0));for(const o of n)if(o.matcher&&o.matcher(r,t)||o.routes&&o.routes.some(a=>a.endsWith("*")?r.startsWith(a.slice(0,-1)):r===a||r.startsWith(a+"/")))return o;return Yn}function Xn(r,t){ge.length===0&&rs();const n=os(r,t),o=t||{pageType:"default",routePath:r};return n.extractContext&&(o.metadata={...o.metadata,...n.extractContext(r)}),n.getSuggestions(o)||[]}function ss(r){const t=ge.findIndex(n=>n.id===r.id);if(t>=0)ge[t]=r;else{const n=ge.findIndex(o=>o.id==="default");n>=0?ge.splice(n,0,r):ge.push(r)}}const as=ss;function Xt(){const{context:r}=Yt(),t=Ae(),n=K();function o(){var u;return(u=r.value)!=null&&u.routePath?r.value.routePath:typeof window<"u"?window.location.pathname:"/"}function s(u){return n!=null&&n.can?u.filter(d=>d.permission?n.can(d.permission):!0):u}const a=e.computed(()=>{if(t.quota.remaining===0)return(n==null?void 0:n.enableSupportMode)!==!1?[{id:"contact-support-quota",title:te("contactSupport"),description:te("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[];const u=o(),d=Xn(u,r.value)||[];return s(d)}),i=e.computed(()=>r.value!==null&&r.value.pageType!=="default");function l(u){return typeof u.prompt=="function"?u.prompt(r.value||{pageType:"default"}):u.prompt}return{suggestions:a,hasContextualSuggestions:i,resolvePrompt:l}}function is(r,t){const{setContext:n,clearContext:o,updateContext:s}=Yt();function a(){if(!t)return{};const l={};for(const[u,d]of Object.entries(t))l[u]=e.isRef(d)?d.value:d;return l}function i(){const l={pageType:r,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return e.onMounted(()=>{i()}),e.onUnmounted(()=>{o()}),t&&e.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function ls(r){const t=r.toLowerCase().split("+");return{key:t.pop()||"",meta:t.includes("cmd")||t.includes("meta")||t.includes("command"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option"),mod:t.includes("mod")}}function cs(r,t){const n=r.key.toLowerCase();if(t.mod){const d=navigator.platform.toUpperCase().indexOf("MAC")>=0||navigator.userAgent.toUpperCase().indexOf("MAC")>=0?r.metaKey:r.ctrlKey,m=t.shift?r.shiftKey:!r.shiftKey,h=t.alt?r.altKey:!r.altKey;return n===t.key&&d&&m&&h}const o=t.meta?r.metaKey:!r.metaKey,s=t.ctrl?r.ctrlKey:!r.ctrlKey,a=t.shift?r.shiftKey:!r.shiftKey,i=t.alt?r.altKey:!r.altKey;let l=o&&s&&a&&i;return(t.meta&&!t.ctrl||!t.meta&&t.ctrl)&&(l=(r.metaKey||r.ctrlKey)&&a&&i),n===t.key&&l}function Jn(r){const{onToggle:t,enabled:n=!0}=r,o=e.ref(!1),s=r.shortcut!==void 0?r.shortcut:ke("keyboardShortcut")??"mod+g";if(s===null)return{isActive:o};const a=ls(s);function i(l){if(!n)return;const u=l.target,d=u.tagName==="INPUT"||u.tagName==="TEXTAREA",m=u.isContentEditable,h=u.closest("[data-ai-input]");if(!((d||m)&&!h)&&cs(l,a)){l.preventDefault(),l.stopPropagation();const g=K();if(g!=null&&g.canToggle&&!g.canToggle())return;o.value=!o.value,t()}}return e.onMounted(()=>{window.addEventListener("keydown",i,!0)}),e.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:o}}function us(r){const t=Ae();return Jn({onToggle:()=>{r?r.value=!r.value:t.showChat=!t.showChat}})}function ds(r,t){const n=e.ref(te("loadingText"));let o=[];function s(){return[te("loadingText"),te("analyzingText"),te("craftingText")]}function a(){return[0,2e3,5e3]}function i(){o.forEach(d=>clearTimeout(d)),o=[]}function l(){i();const d=t==null?void 0:t(),m=(d==null?void 0:d.messages)??s();n.value=m[0]||te("loadingText")}function u(){i();const d=t==null?void 0:t(),m=(d==null?void 0:d.messages)??s(),h=(d==null?void 0:d.intervals)??a();n.value=m[0]||te("loadingText");let g=0;for(let y=1;y<m.length;y++){g+=h[y]||2e3;const f=y,S=window.setTimeout(()=>{r()&&(n.value=m[f])},g);o.push(S)}}return e.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:u,resetLoadingText:l,clearLoadingTextTimers:i}}function ms(r){const{getHistoryLength:t,getStoreLimit:n,getConfig:o,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=r,l=e.ref({showWarning:!1,isReached:!1,pendingMessage:null}),u=e.computed(()=>{var x;return((x=o())==null?void 0:x.limit)??n()}),d=e.computed(()=>{var x;return((x=o())==null?void 0:x.showWarningAt)??u.value-2}),m=e.computed(()=>Math.max(0,u.value-t())),h=e.computed(()=>m.value<=u.value-d.value&&m.value>0),g=e.computed(()=>m.value===0),y=e.computed(()=>{var x,C;return l.value.isReached||g.value?((x=s())==null?void 0:x.historyLimitReachedTitle)??"Chat Limit Reached":((C=s())==null?void 0:C.historyLimitWarningTitle)??"Approaching Chat Limit"}),f=e.computed(()=>{var x,C,I,b;return l.value.isReached||g.value?((x=o())==null?void 0:x.limitMessage)??((C=s())==null?void 0:C.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":((I=o())==null?void 0:I.warningMessage)??((b=s())==null?void 0:b.historyLimitWarningMessage)??`You have ${m.value} message${m.value===1?"":"s"} remaining in this conversation.`});function S(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function p(){l.value.showWarning=!1;const x=o();if(x!=null&&x.onLimitReached&&!await x.onLimitReached())return l.value.isReached=!1,null;if(a(),i(),l.value.isReached=!1,l.value.pendingMessage){const C=l.value.pendingMessage;return l.value.pendingMessage=null,C}return null}function w(){return g.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(h.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function M(x){l.value.pendingMessage=x}return{showHistoryLimitWarning:e.computed(()=>l.value.showWarning),historyLimitReached:e.computed(()=>l.value.isReached),historyLimit:u,remainingMessages:m,historyLimitDialogTitle:y,historyLimitDialogMessage:f,dismissHistoryLimitWarning:S,handleHistoryLimitAction:p,checkHistoryLimit:w,setPendingMessage:M}}function fs(){const r=Ae(),t=e.ref([]),n=e.ref(!1),o=e.ref(0),s=ke("maxAttachments")||5,a=ke("maxFileSize")||10*1024*1024,i=ke("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=e.computed(()=>t.value.length>0),u=e.computed(()=>t.value.some(b=>b.uploading)),d=e.computed(()=>t.value.length<s);function m(b){var G;const N=crypto.randomUUID(),L=b.type.startsWith("image/")?URL.createObjectURL(b):void 0,A=K(),B=!!((G=A==null?void 0:A.endpoints)!=null&&G.uploadFile),V={id:N,name:b.name,type:b.type,size:b.size,uploading:B,progress:B?0:100,previewUrl:L};t.value.push(V),B&&h(b,N)}async function h(b,N){try{const L=await r.uploadFile(b),A=t.value.findIndex(B=>B.id===N);if(A===-1)return;if(L){const B=t.value[A].previewUrl;t.value[A]={...t.value[A],id:L.id||N,url:L.url,extractedText:L.extractedText,uploading:!1,progress:100,previewUrl:B||L.previewUrl}}else g(N)}catch{g(N)}}function g(b){const N=t.value.findIndex(A=>A.id===b);if(N===-1)return;const[L]=t.value.splice(N,1);L!=null&&L.previewUrl&&URL.revokeObjectURL(L.previewUrl)}function y(){t.value.forEach(b=>{b.previewUrl&&URL.revokeObjectURL(b.previewUrl)}),t.value=[]}function f(){return t.value.filter(b=>!b.uploading).map(b=>({id:b.id,name:b.name,url:b.url,type:b.type,size:b.size}))}function S(b){if(!b)return;const N=Array.from(b);for(const L of N){if(t.value.length>=s)break;L.size>a||m(L)}}function p(b){var N;return Array.from(((N=b.dataTransfer)==null?void 0:N.types)||[]).includes("Files")}function w(b){p(b)&&(o.value+=1,n.value=!0)}function M(b){p(b)||b.preventDefault()}function x(b){p(b)&&(o.value=Math.max(0,o.value-1),o.value===0&&(n.value=!1))}function C(b){var N;p(b)&&(o.value=0,n.value=!1,S(((N=b.dataTransfer)==null?void 0:N.files)||null))}function I(b){const N=b.target,L=N.files;L&&L.length&&S(L),N.value=""}return e.onBeforeUnmount(()=>{y()}),{attachments:t,isDraggingFiles:n,hasAttachments:l,isUploading:u,canAddMore:d,acceptedFileTypes:i,isImage:it,formatFileSize:lt,removeAttachment:g,clearAttachments:y,buildPayload:f,processFiles:S,handleFileSelect:I,handleDragEnter:w,handleDragOver:M,handleDragLeave:x,handleDrop:C}}function ps(r,t,n){const o=e.ref(!1),s=e.ref([]),a=e.ref(0),i=e.ref({inMention:!1,query:"",startPos:0}),l=e.ref(!1),u=e.ref([]),d=e.computed(()=>{const p=K();return(p==null?void 0:p.mentionProviders)||[]});function m(p){if(l.value){l.value=!1;return}const w=n();if(!w)return;const M=w.selectionStart,x=gn(p,M);i.value=x,x.inMention&&x.query.length>=0?h(x.query):(o.value=!1,s.value=[])}async function h(p){const w=xn();if(w.length===0){o.value=!1;return}const M=[];for(const x of w)try{const C=await x.search(p);M.push(...C.map(I=>({...I,type:x.type})))}catch(C){console.warn(`Mention provider ${x.type} failed:`,C)}s.value=M.slice(0,10),o.value=M.length>0,a.value=0}function g(p){const{startPos:w}=i.value,M=r(),x=n(),C=M.slice(0,w),I=M.slice((x==null?void 0:x.selectionStart)||w),b=p.name||p.label||p.title||p.id;l.value=!0,t(`${C}@${b} ${I}`),u.value.push({id:p.id,name:b,type:p.type,metadata:p.attributes}),o.value=!1,s.value=[],setTimeout(()=>{const N=n();N==null||N.focus();const L=C.length+b.length+2;N==null||N.setSelectionRange(L,L)},0)}function y(p){if(!o.value||s.value.length===0)return!1;if(p.key==="ArrowDown")return p.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(p.key==="ArrowUp")return p.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(p.key==="Enter"||p.key==="Tab"){p.preventDefault();const w=s.value[a.value];return w&&g(w),!0}return p.key==="Escape"?(p.preventDefault(),o.value=!1,!0):!1}function f(){u.value=[]}function S(){return[...u.value]}return{showMentions:o,mentionItems:s,selectedMentionIndex:a,mentionProviders:d,checkForMentions:m,handleMentionSelect:g,handleMentionKeyDown:y,clearMentions:f,getMentions:S}}function hs(r,t,n,o,s){const a=e.ref(!1),i=e.ref(-1),l=e.ref(null);function u(){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 d(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),u(),!0;if(y.key==="ArrowUp")return y.preventDefault(),i.value=Math.max(i.value-1,0),u(),!0;if(y.key==="Enter"&&i.value>=0){y.preventDefault();const S=f[i.value];return S&&m(S),!0}return y.key==="Escape"?(y.preventDefault(),a.value=!1,i.value=-1,!0):!1}function m(y){s(y),a.value=!1,i.value=-1}function h(){const y=o(),f=t(),S=n(),p=r();y&&!f&&S&&p.length>0?a.value=!0:a.value=!1}function g(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:d,handleSuggestionClick:m,updateSuggestionsVisibility:h,hideSuggestions:g}}function gs(r,t=300){function n(){const o=r();if(!o)return;o.style.height="auto";const s=Math.min(o.scrollHeight,t);o.style.height=`${s}px`,o.style.overflowY=o.scrollHeight>t?"auto":"hidden"}return e.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const ys=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]);function ks(r,t,n=5){function o(a,i){if(!a)return i;const l=a.toLowerCase().trim().split(/\s+/).filter(u=>!ys.has(u));return l.length===0?i:i.filter(u=>{const d=`${u.title} ${u.description||""}`.toLowerCase();return l.every(m=>d.includes(m))})}return{filteredSuggestions:e.computed(()=>{const a=r.value||[],i=t.value.toLowerCase().trim();return o(i,a).slice(0,n).map(l=>({id:l.id,title:l.title,description:l.description||""}))})}}function xs(r){async function t(){await e.nextTick();const o=r.value;o&&(o.scrollTop=o.scrollHeight)}function n(o,s){e.watch(o,t),e.watch(s,t)}return{scrollToBottom:t,watchForScroll:n}}const bs=["stroke-width"],kt=e.defineComponent({inheritAttrs:!1,__name:"IconWarning",props:e.mergeModels({class:{},strokeWidth:{default:2}},{class:{default:"w-5 h-5"},classModifiers:{}}),emits:["update:class"],setup(r){const t=e.useModel(r,"class");return(n,o)=>(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(t.value),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":r.strokeWidth},[...o[0]||(o[0]=[e.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"},null,-1)])],10,bs))}}),ws={viewBox:"0 0 24 24",fill:"currentColor"},vn=e.defineComponent({inheritAttrs:!0,__name:"IconUser",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",ws,[...n[0]||(n[0]=[e.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)])]))}}),Cs={viewBox:"0 0 24 24",fill:"currentColor"},ze=e.defineComponent({inheritAttrs:!0,__name:"IconSparkles",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Cs,[...n[0]||(n[0]=[e.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 4.5a.75.75 0 0 1 .721.544l.813 2.846a3.75 3.75 0 0 0 2.576 2.576l2.846.813a.75.75 0 0 1 0 1.442l-2.846.813a3.75 3.75 0 0 0-2.576 2.576l-.813 2.846a.75.75 0 0 1-1.442 0l-.813-2.846a3.75 3.75 0 0 0-2.576-2.576l-2.846-.813a.75.75 0 0 1 0-1.442l2.846-.813A3.75 3.75 0 0 0 7.466 7.89l.813-2.846A.75.75 0 0 1 9 4.5ZM18 1.5a.75.75 0 0 1 .728.568l.258 1.036a2.63 2.63 0 0 0 1.91 1.91l1.036.258a.75.75 0 0 1 0 1.456l-1.036.258a2.63 2.63 0 0 0-1.91 1.91l-.258 1.036a.75.75 0 0 1-1.456 0l-.258-1.036a2.63 2.63 0 0 0-1.91-1.91l-1.036-.258a.75.75 0 0 1 0-1.456l1.036-.258a2.63 2.63 0 0 0 1.91-1.91l.258-1.036A.75.75 0 0 1 18 1.5ZM16.5 15a.75.75 0 0 1 .712.513l.394 1.183c.15.447.5.799.948.948l1.183.395a.75.75 0 0 1 0 1.422l-1.183.395a1.5 1.5 0 0 0-.948.948l-.395 1.183a.75.75 0 0 1-1.422 0l-.395-1.183a1.5 1.5 0 0 0-.948-.948l-1.183-.395a.75.75 0 0 1 0-1.422l1.183-.395a1.5 1.5 0 0 0 .948-.948l.395-1.183A.75.75 0 0 1 16.5 15Z"},null,-1)])]))}}),Es={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Jt=e.defineComponent({inheritAttrs:!0,__name:"IconDocument",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Es,[...n[0]||(n[0]=[e.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)])]))}}),Ss={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ts=e.defineComponent({inheritAttrs:!0,__name:"IconPaperclip",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ss,[...n[0]||(n[0]=[e.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"},null,-1)])]))}}),As=["stroke-width"],er=e.defineComponent({inheritAttrs:!0,__name:"IconQuestionCircle",props:{strokeWidth:{default:1.5}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":r.strokeWidth},[...n[0]||(n[0]=[e.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"},null,-1)])],8,As))}}),Ms=["stroke-width"],vt=e.defineComponent({inheritAttrs:!0,__name:"IconClose",props:{strokeWidth:{default:1.5}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":r.strokeWidth},[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"},null,-1)])],8,Ms))}}),Bs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ns=e.defineComponent({inheritAttrs:!0,__name:"IconSend",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Bs,[...n[0]||(n[0]=[e.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)])]))}}),Rs={viewBox:"0 0 24 24",fill:"currentColor"},_s=e.defineComponent({inheritAttrs:!0,__name:"IconStop",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Rs,[...n[0]||(n[0]=[e.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)])]))}}),Ls={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Is=e.defineComponent({inheritAttrs:!0,__name:"IconCopy",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ls,[...n[0]||(n[0]=[e.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)])]))}}),$s={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ds=e.defineComponent({inheritAttrs:!0,__name:"IconCheck",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",$s,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])]))}}),zs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},Os=e.defineComponent({inheritAttrs:!0,__name:"IconChatBubble",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",zs,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"},null,-1)])]))}}),Ps={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},Vs=e.defineComponent({inheritAttrs:!0,__name:"IconMinimize",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ps,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"},null,-1)])]))}}),Fs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},Hs=e.defineComponent({inheritAttrs:!0,__name:"IconFullscreen",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Fs,[...n[0]||(n[0]=[e.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)])]))}}),Us={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},qs=e.defineComponent({inheritAttrs:!0,__name:"IconExitFullscreen",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Us,[...n[0]||(n[0]=[e.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)])]))}}),js={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ws=e.defineComponent({inheritAttrs:!0,__name:"IconClock",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",js,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])]))}}),Ks={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Gs=e.defineComponent({inheritAttrs:!0,__name:"IconRefresh",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ks,[...n[0]||(n[0]=[e.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"},null,-1)])]))}}),Qs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Zs=e.defineComponent({inheritAttrs:!0,__name:"IconSupport",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Qs,[...n[0]||(n[0]=[e.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"},null,-1)])]))}}),tr=e.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 min-w-[32px] flex items-center justify-center rounded-full border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800",(o=r.ui)==null?void 0:o.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[e.createVNode(e.unref(ze),{class:e.normalizeClass(["w-4 h-4 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},null,8,["class"])]})],2)}}}),Ys=e.defineComponent({__name:"UserAvatar",props:{ui:{}},setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.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])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[e.createVNode(e.unref(vn),{class:e.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},null,8,["class"])]})],2)}}}),Xs=["onClick","onMouseenter"],nr=e.defineComponent({__name:"MentionList",props:{items:{},selectedIndex:{default:0},providers:{default:()=>[]},ui:{},texts:{}},emits:["select","update:selectedIndex"],setup(r,{emit:t}){const n=r,o=e.computed(()=>n.ui||{}),s=t,a=e.ref(n.selectedIndex);e.watch(()=>n.selectedIndex,p=>{a.value=p}),e.watch(a,p=>{s("update:selectedIndex",p)});const i=e.computed(()=>{const p={};return n.items.forEach(w=>{const M=w.type||"default";p[M]||(p[M]=[]),p[M].push(w)}),p});function l(p){return n.providers.find(w=>w.type===p)||kn(p)}function u(p){const w=l(p);return(w==null?void 0:w.label)||p.charAt(0).toUpperCase()+p.slice(1)+"s"}function d(p,w){let M=0;const x=Object.keys(i.value);for(const C of x){if(C===p)return M+w;M+=i.value[C].length}return M}function m(p){s("select",p)}function h(p){a.value=p,s("update:selectedIndex",p)}function g(p){const w=l(p.type);return Lt(p,w)}function y(p){const w=l(p.type);return yn(p,w)}function f(p){const w={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 w[p]||w.default}function S(p){return p.split(" ").map(w=>w[0]).join("").slice(0,2).toUpperCase()}return(p,w)=>r.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.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])},[e.createElementVNode("div",{class:e.normalizeClass(["p-2",o.value.container])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(M,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:x},[Object.keys(i.value).length>1?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",o.value.groupHeader])},e.toDisplayString(u(x)),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M,(C,I)=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.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"]:d(x,I)===a.value,"hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer":d(x,I)!==a.value}]]),onClick:b=>m(C),onMouseenter:b=>h(d(x,I))},[e.renderSlot(p.$slots,"item-icon",{item:C,type:x},()=>[e.createElementVNode("span",{class:e.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[o.value.itemIcon,f(C.type)]])},e.toDisplayString(S(g(C))),3)]),e.createElementVNode("div",{class:e.normalizeClass(["flex-1 min-w-0",o.value.itemContent])},[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",o.value.itemName])},e.toDisplayString(g(C)),3),y(C)?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",o.value.itemSubtitle])},e.toDisplayString(y(C)),3)):e.createCommentVNode("",!0)],2)],42,Xs))),128))],64))),128))],2)],2)):e.createCommentVNode("",!0)}}),Js=["title"],rr=e.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(r,{emit:t}){const n=r,o=t,s=u=>{var m;return(m=n.texts)!=null&&m[u]?n.texts[u]:te({copyToClipboard:"copyToClipboard",copied:"copied"}[u])},a=e.computed(()=>n.ui||{}),i=e.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(u){console.error("Failed to copy:",u)}}return(u,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",a.value.container])},[e.createElementVNode("button",{type:"button",class:e.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?(e.openBlock(),e.createBlock(e.unref(Ds),{key:1,class:e.normalizeClass(["w-4 h-4 text-green-500",a.value.successState])},null,8,["class"])):(e.openBlock(),e.createBlock(e.unref(Is),{key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400"}))],10,Js)],2))}}),vs={class:"text-gray-600 dark:text-gray-400"},ea=e.defineComponent({__name:"LoadingIndicator",props:{text:{},ui:{}},setup(r){return(t,n)=>{var o,s;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",(o=r.ui)==null?void 0:o.loadingIndicator])},[e.createElementVNode("div",{class:e.normalizeClass(["flex space-x-1",(s=r.ui)==null?void 0:s.loadingDots])},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(3,a=>e.createElementVNode("div",{key:a,class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:e.normalizeStyle({animationDelay:`${(a-1)*150}ms`})},null,4)),64))],2),e.createElementVNode("span",vs,e.toDisplayString(r.text),1)],2)}}}),ta={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},na=["src"],ra={class:"flex-1 min-w-0"},oa={class:"text-sm font-semibold text-white truncate"},sa={class:"text-xs text-white/70"},aa={key:0,class:"text-xs font-medium text-white/90"},ia=["src"],la={class:"flex-shrink-0 group-hover:opacity-0 transition-opacity"},ca=["id","innerHTML"],ua={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"},da=["src"],ma={class:"flex-1 min-w-0"},fa={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},pa={class:"text-xs text-gray-500 dark:text-gray-400"},ha={key:0,class:"text-xs font-medium text-primary"},ga=e.defineComponent({__name:"ChatMessage",props:{message:{},showActions:{type:Boolean,default:!0},loadingText:{default:"Gathering data..."},ui:{},texts:{}},emits:["copy"],setup(r,{emit:t}){const n=r,o=t,s=f=>{var p;return(p=n.texts)!=null&&p[f]?n.texts[f]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[f]||f},{parseMarkdown:a}=Zn(),i=e.ref(!1),l=e.computed(()=>n.message.attachments??[]),u=e.computed(()=>l.value.length>0),d=e.computed(()=>{if(n.message.role!=="user")return!1;const f=n.message.message||"",S=f.split(`
59
- `).length;return f.length>200||S>4});function m(){i.value=!i.value}const h=e.computed(()=>{const f=K();return f!=null&&f.userAvatar?typeof f.userAvatar=="string"?f.userAvatar:typeof f.userAvatar=="function"?f.userAvatar():null:null}),g=e.computed(()=>{if(n.message.role==="assistant"){let f=n.message.message;return f=f.replace(/\\n/g,`
60
- `),a(f)}return n.message.message});function y(f){o("copy",f)}return(f,S)=>{var p,w,M,x,C,I,b,N,L,A,B,V,G,_,O;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[(p=r.ui)==null?void 0:p.root,{"flex justify-end":r.message.role==="user","flex justify-start":r.message.role==="assistant"}]])},[r.message.role==="user"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex gap-3 justify-end",(w=r.ui)==null?void 0:w.userMessage])},[e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl px-4 py-3 bg-primary-500 text-white max-w-fit",(M=r.ui)==null?void 0:M.userBubble])},[r.message.message?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-sm whitespace-pre-wrap",[(x=r.ui)==null?void 0:x.content,{"line-clamp-4":!i.value&&d.value}]])},e.toDisplayString(r.message.message),3)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",(C=r.ui)==null?void 0:C.showMoreButton]),onClick:m},e.toDisplayString(i.value?s("showLess"):s("showMore")),3)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-3 space-y-2",(I=r.ui)==null?void 0:I.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,z=>{var ne;return e.openBlock(),e.createBlock(e.resolveDynamicComponent(z.url?"a":"div"),{key:z.id,href:z.url||void 0,target:z.url?"_blank":void 0,rel:"noopener noreferrer",class:e.normalizeClass(["flex items-center gap-3 rounded-xl border border-white/20 bg-white/10 p-2 transition",[(ne=r.ui)==null?void 0:ne.attachmentItem,z.url?"hover:bg-white/20 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",ta,[z.url&&e.unref(it)(z)?(e.openBlock(),e.createElementBlock("img",{key:0,src:z.url,class:"object-cover h-full w-full",alt:""},null,8,na)):(e.openBlock(),e.createBlock(e.unref(Jt),{key:1,class:"w-5 h-5 text-white"}))]),e.createElementVNode("div",ra,[e.createElementVNode("p",oa,e.toDisplayString(z.name||s("attachment")),1),e.createElementVNode("p",sa,e.toDisplayString(e.unref(lt)(z.size)),1)]),z.url?(e.openBlock(),e.createElementBlock("span",aa,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"])}),128))],2)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",{class:e.normalizeClass(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary-500 overflow-hidden",(b=r.ui)==null?void 0:b.userAvatar])},[h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:h.value,alt:"User",class:"h-full w-full object-cover"},null,8,ia)):(e.openBlock(),e.createBlock(e.unref(vn),{key:1,class:"h-4 w-4 text-white"}))],2)],2)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-start gap-3",(N=r.ui)==null?void 0:N.assistantMessage])},[e.createElementVNode("div",la,[e.createVNode(tr)]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-4 py-3 shadow-sm rounded-2xl transition-all duration-200 max-w-[85%]",(L=r.ui)==null?void 0:L.assistantBubble])},[r.message.loading?(e.openBlock(),e.createBlock(ea,{key:0,text:((A=r.texts)==null?void 0:A.loadingText)||r.loadingText,ui:{loadingIndicator:(B=r.ui)==null?void 0:B.loadingIndicator,loadingDots:(V=r.ui)==null?void 0:V.loadingDots}},null,8,["text","ui"])):r.message.message?(e.openBlock(),e.createElementBlock("div",{key:1,id:r.message.id,class:e.normalizeClass(["text-sm text-gray-700 dark:text-gray-200 leading-relaxed",(G=r.ui)==null?void 0:G.content]),innerHTML:g.value},null,10,ca)):e.createCommentVNode("",!0),!r.message.loading&&u.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-4 space-y-2",(_=r.ui)==null?void 0:_.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,z=>{var ne;return e.openBlock(),e.createBlock(e.resolveDynamicComponent(z.url?"a":"div"),{key:z.id,href:z.url||void 0,target:z.url?"_blank":void 0,rel:"noopener noreferrer",class:e.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",[(ne=r.ui)==null?void 0:ne.attachmentItem,z.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",ua,[z.url&&e.unref(it)(z)?(e.openBlock(),e.createElementBlock("img",{key:0,src:z.url,class:"object-cover h-full w-full",alt:""},null,8,da)):(e.openBlock(),e.createBlock(e.unref(Jt),{key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400"}))]),e.createElementVNode("div",ma,[e.createElementVNode("p",fa,e.toDisplayString(z.name||s("attachment")),1),e.createElementVNode("p",pa,e.toDisplayString(e.unref(lt)(z.size)),1)]),z.url?(e.openBlock(),e.createElementBlock("span",ha,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"])}),128))],2)):e.createCommentVNode("",!0)],2)],2)),r.message.role==="assistant"&&!r.message.loading&&!r.message.streaming&&r.showActions?(e.openBlock(),e.createBlock(rr,{key:2,message:r.message,class:e.normalizeClass(["absolute top-0 left-0",(O=r.ui)==null?void 0:O.actionsContainer]),onCopy:y},null,8,["message","class"])):e.createCommentVNode("",!0)],2)}}}),or=(r,t)=>{const n=r.__vccOpts||r;for(const[o,s]of t)n[o]=s;return n},sr=or(ga,[["__scopeId","data-v-458d9332"]]),ya={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},ka={class:"space-y-2"},xa=["src"],ba={class:"flex-1 min-w-0"},wa={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},Ca={class:"text-xs text-gray-500 dark:text-gray-400"},Ea={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Sa={key:0,class:"text-xs text-gray-400"},Ta=["disabled","onClick"],Aa=e.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.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])},[e.createElementVNode("p",ya,e.toDisplayString(((o=r.texts)==null?void 0:o.attachedFiles)||"Attached files"),1),e.createElementVNode("ul",ka,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.attachments,s=>(e.openBlock(),e.createElementBlock("li",{key:s.id,class:e.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])},[e.createElementVNode("div",{class:e.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)?(e.openBlock(),e.createElementBlock("img",{key:0,src:s.previewUrl||s.url,class:"object-cover h-full w-full",alt:""},null,8,xa)):(e.openBlock(),e.createBlock(e.unref(Jt),{key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400"}))],2),e.createElementVNode("div",ba,[e.createElementVNode("p",wa,e.toDisplayString(s.name),1),e.createElementVNode("p",Ca,e.toDisplayString(r.formatFileSize(s.size)),1),s.uploading?(e.openBlock(),e.createElementBlock("div",Ea,[e.createElementVNode("div",{class:"h-full bg-primary transition-all",style:e.normalizeStyle({width:`${s.progress??10}%`})},null,4)])):e.createCommentVNode("",!0)]),s.uploading?(e.openBlock(),e.createElementBlock("span",Sa,e.toDisplayString(Math.round(s.progress??0))+"% ",1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.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=>t.$emit("remove",s.id)},[e.createVNode(e.unref(vt),{class:"w-4 h-4 text-gray-500 dark:text-gray-400"})],10,Ta)],2))),128))])],2)}}}),Ma={class:"py-1"},Ba=["onClick","onMouseenter"],Na={class:"flex items-start gap-3"},Ra={class:"flex-1 min-w-0"},_a={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},La={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Ia=e.defineComponent({__name:"SuggestionsDropdown",props:{suggestions:{},selectedIndex:{},ui:{}},emits:["select","hover"],setup(r,{expose:t}){const n=e.ref(null);return t({dropdownRef:n}),(o,s)=>(e.openBlock(),e.createBlock(e.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:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"dropdownRef",ref:n,class:e.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])},[e.createElementVNode("ul",Ma,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.suggestions,(a,i)=>(e.openBlock(),e.createElementBlock("li",{key:a.id,class:e.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)},[e.createElementVNode("div",Na,[e.createElementVNode("div",Ra,[e.createElementVNode("p",_a,e.toDisplayString(a.title),1),e.createElementVNode("p",La,e.toDisplayString(a.description),1)])])],42,Ba))),128))])],2)]),_:1}))}}),$a={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},Da=["title"],za=["title"],Oa=["disabled"],Pa=e.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 t=r,n=e.computed(()=>t.sending?[t.ui.stopButton||"bg-red-500 text-white hover:bg-red-600"]:t.canSend?[t.ui.sendButtonActive||"bg-primary-500 text-white hover:bg-primary-600"]:[t.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 e.openBlock(),e.createElementBlock("div",$a,[r.showSupportModeToggle&&!r.supportRequestMode?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.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]=u=>o.$emit("toggle-support-mode"))},[e.createVNode(e.unref(er),{class:"w-5 h-5"})],10,Da)):e.createCommentVNode("",!0),r.showSupportModeToggle&&r.supportRequestMode?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.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]=u=>o.$emit("toggle-support-mode"))},[e.createVNode(e.unref(er),{class:"w-3.5 h-3.5","stroke-width":2}),e.createElementVNode("span",null,e.toDisplayString(((l=r.texts)==null?void 0:l.supportLabel)||"Support"),1),e.createVNode(e.unref(vt),{class:"w-3 h-3","stroke-width":2})],10,za)):e.createCommentVNode("",!0),e.createElementVNode("button",{disabled:!r.canSend&&!r.sending,class:e.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]=e.withModifiers(u=>o.$emit("click"),["prevent"]))},[r.sending?(e.openBlock(),e.createBlock(e.unref(_s),{key:1,class:"w-4 h-4"})):(e.openBlock(),e.createBlock(e.unref(Ns),{key:0,class:"w-4 h-4"}))],10,Oa)])}}}),Va={class:"max-w-3xl mx-auto space-y-3"},Fa=["accept"],Ha=["title"],Ua={class:"flex items-center"},qa=["placeholder","disabled"],ja={key:0,class:"flex justify-center"},ar=e.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,{expose:t,emit:n}){const o=r,s=n,a=e.ref(o.modelValue),i=e.ref(null),l=e.ref(null),u=e.ref(!1),d=fs(),m=ps(()=>a.value,A=>{a.value=A},()=>i.value),h=hs(()=>o.suggestions,()=>o.hasHistory,()=>u.value,()=>a.value,A=>{s("suggestion-select",A),e.nextTick(()=>{var B;return(B=i.value)==null?void 0:B.focus()})}),{adjustTextareaHeight:g}=gs(()=>i.value),y=e.computed(()=>o.supportRequestMode?o.supportPlaceholder:o.placeholder),f=e.computed(()=>o.showSupportModeToggle?o.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),S=e.computed(()=>{var B;return(((B=a.value)==null?void 0:B.trim())??"").length>=o.minLength||d.hasAttachments.value}),p=e.computed(()=>!o.disabled&&!o.sending&&S.value&&!d.isUploading.value);e.watch(()=>o.modelValue,A=>{a.value=A,e.nextTick(g)}),e.watch(a,A=>{s("update:modelValue",A),e.nextTick(g),m.checkForMentions(A),h.updateSuggestionsVisibility()}),e.watch(()=>o.suggestions,()=>{h.updateSuggestionsVisibility()});function w(){g()}function M(A){if(!m.handleMentionKeyDown(A)&&!h.handleSuggestionKeyDown(A)&&A.key==="Enter"){if(A.shiftKey)return;!o.sending&&p.value&&(A.preventDefault(),x())}}function x(){if(!p.value)return;const A=d.buildPayload(),B=a.value.trim(),V=m.getMentions();s("submit",{message:B,attachments:A,mentions:V,isSupportRequest:o.supportRequestMode}),a.value="",d.clearAttachments(),m.clearMentions(),e.nextTick(g)}function C(){o.sending?s("cancel"):p.value&&x()}function I(){var A;o.disabled||o.sending||d.canAddMore.value&&((A=l.value)==null||A.click())}function b(A){h.handleSuggestionClick(A)}function N(){u.value=!0,h.updateSuggestionsVisibility()}function L(){u.value=!1,setTimeout(()=>{h.hideSuggestions(),m.showMentions.value=!1},200)}return t({focus:()=>{var A;return(A=i.value)==null?void 0:A.focus()}}),e.onMounted(()=>{e.nextTick(g)}),(A,B)=>{var V,G,_,O,z,ne,be;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",(V=r.ui)==null?void 0:V.root]),onDragenter:B[6]||(B[6]=e.withModifiers((...U)=>e.unref(d).handleDragEnter&&e.unref(d).handleDragEnter(...U),["prevent"])),onDragover:B[7]||(B[7]=e.withModifiers((...U)=>e.unref(d).handleDragOver&&e.unref(d).handleDragOver(...U),["prevent"])),onDragleave:B[8]||(B[8]=e.withModifiers((...U)=>e.unref(d).handleDragLeave&&e.unref(d).handleDragLeave(...U),["prevent"])),onDrop:B[9]||(B[9]=e.withModifiers((...U)=>e.unref(d).handleDrop&&e.unref(d).handleDrop(...U),["prevent"]))},[e.createElementVNode("form",{class:e.normalizeClass((G=r.ui)==null?void 0:G.form),onSubmit:e.withModifiers(x,["prevent"])},[e.createElementVNode("div",Va,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:e.unref(d).acceptedFileTypes,onChange:B[0]||(B[0]=(...U)=>e.unref(d).handleFileSelect&&e.unref(d).handleFileSelect(...U))},null,40,Fa),e.unref(d).hasAttachments.value?(e.openBlock(),e.createBlock(Aa,{key:0,attachments:e.unref(d).attachments.value,ui:r.ui||{},texts:r.texts,"is-image":e.unref(d).isImage,"format-file-size":e.unref(d).formatFileSize,onRemove:e.unref(d).removeAttachment},null,8,["attachments","ui","texts","is-image","format-file-size","onRemove"])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["relative",(_=r.ui)==null?void 0:_.inputContainer])},[e.unref(h).showSuggestions.value&&r.suggestions.length>0?(e.openBlock(),e.createBlock(Ia,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:r.suggestions,"selected-index":e.unref(h).selectedSuggestionIndex.value,ui:r.ui||{},onSelect:b,onHover:B[1]||(B[1]=U=>e.unref(h).selectedSuggestionIndex.value=U)},null,8,["suggestions","selected-index","ui"])):e.createCommentVNode("",!0),e.createVNode(e.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:e.withCtx(()=>[e.unref(m).showMentions.value&&e.unref(m).mentionItems.value.length>0?(e.openBlock(),e.createBlock(nr,{key:0,items:e.unref(m).mentionItems.value,"selected-index":e.unref(m).selectedMentionIndex.value,providers:e.unref(m).mentionProviders.value,onSelect:e.unref(m).handleMentionSelect,"onUpdate:selectedIndex":B[2]||(B[2]=U=>e.unref(m).selectedMentionIndex.value=U)},null,8,["items","selected-index","providers","onSelect"])):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl border shadow-lg transition-all duration-200 bg-white dark:bg-gray-800",[(O=r.ui)==null?void 0:O.inputWrapper,{"border-primary shadow-primary/30":u.value||e.unref(d).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!u.value&&!e.unref(d).isDraggingFiles.value}]])},[e.createElementVNode("button",{type:"button",class:e.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",(z=r.ui)==null?void 0:z.attachButton]),title:((ne=r.texts)==null?void 0:ne.attachFiles)||"Attach files",onClick:I},[e.createVNode(e.unref(Ts),{class:"w-5 h-5"})],10,Ha),e.createElementVNode("div",Ua,[e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":B[3]||(B[3]=U=>a.value=U),rows:"1","data-ai-input":"",placeholder:y.value,disabled:r.disabled,class:e.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",(be=r.ui)==null?void 0:be.textarea]),style:e.normalizeStyle(f.value),onInput:w,onKeydown:M,onFocus:N,onBlur:L},null,46,qa),[[e.vModelText,a.value]])]),e.createVNode(Pa,{sending:r.sending,"can-send":p.value,"support-request-mode":r.supportRequestMode,"show-support-mode-toggle":r.showSupportModeToggle,ui:r.ui||{},texts:r.texts,onToggleSupportMode:B[4]||(B[4]=U=>A.$emit("toggle-support-mode")),onClick:C},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),e.renderSlot(A.$slots,"context-link",{},()=>{var U;return[r.contextLinkText?(e.openBlock(),e.createElementBlock("div",ja,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",(U=r.ui)==null?void 0:U.contextLink]),onClick:B[5]||(B[5]=nt=>A.$emit("context-link-click"))},e.toDisplayString(r.contextLinkText),3)])):e.createCommentVNode("",!0)]})])],34)],34)}}}),Wa=["onClick"],ir=e.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(r,{emit:t}){const n=r,o=t,s=g=>{var f;return(f=n.texts)!=null&&f[g]?n.texts[g]:te({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[g])},a=e.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=Xt();function u(g){const y={...g,prompt:l(g)};o("item-click",y)}function d(g){return g.gradientClass?g.gradientClass:g.className?g.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function m(g){const y=g.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(g){const y=g.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(g,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-center p-4 h-full",a.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["w-full max-w-4xl",a.value.content])},[e.createElementVNode("div",{class:e.normalizeClass(["mb-8 text-center",a.value.header])},[e.createElementVNode("div",{class:e.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])},[e.createVNode(e.unref(ze),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(s("aiName")),1)],2),e.createElementVNode("h1",{class:e.normalizeClass(["mb-3 text-4xl font-bold tracking-tight text-gray-900 dark:text-white",a.value.title])},e.toDisplayString(s("title")),3),e.createElementVNode("p",{class:e.normalizeClass(["text-gray-600 dark:text-gray-400",a.value.description])},e.toDisplayString(s("description")),3)],2),e.createElementVNode("div",{class:e.normalizeClass(["mb-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",a.value.grid])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),(f,S)=>(e.openBlock(),e.createElementBlock("button",{key:f.id||S,class:e.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,d(f)]]),onClick:p=>u(f)},[e.createElementVNode("div",{class:e.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,m(f)]])},[f.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.icon),{key:0,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]])},null,8,["class"])):(e.openBlock(),e.createBlock(e.unref(ze),{key:1,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]])},null,8,["class"]))],2),e.createElementVNode("h3",{class:e.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",a.value.suggestionTitle])},e.toDisplayString(f.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},e.toDisplayString(f.description),3)],10,Wa))),128))],2)],2)],2))}}),Ka={class:"flex items-center gap-3"},Ga={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},Qa={key:1,class:"flex items-center gap-2"},Za={key:0,class:"flex items-center gap-2 ml-auto mr-4"},Ya={key:1,class:"text-gray-300 dark:text-gray-600"},Xa={class:"text-green-600 dark:text-green-400 font-medium tabular-nums"},Ja={class:"text-gray-500 dark:text-gray-400"},va={key:1,class:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-red-50 dark:bg-red-900/20"},ei={class:"text-xs text-red-600 dark:text-red-400 font-medium"},ti=["title"],ni=["title"],ri=["title"],oi=e.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},showMessageCount:{type:Boolean},messageCount:{},messageLimit:{},t:{type:Function}},emits:["new-chat","close","minimize","toggle-fullscreen"],setup(r){const t=r;function n(){const l=t.messageCount/t.messageLimit;return l>=1?"danger":l>=.8?"warning":"default"}const o={icon:{danger:"text-red-500 dark:text-red-400",warning:"text-amber-500 dark:text-amber-400",default:"text-gray-400 dark:text-gray-500"},text:{danger:"text-red-600 dark:text-red-400",warning:"text-amber-600 dark:text-amber-400",default:"text-gray-600 dark:text-gray-300"}},s=e.computed(()=>o.text[n()]),a=e.computed(()=>o.icon[n()]),i=e.computed(()=>t.showMessageCount&&t.hasHistory&&t.showQuota&&t.quota.remaining>=0);return(l,u)=>{var d,m,h,g,y,f,S;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-between px-4 sm:px-6 pt-4 border-b border-gray-200 dark:border-gray-700 pb-4",(d=r.ui)==null?void 0:d.header])},[e.createElementVNode("div",Ka,[r.isSetupMode?(e.openBlock(),e.createElementBlock("div",Qa,[...u[4]||(u[4]=[e.createElementVNode("span",{class:"flex h-2 w-2 rounded-full bg-amber-500 animate-pulse"},null,-1),e.createElementVNode("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Setup Required",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[r.showNewChatButton&&r.hasHistory?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.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",(m=r.ui)==null?void 0:m.newChatButton]),onClick:u[0]||(u[0]=p=>l.$emit("new-chat"))},[e.createVNode(e.unref(ze),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(r.t("newChat")),1)],2)):(e.openBlock(),e.createElementBlock("span",Ga,e.toDisplayString(r.t("keyboardShortcutHint")),1))],64))]),!r.isSetupMode&&(r.showMessageCount||r.showQuota)?(e.openBlock(),e.createElementBlock("div",Za,[r.showMessageCount&&r.hasHistory?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 px-2 py-1 rounded-md bg-gray-100 dark:bg-gray-800",(h=r.ui)==null?void 0:h.messageCountBadge])},[e.createVNode(e.unref(Os),{class:e.normalizeClass(["w-3.5 h-3.5",a.value])},null,8,["class"]),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium tabular-nums",s.value])},[e.renderSlot(l.$slots,"message-count",{},()=>[e.createTextVNode(e.toDisplayString(r.messageCount),1),u[5]||(u[5]=e.createElementVNode("span",{class:"text-gray-400 dark:text-gray-500"},"/",-1)),e.createTextVNode(e.toDisplayString(r.messageLimit),1)])],2)],2)):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",Ya," • ")):e.createCommentVNode("",!0),r.showQuota?e.renderSlot(l.$slots,"quota",{key:2},()=>{var p;return[r.quota.remaining>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 text-xs",(p=r.ui)==null?void 0:p.quotaDisplay])},[e.createElementVNode("span",Xa,e.toDisplayString(r.quota.remaining),1),e.createElementVNode("span",Ja,e.toDisplayString(r.t("quotaRemaining")),1)],2)):r.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",va,[e.createVNode(e.unref(kt),{class:"w-3.5 h-3.5 text-red-500"}),e.createElementVNode("span",ei,e.toDisplayString(r.t("noQuota")),1)])):e.createCommentVNode("",!0)]}):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1",(g=r.ui)==null?void 0:g.headerActions])},[r.showCloseButton?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(y=r.ui)==null?void 0:y.headerActionButton]),title:r.t("close"),onClick:u[1]||(u[1]=p=>l.$emit("close"))},[e.createVNode(e.unref(vt),{class:"w-5 h-5 text-gray-600 dark:text-gray-400"})],10,ti)):e.createCommentVNode("",!0),r.showMinimizeButton?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(f=r.ui)==null?void 0:f.headerActionButton]),title:r.t("minimize"),onClick:u[2]||(u[2]=p=>l.$emit("minimize"))},[e.createVNode(e.unref(Vs),{class:"w-5 h-5 text-gray-600 dark:text-gray-400"})],10,ni)):e.createCommentVNode("",!0),r.showFullscreenToggle?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(S=r.ui)==null?void 0:S.headerActionButton]),title:r.isFullscreen?r.t("exitFullscreen"):r.t("fullscreen"),onClick:u[3]||(u[3]=p=>l.$emit("toggle-fullscreen"))},[r.isFullscreen?(e.openBlock(),e.createBlock(e.unref(qs),{key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(Hs),{key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400"}))],10,ri)):e.createCommentVNode("",!0)],2)],2)}}}),si={class:"max-w-3xl mx-auto px-4 space-y-6"},ai={class:"flex justify-center"},ii={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},li={key:0,class:"flex justify-center"},ci={class:"flex items-start gap-3"},ui={class:"flex-1 min-w-0"},di={key:0,class:"text-xs text-amber-600 dark:text-amber-400 mt-1"},mi=["title"],fi=e.defineComponent({__name:"DrawerMessageList",props:{messages:{},loadingMessage:{},quota:{},error:{},ui:{},t:{type:Function}},emits:["copy","contact-support","retry"],setup(r){return(t,n)=>{var o,s,a;return e.openBlock(),e.createElementBlock("div",si,[e.createElementVNode("div",ai,[e.createElementVNode("div",ii,[e.createVNode(e.unref(ze),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(r.t("title")||e.unref(te)("aiName")),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.messages,(i,l)=>e.renderSlot(t.$slots,"message",{key:i.id||l,message:i,isUser:i.role==="user",isLoading:i.loading,isStreaming:i.streaming},()=>[e.createVNode(sr,{message:i,"loading-text":r.loadingMessage,onCopy:n[0]||(n[0]=u=>t.$emit("copy",u))},null,8,["message","loading-text"])])),128)),r.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",li,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 px-6 py-3 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all shadow-sm",onClick:n[1]||(n[1]=i=>t.$emit("contact-support"))},[e.createVNode(e.unref(Zs),{class:"w-5 h-5"}),e.createElementVNode("span",null,e.toDisplayString(e.unref(te)("contactSupport")),1)])])):e.createCommentVNode("",!0),r.error.message?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["rounded-lg p-4 mb-4",[(o=r.ui)==null?void 0:o.errorContainer,r.error.rateLimited?"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800":"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800"]])},[e.createElementVNode("div",ci,[e.createElementVNode("div",{class:e.normalizeClass(["flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center",r.error.rateLimited?"bg-amber-100 dark:bg-amber-900/40":"bg-red-100 dark:bg-red-900/40"])},[r.error.rateLimited?(e.openBlock(),e.createBlock(e.unref(Ws),{key:0,class:"w-4 h-4 text-amber-600 dark:text-amber-400"})):(e.openBlock(),e.createBlock(e.unref(kt),{key:1,class:"w-4 h-4 text-red-600 dark:text-red-400"}))],2),e.createElementVNode("div",ui,[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium",[(s=r.ui)==null?void 0:s.errorMessage,r.error.rateLimited?"text-amber-800 dark:text-amber-200":"text-red-800 dark:text-red-200"]])},e.toDisplayString(r.error.message),3),r.error.rateLimited?(e.openBlock(),e.createElementBlock("p",di,e.toDisplayString(r.t("retryHint")||"Please wait a moment before trying again."),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-shrink-0 inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-md transition-colors",[(a=r.ui)==null?void 0:a.retryButton,r.error.rateLimited?"text-amber-700 dark:text-amber-300 bg-amber-100 dark:bg-amber-900/40 hover:bg-amber-200 dark:hover:bg-amber-900/60":"text-red-700 dark:text-red-300 bg-red-100 dark:bg-red-900/40 hover:bg-red-200 dark:hover:bg-red-900/60"]]),title:r.t("retry"),onClick:n[2]||(n[2]=i=>t.$emit("retry"))},[e.createVNode(e.unref(Gs),{class:"w-4 h-4"}),e.createTextVNode(" "+e.toDisplayString(r.t("retry")),1)],10,mi)])],2)):e.createCommentVNode("",!0)])}}}),pi={class:"w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"},hi={class:"w-full max-w-md"},gi={class:"bg-gray-900 rounded-xl overflow-hidden"},yi={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},ki=e.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",pi,[e.createVNode(e.unref(ze),{class:"w-7 h-7 text-primary"})]),n[4]||(n[4]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-1"}," Almost there! ",-1)),n[5]||(n[5]=e.createElementVNode("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. ",-1)),e.createElementVNode("div",hi,[e.createElementVNode("div",gi,[e.createElementVNode("div",yi,[n[1]||(n[1]=e.createElementVNode("span",{class:"text-xs text-gray-400"},"main.ts",-1)),e.createElementVNode("button",{type:"button",class:"text-xs text-gray-400 hover:text-white transition-colors",onClick:n[0]||(n[0]=o=>t.$emit("copy"))},e.toDisplayString(r.copied?"✓ Copied":"Copy"),1)]),n[2]||(n[2]=e.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(t){const o=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+o+`</${r}>
55
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:o,tokens:r}){const s=this.parser.parseInline(r),i=Hn(t);if(i===null)return s;t=i;let a='<a href="'+t+'"';return o&&(a+=' title="'+o+'"'),a+=">"+s+"</a>",a}image({href:t,title:o,text:r}){const s=Hn(t);if(s===null)return r;t=s;let i=`<img src="${t}" alt="${r}"`;return o&&(i+=` title="${o}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Kt{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class he{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||_e,this.options.renderer=this.options.renderer||new xt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Kt}static parse(t,o){return new he(o).parse(t)}static parseInline(t,o){return new he(o).parseInline(t)}parse(t,o=!0){let r="";for(let s=0;s<t.length;s++){const i=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const l=i,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){r+=c||"";continue}}const a=i;switch(a.type){case"space":{r+=this.renderer.space(a);continue}case"hr":{r+=this.renderer.hr(a);continue}case"heading":{r+=this.renderer.heading(a);continue}case"code":{r+=this.renderer.code(a);continue}case"table":{r+=this.renderer.table(a);continue}case"blockquote":{r+=this.renderer.blockquote(a);continue}case"list":{r+=this.renderer.list(a);continue}case"html":{r+=this.renderer.html(a);continue}case"paragraph":{r+=this.renderer.paragraph(a);continue}case"text":{let l=a,c=this.renderer.text(l);for(;s+1<t.length&&t[s+1].type==="text";)l=t[++s],c+=`
56
+ `+this.renderer.text(l);o?r+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c}]}):r+=c;continue}default:{const l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}parseInline(t,o){o=o||this.renderer;let r="";for(let s=0;s<t.length;s++){const i=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=l||"";continue}}const a=i;switch(a.type){case"escape":{r+=o.text(a);break}case"html":{r+=o.html(a);break}case"link":{r+=o.link(a);break}case"image":{r+=o.image(a);break}case"strong":{r+=o.strong(a);break}case"em":{r+=o.em(a);break}case"codespan":{r+=o.codespan(a);break}case"br":{r+=o.br(a);break}case"del":{r+=o.del(a);break}case"text":{r+=o.text(a);break}default:{const l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}}class tt{constructor(t){q(this,"options");q(this,"block");this.options=t||_e}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?me.lex:me.lexInline}provideParser(){return this.block?he.parse:he.parseInline}}q(tt,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class qr{constructor(...t){q(this,"defaults",Ot());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",he);q(this,"Renderer",xt);q(this,"TextRenderer",Kt);q(this,"Lexer",me);q(this,"Tokenizer",pt);q(this,"Hooks",tt);this.use(...t)}walkTokens(t,o){var s,i;let r=[];for(const a of t)switch(r=r.concat(o.call(this,a)),a.type){case"table":{const l=a;for(const c of l.header)r=r.concat(this.walkTokens(c.tokens,o));for(const c of l.rows)for(const u of c)r=r.concat(this.walkTokens(u.tokens,o));break}case"list":{const l=a;r=r.concat(this.walkTokens(l.items,o));break}default:{const l=a;(i=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&i[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{const u=l[c].flat(1/0);r=r.concat(this.walkTokens(u,o))}):l.tokens&&(r=r.concat(this.walkTokens(l.tokens,o)))}}return r}use(...t){const o=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const a=o.renderers[i.name];a?o.renderers[i.name]=function(...l){let c=i.renderer.apply(this,l);return c===!1&&(c=a.apply(this,l)),c}:o.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=o[i.level];a?a.unshift(i.tokenizer):o[i.level]=[i.tokenizer],i.start&&(i.level==="block"?o.startBlock?o.startBlock.push(i.start):o.startBlock=[i.start]:i.level==="inline"&&(o.startInline?o.startInline.push(i.start):o.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(o.childTokens[i.name]=i.childTokens)}),s.extensions=o),r.renderer){const i=this.defaults.renderer||new xt(this.defaults);for(const a in r.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const l=a,c=r.renderer[l],u=i[l];i[l]=(...m)=>{let p=c.apply(i,m);return p===!1&&(p=u.apply(i,m)),p||""}}s.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new pt(this.defaults);for(const a in r.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const l=a,c=r.tokenizer[l],u=i[l];i[l]=(...m)=>{let p=c.apply(i,m);return p===!1&&(p=u.apply(i,m)),p}}s.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new tt;for(const a in r.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const l=a,c=r.hooks[l],u=i[l];tt.passThroughHooks.has(a)?i[l]=m=>{if(this.defaults.async)return Promise.resolve(c.call(i,m)).then(g=>u.call(i,g));const p=c.call(i,m);return u.call(i,p)}:i[l]=(...m)=>{let p=c.apply(i,m);return p===!1&&(p=u.apply(i,m)),p}}s.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,a=r.walkTokens;s.walkTokens=function(l){let c=[];return c.push(a.call(this,l)),i&&(c=c.concat(i.call(this,l))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,o){return me.lex(t,o??this.defaults)}parser(t,o){return he.parse(t,o??this.defaults)}parseMarkdown(t){return(r,s)=>{const i={...s},a={...this.defaults,...i},l=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&i.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"));a.hooks&&(a.hooks.options=a,a.hooks.block=t);const c=a.hooks?a.hooks.provideLexer():t?me.lex:me.lexInline,u=a.hooks?a.hooks.provideParser():t?he.parse:he.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(r):r).then(m=>c(m,a)).then(m=>a.hooks?a.hooks.processAllTokens(m):m).then(m=>a.walkTokens?Promise.all(this.walkTokens(m,a.walkTokens)).then(()=>m):m).then(m=>u(m,a)).then(m=>a.hooks?a.hooks.postprocess(m):m).catch(l);try{a.hooks&&(r=a.hooks.preprocess(r));let m=c(r,a);a.hooks&&(m=a.hooks.processAllTokens(m)),a.walkTokens&&this.walkTokens(m,a.walkTokens);let p=u(m,a);return a.hooks&&(p=a.hooks.postprocess(p)),p}catch(m){return l(m)}}}onError(t,o){return r=>{if(r.message+=`
57
+ Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+ue(r.message+"",!0)+"</pre>";return o?Promise.resolve(s):s}if(o)return Promise.reject(r);throw r}}}const $e=new qr;function F(n,t){return $e.parse(n,t)}F.options=F.setOptions=function(n){return $e.setOptions(n),F.defaults=$e.defaults,$n(F.defaults),F},F.getDefaults=Ot,F.defaults=_e,F.use=function(...n){return $e.use(...n),F.defaults=$e.defaults,$n(F.defaults),F},F.walkTokens=function(n,t){return $e.walkTokens(n,t)},F.parseInline=$e.parseInline,F.Parser=he,F.parser=he.parse,F.Renderer=xt,F.TextRenderer=Kt,F.Lexer=me,F.lexer=me.lex,F.Tokenizer=pt,F.Hooks=tt,F.parse=F,F.options,F.setOptions,F.use,F.walkTokens,F.parseInline,he.parse,me.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:Gn,setPrototypeOf:vn,isFrozen:jr,getPrototypeOf:Wr,getOwnPropertyDescriptor:Kr}=Object;let{freeze:se,seal:fe,create:Qt}=Object,{apply:Gt,construct:vt}=typeof Reflect<"u"&&Reflect;se||(se=function(t){return t}),fe||(fe=function(t){return t}),Gt||(Gt=function(t,o){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return t.apply(o,s)}),vt||(vt=function(t){for(var o=arguments.length,r=new Array(o>1?o-1:0),s=1;s<o;s++)r[s-1]=arguments[s];return new t(...r)});const wt=ae(Array.prototype.forEach),Qr=ae(Array.prototype.lastIndexOf),Yn=ae(Array.prototype.pop),nt=ae(Array.prototype.push),Gr=ae(Array.prototype.splice),bt=ae(String.prototype.toLowerCase),Yt=ae(String.prototype.toString),Zt=ae(String.prototype.match),ot=ae(String.prototype.replace),vr=ae(String.prototype.indexOf),Yr=ae(String.prototype.trim),ye=ae(Object.prototype.hasOwnProperty),ie=ae(RegExp.prototype.test),rt=Zr(TypeError);function ae(n){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var o=arguments.length,r=new Array(o>1?o-1:0),s=1;s<o;s++)r[s-1]=arguments[s];return Gt(n,t,r)}}function Zr(n){return function(){for(var t=arguments.length,o=new Array(t),r=0;r<t;r++)o[r]=arguments[r];return vt(n,o)}}function z(n,t){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bt;vn&&vn(n,null);let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const i=o(s);i!==s&&(jr(t)||(t[r]=i),s=i)}n[s]=!0}return n}function Xr(n){for(let t=0;t<n.length;t++)ye(n,t)||(n[t]=null);return n}function Ee(n){const t=Qt(null);for(const[o,r]of Gn(n))ye(n,o)&&(Array.isArray(r)?t[o]=Xr(r):r&&typeof r=="object"&&r.constructor===Object?t[o]=Ee(r):t[o]=r);return t}function st(n,t){for(;n!==null;){const r=Kr(n,t);if(r){if(r.get)return ae(r.get);if(typeof r.value=="function")return ae(r.value)}n=Wr(n)}function o(){return null}return o}const Zn=se(["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"]),Xt=se(["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"]),Jt=se(["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"]),Jr=se(["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"]),en=se(["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"]),es=se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Xn=se(["#text"]),Jn=se(["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"]),tn=se(["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"]),eo=se(["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"]),Ct=se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ts=fe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ns=fe(/<%[\w\W]*|[\w\W]*%>/gm),os=fe(/\$\{[\w\W]*/gm),rs=fe(/^data-[\-\w.\u00B7-\uFFFF]+$/),ss=fe(/^aria-[\-\w]+$/),to=fe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),is=fe(/^(?:\w+script|data):/i),as=fe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),no=fe(/^html$/i),ls=fe(/^[a-z][.\w]*(-[.\w]+)+$/i);var oo=Object.freeze({__proto__:null,ARIA_ATTR:ss,ATTR_WHITESPACE:as,CUSTOM_ELEMENT:ls,DATA_ATTR:rs,DOCTYPE_NAME:no,ERB_EXPR:ns,IS_ALLOWED_URI:to,IS_SCRIPT_OR_DATA:is,MUSTACHE_EXPR:ts,TMPLIT_EXPR:os});const it={element:1,text:3,progressingInstruction:7,comment:8,document:9},cs=function(){return typeof window>"u"?null:window},ds=function(t,o){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";o&&o.hasAttribute(s)&&(r=o.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},ro=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function so(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cs();const t=M=>so(M);if(t.version="3.3.0",t.removed=[],!n||!n.document||n.document.nodeType!==it.document||!n.Element)return t.isSupported=!1,t;let{document:o}=n;const r=o,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:a,Node:l,Element:c,NodeFilter:u,NamedNodeMap:m=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:g,trustedTypes:k}=n,h=c.prototype,N=st(h,"cloneNode"),f=st(h,"remove"),y=st(h,"nextSibling"),b=st(h,"childNodes"),x=st(h,"parentNode");if(typeof a=="function"){const M=o.createElement("template");M.content&&M.content.ownerDocument&&(o=M.content.ownerDocument)}let C,S="";const{implementation:E,createNodeIterator:R,createDocumentFragment:D,getElementsByTagName:B}=o,{importNode:_}=r;let V=ro();t.isSupported=typeof Gn=="function"&&typeof x=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:X,ERB_EXPR:le,TMPLIT_EXPR:T,DATA_ATTR:I,ARIA_ATTR:Q,IS_SCRIPT_OR_DATA:J,ATTR_WHITESPACE:P,CUSTOM_ELEMENT:Le}=oo;let{IS_ALLOWED_URI:De}=oo,H=null;const pe=z({},[...Zn,...Xt,...Jt,...en,...Xn]);let Y=null;const Tt=z({},[...Jn,...tn,...eo,...Ct]);let G=Object.seal(Qt(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}})),ze=null,Fe=null;const Se=Object.seal(Qt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let At=!0,at=!0,Nt=!1,lt=!0,Te=!1,Ue=!0,be=!1,$=!1,O=!1,v=!1,ce=!1,te=!1,ne=!0,ge=!1;const Bt="user-content-";let an=!0,ct=!1,qe={},je=null;const bo=z({},["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 Co=null;const Eo=z({},["audio","video","img","source","image","track"]);let ln=null;const So=z({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mt="http://www.w3.org/1998/Math/MathML",Rt="http://www.w3.org/2000/svg",Ae="http://www.w3.org/1999/xhtml";let We=Ae,cn=!1,dn=null;const gl=z({},[Mt,Rt,Ae],Yt);let It=z({},["mi","mo","mn","ms","mtext"]),_t=z({},["annotation-xml"]);const yl=z({},["title","style","font","a","script"]);let dt=null;const kl=["application/xhtml+xml","text/html"],xl="text/html";let ee=null,Ke=null;const wl=o.createElement("form"),To=function(d){return d instanceof RegExp||d instanceof Function},un=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ke&&Ke===d)){if((!d||typeof d!="object")&&(d={}),d=Ee(d),dt=kl.indexOf(d.PARSER_MEDIA_TYPE)===-1?xl:d.PARSER_MEDIA_TYPE,ee=dt==="application/xhtml+xml"?Yt:bt,H=ye(d,"ALLOWED_TAGS")?z({},d.ALLOWED_TAGS,ee):pe,Y=ye(d,"ALLOWED_ATTR")?z({},d.ALLOWED_ATTR,ee):Tt,dn=ye(d,"ALLOWED_NAMESPACES")?z({},d.ALLOWED_NAMESPACES,Yt):gl,ln=ye(d,"ADD_URI_SAFE_ATTR")?z(Ee(So),d.ADD_URI_SAFE_ATTR,ee):So,Co=ye(d,"ADD_DATA_URI_TAGS")?z(Ee(Eo),d.ADD_DATA_URI_TAGS,ee):Eo,je=ye(d,"FORBID_CONTENTS")?z({},d.FORBID_CONTENTS,ee):bo,ze=ye(d,"FORBID_TAGS")?z({},d.FORBID_TAGS,ee):Ee({}),Fe=ye(d,"FORBID_ATTR")?z({},d.FORBID_ATTR,ee):Ee({}),qe=ye(d,"USE_PROFILES")?d.USE_PROFILES:!1,At=d.ALLOW_ARIA_ATTR!==!1,at=d.ALLOW_DATA_ATTR!==!1,Nt=d.ALLOW_UNKNOWN_PROTOCOLS||!1,lt=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Te=d.SAFE_FOR_TEMPLATES||!1,Ue=d.SAFE_FOR_XML!==!1,be=d.WHOLE_DOCUMENT||!1,v=d.RETURN_DOM||!1,ce=d.RETURN_DOM_FRAGMENT||!1,te=d.RETURN_TRUSTED_TYPE||!1,O=d.FORCE_BODY||!1,ne=d.SANITIZE_DOM!==!1,ge=d.SANITIZE_NAMED_PROPS||!1,an=d.KEEP_CONTENT!==!1,ct=d.IN_PLACE||!1,De=d.ALLOWED_URI_REGEXP||to,We=d.NAMESPACE||Ae,It=d.MATHML_TEXT_INTEGRATION_POINTS||It,_t=d.HTML_INTEGRATION_POINTS||_t,G=d.CUSTOM_ELEMENT_HANDLING||{},d.CUSTOM_ELEMENT_HANDLING&&To(d.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(G.tagNameCheck=d.CUSTOM_ELEMENT_HANDLING.tagNameCheck),d.CUSTOM_ELEMENT_HANDLING&&To(d.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(G.attributeNameCheck=d.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=d.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Te&&(at=!1),ce&&(v=!0),qe&&(H=z({},Xn),Y=[],qe.html===!0&&(z(H,Zn),z(Y,Jn)),qe.svg===!0&&(z(H,Xt),z(Y,tn),z(Y,Ct)),qe.svgFilters===!0&&(z(H,Jt),z(Y,tn),z(Y,Ct)),qe.mathMl===!0&&(z(H,en),z(Y,eo),z(Y,Ct))),d.ADD_TAGS&&(typeof d.ADD_TAGS=="function"?Se.tagCheck=d.ADD_TAGS:(H===pe&&(H=Ee(H)),z(H,d.ADD_TAGS,ee))),d.ADD_ATTR&&(typeof d.ADD_ATTR=="function"?Se.attributeCheck=d.ADD_ATTR:(Y===Tt&&(Y=Ee(Y)),z(Y,d.ADD_ATTR,ee))),d.ADD_URI_SAFE_ATTR&&z(ln,d.ADD_URI_SAFE_ATTR,ee),d.FORBID_CONTENTS&&(je===bo&&(je=Ee(je)),z(je,d.FORBID_CONTENTS,ee)),an&&(H["#text"]=!0),be&&z(H,["html","head","body"]),H.table&&(z(H,["tbody"]),delete ze.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw rt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw rt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=d.TRUSTED_TYPES_POLICY,S=C.createHTML("")}else C===void 0&&(C=ds(k,s)),C!==null&&typeof S=="string"&&(S=C.createHTML(""));se&&se(d),Ke=d}},Ao=z({},[...Xt,...Jt,...Jr]),No=z({},[...en,...es]),bl=function(d){let w=x(d);(!w||!w.tagName)&&(w={namespaceURI:We,tagName:"template"});const A=bt(d.tagName),W=bt(w.tagName);return dn[d.namespaceURI]?d.namespaceURI===Rt?w.namespaceURI===Ae?A==="svg":w.namespaceURI===Mt?A==="svg"&&(W==="annotation-xml"||It[W]):!!Ao[A]:d.namespaceURI===Mt?w.namespaceURI===Ae?A==="math":w.namespaceURI===Rt?A==="math"&&_t[W]:!!No[A]:d.namespaceURI===Ae?w.namespaceURI===Rt&&!_t[W]||w.namespaceURI===Mt&&!It[W]?!1:!No[A]&&(yl[A]||!Ao[A]):!!(dt==="application/xhtml+xml"&&dn[d.namespaceURI]):!1},Ce=function(d){nt(t.removed,{element:d});try{x(d).removeChild(d)}catch{f(d)}},He=function(d,w){try{nt(t.removed,{attribute:w.getAttributeNode(d),from:w})}catch{nt(t.removed,{attribute:null,from:w})}if(w.removeAttribute(d),d==="is")if(v||ce)try{Ce(w)}catch{}else try{w.setAttribute(d,"")}catch{}},Bo=function(d){let w=null,A=null;if(O)d="<remove></remove>"+d;else{const Z=Zt(d,/^[\r\n\t ]+/);A=Z&&Z[0]}dt==="application/xhtml+xml"&&We===Ae&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const W=C?C.createHTML(d):d;if(We===Ae)try{w=new g().parseFromString(W,dt)}catch{}if(!w||!w.documentElement){w=E.createDocument(We,"template",null);try{w.documentElement.innerHTML=cn?S:W}catch{}}const re=w.body||w.documentElement;return d&&A&&re.insertBefore(o.createTextNode(A),re.childNodes[0]||null),We===Ae?B.call(w,be?"html":"body")[0]:be?w.documentElement:re},Mo=function(d){return R.call(d.ownerDocument||d,d,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},mn=function(d){return d instanceof p&&(typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||!(d.attributes instanceof m)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function")},Ro=function(d){return typeof l=="function"&&d instanceof l};function Ne(M,d,w){wt(M,A=>{A.call(t,d,w,Ke)})}const Io=function(d){let w=null;if(Ne(V.beforeSanitizeElements,d,null),mn(d))return Ce(d),!0;const A=ee(d.nodeName);if(Ne(V.uponSanitizeElement,d,{tagName:A,allowedTags:H}),Ue&&d.hasChildNodes()&&!Ro(d.firstElementChild)&&ie(/<[/\w!]/g,d.innerHTML)&&ie(/<[/\w!]/g,d.textContent)||d.nodeType===it.progressingInstruction||Ue&&d.nodeType===it.comment&&ie(/<[/\w]/g,d.data))return Ce(d),!0;if(!(Se.tagCheck instanceof Function&&Se.tagCheck(A))&&(!H[A]||ze[A])){if(!ze[A]&&$o(A)&&(G.tagNameCheck instanceof RegExp&&ie(G.tagNameCheck,A)||G.tagNameCheck instanceof Function&&G.tagNameCheck(A)))return!1;if(an&&!je[A]){const W=x(d)||d.parentNode,re=b(d)||d.childNodes;if(re&&W){const Z=re.length;for(let de=Z-1;de>=0;--de){const Be=N(re[de],!0);Be.__removalCount=(d.__removalCount||0)+1,W.insertBefore(Be,y(d))}}}return Ce(d),!0}return d instanceof c&&!bl(d)||(A==="noscript"||A==="noembed"||A==="noframes")&&ie(/<\/no(script|embed|frames)/i,d.innerHTML)?(Ce(d),!0):(Te&&d.nodeType===it.text&&(w=d.textContent,wt([X,le,T],W=>{w=ot(w,W," ")}),d.textContent!==w&&(nt(t.removed,{element:d.cloneNode()}),d.textContent=w)),Ne(V.afterSanitizeElements,d,null),!1)},_o=function(d,w,A){if(ne&&(w==="id"||w==="name")&&(A in o||A in wl))return!1;if(!(at&&!Fe[w]&&ie(I,w))){if(!(At&&ie(Q,w))){if(!(Se.attributeCheck instanceof Function&&Se.attributeCheck(w,d))){if(!Y[w]||Fe[w]){if(!($o(d)&&(G.tagNameCheck instanceof RegExp&&ie(G.tagNameCheck,d)||G.tagNameCheck instanceof Function&&G.tagNameCheck(d))&&(G.attributeNameCheck instanceof RegExp&&ie(G.attributeNameCheck,w)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(w,d))||w==="is"&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&ie(G.tagNameCheck,A)||G.tagNameCheck instanceof Function&&G.tagNameCheck(A))))return!1}else if(!ln[w]){if(!ie(De,ot(A,P,""))){if(!((w==="src"||w==="xlink:href"||w==="href")&&d!=="script"&&vr(A,"data:")===0&&Co[d])){if(!(Nt&&!ie(J,ot(A,P,"")))){if(A)return!1}}}}}}}return!0},$o=function(d){return d!=="annotation-xml"&&Zt(d,Le)},Lo=function(d){Ne(V.beforeSanitizeAttributes,d,null);const{attributes:w}=d;if(!w||mn(d))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let W=w.length;for(;W--;){const re=w[W],{name:Z,namespaceURI:de,value:Be}=re,Qe=ee(Z),hn=Be;let oe=Z==="value"?hn:Yr(hn);if(A.attrName=Qe,A.attrValue=oe,A.keepAttr=!0,A.forceKeepAttr=void 0,Ne(V.uponSanitizeAttribute,d,A),oe=A.attrValue,ge&&(Qe==="id"||Qe==="name")&&(He(Z,d),oe=Bt+oe),Ue&&ie(/((--!?|])>)|<\/(style|title|textarea)/i,oe)){He(Z,d);continue}if(Qe==="attributename"&&Zt(oe,"href")){He(Z,d);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){He(Z,d);continue}if(!lt&&ie(/\/>/i,oe)){He(Z,d);continue}Te&&wt([X,le,T],zo=>{oe=ot(oe,zo," ")});const Do=ee(d.nodeName);if(!_o(Do,Qe,oe)){He(Z,d);continue}if(C&&typeof k=="object"&&typeof k.getAttributeType=="function"&&!de)switch(k.getAttributeType(Do,Qe)){case"TrustedHTML":{oe=C.createHTML(oe);break}case"TrustedScriptURL":{oe=C.createScriptURL(oe);break}}if(oe!==hn)try{de?d.setAttributeNS(de,Z,oe):d.setAttribute(Z,oe),mn(d)?Ce(d):Yn(t.removed)}catch{He(Z,d)}}Ne(V.afterSanitizeAttributes,d,null)},Cl=function M(d){let w=null;const A=Mo(d);for(Ne(V.beforeSanitizeShadowDOM,d,null);w=A.nextNode();)Ne(V.uponSanitizeShadowNode,w,null),Io(w),Lo(w),w.content instanceof i&&M(w.content);Ne(V.afterSanitizeShadowDOM,d,null)};return t.sanitize=function(M){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},w=null,A=null,W=null,re=null;if(cn=!M,cn&&(M="<!-->"),typeof M!="string"&&!Ro(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw rt("dirty is not a string, aborting")}else throw rt("toString is not a function");if(!t.isSupported)return M;if($||un(d),t.removed=[],typeof M=="string"&&(ct=!1),ct){if(M.nodeName){const Be=ee(M.nodeName);if(!H[Be]||ze[Be])throw rt("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof l)w=Bo("<!---->"),A=w.ownerDocument.importNode(M,!0),A.nodeType===it.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?w=A:w.appendChild(A);else{if(!v&&!Te&&!be&&M.indexOf("<")===-1)return C&&te?C.createHTML(M):M;if(w=Bo(M),!w)return v?null:te?S:""}w&&O&&Ce(w.firstChild);const Z=Mo(ct?M:w);for(;W=Z.nextNode();)Io(W),Lo(W),W.content instanceof i&&Cl(W.content);if(ct)return M;if(v){if(ce)for(re=D.call(w.ownerDocument);w.firstChild;)re.appendChild(w.firstChild);else re=w;return(Y.shadowroot||Y.shadowrootmode)&&(re=_.call(r,re,!0)),re}let de=be?w.outerHTML:w.innerHTML;return be&&H["!doctype"]&&w.ownerDocument&&w.ownerDocument.doctype&&w.ownerDocument.doctype.name&&ie(no,w.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+w.ownerDocument.doctype.name+`>
58
+ `+de),Te&&wt([X,le,T],Be=>{de=ot(de,Be," ")}),C&&te?C.createHTML(de):de},t.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};un(M),$=!0},t.clearConfig=function(){Ke=null,$=!1},t.isValidAttribute=function(M,d,w){Ke||un({});const A=ee(M),W=ee(d);return _o(A,W,w)},t.addHook=function(M,d){typeof d=="function"&&nt(V[M],d)},t.removeHook=function(M,d){if(d!==void 0){const w=Qr(V[M],d);return w===-1?void 0:Gr(V[M],w,1)[0]}return Yn(V[M])},t.removeHooks=function(M){V[M]=[]},t.removeAllHooks=function(){V=ro()},t}var us=so();function io(){return{parseMarkdown:t=>{if(!t||typeof t!="string")return"";const o=An(t),r=F.parse(o,{async:!1,breaks:!0,gfm:!0});return us.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 ms(){let n=null;function t(i){const a=i||document.querySelector("[data-rai-chat-container]");a&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}function o(i,a=100){const{scrollTop:l,scrollHeight:c,clientHeight:u}=i;return c-l-u<a}function r(i){i&&(s(),n=new MutationObserver(()=>{(i.scrollTop===0||o(i))&&requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})}),n.observe(i,{childList:!0,subtree:!0}))}function s(){n&&(n.disconnect(),n=null)}return e.onUnmounted(()=>{s()}),{scrollToBottom:t,setupAutoScroll:r,cleanupAutoScroll:s}}function hs(){const n=xe(),t=e.computed(()=>n.error),o=e.computed(()=>{var i,a;return((i=t.value)==null?void 0:i.message)!==null&&((a=t.value)==null?void 0:a.message)!==void 0});return{errorState:t,hasError:o,retry:async()=>await n.retry(),clearError:()=>{n.clearError()}}}function nn(){const n=xe(),t=e.computed(()=>n.pageContext);function o(i){n.setPageContext(i)}function r(){n.setPageContext(null)}function s(i){const a=n.pageContext;a&&n.setPageContext({...a,...i,metadata:{...a.metadata,...i.metadata}})}return{context:t,setContext:o,clearContext:r,updateContext:s}}const we=[],ao={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const n=K();return(n==null?void 0:n.defaultSuggestions)||[]}};function fs(){we.length=0;const n=K();n!=null&&n.suggestionProviders&&we.push(...n.suggestionProviders),we.push(ao)}function ps(n,t){const o=[...we].sort((r,s)=>(s.priority||0)-(r.priority||0));for(const r of o)if(r.matcher&&r.matcher(n,t)||r.routes&&r.routes.some(i=>i.endsWith("*")?n.startsWith(i.slice(0,-1)):n===i||n.startsWith(i+"/")))return r;return ao}function lo(n,t){we.length===0&&fs();const o=ps(n,t),r=t||{pageType:"default",routePath:n};return o.extractContext&&(r.metadata={...r.metadata,...o.extractContext(n)}),o.getSuggestions(r)||[]}function gs(n){const t=we.findIndex(o=>o.id===n.id);if(t>=0)we[t]=n;else{const o=we.findIndex(r=>r.id==="default");o>=0?we.splice(o,0,n):we.push(n)}}const ys=gs;function on(){const{context:n}=nn(),t=xe(),o=K();function r(){var c;return(c=n.value)!=null&&c.routePath?n.value.routePath:typeof window<"u"?window.location.pathname:"/"}function s(c){return o!=null&&o.can?c.filter(u=>u.permission?o.can(u.permission):!0):c}const i=e.computed(()=>{if(t.quota.remaining===0)return(o==null?void 0:o.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 c=r(),u=lo(c,n.value)||[];return s(u)}),a=e.computed(()=>n.value!==null&&n.value.pageType!=="default");function l(c){return typeof c.prompt=="function"?c.prompt(n.value||{pageType:"default"}):c.prompt}return{suggestions:i,hasContextualSuggestions:a,resolvePrompt:l}}function ks(n,t){const{setContext:o,clearContext:r,updateContext:s}=nn();function i(){if(!t)return{};const l={};for(const[c,u]of Object.entries(t))l[c]=e.isRef(u)?u.value:u;return l}function a(){const l={pageType:n,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:i()};o(l)}return e.onMounted(()=>{a()}),e.onUnmounted(()=>{r()}),t&&e.watch(()=>i(),l=>{s({metadata:l})},{deep:!0}),{setupContext:a}}function xs(n){const t=n.toLowerCase().split("+");return{key:t.pop()||"",meta:t.includes("cmd")||t.includes("meta")||t.includes("command"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option"),mod:t.includes("mod")}}function ws(n,t){const o=n.key.toLowerCase();if(t.mod){const u=navigator.platform.toUpperCase().indexOf("MAC")>=0||navigator.userAgent.toUpperCase().indexOf("MAC")>=0?n.metaKey:n.ctrlKey,m=t.shift?n.shiftKey:!n.shiftKey,p=t.alt?n.altKey:!n.altKey;return o===t.key&&u&&m&&p}const r=t.meta?n.metaKey:!n.metaKey,s=t.ctrl?n.ctrlKey:!n.ctrlKey,i=t.shift?n.shiftKey:!n.shiftKey,a=t.alt?n.altKey:!n.altKey;let l=r&&s&&i&&a;return(t.meta&&!t.ctrl||!t.meta&&t.ctrl)&&(l=(n.metaKey||n.ctrlKey)&&i&&a),o===t.key&&l}function co(n){const{onToggle:t,enabled:o=!0}=n,r=e.ref(!1),s=n.shortcut!==void 0?n.shortcut:ke("keyboardShortcut")??"mod+g";if(s===null)return{isActive:r};const i=xs(s);function a(l){if(!o)return;const c=l.target,u=c.tagName==="INPUT"||c.tagName==="TEXTAREA",m=c.isContentEditable,p=c.closest("[data-ai-input]");if(!((u||m)&&!p)&&ws(l,i)){l.preventDefault(),l.stopPropagation();const g=K();if(g!=null&&g.canToggle&&!g.canToggle())return;r.value=!r.value,t()}}return e.onMounted(()=>{window.addEventListener("keydown",a,!0)}),e.onUnmounted(()=>{window.removeEventListener("keydown",a,!0)}),{isActive:r}}function bs(n){const t=xe();return co({onToggle:()=>{n?n.value=!n.value:t.showChat=!t.showChat}})}function Cs(n,t){const o=e.ref(j("loadingText"));let r=[];function s(){return[j("loadingText"),j("analyzingText"),j("craftingText")]}function i(){return[0,2e3,5e3]}function a(){r.forEach(u=>clearTimeout(u)),r=[]}function l(){a();const u=t==null?void 0:t(),m=(u==null?void 0:u.messages)??s();o.value=m[0]||j("loadingText")}function c(){a();const u=t==null?void 0:t(),m=(u==null?void 0:u.messages)??s(),p=(u==null?void 0:u.intervals)??i();o.value=m[0]||j("loadingText");let g=0;for(let k=1;k<m.length;k++){g+=p[k]||2e3;const h=k,N=window.setTimeout(()=>{n()&&(o.value=m[h])},g);r.push(N)}}return e.onUnmounted(()=>{a()}),{loadingMessage:o,startLoadingText:c,resetLoadingText:l,clearLoadingTextTimers:a}}function Es(n){const{getHistoryLength:t,getStoreLimit:o,getConfig:r,getTexts:s,onStartNewChat:i,onNewChatEmit:a}=n,l=e.ref({showWarning:!1,isReached:!1,pendingMessage:null}),c=e.computed(()=>{var x;return((x=r())==null?void 0:x.limit)??o()}),u=e.computed(()=>{var x;return((x=r())==null?void 0:x.showWarningAt)??c.value-2}),m=e.computed(()=>Math.max(0,c.value-t())),p=e.computed(()=>m.value<=c.value-u.value&&m.value>0),g=e.computed(()=>m.value===0),k=e.computed(()=>{var x,C;return l.value.isReached||g.value?((x=s())==null?void 0:x.historyLimitReachedTitle)??"Chat Limit Reached":((C=s())==null?void 0:C.historyLimitWarningTitle)??"Approaching Chat Limit"}),h=e.computed(()=>{var x,C,S,E;return l.value.isReached||g.value?((x=r())==null?void 0:x.limitMessage)??((C=s())==null?void 0:C.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":((S=r())==null?void 0:S.warningMessage)??((E=s())==null?void 0:E.historyLimitWarningMessage)??`You have ${m.value} message${m.value===1?"":"s"} remaining in this conversation.`});function N(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function f(){l.value.showWarning=!1;const x=r();if(x!=null&&x.onLimitReached&&!await x.onLimitReached())return l.value.isReached=!1,null;if(i(),a(),l.value.isReached=!1,l.value.pendingMessage){const C=l.value.pendingMessage;return l.value.pendingMessage=null,C}return null}function y(){return g.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(p.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function b(x){l.value.pendingMessage=x}return{showHistoryLimitWarning:e.computed(()=>l.value.showWarning),historyLimitReached:e.computed(()=>l.value.isReached),historyLimit:c,remainingMessages:m,historyLimitDialogTitle:k,historyLimitDialogMessage:h,dismissHistoryLimitWarning:N,handleHistoryLimitAction:f,checkHistoryLimit:y,setPendingMessage:b}}function Ss(){const n=xe(),t=e.ref([]),o=e.ref(!1),r=e.ref(0),s=ke("maxAttachments")||5,i=ke("maxFileSize")||10*1024*1024,a=ke("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=e.computed(()=>t.value.length>0),c=e.computed(()=>t.value.some(E=>E.uploading)),u=e.computed(()=>t.value.length<s);function m(E){var X;const R=crypto.randomUUID(),D=E.type.startsWith("image/")?URL.createObjectURL(E):void 0,B=K(),_=!!((X=B==null?void 0:B.endpoints)!=null&&X.uploadFile),V={id:R,name:E.name,type:E.type,size:E.size,uploading:_,progress:_?0:100,previewUrl:D};t.value.push(V),_&&p(E,R)}async function p(E,R){try{const D=await n.uploadFile(E),B=t.value.findIndex(_=>_.id===R);if(B===-1)return;if(D){const _=t.value[B].previewUrl;t.value[B]={...t.value[B],...D,id:D.id||R,uploading:!1,progress:100,previewUrl:_||D.previewUrl}}else g(R)}catch{g(R)}}function g(E){const R=t.value.findIndex(B=>B.id===E);if(R===-1)return;const[D]=t.value.splice(R,1);D!=null&&D.previewUrl&&URL.revokeObjectURL(D.previewUrl)}function k(){t.value.forEach(E=>{E.previewUrl&&URL.revokeObjectURL(E.previewUrl)}),t.value=[]}function h(){return t.value.filter(E=>!E.uploading).map(E=>({id:E.id,name:E.name,url:E.url,type:E.type,size:E.size,extractedText:E.extractedText,backendFileId:E.backendFileId}))}function N(E){if(!E)return;const R=Array.from(E);for(const D of R){if(t.value.length>=s)break;D.size>i||m(D)}}function f(E){var R;return Array.from(((R=E.dataTransfer)==null?void 0:R.types)||[]).includes("Files")}function y(E){f(E)&&(r.value+=1,o.value=!0)}function b(E){f(E)||E.preventDefault()}function x(E){f(E)&&(r.value=Math.max(0,r.value-1),r.value===0&&(o.value=!1))}function C(E){var R;f(E)&&(r.value=0,o.value=!1,N(((R=E.dataTransfer)==null?void 0:R.files)||null))}function S(E){const R=E.target,D=R.files;D&&D.length&&N(D),R.value=""}return e.onBeforeUnmount(()=>{k()}),{attachments:t,isDraggingFiles:o,hasAttachments:l,isUploading:c,canAddMore:u,acceptedFileTypes:a,isImage:ut,formatFileSize:mt,removeAttachment:g,clearAttachments:k,buildPayload:h,processFiles:N,handleFileSelect:S,handleDragEnter:y,handleDragOver:b,handleDragLeave:x,handleDrop:C}}function Ts(n,t,o){const r=e.ref(!1),s=e.ref([]),i=e.ref(0),a=e.ref({inMention:!1,query:"",startPos:0}),l=e.ref(!1),c=e.ref([]),u=e.computed(()=>{const f=K();return(f==null?void 0:f.mentionProviders)||[]});function m(f){if(l.value){l.value=!1;return}const y=o();if(!y)return;const b=y.selectionStart,x=Nn(f,b);a.value=x,x.inMention&&x.query.length>=0?p(x.query):(r.value=!1,s.value=[])}async function p(f){const y=Rn();if(y.length===0){r.value=!1;return}const b=[];for(const x of y)try{const C=await x.search(f);b.push(...C.map(S=>({...S,type:x.type})))}catch(C){console.warn(`Mention provider ${x.type} failed:`,C)}s.value=b.slice(0,10),r.value=b.length>0,i.value=0}function g(f){const{startPos:y}=a.value,b=n(),x=o(),C=b.slice(0,y),S=b.slice((x==null?void 0:x.selectionStart)||y),E=f.name||f.label||f.title||f.id;l.value=!0,t(`${C}@${E} ${S}`),c.value.push({id:f.id,name:E,type:f.type,metadata:f.attributes}),r.value=!1,s.value=[],setTimeout(()=>{const R=o();R==null||R.focus();const D=C.length+E.length+2;R==null||R.setSelectionRange(D,D)},0)}function k(f){if(!r.value||s.value.length===0)return!1;if(f.key==="ArrowDown")return f.preventDefault(),i.value=Math.min(i.value+1,s.value.length-1),!0;if(f.key==="ArrowUp")return f.preventDefault(),i.value=Math.max(i.value-1,0),!0;if(f.key==="Enter"||f.key==="Tab"){f.preventDefault();const y=s.value[i.value];return y&&g(y),!0}return f.key==="Escape"?(f.preventDefault(),r.value=!1,!0):!1}function h(){c.value=[]}function N(){return[...c.value]}return{showMentions:r,mentionItems:s,selectedMentionIndex:i,mentionProviders:u,checkForMentions:m,handleMentionSelect:g,handleMentionKeyDown:k,clearMentions:h,getMentions:N}}function As(n,t,o,r,s){const i=e.ref(!1),a=e.ref(-1),l=e.ref(null);function c(){setTimeout(()=>{const k=l.value;if(!k)return;const h=k.querySelector(`li:nth-child(${a.value+1})`);h&&h.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function u(k){const h=n();if(!i.value||h.length===0)return!1;if(k.key==="ArrowDown")return k.preventDefault(),a.value=Math.min(a.value+1,h.length-1),c(),!0;if(k.key==="ArrowUp")return k.preventDefault(),a.value=Math.max(a.value-1,0),c(),!0;if(k.key==="Enter"&&a.value>=0){k.preventDefault();const N=h[a.value];return N&&m(N),!0}return k.key==="Escape"?(k.preventDefault(),i.value=!1,a.value=-1,!0):!1}function m(k){s(k),i.value=!1,a.value=-1}function p(){const k=r(),h=t(),N=o(),f=n();k&&!h&&N&&f.length>0?i.value=!0:i.value=!1}function g(){i.value=!1,a.value=-1}return{showSuggestions:i,selectedSuggestionIndex:a,dropdownRef:l,handleSuggestionKeyDown:u,handleSuggestionClick:m,updateSuggestionsVisibility:p,hideSuggestions:g}}function Ns(n,t=300){function o(){const r=n();if(!r)return;r.style.height="auto";const s=Math.min(r.scrollHeight,t);r.style.height=`${s}px`,r.style.overflowY=r.scrollHeight>t?"auto":"hidden"}return e.onMounted(()=>{setTimeout(o,0)}),{adjustTextareaHeight:o}}const Bs=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]);function Ms(n,t,o=5){function r(i,a){if(!i)return a;const l=i.toLowerCase().trim().split(/\s+/).filter(c=>!Bs.has(c));return l.length===0?a:a.filter(c=>{const u=`${c.title} ${c.description||""}`.toLowerCase();return l.every(m=>u.includes(m))})}return{filteredSuggestions:e.computed(()=>{const i=n.value||[],a=t.value.toLowerCase().trim();return r(a,i).slice(0,o).map(l=>({id:l.id,title:l.title,description:l.description||""}))})}}function Rs(n){async function t(){await e.nextTick();const r=n.value;r&&(r.scrollTop=r.scrollHeight)}function o(r,s){e.watch(r,t),e.watch(s,t)}return{scrollToBottom:t,watchForScroll:o}}const Is=["stroke-width"],Et=e.defineComponent({inheritAttrs:!1,__name:"IconWarning",props:e.mergeModels({class:{},strokeWidth:{default:2}},{class:{default:"w-5 h-5"},classModifiers:{}}),emits:["update:class"],setup(n){const t=e.useModel(n,"class");return(o,r)=>(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(t.value),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":n.strokeWidth},[...r[0]||(r[0]=[e.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"},null,-1)])],10,Is))}}),_s={viewBox:"0 0 24 24",fill:"currentColor"},uo=e.defineComponent({inheritAttrs:!0,__name:"IconUser",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",_s,[...o[0]||(o[0]=[e.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)])]))}}),$s={viewBox:"0 0 24 24",fill:"currentColor"},Pe=e.defineComponent({inheritAttrs:!0,__name:"IconSparkles",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",$s,[...o[0]||(o[0]=[e.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 4.5a.75.75 0 0 1 .721.544l.813 2.846a3.75 3.75 0 0 0 2.576 2.576l2.846.813a.75.75 0 0 1 0 1.442l-2.846.813a3.75 3.75 0 0 0-2.576 2.576l-.813 2.846a.75.75 0 0 1-1.442 0l-.813-2.846a3.75 3.75 0 0 0-2.576-2.576l-2.846-.813a.75.75 0 0 1 0-1.442l2.846-.813A3.75 3.75 0 0 0 7.466 7.89l.813-2.846A.75.75 0 0 1 9 4.5ZM18 1.5a.75.75 0 0 1 .728.568l.258 1.036a2.63 2.63 0 0 0 1.91 1.91l1.036.258a.75.75 0 0 1 0 1.456l-1.036.258a2.63 2.63 0 0 0-1.91 1.91l-.258 1.036a.75.75 0 0 1-1.456 0l-.258-1.036a2.63 2.63 0 0 0-1.91-1.91l-1.036-.258a.75.75 0 0 1 0-1.456l1.036-.258a2.63 2.63 0 0 0 1.91-1.91l.258-1.036A.75.75 0 0 1 18 1.5ZM16.5 15a.75.75 0 0 1 .712.513l.394 1.183c.15.447.5.799.948.948l1.183.395a.75.75 0 0 1 0 1.422l-1.183.395a1.5 1.5 0 0 0-.948.948l-.395 1.183a.75.75 0 0 1-1.422 0l-.395-1.183a1.5 1.5 0 0 0-.948-.948l-1.183-.395a.75.75 0 0 1 0-1.422l1.183-.395a1.5 1.5 0 0 0 .948-.948l.395-1.183A.75.75 0 0 1 16.5 15Z"},null,-1)])]))}}),Ls={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},rn=e.defineComponent({inheritAttrs:!0,__name:"IconDocument",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Ls,[...o[0]||(o[0]=[e.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)])]))}}),Ds={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},zs=e.defineComponent({inheritAttrs:!0,__name:"IconPaperclip",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Ds,[...o[0]||(o[0]=[e.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"},null,-1)])]))}}),Hs=["stroke-width"],mo=e.defineComponent({inheritAttrs:!0,__name:"IconQuestionCircle",props:{strokeWidth:{default:1.5}},setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":n.strokeWidth},[...o[0]||(o[0]=[e.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"},null,-1)])],8,Hs))}}),Vs=["stroke-width"],sn=e.defineComponent({inheritAttrs:!0,__name:"IconClose",props:{strokeWidth:{default:1.5}},setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":n.strokeWidth},[...o[0]||(o[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"},null,-1)])],8,Vs))}}),Os={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ps=e.defineComponent({inheritAttrs:!0,__name:"IconSend",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Os,[...o[0]||(o[0]=[e.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)])]))}}),Fs={viewBox:"0 0 24 24",fill:"currentColor"},Us=e.defineComponent({inheritAttrs:!0,__name:"IconStop",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Fs,[...o[0]||(o[0]=[e.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)])]))}}),qs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},js=e.defineComponent({inheritAttrs:!0,__name:"IconCopy",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",qs,[...o[0]||(o[0]=[e.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)])]))}}),Ws={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ks=e.defineComponent({inheritAttrs:!0,__name:"IconCheck",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Ws,[...o[0]||(o[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])]))}}),Qs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},Gs=e.defineComponent({inheritAttrs:!0,__name:"IconChatBubble",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Qs,[...o[0]||(o[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"},null,-1)])]))}}),vs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},Ys=e.defineComponent({inheritAttrs:!0,__name:"IconMinimize",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",vs,[...o[0]||(o[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"},null,-1)])]))}}),Zs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},Xs=e.defineComponent({inheritAttrs:!0,__name:"IconFullscreen",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Zs,[...o[0]||(o[0]=[e.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)])]))}}),Js={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ei=e.defineComponent({inheritAttrs:!0,__name:"IconExitFullscreen",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",Js,[...o[0]||(o[0]=[e.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)])]))}}),ti={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ni=e.defineComponent({inheritAttrs:!0,__name:"IconClock",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",ti,[...o[0]||(o[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])]))}}),oi={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ri=e.defineComponent({inheritAttrs:!0,__name:"IconRefresh",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",oi,[...o[0]||(o[0]=[e.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"},null,-1)])]))}}),si={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ii=e.defineComponent({inheritAttrs:!0,__name:"IconSupport",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",si,[...o[0]||(o[0]=[e.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"},null,-1)])]))}}),St=(n,t)=>{const o=n.__vccOpts||n;for(const[r,s]of t)o[r]=s;return o},ai={},li={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function ci(n,t){return e.openBlock(),e.createElementBlock("svg",li,[...t[0]||(t[0]=[e.createElementVNode("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"},null,-1),e.createElementVNode("path",{d:"M3 3v5h5"},null,-1),e.createElementVNode("path",{d:"M12 7v5l4 2"},null,-1)])])}const di=St(ai,[["render",ci]]),ui={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},mi=e.defineComponent({inheritAttrs:!0,__name:"IconMicrophone",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",ui,[...o[0]||(o[0]=[e.createElementVNode("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"},null,-1),e.createElementVNode("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"},null,-1),e.createElementVNode("line",{x1:"12",x2:"12",y1:"19",y2:"22"},null,-1)])]))}}),hi={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},fi=e.defineComponent({inheritAttrs:!0,__name:"IconMicrophoneOff",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("svg",hi,[...o[0]||(o[0]=[e.createStaticVNode('<line x1="2" x2="22" y1="2" y2="22"></line><path d="M18.89 13.23A7.12 7.12 0 0 0 19 12v-2"></path><path d="M5 10v2a7 7 0 0 0 12 5"></path><path d="M15 9.34V5a3 3 0 0 0-5.68-1.33"></path><path d="M9 9v3a3 3 0 0 0 5.12 2.12"></path><line x1="12" x2="12" y1="19" y2="22"></line>',6)])]))}}),ho=e.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(n){return(t,o)=>{var r;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 min-w-[32px] flex items-center justify-center rounded-full border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800",(r=n.ui)==null?void 0:r.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[e.createVNode(e.unref(Pe),{class:e.normalizeClass(["w-4 h-4 text-gray-500 dark:text-gray-400",(s=n.ui)==null?void 0:s.icon])},null,8,["class"])]})],2)}}}),pi=e.defineComponent({__name:"UserAvatar",props:{ui:{}},setup(n){return(t,o)=>{var r;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(r=n.ui)==null?void 0:r.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[e.createVNode(e.unref(uo),{class:e.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=n.ui)==null?void 0:s.icon])},null,8,["class"])]})],2)}}}),gi=["onClick","onMouseenter"],fo=e.defineComponent({__name:"MentionList",props:{items:{},selectedIndex:{default:0},providers:{default:()=>[]},ui:{},texts:{}},emits:["select","update:selectedIndex"],setup(n,{emit:t}){const o=n,r=e.computed(()=>o.ui||{}),s=t,i=e.ref(o.selectedIndex);e.watch(()=>o.selectedIndex,f=>{i.value=f}),e.watch(i,f=>{s("update:selectedIndex",f)});const a=e.computed(()=>{const f={};return o.items.forEach(y=>{const b=y.type||"default";f[b]||(f[b]=[]),f[b].push(y)}),f});function l(f){return o.providers.find(y=>y.type===f)||Mn(f)}function c(f){const y=l(f);return(y==null?void 0:y.label)||f.charAt(0).toUpperCase()+f.slice(1)+"s"}function u(f,y){let b=0;const x=Object.keys(a.value);for(const C of x){if(C===f)return b+y;b+=a.value[C].length}return b}function m(f){s("select",f)}function p(f){i.value=f,s("update:selectedIndex",f)}function g(f){const y=l(f.type);return Vt(f,y)}function k(f){const y=l(f.type);return Bn(f,y)}function h(f){const y={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 y[f]||y.default}function N(f){return f.split(" ").map(y=>y[0]).join("").slice(0,2).toUpperCase()}return(f,y)=>n.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.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])},[e.createElementVNode("div",{class:e.normalizeClass(["p-2",r.value.container])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(b,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:x},[Object.keys(a.value).length>1?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",r.value.groupHeader])},e.toDisplayString(c(x)),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(C,S)=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.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(x,S)===i.value,"hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer":u(x,S)!==i.value}]]),onClick:E=>m(C),onMouseenter:E=>p(u(x,S))},[e.renderSlot(f.$slots,"item-icon",{item:C,type:x},()=>[e.createElementVNode("span",{class:e.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[r.value.itemIcon,h(C.type)]])},e.toDisplayString(N(g(C))),3)]),e.createElementVNode("div",{class:e.normalizeClass(["flex-1 min-w-0",r.value.itemContent])},[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",r.value.itemName])},e.toDisplayString(g(C)),3),k(C)?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",r.value.itemSubtitle])},e.toDisplayString(k(C)),3)):e.createCommentVNode("",!0)],2)],42,gi))),128))],64))),128))],2)],2)):e.createCommentVNode("",!0)}}),yi=["title"],po=e.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(n,{emit:t}){const o=n,r=t,s=c=>{var m;return(m=o.texts)!=null&&m[c]?o.texts[c]:j({copyToClipboard:"copyToClipboard",copied:"copied"}[c])},i=e.computed(()=>o.ui||{}),a=e.ref(!1);async function l(){try{await navigator.clipboard.writeText(o.message.message),a.value=!0,r("copy",o.message),setTimeout(()=>{a.value=!1},2e3)}catch(c){console.error("Failed to copy:",c)}}return(c,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",i.value.container])},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",[i.value.button,i.value.copyButton]]),title:a.value?s("copied"):s("copyToClipboard"),onClick:l},[a.value?(e.openBlock(),e.createBlock(e.unref(Ks),{key:1,class:e.normalizeClass(["w-4 h-4 text-green-500",i.value.successState])},null,8,["class"])):(e.openBlock(),e.createBlock(e.unref(js),{key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400"}))],10,yi)],2))}}),ki={class:"text-gray-600 dark:text-gray-400"},xi=e.defineComponent({__name:"LoadingIndicator",props:{text:{},ui:{}},setup(n){return(t,o)=>{var r,s;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",(r=n.ui)==null?void 0:r.loadingIndicator])},[e.createElementVNode("div",{class:e.normalizeClass(["flex space-x-1",(s=n.ui)==null?void 0:s.loadingDots])},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(3,i=>e.createElementVNode("div",{key:i,class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:e.normalizeStyle({animationDelay:`${(i-1)*150}ms`})},null,4)),64))],2),e.createElementVNode("span",ki,e.toDisplayString(n.text),1)],2)}}}),wi={class:"h-10 w-10 shrink-0 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},bi=["src"],Ci={class:"flex-1 min-w-0"},Ei={class:"text-sm font-semibold text-white truncate"},Si={class:"text-xs text-white/70"},Ti={key:0,class:"text-xs font-medium text-white/90"},Ai=["src"],Ni={class:"flex-shrink-0 group-hover:opacity-0 transition-opacity"},Bi=["id","innerHTML"],Mi={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"},Ri=["src"],Ii={class:"flex-1 min-w-0"},_i={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},$i={class:"text-xs text-gray-500 dark:text-gray-400"},Li={key:0,class:"text-xs font-medium text-primary"},go=St(e.defineComponent({__name:"ChatMessage",props:{message:{},showActions:{type:Boolean,default:!0},loadingText:{default:"Gathering data..."},ui:{},texts:{}},emits:["copy"],setup(n,{emit:t}){const o=n,r=t,s=h=>{var f;return(f=o.texts)!=null&&f[h]?o.texts[h]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[h]||h},{parseMarkdown:i}=io(),a=e.ref(!1),l=e.computed(()=>o.message.attachments??[]),c=e.computed(()=>l.value.length>0),u=e.computed(()=>{if(o.message.role!=="user")return!1;const h=o.message.message||"",N=h.split(`
59
+ `).length;return h.length>200||N>4});function m(){a.value=!a.value}const p=e.computed(()=>{const h=K();return h!=null&&h.userAvatar?typeof h.userAvatar=="string"?h.userAvatar:typeof h.userAvatar=="function"?h.userAvatar():null:null}),g=e.computed(()=>{if(o.message.role==="assistant"){let h=o.message.message;return h=h.replace(/\\n/g,`
60
+ `),i(h)}return o.message.message});function k(h){r("copy",h)}return(h,N)=>{var f,y,b,x,C,S,E,R,D,B,_,V,X,le,T;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[(f=n.ui)==null?void 0:f.root,{"flex justify-end":n.message.role==="user","flex justify-start":n.message.role==="assistant"}]])},[n.message.role==="user"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex gap-3 justify-end",(y=n.ui)==null?void 0:y.userMessage])},[e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl px-4 py-3 bg-primary-500 text-white max-w-[75%]",(b=n.ui)==null?void 0:b.userBubble])},[n.message.message?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-sm whitespace-pre-wrap",[(x=n.ui)==null?void 0:x.content,{"line-clamp-4":!a.value&&u.value}]])},e.toDisplayString(n.message.message),3)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",(C=n.ui)==null?void 0:C.showMoreButton]),onClick:m},e.toDisplayString(a.value?s("showLess"):s("showMore")),3)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-3 space-y-2",(S=n.ui)==null?void 0:S.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,I=>{var Q;return e.openBlock(),e.createBlock(e.resolveDynamicComponent(I.url?"a":"div"),{key:I.id,href:I.url||void 0,target:I.url?"_blank":void 0,rel:"noopener noreferrer",class:e.normalizeClass(["flex items-center gap-2 rounded-xl border border-white/20 bg-white/10 p-2 transition overflow-hidden",[(Q=n.ui)==null?void 0:Q.attachmentItem,I.url?"hover:bg-white/20 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",wi,[I.url&&e.unref(ut)(I)?(e.openBlock(),e.createElementBlock("img",{key:0,src:I.url,class:"object-cover h-full w-full",alt:""},null,8,bi)):(e.openBlock(),e.createBlock(e.unref(rn),{key:1,class:"w-5 h-5 text-white"}))]),e.createElementVNode("div",Ci,[e.createElementVNode("p",Ei,e.toDisplayString(I.name||s("attachment")),1),e.createElementVNode("p",Si,e.toDisplayString(e.unref(mt)(I.size)),1)]),I.url?(e.openBlock(),e.createElementBlock("span",Ti,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"])}),128))],2)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",{class:e.normalizeClass(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary-500 overflow-hidden",(E=n.ui)==null?void 0:E.userAvatar])},[p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:p.value,alt:"User",class:"h-full w-full object-cover"},null,8,Ai)):(e.openBlock(),e.createBlock(e.unref(uo),{key:1,class:"h-4 w-4 text-white"}))],2)],2)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-start gap-3",(R=n.ui)==null?void 0:R.assistantMessage])},[e.createElementVNode("div",Ni,[e.createVNode(ho)]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-4 py-3 shadow-sm rounded-2xl transition-all duration-200 max-w-[85%]",(D=n.ui)==null?void 0:D.assistantBubble])},[n.message.loading?(e.openBlock(),e.createBlock(xi,{key:0,text:((B=n.texts)==null?void 0:B.loadingText)||n.loadingText,ui:{loadingIndicator:(_=n.ui)==null?void 0:_.loadingIndicator,loadingDots:(V=n.ui)==null?void 0:V.loadingDots}},null,8,["text","ui"])):n.message.message?(e.openBlock(),e.createElementBlock("div",{key:1,id:n.message.id,class:e.normalizeClass(["text-sm text-gray-700 dark:text-gray-200 leading-relaxed",(X=n.ui)==null?void 0:X.content]),innerHTML:g.value},null,10,Bi)):e.createCommentVNode("",!0),!n.message.loading&&c.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-4 space-y-2",(le=n.ui)==null?void 0:le.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,I=>{var Q;return e.openBlock(),e.createBlock(e.resolveDynamicComponent(I.url?"a":"div"),{key:I.id,href:I.url||void 0,target:I.url?"_blank":void 0,rel:"noopener noreferrer",class:e.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",[(Q=n.ui)==null?void 0:Q.attachmentItem,I.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",Mi,[I.url&&e.unref(ut)(I)?(e.openBlock(),e.createElementBlock("img",{key:0,src:I.url,class:"object-cover h-full w-full",alt:""},null,8,Ri)):(e.openBlock(),e.createBlock(e.unref(rn),{key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400"}))]),e.createElementVNode("div",Ii,[e.createElementVNode("p",_i,e.toDisplayString(I.name||s("attachment")),1),e.createElementVNode("p",$i,e.toDisplayString(e.unref(mt)(I.size)),1)]),I.url?(e.openBlock(),e.createElementBlock("span",Li,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"])}),128))],2)):e.createCommentVNode("",!0)],2)],2)),n.message.role==="assistant"&&!n.message.loading&&!n.message.streaming&&n.showActions?(e.openBlock(),e.createBlock(po,{key:2,message:n.message,class:e.normalizeClass(["absolute top-0 left-0",(T=n.ui)==null?void 0:T.actionsContainer]),onCopy:k},null,8,["message","class"])):e.createCommentVNode("",!0)],2)}}}),[["__scopeId","data-v-8b3f46c0"]]),Di={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},zi={class:"space-y-2"},Hi=["src"],Vi={class:"flex-1 min-w-0"},Oi={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},Pi={class:"text-xs text-gray-500 dark:text-gray-400"},Fi={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Ui={key:0,class:"text-xs text-gray-400"},qi=["disabled","onClick"],ji=e.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(n){return(t,o)=>{var r;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",n.ui.attachmentsContainer])},[e.createElementVNode("p",Di,e.toDisplayString(((r=n.texts)==null?void 0:r.attachedFiles)||"Attached files"),1),e.createElementVNode("ul",zi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.attachments,s=>(e.openBlock(),e.createElementBlock("li",{key:s.id,class:e.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",n.ui.attachmentItem])},[e.createElementVNode("div",{class:e.normalizeClass(["h-10 w-10 flex items-center justify-center rounded-lg bg-gray-100 dark:bg-gray-600 overflow-hidden",n.ui.attachmentThumbnail])},[n.isImage(s)?(e.openBlock(),e.createElementBlock("img",{key:0,src:s.previewUrl||s.url,class:"object-cover h-full w-full",alt:""},null,8,Hi)):(e.openBlock(),e.createBlock(e.unref(rn),{key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400"}))],2),e.createElementVNode("div",Vi,[e.createElementVNode("p",Oi,e.toDisplayString(s.name),1),e.createElementVNode("p",Pi,e.toDisplayString(n.formatFileSize(s.size)),1),s.uploading?(e.openBlock(),e.createElementBlock("div",Fi,[e.createElementVNode("div",{class:"h-full bg-primary transition-all",style:e.normalizeStyle({width:`${s.progress??10}%`})},null,4)])):e.createCommentVNode("",!0)]),s.uploading?(e.openBlock(),e.createElementBlock("span",Ui,e.toDisplayString(Math.round(s.progress??0))+"% ",1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",n.ui.attachmentRemove]),disabled:s.uploading,onClick:i=>t.$emit("remove",s.id)},[e.createVNode(e.unref(sn),{class:"w-4 h-4 text-gray-500 dark:text-gray-400"})],10,qi)],2))),128))])],2)}}}),Wi={class:"py-1"},Ki=["onClick","onMouseenter"],Qi={class:"flex items-start gap-3"},Gi={class:"flex-1 min-w-0"},vi={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},Yi={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Zi=e.defineComponent({__name:"SuggestionsDropdown",props:{suggestions:{},selectedIndex:{},ui:{}},emits:["select","hover"],setup(n,{expose:t}){const o=e.ref(null);return t({dropdownRef:o}),(r,s)=>(e.openBlock(),e.createBlock(e.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:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"dropdownRef",ref:o,class:e.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",n.ui.suggestionsDropdown])},[e.createElementVNode("ul",Wi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.suggestions,(i,a)=>(e.openBlock(),e.createElementBlock("li",{key:i.id,class:e.normalizeClass(["px-4 py-3 cursor-pointer transition-colors border-b border-gray-100 dark:border-gray-700 last:border-b-0",[n.ui.suggestionItem,{[n.ui.suggestionItemSelected||"bg-primary/10"]:a===n.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":a!==n.selectedIndex}]]),onClick:l=>r.$emit("select",i),onMouseenter:l=>r.$emit("hover",a)},[e.createElementVNode("div",Qi,[e.createElementVNode("div",Gi,[e.createElementVNode("p",vi,e.toDisplayString(i.title),1),e.createElementVNode("p",Yi,e.toDisplayString(i.description),1)])])],42,Ki))),128))])],2)]),_:1}))}}),Xi={class:"rai-audio-wave"},Ji=e.defineComponent({__name:"AudioWave",props:{barCount:{default:5}},setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("div",Xi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.barCount,r=>(e.openBlock(),e.createElementBlock("span",{key:r,class:"rai-audio-wave-bar",style:e.normalizeStyle({animationDelay:`${(r-1)*.1}s`})},null,4))),128))]))}}),ea={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},ta=["title"],na=["title"],oa=["title"],ra=["disabled"],sa=e.defineComponent({__name:"InputActions",props:{sending:{type:Boolean},canSend:{type:Boolean},supportRequestMode:{type:Boolean},showSupportModeToggle:{type:Boolean},enableAudioInput:{type:Boolean,default:!1},isRecording:{type:Boolean,default:!1},ui:{},texts:{}},emits:["toggle-support-mode","toggle-audio-recording","click"],setup(n){const t=n,o=e.computed(()=>t.sending?[t.ui.stopButton||"bg-red-500 text-white hover:bg-red-600"]:t.canSend?[t.ui.sendButtonActive||"bg-primary-500 text-white hover:bg-primary-600"]:[t.ui.sendButtonDisabled||"bg-gray-200 dark:bg-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed opacity-60"]),r=e.computed(()=>t.isRecording?[t.ui.audioButtonRecording||"text-red-500 hover:text-red-600 bg-red-100 dark:bg-red-900/30 hover:bg-red-200 dark:hover:bg-red-900/50"]:[t.ui.audioButton||"text-gray-400 hover:text-primary hover:bg-gray-100 dark:hover:bg-gray-700"]);return(s,i)=>{var a,l,c,u,m;return e.openBlock(),e.createElementBlock("div",ea,[n.enableAudioInput&&!n.sending?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center transition flex-shrink-0",r.value]),title:n.isRecording?((a=n.texts)==null?void 0:a.stopRecording)||"Stop recording":((l=n.texts)==null?void 0:l.startRecording)||"Start recording",onClick:i[0]||(i[0]=p=>s.$emit("toggle-audio-recording"))},[n.isRecording?(e.openBlock(),e.createBlock(e.unref(fi),{key:0,class:"w-5 h-5"})):(e.openBlock(),e.createBlock(e.unref(mi),{key:1,class:"w-5 h-5"}))],10,ta)):e.createCommentVNode("",!0),n.isRecording?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-center gap-1 px-2 py-1 rounded-lg bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400",n.ui.audioRecordingIndicator])},[e.createVNode(Ji)],2)):e.createCommentVNode("",!0),n.showSupportModeToggle&&!n.supportRequestMode&&!n.isRecording?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:e.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",n.ui.supportToggle]),title:((c=n.texts)==null?void 0:c.toggleSupportMode)||"Toggle support mode",onClick:i[1]||(i[1]=p=>s.$emit("toggle-support-mode"))},[e.createVNode(e.unref(mo),{class:"w-5 h-5"})],10,na)):e.createCommentVNode("",!0),n.showSupportModeToggle&&n.supportRequestMode&&!n.isRecording?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:e.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",n.ui.supportBadge]),title:((u=n.texts)==null?void 0:u.exitSupportMode)||"Exit support mode",onClick:i[2]||(i[2]=p=>s.$emit("toggle-support-mode"))},[e.createVNode(e.unref(mo),{class:"w-3.5 h-3.5","stroke-width":2}),e.createElementVNode("span",null,e.toDisplayString(((m=n.texts)==null?void 0:m.supportLabel)||"Support"),1),e.createVNode(e.unref(sn),{class:"w-3 h-3","stroke-width":2})],10,oa)):e.createCommentVNode("",!0),n.isRecording?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:4,disabled:!n.canSend&&!n.sending,class:e.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center transition-all duration-200 flex-shrink-0",o.value]),type:"button",onClick:i[3]||(i[3]=e.withModifiers(p=>s.$emit("click"),["prevent"]))},[n.sending?(e.openBlock(),e.createBlock(e.unref(Us),{key:1,class:"w-4 h-4"})):(e.openBlock(),e.createBlock(e.unref(Ps),{key:0,class:"w-4 h-4"}))],10,ra))])}}}),ia={class:"max-w-3xl mx-auto space-y-3"},aa=["accept"],la=["title"],ca={class:"flex items-center"},da=["placeholder","disabled"],ua={key:0,class:"flex justify-center"},yo=e.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},enableAudioInput:{type:Boolean,default:!1},isRecording:{type:Boolean,default:!1},contextLinkText:{default:""},ui:{},texts:{}},emits:["update:modelValue","submit","cancel","suggestion-select","toggle-support-mode","toggle-audio-recording","context-link-click"],setup(n,{expose:t,emit:o}){const r=n,s=o,i=e.ref(r.modelValue),a=e.ref(null),l=e.ref(null),c=e.ref(!1),u=Ss(),m=Ts(()=>i.value,B=>{i.value=B},()=>a.value),p=As(()=>r.suggestions,()=>r.hasHistory,()=>c.value,()=>i.value,B=>{s("suggestion-select",B),e.nextTick(()=>{var _;return(_=a.value)==null?void 0:_.focus()})}),{adjustTextareaHeight:g}=Ns(()=>a.value),k=e.computed(()=>r.supportRequestMode?r.supportPlaceholder:r.placeholder),h=e.computed(()=>r.showSupportModeToggle?r.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),N=e.computed(()=>{var _;return(((_=i.value)==null?void 0:_.trim())??"").length>=r.minLength||u.hasAttachments.value}),f=e.computed(()=>!r.disabled&&!r.sending&&N.value&&!u.isUploading.value);e.watch(()=>r.modelValue,B=>{i.value=B,e.nextTick(g)}),e.watch(i,B=>{s("update:modelValue",B),e.nextTick(g),m.checkForMentions(B),p.updateSuggestionsVisibility()}),e.watch(()=>r.suggestions,()=>{p.updateSuggestionsVisibility()});function y(){g()}function b(B){if(!m.handleMentionKeyDown(B)&&!p.handleSuggestionKeyDown(B)&&B.key==="Enter"){if(B.shiftKey)return;!r.sending&&f.value&&(B.preventDefault(),x())}}function x(){if(!f.value)return;const B=u.buildPayload(),_=i.value.trim(),V=m.getMentions();s("submit",{message:_,attachments:B,mentions:V,isSupportRequest:r.supportRequestMode}),i.value="",u.clearAttachments(),m.clearMentions(),e.nextTick(g)}function C(){r.sending?s("cancel"):f.value&&x()}function S(){var B;r.disabled||r.sending||u.canAddMore.value&&((B=l.value)==null||B.click())}function E(B){p.handleSuggestionClick(B)}function R(){c.value=!0,p.updateSuggestionsVisibility()}function D(){c.value=!1,setTimeout(()=>{p.hideSuggestions(),m.showMentions.value=!1},200)}return t({focus:()=>{var B;return(B=a.value)==null?void 0:B.focus()}}),e.onMounted(()=>{e.nextTick(g)}),(B,_)=>{var V,X,le,T,I,Q,J;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",(V=n.ui)==null?void 0:V.root]),onDragenter:_[7]||(_[7]=e.withModifiers((...P)=>e.unref(u).handleDragEnter&&e.unref(u).handleDragEnter(...P),["prevent"])),onDragover:_[8]||(_[8]=e.withModifiers((...P)=>e.unref(u).handleDragOver&&e.unref(u).handleDragOver(...P),["prevent"])),onDragleave:_[9]||(_[9]=e.withModifiers((...P)=>e.unref(u).handleDragLeave&&e.unref(u).handleDragLeave(...P),["prevent"])),onDrop:_[10]||(_[10]=e.withModifiers((...P)=>e.unref(u).handleDrop&&e.unref(u).handleDrop(...P),["prevent"]))},[e.createElementVNode("form",{class:e.normalizeClass((X=n.ui)==null?void 0:X.form),onSubmit:e.withModifiers(x,["prevent"])},[e.createElementVNode("div",ia,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:e.unref(u).acceptedFileTypes,onChange:_[0]||(_[0]=(...P)=>e.unref(u).handleFileSelect&&e.unref(u).handleFileSelect(...P))},null,40,aa),e.unref(u).hasAttachments.value?(e.openBlock(),e.createBlock(ji,{key:0,attachments:e.unref(u).attachments.value,ui:n.ui||{},texts:n.texts,"is-image":e.unref(u).isImage,"format-file-size":e.unref(u).formatFileSize,onRemove:e.unref(u).removeAttachment},null,8,["attachments","ui","texts","is-image","format-file-size","onRemove"])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["relative",(le=n.ui)==null?void 0:le.inputContainer])},[e.unref(p).showSuggestions.value&&n.suggestions.length>0?(e.openBlock(),e.createBlock(Zi,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:n.suggestions,"selected-index":e.unref(p).selectedSuggestionIndex.value,ui:n.ui||{},onSelect:E,onHover:_[1]||(_[1]=P=>e.unref(p).selectedSuggestionIndex.value=P)},null,8,["suggestions","selected-index","ui"])):e.createCommentVNode("",!0),e.createVNode(e.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:e.withCtx(()=>[e.unref(m).showMentions.value&&e.unref(m).mentionItems.value.length>0?(e.openBlock(),e.createBlock(fo,{key:0,items:e.unref(m).mentionItems.value,"selected-index":e.unref(m).selectedMentionIndex.value,providers:e.unref(m).mentionProviders.value,onSelect:e.unref(m).handleMentionSelect,"onUpdate:selectedIndex":_[2]||(_[2]=P=>e.unref(m).selectedMentionIndex.value=P)},null,8,["items","selected-index","providers","onSelect"])):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl border shadow-lg transition-all duration-200 bg-white dark:bg-gray-800",[(T=n.ui)==null?void 0:T.inputWrapper,{"border-primary dark:border-primary-400 shadow-primary/30 dark:shadow-primary-400/20":c.value||e.unref(u).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!c.value&&!e.unref(u).isDraggingFiles.value}]])},[e.createElementVNode("button",{type:"button",class:e.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",(I=n.ui)==null?void 0:I.attachButton]),title:((Q=n.texts)==null?void 0:Q.attachFiles)||"Attach files",onClick:S},[e.createVNode(e.unref(zs),{class:"w-5 h-5"})],10,la),e.createElementVNode("div",ca,[e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:a,"onUpdate:modelValue":_[3]||(_[3]=P=>i.value=P),rows:"1","data-ai-input":"",placeholder:k.value,disabled:n.disabled,class:e.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",(J=n.ui)==null?void 0:J.textarea]),style:e.normalizeStyle(h.value),onInput:y,onKeydown:b,onFocus:R,onBlur:D},null,46,da),[[e.vModelText,i.value]])]),e.createVNode(sa,{sending:n.sending,"can-send":f.value,"support-request-mode":n.supportRequestMode,"show-support-mode-toggle":n.showSupportModeToggle,"enable-audio-input":n.enableAudioInput,"is-recording":n.isRecording,ui:n.ui||{},texts:n.texts,onToggleSupportMode:_[4]||(_[4]=P=>B.$emit("toggle-support-mode")),onToggleAudioRecording:_[5]||(_[5]=P=>B.$emit("toggle-audio-recording")),onClick:C},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","enable-audio-input","is-recording","ui","texts"])],2)],2),e.renderSlot(B.$slots,"context-link",{},()=>{var P;return[n.contextLinkText?(e.openBlock(),e.createElementBlock("div",ua,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",(P=n.ui)==null?void 0:P.contextLink]),onClick:_[6]||(_[6]=Le=>B.$emit("context-link-click"))},e.toDisplayString(n.contextLinkText),3)])):e.createCommentVNode("",!0)]})])],34)],34)}}}),ma=["onClick"],ko=e.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(n,{emit:t}){const o=n,r=t,s=g=>{var h;return(h=o.texts)!=null&&h[g]?o.texts[g]:j({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[g])},i=e.computed(()=>o.ui||{}),{suggestions:a,resolvePrompt:l}=on();function c(g){const k={...g,prompt:l(g)};r("item-click",k)}function u(g){return g.gradientClass?g.gradientClass:g.className?g.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function m(g){const k=g.category||"default",h={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 h[k]||h.default}function p(g){const k=g.category||"default",h={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 h[k]||h.default}return(g,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-center p-4 h-full",i.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["w-full max-w-4xl",i.value.content])},[e.createElementVNode("div",{class:e.normalizeClass(["mb-8 text-center",i.value.header])},[e.createElementVNode("div",{class:e.normalizeClass(["mb-3 inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary",i.value.badge])},[e.createVNode(e.unref(Pe),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(s("aiName")),1)],2),e.createElementVNode("h1",{class:e.normalizeClass(["mb-3 text-4xl font-bold tracking-tight text-gray-900 dark:text-white",i.value.title])},e.toDisplayString(s("title")),3),e.createElementVNode("p",{class:e.normalizeClass(["text-gray-600 dark:text-gray-400",i.value.description])},e.toDisplayString(s("description")),3)],2),e.createElementVNode("div",{class:e.normalizeClass(["mb-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",i.value.grid])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),(h,N)=>(e.openBlock(),e.createElementBlock("button",{key:h.id||N,class:e.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]",[i.value.suggestionCard,u(h)]]),onClick:f=>c(h)},[e.createElementVNode("div",{class:e.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[i.value.suggestionIconContainer,m(h)]])},[h.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h.icon),{key:0,class:e.normalizeClass(["h-5 w-5",[i.value.suggestionIcon,p(h)]])},null,8,["class"])):(e.openBlock(),e.createBlock(e.unref(Pe),{key:1,class:e.normalizeClass(["h-5 w-5",[i.value.suggestionIcon,p(h)]])},null,8,["class"]))],2),e.createElementVNode("h3",{class:e.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",i.value.suggestionTitle])},e.toDisplayString(h.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",i.value.suggestionDescription])},e.toDisplayString(h.description),3)],10,ma))),128))],2)],2)],2))}}),ha={class:"flex items-center gap-3"},fa={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},pa={key:1,class:"flex items-center gap-2"},ga={key:0,class:"flex items-center gap-2 ml-auto mr-4"},ya={key:1,class:"text-gray-300 dark:text-gray-600"},ka={class:"text-green-600 dark:text-green-400 font-medium tabular-nums"},xa={class:"text-gray-500 dark:text-gray-400"},wa={key:1,class:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-red-50 dark:bg-red-900/20"},ba={class:"text-xs text-red-600 dark:text-red-400 font-medium"},Ca=["title"],Ea=["title"],Sa=["title"],Ta=["title"],Aa=e.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},showMessageCount:{type:Boolean},showHistoryButton:{type:Boolean},hasConversationHistory:{type:Boolean},messageCount:{},messageLimit:{},t:{type:Function}},emits:["new-chat","close","minimize","toggle-fullscreen","toggle-history"],setup(n){const t=n;function o(){const l=t.messageCount/t.messageLimit;return l>=1?"danger":l>=.8?"warning":"default"}const r={icon:{danger:"text-red-500 dark:text-red-400",warning:"text-amber-500 dark:text-amber-400",default:"text-gray-400 dark:text-gray-500"},text:{danger:"text-red-600 dark:text-red-400",warning:"text-amber-600 dark:text-amber-400",default:"text-gray-600 dark:text-gray-300"}},s=e.computed(()=>r.text[o()]),i=e.computed(()=>r.icon[o()]),a=e.computed(()=>t.showMessageCount&&t.hasHistory&&t.showQuota&&t.quota.remaining>=0);return(l,c)=>{var u,m,p,g,k,h,N,f;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-between px-4 sm:px-6 pt-4 border-b border-gray-200 dark:border-gray-700 pb-4",(u=n.ui)==null?void 0:u.header])},[e.createElementVNode("div",ha,[n.isSetupMode?(e.openBlock(),e.createElementBlock("div",pa,[...c[5]||(c[5]=[e.createElementVNode("span",{class:"flex h-2 w-2 rounded-full bg-amber-500 animate-pulse"},null,-1),e.createElementVNode("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Setup Required",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n.showNewChatButton&&n.hasHistory?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.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",(m=n.ui)==null?void 0:m.newChatButton]),onClick:c[0]||(c[0]=y=>l.$emit("new-chat"))},[e.createVNode(e.unref(Pe),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(n.t("newChat")),1)],2)):(e.openBlock(),e.createElementBlock("span",fa,e.toDisplayString(n.t("keyboardShortcutHint")),1))],64))]),!n.isSetupMode&&(n.showMessageCount||n.showQuota)?(e.openBlock(),e.createElementBlock("div",ga,[n.showMessageCount&&n.hasHistory?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 px-2 py-1 rounded-md bg-gray-100 dark:bg-gray-800",(p=n.ui)==null?void 0:p.messageCountBadge])},[e.createVNode(e.unref(Gs),{class:e.normalizeClass(["w-3.5 h-3.5",i.value])},null,8,["class"]),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium tabular-nums",s.value])},[e.renderSlot(l.$slots,"message-count",{},()=>[e.createTextVNode(e.toDisplayString(n.messageCount),1),c[6]||(c[6]=e.createElementVNode("span",{class:"text-gray-400 dark:text-gray-500"},"/",-1)),e.createTextVNode(e.toDisplayString(n.messageLimit),1)])],2)],2)):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createElementBlock("span",ya," • ")):e.createCommentVNode("",!0),n.showQuota?e.renderSlot(l.$slots,"quota",{key:2},()=>{var y;return[n.quota.remaining>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 text-xs",(y=n.ui)==null?void 0:y.quotaDisplay])},[e.createElementVNode("span",ka,e.toDisplayString(n.quota.remaining),1),e.createElementVNode("span",xa,e.toDisplayString(n.t("quotaRemaining")),1)],2)):n.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",wa,[e.createVNode(e.unref(Et),{class:"w-3.5 h-3.5 text-red-500"}),e.createElementVNode("span",ba,e.toDisplayString(n.t("noQuota")),1)])):e.createCommentVNode("",!0)]}):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1",(g=n.ui)==null?void 0:g.headerActions])},[n.showHistoryButton&&n.hasConversationHistory?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(k=n.ui)==null?void 0:k.headerActionButton]),title:n.t("conversationHistory")||"Chat History",onClick:c[1]||(c[1]=y=>l.$emit("toggle-history"))},[e.createVNode(e.unref(di),{class:"w-5 h-5 text-gray-600 dark:text-gray-400"})],10,Ca)):e.createCommentVNode("",!0),n.showCloseButton?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(h=n.ui)==null?void 0:h.headerActionButton]),title:n.t("close"),onClick:c[2]||(c[2]=y=>l.$emit("close"))},[e.createVNode(e.unref(sn),{class:"w-5 h-5 text-gray-600 dark:text-gray-400"})],10,Ea)):e.createCommentVNode("",!0),n.showMinimizeButton?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(N=n.ui)==null?void 0:N.headerActionButton]),title:n.t("minimize"),onClick:c[3]||(c[3]=y=>l.$emit("minimize"))},[e.createVNode(e.unref(Ys),{class:"w-5 h-5 text-gray-600 dark:text-gray-400"})],10,Sa)):e.createCommentVNode("",!0),n.showFullscreenToggle?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(f=n.ui)==null?void 0:f.headerActionButton]),title:n.isFullscreen?n.t("exitFullscreen"):n.t("fullscreen"),onClick:c[4]||(c[4]=y=>l.$emit("toggle-fullscreen"))},[n.isFullscreen?(e.openBlock(),e.createBlock(e.unref(ei),{key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(Xs),{key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400"}))],10,Ta)):e.createCommentVNode("",!0)],2)],2)}}}),Na={class:"max-w-3xl mx-auto px-4 space-y-6"},Ba={class:"flex justify-center"},Ma={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},Ra={key:0,class:"flex justify-center"},Ia={class:"flex items-start gap-3"},_a={class:"flex-1 min-w-0"},$a={key:0,class:"text-xs text-amber-600 dark:text-amber-400 mt-1"},La=["title"],Da=e.defineComponent({__name:"DrawerMessageList",props:{messages:{},loadingMessage:{},quota:{},error:{},ui:{},t:{type:Function}},emits:["copy","contact-support","retry"],setup(n){return(t,o)=>{var r,s,i;return e.openBlock(),e.createElementBlock("div",Na,[e.createElementVNode("div",Ba,[e.createElementVNode("div",Ma,[e.createVNode(e.unref(Pe),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(n.t("title")||e.unref(j)("aiName")),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.messages,(a,l)=>e.renderSlot(t.$slots,"message",{key:a.id||l,message:a,isUser:a.role==="user",isLoading:a.loading,isStreaming:a.streaming},()=>[e.createVNode(go,{message:a,"loading-text":n.loadingMessage,ui:n.ui,onCopy:o[0]||(o[0]=c=>t.$emit("copy",c))},null,8,["message","loading-text","ui"])])),128)),n.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",Ra,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 px-6 py-3 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all shadow-sm",onClick:o[1]||(o[1]=a=>t.$emit("contact-support"))},[e.createVNode(e.unref(ii),{class:"w-5 h-5"}),e.createElementVNode("span",null,e.toDisplayString(e.unref(j)("contactSupport")),1)])])):e.createCommentVNode("",!0),n.error.message?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["rounded-lg p-4 mb-4",[(r=n.ui)==null?void 0:r.errorContainer,n.error.rateLimited?"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800":"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800"]])},[e.createElementVNode("div",Ia,[e.createElementVNode("div",{class:e.normalizeClass(["flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center",n.error.rateLimited?"bg-amber-100 dark:bg-amber-900/40":"bg-red-100 dark:bg-red-900/40"])},[n.error.rateLimited?(e.openBlock(),e.createBlock(e.unref(ni),{key:0,class:"w-4 h-4 text-amber-600 dark:text-amber-400"})):(e.openBlock(),e.createBlock(e.unref(Et),{key:1,class:"w-4 h-4 text-red-600 dark:text-red-400"}))],2),e.createElementVNode("div",_a,[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium",[(s=n.ui)==null?void 0:s.errorMessage,n.error.rateLimited?"text-amber-800 dark:text-amber-200":"text-red-800 dark:text-red-200"]])},e.toDisplayString(n.error.message),3),n.error.rateLimited?(e.openBlock(),e.createElementBlock("p",$a,e.toDisplayString(n.t("retryHint")||"Please wait a moment before trying again."),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-shrink-0 inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-md transition-colors",[(i=n.ui)==null?void 0:i.retryButton,n.error.rateLimited?"text-amber-700 dark:text-amber-300 bg-amber-100 dark:bg-amber-900/40 hover:bg-amber-200 dark:hover:bg-amber-900/60":"text-red-700 dark:text-red-300 bg-red-100 dark:bg-red-900/40 hover:bg-red-200 dark:hover:bg-red-900/60"]]),title:n.t("retry"),onClick:o[2]||(o[2]=a=>t.$emit("retry"))},[e.createVNode(e.unref(ri),{class:"w-4 h-4"}),e.createTextVNode(" "+e.toDisplayString(n.t("retry")),1)],10,La)])],2)):e.createCommentVNode("",!0)])}}}),za={class:"w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"},Ha={class:"w-full max-w-md"},Va={class:"bg-gray-900 rounded-xl overflow-hidden"},Oa={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},Pa=e.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",za,[e.createVNode(e.unref(Pe),{class:"w-7 h-7 text-primary"})]),o[4]||(o[4]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-1"}," Almost there! ",-1)),o[5]||(o[5]=e.createElementVNode("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. ",-1)),e.createElementVNode("div",Ha,[e.createElementVNode("div",Va,[e.createElementVNode("div",Oa,[o[1]||(o[1]=e.createElementVNode("span",{class:"text-xs text-gray-400"},"main.ts",-1)),e.createElementVNode("button",{type:"button",class:"text-xs text-gray-400 hover:text-white transition-colors",onClick:o[0]||(o[0]=r=>t.$emit("copy"))},e.toDisplayString(n.copied?"✓ Copied":"Copy"),1)]),o[2]||(o[2]=e.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]=e.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[e.createTextVNode(" Need help? Check the "),e.createElementVNode("a",{href:"https://github.com/BinarCode/restify-chatbot",target:"_blank",class:"text-primary hover:underline"},"documentation")],-1))])],64))}}),xi={key:0,class:"flex items-center gap-3 mb-4"},bi={class:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center"},wi={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ci={key:1,class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"},Ei={class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},Si={class:"flex justify-end gap-3"},lr=e.defineComponent({__name:"ConfirmDialog",props:{show:{type:Boolean},title:{},message:{},confirmText:{},cancelText:{},ui:{},icon:{default:null},confirmVariant:{default:"danger"}},emits:["confirm","cancel"],setup(r){const t=r,n=e.computed(()=>{var s,a;return t.icon==="warning"?(s=t.ui)==null?void 0:s.historyLimitModal:(a=t.ui)==null?void 0:a.closeConfirmModal}),o=e.computed(()=>{var i,l;const s=t.confirmVariant==="danger"?"bg-red-600 hover:bg-red-700":"bg-primary-500 hover:bg-primary-600",a=t.confirmVariant==="danger"?(i=t.ui)==null?void 0:i.closeConfirmButton:(l=t.ui)==null?void 0:l.historyLimitButton;return[s,a]});return(s,a)=>(e.openBlock(),e.createBlock(e.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:e.withCtx(()=>{var i;return[r.show?(e.openBlock(),e.createElementBlock("div",{key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center z-10",onClick:a[2]||(a[2]=e.withModifiers(l=>s.$emit("cancel"),["self"]))},[e.createElementVNode("div",{class:e.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"?(e.openBlock(),e.createElementBlock("div",xi,[e.createElementVNode("div",bi,[e.createVNode(e.unref(kt),{class:"w-5 h-5 text-amber-600 dark:text-amber-400"})]),e.createElementVNode("h3",wi,e.toDisplayString(r.title),1)])):(e.openBlock(),e.createElementBlock("h3",Ci,e.toDisplayString(r.title),1)),e.createElementVNode("p",Ei,e.toDisplayString(r.message),1),e.createElementVNode("div",Si,[e.createElementVNode("button",{type:"button",class:e.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"))},e.toDisplayString(r.cancelText),3),e.createElementVNode("button",{type:"button",class:e.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"))},e.toDisplayString(r.confirmText),3)])],2)])):e.createCommentVNode("",!0)]}),_:1}))}}),Ti={key:0,class:"flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto"},Ai={key:0,class:"flex-1 flex flex-col overflow-y-auto"},Mi=or(e.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:!0},closeOnEscape:{type:Boolean,default:!0},showQuota:{type:Boolean,default:!0},showMessageCount:{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:t}){const n=r,o=t,s=e.computed({get:()=>n.modelValue,set:$=>o("update:modelValue",$)});function a($,P){var le;const X=(le=n.texts)==null?void 0:le[$];if(X){let J=X;if(P)for(const[v,ce]of Object.entries(P))J=J.replace(`{${v}}`,String(ce));return J}return te($,P)}const i=Ae(),l=e.ref(""),u=e.ref(null),d=e.ref(null),m=e.ref(!1),h=e.ref(!1),g=e.ref(!1),{loadingMessage:y,startLoadingText:f,resetLoadingText:S}=ds(()=>i.sending,()=>n.loadingText),{showHistoryLimitWarning:p,historyLimitReached:w,historyLimitDialogTitle:M,historyLimitDialogMessage:x,dismissHistoryLimitWarning:C,handleHistoryLimitAction:I,checkHistoryLimit:b,setPendingMessage:N}=ms({getHistoryLength:()=>i.quota.limit-i.quota.remaining,getStoreLimit:()=>i.quota.limit,getConfig:()=>n.historyLimit,getTexts:()=>n.texts,onStartNewChat:()=>i.clearChatHistory(),onNewChatEmit:()=>o("new-chat")}),L=e.computed(()=>!Nt()),A=e.computed(()=>ke("enableSupportMode")??!1),{suggestions:B,resolvePrompt:V}=Xt(),{scrollToBottom:G,watchForScroll:_}=xs(u),O=e.computed(()=>L.value?[]:B.value||[]),{filteredSuggestions:z}=ks(O,l),ne=e.computed(()=>({quota:i.quota,isFullscreen:m.value,hasHistory:i.chatHistory.length>0,onNewChat:Me,onClose:Q,onMinimize:Ie,onToggleFullscreen:nt})),be=e.computed(()=>({modelValue:l.value,sending:i.sending,disabled:!1,onSubmit:ot,onCancel:()=>i.cancelRequest()}));function U($){const P=(B.value||[]).find(X=>X.id===$.id);P&&(l.value=V(P))}function nt(){m.value=!m.value}function Ie(){s.value=!1}function Q(){n.confirmClose&&!L.value&&i.chatHistory.length>0?g.value=!0:(s.value=!1,o("close"))}function xt(){g.value=!1,i.clearChatHistory(),s.value=!1,o("close")}function Y(){o("contact-support")}function bt(){i.toggleSupportMode()}function j($){l.value=$.prompt,i.clearError()}function Me(){i.clearChatHistory(),o("new-chat")}function rt($){}function Be(){navigator.clipboard.writeText(`import { RestifyAiPlugin } from '@doderasoftware/restify-ai'
68
+ })</code></pre>`,1))]),o[3]||(o[3]=e.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[e.createTextVNode(" Need help? Check the "),e.createElementVNode("a",{href:"https://github.com/BinarCode/restify-chatbot",target:"_blank",class:"text-primary hover:underline"},"documentation")],-1))])],64))}}),Fa={key:0,class:"flex items-center gap-3 mb-4"},Ua={class:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center"},qa={class:"text-lg font-semibold text-gray-900 dark:text-white"},ja={key:1,class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"},Wa={class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},Ka={class:"flex justify-end gap-3"},xo=e.defineComponent({__name:"ConfirmDialog",props:{show:{type:Boolean},title:{},message:{},confirmText:{},cancelText:{},ui:{},icon:{default:null},confirmVariant:{default:"danger"}},emits:["confirm","cancel"],setup(n){const t=n,o=e.computed(()=>{var s,i;return t.icon==="warning"?(s=t.ui)==null?void 0:s.historyLimitModal:(i=t.ui)==null?void 0:i.closeConfirmModal}),r=e.computed(()=>{var a,l;const s=t.confirmVariant==="danger"?"bg-red-600 hover:bg-red-700":"bg-primary-500 hover:bg-primary-600",i=t.confirmVariant==="danger"?(a=t.ui)==null?void 0:a.closeConfirmButton:(l=t.ui)==null?void 0:l.historyLimitButton;return[s,i]});return(s,i)=>(e.openBlock(),e.createBlock(e.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:e.withCtx(()=>{var a;return[n.show?(e.openBlock(),e.createElementBlock("div",{key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center z-10",onClick:i[2]||(i[2]=e.withModifiers(l=>s.$emit("cancel"),["self"]))},[e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-xl p-6 m-4 max-w-sm w-full shadow-xl",o.value])},[n.icon==="warning"?(e.openBlock(),e.createElementBlock("div",Fa,[e.createElementVNode("div",Ua,[e.createVNode(e.unref(Et),{class:"w-5 h-5 text-amber-600 dark:text-amber-400"})]),e.createElementVNode("h3",qa,e.toDisplayString(n.title),1)])):(e.openBlock(),e.createElementBlock("h3",ja,e.toDisplayString(n.title),1)),e.createElementVNode("p",Wa,e.toDisplayString(n.message),1),e.createElementVNode("div",Ka,[e.createElementVNode("button",{type:"button",class:e.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",(a=n.ui)==null?void 0:a.cancelButton]),onClick:i[0]||(i[0]=l=>s.$emit("cancel"))},e.toDisplayString(n.cancelText),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",r.value]),onClick:i[1]||(i[1]=l=>s.$emit("confirm"))},e.toDisplayString(n.confirmText),3)])],2)])):e.createCommentVNode("",!0)]}),_:1}))}}),Qa={class:"rai-history-sidebar"},Ga={class:"rai-history-header"},va={class:"rai-history-title"},Ya=["title"],Za={class:"rai-history-list"},Xa=["onClick"],Ja={class:"rai-history-item-content"},el={key:0,class:"rai-history-item-edit"},tl=["onKeydown","onBlur"],nl=["title"],ol={class:"rai-history-item-meta"},rl={class:"rai-history-item-date"},sl={key:0,class:"rai-history-item-actions"},il=["title","onClick"],al=["title","onClick"],ll={key:0,class:"rai-history-empty"},cl=St(e.defineComponent({__name:"ConversationHistory",setup(n){const t=xe(),o=e.computed(()=>t.conversationHistory),r=e.computed(()=>t.conversationId),s=e.computed(()=>t.sending),i=e.ref(null),a=e.ref(""),l=e.ref(null);function c(y){const b=new Date(y),C=new Date().getTime()-b.getTime(),S=Math.floor(C/(1e3*60)),E=Math.floor(C/(1e3*60*60)),R=Math.floor(C/(1e3*60*60*24));return S<1?"Just now":S<60?`${S}m ago`:E<24?`${E}h ago`:R===1?"Yesterday":R<7?`${R}d ago`:b.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function u(y){i.value||s.value||y.id!==r.value&&t.loadConversation(y.id)}function m(y,b){y.stopPropagation(),t.deleteConversation(b)}function p(y,b){y.stopPropagation(),i.value=b.id,a.value=b.title,e.nextTick(()=>{var x,C;(x=l.value)==null||x.focus(),(C=l.value)==null||C.select()})}function g(y){a.value.trim()&&t.renameConversation(y,a.value.trim()),k()}function k(){i.value=null,a.value=""}function h(y,b){y.key==="Enter"?g(b):y.key==="Escape"&&k()}function N(){t.sending&&t.cancelRequest(),t.clearChatHistory(),t.showHistorySidebar=!1}function f(){t.showHistorySidebar=!1}return(y,b)=>(e.openBlock(),e.createElementBlock("div",Qa,[e.createElementVNode("div",Ga,[e.createElementVNode("h3",va,e.toDisplayString(e.unref(j)("conversationHistory")||"History"),1),e.createElementVNode("button",{class:"rai-history-close",title:e.unref(j)("close")||"Close",onClick:f},[...b[2]||(b[2]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,Ya)]),e.createElementVNode("button",{class:"rai-new-chat-btn",onClick:N},[b[3]||(b[3]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)),e.createTextVNode(" "+e.toDisplayString(e.unref(j)("newChat")||"New Chat"),1)]),e.createElementVNode("div",Za,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,x=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:e.normalizeClass(["rai-history-item",{"rai-history-item--active":x.id===r.value,"rai-history-item--disabled":s.value&&x.id!==r.value}]),onClick:C=>u(x)},[e.createElementVNode("div",Ja,[i.value===x.id?(e.openBlock(),e.createElementBlock("div",el,[e.withDirectives(e.createElementVNode("input",{ref_for:!0,ref_key:"editInput",ref:l,"onUpdate:modelValue":b[0]||(b[0]=C=>a.value=C),type:"text",class:"rai-history-item-input",onKeydown:C=>h(C,x.id),onBlur:C=>g(x.id),onClick:b[1]||(b[1]=e.withModifiers(()=>{},["stop"]))},null,40,tl),[[e.vModelText,a.value]])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",{class:"rai-history-item-title",title:x.title},e.toDisplayString(x.title||e.unref(j)("untitledConversation")||"New conversation"),9,nl),e.createElementVNode("div",ol,[e.createElementVNode("span",rl,e.toDisplayString(c(x.updatedAt)),1)])],64))]),i.value!==x.id?(e.openBlock(),e.createElementBlock("div",sl,[e.createElementVNode("button",{class:"rai-history-item-action",title:e.unref(j)("renameConversation")||"Rename",onClick:C=>p(C,x)},[...b[4]||(b[4]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})],-1)])],8,il),e.createElementVNode("button",{class:"rai-history-item-action rai-history-item-action--delete",title:e.unref(j)("deleteConversation")||"Delete",onClick:C=>m(C,x.id)},[...b[5]||(b[5]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"3 6 5 6 21 6"}),e.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,al)])):e.createCommentVNode("",!0)],10,Xa))),128)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",ll,[b[6]||(b[6]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),e.createElementVNode("p",null,e.toDisplayString(e.unref(j)("noConversations")||"No conversations yet"),1),b[7]||(b[7]=e.createElementVNode("span",{class:"rai-history-empty-hint"},"Start a new chat to begin",-1))])):e.createCommentVNode("",!0)])]))}}),[["__scopeId","data-v-4e30390b"]]),dl={class:"h-full flex relative overflow-hidden"},ul={key:0,class:"absolute left-0 top-0 bottom-0 w-[280px] z-10 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 shadow-lg"},ml={key:0,class:"flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto"},hl={key:0,class:"flex-1 flex flex-col overflow-y-auto"},fl=St(e.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:!0},closeOnEscape:{type:Boolean,default:!0},showQuota:{type:Boolean,default:!0},showMessageCount:{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},enableAudioInput:{type:Boolean,default:!1},isRecording:{type:Boolean,default:!1},inputValue:{default:""},historyLimit:{},loadingText:{},autoFetchQuota:{type:Boolean,default:!0}},emits:["update:modelValue","update:inputValue","close","contact-support","new-chat","toggle-audio-recording"],setup(n,{emit:t}){const o=n,r=t,s=e.computed({get:()=>o.modelValue,set:$=>r("update:modelValue",$)});function i($,O){var ce;const v=(ce=o.texts)==null?void 0:ce[$];if(v){let te=v;if(O)for(const[ne,ge]of Object.entries(O))te=te.replace(`{${ne}}`,String(ge));return te}return j($,O)}const a=xe(),l=e.ref(""),c=e.ref(null),u=e.ref(null),m=e.ref(!1),p=e.ref(!1),g=e.ref(!1),k=e.computed(()=>ke("useConversationHistory")===!0),h=e.computed(()=>a.showHistorySidebar),{loadingMessage:N,startLoadingText:f,resetLoadingText:y}=Cs(()=>a.sending,()=>o.loadingText),{showHistoryLimitWarning:b,historyLimitReached:x,historyLimitDialogTitle:C,historyLimitDialogMessage:S,dismissHistoryLimitWarning:E,handleHistoryLimitAction:R,checkHistoryLimit:D,setPendingMessage:B}=Es({getHistoryLength:()=>a.quota.limit-a.quota.remaining,getStoreLimit:()=>a.quota.limit,getConfig:()=>o.historyLimit,getTexts:()=>o.texts,onStartNewChat:()=>a.clearChatHistory(),onNewChatEmit:()=>r("new-chat")}),_=e.computed(()=>!Lt()),V=e.computed(()=>ke("enableSupportMode")??!1),{suggestions:X,resolvePrompt:le}=on(),{scrollToBottom:T,watchForScroll:I}=Rs(c),Q=e.computed(()=>_.value?[]:X.value||[]),{filteredSuggestions:J}=Ms(Q,l),P=e.computed(()=>({quota:a.quota,isFullscreen:m.value,hasHistory:a.chatHistory.length>0,onNewChat:Se,onClose:Y,onMinimize:pe,onToggleFullscreen:H})),Le=e.computed(()=>({modelValue:l.value,sending:a.sending,disabled:!1,onSubmit:Te,onCancel:()=>a.cancelRequest()}));function De($){const O=(X.value||[]).find(v=>v.id===$.id);O&&(l.value=le(O))}function H(){m.value=!m.value}function pe(){s.value=!1}function Y(){o.confirmClose&&!_.value&&a.chatHistory.length>0?g.value=!0:(s.value=!1,r("close"))}function Tt(){a.conversationId&&a.deleteConversation(a.conversationId),g.value=!1,a.clearChatHistory(),s.value=!1,r("close")}function G($){r("contact-support",$)}function ze(){a.toggleSupportMode()}function Fe($){l.value=$.prompt,a.clearError()}function Se(){a.clearChatHistory(),r("new-chat")}function At($){}function at(){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
- })`),h.value=!0,setTimeout(()=>{h.value=!1},2e3)}async function wt(){const $=await I();$&&(await e.nextTick(),await Oe($.message,$.attachments,$.mentions,$.isSupportRequest))}async function Oe($,P,X,le){i.clearError(),f(),await e.nextTick(),G();const J=await i.askQuestion($,P,X,le);S(),J&&G()}async function ot($){const{message:P,attachments:X,mentions:le,isSupportRequest:J}=$;if(i.sending)return;const v=le.map(ce=>({id:ce.id,name:ce.name,type:ce.type||"unknown",metadata:ce.metadata}));if(!b()){N({message:P,attachments:X,mentions:v,isSupportRequest:J});return}await Oe(P,X,v,J)}async function Ct(){f();const $=await i.retry();S(),$&&G()}function we($){n.closeOnEscape&&$.key==="Escape"&&s.value&&(g.value?g.value=!1:Ie())}return _(()=>i.chatHistory.length,()=>i.chatHistory.map($=>$.message).join("")),e.watch(()=>n.modelValue,async $=>{var P;$&&(await G(),(P=d.value)==null||P.focus()),$&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),e.onMounted(()=>{window.addEventListener("keydown",we)}),e.onUnmounted(()=>{window.removeEventListener("keydown",we)}),($,P)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"rai-fade"},{default:e.withCtx(()=>{var X;return[s.value&&r.showBackdrop?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["fixed inset-0 bg-black/30 z-40",(X=r.ui)==null?void 0:X.backdrop]),onClick:P[0]||(P[0]=le=>r.closeOnBackdropClick&&Ie())},null,2)):e.createCommentVNode("",!0)]}),_:1}),e.createVNode(e.Transition,{name:r.position==="left"?"rai-slide-right":"rai-slide-left"},{default:e.withCtx(()=>{var X,le,J;return[s.value?(e.openBlock(),e.createElementBlock("aside",{key:0,class:e.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",(X=r.ui)==null?void 0:X.drawer]]),style:e.normalizeStyle({width:m.value?r.fullscreenWidth:r.width,top:r.topOffset,height:`calc(100vh - ${r.topOffset})`})},[e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(le=r.ui)==null?void 0:le.panel])},[e.renderSlot($.$slots,"header",e.normalizeProps(e.guardReactiveProps(ne.value)),()=>[e.createVNode(oi,{ui:r.ui,"is-setup-mode":L.value,"show-new-chat-button":r.showNewChatButton,"has-history":e.unref(i).chatHistory.length>0,"show-quota":r.showQuota,quota:e.unref(i).quota,"show-close-button":r.showCloseButton,"show-minimize-button":r.showMinimizeButton,"show-fullscreen-toggle":r.showFullscreenToggle,"is-fullscreen":m.value,"show-message-count":r.showMessageCount,"message-count":e.unref(i).quota.used,"message-limit":e.unref(i).quota.limit,t:a,onNewChat:Me,onClose:Q,onMinimize:Ie,onToggleFullscreen:nt},{quota:e.withCtx(()=>[e.renderSlot($.$slots,"quota",{quota:e.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","show-message-count","message-count","message-limit"])],!0),e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col mx-auto w-full overflow-hidden",[{"max-w-5xl":m.value},(J=r.ui)==null?void 0:J.body]])},[L.value?(e.openBlock(),e.createElementBlock("div",Ti,[e.renderSlot($.$slots,"setup",{},()=>[e.createVNode(ki,{copied:h.value,onCopy:Be},null,8,["copied"])],!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(i).chatHistory.length===0?(e.openBlock(),e.createElementBlock("div",Ai,[e.renderSlot($.$slots,"empty-state",{suggestions:e.unref(z),onClick:j},()=>[e.createVNode(ir,{onItemClick:j})],!0)])):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"chatContainer",ref:u,class:"flex-1 overflow-y-auto py-6 pb-24"},[e.createVNode(fi,{messages:e.unref(i).chatHistory,"loading-message":e.unref(y),quota:e.unref(i).quota,error:e.unref(i).error,ui:r.ui,t:a,onCopy:rt,onContactSupport:Y,onRetry:Ct},{message:e.withCtx(v=>[e.renderSlot($.$slots,"message",{message:v.message,isUser:v.isUser,isLoading:v.isLoading,isStreaming:v.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),P[3]||(P[3]=e.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),e.renderSlot($.$slots,"input",e.normalizeProps(e.guardReactiveProps(be.value)),()=>{var v,ce;return[e.createVNode(ar,{ref_key:"chatInputRef",ref:d,modelValue:l.value,"onUpdate:modelValue":P[1]||(P[1]=Et=>l.value=Et),sending:e.unref(i).sending,placeholder:((v=n.texts)==null?void 0:v.placeholder)||e.unref(te)("inputPlaceholder"),"support-placeholder":((ce=n.texts)==null?void 0:ce.supportPlaceholder)||e.unref(te)("supportPlaceholder"),suggestions:e.unref(z),"has-history":e.unref(i).chatHistory.length>0,"support-request-mode":e.unref(i).supportRequestMode,"show-support-mode-toggle":A.value,onSubmit:ot,onCancel:e.unref(i).cancelRequest,onSuggestionSelect:U,onToggleSupportMode:bt},{"context-link":e.withCtx(()=>[e.renderSlot($.$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),e.createVNode(lr,{show:g.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:r.ui,"confirm-variant":"danger",onConfirm:xt,onCancel:P[2]||(P[2]=v=>g.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),e.createVNode(lr,{show:e.unref(p),title:e.unref(M),message:e.unref(x),"confirm-text":a("startNewChat"),"cancel-text":e.unref(w)?a("continueChat"):a("cancel"),ui:r.ui,icon:"warning","confirm-variant":"primary",onConfirm:wt,onCancel:e.unref(C)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):e.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-25c9b34d"]]),Bi=e.defineComponent({__name:"ErrorBoundary",props:{title:{default:"Something went wrong"},message:{default:"An unexpected error occurred. Please try again."},retryText:{default:"Try Again"},showRetry:{type:Boolean,default:!0},ui:{},onError:{}},emits:["error","reset"],setup(r,{expose:t,emit:n}){const o=r,s=n,a=e.ref(!1),i=e.ref(null);e.onErrorCaptured((u,d,m)=>{var h;return a.value=!0,i.value=u,(h=o.onError)==null||h.call(o,u,m),s("error",u,m),!1});function l(){a.value=!1,i.value=null,s("reset")}return t({hasError:a,error:i,reset:l}),(u,d)=>a.value?e.renderSlot(u.$slots,"error",{key:1,error:i.value,reset:l},()=>{var m,h,g,y,f;return[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-col items-center justify-center p-6 text-center",(m=r.ui)==null?void 0:m.container])},[e.createElementVNode("div",{class:e.normalizeClass(["w-12 h-12 mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",(h=r.ui)==null?void 0:h.iconContainer])},[e.createVNode(e.unref(kt),{class:"w-6 h-6 text-red-600 dark:text-red-400"})],2),e.createElementVNode("h3",{class:e.normalizeClass(["text-lg font-semibold text-gray-900 dark:text-white mb-2",(g=r.ui)==null?void 0:g.title])},e.toDisplayString(r.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4",(y=r.ui)==null?void 0:y.message])},e.toDisplayString(r.message),3),r.showRetry?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary/90 transition-colors",(f=r.ui)==null?void 0:f.retryButton]),onClick:l},e.toDisplayString(r.retryText),3)):e.createCommentVNode("",!0)],2)]}):e.renderSlot(u.$slots,"default",{key:0})}}),cr={install(r,t){if(!t.endpoints||!t.getAuthToken){console.warn("[restify-ai] Plugin requires endpoints and getAuthToken options.");return}const n={endpoints:t.endpoints,baseUrl:t.baseUrl,getAuthToken:t.getAuthToken,getCustomHeaders:t.getCustomHeaders,buildRequest:t.buildRequest,parseStreamContent:t.parseStreamContent,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,retry:t.retry,translate:t.translate,can:t.can,labels:{...Bt,...t.labels},mentionProviders:t.mentionProviders,suggestionProviders:t.suggestionProviders,defaultSuggestions:t.defaultSuggestions,theme:t.theme,chatHistoryLimit:t.chatHistoryLimit,maxAttachments:t.maxAttachments,maxFileSize:t.maxFileSize,acceptedFileTypes:t.acceptedFileTypes,chatHistoryKey:t.chatHistoryKey,drawerStateKey:t.drawerStateKey,keyboardShortcut:t.keyboardShortcut,enableSupportMode:t.enableSupportMode,useQuota:t.useQuota,canToggle:t.canToggle,assistantAvatar:t.assistantAvatar,userAvatar:t.userAvatar,onQuotaFetched:t.onQuotaFetched,onError:t.onError,onMessageSent:t.onMessageSent,onResponseReceived:t.onResponseReceived,onDrawerToggle:t.onDrawerToggle,onNewChat:t.onNewChat,onStreamStart:t.onStreamStart,onStreamEnd:t.onStreamEnd,onStreamChunk:t.onStreamChunk,beforeSend:t.beforeSend,afterResponse:t.afterResponse,onFileUploadStart:t.onFileUploadStart,onFileUploadProgress:t.onFileUploadProgress,onFileUploadComplete:t.onFileUploadComplete,onFileUploadError:t.onFileUploadError};ln(n),r.provide("restify-ai-config",n)}};R.AiAvatar=tr,R.AiChatDrawer=Mi,R.AiEmptyState=ir,R.ChatInput=ar,R.ChatMessage=sr,R.ChatMessageActions=rr,R.ChatRoles=Re,R.ErrorBoundary=Bi,R.MentionList=nr,R.RestifyAiPlugin=cr,R.UserAvatar=Ys,R.default=cr,R.defaultLabels=Bt,R.formatFileSize=lt,R.formatMentionsForApi=bn,R.getConfigValue=ke,R.getLabel=te,R.getRestifyAiConfig=K,R.getRestifyAiConfigOrThrow=Br,R.getSuggestionsForPath=Xn,R.groupMentionsByType=wn,R.isConfigured=Nt,R.isImageFile=it,R.registerSuggestionProvider=as,R.setRestifyAiConfig=ln,R.useAiContext=Yt,R.useAiDrawerShortcut=us,R.useAiSuggestions=Xt,R.useChatErrorHandling=ns,R.useChatMarkdown=Zn,R.useChatScroll=ts,R.useKeyboardShortcut=Jn,R.useMentionParsing=vr,R.usePageAiContext=is,R.useRestifyAiStore=Ae,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
76
+ })`),p.value=!0,setTimeout(()=>{p.value=!1},2e3)}async function Nt(){const $=await R();$&&(await e.nextTick(),await lt($.message,$.attachments,$.mentions,$.isSupportRequest))}async function lt($,O,v,ce){a.clearError(),f(),await e.nextTick(),T();const te=await a.askQuestion($,O,v,ce);y(),te&&T()}async function Te($){const{message:O,attachments:v,mentions:ce,isSupportRequest:te}=$;if(a.sending)return;if(te){r("contact-support",{message:O,attachments:v});return}const ne=ce.map(ge=>({id:ge.id,name:ge.name,type:ge.type||"unknown",metadata:ge.metadata}));if(!D()){B({message:O,attachments:v,mentions:ne,isSupportRequest:te});return}await lt(O,v,ne,te)}async function Ue(){f();const $=await a.retry();y(),$&&T()}function be($){o.closeOnEscape&&$.key==="Escape"&&s.value&&(g.value?g.value=!1:pe())}return I(()=>a.chatHistory.length,()=>a.chatHistory.map($=>$.message).join("")),e.watch(()=>o.modelValue,async $=>{var O;$&&(await T(),(O=u.value)==null||O.focus()),$&&o.autoFetchQuota&&a.fetchQuota()},{immediate:!0}),e.watch(()=>o.inputValue,$=>{$!==l.value&&(l.value=$)}),e.watch(l,$=>{r("update:inputValue",$)}),e.onMounted(()=>{window.addEventListener("keydown",be)}),e.onUnmounted(()=>{window.removeEventListener("keydown",be)}),($,O)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"rai-fade"},{default:e.withCtx(()=>{var v;return[s.value&&n.showBackdrop?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["fixed inset-0 bg-black/30 z-40",(v=n.ui)==null?void 0:v.backdrop]),onClick:O[0]||(O[0]=ce=>n.closeOnBackdropClick&&pe())},null,2)):e.createCommentVNode("",!0)]}),_:1}),e.createVNode(e.Transition,{name:n.position==="left"?"rai-slide-right":"rai-slide-left"},{default:e.withCtx(()=>{var v,ce,te;return[s.value?(e.openBlock(),e.createElementBlock("aside",{key:0,class:e.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",[n.position==="left"?"left-0 border-r":"right-0 border-l",(v=n.ui)==null?void 0:v.drawer]]),style:e.normalizeStyle({width:m.value?n.fullscreenWidth:n.width,top:n.topOffset,height:`calc(100vh - ${n.topOffset})`})},[e.createElementVNode("div",dl,[e.createVNode(e.Transition,{name:"rai-sidebar"},{default:e.withCtx(()=>[k.value&&h.value?(e.openBlock(),e.createElementBlock("div",ul,[e.createVNode(cl)])):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("div",{class:e.normalizeClass(["flex-1 h-full flex flex-col relative bg-white dark:bg-gray-900 min-w-0",(ce=n.ui)==null?void 0:ce.panel])},[e.renderSlot($.$slots,"header",e.normalizeProps(e.guardReactiveProps(P.value)),()=>[e.createVNode(Aa,{ui:n.ui,"is-setup-mode":_.value,"show-new-chat-button":n.showNewChatButton,"has-history":e.unref(a).chatHistory.length>0,"show-quota":n.showQuota,quota:e.unref(a).quota,"show-close-button":n.showCloseButton,"show-minimize-button":n.showMinimizeButton,"show-fullscreen-toggle":n.showFullscreenToggle,"is-fullscreen":m.value,"show-message-count":n.showMessageCount,"show-history-button":k.value,"has-conversation-history":e.unref(a).conversationHistory.length>0,"message-count":e.unref(a).quota.used,"message-limit":e.unref(a).quota.limit,t:i,onNewChat:Se,onClose:Y,onMinimize:pe,onToggleFullscreen:H,onToggleHistory:O[1]||(O[1]=ne=>e.unref(a).toggleHistorySidebar())},{quota:e.withCtx(()=>[e.renderSlot($.$slots,"quota",{quota:e.unref(a).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","show-message-count","show-history-button","has-conversation-history","message-count","message-limit"])],!0),e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col mx-auto w-full overflow-hidden",[{"max-w-5xl":m.value},(te=n.ui)==null?void 0:te.body]])},[_.value?(e.openBlock(),e.createElementBlock("div",ml,[e.renderSlot($.$slots,"setup",{},()=>[e.createVNode(Pa,{copied:p.value,onCopy:at},null,8,["copied"])],!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(a).chatHistory.length===0?(e.openBlock(),e.createElementBlock("div",hl,[e.renderSlot($.$slots,"empty-state",{suggestions:e.unref(J),onClick:Fe},()=>[e.createVNode(ko,{ui:n.ui,onItemClick:Fe},null,8,["ui"])],!0)])):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"chatContainer",ref:c,class:"flex-1 overflow-y-auto py-6 pb-24"},[e.createVNode(Da,{messages:e.unref(a).chatHistory,"loading-message":e.unref(N),quota:e.unref(a).quota,error:e.unref(a).error,ui:n.ui,t:i,onCopy:At,onContactSupport:G,onRetry:Ue},{message:e.withCtx(ne=>[e.renderSlot($.$slots,"message",{message:ne.message,isUser:ne.isUser,isLoading:ne.isLoading,isStreaming:ne.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),O[5]||(O[5]=e.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),e.renderSlot($.$slots,"input",e.normalizeProps(e.guardReactiveProps(Le.value)),()=>{var ne,ge;return[e.createVNode(yo,{ref_key:"chatInputRef",ref:u,modelValue:l.value,"onUpdate:modelValue":O[2]||(O[2]=Bt=>l.value=Bt),sending:e.unref(a).sending,placeholder:((ne=o.texts)==null?void 0:ne.placeholder)||e.unref(j)("inputPlaceholder"),"support-placeholder":((ge=o.texts)==null?void 0:ge.supportPlaceholder)||e.unref(j)("supportPlaceholder"),suggestions:e.unref(J),"has-history":e.unref(a).chatHistory.length>0,"support-request-mode":e.unref(a).supportRequestMode,"show-support-mode-toggle":V.value,"enable-audio-input":n.enableAudioInput,"is-recording":n.isRecording,ui:n.ui,onSubmit:Te,onCancel:e.unref(a).cancelRequest,onSuggestionSelect:De,onToggleSupportMode:ze,onToggleAudioRecording:O[3]||(O[3]=Bt=>$.$emit("toggle-audio-recording"))},{"context-link":e.withCtx(()=>[e.renderSlot($.$slots,"context-link",{},void 0,!0)]),_:3},8,["modelValue","sending","placeholder","support-placeholder","suggestions","has-history","support-request-mode","show-support-mode-toggle","enable-audio-input","is-recording","ui","onCancel"])]},!0)],64))],2)],2)]),e.createVNode(xo,{show:g.value,title:i("closeConfirmTitle"),message:i("closeConfirmMessage"),"confirm-text":i("confirmClose"),"cancel-text":i("cancel"),ui:n.ui,"confirm-variant":"danger",onConfirm:Tt,onCancel:O[4]||(O[4]=ne=>g.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),e.createVNode(xo,{show:e.unref(b),title:e.unref(C),message:e.unref(S),"confirm-text":i("startNewChat"),"cancel-text":e.unref(x)?i("continueChat"):i("cancel"),ui:n.ui,icon:"warning","confirm-variant":"primary",onConfirm:Nt,onCancel:e.unref(E)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):e.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-2552a730"]]),pl=e.defineComponent({__name:"ErrorBoundary",props:{title:{default:"Something went wrong"},message:{default:"An unexpected error occurred. Please try again."},retryText:{default:"Try Again"},showRetry:{type:Boolean,default:!0},ui:{},onError:{}},emits:["error","reset"],setup(n,{expose:t,emit:o}){const r=n,s=o,i=e.ref(!1),a=e.ref(null);e.onErrorCaptured((c,u,m)=>{var p;return i.value=!0,a.value=c,(p=r.onError)==null||p.call(r,c,m),s("error",c,m),!1});function l(){i.value=!1,a.value=null,s("reset")}return t({hasError:i,error:a,reset:l}),(c,u)=>i.value?e.renderSlot(c.$slots,"error",{key:1,error:a.value,reset:l},()=>{var m,p,g,k,h;return[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-col items-center justify-center p-6 text-center",(m=n.ui)==null?void 0:m.container])},[e.createElementVNode("div",{class:e.normalizeClass(["w-12 h-12 mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",(p=n.ui)==null?void 0:p.iconContainer])},[e.createVNode(e.unref(Et),{class:"w-6 h-6 text-red-600 dark:text-red-400"})],2),e.createElementVNode("h3",{class:e.normalizeClass(["text-lg font-semibold text-gray-900 dark:text-white mb-2",(g=n.ui)==null?void 0:g.title])},e.toDisplayString(n.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4",(k=n.ui)==null?void 0:k.message])},e.toDisplayString(n.message),3),n.showRetry?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary/90 transition-colors",(h=n.ui)==null?void 0:h.retryButton]),onClick:l},e.toDisplayString(n.retryText),3)):e.createCommentVNode("",!0)],2)]}):e.renderSlot(c.$slots,"default",{key:0})}}),wo={install(n,t){if(!t.endpoints||!t.getAuthToken){console.warn("[restify-ai] Plugin requires endpoints and getAuthToken options.");return}const o={endpoints:t.endpoints,baseUrl:t.baseUrl,getAuthToken:t.getAuthToken,getCustomHeaders:t.getCustomHeaders,buildRequest:t.buildRequest,parseStreamContent:t.parseStreamContent,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,retry:t.retry,translate:t.translate,can:t.can,labels:{...$t,...t.labels},mentionProviders:t.mentionProviders,suggestionProviders:t.suggestionProviders,defaultSuggestions:t.defaultSuggestions,theme:t.theme,chatHistoryLimit:t.chatHistoryLimit,maxAttachments:t.maxAttachments,maxFileSize:t.maxFileSize,acceptedFileTypes:t.acceptedFileTypes,fileUpload:t.fileUpload,chatHistoryKey:t.chatHistoryKey,drawerStateKey:t.drawerStateKey,keyboardShortcut:t.keyboardShortcut,enableSupportMode:t.enableSupportMode,useQuota:t.useQuota,useConversationId:t.useConversationId,useConversationHistory:t.useConversationHistory,maxConversationHistory:t.maxConversationHistory,canToggle:t.canToggle,assistantAvatar:t.assistantAvatar,userAvatar:t.userAvatar,onQuotaFetched:t.onQuotaFetched,onError:t.onError,onMessageSent:t.onMessageSent,onResponseReceived:t.onResponseReceived,onDrawerToggle:t.onDrawerToggle,onNewChat:t.onNewChat,onStreamStart:t.onStreamStart,onStreamEnd:t.onStreamEnd,onStreamChunk:t.onStreamChunk,beforeSend:t.beforeSend,afterResponse:t.afterResponse,onFileUploadStart:t.onFileUploadStart,onFileUploadProgress:t.onFileUploadProgress,onFileUploadComplete:t.onFileUploadComplete,onFileUploadError:t.onFileUploadError};fn(o),n.provide("restify-ai-config",o)}};L.AiAvatar=ho,L.AiChatDrawer=fl,L.AiEmptyState=ko,L.ChatInput=yo,L.ChatMessage=go,L.ChatMessageActions=po,L.ChatRoles=Me,L.ErrorBoundary=pl,L.MentionList=fo,L.RestifyAiPlugin=wo,L.UserAvatar=pi,L.default=wo,L.defaultLabels=$t,L.formatFileSize=mt,L.formatMentionsForApi=In,L.getConfigValue=ke,L.getLabel=j,L.getRestifyAiConfig=K,L.getRestifyAiConfigOrThrow=Vo,L.getSuggestionsForPath=lo,L.groupMentionsByType=_n,L.isConfigured=Lt,L.isImageFile=ut,L.registerSuggestionProvider=ys,L.setRestifyAiConfig=fn,L.useAiContext=nn,L.useAiDrawerShortcut=bs,L.useAiSuggestions=on,L.useChatErrorHandling=hs,L.useChatMarkdown=io,L.useChatScroll=ms,L.useKeyboardShortcut=co,L.useMentionParsing=ur,L.usePageAiContext=ks,L.useRestifyAiStore=xe,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});