@pillar-ai/sdk 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- const e={actions:new Map,clientInfo:null};function n(n){for(const[t,r]of Object.entries(n))e.actions.has(t)&&console.warn(`[Pillar] Action "${t}" is already registered. Overwriting.`),e.actions.set(t,r);return n}function t(n,t){e.clientInfo={platform:n,version:t}}function r(){return e.clientInfo}function i(n){const t=e.actions.get(n);return t?.handler}function a(n){return e.actions.get(n)}function l(n){return e.actions.has(n)}function o(){return Array.from(e.actions.keys())}function s(n,t,r){const i=[];for(const[n,t]of e.actions){const e={name:n,description:t.description,type:t.type};t.examples?.length&&(e.examples=t.examples),t.path&&(e.path=t.path),t.externalUrl&&(e.external_url=t.externalUrl),t.autoRun&&(e.auto_run=t.autoRun),t.autoComplete&&(e.auto_complete=t.autoComplete),t.returns&&(e.returns_data=t.returns),t.dataSchema&&(e.data_schema=t.dataSchema),t.defaultData&&(e.default_data=t.defaultData),t.requiredContext&&(e.required_context=t.requiredContext),i.push(e)}return{platform:n,version:t,gitSha:r,generatedAt:(new Date).toISOString(),actions:i}}function p(){e.actions.clear(),e.clientInfo=null}function c(){return e.actions.size}class d{constructor(e){this.requestId=0,this.config=e}get baseUrl(){return`${this.config.apiBaseUrl}/mcp/`}get headers(){const e={"Content-Type":"application/json","X-Pillar-Key":this.config.publicKey,"x-customer-id":this.config.helpCenter};return this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}nextId(){return++this.requestId}async callTool(e,n){const t={jsonrpc:"2.0",id:this.nextId(),method:"tools/call",params:{name:e,arguments:n}},r=await fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t)});if(!r.ok){const e=await r.json().catch(()=>({}));throw new Error(e.error?.message||`MCP error: ${r.status}`)}const i=await r.json();if(i.error)throw new Error(i.error.message);return i.result}async callToolStream(e,n,t,r){const i=this.nextId(),a={jsonrpc:"2.0",id:i,method:"tools/call",params:{name:e,arguments:n,stream:!0}},l=await fetch(this.baseUrl,{method:"POST",headers:{...this.headers,Accept:"text/event-stream"},body:JSON.stringify(a),signal:r});if(!l.ok){const e=await l.text();throw new Error(`MCP streaming request failed: ${l.statusText} - ${e}`)}if(!l.body)throw new Error("Response body is null");const o=l.body.getReader(),s=new TextDecoder;let p="",c=[],d=null;try{for(;;){const{done:e,value:n}=await o.read();if(e)break;p+=s.decode(n,{stream:!0});const r=p.split("\n");p=r.pop()||"";for(const e of r)if(e.trim()&&e.startsWith("data: "))try{const n=e.substring(6),r=JSON.parse(n);if("2.0"===r.jsonrpc){if(r.error)throw t.onError?.(r.error.message||"Unknown error"),new Error(r.error.message);if("notifications/progress"===r.method){const e=r.params?.progress;if(e)if("token"===e.kind&&e.token)c.push(e.token),t.onToken?.(e.token);else if("plan_created"===e.kind&&e.plan)t.onPlan?.(e.plan);else{if("cancelled"===e.kind)break;t.onProgress?.(e)}}if(r.result&&r.id===i){d=r.result,d.structuredContent?.sources&&t.onSources?.(d.structuredContent.sources),d.structuredContent?.actions&&t.onActions?.(d.structuredContent.actions),d.structuredContent?.plan&&t.onPlan?.(d.structuredContent.plan);const e=d._meta?.conversation_id,n=d._meta?.query_log_id;t.onComplete?.(e,n)}}}catch(n){console.error("[MCPClient] Failed to parse event:",n,e)}}}catch(e){if("AbortError"===e.name)throw e;throw t.onError?.(e instanceof Error?e.message:"Stream reading failed"),e}finally{o.releaseLock()}return d||(d={content:[{type:"text",text:c.join("")}],isError:!1}),d}async uploadImage(e){const n=`${this.config.apiBaseUrl}/mcp/upload-image/`,t=new FormData;t.append("image",e);const r=await fetch(n,{method:"POST",headers:{"x-customer-id":this.config.helpCenter},body:t});if(!r.ok){const e=await r.json().catch(()=>({error:"Upload failed"}));throw new Error(e.error||"Upload failed")}return r.json()}async ask(e,n,t){const r={query:e};return t?.articleSlug&&(r.article_slug=t.articleSlug),t?.userContext&&t.userContext.length>0&&(r.user_context=t.userContext),t?.images&&t.images.length>0&&(r.images=t.images),this.callToolStream("ask",r,n,t?.signal)}async continuePlan(e,n,t){return await this.callTool("plans/continue",{plan_id:e,step_id:n,result:t})}async cancelPlan(e){return await this.callTool("plans/cancel",{plan_id:e})}async getPlan(e){return await this.callTool("plans/get",{plan_id:e})}async startPlan(e){return await this.callTool("plans/start",{plan_id:e})}async retryStep(e,n){return await this.callTool("plans/retry-step",{plan_id:e,step_id:n})}async failStep(e,n,t){return await this.callTool("plans/fail-step",{plan_id:e,step_id:n,error_message:t||""})}async skipStep(e,n){return await this.callTool("plans/skip-step",{plan_id:e,step_id:n})}sendActionResult(e,n){const t={jsonrpc:"2.0",id:this.nextId(),method:"action/result",params:{action_name:e,result:n}};fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t)}).catch(e=>{console.error("[MCPClient] Failed to send action result:",e)})}}function u(e){return{id:e.id,name:e.name,taskType:e.action_type,data:e.data,autoRun:e.auto_run,autoComplete:e.auto_complete}}class h{constructor(e){this.abortControllers=new Map,this.config=e,this.mcpClient=new d(e)}get baseUrl(){return`${this.config.apiBaseUrl}/api/v1/help-center`}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),n}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_session_id";try{let n=sessionStorage.getItem(e);return n||(n=crypto.randomUUID(),sessionStorage.setItem(e,n)),n}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get headers(){const e={"Content-Type":"application/json","X-Pillar-Key":this.config.publicKey,"x-customer-id":this.config.helpCenter,"x-visitor-id":this.getVisitorId(),"x-session-id":this.getSessionId(),"x-page-url":this.getPageUrl()};return this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}async fetch(e,n={},t){if(t){this.abortControllers.get(t)?.abort();const e=new AbortController;this.abortControllers.set(t,e),n.signal=e.signal}const r=`${this.baseUrl}${e}`;try{const e=await fetch(r,{...n,headers:{...this.headers,...n.headers}});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.detail||n.message||`API error: ${e.status}`)}return e.json()}catch(n){if("AbortError"===n.name)throw n;throw console.error(`[Pillar API] Error fetching ${e}:`,n),n}finally{t&&this.abortControllers.delete(t)}}async fetchEmbedConfig(){try{const e=await fetch(`${this.config.apiBaseUrl}/api/public/products/${this.config.helpCenter}/embed-config/`,{method:"GET",headers:{"Content-Type":"application/json","X-Pillar-Key":this.config.publicKey}});return e.ok?await e.json():(console.warn("[Pillar] Failed to fetch embed config:",e.status),null)}catch(e){return console.warn("[Pillar] Failed to fetch embed config:",e),null}}async getSuggestedQuestions(){try{const e=await this.mcpClient.callTool("suggest_questions",{}),n=e.structuredContent?.questions;return Array.isArray(n)?n:[]}catch(e){return console.warn("[Pillar] Failed to get suggested questions:",e),[]}}async uploadImage(e){return this.mcpClient.uploadImage(e)}async chat(e,n=[],t,r,i,a,l,o,s,p){let c="",d=[],h=[];try{const n=await this.mcpClient.ask(e,{onToken:e=>{c+=e,t?.(e)},onSources:e=>{d=e},onActions:e=>{h=e.map(u),a?.(h)},onPlan:e=>{l?.(e)},onProgress:e=>{p?.(e)},onError:e=>{console.error("[Pillar API] MCP chat error:",e)}},{articleSlug:r,userContext:o,images:s});c||"text"!==n.content[0]?.type||(c=n.content[0].text||"");const i=n._meta||{};return{message:c,sources:d,actions:h,conversationId:i.conversation_id,messageId:i.query_log_id}}catch(e){throw console.error("[Pillar API] Chat error:",e),e}}async chatLegacy(e,n=[],t,r,i){const a=`${this.baseUrl}/ai/chat/`,l=await fetch(a,{method:"POST",headers:this.headers,body:JSON.stringify({message:e,history:n,context:this.config.context,...r&&{article_slug:r},...i&&{conversation_id:i}})});if(!l.ok){const e=await l.json().catch(()=>({}));throw new Error(e.detail||e.message||`Chat error: ${l.status}`)}if(t&&l.headers.get("content-type")?.includes("text/event-stream"))return this.handleStreamingChat(l,t);const o=await l.json();return{message:o.answer||o.message,sources:o.sources,workflow:o.workflow||o.structuredContent?.workflow,conversationId:o.conversation_id,messageId:o.message_id}}async handleStreamingChat(e,n){const t=e.body?.getReader();if(!t)throw new Error("No response body");const r=new TextDecoder;let i,a,l,o="",s=[];try{for(;;){const{done:e,value:p}=await t.read();if(e)break;const c=r.decode(p,{stream:!0}).split("\n");for(const e of c)if(e.startsWith("data: ")){const t=e.slice(6);if("[DONE]"===t)continue;try{const e=JSON.parse(t);e.content&&(o+=e.content,n(e.content)),e.sources&&(s=e.sources),e.workflow&&(i=e.workflow),e.structuredContent?.workflow&&(i=e.structuredContent.workflow),e.conversation_id&&(a=e.conversation_id),e.message_id&&(l=e.message_id)}catch{o+=t,n(t)}}}}finally{t.releaseLock()}return{message:o,sources:s,workflow:i,conversationId:a,messageId:l}}async submitFeedback(e,n,t){try{await this.fetch("/ai/feedback/",{method:"POST",body:JSON.stringify({message_id:e,feedback:n,...t&&{comment:t}})})}catch(e){console.warn("[Pillar] Feedback submission failed:",e)}}async confirmTaskExecution(e,n,t){try{const r={status:n,error:t?.error,duration_ms:t?.duration_ms,session_id:t?.session_id,conversation_id:t?.conversation_id,metadata:t};await this.fetch(`/tasks/${e}/confirm/`,{method:"POST",body:JSON.stringify(r)})}catch(e){console.warn("[Pillar] Failed to confirm task execution:",e)}}async getSuggestions(e,n){try{return(await this.fetch("/suggestions/",{method:"POST",body:JSON.stringify({context:e,user_profile:n})})).suggestions||[]}catch(e){return console.warn("[Pillar] Failed to get suggestions:",e),[]}}async chatWithContext(e,n=[],t,r,i,a,l){let o="",s=[],p=[];try{const n=await this.mcpClient.callToolStream("ask",{query:e,context:{product:t,user_profile:r},...a&&{conversation_id:a}},{onToken:e=>{o+=e,i?.(e)},onSources:e=>{s=e},onActions:e=>{p=e.map(u),l?.(p)},onError:e=>{console.error("[Pillar API] MCP chat with context error:",e)}});o||"text"!==n.content[0]?.type||(o=n.content[0].text||"");const c=n._meta||{};return{message:o,sources:s,actions:p,conversationId:c.conversation_id,messageId:c.query_log_id}}catch(e){throw console.error("[Pillar API] Chat with context error:",e),e}}cancelAllRequests(){this.abortControllers.forEach(e=>e.abort()),this.abortControllers.clear()}}var f,g,_,m,v,b,x,y,k,w,S,C,P,$={},T=[],E=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,z=Array.isArray;function A(e,n){for(var t in n)e[t]=n[t];return e}function I(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function R(e,n,t,r,i){var a={type:e,props:n,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++_:i,__i:-1,__u:0};return null==i&&null!=g.vnode&&g.vnode(a),a}function M(e){return e.children}function B(e,n){this.props=e,this.context=n}function j(e,n){if(null==n)return e.__?j(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e)return t.__e;return"function"==typeof e.type?j(e):null}function L(e){var n,t;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,n=0;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e){e.__e=e.__c.base=t.__e;break}return L(e)}}function H(e){(!e.__d&&(e.__d=!0)&&v.push(e)&&!q.__r++||b!=g.debounceRendering)&&((b=g.debounceRendering)||x)(q)}function q(){for(var e,n,t,r,i,a,l,o=1;v.length;)v.length>o&&v.sort(y),e=v.shift(),o=v.length,e.__d&&(t=void 0,r=void 0,i=(r=(n=e).__v).__e,a=[],l=[],n.__P&&((t=A({},r)).__v=r.__v+1,g.vnode&&g.vnode(t),V(n.__P,t,r,n.__n,n.__P.namespaceURI,32&r.__u?[i]:null,a,null==i?j(r):i,!!(32&r.__u),l),t.__v=r.__v,t.__.__k[t.__i]=t,Z(a,t,l),r.__e=r.__=null,t.__e!=i&&L(t)));q.__r=0}function O(e,n,t,r,i,a,l,o,s,p,c){var d,u,h,f,g,_,m,v=r&&r.__k||T,b=n.length;for(s=function(e,n,t,r,i){var a,l,o,s,p,c=t.length,d=c,u=0;for(e.__k=new Array(i),a=0;a<i;a++)null!=(l=n[a])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[a]=R(null,l,null,null,null):z(l)?l=e.__k[a]=R(M,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[a]=R(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[a]=l,s=a+u,l.__=e,l.__b=e.__b+1,o=null,-1!=(p=l.__i=N(l,t,s,d))&&(d--,(o=t[p])&&(o.__u|=2)),null==o||null==o.__v?(-1==p&&(i>c?u--:i<c&&u++),"function"!=typeof l.type&&(l.__u|=4)):p!=s&&(p==s-1?u--:p==s+1?u++:(p>s?u--:u++,l.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<c;a++)null!=(o=t[a])&&!(2&o.__u)&&(o.__e==r&&(r=j(o)),G(o,o));return r}(t,n,v,s,b),d=0;d<b;d++)null!=(h=t.__k[d])&&(u=-1==h.__i?$:v[h.__i]||$,h.__i=d,_=V(e,h,u,i,a,l,o,s,p,c),f=h.__e,h.ref&&u.ref!=h.ref&&(u.ref&&X(u.ref,null,h),c.push(h.ref,h.__c||f,h)),null==g&&null!=f&&(g=f),(m=!!(4&h.__u))||u.__k===h.__k?s=D(h,s,e,m):"function"==typeof h.type&&void 0!==_?s=_:f&&(s=f.nextSibling),h.__u&=-7);return t.__e=g,s}function D(e,n,t,r){var i,a;if("function"==typeof e.type){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,n=D(i[a],n,t,r));return n}e.__e!=n&&(r&&(n&&e.type&&!n.parentNode&&(n=j(e)),t.insertBefore(e.__e,n||null)),n=e.__e);do{n=n&&n.nextSibling}while(null!=n&&8==n.nodeType);return n}function N(e,n,t,r){var i,a,l,o=e.key,s=e.type,p=n[t],c=null!=p&&!(2&p.__u);if(null===p&&null==o||c&&o==p.key&&s==p.type)return t;if(r>(c?1:0))for(i=t-1,a=t+1;i>=0||a<n.length;)if(null!=(p=n[l=i>=0?i--:a++])&&!(2&p.__u)&&o==p.key&&s==p.type)return l;return-1}function U(e,n,t){"-"==n[0]?e.setProperty(n,null==t?"":t):e[n]=null==t?"":"number"!=typeof t||E.test(n)?t:t+"px"}function F(e,n,t,r,i){var a,l;e:if("style"==n)if("string"==typeof t)e.style.cssText=t;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(n in r)t&&n in t||U(e.style,n,"");if(t)for(n in t)r&&t[n]==r[n]||U(e.style,n,t[n])}else if("o"==n[0]&&"n"==n[1])a=n!=(n=n.replace(k,"$1")),l=n.toLowerCase(),n=l in e||"onFocusOut"==n||"onFocusIn"==n?l.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+a]=t,t?r?t.u=r.u:(t.u=w,e.addEventListener(n,a?C:S,a)):e.removeEventListener(n,a?C:S,a);else{if("http://www.w3.org/2000/svg"==i)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in e)try{e[n]=null==t?"":t;break e}catch(e){}"function"==typeof t||(null==t||!1===t&&"-"!=n[4]?e.removeAttribute(n):e.setAttribute(n,"popover"==n&&1==t?"":t))}}function W(e){return function(n){if(this.l){var t=this.l[n.type+e];if(null==n.t)n.t=w++;else if(n.t<t.u)return;return t(g.event?g.event(n):n)}}}function V(e,n,t,r,i,a,l,o,s,p){var c,d,u,h,_,m,v,b,x,y,k,w,S,C,P,T,E,R=n.type;if(void 0!==n.constructor)return null;128&t.__u&&(s=!!(32&t.__u),a=[o=n.__e=t.__e]),(c=g.__b)&&c(n);e:if("function"==typeof R)try{if(b=n.props,x="prototype"in R&&R.prototype.render,y=(c=R.contextType)&&r[c.__c],k=c?y?y.props.value:c.__:r,t.__c?v=(d=n.__c=t.__c).__=d.__E:(x?n.__c=d=new R(b,k):(n.__c=d=new B(b,k),d.constructor=R,d.render=J),y&&y.sub(d),d.state||(d.state={}),d.__n=r,u=d.__d=!0,d.__h=[],d._sb=[]),x&&null==d.__s&&(d.__s=d.state),x&&null!=R.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=A({},d.__s)),A(d.__s,R.getDerivedStateFromProps(b,d.__s))),h=d.props,_=d.state,d.__v=n,u)x&&null==R.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),x&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(x&&null==R.getDerivedStateFromProps&&b!==h&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(b,k),n.__v==t.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(b,d.__s,k)){for(n.__v!=t.__v&&(d.props=b,d.state=d.__s,d.__d=!1),n.__e=t.__e,n.__k=t.__k,n.__k.some(function(e){e&&(e.__=n)}),w=0;w<d._sb.length;w++)d.__h.push(d._sb[w]);d._sb=[],d.__h.length&&l.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(b,d.__s,k),x&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(h,_,m)})}if(d.context=k,d.props=b,d.__P=e,d.__e=!1,S=g.__r,C=0,x){for(d.state=d.__s,d.__d=!1,S&&S(n),c=d.render(d.props,d.state,d.context),P=0;P<d._sb.length;P++)d.__h.push(d._sb[P]);d._sb=[]}else do{d.__d=!1,S&&S(n),c=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++C<25);d.state=d.__s,null!=d.getChildContext&&(r=A(A({},r),d.getChildContext())),x&&!u&&null!=d.getSnapshotBeforeUpdate&&(m=d.getSnapshotBeforeUpdate(h,_)),T=c,null!=c&&c.type===M&&null==c.key&&(T=Q(c.props.children)),o=O(e,z(T)?T:[T],n,t,r,i,a,l,o,s,p),d.base=n.__e,n.__u&=-161,d.__h.length&&l.push(d),v&&(d.__E=d.__=null)}catch(e){if(n.__v=null,s||null!=a)if(e.then){for(n.__u|=s?160:128;o&&8==o.nodeType&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,n.__e=o}else{for(E=a.length;E--;)I(a[E]);K(n)}else n.__e=t.__e,n.__k=t.__k,e.then||K(n);g.__e(e,n,t)}else null==a&&n.__v==t.__v?(n.__k=t.__k,n.__e=t.__e):o=n.__e=function(e,n,t,r,i,a,l,o,s){var p,c,d,u,h,_,m,v=t.props||$,b=n.props,x=n.type;if("svg"==x?i="http://www.w3.org/2000/svg":"math"==x?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=a)for(p=0;p<a.length;p++)if((h=a[p])&&"setAttribute"in h==!!x&&(x?h.localName==x:3==h.nodeType)){e=h,a[p]=null;break}if(null==e){if(null==x)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),o&&(g.__m&&g.__m(n,a),o=!1),a=null}if(null==x)v===b||o&&e.data==b||(e.data=b);else{if(a=a&&f.call(e.childNodes),!o&&null!=a)for(v={},p=0;p<e.attributes.length;p++)v[(h=e.attributes[p]).name]=h.value;for(p in v)if(h=v[p],"children"==p);else if("dangerouslySetInnerHTML"==p)d=h;else if(!(p in b)){if("value"==p&&"defaultValue"in b||"checked"==p&&"defaultChecked"in b)continue;F(e,p,null,h,i)}for(p in b)h=b[p],"children"==p?u=h:"dangerouslySetInnerHTML"==p?c=h:"value"==p?_=h:"checked"==p?m=h:o&&"function"!=typeof h||v[p]===h||F(e,p,h,v[p],i);if(c)o||d&&(c.__html==d.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),n.__k=[];else if(d&&(e.innerHTML=""),O("template"==n.type?e.content:e,z(u)?u:[u],n,t,r,"foreignObject"==x?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:t.__k&&j(t,0),o,s),null!=a)for(p=a.length;p--;)I(a[p]);o||(p="value","progress"==x&&null==_?e.removeAttribute("value"):null!=_&&(_!==e[p]||"progress"==x&&!_||"option"==x&&_!=v[p])&&F(e,p,_,v[p],i),p="checked",null!=m&&m!=e[p]&&F(e,p,m,v[p],i))}return e}(t.__e,n,t,r,i,a,l,s,p);return(c=g.diffed)&&c(n),128&n.__u?void 0:o}function K(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(K)}function Z(e,n,t){for(var r=0;r<t.length;r++)X(t[r],t[++r],t[++r]);g.__c&&g.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){g.__e(e,n.__v)}})}function Q(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:z(e)?e.map(Q):A({},e)}function X(e,n,t){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==n||(e.__u=e(n))}else e.current=n}catch(e){g.__e(e,t)}}function G(e,n,t){var r,i;if(g.unmount&&g.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||X(r,null,n)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){g.__e(e,n)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&G(r[i],n,t||"function"!=typeof e.type);t||I(e.__e),e.__c=e.__=e.__e=void 0}function J(e,n,t){return this.constructor(e,t)}function Y(e,n,t){var r,i,a;n==document&&(n=document.documentElement),g.__&&g.__(e,n),r=!1?null:n.__k,i=[],a=[],V(n,e=n.__k=function(e,n,t){var r,i,a,l={};for(a in n)"key"==a?r=n[a]:"ref"==a?i=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?f.call(arguments,2):t),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return R(e,l,r,i,null)}(M,null,[e]),r||$,$,n.namespaceURI,r?null:n.firstChild?f.call(n.childNodes):null,i,r?r.__e:n.firstChild,false,a),Z(i,e,a)}f=T.slice,g={__e:function(e,n,t,r){for(var i,a,l;n=n.__;)if((i=n.__c)&&!i.__)try{if((a=i.constructor)&&null!=a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),l=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),l=i.__d),l)return i.__E=i}catch(n){e=n}throw e}},_=0,m=function(e){return null!=e&&void 0===e.constructor},B.prototype.setState=function(e,n){var t;t=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=A({},this.state),"function"==typeof e&&(e=e(A({},t),this.props)),e&&A(t,e),null!=e&&this.__v&&(n&&this._sb.push(n),H(this))},B.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),H(this))},B.prototype.render=M,v=[],x="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,y=function(e,n){return e.__v.__b-n.__v.__b},q.__r=0,k=/(PointerCapture)$|Capture$/i,w=0,S=W(!1),C=W(!0),P=0;var ee=0;function ne(e,n,t,r,i,a){n||(n={});var l,o,s=n;if("ref"in s)for(o in s={},n)"ref"==o?l=n[o]:s[o]=n[o];var p={type:e,props:s,key:t,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ee,__i:-1,__u:0,__source:i,__self:a};if("function"==typeof e&&(l=e.defaultProps))for(o in l)void 0===s[o]&&(s[o]=l[o]);return g.vnode&&g.vnode(p),p}var te,re,ie,ae,le=0,oe=[],se=g,pe=se.__b,ce=se.__r,de=se.diffed,ue=se.__c,he=se.unmount,fe=se.__;function ge(e,n){se.__h&&se.__h(re,e,le||n),le=0;var t=re.__H||(re.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function _e(e){return le=1,function(e,n){var t=ge(te++,2);if(t.t=e,!t.__c&&(t.__=[$e(void 0,n),function(e){var n=t.__N?t.__N[0]:t.__[0],r=t.t(n,e);n!==r&&(t.__N=[r,t.__[1]],t.__c.setState({}))}],t.__c=re,!re.__f)){var r=function(e,n,r){if(!t.__c.__H)return!0;var a=t.__c.__H.__.filter(function(e){return!!e.__c});if(a.every(function(e){return!e.__N}))return!i||i.call(this,e,n,r);var l=t.__c.props!==e;return a.forEach(function(e){if(e.__N){var n=e.__[0];e.__=e.__N,e.__N=void 0,n!==e.__[0]&&(l=!0)}}),i&&i.call(this,e,n,r)||l};re.__f=!0;var i=re.shouldComponentUpdate,a=re.componentWillUpdate;re.componentWillUpdate=function(e,n,t){if(this.__e){var l=i;i=void 0,r(e,n,t),i=l}a&&a.call(this,e,n,t)},re.shouldComponentUpdate=r}return t.__N||t.__}($e,e)}function me(e,n){var t=ge(te++,3);!se.__s&&Pe(t.__H,n)&&(t.__=e,t.u=n,re.__H.__h.push(t))}function ve(e){return le=5,be(function(){return{current:e}},[])}function be(e,n){var t=ge(te++,7);return Pe(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function xe(e,n){return le=8,be(function(){return e},n)}function ye(){for(var e;e=oe.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Se),e.__H.__h.forEach(Ce),e.__H.__h=[]}catch(n){e.__H.__h=[],se.__e(n,e.__v)}}se.__b=function(e){re=null,pe&&pe(e)},se.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),fe&&fe(e,n)},se.__r=function(e){ce&&ce(e),te=0;var n=(re=e.__c).__H;n&&(ie===re?(n.__h=[],re.__h=[],n.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(n.__h.forEach(Se),n.__h.forEach(Ce),n.__h=[],te=0)),ie=re},se.diffed=function(e){de&&de(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==oe.push(n)&&ae===se.requestAnimationFrame||((ae=se.requestAnimationFrame)||we)(ye)),n.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ie=re=null},se.__c=function(e,n){n.some(function(e){try{e.__h.forEach(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(t){n.some(function(e){e.__h&&(e.__h=[])}),n=[],se.__e(t,e.__v)}}),ue&&ue(e,n)},se.unmount=function(e){he&&he(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(e){try{Se(e)}catch(e){n=e}}),t.__H=void 0,n&&se.__e(n,t.__v))};var ke="function"==typeof requestAnimationFrame;function we(e){var n,t=function(){clearTimeout(r),ke&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(t,35);ke&&(n=requestAnimationFrame(t))}function Se(e){var n=re,t=e.__c;"function"==typeof t&&(e.__c=void 0,t()),re=n}function Ce(e){var n=re;e.__c=e.__(),re=n}function Pe(e,n){return!e||e.length!==n.length||n.some(function(n,t){return n!==e[t]})}function $e(e,n){return"function"==typeof n?n(e):n}var Te=Symbol.for("preact-signals");function Ee(){if(Me>1)Me--;else{for(var e,n=!1;void 0!==Re;){var t=Re;for(Re=void 0,Be++;void 0!==t;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&Oe(t))try{t.c()}catch(t){n||(e=t,n=!0)}t=r}}if(Be=0,Me--,n)throw e}}var ze=void 0;function Ae(e){var n=ze;ze=void 0;try{return e()}finally{ze=n}}var Ie,Re=void 0,Me=0,Be=0,je=0;function Le(e){if(void 0!==ze){var n=e.n;if(void 0===n||n.t!==ze)return n={i:0,S:e,p:ze.s,n:void 0,t:ze,e:void 0,x:void 0,r:n},void 0!==ze.s&&(ze.s.n=n),ze.s=n,e.n=n,32&ze.f&&e.S(n),n;if(-1===n.i)return n.i=0,void 0!==n.n&&(n.n.p=n.p,void 0!==n.p&&(n.p.n=n.n),n.p=ze.s,n.n=void 0,ze.s.n=n,ze.s=n),n}}function He(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function qe(e,n){return new He(e,n)}function Oe(e){for(var n=e.s;void 0!==n;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function De(e){for(var n=e.s;void 0!==n;n=n.n){var t=n.S.n;if(void 0!==t&&(n.r=t),n.S.n=n,n.i=-1,void 0===n.n){e.s=n;break}}}function Ne(e){for(var n=e.s,t=void 0;void 0!==n;){var r=n.p;-1===n.i?(n.S.U(n),void 0!==r&&(r.n=n.n),void 0!==n.n&&(n.n.p=r)):t=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=r}e.s=t}function Ue(e,n){He.call(this,void 0),this.x=e,this.s=void 0,this.g=je-1,this.f=4,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function Fe(e,n){return new Ue(e,n)}function We(e){var n=e.u;if(e.u=void 0,"function"==typeof n){Me++;var t=ze;ze=void 0;try{n()}catch(n){throw e.f&=-2,e.f|=8,Ve(e),n}finally{ze=t,Ee()}}}function Ve(e){for(var n=e.s;void 0!==n;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,We(e)}function Ke(e){if(ze!==this)throw new Error("Out-of-order effect");Ne(this),ze=e,this.f&=-2,8&this.f&&Ve(this),Ee()}function Ze(e,n){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==n?void 0:n.name}function Qe(e,n){var t=new Ze(e,n);try{t.c()}catch(e){throw t.d(),e}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}function Xe(e,n){g[e]=n.bind(null,g[e]||function(){})}function Ge(e){Ie&&Ie(),Ie=e&&e.S()}function Je(e){var n=this,t=e.data,r=function(e){return be(function(){return qe(e)},[])}(t);r.value=t;var i=be(function(){for(var e=n.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return n.__$u.c=function(){var e,t=n.__$u.S(),r=i.value;t(),m(r)||3!==(null==(e=n.base)?void 0:e.nodeType)?(n.__$f|=1,n.setState({})):n.base.data=r},Fe(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Ye(e,n,t,r){var i=n in e&&void 0===e.ownerSVGElement,a=qe(t);return{o:function(e,n){a.value=e,r=n},d:Qe(function(){var t=a.value.value;r[n]!==t&&(r[n]=t,i?e[n]=t:t?e.setAttribute(n,t):e.removeAttribute(n))})}}He.prototype.brand=Te,He.prototype.h=function(){return!0},He.prototype.S=function(e){var n=this,t=this.t;t!==e&&void 0===e.e&&(e.x=t,this.t=e,void 0!==t?t.e=e:Ae(function(){var e;null==(e=n.W)||e.call(n)}))},He.prototype.U=function(e){var n=this;if(void 0!==this.t){var t=e.e,r=e.x;void 0!==t&&(t.x=r,e.e=void 0),void 0!==r&&(r.e=t,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&Ae(function(){var e;null==(e=n.Z)||e.call(n)}))}},He.prototype.subscribe=function(e){var n=this;return Qe(function(){var t=n.value,r=ze;ze=void 0;try{e(t)}finally{ze=r}},{name:"sub"})},He.prototype.valueOf=function(){return this.value},He.prototype.toString=function(){return this.value+""},He.prototype.toJSON=function(){return this.value},He.prototype.peek=function(){var e=ze;ze=void 0;try{return this.value}finally{ze=e}},Object.defineProperty(He.prototype,"value",{get:function(){var e=Le(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Be>100)throw new Error("Cycle detected");this.v=e,this.i++,je++,Me++;try{for(var n=this.t;void 0!==n;n=n.x)n.t.N()}finally{Ee()}}}}),Ue.prototype=new He,Ue.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===je)return!0;if(this.g=je,this.f|=1,this.i>0&&!Oe(this))return this.f&=-2,!0;var e=ze;try{De(this),ze=this;var n=this.x();(16&this.f||this.v!==n||0===this.i)&&(this.v=n,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return ze=e,Ne(this),this.f&=-2,!0},Ue.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var n=this.s;void 0!==n;n=n.n)n.S.S(n)}He.prototype.S.call(this,e)},Ue.prototype.U=function(e){if(void 0!==this.t&&(He.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var n=this.s;void 0!==n;n=n.n)n.S.U(n)}},Ue.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(Ue.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Le(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ze.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var n=this.x();"function"==typeof n&&(this.u=n)}finally{e()}},Ze.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,We(this),De(this),Me++;var e=ze;return ze=this,Ke.bind(this,e)},Ze.prototype.N=function(){2&this.f||(this.f|=2,this.o=Re,Re=this)},Ze.prototype.d=function(){this.f|=8,1&this.f||Ve(this)},Ze.prototype.dispose=function(){this.d()},Je.displayName="_st",Object.defineProperties(He.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Je},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Xe("__b",function(e,n){if("string"==typeof n.type){var t,r=n.props;for(var i in r)if("children"!==i){var a=r[i];a instanceof He&&(t||(n.__np=t={}),t[i]=a,r[i]=a.peek())}}e(n)}),Xe("__r",function(e,n){Ge();var t,r=n.__c;r&&(r.__$f&=-2,void 0===(t=r.__$u)&&(r.__$u=t=function(){var e;return Qe(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),Ge(t),e(n)}),Xe("__e",function(e,n,t,r){Ge(),e(n,t,r)}),Xe("diffed",function(e,n){var t;if(Ge(),"string"==typeof n.type&&(t=n.__e)){var r=n.__np,i=n.props;if(r){var a=t.U;if(a)for(var l in a){var o=a[l];void 0===o||l in r||(o.d(),a[l]=void 0)}else t.U=a={};for(var s in r){var p=a[s],c=r[s];void 0===p?(p=Ye(t,s,c,i),a[s]=p):p.o(c,i)}}}e(n)}),Xe("unmount",function(e,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r)for(var i in t.U=void 0,r){var a=r[i];a&&a.d()}}}else{var l=n.__c;if(l){var o=l.__$u;o&&(l.__$u=void 0,o.d())}}e(n)}),Xe("__h",function(e,n,t,r){(r<3||9===r)&&(n.__$f|=2),e(n,t,r)}),B.prototype.shouldComponentUpdate=function(e,n){var t=this.__$u,r=t&&void 0!==t.s;for(var i in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(r||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var a in e)if("__source"!==a&&e[a]!==this.props[a])return!0;for(var l in this.props)if(!(l in e))return!0;return!1};const en=qe(!1),nn=qe("assistant"),tn=qe("right"),rn=qe("overlay"),an=qe(380),ln=qe(1200),on=qe(!0),sn=qe("undefined"!=typeof window?window.innerWidth:1920);let pn=null;const cn=Fe(()=>{const e=ln.value;return!1!==e&&sn.value<e}),dn=Fe(()=>cn.value?"overlay":rn.value);Fe(()=>{const e=["pillar-panel",`pillar-panel--${tn.value}`];return en.value&&e.push("pillar-panel--open"),e.join(" ")});const un=()=>{en.value=!1,"overlay"===dn.value&&(document.body.style.overflow="")},hn=()=>{en.value=!1,nn.value="assistant",document.body.style.overflow=""};function fn(e,n,t){const r=document.createElement("style");return t&&(r.id=t),r.textContent=n,e instanceof Document?e.head.appendChild(r):e.appendChild(r),r}const gn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',_n={assistant:gn,support:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18v-6a9 9 0 0 1 18 0v6"></path><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"></path></svg>'};function mn({position:e,tabs:n,currentActiveTab:t,onTabClick:r,panelOpen:i,panelWidthPx:a,theme:l}){const o=xe(e=>{r(e)},[r]),s=["pillar-edge-sidebar",`pillar-edge-sidebar--${e}`,"pillar-edge-sidebar--mounted",i&&"pillar-edge-sidebar--panel-open","light"===l&&"pillar-edge-sidebar--light","dark"===l&&"pillar-edge-sidebar--dark"].filter(Boolean).join(" "),p={"--pillar-panel-width":`${a}px`},c=n.filter(e=>e.enabled).sort((e,n)=>e.order-n.order);return ne("div",{class:s,style:p,children:c.map(e=>{return ne("button",{class:["pillar-edge-trigger",i&&t===e.id&&"pillar-edge-trigger--active"].filter(Boolean).join(" "),onClick:()=>o(e.id),"aria-label":e.label||"Help",type:"button",children:[ne("span",{class:"pillar-edge-trigger__icon",dangerouslySetInnerHTML:{__html:(n=e.id,_n[n]||gn)}}),ne("span",{class:"pillar-edge-trigger__label",children:e.label})]},e.id);var n})})}class vn{constructor(e,n,t){this.container=null,this.stylesInjected=!1,this.themeStylesInjected=!1,this._isHidden=!1,this.unsubscribeOpen=null,this.unsubscribeWidth=null,this.unsubscribeHoverMode=null,this.unsubscribeActiveTab=null,this.themeObserver=null,this.currentTheme="light",this.handleTabClick=e=>{(e=>{nn.value=e})(e),en.value||this.onClick(),this.render()},this.config=e,this.onClick=n,this.rootContainer=t||null}getEdgePosition(){return this.config.floatingButton.position.includes("left")?"left":"right"}detectTheme(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}init(){if(this.stylesInjected||(fn(document,"\n/* Sidebar container - always visible, shifts when panel opens */\n.pillar-edge-sidebar {\n position: fixed;\n top: 0;\n bottom: 0;\n width: 48px;\n z-index: 100000;\n display: flex;\n flex-direction: column;\n align-items: center;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n transition: right 0.3s ease, left 0.3s ease;\n}\n\n.pillar-edge-sidebar--right {\n right: 0;\n border-left: 1px solid var(--pillar-border);\n border-right: none;\n}\n\n.pillar-edge-sidebar--left {\n left: 0;\n border-right: 1px solid var(--pillar-border);\n border-left: none;\n}\n\n/* When panel is open, shift the trigger to sit at the panel's outer edge */\n.pillar-edge-sidebar--right.pillar-edge-sidebar--panel-open {\n right: var(--pillar-panel-width, 380px);\n}\n\n.pillar-edge-sidebar--left.pillar-edge-sidebar--panel-open {\n left: var(--pillar-panel-width, 380px);\n}\n\n/* The trigger button - vertical sideways text */\n.pillar-edge-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px 8px;\n margin-top: 8px;\n font-family: var(--pillar-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: background 0.15s ease, color 0.15s ease;\n outline: none;\n gap: 8px;\n writing-mode: vertical-rl;\n text-orientation: mixed;\n}\n\n.pillar-edge-trigger:hover {\n background: var(--pillar-bg-secondary);\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active {\n background: var(--pillar-primary-light, rgba(194, 65, 12, 0.1));\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger:focus-visible {\n background: var(--pillar-bg-secondary);\n box-shadow: 0 0 0 2px var(--pillar-primary);\n}\n\n.pillar-edge-trigger__icon {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n opacity: 0.8;\n}\n\n.pillar-edge-trigger:hover .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger__label {\n white-space: nowrap;\n letter-spacing: 0.5px;\n}\n\n/* Animation on mount */\n@keyframes pillar-sidebar-mount {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n.pillar-edge-sidebar--mounted {\n animation: pillar-sidebar-mount 0.2s ease forwards;\n}\n","pillar-edge-trigger-styles"),this.stylesInjected=!0),!this.themeStylesInjected){const e=function(e,n){const t=e=>{const n=[];return e.primary&&n.push(`--pillar-primary: ${e.primary};`),e.primaryHover&&n.push(`--pillar-primary-hover: ${e.primaryHover};`),e.background&&n.push(`--pillar-bg: ${e.background};`),e.backgroundSecondary&&n.push(`--pillar-bg-secondary: ${e.backgroundSecondary};`),e.text&&n.push(`--pillar-text: ${e.text};`),e.textMuted&&n.push(`--pillar-text-muted: ${e.textMuted};`),e.border&&n.push(`--pillar-border: ${e.border};`),e.borderLight&&n.push(`--pillar-border-light: ${e.borderLight};`),n.join("\n ")},r=t(e),i=t(n);let a="";return r&&(a+=`\n.pillar-edge-sidebar,\n.pillar-edge-sidebar--light {\n ${r}\n}\n`),i&&(a+=`\n.pillar-edge-sidebar--dark {\n ${i}\n}\n`),a}(this.config.theme.colors,this.config.theme.darkColors);e&&fn(document,e,"pillar-edge-trigger-theme"),this.themeStylesInjected=!0}this.container=document.createElement("div"),this.container.id="pillar-edge-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.currentTheme=this.detectTheme(),this.applyLayoutPadding(),this.render(),this.unsubscribeOpen=en.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeWidth=an.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeHoverMode=cn.subscribe(()=>{queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeActiveTab=nn.subscribe(()=>{this.render()}),this.themeObserver=new MutationObserver(()=>{const e=this.detectTheme();e!==this.currentTheme&&(this.currentTheme=e,this.render())}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]})}applyLayoutPadding(){if(this._isHidden)return;const e=this.getEdgePosition(),n=an.value,t=cn.value;let r=48;en.value&&!t&&(r=n+48),document.documentElement.style.transition="padding 0.3s ease","right"===e?document.documentElement.style.paddingRight=`${r}px`:document.documentElement.style.paddingLeft=`${r}px`}removeLayoutPadding(){"right"===this.getEdgePosition()?document.documentElement.style.paddingRight="":document.documentElement.style.paddingLeft=""}setOpen(e){this.render()}show(){this._isHidden=!1,this.container&&(this.container.style.display=""),this.applyLayoutPadding()}hide(){this._isHidden=!0,this.container&&(this.container.style.display="none"),this.removeLayoutPadding()}setPosition(e){this.removeLayoutPadding(),this.config.floatingButton.position=e,this.applyLayoutPadding(),this.render()}setLabel(e){this.config.floatingButton.label=e,this.render()}destroy(){this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.unsubscribeWidth?.(),this.unsubscribeWidth=null,this.unsubscribeHoverMode?.(),this.unsubscribeHoverMode=null,this.unsubscribeActiveTab?.(),this.unsubscribeActiveTab=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.removeLayoutPadding(),this.container&&(Y(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-edge-trigger-styles")?.remove(),document.getElementById("pillar-edge-trigger-theme")?.remove(),this.stylesInjected=!1,this.themeStylesInjected=!1}render(){if(!this.container||this._isHidden)return;Y(ne(mn,{position:this.getEdgePosition(),tabs:this.config.sidebarTabs,currentActiveTab:nn.value,onTabClick:this.handleTabClick,panelOpen:en.value,panelWidthPx:an.value,theme:this.currentTheme}),this.container)}}function bn({position:e,label:n,onClick:t,panelOpen:r}){const i=xe(()=>{t()},[t]),a=r?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>';return ne("button",{class:["pillar-floating-button",`pillar-floating-button--${e}`,"pillar-floating-button--mounted",!n&&"pillar-floating-button--icon-only"].filter(Boolean).join(" "),onClick:i,"aria-label":n||"Help",type:"button",children:[ne("span",{class:"pillar-floating-button__icon",dangerouslySetInnerHTML:{__html:a}}),n&&ne("span",{class:"pillar-floating-button__label",children:n})]})}class xn{constructor(e,n){this.container=null,this.stylesInjected=!1,this._isHidden=!1,this.config=e,this.onClick=n}init(){this.stylesInjected||(fn(document,"\n.pillar-floating-button {\n position: fixed;\n z-index: 99998;\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 0 20px;\n height: 48px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 15px;\n font-weight: 500;\n color: #ffffff;\n background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);\n border: none;\n border-radius: 24px;\n cursor: pointer;\n box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4), 0 2px 6px rgba(0, 0, 0, 0.1);\n transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;\n outline: none;\n}\n\n.pillar-floating-button:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);\n}\n\n.pillar-floating-button:active {\n transform: translateY(0);\n box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3), 0 1px 4px rgba(0, 0, 0, 0.1);\n}\n\n.pillar-floating-button:focus-visible {\n box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4), 0 0 0 3px rgba(37, 99, 235, 0.3);\n}\n\n.pillar-floating-button--icon-only {\n width: 56px;\n height: 56px;\n padding: 0;\n border-radius: 28px;\n justify-content: center;\n}\n\n.pillar-floating-button__icon {\n width: 22px;\n height: 22px;\n flex-shrink: 0;\n}\n\n.pillar-floating-button__label {\n white-space: nowrap;\n}\n\n/* Positions */\n.pillar-floating-button--bottom-right {\n bottom: 24px;\n right: 24px;\n}\n\n.pillar-floating-button--bottom-left {\n bottom: 24px;\n left: 24px;\n}\n\n.pillar-floating-button--top-right {\n top: 24px;\n right: 24px;\n}\n\n.pillar-floating-button--top-left {\n top: 24px;\n left: 24px;\n}\n\n/* Hidden state when panel is open */\n.pillar-floating-button--hidden {\n transform: scale(0.8);\n opacity: 0;\n pointer-events: none;\n}\n\n/* Animation on mount */\n@keyframes pillar-button-mount {\n from {\n transform: scale(0.8);\n opacity: 0;\n }\n to {\n transform: scale(1);\n opacity: 1;\n }\n}\n\n.pillar-floating-button--mounted {\n animation: pillar-button-mount 0.3s ease forwards;\n}\n","pillar-floating-button-styles"),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-floating-button-container",document.body.appendChild(this.container),this.render(),en.subscribe(()=>{this.render()})}setOpen(e){this.render()}show(){this._isHidden=!1,this.container&&(this.container.style.display="")}hide(){this._isHidden=!0,this.container&&(this.container.style.display="none")}setPosition(e){this.config.floatingButton.position=e,this.render()}setLabel(e){this.config.floatingButton.label=e,this.render()}destroy(){this.container&&(Y(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-floating-button-styles")?.remove(),this.stylesInjected=!1}render(){if(!this.container||this._isHidden)return;const{position:e,label:n}=this.config.floatingButton;Y(ne(bn,{position:e,label:n,onClick:this.onClick,panelOpen:en.value}),this.container)}}function yn(e){return"highlighted_text"===e.type}const kn=qe([]),wn=qe(null),Sn=qe(!1),Cn=qe({kind:null}),Pn=qe(!1),$n=qe([]),Tn=qe([]),En=qe(""),zn=qe(null),An=qe(0),In=qe([]),Rn=qe([]),Mn=qe([]),Bn=Fe(()=>Mn.value.some(e=>"uploading"===e.status)),jn=(e,n,t,r)=>{Mn.value=Mn.value.map(i=>i.id===e?{...i,status:n,url:t,error:r}:i)},Ln=()=>{Mn.value.forEach(e=>URL.revokeObjectURL(e.preview)),Mn.value=[]};Fe(()=>kn.value.length>0);const Hn=(e,n,t,r)=>{const i=kn.value;if(i.length>0&&"assistant"===i[i.length-1].role){const a=i[i.length-1];kn.value=[...i.slice(0,-1),{role:"assistant",content:e,id:n??a.id,actions:t??a.actions,sources:r??a.sources,actionStatus:a.actionStatus}]}},qn=e=>{Sn.value=e},On=e=>{zn.value=e},Dn=()=>{An.value+=1},Nn=e=>{In.value=In.value.filter(n=>n.id!==e)},Un=()=>{kn.value=[],wn.value=null,Sn.value=!1,Cn.value={kind:null},Pn.value=!1,$n.value=[],Tn.value=[],En.value="",zn.value=null,In.value=[],Rn.value=[],Ln()},Fn=qe([]),Wn=qe({type:"home"}),Vn=Fe(()=>Fn.value.length>0),Kn=Fe(()=>"home"===Wn.value.type),Zn=(e,n)=>{Fn.value=[...Fn.value,{...Wn.value}],Wn.value={type:e,params:n}},Qn=()=>{const e=Fn.value;if(e.length>0){"chat"===Wn.value.type&&Un();const n=e[e.length-1];Wn.value=n,Fn.value=e.slice(0,-1)}},Xn=()=>{"chat"===Wn.value.type&&Un(),Fn.value=[],Wn.value={type:"home"}},Gn=()=>{Fn.value=[],Wn.value={type:"home"}},Jn=()=>{Zn("chat")},Yn='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20,6 9,17 4,12"/></svg>',et='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>';function nt(e){return e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function tt(e,n){const t=document.createElement("div");t.className="pillar-confirm-card";const r=nt(e.data?.card_type||e.name),i=e.data||{};let a="idle",l="";const o=()=>{if("success"!==a){if("error"===a)return t.innerHTML=`\n <div class="pillar-confirm-card__content">\n <div class="pillar-confirm-card__header">\n <span class="pillar-confirm-card__title">${r}</span>\n </div>\n <div class="pillar-confirm-card__error">\n <span>${l||"An error occurred"}</span>\n </div>\n <div class="pillar-confirm-card__actions">\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--secondary js-cancel">\n ${et} Dismiss\n </button>\n </div>\n </div>\n `,void t.querySelector(".js-cancel")?.addEventListener("click",n.onCancel);t.innerHTML=`\n <div class="pillar-confirm-card__content">\n <div class="pillar-confirm-card__header">\n <span class="pillar-confirm-card__title">${r}</span>\n </div>\n ${function(e){const n=Object.entries(e).filter(([e])=>"card_type"!==e).slice(0,5);return 0===n.length?"":`\n <div class="pillar-confirm-card__data">\n ${n.map(([e,n])=>{const t=Array.isArray(n)?n.join(", "):String(n);return`\n <div class="pillar-confirm-card__data-row">\n <span class="pillar-confirm-card__data-key">${nt(e)}:</span>\n <span class="pillar-confirm-card__data-value">${t}</span>\n </div>\n `}).join("")}\n </div>\n `}(i)}\n <div class="pillar-confirm-card__actions">\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--secondary js-cancel" ${"loading"===a?"disabled":""}>\n ${et} Cancel\n </button>\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--primary js-confirm" ${"loading"===a?"disabled":""}>\n ${"loading"===a?'<span class="pillar-confirm-card__spinner"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/><line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/><line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/><line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/></svg></span>':Yn} \n ${"loading"===a?"Processing...":"Confirm"}\n </button>\n </div>\n </div>\n `,t.querySelector(".js-cancel")?.addEventListener("click",n.onCancel),t.querySelector(".js-confirm")?.addEventListener("click",()=>{n.onConfirm(i)})}else t.innerHTML=`\n <div class="pillar-confirm-card__success">\n <span class="pillar-confirm-card__success-icon">${Yn}</span>\n <span>Completed</span>\n </div>\n `};if(o(),n.onStateChange){const e=n.onStateChange;n.onStateChange=(n,t)=>{"loading"===n?a="loading":"success"===n?a="success":"error"===n&&(a="error",l=t||""),o(),e(n,t)}}return t}const rt="\n/* Confirm Action Card */\n.pillar-confirm-card-wrapper {\n margin-top: 12px;\n}\n\n.pillar-confirm-card {\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n overflow: hidden;\n}\n\n.pillar-confirm-card__content {\n padding: 16px;\n}\n\n.pillar-confirm-card__header {\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__title {\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #111827);\n}\n\n.pillar-confirm-card__data {\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__data-row {\n display: flex;\n gap: 8px;\n font-size: 13px;\n margin-bottom: 4px;\n}\n\n.pillar-confirm-card__data-row:last-child {\n margin-bottom: 0;\n}\n\n.pillar-confirm-card__data-key {\n color: var(--pillar-text-secondary, #6b7280);\n flex-shrink: 0;\n}\n\n.pillar-confirm-card__data-value {\n color: var(--pillar-text-primary, #111827);\n word-break: break-word;\n}\n\n.pillar-confirm-card__actions {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n}\n\n.pillar-confirm-card__btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n}\n\n.pillar-confirm-card__btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.pillar-confirm-card__btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-confirm-card__btn--primary {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border-color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-confirm-card__btn--primary:hover:not(:disabled) {\n background: var(--pillar-primary-hover, #1d4ed8);\n border-color: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-confirm-card__btn--secondary {\n background: var(--pillar-bg-primary, #ffffff);\n color: var(--pillar-text-secondary, #6b7280);\n border-color: var(--pillar-border, #e5e7eb);\n}\n\n.pillar-confirm-card__btn--secondary:hover:not(:disabled) {\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n.pillar-confirm-card__success {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px;\n color: #059669;\n font-weight: 500;\n}\n\n.pillar-confirm-card__success-icon svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-confirm-card__error {\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n color: #dc2626;\n font-size: 13px;\n}\n\n.pillar-confirm-card__spinner {\n display: inline-flex;\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n",it=function(e){function n(e){var t,r;return this.getChildContext||(t=new Set,(r={})[n.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){t=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&t.forEach(function(e){e.__e=!0,H(e)})},this.sub=function(e){t.add(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){t&&t.delete(e),n&&n.call(e)}}),e.children}return n.__c="__cC"+P++,n.__=e,n.Provider=n.__l=(n.Consumer=function(e,n){return e.children(n)}).contextType=n,n}(null);function at({api:e,events:n,children:t}){return ne(it.Provider,{value:{api:e,events:n},children:t})}function lt(){const e=function(e){var n=re.context[e.__c],t=ge(te++,9);return t.c=e,n?(null==t.__&&(t.__=!0,n.sub(re)),n.props.value):e.__}(it);if(!e)throw new Error("usePillar must be used within a PillarProvider");return e}function ot(){return lt().api}const st="\n/* Inline Plan Container */\n.pillar-inline-plan {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 8px 0;\n}\n\n/* Steps list */\n.pillar-inline-plan__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Individual step */\n.pillar-inline-plan__step {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 4px 8px;\n border-radius: 6px;\n font-size: 13px;\n background: transparent;\n transition: all 0.15s ease;\n}\n\n.pillar-inline-plan__step-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-inline-plan__step-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n\n.pillar-inline-plan__step-text {\n color: var(--pillar-text-primary, #374151);\n line-height: 1.4;\n}\n\n.pillar-inline-plan__step-instruction {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-wrap: wrap;\n}\n\n.pillar-inline-plan__action-badge {\n display: inline-block;\n padding: 1px 5px;\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n background: var(--pillar-warning, #f59e0b);\n color: white;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n.pillar-inline-plan__instruction-text {\n font-size: 11px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-inline-plan__step-actions {\n display: flex;\n gap: 4px;\n}\n\n/* Step states */\n.pillar-inline-plan__step--pending {\n opacity: 0.6;\n}\n\n.pillar-inline-plan__step--ready .pillar-inline-plan__step-icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-inline-plan__step--awaiting_confirmation {\n background: var(--pillar-bg-warning-subtle, rgba(251, 191, 36, 0.1));\n}\n\n.pillar-inline-plan__step--awaiting_confirmation .pillar-inline-plan__step-icon {\n color: var(--pillar-warning-dark, #d97706);\n}\n\n.pillar-inline-plan__step--executing .pillar-inline-plan__step-icon,\n.pillar-inline-plan__step--awaiting_result .pillar-inline-plan__step-icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-inline-plan__step--completed .pillar-inline-plan__step-icon {\n color: var(--pillar-success, #059669);\n}\n\n.pillar-inline-plan__step--completed .pillar-inline-plan__step-text {\n text-decoration: line-through;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-inline-plan__step--skipped {\n opacity: 0.5;\n}\n\n.pillar-inline-plan__step--skipped .pillar-inline-plan__step-text {\n text-decoration: line-through;\n}\n\n.pillar-inline-plan__step--failed {\n background: var(--pillar-bg-danger-subtle, rgba(220, 38, 38, 0.1));\n}\n\n.pillar-inline-plan__step--failed .pillar-inline-plan__step-icon {\n color: var(--pillar-danger, #dc2626);\n}\n\n/* Buttons */\n.pillar-inline-plan__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 3px 8px;\n font-size: 11px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 4px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: none;\n}\n\n.pillar-inline-plan__btn--confirm {\n background: var(--pillar-success, #059669);\n color: #ffffff;\n min-width: 24px;\n}\n\n.pillar-inline-plan__btn--confirm:hover {\n background: var(--pillar-success-hover, #047857);\n}\n\n.pillar-inline-plan__btn--skip {\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n}\n\n.pillar-inline-plan__btn--skip:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n}\n\n.pillar-inline-plan__btn--retry {\n background: var(--pillar-danger, #dc2626);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--retry:hover {\n background: var(--pillar-danger-hover, #b91c1c);\n}\n\n.pillar-inline-plan__btn--done {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--done:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-inline-plan__btn--start {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--start:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-inline-plan__btn--cancel {\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n}\n\n.pillar-inline-plan__btn--cancel:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-danger, #dc2626);\n border-color: var(--pillar-danger, #dc2626);\n}\n\n/* Footer */\n.pillar-inline-plan__footer {\n display: flex;\n gap: 8px;\n padding-top: 6px;\n}\n\n/* Status messages */\n.pillar-inline-plan__status {\n font-size: 12px;\n font-weight: 500;\n padding: 4px 8px;\n border-radius: 4px;\n}\n\n.pillar-inline-plan__status--success {\n color: var(--pillar-success, #059669);\n background: var(--pillar-bg-success-subtle, rgba(5, 150, 105, 0.1));\n}\n\n.pillar-inline-plan__status--error {\n color: var(--pillar-danger, #dc2626);\n background: var(--pillar-bg-danger-subtle, rgba(220, 38, 38, 0.1));\n}\n\n.pillar-inline-plan__status--cancelled {\n color: var(--pillar-text-tertiary, #9ca3af);\n background: var(--pillar-bg-tertiary, #f3f4f6);\n}\n\n/* Spinner animation */\n@keyframes pillar-inline-plan-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.pillar-inline-plan__spinner {\n animation: pillar-inline-plan-spin 1s linear infinite;\n}\n",pt={pending:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/></svg>',ready:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="4" fill="currentColor"/></svg>',awaiting_confirmation:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',executing:'<svg class="pillar-plan-step__spinner" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/></svg>',awaiting_result:'<svg class="pillar-plan-step__spinner" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/></svg>',completed:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="9,12 12,15 16,10"/></svg>',skipped:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" stroke-dasharray="4,2"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',failed:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>'};function ct(e){switch(e){case"pending":default:return pt.pending;case"ready":return pt.ready;case"awaiting_confirmation":return pt.awaiting_confirmation;case"executing":return pt.executing;case"awaiting_result":return pt.awaiting_result;case"completed":return pt.completed;case"skipped":return pt.skipped;case"failed":return pt.failed}}function dt({step:e,onConfirm:n,onSkip:t,onRetry:r,onDone:i}){"ready"===e.status||"executing"===e.status||"awaiting_confirmation"===e.status||e.status;const a="failed"===e.status&&e.is_retriable&&e.retry_count<e.max_retries;return ne("div",{class:`pillar-plan-step pillar-plan-step--${e.status}`,children:[ne("div",{class:"pillar-plan-step__icon",children:ne("span",{dangerouslySetInnerHTML:{__html:ct(e.status)}})}),ne("div",{class:"pillar-plan-step__content",children:[ne("div",{class:"pillar-plan-step__description",children:e.description}),"awaiting_confirmation"===e.status&&ne("div",{class:"pillar-plan-step__actions",children:[ne("button",{type:"button",class:"pillar-plan-step__confirm-btn",onClick:()=>{n(e.id)},children:"Confirm"}),ne("button",{type:"button",class:"pillar-plan-step__skip-btn",onClick:()=>{t(e.id)},children:"Skip"})]}),"executing"===e.status&&ne("div",{class:"pillar-plan-step__status-text",children:"Running..."}),"awaiting_result"===e.status&&ne("div",{class:"pillar-plan-step__awaiting-container",children:[ne("div",{class:"pillar-plan-step__instruction-row",children:[ne("span",{class:"pillar-plan-step__action-badge",children:"In Progress"}),ne("span",{class:"pillar-plan-step__instruction",children:"Complete this step to continue"})]}),ne("button",{type:"button",class:"pillar-plan-step__done-btn",onClick:()=>{i?.(e.id)},children:"Done"})]}),"failed"===e.status&&ne("div",{class:"pillar-plan-step__error-container",children:[e.error_message&&ne("div",{class:"pillar-plan-step__error",children:e.error_message}),a&&ne("div",{class:"pillar-plan-step__retry-info",children:[ne("span",{class:"pillar-plan-step__retry-count",children:["Attempt ",e.retry_count+1," of ",e.max_retries+1]}),ne("button",{type:"button",class:"pillar-plan-step__retry-btn",onClick:()=>{r?.(e.id)},children:"Retry"})]}),!a&&e.retry_count>=e.max_retries&&ne("div",{class:"pillar-plan-step__retry-exhausted",children:"All retry attempts exhausted"})]})]})]})}const ut="\n/* Individual Step */\n.pillar-plan-step {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step__icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-plan-step__content {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.pillar-plan-step__description {\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-primary, #374151);\n line-height: 1.4;\n}\n\n.pillar-plan-step__status-text {\n font-size: 12px;\n color: var(--pillar-primary, #2563eb);\n font-style: italic;\n}\n\n.pillar-plan-step__error {\n font-size: 12px;\n color: var(--pillar-danger, #dc2626);\n}\n\n.pillar-plan-step__actions {\n display: flex;\n gap: 8px;\n margin-top: 4px;\n}\n\n/* Step States */\n.pillar-plan-step--pending {\n opacity: 0.6;\n}\n\n.pillar-plan-step--ready {\n background: var(--pillar-bg-info-subtle, #eff6ff);\n border-color: var(--pillar-info, #93c5fd);\n}\n\n.pillar-plan-step--ready .pillar-plan-step__icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-plan-step--awaiting_confirmation {\n background: var(--pillar-bg-warning-subtle, #fef3c7);\n border-color: var(--pillar-warning, #fcd34d);\n}\n\n.pillar-plan-step--awaiting_confirmation .pillar-plan-step__icon {\n color: var(--pillar-warning-dark, #d97706);\n}\n\n.pillar-plan-step--executing,\n.pillar-plan-step--awaiting_result {\n background: var(--pillar-bg-info-subtle, #eff6ff);\n border-color: var(--pillar-info, #93c5fd);\n}\n\n.pillar-plan-step--executing .pillar-plan-step__icon,\n.pillar-plan-step--awaiting_result .pillar-plan-step__icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-plan-step--completed .pillar-plan-step__icon {\n color: var(--pillar-success, #059669);\n}\n\n.pillar-plan-step--completed .pillar-plan-step__description {\n text-decoration: line-through;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-plan-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-plan-step--skipped .pillar-plan-step__icon {\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step--skipped .pillar-plan-step__description {\n text-decoration: line-through;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step--failed {\n background: var(--pillar-bg-danger-subtle, #fef2f2);\n border-color: var(--pillar-danger-light, #fca5a5);\n}\n\n.pillar-plan-step--failed .pillar-plan-step__icon {\n color: var(--pillar-danger, #dc2626);\n}\n\n/* Error Container */\n.pillar-plan-step__error-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.pillar-plan-step__retry-info {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-top: 2px;\n}\n\n.pillar-plan-step__retry-count {\n font-size: 11px;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step__retry-exhausted {\n font-size: 11px;\n color: var(--pillar-text-tertiary, #9ca3af);\n font-style: italic;\n margin-top: 2px;\n}\n\n/* Retry Button */\n.pillar-plan-step__retry-btn {\n display: inline-flex;\n align-items: center;\n padding: 4px 10px;\n font-size: 11px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-danger, #dc2626);\n color: #ffffff;\n border: none;\n border-radius: 5px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__retry-btn:hover {\n background: var(--pillar-danger-hover, #b91c1c);\n}\n\n/* Confirm Button */\n.pillar-plan-step__confirm-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__confirm-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Skip Button */\n.pillar-plan-step__skip-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__skip-btn:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-text-primary, #374151);\n}\n\n/* Awaiting Result Container */\n.pillar-plan-step__awaiting-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.pillar-plan-step__instruction-row {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.pillar-plan-step__action-badge {\n display: inline-block;\n padding: 2px 6px;\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n background: var(--pillar-warning, #f59e0b);\n color: white;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n.pillar-plan-step__instruction {\n font-size: 12px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n/* Done Button */\n.pillar-plan-step__done-btn {\n display: inline-flex;\n align-items: center;\n align-self: flex-start;\n padding: 6px 14px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__done-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Spinner Animation for Executing Step */\n@keyframes pillar-plan-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n.pillar-plan-step__spinner {\n animation: pillar-plan-spin 1s linear infinite;\n}\n",ht=qe(null),ft=qe([]),gt=Fe(()=>null!==ht.value);Fe(()=>ht.value&&ht.value.steps.find(e=>"ready"===e.status||"executing"===e.status||"awaiting_confirmation"===e.status)||null),Fe(()=>ht.value?ht.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);const _t=Fe(()=>ht.value&&0!==ht.value.total_steps?ht.value.completed_steps/ht.value.total_steps:0);function mt(e){ht.value&&(ft.value=[...ft.value,ht.value]),ht.value=e}function vt(e){ht.value=e}function bt(e,n){if(!ht.value)return;const t=ht.value.steps.map(t=>t.id===e?{...t,...n}:t);let r=ht.value.completed_steps;"completed"===n.status&&(r=t.filter(e=>"completed"===e.status).length),ht.value={...ht.value,steps:t,completed_steps:r}}function xt(e=!0){ht.value&&e&&(ft.value=[...ft.value,ht.value]),ht.value=null}Fe(()=>"awaiting_start"===ht.value?.status);const yt={plan:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/></svg>'};function kt(){const e=ht.value;if(!e)return null;const n="awaiting_start"===e.status,t="executing"===e.status,r=_t.value,i=Ri.getInstance(),a=(e,n)=>{i?.confirmPlanStep(e,n)},l=e=>{i?.skipPlanStep(e)},o=e=>{i?.retryPlanStep(e)},s=e=>{i?.markPlanStepDone(e)};return ne("div",{class:"pillar-plan",children:[ne("div",{class:"pillar-plan__header",children:[ne("div",{class:"pillar-plan__icon",children:ne("span",{dangerouslySetInnerHTML:{__html:yt.plan}})}),ne("div",{class:"pillar-plan__title",children:e.goal}),ne("div",{class:"pillar-plan__progress",children:[e.completed_steps,"/",e.total_steps]})]}),t&&ne("div",{class:"pillar-plan__progress-bar",children:ne("div",{class:"pillar-plan__progress-fill",style:{width:100*r+"%"}})}),ne("div",{class:"pillar-plan__steps",children:e.steps.map(e=>ne(dt,{step:e,onConfirm:a,onSkip:l,onRetry:o,onDone:s},e.id))}),ne("div",{class:"pillar-plan__footer",children:[n&&ne("button",{type:"button",class:"pillar-plan__start-btn",onClick:()=>{i?.startPlan()},children:"Start Plan"}),ne("button",{type:"button",class:"pillar-plan__cancel-btn",onClick:()=>{i?.cancelPlan()},children:"Cancel"})]})]})}const wt="\n/* Plan Container */\n.pillar-plan {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n margin: 12px 0;\n}\n\n/* Header */\n.pillar-plan__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.pillar-plan__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-plan__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #1a1a1a);\n line-height: 1.4;\n}\n\n.pillar-plan__progress {\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n padding: 2px 8px;\n background: var(--pillar-bg-tertiary, #e5e7eb);\n border-radius: 10px;\n}\n\n/* Progress Bar */\n.pillar-plan__progress-bar {\n height: 4px;\n background: var(--pillar-bg-tertiary, #e5e7eb);\n border-radius: 2px;\n overflow: hidden;\n}\n\n.pillar-plan__progress-fill {\n height: 100%;\n background: var(--pillar-primary, #2563eb);\n border-radius: 2px;\n transition: width 0.3s ease;\n}\n\n/* Steps List */\n.pillar-plan__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Footer */\n.pillar-plan__footer {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n padding-top: 8px;\n border-top: 1px solid var(--pillar-border, #e5e7eb);\n}\n\n/* Start Button */\n.pillar-plan__start-btn {\n display: inline-flex;\n align-items: center;\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan__start-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Cancel Button */\n.pillar-plan__cancel-btn {\n display: inline-flex;\n align-items: center;\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan__cancel-btn:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-danger, #dc2626);\n border-color: var(--pillar-danger, #dc2626);\n}\n",St={home:"Assistant",chat:"Assistant"};function Ct({currentView:e,customTitle:n,hideNavigation:t=!1}){const r=!t&&Vn.value,i=!t&&!Kn.value,a=n||St[e];return ne("header",{class:"_pillar-header pillar-header",children:[ne("div",{class:"_pillar-header-left pillar-header-left",children:[r&&ne("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-back-btn",onClick:()=>{Qn()},"aria-label":"Go back",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd"/></svg>'}}),i&&ne("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-home-btn",onClick:()=>{Xn()},"aria-label":"Go to home",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/></svg>'}}),ne("span",{class:"_pillar-header-title pillar-header-title",children:a})]}),ne("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-close-btn",onClick:()=>{un()},"aria-label":"Close assistant panel",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/></svg>'}})]})}const Pt='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M4.583 17.321C3.553 16.227 3 15 3 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179zm10 0C13.553 16.227 13 15 13 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179z"/></svg>';function $t({context:e,onRemove:n,readOnly:t=!1}){const r="highlighted_text"===(i=e).type?i.text_content.length>40?i.text_content.substring(0,40)+"...":i.text_content:"Context";var i;const a=function(e){return yn(e),Pt}(e),l=function(e){if(yn(e)){const n=e.url_origin?`\nFrom: ${e.url_origin}`:"";return`"${e.text_content}"${n}`}return""}(e);return ne("div",{class:"_pillar-context-tag pillar-context-tag",title:l,children:[ne("span",{class:"_pillar-context-tag-icon pillar-context-tag-icon",dangerouslySetInnerHTML:{__html:a}}),ne("span",{class:"_pillar-context-tag-label pillar-context-tag-label",children:r}),!t&&n&&ne("button",{class:"_pillar-context-tag-remove pillar-context-tag-remove",onClick:t=>{t.preventDefault(),t.stopPropagation(),n?.(e.id)},"aria-label":"Remove context",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]})}function Tt({contexts:e,onRemove:n,readOnly:t=!1}){return 0===e.length?null:ne("div",{class:"_pillar-context-tag-list pillar-context-tag-list",children:e.map(e=>ne($t,{context:e,onRemove:n,readOnly:t},e.id))})}const Et='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>';function zt({placeholder:e="Ask anything...",disabled:n=!1,onSubmit:t,showContextTags:r=!0,showImageUpload:i=!0,className:a=""}){const l=ot(),o=ve(null),s=ve(null),[p,c]=_e(""),[d,u]=_e(!1),h=xe(()=>{const e=o.current;if(!e)return;e.style.height="41px";const n=e.scrollHeight;n>146?(e.style.height="146px",e.style.overflowY="auto"):(e.style.height=`${n}px`,e.style.overflowY="hidden")},[]),f=xe(async e=>{if(Mn.value.length>=4)return;const n=`img-${Date.now()}-${Math.random().toString(36).slice(2)}`,t=URL.createObjectURL(e);var r;r={id:n,file:e,preview:t,status:"uploading"},Mn.value.length>=4||(Mn.value=[...Mn.value,r]);try{const t=await l.uploadImage(e);jn(n,"ready",t.url)}catch(e){const t=e instanceof Error?e.message:"Upload failed";jn(n,"error",void 0,t)}},[l]),g=xe(e=>{const n=Array.from(e).filter(e=>e.type.startsWith("image/")),t=4-Mn.value.length;n.slice(0,t).forEach(f)},[f]),_=xe(e=>{const n=e.clipboardData?.items;if(!n)return;const t=[];for(const e of n)if(e.type.startsWith("image/")){const n=e.getAsFile();n&&t.push(n)}t.length>0&&(e.preventDefault(),g(t))},[g]),m=xe(e=>{e.preventDefault(),e.stopPropagation(),u(!0)},[]),v=xe(e=>{e.preventDefault(),e.stopPropagation(),u(!1)},[]),b=xe(e=>{e.preventDefault(),e.stopPropagation(),u(!1);const n=e.dataTransfer?.files;n&&g(n)},[g]),x=xe(e=>{const n=e.target;n.files&&(g(n.files),n.value="")},[g]),y=xe(()=>{s.current?.click()},[]),k=xe(()=>{const e=p.trim(),n=[...In.value],r=Mn.value.filter(e=>"ready"===e.status&&e.url).map(e=>({url:e.url,detail:"low"})),i=n.length>0,a=r.length>0;var l;(e||i||a)&&(Bn.value||(i&&(In.value=[]),Ln(),t?t(e,n,r):(i&&(l=n,Rn.value=l),On(e),Jn()),c(""),o.current&&(o.current.style.height="41px",o.current.style.overflowY="hidden")))},[p,t]),w=Bn.value,S=p.trim()||In.value.length>0||Mn.value.some(e=>"ready"===e.status);return ne("div",{class:`_pillar-unified-input-wrapper pillar-unified-input-wrapper ${d?"_pillar-unified-input-wrapper--dragging":""} ${a}`.trim(),onDragOver:m,onDragLeave:v,onDrop:b,children:[ne("input",{ref:s,type:"file",accept:"image/*",multiple:!0,onChange:x,style:{display:"none"}}),Mn.value.length>0&&ne("div",{class:"_pillar-chat-images-preview pillar-chat-images-preview",children:Mn.value.map(e=>ne("div",{class:"_pillar-chat-image-thumb pillar-chat-image-thumb",children:[ne("img",{src:e.preview,alt:"Upload preview"}),"uploading"===e.status&&ne("div",{class:"_pillar-chat-image-loading pillar-chat-image-loading",children:ne("div",{class:"_pillar-loading-spinner pillar-loading-spinner",style:{width:"16px",height:"16px"}})}),"error"===e.status&&ne("div",{class:"_pillar-chat-image-error pillar-chat-image-error",title:e.error,children:"!"}),ne("button",{type:"button",class:"_pillar-chat-image-remove pillar-chat-image-remove",onClick:()=>(e=>{const n=Mn.value.find(n=>n.id===e);n&&URL.revokeObjectURL(n.preview),Mn.value=Mn.value.filter(n=>n.id!==e)})(e.id),"aria-label":"Remove image",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]},e.id))}),r&&ne(Tt,{contexts:In.value,onRemove:Nn}),ne("textarea",{ref:o,class:"_pillar-unified-input pillar-unified-input",placeholder:d?"Drop image here...":e,value:p,onInput:e=>{const n=e.target;c(n.value),h()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),k())},onPaste:_,disabled:n,style:{height:"41px"}}),ne("div",{class:"_pillar-unified-input-row pillar-unified-input-row",children:[i&&ne("button",{type:"button",class:"_pillar-chat-image-btn pillar-chat-image-btn",onClick:y,disabled:n||w||Mn.value.length>=4,"aria-label":"Attach image",title:"Attach image (max 4)",dangerouslySetInnerHTML:{__html:Et}}),ne("button",{type:"button",class:"_pillar-unified-send-btn pillar-unified-send-btn",onClick:k,disabled:n||w||!S,"aria-label":"Send message",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/></svg>'}})]}),d&&ne("div",{class:"_pillar-chat-drop-overlay pillar-chat-drop-overlay",children:[ne("span",{dangerouslySetInnerHTML:{__html:Et}}),ne("span",{children:"Drop image here"})]})]})}function At({text:e,onClick:n}){return ne("button",{type:"button",class:"_pillar-question-chip pillar-question-chip",onClick:n,children:[ne("span",{class:"_pillar-question-chip-text pillar-question-chip-text",children:e}),ne("span",{class:"_pillar-question-chip-arrow pillar-question-chip-arrow",children:"→"})]})}function It(){return ne("div",{class:"_pillar-question-chip-skeleton pillar-question-chip-skeleton",children:ne("div",{class:"_pillar-question-chip-skeleton-bar pillar-question-chip-skeleton-bar"})})}function Rt(){const e=ot(),[n,t]=_e(null),[r,i]=_e(!0);me(()=>{let n=!0;return(async()=>{try{const r=await e.getSuggestedQuestions();n&&(t(r),i(!1))}catch(e){n&&(console.error("[Pillar] Failed to load suggested questions:",e),t([]),i(!1))}})(),()=>{n=!1}},[e]);return ne("div",{class:"_pillar-home-view pillar-home-view",children:[ne("div",{class:"_pillar-home-view-header pillar-home-view-header",children:[ne("div",{class:"_pillar-home-view-icon",children:"💬"}),ne("h2",{class:"_pillar-home-view-title pillar-home-view-title",children:"How can I help?"})]}),ne("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:r?ne(M,{children:[ne(It,{}),ne(It,{}),ne(It,{})]}):n&&n.length>0?n.map(e=>ne(At,{text:e.text,onClick:()=>(e=>{On(e.text),Jn()})(e)},e.id)):null}),ne("div",{style:{marginTop:"auto"},children:ne(zt,{placeholder:"Ask anything... (paste or drop images)"})})]})}function Mt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Bt={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function jt(e){Bt=e}var Lt={exec:()=>null};function Ht(e,n=""){let t="string"==typeof e?e:e.source,r={replace:(e,n)=>{let i="string"==typeof n?n:n.source;return i=i.replace(Ot.caret,"$1"),t=t.replace(e,i),r},getRegex:()=>new RegExp(t,n)};return r}var qt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ot={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Dt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Nt=/(?:[*+-]|\d{1,9}[.)])/,Ut=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ft=Ht(Ut).replace(/bull/g,Nt).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/).replace(/\|table/g,"").getRegex(),Wt=Ht(Ut).replace(/bull/g,Nt).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/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Vt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Kt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Zt=Ht(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Kt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qt=Ht(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Nt).getRegex(),Xt="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",Gt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Jt=Ht("^ {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[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Gt).replace("tag",Xt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Yt=Ht(Vt).replace("hr",Dt).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",Xt).getRegex(),er={blockquote:Ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Yt).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:Zt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Dt,html:Jt,lheading:Ft,list:Qt,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Yt,table:Lt,text:/^[^\n]+/},nr=Ht("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Dt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\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",Xt).getRegex(),tr={...er,lheading:Wt,table:nr,paragraph:Ht(Vt).replace("hr",Dt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",nr).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",Xt).getRegex()},rr={...er,html:Ht("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Gt).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:Lt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ht(Vt).replace("hr",Dt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Ft).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ir=/^( {2,}|\\)\n(?!\s*$)/,ar=/[\p{P}\p{S}]/u,lr=/[\s\p{P}\p{S}]/u,or=/[^\s\p{P}\p{S}]/u,sr=Ht(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,lr).getRegex(),pr=/(?!~)[\p{P}\p{S}]/u,cr=Ht(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",qt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),dr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ur=Ht(dr,"u").replace(/punct/g,ar).getRegex(),hr=Ht(dr,"u").replace(/punct/g,pr).getRegex(),fr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",gr=Ht(fr,"gu").replace(/notPunctSpace/g,or).replace(/punctSpace/g,lr).replace(/punct/g,ar).getRegex(),_r=Ht(fr,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,pr).getRegex(),mr=Ht("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,or).replace(/punctSpace/g,lr).replace(/punct/g,ar).getRegex(),vr=Ht(/\\(punct)/,"gu").replace(/punct/g,ar).getRegex(),br=Ht(/^<(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(),xr=Ht(Gt).replace("(?:--\x3e|$)","--\x3e").getRegex(),yr=Ht("^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",xr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),kr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,wr=Ht(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",kr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Sr=Ht(/^!?\[(label)\]\[(ref)\]/).replace("label",kr).replace("ref",Kt).getRegex(),Cr=Ht(/^!?\[(ref)\](?:\[\])?/).replace("ref",Kt).getRegex(),Pr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,$r={_backpedal:Lt,anyPunctuation:vr,autolink:br,blockSkip:cr,br:ir,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Lt,emStrongLDelim:ur,emStrongRDelimAst:gr,emStrongRDelimUnd:mr,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:wr,nolink:Cr,punctuation:sr,reflink:Sr,reflinkSearch:Ht("reflink|nolink(?!\\()","g").replace("reflink",Sr).replace("nolink",Cr).getRegex(),tag:yr,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Lt},Tr={...$r,link:Ht(/^!?\[(label)\]\((.*?)\)/).replace("label",kr).getRegex(),reflink:Ht(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",kr).getRegex()},Er={...$r,emStrongRDelimAst:_r,emStrongLDelim:hr,url:Ht(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Pr).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Ht(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Pr).getRegex()},zr={...Er,br:Ht(ir).replace("{2,}","*").getRegex(),text:Ht(Er.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ar={normal:er,gfm:tr,pedantic:rr},Ir={normal:$r,gfm:Er,breaks:zr,pedantic:Tr},Rr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Mr=e=>Rr[e];function Br(e,n){if(n){if(Ot.escapeTest.test(e))return e.replace(Ot.escapeReplace,Mr)}else if(Ot.escapeTestNoEncode.test(e))return e.replace(Ot.escapeReplaceNoEncode,Mr);return e}function jr(e){try{e=encodeURI(e).replace(Ot.percentDecode,"%")}catch{return null}return e}function Lr(e,n){let t=e.replace(Ot.findPipe,(e,n,t)=>{let r=!1,i=n;for(;--i>=0&&"\\"===t[i];)r=!r;return r?"|":" |"}),r=t.split(Ot.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ot.slashPipe,"|");return r}function Hr(e,n,t){let r=e.length;if(0===r)return"";let i=0;for(;i<r;){if(e.charAt(r-i-1)!==n)break;i++}return e.slice(0,r-i)}function qr(e,n,t,r,i){let a=n.href,l=n.title||null,o=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let s={type:"!"===e[0].charAt(0)?"image":"link",raw:t,href:a,title:l,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,s}var Or=class{options;rules;lexer;constructor(e){this.options=e||Bt}space(e){let n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){let n=this.rules.block.code.exec(e);if(n){let e=n[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Hr(e,"\n")}}}fences(e){let n=this.rules.block.fences.exec(e);if(n){let e=n[0],t=function(e,n,t){let r=e.match(t.other.indentCodeCompensation);if(null===r)return n;let i=r[1];return n.split("\n").map(e=>{let n=e.match(t.other.beginningSpace);if(null===n)return e;let[r]=n;return r.length>=i.length?e.slice(i.length):e}).join("\n")}(e,n[3]||"",this.rules);return{type:"code",raw:e,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:t}}}heading(e){let n=this.rules.block.heading.exec(e);if(n){let e=n[2].trim();if(this.rules.other.endingHash.test(e)){let n=Hr(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:Hr(n[0],"\n")}}blockquote(e){let n=this.rules.block.blockquote.exec(e);if(n){let e=Hr(n[0],"\n").split("\n"),t="",r="",i=[];for(;e.length>0;){let n,a=!1,l=[];for(n=0;n<e.length;n++)if(this.rules.other.blockquoteStart.test(e[n]))l.push(e[n]),a=!0;else{if(a)break;l.push(e[n])}e=e.slice(n);let o=l.join("\n"),s=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");t=t?`${t}\n${o}`:o,r=r?`${r}\n${s}`:s;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(s,i,!0),this.lexer.state.top=p,0===e.length)break;let c=i.at(-1);if("code"===c?.type)break;if("blockquote"===c?.type){let n=c,a=n.raw+"\n"+e.join("\n"),l=this.blockquote(a);i[i.length-1]=l,t=t.substring(0,t.length-n.raw.length)+l.raw,r=r.substring(0,r.length-n.text.length)+l.text;break}if("list"===c?.type){let n=c,a=n.raw+"\n"+e.join("\n"),l=this.list(a);i[i.length-1]=l,t=t.substring(0,t.length-c.raw.length)+l.raw,r=r.substring(0,r.length-n.raw.length)+l.raw,e=a.substring(i.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:t,tokens:i,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let t=n[1].trim(),r=t.length>1,i={type:"list",raw:"",ordered:r,start:r?+t.slice(0,-1):"",loose:!1,items:[]};t=r?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=r?t:"[*+-]");let a=this.rules.other.listItemRegex(t),l=!1;for(;e;){let t=!1,r="",o="";if(!(n=a.exec(e))||this.rules.block.hr.test(e))break;r=n[0],e=e.substring(r.length);let s=n[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),p=e.split("\n",1)[0],c=!s.trim(),d=0;if(this.options.pedantic?(d=2,o=s.trimStart()):c?d=n[1].length+1:(d=n[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,o=s.slice(d),d+=n[1].length),c&&this.rules.other.blankLine.test(p)&&(r+=p+"\n",e=e.substring(p.length+1),t=!0),!t){let n=this.rules.other.nextBulletRegex(d),t=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),l=this.rules.other.htmlBeginRegex(d);for(;e;){let u,h=e.split("\n",1)[0];if(p=h,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),u=p):u=p.replace(this.rules.other.tabCharGlobal," "),i.test(p)||a.test(p)||l.test(p)||n.test(p)||t.test(p))break;if(u.search(this.rules.other.nonSpaceChar)>=d||!p.trim())o+="\n"+u.slice(d);else{if(c||s.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(s)||a.test(s)||t.test(s))break;o+="\n"+p}!c&&!p.trim()&&(c=!0),r+=h+"\n",e=e.substring(h.length+1),s=u.slice(d)}}i.loose||(l?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(l=!0)),i.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),i.raw+=r}let o=i.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,i.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!i.loose){let n=e.tokens.filter(e=>"space"===e.type),t=n.length>0&&n.some(e=>this.rules.other.anyLine.test(e.raw));i.loose=t}}if(i.loose)for(let e of i.items){e.loose=!0;for(let n of e.tokens)"text"===n.type&&(n.type="paragraph")}return i}}html(e){let n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:"pre"===n[1]||"script"===n[1]||"style"===n[1],text:n[0]}}def(e){let n=this.rules.block.def.exec(e);if(n){let e=n[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),t=n[2]?n[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:e,raw:n[0],href:t,title:r}}}table(e){let n=this.rules.block.table.exec(e);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let t=Lr(n[1]),r=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],a={type:"table",raw:n[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push("right"):this.rules.other.tableAlignCenter.test(e)?a.align.push("center"):this.rules.other.tableAlignLeft.test(e)?a.align.push("left"):a.align.push(null);for(let e=0;e<t.length;e++)a.header.push({text:t[e],tokens:this.lexer.inline(t[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Lr(e,a.header.length).map((e,n)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[n]})));return a}}lheading(e){let n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:"="===n[2].charAt(0)?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){let n=this.rules.block.paragraph.exec(e);if(n){let e="\n"===n[1].charAt(n[1].length-1)?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){let n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(e){let n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){let n=this.rules.inline.link.exec(e);if(n){let e=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let n=Hr(e.slice(0,-1),"\\");if((e.length-n.length)%2==0)return}else{let e=function(e,n){if(-1===e.indexOf(n[1]))return-1;let t=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===n[0])t++;else if(e[r]===n[1]&&(t--,t<0))return r;return t>0?-2:-1}(n[2],"()");if(-2===e)return;if(e>-1){let t=(0===n[0].indexOf("!")?5:4)+n[1].length+e;n[2]=n[2].substring(0,e),n[0]=n[0].substring(0,t).trim(),n[3]=""}}let t=n[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(t);e&&(t=e[1],r=e[3])}else r=n[3]?n[3].slice(1,-1):"";return t=t.trim(),this.rules.other.startAngleBracket.test(t)&&(t=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?t.slice(1):t.slice(1,-1)),qr(n,{href:t&&t.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer,this.rules)}}reflink(e,n){let t;if((t=this.rules.inline.reflink.exec(e))||(t=this.rules.inline.nolink.exec(e))){let e=n[(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=t[0].charAt(0);return{type:"text",raw:e,text:e}}return qr(t,e,t[0],this.lexer,this.rules)}}emStrong(e,n,t=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!t||this.rules.inline.punctuation.exec(t))){let t,i,a=[...r[0]].length-1,l=a,o=0,s="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(s.lastIndex=0,n=n.slice(-1*e.length+a);null!=(r=s.exec(n));){if(t=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!t)continue;if(i=[...t].length,r[3]||r[4]){l+=i;continue}if((r[5]||r[6])&&a%3&&!((a+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);let n=[...r[0]][0].length,s=e.slice(0,a+r.index+n+i);if(Math.min(a,i)%2){let e=s.slice(1,-1);return{type:"em",raw:s,text:e,tokens:this.lexer.inlineTokens(e)}}let p=s.slice(2,-2);return{type:"strong",raw:s,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let n=this.rules.inline.code.exec(e);if(n){let e=n[2].replace(this.rules.other.newLineCharGlobal," "),t=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return t&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:n[0],text:e}}}br(e){let n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){let n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){let n=this.rules.inline.autolink.exec(e);if(n){let e,t;return"@"===n[2]?(e=n[1],t="mailto:"+e):(e=n[1],t=e),{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let n;if(n=this.rules.inline.url.exec(e)){let e,t;if("@"===n[2])e=n[0],t="mailto:"+e;else{let r;do{r=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])?.[0]??""}while(r!==n[0]);e=n[0],t="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let n=this.rules.inline.text.exec(e);if(n){let e=this.lexer.state.inRawBlock;return{type:"text",raw:n[0],text:n[0],escaped:e}}}},Dr=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Bt,this.options.tokenizer=this.options.tokenizer||new Or,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ot,block:Ar.normal,inline:Ir.normal};this.options.pedantic?(n.block=Ar.pedantic,n.inline=Ir.pedantic):this.options.gfm&&(n.block=Ar.gfm,this.options.breaks?n.inline=Ir.breaks:n.inline=Ir.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ar,inline:Ir}}static lex(n,t){return new e(t).lex(n)}static lexInline(n,t){return new e(t).inlineTokens(n)}lex(e){e=e.replace(Ot.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],t=!1){for(this.options.pedantic&&(e=e.replace(Ot.tabCharGlobal," ").replace(Ot.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(t=>!!(r=t.call({lexer:this},e,n))&&(e=e.substring(r.raw.length),n.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let t=n.at(-1);1===r.raw.length&&void 0!==t?t.raw+="\n":n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.raw,this.inlineQueue.at(-1).src=t.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let n,t=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=n.at(-1);t&&"paragraph"===a?.type?(a.raw+=(a.raw.endsWith("\n")?"":"\n")+r.raw,a.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r),t=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let t=n.at(-1);"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let t,r=e,i=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(r));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(r));)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(r));)t=i[2]?i[2].length:0,r=r.slice(0,i.index+t)+"["+"a".repeat(i[0].length-t-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let a=!1,l="";for(;e;){let t;if(a||(l=""),a=!1,this.options.extensions?.inline?.some(r=>!!(t=r.call({lexer:this},e,n))&&(e=e.substring(t.raw.length),n.push(t),!0)))continue;if(t=this.tokenizer.escape(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.tag(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.link(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(t.raw.length);let r=n.at(-1);"text"===t.type&&"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(t=this.tokenizer.emStrong(e,r,l)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.codespan(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.br(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.del(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.autolink(e)){e=e.substring(t.raw.length),n.push(t);continue}if(!this.state.inLink&&(t=this.tokenizer.url(e))){e=e.substring(t.raw.length),n.push(t);continue}let i=e;if(this.options.extensions?.startInline){let n,t=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(t=this.tokenizer.inlineText(i)){e=e.substring(t.raw.length),"_"!==t.raw.slice(-1)&&(l=t.raw.slice(-1)),a=!0;let r=n.at(-1);"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return n}},Nr=class{options;parser;constructor(e){this.options=e||Bt}space(e){return""}code({text:e,lang:n,escaped:t}){let r=(n||"").match(Ot.notSpaceStart)?.[0],i=e.replace(Ot.endingNewline,"")+"\n";return r?'<pre><code class="language-'+Br(r)+'">'+(t?i:Br(i,!0))+"</code></pre>\n":"<pre><code>"+(t?i:Br(i,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:n}){return`<h${n}>${this.parser.parseInline(e)}</h${n}>\n`}hr(e){return"<hr>\n"}list(e){let n=e.ordered,t=e.start,r="";for(let n=0;n<e.items.length;n++){let t=e.items[n];r+=this.listitem(t)}let i=n?"ol":"ul";return"<"+i+(n&&1!==t?' start="'+t+'"':"")+">\n"+r+"</"+i+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let n="",t="";for(let n=0;n<e.header.length;n++)t+=this.tablecell(e.header[n]);n+=this.tablerow({text:t});let r="";for(let n=0;n<e.rows.length;n++){let i=e.rows[n];t="";for(let e=0;e<i.length;e++)t+=this.tablecell(i[e]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+n+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let n=this.parser.parseInline(e.tokens),t=e.header?"th":"td";return(e.align?`<${t} align="${e.align}">`:`<${t}>`)+n+`</${t}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Br(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:t}){let r=this.parser.parseInline(t),i=jr(e);if(null===i)return r;let a='<a href="'+(e=i)+'"';return n&&(a+=' title="'+Br(n)+'"'),a+=">"+r+"</a>",a}image({href:e,title:n,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=jr(e);if(null===i)return Br(t);let a=`<img src="${e=i}" alt="${t}"`;return n&&(a+=` title="${Br(n)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Br(e.text)}},Ur=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Fr=class e{options;renderer;textRenderer;constructor(e){this.options=e||Bt,this.options.renderer=this.options.renderer||new Nr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ur}static parse(n,t){return new e(t).parse(n)}static parseInline(n,t){return new e(t).parseInline(n)}parse(e){let n="";for(let t=0;t<e.length;t++){let r=e[t];if(this.options.extensions?.renderers?.[r.type]){let e=r,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){n+=t||"";continue}}let i=r;switch(i.type){case"space":n+=this.renderer.space(i);break;case"hr":n+=this.renderer.hr(i);break;case"heading":n+=this.renderer.heading(i);break;case"code":n+=this.renderer.code(i);break;case"table":n+=this.renderer.table(i);break;case"blockquote":n+=this.renderer.blockquote(i);break;case"list":n+=this.renderer.list(i);break;case"checkbox":n+=this.renderer.checkbox(i);break;case"html":n+=this.renderer.html(i);break;case"def":n+=this.renderer.def(i);break;case"paragraph":n+=this.renderer.paragraph(i);break;case"text":n+=this.renderer.text(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,n=this.renderer){let t="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){t+=e||"";continue}}let a=i;switch(a.type){case"escape":case"text":t+=n.text(a);break;case"html":t+=n.html(a);break;case"link":t+=n.link(a);break;case"image":t+=n.image(a);break;case"checkbox":t+=n.checkbox(a);break;case"strong":t+=n.strong(a);break;case"em":t+=n.em(a);break;case"codespan":t+=n.codespan(a);break;case"br":t+=n.br(a);break;case"del":t+=n.del(a);break;default:{let e='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}},Wr=class{options;block;constructor(e){this.options=e||Bt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Dr.lex:Dr.lexInline}provideParser(){return this.block?Fr.parse:Fr.parseInline}},Vr=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Fr;Renderer=Nr;TextRenderer=Ur;Lexer=Dr;Tokenizer=Or;Hooks=Wr;constructor(...e){this.use(...e)}walkTokens(e,n){let t=[];for(let r of e)switch(t=t.concat(n.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)t=t.concat(this.walkTokens(r.tokens,n));for(let r of e.rows)for(let e of r)t=t.concat(this.walkTokens(e.tokens,n));break}case"list":{let e=r;t=t.concat(this.walkTokens(e.items,n));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);t=t.concat(this.walkTokens(i,n))}):e.tokens&&(t=t.concat(this.walkTokens(e.tokens,n)))}}return t}use(...e){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let t={...e};if(t.async=this.defaults.async||t.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let t=n.renderers[e.name];n.renderers[e.name]=t?function(...n){let r=e.renderer.apply(this,n);return!1===r&&(r=t.apply(this,n)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let t=n[e.level];t?t.unshift(e.tokenizer):n[e.level]=[e.tokenizer],e.start&&("block"===e.level?n.startBlock?n.startBlock.push(e.start):n.startBlock=[e.start]:"inline"===e.level&&(n.startInline?n.startInline.push(e.start):n.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(n.childTokens[e.name]=e.childTokens)}),t.extensions=n),e.renderer){let n=this.defaults.renderer||new Nr(this.defaults);for(let t in e.renderer){if(!(t in n))throw new Error(`renderer '${t}' does not exist`);if(["options","parser"].includes(t))continue;let r=t,i=e.renderer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t||""}}t.renderer=n}if(e.tokenizer){let n=this.defaults.tokenizer||new Or(this.defaults);for(let t in e.tokenizer){if(!(t in n))throw new Error(`tokenizer '${t}' does not exist`);if(["options","rules","lexer"].includes(t))continue;let r=t,i=e.tokenizer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.tokenizer=n}if(e.hooks){let n=this.defaults.hooks||new Wr;for(let t in e.hooks){if(!(t in n))throw new Error(`hook '${t}' does not exist`);if(["options","block"].includes(t))continue;let r=t,i=e.hooks[r],a=n[r];Wr.passThroughHooks.has(t)?n[r]=e=>{if(this.defaults.async&&Wr.passThroughHooksRespectAsync.has(t))return(async()=>{let t=await i.call(n,e);return a.call(n,t)})();let r=i.call(n,e);return a.call(n,r)}:n[r]=(...e)=>{if(this.defaults.async)return(async()=>{let t=await i.apply(n,e);return!1===t&&(t=await a.apply(n,e)),t})();let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.hooks=n}if(e.walkTokens){let n=this.defaults.walkTokens,r=e.walkTokens;t.walkTokens=function(e){let t=[];return t.push(r.call(this,e)),n&&(t=t.concat(n.call(this,e))),t}}this.defaults={...this.defaults,...t}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return Dr.lex(e,n??this.defaults)}parser(e,n){return Fr.parse(e,n??this.defaults)}parseMarkdown(e){return(n,t)=>{let r={...t},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return a(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 n>"u"||null===n)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let t=i.hooks?await i.hooks.preprocess(n):n,r=await(i.hooks?await i.hooks.provideLexer():e?Dr.lex:Dr.lexInline)(t,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let l=await(i.hooks?await i.hooks.provideParser():e?Fr.parse:Fr.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(a);try{i.hooks&&(n=i.hooks.preprocess(n));let t=(i.hooks?i.hooks.provideLexer():e?Dr.lex:Dr.lexInline)(n,i);i.hooks&&(t=i.hooks.processAllTokens(t)),i.walkTokens&&this.walkTokens(t,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Fr.parse:Fr.parseInline)(t,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,n){return t=>{if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Br(t.message+"",!0)+"</pre>";return n?Promise.resolve(e):e}if(n)return Promise.reject(t);throw t}}};function Kr(e,n){return Vr.parse(e,n)}function Zr(e){try{return Kr.parse(e)}catch(n){return console.error("[Pillar] Markdown parsing error:",n),e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")}}Kr.options=Kr.setOptions=function(e){return Vr.setOptions(e),Kr.defaults=Vr.defaults,jt(Kr.defaults),Kr},Kr.getDefaults=Mt,Kr.defaults=Bt,Kr.use=function(...e){return Vr.use(...e),Kr.defaults=Vr.defaults,jt(Kr.defaults),Kr},Kr.walkTokens=function(e,n){return Vr.walkTokens(e,n)},Kr.parseInline=Vr.parseInline,Kr.Parser=Fr,Kr.parser=Fr.parse,Kr.Renderer=Nr,Kr.TextRenderer=Ur,Kr.Lexer=Dr,Kr.lexer=Dr.lex,Kr.Tokenizer=Or,Kr.Hooks=Wr,Kr.parse=Kr,Kr.options,Kr.setOptions,Kr.use,Kr.walkTokens,Kr.parseInline,Fr.parse,Dr.lex,Kr.setOptions({gfm:!0,breaks:!0});const Qr={navigate:"arrow-right",open_modal:"layout",fill_form:"edit",trigger_action:"zap",copy_text:"copy",external_link:"external-link",start_tutorial:"play-circle"},Xr={"arrow-right":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12,5 19,12 12,19"/></svg>',"user-plus":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="8.5" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="23" y1="11" x2="17" y2="11"/></svg>',settings:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',"external-link":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15,3 21,3 21,9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',"play-circle":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polygon points="10,8 16,12 10,16 10,8"/></svg>',zap:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13,2 3,14 12,14 11,22 21,10 12,10 13,2"/></svg>',"message-circle":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/></svg>',download:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',copy:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',layout:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',edit:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>'};function Gr(e){const{task:n,onExecute:t}=e,r=document.createElement("button");r.className=function(e="primary"){return`pillar-task-btn pillar-task-btn--${e}`}(n.buttonVariant||"primary"),r.type="button";const i=n.icon||((a=n.taskType)&&Qr[a]||"zap");var a;if(i&&Xr[i]){const e=document.createElement("span");e.className="pillar-task-btn__icon",e.innerHTML=Xr[i],r.appendChild(e)}const l=n.label||n.name.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");const o=document.createElement("span");return o.className="pillar-task-btn__label",o.textContent=l,r.appendChild(o),r.addEventListener("click",()=>{const e=Ri.getInstance();if(e){const t=n.data||{},r=n.path||t.path,i=n.externalUrl||t.url,a={id:n.id,name:n.name,data:t,taskType:n.taskType,path:r,externalUrl:i};e.executeTask(a)}t?.()}),r}const Jr="\n/* Task Button Component */\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n";function Yr(){const e=ot(),n=ve(null),t=ve(!1);me(()=>{if(t.current)return;const e=zn.value,n=Rn.value;e&&(t.current=!0,zn.value=null,Rn.value=[],a(e,n.length>0?n:void 0))},[]),me(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[kn.value]),me(()=>{const e=Ri.getInstance();if(!e)return;const n=e.on("task:complete",({name:e,success:n})=>{((e,n,t)=>{const r=kn.value;for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.actionStatus?.[e]){const l={...a.actionStatus,[e]:{status:n?"success":"failed",completedAt:Date.now(),errorMessage:t}};return void(kn.value=[...r.slice(0,i),{...a,actionStatus:l},...r.slice(i+1)])}}})(e,n);const t=function(e,n){const t=e.replace(/_/g," ").toLowerCase();return n?t.startsWith("open ")?`Opened ${t.slice(5)}`:t.startsWith("go to ")?`Navigated to ${t.slice(6)}`:t.startsWith("navigate to ")?`Navigated to ${t.slice(12)}`:"Done!":`Failed to ${t}`}(e,n);((e,n)=>{const t=kn.value;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.actionStatus?.[e])return void(kn.value=[...t.slice(0,r),{...i,content:n},...t.slice(r+1)])}})(e,t)});return n},[]);const r=xe(e=>{console.log("[Pillar] Plan received:",e.id,e.goal);const n=Ri.getInstance();n&&n.handlePlanReceived(e)},[]),i=xe(e=>{const n=Ri.getInstance();console.log("[Pillar] handleActionsReceived called with",e.length,"actions"),console.log("[Pillar] Actions detail:",e.map(e=>({name:e.name,autoRun:e.autoRun})));const t=e.filter(e=>!0===e.autoRun),r=e.filter(e=>!e.autoRun);return console.log("[Pillar] Auto-run actions:",t.length,", Manual actions:",r.length),n&&t.length>0?(console.log("[Pillar] Executing auto-run actions..."),t.forEach(e=>{const t=e.data||{},r=t.path,i=t.url,a=kn.value.length-1;a>=0&&((e,n)=>{const t=kn.value;if(e>=0&&e<t.length){const r=t[e],i={...r.actionStatus||{},[n]:{status:"pending"}};kn.value=[...t.slice(0,e),{...r,actionStatus:i},...t.slice(e+1)]}})(a,e.name),console.log("[Pillar] Executing action:",e.name),n.executeTask({id:e.id,name:e.name,taskType:e.taskType,data:t,path:r,externalUrl:i})}),[]):n?r:(console.warn("[Pillar] No Pillar instance available for auto-run"),e)},[]),a=xe(async(n,t,a)=>{var l,o,s;((e,n,t)=>{kn.value=[...kn.value,{role:"user",content:e,userContext:n&&n.length>0?n:void 0,images:t&&t.length>0?t:void 0}]})(n,t,a),qn(!0),l="",kn.value=[...kn.value,{role:"assistant",content:l,id:o}];try{let l="",o=[];const p=kn.value.slice(0,-1),c=await e.chat(n,p,e=>{l+=e,Hn(l)},void 0,wn.value,e=>{o=i(e)},r,t,a,e=>{var n;n={kind:e.kind,message:e.message},Cn.value=n});let d=o;c.actions&&c.actions.length>0&&(d=i(c.actions)),Hn(c.message,c.messageId,d,c.sources),c.conversationId&&(s=c.conversationId,wn.value=s)}catch(e){console.error("[Pillar] Chat error:",e),Hn("Sorry, I encountered an error. Please try again.")}finally{qn(!1),Cn.value={kind:null}}},[e,i]),l=xe(async(n,t)=>{((e,n)=>{kn.value=kn.value.map(t=>t.id===e?{...t,feedback:n}:t)})(n,t),await e.submitFeedback(n,t)},[e]),o=xe((e,n,t)=>{Sn.value||a(e,n.length>0?n:void 0,t.length>0?t:void 0)},[a]),s=ve(new Map);return me(()=>{const e=Ri.getInstance();kn.value.forEach((n,t)=>{if("assistant"===n.role&&n.actions&&n.actions.length>0){const r=s.current.get(t);if(r&&0===r.children.length){const t=n.actions.filter(e=>"inline_ui"===e.taskType),i=n.actions.filter(e=>"inline_ui"!==e.taskType);if(t.forEach(n=>{const t=function(e,n,t){const r=document.createElement("div");r.className="pillar-confirm-card-wrapper";const i=e.data?.card_type||e.name,a=Ri.getInstance(),l=a?.getCardRenderer(i),o={onConfirm:t=>{n(t||e.data)},onCancel:t,onStateChange:(e,n)=>{console.log(`[Pillar] Card state changed to ${e}${n?`: ${n}`:""}`)}};if(l)try{const n=l(r,e.data||{},o);r._cleanup=n||void 0}catch(e){console.error("[Pillar] Custom card renderer error:",e)}else{const n=tt(e,o);r.appendChild(n)}return r}(n,t=>{e&&e.executeTask({id:n.id,name:n.name,taskType:n.taskType,data:t||n.data||{}})},()=>{console.log("[Pillar] Confirm action cancelled:",n.name)});r.appendChild(t)}),i.length>0){const e=function(e){const n=document.createElement("div");return n.className="pillar-task-btn-group",e.forEach(e=>{const t=Gr({task:e});n.appendChild(t)}),n}(i);r.appendChild(e)}}}})},[kn.value]),ne("div",{class:"_pillar-chat-view pillar-chat-view",children:[ne("div",{class:"_pillar-chat-view-messages pillar-chat-view-messages",ref:n,children:[0===kn.value.length&&ne("div",{class:"_pillar-chat-view-welcome pillar-chat-view-welcome",children:[ne("div",{class:"_pillar-chat-view-welcome-icon pillar-chat-view-welcome-icon",children:"💬"}),ne("div",{class:"_pillar-chat-view-welcome-title pillar-chat-view-welcome-title",children:"Ask a question"}),ne("div",{class:"_pillar-chat-view-welcome-text pillar-chat-view-welcome-text",children:"Ask me anything about how to use this product."})]}),kn.value.map((e,n)=>ne("div",{class:`_pillar-chat-view-message pillar-chat-view-message _pillar-chat-view-message--${e.role} pillar-chat-view-message--${e.role}`,children:"user"===e.role?ne("div",{class:"_pillar-message-user pillar-message-user",children:[e.userContext&&e.userContext.length>0&&ne(Tt,{contexts:e.userContext,readOnly:!0}),e.images&&e.images.length>0&&ne("div",{class:"_pillar-message-user-images pillar-message-user-images",children:e.images.map((e,n)=>ne("img",{src:e.url,alt:`Attachment ${n+1}`,class:"_pillar-message-user-image pillar-message-user-image"},n))}),e.content]}):ne("div",{class:"_pillar-message-assistant-wrapper pillar-message-assistant-wrapper",children:[ne("div",{class:"_pillar-message-assistant-content pillar-message-assistant-content",children:[e.content?ne("div",{class:"_pillar-message-assistant pillar-message-assistant",dangerouslySetInnerHTML:{__html:Zr(e.content)}}):ne("div",{class:"_pillar-progress-indicator pillar-progress-indicator",children:[ne("div",{class:"_pillar-loading-spinner pillar-loading-spinner"}),ne("span",{class:"_pillar-progress-message pillar-progress-message",children:Cn.value.message||"Thinking..."})]}),e.actionStatus&&Object.keys(e.actionStatus).length>0&&ne("span",{class:"_pillar-action-status pillar-action-status",children:Object.entries(e.actionStatus).map(([e,n])=>ne("span",{class:`_pillar-action-status-indicator pillar-action-status-indicator _pillar-action-status-indicator--${n.status} pillar-action-status-indicator--${n.status}`,title:"failed"===n.status?n.errorMessage:e,dangerouslySetInnerHTML:{__html:"success"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>':"failed"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" opacity="0.3"/><path d="M12 2v4"/></svg>'}},e))})]}),e.id&&e.content&&ne("div",{class:"_pillar-feedback-icons pillar-feedback-icons",children:[ne("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("up"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>l(e.id,"up"),"aria-label":"Helpful",title:"Helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"/></svg>'}}),ne("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("down"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>l(e.id,"down"),"aria-label":"Not helpful",title:"Not helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"/></svg>'}})]}),e.sources&&e.sources.length>0&&ne("div",{class:"_pillar-chat-sources pillar-chat-sources",children:[ne("div",{class:"_pillar-chat-sources-title pillar-chat-sources-title",children:"Sources"}),e.sources.map(e=>ne("div",{class:"_pillar-chat-source pillar-chat-source",children:e.title},e.slug))]}),e.actions&&e.actions.length>0&&ne("div",{class:"_pillar-chat-actions pillar-chat-actions",children:[ne("div",{class:"_pillar-chat-actions-title pillar-chat-actions-title",children:"Suggested actions"}),ne("div",{ref:e=>{e&&s.current.set(n,e)},class:"_pillar-chat-actions-buttons pillar-chat-actions-buttons"})]})]})},n)),gt.value&&ne(kt,{})]}),ne("div",{class:"_pillar-chat-view-input-area pillar-chat-view-input-area",children:[ne(zt,{placeholder:"Ask a question... (paste or drop images)",disabled:Sn.value,onSubmit:o}),kn.value.length>0&&ne("div",{class:"_pillar-chat-view-input-footer pillar-chat-view-input-footer",children:ne("button",{class:"_pillar-chat-view-new-chat-btn pillar-chat-view-new-chat-btn",onClick:Xn,type:"button",children:[ne("span",{class:"_pillar-chat-view-new-chat-icon",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>'}}),"New chat"]})})]})]})}function ei(){const e=Wn.value,n=nn.value,t=(()=>{if("assistant"!==n)return n.charAt(0).toUpperCase()+n.slice(1)})(),r="chat"===e.type,i="home"===e.type;return ne("div","assistant"!==n?{class:"_pillar-panel-ui pillar-panel-ui",children:[ne(Ct,{currentView:"home",customTitle:t}),ne("div",{class:"_pillar-content pillar-content",children:"support"===n?ne("div",{style:{padding:"24px",textAlign:"center"},children:[ne("h2",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:"Hello World"}),ne("p",{style:{color:"var(--pillar-text-muted)",fontSize:"14px"},children:"Support tab content goes here."})]}):null})]}:{class:"_pillar-panel-ui pillar-panel-ui",children:[ne(Ct,{currentView:e.type,customTitle:t,hideNavigation:r}),ne("div",{class:"_pillar-content pillar-content",children:(()=>{switch(e.type){case"home":default:return ne(Rt,{});case"chat":return ne(Yr,{})}})()}),!r&&!i&&ne("div",{class:"_pillar-chat-input-area pillar-chat-input-area",children:ne(zt,{placeholder:"Ask a question..."})})]})}function ni(e,n=""){const t=[];return e.primary&&t.push(`--pillar-primary${n}: ${e.primary};`),e.primaryHover&&t.push(`--pillar-primary-hover${n}: ${e.primaryHover};`),e.background&&t.push(`--pillar-bg${n}: ${e.background};`),e.backgroundSecondary&&t.push(`--pillar-bg-secondary${n}: ${e.backgroundSecondary};`),e.text&&t.push(`--pillar-text${n}: ${e.text};`),e.textMuted&&t.push(`--pillar-text-muted${n}: ${e.textMuted};`),e.border&&t.push(`--pillar-border${n}: ${e.border};`),e.borderLight&&t.push(`--pillar-border-light${n}: ${e.borderLight};`),t.join("\n ")}function ti(e){const n=ni(e.colors),t=ni(e.darkColors);let r="";return n&&(r+=`\n:host {\n ${n}\n}\n`),t&&(r+=`\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n ${t}\n }\n}\n:host([data-theme="dark"]) {\n ${t}\n}\n`),r}const ri="\n/* ============================================================================\n CSS Custom Properties (Variables)\n Users can override these to customize colors\n ============================================================================ */\n\n:host {\n /* Core colors - Light mode (default) */\n --pillar-primary: #2563eb;\n --pillar-primary-hover: #1d4ed8;\n --pillar-primary-light: #eff6ff;\n --pillar-primary-light-hover: #dbeafe;\n \n --pillar-bg: #ffffff;\n --pillar-bg-secondary: #f9fafb;\n --pillar-bg-tertiary: #f3f4f6;\n \n --pillar-text: #1a1a1a;\n --pillar-text-secondary: #374151;\n --pillar-text-muted: #6b7280;\n --pillar-text-placeholder: #9ca3af;\n \n --pillar-border: #e5e7eb;\n --pillar-border-light: #f3f4f6;\n \n /* Shadows */\n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n \n /* Code blocks */\n --pillar-code-bg: #1f2937;\n --pillar-code-text: #e5e7eb;\n \n /* Scrollbar */\n --pillar-scrollbar-track: transparent;\n --pillar-scrollbar-thumb: #d1d5db;\n --pillar-scrollbar-thumb-hover: #9ca3af;\n \n /* Spacing (can be customized) */\n --pillar-panel-width: 380px;\n --pillar-spacing-xs: 4px;\n --pillar-spacing-sm: 8px;\n --pillar-spacing-md: 12px;\n --pillar-spacing-lg: 16px;\n --pillar-spacing-xl: 20px;\n --pillar-spacing-2xl: 24px;\n \n /* Border radius */\n --pillar-radius-sm: 4px;\n --pillar-radius-md: 6px;\n --pillar-radius-lg: 8px;\n --pillar-radius-xl: 10px;\n --pillar-radius-full: 9999px;\n \n /* Typography */\n --pillar-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n --pillar-font-mono: 'SF Mono', Consolas, monospace;\n --pillar-font-size-xs: 11px;\n --pillar-font-size-sm: 12px;\n --pillar-font-size-base: 14px;\n --pillar-font-size-md: 15px;\n --pillar-font-size-lg: 16px;\n --pillar-font-size-xl: 18px;\n --pillar-font-size-2xl: 20px;\n \n /* Animation */\n --pillar-transition-fast: 0.15s ease;\n --pillar-transition-normal: 0.3s ease;\n}\n\n/* Dark mode - Auto-detect from system preference */\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme=\"light\"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n }\n}\n\n/* Dark mode - Manual override */\n:host([data-theme=\"dark\"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n}\n\n/* ============================================================================\n Base Styles\n Note: No CSS reset - we rely on explicit styles for SDK components\n and allow custom cards to inherit host app styling (Tailwind, etc.)\n ============================================================================ */\n\n:host {\n font-family: var(--pillar-font-family);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n color: var(--pillar-text);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n/* ============================================================================\n Panel Container\n Internal: _pillar-panel | Public: pillar-panel\n ============================================================================ */\n\n._pillar-panel {\n position: fixed;\n top: 0;\n bottom: 0;\n width: var(--pillar-panel-width);\n max-width: 100vw;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n display: flex;\n flex-direction: column;\n z-index: 99999;\n transform: translateX(100%);\n transition: transform var(--pillar-transition-normal);\n}\n\n._pillar-panel--right {\n right: 0;\n}\n\n._pillar-panel--left {\n left: 0;\n border-left: none;\n border-right: 1px solid var(--pillar-border);\n transform: translateX(-100%);\n}\n\n._pillar-panel--open {\n transform: translateX(0);\n}\n\n._pillar-panel--manual {\n position: static;\n transform: none;\n height: 100%;\n}\n\n._pillar-panel-root {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\n._pillar-panel-ui {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n/* Public override classes - empty by default */\n.pillar-panel {}\n.pillar-panel-root {}\n.pillar-panel-ui {}\n\n/* ============================================================================\n Backdrop\n ============================================================================ */\n\n._pillar-backdrop {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity var(--pillar-transition-normal), visibility var(--pillar-transition-normal);\n z-index: 99998;\n}\n\n._pillar-backdrop--visible {\n opacity: 1;\n visibility: visible;\n}\n\n.pillar-backdrop {}\n\n/* ============================================================================\n Header\n Internal: _pillar-header | Public: pillar-header\n ============================================================================ */\n\n._pillar-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n border-bottom: 1px solid var(--pillar-border);\n flex-shrink: 0;\n background: var(--pillar-bg);\n}\n\n._pillar-header-left {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n}\n\n._pillar-header-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n/* Public override classes */\n.pillar-header {}\n.pillar-header-left {}\n.pillar-header-title {}\n\n/* ============================================================================\n Icon Buttons (back, home, close)\n Internal: _pillar-icon-btn | Public: pillar-icon-btn\n ============================================================================ */\n\n._pillar-icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: none;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast), background var(--pillar-transition-fast);\n}\n\n._pillar-icon-btn:hover {\n color: var(--pillar-text);\n background: var(--pillar-bg-tertiary);\n}\n\n._pillar-icon-btn svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-icon-btn {}\n.pillar-back-btn {}\n.pillar-home-btn {}\n.pillar-close-btn {}\n\n/* ============================================================================\n Content Area\n Internal: _pillar-content | Public: pillar-content\n ============================================================================ */\n\n._pillar-content {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 0;\n}\n\n.pillar-content {}\n\n/* ============================================================================\n Search Input\n Internal: _pillar-search | Public: pillar-search\n ============================================================================ */\n\n._pillar-search {\n position: relative;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-search-input {\n width: 100%;\n padding: 10px 12px 10px 40px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n outline: none;\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-search-input:focus {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-search-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-search-icon {\n position: absolute;\n left: 32px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n color: var(--pillar-text-placeholder);\n pointer-events: none;\n}\n\n._pillar-search-icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-search {}\n.pillar-search-input {}\n.pillar-search-icon {}\n\n/* ============================================================================\n Chat Input (Persistent Bottom)\n Internal: _pillar-chat-input | Public: pillar-chat-input\n ============================================================================ */\n\n._pillar-chat-input-container {\n flex-shrink: 0;\n border-top: 1px solid var(--pillar-border);\n background: var(--pillar-bg);\n display: flex;\n flex-direction: column;\n max-height: 50%;\n transition: max-height var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded {\n max-height: 60%;\n}\n\n._pillar-chat-input-messages {\n flex: 1;\n overflow-y: auto;\n padding: 0;\n max-height: 0;\n transition: max-height var(--pillar-transition-normal), padding var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded ._pillar-chat-input-messages {\n max-height: 300px;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-chat-input-message {\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-chat-input-message--user {\n text-align: right;\n}\n\n._pillar-chat-input-message-content {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n}\n\n._pillar-chat-input-message--user ._pillar-chat-input-message-content {\n background: var(--pillar-primary);\n color: #ffffff;\n border-bottom-right-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-message--assistant ._pillar-chat-input-message-content {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n border-bottom-left-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-sources {\n margin-top: var(--pillar-spacing-sm);\n padding-top: var(--pillar-spacing-sm);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-input-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: 6px;\n}\n\n._pillar-chat-input-source {\n display: block;\n padding: 6px 10px;\n margin-bottom: var(--pillar-spacing-xs);\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-md);\n text-decoration: none;\n cursor: pointer;\n}\n\n._pillar-chat-input-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-chat-input-area {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n}\n\n._pillar-chat-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-input-textarea {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-input-textarea::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-chat-input-container {}\n.pillar-chat-input-messages {}\n.pillar-chat-input-message {}\n.pillar-chat-input-message-content {}\n.pillar-chat-input-sources {}\n.pillar-chat-input-area {}\n.pillar-chat-input-wrapper {}\n.pillar-chat-input-textarea {}\n\n/* ============================================================================\n Chat Input Footer (contains send button)\n ============================================================================ */\n\n._pillar-chat-input-footer {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n/* ============================================================================\n Send Button - In footer row, right aligned\n Internal: _pillar-send-btn | Public: pillar-send-btn\n ============================================================================ */\n\n._pillar-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-send-btn {}\n.pillar-chat-input-footer {}\n\n/* ============================================================================\n Loading States\n Internal: _pillar-loading | Public: pillar-loading\n ============================================================================ */\n\n._pillar-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 40px var(--pillar-spacing-xl);\n color: var(--pillar-text-muted);\n}\n\n._pillar-loading-spinner {\n width: 24px;\n height: 24px;\n border: 2px solid var(--pillar-border);\n border-top-color: var(--pillar-primary);\n border-radius: 50%;\n animation: pillar-spin 0.8s linear infinite;\n}\n\n@keyframes pillar-spin {\n to { transform: rotate(360deg); }\n}\n\n.pillar-loading {}\n.pillar-loading-spinner {}\n\n/* ============================================================================\n Progress Indicator (AI activity status)\n Internal: _pillar-progress | Public: pillar-progress\n ============================================================================ */\n\n._pillar-progress-indicator {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-sm) 0;\n}\n\n._pillar-progress-indicator ._pillar-loading-spinner {\n width: 16px;\n height: 16px;\n flex-shrink: 0;\n}\n\n._pillar-progress-message {\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n font-style: italic;\n}\n\n.pillar-progress-indicator {}\n.pillar-progress-message {}\n\n/* ============================================================================\n Empty States\n Internal: _pillar-empty | Public: pillar-empty\n ============================================================================ */\n\n._pillar-empty {\n padding: 40px var(--pillar-spacing-xl);\n text-align: center;\n color: var(--pillar-text-muted);\n}\n\n._pillar-empty-icon {\n width: 48px;\n height: 48px;\n margin: 0 auto var(--pillar-spacing-lg);\n color: var(--pillar-border);\n}\n\n._pillar-empty-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 500;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-empty-description {\n font-size: var(--pillar-font-size-base);\n}\n\n.pillar-empty {}\n.pillar-empty-icon {}\n.pillar-empty-title {}\n.pillar-empty-description {}\n\n/* ============================================================================\n Section Titles\n Internal: _pillar-section-title | Public: pillar-section-title\n ============================================================================ */\n\n._pillar-section-title {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-xl) var(--pillar-spacing-sm);\n font-size: var(--pillar-font-size-xs);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: var(--pillar-text-muted);\n}\n\n.pillar-section-title {}\n\n/* ============================================================================\n Related Articles\n ============================================================================ */\n\n._pillar-related-articles {\n border-top: 1px solid var(--pillar-border);\n margin-top: var(--pillar-spacing-2xl);\n padding-top: var(--pillar-spacing-sm);\n}\n\n.pillar-related-articles {}\n\n/* ============================================================================\n Scrollbar Styling\n ============================================================================ */\n\n._pillar-content::-webkit-scrollbar,\n._pillar-chat-input-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-content::-webkit-scrollbar-track,\n._pillar-chat-input-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-content::-webkit-scrollbar-thumb,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-content::-webkit-scrollbar-thumb:hover,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Home View\n ============================================================================ */\n\n._pillar-home-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n padding: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-header {\n text-align: center;\n padding: var(--pillar-spacing-2xl) 0;\n}\n\n._pillar-home-view-icon {\n font-size: 40px;\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-home-view-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 0;\n}\n\n._pillar-home-view-questions {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n margin-bottom: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-input-wrapper {\n margin-top: auto;\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-home-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-home-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-home-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-home-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-home-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-home-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-home-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-home-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-home-view {}\n.pillar-home-view-header {}\n.pillar-home-view-title {}\n.pillar-home-view-questions {}\n.pillar-home-view-input-wrapper {}\n.pillar-home-view-input {}\n.pillar-home-view-send-btn {}\n\n/* ============================================================================\n Question Chip\n ============================================================================ */\n\n._pillar-question-chip {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n text-align: left;\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: background var(--pillar-transition-fast), border-color var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover {\n border-color: var(--pillar-primary);\n}\n\n._pillar-question-chip-text {\n flex: 1;\n}\n\n._pillar-question-chip-arrow {\n color: var(--pillar-text-muted);\n margin-left: var(--pillar-spacing-sm);\n transition: color var(--pillar-transition-fast), transform var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover ._pillar-question-chip-arrow {\n color: var(--pillar-primary);\n transform: translateX(2px);\n}\n\n._pillar-question-chip-skeleton {\n height: 44px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n overflow: hidden;\n}\n\n._pillar-question-chip-skeleton-bar {\n width: 60%;\n height: 14px;\n margin: 15px var(--pillar-spacing-lg);\n background: linear-gradient(90deg, var(--pillar-border) 25%, var(--pillar-bg-tertiary) 50%, var(--pillar-border) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n border-radius: var(--pillar-radius-sm);\n}\n\n@keyframes pillar-shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n\n.pillar-question-chip {}\n.pillar-question-chip-text {}\n.pillar-question-chip-arrow {}\n.pillar-question-chip-skeleton {}\n.pillar-question-chip-skeleton-bar {}\n\n/* ============================================================================\n Standalone Chat View\n Internal: _pillar-chat-view | Public: pillar-chat-view\n ============================================================================ */\n\n._pillar-chat-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n._pillar-chat-view-messages {\n flex: 1;\n overflow-y: auto;\n padding: var(--pillar-spacing-xl);\n display: flex;\n flex-direction: column;\n}\n\n._pillar-chat-view-welcome {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px var(--pillar-spacing-xl);\n text-align: center;\n flex: 1;\n}\n\n._pillar-chat-view-welcome-icon {\n font-size: 48px;\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-welcome-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-welcome-text {\n font-size: var(--pillar-font-size-base);\n color: var(--pillar-text-muted);\n max-width: 280px;\n}\n\n._pillar-chat-view-message {\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-message--user {\n text-align: right;\n}\n\n._pillar-chat-view-message--assistant {\n text-align: left;\n}\n\n.pillar-chat-view {}\n.pillar-chat-view-messages {}\n.pillar-chat-view-welcome {}\n.pillar-chat-view-message {}\n\n/* ============================================================================\n User Message Bubble\n Internal: _pillar-message-user | Public: pillar-message-user\n ============================================================================ */\n\n._pillar-message-user {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n border-bottom-right-radius: var(--pillar-radius-sm);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n background: var(--pillar-primary);\n color: #ffffff;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n\n._pillar-message-user-images {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-message-user-image {\n max-width: 120px;\n max-height: 120px;\n border-radius: var(--pillar-radius-md);\n object-fit: cover;\n}\n\n.pillar-message-user {}\n.pillar-message-user-images {}\n.pillar-message-user-image {}\n\n/* ============================================================================\n AI Response\n Internal: _pillar-message-assistant | Public: pillar-message-assistant\n ============================================================================ */\n\n._pillar-message-assistant {\n font-size: var(--pillar-font-size-base);\n line-height: 1.6;\n color: var(--pillar-text-secondary);\n}\n\n._pillar-message-assistant p {\n margin: 0 0 var(--pillar-spacing-md);\n}\n\n._pillar-message-assistant p:last-child {\n margin-bottom: 0;\n}\n\n._pillar-message-assistant h2 {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-lg) 0 var(--pillar-spacing-sm);\n}\n\n._pillar-message-assistant h3 {\n font-size: var(--pillar-font-size-md);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 14px 0 6px;\n}\n\n._pillar-message-assistant h4 {\n font-size: var(--pillar-font-size-base);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-md) 0 6px;\n}\n\n._pillar-message-assistant ul,\n._pillar-message-assistant ol {\n margin: 0 0 var(--pillar-spacing-md);\n padding-left: var(--pillar-spacing-2xl);\n list-style-position: outside;\n}\n\n._pillar-message-assistant ul {\n list-style-type: disc;\n}\n\n._pillar-message-assistant ol {\n list-style-type: decimal;\n}\n\n._pillar-message-assistant li {\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-message-assistant code {\n padding: 2px 6px;\n font-size: var(--pillar-font-size-sm);\n background: var(--pillar-bg-tertiary);\n border-radius: var(--pillar-radius-sm);\n font-family: var(--pillar-font-mono);\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant pre {\n margin: var(--pillar-spacing-md) 0;\n padding: var(--pillar-spacing-md) 14px;\n background: var(--pillar-code-bg);\n border-radius: var(--pillar-radius-lg);\n overflow-x: auto;\n}\n\n._pillar-message-assistant pre code {\n padding: 0;\n background: none;\n color: var(--pillar-code-text);\n font-size: var(--pillar-font-size-sm);\n line-height: 1.5;\n}\n\n._pillar-message-assistant a {\n color: var(--pillar-primary);\n text-decoration: none;\n}\n\n._pillar-message-assistant a:hover {\n text-decoration: underline;\n}\n\n._pillar-message-assistant strong {\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant em {\n font-style: italic;\n}\n\n.pillar-message-assistant {}\n\n/* ============================================================================\n Chat Sources\n Internal: _pillar-chat-sources | Public: pillar-chat-sources\n ============================================================================ */\n\n._pillar-chat-sources {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-source {\n display: block;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n margin-bottom: 6px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-lg);\n text-decoration: none;\n cursor: pointer;\n transition: background var(--pillar-transition-fast);\n}\n\n._pillar-chat-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n.pillar-chat-sources {}\n.pillar-chat-sources-title {}\n.pillar-chat-source {}\n\n/* ============================================================================\n Chat Actions (Suggested action buttons)\n Internal: _pillar-chat-actions | Public: pillar-chat-actions\n ============================================================================ */\n\n._pillar-chat-actions {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-actions-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-actions-buttons {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Task buttons should wrap horizontally */\n._pillar-chat-actions-buttons > ._pillar-task-button-group {\n display: flex;\n flex-wrap: wrap;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Confirm cards take full width */\n._pillar-chat-actions-buttons > .pillar-confirm-card-wrapper {\n width: 100%;\n}\n\n.pillar-chat-actions {}\n.pillar-chat-actions-title {}\n.pillar-chat-actions-buttons {}\n\n/* ============================================================================\n Chat View Input Area - Cursor-style design\n ============================================================================ */\n\n._pillar-chat-view-input-area {\n flex-shrink: 0;\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n border-top: 1px solid var(--pillar-border);\n background: var(--pillar-bg);\n}\n\n._pillar-chat-view-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-chat-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-chat-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-chat-view-send-btn:active:not(:disabled) {\n transform: scale(0.95);\n}\n\n._pillar-chat-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-chat-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-chat-view-input-area {}\n.pillar-chat-view-input-wrapper {}\n.pillar-chat-view-input {}\n.pillar-chat-view-send-btn {}\n.pillar-chat-view-input-footer {}\n.pillar-chat-view-new-chat-btn {}\n\n/* New chat button styling */\n._pillar-chat-view-input-footer {\n display: flex;\n justify-content: center;\n margin-top: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-new-chat-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 6px 12px;\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n font-family: var(--pillar-font-family);\n color: var(--pillar-text-muted);\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-new-chat-btn:hover {\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-chat-view-new-chat-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-view-new-chat-icon svg {\n width: 14px;\n height: 14px;\n}\n\n/* Scrollbar for chat view */\n._pillar-chat-view-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Chat Image Upload\n ============================================================================ */\n\n._pillar-chat-view-input-area--dragging {\n position: relative;\n background: rgba(37, 99, 235, 0.05);\n}\n\n._pillar-chat-drop-overlay {\n position: absolute;\n inset: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: rgba(37, 99, 235, 0.1);\n border: 2px dashed var(--pillar-primary);\n border-radius: var(--pillar-radius-lg);\n color: var(--pillar-primary);\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n z-index: 10;\n pointer-events: none;\n}\n\n._pillar-chat-drop-overlay svg {\n width: 24px;\n height: 24px;\n}\n\n._pillar-chat-images-preview {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 12px 4px 12px;\n}\n\n._pillar-chat-image-thumb {\n position: relative;\n width: 56px;\n height: 56px;\n border-radius: var(--pillar-radius-md);\n overflow: hidden;\n border: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-image-thumb img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n._pillar-chat-image-loading {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-image-error {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(239, 68, 68, 0.3);\n color: #dc2626;\n font-weight: bold;\n font-size: 14px;\n}\n\n._pillar-chat-image-remove {\n position: absolute;\n top: 2px;\n right: 2px;\n width: 18px;\n height: 18px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n border: none;\n border-radius: 50%;\n color: white;\n cursor: pointer;\n opacity: 0;\n transition: opacity var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-thumb:hover ._pillar-chat-image-remove {\n opacity: 1;\n}\n\n._pillar-chat-image-remove svg {\n width: 10px;\n height: 10px;\n}\n\n._pillar-chat-image-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-btn:hover:not(:disabled) {\n color: var(--pillar-text);\n}\n\n._pillar-chat-image-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n._pillar-chat-image-btn svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-chat-images-preview {}\n.pillar-chat-image-thumb {}\n.pillar-chat-image-remove {}\n.pillar-chat-image-btn {}\n.pillar-chat-drop-overlay {}\n\n/* ============================================================================\n Legacy Class Mappings (for backward compatibility)\n Maps old BEM-style class names to new internal classes\n ============================================================================ */\n\n.pillar-panel { }\n.pillar-panel--right { }\n.pillar-panel--left { }\n.pillar-panel--open { }\n.pillar-panel--manual { }\n.pillar-panel-root { }\n.pillar-panel-ui { }\n.pillar-panel__header { }\n.pillar-panel__header-left { }\n.pillar-panel__back-btn { }\n.pillar-panel__home-btn { }\n.pillar-panel__title { }\n.pillar-panel__close-btn { }\n.pillar-panel__content { }\n.pillar-search { }\n.pillar-search__input { }\n.pillar-search__icon { }\n.pillar-category-card { }\n.pillar-category-card__icon { }\n.pillar-category-card__content { }\n.pillar-category-card__title { }\n.pillar-category-card__description { }\n.pillar-category-card__count { }\n.pillar-article-card { }\n.pillar-article-card__title { }\n.pillar-article-card__excerpt { }\n.pillar-article-card__meta { }\n.pillar-article { }\n.pillar-article__title { }\n.pillar-article__content { }\n.pillar-category-header { }\n.pillar-category-header__title { }\n.pillar-category-header__description { }\n.pillar-chat-input-container { }\n.pillar-chat-input-container--expanded { }\n.pillar-chat-input__messages { }\n.pillar-chat-input__message { }\n.pillar-chat-input__message--user { }\n.pillar-chat-input__message--assistant { }\n.pillar-chat-input__message-content { }\n.pillar-chat-input__sources { }\n.pillar-chat-input__sources-title { }\n.pillar-chat-input__source { }\n.pillar-chat-input__area { }\n.pillar-chat-input__wrapper { }\n.pillar-chat-input__input { }\n.pillar-chat-input__send-btn { }\n.pillar-loading { }\n.pillar-loading__spinner { }\n.pillar-empty { }\n.pillar-empty__icon { }\n.pillar-empty__title { }\n.pillar-empty__description { }\n.pillar-section-title { }\n.pillar-related-articles { }\n.pillar-home-view { }\n.pillar-chat-view { }\n.pillar-chat-view__messages { }\n.pillar-chat-view__welcome { }\n.pillar-chat-view__welcome-icon { }\n.pillar-chat-view__welcome-title { }\n.pillar-chat-view__welcome-text { }\n.pillar-chat-view__message { }\n.pillar-chat-view__message--user { }\n.pillar-chat-view__message--assistant { }\n.pillar-chat-view__user-bubble { }\n.pillar-chat-view__ai-response { }\n.pillar-chat-view__sources { }\n.pillar-chat-view__sources-title { }\n.pillar-chat-view__source { }\n.pillar-chat-view__input-area { }\n.pillar-chat-view__input-wrapper { }\n.pillar-chat-view__input { }\n.pillar-chat-view__send-btn { }\n.pillar-backdrop { }\n.pillar-backdrop--visible { }\n\n/* ============================================================================\n Task Button Component\n ============================================================================ */\n\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n\n/* ============================================================================\n Feedback Icons\n Internal: _pillar-feedback | Public: pillar-feedback\n ============================================================================ */\n\n._pillar-message-assistant-wrapper {\n position: relative;\n}\n\n._pillar-feedback-icons {\n display: flex;\n gap: 4px;\n margin-top: var(--pillar-spacing-sm);\n justify-content: flex-end;\n}\n\n._pillar-feedback-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n color: var(--pillar-text-placeholder);\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-feedback-btn:hover {\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-border);\n}\n\n._pillar-feedback-btn--active {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-color: var(--pillar-primary);\n}\n\n._pillar-feedback-btn--active:hover {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-feedback-btn svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-feedback-icons {}\n.pillar-feedback-btn {}\n.pillar-message-assistant-wrapper {}\n\n/* ============================================================================\n Action Status Indicators\n Internal: _pillar-action-status | Public: pillar-action-status\n Shows completion status for auto-run actions (checkmark, X, or spinner)\n ============================================================================ */\n\n._pillar-message-assistant-content {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n}\n\n._pillar-action-status {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n flex-shrink: 0;\n margin-top: 2px;\n}\n\n._pillar-action-status-indicator {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n}\n\n._pillar-action-status-indicator svg {\n width: 16px;\n height: 16px;\n}\n\n._pillar-action-status-indicator--success {\n color: #22c55e;\n}\n\n._pillar-action-status-indicator--failed {\n color: #ef4444;\n}\n\n._pillar-action-status-indicator--pending {\n color: var(--pillar-text-muted);\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.pillar-action-status {}\n.pillar-action-status-indicator {}\n.pillar-message-assistant-content {}\n\n/* ============================================================================\n Context Tags\n Internal: _pillar-context-tag | Public: pillar-context-tag\n Removable chips for user context items (highlighted text, etc.)\n ============================================================================ */\n\n._pillar-context-tag-list {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n padding: 8px 14px 0;\n}\n\n._pillar-context-tag {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 200px;\n padding: 4px 6px 4px 8px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-secondary);\n background: var(--pillar-bg-tertiary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: default;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag:hover {\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-context-tag-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n color: var(--pillar-primary);\n}\n\n._pillar-context-tag-icon svg {\n width: 12px;\n height: 12px;\n}\n\n._pillar-context-tag-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n line-height: 1.3;\n}\n\n._pillar-context-tag-remove {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n padding: 0;\n margin-left: 2px;\n color: var(--pillar-text-placeholder);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-sm);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag-remove:hover {\n color: var(--pillar-text);\n background: var(--pillar-border);\n}\n\n._pillar-context-tag-remove svg {\n width: 12px;\n height: 12px;\n}\n\n.pillar-context-tag-list {}\n.pillar-context-tag {}\n.pillar-context-tag-icon {}\n.pillar-context-tag-label {}\n.pillar-context-tag-remove {}\n\n/* Context tags inside user message bubbles need inverted colors */\n._pillar-message-user ._pillar-context-tag-list {\n padding: 0 0 8px 0;\n}\n\n._pillar-message-user ._pillar-context-tag {\n background: rgba(255, 255, 255, 0.2);\n border-color: rgba(255, 255, 255, 0.3);\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag:hover {\n background: rgba(255, 255, 255, 0.3);\n border-color: rgba(255, 255, 255, 0.4);\n}\n\n._pillar-message-user ._pillar-context-tag-icon {\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag-label {\n color: #ffffff;\n}\n\n/* ============================================================================\n Unified Chat Input\n Internal: _pillar-unified-input | Public: pillar-unified-input\n Reusable input component with context tag support\n ============================================================================ */\n\n._pillar-unified-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-unified-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-unified-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-unified-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-unified-input:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n._pillar-unified-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-unified-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: #ffffff;\n background: var(--pillar-primary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-unified-send-btn:hover:not(:disabled) {\n background: var(--pillar-primary-hover);\n}\n\n._pillar-unified-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-unified-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-unified-input-wrapper {}\n.pillar-unified-input {}\n.pillar-unified-input-row {}\n.pillar-unified-send-btn {}\n",ii=qe(null),ai=qe([]);Fe(()=>null!==ii.value),Fe(()=>ii.value&&ii.value.steps[ii.value.current_step]||null);const li=Fe(()=>ii.value?ii.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);function oi(e,n){if(!ii.value)return;const t=ii.value.steps.map((t,r)=>r===e?{...t,status:n}:t);ii.value={...ii.value,steps:t}}function si(){if(!ii.value)return null;const e=ii.value.current_step+1;if(e>=ii.value.steps.length)return null;const n=ii.value.steps[e].auto_run?"active":"awaiting_initiation",t=ii.value.steps.map((t,r)=>r===e?{...t,status:n}:t);return ii.value={...ii.value,steps:t,current_step:e},ii.value.steps[e]}function pi(){if(!ii.value)return null;const e=ii.value;return ai.value=[...ai.value,e],ii.value=null,e}Fe(()=>ii.value?li.value/ii.value.total_steps:0);const ci="\n/* Workflow Checklist Container */\n.pillar-workflow {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin: 12px 0;\n}\n\n/* Header */\n.pillar-workflow__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.pillar-workflow__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #6b7280;\n}\n\n.pillar-workflow__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: #1a1a1a;\n}\n\n.pillar-workflow__progress {\n font-size: 12px;\n font-weight: 500;\n color: #6b7280;\n padding: 2px 8px;\n background: #e5e7eb;\n border-radius: 10px;\n}\n\n.pillar-workflow__description {\n font-size: 13px;\n color: #6b7280;\n}\n\n/* Steps List */\n.pillar-workflow__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Individual Step */\n.pillar-workflow-step {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n background: #ffffff;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-workflow-step__content {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.pillar-workflow-step__label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n}\n\n.pillar-workflow-step__note {\n font-size: 12px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__status-text {\n font-size: 12px;\n color: #2563eb;\n font-style: italic;\n}\n\n.pillar-workflow-step__actions {\n display: flex;\n gap: 8px;\n margin-top: 4px;\n}\n\n/* Step States */\n.pillar-workflow-step--pending {\n opacity: 0.6;\n}\n\n.pillar-workflow-step--awaiting_initiation {\n background: #fef3c7;\n border-color: #fcd34d;\n}\n\n.pillar-workflow-step--awaiting_initiation .pillar-workflow-step__icon {\n color: #d97706;\n}\n\n.pillar-workflow-step--active {\n background: #eff6ff;\n border-color: #93c5fd;\n}\n\n.pillar-workflow-step--active .pillar-workflow-step__icon {\n color: #2563eb;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__icon {\n color: #059669;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #6b7280;\n}\n\n.pillar-workflow-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__icon {\n color: #9ca3af;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #9ca3af;\n}\n\n.pillar-workflow-step--failed {\n background: #fef2f2;\n border-color: #fca5a5;\n}\n\n.pillar-workflow-step--failed .pillar-workflow-step__icon {\n color: #dc2626;\n}\n\n/* Start Button */\n.pillar-workflow-step__start-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: #2563eb;\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__start-btn:hover {\n background: #1d4ed8;\n}\n\n/* Skip Button */\n.pillar-workflow-step__skip-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #6b7280;\n border: 1px solid #d1d5db;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__skip-btn:hover {\n background: #f3f4f6;\n color: #374151;\n}\n\n/* Spinner Animation for Active Step */\n@keyframes pillar-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n.pillar-workflow-step__spinner {\n animation: pillar-spin 1s linear infinite;\n}\n\n/* Footer */\n.pillar-workflow__footer {\n display: flex;\n justify-content: flex-end;\n padding-top: 8px;\n border-top: 1px solid #e5e7eb;\n}\n\n.pillar-workflow__cancel-btn {\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #9ca3af;\n border: none;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow__cancel-btn:hover {\n color: #dc2626;\n}\n";class di{constructor(e,n,t,r){this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,this.unsubscribe=null,this.isManualMount=!1,this.themeObserver=null,this.handleKeyDown=e=>{"Escape"===e.key&&en.value&&un()},this.config=e,this.api=n,this.events=t,this.rootContainer=r||null,this.isManualMount="manual"===e.panel.container}detectThemeFromDOM(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}get isOpen(){return en.value}async init(){var e,n,t;e=this.config.panel.position,tn.value=e,(e=>{rn.value=e})(this.config.panel.mode),(e=>{an.value=e})(this.config.panel.width),n=this.config.panel.hoverBreakpoint,ln.value=n,t=this.config.panel.hoverBackdrop,on.value=t,(()=>{if("undefined"==typeof window)return;pn?.();const e=()=>{sn.value=window.innerWidth};sn.value=window.innerWidth,window.addEventListener("resize",e),pn=()=>{window.removeEventListener("resize",e)}})(),this.createHost(),this.isManualMount||this.createBackdrop(),this.createPanel(),this.renderPreact(),this.bindEvents(),this.subscribeToState()}open(e){if(en.value)return e?.view&&Zn(e.view),void(e?.focusInput&&Dn());en.value=!0,"overlay"===dn.value&&(document.body.style.overflow="hidden"),e?.view&&Zn(e.view),e?.focusInput?Dn():this.setupFocusTrap()}close(){en.value&&un()}navigate(e,n){en.value?Zn(e,n):this.open({view:e})}destroy(){this.close(),this.isManualMount||this.removePushModeStyles(),this.unsubscribe?.(),this.unsubscribe=null,pn?.(),pn=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.renderRoot&&Y(null,this.renderRoot),this.backdrop?.remove(),this.host?.remove(),document.getElementById("pillar-sdk-styles")?.remove(),document.getElementById("pillar-sdk-theme")?.remove(),document.getElementById("pillar-sdk-custom")?.remove(),this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,document.removeEventListener("keydown",this.handleKeyDown),hn(),Gn(),Un()}subscribeToState(){if(this.isManualMount)return void(this.unsubscribe=en.subscribe(e=>{e||this.events.emit("panel:close")}));let e=en.value,n=dn.value;const t=()=>{const e=en.value,n="push"===dn.value,t=an.value,r=tn.value,i=cn.value&&on.value;e?(n?(this.applyPushModeStyles(t,r),this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")):(this.removePushModeStyles(),i?this.backdrop?.classList.add("_pillar-backdrop--visible","pillar-backdrop--visible"):this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")),this.panelElement?.classList.add("_pillar-panel--open","pillar-panel--open")):(this.removePushModeStyles(),this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible"),this.panelElement?.classList.remove("_pillar-panel--open","pillar-panel--open"))},r=en.subscribe(n=>{n!==e&&(e=n,t(),n||(setTimeout(()=>{en.value||(Gn(),Un())},300),this.events.emit("panel:close")))}),i=dn.subscribe(e=>{e!==n&&(n=e,t())});this.unsubscribe=()=>{r(),i()}}applyPushModeStyles(e,n){document.documentElement.style.transition="padding 0.3s ease","right"===n?document.documentElement.style.paddingRight=`${e}px`:document.documentElement.style.paddingLeft=`${e}px`}removePushModeStyles(){document.documentElement.style.paddingLeft="",document.documentElement.style.paddingRight="",setTimeout(()=>{en.value||(document.documentElement.style.transition="")},300)}get renderContainer(){return this.shadow||this.host}transformStylesForRegularDOM(e){return e.replace(/:host\(([^)]+)\)/g,"[data-pillar-panel]$1").replace(/:host-context\(([^)]+)\)/g,"$1 [data-pillar-panel]").replace(/:host:not\(([^)]+)\)/g,"[data-pillar-panel]:not($1)").replace(/:host/g,"[data-pillar-panel]")}injectStylesIntoHead(){const e="pillar-sdk-styles";if(document.getElementById(e))return;const n=ri+Jr+ci+rt+wt+ut+st,t=this.transformStylesForRegularDOM(n),r=document.createElement("style");r.id=e,r.textContent=t,document.head.appendChild(r);const i=ti(this.config.theme);if(i){const e=document.createElement("style");e.id="pillar-sdk-theme",e.textContent=this.transformStylesForRegularDOM(i),document.head.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.id="pillar-sdk-custom",e.textContent=this.transformStylesForRegularDOM(this.config.customCSS),document.head.appendChild(e)}}injectStylesIntoShadow(){if(!this.shadow)return;const e=document.createElement("style");e.textContent=ri+Jr+ci+rt+wt+ut+st,this.shadow.appendChild(e);const n=ti(this.config.theme);if(n){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme",""),this.shadow.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.textContent=this.config.customCSS,e.setAttribute("data-pillar-custom",""),this.shadow.appendChild(e)}}createHost(){this.host=document.createElement("div"),this.host.className="pillar-panel-host",this.host.setAttribute("data-pillar-panel",""),this.config.panel.useShadowDOM?(this.shadow=this.host.attachShadow({mode:"open"}),this.injectStylesIntoShadow()):(this.shadow=null,this.injectStylesIntoHead()),this.applyThemeMode(),this.setupThemeObserver();const e=this.config.panel.container;if("manual"===e)return;const n=this.rootContainer||document.body;let t=null;"string"==typeof e?(t=document.querySelector(e),t||(console.warn(`[Pillar] Container element not found: ${e}, falling back to root container`),t=n)):t=e instanceof HTMLElement?e:n,t.appendChild(this.host)}mountTo(e){this.host?(this.host.parentElement&&this.host.parentElement.removeChild(this.host),e.appendChild(this.host)):console.warn("[Pillar] Panel host not created yet")}getHostElement(){return this.host}createBackdrop(){this.backdrop=document.createElement("div"),this.backdrop.className="_pillar-backdrop pillar-backdrop",this.backdrop.style.cssText="\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.3s ease, visibility 0.3s ease;\n z-index: 99998;\n ",this.backdrop.addEventListener("click",()=>{un()}),document.body.appendChild(this.backdrop)}createPanel(){const e=this.renderContainer;if(!e)return;this.panelElement=document.createElement("div");const n=this.isManualMount?" _pillar-panel--manual pillar-panel--manual":"",t=`_pillar-panel--${tn.value} pillar-panel--${tn.value}`;this.panelElement.className=`_pillar-panel pillar-panel ${t}${n}`,this.panelElement.style.setProperty("--pillar-panel-width",`${an.value}px`),this.panelElement.setAttribute("role","dialog"),this.panelElement.setAttribute("aria-modal","true"),this.panelElement.setAttribute("aria-label","Assistant panel"),this.renderRoot=document.createElement("div"),this.renderRoot.className="_pillar-panel-root pillar-panel-root",this.panelElement.appendChild(this.renderRoot),e.appendChild(this.panelElement)}renderPreact(){this.renderRoot&&Y(ne(at,{api:this.api,events:this.events,children:ne(ei,{})}),this.renderRoot)}bindEvents(){document.addEventListener("keydown",this.handleKeyDown)}setupFocusTrap(){setTimeout(()=>{const e=this.renderContainer,n=e?.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');n?.focus()},100)}applyThemeMode(){if(!this.host)return;const e=this.config.theme.mode;if("light"===e||"dark"===e)this.host.setAttribute("data-theme",e);else{const e=this.detectThemeFromDOM();this.host.setAttribute("data-theme",e)}}setupThemeObserver(){"auto"===this.config.theme.mode&&(this.themeObserver=new MutationObserver(()=>{this.applyThemeMode()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}))}setTheme(e){this.config={...this.config,theme:{...this.config.theme,...e,colors:{...this.config.theme.colors,...e.colors},darkColors:{...this.config.theme.darkColors,...e.darkColors}}},this.applyThemeMode();const n=ti(this.config.theme);if(this.shadow){const e=this.shadow.querySelector("style[data-pillar-theme]");if(e&&n)e.textContent=n;else if(n&&!e){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme","");const t=this.shadow.querySelector("style");t?.nextSibling?this.shadow.insertBefore(e,t.nextSibling):this.shadow.appendChild(e)}}else{const e=this.transformStylesForRegularDOM(n),t=document.getElementById("pillar-sdk-theme");if(t&&e)t.textContent=e;else if(e&&!t){const n=document.createElement("style");n.id="pillar-sdk-theme",n.textContent=e,document.head.appendChild(n)}}}}function ui({label:e,x:n,y:t,isVisible:r,onClick:i}){const a=ve(null),[l,o]=_e({x:n,y:t}),[s,p]=_e(!1),c=xe(()=>{if(!a.current||!r)return;const e=a.current.getBoundingClientRect(),i=window.innerWidth;let l=n,s=t,c=!1;l=n-e.width/2,l<10?l=10:l+e.width>i-10&&(l=i-e.width-10),s=t-e.height-10,s<10&&(s=t+10,c=!0),o({x:l,y:s}),p(c)},[n,t,r]);me(()=>{r&&requestAnimationFrame(c)},[r,c,n,t]);return ne("div",{ref:a,class:`pillar-text-selection-popover${r?" pillar-text-selection-popover--visible":""}${s?" pillar-text-selection-popover--below":""}`,style:{left:`${l.x}px`,top:`${l.y}px`},onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())},children:[ne("div",{class:"pillar-text-selection-popover__content",children:[ne("span",{class:"pillar-text-selection-popover__icon",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 2a1 1 0 011 1v1.323l3.954 1.582 1.599-.8a1 1 0 01.894 1.79l-1.233.616 1.738 5.42a1 1 0 01-.285 1.05A3.989 3.989 0 0115 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.715-5.349L10 6.477l-3.763 1.105 1.715 5.349a1 1 0 01-.285 1.05A3.989 3.989 0 015 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.738-5.42-1.233-.617a1 1 0 01.894-1.788l1.599.799L9 4.323V3a1 1 0 011-1z"/></svg>'}}),ne("span",{children:e})]}),ne("div",{class:"pillar-text-selection-popover__arrow"})]})}const hi="pillar-text-selection-styles";class fi{constructor(e,n,t){this.container=null,this.isVisible=!1,this.currentSelection="",this.stylesInjected=!1,this.handleMouseUp=e=>{setTimeout(()=>{this.checkSelection(e)},10)},this.handleMouseDown=e=>{e.target.closest(".pillar-text-selection-popover")||this.hidePopover()},this.handleKeyDown=e=>{"Escape"===e.key&&this.hidePopover()},this.handleScroll=()=>{this.isVisible&&this.hidePopover()},this.handlePopoverClick=()=>{this.currentSelection&&(this.events.emit("textSelection:click",{text:this.currentSelection}),(e=>{const n={...e,id:`ctx_${Date.now()}_${Math.random().toString(36).substring(2,9)}`};In.value=[...In.value,n]})({type:"highlighted_text",url_origin:window.location.href,text_content:this.currentSelection}),this.hidePopover(),window.getSelection()?.removeAllRanges(),this.openPanel())},this.config=e,this.events=n,this.openPanel=t}init(){this.stylesInjected||(fn(document,"\n/* Pillar Text Selection Popover Styles */\n.pillar-text-selection-popover {\n position: absolute;\n z-index: 99999;\n padding: 6px 12px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 13px;\n font-weight: 500;\n line-height: 1;\n color: #ffffff;\n background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);\n pointer-events: auto;\n opacity: 0;\n transform: translateY(4px) scale(0.95);\n transition: opacity 0.15s ease, transform 0.15s ease;\n cursor: pointer;\n user-select: none;\n}\n\n.pillar-text-selection-popover.pillar-text-selection-popover--visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n}\n\n.pillar-text-selection-popover:hover {\n background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);\n box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);\n}\n\n.pillar-text-selection-popover:active {\n transform: translateY(0) scale(0.98);\n}\n\n.pillar-text-selection-popover__content {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.pillar-text-selection-popover__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n}\n\n.pillar-text-selection-popover__icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Arrow pointing down to selection */\n.pillar-text-selection-popover__arrow {\n position: absolute;\n bottom: -5px;\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n width: 10px;\n height: 10px;\n background: linear-gradient(135deg, #8b5cf6 0%, #8b5cf6 100%);\n}\n\n.pillar-text-selection-popover--below .pillar-text-selection-popover__arrow {\n bottom: auto;\n top: -5px;\n background: linear-gradient(135deg, #6366f1 0%, #6366f1 100%);\n}\n",hi),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-text-selection-container",document.body.appendChild(this.container),this.bindEvents()}destroy(){this.unbindEvents(),this.container&&(Y(null,this.container),this.container.remove(),this.container=null),document.getElementById(hi)?.remove(),this.stylesInjected=!1,this.isVisible=!1,this.currentSelection=""}bindEvents(){document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("scroll",this.handleScroll,!0)}unbindEvents(){document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("scroll",this.handleScroll,!0)}checkSelection(e){const n=window.getSelection();if(!n||n.isCollapsed)return;const t=n.toString().trim();if(t.length<3)return;const r=n.getRangeAt(0),i=r.commonAncestorContainer,a=i instanceof Element?i:i.parentElement;if(a?.closest("[data-pillar-panel]")||a?.closest(".pillar-panel-host"))return;const l=r.getBoundingClientRect(),o=l.left+l.width/2,s=l.top+window.scrollY;this.currentSelection=t,this.showPopover(o,s)}showPopover(e,n){this.container&&(this.isVisible=!0,Y(ne(ui,{label:this.config.textSelection.label,x:e,y:n,isVisible:!0,onClick:this.handlePopoverClick}),this.container),this.events.emit("textSelection:shown",{text:this.currentSelection}))}hidePopover(){this.container&&this.isVisible&&(this.isVisible=!1,Y(ne(ui,{label:this.config.textSelection.label,x:0,y:0,isVisible:!1,onClick:()=>{}}),this.container))}}const gi={recentActions:[]},_i={},mi=qe({...gi}),vi=qe({..._i});Fe(()=>{const e=mi.value;return!!(e.currentPage||e.currentFeature||e.userRole||e.errorState||e.recentActions&&e.recentActions.length>0)}),Fe(()=>!!mi.value.errorState);const bi="pillar-";const xi=[{id:"assistant",label:"Assistant",enabled:!0,order:0}],yi="https://api.trypillar.com",ki={enabled:!0,position:"right",mode:"push",width:380,useShadowDOM:!1,hoverBreakpoint:1200,hoverBackdrop:!0},wi={enabled:!0,position:"bottom-right",label:"Assistant",style:"edge"},Si={enabled:!0,prefix:"pillar-",clearAfterOpen:!0},Ci={enabled:!0,label:"Ask AI"},Pi={mode:"auto"};function $i(e){if(!e||0===e.length)return xi;const n=new Map;for(const e of xi)n.set(e.id,{...e});for(const t of e)n.set(t.id,{...t});const t=n.get("assistant");return t&&(t.enabled=!0),Array.from(n.values()).sort((e,n)=>e.order-n.order)}function Ti(e){return{helpCenter:e.helpCenter,publicKey:e.publicKey,apiBaseUrl:e.apiBaseUrl||yi,platform:e.platform||"web",version:e.version,panel:{...ki,...e.panel},floatingButton:{...wi,...e.floatingButton},urlParams:{...Si,...e.urlParams},textSelection:{...Ci,...e.textSelection},sidebarTabs:$i(e.sidebarTabs),theme:{mode:e.theme?.mode??Pi.mode,colors:{...e.theme?.colors},darkColors:{...e.theme?.darkColors}},customCSS:e.customCSS,context:e.context||{},onReady:e.onReady,onError:e.onError}}class Ei{constructor(){this.listeners=new Map}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.off(e,n)}}off(e,n){const t=this.listeners.get(e);t&&t.delete(n)}emit(e,n){const t=this.listeners.get(e);t&&t.forEach(t=>{try{t(n)}catch(n){console.error(`[Pillar] Error in event handler for "${e}":`,n)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}function zi(e){if(e)try{const n=Ai(e);localStorage.removeItem(n),console.log("[PlanPersistence] Cleared saved plan")}catch(e){console.warn("[PlanPersistence] Failed to clear plan:",e)}}function Ai(e){return`pillar:active_plan:${e}`}class Ii{constructor(e,n,t){this.mcpClient=e,this.events=n,this.siteId=t}async handlePlanReceived(e){console.log(`[PlanExecutor] Received plan: ${e.id}, auto_execute=${e.auto_execute}, status=${e.status}`),mt(e),this.persistPlan(e),e.auto_execute&&"executing"===e.status&&(this.events.emit("plan:start",e),await this.executeNextStep())}async recoverPlan(){const e=function(e){if(!e)return null;try{const n=Ai(e),t=localStorage.getItem(n);if(!t)return null;const r=JSON.parse(t);if(1!==r.version)return console.warn("[PlanPersistence] Stored plan has incompatible version, clearing"),zi(e),null;if(r.siteId!==e)return console.warn("[PlanPersistence] Stored plan is for different site, clearing"),zi(e),null;const i=new Date(r.storedAt),a=new Date,l=r.plan.timeout_minutes||30,o=(a.getTime()-i.getTime())/6e4;return o>l?(console.warn(`[PlanPersistence] Stored plan has timed out (${Math.round(o)} minutes old, timeout: ${l} minutes)`),zi(e),null):(console.log(`[PlanPersistence] Loaded plan ${r.plan.id} from localStorage`),r.plan)}catch(n){return console.warn("[PlanPersistence] Failed to load plan:",n),zi(e),null}}(this.siteId);if(!e)return console.log("[PlanExecutor] No saved plan found"),null;console.log(`[PlanExecutor] Found saved plan ${e.id}, fetching latest state from server`);try{const n=(await this.mcpClient.getPlan(e.id)).plan;return["planning","ready","executing","awaiting_start","awaiting_input","awaiting_result"].includes(n.status)?(mt(n),this.events.emit("plan:updated",n),console.log(`[PlanExecutor] Recovered plan ${n.id} with status ${n.status}`),"executing"===n.status&&await this.executeNextStep(),n):(console.log(`[PlanExecutor] Plan ${n.id} is no longer active (status: ${n.status}), clearing`),zi(this.siteId),null)}catch(e){return console.error("[PlanExecutor] Failed to recover plan from server:",e),zi(this.siteId),null}}persistPlan(e){!function(e,n){if(!e||!n)return;if(["planning","ready","executing","awaiting_start","awaiting_input","awaiting_result"].includes(e.status))try{const t={version:1,plan:e,siteId:n,storedAt:(new Date).toISOString()},r=Ai(n);localStorage.setItem(r,JSON.stringify(t)),console.log(`[PlanPersistence] Saved plan ${e.id} to localStorage`)}catch(e){console.warn("[PlanPersistence] Failed to save plan:",e)}else zi(n)}(e,this.siteId)}async startPlan(){const e=ht.value;if(e)if("awaiting_start"===e.status)try{const n=await this.mcpClient.startPlan(e.id);vt(n.plan),this.events.emit("plan:start",n.plan),await this.executeNextStep()}catch(n){console.error("[PlanExecutor] Failed to start plan:",n),this.events.emit("plan:error",{plan:e,error:n instanceof Error?n:new Error(String(n))})}else console.warn(`[PlanExecutor] Plan ${e.id} is not in awaiting_start status`);else console.warn("[PlanExecutor] No active plan to start")}async executeNextStep(){const e=ht.value;if(!e)return;let n=e.steps.find(e=>"ready"===e.status);if(n||(n=e.steps.find(e=>"awaiting_confirmation"===e.status&&e.requires_user_confirmation)),!n){const n=e.steps.every(e=>"completed"===e.status||"skipped"===e.status||"failed"===e.status);return void(n&&(console.log(`[PlanExecutor] Plan ${e.id} complete`),this.events.emit("plan:complete",e),xt(),zi(this.siteId)))}if(n.requires_user_confirmation&&"awaiting_confirmation"!==n.status)return bt(n.id,{status:"awaiting_confirmation"}),void this.events.emit("plan:step:confirm",{plan:ht.value,step:n});"awaiting_confirmation"!==n.status&&await this.executeStep(n)}async confirmStep(e,n){const t=ht.value;if(!t)return;const r=t.steps.find(n=>n.id===e);if(!r)return void console.warn(`[PlanExecutor] Step ${e} not found`);n&&bt(e,{action_data:{...r.action_data,...n}});const i=ht.value,a=i?.steps.find(n=>n.id===e);a&&await this.executeStep(a)}async skipStep(e){const n=ht.value;if(!n)return;const t=n.steps.find(n=>n.id===e);if(t)try{const r=await this.mcpClient.skipStep(n.id,e);vt(r.plan),this.events.emit("plan:step:skip",{plan:r.plan,step:t}),await this.executeNextStep()}catch(n){console.error("[PlanExecutor] Failed to skip step:",n),bt(e,{status:"skipped"}),this.events.emit("plan:step:skip",{plan:ht.value,step:t}),await this.executeNextStep()}else console.warn(`[PlanExecutor] Step ${e} not found`)}async retryStep(e){const n=ht.value;if(!n)return;const t=n.steps.find(n=>n.id===e);if(t)if(t.is_retriable)if(t.retry_count>=t.max_retries)console.warn(`[PlanExecutor] Step ${e} has exceeded max retries (${t.retry_count}/${t.max_retries})`);else try{const r=await this.mcpClient.retryStep(n.id,e);vt(r.plan);const i=r.plan.steps.find(n=>n.id===e);this.events.emit("plan:step:retry",{plan:r.plan,step:i||t,retryCount:i?.retry_count||t.retry_count+1}),await this.executeNextStep()}catch(e){console.error("[PlanExecutor] Failed to retry step:",e),this.events.emit("plan:error",{plan:ht.value,error:e instanceof Error?e:new Error(String(e))})}else console.warn(`[PlanExecutor] Step ${e} is not retriable`);else console.warn(`[PlanExecutor] Step ${e} not found`)}async cancel(){const e=ht.value;if(e)try{const n=await this.mcpClient.cancelPlan(e.id);vt(n.plan),this.events.emit("plan:cancel",n.plan),xt(!0),zi(this.siteId)}catch(n){console.error("[PlanExecutor] Failed to cancel plan:",n),this.events.emit("plan:cancel",e),xt(!0),zi(this.siteId)}else console.warn("[PlanExecutor] No active plan to cancel")}async completeStepByAction(e,n=!0,t){const r=ht.value;if(!r)return void console.warn("[PlanExecutor] No active plan");const i=r.steps.find(n=>n.action_name===e&&"awaiting_result"===n.status);i?(console.log(`[PlanExecutor] Completing step ${i.index} (${e}) via callback`),n?await this.markStepComplete(i.id,t):(bt(i.id,{status:"failed",result:{error:"Action failed by host app"}}),this.events.emit("plan:step:failed",{plan:ht.value,step:ht.value.steps.find(e=>e.id===i.id),error:new Error("Action failed by host app"),canRetry:i.is_retriable}))):console.warn(`[PlanExecutor] No awaiting step found for action: ${e}`)}async markStepDone(e){const n=ht.value;if(!n)return void console.warn("[PlanExecutor] No active plan");const t=n.steps.find(n=>n.id===e);t?"awaiting_result"===t.status?(console.log(`[PlanExecutor] Marking step ${t.index} as done via UI button`),await this.markStepComplete(e)):console.warn(`[PlanExecutor] Step ${e} is not awaiting result (status: ${t.status})`):console.warn(`[PlanExecutor] Step ${e} not found`)}async markStepComplete(e,n){bt(e,{status:"completed",result:n});const t=ht.value,r=t.steps.find(n=>n.id===e);this.events.emit("plan:step:complete",{plan:t,step:r,success:!0}),await this.executeNextStep()}async executeStep(e){const n=ht.value;if(n){console.log(`[PlanExecutor] Executing step ${e.index}: ${e.action_name}`),bt(e.id,{status:"executing"}),this.events.emit("plan:step:active",{plan:ht.value,step:e});try{const t=l(e.action_name)?a(e.action_name):void 0,r=t?.handler;let i;if(r){if(i=await r(e.action_data),t?.returns&&void 0!==i){const{default:n}=await Promise.resolve().then(function(){return Mi}),t=n.getInstance();t&&t.sendActionResult(e.action_name,i)}}else{const{default:n}=await Promise.resolve().then(function(){return Mi}),t=n.getInstance();if(!t)throw new Error(`No handler for action: ${e.action_name} (Pillar not initialized)`);{const n=e.action_type,r=e.action_data?.path,a=e.action_data?.url;console.log(`[PlanExecutor] Executing via Pillar.executeTask: ${e.action_name}`),t.executeTask({id:e.id,name:e.action_name,taskType:n,path:r,externalUrl:a,data:e.action_data||{}}),i={executed:!0,action:e.action_name}}}if(e.requires_result_feedback){console.log(`[PlanExecutor] Sending step ${e.index} result to server`);const t=await this.mcpClient.continuePlan(n.id,e.id,i);vt(t.plan),this.events.emit("plan:updated",t.plan)}else if(e.auto_complete){bt(e.id,{status:"completed",result:i});const n=ht.value,t=n?.steps.find(n=>n.id===e.id);this.events.emit("plan:step:complete",{plan:n,step:t||e,success:!0}),await this.executeNextStep()}else console.log(`[PlanExecutor] Step ${e.index} awaiting callback (auto_complete=false)`),bt(e.id,{status:"awaiting_result",result:i}),this.events.emit("plan:step:active",{plan:ht.value,step:e})}catch(t){console.error(`[PlanExecutor] Step ${e.index} failed:`,t);const r=t instanceof Error?t.message:"Unknown error";try{vt((await this.mcpClient.failStep(n.id,e.id,r)).plan)}catch(n){console.error("[PlanExecutor] Failed to notify server of step failure:",n),bt(e.id,{status:"failed",error_message:r})}const i=ht.value,a=i?.steps.find(n=>n.id===e.id),l=a?a.is_retriable&&a.retry_count<a.max_retries:e.is_retriable&&e.retry_count<e.max_retries;this.events.emit("plan:step:failed",{plan:i,step:a||e,error:t instanceof Error?t:new Error(String(t)),canRetry:l}),this.events.emit("plan:step:complete",{plan:i,step:a||e,success:!1}),l||this.events.emit("plan:error",{plan:i,error:t instanceof Error?t:new Error(String(t))})}}}getActivePlan(){return ht.value}}class Ri{constructor(){this._state="uninitialized",this._config=null,this._api=null,this._mcpClient=null,this._planExecutor=null,this._textSelectionManager=null,this._panel=null,this._floatingButton=null,this._initPromise=null,this._rootContainer=null,this._unsubscribeHoverMode=null,this._productContext={...gi},this._userProfile={..._i},this._taskHandlers=new Map,this._anyTaskHandler=null,this._cardRenderers=new Map,this._events=new Ei}_createRootContainer(){let e=document.getElementById("pillar-root");if(e)return this._subscribeToHoverModeForRoot(e),e;e=document.createElement("div"),e.id="pillar-root";const n=cn.value?"20":"-1";return e.style.cssText=`isolation: isolate; z-index: ${n}; position: relative;`,document.body.appendChild(e),this._subscribeToHoverModeForRoot(e),e}_subscribeToHoverModeForRoot(e){this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=cn.subscribe(n=>{e.style.zIndex=n?"20":"-1"})}static async init(e){if(!e.helpCenter||!e.publicKey)throw new Error("[Pillar] helpCenter and publicKey are required");return Ri.instance||(Ri.instance=new Ri),await Ri.instance._init(e),Ri.instance}static getInstance(){return Ri.instance}static destroy(){Ri.instance&&(Ri.instance._destroy(),Ri.instance=null)}get state(){return this._state}get isReady(){return"ready"===this._state}get isPanelOpen(){return en.value}get config(){return this._config}on(e,n){return this._events.on(e,n)}open(e){this._panel&&(this._panel.open(e),this._events.emit("panel:open"))}close(){this._panel&&(this._panel.close(),this._events.emit("panel:close"))}toggle(){this.isPanelOpen?this.close():this.open()}navigate(e,n){this._panel?.navigate(e,n),this._events.emit("panel:navigate",{view:e,params:n})}setContext(e){this._config&&(this._config.context={...this._config.context,...e})}setTheme(e){this._config&&(this._config.theme={...this._config.theme,...e,mode:e.mode??this._config.theme.mode,colors:{...this._config.theme.colors,...e.colors},darkColors:{...this._config.theme.darkColors,...e.darkColors}},this._panel?.setTheme(this._config.theme),this._events.emit("theme:change",{theme:this._config.theme}))}setTextSelectionEnabled(e){if(!this._config)return;this._config.textSelection.enabled!==e&&(this._config.textSelection.enabled=e,e?this._config.panel.enabled&&!this._textSelectionManager&&(this._textSelectionManager=new fi(this._config,this._events,()=>this.open()),this._textSelectionManager.init()):this._textSelectionManager&&(this._textSelectionManager.destroy(),this._textSelectionManager=null),this._events.emit("textSelection:change",{enabled:e}))}mountPanelTo(e){this._panel?.mountTo(e)}getPanelHostElement(){return this._panel?.getHostElement()??null}get productContext(){return{...this._productContext}}get userProfile(){return{...this._userProfile}}setProductContext(e){this._productContext={...e,recentActions:e.recentActions||[]},(e=>{mi.value={...e,recentActions:e.recentActions||[]}})(this._productContext),this._events.emit("context:change",{context:this._productContext})}updateContext(e){this._productContext={...this._productContext,...e},(e=>{mi.value={...mi.value,...e}})(e),this._events.emit("context:change",{context:this._productContext})}setUserProfile(e){this._userProfile={...e},(e=>{vi.value={...e}})(this._userProfile),this._events.emit("profile:change",{profile:this._userProfile})}reportAction(e,n){const t=[...(this._productContext.recentActions||[]).slice(-9),e];this._productContext={...this._productContext,recentActions:t},(e=>{const n=mi.value.recentActions||[];mi.value={...mi.value,recentActions:[...n.slice(-9),e]}})(e),this._events.emit("action:report",{action:e,metadata:n})}clearErrorState(){if(this._productContext.errorState){const{errorState:e,...n}=this._productContext;this._productContext=n,(()=>{const{errorState:e,...n}=mi.value;mi.value=n})(),this._events.emit("context:change",{context:this._productContext})}}setErrorState(e,n){this._productContext={...this._productContext,errorState:{code:e,message:n}},((e,n)=>{mi.value={...mi.value,errorState:{code:e,message:n}}})(e,n),this._events.emit("context:change",{context:this._productContext})}async getSuggestions(){if(!this._api)return console.warn("[Pillar] SDK not initialized, cannot get suggestions"),[];try{return await this._api.getSuggestions(this._productContext,this._userProfile)}catch(e){return console.error("[Pillar] Failed to get suggestions:",e),[]}}getAssistantContext(){return{product:this._productContext,user:this._userProfile}}onTask(e,n){return this._taskHandlers.set(e,n),()=>this._taskHandlers.delete(e)}onAnyTask(e){return this._anyTaskHandler=e,()=>{this._anyTaskHandler=null}}offTask(e){this._taskHandlers.delete(e)}executeTask(e){const{name:n,data:t,taskType:r,path:i,externalUrl:o}=e;if(this._events.emit("task:execute",e),this._anyTaskHandler)try{this._anyTaskHandler(n,t)}catch(e){console.error("[Pillar] Error in onAnyTask handler:",e)}const s=l(n)?a(n):void 0,p=s?.handler,c=this._taskHandlers.get(n),d=r?this._taskHandlers.get(r):void 0,u=p||c||d;if(u)try{const e=u("navigate"===r&&i?{...t,path:i}:t);s?.returns&&void 0!==e&&Promise.resolve(e).then(e=>{void 0!==e&&this.sendActionResult(n,e)}).catch(e=>{console.error(`[Pillar] Error in query action "${n}":`,e)}),this._events.emit("task:complete",{name:n,success:!0,data:t})}catch(e){console.error(`[Pillar] Error executing task "${n}":`,e),this._events.emit("task:complete",{name:n,success:!1,data:t})}else switch(r){case"navigate":i&&"undefined"!=typeof window&&(console.warn("[Pillar] No 'navigate' handler registered. Using window.location.href as fallback."),window.location.href=i,this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"external_link":o&&"undefined"!=typeof window&&(window.open(o,"_blank","noopener,noreferrer"),this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"copy_text":t.text&&"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(String(t.text)).then(()=>{this._events.emit("task:complete",{name:n,success:!0,data:t})}).catch(()=>{this._events.emit("task:complete",{name:n,success:!1,data:t})});break;default:console.warn(`[Pillar] No handler registered for task "${n}". Register one with pillar.onTask('${n}', handler) or defineActions()`),this._events.emit("task:complete",{name:n,success:!1,data:{error:"No handler registered"}})}}completeTask(e,n=!0,t){this._events.emit("task:complete",{name:e,success:n,data:t})}confirmTaskExecution(e,n,t){e?this._api?this._api.confirmTaskExecution(e,n,t):console.warn("[Pillar] SDK not initialized, cannot confirm task execution"):console.warn("[Pillar] confirmTaskExecution called without taskId")}registerCard(e,n){return this._cardRenderers.set(e,n),()=>this._cardRenderers.delete(e)}getCardRenderer(e){return this._cardRenderers.get(e)}hasCardRenderer(e){return this._cardRenderers.has(e)}get workflow(){return ii.value}startWorkflow(e){!function(e){ii.value&&(ai.value=[...ai.value,ii.value]);const n=e.steps.map((e,n)=>0===n?{...e,status:e.auto_run?"active":"awaiting_initiation"}:{...e,status:"pending"});ii.value={...e,steps:n,current_step:0}}(e),this._events.emit("workflow:start",ii.value);const n=ii.value.steps[0];n.auto_run&&this._executeWorkflowStep(n)}initiateWorkflowStep(e){const n=ii.value;if(!n)return void console.warn("[Pillar] No active workflow");const t=e??n.current_step,r=n.steps[t];r?"awaiting_initiation"===r.status?this._executeWorkflowStep(r):console.warn(`[Pillar] Step ${t} is not awaiting initiation`):console.warn(`[Pillar] Invalid step index: ${t}`)}confirmWorkflowStep(e,n){const t=ii.value;if(!t)return;const r=n??t.current_step;if(t.steps[r],oi(r,e?"completed":"failed"),this._events.emit("workflow:step:complete",{workflow:ii.value,step:ii.value.steps[r],success:e}),!e)return;const i=si();if(!i)return this._events.emit("workflow:complete",ii.value),void pi();this._events.emit("workflow:step:active",{workflow:ii.value,step:i}),i.auto_run&&this._executeWorkflowStep(i)}skipWorkflowStep(e){const n=ii.value;if(!n)return;const t=e??n.current_step;n.steps[t],oi(t,"skipped"),this._events.emit("workflow:step:skip",{workflow:ii.value,step:ii.value.steps[t]});const r=si();if(!r)return this._events.emit("workflow:complete",ii.value),void pi();this._events.emit("workflow:step:active",{workflow:ii.value,step:r}),r.auto_run&&this._executeWorkflowStep(r)}cancelWorkflow(){const e=ii.value;e&&(this._events.emit("workflow:cancel",e),function(){if(!ii.value)return null;const e=ii.value;ii.value=null}())}_executeWorkflowStep(e){oi(e.index,"active"),this.executeTask({id:e.task_id,name:e.task_name,taskType:e.task_type,data:e.data,path:e.data?.path,externalUrl:e.data?.url}),e.auto_complete&&setTimeout(()=>{this.confirmWorkflowStep(!0,e.index)},100)}get activePlan(){return ht.value}handlePlanReceived(e){this._planExecutor?.handlePlanReceived(e)}async startPlan(){await(this._planExecutor?.startPlan())}async confirmPlanStep(e,n){await(this._planExecutor?.confirmStep(e,n))}async skipPlanStep(e){await(this._planExecutor?.skipStep(e))}async retryPlanStep(e){await(this._planExecutor?.retryStep(e))}async cancelPlan(){await(this._planExecutor?.cancel())}async completePlanStepByAction(e,n=!0,t){await(this._planExecutor?.completeStepByAction(e,n,t))}async markPlanStepDone(e){await(this._planExecutor?.markStepDone(e))}sendActionResult(e,n){this._mcpClient?(this._mcpClient.sendActionResult(e,n),this._events.emit("action:result",{actionName:e,result:n})):console.warn("[Pillar] SDK not initialized, cannot send action result")}async _init(e){if("initializing"===this._state&&this._initPromise)return console.log("[Pillar] Already initializing, waiting for completion"),void await this._initPromise;"ready"!==this._state?(this._state="initializing",this._initPromise=this._doInit(e),await this._initPromise):console.log("[Pillar] Already initialized")}async _doInit(e){try{await new Promise(e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e(),{once:!0}):e()});const n=Ti(e),r=new h(n),i=function(e,n){if(!n)return e;const t={...e};return n.panel&&(t.panel={...n.panel,...e.panel}),n.floatingButton&&(t.floatingButton={...n.floatingButton,...e.floatingButton}),n.sidebarTabs&&!e.sidebarTabs&&(t.sidebarTabs=n.sidebarTabs),n.theme?.colors?.primary&&(t.theme={...t.theme,colors:{primary:e.theme?.colors?.primary??n.theme.colors.primary,...e.theme?.colors}}),t}(e,await r.fetchEmbedConfig().catch(e=>(console.warn("[Pillar] Failed to fetch server config, using local config only:",e),null)));this._config=Ti(i),this._config.platform&&this._config.version&&t(this._config.platform,this._config.version),this._api=new h(this._config),this._mcpClient=new d(this._config),this._planExecutor=new Ii(this._mcpClient,this._events,this._config.helpCenter),this._rootContainer=this._createRootContainer(),this._config.panel.enabled&&(this._panel=new di(this._config,this._api,this._events,this._rootContainer),await this._panel.init()),this._config.floatingButton.enabled&&("edge"===this._config.floatingButton.style?this._floatingButton=new vn(this._config,()=>this.toggle(),this._rootContainer):this._floatingButton=new xn(this._config,()=>this.toggle()),this._floatingButton.init()),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new fi(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),this._state="ready",this._events.emit("ready"),this._config.onReady?.(),console.log("[Pillar] SDK initialized successfully"),await(this._planExecutor?.recoverPlan()),this._config.urlParams.enabled&&await this._handleUrlParams()}catch(e){this._state="error";const n=e instanceof Error?e:new Error(String(e));throw this._events.emit("error",n),this._config?.onError?.(n),console.error("[Pillar] Failed to initialize:",e),e}}async _handleUrlParams(){if(!this._config)return;(function(e=bi){if("undefined"==typeof window||!window.location)return{};const n=new URLSearchParams(window.location.search),t={};n.has(`${e}open`)&&(t.open=!0);const r=n.get(`${e}article`);r&&(t.article=r);const i=n.get(`${e}article-id`);i&&!t.article&&(t.article=i);const a=n.get(`${e}category`);a&&(t.category=a);const l=n.get(`${e}search`);return l&&(t.search=l),t})(this._config.urlParams.prefix).open&&(this.open(),this._config.urlParams.clearAfterOpen&&function(e=bi){if("undefined"==typeof window||!window.location||!window.history)return;const n=new URL(window.location.href),t=[`${e}open`,`${e}article`,`${e}article-id`,`${e}category`,`${e}search`];let r=!1;for(const e of t)n.searchParams.has(e)&&(n.searchParams.delete(e),r=!0);r&&window.history.replaceState({},"",n.toString())}(this._config.urlParams.prefix))}_destroy(){this._textSelectionManager?.destroy(),this._panel?.destroy(),this._floatingButton?.destroy(),this._api?.cancelAllRequests(),this._events.removeAllListeners(),this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=null,this._rootContainer?.remove(),this._rootContainer=null,hn(),Gn(),Un(),mi.value={...gi},vi.value={..._i},ii.value=null,ai.value=[],ht.value=null,ft.value=[],this._productContext={...gi},this._userProfile={..._i},this._taskHandlers.clear(),this._anyTaskHandler=null,this._textSelectionManager=null,this._panel=null,this._floatingButton=null,this._api=null,this._mcpClient=null,this._planExecutor=null,this._config=null,this._state="uninitialized",console.log("[Pillar] SDK destroyed")}}Ri.instance=null;var Mi=Object.freeze({__proto__:null,Pillar:Ri,default:Ri});if("undefined"!=typeof window){window.Pillar=Ri;const e=()=>{const e=document.currentScript;if(e){const n=e.dataset.helpCenter,t=e.dataset.publicKey;n&&t&&Ri.init({helpCenter:n,publicKey:t}).catch(console.error)}};if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",e);else{const e=document.querySelectorAll("script[data-help-center][data-public-key]");if(e.length>0){const n=e[e.length-1],t=n.dataset.helpCenter,r=n.dataset.publicKey;t&&r&&Ri.init({helpCenter:t,publicKey:r}).catch(console.error)}}}export{h as APIClient,xi as DEFAULT_SIDEBAR_TABS,Ei as EventEmitter,Ri as Pillar,p as clearRegistry,Ri as default,n as defineActions,c as getActionCount,a as getActionDefinition,o as getActionNames,r as getClientInfo,i as getHandler,s as getManifest,l as hasAction,t as setClientInfo};
1
+ const e={actions:new Map,clientInfo:null};function n(n){for(const[t,r]of Object.entries(n))e.actions.has(t)&&console.warn(`[Pillar] Action "${t}" is already registered. Overwriting.`),e.actions.set(t,r);return n}function t(n,t){e.clientInfo={platform:n,version:t}}function r(){return e.clientInfo}function i(n){const t=e.actions.get(n);return t?.handler}function a(n){return e.actions.get(n)}function l(n){return e.actions.has(n)}function o(){return Array.from(e.actions.keys())}function s(n,t,r){const i=[];for(const[n,t]of e.actions){const e={name:n,description:t.description,type:t.type};t.examples?.length&&(e.examples=t.examples),t.path&&(e.path=t.path),t.externalUrl&&(e.external_url=t.externalUrl),t.autoRun&&(e.auto_run=t.autoRun),t.autoComplete&&(e.auto_complete=t.autoComplete),t.returns&&(e.returns_data=t.returns),t.dataSchema&&(e.data_schema=t.dataSchema),t.defaultData&&(e.default_data=t.defaultData),t.requiredContext&&(e.required_context=t.requiredContext),i.push(e)}return{platform:n,version:t,gitSha:r,generatedAt:(new Date).toISOString(),actions:i}}function p(){e.actions.clear(),e.clientInfo=null}function c(){return e.actions.size}class d{constructor(e){this.requestId=0,this.config=e}get baseUrl(){return`${this.config.apiBaseUrl}/mcp/`}get headers(){const e={"Content-Type":"application/json","X-Pillar-Key":this.config.publicKey,"x-customer-id":this.config.helpCenter};return this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}nextId(){return++this.requestId}async callTool(e,n){const t={jsonrpc:"2.0",id:this.nextId(),method:"tools/call",params:{name:e,arguments:n}},r=await fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t)});if(!r.ok){const e=await r.json().catch(()=>({}));throw new Error(e.error?.message||`MCP error: ${r.status}`)}const i=await r.json();if(i.error)throw new Error(i.error.message);return i.result}async callToolStream(e,n,t,r){const i=this.nextId(),a={jsonrpc:"2.0",id:i,method:"tools/call",params:{name:e,arguments:n,stream:!0}},l=await fetch(this.baseUrl,{method:"POST",headers:{...this.headers,Accept:"text/event-stream"},body:JSON.stringify(a),signal:r});if(!l.ok){const e=await l.text();throw new Error(`MCP streaming request failed: ${l.statusText} - ${e}`)}if(!l.body)throw new Error("Response body is null");const o=l.body.getReader(),s=new TextDecoder;let p="",c=[],d=null;try{for(;;){const{done:e,value:n}=await o.read();if(e)break;p+=s.decode(n,{stream:!0});const r=p.split("\n");p=r.pop()||"";for(const e of r)if(e.trim()&&e.startsWith("data: "))try{const n=e.substring(6),r=JSON.parse(n);if("2.0"===r.jsonrpc){if(r.error)throw t.onError?.(r.error.message||"Unknown error"),new Error(r.error.message);if("notifications/progress"===r.method){const e=r.params?.progress;if(e)if("token"===e.kind&&e.token)c.push(e.token),t.onToken?.(e.token);else if("plan_created"===e.kind&&e.plan)t.onPlan?.(e.plan);else{if("cancelled"===e.kind)break;t.onProgress?.(e)}}if(r.result&&r.id===i){d=r.result,d.structuredContent?.sources&&t.onSources?.(d.structuredContent.sources),d.structuredContent?.actions&&t.onActions?.(d.structuredContent.actions),d.structuredContent?.plan&&t.onPlan?.(d.structuredContent.plan);const e=d._meta?.conversation_id,n=d._meta?.query_log_id;t.onComplete?.(e,n)}}}catch(n){console.error("[MCPClient] Failed to parse event:",n,e)}}}catch(e){if("AbortError"===e.name)throw e;throw t.onError?.(e instanceof Error?e.message:"Stream reading failed"),e}finally{o.releaseLock()}return d||(d={content:[{type:"text",text:c.join("")}],isError:!1}),d}async uploadImage(e){const n=`${this.config.apiBaseUrl}/mcp/upload-image/`,t=new FormData;t.append("image",e);const r=await fetch(n,{method:"POST",headers:{"x-customer-id":this.config.helpCenter},body:t});if(!r.ok){const e=await r.json().catch(()=>({error:"Upload failed"}));throw new Error(e.error||"Upload failed")}return r.json()}async ask(e,n,t){const r={query:e};return t?.articleSlug&&(r.article_slug=t.articleSlug),t?.userContext&&t.userContext.length>0&&(r.user_context=t.userContext),t?.images&&t.images.length>0&&(r.images=t.images),this.callToolStream("ask",r,n,t?.signal)}async continuePlan(e,n,t){return await this.callTool("plans/continue",{plan_id:e,step_id:n,result:t})}async cancelPlan(e){return await this.callTool("plans/cancel",{plan_id:e})}async getPlan(e){return await this.callTool("plans/get",{plan_id:e})}async startPlan(e){return await this.callTool("plans/start",{plan_id:e})}async retryStep(e,n){return await this.callTool("plans/retry-step",{plan_id:e,step_id:n})}async failStep(e,n,t){return await this.callTool("plans/fail-step",{plan_id:e,step_id:n,error_message:t||""})}async skipStep(e,n){return await this.callTool("plans/skip-step",{plan_id:e,step_id:n})}sendActionResult(e,n){const t={jsonrpc:"2.0",id:this.nextId(),method:"action/result",params:{action_name:e,result:n}};fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t)}).catch(e=>{console.error("[MCPClient] Failed to send action result:",e)})}}function u(e){return{id:e.id,name:e.name,taskType:e.action_type,data:e.data,autoRun:e.auto_run,autoComplete:e.auto_complete}}class h{constructor(e){this.abortControllers=new Map,this.config=e,this.mcpClient=new d(e)}get baseUrl(){return`${this.config.apiBaseUrl}/api/v1/help-center`}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),n}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_session_id";try{let n=sessionStorage.getItem(e);return n||(n=crypto.randomUUID(),sessionStorage.setItem(e,n)),n}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get headers(){const e={"Content-Type":"application/json","X-Pillar-Key":this.config.publicKey,"x-customer-id":this.config.helpCenter,"x-visitor-id":this.getVisitorId(),"x-session-id":this.getSessionId(),"x-page-url":this.getPageUrl()};return this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}async fetch(e,n={},t){if(t){this.abortControllers.get(t)?.abort();const e=new AbortController;this.abortControllers.set(t,e),n.signal=e.signal}const r=`${this.baseUrl}${e}`;try{const e=await fetch(r,{...n,headers:{...this.headers,...n.headers}});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.detail||n.message||`API error: ${e.status}`)}return e.json()}catch(n){if("AbortError"===n.name)throw n;throw console.error(`[Pillar API] Error fetching ${e}:`,n),n}finally{t&&this.abortControllers.delete(t)}}async fetchEmbedConfig(){try{const e=await fetch(`${this.config.apiBaseUrl}/api/public/products/${this.config.helpCenter}/embed-config/`,{method:"GET",headers:{"Content-Type":"application/json","X-Pillar-Key":this.config.publicKey}});return e.ok?await e.json():(console.warn("[Pillar] Failed to fetch embed config:",e.status),null)}catch(e){return console.warn("[Pillar] Failed to fetch embed config:",e),null}}async getSuggestedQuestions(){try{const e=await this.mcpClient.callTool("suggest_questions",{}),n=e.structuredContent?.questions;return Array.isArray(n)?n:[]}catch(e){return console.warn("[Pillar] Failed to get suggested questions:",e),[]}}async uploadImage(e){return this.mcpClient.uploadImage(e)}async chat(e,n=[],t,r,i,a,l,o,s,p){let c="",d=[],h=[];try{const n=await this.mcpClient.ask(e,{onToken:e=>{c+=e,t?.(e)},onSources:e=>{d=e},onActions:e=>{h=e.map(u),a?.(h)},onPlan:e=>{l?.(e)},onProgress:e=>{p?.(e)},onError:e=>{console.error("[Pillar API] MCP chat error:",e)}},{articleSlug:r,userContext:o,images:s});c||"text"!==n.content[0]?.type||(c=n.content[0].text||"");const i=n._meta||{};return{message:c,sources:d,actions:h,conversationId:i.conversation_id,messageId:i.query_log_id}}catch(e){throw console.error("[Pillar API] Chat error:",e),e}}async chatLegacy(e,n=[],t,r,i){const a=`${this.baseUrl}/ai/chat/`,l=await fetch(a,{method:"POST",headers:this.headers,body:JSON.stringify({message:e,history:n,context:this.config.context,...r&&{article_slug:r},...i&&{conversation_id:i}})});if(!l.ok){const e=await l.json().catch(()=>({}));throw new Error(e.detail||e.message||`Chat error: ${l.status}`)}if(t&&l.headers.get("content-type")?.includes("text/event-stream"))return this.handleStreamingChat(l,t);const o=await l.json();return{message:o.answer||o.message,sources:o.sources,workflow:o.workflow||o.structuredContent?.workflow,conversationId:o.conversation_id,messageId:o.message_id}}async handleStreamingChat(e,n){const t=e.body?.getReader();if(!t)throw new Error("No response body");const r=new TextDecoder;let i,a,l,o="",s=[];try{for(;;){const{done:e,value:p}=await t.read();if(e)break;const c=r.decode(p,{stream:!0}).split("\n");for(const e of c)if(e.startsWith("data: ")){const t=e.slice(6);if("[DONE]"===t)continue;try{const e=JSON.parse(t);e.content&&(o+=e.content,n(e.content)),e.sources&&(s=e.sources),e.workflow&&(i=e.workflow),e.structuredContent?.workflow&&(i=e.structuredContent.workflow),e.conversation_id&&(a=e.conversation_id),e.message_id&&(l=e.message_id)}catch{o+=t,n(t)}}}}finally{t.releaseLock()}return{message:o,sources:s,workflow:i,conversationId:a,messageId:l}}async submitFeedback(e,n,t){try{await this.fetch("/ai/feedback/",{method:"POST",body:JSON.stringify({message_id:e,feedback:n,...t&&{comment:t}})})}catch(e){console.warn("[Pillar] Feedback submission failed:",e)}}async confirmTaskExecution(e,n,t){try{const r={status:n,error:t?.error,duration_ms:t?.duration_ms,session_id:t?.session_id,conversation_id:t?.conversation_id,metadata:t};await this.fetch(`/tasks/${e}/confirm/`,{method:"POST",body:JSON.stringify(r)})}catch(e){console.warn("[Pillar] Failed to confirm task execution:",e)}}async getSuggestions(e,n){try{return(await this.fetch("/suggestions/",{method:"POST",body:JSON.stringify({context:e,user_profile:n})})).suggestions||[]}catch(e){return console.warn("[Pillar] Failed to get suggestions:",e),[]}}async chatWithContext(e,n=[],t,r,i,a,l){let o="",s=[],p=[];try{const n=await this.mcpClient.callToolStream("ask",{query:e,context:{product:t,user_profile:r},...a&&{conversation_id:a}},{onToken:e=>{o+=e,i?.(e)},onSources:e=>{s=e},onActions:e=>{p=e.map(u),l?.(p)},onError:e=>{console.error("[Pillar API] MCP chat with context error:",e)}});o||"text"!==n.content[0]?.type||(o=n.content[0].text||"");const c=n._meta||{};return{message:o,sources:s,actions:p,conversationId:c.conversation_id,messageId:c.query_log_id}}catch(e){throw console.error("[Pillar API] Chat with context error:",e),e}}cancelAllRequests(){this.abortControllers.forEach(e=>e.abort()),this.abortControllers.clear()}}var g,f,_,v,m,b,x,k,y,w,S,C,P,$={},T=[],E=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,z=Array.isArray;function A(e,n){for(var t in n)e[t]=n[t];return e}function I(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function R(e,n,t,r,i){var a={type:e,props:n,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++_:i,__i:-1,__u:0};return null==i&&null!=f.vnode&&f.vnode(a),a}function M(e){return e.children}function j(e,n){this.props=e,this.context=n}function L(e,n){if(null==n)return e.__?L(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e)return t.__e;return"function"==typeof e.type?L(e):null}function B(e){var n,t;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,n=0;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e){e.__e=e.__c.base=t.__e;break}return B(e)}}function H(e){(!e.__d&&(e.__d=!0)&&m.push(e)&&!q.__r++||b!=f.debounceRendering)&&((b=f.debounceRendering)||x)(q)}function q(){for(var e,n,t,r,i,a,l,o=1;m.length;)m.length>o&&m.sort(k),e=m.shift(),o=m.length,e.__d&&(t=void 0,r=void 0,i=(r=(n=e).__v).__e,a=[],l=[],n.__P&&((t=A({},r)).__v=r.__v+1,f.vnode&&f.vnode(t),V(n.__P,t,r,n.__n,n.__P.namespaceURI,32&r.__u?[i]:null,a,null==i?L(r):i,!!(32&r.__u),l),t.__v=r.__v,t.__.__k[t.__i]=t,Z(a,t,l),r.__e=r.__=null,t.__e!=i&&B(t)));q.__r=0}function D(e,n,t,r,i,a,l,o,s,p,c){var d,u,h,g,f,_,v,m=r&&r.__k||T,b=n.length;for(s=function(e,n,t,r,i){var a,l,o,s,p,c=t.length,d=c,u=0;for(e.__k=new Array(i),a=0;a<i;a++)null!=(l=n[a])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[a]=R(null,l,null,null,null):z(l)?l=e.__k[a]=R(M,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[a]=R(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[a]=l,s=a+u,l.__=e,l.__b=e.__b+1,o=null,-1!=(p=l.__i=N(l,t,s,d))&&(d--,(o=t[p])&&(o.__u|=2)),null==o||null==o.__v?(-1==p&&(i>c?u--:i<c&&u++),"function"!=typeof l.type&&(l.__u|=4)):p!=s&&(p==s-1?u--:p==s+1?u++:(p>s?u--:u++,l.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<c;a++)null!=(o=t[a])&&!(2&o.__u)&&(o.__e==r&&(r=L(o)),G(o,o));return r}(t,n,m,s,b),d=0;d<b;d++)null!=(h=t.__k[d])&&(u=-1==h.__i?$:m[h.__i]||$,h.__i=d,_=V(e,h,u,i,a,l,o,s,p,c),g=h.__e,h.ref&&u.ref!=h.ref&&(u.ref&&X(u.ref,null,h),c.push(h.ref,h.__c||g,h)),null==f&&null!=g&&(f=g),(v=!!(4&h.__u))||u.__k===h.__k?s=O(h,s,e,v):"function"==typeof h.type&&void 0!==_?s=_:g&&(s=g.nextSibling),h.__u&=-7);return t.__e=f,s}function O(e,n,t,r){var i,a;if("function"==typeof e.type){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,n=O(i[a],n,t,r));return n}e.__e!=n&&(r&&(n&&e.type&&!n.parentNode&&(n=L(e)),t.insertBefore(e.__e,n||null)),n=e.__e);do{n=n&&n.nextSibling}while(null!=n&&8==n.nodeType);return n}function N(e,n,t,r){var i,a,l,o=e.key,s=e.type,p=n[t],c=null!=p&&!(2&p.__u);if(null===p&&null==o||c&&o==p.key&&s==p.type)return t;if(r>(c?1:0))for(i=t-1,a=t+1;i>=0||a<n.length;)if(null!=(p=n[l=i>=0?i--:a++])&&!(2&p.__u)&&o==p.key&&s==p.type)return l;return-1}function U(e,n,t){"-"==n[0]?e.setProperty(n,null==t?"":t):e[n]=null==t?"":"number"!=typeof t||E.test(n)?t:t+"px"}function F(e,n,t,r,i){var a,l;e:if("style"==n)if("string"==typeof t)e.style.cssText=t;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(n in r)t&&n in t||U(e.style,n,"");if(t)for(n in t)r&&t[n]==r[n]||U(e.style,n,t[n])}else if("o"==n[0]&&"n"==n[1])a=n!=(n=n.replace(y,"$1")),l=n.toLowerCase(),n=l in e||"onFocusOut"==n||"onFocusIn"==n?l.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+a]=t,t?r?t.u=r.u:(t.u=w,e.addEventListener(n,a?C:S,a)):e.removeEventListener(n,a?C:S,a);else{if("http://www.w3.org/2000/svg"==i)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in e)try{e[n]=null==t?"":t;break e}catch(e){}"function"==typeof t||(null==t||!1===t&&"-"!=n[4]?e.removeAttribute(n):e.setAttribute(n,"popover"==n&&1==t?"":t))}}function W(e){return function(n){if(this.l){var t=this.l[n.type+e];if(null==n.t)n.t=w++;else if(n.t<t.u)return;return t(f.event?f.event(n):n)}}}function V(e,n,t,r,i,a,l,o,s,p){var c,d,u,h,_,v,m,b,x,k,y,w,S,C,P,T,E,R=n.type;if(void 0!==n.constructor)return null;128&t.__u&&(s=!!(32&t.__u),a=[o=n.__e=t.__e]),(c=f.__b)&&c(n);e:if("function"==typeof R)try{if(b=n.props,x="prototype"in R&&R.prototype.render,k=(c=R.contextType)&&r[c.__c],y=c?k?k.props.value:c.__:r,t.__c?m=(d=n.__c=t.__c).__=d.__E:(x?n.__c=d=new R(b,y):(n.__c=d=new j(b,y),d.constructor=R,d.render=J),k&&k.sub(d),d.state||(d.state={}),d.__n=r,u=d.__d=!0,d.__h=[],d._sb=[]),x&&null==d.__s&&(d.__s=d.state),x&&null!=R.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=A({},d.__s)),A(d.__s,R.getDerivedStateFromProps(b,d.__s))),h=d.props,_=d.state,d.__v=n,u)x&&null==R.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),x&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(x&&null==R.getDerivedStateFromProps&&b!==h&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(b,y),n.__v==t.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(b,d.__s,y)){for(n.__v!=t.__v&&(d.props=b,d.state=d.__s,d.__d=!1),n.__e=t.__e,n.__k=t.__k,n.__k.some(function(e){e&&(e.__=n)}),w=0;w<d._sb.length;w++)d.__h.push(d._sb[w]);d._sb=[],d.__h.length&&l.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(b,d.__s,y),x&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(h,_,v)})}if(d.context=y,d.props=b,d.__P=e,d.__e=!1,S=f.__r,C=0,x){for(d.state=d.__s,d.__d=!1,S&&S(n),c=d.render(d.props,d.state,d.context),P=0;P<d._sb.length;P++)d.__h.push(d._sb[P]);d._sb=[]}else do{d.__d=!1,S&&S(n),c=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++C<25);d.state=d.__s,null!=d.getChildContext&&(r=A(A({},r),d.getChildContext())),x&&!u&&null!=d.getSnapshotBeforeUpdate&&(v=d.getSnapshotBeforeUpdate(h,_)),T=c,null!=c&&c.type===M&&null==c.key&&(T=Q(c.props.children)),o=D(e,z(T)?T:[T],n,t,r,i,a,l,o,s,p),d.base=n.__e,n.__u&=-161,d.__h.length&&l.push(d),m&&(d.__E=d.__=null)}catch(e){if(n.__v=null,s||null!=a)if(e.then){for(n.__u|=s?160:128;o&&8==o.nodeType&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,n.__e=o}else{for(E=a.length;E--;)I(a[E]);K(n)}else n.__e=t.__e,n.__k=t.__k,e.then||K(n);f.__e(e,n,t)}else null==a&&n.__v==t.__v?(n.__k=t.__k,n.__e=t.__e):o=n.__e=function(e,n,t,r,i,a,l,o,s){var p,c,d,u,h,_,v,m=t.props||$,b=n.props,x=n.type;if("svg"==x?i="http://www.w3.org/2000/svg":"math"==x?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=a)for(p=0;p<a.length;p++)if((h=a[p])&&"setAttribute"in h==!!x&&(x?h.localName==x:3==h.nodeType)){e=h,a[p]=null;break}if(null==e){if(null==x)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),o&&(f.__m&&f.__m(n,a),o=!1),a=null}if(null==x)m===b||o&&e.data==b||(e.data=b);else{if(a=a&&g.call(e.childNodes),!o&&null!=a)for(m={},p=0;p<e.attributes.length;p++)m[(h=e.attributes[p]).name]=h.value;for(p in m)if(h=m[p],"children"==p);else if("dangerouslySetInnerHTML"==p)d=h;else if(!(p in b)){if("value"==p&&"defaultValue"in b||"checked"==p&&"defaultChecked"in b)continue;F(e,p,null,h,i)}for(p in b)h=b[p],"children"==p?u=h:"dangerouslySetInnerHTML"==p?c=h:"value"==p?_=h:"checked"==p?v=h:o&&"function"!=typeof h||m[p]===h||F(e,p,h,m[p],i);if(c)o||d&&(c.__html==d.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),n.__k=[];else if(d&&(e.innerHTML=""),D("template"==n.type?e.content:e,z(u)?u:[u],n,t,r,"foreignObject"==x?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:t.__k&&L(t,0),o,s),null!=a)for(p=a.length;p--;)I(a[p]);o||(p="value","progress"==x&&null==_?e.removeAttribute("value"):null!=_&&(_!==e[p]||"progress"==x&&!_||"option"==x&&_!=m[p])&&F(e,p,_,m[p],i),p="checked",null!=v&&v!=e[p]&&F(e,p,v,m[p],i))}return e}(t.__e,n,t,r,i,a,l,s,p);return(c=f.diffed)&&c(n),128&n.__u?void 0:o}function K(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(K)}function Z(e,n,t){for(var r=0;r<t.length;r++)X(t[r],t[++r],t[++r]);f.__c&&f.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){f.__e(e,n.__v)}})}function Q(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:z(e)?e.map(Q):A({},e)}function X(e,n,t){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==n||(e.__u=e(n))}else e.current=n}catch(e){f.__e(e,t)}}function G(e,n,t){var r,i;if(f.unmount&&f.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||X(r,null,n)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){f.__e(e,n)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&G(r[i],n,t||"function"!=typeof e.type);t||I(e.__e),e.__c=e.__=e.__e=void 0}function J(e,n,t){return this.constructor(e,t)}function Y(e,n,t){var r,i,a;n==document&&(n=document.documentElement),f.__&&f.__(e,n),r=!1?null:n.__k,i=[],a=[],V(n,e=n.__k=function(e,n,t){var r,i,a,l={};for(a in n)"key"==a?r=n[a]:"ref"==a?i=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?g.call(arguments,2):t),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return R(e,l,r,i,null)}(M,null,[e]),r||$,$,n.namespaceURI,r?null:n.firstChild?g.call(n.childNodes):null,i,r?r.__e:n.firstChild,false,a),Z(i,e,a)}g=T.slice,f={__e:function(e,n,t,r){for(var i,a,l;n=n.__;)if((i=n.__c)&&!i.__)try{if((a=i.constructor)&&null!=a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),l=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),l=i.__d),l)return i.__E=i}catch(n){e=n}throw e}},_=0,v=function(e){return null!=e&&void 0===e.constructor},j.prototype.setState=function(e,n){var t;t=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=A({},this.state),"function"==typeof e&&(e=e(A({},t),this.props)),e&&A(t,e),null!=e&&this.__v&&(n&&this._sb.push(n),H(this))},j.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),H(this))},j.prototype.render=M,m=[],x="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,k=function(e,n){return e.__v.__b-n.__v.__b},q.__r=0,y=/(PointerCapture)$|Capture$/i,w=0,S=W(!1),C=W(!0),P=0;var ee=0;function ne(e,n,t,r,i,a){n||(n={});var l,o,s=n;if("ref"in s)for(o in s={},n)"ref"==o?l=n[o]:s[o]=n[o];var p={type:e,props:s,key:t,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ee,__i:-1,__u:0,__source:i,__self:a};if("function"==typeof e&&(l=e.defaultProps))for(o in l)void 0===s[o]&&(s[o]=l[o]);return f.vnode&&f.vnode(p),p}var te,re,ie,ae,le=0,oe=[],se=f,pe=se.__b,ce=se.__r,de=se.diffed,ue=se.__c,he=se.unmount,ge=se.__;function fe(e,n){se.__h&&se.__h(re,e,le||n),le=0;var t=re.__H||(re.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function _e(e){return le=1,function(e,n){var t=fe(te++,2);if(t.t=e,!t.__c&&(t.__=[$e(void 0,n),function(e){var n=t.__N?t.__N[0]:t.__[0],r=t.t(n,e);n!==r&&(t.__N=[r,t.__[1]],t.__c.setState({}))}],t.__c=re,!re.__f)){var r=function(e,n,r){if(!t.__c.__H)return!0;var a=t.__c.__H.__.filter(function(e){return!!e.__c});if(a.every(function(e){return!e.__N}))return!i||i.call(this,e,n,r);var l=t.__c.props!==e;return a.forEach(function(e){if(e.__N){var n=e.__[0];e.__=e.__N,e.__N=void 0,n!==e.__[0]&&(l=!0)}}),i&&i.call(this,e,n,r)||l};re.__f=!0;var i=re.shouldComponentUpdate,a=re.componentWillUpdate;re.componentWillUpdate=function(e,n,t){if(this.__e){var l=i;i=void 0,r(e,n,t),i=l}a&&a.call(this,e,n,t)},re.shouldComponentUpdate=r}return t.__N||t.__}($e,e)}function ve(e,n){var t=fe(te++,3);!se.__s&&Pe(t.__H,n)&&(t.__=e,t.u=n,re.__H.__h.push(t))}function me(e){return le=5,be(function(){return{current:e}},[])}function be(e,n){var t=fe(te++,7);return Pe(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function xe(e,n){return le=8,be(function(){return e},n)}function ke(){for(var e;e=oe.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Se),e.__H.__h.forEach(Ce),e.__H.__h=[]}catch(n){e.__H.__h=[],se.__e(n,e.__v)}}se.__b=function(e){re=null,pe&&pe(e)},se.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),ge&&ge(e,n)},se.__r=function(e){ce&&ce(e),te=0;var n=(re=e.__c).__H;n&&(ie===re?(n.__h=[],re.__h=[],n.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(n.__h.forEach(Se),n.__h.forEach(Ce),n.__h=[],te=0)),ie=re},se.diffed=function(e){de&&de(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==oe.push(n)&&ae===se.requestAnimationFrame||((ae=se.requestAnimationFrame)||we)(ke)),n.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ie=re=null},se.__c=function(e,n){n.some(function(e){try{e.__h.forEach(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(t){n.some(function(e){e.__h&&(e.__h=[])}),n=[],se.__e(t,e.__v)}}),ue&&ue(e,n)},se.unmount=function(e){he&&he(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(e){try{Se(e)}catch(e){n=e}}),t.__H=void 0,n&&se.__e(n,t.__v))};var ye="function"==typeof requestAnimationFrame;function we(e){var n,t=function(){clearTimeout(r),ye&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(t,35);ye&&(n=requestAnimationFrame(t))}function Se(e){var n=re,t=e.__c;"function"==typeof t&&(e.__c=void 0,t()),re=n}function Ce(e){var n=re;e.__c=e.__(),re=n}function Pe(e,n){return!e||e.length!==n.length||n.some(function(n,t){return n!==e[t]})}function $e(e,n){return"function"==typeof n?n(e):n}var Te=Symbol.for("preact-signals");function Ee(){if(Me>1)Me--;else{for(var e,n=!1;void 0!==Re;){var t=Re;for(Re=void 0,je++;void 0!==t;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&De(t))try{t.c()}catch(t){n||(e=t,n=!0)}t=r}}if(je=0,Me--,n)throw e}}var ze=void 0;function Ae(e){var n=ze;ze=void 0;try{return e()}finally{ze=n}}var Ie,Re=void 0,Me=0,je=0,Le=0;function Be(e){if(void 0!==ze){var n=e.n;if(void 0===n||n.t!==ze)return n={i:0,S:e,p:ze.s,n:void 0,t:ze,e:void 0,x:void 0,r:n},void 0!==ze.s&&(ze.s.n=n),ze.s=n,e.n=n,32&ze.f&&e.S(n),n;if(-1===n.i)return n.i=0,void 0!==n.n&&(n.n.p=n.p,void 0!==n.p&&(n.p.n=n.n),n.p=ze.s,n.n=void 0,ze.s.n=n,ze.s=n),n}}function He(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function qe(e,n){return new He(e,n)}function De(e){for(var n=e.s;void 0!==n;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function Oe(e){for(var n=e.s;void 0!==n;n=n.n){var t=n.S.n;if(void 0!==t&&(n.r=t),n.S.n=n,n.i=-1,void 0===n.n){e.s=n;break}}}function Ne(e){for(var n=e.s,t=void 0;void 0!==n;){var r=n.p;-1===n.i?(n.S.U(n),void 0!==r&&(r.n=n.n),void 0!==n.n&&(n.n.p=r)):t=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=r}e.s=t}function Ue(e,n){He.call(this,void 0),this.x=e,this.s=void 0,this.g=Le-1,this.f=4,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function Fe(e,n){return new Ue(e,n)}function We(e){var n=e.u;if(e.u=void 0,"function"==typeof n){Me++;var t=ze;ze=void 0;try{n()}catch(n){throw e.f&=-2,e.f|=8,Ve(e),n}finally{ze=t,Ee()}}}function Ve(e){for(var n=e.s;void 0!==n;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,We(e)}function Ke(e){if(ze!==this)throw new Error("Out-of-order effect");Ne(this),ze=e,this.f&=-2,8&this.f&&Ve(this),Ee()}function Ze(e,n){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==n?void 0:n.name}function Qe(e,n){var t=new Ze(e,n);try{t.c()}catch(e){throw t.d(),e}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}function Xe(e,n){f[e]=n.bind(null,f[e]||function(){})}function Ge(e){Ie&&Ie(),Ie=e&&e.S()}function Je(e){var n=this,t=e.data,r=function(e){return be(function(){return qe(e)},[])}(t);r.value=t;var i=be(function(){for(var e=n.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return n.__$u.c=function(){var e,t=n.__$u.S(),r=i.value;t(),v(r)||3!==(null==(e=n.base)?void 0:e.nodeType)?(n.__$f|=1,n.setState({})):n.base.data=r},Fe(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Ye(e,n,t,r){var i=n in e&&void 0===e.ownerSVGElement,a=qe(t);return{o:function(e,n){a.value=e,r=n},d:Qe(function(){var t=a.value.value;r[n]!==t&&(r[n]=t,i?e[n]=t:t?e.setAttribute(n,t):e.removeAttribute(n))})}}He.prototype.brand=Te,He.prototype.h=function(){return!0},He.prototype.S=function(e){var n=this,t=this.t;t!==e&&void 0===e.e&&(e.x=t,this.t=e,void 0!==t?t.e=e:Ae(function(){var e;null==(e=n.W)||e.call(n)}))},He.prototype.U=function(e){var n=this;if(void 0!==this.t){var t=e.e,r=e.x;void 0!==t&&(t.x=r,e.e=void 0),void 0!==r&&(r.e=t,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&Ae(function(){var e;null==(e=n.Z)||e.call(n)}))}},He.prototype.subscribe=function(e){var n=this;return Qe(function(){var t=n.value,r=ze;ze=void 0;try{e(t)}finally{ze=r}},{name:"sub"})},He.prototype.valueOf=function(){return this.value},He.prototype.toString=function(){return this.value+""},He.prototype.toJSON=function(){return this.value},He.prototype.peek=function(){var e=ze;ze=void 0;try{return this.value}finally{ze=e}},Object.defineProperty(He.prototype,"value",{get:function(){var e=Be(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(je>100)throw new Error("Cycle detected");this.v=e,this.i++,Le++,Me++;try{for(var n=this.t;void 0!==n;n=n.x)n.t.N()}finally{Ee()}}}}),Ue.prototype=new He,Ue.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===Le)return!0;if(this.g=Le,this.f|=1,this.i>0&&!De(this))return this.f&=-2,!0;var e=ze;try{Oe(this),ze=this;var n=this.x();(16&this.f||this.v!==n||0===this.i)&&(this.v=n,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return ze=e,Ne(this),this.f&=-2,!0},Ue.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var n=this.s;void 0!==n;n=n.n)n.S.S(n)}He.prototype.S.call(this,e)},Ue.prototype.U=function(e){if(void 0!==this.t&&(He.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var n=this.s;void 0!==n;n=n.n)n.S.U(n)}},Ue.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(Ue.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Be(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ze.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var n=this.x();"function"==typeof n&&(this.u=n)}finally{e()}},Ze.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,We(this),Oe(this),Me++;var e=ze;return ze=this,Ke.bind(this,e)},Ze.prototype.N=function(){2&this.f||(this.f|=2,this.o=Re,Re=this)},Ze.prototype.d=function(){this.f|=8,1&this.f||Ve(this)},Ze.prototype.dispose=function(){this.d()},Je.displayName="_st",Object.defineProperties(He.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Je},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Xe("__b",function(e,n){if("string"==typeof n.type){var t,r=n.props;for(var i in r)if("children"!==i){var a=r[i];a instanceof He&&(t||(n.__np=t={}),t[i]=a,r[i]=a.peek())}}e(n)}),Xe("__r",function(e,n){Ge();var t,r=n.__c;r&&(r.__$f&=-2,void 0===(t=r.__$u)&&(r.__$u=t=function(){var e;return Qe(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),Ge(t),e(n)}),Xe("__e",function(e,n,t,r){Ge(),e(n,t,r)}),Xe("diffed",function(e,n){var t;if(Ge(),"string"==typeof n.type&&(t=n.__e)){var r=n.__np,i=n.props;if(r){var a=t.U;if(a)for(var l in a){var o=a[l];void 0===o||l in r||(o.d(),a[l]=void 0)}else t.U=a={};for(var s in r){var p=a[s],c=r[s];void 0===p?(p=Ye(t,s,c,i),a[s]=p):p.o(c,i)}}}e(n)}),Xe("unmount",function(e,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r)for(var i in t.U=void 0,r){var a=r[i];a&&a.d()}}}else{var l=n.__c;if(l){var o=l.__$u;o&&(l.__$u=void 0,o.d())}}e(n)}),Xe("__h",function(e,n,t,r){(r<3||9===r)&&(n.__$f|=2),e(n,t,r)}),j.prototype.shouldComponentUpdate=function(e,n){var t=this.__$u,r=t&&void 0!==t.s;for(var i in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(r||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var a in e)if("__source"!==a&&e[a]!==this.props[a])return!0;for(var l in this.props)if(!(l in e))return!0;return!1};const en=qe(!1),nn=qe("assistant"),tn=qe("right"),rn=qe("overlay"),an=qe(380),ln=qe(1200),on=qe(!0),sn=qe("undefined"!=typeof window?window.innerWidth:1920);let pn=null;const cn=Fe(()=>{const e=ln.value;return!1!==e&&sn.value<e}),dn=Fe(()=>cn.value?"overlay":rn.value);Fe(()=>{const e=["pillar-panel",`pillar-panel--${tn.value}`];return en.value&&e.push("pillar-panel--open"),e.join(" ")});const un=()=>{en.value=!1,"overlay"===dn.value&&(document.body.style.overflow="")},hn=()=>{en.value=!1,nn.value="assistant",document.body.style.overflow=""};function gn(e,n,t){const r=document.createElement("style");return t&&(r.id=t),r.textContent=n,e instanceof Document?e.head.appendChild(r):e.appendChild(r),r}const fn={help:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',support:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18v-6a9 9 0 0 1 18 0v6"></path><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"></path></svg>',settings:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path><circle cx="12" cy="12" r="3"></circle></svg>',feedback:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>',chat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>',calendar:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>',mail:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>'},_n={assistant:fn.help,support:fn.support};function vn({position:e,tabs:n,currentActiveTab:t,onTabClick:r,panelOpen:i,panelWidthPx:a,theme:l}){const o=xe(e=>{r(e)},[r]),s=["pillar-edge-sidebar",`pillar-edge-sidebar--${e}`,"pillar-edge-sidebar--mounted",i&&"pillar-edge-sidebar--panel-open","light"===l&&"pillar-edge-sidebar--light","dark"===l&&"pillar-edge-sidebar--dark"].filter(Boolean).join(" "),p={"--pillar-panel-width":`${a}px`},c=n.filter(e=>e.enabled).sort((e,n)=>e.order-n.order);return ne("div",{class:s,style:p,children:c.map(e=>{return ne("button",{class:["pillar-edge-trigger",i&&t===e.id&&"pillar-edge-trigger--active"].filter(Boolean).join(" "),onClick:()=>o(e.id),"aria-label":e.label||"Help",type:"button",children:[ne("span",{class:"pillar-edge-trigger__icon",dangerouslySetInnerHTML:{__html:(n=e.id,r=e.icon,r&&r in fn?fn[r]:_n[n]||fn.help)}}),ne("span",{class:"pillar-edge-trigger__label",children:e.label})]},e.id);var n,r})})}class mn{constructor(e,n,t,r){this.container=null,this.stylesInjected=!1,this.themeStylesInjected=!1,this._isHidden=!1,this.unsubscribeOpen=null,this.unsubscribeWidth=null,this.unsubscribeHoverMode=null,this.unsubscribeActiveTab=null,this.themeObserver=null,this.currentTheme="light",this.handleTabClick=e=>{if("assistant"!==e){const n=this.config.sidebarTabs.find(n=>n.id===e);return this.events.emit("sidebar:click",{tabId:e,label:n?.label||e}),void("support"===e&&this.events.emit("support:request",{tabId:e}))}(e=>{nn.value=e})(e),en.value||this.onClick(),this.render()},this.config=e,this.events=n,this.onClick=t,this.rootContainer=r||null}getEdgePosition(){return this.config.panel.position}detectTheme(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}init(){if(this.stylesInjected||(gn(document,"\n/* Sidebar container - always visible, shifts when panel opens */\n.pillar-edge-sidebar {\n position: fixed;\n top: 0;\n bottom: 0;\n width: 48px;\n z-index: 100000;\n display: flex;\n flex-direction: column;\n align-items: center;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n transition: right 0.3s ease, left 0.3s ease;\n}\n\n.pillar-edge-sidebar--right {\n right: 0;\n border-left: 1px solid var(--pillar-border);\n border-right: none;\n}\n\n.pillar-edge-sidebar--left {\n left: 0;\n border-right: 1px solid var(--pillar-border);\n border-left: none;\n}\n\n/* When panel is open, shift the trigger to sit at the panel's outer edge */\n.pillar-edge-sidebar--right.pillar-edge-sidebar--panel-open {\n right: var(--pillar-panel-width, 380px);\n}\n\n.pillar-edge-sidebar--left.pillar-edge-sidebar--panel-open {\n left: var(--pillar-panel-width, 380px);\n}\n\n/* The trigger button - vertical sideways text */\n.pillar-edge-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px 8px;\n margin-top: 8px;\n font-family: var(--pillar-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: background 0.15s ease, color 0.15s ease;\n outline: none;\n gap: 8px;\n writing-mode: vertical-rl;\n text-orientation: mixed;\n}\n\n.pillar-edge-trigger:hover {\n background: var(--pillar-bg-secondary);\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active {\n background: var(--pillar-primary-light, rgba(194, 65, 12, 0.1));\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger:focus-visible {\n background: var(--pillar-bg-secondary);\n box-shadow: 0 0 0 2px var(--pillar-primary);\n}\n\n.pillar-edge-trigger__icon {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n opacity: 0.8;\n}\n\n.pillar-edge-trigger:hover .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger__label {\n white-space: nowrap;\n letter-spacing: 0.5px;\n}\n\n/* Animation on mount */\n@keyframes pillar-sidebar-mount {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n.pillar-edge-sidebar--mounted {\n animation: pillar-sidebar-mount 0.2s ease forwards;\n}\n","pillar-edge-trigger-styles"),this.stylesInjected=!0),!this.themeStylesInjected){const e=function(e,n){const t=e=>{const n=[];return e.primary&&n.push(`--pillar-primary: ${e.primary};`),e.primaryHover&&n.push(`--pillar-primary-hover: ${e.primaryHover};`),e.background&&n.push(`--pillar-bg: ${e.background};`),e.backgroundSecondary&&n.push(`--pillar-bg-secondary: ${e.backgroundSecondary};`),e.text&&n.push(`--pillar-text: ${e.text};`),e.textMuted&&n.push(`--pillar-text-muted: ${e.textMuted};`),e.border&&n.push(`--pillar-border: ${e.border};`),e.borderLight&&n.push(`--pillar-border-light: ${e.borderLight};`),n.join("\n ")},r=t(e),i=t(n);let a="";return r&&(a+=`\n.pillar-edge-sidebar,\n.pillar-edge-sidebar--light {\n ${r}\n}\n`),i&&(a+=`\n.pillar-edge-sidebar--dark {\n ${i}\n}\n`),a}(this.config.theme.colors,this.config.theme.darkColors);e&&gn(document,e,"pillar-edge-trigger-theme"),this.themeStylesInjected=!0}this.container=document.createElement("div"),this.container.id="pillar-edge-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.currentTheme=this.detectTheme(),this.applyLayoutPadding(),this.render(),this.unsubscribeOpen=en.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeWidth=an.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeHoverMode=cn.subscribe(()=>{queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeActiveTab=nn.subscribe(()=>{this.render()}),this.themeObserver=new MutationObserver(()=>{const e=this.detectTheme();e!==this.currentTheme&&(this.currentTheme=e,this.render())}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]})}applyLayoutPadding(){if(this._isHidden)return;const e=this.getEdgePosition(),n=an.value,t=cn.value;let r=48;en.value&&!t&&(r=n+48),document.documentElement.style.transition="padding 0.3s ease","right"===e?document.documentElement.style.paddingRight=`${r}px`:document.documentElement.style.paddingLeft=`${r}px`}removeLayoutPadding(){"right"===this.getEdgePosition()?document.documentElement.style.paddingRight="":document.documentElement.style.paddingLeft=""}setOpen(e){this.render()}show(){this._isHidden=!1,this.container&&(this.container.style.display=""),this.applyLayoutPadding()}hide(){this._isHidden=!0,this.container&&(this.container.style.display="none"),this.removeLayoutPadding()}setPosition(e){this.removeLayoutPadding(),this.config.panel.position=e,this.applyLayoutPadding(),this.render()}destroy(){this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.unsubscribeWidth?.(),this.unsubscribeWidth=null,this.unsubscribeHoverMode?.(),this.unsubscribeHoverMode=null,this.unsubscribeActiveTab?.(),this.unsubscribeActiveTab=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.removeLayoutPadding(),this.container&&(Y(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-edge-trigger-styles")?.remove(),document.getElementById("pillar-edge-trigger-theme")?.remove(),this.stylesInjected=!1,this.themeStylesInjected=!1}render(){if(!this.container||this._isHidden)return;Y(ne(vn,{position:this.getEdgePosition(),tabs:this.config.sidebarTabs,currentActiveTab:nn.value,onTabClick:this.handleTabClick,panelOpen:en.value,panelWidthPx:an.value,theme:this.currentTheme}),this.container)}}function bn(e){return"highlighted_text"===e.type}const xn=qe([]),kn=qe(null),yn=qe(!1),wn=qe({kind:null}),Sn=qe(!1),Cn=qe([]),Pn=qe([]),$n=qe(""),Tn=qe(null),En=qe(0),zn=qe([]),An=qe([]),In=qe([]),Rn=Fe(()=>In.value.some(e=>"uploading"===e.status)),Mn=(e,n,t,r)=>{In.value=In.value.map(i=>i.id===e?{...i,status:n,url:t,error:r}:i)},jn=()=>{In.value.forEach(e=>URL.revokeObjectURL(e.preview)),In.value=[]};Fe(()=>xn.value.length>0);const Ln=(e,n,t,r)=>{const i=xn.value;if(i.length>0&&"assistant"===i[i.length-1].role){const a=i[i.length-1];xn.value=[...i.slice(0,-1),{role:"assistant",content:e,id:n??a.id,actions:t??a.actions,sources:r??a.sources,actionStatus:a.actionStatus}]}},Bn=e=>{yn.value=e},Hn=e=>{Tn.value=e},qn=()=>{En.value+=1},Dn=e=>{zn.value=zn.value.filter(n=>n.id!==e)},On=()=>{xn.value=[],kn.value=null,yn.value=!1,wn.value={kind:null},Sn.value=!1,Cn.value=[],Pn.value=[],$n.value="",Tn.value=null,zn.value=[],An.value=[],jn()},Nn=qe([]),Un=qe({type:"home"}),Fn=Fe(()=>Nn.value.length>0),Wn=Fe(()=>"home"===Un.value.type),Vn=(e,n)=>{Nn.value=[...Nn.value,{...Un.value}],Un.value={type:e,params:n}},Kn=()=>{const e=Nn.value;if(e.length>0){"chat"===Un.value.type&&On();const n=e[e.length-1];Un.value=n,Nn.value=e.slice(0,-1)}},Zn=()=>{"chat"===Un.value.type&&On(),Nn.value=[],Un.value={type:"home"}},Qn=()=>{Nn.value=[],Un.value={type:"home"}},Xn=()=>{Vn("chat")},Gn='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20,6 9,17 4,12"/></svg>',Jn='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>';function Yn(e){return e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function et(e,n){const t=document.createElement("div");t.className="pillar-confirm-card";const r=Yn(e.data?.card_type||e.name),i=e.data||{};let a="idle",l="";const o=()=>{if("success"!==a){if("error"===a)return t.innerHTML=`\n <div class="pillar-confirm-card__content">\n <div class="pillar-confirm-card__header">\n <span class="pillar-confirm-card__title">${r}</span>\n </div>\n <div class="pillar-confirm-card__error">\n <span>${l||"An error occurred"}</span>\n </div>\n <div class="pillar-confirm-card__actions">\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--secondary js-cancel">\n ${Jn} Dismiss\n </button>\n </div>\n </div>\n `,void t.querySelector(".js-cancel")?.addEventListener("click",n.onCancel);t.innerHTML=`\n <div class="pillar-confirm-card__content">\n <div class="pillar-confirm-card__header">\n <span class="pillar-confirm-card__title">${r}</span>\n </div>\n ${function(e){const n=Object.entries(e).filter(([e])=>"card_type"!==e).slice(0,5);return 0===n.length?"":`\n <div class="pillar-confirm-card__data">\n ${n.map(([e,n])=>{const t=Array.isArray(n)?n.join(", "):String(n);return`\n <div class="pillar-confirm-card__data-row">\n <span class="pillar-confirm-card__data-key">${Yn(e)}:</span>\n <span class="pillar-confirm-card__data-value">${t}</span>\n </div>\n `}).join("")}\n </div>\n `}(i)}\n <div class="pillar-confirm-card__actions">\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--secondary js-cancel" ${"loading"===a?"disabled":""}>\n ${Jn} Cancel\n </button>\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--primary js-confirm" ${"loading"===a?"disabled":""}>\n ${"loading"===a?'<span class="pillar-confirm-card__spinner"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/><line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/><line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/><line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/></svg></span>':Gn} \n ${"loading"===a?"Processing...":"Confirm"}\n </button>\n </div>\n </div>\n `,t.querySelector(".js-cancel")?.addEventListener("click",n.onCancel),t.querySelector(".js-confirm")?.addEventListener("click",()=>{n.onConfirm(i)})}else t.innerHTML=`\n <div class="pillar-confirm-card__success">\n <span class="pillar-confirm-card__success-icon">${Gn}</span>\n <span>Completed</span>\n </div>\n `};if(o(),n.onStateChange){const e=n.onStateChange;n.onStateChange=(n,t)=>{"loading"===n?a="loading":"success"===n?a="success":"error"===n&&(a="error",l=t||""),o(),e(n,t)}}return t}const nt="\n/* Confirm Action Card */\n.pillar-confirm-card-wrapper {\n margin-top: 12px;\n}\n\n.pillar-confirm-card {\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n overflow: hidden;\n}\n\n.pillar-confirm-card__content {\n padding: 16px;\n}\n\n.pillar-confirm-card__header {\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__title {\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #111827);\n}\n\n.pillar-confirm-card__data {\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__data-row {\n display: flex;\n gap: 8px;\n font-size: 13px;\n margin-bottom: 4px;\n}\n\n.pillar-confirm-card__data-row:last-child {\n margin-bottom: 0;\n}\n\n.pillar-confirm-card__data-key {\n color: var(--pillar-text-secondary, #6b7280);\n flex-shrink: 0;\n}\n\n.pillar-confirm-card__data-value {\n color: var(--pillar-text-primary, #111827);\n word-break: break-word;\n}\n\n.pillar-confirm-card__actions {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n}\n\n.pillar-confirm-card__btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n}\n\n.pillar-confirm-card__btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.pillar-confirm-card__btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-confirm-card__btn--primary {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border-color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-confirm-card__btn--primary:hover:not(:disabled) {\n background: var(--pillar-primary-hover, #1d4ed8);\n border-color: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-confirm-card__btn--secondary {\n background: var(--pillar-bg-primary, #ffffff);\n color: var(--pillar-text-secondary, #6b7280);\n border-color: var(--pillar-border, #e5e7eb);\n}\n\n.pillar-confirm-card__btn--secondary:hover:not(:disabled) {\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n.pillar-confirm-card__success {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px;\n color: #059669;\n font-weight: 500;\n}\n\n.pillar-confirm-card__success-icon svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-confirm-card__error {\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n color: #dc2626;\n font-size: 13px;\n}\n\n.pillar-confirm-card__spinner {\n display: inline-flex;\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n",tt=function(e){function n(e){var t,r;return this.getChildContext||(t=new Set,(r={})[n.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){t=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&t.forEach(function(e){e.__e=!0,H(e)})},this.sub=function(e){t.add(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){t&&t.delete(e),n&&n.call(e)}}),e.children}return n.__c="__cC"+P++,n.__=e,n.Provider=n.__l=(n.Consumer=function(e,n){return e.children(n)}).contextType=n,n}(null);function rt({api:e,events:n,children:t}){return ne(tt.Provider,{value:{api:e,events:n},children:t})}function it(){const e=function(e){var n=re.context[e.__c],t=fe(te++,9);return t.c=e,n?(null==t.__&&(t.__=!0,n.sub(re)),n.props.value):e.__}(tt);if(!e)throw new Error("usePillar must be used within a PillarProvider");return e}function at(){return it().api}const lt="\n/* Inline Plan Container */\n.pillar-inline-plan {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 8px 0;\n}\n\n/* Steps list */\n.pillar-inline-plan__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Individual step */\n.pillar-inline-plan__step {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 4px 8px;\n border-radius: 6px;\n font-size: 13px;\n background: transparent;\n transition: all 0.15s ease;\n}\n\n.pillar-inline-plan__step-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-inline-plan__step-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n\n.pillar-inline-plan__step-text {\n color: var(--pillar-text-primary, #374151);\n line-height: 1.4;\n}\n\n.pillar-inline-plan__step-instruction {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-wrap: wrap;\n}\n\n.pillar-inline-plan__action-badge {\n display: inline-block;\n padding: 1px 5px;\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n background: var(--pillar-warning, #f59e0b);\n color: white;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n.pillar-inline-plan__instruction-text {\n font-size: 11px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-inline-plan__step-actions {\n display: flex;\n gap: 4px;\n}\n\n/* Step states */\n.pillar-inline-plan__step--pending {\n opacity: 0.6;\n}\n\n.pillar-inline-plan__step--ready .pillar-inline-plan__step-icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-inline-plan__step--awaiting_confirmation {\n background: var(--pillar-bg-warning-subtle, rgba(251, 191, 36, 0.1));\n}\n\n.pillar-inline-plan__step--awaiting_confirmation .pillar-inline-plan__step-icon {\n color: var(--pillar-warning-dark, #d97706);\n}\n\n.pillar-inline-plan__step--executing .pillar-inline-plan__step-icon,\n.pillar-inline-plan__step--awaiting_result .pillar-inline-plan__step-icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-inline-plan__step--completed .pillar-inline-plan__step-icon {\n color: var(--pillar-success, #059669);\n}\n\n.pillar-inline-plan__step--completed .pillar-inline-plan__step-text {\n text-decoration: line-through;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-inline-plan__step--skipped {\n opacity: 0.5;\n}\n\n.pillar-inline-plan__step--skipped .pillar-inline-plan__step-text {\n text-decoration: line-through;\n}\n\n.pillar-inline-plan__step--failed {\n background: var(--pillar-bg-danger-subtle, rgba(220, 38, 38, 0.1));\n}\n\n.pillar-inline-plan__step--failed .pillar-inline-plan__step-icon {\n color: var(--pillar-danger, #dc2626);\n}\n\n/* Buttons */\n.pillar-inline-plan__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 3px 8px;\n font-size: 11px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 4px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: none;\n}\n\n.pillar-inline-plan__btn--confirm {\n background: var(--pillar-success, #059669);\n color: #ffffff;\n min-width: 24px;\n}\n\n.pillar-inline-plan__btn--confirm:hover {\n background: var(--pillar-success-hover, #047857);\n}\n\n.pillar-inline-plan__btn--skip {\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n}\n\n.pillar-inline-plan__btn--skip:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n}\n\n.pillar-inline-plan__btn--retry {\n background: var(--pillar-danger, #dc2626);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--retry:hover {\n background: var(--pillar-danger-hover, #b91c1c);\n}\n\n.pillar-inline-plan__btn--done {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--done:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-inline-plan__btn--start {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--start:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-inline-plan__btn--cancel {\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n}\n\n.pillar-inline-plan__btn--cancel:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-danger, #dc2626);\n border-color: var(--pillar-danger, #dc2626);\n}\n\n/* Footer */\n.pillar-inline-plan__footer {\n display: flex;\n gap: 8px;\n padding-top: 6px;\n}\n\n/* Status messages */\n.pillar-inline-plan__status {\n font-size: 12px;\n font-weight: 500;\n padding: 4px 8px;\n border-radius: 4px;\n}\n\n.pillar-inline-plan__status--success {\n color: var(--pillar-success, #059669);\n background: var(--pillar-bg-success-subtle, rgba(5, 150, 105, 0.1));\n}\n\n.pillar-inline-plan__status--error {\n color: var(--pillar-danger, #dc2626);\n background: var(--pillar-bg-danger-subtle, rgba(220, 38, 38, 0.1));\n}\n\n.pillar-inline-plan__status--cancelled {\n color: var(--pillar-text-tertiary, #9ca3af);\n background: var(--pillar-bg-tertiary, #f3f4f6);\n}\n\n/* Spinner animation */\n@keyframes pillar-inline-plan-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.pillar-inline-plan__spinner {\n animation: pillar-inline-plan-spin 1s linear infinite;\n}\n",ot={pending:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/></svg>',ready:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="4" fill="currentColor"/></svg>',awaiting_confirmation:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',executing:'<svg class="pillar-plan-step__spinner" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/></svg>',awaiting_result:'<svg class="pillar-plan-step__spinner" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/></svg>',completed:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="9,12 12,15 16,10"/></svg>',skipped:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" stroke-dasharray="4,2"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',failed:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>'};function st(e){switch(e){case"pending":default:return ot.pending;case"ready":return ot.ready;case"awaiting_confirmation":return ot.awaiting_confirmation;case"executing":return ot.executing;case"awaiting_result":return ot.awaiting_result;case"completed":return ot.completed;case"skipped":return ot.skipped;case"failed":return ot.failed}}function pt({step:e,onConfirm:n,onSkip:t,onRetry:r,onDone:i}){"ready"===e.status||"executing"===e.status||"awaiting_confirmation"===e.status||e.status;const a="failed"===e.status&&e.is_retriable&&e.retry_count<e.max_retries;return ne("div",{class:`pillar-plan-step pillar-plan-step--${e.status}`,children:[ne("div",{class:"pillar-plan-step__icon",children:ne("span",{dangerouslySetInnerHTML:{__html:st(e.status)}})}),ne("div",{class:"pillar-plan-step__content",children:[ne("div",{class:"pillar-plan-step__description",children:e.description}),"awaiting_confirmation"===e.status&&ne("div",{class:"pillar-plan-step__actions",children:[ne("button",{type:"button",class:"pillar-plan-step__confirm-btn",onClick:()=>{n(e.id)},children:"Confirm"}),ne("button",{type:"button",class:"pillar-plan-step__skip-btn",onClick:()=>{t(e.id)},children:"Skip"})]}),"executing"===e.status&&ne("div",{class:"pillar-plan-step__status-text",children:"Running..."}),"awaiting_result"===e.status&&ne("div",{class:"pillar-plan-step__awaiting-container",children:[ne("div",{class:"pillar-plan-step__instruction-row",children:[ne("span",{class:"pillar-plan-step__action-badge",children:"In Progress"}),ne("span",{class:"pillar-plan-step__instruction",children:"Complete this step to continue"})]}),ne("button",{type:"button",class:"pillar-plan-step__done-btn",onClick:()=>{i?.(e.id)},children:"Done"})]}),"failed"===e.status&&ne("div",{class:"pillar-plan-step__error-container",children:[e.error_message&&ne("div",{class:"pillar-plan-step__error",children:e.error_message}),a&&ne("div",{class:"pillar-plan-step__retry-info",children:[ne("span",{class:"pillar-plan-step__retry-count",children:["Attempt ",e.retry_count+1," of ",e.max_retries+1]}),ne("button",{type:"button",class:"pillar-plan-step__retry-btn",onClick:()=>{r?.(e.id)},children:"Retry"})]}),!a&&e.retry_count>=e.max_retries&&ne("div",{class:"pillar-plan-step__retry-exhausted",children:"All retry attempts exhausted"})]})]})]})}const ct="\n/* Individual Step */\n.pillar-plan-step {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step__icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-plan-step__content {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.pillar-plan-step__description {\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-primary, #374151);\n line-height: 1.4;\n}\n\n.pillar-plan-step__status-text {\n font-size: 12px;\n color: var(--pillar-primary, #2563eb);\n font-style: italic;\n}\n\n.pillar-plan-step__error {\n font-size: 12px;\n color: var(--pillar-danger, #dc2626);\n}\n\n.pillar-plan-step__actions {\n display: flex;\n gap: 8px;\n margin-top: 4px;\n}\n\n/* Step States */\n.pillar-plan-step--pending {\n opacity: 0.6;\n}\n\n.pillar-plan-step--ready {\n background: var(--pillar-bg-info-subtle, #eff6ff);\n border-color: var(--pillar-info, #93c5fd);\n}\n\n.pillar-plan-step--ready .pillar-plan-step__icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-plan-step--awaiting_confirmation {\n background: var(--pillar-bg-warning-subtle, #fef3c7);\n border-color: var(--pillar-warning, #fcd34d);\n}\n\n.pillar-plan-step--awaiting_confirmation .pillar-plan-step__icon {\n color: var(--pillar-warning-dark, #d97706);\n}\n\n.pillar-plan-step--executing,\n.pillar-plan-step--awaiting_result {\n background: var(--pillar-bg-info-subtle, #eff6ff);\n border-color: var(--pillar-info, #93c5fd);\n}\n\n.pillar-plan-step--executing .pillar-plan-step__icon,\n.pillar-plan-step--awaiting_result .pillar-plan-step__icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-plan-step--completed .pillar-plan-step__icon {\n color: var(--pillar-success, #059669);\n}\n\n.pillar-plan-step--completed .pillar-plan-step__description {\n text-decoration: line-through;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-plan-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-plan-step--skipped .pillar-plan-step__icon {\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step--skipped .pillar-plan-step__description {\n text-decoration: line-through;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step--failed {\n background: var(--pillar-bg-danger-subtle, #fef2f2);\n border-color: var(--pillar-danger-light, #fca5a5);\n}\n\n.pillar-plan-step--failed .pillar-plan-step__icon {\n color: var(--pillar-danger, #dc2626);\n}\n\n/* Error Container */\n.pillar-plan-step__error-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.pillar-plan-step__retry-info {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-top: 2px;\n}\n\n.pillar-plan-step__retry-count {\n font-size: 11px;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step__retry-exhausted {\n font-size: 11px;\n color: var(--pillar-text-tertiary, #9ca3af);\n font-style: italic;\n margin-top: 2px;\n}\n\n/* Retry Button */\n.pillar-plan-step__retry-btn {\n display: inline-flex;\n align-items: center;\n padding: 4px 10px;\n font-size: 11px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-danger, #dc2626);\n color: #ffffff;\n border: none;\n border-radius: 5px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__retry-btn:hover {\n background: var(--pillar-danger-hover, #b91c1c);\n}\n\n/* Confirm Button */\n.pillar-plan-step__confirm-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__confirm-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Skip Button */\n.pillar-plan-step__skip-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__skip-btn:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-text-primary, #374151);\n}\n\n/* Awaiting Result Container */\n.pillar-plan-step__awaiting-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.pillar-plan-step__instruction-row {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.pillar-plan-step__action-badge {\n display: inline-block;\n padding: 2px 6px;\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n background: var(--pillar-warning, #f59e0b);\n color: white;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n.pillar-plan-step__instruction {\n font-size: 12px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n/* Done Button */\n.pillar-plan-step__done-btn {\n display: inline-flex;\n align-items: center;\n align-self: flex-start;\n padding: 6px 14px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__done-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Spinner Animation for Executing Step */\n@keyframes pillar-plan-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n.pillar-plan-step__spinner {\n animation: pillar-plan-spin 1s linear infinite;\n}\n",dt=qe(null),ut=qe([]),ht=Fe(()=>null!==dt.value);Fe(()=>dt.value&&dt.value.steps.find(e=>"ready"===e.status||"executing"===e.status||"awaiting_confirmation"===e.status)||null),Fe(()=>dt.value?dt.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);const gt=Fe(()=>dt.value&&0!==dt.value.total_steps?dt.value.completed_steps/dt.value.total_steps:0);function ft(e){dt.value&&(ut.value=[...ut.value,dt.value]),dt.value=e}function _t(e){dt.value=e}function vt(e,n){if(!dt.value)return;const t=dt.value.steps.map(t=>t.id===e?{...t,...n}:t);let r=dt.value.completed_steps;"completed"===n.status&&(r=t.filter(e=>"completed"===e.status).length),dt.value={...dt.value,steps:t,completed_steps:r}}function mt(e=!0){dt.value&&e&&(ut.value=[...ut.value,dt.value]),dt.value=null}Fe(()=>"awaiting_start"===dt.value?.status);const bt={plan:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/></svg>'};function xt(){const e=dt.value;if(!e)return null;const n="awaiting_start"===e.status,t="executing"===e.status,r=gt.value,i=Ai.getInstance(),a=(e,n)=>{i?.confirmPlanStep(e,n)},l=e=>{i?.skipPlanStep(e)},o=e=>{i?.retryPlanStep(e)},s=e=>{i?.markPlanStepDone(e)};return ne("div",{class:"pillar-plan",children:[ne("div",{class:"pillar-plan__header",children:[ne("div",{class:"pillar-plan__icon",children:ne("span",{dangerouslySetInnerHTML:{__html:bt.plan}})}),ne("div",{class:"pillar-plan__title",children:e.goal}),ne("div",{class:"pillar-plan__progress",children:[e.completed_steps,"/",e.total_steps]})]}),t&&ne("div",{class:"pillar-plan__progress-bar",children:ne("div",{class:"pillar-plan__progress-fill",style:{width:100*r+"%"}})}),ne("div",{class:"pillar-plan__steps",children:e.steps.map(e=>ne(pt,{step:e,onConfirm:a,onSkip:l,onRetry:o,onDone:s},e.id))}),ne("div",{class:"pillar-plan__footer",children:[n&&ne("button",{type:"button",class:"pillar-plan__start-btn",onClick:()=>{i?.startPlan()},children:"Start Plan"}),ne("button",{type:"button",class:"pillar-plan__cancel-btn",onClick:()=>{i?.cancelPlan()},children:"Cancel"})]})]})}const kt="\n/* Plan Container */\n.pillar-plan {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n margin: 12px 0;\n}\n\n/* Header */\n.pillar-plan__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.pillar-plan__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-plan__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #1a1a1a);\n line-height: 1.4;\n}\n\n.pillar-plan__progress {\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n padding: 2px 8px;\n background: var(--pillar-bg-tertiary, #e5e7eb);\n border-radius: 10px;\n}\n\n/* Progress Bar */\n.pillar-plan__progress-bar {\n height: 4px;\n background: var(--pillar-bg-tertiary, #e5e7eb);\n border-radius: 2px;\n overflow: hidden;\n}\n\n.pillar-plan__progress-fill {\n height: 100%;\n background: var(--pillar-primary, #2563eb);\n border-radius: 2px;\n transition: width 0.3s ease;\n}\n\n/* Steps List */\n.pillar-plan__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Footer */\n.pillar-plan__footer {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n padding-top: 8px;\n border-top: 1px solid var(--pillar-border, #e5e7eb);\n}\n\n/* Start Button */\n.pillar-plan__start-btn {\n display: inline-flex;\n align-items: center;\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan__start-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Cancel Button */\n.pillar-plan__cancel-btn {\n display: inline-flex;\n align-items: center;\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan__cancel-btn:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-danger, #dc2626);\n border-color: var(--pillar-danger, #dc2626);\n}\n",yt={home:"Assistant",chat:"Assistant"};function wt({currentView:e,customTitle:n,hideNavigation:t=!1}){const r=!t&&Fn.value,i=!t&&!Wn.value,a=n||yt[e];return ne("header",{class:"_pillar-header pillar-header",children:[ne("div",{class:"_pillar-header-left pillar-header-left",children:[r&&ne("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-back-btn",onClick:()=>{Kn()},"aria-label":"Go back",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd"/></svg>'}}),i&&ne("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-home-btn",onClick:()=>{Zn()},"aria-label":"Go to home",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/></svg>'}}),ne("span",{class:"_pillar-header-title pillar-header-title",children:a})]}),ne("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-close-btn",onClick:()=>{un()},"aria-label":"Close assistant panel",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/></svg>'}})]})}const St='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M4.583 17.321C3.553 16.227 3 15 3 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179zm10 0C13.553 16.227 13 15 13 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179z"/></svg>';function Ct({context:e,onRemove:n,readOnly:t=!1}){const r="highlighted_text"===(i=e).type?i.text_content.length>40?i.text_content.substring(0,40)+"...":i.text_content:"Context";var i;const a=function(e){return bn(e),St}(e),l=function(e){if(bn(e)){const n=e.url_origin?`\nFrom: ${e.url_origin}`:"";return`"${e.text_content}"${n}`}return""}(e);return ne("div",{class:"_pillar-context-tag pillar-context-tag",title:l,children:[ne("span",{class:"_pillar-context-tag-icon pillar-context-tag-icon",dangerouslySetInnerHTML:{__html:a}}),ne("span",{class:"_pillar-context-tag-label pillar-context-tag-label",children:r}),!t&&n&&ne("button",{class:"_pillar-context-tag-remove pillar-context-tag-remove",onClick:t=>{t.preventDefault(),t.stopPropagation(),n?.(e.id)},"aria-label":"Remove context",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]})}function Pt({contexts:e,onRemove:n,readOnly:t=!1}){return 0===e.length?null:ne("div",{class:"_pillar-context-tag-list pillar-context-tag-list",children:e.map(e=>ne(Ct,{context:e,onRemove:n,readOnly:t},e.id))})}const $t='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>';function Tt({placeholder:e="Ask anything...",disabled:n=!1,onSubmit:t,showContextTags:r=!0,showImageUpload:i=!0,className:a=""}){const l=at(),o=me(null),s=me(null),[p,c]=_e(""),[d,u]=_e(!1),h=xe(()=>{const e=o.current;if(!e)return;e.style.height="41px";const n=e.scrollHeight;n>146?(e.style.height="146px",e.style.overflowY="auto"):(e.style.height=`${n}px`,e.style.overflowY="hidden")},[]),g=xe(async e=>{if(In.value.length>=4)return;const n=`img-${Date.now()}-${Math.random().toString(36).slice(2)}`,t=URL.createObjectURL(e);var r;r={id:n,file:e,preview:t,status:"uploading"},In.value.length>=4||(In.value=[...In.value,r]);try{const t=await l.uploadImage(e);Mn(n,"ready",t.url)}catch(e){const t=e instanceof Error?e.message:"Upload failed";Mn(n,"error",void 0,t)}},[l]),f=xe(e=>{const n=Array.from(e).filter(e=>e.type.startsWith("image/")),t=4-In.value.length;n.slice(0,t).forEach(g)},[g]),_=xe(e=>{const n=e.clipboardData?.items;if(!n)return;const t=[];for(const e of n)if(e.type.startsWith("image/")){const n=e.getAsFile();n&&t.push(n)}t.length>0&&(e.preventDefault(),f(t))},[f]),v=xe(e=>{e.preventDefault(),e.stopPropagation(),u(!0)},[]),m=xe(e=>{e.preventDefault(),e.stopPropagation(),u(!1)},[]),b=xe(e=>{e.preventDefault(),e.stopPropagation(),u(!1);const n=e.dataTransfer?.files;n&&f(n)},[f]),x=xe(e=>{const n=e.target;n.files&&(f(n.files),n.value="")},[f]),k=xe(()=>{s.current?.click()},[]),y=xe(()=>{const e=p.trim(),n=[...zn.value],r=In.value.filter(e=>"ready"===e.status&&e.url).map(e=>({url:e.url,detail:"low"})),i=n.length>0,a=r.length>0;var l;(e||i||a)&&(Rn.value||(i&&(zn.value=[]),jn(),t?t(e,n,r):(i&&(l=n,An.value=l),Hn(e),Xn()),c(""),o.current&&(o.current.style.height="41px",o.current.style.overflowY="hidden")))},[p,t]),w=Rn.value,S=p.trim()||zn.value.length>0||In.value.some(e=>"ready"===e.status);return ne("div",{class:`_pillar-unified-input-wrapper pillar-unified-input-wrapper ${d?"_pillar-unified-input-wrapper--dragging":""} ${a}`.trim(),onDragOver:v,onDragLeave:m,onDrop:b,children:[ne("input",{ref:s,type:"file",accept:"image/*",multiple:!0,onChange:x,style:{display:"none"}}),In.value.length>0&&ne("div",{class:"_pillar-chat-images-preview pillar-chat-images-preview",children:In.value.map(e=>ne("div",{class:"_pillar-chat-image-thumb pillar-chat-image-thumb",children:[ne("img",{src:e.preview,alt:"Upload preview"}),"uploading"===e.status&&ne("div",{class:"_pillar-chat-image-loading pillar-chat-image-loading",children:ne("div",{class:"_pillar-loading-spinner pillar-loading-spinner",style:{width:"16px",height:"16px"}})}),"error"===e.status&&ne("div",{class:"_pillar-chat-image-error pillar-chat-image-error",title:e.error,children:"!"}),ne("button",{type:"button",class:"_pillar-chat-image-remove pillar-chat-image-remove",onClick:()=>(e=>{const n=In.value.find(n=>n.id===e);n&&URL.revokeObjectURL(n.preview),In.value=In.value.filter(n=>n.id!==e)})(e.id),"aria-label":"Remove image",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]},e.id))}),r&&ne(Pt,{contexts:zn.value,onRemove:Dn}),ne("textarea",{ref:o,class:"_pillar-unified-input pillar-unified-input",placeholder:d?"Drop image here...":e,value:p,onInput:e=>{const n=e.target;c(n.value),h()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),y())},onPaste:_,disabled:n,style:{height:"41px"}}),ne("div",{class:"_pillar-unified-input-row pillar-unified-input-row",children:[i&&ne("button",{type:"button",class:"_pillar-chat-image-btn pillar-chat-image-btn",onClick:k,disabled:n||w||In.value.length>=4,"aria-label":"Attach image",title:"Attach image (max 4)",dangerouslySetInnerHTML:{__html:$t}}),ne("button",{type:"button",class:"_pillar-unified-send-btn pillar-unified-send-btn",onClick:y,disabled:n||w||!S,"aria-label":"Send message",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/></svg>'}})]}),d&&ne("div",{class:"_pillar-chat-drop-overlay pillar-chat-drop-overlay",children:[ne("span",{dangerouslySetInnerHTML:{__html:$t}}),ne("span",{children:"Drop image here"})]})]})}function Et({text:e,onClick:n}){return ne("button",{type:"button",class:"_pillar-question-chip pillar-question-chip",onClick:n,children:[ne("span",{class:"_pillar-question-chip-text pillar-question-chip-text",children:e}),ne("span",{class:"_pillar-question-chip-arrow pillar-question-chip-arrow",children:"→"})]})}function zt(){return ne("div",{class:"_pillar-question-chip-skeleton pillar-question-chip-skeleton",children:ne("div",{class:"_pillar-question-chip-skeleton-bar pillar-question-chip-skeleton-bar"})})}function At(){const e=at(),[n,t]=_e(null),[r,i]=_e(!0);ve(()=>{let n=!0;return(async()=>{try{const r=await e.getSuggestedQuestions();n&&(t(r),i(!1))}catch(e){n&&(console.error("[Pillar] Failed to load suggested questions:",e),t([]),i(!1))}})(),()=>{n=!1}},[e]);return ne("div",{class:"_pillar-home-view pillar-home-view",children:[ne("div",{class:"_pillar-home-view-header pillar-home-view-header",children:[ne("div",{class:"_pillar-home-view-icon",children:"💬"}),ne("h2",{class:"_pillar-home-view-title pillar-home-view-title",children:"How can I help?"})]}),ne("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:r?ne(M,{children:[ne(zt,{}),ne(zt,{}),ne(zt,{})]}):n&&n.length>0?n.map(e=>ne(Et,{text:e.text,onClick:()=>(e=>{Hn(e.text),Xn()})(e)},e.id)):null}),ne("div",{style:{marginTop:"auto"},children:ne(Tt,{placeholder:"Ask anything... (paste or drop images)"})})]})}function It(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Rt={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Mt(e){Rt=e}var jt={exec:()=>null};function Lt(e,n=""){let t="string"==typeof e?e:e.source,r={replace:(e,n)=>{let i="string"==typeof n?n:n.source;return i=i.replace(Ht.caret,"$1"),t=t.replace(e,i),r},getRegex:()=>new RegExp(t,n)};return r}var Bt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ht={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},qt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Dt=/(?:[*+-]|\d{1,9}[.)])/,Ot=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Nt=Lt(Ot).replace(/bull/g,Dt).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/).replace(/\|table/g,"").getRegex(),Ut=Lt(Ot).replace(/bull/g,Dt).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/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ft=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Wt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Vt=Lt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Wt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Kt=Lt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Dt).getRegex(),Zt="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",Qt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Xt=Lt("^ {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[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Qt).replace("tag",Zt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Gt=Lt(Ft).replace("hr",qt).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",Zt).getRegex(),Jt={blockquote:Lt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Gt).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:Vt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:qt,html:Xt,lheading:Nt,list:Kt,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Gt,table:jt,text:/^[^\n]+/},Yt=Lt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",qt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\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",Zt).getRegex(),er={...Jt,lheading:Ut,table:Yt,paragraph:Lt(Ft).replace("hr",qt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yt).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",Zt).getRegex()},nr={...Jt,html:Lt("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Qt).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:jt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Lt(Ft).replace("hr",qt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Nt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},tr=/^( {2,}|\\)\n(?!\s*$)/,rr=/[\p{P}\p{S}]/u,ir=/[\s\p{P}\p{S}]/u,ar=/[^\s\p{P}\p{S}]/u,lr=Lt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ir).getRegex(),or=/(?!~)[\p{P}\p{S}]/u,sr=Lt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Bt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),pr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,cr=Lt(pr,"u").replace(/punct/g,rr).getRegex(),dr=Lt(pr,"u").replace(/punct/g,or).getRegex(),ur="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",hr=Lt(ur,"gu").replace(/notPunctSpace/g,ar).replace(/punctSpace/g,ir).replace(/punct/g,rr).getRegex(),gr=Lt(ur,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,or).getRegex(),fr=Lt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ar).replace(/punctSpace/g,ir).replace(/punct/g,rr).getRegex(),_r=Lt(/\\(punct)/,"gu").replace(/punct/g,rr).getRegex(),vr=Lt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),mr=Lt(Qt).replace("(?:--\x3e|$)","--\x3e").getRegex(),br=Lt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",mr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,kr=Lt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",xr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yr=Lt(/^!?\[(label)\]\[(ref)\]/).replace("label",xr).replace("ref",Wt).getRegex(),wr=Lt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Wt).getRegex(),Sr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Cr={_backpedal:jt,anyPunctuation:_r,autolink:vr,blockSkip:sr,br:tr,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:jt,emStrongLDelim:cr,emStrongRDelimAst:hr,emStrongRDelimUnd:fr,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:kr,nolink:wr,punctuation:lr,reflink:yr,reflinkSearch:Lt("reflink|nolink(?!\\()","g").replace("reflink",yr).replace("nolink",wr).getRegex(),tag:br,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:jt},Pr={...Cr,link:Lt(/^!?\[(label)\]\((.*?)\)/).replace("label",xr).getRegex(),reflink:Lt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",xr).getRegex()},$r={...Cr,emStrongRDelimAst:gr,emStrongLDelim:dr,url:Lt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Sr).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Lt(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Sr).getRegex()},Tr={...$r,br:Lt(tr).replace("{2,}","*").getRegex(),text:Lt($r.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Er={normal:Jt,gfm:er,pedantic:nr},zr={normal:Cr,gfm:$r,breaks:Tr,pedantic:Pr},Ar={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ir=e=>Ar[e];function Rr(e,n){if(n){if(Ht.escapeTest.test(e))return e.replace(Ht.escapeReplace,Ir)}else if(Ht.escapeTestNoEncode.test(e))return e.replace(Ht.escapeReplaceNoEncode,Ir);return e}function Mr(e){try{e=encodeURI(e).replace(Ht.percentDecode,"%")}catch{return null}return e}function jr(e,n){let t=e.replace(Ht.findPipe,(e,n,t)=>{let r=!1,i=n;for(;--i>=0&&"\\"===t[i];)r=!r;return r?"|":" |"}),r=t.split(Ht.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ht.slashPipe,"|");return r}function Lr(e,n,t){let r=e.length;if(0===r)return"";let i=0;for(;i<r;){if(e.charAt(r-i-1)!==n)break;i++}return e.slice(0,r-i)}function Br(e,n,t,r,i){let a=n.href,l=n.title||null,o=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let s={type:"!"===e[0].charAt(0)?"image":"link",raw:t,href:a,title:l,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,s}var Hr=class{options;rules;lexer;constructor(e){this.options=e||Rt}space(e){let n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){let n=this.rules.block.code.exec(e);if(n){let e=n[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Lr(e,"\n")}}}fences(e){let n=this.rules.block.fences.exec(e);if(n){let e=n[0],t=function(e,n,t){let r=e.match(t.other.indentCodeCompensation);if(null===r)return n;let i=r[1];return n.split("\n").map(e=>{let n=e.match(t.other.beginningSpace);if(null===n)return e;let[r]=n;return r.length>=i.length?e.slice(i.length):e}).join("\n")}(e,n[3]||"",this.rules);return{type:"code",raw:e,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:t}}}heading(e){let n=this.rules.block.heading.exec(e);if(n){let e=n[2].trim();if(this.rules.other.endingHash.test(e)){let n=Lr(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:Lr(n[0],"\n")}}blockquote(e){let n=this.rules.block.blockquote.exec(e);if(n){let e=Lr(n[0],"\n").split("\n"),t="",r="",i=[];for(;e.length>0;){let n,a=!1,l=[];for(n=0;n<e.length;n++)if(this.rules.other.blockquoteStart.test(e[n]))l.push(e[n]),a=!0;else{if(a)break;l.push(e[n])}e=e.slice(n);let o=l.join("\n"),s=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");t=t?`${t}\n${o}`:o,r=r?`${r}\n${s}`:s;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(s,i,!0),this.lexer.state.top=p,0===e.length)break;let c=i.at(-1);if("code"===c?.type)break;if("blockquote"===c?.type){let n=c,a=n.raw+"\n"+e.join("\n"),l=this.blockquote(a);i[i.length-1]=l,t=t.substring(0,t.length-n.raw.length)+l.raw,r=r.substring(0,r.length-n.text.length)+l.text;break}if("list"===c?.type){let n=c,a=n.raw+"\n"+e.join("\n"),l=this.list(a);i[i.length-1]=l,t=t.substring(0,t.length-c.raw.length)+l.raw,r=r.substring(0,r.length-n.raw.length)+l.raw,e=a.substring(i.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:t,tokens:i,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let t=n[1].trim(),r=t.length>1,i={type:"list",raw:"",ordered:r,start:r?+t.slice(0,-1):"",loose:!1,items:[]};t=r?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=r?t:"[*+-]");let a=this.rules.other.listItemRegex(t),l=!1;for(;e;){let t=!1,r="",o="";if(!(n=a.exec(e))||this.rules.block.hr.test(e))break;r=n[0],e=e.substring(r.length);let s=n[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),p=e.split("\n",1)[0],c=!s.trim(),d=0;if(this.options.pedantic?(d=2,o=s.trimStart()):c?d=n[1].length+1:(d=n[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,o=s.slice(d),d+=n[1].length),c&&this.rules.other.blankLine.test(p)&&(r+=p+"\n",e=e.substring(p.length+1),t=!0),!t){let n=this.rules.other.nextBulletRegex(d),t=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),l=this.rules.other.htmlBeginRegex(d);for(;e;){let u,h=e.split("\n",1)[0];if(p=h,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),u=p):u=p.replace(this.rules.other.tabCharGlobal," "),i.test(p)||a.test(p)||l.test(p)||n.test(p)||t.test(p))break;if(u.search(this.rules.other.nonSpaceChar)>=d||!p.trim())o+="\n"+u.slice(d);else{if(c||s.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(s)||a.test(s)||t.test(s))break;o+="\n"+p}!c&&!p.trim()&&(c=!0),r+=h+"\n",e=e.substring(h.length+1),s=u.slice(d)}}i.loose||(l?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(l=!0)),i.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),i.raw+=r}let o=i.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,i.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!i.loose){let n=e.tokens.filter(e=>"space"===e.type),t=n.length>0&&n.some(e=>this.rules.other.anyLine.test(e.raw));i.loose=t}}if(i.loose)for(let e of i.items){e.loose=!0;for(let n of e.tokens)"text"===n.type&&(n.type="paragraph")}return i}}html(e){let n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:"pre"===n[1]||"script"===n[1]||"style"===n[1],text:n[0]}}def(e){let n=this.rules.block.def.exec(e);if(n){let e=n[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),t=n[2]?n[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:e,raw:n[0],href:t,title:r}}}table(e){let n=this.rules.block.table.exec(e);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let t=jr(n[1]),r=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],a={type:"table",raw:n[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push("right"):this.rules.other.tableAlignCenter.test(e)?a.align.push("center"):this.rules.other.tableAlignLeft.test(e)?a.align.push("left"):a.align.push(null);for(let e=0;e<t.length;e++)a.header.push({text:t[e],tokens:this.lexer.inline(t[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(jr(e,a.header.length).map((e,n)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[n]})));return a}}lheading(e){let n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:"="===n[2].charAt(0)?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){let n=this.rules.block.paragraph.exec(e);if(n){let e="\n"===n[1].charAt(n[1].length-1)?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){let n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(e){let n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){let n=this.rules.inline.link.exec(e);if(n){let e=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let n=Lr(e.slice(0,-1),"\\");if((e.length-n.length)%2==0)return}else{let e=function(e,n){if(-1===e.indexOf(n[1]))return-1;let t=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===n[0])t++;else if(e[r]===n[1]&&(t--,t<0))return r;return t>0?-2:-1}(n[2],"()");if(-2===e)return;if(e>-1){let t=(0===n[0].indexOf("!")?5:4)+n[1].length+e;n[2]=n[2].substring(0,e),n[0]=n[0].substring(0,t).trim(),n[3]=""}}let t=n[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(t);e&&(t=e[1],r=e[3])}else r=n[3]?n[3].slice(1,-1):"";return t=t.trim(),this.rules.other.startAngleBracket.test(t)&&(t=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?t.slice(1):t.slice(1,-1)),Br(n,{href:t&&t.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer,this.rules)}}reflink(e,n){let t;if((t=this.rules.inline.reflink.exec(e))||(t=this.rules.inline.nolink.exec(e))){let e=n[(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=t[0].charAt(0);return{type:"text",raw:e,text:e}}return Br(t,e,t[0],this.lexer,this.rules)}}emStrong(e,n,t=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!t||this.rules.inline.punctuation.exec(t))){let t,i,a=[...r[0]].length-1,l=a,o=0,s="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(s.lastIndex=0,n=n.slice(-1*e.length+a);null!=(r=s.exec(n));){if(t=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!t)continue;if(i=[...t].length,r[3]||r[4]){l+=i;continue}if((r[5]||r[6])&&a%3&&!((a+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);let n=[...r[0]][0].length,s=e.slice(0,a+r.index+n+i);if(Math.min(a,i)%2){let e=s.slice(1,-1);return{type:"em",raw:s,text:e,tokens:this.lexer.inlineTokens(e)}}let p=s.slice(2,-2);return{type:"strong",raw:s,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let n=this.rules.inline.code.exec(e);if(n){let e=n[2].replace(this.rules.other.newLineCharGlobal," "),t=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return t&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:n[0],text:e}}}br(e){let n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){let n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){let n=this.rules.inline.autolink.exec(e);if(n){let e,t;return"@"===n[2]?(e=n[1],t="mailto:"+e):(e=n[1],t=e),{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let n;if(n=this.rules.inline.url.exec(e)){let e,t;if("@"===n[2])e=n[0],t="mailto:"+e;else{let r;do{r=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])?.[0]??""}while(r!==n[0]);e=n[0],t="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let n=this.rules.inline.text.exec(e);if(n){let e=this.lexer.state.inRawBlock;return{type:"text",raw:n[0],text:n[0],escaped:e}}}},qr=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Rt,this.options.tokenizer=this.options.tokenizer||new Hr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ht,block:Er.normal,inline:zr.normal};this.options.pedantic?(n.block=Er.pedantic,n.inline=zr.pedantic):this.options.gfm&&(n.block=Er.gfm,this.options.breaks?n.inline=zr.breaks:n.inline=zr.gfm),this.tokenizer.rules=n}static get rules(){return{block:Er,inline:zr}}static lex(n,t){return new e(t).lex(n)}static lexInline(n,t){return new e(t).inlineTokens(n)}lex(e){e=e.replace(Ht.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],t=!1){for(this.options.pedantic&&(e=e.replace(Ht.tabCharGlobal," ").replace(Ht.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(t=>!!(r=t.call({lexer:this},e,n))&&(e=e.substring(r.raw.length),n.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let t=n.at(-1);1===r.raw.length&&void 0!==t?t.raw+="\n":n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.raw,this.inlineQueue.at(-1).src=t.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let n,t=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=n.at(-1);t&&"paragraph"===a?.type?(a.raw+=(a.raw.endsWith("\n")?"":"\n")+r.raw,a.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r),t=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let t=n.at(-1);"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let t,r=e,i=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(r));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(r));)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(r));)t=i[2]?i[2].length:0,r=r.slice(0,i.index+t)+"["+"a".repeat(i[0].length-t-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let a=!1,l="";for(;e;){let t;if(a||(l=""),a=!1,this.options.extensions?.inline?.some(r=>!!(t=r.call({lexer:this},e,n))&&(e=e.substring(t.raw.length),n.push(t),!0)))continue;if(t=this.tokenizer.escape(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.tag(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.link(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(t.raw.length);let r=n.at(-1);"text"===t.type&&"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(t=this.tokenizer.emStrong(e,r,l)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.codespan(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.br(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.del(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.autolink(e)){e=e.substring(t.raw.length),n.push(t);continue}if(!this.state.inLink&&(t=this.tokenizer.url(e))){e=e.substring(t.raw.length),n.push(t);continue}let i=e;if(this.options.extensions?.startInline){let n,t=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(t=this.tokenizer.inlineText(i)){e=e.substring(t.raw.length),"_"!==t.raw.slice(-1)&&(l=t.raw.slice(-1)),a=!0;let r=n.at(-1);"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return n}},Dr=class{options;parser;constructor(e){this.options=e||Rt}space(e){return""}code({text:e,lang:n,escaped:t}){let r=(n||"").match(Ht.notSpaceStart)?.[0],i=e.replace(Ht.endingNewline,"")+"\n";return r?'<pre><code class="language-'+Rr(r)+'">'+(t?i:Rr(i,!0))+"</code></pre>\n":"<pre><code>"+(t?i:Rr(i,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:n}){return`<h${n}>${this.parser.parseInline(e)}</h${n}>\n`}hr(e){return"<hr>\n"}list(e){let n=e.ordered,t=e.start,r="";for(let n=0;n<e.items.length;n++){let t=e.items[n];r+=this.listitem(t)}let i=n?"ol":"ul";return"<"+i+(n&&1!==t?' start="'+t+'"':"")+">\n"+r+"</"+i+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let n="",t="";for(let n=0;n<e.header.length;n++)t+=this.tablecell(e.header[n]);n+=this.tablerow({text:t});let r="";for(let n=0;n<e.rows.length;n++){let i=e.rows[n];t="";for(let e=0;e<i.length;e++)t+=this.tablecell(i[e]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+n+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let n=this.parser.parseInline(e.tokens),t=e.header?"th":"td";return(e.align?`<${t} align="${e.align}">`:`<${t}>`)+n+`</${t}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Rr(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:t}){let r=this.parser.parseInline(t),i=Mr(e);if(null===i)return r;let a='<a href="'+(e=i)+'"';return n&&(a+=' title="'+Rr(n)+'"'),a+=">"+r+"</a>",a}image({href:e,title:n,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=Mr(e);if(null===i)return Rr(t);let a=`<img src="${e=i}" alt="${t}"`;return n&&(a+=` title="${Rr(n)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Rr(e.text)}},Or=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Nr=class e{options;renderer;textRenderer;constructor(e){this.options=e||Rt,this.options.renderer=this.options.renderer||new Dr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Or}static parse(n,t){return new e(t).parse(n)}static parseInline(n,t){return new e(t).parseInline(n)}parse(e){let n="";for(let t=0;t<e.length;t++){let r=e[t];if(this.options.extensions?.renderers?.[r.type]){let e=r,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){n+=t||"";continue}}let i=r;switch(i.type){case"space":n+=this.renderer.space(i);break;case"hr":n+=this.renderer.hr(i);break;case"heading":n+=this.renderer.heading(i);break;case"code":n+=this.renderer.code(i);break;case"table":n+=this.renderer.table(i);break;case"blockquote":n+=this.renderer.blockquote(i);break;case"list":n+=this.renderer.list(i);break;case"checkbox":n+=this.renderer.checkbox(i);break;case"html":n+=this.renderer.html(i);break;case"def":n+=this.renderer.def(i);break;case"paragraph":n+=this.renderer.paragraph(i);break;case"text":n+=this.renderer.text(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,n=this.renderer){let t="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){t+=e||"";continue}}let a=i;switch(a.type){case"escape":case"text":t+=n.text(a);break;case"html":t+=n.html(a);break;case"link":t+=n.link(a);break;case"image":t+=n.image(a);break;case"checkbox":t+=n.checkbox(a);break;case"strong":t+=n.strong(a);break;case"em":t+=n.em(a);break;case"codespan":t+=n.codespan(a);break;case"br":t+=n.br(a);break;case"del":t+=n.del(a);break;default:{let e='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}},Ur=class{options;block;constructor(e){this.options=e||Rt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?qr.lex:qr.lexInline}provideParser(){return this.block?Nr.parse:Nr.parseInline}},Fr=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Nr;Renderer=Dr;TextRenderer=Or;Lexer=qr;Tokenizer=Hr;Hooks=Ur;constructor(...e){this.use(...e)}walkTokens(e,n){let t=[];for(let r of e)switch(t=t.concat(n.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)t=t.concat(this.walkTokens(r.tokens,n));for(let r of e.rows)for(let e of r)t=t.concat(this.walkTokens(e.tokens,n));break}case"list":{let e=r;t=t.concat(this.walkTokens(e.items,n));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);t=t.concat(this.walkTokens(i,n))}):e.tokens&&(t=t.concat(this.walkTokens(e.tokens,n)))}}return t}use(...e){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let t={...e};if(t.async=this.defaults.async||t.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let t=n.renderers[e.name];n.renderers[e.name]=t?function(...n){let r=e.renderer.apply(this,n);return!1===r&&(r=t.apply(this,n)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let t=n[e.level];t?t.unshift(e.tokenizer):n[e.level]=[e.tokenizer],e.start&&("block"===e.level?n.startBlock?n.startBlock.push(e.start):n.startBlock=[e.start]:"inline"===e.level&&(n.startInline?n.startInline.push(e.start):n.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(n.childTokens[e.name]=e.childTokens)}),t.extensions=n),e.renderer){let n=this.defaults.renderer||new Dr(this.defaults);for(let t in e.renderer){if(!(t in n))throw new Error(`renderer '${t}' does not exist`);if(["options","parser"].includes(t))continue;let r=t,i=e.renderer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t||""}}t.renderer=n}if(e.tokenizer){let n=this.defaults.tokenizer||new Hr(this.defaults);for(let t in e.tokenizer){if(!(t in n))throw new Error(`tokenizer '${t}' does not exist`);if(["options","rules","lexer"].includes(t))continue;let r=t,i=e.tokenizer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.tokenizer=n}if(e.hooks){let n=this.defaults.hooks||new Ur;for(let t in e.hooks){if(!(t in n))throw new Error(`hook '${t}' does not exist`);if(["options","block"].includes(t))continue;let r=t,i=e.hooks[r],a=n[r];Ur.passThroughHooks.has(t)?n[r]=e=>{if(this.defaults.async&&Ur.passThroughHooksRespectAsync.has(t))return(async()=>{let t=await i.call(n,e);return a.call(n,t)})();let r=i.call(n,e);return a.call(n,r)}:n[r]=(...e)=>{if(this.defaults.async)return(async()=>{let t=await i.apply(n,e);return!1===t&&(t=await a.apply(n,e)),t})();let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.hooks=n}if(e.walkTokens){let n=this.defaults.walkTokens,r=e.walkTokens;t.walkTokens=function(e){let t=[];return t.push(r.call(this,e)),n&&(t=t.concat(n.call(this,e))),t}}this.defaults={...this.defaults,...t}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return qr.lex(e,n??this.defaults)}parser(e,n){return Nr.parse(e,n??this.defaults)}parseMarkdown(e){return(n,t)=>{let r={...t},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return a(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 n>"u"||null===n)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let t=i.hooks?await i.hooks.preprocess(n):n,r=await(i.hooks?await i.hooks.provideLexer():e?qr.lex:qr.lexInline)(t,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let l=await(i.hooks?await i.hooks.provideParser():e?Nr.parse:Nr.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(a);try{i.hooks&&(n=i.hooks.preprocess(n));let t=(i.hooks?i.hooks.provideLexer():e?qr.lex:qr.lexInline)(n,i);i.hooks&&(t=i.hooks.processAllTokens(t)),i.walkTokens&&this.walkTokens(t,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Nr.parse:Nr.parseInline)(t,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,n){return t=>{if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Rr(t.message+"",!0)+"</pre>";return n?Promise.resolve(e):e}if(n)return Promise.reject(t);throw t}}};function Wr(e,n){return Fr.parse(e,n)}function Vr(e){try{return Wr.parse(e)}catch(n){return console.error("[Pillar] Markdown parsing error:",n),e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")}}Wr.options=Wr.setOptions=function(e){return Fr.setOptions(e),Wr.defaults=Fr.defaults,Mt(Wr.defaults),Wr},Wr.getDefaults=It,Wr.defaults=Rt,Wr.use=function(...e){return Fr.use(...e),Wr.defaults=Fr.defaults,Mt(Wr.defaults),Wr},Wr.walkTokens=function(e,n){return Fr.walkTokens(e,n)},Wr.parseInline=Fr.parseInline,Wr.Parser=Nr,Wr.parser=Nr.parse,Wr.Renderer=Dr,Wr.TextRenderer=Or,Wr.Lexer=qr,Wr.lexer=qr.lex,Wr.Tokenizer=Hr,Wr.Hooks=Ur,Wr.parse=Wr,Wr.options,Wr.setOptions,Wr.use,Wr.walkTokens,Wr.parseInline,Nr.parse,qr.lex,Wr.setOptions({gfm:!0,breaks:!0});const Kr={navigate:"arrow-right",open_modal:"layout",fill_form:"edit",trigger_action:"zap",copy_text:"copy",external_link:"external-link",start_tutorial:"play-circle"},Zr={"arrow-right":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12,5 19,12 12,19"/></svg>',"user-plus":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="8.5" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="23" y1="11" x2="17" y2="11"/></svg>',settings:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',"external-link":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15,3 21,3 21,9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',"play-circle":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polygon points="10,8 16,12 10,16 10,8"/></svg>',zap:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13,2 3,14 12,14 11,22 21,10 12,10 13,2"/></svg>',"message-circle":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/></svg>',download:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',copy:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',layout:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',edit:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>'};function Qr(e){const{task:n,onExecute:t}=e,r=document.createElement("button");r.className=function(e="primary"){return`pillar-task-btn pillar-task-btn--${e}`}(n.buttonVariant||"primary"),r.type="button";const i=n.icon||((a=n.taskType)&&Kr[a]||"zap");var a;if(i&&Zr[i]){const e=document.createElement("span");e.className="pillar-task-btn__icon",e.innerHTML=Zr[i],r.appendChild(e)}const l=n.label||n.name.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");const o=document.createElement("span");return o.className="pillar-task-btn__label",o.textContent=l,r.appendChild(o),r.addEventListener("click",()=>{const e=Ai.getInstance();if(e){const t=n.data||{},r=n.path||t.path,i=n.externalUrl||t.url,a={id:n.id,name:n.name,data:t,taskType:n.taskType,path:r,externalUrl:i};e.executeTask(a)}t?.()}),r}const Xr="\n/* Task Button Component */\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n";function Gr(){const e=at(),n=me(null),t=me(!1);ve(()=>{if(t.current)return;const e=Tn.value,n=An.value;e&&(t.current=!0,Tn.value=null,An.value=[],a(e,n.length>0?n:void 0))},[]),ve(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[xn.value]),ve(()=>{const e=Ai.getInstance();if(!e)return;const n=e.on("task:complete",({name:e,success:n})=>{((e,n,t)=>{const r=xn.value;for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.actionStatus?.[e]){const l={...a.actionStatus,[e]:{status:n?"success":"failed",completedAt:Date.now(),errorMessage:t}};return void(xn.value=[...r.slice(0,i),{...a,actionStatus:l},...r.slice(i+1)])}}})(e,n);const t=function(e,n){const t=e.replace(/_/g," ").toLowerCase();return n?t.startsWith("open ")?`Opened ${t.slice(5)}`:t.startsWith("go to ")?`Navigated to ${t.slice(6)}`:t.startsWith("navigate to ")?`Navigated to ${t.slice(12)}`:"Done!":`Failed to ${t}`}(e,n);((e,n)=>{const t=xn.value;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.actionStatus?.[e])return void(xn.value=[...t.slice(0,r),{...i,content:n},...t.slice(r+1)])}})(e,t)});return n},[]);const r=xe(e=>{console.log("[Pillar] Plan received:",e.id,e.goal);const n=Ai.getInstance();n&&n.handlePlanReceived(e)},[]),i=xe(e=>{const n=Ai.getInstance();console.log("[Pillar] handleActionsReceived called with",e.length,"actions"),console.log("[Pillar] Actions detail:",e.map(e=>({name:e.name,autoRun:e.autoRun})));const t=e.filter(e=>!0===e.autoRun),r=e.filter(e=>!e.autoRun);return console.log("[Pillar] Auto-run actions:",t.length,", Manual actions:",r.length),n&&t.length>0?(console.log("[Pillar] Executing auto-run actions..."),t.forEach(e=>{const t=e.data||{},r=t.path,i=t.url,a=xn.value.length-1;a>=0&&((e,n)=>{const t=xn.value;if(e>=0&&e<t.length){const r=t[e],i={...r.actionStatus||{},[n]:{status:"pending"}};xn.value=[...t.slice(0,e),{...r,actionStatus:i},...t.slice(e+1)]}})(a,e.name),console.log("[Pillar] Executing action:",e.name),n.executeTask({id:e.id,name:e.name,taskType:e.taskType,data:t,path:r,externalUrl:i})}),[]):n?r:(console.warn("[Pillar] No Pillar instance available for auto-run"),e)},[]),a=xe(async(n,t,a)=>{var l,o,s;((e,n,t)=>{xn.value=[...xn.value,{role:"user",content:e,userContext:n&&n.length>0?n:void 0,images:t&&t.length>0?t:void 0}]})(n,t,a),Bn(!0),l="",xn.value=[...xn.value,{role:"assistant",content:l,id:o}];try{let l="",o=[];const p=xn.value.slice(0,-1),c=await e.chat(n,p,e=>{l+=e,Ln(l)},void 0,kn.value,e=>{o=i(e)},r,t,a,e=>{var n;n={kind:e.kind,message:e.message},wn.value=n});let d=o;c.actions&&c.actions.length>0&&(d=i(c.actions)),Ln(c.message,c.messageId,d,c.sources),c.conversationId&&(s=c.conversationId,kn.value=s)}catch(e){console.error("[Pillar] Chat error:",e),Ln("Sorry, I encountered an error. Please try again.")}finally{Bn(!1),wn.value={kind:null}}},[e,i]),l=xe(async(n,t)=>{((e,n)=>{xn.value=xn.value.map(t=>t.id===e?{...t,feedback:n}:t)})(n,t),await e.submitFeedback(n,t)},[e]),o=xe((e,n,t)=>{yn.value||a(e,n.length>0?n:void 0,t.length>0?t:void 0)},[a]),s=me(new Map);return ve(()=>{const e=Ai.getInstance();xn.value.forEach((n,t)=>{if("assistant"===n.role&&n.actions&&n.actions.length>0){const r=s.current.get(t);if(r&&0===r.children.length){const t=n.actions.filter(e=>"inline_ui"===e.taskType),i=n.actions.filter(e=>"inline_ui"!==e.taskType);if(t.forEach(n=>{const t=function(e,n,t){const r=document.createElement("div");r.className="pillar-confirm-card-wrapper";const i=e.data?.card_type||e.name,a=Ai.getInstance(),l=a?.getCardRenderer(i),o={onConfirm:t=>{n(t||e.data)},onCancel:t,onStateChange:(e,n)=>{console.log(`[Pillar] Card state changed to ${e}${n?`: ${n}`:""}`)}};if(l)try{const n=l(r,e.data||{},o);r._cleanup=n||void 0}catch(e){console.error("[Pillar] Custom card renderer error:",e)}else{const n=et(e,o);r.appendChild(n)}return r}(n,t=>{e&&e.executeTask({id:n.id,name:n.name,taskType:n.taskType,data:t||n.data||{}})},()=>{console.log("[Pillar] Confirm action cancelled:",n.name)});r.appendChild(t)}),i.length>0){const e=function(e){const n=document.createElement("div");return n.className="pillar-task-btn-group",e.forEach(e=>{const t=Qr({task:e});n.appendChild(t)}),n}(i);r.appendChild(e)}}}})},[xn.value]),ne("div",{class:"_pillar-chat-view pillar-chat-view",children:[ne("div",{class:"_pillar-chat-view-messages pillar-chat-view-messages",ref:n,children:[0===xn.value.length&&ne("div",{class:"_pillar-chat-view-welcome pillar-chat-view-welcome",children:[ne("div",{class:"_pillar-chat-view-welcome-icon pillar-chat-view-welcome-icon",children:"💬"}),ne("div",{class:"_pillar-chat-view-welcome-title pillar-chat-view-welcome-title",children:"Ask a question"}),ne("div",{class:"_pillar-chat-view-welcome-text pillar-chat-view-welcome-text",children:"Ask me anything about how to use this product."})]}),xn.value.map((e,n)=>ne("div",{class:`_pillar-chat-view-message pillar-chat-view-message _pillar-chat-view-message--${e.role} pillar-chat-view-message--${e.role}`,children:"user"===e.role?ne("div",{class:"_pillar-message-user pillar-message-user",children:[e.userContext&&e.userContext.length>0&&ne(Pt,{contexts:e.userContext,readOnly:!0}),e.images&&e.images.length>0&&ne("div",{class:"_pillar-message-user-images pillar-message-user-images",children:e.images.map((e,n)=>ne("img",{src:e.url,alt:`Attachment ${n+1}`,class:"_pillar-message-user-image pillar-message-user-image"},n))}),e.content]}):ne("div",{class:"_pillar-message-assistant-wrapper pillar-message-assistant-wrapper",children:[ne("div",{class:"_pillar-message-assistant-content pillar-message-assistant-content",children:[e.content?ne("div",{class:"_pillar-message-assistant pillar-message-assistant",dangerouslySetInnerHTML:{__html:Vr(e.content)}}):ne("div",{class:"_pillar-progress-indicator pillar-progress-indicator",children:[ne("div",{class:"_pillar-loading-spinner pillar-loading-spinner"}),ne("span",{class:"_pillar-progress-message pillar-progress-message",children:wn.value.message||"Thinking..."})]}),e.actionStatus&&Object.keys(e.actionStatus).length>0&&ne("span",{class:"_pillar-action-status pillar-action-status",children:Object.entries(e.actionStatus).map(([e,n])=>ne("span",{class:`_pillar-action-status-indicator pillar-action-status-indicator _pillar-action-status-indicator--${n.status} pillar-action-status-indicator--${n.status}`,title:"failed"===n.status?n.errorMessage:e,dangerouslySetInnerHTML:{__html:"success"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>':"failed"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" opacity="0.3"/><path d="M12 2v4"/></svg>'}},e))})]}),e.id&&e.content&&ne("div",{class:"_pillar-feedback-icons pillar-feedback-icons",children:[ne("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("up"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>l(e.id,"up"),"aria-label":"Helpful",title:"Helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"/></svg>'}}),ne("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("down"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>l(e.id,"down"),"aria-label":"Not helpful",title:"Not helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"/></svg>'}})]}),e.sources&&e.sources.length>0&&ne("div",{class:"_pillar-chat-sources pillar-chat-sources",children:[ne("div",{class:"_pillar-chat-sources-title pillar-chat-sources-title",children:"Sources"}),e.sources.map(e=>ne("div",{class:"_pillar-chat-source pillar-chat-source",children:e.title},e.slug))]}),e.actions&&e.actions.length>0&&ne("div",{class:"_pillar-chat-actions pillar-chat-actions",children:[ne("div",{class:"_pillar-chat-actions-title pillar-chat-actions-title",children:"Suggested actions"}),ne("div",{ref:e=>{e&&s.current.set(n,e)},class:"_pillar-chat-actions-buttons pillar-chat-actions-buttons"})]})]})},n)),ht.value&&ne(xt,{})]}),ne("div",{class:"_pillar-chat-view-input-area pillar-chat-view-input-area",children:[ne(Tt,{placeholder:"Ask a question... (paste or drop images)",disabled:yn.value,onSubmit:o}),xn.value.length>0&&ne("div",{class:"_pillar-chat-view-input-footer pillar-chat-view-input-footer",children:ne("button",{class:"_pillar-chat-view-new-chat-btn pillar-chat-view-new-chat-btn",onClick:Zn,type:"button",children:[ne("span",{class:"_pillar-chat-view-new-chat-icon",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>'}}),"New chat"]})})]})]})}function Jr(){const e=Un.value,n=nn.value,t=(()=>{if("assistant"!==n)return n.charAt(0).toUpperCase()+n.slice(1)})(),r="chat"===e.type,i="home"===e.type;return ne("div","assistant"!==n?{class:"_pillar-panel-ui pillar-panel-ui",children:[ne(wt,{currentView:"home",customTitle:t}),ne("div",{class:"_pillar-content pillar-content",children:"support"===n?ne("div",{style:{padding:"24px",textAlign:"center"},children:[ne("h2",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:"Hello World"}),ne("p",{style:{color:"var(--pillar-text-muted)",fontSize:"14px"},children:"Support tab content goes here."})]}):null})]}:{class:"_pillar-panel-ui pillar-panel-ui",children:[ne(wt,{currentView:e.type,customTitle:t,hideNavigation:r}),ne("div",{class:"_pillar-content pillar-content",children:(()=>{switch(e.type){case"home":default:return ne(At,{});case"chat":return ne(Gr,{})}})()}),!r&&!i&&ne("div",{class:"_pillar-chat-input-area pillar-chat-input-area",children:ne(Tt,{placeholder:"Ask a question..."})})]})}function Yr(e,n=""){const t=[];return e.primary&&t.push(`--pillar-primary${n}: ${e.primary};`),e.primaryHover&&t.push(`--pillar-primary-hover${n}: ${e.primaryHover};`),e.background&&t.push(`--pillar-bg${n}: ${e.background};`),e.backgroundSecondary&&t.push(`--pillar-bg-secondary${n}: ${e.backgroundSecondary};`),e.text&&t.push(`--pillar-text${n}: ${e.text};`),e.textMuted&&t.push(`--pillar-text-muted${n}: ${e.textMuted};`),e.border&&t.push(`--pillar-border${n}: ${e.border};`),e.borderLight&&t.push(`--pillar-border-light${n}: ${e.borderLight};`),t.join("\n ")}function ei(e){const n=Yr(e.colors),t=Yr(e.darkColors);let r="";return n&&(r+=`\n:host {\n ${n}\n}\n`),t&&(r+=`\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n ${t}\n }\n}\n:host([data-theme="dark"]) {\n ${t}\n}\n`),r}const ni="\n/* ============================================================================\n CSS Custom Properties (Variables)\n Users can override these to customize colors\n ============================================================================ */\n\n:host {\n /* Core colors - Light mode (default) */\n --pillar-primary: #2563eb;\n --pillar-primary-hover: #1d4ed8;\n --pillar-primary-light: #eff6ff;\n --pillar-primary-light-hover: #dbeafe;\n \n --pillar-bg: #ffffff;\n --pillar-bg-secondary: #f9fafb;\n --pillar-bg-tertiary: #f3f4f6;\n \n --pillar-text: #1a1a1a;\n --pillar-text-secondary: #374151;\n --pillar-text-muted: #6b7280;\n --pillar-text-placeholder: #9ca3af;\n \n --pillar-border: #e5e7eb;\n --pillar-border-light: #f3f4f6;\n \n /* Shadows */\n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n \n /* Code blocks */\n --pillar-code-bg: #1f2937;\n --pillar-code-text: #e5e7eb;\n \n /* Scrollbar */\n --pillar-scrollbar-track: transparent;\n --pillar-scrollbar-thumb: #d1d5db;\n --pillar-scrollbar-thumb-hover: #9ca3af;\n \n /* Spacing (can be customized) */\n --pillar-panel-width: 380px;\n --pillar-spacing-xs: 4px;\n --pillar-spacing-sm: 8px;\n --pillar-spacing-md: 12px;\n --pillar-spacing-lg: 16px;\n --pillar-spacing-xl: 20px;\n --pillar-spacing-2xl: 24px;\n \n /* Border radius */\n --pillar-radius-sm: 4px;\n --pillar-radius-md: 6px;\n --pillar-radius-lg: 8px;\n --pillar-radius-xl: 10px;\n --pillar-radius-full: 9999px;\n \n /* Typography */\n --pillar-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n --pillar-font-mono: 'SF Mono', Consolas, monospace;\n --pillar-font-size-xs: 11px;\n --pillar-font-size-sm: 12px;\n --pillar-font-size-base: 14px;\n --pillar-font-size-md: 15px;\n --pillar-font-size-lg: 16px;\n --pillar-font-size-xl: 18px;\n --pillar-font-size-2xl: 20px;\n \n /* Animation */\n --pillar-transition-fast: 0.15s ease;\n --pillar-transition-normal: 0.3s ease;\n}\n\n/* Dark mode - Auto-detect from system preference */\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme=\"light\"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n }\n}\n\n/* Dark mode - Manual override */\n:host([data-theme=\"dark\"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n}\n\n/* ============================================================================\n Base Styles\n Note: No CSS reset - we rely on explicit styles for SDK components\n and allow custom cards to inherit host app styling (Tailwind, etc.)\n ============================================================================ */\n\n:host {\n font-family: var(--pillar-font-family);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n color: var(--pillar-text);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n/* ============================================================================\n Panel Container\n Internal: _pillar-panel | Public: pillar-panel\n ============================================================================ */\n\n._pillar-panel {\n position: fixed;\n top: 0;\n bottom: 0;\n width: var(--pillar-panel-width);\n max-width: 100vw;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n display: flex;\n flex-direction: column;\n z-index: 99999;\n transform: translateX(100%);\n transition: transform var(--pillar-transition-normal);\n}\n\n._pillar-panel--right {\n right: 0;\n}\n\n._pillar-panel--left {\n left: 0;\n border-left: none;\n border-right: 1px solid var(--pillar-border);\n transform: translateX(-100%);\n}\n\n._pillar-panel--open {\n transform: translateX(0);\n}\n\n._pillar-panel--manual {\n position: static;\n transform: none;\n height: 100%;\n}\n\n._pillar-panel-root {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\n._pillar-panel-ui {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n/* Public override classes - empty by default */\n.pillar-panel {}\n.pillar-panel-root {}\n.pillar-panel-ui {}\n\n/* ============================================================================\n Backdrop\n ============================================================================ */\n\n._pillar-backdrop {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity var(--pillar-transition-normal), visibility var(--pillar-transition-normal);\n z-index: 99998;\n}\n\n._pillar-backdrop--visible {\n opacity: 1;\n visibility: visible;\n}\n\n.pillar-backdrop {}\n\n/* ============================================================================\n Header\n Internal: _pillar-header | Public: pillar-header\n ============================================================================ */\n\n._pillar-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n border-bottom: 1px solid var(--pillar-border);\n flex-shrink: 0;\n background: var(--pillar-bg);\n}\n\n._pillar-header-left {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n}\n\n._pillar-header-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n/* Public override classes */\n.pillar-header {}\n.pillar-header-left {}\n.pillar-header-title {}\n\n/* ============================================================================\n Icon Buttons (back, home, close)\n Internal: _pillar-icon-btn | Public: pillar-icon-btn\n ============================================================================ */\n\n._pillar-icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: none;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast), background var(--pillar-transition-fast);\n}\n\n._pillar-icon-btn:hover {\n color: var(--pillar-text);\n background: var(--pillar-bg-tertiary);\n}\n\n._pillar-icon-btn svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-icon-btn {}\n.pillar-back-btn {}\n.pillar-home-btn {}\n.pillar-close-btn {}\n\n/* ============================================================================\n Content Area\n Internal: _pillar-content | Public: pillar-content\n ============================================================================ */\n\n._pillar-content {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 0;\n}\n\n.pillar-content {}\n\n/* ============================================================================\n Search Input\n Internal: _pillar-search | Public: pillar-search\n ============================================================================ */\n\n._pillar-search {\n position: relative;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-search-input {\n width: 100%;\n padding: 10px 12px 10px 40px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n outline: none;\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-search-input:focus {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-search-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-search-icon {\n position: absolute;\n left: 32px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n color: var(--pillar-text-placeholder);\n pointer-events: none;\n}\n\n._pillar-search-icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-search {}\n.pillar-search-input {}\n.pillar-search-icon {}\n\n/* ============================================================================\n Chat Input (Persistent Bottom)\n Internal: _pillar-chat-input | Public: pillar-chat-input\n ============================================================================ */\n\n._pillar-chat-input-container {\n flex-shrink: 0;\n border-top: 1px solid var(--pillar-border);\n background: var(--pillar-bg);\n display: flex;\n flex-direction: column;\n max-height: 50%;\n transition: max-height var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded {\n max-height: 60%;\n}\n\n._pillar-chat-input-messages {\n flex: 1;\n overflow-y: auto;\n padding: 0;\n max-height: 0;\n transition: max-height var(--pillar-transition-normal), padding var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded ._pillar-chat-input-messages {\n max-height: 300px;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-chat-input-message {\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-chat-input-message--user {\n text-align: right;\n}\n\n._pillar-chat-input-message-content {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n}\n\n._pillar-chat-input-message--user ._pillar-chat-input-message-content {\n background: var(--pillar-primary);\n color: #ffffff;\n border-bottom-right-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-message--assistant ._pillar-chat-input-message-content {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n border-bottom-left-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-sources {\n margin-top: var(--pillar-spacing-sm);\n padding-top: var(--pillar-spacing-sm);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-input-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: 6px;\n}\n\n._pillar-chat-input-source {\n display: block;\n padding: 6px 10px;\n margin-bottom: var(--pillar-spacing-xs);\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-md);\n text-decoration: none;\n cursor: pointer;\n}\n\n._pillar-chat-input-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-chat-input-area {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n}\n\n._pillar-chat-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-input-textarea {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-input-textarea::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-chat-input-container {}\n.pillar-chat-input-messages {}\n.pillar-chat-input-message {}\n.pillar-chat-input-message-content {}\n.pillar-chat-input-sources {}\n.pillar-chat-input-area {}\n.pillar-chat-input-wrapper {}\n.pillar-chat-input-textarea {}\n\n/* ============================================================================\n Chat Input Footer (contains send button)\n ============================================================================ */\n\n._pillar-chat-input-footer {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n/* ============================================================================\n Send Button - In footer row, right aligned\n Internal: _pillar-send-btn | Public: pillar-send-btn\n ============================================================================ */\n\n._pillar-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-send-btn {}\n.pillar-chat-input-footer {}\n\n/* ============================================================================\n Loading States\n Internal: _pillar-loading | Public: pillar-loading\n ============================================================================ */\n\n._pillar-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 40px var(--pillar-spacing-xl);\n color: var(--pillar-text-muted);\n}\n\n._pillar-loading-spinner {\n width: 24px;\n height: 24px;\n border: 2px solid var(--pillar-border);\n border-top-color: var(--pillar-primary);\n border-radius: 50%;\n animation: pillar-spin 0.8s linear infinite;\n}\n\n@keyframes pillar-spin {\n to { transform: rotate(360deg); }\n}\n\n.pillar-loading {}\n.pillar-loading-spinner {}\n\n/* ============================================================================\n Progress Indicator (AI activity status)\n Internal: _pillar-progress | Public: pillar-progress\n ============================================================================ */\n\n._pillar-progress-indicator {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-sm) 0;\n}\n\n._pillar-progress-indicator ._pillar-loading-spinner {\n width: 16px;\n height: 16px;\n flex-shrink: 0;\n}\n\n._pillar-progress-message {\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n font-style: italic;\n}\n\n.pillar-progress-indicator {}\n.pillar-progress-message {}\n\n/* ============================================================================\n Empty States\n Internal: _pillar-empty | Public: pillar-empty\n ============================================================================ */\n\n._pillar-empty {\n padding: 40px var(--pillar-spacing-xl);\n text-align: center;\n color: var(--pillar-text-muted);\n}\n\n._pillar-empty-icon {\n width: 48px;\n height: 48px;\n margin: 0 auto var(--pillar-spacing-lg);\n color: var(--pillar-border);\n}\n\n._pillar-empty-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 500;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-empty-description {\n font-size: var(--pillar-font-size-base);\n}\n\n.pillar-empty {}\n.pillar-empty-icon {}\n.pillar-empty-title {}\n.pillar-empty-description {}\n\n/* ============================================================================\n Section Titles\n Internal: _pillar-section-title | Public: pillar-section-title\n ============================================================================ */\n\n._pillar-section-title {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-xl) var(--pillar-spacing-sm);\n font-size: var(--pillar-font-size-xs);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: var(--pillar-text-muted);\n}\n\n.pillar-section-title {}\n\n/* ============================================================================\n Related Articles\n ============================================================================ */\n\n._pillar-related-articles {\n border-top: 1px solid var(--pillar-border);\n margin-top: var(--pillar-spacing-2xl);\n padding-top: var(--pillar-spacing-sm);\n}\n\n.pillar-related-articles {}\n\n/* ============================================================================\n Scrollbar Styling\n ============================================================================ */\n\n._pillar-content::-webkit-scrollbar,\n._pillar-chat-input-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-content::-webkit-scrollbar-track,\n._pillar-chat-input-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-content::-webkit-scrollbar-thumb,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-content::-webkit-scrollbar-thumb:hover,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Home View\n ============================================================================ */\n\n._pillar-home-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n padding: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-header {\n text-align: center;\n padding: var(--pillar-spacing-2xl) 0;\n}\n\n._pillar-home-view-icon {\n font-size: 40px;\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-home-view-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 0;\n}\n\n._pillar-home-view-questions {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n margin-bottom: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-input-wrapper {\n margin-top: auto;\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-home-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-home-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-home-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-home-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-home-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-home-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-home-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-home-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-home-view {}\n.pillar-home-view-header {}\n.pillar-home-view-title {}\n.pillar-home-view-questions {}\n.pillar-home-view-input-wrapper {}\n.pillar-home-view-input {}\n.pillar-home-view-send-btn {}\n\n/* ============================================================================\n Question Chip\n ============================================================================ */\n\n._pillar-question-chip {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n text-align: left;\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: background var(--pillar-transition-fast), border-color var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover {\n border-color: var(--pillar-primary);\n}\n\n._pillar-question-chip-text {\n flex: 1;\n}\n\n._pillar-question-chip-arrow {\n color: var(--pillar-text-muted);\n margin-left: var(--pillar-spacing-sm);\n transition: color var(--pillar-transition-fast), transform var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover ._pillar-question-chip-arrow {\n color: var(--pillar-primary);\n transform: translateX(2px);\n}\n\n._pillar-question-chip-skeleton {\n height: 44px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n overflow: hidden;\n}\n\n._pillar-question-chip-skeleton-bar {\n width: 60%;\n height: 14px;\n margin: 15px var(--pillar-spacing-lg);\n background: linear-gradient(90deg, var(--pillar-border) 25%, var(--pillar-bg-tertiary) 50%, var(--pillar-border) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n border-radius: var(--pillar-radius-sm);\n}\n\n@keyframes pillar-shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n\n.pillar-question-chip {}\n.pillar-question-chip-text {}\n.pillar-question-chip-arrow {}\n.pillar-question-chip-skeleton {}\n.pillar-question-chip-skeleton-bar {}\n\n/* ============================================================================\n Standalone Chat View\n Internal: _pillar-chat-view | Public: pillar-chat-view\n ============================================================================ */\n\n._pillar-chat-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n._pillar-chat-view-messages {\n flex: 1;\n overflow-y: auto;\n padding: var(--pillar-spacing-xl);\n display: flex;\n flex-direction: column;\n}\n\n._pillar-chat-view-welcome {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px var(--pillar-spacing-xl);\n text-align: center;\n flex: 1;\n}\n\n._pillar-chat-view-welcome-icon {\n font-size: 48px;\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-welcome-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-welcome-text {\n font-size: var(--pillar-font-size-base);\n color: var(--pillar-text-muted);\n max-width: 280px;\n}\n\n._pillar-chat-view-message {\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-message--user {\n text-align: right;\n}\n\n._pillar-chat-view-message--assistant {\n text-align: left;\n}\n\n.pillar-chat-view {}\n.pillar-chat-view-messages {}\n.pillar-chat-view-welcome {}\n.pillar-chat-view-message {}\n\n/* ============================================================================\n User Message Bubble\n Internal: _pillar-message-user | Public: pillar-message-user\n ============================================================================ */\n\n._pillar-message-user {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n border-bottom-right-radius: var(--pillar-radius-sm);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n background: var(--pillar-primary);\n color: #ffffff;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n\n._pillar-message-user-images {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-message-user-image {\n max-width: 120px;\n max-height: 120px;\n border-radius: var(--pillar-radius-md);\n object-fit: cover;\n}\n\n.pillar-message-user {}\n.pillar-message-user-images {}\n.pillar-message-user-image {}\n\n/* ============================================================================\n AI Response\n Internal: _pillar-message-assistant | Public: pillar-message-assistant\n ============================================================================ */\n\n._pillar-message-assistant {\n font-size: var(--pillar-font-size-base);\n line-height: 1.6;\n color: var(--pillar-text-secondary);\n}\n\n._pillar-message-assistant p {\n margin: 0 0 var(--pillar-spacing-md);\n}\n\n._pillar-message-assistant p:last-child {\n margin-bottom: 0;\n}\n\n._pillar-message-assistant h2 {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-lg) 0 var(--pillar-spacing-sm);\n}\n\n._pillar-message-assistant h3 {\n font-size: var(--pillar-font-size-md);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 14px 0 6px;\n}\n\n._pillar-message-assistant h4 {\n font-size: var(--pillar-font-size-base);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-md) 0 6px;\n}\n\n._pillar-message-assistant ul,\n._pillar-message-assistant ol {\n margin: 0 0 var(--pillar-spacing-md);\n padding-left: var(--pillar-spacing-2xl);\n list-style-position: outside;\n}\n\n._pillar-message-assistant ul {\n list-style-type: disc;\n}\n\n._pillar-message-assistant ol {\n list-style-type: decimal;\n}\n\n._pillar-message-assistant li {\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-message-assistant code {\n padding: 2px 6px;\n font-size: var(--pillar-font-size-sm);\n background: var(--pillar-bg-tertiary);\n border-radius: var(--pillar-radius-sm);\n font-family: var(--pillar-font-mono);\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant pre {\n margin: var(--pillar-spacing-md) 0;\n padding: var(--pillar-spacing-md) 14px;\n background: var(--pillar-code-bg);\n border-radius: var(--pillar-radius-lg);\n overflow-x: auto;\n}\n\n._pillar-message-assistant pre code {\n padding: 0;\n background: none;\n color: var(--pillar-code-text);\n font-size: var(--pillar-font-size-sm);\n line-height: 1.5;\n}\n\n._pillar-message-assistant a {\n color: var(--pillar-primary);\n text-decoration: none;\n}\n\n._pillar-message-assistant a:hover {\n text-decoration: underline;\n}\n\n._pillar-message-assistant strong {\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant em {\n font-style: italic;\n}\n\n.pillar-message-assistant {}\n\n/* ============================================================================\n Chat Sources\n Internal: _pillar-chat-sources | Public: pillar-chat-sources\n ============================================================================ */\n\n._pillar-chat-sources {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-source {\n display: block;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n margin-bottom: 6px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-lg);\n text-decoration: none;\n cursor: pointer;\n transition: background var(--pillar-transition-fast);\n}\n\n._pillar-chat-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n.pillar-chat-sources {}\n.pillar-chat-sources-title {}\n.pillar-chat-source {}\n\n/* ============================================================================\n Chat Actions (Suggested action buttons)\n Internal: _pillar-chat-actions | Public: pillar-chat-actions\n ============================================================================ */\n\n._pillar-chat-actions {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-actions-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-actions-buttons {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Task buttons should wrap horizontally */\n._pillar-chat-actions-buttons > ._pillar-task-button-group {\n display: flex;\n flex-wrap: wrap;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Confirm cards take full width */\n._pillar-chat-actions-buttons > .pillar-confirm-card-wrapper {\n width: 100%;\n}\n\n.pillar-chat-actions {}\n.pillar-chat-actions-title {}\n.pillar-chat-actions-buttons {}\n\n/* ============================================================================\n Chat View Input Area - Cursor-style design\n ============================================================================ */\n\n._pillar-chat-view-input-area {\n flex-shrink: 0;\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n border-top: 1px solid var(--pillar-border);\n background: var(--pillar-bg);\n}\n\n._pillar-chat-view-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-chat-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-chat-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-chat-view-send-btn:active:not(:disabled) {\n transform: scale(0.95);\n}\n\n._pillar-chat-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-chat-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-chat-view-input-area {}\n.pillar-chat-view-input-wrapper {}\n.pillar-chat-view-input {}\n.pillar-chat-view-send-btn {}\n.pillar-chat-view-input-footer {}\n.pillar-chat-view-new-chat-btn {}\n\n/* New chat button styling */\n._pillar-chat-view-input-footer {\n display: flex;\n justify-content: center;\n margin-top: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-new-chat-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 6px 12px;\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n font-family: var(--pillar-font-family);\n color: var(--pillar-text-muted);\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-new-chat-btn:hover {\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-chat-view-new-chat-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-view-new-chat-icon svg {\n width: 14px;\n height: 14px;\n}\n\n/* Scrollbar for chat view */\n._pillar-chat-view-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Chat Image Upload\n ============================================================================ */\n\n._pillar-chat-view-input-area--dragging {\n position: relative;\n background: rgba(37, 99, 235, 0.05);\n}\n\n._pillar-chat-drop-overlay {\n position: absolute;\n inset: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: rgba(37, 99, 235, 0.1);\n border: 2px dashed var(--pillar-primary);\n border-radius: var(--pillar-radius-lg);\n color: var(--pillar-primary);\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n z-index: 10;\n pointer-events: none;\n}\n\n._pillar-chat-drop-overlay svg {\n width: 24px;\n height: 24px;\n}\n\n._pillar-chat-images-preview {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 12px 4px 12px;\n}\n\n._pillar-chat-image-thumb {\n position: relative;\n width: 56px;\n height: 56px;\n border-radius: var(--pillar-radius-md);\n overflow: hidden;\n border: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-image-thumb img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n._pillar-chat-image-loading {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-image-error {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(239, 68, 68, 0.3);\n color: #dc2626;\n font-weight: bold;\n font-size: 14px;\n}\n\n._pillar-chat-image-remove {\n position: absolute;\n top: 2px;\n right: 2px;\n width: 18px;\n height: 18px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n border: none;\n border-radius: 50%;\n color: white;\n cursor: pointer;\n opacity: 0;\n transition: opacity var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-thumb:hover ._pillar-chat-image-remove {\n opacity: 1;\n}\n\n._pillar-chat-image-remove svg {\n width: 10px;\n height: 10px;\n}\n\n._pillar-chat-image-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-btn:hover:not(:disabled) {\n color: var(--pillar-text);\n}\n\n._pillar-chat-image-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n._pillar-chat-image-btn svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-chat-images-preview {}\n.pillar-chat-image-thumb {}\n.pillar-chat-image-remove {}\n.pillar-chat-image-btn {}\n.pillar-chat-drop-overlay {}\n\n/* ============================================================================\n Legacy Class Mappings (for backward compatibility)\n Maps old BEM-style class names to new internal classes\n ============================================================================ */\n\n.pillar-panel { }\n.pillar-panel--right { }\n.pillar-panel--left { }\n.pillar-panel--open { }\n.pillar-panel--manual { }\n.pillar-panel-root { }\n.pillar-panel-ui { }\n.pillar-panel__header { }\n.pillar-panel__header-left { }\n.pillar-panel__back-btn { }\n.pillar-panel__home-btn { }\n.pillar-panel__title { }\n.pillar-panel__close-btn { }\n.pillar-panel__content { }\n.pillar-search { }\n.pillar-search__input { }\n.pillar-search__icon { }\n.pillar-category-card { }\n.pillar-category-card__icon { }\n.pillar-category-card__content { }\n.pillar-category-card__title { }\n.pillar-category-card__description { }\n.pillar-category-card__count { }\n.pillar-article-card { }\n.pillar-article-card__title { }\n.pillar-article-card__excerpt { }\n.pillar-article-card__meta { }\n.pillar-article { }\n.pillar-article__title { }\n.pillar-article__content { }\n.pillar-category-header { }\n.pillar-category-header__title { }\n.pillar-category-header__description { }\n.pillar-chat-input-container { }\n.pillar-chat-input-container--expanded { }\n.pillar-chat-input__messages { }\n.pillar-chat-input__message { }\n.pillar-chat-input__message--user { }\n.pillar-chat-input__message--assistant { }\n.pillar-chat-input__message-content { }\n.pillar-chat-input__sources { }\n.pillar-chat-input__sources-title { }\n.pillar-chat-input__source { }\n.pillar-chat-input__area { }\n.pillar-chat-input__wrapper { }\n.pillar-chat-input__input { }\n.pillar-chat-input__send-btn { }\n.pillar-loading { }\n.pillar-loading__spinner { }\n.pillar-empty { }\n.pillar-empty__icon { }\n.pillar-empty__title { }\n.pillar-empty__description { }\n.pillar-section-title { }\n.pillar-related-articles { }\n.pillar-home-view { }\n.pillar-chat-view { }\n.pillar-chat-view__messages { }\n.pillar-chat-view__welcome { }\n.pillar-chat-view__welcome-icon { }\n.pillar-chat-view__welcome-title { }\n.pillar-chat-view__welcome-text { }\n.pillar-chat-view__message { }\n.pillar-chat-view__message--user { }\n.pillar-chat-view__message--assistant { }\n.pillar-chat-view__user-bubble { }\n.pillar-chat-view__ai-response { }\n.pillar-chat-view__sources { }\n.pillar-chat-view__sources-title { }\n.pillar-chat-view__source { }\n.pillar-chat-view__input-area { }\n.pillar-chat-view__input-wrapper { }\n.pillar-chat-view__input { }\n.pillar-chat-view__send-btn { }\n.pillar-backdrop { }\n.pillar-backdrop--visible { }\n\n/* ============================================================================\n Task Button Component\n ============================================================================ */\n\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n\n/* ============================================================================\n Feedback Icons\n Internal: _pillar-feedback | Public: pillar-feedback\n ============================================================================ */\n\n._pillar-message-assistant-wrapper {\n position: relative;\n}\n\n._pillar-feedback-icons {\n display: flex;\n gap: 4px;\n margin-top: var(--pillar-spacing-sm);\n justify-content: flex-end;\n}\n\n._pillar-feedback-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n color: var(--pillar-text-placeholder);\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-feedback-btn:hover {\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-border);\n}\n\n._pillar-feedback-btn--active {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-color: var(--pillar-primary);\n}\n\n._pillar-feedback-btn--active:hover {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-feedback-btn svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-feedback-icons {}\n.pillar-feedback-btn {}\n.pillar-message-assistant-wrapper {}\n\n/* ============================================================================\n Action Status Indicators\n Internal: _pillar-action-status | Public: pillar-action-status\n Shows completion status for auto-run actions (checkmark, X, or spinner)\n ============================================================================ */\n\n._pillar-message-assistant-content {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n}\n\n._pillar-action-status {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n flex-shrink: 0;\n margin-top: 2px;\n}\n\n._pillar-action-status-indicator {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n}\n\n._pillar-action-status-indicator svg {\n width: 16px;\n height: 16px;\n}\n\n._pillar-action-status-indicator--success {\n color: #22c55e;\n}\n\n._pillar-action-status-indicator--failed {\n color: #ef4444;\n}\n\n._pillar-action-status-indicator--pending {\n color: var(--pillar-text-muted);\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.pillar-action-status {}\n.pillar-action-status-indicator {}\n.pillar-message-assistant-content {}\n\n/* ============================================================================\n Context Tags\n Internal: _pillar-context-tag | Public: pillar-context-tag\n Removable chips for user context items (highlighted text, etc.)\n ============================================================================ */\n\n._pillar-context-tag-list {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n padding: 8px 14px 0;\n}\n\n._pillar-context-tag {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 200px;\n padding: 4px 6px 4px 8px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-secondary);\n background: var(--pillar-bg-tertiary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: default;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag:hover {\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-context-tag-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n color: var(--pillar-primary);\n}\n\n._pillar-context-tag-icon svg {\n width: 12px;\n height: 12px;\n}\n\n._pillar-context-tag-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n line-height: 1.3;\n}\n\n._pillar-context-tag-remove {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n padding: 0;\n margin-left: 2px;\n color: var(--pillar-text-placeholder);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-sm);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag-remove:hover {\n color: var(--pillar-text);\n background: var(--pillar-border);\n}\n\n._pillar-context-tag-remove svg {\n width: 12px;\n height: 12px;\n}\n\n.pillar-context-tag-list {}\n.pillar-context-tag {}\n.pillar-context-tag-icon {}\n.pillar-context-tag-label {}\n.pillar-context-tag-remove {}\n\n/* Context tags inside user message bubbles need inverted colors */\n._pillar-message-user ._pillar-context-tag-list {\n padding: 0 0 8px 0;\n}\n\n._pillar-message-user ._pillar-context-tag {\n background: rgba(255, 255, 255, 0.2);\n border-color: rgba(255, 255, 255, 0.3);\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag:hover {\n background: rgba(255, 255, 255, 0.3);\n border-color: rgba(255, 255, 255, 0.4);\n}\n\n._pillar-message-user ._pillar-context-tag-icon {\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag-label {\n color: #ffffff;\n}\n\n/* ============================================================================\n Unified Chat Input\n Internal: _pillar-unified-input | Public: pillar-unified-input\n Reusable input component with context tag support\n ============================================================================ */\n\n._pillar-unified-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-unified-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-unified-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-unified-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-unified-input:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n._pillar-unified-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-unified-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: #ffffff;\n background: var(--pillar-primary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-unified-send-btn:hover:not(:disabled) {\n background: var(--pillar-primary-hover);\n}\n\n._pillar-unified-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-unified-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-unified-input-wrapper {}\n.pillar-unified-input {}\n.pillar-unified-input-row {}\n.pillar-unified-send-btn {}\n",ti=qe(null),ri=qe([]);Fe(()=>null!==ti.value),Fe(()=>ti.value&&ti.value.steps[ti.value.current_step]||null);const ii=Fe(()=>ti.value?ti.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);function ai(e,n){if(!ti.value)return;const t=ti.value.steps.map((t,r)=>r===e?{...t,status:n}:t);ti.value={...ti.value,steps:t}}function li(){if(!ti.value)return null;const e=ti.value.current_step+1;if(e>=ti.value.steps.length)return null;const n=ti.value.steps[e].auto_run?"active":"awaiting_initiation",t=ti.value.steps.map((t,r)=>r===e?{...t,status:n}:t);return ti.value={...ti.value,steps:t,current_step:e},ti.value.steps[e]}function oi(){if(!ti.value)return null;const e=ti.value;return ri.value=[...ri.value,e],ti.value=null,e}Fe(()=>ti.value?ii.value/ti.value.total_steps:0);const si="\n/* Workflow Checklist Container */\n.pillar-workflow {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin: 12px 0;\n}\n\n/* Header */\n.pillar-workflow__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.pillar-workflow__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #6b7280;\n}\n\n.pillar-workflow__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: #1a1a1a;\n}\n\n.pillar-workflow__progress {\n font-size: 12px;\n font-weight: 500;\n color: #6b7280;\n padding: 2px 8px;\n background: #e5e7eb;\n border-radius: 10px;\n}\n\n.pillar-workflow__description {\n font-size: 13px;\n color: #6b7280;\n}\n\n/* Steps List */\n.pillar-workflow__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Individual Step */\n.pillar-workflow-step {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n background: #ffffff;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-workflow-step__content {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.pillar-workflow-step__label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n}\n\n.pillar-workflow-step__note {\n font-size: 12px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__status-text {\n font-size: 12px;\n color: #2563eb;\n font-style: italic;\n}\n\n.pillar-workflow-step__actions {\n display: flex;\n gap: 8px;\n margin-top: 4px;\n}\n\n/* Step States */\n.pillar-workflow-step--pending {\n opacity: 0.6;\n}\n\n.pillar-workflow-step--awaiting_initiation {\n background: #fef3c7;\n border-color: #fcd34d;\n}\n\n.pillar-workflow-step--awaiting_initiation .pillar-workflow-step__icon {\n color: #d97706;\n}\n\n.pillar-workflow-step--active {\n background: #eff6ff;\n border-color: #93c5fd;\n}\n\n.pillar-workflow-step--active .pillar-workflow-step__icon {\n color: #2563eb;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__icon {\n color: #059669;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #6b7280;\n}\n\n.pillar-workflow-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__icon {\n color: #9ca3af;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #9ca3af;\n}\n\n.pillar-workflow-step--failed {\n background: #fef2f2;\n border-color: #fca5a5;\n}\n\n.pillar-workflow-step--failed .pillar-workflow-step__icon {\n color: #dc2626;\n}\n\n/* Start Button */\n.pillar-workflow-step__start-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: #2563eb;\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__start-btn:hover {\n background: #1d4ed8;\n}\n\n/* Skip Button */\n.pillar-workflow-step__skip-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #6b7280;\n border: 1px solid #d1d5db;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__skip-btn:hover {\n background: #f3f4f6;\n color: #374151;\n}\n\n/* Spinner Animation for Active Step */\n@keyframes pillar-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n.pillar-workflow-step__spinner {\n animation: pillar-spin 1s linear infinite;\n}\n\n/* Footer */\n.pillar-workflow__footer {\n display: flex;\n justify-content: flex-end;\n padding-top: 8px;\n border-top: 1px solid #e5e7eb;\n}\n\n.pillar-workflow__cancel-btn {\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #9ca3af;\n border: none;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow__cancel-btn:hover {\n color: #dc2626;\n}\n";class pi{constructor(e,n,t,r){this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,this.unsubscribe=null,this.isManualMount=!1,this.themeObserver=null,this.handleKeyDown=e=>{"Escape"===e.key&&en.value&&un()},this.config=e,this.api=n,this.events=t,this.rootContainer=r||null,this.isManualMount="manual"===e.panel.container}detectThemeFromDOM(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}get isOpen(){return en.value}async init(){var e,n,t;e=this.config.panel.position,tn.value=e,(e=>{rn.value=e})(this.config.panel.mode),(e=>{an.value=e})(this.config.panel.width),n=this.config.panel.hoverBreakpoint,ln.value=n,t=this.config.panel.hoverBackdrop,on.value=t,(()=>{if("undefined"==typeof window)return;pn?.();const e=()=>{sn.value=window.innerWidth};sn.value=window.innerWidth,window.addEventListener("resize",e),pn=()=>{window.removeEventListener("resize",e)}})(),this.createHost(),this.isManualMount||this.createBackdrop(),this.createPanel(),this.renderPreact(),this.bindEvents(),this.subscribeToState()}open(e){if(en.value)return e?.view&&Vn(e.view),void(e?.focusInput&&qn());en.value=!0,"overlay"===dn.value&&(document.body.style.overflow="hidden"),e?.view&&Vn(e.view),e?.focusInput?qn():this.setupFocusTrap()}close(){en.value&&un()}navigate(e,n){en.value?Vn(e,n):this.open({view:e})}destroy(){this.close(),this.isManualMount||this.removePushModeStyles(),this.unsubscribe?.(),this.unsubscribe=null,pn?.(),pn=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.renderRoot&&Y(null,this.renderRoot),this.backdrop?.remove(),this.host?.remove(),document.getElementById("pillar-sdk-styles")?.remove(),document.getElementById("pillar-sdk-theme")?.remove(),document.getElementById("pillar-sdk-custom")?.remove(),this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,document.removeEventListener("keydown",this.handleKeyDown),hn(),Qn(),On()}subscribeToState(){if(this.isManualMount)return void(this.unsubscribe=en.subscribe(e=>{e||this.events.emit("panel:close")}));let e=en.value,n=dn.value;const t=()=>{const e=en.value,n="push"===dn.value,t=an.value,r=tn.value,i=cn.value&&on.value;e?(n?(this.applyPushModeStyles(t,r),this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")):(this.removePushModeStyles(),i?this.backdrop?.classList.add("_pillar-backdrop--visible","pillar-backdrop--visible"):this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")),this.panelElement?.classList.add("_pillar-panel--open","pillar-panel--open")):(this.removePushModeStyles(),this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible"),this.panelElement?.classList.remove("_pillar-panel--open","pillar-panel--open"))},r=en.subscribe(n=>{n!==e&&(e=n,t(),n||(setTimeout(()=>{en.value||(Qn(),On())},300),this.events.emit("panel:close")))}),i=dn.subscribe(e=>{e!==n&&(n=e,t())});this.unsubscribe=()=>{r(),i()}}applyPushModeStyles(e,n){document.documentElement.style.transition="padding 0.3s ease","right"===n?document.documentElement.style.paddingRight=`${e}px`:document.documentElement.style.paddingLeft=`${e}px`}removePushModeStyles(){document.documentElement.style.paddingLeft="",document.documentElement.style.paddingRight="",setTimeout(()=>{en.value||(document.documentElement.style.transition="")},300)}get renderContainer(){return this.shadow||this.host}transformStylesForRegularDOM(e){return e.replace(/:host\(([^)]+)\)/g,"[data-pillar-panel]$1").replace(/:host-context\(([^)]+)\)/g,"$1 [data-pillar-panel]").replace(/:host:not\(([^)]+)\)/g,"[data-pillar-panel]:not($1)").replace(/:host/g,"[data-pillar-panel]")}injectStylesIntoHead(){const e="pillar-sdk-styles";if(document.getElementById(e))return;const n=ni+Xr+si+nt+kt+ct+lt,t=this.transformStylesForRegularDOM(n),r=document.createElement("style");r.id=e,r.textContent=t,document.head.appendChild(r);const i=ei(this.config.theme);if(i){const e=document.createElement("style");e.id="pillar-sdk-theme",e.textContent=this.transformStylesForRegularDOM(i),document.head.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.id="pillar-sdk-custom",e.textContent=this.transformStylesForRegularDOM(this.config.customCSS),document.head.appendChild(e)}}injectStylesIntoShadow(){if(!this.shadow)return;const e=document.createElement("style");e.textContent=ni+Xr+si+nt+kt+ct+lt,this.shadow.appendChild(e);const n=ei(this.config.theme);if(n){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme",""),this.shadow.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.textContent=this.config.customCSS,e.setAttribute("data-pillar-custom",""),this.shadow.appendChild(e)}}createHost(){this.host=document.createElement("div"),this.host.className="pillar-panel-host",this.host.setAttribute("data-pillar-panel",""),this.config.panel.useShadowDOM?(this.shadow=this.host.attachShadow({mode:"open"}),this.injectStylesIntoShadow()):(this.shadow=null,this.injectStylesIntoHead()),this.applyThemeMode(),this.setupThemeObserver();const e=this.config.panel.container;if("manual"===e)return;const n=this.rootContainer||document.body;let t=null;"string"==typeof e?(t=document.querySelector(e),t||(console.warn(`[Pillar] Container element not found: ${e}, falling back to root container`),t=n)):t=e instanceof HTMLElement?e:n,t.appendChild(this.host)}mountTo(e){this.host?(this.host.parentElement&&this.host.parentElement.removeChild(this.host),e.appendChild(this.host)):console.warn("[Pillar] Panel host not created yet")}getHostElement(){return this.host}createBackdrop(){this.backdrop=document.createElement("div"),this.backdrop.className="_pillar-backdrop pillar-backdrop",this.backdrop.style.cssText="\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.3s ease, visibility 0.3s ease;\n z-index: 99998;\n ",this.backdrop.addEventListener("click",()=>{un()}),document.body.appendChild(this.backdrop)}createPanel(){const e=this.renderContainer;if(!e)return;this.panelElement=document.createElement("div");const n=this.isManualMount?" _pillar-panel--manual pillar-panel--manual":"",t=`_pillar-panel--${tn.value} pillar-panel--${tn.value}`;this.panelElement.className=`_pillar-panel pillar-panel ${t}${n}`,this.panelElement.style.setProperty("--pillar-panel-width",`${an.value}px`),this.panelElement.setAttribute("role","dialog"),this.panelElement.setAttribute("aria-modal","true"),this.panelElement.setAttribute("aria-label","Assistant panel"),this.renderRoot=document.createElement("div"),this.renderRoot.className="_pillar-panel-root pillar-panel-root",this.panelElement.appendChild(this.renderRoot),e.appendChild(this.panelElement)}renderPreact(){this.renderRoot&&Y(ne(rt,{api:this.api,events:this.events,children:ne(Jr,{})}),this.renderRoot)}bindEvents(){document.addEventListener("keydown",this.handleKeyDown)}setupFocusTrap(){setTimeout(()=>{const e=this.renderContainer,n=e?.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');n?.focus()},100)}applyThemeMode(){if(!this.host)return;const e=this.config.theme.mode;if("light"===e||"dark"===e)this.host.setAttribute("data-theme",e);else{const e=this.detectThemeFromDOM();this.host.setAttribute("data-theme",e)}}setupThemeObserver(){"auto"===this.config.theme.mode&&(this.themeObserver=new MutationObserver(()=>{this.applyThemeMode()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}))}setTheme(e){this.config={...this.config,theme:{...this.config.theme,...e,colors:{...this.config.theme.colors,...e.colors},darkColors:{...this.config.theme.darkColors,...e.darkColors}}},this.applyThemeMode();const n=ei(this.config.theme);if(this.shadow){const e=this.shadow.querySelector("style[data-pillar-theme]");if(e&&n)e.textContent=n;else if(n&&!e){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme","");const t=this.shadow.querySelector("style");t?.nextSibling?this.shadow.insertBefore(e,t.nextSibling):this.shadow.appendChild(e)}}else{const e=this.transformStylesForRegularDOM(n),t=document.getElementById("pillar-sdk-theme");if(t&&e)t.textContent=e;else if(e&&!t){const n=document.createElement("style");n.id="pillar-sdk-theme",n.textContent=e,document.head.appendChild(n)}}}}function ci({label:e,x:n,y:t,isVisible:r,onClick:i}){const a=me(null),[l,o]=_e({x:n,y:t}),[s,p]=_e(!1),c=xe(()=>{if(!a.current||!r)return;const e=a.current.getBoundingClientRect(),i=window.innerWidth;let l=n,s=t,c=!1;l=n-e.width/2,l<10?l=10:l+e.width>i-10&&(l=i-e.width-10),s=t-e.height-10,s<10&&(s=t+10,c=!0),o({x:l,y:s}),p(c)},[n,t,r]);ve(()=>{r&&requestAnimationFrame(c)},[r,c,n,t]);return ne("div",{ref:a,class:`pillar-text-selection-popover${r?" pillar-text-selection-popover--visible":""}${s?" pillar-text-selection-popover--below":""}`,style:{left:`${l.x}px`,top:`${l.y}px`},onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())},children:[ne("div",{class:"pillar-text-selection-popover__content",children:[ne("span",{class:"pillar-text-selection-popover__icon",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 2a1 1 0 011 1v1.323l3.954 1.582 1.599-.8a1 1 0 01.894 1.79l-1.233.616 1.738 5.42a1 1 0 01-.285 1.05A3.989 3.989 0 0115 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.715-5.349L10 6.477l-3.763 1.105 1.715 5.349a1 1 0 01-.285 1.05A3.989 3.989 0 015 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.738-5.42-1.233-.617a1 1 0 01.894-1.788l1.599.799L9 4.323V3a1 1 0 011-1z"/></svg>'}}),ne("span",{children:e})]}),ne("div",{class:"pillar-text-selection-popover__arrow"})]})}const di="pillar-text-selection-styles";class ui{constructor(e,n,t){this.container=null,this.isVisible=!1,this.currentSelection="",this.stylesInjected=!1,this.handleMouseUp=e=>{setTimeout(()=>{this.checkSelection(e)},10)},this.handleMouseDown=e=>{e.target.closest(".pillar-text-selection-popover")||this.hidePopover()},this.handleKeyDown=e=>{"Escape"===e.key&&this.hidePopover()},this.handleScroll=()=>{this.isVisible&&this.hidePopover()},this.handlePopoverClick=()=>{this.currentSelection&&(this.events.emit("textSelection:click",{text:this.currentSelection}),(e=>{const n={...e,id:`ctx_${Date.now()}_${Math.random().toString(36).substring(2,9)}`};zn.value=[...zn.value,n]})({type:"highlighted_text",url_origin:window.location.href,text_content:this.currentSelection}),this.hidePopover(),window.getSelection()?.removeAllRanges(),this.openPanel())},this.config=e,this.events=n,this.openPanel=t}init(){this.stylesInjected||(gn(document,"\n/* Pillar Text Selection Popover Styles */\n.pillar-text-selection-popover {\n position: absolute;\n z-index: 99999;\n padding: 6px 12px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 13px;\n font-weight: 500;\n line-height: 1;\n color: #ffffff;\n background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);\n pointer-events: auto;\n opacity: 0;\n transform: translateY(4px) scale(0.95);\n transition: opacity 0.15s ease, transform 0.15s ease;\n cursor: pointer;\n user-select: none;\n}\n\n.pillar-text-selection-popover.pillar-text-selection-popover--visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n}\n\n.pillar-text-selection-popover:hover {\n background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);\n box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);\n}\n\n.pillar-text-selection-popover:active {\n transform: translateY(0) scale(0.98);\n}\n\n.pillar-text-selection-popover__content {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.pillar-text-selection-popover__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n}\n\n.pillar-text-selection-popover__icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Arrow pointing down to selection */\n.pillar-text-selection-popover__arrow {\n position: absolute;\n bottom: -5px;\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n width: 10px;\n height: 10px;\n background: linear-gradient(135deg, #8b5cf6 0%, #8b5cf6 100%);\n}\n\n.pillar-text-selection-popover--below .pillar-text-selection-popover__arrow {\n bottom: auto;\n top: -5px;\n background: linear-gradient(135deg, #6366f1 0%, #6366f1 100%);\n}\n",di),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-text-selection-container",document.body.appendChild(this.container),this.bindEvents()}destroy(){this.unbindEvents(),this.container&&(Y(null,this.container),this.container.remove(),this.container=null),document.getElementById(di)?.remove(),this.stylesInjected=!1,this.isVisible=!1,this.currentSelection=""}bindEvents(){document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("scroll",this.handleScroll,!0)}unbindEvents(){document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("scroll",this.handleScroll,!0)}checkSelection(e){const n=window.getSelection();if(!n||n.isCollapsed)return;const t=n.toString().trim();if(t.length<3)return;const r=n.getRangeAt(0),i=r.commonAncestorContainer,a=i instanceof Element?i:i.parentElement;if(a?.closest("[data-pillar-panel]")||a?.closest(".pillar-panel-host"))return;const l=r.getBoundingClientRect(),o=l.left+l.width/2,s=l.top+window.scrollY;this.currentSelection=t,this.showPopover(o,s)}showPopover(e,n){this.container&&(this.isVisible=!0,Y(ne(ci,{label:this.config.textSelection.label,x:e,y:n,isVisible:!0,onClick:this.handlePopoverClick}),this.container),this.events.emit("textSelection:shown",{text:this.currentSelection}))}hidePopover(){this.container&&this.isVisible&&(this.isVisible=!1,Y(ne(ci,{label:this.config.textSelection.label,x:0,y:0,isVisible:!1,onClick:()=>{}}),this.container))}}const hi={recentActions:[]},gi={},fi=qe({...hi}),_i=qe({...gi});Fe(()=>{const e=fi.value;return!!(e.currentPage||e.currentFeature||e.userRole||e.errorState||e.recentActions&&e.recentActions.length>0)}),Fe(()=>!!fi.value.errorState);const vi="pillar-";const mi=[{id:"assistant",label:"Assistant",enabled:!0,order:0}],bi="https://api.trypillar.com",xi={enabled:!0,position:"right",mode:"push",width:380,useShadowDOM:!1,hoverBreakpoint:1200,hoverBackdrop:!0},ki={enabled:!0},yi={enabled:!0,prefix:"pillar-",clearAfterOpen:!0},wi={enabled:!0,label:"Ask AI"},Si={mode:"auto"};function Ci(e){if(!e||0===e.length)return mi;const n=new Map;for(const e of mi)n.set(e.id,{...e});for(const t of e)n.set(t.id,{...t});const t=n.get("assistant");return t&&(t.enabled=!0),Array.from(n.values()).sort((e,n)=>e.order-n.order)}function Pi(e){return{helpCenter:e.helpCenter,publicKey:e.publicKey,apiBaseUrl:e.apiBaseUrl||bi,platform:e.platform||"web",version:e.version,panel:{...xi,...e.panel},edgeTrigger:{...ki,...e.edgeTrigger},urlParams:{...yi,...e.urlParams},textSelection:{...wi,...e.textSelection},sidebarTabs:Ci(e.sidebarTabs),theme:{mode:e.theme?.mode??Si.mode,colors:{...e.theme?.colors},darkColors:{...e.theme?.darkColors}},customCSS:e.customCSS,context:e.context||{},onReady:e.onReady,onError:e.onError}}class $i{constructor(){this.listeners=new Map}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.off(e,n)}}off(e,n){const t=this.listeners.get(e);t&&t.delete(n)}emit(e,n){const t=this.listeners.get(e);t&&t.forEach(t=>{try{t(n)}catch(n){console.error(`[Pillar] Error in event handler for "${e}":`,n)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}function Ti(e){if(e)try{const n=Ei(e);localStorage.removeItem(n),console.log("[PlanPersistence] Cleared saved plan")}catch(e){console.warn("[PlanPersistence] Failed to clear plan:",e)}}function Ei(e){return`pillar:active_plan:${e}`}class zi{constructor(e,n,t){this.mcpClient=e,this.events=n,this.siteId=t}async handlePlanReceived(e){console.log(`[PlanExecutor] Received plan: ${e.id}, auto_execute=${e.auto_execute}, status=${e.status}`),ft(e),this.persistPlan(e),e.auto_execute&&"executing"===e.status&&(this.events.emit("plan:start",e),await this.executeNextStep())}async recoverPlan(){const e=function(e){if(!e)return null;try{const n=Ei(e),t=localStorage.getItem(n);if(!t)return null;const r=JSON.parse(t);if(1!==r.version)return console.warn("[PlanPersistence] Stored plan has incompatible version, clearing"),Ti(e),null;if(r.siteId!==e)return console.warn("[PlanPersistence] Stored plan is for different site, clearing"),Ti(e),null;const i=new Date(r.storedAt),a=new Date,l=r.plan.timeout_minutes||30,o=(a.getTime()-i.getTime())/6e4;return o>l?(console.warn(`[PlanPersistence] Stored plan has timed out (${Math.round(o)} minutes old, timeout: ${l} minutes)`),Ti(e),null):(console.log(`[PlanPersistence] Loaded plan ${r.plan.id} from localStorage`),r.plan)}catch(n){return console.warn("[PlanPersistence] Failed to load plan:",n),Ti(e),null}}(this.siteId);if(!e)return console.log("[PlanExecutor] No saved plan found"),null;console.log(`[PlanExecutor] Found saved plan ${e.id}, fetching latest state from server`);try{const n=(await this.mcpClient.getPlan(e.id)).plan;return["planning","ready","executing","awaiting_start","awaiting_input","awaiting_result"].includes(n.status)?(ft(n),this.events.emit("plan:updated",n),console.log(`[PlanExecutor] Recovered plan ${n.id} with status ${n.status}`),"executing"===n.status&&await this.executeNextStep(),n):(console.log(`[PlanExecutor] Plan ${n.id} is no longer active (status: ${n.status}), clearing`),Ti(this.siteId),null)}catch(e){return console.error("[PlanExecutor] Failed to recover plan from server:",e),Ti(this.siteId),null}}persistPlan(e){!function(e,n){if(!e||!n)return;if(["planning","ready","executing","awaiting_start","awaiting_input","awaiting_result"].includes(e.status))try{const t={version:1,plan:e,siteId:n,storedAt:(new Date).toISOString()},r=Ei(n);localStorage.setItem(r,JSON.stringify(t)),console.log(`[PlanPersistence] Saved plan ${e.id} to localStorage`)}catch(e){console.warn("[PlanPersistence] Failed to save plan:",e)}else Ti(n)}(e,this.siteId)}async startPlan(){const e=dt.value;if(e)if("awaiting_start"===e.status)try{const n=await this.mcpClient.startPlan(e.id);_t(n.plan),this.events.emit("plan:start",n.plan),await this.executeNextStep()}catch(n){console.error("[PlanExecutor] Failed to start plan:",n),this.events.emit("plan:error",{plan:e,error:n instanceof Error?n:new Error(String(n))})}else console.warn(`[PlanExecutor] Plan ${e.id} is not in awaiting_start status`);else console.warn("[PlanExecutor] No active plan to start")}async executeNextStep(){const e=dt.value;if(!e)return;let n=e.steps.find(e=>"ready"===e.status);if(n||(n=e.steps.find(e=>"awaiting_confirmation"===e.status&&e.requires_user_confirmation)),!n){const n=e.steps.every(e=>"completed"===e.status||"skipped"===e.status||"failed"===e.status);return void(n&&(console.log(`[PlanExecutor] Plan ${e.id} complete`),this.events.emit("plan:complete",e),mt(),Ti(this.siteId)))}if(n.requires_user_confirmation&&"awaiting_confirmation"!==n.status)return vt(n.id,{status:"awaiting_confirmation"}),void this.events.emit("plan:step:confirm",{plan:dt.value,step:n});"awaiting_confirmation"!==n.status&&await this.executeStep(n)}async confirmStep(e,n){const t=dt.value;if(!t)return;const r=t.steps.find(n=>n.id===e);if(!r)return void console.warn(`[PlanExecutor] Step ${e} not found`);n&&vt(e,{action_data:{...r.action_data,...n}});const i=dt.value,a=i?.steps.find(n=>n.id===e);a&&await this.executeStep(a)}async skipStep(e){const n=dt.value;if(!n)return;const t=n.steps.find(n=>n.id===e);if(t)try{const r=await this.mcpClient.skipStep(n.id,e);_t(r.plan),this.events.emit("plan:step:skip",{plan:r.plan,step:t}),await this.executeNextStep()}catch(n){console.error("[PlanExecutor] Failed to skip step:",n),vt(e,{status:"skipped"}),this.events.emit("plan:step:skip",{plan:dt.value,step:t}),await this.executeNextStep()}else console.warn(`[PlanExecutor] Step ${e} not found`)}async retryStep(e){const n=dt.value;if(!n)return;const t=n.steps.find(n=>n.id===e);if(t)if(t.is_retriable)if(t.retry_count>=t.max_retries)console.warn(`[PlanExecutor] Step ${e} has exceeded max retries (${t.retry_count}/${t.max_retries})`);else try{const r=await this.mcpClient.retryStep(n.id,e);_t(r.plan);const i=r.plan.steps.find(n=>n.id===e);this.events.emit("plan:step:retry",{plan:r.plan,step:i||t,retryCount:i?.retry_count||t.retry_count+1}),await this.executeNextStep()}catch(e){console.error("[PlanExecutor] Failed to retry step:",e),this.events.emit("plan:error",{plan:dt.value,error:e instanceof Error?e:new Error(String(e))})}else console.warn(`[PlanExecutor] Step ${e} is not retriable`);else console.warn(`[PlanExecutor] Step ${e} not found`)}async cancel(){const e=dt.value;if(e)try{const n=await this.mcpClient.cancelPlan(e.id);_t(n.plan),this.events.emit("plan:cancel",n.plan),mt(!0),Ti(this.siteId)}catch(n){console.error("[PlanExecutor] Failed to cancel plan:",n),this.events.emit("plan:cancel",e),mt(!0),Ti(this.siteId)}else console.warn("[PlanExecutor] No active plan to cancel")}async completeStepByAction(e,n=!0,t){const r=dt.value;if(!r)return void console.warn("[PlanExecutor] No active plan");const i=r.steps.find(n=>n.action_name===e&&"awaiting_result"===n.status);i?(console.log(`[PlanExecutor] Completing step ${i.index} (${e}) via callback`),n?await this.markStepComplete(i.id,t):(vt(i.id,{status:"failed",result:{error:"Action failed by host app"}}),this.events.emit("plan:step:failed",{plan:dt.value,step:dt.value.steps.find(e=>e.id===i.id),error:new Error("Action failed by host app"),canRetry:i.is_retriable}))):console.warn(`[PlanExecutor] No awaiting step found for action: ${e}`)}async markStepDone(e){const n=dt.value;if(!n)return void console.warn("[PlanExecutor] No active plan");const t=n.steps.find(n=>n.id===e);t?"awaiting_result"===t.status?(console.log(`[PlanExecutor] Marking step ${t.index} as done via UI button`),await this.markStepComplete(e)):console.warn(`[PlanExecutor] Step ${e} is not awaiting result (status: ${t.status})`):console.warn(`[PlanExecutor] Step ${e} not found`)}async markStepComplete(e,n){vt(e,{status:"completed",result:n});const t=dt.value,r=t.steps.find(n=>n.id===e);this.events.emit("plan:step:complete",{plan:t,step:r,success:!0}),await this.executeNextStep()}async executeStep(e){const n=dt.value;if(n){console.log(`[PlanExecutor] Executing step ${e.index}: ${e.action_name}`),vt(e.id,{status:"executing"}),this.events.emit("plan:step:active",{plan:dt.value,step:e});try{const t=l(e.action_name)?a(e.action_name):void 0,r=t?.handler;let i;if(r){if(i=await r(e.action_data),t?.returns&&void 0!==i){const{default:n}=await Promise.resolve().then(function(){return Ii}),t=n.getInstance();t&&t.sendActionResult(e.action_name,i)}}else{const{default:n}=await Promise.resolve().then(function(){return Ii}),t=n.getInstance();if(!t)throw new Error(`No handler for action: ${e.action_name} (Pillar not initialized)`);{const n=e.action_type,r=e.action_data?.path,a=e.action_data?.url;console.log(`[PlanExecutor] Executing via Pillar.executeTask: ${e.action_name}`),t.executeTask({id:e.id,name:e.action_name,taskType:n,path:r,externalUrl:a,data:e.action_data||{}}),i={executed:!0,action:e.action_name}}}if(e.requires_result_feedback){console.log(`[PlanExecutor] Sending step ${e.index} result to server`);const t=await this.mcpClient.continuePlan(n.id,e.id,i);_t(t.plan),this.events.emit("plan:updated",t.plan)}else if(e.auto_complete){vt(e.id,{status:"completed",result:i});const n=dt.value,t=n?.steps.find(n=>n.id===e.id);this.events.emit("plan:step:complete",{plan:n,step:t||e,success:!0}),await this.executeNextStep()}else console.log(`[PlanExecutor] Step ${e.index} awaiting callback (auto_complete=false)`),vt(e.id,{status:"awaiting_result",result:i}),this.events.emit("plan:step:active",{plan:dt.value,step:e})}catch(t){console.error(`[PlanExecutor] Step ${e.index} failed:`,t);const r=t instanceof Error?t.message:"Unknown error";try{_t((await this.mcpClient.failStep(n.id,e.id,r)).plan)}catch(n){console.error("[PlanExecutor] Failed to notify server of step failure:",n),vt(e.id,{status:"failed",error_message:r})}const i=dt.value,a=i?.steps.find(n=>n.id===e.id),l=a?a.is_retriable&&a.retry_count<a.max_retries:e.is_retriable&&e.retry_count<e.max_retries;this.events.emit("plan:step:failed",{plan:i,step:a||e,error:t instanceof Error?t:new Error(String(t)),canRetry:l}),this.events.emit("plan:step:complete",{plan:i,step:a||e,success:!1}),l||this.events.emit("plan:error",{plan:i,error:t instanceof Error?t:new Error(String(t))})}}}getActivePlan(){return dt.value}}class Ai{constructor(){this._state="uninitialized",this._config=null,this._api=null,this._mcpClient=null,this._planExecutor=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._initPromise=null,this._rootContainer=null,this._unsubscribeHoverMode=null,this._productContext={...hi},this._userProfile={...gi},this._taskHandlers=new Map,this._anyTaskHandler=null,this._cardRenderers=new Map,this._events=new $i}_createRootContainer(){let e=document.getElementById("pillar-root");if(e)return this._subscribeToHoverModeForRoot(e),e;e=document.createElement("div"),e.id="pillar-root";const n=cn.value?"20":"-1";return e.style.cssText=`isolation: isolate; z-index: ${n}; position: relative;`,document.body.appendChild(e),this._subscribeToHoverModeForRoot(e),e}_subscribeToHoverModeForRoot(e){this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=cn.subscribe(n=>{e.style.zIndex=n?"20":"-1"})}static async init(e){if(!e.helpCenter||!e.publicKey)throw new Error("[Pillar] helpCenter and publicKey are required");return Ai.instance||(Ai.instance=new Ai),await Ai.instance._init(e),Ai.instance}static getInstance(){return Ai.instance}static destroy(){Ai.instance&&(Ai.instance._destroy(),Ai.instance=null)}get state(){return this._state}get isReady(){return"ready"===this._state}get isPanelOpen(){return en.value}get config(){return this._config}on(e,n){return this._events.on(e,n)}open(e){this._panel&&(this._panel.open(e),this._events.emit("panel:open"))}close(){this._panel&&(this._panel.close(),this._events.emit("panel:close"))}toggle(){this.isPanelOpen?this.close():this.open()}navigate(e,n){this._panel?.navigate(e,n),this._events.emit("panel:navigate",{view:e,params:n})}setContext(e){this._config&&(this._config.context={...this._config.context,...e})}setTheme(e){this._config&&(this._config.theme={...this._config.theme,...e,mode:e.mode??this._config.theme.mode,colors:{...this._config.theme.colors,...e.colors},darkColors:{...this._config.theme.darkColors,...e.darkColors}},this._panel?.setTheme(this._config.theme),this._events.emit("theme:change",{theme:this._config.theme}))}setTextSelectionEnabled(e){if(!this._config)return;this._config.textSelection.enabled!==e&&(this._config.textSelection.enabled=e,e?this._config.panel.enabled&&!this._textSelectionManager&&(this._textSelectionManager=new ui(this._config,this._events,()=>this.open()),this._textSelectionManager.init()):this._textSelectionManager&&(this._textSelectionManager.destroy(),this._textSelectionManager=null),this._events.emit("textSelection:change",{enabled:e}))}mountPanelTo(e){this._panel?.mountTo(e)}getPanelHostElement(){return this._panel?.getHostElement()??null}get productContext(){return{...this._productContext}}get userProfile(){return{...this._userProfile}}setProductContext(e){this._productContext={...e,recentActions:e.recentActions||[]},(e=>{fi.value={...e,recentActions:e.recentActions||[]}})(this._productContext),this._events.emit("context:change",{context:this._productContext})}updateContext(e){this._productContext={...this._productContext,...e},(e=>{fi.value={...fi.value,...e}})(e),this._events.emit("context:change",{context:this._productContext})}setUserProfile(e){this._userProfile={...e},(e=>{_i.value={...e}})(this._userProfile),this._events.emit("profile:change",{profile:this._userProfile})}reportAction(e,n){const t=[...(this._productContext.recentActions||[]).slice(-9),e];this._productContext={...this._productContext,recentActions:t},(e=>{const n=fi.value.recentActions||[];fi.value={...fi.value,recentActions:[...n.slice(-9),e]}})(e),this._events.emit("action:report",{action:e,metadata:n})}clearErrorState(){if(this._productContext.errorState){const{errorState:e,...n}=this._productContext;this._productContext=n,(()=>{const{errorState:e,...n}=fi.value;fi.value=n})(),this._events.emit("context:change",{context:this._productContext})}}setErrorState(e,n){this._productContext={...this._productContext,errorState:{code:e,message:n}},((e,n)=>{fi.value={...fi.value,errorState:{code:e,message:n}}})(e,n),this._events.emit("context:change",{context:this._productContext})}async getSuggestions(){if(!this._api)return console.warn("[Pillar] SDK not initialized, cannot get suggestions"),[];try{return await this._api.getSuggestions(this._productContext,this._userProfile)}catch(e){return console.error("[Pillar] Failed to get suggestions:",e),[]}}getAssistantContext(){return{product:this._productContext,user:this._userProfile}}onTask(e,n){return this._taskHandlers.set(e,n),()=>this._taskHandlers.delete(e)}onAnyTask(e){return this._anyTaskHandler=e,()=>{this._anyTaskHandler=null}}offTask(e){this._taskHandlers.delete(e)}executeTask(e){const{name:n,data:t,taskType:r,path:i,externalUrl:o}=e;if(this._events.emit("task:execute",e),this._anyTaskHandler)try{this._anyTaskHandler(n,t)}catch(e){console.error("[Pillar] Error in onAnyTask handler:",e)}const s=l(n)?a(n):void 0,p=s?.handler,c=this._taskHandlers.get(n),d=r?this._taskHandlers.get(r):void 0,u=p||c||d;if(u)try{const e=u("navigate"===r&&i?{...t,path:i}:t);s?.returns&&void 0!==e&&Promise.resolve(e).then(e=>{void 0!==e&&this.sendActionResult(n,e)}).catch(e=>{console.error(`[Pillar] Error in query action "${n}":`,e)}),this._events.emit("task:complete",{name:n,success:!0,data:t})}catch(e){console.error(`[Pillar] Error executing task "${n}":`,e),this._events.emit("task:complete",{name:n,success:!1,data:t})}else switch(r){case"navigate":i&&"undefined"!=typeof window&&(console.warn("[Pillar] No 'navigate' handler registered. Using window.location.href as fallback."),window.location.href=i,this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"external_link":o&&"undefined"!=typeof window&&(window.open(o,"_blank","noopener,noreferrer"),this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"copy_text":t.text&&"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(String(t.text)).then(()=>{this._events.emit("task:complete",{name:n,success:!0,data:t})}).catch(()=>{this._events.emit("task:complete",{name:n,success:!1,data:t})});break;default:console.warn(`[Pillar] No handler registered for task "${n}". Register one with pillar.onTask('${n}', handler) or defineActions()`),this._events.emit("task:complete",{name:n,success:!1,data:{error:"No handler registered"}})}}completeTask(e,n=!0,t){this._events.emit("task:complete",{name:e,success:n,data:t})}confirmTaskExecution(e,n,t){e?this._api?this._api.confirmTaskExecution(e,n,t):console.warn("[Pillar] SDK not initialized, cannot confirm task execution"):console.warn("[Pillar] confirmTaskExecution called without taskId")}registerCard(e,n){return this._cardRenderers.set(e,n),()=>this._cardRenderers.delete(e)}getCardRenderer(e){return this._cardRenderers.get(e)}hasCardRenderer(e){return this._cardRenderers.has(e)}get workflow(){return ti.value}startWorkflow(e){!function(e){ti.value&&(ri.value=[...ri.value,ti.value]);const n=e.steps.map((e,n)=>0===n?{...e,status:e.auto_run?"active":"awaiting_initiation"}:{...e,status:"pending"});ti.value={...e,steps:n,current_step:0}}(e),this._events.emit("workflow:start",ti.value);const n=ti.value.steps[0];n.auto_run&&this._executeWorkflowStep(n)}initiateWorkflowStep(e){const n=ti.value;if(!n)return void console.warn("[Pillar] No active workflow");const t=e??n.current_step,r=n.steps[t];r?"awaiting_initiation"===r.status?this._executeWorkflowStep(r):console.warn(`[Pillar] Step ${t} is not awaiting initiation`):console.warn(`[Pillar] Invalid step index: ${t}`)}confirmWorkflowStep(e,n){const t=ti.value;if(!t)return;const r=n??t.current_step;if(t.steps[r],ai(r,e?"completed":"failed"),this._events.emit("workflow:step:complete",{workflow:ti.value,step:ti.value.steps[r],success:e}),!e)return;const i=li();if(!i)return this._events.emit("workflow:complete",ti.value),void oi();this._events.emit("workflow:step:active",{workflow:ti.value,step:i}),i.auto_run&&this._executeWorkflowStep(i)}skipWorkflowStep(e){const n=ti.value;if(!n)return;const t=e??n.current_step;n.steps[t],ai(t,"skipped"),this._events.emit("workflow:step:skip",{workflow:ti.value,step:ti.value.steps[t]});const r=li();if(!r)return this._events.emit("workflow:complete",ti.value),void oi();this._events.emit("workflow:step:active",{workflow:ti.value,step:r}),r.auto_run&&this._executeWorkflowStep(r)}cancelWorkflow(){const e=ti.value;e&&(this._events.emit("workflow:cancel",e),function(){if(!ti.value)return null;const e=ti.value;ti.value=null}())}_executeWorkflowStep(e){ai(e.index,"active"),this.executeTask({id:e.task_id,name:e.task_name,taskType:e.task_type,data:e.data,path:e.data?.path,externalUrl:e.data?.url}),e.auto_complete&&setTimeout(()=>{this.confirmWorkflowStep(!0,e.index)},100)}get activePlan(){return dt.value}handlePlanReceived(e){this._planExecutor?.handlePlanReceived(e)}async startPlan(){await(this._planExecutor?.startPlan())}async confirmPlanStep(e,n){await(this._planExecutor?.confirmStep(e,n))}async skipPlanStep(e){await(this._planExecutor?.skipStep(e))}async retryPlanStep(e){await(this._planExecutor?.retryStep(e))}async cancelPlan(){await(this._planExecutor?.cancel())}async completePlanStepByAction(e,n=!0,t){await(this._planExecutor?.completeStepByAction(e,n,t))}async markPlanStepDone(e){await(this._planExecutor?.markStepDone(e))}sendActionResult(e,n){this._mcpClient?(this._mcpClient.sendActionResult(e,n),this._events.emit("action:result",{actionName:e,result:n})):console.warn("[Pillar] SDK not initialized, cannot send action result")}async _init(e){if("initializing"===this._state&&this._initPromise)return console.log("[Pillar] Already initializing, waiting for completion"),void await this._initPromise;"ready"!==this._state?(this._state="initializing",this._initPromise=this._doInit(e),await this._initPromise):console.log("[Pillar] Already initialized")}async _doInit(e){try{await new Promise(e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e(),{once:!0}):e()});const n=Pi(e),r=new h(n),i=function(e,n){if(!n)return e;const t={...e};return n.panel&&(t.panel={...n.panel,...e.panel}),n.theme?.colors?.primary&&(t.theme={...t.theme,colors:{primary:e.theme?.colors?.primary??n.theme.colors.primary,...e.theme?.colors}}),t}(e,await r.fetchEmbedConfig().catch(e=>(console.warn("[Pillar] Failed to fetch server config, using local config only:",e),null)));this._config=Pi(i),this._config.platform&&this._config.version&&t(this._config.platform,this._config.version),this._api=new h(this._config),this._mcpClient=new d(this._config),this._planExecutor=new zi(this._mcpClient,this._events,this._config.helpCenter),this._rootContainer=this._createRootContainer(),this._config.panel.enabled&&(this._panel=new pi(this._config,this._api,this._events,this._rootContainer),await this._panel.init()),this._config.edgeTrigger.enabled&&(this._edgeTrigger=new mn(this._config,this._events,()=>this.toggle(),this._rootContainer),this._edgeTrigger.init()),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new ui(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),this._state="ready",this._events.emit("ready"),this._config.onReady?.(),console.log("[Pillar] SDK initialized successfully"),await(this._planExecutor?.recoverPlan()),this._config.urlParams.enabled&&await this._handleUrlParams()}catch(e){this._state="error";const n=e instanceof Error?e:new Error(String(e));throw this._events.emit("error",n),this._config?.onError?.(n),console.error("[Pillar] Failed to initialize:",e),e}}async _handleUrlParams(){if(!this._config)return;(function(e=vi){if("undefined"==typeof window||!window.location)return{};const n=new URLSearchParams(window.location.search),t={};n.has(`${e}open`)&&(t.open=!0);const r=n.get(`${e}article`);r&&(t.article=r);const i=n.get(`${e}article-id`);i&&!t.article&&(t.article=i);const a=n.get(`${e}category`);a&&(t.category=a);const l=n.get(`${e}search`);return l&&(t.search=l),t})(this._config.urlParams.prefix).open&&(this.open(),this._config.urlParams.clearAfterOpen&&function(e=vi){if("undefined"==typeof window||!window.location||!window.history)return;const n=new URL(window.location.href),t=[`${e}open`,`${e}article`,`${e}article-id`,`${e}category`,`${e}search`];let r=!1;for(const e of t)n.searchParams.has(e)&&(n.searchParams.delete(e),r=!0);r&&window.history.replaceState({},"",n.toString())}(this._config.urlParams.prefix))}_destroy(){this._textSelectionManager?.destroy(),this._panel?.destroy(),this._edgeTrigger?.destroy(),this._api?.cancelAllRequests(),this._events.removeAllListeners(),this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=null,this._rootContainer?.remove(),this._rootContainer=null,hn(),Qn(),On(),fi.value={...hi},_i.value={...gi},ti.value=null,ri.value=[],dt.value=null,ut.value=[],this._productContext={...hi},this._userProfile={...gi},this._taskHandlers.clear(),this._anyTaskHandler=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._api=null,this._mcpClient=null,this._planExecutor=null,this._config=null,this._state="uninitialized",console.log("[Pillar] SDK destroyed")}}Ai.instance=null;var Ii=Object.freeze({__proto__:null,Pillar:Ai,default:Ai});if("undefined"!=typeof window){window.Pillar=Ai;const e=()=>{const e=document.currentScript;if(e){const n=e.dataset.helpCenter,t=e.dataset.publicKey;n&&t&&Ai.init({helpCenter:n,publicKey:t}).catch(console.error)}};if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",e);else{const e=document.querySelectorAll("script[data-help-center][data-public-key]");if(e.length>0){const n=e[e.length-1],t=n.dataset.helpCenter,r=n.dataset.publicKey;t&&r&&Ai.init({helpCenter:t,publicKey:r}).catch(console.error)}}}export{h as APIClient,mi as DEFAULT_SIDEBAR_TABS,$i as EventEmitter,Ai as Pillar,p as clearRegistry,Ai as default,n as defineActions,c as getActionCount,a as getActionDefinition,o as getActionNames,r as getClientInfo,i as getHandler,s as getManifest,l as hasAction,t as setClientInfo};
2
2
  //# sourceMappingURL=pillar.esm.js.map