@doderasoftware/restify-ai 0.1.0-beta.11 → 0.1.0-beta.12
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.
- package/dist/composables/useChatInput.d.ts.map +1 -1
- package/dist/restify-ai.js +957 -948
- package/dist/restify-ai.umd.cjs +28 -28
- package/dist/store/store.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/restify-ai.umd.cjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
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,$e){"use strict";var Ya=Object.defineProperty;var Xa=(L,e,$e)=>e in L?Ya(L,e,{enumerable:!0,configurable:!0,writable:!0,value:$e}):L[e]=$e;var
|
|
2
|
-
`+d:d;break;case"event":r.event=d;break;case"id":o(r.id=d);break;case"retry":const h=parseInt(d,10);isNaN(h)||t(r.retry=h);break}}}}function To(o,t){const n=new Uint8Array(o.length+t.length);return n.set(o),n.set(t,o.length),n}function nn(){return{data:"",event:"",id:"",retry:void 0}}var Ao=function(o,t){var n={};for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&t.indexOf(r)<0&&(n[r]=o[r]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(o);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(o,r[s])&&(n[r[s]]=o[r[s]]);return n};const St="text/event-stream",Mo=1e3,on="last-event-id";function No(o,t){var{signal:n,headers:r,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:u,fetch:p}=t,d=Ao(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((h,g)=>{const m=Object.assign({},r);m.accept||(m.accept=St);let f;function E(){f.abort(),document.hidden||z()}u||document.addEventListener("visibilitychange",E);let k=Mo,y=0;function b(){document.removeEventListener("visibilitychange",E),window.clearTimeout(y),f.abort()}n==null||n.addEventListener("abort",()=>{b(),h()});const S=p??window.fetch,w=s??Ro;async function z(){var O;f=new AbortController;try{const K=await S(o,Object.assign(Object.assign({},d),{headers:m,signal:f.signal}));await w(K),await Eo(K.body,Co(So(C=>{C?m[on]=C:delete m[on]},C=>{k=C},a))),i==null||i(),b(),h()}catch(K){if(!f.signal.aborted)try{const C=(O=l==null?void 0:l(K))!==null&&O!==void 0?O:k;window.clearTimeout(y),y=window.setTimeout(z,C)}catch(C){b(),g(C)}}}z()})}function Ro(o){const t=o.headers.get("content-type");if(!(t!=null&&t.startsWith(St)))throw new Error(`Expected content-type to be ${St}, Actual: ${t}`)}function at(o){if(!o)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||o.startsWith("http://")||o.startsWith("https://"))return o;const r=n.endsWith("/")?n.slice(0,-1):n,s=o.startsWith("/")?o:`/${o}`;return`${r}${s}`}function Bo(o){const n=(o instanceof Error?o.message:String(o)).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 Lo(o,t){var n,r,s;try{if(t==="done"||o==="[DONE]")return"[DONE]";const a=JSON.parse(o);return(a==null?void 0:a.content)!==void 0?a.content:((s=(r=(n=a==null?void 0:a.choices)==null?void 0:n[0])==null?void 0:r.delta)==null?void 0:s.content)||null}catch{return null}}function Do(o){return new Promise(t=>setTimeout(t,o))}function Io(o){const t={};return o.forEach(n=>{var r;(r=n.attachments)==null||r.forEach(s=>{s!=null&&s.id&&(t[s.id]=s)})}),t}function Se(o){const t=q();return o==="chatHistory"?(t==null?void 0:t.chatHistoryKey)||"restify_ai_chat_history":o==="setupComplete"?"restify_ai_setup_complete":(t==null?void 0:t.drawerStateKey)||"restify_ai_drawer_open"}function it(o){try{sessionStorage.setItem(Se("chatHistory"),JSON.stringify(o))}catch(t){console.warn("[RestifyAi] Failed to save chat history:",t)}}function zo(){try{const o=sessionStorage.getItem(Se("chatHistory"));if(o){const t=JSON.parse(o),n=t.filter(a=>{var i;return!(a.role===Re.Assistant&&a.loading||a.role===Re.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==t.length&&sessionStorage.setItem(Se("chatHistory"),JSON.stringify(n));const r=n[n.length-1],s=(r==null?void 0:r.role)===Re.User;return{history:n,hasOrphanedUserMessage:s,orphanedMessage:s?{question:r.message,attachments:r.attachments||[]}:void 0}}}catch(o){console.warn("[RestifyAi] Failed to load chat history:",o)}return{history:[],hasOrphanedUserMessage:!1}}function $o(){try{sessionStorage.removeItem(Se("chatHistory"))}catch(o){console.warn("[RestifyAi] Failed to clear chat history:",o)}}function Oo(o){try{o.message||o.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(o)):sessionStorage.removeItem("restify_ai_error_state")}catch(t){console.warn("[RestifyAi] Failed to save error state:",t)}}function Vo(){try{const o=sessionStorage.getItem("restify_ai_error_state");if(o)return JSON.parse(o)}catch(o){console.warn("[RestifyAi] Failed to load error state:",o)}return null}function Po(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(o){console.warn("[RestifyAi] Failed to clear error state:",o)}}function Tt(o){try{localStorage.setItem(Se("drawerState"),JSON.stringify(o))}catch(t){console.warn("[RestifyAi] Failed to save drawer state:",t)}}function _o(){try{const o=localStorage.getItem(Se("drawerState"));if(o!==null)return JSON.parse(o)}catch(o){console.warn("[RestifyAi] Failed to load drawer state:",o)}return!1}function Fo(){try{return localStorage.getItem(Se("setupComplete"))==="true"}catch{return!1}}function rn(){try{localStorage.setItem(Se("setupComplete"),"true")}catch(o){console.warn("[RestifyAi] Failed to mark setup complete:",o)}}function sn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}let He=new AbortController;const Te=$e.defineStore("restifyAiStore",{state:()=>{const o=zo(),t=Vo();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}:o.hasOrphanedUserMessage&&o.orphanedMessage&&(n={message:"Previous request failed. Click retry to try again.",failedQuestion:o.orphanedMessage.question,failedAttachments:o.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}),{chatHistoryLimit:he("chatHistoryLimit")||20,chatHistory:o.history,uploadedFiles:Io(o.history),loading:!1,showChat:_o(),isFullscreen:!1,sending:!1,pageContext:null,quota:(()=>{const r=he("chatHistoryLimit")||10,s=o.history.filter(a=>a.role==="user").length;return{limit:r,used:s,remaining:Math.max(0,r-s)}})(),error:n,supportRequestMode:!1,setupState:!Ct()&&!Fo()?{...sn(),isActive:!0}:sn()}},getters:{hasMessages:o=>o.chatHistory.length>0,isInSetupMode:o=>o.setupState.isActive,canChat:o=>!o.setupState.isActive||o.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(o=0){await e.nextTick(),o>0&&await new Promise(n=>setTimeout(n,o));const t=document.getElementById("rai-chat-bottom");t&&t.scrollIntoView({behavior:"smooth"})},parseStreamContent(o,t){const n=q(),r=n==null?void 0:n.parseStreamContent;return r?r(t,o):Lo(t,o)},async askQuestion(o,t=[],n=[],r=!1){var m;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,p=l.retryDelay??1e3;let d=0;const h=t.map(f=>({id:f.id,name:f.name,url:f.url,type:f.type,size:f.size,extractedText:f.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Re.User,message:o,loading:!1,attachments:h,mentions:n,timestamp:Date.now()}),h.forEach(f=>this.registerUploadedFile(f)),it(this.chatHistory),this.sending=!0,this.quota.remaining>0&&!r&&(this.quota.remaining--,this.quota.used++),this.scrollToBottom(),this.chatHistory.length>=this.chatHistoryLimit&&((m=s.onError)==null||m.call(s,new Error("Chat history limit reached")));const g=async()=>{var f,E,k;try{const y=this.chatHistory.map(N=>({role:N.role,content:N.message})),b={},S=N=>{N!=null&&N.id&&(b[N.id]={extracted_text:N.extractedText||"",file_name:N.name,mime_type:N.type||"",...N.size?{file_size:N.size}:{},...N.url?{file_url:N.url}:{}})};Object.values(this.uploadedFiles).forEach(S),this.chatHistory.forEach(N=>{var F;return(F=N.attachments)==null?void 0:F.forEach(S)}),h.forEach(S);const w=Object.values(b),z=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Re.Assistant,message:"",loading:!0,timestamp:Date.now()}),it(this.chatHistory),He=new AbortController,this.scrollToBottom();const O=await s.getAuthToken(),C={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?C["X-Test-Api-Key"]=this.setupState.testApiKey:O&&(C.Authorization=`Bearer ${O}`);const D={};if(typeof window<"u"){D.route=window.location.pathname;const N=new URLSearchParams(window.location.search),F={};N.forEach((De,ye)=>{F[ye]=De}),Object.keys(F).length>0&&(D.query=F),document.title&&(D.pageTitle=document.title)}n.length>0&&(D.mentionedEntities=n.map(N=>({type:N.type,id:N.id,displayName:N.name,metadata:N.metadata})));let A={message:o,history:y,stream:!0,...w.length>0&&{files:w},...Object.keys(D).length>0&&{context:D},...this.supportRequestMode&&{contact_support:!0},...s.model&&{model:s.model},...s.temperature&&{temperature:s.temperature},...s.maxTokens&&{max_tokens:s.maxTokens}};s.beforeSend&&(A=await s.beforeSend(A)),s.buildRequest&&(A=await s.buildRequest(A)),(f=s.onMessageSent)==null||f.call(s,this.chatHistory[z-1]);const T=at(s.endpoints.ask);let v={method:"POST",body:JSON.stringify(A),headers:C};return s.requestInterceptor&&(v=await s.requestInterceptor(T,v)),(E=s.onStreamStart)==null||E.call(s),await No(T,{method:"POST",body:JSON.stringify(A),signal:He.signal,headers:v.headers,openWhenHidden:!0,async onopen(N){if(!N.ok){if(N.status===429){const F=Te();throw F.error={message:te("noQuota"),failedQuestion:o,failedAttachments:h,timestamp:Date.now(),quotaExceeded:!0},await F.fetchQuota(),new Error("Quota exceeded")}throw new Error(`Failed to connect: ${N.status}`)}},onmessage:async N=>{var ye,ke,Ae;const F=this.parseStreamContent(N.event,N.data);if(!F)return;this.chatHistory[z].loading=!1;const De={content:F,done:F==="[DONE]",raw:N.data};(ye=s.onStreamChunk)==null||ye.call(s,De),a?F==="[DONE]"?(this.chatHistory[z].streaming=!1,it(this.chatHistory),(ke=s.onStreamEnd)==null||ke.call(s,a),this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[z]),(Ae=s.onResponseReceived)==null||Ae.call(s,this.chatHistory[z])):(a+=F,this.chatHistory[z].message=a):(a=F,this.chatHistory[z].message=a,this.chatHistory[z].streaming=!0),await this.scrollToBottom()},onerror(N){throw i=!0,N}}),!0}catch(y){i=!0;const b=this.chatHistory.length-1;return this.chatHistory.splice(b,1),y.name==="AbortError"?!0:d<u&&(l.shouldRetry?l.shouldRetry(y,d):!0)?(d++,await Do(p*d),g()):(this.error={message:Bo(y),failedQuestion:o,failedAttachments:h,timestamp:Date.now()},Oo({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(k=s.onError)==null||k.call(s,y),!1)}finally{this.sending=!1}};return g()},cancelRequest(){He==null||He.abort(),this.chatHistory=this.chatHistory.map(o=>({...o,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var n;const o=q();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1);const t=he("chatHistoryLimit")||10;this.quota={limit:t,used:0,remaining:t},$o(),(n=o==null?void 0:o.onNewChat)==null||n.call(o)},async retry(){if(!this.error.failedQuestion)return!1;const o=this.error.failedQuestion,t=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Re.User&&n.message===o&&(this.chatHistory.pop(),it(this.chatHistory)),this.clearError(),await this.askQuestion(o,t)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},Po()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var t,n;const o=q();if((t=o==null?void 0:o.endpoints)!=null&&t.quota)try{const r=await o.getAuthToken(),s=o.getCustomHeaders?await o.getCustomHeaders():{},a=at(o.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...r?{Authorization:`Bearer ${r}`}:{},...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&&o.enableSupportMode!==!1&&(this.supportRequestMode=!0),(n=o.onQuotaFetched)==null||n.call(o,this.quota)}}catch(r){console.error("[RestifyAi] Failed to fetch quota:",r)}},async uploadFile(o){var s,a,i,l,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 r={id:crypto.randomUUID(),name:o.name,type:o.type,size:o.size,uploading:!0,progress:0};(a=t.onFileUploadStart)==null||a.call(t,r);try{const p=await t.getAuthToken(),d=t.getCustomHeaders?await t.getCustomHeaders():{},h=at(t.endpoints.uploadFile),g=new FormData;g.append("file",o);const m=await new Promise((f,E)=>{const k=new XMLHttpRequest;k.upload.addEventListener("progress",y=>{var b;if(y.lengthComputable){const S=Math.round(y.loaded/y.total*100);r.progress=S,(b=t.onFileUploadProgress)==null||b.call(t,r,S)}}),k.addEventListener("load",()=>{var y,b;if(k.status>=200&&k.status<300)try{const S=JSON.parse(k.responseText),w={...r,url:S.url||((y=S.data)==null?void 0:y.url),extractedText:S.extracted_text||((b=S.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: ${k.status}`))}),k.addEventListener("error",()=>E(new Error("Upload failed"))),k.open("POST",h),p&&k.setRequestHeader("Authorization",`Bearer ${p}`),Object.entries(d).forEach(([y,b])=>k.setRequestHeader(y,b)),k.send(g)});return(i=t.onFileUploadComplete)==null||i.call(t,m),m}catch(p){const d={...r,uploading:!1};return(l=t.onFileUploadError)==null||l.call(t,d,p),(u=t.onError)==null||u.call(t,p),null}},setPageContext(o){this.pageContext=o},toggleDrawer(){var o,t;this.showChat=!this.showChat,Tt(this.showChat),(t=(o=q())==null?void 0:o.onDrawerToggle)==null||t.call(o,this.showChat),this.showChat&&this.scrollToBottom(100)},openDrawer(){var o,t;this.showChat=!0,Tt(!0),(t=(o=q())==null?void 0:o.onDrawerToggle)==null||t.call(o,!0),this.scrollToBottom(100)},closeDrawer(){var o,t;this.showChat=!1,Tt(!1),(t=(o=q())==null?void 0:o.onDrawerToggle)==null||t.call(o,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(o){o!=null&&o.id&&(this.uploadedFiles[o.id]={...o})},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(o){this.setupState.currentStep=o},setTestApiKey(o){this.setupState.testApiKey=o},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const o=q();if(!o)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const t={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(t["X-Test-Api-Key"]=this.setupState.testApiKey);const n=o.endpoints.quota||o.endpoints.ask,r=at(n),s=await fetch(r,{method:o.endpoints.quota?"GET":"POST",headers:t,...o.endpoints.quota?{}:{body:JSON.stringify({question:"test",stream:!1})}});return s.ok?(this.setupState.connectionStatus="connected",this.setupState.backendConfigured=!0,!0):(this.setupState.connectionStatus="failed",this.setupState.lastError=`Connection failed: ${s.status} ${s.statusText}`,!1)}catch(t){return this.setupState.connectionStatus="failed",this.setupState.lastError=t.message||"Connection failed",!1}},completeSetup(){var o,t;this.setupState.isActive=!1,this.setupState.currentStep="complete",rn(),(t=(o=q())==null?void 0:o.onSetupComplete)==null||t.call(o)},skipSetup(){this.setupState.isActive=!1,rn()}}});function an(o){const t=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let r=o,s;for(;(s=t.exec(o))!==null;){const[a,i,l]=s,[u,p]=l.includes(":")?l.split(":"):["default",l];n.push({id:p,name:i,type:u}),r=r.replace(a,i)}return{cleanText:r,mentions:n}}function Ho(o){const{cleanText:t}=an(o);return t}function ln(o){return o.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function cn(o,t){const r=o.substring(0,t).match(/@(\w*)$/);return r?{inMention:!0,query:r[1],startPos:t-r[0].length}:{inMention:!1,query:"",startPos:-1}}function At(o,t){var n,r;return t!=null&&t.getDisplayName?t.getDisplayName(o):o.name||o.title||((n=o.attributes)==null?void 0:n.name)||((r=o.attributes)==null?void 0:r.title)||"Unknown"}function un(o,t){var n,r;return t!=null&&t.getSubtitle?t.getSubtitle(o):((n=o.attributes)==null?void 0:n.email)||((r=o.attributes)==null?void 0:r.description)||null}function Uo(o,t){return t!=null&&t.buildMentionText?t.buildMentionText(o):`@[${At(o,t)}](${o.type}:${o.id})`}function dn(o){var n;const t=q();return(n=t==null?void 0:t.mentionProviders)==null?void 0:n.find(r=>r.type===o)}function pn(o){const t=q(),n=(t==null?void 0:t.mentionProviders)||[];return o?n.filter(r=>r.routes?r.routes.some(s=>s.endsWith("*")?o.startsWith(s.slice(0,-1)):o===s||o.startsWith(s+"/")):!0):n}function mn(o){return o.map(t=>({type:t.type,id:t.id,name:t.name}))}function fn(o){return o.reduce((t,n)=>{const r=n.type||"default";return t[r]||(t[r]=[]),t[r].push(n),t},{})}function qo(){return{extractMentions:an,parseAndCleanMessage:Ho,renderMentionsInHtml:ln,detectMentionContext:cn,getMentionDisplayName:At,getMentionSubtitle:un,buildMentionText:Uo,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 Be=Mt();function hn(o){Be=o}const gn=/[&<>"']/,vo=new RegExp(gn.source,"g"),yn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,jo=new RegExp(yn.source,"g"),Wo={"&":"&","<":"<",">":">",'"':""","'":"'"},kn=o=>Wo[o];function le(o,t){if(t){if(gn.test(o))return o.replace(vo,kn)}else if(yn.test(o))return o.replace(jo,kn);return o}const Ko=/(^|[^\[])\^/g;function P(o,t){let n=typeof o=="string"?o:o.source;t=t||"";const r={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Ko,"$1"),n=n.replace(s,i),r},getRegex:()=>new RegExp(n,t)};return r}function xn(o){try{o=encodeURI(o).replace(/%25/g,"%")}catch{return null}return o}const Ue={exec:()=>null};function wn(o,t){const n=o.replace(/\|/g,(a,i,l)=>{let u=!1,p=i;for(;--p>=0&&l[p]==="\\";)u=!u;return u?"|":" |"}),r=n.split(/ \|/);let s=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(/\\\|/g,"|");return r}function qe(o,t,n){const r=o.length;if(r===0)return"";let s=0;for(;s<r&&o.charAt(r-s-1)===t;)s++;return o.slice(0,r-s)}function Go(o,t){if(o.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<o.length;r++)if(o[r]==="\\")r++;else if(o[r]===t[0])n++;else if(o[r]===t[1]&&(n--,n<0))return r;return-1}function bn(o,t,n,r){const s=t.href,a=t.title?le(t.title):null,i=o[1].replace(/\\([\[\]])/g,"$1");if(o[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:s,title:a,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:s,title:a,text:le(i)}}function Qo(o,t){const n=o.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.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,$e){"use strict";var Ya=Object.defineProperty;var Xa=(L,e,$e)=>e in L?Ya(L,e,{enumerable:!0,configurable:!0,writable:!0,value:$e}):L[e]=$e;var H=(L,e,$e)=>Xa(L,typeof e!="symbol"?e+"":e,$e);let Ne=null;const wo=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(o){Ne=o,wo.value=o}function v(){return Ne}function bo(){if(!Ne)throw new Error("[@doderasoftware/restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Ne}function Ct(){return Ne!==null}function te(o,t){const n=Ne,r=(n==null?void 0:n.labels)||{},s=n==null?void 0:n.translate;if(s){const i=s(o,t);if(i!==o)return i}let a=r[o]||Et[o];return t&&Object.entries(t).forEach(([i,l])=>{a=a.replace(`{${i}}`,String(l))}),a}function tn(o){return{chatHistoryLimit:15,maxAttachments:5,maxFileSize:10485760,acceptedFileTypes:"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",chatHistoryKey:"restify_ai_chat_history",drawerStateKey:"restify_ai_drawer_open",keyboardShortcut:"cmd+g",enableSupportMode:!1}[o]}function he(o){const t=Ne;return t?t[o]??tn(o):tn(o)}const Re={Assistant:"assistant",User:"user",System:"system"};async function Eo(o,t){const n=o.getReader();let r;for(;!(r=await n.read()).done;)t(r.value)}function Co(o){let t,n,r,s=!1;return function(i){t===void 0?(t=i,n=0,r=-1):t=To(t,i);const l=t.length;let u=0;for(;n<l;){s&&(t[n]===10&&(u=++n),s=!1);let p=-1;for(;n<l&&p===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-u);break;case 13:s=!0;case 10:p=n;break}if(p===-1)break;o(t.subarray(u,p),r),u=n,r=-1}u===l?t=void 0:u!==0&&(t=t.subarray(u),n-=u)}}function So(o,t,n){let r=nn();const s=new TextDecoder;return function(i,l){if(i.length===0)n==null||n(r),r=nn();else if(l>0){const u=s.decode(i.subarray(0,l)),p=l+(i[l+1]===32?2:1),d=s.decode(i.subarray(p));switch(u){case"data":r.data=r.data?r.data+`
|
|
2
|
+
`+d:d;break;case"event":r.event=d;break;case"id":o(r.id=d);break;case"retry":const y=parseInt(d,10);isNaN(y)||t(r.retry=y);break}}}}function To(o,t){const n=new Uint8Array(o.length+t.length);return n.set(o),n.set(t,o.length),n}function nn(){return{data:"",event:"",id:"",retry:void 0}}var Ao=function(o,t){var n={};for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&t.indexOf(r)<0&&(n[r]=o[r]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(o);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(o,r[s])&&(n[r[s]]=o[r[s]]);return n};const St="text/event-stream",Mo=1e3,on="last-event-id";function No(o,t){var{signal:n,headers:r,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:u,fetch:p}=t,d=Ao(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((y,k)=>{const m=Object.assign({},r);m.accept||(m.accept=St);let f;function R(){f.abort(),document.hidden||I()}u||document.addEventListener("visibilitychange",R);let h=Mo,g=0;function C(){document.removeEventListener("visibilitychange",R),window.clearTimeout(g),f.abort()}n==null||n.addEventListener("abort",()=>{C(),y()});const b=p??window.fetch,w=s??Ro;async function I(){var V;f=new AbortController;try{const F=await b(o,Object.assign(Object.assign({},d),{headers:m,signal:f.signal}));await w(F),await Eo(F.body,Co(So(E=>{E?m[on]=E:delete m[on]},E=>{h=E},a))),i==null||i(),C(),y()}catch(F){if(!f.signal.aborted)try{const E=(V=l==null?void 0:l(F))!==null&&V!==void 0?V:h;window.clearTimeout(g),g=window.setTimeout(I,E)}catch(E){C(),k(E)}}}I()})}function Ro(o){const t=o.headers.get("content-type");if(!(t!=null&&t.startsWith(St)))throw new Error(`Expected content-type to be ${St}, Actual: ${t}`)}function it(o){if(!o)throw console.error("[RestifyAi] Endpoint is undefined. Check your endpoints configuration."),new Error("AI service endpoint is not configured. Please contact support.");const t=v(),n=(t==null?void 0:t.baseUrl)||"";if(!n||o.startsWith("http://")||o.startsWith("https://"))return o;const r=n.endsWith("/")?n.slice(0,-1):n,s=o.startsWith("/")?o:`/${o}`;return`${r}${s}`}function Bo(o){const n=(o instanceof Error?o.message:String(o)).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 Lo(o,t){var n,r,s;try{if(t==="done"||o==="[DONE]")return"[DONE]";const a=JSON.parse(o);return(a==null?void 0:a.content)!==void 0?a.content:((s=(r=(n=a==null?void 0:a.choices)==null?void 0:n[0])==null?void 0:r.delta)==null?void 0:s.content)||null}catch{return null}}function Do(o){return new Promise(t=>setTimeout(t,o))}function Io(o){const t={};return o.forEach(n=>{var r;(r=n.attachments)==null||r.forEach(s=>{s!=null&&s.id&&(t[s.id]=s)})}),t}function Se(o){const t=v();return o==="chatHistory"?(t==null?void 0:t.chatHistoryKey)||"restify_ai_chat_history":o==="setupComplete"?"restify_ai_setup_complete":(t==null?void 0:t.drawerStateKey)||"restify_ai_drawer_open"}function Fe(o){try{sessionStorage.setItem(Se("chatHistory"),JSON.stringify(o))}catch(t){console.warn("[RestifyAi] Failed to save chat history:",t)}}function zo(){try{const o=sessionStorage.getItem(Se("chatHistory"));if(o){const t=JSON.parse(o),n=t.filter(a=>{var i;return!(a.role===Re.Assistant&&a.loading||a.role===Re.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==t.length&&sessionStorage.setItem(Se("chatHistory"),JSON.stringify(n));const r=n[n.length-1],s=(r==null?void 0:r.role)===Re.User;return{history:n,hasOrphanedUserMessage:s,orphanedMessage:s?{question:r.message,attachments:r.attachments||[]}:void 0}}}catch(o){console.warn("[RestifyAi] Failed to load chat history:",o)}return{history:[],hasOrphanedUserMessage:!1}}function $o(){try{sessionStorage.removeItem(Se("chatHistory"))}catch(o){console.warn("[RestifyAi] Failed to clear chat history:",o)}}function Oo(o){try{o.message||o.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(o)):sessionStorage.removeItem("restify_ai_error_state")}catch(t){console.warn("[RestifyAi] Failed to save error state:",t)}}function Vo(){try{const o=sessionStorage.getItem("restify_ai_error_state");if(o)return JSON.parse(o)}catch(o){console.warn("[RestifyAi] Failed to load error state:",o)}return null}function Po(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(o){console.warn("[RestifyAi] Failed to clear error state:",o)}}function Tt(o){try{localStorage.setItem(Se("drawerState"),JSON.stringify(o))}catch(t){console.warn("[RestifyAi] Failed to save drawer state:",t)}}function _o(){try{const o=localStorage.getItem(Se("drawerState"));if(o!==null)return JSON.parse(o)}catch(o){console.warn("[RestifyAi] Failed to load drawer state:",o)}return!1}function Ho(){try{return localStorage.getItem(Se("setupComplete"))==="true"}catch{return!1}}function rn(){try{localStorage.setItem(Se("setupComplete"),"true")}catch(o){console.warn("[RestifyAi] Failed to mark setup complete:",o)}}function sn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}let Ue=new AbortController;const Te=$e.defineStore("restifyAiStore",{state:()=>{const o=zo(),t=Vo();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}:o.hasOrphanedUserMessage&&o.orphanedMessage&&(n={message:"Previous request failed. Click retry to try again.",failedQuestion:o.orphanedMessage.question,failedAttachments:o.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}),{chatHistoryLimit:he("chatHistoryLimit")||20,chatHistory:o.history,uploadedFiles:Io(o.history),loading:!1,showChat:_o(),isFullscreen:!1,sending:!1,pageContext:null,quota:(()=>{const r=he("chatHistoryLimit")||10,s=o.history.filter(a=>a.role==="user").length;return{limit:r,used:s,remaining:Math.max(0,r-s)}})(),error:n,supportRequestMode:!1,setupState:!Ct()&&!Ho()?{...sn(),isActive:!0}:sn()}},getters:{hasMessages:o=>o.chatHistory.length>0,isInSetupMode:o=>o.setupState.isActive,canChat:o=>!o.setupState.isActive||o.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(o=0){await e.nextTick(),o>0&&await new Promise(n=>setTimeout(n,o));const t=document.getElementById("rai-chat-bottom");t&&t.scrollIntoView({behavior:"smooth"})},parseStreamContent(o,t){const n=v(),r=n==null?void 0:n.parseStreamContent;return r?r(t,o):Lo(t,o)},async askQuestion(o,t=[],n=[],r=!1){var m;const s=v();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,p=l.retryDelay??1e3;let d=0;const y=t.map(f=>({id:f.id,name:f.name,url:f.url,type:f.type,size:f.size,extractedText:f.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Re.User,message:o,loading:!1,attachments:y,mentions:n,timestamp:Date.now()}),y.forEach(f=>this.registerUploadedFile(f)),Fe(this.chatHistory),this.sending=!0,this.quota.remaining>0&&!r&&(this.quota.remaining--,this.quota.used++),this.scrollToBottom(),this.chatHistory.length>=this.chatHistoryLimit&&((m=s.onError)==null||m.call(s,new Error("Chat history limit reached")));const k=async()=>{var f,R,h;try{const g=this.chatHistory.map(T=>({role:T.role,content:T.message})),C={},b=T=>{T!=null&&T.id&&(C[T.id]={extracted_text:T.extractedText||"",file_name:T.name,mime_type:T.type||"",...T.size?{file_size:T.size}:{},...T.url?{file_url:T.url}:{}})};Object.values(this.uploadedFiles).forEach(b),this.chatHistory.forEach(T=>{var _;return(_=T.attachments)==null?void 0:_.forEach(b)}),y.forEach(b);const w=Object.values(C),I=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Re.Assistant,message:"",loading:!0,timestamp:Date.now()}),Fe(this.chatHistory),Ue=new AbortController,this.scrollToBottom();const V=await s.getAuthToken(),E={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?E["X-Test-Api-Key"]=this.setupState.testApiKey:V&&(E.Authorization=`Bearer ${V}`);const D={};if(typeof window<"u"){D.route=window.location.pathname;const T=new URLSearchParams(window.location.search),_={};T.forEach((De,ye)=>{_[ye]=De}),Object.keys(_).length>0&&(D.query=_),document.title&&(D.pageTitle=document.title)}n.length>0&&(D.mentionedEntities=n.map(T=>({type:T.type,id:T.id,displayName:T.name,metadata:T.metadata})));let A={message:o,history:g,stream:!0,...w.length>0&&{files:w},...Object.keys(D).length>0&&{context:D},...this.supportRequestMode&&{contact_support:!0},...s.model&&{model:s.model},...s.temperature&&{temperature:s.temperature},...s.maxTokens&&{max_tokens:s.maxTokens}};s.beforeSend&&(A=await s.beforeSend(A)),s.buildRequest&&(A=await s.buildRequest(A)),(f=s.onMessageSent)==null||f.call(s,this.chatHistory[I-1]);const S=it(s.endpoints.ask);let j={method:"POST",body:JSON.stringify(A),headers:E};return s.requestInterceptor&&(j=await s.requestInterceptor(S,j)),(R=s.onStreamStart)==null||R.call(s),await No(S,{method:"POST",body:JSON.stringify(A),signal:Ue.signal,headers:j.headers,openWhenHidden:!0,async onopen(T){if(!T.ok){if(T.status===429){const _=Te();throw _.error={message:te("noQuota"),failedQuestion:o,failedAttachments:y,timestamp:Date.now(),quotaExceeded:!0},await _.fetchQuota(),new Error("Quota exceeded")}throw new Error(`Failed to connect: ${T.status}`)}},onmessage:async T=>{var ye,ke,Ae;const _=this.parseStreamContent(T.event,T.data);if(!_)return;this.chatHistory[I].loading=!1;const De={content:_,done:_==="[DONE]",raw:T.data};(ye=s.onStreamChunk)==null||ye.call(s,De),a?_==="[DONE]"?(this.chatHistory[I].streaming=!1,Fe(this.chatHistory),(ke=s.onStreamEnd)==null||ke.call(s,a),this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[I]),(Ae=s.onResponseReceived)==null||Ae.call(s,this.chatHistory[I])):(a+=_,this.chatHistory[I].message=a):(a=_,this.chatHistory[I].message=a,this.chatHistory[I].streaming=!0),await this.scrollToBottom()},onclose:()=>{var T,_;a&&!i&&(this.chatHistory[I].streaming=!1,this.chatHistory[I].loading=!1,Fe(this.chatHistory),(T=s.onStreamEnd)==null||T.call(s,a),s.afterResponse&&s.afterResponse(this.chatHistory[I]),(_=s.onResponseReceived)==null||_.call(s,this.chatHistory[I]))},onerror:T=>{if(!a)throw i=!0,T}}),!0}catch(g){i=!0;const C=this.chatHistory.length-1;return this.chatHistory.splice(C,1),g.name==="AbortError"?!0:d<u&&(l.shouldRetry?l.shouldRetry(g,d):!0)?(d++,await Do(p*d),k()):(this.error={message:Bo(g),failedQuestion:o,failedAttachments:y,timestamp:Date.now()},Oo({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(h=s.onError)==null||h.call(s,g),!1)}finally{this.sending=!1}};return k()},cancelRequest(){Ue==null||Ue.abort(),this.chatHistory=this.chatHistory.map(o=>({...o,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var n;const o=v();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1);const t=he("chatHistoryLimit")||10;this.quota={limit:t,used:0,remaining:t},$o(),(n=o==null?void 0:o.onNewChat)==null||n.call(o)},async retry(){if(!this.error.failedQuestion)return!1;const o=this.error.failedQuestion,t=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Re.User&&n.message===o&&(this.chatHistory.pop(),Fe(this.chatHistory)),this.clearError(),await this.askQuestion(o,t)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},Po()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var t,n;const o=v();if((t=o==null?void 0:o.endpoints)!=null&&t.quota)try{const r=await o.getAuthToken(),s=o.getCustomHeaders?await o.getCustomHeaders():{},a=it(o.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...r?{Authorization:`Bearer ${r}`}:{},...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&&o.enableSupportMode!==!1&&(this.supportRequestMode=!0),(n=o.onQuotaFetched)==null||n.call(o,this.quota)}}catch(r){console.error("[RestifyAi] Failed to fetch quota:",r)}},async uploadFile(o){var s,a,i,l,u;const t=v();if(!((s=t==null?void 0:t.endpoints)!=null&&s.uploadFile))return console.warn("[RestifyAi] No uploadFile endpoint configured"),null;const r={id:crypto.randomUUID(),name:o.name,type:o.type,size:o.size,uploading:!0,progress:0};(a=t.onFileUploadStart)==null||a.call(t,r);try{const p=await t.getAuthToken(),d=t.getCustomHeaders?await t.getCustomHeaders():{},y=it(t.endpoints.uploadFile),k=new FormData;k.append("file",o);const m=await new Promise((f,R)=>{const h=new XMLHttpRequest;h.upload.addEventListener("progress",g=>{var C;if(g.lengthComputable){const b=Math.round(g.loaded/g.total*100);r.progress=b,(C=t.onFileUploadProgress)==null||C.call(t,r,b)}}),h.addEventListener("load",()=>{var g,C;if(h.status>=200&&h.status<300)try{const b=JSON.parse(h.responseText),w={...r,url:b.url||((g=b.data)==null?void 0:g.url),extractedText:b.extracted_text||((C=b.data)==null?void 0:C.extracted_text),uploading:!1,progress:100};f(w)}catch{R(new Error("Failed to parse upload response"))}else R(new Error(`Upload failed: ${h.status}`))}),h.addEventListener("error",()=>R(new Error("Upload failed"))),h.open("POST",y),p&&h.setRequestHeader("Authorization",`Bearer ${p}`),Object.entries(d).forEach(([g,C])=>h.setRequestHeader(g,C)),h.send(k)});return(i=t.onFileUploadComplete)==null||i.call(t,m),m}catch(p){const d={...r,uploading:!1};return(l=t.onFileUploadError)==null||l.call(t,d,p),(u=t.onError)==null||u.call(t,p),null}},setPageContext(o){this.pageContext=o},toggleDrawer(){var o,t;this.showChat=!this.showChat,Tt(this.showChat),(t=(o=v())==null?void 0:o.onDrawerToggle)==null||t.call(o,this.showChat),this.showChat&&this.scrollToBottom(100)},openDrawer(){var o,t;this.showChat=!0,Tt(!0),(t=(o=v())==null?void 0:o.onDrawerToggle)==null||t.call(o,!0),this.scrollToBottom(100)},closeDrawer(){var o,t;this.showChat=!1,Tt(!1),(t=(o=v())==null?void 0:o.onDrawerToggle)==null||t.call(o,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(o){o!=null&&o.id&&(this.uploadedFiles[o.id]={...o})},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(o){this.setupState.currentStep=o},setTestApiKey(o){this.setupState.testApiKey=o},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const o=v();if(!o)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=o.endpoints.quota||o.endpoints.ask,r=it(n),s=await fetch(r,{method:o.endpoints.quota?"GET":"POST",headers:t,...o.endpoints.quota?{}:{body:JSON.stringify({question:"test",stream:!1})}});return s.ok?(this.setupState.connectionStatus="connected",this.setupState.backendConfigured=!0,!0):(this.setupState.connectionStatus="failed",this.setupState.lastError=`Connection failed: ${s.status} ${s.statusText}`,!1)}catch(t){return this.setupState.connectionStatus="failed",this.setupState.lastError=t.message||"Connection failed",!1}},completeSetup(){var o,t;this.setupState.isActive=!1,this.setupState.currentStep="complete",rn(),(t=(o=v())==null?void 0:o.onSetupComplete)==null||t.call(o)},skipSetup(){this.setupState.isActive=!1,rn()}}});function an(o){const t=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let r=o,s;for(;(s=t.exec(o))!==null;){const[a,i,l]=s,[u,p]=l.includes(":")?l.split(":"):["default",l];n.push({id:p,name:i,type:u}),r=r.replace(a,i)}return{cleanText:r,mentions:n}}function Fo(o){const{cleanText:t}=an(o);return t}function ln(o){return o.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function cn(o,t){const r=o.substring(0,t).match(/@(\w*)$/);return r?{inMention:!0,query:r[1],startPos:t-r[0].length}:{inMention:!1,query:"",startPos:-1}}function At(o,t){var n,r;return t!=null&&t.getDisplayName?t.getDisplayName(o):o.name||o.title||((n=o.attributes)==null?void 0:n.name)||((r=o.attributes)==null?void 0:r.title)||"Unknown"}function un(o,t){var n,r;return t!=null&&t.getSubtitle?t.getSubtitle(o):((n=o.attributes)==null?void 0:n.email)||((r=o.attributes)==null?void 0:r.description)||null}function Uo(o,t){return t!=null&&t.buildMentionText?t.buildMentionText(o):`@[${At(o,t)}](${o.type}:${o.id})`}function dn(o){var n;const t=v();return(n=t==null?void 0:t.mentionProviders)==null?void 0:n.find(r=>r.type===o)}function pn(o){const t=v(),n=(t==null?void 0:t.mentionProviders)||[];return o?n.filter(r=>r.routes?r.routes.some(s=>s.endsWith("*")?o.startsWith(s.slice(0,-1)):o===s||o.startsWith(s+"/")):!0):n}function mn(o){return o.map(t=>({type:t.type,id:t.id,name:t.name}))}function fn(o){return o.reduce((t,n)=>{const r=n.type||"default";return t[r]||(t[r]=[]),t[r].push(n),t},{})}function qo(){return{extractMentions:an,parseAndCleanMessage:Fo,renderMentionsInHtml:ln,detectMentionContext:cn,getMentionDisplayName:At,getMentionSubtitle:un,buildMentionText:Uo,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 Be=Mt();function hn(o){Be=o}const gn=/[&<>"']/,vo=new RegExp(gn.source,"g"),yn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,jo=new RegExp(yn.source,"g"),Wo={"&":"&","<":"<",">":">",'"':""","'":"'"},kn=o=>Wo[o];function le(o,t){if(t){if(gn.test(o))return o.replace(vo,kn)}else if(yn.test(o))return o.replace(jo,kn);return o}const Ko=/(^|[^\[])\^/g;function P(o,t){let n=typeof o=="string"?o:o.source;t=t||"";const r={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Ko,"$1"),n=n.replace(s,i),r},getRegex:()=>new RegExp(n,t)};return r}function xn(o){try{o=encodeURI(o).replace(/%25/g,"%")}catch{return null}return o}const qe={exec:()=>null};function wn(o,t){const n=o.replace(/\|/g,(a,i,l)=>{let u=!1,p=i;for(;--p>=0&&l[p]==="\\";)u=!u;return u?"|":" |"}),r=n.split(/ \|/);let s=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(/\\\|/g,"|");return r}function ve(o,t,n){const r=o.length;if(r===0)return"";let s=0;for(;s<r&&o.charAt(r-s-1)===t;)s++;return o.slice(0,r-s)}function Go(o,t){if(o.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<o.length;r++)if(o[r]==="\\")r++;else if(o[r]===t[0])n++;else if(o[r]===t[1]&&(n--,n<0))return r;return-1}function bn(o,t,n,r){const s=t.href,a=t.title?le(t.title):null,i=o[1].replace(/\\([\[\]])/g,"$1");if(o[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:s,title:a,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:s,title:a,text:le(i)}}function Qo(o,t){const n=o.match(/^(\s+)(?:```)/);if(n===null)return t;const r=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>=r.length?s.slice(r.length):s}).join(`
|
|
4
|
-
`)}class lt{constructor(t){
|
|
5
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],s=Qo(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:s}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const s=
|
|
6
|
-
`)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let r=
|
|
4
|
+
`)}class lt{constructor(t){H(this,"options");H(this,"rules");H(this,"lexer");this.options=t||Be}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 r=n[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:ve(r,`
|
|
5
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],s=Qo(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:s}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const s=ve(r,"#");(this.options.pedantic||!s||/ $/.test(s))&&(r=s.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:ve(n[0],`
|
|
6
|
+
`)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let r=ve(n[0],`
|
|
7
7
|
`).split(`
|
|
8
8
|
`),s="",a="";const i=[];for(;r.length>0;){let l=!1;const u=[];let p;for(p=0;p<r.length;p++)if(/^ {0,3}>/.test(r[p]))u.push(r[p]),l=!0;else if(!l)u.push(r[p]);else break;r=r.slice(p);const d=u.join(`
|
|
9
|
-
`),
|
|
9
|
+
`),y=d.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
10
10
|
$1`).replace(/^ {0,3}>[ \t]?/gm,"");s=s?`${s}
|
|
11
11
|
${d}`:d,a=a?`${a}
|
|
12
|
-
${
|
|
12
|
+
${y}`:y;const k=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(y,i,!0),this.lexer.state.top=k,r.length===0)break;const m=i[i.length-1];if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){const f=m,R=f.raw+`
|
|
13
13
|
`+r.join(`
|
|
14
|
-
`),
|
|
14
|
+
`),h=this.blockquote(R);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((m==null?void 0:m.type)==="list"){const f=m,R=f.raw+`
|
|
15
15
|
`+r.join(`
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r=n[1].trim();const s=r.length>1,a={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");const i=new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;t;){let u=!1,p="",d="";if(!(n=i.exec(t))||this.rules.block.hr.test(t))break;p=n[0],t=t.substring(p.length);let
|
|
18
|
-
`,1)[0].replace(/^\t+/,
|
|
19
|
-
`,1)[0],m=!
|
|
20
|
-
`,t=t.substring(
|
|
21
|
-
`,1)[0];let
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`,t=t.substring(
|
|
16
|
+
`),h=this.list(R);i[i.length-1]=h,s=s.substring(0,s.length-m.raw.length)+h.raw,a=a.substring(0,a.length-f.raw.length)+h.raw,r=R.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 r=n[1].trim();const s=r.length>1,a={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");const i=new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;t;){let u=!1,p="",d="";if(!(n=i.exec(t))||this.rules.block.hr.test(t))break;p=n[0],t=t.substring(p.length);let y=n[2].split(`
|
|
18
|
+
`,1)[0].replace(/^\t+/,g=>" ".repeat(3*g.length)),k=t.split(`
|
|
19
|
+
`,1)[0],m=!y.trim(),f=0;if(this.options.pedantic?(f=2,d=y.trimStart()):m?f=n[1].length+1:(f=n[2].search(/[^ ]/),f=f>4?1:f,d=y.slice(f),f+=n[1].length),m&&/^[ \t]*$/.test(k)&&(p+=k+`
|
|
20
|
+
`,t=t.substring(k.length+1),u=!0),!u){const g=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),b=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),w=new RegExp(`^ {0,${Math.min(3,f-1)}}#`),I=new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const V=t.split(`
|
|
21
|
+
`,1)[0];let F;if(k=V,this.options.pedantic?(k=k.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),F=k):F=k.replace(/\t/g," "),b.test(k)||w.test(k)||I.test(k)||g.test(k)||C.test(k))break;if(F.search(/[^ ]/)>=f||!k.trim())d+=`
|
|
22
|
+
`+F.slice(f);else{if(m||y.replace(/\t/g," ").search(/[^ ]/)>=4||b.test(y)||w.test(y)||C.test(y))break;d+=`
|
|
23
|
+
`+k}!m&&!k.trim()&&(m=!0),p+=V+`
|
|
24
|
+
`,t=t.substring(V.length+1),y=F.slice(f)}}a.loose||(l?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(p)&&(l=!0));let R=null,h;this.options.gfm&&(R=/^\[[ xX]\] /.exec(d),R&&(h=R[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:p,task:!!R,checked:h,loose:!1,text:d,tokens:[]}),a.raw+=p}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 p=a.items[u].tokens.filter(y=>y.type==="space"),d=p.length>0&&p.some(y=>/\n.*\n/.test(y.raw));a.loose=d}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 r=n[1].toLowerCase().replace(/\s+/g," "),s=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:s,title:a}}}table(t){const n=this.rules.block.table.exec(t);if(!n||!/[:|]/.test(n[2]))return;const r=wn(n[1]),s=n[2].replace(/^\||\| *$/g,"").split("|"),a=n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
25
25
|
`):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?i.align.push("right"):/^ *:-+: *$/.test(l)?i.align.push("center"):/^ *:-+ *$/.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<r.length;l++)i.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:i.align[l]});for(const l of a)i.rows.push(wn(l,i.header.length).map((u,p)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:i.align[p]})));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 r=n[1].charAt(n[1].length-1)===`
|
|
26
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(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:le(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 r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=
|
|
27
|
-
]`).replace("lheading",Cn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},An=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ar=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mn=/^( {2,}|\\)\n(?!\s*$)/,ir=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
26
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}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:le(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 r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=ve(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Go(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(r)?s=s.slice(1):s=s.slice(1,-1)),bn(n,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){const s=(r[2]||r[1]).replace(/\s+/g," "),a=n[s.toLowerCase()];if(!a){const i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return bn(r,a,r[0],this.lexer)}}emStrong(t,n,r=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!s||s[3]&&r.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const i=[...s[0]].length-1;let l,u,p=i,d=0;const y=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(y.lastIndex=0,n=n.slice(-1*t.length+i);(s=y.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]){p+=u;continue}else if((s[5]||s[6])&&i%3&&!((i+u)%3)){d+=u;continue}if(p-=u,p>0)continue;u=Math.min(u,u+p+d);const k=[...s[0]][0].length,m=t.slice(0,i+s.index+k+u);if(Math.min(i,u)%2){const R=m.slice(1,-1);return{type:"em",raw:m,text:R,tokens:this.lexer.inlineTokens(R)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const s=/[^ ]/.test(r),a=/^ /.test(r)&&/ $/.test(r);return s&&a&&(r=r.substring(1,r.length-1)),r=le(r,!0),{type:"codespan",raw:n[0],text:r}}}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 r,s;return n[2]==="@"?(r=le(n[1]),s="mailto:"+r):(r=le(n[1]),s=r),{type:"link",raw:n[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(t){var r;let n;if(n=this.rules.inline.url.exec(t)){let s,a;if(n[2]==="@")s=le(n[0]),a="mailto:"+s;else{let i;do i=n[0],n[0]=((r=this.rules.inline._backpedal.exec(n[0]))==null?void 0:r[0])??"";while(i!==n[0]);s=le(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 r;return this.lexer.state.inRawBlock?r=n[0]:r=le(n[0]),{type:"text",raw:n[0],text:r}}}}const Zo=/^(?:[ \t]*(?:\n|$))+/,Yo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Xo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,je=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Jo=/^ {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]+)*)/,er=/^[^\n]+/,Rt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,tr=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),nr=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]*?(?:-->|$))/,or=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",je).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:Yo,def:tr,fences:Xo,heading:Jo,hr:je,html:or,lheading:Cn,list:nr,newline:Zo,paragraph:Sn,table:qe,text:er},Tn=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",je).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(),rr={...Lt,table:Tn,paragraph:P(Nt).replace("hr",je).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()},sr={...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:qe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Nt).replace("hr",je).replace("heading",` *#{1,6} *[^
|
|
27
|
+
]`).replace("lheading",Cn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},An=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ar=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mn=/^( {2,}|\\)\n(?!\s*$)/,ir=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,We="\\p{P}\\p{S}",lr=P(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,We).getRegex(),cr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ur=P(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,We).getRegex(),dr=P("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,We).getRegex(),pr=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,We).getRegex(),mr=P(/\\([punct])/,"gu").replace(/punct/g,We).getRegex(),fr=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(),hr=P(Bt).replace("(?:-->|$)","-->").getRegex(),gr=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",hr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ut=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,yr=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(),kr=P("reflink|nolink(?!\\()","g").replace("reflink",Nn).replace("nolink",Rn).getRegex(),Dt={_backpedal:qe,anyPunctuation:mr,autolink:fr,blockSkip:cr,br:Mn,code:ar,del:qe,emStrongLDelim:ur,emStrongRDelimAst:dr,emStrongRDelimUnd:pr,escape:An,link:yr,nolink:Rn,punctuation:lr,reflink:Nn,reflinkSearch:kr,tag:gr,text:ir,url:qe},xr={...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.!#$%&'*+\/=?_`{\|}~-]+@)))/},wr={...It,br:P(Mn).replace("{2,}","*").getRegex(),text:P(It.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},dt={normal:Lt,gfm:rr,pedantic:sr},Ke={normal:Dt,gfm:It,breaks:wr,pedantic:xr};class ce{constructor(t){H(this,"tokens");H(this,"options");H(this,"state");H(this,"tokenizer");H(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Be,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:Ke.normal};this.options.pedantic?(n.block=dt.pedantic,n.inline=Ke.pedantic):this.options.gfm&&(n.block=dt.gfm,this.options.breaks?n.inline=Ke.breaks:n.inline=Ke.gfm),this.tokenizer.rules=n}static get rules(){return{block:dt,inline:Ke}}static lex(t,n){return new ce(n).lex(t)}static lexInline(t,n){return new ce(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
28
28
|
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!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
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+=`
|
|
@@ -34,7 +34,7 @@ ${h}`:h;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
34
34
|
`+s.raw,a.text+=`
|
|
35
35
|
`+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s),r=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(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 r,s,a,i=t,l,u,p;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.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||(p=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),s=n[n.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),s=n[n.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,p)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t))){t=t.substring(r.raw.length),n.push(r);continue}if(a=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const
|
|
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 r,s,a,i=t,l,u,p;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.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||(p=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),s=n[n.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),s=n[n.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,p)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t))){t=t.substring(r.raw.length),n.push(r);continue}if(a=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const y=t.slice(1);let k;this.options.extensions.startInline.forEach(m=>{k=m.call({lexer:this},y),typeof k=="number"&&k>=0&&(d=Math.min(d,k))}),d<1/0&&d>=0&&(a=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(a)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(p=r.raw.slice(-1)),u=!0,s=n[n.length-1],s&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class pt{constructor(t){H(this,"options");H(this,"parser");this.options=t||Be}space(t){return""}code({text:t,lang:n,escaped:r}){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-'+le(s)+'">'+(r?a:le(a,!0))+`</code></pre>
|
|
39
39
|
`:"<pre><code>"+(r?a:le(a,!0))+`</code></pre>
|
|
40
40
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
@@ -52,12 +52,12 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
52
52
|
`}tablerow({text:t}){return`<tr>
|
|
53
53
|
${t}</tr>
|
|
54
54
|
`}tablecell(t){const n=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+n+`</${r}>
|
|
55
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:r}){const s=this.parser.parseInline(r),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:r}){const s=xn(t);if(s===null)return r;t=s;let a=`<img src="${t}" alt="${r}"`;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 ue{constructor(t){
|
|
56
|
-
`+this.renderer.text(l);n?r+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u}]}):r+=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 r}parseInline(t,n){n=n||this.renderer;let r="";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)){r+=l||"";continue}}const i=a;switch(i.type){case"escape":{r+=n.text(i);break}case"html":{r+=n.html(i);break}case"link":{r+=n.link(i);break}case"image":{r+=n.image(i);break}case"strong":{r+=n.strong(i);break}case"em":{r+=n.em(i);break}case"codespan":{r+=n.codespan(i);break}case"br":{r+=n.br(i);break}case"del":{r+=n.del(i);break}case"text":{r+=n.text(i);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}}class
|
|
57
|
-
Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+le(r.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(r);throw r}}}const Le=new br;function V(o,t){return Le.parse(o,t)}V.options=V.setOptions=function(o){return Le.setOptions(o),V.defaults=Le.defaults,hn(V.defaults),V},V.getDefaults=Mt,V.defaults=Be,V.use=function(...o){return Le.use(...o),V.defaults=Le.defaults,hn(V.defaults),V},V.walkTokens=function(o,t){return Le.walkTokens(o,t)},V.parseInline=Le.parseInline,V.Parser=ue,V.parser=ue.parse,V.Renderer=pt,V.TextRenderer=zt,V.Lexer=ce,V.lexer=ce.lex,V.Tokenizer=lt,V.Hooks=Ke,V.parse=V,V.options,V.setOptions,V.use,V.walkTokens,V.parseInline,ue.parse,ce.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:Er,getPrototypeOf:Cr,getOwnPropertyDescriptor:Sr}=Object;let{freeze:re,seal:de,create:$t}=Object,{apply:Ot,construct:Vt}=typeof Reflect<"u"&&Reflect;re||(re=function(t){return t}),de||(de=function(t){return t}),Ot||(Ot=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),a=2;a<r;a++)s[a-2]=arguments[a];return t.apply(n,s)}),Vt||(Vt=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new t(...r)});const mt=ae(Array.prototype.forEach),Tr=ae(Array.prototype.lastIndexOf),Dn=ae(Array.prototype.pop),Ge=ae(Array.prototype.push),Ar=ae(Array.prototype.splice),ft=ae(String.prototype.toLowerCase),Pt=ae(String.prototype.toString),_t=ae(String.prototype.match),Qe=ae(String.prototype.replace),Mr=ae(String.prototype.indexOf),Nr=ae(String.prototype.trim),pe=ae(Object.prototype.hasOwnProperty),se=ae(RegExp.prototype.test),Ze=Rr(TypeError);function ae(o){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Ot(o,t,r)}}function Rr(o){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Vt(o,n)}}function I(o,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ft;Ln&&Ln(o,null);let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const a=n(s);a!==s&&(Er(t)||(t[r]=a),s=a)}o[s]=!0}return o}function Br(o){for(let t=0;t<o.length;t++)pe(o,t)||(o[t]=null);return o}function ge(o){const t=$t(null);for(const[n,r]of Bn(o))pe(o,n)&&(Array.isArray(r)?t[n]=Br(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=ge(r):t[n]=r);return t}function Ye(o,t){for(;o!==null;){const r=Sr(o,t);if(r){if(r.get)return ae(r.get);if(typeof r.value=="function")return ae(r.value)}o=Cr(o)}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"]),Lr=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"]),Dr=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"]),Ir=de(/\{\{[\w\W]*|[\w\W]*\}\}/gm),zr=de(/<%[\w\W]*|[\w\W]*%>/gm),$r=de(/\$\{[\w\W]*/gm),Or=de(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vr=de(/^aria-[\-\w]+$/),Vn=de(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pr=de(/^(?:\w+script|data):/i),_r=de(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pn=de(/^html$/i),Fr=de(/^[a-z][.\w]*(-[.\w]+)+$/i);var _n=Object.freeze({__proto__:null,ARIA_ATTR:Vr,ATTR_WHITESPACE:_r,CUSTOM_ELEMENT:Fr,DATA_ATTR:Or,DOCTYPE_NAME:Pn,ERB_EXPR:zr,IS_ALLOWED_URI:Vn,IS_SCRIPT_OR_DATA:Pr,MUSTACHE_EXPR:Ir,TMPLIT_EXPR:$r});const Xe={element:1,text:3,progressingInstruction:7,comment:8,document:9},Hr=function(){return typeof window>"u"?null:window},Ur=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const a="dompurify"+(r?"#"+r:"");try{return 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 o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Hr();const t=R=>Hn(R);if(t.version="3.3.0",t.removed=[],!o||!o.document||o.document.nodeType!==Xe.document||!o.Element)return t.isSupported=!1,t;let{document:n}=o;const r=n,s=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:u,NodeFilter:p,NamedNodeMap:d=o.NamedNodeMap||o.MozNamedAttrMap,HTMLFormElement:h,DOMParser:g,trustedTypes:m}=o,f=u.prototype,E=Ye(f,"cloneNode"),k=Ye(f,"remove"),y=Ye(f,"nextSibling"),b=Ye(f,"childNodes"),S=Ye(f,"parentNode");if(typeof i=="function"){const R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let w,z="";const{implementation:O,createNodeIterator:K,createDocumentFragment:C,getElementsByTagName:D}=n,{importNode:A}=r;let T=Fn();t.isSupported=typeof Bn=="function"&&typeof S=="function"&&O&&O.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:v,ERB_EXPR:N,TMPLIT_EXPR:F,DATA_ATTR:De,ARIA_ATTR:ye,IS_SCRIPT_OR_DATA:ke,ATTR_WHITESPACE:Ae,CUSTOM_ELEMENT:Wt}=_n;let{IS_ALLOWED_URI:gt}=_n,Q=null;const xe=I({},[...In,...Ft,...Ht,...Ut,...zn]);let Z=null;const Je=I({},[...$n,...qt,...On,...ht]);let j=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}})),Ie=null,et=null;const we=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,ot=!1,B=!0,$=!1,W=!0,H=!1,X=!1,G=!1,J=!1,Me=!1,yt=!1,to=!0,no=!1;const qa="user-content-";let Kt=!0,rt=!1,Oe={},Ve=null;const oo=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ro=null;const so=I({},["audio","video","img","source","image","track"]);let Gt=null;const ao=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",be="http://www.w3.org/1999/xhtml";let Pe=be,Qt=!1,Zt=null;const va=I({},[kt,xt,be],Pt);let wt=I({},["mi","mo","mn","ms","mtext"]),bt=I({},["annotation-xml"]);const ja=I({},["title","style","font","a","script"]);let st=null;const Wa=["application/xhtml+xml","text/html"],Ka="text/html";let ee=null,_e=null;const Ga=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(!(_e&&_e===c)){if((!c||typeof c!="object")&&(c={}),c=ge(c),st=Wa.indexOf(c.PARSER_MEDIA_TYPE)===-1?Ka:c.PARSER_MEDIA_TYPE,ee=st==="application/xhtml+xml"?Pt:ft,Q=pe(c,"ALLOWED_TAGS")?I({},c.ALLOWED_TAGS,ee):xe,Z=pe(c,"ALLOWED_ATTR")?I({},c.ALLOWED_ATTR,ee):Je,Zt=pe(c,"ALLOWED_NAMESPACES")?I({},c.ALLOWED_NAMESPACES,Pt):va,Gt=pe(c,"ADD_URI_SAFE_ATTR")?I(ge(ao),c.ADD_URI_SAFE_ATTR,ee):ao,ro=pe(c,"ADD_DATA_URI_TAGS")?I(ge(so),c.ADD_DATA_URI_TAGS,ee):so,Ve=pe(c,"FORBID_CONTENTS")?I({},c.FORBID_CONTENTS,ee):oo,Ie=pe(c,"FORBID_TAGS")?I({},c.FORBID_TAGS,ee):ge({}),et=pe(c,"FORBID_ATTR")?I({},c.FORBID_ATTR,ee):ge({}),Oe=pe(c,"USE_PROFILES")?c.USE_PROFILES:!1,tt=c.ALLOW_ARIA_ATTR!==!1,nt=c.ALLOW_DATA_ATTR!==!1,ot=c.ALLOW_UNKNOWN_PROTOCOLS||!1,B=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$=c.SAFE_FOR_TEMPLATES||!1,W=c.SAFE_FOR_XML!==!1,H=c.WHOLE_DOCUMENT||!1,J=c.RETURN_DOM||!1,Me=c.RETURN_DOM_FRAGMENT||!1,yt=c.RETURN_TRUSTED_TYPE||!1,G=c.FORCE_BODY||!1,to=c.SANITIZE_DOM!==!1,no=c.SANITIZE_NAMED_PROPS||!1,Kt=c.KEEP_CONTENT!==!1,rt=c.IN_PLACE||!1,gt=c.ALLOWED_URI_REGEXP||Vn,Pe=c.NAMESPACE||be,wt=c.MATHML_TEXT_INTEGRATION_POINTS||wt,bt=c.HTML_INTEGRATION_POINTS||bt,j=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$&&(nt=!1),Me&&(J=!0),Oe&&(Q=I({},zn),Z=[],Oe.html===!0&&(I(Q,In),I(Z,$n)),Oe.svg===!0&&(I(Q,Ft),I(Z,qt),I(Z,ht)),Oe.svgFilters===!0&&(I(Q,Ht),I(Z,qt),I(Z,ht)),Oe.mathMl===!0&&(I(Q,Ut),I(Z,On),I(Z,ht))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?we.tagCheck=c.ADD_TAGS:(Q===xe&&(Q=ge(Q)),I(Q,c.ADD_TAGS,ee))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?we.attributeCheck=c.ADD_ATTR:(Z===Je&&(Z=ge(Z)),I(Z,c.ADD_ATTR,ee))),c.ADD_URI_SAFE_ATTR&&I(Gt,c.ADD_URI_SAFE_ATTR,ee),c.FORBID_CONTENTS&&(Ve===oo&&(Ve=ge(Ve)),I(Ve,c.FORBID_CONTENTS,ee)),Kt&&(Q["#text"]=!0),H&&I(Q,["html","head","body"]),Q.table&&(I(Q,["tbody"]),delete Ie.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=c.TRUSTED_TYPES_POLICY,z=w.createHTML("")}else w===void 0&&(w=Ur(m,s)),w!==null&&typeof z=="string"&&(z=w.createHTML(""));re&&re(c),_e=c}},lo=I({},[...Ft,...Ht,...Lr]),co=I({},[...Ut,...Dr]),Qa=function(c){let x=S(c);(!x||!x.tagName)&&(x={namespaceURI:Pe,tagName:"template"});const M=ft(c.tagName),U=ft(x.tagName);return Zt[c.namespaceURI]?c.namespaceURI===xt?x.namespaceURI===be?M==="svg":x.namespaceURI===kt?M==="svg"&&(U==="annotation-xml"||wt[U]):!!lo[M]:c.namespaceURI===kt?x.namespaceURI===be?M==="math":x.namespaceURI===xt?M==="math"&&bt[U]:!!co[M]:c.namespaceURI===be?x.namespaceURI===xt&&!bt[U]||x.namespaceURI===kt&&!wt[U]?!1:!co[M]&&(ja[M]||!lo[M]):!!(st==="application/xhtml+xml"&&Zt[c.namespaceURI]):!1},fe=function(c){Ge(t.removed,{element:c});try{S(c).removeChild(c)}catch{k(c)}},ze=function(c,x){try{Ge(t.removed,{attribute:x.getAttributeNode(c),from:x})}catch{Ge(t.removed,{attribute:null,from:x})}if(x.removeAttribute(c),c==="is")if(J||Me)try{fe(x)}catch{}else try{x.setAttribute(c,"")}catch{}},uo=function(c){let x=null,M=null;if(G)c="<remove></remove>"+c;else{const Y=_t(c,/^[\r\n\t ]+/);M=Y&&Y[0]}st==="application/xhtml+xml"&&Pe===be&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const U=w?w.createHTML(c):c;if(Pe===be)try{x=new g().parseFromString(U,st)}catch{}if(!x||!x.documentElement){x=O.createDocument(Pe,"template",null);try{x.documentElement.innerHTML=Qt?z:U}catch{}}const oe=x.body||x.documentElement;return c&&M&&oe.insertBefore(n.createTextNode(M),oe.childNodes[0]||null),Pe===be?D.call(x,H?"html":"body")[0]:H?x.documentElement:oe},po=function(c){return K.call(c.ownerDocument||c,c,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Xt=function(c){return c instanceof h&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof d)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},mo=function(c){return typeof l=="function"&&c instanceof l};function Ee(R,c,x){mt(R,M=>{M.call(t,c,x,_e)})}const fo=function(c){let x=null;if(Ee(T.beforeSanitizeElements,c,null),Xt(c))return fe(c),!0;const M=ee(c.nodeName);if(Ee(T.uponSanitizeElement,c,{tagName:M,allowedTags:Q}),W&&c.hasChildNodes()&&!mo(c.firstElementChild)&&se(/<[/\w!]/g,c.innerHTML)&&se(/<[/\w!]/g,c.textContent)||c.nodeType===Xe.progressingInstruction||W&&c.nodeType===Xe.comment&&se(/<[/\w]/g,c.data))return fe(c),!0;if(!(we.tagCheck instanceof Function&&we.tagCheck(M))&&(!Q[M]||Ie[M])){if(!Ie[M]&&go(M)&&(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,M)||j.tagNameCheck instanceof Function&&j.tagNameCheck(M)))return!1;if(Kt&&!Ve[M]){const U=S(c)||c.parentNode,oe=b(c)||c.childNodes;if(oe&&U){const Y=oe.length;for(let ie=Y-1;ie>=0;--ie){const Ce=E(oe[ie],!0);Ce.__removalCount=(c.__removalCount||0)+1,U.insertBefore(Ce,y(c))}}}return fe(c),!0}return c instanceof u&&!Qa(c)||(M==="noscript"||M==="noembed"||M==="noframes")&&se(/<\/no(script|embed|frames)/i,c.innerHTML)?(fe(c),!0):($&&c.nodeType===Xe.text&&(x=c.textContent,mt([v,N,F],U=>{x=Qe(x,U," ")}),c.textContent!==x&&(Ge(t.removed,{element:c.cloneNode()}),c.textContent=x)),Ee(T.afterSanitizeElements,c,null),!1)},ho=function(c,x,M){if(to&&(x==="id"||x==="name")&&(M in n||M in Ga))return!1;if(!(nt&&!et[x]&&se(De,x))){if(!(tt&&se(ye,x))){if(!(we.attributeCheck instanceof Function&&we.attributeCheck(x,c))){if(!Z[x]||et[x]){if(!(go(c)&&(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,c)||j.tagNameCheck instanceof Function&&j.tagNameCheck(c))&&(j.attributeNameCheck instanceof RegExp&&se(j.attributeNameCheck,x)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(x,c))||x==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,M)||j.tagNameCheck instanceof Function&&j.tagNameCheck(M))))return!1}else if(!Gt[x]){if(!se(gt,Qe(M,Ae,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&c!=="script"&&Mr(M,"data:")===0&&ro[c])){if(!(ot&&!se(ke,Qe(M,Ae,"")))){if(M)return!1}}}}}}}return!0},go=function(c){return c!=="annotation-xml"&&_t(c,Wt)},yo=function(c){Ee(T.beforeSanitizeAttributes,c,null);const{attributes:x}=c;if(!x||Xt(c))return;const M={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0};let U=x.length;for(;U--;){const oe=x[U],{name:Y,namespaceURI:ie,value:Ce}=oe,Fe=ee(Y),Jt=Ce;let ne=Y==="value"?Jt:Nr(Jt);if(M.attrName=Fe,M.attrValue=ne,M.keepAttr=!0,M.forceKeepAttr=void 0,Ee(T.uponSanitizeAttribute,c,M),ne=M.attrValue,no&&(Fe==="id"||Fe==="name")&&(ze(Y,c),ne=qa+ne),W&&se(/((--!?|])>)|<\/(style|title|textarea)/i,ne)){ze(Y,c);continue}if(Fe==="attributename"&&_t(ne,"href")){ze(Y,c);continue}if(M.forceKeepAttr)continue;if(!M.keepAttr){ze(Y,c);continue}if(!B&&se(/\/>/i,ne)){ze(Y,c);continue}$&&mt([v,N,F],xo=>{ne=Qe(ne,xo," ")});const ko=ee(c.nodeName);if(!ho(ko,Fe,ne)){ze(Y,c);continue}if(w&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ie)switch(m.getAttributeType(ko,Fe)){case"TrustedHTML":{ne=w.createHTML(ne);break}case"TrustedScriptURL":{ne=w.createScriptURL(ne);break}}if(ne!==Jt)try{ie?c.setAttributeNS(ie,Y,ne):c.setAttribute(Y,ne),Xt(c)?fe(c):Dn(t.removed)}catch{ze(Y,c)}}Ee(T.afterSanitizeAttributes,c,null)},Za=function R(c){let x=null;const M=po(c);for(Ee(T.beforeSanitizeShadowDOM,c,null);x=M.nextNode();)Ee(T.uponSanitizeShadowNode,x,null),fo(x),yo(x),x.content instanceof a&&R(x.content);Ee(T.afterSanitizeShadowDOM,c,null)};return t.sanitize=function(R){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,M=null,U=null,oe=null;if(Qt=!R,Qt&&(R="<!-->"),typeof R!="string"&&!mo(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(!t.isSupported)return R;if(X||Yt(c),t.removed=[],typeof R=="string"&&(rt=!1),rt){if(R.nodeName){const Ce=ee(R.nodeName);if(!Q[Ce]||Ie[Ce])throw Ze("root node is forbidden and cannot be sanitized in-place")}}else if(R instanceof l)x=uo("<!---->"),M=x.ownerDocument.importNode(R,!0),M.nodeType===Xe.element&&M.nodeName==="BODY"||M.nodeName==="HTML"?x=M:x.appendChild(M);else{if(!J&&!$&&!H&&R.indexOf("<")===-1)return w&&yt?w.createHTML(R):R;if(x=uo(R),!x)return J?null:yt?z:""}x&&G&&fe(x.firstChild);const Y=po(rt?R:x);for(;U=Y.nextNode();)fo(U),yo(U),U.content instanceof a&&Za(U.content);if(rt)return R;if(J){if(Me)for(oe=C.call(x.ownerDocument);x.firstChild;)oe.appendChild(x.firstChild);else oe=x;return(Z.shadowroot||Z.shadowrootmode)&&(oe=A.call(r,oe,!0)),oe}let ie=H?x.outerHTML:x.innerHTML;return H&&Q["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&se(Pn,x.ownerDocument.doctype.name)&&(ie="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
58
|
-
`+ie),$&&mt([v,N,F],Ce=>{ie=Qe(ie,Ce," ")}),w&&yt?w.createHTML(ie):ie},t.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(R),X=!0},t.clearConfig=function(){_e=null,X=!1},t.isValidAttribute=function(R,c,x){_e||Yt({});const M=ee(R),U=ee(c);return ho(M,U,x)},t.addHook=function(R,c){typeof c=="function"&&Ge(T[R],c)},t.removeHook=function(R,c){if(c!==void 0){const x=Tr(T[R],c);return x===-1?void 0:Ar(T[R],x,1)[0]}return Dn(T[R])},t.removeHooks=function(R){T[R]=[]},t.removeAllHooks=function(){T=Fn()},t}var qr=Hn();function Un(){return{parseMarkdown:t=>{if(!t||typeof t!="string")return"";const n=ln(t),r=V.parse(n,{async:!1,breaks:!0,gfm:!0});return qr.sanitize(r,{ALLOWED_TAGS:["p","br","strong","em","b","i","code","pre","ul","ol","li","h1","h2","h3","h4","h5","h6","a","blockquote","span","div","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","target","rel","data-mention-id","data-mention-type"],ALLOW_UNKNOWN_PROTOCOLS:!1,FORBID_ATTR:["onerror","onload","onclick","onmouseover"],KEEP_CONTENT:!0})}}}function vr(){let o=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:p}=a;return u-l-p<i}function r(a){a&&(s(),o=new MutationObserver(()=>{(a.scrollTop===0||n(a))&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}),o.observe(a,{childList:!0,subtree:!0}))}function s(){o&&(o.disconnect(),o=null)}return e.onUnmounted(()=>{s()}),{scrollToBottom:t,setupAutoScroll:r,cleanupAutoScroll:s}}function jr(){const o=Te(),t=e.computed(()=>o.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 o.retry(),clearError:()=>{o.clearError()}}}function vt(){const o=Te(),t=e.computed(()=>o.pageContext);function n(a){o.setPageContext(a)}function r(){o.setPageContext(null)}function s(a){const i=o.pageContext;i&&o.setPageContext({...i,...a,metadata:{...i.metadata,...a.metadata}})}return{context:t,setContext:n,clearContext:r,updateContext:s}}const me=[],qn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const o=q();return(o==null?void 0:o.defaultSuggestions)||[]}};function Wr(){me.length=0;const o=q();o!=null&&o.suggestionProviders&&me.push(...o.suggestionProviders),me.push(qn)}function Kr(o,t){const n=[...me].sort((r,s)=>(s.priority||0)-(r.priority||0));for(const r of n)if(r.matcher&&r.matcher(o,t)||r.routes&&r.routes.some(a=>a.endsWith("*")?o.startsWith(a.slice(0,-1)):o===a||o.startsWith(a+"/")))return r;return qn}function vn(o,t){me.length===0&&Wr();const n=Kr(o,t),r=t||{pageType:"default",routePath:o};return n.extractContext&&(r.metadata={...r.metadata,...n.extractContext(o)}),n.getSuggestions(r)||[]}function Gr(o){const t=me.findIndex(n=>n.id===o.id);if(t>=0)me[t]=o;else{const n=me.findIndex(r=>r.id==="default");n>=0?me.splice(n,0,o):me.push(o)}}const Qr=Gr;function jt(){const{context:o}=vt(),t=Te(),n=e.computed(()=>{var u;if(t.quota.remaining===0){const p=q();return(p==null?void 0:p.enableSupportMode)!==!1?[{id:"contact-support-quota",title:te("contactSupport"),description:te("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[]}const a=((u=o.value)==null?void 0:u.routePath)||(typeof window<"u"?window.location.pathname:"/"),i=vn(a,o.value)||[],l=q();return l!=null&&l.can?i.filter(p=>!(p.permission&&!l.can(p.permission))):i}),r=e.computed(()=>o.value!==null&&o.value.pageType!=="default");function s(a){return typeof a.prompt=="function"?a.prompt(o.value||{pageType:"default"}):a.prompt}return{suggestions:n,hasContextualSuggestions:r,resolvePrompt:s}}function Zr(o,t){const{setContext:n,clearContext:r,updateContext:s}=vt();function a(){if(!t)return{};const l={};for(const[u,p]of Object.entries(t))l[u]=e.isRef(p)?p.value:p;return l}function i(){const l={pageType:o,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return e.onMounted(()=>{i()}),e.onUnmounted(()=>{r()}),t&&e.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function Yr(o){const t=o.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 Xr(o,t){const n=o.key.toLowerCase();if(t.mod){const p=navigator.platform.toUpperCase().indexOf("MAC")>=0||navigator.userAgent.toUpperCase().indexOf("MAC")>=0?o.metaKey:o.ctrlKey,d=t.shift?o.shiftKey:!o.shiftKey,h=t.alt?o.altKey:!o.altKey;return n===t.key&&p&&d&&h}const r=t.meta?o.metaKey:!o.metaKey,s=t.ctrl?o.ctrlKey:!o.ctrlKey,a=t.shift?o.shiftKey:!o.shiftKey,i=t.alt?o.altKey:!o.altKey;let l=r&&s&&a&&i;return(t.meta&&!t.ctrl||!t.meta&&t.ctrl)&&(l=(o.metaKey||o.ctrlKey)&&a&&i),n===t.key&&l}function jn(o){const{onToggle:t,enabled:n=!0}=o,r=e.ref(!1),s=o.shortcut!==void 0?o.shortcut:he("keyboardShortcut")??"mod+g";if(s===null)return{isActive:r};const a=Yr(s);function i(l){if(!n)return;const u=l.target,p=u.tagName==="INPUT"||u.tagName==="TEXTAREA",d=u.isContentEditable,h=u.closest("[data-ai-input]");if(!((p||d)&&!h)&&Xr(l,a)){l.preventDefault(),l.stopPropagation();const g=q();if(g!=null&&g.canToggle&&!g.canToggle())return;r.value=!r.value,t()}}return e.onMounted(()=>{window.addEventListener("keydown",i,!0)}),e.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:r}}function Jr(o){const t=Te();return jn({onToggle:()=>{o?o.value=!o.value:t.showChat=!t.showChat}})}function es(o,t){const n=e.ref(te("loadingText"));let r=[];function s(){return[te("loadingText"),te("analyzingText"),te("craftingText")]}function a(){return[0,2e3,5e3]}function i(){r.forEach(p=>clearTimeout(p)),r=[]}function l(){i();const p=t==null?void 0:t(),d=(p==null?void 0:p.messages)??s();n.value=d[0]||te("loadingText")}function u(){i();const p=t==null?void 0:t(),d=(p==null?void 0:p.messages)??s(),h=(p==null?void 0:p.intervals)??a();n.value=d[0]||te("loadingText");let g=0;for(let m=1;m<d.length;m++){g+=h[m]||2e3;const f=m,E=window.setTimeout(()=>{o()&&(n.value=d[f])},g);r.push(E)}}return e.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:u,resetLoadingText:l,clearLoadingTextTimers:i}}function ts(o){const{getHistoryLength:t,getStoreLimit:n,getConfig:r,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=o,l=e.ref({showWarning:!1,isReached:!1,pendingMessage:null}),u=e.computed(()=>{var S;return((S=r())==null?void 0:S.limit)??n()}),p=e.computed(()=>{var S;return((S=r())==null?void 0:S.showWarningAt)??u.value-2}),d=e.computed(()=>Math.max(0,u.value-t())),h=e.computed(()=>d.value<=u.value-p.value&&d.value>0),g=e.computed(()=>d.value===0),m=e.computed(()=>{var S,w;return l.value.isReached||g.value?((S=s())==null?void 0:S.historyLimitReachedTitle)??"Chat Limit Reached":((w=s())==null?void 0:w.historyLimitWarningTitle)??"Approaching Chat Limit"}),f=e.computed(()=>{var S,w,z,O;return l.value.isReached||g.value?((S=r())==null?void 0:S.limitMessage)??((w=s())==null?void 0:w.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":((z=r())==null?void 0:z.warningMessage)??((O=s())==null?void 0:O.historyLimitWarningMessage)??`You have ${d.value} message${d.value===1?"":"s"} remaining in this conversation.`});function E(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function k(){l.value.showWarning=!1;const S=r();if(S!=null&&S.onLimitReached&&!await S.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 y(){return g.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(h.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function b(S){l.value.pendingMessage=S}return{showHistoryLimitWarning:e.computed(()=>l.value.showWarning),historyLimitReached:e.computed(()=>l.value.isReached),historyLimit:u,remainingMessages:d,historyLimitDialogTitle:m,historyLimitDialogMessage:f,dismissHistoryLimitWarning:E,handleHistoryLimitAction:k,checkHistoryLimit:y,setPendingMessage:b}}function ns(){const o=Te(),t=e.ref([]),n=e.ref(!1),r=e.ref(0),s=he("maxAttachments")||5,a=he("maxFileSize")||10*1024*1024,i=he("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=e.computed(()=>t.value.length>0),u=e.computed(()=>t.value.some(C=>C.uploading)),p=e.computed(()=>t.value.length<s);function d(C){return(C.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(C.name)}function h(C){if(C==null)return"";const D=typeof C=="string"?parseInt(C,10):C;return Number.isNaN(D)?"":D>=1024*1024?`${(D/(1024*1024)).toFixed(1)} MB`:D>=1024?`${Math.round(D/1024)} KB`:`${D} B`}function g(C){var F;const D=crypto.randomUUID(),A=C.type.startsWith("image/")?URL.createObjectURL(C):void 0,T=q(),v=!!((F=T==null?void 0:T.endpoints)!=null&&F.uploadFile),N={id:D,name:C.name,type:C.type,size:C.size,uploading:v,progress:v?0:100,previewUrl:A};t.value.push(N),v&&m(C,D)}async function m(C,D){try{const A=await o.uploadFile(C),T=t.value.findIndex(v=>v.id===D);if(T===-1)return;if(A){const v=t.value[T].previewUrl;t.value[T]={...t.value[T],id:A.id||D,url:A.url,extractedText:A.extractedText,uploading:!1,progress:100,previewUrl:v||A.previewUrl}}else f(D)}catch{f(D)}}function f(C){const D=t.value.findIndex(T=>T.id===C);if(D===-1)return;const[A]=t.value.splice(D,1);A!=null&&A.previewUrl&&URL.revokeObjectURL(A.previewUrl)}function E(){t.value.forEach(C=>{C.previewUrl&&URL.revokeObjectURL(C.previewUrl)}),t.value=[]}function k(){return t.value.filter(C=>!C.uploading).map(C=>({id:C.id,name:C.name,url:C.url,type:C.type,size:C.size}))}function y(C){if(!C)return;const D=Array.from(C);for(const A of D){if(t.value.length>=s)break;A.size>a||g(A)}}function b(C){var D;return Array.from(((D=C.dataTransfer)==null?void 0:D.types)||[]).includes("Files")}function S(C){b(C)&&(r.value+=1,n.value=!0)}function w(C){b(C)||C.preventDefault()}function z(C){b(C)&&(r.value=Math.max(0,r.value-1),r.value===0&&(n.value=!1))}function O(C){var D;b(C)&&(r.value=0,n.value=!1,y(((D=C.dataTransfer)==null?void 0:D.files)||null))}function K(C){const D=C.target,A=D.files;A&&A.length&&y(A),D.value=""}return e.onBeforeUnmount(()=>{E()}),{attachments:t,isDraggingFiles:n,hasAttachments:l,isUploading:u,canAddMore:p,acceptedFileTypes:i,isImage:d,formatFileSize:h,removeAttachment:f,clearAttachments:E,buildPayload:k,processFiles:y,handleFileSelect:K,handleDragEnter:S,handleDragOver:w,handleDragLeave:z,handleDrop:O}}function os(o,t,n){const r=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 p(E){const k=n();if(!k)return;const y=k.selectionStart,b=cn(E,y);i.value=b,b.inMention&&b.query.length>=0?d(b.query):(r.value=!1,s.value=[])}async function d(E){const k=pn();if(k.length===0){r.value=!1;return}const y=[];for(const b of k)try{const S=await b.search(E);y.push(...S.map(w=>({...w,type:b.type})))}catch(S){console.warn(`Mention provider ${b.type} failed:`,S)}s.value=y.slice(0,10),r.value=y.length>0,a.value=0}function h(E){const{startPos:k}=i.value,y=o(),b=n(),S=y.slice(0,k),w=y.slice((b==null?void 0:b.selectionStart)||k),z=E.name||E.label||E.title||E.id;t(`${S}@${z} ${w}`),l.value.push({id:E.id,name:z,type:E.type,metadata:E.attributes}),r.value=!1,s.value=[],setTimeout(()=>{const O=n();O==null||O.focus();const K=S.length+z.length+2;O==null||O.setSelectionRange(K,K)},0)}function g(E){if(!r.value||s.value.length===0)return!1;if(E.key==="ArrowDown")return E.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(E.key==="ArrowUp")return E.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(E.key==="Enter"||E.key==="Tab"){E.preventDefault();const k=s.value[a.value];return k&&h(k),!0}return E.key==="Escape"?(E.preventDefault(),r.value=!1,!0):!1}function m(){l.value=[]}function f(){return[...l.value]}return{showMentions:r,mentionItems:s,selectedMentionIndex:a,mentionProviders:u,checkForMentions:p,handleMentionSelect:h,handleMentionKeyDown:g,clearMentions:m,getMentions:f}}function rs(o,t,n,r,s){const a=e.ref(!1),i=e.ref(-1),l=e.ref(null);function u(){setTimeout(()=>{const m=l.value;if(!m)return;const f=m.querySelector(`li:nth-child(${i.value+1})`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function p(m){const f=o();if(!a.value||f.length===0)return!1;if(m.key==="ArrowDown")return m.preventDefault(),i.value=Math.min(i.value+1,f.length-1),u(),!0;if(m.key==="ArrowUp")return m.preventDefault(),i.value=Math.max(i.value-1,0),u(),!0;if(m.key==="Enter"&&i.value>=0){m.preventDefault();const E=f[i.value];return E&&d(E),!0}return m.key==="Escape"?(m.preventDefault(),a.value=!1,i.value=-1,!0):!1}function d(m){s(m),a.value=!1,i.value=-1}function h(){const m=r(),f=t(),E=n(),k=o();m&&!f&&E&&k.length>0?a.value=!0:a.value=!1}function g(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:p,handleSuggestionClick:d,updateSuggestionsVisibility:h,hideSuggestions:g}}function ss(o,t=300){function n(){const r=o();if(!r)return;r.style.height="auto";const s=Math.min(r.scrollHeight,t);r.style.height=`${s}px`,r.style.overflowY=r.scrollHeight>t?"auto":"hidden"}return e.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const Wn=e.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(o){return(t,n)=>{var r;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",(r=o.ui)==null?void 0:r.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=o.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(o){return(t,n)=>{var r;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(r=o.ui)==null?void 0:r.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=o.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(o,{emit:t}){const n=o,r=e.computed(()=>n.ui||{}),s=t,a=e.ref(n.selectedIndex);e.watch(()=>n.selectedIndex,k=>{a.value=k}),e.watch(a,k=>{s("update:selectedIndex",k)});const i=e.computed(()=>{const k={};return n.items.forEach(y=>{const b=y.type||"default";k[b]||(k[b]=[]),k[b].push(y)}),k});function l(k){return n.providers.find(y=>y.type===k)||dn(k)}function u(k){const y=l(k);return(y==null?void 0:y.label)||k.charAt(0).toUpperCase()+k.slice(1)+"s"}function p(k,y){let b=0;const S=Object.keys(i.value);for(const w of S){if(w===k)return b+y;b+=i.value[w].length}return b}function d(k){s("select",k)}function h(k){a.value=k,s("update:selectedIndex",k)}function g(k){const y=l(k.type);return At(k,y)}function m(k){const y=l(k.type);return un(k,y)}function f(k){const y={employee:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",job:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",candidate:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",project:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400",default:"bg-primary/10 text-primary"};return y[k]||y.default}function E(k){return k.split(" ").map(y=>y[0]).join("").slice(0,2).toUpperCase()}return(k,y)=>o.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-60 overflow-y-auto z-50",r.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["p-2",r.value.container])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(b,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:S},[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",r.value.groupHeader])},e.toDisplayString(u(S)),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(w,z)=>(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",[r.value.item,{[r.value.itemSelected||"bg-primary/10"]:p(S,z)===a.value,"hover:bg-gray-50 dark:hover:bg-gray-700":p(S,z)!==a.value}]]),onClick:O=>d(w),onMouseenter:O=>h(p(S,z))},[e.renderSlot(k.$slots,"item-icon",{item:w,type:S},()=>[e.createElementVNode("span",{class:e.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[r.value.itemIcon,f(w.type)]])},e.toDisplayString(E(g(w))),3)]),e.createElementVNode("div",{class:e.normalizeClass(["flex-1 min-w-0",r.value.itemContent])},[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",r.value.itemName])},e.toDisplayString(g(w)),3),m(w)?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",r.value.itemSubtitle])},e.toDisplayString(m(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(o,{emit:t}){const n=o,r=t,s=u=>{var d;return(d=n.texts)!=null&&d[u]?n.texts[u]:te({copyToClipboard:"copyToClipboard",copied:"copied"}[u])},a=e.computed(()=>n.ui||{}),i=e.ref(!1);async function l(){try{await navigator.clipboard.writeText(n.message.message),i.value=!0,r("copy",n.message),setTimeout(()=>{i.value=!1},2e3)}catch(u){console.error("Failed to copy:",u)}}return(u,p)=>(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"},[...p[1]||(p[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,[...p[0]||(p[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 group-hover:opacity-0 transition-opacity"},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(o,{emit:t}){const n=o,r=t,s=y=>{var S;return(S=n.texts)!=null&&S[y]?n.texts[y]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[y]||y},a=e.computed(()=>n.ui||{}),{parseMarkdown:i}=Un(),l=e.ref(!1),u=e.computed(()=>n.message.attachments??[]),p=e.computed(()=>u.value.length>0),d=e.computed(()=>{if(n.message.role!=="user")return!1;const y=n.message.message||"",b=y.split(`
|
|
59
|
-
`).length;return
|
|
60
|
-
`),i(y)}return n.message.message});function k(y){r("copy",y)}return(y,b)=>{var S;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":o.message.role==="user","flex justify-start":o.message.role==="assistant"}]])},[o.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])},[o.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&&d.value}]])},e.toDisplayString(o.message.message),3)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",a.value.showMoreButton]),onClick:h},e.toDisplayString(l.value?s("showLess"):s("showMore")),3)):e.createCommentVNode("",!0),p.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&&g(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(f(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])},[m.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:m.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-4 py-3 shadow-sm rounded-2xl transition-all duration-200 max-w-[85%]",a.value.assistantBubble])},[o.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(((S=o.texts)==null?void 0:S.loadingText)||o.loadingText),1)],2)):o.message.message?(e.openBlock(),e.createElementBlock("div",{key:1,id:o.message.id,class:e.normalizeClass(["text-sm text-gray-700 dark:text-gray-200 leading-relaxed",a.value.content]),innerHTML:E.value},null,10,bs)):e.createCommentVNode("",!0),!o.message.loading&&p.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&&g(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(f(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)),o.message.role==="assistant"&&!o.message.loading&&!o.message.streaming&&o.showActions?(e.openBlock(),e.createBlock(Gn,{key:2,message:o.message,class:e.normalizeClass(["absolute top-0 left-0",a.value.actionsContainer]),onCopy:k},null,8,["message","class"])):e.createCommentVNode("",!0)],2)}}}),Qn=(o,t)=>{const n=o.__vccOpts||o;for(const[r,s]of t)n[r]=s;return n},Zn=Qn(Rs,[["__scopeId","data-v-d045bee3"]]),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(o){return(t,n)=>{var r;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",o.ui.attachmentsContainer])},[e.createElementVNode("p",Bs,e.toDisplayString(((r=o.texts)==null?void 0:r.attachedFiles)||"Attached files"),1),e.createElementVNode("ul",Ls,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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",o.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",o.ui.attachmentThumbnail])},[o.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(o.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",o.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(o,{expose:t}){const n=e.ref(null);return t({dropdownRef:n}),(r,s)=>(e.openBlock(),e.createBlock(e.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"dropdownRef",ref: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",o.ui.suggestionsDropdown])},[e.createElementVNode("ul",Hs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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",[o.ui.suggestionItem,{[o.ui.suggestionItemSelected||"bg-primary/10"]:i===o.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":i!==o.selectedIndex}]]),onClick:l=>r.$emit("select",a),onMouseenter:l=>r.$emit("hover",i)},[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(o){const t=o,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(r,s)=>{var a,i,l;return e.openBlock(),e.createElementBlock("div",Gs,[o.showSupportModeToggle&&!o.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",o.ui.supportToggle]),title:((a=o.texts)==null?void 0:a.toggleSupportMode)||"Toggle support mode",onClick:s[0]||(s[0]=u=>r.$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),o.showSupportModeToggle&&o.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",o.ui.supportBadge]),title:((i=o.texts)==null?void 0:i.exitSupportMode)||"Exit support mode",onClick:s[1]||(s[1]=u=>r.$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=o.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:!o.canSend&&!o.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=>r.$emit("click"),["prevent"]))},[o.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"],oa=["title"],ra={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(o,{expose:t,emit:n}){const r=o,s=e.computed(()=>r.ui||{}),a=n,i=e.ref(r.modelValue),l=e.ref(null),u=e.ref(null),p=e.ref(!1),d=ns(),h=os(()=>i.value,A=>{i.value=A},()=>l.value),g=rs(()=>r.suggestions,()=>r.hasHistory,()=>p.value,()=>i.value,A=>{a("suggestion-select",A),e.nextTick(()=>{var T;return(T=l.value)==null?void 0:T.focus()})}),{adjustTextareaHeight:m}=ss(()=>l.value),f=e.computed(()=>r.supportRequestMode?r.supportPlaceholder:r.placeholder),E=e.computed(()=>r.showSupportModeToggle?r.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),k=e.computed(()=>{var T;return(((T=i.value)==null?void 0:T.trim())??"").length>=r.minLength?!0:d.hasAttachments.value}),y=e.computed(()=>!r.disabled&&!r.sending&&k.value&&!d.isUploading.value);e.watch(()=>r.modelValue,A=>{i.value=A,e.nextTick(m)}),e.watch(i,A=>{a("update:modelValue",A),e.nextTick(m),h.checkForMentions(A),g.updateSuggestionsVisibility()}),e.watch(()=>r.suggestions,()=>{g.updateSuggestionsVisibility()});function b(){m()}function S(A){if(!h.handleMentionKeyDown(A)&&!g.handleSuggestionKeyDown(A)&&A.key==="Enter"){if(A.shiftKey)return;!r.sending&&y.value&&(A.preventDefault(),w())}}function w(){if(!y.value)return;const A=d.buildPayload(),T=i.value.trim(),v=h.getMentions();a("submit",{message:T,attachments:A,mentions:v,isSupportRequest:r.supportRequestMode}),i.value="",d.clearAttachments(),h.clearMentions(),e.nextTick(m)}function z(){r.sending?a("cancel"):y.value&&w()}function O(){var A;r.disabled||r.sending||d.canAddMore.value&&((A=u.value)==null||A.click())}function K(A){g.handleSuggestionClick(A)}function C(){p.value=!0,g.updateSuggestionsVisibility()}function D(){p.value=!1,setTimeout(()=>{g.hideSuggestions(),h.showMentions.value=!1},200)}return t({focus:()=>{var A;return(A=l.value)==null?void 0:A.focus()}}),e.onMounted(()=>{e.nextTick(m)}),(A,T)=>{var v;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",s.value.root]),onDragenter:T[6]||(T[6]=e.withModifiers((...N)=>e.unref(d).handleDragEnter&&e.unref(d).handleDragEnter(...N),["prevent"])),onDragover:T[7]||(T[7]=e.withModifiers((...N)=>e.unref(d).handleDragOver&&e.unref(d).handleDragOver(...N),["prevent"])),onDragleave:T[8]||(T[8]=e.withModifiers((...N)=>e.unref(d).handleDragLeave&&e.unref(d).handleDragLeave(...N),["prevent"])),onDrop:T[9]||(T[9]=e.withModifiers((...N)=>e.unref(d).handleDrop&&e.unref(d).handleDrop(...N),["prevent"]))},[e.createElementVNode("form",{class:e.normalizeClass(s.value.form),onSubmit:e.withModifiers(w,["prevent"])},[e.createElementVNode("div",ta,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:u,type:"file",class:"hidden",multiple:"",accept:e.unref(d).acceptedFileTypes,onChange:T[0]||(T[0]=(...N)=>e.unref(d).handleFileSelect&&e.unref(d).handleFileSelect(...N))},null,40,na),e.unref(d).hasAttachments.value?(e.openBlock(),e.createBlock(Fs,{key:0,attachments:e.unref(d).attachments.value,ui:s.value,texts:o.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",s.value.inputContainer])},[e.unref(g).showSuggestions.value&&o.suggestions.length>0?(e.openBlock(),e.createBlock(Ks,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:o.suggestions,"selected-index":e.unref(g).selectedSuggestionIndex.value,ui:s.value,onSelect:K,onHover:T[1]||(T[1]=N=>e.unref(g).selectedSuggestionIndex.value=N)},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(h).showMentions.value&&e.unref(h).mentionItems.value.length>0?(e.openBlock(),e.createBlock(Kn,{key:0,items:e.unref(h).mentionItems.value,"selected-index":e.unref(h).selectedMentionIndex.value,providers:e.unref(h).mentionProviders.value,onSelect:e.unref(h).handleMentionSelect,"onUpdate:selectedIndex":T[2]||(T[2]=N=>e.unref(h).selectedMentionIndex.value=N)},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",[s.value.inputWrapper,{"border-primary shadow-primary/30":p.value||e.unref(d).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!p.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",s.value.attachButton]),title:((v=o.texts)==null?void 0:v.attachFiles)||"Attach files",onClick:O},[...T[10]||(T[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,oa),e.createElementVNode("div",ra,[e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:l,"onUpdate:modelValue":T[3]||(T[3]=N=>i.value=N),rows:"1","data-ai-input":"",placeholder:f.value,disabled:o.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",s.value.textarea]),style:e.normalizeStyle(E.value),onInput:b,onKeydown:S,onFocus:C,onBlur:D},null,46,sa),[[e.vModelText,i.value]])]),e.createVNode(ea,{sending:o.sending,"can-send":y.value,"support-request-mode":o.supportRequestMode,"show-support-mode-toggle":o.showSupportModeToggle,ui:s.value,texts:o.texts,onToggleSupportMode:T[4]||(T[4]=N=>A.$emit("toggle-support-mode")),onClick:z},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),e.renderSlot(A.$slots,"context-link",{},()=>[o.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",s.value.contextLink]),onClick:T[5]||(T[5]=N=>A.$emit("context-link-click"))},e.toDisplayString(o.contextLinkText),3)])):e.createCommentVNode("",!0)])])],34)],34)}}}),ia=["onClick"],Xn=e.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(o,{emit:t}){const n=o,r=t,s=g=>{var f;return(f=n.texts)!=null&&f[g]?n.texts[g]:te({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[g])},a=e.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=jt();function u(g){const m={...g,prompt:l(g)};r("item-click",m)}function p(g){return g.gradientClass?g.gradientClass:g.className?g.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function d(g){const m=g.category||"default",f={hr:"bg-blue-100 dark:bg-blue-900/30",finance:"bg-green-100 dark:bg-green-900/30",analytics:"bg-purple-100 dark:bg-purple-900/30",support:"bg-amber-100 dark:bg-amber-900/30",default:"bg-primary/10"};return f[m]||f.default}function h(g){const m=g.category||"default",f={hr:"text-blue-600 dark:text-blue-400",finance:"text-green-600 dark:text-green-400",analytics:"text-purple-600 dark:text-purple-400",support:"text-amber-600 dark:text-amber-400",default:"text-primary"};return f[m]||f.default}return(g,m)=>(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])},[m[0]||(m[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),(f,E)=>(e.openBlock(),e.createElementBlock("button",{key:f.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,p(f)]]),onClick:k=>u(f)},[e.createElementVNode("div",{class:e.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,d(f)]])},[f.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.icon),{key:0,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]])},null,8,["class"])):(e.openBlock(),e.createElementBlock("svg",{key:1,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...m[1]||(m[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(f.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},e.toDisplayString(f.description),3)],10,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(o){const t=o,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"}),r=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,p,d,h,g;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=o.ui)==null?void 0:i.header])},[e.createElementVNode("div",la,[o.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},[o.showNewChatButton&&o.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=o.ui)==null?void 0:l.newChatButton]),onClick:a[0]||(a[0]=m=>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(o.t("newChat")),1)],2)):(e.openBlock(),e.createElementBlock("span",ca,e.toDisplayString(o.t("keyboardShortcutHint")),1))],64))]),!o.isSetupMode&&(o.showMessageCount||o.showQuota)?(e.openBlock(),e.createElementBlock("div",da,[o.showMessageCount&&o.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=o.ui)==null?void 0:u.messageCountBadge])},[(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-3.5 h-3.5",r.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(o.messageCount),1),a[7]||(a[7]=e.createElementVNode("span",{class:"text-gray-400 dark:text-gray-500"},"/",-1)),e.createTextVNode(e.toDisplayString(o.messageLimit),1)])],2)],2)):e.createCommentVNode("",!0),o.showMessageCount&&o.hasHistory&&o.showQuota&&o.quota.remaining>=0?(e.openBlock(),e.createElementBlock("span",pa," • ")):e.createCommentVNode("",!0),o.showQuota?e.renderSlot(s.$slots,"quota",{key:2},()=>{var m;return[o.quota.remaining>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 text-xs",(m=o.ui)==null?void 0:m.quotaDisplay])},[e.createElementVNode("span",ma,e.toDisplayString(o.quota.remaining),1),e.createElementVNode("span",fa,e.toDisplayString(o.t("quotaRemaining")),1)],2)):o.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(o.t("noQuota")),1)])):e.createCommentVNode("",!0)]}):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1",(p=o.ui)==null?void 0:p.headerActions])},[o.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",(d=o.ui)==null?void 0:d.headerActionButton]),title:o.t("close"),onClick:a[1]||(a[1]=m=>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),o.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",(h=o.ui)==null?void 0:h.headerActionButton]),title:o.t("minimize"),onClick:a[2]||(a[2]=m=>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),o.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",(g=o.ui)==null?void 0:g.headerActionButton]),title:o.isFullscreen?o.t("exitFullscreen"):o.t("fullscreen"),onClick:a[3]||(a[3]=m=>s.$emit("toggle-fullscreen"))},[o.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(o){return(t,n)=>{var r,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(o.t("title")||e.unref(te)("aiName")),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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":o.loadingMessage,onCopy:n[0]||(n[0]=u=>t.$emit("copy",u))},null,8,["message","loading-text"])])),128)),o.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(te)("contactSupport")),1)])])):e.createCommentVNode("",!0),o.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",(r=o.ui)==null?void 0:r.errorContainer])},[e.createElementVNode("span",{class:e.normalizeClass((s=o.ui)==null?void 0:s.errorMessage)},e.toDisplayString(o.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=o.ui)==null?void 0:a.retryButton]),title:o.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(o){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]=r=>t.$emit("copy"))},e.toDisplayString(o.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">'@doderasoftware/restify-ai'</span>
|
|
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:r}){const s=this.parser.parseInline(r),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:r}){const s=xn(t);if(s===null)return r;t=s;let a=`<img src="${t}" alt="${r}"`;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 ue{constructor(t){H(this,"options");H(this,"renderer");H(this,"textRenderer");this.options=t||Be,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 ue(n).parse(t)}static parseInline(t,n){return new ue(n).parseInline(t)}parse(t,n=!0){let r="";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)){r+=u||"";continue}}const i=a;switch(i.type){case"space":{r+=this.renderer.space(i);continue}case"hr":{r+=this.renderer.hr(i);continue}case"heading":{r+=this.renderer.heading(i);continue}case"code":{r+=this.renderer.code(i);continue}case"table":{r+=this.renderer.table(i);continue}case"blockquote":{r+=this.renderer.blockquote(i);continue}case"list":{r+=this.renderer.list(i);continue}case"html":{r+=this.renderer.html(i);continue}case"paragraph":{r+=this.renderer.paragraph(i);continue}case"text":{let l=i,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?r+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u}]}):r+=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 r}parseInline(t,n){n=n||this.renderer;let r="";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)){r+=l||"";continue}}const i=a;switch(i.type){case"escape":{r+=n.text(i);break}case"html":{r+=n.html(i);break}case"link":{r+=n.link(i);break}case"image":{r+=n.image(i);break}case"strong":{r+=n.strong(i);break}case"em":{r+=n.em(i);break}case"codespan":{r+=n.codespan(i);break}case"br":{r+=n.br(i);break}case"del":{r+=n.del(i);break}case"text":{r+=n.text(i);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}}class Ge{constructor(t){H(this,"options");H(this,"block");this.options=t||Be}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?ce.lex:ce.lexInline}provideParser(){return this.block?ue.parse:ue.parseInline}}H(Ge,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class br{constructor(...t){H(this,"defaults",Mt());H(this,"options",this.setOptions);H(this,"parse",this.parseMarkdown(!0));H(this,"parseInline",this.parseMarkdown(!1));H(this,"Parser",ue);H(this,"Renderer",pt);H(this,"TextRenderer",zt);H(this,"Lexer",ce);H(this,"Tokenizer",lt);H(this,"Hooks",Ge);this.use(...t)}walkTokens(t,n){var s,a;let r=[];for(const i of t)switch(r=r.concat(n.call(this,i)),i.type){case"table":{const l=i;for(const u of l.header)r=r.concat(this.walkTokens(u.tokens,n));for(const u of l.rows)for(const p of u)r=r.concat(this.walkTokens(p.tokens,n));break}case"list":{const l=i;r=r.concat(this.walkTokens(l.items,n));break}default:{const l=i;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[l.type]?this.defaults.extensions.childTokens[l.type].forEach(u=>{const p=l[u].flat(1/0);r=r.concat(this.walkTokens(p,n))}):l.tokens&&(r=r.concat(this.walkTokens(l.tokens,n)))}}return r}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(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),r.renderer){const a=this.defaults.renderer||new pt(this.defaults);for(const i in r.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const l=i,u=r.renderer[l],p=a[l];a[l]=(...d)=>{let y=u.apply(a,d);return y===!1&&(y=p.apply(a,d)),y||""}}s.renderer=a}if(r.tokenizer){const a=this.defaults.tokenizer||new lt(this.defaults);for(const i in r.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const l=i,u=r.tokenizer[l],p=a[l];a[l]=(...d)=>{let y=u.apply(a,d);return y===!1&&(y=p.apply(a,d)),y}}s.tokenizer=a}if(r.hooks){const a=this.defaults.hooks||new Ge;for(const i in r.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const l=i,u=r.hooks[l],p=a[l];Ge.passThroughHooks.has(i)?a[l]=d=>{if(this.defaults.async)return Promise.resolve(u.call(a,d)).then(k=>p.call(a,k));const y=u.call(a,d);return p.call(a,y)}:a[l]=(...d)=>{let y=u.apply(a,d);return y===!1&&(y=p.apply(a,d)),y}}s.hooks=a}if(r.walkTokens){const a=this.defaults.walkTokens,i=r.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 ce.lex(t,n??this.defaults)}parser(t,n){return ue.parse(t,n??this.defaults)}parseMarkdown(t){return(r,s)=>{const a={...s},i={...this.defaults,...a},l=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&a.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=t);const u=i.hooks?i.hooks.provideLexer():t?ce.lex:ce.lexInline,p=i.hooks?i.hooks.provideParser():t?ue.parse:ue.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(r):r).then(d=>u(d,i)).then(d=>i.hooks?i.hooks.processAllTokens(d):d).then(d=>i.walkTokens?Promise.all(this.walkTokens(d,i.walkTokens)).then(()=>d):d).then(d=>p(d,i)).then(d=>i.hooks?i.hooks.postprocess(d):d).catch(l);try{i.hooks&&(r=i.hooks.preprocess(r));let d=u(r,i);i.hooks&&(d=i.hooks.processAllTokens(d)),i.walkTokens&&this.walkTokens(d,i.walkTokens);let y=p(d,i);return i.hooks&&(y=i.hooks.postprocess(y)),y}catch(d){return l(d)}}}onError(t,n){return r=>{if(r.message+=`
|
|
57
|
+
Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+le(r.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(r);throw r}}}const Le=new br;function O(o,t){return Le.parse(o,t)}O.options=O.setOptions=function(o){return Le.setOptions(o),O.defaults=Le.defaults,hn(O.defaults),O},O.getDefaults=Mt,O.defaults=Be,O.use=function(...o){return Le.use(...o),O.defaults=Le.defaults,hn(O.defaults),O},O.walkTokens=function(o,t){return Le.walkTokens(o,t)},O.parseInline=Le.parseInline,O.Parser=ue,O.parser=ue.parse,O.Renderer=pt,O.TextRenderer=zt,O.Lexer=ce,O.lexer=ce.lex,O.Tokenizer=lt,O.Hooks=Ge,O.parse=O,O.options,O.setOptions,O.use,O.walkTokens,O.parseInline,ue.parse,ce.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:Er,getPrototypeOf:Cr,getOwnPropertyDescriptor:Sr}=Object;let{freeze:re,seal:de,create:$t}=Object,{apply:Ot,construct:Vt}=typeof Reflect<"u"&&Reflect;re||(re=function(t){return t}),de||(de=function(t){return t}),Ot||(Ot=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),a=2;a<r;a++)s[a-2]=arguments[a];return t.apply(n,s)}),Vt||(Vt=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new t(...r)});const mt=ae(Array.prototype.forEach),Tr=ae(Array.prototype.lastIndexOf),Dn=ae(Array.prototype.pop),Qe=ae(Array.prototype.push),Ar=ae(Array.prototype.splice),ft=ae(String.prototype.toLowerCase),Pt=ae(String.prototype.toString),_t=ae(String.prototype.match),Ze=ae(String.prototype.replace),Mr=ae(String.prototype.indexOf),Nr=ae(String.prototype.trim),pe=ae(Object.prototype.hasOwnProperty),se=ae(RegExp.prototype.test),Ye=Rr(TypeError);function ae(o){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Ot(o,t,r)}}function Rr(o){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Vt(o,n)}}function z(o,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ft;Ln&&Ln(o,null);let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const a=n(s);a!==s&&(Er(t)||(t[r]=a),s=a)}o[s]=!0}return o}function Br(o){for(let t=0;t<o.length;t++)pe(o,t)||(o[t]=null);return o}function ge(o){const t=$t(null);for(const[n,r]of Bn(o))pe(o,n)&&(Array.isArray(r)?t[n]=Br(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=ge(r):t[n]=r);return t}function Xe(o,t){for(;o!==null;){const r=Sr(o,t);if(r){if(r.get)return ae(r.get);if(typeof r.value=="function")return ae(r.value)}o=Cr(o)}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"]),Ht=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"]),Ft=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"]),Lr=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"]),Dr=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"]),Ir=de(/\{\{[\w\W]*|[\w\W]*\}\}/gm),zr=de(/<%[\w\W]*|[\w\W]*%>/gm),$r=de(/\$\{[\w\W]*/gm),Or=de(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vr=de(/^aria-[\-\w]+$/),Vn=de(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pr=de(/^(?:\w+script|data):/i),_r=de(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pn=de(/^html$/i),Hr=de(/^[a-z][.\w]*(-[.\w]+)+$/i);var _n=Object.freeze({__proto__:null,ARIA_ATTR:Vr,ATTR_WHITESPACE:_r,CUSTOM_ELEMENT:Hr,DATA_ATTR:Or,DOCTYPE_NAME:Pn,ERB_EXPR:zr,IS_ALLOWED_URI:Vn,IS_SCRIPT_OR_DATA:Pr,MUSTACHE_EXPR:Ir,TMPLIT_EXPR:$r});const Je={element:1,text:3,progressingInstruction:7,comment:8,document:9},Fr=function(){return typeof window>"u"?null:window},Ur=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Hn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Fn(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fr();const t=N=>Fn(N);if(t.version="3.3.0",t.removed=[],!o||!o.document||o.document.nodeType!==Je.document||!o.Element)return t.isSupported=!1,t;let{document:n}=o;const r=n,s=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:u,NodeFilter:p,NamedNodeMap:d=o.NamedNodeMap||o.MozNamedAttrMap,HTMLFormElement:y,DOMParser:k,trustedTypes:m}=o,f=u.prototype,R=Xe(f,"cloneNode"),h=Xe(f,"remove"),g=Xe(f,"nextSibling"),C=Xe(f,"childNodes"),b=Xe(f,"parentNode");if(typeof i=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let w,I="";const{implementation:V,createNodeIterator:F,createDocumentFragment:E,getElementsByTagName:D}=n,{importNode:A}=r;let S=Hn();t.isSupported=typeof Bn=="function"&&typeof b=="function"&&V&&V.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:j,ERB_EXPR:T,TMPLIT_EXPR:_,DATA_ATTR:De,ARIA_ATTR:ye,IS_SCRIPT_OR_DATA:ke,ATTR_WHITESPACE:Ae,CUSTOM_ELEMENT:Wt}=_n;let{IS_ALLOWED_URI:gt}=_n,Q=null;const xe=z({},[...In,...Ht,...Ft,...Ut,...zn]);let Z=null;const et=z({},[...$n,...qt,...On,...ht]);let W=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}})),Ie=null,tt=null;const we=Object.seal($t(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let nt=!0,ot=!0,rt=!1,B=!0,$=!1,K=!0,U=!1,X=!1,G=!1,J=!1,Me=!1,yt=!1,to=!0,no=!1;const qa="user-content-";let Kt=!0,st=!1,Oe={},Ve=null;const oo=z({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ro=null;const so=z({},["audio","video","img","source","image","track"]);let Gt=null;const ao=z({},["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",be="http://www.w3.org/1999/xhtml";let Pe=be,Qt=!1,Zt=null;const va=z({},[kt,xt,be],Pt);let wt=z({},["mi","mo","mn","ms","mtext"]),bt=z({},["annotation-xml"]);const ja=z({},["title","style","font","a","script"]);let at=null;const Wa=["application/xhtml+xml","text/html"],Ka="text/html";let ee=null,_e=null;const Ga=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(!(_e&&_e===c)){if((!c||typeof c!="object")&&(c={}),c=ge(c),at=Wa.indexOf(c.PARSER_MEDIA_TYPE)===-1?Ka:c.PARSER_MEDIA_TYPE,ee=at==="application/xhtml+xml"?Pt:ft,Q=pe(c,"ALLOWED_TAGS")?z({},c.ALLOWED_TAGS,ee):xe,Z=pe(c,"ALLOWED_ATTR")?z({},c.ALLOWED_ATTR,ee):et,Zt=pe(c,"ALLOWED_NAMESPACES")?z({},c.ALLOWED_NAMESPACES,Pt):va,Gt=pe(c,"ADD_URI_SAFE_ATTR")?z(ge(ao),c.ADD_URI_SAFE_ATTR,ee):ao,ro=pe(c,"ADD_DATA_URI_TAGS")?z(ge(so),c.ADD_DATA_URI_TAGS,ee):so,Ve=pe(c,"FORBID_CONTENTS")?z({},c.FORBID_CONTENTS,ee):oo,Ie=pe(c,"FORBID_TAGS")?z({},c.FORBID_TAGS,ee):ge({}),tt=pe(c,"FORBID_ATTR")?z({},c.FORBID_ATTR,ee):ge({}),Oe=pe(c,"USE_PROFILES")?c.USE_PROFILES:!1,nt=c.ALLOW_ARIA_ATTR!==!1,ot=c.ALLOW_DATA_ATTR!==!1,rt=c.ALLOW_UNKNOWN_PROTOCOLS||!1,B=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$=c.SAFE_FOR_TEMPLATES||!1,K=c.SAFE_FOR_XML!==!1,U=c.WHOLE_DOCUMENT||!1,J=c.RETURN_DOM||!1,Me=c.RETURN_DOM_FRAGMENT||!1,yt=c.RETURN_TRUSTED_TYPE||!1,G=c.FORCE_BODY||!1,to=c.SANITIZE_DOM!==!1,no=c.SANITIZE_NAMED_PROPS||!1,Kt=c.KEEP_CONTENT!==!1,st=c.IN_PLACE||!1,gt=c.ALLOWED_URI_REGEXP||Vn,Pe=c.NAMESPACE||be,wt=c.MATHML_TEXT_INTEGRATION_POINTS||wt,bt=c.HTML_INTEGRATION_POINTS||bt,W=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&io(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$&&(ot=!1),Me&&(J=!0),Oe&&(Q=z({},zn),Z=[],Oe.html===!0&&(z(Q,In),z(Z,$n)),Oe.svg===!0&&(z(Q,Ht),z(Z,qt),z(Z,ht)),Oe.svgFilters===!0&&(z(Q,Ft),z(Z,qt),z(Z,ht)),Oe.mathMl===!0&&(z(Q,Ut),z(Z,On),z(Z,ht))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?we.tagCheck=c.ADD_TAGS:(Q===xe&&(Q=ge(Q)),z(Q,c.ADD_TAGS,ee))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?we.attributeCheck=c.ADD_ATTR:(Z===et&&(Z=ge(Z)),z(Z,c.ADD_ATTR,ee))),c.ADD_URI_SAFE_ATTR&&z(Gt,c.ADD_URI_SAFE_ATTR,ee),c.FORBID_CONTENTS&&(Ve===oo&&(Ve=ge(Ve)),z(Ve,c.FORBID_CONTENTS,ee)),Kt&&(Q["#text"]=!0),U&&z(Q,["html","head","body"]),Q.table&&(z(Q,["tbody"]),delete Ie.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=c.TRUSTED_TYPES_POLICY,I=w.createHTML("")}else w===void 0&&(w=Ur(m,s)),w!==null&&typeof I=="string"&&(I=w.createHTML(""));re&&re(c),_e=c}},lo=z({},[...Ht,...Ft,...Lr]),co=z({},[...Ut,...Dr]),Qa=function(c){let x=b(c);(!x||!x.tagName)&&(x={namespaceURI:Pe,tagName:"template"});const M=ft(c.tagName),q=ft(x.tagName);return Zt[c.namespaceURI]?c.namespaceURI===xt?x.namespaceURI===be?M==="svg":x.namespaceURI===kt?M==="svg"&&(q==="annotation-xml"||wt[q]):!!lo[M]:c.namespaceURI===kt?x.namespaceURI===be?M==="math":x.namespaceURI===xt?M==="math"&&bt[q]:!!co[M]:c.namespaceURI===be?x.namespaceURI===xt&&!bt[q]||x.namespaceURI===kt&&!wt[q]?!1:!co[M]&&(ja[M]||!lo[M]):!!(at==="application/xhtml+xml"&&Zt[c.namespaceURI]):!1},fe=function(c){Qe(t.removed,{element:c});try{b(c).removeChild(c)}catch{h(c)}},ze=function(c,x){try{Qe(t.removed,{attribute:x.getAttributeNode(c),from:x})}catch{Qe(t.removed,{attribute:null,from:x})}if(x.removeAttribute(c),c==="is")if(J||Me)try{fe(x)}catch{}else try{x.setAttribute(c,"")}catch{}},uo=function(c){let x=null,M=null;if(G)c="<remove></remove>"+c;else{const Y=_t(c,/^[\r\n\t ]+/);M=Y&&Y[0]}at==="application/xhtml+xml"&&Pe===be&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const q=w?w.createHTML(c):c;if(Pe===be)try{x=new k().parseFromString(q,at)}catch{}if(!x||!x.documentElement){x=V.createDocument(Pe,"template",null);try{x.documentElement.innerHTML=Qt?I:q}catch{}}const oe=x.body||x.documentElement;return c&&M&&oe.insertBefore(n.createTextNode(M),oe.childNodes[0]||null),Pe===be?D.call(x,U?"html":"body")[0]:U?x.documentElement:oe},po=function(c){return F.call(c.ownerDocument||c,c,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Xt=function(c){return c instanceof y&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof d)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},mo=function(c){return typeof l=="function"&&c instanceof l};function Ee(N,c,x){mt(N,M=>{M.call(t,c,x,_e)})}const fo=function(c){let x=null;if(Ee(S.beforeSanitizeElements,c,null),Xt(c))return fe(c),!0;const M=ee(c.nodeName);if(Ee(S.uponSanitizeElement,c,{tagName:M,allowedTags:Q}),K&&c.hasChildNodes()&&!mo(c.firstElementChild)&&se(/<[/\w!]/g,c.innerHTML)&&se(/<[/\w!]/g,c.textContent)||c.nodeType===Je.progressingInstruction||K&&c.nodeType===Je.comment&&se(/<[/\w]/g,c.data))return fe(c),!0;if(!(we.tagCheck instanceof Function&&we.tagCheck(M))&&(!Q[M]||Ie[M])){if(!Ie[M]&&go(M)&&(W.tagNameCheck instanceof RegExp&&se(W.tagNameCheck,M)||W.tagNameCheck instanceof Function&&W.tagNameCheck(M)))return!1;if(Kt&&!Ve[M]){const q=b(c)||c.parentNode,oe=C(c)||c.childNodes;if(oe&&q){const Y=oe.length;for(let ie=Y-1;ie>=0;--ie){const Ce=R(oe[ie],!0);Ce.__removalCount=(c.__removalCount||0)+1,q.insertBefore(Ce,g(c))}}}return fe(c),!0}return c instanceof u&&!Qa(c)||(M==="noscript"||M==="noembed"||M==="noframes")&&se(/<\/no(script|embed|frames)/i,c.innerHTML)?(fe(c),!0):($&&c.nodeType===Je.text&&(x=c.textContent,mt([j,T,_],q=>{x=Ze(x,q," ")}),c.textContent!==x&&(Qe(t.removed,{element:c.cloneNode()}),c.textContent=x)),Ee(S.afterSanitizeElements,c,null),!1)},ho=function(c,x,M){if(to&&(x==="id"||x==="name")&&(M in n||M in Ga))return!1;if(!(ot&&!tt[x]&&se(De,x))){if(!(nt&&se(ye,x))){if(!(we.attributeCheck instanceof Function&&we.attributeCheck(x,c))){if(!Z[x]||tt[x]){if(!(go(c)&&(W.tagNameCheck instanceof RegExp&&se(W.tagNameCheck,c)||W.tagNameCheck instanceof Function&&W.tagNameCheck(c))&&(W.attributeNameCheck instanceof RegExp&&se(W.attributeNameCheck,x)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(x,c))||x==="is"&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&se(W.tagNameCheck,M)||W.tagNameCheck instanceof Function&&W.tagNameCheck(M))))return!1}else if(!Gt[x]){if(!se(gt,Ze(M,Ae,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&c!=="script"&&Mr(M,"data:")===0&&ro[c])){if(!(rt&&!se(ke,Ze(M,Ae,"")))){if(M)return!1}}}}}}}return!0},go=function(c){return c!=="annotation-xml"&&_t(c,Wt)},yo=function(c){Ee(S.beforeSanitizeAttributes,c,null);const{attributes:x}=c;if(!x||Xt(c))return;const M={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0};let q=x.length;for(;q--;){const oe=x[q],{name:Y,namespaceURI:ie,value:Ce}=oe,He=ee(Y),Jt=Ce;let ne=Y==="value"?Jt:Nr(Jt);if(M.attrName=He,M.attrValue=ne,M.keepAttr=!0,M.forceKeepAttr=void 0,Ee(S.uponSanitizeAttribute,c,M),ne=M.attrValue,no&&(He==="id"||He==="name")&&(ze(Y,c),ne=qa+ne),K&&se(/((--!?|])>)|<\/(style|title|textarea)/i,ne)){ze(Y,c);continue}if(He==="attributename"&&_t(ne,"href")){ze(Y,c);continue}if(M.forceKeepAttr)continue;if(!M.keepAttr){ze(Y,c);continue}if(!B&&se(/\/>/i,ne)){ze(Y,c);continue}$&&mt([j,T,_],xo=>{ne=Ze(ne,xo," ")});const ko=ee(c.nodeName);if(!ho(ko,He,ne)){ze(Y,c);continue}if(w&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ie)switch(m.getAttributeType(ko,He)){case"TrustedHTML":{ne=w.createHTML(ne);break}case"TrustedScriptURL":{ne=w.createScriptURL(ne);break}}if(ne!==Jt)try{ie?c.setAttributeNS(ie,Y,ne):c.setAttribute(Y,ne),Xt(c)?fe(c):Dn(t.removed)}catch{ze(Y,c)}}Ee(S.afterSanitizeAttributes,c,null)},Za=function N(c){let x=null;const M=po(c);for(Ee(S.beforeSanitizeShadowDOM,c,null);x=M.nextNode();)Ee(S.uponSanitizeShadowNode,x,null),fo(x),yo(x),x.content instanceof a&&N(x.content);Ee(S.afterSanitizeShadowDOM,c,null)};return t.sanitize=function(N){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,M=null,q=null,oe=null;if(Qt=!N,Qt&&(N="<!-->"),typeof N!="string"&&!mo(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw Ye("dirty is not a string, aborting")}else throw Ye("toString is not a function");if(!t.isSupported)return N;if(X||Yt(c),t.removed=[],typeof N=="string"&&(st=!1),st){if(N.nodeName){const Ce=ee(N.nodeName);if(!Q[Ce]||Ie[Ce])throw Ye("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof l)x=uo("<!---->"),M=x.ownerDocument.importNode(N,!0),M.nodeType===Je.element&&M.nodeName==="BODY"||M.nodeName==="HTML"?x=M:x.appendChild(M);else{if(!J&&!$&&!U&&N.indexOf("<")===-1)return w&&yt?w.createHTML(N):N;if(x=uo(N),!x)return J?null:yt?I:""}x&&G&&fe(x.firstChild);const Y=po(st?N:x);for(;q=Y.nextNode();)fo(q),yo(q),q.content instanceof a&&Za(q.content);if(st)return N;if(J){if(Me)for(oe=E.call(x.ownerDocument);x.firstChild;)oe.appendChild(x.firstChild);else oe=x;return(Z.shadowroot||Z.shadowrootmode)&&(oe=A.call(r,oe,!0)),oe}let ie=U?x.outerHTML:x.innerHTML;return U&&Q["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&se(Pn,x.ownerDocument.doctype.name)&&(ie="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
58
|
+
`+ie),$&&mt([j,T,_],Ce=>{ie=Ze(ie,Ce," ")}),w&&yt?w.createHTML(ie):ie},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(N),X=!0},t.clearConfig=function(){_e=null,X=!1},t.isValidAttribute=function(N,c,x){_e||Yt({});const M=ee(N),q=ee(c);return ho(M,q,x)},t.addHook=function(N,c){typeof c=="function"&&Qe(S[N],c)},t.removeHook=function(N,c){if(c!==void 0){const x=Tr(S[N],c);return x===-1?void 0:Ar(S[N],x,1)[0]}return Dn(S[N])},t.removeHooks=function(N){S[N]=[]},t.removeAllHooks=function(){S=Hn()},t}var qr=Fn();function Un(){return{parseMarkdown:t=>{if(!t||typeof t!="string")return"";const n=ln(t),r=O.parse(n,{async:!1,breaks:!0,gfm:!0});return qr.sanitize(r,{ALLOWED_TAGS:["p","br","strong","em","b","i","code","pre","ul","ol","li","h1","h2","h3","h4","h5","h6","a","blockquote","span","div","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","target","rel","data-mention-id","data-mention-type"],ALLOW_UNKNOWN_PROTOCOLS:!1,FORBID_ATTR:["onerror","onload","onclick","onmouseover"],KEEP_CONTENT:!0})}}}function vr(){let o=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:p}=a;return u-l-p<i}function r(a){a&&(s(),o=new MutationObserver(()=>{(a.scrollTop===0||n(a))&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}),o.observe(a,{childList:!0,subtree:!0}))}function s(){o&&(o.disconnect(),o=null)}return e.onUnmounted(()=>{s()}),{scrollToBottom:t,setupAutoScroll:r,cleanupAutoScroll:s}}function jr(){const o=Te(),t=e.computed(()=>o.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 o.retry(),clearError:()=>{o.clearError()}}}function vt(){const o=Te(),t=e.computed(()=>o.pageContext);function n(a){o.setPageContext(a)}function r(){o.setPageContext(null)}function s(a){const i=o.pageContext;i&&o.setPageContext({...i,...a,metadata:{...i.metadata,...a.metadata}})}return{context:t,setContext:n,clearContext:r,updateContext:s}}const me=[],qn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const o=v();return(o==null?void 0:o.defaultSuggestions)||[]}};function Wr(){me.length=0;const o=v();o!=null&&o.suggestionProviders&&me.push(...o.suggestionProviders),me.push(qn)}function Kr(o,t){const n=[...me].sort((r,s)=>(s.priority||0)-(r.priority||0));for(const r of n)if(r.matcher&&r.matcher(o,t)||r.routes&&r.routes.some(a=>a.endsWith("*")?o.startsWith(a.slice(0,-1)):o===a||o.startsWith(a+"/")))return r;return qn}function vn(o,t){me.length===0&&Wr();const n=Kr(o,t),r=t||{pageType:"default",routePath:o};return n.extractContext&&(r.metadata={...r.metadata,...n.extractContext(o)}),n.getSuggestions(r)||[]}function Gr(o){const t=me.findIndex(n=>n.id===o.id);if(t>=0)me[t]=o;else{const n=me.findIndex(r=>r.id==="default");n>=0?me.splice(n,0,o):me.push(o)}}const Qr=Gr;function jt(){const{context:o}=vt(),t=Te(),n=e.computed(()=>{var u;if(t.quota.remaining===0){const p=v();return(p==null?void 0:p.enableSupportMode)!==!1?[{id:"contact-support-quota",title:te("contactSupport"),description:te("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[]}const a=((u=o.value)==null?void 0:u.routePath)||(typeof window<"u"?window.location.pathname:"/"),i=vn(a,o.value)||[],l=v();return l!=null&&l.can?i.filter(p=>!(p.permission&&!l.can(p.permission))):i}),r=e.computed(()=>o.value!==null&&o.value.pageType!=="default");function s(a){return typeof a.prompt=="function"?a.prompt(o.value||{pageType:"default"}):a.prompt}return{suggestions:n,hasContextualSuggestions:r,resolvePrompt:s}}function Zr(o,t){const{setContext:n,clearContext:r,updateContext:s}=vt();function a(){if(!t)return{};const l={};for(const[u,p]of Object.entries(t))l[u]=e.isRef(p)?p.value:p;return l}function i(){const l={pageType:o,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return e.onMounted(()=>{i()}),e.onUnmounted(()=>{r()}),t&&e.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function Yr(o){const t=o.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 Xr(o,t){const n=o.key.toLowerCase();if(t.mod){const p=navigator.platform.toUpperCase().indexOf("MAC")>=0||navigator.userAgent.toUpperCase().indexOf("MAC")>=0?o.metaKey:o.ctrlKey,d=t.shift?o.shiftKey:!o.shiftKey,y=t.alt?o.altKey:!o.altKey;return n===t.key&&p&&d&&y}const r=t.meta?o.metaKey:!o.metaKey,s=t.ctrl?o.ctrlKey:!o.ctrlKey,a=t.shift?o.shiftKey:!o.shiftKey,i=t.alt?o.altKey:!o.altKey;let l=r&&s&&a&&i;return(t.meta&&!t.ctrl||!t.meta&&t.ctrl)&&(l=(o.metaKey||o.ctrlKey)&&a&&i),n===t.key&&l}function jn(o){const{onToggle:t,enabled:n=!0}=o,r=e.ref(!1),s=o.shortcut!==void 0?o.shortcut:he("keyboardShortcut")??"mod+g";if(s===null)return{isActive:r};const a=Yr(s);function i(l){if(!n)return;const u=l.target,p=u.tagName==="INPUT"||u.tagName==="TEXTAREA",d=u.isContentEditable,y=u.closest("[data-ai-input]");if(!((p||d)&&!y)&&Xr(l,a)){l.preventDefault(),l.stopPropagation();const k=v();if(k!=null&&k.canToggle&&!k.canToggle())return;r.value=!r.value,t()}}return e.onMounted(()=>{window.addEventListener("keydown",i,!0)}),e.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:r}}function Jr(o){const t=Te();return jn({onToggle:()=>{o?o.value=!o.value:t.showChat=!t.showChat}})}function es(o,t){const n=e.ref(te("loadingText"));let r=[];function s(){return[te("loadingText"),te("analyzingText"),te("craftingText")]}function a(){return[0,2e3,5e3]}function i(){r.forEach(p=>clearTimeout(p)),r=[]}function l(){i();const p=t==null?void 0:t(),d=(p==null?void 0:p.messages)??s();n.value=d[0]||te("loadingText")}function u(){i();const p=t==null?void 0:t(),d=(p==null?void 0:p.messages)??s(),y=(p==null?void 0:p.intervals)??a();n.value=d[0]||te("loadingText");let k=0;for(let m=1;m<d.length;m++){k+=y[m]||2e3;const f=m,R=window.setTimeout(()=>{o()&&(n.value=d[f])},k);r.push(R)}}return e.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:u,resetLoadingText:l,clearLoadingTextTimers:i}}function ts(o){const{getHistoryLength:t,getStoreLimit:n,getConfig:r,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=o,l=e.ref({showWarning:!1,isReached:!1,pendingMessage:null}),u=e.computed(()=>{var b;return((b=r())==null?void 0:b.limit)??n()}),p=e.computed(()=>{var b;return((b=r())==null?void 0:b.showWarningAt)??u.value-2}),d=e.computed(()=>Math.max(0,u.value-t())),y=e.computed(()=>d.value<=u.value-p.value&&d.value>0),k=e.computed(()=>d.value===0),m=e.computed(()=>{var b,w;return l.value.isReached||k.value?((b=s())==null?void 0:b.historyLimitReachedTitle)??"Chat Limit Reached":((w=s())==null?void 0:w.historyLimitWarningTitle)??"Approaching Chat Limit"}),f=e.computed(()=>{var b,w,I,V;return l.value.isReached||k.value?((b=r())==null?void 0:b.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=r())==null?void 0:I.warningMessage)??((V=s())==null?void 0:V.historyLimitWarningMessage)??`You have ${d.value} message${d.value===1?"":"s"} remaining in this conversation.`});function R(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function h(){l.value.showWarning=!1;const b=r();if(b!=null&&b.onLimitReached&&!await b.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):(y.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function C(b){l.value.pendingMessage=b}return{showHistoryLimitWarning:e.computed(()=>l.value.showWarning),historyLimitReached:e.computed(()=>l.value.isReached),historyLimit:u,remainingMessages:d,historyLimitDialogTitle:m,historyLimitDialogMessage:f,dismissHistoryLimitWarning:R,handleHistoryLimitAction:h,checkHistoryLimit:g,setPendingMessage:C}}function ns(){const o=Te(),t=e.ref([]),n=e.ref(!1),r=e.ref(0),s=he("maxAttachments")||5,a=he("maxFileSize")||10*1024*1024,i=he("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=e.computed(()=>t.value.length>0),u=e.computed(()=>t.value.some(E=>E.uploading)),p=e.computed(()=>t.value.length<s);function d(E){return(E.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(E.name)}function y(E){if(E==null)return"";const D=typeof E=="string"?parseInt(E,10):E;return Number.isNaN(D)?"":D>=1024*1024?`${(D/(1024*1024)).toFixed(1)} MB`:D>=1024?`${Math.round(D/1024)} KB`:`${D} B`}function k(E){var _;const D=crypto.randomUUID(),A=E.type.startsWith("image/")?URL.createObjectURL(E):void 0,S=v(),j=!!((_=S==null?void 0:S.endpoints)!=null&&_.uploadFile),T={id:D,name:E.name,type:E.type,size:E.size,uploading:j,progress:j?0:100,previewUrl:A};t.value.push(T),j&&m(E,D)}async function m(E,D){try{const A=await o.uploadFile(E),S=t.value.findIndex(j=>j.id===D);if(S===-1)return;if(A){const j=t.value[S].previewUrl;t.value[S]={...t.value[S],id:A.id||D,url:A.url,extractedText:A.extractedText,uploading:!1,progress:100,previewUrl:j||A.previewUrl}}else f(D)}catch{f(D)}}function f(E){const D=t.value.findIndex(S=>S.id===E);if(D===-1)return;const[A]=t.value.splice(D,1);A!=null&&A.previewUrl&&URL.revokeObjectURL(A.previewUrl)}function R(){t.value.forEach(E=>{E.previewUrl&&URL.revokeObjectURL(E.previewUrl)}),t.value=[]}function h(){return t.value.filter(E=>!E.uploading).map(E=>({id:E.id,name:E.name,url:E.url,type:E.type,size:E.size}))}function g(E){if(!E)return;const D=Array.from(E);for(const A of D){if(t.value.length>=s)break;A.size>a||k(A)}}function C(E){var D;return Array.from(((D=E.dataTransfer)==null?void 0:D.types)||[]).includes("Files")}function b(E){C(E)&&(r.value+=1,n.value=!0)}function w(E){C(E)||E.preventDefault()}function I(E){C(E)&&(r.value=Math.max(0,r.value-1),r.value===0&&(n.value=!1))}function V(E){var D;C(E)&&(r.value=0,n.value=!1,g(((D=E.dataTransfer)==null?void 0:D.files)||null))}function F(E){const D=E.target,A=D.files;A&&A.length&&g(A),D.value=""}return e.onBeforeUnmount(()=>{R()}),{attachments:t,isDraggingFiles:n,hasAttachments:l,isUploading:u,canAddMore:p,acceptedFileTypes:i,isImage:d,formatFileSize:y,removeAttachment:f,clearAttachments:R,buildPayload:h,processFiles:g,handleFileSelect:F,handleDragEnter:b,handleDragOver:w,handleDragLeave:I,handleDrop:V}}function os(o,t,n){const r=e.ref(!1),s=e.ref([]),a=e.ref(0),i=e.ref({inMention:!1,query:"",startPos:0}),l=e.ref(!1),u=e.ref([]),p=e.computed(()=>{const h=v();return(h==null?void 0:h.mentionProviders)||[]});function d(h){if(l.value){l.value=!1;return}const g=n();if(!g)return;const C=g.selectionStart,b=cn(h,C);i.value=b,b.inMention&&b.query.length>=0?y(b.query):(r.value=!1,s.value=[])}async function y(h){const g=pn();if(g.length===0){r.value=!1;return}const C=[];for(const b of g)try{const w=await b.search(h);C.push(...w.map(I=>({...I,type:b.type})))}catch(w){console.warn(`Mention provider ${b.type} failed:`,w)}s.value=C.slice(0,10),r.value=C.length>0,a.value=0}function k(h){const{startPos:g}=i.value,C=o(),b=n(),w=C.slice(0,g),I=C.slice((b==null?void 0:b.selectionStart)||g),V=h.name||h.label||h.title||h.id;l.value=!0,t(`${w}@${V} ${I}`),u.value.push({id:h.id,name:V,type:h.type,metadata:h.attributes}),r.value=!1,s.value=[],setTimeout(()=>{const F=n();F==null||F.focus();const E=w.length+V.length+2;F==null||F.setSelectionRange(E,E)},0)}function m(h){if(!r.value||s.value.length===0)return!1;if(h.key==="ArrowDown")return h.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(h.key==="ArrowUp")return h.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(h.key==="Enter"||h.key==="Tab"){h.preventDefault();const g=s.value[a.value];return g&&k(g),!0}return h.key==="Escape"?(h.preventDefault(),r.value=!1,!0):!1}function f(){u.value=[]}function R(){return[...u.value]}return{showMentions:r,mentionItems:s,selectedMentionIndex:a,mentionProviders:p,checkForMentions:d,handleMentionSelect:k,handleMentionKeyDown:m,clearMentions:f,getMentions:R}}function rs(o,t,n,r,s){const a=e.ref(!1),i=e.ref(-1),l=e.ref(null);function u(){setTimeout(()=>{const m=l.value;if(!m)return;const f=m.querySelector(`li:nth-child(${i.value+1})`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function p(m){const f=o();if(!a.value||f.length===0)return!1;if(m.key==="ArrowDown")return m.preventDefault(),i.value=Math.min(i.value+1,f.length-1),u(),!0;if(m.key==="ArrowUp")return m.preventDefault(),i.value=Math.max(i.value-1,0),u(),!0;if(m.key==="Enter"&&i.value>=0){m.preventDefault();const R=f[i.value];return R&&d(R),!0}return m.key==="Escape"?(m.preventDefault(),a.value=!1,i.value=-1,!0):!1}function d(m){s(m),a.value=!1,i.value=-1}function y(){const m=r(),f=t(),R=n(),h=o();m&&!f&&R&&h.length>0?a.value=!0:a.value=!1}function k(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:p,handleSuggestionClick:d,updateSuggestionsVisibility:y,hideSuggestions:k}}function ss(o,t=300){function n(){const r=o();if(!r)return;r.style.height="auto";const s=Math.min(r.scrollHeight,t);r.style.height=`${s}px`,r.style.overflowY=r.scrollHeight>t?"auto":"hidden"}return e.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const Wn=e.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(o){return(t,n)=>{var r;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",(r=o.ui)==null?void 0:r.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=o.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(o){return(t,n)=>{var r;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(r=o.ui)==null?void 0:r.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=o.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(o,{emit:t}){const n=o,r=e.computed(()=>n.ui||{}),s=t,a=e.ref(n.selectedIndex);e.watch(()=>n.selectedIndex,h=>{a.value=h}),e.watch(a,h=>{s("update:selectedIndex",h)});const i=e.computed(()=>{const h={};return n.items.forEach(g=>{const C=g.type||"default";h[C]||(h[C]=[]),h[C].push(g)}),h});function l(h){return n.providers.find(g=>g.type===h)||dn(h)}function u(h){const g=l(h);return(g==null?void 0:g.label)||h.charAt(0).toUpperCase()+h.slice(1)+"s"}function p(h,g){let C=0;const b=Object.keys(i.value);for(const w of b){if(w===h)return C+g;C+=i.value[w].length}return C}function d(h){s("select",h)}function y(h){a.value=h,s("update:selectedIndex",h)}function k(h){const g=l(h.type);return At(h,g)}function m(h){const g=l(h.type);return un(h,g)}function f(h){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[h]||g.default}function R(h){return h.split(" ").map(g=>g[0]).join("").slice(0,2).toUpperCase()}return(h,g)=>o.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-60 overflow-y-auto z-50",r.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["p-2",r.value.container])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(C,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:b},[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",r.value.groupHeader])},e.toDisplayString(u(b)),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C,(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",[r.value.item,{[r.value.itemSelected||"bg-primary/10"]:p(b,I)===a.value,"hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer":p(b,I)!==a.value}]]),onClick:V=>d(w),onMouseenter:V=>y(p(b,I))},[e.renderSlot(h.$slots,"item-icon",{item:w,type:b},()=>[e.createElementVNode("span",{class:e.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[r.value.itemIcon,f(w.type)]])},e.toDisplayString(R(k(w))),3)]),e.createElementVNode("div",{class:e.normalizeClass(["flex-1 min-w-0",r.value.itemContent])},[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",r.value.itemName])},e.toDisplayString(k(w)),3),m(w)?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",r.value.itemSubtitle])},e.toDisplayString(m(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(o,{emit:t}){const n=o,r=t,s=u=>{var d;return(d=n.texts)!=null&&d[u]?n.texts[u]:te({copyToClipboard:"copyToClipboard",copied:"copied"}[u])},a=e.computed(()=>n.ui||{}),i=e.ref(!1);async function l(){try{await navigator.clipboard.writeText(n.message.message),i.value=!0,r("copy",n.message),setTimeout(()=>{i.value=!1},2e3)}catch(u){console.error("Failed to copy:",u)}}return(u,p)=>(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"},[...p[1]||(p[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,[...p[0]||(p[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 group-hover:opacity-0 transition-opacity"},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(o,{emit:t}){const n=o,r=t,s=g=>{var b;return(b=n.texts)!=null&&b[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??[]),p=e.computed(()=>u.value.length>0),d=e.computed(()=>{if(n.message.role!=="user")return!1;const g=n.message.message||"",C=g.split(`
|
|
59
|
+
`).length;return g.length>200||C>4});function y(){l.value=!l.value}function k(g){return(g.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(g.name||"")}const m=e.computed(()=>{const g=v();return g!=null&&g.userAvatar?typeof g.userAvatar=="string"?g.userAvatar:typeof g.userAvatar=="function"?g.userAvatar():null:null});function f(g){if(g==null)return"";const C=typeof g=="string"?parseInt(g,10):g;return Number.isNaN(C)?"":C>=1024*1024?`${(C/(1024*1024)).toFixed(1)} MB`:C>=1024?`${Math.round(C/1024)} KB`:`${C} B`}const R=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 h(g){r("copy",g)}return(g,C)=>{var b;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":o.message.role==="user","flex justify-start":o.message.role==="assistant"}]])},[o.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])},[o.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&&d.value}]])},e.toDisplayString(o.message.message),3)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",a.value.showMoreButton]),onClick:y},e.toDisplayString(l.value?s("showLess"):s("showMore")),3)):e.createCommentVNode("",!0),p.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,[...C[0]||(C[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(f(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])},[m.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:m.value,alt:"User",class:"h-full w-full object-cover"},null,8,ys)):(e.openBlock(),e.createElementBlock("svg",ks,[...C[1]||(C[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-4 py-3 shadow-sm rounded-2xl transition-all duration-200 max-w-[85%]",a.value.assistantBubble])},[o.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])},[...C[2]||(C[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(((b=o.texts)==null?void 0:b.loadingText)||o.loadingText),1)],2)):o.message.message?(e.openBlock(),e.createElementBlock("div",{key:1,id:o.message.id,class:e.normalizeClass(["text-sm text-gray-700 dark:text-gray-200 leading-relaxed",a.value.content]),innerHTML:R.value},null,10,bs)):e.createCommentVNode("",!0),!o.message.loading&&p.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,[...C[3]||(C[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(f(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)),o.message.role==="assistant"&&!o.message.loading&&!o.message.streaming&&o.showActions?(e.openBlock(),e.createBlock(Gn,{key:2,message:o.message,class:e.normalizeClass(["absolute top-0 left-0",a.value.actionsContainer]),onCopy:h},null,8,["message","class"])):e.createCommentVNode("",!0)],2)}}}),Qn=(o,t)=>{const n=o.__vccOpts||o;for(const[r,s]of t)n[r]=s;return n},Zn=Qn(Rs,[["__scopeId","data-v-1fd34583"]]),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"],Hs=e.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(o){return(t,n)=>{var r;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",o.ui.attachmentsContainer])},[e.createElementVNode("p",Bs,e.toDisplayString(((r=o.texts)==null?void 0:r.attachedFiles)||"Attached files"),1),e.createElementVNode("ul",Ls,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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",o.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",o.ui.attachmentThumbnail])},[o.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(o.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",o.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)}}}),Fs={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(o,{expose:t}){const n=e.ref(null);return t({dropdownRef:n}),(r,s)=>(e.openBlock(),e.createBlock(e.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"dropdownRef",ref: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",o.ui.suggestionsDropdown])},[e.createElementVNode("ul",Fs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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",[o.ui.suggestionItem,{[o.ui.suggestionItemSelected||"bg-primary/10"]:i===o.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":i!==o.selectedIndex}]]),onClick:l=>r.$emit("select",a),onMouseenter:l=>r.$emit("hover",i)},[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(o){const t=o,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(r,s)=>{var a,i,l;return e.openBlock(),e.createElementBlock("div",Gs,[o.showSupportModeToggle&&!o.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",o.ui.supportToggle]),title:((a=o.texts)==null?void 0:a.toggleSupportMode)||"Toggle support mode",onClick:s[0]||(s[0]=u=>r.$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),o.showSupportModeToggle&&o.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",o.ui.supportBadge]),title:((i=o.texts)==null?void 0:i.exitSupportMode)||"Exit support mode",onClick:s[1]||(s[1]=u=>r.$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=o.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:!o.canSend&&!o.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=>r.$emit("click"),["prevent"]))},[o.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"],oa=["title"],ra={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(o,{expose:t,emit:n}){const r=o,s=e.computed(()=>r.ui||{}),a=n,i=e.ref(r.modelValue),l=e.ref(null),u=e.ref(null),p=e.ref(!1),d=ns(),y=os(()=>i.value,A=>{i.value=A},()=>l.value),k=rs(()=>r.suggestions,()=>r.hasHistory,()=>p.value,()=>i.value,A=>{a("suggestion-select",A),e.nextTick(()=>{var S;return(S=l.value)==null?void 0:S.focus()})}),{adjustTextareaHeight:m}=ss(()=>l.value),f=e.computed(()=>r.supportRequestMode?r.supportPlaceholder:r.placeholder),R=e.computed(()=>r.showSupportModeToggle?r.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),h=e.computed(()=>{var S;return(((S=i.value)==null?void 0:S.trim())??"").length>=r.minLength?!0:d.hasAttachments.value}),g=e.computed(()=>!r.disabled&&!r.sending&&h.value&&!d.isUploading.value);e.watch(()=>r.modelValue,A=>{i.value=A,e.nextTick(m)}),e.watch(i,A=>{a("update:modelValue",A),e.nextTick(m),y.checkForMentions(A),k.updateSuggestionsVisibility()}),e.watch(()=>r.suggestions,()=>{k.updateSuggestionsVisibility()});function C(){m()}function b(A){if(!y.handleMentionKeyDown(A)&&!k.handleSuggestionKeyDown(A)&&A.key==="Enter"){if(A.shiftKey)return;!r.sending&&g.value&&(A.preventDefault(),w())}}function w(){if(!g.value)return;const A=d.buildPayload(),S=i.value.trim(),j=y.getMentions();a("submit",{message:S,attachments:A,mentions:j,isSupportRequest:r.supportRequestMode}),i.value="",d.clearAttachments(),y.clearMentions(),e.nextTick(m)}function I(){r.sending?a("cancel"):g.value&&w()}function V(){var A;r.disabled||r.sending||d.canAddMore.value&&((A=u.value)==null||A.click())}function F(A){k.handleSuggestionClick(A)}function E(){p.value=!0,k.updateSuggestionsVisibility()}function D(){p.value=!1,setTimeout(()=>{k.hideSuggestions(),y.showMentions.value=!1},200)}return t({focus:()=>{var A;return(A=l.value)==null?void 0:A.focus()}}),e.onMounted(()=>{e.nextTick(m)}),(A,S)=>{var j;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",s.value.root]),onDragenter:S[6]||(S[6]=e.withModifiers((...T)=>e.unref(d).handleDragEnter&&e.unref(d).handleDragEnter(...T),["prevent"])),onDragover:S[7]||(S[7]=e.withModifiers((...T)=>e.unref(d).handleDragOver&&e.unref(d).handleDragOver(...T),["prevent"])),onDragleave:S[8]||(S[8]=e.withModifiers((...T)=>e.unref(d).handleDragLeave&&e.unref(d).handleDragLeave(...T),["prevent"])),onDrop:S[9]||(S[9]=e.withModifiers((...T)=>e.unref(d).handleDrop&&e.unref(d).handleDrop(...T),["prevent"]))},[e.createElementVNode("form",{class:e.normalizeClass(s.value.form),onSubmit:e.withModifiers(w,["prevent"])},[e.createElementVNode("div",ta,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:u,type:"file",class:"hidden",multiple:"",accept:e.unref(d).acceptedFileTypes,onChange:S[0]||(S[0]=(...T)=>e.unref(d).handleFileSelect&&e.unref(d).handleFileSelect(...T))},null,40,na),e.unref(d).hasAttachments.value?(e.openBlock(),e.createBlock(Hs,{key:0,attachments:e.unref(d).attachments.value,ui:s.value,texts:o.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",s.value.inputContainer])},[e.unref(k).showSuggestions.value&&o.suggestions.length>0?(e.openBlock(),e.createBlock(Ks,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:o.suggestions,"selected-index":e.unref(k).selectedSuggestionIndex.value,ui:s.value,onSelect:F,onHover:S[1]||(S[1]=T=>e.unref(k).selectedSuggestionIndex.value=T)},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(y).showMentions.value&&e.unref(y).mentionItems.value.length>0?(e.openBlock(),e.createBlock(Kn,{key:0,items:e.unref(y).mentionItems.value,"selected-index":e.unref(y).selectedMentionIndex.value,providers:e.unref(y).mentionProviders.value,onSelect:e.unref(y).handleMentionSelect,"onUpdate:selectedIndex":S[2]||(S[2]=T=>e.unref(y).selectedMentionIndex.value=T)},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",[s.value.inputWrapper,{"border-primary shadow-primary/30":p.value||e.unref(d).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!p.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",s.value.attachButton]),title:((j=o.texts)==null?void 0:j.attachFiles)||"Attach files",onClick:V},[...S[10]||(S[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,oa),e.createElementVNode("div",ra,[e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:l,"onUpdate:modelValue":S[3]||(S[3]=T=>i.value=T),rows:"1","data-ai-input":"",placeholder:f.value,disabled:o.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",s.value.textarea]),style:e.normalizeStyle(R.value),onInput:C,onKeydown:b,onFocus:E,onBlur:D},null,46,sa),[[e.vModelText,i.value]])]),e.createVNode(ea,{sending:o.sending,"can-send":g.value,"support-request-mode":o.supportRequestMode,"show-support-mode-toggle":o.showSupportModeToggle,ui:s.value,texts:o.texts,onToggleSupportMode:S[4]||(S[4]=T=>A.$emit("toggle-support-mode")),onClick:I},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),e.renderSlot(A.$slots,"context-link",{},()=>[o.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",s.value.contextLink]),onClick:S[5]||(S[5]=T=>A.$emit("context-link-click"))},e.toDisplayString(o.contextLinkText),3)])):e.createCommentVNode("",!0)])])],34)],34)}}}),ia=["onClick"],Xn=e.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(o,{emit:t}){const n=o,r=t,s=k=>{var f;return(f=n.texts)!=null&&f[k]?n.texts[k]:te({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[k])},a=e.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=jt();function u(k){const m={...k,prompt:l(k)};r("item-click",m)}function p(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 d(k){const m=k.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[m]||f.default}function y(k){const m=k.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[m]||f.default}return(k,m)=>(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])},[m[0]||(m[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),(f,R)=>(e.openBlock(),e.createElementBlock("button",{key:f.id||R,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,p(f)]]),onClick:h=>u(f)},[e.createElementVNode("div",{class:e.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,d(f)]])},[f.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.icon),{key:0,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,y(f)]])},null,8,["class"])):(e.openBlock(),e.createElementBlock("svg",{key:1,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,y(f)]]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...m[1]||(m[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(f.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},e.toDisplayString(f.description),3)],10,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(o){const t=o,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"}),r=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,p,d,y,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=o.ui)==null?void 0:i.header])},[e.createElementVNode("div",la,[o.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},[o.showNewChatButton&&o.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=o.ui)==null?void 0:l.newChatButton]),onClick:a[0]||(a[0]=m=>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(o.t("newChat")),1)],2)):(e.openBlock(),e.createElementBlock("span",ca,e.toDisplayString(o.t("keyboardShortcutHint")),1))],64))]),!o.isSetupMode&&(o.showMessageCount||o.showQuota)?(e.openBlock(),e.createElementBlock("div",da,[o.showMessageCount&&o.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=o.ui)==null?void 0:u.messageCountBadge])},[(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-3.5 h-3.5",r.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(o.messageCount),1),a[7]||(a[7]=e.createElementVNode("span",{class:"text-gray-400 dark:text-gray-500"},"/",-1)),e.createTextVNode(e.toDisplayString(o.messageLimit),1)])],2)],2)):e.createCommentVNode("",!0),o.showMessageCount&&o.hasHistory&&o.showQuota&&o.quota.remaining>=0?(e.openBlock(),e.createElementBlock("span",pa," • ")):e.createCommentVNode("",!0),o.showQuota?e.renderSlot(s.$slots,"quota",{key:2},()=>{var m;return[o.quota.remaining>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 text-xs",(m=o.ui)==null?void 0:m.quotaDisplay])},[e.createElementVNode("span",ma,e.toDisplayString(o.quota.remaining),1),e.createElementVNode("span",fa,e.toDisplayString(o.t("quotaRemaining")),1)],2)):o.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(o.t("noQuota")),1)])):e.createCommentVNode("",!0)]}):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1",(p=o.ui)==null?void 0:p.headerActions])},[o.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",(d=o.ui)==null?void 0:d.headerActionButton]),title:o.t("close"),onClick:a[1]||(a[1]=m=>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),o.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",(y=o.ui)==null?void 0:y.headerActionButton]),title:o.t("minimize"),onClick:a[2]||(a[2]=m=>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),o.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=o.ui)==null?void 0:k.headerActionButton]),title:o.isFullscreen?o.t("exitFullscreen"):o.t("fullscreen"),onClick:a[3]||(a[3]=m=>s.$emit("toggle-fullscreen"))},[o.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(o){return(t,n)=>{var r,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(o.t("title")||e.unref(te)("aiName")),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.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":o.loadingMessage,onCopy:n[0]||(n[0]=u=>t.$emit("copy",u))},null,8,["message","loading-text"])])),128)),o.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(te)("contactSupport")),1)])])):e.createCommentVNode("",!0),o.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",(r=o.ui)==null?void 0:r.errorContainer])},[e.createElementVNode("span",{class:e.normalizeClass((s=o.ui)==null?void 0:s.errorMessage)},e.toDisplayString(o.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=o.ui)==null?void 0:a.retryButton]),title:o.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(o){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]=r=>t.$emit("copy"))},e.toDisplayString(o.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">'@doderasoftware/restify-ai'</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">'/api/ai/quota'</span>, <span class="text-gray-500">// optional</span>
|
|
66
66
|
},
|
|
67
67
|
<span class="text-blue-300">getAuthToken</span>: () => <span class="text-yellow-300">getToken</span>(),
|
|
68
|
-
})</code></pre>`,1))]),n[3]||(n[3]=e.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[e.createTextVNode(" Need help? Check the "),e.createElementVNode("a",{href:"https://github.com/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(o){const t=o,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}),r=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[o.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])},[o.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(o.title),1)])):(e.openBlock(),e.createElementBlock("h3",Oa,e.toDisplayString(o.title),1)),e.createElementVNode("p",Va,e.toDisplayString(o.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=o.ui)==null?void 0:i.cancelButton]),onClick:a[0]||(a[0]=l=>s.$emit("cancel"))},e.toDisplayString(o.cancelText),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",r.value]),onClick:a[1]||(a[1]=l=>s.$emit("confirm"))},e.toDisplayString(o.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"},
|
|
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(o){const t=o,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}),r=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[o.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])},[o.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(o.title),1)])):(e.openBlock(),e.createElementBlock("h3",Oa,e.toDisplayString(o.title),1)),e.createElementVNode("p",Va,e.toDisplayString(o.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=o.ui)==null?void 0:i.cancelButton]),onClick:a[0]||(a[0]=l=>s.$emit("cancel"))},e.toDisplayString(o.cancelText),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",r.value]),onClick:a[1]||(a[1]=l=>s.$emit("confirm"))},e.toDisplayString(o.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"},Ha={key:0,class:"flex-1 flex flex-col overflow-y-auto"},Fa=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(o,{emit:t}){const n=o,r=t,s=e.computed({get:()=>n.modelValue,set:B=>r("update:modelValue",B)});function a(B,$){var U;const K=(U=n.texts)==null?void 0:U[B];if(K){let X=K;if($)for(const[G,J]of Object.entries($))X=X.replace(`{${G}}`,String(J));return X}return te(B,$)}const i=Te(),l=e.ref(""),u=e.ref(null),p=e.ref(null),d=e.ref(!1),y=e.ref(!1),k=e.ref(!1),{loadingMessage:m,startLoadingText:f,resetLoadingText:R}=es(()=>i.sending,()=>n.loadingText),{showHistoryLimitWarning:h,historyLimitReached:g,historyLimitDialogTitle:C,historyLimitDialogMessage:b,dismissHistoryLimitWarning:w,handleHistoryLimitAction:I,checkHistoryLimit:V,setPendingMessage:F}=ts({getHistoryLength:()=>i.quota.limit-i.quota.remaining,getStoreLimit:()=>i.quota.limit,getConfig:()=>n.historyLimit,getTexts:()=>n.texts,onStartNewChat:()=>i.clearChatHistory(),onNewChatEmit:()=>r("new-chat")}),E=e.computed(()=>!Ct()),D=e.computed(()=>he("enableSupportMode")??!1),{suggestions:A,resolvePrompt:S}=jt();e.computed(()=>i.chatHistory.filter(B=>B.role==="user").length);const j=e.computed(()=>{if(E.value)return[];const B=l.value.toLowerCase().trim(),$=A.value||[];let K=$;if(B){const U=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]),X=B.split(/\s+/).filter(G=>!U.has(G));X.length>0&&(K=$.filter(G=>{const J=`${G.title} ${G.description||""}`.toLowerCase();return X.every(Me=>J.includes(Me))}))}return K.slice(0,5).map(U=>({id:U.id,title:U.title,description:U.description||""}))}),T=e.computed(()=>({quota:i.quota,isFullscreen:d.value,hasHistory:i.chatHistory.length>0,onNewChat:et,onClose:Ae,onMinimize:ke,onToggleFullscreen:ye})),_=e.computed(()=>({modelValue:l.value,sending:i.sending,disabled:!1,onSubmit:nt,onCancel:()=>i.cancelRequest()}));function De(B){const $=(A.value||[]).find(K=>K.id===B.id);$&&(l.value=S($))}function ye(){d.value=!d.value}function ke(){s.value=!1}function Ae(){n.confirmClose&&!E.value&&i.chatHistory.length>0?k.value=!0:(s.value=!1,r("close"))}function Wt(){k.value=!1,i.clearChatHistory(),s.value=!1,r("close")}function gt(){r("contact-support")}function Q(){i.toggleSupportMode()}async function xe(){await e.nextTick();const B=u.value;B&&(B.scrollTop=B.scrollHeight)}function Z(B){l.value=B.prompt,i.clearError()}function et(){i.clearChatHistory(),r("new-chat")}function W(B){}function Ie(){navigator.clipboard.writeText(`import { RestifyAiPlugin } from '@doderasoftware/restify-ai'
|
|
69
69
|
|
|
70
70
|
app.use(RestifyAiPlugin, {
|
|
71
71
|
endpoints: {
|
|
@@ -73,4 +73,4 @@ app.use(RestifyAiPlugin, {
|
|
|
73
73
|
quota: '/api/ai/quota', // optional
|
|
74
74
|
},
|
|
75
75
|
getAuthToken: () => getToken(),
|
|
76
|
-
})`),h.value=!0,setTimeout(()=>{h.value=!1},2e3)}async function et(){const B=await z();B&&(await e.nextTick(),await we(B.message,B.attachments,B.mentions,B.isSupportRequest))}async function we(B,$,W,H){i.clearError(),f(),await e.nextTick(),xe();const X=await i.askQuestion(B,$,W,H);E(),X&&xe()}async function tt(B){const{message:$,attachments:W,mentions:H,isSupportRequest:X}=B;if(i.sending)return;const G=H.map(J=>({id:J.id,name:J.name,type:J.type||"unknown",metadata:J.metadata}));if(!O()){K({message:$,attachments:W,mentions:G,isSupportRequest:X});return}await we($,W,G,X)}async function nt(){f();const B=await i.retry();E(),B&&xe()}function ot(B){n.closeOnEscape&&B.key==="Escape"&&s.value&&(g.value?g.value=!1:ke())}return e.watch(()=>i.chatHistory.length,()=>{xe()}),e.watch(()=>i.chatHistory.map(B=>B.message).join(""),()=>{xe()}),e.watch(()=>n.modelValue,async B=>{var $;B&&(await xe(),($=p.value)==null||$.focus()),B&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),e.onMounted(()=>{window.addEventListener("keydown",ot)}),e.onUnmounted(()=>{window.removeEventListener("keydown",ot)}),(B,$)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"rai-fade"},{default:e.withCtx(()=>{var W;return[s.value&&o.showBackdrop?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["fixed inset-0 bg-black/30 z-40",(W=o.ui)==null?void 0:W.backdrop]),onClick:$[0]||($[0]=H=>o.closeOnBackdropClick&&ke())},null,2)):e.createCommentVNode("",!0)]}),_:1}),e.createVNode(e.Transition,{name:o.position==="left"?"rai-slide-right":"rai-slide-left"},{default:e.withCtx(()=>{var W,H,X;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",[o.position==="left"?"left-0 border-r":"right-0 border-l",(W=o.ui)==null?void 0:W.drawer]]),style:e.normalizeStyle({width:d.value?o.fullscreenWidth:o.width,top:o.topOffset,height:`calc(100vh - ${o.topOffset})`})},[e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(H=o.ui)==null?void 0:H.panel])},[e.renderSlot(B.$slots,"header",e.normalizeProps(e.guardReactiveProps(N.value)),()=>[e.createVNode(Ea,{ui:o.ui,"is-setup-mode":C.value,"show-new-chat-button":o.showNewChatButton,"has-history":e.unref(i).chatHistory.length>0,"show-quota":o.showQuota,quota:e.unref(i).quota,"show-close-button":o.showCloseButton,"show-minimize-button":o.showMinimizeButton,"show-fullscreen-toggle":o.showFullscreenToggle,"is-fullscreen":d.value,"show-message-count":o.showMessageCount,"message-count":e.unref(i).quota.used,"message-limit":e.unref(i).quota.limit,t:a,onNewChat:Je,onClose:Ae,onMinimize:ke,onToggleFullscreen:ye},{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},(X=o.ui)==null?void 0:X.body]])},[C.value?(e.openBlock(),e.createElementBlock("div",_a,[e.renderSlot(B.$slots,"setup",{},()=>[e.createVNode(Da,{copied:h.value,onCopy:Ie},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:v.value,onClick:Z},()=>[e.createVNode(Xn,{onItemClick:Z})],!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(m),quota:e.unref(i).quota,error:e.unref(i).error,ui:o.ui,t:a,onCopy:j,onContactSupport:gt,onRetry:nt},{message:e.withCtx(G=>[e.renderSlot(B.$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)),$[3]||($[3]=e.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),e.renderSlot(B.$slots,"input",e.normalizeProps(e.guardReactiveProps(F.value)),()=>{var G,J;return[e.createVNode(Yn,{ref_key:"chatInputRef",ref:p,modelValue:l.value,"onUpdate:modelValue":$[1]||($[1]=Me=>l.value=Me),sending:e.unref(i).sending,placeholder:((G=n.texts)==null?void 0:G.placeholder)||e.unref(te)("inputPlaceholder"),"support-placeholder":((J=n.texts)==null?void 0:J.supportPlaceholder)||e.unref(te)("supportPlaceholder"),suggestions:v.value,"has-history":e.unref(i).chatHistory.length>0,"support-request-mode":e.unref(i).supportRequestMode,"show-support-mode-toggle":D.value,onSubmit:tt,onCancel:e.unref(i).cancelRequest,onSuggestionSelect:De,onToggleSupportMode:Q},{"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:g.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:o.ui,"confirm-variant":"danger",onConfirm:Wt,onCancel:$[2]||($[2]=G=>g.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),e.createVNode(Jn,{show:e.unref(k),title:e.unref(b),message:e.unref(S),"confirm-text":a("startNewChat"),"cancel-text":e.unref(y)?a("continueChat"):a("cancel"),ui:o.ui,icon:"warning","confirm-variant":"primary",onConfirm:et,onCancel:e.unref(w)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):e.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-45532662"]]),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(o,{expose:t,emit:n}){const r=o,s=n,a=e.ref(!1),i=e.ref(null);e.onErrorCaptured((u,p,d)=>{var h;return a.value=!0,i.value=u,(h=r.onError)==null||h.call(r,u,d),s("error",u,d),!1});function l(){a.value=!1,i.value=null,s("reset")}return t({hasError:a,error:i,reset:l}),(u,p)=>a.value?e.renderSlot(u.$slots,"error",{key:1,error:i.value,reset:l},()=>{var d,h,g,m,f;return[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-col items-center justify-center p-6 text-center",(d=o.ui)==null?void 0:d.container])},[e.createElementVNode("div",{class:e.normalizeClass(["w-12 h-12 mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",(h=o.ui)==null?void 0:h.iconContainer])},[...p[0]||(p[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",(g=o.ui)==null?void 0:g.title])},e.toDisplayString(o.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4",(m=o.ui)==null?void 0:m.message])},e.toDisplayString(o.message),3),o.showRetry?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary/90 transition-colors",(f=o.ui)==null?void 0:f.retryButton]),onClick:l},e.toDisplayString(o.retryText),3)):e.createCommentVNode("",!0)],2)]}):e.renderSlot(u.$slots,"default",{key:0})}}),eo={install(o,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),o.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=Re,L.ErrorBoundary=Ua,L.MentionList=Kn,L.RestifyAiPlugin=eo,L.UserAvatar=as,L.default=eo,L.defaultLabels=Et,L.formatMentionsForApi=mn,L.getConfigValue=he,L.getLabel=te,L.getRestifyAiConfig=q,L.getRestifyAiConfigOrThrow=bo,L.getSuggestionsForPath=vn,L.groupMentionsByType=fn,L.isConfigured=Ct,L.registerSuggestionProvider=Qr,L.setRestifyAiConfig=en,L.useAiContext=vt,L.useAiDrawerShortcut=Jr,L.useAiSuggestions=jt,L.useChatErrorHandling=jr,L.useChatMarkdown=Un,L.useChatScroll=vr,L.useKeyboardShortcut=jn,L.useMentionParsing=qo,L.usePageAiContext=Zr,L.useRestifyAiStore=Te,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
76
|
+
})`),y.value=!0,setTimeout(()=>{y.value=!1},2e3)}async function tt(){const B=await I();B&&(await e.nextTick(),await we(B.message,B.attachments,B.mentions,B.isSupportRequest))}async function we(B,$,K,U){i.clearError(),f(),await e.nextTick(),xe();const X=await i.askQuestion(B,$,K,U);R(),X&&xe()}async function nt(B){const{message:$,attachments:K,mentions:U,isSupportRequest:X}=B;if(i.sending)return;const G=U.map(J=>({id:J.id,name:J.name,type:J.type||"unknown",metadata:J.metadata}));if(!V()){F({message:$,attachments:K,mentions:G,isSupportRequest:X});return}await we($,K,G,X)}async function ot(){f();const B=await i.retry();R(),B&&xe()}function rt(B){n.closeOnEscape&&B.key==="Escape"&&s.value&&(k.value?k.value=!1:ke())}return e.watch(()=>i.chatHistory.length,()=>{xe()}),e.watch(()=>i.chatHistory.map(B=>B.message).join(""),()=>{xe()}),e.watch(()=>n.modelValue,async B=>{var $;B&&(await xe(),($=p.value)==null||$.focus()),B&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),e.onMounted(()=>{window.addEventListener("keydown",rt)}),e.onUnmounted(()=>{window.removeEventListener("keydown",rt)}),(B,$)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"rai-fade"},{default:e.withCtx(()=>{var K;return[s.value&&o.showBackdrop?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["fixed inset-0 bg-black/30 z-40",(K=o.ui)==null?void 0:K.backdrop]),onClick:$[0]||($[0]=U=>o.closeOnBackdropClick&&ke())},null,2)):e.createCommentVNode("",!0)]}),_:1}),e.createVNode(e.Transition,{name:o.position==="left"?"rai-slide-right":"rai-slide-left"},{default:e.withCtx(()=>{var K,U,X;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",[o.position==="left"?"left-0 border-r":"right-0 border-l",(K=o.ui)==null?void 0:K.drawer]]),style:e.normalizeStyle({width:d.value?o.fullscreenWidth:o.width,top:o.topOffset,height:`calc(100vh - ${o.topOffset})`})},[e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(U=o.ui)==null?void 0:U.panel])},[e.renderSlot(B.$slots,"header",e.normalizeProps(e.guardReactiveProps(T.value)),()=>[e.createVNode(Ea,{ui:o.ui,"is-setup-mode":E.value,"show-new-chat-button":o.showNewChatButton,"has-history":e.unref(i).chatHistory.length>0,"show-quota":o.showQuota,quota:e.unref(i).quota,"show-close-button":o.showCloseButton,"show-minimize-button":o.showMinimizeButton,"show-fullscreen-toggle":o.showFullscreenToggle,"is-fullscreen":d.value,"show-message-count":o.showMessageCount,"message-count":e.unref(i).quota.used,"message-limit":e.unref(i).quota.limit,t:a,onNewChat:et,onClose:Ae,onMinimize:ke,onToggleFullscreen:ye},{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},(X=o.ui)==null?void 0:X.body]])},[E.value?(e.openBlock(),e.createElementBlock("div",_a,[e.renderSlot(B.$slots,"setup",{},()=>[e.createVNode(Da,{copied:y.value,onCopy:Ie},null,8,["copied"])],!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(i).chatHistory.length===0?(e.openBlock(),e.createElementBlock("div",Ha,[e.renderSlot(B.$slots,"empty-state",{suggestions:j.value,onClick:Z},()=>[e.createVNode(Xn,{onItemClick:Z})],!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(m),quota:e.unref(i).quota,error:e.unref(i).error,ui:o.ui,t:a,onCopy:W,onContactSupport:gt,onRetry:ot},{message:e.withCtx(G=>[e.renderSlot(B.$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)),$[3]||($[3]=e.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),e.renderSlot(B.$slots,"input",e.normalizeProps(e.guardReactiveProps(_.value)),()=>{var G,J;return[e.createVNode(Yn,{ref_key:"chatInputRef",ref:p,modelValue:l.value,"onUpdate:modelValue":$[1]||($[1]=Me=>l.value=Me),sending:e.unref(i).sending,placeholder:((G=n.texts)==null?void 0:G.placeholder)||e.unref(te)("inputPlaceholder"),"support-placeholder":((J=n.texts)==null?void 0:J.supportPlaceholder)||e.unref(te)("supportPlaceholder"),suggestions:j.value,"has-history":e.unref(i).chatHistory.length>0,"support-request-mode":e.unref(i).supportRequestMode,"show-support-mode-toggle":D.value,onSubmit:nt,onCancel:e.unref(i).cancelRequest,onSuggestionSelect:De,onToggleSupportMode:Q},{"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:k.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:o.ui,"confirm-variant":"danger",onConfirm:Wt,onCancel:$[2]||($[2]=G=>k.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),e.createVNode(Jn,{show:e.unref(h),title:e.unref(C),message:e.unref(b),"confirm-text":a("startNewChat"),"cancel-text":e.unref(g)?a("continueChat"):a("cancel"),ui:o.ui,icon:"warning","confirm-variant":"primary",onConfirm:tt,onCancel:e.unref(w)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):e.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-45532662"]]),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(o,{expose:t,emit:n}){const r=o,s=n,a=e.ref(!1),i=e.ref(null);e.onErrorCaptured((u,p,d)=>{var y;return a.value=!0,i.value=u,(y=r.onError)==null||y.call(r,u,d),s("error",u,d),!1});function l(){a.value=!1,i.value=null,s("reset")}return t({hasError:a,error:i,reset:l}),(u,p)=>a.value?e.renderSlot(u.$slots,"error",{key:1,error:i.value,reset:l},()=>{var d,y,k,m,f;return[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-col items-center justify-center p-6 text-center",(d=o.ui)==null?void 0:d.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",(y=o.ui)==null?void 0:y.iconContainer])},[...p[0]||(p[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=o.ui)==null?void 0:k.title])},e.toDisplayString(o.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4",(m=o.ui)==null?void 0:m.message])},e.toDisplayString(o.message),3),o.showRetry?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary/90 transition-colors",(f=o.ui)==null?void 0:f.retryButton]),onClick:l},e.toDisplayString(o.retryText),3)):e.createCommentVNode("",!0)],2)]}):e.renderSlot(u.$slots,"default",{key:0})}}),eo={install(o,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),o.provide("restify-ai-config",n)}};L.AiAvatar=Wn,L.AiChatDrawer=Fa,L.AiEmptyState=Xn,L.ChatInput=Yn,L.ChatMessage=Zn,L.ChatMessageActions=Gn,L.ChatRoles=Re,L.ErrorBoundary=Ua,L.MentionList=Kn,L.RestifyAiPlugin=eo,L.UserAvatar=as,L.default=eo,L.defaultLabels=Et,L.formatMentionsForApi=mn,L.getConfigValue=he,L.getLabel=te,L.getRestifyAiConfig=v,L.getRestifyAiConfigOrThrow=bo,L.getSuggestionsForPath=vn,L.groupMentionsByType=fn,L.isConfigured=Ct,L.registerSuggestionProvider=Qr,L.setRestifyAiConfig=en,L.useAiContext=vt,L.useAiDrawerShortcut=Jr,L.useAiSuggestions=jt,L.useChatErrorHandling=jr,L.useChatMarkdown=Un,L.useChatScroll=vr,L.useKeyboardShortcut=jn,L.useMentionParsing=qo,L.usePageAiContext=Zr,L.useRestifyAiStore=Te,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|