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

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 (59) hide show
  1. package/README.md +939 -401
  2. package/dist/components/AiAvatar.vue.d.ts.map +1 -1
  3. package/dist/components/AiChatDrawer.vue.d.ts +7 -3
  4. package/dist/components/AiChatDrawer.vue.d.ts.map +1 -1
  5. package/dist/components/AiEmptyState.vue.d.ts.map +1 -1
  6. package/dist/components/ChatInput.vue.d.ts.map +1 -1
  7. package/dist/components/ChatMessage.vue.d.ts.map +1 -1
  8. package/dist/components/ChatMessageActions.vue.d.ts.map +1 -1
  9. package/dist/components/ErrorBoundary.vue.d.ts +74 -0
  10. package/dist/components/ErrorBoundary.vue.d.ts.map +1 -0
  11. package/dist/components/MentionList.vue.d.ts.map +1 -1
  12. package/dist/components/UserAvatar.vue.d.ts.map +1 -1
  13. package/dist/components/drawer/ConfirmDialog.vue.d.ts.map +1 -1
  14. package/dist/components/drawer/DrawerHeader.vue.d.ts +4 -0
  15. package/dist/components/drawer/DrawerHeader.vue.d.ts.map +1 -1
  16. package/dist/components/drawer/DrawerMessageList.vue.d.ts.map +1 -1
  17. package/dist/components/drawer/SetupGuide.vue.d.ts.map +1 -1
  18. package/dist/components/index.d.ts +1 -0
  19. package/dist/components/index.d.ts.map +1 -1
  20. package/dist/components/input/AttachmentsPreview.vue.d.ts.map +1 -1
  21. package/dist/components/input/InputActions.vue.d.ts.map +1 -1
  22. package/dist/composables/useKeyboardShortcut.d.ts +9 -5
  23. package/dist/composables/useKeyboardShortcut.d.ts.map +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/restify-ai.js +1866 -1722
  27. package/dist/restify-ai.umd.cjs +46 -46
  28. package/dist/store/index.d.ts +2 -0
  29. package/dist/store/index.d.ts.map +1 -0
  30. package/dist/store/storage.d.ts +30 -0
  31. package/dist/store/storage.d.ts.map +1 -0
  32. package/dist/store/store.d.ts +247 -0
  33. package/dist/store/store.d.ts.map +1 -0
  34. package/dist/store/utils.d.ts +23 -0
  35. package/dist/store/utils.d.ts.map +1 -0
  36. package/dist/store.d.ts +1 -246
  37. package/dist/store.d.ts.map +1 -1
  38. package/dist/style.css +1 -1
  39. package/dist/types/api.d.ts +43 -0
  40. package/dist/types/api.d.ts.map +1 -0
  41. package/dist/types/chat.d.ts +56 -0
  42. package/dist/types/chat.d.ts.map +1 -0
  43. package/dist/types/config.d.ts +167 -0
  44. package/dist/types/config.d.ts.map +1 -0
  45. package/dist/types/index.d.ts +15 -599
  46. package/dist/types/index.d.ts.map +1 -1
  47. package/dist/types/mentions.d.ts +34 -0
  48. package/dist/types/mentions.d.ts.map +1 -0
  49. package/dist/types/setup.d.ts +13 -0
  50. package/dist/types/setup.d.ts.map +1 -0
  51. package/dist/types/slots.d.ts +33 -0
  52. package/dist/types/slots.d.ts.map +1 -0
  53. package/dist/types/suggestions.d.ts +32 -0
  54. package/dist/types/suggestions.d.ts.map +1 -0
  55. package/dist/types/texts.d.ts +57 -0
  56. package/dist/types/texts.d.ts.map +1 -0
  57. package/dist/types/ui.d.ts +102 -0
  58. package/dist/types/ui.d.ts.map +1 -0
  59. package/package.json +31 -11
@@ -1,63 +1,63 @@
1
- (function(B,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],t):(B=typeof globalThis<"u"?globalThis:B||self,t(B.RestifyAi={},B.Vue,B.Pinia))})(this,function(B,t,Ie){"use strict";var va=Object.defineProperty;var ja=(B,t,Ie)=>t in B?va(B,t,{enumerable:!0,configurable:!0,writable:!0,value:Ie}):B[t]=Ie;var P=(B,t,Ie)=>ja(B,typeof t!="symbol"?t+"":t,Ie);let Ce=null;const wo=t.ref(null),Et={title:"AI Assistant",aiName:"AI Assistant",you:"You",newChat:"New chat",placeholder:"Ask me anything...",inputPlaceholder:"Ask me anything...",supportPlaceholder:"Describe your support request...",loadingText:"Thinking...",analyzingText:"Analyzing...",craftingText:"Crafting response...",quotaRemaining:"{count} questions remaining",noQuota:"No AI credit available",contactSupport:"Contact Support",close:"Close",minimize:"Minimize",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",copyToClipboard:"Copy to clipboard",copied:"Copied!",showMore:"Show more",showLess:"Show less",retry:"Retry",attachFiles:"Attach files",emptyStateTitle:"How can I help you today?",emptyStateDescription:"Ask me anything or choose a suggestion below",keyboardShortcutHint:"Press ⌘G to toggle",sendMessage:"Send message",attachFile:"Attach file",closeConfirmTitle:"Close conversation?",closeConfirmMessage:"This will clear your chat history. Are you sure you want to close?",confirmClose:"Close & Clear",cancel:"Cancel",toggleSupportMode:"Toggle support mode",exitSupportMode:"Exit support mode",historyLimitWarningTitle:"Approaching Chat Limit",historyLimitWarningMessage:"You are approaching the maximum number of messages in this conversation.",historyLimitReachedTitle:"Chat Limit Reached",historyLimitReachedMessage:"You have reached the maximum number of messages. Start a new chat to continue.",startNewChat:"Start New Chat",continueChat:"Continue",setupWelcomeTitle:"Welcome to AI Assistant",setupWelcomeDescription:"Let's get you set up to start using AI features.",setupApiKeyTitle:"API Key Configuration",setupApiKeyDescription:"Enter your API key to test the connection",setupTestingTitle:"Testing Connection...",setupBackendTitle:"Backend Configuration",setupBackendDescription:"Configure your backend endpoint",setupCompleteTitle:"Setup Complete!"};function en(r){Ce=r,wo.value=r}function q(){return Ce}function bo(){if(!Ce)throw new Error("[@doderasoftware/restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Ce}function Ct(){return Ce!==null}function J(r,e){const n=Ce,o=(n==null?void 0:n.labels)||{},s=n==null?void 0:n.translate;if(s){const i=s(r,e);if(i!==r)return i}let a=o[r]||Et[r];return e&&Object.entries(e).forEach(([i,l])=>{a=a.replace(`{${i}}`,String(l))}),a}function tn(r){return{chatHistoryLimit:15,maxAttachments:5,maxFileSize:10485760,acceptedFileTypes:"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",chatHistoryKey:"restify_ai_chat_history",drawerStateKey:"restify_ai_drawer_open",keyboardShortcut:"cmd+g",enableSupportMode:!1}[r]}function Se(r){const e=Ce;return e?e[r]??tn(r):tn(r)}const Te={Assistant:"assistant",User:"user",System:"system"};async function Eo(r,e){const n=r.getReader();let o;for(;!(o=await n.read()).done;)e(o.value)}function Co(r){let e,n,o,s=!1;return function(i){e===void 0?(e=i,n=0,o=-1):e=To(e,i);const l=e.length;let d=0;for(;n<l;){s&&(e[n]===10&&(d=++n),s=!1);let u=-1;for(;n<l&&u===-1;++n)switch(e[n]){case 58:o===-1&&(o=n-d);break;case 13:s=!0;case 10:u=n;break}if(u===-1)break;r(e.subarray(d,u),o),d=n,o=-1}d===l?e=void 0:d!==0&&(e=e.subarray(d),n-=d)}}function So(r,e,n){let o=nn();const s=new TextDecoder;return function(i,l){if(i.length===0)n==null||n(o),o=nn();else if(l>0){const d=s.decode(i.subarray(0,l)),u=l+(i[l+1]===32?2:1),p=s.decode(i.subarray(u));switch(d){case"data":o.data=o.data?o.data+`
2
- `+p:p;break;case"event":o.event=p;break;case"id":r(o.id=p);break;case"retry":const g=parseInt(p,10);isNaN(g)||e(o.retry=g);break}}}}function To(r,e){const n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}function nn(){return{data:"",event:"",id:"",retry:void 0}}var Ao=function(r,e){var n={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&e.indexOf(o)<0&&(n[o]=r[o]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(r);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(r,o[s])&&(n[o[s]]=r[o[s]]);return n};const St="text/event-stream",Mo=1e3,on="last-event-id";function No(r,e){var{signal:n,headers:o,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:d,fetch:u}=e,p=Ao(e,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((g,x)=>{const y=Object.assign({},o);y.accept||(y.accept=St);let f;function E(){f.abort(),document.hidden||$()}d||document.addEventListener("visibilitychange",E);let h=Mo,m=0;function b(){document.removeEventListener("visibilitychange",E),window.clearTimeout(m),f.abort()}n==null||n.addEventListener("abort",()=>{b(),g()});const C=u??window.fetch,w=s??Ro;async function $(){var z;f=new AbortController;try{const F=await C(r,Object.assign(Object.assign({},p),{headers:y,signal:f.signal}));await w(F),await Eo(F.body,Co(So(S=>{S?y[on]=S:delete y[on]},S=>{h=S},a))),i==null||i(),b(),g()}catch(F){if(!f.signal.aborted)try{const S=(z=l==null?void 0:l(F))!==null&&z!==void 0?z:h;window.clearTimeout(m),m=window.setTimeout($,S)}catch(S){b(),x(S)}}}$()})}function Ro(r){const e=r.headers.get("content-type");if(!(e!=null&&e.startsWith(St)))throw new Error(`Expected content-type to be ${St}, Actual: ${e}`)}let He=new AbortController;function nt(r){const e=q(),n=(e==null?void 0:e.baseUrl)||"";if(!n||r.startsWith("http://")||r.startsWith("https://"))return r;const o=n.endsWith("/")?n.slice(0,-1):n,s=r.startsWith("/")?r:`/${r}`;return`${o}${s}`}function Bo(r){var e,n,o;try{if(r==="[DONE]")return"[DONE]";const s=JSON.parse(r);return((o=(n=(e=s==null?void 0:s.choices)==null?void 0:e[0])==null?void 0:n.delta)==null?void 0:o.content)||""}catch{return null}}function Lo(r){return new Promise(e=>setTimeout(e,r))}function Ee(r){const e=q();return r==="chatHistory"?(e==null?void 0:e.chatHistoryKey)||"restify_ai_chat_history":r==="setupComplete"?"restify_ai_setup_complete":(e==null?void 0:e.drawerStateKey)||"restify_ai_drawer_open"}function ot(r){try{sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(r))}catch(e){console.warn("[RestifyAi] Failed to save chat history:",e)}}function Do(r){try{r.message||r.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(r)):sessionStorage.removeItem("restify_ai_error_state")}catch(e){console.warn("[RestifyAi] Failed to save error state:",e)}}function Io(){try{const r=sessionStorage.getItem("restify_ai_error_state");if(r)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load error state:",r)}return null}function $o(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(r){console.warn("[RestifyAi] Failed to clear error state:",r)}}function zo(){try{const r=sessionStorage.getItem(Ee("chatHistory"));if(r){const e=JSON.parse(r),n=e.filter(a=>{var i;return!(a.role===Te.Assistant&&a.loading||a.role===Te.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==e.length&&sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(n));const o=n[n.length-1],s=(o==null?void 0:o.role)===Te.User;return{history:n,hasOrphanedUserMessage:s,orphanedMessage:s?{question:o.message,attachments:o.attachments||[]}:void 0}}}catch(r){console.warn("[RestifyAi] Failed to load chat history:",r)}return{history:[],hasOrphanedUserMessage:!1}}function _o(){try{sessionStorage.removeItem(Ee("chatHistory"))}catch(r){console.warn("[RestifyAi] Failed to clear chat history:",r)}}function Tt(r){try{localStorage.setItem(Ee("drawerState"),JSON.stringify(r))}catch(e){console.warn("[RestifyAi] Failed to save drawer state:",e)}}function Oo(){try{const r=localStorage.getItem(Ee("drawerState"));if(r!==null)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load drawer state:",r)}return!1}function Po(){try{return localStorage.getItem(Ee("setupComplete"))==="true"}catch{return!1}}function rn(){try{localStorage.setItem(Ee("setupComplete"),"true")}catch(r){console.warn("[RestifyAi] Failed to mark setup complete:",r)}}function Vo(r){const e={};return r.forEach(n=>{var o;(o=n.attachments)==null||o.forEach(s=>{s!=null&&s.id&&(e[s.id]=s)})}),e}function sn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}const Ae=Ie.defineStore("restifyAiStore",{state:()=>{const r=zo(),e=Io();let n={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1};return e!=null&&e.message?n={message:e.message,failedQuestion:e.failedQuestion,failedAttachments:e.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:r.hasOrphanedUserMessage&&r.orphanedMessage&&(n={message:"Previous request failed. Click retry to try again.",failedQuestion:r.orphanedMessage.question,failedAttachments:r.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}),{chatHistoryLimit:Se("chatHistoryLimit")||15,chatHistory:r.history,uploadedFiles:Vo(r.history),loading:!1,showChat:Oo(),isFullscreen:!1,sending:!1,pageContext:null,quota:{limit:100,used:0,remaining:100},error:n,supportRequestMode:!1,setupState:!Ct()&&!Po()?{...sn(),isActive:!0}:sn()}},getters:{hasMessages:r=>r.chatHistory.length>0,isInSetupMode:r=>r.setupState.isActive,canChat:r=>!r.setupState.isActive||r.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(){await t.nextTick();const r=document.getElementById("rai-chat-bottom");r&&r.scrollIntoView({behavior:"smooth"})},parseStreamContent(r){const e=q(),n=e==null?void 0:e.parseStreamContent;return n?n(r.data):Bo(r.data)},async askQuestion(r,e=[],n=[],o=!1){var y;const s=q();if(!s)return console.warn("[RestifyAi] Cannot ask question - plugin not configured"),!1;let a="",i=!1;const l=s.retry||{},d=l.maxRetries??0,u=l.retryDelay??1e3;let p=0;const g=e.map(f=>({id:f.id,name:f.name,url:f.url,type:f.type,size:f.size,extractedText:f.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Te.User,message:r,loading:!1,attachments:g,mentions:n,timestamp:Date.now()}),g.forEach(f=>this.registerUploadedFile(f)),ot(this.chatHistory),this.sending=!0,this.chatHistory.length>=this.chatHistoryLimit&&((y=s.onError)==null||y.call(s,new Error("Chat history limit reached")));const x=async()=>{var f,E,h;try{const m=this.chatHistory.map(M=>({role:M.role,message:M.message,attachments:M.attachments??[]})),b={},C=M=>{M!=null&&M.id&&(b[M.id]={extracted_text:M.extractedText||"",file_name:M.name,mime_type:M.type||"",...M.size?{file_size:M.size}:{},...M.url?{file_url:M.url}:{}})};Object.values(this.uploadedFiles).forEach(C),this.chatHistory.forEach(M=>{var Q;(Q=M.attachments)==null||Q.forEach(C)}),g.forEach(C);const w=Object.values(b),$=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Te.Assistant,message:"",loading:!0,timestamp:Date.now()}),ot(this.chatHistory),He=new AbortController;const z=await s.getAuthToken();let S={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?S["X-Test-Api-Key"]=this.setupState.testApiKey:z&&(S.Authorization=`Bearer ${z}`);let T={question:r,history:m,stream:!0,...w.length>0&&{files:w},...n.length>0&&{mentions:n},...this.supportRequestMode&&{contact_support:!0}};s.beforeSend&&(T=await s.beforeSend(T)),s.buildRequest&&(T=await s.buildRequest(T)),(f=s.onMessageSent)==null||f.call(s,this.chatHistory[$-1]);const N=nt(s.endpoints.ask);let D={method:"POST",body:JSON.stringify(T),headers:S};return s.requestInterceptor&&(D=await s.requestInterceptor(N,D)),(E=s.onStreamStart)==null||E.call(s),await No(N,{method:"POST",body:JSON.stringify(T),signal:He.signal,headers:D.headers,openWhenHidden:!0,async onopen(M){if(!M.ok){if(M.status===429){const Q=Ae();throw Q.error={message:J("noQuota"),failedQuestion:r,failedAttachments:g,timestamp:Date.now(),quotaExceeded:!0},await Q.fetchQuota(),new Error("Quota exceeded")}throw new Error(`Failed to connect: ${M.status}`)}},onmessage:async M=>{var Re,ye,Be;const Q=this.parseStreamContent(M);if(!Q)return;this.chatHistory[$].loading=!1;const fe={content:Q,done:Q==="[DONE]",raw:M.data};(Re=s.onStreamChunk)==null||Re.call(s,fe),a?Q==="[DONE]"?(this.chatHistory[$].streaming=!1,ot(this.chatHistory),(ye=s.onStreamEnd)==null||ye.call(s,a),this.quota.remaining>0&&!this.supportRequestMode&&(this.quota.remaining--,this.quota.used++,this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0)),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[$]),(Be=s.onResponseReceived)==null||Be.call(s,this.chatHistory[$])):(a+=Q,this.chatHistory[$].message=a):(a=Q,this.chatHistory[$].message=a,this.chatHistory[$].streaming=!0),await this.scrollToBottom()},onerror(M){throw i=!0,M}}),!0}catch(m){i=!0;const b=this.chatHistory.length-1;return this.chatHistory.splice(b,1),m.name==="AbortError"?!0:p<d&&(l.shouldRetry?l.shouldRetry(m,p):!0)?(p++,await Lo(u*p),x()):(this.error={message:m.message||"Network error occurred. Please try again.",failedQuestion:r,failedAttachments:g,timestamp:Date.now()},Do({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(h=s.onError)==null||h.call(s,m),!1)}finally{this.sending=!1}};return x()},cancelRequest(){He==null||He.abort(),this.chatHistory=this.chatHistory.map(r=>({...r,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var e;const r=q();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1),_o(),(e=r==null?void 0:r.onNewChat)==null||e.call(r)},async retry(){if(!this.error.failedQuestion)return!1;const r=this.error.failedQuestion,e=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Te.User&&n.message===r&&(this.chatHistory.pop(),ot(this.chatHistory)),this.clearError(),await this.askQuestion(r,e)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},$o()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var e,n;const r=q();if((e=r==null?void 0:r.endpoints)!=null&&e.quota)try{const o=await r.getAuthToken(),s=r.getCustomHeaders?await r.getCustomHeaders():{},a=nt(r.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...o?{Authorization:`Bearer ${o}`}:{},...s}});if(i.ok){const l=await i.json(),d=l.data??l;this.quota={limit:d.limit??this.quota.limit,used:d.used??this.quota.used,remaining:d.remaining??this.quota.remaining},this.quota.remaining===0&&r.enableSupportMode!==!1&&(this.supportRequestMode=!0),(n=r.onQuotaFetched)==null||n.call(r,this.quota)}}catch(o){console.error("[RestifyAi] Failed to fetch quota:",o)}},async uploadFile(r){var s,a,i,l,d;const e=q();if(!((s=e==null?void 0:e.endpoints)!=null&&s.uploadFile))return console.warn("[RestifyAi] No uploadFile endpoint configured"),null;const o={id:crypto.randomUUID(),name:r.name,type:r.type,size:r.size,uploading:!0,progress:0};(a=e.onFileUploadStart)==null||a.call(e,o);try{const u=await e.getAuthToken(),p=e.getCustomHeaders?await e.getCustomHeaders():{},g=nt(e.endpoints.uploadFile),x=new FormData;x.append("file",r);const y=await new Promise((f,E)=>{const h=new XMLHttpRequest;h.upload.addEventListener("progress",m=>{var b;if(m.lengthComputable){const C=Math.round(m.loaded/m.total*100);o.progress=C,(b=e.onFileUploadProgress)==null||b.call(e,o,C)}}),h.addEventListener("load",()=>{var m,b;if(h.status>=200&&h.status<300)try{const C=JSON.parse(h.responseText),w={...o,url:C.url||((m=C.data)==null?void 0:m.url),extractedText:C.extracted_text||((b=C.data)==null?void 0:b.extracted_text),uploading:!1,progress:100};f(w)}catch{E(new Error("Failed to parse upload response"))}else E(new Error(`Upload failed: ${h.status}`))}),h.addEventListener("error",()=>{E(new Error("Upload failed"))}),h.open("POST",g),u&&h.setRequestHeader("Authorization",`Bearer ${u}`),Object.entries(p).forEach(([m,b])=>{h.setRequestHeader(m,b)}),h.send(x)});return(i=e.onFileUploadComplete)==null||i.call(e,y),y}catch(u){const p={...o,uploading:!1};return(l=e.onFileUploadError)==null||l.call(e,p,u),(d=e.onError)==null||d.call(e,u),null}},setPageContext(r){this.pageContext=r},toggleDrawer(){var r,e;this.showChat=!this.showChat,Tt(this.showChat),(e=(r=q())==null?void 0:r.onDrawerToggle)==null||e.call(r,this.showChat)},openDrawer(){var r,e;this.showChat=!0,Tt(!0),(e=(r=q())==null?void 0:r.onDrawerToggle)==null||e.call(r,!0)},closeDrawer(){var r,e;this.showChat=!1,Tt(!1),(e=(r=q())==null?void 0:r.onDrawerToggle)==null||e.call(r,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(r){r!=null&&r.id&&(this.uploadedFiles[r.id]={...r})},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(r){this.setupState.currentStep=r},setTestApiKey(r){this.setupState.testApiKey=r},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const r=q();if(!r)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const e={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(e["X-Test-Api-Key"]=this.setupState.testApiKey);const n=r.endpoints.quota||r.endpoints.ask,o=nt(n),s=await fetch(o,{method:r.endpoints.quota?"GET":"POST",headers:e,...r.endpoints.quota?{}:{body:JSON.stringify({question:"test",stream:!1})}});return s.ok?(this.setupState.connectionStatus="connected",this.setupState.backendConfigured=!0,!0):(this.setupState.connectionStatus="failed",this.setupState.lastError=`Connection failed: ${s.status} ${s.statusText}`,!1)}catch(e){return this.setupState.connectionStatus="failed",this.setupState.lastError=e.message||"Connection failed",!1}},completeSetup(){var r,e;this.setupState.isActive=!1,this.setupState.currentStep="complete",rn(),(e=(r=q())==null?void 0:r.onSetupComplete)==null||e.call(r)},skipSetup(){this.setupState.isActive=!1,rn()}}});function an(r){const e=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let o=r,s;for(;(s=e.exec(r))!==null;){const[a,i,l]=s,[d,u]=l.includes(":")?l.split(":"):["default",l];n.push({id:u,name:i,type:d}),o=o.replace(a,i)}return{cleanText:o,mentions:n}}function Fo(r){const{cleanText:e}=an(r);return e}function ln(r){return r.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function cn(r,e){const o=r.substring(0,e).match(/@(\w*)$/);return o?{inMention:!0,query:o[1],startPos:e-o[0].length}:{inMention:!1,query:"",startPos:-1}}function At(r,e){var n,o;return e!=null&&e.getDisplayName?e.getDisplayName(r):r.name||r.title||((n=r.attributes)==null?void 0:n.name)||((o=r.attributes)==null?void 0:o.title)||"Unknown"}function un(r,e){var n,o;return e!=null&&e.getSubtitle?e.getSubtitle(r):((n=r.attributes)==null?void 0:n.email)||((o=r.attributes)==null?void 0:o.description)||null}function Ho(r,e){return e!=null&&e.buildMentionText?e.buildMentionText(r):`@[${At(r,e)}](${r.type}:${r.id})`}function dn(r){var n;const e=q();return(n=e==null?void 0:e.mentionProviders)==null?void 0:n.find(o=>o.type===r)}function pn(r){const e=q(),n=(e==null?void 0:e.mentionProviders)||[];return r?n.filter(o=>o.routes?o.routes.some(s=>s.endsWith("*")?r.startsWith(s.slice(0,-1)):r===s||r.startsWith(s+"/")):!0):n}function fn(r){return r.map(e=>({type:e.type,id:e.id,name:e.name}))}function mn(r){return r.reduce((e,n)=>{const o=n.type||"default";return e[o]||(e[o]=[]),e[o].push(n),e},{})}function Uo(){return{extractMentions:an,parseAndCleanMessage:Fo,renderMentionsInHtml:ln,detectMentionContext:cn,getMentionDisplayName:At,getMentionSubtitle:un,buildMentionText:Ho,getMentionProvider:dn,getActiveMentionProviders:pn,formatMentionsForApi:fn,groupMentionsByType:mn}}function Mt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Me=Mt();function hn(r){Me=r}const gn=/[&<>"']/,qo=new RegExp(gn.source,"g"),yn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vo=new RegExp(yn.source,"g"),jo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},kn=r=>jo[r];function ie(r,e){if(e){if(gn.test(r))return r.replace(qo,kn)}else if(yn.test(r))return r.replace(vo,kn);return r}const Wo=/(^|[^\[])\^/g;function O(r,e){let n=typeof r=="string"?r:r.source;e=e||"";const o={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Wo,"$1"),n=n.replace(s,i),o},getRegex:()=>new RegExp(n,e)};return o}function xn(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const Ue={exec:()=>null};function wn(r,e){const n=r.replace(/\|/g,(a,i,l)=>{let d=!1,u=i;for(;--u>=0&&l[u]==="\\";)d=!d;return d?"|":" |"}),o=n.split(/ \|/);let s=0;if(o[0].trim()||o.shift(),o.length>0&&!o[o.length-1].trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;s<o.length;s++)o[s]=o[s].trim().replace(/\\\|/g,"|");return o}function qe(r,e,n){const o=r.length;if(o===0)return"";let s=0;for(;s<o&&r.charAt(o-s-1)===e;)s++;return r.slice(0,o-s)}function Go(r,e){if(r.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<r.length;o++)if(r[o]==="\\")o++;else if(r[o]===e[0])n++;else if(r[o]===e[1]&&(n--,n<0))return o;return-1}function bn(r,e,n,o){const s=e.href,a=e.title?ie(e.title):null,i=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){o.state.inLink=!0;const l={type:"link",raw:n,href:s,title:a,text:i,tokens:o.inlineTokens(i)};return o.state.inLink=!1,l}return{type:"image",raw:n,href:s,title:a,text:ie(i)}}function Ko(r,e){const n=r.match(/^(\s+)(?:```)/);if(n===null)return e;const o=n[1];return e.split(`
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,Ie){"use strict";var Ya=Object.defineProperty;var Xa=(L,e,Ie)=>e in L?Ya(L,e,{enumerable:!0,configurable:!0,writable:!0,value:Ie}):L[e]=Ie;var _=(L,e,Ie)=>Xa(L,typeof e!="symbol"?e+"":e,Ie);let Te=null;const xr=e.ref(null),Et={title:"AI Assistant",aiName:"AI Assistant",you:"You",newChat:"New chat",placeholder:"Ask me anything...",inputPlaceholder:"Ask me anything...",supportPlaceholder:"Describe your support request...",loadingText:"Thinking...",analyzingText:"Analyzing...",craftingText:"Crafting response...",quotaRemaining:"{count} questions remaining",noQuota:"No AI credit available",contactSupport:"Contact Support",close:"Close",minimize:"Minimize",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",copyToClipboard:"Copy to clipboard",copied:"Copied!",showMore:"Show more",showLess:"Show less",retry:"Retry",attachFiles:"Attach files",emptyStateTitle:"How can I help you today?",emptyStateDescription:"Ask me anything or choose a suggestion below",keyboardShortcutHint:"Press ⌘G to toggle",sendMessage:"Send message",attachFile:"Attach file",closeConfirmTitle:"Close conversation?",closeConfirmMessage:"This will clear your chat history. Are you sure you want to close?",confirmClose:"Close & Clear",cancel:"Cancel",toggleSupportMode:"Toggle support mode",exitSupportMode:"Exit support mode",historyLimitWarningTitle:"Approaching Chat Limit",historyLimitWarningMessage:"You are approaching the maximum number of messages in this conversation.",historyLimitReachedTitle:"Chat Limit Reached",historyLimitReachedMessage:"You have reached the maximum number of messages. Start a new chat to continue.",startNewChat:"Start New Chat",continueChat:"Continue",setupWelcomeTitle:"Welcome to AI Assistant",setupWelcomeDescription:"Let's get you set up to start using AI features.",setupApiKeyTitle:"API Key Configuration",setupApiKeyDescription:"Enter your API key to test the connection",setupTestingTitle:"Testing Connection...",setupBackendTitle:"Backend Configuration",setupBackendDescription:"Configure your backend endpoint",setupCompleteTitle:"Setup Complete!"};function en(r){Te=r,xr.value=r}function q(){return Te}function wr(){if(!Te)throw new Error("[@doderasoftware/restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Te}function Ct(){return Te!==null}function ee(r,t){const n=Te,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]||Et[r];return t&&Object.entries(t).forEach(([i,l])=>{a=a.replace(`{${i}}`,String(l))}),a}function tn(r){return{chatHistoryLimit:15,maxAttachments:5,maxFileSize:10485760,acceptedFileTypes:"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",chatHistoryKey:"restify_ai_chat_history",drawerStateKey:"restify_ai_drawer_open",keyboardShortcut:"cmd+g",enableSupportMode:!1}[r]}function Ae(r){const t=Te;return t?t[r]??tn(r):tn(r)}const Me={Assistant:"assistant",User:"user",System:"system"};async function br(r,t){const n=r.getReader();let o;for(;!(o=await n.read()).done;)t(o.value)}function Er(r){let t,n,o,s=!1;return function(i){t===void 0?(t=i,n=0,o=-1):t=Sr(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 Cr(r,t,n){let o=nn();const s=new TextDecoder;return function(i,l){if(i.length===0)n==null||n(o),o=nn();else if(l>0){const u=s.decode(i.subarray(0,l)),d=l+(i[l+1]===32?2:1),p=s.decode(i.subarray(d));switch(u){case"data":o.data=o.data?o.data+`
2
+ `+p:p;break;case"event":o.event=p;break;case"id":r(o.id=p);break;case"retry":const f=parseInt(p,10);isNaN(f)||t(o.retry=f);break}}}}function Sr(r,t){const n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),n}function nn(){return{data:"",event:"",id:"",retry:void 0}}var Tr=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 St="text/event-stream",Ar=1e3,rn="last-event-id";function Mr(r,t){var{signal:n,headers:o,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:u,fetch:d}=t,p=Tr(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((f,k)=>{const h=Object.assign({},o);h.accept||(h.accept=St);let m;function E(){m.abort(),document.hidden||I()}u||document.addEventListener("visibilitychange",E);let y=Ar,g=0;function b(){document.removeEventListener("visibilitychange",E),window.clearTimeout(g),m.abort()}n==null||n.addEventListener("abort",()=>{b(),f()});const C=d??window.fetch,w=s??Nr;async function I(){var $;m=new AbortController;try{const F=await C(r,Object.assign(Object.assign({},p),{headers:h,signal:m.signal}));await w(F),await br(F.body,Er(Cr(S=>{S?h[rn]=S:delete h[rn]},S=>{y=S},a))),i==null||i(),b(),f()}catch(F){if(!m.signal.aborted)try{const S=($=l==null?void 0:l(F))!==null&&$!==void 0?$:y;window.clearTimeout(g),g=window.setTimeout(I,S)}catch(S){b(),k(S)}}}I()})}function Nr(r){const t=r.headers.get("content-type");if(!(t!=null&&t.startsWith(St)))throw new Error(`Expected content-type to be ${St}, Actual: ${t}`)}function at(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=q(),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 Rr(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 Br(r){var t,n,o;try{if(r==="[DONE]")return"[DONE]";const s=JSON.parse(r);return((o=(n=(t=s==null?void 0:s.choices)==null?void 0:t[0])==null?void 0:n.delta)==null?void 0:o.content)||""}catch{return null}}function Lr(r){return new Promise(t=>setTimeout(t,r))}function Dr(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 be(r){const t=q();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 it(r){try{sessionStorage.setItem(be("chatHistory"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save chat history:",t)}}function Ir(){try{const r=sessionStorage.getItem(be("chatHistory"));if(r){const t=JSON.parse(r),n=t.filter(a=>{var i;return!(a.role===Me.Assistant&&a.loading||a.role===Me.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==t.length&&sessionStorage.setItem(be("chatHistory"),JSON.stringify(n));const o=n[n.length-1],s=(o==null?void 0:o.role)===Me.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 zr(){try{sessionStorage.removeItem(be("chatHistory"))}catch(r){console.warn("[RestifyAi] Failed to clear chat history:",r)}}function $r(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 Or(){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 Vr(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(r){console.warn("[RestifyAi] Failed to clear error state:",r)}}function Tt(r){try{localStorage.setItem(be("drawerState"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save drawer state:",t)}}function Pr(){try{const r=localStorage.getItem(be("drawerState"));if(r!==null)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load drawer state:",r)}return!1}function _r(){try{return localStorage.getItem(be("setupComplete"))==="true"}catch{return!1}}function on(){try{localStorage.setItem(be("setupComplete"),"true")}catch(r){console.warn("[RestifyAi] Failed to mark setup complete:",r)}}function sn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}let Fe=new AbortController;const Ee=Ie.defineStore("restifyAiStore",{state:()=>{const r=Ir(),t=Or();let n={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1};return t!=null&&t.message?n={message:t.message,failedQuestion:t.failedQuestion,failedAttachments:t.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:r.hasOrphanedUserMessage&&r.orphanedMessage&&(n={message:"Previous request failed. Click retry to try again.",failedQuestion:r.orphanedMessage.question,failedAttachments:r.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}),{chatHistoryLimit:Ae("chatHistoryLimit")||20,chatHistory:r.history,uploadedFiles:Dr(r.history),loading:!1,showChat:Pr(),isFullscreen:!1,sending:!1,pageContext:null,quota:{limit:100,used:0,remaining:100},error:n,supportRequestMode:!1,setupState:!Ct()&&!_r()?{...sn(),isActive:!0}:sn()}},getters:{hasMessages:r=>r.chatHistory.length>0,isInSetupMode:r=>r.setupState.isActive,canChat:r=>!r.setupState.isActive||r.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(){await e.nextTick();const r=document.getElementById("rai-chat-bottom");r&&r.scrollIntoView({behavior:"smooth"})},parseStreamContent(r){const t=q(),n=t==null?void 0:t.parseStreamContent;return n?n(r.data):Br(r.data)},async askQuestion(r,t=[],n=[],o=!1){var h;const s=q();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 p=0;const f=t.map(m=>({id:m.id,name:m.name,url:m.url,type:m.type,size:m.size,extractedText:m.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Me.User,message:r,loading:!1,attachments:f,mentions:n,timestamp:Date.now()}),f.forEach(m=>this.registerUploadedFile(m)),it(this.chatHistory),this.sending=!0,this.chatHistory.length>=this.chatHistoryLimit&&((h=s.onError)==null||h.call(s,new Error("Chat history limit reached")));const k=async()=>{var m,E,y;try{const g=this.chatHistory.map(M=>({role:M.role,message:M.message,attachments:M.attachments??[]})),b={},C=M=>{M!=null&&M.id&&(b[M.id]={extracted_text:M.extractedText||"",file_name:M.name,mime_type:M.type||"",...M.size?{file_size:M.size}:{},...M.url?{file_url:M.url}:{}})};Object.values(this.uploadedFiles).forEach(C),this.chatHistory.forEach(M=>{var K;return(K=M.attachments)==null?void 0:K.forEach(C)}),f.forEach(C);const w=Object.values(b),I=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Me.Assistant,message:"",loading:!0,timestamp:Date.now()}),it(this.chatHistory),Fe=new AbortController;const $=await s.getAuthToken(),S={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?S["X-Test-Api-Key"]=this.setupState.testApiKey:$&&(S.Authorization=`Bearer ${$}`);let T={question:r,history:g,stream:!0,...w.length>0&&{files:w},...n.length>0&&{mentions:n},...this.supportRequestMode&&{contact_support:!0}};s.beforeSend&&(T=await s.beforeSend(T)),s.buildRequest&&(T=await s.buildRequest(T)),(m=s.onMessageSent)==null||m.call(s,this.chatHistory[I-1]);const N=at(s.endpoints.ask);let z={method:"POST",body:JSON.stringify(T),headers:S};return s.requestInterceptor&&(z=await s.requestInterceptor(N,z)),(E=s.onStreamStart)==null||E.call(s),await Mr(N,{method:"POST",body:JSON.stringify(T),signal:Fe.signal,headers:z.headers,openWhenHidden:!0,async onopen(M){if(!M.ok){if(M.status===429){const K=Ee();throw K.error={message:ee("noQuota"),failedQuestion:r,failedAttachments:f,timestamp:Date.now(),quotaExceeded:!0},await K.fetchQuota(),new Error("Quota exceeded")}throw new Error(`Failed to connect: ${M.status}`)}},onmessage:async M=>{var ze,Be,ge;const K=this.parseStreamContent(M);if(!K)return;this.chatHistory[I].loading=!1;const me={content:K,done:K==="[DONE]",raw:M.data};(ze=s.onStreamChunk)==null||ze.call(s,me),a?K==="[DONE]"?(this.chatHistory[I].streaming=!1,it(this.chatHistory),(Be=s.onStreamEnd)==null||Be.call(s,a),this.quota.remaining>0&&!this.supportRequestMode&&(this.quota.remaining--,this.quota.used++,this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0)),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[I]),(ge=s.onResponseReceived)==null||ge.call(s,this.chatHistory[I])):(a+=K,this.chatHistory[I].message=a):(a=K,this.chatHistory[I].message=a,this.chatHistory[I].streaming=!0),await this.scrollToBottom()},onerror(M){throw i=!0,M}}),!0}catch(g){i=!0;const b=this.chatHistory.length-1;return this.chatHistory.splice(b,1),g.name==="AbortError"?!0:p<u&&(l.shouldRetry?l.shouldRetry(g,p):!0)?(p++,await Lr(d*p),k()):(this.error={message:Rr(g),failedQuestion:r,failedAttachments:f,timestamp:Date.now()},$r({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(y=s.onError)==null||y.call(s,g),!1)}finally{this.sending=!1}};return k()},cancelRequest(){Fe==null||Fe.abort(),this.chatHistory=this.chatHistory.map(r=>({...r,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var t;const r=q();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1),zr(),(t=r==null?void 0:r.onNewChat)==null||t.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)===Me.User&&n.message===r&&(this.chatHistory.pop(),it(this.chatHistory)),this.clearError(),await this.askQuestion(r,t)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},Vr()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var t,n;const r=q();if((t=r==null?void 0:r.endpoints)!=null&&t.quota)try{const o=await r.getAuthToken(),s=r.getCustomHeaders?await r.getCustomHeaders():{},a=at(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=q();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(),p=t.getCustomHeaders?await t.getCustomHeaders():{},f=at(t.endpoints.uploadFile),k=new FormData;k.append("file",r);const h=await new Promise((m,E)=>{const y=new XMLHttpRequest;y.upload.addEventListener("progress",g=>{var b;if(g.lengthComputable){const C=Math.round(g.loaded/g.total*100);o.progress=C,(b=t.onFileUploadProgress)==null||b.call(t,o,C)}}),y.addEventListener("load",()=>{var g,b;if(y.status>=200&&y.status<300)try{const C=JSON.parse(y.responseText),w={...o,url:C.url||((g=C.data)==null?void 0:g.url),extractedText:C.extracted_text||((b=C.data)==null?void 0:b.extracted_text),uploading:!1,progress:100};m(w)}catch{E(new Error("Failed to parse upload response"))}else E(new Error(`Upload failed: ${y.status}`))}),y.addEventListener("error",()=>E(new Error("Upload failed"))),y.open("POST",f),d&&y.setRequestHeader("Authorization",`Bearer ${d}`),Object.entries(p).forEach(([g,b])=>y.setRequestHeader(g,b)),y.send(k)});return(i=t.onFileUploadComplete)==null||i.call(t,h),h}catch(d){const p={...o,uploading:!1};return(l=t.onFileUploadError)==null||l.call(t,p,d),(u=t.onError)==null||u.call(t,d),null}},setPageContext(r){this.pageContext=r},toggleDrawer(){var r,t;this.showChat=!this.showChat,Tt(this.showChat),(t=(r=q())==null?void 0:r.onDrawerToggle)==null||t.call(r,this.showChat)},openDrawer(){var r,t;this.showChat=!0,Tt(!0),(t=(r=q())==null?void 0:r.onDrawerToggle)==null||t.call(r,!0)},closeDrawer(){var r,t;this.showChat=!1,Tt(!1),(t=(r=q())==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=q();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=at(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",on(),(t=(r=q())==null?void 0:r.onSetupComplete)==null||t.call(r)},skipSetup(){this.setupState.isActive=!1,on()}}});function an(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 Fr(r){const{cleanText:t}=an(r);return t}function ln(r){return r.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function cn(r,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 At(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 un(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 Hr(r,t){return t!=null&&t.buildMentionText?t.buildMentionText(r):`@[${At(r,t)}](${r.type}:${r.id})`}function dn(r){var n;const t=q();return(n=t==null?void 0:t.mentionProviders)==null?void 0:n.find(o=>o.type===r)}function pn(r){const t=q(),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 mn(r){return r.map(t=>({type:t.type,id:t.id,name:t.name}))}function fn(r){return r.reduce((t,n)=>{const o=n.type||"default";return t[o]||(t[o]=[]),t[o].push(n),t},{})}function Ur(){return{extractMentions:an,parseAndCleanMessage:Fr,renderMentionsInHtml:ln,detectMentionContext:cn,getMentionDisplayName:At,getMentionSubtitle:un,buildMentionText:Hr,getMentionProvider:dn,getActiveMentionProviders:pn,formatMentionsForApi:mn,groupMentionsByType:fn}}function Mt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ne=Mt();function hn(r){Ne=r}const gn=/[&<>"']/,qr=new RegExp(gn.source,"g"),yn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vr=new RegExp(yn.source,"g"),jr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},kn=r=>jr[r];function ie(r,t){if(t){if(gn.test(r))return r.replace(qr,kn)}else if(yn.test(r))return r.replace(vr,kn);return r}const Wr=/(^|[^\[])\^/g;function P(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(Wr,"$1"),n=n.replace(s,i),o},getRegex:()=>new RegExp(n,t)};return o}function xn(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const He={exec:()=>null};function wn(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 Ue(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 Kr(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?ie(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:ie(i)}}function Gr(r,t){const n=r.match(/^(\s+)(?:```)/);if(n===null)return t;const o=n[1];return t.split(`
3
3
  `).map(s=>{const a=s.match(/^\s+/);if(a===null)return s;const[i]=a;return i.length>=o.length?s.slice(o.length):s}).join(`
4
- `)}class rt{constructor(e){P(this,"options");P(this,"rules");P(this,"lexer");this.options=e||Me}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const o=n[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?o:qe(o,`
5
- `)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const o=n[0],s=Ko(o,n[3]||"");return{type:"code",raw:o,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:s}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let o=n[2].trim();if(/#$/.test(o)){const s=qe(o,"#");(this.options.pedantic||!s||/ $/.test(s))&&(o=s.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:o,tokens:this.lexer.inline(o)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:qe(n[0],`
6
- `)}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){let o=qe(n[0],`
4
+ `)}class lt{constructor(t){_(this,"options");_(this,"rules");_(this,"lexer");this.options=t||Ne}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:Ue(o,`
5
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const o=n[0],s=Gr(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=Ue(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:Ue(n[0],`
6
+ `)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let o=Ue(n[0],`
7
7
  `).split(`
8
- `),s="",a="";const i=[];for(;o.length>0;){let l=!1;const d=[];let u;for(u=0;u<o.length;u++)if(/^ {0,3}>/.test(o[u]))d.push(o[u]),l=!0;else if(!l)d.push(o[u]);else break;o=o.slice(u);const p=d.join(`
9
- `),g=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
8
+ `),s="",a="";const i=[];for(;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 p=u.join(`
9
+ `),f=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
10
10
  $1`).replace(/^ {0,3}>[ \t]?/gm,"");s=s?`${s}
11
11
  ${p}`:p,a=a?`${a}
12
- ${g}`:g;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(g,i,!0),this.lexer.state.top=x,o.length===0)break;const y=i[i.length-1];if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){const f=y,E=f.raw+`
12
+ ${f}`:f;const k=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,i,!0),this.lexer.state.top=k,o.length===0)break;const h=i[i.length-1];if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){const m=h,E=m.raw+`
13
13
  `+o.join(`
14
- `),h=this.blockquote(E);i[i.length-1]=h,s=s.substring(0,s.length-f.raw.length)+h.raw,a=a.substring(0,a.length-f.text.length)+h.text;break}else if((y==null?void 0:y.type)==="list"){const f=y,E=f.raw+`
14
+ `),y=this.blockquote(E);i[i.length-1]=y,s=s.substring(0,s.length-m.raw.length)+y.raw,a=a.substring(0,a.length-m.text.length)+y.text;break}else if((h==null?void 0:h.type)==="list"){const m=h,E=m.raw+`
15
15
  `+o.join(`
16
- `),h=this.list(E);i[i.length-1]=h,s=s.substring(0,s.length-y.raw.length)+h.raw,a=a.substring(0,a.length-f.raw.length)+h.raw,o=E.substring(i[i.length-1].raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(e){let n=this.rules.block.list.exec(e);if(n){let o=n[1].trim();const s=o.length>1,a={type:"list",raw:"",ordered:s,start:s?+o.slice(0,-1):"",loose:!1,items:[]};o=s?`\\d{1,9}\\${o.slice(-1)}`:`\\${o}`,this.options.pedantic&&(o=s?o:"[*+-]");const i=new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;e;){let d=!1,u="",p="";if(!(n=i.exec(e))||this.rules.block.hr.test(e))break;u=n[0],e=e.substring(u.length);let g=n[2].split(`
18
- `,1)[0].replace(/^\t+/,m=>" ".repeat(3*m.length)),x=e.split(`
19
- `,1)[0],y=!g.trim(),f=0;if(this.options.pedantic?(f=2,p=g.trimStart()):y?f=n[1].length+1:(f=n[2].search(/[^ ]/),f=f>4?1:f,p=g.slice(f),f+=n[1].length),y&&/^[ \t]*$/.test(x)&&(u+=x+`
20
- `,e=e.substring(x.length+1),d=!0),!d){const m=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),w=new RegExp(`^ {0,${Math.min(3,f-1)}}#`),$=new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i");for(;e;){const z=e.split(`
21
- `,1)[0];let F;if(x=z,this.options.pedantic?(x=x.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),F=x):F=x.replace(/\t/g," "),C.test(x)||w.test(x)||$.test(x)||m.test(x)||b.test(x))break;if(F.search(/[^ ]/)>=f||!x.trim())p+=`
22
- `+F.slice(f);else{if(y||g.replace(/\t/g," ").search(/[^ ]/)>=4||C.test(g)||w.test(g)||b.test(g))break;p+=`
23
- `+x}!y&&!x.trim()&&(y=!0),u+=z+`
24
- `,e=e.substring(z.length+1),g=F.slice(f)}}a.loose||(l?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(u)&&(l=!0));let E=null,h;this.options.gfm&&(E=/^\[[ xX]\] /.exec(p),E&&(h=E[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:u,task:!!E,checked:h,loose:!1,text:p,tokens:[]}),a.raw+=u}a.items[a.items.length-1].raw=a.items[a.items.length-1].raw.trimEnd(),a.items[a.items.length-1].text=a.items[a.items.length-1].text.trimEnd(),a.raw=a.raw.trimEnd();for(let d=0;d<a.items.length;d++)if(this.lexer.state.top=!1,a.items[d].tokens=this.lexer.blockTokens(a.items[d].text,[]),!a.loose){const u=a.items[d].tokens.filter(g=>g.type==="space"),p=u.length>0&&u.some(g=>/\n.*\n/.test(g.raw));a.loose=p}if(a.loose)for(let d=0;d<a.items.length;d++)a.items[d].loose=!0;return a}}html(e){const n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:n[0]}}def(e){const n=this.rules.block.def.exec(e);if(n){const o=n[1].toLowerCase().replace(/\s+/g," "),s=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:o,raw:n[0],href:s,title:a}}}table(e){const n=this.rules.block.table.exec(e);if(!n||!/[:|]/.test(n[2]))return;const o=wn(n[1]),s=n[2].replace(/^\||\| *$/g,"").split("|"),a=n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
25
- `):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(o.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?i.align.push("right"):/^ *:-+: *$/.test(l)?i.align.push("center"):/^ *:-+ *$/.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<o.length;l++)i.header.push({text:o[l],tokens:this.lexer.inline(o[l]),header:!0,align:i.align[l]});for(const l of a)i.rows.push(wn(l,i.header.length).map((d,u)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:i.align[u]})));return i}}lheading(e){const n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){const n=this.rules.block.paragraph.exec(e);if(n){const o=n[1].charAt(n[1].length-1)===`
26
- `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:o,tokens:this.lexer.inline(o)}}}text(e){const n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){const n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:ie(n[1])}}tag(e){const n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const o=n[2].trim();if(!this.options.pedantic&&/^</.test(o)){if(!/>$/.test(o))return;const i=qe(o.slice(0,-1),"\\");if((o.length-i.length)%2===0)return}else{const i=Go(n[2],"()");if(i>-1){const d=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,d).trim(),n[3]=""}}let s=n[2],a="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);i&&(s=i[1],a=i[3])}else a=n[3]?n[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(o)?s=s.slice(1):s=s.slice(1,-1)),bn(n,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer)}}reflink(e,n){let o;if((o=this.rules.inline.reflink.exec(e))||(o=this.rules.inline.nolink.exec(e))){const s=(o[2]||o[1]).replace(/\s+/g," "),a=n[s.toLowerCase()];if(!a){const i=o[0].charAt(0);return{type:"text",raw:i,text:i}}return bn(o,a,o[0],this.lexer)}}emStrong(e,n,o=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||s[3]&&o.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!o||this.rules.inline.punctuation.exec(o)){const i=[...s[0]].length-1;let l,d,u=i,p=0;const g=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,n=n.slice(-1*e.length+i);(s=g.exec(n))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(d=[...l].length,s[3]||s[4]){u+=d;continue}else if((s[5]||s[6])&&i%3&&!((i+d)%3)){p+=d;continue}if(u-=d,u>0)continue;d=Math.min(d,d+u+p);const x=[...s[0]][0].length,y=e.slice(0,i+s.index+x+d);if(Math.min(i,d)%2){const E=y.slice(1,-1);return{type:"em",raw:y,text:E,tokens:this.lexer.inlineTokens(E)}}const f=y.slice(2,-2);return{type:"strong",raw:y,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let o=n[2].replace(/\n/g," ");const s=/[^ ]/.test(o),a=/^ /.test(o)&&/ $/.test(o);return s&&a&&(o=o.substring(1,o.length-1)),o=ie(o,!0),{type:"codespan",raw:n[0],text:o}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){const n=this.rules.inline.autolink.exec(e);if(n){let o,s;return n[2]==="@"?(o=ie(n[1]),s="mailto:"+o):(o=ie(n[1]),s=o),{type:"link",raw:n[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(e){var o;let n;if(n=this.rules.inline.url.exec(e)){let s,a;if(n[2]==="@")s=ie(n[0]),a="mailto:"+s;else{let i;do i=n[0],n[0]=((o=this.rules.inline._backpedal.exec(n[0]))==null?void 0:o[0])??"";while(i!==n[0]);s=ie(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){const n=this.rules.inline.text.exec(e);if(n){let o;return this.lexer.state.inRawBlock?o=n[0]:o=ie(n[0]),{type:"text",raw:n[0],text:o}}}}const Qo=/^(?:[ \t]*(?:\n|$))+/,Zo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ve=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,En=/(?:[*+-]|\d{1,9}[.)])/,Cn=O(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,En).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Nt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Jo=/^[^\n]+/,Rt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,er=O(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),tr=O(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,En).getRegex(),st="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Bt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nr=O("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Bt).replace("tag",st).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sn=O(Nt).replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex(),Lt={blockquote:O(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Sn).getRegex(),code:Zo,def:er,fences:Yo,heading:Xo,hr:ve,html:nr,lheading:Cn,list:tr,newline:Qo,paragraph:Sn,table:Ue,text:Jo},Tn=O("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex(),or={...Lt,table:Tn,paragraph:O(Nt).replace("hr",ve).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Tn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",st).getRegex()},rr={...Lt,html:O(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ue,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:O(Nt).replace("hr",ve).replace("heading",` *#{1,6} *[^
27
- ]`).replace("lheading",Cn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},An=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,sr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mn=/^( {2,}|\\)\n(?!\s*$)/,ar=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,je="\\p{P}\\p{S}",ir=O(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,je).getRegex(),lr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,cr=O(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,je).getRegex(),ur=O("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,je).getRegex(),dr=O("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,je).getRegex(),pr=O(/\\([punct])/,"gu").replace(/punct/g,je).getRegex(),fr=O(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),mr=O(Bt).replace("(?:-->|$)","-->").getRegex(),hr=O("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",mr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),at=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,gr=O(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",at).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nn=O(/^!?\[(label)\]\[(ref)\]/).replace("label",at).replace("ref",Rt).getRegex(),Rn=O(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rt).getRegex(),yr=O("reflink|nolink(?!\\()","g").replace("reflink",Nn).replace("nolink",Rn).getRegex(),Dt={_backpedal:Ue,anyPunctuation:pr,autolink:fr,blockSkip:lr,br:Mn,code:sr,del:Ue,emStrongLDelim:cr,emStrongRDelimAst:ur,emStrongRDelimUnd:dr,escape:An,link:gr,nolink:Rn,punctuation:ir,reflink:Nn,reflinkSearch:yr,tag:hr,text:ar,url:Ue},kr={...Dt,link:O(/^!?\[(label)\]\((.*?)\)/).replace("label",at).getRegex(),reflink:O(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",at).getRegex()},It={...Dt,escape:O(An).replace("])","~|])").getRegex(),url:O(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},xr={...It,br:O(Mn).replace("{2,}","*").getRegex(),text:O(It.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},it={normal:Lt,gfm:or,pedantic:rr},We={normal:Dt,gfm:It,breaks:xr,pedantic:kr};class le{constructor(e){P(this,"tokens");P(this,"options");P(this,"state");P(this,"tokenizer");P(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Me,this.options.tokenizer=this.options.tokenizer||new rt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:it.normal,inline:We.normal};this.options.pedantic?(n.block=it.pedantic,n.inline=We.pedantic):this.options.gfm&&(n.block=it.gfm,this.options.breaks?n.inline=We.breaks:n.inline=We.gfm),this.tokenizer.rules=n}static get rules(){return{block:it,inline:We}}static lex(e,n){return new le(n).lex(e)}static lexInline(e,n){return new le(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
28
- `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],o=!1){this.options.pedantic&&(e=e.replace(/\t/g," ").replace(/^ +$/gm,""));let s,a,i;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(s=l.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))){if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length),s.raw.length===1&&n.length>0?n[n.length-1].raw+=`
29
- `:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
16
+ `),y=this.list(E);i[i.length-1]=y,s=s.substring(0,s.length-h.raw.length)+y.raw,a=a.substring(0,a.length-m.raw.length)+y.raw,o=E.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="",p="";if(!(n=i.exec(t))||this.rules.block.hr.test(t))break;d=n[0],t=t.substring(d.length);let f=n[2].split(`
18
+ `,1)[0].replace(/^\t+/,g=>" ".repeat(3*g.length)),k=t.split(`
19
+ `,1)[0],h=!f.trim(),m=0;if(this.options.pedantic?(m=2,p=f.trimStart()):h?m=n[1].length+1:(m=n[2].search(/[^ ]/),m=m>4?1:m,p=f.slice(m),m+=n[1].length),h&&/^[ \t]*$/.test(k)&&(d+=k+`
20
+ `,t=t.substring(k.length+1),u=!0),!u){const g=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),w=new RegExp(`^ {0,${Math.min(3,m-1)}}#`),I=new RegExp(`^ {0,${Math.min(3,m-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const $=t.split(`
21
+ `,1)[0];let F;if(k=$,this.options.pedantic?(k=k.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),F=k):F=k.replace(/\t/g," "),C.test(k)||w.test(k)||I.test(k)||g.test(k)||b.test(k))break;if(F.search(/[^ ]/)>=m||!k.trim())p+=`
22
+ `+F.slice(m);else{if(h||f.replace(/\t/g," ").search(/[^ ]/)>=4||C.test(f)||w.test(f)||b.test(f))break;p+=`
23
+ `+k}!h&&!k.trim()&&(h=!0),d+=$+`
24
+ `,t=t.substring($.length+1),f=F.slice(m)}}a.loose||(l?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(l=!0));let E=null,y;this.options.gfm&&(E=/^\[[ xX]\] /.exec(p),E&&(y=E[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:d,task:!!E,checked:y,loose:!1,text:p,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(f=>f.type==="space"),p=d.length>0&&d.some(f=>/\n.*\n/.test(f.raw));a.loose=p}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=wn(n[1]),s=n[2].replace(/^\||\| *$/g,"").split("|"),a=n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
25
+ `):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(o.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?i.align.push("right"):/^ *:-+: *$/.test(l)?i.align.push("center"):/^ *:-+ *$/.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<o.length;l++)i.header.push({text:o[l],tokens:this.lexer.inline(o[l]),header:!0,align:i.align[l]});for(const l of a)i.rows.push(wn(l,i.header.length).map((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:ie(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=Ue(o.slice(0,-1),"\\");if((o.length-i.length)%2===0)return}else{const i=Kr(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,p=0;const f=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(s=f.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)){p+=u;continue}if(d-=u,d>0)continue;u=Math.min(u,u+d+p);const k=[...s[0]][0].length,h=t.slice(0,i+s.index+k+u);if(Math.min(i,u)%2){const E=h.slice(1,-1);return{type:"em",raw:h,text:E,tokens:this.lexer.inlineTokens(E)}}const m=h.slice(2,-2);return{type:"strong",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}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=ie(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=ie(n[1]),s="mailto:"+o):(o=ie(n[1]),s=o),{type:"link",raw:n[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t){var o;let n;if(n=this.rules.inline.url.exec(t)){let s,a;if(n[2]==="@")s=ie(n[0]),a="mailto:"+s;else{let i;do i=n[0],n[0]=((o=this.rules.inline._backpedal.exec(n[0]))==null?void 0:o[0])??"";while(i!==n[0]);s=ie(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){const n=this.rules.inline.text.exec(t);if(n){let o;return this.lexer.state.inRawBlock?o=n[0]:o=ie(n[0]),{type:"text",raw:n[0],text:o}}}}const Qr=/^(?:[ \t]*(?:\n|$))+/,Zr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,qe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,En=/(?:[*+-]|\d{1,9}[.)])/,Cn=P(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,En).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Nt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Jr=/^[^\n]+/,Rt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,eo=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),to=P(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,En).getRegex(),ct="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Bt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,no=P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Bt).replace("tag",ct).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sn=P(Nt).replace("hr",qe).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",ct).getRegex(),Lt={blockquote:P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Sn).getRegex(),code:Zr,def:eo,fences:Yr,heading:Xr,hr:qe,html:no,lheading:Cn,list:to,newline:Qr,paragraph:Sn,table:He,text:Jr},Tn=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",qe).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",ct).getRegex(),ro={...Lt,table:Tn,paragraph:P(Nt).replace("hr",qe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Tn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ct).getRegex()},oo={...Lt,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:He,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Nt).replace("hr",qe).replace("heading",` *#{1,6} *[^
27
+ ]`).replace("lheading",Cn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},An=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,so=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mn=/^( {2,}|\\)\n(?!\s*$)/,ao=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ve="\\p{P}\\p{S}",io=P(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ve).getRegex(),lo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,co=P(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ve).getRegex(),uo=P("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ve).getRegex(),po=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ve).getRegex(),mo=P(/\\([punct])/,"gu").replace(/punct/g,ve).getRegex(),fo=P(/^<(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(),ho=P(Bt).replace("(?:-->|$)","-->").getRegex(),go=P("^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",ho).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ut=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,yo=P(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",ut).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nn=P(/^!?\[(label)\]\[(ref)\]/).replace("label",ut).replace("ref",Rt).getRegex(),Rn=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rt).getRegex(),ko=P("reflink|nolink(?!\\()","g").replace("reflink",Nn).replace("nolink",Rn).getRegex(),Dt={_backpedal:He,anyPunctuation:mo,autolink:fo,blockSkip:lo,br:Mn,code:so,del:He,emStrongLDelim:co,emStrongRDelimAst:uo,emStrongRDelimUnd:po,escape:An,link:yo,nolink:Rn,punctuation:io,reflink:Nn,reflinkSearch:ko,tag:go,text:ao,url:He},xo={...Dt,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",ut).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ut).getRegex()},It={...Dt,escape:P(An).replace("])","~|])").getRegex(),url:P(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},wo={...It,br:P(Mn).replace("{2,}","*").getRegex(),text:P(It.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},dt={normal:Lt,gfm:ro,pedantic:oo},je={normal:Dt,gfm:It,breaks:wo,pedantic:xo};class le{constructor(t){_(this,"tokens");_(this,"options");_(this,"state");_(this,"tokenizer");_(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ne,this.options.tokenizer=this.options.tokenizer||new lt,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:dt.normal,inline:je.normal};this.options.pedantic?(n.block=dt.pedantic,n.inline=je.pedantic):this.options.gfm&&(n.block=dt.gfm,this.options.breaks?n.inline=je.breaks:n.inline=je.gfm),this.tokenizer.rules=n}static get rules(){return{block:dt,inline:je}}static lex(t,n){return new le(n).lex(t)}static lexInline(t,n){return new le(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
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(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
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
32
  `+s.raw,a.text+=`
33
- `+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(i=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const d=e.slice(1);let u;this.options.extensions.startBlock.forEach(p=>{u=p.call({lexer:this},d),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(i=e.substring(0,l+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){a=n[n.length-1],o&&(a==null?void 0:a.type)==="paragraph"?(a.raw+=`
33
+ `+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(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(p=>{d=p.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
34
  `+s.raw,a.text+=`
35
- `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s),o=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length),a=n[n.length-1],a&&a.type==="text"?(a.raw+=`
35
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s),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
36
  `+s.raw,a.text+=`
37
- `+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let o,s,a,i=e,l,d,u;if(this.tokens.links){const p=Object.keys(this.tokens.links);if(p.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)p.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,l.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(d||(u=""),d=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(o=p.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))){if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),s=n[n.length-1],s&&o.type==="text"&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length),s=n[n.length-1],s&&o.type==="text"&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(o=this.tokenizer.emStrong(e,i,u)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),n.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),n.push(o);continue}if(a=e,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const g=e.slice(1);let x;this.options.extensions.startInline.forEach(y=>{x=y.call({lexer:this},g),typeof x=="number"&&x>=0&&(p=Math.min(p,x))}),p<1/0&&p>=0&&(a=e.substring(0,p+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(u=o.raw.slice(-1)),d=!0,s=n[n.length-1],s&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(e){const p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return n}}class lt{constructor(e){P(this,"options");P(this,"parser");this.options=e||Me}space(e){return""}code({text:e,lang:n,escaped:o}){var i;const s=(i=(n||"").match(/^\S*/))==null?void 0:i[0],a=e.replace(/\n$/,"")+`
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 p=Object.keys(this.tokens.links);if(p.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)p.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,l.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(u||(d=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(o=p.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 p=1/0;const f=t.slice(1);let k;this.options.extensions.startInline.forEach(h=>{k=h.call({lexer:this},f),typeof k=="number"&&k>=0&&(p=Math.min(p,k))}),p<1/0&&p>=0&&(a=t.substring(0,p+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 p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return n}}class pt{constructor(t){_(this,"options");_(this,"parser");this.options=t||Ne}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
38
  `;return s?'<pre><code class="language-'+ie(s)+'">'+(o?a:ie(a,!0))+`</code></pre>
39
39
  `:"<pre><code>"+(o?a:ie(a,!0))+`</code></pre>
40
- `}blockquote({tokens:e}){return`<blockquote>
41
- ${this.parser.parse(e)}</blockquote>
42
- `}html({text:e}){return e}heading({tokens:e,depth:n}){return`<h${n}>${this.parser.parseInline(e)}</h${n}>
43
- `}hr(e){return`<hr>
44
- `}list(e){const n=e.ordered,o=e.start;let s="";for(let l=0;l<e.items.length;l++){const d=e.items[l];s+=this.listitem(d)}const a=n?"ol":"ul",i=n&&o!==1?' start="'+o+'"':"";return"<"+a+i+`>
40
+ `}blockquote({tokens:t}){return`<blockquote>
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}>
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
45
  `+s+"</"+a+`>
46
- `}listitem(e){let n="";if(e.task){const o=this.checkbox({checked:!!e.checked});e.loose?e.tokens.length>0&&e.tokens[0].type==="paragraph"?(e.tokens[0].text=o+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=o+" "+e.tokens[0].tokens[0].text)):e.tokens.unshift({type:"text",raw:o+" ",text:o+" "}):n+=o+" "}return n+=this.parser.parse(e.tokens,!!e.loose),`<li>${n}</li>
47
- `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
48
- `}table(e){let n="",o="";for(let a=0;a<e.header.length;a++)o+=this.tablecell(e.header[a]);n+=this.tablerow({text:o});let s="";for(let a=0;a<e.rows.length;a++){const i=e.rows[a];o="";for(let l=0;l<i.length;l++)o+=this.tablecell(i[l]);s+=this.tablerow({text:o})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
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>
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>
49
49
  <thead>
50
50
  `+n+`</thead>
51
51
  `+s+`</table>
52
- `}tablerow({text:e}){return`<tr>
53
- ${e}</tr>
54
- `}tablecell(e){const n=this.parser.parseInline(e.tokens),o=e.header?"th":"td";return(e.align?`<${o} align="${e.align}">`:`<${o}>`)+n+`</${o}>
55
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${e}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:o}){const s=this.parser.parseInline(o),a=xn(e);if(a===null)return s;e=a;let i='<a href="'+e+'"';return n&&(i+=' title="'+n+'"'),i+=">"+s+"</a>",i}image({href:e,title:n,text:o}){const s=xn(e);if(s===null)return o;e=s;let a=`<img src="${e}" alt="${o}"`;return n&&(a+=` title="${n}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):e.text}}class $t{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class ce{constructor(e){P(this,"options");P(this,"renderer");P(this,"textRenderer");this.options=e||Me,this.options.renderer=this.options.renderer||new lt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $t}static parse(e,n){return new ce(n).parse(e)}static parseInline(e,n){return new ce(n).parseInline(e)}parse(e,n=!0){let o="";for(let s=0;s<e.length;s++){const a=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=a,d=this.options.extensions.renderers[l.type].call({parser:this},l);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){o+=d||"";continue}}const i=a;switch(i.type){case"space":{o+=this.renderer.space(i);continue}case"hr":{o+=this.renderer.hr(i);continue}case"heading":{o+=this.renderer.heading(i);continue}case"code":{o+=this.renderer.code(i);continue}case"table":{o+=this.renderer.table(i);continue}case"blockquote":{o+=this.renderer.blockquote(i);continue}case"list":{o+=this.renderer.list(i);continue}case"html":{o+=this.renderer.html(i);continue}case"paragraph":{o+=this.renderer.paragraph(i);continue}case"text":{let l=i,d=this.renderer.text(l);for(;s+1<e.length&&e[s+1].type==="text";)l=e[++s],d+=`
56
- `+this.renderer.text(l);n?o+=this.renderer.paragraph({type:"paragraph",raw:d,text:d,tokens:[{type:"text",raw:d,text:d}]}):o+=d;continue}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}parseInline(e,n){n=n||this.renderer;let o="";for(let s=0;s<e.length;s++){const a=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){o+=l||"";continue}}const i=a;switch(i.type){case"escape":{o+=n.text(i);break}case"html":{o+=n.html(i);break}case"link":{o+=n.link(i);break}case"image":{o+=n.image(i);break}case"strong":{o+=n.strong(i);break}case"em":{o+=n.em(i);break}case"codespan":{o+=n.codespan(i);break}case"br":{o+=n.br(i);break}case"del":{o+=n.del(i);break}case"text":{o+=n.text(i);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}}class Ge{constructor(e){P(this,"options");P(this,"block");this.options=e||Me}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?le.lex:le.lexInline}provideParser(){return this.block?ce.parse:ce.parseInline}}P(Ge,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class wr{constructor(...e){P(this,"defaults",Mt());P(this,"options",this.setOptions);P(this,"parse",this.parseMarkdown(!0));P(this,"parseInline",this.parseMarkdown(!1));P(this,"Parser",ce);P(this,"Renderer",lt);P(this,"TextRenderer",$t);P(this,"Lexer",le);P(this,"Tokenizer",rt);P(this,"Hooks",Ge);this.use(...e)}walkTokens(e,n){var s,a;let o=[];for(const i of e)switch(o=o.concat(n.call(this,i)),i.type){case"table":{const l=i;for(const d of l.header)o=o.concat(this.walkTokens(d.tokens,n));for(const d of l.rows)for(const u of d)o=o.concat(this.walkTokens(u.tokens,n));break}case"list":{const l=i;o=o.concat(this.walkTokens(l.items,n));break}default:{const l=i;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[l.type]?this.defaults.extensions.childTokens[l.type].forEach(d=>{const u=l[d].flat(1/0);o=o.concat(this.walkTokens(u,n))}):l.tokens&&(o=o.concat(this.walkTokens(l.tokens,n)))}}return o}use(...e){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(o=>{const s={...o};if(s.async=this.defaults.async||s.async||!1,o.extensions&&(o.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=n.renderers[a.name];i?n.renderers[a.name]=function(...l){let d=a.renderer.apply(this,l);return d===!1&&(d=i.apply(this,l)),d}:n.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=n[a.level];i?i.unshift(a.tokenizer):n[a.level]=[a.tokenizer],a.start&&(a.level==="block"?n.startBlock?n.startBlock.push(a.start):n.startBlock=[a.start]:a.level==="inline"&&(n.startInline?n.startInline.push(a.start):n.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(n.childTokens[a.name]=a.childTokens)}),s.extensions=n),o.renderer){const a=this.defaults.renderer||new lt(this.defaults);for(const i in o.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const l=i,d=o.renderer[l],u=a[l];a[l]=(...p)=>{let g=d.apply(a,p);return g===!1&&(g=u.apply(a,p)),g||""}}s.renderer=a}if(o.tokenizer){const a=this.defaults.tokenizer||new rt(this.defaults);for(const i in o.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const l=i,d=o.tokenizer[l],u=a[l];a[l]=(...p)=>{let g=d.apply(a,p);return g===!1&&(g=u.apply(a,p)),g}}s.tokenizer=a}if(o.hooks){const a=this.defaults.hooks||new Ge;for(const i in o.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const l=i,d=o.hooks[l],u=a[l];Ge.passThroughHooks.has(i)?a[l]=p=>{if(this.defaults.async)return Promise.resolve(d.call(a,p)).then(x=>u.call(a,x));const g=d.call(a,p);return u.call(a,g)}:a[l]=(...p)=>{let g=d.apply(a,p);return g===!1&&(g=u.apply(a,p)),g}}s.hooks=a}if(o.walkTokens){const a=this.defaults.walkTokens,i=o.walkTokens;s.walkTokens=function(l){let d=[];return d.push(i.call(this,l)),a&&(d=d.concat(a.call(this,l))),d}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return le.lex(e,n??this.defaults)}parser(e,n){return ce.parse(e,n??this.defaults)}parseMarkdown(e){return(o,s)=>{const a={...s},i={...this.defaults,...a},l=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&a.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof o>"u"||o===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const d=i.hooks?i.hooks.provideLexer():e?le.lex:le.lexInline,u=i.hooks?i.hooks.provideParser():e?ce.parse:ce.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(o):o).then(p=>d(p,i)).then(p=>i.hooks?i.hooks.processAllTokens(p):p).then(p=>i.walkTokens?Promise.all(this.walkTokens(p,i.walkTokens)).then(()=>p):p).then(p=>u(p,i)).then(p=>i.hooks?i.hooks.postprocess(p):p).catch(l);try{i.hooks&&(o=i.hooks.preprocess(o));let p=d(o,i);i.hooks&&(p=i.hooks.processAllTokens(p)),i.walkTokens&&this.walkTokens(p,i.walkTokens);let g=u(p,i);return i.hooks&&(g=i.hooks.postprocess(g)),g}catch(p){return l(p)}}}onError(e,n){return o=>{if(o.message+=`
57
- Please report this to https://github.com/markedjs/marked.`,e){const s="<p>An error occurred:</p><pre>"+ie(o.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(o);throw o}}}const Ne=new wr;function _(r,e){return Ne.parse(r,e)}_.options=_.setOptions=function(r){return Ne.setOptions(r),_.defaults=Ne.defaults,hn(_.defaults),_},_.getDefaults=Mt,_.defaults=Me,_.use=function(...r){return Ne.use(...r),_.defaults=Ne.defaults,hn(_.defaults),_},_.walkTokens=function(r,e){return Ne.walkTokens(r,e)},_.parseInline=Ne.parseInline,_.Parser=ce,_.parser=ce.parse,_.Renderer=lt,_.TextRenderer=$t,_.Lexer=le,_.lexer=le.lex,_.Tokenizer=rt,_.Hooks=Ge,_.parse=_,_.options,_.setOptions,_.use,_.walkTokens,_.parseInline,ce.parse,le.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:Bn,setPrototypeOf:Ln,isFrozen:br,getPrototypeOf:Er,getOwnPropertyDescriptor:Cr}=Object;let{freeze:ne,seal:ue,create:zt}=Object,{apply:_t,construct:Ot}=typeof Reflect<"u"&&Reflect;ne||(ne=function(e){return e}),ue||(ue=function(e){return e}),_t||(_t=function(e,n){for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];return e.apply(n,s)}),Ot||(Ot=function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return new e(...o)});const ct=re(Array.prototype.forEach),Sr=re(Array.prototype.lastIndexOf),Dn=re(Array.prototype.pop),Ke=re(Array.prototype.push),Tr=re(Array.prototype.splice),ut=re(String.prototype.toLowerCase),Pt=re(String.prototype.toString),Vt=re(String.prototype.match),Qe=re(String.prototype.replace),Ar=re(String.prototype.indexOf),Mr=re(String.prototype.trim),de=re(Object.prototype.hasOwnProperty),oe=re(RegExp.prototype.test),Ze=Nr(TypeError);function re(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return _t(r,e,o)}}function Nr(r){return function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return Ot(r,n)}}function I(r,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ut;Ln&&Ln(r,null);let o=e.length;for(;o--;){let s=e[o];if(typeof s=="string"){const a=n(s);a!==s&&(br(e)||(e[o]=a),s=a)}r[s]=!0}return r}function Rr(r){for(let e=0;e<r.length;e++)de(r,e)||(r[e]=null);return r}function ge(r){const e=zt(null);for(const[n,o]of Bn(r))de(r,n)&&(Array.isArray(o)?e[n]=Rr(o):o&&typeof o=="object"&&o.constructor===Object?e[n]=ge(o):e[n]=o);return e}function Ye(r,e){for(;r!==null;){const o=Cr(r,e);if(o){if(o.get)return re(o.get);if(typeof o.value=="function")return re(o.value)}r=Er(r)}function n(){return null}return n}const In=ne(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ft=ne(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ht=ne(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Br=ne(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ut=ne(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Lr=ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),$n=ne(["#text"]),zn=ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),qt=ne(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),_n=ne(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),dt=ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Dr=ue(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ir=ue(/<%[\w\W]*|[\w\W]*%>/gm),$r=ue(/\$\{[\w\W]*/gm),zr=ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),_r=ue(/^aria-[\-\w]+$/),On=ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Or=ue(/^(?:\w+script|data):/i),Pr=ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pn=ue(/^html$/i),Vr=ue(/^[a-z][.\w]*(-[.\w]+)+$/i);var Vn=Object.freeze({__proto__:null,ARIA_ATTR:_r,ATTR_WHITESPACE:Pr,CUSTOM_ELEMENT:Vr,DATA_ATTR:zr,DOCTYPE_NAME:Pn,ERB_EXPR:Ir,IS_ALLOWED_URI:On,IS_SCRIPT_OR_DATA:Or,MUSTACHE_EXPR:Dr,TMPLIT_EXPR:$r});const Xe={element:1,text:3,progressingInstruction:7,comment:8,document:9},Fr=function(){return typeof window>"u"?null:window},Hr=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(o=n.getAttribute(s));const a="dompurify"+(o?"#"+o:"");try{return e.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Fn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hn(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fr();const e=R=>Hn(R);if(e.version="3.3.0",e.removed=[],!r||!r.document||r.document.nodeType!==Xe.document||!r.Element)return e.isSupported=!1,e;let{document:n}=r;const o=n,s=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:d,NodeFilter:u,NamedNodeMap:p=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:g,DOMParser:x,trustedTypes:y}=r,f=d.prototype,E=Ye(f,"cloneNode"),h=Ye(f,"remove"),m=Ye(f,"nextSibling"),b=Ye(f,"childNodes"),C=Ye(f,"parentNode");if(typeof i=="function"){const R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let w,$="";const{implementation:z,createNodeIterator:F,createDocumentFragment:S,getElementsByTagName:T}=n,{importNode:N}=o;let D=Fn();e.isSupported=typeof Bn=="function"&&typeof C=="function"&&z&&z.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:Q,TMPLIT_EXPR:fe,DATA_ATTR:Re,ARIA_ATTR:ye,IS_SCRIPT_OR_DATA:Be,ATTR_WHITESPACE:pt,CUSTOM_ELEMENT:Wt}=Vn;let{IS_ALLOWED_URI:ft}=Vn,j=null;const Je=I({},[...In,...Ft,...Ht,...Ut,...$n]);let Z=null;const mt=I({},[...zn,...qt,..._n,...dt]);let v=Object.seal(zt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Le=null,$e=null;const ke=Object.seal(zt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ht=!0,ze=!0,L=!1,V=!0,H=!1,K=!0,W=!1,G=!1,se=!1,me=!1,gt=!1,yt=!1,to=!0,no=!1;const _a="user-content-";let Gt=!0,et=!1,_e={},Oe=null;const oo=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ro=null;const so=I({},["audio","video","img","source","image","track"]);let Kt=null;const ao=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let Pe=xe,Qt=!1,Zt=null;const Oa=I({},[kt,xt,xe],Pt);let wt=I({},["mi","mo","mn","ms","mtext"]),bt=I({},["annotation-xml"]);const Pa=I({},["title","style","font","a","script"]);let tt=null;const Va=["application/xhtml+xml","text/html"],Fa="text/html";let X=null,Ve=null;const Ha=n.createElement("form"),io=function(c){return c instanceof RegExp||c instanceof Function},Yt=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ve&&Ve===c)){if((!c||typeof c!="object")&&(c={}),c=ge(c),tt=Va.indexOf(c.PARSER_MEDIA_TYPE)===-1?Fa:c.PARSER_MEDIA_TYPE,X=tt==="application/xhtml+xml"?Pt:ut,j=de(c,"ALLOWED_TAGS")?I({},c.ALLOWED_TAGS,X):Je,Z=de(c,"ALLOWED_ATTR")?I({},c.ALLOWED_ATTR,X):mt,Zt=de(c,"ALLOWED_NAMESPACES")?I({},c.ALLOWED_NAMESPACES,Pt):Oa,Kt=de(c,"ADD_URI_SAFE_ATTR")?I(ge(ao),c.ADD_URI_SAFE_ATTR,X):ao,ro=de(c,"ADD_DATA_URI_TAGS")?I(ge(so),c.ADD_DATA_URI_TAGS,X):so,Oe=de(c,"FORBID_CONTENTS")?I({},c.FORBID_CONTENTS,X):oo,Le=de(c,"FORBID_TAGS")?I({},c.FORBID_TAGS,X):ge({}),$e=de(c,"FORBID_ATTR")?I({},c.FORBID_ATTR,X):ge({}),_e=de(c,"USE_PROFILES")?c.USE_PROFILES:!1,ht=c.ALLOW_ARIA_ATTR!==!1,ze=c.ALLOW_DATA_ATTR!==!1,L=c.ALLOW_UNKNOWN_PROTOCOLS||!1,V=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=c.SAFE_FOR_TEMPLATES||!1,K=c.SAFE_FOR_XML!==!1,W=c.WHOLE_DOCUMENT||!1,me=c.RETURN_DOM||!1,gt=c.RETURN_DOM_FRAGMENT||!1,yt=c.RETURN_TRUSTED_TYPE||!1,se=c.FORCE_BODY||!1,to=c.SANITIZE_DOM!==!1,no=c.SANITIZE_NAMED_PROPS||!1,Gt=c.KEEP_CONTENT!==!1,et=c.IN_PLACE||!1,ft=c.ALLOWED_URI_REGEXP||On,Pe=c.NAMESPACE||xe,wt=c.MATHML_TEXT_INTEGRATION_POINTS||wt,bt=c.HTML_INTEGRATION_POINTS||bt,v=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(v.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(v.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(v.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),H&&(ze=!1),gt&&(me=!0),_e&&(j=I({},$n),Z=[],_e.html===!0&&(I(j,In),I(Z,zn)),_e.svg===!0&&(I(j,Ft),I(Z,qt),I(Z,dt)),_e.svgFilters===!0&&(I(j,Ht),I(Z,qt),I(Z,dt)),_e.mathMl===!0&&(I(j,Ut),I(Z,_n),I(Z,dt))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?ke.tagCheck=c.ADD_TAGS:(j===Je&&(j=ge(j)),I(j,c.ADD_TAGS,X))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?ke.attributeCheck=c.ADD_ATTR:(Z===mt&&(Z=ge(Z)),I(Z,c.ADD_ATTR,X))),c.ADD_URI_SAFE_ATTR&&I(Kt,c.ADD_URI_SAFE_ATTR,X),c.FORBID_CONTENTS&&(Oe===oo&&(Oe=ge(Oe)),I(Oe,c.FORBID_CONTENTS,X)),Gt&&(j["#text"]=!0),W&&I(j,["html","head","body"]),j.table&&(I(j,["tbody"]),delete Le.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=c.TRUSTED_TYPES_POLICY,$=w.createHTML("")}else w===void 0&&(w=Hr(y,s)),w!==null&&typeof $=="string"&&($=w.createHTML(""));ne&&ne(c),Ve=c}},lo=I({},[...Ft,...Ht,...Br]),co=I({},[...Ut,...Lr]),Ua=function(c){let k=C(c);(!k||!k.tagName)&&(k={namespaceURI:Pe,tagName:"template"});const A=ut(c.tagName),U=ut(k.tagName);return Zt[c.namespaceURI]?c.namespaceURI===xt?k.namespaceURI===xe?A==="svg":k.namespaceURI===kt?A==="svg"&&(U==="annotation-xml"||wt[U]):!!lo[A]:c.namespaceURI===kt?k.namespaceURI===xe?A==="math":k.namespaceURI===xt?A==="math"&&bt[U]:!!co[A]:c.namespaceURI===xe?k.namespaceURI===xt&&!bt[U]||k.namespaceURI===kt&&!wt[U]?!1:!co[A]&&(Pa[A]||!lo[A]):!!(tt==="application/xhtml+xml"&&Zt[c.namespaceURI]):!1},he=function(c){Ke(e.removed,{element:c});try{C(c).removeChild(c)}catch{h(c)}},De=function(c,k){try{Ke(e.removed,{attribute:k.getAttributeNode(c),from:k})}catch{Ke(e.removed,{attribute:null,from:k})}if(k.removeAttribute(c),c==="is")if(me||gt)try{he(k)}catch{}else try{k.setAttribute(c,"")}catch{}},uo=function(c){let k=null,A=null;if(se)c="<remove></remove>"+c;else{const Y=Vt(c,/^[\r\n\t ]+/);A=Y&&Y[0]}tt==="application/xhtml+xml"&&Pe===xe&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const U=w?w.createHTML(c):c;if(Pe===xe)try{k=new x().parseFromString(U,tt)}catch{}if(!k||!k.documentElement){k=z.createDocument(Pe,"template",null);try{k.documentElement.innerHTML=Qt?$:U}catch{}}const te=k.body||k.documentElement;return c&&A&&te.insertBefore(n.createTextNode(A),te.childNodes[0]||null),Pe===xe?T.call(k,W?"html":"body")[0]:W?k.documentElement:te},po=function(c){return F.call(c.ownerDocument||c,c,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Xt=function(c){return c instanceof g&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof p)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},fo=function(c){return typeof l=="function"&&c instanceof l};function we(R,c,k){ct(R,A=>{A.call(e,c,k,Ve)})}const mo=function(c){let k=null;if(we(D.beforeSanitizeElements,c,null),Xt(c))return he(c),!0;const A=X(c.nodeName);if(we(D.uponSanitizeElement,c,{tagName:A,allowedTags:j}),K&&c.hasChildNodes()&&!fo(c.firstElementChild)&&oe(/<[/\w!]/g,c.innerHTML)&&oe(/<[/\w!]/g,c.textContent)||c.nodeType===Xe.progressingInstruction||K&&c.nodeType===Xe.comment&&oe(/<[/\w]/g,c.data))return he(c),!0;if(!(ke.tagCheck instanceof Function&&ke.tagCheck(A))&&(!j[A]||Le[A])){if(!Le[A]&&go(A)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A)))return!1;if(Gt&&!Oe[A]){const U=C(c)||c.parentNode,te=b(c)||c.childNodes;if(te&&U){const Y=te.length;for(let ae=Y-1;ae>=0;--ae){const be=E(te[ae],!0);be.__removalCount=(c.__removalCount||0)+1,U.insertBefore(be,m(c))}}}return he(c),!0}return c instanceof d&&!Ua(c)||(A==="noscript"||A==="noembed"||A==="noframes")&&oe(/<\/no(script|embed|frames)/i,c.innerHTML)?(he(c),!0):(H&&c.nodeType===Xe.text&&(k=c.textContent,ct([M,Q,fe],U=>{k=Qe(k,U," ")}),c.textContent!==k&&(Ke(e.removed,{element:c.cloneNode()}),c.textContent=k)),we(D.afterSanitizeElements,c,null),!1)},ho=function(c,k,A){if(to&&(k==="id"||k==="name")&&(A in n||A in Ha))return!1;if(!(ze&&!$e[k]&&oe(Re,k))){if(!(ht&&oe(ye,k))){if(!(ke.attributeCheck instanceof Function&&ke.attributeCheck(k,c))){if(!Z[k]||$e[k]){if(!(go(c)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,c)||v.tagNameCheck instanceof Function&&v.tagNameCheck(c))&&(v.attributeNameCheck instanceof RegExp&&oe(v.attributeNameCheck,k)||v.attributeNameCheck instanceof Function&&v.attributeNameCheck(k,c))||k==="is"&&v.allowCustomizedBuiltInElements&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A))))return!1}else if(!Kt[k]){if(!oe(ft,Qe(A,pt,""))){if(!((k==="src"||k==="xlink:href"||k==="href")&&c!=="script"&&Ar(A,"data:")===0&&ro[c])){if(!(L&&!oe(Be,Qe(A,pt,"")))){if(A)return!1}}}}}}}return!0},go=function(c){return c!=="annotation-xml"&&Vt(c,Wt)},yo=function(c){we(D.beforeSanitizeAttributes,c,null);const{attributes:k}=c;if(!k||Xt(c))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0};let U=k.length;for(;U--;){const te=k[U],{name:Y,namespaceURI:ae,value:be}=te,Fe=X(Y),Jt=be;let ee=Y==="value"?Jt:Mr(Jt);if(A.attrName=Fe,A.attrValue=ee,A.keepAttr=!0,A.forceKeepAttr=void 0,we(D.uponSanitizeAttribute,c,A),ee=A.attrValue,no&&(Fe==="id"||Fe==="name")&&(De(Y,c),ee=_a+ee),K&&oe(/((--!?|])>)|<\/(style|title|textarea)/i,ee)){De(Y,c);continue}if(Fe==="attributename"&&Vt(ee,"href")){De(Y,c);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){De(Y,c);continue}if(!V&&oe(/\/>/i,ee)){De(Y,c);continue}H&&ct([M,Q,fe],xo=>{ee=Qe(ee,xo," ")});const ko=X(c.nodeName);if(!ho(ko,Fe,ee)){De(Y,c);continue}if(w&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!ae)switch(y.getAttributeType(ko,Fe)){case"TrustedHTML":{ee=w.createHTML(ee);break}case"TrustedScriptURL":{ee=w.createScriptURL(ee);break}}if(ee!==Jt)try{ae?c.setAttributeNS(ae,Y,ee):c.setAttribute(Y,ee),Xt(c)?he(c):Dn(e.removed)}catch{De(Y,c)}}we(D.afterSanitizeAttributes,c,null)},qa=function R(c){let k=null;const A=po(c);for(we(D.beforeSanitizeShadowDOM,c,null);k=A.nextNode();)we(D.uponSanitizeShadowNode,k,null),mo(k),yo(k),k.content instanceof a&&R(k.content);we(D.afterSanitizeShadowDOM,c,null)};return e.sanitize=function(R){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=null,A=null,U=null,te=null;if(Qt=!R,Qt&&(R="<!-->"),typeof R!="string"&&!fo(R))if(typeof R.toString=="function"){if(R=R.toString(),typeof R!="string")throw Ze("dirty is not a string, aborting")}else throw Ze("toString is not a function");if(!e.isSupported)return R;if(G||Yt(c),e.removed=[],typeof R=="string"&&(et=!1),et){if(R.nodeName){const be=X(R.nodeName);if(!j[be]||Le[be])throw Ze("root node is forbidden and cannot be sanitized in-place")}}else if(R instanceof l)k=uo("<!---->"),A=k.ownerDocument.importNode(R,!0),A.nodeType===Xe.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?k=A:k.appendChild(A);else{if(!me&&!H&&!W&&R.indexOf("<")===-1)return w&&yt?w.createHTML(R):R;if(k=uo(R),!k)return me?null:yt?$:""}k&&se&&he(k.firstChild);const Y=po(et?R:k);for(;U=Y.nextNode();)mo(U),yo(U),U.content instanceof a&&qa(U.content);if(et)return R;if(me){if(gt)for(te=S.call(k.ownerDocument);k.firstChild;)te.appendChild(k.firstChild);else te=k;return(Z.shadowroot||Z.shadowrootmode)&&(te=N.call(o,te,!0)),te}let ae=W?k.outerHTML:k.innerHTML;return W&&j["!doctype"]&&k.ownerDocument&&k.ownerDocument.doctype&&k.ownerDocument.doctype.name&&oe(Pn,k.ownerDocument.doctype.name)&&(ae="<!DOCTYPE "+k.ownerDocument.doctype.name+`>
58
- `+ae),H&&ct([M,Q,fe],be=>{ae=Qe(ae,be," ")}),w&&yt?w.createHTML(ae):ae},e.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(R),G=!0},e.clearConfig=function(){Ve=null,G=!1},e.isValidAttribute=function(R,c,k){Ve||Yt({});const A=X(R),U=X(c);return ho(A,U,k)},e.addHook=function(R,c){typeof c=="function"&&Ke(D[R],c)},e.removeHook=function(R,c){if(c!==void 0){const k=Sr(D[R],c);return k===-1?void 0:Tr(D[R],k,1)[0]}return Dn(D[R])},e.removeHooks=function(R){D[R]=[]},e.removeAllHooks=function(){D=Fn()},e}var Ur=Hn();function Un(){return{parseMarkdown:e=>{if(!e||typeof e!="string")return"";const n=ln(e),o=_.parse(n,{async:!1,breaks:!0,gfm:!0});return Ur.sanitize(o,{ALLOWED_TAGS:["p","br","strong","em","b","i","code","pre","ul","ol","li","h1","h2","h3","h4","h5","h6","a","blockquote","span","div","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","target","rel","data-mention-id","data-mention-type"],ALLOW_UNKNOWN_PROTOCOLS:!1,FORBID_ATTR:["onerror","onload","onclick","onmouseover"],KEEP_CONTENT:!0})}}}function qr(){let r=null;function e(a){const i=a||document.querySelector("[data-rai-chat-container]");i&&requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})}function n(a,i=100){const{scrollTop:l,scrollHeight:d,clientHeight:u}=a;return d-l-u<i}function o(a){a&&(s(),r=new MutationObserver(()=>{(a.scrollTop===0||n(a))&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}),r.observe(a,{childList:!0,subtree:!0}))}function s(){r&&(r.disconnect(),r=null)}return t.onUnmounted(()=>{s()}),{scrollToBottom:e,setupAutoScroll:o,cleanupAutoScroll:s}}function vr(){const r=Ae(),e=t.computed(()=>r.error),n=t.computed(()=>{var a,i;return((a=e.value)==null?void 0:a.message)!==null&&((i=e.value)==null?void 0:i.message)!==void 0});return{errorState:e,hasError:n,retry:async()=>await r.retry(),clearError:()=>{r.clearError()}}}function vt(){const r=Ae(),e=t.computed(()=>r.pageContext);function n(a){r.setPageContext(a)}function o(){r.setPageContext(null)}function s(a){const i=r.pageContext;i&&r.setPageContext({...i,...a,metadata:{...i.metadata,...a.metadata}})}return{context:e,setContext:n,clearContext:o,updateContext:s}}const pe=[],qn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const r=q();return(r==null?void 0:r.defaultSuggestions)||[]}};function jr(){pe.length=0;const r=q();r!=null&&r.suggestionProviders&&pe.push(...r.suggestionProviders),pe.push(qn)}function Wr(r,e){const n=[...pe].sort((o,s)=>(s.priority||0)-(o.priority||0));for(const o of n)if(o.matcher&&o.matcher(r,e)||o.routes&&o.routes.some(a=>a.endsWith("*")?r.startsWith(a.slice(0,-1)):r===a||r.startsWith(a+"/")))return o;return qn}function vn(r,e){pe.length===0&&jr();const n=Wr(r,e),o=e||{pageType:"default",routePath:r};return n.extractContext&&(o.metadata={...o.metadata,...n.extractContext(r)}),n.getSuggestions(o)||[]}function Gr(r){const e=pe.findIndex(n=>n.id===r.id);if(e>=0)pe[e]=r;else{const n=pe.findIndex(o=>o.id==="default");n>=0?pe.splice(n,0,r):pe.push(r)}}const Kr=Gr;function jt(){const{context:r}=vt(),e=Ae(),n=t.computed(()=>{var d;if(e.quota.remaining===0){const u=q();return(u==null?void 0:u.enableSupportMode)!==!1?[{id:"contact-support-quota",title:J("contactSupport"),description:J("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[]}const a=((d=r.value)==null?void 0:d.routePath)||(typeof window<"u"?window.location.pathname:"/"),i=vn(a,r.value)||[],l=q();return l!=null&&l.can?i.filter(u=>!(u.permission&&!l.can(u.permission))):i}),o=t.computed(()=>r.value!==null&&r.value.pageType!=="default");function s(a){return typeof a.prompt=="function"?a.prompt(r.value||{pageType:"default"}):a.prompt}return{suggestions:n,hasContextualSuggestions:o,resolvePrompt:s}}function Qr(r,e){const{setContext:n,clearContext:o,updateContext:s}=vt();function a(){if(!e)return{};const l={};for(const[d,u]of Object.entries(e))l[d]=t.isRef(u)?u.value:u;return l}function i(){const l={pageType:r,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return t.onMounted(()=>{i()}),t.onUnmounted(()=>{o()}),e&&t.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function Zr(r){const e=r.toLowerCase().split("+");return{key:e.pop()||"",meta:e.includes("cmd")||e.includes("meta")||e.includes("command"),ctrl:e.includes("ctrl")||e.includes("control"),shift:e.includes("shift"),alt:e.includes("alt")||e.includes("option")}}function Yr(r,e){const n=r.key.toLowerCase(),o=e.meta?r.metaKey:!r.metaKey,s=e.ctrl?r.ctrlKey:!r.ctrlKey,a=e.shift?r.shiftKey:!r.shiftKey,i=e.alt?r.altKey:!r.altKey;let l=o&&s&&a&&i;return(e.meta&&!e.ctrl||!e.meta&&e.ctrl)&&(l=(r.metaKey||r.ctrlKey)&&a&&i),n===e.key&&l}function jn(r){const{onToggle:e,enabled:n=!0}=r,o=t.ref(!1),s=r.shortcut!==void 0?r.shortcut:Se("keyboardShortcut")??"cmd+g";if(s===null)return{isActive:o};const a=Zr(s);function i(l){if(!n)return;const d=l.target,u=d.tagName==="INPUT"||d.tagName==="TEXTAREA",p=d.isContentEditable,g=d.closest("[data-ai-input]");if(!((u||p)&&!g)&&Yr(l,a)){l.preventDefault(),l.stopPropagation();const x=q();if(x!=null&&x.canToggle&&!x.canToggle())return;o.value=!o.value,e()}}return t.onMounted(()=>{window.addEventListener("keydown",i,!0)}),t.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:o}}function Xr(r){return jn({onToggle:()=>{r.value=!r.value}})}function Jr(r,e){const n=t.ref(J("loadingText"));let o=[];function s(){return[J("loadingText"),J("analyzingText"),J("craftingText")]}function a(){return[0,2e3,5e3]}function i(){o.forEach(u=>clearTimeout(u)),o=[]}function l(){i();const u=e==null?void 0:e(),p=(u==null?void 0:u.messages)??s();n.value=p[0]||J("loadingText")}function d(){i();const u=e==null?void 0:e(),p=(u==null?void 0:u.messages)??s(),g=(u==null?void 0:u.intervals)??a();n.value=p[0]||J("loadingText");let x=0;for(let y=1;y<p.length;y++){x+=g[y]||2e3;const f=y,E=window.setTimeout(()=>{r()&&(n.value=p[f])},x);o.push(E)}}return t.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:d,resetLoadingText:l,clearLoadingTextTimers:i}}function es(r){const{getHistoryLength:e,getStoreLimit:n,getConfig:o,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=r,l=t.ref({showWarning:!1,isReached:!1,pendingMessage:null}),d=t.computed(()=>{var C;return((C=o())==null?void 0:C.limit)??n()}),u=t.computed(()=>{var C;return((C=o())==null?void 0:C.showWarningAt)??d.value-2}),p=t.computed(()=>Math.max(0,d.value-e())),g=t.computed(()=>p.value<=d.value-u.value&&p.value>0),x=t.computed(()=>p.value===0),y=t.computed(()=>{var C,w;return l.value.isReached?((C=s())==null?void 0:C.historyLimitReachedTitle)??"Chat Limit Reached":((w=s())==null?void 0:w.historyLimitWarningTitle)??"Approaching Chat Limit"}),f=t.computed(()=>{var C,w,$,z;return l.value.isReached?((C=o())==null?void 0:C.limitMessage)??((w=s())==null?void 0:w.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":(($=o())==null?void 0:$.warningMessage)??((z=s())==null?void 0:z.historyLimitWarningMessage)??`You have ${p.value} message${p.value===1?"":"s"} remaining in this conversation.`});function E(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function h(){l.value.showWarning=!1;const C=o();if(C!=null&&C.onLimitReached&&!await C.onLimitReached())return l.value.isReached=!1,null;if(a(),i(),l.value.isReached=!1,l.value.pendingMessage){const w=l.value.pendingMessage;return l.value.pendingMessage=null,w}return null}function m(){return x.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(g.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function b(C){l.value.pendingMessage=C}return{showHistoryLimitWarning:t.computed(()=>l.value.showWarning),historyLimitReached:t.computed(()=>l.value.isReached),historyLimit:d,remainingMessages:p,historyLimitDialogTitle:y,historyLimitDialogMessage:f,dismissHistoryLimitWarning:E,handleHistoryLimitAction:h,checkHistoryLimit:m,setPendingMessage:b}}function ts(){const r=Ae(),e=t.ref([]),n=t.ref(!1),o=t.ref(0),s=Se("maxAttachments")||5,a=Se("maxFileSize")||10*1024*1024,i=Se("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=t.computed(()=>e.value.length>0),d=t.computed(()=>e.value.some(S=>S.uploading)),u=t.computed(()=>e.value.length<s);function p(S){return(S.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(S.name)}function g(S){if(S==null)return"";const T=typeof S=="string"?parseInt(S,10):S;return Number.isNaN(T)?"":T>=1024*1024?`${(T/(1024*1024)).toFixed(1)} MB`:T>=1024?`${Math.round(T/1024)} KB`:`${T} B`}function x(S){var fe;const T=crypto.randomUUID(),N=S.type.startsWith("image/")?URL.createObjectURL(S):void 0,D=q(),M=!!((fe=D==null?void 0:D.endpoints)!=null&&fe.uploadFile),Q={id:T,name:S.name,type:S.type,size:S.size,uploading:M,progress:M?0:100,previewUrl:N};e.value.push(Q),M&&y(S,T)}async function y(S,T){try{const N=await r.uploadFile(S),D=e.value.findIndex(M=>M.id===T);if(D===-1)return;if(N){const M=e.value[D].previewUrl;e.value[D]={...e.value[D],id:N.id||T,url:N.url,extractedText:N.extractedText,uploading:!1,progress:100,previewUrl:M||N.previewUrl}}else f(T)}catch{f(T)}}function f(S){const T=e.value.findIndex(D=>D.id===S);if(T===-1)return;const[N]=e.value.splice(T,1);N!=null&&N.previewUrl&&URL.revokeObjectURL(N.previewUrl)}function E(){e.value.forEach(S=>{S.previewUrl&&URL.revokeObjectURL(S.previewUrl)}),e.value=[]}function h(){return e.value.filter(S=>!S.uploading).map(S=>({id:S.id,name:S.name,url:S.url,type:S.type,size:S.size}))}function m(S){if(!S)return;const T=Array.from(S);for(const N of T){if(e.value.length>=s)break;N.size>a||x(N)}}function b(S){var T;return Array.from(((T=S.dataTransfer)==null?void 0:T.types)||[]).includes("Files")}function C(S){b(S)&&(o.value+=1,n.value=!0)}function w(S){b(S)||S.preventDefault()}function $(S){b(S)&&(o.value=Math.max(0,o.value-1),o.value===0&&(n.value=!1))}function z(S){var T;b(S)&&(o.value=0,n.value=!1,m(((T=S.dataTransfer)==null?void 0:T.files)||null))}function F(S){const T=S.target,N=T.files;N&&N.length&&m(N),T.value=""}return t.onBeforeUnmount(()=>{E()}),{attachments:e,isDraggingFiles:n,hasAttachments:l,isUploading:d,canAddMore:u,acceptedFileTypes:i,isImage:p,formatFileSize:g,removeAttachment:f,clearAttachments:E,buildPayload:h,processFiles:m,handleFileSelect:F,handleDragEnter:C,handleDragOver:w,handleDragLeave:$,handleDrop:z}}function ns(r,e,n){const o=t.ref(!1),s=t.ref([]),a=t.ref(0),i=t.ref({inMention:!1,query:"",startPos:0}),l=t.ref([]),d=t.computed(()=>{const E=q();return(E==null?void 0:E.mentionProviders)||[]});function u(E){const h=n();if(!h)return;const m=h.selectionStart,b=cn(E,m);i.value=b,b.inMention&&b.query.length>=0?p(b.query):(o.value=!1,s.value=[])}async function p(E){const h=pn();if(h.length===0){o.value=!1;return}const m=[];for(const b of h)try{const C=await b.search(E);m.push(...C.map(w=>({...w,type:b.type})))}catch(C){console.warn(`Mention provider ${b.type} failed:`,C)}s.value=m.slice(0,10),o.value=m.length>0,a.value=0}function g(E){const{startPos:h}=i.value,m=r(),b=n(),C=m.slice(0,h),w=m.slice((b==null?void 0:b.selectionStart)||h),$=E.name||E.label||E.title||E.id;e(`${C}@${$} ${w}`),l.value.push({id:E.id,name:$,type:E.type,metadata:E.attributes}),o.value=!1,s.value=[],setTimeout(()=>{const z=n();z==null||z.focus();const F=C.length+$.length+2;z==null||z.setSelectionRange(F,F)},0)}function x(E){if(!o.value||s.value.length===0)return!1;if(E.key==="ArrowDown")return E.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(E.key==="ArrowUp")return E.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(E.key==="Enter"||E.key==="Tab"){E.preventDefault();const h=s.value[a.value];return h&&g(h),!0}return E.key==="Escape"?(E.preventDefault(),o.value=!1,!0):!1}function y(){l.value=[]}function f(){return[...l.value]}return{showMentions:o,mentionItems:s,selectedMentionIndex:a,mentionProviders:d,checkForMentions:u,handleMentionSelect:g,handleMentionKeyDown:x,clearMentions:y,getMentions:f}}function os(r,e,n,o,s){const a=t.ref(!1),i=t.ref(-1),l=t.ref(null);function d(){setTimeout(()=>{const y=l.value;if(!y)return;const f=y.querySelector(`li:nth-child(${i.value+1})`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function u(y){const f=r();if(!a.value||f.length===0)return!1;if(y.key==="ArrowDown")return y.preventDefault(),i.value=Math.min(i.value+1,f.length-1),d(),!0;if(y.key==="ArrowUp")return y.preventDefault(),i.value=Math.max(i.value-1,0),d(),!0;if(y.key==="Enter"&&i.value>=0){y.preventDefault();const E=f[i.value];return E&&p(E),!0}return y.key==="Escape"?(y.preventDefault(),a.value=!1,i.value=-1,!0):!1}function p(y){s(y),a.value=!1,i.value=-1}function g(){const y=o(),f=e(),E=n(),h=r();y&&!f&&E&&h.length>0?a.value=!0:a.value=!1}function x(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:u,handleSuggestionClick:p,updateSuggestionsVisibility:g,hideSuggestions:x}}function rs(r,e=300){function n(){const o=r();if(!o)return;o.style.height="auto";const s=Math.min(o.scrollHeight,e);o.style.height=`${s}px`,o.style.overflowY=o.scrollHeight>e?"auto":"hidden"}return t.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const Wn=t.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(r){return(e,n)=>{var o;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["w-6 h-6 min-w-[24px] flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-600",(o=r.ui)==null?void 0:o.container])},[t.renderSlot(e.$slots,"default",{},()=>{var s;return[(t.openBlock(),t.createElementBlock("svg",{class:t.normalizeClass(["w-4 h-4 text-gray-400 dark:text-gray-500",(s=r.ui)==null?void 0:s.icon]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...n[0]||(n[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))]})],2)}}}),ss=t.defineComponent({__name:"UserAvatar",props:{ui:{}},setup(r){return(e,n)=>{var o;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(o=r.ui)==null?void 0:o.container])},[t.renderSlot(e.$slots,"default",{},()=>{var s;return[(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:t.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},[...n[0]||(n[0]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])],2))]})],2)}}}),as=["onClick","onMouseenter"],Gn=t.defineComponent({__name:"MentionList",props:{items:{},selectedIndex:{default:0},providers:{default:()=>[]},ui:{},texts:{}},emits:["select","update:selectedIndex"],setup(r,{emit:e}){const n=r,o=t.computed(()=>n.ui||{}),s=e,a=t.ref(n.selectedIndex);t.watch(()=>n.selectedIndex,h=>{a.value=h}),t.watch(a,h=>{s("update:selectedIndex",h)});const i=t.computed(()=>{const h={};return n.items.forEach(m=>{const b=m.type||"default";h[b]||(h[b]=[]),h[b].push(m)}),h});function l(h){return n.providers.find(m=>m.type===h)||dn(h)}function d(h){const m=l(h);return(m==null?void 0:m.label)||h.charAt(0).toUpperCase()+h.slice(1)+"s"}function u(h,m){let b=0;const C=Object.keys(i.value);for(const w of C){if(w===h)return b+m;b+=i.value[w].length}return b}function p(h){s("select",h)}function g(h){a.value=h,s("update:selectedIndex",h)}function x(h){const m=l(h.type);return At(h,m)}function y(h){const m=l(h.type);return un(h,m)}function f(h){const m={employee:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",job:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",candidate:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",project:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400",default:"bg-primary/10 text-primary"};return m[h]||m.default}function E(h){return h.split(" ").map(m=>m[0]).join("").slice(0,2).toUpperCase()}return(h,m)=>r.items.length>0?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-60 overflow-y-auto z-50",o.value.root])},[t.createElementVNode("div",{class:t.normalizeClass(["p-2",o.value.container])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value,(b,C)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:C},[Object.keys(i.value).length>1?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",o.value.groupHeader])},t.toDisplayString(d(C)),3)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(b,(w,$)=>(t.openBlock(),t.createElementBlock("button",{key:w.id,type:"button",class:t.normalizeClass(["w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors mb-0.5",[o.value.item,{[o.value.itemSelected||"bg-primary/10"]:u(C,$)===a.value,"hover:bg-gray-50 dark:hover:bg-gray-700":u(C,$)!==a.value}]]),onClick:z=>p(w),onMouseenter:z=>g(u(C,$))},[t.renderSlot(h.$slots,"item-icon",{item:w,type:C},()=>[t.createElementVNode("span",{class:t.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[o.value.itemIcon,f(w.type)]])},t.toDisplayString(E(x(w))),3)]),t.createElementVNode("div",{class:t.normalizeClass(["flex-1 min-w-0",o.value.itemContent])},[t.createElementVNode("p",{class:t.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",o.value.itemName])},t.toDisplayString(x(w)),3),y(w)?(t.openBlock(),t.createElementBlock("p",{key:0,class:t.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",o.value.itemSubtitle])},t.toDisplayString(y(w)),3)):t.createCommentVNode("",!0)],2)],42,as))),128))],64))),128))],2)],2)):t.createCommentVNode("",!0)}}),is=["title"],ls={key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Kn=t.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(r,{emit:e}){const n=r,o=e,s=d=>{var p;return(p=n.texts)!=null&&p[d]?n.texts[d]:J({copyToClipboard:"copyToClipboard",copied:"copied"}[d])},a=t.computed(()=>n.ui||{}),i=t.ref(!1);async function l(){try{await navigator.clipboard.writeText(n.message.message),i.value=!0,o("copy",n.message),setTimeout(()=>{i.value=!1},2e3)}catch(d){console.error("Failed to copy:",d)}}return(d,u)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",a.value.container])},[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",[a.value.button,a.value.copyButton]]),title:i.value?s("copied"):s("copyToClipboard"),onClick:l},[i.value?(t.openBlock(),t.createElementBlock("svg",{key:1,class:t.normalizeClass(["w-4 h-4 text-green-500",a.value.successState]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[...u[1]||(u[1]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])],2)):(t.openBlock(),t.createElementBlock("svg",ls,[...u[0]||(u[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"},null,-1)])]))],10,is)],2))}}),cs={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},us=["src"],ds={key:1,class:"w-5 h-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ps={class:"flex-1 min-w-0"},fs={class:"text-sm font-semibold text-white truncate"},ms={class:"text-xs text-white/70"},hs={key:0,class:"text-xs font-medium text-white/90"},gs=["src"],ys={key:1,class:"h-4 w-4 text-white",viewBox:"0 0 24 24",fill:"currentColor"},ks={class:"flex-shrink-0 mt-0.5"},xs={class:"text-gray-600 dark:text-gray-400"},ws=["id","innerHTML"],bs={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white dark:bg-gray-800 overflow-hidden border border-gray-200 dark:border-gray-600"},Es=["src"],Cs={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ss={class:"flex-1 min-w-0"},Ts={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},As={class:"text-xs text-gray-500 dark:text-gray-400"},Ms={key:0,class:"text-xs font-medium text-primary"},Ns=t.defineComponent({__name:"ChatMessage",props:{message:{},showActions:{type:Boolean,default:!0},loadingText:{default:"Gathering data..."},ui:{},texts:{}},emits:["copy"],setup(r,{emit:e}){const n=r,o=e,s=m=>{var C;return(C=n.texts)!=null&&C[m]?n.texts[m]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[m]||m},a=t.computed(()=>n.ui||{}),{parseMarkdown:i}=Un(),l=t.ref(!1),d=t.computed(()=>n.message.attachments??[]),u=t.computed(()=>d.value.length>0),p=t.computed(()=>{if(n.message.role!=="user")return!1;const m=n.message.message||"",b=m.split(`
59
- `).length;return m.length>200||b>4});function g(){l.value=!l.value}function x(m){return(m.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(m.name||"")}const y=t.computed(()=>{const m=q();return m!=null&&m.userAvatar?typeof m.userAvatar=="string"?m.userAvatar:typeof m.userAvatar=="function"?m.userAvatar():null:null});function f(m){if(m==null)return"";const b=typeof m=="string"?parseInt(m,10):m;return Number.isNaN(b)?"":b>=1024*1024?`${(b/(1024*1024)).toFixed(1)} MB`:b>=1024?`${Math.round(b/1024)} KB`:`${b} B`}const E=t.computed(()=>{if(n.message.role==="assistant"){let m=n.message.message;return m=m.replace(/\\n/g,`
60
- `),i(m)}return n.message.message});function h(m){o("copy",m)}return(m,b)=>{var C;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[a.value.root,{"flex justify-end":r.message.role==="user","flex justify-start":r.message.role==="assistant"}]])},[r.message.role==="user"?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["flex gap-3 justify-end",a.value.userMessage])},[t.createElementVNode("div",{class:t.normalizeClass(["rounded-2xl px-4 py-3 bg-primary text-white max-w-fit",a.value.userBubble])},[r.message.message?(t.openBlock(),t.createElementBlock("p",{key:0,class:t.normalizeClass(["text-sm whitespace-pre-wrap",[a.value.content,{"line-clamp-4":!l.value&&p.value}]])},t.toDisplayString(r.message.message),3)):t.createCommentVNode("",!0),p.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:t.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",a.value.showMoreButton]),onClick:g},t.toDisplayString(l.value?s("showLess"):s("showMore")),3)):t.createCommentVNode("",!0),u.value?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["mt-3 space-y-2",a.value.attachmentsContainer])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,w=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:t.normalizeClass(["flex items-center gap-3 rounded-xl border border-white/20 bg-white/10 p-2 transition",[a.value.attachmentItem,w.url?"hover:bg-white/20 cursor-pointer":""]])},{default:t.withCtx(()=>[t.createElementVNode("div",cs,[w.url&&x(w)?(t.openBlock(),t.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,us)):(t.openBlock(),t.createElementBlock("svg",ds,[...b[0]||(b[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),t.createElementVNode("div",ps,[t.createElementVNode("p",fs,t.toDisplayString(w.name||s("attachment")),1),t.createElementVNode("p",ms,t.toDisplayString(f(w.size)),1)]),w.url?(t.openBlock(),t.createElementBlock("span",hs,t.toDisplayString(s("openAttachment")),1)):t.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):t.createCommentVNode("",!0)],2),t.createElementVNode("div",{class:t.normalizeClass(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary overflow-hidden",a.value.userAvatar])},[y.value?(t.openBlock(),t.createElementBlock("img",{key:0,src:y.value,alt:"User",class:"h-full w-full object-cover"},null,8,gs)):(t.openBlock(),t.createElementBlock("svg",ys,[...b[1]||(b[1]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])]))],2)],2)):(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["flex items-start gap-3",a.value.assistantMessage])},[t.createElementVNode("div",ks,[t.createVNode(Wn)]),t.createElementVNode("div",{class:t.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-5 py-4 shadow-sm rounded-2xl transition-all duration-200 flex-1",a.value.assistantBubble])},[r.message.loading?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",a.value.loadingIndicator])},[t.createElementVNode("div",{class:t.normalizeClass(["flex space-x-1",a.value.loadingDots])},[...b[2]||(b[2]=[t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"0ms"}},null,-1),t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"150ms"}},null,-1),t.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"300ms"}},null,-1)])],2),t.createElementVNode("span",xs,t.toDisplayString(((C=r.texts)==null?void 0:C.loadingText)||r.loadingText),1)],2)):r.message.message?(t.openBlock(),t.createElementBlock("div",{key:1,id:r.message.id,class:t.normalizeClass(["prose prose-sm max-w-none prose-gray dark:prose-invert",a.value.content]),innerHTML:E.value},null,10,ws)):t.createCommentVNode("",!0),!r.message.loading&&u.value?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["mt-4 space-y-2",a.value.attachmentsContainer])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,w=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:t.normalizeClass(["flex items-center gap-3 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 p-3 transition",[a.value.attachmentItem,w.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:t.withCtx(()=>[t.createElementVNode("div",bs,[w.url&&x(w)?(t.openBlock(),t.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,Es)):(t.openBlock(),t.createElementBlock("svg",Cs,[...b[3]||(b[3]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),t.createElementVNode("div",Ss,[t.createElementVNode("p",Ts,t.toDisplayString(w.name||s("attachment")),1),t.createElementVNode("p",As,t.toDisplayString(f(w.size)),1)]),w.url?(t.openBlock(),t.createElementBlock("span",Ms,t.toDisplayString(s("openAttachment")),1)):t.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):t.createCommentVNode("",!0)],2)],2)),r.message.role==="assistant"&&!r.message.loading&&!r.message.streaming&&r.showActions?(t.openBlock(),t.createBlock(Kn,{key:2,message:r.message,class:t.normalizeClass(["absolute -bottom-8 left-14",a.value.actionsContainer]),onCopy:h},null,8,["message","class"])):t.createCommentVNode("",!0)],2)}}}),Qn=(r,e)=>{const n=r.__vccOpts||r;for(const[o,s]of e)n[o]=s;return n},Zn=Qn(Ns,[["__scopeId","data-v-df348786"]]),Rs={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},Bs={class:"space-y-2"},Ls=["src"],Ds={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Is={class:"flex-1 min-w-0"},$s={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},zs={class:"text-xs text-gray-500 dark:text-gray-400"},_s={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Os={key:0,class:"text-xs text-gray-400"},Ps=["disabled","onClick"],Vs=t.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(r){return(e,n)=>{var o;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",r.ui.attachmentsContainer])},[t.createElementVNode("p",Rs,t.toDisplayString(((o=r.texts)==null?void 0:o.attachedFiles)||"Attached files"),1),t.createElementVNode("ul",Bs,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.attachments,s=>(t.openBlock(),t.createElementBlock("li",{key:s.id,class:t.normalizeClass(["flex items-center gap-3 rounded-xl bg-white dark:bg-gray-700 p-2 shadow-sm border border-gray-100 dark:border-gray-600",r.ui.attachmentItem])},[t.createElementVNode("div",{class:t.normalizeClass(["h-10 w-10 flex items-center justify-center rounded-lg bg-gray-100 dark:bg-gray-600 overflow-hidden",r.ui.attachmentThumbnail])},[r.isImage(s)?(t.openBlock(),t.createElementBlock("img",{key:0,src:s.previewUrl||s.url,class:"object-cover h-full w-full",alt:""},null,8,Ls)):(t.openBlock(),t.createElementBlock("svg",Ds,[...n[0]||(n[0]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))],2),t.createElementVNode("div",Is,[t.createElementVNode("p",$s,t.toDisplayString(s.name),1),t.createElementVNode("p",zs,t.toDisplayString(r.formatFileSize(s.size)),1),s.uploading?(t.openBlock(),t.createElementBlock("div",_s,[t.createElementVNode("div",{class:"h-full bg-primary transition-all",style:t.normalizeStyle({width:`${s.progress??10}%`})},null,4)])):t.createCommentVNode("",!0)]),s.uploading?(t.openBlock(),t.createElementBlock("span",Os,t.toDisplayString(Math.round(s.progress??0))+"% ",1)):t.createCommentVNode("",!0),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",r.ui.attachmentRemove]),disabled:s.uploading,onClick:a=>e.$emit("remove",s.id)},[...n[1]||(n[1]=[t.createElementVNode("svg",{class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,Ps)],2))),128))])],2)}}}),Fs={class:"py-1"},Hs=["onClick","onMouseenter"],Us={class:"flex items-start gap-3"},qs={class:"flex-1 min-w-0"},vs={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},js={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Ws=t.defineComponent({__name:"SuggestionsDropdown",props:{suggestions:{},selectedIndex:{},ui:{}},emits:["select","hover"],setup(r,{expose:e}){const n=t.ref(null);return e({dropdownRef:n}),(o,s)=>(t.openBlock(),t.createBlock(t.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:t.withCtx(()=>[t.createElementVNode("div",{ref_key:"dropdownRef",ref:n,class:t.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-80 overflow-y-auto z-10",r.ui.suggestionsDropdown])},[t.createElementVNode("ul",Fs,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.suggestions,(a,i)=>(t.openBlock(),t.createElementBlock("li",{key:a.id,class:t.normalizeClass(["px-4 py-3 cursor-pointer transition-colors border-b border-gray-100 dark:border-gray-700 last:border-b-0",[r.ui.suggestionItem,{[r.ui.suggestionItemSelected||"bg-primary/10"]:i===r.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":i!==r.selectedIndex}]]),onClick:l=>o.$emit("select",a),onMouseenter:l=>o.$emit("hover",i)},[t.createElementVNode("div",Us,[t.createElementVNode("div",qs,[t.createElementVNode("p",vs,t.toDisplayString(a.title),1),t.createElementVNode("p",js,t.toDisplayString(a.description),1)])])],42,Hs))),128))])],2)]),_:1}))}}),Gs={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},Ks=["title"],Qs=["title"],Zs=["disabled"],Ys={key:0,class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Xs={key:1,class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},Js=t.defineComponent({__name:"InputActions",props:{sending:{type:Boolean},canSend:{type:Boolean},supportRequestMode:{type:Boolean},showSupportModeToggle:{type:Boolean},ui:{},texts:{}},emits:["toggle-support-mode","click"],setup(r){const e=r,n=t.computed(()=>e.sending?[e.ui.stopButton||"bg-red-500 text-white hover:bg-red-600"]:e.canSend?[e.ui.sendButtonActive||"bg-primary text-white hover:bg-primary/90"]:[e.ui.sendButtonDisabled||"bg-gray-200 dark:bg-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed opacity-60"]);return(o,s)=>{var a,i,l;return t.openBlock(),t.createElementBlock("div",Gs,[r.showSupportModeToggle&&!r.supportRequestMode?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center text-gray-400 hover:text-primary hover:bg-gray-100 dark:hover:bg-gray-700 transition flex-shrink-0",r.ui.supportToggle]),title:((a=r.texts)==null?void 0:a.toggleSupportMode)||"Toggle support mode",onClick:s[0]||(s[0]=d=>o.$emit("toggle-support-mode"))},[...s[3]||(s[3]=[t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)])],10,Ks)):t.createCommentVNode("",!0),r.showSupportModeToggle&&r.supportRequestMode?(t.openBlock(),t.createElementBlock("button",{key:1,type:"button",class:t.normalizeClass(["h-7 px-2 rounded-lg flex items-center gap-1 text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 hover:bg-amber-200 dark:hover:bg-amber-900/50 transition flex-shrink-0",r.ui.supportBadge]),title:((i=r.texts)==null?void 0:i.exitSupportMode)||"Exit support mode",onClick:s[1]||(s[1]=d=>o.$emit("toggle-support-mode"))},[s[4]||(s[4]=t.createElementVNode("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(((l=r.texts)==null?void 0:l.supportLabel)||"Support"),1),s[5]||(s[5]=t.createElementVNode("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1))],10,Qs)):t.createCommentVNode("",!0),t.createElementVNode("button",{disabled:!r.canSend&&!r.sending,class:t.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center transition-all duration-200 flex-shrink-0",n.value]),type:"button",onClick:s[2]||(s[2]=t.withModifiers(d=>o.$emit("click"),["prevent"]))},[r.sending?(t.openBlock(),t.createElementBlock("svg",Xs,[...s[7]||(s[7]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.5 7.5a3 3 0 013-3h9a3 3 0 013 3v9a3 3 0 01-3 3h-9a3 3 0 01-3-3v-9z","clip-rule":"evenodd"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",Ys,[...s[6]||(s[6]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"},null,-1)])]))],10,Zs)])}}}),ea={class:"max-w-3xl mx-auto space-y-3"},ta=["accept"],na=["title"],oa={class:"flex items-center"},ra=["placeholder","disabled"],sa={key:0,class:"flex justify-center"},Yn=t.defineComponent({__name:"ChatInput",props:{modelValue:{},disabled:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},placeholder:{default:"Ask me anything..."},supportPlaceholder:{default:"Describe your support request..."},minLength:{default:3},suggestions:{default:()=>[]},hasHistory:{type:Boolean,default:!1},supportRequestMode:{type:Boolean,default:!1},showSupportModeToggle:{type:Boolean,default:!1},contextLinkText:{default:""},ui:{},texts:{}},emits:["update:modelValue","submit","cancel","suggestion-select","toggle-support-mode","context-link-click"],setup(r,{emit:e}){const n=r,o=t.computed(()=>n.ui||{}),s=e,a=t.ref(n.modelValue),i=t.ref(null),l=t.ref(null),d=t.ref(!1),u=ts(),p=ns(()=>a.value,T=>{a.value=T},()=>i.value),g=os(()=>n.suggestions,()=>n.hasHistory,()=>d.value,()=>a.value,T=>{s("suggestion-select",T),t.nextTick(()=>{var N;return(N=i.value)==null?void 0:N.focus()})}),{adjustTextareaHeight:x}=rs(()=>i.value),y=t.computed(()=>n.supportRequestMode?n.supportPlaceholder:n.placeholder),f=t.computed(()=>n.showSupportModeToggle?n.supportRequestMode?"pr-32":"pr-24":"pr-14"),E=t.computed(()=>{var N;return(((N=a.value)==null?void 0:N.trim())??"").length>=n.minLength?!0:u.hasAttachments.value}),h=t.computed(()=>!n.disabled&&!n.sending&&E.value&&!u.isUploading.value);t.watch(()=>n.modelValue,T=>{a.value=T,t.nextTick(x)}),t.watch(a,T=>{s("update:modelValue",T),t.nextTick(x),p.checkForMentions(T),g.updateSuggestionsVisibility()}),t.watch(()=>n.suggestions,()=>{g.updateSuggestionsVisibility()});function m(){x()}function b(T){if(!p.handleMentionKeyDown(T)&&!g.handleSuggestionKeyDown(T)&&T.key==="Enter"){if(T.shiftKey)return;!n.sending&&h.value&&(T.preventDefault(),C())}}function C(){if(!h.value)return;const T=u.buildPayload(),N=a.value.trim(),D=p.getMentions();s("submit",{message:N,attachments:T,mentions:D,isSupportRequest:n.supportRequestMode}),a.value="",u.clearAttachments(),p.clearMentions(),t.nextTick(x)}function w(){n.sending?s("cancel"):h.value&&C()}function $(){var T;n.disabled||n.sending||u.canAddMore.value&&((T=l.value)==null||T.click())}function z(T){g.handleSuggestionClick(T)}function F(){d.value=!0,g.updateSuggestionsVisibility()}function S(){d.value=!1,setTimeout(()=>{g.hideSuggestions(),p.showMentions.value=!1},200)}return t.onMounted(()=>{t.nextTick(x)}),(T,N)=>{var D;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",o.value.root]),onDragenter:N[6]||(N[6]=t.withModifiers((...M)=>t.unref(u).handleDragEnter&&t.unref(u).handleDragEnter(...M),["prevent"])),onDragover:N[7]||(N[7]=t.withModifiers((...M)=>t.unref(u).handleDragOver&&t.unref(u).handleDragOver(...M),["prevent"])),onDragleave:N[8]||(N[8]=t.withModifiers((...M)=>t.unref(u).handleDragLeave&&t.unref(u).handleDragLeave(...M),["prevent"])),onDrop:N[9]||(N[9]=t.withModifiers((...M)=>t.unref(u).handleDrop&&t.unref(u).handleDrop(...M),["prevent"]))},[t.createElementVNode("form",{onSubmit:t.withModifiers(C,["prevent"]),class:t.normalizeClass(o.value.form)},[t.createElementVNode("div",ea,[t.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:t.unref(u).acceptedFileTypes,onChange:N[0]||(N[0]=(...M)=>t.unref(u).handleFileSelect&&t.unref(u).handleFileSelect(...M))},null,40,ta),t.unref(u).hasAttachments.value?(t.openBlock(),t.createBlock(Vs,{key:0,attachments:t.unref(u).attachments.value,ui:o.value,texts:r.texts,"is-image":t.unref(u).isImage,"format-file-size":t.unref(u).formatFileSize,onRemove:t.unref(u).removeAttachment},null,8,["attachments","ui","texts","is-image","format-file-size","onRemove"])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["relative",o.value.inputContainer])},[t.unref(g).showSuggestions.value&&r.suggestions.length>0?(t.openBlock(),t.createBlock(Ws,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:r.suggestions,"selected-index":t.unref(g).selectedSuggestionIndex.value,ui:o.value,onSelect:z,onHover:N[1]||(N[1]=M=>t.unref(g).selectedSuggestionIndex.value=M)},null,8,["suggestions","selected-index","ui"])):t.createCommentVNode("",!0),t.createVNode(t.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:t.withCtx(()=>[t.unref(p).showMentions.value&&t.unref(p).mentionItems.value.length>0?(t.openBlock(),t.createBlock(Gn,{key:0,items:t.unref(p).mentionItems.value,"selected-index":t.unref(p).selectedMentionIndex.value,providers:t.unref(p).mentionProviders.value,onSelect:t.unref(p).handleMentionSelect,"onUpdate:selectedIndex":N[2]||(N[2]=M=>t.unref(p).selectedMentionIndex.value=M)},null,8,["items","selected-index","providers","onSelect"])):t.createCommentVNode("",!0)]),_:1}),t.createElementVNode("div",{class:t.normalizeClass(["rounded-2xl border shadow-lg transition-all duration-200 bg-white dark:bg-gray-800",[o.value.inputWrapper,{"border-primary shadow-primary/30":d.value||t.unref(u).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!d.value&&!t.unref(u).isDraggingFiles.value}]])},[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["absolute left-3 top-1/2 -translate-y-1/2 h-9 w-9 rounded-xl flex items-center justify-center text-gray-500 dark:text-gray-400 hover:text-primary transition z-10",o.value.attachButton]),title:((D=r.texts)==null?void 0:D.attachFiles)||"Attach files",onClick:$},[...N[10]||(N[10]=[t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M18.375 12.739l-7.693 7.693a4.5 4.5 0 01-6.364-6.364l10.94-10.94A3 3 0 1119.5 7.372L8.552 18.32m.009-.01l-.01.01m5.699-9.941l-7.81 7.81a1.5 1.5 0 002.112 2.13"})],-1)])],10,na),t.createElementVNode("div",oa,[t.withDirectives(t.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":N[3]||(N[3]=M=>a.value=M),rows:"1","data-ai-input":"",placeholder:y.value,disabled:r.disabled,class:t.normalizeClass(["block w-full bg-transparent py-3 text-sm leading-5 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 dark:placeholder:text-gray-500 border-0 focus:outline-none focus-visible:outline-none resize-none pl-12",[o.value.textarea,f.value]]),onInput:m,onKeydown:b,onFocus:F,onBlur:S},null,42,ra),[[t.vModelText,a.value]])]),t.createVNode(Js,{sending:r.sending,"can-send":h.value,"support-request-mode":r.supportRequestMode,"show-support-mode-toggle":r.showSupportModeToggle,ui:o.value,texts:r.texts,onToggleSupportMode:N[4]||(N[4]=M=>T.$emit("toggle-support-mode")),onClick:w},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),t.renderSlot(T.$slots,"context-link",{},()=>[r.contextLinkText?(t.openBlock(),t.createElementBlock("div",sa,[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",o.value.contextLink]),onClick:N[5]||(N[5]=M=>T.$emit("context-link-click"))},t.toDisplayString(r.contextLinkText),3)])):t.createCommentVNode("",!0)])])],34)],34)}}}),aa=["onClick"],Xn=t.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(r,{emit:e}){const n=r,o=e,s=x=>{var f;return(f=n.texts)!=null&&f[x]?n.texts[x]:J({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[x])},a=t.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=jt();function d(x){const y={...x,prompt:l(x)};o("item-click",y)}function u(x){return x.gradientClass?x.gradientClass:x.className?x.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function p(x){const y=x.category||"default",f={hr:"bg-blue-100 dark:bg-blue-900/30",finance:"bg-green-100 dark:bg-green-900/30",analytics:"bg-purple-100 dark:bg-purple-900/30",support:"bg-amber-100 dark:bg-amber-900/30",default:"bg-primary/10"};return f[y]||f.default}function g(x){const y=x.category||"default",f={hr:"text-blue-600 dark:text-blue-400",finance:"text-green-600 dark:text-green-400",analytics:"text-purple-600 dark:text-purple-400",support:"text-amber-600 dark:text-amber-400",default:"text-primary"};return f[y]||f.default}return(x,y)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center justify-center p-4 h-full",a.value.root])},[t.createElementVNode("div",{class:t.normalizeClass(["w-full max-w-4xl",a.value.content])},[t.createElementVNode("div",{class:t.normalizeClass(["mb-8 text-center",a.value.header])},[t.createElementVNode("div",{class:t.normalizeClass(["mb-3 inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary",a.value.badge])},[y[0]||(y[0]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(s("aiName")),1)],2),t.createElementVNode("h1",{class:t.normalizeClass(["mb-3 text-4xl font-bold tracking-tight text-gray-900 dark:text-white",a.value.title])},t.toDisplayString(s("title")),3),t.createElementVNode("p",{class:t.normalizeClass(["text-gray-600 dark:text-gray-400",a.value.description])},t.toDisplayString(s("description")),3)],2),t.createElementVNode("div",{class:t.normalizeClass(["mb-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",a.value.grid])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(i),(f,E)=>(t.openBlock(),t.createElementBlock("button",{key:f.id||E,class:t.normalizeClass(["group relative overflow-hidden rounded-xl border border-gray-300 dark:border-gray-600 p-4 text-left transition-all hover:shadow-md hover:scale-[1.02]",[a.value.suggestionCard,u(f)]]),onClick:h=>d(f)},[t.createElementVNode("div",{class:t.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,p(f)]])},[f.icon?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(f.icon),{key:0,class:t.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,g(f)]])},null,8,["class"])):(t.openBlock(),t.createElementBlock("svg",{key:1,class:t.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,g(f)]]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...y[1]||(y[1]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))],2),t.createElementVNode("h3",{class:t.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",a.value.suggestionTitle])},t.toDisplayString(f.title),3),t.createElementVNode("p",{class:t.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},t.toDisplayString(f.description),3)],10,aa))),128))],2)],2)],2))}}),ia={class:"flex items-center gap-3"},la={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},ca={key:1,class:"flex items-center gap-2"},ua={key:0,class:"flex items-center gap-2 ml-auto mr-3"},da=["title"],pa=["title"],fa=["title"],ma={key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ha={key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ga=t.defineComponent({__name:"DrawerHeader",props:{ui:{},isSetupMode:{type:Boolean},showNewChatButton:{type:Boolean},hasHistory:{type:Boolean},showQuota:{type:Boolean},quota:{},showCloseButton:{type:Boolean},showMinimizeButton:{type:Boolean},showFullscreenToggle:{type:Boolean},isFullscreen:{type:Boolean},t:{type:Function}},emits:["new-chat","close","minimize","toggle-fullscreen"],setup(r){return(e,n)=>{var o,s,a,i,l,d;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flex items-center justify-between px-4 sm:px-6 pt-4 border-b border-gray-200 dark:border-gray-700 pb-4",(o=r.ui)==null?void 0:o.header])},[t.createElementVNode("div",ia,[r.isSetupMode?(t.openBlock(),t.createElementBlock("div",ca,[...n[5]||(n[5]=[t.createElementVNode("span",{class:"flex h-2 w-2 rounded-full bg-amber-500 animate-pulse"},null,-1),t.createElementVNode("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Setup Required",-1)])])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[r.showNewChatButton&&r.hasHistory?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 transition-all duration-200 shadow-sm",(s=r.ui)==null?void 0:s.newChatButton]),onClick:n[0]||(n[0]=u=>e.$emit("new-chat"))},[n[4]||(n[4]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(r.t("newChat")),1)],2)):(t.openBlock(),t.createElementBlock("span",la,t.toDisplayString(r.t("keyboardShortcutHint")),1))],64))]),r.showQuota&&!r.isSetupMode?(t.openBlock(),t.createElementBlock("div",ua,[t.renderSlot(e.$slots,"quota",{},()=>{var u,p;return[r.quota.remaining>0?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["text-xs text-green-600 dark:text-green-400",(u=r.ui)==null?void 0:u.quotaDisplay])},t.toDisplayString(r.quota.remaining)+" "+t.toDisplayString(r.t("quotaRemaining")),3)):r.quota.remaining===0?(t.openBlock(),t.createElementBlock("span",{key:1,class:t.normalizeClass(["text-xs text-red-600 dark:text-red-400",(p=r.ui)==null?void 0:p.quotaDisplay])},t.toDisplayString(r.t("noQuota")),3)):t.createCommentVNode("",!0)]})])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["flex items-center gap-1",(a=r.ui)==null?void 0:a.headerActions])},[r.showCloseButton?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(i=r.ui)==null?void 0:i.headerActionButton]),title:r.t("close"),onClick:n[1]||(n[1]=u=>e.$emit("close"))},[...n[6]||(n[6]=[t.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,da)):t.createCommentVNode("",!0),r.showMinimizeButton?(t.openBlock(),t.createElementBlock("button",{key:1,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(l=r.ui)==null?void 0:l.headerActionButton]),title:r.t("minimize"),onClick:n[2]||(n[2]=u=>e.$emit("minimize"))},[...n[7]||(n[7]=[t.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"})],-1)])],10,pa)):t.createCommentVNode("",!0),r.showFullscreenToggle?(t.openBlock(),t.createElementBlock("button",{key:2,type:"button",class:t.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(d=r.ui)==null?void 0:d.headerActionButton]),title:r.isFullscreen?r.t("exitFullscreen"):r.t("fullscreen"),onClick:n[3]||(n[3]=u=>e.$emit("toggle-fullscreen"))},[r.isFullscreen?(t.openBlock(),t.createElementBlock("svg",ha,[...n[9]||(n[9]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",ma,[...n[8]||(n[8]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"},null,-1)])]))],10,fa)):t.createCommentVNode("",!0)],2)],2)}}}),ya={class:"max-w-3xl mx-auto px-4 space-y-6"},ka={class:"flex justify-center"},xa={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},wa={key:0,class:"flex justify-center"},ba=["title"],Ea=t.defineComponent({__name:"DrawerMessageList",props:{messages:{},loadingMessage:{},quota:{},error:{},ui:{},t:{type:Function}},emits:["copy","contact-support","retry"],setup(r){return(e,n)=>{var o,s,a;return t.openBlock(),t.createElementBlock("div",ya,[t.createElementVNode("div",ka,[t.createElementVNode("div",xa,[n[3]||(n[3]=t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(r.t("title")||t.unref(J)("aiName")),1)])]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.messages,(i,l)=>t.renderSlot(e.$slots,"message",{key:i.id||l,message:i,isUser:i.role==="user",isLoading:i.loading,isStreaming:i.streaming},()=>[t.createVNode(Zn,{message:i,"loading-text":r.loadingMessage,onCopy:n[0]||(n[0]=d=>e.$emit("copy",d))},null,8,["message","loading-text"])])),128)),r.quota.remaining===0?(t.openBlock(),t.createElementBlock("div",wa,[t.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 px-6 py-3 bg-primary text-white rounded-lg hover:bg-primary/90 transition-all shadow-sm",onClick:n[1]||(n[1]=i=>e.$emit("contact-support"))},[n[4]||(n[4]=t.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})],-1)),t.createElementVNode("span",null,t.toDisplayString(t.unref(J)("contactSupport")),1)])])):t.createCommentVNode("",!0),r.error.message?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["flex items-center gap-2 text-sm text-red-600 dark:text-red-400 px-2 py-1 pb-6",(o=r.ui)==null?void 0:o.errorContainer])},[t.createElementVNode("span",{class:t.normalizeClass((s=r.ui)==null?void 0:s.errorMessage)},t.toDisplayString(r.error.message),3),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["inline-flex items-center gap-1 text-red-700 dark:text-red-300 hover:text-red-800 dark:hover:text-red-200 font-medium",(a=r.ui)==null?void 0:a.retryButton]),title:r.t("retry"),onClick:n[2]||(n[2]=i=>e.$emit("retry"))},[...n[5]||(n[5]=[t.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1)])],10,ba)],2)):t.createCommentVNode("",!0)])}}}),Ca={class:"w-full max-w-md"},Sa={class:"bg-gray-900 rounded-xl overflow-hidden"},Ta={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},Aa=t.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(r){return(e,n)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[n[4]||(n[4]=t.createStaticVNode('<div class="w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"><svg class="w-7 h-7 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"></path></svg></div><h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-1"> Almost there! </h2><p class="text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-sm text-center"> Configure the plugin in your app entry file to start using AI. </p>',3)),t.createElementVNode("div",Ca,[t.createElementVNode("div",Sa,[t.createElementVNode("div",Ta,[n[1]||(n[1]=t.createElementVNode("span",{class:"text-xs text-gray-400"},"main.ts",-1)),t.createElementVNode("button",{type:"button",class:"text-xs text-gray-400 hover:text-white transition-colors",onClick:n[0]||(n[0]=o=>e.$emit("copy"))},t.toDisplayString(r.copied?"✓ Copied":"Copy"),1)]),n[2]||(n[2]=t.createStaticVNode(`<pre class="text-xs text-gray-100 p-4 overflow-x-auto leading-relaxed"><code class="language-typescript"><span class="text-purple-400">import</span> { RestifyAiPlugin } <span class="text-purple-400">from</span> <span class="text-green-400">&#39;@doderasoftware/restify-ai&#39;</span>
52
+ `}tablerow({text:t}){return`<tr>
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=xn(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=xn(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 zt{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 ce{constructor(t){_(this,"options");_(this,"renderer");_(this,"textRenderer");this.options=t||Ne,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 zt}static parse(t,n){return new ce(n).parse(t)}static parseInline(t,n){return new ce(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 We{constructor(t){_(this,"options");_(this,"block");this.options=t||Ne}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?le.lex:le.lexInline}provideParser(){return this.block?ce.parse:ce.parseInline}}_(We,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class bo{constructor(...t){_(this,"defaults",Mt());_(this,"options",this.setOptions);_(this,"parse",this.parseMarkdown(!0));_(this,"parseInline",this.parseMarkdown(!1));_(this,"Parser",ce);_(this,"Renderer",pt);_(this,"TextRenderer",zt);_(this,"Lexer",le);_(this,"Tokenizer",lt);_(this,"Hooks",We);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]=(...p)=>{let f=u.apply(a,p);return f===!1&&(f=d.apply(a,p)),f||""}}s.renderer=a}if(o.tokenizer){const a=this.defaults.tokenizer||new lt(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]=(...p)=>{let f=u.apply(a,p);return f===!1&&(f=d.apply(a,p)),f}}s.tokenizer=a}if(o.hooks){const a=this.defaults.hooks||new We;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];We.passThroughHooks.has(i)?a[l]=p=>{if(this.defaults.async)return Promise.resolve(u.call(a,p)).then(k=>d.call(a,k));const f=u.call(a,p);return d.call(a,f)}:a[l]=(...p)=>{let f=u.apply(a,p);return f===!1&&(f=d.apply(a,p)),f}}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 le.lex(t,n??this.defaults)}parser(t,n){return ce.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?le.lex:le.lexInline,d=i.hooks?i.hooks.provideParser():t?ce.parse:ce.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(o):o).then(p=>u(p,i)).then(p=>i.hooks?i.hooks.processAllTokens(p):p).then(p=>i.walkTokens?Promise.all(this.walkTokens(p,i.walkTokens)).then(()=>p):p).then(p=>d(p,i)).then(p=>i.hooks?i.hooks.postprocess(p):p).catch(l);try{i.hooks&&(o=i.hooks.preprocess(o));let p=u(o,i);i.hooks&&(p=i.hooks.processAllTokens(p)),i.walkTokens&&this.walkTokens(p,i.walkTokens);let f=d(p,i);return i.hooks&&(f=i.hooks.postprocess(f)),f}catch(p){return l(p)}}}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>"+ie(o.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(o);throw o}}}const Re=new bo;function V(r,t){return Re.parse(r,t)}V.options=V.setOptions=function(r){return Re.setOptions(r),V.defaults=Re.defaults,hn(V.defaults),V},V.getDefaults=Mt,V.defaults=Ne,V.use=function(...r){return Re.use(...r),V.defaults=Re.defaults,hn(V.defaults),V},V.walkTokens=function(r,t){return Re.walkTokens(r,t)},V.parseInline=Re.parseInline,V.Parser=ce,V.parser=ce.parse,V.Renderer=pt,V.TextRenderer=zt,V.Lexer=le,V.lexer=le.lex,V.Tokenizer=lt,V.Hooks=We,V.parse=V,V.options,V.setOptions,V.use,V.walkTokens,V.parseInline,ce.parse,le.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:Bn,setPrototypeOf:Ln,isFrozen:Eo,getPrototypeOf:Co,getOwnPropertyDescriptor:So}=Object;let{freeze:re,seal:ue,create:$t}=Object,{apply:Ot,construct:Vt}=typeof Reflect<"u"&&Reflect;re||(re=function(t){return t}),ue||(ue=function(t){return t}),Ot||(Ot=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)}),Vt||(Vt=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 mt=se(Array.prototype.forEach),To=se(Array.prototype.lastIndexOf),Dn=se(Array.prototype.pop),Ke=se(Array.prototype.push),Ao=se(Array.prototype.splice),ft=se(String.prototype.toLowerCase),Pt=se(String.prototype.toString),_t=se(String.prototype.match),Ge=se(String.prototype.replace),Mo=se(String.prototype.indexOf),No=se(String.prototype.trim),de=se(Object.prototype.hasOwnProperty),oe=se(RegExp.prototype.test),Qe=Ro(TypeError);function se(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 Ot(r,t,o)}}function Ro(r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return Vt(r,n)}}function D(r,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ft;Ln&&Ln(r,null);let o=t.length;for(;o--;){let s=t[o];if(typeof s=="string"){const a=n(s);a!==s&&(Eo(t)||(t[o]=a),s=a)}r[s]=!0}return r}function Bo(r){for(let t=0;t<r.length;t++)de(r,t)||(r[t]=null);return r}function he(r){const t=$t(null);for(const[n,o]of Bn(r))de(r,n)&&(Array.isArray(o)?t[n]=Bo(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=he(o):t[n]=o);return t}function Ze(r,t){for(;r!==null;){const o=So(r,t);if(o){if(o.get)return se(o.get);if(typeof o.value=="function")return se(o.value)}r=Co(r)}function n(){return null}return n}const In=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ft=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ht=re(["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"]),Lo=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ut=re(["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"]),Do=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zn=re(["#text"]),$n=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),qt=re(["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"]),On=re(["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"]),ht=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Io=ue(/\{\{[\w\W]*|[\w\W]*\}\}/gm),zo=ue(/<%[\w\W]*|[\w\W]*%>/gm),$o=ue(/\$\{[\w\W]*/gm),Oo=ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vo=ue(/^aria-[\-\w]+$/),Vn=ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Po=ue(/^(?:\w+script|data):/i),_o=ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pn=ue(/^html$/i),Fo=ue(/^[a-z][.\w]*(-[.\w]+)+$/i);var _n=Object.freeze({__proto__:null,ARIA_ATTR:Vo,ATTR_WHITESPACE:_o,CUSTOM_ELEMENT:Fo,DATA_ATTR:Oo,DOCTYPE_NAME:Pn,ERB_EXPR:zo,IS_ALLOWED_URI:Vn,IS_SCRIPT_OR_DATA:Po,MUSTACHE_EXPR:Io,TMPLIT_EXPR:$o});const Ye={element:1,text:3,progressingInstruction:7,comment:8,document:9},Ho=function(){return typeof window>"u"?null:window},Uo=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}},Fn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hn(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ho();const t=R=>Hn(R);if(t.version="3.3.0",t.removed=[],!r||!r.document||r.document.nodeType!==Ye.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:p=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:f,DOMParser:k,trustedTypes:h}=r,m=u.prototype,E=Ze(m,"cloneNode"),y=Ze(m,"remove"),g=Ze(m,"nextSibling"),b=Ze(m,"childNodes"),C=Ze(m,"parentNode");if(typeof i=="function"){const R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let w,I="";const{implementation:$,createNodeIterator:F,createDocumentFragment:S,getElementsByTagName:T}=n,{importNode:N}=o;let z=Fn();t.isSupported=typeof Bn=="function"&&typeof C=="function"&&$&&$.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:K,TMPLIT_EXPR:me,DATA_ATTR:ze,ARIA_ATTR:Be,IS_SCRIPT_OR_DATA:ge,ATTR_WHITESPACE:Xe,CUSTOM_ELEMENT:Wt}=_n;let{IS_ALLOWED_URI:gt}=_n,G=null;const Ce=D({},[...In,...Ft,...Ht,...Ut,...zn]);let Q=null;const Je=D({},[...$n,...qt,...On,...ht]);let v=Object.seal($t(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Le=null,et=null;const ye=Object.seal($t(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,nt=!0,rt=!1,B=!0,O=!1,j=!0,H=!1,Y=!1,W=!1,X=!1,Se=!1,yt=!1,tr=!0,nr=!1;const qa="user-content-";let Kt=!0,ot=!1,$e={},Oe=null;const rr=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 or=null;const sr=D({},["audio","video","img","source","image","track"]);let Gt=null;const ar=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",ke="http://www.w3.org/1999/xhtml";let Ve=ke,Qt=!1,Zt=null;const va=D({},[kt,xt,ke],Pt);let wt=D({},["mi","mo","mn","ms","mtext"]),bt=D({},["annotation-xml"]);const ja=D({},["title","style","font","a","script"]);let st=null;const Wa=["application/xhtml+xml","text/html"],Ka="text/html";let J=null,Pe=null;const Ga=n.createElement("form"),ir=function(c){return c instanceof RegExp||c instanceof Function},Yt=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Pe&&Pe===c)){if((!c||typeof c!="object")&&(c={}),c=he(c),st=Wa.indexOf(c.PARSER_MEDIA_TYPE)===-1?Ka:c.PARSER_MEDIA_TYPE,J=st==="application/xhtml+xml"?Pt:ft,G=de(c,"ALLOWED_TAGS")?D({},c.ALLOWED_TAGS,J):Ce,Q=de(c,"ALLOWED_ATTR")?D({},c.ALLOWED_ATTR,J):Je,Zt=de(c,"ALLOWED_NAMESPACES")?D({},c.ALLOWED_NAMESPACES,Pt):va,Gt=de(c,"ADD_URI_SAFE_ATTR")?D(he(ar),c.ADD_URI_SAFE_ATTR,J):ar,or=de(c,"ADD_DATA_URI_TAGS")?D(he(sr),c.ADD_DATA_URI_TAGS,J):sr,Oe=de(c,"FORBID_CONTENTS")?D({},c.FORBID_CONTENTS,J):rr,Le=de(c,"FORBID_TAGS")?D({},c.FORBID_TAGS,J):he({}),et=de(c,"FORBID_ATTR")?D({},c.FORBID_ATTR,J):he({}),$e=de(c,"USE_PROFILES")?c.USE_PROFILES:!1,tt=c.ALLOW_ARIA_ATTR!==!1,nt=c.ALLOW_DATA_ATTR!==!1,rt=c.ALLOW_UNKNOWN_PROTOCOLS||!1,B=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=c.SAFE_FOR_TEMPLATES||!1,j=c.SAFE_FOR_XML!==!1,H=c.WHOLE_DOCUMENT||!1,X=c.RETURN_DOM||!1,Se=c.RETURN_DOM_FRAGMENT||!1,yt=c.RETURN_TRUSTED_TYPE||!1,W=c.FORCE_BODY||!1,tr=c.SANITIZE_DOM!==!1,nr=c.SANITIZE_NAMED_PROPS||!1,Kt=c.KEEP_CONTENT!==!1,ot=c.IN_PLACE||!1,gt=c.ALLOWED_URI_REGEXP||Vn,Ve=c.NAMESPACE||ke,wt=c.MATHML_TEXT_INTEGRATION_POINTS||wt,bt=c.HTML_INTEGRATION_POINTS||bt,v=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&ir(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(v.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&ir(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(v.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(v.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),O&&(nt=!1),Se&&(X=!0),$e&&(G=D({},zn),Q=[],$e.html===!0&&(D(G,In),D(Q,$n)),$e.svg===!0&&(D(G,Ft),D(Q,qt),D(Q,ht)),$e.svgFilters===!0&&(D(G,Ht),D(Q,qt),D(Q,ht)),$e.mathMl===!0&&(D(G,Ut),D(Q,On),D(Q,ht))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?ye.tagCheck=c.ADD_TAGS:(G===Ce&&(G=he(G)),D(G,c.ADD_TAGS,J))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?ye.attributeCheck=c.ADD_ATTR:(Q===Je&&(Q=he(Q)),D(Q,c.ADD_ATTR,J))),c.ADD_URI_SAFE_ATTR&&D(Gt,c.ADD_URI_SAFE_ATTR,J),c.FORBID_CONTENTS&&(Oe===rr&&(Oe=he(Oe)),D(Oe,c.FORBID_CONTENTS,J)),Kt&&(G["#text"]=!0),H&&D(G,["html","head","body"]),G.table&&(D(G,["tbody"]),delete Le.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=c.TRUSTED_TYPES_POLICY,I=w.createHTML("")}else w===void 0&&(w=Uo(h,s)),w!==null&&typeof I=="string"&&(I=w.createHTML(""));re&&re(c),Pe=c}},lr=D({},[...Ft,...Ht,...Lo]),cr=D({},[...Ut,...Do]),Qa=function(c){let x=C(c);(!x||!x.tagName)&&(x={namespaceURI:Ve,tagName:"template"});const A=ft(c.tagName),U=ft(x.tagName);return Zt[c.namespaceURI]?c.namespaceURI===xt?x.namespaceURI===ke?A==="svg":x.namespaceURI===kt?A==="svg"&&(U==="annotation-xml"||wt[U]):!!lr[A]:c.namespaceURI===kt?x.namespaceURI===ke?A==="math":x.namespaceURI===xt?A==="math"&&bt[U]:!!cr[A]:c.namespaceURI===ke?x.namespaceURI===xt&&!bt[U]||x.namespaceURI===kt&&!wt[U]?!1:!cr[A]&&(ja[A]||!lr[A]):!!(st==="application/xhtml+xml"&&Zt[c.namespaceURI]):!1},fe=function(c){Ke(t.removed,{element:c});try{C(c).removeChild(c)}catch{y(c)}},De=function(c,x){try{Ke(t.removed,{attribute:x.getAttributeNode(c),from:x})}catch{Ke(t.removed,{attribute:null,from:x})}if(x.removeAttribute(c),c==="is")if(X||Se)try{fe(x)}catch{}else try{x.setAttribute(c,"")}catch{}},ur=function(c){let x=null,A=null;if(W)c="<remove></remove>"+c;else{const Z=_t(c,/^[\r\n\t ]+/);A=Z&&Z[0]}st==="application/xhtml+xml"&&Ve===ke&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const U=w?w.createHTML(c):c;if(Ve===ke)try{x=new k().parseFromString(U,st)}catch{}if(!x||!x.documentElement){x=$.createDocument(Ve,"template",null);try{x.documentElement.innerHTML=Qt?I:U}catch{}}const ne=x.body||x.documentElement;return c&&A&&ne.insertBefore(n.createTextNode(A),ne.childNodes[0]||null),Ve===ke?T.call(x,H?"html":"body")[0]:H?x.documentElement:ne},dr=function(c){return F.call(c.ownerDocument||c,c,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Xt=function(c){return c instanceof f&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof p)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},pr=function(c){return typeof l=="function"&&c instanceof l};function xe(R,c,x){mt(R,A=>{A.call(t,c,x,Pe)})}const mr=function(c){let x=null;if(xe(z.beforeSanitizeElements,c,null),Xt(c))return fe(c),!0;const A=J(c.nodeName);if(xe(z.uponSanitizeElement,c,{tagName:A,allowedTags:G}),j&&c.hasChildNodes()&&!pr(c.firstElementChild)&&oe(/<[/\w!]/g,c.innerHTML)&&oe(/<[/\w!]/g,c.textContent)||c.nodeType===Ye.progressingInstruction||j&&c.nodeType===Ye.comment&&oe(/<[/\w]/g,c.data))return fe(c),!0;if(!(ye.tagCheck instanceof Function&&ye.tagCheck(A))&&(!G[A]||Le[A])){if(!Le[A]&&hr(A)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A)))return!1;if(Kt&&!Oe[A]){const U=C(c)||c.parentNode,ne=b(c)||c.childNodes;if(ne&&U){const Z=ne.length;for(let ae=Z-1;ae>=0;--ae){const we=E(ne[ae],!0);we.__removalCount=(c.__removalCount||0)+1,U.insertBefore(we,g(c))}}}return fe(c),!0}return c instanceof u&&!Qa(c)||(A==="noscript"||A==="noembed"||A==="noframes")&&oe(/<\/no(script|embed|frames)/i,c.innerHTML)?(fe(c),!0):(O&&c.nodeType===Ye.text&&(x=c.textContent,mt([M,K,me],U=>{x=Ge(x,U," ")}),c.textContent!==x&&(Ke(t.removed,{element:c.cloneNode()}),c.textContent=x)),xe(z.afterSanitizeElements,c,null),!1)},fr=function(c,x,A){if(tr&&(x==="id"||x==="name")&&(A in n||A in Ga))return!1;if(!(nt&&!et[x]&&oe(ze,x))){if(!(tt&&oe(Be,x))){if(!(ye.attributeCheck instanceof Function&&ye.attributeCheck(x,c))){if(!Q[x]||et[x]){if(!(hr(c)&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,c)||v.tagNameCheck instanceof Function&&v.tagNameCheck(c))&&(v.attributeNameCheck instanceof RegExp&&oe(v.attributeNameCheck,x)||v.attributeNameCheck instanceof Function&&v.attributeNameCheck(x,c))||x==="is"&&v.allowCustomizedBuiltInElements&&(v.tagNameCheck instanceof RegExp&&oe(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A))))return!1}else if(!Gt[x]){if(!oe(gt,Ge(A,Xe,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&c!=="script"&&Mo(A,"data:")===0&&or[c])){if(!(rt&&!oe(ge,Ge(A,Xe,"")))){if(A)return!1}}}}}}}return!0},hr=function(c){return c!=="annotation-xml"&&_t(c,Wt)},gr=function(c){xe(z.beforeSanitizeAttributes,c,null);const{attributes:x}=c;if(!x||Xt(c))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Q,forceKeepAttr:void 0};let U=x.length;for(;U--;){const ne=x[U],{name:Z,namespaceURI:ae,value:we}=ne,_e=J(Z),Jt=we;let te=Z==="value"?Jt:No(Jt);if(A.attrName=_e,A.attrValue=te,A.keepAttr=!0,A.forceKeepAttr=void 0,xe(z.uponSanitizeAttribute,c,A),te=A.attrValue,nr&&(_e==="id"||_e==="name")&&(De(Z,c),te=qa+te),j&&oe(/((--!?|])>)|<\/(style|title|textarea)/i,te)){De(Z,c);continue}if(_e==="attributename"&&_t(te,"href")){De(Z,c);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){De(Z,c);continue}if(!B&&oe(/\/>/i,te)){De(Z,c);continue}O&&mt([M,K,me],kr=>{te=Ge(te,kr," ")});const yr=J(c.nodeName);if(!fr(yr,_e,te)){De(Z,c);continue}if(w&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!ae)switch(h.getAttributeType(yr,_e)){case"TrustedHTML":{te=w.createHTML(te);break}case"TrustedScriptURL":{te=w.createScriptURL(te);break}}if(te!==Jt)try{ae?c.setAttributeNS(ae,Z,te):c.setAttribute(Z,te),Xt(c)?fe(c):Dn(t.removed)}catch{De(Z,c)}}xe(z.afterSanitizeAttributes,c,null)},Za=function R(c){let x=null;const A=dr(c);for(xe(z.beforeSanitizeShadowDOM,c,null);x=A.nextNode();)xe(z.uponSanitizeShadowNode,x,null),mr(x),gr(x),x.content instanceof a&&R(x.content);xe(z.afterSanitizeShadowDOM,c,null)};return t.sanitize=function(R){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,A=null,U=null,ne=null;if(Qt=!R,Qt&&(R="<!-->"),typeof R!="string"&&!pr(R))if(typeof R.toString=="function"){if(R=R.toString(),typeof R!="string")throw Qe("dirty is not a string, aborting")}else throw Qe("toString is not a function");if(!t.isSupported)return R;if(Y||Yt(c),t.removed=[],typeof R=="string"&&(ot=!1),ot){if(R.nodeName){const we=J(R.nodeName);if(!G[we]||Le[we])throw Qe("root node is forbidden and cannot be sanitized in-place")}}else if(R instanceof l)x=ur("<!---->"),A=x.ownerDocument.importNode(R,!0),A.nodeType===Ye.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?x=A:x.appendChild(A);else{if(!X&&!O&&!H&&R.indexOf("<")===-1)return w&&yt?w.createHTML(R):R;if(x=ur(R),!x)return X?null:yt?I:""}x&&W&&fe(x.firstChild);const Z=dr(ot?R:x);for(;U=Z.nextNode();)mr(U),gr(U),U.content instanceof a&&Za(U.content);if(ot)return R;if(X){if(Se)for(ne=S.call(x.ownerDocument);x.firstChild;)ne.appendChild(x.firstChild);else ne=x;return(Q.shadowroot||Q.shadowrootmode)&&(ne=N.call(o,ne,!0)),ne}let ae=H?x.outerHTML:x.innerHTML;return H&&G["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&oe(Pn,x.ownerDocument.doctype.name)&&(ae="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
58
+ `+ae),O&&mt([M,K,me],we=>{ae=Ge(ae,we," ")}),w&&yt?w.createHTML(ae):ae},t.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(R),Y=!0},t.clearConfig=function(){Pe=null,Y=!1},t.isValidAttribute=function(R,c,x){Pe||Yt({});const A=J(R),U=J(c);return fr(A,U,x)},t.addHook=function(R,c){typeof c=="function"&&Ke(z[R],c)},t.removeHook=function(R,c){if(c!==void 0){const x=To(z[R],c);return x===-1?void 0:Ao(z[R],x,1)[0]}return Dn(z[R])},t.removeHooks=function(R){z[R]=[]},t.removeAllHooks=function(){z=Fn()},t}var qo=Hn();function Un(){return{parseMarkdown:t=>{if(!t||typeof t!="string")return"";const n=ln(t),o=V.parse(n,{async:!1,breaks:!0,gfm:!0});return qo.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 vo(){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 jo(){const r=Ee(),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 vt(){const r=Ee(),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 pe=[],qn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const r=q();return(r==null?void 0:r.defaultSuggestions)||[]}};function Wo(){pe.length=0;const r=q();r!=null&&r.suggestionProviders&&pe.push(...r.suggestionProviders),pe.push(qn)}function Ko(r,t){const n=[...pe].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 qn}function vn(r,t){pe.length===0&&Wo();const n=Ko(r,t),o=t||{pageType:"default",routePath:r};return n.extractContext&&(o.metadata={...o.metadata,...n.extractContext(r)}),n.getSuggestions(o)||[]}function Go(r){const t=pe.findIndex(n=>n.id===r.id);if(t>=0)pe[t]=r;else{const n=pe.findIndex(o=>o.id==="default");n>=0?pe.splice(n,0,r):pe.push(r)}}const Qo=Go;function jt(){const{context:r}=vt(),t=Ee(),n=e.computed(()=>{var u;if(t.quota.remaining===0){const d=q();return(d==null?void 0:d.enableSupportMode)!==!1?[{id:"contact-support-quota",title:ee("contactSupport"),description:ee("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[]}const a=((u=r.value)==null?void 0:u.routePath)||(typeof window<"u"?window.location.pathname:"/"),i=vn(a,r.value)||[],l=q();return l!=null&&l.can?i.filter(d=>!(d.permission&&!l.can(d.permission))):i}),o=e.computed(()=>r.value!==null&&r.value.pageType!=="default");function s(a){return typeof a.prompt=="function"?a.prompt(r.value||{pageType:"default"}):a.prompt}return{suggestions:n,hasContextualSuggestions:o,resolvePrompt:s}}function Zo(r,t){const{setContext:n,clearContext:o,updateContext:s}=vt();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 Yo(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 Xo(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,p=t.shift?r.shiftKey:!r.shiftKey,f=t.alt?r.altKey:!r.altKey;return n===t.key&&d&&p&&f}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:Ae("keyboardShortcut")??"mod+g";if(s===null)return{isActive:o};const a=Yo(s);function i(l){if(!n)return;const u=l.target,d=u.tagName==="INPUT"||u.tagName==="TEXTAREA",p=u.isContentEditable,f=u.closest("[data-ai-input]");if(!((d||p)&&!f)&&Xo(l,a)){l.preventDefault(),l.stopPropagation();const k=q();if(k!=null&&k.canToggle&&!k.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 Jo(r){const t=Ee();return jn({onToggle:()=>{r?r.value=!r.value:t.showChat=!t.showChat}})}function es(r,t){const n=e.ref(ee("loadingText"));let o=[];function s(){return[ee("loadingText"),ee("analyzingText"),ee("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(),p=(d==null?void 0:d.messages)??s();n.value=p[0]||ee("loadingText")}function u(){i();const d=t==null?void 0:t(),p=(d==null?void 0:d.messages)??s(),f=(d==null?void 0:d.intervals)??a();n.value=p[0]||ee("loadingText");let k=0;for(let h=1;h<p.length;h++){k+=f[h]||2e3;const m=h,E=window.setTimeout(()=>{r()&&(n.value=p[m])},k);o.push(E)}}return e.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:u,resetLoadingText:l,clearLoadingTextTimers:i}}function ts(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 C;return((C=o())==null?void 0:C.limit)??n()}),d=e.computed(()=>{var C;return((C=o())==null?void 0:C.showWarningAt)??u.value-2}),p=e.computed(()=>Math.max(0,u.value-t())),f=e.computed(()=>p.value<=u.value-d.value&&p.value>0),k=e.computed(()=>p.value===0),h=e.computed(()=>{var C,w;return l.value.isReached?((C=s())==null?void 0:C.historyLimitReachedTitle)??"Chat Limit Reached":((w=s())==null?void 0:w.historyLimitWarningTitle)??"Approaching Chat Limit"}),m=e.computed(()=>{var C,w,I,$;return l.value.isReached?((C=o())==null?void 0:C.limitMessage)??((w=s())==null?void 0:w.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":((I=o())==null?void 0:I.warningMessage)??(($=s())==null?void 0:$.historyLimitWarningMessage)??`You have ${p.value} message${p.value===1?"":"s"} remaining in this conversation.`});function E(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function y(){l.value.showWarning=!1;const C=o();if(C!=null&&C.onLimitReached&&!await C.onLimitReached())return l.value.isReached=!1,null;if(a(),i(),l.value.isReached=!1,l.value.pendingMessage){const w=l.value.pendingMessage;return l.value.pendingMessage=null,w}return null}function g(){return k.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(f.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function b(C){l.value.pendingMessage=C}return{showHistoryLimitWarning:e.computed(()=>l.value.showWarning),historyLimitReached:e.computed(()=>l.value.isReached),historyLimit:u,remainingMessages:p,historyLimitDialogTitle:h,historyLimitDialogMessage:m,dismissHistoryLimitWarning:E,handleHistoryLimitAction:y,checkHistoryLimit:g,setPendingMessage:b}}function ns(){const r=Ee(),t=e.ref([]),n=e.ref(!1),o=e.ref(0),s=Ae("maxAttachments")||5,a=Ae("maxFileSize")||10*1024*1024,i=Ae("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=e.computed(()=>t.value.length>0),u=e.computed(()=>t.value.some(S=>S.uploading)),d=e.computed(()=>t.value.length<s);function p(S){return(S.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(S.name)}function f(S){if(S==null)return"";const T=typeof S=="string"?parseInt(S,10):S;return Number.isNaN(T)?"":T>=1024*1024?`${(T/(1024*1024)).toFixed(1)} MB`:T>=1024?`${Math.round(T/1024)} KB`:`${T} B`}function k(S){var me;const T=crypto.randomUUID(),N=S.type.startsWith("image/")?URL.createObjectURL(S):void 0,z=q(),M=!!((me=z==null?void 0:z.endpoints)!=null&&me.uploadFile),K={id:T,name:S.name,type:S.type,size:S.size,uploading:M,progress:M?0:100,previewUrl:N};t.value.push(K),M&&h(S,T)}async function h(S,T){try{const N=await r.uploadFile(S),z=t.value.findIndex(M=>M.id===T);if(z===-1)return;if(N){const M=t.value[z].previewUrl;t.value[z]={...t.value[z],id:N.id||T,url:N.url,extractedText:N.extractedText,uploading:!1,progress:100,previewUrl:M||N.previewUrl}}else m(T)}catch{m(T)}}function m(S){const T=t.value.findIndex(z=>z.id===S);if(T===-1)return;const[N]=t.value.splice(T,1);N!=null&&N.previewUrl&&URL.revokeObjectURL(N.previewUrl)}function E(){t.value.forEach(S=>{S.previewUrl&&URL.revokeObjectURL(S.previewUrl)}),t.value=[]}function y(){return t.value.filter(S=>!S.uploading).map(S=>({id:S.id,name:S.name,url:S.url,type:S.type,size:S.size}))}function g(S){if(!S)return;const T=Array.from(S);for(const N of T){if(t.value.length>=s)break;N.size>a||k(N)}}function b(S){var T;return Array.from(((T=S.dataTransfer)==null?void 0:T.types)||[]).includes("Files")}function C(S){b(S)&&(o.value+=1,n.value=!0)}function w(S){b(S)||S.preventDefault()}function I(S){b(S)&&(o.value=Math.max(0,o.value-1),o.value===0&&(n.value=!1))}function $(S){var T;b(S)&&(o.value=0,n.value=!1,g(((T=S.dataTransfer)==null?void 0:T.files)||null))}function F(S){const T=S.target,N=T.files;N&&N.length&&g(N),T.value=""}return e.onBeforeUnmount(()=>{E()}),{attachments:t,isDraggingFiles:n,hasAttachments:l,isUploading:u,canAddMore:d,acceptedFileTypes:i,isImage:p,formatFileSize:f,removeAttachment:m,clearAttachments:E,buildPayload:y,processFiles:g,handleFileSelect:F,handleDragEnter:C,handleDragOver:w,handleDragLeave:I,handleDrop:$}}function rs(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([]),u=e.computed(()=>{const E=q();return(E==null?void 0:E.mentionProviders)||[]});function d(E){const y=n();if(!y)return;const g=y.selectionStart,b=cn(E,g);i.value=b,b.inMention&&b.query.length>=0?p(b.query):(o.value=!1,s.value=[])}async function p(E){const y=pn();if(y.length===0){o.value=!1;return}const g=[];for(const b of y)try{const C=await b.search(E);g.push(...C.map(w=>({...w,type:b.type})))}catch(C){console.warn(`Mention provider ${b.type} failed:`,C)}s.value=g.slice(0,10),o.value=g.length>0,a.value=0}function f(E){const{startPos:y}=i.value,g=r(),b=n(),C=g.slice(0,y),w=g.slice((b==null?void 0:b.selectionStart)||y),I=E.name||E.label||E.title||E.id;t(`${C}@${I} ${w}`),l.value.push({id:E.id,name:I,type:E.type,metadata:E.attributes}),o.value=!1,s.value=[],setTimeout(()=>{const $=n();$==null||$.focus();const F=C.length+I.length+2;$==null||$.setSelectionRange(F,F)},0)}function k(E){if(!o.value||s.value.length===0)return!1;if(E.key==="ArrowDown")return E.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(E.key==="ArrowUp")return E.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(E.key==="Enter"||E.key==="Tab"){E.preventDefault();const y=s.value[a.value];return y&&f(y),!0}return E.key==="Escape"?(E.preventDefault(),o.value=!1,!0):!1}function h(){l.value=[]}function m(){return[...l.value]}return{showMentions:o,mentionItems:s,selectedMentionIndex:a,mentionProviders:u,checkForMentions:d,handleMentionSelect:f,handleMentionKeyDown:k,clearMentions:h,getMentions:m}}function os(r,t,n,o,s){const a=e.ref(!1),i=e.ref(-1),l=e.ref(null);function u(){setTimeout(()=>{const h=l.value;if(!h)return;const m=h.querySelector(`li:nth-child(${i.value+1})`);m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function d(h){const m=r();if(!a.value||m.length===0)return!1;if(h.key==="ArrowDown")return h.preventDefault(),i.value=Math.min(i.value+1,m.length-1),u(),!0;if(h.key==="ArrowUp")return h.preventDefault(),i.value=Math.max(i.value-1,0),u(),!0;if(h.key==="Enter"&&i.value>=0){h.preventDefault();const E=m[i.value];return E&&p(E),!0}return h.key==="Escape"?(h.preventDefault(),a.value=!1,i.value=-1,!0):!1}function p(h){s(h),a.value=!1,i.value=-1}function f(){const h=o(),m=t(),E=n(),y=r();h&&!m&&E&&y.length>0?a.value=!0:a.value=!1}function k(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:d,handleSuggestionClick:p,updateSuggestionsVisibility:f,hideSuggestions:k}}function ss(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 Wn=e.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-6 h-6 min-w-[24px] flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-600",(o=r.ui)==null?void 0:o.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-4 h-4 text-gray-400 dark:text-gray-500",(s=r.ui)==null?void 0:s.icon]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))]})],2)}}}),as=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.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:e.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},[...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)])],2))]})],2)}}}),is=["onClick","onMouseenter"],Kn=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,y=>{a.value=y}),e.watch(a,y=>{s("update:selectedIndex",y)});const i=e.computed(()=>{const y={};return n.items.forEach(g=>{const b=g.type||"default";y[b]||(y[b]=[]),y[b].push(g)}),y});function l(y){return n.providers.find(g=>g.type===y)||dn(y)}function u(y){const g=l(y);return(g==null?void 0:g.label)||y.charAt(0).toUpperCase()+y.slice(1)+"s"}function d(y,g){let b=0;const C=Object.keys(i.value);for(const w of C){if(w===y)return b+g;b+=i.value[w].length}return b}function p(y){s("select",y)}function f(y){a.value=y,s("update:selectedIndex",y)}function k(y){const g=l(y.type);return At(y,g)}function h(y){const g=l(y.type);return un(y,g)}function m(y){const g={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 g[y]||g.default}function E(y){return y.split(" ").map(g=>g[0]).join("").slice(0,2).toUpperCase()}return(y,g)=>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,(b,C)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:C},[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(C)),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(w,I)=>(e.openBlock(),e.createElementBlock("button",{key:w.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(C,I)===a.value,"hover:bg-gray-50 dark:hover:bg-gray-700":d(C,I)!==a.value}]]),onClick:$=>p(w),onMouseenter:$=>f(d(C,I))},[e.renderSlot(y.$slots,"item-icon",{item:w,type:C},()=>[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,m(w.type)]])},e.toDisplayString(E(k(w))),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(k(w)),3),h(w)?(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(h(w)),3)):e.createCommentVNode("",!0)],2)],42,is))),128))],64))),128))],2)],2)):e.createCommentVNode("",!0)}}),ls=["title"],cs={key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Gn=e.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(r,{emit:t}){const n=r,o=t,s=u=>{var p;return(p=n.texts)!=null&&p[u]?n.texts[u]:ee({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.createElementBlock("svg",{key:1,class:e.normalizeClass(["w-4 h-4 text-green-500",a.value.successState]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[...d[1]||(d[1]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])],2)):(e.openBlock(),e.createElementBlock("svg",cs,[...d[0]||(d[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)])]))],10,ls)],2))}}),us={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},ds=["src"],ps={key:1,class:"w-5 h-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ms={class:"flex-1 min-w-0"},fs={class:"text-sm font-semibold text-white truncate"},hs={class:"text-xs text-white/70"},gs={key:0,class:"text-xs font-medium text-white/90"},ys=["src"],ks={key:1,class:"h-4 w-4 text-white",viewBox:"0 0 24 24",fill:"currentColor"},xs={class:"flex-shrink-0 mt-0.5"},ws={class:"text-gray-600 dark:text-gray-400"},bs=["id","innerHTML"],Es={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"},Cs=["src"],Ss={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ts={class:"flex-1 min-w-0"},As={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},Ms={class:"text-xs text-gray-500 dark:text-gray-400"},Ns={key:0,class:"text-xs font-medium text-primary"},Rs=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=g=>{var C;return(C=n.texts)!=null&&C[g]?n.texts[g]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[g]||g},a=e.computed(()=>n.ui||{}),{parseMarkdown:i}=Un(),l=e.ref(!1),u=e.computed(()=>n.message.attachments??[]),d=e.computed(()=>u.value.length>0),p=e.computed(()=>{if(n.message.role!=="user")return!1;const g=n.message.message||"",b=g.split(`
59
+ `).length;return g.length>200||b>4});function f(){l.value=!l.value}function k(g){return(g.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(g.name||"")}const h=e.computed(()=>{const g=q();return g!=null&&g.userAvatar?typeof g.userAvatar=="string"?g.userAvatar:typeof g.userAvatar=="function"?g.userAvatar():null:null});function m(g){if(g==null)return"";const b=typeof g=="string"?parseInt(g,10):g;return Number.isNaN(b)?"":b>=1024*1024?`${(b/(1024*1024)).toFixed(1)} MB`:b>=1024?`${Math.round(b/1024)} KB`:`${b} B`}const E=e.computed(()=>{if(n.message.role==="assistant"){let g=n.message.message;return g=g.replace(/\\n/g,`
60
+ `),i(g)}return n.message.message});function y(g){o("copy",g)}return(g,b)=>{var C;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[a.value.root,{"flex justify-end":r.message.role==="user","flex justify-start":r.message.role==="assistant"}]])},[r.message.role==="user"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex gap-3 justify-end",a.value.userMessage])},[e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl px-4 py-3 bg-primary-500 text-white max-w-fit",a.value.userBubble])},[r.message.message?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-sm whitespace-pre-wrap",[a.value.content,{"line-clamp-4":!l.value&&p.value}]])},e.toDisplayString(r.message.message),3)):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",a.value.showMoreButton]),onClick:f},e.toDisplayString(l.value?s("showLess"):s("showMore")),3)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-3 space-y-2",a.value.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,w=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.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",[a.value.attachmentItem,w.url?"hover:bg-white/20 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",us,[w.url&&k(w)?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,ds)):(e.openBlock(),e.createElementBlock("svg",ps,[...b[0]||(b[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)])]))]),e.createElementVNode("div",ms,[e.createElementVNode("p",fs,e.toDisplayString(w.name||s("attachment")),1),e.createElementVNode("p",hs,e.toDisplayString(m(w.size)),1)]),w.url?(e.openBlock(),e.createElementBlock("span",gs,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",a.value.userAvatar])},[h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:h.value,alt:"User",class:"h-full w-full object-cover"},null,8,ys)):(e.openBlock(),e.createElementBlock("svg",ks,[...b[1]||(b[1]=[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)])]))],2)],2)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-start gap-3",a.value.assistantMessage])},[e.createElementVNode("div",xs,[e.createVNode(Wn)]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-5 py-4 shadow-sm rounded-2xl transition-all duration-200 flex-1",a.value.assistantBubble])},[r.message.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",a.value.loadingIndicator])},[e.createElementVNode("div",{class:e.normalizeClass(["flex space-x-1",a.value.loadingDots])},[...b[2]||(b[2]=[e.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"0ms"}},null,-1),e.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"150ms"}},null,-1),e.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"300ms"}},null,-1)])],2),e.createElementVNode("span",ws,e.toDisplayString(((C=r.texts)==null?void 0:C.loadingText)||r.loadingText),1)],2)):r.message.message?(e.openBlock(),e.createElementBlock("div",{key:1,id:r.message.id,class:e.normalizeClass(["prose prose-sm max-w-none prose-gray dark:prose-invert",a.value.content]),innerHTML:E.value},null,10,bs)):e.createCommentVNode("",!0),!r.message.loading&&d.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-4 space-y-2",a.value.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,w=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.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",[a.value.attachmentItem,w.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",Es,[w.url&&k(w)?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,Cs)):(e.openBlock(),e.createElementBlock("svg",Ss,[...b[3]||(b[3]=[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)])]))]),e.createElementVNode("div",Ts,[e.createElementVNode("p",As,e.toDisplayString(w.name||s("attachment")),1),e.createElementVNode("p",Ms,e.toDisplayString(m(w.size)),1)]),w.url?(e.openBlock(),e.createElementBlock("span",Ns,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(Gn,{key:2,message:r.message,class:e.normalizeClass(["absolute -bottom-8 left-14",a.value.actionsContainer]),onCopy:y},null,8,["message","class"])):e.createCommentVNode("",!0)],2)}}}),Qn=(r,t)=>{const n=r.__vccOpts||r;for(const[o,s]of t)n[o]=s;return n},Zn=Qn(Rs,[["__scopeId","data-v-5f7bccb0"]]),Bs={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},Ls={class:"space-y-2"},Ds=["src"],Is={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},zs={class:"flex-1 min-w-0"},$s={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},Os={class:"text-xs text-gray-500 dark:text-gray-400"},Vs={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Ps={key:0,class:"text-xs text-gray-400"},_s=["disabled","onClick"],Fs=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",Bs,e.toDisplayString(((o=r.texts)==null?void 0:o.attachedFiles)||"Attached files"),1),e.createElementVNode("ul",Ls,[(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,Ds)):(e.openBlock(),e.createElementBlock("svg",Is,[...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)])]))],2),e.createElementVNode("div",zs,[e.createElementVNode("p",$s,e.toDisplayString(s.name),1),e.createElementVNode("p",Os,e.toDisplayString(r.formatFileSize(s.size)),1),s.uploading?(e.openBlock(),e.createElementBlock("div",Vs,[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",Ps,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)},[...n[1]||(n[1]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,_s)],2))),128))])],2)}}}),Hs={class:"py-1"},Us=["onClick","onMouseenter"],qs={class:"flex items-start gap-3"},vs={class:"flex-1 min-w-0"},js={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},Ws={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Ks=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",Hs,[(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",qs,[e.createElementVNode("div",vs,[e.createElementVNode("p",js,e.toDisplayString(a.title),1),e.createElementVNode("p",Ws,e.toDisplayString(a.description),1)])])],42,Us))),128))])],2)]),_:1}))}}),Gs={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},Qs=["title"],Zs=["title"],Ys=["disabled"],Xs={key:0,class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Js={key:1,class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},ea=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",Gs,[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"))},[...s[3]||(s[3]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[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"})],-1)])],10,Qs)):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"))},[s[4]||(s[4]=e.createElementVNode("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[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"})],-1)),e.createElementVNode("span",null,e.toDisplayString(((l=r.texts)==null?void 0:l.supportLabel)||"Support"),1),s[5]||(s[5]=e.createElementVNode("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1))],10,Zs)):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.createElementBlock("svg",Js,[...s[7]||(s[7]=[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)])])):(e.openBlock(),e.createElementBlock("svg",Xs,[...s[6]||(s[6]=[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)])]))],10,Ys)])}}}),ta={class:"max-w-3xl mx-auto space-y-3"},na=["accept"],ra=["title"],oa={class:"flex items-center"},sa=["placeholder","disabled"],aa={key:0,class:"flex justify-center"},Yn=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,{emit:t}){const n=r,o=e.computed(()=>n.ui||{}),s=t,a=e.ref(n.modelValue),i=e.ref(null),l=e.ref(null),u=e.ref(!1),d=ns(),p=rs(()=>a.value,T=>{a.value=T},()=>i.value),f=os(()=>n.suggestions,()=>n.hasHistory,()=>u.value,()=>a.value,T=>{s("suggestion-select",T),e.nextTick(()=>{var N;return(N=i.value)==null?void 0:N.focus()})}),{adjustTextareaHeight:k}=ss(()=>i.value),h=e.computed(()=>n.supportRequestMode?n.supportPlaceholder:n.placeholder),m=e.computed(()=>n.showSupportModeToggle?n.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),E=e.computed(()=>{var N;return(((N=a.value)==null?void 0:N.trim())??"").length>=n.minLength?!0:d.hasAttachments.value}),y=e.computed(()=>!n.disabled&&!n.sending&&E.value&&!d.isUploading.value);e.watch(()=>n.modelValue,T=>{a.value=T,e.nextTick(k)}),e.watch(a,T=>{s("update:modelValue",T),e.nextTick(k),p.checkForMentions(T),f.updateSuggestionsVisibility()}),e.watch(()=>n.suggestions,()=>{f.updateSuggestionsVisibility()});function g(){k()}function b(T){if(!p.handleMentionKeyDown(T)&&!f.handleSuggestionKeyDown(T)&&T.key==="Enter"){if(T.shiftKey)return;!n.sending&&y.value&&(T.preventDefault(),C())}}function C(){if(!y.value)return;const T=d.buildPayload(),N=a.value.trim(),z=p.getMentions();s("submit",{message:N,attachments:T,mentions:z,isSupportRequest:n.supportRequestMode}),a.value="",d.clearAttachments(),p.clearMentions(),e.nextTick(k)}function w(){n.sending?s("cancel"):y.value&&C()}function I(){var T;n.disabled||n.sending||d.canAddMore.value&&((T=l.value)==null||T.click())}function $(T){f.handleSuggestionClick(T)}function F(){u.value=!0,f.updateSuggestionsVisibility()}function S(){u.value=!1,setTimeout(()=>{f.hideSuggestions(),p.showMentions.value=!1},200)}return e.onMounted(()=>{e.nextTick(k)}),(T,N)=>{var z;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",o.value.root]),onDragenter:N[6]||(N[6]=e.withModifiers((...M)=>e.unref(d).handleDragEnter&&e.unref(d).handleDragEnter(...M),["prevent"])),onDragover:N[7]||(N[7]=e.withModifiers((...M)=>e.unref(d).handleDragOver&&e.unref(d).handleDragOver(...M),["prevent"])),onDragleave:N[8]||(N[8]=e.withModifiers((...M)=>e.unref(d).handleDragLeave&&e.unref(d).handleDragLeave(...M),["prevent"])),onDrop:N[9]||(N[9]=e.withModifiers((...M)=>e.unref(d).handleDrop&&e.unref(d).handleDrop(...M),["prevent"]))},[e.createElementVNode("form",{class:e.normalizeClass(o.value.form),onSubmit:e.withModifiers(C,["prevent"])},[e.createElementVNode("div",ta,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:e.unref(d).acceptedFileTypes,onChange:N[0]||(N[0]=(...M)=>e.unref(d).handleFileSelect&&e.unref(d).handleFileSelect(...M))},null,40,na),e.unref(d).hasAttachments.value?(e.openBlock(),e.createBlock(Fs,{key:0,attachments:e.unref(d).attachments.value,ui:o.value,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",o.value.inputContainer])},[e.unref(f).showSuggestions.value&&r.suggestions.length>0?(e.openBlock(),e.createBlock(Ks,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:r.suggestions,"selected-index":e.unref(f).selectedSuggestionIndex.value,ui:o.value,onSelect:$,onHover:N[1]||(N[1]=M=>e.unref(f).selectedSuggestionIndex.value=M)},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(p).showMentions.value&&e.unref(p).mentionItems.value.length>0?(e.openBlock(),e.createBlock(Kn,{key:0,items:e.unref(p).mentionItems.value,"selected-index":e.unref(p).selectedMentionIndex.value,providers:e.unref(p).mentionProviders.value,onSelect:e.unref(p).handleMentionSelect,"onUpdate:selectedIndex":N[2]||(N[2]=M=>e.unref(p).selectedMentionIndex.value=M)},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.value.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",o.value.attachButton]),title:((z=r.texts)==null?void 0:z.attachFiles)||"Attach files",onClick:I},[...N[10]||(N[10]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[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"})],-1)])],10,ra),e.createElementVNode("div",oa,[e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":N[3]||(N[3]=M=>a.value=M),rows:"1","data-ai-input":"",placeholder:h.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",o.value.textarea]),style:e.normalizeStyle(m.value),onInput:g,onKeydown:b,onFocus:F,onBlur:S},null,46,sa),[[e.vModelText,a.value]])]),e.createVNode(ea,{sending:r.sending,"can-send":y.value,"support-request-mode":r.supportRequestMode,"show-support-mode-toggle":r.showSupportModeToggle,ui:o.value,texts:r.texts,onToggleSupportMode:N[4]||(N[4]=M=>T.$emit("toggle-support-mode")),onClick:w},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),e.renderSlot(T.$slots,"context-link",{},()=>[r.contextLinkText?(e.openBlock(),e.createElementBlock("div",aa,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",o.value.contextLink]),onClick:N[5]||(N[5]=M=>T.$emit("context-link-click"))},e.toDisplayString(r.contextLinkText),3)])):e.createCommentVNode("",!0)])])],34)],34)}}}),ia=["onClick"],Xn=e.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(r,{emit:t}){const n=r,o=t,s=k=>{var m;return(m=n.texts)!=null&&m[k]?n.texts[k]:ee({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[k])},a=e.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=jt();function u(k){const h={...k,prompt:l(k)};o("item-click",h)}function d(k){return k.gradientClass?k.gradientClass:k.className?k.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function p(k){const h=k.category||"default",m={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 m[h]||m.default}function f(k){const h=k.category||"default",m={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 m[h]||m.default}return(k,h)=>(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])},[h[0]||(h[0]=e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),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),(m,E)=>(e.openBlock(),e.createElementBlock("button",{key:m.id||E,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(m)]]),onClick:y=>u(m)},[e.createElementVNode("div",{class:e.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,p(m)]])},[m.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.icon),{key:0,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,f(m)]])},null,8,["class"])):(e.openBlock(),e.createElementBlock("svg",{key:1,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,f(m)]]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...h[1]||(h[1]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))],2),e.createElementVNode("h3",{class:e.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",a.value.suggestionTitle])},e.toDisplayString(m.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},e.toDisplayString(m.description),3)],10,ia))),128))],2)],2)],2))}}),la={class:"flex items-center gap-3"},ca={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},ua={key:1,class:"flex items-center gap-2"},da={key:0,class:"flex items-center gap-2 ml-auto mr-4"},pa={key:1,class:"text-gray-300 dark:text-gray-600"},ma={class:"text-green-600 dark:text-green-400 font-medium tabular-nums"},fa={class:"text-gray-500 dark:text-gray-400"},ha={key:1,class:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-red-50 dark:bg-red-900/20"},ga={class:"text-xs text-red-600 dark:text-red-400 font-medium"},ya=["title"],ka=["title"],xa=["title"],wa={key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ba={key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},Ea=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,n=e.computed(()=>{const s=t.messageCount/t.messageLimit;return s>=1?"text-red-600 dark:text-red-400":s>=.8?"text-amber-600 dark:text-amber-400":"text-gray-600 dark:text-gray-300"}),o=e.computed(()=>{const s=t.messageCount/t.messageLimit;return s>=1?"text-red-500 dark:text-red-400":s>=.8?"text-amber-500 dark:text-amber-400":"text-gray-400 dark:text-gray-500"});return(s,a)=>{var i,l,u,d,p,f,k;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",(i=r.ui)==null?void 0:i.header])},[e.createElementVNode("div",la,[r.isSetupMode?(e.openBlock(),e.createElementBlock("div",ua,[...a[5]||(a[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},[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",(l=r.ui)==null?void 0:l.newChatButton]),onClick:a[0]||(a[0]=h=>s.$emit("new-chat"))},[a[4]||(a[4]=e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.t("newChat")),1)],2)):(e.openBlock(),e.createElementBlock("span",ca,e.toDisplayString(r.t("keyboardShortcutHint")),1))],64))]),!r.isSetupMode&&(r.showMessageCount||r.showQuota)?(e.openBlock(),e.createElementBlock("div",da,[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",(u=r.ui)==null?void 0:u.messageCountBadge])},[(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-3.5 h-3.5",o.value]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[...a[6]||(a[6]=[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)])],2)),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium tabular-nums",n.value])},[e.renderSlot(s.$slots,"message-count",{},()=>[e.createTextVNode(e.toDisplayString(r.messageCount),1),a[7]||(a[7]=e.createElementVNode("span",{class:"text-gray-400 dark:text-gray-500"},"/",-1)),e.createTextVNode(e.toDisplayString(r.messageLimit),1)])],2)],2)):e.createCommentVNode("",!0),r.showMessageCount&&r.hasHistory&&r.showQuota&&r.quota.remaining>=0?(e.openBlock(),e.createElementBlock("span",pa," • ")):e.createCommentVNode("",!0),r.showQuota?e.renderSlot(s.$slots,"quota",{key:2},()=>{var h;return[r.quota.remaining>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 text-xs",(h=r.ui)==null?void 0:h.quotaDisplay])},[e.createElementVNode("span",ma,e.toDisplayString(r.quota.remaining),1),e.createElementVNode("span",fa,e.toDisplayString(r.t("quotaRemaining")),1)],2)):r.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",ha,[a[8]||(a[8]=e.createElementVNode("svg",{class:"w-3.5 h-3.5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[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"})],-1)),e.createElementVNode("span",ga,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",(d=r.ui)==null?void 0:d.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",(p=r.ui)==null?void 0:p.headerActionButton]),title:r.t("close"),onClick:a[1]||(a[1]=h=>s.$emit("close"))},[...a[9]||(a[9]=[e.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,ya)):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:a[2]||(a[2]=h=>s.$emit("minimize"))},[...a[10]||(a[10]=[e.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"})],-1)])],10,ka)):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",(k=r.ui)==null?void 0:k.headerActionButton]),title:r.isFullscreen?r.t("exitFullscreen"):r.t("fullscreen"),onClick:a[3]||(a[3]=h=>s.$emit("toggle-fullscreen"))},[r.isFullscreen?(e.openBlock(),e.createElementBlock("svg",ba,[...a[12]||(a[12]=[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)])])):(e.openBlock(),e.createElementBlock("svg",wa,[...a[11]||(a[11]=[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)])]))],10,xa)):e.createCommentVNode("",!0)],2)],2)}}}),Ca={class:"max-w-3xl mx-auto px-4 space-y-6"},Sa={class:"flex justify-center"},Ta={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},Aa={key:0,class:"flex justify-center"},Ma=["title"],Na=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",Ca,[e.createElementVNode("div",Sa,[e.createElementVNode("div",Ta,[n[3]||(n[3]=e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.t("title")||e.unref(ee)("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(Zn,{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",Aa,[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"))},[n[4]||(n[4]=e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[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"})],-1)),e.createElementVNode("span",null,e.toDisplayString(e.unref(ee)("contactSupport")),1)])])):e.createCommentVNode("",!0),r.error.message?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-center gap-2 text-sm text-red-600 dark:text-red-400 px-2 py-1 pb-6",(o=r.ui)==null?void 0:o.errorContainer])},[e.createElementVNode("span",{class:e.normalizeClass((s=r.ui)==null?void 0:s.errorMessage)},e.toDisplayString(r.error.message),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["inline-flex items-center gap-1 text-red-700 dark:text-red-300 hover:text-red-800 dark:hover:text-red-200 font-medium",(a=r.ui)==null?void 0:a.retryButton]),title:r.t("retry"),onClick:n[2]||(n[2]=i=>t.$emit("retry"))},[...n[5]||(n[5]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[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"})],-1)])],10,Ma)],2)):e.createCommentVNode("",!0)])}}}),Ra={class:"w-full max-w-md"},Ba={class:"bg-gray-900 rounded-xl overflow-hidden"},La={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},Da=e.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[n[4]||(n[4]=e.createStaticVNode('<div class="w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"><svg class="w-7 h-7 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"></path></svg></div><h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-1"> Almost there! </h2><p class="text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-sm text-center"> Configure the plugin in your app entry file to start using AI. </p>',3)),e.createElementVNode("div",Ra,[e.createElementVNode("div",Ba,[e.createElementVNode("div",La,[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>
61
61
 
62
62
  app.<span class="text-yellow-300">use</span>(RestifyAiPlugin, {
63
63
  <span class="text-blue-300">endpoints</span>: {
@@ -65,7 +65,7 @@ app.<span class="text-yellow-300">use</span>(RestifyAiPlugin, {
65
65
  <span class="text-blue-300">quota</span>: <span class="text-green-400">&#39;/api/ai/quota&#39;</span>, <span class="text-gray-500">// optional</span>
66
66
  },
67
67
  <span class="text-blue-300">getAuthToken</span>: () =&gt; <span class="text-yellow-300">getToken</span>(),
68
- })</code></pre>`,1))]),n[3]||(n[3]=t.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[t.createTextVNode(" Need help? Check the "),t.createElementVNode("a",{href:"https://github.com/doderasoftware/restify-ai",target:"_blank",class:"text-primary hover:underline"},"documentation")],-1))])],64))}}),Ma={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center z-10"},Na={key:0,class:"flex items-center gap-3 mb-4"},Ra={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ba={key:1,class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"},La={class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},Da={class:"flex justify-end gap-3"},Jn=t.defineComponent({__name:"ConfirmDialog",props:{show:{type:Boolean},title:{},message:{},confirmText:{},cancelText:{},ui:{},icon:{default:null},confirmVariant:{default:"danger"}},emits:["confirm","cancel"],setup(r){const e=r,n=t.computed(()=>{var s,a;return e.icon==="warning"?(s=e.ui)==null?void 0:s.historyLimitModal:(a=e.ui)==null?void 0:a.closeConfirmModal}),o=t.computed(()=>{var i,l;const s=e.confirmVariant==="danger"?"bg-red-600 hover:bg-red-700":"bg-primary hover:bg-primary/90",a=e.confirmVariant==="danger"?(i=e.ui)==null?void 0:i.closeConfirmButton:(l=e.ui)==null?void 0:l.historyLimitButton;return[s,a]});return(s,a)=>(t.openBlock(),t.createBlock(t.Transition,{"enter-active-class":"transition ease-out duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition ease-in duration-150","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:t.withCtx(()=>{var i;return[r.show?(t.openBlock(),t.createElementBlock("div",Ma,[t.createElementVNode("div",{class:t.normalizeClass(["bg-white dark:bg-gray-800 rounded-xl p-6 m-4 max-w-sm w-full shadow-xl",n.value])},[r.icon==="warning"?(t.openBlock(),t.createElementBlock("div",Na,[a[2]||(a[2]=t.createElementVNode("div",{class:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center"},[t.createElementVNode("svg",{class:"w-5 h-5 text-amber-600 dark:text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})])],-1)),t.createElementVNode("h3",Ra,t.toDisplayString(r.title),1)])):(t.openBlock(),t.createElementBlock("h3",Ba,t.toDisplayString(r.title),1)),t.createElementVNode("p",La,t.toDisplayString(r.message),1),t.createElementVNode("div",Da,[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",(i=r.ui)==null?void 0:i.cancelButton]),onClick:a[0]||(a[0]=l=>s.$emit("cancel"))},t.toDisplayString(r.cancelText),3),t.createElementVNode("button",{type:"button",class:t.normalizeClass(["px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",o.value]),onClick:a[1]||(a[1]=l=>s.$emit("confirm"))},t.toDisplayString(r.confirmText),3)])],2)])):t.createCommentVNode("",!0)]}),_:1}))}}),Ia={key:0,class:"flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto"},$a={key:0,class:"flex-1 flex flex-col overflow-y-auto"},za=Qn(t.defineComponent({__name:"AiChatDrawer",props:{modelValue:{type:Boolean},ui:{},texts:{},width:{default:"600px"},fullscreenWidth:{default:"90vw"},topOffset:{default:"0"},position:{default:"right"},showBackdrop:{type:Boolean,default:!1},closeOnBackdropClick:{type:Boolean,default:!1},closeOnEscape:{type:Boolean,default:!0},showQuota:{type:Boolean,default:!0},showFullscreenToggle:{type:Boolean,default:!0},showMinimizeButton:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0},showNewChatButton:{type:Boolean,default:!0},confirmClose:{type:Boolean,default:!0},historyLimit:{},loadingText:{},autoFetchQuota:{type:Boolean,default:!0}},emits:["update:modelValue","close","contact-support","new-chat"],setup(r,{emit:e}){const n=r,o=e,s=t.computed({get:()=>n.modelValue,set:L=>o("update:modelValue",L)});function a(L,V){var K;const H=(K=n.texts)==null?void 0:K[L];if(H){let W=H;if(V)for(const[G,se]of Object.entries(V))W=W.replace(`{${G}}`,String(se));return W}return J(L,V)}const i=Ae(),l=t.ref(""),d=t.ref(null),u=t.ref(!1),p=t.ref(!1),g=t.ref(!1),{loadingMessage:x,startLoadingText:y,resetLoadingText:f}=Jr(()=>i.sending,()=>n.loadingText),{showHistoryLimitWarning:E,historyLimitReached:h,historyLimitDialogTitle:m,historyLimitDialogMessage:b,dismissHistoryLimitWarning:C,handleHistoryLimitAction:w,checkHistoryLimit:$,setPendingMessage:z}=es({getHistoryLength:()=>i.chatHistory.length,getStoreLimit:()=>i.chatHistoryLimit,getConfig:()=>n.historyLimit,getTexts:()=>n.texts,onStartNewChat:()=>i.clearChatHistory(),onNewChatEmit:()=>o("new-chat")}),F=t.computed(()=>!Ct()),S=t.computed(()=>Se("enableSupportMode")??!1),{suggestions:T,resolvePrompt:N}=jt(),D=t.computed(()=>{if(F.value)return[];const L=l.value.toLowerCase().trim(),V=T.value||[];let H=V;if(L){const K=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]),W=L.split(/\s+/).filter(G=>!K.has(G));W.length>0&&(H=V.filter(G=>{const se=`${G.title} ${G.description||""}`.toLowerCase();return W.every(me=>se.includes(me))}))}return H.slice(0,5).map(K=>({id:K.id,title:K.title,description:K.description||""}))}),M=t.computed(()=>({quota:i.quota,isFullscreen:u.value,hasHistory:i.chatHistory.length>0,onNewChat:Z,onClose:Be,onMinimize:ye,onToggleFullscreen:Re})),Q=t.computed(()=>({modelValue:l.value,sending:i.sending,disabled:!1,onSubmit:ke,onCancel:()=>i.cancelRequest()}));function fe(L){const V=(T.value||[]).find(H=>H.id===L.id);V&&(l.value=N(V))}function Re(){u.value=!u.value}function ye(){s.value=!1}function Be(){n.confirmClose&&!F.value&&i.chatHistory.length>0?g.value=!0:(s.value=!1,o("close"))}function pt(){g.value=!1,i.clearChatHistory(),s.value=!1,o("close")}function Wt(){o("contact-support")}function ft(){i.toggleSupportMode()}async function j(){await t.nextTick();const L=document.getElementById("rai-chat-bottom");L&&L.scrollIntoView({behavior:"smooth",block:"end"})}function Je(L){l.value=L.prompt,i.clearError()}function Z(){i.clearChatHistory(),o("new-chat")}function mt(L){}function v(){navigator.clipboard.writeText(`import { RestifyAiPlugin } from '@doderasoftware/restify-ai'
68
+ })</code></pre>`,1))]),n[3]||(n[3]=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/doderasoftware/restify-ai",target:"_blank",class:"text-primary hover:underline"},"documentation")],-1))])],64))}}),Ia={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center z-10"},za={key:0,class:"flex items-center gap-3 mb-4"},$a={class:"text-lg font-semibold text-gray-900 dark:text-white"},Oa={key:1,class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"},Va={class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},Pa={class:"flex justify-end gap-3"},Jn=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",Ia,[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",za,[a[2]||(a[2]=e.createElementVNode("div",{class:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center"},[e.createElementVNode("svg",{class:"w-5 h-5 text-amber-600 dark:text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[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"})])],-1)),e.createElementVNode("h3",$a,e.toDisplayString(r.title),1)])):(e.openBlock(),e.createElementBlock("h3",Oa,e.toDisplayString(r.title),1)),e.createElementVNode("p",Va,e.toDisplayString(r.message),1),e.createElementVNode("div",Pa,[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}))}}),_a={key:0,class:"flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto"},Fa={key:0,class:"flex-1 flex flex-col overflow-y-auto"},Ha=Qn(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:!1},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:B=>o("update:modelValue",B)});function a(B,O){var H;const j=(H=n.texts)==null?void 0:H[B];if(j){let Y=j;if(O)for(const[W,X]of Object.entries(O))Y=Y.replace(`{${W}}`,String(X));return Y}return ee(B,O)}const i=Ee(),l=e.ref(""),u=e.ref(null),d=e.ref(!1),p=e.ref(!1),f=e.ref(!1),{loadingMessage:k,startLoadingText:h,resetLoadingText:m}=es(()=>i.sending,()=>n.loadingText),{showHistoryLimitWarning:E,historyLimitReached:y,historyLimitDialogTitle:g,historyLimitDialogMessage:b,dismissHistoryLimitWarning:C,handleHistoryLimitAction:w,checkHistoryLimit:I,setPendingMessage:$}=ts({getHistoryLength:()=>i.chatHistory.length,getStoreLimit:()=>i.chatHistoryLimit,getConfig:()=>n.historyLimit,getTexts:()=>n.texts,onStartNewChat:()=>i.clearChatHistory(),onNewChatEmit:()=>o("new-chat")}),F=e.computed(()=>!Ct()),S=e.computed(()=>Ae("enableSupportMode")??!1),{suggestions:T,resolvePrompt:N}=jt(),z=e.computed(()=>i.chatHistory.filter(B=>B.role==="user").length),M=e.computed(()=>{if(F.value)return[];const B=l.value.toLowerCase().trim(),O=T.value||[];let j=O;if(B){const H=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]),Y=B.split(/\s+/).filter(W=>!H.has(W));Y.length>0&&(j=O.filter(W=>{const X=`${W.title} ${W.description||""}`.toLowerCase();return Y.every(Se=>X.includes(Se))}))}return j.slice(0,5).map(H=>({id:H.id,title:H.title,description:H.description||""}))}),K=e.computed(()=>({quota:i.quota,isFullscreen:d.value,hasHistory:i.chatHistory.length>0,onNewChat:Je,onClose:Xe,onMinimize:ge,onToggleFullscreen:Be})),me=e.computed(()=>({modelValue:l.value,sending:i.sending,disabled:!1,onSubmit:tt,onCancel:()=>i.cancelRequest()}));function ze(B){const O=(T.value||[]).find(j=>j.id===B.id);O&&(l.value=N(O))}function Be(){d.value=!d.value}function ge(){s.value=!1}function Xe(){n.confirmClose&&!F.value&&i.chatHistory.length>0?f.value=!0:(s.value=!1,o("close"))}function Wt(){f.value=!1,i.clearChatHistory(),s.value=!1,o("close")}function gt(){o("contact-support")}function G(){i.toggleSupportMode()}async function Ce(){await e.nextTick();const B=document.getElementById("rai-chat-bottom");B&&B.scrollIntoView({behavior:"smooth",block:"end"})}function Q(B){l.value=B.prompt,i.clearError()}function Je(){i.clearChatHistory(),o("new-chat")}function v(B){}function Le(){navigator.clipboard.writeText(`import { RestifyAiPlugin } from '@doderasoftware/restify-ai'
69
69
 
70
70
  app.use(RestifyAiPlugin, {
71
71
  endpoints: {
@@ -73,4 +73,4 @@ app.use(RestifyAiPlugin, {
73
73
  quota: '/api/ai/quota', // optional
74
74
  },
75
75
  getAuthToken: () => getToken(),
76
- })`),p.value=!0,setTimeout(()=>{p.value=!1},2e3)}async function Le(){const L=await w();L&&(await t.nextTick(),await $e(L.message,L.attachments,L.mentions,L.isSupportRequest))}async function $e(L,V,H,K){i.clearError(),y(),await t.nextTick(),j();const W=await i.askQuestion(L,V,H,K);f(),W&&j()}async function ke(L){const{message:V,attachments:H,mentions:K,isSupportRequest:W}=L;if(i.sending)return;const G=K.map(se=>({id:se.id,name:se.name,type:se.type||"unknown",metadata:se.metadata}));if(!$()){z({message:V,attachments:H,mentions:G,isSupportRequest:W});return}await $e(V,H,G,W)}async function ht(){y();const L=await i.retry();f(),L&&j()}function ze(L){n.closeOnEscape&&L.key==="Escape"&&s.value&&(g.value?g.value=!1:ye())}return t.watch(()=>n.modelValue,L=>{L&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),t.onMounted(()=>{window.addEventListener("keydown",ze)}),t.onUnmounted(()=>{window.removeEventListener("keydown",ze)}),(L,V)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.Transition,{name:"rai-fade"},{default:t.withCtx(()=>{var H;return[s.value&&r.showBackdrop?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["fixed inset-0 bg-black/30 z-40",(H=r.ui)==null?void 0:H.backdrop]),onClick:V[0]||(V[0]=K=>r.closeOnBackdropClick&&ye())},null,2)):t.createCommentVNode("",!0)]}),_:1}),t.createVNode(t.Transition,{name:r.position==="left"?"rai-slide-right":"rai-slide-left"},{default:t.withCtx(()=>{var H,K,W;return[s.value?(t.openBlock(),t.createElementBlock("aside",{key:0,class:t.normalizeClass(["fixed bottom-0 z-50 flex-shrink-0 border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-2xl will-change-transform",[r.position==="left"?"left-0 border-r":"right-0 border-l",(H=r.ui)==null?void 0:H.drawer]]),style:t.normalizeStyle({width:u.value?r.fullscreenWidth:r.width,top:r.topOffset,height:`calc(100vh - ${r.topOffset})`})},[t.createElementVNode("div",{class:t.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(K=r.ui)==null?void 0:K.panel])},[t.renderSlot(L.$slots,"header",t.normalizeProps(t.guardReactiveProps(M.value)),()=>[t.createVNode(ga,{ui:r.ui,"is-setup-mode":F.value,"show-new-chat-button":r.showNewChatButton,"has-history":t.unref(i).chatHistory.length>0,"show-quota":r.showQuota,quota:t.unref(i).quota,"show-close-button":r.showCloseButton,"show-minimize-button":r.showMinimizeButton,"show-fullscreen-toggle":r.showFullscreenToggle,"is-fullscreen":u.value,t:a,onNewChat:Z,onClose:Be,onMinimize:ye,onToggleFullscreen:Re},{quota:t.withCtx(()=>[t.renderSlot(L.$slots,"quota",{quota:t.unref(i).quota},void 0,!0)]),_:3},8,["ui","is-setup-mode","show-new-chat-button","has-history","show-quota","quota","show-close-button","show-minimize-button","show-fullscreen-toggle","is-fullscreen"])],!0),t.createElementVNode("div",{class:t.normalizeClass(["h-full flex flex-col mx-auto w-full overflow-hidden",[{"max-w-5xl":u.value},(W=r.ui)==null?void 0:W.body]])},[F.value?(t.openBlock(),t.createElementBlock("div",Ia,[t.renderSlot(L.$slots,"setup",{},()=>[t.createVNode(Aa,{copied:p.value,onCopy:v},null,8,["copied"])],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.unref(i).chatHistory.length===0?(t.openBlock(),t.createElementBlock("div",$a,[t.renderSlot(L.$slots,"empty-state",{suggestions:D.value,onClick:Je},()=>[t.createVNode(Xn,{onItemClick:Je})],!0)])):(t.openBlock(),t.createElementBlock("div",{key:1,ref_key:"chatContainer",ref:d,class:"flex-1 overflow-y-auto py-6 pb-24"},[t.createVNode(Ea,{messages:t.unref(i).chatHistory,"loading-message":t.unref(x),quota:t.unref(i).quota,error:t.unref(i).error,ui:r.ui,t:a,onCopy:mt,onContactSupport:Wt,onRetry:ht},{message:t.withCtx(G=>[t.renderSlot(L.$slots,"message",{message:G.message,isUser:G.isUser,isLoading:G.isLoading,isStreaming:G.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),V[3]||(V[3]=t.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),t.renderSlot(L.$slots,"input",t.normalizeProps(t.guardReactiveProps(Q.value)),()=>{var G,se;return[t.createVNode(Yn,{modelValue:l.value,"onUpdate:modelValue":V[1]||(V[1]=me=>l.value=me),sending:t.unref(i).sending,placeholder:((G=n.texts)==null?void 0:G.placeholder)||t.unref(J)("inputPlaceholder"),"support-placeholder":((se=n.texts)==null?void 0:se.supportPlaceholder)||t.unref(J)("supportPlaceholder"),suggestions:D.value,"has-history":t.unref(i).chatHistory.length>0,"support-request-mode":t.unref(i).supportRequestMode,"show-support-mode-toggle":S.value,onSubmit:ke,onCancel:t.unref(i).cancelRequest,onSuggestionSelect:fe,onToggleSupportMode:ft},{"context-link":t.withCtx(()=>[t.renderSlot(L.$slots,"context-link",{},void 0,!0)]),_:3},8,["modelValue","sending","placeholder","support-placeholder","suggestions","has-history","support-request-mode","show-support-mode-toggle","onCancel"])]},!0)],64))],2)],2),t.createVNode(Jn,{show:g.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:r.ui,"confirm-variant":"danger",onConfirm:pt,onCancel:V[2]||(V[2]=G=>g.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),t.createVNode(Jn,{show:t.unref(E),title:t.unref(m),message:t.unref(b),"confirm-text":a("startNewChat"),"cancel-text":t.unref(h)?a("continueChat"):a("cancel"),ui:r.ui,icon:"warning","confirm-variant":"primary",onConfirm:Le,onCancel:t.unref(C)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):t.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-e286ec63"]]),eo={install(r,e){if(!e.endpoints||!e.getAuthToken){console.warn("[@doderasoftware/restify-ai] Plugin requires endpoints and getAuthToken options.");return}const n={endpoints:e.endpoints,baseUrl:e.baseUrl,getAuthToken:e.getAuthToken,getCustomHeaders:e.getCustomHeaders,buildRequest:e.buildRequest,parseStreamContent:e.parseStreamContent,requestInterceptor:e.requestInterceptor,responseInterceptor:e.responseInterceptor,retry:e.retry,translate:e.translate,can:e.can,labels:{...Et,...e.labels},mentionProviders:e.mentionProviders,suggestionProviders:e.suggestionProviders,defaultSuggestions:e.defaultSuggestions,theme:e.theme,chatHistoryLimit:e.chatHistoryLimit,maxAttachments:e.maxAttachments,maxFileSize:e.maxFileSize,acceptedFileTypes:e.acceptedFileTypes,chatHistoryKey:e.chatHistoryKey,drawerStateKey:e.drawerStateKey,keyboardShortcut:e.keyboardShortcut,enableSupportMode:e.enableSupportMode,canToggle:e.canToggle,assistantAvatar:e.assistantAvatar,userAvatar:e.userAvatar,onQuotaFetched:e.onQuotaFetched,onError:e.onError,onMessageSent:e.onMessageSent,onResponseReceived:e.onResponseReceived,onDrawerToggle:e.onDrawerToggle,onNewChat:e.onNewChat,onStreamStart:e.onStreamStart,onStreamEnd:e.onStreamEnd,onStreamChunk:e.onStreamChunk,beforeSend:e.beforeSend,afterResponse:e.afterResponse,onFileUploadStart:e.onFileUploadStart,onFileUploadProgress:e.onFileUploadProgress,onFileUploadComplete:e.onFileUploadComplete,onFileUploadError:e.onFileUploadError};en(n),r.provide("restify-ai-config",n)}};B.AiAvatar=Wn,B.AiChatDrawer=za,B.AiEmptyState=Xn,B.ChatInput=Yn,B.ChatMessage=Zn,B.ChatMessageActions=Kn,B.ChatRoles=Te,B.MentionList=Gn,B.RestifyAiPlugin=eo,B.UserAvatar=ss,B.default=eo,B.defaultLabels=Et,B.formatMentionsForApi=fn,B.getConfigValue=Se,B.getLabel=J,B.getRestifyAiConfig=q,B.getRestifyAiConfigOrThrow=bo,B.getSuggestionsForPath=vn,B.groupMentionsByType=mn,B.isConfigured=Ct,B.registerSuggestionProvider=Kr,B.setRestifyAiConfig=en,B.useAiContext=vt,B.useAiDrawerShortcut=Xr,B.useAiSuggestions=jt,B.useChatErrorHandling=vr,B.useChatMarkdown=Un,B.useChatScroll=qr,B.useKeyboardShortcut=jn,B.useMentionParsing=Uo,B.usePageAiContext=Qr,B.useRestifyAiStore=Ae,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
76
+ })`),p.value=!0,setTimeout(()=>{p.value=!1},2e3)}async function et(){const B=await w();B&&(await e.nextTick(),await ye(B.message,B.attachments,B.mentions,B.isSupportRequest))}async function ye(B,O,j,H){i.clearError(),h(),await e.nextTick(),Ce();const Y=await i.askQuestion(B,O,j,H);m(),Y&&Ce()}async function tt(B){const{message:O,attachments:j,mentions:H,isSupportRequest:Y}=B;if(i.sending)return;const W=H.map(X=>({id:X.id,name:X.name,type:X.type||"unknown",metadata:X.metadata}));if(!I()){$({message:O,attachments:j,mentions:W,isSupportRequest:Y});return}await ye(O,j,W,Y)}async function nt(){h();const B=await i.retry();m(),B&&Ce()}function rt(B){n.closeOnEscape&&B.key==="Escape"&&s.value&&(f.value?f.value=!1:ge())}return e.watch(()=>i.chatHistory.length,()=>{Ce()}),e.watch(()=>i.chatHistory.map(B=>B.message).join(""),()=>{Ce()}),e.watch(()=>n.modelValue,B=>{B&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),e.onMounted(()=>{window.addEventListener("keydown",rt)}),e.onUnmounted(()=>{window.removeEventListener("keydown",rt)}),(B,O)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"rai-fade"},{default:e.withCtx(()=>{var j;return[s.value&&r.showBackdrop?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["fixed inset-0 bg-black/30 z-40",(j=r.ui)==null?void 0:j.backdrop]),onClick:O[0]||(O[0]=H=>r.closeOnBackdropClick&&ge())},null,2)):e.createCommentVNode("",!0)]}),_:1}),e.createVNode(e.Transition,{name:r.position==="left"?"rai-slide-right":"rai-slide-left"},{default:e.withCtx(()=>{var j,H,Y;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",(j=r.ui)==null?void 0:j.drawer]]),style:e.normalizeStyle({width:d.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",(H=r.ui)==null?void 0:H.panel])},[e.renderSlot(B.$slots,"header",e.normalizeProps(e.guardReactiveProps(K.value)),()=>[e.createVNode(Ea,{ui:r.ui,"is-setup-mode":F.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":d.value,"show-message-count":r.showMessageCount,"message-count":z.value,"message-limit":e.unref(i).chatHistoryLimit,t:a,onNewChat:Je,onClose:Xe,onMinimize:ge,onToggleFullscreen:Be},{quota:e.withCtx(()=>[e.renderSlot(B.$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":d.value},(Y=r.ui)==null?void 0:Y.body]])},[F.value?(e.openBlock(),e.createElementBlock("div",_a,[e.renderSlot(B.$slots,"setup",{},()=>[e.createVNode(Da,{copied:p.value,onCopy:Le},null,8,["copied"])],!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(i).chatHistory.length===0?(e.openBlock(),e.createElementBlock("div",Fa,[e.renderSlot(B.$slots,"empty-state",{suggestions:M.value,onClick:Q},()=>[e.createVNode(Xn,{onItemClick:Q})],!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(Na,{messages:e.unref(i).chatHistory,"loading-message":e.unref(k),quota:e.unref(i).quota,error:e.unref(i).error,ui:r.ui,t:a,onCopy:v,onContactSupport:gt,onRetry:nt},{message:e.withCtx(W=>[e.renderSlot(B.$slots,"message",{message:W.message,isUser:W.isUser,isLoading:W.isLoading,isStreaming:W.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),O[3]||(O[3]=e.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),e.renderSlot(B.$slots,"input",e.normalizeProps(e.guardReactiveProps(me.value)),()=>{var W,X;return[e.createVNode(Yn,{modelValue:l.value,"onUpdate:modelValue":O[1]||(O[1]=Se=>l.value=Se),sending:e.unref(i).sending,placeholder:((W=n.texts)==null?void 0:W.placeholder)||e.unref(ee)("inputPlaceholder"),"support-placeholder":((X=n.texts)==null?void 0:X.supportPlaceholder)||e.unref(ee)("supportPlaceholder"),suggestions:M.value,"has-history":e.unref(i).chatHistory.length>0,"support-request-mode":e.unref(i).supportRequestMode,"show-support-mode-toggle":S.value,onSubmit:tt,onCancel:e.unref(i).cancelRequest,onSuggestionSelect:ze,onToggleSupportMode:G},{"context-link":e.withCtx(()=>[e.renderSlot(B.$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(Jn,{show:f.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:r.ui,"confirm-variant":"danger",onConfirm:Wt,onCancel:O[2]||(O[2]=W=>f.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),e.createVNode(Jn,{show:e.unref(E),title:e.unref(g),message:e.unref(b),"confirm-text":a("startNewChat"),"cancel-text":e.unref(y)?a("continueChat"):a("cancel"),ui:r.ui,icon:"warning","confirm-variant":"primary",onConfirm:et,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-0dc9abc8"]]),Ua=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,p)=>{var f;return a.value=!0,i.value=u,(f=o.onError)==null||f.call(o,u,p),s("error",u,p),!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 p,f,k,h,m;return[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-col items-center justify-center p-6 text-center",(p=r.ui)==null?void 0:p.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",(f=r.ui)==null?void 0:f.iconContainer])},[...d[0]||(d[0]=[e.createElementVNode("svg",{class:"w-6 h-6 text-red-600 dark:text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1)])],2),e.createElementVNode("h3",{class:e.normalizeClass(["text-lg font-semibold text-gray-900 dark:text-white mb-2",(k=r.ui)==null?void 0:k.title])},e.toDisplayString(r.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4",(h=r.ui)==null?void 0:h.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",(m=r.ui)==null?void 0:m.retryButton]),onClick:l},e.toDisplayString(r.retryText),3)):e.createCommentVNode("",!0)],2)]}):e.renderSlot(u.$slots,"default",{key:0})}}),er={install(r,t){if(!t.endpoints||!t.getAuthToken){console.warn("[@doderasoftware/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:{...Et,...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,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};en(n),r.provide("restify-ai-config",n)}};L.AiAvatar=Wn,L.AiChatDrawer=Ha,L.AiEmptyState=Xn,L.ChatInput=Yn,L.ChatMessage=Zn,L.ChatMessageActions=Gn,L.ChatRoles=Me,L.ErrorBoundary=Ua,L.MentionList=Kn,L.RestifyAiPlugin=er,L.UserAvatar=as,L.default=er,L.defaultLabels=Et,L.formatMentionsForApi=mn,L.getConfigValue=Ae,L.getLabel=ee,L.getRestifyAiConfig=q,L.getRestifyAiConfigOrThrow=wr,L.getSuggestionsForPath=vn,L.groupMentionsByType=fn,L.isConfigured=Ct,L.registerSuggestionProvider=Qo,L.setRestifyAiConfig=en,L.useAiContext=vt,L.useAiDrawerShortcut=Jo,L.useAiSuggestions=jt,L.useChatErrorHandling=jo,L.useChatMarkdown=Un,L.useChatScroll=vo,L.useKeyboardShortcut=jn,L.useMentionParsing=Ur,L.usePageAiContext=Zo,L.useRestifyAiStore=Ee,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});