@pillar-ai/sdk 0.1.34 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +5 -5
  2. package/dist/api/mcp-client.d.ts +0 -4
  3. package/dist/cli/sync.js +0 -0
  4. package/dist/components/Cards/ConfirmActionCard.d.ts +16 -5
  5. package/dist/components/Panel/TaskButton.d.ts +2 -0
  6. package/dist/core/Pillar.d.ts +44 -2
  7. package/dist/core/config.d.ts +7 -1
  8. package/dist/core/events.d.ts +26 -13
  9. package/dist/index.d.ts +6 -4
  10. package/dist/pillar.esm.js +1 -1
  11. package/dist/store/chat.d.ts +5 -0
  12. package/dist/tools/types.d.ts +8 -1
  13. package/package.json +1 -1
  14. package/dist/actions/definitions/analytics.d.ts +0 -18
  15. package/dist/actions/definitions/content.d.ts +0 -40
  16. package/dist/actions/definitions/index.d.ts +0 -26
  17. package/dist/actions/definitions/navigation.d.ts +0 -65
  18. package/dist/actions/definitions/settings.d.ts +0 -162
  19. package/dist/actions/definitions/sources.d.ts +0 -44
  20. package/dist/actions/definitions/support.d.ts +0 -15
  21. package/dist/actions/definitions/team.d.ts +0 -120
  22. package/dist/actions/index.d.ts +0 -33
  23. package/dist/actions/registry.d.ts +0 -98
  24. package/dist/actions/types.d.ts +0 -530
  25. package/dist/api/ag-ui-adapter.d.ts +0 -76
  26. package/dist/api/ag-ui-bridge.d.ts +0 -49
  27. package/dist/api/ag-ui-client.d.ts +0 -102
  28. package/dist/api/ag-ui-handler.d.ts +0 -89
  29. package/dist/button/FloatingButton.d.ts +0 -44
  30. package/dist/components/Button/FloatingButton.d.ts +0 -46
  31. package/dist/components/DevTools/DOMScannerPreview.d.ts +0 -21
  32. package/dist/components/DevTools/styles.d.ts +0 -5
  33. package/dist/components/PagePilot/PagePilotBanner.d.ts +0 -7
  34. package/dist/components/PagePilot/PagePilotManager.d.ts +0 -47
  35. package/dist/components/PagePilot/index.d.ts +0 -6
  36. package/dist/components/PagePilot/styles.d.ts +0 -6
  37. package/dist/components/Panel/styles.d.ts +0 -20
  38. package/dist/components/Plan/InlinePlanView.d.ts +0 -24
  39. package/dist/components/Plan/PlanDocument.d.ts +0 -18
  40. package/dist/components/Plan/PlanStepItem.d.ts +0 -23
  41. package/dist/components/Plan/PlanView.d.ts +0 -10
  42. package/dist/components/Plan/index.d.ts +0 -9
  43. package/dist/components/Progress/AGUIProgress.d.ts +0 -15
  44. package/dist/components/Progress/ReasoningDisclosure.d.ts +0 -16
  45. package/dist/components/TextSelection/styles.d.ts +0 -5
  46. package/dist/components/Tooltips/Tooltip.d.ts +0 -46
  47. package/dist/components/Tooltips/TooltipManager.d.ts +0 -41
  48. package/dist/components/Tooltips/index.d.ts +0 -6
  49. package/dist/components/Tooltips/styles.d.ts +0 -5
  50. package/dist/components/Views/ArticleChatView.d.ts +0 -9
  51. package/dist/components/Views/ArticleView.d.ts +0 -10
  52. package/dist/components/Views/CategoryView.d.ts +0 -11
  53. package/dist/components/Views/DeveloperView.d.ts +0 -6
  54. package/dist/components/Views/SearchView.d.ts +0 -10
  55. package/dist/components/shared/ArticleCard.d.ts +0 -17
  56. package/dist/components/shared/CategoryCard.d.ts +0 -17
  57. package/dist/content/extensions/AccordionNode.d.ts +0 -10
  58. package/dist/content/extensions/CalloutNode.d.ts +0 -11
  59. package/dist/content/extensions/index.d.ts +0 -5
  60. package/dist/content/index.d.ts +0 -5
  61. package/dist/content/renderer.d.ts +0 -24
  62. package/dist/core/plan-executor.d.ts +0 -148
  63. package/dist/core/plan.d.ts +0 -192
  64. package/dist/hooks/useInlineCard.d.ts +0 -35
  65. package/dist/panel/Panel.d.ts +0 -53
  66. package/dist/panel/PanelUI.d.ts +0 -43
  67. package/dist/panel/components/ArticleCard.d.ts +0 -10
  68. package/dist/panel/components/CategoryCard.d.ts +0 -10
  69. package/dist/panel/components/ChatInput.d.ts +0 -36
  70. package/dist/panel/components/Header.d.ts +0 -16
  71. package/dist/panel/components/SearchInput.d.ts +0 -11
  72. package/dist/panel/styles.d.ts +0 -5
  73. package/dist/panel/views/ArticleView.d.ts +0 -21
  74. package/dist/panel/views/CategoryView.d.ts +0 -20
  75. package/dist/panel/views/ChatView.d.ts +0 -30
  76. package/dist/panel/views/HomeView.d.ts +0 -18
  77. package/dist/panel/views/SearchView.d.ts +0 -22
  78. package/dist/store/developer.d.ts +0 -19
  79. package/dist/store/plan-persistence.d.ts +0 -47
  80. package/dist/store/plan.d.ts +0 -45
  81. package/dist/store/tooltips.d.ts +0 -21
  82. package/dist/tooltips/Tooltip.d.ts +0 -63
  83. package/dist/tooltips/TooltipManager.d.ts +0 -42
  84. package/dist/tooltips/styles.d.ts +0 -5
  85. package/dist/ui/config.d.ts +0 -96
  86. package/dist/ui/executor.d.ts +0 -75
  87. package/dist/ui/index.d.ts +0 -11
  88. package/dist/ui/scanner.d.ts +0 -105
  89. package/dist/ui/types.d.ts +0 -293
  90. package/dist/utils/markdown.d.ts +0 -9
@@ -1,2 +1,2 @@
1
- let e=!1;function t(t){e=t,console.log("[Pillar] Debug mode enabled - verbose logging active")}function n(){return e||r()}const r=()=>{if("undefined"!=typeof process&&process.env?.NODE_ENV)return"development"===process.env.NODE_ENV;if("undefined"!=typeof window){const e=window.location?.hostname||"";return"localhost"===e||"127.0.0.1"===e||e.includes(".local")}return!1},i=["[Pillar]","[MCPClient]","[PlanExecutor]"],a=["sdk","handler","network"];class l{constructor(e,t=5e3){this.buffer=[],this.flushTimer=null,this.maxBufferSize=100,this.handleBeforeUnload=()=>{this.flush()},this.mcpClient=e,this.flushIntervalMs=t,this.startFlushTimer(),this.setupUnloadListener()}shouldForward(e){return!!a.includes(e.source)||(!(!e.prefix||!i.some(t=>e.prefix?.startsWith(t)))||"error"===e.level)}bufferEntry(e){const t={level:"info"===e.level?"log":e.level,message:e.prefix?`${e.prefix} ${e.event}`:`[${e.source}] ${e.event}`,data:e.data,timestamp:new Date(e.timestamp).toISOString()};this.buffer.push(t),this.buffer.length>=this.maxBufferSize&&this.flush(),"error"===e.level&&this.flush()}flush(){if(0===this.buffer.length)return;const e=this.buffer.splice(0);this.mcpClient.sendLogBatch(e)}startFlushTimer(){this.flushTimer||(this.flushTimer=setInterval(()=>this.flush(),this.flushIntervalMs))}stopFlushTimer(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}setupUnloadListener(){"undefined"!=typeof window&&window.addEventListener("beforeunload",this.handleBeforeUnload)}removeUnloadListener(){"undefined"!=typeof window&&window.removeEventListener("beforeunload",this.handleBeforeUnload)}destroy(){this.stopFlushTimer(),this.removeUnloadListener(),this.flush(),this.buffer=[]}}const o=new class{constructor(){this.entries=[],this.maxEntries=500,this.listeners=new Set,this.serverForwarder=null,this.forwarderUnsubscribe=null}add(e){const t={...e,timestamp:Date.now()};this.entries.push(t),this.entries.length>this.maxEntries&&(this.entries=this.entries.slice(-this.maxEntries)),this.listeners.forEach(e=>e(this.entries)),n()&&!e.prefix&&this.logToConsole(t),this.serverForwarder?.shouldForward(t)&&this.serverForwarder.bufferEntry(t)}logToConsole(e){const t=`[${new Date(e.timestamp).toISOString().split("T")[1].slice(0,12)}] [${e.source}]`,n=void 0!==e.data?[t,e.event,e.data]:[t,e.event];"error"===e.level?console.error(...n):"warn"===e.level?console.warn(...n):console.log(...n)}enableServerForwarding(e,t){this.disableServerForwarding(),this.serverForwarder=new l(e,t?.flushIntervalMs)}disableServerForwarding(){this.serverForwarder&&(this.serverForwarder.destroy(),this.serverForwarder=null),this.forwarderUnsubscribe&&(this.forwarderUnsubscribe(),this.forwarderUnsubscribe=null)}flush(){this.serverForwarder?.flush()}getEntries(){return[...this.entries]}clear(){this.entries=[],this.listeners.forEach(e=>e(this.entries))}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.disableServerForwarding(),this.entries=[],this.listeners.clear()}};function s(e){if(0===e.length)return{event:""};const t=e[0];let n,r,i=[];"string"==typeof t&&t.startsWith("[")&&t.endsWith("]")&&(n=t,e=e.slice(1));for(const t of e)"string"==typeof t?i.push(t):"object"==typeof t&&null!==t&&(r=t);return{prefix:n,event:i.join(" "),data:r}}function c(e){return e?e.includes("MCPClient")?"network":(e.includes("PlanExecutor"),"sdk"):"sdk"}const p={configure:(e,t)=>{!1!==t?.forwardToServer&&o.enableServerForwarding(e,{flushIntervalMs:t?.flushIntervalMs})},flush:()=>{o.flush()},log:(...e)=>{if(!n())return;const{prefix:t,event:r,data:i}=s(e);console.log(...e),o.add({event:r,data:i,source:c(t),level:"info",prefix:t})},warn:(...e)=>{if(!n())return;const{prefix:t,event:r,data:i}=s(e);console.warn(...e),o.add({event:r,data:i,source:c(t),level:"warn",prefix:t})},error:(...e)=>{const{prefix:t,event:n,data:r}=s(e);console.error(...e),o.add({event:n,data:r,source:c(t),level:"error",prefix:t})},destroy:()=>{o.destroy()}};var d=Object.freeze({__proto__:null,debug:p,debugLog:o,isDebugEnabled:n,setDebugMode:t});class u{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{this.off(e,t)}}off(e,t){const n=this.listeners.get(e);n&&n.delete(t)}emit(e,t){const n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){p.error(`[Pillar] Error in event handler for "${e}":`,t)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}var h,g,f,m,b,v,_,x,y,w,k,S,C,P={},E=[],T=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,z=Array.isArray;function R(e,t){for(var n in t)e[n]=t[n];return e}function I(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function A(e,t,n){var r,i,a,l={};for(a in t)"key"==a?r=t[a]:"ref"==a?i=t[a]:l[a]=t[a];if(arguments.length>2&&(l.children=arguments.length>3?h.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return M(e,l,r,i,null)}function M(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++f:i,__i:-1,__u:0};return null==i&&null!=g.vnode&&g.vnode(a),a}function $(e){return e.children}function L(e,t){this.props=e,this.context=t}function O(e,t){if(null==t)return e.__?O(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?O(e):null}function D(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return D(e)}}function j(e){(!e.__d&&(e.__d=!0)&&b.push(e)&&!H.__r++||v!=g.debounceRendering)&&((v=g.debounceRendering)||_)(H)}function H(){for(var e,t,n,r,i,a,l,o=1;b.length;)b.length>o&&b.sort(x),e=b.shift(),o=b.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,a=[],l=[],t.__P&&((n=R({},r)).__v=r.__v+1,g.vnode&&g.vnode(n),V(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,a,null==i?O(r):i,!!(32&r.__u),l),n.__v=r.__v,n.__.__k[n.__i]=n,G(a,n,l),r.__e=r.__=null,n.__e!=i&&D(n)));H.__r=0}function N(e,t,n,r,i,a,l,o,s,c,p){var d,u,h,g,f,m,b,v=r&&r.__k||E,_=t.length;for(s=function(e,t,n,r,i){var a,l,o,s,c,p=n.length,d=p,u=0;for(e.__k=new Array(i),a=0;a<i;a++)null!=(l=t[a])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[a]=M(null,l,null,null,null):z(l)?l=e.__k[a]=M($,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[a]=M(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!=(c=l.__i=B(l,n,s,d))&&(d--,(o=n[c])&&(o.__u|=2)),null==o||null==o.__v?(-1==c&&(i>p?u--:i<p&&u++),"function"!=typeof l.type&&(l.__u|=4)):c!=s&&(c==s-1?u--:c==s+1?u++:(c>s?u--:u++,l.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<p;a++)null!=(o=n[a])&&!(2&o.__u)&&(o.__e==r&&(r=O(o)),X(o,o));return r}(n,t,v,s,_),d=0;d<_;d++)null!=(h=n.__k[d])&&(u=-1==h.__i?P:v[h.__i]||P,h.__i=d,m=V(e,h,u,i,a,l,o,s,c,p),g=h.__e,h.ref&&u.ref!=h.ref&&(u.ref&&J(u.ref,null,h),p.push(h.ref,h.__c||g,h)),null==f&&null!=g&&(f=g),(b=!!(4&h.__u))||u.__k===h.__k?s=U(h,s,e,b):"function"==typeof h.type&&void 0!==m?s=m:g&&(s=g.nextSibling),h.__u&=-7);return n.__e=f,s}function U(e,t,n,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,t=U(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=O(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function B(e,t,n,r){var i,a,l,o=e.key,s=e.type,c=t[n],p=null!=c&&!(2&c.__u);if(null===c&&null==o||p&&o==c.key&&s==c.type)return n;if(r>(p?1:0))for(i=n-1,a=n+1;i>=0||a<t.length;)if(null!=(c=t[l=i>=0?i--:a++])&&!(2&c.__u)&&o==c.key&&s==c.type)return l;return-1}function F(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||T.test(t)?n:n+"px"}function q(e,t,n,r,i){var a,l;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||F(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||F(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])a=t!=(t=t.replace(y,"$1")),l=t.toLowerCase(),t=l in e||"onFocusOut"==t||"onFocusIn"==t?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=w,e.addEventListener(t,a?S:k,a)):e.removeEventListener(t,a?S:k,a);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function W(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=w++;else if(t.t<n.u)return;return n(g.event?g.event(t):t)}}}function V(e,t,n,r,i,a,l,o,s,c){var p,d,u,f,m,b,v,_,x,y,w,k,S,C,E,T,A,M=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(s=!!(32&n.__u),a=[o=t.__e=n.__e]),(p=g.__b)&&p(t);e:if("function"==typeof M)try{if(_=t.props,x="prototype"in M&&M.prototype.render,y=(p=M.contextType)&&r[p.__c],w=p?y?y.props.value:p.__:r,n.__c?v=(d=t.__c=n.__c).__=d.__E:(x?t.__c=d=new M(_,w):(t.__c=d=new L(_,w),d.constructor=M,d.render=Z),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!=M.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=R({},d.__s)),R(d.__s,M.getDerivedStateFromProps(_,d.__s))),f=d.props,m=d.state,d.__v=t,u)x&&null==M.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),x&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(x&&null==M.getDerivedStateFromProps&&_!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(_,w),t.__v==n.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(_,d.__s,w)){for(t.__v!=n.__v&&(d.props=_,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[],d.__h.length&&l.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(_,d.__s,w),x&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,m,b)})}if(d.context=w,d.props=_,d.__P=e,d.__e=!1,S=g.__r,C=0,x){for(d.state=d.__s,d.__d=!1,S&&S(t),p=d.render(d.props,d.state,d.context),E=0;E<d._sb.length;E++)d.__h.push(d._sb[E]);d._sb=[]}else do{d.__d=!1,S&&S(t),p=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=R(R({},r),d.getChildContext())),x&&!u&&null!=d.getSnapshotBeforeUpdate&&(b=d.getSnapshotBeforeUpdate(f,m)),T=p,null!=p&&p.type===$&&null==p.key&&(T=Q(p.props.children)),o=N(e,z(T)?T:[T],t,n,r,i,a,l,o,s,c),d.base=t.__e,t.__u&=-161,d.__h.length&&l.push(d),v&&(d.__E=d.__=null)}catch(e){if(t.__v=null,s||null!=a)if(e.then){for(t.__u|=s?160:128;o&&8==o.nodeType&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,t.__e=o}else{for(A=a.length;A--;)I(a[A]);K(t)}else t.__e=n.__e,t.__k=n.__k,e.then||K(t);g.__e(e,t,n)}else null==a&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):o=t.__e=function(e,t,n,r,i,a,l,o,s){var c,p,d,u,f,m,b,v=n.props||P,_=t.props,x=t.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(c=0;c<a.length;c++)if((f=a[c])&&"setAttribute"in f==!!x&&(x?f.localName==x:3==f.nodeType)){e=f,a[c]=null;break}if(null==e){if(null==x)return document.createTextNode(_);e=document.createElementNS(i,x,_.is&&_),o&&(g.__m&&g.__m(t,a),o=!1),a=null}if(null==x)v===_||o&&e.data==_||(e.data=_);else{if(a=a&&h.call(e.childNodes),!o&&null!=a)for(v={},c=0;c<e.attributes.length;c++)v[(f=e.attributes[c]).name]=f.value;for(c in v)if(f=v[c],"children"==c);else if("dangerouslySetInnerHTML"==c)d=f;else if(!(c in _)){if("value"==c&&"defaultValue"in _||"checked"==c&&"defaultChecked"in _)continue;q(e,c,null,f,i)}for(c in _)f=_[c],"children"==c?u=f:"dangerouslySetInnerHTML"==c?p=f:"value"==c?m=f:"checked"==c?b=f:o&&"function"!=typeof f||v[c]===f||q(e,c,f,v[c],i);if(p)o||d&&(p.__html==d.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(d&&(e.innerHTML=""),N("template"==t.type?e.content:e,z(u)?u:[u],t,n,r,"foreignObject"==x?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:n.__k&&O(n,0),o,s),null!=a)for(c=a.length;c--;)I(a[c]);o||(c="value","progress"==x&&null==m?e.removeAttribute("value"):null!=m&&(m!==e[c]||"progress"==x&&!m||"option"==x&&m!=v[c])&&q(e,c,m,v[c],i),c="checked",null!=b&&b!=e[c]&&q(e,c,b,v[c],i))}return e}(n.__e,t,n,r,i,a,l,s,c);return(p=g.diffed)&&p(t),128&t.__u?void 0:o}function K(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(K)}function G(e,t,n){for(var r=0;r<n.length;r++)J(n[r],n[++r],n[++r]);g.__c&&g.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){g.__e(e,t.__v)}})}function Q(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:z(e)?e.map(Q):R({},e)}function J(e,t,n){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==t||(e.__u=e(t))}else e.current=t}catch(e){g.__e(e,n)}}function X(e,t,n){var r,i;if(g.unmount&&g.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||J(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){g.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&X(r[i],t,n||"function"!=typeof e.type);n||I(e.__e),e.__c=e.__=e.__e=void 0}function Z(e,t,n){return this.constructor(e,n)}function Y(e,t,n){var r,i,a;t==document&&(t=document.documentElement),g.__&&g.__(e,t),r=!1?null:t.__k,i=[],a=[],V(t,e=t.__k=A($,null,[e]),r||P,P,t.namespaceURI,r?null:t.firstChild?h.call(t.childNodes):null,i,r?r.__e:t.firstChild,false,a),G(i,e,a)}function ee(e,t){return e instanceof TypeError||(!!(e instanceof Error&&e.message.includes("Failed to fetch"))||!!(t&&t.status>=500))}async function te(e,t={}){const{maxRetries:n=0,baseDelayMs:r=100,retryOn:i=ee,onRetry:a,...l}=t;let o;for(let t=0;t<=n;t++){if(t>0){const e=r*Math.pow(2,t-1);a?.(t,e,o),await new Promise(t=>setTimeout(t,e))}try{const r=await fetch(e,l);if(!r.ok&&t<n&&i(null,r)){o=new Error(`HTTP ${r.status}`);continue}return r}catch(e){if(o=e,t<n&&i(e))continue;throw e}}throw o}h=E.slice,g={__e:function(e,t,n,r){for(var i,a,l;t=t.__;)if((i=t.__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(t){e=t}throw e}},f=0,m=function(e){return null!=e&&void 0===e.constructor},L.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=R({},this.state),"function"==typeof e&&(e=e(R({},n),this.props)),e&&R(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),j(this))},L.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),j(this))},L.prototype.render=$,b=[],_="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,x=function(e,t){return e.__v.__b-t.__v.__b},H.__r=0,y=/(PointerCapture)$|Capture$/i,w=0,k=W(!1),S=W(!0),C=0;var ne="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},re="1.9.0",ie=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;var ae=function(e){var t=new Set([e]),n=new Set,r=e.match(ie);if(!r)return function(){return!1};var i=+r[1],a=+r[2],l=+r[3];if(null!=r[4])return function(t){return t===e};function o(e){return n.add(e),!1}function s(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;var r=e.match(ie);if(!r)return o(e);var c=+r[1],p=+r[2],d=+r[3];return null!=r[4]||i!==c?o(e):0===i?a===p&&l<=d?s(e):o(e):a<=p?s(e):o(e)}}(re),le=re.split(".")[0],oe=Symbol.for("opentelemetry.js.api."+le),se=ne;function ce(e,t,n,r){var i;void 0===r&&(r=!1);var a=se[oe]=null!==(i=se[oe])&&void 0!==i?i:{version:re};if(!r&&a[e]){var l=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return n.error(l.stack||l.message),!1}if(a.version!==re){l=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+e+" does not match previously registered API v"+re);return n.error(l.stack||l.message),!1}return a[e]=t,n.debug("@opentelemetry/api: Registered a global for "+e+" v"+re+"."),!0}function pe(e){var t,n,r=null===(t=se[oe])||void 0===t?void 0:t.version;if(r&&ae(r))return null===(n=se[oe])||void 0===n?void 0:n[e]}function de(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+re+".");var n=se[oe];n&&delete n[e]}var ue,he=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},ge=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},fe=function(){function e(e){this._namespace=e.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("debug",this._namespace,e)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("error",this._namespace,e)},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("info",this._namespace,e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("warn",this._namespace,e)},e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("verbose",this._namespace,e)},e}();function me(e,t,n){var r=pe("diag");if(r)return n.unshift(t),r[e].apply(r,ge([],he(n),!1))}!function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"}(ue||(ue={}));var be=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},ve=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},_e=function(){function e(){function e(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=pe("diag");if(r)return r[e].apply(r,ve([],be(t),!1))}}var t=this;t.setLogger=function(e,n){var r,i,a;if(void 0===n&&(n={logLevel:ue.INFO}),e===t){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error(null!==(r=l.stack)&&void 0!==r?r:l.message),!1}"number"==typeof n&&(n={logLevel:n});var o=pe("diag"),s=function(e,t){function n(n,r){var i=t[n];return"function"==typeof i&&e>=r?i.bind(t):function(){}}return e<ue.NONE?e=ue.NONE:e>ue.ALL&&(e=ue.ALL),t=t||{},{error:n("error",ue.ERROR),warn:n("warn",ue.WARN),info:n("info",ue.INFO),debug:n("debug",ue.DEBUG),verbose:n("verbose",ue.VERBOSE)}}(null!==(i=n.logLevel)&&void 0!==i?i:ue.INFO,e);if(o&&!n.suppressOverrideMessage){var c=null!==(a=(new Error).stack)&&void 0!==a?a:"<failed to generate stacktrace>";o.warn("Current logger will be overwritten from "+c),s.warn("Current logger will overwrite one already registered from "+c)}return ce("diag",s,t,!0)},t.disable=function(){de("diag",t)},t.createComponentLogger=function(e){return new fe(e)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}(),xe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},ye=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},we=function(){function e(e){this._entries=e?new Map(e):new Map}return e.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},e.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=xe(e,2);return[t[0],t[1]]})},e.prototype.setEntry=function(t,n){var r=new e(this._entries);return r._entries.set(t,n),r},e.prototype.removeEntry=function(t){var n=new e(this._entries);return n._entries.delete(t),n},e.prototype.removeEntries=function(){for(var t,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=new e(this._entries);try{for(var l=ye(r),o=l.next();!o.done;o=l.next()){var s=o.value;a._entries.delete(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return a},e.prototype.clear=function(){return new e},e}(),ke=Symbol("BaggageEntryMetadata"),Se=_e.instance();function Ce(e){return void 0===e&&(e={}),new we(new Map(Object.entries(e)))}function Pe(e){return Symbol.for(e)}var Ee,Te=function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(e){return n._currentContext.get(e)},n.setValue=function(t,r){var i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=function(t){var r=new e(n._currentContext);return r._currentContext.delete(t),r}},ze=new Te,Re={get:function(e,t){if(null!=e)return e[t]},keys:function(e){return null==e?[]:Object.keys(e)}},Ie={set:function(e,t,n){null!=e&&(e[t]=n)}},Ae=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},Me=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},$e=function(){function e(){}return e.prototype.active=function(){return ze},e.prototype.with=function(e,t,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return t.call.apply(t,Me([n],Ae(r),!1))},e.prototype.bind=function(e,t){return t},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),Le=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},Oe=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},De="context",je=new $e,He=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(e){return ce(De,e,_e.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(e,t,n){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,Oe([e,t,n],Le(i),!1))},e.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},e.prototype._getContextManager=function(){return pe(De)||je},e.prototype.disable=function(){this._getContextManager().disable(),de(De,_e.instance())},e}();!function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"}(Ee||(Ee={}));var Ne="0000000000000000",Ue="00000000000000000000000000000000",Be={traceId:Ue,spanId:Ne,traceFlags:Ee.NONE},Fe=function(){function e(e){void 0===e&&(e=Be),this._spanContext=e}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(e,t){return this},e.prototype.setAttributes=function(e){return this},e.prototype.addEvent=function(e,t){return this},e.prototype.addLink=function(e){return this},e.prototype.addLinks=function(e){return this},e.prototype.setStatus=function(e){return this},e.prototype.updateName=function(e){return this},e.prototype.end=function(e){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(e,t){},e}(),qe=Pe("OpenTelemetry Context Key SPAN");function We(e){return e.getValue(qe)||void 0}function Ve(){return We(He.getInstance().active())}function Ke(e,t){return e.setValue(qe,t)}function Ge(e){return e.deleteValue(qe)}function Qe(e,t){return Ke(e,new Fe(t))}function Je(e){var t;return null===(t=We(e))||void 0===t?void 0:t.spanContext()}var Xe=/^([0-9a-f]{32})$/i,Ze=/^[0-9a-f]{16}$/i;function Ye(e){return Xe.test(e)&&e!==Ue}function et(e){return Ye(e.traceId)&&(t=e.spanId,Ze.test(t)&&t!==Ne);var t}function tt(e){return new Fe(e)}var nt=He.getInstance(),rt=function(){function e(){}return e.prototype.startSpan=function(e,t,n){if(void 0===n&&(n=nt.active()),Boolean(null==t?void 0:t.root))return new Fe;var r,i=n&&Je(n);return"object"==typeof(r=i)&&"string"==typeof r.spanId&&"string"==typeof r.traceId&&"number"==typeof r.traceFlags&&et(i)?new Fe(i):new Fe},e.prototype.startActiveSpan=function(e,t,n,r){var i,a,l;if(!(arguments.length<2)){2===arguments.length?l=t:3===arguments.length?(i=t,l=n):(i=t,a=n,l=r);var o=null!=a?a:nt.active(),s=this.startSpan(e,i,o),c=Ke(o,s);return nt.with(c,l,void 0,s)}},e}();var it,at,lt,ot=new rt,st=function(){function e(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}return e.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},e.prototype.startActiveSpan=function(e,t,n,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):ot},e}(),ct=new(function(){function e(){}return e.prototype.getTracer=function(e,t,n){return new rt},e}()),pt=function(){function e(){}return e.prototype.getTracer=function(e,t,n){var r;return null!==(r=this.getDelegateTracer(e,t,n))&&void 0!==r?r:new st(this,e,t,n)},e.prototype.getDelegate=function(){var e;return null!==(e=this._delegate)&&void 0!==e?e:ct},e.prototype.setDelegate=function(e){this._delegate=e},e.prototype.getDelegateTracer=function(e,t,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getTracer(e,t,n)},e}();!function(e){e[e.NOT_RECORD=0]="NOT_RECORD",e[e.RECORD=1]="RECORD",e[e.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(it||(it={})),function(e){e[e.INTERNAL=0]="INTERNAL",e[e.SERVER=1]="SERVER",e[e.CLIENT=2]="CLIENT",e[e.PRODUCER=3]="PRODUCER",e[e.CONSUMER=4]="CONSUMER"}(at||(at={})),function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"}(lt||(lt={}));var dt=He.getInstance(),ut=_e.instance(),ht=function(){function e(){}return e.prototype.inject=function(e,t){},e.prototype.extract=function(e,t){return e},e.prototype.fields=function(){return[]},e}(),gt=Pe("OpenTelemetry Baggage Key");function ft(e){return e.getValue(gt)||void 0}function mt(){return ft(He.getInstance().active())}function bt(e,t){return e.setValue(gt,t)}function vt(e){return e.deleteValue(gt)}var _t="propagation",xt=new ht,yt=function(){function e(){this.createBaggage=Ce,this.getBaggage=ft,this.getActiveBaggage=mt,this.setBaggage=bt,this.deleteBaggage=vt}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalPropagator=function(e){return ce(_t,e,_e.instance())},e.prototype.inject=function(e,t,n){return void 0===n&&(n=Ie),this._getGlobalPropagator().inject(e,t,n)},e.prototype.extract=function(e,t,n){return void 0===n&&(n=Re),this._getGlobalPropagator().extract(e,t,n)},e.prototype.fields=function(){return this._getGlobalPropagator().fields()},e.prototype.disable=function(){de(_t,_e.instance())},e.prototype._getGlobalPropagator=function(){return pe(_t)||xt},e}(),wt=yt.getInstance(),kt="trace",St=function(){function e(){this._proxyTracerProvider=new pt,this.wrapSpanContext=tt,this.isSpanContextValid=et,this.deleteSpan=Ge,this.getSpan=We,this.getActiveSpan=Ve,this.getSpanContext=Je,this.setSpan=Ke,this.setSpanContext=Qe}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(e){var t=ce(kt,this._proxyTracerProvider,_e.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},e.prototype.getTracerProvider=function(){return pe(kt)||this._proxyTracerProvider},e.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},e.prototype.disable=function(){de(kt,_e.instance()),this._proxyTracerProvider=new pt},e}().getInstance();const Ct=Pe("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Pt(e){return!0===e.getValue(Ct)}const Et="baggage";function Tt(e){if(!e)return;const t=e.indexOf(";"),n=-1===t?e:e.substring(0,t),r=n.indexOf("=");if(r<=0)return;const i=n.substring(0,r).trim(),a=n.substring(r+1).trim();if(!i||!a)return;let l,o,s;try{l=decodeURIComponent(i),o=decodeURIComponent(a)}catch{return}if(-1!==t&&t<e.length-1){const n=e.substring(t+1);"string"!=typeof(c=n)&&(Se.error("Cannot create baggage metadata from unknown type: "+typeof c),c=""),s={__TYPE__:ke,toString:function(){return c}}}var c;return{key:l,value:o,metadata:s}}class zt{inject(e,t,n){const r=wt.getBaggage(e);if(!r||Pt(e))return;const i=function(e){return e.getAllEntries().map(([e,t])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(t.value)}`;return void 0!==t.metadata&&(n+=";"+t.metadata.toString()),n})}(r).filter(e=>e.length<=4096).slice(0,180),a=function(e){return e.reduce((e,t)=>{const n=`${e}${""!==e?",":""}${t}`;return n.length>8192?e:n},"")}(i);a.length>0&&n.set(t,Et,a)}extract(e,t,n){const r=n.get(t,Et),i=Array.isArray(r)?r.join(","):r;if(!i)return e;const a={};if(0===i.length)return e;return i.split(",").forEach(e=>{const t=Tt(e);if(t){const e={value:t.value};t.metadata&&(e.metadata=t.metadata),a[t.key]=e}}),0===Object.entries(a).length?e:wt.setBaggage(e,wt.createBaggage(a))}fields(){return[Et]}}function Rt(e){const t={};if("object"!=typeof e||null==e)return t;for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!It(n)){ut.warn(`Invalid attribute key: ${n}`);continue}const r=e[n];At(r)?Array.isArray(r)?t[n]=r.slice():t[n]=r:ut.warn(`Invalid attribute value set for key: ${n}`)}return t}function It(e){return"string"==typeof e&&""!==e}function At(e){return null==e||(Array.isArray(e)?function(e){let t;for(const n of e){if(null==n)continue;const e=typeof n;if(e!==t){if(!t){if(Mt(e)){t=e;continue}return!1}return!1}}return!0}(e):Mt(typeof e))}function Mt(e){switch(e){case"number":case"boolean":case"string":return!0}return!1}let $t=e=>{ut.error(function(e){return"string"==typeof e?e:JSON.stringify(function(e){const t={};let n=e;for(;null!==n;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;const r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}(e))}(e))};function Lt(e){try{$t(e)}catch{}}const Ot="exception.message",Dt="exception.type",jt="service.name",Ht="telemetry.sdk.language",Nt="telemetry.sdk.name",Ut="telemetry.sdk.version",Bt="process.runtime.name",Ft={[Nt]:"opentelemetry",[Bt]:"browser",[Ht]:"webjs",[Ut]:"2.5.1"},qt=performance,Wt=Math.pow(10,6),Vt=Math.pow(10,9);function Kt(e){const t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*Wt)]}function Gt(e){return Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Qt(e){return Gt(e)||"number"==typeof e||e instanceof Date}function Jt(e,t){const n=[e[0]+t[0],e[1]+t[1]];return n[1]>=Vt&&(n[1]-=Vt,n[0]+=1),n}var Xt;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.FAILED=1]="FAILED"}(Xt||(Xt={}));class Zt{_propagators;_fields;constructor(e={}){this._propagators=e.propagators??[],this._fields=Array.from(new Set(this._propagators.map(e=>"function"==typeof e.fields?e.fields():[]).reduce((e,t)=>e.concat(t),[])))}inject(e,t,n){for(const r of this._propagators)try{r.inject(e,t,n)}catch(e){ut.warn(`Failed to inject with ${r.constructor.name}. Err: ${e.message}`)}}extract(e,t,n){return this._propagators.reduce((e,r)=>{try{return r.extract(e,t,n)}catch(e){ut.warn(`Failed to extract with ${r.constructor.name}. Err: ${e.message}`)}return e},e)}fields(){return this._fields.slice()}}const Yt="[_0-9a-z-*/]",en=new RegExp(`^(?:${`[a-z]${Yt}{0,255}`}|${`[a-z0-9]${Yt}{0,240}@[a-z]${Yt}{0,13}`})$`),tn=/^[ -~]{0,255}[!-~]$/,nn=/,|=/;class rn{_internalState=new Map;constructor(e){e&&this._parse(e)}set(e,t){const n=this._clone();return n._internalState.has(e)&&n._internalState.delete(e),n._internalState.set(e,t),n}unset(e){const t=this._clone();return t._internalState.delete(e),t}get(e){return this._internalState.get(e)}serialize(){return this._keys().reduce((e,t)=>(e.push(t+"="+this.get(t)),e),[]).join(",")}_parse(e){e.length>512||(this._internalState=e.split(",").reverse().reduce((e,t)=>{const n=t.trim(),r=n.indexOf("=");if(-1!==r){const i=n.slice(0,r),a=n.slice(r+1,t.length);(function(e){return en.test(e)})(i)&&function(e){return tn.test(e)&&!nn.test(e)}(a)&&e.set(i,a)}return e},new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){const e=new rn;return e._internalState=new Map(this._internalState),e}}const an="traceparent",ln="tracestate",on=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");class sn{inject(e,t,n){const r=St.getSpanContext(e);if(!r||Pt(e)||!et(r))return;const i=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||Ee.NONE).toString(16)}`;n.set(t,an,i),r.traceState&&n.set(t,ln,r.traceState.serialize())}extract(e,t,n){const r=n.get(t,an);if(!r)return e;const i=Array.isArray(r)?r[0]:r;if("string"!=typeof i)return e;const a=function(e){const t=on.exec(e);return t?"00"===t[1]&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}:null}(i);if(!a)return e;a.isRemote=!0;const l=n.get(t,ln);if(l){const e=Array.isArray(l)?l.join(","):l;a.traceState=new rn("string"==typeof e?e:void 0)}return St.setSpanContext(e,a)}fields(){return[an,ln]}}const cn="[object Null]",pn="[object Undefined]",dn=Function.prototype.toString,un=dn.call(Object),hn=Object.getPrototypeOf,gn=Object.prototype,fn=gn.hasOwnProperty,mn=Symbol?Symbol.toStringTag:void 0,bn=gn.toString;function vn(e){if(!function(e){return null!=e&&"object"==typeof e}(e)||"[object Object]"!==function(e){if(null==e)return void 0===e?pn:cn;return mn&&mn in Object(e)?function(e){const t=fn.call(e,mn),n=e[mn];let r=!1;try{e[mn]=void 0,r=!0}catch{}const i=bn.call(e);r&&(t?e[mn]=n:delete e[mn]);return i}(e):function(e){return bn.call(e)}(e)}(e))return!1;const t=hn(e);if(null===t)return!0;const n=fn.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&dn.call(n)===un}function _n(e){return wn(e)?e.slice():e}function xn(e,t,n=0,r){let i;if(!(n>20)){if(n++,Cn(e)||Cn(t)||kn(t))i=_n(t);else if(wn(e)){if(i=e.slice(),wn(t))for(let e=0,n=t.length;e<n;e++)i.push(_n(t[e]));else if(Sn(t)){const e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){const r=e[n];i[r]=_n(t[r])}}}else if(Sn(e))if(Sn(t)){if(!function(e,t){if(!vn(e)||!vn(t))return!1;return!0}(e,t))return t;i=Object.assign({},e);const a=Object.keys(t);for(let l=0,o=a.length;l<o;l++){const o=a[l],s=t[o];if(Cn(s))void 0===s?delete i[o]:i[o]=s;else{const a=i[o],l=s;if(yn(e,o,r)||yn(t,o,r))delete i[o];else{if(Sn(a)&&Sn(l)){const n=r.get(a)||[],i=r.get(l)||[];n.push({obj:e,key:o}),i.push({obj:t,key:o}),r.set(a,n),r.set(l,i)}i[o]=xn(i[o],s,n,r)}}}}else i=t;return i}}function yn(e,t,n){const r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){const i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function wn(e){return Array.isArray(e)}function kn(e){return"function"==typeof e}function Sn(e){return!Cn(e)&&!wn(e)&&!kn(e)&&"object"==typeof e}function Cn(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||void 0===e||e instanceof Date||e instanceof RegExp||null===e}class Pn{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}}class En{_isCalled=!1;_deferred=new Pn;_callback;_that;constructor(e,t){this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}}let Tn;function zn(){if(void 0===Tn)try{const e=globalThis.process.argv0;Tn=e?`unknown_service:${e}`:"unknown_service"}catch{Tn="unknown_service"}return Tn}const Rn=e=>null!==e&&"object"==typeof e&&"function"==typeof e.then;class In{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,t){const n=new In({},t);return n._rawAttributes=Mn(e),n._asyncAttributesPending=e.filter(([e,t])=>Rn(t)).length>0,n}constructor(e,t){const n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([e,t])=>(Rn(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Mn(this._rawAttributes),this._schemaUrl=function(e){if("string"==typeof e||void 0===e)return e;return void ut.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",e)}(t?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){const[t,n]=this._rawAttributes[e];this._rawAttributes[e]=[t,Rn(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ut.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const e={};for(const[t,n]of this._rawAttributes)Rn(n)?ut.debug(`Unsettled resource attribute ${t} skipped`):null!=n&&(e[t]??=n);return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(null==e)return this;const t=function(e,t){const n=e?.schemaUrl,r=t?.schemaUrl,i=void 0===n||""===n,a=void 0===r||""===r;if(i)return r;if(a)return n;if(n===r)return n;return void ut.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',n,r)}(this,e),n=t?{schemaUrl:t}:void 0;return In.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}}function An(e,t){return In.FromAttributeList(Object.entries(e),t)}function Mn(e){return e.map(([e,t])=>Rn(t)?[e,t.catch(t=>{ut.debug("promise rejection for resource attribute: %s - %s",e,t)})]:[e,t])}class $n{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:lt.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(e){const t=Date.now();this._spanContext=e.spanContext,this._performanceStartTime=qt.now(),this._performanceOffset=t-(this._performanceStartTime+qt.timeOrigin),this._startTimeProvided=null!=e.startTime,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit||0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,this.links=e.links||[],this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,null!=e.attributes&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(null==t||this._isSpanEnded())return this;if(0===e.length)return ut.warn(`Invalid attribute key: ${e}`),this;if(!At(t))return ut.warn(`Invalid attribute value set for key: ${e}`),this;const{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return void 0!==n&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(const[t,n]of Object.entries(e))this.setAttribute(t,n);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;const{eventCountLimit:r}=this._spanLimits;if(0===r)return ut.warn("No events allowed."),this._droppedEventsCount++,this;void 0!==r&&this.events.length>=r&&(0===this._droppedEventsCount&&ut.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),Qt(t)&&(Qt(n)||(n=t),t=void 0);const i=Rt(t);return this.events.push({name:e,attributes:i,time:this._getTime(n),droppedAttributesCount:0}),this}addLink(e){return this.links.push(e),this}addLinks(e){return this.links.push(...e),this}setStatus(e){return this._isSpanEnded()||(this.status={...e},null!=this.status.message&&"string"!=typeof e.message&&(ut.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`),delete this.status.message)),this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){this._isSpanEnded()?ut.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this.endTime=this._getTime(e),this._duration=function(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(n-=1,r+=Vt),[n,r]}(this.startTime,this.endTime),this._duration[0]<0&&(ut.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.",this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&ut.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._ended=!0,this._spanProcessor.onEnd(this))}_getTime(e){if("number"==typeof e&&e<=qt.now())return t=e+this._performanceOffset,Jt(Kt(qt.timeOrigin),Kt("number"==typeof t?t:qt.now()));var t;if("number"==typeof e)return Kt(e);if(e instanceof Date)return Kt(e.getTime());if(Gt(e))return e;if(this._startTimeProvided)return Kt(Date.now());const n=qt.now()-this._performanceStartTime;return Jt(this.startTime,Kt(n))}isRecording(){return!1===this._ended}recordException(e,t){const n={};"string"==typeof e?n[Ot]=e:e&&(e.code?n[Dt]=e.code.toString():e.name&&(n[Dt]=e.name),e.message&&(n[Ot]=e.message),e.stack&&(n["exception.stacktrace"]=e.stack)),n[Dt]||n[Ot]?this.addEvent("exception",n,t):ut.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){const e=new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);ut.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){const t=this._attributeValueLengthLimit;return t<=0?(ut.warn(`Attribute value limit must be positive, got ${t}`),e):"string"==typeof e?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>"string"==typeof e?this._truncateToLimitUtil(e,t):e):e}}var Ln,On;!function(e){e[e.NOT_RECORD=0]="NOT_RECORD",e[e.RECORD=1]="RECORD",e[e.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(Ln||(Ln={}));class Dn{shouldSample(){return{decision:Ln.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class jn{shouldSample(){return{decision:Ln.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class Hn{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(e){this._root=e.root,this._root||(Lt(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new jn),this._remoteParentSampled=e.remoteParentSampled??new jn,this._remoteParentNotSampled=e.remoteParentNotSampled??new Dn,this._localParentSampled=e.localParentSampled??new jn,this._localParentNotSampled=e.localParentNotSampled??new Dn}shouldSample(e,t,n,r,i,a){const l=St.getSpanContext(e);return l&&et(l)?l.isRemote?l.traceFlags&Ee.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):l.traceFlags&Ee.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a):this._root.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}class Nn{_ratio;_upperBound;constructor(e=0){this._ratio=this._normalize(e),this._upperBound=Math.floor(4294967295*this._ratio)}shouldSample(e,t){return{decision:Ye(t)&&this._accumulate(t)<this._upperBound?Ln.RECORD_AND_SAMPLED:Ln.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return"number"!=typeof e||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<e.length/8;n++){const r=8*n;t=(t^parseInt(e.slice(r,r+8),16))>>>0}return t}}!function(e){e.AlwaysOff="always_off",e.AlwaysOn="always_on",e.ParentBasedAlwaysOff="parentbased_always_off",e.ParentBasedAlwaysOn="parentbased_always_on",e.ParentBasedTraceIdRatio="parentbased_traceidratio",e.TraceIdRatio="traceidratio"}(On||(On={}));function Un(){return{sampler:Bn(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function Bn(){const e=On.ParentBasedAlwaysOn;switch(e){case On.AlwaysOn:return new jn;case On.AlwaysOff:return new Dn;case On.ParentBasedAlwaysOn:return new Hn({root:new jn});case On.ParentBasedAlwaysOff:return new Hn({root:new Dn});case On.TraceIdRatio:return new Nn(Fn());case On.ParentBasedTraceIdRatio:return new Hn({root:new Nn(Fn())});default:return ut.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${On.ParentBasedAlwaysOn}".`),new Hn({root:new jn})}}function Fn(){return ut.error("OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1."),1}const qn=1/0;class Wn{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(e,t){this._exporter=e,this._maxExportBatchSize="number"==typeof t?.maxExportBatchSize?t.maxExportBatchSize:512,this._maxQueueSize="number"==typeof t?.maxQueueSize?t.maxQueueSize:2048,this._scheduledDelayMillis="number"==typeof t?.scheduledDelayMillis?t.scheduledDelayMillis:5e3,this._exportTimeoutMillis="number"==typeof t?.exportTimeoutMillis?t.exportTimeoutMillis:3e4,this._shutdownOnce=new En(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(ut.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||0!==(e.spanContext().traceFlags&Ee.SAMPLED)&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize)return 0===this._droppedSpansCount&&ut.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(ut.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{const n=[];for(let e=0,t=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),0===this._finishedSpans.length?Promise.resolve():new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error("Timeout"))},this._exportTimeoutMillis);dt.with(function(e){return e.setValue(Ct,!0)}(dt.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);const i=()=>this._exporter.export(r,r=>{clearTimeout(n),r.code===Xt.SUCCESS?e():t(r.error??new Error("BatchSpanProcessor: span export failed"))});let a=null;for(let e=0,t=r.length;e<t;e++){const t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a??=[],a.push(t.resource.waitForAsyncAttributes()))}null===a?i():Promise.all(a).then(i,e=>{Lt(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;const e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,Lt(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();void 0===this._timer&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),"number"!=typeof this._timer&&this._timer.unref())}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class Vn extends Wn{_visibilityChangeListener;_pageHideListener;constructor(e,t){super(e,t),this.onInit(t)}onInit(e){!0!==e?.disableAutoFlushOnDocumentHide&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush().catch(e=>{Lt(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{Lt(e)})},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}onShutdown(){"undefined"!=typeof document&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}}const Kn=new Uint8Array(16),Gn=new Uint8Array(8),Qn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Jn(e){for(let t=0;t<e.length;t++)e[t]=256*Math.random()>>>0;for(let t=0;t<e.length;t++)if(e[t]>0)return;e[e.length-1]=1}function Xn(e){let t="";for(let n=0;n<e.length;n++)t+=Qn[e[n]];return t}class Zn{generateTraceId(){return Jn(Kn),Xn(Kn)}generateSpanId(){return Jn(Gn),Xn(Gn)}}class Yn{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;constructor(e,t,n,r){const i=function(e){const t={sampler:Bn()},n=Un(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new Zn,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e}startSpan(e,t={},n=dt.active()){t.root&&(n=St.deleteSpan(n));const r=St.getSpan(n);if(Pt(n)){ut.debug("Instrumentation suppressed, returning Noop Span");return St.wrapSpanContext(Be)}const i=r?.spanContext(),a=this._idGenerator.generateSpanId();let l,o,s;i&&St.isSpanContextValid(i)?(o=i.traceId,s=i.traceState,l=i):o=this._idGenerator.generateTraceId();const c=t.kind??at.INTERNAL,p=(t.links??[]).map(e=>({context:e.context,attributes:Rt(e.attributes)})),d=Rt(t.attributes),u=this._sampler.shouldSample(n,o,e,c,d,p);s=u.traceState??s;const h={traceId:o,spanId:a,traceFlags:u.decision===it.RECORD_AND_SAMPLED?Ee.SAMPLED:Ee.NONE,traceState:s};if(u.decision===it.NOT_RECORD){ut.debug("Recording is off, propagating context in a non-recording span");return St.wrapSpanContext(h)}const g=Rt(Object.assign(d,u.attributes));return new $n({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:h,name:e,kind:c,links:p,parentSpanContext:l,attributes:g,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits})}startActiveSpan(e,t,n,r){let i,a,l;if(arguments.length<2)return;2===arguments.length?l=t:3===arguments.length?(i=t,l=n):(i=t,a=n,l=r);const o=a??dt.active(),s=this.startSpan(e,i,o),c=St.setSpan(o,s);return dt.with(c,l,void 0,s)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}class er{_spanProcessors;constructor(e){this._spanProcessors=e}forceFlush(){const e=[];for(const t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{Lt(e||new Error("MultiSpanProcessor: forceFlush failed")),t()})})}onStart(e,t){for(const n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(const t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(const t of this._spanProcessors)t.onEnd(e)}shutdown(){const e=[];for(const t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}}var tr;!function(e){e[e.resolved=0]="resolved",e[e.timeout=1]="timeout",e[e.error=2]="error",e[e.unresolved=3]="unresolved"}(tr||(tr={}));class nr{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(e={}){const t=function(...e){let t=e.shift();const n=new WeakMap;for(;e.length>0;)t=xn(t,e.shift(),0,n);return t}({},Un(),function(e){const t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??void 0??void 0??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??void 0??void 0??qn,Object.assign({},e,{spanLimits:t})}(e));this._resource=t.resource??An({[jt]:zn(),[Ht]:Ft[Ht],[Nt]:Ft[Nt],[Ut]:Ft[Ut]}),this._config=Object.assign({},t,{resource:this._resource});const n=[];e.spanProcessors?.length&&n.push(...e.spanProcessors),this._activeSpanProcessor=new er(n)}getTracer(e,t,n){const r=`${e}@${t||""}:${n?.schemaUrl||""}`;return this._tracers.has(r)||this._tracers.set(r,new Yn({name:e,version:t,schemaUrl:n?.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){const e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r;const i=setTimeout(()=>{n(new Error(`Span processor did not completed within timeout period of ${e} ms`)),r=tr.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==tr.timeout&&(r=tr.resolved,n(r))}).catch(e=>{clearTimeout(i),r=tr.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{const r=t.filter(e=>e!==tr.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}class rr{_enabled=!1;_currentContext=ze;_bindFunction(e=ze,t){const n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,"length",{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return void 0===e&&(e=this.active()),"function"==typeof t?this._bindFunction(e,t):t}disable(){return this._currentContext=ze,this._enabled=!1,this}enable(){return this._enabled||(this._enabled=!0,this._currentContext=ze),this}with(e,t,n,...r){const i=this._currentContext;this._currentContext=e||ze;try{return t.call(n,...r)}finally{this._currentContext=i}}}class ir extends nr{constructor(e={}){super(e)}register(e={}){var t;St.setGlobalTracerProvider(this),null!==(t=e.propagator)&&(void 0!==t?wt.setGlobalPropagator(t):wt.setGlobalPropagator(new Zt({propagators:[new sn,new zt]}))),function(e){if(null!==e){if(void 0===e){const e=new rr;return e.enable(),void dt.setGlobalContextManager(e)}e.enable(),dt.setGlobalContextManager(e)}}(e.contextManager)}}class ar{_delegate;constructor(e){this._delegate=e}export(e,t){this._delegate.export(e,t)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}}class lr extends Error{code;name="OTLPExporterError";data;constructor(e,t,n){super(e),this.data=n,this.code=t}}function or(e){if(Number.isFinite(e)&&e>0)return e;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function sr(e,t,n){return{timeoutMillis:or(e.timeoutMillis??t.timeoutMillis??n.timeoutMillis),concurrencyLimit:e.concurrencyLimit??t.concurrencyLimit??n.concurrencyLimit,compression:e.compression??t.compression??n.compression}}class cr{_concurrencyLimit;_sendingPromises=[];constructor(e){this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw new Error("Concurrency Limit reached");this._sendingPromises.push(e);const t=()=>{const t=this._sendingPromises.indexOf(e);this._sendingPromises.splice(t,1)};e.then(t,t)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}}function pr(e){return new cr(e.concurrencyLimit)}function dr(){return{handleResponse(e){null!=e&&function(e){return Object.prototype.hasOwnProperty.call(e,"partialSuccess")}(e)&&null!=e.partialSuccess&&0!==Object.keys(e.partialSuccess).length&&ut.warn("Received Partial Success response:",JSON.stringify(e.partialSuccess))}}}class ur{_diagLogger;_transport;_serializer;_responseHandler;_promiseQueue;_timeout;constructor(e,t,n,r,i){this._transport=e,this._serializer=t,this._responseHandler=n,this._promiseQueue=r,this._timeout=i,this._diagLogger=ut.createComponentLogger({namespace:"OTLPExportDelegate"})}export(e,t){if(this._diagLogger.debug("items to be sent",e),this._promiseQueue.hasReachedLimit())return void t({code:Xt.FAILED,error:new Error("Concurrent export limit reached")});const n=this._serializer.serializeRequest(e);null!=n?this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(e=>{if("success"!==e.status)"failure"===e.status&&e.error?t({code:Xt.FAILED,error:e.error}):"retryable"===e.status?t({code:Xt.FAILED,error:e.error??new lr("Export failed with retryable status")}):t({code:Xt.FAILED,error:new lr("Export failed with unknown error")});else{if(null!=e.data)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(e.data))}catch(t){this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?",t,e.data)}t({code:Xt.SUCCESS})}},e=>t({code:Xt.FAILED,error:e}))):t({code:Xt.FAILED,error:new Error("Nothing to send")})}forceFlush(){return this._promiseQueue.awaitAll()}async shutdown(){this._diagLogger.debug("shutdown started"),await this.forceFlush(),this._transport.shutdown()}}function hr(e,t,n){return r={transport:n,serializer:t,promiseHandler:pr(e)},i={timeout:e.timeoutMillis},new ur(r.transport,r.serializer,dr(),r.promiseHandler,i.timeout);var r,i}function gr(e,t){const n={attributes:mr(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&""!==r&&(n.schemaUrl=r),n}function fr(e){return{name:e.name,version:e.version}}function mr(e,t){return Object.keys(e).map(n=>function(e,t,n){return{key:e,value:br(t,n)}}(n,e[n],t))}function br(e,t){const n=typeof e;if("string"===n)return{stringValue:e};if("number"===n)return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if("boolean"===n)return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=br(e[r],t);return{arrayValue:{values:n}}}if("object"===n&&null!=e){const n=Object.keys(e),r=new Array(n.length);for(let i=0;i<n.length;i++)r[i]={key:n[i],value:br(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}const vr="undefined"!=typeof BigInt?function(e){const t=function(e){const t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}(e);return t.toString()}:function(e){return e[0]*Vt+e[1]};function _r(e){return e}const xr={encodeHrTime:vr,encodeSpanContext:_r,encodeOptionalSpanContext:_r,encodeUint8Array:e=>{if("undefined"!=typeof Buffer)return Buffer.from(e).toString("base64");const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return btoa(t.join(""))}};function yr(e,t){let n=255&e|256;return t&&(n|=512),n}function wr(e,t){const n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:null==e.kind?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:mr(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>function(e,t){return{attributes:e.attributes?mr(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>function(e,t){return{attributes:e.attributes?mr(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:yr(e.context.traceFlags,e.context.isRemote)}}(e,t)),droppedLinksCount:e.droppedLinksCount,flags:yr(n.traceFlags,e.parentSpanContext?.isRemote)}}function kr(e,t){const n=function(e){const t=new Map;for(const n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));const r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||""}:${n.instrumentationScope.schemaUrl||""}`;let i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}(e),r=[],i=n.entries();let a=i.next();for(;!a.done;){const[e,n]=a.value,l=[],o=n.values();let s=o.next();for(;!s.done;){const e=s.value;if(e.length>0){const n=e.map(e=>wr(e,t));l.push({scope:fr(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}s=o.next()}const c=gr(e,t),p={resource:c,scopeSpans:l,schemaUrl:c.schemaUrl};r.push(p),a=i.next()}return r}const Sr={serializeRequest:e=>{const t=function(e,t){return{resourceSpans:kr(e,t)}}(e,xr);return(new TextEncoder).encode(JSON.stringify(t))},deserializeResponse:e=>{if(0===e.length)return{};const t=new TextDecoder;return JSON.parse(t.decode(e))}};function Cr(){return.4*Math.random()-.2}class Pr{_transport;constructor(e){this._transport=e}retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}async send(e,t){let n=5,r=1e3;const i=Date.now()+t;let a=await this._transport.send(e,t);for(;"retryable"===a.status&&n>0;){n--;const t=Math.max(Math.min(r*(1+Cr()),5e3),0);r*=1.5;const l=a.retryInMillis??t,o=i-Date.now();if(l>o)return ut.info(`Export retry time ${Math.round(l)}ms exceeds remaining timeout ${Math.round(o)}ms, not retrying further.`),a;ut.verbose(`Scheduling export retry in ${Math.round(l)}ms`),a=await this.retry(e,o,l)}return"success"===a.status?ut.verbose(`Export succeeded after ${5-n} retry attempts.`):"retryable"===a.status?ut.info("Export failed after maximum retry attempts (5)."):ut.info(`Export failed with non-retryable error: ${a.error}`),a}shutdown(){return this._transport.shutdown()}}function Er(e){return new Pr(e.transport)}class Tr{_params;constructor(e){this._params=e}async send(e){const t=(await this._params.headers())["Content-Type"];return new Promise(n=>{navigator.sendBeacon(this._params.url,new Blob([e],{type:t}))?(ut.debug("SendBeacon success"),n({status:"success"})):n({status:"failure",error:new Error("SendBeacon failed")})})}shutdown(){}}class zr{_parameters;constructor(e){this._parameters=e}async send(e,t){const n=new AbortController,r=setTimeout(()=>n.abort(),t);let i=globalThis.fetch;"function"==typeof i.__original&&(i=i.__original);try{const t=!!globalThis.location,r=new URL(this._parameters.url),l=await i(r.href,{method:"POST",headers:await this._parameters.headers(),body:e,signal:n.signal,keepalive:t,mode:t?globalThis.location?.origin===r.origin?"same-origin":"cors":"no-cors"});if(l.status>=200&&l.status<=299)return ut.debug("response success"),{status:"success"};if(429===(a=l.status)||502===a||503===a||504===a){const e=function(e){if(null==e)return;const t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?1e3*t:-1;const n=new Date(e).getTime()-Date.now();return n>=0?n:0}(l.headers.get("Retry-After"));return{status:"retryable",retryInMillis:e}}return{status:"failure",error:new Error("Fetch request failed with non-retryable status")}}catch(e){return function(e){return e instanceof TypeError&&!e.cause}(e)?{status:"retryable",error:new Error("Fetch request encountered a network error",{cause:e})}:{status:"failure",error:new Error("Fetch request errored",{cause:e})}}finally{clearTimeout(r)}var a}shutdown(){}}function Rr(e,t){return hr(e,t,Er({transport:(n=e,new zr(n))}));var n}function Ir(e,t){return hr(e,t,Er({transport:(n={url:e.url,headers:e.headers},new Tr(n))}));var n}function Ar(e,t,n){return async()=>{const r={...await n()},i={};return null!=t&&Object.assign(i,await t()),null!=e&&Object.assign(i,function(e){const t={};return Object.entries(e??{}).forEach(([e,n])=>{void 0!==n?t[e]=String(n):ut.warn(`Header "${e}" has invalid value (${n}) and will be ignored`)}),t}(await e())),Object.assign(i,r)}}function Mr(e){if(null!=e)try{const t=globalThis.location?.href;return new URL(e,t).href}catch{throw new Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function $r(e){return"function"==typeof e.headers?e.headers:function(e){if(null!=e)return async()=>e}(e.headers)}function Lr(e,t,n){return r={url:e.url,timeoutMillis:e.timeoutMillis,headers:$r(e),concurrencyLimit:e.concurrencyLimit},i={},a=function(e,t){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none",headers:async()=>e,url:"http://localhost:4318/"+t}}(n,t),{...sr(r,i,a),headers:Ar(r.headers,i.headers,a.headers),url:Mr(r.url)??i.url??a.url};var r,i,a}function Or(e,t,n,r){return function(e){if(!e&&"function"==typeof navigator.sendBeacon)return Ir;return Rr}(e.headers)(Lr(e,n,r),t)}class Dr extends ar{constructor(e={}){super(Or(e,Sr,"v1/traces",{"Content-Type":"application/json"}))}}let jr=null,Hr=null;function Nr(){return Hr??St.getTracer("pillar-sdk")}function Ur(e){const t=function(){const e=St.getActiveSpan();if(!e)return;const t=e.spanContext();if(!t)return;return`00-${t.traceId}-${t.spanId}-${t.traceFlags.toString(16).padStart(2,"0")}`}();return t&&(e.traceparent=t),e}class Br{constructor(e){this.requestId=0,this._externalUserId="",this.config=e}setExternalUserId(e){this._externalUserId=e}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_mcp_session_id";try{let t=sessionStorage.getItem(e);return t||(t=crypto.randomUUID(),sessionStorage.setItem(e,t)),t}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get baseUrl(){return`${this.config.apiBaseUrl}/mcp/`}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey,"x-visitor-id":this.getVisitorId(),"x-page-url":this.getPageUrl()},t=this.getSessionId();return t&&(e["Mcp-Session-Id"]=t),this._externalUserId&&(e["x-external-user-id"]=this._externalUserId),"undefined"!=typeof navigator&&(e["Accept-Language"]=navigator.language||navigator.languages?.[0]||"en"),this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),null!==jr&&Ur(e),e}nextId(){return++this.requestId}async callTool(e,t){const n=performance.now(),r={jsonrpc:"2.0",id:this.nextId(),method:"tools/call",params:{name:e,arguments:t}};o.add({event:"network:request",data:{method:"tools/call",tool:e,url:this.baseUrl},source:"network",level:"info"});const i=await te(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(r),maxRetries:3,onRetry:(t,n)=>{p.log(`[MCPClient] Retrying callTool "${e}" (attempt ${t+1}) after ${n}ms...`)}}),a=Math.round(performance.now()-n);if(!i.ok){const e=await i.json().catch(()=>({}));throw o.add({event:"network:response",data:{status:i.status,duration:a,error:e.error?.message},source:"network",level:"error"}),new Error(e.error?.message||`MCP error: ${i.status}`)}const l=await i.json();if(o.add({event:"network:response",data:{status:i.status,duration:a,method:"tools/call",tool:e},source:"network",level:"info"}),l.error)throw new Error(l.error.message);return l.result}async callToolStream(e,t,n,r){const i=performance.now(),a=this.nextId();n.onRequestId?.(a);const l=Nr().startSpan("mcp.call_tool_stream",{attributes:{"mcp.tool":e,"mcp.request_id":a}}),s={jsonrpc:"2.0",id:a,method:"tools/call",params:{name:e,arguments:t,stream:!0}};o.add({event:"network:request",data:{method:"tools/call",tool:e,stream:!0,url:this.baseUrl},source:"network",level:"info"});const c=await te(this.baseUrl,{method:"POST",headers:{...this.headers,Accept:"text/event-stream"},body:JSON.stringify(s),signal:r,maxRetries:3,onRetry:(t,n)=>{p.log(`[MCPClient] Retrying stream connection for "${e}" (attempt ${t+1}) after ${n}ms...`)}}),d=Math.round(performance.now()-i);if(!c.ok){const e=await c.text();throw o.add({event:"network:response",data:{status:c.status,duration:d,error:e},source:"network",level:"error"}),new Error(`MCP streaming request failed: ${c.statusText} - ${e}`)}if(o.add({event:"network:stream:connected",data:{status:c.status,connectionTime:d,tool:e},source:"network",level:"info"}),!c.body)throw new Error("Response body is null");const u=c.body.getReader(),h=new TextDecoder;let g="",f=[],m=null;try{for(;;){const{done:e,value:t}=await u.read();if(e)break;g+=h.decode(t,{stream:!0});const r=g.split("\n");g=r.pop()||"";for(const e of r)if(e.trim()&&e.startsWith("data: "))try{const t=e.substring(6),r=JSON.parse(t);if("2.0"===r.jsonrpc){if(r.error){const e=r.error.data;n.onError?.(r.error.message||"Unknown error",e);const t=new Error(r.error.message);throw t.data=e,t}if("notifications/progress"===r.method){const e=r.params?.progress;if(e){if("debug"===e.type){o.add({event:e.event||"server:event",data:e.data,source:"server",level:"info"});continue}if("progress"===e.type&&e.data){const t=e.data;p.log(`[MCPClient] Progress event (new schema): ${t.kind}`,t),n.onProgress?.({kind:t.kind,id:t.id,label:t.label,status:t.status,text:t.text,children:t.children,metadata:t.metadata});continue}if("token"!==e.kind&&"token"!==e.type&&(console.log(`[MCPClient] Progress event: kind=${e.kind} type=${e.type}`,e),p.log(`[MCPClient] Progress event: ${e.kind}`,e)),"token"===e.kind&&e.token)f.push(e.token),n.onToken?.(e.token);else if("conversation_started"===e.kind)n.onConversationStarted?.(e.conversation_id,e.assistant_message_id);else if("token_usage"===e.kind)n.onTokenUsage?.({prompt_tokens:e.prompt_tokens,completion_tokens:e.completion_tokens,total_prompt_tokens:e.total_prompt_tokens,total_completion_tokens:e.total_completion_tokens,total_used:e.total_used,context_window:e.context_window,occupancy_pct:e.occupancy_pct,model_name:e.model_name,iteration:e.iteration});else{if("cancelled"===e.kind)break;if("action_request"===e.kind||"action_request"===e.type){if(console.log("[MCPClient] *** RECEIVED tool_request ***",e.action_name,e.parameters),p.log("[MCPClient] Received tool_request:",e.action_name,e.parameters),!e.action_name||"string"!=typeof e.action_name||""===e.action_name.trim()){console.error("[MCPClient] tool_request INVALID - missing action_name:",e),p.error("[MCPClient] Received tool_request with missing or invalid action_name:",e);continue}const t=n.onToolRequest||n.onActionRequest;if(t){console.log("[MCPClient] *** CALLING tool request handler ***"),e.tool_call_id||(console.warn("[MCPClient] tool_request missing tool_call_id - result correlation may fail"),p.warn("[MCPClient] tool_request missing tool_call_id for tool:",e.action_name));t({action_name:e.action_name,parameters:e.parameters||{},action:e.action,tool_call_id:e.tool_call_id}).catch(e=>{console.error("[MCPClient] Tool request handler FAILED:",e),p.error("[MCPClient] Tool request handler failed:",e)})}else console.warn("[MCPClient] tool_request received but NO HANDLER registered"),p.warn("[MCPClient] Received tool_request but no handler registered")}else n.onProgress?.({kind:e.kind,id:e.id,label:e.label,status:e.status,text:e.text||e.content,children:e.children,message:e.message,progress_id:e.progress_id,metadata:{...e.metadata,...null!=e.sources&&{sources:e.sources},...null!=e.result_count&&{result_count:e.result_count},...null!=e.query&&{query:e.query},...null!=e.action_name&&{action_name:e.action_name},...null!=e.no_sources_used&&{no_sources_used:e.no_sources_used}}})}}}if(r.result&&r.id===a){m=r.result,m.structuredContent?.sources&&n.onSources?.(m.structuredContent.sources);const e=m.structuredContent?.tools||m.structuredContent?.actions;e&&(n.onTools?.(e),n.onActions?.(e));const t=m.structuredContent?.registered_tools||m.structuredContent?.registered_actions;t&&(n.onRegisteredTools?.(t),n.onRegisteredActions?.(t));const i=m._meta?.conversation_id,a=m._meta?.query_log_id;n.onComplete?.(i,a)}}}catch(t){p.error("[MCPClient] Failed to parse event:",t,e)}}}catch(e){if(l.setStatus({code:lt.ERROR,message:e.message}),"AbortError"===e.name)throw l.setAttribute("mcp.cancelled",!0),l.end(),e;const t=e instanceof Error?e.message:"Stream reading failed";throw n.onProgress?.({kind:"error",id:"stream-error",label:"Connection interrupted",status:"error",text:t,metadata:{error:t}}),n.onError?.(t),l.end(),e}finally{u.releaseLock();const t=Math.round(performance.now()-i);l.setAttribute("mcp.duration_ms",t),l.end(),o.add({event:"network:stream:complete",data:{duration:t,tool:e},source:"network",level:"info"})}return m||(m={content:[{type:"text",text:f.join("")}],isError:!1}),m}async uploadImage(e){const t=`${this.config.apiBaseUrl}/mcp/upload-image/`,n=new FormData;n.append("image",e);const r=await te(t,{method:"POST",headers:{"x-customer-id":this.config.productKey},body:n,maxRetries:3,onRetry:(e,t)=>{p.log(`[MCPClient] Retrying image upload (attempt ${e+1}) after ${t}ms...`)}});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,t,n){const r={query:e};n?.conversationId&&(r.conversation_id=n.conversationId),n?.articleSlug&&(r.article_slug=n.articleSlug),n?.userContext&&n.userContext.length>0&&(r.user_context=n.userContext),n?.images&&n.images.length>0&&(r.images=n.images),n?.history&&n.history.length>0&&(r.history=n.history);const i=n?.registeredTools||n?.registeredActions;return i&&i.length>0&&(r.registered_actions=i),n?.resume&&(r.resume=!0),this.callToolStream("ask",r,t,n?.signal)}async cancelStream(e){const t={jsonrpc:"2.0",id:this.nextId(),method:"notifications/cancel",params:{request_id:e}};p.log(`[MCPClient] Cancelling stream request_id=${e}`);try{await te(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t),keepalive:!0,maxRetries:3,onRetry:(e,t)=>{p.log(`[MCPClient] Retrying cancel request (attempt ${e+1}) after ${t}ms...`)}})}catch(e){p.warn("[MCPClient] Failed to send cancel request:",e)}}async sendToolResult(e,t,n){const r=performance.now(),i=Nr().startSpan("mcp.send_tool_result",{attributes:{"mcp.tool":e,"mcp.tool_call_id":n||""}});n||(console.warn(`[MCPClient] sendToolResult called without toolCallId for tool "${e}" - server will not be able to correlate result`),p.warn("[MCPClient] Missing toolCallId in sendToolResult for:",e));const a={jsonrpc:"2.0",id:this.nextId(),method:"action/result",params:{action_name:e,result:t,tool_call_id:n}};o.add({event:"network:request",data:{method:"action/result",tool:e,tool_call_id:n,url:this.baseUrl},source:"network",level:"info"}),p.log(`[MCPClient] Sending tool result for "${e}"...`),await new Promise(e=>setTimeout(e,0));try{const t=await te(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(a),keepalive:!0,maxRetries:6,onRetry:(t,n)=>{p.log(`[MCPClient] Retrying tool result for "${e}" (attempt ${t+1}) after ${n}ms...`),o.add({event:"network:retry",data:{method:"action/result",action:e,attempt:t+1,delay:n},source:"network",level:"warn"})}}),n=Math.round(performance.now()-r);if(!t.ok){const r=await t.text().catch(()=>"");throw o.add({event:"network:response",data:{status:t.status,duration:n,tool:e,error:r},source:"network",level:"error"}),p.error(`[MCPClient] Tool result delivery failed: ${t.status} ${t.statusText}`,r),new Error(`Failed to send tool result: ${t.status}`)}o.add({event:"network:response",data:{status:t.status,duration:n,tool:e},source:"network",level:"info"}),p.log(`[MCPClient] Tool result for "${e}" delivered in ${n}ms`),i.setAttribute("mcp.duration_ms",n),i.end()}catch(t){const n=Math.round(performance.now()-r);throw i.setStatus({code:lt.ERROR,message:t.message}),i.end(),p.error(`[MCPClient] Failed to send tool result for "${e}" after ${n}ms:`,t),t}}async sendActionResult(e,t,n){return this.sendToolResult(e,t,n)}async sendLog(e,t,n){const r={jsonrpc:"2.0",id:this.nextId(),method:"client/log",params:{level:e,message:t,data:n,timestamp:(new Date).toISOString()}};try{fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(r),keepalive:!0}).catch(()=>{})}catch{}}sendLogBatch(e){if(0===e.length)return;const t={jsonrpc:"2.0",id:this.nextId(),method:"client/log-batch",params:{logs:e}};try{fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}async getConversationStatus(e){try{const t=await te(`${this.baseUrl}conversations/${e}/status/`,{method:"GET",headers:this.headers,maxRetries:3,onRetry:(e,t)=>{p.log(`[MCPClient] Retrying conversation status check (attempt ${e+1}) after ${t}ms...`)}});if(!t.ok)return p.warn(`[MCPClient] Failed to get conversation status: ${t.status}`),null;return await t.json()}catch(e){return p.warn("[MCPClient] Error getting conversation status:",e),null}}}function Fr(e){return{id:e.id,name:e.name,taskType:e.action_type,data:e.data,autoRun:e.auto_run,autoComplete:e.auto_complete}}const qr=Fr;class Wr{constructor(e){this.abortControllers=new Map,this._externalUserId=null,this.config=e,this.mcpClient=new Br(e)}get mcp(){return this.mcpClient}get baseUrl(){return`${this.config.apiBaseUrl}/api/v1/help-center`}setExternalUserId(e){this._externalUserId=e,this.mcpClient.setExternalUserId(e)}clearExternalUserId(){this._externalUserId=null,this.mcpClient.setExternalUserId("")}regenerateVisitorId(){if("undefined"==typeof window)return;try{const e=crypto.randomUUID();localStorage.setItem("pillar_visitor_id",e)}catch{}}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_session_id";try{let t=sessionStorage.getItem(e);return t||(t=crypto.randomUUID(),sessionStorage.setItem(e,t)),t}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey,"x-visitor-id":this.getVisitorId(),"x-session-id":this.getSessionId(),"x-page-url":this.getPageUrl()};return this._externalUserId&&(e["x-external-user-id"]=this._externalUserId),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,t={},n){if(n){this.abortControllers.get(n)?.abort();const e=new AbortController;this.abortControllers.set(n,e),t.signal=e.signal}const r=`${this.baseUrl}${e}`;try{const n=await te(r,{...t,headers:{...this.headers,...t.headers},maxRetries:3,onRetry:(t,n)=>{p.log(`[Pillar API] Retrying ${e} (attempt ${t+1}) after ${n}ms...`)}});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.detail||e.message||`API error: ${n.status}`)}return n.json()}catch(t){if("AbortError"===t.name)throw t;throw p.error(`[Pillar API] Error fetching ${e}:`,t),t}finally{n&&this.abortControllers.delete(n)}}async fetchEmbedConfig(){try{const e=await te(`${this.config.apiBaseUrl}/api/public/products/${this.config.productKey}/embed-config/`,{method:"GET",headers:{"Content-Type":"application/json"},maxRetries:3,onRetry:(e,t)=>{p.log(`[Pillar] Retrying embed config fetch (attempt ${e+1}) after ${t}ms...`)}});return e.ok?await e.json():(p.warn("[Pillar] Failed to fetch embed config:",e.status),null)}catch(e){return p.warn("[Pillar] Failed to fetch embed config:",e),null}}async getSuggestedQuestions(){try{const e=await this.mcpClient.callTool("suggest_questions",{}),t=e.structuredContent?.questions;return Array.isArray(t)?t:[]}catch(e){return p.warn("[Pillar] Failed to get suggested questions:",e),[]}}async uploadImage(e){return this.mcpClient.uploadImage(e)}async chat(e){let t="",n=[],r=[];const{getRegisteredActions:i,setRegisteredActions:a,updateTokenUsage:l}=await Promise.resolve().then(function(){return lo});try{const o=await this.mcpClient.ask(e.message,{onToken:n=>{t+=n,e.onChunk?.(n)},onSources:e=>{n=e},onActions:t=>{r=t.map(qr),e.onActions?.(r)},onProgress:t=>{e.onProgress?.(t)},onConversationStarted:(t,n)=>{e.onConversationStarted?.(t,n)},onActionRequest:async t=>{e.onActionRequest&&await e.onActionRequest(t)},onRegisteredActions:e=>{a(e),p.log("[Pillar API] Stored",e.length,"registered actions for dynamic tool calling")},onRequestId:t=>{e.onRequestId?.(t)},onTokenUsage:e=>{l({promptTokens:e.prompt_tokens,completionTokens:e.completion_tokens,totalPromptTokens:e.total_prompt_tokens,totalCompletionTokens:e.total_completion_tokens,totalUsed:e.total_used,contextWindow:e.context_window,occupancyPct:e.occupancy_pct,modelName:e.model_name,iteration:e.iteration})},onError:e=>{p.error("[Pillar API] MCP chat error:",e)}},{articleSlug:e.articleSlug,userContext:e.userContext,images:e.images,history:e.history,registeredActions:i(),conversationId:e.existingConversationId||void 0,signal:e.signal,resume:e.resume});t||"text"!==o.content[0]?.type||(t=o.content[0].text||"");const s=o._meta||{};return{message:t,sources:n,actions:r,conversationId:s.conversation_id,messageId:s.query_log_id}}catch(e){throw p.error("[Pillar API] Chat error:",e),e}}async submitFeedback(e,t,n){try{await this.fetch("/ai/feedback/",{method:"POST",body:JSON.stringify({message_id:e,feedback:t,...n&&{comment:n}})})}catch(e){p.warn("[Pillar] Feedback submission failed:",e)}}async confirmTaskExecution(e,t,n){try{const r={status:t,error:n?.error,duration_ms:n?.duration_ms,session_id:n?.session_id,conversation_id:n?.conversation_id,metadata:n};await this.fetch(`/tasks/${e}/confirm/`,{method:"POST",body:JSON.stringify(r)})}catch(e){p.warn("[Pillar] Failed to confirm task execution:",e)}}async trackWebMCPExecution(e,t,n){try{const r=`${this.config.apiBaseUrl}/mcp/track-webmcp-execution/`;await te(r,{method:"POST",headers:this.headers,body:JSON.stringify({tool_name:e,status:t,duration_ms:n?.duration_ms,error:n?.error,input:n?.input,session_id:this.getSessionId(),visitor_id:this.getVisitorId()}),maxRetries:1})}catch(e){p.warn("[Pillar] Failed to track WebMCP execution:",e)}}async getSuggestions(e,t){try{return(await this.fetch("/suggestions/",{method:"POST",body:JSON.stringify({context:e,user_profile:t})})).suggestions||[]}catch(e){return p.warn("[Pillar] Failed to get suggestions:",e),[]}}async identify(e,t){const n=`${this.config.apiBaseUrl}/mcp/identify/`,r=await te(n,{method:"POST",headers:this.headers,body:JSON.stringify({userId:e,name:t?.name,email:t?.email,metadata:t?.metadata}),maxRetries:3,onRetry:(e,t)=>{p.log(`[Pillar] Retrying identify (attempt ${e+1}) after ${t}ms...`)}});if(!r.ok){const e=await r.json().catch(()=>({}));throw new Error(e.error||`Identify failed: ${r.status}`)}}async listConversations(e=20){const t=`${this.config.apiBaseUrl}/mcp/conversations/?limit=${Math.min(e,50)}`;try{const e=await fetch(t,{method:"GET",headers:this.headers});if(!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`Failed to list conversations: ${e.status}`)}return(await e.json()).conversations||[]}catch(e){return p.warn("[Pillar] Failed to list conversations:",e),[]}}async getConversation(e){const t=`${this.config.apiBaseUrl}/mcp/conversations/${e}/`;try{const e=await fetch(t,{method:"GET",headers:this.headers});if(!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`Failed to get conversation: ${e.status}`)}return await e.json()}catch(e){return p.warn("[Pillar] Failed to get conversation:",e),null}}cancelAllRequests(){this.abortControllers.forEach(e=>e.abort()),this.abortControllers.clear()}}var Vr=0;function Kr(e,t,n,r,i,a){t||(t={});var l,o,s=t;if("ref"in s)for(o in s={},t)"ref"==o?l=t[o]:s[o]=t[o];var c={type:e,props:s,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Vr,__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(c),c}var Gr,Qr,Jr,Xr,Zr=0,Yr=[],ei=g,ti=ei.__b,ni=ei.__r,ri=ei.diffed,ii=ei.__c,ai=ei.unmount,li=ei.__;function oi(e,t){ei.__h&&ei.__h(Qr,e,Zr||t),Zr=0;var n=Qr.__H||(Qr.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function si(e){return Zr=1,function(e,t){var n=oi(Gr++,2);if(n.t=e,!n.__c&&(n.__=[_i(void 0,t),function(e){var t=n.__N?n.__N[0]:n.__[0],r=n.t(t,e);t!==r&&(n.__N=[r,n.__[1]],n.__c.setState({}))}],n.__c=Qr,!Qr.__f)){var r=function(e,t,r){if(!n.__c.__H)return!0;var a=n.__c.__H.__.filter(function(e){return!!e.__c});if(a.every(function(e){return!e.__N}))return!i||i.call(this,e,t,r);var l=n.__c.props!==e;return a.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(l=!0)}}),i&&i.call(this,e,t,r)||l};Qr.__f=!0;var i=Qr.shouldComponentUpdate,a=Qr.componentWillUpdate;Qr.componentWillUpdate=function(e,t,n){if(this.__e){var l=i;i=void 0,r(e,t,n),i=l}a&&a.call(this,e,t,n)},Qr.shouldComponentUpdate=r}return n.__N||n.__}(_i,e)}function ci(e,t){var n=oi(Gr++,3);!ei.__s&&vi(n.__H,t)&&(n.__=e,n.u=t,Qr.__H.__h.push(n))}function pi(e){return Zr=5,di(function(){return{current:e}},[])}function di(e,t){var n=oi(Gr++,7);return vi(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ui(e,t){return Zr=8,di(function(){return e},t)}function hi(){for(var e;e=Yr.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(mi),e.__H.__h.forEach(bi),e.__H.__h=[]}catch(t){e.__H.__h=[],ei.__e(t,e.__v)}}ei.__b=function(e){Qr=null,ti&&ti(e)},ei.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),li&&li(e,t)},ei.__r=function(e){ni&&ni(e),Gr=0;var t=(Qr=e.__c).__H;t&&(Jr===Qr?(t.__h=[],Qr.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(mi),t.__h.forEach(bi),t.__h=[],Gr=0)),Jr=Qr},ei.diffed=function(e){ri&&ri(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==Yr.push(t)&&Xr===ei.requestAnimationFrame||((Xr=ei.requestAnimationFrame)||fi)(hi)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Jr=Qr=null},ei.__c=function(e,t){t.some(function(e){try{e.__h.forEach(mi),e.__h=e.__h.filter(function(e){return!e.__||bi(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],ei.__e(n,e.__v)}}),ii&&ii(e,t)},ei.unmount=function(e){ai&&ai(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{mi(e)}catch(e){t=e}}),n.__H=void 0,t&&ei.__e(t,n.__v))};var gi="function"==typeof requestAnimationFrame;function fi(e){var t,n=function(){clearTimeout(r),gi&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);gi&&(t=requestAnimationFrame(n))}function mi(e){var t=Qr,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Qr=t}function bi(e){var t=Qr;e.__c=e.__(),Qr=t}function vi(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function _i(e,t){return"function"==typeof t?t(e):t}var xi=Symbol.for("preact-signals");function yi(){if(Ei>1)Ei--;else{for(var e,t=!1;void 0!==Pi;){var n=Pi;for(Pi=void 0,Ti++;void 0!==n;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Mi(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(Ti=0,Ei--,t)throw e}}var wi=void 0;function ki(e){var t=wi;wi=void 0;try{return e()}finally{wi=t}}var Si,Ci,Pi=void 0,Ei=0,Ti=0,zi=0;function Ri(e){if(void 0!==wi){var t=e.n;if(void 0===t||t.t!==wi)return t={i:0,S:e,p:wi.s,n:void 0,t:wi,e:void 0,x:void 0,r:t},void 0!==wi.s&&(wi.s.n=t),wi.s=t,e.n=t,32&wi.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=wi.s,t.n=void 0,wi.s.n=t,wi.s=t),t}}function Ii(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Ai(e,t){return new Ii(e,t)}function Mi(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function $i(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function Li(e){for(var t=e.s,n=void 0;void 0!==t;){var r=t.p;-1===t.i?(t.S.U(t),void 0!==r&&(r.n=t.n),void 0!==t.n&&(t.n.p=r)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=r}e.s=n}function Oi(e,t){Ii.call(this,void 0),this.x=e,this.s=void 0,this.g=zi-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Di(e,t){return new Oi(e,t)}function ji(e){var t=e.u;if(e.u=void 0,"function"==typeof t){Ei++;var n=wi;wi=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Hi(e),t}finally{wi=n,yi()}}}function Hi(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ji(e)}function Ni(e){if(wi!==this)throw new Error("Out-of-order effect");Li(this),wi=e,this.f&=-2,8&this.f&&Hi(this),yi()}function Ui(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function Bi(e,t){var n=new Ui(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function Fi(e,t){g[e]=t.bind(null,g[e]||function(){})}function qi(e){Ci&&Ci(),Ci=e&&e.S()}function Wi(e){var t=this,n=e.data,r=function(e){return di(function(){return Ai(e)},[])}(n);r.value=n;var i=di(function(){for(var e=t.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return t.__$u.c=function(){var e,n=t.__$u.S(),r=i.value;n(),m(r)||3!==(null==(e=t.base)?void 0:e.nodeType)?(t.__$f|=1,t.setState({})):t.base.data=r},Di(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Vi(e,t,n,r){var i=t in e&&void 0===e.ownerSVGElement,a=Ai(n);return{o:function(e,t){a.value=e,r=t},d:Bi(function(){var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n?e.setAttribute(t,n):e.removeAttribute(t))})}}function Ki(e){var t=pi(e);return t.current=e,Si.__$f|=4,di(function(){return Di(function(){return t.current()})},[])}Ii.prototype.brand=xi,Ii.prototype.h=function(){return!0},Ii.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:ki(function(){var e;null==(e=t.W)||e.call(t)}))},Ii.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,r=e.x;void 0!==n&&(n.x=r,e.e=void 0),void 0!==r&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&ki(function(){var e;null==(e=t.Z)||e.call(t)}))}},Ii.prototype.subscribe=function(e){var t=this;return Bi(function(){var n=t.value,r=wi;wi=void 0;try{e(n)}finally{wi=r}},{name:"sub"})},Ii.prototype.valueOf=function(){return this.value},Ii.prototype.toString=function(){return this.value+""},Ii.prototype.toJSON=function(){return this.value},Ii.prototype.peek=function(){var e=wi;wi=void 0;try{return this.value}finally{wi=e}},Object.defineProperty(Ii.prototype,"value",{get:function(){var e=Ri(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ti>100)throw new Error("Cycle detected");this.v=e,this.i++,zi++,Ei++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{yi()}}}}),Oi.prototype=new Ii,Oi.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===zi)return!0;if(this.g=zi,this.f|=1,this.i>0&&!Mi(this))return this.f&=-2,!0;var e=wi;try{$i(this),wi=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return wi=e,Li(this),this.f&=-2,!0},Oi.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}Ii.prototype.S.call(this,e)},Oi.prototype.U=function(e){if(void 0!==this.t&&(Ii.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},Oi.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(Oi.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ri(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ui.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},Ui.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ji(this),$i(this),Ei++;var e=wi;return wi=this,Ni.bind(this,e)},Ui.prototype.N=function(){2&this.f||(this.f|=2,this.o=Pi,Pi=this)},Ui.prototype.d=function(){this.f|=8,1&this.f||Hi(this)},Ui.prototype.dispose=function(){this.d()},Wi.displayName="_st",Object.defineProperties(Ii.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Wi},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Fi("__b",function(e,t){if("string"==typeof t.type){var n,r=t.props;for(var i in r)if("children"!==i){var a=r[i];a instanceof Ii&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),Fi("__r",function(e,t){qi();var n,r=t.__c;r&&(r.__$f&=-2,void 0===(n=r.__$u)&&(r.__$u=n=function(){var e;return Bi(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),Si=r,qi(n),e(t)}),Fi("__e",function(e,t,n,r){qi(),Si=void 0,e(t,n,r)}),Fi("diffed",function(e,t){var n;if(qi(),Si=void 0,"string"==typeof t.type&&(n=t.__e)){var r=t.__np,i=t.props;if(r){var a=n.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 n.U=a={};for(var s in r){var c=a[s],p=r[s];void 0===c?(c=Vi(n,s,p,i),a[s]=c):c.o(p,i)}}}e(t)}),Fi("unmount",function(e,t){if("string"==typeof t.type){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}}else{var l=t.__c;if(l){var o=l.__$u;o&&(l.__$u=void 0,o.d())}}e(t)}),Fi("__h",function(e,t,n,r){(r<3||9===r)&&(t.__$f|=2),e(t,n,r)}),L.prototype.shouldComponentUpdate=function(e,t){var n=this.__$u,r=n&&void 0!==n.s;for(var i in t)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 Gi="pillar:panel_open",Qi="pillar:panel_width";function Ji(e){if("undefined"!=typeof window)try{localStorage.setItem(Gi,String(e))}catch{}}function Xi(){if("undefined"==typeof window)return null;try{const e=localStorage.getItem(Qi);if(null===e)return null;const t=Number(e);return Number.isFinite(t)&&t>0?t:null}catch{return null}}function Zi(e){if("undefined"!=typeof window)try{localStorage.setItem(Qi,String(e))}catch{}}const Yi=Ai(function(){if("undefined"==typeof window)return!1;try{return"true"===localStorage.getItem(Gi)}catch{return!1}}()),ea=Ai("assistant"),ta=Ai("right"),na=Ai("overlay"),ra=Ai(380),ia=Ai(1200),aa=Ai(!0),la=Ai(700),oa=Ai(500),sa=Ai("undefined"!=typeof window?window.innerWidth:1920);let ca=null;const pa=Di(()=>{const e=ia.value;return!1!==e&&sa.value<e}),da=Di(()=>sa.value<la.value),ua=Di(()=>sa.value<oa.value),ha=Di(()=>pa.value?"overlay":na.value);Di(()=>{const e=["pillar-panel",`pillar-panel--${ta.value}`];return Yi.value&&e.push("pillar-panel--open"),e.join(" ")});const ga=()=>{Yi.value=!1,Ji(!1),"overlay"===ha.value&&(document.body.style.overflow="")},fa=e=>{ra.value=e},ma=()=>{Yi.value=!1,Ji(!1),ea.value="assistant",document.body.style.overflow=""};function ba(e,t,n){const r=document.createElement("style");return n&&(r.id=n),r.textContent=t,e instanceof Document?e.head.appendChild(r):e.appendChild(r),r}const va={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>',tools:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path></svg>'},_a={assistant:va.help,support:va.support,tools:va.tools};function xa({position:e,tabs:t,currentActiveTab:n,onTabClick:r,panelOpen:i,panelWidthPx:a,theme:l,resizable:o,isResizing:s,onResizeStart:c}){const p=ui(e=>{r(e)},[r]),d=["pillar-edge-sidebar",`pillar-edge-sidebar--${e}`,"pillar-edge-sidebar--mounted",i&&"pillar-edge-sidebar--panel-open",s&&"pillar-edge-sidebar--resizing","light"===l&&"pillar-edge-sidebar--light","dark"===l&&"pillar-edge-sidebar--dark"].filter(Boolean).join(" "),u={"--pillar-panel-width":`${a}px`},h=t.filter(e=>e.enabled).sort((e,t)=>e.order-t.order);return Kr("div",{class:d,style:u,children:[o&&i&&Kr("div",{class:"pillar-edge-resize-handle",onMouseDown:c,onTouchStart:c}),h.map(e=>{return Kr("button",{class:["pillar-edge-trigger",i&&n===e.id&&"pillar-edge-trigger--active"].filter(Boolean).join(" "),onClick:()=>p(e.id),"aria-label":e.label||"Help",type:"button",children:[Kr("span",{class:"pillar-edge-trigger__icon",dangerouslySetInnerHTML:{__html:(t=e.id,r=e.icon,r&&r in va?va[r]:_a[t]||va.help)}}),Kr("span",{class:"pillar-edge-trigger__label",children:e.label})]},e.id);var t,r})]})}class ya{constructor(e,t,n,r){this.container=null,this.stylesInjected=!1,this.themeStylesInjected=!1,this._isHidden=!1,this.unsubscribeOpen=null,this.unsubscribeWidth=null,this.unsubscribeHoverMode=null,this.unsubscribeMobileMode=null,this.unsubscribeActiveTab=null,this.themeObserver=null,this.currentTheme="light",this._isResizing=!1,this._resizeStartX=0,this._resizeStartWidth=0,this._resizeRafId=null,this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,this.handleTabClick=e=>{if(!["assistant","tools"].includes(e)){const t=this.config.sidebarTabs.find(t=>t.id===e);return this.events.emit("sidebar:click",{tabId:e,label:t?.label||e}),void("support"===e&&this.events.emit("support:request",{tabId:e}))}if(Yi.value&&ea.value===e)return this.onClick(),void this.render();(e=>{ea.value=e})(e),Yi.value||this.onClick(),this.render()},this.handleResizeStart=e=>{if(!Yi.value||!this.config.panel.resizable||!this.config.edgeTrigger.resizable)return;e.preventDefault(),e.stopPropagation();const t="touches"in e?e.touches[0].clientX:e.clientX;this._isResizing=!0,this._resizeStartX=t,this._resizeStartWidth=ra.value,this._boundHandleResizeMove=this.handleResizeMove.bind(this),this._boundHandleResizeEnd=this.handleResizeEnd.bind(this),document.addEventListener("mousemove",this._boundHandleResizeMove),document.addEventListener("mouseup",this._boundHandleResizeEnd),document.addEventListener("touchmove",this._boundHandleResizeMove,{passive:!1}),document.addEventListener("touchend",this._boundHandleResizeEnd),document.addEventListener("touchcancel",this._boundHandleResizeEnd),document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",document.documentElement.style.cursor="col-resize",document.documentElement.style.transition="none",this.render()},this.handleResizeEnd=e=>{this._isResizing&&(null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this._isResizing=!1,Zi(ra.value),this._boundHandleResizeMove&&(document.removeEventListener("mousemove",this._boundHandleResizeMove),document.removeEventListener("touchmove",this._boundHandleResizeMove)),this._boundHandleResizeEnd&&(document.removeEventListener("mouseup",this._boundHandleResizeEnd),document.removeEventListener("touchend",this._boundHandleResizeEnd),document.removeEventListener("touchcancel",this._boundHandleResizeEnd)),this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,document.body.style.userSelect="",document.body.style.webkitUserSelect="",document.documentElement.style.cursor="",document.documentElement.style.transition="padding 0.3s ease",this.render())},this.config=e,this.events=t,this.onClick=n,this.rootContainer=r||null}getEdgePosition(){return this.config.panel.position}detectThemeFromDOM(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}applyThemeMode(){const e=this.config.theme.mode;this.currentTheme="light"===e||"dark"===e?e:this.detectThemeFromDOM()}init(){if(this.stylesInjected||(ba(document,"/* Sidebar container - always visible, shifts when panel opens */\n.pillar-edge-sidebar {\n /* Default light mode variables (match panel's variables.css) */\n --pillar-primary: #2563eb;\n --pillar-primary-hover: #1d4ed8;\n --pillar-bg: #ffffff;\n --pillar-bg-secondary: #f9fafb;\n --pillar-text: #1a1a1a;\n --pillar-text-muted: #6b7280;\n --pillar-border: #e5e7eb;\n --pillar-border-light: #f3f4f6;\n --pillar-outline-color: rgba(37, 99, 235, 0.15);\n\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/* Default dark mode variables (match panel's variables.css) */\n.pillar-edge-sidebar--dark {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-text: #f5f5f5;\n --pillar-text-muted: #a3a3a3;\n --pillar-border: #404040;\n --pillar-border-light: #333333;\n --pillar-outline-color: rgba(96, 165, 250, 0.25);\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-left: none;\n border-right: 1px solid var(--pillar-border);\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-bg-secondary);\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\n/* Resize handle - appears on the inner edge of the sidebar (content side) */\n.pillar-edge-resize-handle {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 6px;\n cursor: col-resize;\n z-index: 1;\n display: none;\n touch-action: none;\n}\n\n/* Position the handle on the correct edge based on panel position */\n.pillar-edge-sidebar--right .pillar-edge-resize-handle {\n left: -3px;\n}\n\n.pillar-edge-sidebar--left .pillar-edge-resize-handle {\n right: -3px;\n}\n\n/* Only show when panel is open */\n.pillar-edge-sidebar--panel-open .pillar-edge-resize-handle {\n display: block;\n}\n\n/* Visible indicator line on hover */\n.pillar-edge-resize-handle::after {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n width: 2px;\n left: 50%;\n transform: translateX(-50%);\n background: transparent;\n transition: background 0.15s ease;\n border-radius: 1px;\n}\n\n.pillar-edge-resize-handle:hover::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.5;\n}\n\n.pillar-edge-sidebar--resizing .pillar-edge-resize-handle::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.7;\n}\n\n/* Override cursor on the whole sidebar during resize */\n.pillar-edge-sidebar--resizing,\n.pillar-edge-sidebar--resizing * {\n cursor: col-resize !important;\n}\n\n/* Disable sidebar transition during resize for immediate feedback */\n.pillar-edge-sidebar--resizing {\n transition: none !important;\n}\n","pillar-edge-trigger-styles"),this.stylesInjected=!0),!this.themeStylesInjected){const e=function(e,t,n){const r=e=>{const t=[];return e.primary&&t.push(`--pillar-primary: ${e.primary};`),e.primaryHover&&t.push(`--pillar-primary-hover: ${e.primaryHover};`),e.background&&t.push(`--pillar-bg: ${e.background};`),e.backgroundSecondary&&t.push(`--pillar-bg-secondary: ${e.backgroundSecondary};`),e.text&&t.push(`--pillar-text: ${e.text};`),e.textMuted&&t.push(`--pillar-text-muted: ${e.textMuted};`),e.border&&t.push(`--pillar-border: ${e.border};`),e.borderLight&&t.push(`--pillar-border-light: ${e.borderLight};`),e.outlineColor&&t.push(`--pillar-outline-color: ${e.outlineColor};`),t.join("\n ")},i=r(e),a=r(t),l=n?`--pillar-font-family: ${n};`:"";let o="";return(i||l)&&(o+=`\n.pillar-edge-sidebar,\n.pillar-edge-sidebar--light {\n ${[i,l].filter(Boolean).join("\n ")}\n}\n`),a&&(o+=`\n.pillar-edge-sidebar--dark {\n ${a}\n}\n`),o}(this.config.theme.colors,this.config.theme.darkColors,this.config.theme.fontFamily);e&&ba(document,e,"pillar-edge-trigger-theme"),this.themeStylesInjected=!0}if(this.config.panel.resizable&&this.config.edgeTrigger.resizable){const e=Xi();null!==e&&fa(e)}this.container=document.createElement("div"),this.container.id="pillar-edge-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.applyThemeMode(),this.applyLayoutPadding(),this.render(),this.unsubscribeOpen=Yi.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeWidth=ra.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())});let e=pa.value;this.unsubscribeHoverMode=pa.subscribe(t=>{t!==e&&(e=t,queueMicrotask(()=>this.applyLayoutPadding()))});let t=da.value;this.unsubscribeMobileMode=da.subscribe(e=>{e!==t&&(t=e,e?this.hide():this.show())}),da.value&&this.hide(),this.unsubscribeActiveTab=ea.subscribe(()=>{this.render()}),"auto"===this.config.theme.mode&&(this.themeObserver=new MutationObserver(()=>{const e=this.detectThemeFromDOM();e!==this.currentTheme&&(this.currentTheme=e,this.render())}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}))}getPushTargetElement(){const e=this.config.panel.pushTarget;return e?"string"==typeof e?document.querySelector(e)||document.documentElement:e:document.documentElement}applyLayoutPadding(){if(this._isHidden)return;const e=this.getEdgePosition(),t=ra.value,n=pa.value,r=this.getPushTargetElement();let i=48;Yi.value&&!n&&(i=t+48),r.style.transition="padding 0.3s ease","right"===e?(r.style.paddingRight=`${i}px`,document.documentElement.style.setProperty("--pillar-inset-right",`${i}px`),document.documentElement.style.setProperty("--pillar-inset-left","0px")):(r.style.paddingLeft=`${i}px`,document.documentElement.style.setProperty("--pillar-inset-left",`${i}px`),document.documentElement.style.setProperty("--pillar-inset-right","0px"))}removeLayoutPadding(){const e=this.getEdgePosition(),t=this.getPushTargetElement();"right"===e?t.style.paddingRight="":t.style.paddingLeft="",document.documentElement.style.removeProperty("--pillar-inset-right"),document.documentElement.style.removeProperty("--pillar-inset-left")}setOpen(e){this.render()}show(){this._isHidden=!1,this.container&&(this.container.style.display=""),this.applyLayoutPadding(),this.render()}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._isResizing&&this.handleResizeEnd(new MouseEvent("mouseup")),null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.unsubscribeWidth?.(),this.unsubscribeWidth=null,this.unsubscribeHoverMode?.(),this.unsubscribeHoverMode=null,this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=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}handleResizeMove(e){this._isResizing&&("touches"in e&&e.preventDefault(),null===this._resizeRafId&&(this._resizeRafId=requestAnimationFrame(()=>{if(this._resizeRafId=null,!this._isResizing)return;const t="touches"in e?e.touches[0].clientX:e.clientX,n=this._resizeStartX-t,r="right"===this.getEdgePosition()?n:-n,i=window.innerWidth-48-100,a=Math.max(200,Math.min(i,this._resizeStartWidth+r));fa(a)})))}render(){if(!this.container||this._isHidden)return;const e=this.getEdgePosition();let t=[...this.config.sidebarTabs];const n=t.findIndex(e=>"assistant"===e.id);if(-1!==n&&(t[n]={...t[n],label:this.config.assistantDisplayName}),this.config.debug){const e=t.some(e=>"tools"===e.id);if(!e){const e=Math.max(...t.map(e=>e.order),0);t.push({id:"tools",label:"Tools",enabled:!0,order:e+1,icon:"tools"})}}Y(Kr(xa,{position:e,tabs:t,currentActiveTab:ea.value,onTabClick:this.handleTabClick,panelOpen:Yi.value,panelWidthPx:ra.value,theme:this.currentTheme,resizable:this.config.panel.resizable&&this.config.edgeTrigger.resizable,isResizing:this._isResizing,onResizeStart:this.handleResizeStart}),this.container)}}const wa={sparkle:'<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8.8 8.44L9.497 11l.697-2.56c.175-.643.263-.965.435-1.23a2 2 0 0 1 .583-.583c.263-.172.585-.259 1.23-.435l2.56-.697l-2.56-.697c-.643-.175-.964-.263-1.23-.435a2 2 0 0 1-.583-.583c-.172-.263-.259-.585-.435-1.23L9.497-.01L8.8 2.55c-.175.643-.263.965-.435 1.23a2 2 0 0 1-.583.583c-.263.172-.585.259-1.23.435l-2.56.697l2.56.697c.643.175.965.263 1.23.435a2 2 0 0 1 .583.583c.172.263.259.585.435 1.23M2.68 13.7c.169.244.264.542.456 1.14l.362 1.12l.362-1.12c.191-.595.287-.893.456-1.14c.149-.216.34-.4.561-.543c.249-.161.55-.247 1.15-.418l.971-.277l-.971-.277c-.601-.172-.902-.258-1.15-.418a2 2 0 0 1-.561-.543c-.169-.244-.264-.542-.456-1.14l-.362-1.12l-.362 1.12c-.191.595-.287.893-.456 1.14c-.149.216-.34.4-.561.543c-.249.161-.55.247-1.15.418l-.971.277l.971.277c.601.172.902.258 1.15.418a2 2 0 0 1 .561.543"/></svg>',question:'<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>',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>',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>',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>'},ka={small:44,medium:56,large:68};function Sa({position:e,icon:t,backgroundColor:n,iconColor:r,size:i,label:a,offset:l,panelOpen:o,onClick:s}){const c=ui(()=>{s()},[s]);return Kr("button",{class:["pillar-mobile-trigger",`pillar-mobile-trigger--${e}`,"pillar-mobile-trigger--mounted",o&&"pillar-mobile-trigger--hidden"].filter(Boolean).join(" "),style:{"--pillar-mobile-offset":`${l}px`,"--pillar-mobile-bg":n,width:`${i}px`,height:`${i}px`,backgroundColor:n,color:r},onClick:c,"aria-label":a,title:a,type:"button",children:Kr("span",{class:"pillar-mobile-trigger__icon",dangerouslySetInnerHTML:{__html:t}})})}class Ca{constructor(e,t,n,r){this.container=null,this.stylesInjected=!1,this._isEnabled=!0,this.unsubscribeMobileMode=null,this.unsubscribeOpen=null,this.config=e,this.events=t,this.onClick=n,this.rootContainer=r||null,this._isEnabled=e.mobileTrigger.enabled}getSize(){const e=this.config.mobileTrigger.size;return"number"==typeof e?e:ka[e]}getIcon(){const{customIcon:e,icon:t}=this.config.mobileTrigger;return e||wa[t]}getBackgroundColor(){const{backgroundColor:e}=this.config.mobileTrigger;return e||(this.config.theme.colors.primary||"#c2410c")}init(){if(!this._isEnabled)return;this.stylesInjected||(ba(document,"/* Mobile trigger floating button */\n.pillar-mobile-trigger {\n position: fixed;\n z-index: 100000;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);\n transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n}\n\n.pillar-mobile-trigger:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.12);\n}\n\n.pillar-mobile-trigger:active {\n transform: scale(0.95);\n}\n\n.pillar-mobile-trigger:focus-visible {\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 5px var(--pillar-mobile-bg, #c2410c);\n}\n\n/* Position variants */\n.pillar-mobile-trigger--bottom-right {\n bottom: var(--pillar-mobile-offset, 24px);\n right: var(--pillar-mobile-offset, 24px);\n}\n\n.pillar-mobile-trigger--bottom-left {\n bottom: var(--pillar-mobile-offset, 24px);\n left: var(--pillar-mobile-offset, 24px);\n}\n\n/* Icon styling */\n.pillar-mobile-trigger__icon {\n width: 55%;\n height: 55%;\n flex-shrink: 0;\n transform: translateY(-1px);\n}\n\n/* Hidden state (when panel is open) */\n.pillar-mobile-trigger--hidden {\n opacity: 0 !important;\n pointer-events: none;\n transform: scale(0.8) !important;\n visibility: hidden;\n}\n\n/* Animation on mount */\n@keyframes pillar-mobile-trigger-mount {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.pillar-mobile-trigger--mounted {\n animation: pillar-mobile-trigger-mount 0.2s ease forwards;\n}\n","pillar-mobile-trigger-styles"),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-mobile-trigger-container";(this.rootContainer||document.body).appendChild(this.container);let e=da.value;this.unsubscribeMobileMode=da.subscribe(t=>{t!==e&&(e=t,this.render())});let t=Yi.value;this.unsubscribeOpen=Yi.subscribe(e=>{e!==t&&(t=e,this.render())}),this.render()}show(){this._isEnabled=!0,this.render()}hide(){this._isEnabled=!1,this.render()}get isVisible(){return this._isEnabled&&da.value&&!Yi.value}destroy(){this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=null,this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.container&&(Y(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-mobile-trigger-styles")?.remove(),this.stylesInjected=!1}render(){if(!this.container)return;if(!this._isEnabled||!da.value)return void Y(null,this.container);const{position:e,iconColor:t,label:n,offset:r}=this.config.mobileTrigger;Y(Kr(Sa,{position:e,icon:this.getIcon(),backgroundColor:this.getBackgroundColor(),iconColor:t,size:this.getSize(),label:n,offset:r,panelOpen:Yi.value,onClick:this.onClick}),this.container)}}let Pa=null;function Ea(e){Pa=e}function Ta(){return Pa}function za(){return Pa?._api??null}function Ra(e){const t=new Date(e);return`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function Ia(e){switch(e){case"error":return"#ef4444";case"warn":return"#f59e0b";default:return"#d4d4d4"}}function Aa(e){switch(e){case"sdk":return"⚡";case"handler":return"🔧";case"network":return"🌐";case"server":return"🧠";default:return"•"}}function Ma(e){switch(e){case"sdk":return"SDK";case"handler":return"Handler";case"network":return"Network";case"server":return"Server";default:return e}}const $a=["sdk","handler","network","server"];function La({expanded:e=!1,onToggle:t}){const[n,r]=si([]),[i,a]=si(e),[l,o]=si(""),[s,c]=si(new Set($a)),[p,d]=si(200),[u,h]=si(!1),[g,f]=si(new Set),[m,b]=si(null),v=pi(null),_=pi("");ci(()=>{const e="pillar-debug-panel-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=".pillar-debug-panel {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: #1e1e1e;\n color: #d4d4d4;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 12px;\n z-index: 999999;\n border-top: 1px solid #333;\n}\n.pillar-debug-resize-handle {\n height: 8px;\n background-color: #333;\n cursor: ns-resize;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.pillar-debug-resize-handle::after {\n content: '';\n width: 40px;\n height: 3px;\n background-color: #555;\n border-radius: 2px;\n}\n.pillar-debug-resize-handle:hover,\n.pillar-debug-resize-handle.active {\n background-color: #3b82f6;\n}\n.pillar-debug-resize-handle:hover::after,\n.pillar-debug-resize-handle.active::after {\n background-color: #fff;\n}\n.pillar-debug-header {\n display: flex;\n align-items: center;\n padding: 8px 12px;\n background-color: #252526;\n cursor: pointer;\n user-select: none;\n}\n.pillar-debug-header-icon {\n margin-right: 8px;\n font-size: 10px;\n}\n.pillar-debug-header-title {\n font-weight: 600;\n margin-right: 8px;\n}\n.pillar-debug-header-count {\n background-color: #3c3c3c;\n padding: 2px 6px;\n border-radius: 4px;\n font-size: 11px;\n margin-right: auto;\n}\n.pillar-debug-header-actions {\n display: flex;\n gap: 8px;\n}\n.pillar-debug-btn {\n background-color: transparent;\n border: 1px solid #555;\n color: #d4d4d4;\n padding: 2px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n}\n.pillar-debug-btn:hover {\n background-color: #333;\n}\n.pillar-debug-btn.copied {\n border-color: #10b981;\n color: #10b981;\n}\n.pillar-debug-content {\n overflow: hidden;\n display: flex;\n flex-direction: column;\n}\n.pillar-debug-toolbar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n background-color: #2d2d2d;\n border-bottom: 1px solid #3c3c3c;\n flex-shrink: 0;\n}\n.pillar-debug-filter-input {\n background-color: #3c3c3c;\n border: none;\n color: #d4d4d4;\n padding: 4px 8px;\n font-size: 12px;\n outline: none;\n border-radius: 4px;\n flex: 1;\n max-width: 200px;\n}\n.pillar-debug-source-filters {\n display: flex;\n gap: 4px;\n}\n.pillar-debug-source-btn {\n background-color: transparent;\n border: 1px solid #444;\n color: #888;\n padding: 2px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n.pillar-debug-source-btn.active {\n background-color: #3c3c3c;\n border-color: #666;\n color: #d4d4d4;\n}\n.pillar-debug-source-btn:hover {\n background-color: #333;\n}\n.pillar-debug-source-count {\n background-color: #444;\n padding: 0 4px;\n border-radius: 3px;\n font-size: 10px;\n}\n.pillar-debug-timeline {\n flex: 1;\n overflow-y: auto;\n padding: 4px 0;\n}\n.pillar-debug-empty {\n padding: 12px;\n color: #6b7280;\n text-align: center;\n}\n.pillar-debug-entry {\n padding: 4px 12px;\n border-bottom: 1px solid #2d2d2d;\n}\n.pillar-debug-entry:hover {\n background-color: #252526;\n}\n.pillar-debug-entry.server {\n background-color: rgba(139, 92, 246, 0.1);\n}\n.pillar-debug-entry.server:hover {\n background-color: rgba(139, 92, 246, 0.15);\n}\n.pillar-debug-entry-row {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.pillar-debug-entry-time {\n color: #6b7280;\n flex-shrink: 0;\n}\n.pillar-debug-entry-source {\n flex-shrink: 0;\n font-size: 10px;\n padding: 1px 4px;\n border-radius: 3px;\n background-color: #333;\n}\n.pillar-debug-entry-source.sdk { background-color: #3b82f6; color: white; }\n.pillar-debug-entry-source.handler { background-color: #10b981; color: white; }\n.pillar-debug-entry-source.network { background-color: #f59e0b; color: black; }\n.pillar-debug-entry-source.server { background-color: #8b5cf6; color: white; }\n.pillar-debug-entry-event {\n font-weight: 500;\n flex-shrink: 0;\n}\n.pillar-debug-entry-data {\n color: #9ca3af;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.pillar-debug-entry.expanded {\n flex-direction: column;\n align-items: stretch;\n}\n.pillar-debug-entry.expanded .pillar-debug-entry-row {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.pillar-debug-entry.expanded .pillar-debug-entry-data {\n white-space: pre-wrap;\n word-break: break-all;\n overflow: visible;\n margin-top: 8px;\n padding: 8px;\n background-color: #2d2d2d;\n border-radius: 4px;\n font-size: 11px;\n line-height: 1.4;\n}\n.pillar-debug-entry-expand {\n color: #6b7280;\n font-size: 10px;\n flex-shrink: 0;\n margin-left: auto;\n}\n",document.head.appendChild(t)}_.current=document.body.style.paddingBottom||"";const t=Ta();if(!t)return;r(t.getDebugLog());const n=t.onDebugLog(e=>{r([...e])});return()=>{n(),document.body.style.paddingBottom=_.current}},[]);const x=pi(null);ci(()=>{const e=x.current;if(!e)return;const t=()=>{document.body.style.paddingBottom=`${e.offsetHeight}px`},n=new ResizeObserver(t);return n.observe(e),t(),()=>{n.disconnect()}},[]),ci(()=>{v.current&&n.length>0&&requestAnimationFrame(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)})},[n]);const y=ui(e=>{e.preventDefault(),h(!0);const t=e.clientY,n=p,r=e=>{const r=t-e.clientY,i=Math.min(600,Math.max(100,n+r));d(i)},i=()=>{h(!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",i)},[p]),w=di(()=>{const e={sdk:0,handler:0,network:0,server:0};for(const t of n)e[t.source]=(e[t.source]||0)+1;return e},[n]),k=di(()=>n.filter(e=>{if(!s.has(e.source))return!1;if(l){const t=l.toLowerCase(),n=e.event.toLowerCase().includes(t),r=!!e.data&&JSON.stringify(e.data).toLowerCase().includes(t);if(!n&&!r)return!1}return!0}),[n,s,l]),S=(e,t)=>["=== Pillar SDK — Client Logs ===",`Output: ${t}`,`Exported: ${(new Date).toISOString()}`,`Entries: ${e.length}`,""].join("\n")+e.map(e=>{const t=Ra(e.timestamp),n=Ma(e.source).toUpperCase().padEnd(8),r="error"===e.level?" [ERROR]":"warn"===e.level?" [WARN]":"",i=null!=e.data?` ${"object"==typeof e.data?JSON.stringify(e.data):String(e.data)}`:"";return`${t} [${n}]${r} ${e.event}${i}`}).join("\n");return Kr("div",{class:"pillar-debug-panel",ref:x,children:[i&&Kr("div",{class:"pillar-debug-resize-handle "+(u?"active":""),onMouseDown:y}),Kr("div",{class:"pillar-debug-header",onClick:()=>{a(!i),t?.()},children:[Kr("span",{class:"pillar-debug-header-icon",children:i?"▼":"▶"}),Kr("span",{class:"pillar-debug-header-title",children:"Debug"}),Kr("span",{class:"pillar-debug-header-count",children:n.length}),i&&Kr("div",{class:"pillar-debug-header-actions",children:[Kr("button",{class:"pillar-debug-btn "+("copy"===m?"copied":""),onClick:e=>{e.stopPropagation(),(()=>{const e=$a.filter(e=>s.has(e)).map(Ma).join(", "),t=S(k,l?`${e} (filtered: "${l}")`:e);navigator.clipboard.writeText(t),b("copy"),setTimeout(()=>b(null),1500)})()},children:"copy"===m?"Copied!":"Copy"}),Kr("button",{class:"pillar-debug-btn "+("copyAll"===m?"copied":""),onClick:e=>{e.stopPropagation(),(()=>{const e=S(n,"All Sources");navigator.clipboard.writeText(e),b("copyAll"),setTimeout(()=>b(null),1500)})()},children:"copyAll"===m?"Copied!":"Copy All"}),Kr("button",{class:"pillar-debug-btn",onClick:e=>{e.stopPropagation(),(()=>{const e=JSON.stringify(n,null,2),t=new Blob([e],{type:"application/json"}),r=URL.createObjectURL(t),i=document.createElement("a");i.href=r,i.download=`pillar-debug-${(new Date).toISOString().slice(0,19).replace(/:/g,"-")}.json`,i.click(),URL.revokeObjectURL(r)})()},children:"Export"}),Kr("button",{class:"pillar-debug-btn",onClick:e=>{e.stopPropagation(),(()=>{const e=Ta();e?.clearDebugLog()})()},children:"Clear"})]})]}),i&&Kr("div",{class:"pillar-debug-content",style:{height:`${p}px`},children:[Kr("div",{class:"pillar-debug-toolbar",children:[Kr("input",{type:"text",class:"pillar-debug-filter-input",placeholder:"Filter...",value:l,onInput:e=>o(e.target.value),onClick:e=>e.stopPropagation()}),Kr("div",{class:"pillar-debug-source-filters",children:$a.map(e=>Kr("button",{class:"pillar-debug-source-btn "+(s.has(e)?"active":""),onClick:t=>{t.stopPropagation(),(e=>{c(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})(e)},children:[Aa(e)," ",Ma(e),Kr("span",{class:"pillar-debug-source-count",children:w[e]})]},e))})]}),Kr("div",{class:"pillar-debug-timeline",ref:v,children:0===k.length?Kr("div",{class:"pillar-debug-empty",children:0===n.length?"No events captured yet":"No events match filters"}):k.map((e,t)=>{const n=g.has(t),r=null!==e.data&&void 0!==e.data;return Kr("div",{class:`pillar-debug-entry ${e.source} ${n?"expanded":""}`,onClick:()=>r&&(e=>{f(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})(t),style:{cursor:r?"pointer":"default"},children:[Kr("div",{class:"pillar-debug-entry-row",children:[Kr("span",{class:"pillar-debug-entry-time",children:Ra(e.timestamp)}),Kr("span",{class:`pillar-debug-entry-source ${e.source}`,children:Aa(e.source)}),Kr("span",{class:"pillar-debug-entry-event",style:{color:Ia(e.level)},children:e.event}),r&&!n&&Kr("span",{class:"pillar-debug-entry-data",children:"object"==typeof e.data?JSON.stringify(e.data,null,0).slice(0,100):String(e.data)}),r&&Kr("span",{class:"pillar-debug-entry-expand",children:n?"▼":"▶"})]}),r&&n&&Kr("span",{class:"pillar-debug-entry-data",children:(i=e.data,null==i?"":"object"==typeof i?JSON.stringify(i,null,2):String(i))})]},t);var i})})]})]})}function Oa(){return`ctx_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Da(e){return"highlighted_text"===e.type}function ja(e){return"dom_snapshot"===e.type}function Ha(e){return Da(e)?e.text_content.length>40?e.text_content.substring(0,40)+"...":e.text_content:ja(e)?`Page scan: ${e.interactableCount} elements`:"Context"}const Na=Ai([]),Ua=Ai(null),Ba=Ai([]),Fa=Ai(0),qa=Ai([]),Wa="pillar:conversation_id";function Va(e){if("undefined"!=typeof window)try{if(null===e)localStorage.removeItem(Wa);else{const t={id:e,lastActiveAt:Date.now()};localStorage.setItem(Wa,JSON.stringify(t))}}catch{}}let Ka=0;const Ga=Ai(!1),Qa=Ai(null),Ja=e=>{Qa.value=e},Xa=Ai(!1),Za=Ai(null),Ya=e=>{Za.value=e},el=()=>{Za.value=null},tl=Ai(null),nl=Ai(null),rl=Ai({kind:null}),il=Ai([]),al=e=>{const t=Na.value;if(t.length>0&&"assistant"===t[t.length-1].role){const n=t[t.length-1],r=n.progressEvents||[];let i;const a=e.id||e.progress_id;if(a){const t=r.findIndex(e=>(e.id||e.progress_id)===a);if(t>=0){const n=r[t],a="thinking"===n.kind||"step_start"===n.kind,l="active"===n.status,o="done"===e.status||"error"===e.status,s=n.metadata?._startTime,c=a&&l&&o&&s?{_durationSeconds:Math.round((Date.now()-s)/1e3)}:{},p={...n,...e,id:e.id||n.id,progress_id:e.progress_id||n.progress_id,text:n.text&&e.text?n.text+e.text:e.text??n.text,children:e.children||n.children,metadata:{...n.metadata,...e.metadata,...c}};i=[...r.slice(0,t),p,...r.slice(t+1)]}else{const t=Date.now(),n=r.map(e=>{if(!(("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status))return e;const n=e.metadata?._startTime,r=n?{_durationSeconds:Math.round((t-n)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...r}}});i=[...n,("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status?{...e,metadata:{...e.metadata,_startTime:t}}:e]}}else{const t=Date.now(),n=r.map(e=>{if(!(("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status))return e;const n=e.metadata?._startTime,r=n?{_durationSeconds:Math.round((t-n)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...r}}});i=[...n,("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status?{...e,metadata:{...e.metadata,_startTime:t}}:e]}const l=[...n.segments||[]],o=e.id&&r.some(t=>t.id===e.id);if(o)for(let t=l.length-1;t>=0;t--){const n=l[t];if("progress"!==n.type)continue;const r=n.events.findIndex(t=>t.id===e.id);if(r>=0){const a=i.find(t=>t.id===e.id);if(a){const e=[...n.events];e[r]=a,l[t]={type:"progress",events:e}}break}}else{const t=e.id?i.find(t=>t.id===e.id):i[i.length-1];if(t){const e=l[l.length-1];e&&"progress"===e.type?l[l.length-1]={type:"progress",events:[...e.events,t]}:l.push({type:"progress",events:[t]})}}Na.value=[...t.slice(0,-1),{...n,progressEvents:i,segments:l}]}},ll=e=>{!function(){const e=Date.now();if(!(e-Ka<3e4)&&(Ka=e,"undefined"!=typeof window))try{const t=localStorage.getItem(Wa);if(!t)return;const n=JSON.parse(t);n.lastActiveAt=e,localStorage.setItem(Wa,JSON.stringify(n))}catch{}}();const t=Na.value;if(0===t.length||"assistant"!==t[t.length-1].role)return;const n=t[t.length-1],r=[...n.segments||[]],i=r[r.length-1];i&&"text"===i.type?r[r.length-1]={type:"text",content:i.content+e}:r.push({type:"text",content:e}),Na.value=[...t.slice(0,-1),{...n,segments:r,content:(n.content||"")+e}]},ol=(e,t)=>{const n=Na.value;if(0===n.length||"assistant"!==n[n.length-1].role)return;const r=n[n.length-1],i=[...r.segments||[]];i.push({type:"card",cardType:e,data:t}),Na.value=[...n.slice(0,-1),{...r,segments:i}]},sl=Ai(!1),cl=Ai([]),pl=Ai([]),dl=Ai(""),ul=Ai(null),hl=Ai(0),gl=Ai(0),fl=Ai([]),ml=Ai([]),bl=Ai([]),vl=Ai([]),_l=Di(()=>vl.value.some(e=>"uploading"===e.status)),xl=()=>vl.value.filter(e=>"ready"===e.status&&e.url).map(e=>({url:e.url,detail:"low",path:e.path})),yl=e=>{vl.value.length>=4||(vl.value=[...vl.value,e])},wl=(e,t,n,r,i)=>{vl.value=vl.value.map(a=>a.id===e?{...a,status:t,url:n,error:r,path:i}:a)},kl=e=>{const t=vl.value.find(t=>t.id===e);t&&URL.revokeObjectURL(t.preview),vl.value=vl.value.filter(t=>t.id!==e)},Sl=()=>{vl.value.forEach(e=>URL.revokeObjectURL(e.preview)),vl.value=[]},Cl=Di(()=>Na.value.length>0),Pl=(e,t,n)=>{Na.value=[...Na.value,{role:"user",content:e,userContext:t&&t.length>0?t:void 0,images:n&&n.length>0?n:void 0}]},El=(e,t)=>{Na.value=[...Na.value,{role:"assistant",content:e,id:t,progressEvents:[]}]},Tl=(e,t,n,r)=>{const i=Na.value;if(i.length>0&&"assistant"===i[i.length-1].role){const a=i[i.length-1];Na.value=[...i.slice(0,-1),{role:"assistant",content:void 0!==e?e:a.content,id:t??a.id,actions:n??a.actions,sources:r??a.sources,actionStatus:a.actionStatus,progressEvents:a.progressEvents,segments:a.segments}]}},zl=(e,t)=>{const n=Na.value;if(e>=0&&e<n.length){const r=n[e],i={...r.actionStatus||{},[t]:{status:"pending"}};Na.value=[...n.slice(0,e),{...r,actionStatus:i},...n.slice(e+1)]}},Rl=(e,t,n)=>{const r=Na.value;for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.actionStatus?.[e]){const l={...a.actionStatus,[e]:{status:t?"success":"failed",completedAt:Date.now(),errorMessage:n}};return void(Na.value=[...r.slice(0,i),{...a,actionStatus:l},...r.slice(i+1)])}}},Il=(e,t)=>{const n=Na.value;for(let r=n.length-1;r>=0;r--){const i=n[r];if(i.actionStatus?.[e])return void(Na.value=[...n.slice(0,r),{...i,content:t},...n.slice(r+1)])}},Al=e=>{Ua.value=e,Va(e)},Ml=(e,t)=>{Na.value=Na.value.map(n=>n.id===e?{...n,feedback:t}:n)},$l=e=>{Ga.value=e},Ll=()=>{rl.value={kind:null}},Ol=()=>{const e=Na.value;if(0===e.length)return;const t=e[e.length-1];if("assistant"!==t.role||!t.progressEvents)return;const n=t.progressEvents.some(e=>"active"===e.status);if(!n)return;const r=Date.now(),i=t.progressEvents.map(e=>{if("active"!==e.status)return e;const t=e.metadata?._startTime,n=t?{_durationSeconds:Math.round((r-t)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...n}}});Na.value=[...e.slice(0,-1),{...t,progressEvents:i}]},Dl=e=>{const t=e.id||e.progress_id;if(t){const n=il.value.findIndex(e=>(e.id||e.progress_id)===t);if(n>=0){const t=il.value[n],r={...t,...e,id:e.id||t.id,progress_id:e.progress_id||t.progress_id,text:"thinking"===e.kind&&t.text&&e.text?t.text+e.text:e.text??t.text};il.value=[...il.value.slice(0,n),r,...il.value.slice(n+1)]}else il.value=[...il.value,e]}else il.value=[...il.value,e];al(e)},jl=e=>{tl.value=e},Hl=()=>{tl.value=null},Nl=()=>{const e=Na.value;if(0===e.length)return;const t=e[e.length-1],n=t.progressEvents&&t.progressEvents.length>0;"assistant"!==t.role||t.content?.trim()||n||(Na.value=e.slice(0,-1))},Ul=e=>{ul.value=e},Bl=()=>{ul.value=null},Fl=()=>{hl.value+=1},ql=()=>{gl.value+=1},Wl=e=>{const t={...e,id:Oa()};fl.value=[...fl.value,t]},Vl=e=>{fl.value=fl.value.filter(t=>t.id!==e)},Kl=()=>{fl.value=[]},Gl=e=>{ml.value=e},Ql=()=>{ml.value=[]},Jl=e=>{bl.value=e},Xl=()=>{bl.value=[]},Zl=()=>{Na.value=[],Ua.value=null,Va(null),Ba.value=[],Ga.value=!1,rl.value={kind:null},il.value=[],nl.value=null,sl.value=!1,cl.value=[],pl.value=[],dl.value="",ul.value=null,hl.value=0,fl.value=[],ml.value=[],bl.value=[],Sl()},Yl=()=>{Zl(),Xa.value=!0};function eo(e){return"token_summary"===e.step_type||"tool_decision"===e.step_type||"parallel_tool_decision"===e.step_type||"narration"===e.step_type?null:"thinking"===e.step_type?{kind:"thinking",status:"done",text:e.content||"",label:"Thought",metadata:{iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:"tool_result"===e.step_type?{kind:e.kind||"tool_call",status:!1===e.success?"error":"done",label:e.label||e.tool||"Result",text:e.text,children:e.children,metadata:{tool_name:e.tool,tool:e.tool,arguments:e.arguments,success:e.success,iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:"step_start"===e.step_type?{kind:"step_start",status:"done",label:e.label||"Step",metadata:{iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:{kind:e.step_type,status:"done",label:e.label||e.step_type,text:e.content,metadata:e}}function to(e){if(!e||0===e.length)return;const t=[];for(const n of e)if("narration"===n.step_type){const e=n.content||"",r=t[t.length-1];r&&"text"===r.type?r.content+=e:t.push({type:"text",content:e})}else{const e=eo(n);if(!e)continue;const r=t[t.length-1];r&&"progress"===r.type?r.events.push(e):t.push({type:"progress",events:[e]})}return t.length>0?t:void 0}const no=(e,t)=>{Ua.value=e,Va(e),Na.value=t.map(e=>({role:e.role,content:e.content,id:e.id,images:"user"===e.role&&e.images?.length?e.images:void 0,segments:"assistant"===e.role?to(e.display_trace):void 0})),sl.value=!0,Xa.value=!1,Fa.value+=1},ro=()=>{Xa.value=!1},io=(e,t)=>{const n=(new Date).toISOString(),r={id:e,title:t,startedAt:n,lastMessageAt:n,messageCount:1};qa.value=[r,...qa.value.filter(t=>t.id!==e)],Fa.value+=1},ao=async e=>{const{getApiClient:t}=await Promise.resolve().then(function(){return Yp}),{navigate:n}=await Promise.resolve().then(function(){return bo}),{debug:r}=await Promise.resolve().then(function(){return d}),i=t();if(i){Yl(),n("chat");try{const t=await i.getConversation(e);t&&t.messages.length>0?no(t.id,t.messages):ro()}catch(e){r.error("[Pillar] Failed to load conversation:",e),ro()}}};var lo=Object.freeze({__proto__:null,activeRequestId:Qa,addAssistantMessage:El,addCardSegment:ol,addOptimisticConversation:io,addPendingImage:yl,addProgressEvent:Dl,addProgressEventToLastMessage:al,addUserContext:Wl,addUserMessage:Pl,appendTokenToSegments:ll,chatError:Za,clearChatError:el,clearInterruptedSession:Hl,clearPendingImages:Sl,clearPendingImagesForNavigation:Xl,clearPendingMessage:Bl,clearPendingUserContext:Ql,clearProgressStatus:Ll,clearUserContext:Kl,conversationId:Ua,currentActions:pl,currentSources:cl,finalizeActiveProgressEvents:Ol,focusInputTrigger:gl,getReadyImages:xl,getRegisteredActions:()=>Ba.value,getStoredConversationId:function(){if("undefined"==typeof window)return null;try{const e=localStorage.getItem(Wa);if(!e)return null;try{const t=JSON.parse(e);if(t.id&&t.lastActiveAt){return Date.now()-t.lastActiveAt>18e4?(localStorage.removeItem(Wa),null):t.id}}catch{}return localStorage.removeItem(Wa),null}catch{return null}},hasMessages:Cl,historyInvalidationCounter:Fa,interruptedSession:tl,isExpanded:sl,isLoading:Ga,isLoadingHistory:Xa,isUploadingImages:_l,loadConversation:no,messages:Na,optimisticConversations:qa,pendingImages:vl,pendingImagesForNavigation:bl,pendingMessage:ul,pendingUserContext:ml,prefillText:dl,progressEvents:il,progressStatus:rl,registeredActions:Ba,removeLastEmptyAssistantMessage:Nl,removePendingImage:kl,removeUserContext:Vl,resetChat:Zl,selectConversationById:ao,setActionComplete:Rl,setActionPending:zl,setActiveRequestId:Ja,setChatError:Ya,setConversationId:Al,setInterruptedSession:jl,setLoading:$l,setMessageFeedback:Ml,setPendingImagesForNavigation:Jl,setPendingMessage:Ul,setPendingUserContext:Gl,setRegisteredActions:e=>{Ba.value=e},startLoadingHistory:Yl,stopLoadingHistory:ro,submitPendingTrigger:hl,tokenUsage:nl,triggerInputFocus:ql,triggerSubmitPending:Fl,updateActionMessageContent:Il,updateImageStatus:wl,updateLastAssistantMessage:Tl,updateTokenUsage:e=>{nl.value=e},userContext:fl});const oo=Ai([]),so=Ai({type:"home"}),co=Di(()=>oo.value.length>0),po=Di(()=>"home"===so.value.type),uo=(e,t)=>{oo.value=[...oo.value,{...so.value}],so.value={type:e,params:t}},ho=()=>{const e=oo.value;if(e.length>0){"chat"===so.value.type&&Zl();const t=e[e.length-1];so.value=t,oo.value=e.slice(0,-1)}},go=()=>{"chat"===so.value.type&&Zl(),oo.value=[],so.value={type:"home"}},fo=()=>{oo.value=[],so.value={type:"home"}},mo=()=>{uo("chat"),Fl()};var bo=Object.freeze({__proto__:null,canGoBack:co,currentView:so,goBack:ho,goHome:go,isAtHome:po,navigate:uo,navigateToChat:mo,resetRouter:fo,viewStack:oo});const vo=["/* ============================================================================\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 /* Focus/outline */\n --pillar-outline-color: rgba(37, 99, 235, 0.15);\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 /* Status colors */\n --pillar-success: #059669;\n --pillar-error: #dc2626;\n --pillar-warning: #d97706;\n \n /* Status backgrounds (light tints) */\n --pillar-success-light: #ecfdf5;\n --pillar-success-border: #6ee7b7;\n --pillar-error-light: #fef2f2;\n --pillar-error-border: #fca5a5;\n --pillar-warning-light: #fef3c7;\n --pillar-warning-border: #fcd34d;\n \n /* Hover */\n --pillar-bg-hover: rgba(0, 0, 0, 0.05);\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-outline-color: rgba(96, 165, 250, 0.25);\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-success: #34d399;\n --pillar-error: #f87171;\n --pillar-warning: #fbbf24;\n \n --pillar-success-light: rgba(52, 211, 153, 0.1);\n --pillar-success-border: rgba(52, 211, 153, 0.3);\n --pillar-error-light: rgba(248, 113, 113, 0.1);\n --pillar-error-border: rgba(248, 113, 113, 0.3);\n --pillar-warning-light: rgba(251, 191, 36, 0.1);\n --pillar-warning-border: rgba(251, 191, 36, 0.3);\n \n --pillar-bg-hover: rgba(255, 255, 255, 0.05);\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-outline-color: rgba(96, 165, 250, 0.25);\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-success: #34d399;\n --pillar-error: #f87171;\n --pillar-warning: #fbbf24;\n \n --pillar-success-light: rgba(52, 211, 153, 0.1);\n --pillar-success-border: rgba(52, 211, 153, 0.3);\n --pillar-error-light: rgba(248, 113, 113, 0.1);\n --pillar-error-border: rgba(248, 113, 113, 0.3);\n --pillar-warning-light: rgba(251, 191, 36, 0.1);\n --pillar-warning-border: rgba(251, 191, 36, 0.3);\n \n --pillar-bg-hover: rgba(255, 255, 255, 0.05);\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\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 overflow-wrap: anywhere;\n word-break: break-word;\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 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 overflow: hidden;\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--full-width {\n width: 100vw;\n max-width: 100vw;\n}\n\n/* ============================================================================\n Mobile Bottom Sheet\n When viewport < mobileBreakpoint, the panel slides up from the bottom\n like an iOS sheet instead of from the side.\n ============================================================================ */\n\n._pillar-panel--mobile {\n top: auto;\n bottom: 0;\n left: 0;\n right: 0;\n width: 100vw;\n max-width: 100vw;\n height: 90dvh;\n max-height: 90dvh;\n border-left: none;\n border-right: none;\n border-top: none;\n border-radius: 12px 12px 0 0;\n box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15);\n overflow: hidden;\n transform: translateY(100%);\n /* iOS spring animation: fast acceleration, gradual deceleration with subtle settle */\n transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);\n will-change: transform;\n}\n\n._pillar-panel--mobile._pillar-panel--open {\n transform: translateY(0);\n}\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}\n.pillar-panel-root {\n}\n.pillar-panel-ui {\n}\n\n/* ============================================================================\n Backdrop\n ============================================================================ */\n\n._pillar-backdrop {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.4);\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1),\n visibility 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n z-index: 99998;\n -webkit-tap-highlight-color: transparent;\n}\n\n._pillar-backdrop--visible {\n opacity: 1;\n visibility: visible;\n}\n\n.pillar-backdrop {\n}\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/* ============================================================================\n Resize Handle\n Appears on the content-facing edge of the panel for drag-to-resize.\n Internal: _pillar-resize-handle | Public: pillar-resize-handle\n ============================================================================ */\n\n._pillar-resize-handle {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 6px;\n cursor: col-resize;\n z-index: 1;\n touch-action: none;\n}\n\n/* Right panel: handle on left edge */\n._pillar-panel--right ._pillar-resize-handle {\n left: -3px;\n}\n\n/* Left panel: handle on right edge */\n._pillar-panel--left ._pillar-resize-handle {\n right: -3px;\n}\n\n/* Visible indicator line on hover */\n._pillar-resize-handle::after {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n width: 3px;\n left: 50%;\n transform: translateX(-50%);\n background: transparent;\n transition: background 0.15s ease;\n border-radius: 1.5px;\n}\n\n._pillar-resize-handle:hover::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.5;\n}\n\n/* During active resize, keep indicator visible */\n._pillar-panel--resizing ._pillar-resize-handle::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.7;\n}\n\n/* Override cursor on the whole panel during resize */\n._pillar-panel--resizing,\n._pillar-panel--resizing * {\n cursor: col-resize !important;\n}\n\n/* Disable panel slide transition during resize for immediate feedback */\n._pillar-panel--resizing {\n transition: none !important;\n}\n\n/* Hide resize handle in mobile/full-width modes */\n._pillar-panel--mobile ._pillar-resize-handle,\n._pillar-panel--full-width ._pillar-resize-handle {\n display: none;\n}\n\n.pillar-resize-handle {\n}\n\n/* ============================================================================\n Reduced Motion\n Disable all panel and backdrop transitions when the user prefers reduced motion.\n ============================================================================ */\n\n@media (prefers-reduced-motion: reduce) {\n ._pillar-panel,\n ._pillar-panel--mobile,\n ._pillar-backdrop {\n transition: none;\n }\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 height: 44px;\n padding: 0 var(--pillar-spacing-md);\n flex-shrink: 0;\n background: var(--pillar-bg);\n}\n\n._pillar-panel--mobile ._pillar-header {\n position: relative;\n height: auto;\n min-height: 48px;\n padding: 20px var(--pillar-spacing-md) 8px;\n cursor: grab;\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n}\n\n/* ---- Drag indicator (iOS-style pill) ---- */\n\n._pillar-drag-indicator {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n display: flex;\n justify-content: center;\n padding: 6px 0 0;\n pointer-events: none;\n}\n\n._pillar-drag-indicator-pill {\n width: 36px;\n height: 5px;\n border-radius: 2.5px;\n background: var(--pillar-text-muted);\n opacity: 0.4;\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._pillar-header-right {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-xs);\n}\n\n/* Public override classes */\n.pillar-header {\n}\n.pillar-header-left {\n}\n.pillar-header-right {\n}\n.pillar-header-title {\n}\n.pillar-new-chat-btn {\n}\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:\n color var(--pillar-transition-fast),\n background var(--pillar-transition-fast);\n}\n\n._pillar-icon-btn:hover {\n color: var(--pillar-text);\n}\n\n._pillar-icon-btn svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-icon-btn {\n}\n.pillar-back-btn {\n}\n.pillar-home-btn {\n}\n.pillar-history-btn {\n}\n\n/* ============================================================================\n History Dropdown\n Internal: _pillar-history-* | Public: pillar-history-*\n ============================================================================ */\n\n._pillar-history-dropdown {\n position: relative;\n}\n\n._pillar-history-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: var(--pillar-spacing-xs);\n width: 280px;\n max-height: 400px;\n background: var(--pillar-bg);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);\n overflow: hidden;\n z-index: 100;\n}\n\n._pillar-history-loading {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-xl);\n color: var(--pillar-text-muted);\n font-size: 13px;\n}\n\n._pillar-history-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 {\n transform: rotate(360deg);\n }\n}\n\n._pillar-history-empty {\n padding: var(--pillar-spacing-xl);\n text-align: center;\n color: var(--pillar-text-muted);\n font-size: 13px;\n}\n\n._pillar-history-list {\n max-height: 360px;\n overflow-y: auto;\n padding: var(--pillar-spacing-xs) 0;\n}\n\n._pillar-history-group-header {\n padding: var(--pillar-spacing-xs) var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-sm);\n font-size: 10px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n letter-spacing: 0.02em;\n}\n\n._pillar-history-group-header:first-child {\n padding-top: var(--pillar-spacing-xs);\n}\n\n._pillar-history-item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: var(--pillar-spacing-xs) var(--pillar-spacing-md);\n background: none;\n border: none;\n text-align: left;\n cursor: pointer;\n transition: background var(--pillar-transition-fast);\n border-radius: var(--pillar-radius-sm);\n margin: 0 var(--pillar-spacing-xs);\n width: calc(100% - var(--pillar-spacing-sm));\n}\n\n._pillar-history-item:hover {\n background: var(--pillar-bg-secondary);\n}\n\n._pillar-history-item-title {\n font-size: 13px;\n color: var(--pillar-text);\n line-height: 1.4;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 100%;\n}\n\n/* ============================================================================\n History Dropdown – Mobile Overlay\n When inside a mobile panel, the dropdown becomes a full-screen overlay\n within the panel instead of a small positioned menu.\n ============================================================================ */\n\n._pillar-history-menu--mobile {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n max-width: 100%;\n height: 100%;\n max-height: 100%;\n margin-top: 0;\n border: none;\n border-radius: 0;\n box-shadow: none;\n z-index: 200;\n display: flex;\n flex-direction: column;\n}\n\n._pillar-history-mobile-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 48px;\n padding: 0 var(--pillar-spacing-md);\n border-bottom: 1px solid var(--pillar-border);\n flex-shrink: 0;\n}\n\n._pillar-history-mobile-title {\n font-size: 16px;\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-history-mobile-close {\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: none;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition:\n color var(--pillar-transition-fast),\n background var(--pillar-transition-fast);\n}\n\n._pillar-history-mobile-close:hover,\n._pillar-history-mobile-close:active {\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n}\n\n._pillar-history-mobile-close svg {\n width: 20px;\n height: 20px;\n}\n\n/* Mobile: larger list area fills remaining space */\n._pillar-history-menu--mobile ._pillar-history-list {\n flex: 1;\n max-height: none;\n padding: var(--pillar-spacing-sm) 0;\n -webkit-overflow-scrolling: touch;\n}\n\n/* Mobile: larger group headers */\n._pillar-history-menu--mobile ._pillar-history-group-header {\n font-size: 12px;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n}\n\n._pillar-history-menu--mobile ._pillar-history-group-header:first-child {\n padding-top: var(--pillar-spacing-sm);\n}\n\n/* Mobile: larger touch targets (min 44px) */\n._pillar-history-menu--mobile ._pillar-history-item {\n min-height: 44px;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n margin: 0 var(--pillar-spacing-sm);\n width: calc(100% - var(--pillar-spacing-md));\n border-radius: var(--pillar-radius-md);\n}\n\n._pillar-history-menu--mobile ._pillar-history-item:active {\n background: var(--pillar-bg-secondary);\n}\n\n/* Mobile: slightly larger item text */\n._pillar-history-menu--mobile ._pillar-history-item-title {\n font-size: 15px;\n}\n\n/* Mobile: loading / empty states get more breathing room */\n._pillar-history-menu--mobile ._pillar-history-loading,\n._pillar-history-menu--mobile ._pillar-history-empty {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 15px;\n}\n\n/* Public override classes */\n.pillar-history-dropdown {\n}\n.pillar-history-menu {\n}\n.pillar-history-group-header {\n}\n.pillar-history-list {\n}\n.pillar-history-item {\n}\n.pillar-history-item-title {\n}\n.pillar-close-btn {\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 /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-search-input {\n font-size: var(--pillar-font-size-base);\n }\n}\n\n._pillar-search-input:focus {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px var(--pillar-outline-color);\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 var(--pillar-outline-color);\n}\n\n._pillar-chat-input-textarea {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-chat-input-textarea {\n font-size: var(--pillar-font-size-base);\n }\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 Chat Image Upload\n ============================================================================ */\n\n._pillar-chat-view-input-area--dragging {\n position: relative;\n background: var(--pillar-primary-light);\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: var(--pillar-primary-light);\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 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:\n border-color var(--pillar-transition-fast),\n 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 1px var(--pillar-outline-color);\n}\n\n._pillar-unified-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-unified-input {\n font-size: var(--pillar-font-size-base);\n }\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 align-items: flex-end;\n padding: 4px 8px 0px 8px;\n}\n\n._pillar-unified-input-actions {\n padding-bottom: 8px;\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}\n.pillar-unified-input {\n}\n.pillar-unified-input-row {\n}\n.pillar-unified-send-btn {\n}\n\n._pillar-unified-stop-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-unified-stop-btn:hover {\n opacity: 0.9;\n}\n\n._pillar-unified-stop-btn svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-unified-stop-btn {\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","/* 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: var(--pillar-primary);\n color: #ffffff;\n border-color: var(--pillar-primary);\n}\n\n.pillar-task-btn--primary:hover {\n background: var(--pillar-primary-hover);\n border-color: var(--pillar-primary-hover);\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n border-color: var(--pillar-border);\n}\n\n.pillar-task-btn--default:hover {\n background: var(--pillar-border);\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: var(--pillar-primary-light);\n color: var(--pillar-primary);\n border-color: var(--pillar-primary-light-hover);\n}\n\n.pillar-task-btn--secondary:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: var(--pillar-primary);\n border-color: var(--pillar-primary);\n}\n\n.pillar-task-btn--outline:hover {\n background: var(--pillar-primary-light);\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: var(--pillar-text-muted);\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n}\n\n/* Active state for inline_ui buttons with expanded card */\n.pillar-task-btn--active {\n background: var(--pillar-primary-hover);\n border-color: var(--pillar-primary-hover);\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/* Inline card container for inline_ui actions */\n.pillar-task-btn-inline-card {\n margin-top: 12px;\n animation: pillar-slide-down 0.15s ease-out;\n}\n\n@keyframes pillar-slide-down {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\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: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\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: var(--pillar-text-muted);\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: var(--pillar-text-secondary);\n}\n","/* Workflow Checklist Container */\n.pillar-workflow {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\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: var(--pillar-text-muted);\n}\n\n.pillar-workflow__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n.pillar-workflow__progress {\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n padding: 2px 8px;\n background: var(--pillar-border);\n border-radius: 10px;\n}\n\n.pillar-workflow__description {\n font-size: 13px;\n color: var(--pillar-text-muted);\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: var(--pillar-bg);\n border: 1px solid var(--pillar-border);\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: var(--pillar-text-placeholder);\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: var(--pillar-text-secondary);\n}\n\n.pillar-workflow-step__note {\n font-size: 12px;\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-workflow-step__status-text {\n font-size: 12px;\n color: var(--pillar-primary);\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: var(--pillar-warning-light);\n border-color: var(--pillar-warning-border);\n}\n\n.pillar-workflow-step--awaiting_initiation .pillar-workflow-step__icon {\n color: var(--pillar-warning);\n}\n\n.pillar-workflow-step--active {\n background: var(--pillar-primary-light);\n border-color: var(--pillar-primary);\n}\n\n.pillar-workflow-step--active .pillar-workflow-step__icon {\n color: var(--pillar-primary);\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__icon {\n color: var(--pillar-success);\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__label {\n text-decoration: line-through;\n color: var(--pillar-text-muted);\n}\n\n.pillar-workflow-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__icon {\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__label {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-workflow-step--failed {\n background: var(--pillar-error-light);\n border-color: var(--pillar-error-border);\n}\n\n.pillar-workflow-step--failed .pillar-workflow-step__icon {\n color: var(--pillar-error);\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: var(--pillar-primary);\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: var(--pillar-primary-hover);\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: var(--pillar-text-muted);\n border: 1px solid var(--pillar-border);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__skip-btn:hover {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text-secondary);\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 var(--pillar-border);\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: var(--pillar-text-placeholder);\n border: none;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow__cancel-btn:hover {\n color: var(--pillar-error);\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-md);\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 var(--pillar-outline-color);\n}\n\n._pillar-home-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-home-view-input {\n font-size: var(--pillar-font-size-base);\n }\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 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 overflow-x: hidden;\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: flex-start;\n padding: var(--pillar-spacing-xl);\n text-align: center;\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/* History Loading Skeleton */\n._pillar-chat-history-loading {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-lg);\n padding: var(--pillar-spacing-md) 0;\n}\n\n._pillar-chat-history-loading-message {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-xs);\n}\n\n._pillar-chat-history-loading-message--user {\n align-items: flex-end;\n}\n\n._pillar-chat-history-loading-message--assistant {\n align-items: flex-start;\n}\n\n._pillar-chat-history-loading-bar {\n height: 16px;\n border-radius: var(--pillar-radius-md);\n background: linear-gradient(90deg, var(--pillar-bg-secondary) 25%, var(--pillar-border) 50%, var(--pillar-bg-secondary) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n}\n\n._pillar-chat-history-loading-message--user ._pillar-chat-history-loading-bar {\n background: linear-gradient(90deg, var(--pillar-bg-secondary) 25%, var(--pillar-border) 50%, var(--pillar-bg-secondary) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n}\n\n.pillar-chat-history-loading {}\n.pillar-chat-history-loading-message--user {}\n.pillar-chat-history-loading-message--assistant {}\n.pillar-chat-history-loading-bar {}\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 text-align: left;\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.45;\n color: var(--pillar-text-secondary);\n overflow-wrap: anywhere;\n max-width: 100%;\n}\n\n._pillar-message-assistant p {\n margin: 0 0 var(--pillar-spacing-sm);\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-md) 0 var(--pillar-spacing-xs);\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: 10px 0 4px;\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-sm) 0 4px;\n}\n\n._pillar-message-assistant ul,\n._pillar-message-assistant ol {\n margin: 0 0 var(--pillar-spacing-sm);\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: 2px;\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 overflow-wrap: anywhere;\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: 0 var(--pillar-spacing-xl) var(--pillar-spacing-xl);\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 var(--pillar-outline-color);\n}\n\n._pillar-chat-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-chat-view-input {\n font-size: var(--pillar-font-size-base);\n }\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 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-start;\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 flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n min-width: 0;\n overflow: hidden;\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: var(--pillar-success);\n}\n\n._pillar-action-status-indicator--failed {\n color: var(--pillar-error);\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/* Card segment (inline tool result cards) */\n._pillar-card-segment {\n margin: 8px 0;\n border-radius: var(--pillar-radius-lg, 12px);\n overflow: hidden;\n}\n\n.pillar-card-segment {}\n","/* ============================================================================\n Resume Prompt (Session Resumption)\n Internal: _pillar-resume-prompt | Public: pillar-resume-prompt\n Shows when user reconnects and has an interrupted session to resume\n ============================================================================ */\n\n._pillar-resume-prompt {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-md);\n padding: var(--pillar-spacing-lg);\n margin: var(--pillar-spacing-md) 0;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n}\n\n._pillar-resume-prompt--seamless {\n flex-direction: row;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n background: transparent;\n border: none;\n justify-content: center;\n}\n\n._pillar-resume-prompt-spinner {\n width: 16px;\n height: 16px;\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 flex-shrink: 0;\n}\n\n._pillar-resume-prompt-text {\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n font-style: italic;\n}\n\n._pillar-resume-prompt-content {\n display: flex;\n gap: var(--pillar-spacing-md);\n align-items: flex-start;\n}\n\n._pillar-resume-prompt-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n flex-shrink: 0;\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-md);\n}\n\n._pillar-resume-prompt-body {\n flex: 1;\n min-width: 0;\n}\n\n._pillar-resume-prompt-title {\n font-size: var(--pillar-font-size-base);\n font-weight: 600;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-resume-prompt-message {\n display: flex;\n flex-direction: column;\n gap: 2px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n}\n\n._pillar-resume-prompt-user-msg {\n font-style: italic;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n._pillar-resume-prompt-summary {\n font-size: var(--pillar-font-size-xs);\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-resume-prompt-actions {\n display: flex;\n gap: var(--pillar-spacing-sm);\n justify-content: flex-end;\n}\n\n._pillar-resume-prompt-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n font-family: var(--pillar-font-family);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n border: 1px solid transparent;\n}\n\n._pillar-resume-prompt-btn--primary {\n background: var(--pillar-primary);\n color: #ffffff;\n border-color: var(--pillar-primary);\n}\n\n._pillar-resume-prompt-btn--primary:hover {\n background: var(--pillar-primary-hover);\n border-color: var(--pillar-primary-hover);\n}\n\n._pillar-resume-prompt-btn--ghost {\n background: transparent;\n color: var(--pillar-text-muted);\n border-color: transparent;\n}\n\n._pillar-resume-prompt-btn--ghost:hover {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n}\n\n._pillar-resume-prompt-btn svg {\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n}\n\n.pillar-resume-prompt {}\n.pillar-resume-prompt-spinner {}\n.pillar-resume-prompt-text {}\n.pillar-resume-prompt-content {}\n.pillar-resume-prompt-icon {}\n.pillar-resume-prompt-body {}\n.pillar-resume-prompt-title {}\n.pillar-resume-prompt-message {}\n.pillar-resume-prompt-user-msg {}\n.pillar-resume-prompt-summary {}\n.pillar-resume-prompt-actions {}\n.pillar-resume-prompt-btn {}\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 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._pillar-thinking-shimmer {\n display: inline-block;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n background: linear-gradient(\n 90deg,\n var(--pillar-text-muted) 0%,\n var(--pillar-text-primary, #e5e5e5) 40%,\n var(--pillar-text-muted) 60%\n );\n background-size: 200% 100%;\n -webkit-background-clip: text;\n background-clip: text;\n -webkit-text-fill-color: transparent;\n animation: pillar-shimmer 2s ease-in-out infinite;\n}\n\n.pillar-thinking-shimmer {}\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 Progress Row (for search, query, generating events)\n Internal: _pillar-progress-row | Public: pillar-progress-row\n ============================================================================ */\n\n._pillar-progress-events {\n margin: 4px 0;\n}\n\n._pillar-progress-row {\n margin: 1px 0;\n padding: 1px 0;\n font-size: 12px;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-progress-row--error {\n color: var(--pillar-error);\n}\n\n@keyframes pillar-progress-row-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n._pillar-progress-row-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n}\n\n._pillar-progress-expand-icon {\n font-size: 10px;\n color: var(--pillar-text-muted);\n transition: transform 0.2s ease;\n flex-shrink: 0;\n}\n\n._pillar-progress-row-header[style*=\"cursor: pointer\"]:hover ._pillar-progress-expand-icon {\n color: var(--pillar-text-secondary);\n}\n\n._pillar-progress-row-header[data-expanded=\"true\"] ._pillar-progress-expand-icon {\n transform: rotate(90deg);\n}\n\n._pillar-progress-message {\n color: var(--pillar-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n._pillar-progress-no-results {\n color: var(--pillar-text-muted);\n font-size: 11px;\n font-style: italic;\n margin-left: 4px;\n}\n\n._pillar-progress-sources {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n._pillar-progress-source-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 11px;\n}\n\n._pillar-progress-source-link {\n flex: 1;\n display: flex;\n flex-direction: column;\n text-decoration: none;\n overflow: hidden;\n color: inherit;\n}\n\n._pillar-progress-source-link:hover ._pillar-progress-source-title {\n text-decoration: underline;\n}\n\n._pillar-progress-source-title {\n font-weight: 400;\n color: var(--pillar-text-muted);\n font-size: 11px;\n}\n\n._pillar-progress-details {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n._pillar-progress-detail-item {\n font-size: 11px;\n color: var(--pillar-text-muted);\n padding: 1px 0;\n}\n\n._pillar-progress-detail-action {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n}\n\n._pillar-progress-detail-name {\n font-weight: 500;\n}\n\n._pillar-progress-detail-desc {\n color: var(--pillar-text-muted);\n opacity: 0.8;\n}\n\n._pillar-progress-content-wrapper {\n position: relative;\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease-out;\n}\n\n._pillar-progress-content-wrapper--expanded {\n grid-template-rows: 1fr;\n margin-top: 6px;\n}\n\n._pillar-progress-content-container {\n overflow: hidden;\n min-height: 0;\n scrollbar-width: thin;\n scrollbar-color: var(--pillar-scrollbar-thumb) transparent;\n}\n\n._pillar-progress-content-wrapper--expanded ._pillar-progress-content-container {\n max-height: 180px;\n overflow-y: auto;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar {\n width: 4px;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-track {\n background: transparent;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-thumb {\n background-color: var(--pillar-scrollbar-thumb);\n border-radius: 2px;\n}\n\n._pillar-progress-content-gradient {\n position: absolute;\n bottom: 0;\n left: 16px;\n right: 0;\n height: 20px;\n background: linear-gradient(transparent, var(--pillar-bg));\n pointer-events: none;\n}\n\n._pillar-progress-text {\n font-size: 11px;\n color: var(--pillar-text-muted);\n line-height: 1.4;\n word-break: break-word;\n}\n\n._pillar-progress-text p {\n margin: 0 0 4px 0;\n}\n\n._pillar-progress-text p:last-child {\n margin-bottom: 0;\n}\n\n._pillar-progress-text ol,\n._pillar-progress-text ul {\n margin: 2px 0;\n padding-left: 16px;\n}\n\n._pillar-progress-text li {\n margin-bottom: 1px;\n}\n\n._pillar-progress-text br {\n display: block;\n content: \"\";\n margin-top: 2px;\n}\n\n/* Chevron indicator for progress rows - rotates based on expanded state */\n/* Positioned inline next to label, hidden by default, shown on hover */\n._pillar-progress-chevron {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n color: var(--pillar-text-muted);\n transition: transform 0.2s ease, opacity 0.15s ease;\n opacity: 0;\n}\n\n._pillar-progress-row:hover ._pillar-progress-chevron {\n opacity: 1;\n}\n\n._pillar-progress-error-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n color: var(--pillar-error);\n}\n\n/* Tool call arguments (inputs) */\n._pillar-progress-arguments {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 10px;\n margin-bottom: 6px;\n font-size: 11px;\n line-height: 1.4;\n}\n\n._pillar-progress-argument-key {\n color: var(--pillar-text-muted);\n}\n\n._pillar-progress-argument-value {\n color: var(--pillar-text-secondary);\n}\n\n/* Text preview for streaming content */\n._pillar-progress-text-preview-wrapper {\n position: relative;\n margin-top: 4px;\n}\n\n._pillar-progress-text-preview {\n max-height: 180px;\n overflow-y: auto;\n font-size: 11px;\n color: var(--pillar-text-muted);\n line-height: 1.4;\n scroll-behavior: smooth;\n white-space: pre-wrap;\n word-break: break-word;\n scrollbar-width: thin;\n scrollbar-color: var(--pillar-scrollbar-thumb) transparent;\n}\n\n/* All content inside progress text preview should stay muted and small.\n Markdown headers, paragraphs, etc. must not look like answer text. */\n._pillar-progress-text-preview * {\n color: inherit !important;\n font-size: inherit !important;\n font-weight: normal !important;\n line-height: inherit !important;\n margin: 0 !important;\n}\n\n/* Top gradient - fades out older text at the top */\n._pillar-progress-text-gradient {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 20px;\n background: linear-gradient(to bottom, var(--pillar-bg), transparent);\n pointer-events: none;\n z-index: 1;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar {\n width: 4px;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar-track {\n background: transparent;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar-thumb {\n background-color: var(--pillar-scrollbar-thumb);\n border-radius: 2px;\n}\n\n/* Active state indicator */\n._pillar-progress-row--active ._pillar-progress-message {\n font-weight: 500;\n}\n\n/* Long text truncation for labels */\n._pillar-progress-message {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 300px;\n}\n\n/* Children/sub-items styling */\n._pillar-progress-children {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n._pillar-progress-child-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 11px;\n}\n\n._pillar-progress-child-link {\n color: var(--pillar-text-muted);\n text-decoration: none;\n transition: color 0.15s ease;\n}\n\n._pillar-progress-child-link:hover {\n color: var(--pillar-text-secondary);\n text-decoration: underline;\n}\n\n._pillar-progress-child-label {\n color: var(--pillar-text-muted);\n font-size: 11px;\n}\n\n/* ============================================================================\n Progress Group (collapsible tool event groups)\n Internal: _pillar-progress-group | Public: pillar-progress-group\n ============================================================================ */\n\n._pillar-progress-group {\n margin: 1px 0;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-progress-group-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 3px 0;\n cursor: pointer;\n font-size: 12px;\n color: var(--pillar-text-secondary, #6b7280);\n user-select: none;\n border-radius: 4px;\n transition: color 0.15s ease;\n}\n\n._pillar-progress-group-chevron {\n flex-shrink: 0;\n font-size: 8px;\n line-height: 1;\n color: inherit;\n}\n\n._pillar-progress-group-summary {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n._pillar-progress-group-active-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--pillar-primary, #3b82f6);\n flex-shrink: 0;\n animation: pillar-progress-group-pulse 1.5s ease-in-out infinite;\n}\n\n@keyframes pillar-progress-group-pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.4; }\n}\n\n._pillar-progress-group-children {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease;\n overflow: hidden;\n}\n\n._pillar-progress-group-children--expanded {\n grid-template-rows: 1fr;\n}\n\n._pillar-progress-group-children-inner {\n min-height: 0;\n padding-left: 14px;\n}\n\n/* Nested rows inside groups have reduced spacing */\n._pillar-progress-row--nested {\n margin: 0;\n padding: 0;\n}\n\n._pillar-progress-row--nested ._pillar-progress-row-header {\n padding: 2px 0;\n}\n\n._pillar-progress-row--nested ._pillar-progress-message {\n font-size: 11px;\n}\n\n/* ============================================================================\n Error Row (shown when MCP request fails)\n Internal: _pillar-error-row | Public: pillar-error-row\n ============================================================================ */\n\n._pillar-error-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin: 4px 0;\n padding: 2px 0;\n font-size: 12px;\n color: var(--pillar-error);\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-error-row-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n}\n\n._pillar-error-row-message {\n font-size: 12px;\n font-style: italic;\n}\n\n._pillar-error-row-retry {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin-left: 4px;\n padding: 1px 8px;\n font-size: 11px;\n color: var(--pillar-error);\n background: none;\n border: 1px solid color-mix(in srgb, var(--pillar-error) 30%, transparent);\n border-radius: 4px;\n cursor: pointer;\n transition: background 0.15s ease, border-color 0.15s ease;\n font-family: inherit;\n line-height: 1.4;\n}\n\n._pillar-error-row-retry:hover {\n background: color-mix(in srgb, var(--pillar-error) 8%, transparent);\n border-color: color-mix(in srgb, var(--pillar-error) 50%, transparent);\n}\n\n._pillar-error-row-retry svg {\n flex-shrink: 0;\n}\n\n.pillar-error-row {}\n.pillar-error-row-icon {}\n.pillar-error-row-message {}\n.pillar-error-row-retry {}\n\n.pillar-progress-events {}\n.pillar-progress-chevron {}\n.pillar-progress-error-icon {}\n.pillar-progress-text-preview-wrapper {}\n.pillar-progress-text-preview {}\n.pillar-progress-text-gradient {}\n.pillar-progress-children {}\n.pillar-progress-child-item {}\n.pillar-progress-child-link {}\n.pillar-progress-child-label {}\n.pillar-progress-row {}\n.pillar-progress-row-header {}\n.pillar-progress-expand-icon {}\n.pillar-progress-message {}\n.pillar-progress-no-results {}\n.pillar-progress-sources {}\n.pillar-progress-source-item {}\n.pillar-progress-source-link {}\n.pillar-progress-source-title {}\n.pillar-progress-arguments {}\n.pillar-progress-argument {}\n.pillar-progress-argument-key {}\n.pillar-progress-argument-value {}\n.pillar-progress-content-wrapper {}\n.pillar-progress-content-container {}\n.pillar-progress-content-gradient {}\n.pillar-progress-text {}\n.pillar-progress-group {}\n.pillar-progress-group-header {}\n.pillar-progress-group-chevron {}\n.pillar-progress-group-summary {}\n.pillar-progress-group-active-dot {}\n.pillar-progress-group-children {}\n\n/* ============================================================================\n Secret Reveal (for sensitive tool output redemption)\n Internal: _pillar-secret-reveal | Public: pillar-secret-reveal\n ============================================================================ */\n\n._pillar-secret-reveal {\n margin: 6px 0;\n font-size: 13px;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-secret-reveal-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 6px 12px;\n border: 1px solid var(--pillar-border, #e0e0e0);\n border-radius: 6px;\n background: var(--pillar-bg-secondary);\n color: var(--pillar-text, #333);\n cursor: pointer;\n font-size: 12px;\n font-family: inherit;\n transition: background 0.15s, border-color 0.15s;\n}\n\n._pillar-secret-reveal-btn:hover {\n background: var(--pillar-bg-tertiary);\n border-color: var(--pillar-border);\n}\n\n._pillar-secret-reveal-loading {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n color: var(--pillar-text-secondary, #888);\n font-size: 12px;\n}\n\n._pillar-secret-reveal-spinner {\n animation: pillar-secret-spin 1s linear infinite;\n}\n\n@keyframes pillar-secret-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n._pillar-secret-reveal-value {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 8px;\n border-radius: 6px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border, #e0e0e0);\n max-width: 100%;\n}\n\n._pillar-secret-reveal-code {\n font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;\n font-size: 11px;\n word-break: break-all;\n color: var(--pillar-text, #333);\n}\n\n._pillar-secret-reveal-copy {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 2px;\n border: none;\n background: transparent;\n color: var(--pillar-text-secondary, #888);\n cursor: pointer;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n._pillar-secret-reveal-copy:hover {\n color: var(--pillar-text, #333);\n background: var(--pillar-bg-tertiary);\n}\n\n._pillar-secret-reveal-expired,\n._pillar-secret-reveal-error {\n font-size: 12px;\n color: var(--pillar-text-secondary, #888);\n font-style: italic;\n}\n\n.pillar-secret-reveal {}\n.pillar-secret-reveal-btn {}\n.pillar-secret-reveal-value {}\n.pillar-secret-reveal-code {}\n.pillar-secret-reveal-copy {}\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: var(--pillar-success);\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: var(--pillar-error-light);\n border: 1px solid var(--pillar-error-border);\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n color: var(--pillar-error);\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","/* ============================================================================\n Markdown Component Styles\n Combined from markdown-components.tsx and preact-markdown.tsx\n ============================================================================ */\n\n/* Collapsible Section */\n._pillar-collapsible {\n margin: 2px 0;\n}\n\n._pillar-collapsible-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n background: transparent;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n font-family: inherit;\n width: 100%;\n text-align: left;\n transition: background-color 0.15s ease;\n}\n\n._pillar-collapsible-header:hover {\n background: var(--pillar-bg-hover);\n}\n\n._pillar-collapsible-icon {\n font-size: 10px;\n color: var(--pillar-text-muted, #9ca3af);\n}\n\n._pillar-collapsible-title {\n flex: 1;\n}\n\n._pillar-collapsible-content-wrapper {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease;\n}\n\n._pillar-collapsible-content-wrapper--expanded {\n grid-template-rows: 1fr;\n}\n\n._pillar-collapsible-content {\n overflow: hidden;\n padding-left: 18px;\n font-size: 13px;\n color: var(--pillar-text-secondary, #6b7280);\n line-height: 1.4;\n}\n\n._pillar-collapsible-content-wrapper--expanded ._pillar-collapsible-content {\n padding-top: 2px;\n padding-bottom: 4px;\n}\n\n/* Source List */\n._pillar-source-list {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 4px 0;\n}\n\n._pillar-source-item {\n display: block;\n padding: 4px 8px;\n font-size: 12px;\n color: var(--pillar-primary, #2563eb);\n text-decoration: none;\n border-radius: 4px;\n transition: background-color 0.15s ease;\n}\n\n._pillar-source-item:hover {\n background: var(--pillar-bg-hover);\n text-decoration: underline;\n}\n\n/* Task List */\n._pillar-task-list {\n list-style: none;\n padding: 0;\n margin: 8px 0;\n}\n\n._pillar-task-item {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 4px 0;\n font-size: 13px;\n}\n\n._pillar-task-item--completed ._pillar-task-text {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder, #9ca3af);\n}\n\n._pillar-task-checkbox {\n width: 16px;\n height: 16px;\n cursor: pointer;\n}\n\n/* Code Block */\n._pillar-code-block {\n margin: 8px 0;\n border-radius: 8px;\n overflow: hidden;\n background: var(--pillar-bg-code, #1e1e1e);\n}\n\n._pillar-code-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 12px;\n background: var(--pillar-bg-code-header, #2d2d2d);\n border-bottom: 1px solid var(--pillar-border-code, #404040);\n}\n\n._pillar-code-language {\n font-size: 11px;\n font-weight: 500;\n color: var(--pillar-text-code-header, #a0a0a0);\n text-transform: uppercase;\n}\n\n._pillar-code-copy {\n padding: 4px 8px;\n font-size: 11px;\n font-family: inherit;\n background: transparent;\n border: 1px solid var(--pillar-border-code, #404040);\n border-radius: 4px;\n color: var(--pillar-text-code-header, #a0a0a0);\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n._pillar-code-copy:hover {\n background: var(--pillar-bg-code-hover, #404040);\n color: #fff;\n}\n\n._pillar-code-pre {\n margin: 0;\n padding: 12px;\n overflow-x: auto;\n font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;\n font-size: 13px;\n line-height: 1.5;\n}\n\n._pillar-code-content {\n color: var(--pillar-text-code, #e0e0e0);\n}\n\n/* Action Buttons */\n._pillar-action-buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin: 8px 0;\n}\n\n._pillar-action-button {\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #fff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n._pillar-action-button:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Progress Indicator */\n._pillar-progress-indicator {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n font-size: 13px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n._pillar-progress-indicator--active ._pillar-loading-spinner {\n display: inline-block;\n}\n\n/* Streaming Thinking Content */\n._pillar-progress-row--streaming {\n margin: 2px 0;\n}\n\n._pillar-thinking-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n._pillar-thinking-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n}\n\n._pillar-spinner {\n width: 12px;\n height: 12px;\n border: 2px solid var(--pillar-border, #e5e7eb);\n border-top-color: var(--pillar-primary, #2563eb);\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-thinking-label {\n flex: 1;\n}\n\n._pillar-thinking-content {\n padding: 6px 10px;\n font-size: 13px;\n line-height: 1.4;\n color: var(--pillar-text-secondary, #6b7280);\n background: var(--pillar-bg-tertiary, #f9fafb);\n border-radius: 4px;\n margin-top: 2px;\n max-height: 150px;\n overflow-y: auto;\n}\n\n/* ============================================================================\n Preact Markdown Styles\n ============================================================================ */\n\n/* Base markdown container */\n._pillar-markdown {\n font-size: 14px;\n line-height: 1.45;\n color: var(--pillar-text, #1a1a1a);\n overflow-wrap: anywhere;\n}\n\n/* Headings */\n._pillar-md-heading {\n margin: 10px 0 4px 0;\n font-weight: 600;\n line-height: 1.3;\n}\n\n._pillar-md-h1 { font-size: 1.5em; }\n._pillar-md-h2 { font-size: 1.3em; }\n._pillar-md-h3 { font-size: 1.15em; }\n._pillar-md-h4 { font-size: 1em; }\n._pillar-md-h5 { font-size: 0.95em; }\n._pillar-md-h6 { font-size: 0.9em; }\n\n/* Paragraphs */\n._pillar-md-paragraph {\n margin: 4px 0;\n}\n\n/* Links */\n._pillar-md-link {\n color: var(--pillar-primary, #2563eb);\n text-decoration: none;\n}\n\n._pillar-md-link:hover {\n text-decoration: underline;\n}\n\n/* Inline code */\n._pillar-md-code-inline {\n padding: 2px 6px;\n font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;\n font-size: 0.9em;\n background: var(--pillar-bg-tertiary);\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Lists */\n._pillar-md-list {\n margin: 4px 0;\n padding-left: 24px;\n}\n\n._pillar-md-list-item {\n margin: 2px 0;\n}\n\n/* Task list items */\n._pillar-md-task-item {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n list-style: none;\n margin-left: -24px;\n}\n\n._pillar-md-task-checkbox {\n margin-top: 4px;\n}\n\n._pillar-md-task-text--checked {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder, #9ca3af);\n}\n\n/* Blockquote */\n._pillar-md-blockquote {\n margin: 8px 0;\n padding: 8px 16px;\n border-left: 3px solid var(--pillar-border, #e5e7eb);\n color: var(--pillar-text-muted, #6b7280);\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n/* Horizontal rule */\n._pillar-md-hr {\n margin: 16px 0;\n border: none;\n border-top: 1px solid var(--pillar-border, #e5e7eb);\n}\n\n/* Tables */\n._pillar-md-table-wrapper {\n overflow-x: auto;\n margin: 8px 0;\n max-width: 100%;\n}\n\n._pillar-md-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 13px;\n}\n\n._pillar-md-th,\n._pillar-md-td {\n padding: 8px 12px;\n border: 1px solid var(--pillar-border, #e5e7eb);\n text-align: left;\n min-width: 100px;\n}\n\n._pillar-md-th {\n background: var(--pillar-bg-secondary, #f9fafb);\n font-weight: 600;\n}\n\n/* Images */\n._pillar-md-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n margin: 8px 0;\n}\n"].join("\n");function _o(e,t=""){const n=[];return e.primary&&n.push(`--pillar-primary${t}: ${e.primary};`),e.primaryHover&&n.push(`--pillar-primary-hover${t}: ${e.primaryHover};`),e.background&&n.push(`--pillar-bg${t}: ${e.background};`),e.backgroundSecondary&&n.push(`--pillar-bg-secondary${t}: ${e.backgroundSecondary};`),e.text&&n.push(`--pillar-text${t}: ${e.text};`),e.textMuted&&n.push(`--pillar-text-muted${t}: ${e.textMuted};`),e.border&&n.push(`--pillar-border${t}: ${e.border};`),e.borderLight&&n.push(`--pillar-border-light${t}: ${e.borderLight};`),e.outlineColor&&n.push(`--pillar-outline-color${t}: ${e.outlineColor};`),n.join("\n ")}function xo(e){const t=_o(e.colors),n=_o(e.darkColors),r=e.fontFamily?`--pillar-font-family: ${e.fontFamily};`:"";let i="";return(t||r)&&(i+=`\n:host {\n ${[t,r].filter(Boolean).join("\n ")}\n}\n`),n&&(i+=`\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n ${n}\n }\n}\n:host([data-theme="dark"]) {\n ${n}\n}\n`),i}const yo=function(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,j(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+C++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}(null);function wo({api:e,events:t,config:n,children:r}){return Kr(yo.Provider,{value:{api:e,events:t,config:n},children:r})}function ko(){const e=function(e){var t=Qr.context[e.__c],n=oi(Gr++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Qr)),t.props.value):e.__}(yo);if(!e)throw new Error("usePillar must be used within a PillarProvider");return e}function So(){return ko().api}function Co(){return ko().config}const Po=Ai([]),Eo=Ai([]),To=Ai(!1),zo=Ai(null),Ro=Ai(null);function Io(e,t,n,r=3){if(0===e.length)return[];const i=e.filter(e=>function(e,t){if(!e)return!0;if(e===t)return!0;if(e.endsWith("/**")){const n=e.slice(0,-3);return t===n||t.startsWith(n+"/")}if(e.endsWith("/*")){const n=e.slice(0,-2);return!!t.startsWith(n+"/")&&!t.slice(n.length+1).includes("/")}return t.startsWith(e)}(e.pathPattern,t));if(0===i.length)return[];const a=function(e,t){const n=e.split("/").filter(Boolean).flatMap(e=>e.split(/[-_]/)),r=t.toLowerCase().split(/\s+/);return[...new Set([...n,...r])].map(e=>e.toLowerCase()).filter(e=>e.length>2)}(t,n),l=i.map(e=>({suggestion:e,score:Ao(e,a)}));return l.sort((e,t)=>t.score-e.score),l.slice(0,r).map(e=>e.suggestion)}function Ao(e,t){if(e.manual)return 1/0;const n=e.text.toLowerCase();let r=0;for(const e of t)n.includes(e)&&(r+=e.length);return r}function Mo(e){To.value=e}Di(()=>Eo.value.length>0),Di(()=>Po.value.length>0);const $o='<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 Lo({context:e,onRemove:t,readOnly:n=!1}){const r=Ha(e),i=function(e){return Da(e),$o}(e),a=function(e){if(Da(e)){const t=e.url_origin?`\nFrom: ${e.url_origin}`:"";return`"${e.text_content}"${t}`}return""}(e);return Kr("div",{class:"_pillar-context-tag pillar-context-tag",title:a,children:[Kr("span",{class:"_pillar-context-tag-icon pillar-context-tag-icon",dangerouslySetInnerHTML:{__html:i}}),Kr("span",{class:"_pillar-context-tag-label pillar-context-tag-label",children:r}),!n&&t&&Kr("button",{class:"_pillar-context-tag-remove pillar-context-tag-remove",onClick:n=>{n.preventDefault(),n.stopPropagation(),t?.(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 Oo({contexts:e,onRemove:t,readOnly:n=!1}){const r=e.filter(e=>!ja(e));return 0===r.length?null:Kr("div",{class:"_pillar-context-tag-list pillar-context-tag-list",children:r.map(e=>Kr(Lo,{context:e,onRemove:t,readOnly:n},e.id))})}const Do='<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 jo({placeholder:e="Ask anything...",disabled:t=!1,onSubmit:n,showContextTags:r=!0,showImageUpload:i=!0,className:a="",isStreaming:l=!1,onStop:o}){const s=So(),c=pi(null),p=pi(null),[d,u]=si(""),[h,g]=si(!1),f=ui(()=>{const e=c.current;if(!e)return;e.style.height="41px";const t=e.scrollHeight;t>146?(e.style.height="146px",e.style.overflowY="auto"):(e.style.height=`${t}px`,e.style.overflowY="hidden")},[]),m=ui(async e=>{if(vl.value.length>=4)return;const t=`img-${Date.now()}-${Math.random().toString(36).slice(2)}`,n=URL.createObjectURL(e);yl({id:t,file:e,preview:n,status:"uploading"});try{const n=await s.uploadImage(e);wl(t,"ready",n.url,void 0,n.path)}catch(e){const n=e instanceof Error?e.message:"Upload failed";wl(t,"error",void 0,n)}},[s]),b=ui(e=>{const t=Array.from(e).filter(e=>e.type.startsWith("image/")),n=4-vl.value.length;t.slice(0,n).forEach(m)},[m]),v=ui(e=>{const t=e.clipboardData?.items;if(!t)return;const n=[];for(const e of t)if(e.type.startsWith("image/")){const t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),b(n))},[b]),_=ui(e=>{e.preventDefault(),e.stopPropagation(),g(!0)},[]),x=ui(e=>{e.preventDefault(),e.stopPropagation(),g(!1)},[]),y=ui(e=>{e.preventDefault(),e.stopPropagation(),g(!1);const t=e.dataTransfer?.files;t&&b(t)},[b]),w=ui(e=>{const t=e.target;t.files&&(b(t.files),t.value="")},[b]),k=ui(()=>{p.current?.click()},[]),S=ui(()=>{const e=d.trim(),t=[...fl.value],r=xl(),i=t.length>0,a=r.length>0;(e||i||a)&&(_l.value||(i&&Kl(),Sl(),n?n(e,t,r):(i&&Gl(t),a&&Jl(r),Ul(e),mo()),u(""),c.current&&(c.current.style.height="41px",c.current.style.overflowY="hidden")))},[d,n]),C=_l.value,P=d.trim()||fl.value.length>0||vl.value.some(e=>"ready"===e.status);return Kr("div",{class:`_pillar-unified-input-wrapper pillar-unified-input-wrapper ${h?"_pillar-unified-input-wrapper--dragging":""} ${a}`.trim(),onDragOver:_,onDragLeave:x,onDrop:y,children:[Kr("input",{ref:p,type:"file",accept:"image/*",multiple:!0,onChange:w,style:{display:"none"}}),vl.value.length>0&&Kr("div",{class:"_pillar-chat-images-preview pillar-chat-images-preview",children:vl.value.map(e=>Kr("div",{class:"_pillar-chat-image-thumb pillar-chat-image-thumb",children:[Kr("img",{src:e.preview,alt:"Upload preview"}),"uploading"===e.status&&Kr("div",{class:"_pillar-chat-image-loading pillar-chat-image-loading",children:Kr("div",{class:"_pillar-loading-spinner pillar-loading-spinner",style:{width:"16px",height:"16px"}})}),"error"===e.status&&Kr("div",{class:"_pillar-chat-image-error pillar-chat-image-error",title:e.error,children:"!"}),Kr("button",{type:"button",class:"_pillar-chat-image-remove pillar-chat-image-remove",onClick:()=>kl(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&&Kr(Oo,{contexts:fl.value,onRemove:Vl}),Kr("textarea",{ref:c,class:"_pillar-unified-input pillar-unified-input",placeholder:h?"Drop image here...":e,value:d,onInput:e=>{const t=e.target;u(t.value),f()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),S())},onPaste:v,disabled:t||l,maxLength:32e3,style:{height:"41px"}}),Kr("div",{class:"_pillar-unified-input-row pillar-unified-input-row",children:[i&&!l&&Kr("button",{type:"button",class:"_pillar-chat-image-btn pillar-chat-image-btn",onClick:k,disabled:t||C||vl.value.length>=4,"aria-label":"Attach image",title:"Attach image (max 4)",dangerouslySetInnerHTML:{__html:Do}}),Kr("div",{class:"_pillar-unified-input-actions pillar-unified-input-actions",children:Kr("button",l?{type:"button",class:"_pillar-unified-stop-btn pillar-unified-stop-btn",onClick:o,"aria-label":"Stop generating",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>'}}:{type:"button",class:"_pillar-unified-send-btn pillar-unified-send-btn",onClick:S,disabled:t||C||!P,"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>'}})})]}),h&&Kr("div",{class:"_pillar-chat-drop-overlay pillar-chat-drop-overlay",children:[Kr("span",{dangerouslySetInnerHTML:{__html:Do}}),Kr("span",{children:"Drop image here"})]})]})}function Ho({text:e,onClick:t}){return Kr("button",{type:"button",class:"_pillar-question-chip pillar-question-chip",onClick:t,children:[Kr("span",{class:"_pillar-question-chip-text pillar-question-chip-text",children:e}),Kr("span",{class:"_pillar-question-chip-arrow pillar-question-chip-arrow",children:"→"})]})}function No(){return Kr("div",{class:"_pillar-question-chip-skeleton pillar-question-chip-skeleton",children:Kr("div",{class:"_pillar-question-chip-skeleton-bar pillar-question-chip-skeleton-bar"})})}function Uo(){const e=Co(),t=Ki(()=>Eo.value),n=Ki(()=>To.value);return Kr("div",{class:"_pillar-home-view pillar-home-view",children:[e.welcomeMessage&&Kr("div",{class:"_pillar-home-view-welcome pillar-home-view-welcome",style:{fontSize:"1.25rem",fontWeight:500,padding:"16px 0"},children:e.welcomeMessage}),Kr("div",{style:{flex:1}}),Kr("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:n.value?Kr($,{children:[Kr(No,{}),Kr(No,{}),Kr(No,{})]}):t.value&&t.value.length>0?t.value.map(e=>Kr(Ho,{text:e.text,onClick:()=>(e=>{Ul(e.text),mo()})(e)},e.id)):null}),Kr(jo,{placeholder:e.inputPlaceholder})]})}const Bo=Ai(!1),Fo=Ai(null),qo=Ai(!1),Wo=Ai(null);function Vo(e,t){Bo.value=!0,Fo.value=e,qo.value=!1,Wo.value=t??null}function Ko(){Bo.value=!1,Fo.value=null,Wo.value=null}function Go(){qo.value=!1}function Qo(){return qo.value}const Jo=Ai(!1),Xo=Ai(null),Zo=Ai(null);var Yo=Object.freeze({__proto__:null,confirmationLabel:Xo,confirmationResolver:Zo,currentToolCallId:Wo,isCancelled:qo,isPiloting:Bo,needsConfirmation:Jo,pilotOperation:Fo,requestConfirmation:function(e){return new Promise(t=>{Xo.value=e,Zo.value=t,Jo.value=!0})},resetCancellation:Go,startPiloting:Vo,stopPiloting:Ko,wasCancelled:Qo});function es(e){if(e)try{const t=ts(e);localStorage.removeItem(t),p.log("[SessionPersistence] Cleared saved session")}catch(e){p.warn("[SessionPersistence] Failed to clear session:",e)}}function ts(e){return`pillar:active_session:${e}`}var ns=Object.freeze({__proto__:null,clearActiveSession:es,loadActiveSession:function(e){if(!e)return p.warn("[SessionPersistence] loadActiveSession called with empty siteId"),null;try{const t=ts(e),n=localStorage.getItem(t);if(!n)return p.log(`[SessionPersistence] No session found at key "${t}"`),null;const r=JSON.parse(n);return 1!==r.version?(p.warn("[SessionPersistence] Stored session has incompatible version, clearing"),es(e),null):r.siteId!==e?(p.warn("[SessionPersistence] Stored session is for different site, clearing"),es(e),null):(p.log(`[SessionPersistence] Loaded session ${r.conversationId.slice(0,8)}... from localStorage`),r)}catch(t){return p.warn("[SessionPersistence] Failed to load session:",t),es(e),null}},saveActiveSession:function(e,t){if(e&&t)try{const n={version:1,conversationId:e,siteId:t,streamingStartedAt:(new Date).toISOString()},r=ts(t);localStorage.setItem(r,JSON.stringify(n)),p.log(`[SessionPersistence] Saved session ${e.slice(0,8)}... to localStorage (key="${r}")`)}catch(e){p.warn("[SessionPersistence] Failed to save session:",e)}}});function rs(e){if(null==e)return{success:!0};if("object"!=typeof e||Array.isArray(e))return e;const t=e;return!1===t.success?{success:!1,error:t.error||t.message||"Action failed"}:"data"in t&&null!=t.data&&"object"==typeof t.data?t.data:e}const is={maxDepth:20,includeText:!0,visibleOnly:!0,minTextLength:1,maxTextLength:500,maxTotalLength:5e4,maxLabelLength:100,includePositions:!1},as=new Set(["a","button","input","select","textarea","details","summary","dialog","menu","menuitem"]),ls=new Set(["button","link","checkbox","radio","switch","tab","tabpanel","menuitem","menuitemcheckbox","menuitemradio","option","slider","spinbutton","textbox","combobox","listbox","searchbox","tree","treeitem","grid","gridcell","row","rowheader","columnheader"]),os=new Set(["script","style","noscript","template","svg","path","iframe","object","embed","head","meta","link","base"]);let ss=0;function cs(){document.querySelectorAll("[data-pillar-ref]").forEach(e=>e.removeAttribute("data-pillar-ref")),ss=0}let ps=new Set,ds=new Set;function us(e){return e instanceof HTMLInputElement&&"password"===e.type.toLowerCase()||null!==e.closest("[data-pillar-redact]")}const hs=/\b(delete|remove|destroy|reset|revoke|archive|cancel subscription|deactivate|disable|erase|purge|terminate|unsubscribe|drop)\b/i;function gs(e){if(e.hasAttribute("data-pillar-destructive"))return!0;const t=e.getAttribute("aria-label");if(t&&hs.test(t))return!0;const n=e.textContent?.trim().slice(0,200);if(n&&hs.test(n))return!0;const r=e.getAttribute("title");if(r&&hs.test(r))return!0;if(e instanceof HTMLInputElement||e instanceof HTMLButtonElement){const t=e.type?.toLowerCase();if("reset"===t||"submit"===t){const t=e.closest("form");if(t){const e=t.getAttribute("action")||"";if(hs.test(e))return!0}}}return!1}function fs(e){const t=e.tagName.toLowerCase();if(e.hasAttribute("data-pillar-interactable"))return!0;if(as.has(t))return!0;const n=e.getAttribute("role");if(n&&ls.has(n))return!0;const r=e.getAttribute("tabindex");return null!==r&&"-1"!==r||("true"===e.getAttribute("contenteditable")||!!(e.hasAttribute("onclick")||e.hasAttribute("onkeydown")||e.hasAttribute("onkeyup")))}const ms=/^pr-[a-z0-9]+$/;function bs(e){return ms.test(e)}function vs(e){if(!bs(e))throw new Error(`Invalid pillar ref format: "${e}"`);return`[data-pillar-ref="${e}"]`}function _s(e,t){return e.length<=t?e:e.slice(0,t)+"..."}function xs(e,t){const n=function(e){const t=e.getAttribute("aria-label");if(t)return t;const n=e.getAttribute("aria-labelledby");if(n){const e=document.getElementById(n);if(e)return e.textContent?.trim()||void 0}if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement){if(e.id){const t=document.querySelector(`label[for="${e.id}"]`);if(t)return t.textContent?.trim()||void 0}const t=e.closest("label");if(t){const e=t.cloneNode(!0);e.querySelectorAll("input, select, textarea").forEach(e=>e.remove());const n=e.textContent?.trim();if(n)return n}}const r=e.getAttribute("title");return r||void 0}(e);if(n)return _s(n,t);if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.placeholder)return _s(e.placeholder,t);const r=e.textContent?.trim();if(r&&r.length>0)return _s(r,t);const i=e.getAttribute("name");return i?_s(i,t):e.id?_s(e.id,t):e.tagName.toLowerCase()}function ys(e,t,n){if(n>t.maxDepth&&(t.maxDepth=n),n>t.options.maxDepth)return;if(e.nodeType===Node.TEXT_NODE){if(t.options.includeText&&!t.budgetExhausted){const n=e.textContent?.trim();if(n&&n.length>=t.options.minTextLength){const e=n.length>t.options.maxTextLength?n.slice(0,t.options.maxTextLength)+"...":n,r=e.length+1;if(t.totalLength+r>t.options.maxTotalLength)return void(t.budgetExhausted=!0);t.lines.push(e),t.totalLength+=r}}return}if(e.nodeType!==Node.ELEMENT_NODE)return;const r=e,i=r.tagName.toLowerCase();if(!os.has(i)){if(t.options.excludeSelector)try{if(r.matches(t.options.excludeSelector))return}catch{}if((!t.options.visibleOnly||function(e){if(!e.isConnected)return!1;const t=window.getComputedStyle(e);if("none"===t.display)return!1;if("hidden"===t.visibility)return!1;if("0"===t.opacity)return!1;const n=e.getBoundingClientRect();return(0!==n.width||0!==n.height)&&!e.hasAttribute("hidden")&&"true"!==e.getAttribute("aria-hidden")}(r))&&!r.hasAttribute("data-pillar-redact")){if(fs(r)){if(us(r))return;const e=function(e){const t=e.tagName.toLowerCase(),n=e.getAttribute("data-pillar-interactable");if(n&&"true"!==n)return n;switch(t){case"input":switch(e.type.toLowerCase()){case"checkbox":case"radio":return"toggle";case"submit":case"button":case"reset":return"click";case"file":return"select";default:return"input"}case"textarea":return"input";case"select":return"select";case"button":return"submit"===e.getAttribute("type")?"submit":"click";case"a":return"click";case"details":case"summary":return"toggle"}const r=e.getAttribute("role");if(r)switch(r){case"button":case"link":case"menuitem":case"tab":default:return"click";case"checkbox":case"radio":case"switch":return"toggle";case"textbox":case"searchbox":case"combobox":case"slider":case"spinbutton":return"input";case"listbox":case"option":return"select"}return"true"===e.getAttribute("contenteditable")?"input":"click"}(r),n=xs(r,t.options.maxLabelLength);let i=r.getAttribute("data-pillar-ref");i||(i=`pr-${(ss++).toString(36)}`,r.setAttribute("data-pillar-ref",i)),t.refs.add(i);const a=`${e.toUpperCase()}: ${n} [[${i}]]`;t.lines.push(a),t.totalLength+=a.length+1,t.interactableCount++}for(const e of r.childNodes)ys(e,t,n+1)}}}function ws(e){cs();const t=e?.root||document.body,n={lines:[],refs:new Set,interactableCount:0,totalLength:0,budgetExhausted:!1,maxDepth:0,options:{...is,...e}};return n.lines.push(`=== PAGE: ${document.title} | ${window.location.pathname} ===`),n.lines.push(""),ys(t,n,0),n.lines.push(""),n.lines.push(`=== ${n.interactableCount} interactable elements ===`),ps=new Set(n.lines),ds=new Set(n.refs),{content:n.lines.join("\n"),interactableCount:n.interactableCount,timestamp:Date.now(),url:window.location.href,title:document.title}}function ks(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ss={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Cs(e){Ss=e}var Ps={exec:()=>null};function Es(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(zs.caret,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ts=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),zs={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")},Rs=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Is=/(?:[*+-]|\d{1,9}[.)])/,As=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ms=Es(As).replace(/bull/g,Is).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(),$s=Es(As).replace(/bull/g,Is).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(),Ls=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Os=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ds=Es(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Os).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),js=Es(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Is).getRegex(),Hs="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",Ns=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Us=Es("^ {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",Ns).replace("tag",Hs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Bs=Es(Ls).replace("hr",Rs).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",Hs).getRegex(),Fs={blockquote:Es(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Bs).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:Ds,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Rs,html:Us,lheading:Ms,list:js,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Bs,table:Ps,text:/^[^\n]+/},qs=Es("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Rs).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",Hs).getRegex(),Ws={...Fs,lheading:$s,table:qs,paragraph:Es(Ls).replace("hr",Rs).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qs).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",Hs).getRegex()},Vs={...Fs,html:Es("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Ns).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:Ps,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Es(Ls).replace("hr",Rs).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Ms).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ks=/^( {2,}|\\)\n(?!\s*$)/,Gs=/[\p{P}\p{S}]/u,Qs=/[\s\p{P}\p{S}]/u,Js=/[^\s\p{P}\p{S}]/u,Xs=Es(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qs).getRegex(),Zs=/(?!~)[\p{P}\p{S}]/u,Ys=Es(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ts?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ec=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,tc=Es(ec,"u").replace(/punct/g,Gs).getRegex(),nc=Es(ec,"u").replace(/punct/g,Zs).getRegex(),rc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ic=Es(rc,"gu").replace(/notPunctSpace/g,Js).replace(/punctSpace/g,Qs).replace(/punct/g,Gs).getRegex(),ac=Es(rc,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Zs).getRegex(),lc=Es("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Js).replace(/punctSpace/g,Qs).replace(/punct/g,Gs).getRegex(),oc=Es(/\\(punct)/,"gu").replace(/punct/g,Gs).getRegex(),sc=Es(/^<(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(),cc=Es(Ns).replace("(?:--\x3e|$)","--\x3e").getRegex(),pc=Es("^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",cc).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),dc=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,uc=Es(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",dc).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hc=Es(/^!?\[(label)\]\[(ref)\]/).replace("label",dc).replace("ref",Os).getRegex(),gc=Es(/^!?\[(ref)\](?:\[\])?/).replace("ref",Os).getRegex(),fc=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,mc={_backpedal:Ps,anyPunctuation:oc,autolink:sc,blockSkip:Ys,br:Ks,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Ps,emStrongLDelim:tc,emStrongRDelimAst:ic,emStrongRDelimUnd:lc,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:uc,nolink:gc,punctuation:Xs,reflink:hc,reflinkSearch:Es("reflink|nolink(?!\\()","g").replace("reflink",hc).replace("nolink",gc).getRegex(),tag:pc,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Ps},bc={...mc,link:Es(/^!?\[(label)\]\((.*?)\)/).replace("label",dc).getRegex(),reflink:Es(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",dc).getRegex()},vc={...mc,emStrongRDelimAst:ac,emStrongLDelim:nc,url:Es(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",fc).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:Es(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",fc).getRegex()},_c={...vc,br:Es(Ks).replace("{2,}","*").getRegex(),text:Es(vc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},xc={normal:Fs,gfm:Ws,pedantic:Vs},yc={normal:mc,gfm:vc,breaks:_c,pedantic:bc},wc={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},kc=e=>wc[e];function Sc(e,t){if(t){if(zs.escapeTest.test(e))return e.replace(zs.escapeReplace,kc)}else if(zs.escapeTestNoEncode.test(e))return e.replace(zs.escapeReplaceNoEncode,kc);return e}function Cc(e){try{e=encodeURI(e).replace(zs.percentDecode,"%")}catch{return null}return e}function Pc(e,t){let n=e.replace(zs.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"}),r=n.split(zs.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(zs.slashPipe,"|");return r}function Ec(e,t,n){let r=e.length;if(0===r)return"";let i=0;for(;i<r;){if(e.charAt(r-i-1)!==t)break;i++}return e.slice(0,r-i)}function Tc(e,t,n,r,i){let a=t.href,l=t.title||null,o=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let s={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:a,title:l,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,s}var zc=class{options;rules;lexer;constructor(e){this.options=e||Ss}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Ec(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let i=r[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Ec(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ec(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Ec(t[0],"\n").split("\n"),n="",r="",i=[];for(;e.length>0;){let t,a=!1,l=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))l.push(e[t]),a=!0;else{if(a)break;l.push(e[t])}e=e.slice(t);let o=l.join("\n"),s=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${o}`:o,r=r?`${r}\n${s}`:s;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(s,i,!0),this.lexer.state.top=c,0===e.length)break;let p=i.at(-1);if("code"===p?.type)break;if("blockquote"===p?.type){let t=p,a=t.raw+"\n"+e.join("\n"),l=this.blockquote(a);i[i.length-1]=l,n=n.substring(0,n.length-t.raw.length)+l.raw,r=r.substring(0,r.length-t.text.length)+l.text;break}if("list"===p?.type){let t=p,a=t.raw+"\n"+e.join("\n"),l=this.list(a);i[i.length-1]=l,n=n.substring(0,n.length-p.raw.length)+l.raw,r=r.substring(0,r.length-t.raw.length)+l.raw,e=a.substring(i.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let a=this.rules.other.listItemRegex(n),l=!1;for(;e;){let n=!1,r="",o="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let s=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],p=!s.trim(),d=0;if(this.options.pedantic?(d=2,o=s.trimStart()):p?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,o=s.slice(d),d+=t[1].length),p&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=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(c=h,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),i.test(c)||a.test(c)||l.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=d||!c.trim())o+="\n"+u.slice(d);else{if(p||s.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(s)||a.test(s)||n.test(s))break;o+="\n"+c}!p&&!c.trim()&&(p=!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 t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.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=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));i.loose=n}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Pc(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.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<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Pc(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Ec(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Tc(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Tc(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){let n,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,t=t.slice(-1*e.length+a);null!=(r=s.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(i=[...n].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 t=[...r[0]][0].length,s=e.slice(0,a+r.index+t+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 c=s.slice(2,-2);return{type:"strong",raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Rc=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ss,this.options.tokenizer=this.options.tokenizer||new zc,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 t={other:zs,block:xc.normal,inline:yc.normal};this.options.pedantic?(t.block=xc.pedantic,t.inline=yc.pedantic):this.options.gfm&&(t.block=xc.gfm,this.options.breaks?t.inline=yc.breaks:t.inline=yc.gfm),this.tokenizer.rules=t}static get rules(){return{block:xc,inline:yc}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(zs.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(zs.tabCharGlobal," ").replace(zs.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&"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):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,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));)n=i[2]?i[2].length:0,r=r.slice(0,i.index+n)+"["+"a".repeat(i[0].length-n-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 n;if(a||(l=""),a=!1,this.options.extensions?.inline?.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let r=t.at(-1);"text"===n.type&&"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,r,l)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let i=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(i)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(l=n.raw.slice(-1)),a=!0;let r=t.at(-1);"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},Ic=class{options;parser;constructor(e){this.options=e||Ss}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(zs.notSpaceStart)?.[0],i=e.replace(zs.endingNewline,"")+"\n";return r?'<pre><code class="language-'+Sc(r)+'">'+(n?i:Sc(i,!0))+"</code></pre>\n":"<pre><code>"+(n?i:Sc(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:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,r="";for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?"ol":"ul";return"<"+i+(t&&1!==n?' start="'+n+'"':"")+">\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 t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r="";for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n="";for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\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>${Sc(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Cc(e);if(null===i)return r;let a='<a href="'+(e=i)+'"';return t&&(a+=' title="'+Sc(t)+'"'),a+=">"+r+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Cc(e);if(null===i)return Sc(n);let a=`<img src="${e=i}" alt="${n}"`;return t&&(a+=` title="${Sc(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Sc(e.text)}},Ac=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}},Mc=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ss,this.options.renderer=this.options.renderer||new Ic,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ac}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let i=r;switch(i.type){case"space":t+=this.renderer.space(i);break;case"hr":t+=this.renderer.hr(i);break;case"heading":t+=this.renderer.heading(i);break;case"code":t+=this.renderer.code(i);break;case"table":t+=this.renderer.table(i);break;case"blockquote":t+=this.renderer.blockquote(i);break;case"list":t+=this.renderer.list(i);break;case"checkbox":t+=this.renderer.checkbox(i);break;case"html":t+=this.renderer.html(i);break;case"def":t+=this.renderer.def(i);break;case"paragraph":t+=this.renderer.paragraph(i);break;case"text":t+=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 t}parseInline(e,t=this.renderer){let n="";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)){n+=e||"";continue}}let a=i;switch(a.type){case"escape":case"text":n+=t.text(a);break;case"html":n+=t.html(a);break;case"link":n+=t.link(a);break;case"image":n+=t.image(a);break;case"checkbox":n+=t.checkbox(a);break;case"strong":n+=t.strong(a);break;case"em":n+=t.em(a);break;case"codespan":n+=t.codespan(a);break;case"br":n+=t.br(a);break;case"del":n+=t.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 n}},$c=class{options;block;constructor(e){this.options=e||Ss}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?Rc.lex:Rc.lexInline}provideParser(){return this.block?Mc.parse:Mc.parseInline}},Lc=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=Mc;Renderer=Ic;TextRenderer=Ac;Lexer=Rc;Tokenizer=zc;Hooks=$c;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=r;n=n.concat(this.walkTokens(e.items,t));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);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),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 n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Ic(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=a.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new zc(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new $c;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];$c.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&$c.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return!1===n&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return!1===n&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Rc.lex(e,t??this.defaults)}parser(e,t){return Mc.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},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 t>"u"||null===t)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?Rc.lex:Rc.lexInline)(n,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?Mc.parse:Mc.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?Rc.lex:Rc.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Mc.parse:Mc.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Sc(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Oc(e,t){return Lc.parse(e,t)}function Dc({title:e,defaultOpen:t=!1,children:n}){const[r,i]=si(t),a=pi(null);return Kr("div",{class:"_pillar-collapsible pillar-collapsible",children:[Kr("button",{type:"button",class:"_pillar-collapsible-header pillar-collapsible-header",onClick:()=>i(!r),children:[Kr("span",{class:"_pillar-collapsible-icon pillar-collapsible-icon",style:{transform:r?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:"▶"}),Kr("span",{class:"_pillar-collapsible-title pillar-collapsible-title",children:e})]}),Kr("div",{class:"_pillar-collapsible-content-wrapper pillar-collapsible-content-wrapper "+(r?"_pillar-collapsible-content-wrapper--expanded pillar-collapsible-content-wrapper--expanded":""),children:Kr("div",{ref:a,class:"_pillar-collapsible-content pillar-collapsible-content",children:n})})]})}function jc({sources:e}){return e&&0!==e.length?Kr("div",{class:"_pillar-source-list pillar-source-list",children:e.map((e,t)=>Kr("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-source-item pillar-source-item",children:Kr("span",{class:"_pillar-source-title pillar-source-title",children:e.title})},t))}):Kr("span",{})}function Hc({language:e,children:t}){const[n,r]=si(!1);return Kr("div",{class:"_pillar-code-block pillar-code-block",children:[e&&Kr("div",{class:"_pillar-code-header pillar-code-header",children:[Kr("span",{class:"_pillar-code-language pillar-code-language",children:e}),Kr("button",{type:"button",class:"_pillar-code-copy pillar-code-copy",onClick:async()=>{try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch(e){p.error("[Pillar] Failed to copy code:",e)}},children:n?"Copied!":"Copy"})]}),Kr("pre",{class:`_pillar-code-pre pillar-code-pre language-${e||"text"}`,children:Kr("code",{class:"_pillar-code-content pillar-code-content",children:t})})]})}function Nc({message:e,isActive:t=!0}){return Kr("div",{class:"_pillar-progress-indicator pillar-progress-indicator "+(t?"_pillar-progress-indicator--active pillar-progress-indicator--active":""),children:[t&&Kr("div",{class:"_pillar-loading-spinner pillar-loading-spinner"}),Kr("span",{class:"_pillar-progress-message pillar-progress-message",children:e})]})}function Uc({content:e,class:t}){if(!e||!e.trim())return Kr("span",{});try{return Kr("div",{class:`_pillar-markdown pillar-markdown ${t||""}`,children:Bc(Oc.lexer(e))})}catch(n){return p.error("[Pillar] Markdown parsing error:",n),Kr("div",{class:`_pillar-markdown pillar-markdown ${t||""}`,children:e})}}function Bc(e){return e.map((e,t)=>function(e,t){switch(e.type){case"heading":return function(e,t){const n=`h${e.depth}`;return Kr(n,{class:`_pillar-md-heading _pillar-md-h${e.depth} pillar-md-heading pillar-md-h${e.depth}`,children:qc(e.tokens)},t)}(e,t);case"paragraph":return function(e,t){return Kr("p",{class:"_pillar-md-paragraph pillar-md-paragraph",children:qc(e.tokens)},t)}(e,t);case"text":return function(e,t){if(e.tokens&&e.tokens.length>0)return Kr($,{children:qc(e.tokens)},t);return Kr($,{children:e.text},t)}(e,t);case"code":return function(e,t){const n=e.lang||"",r=e.text;if(n.startsWith("collapsible:")){return Kr(Dc,{title:n.substring(12),children:Kr(Uc,{content:r})},t)}if(n.startsWith("collapsible-open:")){return Kr(Dc,{title:n.substring(17),defaultOpen:!0,children:Kr(Uc,{content:r})},t)}if("sources"===n)try{return Kr(jc,{sources:JSON.parse(r)},t)}catch{p.warn("[Pillar] Failed to parse sources JSON")}if(n.startsWith("progress:")){return Kr(Nc,{message:n.substring(9),isActive:!0},t)}if(n.startsWith("progress-done:")){return Kr(Nc,{message:n.substring(14),isActive:!1},t)}return Kr(Hc,{language:n||void 0,children:r},t)}(e,t);case"blockquote":return function(e,t){return Kr("blockquote",{class:"_pillar-md-blockquote pillar-md-blockquote",children:Bc(e.tokens)},t)}(e,t);case"list":return function(e,t){const n=e.items.map((e,t)=>Fc(e,t));if(e.ordered)return Kr("ol",{start:e.start||1,class:"_pillar-md-list _pillar-md-list--ordered pillar-md-list pillar-md-list--ordered",children:n},t);return Kr("ul",{class:"_pillar-md-list _pillar-md-list--unordered pillar-md-list pillar-md-list--unordered",children:n},t)}(e,t);case"list_item":return Fc(e,t);case"table":return function(e,t){return Kr("div",{class:"_pillar-md-table-wrapper pillar-md-table-wrapper",children:Kr("table",{class:"_pillar-md-table pillar-md-table",children:[Kr("thead",{children:Kr("tr",{children:e.header.map((t,n)=>Kr("th",{style:e.align[n]?{textAlign:e.align[n]}:void 0,class:"_pillar-md-th pillar-md-th",children:qc(t.tokens)},n))})}),Kr("tbody",{children:e.rows.map((t,n)=>Kr("tr",{children:t.map((t,n)=>Kr("td",{style:e.align[n]?{textAlign:e.align[n]}:void 0,class:"_pillar-md-td pillar-md-td",children:qc(t.tokens)},n))},n))})]})},t)}(e,t);case"hr":return Kr("hr",{class:"_pillar-md-hr pillar-md-hr"},t);case"space":return null;case"html":return function(e,t){const n=e.raw.match(/<(\w+)\s*([^>]*)\/?\s*>/);if(n){const[,e,r]=n,i=function(e){const t={},n=/(\w+)=["']([^"']*)["']/g;let r;for(;null!==(r=n.exec(e));)t[r[1]]=r[2];return t}(r);switch(e){case"SourceList":if(i.sources)try{return Kr(jc,{sources:JSON.parse(i.sources)},t)}catch{p.warn("[Pillar] Failed to parse SourceList sources")}break;case"Progress":return Kr(Nc,{message:i.message||"Processing...",isActive:"false"!==i.active},t);case"Collapsible":return Kr(Dc,{title:i.title||"Details",defaultOpen:"true"===i.open,children:i.content?Kr(Uc,{content:i.content}):null},t)}}return Kr("span",{dangerouslySetInnerHTML:{__html:e.raw}},t)}(e,t);case"strong":return Kr("strong",{children:qc(e.tokens)},t);case"em":return Kr("em",{children:qc(e.tokens)},t);case"codespan":return Kr("code",{class:"_pillar-md-code-inline pillar-md-code-inline",children:e.text},t);case"link":const n=e;return Kr("a",{href:n.href,title:n.title||void 0,target:"_blank",rel:"noopener noreferrer",class:"_pillar-md-link pillar-md-link",children:qc(n.tokens)},t);case"image":const r=e;return Kr("img",{src:r.href,alt:r.text,title:r.title||void 0,class:"_pillar-md-image pillar-md-image"},t);case"br":return Kr("br",{},t);case"del":return Kr("del",{children:qc(e.tokens)},t);default:return"raw"in e&&"string"==typeof e.raw?Kr("span",{children:e.raw},t):null}}(e,t)).filter(Boolean)}function Fc(e,t){return e.task?Kr("li",{class:"_pillar-md-list-item _pillar-md-task-item pillar-md-list-item pillar-md-task-item",children:[Kr("input",{type:"checkbox",checked:e.checked,disabled:!0,class:"_pillar-md-task-checkbox pillar-md-task-checkbox"}),Kr("span",{class:e.checked?"_pillar-md-task-text--checked pillar-md-task-text--checked":"",children:Bc(e.tokens)})]},t):Kr("li",{class:"_pillar-md-list-item pillar-md-list-item",children:Bc(e.tokens)},t)}function qc(e){return e&&0!==e.length?e.map((e,t)=>{switch(e.type){case"text":case"escape":return e.text;case"strong":return Kr("strong",{children:qc(e.tokens)},t);case"em":return Kr("em",{children:qc(e.tokens)},t);case"codespan":return Kr("code",{class:"_pillar-md-code-inline pillar-md-code-inline",children:e.text},t);case"link":const n=e;return Kr("a",{href:n.href,title:n.title||void 0,target:"_blank",rel:"noopener noreferrer",class:"_pillar-md-link pillar-md-link",children:qc(n.tokens)},t);case"image":const r=e;return Kr("img",{src:r.href,alt:r.text,title:r.title||void 0,class:"_pillar-md-image pillar-md-image"},t);case"br":return Kr("br",{},t);case"del":return Kr("del",{children:qc(e.tokens)},t);default:return"raw"in e&&"string"==typeof e.raw?e.raw:null}}):null}function Wc({progress:e,isActive:t=!1,isLast:n=!1,responseStarted:r=!1,nested:i=!1,groupActive:a=!1}){const l="active"===e.status||void 0===e.status&&t,o="error"===e.status||"query_failed"===e.kind,s="thinking"===e.kind||"step_start"===e.kind,c=function(e,t=50){const[n,r]=si(e);return ci(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}(e.text,50),[p,d]=si(0);ci(()=>{if(!s||!l)return;const t=e.metadata?._startTime||Date.now();d(Math.max(1,Math.round((Date.now()-t)/1e3)));const n=setInterval(()=>{d(Math.round((Date.now()-t)/1e3))},1e3);return()=>clearInterval(n)},[s,l,e.metadata]);const u=Boolean(e.text),h=e.children&&e.children.length>0,g=e.metadata?.sources,f="search_complete"===e.kind&&g&&g.length>0,m=!0===e.metadata?.no_sources_used,b=e.metadata?.arguments,v=b&&Object.keys(b).length>0,_=u||h||f&&!m||v,x=e.metadata?.result_count,y="search"===e.kind&&0===x,[w,k]=si(!1),[S,C]=si(!1),P=_&&(w?S:i?l||n&&a:l||n&&!r),E=pi(null),[T,z]=si(!1),[R,I]=si(!1);ci(()=>{k(!1)},[l]),ci(()=>{I(!1)},[e.id,e.progress_id]),ci(()=>{E.current&&l&&e.text&&!R&&(E.current.scrollTop=E.current.scrollHeight)},[e.text,l,R]);const A=()=>{_&&(k(!0),C(!P))},M=P?"rotate(90deg)":"rotate(0deg)";if(!(e.label||e.message||e.text||h||f||s))return null;const $=(()=>{if(s){if(l)return p>0?`Thought for ${p}s`:"Thinking...";const t=e.metadata?._durationSeconds,n=t||p;return n>0?`Thought for ${n}s`:"Thought"}return e.label||e.message||function(e){switch(e){case"processing":return"Processing...";case"search":return"Searching...";case"search_complete":return"Search complete";case"query":return"Executing action...";case"query_complete":return"Action complete";case"query_failed":return"Action failed";case"generating":return"Generating answer...";case"thinking":case"step_start":return"Thinking...";case"step_complete":return"Done";case"tool_call":return"Running tool...";case"plan":return"Planning...";default:return"Working..."}}(e.kind)})();return Kr("div",{class:`_pillar-progress-row pillar-progress-row${o?" _pillar-progress-row--error pillar-progress-row--error":""}${l?" _pillar-progress-row--active pillar-progress-row--active":""}${n?" _pillar-progress-row--last pillar-progress-row--last":""}${i?" _pillar-progress-row--nested pillar-progress-row--nested":""}`,role:"status","aria-live":l?"polite":"off","aria-label":`${$}: ${l?"in progress":o?"error":"complete"}`,children:[Kr("div",{class:"_pillar-progress-row-header pillar-progress-row-header",onClick:A,style:{cursor:_?"pointer":"default"},"data-expanded":P,role:_?"button":void 0,"aria-expanded":_?P:void 0,tabIndex:_?0:void 0,onKeyDown:_?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),A())}:void 0,children:[o&&Kr("span",{class:"_pillar-progress-error-icon pillar-progress-error-icon","aria-label":"Error",children:"✗"}),Kr("span",{class:"_pillar-progress-message pillar-progress-message",children:$}),y&&Kr("span",{class:"_pillar-progress-no-results pillar-progress-no-results",children:"— no relevant results"}),_&&!o&&Kr("span",{class:"_pillar-progress-chevron pillar-progress-chevron",style:{transform:M,transition:"transform 0.2s ease, opacity 0.15s ease"},"aria-hidden":"true",children:"▶"})]}),_&&Kr("div",{class:"_pillar-progress-content-wrapper pillar-progress-content-wrapper "+(P?"_pillar-progress-content-wrapper--expanded pillar-progress-content-wrapper--expanded":""),children:Kr("div",{class:"_pillar-progress-content-container pillar-progress-content-container",children:[v&&Kr("div",{class:"_pillar-progress-arguments pillar-progress-arguments",children:Object.entries(b).map(([e,t])=>Kr("span",{class:"_pillar-progress-argument pillar-progress-argument",children:[Kr("span",{class:"_pillar-progress-argument-key pillar-progress-argument-key",children:[e,":"]})," ",Kr("span",{class:"_pillar-progress-argument-value pillar-progress-argument-value",children:"string"==typeof t?t:JSON.stringify(t)})]},e))}),u&&Kr("div",{class:"_pillar-progress-text-preview-wrapper pillar-progress-text-preview-wrapper",children:[T&&Kr("div",{class:"_pillar-progress-text-gradient pillar-progress-text-gradient"}),Kr("div",{ref:E,class:"_pillar-progress-text-preview pillar-progress-text-preview",onScroll:()=>{if(E.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=E.current;I(!(e>=t-n-5)),z(e>0)}},children:Kr(Uc,{content:c||""})})]}),h?Kr("div",{class:"_pillar-progress-children pillar-progress-children",children:e.children.map((e,t)=>Kr("div",{class:"_pillar-progress-child-item pillar-progress-child-item",children:e.url?Kr("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-progress-child-link pillar-progress-child-link",children:e.label}):Kr("span",{class:"_pillar-progress-child-label pillar-progress-child-label",children:e.label})},e.id||t))}):f?Kr("div",{class:"_pillar-progress-sources pillar-progress-sources",children:g.map((e,t)=>Kr("div",{class:"_pillar-progress-source-item pillar-progress-source-item",children:Kr("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-progress-source-link pillar-progress-source-link",children:Kr("span",{class:"_pillar-progress-source-title pillar-progress-source-title",children:e.title})})},t))}):null]})})]})}function Vc({events:e,summary:t,isLast:n=!1,responseStarted:r=!1}){const i=e.some(e=>"active"===e.status),[a,l]=si(!1),[o,s]=si(!1),c=a?o:i||n&&!r;ci(()=>{i&&l(!1)},[i]);const p=()=>{l(!0),s(!c)};return Kr("div",{class:`_pillar-progress-group pillar-progress-group${i?" _pillar-progress-group--active pillar-progress-group--active":""}${n?" _pillar-progress-group--last pillar-progress-group--last":""}`,children:[Kr("div",{class:"_pillar-progress-group-header pillar-progress-group-header",onClick:p,role:"button","aria-expanded":c,tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())},children:[Kr("span",{class:"_pillar-progress-group-chevron pillar-progress-group-chevron",style:{transform:c?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},"aria-hidden":"true",children:"▶"}),Kr("span",{class:"_pillar-progress-group-summary pillar-progress-group-summary",children:t}),i&&Kr("span",{class:"_pillar-progress-group-active-dot pillar-progress-group-active-dot"})]}),Kr("div",{class:"_pillar-progress-group-children pillar-progress-group-children "+(c?"_pillar-progress-group-children--expanded pillar-progress-group-children--expanded":""),children:Kr("div",{class:"_pillar-progress-group-children-inner pillar-progress-group-children-inner",children:e.map((t,n)=>Kr(Wc,{progress:t,isActive:"active"===t.status,isLast:n===e.length-1,responseStarted:r,nested:!0,groupActive:i},t.id||t.progress_id||n))})})]})}function Kc({event:e}){const[t,n]=si("idle"),[r,i]=si(null),[a,l]=si(!1),o=e.metadata?.endpoint,s=e.label||"Secret",c=ui(async()=>{if(o){n("loading");try{const e=Ta(),t=e?.config?.apiBaseUrl||"",r=o.startsWith("http")?o:`${t}${o}`,a=await fetch(r);if(410===a.status)n("expired");else if(a.ok){const e=await a.json();i(e.value),n("revealed")}else n("error")}catch{n("error")}}else n("error")},[o]),p=ui(async()=>{if(r)try{await navigator.clipboard.writeText(r),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[r]);return Kr("div",{class:"_pillar-secret-reveal pillar-secret-reveal",children:["idle"===t&&Kr("button",{class:"_pillar-secret-reveal-btn pillar-secret-reveal-btn",onClick:c,type:"button",children:[Kr(Gc,{}),Kr("span",{children:["Reveal ",s]})]}),"loading"===t&&Kr("div",{class:"_pillar-secret-reveal-loading",children:[Kr(Qc,{}),Kr("span",{children:"Fetching…"})]}),"revealed"===t&&r&&Kr("div",{class:"_pillar-secret-reveal-value",children:[Kr("code",{class:"_pillar-secret-reveal-code",children:r}),Kr("button",{class:"_pillar-secret-reveal-copy",onClick:p,type:"button",title:a?"Copied!":"Copy to clipboard",children:Kr(a?Xc:Jc,{})})]}),"expired"===t&&Kr("div",{class:"_pillar-secret-reveal-expired",children:"This secret has expired or was already revealed."}),"error"===t&&Kr("div",{class:"_pillar-secret-reveal-error",children:"Failed to retrieve secret."})]})}function Gc(){return Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Kr("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})})}function Qc(){return Kr("svg",{class:"_pillar-secret-reveal-spinner",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:Kr("path",{d:"M12 2v4m0 12v4m-7.07-3.93l2.83-2.83m8.48-8.48l2.83-2.83M2 12h4m12 0h4m-3.93 7.07l-2.83-2.83M6.34 6.34L3.51 3.51"})})}function Jc(){return Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Kr("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),Kr("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Xc(){return Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Kr("polyline",{points:"20 6 9 17 4 12"})})}Oc.options=Oc.setOptions=function(e){return Lc.setOptions(e),Oc.defaults=Lc.defaults,Cs(Oc.defaults),Oc},Oc.getDefaults=ks,Oc.defaults=Ss,Oc.use=function(...e){return Lc.use(...e),Oc.defaults=Lc.defaults,Cs(Oc.defaults),Oc},Oc.walkTokens=function(e,t){return Lc.walkTokens(e,t)},Oc.parseInline=Lc.parseInline,Oc.Parser=Mc,Oc.parser=Mc.parse,Oc.Renderer=Ic,Oc.TextRenderer=Ac,Oc.Lexer=Rc,Oc.lexer=Rc.lex,Oc.Tokenizer=zc,Oc.Hooks=$c,Oc.parse=Oc,Oc.options,Oc.setOptions,Oc.use,Oc.walkTokens,Oc.parseInline,Mc.parse,Rc.lex;const Zc=new Set(["search","search_complete","tool_call","plan","generating","query","query_complete","query_failed","step_complete","processing"]);const Yc=new Set(["search_complete","query_complete","step_complete"]);function ep(e){const t=e.filter(e=>!Yc.has(e.kind));if(1===t.length&&t[0].label)return t[0].label;let n=0,r=0;for(const t of e)switch(t.kind){case"search":case"search_complete":break;case"query":case"query_complete":case"query_failed":case"tool_call":n++;break;default:r++}const i=e.filter(e=>"search_complete"===e.kind).length,a=e.filter(e=>"search"===e.kind).length,l=Math.max(i,a),o=[];return l>0&&o.push(`Searched ${l} ${1===l?"source":"sources"}`),n>0&&o.push(`Ran ${n} ${1===n?"action":"actions"}`),r>0&&0===o.length&&o.push(`${r} ${1===r?"step":"steps"}`),o.length>0?o.join(", "):`${e.length} steps`}function tp({events:e,responseStarted:t=!1}){if(!e||0===e.length)return null;const n=function(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"tool_group",events:[...n],summary:ep(n)}),n=[])};for(const i of e){const e="thinking"===i.kind||"step_start"===i.kind,a="secret_reveal"===i.kind;e?(r(),t.push({type:"thinking",event:i})):a?(r(),t.push({type:"secret_reveal",event:i})):(Zc.has(i.kind),n.push(i))}return r(),t}(e);return Kr("div",{class:"_pillar-progress-stack pillar-progress-stack",children:n.flatMap((e,r)=>{if("thinking"===e.type)return[Kr(Wc,{progress:e.event,isActive:"active"===e.event.status,isLast:r===n.length-1,responseStarted:t},e.event.id||e.event.progress_id||`thinking-${r}`)];if("secret_reveal"===e.type)return[Kr(Kc,{event:e.event},e.event.id||`secret-${r}`)];const i=e.events.filter(e=>!Yc.has(e.kind));return i.length<=2?e.events.map((i,a)=>Kr(Wc,{progress:i,isActive:"active"===i.status,isLast:r===n.length-1&&a===e.events.length-1,responseStarted:t},i.id||i.progress_id||`flat-${r}-${a}`)):[Kr(Vc,{events:e.events,summary:e.summary,isLast:r===n.length-1,responseStarted:t},`group-${r}`)]})})}function np({error:e,onRetry:t}){return Kr("div",{class:"_pillar-error-row pillar-error-row",role:"alert",children:[Kr("span",{class:"_pillar-error-row-icon pillar-error-row-icon","aria-hidden":"true",children:"✗"}),Kr("span",{class:"_pillar-error-row-message pillar-error-row-message",children:e.message}),e.upgradeUrl?Kr("a",{class:"_pillar-error-row-retry pillar-error-row-retry",href:e.upgradeUrl,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:[Kr("span",{dangerouslySetInnerHTML:{__html:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7"></line><polyline points="7 7 17 7 17 17"></polyline></svg>'}}),"Upgrade"]}):Kr("button",{class:"_pillar-error-row-retry pillar-error-row-retry",onClick:t,type:"button","aria-label":"Retry",children:[Kr("span",{dangerouslySetInnerHTML:{__html:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"></polyline><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path></svg>'}}),"Retry"]})]})}function rp({session:e,onResume:t,onDiscard:n,isResuming:r=!1}){return Kr("div",e.elapsedMs<15e3||r?{class:"_pillar-resume-prompt _pillar-resume-prompt--seamless pillar-resume-prompt",children:[Kr("div",{class:"_pillar-resume-prompt-spinner pillar-resume-prompt-spinner"}),Kr("span",{class:"_pillar-resume-prompt-text pillar-resume-prompt-text",children:"Resuming conversation..."})]}:{class:"_pillar-resume-prompt pillar-resume-prompt",children:[Kr("div",{class:"_pillar-resume-prompt-content pillar-resume-prompt-content",children:[Kr("div",{class:"_pillar-resume-prompt-icon pillar-resume-prompt-icon",children:Kr("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Kr("circle",{cx:"12",cy:"12",r:"10"}),Kr("polyline",{points:"12 6 12 12 16 14"})]})}),Kr("div",{class:"_pillar-resume-prompt-body pillar-resume-prompt-body",children:[Kr("div",{class:"_pillar-resume-prompt-title pillar-resume-prompt-title",children:"Session Interrupted"}),Kr("div",{class:"_pillar-resume-prompt-message pillar-resume-prompt-message",children:[e.userMessage&&Kr("span",{class:"_pillar-resume-prompt-user-msg pillar-resume-prompt-user-msg",children:['"',ip(e.userMessage,50),'"']}),e.partialResponse&&Kr("span",{class:"_pillar-resume-prompt-summary pillar-resume-prompt-summary",children:ip(e.partialResponse,80)})]})]})]}),Kr("div",{class:"_pillar-resume-prompt-actions pillar-resume-prompt-actions",children:[Kr("button",{type:"button",class:"_pillar-resume-prompt-btn _pillar-resume-prompt-btn--primary pillar-resume-prompt-btn",onClick:t,children:[Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:Kr("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume"]}),Kr("button",{type:"button",class:"_pillar-resume-prompt-btn _pillar-resume-prompt-btn--ghost pillar-resume-prompt-btn",onClick:n,children:"Discard"})]})]})}function ip(e,t){return e.length<=t?e:e.slice(0,t)+"..."}function ap(){const e=Ta(),t=e?.config?.domScanning?.excludeSelector;return{excludeSelector:t?`#pillar-root, ${t}`:"#pillar-root"}}function lp({cardType:e,data:t}){const n=pi(null),r=pi(null);return ci(()=>{const i=Ta(),a=i?.getCardRenderer(e);if(a&&n.current){const i=a(n.current,t,{onConfirm:()=>{p.log(`[Pillar] Card "${e}" confirmed`)},onCancel:()=>{p.log(`[Pillar] Card "${e}" cancelled`)},onStateChange:(t,n)=>{p.log(`[Pillar] Card "${e}" state: ${t}${n?` - ${n}`:""}`)}});r.current=i||null}return()=>{r.current&&(r.current(),r.current=null)}},[e,t]),Kr("div",{ref:n,class:"_pillar-card-segment pillar-card-segment"})}function op(){const e=So(),t=pi(null),n=pi(null),r=pi(0),[i,a]=si(!1),l=ui(async t=>{const n=performance.now(),r=(new Date).toISOString();p.log("[Pillar] Received action_request:",t.action_name,t.parameters,`at ${r}`);const i=Ta();if(i)try{if("interact_with_page"===t.action_name){const r=t.parameters;Vo(r.operation,t.tool_call_id);try{if(Qo())return await e.mcp.sendActionResult(t.action_name,{success:!1,error:"User cancelled action"},t.tool_call_id),void p.log("[Pillar] Page interaction cancelled by user before execution");const a=await i.handlePageInteraction(r);if(Qo())return await e.mcp.sendActionResult(t.action_name,{success:!1,error:"User cancelled action"},t.tool_call_id),void p.log("[Pillar] Page interaction cancelled by user after execution");let l=null;if(a.success&&i?.isDOMScanningEnabled){await new Promise(e=>setTimeout(e,150));const e=function(e){const t=e?.root||document.body,n={lines:[],refs:new Set,interactableCount:0,totalLength:0,budgetExhausted:!1,maxDepth:0,options:{...is,...e}};ys(t,n,0);const r=n.lines.filter(e=>!ps.has(e)),i=[...ds].filter(e=>!n.refs.has(e)),a=/\[\[pr-[a-z0-9]+\]\]$/,l=r.filter(e=>a.test(e)).length,o=r.length>0||i.length>0;ps=new Set(n.lines),ds=new Set(n.refs);let s=null;if(o){const e=[];r.length>0&&(e.push(...r),e.push(""));const t=i.length>0?`, ${i.length} removed: ${i.join(", ")}`:"";e.push(`=== ${l} new${t} ===`),s=e.join("\n")}return{content:s,removedRefs:i,newInteractableCount:l,totalInteractableCount:n.refs.size,hasChanges:o,timestamp:Date.now(),url:window.location.href,title:document.title}}(ap());l=e.content,p.log("[Pillar] DOM delta scanned after page interaction:",e.hasChanges?`${e.newInteractableCount} new, ${e.removedRefs.length} removed`:"no changes")}await e.mcp.sendActionResult(t.action_name,{...a,dom_snapshot:l},t.tool_call_id);const o=Math.round(performance.now()-n);p.log(`[Pillar] Page interaction "${r.operation}" completed in ${o}ms:`,a)}finally{Ko(),Go()}return}const r=i.getHandler(t.action_name);if(!r)throw new Error(`No handler registered for action "${t.action_name}". Register one with pillar.defineTool() or usePillarTool().`);const a=rs(await Promise.resolve(r(t.parameters)));await e.mcp.sendActionResult(t.action_name,a,t.tool_call_id);const l=Math.round(performance.now()-n);if(a&&"object"==typeof a&&!Array.isArray(a)&&!1===a.success)p.error(`[Pillar] Action "${t.action_name}" failed after ${l}ms:`,a.error||a.message);else if(p.log(`[Pillar] Action "${t.action_name}" completed in ${l}ms`),a&&"object"==typeof a&&!Array.isArray(a)){const e=a,t=e.card_type;t&&i.hasCardRenderer(t)&&(p.log(`[Pillar] Rendering card for type "${t}"`),ol(t,e))}}catch(r){const i=r instanceof Error?r.message:String(r);await e.mcp.sendActionResult(t.action_name,{success:!1,error:i},t.tool_call_id);const a=Math.round(performance.now()-n);p.error(`[Pillar] Action "${t.action_name}" failed after ${a}ms:`,r)}else p.error("[Pillar] SDK not initialized, cannot execute action"),await e.mcp.sendActionResult(t.action_name,{success:!1,error:"SDK not initialized"},t.tool_call_id)},[e]),o=ui(()=>{const e=Ta(),t=e?.config?.productKey??"";Hl(),es(t)},[]);ci(()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)},[Na.value,tl.value]),ci(()=>{const e=Ta();if(!e)return;return e.on("task:complete",({name:e,success:t})=>{Rl(e,t);const n=function(e,t){const n=e.replace(/_/g," ").toLowerCase();return t?n.startsWith("open ")?`Opened ${n.slice(5)}`:n.startsWith("go to ")?`Navigated to ${n.slice(6)}`:n.startsWith("navigate to ")?`Navigated to ${n.slice(12)}`:"Done!":`Failed to ${n}`}(e,t);Il(e,n)})},[]);const s=ui(e=>{const t=Ta();p.log("[Pillar] handleActionsReceived called with",e.length,"actions"),p.log("[Pillar] Actions detail:",e.map(e=>({name:e.name,autoRun:e.autoRun})));const n=e.filter(e=>!0===e.autoRun),r=e.filter(e=>!e.autoRun);return p.log("[Pillar] Auto-run actions:",n.length,", Manual actions:",r.length),t&&n.length>0?(p.log("[Pillar] Executing auto-run actions..."),n.forEach(e=>{const n=e.data||{},r=n.path,i=n.url,a=Na.value.length-1;a>=0&&zl(a,e.name),p.log("[Pillar] Executing action:",e.name),t.executeTask({id:e.id,name:e.name,taskType:e.taskType,data:n,path:r,externalUrl:i})}),[]):t?r:(p.warn("[Pillar] No Pillar instance available for auto-run"),e)},[]),c=ui(async t=>{n.current&&(n.current.abort(),n.current=null);const i=++r.current,a=new AbortController;n.current=a;let o=[];const c=()=>r.current!==i,p=await e.chat({message:t.message,history:t.history,existingConversationId:t.conversationId,userContext:t.userContext,images:t.images,resume:t.resume,signal:a.signal,onChunk:e=>{c()||ll(e)},onActions:e=>{c()||(o=s(e))},onProgress:e=>{c()||Dl(e)},onConversationStarted:()=>{const e=Ta(),t=e?.config?.productKey??"",n=Ua.value;t&&n&&Promise.resolve().then(function(){return ns}).then(({saveActiveSession:e})=>{e(n,t)})},onActionRequest:l,onRequestId:e=>Ja(e)});return{response:p,receivedActions:o,generation:i}},[e,s,l]),d=ui(async(e,t,i)=>{Hl(),el();const a=Nr().startSpan("chat.send_message",{attributes:{"chat.message_length":e.length}});Pl(e,t,i),$l(!0),El("");let l=-1;try{const n=Na.value.slice(0,-1),r=!Ua.value;r&&Al(crypto.randomUUID());const{response:o,receivedActions:p,generation:d}=await c({message:e,conversationId:Ua.value,userContext:t,images:i,history:n});l=d;let u=p;o.actions&&o.actions.length>0&&(u=s(o.actions)),Tl(o.message,o.messageId,u,o.sources),o.conversationId&&Al(o.conversationId),r&&Ua.value&&io(Ua.value,e);{const e=Ta(),t=e?.config?.productKey??"";t&&es(t)}a.end()}catch(n){if("AbortError"===n.name)return Nl(),p.log("[Pillar] Chat cancelled by user"),a.setAttribute("chat.cancelled",!0),void a.end();l=r.current,p.error("[Pillar] Chat error:",n),a.setStatus({code:lt.ERROR,message:n.message}),a.end(),Nl();const o=n.data;Ya({message:n.message||"Something went wrong. Please try again.",retryMessage:e,retryContext:t,retryImages:i,upgradeUrl:o?.upgrade_url})}finally{r.current===l&&($l(!1),Ll(),Ja(null),n.current=null)}},[e,c,s]),u=ui(async()=>{const e=tl.value;if(!e)return;const t=Ta(),i=t?.config?.productKey??"",l=t?.isDOMScanningEnabled??!1;let o=[...fl.value];if(l){const e=ws(ap()),t={id:Oa(),type:"dom_snapshot",url:e.url,title:e.title,content:e.content,interactableCount:e.interactableCount,timestamp:e.timestamp};o=[...o,t]}a(!0),$l(!0),El("");let d=-1;try{const{response:t,receivedActions:n,generation:r}=await c({message:"",conversationId:e.conversationId,userContext:o.length>0?o:void 0,resume:!0});d=r;let a=n;t.actions&&t.actions.length>0&&(a=s(t.actions)),Tl(t.message,t.messageId,a,t.sources),Hl(),es(i)}catch(t){if("AbortError"===t.name)return void Nl();d=r.current,p.error("[Pillar] Resume error:",t),Nl();const n=t.data;Ya({message:t.message||"Failed to resume. Please try again.",retryMessage:e.userMessage,upgradeUrl:n?.upgrade_url}),Hl(),es(i)}finally{a(!1),r.current===d&&($l(!1),Ll(),Ja(null),n.current=null)}},[c,s]);ci(()=>{const e=tl.value;e&&e.elapsedMs<15e3&&!Ga.value&&u()},[tl.value,u]),ci(()=>()=>{n.current&&(n.current.abort(),n.current=null)},[]);const h=ui(()=>{n.current?.abort(),n.current=null;const t=Qa.value;null!==t&&(e.mcp.cancelStream(t),Ja(null)),$l(!1),Ll(),Nl(),Ol();const r=Na.value,i=r.length>0?r[r.length-1]:null,a="assistant"===i?.role&&Boolean(i?.content?.trim()),l=Ta(),o=l?.config?.productKey??"";if(a&&Ua.value){const e=[...r].reverse().find(e=>"user"===e.role);jl({conversationId:Ua.value,userMessage:e?.content??"",partialResponse:i.content??"",displayTrace:[],elapsedMs:99999})}else o&&es(o)},[e]),g=ui(()=>{const e=Za.value;if(!e)return;el();const t=Na.value;t.length>0&&"user"===t[t.length-1].role&&(Na.value=t.slice(0,-1)),d(e.retryMessage,e.retryContext,e.retryImages)},[d]),f=ui(async(t,n)=>{Ml(t,n),await e.submitFeedback(t,n)},[e]),m=ui((e,t,n)=>{if(Ga.value)return;const r=Ta();if(r?.isDOMScanningEnabled??!1){const r=ws(ap()),i={id:Oa(),type:"dom_snapshot",url:r.url,title:r.title,content:r.content,interactableCount:r.interactableCount,timestamp:r.timestamp},a=[...t,i];return void d(e,a.length>0?a:void 0,n.length>0?n:void 0)}d(e,t.length>0?t:void 0,n.length>0?n:void 0)},[d]);return ci(()=>{const e=ul.value,t=ml.value,n=bl.value;e&&(Bl(),Ql(),Xl(),m(e,t,n))},[hl.value,m]),Kr("div",{class:"_pillar-chat-view pillar-chat-view",children:[Kr("div",{class:"_pillar-chat-view-messages pillar-chat-view-messages",ref:t,children:[Xa.value&&Kr("div",{class:"_pillar-chat-history-loading pillar-chat-history-loading",children:[Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--user pillar-chat-history-loading-message--user",children:Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 70%"})}),Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--assistant pillar-chat-history-loading-message--assistant",children:[Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 90%"}),Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 85%"}),Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 60%"})]}),Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--user pillar-chat-history-loading-message--user",children:Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 55%"})}),Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--assistant pillar-chat-history-loading-message--assistant",children:[Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 95%"}),Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 80%"})]})]}),0===Na.value.length&&!tl.value&&!Xa.value&&Kr("div",{class:"_pillar-chat-view-welcome pillar-chat-view-welcome",children:To.value?Kr("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:[Kr(No,{}),Kr(No,{}),Kr(No,{})]}):Eo.value&&Eo.value.length>0?Kr("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:Eo.value.map(e=>Kr(Ho,{text:e.text,onClick:()=>m(e.text,[],[])},e.id))}):Kr($,{children:[Kr("div",{class:"_pillar-chat-view-welcome-icon pillar-chat-view-welcome-icon",children:"💬"}),Kr("div",{class:"_pillar-chat-view-welcome-title pillar-chat-view-welcome-title",children:"Ask a question"}),Kr("div",{class:"_pillar-chat-view-welcome-text pillar-chat-view-welcome-text",children:"Ask me anything about how to use this product."})]})}),Na.value.map((e,t)=>Kr("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?Kr("div",{class:"_pillar-message-user pillar-message-user",children:[e.userContext&&e.userContext.length>0&&Kr(Oo,{contexts:e.userContext,readOnly:!0}),e.images&&e.images.length>0&&Kr("div",{class:"_pillar-message-user-images pillar-message-user-images",children:e.images.map((e,t)=>Kr("img",{src:e.url,alt:`Attachment ${t+1}`,class:"_pillar-message-user-image pillar-message-user-image"},t))}),e.content]}):Kr("div",{class:"_pillar-message-assistant-wrapper pillar-message-assistant-wrapper",children:[Kr("div",{class:"_pillar-message-assistant-content pillar-message-assistant-content",children:[e.segments&&e.segments.length>0?e.segments.map((t,n)=>{if("progress"===t.type){const r=e.segments.slice(n+1).some(e=>"text"===e.type);return Kr(tp,{events:t.events,responseStarted:r||Boolean(e.content)},`seg-${n}`)}return"card"===t.type?Kr(lp,{cardType:t.cardType,data:t.data},`seg-${n}`):Kr("div",{class:"_pillar-message-assistant pillar-message-assistant",children:Kr(Uc,{content:t.content})},`seg-${n}`)}):Ga.value&&t===Na.value.length-1&&Kr("span",{class:"_pillar-thinking-shimmer pillar-thinking-shimmer",children:"Thinking..."}),e.actionStatus&&Object.keys(e.actionStatus).length>0&&Kr("span",{class:"_pillar-action-status pillar-action-status",children:Object.entries(e.actionStatus).map(([e,t])=>Kr("span",{class:`_pillar-action-status-indicator pillar-action-status-indicator _pillar-action-status-indicator--${t.status} pillar-action-status-indicator--${t.status}`,title:"failed"===t.status?t.errorMessage:e,dangerouslySetInnerHTML:{__html:"success"===t.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"===t.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))})]}),"assistant"===e.role&&e.id&&e.content&&Kr("div",{class:"_pillar-feedback-icons pillar-feedback-icons",children:[Kr("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("up"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>f(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>'}}),Kr("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("down"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>f(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&&Kr("div",{class:"_pillar-chat-sources pillar-chat-sources",children:[Kr("div",{class:"_pillar-chat-sources-title pillar-chat-sources-title",children:"Sources"}),e.sources.map(e=>Kr("div",{class:"_pillar-chat-source pillar-chat-source",children:e.title},e.slug))]})]})},t)),Za.value&&Kr(np,{error:Za.value,onRetry:g}),tl.value&&tl.value.elapsedMs>=15e3&&Kr(rp,{session:tl.value,onResume:u,onDiscard:o,isResuming:i}),i&&tl.value&&tl.value.elapsedMs<15e3&&Kr(rp,{session:tl.value,onResume:u,onDiscard:o,isResuming:!0})]}),Kr("div",{class:"_pillar-chat-view-input-area pillar-chat-view-input-area",children:Kr(jo,{placeholder:"Ask a question...",disabled:Xa.value,isStreaming:Ga.value,onStop:h,onSubmit:m})})]})}function sp(e){if(!e)return"Unknown";const t=function(e){let t=e;return e.endsWith("Z")&&e.includes("+")&&(t=e.slice(0,-1)),new Date(t)}(e),n=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime()-r.getTime(),a=Math.floor(i/864e5);if(0===a)return"Today";if(1===a)return"Yesterday";if(a<7)return`${a}d ago`;if(a<30){const e=Math.floor(a/7);return 1===e?"1 week ago":`${e} weeks ago`}return t.toLocaleDateString(void 0,{month:"short",year:"numeric"})}function cp({onSelectConversation:e}){const[t,n]=si(!1),[r,i]=si(!1),[a,l]=si([]),[o,s]=si(!1),[c,d]=si(Fa.value),u=pi(null),h=di(()=>function(e){const t=new Map;for(const n of e){const e=sp(n.lastMessageAt),r=t.get(e)||[];r.push(n),t.set(e,r)}return Array.from(t.entries()).map(([e,t])=>({label:e,conversations:t}))}(a),[a]);ci(()=>Fa.subscribe(e=>{e>c&&(s(!1),d(e))}),[c]),ci(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&n(!1)};return t&&(document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[t]);const g=async()=>{if(!o){i(!0);try{const e=za();if(e){const t=await e.listConversations(20);l((e=>{const t=qa.value;if(0===t.length)return e;const n=new Set(e.map(e=>e.id)),r=t.filter(e=>!n.has(e.id));return[...r,...e]})(t))}}catch(e){p.error("[Pillar] Failed to fetch conversations:",e),qa.value.length>0&&l(qa.value)}finally{i(!1),s(!0)}}},f=da.value,m=["_pillar-history-menu","pillar-history-menu",f?"_pillar-history-menu--mobile":""].filter(Boolean).join(" "),b=r?Kr("div",{class:"_pillar-history-loading pillar-history-loading",children:[Kr("div",{class:"_pillar-history-spinner pillar-history-spinner"}),Kr("span",{children:"Loading..."})]}):0===a.length?Kr("div",{class:"_pillar-history-empty pillar-history-empty",children:"No conversations yet"}):Kr("div",{class:"_pillar-history-list pillar-history-list",children:h.map(t=>Kr($,{children:[Kr("div",{class:"_pillar-history-group-header pillar-history-group-header",children:t.label}),t.conversations.map(t=>Kr("button",{class:"_pillar-history-item pillar-history-item",onClick:()=>(t=>{n(!1),e(t)})(t.id),type:"button",children:Kr("span",{class:"_pillar-history-item-title pillar-history-item-title",children:t.title})},t.id))]},t.label))});return Kr("div",{class:"_pillar-history-dropdown pillar-history-dropdown",ref:u,children:[Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-history-btn",onClick:()=>{const e=!t;n(e),e&&!o&&g()},"aria-label":"Conversation history","aria-expanded":t,title:"Conversation history",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z" clip-rule="evenodd"/></svg>'}}),t&&Kr("div",{class:m,children:[f&&Kr("div",{class:"_pillar-history-mobile-header",children:[Kr("span",{class:"_pillar-history-mobile-title",children:"History"}),Kr("button",{class:"_pillar-history-mobile-close",onClick:()=>n(!1),"aria-label":"Close history",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>'}})]}),b]})]})}const pp=120;function dp({currentView:e,hideNavigation:t=!1}){const n=pi(null),r=da.value,i=!t&&co.value,a=!t&&!po.value,l="chat"===e&&Cl.value,o=ao;return ci(()=>{if(!r)return;const e=n.current;if(!e)return;const t=e.closest("._pillar-panel");if(!t)return;let i=0,a=0,l=!1,o=!1,s=0;const c=e=>{e.target.closest("button")||(i=e.touches[0].clientY,a=i,s=Date.now(),l=!0,o=!1)},p=e=>{if(!l)return;a=e.touches[0].clientY;const n=a-i;if(n<0)return;if(!o){if(n<10)return;o=!0,t.style.transition="none"}const r=n<pp?n:pp+.3*(n-pp);t.style.transform=`translateY(${r}px)`,e.preventDefault()},d=()=>{if(!l||!o)return void(l=!1);l=!1,o=!1;const e=a-i,n=Date.now()-s,r=e/Math.max(n,1);if(t.style.transition="",t.offsetHeight,e>pp||r>.5){t.style.transform="translateY(100%)";const e=()=>{t.removeEventListener("transitionend",e),clearTimeout(n),t.style.transform="",ga()},n=setTimeout(e,600);t.addEventListener("transitionend",e)}else t.style.transform=""};return e.addEventListener("touchstart",c,{passive:!0}),document.addEventListener("touchmove",p,{passive:!1}),document.addEventListener("touchend",d),()=>{e.removeEventListener("touchstart",c),document.removeEventListener("touchmove",p),document.removeEventListener("touchend",d),t.style.transition="",t.style.transform=""}},[r]),Kr("header",{ref:n,class:"_pillar-header pillar-header",children:[r&&Kr("div",{class:"_pillar-drag-indicator pillar-drag-indicator",children:Kr("div",{class:"_pillar-drag-indicator-pill"})}),Kr("div",{class:"_pillar-header-left pillar-header-left",children:[i&&Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-back-btn",onClick:()=>{ho()},"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>'}}),a&&!l&&Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-home-btn",onClick:()=>{go()},"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>'}})]}),Kr("div",{class:"_pillar-header-right pillar-header-right",children:[l&&Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-new-chat-btn",onClick:()=>{go()},"aria-label":"New chat",title:"New chat",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z"/></svg>'}}),Kr(cp,{onSelectConversation:o}),Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-close-btn",onClick:()=>{ga()},"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>'}})]})]})}function up(e){switch(e){case"navigate":return"pillar-tool-badge--navigate";case"query":return"pillar-tool-badge--query";case"trigger_tool":return"pillar-tool-badge--trigger";case"inline_ui":return"pillar-tool-badge--inline";default:return"pillar-tool-badge--default"}}function hp(e){switch(e){case"defined":return"defineTool";case"registered":return"registerTool";case"registry":return"onTask";default:return e}}function gp({onClose:e}){const[t,n]=si([]),[r,i]=si(""),[a,l]=si(null),[o,s]=si("{}"),[c,p]=si(null),[d,u]=si(!1),[h,g]=si(null);ci(()=>{const e="pillar-tool-debug-panel-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent="/**\n * Tool Debug Panel Styles\n * Matches the debug panel theme and styling patterns\n */\n\n.pillar-tool-debug-panel {\n display: flex;\n flex-direction: column;\n height: 100%;\n background-color: #1e1e1e;\n color: #d4d4d4;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 13px;\n}\n\n/* Header */\n.pillar-tool-debug-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 16px;\n background-color: #252526;\n border-bottom: 1px solid #333;\n flex-shrink: 0;\n}\n\n.pillar-tool-debug-title {\n font-size: 14px;\n font-weight: 600;\n margin: 0;\n color: #e5e5e5;\n}\n\n.pillar-tool-debug-header-actions {\n display: flex;\n gap: 8px;\n}\n\n.pillar-tool-debug-btn {\n background-color: transparent;\n border: 1px solid #555;\n color: #d4d4d4;\n padding: 4px 10px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n font-family: inherit;\n transition: background-color 0.15s, border-color 0.15s;\n}\n\n.pillar-tool-debug-btn:hover {\n background-color: #333;\n border-color: #666;\n}\n\n/* Content Layout */\n.pillar-tool-debug-content {\n display: flex;\n flex: 1;\n overflow: hidden;\n}\n\n/* Tool List */\n.pillar-tool-debug-list {\n width: 280px;\n min-width: 220px;\n display: flex;\n flex-direction: column;\n border-right: 1px solid #333;\n background-color: #1e1e1e;\n}\n\n.pillar-tool-debug-search {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 12px;\n background-color: #252526;\n border-bottom: 1px solid #333;\n}\n\n.pillar-tool-debug-search-input {\n flex: 1;\n background-color: #3c3c3c;\n border: 1px solid transparent;\n color: #d4d4d4;\n padding: 6px 10px;\n font-size: 12px;\n font-family: inherit;\n outline: none;\n border-radius: 4px;\n transition: border-color 0.15s;\n}\n\n.pillar-tool-debug-search-input:focus {\n border-color: #3b82f6;\n}\n\n.pillar-tool-debug-search-input::placeholder {\n color: #6b7280;\n}\n\n.pillar-tool-debug-count {\n color: #6b7280;\n font-size: 11px;\n white-space: nowrap;\n}\n\n.pillar-tool-debug-tools {\n flex: 1;\n overflow-y: auto;\n padding: 4px 0;\n}\n\n.pillar-tool-debug-empty {\n padding: 24px 16px;\n color: #6b7280;\n text-align: center;\n font-size: 12px;\n}\n\n/* Tool Item */\n.pillar-tool-debug-tool-item {\n display: block;\n width: 100%;\n padding: 10px 12px;\n background: none;\n border: none;\n border-bottom: 1px solid #2d2d2d;\n text-align: left;\n cursor: pointer;\n color: #d4d4d4;\n font-family: inherit;\n transition: background-color 0.15s;\n}\n\n.pillar-tool-debug-tool-item:hover {\n background-color: #252526;\n}\n\n.pillar-tool-debug-tool-item--selected {\n background-color: #2d4a7c;\n}\n\n.pillar-tool-debug-tool-item--selected:hover {\n background-color: #2d4a7c;\n}\n\n.pillar-tool-debug-tool-header {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-bottom: 4px;\n}\n\n.pillar-tool-debug-tool-name {\n font-weight: 600;\n font-size: 12px;\n color: #e5e5e5;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.pillar-tool-debug-tool-desc {\n font-size: 11px;\n color: #9ca3af;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin-bottom: 4px;\n}\n\n.pillar-tool-debug-tool-meta {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 10px;\n}\n\n.pillar-tool-source {\n color: #6b7280;\n background-color: #2d2d2d;\n padding: 1px 5px;\n border-radius: 3px;\n}\n\n.pillar-tool-handler {\n color: #6b7280;\n}\n\n.pillar-tool-handler--active {\n color: #10b981;\n}\n\n/* Type Badges */\n.pillar-tool-badge {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n padding: 2px 5px;\n border-radius: 3px;\n white-space: nowrap;\n letter-spacing: 0.5px;\n}\n\n.pillar-tool-badge--navigate {\n background-color: #3b82f6;\n color: white;\n}\n\n.pillar-tool-badge--query {\n background-color: #8b5cf6;\n color: white;\n}\n\n.pillar-tool-badge--trigger {\n background-color: #10b981;\n color: white;\n}\n\n.pillar-tool-badge--inline {\n background-color: #f59e0b;\n color: black;\n}\n\n.pillar-tool-badge--default {\n background-color: #4b5563;\n color: white;\n}\n\n/* Tool Detail */\n.pillar-tool-debug-detail {\n flex: 1;\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n padding: 16px;\n background-color: #1e1e1e;\n}\n\n.pillar-tool-debug-no-selection {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: #6b7280;\n text-align: center;\n padding: 24px;\n}\n\n.pillar-tool-debug-detail-header {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 8px;\n}\n\n.pillar-tool-debug-detail-name {\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n color: #e5e5e5;\n}\n\n.pillar-tool-debug-detail-desc {\n color: #9ca3af;\n margin: 0 0 16px 0;\n font-size: 13px;\n line-height: 1.5;\n}\n\n.pillar-tool-debug-section-title {\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n margin: 0 0 8px 0;\n}\n\n/* Schema Display */\n.pillar-tool-debug-schema {\n margin-bottom: 16px;\n}\n\n.pillar-tool-debug-schema-content {\n background-color: #252526;\n border: 1px solid #333;\n border-radius: 6px;\n padding: 12px;\n margin: 0;\n font-size: 11px;\n line-height: 1.5;\n overflow-x: auto;\n max-height: 200px;\n color: #d4d4d4;\n}\n\n/* Input Editor */\n.pillar-tool-debug-input {\n margin-bottom: 16px;\n}\n\n.pillar-tool-debug-textarea {\n width: 100%;\n background-color: #252526;\n border: 1px solid #333;\n color: #d4d4d4;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 12px;\n line-height: 1.5;\n padding: 12px;\n border-radius: 6px;\n resize: vertical;\n outline: none;\n transition: border-color 0.15s;\n box-sizing: border-box;\n}\n\n.pillar-tool-debug-textarea:focus {\n border-color: #3b82f6;\n}\n\n.pillar-tool-debug-textarea--error {\n border-color: #ef4444;\n}\n\n.pillar-tool-debug-json-error {\n color: #ef4444;\n font-size: 11px;\n margin-top: 4px;\n}\n\n/* Actions */\n.pillar-tool-debug-actions {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-bottom: 16px;\n}\n\n.pillar-tool-debug-execute-btn {\n background-color: #3b82f6;\n border: none;\n color: white;\n padding: 8px 16px;\n border-radius: 6px;\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n transition: background-color 0.15s;\n}\n\n.pillar-tool-debug-execute-btn:hover:not(:disabled) {\n background-color: #2563eb;\n}\n\n.pillar-tool-debug-execute-btn:disabled {\n background-color: #4b5563;\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.pillar-tool-debug-no-handler {\n color: #f59e0b;\n font-size: 12px;\n}\n\n/* Execution Result */\n.pillar-tool-debug-result {\n border-radius: 6px;\n padding: 12px;\n margin-top: auto;\n}\n\n.pillar-tool-debug-result--success {\n background-color: rgba(16, 185, 129, 0.1);\n border: 1px solid rgba(16, 185, 129, 0.3);\n}\n\n.pillar-tool-debug-result--error {\n background-color: rgba(239, 68, 68, 0.1);\n border: 1px solid rgba(239, 68, 68, 0.3);\n}\n\n.pillar-tool-debug-result--success .pillar-tool-debug-section-title {\n color: #10b981;\n}\n\n.pillar-tool-debug-result--error .pillar-tool-debug-section-title {\n color: #ef4444;\n}\n\n.pillar-tool-debug-result-content {\n margin: 0;\n font-size: 11px;\n line-height: 1.5;\n white-space: pre-wrap;\n word-break: break-word;\n color: #d4d4d4;\n}\n\n/* Scrollbar Styling */\n.pillar-tool-debug-tools::-webkit-scrollbar,\n.pillar-tool-debug-detail::-webkit-scrollbar,\n.pillar-tool-debug-schema-content::-webkit-scrollbar {\n width: 8px;\n}\n\n.pillar-tool-debug-tools::-webkit-scrollbar-track,\n.pillar-tool-debug-detail::-webkit-scrollbar-track,\n.pillar-tool-debug-schema-content::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.pillar-tool-debug-tools::-webkit-scrollbar-thumb,\n.pillar-tool-debug-detail::-webkit-scrollbar-thumb,\n.pillar-tool-debug-schema-content::-webkit-scrollbar-thumb {\n background-color: #4b5563;\n border-radius: 4px;\n}\n\n.pillar-tool-debug-tools::-webkit-scrollbar-thumb:hover,\n.pillar-tool-debug-detail::-webkit-scrollbar-thumb:hover,\n.pillar-tool-debug-schema-content::-webkit-scrollbar-thumb:hover {\n background-color: #6b7280;\n}\n",document.head.appendChild(t)}},[]),ci(()=>{const e=Ta();if(!e)return;n(e.getTools());return e.on("tools:change",t=>{const r=e.getTools();n(r),"remove"===t.action&&l(e=>e&&e.name===t.name?(g(null),null):e)})},[]);const f=di(()=>{if(!r)return t;const e=r.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.type?.toLowerCase().includes(e))},[t,r]),m=ui(e=>{l(e),g(null);const t=function(e){if(!e?.properties)return{};const t={};for(const[n,r]of Object.entries(e.properties)){const e=r;if(void 0!==e.default)t[n]=e.default;else if(e.enum&&e.enum.length>0)t[n]=e.enum[0];else switch(e.type){case"string":t[n]="";break;case"number":t[n]=0;break;case"boolean":t[n]=!1;break;case"array":t[n]=[];break;case"object":t[n]={};break;default:t[n]=null}}return t}(e.inputSchema);s(JSON.stringify(t,null,2)),p(null)},[]),b=ui(e=>{s(e);try{JSON.parse(e),p(null)}catch(e){p(e instanceof Error?e.message:"Invalid JSON")}},[]),v=ui(async()=>{if(!a||c)return;const e=Ta();if(e){u(!0),g(null);try{const t=JSON.parse(o),n=await e.executeToolForDebug(a.name,t);g(n)}catch(e){g({success:!1,error:e instanceof Error?e.message:String(e)})}finally{u(!1)}}},[a,o,c]),_=ui(()=>{const e=Ta();e&&n(e.getTools())},[]);return Kr("div",{class:"pillar-tool-debug-panel",children:[Kr("div",{class:"pillar-tool-debug-header",children:[Kr("h2",{class:"pillar-tool-debug-title",children:"Tool Debugger"}),Kr("div",{class:"pillar-tool-debug-header-actions",children:[Kr("button",{class:"pillar-tool-debug-btn",onClick:_,title:"Refresh tools list",children:"Refresh"}),e&&Kr("button",{class:"pillar-tool-debug-btn",onClick:e,children:"Close"})]})]}),Kr("div",{class:"pillar-tool-debug-content",children:[Kr("div",{class:"pillar-tool-debug-list",children:[Kr("div",{class:"pillar-tool-debug-search",children:[Kr("input",{type:"text",class:"pillar-tool-debug-search-input",placeholder:"Search tools...",value:r,onInput:e=>i(e.target.value)}),Kr("span",{class:"pillar-tool-debug-count",children:[f.length," tool",1!==f.length?"s":""]})]}),Kr("div",{class:"pillar-tool-debug-tools",children:0===f.length?Kr("div",{class:"pillar-tool-debug-empty",children:0===t.length?"No tools registered":"No tools match your search"}):f.map(e=>Kr("button",{class:"pillar-tool-debug-tool-item "+(a?.name===e.name?"pillar-tool-debug-tool-item--selected":""),onClick:()=>m(e),children:[Kr("div",{class:"pillar-tool-debug-tool-header",children:[Kr("span",{class:"pillar-tool-debug-tool-name",children:e.name}),e.type&&Kr("span",{class:`pillar-tool-badge ${up(e.type)}`,children:e.type})]}),Kr("div",{class:"pillar-tool-debug-tool-desc",children:e.description||"No description"}),Kr("div",{class:"pillar-tool-debug-tool-meta",children:[Kr("span",{class:"pillar-tool-source",children:hp(e.source)}),e.hasHandler?Kr("span",{class:"pillar-tool-handler pillar-tool-handler--active",children:"handler"}):Kr("span",{class:"pillar-tool-handler",children:"no handler"})]})]},e.name))})]}),Kr("div",{class:"pillar-tool-debug-detail",children:a?Kr($,{children:[Kr("div",{class:"pillar-tool-debug-detail-header",children:[Kr("h3",{class:"pillar-tool-debug-detail-name",children:a.name}),a.type&&Kr("span",{class:`pillar-tool-badge ${up(a.type)}`,children:a.type})]}),Kr("p",{class:"pillar-tool-debug-detail-desc",children:a.description||"No description provided"}),a.inputSchema&&Kr("div",{class:"pillar-tool-debug-schema",children:[Kr("h4",{class:"pillar-tool-debug-section-title",children:"Input Schema"}),Kr("pre",{class:"pillar-tool-debug-schema-content",children:JSON.stringify(a.inputSchema,null,2)})]}),Kr("div",{class:"pillar-tool-debug-input",children:[Kr("h4",{class:"pillar-tool-debug-section-title",children:"Input Parameters"}),Kr("textarea",{class:"pillar-tool-debug-textarea "+(c?"pillar-tool-debug-textarea--error":""),value:o,onInput:e=>b(e.target.value),rows:8,spellcheck:!1}),c&&Kr("div",{class:"pillar-tool-debug-json-error",children:c})]}),Kr("div",{class:"pillar-tool-debug-actions",children:[Kr("button",{class:"pillar-tool-debug-execute-btn",onClick:v,disabled:d||!!c||!a.hasHandler,children:d?"Executing...":"Execute Tool"}),!a.hasHandler&&Kr("span",{class:"pillar-tool-debug-no-handler",children:"No handler registered"})]}),h&&Kr("div",{class:"pillar-tool-debug-result "+(h.success?"pillar-tool-debug-result--success":"pillar-tool-debug-result--error"),children:[Kr("h4",{class:"pillar-tool-debug-section-title",children:h.success?"Result":"Error"}),Kr("pre",{class:"pillar-tool-debug-result-content",children:h.success?JSON.stringify(h.result,null,2)||"undefined":h.error})]})]}):Kr("div",{class:"pillar-tool-debug-no-selection",children:Kr("p",{children:"Select a tool from the list to view details and test execution"})})})]})]})}function fp(){const e=Co(),t=so.value,n=ea.value,r="chat"===t.type,i="home"===t.type,a=()=>{switch(n){case"tools":return Kr(gp,{});case"support":return Kr("div",{style:{padding:"24px",textAlign:"center"},children:[Kr("h2",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:"Hello World"}),Kr("p",{style:{color:"var(--pillar-text-muted)",fontSize:"14px"},children:"Support tab content goes here."})]});default:return null}};return Kr("div","tools"===n?{class:"_pillar-panel-ui pillar-panel-ui",children:Kr(gp,{})}:"assistant"!==n?{class:"_pillar-panel-ui pillar-panel-ui",children:[Kr(dp,{currentView:"home"}),Kr("div",{class:"_pillar-content pillar-content",children:a()})]}:{class:"_pillar-panel-ui pillar-panel-ui",children:[Kr(dp,{currentView:t.type,hideNavigation:r}),Kr("div",{class:"_pillar-content pillar-content",children:(()=>{switch(t.type){case"home":default:return Kr(Uo,{});case"chat":return Kr(op,{})}})()}),!r&&!i&&Kr("div",{class:"_pillar-chat-input-area pillar-chat-input-area",children:Kr(jo,{placeholder:e.inputPlaceholder})})]})}class mp{constructor(e,t,n,r){this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,this.resizeHandle=null,this.unsubscribe=null,this.isManualMount=!1,this.themeObserver=null,this._isResizing=!1,this._resizeStartX=0,this._resizeStartWidth=0,this._resizeRafId=null,this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,this.handleResizeStart=e=>{if(!Yi.value||!this.config.panel.resizable)return;e.preventDefault(),e.stopPropagation();const t="touches"in e?e.touches[0].clientX:e.clientX;this._isResizing=!0,this._resizeStartX=t,this._resizeStartWidth=ra.value,this._boundHandleResizeMove=this.handleResizeMove.bind(this),this._boundHandleResizeEnd=this.handleResizeEnd.bind(this),document.addEventListener("mousemove",this._boundHandleResizeMove),document.addEventListener("mouseup",this._boundHandleResizeEnd),document.addEventListener("touchmove",this._boundHandleResizeMove,{passive:!1}),document.addEventListener("touchend",this._boundHandleResizeEnd),document.addEventListener("touchcancel",this._boundHandleResizeEnd),document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",document.documentElement.style.cursor="col-resize",document.documentElement.style.transition="none",this.panelElement?.classList.add("_pillar-panel--resizing","pillar-panel--resizing")},this.handleResizeEnd=e=>{this._isResizing&&(null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this._isResizing=!1,Zi(ra.value),this._boundHandleResizeMove&&(document.removeEventListener("mousemove",this._boundHandleResizeMove),document.removeEventListener("touchmove",this._boundHandleResizeMove)),this._boundHandleResizeEnd&&(document.removeEventListener("mouseup",this._boundHandleResizeEnd),document.removeEventListener("touchend",this._boundHandleResizeEnd),document.removeEventListener("touchcancel",this._boundHandleResizeEnd)),this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,document.body.style.userSelect="",document.body.style.webkitUserSelect="",document.documentElement.style.cursor="",document.documentElement.style.transition="padding 0.3s ease",this.panelElement?.classList.remove("_pillar-panel--resizing","pillar-panel--resizing"))},this.handleKeyDown=e=>{"Escape"===e.key&&Yi.value&&ga()},this.config=e,this.api=t,this.events=n,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 Yi.value}async init(){var e,t,n;if(e=this.config.panel.position,ta.value=e,(e=>{na.value=e})(this.config.panel.mode),t=this.config.panel.hoverBreakpoint,ia.value=t,n=this.config.panel.hoverBackdrop,aa.value=n,this.config.panel.resizable){const e=Xi();fa(null!==e?e:this.config.panel.width)}else fa(this.config.panel.width);this.createHost(),this.isManualMount||this.createBackdrop(),this.createPanel(),this.renderPreact(),this.bindEvents(),this.subscribeToState()}open(e){if(e?.search&&(Ul(e.search),uo("chat"),Fl()),Yi.value)return e?.view&&uo(e.view),void(e?.focusInput&&ql());Yi.value=!0,Ji(!0),"overlay"===ha.value&&(document.body.style.overflow="hidden"),e?.view&&!e?.search&&uo(e.view),e?.focusInput?ql():this.setupFocusTrap()}close(){Yi.value&&ga()}navigate(e,t){Yi.value?uo(e,t):this.open({view:e})}destroy(){this.close(),this._isResizing&&this.handleResizeEnd(new MouseEvent("mouseup")),null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.resizeHandle&&(this.resizeHandle.removeEventListener("mousedown",this.handleResizeStart),this.resizeHandle.removeEventListener("touchstart",this.handleResizeStart),this.resizeHandle=null),this.isManualMount||this.removePushModeStyles(),this.unsubscribe?.(),this.unsubscribe=null,ca?.(),ca=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),ma(),fo(),Zl()}handleResizeMove(e){this._isResizing&&("touches"in e&&e.preventDefault(),null===this._resizeRafId&&(this._resizeRafId=requestAnimationFrame(()=>{if(this._resizeRafId=null,!this._isResizing)return;const t="touches"in e?e.touches[0].clientX:e.clientX,n=this._resizeStartX-t,r="right"===ta.value?n:-n,i=window.innerWidth-100,a=Math.max(mp.MIN_PANEL_WIDTH,Math.min(i,this._resizeStartWidth+r));fa(a)})))}subscribeToState(){if(this.isManualMount)return void(this.unsubscribe=Yi.subscribe(e=>{e||this.events.emit("panel:close")}));let e=Yi.value,t=ha.value;const n=()=>{const e=Yi.value,t="push"===ha.value,n=ra.value,r=ta.value,i=pa.value&&aa.value||da.value;e?(t?(this.applyPushModeStyles(n,r),this.setBackdropVisible(!1)):(this.removePushModeStyles(),document.body.style.overflow="hidden",this.setBackdropVisible(i)),this.panelElement?.classList.add("_pillar-panel--open","pillar-panel--open")):(this.removePushModeStyles(),document.body.style.overflow="",this.setBackdropVisible(!1),this.panelElement?.classList.remove("_pillar-panel--open","pillar-panel--open"))};n();const r=Yi.subscribe(t=>{t!==e&&(e=t,n(),t||this.events.emit("panel:close"))}),i=ha.subscribe(e=>{e!==t&&(t=e,n())});let a=ua.value;const l=ua.subscribe(e=>{e!==a&&(a=e,e?this.panelElement?.classList.add("_pillar-panel--full-width","pillar-panel--full-width"):this.panelElement?.classList.remove("_pillar-panel--full-width","pillar-panel--full-width"))});let o=da.value;const s=da.subscribe(e=>{e!==o&&(o=e,e?this.panelElement?.classList.add("_pillar-panel--mobile","pillar-panel--mobile"):this.panelElement?.classList.remove("_pillar-panel--mobile","pillar-panel--mobile"),n())});let c=ra.value;const p=ra.subscribe(e=>{e!==c&&(c=e,this.panelElement?.style.setProperty("--pillar-panel-width",`${e}px`),Yi.value&&n())});this.unsubscribe=()=>{r(),i(),l(),s(),p()}}setBackdropVisible(e){this.backdrop&&(e?(this.backdrop.style.opacity="1",this.backdrop.style.visibility="visible",this.backdrop.classList.add("_pillar-backdrop--visible","pillar-backdrop--visible")):(this.backdrop.style.opacity="0",this.backdrop.style.visibility="hidden",this.backdrop.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")))}getPushTargetElement(){const e=this.config.panel.pushTarget;return e?"string"==typeof e?document.querySelector(e)||document.documentElement:e:document.documentElement}applyPushModeStyles(e,t){const n=this.getPushTargetElement();n.style.transition="padding 0.3s ease","right"===t?(n.style.paddingRight=`${e}px`,document.documentElement.style.setProperty("--pillar-inset-right",`${e}px`),document.documentElement.style.setProperty("--pillar-inset-left","0px")):(n.style.paddingLeft=`${e}px`,document.documentElement.style.setProperty("--pillar-inset-left",`${e}px`),document.documentElement.style.setProperty("--pillar-inset-right","0px"))}removePushModeStyles(){const e=this.getPushTargetElement();e.style.paddingLeft="",e.style.paddingRight="",document.documentElement.style.removeProperty("--pillar-inset-right"),document.documentElement.style.removeProperty("--pillar-inset-left"),setTimeout(()=>{Yi.value||(e.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 t=vo,n=this.transformStylesForRegularDOM(t),r=document.createElement("style");r.id=e,r.textContent=n,document.head.appendChild(r);const i=xo(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=vo,this.shadow.appendChild(e);const t=xo(this.config.theme);if(t){const e=document.createElement("style");e.textContent=t,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 t=this.rootContainer||document.body;let n=null;"string"==typeof e?(n=document.querySelector(e),n||(p.warn(`[Pillar] Container element not found: ${e}, falling back to root container`),n=t)):n=e instanceof HTMLElement?e:t,n.appendChild(this.host)}mountTo(e){this.host?(this.host.parentElement&&this.host.parentElement.removeChild(this.host),e.appendChild(this.host)):p.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.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.4s cubic-bezier(0.32, 0.72, 0, 1);\n z-index: 99998;\n ",this.backdrop.addEventListener("click",()=>{ga()});(this.rootContainer||document.body).appendChild(this.backdrop)}createPanel(){const e=this.renderContainer;if(!e)return;this.panelElement=document.createElement("div");const t=this.isManualMount?" _pillar-panel--manual pillar-panel--manual":"",n=`_pillar-panel--${ta.value} pillar-panel--${ta.value}`,r=da.value?" _pillar-panel--mobile pillar-panel--mobile":"",i=ua.value?" _pillar-panel--full-width pillar-panel--full-width":"";this.panelElement.className=`_pillar-panel pillar-panel ${n}${t}${r}${i}`,this.panelElement.style.setProperty("--pillar-panel-width",`${ra.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),!this.config.panel.resizable||this.isManualMount||this.config.edgeTrigger.enabled||(this.resizeHandle=document.createElement("div"),this.resizeHandle.className="_pillar-resize-handle pillar-resize-handle",this.resizeHandle.addEventListener("mousedown",this.handleResizeStart),this.resizeHandle.addEventListener("touchstart",this.handleResizeStart,{passive:!1}),this.panelElement.appendChild(this.resizeHandle)),e.appendChild(this.panelElement)}renderPreact(){this.renderRoot&&Y(Kr(wo,{api:this.api,events:this.events,config:this.config,children:Kr(fp,{})}),this.renderRoot)}bindEvents(){document.addEventListener("keydown",this.handleKeyDown)}setupFocusTrap(){setTimeout(()=>{const e=this.renderContainer,t=e?.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');t?.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 t=xo(this.config.theme);if(this.shadow){const e=this.shadow.querySelector("style[data-pillar-theme]");if(e&&t)e.textContent=t;else if(t&&!e){const e=document.createElement("style");e.textContent=t,e.setAttribute("data-pillar-theme","");const n=this.shadow.querySelector("style");n?.nextSibling?this.shadow.insertBefore(e,n.nextSibling):this.shadow.appendChild(e)}}else{const e=this.transformStylesForRegularDOM(t),n=document.getElementById("pillar-sdk-theme");if(n&&e)n.textContent=e;else if(e&&!n){const t=document.createElement("style");t.id="pillar-sdk-theme",t.textContent=e,document.head.appendChild(t)}}}}mp.MIN_PANEL_WIDTH=200;function bp({label:e,x:t,y:n,isVisible:r,onClick:i}){const a=pi(null),[l,o]=si({x:t,y:n}),[s,c]=si(!1),p=ui(()=>{if(!a.current||!r)return;const e=a.current.getBoundingClientRect(),i=window.innerWidth;let l=t,s=n,p=!1;l=t-e.width/2,l<10?l=10:l+e.width>i-10&&(l=i-e.width-10),s=n-e.height-10,s<10&&(s=n+10,p=!0),o({x:l,y:s}),c(p)},[t,n,r]);ci(()=>{r&&requestAnimationFrame(p)},[r,p,t,n]);return Kr("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:[Kr("div",{class:"pillar-text-selection-popover__content",children:[Kr("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>'}}),Kr("span",{children:e})]}),Kr("div",{class:"pillar-text-selection-popover__arrow"})]})}const vp="pillar-text-selection-styles";class _p{constructor(e,t,n){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}),Wl({type:"highlighted_text",url_origin:window.location.href,text_content:this.currentSelection}),this.hidePopover(),window.getSelection()?.removeAllRanges(),this.openPanel())},this.config=e,this.events=t,this.openPanel=n}init(){this.stylesInjected||(ba(document,"/* Pillar Text Selection Popover Styles */\n.pillar-text-selection-popover {\n position: absolute;\n z-index: 99999;\n padding: 6px 12px;\n font-family: var(--pillar-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",vp),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(vp)?.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 t=window.getSelection();if(!t||t.isCollapsed)return;const n=t.toString().trim();if(n.length<3)return;const r=t.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=n,this.showPopover(o,s)}showPopover(e,t){this.container&&(this.isVisible=!0,Y(Kr(bp,{label:this.config.textSelection.label,x:e,y:t,isVisible:!0,onClick:this.handlePopoverClick}),this.container),this.events.emit("textSelection:shown",{text:this.currentSelection}))}hidePopover(){this.container&&this.isVisible&&(this.isVisible=!1,Y(Kr(bp,{label:this.config.textSelection.label,x:0,y:0,isVisible:!1,onClick:()=>{}}),this.container))}}const xp={recentActions:[]},yp={},wp=Ai({...xp}),kp=Ai({...yp});Di(()=>{const e=wp.value;return!!(e.currentPage||e.currentFeature||e.userRole||e.errorState||e.recentActions&&e.recentActions.length>0)}),Di(()=>!!wp.value.errorState);const Sp=e=>{kp.value={...e}},Cp=Ai(null),Pp=Ai([]);Di(()=>null!==Cp.value),Di(()=>Cp.value&&Cp.value.steps[Cp.value.current_step]||null);const Ep=Di(()=>Cp.value?Cp.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);function Tp(e,t){if(!Cp.value)return;const n=Cp.value.steps.map((n,r)=>r===e?{...n,status:t}:n);Cp.value={...Cp.value,steps:n}}function zp(){if(!Cp.value)return null;const e=Cp.value.current_step+1;if(e>=Cp.value.steps.length)return null;const t=Cp.value.steps[e].auto_run?"active":"awaiting_initiation",n=Cp.value.steps.map((n,r)=>r===e?{...n,status:t}:n);return Cp.value={...Cp.value,steps:n,current_step:e},Cp.value.steps[e]}function Rp(){if(!Cp.value)return null;const e=Cp.value;return Pp.value=[...Pp.value,e],Cp.value=null,e}Di(()=>Cp.value?Ep.value/Cp.value.total_steps:0);const Ip=/^[a-zA-Z_][a-zA-Z0-9_.\-:]{0,63}$/;const Ap={tools:new Map,clientInfo:null};function Mp(e,t){Ap.clientInfo={platform:e,version:t}}function $p(){return Ap.clientInfo}function Lp(e){const t=Ap.tools.get(e);return t?.handler}function Op(e){return Ap.tools.get(e)}function Dp(e){return Ap.tools.has(e)}function jp(){return Array.from(Ap.tools.keys())}function Hp(e,t,n){const r=[];for(const[e,t]of Ap.tools){const n={name:e,description:t.description,type:t.type};t.examples?.length&&(n.examples=t.examples),t.path&&(n.path=t.path),t.externalUrl&&(n.external_url=t.externalUrl),t.autoRun&&(n.auto_run=t.autoRun),t.autoComplete&&(n.auto_complete=t.autoComplete),t.returns&&(n.returns_data=t.returns),t.dataSchema&&(n.data_schema=t.dataSchema),t.defaultData&&(n.default_data=t.defaultData),t.requiredContext&&(n.required_context=t.requiredContext),r.push(n)}return{platform:e,version:t,gitSha:n,generatedAt:(new Date).toISOString(),tools:r}}function Np(){Ap.tools.clear(),Ap.clientInfo=null}function Up(){return Ap.tools.size}const Bp=Op,Fp=Dp,qp=jp,Wp=Up;class Vp{constructor(e={}){this._callback=null,this._debounceTimer=null,this._lastRoute=null,this._running=!1,this._originalPushState=null,this._originalReplaceState=null,this._handleRouteChange=()=>{this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{const e=this._getCurrentUrl();e!==this._lastRoute&&(this._lastRoute=e,this._callback&&this._callback(this.getCurrentRoute()))},this._debounceMs)},this._debounceMs=e.debounceMs??100}get running(){return this._running}onRouteChange(e){this._callback=e}start(){this._running||"undefined"!=typeof window&&(this._running=!0,this._lastRoute=this._getCurrentUrl(),this._patchHistory(),window.addEventListener("popstate",this._handleRouteChange),window.addEventListener("hashchange",this._handleRouteChange))}stop(){this._running&&(this._running=!1,this._restoreHistory(),window.removeEventListener("popstate",this._handleRouteChange),window.removeEventListener("hashchange",this._handleRouteChange),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null))}getCurrentRoute(){return{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,url:window.location.href,title:document.title}}_patchHistory(){this._originalPushState=history.pushState.bind(history),this._originalReplaceState=history.replaceState.bind(history),history.pushState=(...e)=>{this._originalPushState(...e),this._handleRouteChange()},history.replaceState=(...e)=>{this._originalReplaceState(...e),this._handleRouteChange()}}_restoreHistory(){this._originalPushState&&(history.pushState=this._originalPushState),this._originalReplaceState&&(history.replaceState=this._originalReplaceState),this._originalPushState=null,this._originalReplaceState=null}_getCurrentUrl(){return window.location.pathname+window.location.search+window.location.hash}}const Kp="pillar-";const Gp=[{id:"assistant",label:"Assistant",enabled:!0,order:0}],Qp={apiBaseUrl:"https://help-api.trypillar.com",assistantDisplayName:"Copilot",inputPlaceholder:"Ask anything...",welcomeMessage:"Hi! How can I help you today?",panel:{enabled:!0,position:"right",mode:"push",width:380,useShadowDOM:!1,hoverBreakpoint:1200,hoverBackdrop:!0,fullWidthBreakpoint:500,initialOpen:!1,resizable:!0},edgeTrigger:{enabled:!0,resizable:!0},mobileTrigger:{enabled:!0,breakpoint:700,position:"bottom-right",icon:"sparkle",iconColor:"white",size:"medium",label:"Get help",offset:24},urlParams:{enabled:!0,prefix:"pillar-",clearAfterOpen:!0},textSelection:{enabled:!0,label:"Ask AI"},domScanning:{enabled:!1,includeText:!0,maxDepth:20,visibleOnly:!0,maxTextLength:500,interactionHighlight:{enabled:!0,outlineColor:"#3b82f6",outlineWidth:2,outlineOffset:2,duration:2e3,scrollIntoView:!0,scrollBehavior:"smooth"}},suggestions:{enabled:!0,debounceMs:100,displayLimit:3},theme:{mode:"auto"},zIndex:{push:1,hover:9999},excludeRoutes:["/login","/signup"]};function Jp(e){if(!e||0===e.length)return Gp;const t=new Map;for(const e of Gp)t.set(e.id,{...e});for(const n of e)t.set(n.id,{...n});const n=t.get("assistant");return n&&(n.enabled=!0),Array.from(t.values()).sort((e,t)=>e.order-t.order)}function Xp(e){if(!e.productKey)throw new Error("[Pillar] productKey is required");return{productKey:e.productKey,apiBaseUrl:e.apiBaseUrl||Qp.apiBaseUrl,assistantDisplayName:e.assistantDisplayName||Qp.assistantDisplayName,inputPlaceholder:e.inputPlaceholder||Qp.inputPlaceholder,welcomeMessage:e.welcomeMessage||Qp.welcomeMessage,platform:e.platform||"web",version:e.version,debug:e.debug??!1,tracing:e.tracing??e.debug??!1,panel:{...Qp.panel,...e.panel},edgeTrigger:{...Qp.edgeTrigger,...e.edgeTrigger},mobileTrigger:{...Qp.mobileTrigger,...e.mobileTrigger},urlParams:{...Qp.urlParams,...e.urlParams},textSelection:{...Qp.textSelection,...e.textSelection},domScanning:{...Qp.domScanning,...e.domScanning,enabled:!1,interactionHighlight:{...Qp.domScanning.interactionHighlight,...e.domScanning?.interactionHighlight}},suggestions:{...Qp.suggestions,...e.suggestions},sidebarTabs:Jp(e.sidebarTabs),theme:{mode:e.theme?.mode??Qp.theme.mode,colors:{...e.theme?.colors},darkColors:{...e.theme?.darkColors},fontFamily:e.theme?.fontFamily},customCSS:e.customCSS,zIndex:{...Qp.zIndex,...e.zIndex},excludeRoutes:e.excludeRoutes??Qp.excludeRoutes,onReady:e.onReady,onError:e.onError}}class Zp{_persistExternalUserId(e){if("undefined"!=typeof window)try{null===e?localStorage.removeItem(Zp.EXTERNAL_USER_ID_STORAGE_KEY):localStorage.setItem(Zp.EXTERNAL_USER_ID_STORAGE_KEY,e)}catch{}}_getStoredExternalUserId(){if("undefined"==typeof window)return null;try{return localStorage.getItem(Zp.EXTERNAL_USER_ID_STORAGE_KEY)}catch{return null}}get _registeredActions(){return this._registeredTools}constructor(){this._state="uninitialized",this._config=null,this._api=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._initPromise=null,this._rootContainer=null,this._unsubscribeHoverMode=null,this._context={...xp},this._userProfile={...yp},this._externalUserId=null,this._taskHandlers=new Map,this._anyTaskHandler=null,this._registeredTools=new Map,this._definedTools=new Map,this._cardRenderers=new Map,this._debugPanelContainer=null,this._routeObserver=null,this._isRouteExcluded=!1,this._suggestionPool=[],this._highlightedElement=null,this._highlightTimeout=null,this._fadeOutTimeout=null,this._originalStyles=null,this._events=new u}_createRootContainer(){const{push:e,hover:t}=this._config.zIndex;let n=document.getElementById("pillar-root");if(n)return this._subscribeToHoverModeForRoot(n,e,t),n;n=document.createElement("div"),n.id="pillar-root";const r=pa.value?t:e;return n.style.cssText=`isolation: isolate; z-index: ${r}; position: relative;`,document.body.appendChild(n),this._subscribeToHoverModeForRoot(n,e,t),n}_subscribeToHoverModeForRoot(e,t,n){this._unsubscribeHoverMode?.();let r=pa.value;this._unsubscribeHoverMode=pa.subscribe(i=>{i!==r&&(r=i,e.style.zIndex=String(i?n:t))})}static async init(e){if(!e.productKey)throw new Error("[Pillar] productKey is required");return Zp.instance||(Zp.instance=new Zp,Ea(Zp.instance)),await Zp.instance._init(e),Zp.instance}static getInstance(){return Zp.instance}static destroy(){Zp.instance&&(Zp.instance._destroy(),Zp.instance=null,Ea(null))}get state(){return this._state}get isReady(){return"ready"===this._state}get isPanelOpen(){return Yi.value}get config(){return this._config}get isDebugEnabled(){return this._config?.debug??!1}getDebugLog(){return this._config?.debug?o.getEntries():[]}onDebugLog(e){return o.subscribe(e)}clearDebugLog(){o.clear()}getTools(){if(!this._config?.debug)return[];const e=[],t=new Set;for(const[n,r]of this._definedTools){t.add(n);const i="inline_ui"===r.type;e.push({name:n,description:r.description,type:r.type,inputSchema:r.inputSchema,source:"defined",hasHandler:i?this._cardRenderers.has(n):"function"==typeof r.execute})}for(const[n,r]of this._registeredTools)t.has(n)||(t.add(n),e.push({name:n,description:r.description||"",type:r.type,inputSchema:r.dataSchema,source:"registered",hasHandler:this._taskHandlers.has(n)}));for(const n of jp()){if(t.has(n))continue;t.add(n);const r=Op(n);e.push({name:n,description:r?.description||"",type:r?.type,inputSchema:r?.dataSchema,source:"registry",hasHandler:this._taskHandlers.has(n)})}return e.sort((e,t)=>e.name.localeCompare(t.name))}async executeToolForDebug(e,t){if(!this._config?.debug)return{success:!1,error:"Debug mode not enabled"};try{const n=this._definedTools.get(e);if(n){if("inline_ui"===n.type)return{success:!1,error:`Tool "${e}" is an inline_ui tool. It renders UI via its card renderer instead of executing a handler.`};if(n.execute){return{success:!0,result:await n.execute(t)}}}const r=this._taskHandlers.get(e);if(r){return{success:!0,result:await r(t)}}return{success:!1,error:`No handler found for tool: ${e}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}on(e,t){return this._events.on(e,t)}open(e){this._panel&&!this._isRouteExcluded&&(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,t){this._panel?.navigate(e,t),this._events.emit("panel:navigate",{view:e,params:t})}setContext(e){this._context={...this._context,...e},(e=>{wp.value={...wp.value,...e}})(e),this._events.emit("context:change",{context:this._context})}getChatContext(){const e=Na.value,t=Ua.value;return 0===e.length?null:{conversationId:t,messages:e.map(e=>({role:e.role,content:e.content}))}}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 _p(this._config,this._events,()=>this.open()),this._textSelectionManager.init()):this._textSelectionManager&&(this._textSelectionManager.destroy(),this._textSelectionManager=null),this._events.emit("textSelection:change",{enabled:e}))}setDOMScanningEnabled(e){}get isDOMScanningEnabled(){return!1}highlightElement(e){const t=this._config?.domScanning.interactionHighlight;if(!t?.enabled)return;this.clearHighlight(!0),t.scrollIntoView&&e.scrollIntoView({behavior:t.scrollBehavior,block:"center",inline:"nearest"}),this._originalStyles={outline:e.style.outline,outlineOffset:e.style.outlineOffset,transition:e.style.transition},this._highlightedElement=e;const n=e.style.transition,r="outline-color 0.3s ease-in-out";e.style.transition=n?`${n}, ${r}`:r,e.style.outline=`${t.outlineWidth}px solid transparent`,e.style.outlineOffset=`${t.outlineOffset}px`,e.offsetHeight,e.style.outline=`${t.outlineWidth}px solid ${t.outlineColor}`,p.log("[Pillar] Element highlighted with fade-in:",e.tagName),t.duration>0&&(this._highlightTimeout=setTimeout(()=>{this.clearHighlight()},t.duration))}clearHighlight(e=!1){if(this._highlightTimeout&&(clearTimeout(this._highlightTimeout),this._highlightTimeout=null),this._fadeOutTimeout&&(clearTimeout(this._fadeOutTimeout),this._fadeOutTimeout=null),this._highlightedElement&&this._originalStyles){const t=this._highlightedElement,n=this._originalStyles;e?(t.style.outline=n.outline,t.style.outlineOffset=n.outlineOffset,t.style.transition=n.transition,p.log("[Pillar] Highlight cleared immediately")):(t.style.outline=t.style.outline.replace(/[^,\s]+$/,"transparent"),this._fadeOutTimeout=setTimeout(()=>{t.style.outline=n.outline,t.style.outlineOffset=n.outlineOffset,t.style.transition=n.transition,p.log("[Pillar] Highlight fade-out complete"),this._fadeOutTimeout=null},300)),this._highlightedElement=null,this._originalStyles=null}}getElement(e){return document.querySelector(e)}clickElement(e){p.log("[Pillar] clickElement called with selector:",e);const t=this.getElement(e);if(p.log("[Pillar] clickElement found element:",t),t instanceof HTMLElement){p.log("[Pillar] clickElement clicking element:",t.tagName,t.textContent?.slice(0,50)),this.highlightElement(t);const e=t.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height/2,i={bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:r,button:0,buttons:1};return t.dispatchEvent(new MouseEvent("mousedown",i)),t.dispatchEvent(new MouseEvent("mouseup",i)),t.dispatchEvent(new MouseEvent("click",i)),p.log("[Pillar] clickElement full mouse sequence executed"),!0}return p.warn("[Pillar] clickElement element not found or not HTMLElement"),!1}typeInElement(e,t){p.log("[Pillar] typeInElement called with selector:",e,"text:",t);const n=this.getElement(e);if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){p.log("[Pillar] typeInElement found input/textarea:",n.tagName,n.type),this.highlightElement(n),n.focus();const e=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,r=Object.getOwnPropertyDescriptor(e,"value")?.set;return r?(r.call(n,t),p.log("[Pillar] typeInElement set value via native setter")):(n.value=t,p.log("[Pillar] typeInElement set value directly (fallback)")),n.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),n.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),n.dispatchEvent(new Event("change",{bubbles:!0})),p.log("[Pillar] typeInElement complete - events fired"),!0}return n instanceof HTMLElement&&"true"===n.getAttribute("contenteditable")?(p.log("[Pillar] typeInElement found contenteditable element"),this.highlightElement(n),n.focus(),n.textContent=t,n.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),n.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),p.log("[Pillar] typeInElement contenteditable complete"),!0):(p.warn("[Pillar] typeInElement element not found or not an input:",n),!1)}selectOption(e,t){p.log("[Pillar] selectOption called with selector:",e,"value:",t);const n=this.getElement(e);if(n instanceof HTMLSelectElement){p.log("[Pillar] selectOption found select element"),this.highlightElement(n),n.focus();const e=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;return e?(e.call(n,t),p.log("[Pillar] selectOption set value via native setter")):(n.value=t,p.log("[Pillar] selectOption set value directly (fallback)")),n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})),p.log("[Pillar] selectOption complete"),!0}return p.warn("[Pillar] selectOption element not found or not a select:",n),!1}focusElement(e){p.log("[Pillar] focusElement called with selector:",e);const t=this.getElement(e);return t instanceof HTMLElement?(p.log("[Pillar] focusElement found element:",t.tagName),this.highlightElement(t),t.focus(),t.dispatchEvent(new FocusEvent("focusin",{bubbles:!0})),p.log("[Pillar] focusElement complete"),!0):(p.warn("[Pillar] focusElement element not found:",t),!1)}toggleElement(e){p.log("[Pillar] toggleElement called with selector:",e);const t=this.getElement(e);if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type)){p.log("[Pillar] toggleElement found checkbox/radio:",t.type,"current checked:",t.checked),this.highlightElement(t),t.focus();const e=t.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height/2,i={bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:r,button:0,buttons:1};return t.dispatchEvent(new MouseEvent("mousedown",i)),t.dispatchEvent(new MouseEvent("mouseup",i)),t.dispatchEvent(new MouseEvent("click",i)),t.dispatchEvent(new Event("input",{bubbles:!0})),p.log("[Pillar] toggleElement complete - new checked:",t.checked),!0}return p.warn("[Pillar] toggleElement element not found or not checkbox/radio:",t),!1}async handlePageInteraction(e){if(p.log("[Pillar] handlePageInteraction called with params:",e),!bs(e.ref))return p.warn("[Pillar] handlePageInteraction rejected invalid ref format:",e.ref),{success:!1,error:"Invalid ref format"};const t=vs(e.ref);p.log("[Pillar] handlePageInteraction built selector:",t);const n=this.getElement(t);if(!n)return p.warn("[Pillar] handlePageInteraction element not found for ref:",e.ref),{success:!1,error:"Element not found"};if(n.getAttribute("data-pillar-ref")!==e.ref)return p.warn("[Pillar] handlePageInteraction ref attribute mismatch"),{success:!1,error:"Ref attribute mismatch"};if(gs(n)){const t=n.textContent?.trim().slice(0,50)||n.getAttribute("aria-label")||e.operation;p.log("[Pillar] handlePageInteraction detected destructive element:",t);const{requestConfirmation:r}=await Promise.resolve().then(function(){return Yo});if(!await r(`Agent wants to ${e.operation} "${t}"`))return p.log("[Pillar] handlePageInteraction destructive action denied by user"),{success:!1,error:"User denied destructive action"};p.log("[Pillar] handlePageInteraction destructive action confirmed by user")}let r;switch(e.operation){case"click":r={success:this.clickElement(t)};break;case"type":if(!e.value){r={success:!1,error:"value required for type operation"};break}r={success:this.typeInElement(t,e.value)};break;case"select":if(!e.value){r={success:!1,error:"value required for select operation"};break}r={success:this.selectOption(t,e.value)};break;case"focus":r={success:this.focusElement(t)};break;case"toggle":r={success:this.toggleElement(t)};break;default:r={success:!1,error:`Unknown operation: ${e.operation}`}}return p.log("[Pillar] handlePageInteraction result:",r),r}mountPanelTo(e){this._panel?.mountTo(e)}getPanelHostElement(){return this._panel?.getHostElement()??null}get context(){return{...this._context}}get userProfile(){return{...this._userProfile}}setUserProfile(e){this._userProfile={...e},Sp(this._userProfile),this._events.emit("profile:change",{profile:this._userProfile})}async identify(e,t,n){if(this._api)if(e)if(null===this._externalUserId||String(this._externalUserId)!==String(e))try{await this._api.identify(e,t),this._externalUserId=e,this._persistExternalUserId(e),this._userProfile={...this._userProfile,userId:e,...t?.name&&{name:t.name}},Sp(this._userProfile),this._api.setExternalUserId(e),n?.preserveConversation||Zl(),Fa.value+=1,this._events.emit("user:identified",{userId:e,profile:t})}catch(e){throw p.error("[Pillar] Failed to identify user:",e),e}else p.log("[Pillar] Already identified as this user, skipping");else p.warn("[Pillar] userId is required for identify()");else p.warn("[Pillar] SDK not initialized, cannot identify user")}logout(e){this._externalUserId=null,this._persistExternalUserId(null),this._userProfile={...yp},Sp(this._userProfile),this._api?.clearExternalUserId(),this._api?.regenerateVisitorId(),e?.preserveConversation||Zl(),Fa.value+=1,this._events.emit("user:logout",{})}get externalUserId(){return this._externalUserId}get isIdentified(){return null!==this._externalUserId}reportAction(e,t){const n=[...(this._context.recentActions||[]).slice(-9),e];this._context={...this._context,recentActions:n},(e=>{const t=wp.value.recentActions||[];wp.value={...wp.value,recentActions:[...t.slice(-9),e]}})(e),this._events.emit("action:report",{action:e,metadata:t})}clearErrorState(){if(this._context.errorState){const{errorState:e,...t}=this._context;this._context=t,(()=>{const{errorState:e,...t}=wp.value;wp.value=t})(),this._events.emit("context:change",{context:this._context})}}setErrorState(e,t){this._context={...this._context,errorState:{code:e,message:t}},((e,t)=>{wp.value={...wp.value,errorState:{code:e,message:t}}})(e,t),this._events.emit("context:change",{context:this._context})}async getSuggestions(){if(!this._api)return p.warn("[Pillar] SDK not initialized, cannot get suggestions"),[];try{return await this._api.getSuggestions(this._context,this._userProfile)}catch(e){return p.error("[Pillar] Failed to get suggestions:",e),[]}}getAssistantContext(){return{product:this._context,user:this._userProfile}}onTask(e,t){return this._taskHandlers.set(e,t),()=>this._taskHandlers.delete(e)}defineTool(e){if(!e.name)return p.warn("[Pillar] defineTool called without a name"),()=>{};const t=function(e){if(!e||"string"!=typeof e)return{valid:!1,error:"Tool name is required"};if(e.length>64)return{valid:!1,error:`Tool name exceeds 64 characters (got ${e.length})`};if(!/^[a-zA-Z_]/.test(e))return{valid:!1,error:`Tool name must start with a letter or underscore, got "${e[0]}"`};if(!Ip.test(e)){const t=e.match(/[^a-zA-Z0-9_.\-:]/g);return{valid:!1,error:`Tool name contains invalid characters: ${[...new Set(t)].map(e=>`"${e}"`).join(", ")}. Only letters, numbers, underscores, dots, colons, and dashes are allowed.`}}return{valid:!0}}(e.name);if(!t.valid)return p.error(`[Pillar] Invalid tool name "${e.name}": ${t.error}. Tool names must start with a letter or underscore and contain only letters, numbers, underscores, dots, colons, or dashes (max 64 chars). Example: "add_to_cart" or "get-user-profile"`),()=>{};this._definedTools.set(e.name,e),p.log(`[Pillar] Defined tool: ${e.name}`),this._events.emit("tools:change",{action:"add",name:e.name});const n=[];"inline_ui"===e.type&&e.render&&n.push(this.registerCard(e.name,e.render));let r=!1;if(e.webMCP&&"inline_ui"!==e.type&&"execute"in e){const t=e;if("undefined"!=typeof navigator&&navigator.modelContext)try{navigator.modelContext.registerTool({name:e.name,description:e.description,inputSchema:e.inputSchema,execute:async(n,r)=>{const i=performance.now();let a,l,o="success";try{l=await t.execute(n),l&&"object"==typeof l&&!Array.isArray(l)&&!1===l.success&&(o="failure",a=l.error||l.message)}catch(e){throw o="failure",a=e instanceof Error?e.message:String(e),e}finally{const t=Math.round(performance.now()-i);this._api?.trackWebMCPExecution(e.name,o,{duration_ms:t,error:a,input:n})}return l&&"object"==typeof l&&"content"in l?l:{content:[{type:"text",text:"string"==typeof l?l:JSON.stringify(l??{success:!0})}]}}}),r=!0,p.log(`[Pillar] Registered tool with WebMCP: ${e.name}`)}catch(t){p.warn(`[Pillar] Failed to register tool with WebMCP: ${e.name}`,t)}else p.log(`[Pillar] WebMCP not available, skipping WebMCP registration for: ${e.name}`)}return()=>{if(this._definedTools.delete(e.name),this._events.emit("tools:change",{action:"remove",name:e.name}),n.forEach(e=>e()),r&&navigator.modelContext)try{navigator.modelContext.unregisterTool(e.name),p.log(`[Pillar] Unregistered tool from WebMCP: ${e.name}`)}catch(t){p.warn(`[Pillar] Failed to unregister tool from WebMCP: ${e.name}`,t)}}}defineAction(e){return this.defineTool(e)}registerTool(e){const{name:t,...n}=e;t?(this._registeredTools.set(t,{name:t,...n,returns:n.returnsData||n.returns||!1,autoRun:n.autoRun??n.auto_run??!1,autoComplete:n.autoComplete??n.auto_complete??!0}),p.log(`[Pillar] Registered tool: ${t}`),this._events.emit("tools:change",{action:"add",name:t})):p.warn("[Pillar] registerTool called without a name")}registerAction(e){this.registerTool(e)}getRegisteredTool(e){return this._registeredTools.get(e)}getRegisteredAction(e){return this.getRegisteredTool(e)}getHandler(e){const t=this._definedTools.get(e);if(t){if(t.execute)return t.execute;if("inline_ui"===t.type&&this._cardRenderers.has(e))return t=>({...t,card_type:e})}const n=Dp(e)?Op(e):void 0;if(n?.handler)return n.handler;const r=this._taskHandlers.get(e);return r||void 0}onAnyTask(e){return this._anyTaskHandler=e,()=>{this._anyTaskHandler=null}}offTask(e){this._taskHandlers.delete(e)}executeTask(e){const{name:t,data:n,taskType:r,path:i,externalUrl:a}=e;if(this._events.emit("task:execute",e),this._anyTaskHandler)try{this._anyTaskHandler(t,n)}catch(e){p.error("[Pillar] Error in onAnyTask handler:",e)}const l=this._definedTools.get(t),s=l?.execute,c=Dp(t)?Op(t):void 0,d=this._registeredTools.get(t),u=c?.handler,h=this._taskHandlers.get(t),g=r?this._taskHandlers.get(r):void 0,f=s||u||h||g,m=!!l||c?.returns||d?.returns;if(f){const e=performance.now();o.add({event:"handler:execute",data:{action:t,taskType:r,params:n},source:"handler",level:"info"});try{const a=f("navigate"===r&&i?{...n,path:i}:n);if(m&&void 0!==a)Promise.resolve(a).then(async r=>{const i=Math.round(performance.now()-e);if(void 0!==r){const e=rs(r);await this.sendToolResult(t,e);let n=!0;if(e&&"object"==typeof e&&!Array.isArray(e)){!1===e.success&&(n=!1)}o.add({event:"handler:complete",data:{action:t,duration:i,success:n,returnsData:!0},source:"handler",level:n?"info":"warn"}),this._events.emit("task:complete",{name:t,success:n,data:r})}else o.add({event:"handler:complete",data:{action:t,duration:i,success:!0},source:"handler",level:"info"}),this._events.emit("task:complete",{name:t,success:!0,data:n})}).catch(r=>{const i=Math.round(performance.now()-e);o.add({event:"handler:error",data:{action:t,duration:i,error:r instanceof Error?r.message:String(r)},source:"handler",level:"error"}),p.error(`[Pillar] Error in query action "${t}":`,r),this._events.emit("task:complete",{name:t,success:!1,data:n})});else{const r=Math.round(performance.now()-e);o.add({event:"handler:complete",data:{action:t,duration:r,success:!0},source:"handler",level:"info"}),this._events.emit("task:complete",{name:t,success:!0,data:n})}}catch(r){const i=Math.round(performance.now()-e);o.add({event:"handler:error",data:{action:t,duration:i,error:r instanceof Error?r.message:String(r)},source:"handler",level:"error"}),p.error(`[Pillar] Error executing task "${t}":`,r),this._events.emit("task:complete",{name:t,success:!1,data:n})}}else switch(r){case"navigate":i&&"undefined"!=typeof window&&(p.warn("[Pillar] No 'navigate' handler registered. Using window.location.href as fallback."),window.location.href=i,this._events.emit("task:complete",{name:t,success:!0,data:n}));break;case"external_link":a&&"undefined"!=typeof window&&(window.open(a,"_blank","noopener,noreferrer"),this._events.emit("task:complete",{name:t,success:!0,data:n}));break;case"copy_text":n.text&&"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(String(n.text)).then(()=>{this._events.emit("task:complete",{name:t,success:!0,data:n})}).catch(()=>{this._events.emit("task:complete",{name:t,success:!1,data:n})});break;default:p.warn(`[Pillar] No handler registered for task "${t}". Register one with pillar.onTask('${t}', handler)`),this._events.emit("task:complete",{name:t,success:!1,data:{error:"No handler registered"}})}}completeTask(e,t=!0,n){this._events.emit("task:complete",{name:e,success:t,data:n})}async completeTool(e,t=!0,n){this._events.emit("task:complete",{name:e,success:t,data:n})}async completeAction(e,t=!0,n){return this.completeTool(e,t,n)}confirmTaskExecution(e,t,n){e?this._api?this._api.confirmTaskExecution(e,t,n):p.warn("[Pillar] SDK not initialized, cannot confirm task execution"):p.warn("[Pillar] confirmTaskExecution called without taskId")}registerCard(e,t){return this._cardRenderers.set(e,t),()=>this._cardRenderers.delete(e)}getCardRenderer(e){return this._cardRenderers.get(e)}hasCardRenderer(e){return this._cardRenderers.has(e)}get workflow(){return Cp.value}startWorkflow(e){!function(e){Cp.value&&(Pp.value=[...Pp.value,Cp.value]);const t=e.steps.map((e,t)=>0===t?{...e,status:e.auto_run?"active":"awaiting_initiation"}:{...e,status:"pending"});Cp.value={...e,steps:t,current_step:0}}(e),this._events.emit("workflow:start",Cp.value);const t=Cp.value.steps[0];t.auto_run&&this._executeWorkflowStep(t)}initiateWorkflowStep(e){const t=Cp.value;if(!t)return void p.warn("[Pillar] No active workflow");const n=e??t.current_step,r=t.steps[n];r?"awaiting_initiation"===r.status?this._executeWorkflowStep(r):p.warn(`[Pillar] Step ${n} is not awaiting initiation`):p.warn(`[Pillar] Invalid step index: ${n}`)}confirmWorkflowStep(e,t){const n=Cp.value;if(!n)return;const r=t??n.current_step;if(n.steps[r],Tp(r,e?"completed":"failed"),this._events.emit("workflow:step:complete",{workflow:Cp.value,step:Cp.value.steps[r],success:e}),!e)return;const i=zp();if(!i)return this._events.emit("workflow:complete",Cp.value),void Rp();this._events.emit("workflow:step:active",{workflow:Cp.value,step:i}),i.auto_run&&this._executeWorkflowStep(i)}skipWorkflowStep(e){const t=Cp.value;if(!t)return;const n=e??t.current_step;t.steps[n],Tp(n,"skipped"),this._events.emit("workflow:step:skip",{workflow:Cp.value,step:Cp.value.steps[n]});const r=zp();if(!r)return this._events.emit("workflow:complete",Cp.value),void Rp();this._events.emit("workflow:step:active",{workflow:Cp.value,step:r}),r.auto_run&&this._executeWorkflowStep(r)}cancelWorkflow(){const e=Cp.value;e&&(this._events.emit("workflow:cancel",e),function(){if(!Cp.value)return null;const e=Cp.value;Cp.value=null}())}_executeWorkflowStep(e){Tp(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)}async sendToolResult(e,t,n){this._api?(p.log(`[Pillar] Sending tool result for "${e}" (tool_call_id: ${n}):`,t),await this._api.mcp.sendToolResult(e,t,n),this._events.emit("tool:result",{toolName:e,result:t,toolCallId:n}),this._events.emit("action:result",{actionName:e,result:t,toolCallId:n})):p.warn("[Pillar] SDK not initialized, cannot send tool result")}async sendActionResult(e,t,n){return this.sendToolResult(e,t,n)}async executeQueryTool(e,t={},n){const r=performance.now(),i=Nr().startSpan("query_tool.execute",{attributes:{"query_tool.name":e}});if(!e||"string"!=typeof e||""===e.trim())return p.error("[Pillar] executeQueryTool called with missing or invalid toolName:",e),i.setStatus({code:lt.ERROR,message:"invalid toolName"}),void i.end();if(p.log(`[Pillar] Starting query tool "${e}"`,t),n?.properties){const r=this._validateQueryParams(t,n);if(r)return p.error(`[Pillar] Query param validation failed: ${r}`),void await this.sendToolResult(e,{success:!1,error:r})}const a=this._definedTools.get(e),l=a?.execute,s=Dp(e)?Op(e):void 0;this._registeredTools.get(e);const c=s?.handler,d=this._taskHandlers.get(e),u=this._taskHandlers.get("query"),h=l||c||d||u;if(!h)return p.error(`[Pillar] No handler registered for query tool "${e}". Register one with: pillar.onTask('${e}', async (data) => { ... return result; })`),void await this.sendToolResult(e,{error:`No handler registered for tool "${e}"`,success:!1});o.add({event:"handler:execute",data:{tool:e,type:"query",params:t},source:"handler",level:"info"});try{const n=performance.now(),a=await Promise.resolve(h(t)),l=Math.round(performance.now()-n);if(p.log(`[Pillar] Query tool "${e}" handler completed in ${l}ms`,a),void 0!==a){o.add({event:"handler:complete",data:{tool:e,duration:l,success:!0,returnsData:!0},source:"handler",level:"info"});const t=rs(a);await this.sendToolResult(e,t);const n=Math.round(performance.now()-r);i.setAttribute("query_tool.duration_ms",n),i.setAttribute("query_tool.success",!0),i.end(),p.log(`[Pillar] Query tool "${e}" total time: ${n}ms`)}else o.add({event:"handler:complete",data:{tool:e,duration:l,success:!1,error:"returned undefined"},source:"handler",level:"warn"}),p.warn(`[Pillar] Query tool "${e}" returned undefined. Make sure your handler returns data for the agent.`),i.setAttribute("query_tool.success",!1),i.end(),await this.sendToolResult(e,{error:"Handler returned undefined",success:!1})}catch(t){const n=Math.round(performance.now()-r);i.setStatus({code:lt.ERROR,message:t.message}),i.end(),o.add({event:"handler:error",data:{tool:e,duration:n,error:t instanceof Error?t.message:String(t)},source:"handler",level:"error"}),p.error(`[Pillar] Error executing query tool "${e}" after ${n}ms:`,t),await this.sendToolResult(e,{error:t instanceof Error?t.message:String(t),success:!1})}}async executeQueryAction(e,t={},n){return this.executeQueryTool(e,t,n)}_validateQueryParams(e,t){const n=t.properties||{},r=t.required||[],i=Object.keys(n),a=r.filter(t=>!(t in e));if(a.length>0)return`Missing required parameters: ${a.join(", ")}. Expected: ${i.join(", ")}`;const l=Object.keys(e).filter(e=>!(e in n));return l.length>0?`Unknown parameters: ${l.join(", ")}. Expected: ${i.join(", ")}`:null}async _init(e){if("initializing"===this._state&&this._initPromise)return p.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):p.log("[Pillar] Already initialized")}async _doInit(e){try{e.debug&&(t(!0),o.add({event:"sdk:init:start",data:{productKey:e.productKey,debug:!0},source:"sdk",level:"info"})),await new Promise(e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e(),{once:!0}):e()});const r=Xp(e),i=new Wr(r),a=await i.fetchEmbedConfig().catch(e=>(p.warn("[Pillar] Failed to fetch server config, using local config only:",e),null));if(!1===a?.security?.originAllowed)throw new Error("[Pillar] This domain is not authorized to use this product. Add it to your allowed domains in the Pillar dashboard.");!function(e,t){if(!t)return;const n=[];e.assistantDisplayName&&t.assistantDisplayName&&e.assistantDisplayName!==t.assistantDisplayName&&n.push(`assistantDisplayName: local="${e.assistantDisplayName}" vs server="${t.assistantDisplayName}"`),e.inputPlaceholder&&t.inputPlaceholder&&e.inputPlaceholder!==t.inputPlaceholder&&n.push(`inputPlaceholder: local="${e.inputPlaceholder}" vs server="${t.inputPlaceholder}"`),e.welcomeMessage&&t.welcomeMessage&&e.welcomeMessage!==t.welcomeMessage&&n.push(`welcomeMessage: local="${e.welcomeMessage}" vs server="${t.welcomeMessage}"`);const r=e.theme?.colors?.primary,i=t.theme?.colors?.primary;r&&i&&r!==i&&n.push(`theme.colors.primary: local="${r}" vs server="${i}"`),n.length>0&&console.warn(`[Pillar] Config mismatch detected (local config will take precedence):\n - ${n.join("\n - ")}`)}(e,a);const l=function(e,t){if(!t)return e;const n={...e};return t.panel&&(n.panel={...t.panel,...e.panel}),t.theme?.colors?.primary&&(n.theme={...n.theme,colors:{primary:e.theme?.colors?.primary??t.theme.colors.primary,...e.theme?.colors}}),t.assistantDisplayName&&!e.assistantDisplayName&&(n.assistantDisplayName=t.assistantDisplayName),t.inputPlaceholder&&!e.inputPlaceholder&&(n.inputPlaceholder=t.inputPlaceholder),t.welcomeMessage&&!e.welcomeMessage&&(n.welcomeMessage=t.welcomeMessage),n}(e,a);this._config=Xp(l),this._config.platform&&this._config.version&&Mp(this._config.platform,this._config.version),this._api=new Wr(this._config);const s=this._getStoredExternalUserId();s&&(this._externalUserId=s,this._api.setExternalUserId(s),p.log("[Pillar] Restored external user ID from localStorage")),p.configure(this._api.mcp,{forwardToServer:!0}),this._config.debug&&this._setupDebugEventCapture(),this._config.tracing&&(!function(e,t={}){if(jr)return Hr;const n=new Dr({url:`${e}/mcp/telemetry/v1/traces`,headers:{}}),r=An({"service.name":"pillar-sdk-browser",...t});jr=new ir({resource:r,spanProcessors:[new Vn(n,{maxQueueSize:100,maxExportBatchSize:30,scheduledDelayMillis:5e3})]}),jr.register({propagator:new sn}),Hr=St.getTracer("pillar-sdk","0.1.0")}(this._config.apiBaseUrl,{"pillar.product_key":this._config.productKey,"pillar.platform":this._config.platform||"web"}),p.log("[Pillar] OpenTelemetry tracing enabled")),this._rootContainer=this._createRootContainer(),n=this._config.mobileTrigger.breakpoint,la.value=n,(e=>{oa.value=e})(this._config.panel.fullWidthBreakpoint),(()=>{if("undefined"==typeof window)return;ca?.();let e=null;const t=()=>{null===e&&(e=requestAnimationFrame(()=>{e=null,sa.value=window.innerWidth}))};sa.value=window.innerWidth,window.addEventListener("resize",t),ca=()=>{null!==e&&cancelAnimationFrame(e),window.removeEventListener("resize",t)}})(),this._config.panel.enabled&&(this._panel=new mp(this._config,this._api,this._events,this._rootContainer),await this._panel.init()),this._config.edgeTrigger.enabled&&(this._edgeTrigger=new ya(this._config,this._events,()=>this.toggle(),this._rootContainer),this._edgeTrigger.init()),this._config.mobileTrigger.enabled&&(this._mobileTrigger=new Ca(this._config,this._events,()=>this.toggle(),this._rootContainer),this._mobileTrigger.init()),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new _p(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),this._state="ready",this._events.emit("ready"),this._config.onReady?.(),p.log("[Pillar] SDK initialized successfully"),this._config.debug&&this._mountDebugPanel(),this._routeObserver=new Vp({debounceMs:this._config.suggestions.debounceMs}),this._routeObserver.onRouteChange(e=>{this._syncCurrentPage(e),this._applyRouteExclusion(e.pathname),this._config?.suggestions.enabled&&this._handleRouteChange(e)}),this._routeObserver.start();const c=this._routeObserver.getCurrentRoute();this._syncCurrentPage(c),this._applyRouteExclusion(c.pathname),this._config.suggestions.enabled&&this._initSuggestions().catch(e=>{p.warn("[Pillar] Background suggestions init failed:",e)}),await this._recoverSession(),this._config.urlParams.enabled&&await this._handleUrlParams(),this._config.panel.initialOpen&&!Yi.value&&(this.open(),p.log("[Pillar] Panel auto-opened via initialOpen config")),await this._restoreConversation()}catch(e){this._state="error";const t=e instanceof Error?e:new Error(String(e));throw this._events.emit("error",t),this._config?.onError?.(t),p.error("[Pillar] Failed to initialize:",e),e}var n}async _recoverSession(){if(!this._config||!this._api)return void p.warn("[Pillar] _recoverSession skipped: config or api not available");const e=this._config.productKey;p.log("[Pillar] Checking for saved session hint with siteId:",e);const{loadActiveSession:t,clearActiveSession:n}=await Promise.resolve().then(function(){return ns}),{setInterruptedSession:r,setConversationId:i}=await Promise.resolve().then(function(){return lo}),a=t(e);if(a){p.log("[Pillar] Found saved session hint, checking with server...");try{const t=await this._api.mcp.getConversationStatus(a.conversationId);if(!t||!t.resumable)return p.log("[Pillar] Session is no longer resumable, clearing hint"),void n(e);p.log("[Pillar] Session is resumable, setting up resume state"),i(a.conversationId),r({conversationId:a.conversationId,userMessage:t.user_message??"",partialResponse:t.partial_response??"",displayTrace:t.display_trace??[],elapsedMs:t.elapsed_ms??0}),p.log("[Pillar] Resume state set up successfully")}catch(t){p.warn("[Pillar] Failed to check session status:",t),n(e)}}else p.log("[Pillar] No saved session found for siteId:",e)}async _restoreConversation(){if(!this._api)return;const{getStoredConversationId:e,messages:t,loadConversation:n,isLoadingHistory:r,interruptedSession:i,setInterruptedSession:a}=await Promise.resolve().then(function(){return lo}),{navigate:l,currentView:o}=await Promise.resolve().then(function(){return bo}),s=e();if(s&&!(t.value.length>0)){p.log("[Pillar] Restoring conversation from localStorage:",s);try{r.value=!0,"chat"!==o.value.type&&l("chat");const e=await this._api.getConversation(s);if(e&&e.messages.length>0){let t=e.messages;const l=t[t.length-1],o="assistant"===l.role&&!l.content?.trim();if(o&&(p.log("[Pillar] Stripped trailing empty assistant message from restored conversation"),t=t.slice(0,-1)),t.length>0?n(e.id,t):r.value=!1,o&&!i.value&&this._api.mcp){p.log("[Pillar] Checking conversation status as fallback for resume...");try{const e=await this._api.mcp.getConversationStatus(s);e&&e.resumable&&(p.log("[Pillar] Fallback: session is resumable, setting up resume state"),a({conversationId:s,userMessage:e.user_message??"",partialResponse:e.partial_response??"",displayTrace:e.display_trace??[],elapsedMs:e.elapsed_ms??0}))}catch(e){p.warn("[Pillar] Fallback resume check failed:",e)}}}else r.value=!1}catch(e){p.warn("[Pillar] Failed to restore conversation:",e),r.value=!1}}}async _handleUrlParams(){if(!this._config)return;(function(e=Kp){if("undefined"==typeof window||!window.location)return{};const t=new URLSearchParams(window.location.search),n={};t.has(`${e}open`)&&(n.open=!0);const r=t.get(`${e}article`);r&&(n.article=r);const i=t.get(`${e}article-id`);i&&!n.article&&(n.article=i);const a=t.get(`${e}category`);a&&(n.category=a);const l=t.get(`${e}search`);return l&&(n.search=l),n})(this._config.urlParams.prefix).open&&(this.open(),this._config.urlParams.clearAfterOpen&&function(e=Kp){if("undefined"==typeof window||!window.location||!window.history)return;const t=new URL(window.location.href),n=[`${e}open`,`${e}article`,`${e}article-id`,`${e}category`,`${e}search`];let r=!1;for(const e of n)t.searchParams.has(e)&&(t.searchParams.delete(e),r=!0);r&&window.history.replaceState({},"",t.toString())}(this._config.urlParams.prefix))}_mountDebugPanel(){this._debugPanelContainer=document.createElement("div"),this._debugPanelContainer.id="pillar-debug-panel-root",document.body.appendChild(this._debugPanelContainer),Y(A(La,null),this._debugPanelContainer),o.add({event:"debug:panel:mounted",source:"sdk",level:"info"})}_setupDebugEventCapture(){this._events.on("task:execute",e=>{o.add({event:"task:execute",data:{name:e.name,taskType:e.taskType},source:"sdk",level:"info"})}),this._events.on("task:complete",e=>{o.add({event:"task:complete",data:{name:e.name,success:e.success},source:"sdk",level:e.success?"info":"error"})}),this._events.on("action:result",e=>{o.add({event:"action:result",data:{actionName:e.actionName,hasResult:!!e.result},source:"sdk",level:"info"})}),this._events.on("ready",()=>{o.add({event:"sdk:ready",source:"sdk",level:"info"})}),this._events.on("error",e=>{o.add({event:"sdk:error",data:{message:e.message},source:"sdk",level:"error"})}),p.log("[Pillar] Debug event capture enabled")}_syncCurrentPage(e){this.setContext({currentPage:e.pathname})}_applyRouteExclusion(e){if(!this._config)return;const t=this._config.excludeRoutes.some(t=>e===t||e.startsWith(t+"/"));t!==this._isRouteExcluded&&(this._isRouteExcluded=t,t?(this._panel?.close(),this._edgeTrigger?.hide(),this._mobileTrigger?.hide(),this._textSelectionManager?.destroy(),p.log(`[Pillar] UI hidden — route "${e}" is excluded`)):(this._edgeTrigger?.show(),this._mobileTrigger?.show(),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new _p(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),p.log(`[Pillar] UI restored — route "${e}" is not excluded`)))}async _initSuggestions(){if(this._api&&this._config){p.log("[Pillar] Initializing page-aware suggestions"),Mo(!0);try{const e=await this._api.getSuggestedQuestions();if(p.log(`[Pillar] Fetched ${e.length} suggestions for pool`),this._suggestionPool=e,function(e){Po.value=e}(e),this._routeObserver){const e=this._routeObserver.getCurrentRoute();this._handleRouteChange(e)}Mo(!1)}catch(e){p.error("[Pillar] Failed to initialize suggestions:",e),function(e){zo.value=e,To.value=!1}(e instanceof Error?e.message:String(e)),Mo(!1)}}}_handleRouteChange(e){if(!this._config)return;const{pathname:t,title:n}=e,r=this._config.suggestions.displayLimit;p.log(`[Pillar] Route changed to: ${t}, sorting suggestions`);const i=Io(this._suggestionPool,t,n,r);!function(e,t){Eo.value=e,Ro.value=t}(i,t),this._events.emit("suggestions:updated",{suggestions:i.map(e=>({id:e.id,text:e.text})),route:t}),p.log(`[Pillar] Sorted ${i.length} suggestions for page`)}_destroy(){this._routeObserver?.stop(),this._routeObserver=null,this._suggestionPool=[],Po.value=[],Eo.value=[],To.value=!1,zo.value=null,Ro.value=null,this._textSelectionManager?.destroy(),this._panel?.destroy(),this._edgeTrigger?.destroy(),this._mobileTrigger?.destroy(),this._api?.cancelAllRequests(),this._events.removeAllListeners(),this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=null,this._rootContainer?.remove(),this._rootContainer=null,this._debugPanelContainer&&(Y(null,this._debugPanelContainer),this._debugPanelContainer.remove(),this._debugPanelContainer=null),ma(),fo(),Zl(),wp.value={...xp},kp.value={...yp},Cp.value=null,Pp.value=[],this._context={...xp},this._userProfile={...yp},this._taskHandlers.clear(),this._anyTaskHandler=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._api=null,this._config=null,this._state="uninitialized",p.log("[Pillar] SDK destroyed")}}Zp.version="0.1.34",Zp.instance=null,Zp.EXTERNAL_USER_ID_STORAGE_KEY="pillar:external_user_id";var Yp=Object.freeze({__proto__:null,Pillar:Zp,getApiClient:za});if("undefined"!=typeof window){window.Pillar=Zp;const e=()=>{const e=document.currentScript;e?.dataset.productKey&&Zp.init({productKey:e.dataset.productKey}).catch(p.error)};if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",e);else{const e=document.querySelectorAll("script[data-product-key]");if(e.length>0){const t=e[e.length-1];t.dataset.productKey&&Zp.init({productKey:t.dataset.productKey}).catch(p.error)}}}export{Wr as APIClient,is as DEFAULT_SCAN_OPTIONS,Gp as DEFAULT_SIDEBAR_TABS,u as EventEmitter,ls as INTERACTABLE_ROLES,as as INTERACTABLE_TAGS,Zp as Pillar,os as SKIP_TAGS,qr as actionToTaskButton,vs as buildSelectorFromRef,cs as clearPillarRefs,Np as clearRegistry,Zp as default,Oa as generateContextId,Wp as getActionCount,Bp as getActionDefinition,qp as getActionNames,$p as getClientInfo,Ha as getContextDisplayLabel,Lp as getHandler,Hp as getManifest,Up as getToolCount,Op as getToolDefinition,jp as getToolNames,Fp as hasAction,Dp as hasTool,ja as isDOMSnapshotContext,gs as isDestructiveElement,Da as isHighlightedTextContext,fs as isInteractable,us as isRedacted,bs as isValidPillarRef,ws as scanPageDirect,Mp as setClientInfo,Fr as toolToTaskButton};
1
+ let e=!1;function t(t){e=t,console.log("[Pillar] Debug mode enabled - verbose logging active")}function n(){return e||r()}const r=()=>{if("undefined"!=typeof process&&process.env?.NODE_ENV)return"development"===process.env.NODE_ENV;if("undefined"!=typeof window){const e=window.location?.hostname||"";return"localhost"===e||"127.0.0.1"===e||e.includes(".local")}return!1},i=["[Pillar]","[MCPClient]","[PlanExecutor]"],a=["sdk","handler","network"];class l{constructor(e,t=5e3){this.buffer=[],this.flushTimer=null,this.maxBufferSize=100,this.handleBeforeUnload=()=>{this.flush()},this.mcpClient=e,this.flushIntervalMs=t,this.startFlushTimer(),this.setupUnloadListener()}shouldForward(e){return!!a.includes(e.source)||(!(!e.prefix||!i.some(t=>e.prefix?.startsWith(t)))||"error"===e.level)}bufferEntry(e){const t={level:"info"===e.level?"log":e.level,message:e.prefix?`${e.prefix} ${e.event}`:`[${e.source}] ${e.event}`,data:e.data,timestamp:new Date(e.timestamp).toISOString()};this.buffer.push(t),this.buffer.length>=this.maxBufferSize&&this.flush(),"error"===e.level&&this.flush()}flush(){if(0===this.buffer.length)return;const e=this.buffer.splice(0);this.mcpClient.sendLogBatch(e)}startFlushTimer(){this.flushTimer||(this.flushTimer=setInterval(()=>this.flush(),this.flushIntervalMs))}stopFlushTimer(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}setupUnloadListener(){"undefined"!=typeof window&&window.addEventListener("beforeunload",this.handleBeforeUnload)}removeUnloadListener(){"undefined"!=typeof window&&window.removeEventListener("beforeunload",this.handleBeforeUnload)}destroy(){this.stopFlushTimer(),this.removeUnloadListener(),this.flush(),this.buffer=[]}}const o=new class{constructor(){this.entries=[],this.maxEntries=500,this.listeners=new Set,this.serverForwarder=null,this.forwarderUnsubscribe=null}add(e){const t={...e,timestamp:Date.now()};this.entries.push(t),this.entries.length>this.maxEntries&&(this.entries=this.entries.slice(-this.maxEntries)),this.listeners.forEach(e=>e(this.entries)),n()&&!e.prefix&&this.logToConsole(t),this.serverForwarder?.shouldForward(t)&&this.serverForwarder.bufferEntry(t)}logToConsole(e){const t=`[${new Date(e.timestamp).toISOString().split("T")[1].slice(0,12)}] [${e.source}]`,n=void 0!==e.data?[t,e.event,e.data]:[t,e.event];"error"===e.level?console.error(...n):"warn"===e.level?console.warn(...n):console.log(...n)}enableServerForwarding(e,t){this.disableServerForwarding(),this.serverForwarder=new l(e,t?.flushIntervalMs)}disableServerForwarding(){this.serverForwarder&&(this.serverForwarder.destroy(),this.serverForwarder=null),this.forwarderUnsubscribe&&(this.forwarderUnsubscribe(),this.forwarderUnsubscribe=null)}flush(){this.serverForwarder?.flush()}getEntries(){return[...this.entries]}clear(){this.entries=[],this.listeners.forEach(e=>e(this.entries))}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.disableServerForwarding(),this.entries=[],this.listeners.clear()}};function s(e){if(0===e.length)return{event:""};const t=e[0];let n,r,i=[];"string"==typeof t&&t.startsWith("[")&&t.endsWith("]")&&(n=t,e=e.slice(1));for(const t of e)"string"==typeof t?i.push(t):"object"==typeof t&&null!==t&&(r=t);return{prefix:n,event:i.join(" "),data:r}}function c(e){return e?e.includes("MCPClient")?"network":(e.includes("PlanExecutor"),"sdk"):"sdk"}const p={configure:(e,t)=>{!1!==t?.forwardToServer&&o.enableServerForwarding(e,{flushIntervalMs:t?.flushIntervalMs})},flush:()=>{o.flush()},log:(...e)=>{if(!n())return;const{prefix:t,event:r,data:i}=s(e);console.log(...e),o.add({event:r,data:i,source:c(t),level:"info",prefix:t})},warn:(...e)=>{if(!n())return;const{prefix:t,event:r,data:i}=s(e);console.warn(...e),o.add({event:r,data:i,source:c(t),level:"warn",prefix:t})},error:(...e)=>{const{prefix:t,event:n,data:r}=s(e);console.error(...e),o.add({event:n,data:r,source:c(t),level:"error",prefix:t})},destroy:()=>{o.destroy()}};var d=Object.freeze({__proto__:null,debug:p,debugLog:o,isDebugEnabled:n,setDebugMode:t});class u{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{this.off(e,t)}}off(e,t){const n=this.listeners.get(e);n&&n.delete(t)}emit(e,t){const n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){p.error(`[Pillar] Error in event handler for "${e}":`,t)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}var h,g,f,m,b,v,_,x,y,w,k,S,C,P={},E=[],T=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,z=Array.isArray;function R(e,t){for(var n in t)e[n]=t[n];return e}function I(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function M(e,t,n){var r,i,a,l={};for(a in t)"key"==a?r=t[a]:"ref"==a?i=t[a]:l[a]=t[a];if(arguments.length>2&&(l.children=arguments.length>3?h.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return A(e,l,r,i,null)}function A(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++f:i,__i:-1,__u:0};return null==i&&null!=g.vnode&&g.vnode(a),a}function $(e){return e.children}function L(e,t){this.props=e,this.context=t}function O(e,t){if(null==t)return e.__?O(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?O(e):null}function D(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return D(e)}}function j(e){(!e.__d&&(e.__d=!0)&&b.push(e)&&!H.__r++||v!=g.debounceRendering)&&((v=g.debounceRendering)||_)(H)}function H(){for(var e,t,n,r,i,a,l,o=1;b.length;)b.length>o&&b.sort(x),e=b.shift(),o=b.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,a=[],l=[],t.__P&&((n=R({},r)).__v=r.__v+1,g.vnode&&g.vnode(n),V(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,a,null==i?O(r):i,!!(32&r.__u),l),n.__v=r.__v,n.__.__k[n.__i]=n,G(a,n,l),r.__e=r.__=null,n.__e!=i&&D(n)));H.__r=0}function N(e,t,n,r,i,a,l,o,s,c,p){var d,u,h,g,f,m,b,v=r&&r.__k||E,_=t.length;for(s=function(e,t,n,r,i){var a,l,o,s,c,p=n.length,d=p,u=0;for(e.__k=new Array(i),a=0;a<i;a++)null!=(l=t[a])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[a]=A(null,l,null,null,null):z(l)?l=e.__k[a]=A($,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[a]=A(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!=(c=l.__i=B(l,n,s,d))&&(d--,(o=n[c])&&(o.__u|=2)),null==o||null==o.__v?(-1==c&&(i>p?u--:i<p&&u++),"function"!=typeof l.type&&(l.__u|=4)):c!=s&&(c==s-1?u--:c==s+1?u++:(c>s?u--:u++,l.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<p;a++)null!=(o=n[a])&&!(2&o.__u)&&(o.__e==r&&(r=O(o)),X(o,o));return r}(n,t,v,s,_),d=0;d<_;d++)null!=(h=n.__k[d])&&(u=-1==h.__i?P:v[h.__i]||P,h.__i=d,m=V(e,h,u,i,a,l,o,s,c,p),g=h.__e,h.ref&&u.ref!=h.ref&&(u.ref&&J(u.ref,null,h),p.push(h.ref,h.__c||g,h)),null==f&&null!=g&&(f=g),(b=!!(4&h.__u))||u.__k===h.__k?s=U(h,s,e,b):"function"==typeof h.type&&void 0!==m?s=m:g&&(s=g.nextSibling),h.__u&=-7);return n.__e=f,s}function U(e,t,n,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,t=U(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=O(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function B(e,t,n,r){var i,a,l,o=e.key,s=e.type,c=t[n],p=null!=c&&!(2&c.__u);if(null===c&&null==o||p&&o==c.key&&s==c.type)return n;if(r>(p?1:0))for(i=n-1,a=n+1;i>=0||a<t.length;)if(null!=(c=t[l=i>=0?i--:a++])&&!(2&c.__u)&&o==c.key&&s==c.type)return l;return-1}function F(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||T.test(t)?n:n+"px"}function q(e,t,n,r,i){var a,l;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||F(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||F(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])a=t!=(t=t.replace(y,"$1")),l=t.toLowerCase(),t=l in e||"onFocusOut"==t||"onFocusIn"==t?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=w,e.addEventListener(t,a?S:k,a)):e.removeEventListener(t,a?S:k,a);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function W(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=w++;else if(t.t<n.u)return;return n(g.event?g.event(t):t)}}}function V(e,t,n,r,i,a,l,o,s,c){var p,d,u,f,m,b,v,_,x,y,w,k,S,C,E,T,M,A=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(s=!!(32&n.__u),a=[o=t.__e=n.__e]),(p=g.__b)&&p(t);e:if("function"==typeof A)try{if(_=t.props,x="prototype"in A&&A.prototype.render,y=(p=A.contextType)&&r[p.__c],w=p?y?y.props.value:p.__:r,n.__c?v=(d=t.__c=n.__c).__=d.__E:(x?t.__c=d=new A(_,w):(t.__c=d=new L(_,w),d.constructor=A,d.render=Z),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!=A.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=R({},d.__s)),R(d.__s,A.getDerivedStateFromProps(_,d.__s))),f=d.props,m=d.state,d.__v=t,u)x&&null==A.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),x&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(x&&null==A.getDerivedStateFromProps&&_!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(_,w),t.__v==n.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(_,d.__s,w)){for(t.__v!=n.__v&&(d.props=_,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[],d.__h.length&&l.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(_,d.__s,w),x&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,m,b)})}if(d.context=w,d.props=_,d.__P=e,d.__e=!1,S=g.__r,C=0,x){for(d.state=d.__s,d.__d=!1,S&&S(t),p=d.render(d.props,d.state,d.context),E=0;E<d._sb.length;E++)d.__h.push(d._sb[E]);d._sb=[]}else do{d.__d=!1,S&&S(t),p=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=R(R({},r),d.getChildContext())),x&&!u&&null!=d.getSnapshotBeforeUpdate&&(b=d.getSnapshotBeforeUpdate(f,m)),T=p,null!=p&&p.type===$&&null==p.key&&(T=Q(p.props.children)),o=N(e,z(T)?T:[T],t,n,r,i,a,l,o,s,c),d.base=t.__e,t.__u&=-161,d.__h.length&&l.push(d),v&&(d.__E=d.__=null)}catch(e){if(t.__v=null,s||null!=a)if(e.then){for(t.__u|=s?160:128;o&&8==o.nodeType&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,t.__e=o}else{for(M=a.length;M--;)I(a[M]);K(t)}else t.__e=n.__e,t.__k=n.__k,e.then||K(t);g.__e(e,t,n)}else null==a&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):o=t.__e=function(e,t,n,r,i,a,l,o,s){var c,p,d,u,f,m,b,v=n.props||P,_=t.props,x=t.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(c=0;c<a.length;c++)if((f=a[c])&&"setAttribute"in f==!!x&&(x?f.localName==x:3==f.nodeType)){e=f,a[c]=null;break}if(null==e){if(null==x)return document.createTextNode(_);e=document.createElementNS(i,x,_.is&&_),o&&(g.__m&&g.__m(t,a),o=!1),a=null}if(null==x)v===_||o&&e.data==_||(e.data=_);else{if(a=a&&h.call(e.childNodes),!o&&null!=a)for(v={},c=0;c<e.attributes.length;c++)v[(f=e.attributes[c]).name]=f.value;for(c in v)if(f=v[c],"children"==c);else if("dangerouslySetInnerHTML"==c)d=f;else if(!(c in _)){if("value"==c&&"defaultValue"in _||"checked"==c&&"defaultChecked"in _)continue;q(e,c,null,f,i)}for(c in _)f=_[c],"children"==c?u=f:"dangerouslySetInnerHTML"==c?p=f:"value"==c?m=f:"checked"==c?b=f:o&&"function"!=typeof f||v[c]===f||q(e,c,f,v[c],i);if(p)o||d&&(p.__html==d.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(d&&(e.innerHTML=""),N("template"==t.type?e.content:e,z(u)?u:[u],t,n,r,"foreignObject"==x?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:n.__k&&O(n,0),o,s),null!=a)for(c=a.length;c--;)I(a[c]);o||(c="value","progress"==x&&null==m?e.removeAttribute("value"):null!=m&&(m!==e[c]||"progress"==x&&!m||"option"==x&&m!=v[c])&&q(e,c,m,v[c],i),c="checked",null!=b&&b!=e[c]&&q(e,c,b,v[c],i))}return e}(n.__e,t,n,r,i,a,l,s,c);return(p=g.diffed)&&p(t),128&t.__u?void 0:o}function K(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(K)}function G(e,t,n){for(var r=0;r<n.length;r++)J(n[r],n[++r],n[++r]);g.__c&&g.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){g.__e(e,t.__v)}})}function Q(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:z(e)?e.map(Q):R({},e)}function J(e,t,n){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==t||(e.__u=e(t))}else e.current=t}catch(e){g.__e(e,n)}}function X(e,t,n){var r,i;if(g.unmount&&g.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||J(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){g.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&X(r[i],t,n||"function"!=typeof e.type);n||I(e.__e),e.__c=e.__=e.__e=void 0}function Z(e,t,n){return this.constructor(e,n)}function Y(e,t,n){var r,i,a;t==document&&(t=document.documentElement),g.__&&g.__(e,t),r=!1?null:t.__k,i=[],a=[],V(t,e=t.__k=M($,null,[e]),r||P,P,t.namespaceURI,r?null:t.firstChild?h.call(t.childNodes):null,i,r?r.__e:t.firstChild,false,a),G(i,e,a)}function ee(e,t){return e instanceof TypeError||(!!(e instanceof Error&&e.message.includes("Failed to fetch"))||!!(t&&t.status>=500))}async function te(e,t={}){const{maxRetries:n=0,baseDelayMs:r=100,retryOn:i=ee,onRetry:a,...l}=t;let o;for(let t=0;t<=n;t++){if(t>0){const e=r*Math.pow(2,t-1);a?.(t,e,o),await new Promise(t=>setTimeout(t,e))}try{const r=await fetch(e,l);if(!r.ok&&t<n&&i(null,r)){o=new Error(`HTTP ${r.status}`);continue}return r}catch(e){if(o=e,t<n&&i(e))continue;throw e}}throw o}h=E.slice,g={__e:function(e,t,n,r){for(var i,a,l;t=t.__;)if((i=t.__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(t){e=t}throw e}},f=0,m=function(e){return null!=e&&void 0===e.constructor},L.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=R({},this.state),"function"==typeof e&&(e=e(R({},n),this.props)),e&&R(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),j(this))},L.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),j(this))},L.prototype.render=$,b=[],_="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,x=function(e,t){return e.__v.__b-t.__v.__b},H.__r=0,y=/(PointerCapture)$|Capture$/i,w=0,k=W(!1),S=W(!0),C=0;var ne="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},re="1.9.0",ie=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;var ae=function(e){var t=new Set([e]),n=new Set,r=e.match(ie);if(!r)return function(){return!1};var i=+r[1],a=+r[2],l=+r[3];if(null!=r[4])return function(t){return t===e};function o(e){return n.add(e),!1}function s(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;var r=e.match(ie);if(!r)return o(e);var c=+r[1],p=+r[2],d=+r[3];return null!=r[4]||i!==c?o(e):0===i?a===p&&l<=d?s(e):o(e):a<=p?s(e):o(e)}}(re),le=re.split(".")[0],oe=Symbol.for("opentelemetry.js.api."+le),se=ne;function ce(e,t,n,r){var i;void 0===r&&(r=!1);var a=se[oe]=null!==(i=se[oe])&&void 0!==i?i:{version:re};if(!r&&a[e]){var l=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return n.error(l.stack||l.message),!1}if(a.version!==re){l=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+e+" does not match previously registered API v"+re);return n.error(l.stack||l.message),!1}return a[e]=t,n.debug("@opentelemetry/api: Registered a global for "+e+" v"+re+"."),!0}function pe(e){var t,n,r=null===(t=se[oe])||void 0===t?void 0:t.version;if(r&&ae(r))return null===(n=se[oe])||void 0===n?void 0:n[e]}function de(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+re+".");var n=se[oe];n&&delete n[e]}var ue,he=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},ge=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},fe=function(){function e(e){this._namespace=e.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("debug",this._namespace,e)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("error",this._namespace,e)},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("info",this._namespace,e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("warn",this._namespace,e)},e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return me("verbose",this._namespace,e)},e}();function me(e,t,n){var r=pe("diag");if(r)return n.unshift(t),r[e].apply(r,ge([],he(n),!1))}!function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"}(ue||(ue={}));var be=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},ve=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},_e=function(){function e(){function e(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=pe("diag");if(r)return r[e].apply(r,ve([],be(t),!1))}}var t=this;t.setLogger=function(e,n){var r,i,a;if(void 0===n&&(n={logLevel:ue.INFO}),e===t){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error(null!==(r=l.stack)&&void 0!==r?r:l.message),!1}"number"==typeof n&&(n={logLevel:n});var o=pe("diag"),s=function(e,t){function n(n,r){var i=t[n];return"function"==typeof i&&e>=r?i.bind(t):function(){}}return e<ue.NONE?e=ue.NONE:e>ue.ALL&&(e=ue.ALL),t=t||{},{error:n("error",ue.ERROR),warn:n("warn",ue.WARN),info:n("info",ue.INFO),debug:n("debug",ue.DEBUG),verbose:n("verbose",ue.VERBOSE)}}(null!==(i=n.logLevel)&&void 0!==i?i:ue.INFO,e);if(o&&!n.suppressOverrideMessage){var c=null!==(a=(new Error).stack)&&void 0!==a?a:"<failed to generate stacktrace>";o.warn("Current logger will be overwritten from "+c),s.warn("Current logger will overwrite one already registered from "+c)}return ce("diag",s,t,!0)},t.disable=function(){de("diag",t)},t.createComponentLogger=function(e){return new fe(e)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}(),xe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},ye=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},we=function(){function e(e){this._entries=e?new Map(e):new Map}return e.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},e.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=xe(e,2);return[t[0],t[1]]})},e.prototype.setEntry=function(t,n){var r=new e(this._entries);return r._entries.set(t,n),r},e.prototype.removeEntry=function(t){var n=new e(this._entries);return n._entries.delete(t),n},e.prototype.removeEntries=function(){for(var t,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=new e(this._entries);try{for(var l=ye(r),o=l.next();!o.done;o=l.next()){var s=o.value;a._entries.delete(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return a},e.prototype.clear=function(){return new e},e}(),ke=Symbol("BaggageEntryMetadata"),Se=_e.instance();function Ce(e){return void 0===e&&(e={}),new we(new Map(Object.entries(e)))}function Pe(e){return Symbol.for(e)}var Ee,Te=function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(e){return n._currentContext.get(e)},n.setValue=function(t,r){var i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=function(t){var r=new e(n._currentContext);return r._currentContext.delete(t),r}},ze=new Te,Re={get:function(e,t){if(null!=e)return e[t]},keys:function(e){return null==e?[]:Object.keys(e)}},Ie={set:function(e,t,n){null!=e&&(e[t]=n)}},Me=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},Ae=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},$e=function(){function e(){}return e.prototype.active=function(){return ze},e.prototype.with=function(e,t,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return t.call.apply(t,Ae([n],Me(r),!1))},e.prototype.bind=function(e,t){return t},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),Le=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return l},Oe=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},De="context",je=new $e,He=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(e){return ce(De,e,_e.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(e,t,n){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,Oe([e,t,n],Le(i),!1))},e.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},e.prototype._getContextManager=function(){return pe(De)||je},e.prototype.disable=function(){this._getContextManager().disable(),de(De,_e.instance())},e}();!function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"}(Ee||(Ee={}));var Ne="0000000000000000",Ue="00000000000000000000000000000000",Be={traceId:Ue,spanId:Ne,traceFlags:Ee.NONE},Fe=function(){function e(e){void 0===e&&(e=Be),this._spanContext=e}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(e,t){return this},e.prototype.setAttributes=function(e){return this},e.prototype.addEvent=function(e,t){return this},e.prototype.addLink=function(e){return this},e.prototype.addLinks=function(e){return this},e.prototype.setStatus=function(e){return this},e.prototype.updateName=function(e){return this},e.prototype.end=function(e){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(e,t){},e}(),qe=Pe("OpenTelemetry Context Key SPAN");function We(e){return e.getValue(qe)||void 0}function Ve(){return We(He.getInstance().active())}function Ke(e,t){return e.setValue(qe,t)}function Ge(e){return e.deleteValue(qe)}function Qe(e,t){return Ke(e,new Fe(t))}function Je(e){var t;return null===(t=We(e))||void 0===t?void 0:t.spanContext()}var Xe=/^([0-9a-f]{32})$/i,Ze=/^[0-9a-f]{16}$/i;function Ye(e){return Xe.test(e)&&e!==Ue}function et(e){return Ye(e.traceId)&&(t=e.spanId,Ze.test(t)&&t!==Ne);var t}function tt(e){return new Fe(e)}var nt=He.getInstance(),rt=function(){function e(){}return e.prototype.startSpan=function(e,t,n){if(void 0===n&&(n=nt.active()),Boolean(null==t?void 0:t.root))return new Fe;var r,i=n&&Je(n);return"object"==typeof(r=i)&&"string"==typeof r.spanId&&"string"==typeof r.traceId&&"number"==typeof r.traceFlags&&et(i)?new Fe(i):new Fe},e.prototype.startActiveSpan=function(e,t,n,r){var i,a,l;if(!(arguments.length<2)){2===arguments.length?l=t:3===arguments.length?(i=t,l=n):(i=t,a=n,l=r);var o=null!=a?a:nt.active(),s=this.startSpan(e,i,o),c=Ke(o,s);return nt.with(c,l,void 0,s)}},e}();var it,at,lt,ot=new rt,st=function(){function e(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}return e.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},e.prototype.startActiveSpan=function(e,t,n,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):ot},e}(),ct=new(function(){function e(){}return e.prototype.getTracer=function(e,t,n){return new rt},e}()),pt=function(){function e(){}return e.prototype.getTracer=function(e,t,n){var r;return null!==(r=this.getDelegateTracer(e,t,n))&&void 0!==r?r:new st(this,e,t,n)},e.prototype.getDelegate=function(){var e;return null!==(e=this._delegate)&&void 0!==e?e:ct},e.prototype.setDelegate=function(e){this._delegate=e},e.prototype.getDelegateTracer=function(e,t,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getTracer(e,t,n)},e}();!function(e){e[e.NOT_RECORD=0]="NOT_RECORD",e[e.RECORD=1]="RECORD",e[e.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(it||(it={})),function(e){e[e.INTERNAL=0]="INTERNAL",e[e.SERVER=1]="SERVER",e[e.CLIENT=2]="CLIENT",e[e.PRODUCER=3]="PRODUCER",e[e.CONSUMER=4]="CONSUMER"}(at||(at={})),function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"}(lt||(lt={}));var dt=He.getInstance(),ut=_e.instance(),ht=function(){function e(){}return e.prototype.inject=function(e,t){},e.prototype.extract=function(e,t){return e},e.prototype.fields=function(){return[]},e}(),gt=Pe("OpenTelemetry Baggage Key");function ft(e){return e.getValue(gt)||void 0}function mt(){return ft(He.getInstance().active())}function bt(e,t){return e.setValue(gt,t)}function vt(e){return e.deleteValue(gt)}var _t="propagation",xt=new ht,yt=function(){function e(){this.createBaggage=Ce,this.getBaggage=ft,this.getActiveBaggage=mt,this.setBaggage=bt,this.deleteBaggage=vt}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalPropagator=function(e){return ce(_t,e,_e.instance())},e.prototype.inject=function(e,t,n){return void 0===n&&(n=Ie),this._getGlobalPropagator().inject(e,t,n)},e.prototype.extract=function(e,t,n){return void 0===n&&(n=Re),this._getGlobalPropagator().extract(e,t,n)},e.prototype.fields=function(){return this._getGlobalPropagator().fields()},e.prototype.disable=function(){de(_t,_e.instance())},e.prototype._getGlobalPropagator=function(){return pe(_t)||xt},e}(),wt=yt.getInstance(),kt="trace",St=function(){function e(){this._proxyTracerProvider=new pt,this.wrapSpanContext=tt,this.isSpanContextValid=et,this.deleteSpan=Ge,this.getSpan=We,this.getActiveSpan=Ve,this.getSpanContext=Je,this.setSpan=Ke,this.setSpanContext=Qe}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(e){var t=ce(kt,this._proxyTracerProvider,_e.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},e.prototype.getTracerProvider=function(){return pe(kt)||this._proxyTracerProvider},e.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},e.prototype.disable=function(){de(kt,_e.instance()),this._proxyTracerProvider=new pt},e}().getInstance();const Ct=Pe("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Pt(e){return!0===e.getValue(Ct)}const Et="baggage";function Tt(e){if(!e)return;const t=e.indexOf(";"),n=-1===t?e:e.substring(0,t),r=n.indexOf("=");if(r<=0)return;const i=n.substring(0,r).trim(),a=n.substring(r+1).trim();if(!i||!a)return;let l,o,s;try{l=decodeURIComponent(i),o=decodeURIComponent(a)}catch{return}if(-1!==t&&t<e.length-1){const n=e.substring(t+1);"string"!=typeof(c=n)&&(Se.error("Cannot create baggage metadata from unknown type: "+typeof c),c=""),s={__TYPE__:ke,toString:function(){return c}}}var c;return{key:l,value:o,metadata:s}}class zt{inject(e,t,n){const r=wt.getBaggage(e);if(!r||Pt(e))return;const i=function(e){return e.getAllEntries().map(([e,t])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(t.value)}`;return void 0!==t.metadata&&(n+=";"+t.metadata.toString()),n})}(r).filter(e=>e.length<=4096).slice(0,180),a=function(e){return e.reduce((e,t)=>{const n=`${e}${""!==e?",":""}${t}`;return n.length>8192?e:n},"")}(i);a.length>0&&n.set(t,Et,a)}extract(e,t,n){const r=n.get(t,Et),i=Array.isArray(r)?r.join(","):r;if(!i)return e;const a={};if(0===i.length)return e;return i.split(",").forEach(e=>{const t=Tt(e);if(t){const e={value:t.value};t.metadata&&(e.metadata=t.metadata),a[t.key]=e}}),0===Object.entries(a).length?e:wt.setBaggage(e,wt.createBaggage(a))}fields(){return[Et]}}function Rt(e){const t={};if("object"!=typeof e||null==e)return t;for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!It(n)){ut.warn(`Invalid attribute key: ${n}`);continue}const r=e[n];Mt(r)?Array.isArray(r)?t[n]=r.slice():t[n]=r:ut.warn(`Invalid attribute value set for key: ${n}`)}return t}function It(e){return"string"==typeof e&&""!==e}function Mt(e){return null==e||(Array.isArray(e)?function(e){let t;for(const n of e){if(null==n)continue;const e=typeof n;if(e!==t){if(!t){if(At(e)){t=e;continue}return!1}return!1}}return!0}(e):At(typeof e))}function At(e){switch(e){case"number":case"boolean":case"string":return!0}return!1}let $t=e=>{ut.error(function(e){return"string"==typeof e?e:JSON.stringify(function(e){const t={};let n=e;for(;null!==n;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;const r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}(e))}(e))};function Lt(e){try{$t(e)}catch{}}const Ot="exception.message",Dt="exception.type",jt="service.name",Ht="telemetry.sdk.language",Nt="telemetry.sdk.name",Ut="telemetry.sdk.version",Bt="process.runtime.name",Ft={[Nt]:"opentelemetry",[Bt]:"browser",[Ht]:"webjs",[Ut]:"2.5.1"},qt=performance,Wt=Math.pow(10,6),Vt=Math.pow(10,9);function Kt(e){const t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*Wt)]}function Gt(e){return Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Qt(e){return Gt(e)||"number"==typeof e||e instanceof Date}function Jt(e,t){const n=[e[0]+t[0],e[1]+t[1]];return n[1]>=Vt&&(n[1]-=Vt,n[0]+=1),n}var Xt;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.FAILED=1]="FAILED"}(Xt||(Xt={}));class Zt{_propagators;_fields;constructor(e={}){this._propagators=e.propagators??[],this._fields=Array.from(new Set(this._propagators.map(e=>"function"==typeof e.fields?e.fields():[]).reduce((e,t)=>e.concat(t),[])))}inject(e,t,n){for(const r of this._propagators)try{r.inject(e,t,n)}catch(e){ut.warn(`Failed to inject with ${r.constructor.name}. Err: ${e.message}`)}}extract(e,t,n){return this._propagators.reduce((e,r)=>{try{return r.extract(e,t,n)}catch(e){ut.warn(`Failed to extract with ${r.constructor.name}. Err: ${e.message}`)}return e},e)}fields(){return this._fields.slice()}}const Yt="[_0-9a-z-*/]",en=new RegExp(`^(?:${`[a-z]${Yt}{0,255}`}|${`[a-z0-9]${Yt}{0,240}@[a-z]${Yt}{0,13}`})$`),tn=/^[ -~]{0,255}[!-~]$/,nn=/,|=/;class rn{_internalState=new Map;constructor(e){e&&this._parse(e)}set(e,t){const n=this._clone();return n._internalState.has(e)&&n._internalState.delete(e),n._internalState.set(e,t),n}unset(e){const t=this._clone();return t._internalState.delete(e),t}get(e){return this._internalState.get(e)}serialize(){return this._keys().reduce((e,t)=>(e.push(t+"="+this.get(t)),e),[]).join(",")}_parse(e){e.length>512||(this._internalState=e.split(",").reverse().reduce((e,t)=>{const n=t.trim(),r=n.indexOf("=");if(-1!==r){const i=n.slice(0,r),a=n.slice(r+1,t.length);(function(e){return en.test(e)})(i)&&function(e){return tn.test(e)&&!nn.test(e)}(a)&&e.set(i,a)}return e},new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){const e=new rn;return e._internalState=new Map(this._internalState),e}}const an="traceparent",ln="tracestate",on=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");class sn{inject(e,t,n){const r=St.getSpanContext(e);if(!r||Pt(e)||!et(r))return;const i=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||Ee.NONE).toString(16)}`;n.set(t,an,i),r.traceState&&n.set(t,ln,r.traceState.serialize())}extract(e,t,n){const r=n.get(t,an);if(!r)return e;const i=Array.isArray(r)?r[0]:r;if("string"!=typeof i)return e;const a=function(e){const t=on.exec(e);return t?"00"===t[1]&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}:null}(i);if(!a)return e;a.isRemote=!0;const l=n.get(t,ln);if(l){const e=Array.isArray(l)?l.join(","):l;a.traceState=new rn("string"==typeof e?e:void 0)}return St.setSpanContext(e,a)}fields(){return[an,ln]}}const cn="[object Null]",pn="[object Undefined]",dn=Function.prototype.toString,un=dn.call(Object),hn=Object.getPrototypeOf,gn=Object.prototype,fn=gn.hasOwnProperty,mn=Symbol?Symbol.toStringTag:void 0,bn=gn.toString;function vn(e){if(!function(e){return null!=e&&"object"==typeof e}(e)||"[object Object]"!==function(e){if(null==e)return void 0===e?pn:cn;return mn&&mn in Object(e)?function(e){const t=fn.call(e,mn),n=e[mn];let r=!1;try{e[mn]=void 0,r=!0}catch{}const i=bn.call(e);r&&(t?e[mn]=n:delete e[mn]);return i}(e):function(e){return bn.call(e)}(e)}(e))return!1;const t=hn(e);if(null===t)return!0;const n=fn.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&dn.call(n)===un}function _n(e){return wn(e)?e.slice():e}function xn(e,t,n=0,r){let i;if(!(n>20)){if(n++,Cn(e)||Cn(t)||kn(t))i=_n(t);else if(wn(e)){if(i=e.slice(),wn(t))for(let e=0,n=t.length;e<n;e++)i.push(_n(t[e]));else if(Sn(t)){const e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){const r=e[n];i[r]=_n(t[r])}}}else if(Sn(e))if(Sn(t)){if(!function(e,t){if(!vn(e)||!vn(t))return!1;return!0}(e,t))return t;i=Object.assign({},e);const a=Object.keys(t);for(let l=0,o=a.length;l<o;l++){const o=a[l],s=t[o];if(Cn(s))void 0===s?delete i[o]:i[o]=s;else{const a=i[o],l=s;if(yn(e,o,r)||yn(t,o,r))delete i[o];else{if(Sn(a)&&Sn(l)){const n=r.get(a)||[],i=r.get(l)||[];n.push({obj:e,key:o}),i.push({obj:t,key:o}),r.set(a,n),r.set(l,i)}i[o]=xn(i[o],s,n,r)}}}}else i=t;return i}}function yn(e,t,n){const r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){const i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function wn(e){return Array.isArray(e)}function kn(e){return"function"==typeof e}function Sn(e){return!Cn(e)&&!wn(e)&&!kn(e)&&"object"==typeof e}function Cn(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||void 0===e||e instanceof Date||e instanceof RegExp||null===e}class Pn{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}}class En{_isCalled=!1;_deferred=new Pn;_callback;_that;constructor(e,t){this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}}let Tn;function zn(){if(void 0===Tn)try{const e=globalThis.process.argv0;Tn=e?`unknown_service:${e}`:"unknown_service"}catch{Tn="unknown_service"}return Tn}const Rn=e=>null!==e&&"object"==typeof e&&"function"==typeof e.then;class In{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,t){const n=new In({},t);return n._rawAttributes=An(e),n._asyncAttributesPending=e.filter(([e,t])=>Rn(t)).length>0,n}constructor(e,t){const n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([e,t])=>(Rn(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=An(this._rawAttributes),this._schemaUrl=function(e){if("string"==typeof e||void 0===e)return e;return void ut.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",e)}(t?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){const[t,n]=this._rawAttributes[e];this._rawAttributes[e]=[t,Rn(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ut.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const e={};for(const[t,n]of this._rawAttributes)Rn(n)?ut.debug(`Unsettled resource attribute ${t} skipped`):null!=n&&(e[t]??=n);return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(null==e)return this;const t=function(e,t){const n=e?.schemaUrl,r=t?.schemaUrl,i=void 0===n||""===n,a=void 0===r||""===r;if(i)return r;if(a)return n;if(n===r)return n;return void ut.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',n,r)}(this,e),n=t?{schemaUrl:t}:void 0;return In.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}}function Mn(e,t){return In.FromAttributeList(Object.entries(e),t)}function An(e){return e.map(([e,t])=>Rn(t)?[e,t.catch(t=>{ut.debug("promise rejection for resource attribute: %s - %s",e,t)})]:[e,t])}class $n{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:lt.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(e){const t=Date.now();this._spanContext=e.spanContext,this._performanceStartTime=qt.now(),this._performanceOffset=t-(this._performanceStartTime+qt.timeOrigin),this._startTimeProvided=null!=e.startTime,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit||0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,this.links=e.links||[],this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,null!=e.attributes&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(null==t||this._isSpanEnded())return this;if(0===e.length)return ut.warn(`Invalid attribute key: ${e}`),this;if(!Mt(t))return ut.warn(`Invalid attribute value set for key: ${e}`),this;const{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return void 0!==n&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(const[t,n]of Object.entries(e))this.setAttribute(t,n);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;const{eventCountLimit:r}=this._spanLimits;if(0===r)return ut.warn("No events allowed."),this._droppedEventsCount++,this;void 0!==r&&this.events.length>=r&&(0===this._droppedEventsCount&&ut.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),Qt(t)&&(Qt(n)||(n=t),t=void 0);const i=Rt(t);return this.events.push({name:e,attributes:i,time:this._getTime(n),droppedAttributesCount:0}),this}addLink(e){return this.links.push(e),this}addLinks(e){return this.links.push(...e),this}setStatus(e){return this._isSpanEnded()||(this.status={...e},null!=this.status.message&&"string"!=typeof e.message&&(ut.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`),delete this.status.message)),this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){this._isSpanEnded()?ut.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this.endTime=this._getTime(e),this._duration=function(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(n-=1,r+=Vt),[n,r]}(this.startTime,this.endTime),this._duration[0]<0&&(ut.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.",this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&ut.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._ended=!0,this._spanProcessor.onEnd(this))}_getTime(e){if("number"==typeof e&&e<=qt.now())return t=e+this._performanceOffset,Jt(Kt(qt.timeOrigin),Kt("number"==typeof t?t:qt.now()));var t;if("number"==typeof e)return Kt(e);if(e instanceof Date)return Kt(e.getTime());if(Gt(e))return e;if(this._startTimeProvided)return Kt(Date.now());const n=qt.now()-this._performanceStartTime;return Jt(this.startTime,Kt(n))}isRecording(){return!1===this._ended}recordException(e,t){const n={};"string"==typeof e?n[Ot]=e:e&&(e.code?n[Dt]=e.code.toString():e.name&&(n[Dt]=e.name),e.message&&(n[Ot]=e.message),e.stack&&(n["exception.stacktrace"]=e.stack)),n[Dt]||n[Ot]?this.addEvent("exception",n,t):ut.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){const e=new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);ut.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){const t=this._attributeValueLengthLimit;return t<=0?(ut.warn(`Attribute value limit must be positive, got ${t}`),e):"string"==typeof e?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>"string"==typeof e?this._truncateToLimitUtil(e,t):e):e}}var Ln,On;!function(e){e[e.NOT_RECORD=0]="NOT_RECORD",e[e.RECORD=1]="RECORD",e[e.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(Ln||(Ln={}));class Dn{shouldSample(){return{decision:Ln.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class jn{shouldSample(){return{decision:Ln.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class Hn{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(e){this._root=e.root,this._root||(Lt(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new jn),this._remoteParentSampled=e.remoteParentSampled??new jn,this._remoteParentNotSampled=e.remoteParentNotSampled??new Dn,this._localParentSampled=e.localParentSampled??new jn,this._localParentNotSampled=e.localParentNotSampled??new Dn}shouldSample(e,t,n,r,i,a){const l=St.getSpanContext(e);return l&&et(l)?l.isRemote?l.traceFlags&Ee.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):l.traceFlags&Ee.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a):this._root.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}class Nn{_ratio;_upperBound;constructor(e=0){this._ratio=this._normalize(e),this._upperBound=Math.floor(4294967295*this._ratio)}shouldSample(e,t){return{decision:Ye(t)&&this._accumulate(t)<this._upperBound?Ln.RECORD_AND_SAMPLED:Ln.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return"number"!=typeof e||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<e.length/8;n++){const r=8*n;t=(t^parseInt(e.slice(r,r+8),16))>>>0}return t}}!function(e){e.AlwaysOff="always_off",e.AlwaysOn="always_on",e.ParentBasedAlwaysOff="parentbased_always_off",e.ParentBasedAlwaysOn="parentbased_always_on",e.ParentBasedTraceIdRatio="parentbased_traceidratio",e.TraceIdRatio="traceidratio"}(On||(On={}));function Un(){return{sampler:Bn(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function Bn(){const e=On.ParentBasedAlwaysOn;switch(e){case On.AlwaysOn:return new jn;case On.AlwaysOff:return new Dn;case On.ParentBasedAlwaysOn:return new Hn({root:new jn});case On.ParentBasedAlwaysOff:return new Hn({root:new Dn});case On.TraceIdRatio:return new Nn(Fn());case On.ParentBasedTraceIdRatio:return new Hn({root:new Nn(Fn())});default:return ut.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${On.ParentBasedAlwaysOn}".`),new Hn({root:new jn})}}function Fn(){return ut.error("OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1."),1}const qn=1/0;class Wn{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(e,t){this._exporter=e,this._maxExportBatchSize="number"==typeof t?.maxExportBatchSize?t.maxExportBatchSize:512,this._maxQueueSize="number"==typeof t?.maxQueueSize?t.maxQueueSize:2048,this._scheduledDelayMillis="number"==typeof t?.scheduledDelayMillis?t.scheduledDelayMillis:5e3,this._exportTimeoutMillis="number"==typeof t?.exportTimeoutMillis?t.exportTimeoutMillis:3e4,this._shutdownOnce=new En(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(ut.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||0!==(e.spanContext().traceFlags&Ee.SAMPLED)&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize)return 0===this._droppedSpansCount&&ut.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(ut.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{const n=[];for(let e=0,t=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),0===this._finishedSpans.length?Promise.resolve():new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error("Timeout"))},this._exportTimeoutMillis);dt.with(function(e){return e.setValue(Ct,!0)}(dt.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);const i=()=>this._exporter.export(r,r=>{clearTimeout(n),r.code===Xt.SUCCESS?e():t(r.error??new Error("BatchSpanProcessor: span export failed"))});let a=null;for(let e=0,t=r.length;e<t;e++){const t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a??=[],a.push(t.resource.waitForAsyncAttributes()))}null===a?i():Promise.all(a).then(i,e=>{Lt(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;const e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,Lt(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();void 0===this._timer&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),"number"!=typeof this._timer&&this._timer.unref())}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class Vn extends Wn{_visibilityChangeListener;_pageHideListener;constructor(e,t){super(e,t),this.onInit(t)}onInit(e){!0!==e?.disableAutoFlushOnDocumentHide&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush().catch(e=>{Lt(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{Lt(e)})},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}onShutdown(){"undefined"!=typeof document&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}}const Kn=new Uint8Array(16),Gn=new Uint8Array(8),Qn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Jn(e){for(let t=0;t<e.length;t++)e[t]=256*Math.random()>>>0;for(let t=0;t<e.length;t++)if(e[t]>0)return;e[e.length-1]=1}function Xn(e){let t="";for(let n=0;n<e.length;n++)t+=Qn[e[n]];return t}class Zn{generateTraceId(){return Jn(Kn),Xn(Kn)}generateSpanId(){return Jn(Gn),Xn(Gn)}}class Yn{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;constructor(e,t,n,r){const i=function(e){const t={sampler:Bn()},n=Un(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new Zn,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e}startSpan(e,t={},n=dt.active()){t.root&&(n=St.deleteSpan(n));const r=St.getSpan(n);if(Pt(n)){ut.debug("Instrumentation suppressed, returning Noop Span");return St.wrapSpanContext(Be)}const i=r?.spanContext(),a=this._idGenerator.generateSpanId();let l,o,s;i&&St.isSpanContextValid(i)?(o=i.traceId,s=i.traceState,l=i):o=this._idGenerator.generateTraceId();const c=t.kind??at.INTERNAL,p=(t.links??[]).map(e=>({context:e.context,attributes:Rt(e.attributes)})),d=Rt(t.attributes),u=this._sampler.shouldSample(n,o,e,c,d,p);s=u.traceState??s;const h={traceId:o,spanId:a,traceFlags:u.decision===it.RECORD_AND_SAMPLED?Ee.SAMPLED:Ee.NONE,traceState:s};if(u.decision===it.NOT_RECORD){ut.debug("Recording is off, propagating context in a non-recording span");return St.wrapSpanContext(h)}const g=Rt(Object.assign(d,u.attributes));return new $n({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:h,name:e,kind:c,links:p,parentSpanContext:l,attributes:g,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits})}startActiveSpan(e,t,n,r){let i,a,l;if(arguments.length<2)return;2===arguments.length?l=t:3===arguments.length?(i=t,l=n):(i=t,a=n,l=r);const o=a??dt.active(),s=this.startSpan(e,i,o),c=St.setSpan(o,s);return dt.with(c,l,void 0,s)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}class er{_spanProcessors;constructor(e){this._spanProcessors=e}forceFlush(){const e=[];for(const t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{Lt(e||new Error("MultiSpanProcessor: forceFlush failed")),t()})})}onStart(e,t){for(const n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(const t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(const t of this._spanProcessors)t.onEnd(e)}shutdown(){const e=[];for(const t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}}var tr;!function(e){e[e.resolved=0]="resolved",e[e.timeout=1]="timeout",e[e.error=2]="error",e[e.unresolved=3]="unresolved"}(tr||(tr={}));class nr{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(e={}){const t=function(...e){let t=e.shift();const n=new WeakMap;for(;e.length>0;)t=xn(t,e.shift(),0,n);return t}({},Un(),function(e){const t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??void 0??void 0??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??void 0??void 0??qn,Object.assign({},e,{spanLimits:t})}(e));this._resource=t.resource??Mn({[jt]:zn(),[Ht]:Ft[Ht],[Nt]:Ft[Nt],[Ut]:Ft[Ut]}),this._config=Object.assign({},t,{resource:this._resource});const n=[];e.spanProcessors?.length&&n.push(...e.spanProcessors),this._activeSpanProcessor=new er(n)}getTracer(e,t,n){const r=`${e}@${t||""}:${n?.schemaUrl||""}`;return this._tracers.has(r)||this._tracers.set(r,new Yn({name:e,version:t,schemaUrl:n?.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){const e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r;const i=setTimeout(()=>{n(new Error(`Span processor did not completed within timeout period of ${e} ms`)),r=tr.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==tr.timeout&&(r=tr.resolved,n(r))}).catch(e=>{clearTimeout(i),r=tr.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{const r=t.filter(e=>e!==tr.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}class rr{_enabled=!1;_currentContext=ze;_bindFunction(e=ze,t){const n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,"length",{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return void 0===e&&(e=this.active()),"function"==typeof t?this._bindFunction(e,t):t}disable(){return this._currentContext=ze,this._enabled=!1,this}enable(){return this._enabled||(this._enabled=!0,this._currentContext=ze),this}with(e,t,n,...r){const i=this._currentContext;this._currentContext=e||ze;try{return t.call(n,...r)}finally{this._currentContext=i}}}class ir extends nr{constructor(e={}){super(e)}register(e={}){var t;St.setGlobalTracerProvider(this),null!==(t=e.propagator)&&(void 0!==t?wt.setGlobalPropagator(t):wt.setGlobalPropagator(new Zt({propagators:[new sn,new zt]}))),function(e){if(null!==e){if(void 0===e){const e=new rr;return e.enable(),void dt.setGlobalContextManager(e)}e.enable(),dt.setGlobalContextManager(e)}}(e.contextManager)}}class ar{_delegate;constructor(e){this._delegate=e}export(e,t){this._delegate.export(e,t)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}}class lr extends Error{code;name="OTLPExporterError";data;constructor(e,t,n){super(e),this.data=n,this.code=t}}function or(e){if(Number.isFinite(e)&&e>0)return e;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function sr(e,t,n){return{timeoutMillis:or(e.timeoutMillis??t.timeoutMillis??n.timeoutMillis),concurrencyLimit:e.concurrencyLimit??t.concurrencyLimit??n.concurrencyLimit,compression:e.compression??t.compression??n.compression}}class cr{_concurrencyLimit;_sendingPromises=[];constructor(e){this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw new Error("Concurrency Limit reached");this._sendingPromises.push(e);const t=()=>{const t=this._sendingPromises.indexOf(e);this._sendingPromises.splice(t,1)};e.then(t,t)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}}function pr(e){return new cr(e.concurrencyLimit)}function dr(){return{handleResponse(e){null!=e&&function(e){return Object.prototype.hasOwnProperty.call(e,"partialSuccess")}(e)&&null!=e.partialSuccess&&0!==Object.keys(e.partialSuccess).length&&ut.warn("Received Partial Success response:",JSON.stringify(e.partialSuccess))}}}class ur{_diagLogger;_transport;_serializer;_responseHandler;_promiseQueue;_timeout;constructor(e,t,n,r,i){this._transport=e,this._serializer=t,this._responseHandler=n,this._promiseQueue=r,this._timeout=i,this._diagLogger=ut.createComponentLogger({namespace:"OTLPExportDelegate"})}export(e,t){if(this._diagLogger.debug("items to be sent",e),this._promiseQueue.hasReachedLimit())return void t({code:Xt.FAILED,error:new Error("Concurrent export limit reached")});const n=this._serializer.serializeRequest(e);null!=n?this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(e=>{if("success"!==e.status)"failure"===e.status&&e.error?t({code:Xt.FAILED,error:e.error}):"retryable"===e.status?t({code:Xt.FAILED,error:e.error??new lr("Export failed with retryable status")}):t({code:Xt.FAILED,error:new lr("Export failed with unknown error")});else{if(null!=e.data)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(e.data))}catch(t){this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?",t,e.data)}t({code:Xt.SUCCESS})}},e=>t({code:Xt.FAILED,error:e}))):t({code:Xt.FAILED,error:new Error("Nothing to send")})}forceFlush(){return this._promiseQueue.awaitAll()}async shutdown(){this._diagLogger.debug("shutdown started"),await this.forceFlush(),this._transport.shutdown()}}function hr(e,t,n){return r={transport:n,serializer:t,promiseHandler:pr(e)},i={timeout:e.timeoutMillis},new ur(r.transport,r.serializer,dr(),r.promiseHandler,i.timeout);var r,i}function gr(e,t){const n={attributes:mr(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&""!==r&&(n.schemaUrl=r),n}function fr(e){return{name:e.name,version:e.version}}function mr(e,t){return Object.keys(e).map(n=>function(e,t,n){return{key:e,value:br(t,n)}}(n,e[n],t))}function br(e,t){const n=typeof e;if("string"===n)return{stringValue:e};if("number"===n)return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if("boolean"===n)return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=br(e[r],t);return{arrayValue:{values:n}}}if("object"===n&&null!=e){const n=Object.keys(e),r=new Array(n.length);for(let i=0;i<n.length;i++)r[i]={key:n[i],value:br(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}const vr="undefined"!=typeof BigInt?function(e){const t=function(e){const t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}(e);return t.toString()}:function(e){return e[0]*Vt+e[1]};function _r(e){return e}const xr={encodeHrTime:vr,encodeSpanContext:_r,encodeOptionalSpanContext:_r,encodeUint8Array:e=>{if("undefined"!=typeof Buffer)return Buffer.from(e).toString("base64");const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return btoa(t.join(""))}};function yr(e,t){let n=255&e|256;return t&&(n|=512),n}function wr(e,t){const n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:null==e.kind?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:mr(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>function(e,t){return{attributes:e.attributes?mr(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>function(e,t){return{attributes:e.attributes?mr(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:yr(e.context.traceFlags,e.context.isRemote)}}(e,t)),droppedLinksCount:e.droppedLinksCount,flags:yr(n.traceFlags,e.parentSpanContext?.isRemote)}}function kr(e,t){const n=function(e){const t=new Map;for(const n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));const r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||""}:${n.instrumentationScope.schemaUrl||""}`;let i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}(e),r=[],i=n.entries();let a=i.next();for(;!a.done;){const[e,n]=a.value,l=[],o=n.values();let s=o.next();for(;!s.done;){const e=s.value;if(e.length>0){const n=e.map(e=>wr(e,t));l.push({scope:fr(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}s=o.next()}const c=gr(e,t),p={resource:c,scopeSpans:l,schemaUrl:c.schemaUrl};r.push(p),a=i.next()}return r}const Sr={serializeRequest:e=>{const t=function(e,t){return{resourceSpans:kr(e,t)}}(e,xr);return(new TextEncoder).encode(JSON.stringify(t))},deserializeResponse:e=>{if(0===e.length)return{};const t=new TextDecoder;return JSON.parse(t.decode(e))}};function Cr(){return.4*Math.random()-.2}class Pr{_transport;constructor(e){this._transport=e}retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}async send(e,t){let n=5,r=1e3;const i=Date.now()+t;let a=await this._transport.send(e,t);for(;"retryable"===a.status&&n>0;){n--;const t=Math.max(Math.min(r*(1+Cr()),5e3),0);r*=1.5;const l=a.retryInMillis??t,o=i-Date.now();if(l>o)return ut.info(`Export retry time ${Math.round(l)}ms exceeds remaining timeout ${Math.round(o)}ms, not retrying further.`),a;ut.verbose(`Scheduling export retry in ${Math.round(l)}ms`),a=await this.retry(e,o,l)}return"success"===a.status?ut.verbose(`Export succeeded after ${5-n} retry attempts.`):"retryable"===a.status?ut.info("Export failed after maximum retry attempts (5)."):ut.info(`Export failed with non-retryable error: ${a.error}`),a}shutdown(){return this._transport.shutdown()}}function Er(e){return new Pr(e.transport)}class Tr{_params;constructor(e){this._params=e}async send(e){const t=(await this._params.headers())["Content-Type"];return new Promise(n=>{navigator.sendBeacon(this._params.url,new Blob([e],{type:t}))?(ut.debug("SendBeacon success"),n({status:"success"})):n({status:"failure",error:new Error("SendBeacon failed")})})}shutdown(){}}class zr{_parameters;constructor(e){this._parameters=e}async send(e,t){const n=new AbortController,r=setTimeout(()=>n.abort(),t);let i=globalThis.fetch;"function"==typeof i.__original&&(i=i.__original);try{const t=!!globalThis.location,r=new URL(this._parameters.url),l=await i(r.href,{method:"POST",headers:await this._parameters.headers(),body:e,signal:n.signal,keepalive:t,mode:t?globalThis.location?.origin===r.origin?"same-origin":"cors":"no-cors"});if(l.status>=200&&l.status<=299)return ut.debug("response success"),{status:"success"};if(429===(a=l.status)||502===a||503===a||504===a){const e=function(e){if(null==e)return;const t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?1e3*t:-1;const n=new Date(e).getTime()-Date.now();return n>=0?n:0}(l.headers.get("Retry-After"));return{status:"retryable",retryInMillis:e}}return{status:"failure",error:new Error("Fetch request failed with non-retryable status")}}catch(e){return function(e){return e instanceof TypeError&&!e.cause}(e)?{status:"retryable",error:new Error("Fetch request encountered a network error",{cause:e})}:{status:"failure",error:new Error("Fetch request errored",{cause:e})}}finally{clearTimeout(r)}var a}shutdown(){}}function Rr(e,t){return hr(e,t,Er({transport:(n=e,new zr(n))}));var n}function Ir(e,t){return hr(e,t,Er({transport:(n={url:e.url,headers:e.headers},new Tr(n))}));var n}function Mr(e,t,n){return async()=>{const r={...await n()},i={};return null!=t&&Object.assign(i,await t()),null!=e&&Object.assign(i,function(e){const t={};return Object.entries(e??{}).forEach(([e,n])=>{void 0!==n?t[e]=String(n):ut.warn(`Header "${e}" has invalid value (${n}) and will be ignored`)}),t}(await e())),Object.assign(i,r)}}function Ar(e){if(null!=e)try{const t=globalThis.location?.href;return new URL(e,t).href}catch{throw new Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function $r(e){return"function"==typeof e.headers?e.headers:function(e){if(null!=e)return async()=>e}(e.headers)}function Lr(e,t,n){return r={url:e.url,timeoutMillis:e.timeoutMillis,headers:$r(e),concurrencyLimit:e.concurrencyLimit},i={},a=function(e,t){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none",headers:async()=>e,url:"http://localhost:4318/"+t}}(n,t),{...sr(r,i,a),headers:Mr(r.headers,i.headers,a.headers),url:Ar(r.url)??i.url??a.url};var r,i,a}function Or(e,t,n,r){return function(e){if(!e&&"function"==typeof navigator.sendBeacon)return Ir;return Rr}(e.headers)(Lr(e,n,r),t)}class Dr extends ar{constructor(e={}){super(Or(e,Sr,"v1/traces",{"Content-Type":"application/json"}))}}let jr=null,Hr=null;function Nr(){return Hr??St.getTracer("pillar-sdk")}function Ur(e){const t=function(){const e=St.getActiveSpan();if(!e)return;const t=e.spanContext();if(!t)return;return`00-${t.traceId}-${t.spanId}-${t.traceFlags.toString(16).padStart(2,"0")}`}();return t&&(e.traceparent=t),e}class Br{constructor(e){this.requestId=0,this._externalUserId="",this.config=e}setExternalUserId(e){this._externalUserId=e}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_mcp_session_id";try{let t=sessionStorage.getItem(e);return t||(t=crypto.randomUUID(),sessionStorage.setItem(e,t)),t}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get baseUrl(){return`${this.config.apiBaseUrl}/mcp/`}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey,"x-visitor-id":this.getVisitorId(),"x-page-url":this.getPageUrl()};this.config.agentSlug&&(e["x-agent-slug"]=this.config.agentSlug);const t=this.getSessionId();return t&&(e["Mcp-Session-Id"]=t),this._externalUserId&&(e["x-external-user-id"]=this._externalUserId),"undefined"!=typeof navigator&&(e["Accept-Language"]=navigator.language||navigator.languages?.[0]||"en"),this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),null!==jr&&Ur(e),e}nextId(){return++this.requestId}async callTool(e,t){const n=performance.now(),r={jsonrpc:"2.0",id:this.nextId(),method:"tools/call",params:{name:e,arguments:t}};o.add({event:"network:request",data:{method:"tools/call",tool:e,url:this.baseUrl},source:"network",level:"info"});const i=await te(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(r),maxRetries:3,onRetry:(t,n)=>{p.log(`[MCPClient] Retrying callTool "${e}" (attempt ${t+1}) after ${n}ms...`)}}),a=Math.round(performance.now()-n);if(!i.ok){const e=await i.json().catch(()=>({}));throw o.add({event:"network:response",data:{status:i.status,duration:a,error:e.error?.message},source:"network",level:"error"}),new Error(e.error?.message||`MCP error: ${i.status}`)}const l=await i.json();if(o.add({event:"network:response",data:{status:i.status,duration:a,method:"tools/call",tool:e},source:"network",level:"info"}),l.error)throw new Error(l.error.message);return l.result}async callToolStream(e,t,n,r){const i=performance.now(),a=this.nextId();n.onRequestId?.(a);const l=Nr().startSpan("mcp.call_tool_stream",{attributes:{"mcp.tool":e,"mcp.request_id":a}}),s={jsonrpc:"2.0",id:a,method:"tools/call",params:{name:e,arguments:t,stream:!0}};o.add({event:"network:request",data:{method:"tools/call",tool:e,stream:!0,url:this.baseUrl},source:"network",level:"info"});const c=await te(this.baseUrl,{method:"POST",headers:{...this.headers,Accept:"text/event-stream"},body:JSON.stringify(s),signal:r,maxRetries:3,onRetry:(t,n)=>{p.log(`[MCPClient] Retrying stream connection for "${e}" (attempt ${t+1}) after ${n}ms...`)}}),d=Math.round(performance.now()-i);if(!c.ok){const e=await c.text();throw o.add({event:"network:response",data:{status:c.status,duration:d,error:e},source:"network",level:"error"}),new Error(`MCP streaming request failed: ${c.statusText} - ${e}`)}if(o.add({event:"network:stream:connected",data:{status:c.status,connectionTime:d,tool:e},source:"network",level:"info"}),!c.body)throw new Error("Response body is null");const u=c.body.getReader(),h=new TextDecoder;let g="",f=[],m=null;try{for(;;){const{done:e,value:t}=await u.read();if(e)break;g+=h.decode(t,{stream:!0});const r=g.split("\n");g=r.pop()||"";for(const e of r)if(e.trim()&&e.startsWith("data: "))try{const t=e.substring(6),r=JSON.parse(t);if("2.0"===r.jsonrpc){if(r.error){const e=r.error.data;n.onError?.(r.error.message||"Unknown error",e);const t=new Error(r.error.message);throw t.data=e,t}if("notifications/progress"===r.method){const e=r.params?.progress;if(e){if("debug"===e.type){o.add({event:e.event||"server:event",data:e.data,source:"server",level:"info"});continue}if("progress"===e.type&&e.data){const t=e.data;p.log(`[MCPClient] Progress event (new schema): ${t.kind}`,t),n.onProgress?.({kind:t.kind,id:t.id,label:t.label,status:t.status,text:t.text,children:t.children,metadata:t.metadata});continue}if("token"!==e.kind&&"token"!==e.type&&(console.log(`[MCPClient] Progress event: kind=${e.kind} type=${e.type}`,e),p.log(`[MCPClient] Progress event: ${e.kind}`,e)),"token"===e.kind&&e.token)f.push(e.token),n.onToken?.(e.token);else if("conversation_started"===e.kind)n.onConversationStarted?.(e.conversation_id,e.assistant_message_id);else if("token_usage"===e.kind)n.onTokenUsage?.({prompt_tokens:e.prompt_tokens,completion_tokens:e.completion_tokens,total_prompt_tokens:e.total_prompt_tokens,total_completion_tokens:e.total_completion_tokens,total_used:e.total_used,context_window:e.context_window,occupancy_pct:e.occupancy_pct,model_name:e.model_name,iteration:e.iteration});else{if("cancelled"===e.kind)break;if("action_request"===e.kind||"action_request"===e.type){if(console.log("[MCPClient] *** RECEIVED tool_request ***",e.action_name,e.parameters),p.log("[MCPClient] Received tool_request:",e.action_name,e.parameters),!e.action_name||"string"!=typeof e.action_name||""===e.action_name.trim()){console.error("[MCPClient] tool_request INVALID - missing action_name:",e),p.error("[MCPClient] Received tool_request with missing or invalid action_name:",e);continue}const t=n.onToolRequest||n.onActionRequest;if(t){console.log("[MCPClient] *** CALLING tool request handler ***"),e.tool_call_id||(console.warn("[MCPClient] tool_request missing tool_call_id - result correlation may fail"),p.warn("[MCPClient] tool_request missing tool_call_id for tool:",e.action_name));t({action_name:e.action_name,parameters:e.parameters||{},action:e.action,tool_call_id:e.tool_call_id}).catch(e=>{console.error("[MCPClient] Tool request handler FAILED:",e),p.error("[MCPClient] Tool request handler failed:",e)})}else console.warn("[MCPClient] tool_request received but NO HANDLER registered"),p.warn("[MCPClient] Received tool_request but no handler registered")}else n.onProgress?.({kind:e.kind,id:e.id,label:e.label,status:e.status,text:e.text||e.content,children:e.children,message:e.message,progress_id:e.progress_id,metadata:{...e.metadata,...null!=e.sources&&{sources:e.sources},...null!=e.result_count&&{result_count:e.result_count},...null!=e.query&&{query:e.query},...null!=e.action_name&&{action_name:e.action_name},...null!=e.no_sources_used&&{no_sources_used:e.no_sources_used}}})}}}if(r.result&&r.id===a){m=r.result,m.structuredContent?.sources&&n.onSources?.(m.structuredContent.sources);const e=m.structuredContent?.tools||m.structuredContent?.actions;e&&(n.onTools?.(e),n.onActions?.(e));const t=m.structuredContent?.registered_tools;t&&(n.onRegisteredTools?.(t),n.onRegisteredActions?.(t));const i=m._meta?.conversation_id,a=m._meta?.query_log_id;n.onComplete?.(i,a)}}}catch(t){p.error("[MCPClient] Failed to parse event:",t,e)}}}catch(e){if(l.setStatus({code:lt.ERROR,message:e.message}),"AbortError"===e.name)throw l.setAttribute("mcp.cancelled",!0),l.end(),e;const t=e instanceof Error?e.message:"Stream reading failed";throw n.onProgress?.({kind:"error",id:"stream-error",label:"Connection interrupted",status:"error",text:t,metadata:{error:t}}),n.onError?.(t),l.end(),e}finally{u.releaseLock();const t=Math.round(performance.now()-i);l.setAttribute("mcp.duration_ms",t),l.end(),o.add({event:"network:stream:complete",data:{duration:t,tool:e},source:"network",level:"info"})}return m||(m={content:[{type:"text",text:f.join("")}],isError:!1}),m}async uploadImage(e){const t=`${this.config.apiBaseUrl}/mcp/upload-image/`,n=new FormData;n.append("image",e);const r=await te(t,{method:"POST",headers:{"x-customer-id":this.config.productKey},body:n,maxRetries:3,onRetry:(e,t)=>{p.log(`[MCPClient] Retrying image upload (attempt ${e+1}) after ${t}ms...`)}});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,t,n){const r={query:e};n?.conversationId&&(r.conversation_id=n.conversationId),n?.articleSlug&&(r.article_slug=n.articleSlug),n?.userContext&&n.userContext.length>0&&(r.user_context=n.userContext),n?.images&&n.images.length>0&&(r.images=n.images),n?.history&&n.history.length>0&&(r.history=n.history);const i=n?.registeredTools||n?.registeredActions;return i&&i.length>0&&(r.registered_tools=i),n?.resume&&(r.resume=!0),this.callToolStream("ask",r,t,n?.signal)}async cancelStream(e){const t={jsonrpc:"2.0",id:this.nextId(),method:"notifications/cancel",params:{request_id:e}};p.log(`[MCPClient] Cancelling stream request_id=${e}`);try{await te(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t),keepalive:!0,maxRetries:3,onRetry:(e,t)=>{p.log(`[MCPClient] Retrying cancel request (attempt ${e+1}) after ${t}ms...`)}})}catch(e){p.warn("[MCPClient] Failed to send cancel request:",e)}}async sendToolResult(e,t,n){const r=performance.now(),i=Nr().startSpan("mcp.send_tool_result",{attributes:{"mcp.tool":e,"mcp.tool_call_id":n||""}});n||(console.warn(`[MCPClient] sendToolResult called without toolCallId for tool "${e}" - server will not be able to correlate result`),p.warn("[MCPClient] Missing toolCallId in sendToolResult for:",e));const a={jsonrpc:"2.0",id:this.nextId(),method:"action/result",params:{action_name:e,result:t,tool_call_id:n}};o.add({event:"network:request",data:{method:"action/result",tool:e,tool_call_id:n,url:this.baseUrl},source:"network",level:"info"}),p.log(`[MCPClient] Sending tool result for "${e}"...`),await new Promise(e=>setTimeout(e,0));try{const t=await te(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(a),keepalive:!0,maxRetries:6,onRetry:(t,n)=>{p.log(`[MCPClient] Retrying tool result for "${e}" (attempt ${t+1}) after ${n}ms...`),o.add({event:"network:retry",data:{method:"action/result",action:e,attempt:t+1,delay:n},source:"network",level:"warn"})}}),n=Math.round(performance.now()-r);if(!t.ok){const r=await t.text().catch(()=>"");throw o.add({event:"network:response",data:{status:t.status,duration:n,tool:e,error:r},source:"network",level:"error"}),p.error(`[MCPClient] Tool result delivery failed: ${t.status} ${t.statusText}`,r),new Error(`Failed to send tool result: ${t.status}`)}o.add({event:"network:response",data:{status:t.status,duration:n,tool:e},source:"network",level:"info"}),p.log(`[MCPClient] Tool result for "${e}" delivered in ${n}ms`),i.setAttribute("mcp.duration_ms",n),i.end()}catch(t){const n=Math.round(performance.now()-r);throw i.setStatus({code:lt.ERROR,message:t.message}),i.end(),p.error(`[MCPClient] Failed to send tool result for "${e}" after ${n}ms:`,t),t}}async sendActionResult(e,t,n){return this.sendToolResult(e,t,n)}async sendLog(e,t,n){const r={jsonrpc:"2.0",id:this.nextId(),method:"client/log",params:{level:e,message:t,data:n,timestamp:(new Date).toISOString()}};try{fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(r),keepalive:!0}).catch(()=>{})}catch{}}sendLogBatch(e){if(0===e.length)return;const t={jsonrpc:"2.0",id:this.nextId(),method:"client/log-batch",params:{logs:e}};try{fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}async getConversationStatus(e){try{const t=await te(`${this.baseUrl}conversations/${e}/status/`,{method:"GET",headers:this.headers,maxRetries:3,onRetry:(e,t)=>{p.log(`[MCPClient] Retrying conversation status check (attempt ${e+1}) after ${t}ms...`)}});if(!t.ok)return p.warn(`[MCPClient] Failed to get conversation status: ${t.status}`),null;return await t.json()}catch(e){return p.warn("[MCPClient] Error getting conversation status:",e),null}}}function Fr(e){return{id:e.id,name:e.name,taskType:e.action_type,data:e.data,autoRun:e.auto_run,autoComplete:e.auto_complete}}const qr=Fr;class Wr{constructor(e){this.abortControllers=new Map,this._externalUserId=null,this.config=e,this.mcpClient=new Br(e)}get mcp(){return this.mcpClient}get baseUrl(){return`${this.config.apiBaseUrl}/api/v1/help-center`}setExternalUserId(e){this._externalUserId=e,this.mcpClient.setExternalUserId(e)}clearExternalUserId(){this._externalUserId=null,this.mcpClient.setExternalUserId("")}regenerateVisitorId(){if("undefined"==typeof window)return;try{const e=crypto.randomUUID();localStorage.setItem("pillar_visitor_id",e)}catch{}}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_session_id";try{let t=sessionStorage.getItem(e);return t||(t=crypto.randomUUID(),sessionStorage.setItem(e,t)),t}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey,"x-visitor-id":this.getVisitorId(),"x-session-id":this.getSessionId(),"x-page-url":this.getPageUrl()};return this.config.agentSlug&&(e["x-agent-slug"]=this.config.agentSlug),this._externalUserId&&(e["x-external-user-id"]=this._externalUserId),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,t={},n){if(n){this.abortControllers.get(n)?.abort();const e=new AbortController;this.abortControllers.set(n,e),t.signal=e.signal}const r=`${this.baseUrl}${e}`;try{const n=await te(r,{...t,headers:{...this.headers,...t.headers},maxRetries:3,onRetry:(t,n)=>{p.log(`[Pillar API] Retrying ${e} (attempt ${t+1}) after ${n}ms...`)}});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.detail||e.message||`API error: ${n.status}`)}return n.json()}catch(t){if("AbortError"===t.name)throw t;throw p.error(`[Pillar API] Error fetching ${e}:`,t),t}finally{n&&this.abortControllers.delete(n)}}async fetchEmbedConfig(){try{const e=this.config.agentSlug?`${this.config.apiBaseUrl}/api/public/agents/${this.config.agentSlug}/embed-config/`:`${this.config.apiBaseUrl}/api/public/products/${this.config.productKey}/embed-config/`,t=await te(e,{method:"GET",headers:{"Content-Type":"application/json"},maxRetries:3,onRetry:(e,t)=>{p.log(`[Pillar] Retrying embed config fetch (attempt ${e+1}) after ${t}ms...`)}});return t.ok?await t.json():(p.warn("[Pillar] Failed to fetch embed config:",t.status),null)}catch(e){return p.warn("[Pillar] Failed to fetch embed config:",e),null}}async getSuggestedQuestions(){try{const e=await this.mcpClient.callTool("suggest_questions",{}),t=e.structuredContent?.questions;return Array.isArray(t)?t:[]}catch(e){return p.warn("[Pillar] Failed to get suggested questions:",e),[]}}async uploadImage(e){return this.mcpClient.uploadImage(e)}async chat(e){let t="",n=[],r=[];const{getRegisteredActions:i,setRegisteredActions:a,updateTokenUsage:l}=await Promise.resolve().then(function(){return po});try{const o=await this.mcpClient.ask(e.message,{onToken:n=>{t+=n,e.onChunk?.(n)},onSources:e=>{n=e},onActions:t=>{r=t.map(qr),e.onActions?.(r)},onProgress:t=>{e.onProgress?.(t)},onConversationStarted:(t,n)=>{e.onConversationStarted?.(t,n)},onActionRequest:async t=>{e.onActionRequest&&await e.onActionRequest(t)},onRegisteredActions:e=>{a(e),p.log("[Pillar API] Stored",e.length,"registered actions for dynamic tool calling")},onRequestId:t=>{e.onRequestId?.(t)},onTokenUsage:e=>{l({promptTokens:e.prompt_tokens,completionTokens:e.completion_tokens,totalPromptTokens:e.total_prompt_tokens,totalCompletionTokens:e.total_completion_tokens,totalUsed:e.total_used,contextWindow:e.context_window,occupancyPct:e.occupancy_pct,modelName:e.model_name,iteration:e.iteration})},onError:e=>{p.error("[Pillar API] MCP chat error:",e)}},{articleSlug:e.articleSlug,userContext:e.userContext,images:e.images,history:e.history,registeredActions:i(),conversationId:e.existingConversationId||void 0,signal:e.signal,resume:e.resume});t||"text"!==o.content[0]?.type||(t=o.content[0].text||"");const s=o._meta||{};return{message:t,sources:n,actions:r,conversationId:s.conversation_id,messageId:s.query_log_id}}catch(e){throw p.error("[Pillar API] Chat error:",e),e}}async submitFeedback(e,t,n){try{await this.fetch("/ai/feedback/",{method:"POST",body:JSON.stringify({message_id:e,feedback:t,...n&&{comment:n}})})}catch(e){p.warn("[Pillar] Feedback submission failed:",e)}}async confirmTaskExecution(e,t,n){try{const r={status:t,error:n?.error,duration_ms:n?.duration_ms,session_id:n?.session_id,conversation_id:n?.conversation_id,metadata:n};await this.fetch(`/tasks/${e}/confirm/`,{method:"POST",body:JSON.stringify(r)})}catch(e){p.warn("[Pillar] Failed to confirm task execution:",e)}}async trackWebMCPExecution(e,t,n){try{const r=`${this.config.apiBaseUrl}/mcp/track-webmcp-execution/`;await te(r,{method:"POST",headers:this.headers,body:JSON.stringify({tool_name:e,status:t,duration_ms:n?.duration_ms,error:n?.error,input:n?.input,session_id:this.getSessionId(),visitor_id:this.getVisitorId()}),maxRetries:1})}catch(e){p.warn("[Pillar] Failed to track WebMCP execution:",e)}}async getSuggestions(e,t){try{return(await this.fetch("/suggestions/",{method:"POST",body:JSON.stringify({context:e,user_profile:t})})).suggestions||[]}catch(e){return p.warn("[Pillar] Failed to get suggestions:",e),[]}}async identify(e,t){const n=`${this.config.apiBaseUrl}/mcp/identify/`,r=await te(n,{method:"POST",headers:this.headers,body:JSON.stringify({userId:e,name:t?.name,email:t?.email,metadata:t?.metadata}),maxRetries:3,onRetry:(e,t)=>{p.log(`[Pillar] Retrying identify (attempt ${e+1}) after ${t}ms...`)}});if(!r.ok){const e=await r.json().catch(()=>({}));throw new Error(e.error||`Identify failed: ${r.status}`)}}async listConversations(e=20){const t=`${this.config.apiBaseUrl}/mcp/conversations/?limit=${Math.min(e,50)}`;try{const e=await fetch(t,{method:"GET",headers:this.headers});if(!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`Failed to list conversations: ${e.status}`)}return(await e.json()).conversations||[]}catch(e){return p.warn("[Pillar] Failed to list conversations:",e),[]}}async getConversation(e){const t=`${this.config.apiBaseUrl}/mcp/conversations/${e}/`;try{const e=await fetch(t,{method:"GET",headers:this.headers});if(!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`Failed to get conversation: ${e.status}`)}return await e.json()}catch(e){return p.warn("[Pillar] Failed to get conversation:",e),null}}cancelAllRequests(){this.abortControllers.forEach(e=>e.abort()),this.abortControllers.clear()}}var Vr=0;function Kr(e,t,n,r,i,a){t||(t={});var l,o,s=t;if("ref"in s)for(o in s={},t)"ref"==o?l=t[o]:s[o]=t[o];var c={type:e,props:s,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Vr,__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(c),c}var Gr,Qr,Jr,Xr,Zr=0,Yr=[],ei=g,ti=ei.__b,ni=ei.__r,ri=ei.diffed,ii=ei.__c,ai=ei.unmount,li=ei.__;function oi(e,t){ei.__h&&ei.__h(Qr,e,Zr||t),Zr=0;var n=Qr.__H||(Qr.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function si(e){return Zr=1,function(e,t){var n=oi(Gr++,2);if(n.t=e,!n.__c&&(n.__=[_i(void 0,t),function(e){var t=n.__N?n.__N[0]:n.__[0],r=n.t(t,e);t!==r&&(n.__N=[r,n.__[1]],n.__c.setState({}))}],n.__c=Qr,!Qr.__f)){var r=function(e,t,r){if(!n.__c.__H)return!0;var a=n.__c.__H.__.filter(function(e){return!!e.__c});if(a.every(function(e){return!e.__N}))return!i||i.call(this,e,t,r);var l=n.__c.props!==e;return a.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(l=!0)}}),i&&i.call(this,e,t,r)||l};Qr.__f=!0;var i=Qr.shouldComponentUpdate,a=Qr.componentWillUpdate;Qr.componentWillUpdate=function(e,t,n){if(this.__e){var l=i;i=void 0,r(e,t,n),i=l}a&&a.call(this,e,t,n)},Qr.shouldComponentUpdate=r}return n.__N||n.__}(_i,e)}function ci(e,t){var n=oi(Gr++,3);!ei.__s&&vi(n.__H,t)&&(n.__=e,n.u=t,Qr.__H.__h.push(n))}function pi(e){return Zr=5,di(function(){return{current:e}},[])}function di(e,t){var n=oi(Gr++,7);return vi(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ui(e,t){return Zr=8,di(function(){return e},t)}function hi(){for(var e;e=Yr.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(mi),e.__H.__h.forEach(bi),e.__H.__h=[]}catch(t){e.__H.__h=[],ei.__e(t,e.__v)}}ei.__b=function(e){Qr=null,ti&&ti(e)},ei.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),li&&li(e,t)},ei.__r=function(e){ni&&ni(e),Gr=0;var t=(Qr=e.__c).__H;t&&(Jr===Qr?(t.__h=[],Qr.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(mi),t.__h.forEach(bi),t.__h=[],Gr=0)),Jr=Qr},ei.diffed=function(e){ri&&ri(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==Yr.push(t)&&Xr===ei.requestAnimationFrame||((Xr=ei.requestAnimationFrame)||fi)(hi)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Jr=Qr=null},ei.__c=function(e,t){t.some(function(e){try{e.__h.forEach(mi),e.__h=e.__h.filter(function(e){return!e.__||bi(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],ei.__e(n,e.__v)}}),ii&&ii(e,t)},ei.unmount=function(e){ai&&ai(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{mi(e)}catch(e){t=e}}),n.__H=void 0,t&&ei.__e(t,n.__v))};var gi="function"==typeof requestAnimationFrame;function fi(e){var t,n=function(){clearTimeout(r),gi&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);gi&&(t=requestAnimationFrame(n))}function mi(e){var t=Qr,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Qr=t}function bi(e){var t=Qr;e.__c=e.__(),Qr=t}function vi(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function _i(e,t){return"function"==typeof t?t(e):t}var xi=Symbol.for("preact-signals");function yi(){if(Ei>1)Ei--;else{for(var e,t=!1;void 0!==Pi;){var n=Pi;for(Pi=void 0,Ti++;void 0!==n;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ai(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(Ti=0,Ei--,t)throw e}}var wi=void 0;function ki(e){var t=wi;wi=void 0;try{return e()}finally{wi=t}}var Si,Ci,Pi=void 0,Ei=0,Ti=0,zi=0;function Ri(e){if(void 0!==wi){var t=e.n;if(void 0===t||t.t!==wi)return t={i:0,S:e,p:wi.s,n:void 0,t:wi,e:void 0,x:void 0,r:t},void 0!==wi.s&&(wi.s.n=t),wi.s=t,e.n=t,32&wi.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=wi.s,t.n=void 0,wi.s.n=t,wi.s=t),t}}function Ii(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Mi(e,t){return new Ii(e,t)}function Ai(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function $i(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function Li(e){for(var t=e.s,n=void 0;void 0!==t;){var r=t.p;-1===t.i?(t.S.U(t),void 0!==r&&(r.n=t.n),void 0!==t.n&&(t.n.p=r)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=r}e.s=n}function Oi(e,t){Ii.call(this,void 0),this.x=e,this.s=void 0,this.g=zi-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Di(e,t){return new Oi(e,t)}function ji(e){var t=e.u;if(e.u=void 0,"function"==typeof t){Ei++;var n=wi;wi=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Hi(e),t}finally{wi=n,yi()}}}function Hi(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ji(e)}function Ni(e){if(wi!==this)throw new Error("Out-of-order effect");Li(this),wi=e,this.f&=-2,8&this.f&&Hi(this),yi()}function Ui(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function Bi(e,t){var n=new Ui(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function Fi(e,t){g[e]=t.bind(null,g[e]||function(){})}function qi(e){Ci&&Ci(),Ci=e&&e.S()}function Wi(e){var t=this,n=e.data,r=function(e){return di(function(){return Mi(e)},[])}(n);r.value=n;var i=di(function(){for(var e=t.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return t.__$u.c=function(){var e,n=t.__$u.S(),r=i.value;n(),m(r)||3!==(null==(e=t.base)?void 0:e.nodeType)?(t.__$f|=1,t.setState({})):t.base.data=r},Di(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Vi(e,t,n,r){var i=t in e&&void 0===e.ownerSVGElement,a=Mi(n);return{o:function(e,t){a.value=e,r=t},d:Bi(function(){var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n?e.setAttribute(t,n):e.removeAttribute(t))})}}function Ki(e){var t=pi(e);return t.current=e,Si.__$f|=4,di(function(){return Di(function(){return t.current()})},[])}Ii.prototype.brand=xi,Ii.prototype.h=function(){return!0},Ii.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:ki(function(){var e;null==(e=t.W)||e.call(t)}))},Ii.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,r=e.x;void 0!==n&&(n.x=r,e.e=void 0),void 0!==r&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&ki(function(){var e;null==(e=t.Z)||e.call(t)}))}},Ii.prototype.subscribe=function(e){var t=this;return Bi(function(){var n=t.value,r=wi;wi=void 0;try{e(n)}finally{wi=r}},{name:"sub"})},Ii.prototype.valueOf=function(){return this.value},Ii.prototype.toString=function(){return this.value+""},Ii.prototype.toJSON=function(){return this.value},Ii.prototype.peek=function(){var e=wi;wi=void 0;try{return this.value}finally{wi=e}},Object.defineProperty(Ii.prototype,"value",{get:function(){var e=Ri(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ti>100)throw new Error("Cycle detected");this.v=e,this.i++,zi++,Ei++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{yi()}}}}),Oi.prototype=new Ii,Oi.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===zi)return!0;if(this.g=zi,this.f|=1,this.i>0&&!Ai(this))return this.f&=-2,!0;var e=wi;try{$i(this),wi=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return wi=e,Li(this),this.f&=-2,!0},Oi.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}Ii.prototype.S.call(this,e)},Oi.prototype.U=function(e){if(void 0!==this.t&&(Ii.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},Oi.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(Oi.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ri(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ui.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},Ui.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ji(this),$i(this),Ei++;var e=wi;return wi=this,Ni.bind(this,e)},Ui.prototype.N=function(){2&this.f||(this.f|=2,this.o=Pi,Pi=this)},Ui.prototype.d=function(){this.f|=8,1&this.f||Hi(this)},Ui.prototype.dispose=function(){this.d()},Wi.displayName="_st",Object.defineProperties(Ii.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Wi},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Fi("__b",function(e,t){if("string"==typeof t.type){var n,r=t.props;for(var i in r)if("children"!==i){var a=r[i];a instanceof Ii&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),Fi("__r",function(e,t){qi();var n,r=t.__c;r&&(r.__$f&=-2,void 0===(n=r.__$u)&&(r.__$u=n=function(){var e;return Bi(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),Si=r,qi(n),e(t)}),Fi("__e",function(e,t,n,r){qi(),Si=void 0,e(t,n,r)}),Fi("diffed",function(e,t){var n;if(qi(),Si=void 0,"string"==typeof t.type&&(n=t.__e)){var r=t.__np,i=t.props;if(r){var a=n.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 n.U=a={};for(var s in r){var c=a[s],p=r[s];void 0===c?(c=Vi(n,s,p,i),a[s]=c):c.o(p,i)}}}e(t)}),Fi("unmount",function(e,t){if("string"==typeof t.type){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}}else{var l=t.__c;if(l){var o=l.__$u;o&&(l.__$u=void 0,o.d())}}e(t)}),Fi("__h",function(e,t,n,r){(r<3||9===r)&&(t.__$f|=2),e(t,n,r)}),L.prototype.shouldComponentUpdate=function(e,t){var n=this.__$u,r=n&&void 0!==n.s;for(var i in t)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 Gi="pillar:panel_open",Qi="pillar:panel_width";function Ji(e){if("undefined"!=typeof window)try{localStorage.setItem(Gi,String(e))}catch{}}function Xi(){if("undefined"==typeof window)return null;try{const e=localStorage.getItem(Qi);if(null===e)return null;const t=Number(e);return Number.isFinite(t)&&t>0?t:null}catch{return null}}function Zi(e){if("undefined"!=typeof window)try{localStorage.setItem(Qi,String(e))}catch{}}const Yi=Mi(function(){if("undefined"==typeof window)return!1;try{return"true"===localStorage.getItem(Gi)}catch{return!1}}()),ea=Mi("assistant"),ta=Mi("right"),na=Mi("overlay"),ra=Mi(380),ia=Mi(1200),aa=Mi(!0),la=Mi(700),oa=Mi(500),sa=Mi("undefined"!=typeof window?window.innerWidth:1920);let ca=null;const pa=Di(()=>{const e=ia.value;return!1!==e&&sa.value<e}),da=Di(()=>sa.value<la.value),ua=Di(()=>sa.value<oa.value),ha=Di(()=>pa.value?"overlay":na.value);Di(()=>{const e=["pillar-panel",`pillar-panel--${ta.value}`];return Yi.value&&e.push("pillar-panel--open"),e.join(" ")});const ga=()=>{Yi.value=!1,Ji(!1),"overlay"===ha.value&&(document.body.style.overflow="")},fa=e=>{ra.value=e},ma=()=>{Yi.value=!1,Ji(!1),ea.value="assistant",document.body.style.overflow=""};function ba(e,t,n){const r=document.createElement("style");return n&&(r.id=n),r.textContent=t,e instanceof Document?e.head.appendChild(r):e.appendChild(r),r}const va={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>',tools:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path></svg>'},_a={assistant:va.help,support:va.support,tools:va.tools};function xa({position:e,tabs:t,currentActiveTab:n,onTabClick:r,panelOpen:i,panelWidthPx:a,theme:l,resizable:o,isResizing:s,onResizeStart:c}){const p=ui(e=>{r(e)},[r]),d=["pillar-edge-sidebar",`pillar-edge-sidebar--${e}`,"pillar-edge-sidebar--mounted",i&&"pillar-edge-sidebar--panel-open",s&&"pillar-edge-sidebar--resizing","light"===l&&"pillar-edge-sidebar--light","dark"===l&&"pillar-edge-sidebar--dark"].filter(Boolean).join(" "),u={"--pillar-panel-width":`${a}px`},h=t.filter(e=>e.enabled).sort((e,t)=>e.order-t.order);return Kr("div",{class:d,style:u,children:[o&&i&&Kr("div",{class:"pillar-edge-resize-handle",onMouseDown:c,onTouchStart:c}),h.map(e=>{return Kr("button",{class:["pillar-edge-trigger",i&&n===e.id&&"pillar-edge-trigger--active"].filter(Boolean).join(" "),onClick:()=>p(e.id),"aria-label":e.label||"Help",type:"button",children:[Kr("span",{class:"pillar-edge-trigger__icon",dangerouslySetInnerHTML:{__html:(t=e.id,r=e.icon,r&&r in va?va[r]:_a[t]||va.help)}}),Kr("span",{class:"pillar-edge-trigger__label",children:e.label})]},e.id);var t,r})]})}class ya{constructor(e,t,n,r){this.container=null,this.stylesInjected=!1,this.themeStylesInjected=!1,this._isHidden=!1,this.unsubscribeOpen=null,this.unsubscribeWidth=null,this.unsubscribeHoverMode=null,this.unsubscribeMobileMode=null,this.unsubscribeActiveTab=null,this.themeObserver=null,this.currentTheme="light",this._isResizing=!1,this._resizeStartX=0,this._resizeStartWidth=0,this._resizeRafId=null,this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,this.handleTabClick=e=>{if(!["assistant","tools"].includes(e)){const t=this.config.sidebarTabs.find(t=>t.id===e);return this.events.emit("sidebar:click",{tabId:e,label:t?.label||e}),void("support"===e&&this.events.emit("support:request",{tabId:e}))}if(Yi.value&&ea.value===e)return this.onClick(),void this.render();(e=>{ea.value=e})(e),Yi.value||this.onClick(),this.render()},this.handleResizeStart=e=>{if(!Yi.value||!this.config.panel.resizable||!this.config.edgeTrigger.resizable)return;e.preventDefault(),e.stopPropagation();const t="touches"in e?e.touches[0].clientX:e.clientX;this._isResizing=!0,this._resizeStartX=t,this._resizeStartWidth=ra.value,this._boundHandleResizeMove=this.handleResizeMove.bind(this),this._boundHandleResizeEnd=this.handleResizeEnd.bind(this),document.addEventListener("mousemove",this._boundHandleResizeMove),document.addEventListener("mouseup",this._boundHandleResizeEnd),document.addEventListener("touchmove",this._boundHandleResizeMove,{passive:!1}),document.addEventListener("touchend",this._boundHandleResizeEnd),document.addEventListener("touchcancel",this._boundHandleResizeEnd),document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",document.documentElement.style.cursor="col-resize",document.documentElement.style.transition="none",this.render()},this.handleResizeEnd=e=>{this._isResizing&&(null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this._isResizing=!1,Zi(ra.value),this._boundHandleResizeMove&&(document.removeEventListener("mousemove",this._boundHandleResizeMove),document.removeEventListener("touchmove",this._boundHandleResizeMove)),this._boundHandleResizeEnd&&(document.removeEventListener("mouseup",this._boundHandleResizeEnd),document.removeEventListener("touchend",this._boundHandleResizeEnd),document.removeEventListener("touchcancel",this._boundHandleResizeEnd)),this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,document.body.style.userSelect="",document.body.style.webkitUserSelect="",document.documentElement.style.cursor="",document.documentElement.style.transition="padding 0.3s ease",this.render())},this.config=e,this.events=t,this.onClick=n,this.rootContainer=r||null}getEdgePosition(){return this.config.panel.position}detectThemeFromDOM(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}applyThemeMode(){const e=this.config.theme.mode;this.currentTheme="light"===e||"dark"===e?e:this.detectThemeFromDOM()}init(){if(this.stylesInjected||(ba(document,"/* Sidebar container - always visible, shifts when panel opens */\n.pillar-edge-sidebar {\n /* Default light mode variables (match panel's variables.css) */\n --pillar-primary: #2563eb;\n --pillar-primary-hover: #1d4ed8;\n --pillar-bg: #ffffff;\n --pillar-bg-secondary: #f9fafb;\n --pillar-text: #1a1a1a;\n --pillar-text-muted: #6b7280;\n --pillar-border: #e5e7eb;\n --pillar-border-light: #f3f4f6;\n --pillar-outline-color: rgba(37, 99, 235, 0.15);\n\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/* Default dark mode variables (match panel's variables.css) */\n.pillar-edge-sidebar--dark {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-text: #f5f5f5;\n --pillar-text-muted: #a3a3a3;\n --pillar-border: #404040;\n --pillar-border-light: #333333;\n --pillar-outline-color: rgba(96, 165, 250, 0.25);\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-left: none;\n border-right: 1px solid var(--pillar-border);\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-bg-secondary);\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\n/* Resize handle - appears on the inner edge of the sidebar (content side) */\n.pillar-edge-resize-handle {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 6px;\n cursor: col-resize;\n z-index: 1;\n display: none;\n touch-action: none;\n}\n\n/* Position the handle on the correct edge based on panel position */\n.pillar-edge-sidebar--right .pillar-edge-resize-handle {\n left: -3px;\n}\n\n.pillar-edge-sidebar--left .pillar-edge-resize-handle {\n right: -3px;\n}\n\n/* Only show when panel is open */\n.pillar-edge-sidebar--panel-open .pillar-edge-resize-handle {\n display: block;\n}\n\n/* Visible indicator line on hover */\n.pillar-edge-resize-handle::after {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n width: 2px;\n left: 50%;\n transform: translateX(-50%);\n background: transparent;\n transition: background 0.15s ease;\n border-radius: 1px;\n}\n\n.pillar-edge-resize-handle:hover::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.5;\n}\n\n.pillar-edge-sidebar--resizing .pillar-edge-resize-handle::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.7;\n}\n\n/* Override cursor on the whole sidebar during resize */\n.pillar-edge-sidebar--resizing,\n.pillar-edge-sidebar--resizing * {\n cursor: col-resize !important;\n}\n\n/* Disable sidebar transition during resize for immediate feedback */\n.pillar-edge-sidebar--resizing {\n transition: none !important;\n}\n","pillar-edge-trigger-styles"),this.stylesInjected=!0),!this.themeStylesInjected){const e=function(e,t,n){const r=e=>{const t=[];return e.primary&&t.push(`--pillar-primary: ${e.primary};`),e.primaryHover&&t.push(`--pillar-primary-hover: ${e.primaryHover};`),e.background&&t.push(`--pillar-bg: ${e.background};`),e.backgroundSecondary&&t.push(`--pillar-bg-secondary: ${e.backgroundSecondary};`),e.text&&t.push(`--pillar-text: ${e.text};`),e.textMuted&&t.push(`--pillar-text-muted: ${e.textMuted};`),e.border&&t.push(`--pillar-border: ${e.border};`),e.borderLight&&t.push(`--pillar-border-light: ${e.borderLight};`),e.outlineColor&&t.push(`--pillar-outline-color: ${e.outlineColor};`),t.join("\n ")},i=r(e),a=r(t),l=n?`--pillar-font-family: ${n};`:"";let o="";return(i||l)&&(o+=`\n.pillar-edge-sidebar,\n.pillar-edge-sidebar--light {\n ${[i,l].filter(Boolean).join("\n ")}\n}\n`),a&&(o+=`\n.pillar-edge-sidebar--dark {\n ${a}\n}\n`),o}(this.config.theme.colors,this.config.theme.darkColors,this.config.theme.fontFamily);e&&ba(document,e,"pillar-edge-trigger-theme"),this.themeStylesInjected=!0}if(this.config.panel.resizable&&this.config.edgeTrigger.resizable){const e=Xi();null!==e&&fa(e)}this.container=document.createElement("div"),this.container.id="pillar-edge-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.applyThemeMode(),this.applyLayoutPadding(),this.render(),this.unsubscribeOpen=Yi.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeWidth=ra.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())});let e=pa.value;this.unsubscribeHoverMode=pa.subscribe(t=>{t!==e&&(e=t,queueMicrotask(()=>this.applyLayoutPadding()))});let t=da.value;this.unsubscribeMobileMode=da.subscribe(e=>{e!==t&&(t=e,e?this.hide():this.show())}),da.value&&this.hide(),this.unsubscribeActiveTab=ea.subscribe(()=>{this.render()}),"auto"===this.config.theme.mode&&(this.themeObserver=new MutationObserver(()=>{const e=this.detectThemeFromDOM();e!==this.currentTheme&&(this.currentTheme=e,this.render())}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}))}getPushTargetElement(){const e=this.config.panel.pushTarget;return e?"string"==typeof e?document.querySelector(e)||document.documentElement:e:document.documentElement}applyLayoutPadding(){if(this._isHidden)return;const e=this.getEdgePosition(),t=ra.value,n=pa.value,r=this.getPushTargetElement();let i=48;Yi.value&&!n&&(i=t+48),r.style.transition="padding 0.3s ease","right"===e?(r.style.paddingRight=`${i}px`,document.documentElement.style.setProperty("--pillar-inset-right",`${i}px`),document.documentElement.style.setProperty("--pillar-inset-left","0px")):(r.style.paddingLeft=`${i}px`,document.documentElement.style.setProperty("--pillar-inset-left",`${i}px`),document.documentElement.style.setProperty("--pillar-inset-right","0px"))}removeLayoutPadding(){const e=this.getEdgePosition(),t=this.getPushTargetElement();"right"===e?t.style.paddingRight="":t.style.paddingLeft="",document.documentElement.style.removeProperty("--pillar-inset-right"),document.documentElement.style.removeProperty("--pillar-inset-left")}setOpen(e){this.render()}show(){this._isHidden=!1,this.container&&(this.container.style.display=""),this.applyLayoutPadding(),this.render()}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._isResizing&&this.handleResizeEnd(new MouseEvent("mouseup")),null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.unsubscribeWidth?.(),this.unsubscribeWidth=null,this.unsubscribeHoverMode?.(),this.unsubscribeHoverMode=null,this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=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}handleResizeMove(e){this._isResizing&&("touches"in e&&e.preventDefault(),null===this._resizeRafId&&(this._resizeRafId=requestAnimationFrame(()=>{if(this._resizeRafId=null,!this._isResizing)return;const t="touches"in e?e.touches[0].clientX:e.clientX,n=this._resizeStartX-t,r="right"===this.getEdgePosition()?n:-n,i=window.innerWidth-48-100,a=Math.max(200,Math.min(i,this._resizeStartWidth+r));fa(a)})))}render(){if(!this.container||this._isHidden)return;const e=this.getEdgePosition();let t=[...this.config.sidebarTabs];const n=t.findIndex(e=>"assistant"===e.id);if(-1!==n&&(t[n]={...t[n],label:this.config.assistantDisplayName}),this.config.debug){const e=t.some(e=>"tools"===e.id);if(!e){const e=Math.max(...t.map(e=>e.order),0);t.push({id:"tools",label:"Tools",enabled:!0,order:e+1,icon:"tools"})}}Y(Kr(xa,{position:e,tabs:t,currentActiveTab:ea.value,onTabClick:this.handleTabClick,panelOpen:Yi.value,panelWidthPx:ra.value,theme:this.currentTheme,resizable:this.config.panel.resizable&&this.config.edgeTrigger.resizable,isResizing:this._isResizing,onResizeStart:this.handleResizeStart}),this.container)}}const wa={sparkle:'<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8.8 8.44L9.497 11l.697-2.56c.175-.643.263-.965.435-1.23a2 2 0 0 1 .583-.583c.263-.172.585-.259 1.23-.435l2.56-.697l-2.56-.697c-.643-.175-.964-.263-1.23-.435a2 2 0 0 1-.583-.583c-.172-.263-.259-.585-.435-1.23L9.497-.01L8.8 2.55c-.175.643-.263.965-.435 1.23a2 2 0 0 1-.583.583c-.263.172-.585.259-1.23.435l-2.56.697l2.56.697c.643.175.965.263 1.23.435a2 2 0 0 1 .583.583c.172.263.259.585.435 1.23M2.68 13.7c.169.244.264.542.456 1.14l.362 1.12l.362-1.12c.191-.595.287-.893.456-1.14c.149-.216.34-.4.561-.543c.249-.161.55-.247 1.15-.418l.971-.277l-.971-.277c-.601-.172-.902-.258-1.15-.418a2 2 0 0 1-.561-.543c-.169-.244-.264-.542-.456-1.14l-.362-1.12l-.362 1.12c-.191.595-.287.893-.456 1.14c-.149.216-.34.4-.561.543c-.249.161-.55.247-1.15.418l-.971.277l.971.277c.601.172.902.258 1.15.418a2 2 0 0 1 .561.543"/></svg>',question:'<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>',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>',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>',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>'},ka={small:44,medium:56,large:68};function Sa({position:e,icon:t,backgroundColor:n,iconColor:r,size:i,label:a,offset:l,panelOpen:o,onClick:s}){const c=ui(()=>{s()},[s]);return Kr("button",{class:["pillar-mobile-trigger",`pillar-mobile-trigger--${e}`,"pillar-mobile-trigger--mounted",o&&"pillar-mobile-trigger--hidden"].filter(Boolean).join(" "),style:{"--pillar-mobile-offset":`${l}px`,"--pillar-mobile-bg":n,width:`${i}px`,height:`${i}px`,backgroundColor:n,color:r},onClick:c,"aria-label":a,title:a,type:"button",children:Kr("span",{class:"pillar-mobile-trigger__icon",dangerouslySetInnerHTML:{__html:t}})})}class Ca{constructor(e,t,n,r){this.container=null,this.stylesInjected=!1,this._isEnabled=!0,this.unsubscribeMobileMode=null,this.unsubscribeOpen=null,this.config=e,this.events=t,this.onClick=n,this.rootContainer=r||null,this._isEnabled=e.mobileTrigger.enabled}getSize(){const e=this.config.mobileTrigger.size;return"number"==typeof e?e:ka[e]}getIcon(){const{customIcon:e,icon:t}=this.config.mobileTrigger;return e||wa[t]}getBackgroundColor(){const{backgroundColor:e}=this.config.mobileTrigger;return e||(this.config.theme.colors.primary||"#c2410c")}init(){if(!this._isEnabled)return;this.stylesInjected||(ba(document,"/* Mobile trigger floating button */\n.pillar-mobile-trigger {\n position: fixed;\n z-index: 100000;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);\n transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n}\n\n.pillar-mobile-trigger:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.12);\n}\n\n.pillar-mobile-trigger:active {\n transform: scale(0.95);\n}\n\n.pillar-mobile-trigger:focus-visible {\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 5px var(--pillar-mobile-bg, #c2410c);\n}\n\n/* Position variants */\n.pillar-mobile-trigger--bottom-right {\n bottom: var(--pillar-mobile-offset, 24px);\n right: var(--pillar-mobile-offset, 24px);\n}\n\n.pillar-mobile-trigger--bottom-left {\n bottom: var(--pillar-mobile-offset, 24px);\n left: var(--pillar-mobile-offset, 24px);\n}\n\n/* Icon styling */\n.pillar-mobile-trigger__icon {\n width: 55%;\n height: 55%;\n flex-shrink: 0;\n transform: translateY(-1px);\n}\n\n/* Hidden state (when panel is open) */\n.pillar-mobile-trigger--hidden {\n opacity: 0 !important;\n pointer-events: none;\n transform: scale(0.8) !important;\n visibility: hidden;\n}\n\n/* Animation on mount */\n@keyframes pillar-mobile-trigger-mount {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.pillar-mobile-trigger--mounted {\n animation: pillar-mobile-trigger-mount 0.2s ease forwards;\n}\n","pillar-mobile-trigger-styles"),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-mobile-trigger-container";(this.rootContainer||document.body).appendChild(this.container);let e=da.value;this.unsubscribeMobileMode=da.subscribe(t=>{t!==e&&(e=t,this.render())});let t=Yi.value;this.unsubscribeOpen=Yi.subscribe(e=>{e!==t&&(t=e,this.render())}),this.render()}show(){this._isEnabled=!0,this.render()}hide(){this._isEnabled=!1,this.render()}get isVisible(){return this._isEnabled&&da.value&&!Yi.value}destroy(){this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=null,this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.container&&(Y(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-mobile-trigger-styles")?.remove(),this.stylesInjected=!1}render(){if(!this.container)return;if(!this._isEnabled||!da.value)return void Y(null,this.container);const{position:e,iconColor:t,label:n,offset:r}=this.config.mobileTrigger;Y(Kr(Sa,{position:e,icon:this.getIcon(),backgroundColor:this.getBackgroundColor(),iconColor:t,size:this.getSize(),label:n,offset:r,panelOpen:Yi.value,onClick:this.onClick}),this.container)}}let Pa=null;function Ea(e){Pa=e}function Ta(){return Pa}function za(){return Pa?._api??null}function Ra(e){const t=new Date(e);return`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function Ia(e){switch(e){case"error":return"#ef4444";case"warn":return"#f59e0b";default:return"#d4d4d4"}}function Ma(e){switch(e){case"sdk":return"⚡";case"handler":return"🔧";case"network":return"🌐";case"server":return"🧠";default:return"•"}}function Aa(e){switch(e){case"sdk":return"SDK";case"handler":return"Handler";case"network":return"Network";case"server":return"Server";default:return e}}const $a=["sdk","handler","network","server"];function La({expanded:e=!1,onToggle:t}){const[n,r]=si([]),[i,a]=si(e),[l,o]=si(""),[s,c]=si(new Set($a)),[p,d]=si(200),[u,h]=si(!1),[g,f]=si(new Set),[m,b]=si(null),v=pi(null),_=pi("");ci(()=>{const e="pillar-debug-panel-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=".pillar-debug-panel {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: #1e1e1e;\n color: #d4d4d4;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 12px;\n z-index: 999999;\n border-top: 1px solid #333;\n}\n.pillar-debug-resize-handle {\n height: 8px;\n background-color: #333;\n cursor: ns-resize;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.pillar-debug-resize-handle::after {\n content: '';\n width: 40px;\n height: 3px;\n background-color: #555;\n border-radius: 2px;\n}\n.pillar-debug-resize-handle:hover,\n.pillar-debug-resize-handle.active {\n background-color: #3b82f6;\n}\n.pillar-debug-resize-handle:hover::after,\n.pillar-debug-resize-handle.active::after {\n background-color: #fff;\n}\n.pillar-debug-header {\n display: flex;\n align-items: center;\n padding: 8px 12px;\n background-color: #252526;\n cursor: pointer;\n user-select: none;\n}\n.pillar-debug-header-icon {\n margin-right: 8px;\n font-size: 10px;\n}\n.pillar-debug-header-title {\n font-weight: 600;\n margin-right: 8px;\n}\n.pillar-debug-header-count {\n background-color: #3c3c3c;\n padding: 2px 6px;\n border-radius: 4px;\n font-size: 11px;\n margin-right: auto;\n}\n.pillar-debug-header-actions {\n display: flex;\n gap: 8px;\n}\n.pillar-debug-btn {\n background-color: transparent;\n border: 1px solid #555;\n color: #d4d4d4;\n padding: 2px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n}\n.pillar-debug-btn:hover {\n background-color: #333;\n}\n.pillar-debug-btn.copied {\n border-color: #10b981;\n color: #10b981;\n}\n.pillar-debug-content {\n overflow: hidden;\n display: flex;\n flex-direction: column;\n}\n.pillar-debug-toolbar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n background-color: #2d2d2d;\n border-bottom: 1px solid #3c3c3c;\n flex-shrink: 0;\n}\n.pillar-debug-filter-input {\n background-color: #3c3c3c;\n border: none;\n color: #d4d4d4;\n padding: 4px 8px;\n font-size: 12px;\n outline: none;\n border-radius: 4px;\n flex: 1;\n max-width: 200px;\n}\n.pillar-debug-source-filters {\n display: flex;\n gap: 4px;\n}\n.pillar-debug-source-btn {\n background-color: transparent;\n border: 1px solid #444;\n color: #888;\n padding: 2px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n.pillar-debug-source-btn.active {\n background-color: #3c3c3c;\n border-color: #666;\n color: #d4d4d4;\n}\n.pillar-debug-source-btn:hover {\n background-color: #333;\n}\n.pillar-debug-source-count {\n background-color: #444;\n padding: 0 4px;\n border-radius: 3px;\n font-size: 10px;\n}\n.pillar-debug-timeline {\n flex: 1;\n overflow-y: auto;\n padding: 4px 0;\n}\n.pillar-debug-empty {\n padding: 12px;\n color: #6b7280;\n text-align: center;\n}\n.pillar-debug-entry {\n padding: 4px 12px;\n border-bottom: 1px solid #2d2d2d;\n}\n.pillar-debug-entry:hover {\n background-color: #252526;\n}\n.pillar-debug-entry.server {\n background-color: rgba(139, 92, 246, 0.1);\n}\n.pillar-debug-entry.server:hover {\n background-color: rgba(139, 92, 246, 0.15);\n}\n.pillar-debug-entry-row {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.pillar-debug-entry-time {\n color: #6b7280;\n flex-shrink: 0;\n}\n.pillar-debug-entry-source {\n flex-shrink: 0;\n font-size: 10px;\n padding: 1px 4px;\n border-radius: 3px;\n background-color: #333;\n}\n.pillar-debug-entry-source.sdk { background-color: #3b82f6; color: white; }\n.pillar-debug-entry-source.handler { background-color: #10b981; color: white; }\n.pillar-debug-entry-source.network { background-color: #f59e0b; color: black; }\n.pillar-debug-entry-source.server { background-color: #8b5cf6; color: white; }\n.pillar-debug-entry-event {\n font-weight: 500;\n flex-shrink: 0;\n}\n.pillar-debug-entry-data {\n color: #9ca3af;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.pillar-debug-entry.expanded {\n flex-direction: column;\n align-items: stretch;\n}\n.pillar-debug-entry.expanded .pillar-debug-entry-row {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.pillar-debug-entry.expanded .pillar-debug-entry-data {\n white-space: pre-wrap;\n word-break: break-all;\n overflow: visible;\n margin-top: 8px;\n padding: 8px;\n background-color: #2d2d2d;\n border-radius: 4px;\n font-size: 11px;\n line-height: 1.4;\n}\n.pillar-debug-entry-expand {\n color: #6b7280;\n font-size: 10px;\n flex-shrink: 0;\n margin-left: auto;\n}\n",document.head.appendChild(t)}_.current=document.body.style.paddingBottom||"";const t=Ta();if(!t)return;r(t.getDebugLog());const n=t.onDebugLog(e=>{r([...e])});return()=>{n(),document.body.style.paddingBottom=_.current}},[]);const x=pi(null);ci(()=>{const e=x.current;if(!e)return;const t=()=>{document.body.style.paddingBottom=`${e.offsetHeight}px`},n=new ResizeObserver(t);return n.observe(e),t(),()=>{n.disconnect()}},[]),ci(()=>{v.current&&n.length>0&&requestAnimationFrame(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)})},[n]);const y=ui(e=>{e.preventDefault(),h(!0);const t=e.clientY,n=p,r=e=>{const r=t-e.clientY,i=Math.min(600,Math.max(100,n+r));d(i)},i=()=>{h(!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",i)},[p]),w=di(()=>{const e={sdk:0,handler:0,network:0,server:0};for(const t of n)e[t.source]=(e[t.source]||0)+1;return e},[n]),k=di(()=>n.filter(e=>{if(!s.has(e.source))return!1;if(l){const t=l.toLowerCase(),n=e.event.toLowerCase().includes(t),r=!!e.data&&JSON.stringify(e.data).toLowerCase().includes(t);if(!n&&!r)return!1}return!0}),[n,s,l]),S=(e,t)=>["=== Pillar SDK — Client Logs ===",`Output: ${t}`,`Exported: ${(new Date).toISOString()}`,`Entries: ${e.length}`,""].join("\n")+e.map(e=>{const t=Ra(e.timestamp),n=Aa(e.source).toUpperCase().padEnd(8),r="error"===e.level?" [ERROR]":"warn"===e.level?" [WARN]":"",i=null!=e.data?` ${"object"==typeof e.data?JSON.stringify(e.data):String(e.data)}`:"";return`${t} [${n}]${r} ${e.event}${i}`}).join("\n");return Kr("div",{class:"pillar-debug-panel",ref:x,children:[i&&Kr("div",{class:"pillar-debug-resize-handle "+(u?"active":""),onMouseDown:y}),Kr("div",{class:"pillar-debug-header",onClick:()=>{a(!i),t?.()},children:[Kr("span",{class:"pillar-debug-header-icon",children:i?"▼":"▶"}),Kr("span",{class:"pillar-debug-header-title",children:"Debug"}),Kr("span",{class:"pillar-debug-header-count",children:n.length}),i&&Kr("div",{class:"pillar-debug-header-actions",children:[Kr("button",{class:"pillar-debug-btn "+("copy"===m?"copied":""),onClick:e=>{e.stopPropagation(),(()=>{const e=$a.filter(e=>s.has(e)).map(Aa).join(", "),t=S(k,l?`${e} (filtered: "${l}")`:e);navigator.clipboard.writeText(t),b("copy"),setTimeout(()=>b(null),1500)})()},children:"copy"===m?"Copied!":"Copy"}),Kr("button",{class:"pillar-debug-btn "+("copyAll"===m?"copied":""),onClick:e=>{e.stopPropagation(),(()=>{const e=S(n,"All Sources");navigator.clipboard.writeText(e),b("copyAll"),setTimeout(()=>b(null),1500)})()},children:"copyAll"===m?"Copied!":"Copy All"}),Kr("button",{class:"pillar-debug-btn",onClick:e=>{e.stopPropagation(),(()=>{const e=JSON.stringify(n,null,2),t=new Blob([e],{type:"application/json"}),r=URL.createObjectURL(t),i=document.createElement("a");i.href=r,i.download=`pillar-debug-${(new Date).toISOString().slice(0,19).replace(/:/g,"-")}.json`,i.click(),URL.revokeObjectURL(r)})()},children:"Export"}),Kr("button",{class:"pillar-debug-btn",onClick:e=>{e.stopPropagation(),(()=>{const e=Ta();e?.clearDebugLog()})()},children:"Clear"})]})]}),i&&Kr("div",{class:"pillar-debug-content",style:{height:`${p}px`},children:[Kr("div",{class:"pillar-debug-toolbar",children:[Kr("input",{type:"text",class:"pillar-debug-filter-input",placeholder:"Filter...",value:l,onInput:e=>o(e.target.value),onClick:e=>e.stopPropagation()}),Kr("div",{class:"pillar-debug-source-filters",children:$a.map(e=>Kr("button",{class:"pillar-debug-source-btn "+(s.has(e)?"active":""),onClick:t=>{t.stopPropagation(),(e=>{c(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})(e)},children:[Ma(e)," ",Aa(e),Kr("span",{class:"pillar-debug-source-count",children:w[e]})]},e))})]}),Kr("div",{class:"pillar-debug-timeline",ref:v,children:0===k.length?Kr("div",{class:"pillar-debug-empty",children:0===n.length?"No events captured yet":"No events match filters"}):k.map((e,t)=>{const n=g.has(t),r=null!==e.data&&void 0!==e.data;return Kr("div",{class:`pillar-debug-entry ${e.source} ${n?"expanded":""}`,onClick:()=>r&&(e=>{f(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})(t),style:{cursor:r?"pointer":"default"},children:[Kr("div",{class:"pillar-debug-entry-row",children:[Kr("span",{class:"pillar-debug-entry-time",children:Ra(e.timestamp)}),Kr("span",{class:`pillar-debug-entry-source ${e.source}`,children:Ma(e.source)}),Kr("span",{class:"pillar-debug-entry-event",style:{color:Ia(e.level)},children:e.event}),r&&!n&&Kr("span",{class:"pillar-debug-entry-data",children:"object"==typeof e.data?JSON.stringify(e.data,null,0).slice(0,100):String(e.data)}),r&&Kr("span",{class:"pillar-debug-entry-expand",children:n?"▼":"▶"})]}),r&&n&&Kr("span",{class:"pillar-debug-entry-data",children:(i=e.data,null==i?"":"object"==typeof i?JSON.stringify(i,null,2):String(i))})]},t);var i})})]})]})}function Oa(){return`ctx_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Da(e){return"highlighted_text"===e.type}function ja(e){return"dom_snapshot"===e.type}function Ha(e){return Da(e)?e.text_content.length>40?e.text_content.substring(0,40)+"...":e.text_content:ja(e)?`Page scan: ${e.interactableCount} elements`:"Context"}const Na=Mi([]),Ua=Mi(null),Ba=Mi([]),Fa=Mi(0),qa=Mi([]),Wa="pillar:conversation_id";function Va(e){if("undefined"!=typeof window)try{if(null===e)localStorage.removeItem(Wa);else{const t={id:e,lastActiveAt:Date.now()};localStorage.setItem(Wa,JSON.stringify(t))}}catch{}}let Ka=0;const Ga=Mi(!1),Qa=Mi(null),Ja=e=>{Qa.value=e},Xa=Mi(!1),Za=Mi(null),Ya=e=>{Za.value=e},el=()=>{Za.value=null},tl=Mi(null),nl=Mi(null),rl=Mi({kind:null}),il=Mi([]),al=e=>{const t=Na.value;if(t.length>0&&"assistant"===t[t.length-1].role){const n=t[t.length-1],r=n.progressEvents||[];let i;const a=e.id||e.progress_id;if(a){const t=r.findIndex(e=>(e.id||e.progress_id)===a);if(t>=0){const n=r[t],a="thinking"===n.kind||"step_start"===n.kind,l="active"===n.status,o="done"===e.status||"error"===e.status,s=n.metadata?._startTime,c=a&&l&&o&&s?{_durationSeconds:Math.round((Date.now()-s)/1e3)}:{},p={...n,...e,id:e.id||n.id,progress_id:e.progress_id||n.progress_id,text:n.text&&e.text?n.text+e.text:e.text??n.text,children:e.children||n.children,metadata:{...n.metadata,...e.metadata,...c}};i=[...r.slice(0,t),p,...r.slice(t+1)]}else{const t=Date.now(),n=r.map(e=>{if(!(("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status))return e;const n=e.metadata?._startTime,r=n?{_durationSeconds:Math.round((t-n)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...r}}});i=[...n,("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status?{...e,metadata:{...e.metadata,_startTime:t}}:e]}}else{const t=Date.now(),n=r.map(e=>{if(!(("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status))return e;const n=e.metadata?._startTime,r=n?{_durationSeconds:Math.round((t-n)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...r}}});i=[...n,("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status?{...e,metadata:{...e.metadata,_startTime:t}}:e]}const l=[...n.segments||[]],o=e.id&&r.some(t=>t.id===e.id);if(o)for(let t=l.length-1;t>=0;t--){const n=l[t];if("progress"!==n.type)continue;const r=n.events.findIndex(t=>t.id===e.id);if(r>=0){const a=i.find(t=>t.id===e.id);if(a){const e=[...n.events];e[r]=a,l[t]={type:"progress",events:e}}break}}else{const t=e.id?i.find(t=>t.id===e.id):i[i.length-1];if(t){const e=l[l.length-1];e&&"progress"===e.type?l[l.length-1]={type:"progress",events:[...e.events,t]}:l.push({type:"progress",events:[t]})}}Na.value=[...t.slice(0,-1),{...n,progressEvents:i,segments:l}]}},ll=e=>{!function(){const e=Date.now();if(!(e-Ka<3e4)&&(Ka=e,"undefined"!=typeof window))try{const t=localStorage.getItem(Wa);if(!t)return;const n=JSON.parse(t);n.lastActiveAt=e,localStorage.setItem(Wa,JSON.stringify(n))}catch{}}();const t=Na.value;if(0===t.length||"assistant"!==t[t.length-1].role)return;const n=t[t.length-1],r=[...n.segments||[]],i=r[r.length-1];i&&"text"===i.type?r[r.length-1]={type:"text",content:i.content+e}:r.push({type:"text",content:e}),Na.value=[...t.slice(0,-1),{...n,segments:r,content:(n.content||"")+e}]},ol=(e,t)=>{const n=Na.value;if(0===n.length||"assistant"!==n[n.length-1].role)return;const r=n[n.length-1],i=[...r.segments||[]];i.push({type:"card",cardType:e,data:t}),Na.value=[...n.slice(0,-1),{...r,segments:i}]},sl=Mi(!1),cl=Mi([]),pl=Mi([]),dl=Mi(""),ul=Mi(null),hl=Mi(null),gl=Mi(0),fl=Mi(0),ml=Mi([]),bl=Mi([]),vl=Mi([]),_l=Mi([]),xl=Di(()=>_l.value.some(e=>"uploading"===e.status)),yl=()=>_l.value.filter(e=>"ready"===e.status&&e.url).map(e=>({url:e.url,detail:"low",path:e.path})),wl=e=>{_l.value.length>=4||(_l.value=[..._l.value,e])},kl=(e,t,n,r,i)=>{_l.value=_l.value.map(a=>a.id===e?{...a,status:t,url:n,error:r,path:i}:a)},Sl=e=>{const t=_l.value.find(t=>t.id===e);t&&URL.revokeObjectURL(t.preview),_l.value=_l.value.filter(t=>t.id!==e)},Cl=()=>{_l.value.forEach(e=>URL.revokeObjectURL(e.preview)),_l.value=[]},Pl=Di(()=>Na.value.length>0),El=(e,t,n)=>{Na.value=[...Na.value,{role:"user",content:e,userContext:t&&t.length>0?t:void 0,images:n&&n.length>0?n:void 0}]},Tl=e=>{Na.value=[...Na.value,{role:"user",content:e,hidden:!0}]},zl=(e,t)=>{Na.value=[...Na.value,{role:"assistant",content:e,id:t,progressEvents:[]}]},Rl=(e,t,n,r)=>{const i=Na.value;if(i.length>0&&"assistant"===i[i.length-1].role){const a=i[i.length-1];Na.value=[...i.slice(0,-1),{role:"assistant",content:void 0!==e?e:a.content,id:t??a.id,actions:n??a.actions,sources:r??a.sources,actionStatus:a.actionStatus,progressEvents:a.progressEvents,segments:a.segments}]}},Il=(e,t)=>{const n=Na.value;if(e>=0&&e<n.length){const r=n[e],i={...r.actionStatus||{},[t]:{status:"pending"}};Na.value=[...n.slice(0,e),{...r,actionStatus:i},...n.slice(e+1)]}},Ml=(e,t,n)=>{const r=Na.value;for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.actionStatus?.[e]){const l={...a.actionStatus,[e]:{status:t?"success":"failed",completedAt:Date.now(),errorMessage:n}};return void(Na.value=[...r.slice(0,i),{...a,actionStatus:l},...r.slice(i+1)])}}},Al=(e,t)=>{const n=Na.value;for(let r=n.length-1;r>=0;r--){const i=n[r];if(i.actionStatus?.[e])return void(Na.value=[...n.slice(0,r),{...i,content:t},...n.slice(r+1)])}},$l=e=>{Ua.value=e,Va(e)},Ll=(e,t)=>{Na.value=Na.value.map(n=>n.id===e?{...n,feedback:t}:n)},Ol=e=>{Ga.value=e},Dl=()=>{rl.value={kind:null}},jl=()=>{const e=Na.value;if(0===e.length)return;const t=e[e.length-1];if("assistant"!==t.role||!t.progressEvents)return;const n=t.progressEvents.some(e=>"active"===e.status);if(!n)return;const r=Date.now(),i=t.progressEvents.map(e=>{if("active"!==e.status)return e;const t=e.metadata?._startTime,n=t?{_durationSeconds:Math.round((r-t)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...n}}});Na.value=[...e.slice(0,-1),{...t,progressEvents:i}]},Hl=e=>{const t=e.id||e.progress_id;if(t){const n=il.value.findIndex(e=>(e.id||e.progress_id)===t);if(n>=0){const t=il.value[n],r={...t,...e,id:e.id||t.id,progress_id:e.progress_id||t.progress_id,text:"thinking"===e.kind&&t.text&&e.text?t.text+e.text:e.text??t.text};il.value=[...il.value.slice(0,n),r,...il.value.slice(n+1)]}else il.value=[...il.value,e]}else il.value=[...il.value,e];al(e)},Nl=e=>{tl.value=e},Ul=()=>{tl.value=null},Bl=()=>{const e=Na.value;if(0===e.length)return;const t=e[e.length-1],n=t.progressEvents&&t.progressEvents.length>0;"assistant"!==t.role||t.content?.trim()||n||(Na.value=e.slice(0,-1))},Fl=e=>{ul.value=e},ql=()=>{ul.value=null},Wl=e=>{hl.value=e},Vl=()=>{hl.value=null},Kl=()=>{gl.value+=1},Gl=()=>{fl.value+=1},Ql=e=>{const t={...e,id:Oa()};ml.value=[...ml.value,t]},Jl=e=>{ml.value=ml.value.filter(t=>t.id!==e)},Xl=()=>{ml.value=[]},Zl=e=>{bl.value=e},Yl=()=>{bl.value=[]},eo=e=>{vl.value=e},to=()=>{vl.value=[]},no=()=>{Na.value=[],Ua.value=null,Va(null),Ba.value=[],Ga.value=!1,rl.value={kind:null},il.value=[],nl.value=null,sl.value=!1,cl.value=[],pl.value=[],dl.value="",ul.value=null,hl.value=null,gl.value=0,ml.value=[],bl.value=[],vl.value=[],Cl()},ro=()=>{no(),Xa.value=!0};function io(e){return"token_summary"===e.step_type||"tool_decision"===e.step_type||"parallel_tool_decision"===e.step_type||"narration"===e.step_type?null:"thinking"===e.step_type?{kind:"thinking",status:"done",text:e.content||"",label:"Thought",metadata:{iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:"tool_result"===e.step_type?{kind:e.kind||"tool_call",status:!1===e.success?"error":"done",label:e.label||e.tool||"Result",text:e.text,children:e.children,metadata:{tool_name:e.tool,tool:e.tool,arguments:e.arguments,success:e.success,iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:"step_start"===e.step_type?{kind:"step_start",status:"done",label:e.label||"Step",metadata:{iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:{kind:e.step_type,status:"done",label:e.label||e.step_type,text:e.content,metadata:e}}function ao(e){if(!e||0===e.length)return;const t=[];for(const n of e)if("narration"===n.step_type){const e=n.content||"",r=t[t.length-1];r&&"text"===r.type?r.content+=e:t.push({type:"text",content:e})}else{const e=io(n);if(!e)continue;const r=t[t.length-1];r&&"progress"===r.type?r.events.push(e):t.push({type:"progress",events:[e]})}return t.length>0?t:void 0}const lo=(e,t)=>{Ua.value=e,Va(e),Na.value=t.map(e=>({role:e.role,content:e.content,id:e.id,images:"user"===e.role&&e.images?.length?e.images:void 0,segments:"assistant"===e.role?ao(e.display_trace):void 0})),sl.value=!0,Xa.value=!1,Fa.value+=1},oo=()=>{Xa.value=!1},so=(e,t)=>{const n=(new Date).toISOString(),r={id:e,title:t,startedAt:n,lastMessageAt:n,messageCount:1};qa.value=[r,...qa.value.filter(t=>t.id!==e)],Fa.value+=1},co=async e=>{const{getApiClient:t}=await Promise.resolve().then(function(){return rd}),{navigate:n}=await Promise.resolve().then(function(){return yo}),{debug:r}=await Promise.resolve().then(function(){return d}),i=t();if(i){ro(),n("chat");try{const t=await i.getConversation(e);t&&t.messages.length>0?lo(t.id,t.messages):oo()}catch(e){r.error("[Pillar] Failed to load conversation:",e),oo()}}};var po=Object.freeze({__proto__:null,activeRequestId:Qa,addAssistantMessage:zl,addCardSegment:ol,addHiddenUserMessage:Tl,addOptimisticConversation:so,addPendingImage:wl,addProgressEvent:Hl,addProgressEventToLastMessage:al,addUserContext:Ql,addUserMessage:El,appendTokenToSegments:ll,chatError:Za,clearChatError:el,clearInterruptedSession:Ul,clearPendingHiddenMessage:Vl,clearPendingImages:Cl,clearPendingImagesForNavigation:to,clearPendingMessage:ql,clearPendingUserContext:Yl,clearProgressStatus:Dl,clearUserContext:Xl,conversationId:Ua,currentActions:pl,currentSources:cl,finalizeActiveProgressEvents:jl,focusInputTrigger:fl,getReadyImages:yl,getRegisteredActions:()=>Ba.value,getStoredConversationId:function(){if("undefined"==typeof window)return null;try{const e=localStorage.getItem(Wa);if(!e)return null;try{const t=JSON.parse(e);if(t.id&&t.lastActiveAt){return Date.now()-t.lastActiveAt>18e4?(localStorage.removeItem(Wa),null):t.id}}catch{}return localStorage.removeItem(Wa),null}catch{return null}},hasMessages:Pl,historyInvalidationCounter:Fa,interruptedSession:tl,isExpanded:sl,isLoading:Ga,isLoadingHistory:Xa,isUploadingImages:xl,loadConversation:lo,messages:Na,optimisticConversations:qa,pendingHiddenMessage:hl,pendingImages:_l,pendingImagesForNavigation:vl,pendingMessage:ul,pendingUserContext:bl,prefillText:dl,progressEvents:il,progressStatus:rl,registeredActions:Ba,removeLastEmptyAssistantMessage:Bl,removePendingImage:Sl,removeUserContext:Jl,resetChat:no,selectConversationById:co,setActionComplete:Ml,setActionPending:Il,setActiveRequestId:Ja,setChatError:Ya,setConversationId:$l,setInterruptedSession:Nl,setLoading:Ol,setMessageFeedback:Ll,setPendingHiddenMessage:Wl,setPendingImagesForNavigation:eo,setPendingMessage:Fl,setPendingUserContext:Zl,setRegisteredActions:e=>{Ba.value=e},startLoadingHistory:ro,stopLoadingHistory:oo,submitPendingTrigger:gl,tokenUsage:nl,triggerInputFocus:Gl,triggerSubmitPending:Kl,updateActionMessageContent:Al,updateImageStatus:kl,updateLastAssistantMessage:Rl,updateTokenUsage:e=>{nl.value=e},userContext:ml});const uo=Mi([]),ho=Mi({type:"home"}),go=Di(()=>uo.value.length>0),fo=Di(()=>"home"===ho.value.type),mo=(e,t)=>{uo.value=[...uo.value,{...ho.value}],ho.value={type:e,params:t}},bo=()=>{const e=uo.value;if(e.length>0){"chat"===ho.value.type&&no();const t=e[e.length-1];ho.value=t,uo.value=e.slice(0,-1)}},vo=()=>{"chat"===ho.value.type&&no(),uo.value=[],ho.value={type:"home"}},_o=()=>{uo.value=[],ho.value={type:"home"}},xo=()=>{mo("chat"),Kl()};var yo=Object.freeze({__proto__:null,canGoBack:go,currentView:ho,goBack:bo,goHome:vo,isAtHome:fo,navigate:mo,navigateToChat:xo,resetRouter:_o,viewStack:uo});const wo=["/* ============================================================================\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 /* Focus/outline */\n --pillar-outline-color: rgba(37, 99, 235, 0.15);\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 /* Status colors */\n --pillar-success: #059669;\n --pillar-error: #dc2626;\n --pillar-warning: #d97706;\n \n /* Status backgrounds (light tints) */\n --pillar-success-light: #ecfdf5;\n --pillar-success-border: #6ee7b7;\n --pillar-error-light: #fef2f2;\n --pillar-error-border: #fca5a5;\n --pillar-warning-light: #fef3c7;\n --pillar-warning-border: #fcd34d;\n \n /* Hover */\n --pillar-bg-hover: rgba(0, 0, 0, 0.05);\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-outline-color: rgba(96, 165, 250, 0.25);\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-success: #34d399;\n --pillar-error: #f87171;\n --pillar-warning: #fbbf24;\n \n --pillar-success-light: rgba(52, 211, 153, 0.1);\n --pillar-success-border: rgba(52, 211, 153, 0.3);\n --pillar-error-light: rgba(248, 113, 113, 0.1);\n --pillar-error-border: rgba(248, 113, 113, 0.3);\n --pillar-warning-light: rgba(251, 191, 36, 0.1);\n --pillar-warning-border: rgba(251, 191, 36, 0.3);\n \n --pillar-bg-hover: rgba(255, 255, 255, 0.05);\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-outline-color: rgba(96, 165, 250, 0.25);\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-success: #34d399;\n --pillar-error: #f87171;\n --pillar-warning: #fbbf24;\n \n --pillar-success-light: rgba(52, 211, 153, 0.1);\n --pillar-success-border: rgba(52, 211, 153, 0.3);\n --pillar-error-light: rgba(248, 113, 113, 0.1);\n --pillar-error-border: rgba(248, 113, 113, 0.3);\n --pillar-warning-light: rgba(251, 191, 36, 0.1);\n --pillar-warning-border: rgba(251, 191, 36, 0.3);\n \n --pillar-bg-hover: rgba(255, 255, 255, 0.05);\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\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 overflow-wrap: anywhere;\n word-break: break-word;\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 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 overflow: hidden;\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--full-width {\n width: 100vw;\n max-width: 100vw;\n}\n\n/* ============================================================================\n Mobile Bottom Sheet\n When viewport < mobileBreakpoint, the panel slides up from the bottom\n like an iOS sheet instead of from the side.\n ============================================================================ */\n\n._pillar-panel--mobile {\n top: auto;\n bottom: 0;\n left: 0;\n right: 0;\n width: 100vw;\n max-width: 100vw;\n height: 90dvh;\n max-height: 90dvh;\n border-left: none;\n border-right: none;\n border-top: none;\n border-radius: 12px 12px 0 0;\n box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15);\n overflow: hidden;\n transform: translateY(100%);\n /* iOS spring animation: fast acceleration, gradual deceleration with subtle settle */\n transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);\n will-change: transform;\n}\n\n._pillar-panel--mobile._pillar-panel--open {\n transform: translateY(0);\n}\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}\n.pillar-panel-root {\n}\n.pillar-panel-ui {\n}\n\n/* ============================================================================\n Backdrop\n ============================================================================ */\n\n._pillar-backdrop {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.4);\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1),\n visibility 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n z-index: 99998;\n -webkit-tap-highlight-color: transparent;\n}\n\n._pillar-backdrop--visible {\n opacity: 1;\n visibility: visible;\n}\n\n.pillar-backdrop {\n}\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/* ============================================================================\n Resize Handle\n Appears on the content-facing edge of the panel for drag-to-resize.\n Internal: _pillar-resize-handle | Public: pillar-resize-handle\n ============================================================================ */\n\n._pillar-resize-handle {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 6px;\n cursor: col-resize;\n z-index: 1;\n touch-action: none;\n}\n\n/* Right panel: handle on left edge */\n._pillar-panel--right ._pillar-resize-handle {\n left: -3px;\n}\n\n/* Left panel: handle on right edge */\n._pillar-panel--left ._pillar-resize-handle {\n right: -3px;\n}\n\n/* Visible indicator line on hover */\n._pillar-resize-handle::after {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n width: 3px;\n left: 50%;\n transform: translateX(-50%);\n background: transparent;\n transition: background 0.15s ease;\n border-radius: 1.5px;\n}\n\n._pillar-resize-handle:hover::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.5;\n}\n\n/* During active resize, keep indicator visible */\n._pillar-panel--resizing ._pillar-resize-handle::after {\n background: var(--pillar-primary, #2563eb);\n opacity: 0.7;\n}\n\n/* Override cursor on the whole panel during resize */\n._pillar-panel--resizing,\n._pillar-panel--resizing * {\n cursor: col-resize !important;\n}\n\n/* Disable panel slide transition during resize for immediate feedback */\n._pillar-panel--resizing {\n transition: none !important;\n}\n\n/* Hide resize handle in mobile/full-width modes */\n._pillar-panel--mobile ._pillar-resize-handle,\n._pillar-panel--full-width ._pillar-resize-handle {\n display: none;\n}\n\n.pillar-resize-handle {\n}\n\n/* ============================================================================\n Reduced Motion\n Disable all panel and backdrop transitions when the user prefers reduced motion.\n ============================================================================ */\n\n@media (prefers-reduced-motion: reduce) {\n ._pillar-panel,\n ._pillar-panel--mobile,\n ._pillar-backdrop {\n transition: none;\n }\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 height: 44px;\n padding: 0 var(--pillar-spacing-md);\n flex-shrink: 0;\n background: var(--pillar-bg);\n}\n\n._pillar-panel--mobile ._pillar-header {\n position: relative;\n height: auto;\n min-height: 48px;\n padding: 20px var(--pillar-spacing-md) 8px;\n cursor: grab;\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n}\n\n/* ---- Drag indicator (iOS-style pill) ---- */\n\n._pillar-drag-indicator {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n display: flex;\n justify-content: center;\n padding: 6px 0 0;\n pointer-events: none;\n}\n\n._pillar-drag-indicator-pill {\n width: 36px;\n height: 5px;\n border-radius: 2.5px;\n background: var(--pillar-text-muted);\n opacity: 0.4;\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._pillar-header-right {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-xs);\n}\n\n/* Public override classes */\n.pillar-header {\n}\n.pillar-header-left {\n}\n.pillar-header-right {\n}\n.pillar-header-title {\n}\n.pillar-new-chat-btn {\n}\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:\n color var(--pillar-transition-fast),\n background var(--pillar-transition-fast);\n}\n\n._pillar-icon-btn:hover {\n color: var(--pillar-text);\n}\n\n._pillar-icon-btn svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-icon-btn {\n}\n.pillar-back-btn {\n}\n.pillar-home-btn {\n}\n.pillar-history-btn {\n}\n\n/* ============================================================================\n History Dropdown\n Internal: _pillar-history-* | Public: pillar-history-*\n ============================================================================ */\n\n._pillar-history-dropdown {\n position: relative;\n}\n\n._pillar-history-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: var(--pillar-spacing-xs);\n width: 280px;\n max-height: 400px;\n background: var(--pillar-bg);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);\n overflow: hidden;\n z-index: 100;\n}\n\n._pillar-history-loading {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-xl);\n color: var(--pillar-text-muted);\n font-size: 13px;\n}\n\n._pillar-history-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 {\n transform: rotate(360deg);\n }\n}\n\n._pillar-history-empty {\n padding: var(--pillar-spacing-xl);\n text-align: center;\n color: var(--pillar-text-muted);\n font-size: 13px;\n}\n\n._pillar-history-list {\n max-height: 360px;\n overflow-y: auto;\n padding: var(--pillar-spacing-xs) 0;\n}\n\n._pillar-history-group-header {\n padding: var(--pillar-spacing-xs) var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-sm);\n font-size: 10px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n letter-spacing: 0.02em;\n}\n\n._pillar-history-group-header:first-child {\n padding-top: var(--pillar-spacing-xs);\n}\n\n._pillar-history-item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: var(--pillar-spacing-xs) var(--pillar-spacing-md);\n background: none;\n border: none;\n text-align: left;\n cursor: pointer;\n transition: background var(--pillar-transition-fast);\n border-radius: var(--pillar-radius-sm);\n margin: 0 var(--pillar-spacing-xs);\n width: calc(100% - var(--pillar-spacing-sm));\n}\n\n._pillar-history-item:hover {\n background: var(--pillar-bg-secondary);\n}\n\n._pillar-history-item-title {\n font-size: 13px;\n color: var(--pillar-text);\n line-height: 1.4;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 100%;\n}\n\n/* ============================================================================\n History Dropdown – Mobile Overlay\n When inside a mobile panel, the dropdown becomes a full-screen overlay\n within the panel instead of a small positioned menu.\n ============================================================================ */\n\n._pillar-history-menu--mobile {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n max-width: 100%;\n height: 100%;\n max-height: 100%;\n margin-top: 0;\n border: none;\n border-radius: 0;\n box-shadow: none;\n z-index: 200;\n display: flex;\n flex-direction: column;\n}\n\n._pillar-history-mobile-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 48px;\n padding: 0 var(--pillar-spacing-md);\n border-bottom: 1px solid var(--pillar-border);\n flex-shrink: 0;\n}\n\n._pillar-history-mobile-title {\n font-size: 16px;\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-history-mobile-close {\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: none;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition:\n color var(--pillar-transition-fast),\n background var(--pillar-transition-fast);\n}\n\n._pillar-history-mobile-close:hover,\n._pillar-history-mobile-close:active {\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n}\n\n._pillar-history-mobile-close svg {\n width: 20px;\n height: 20px;\n}\n\n/* Mobile: larger list area fills remaining space */\n._pillar-history-menu--mobile ._pillar-history-list {\n flex: 1;\n max-height: none;\n padding: var(--pillar-spacing-sm) 0;\n -webkit-overflow-scrolling: touch;\n}\n\n/* Mobile: larger group headers */\n._pillar-history-menu--mobile ._pillar-history-group-header {\n font-size: 12px;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n}\n\n._pillar-history-menu--mobile ._pillar-history-group-header:first-child {\n padding-top: var(--pillar-spacing-sm);\n}\n\n/* Mobile: larger touch targets (min 44px) */\n._pillar-history-menu--mobile ._pillar-history-item {\n min-height: 44px;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n margin: 0 var(--pillar-spacing-sm);\n width: calc(100% - var(--pillar-spacing-md));\n border-radius: var(--pillar-radius-md);\n}\n\n._pillar-history-menu--mobile ._pillar-history-item:active {\n background: var(--pillar-bg-secondary);\n}\n\n/* Mobile: slightly larger item text */\n._pillar-history-menu--mobile ._pillar-history-item-title {\n font-size: 15px;\n}\n\n/* Mobile: loading / empty states get more breathing room */\n._pillar-history-menu--mobile ._pillar-history-loading,\n._pillar-history-menu--mobile ._pillar-history-empty {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 15px;\n}\n\n/* Public override classes */\n.pillar-history-dropdown {\n}\n.pillar-history-menu {\n}\n.pillar-history-group-header {\n}\n.pillar-history-list {\n}\n.pillar-history-item {\n}\n.pillar-history-item-title {\n}\n.pillar-close-btn {\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 /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-search-input {\n font-size: var(--pillar-font-size-base);\n }\n}\n\n._pillar-search-input:focus {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px var(--pillar-outline-color);\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 var(--pillar-outline-color);\n}\n\n._pillar-chat-input-textarea {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-chat-input-textarea {\n font-size: var(--pillar-font-size-base);\n }\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 Chat Image Upload\n ============================================================================ */\n\n._pillar-chat-view-input-area--dragging {\n position: relative;\n background: var(--pillar-primary-light);\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: var(--pillar-primary-light);\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 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:\n border-color var(--pillar-transition-fast),\n 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 1px var(--pillar-outline-color);\n}\n\n._pillar-unified-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-unified-input {\n font-size: var(--pillar-font-size-base);\n }\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 align-items: flex-end;\n padding: 4px 8px 0px 8px;\n}\n\n._pillar-unified-input-actions {\n padding-bottom: 8px;\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}\n.pillar-unified-input {\n}\n.pillar-unified-input-row {\n}\n.pillar-unified-send-btn {\n}\n\n._pillar-unified-stop-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-unified-stop-btn:hover {\n opacity: 0.9;\n}\n\n._pillar-unified-stop-btn svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-unified-stop-btn {\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","/* 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: var(--pillar-primary);\n color: #ffffff;\n border-color: var(--pillar-primary);\n}\n\n.pillar-task-btn--primary:hover {\n background: var(--pillar-primary-hover);\n border-color: var(--pillar-primary-hover);\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n border-color: var(--pillar-border);\n}\n\n.pillar-task-btn--default:hover {\n background: var(--pillar-border);\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: var(--pillar-primary-light);\n color: var(--pillar-primary);\n border-color: var(--pillar-primary-light-hover);\n}\n\n.pillar-task-btn--secondary:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: var(--pillar-primary);\n border-color: var(--pillar-primary);\n}\n\n.pillar-task-btn--outline:hover {\n background: var(--pillar-primary-light);\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: var(--pillar-text-muted);\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n}\n\n/* Active state for inline_ui buttons with expanded card */\n.pillar-task-btn--active {\n background: var(--pillar-primary-hover);\n border-color: var(--pillar-primary-hover);\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/* Inline card container for inline_ui actions */\n.pillar-task-btn-inline-card {\n margin-top: 12px;\n animation: pillar-slide-down 0.15s ease-out;\n}\n\n@keyframes pillar-slide-down {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\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: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\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: var(--pillar-text-muted);\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: var(--pillar-text-secondary);\n}\n","/* Workflow Checklist Container */\n.pillar-workflow {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\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: var(--pillar-text-muted);\n}\n\n.pillar-workflow__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n.pillar-workflow__progress {\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n padding: 2px 8px;\n background: var(--pillar-border);\n border-radius: 10px;\n}\n\n.pillar-workflow__description {\n font-size: 13px;\n color: var(--pillar-text-muted);\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: var(--pillar-bg);\n border: 1px solid var(--pillar-border);\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: var(--pillar-text-placeholder);\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: var(--pillar-text-secondary);\n}\n\n.pillar-workflow-step__note {\n font-size: 12px;\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-workflow-step__status-text {\n font-size: 12px;\n color: var(--pillar-primary);\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: var(--pillar-warning-light);\n border-color: var(--pillar-warning-border);\n}\n\n.pillar-workflow-step--awaiting_initiation .pillar-workflow-step__icon {\n color: var(--pillar-warning);\n}\n\n.pillar-workflow-step--active {\n background: var(--pillar-primary-light);\n border-color: var(--pillar-primary);\n}\n\n.pillar-workflow-step--active .pillar-workflow-step__icon {\n color: var(--pillar-primary);\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__icon {\n color: var(--pillar-success);\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__label {\n text-decoration: line-through;\n color: var(--pillar-text-muted);\n}\n\n.pillar-workflow-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__icon {\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__label {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-workflow-step--failed {\n background: var(--pillar-error-light);\n border-color: var(--pillar-error-border);\n}\n\n.pillar-workflow-step--failed .pillar-workflow-step__icon {\n color: var(--pillar-error);\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: var(--pillar-primary);\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: var(--pillar-primary-hover);\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: var(--pillar-text-muted);\n border: 1px solid var(--pillar-border);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__skip-btn:hover {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text-secondary);\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 var(--pillar-border);\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: var(--pillar-text-placeholder);\n border: none;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow__cancel-btn:hover {\n color: var(--pillar-error);\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-md);\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 var(--pillar-outline-color);\n}\n\n._pillar-home-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-home-view-input {\n font-size: var(--pillar-font-size-base);\n }\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 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 overflow-x: hidden;\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: flex-start;\n padding: var(--pillar-spacing-xl);\n text-align: center;\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/* History Loading Skeleton */\n._pillar-chat-history-loading {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-lg);\n padding: var(--pillar-spacing-md) 0;\n}\n\n._pillar-chat-history-loading-message {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-xs);\n}\n\n._pillar-chat-history-loading-message--user {\n align-items: flex-end;\n}\n\n._pillar-chat-history-loading-message--assistant {\n align-items: flex-start;\n}\n\n._pillar-chat-history-loading-bar {\n height: 16px;\n border-radius: var(--pillar-radius-md);\n background: linear-gradient(90deg, var(--pillar-bg-secondary) 25%, var(--pillar-border) 50%, var(--pillar-bg-secondary) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n}\n\n._pillar-chat-history-loading-message--user ._pillar-chat-history-loading-bar {\n background: linear-gradient(90deg, var(--pillar-bg-secondary) 25%, var(--pillar-border) 50%, var(--pillar-bg-secondary) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n}\n\n.pillar-chat-history-loading {}\n.pillar-chat-history-loading-message--user {}\n.pillar-chat-history-loading-message--assistant {}\n.pillar-chat-history-loading-bar {}\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 text-align: left;\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.45;\n color: var(--pillar-text-secondary);\n overflow-wrap: anywhere;\n max-width: 100%;\n}\n\n._pillar-message-assistant p {\n margin: 0 0 var(--pillar-spacing-sm);\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-md) 0 var(--pillar-spacing-xs);\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: 10px 0 4px;\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-sm) 0 4px;\n}\n\n._pillar-message-assistant ul,\n._pillar-message-assistant ol {\n margin: 0 0 var(--pillar-spacing-sm);\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: 2px;\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 overflow-wrap: anywhere;\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: 0 var(--pillar-spacing-xl) var(--pillar-spacing-xl);\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 var(--pillar-outline-color);\n}\n\n._pillar-chat-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n /* 16px on mobile prevents iOS zoom on focus */\n font-size: 16px;\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@media (min-width: 768px) {\n ._pillar-chat-view-input {\n font-size: var(--pillar-font-size-base);\n }\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 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-start;\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 flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n min-width: 0;\n overflow: hidden;\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: var(--pillar-success);\n}\n\n._pillar-action-status-indicator--failed {\n color: var(--pillar-error);\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/* Card segment (inline tool result cards) */\n._pillar-card-segment {\n margin: 8px 0;\n border-radius: var(--pillar-radius-lg, 12px);\n overflow: hidden;\n width: 100%;\n}\n\n.pillar-card-segment {}\n","/* ============================================================================\n Resume Prompt (Session Resumption)\n Internal: _pillar-resume-prompt | Public: pillar-resume-prompt\n Shows when user reconnects and has an interrupted session to resume\n ============================================================================ */\n\n._pillar-resume-prompt {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-md);\n padding: var(--pillar-spacing-lg);\n margin: var(--pillar-spacing-md) 0;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n}\n\n._pillar-resume-prompt--seamless {\n flex-direction: row;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n background: transparent;\n border: none;\n justify-content: center;\n}\n\n._pillar-resume-prompt-spinner {\n width: 16px;\n height: 16px;\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 flex-shrink: 0;\n}\n\n._pillar-resume-prompt-text {\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n font-style: italic;\n}\n\n._pillar-resume-prompt-content {\n display: flex;\n gap: var(--pillar-spacing-md);\n align-items: flex-start;\n}\n\n._pillar-resume-prompt-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n flex-shrink: 0;\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-md);\n}\n\n._pillar-resume-prompt-body {\n flex: 1;\n min-width: 0;\n}\n\n._pillar-resume-prompt-title {\n font-size: var(--pillar-font-size-base);\n font-weight: 600;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-resume-prompt-message {\n display: flex;\n flex-direction: column;\n gap: 2px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n}\n\n._pillar-resume-prompt-user-msg {\n font-style: italic;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n._pillar-resume-prompt-summary {\n font-size: var(--pillar-font-size-xs);\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-resume-prompt-actions {\n display: flex;\n gap: var(--pillar-spacing-sm);\n justify-content: flex-end;\n}\n\n._pillar-resume-prompt-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n font-family: var(--pillar-font-family);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n border: 1px solid transparent;\n}\n\n._pillar-resume-prompt-btn--primary {\n background: var(--pillar-primary);\n color: #ffffff;\n border-color: var(--pillar-primary);\n}\n\n._pillar-resume-prompt-btn--primary:hover {\n background: var(--pillar-primary-hover);\n border-color: var(--pillar-primary-hover);\n}\n\n._pillar-resume-prompt-btn--ghost {\n background: transparent;\n color: var(--pillar-text-muted);\n border-color: transparent;\n}\n\n._pillar-resume-prompt-btn--ghost:hover {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n}\n\n._pillar-resume-prompt-btn svg {\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n}\n\n.pillar-resume-prompt {}\n.pillar-resume-prompt-spinner {}\n.pillar-resume-prompt-text {}\n.pillar-resume-prompt-content {}\n.pillar-resume-prompt-icon {}\n.pillar-resume-prompt-body {}\n.pillar-resume-prompt-title {}\n.pillar-resume-prompt-message {}\n.pillar-resume-prompt-user-msg {}\n.pillar-resume-prompt-summary {}\n.pillar-resume-prompt-actions {}\n.pillar-resume-prompt-btn {}\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 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._pillar-thinking-shimmer {\n display: inline-block;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n background: linear-gradient(\n 90deg,\n var(--pillar-text-muted) 0%,\n var(--pillar-text-primary, #e5e5e5) 40%,\n var(--pillar-text-muted) 60%\n );\n background-size: 200% 100%;\n -webkit-background-clip: text;\n background-clip: text;\n -webkit-text-fill-color: transparent;\n animation: pillar-shimmer 2s ease-in-out infinite;\n}\n\n.pillar-thinking-shimmer {}\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 Progress Row (for search, query, generating events)\n Internal: _pillar-progress-row | Public: pillar-progress-row\n ============================================================================ */\n\n._pillar-progress-events {\n margin: 4px 0;\n}\n\n._pillar-progress-row {\n margin: 1px 0;\n padding: 1px 0;\n font-size: 12px;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-progress-row--error {\n color: var(--pillar-error);\n}\n\n@keyframes pillar-progress-row-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n._pillar-progress-row-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n}\n\n._pillar-progress-expand-icon {\n font-size: 10px;\n color: var(--pillar-text-muted);\n transition: transform 0.2s ease;\n flex-shrink: 0;\n}\n\n._pillar-progress-row-header[style*=\"cursor: pointer\"]:hover ._pillar-progress-expand-icon {\n color: var(--pillar-text-secondary);\n}\n\n._pillar-progress-row-header[data-expanded=\"true\"] ._pillar-progress-expand-icon {\n transform: rotate(90deg);\n}\n\n._pillar-progress-message {\n color: var(--pillar-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n._pillar-progress-no-results {\n color: var(--pillar-text-muted);\n font-size: 11px;\n font-style: italic;\n margin-left: 4px;\n}\n\n._pillar-progress-sources {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n._pillar-progress-source-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 11px;\n}\n\n._pillar-progress-source-link {\n flex: 1;\n display: flex;\n flex-direction: column;\n text-decoration: none;\n overflow: hidden;\n color: inherit;\n}\n\n._pillar-progress-source-link:hover ._pillar-progress-source-title {\n text-decoration: underline;\n}\n\n._pillar-progress-source-title {\n font-weight: 400;\n color: var(--pillar-text-muted);\n font-size: 11px;\n}\n\n._pillar-progress-details {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n._pillar-progress-detail-item {\n font-size: 11px;\n color: var(--pillar-text-muted);\n padding: 1px 0;\n}\n\n._pillar-progress-detail-action {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n}\n\n._pillar-progress-detail-name {\n font-weight: 500;\n}\n\n._pillar-progress-detail-desc {\n color: var(--pillar-text-muted);\n opacity: 0.8;\n}\n\n._pillar-progress-content-wrapper {\n position: relative;\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease-out;\n}\n\n._pillar-progress-content-wrapper--expanded {\n grid-template-rows: 1fr;\n margin-top: 6px;\n}\n\n._pillar-progress-content-container {\n overflow: hidden;\n min-height: 0;\n scrollbar-width: thin;\n scrollbar-color: var(--pillar-scrollbar-thumb) transparent;\n}\n\n._pillar-progress-content-wrapper--expanded ._pillar-progress-content-container {\n max-height: 180px;\n overflow-y: auto;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar {\n width: 4px;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-track {\n background: transparent;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-thumb {\n background-color: var(--pillar-scrollbar-thumb);\n border-radius: 2px;\n}\n\n._pillar-progress-content-gradient {\n position: absolute;\n bottom: 0;\n left: 16px;\n right: 0;\n height: 20px;\n background: linear-gradient(transparent, var(--pillar-bg));\n pointer-events: none;\n}\n\n._pillar-progress-text {\n font-size: 11px;\n color: var(--pillar-text-muted);\n line-height: 1.4;\n word-break: break-word;\n}\n\n._pillar-progress-text p {\n margin: 0 0 4px 0;\n}\n\n._pillar-progress-text p:last-child {\n margin-bottom: 0;\n}\n\n._pillar-progress-text ol,\n._pillar-progress-text ul {\n margin: 2px 0;\n padding-left: 16px;\n}\n\n._pillar-progress-text li {\n margin-bottom: 1px;\n}\n\n._pillar-progress-text br {\n display: block;\n content: \"\";\n margin-top: 2px;\n}\n\n/* Chevron indicator for progress rows - rotates based on expanded state */\n/* Positioned inline next to label, hidden by default, shown on hover */\n._pillar-progress-chevron {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n color: var(--pillar-text-muted);\n transition: transform 0.2s ease, opacity 0.15s ease;\n opacity: 0;\n}\n\n._pillar-progress-row:hover ._pillar-progress-chevron {\n opacity: 1;\n}\n\n._pillar-progress-error-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n color: var(--pillar-error);\n}\n\n/* Tool call arguments (inputs) */\n._pillar-progress-arguments {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 10px;\n margin-bottom: 6px;\n font-size: 11px;\n line-height: 1.4;\n}\n\n._pillar-progress-argument-key {\n color: var(--pillar-text-muted);\n}\n\n._pillar-progress-argument-value {\n color: var(--pillar-text-secondary);\n}\n\n/* Text preview for streaming content */\n._pillar-progress-text-preview-wrapper {\n position: relative;\n margin-top: 4px;\n}\n\n._pillar-progress-text-preview {\n max-height: 180px;\n overflow-y: auto;\n font-size: 11px;\n color: var(--pillar-text-muted);\n line-height: 1.4;\n scroll-behavior: smooth;\n white-space: pre-wrap;\n word-break: break-word;\n scrollbar-width: thin;\n scrollbar-color: var(--pillar-scrollbar-thumb) transparent;\n}\n\n/* All content inside progress text preview should stay muted and small.\n Markdown headers, paragraphs, etc. must not look like answer text. */\n._pillar-progress-text-preview * {\n color: inherit !important;\n font-size: inherit !important;\n font-weight: normal !important;\n line-height: inherit !important;\n margin: 0 !important;\n}\n\n/* Top gradient - fades out older text at the top */\n._pillar-progress-text-gradient {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 20px;\n background: linear-gradient(to bottom, var(--pillar-bg), transparent);\n pointer-events: none;\n z-index: 1;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar {\n width: 4px;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar-track {\n background: transparent;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar-thumb {\n background-color: var(--pillar-scrollbar-thumb);\n border-radius: 2px;\n}\n\n/* Active state indicator */\n._pillar-progress-row--active ._pillar-progress-message {\n font-weight: 500;\n}\n\n/* Long text truncation for labels */\n._pillar-progress-message {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 300px;\n}\n\n/* Children/sub-items styling */\n._pillar-progress-children {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n._pillar-progress-child-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 11px;\n}\n\n._pillar-progress-child-link {\n color: var(--pillar-text-muted);\n text-decoration: none;\n transition: color 0.15s ease;\n}\n\n._pillar-progress-child-link:hover {\n color: var(--pillar-text-secondary);\n text-decoration: underline;\n}\n\n._pillar-progress-child-label {\n color: var(--pillar-text-muted);\n font-size: 11px;\n}\n\n/* ============================================================================\n Progress Group (collapsible tool event groups)\n Internal: _pillar-progress-group | Public: pillar-progress-group\n ============================================================================ */\n\n._pillar-progress-group {\n margin: 1px 0;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-progress-group-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 3px 0;\n cursor: pointer;\n font-size: 12px;\n color: var(--pillar-text-secondary, #6b7280);\n user-select: none;\n border-radius: 4px;\n transition: color 0.15s ease;\n}\n\n._pillar-progress-group-chevron {\n flex-shrink: 0;\n font-size: 8px;\n line-height: 1;\n color: inherit;\n}\n\n._pillar-progress-group-summary {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n._pillar-progress-group-active-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--pillar-primary, #3b82f6);\n flex-shrink: 0;\n animation: pillar-progress-group-pulse 1.5s ease-in-out infinite;\n}\n\n@keyframes pillar-progress-group-pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.4; }\n}\n\n._pillar-progress-group-children {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease;\n overflow: hidden;\n}\n\n._pillar-progress-group-children--expanded {\n grid-template-rows: 1fr;\n}\n\n._pillar-progress-group-children-inner {\n min-height: 0;\n padding-left: 14px;\n}\n\n/* Nested rows inside groups have reduced spacing */\n._pillar-progress-row--nested {\n margin: 0;\n padding: 0;\n}\n\n._pillar-progress-row--nested ._pillar-progress-row-header {\n padding: 2px 0;\n}\n\n._pillar-progress-row--nested ._pillar-progress-message {\n font-size: 11px;\n}\n\n/* ============================================================================\n Error Row (shown when MCP request fails)\n Internal: _pillar-error-row | Public: pillar-error-row\n ============================================================================ */\n\n._pillar-error-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin: 4px 0;\n padding: 2px 0;\n font-size: 12px;\n color: var(--pillar-error);\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-error-row-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n}\n\n._pillar-error-row-message {\n font-size: 12px;\n font-style: italic;\n}\n\n._pillar-error-row-retry {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin-left: 4px;\n padding: 1px 8px;\n font-size: 11px;\n color: var(--pillar-error);\n background: none;\n border: 1px solid color-mix(in srgb, var(--pillar-error) 30%, transparent);\n border-radius: 4px;\n cursor: pointer;\n transition: background 0.15s ease, border-color 0.15s ease;\n font-family: inherit;\n line-height: 1.4;\n}\n\n._pillar-error-row-retry:hover {\n background: color-mix(in srgb, var(--pillar-error) 8%, transparent);\n border-color: color-mix(in srgb, var(--pillar-error) 50%, transparent);\n}\n\n._pillar-error-row-retry svg {\n flex-shrink: 0;\n}\n\n.pillar-error-row {}\n.pillar-error-row-icon {}\n.pillar-error-row-message {}\n.pillar-error-row-retry {}\n\n.pillar-progress-events {}\n.pillar-progress-chevron {}\n.pillar-progress-error-icon {}\n.pillar-progress-text-preview-wrapper {}\n.pillar-progress-text-preview {}\n.pillar-progress-text-gradient {}\n.pillar-progress-children {}\n.pillar-progress-child-item {}\n.pillar-progress-child-link {}\n.pillar-progress-child-label {}\n.pillar-progress-row {}\n.pillar-progress-row-header {}\n.pillar-progress-expand-icon {}\n.pillar-progress-message {}\n.pillar-progress-no-results {}\n.pillar-progress-sources {}\n.pillar-progress-source-item {}\n.pillar-progress-source-link {}\n.pillar-progress-source-title {}\n.pillar-progress-arguments {}\n.pillar-progress-argument {}\n.pillar-progress-argument-key {}\n.pillar-progress-argument-value {}\n.pillar-progress-content-wrapper {}\n.pillar-progress-content-container {}\n.pillar-progress-content-gradient {}\n.pillar-progress-text {}\n.pillar-progress-group {}\n.pillar-progress-group-header {}\n.pillar-progress-group-chevron {}\n.pillar-progress-group-summary {}\n.pillar-progress-group-active-dot {}\n.pillar-progress-group-children {}\n\n/* ============================================================================\n Secret Reveal (for sensitive tool output redemption)\n Internal: _pillar-secret-reveal | Public: pillar-secret-reveal\n ============================================================================ */\n\n._pillar-secret-reveal {\n margin: 6px 0;\n font-size: 13px;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-secret-reveal-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 6px 12px;\n border: 1px solid var(--pillar-border, #e0e0e0);\n border-radius: 6px;\n background: var(--pillar-bg-secondary);\n color: var(--pillar-text, #333);\n cursor: pointer;\n font-size: 12px;\n font-family: inherit;\n transition: background 0.15s, border-color 0.15s;\n}\n\n._pillar-secret-reveal-btn:hover {\n background: var(--pillar-bg-tertiary);\n border-color: var(--pillar-border);\n}\n\n._pillar-secret-reveal-loading {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n color: var(--pillar-text-secondary, #888);\n font-size: 12px;\n}\n\n._pillar-secret-reveal-spinner {\n animation: pillar-secret-spin 1s linear infinite;\n}\n\n@keyframes pillar-secret-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n._pillar-secret-reveal-value {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 8px;\n border-radius: 6px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border, #e0e0e0);\n max-width: 100%;\n}\n\n._pillar-secret-reveal-code {\n font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;\n font-size: 11px;\n word-break: break-all;\n color: var(--pillar-text, #333);\n}\n\n._pillar-secret-reveal-copy {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 2px;\n border: none;\n background: transparent;\n color: var(--pillar-text-secondary, #888);\n cursor: pointer;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n._pillar-secret-reveal-copy:hover {\n color: var(--pillar-text, #333);\n background: var(--pillar-bg-tertiary);\n}\n\n._pillar-secret-reveal-expired,\n._pillar-secret-reveal-error {\n font-size: 12px;\n color: var(--pillar-text-secondary, #888);\n font-style: italic;\n}\n\n.pillar-secret-reveal {}\n.pillar-secret-reveal-btn {}\n.pillar-secret-reveal-value {}\n.pillar-secret-reveal-code {}\n.pillar-secret-reveal-copy {}\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}\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/* Confirmation buttons */\n.pillar-confirm-card__actions {\n display: flex;\n gap: 8px;\n margin-top: 12px;\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: 6px 14px;\n border-radius: 8px;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n border: 1px solid var(--pillar-border, #e5e7eb);\n transition: background 0.15s, border-color 0.15s, opacity 0.15s;\n}\n\n.pillar-confirm-card__btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.pillar-confirm-card__btn--cancel {\n background: var(--pillar-bg-primary, #ffffff);\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-confirm-card__btn--cancel:hover:not(:disabled) {\n background: var(--pillar-bg-secondary, #f9fafb);\n border-color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-confirm-card__btn--confirm {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border-color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-confirm-card__btn--confirm:hover:not(:disabled) {\n opacity: 0.9;\n}\n\n/* Status indicators */\n.pillar-confirm-card__status {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n font-weight: 500;\n padding: 6px 0;\n}\n\n.pillar-confirm-card__status--success {\n color: var(--pillar-success, #16a34a);\n}\n\n.pillar-confirm-card__status--error {\n color: var(--pillar-error, #dc2626);\n}\n\n/* Spinner animation */\n@keyframes pillar-spin {\n to { transform: rotate(360deg); }\n}\n\n.pillar-confirm-card__spinner {\n animation: pillar-spin 0.8s linear infinite;\n}\n","/* ============================================================================\n Markdown Component Styles\n Combined from markdown-components.tsx and preact-markdown.tsx\n ============================================================================ */\n\n/* Collapsible Section */\n._pillar-collapsible {\n margin: 2px 0;\n}\n\n._pillar-collapsible-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n background: transparent;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n font-family: inherit;\n width: 100%;\n text-align: left;\n transition: background-color 0.15s ease;\n}\n\n._pillar-collapsible-header:hover {\n background: var(--pillar-bg-hover);\n}\n\n._pillar-collapsible-icon {\n font-size: 10px;\n color: var(--pillar-text-muted, #9ca3af);\n}\n\n._pillar-collapsible-title {\n flex: 1;\n}\n\n._pillar-collapsible-content-wrapper {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease;\n}\n\n._pillar-collapsible-content-wrapper--expanded {\n grid-template-rows: 1fr;\n}\n\n._pillar-collapsible-content {\n overflow: hidden;\n padding-left: 18px;\n font-size: 13px;\n color: var(--pillar-text-secondary, #6b7280);\n line-height: 1.4;\n}\n\n._pillar-collapsible-content-wrapper--expanded ._pillar-collapsible-content {\n padding-top: 2px;\n padding-bottom: 4px;\n}\n\n/* Source List */\n._pillar-source-list {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 4px 0;\n}\n\n._pillar-source-item {\n display: block;\n padding: 4px 8px;\n font-size: 12px;\n color: var(--pillar-primary, #2563eb);\n text-decoration: none;\n border-radius: 4px;\n transition: background-color 0.15s ease;\n}\n\n._pillar-source-item:hover {\n background: var(--pillar-bg-hover);\n text-decoration: underline;\n}\n\n/* Task List */\n._pillar-task-list {\n list-style: none;\n padding: 0;\n margin: 8px 0;\n}\n\n._pillar-task-item {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 4px 0;\n font-size: 13px;\n}\n\n._pillar-task-item--completed ._pillar-task-text {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder, #9ca3af);\n}\n\n._pillar-task-checkbox {\n width: 16px;\n height: 16px;\n cursor: pointer;\n}\n\n/* Code Block */\n._pillar-code-block {\n margin: 8px 0;\n border-radius: 8px;\n overflow: hidden;\n background: var(--pillar-bg-code, #1e1e1e);\n}\n\n._pillar-code-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 12px;\n background: var(--pillar-bg-code-header, #2d2d2d);\n border-bottom: 1px solid var(--pillar-border-code, #404040);\n}\n\n._pillar-code-language {\n font-size: 11px;\n font-weight: 500;\n color: var(--pillar-text-code-header, #a0a0a0);\n text-transform: uppercase;\n}\n\n._pillar-code-copy {\n padding: 4px 8px;\n font-size: 11px;\n font-family: inherit;\n background: transparent;\n border: 1px solid var(--pillar-border-code, #404040);\n border-radius: 4px;\n color: var(--pillar-text-code-header, #a0a0a0);\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n._pillar-code-copy:hover {\n background: var(--pillar-bg-code-hover, #404040);\n color: #fff;\n}\n\n._pillar-code-pre {\n margin: 0;\n padding: 12px;\n overflow-x: auto;\n font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;\n font-size: 13px;\n line-height: 1.5;\n}\n\n._pillar-code-content {\n color: var(--pillar-text-code, #e0e0e0);\n}\n\n/* Action Buttons */\n._pillar-action-buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin: 8px 0;\n}\n\n._pillar-action-button {\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #fff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n._pillar-action-button:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Progress Indicator */\n._pillar-progress-indicator {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n font-size: 13px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n._pillar-progress-indicator--active ._pillar-loading-spinner {\n display: inline-block;\n}\n\n/* Streaming Thinking Content */\n._pillar-progress-row--streaming {\n margin: 2px 0;\n}\n\n._pillar-thinking-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n._pillar-thinking-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n}\n\n._pillar-spinner {\n width: 12px;\n height: 12px;\n border: 2px solid var(--pillar-border, #e5e7eb);\n border-top-color: var(--pillar-primary, #2563eb);\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-thinking-label {\n flex: 1;\n}\n\n._pillar-thinking-content {\n padding: 6px 10px;\n font-size: 13px;\n line-height: 1.4;\n color: var(--pillar-text-secondary, #6b7280);\n background: var(--pillar-bg-tertiary, #f9fafb);\n border-radius: 4px;\n margin-top: 2px;\n max-height: 150px;\n overflow-y: auto;\n}\n\n/* ============================================================================\n Preact Markdown Styles\n ============================================================================ */\n\n/* Base markdown container */\n._pillar-markdown {\n font-size: 14px;\n line-height: 1.45;\n color: var(--pillar-text, #1a1a1a);\n overflow-wrap: anywhere;\n}\n\n/* Headings */\n._pillar-md-heading {\n margin: 10px 0 4px 0;\n font-weight: 600;\n line-height: 1.3;\n}\n\n._pillar-md-h1 { font-size: 1.5em; }\n._pillar-md-h2 { font-size: 1.3em; }\n._pillar-md-h3 { font-size: 1.15em; }\n._pillar-md-h4 { font-size: 1em; }\n._pillar-md-h5 { font-size: 0.95em; }\n._pillar-md-h6 { font-size: 0.9em; }\n\n/* Paragraphs */\n._pillar-md-paragraph {\n margin: 4px 0;\n}\n\n/* Links */\n._pillar-md-link {\n color: var(--pillar-primary, #2563eb);\n text-decoration: none;\n}\n\n._pillar-md-link:hover {\n text-decoration: underline;\n}\n\n/* Inline code */\n._pillar-md-code-inline {\n padding: 2px 6px;\n font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;\n font-size: 0.9em;\n background: var(--pillar-bg-tertiary);\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Lists */\n._pillar-md-list {\n margin: 4px 0;\n padding-left: 24px;\n}\n\n._pillar-md-list-item {\n margin: 2px 0;\n}\n\n/* Task list items */\n._pillar-md-task-item {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n list-style: none;\n margin-left: -24px;\n}\n\n._pillar-md-task-checkbox {\n margin-top: 4px;\n}\n\n._pillar-md-task-text--checked {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder, #9ca3af);\n}\n\n/* Blockquote */\n._pillar-md-blockquote {\n margin: 8px 0;\n padding: 8px 16px;\n border-left: 3px solid var(--pillar-border, #e5e7eb);\n color: var(--pillar-text-muted, #6b7280);\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n/* Horizontal rule */\n._pillar-md-hr {\n margin: 16px 0;\n border: none;\n border-top: 1px solid var(--pillar-border, #e5e7eb);\n}\n\n/* Tables */\n._pillar-md-table-wrapper {\n overflow-x: auto;\n margin: 8px 0;\n max-width: 100%;\n}\n\n._pillar-md-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 13px;\n}\n\n._pillar-md-th,\n._pillar-md-td {\n padding: 8px 12px;\n border: 1px solid var(--pillar-border, #e5e7eb);\n text-align: left;\n min-width: 100px;\n}\n\n._pillar-md-th {\n background: var(--pillar-bg-secondary, #f9fafb);\n font-weight: 600;\n}\n\n/* Images */\n._pillar-md-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n margin: 8px 0;\n}\n"].join("\n");function ko(e,t=""){const n=[];return e.primary&&n.push(`--pillar-primary${t}: ${e.primary};`),e.primaryHover&&n.push(`--pillar-primary-hover${t}: ${e.primaryHover};`),e.background&&n.push(`--pillar-bg${t}: ${e.background};`),e.backgroundSecondary&&n.push(`--pillar-bg-secondary${t}: ${e.backgroundSecondary};`),e.text&&n.push(`--pillar-text${t}: ${e.text};`),e.textMuted&&n.push(`--pillar-text-muted${t}: ${e.textMuted};`),e.border&&n.push(`--pillar-border${t}: ${e.border};`),e.borderLight&&n.push(`--pillar-border-light${t}: ${e.borderLight};`),e.outlineColor&&n.push(`--pillar-outline-color${t}: ${e.outlineColor};`),n.join("\n ")}function So(e){const t=ko(e.colors),n=ko(e.darkColors),r=e.fontFamily?`--pillar-font-family: ${e.fontFamily};`:"";let i="";return(t||r)&&(i+=`\n:host {\n ${[t,r].filter(Boolean).join("\n ")}\n}\n`),n&&(i+=`\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n ${n}\n }\n}\n:host([data-theme="dark"]) {\n ${n}\n}\n`),i}const Co=function(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,j(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+C++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}(null);function Po({api:e,events:t,config:n,children:r}){return Kr(Co.Provider,{value:{api:e,events:t,config:n},children:r})}function Eo(){const e=function(e){var t=Qr.context[e.__c],n=oi(Gr++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Qr)),t.props.value):e.__}(Co);if(!e)throw new Error("usePillar must be used within a PillarProvider");return e}function To(){return Eo().api}function zo(){return Eo().config}const Ro=Mi([]),Io=Mi([]),Mo=Mi(!1),Ao=Mi(null),$o=Mi(null);function Lo(e,t,n,r=3){if(0===e.length)return[];const i=e.filter(e=>function(e,t){if(!e)return!0;if(e===t)return!0;if(e.endsWith("/**")){const n=e.slice(0,-3);return t===n||t.startsWith(n+"/")}if(e.endsWith("/*")){const n=e.slice(0,-2);return!!t.startsWith(n+"/")&&!t.slice(n.length+1).includes("/")}return t.startsWith(e)}(e.pathPattern,t));if(0===i.length)return[];const a=function(e,t){const n=e.split("/").filter(Boolean).flatMap(e=>e.split(/[-_]/)),r=t.toLowerCase().split(/\s+/);return[...new Set([...n,...r])].map(e=>e.toLowerCase()).filter(e=>e.length>2)}(t,n),l=i.map(e=>({suggestion:e,score:Oo(e,a)}));return l.sort((e,t)=>t.score-e.score),l.slice(0,r).map(e=>e.suggestion)}function Oo(e,t){if(e.manual)return 1/0;const n=e.text.toLowerCase();let r=0;for(const e of t)n.includes(e)&&(r+=e.length);return r}function Do(e){Mo.value=e}Di(()=>Io.value.length>0),Di(()=>Ro.value.length>0);const jo='<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 Ho({context:e,onRemove:t,readOnly:n=!1}){const r=Ha(e),i=function(e){return Da(e),jo}(e),a=function(e){if(Da(e)){const t=e.url_origin?`\nFrom: ${e.url_origin}`:"";return`"${e.text_content}"${t}`}return""}(e);return Kr("div",{class:"_pillar-context-tag pillar-context-tag",title:a,children:[Kr("span",{class:"_pillar-context-tag-icon pillar-context-tag-icon",dangerouslySetInnerHTML:{__html:i}}),Kr("span",{class:"_pillar-context-tag-label pillar-context-tag-label",children:r}),!n&&t&&Kr("button",{class:"_pillar-context-tag-remove pillar-context-tag-remove",onClick:n=>{n.preventDefault(),n.stopPropagation(),t?.(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 No({contexts:e,onRemove:t,readOnly:n=!1}){const r=e.filter(e=>!ja(e));return 0===r.length?null:Kr("div",{class:"_pillar-context-tag-list pillar-context-tag-list",children:r.map(e=>Kr(Ho,{context:e,onRemove:t,readOnly:n},e.id))})}const Uo='<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 Bo({placeholder:e="Ask anything...",disabled:t=!1,onSubmit:n,showContextTags:r=!0,showImageUpload:i=!0,className:a="",isStreaming:l=!1,onStop:o}){const s=To(),c=pi(null),p=pi(null),[d,u]=si(""),[h,g]=si(!1),f=ui(()=>{const e=c.current;if(!e)return;e.style.height="41px";const t=e.scrollHeight;t>146?(e.style.height="146px",e.style.overflowY="auto"):(e.style.height=`${t}px`,e.style.overflowY="hidden")},[]),m=ui(async e=>{if(_l.value.length>=4)return;const t=`img-${Date.now()}-${Math.random().toString(36).slice(2)}`,n=URL.createObjectURL(e);wl({id:t,file:e,preview:n,status:"uploading"});try{const n=await s.uploadImage(e);kl(t,"ready",n.url,void 0,n.path)}catch(e){const n=e instanceof Error?e.message:"Upload failed";kl(t,"error",void 0,n)}},[s]),b=ui(e=>{const t=Array.from(e).filter(e=>e.type.startsWith("image/")),n=4-_l.value.length;t.slice(0,n).forEach(m)},[m]),v=ui(e=>{const t=e.clipboardData?.items;if(!t)return;const n=[];for(const e of t)if(e.type.startsWith("image/")){const t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),b(n))},[b]),_=ui(e=>{e.preventDefault(),e.stopPropagation(),g(!0)},[]),x=ui(e=>{e.preventDefault(),e.stopPropagation(),g(!1)},[]),y=ui(e=>{e.preventDefault(),e.stopPropagation(),g(!1);const t=e.dataTransfer?.files;t&&b(t)},[b]),w=ui(e=>{const t=e.target;t.files&&(b(t.files),t.value="")},[b]),k=ui(()=>{p.current?.click()},[]),S=ui(()=>{const e=d.trim(),t=[...ml.value],r=yl(),i=t.length>0,a=r.length>0;(e||i||a)&&(xl.value||(i&&Xl(),Cl(),n?n(e,t,r):(i&&Zl(t),a&&eo(r),Fl(e),xo()),u(""),c.current&&(c.current.style.height="41px",c.current.style.overflowY="hidden")))},[d,n]),C=xl.value,P=d.trim()||ml.value.length>0||_l.value.some(e=>"ready"===e.status);return Kr("div",{class:`_pillar-unified-input-wrapper pillar-unified-input-wrapper ${h?"_pillar-unified-input-wrapper--dragging":""} ${a}`.trim(),onDragOver:_,onDragLeave:x,onDrop:y,children:[Kr("input",{ref:p,type:"file",accept:"image/*",multiple:!0,onChange:w,style:{display:"none"}}),_l.value.length>0&&Kr("div",{class:"_pillar-chat-images-preview pillar-chat-images-preview",children:_l.value.map(e=>Kr("div",{class:"_pillar-chat-image-thumb pillar-chat-image-thumb",children:[Kr("img",{src:e.preview,alt:"Upload preview"}),"uploading"===e.status&&Kr("div",{class:"_pillar-chat-image-loading pillar-chat-image-loading",children:Kr("div",{class:"_pillar-loading-spinner pillar-loading-spinner",style:{width:"16px",height:"16px"}})}),"error"===e.status&&Kr("div",{class:"_pillar-chat-image-error pillar-chat-image-error",title:e.error,children:"!"}),Kr("button",{type:"button",class:"_pillar-chat-image-remove pillar-chat-image-remove",onClick:()=>Sl(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&&Kr(No,{contexts:ml.value,onRemove:Jl}),Kr("textarea",{ref:c,class:"_pillar-unified-input pillar-unified-input",placeholder:h?"Drop image here...":e,value:d,onInput:e=>{const t=e.target;u(t.value),f()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),S())},onPaste:v,disabled:t||l,maxLength:32e3,style:{height:"41px"}}),Kr("div",{class:"_pillar-unified-input-row pillar-unified-input-row",children:[i&&!l&&Kr("button",{type:"button",class:"_pillar-chat-image-btn pillar-chat-image-btn",onClick:k,disabled:t||C||_l.value.length>=4,"aria-label":"Attach image",title:"Attach image (max 4)",dangerouslySetInnerHTML:{__html:Uo}}),Kr("div",{class:"_pillar-unified-input-actions pillar-unified-input-actions",children:Kr("button",l?{type:"button",class:"_pillar-unified-stop-btn pillar-unified-stop-btn",onClick:o,"aria-label":"Stop generating",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>'}}:{type:"button",class:"_pillar-unified-send-btn pillar-unified-send-btn",onClick:S,disabled:t||C||!P,"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>'}})})]}),h&&Kr("div",{class:"_pillar-chat-drop-overlay pillar-chat-drop-overlay",children:[Kr("span",{dangerouslySetInnerHTML:{__html:Uo}}),Kr("span",{children:"Drop image here"})]})]})}function Fo({text:e,onClick:t}){return Kr("button",{type:"button",class:"_pillar-question-chip pillar-question-chip",onClick:t,children:[Kr("span",{class:"_pillar-question-chip-text pillar-question-chip-text",children:e}),Kr("span",{class:"_pillar-question-chip-arrow pillar-question-chip-arrow",children:"→"})]})}function qo(){return Kr("div",{class:"_pillar-question-chip-skeleton pillar-question-chip-skeleton",children:Kr("div",{class:"_pillar-question-chip-skeleton-bar pillar-question-chip-skeleton-bar"})})}function Wo(){const e=zo(),t=Ki(()=>Io.value),n=Ki(()=>Mo.value);return Kr("div",{class:"_pillar-home-view pillar-home-view",children:[e.welcomeMessage&&Kr("div",{class:"_pillar-home-view-welcome pillar-home-view-welcome",style:{fontSize:"1.25rem",fontWeight:500,padding:"16px 0"},children:e.welcomeMessage}),Kr("div",{style:{flex:1}}),Kr("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:n.value?Kr($,{children:[Kr(qo,{}),Kr(qo,{}),Kr(qo,{})]}):t.value&&t.value.length>0?t.value.map(e=>Kr(Fo,{text:e.text,onClick:()=>(e=>{Fl(e.text),xo()})(e)},e.id)):null}),Kr(Bo,{placeholder:e.inputPlaceholder})]})}const Vo=Mi(!1),Ko=Mi(null),Go=Mi(!1),Qo=Mi(null);function Jo(e,t){Vo.value=!0,Ko.value=e,Go.value=!1,Qo.value=t??null}function Xo(){Vo.value=!1,Ko.value=null,Qo.value=null}function Zo(){Go.value=!1}function Yo(){return Go.value}const es=Mi(!1),ts=Mi(null),ns=Mi(null);var rs=Object.freeze({__proto__:null,confirmationLabel:ts,confirmationResolver:ns,currentToolCallId:Qo,isCancelled:Go,isPiloting:Vo,needsConfirmation:es,pilotOperation:Ko,requestConfirmation:function(e){return new Promise(t=>{ts.value=e,ns.value=t,es.value=!0})},resetCancellation:Zo,startPiloting:Jo,stopPiloting:Xo,wasCancelled:Yo});function is(e){if(e)try{const t=as(e);localStorage.removeItem(t),p.log("[SessionPersistence] Cleared saved session")}catch(e){p.warn("[SessionPersistence] Failed to clear session:",e)}}function as(e){return`pillar:active_session:${e}`}var ls=Object.freeze({__proto__:null,clearActiveSession:is,loadActiveSession:function(e){if(!e)return p.warn("[SessionPersistence] loadActiveSession called with empty siteId"),null;try{const t=as(e),n=localStorage.getItem(t);if(!n)return p.log(`[SessionPersistence] No session found at key "${t}"`),null;const r=JSON.parse(n);return 1!==r.version?(p.warn("[SessionPersistence] Stored session has incompatible version, clearing"),is(e),null):r.siteId!==e?(p.warn("[SessionPersistence] Stored session is for different site, clearing"),is(e),null):(p.log(`[SessionPersistence] Loaded session ${r.conversationId.slice(0,8)}... from localStorage`),r)}catch(t){return p.warn("[SessionPersistence] Failed to load session:",t),is(e),null}},saveActiveSession:function(e,t){if(e&&t)try{const n={version:1,conversationId:e,siteId:t,streamingStartedAt:(new Date).toISOString()},r=as(t);localStorage.setItem(r,JSON.stringify(n)),p.log(`[SessionPersistence] Saved session ${e.slice(0,8)}... to localStorage (key="${r}")`)}catch(e){p.warn("[SessionPersistence] Failed to save session:",e)}}});function os(e){if(null==e)return{success:!0};if("object"!=typeof e||Array.isArray(e))return e;const t=e;return!1===t.success?{success:!1,error:t.error||t.message||"Action failed"}:"data"in t&&null!=t.data&&"object"==typeof t.data?t.data:e}const ss={maxDepth:20,includeText:!0,visibleOnly:!0,minTextLength:1,maxTextLength:500,maxTotalLength:5e4,maxLabelLength:100,includePositions:!1},cs=new Set(["a","button","input","select","textarea","details","summary","dialog","menu","menuitem"]),ps=new Set(["button","link","checkbox","radio","switch","tab","tabpanel","menuitem","menuitemcheckbox","menuitemradio","option","slider","spinbutton","textbox","combobox","listbox","searchbox","tree","treeitem","grid","gridcell","row","rowheader","columnheader"]),ds=new Set(["script","style","noscript","template","svg","path","iframe","object","embed","head","meta","link","base"]);let us=0;function hs(){document.querySelectorAll("[data-pillar-ref]").forEach(e=>e.removeAttribute("data-pillar-ref")),us=0}let gs=new Set,fs=new Set;function ms(e){return e instanceof HTMLInputElement&&"password"===e.type.toLowerCase()||null!==e.closest("[data-pillar-redact]")}const bs=/\b(delete|remove|destroy|reset|revoke|archive|cancel subscription|deactivate|disable|erase|purge|terminate|unsubscribe|drop)\b/i;function vs(e){if(e.hasAttribute("data-pillar-destructive"))return!0;const t=e.getAttribute("aria-label");if(t&&bs.test(t))return!0;const n=e.textContent?.trim().slice(0,200);if(n&&bs.test(n))return!0;const r=e.getAttribute("title");if(r&&bs.test(r))return!0;if(e instanceof HTMLInputElement||e instanceof HTMLButtonElement){const t=e.type?.toLowerCase();if("reset"===t||"submit"===t){const t=e.closest("form");if(t){const e=t.getAttribute("action")||"";if(bs.test(e))return!0}}}return!1}function _s(e){const t=e.tagName.toLowerCase();if(e.hasAttribute("data-pillar-interactable"))return!0;if(cs.has(t))return!0;const n=e.getAttribute("role");if(n&&ps.has(n))return!0;const r=e.getAttribute("tabindex");return null!==r&&"-1"!==r||("true"===e.getAttribute("contenteditable")||!!(e.hasAttribute("onclick")||e.hasAttribute("onkeydown")||e.hasAttribute("onkeyup")))}const xs=/^pr-[a-z0-9]+$/;function ys(e){return xs.test(e)}function ws(e){if(!ys(e))throw new Error(`Invalid pillar ref format: "${e}"`);return`[data-pillar-ref="${e}"]`}function ks(e,t){return e.length<=t?e:e.slice(0,t)+"..."}function Ss(e,t){const n=function(e){const t=e.getAttribute("aria-label");if(t)return t;const n=e.getAttribute("aria-labelledby");if(n){const e=document.getElementById(n);if(e)return e.textContent?.trim()||void 0}if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement){if(e.id){const t=document.querySelector(`label[for="${e.id}"]`);if(t)return t.textContent?.trim()||void 0}const t=e.closest("label");if(t){const e=t.cloneNode(!0);e.querySelectorAll("input, select, textarea").forEach(e=>e.remove());const n=e.textContent?.trim();if(n)return n}}const r=e.getAttribute("title");return r||void 0}(e);if(n)return ks(n,t);if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.placeholder)return ks(e.placeholder,t);const r=e.textContent?.trim();if(r&&r.length>0)return ks(r,t);const i=e.getAttribute("name");return i?ks(i,t):e.id?ks(e.id,t):e.tagName.toLowerCase()}function Cs(e,t,n){if(n>t.maxDepth&&(t.maxDepth=n),n>t.options.maxDepth)return;if(e.nodeType===Node.TEXT_NODE){if(t.options.includeText&&!t.budgetExhausted){const n=e.textContent?.trim();if(n&&n.length>=t.options.minTextLength){const e=n.length>t.options.maxTextLength?n.slice(0,t.options.maxTextLength)+"...":n,r=e.length+1;if(t.totalLength+r>t.options.maxTotalLength)return void(t.budgetExhausted=!0);t.lines.push(e),t.totalLength+=r}}return}if(e.nodeType!==Node.ELEMENT_NODE)return;const r=e,i=r.tagName.toLowerCase();if(!ds.has(i)){if(t.options.excludeSelector)try{if(r.matches(t.options.excludeSelector))return}catch{}if((!t.options.visibleOnly||function(e){if(!e.isConnected)return!1;const t=window.getComputedStyle(e);if("none"===t.display)return!1;if("hidden"===t.visibility)return!1;if("0"===t.opacity)return!1;const n=e.getBoundingClientRect();return(0!==n.width||0!==n.height)&&!e.hasAttribute("hidden")&&"true"!==e.getAttribute("aria-hidden")}(r))&&!r.hasAttribute("data-pillar-redact")){if(_s(r)){if(ms(r))return;const e=function(e){const t=e.tagName.toLowerCase(),n=e.getAttribute("data-pillar-interactable");if(n&&"true"!==n)return n;switch(t){case"input":switch(e.type.toLowerCase()){case"checkbox":case"radio":return"toggle";case"submit":case"button":case"reset":return"click";case"file":return"select";default:return"input"}case"textarea":return"input";case"select":return"select";case"button":return"submit"===e.getAttribute("type")?"submit":"click";case"a":return"click";case"details":case"summary":return"toggle"}const r=e.getAttribute("role");if(r)switch(r){case"button":case"link":case"menuitem":case"tab":default:return"click";case"checkbox":case"radio":case"switch":return"toggle";case"textbox":case"searchbox":case"combobox":case"slider":case"spinbutton":return"input";case"listbox":case"option":return"select"}return"true"===e.getAttribute("contenteditable")?"input":"click"}(r),n=Ss(r,t.options.maxLabelLength);let i=r.getAttribute("data-pillar-ref");i||(i=`pr-${(us++).toString(36)}`,r.setAttribute("data-pillar-ref",i)),t.refs.add(i);const a=`${e.toUpperCase()}: ${n} [[${i}]]`;t.lines.push(a),t.totalLength+=a.length+1,t.interactableCount++}for(const e of r.childNodes)Cs(e,t,n+1)}}}function Ps(e){hs();const t=e?.root||document.body,n={lines:[],refs:new Set,interactableCount:0,totalLength:0,budgetExhausted:!1,maxDepth:0,options:{...ss,...e}};return n.lines.push(`=== PAGE: ${document.title} | ${window.location.pathname} ===`),n.lines.push(""),Cs(t,n,0),n.lines.push(""),n.lines.push(`=== ${n.interactableCount} interactable elements ===`),gs=new Set(n.lines),fs=new Set(n.refs),{content:n.lines.join("\n"),interactableCount:n.interactableCount,timestamp:Date.now(),url:window.location.href,title:document.title}}function Es(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ts={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function zs(e){Ts=e}var Rs={exec:()=>null};function Is(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(As.caret,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ms=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),As={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")},$s=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ls=/(?:[*+-]|\d{1,9}[.)])/,Os=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ds=Is(Os).replace(/bull/g,Ls).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(),js=Is(Os).replace(/bull/g,Ls).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(),Hs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ns=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Us=Is(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ns).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Bs=Is(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ls).getRegex(),Fs="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",qs=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ws=Is("^ {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",qs).replace("tag",Fs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vs=Is(Hs).replace("hr",$s).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",Fs).getRegex(),Ks={blockquote:Is(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Vs).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:Us,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:$s,html:Ws,lheading:Ds,list:Bs,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Vs,table:Rs,text:/^[^\n]+/},Gs=Is("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",$s).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",Fs).getRegex(),Qs={...Ks,lheading:js,table:Gs,paragraph:Is(Hs).replace("hr",$s).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gs).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",Fs).getRegex()},Js={...Ks,html:Is("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",qs).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:Rs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Is(Hs).replace("hr",$s).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Ds).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Xs=/^( {2,}|\\)\n(?!\s*$)/,Zs=/[\p{P}\p{S}]/u,Ys=/[\s\p{P}\p{S}]/u,ec=/[^\s\p{P}\p{S}]/u,tc=Is(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ys).getRegex(),nc=/(?!~)[\p{P}\p{S}]/u,rc=Is(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ms?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ic=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ac=Is(ic,"u").replace(/punct/g,Zs).getRegex(),lc=Is(ic,"u").replace(/punct/g,nc).getRegex(),oc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",sc=Is(oc,"gu").replace(/notPunctSpace/g,ec).replace(/punctSpace/g,Ys).replace(/punct/g,Zs).getRegex(),cc=Is(oc,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,nc).getRegex(),pc=Is("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ec).replace(/punctSpace/g,Ys).replace(/punct/g,Zs).getRegex(),dc=Is(/\\(punct)/,"gu").replace(/punct/g,Zs).getRegex(),uc=Is(/^<(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(),hc=Is(qs).replace("(?:--\x3e|$)","--\x3e").getRegex(),gc=Is("^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",hc).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),fc=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,mc=Is(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",fc).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),bc=Is(/^!?\[(label)\]\[(ref)\]/).replace("label",fc).replace("ref",Ns).getRegex(),vc=Is(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ns).getRegex(),_c=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,xc={_backpedal:Rs,anyPunctuation:dc,autolink:uc,blockSkip:rc,br:Xs,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Rs,emStrongLDelim:ac,emStrongRDelimAst:sc,emStrongRDelimUnd:pc,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:mc,nolink:vc,punctuation:tc,reflink:bc,reflinkSearch:Is("reflink|nolink(?!\\()","g").replace("reflink",bc).replace("nolink",vc).getRegex(),tag:gc,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Rs},yc={...xc,link:Is(/^!?\[(label)\]\((.*?)\)/).replace("label",fc).getRegex(),reflink:Is(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",fc).getRegex()},wc={...xc,emStrongRDelimAst:cc,emStrongLDelim:lc,url:Is(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",_c).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:Is(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",_c).getRegex()},kc={...wc,br:Is(Xs).replace("{2,}","*").getRegex(),text:Is(wc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Sc={normal:Ks,gfm:Qs,pedantic:Js},Cc={normal:xc,gfm:wc,breaks:kc,pedantic:yc},Pc={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ec=e=>Pc[e];function Tc(e,t){if(t){if(As.escapeTest.test(e))return e.replace(As.escapeReplace,Ec)}else if(As.escapeTestNoEncode.test(e))return e.replace(As.escapeReplaceNoEncode,Ec);return e}function zc(e){try{e=encodeURI(e).replace(As.percentDecode,"%")}catch{return null}return e}function Rc(e,t){let n=e.replace(As.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"}),r=n.split(As.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(As.slashPipe,"|");return r}function Ic(e,t,n){let r=e.length;if(0===r)return"";let i=0;for(;i<r;){if(e.charAt(r-i-1)!==t)break;i++}return e.slice(0,r-i)}function Mc(e,t,n,r,i){let a=t.href,l=t.title||null,o=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let s={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:a,title:l,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,s}var Ac=class{options;rules;lexer;constructor(e){this.options=e||Ts}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Ic(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let i=r[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Ic(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ic(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Ic(t[0],"\n").split("\n"),n="",r="",i=[];for(;e.length>0;){let t,a=!1,l=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))l.push(e[t]),a=!0;else{if(a)break;l.push(e[t])}e=e.slice(t);let o=l.join("\n"),s=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${o}`:o,r=r?`${r}\n${s}`:s;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(s,i,!0),this.lexer.state.top=c,0===e.length)break;let p=i.at(-1);if("code"===p?.type)break;if("blockquote"===p?.type){let t=p,a=t.raw+"\n"+e.join("\n"),l=this.blockquote(a);i[i.length-1]=l,n=n.substring(0,n.length-t.raw.length)+l.raw,r=r.substring(0,r.length-t.text.length)+l.text;break}if("list"===p?.type){let t=p,a=t.raw+"\n"+e.join("\n"),l=this.list(a);i[i.length-1]=l,n=n.substring(0,n.length-p.raw.length)+l.raw,r=r.substring(0,r.length-t.raw.length)+l.raw,e=a.substring(i.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let a=this.rules.other.listItemRegex(n),l=!1;for(;e;){let n=!1,r="",o="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let s=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],p=!s.trim(),d=0;if(this.options.pedantic?(d=2,o=s.trimStart()):p?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,o=s.slice(d),d+=t[1].length),p&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=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(c=h,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),i.test(c)||a.test(c)||l.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=d||!c.trim())o+="\n"+u.slice(d);else{if(p||s.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(s)||a.test(s)||n.test(s))break;o+="\n"+c}!p&&!c.trim()&&(p=!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 t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.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=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));i.loose=n}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Rc(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.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<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Rc(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Ic(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Mc(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Mc(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){let n,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,t=t.slice(-1*e.length+a);null!=(r=s.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(i=[...n].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 t=[...r[0]][0].length,s=e.slice(0,a+r.index+t+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 c=s.slice(2,-2);return{type:"strong",raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},$c=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ts,this.options.tokenizer=this.options.tokenizer||new Ac,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 t={other:As,block:Sc.normal,inline:Cc.normal};this.options.pedantic?(t.block=Sc.pedantic,t.inline=Cc.pedantic):this.options.gfm&&(t.block=Sc.gfm,this.options.breaks?t.inline=Cc.breaks:t.inline=Cc.gfm),this.tokenizer.rules=t}static get rules(){return{block:Sc,inline:Cc}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(As.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(As.tabCharGlobal," ").replace(As.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&"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):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,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));)n=i[2]?i[2].length:0,r=r.slice(0,i.index+n)+"["+"a".repeat(i[0].length-n-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 n;if(a||(l=""),a=!1,this.options.extensions?.inline?.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let r=t.at(-1);"text"===n.type&&"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,r,l)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let i=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(i)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(l=n.raw.slice(-1)),a=!0;let r=t.at(-1);"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},Lc=class{options;parser;constructor(e){this.options=e||Ts}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(As.notSpaceStart)?.[0],i=e.replace(As.endingNewline,"")+"\n";return r?'<pre><code class="language-'+Tc(r)+'">'+(n?i:Tc(i,!0))+"</code></pre>\n":"<pre><code>"+(n?i:Tc(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:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,r="";for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?"ol":"ul";return"<"+i+(t&&1!==n?' start="'+n+'"':"")+">\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 t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r="";for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n="";for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\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>${Tc(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=zc(e);if(null===i)return r;let a='<a href="'+(e=i)+'"';return t&&(a+=' title="'+Tc(t)+'"'),a+=">"+r+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=zc(e);if(null===i)return Tc(n);let a=`<img src="${e=i}" alt="${n}"`;return t&&(a+=` title="${Tc(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Tc(e.text)}},Oc=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}},Dc=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ts,this.options.renderer=this.options.renderer||new Lc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Oc}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let i=r;switch(i.type){case"space":t+=this.renderer.space(i);break;case"hr":t+=this.renderer.hr(i);break;case"heading":t+=this.renderer.heading(i);break;case"code":t+=this.renderer.code(i);break;case"table":t+=this.renderer.table(i);break;case"blockquote":t+=this.renderer.blockquote(i);break;case"list":t+=this.renderer.list(i);break;case"checkbox":t+=this.renderer.checkbox(i);break;case"html":t+=this.renderer.html(i);break;case"def":t+=this.renderer.def(i);break;case"paragraph":t+=this.renderer.paragraph(i);break;case"text":t+=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 t}parseInline(e,t=this.renderer){let n="";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)){n+=e||"";continue}}let a=i;switch(a.type){case"escape":case"text":n+=t.text(a);break;case"html":n+=t.html(a);break;case"link":n+=t.link(a);break;case"image":n+=t.image(a);break;case"checkbox":n+=t.checkbox(a);break;case"strong":n+=t.strong(a);break;case"em":n+=t.em(a);break;case"codespan":n+=t.codespan(a);break;case"br":n+=t.br(a);break;case"del":n+=t.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 n}},jc=class{options;block;constructor(e){this.options=e||Ts}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?$c.lex:$c.lexInline}provideParser(){return this.block?Dc.parse:Dc.parseInline}},Hc=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=Dc;Renderer=Lc;TextRenderer=Oc;Lexer=$c;Tokenizer=Ac;Hooks=jc;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=r;n=n.concat(this.walkTokens(e.items,t));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);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),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 n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Lc(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=a.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Ac(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new jc;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];jc.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&jc.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return!1===n&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return!1===n&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return $c.lex(e,t??this.defaults)}parser(e,t){return Dc.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},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 t>"u"||null===t)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?$c.lex:$c.lexInline)(n,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?Dc.parse:Dc.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?$c.lex:$c.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Dc.parse:Dc.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Tc(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Nc(e,t){return Hc.parse(e,t)}function Uc({title:e,defaultOpen:t=!1,children:n}){const[r,i]=si(t),a=pi(null);return Kr("div",{class:"_pillar-collapsible pillar-collapsible",children:[Kr("button",{type:"button",class:"_pillar-collapsible-header pillar-collapsible-header",onClick:()=>i(!r),children:[Kr("span",{class:"_pillar-collapsible-icon pillar-collapsible-icon",style:{transform:r?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:"▶"}),Kr("span",{class:"_pillar-collapsible-title pillar-collapsible-title",children:e})]}),Kr("div",{class:"_pillar-collapsible-content-wrapper pillar-collapsible-content-wrapper "+(r?"_pillar-collapsible-content-wrapper--expanded pillar-collapsible-content-wrapper--expanded":""),children:Kr("div",{ref:a,class:"_pillar-collapsible-content pillar-collapsible-content",children:n})})]})}function Bc({sources:e}){return e&&0!==e.length?Kr("div",{class:"_pillar-source-list pillar-source-list",children:e.map((e,t)=>Kr("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-source-item pillar-source-item",children:Kr("span",{class:"_pillar-source-title pillar-source-title",children:e.title})},t))}):Kr("span",{})}function Fc({language:e,children:t}){const[n,r]=si(!1);return Kr("div",{class:"_pillar-code-block pillar-code-block",children:[e&&Kr("div",{class:"_pillar-code-header pillar-code-header",children:[Kr("span",{class:"_pillar-code-language pillar-code-language",children:e}),Kr("button",{type:"button",class:"_pillar-code-copy pillar-code-copy",onClick:async()=>{try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch(e){p.error("[Pillar] Failed to copy code:",e)}},children:n?"Copied!":"Copy"})]}),Kr("pre",{class:`_pillar-code-pre pillar-code-pre language-${e||"text"}`,children:Kr("code",{class:"_pillar-code-content pillar-code-content",children:t})})]})}function qc({message:e,isActive:t=!0}){return Kr("div",{class:"_pillar-progress-indicator pillar-progress-indicator "+(t?"_pillar-progress-indicator--active pillar-progress-indicator--active":""),children:[t&&Kr("div",{class:"_pillar-loading-spinner pillar-loading-spinner"}),Kr("span",{class:"_pillar-progress-message pillar-progress-message",children:e})]})}function Wc({content:e,class:t}){if(!e||!e.trim())return Kr("span",{});try{return Kr("div",{class:`_pillar-markdown pillar-markdown ${t||""}`,children:Vc(Nc.lexer(e))})}catch(n){return p.error("[Pillar] Markdown parsing error:",n),Kr("div",{class:`_pillar-markdown pillar-markdown ${t||""}`,children:e})}}function Vc(e){return e.map((e,t)=>function(e,t){switch(e.type){case"heading":return function(e,t){const n=`h${e.depth}`;return Kr(n,{class:`_pillar-md-heading _pillar-md-h${e.depth} pillar-md-heading pillar-md-h${e.depth}`,children:Gc(e.tokens)},t)}(e,t);case"paragraph":return function(e,t){return Kr("p",{class:"_pillar-md-paragraph pillar-md-paragraph",children:Gc(e.tokens)},t)}(e,t);case"text":return function(e,t){if(e.tokens&&e.tokens.length>0)return Kr($,{children:Gc(e.tokens)},t);return Kr($,{children:e.text},t)}(e,t);case"code":return function(e,t){const n=e.lang||"",r=e.text;if(n.startsWith("collapsible:")){return Kr(Uc,{title:n.substring(12),children:Kr(Wc,{content:r})},t)}if(n.startsWith("collapsible-open:")){return Kr(Uc,{title:n.substring(17),defaultOpen:!0,children:Kr(Wc,{content:r})},t)}if("sources"===n)try{return Kr(Bc,{sources:JSON.parse(r)},t)}catch{p.warn("[Pillar] Failed to parse sources JSON")}if(n.startsWith("progress:")){return Kr(qc,{message:n.substring(9),isActive:!0},t)}if(n.startsWith("progress-done:")){return Kr(qc,{message:n.substring(14),isActive:!1},t)}return Kr(Fc,{language:n||void 0,children:r},t)}(e,t);case"blockquote":return function(e,t){return Kr("blockquote",{class:"_pillar-md-blockquote pillar-md-blockquote",children:Vc(e.tokens)},t)}(e,t);case"list":return function(e,t){const n=e.items.map((e,t)=>Kc(e,t));if(e.ordered)return Kr("ol",{start:e.start||1,class:"_pillar-md-list _pillar-md-list--ordered pillar-md-list pillar-md-list--ordered",children:n},t);return Kr("ul",{class:"_pillar-md-list _pillar-md-list--unordered pillar-md-list pillar-md-list--unordered",children:n},t)}(e,t);case"list_item":return Kc(e,t);case"table":return function(e,t){return Kr("div",{class:"_pillar-md-table-wrapper pillar-md-table-wrapper",children:Kr("table",{class:"_pillar-md-table pillar-md-table",children:[Kr("thead",{children:Kr("tr",{children:e.header.map((t,n)=>Kr("th",{style:e.align[n]?{textAlign:e.align[n]}:void 0,class:"_pillar-md-th pillar-md-th",children:Gc(t.tokens)},n))})}),Kr("tbody",{children:e.rows.map((t,n)=>Kr("tr",{children:t.map((t,n)=>Kr("td",{style:e.align[n]?{textAlign:e.align[n]}:void 0,class:"_pillar-md-td pillar-md-td",children:Gc(t.tokens)},n))},n))})]})},t)}(e,t);case"hr":return Kr("hr",{class:"_pillar-md-hr pillar-md-hr"},t);case"space":return null;case"html":return function(e,t){const n=e.raw.match(/<(\w+)\s*([^>]*)\/?\s*>/);if(n){const[,e,r]=n,i=function(e){const t={},n=/(\w+)=["']([^"']*)["']/g;let r;for(;null!==(r=n.exec(e));)t[r[1]]=r[2];return t}(r);switch(e){case"SourceList":if(i.sources)try{return Kr(Bc,{sources:JSON.parse(i.sources)},t)}catch{p.warn("[Pillar] Failed to parse SourceList sources")}break;case"Progress":return Kr(qc,{message:i.message||"Processing...",isActive:"false"!==i.active},t);case"Collapsible":return Kr(Uc,{title:i.title||"Details",defaultOpen:"true"===i.open,children:i.content?Kr(Wc,{content:i.content}):null},t)}}return Kr("span",{dangerouslySetInnerHTML:{__html:e.raw}},t)}(e,t);case"strong":return Kr("strong",{children:Gc(e.tokens)},t);case"em":return Kr("em",{children:Gc(e.tokens)},t);case"codespan":return Kr("code",{class:"_pillar-md-code-inline pillar-md-code-inline",children:e.text},t);case"link":const n=e;return Kr("a",{href:n.href,title:n.title||void 0,target:"_blank",rel:"noopener noreferrer",class:"_pillar-md-link pillar-md-link",children:Gc(n.tokens)},t);case"image":const r=e;return Kr("img",{src:r.href,alt:r.text,title:r.title||void 0,class:"_pillar-md-image pillar-md-image"},t);case"br":return Kr("br",{},t);case"del":return Kr("del",{children:Gc(e.tokens)},t);default:return"raw"in e&&"string"==typeof e.raw?Kr("span",{children:e.raw},t):null}}(e,t)).filter(Boolean)}function Kc(e,t){return e.task?Kr("li",{class:"_pillar-md-list-item _pillar-md-task-item pillar-md-list-item pillar-md-task-item",children:[Kr("input",{type:"checkbox",checked:e.checked,disabled:!0,class:"_pillar-md-task-checkbox pillar-md-task-checkbox"}),Kr("span",{class:e.checked?"_pillar-md-task-text--checked pillar-md-task-text--checked":"",children:Vc(e.tokens)})]},t):Kr("li",{class:"_pillar-md-list-item pillar-md-list-item",children:Vc(e.tokens)},t)}function Gc(e){return e&&0!==e.length?e.map((e,t)=>{switch(e.type){case"text":case"escape":return e.text;case"strong":return Kr("strong",{children:Gc(e.tokens)},t);case"em":return Kr("em",{children:Gc(e.tokens)},t);case"codespan":return Kr("code",{class:"_pillar-md-code-inline pillar-md-code-inline",children:e.text},t);case"link":const n=e;return Kr("a",{href:n.href,title:n.title||void 0,target:"_blank",rel:"noopener noreferrer",class:"_pillar-md-link pillar-md-link",children:Gc(n.tokens)},t);case"image":const r=e;return Kr("img",{src:r.href,alt:r.text,title:r.title||void 0,class:"_pillar-md-image pillar-md-image"},t);case"br":return Kr("br",{},t);case"del":return Kr("del",{children:Gc(e.tokens)},t);default:return"raw"in e&&"string"==typeof e.raw?e.raw:null}}):null}function Qc({progress:e,isActive:t=!1,isLast:n=!1,responseStarted:r=!1,nested:i=!1,groupActive:a=!1}){const l="active"===e.status||void 0===e.status&&t,o="error"===e.status||"query_failed"===e.kind,s="thinking"===e.kind||"step_start"===e.kind,c=function(e,t=50){const[n,r]=si(e);return ci(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}(e.text,50),[p,d]=si(0);ci(()=>{if(!s||!l)return;const t=e.metadata?._startTime||Date.now();d(Math.max(1,Math.round((Date.now()-t)/1e3)));const n=setInterval(()=>{d(Math.round((Date.now()-t)/1e3))},1e3);return()=>clearInterval(n)},[s,l,e.metadata]);const u=Boolean(e.text),h=e.children&&e.children.length>0,g=e.metadata?.sources,f="search_complete"===e.kind&&g&&g.length>0,m=!0===e.metadata?.no_sources_used,b=e.metadata?.arguments,v=b&&Object.keys(b).length>0,_=u||h||f&&!m||v,x=e.metadata?.result_count,y="search"===e.kind&&0===x,[w,k]=si(!1),[S,C]=si(!1),P=_&&(w?S:i?l||n&&a:l||n&&!r),E=pi(null),[T,z]=si(!1),[R,I]=si(!1);ci(()=>{k(!1)},[l]),ci(()=>{I(!1)},[e.id,e.progress_id]),ci(()=>{E.current&&l&&e.text&&!R&&(E.current.scrollTop=E.current.scrollHeight)},[e.text,l,R]);const M=()=>{_&&(k(!0),C(!P))},A=P?"rotate(90deg)":"rotate(0deg)";if(!(e.label||e.message||e.text||h||f||s))return null;const $=(()=>{if(s){if(l)return p>0?`Thought for ${p}s`:"Thinking...";const t=e.metadata?._durationSeconds,n=t||p;return n>0?`Thought for ${n}s`:"Thought"}return e.label||e.message||function(e){switch(e){case"processing":return"Processing...";case"search":return"Searching...";case"search_complete":return"Search complete";case"query":return"Executing action...";case"query_complete":return"Action complete";case"query_failed":return"Action failed";case"generating":return"Generating answer...";case"thinking":case"step_start":return"Thinking...";case"step_complete":return"Done";case"tool_call":return"Running tool...";case"plan":return"Planning...";default:return"Working..."}}(e.kind)})();return Kr("div",{class:`_pillar-progress-row pillar-progress-row${o?" _pillar-progress-row--error pillar-progress-row--error":""}${l?" _pillar-progress-row--active pillar-progress-row--active":""}${n?" _pillar-progress-row--last pillar-progress-row--last":""}${i?" _pillar-progress-row--nested pillar-progress-row--nested":""}`,role:"status","aria-live":l?"polite":"off","aria-label":`${$}: ${l?"in progress":o?"error":"complete"}`,children:[Kr("div",{class:"_pillar-progress-row-header pillar-progress-row-header",onClick:M,style:{cursor:_?"pointer":"default"},"data-expanded":P,role:_?"button":void 0,"aria-expanded":_?P:void 0,tabIndex:_?0:void 0,onKeyDown:_?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),M())}:void 0,children:[o&&Kr("span",{class:"_pillar-progress-error-icon pillar-progress-error-icon","aria-label":"Error",children:"✗"}),Kr("span",{class:"_pillar-progress-message pillar-progress-message",children:$}),y&&Kr("span",{class:"_pillar-progress-no-results pillar-progress-no-results",children:"— no relevant results"}),_&&!o&&Kr("span",{class:"_pillar-progress-chevron pillar-progress-chevron",style:{transform:A,transition:"transform 0.2s ease, opacity 0.15s ease"},"aria-hidden":"true",children:"▶"})]}),_&&Kr("div",{class:"_pillar-progress-content-wrapper pillar-progress-content-wrapper "+(P?"_pillar-progress-content-wrapper--expanded pillar-progress-content-wrapper--expanded":""),children:Kr("div",{class:"_pillar-progress-content-container pillar-progress-content-container",children:[v&&Kr("div",{class:"_pillar-progress-arguments pillar-progress-arguments",children:Object.entries(b).map(([e,t])=>Kr("span",{class:"_pillar-progress-argument pillar-progress-argument",children:[Kr("span",{class:"_pillar-progress-argument-key pillar-progress-argument-key",children:[e,":"]})," ",Kr("span",{class:"_pillar-progress-argument-value pillar-progress-argument-value",children:"string"==typeof t?t:JSON.stringify(t)})]},e))}),u&&Kr("div",{class:"_pillar-progress-text-preview-wrapper pillar-progress-text-preview-wrapper",children:[T&&Kr("div",{class:"_pillar-progress-text-gradient pillar-progress-text-gradient"}),Kr("div",{ref:E,class:"_pillar-progress-text-preview pillar-progress-text-preview",onScroll:()=>{if(E.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=E.current;I(!(e>=t-n-5)),z(e>0)}},children:Kr(Wc,{content:c||""})})]}),h?Kr("div",{class:"_pillar-progress-children pillar-progress-children",children:e.children.map((e,t)=>Kr("div",{class:"_pillar-progress-child-item pillar-progress-child-item",children:e.url?Kr("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-progress-child-link pillar-progress-child-link",children:e.label}):Kr("span",{class:"_pillar-progress-child-label pillar-progress-child-label",children:e.label})},e.id||t))}):f?Kr("div",{class:"_pillar-progress-sources pillar-progress-sources",children:g.map((e,t)=>Kr("div",{class:"_pillar-progress-source-item pillar-progress-source-item",children:Kr("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-progress-source-link pillar-progress-source-link",children:Kr("span",{class:"_pillar-progress-source-title pillar-progress-source-title",children:e.title})})},t))}):null]})})]})}function Jc({events:e,summary:t,isLast:n=!1,responseStarted:r=!1}){const i=e.some(e=>"active"===e.status),[a,l]=si(!1),[o,s]=si(!1),c=a?o:i||n&&!r;ci(()=>{i&&l(!1)},[i]);const p=()=>{l(!0),s(!c)};return Kr("div",{class:`_pillar-progress-group pillar-progress-group${i?" _pillar-progress-group--active pillar-progress-group--active":""}${n?" _pillar-progress-group--last pillar-progress-group--last":""}`,children:[Kr("div",{class:"_pillar-progress-group-header pillar-progress-group-header",onClick:p,role:"button","aria-expanded":c,tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())},children:[Kr("span",{class:"_pillar-progress-group-chevron pillar-progress-group-chevron",style:{transform:c?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},"aria-hidden":"true",children:"▶"}),Kr("span",{class:"_pillar-progress-group-summary pillar-progress-group-summary",children:t}),i&&Kr("span",{class:"_pillar-progress-group-active-dot pillar-progress-group-active-dot"})]}),Kr("div",{class:"_pillar-progress-group-children pillar-progress-group-children "+(c?"_pillar-progress-group-children--expanded pillar-progress-group-children--expanded":""),children:Kr("div",{class:"_pillar-progress-group-children-inner pillar-progress-group-children-inner",children:e.map((t,n)=>Kr(Qc,{progress:t,isActive:"active"===t.status,isLast:n===e.length-1,responseStarted:r,nested:!0,groupActive:i},t.id||t.progress_id||n))})})]})}function Xc({event:e}){const[t,n]=si("idle"),[r,i]=si(null),[a,l]=si(!1),o=e.metadata?.endpoint,s=e.label||"Secret",c=ui(async()=>{if(o){n("loading");try{const e=Ta(),t=e?.config?.apiBaseUrl||"",r=o.startsWith("http")?o:`${t}${o}`,a=await fetch(r);if(410===a.status)n("expired");else if(a.ok){const e=await a.json();i(e.value),n("revealed")}else n("error")}catch{n("error")}}else n("error")},[o]),p=ui(async()=>{if(r)try{await navigator.clipboard.writeText(r),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[r]);return Kr("div",{class:"_pillar-secret-reveal pillar-secret-reveal",children:["idle"===t&&Kr("button",{class:"_pillar-secret-reveal-btn pillar-secret-reveal-btn",onClick:c,type:"button",children:[Kr(Zc,{}),Kr("span",{children:["Reveal ",s]})]}),"loading"===t&&Kr("div",{class:"_pillar-secret-reveal-loading",children:[Kr(Yc,{}),Kr("span",{children:"Fetching…"})]}),"revealed"===t&&r&&Kr("div",{class:"_pillar-secret-reveal-value",children:[Kr("code",{class:"_pillar-secret-reveal-code",children:r}),Kr("button",{class:"_pillar-secret-reveal-copy",onClick:p,type:"button",title:a?"Copied!":"Copy to clipboard",children:Kr(a?tp:ep,{})})]}),"expired"===t&&Kr("div",{class:"_pillar-secret-reveal-expired",children:"This secret has expired or was already revealed."}),"error"===t&&Kr("div",{class:"_pillar-secret-reveal-error",children:"Failed to retrieve secret."})]})}function Zc(){return Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Kr("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})})}function Yc(){return Kr("svg",{class:"_pillar-secret-reveal-spinner",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:Kr("path",{d:"M12 2v4m0 12v4m-7.07-3.93l2.83-2.83m8.48-8.48l2.83-2.83M2 12h4m12 0h4m-3.93 7.07l-2.83-2.83M6.34 6.34L3.51 3.51"})})}function ep(){return Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Kr("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),Kr("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function tp(){return Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Kr("polyline",{points:"20 6 9 17 4 12"})})}Nc.options=Nc.setOptions=function(e){return Hc.setOptions(e),Nc.defaults=Hc.defaults,zs(Nc.defaults),Nc},Nc.getDefaults=Es,Nc.defaults=Ts,Nc.use=function(...e){return Hc.use(...e),Nc.defaults=Hc.defaults,zs(Nc.defaults),Nc},Nc.walkTokens=function(e,t){return Hc.walkTokens(e,t)},Nc.parseInline=Hc.parseInline,Nc.Parser=Dc,Nc.parser=Dc.parse,Nc.Renderer=Lc,Nc.TextRenderer=Oc,Nc.Lexer=$c,Nc.lexer=$c.lex,Nc.Tokenizer=Ac,Nc.Hooks=jc,Nc.parse=Nc,Nc.options,Nc.setOptions,Nc.use,Nc.walkTokens,Nc.parseInline,Dc.parse,$c.lex;const np=new Set(["search","search_complete","tool_call","plan","generating","query","query_complete","query_failed","step_complete","processing"]);const rp=new Set(["search_complete","query_complete","step_complete"]);function ip(e){const t=e.filter(e=>!rp.has(e.kind));if(1===t.length&&t[0].label)return t[0].label;let n=0,r=0;for(const t of e)switch(t.kind){case"search":case"search_complete":break;case"query":case"query_complete":case"query_failed":case"tool_call":n++;break;default:r++}const i=e.filter(e=>"search_complete"===e.kind).length,a=e.filter(e=>"search"===e.kind).length,l=Math.max(i,a),o=[];return l>0&&o.push(`Searched ${l} ${1===l?"source":"sources"}`),n>0&&o.push(`Ran ${n} ${1===n?"action":"actions"}`),r>0&&0===o.length&&o.push(`${r} ${1===r?"step":"steps"}`),o.length>0?o.join(", "):`${e.length} steps`}function ap({events:e,responseStarted:t=!1}){if(!e||0===e.length)return null;const n=function(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"tool_group",events:[...n],summary:ip(n)}),n=[])};for(const i of e){const e="thinking"===i.kind||"step_start"===i.kind,a="secret_reveal"===i.kind;e?(r(),t.push({type:"thinking",event:i})):a?(r(),t.push({type:"secret_reveal",event:i})):(np.has(i.kind),n.push(i))}return r(),t}(e);return Kr("div",{class:"_pillar-progress-stack pillar-progress-stack",children:n.flatMap((e,r)=>{if("thinking"===e.type)return[Kr(Qc,{progress:e.event,isActive:"active"===e.event.status,isLast:r===n.length-1,responseStarted:t},e.event.id||e.event.progress_id||`thinking-${r}`)];if("secret_reveal"===e.type)return[Kr(Xc,{event:e.event},e.event.id||`secret-${r}`)];const i=e.events.filter(e=>!rp.has(e.kind));return i.length<=2?e.events.map((i,a)=>Kr(Qc,{progress:i,isActive:"active"===i.status,isLast:r===n.length-1&&a===e.events.length-1,responseStarted:t},i.id||i.progress_id||`flat-${r}-${a}`)):[Kr(Jc,{events:e.events,summary:e.summary,isLast:r===n.length-1,responseStarted:t},`group-${r}`)]})})}function lp({error:e,onRetry:t}){return Kr("div",{class:"_pillar-error-row pillar-error-row",role:"alert",children:[Kr("span",{class:"_pillar-error-row-icon pillar-error-row-icon","aria-hidden":"true",children:"✗"}),Kr("span",{class:"_pillar-error-row-message pillar-error-row-message",children:e.message}),e.upgradeUrl?Kr("a",{class:"_pillar-error-row-retry pillar-error-row-retry",href:e.upgradeUrl,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:[Kr("span",{dangerouslySetInnerHTML:{__html:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7"></line><polyline points="7 7 17 7 17 17"></polyline></svg>'}}),"Upgrade"]}):Kr("button",{class:"_pillar-error-row-retry pillar-error-row-retry",onClick:t,type:"button","aria-label":"Retry",children:[Kr("span",{dangerouslySetInnerHTML:{__html:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"></polyline><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path></svg>'}}),"Retry"]})]})}function op({session:e,onResume:t,onDiscard:n,isResuming:r=!1}){return Kr("div",e.elapsedMs<15e3||r?{class:"_pillar-resume-prompt _pillar-resume-prompt--seamless pillar-resume-prompt",children:[Kr("div",{class:"_pillar-resume-prompt-spinner pillar-resume-prompt-spinner"}),Kr("span",{class:"_pillar-resume-prompt-text pillar-resume-prompt-text",children:"Resuming conversation..."})]}:{class:"_pillar-resume-prompt pillar-resume-prompt",children:[Kr("div",{class:"_pillar-resume-prompt-content pillar-resume-prompt-content",children:[Kr("div",{class:"_pillar-resume-prompt-icon pillar-resume-prompt-icon",children:Kr("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Kr("circle",{cx:"12",cy:"12",r:"10"}),Kr("polyline",{points:"12 6 12 12 16 14"})]})}),Kr("div",{class:"_pillar-resume-prompt-body pillar-resume-prompt-body",children:[Kr("div",{class:"_pillar-resume-prompt-title pillar-resume-prompt-title",children:"Session Interrupted"}),Kr("div",{class:"_pillar-resume-prompt-message pillar-resume-prompt-message",children:[e.userMessage&&Kr("span",{class:"_pillar-resume-prompt-user-msg pillar-resume-prompt-user-msg",children:['"',sp(e.userMessage,50),'"']}),e.partialResponse&&Kr("span",{class:"_pillar-resume-prompt-summary pillar-resume-prompt-summary",children:sp(e.partialResponse,80)})]})]})]}),Kr("div",{class:"_pillar-resume-prompt-actions pillar-resume-prompt-actions",children:[Kr("button",{type:"button",class:"_pillar-resume-prompt-btn _pillar-resume-prompt-btn--primary pillar-resume-prompt-btn",onClick:t,children:[Kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:Kr("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume"]}),Kr("button",{type:"button",class:"_pillar-resume-prompt-btn _pillar-resume-prompt-btn--ghost pillar-resume-prompt-btn",onClick:n,children:"Discard"})]})]})}function sp(e,t){return e.length<=t?e:e.slice(0,t)+"..."}function cp(){const e=Ta(),t=e?.config?.domScanning?.excludeSelector;return{excludeSelector:t?`#pillar-root, ${t}`:"#pillar-root"}}function pp({cardType:e,data:t,messageIndex:n,segmentIndex:r}){const i=pi(null),a=pi(null);return ci(()=>{const l=Ta(),o=l?.getCardRenderer(e);if(o&&i.current){const s=function(e,t,n){for(let r=e.length-1;r>=0;r--){const i=e[r].segments;if(i)for(let e=i.length-1;e>=0;e--)if("card"===i[e].type)return r===t&&e===n}return!1}(Na.value,n,r),c={isLatest:s,isReady:!Ga.value,messageIndex:n,segmentIndex:r,toolName:e},d=o(i.current,t,{sendResult:t=>(l?.sendToolResultAsMessage(e,t),Promise.resolve()),onStateChange:(t,n)=>{p.log(`[Pillar] Card "${e}" state: ${t}${n?` - ${n}`:""}`)}},c);a.current=d||null}return()=>{a.current&&(a.current(),a.current=null)}},[e,t,n,r]),Kr("div",{ref:i,class:"_pillar-card-segment pillar-card-segment"})}function dp(){const e=To(),t=pi(null),n=pi(null),r=pi(0),[i,a]=si(!1),l=ui(async t=>{const n=performance.now(),r=(new Date).toISOString();p.log("[Pillar] Received action_request:",t.action_name,t.parameters,`at ${r}`);const i=Ta();if(i)try{if("interact_with_page"===t.action_name){const r=t.parameters;Jo(r.operation,t.tool_call_id);try{if(Yo())return await e.mcp.sendActionResult(t.action_name,{success:!1,error:"User cancelled action"},t.tool_call_id),void p.log("[Pillar] Page interaction cancelled by user before execution");const a=await i.handlePageInteraction(r);if(Yo())return await e.mcp.sendActionResult(t.action_name,{success:!1,error:"User cancelled action"},t.tool_call_id),void p.log("[Pillar] Page interaction cancelled by user after execution");let l=null;if(a.success&&i?.isDOMScanningEnabled){await new Promise(e=>setTimeout(e,150));const e=function(e){const t=e?.root||document.body,n={lines:[],refs:new Set,interactableCount:0,totalLength:0,budgetExhausted:!1,maxDepth:0,options:{...ss,...e}};Cs(t,n,0);const r=n.lines.filter(e=>!gs.has(e)),i=[...fs].filter(e=>!n.refs.has(e)),a=/\[\[pr-[a-z0-9]+\]\]$/,l=r.filter(e=>a.test(e)).length,o=r.length>0||i.length>0;gs=new Set(n.lines),fs=new Set(n.refs);let s=null;if(o){const e=[];r.length>0&&(e.push(...r),e.push(""));const t=i.length>0?`, ${i.length} removed: ${i.join(", ")}`:"";e.push(`=== ${l} new${t} ===`),s=e.join("\n")}return{content:s,removedRefs:i,newInteractableCount:l,totalInteractableCount:n.refs.size,hasChanges:o,timestamp:Date.now(),url:window.location.href,title:document.title}}(cp());l=e.content,p.log("[Pillar] DOM delta scanned after page interaction:",e.hasChanges?`${e.newInteractableCount} new, ${e.removedRefs.length} removed`:"no changes")}await e.mcp.sendActionResult(t.action_name,{...a,dom_snapshot:l},t.tool_call_id);const o=Math.round(performance.now()-n);p.log(`[Pillar] Page interaction "${r.operation}" completed in ${o}ms:`,a)}finally{Xo(),Zo()}return}const r=i.getHandler(t.action_name);if(!r)throw new Error(`No handler registered for action "${t.action_name}". Register one with pillar.defineTool() or usePillarTool().`);const a=os(await Promise.resolve(r(t.parameters)));await e.mcp.sendActionResult(t.action_name,a,t.tool_call_id);const l=Math.round(performance.now()-n);if(a&&"object"==typeof a&&!Array.isArray(a)&&!1===a.success)p.error(`[Pillar] Action "${t.action_name}" failed after ${l}ms:`,a.error||a.message);else if(p.log(`[Pillar] Action "${t.action_name}" completed in ${l}ms`),a&&"object"==typeof a&&!Array.isArray(a)){const e=a,t=e.card_type;t&&i.hasCardRenderer(t)&&(p.log(`[Pillar] Rendering card for type "${t}"`),ol(t,e))}}catch(r){const i=r instanceof Error?r.message:String(r);await e.mcp.sendActionResult(t.action_name,{success:!1,error:i},t.tool_call_id);const a=Math.round(performance.now()-n);p.error(`[Pillar] Action "${t.action_name}" failed after ${a}ms:`,r)}else p.error("[Pillar] SDK not initialized, cannot execute action"),await e.mcp.sendActionResult(t.action_name,{success:!1,error:"SDK not initialized"},t.tool_call_id)},[e]),o=ui(()=>{const e=Ta(),t=e?.config?.productKey??"";Ul(),is(t)},[]);ci(()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)},[Na.value,tl.value]),ci(()=>{const e=Ta();if(!e)return;return e.on("task:complete",({name:e,success:t})=>{Ml(e,t);const n=function(e,t){const n=e.replace(/_/g," ").toLowerCase();return t?n.startsWith("open ")?`Opened ${n.slice(5)}`:n.startsWith("go to ")?`Navigated to ${n.slice(6)}`:n.startsWith("navigate to ")?`Navigated to ${n.slice(12)}`:"Done!":`Failed to ${n}`}(e,t);Al(e,n)})},[]);const s=ui(e=>{const t=Ta();p.log("[Pillar] handleActionsReceived called with",e.length,"actions"),p.log("[Pillar] Actions detail:",e.map(e=>({name:e.name,autoRun:e.autoRun})));const n=e.filter(e=>!0===e.autoRun),r=e.filter(e=>!e.autoRun);return p.log("[Pillar] Auto-run actions:",n.length,", Manual actions:",r.length),t&&n.length>0?(p.log("[Pillar] Executing auto-run actions..."),n.forEach(e=>{const n=e.data||{},r=n.path,i=n.url,a=Na.value.length-1;a>=0&&Il(a,e.name),p.log("[Pillar] Executing action:",e.name),t.executeTask({id:e.id,name:e.name,taskType:e.taskType,data:n,path:r,externalUrl:i})}),[]):t?r:(p.warn("[Pillar] No Pillar instance available for auto-run"),e)},[]),c=ui(async t=>{n.current&&(n.current.abort(),n.current=null);const i=++r.current,a=new AbortController;n.current=a;let o=[];const c=()=>r.current!==i,p=await e.chat({message:t.message,history:t.history,existingConversationId:t.conversationId,userContext:t.userContext,images:t.images,resume:t.resume,signal:a.signal,onChunk:e=>{c()||ll(e)},onActions:e=>{c()||(o=s(e))},onProgress:e=>{c()||Hl(e)},onConversationStarted:()=>{const e=Ta(),t=e?.config?.productKey??"",n=Ua.value;t&&n&&Promise.resolve().then(function(){return ls}).then(({saveActiveSession:e})=>{e(n,t)})},onActionRequest:l,onRequestId:e=>Ja(e)});return{response:p,receivedActions:o,generation:i}},[e,s,l]),d=ui(async(e,t,i)=>{Ul(),el();const a=Nr().startSpan("chat.send_message",{attributes:{"chat.message_length":e.length}});El(e,t,i),Ol(!0),zl("");let l=-1;try{const n=Na.value.slice(0,-1),r=!Ua.value;r&&$l(crypto.randomUUID());const{response:o,receivedActions:p,generation:d}=await c({message:e,conversationId:Ua.value,userContext:t,images:i,history:n});l=d;let u=p;o.actions&&o.actions.length>0&&(u=s(o.actions)),Rl(o.message,o.messageId,u,o.sources),o.conversationId&&$l(o.conversationId),r&&Ua.value&&so(Ua.value,e);{const e=Ta(),t=e?.config?.productKey??"";t&&is(t)}a.end()}catch(n){if("AbortError"===n.name)return Bl(),p.log("[Pillar] Chat cancelled by user"),a.setAttribute("chat.cancelled",!0),void a.end();l=r.current,p.error("[Pillar] Chat error:",n),a.setStatus({code:lt.ERROR,message:n.message}),a.end(),Bl();const o=n.data;Ya({message:n.message||"Something went wrong. Please try again.",retryMessage:e,retryContext:t,retryImages:i,upgradeUrl:o?.upgrade_url})}finally{r.current===l&&(Ol(!1),Dl(),Ja(null),n.current=null)}},[e,c,s]),u=ui(async e=>{el(),Tl(e),Ol(!0),zl("");let t=-1;try{const n=Na.value.slice(0,-1);Ua.value||$l(crypto.randomUUID());const{response:r,receivedActions:i,generation:a}=await c({message:e,conversationId:Ua.value,history:n});t=a;let l=i;r.actions&&r.actions.length>0&&(l=s(r.actions)),Rl(r.message,r.messageId,l,r.sources),r.conversationId&&$l(r.conversationId)}catch(e){if("AbortError"===e.name)return void Bl();t=r.current,p.error("[Pillar] Hidden message error:",e),Bl(),Ya({message:e.message||"Something went wrong. Please try again.",retryMessage:""})}finally{r.current===t&&(Ol(!1),Dl(),Ja(null),n.current=null)}},[c,s]),h=ui(async()=>{const e=tl.value;if(!e)return;const t=Ta(),i=t?.config?.productKey??"",l=t?.isDOMScanningEnabled??!1;let o=[...ml.value];if(l){const e=Ps(cp()),t={id:Oa(),type:"dom_snapshot",url:e.url,title:e.title,content:e.content,interactableCount:e.interactableCount,timestamp:e.timestamp};o=[...o,t]}a(!0),Ol(!0),zl("");let d=-1;try{const{response:t,receivedActions:n,generation:r}=await c({message:"",conversationId:e.conversationId,userContext:o.length>0?o:void 0,resume:!0});d=r;let a=n;t.actions&&t.actions.length>0&&(a=s(t.actions)),Rl(t.message,t.messageId,a,t.sources),Ul(),is(i)}catch(t){if("AbortError"===t.name)return void Bl();d=r.current,p.error("[Pillar] Resume error:",t),Bl();const n=t.data;Ya({message:t.message||"Failed to resume. Please try again.",retryMessage:e.userMessage,upgradeUrl:n?.upgrade_url}),Ul(),is(i)}finally{a(!1),r.current===d&&(Ol(!1),Dl(),Ja(null),n.current=null)}},[c,s]);ci(()=>{const e=tl.value;e&&e.elapsedMs<15e3&&!Ga.value&&h()},[tl.value,h]),ci(()=>()=>{n.current&&(n.current.abort(),n.current=null)},[]);const g=ui(()=>{n.current?.abort(),n.current=null;const t=Qa.value;null!==t&&(e.mcp.cancelStream(t),Ja(null)),Ol(!1),Dl(),Bl(),jl();const r=Na.value,i=r.length>0?r[r.length-1]:null,a="assistant"===i?.role&&Boolean(i?.content?.trim()),l=Ta(),o=l?.config?.productKey??"";if(a&&Ua.value){const e=[...r].reverse().find(e=>"user"===e.role);Nl({conversationId:Ua.value,userMessage:e?.content??"",partialResponse:i.content??"",displayTrace:[],elapsedMs:99999})}else o&&is(o)},[e]),f=ui(()=>{const e=Za.value;if(!e)return;el();const t=Na.value;t.length>0&&"user"===t[t.length-1].role&&(Na.value=t.slice(0,-1)),d(e.retryMessage,e.retryContext,e.retryImages)},[d]),m=ui(async(t,n)=>{Ll(t,n),await e.submitFeedback(t,n)},[e]),b=ui((e,t,n)=>{if(Ga.value)return;const r=Ta();if(r?.isDOMScanningEnabled??!1){const r=Ps(cp()),i={id:Oa(),type:"dom_snapshot",url:r.url,title:r.title,content:r.content,interactableCount:r.interactableCount,timestamp:r.timestamp},a=[...t,i];return void d(e,a.length>0?a:void 0,n.length>0?n:void 0)}d(e,t.length>0?t:void 0,n.length>0?n:void 0)},[d]);return ci(()=>{const e=hl.value;if(e)return Vl(),void u(e);const t=ul.value,n=bl.value,r=vl.value;t&&(ql(),Yl(),to(),b(t,n,r))},[gl.value,b,u]),Kr("div",{class:"_pillar-chat-view pillar-chat-view",children:[Kr("div",{class:"_pillar-chat-view-messages pillar-chat-view-messages",ref:t,children:[Xa.value&&Kr("div",{class:"_pillar-chat-history-loading pillar-chat-history-loading",children:[Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--user pillar-chat-history-loading-message--user",children:Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 70%"})}),Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--assistant pillar-chat-history-loading-message--assistant",children:[Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 90%"}),Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 85%"}),Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 60%"})]}),Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--user pillar-chat-history-loading-message--user",children:Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 55%"})}),Kr("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--assistant pillar-chat-history-loading-message--assistant",children:[Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 95%"}),Kr("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 80%"})]})]}),0===Na.value.length&&!tl.value&&!Xa.value&&Kr("div",{class:"_pillar-chat-view-welcome pillar-chat-view-welcome",children:Mo.value?Kr("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:[Kr(qo,{}),Kr(qo,{}),Kr(qo,{})]}):Io.value&&Io.value.length>0?Kr("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:Io.value.map(e=>Kr(Fo,{text:e.text,onClick:()=>b(e.text,[],[])},e.id))}):Kr($,{children:[Kr("div",{class:"_pillar-chat-view-welcome-icon pillar-chat-view-welcome-icon",children:"💬"}),Kr("div",{class:"_pillar-chat-view-welcome-title pillar-chat-view-welcome-title",children:"Ask a question"}),Kr("div",{class:"_pillar-chat-view-welcome-text pillar-chat-view-welcome-text",children:"Ask me anything about how to use this product."})]})}),Na.value.map((e,t)=>e.hidden?null:Kr("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?Kr("div",{class:"_pillar-message-user pillar-message-user",children:[e.userContext&&e.userContext.length>0&&Kr(No,{contexts:e.userContext,readOnly:!0}),e.images&&e.images.length>0&&Kr("div",{class:"_pillar-message-user-images pillar-message-user-images",children:e.images.map((e,t)=>Kr("img",{src:e.url,alt:`Attachment ${t+1}`,class:"_pillar-message-user-image pillar-message-user-image"},t))}),e.content]}):Kr("div",{class:"_pillar-message-assistant-wrapper pillar-message-assistant-wrapper",children:[Kr("div",{class:"_pillar-message-assistant-content pillar-message-assistant-content",children:[e.segments&&e.segments.length>0?e.segments.map((n,r)=>{if("progress"===n.type){const t=e.segments.slice(r+1).some(e=>"text"===e.type);return Kr(ap,{events:n.events,responseStarted:t||Boolean(e.content)},`seg-${r}`)}return"card"===n.type?Kr(pp,{cardType:n.cardType,data:n.data,messageIndex:t,segmentIndex:r},`seg-${r}`):Kr("div",{class:"_pillar-message-assistant pillar-message-assistant",children:Kr(Wc,{content:n.content})},`seg-${r}`)}):Ga.value&&t===Na.value.length-1&&Kr("span",{class:"_pillar-thinking-shimmer pillar-thinking-shimmer",children:"Thinking..."}),e.actionStatus&&Object.keys(e.actionStatus).length>0&&Kr("span",{class:"_pillar-action-status pillar-action-status",children:Object.entries(e.actionStatus).map(([e,t])=>Kr("span",{class:`_pillar-action-status-indicator pillar-action-status-indicator _pillar-action-status-indicator--${t.status} pillar-action-status-indicator--${t.status}`,title:"failed"===t.status?t.errorMessage:e,dangerouslySetInnerHTML:{__html:"success"===t.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"===t.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))})]}),"assistant"===e.role&&e.id&&e.content&&Kr("div",{class:"_pillar-feedback-icons pillar-feedback-icons",children:[Kr("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("up"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>m(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>'}}),Kr("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("down"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>m(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&&Kr("div",{class:"_pillar-chat-sources pillar-chat-sources",children:[Kr("div",{class:"_pillar-chat-sources-title pillar-chat-sources-title",children:"Sources"}),e.sources.map(e=>Kr("div",{class:"_pillar-chat-source pillar-chat-source",children:e.title},e.slug))]})]})},t)),Za.value&&Kr(lp,{error:Za.value,onRetry:f}),tl.value&&tl.value.elapsedMs>=15e3&&Kr(op,{session:tl.value,onResume:h,onDiscard:o,isResuming:i}),i&&tl.value&&tl.value.elapsedMs<15e3&&Kr(op,{session:tl.value,onResume:h,onDiscard:o,isResuming:!0})]}),Kr("div",{class:"_pillar-chat-view-input-area pillar-chat-view-input-area",children:Kr(Bo,{placeholder:"Ask a question...",disabled:Xa.value,isStreaming:Ga.value,onStop:g,onSubmit:b})})]})}function up(e){if(!e)return"Unknown";const t=function(e){let t=e;return e.endsWith("Z")&&e.includes("+")&&(t=e.slice(0,-1)),new Date(t)}(e),n=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime()-r.getTime(),a=Math.floor(i/864e5);if(0===a)return"Today";if(1===a)return"Yesterday";if(a<7)return`${a}d ago`;if(a<30){const e=Math.floor(a/7);return 1===e?"1 week ago":`${e} weeks ago`}return t.toLocaleDateString(void 0,{month:"short",year:"numeric"})}function hp({onSelectConversation:e}){const[t,n]=si(!1),[r,i]=si(!1),[a,l]=si([]),[o,s]=si(!1),[c,d]=si(Fa.value),u=pi(null),h=di(()=>function(e){const t=new Map;for(const n of e){const e=up(n.lastMessageAt),r=t.get(e)||[];r.push(n),t.set(e,r)}return Array.from(t.entries()).map(([e,t])=>({label:e,conversations:t}))}(a),[a]);ci(()=>Fa.subscribe(e=>{e>c&&(s(!1),d(e))}),[c]),ci(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&n(!1)};return t&&(document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[t]);const g=async()=>{if(!o){i(!0);try{const e=za();if(e){const t=await e.listConversations(20);l((e=>{const t=qa.value;if(0===t.length)return e;const n=new Set(e.map(e=>e.id)),r=t.filter(e=>!n.has(e.id));return[...r,...e]})(t))}}catch(e){p.error("[Pillar] Failed to fetch conversations:",e),qa.value.length>0&&l(qa.value)}finally{i(!1),s(!0)}}},f=da.value,m=["_pillar-history-menu","pillar-history-menu",f?"_pillar-history-menu--mobile":""].filter(Boolean).join(" "),b=r?Kr("div",{class:"_pillar-history-loading pillar-history-loading",children:[Kr("div",{class:"_pillar-history-spinner pillar-history-spinner"}),Kr("span",{children:"Loading..."})]}):0===a.length?Kr("div",{class:"_pillar-history-empty pillar-history-empty",children:"No conversations yet"}):Kr("div",{class:"_pillar-history-list pillar-history-list",children:h.map(t=>Kr($,{children:[Kr("div",{class:"_pillar-history-group-header pillar-history-group-header",children:t.label}),t.conversations.map(t=>Kr("button",{class:"_pillar-history-item pillar-history-item",onClick:()=>(t=>{n(!1),e(t)})(t.id),type:"button",children:Kr("span",{class:"_pillar-history-item-title pillar-history-item-title",children:t.title})},t.id))]},t.label))});return Kr("div",{class:"_pillar-history-dropdown pillar-history-dropdown",ref:u,children:[Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-history-btn",onClick:()=>{const e=!t;n(e),e&&!o&&g()},"aria-label":"Conversation history","aria-expanded":t,title:"Conversation history",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z" clip-rule="evenodd"/></svg>'}}),t&&Kr("div",{class:m,children:[f&&Kr("div",{class:"_pillar-history-mobile-header",children:[Kr("span",{class:"_pillar-history-mobile-title",children:"History"}),Kr("button",{class:"_pillar-history-mobile-close",onClick:()=>n(!1),"aria-label":"Close history",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>'}})]}),b]})]})}const gp=120;function fp({currentView:e,hideNavigation:t=!1}){const n=pi(null),r=da.value,i=!t&&go.value,a=!t&&!fo.value,l="chat"===e&&Pl.value,o=co;return ci(()=>{if(!r)return;const e=n.current;if(!e)return;const t=e.closest("._pillar-panel");if(!t)return;let i=0,a=0,l=!1,o=!1,s=0;const c=e=>{e.target.closest("button")||(i=e.touches[0].clientY,a=i,s=Date.now(),l=!0,o=!1)},p=e=>{if(!l)return;a=e.touches[0].clientY;const n=a-i;if(n<0)return;if(!o){if(n<10)return;o=!0,t.style.transition="none"}const r=n<gp?n:gp+.3*(n-gp);t.style.transform=`translateY(${r}px)`,e.preventDefault()},d=()=>{if(!l||!o)return void(l=!1);l=!1,o=!1;const e=a-i,n=Date.now()-s,r=e/Math.max(n,1);if(t.style.transition="",t.offsetHeight,e>gp||r>.5){t.style.transform="translateY(100%)";const e=()=>{t.removeEventListener("transitionend",e),clearTimeout(n),t.style.transform="",ga()},n=setTimeout(e,600);t.addEventListener("transitionend",e)}else t.style.transform=""};return e.addEventListener("touchstart",c,{passive:!0}),document.addEventListener("touchmove",p,{passive:!1}),document.addEventListener("touchend",d),()=>{e.removeEventListener("touchstart",c),document.removeEventListener("touchmove",p),document.removeEventListener("touchend",d),t.style.transition="",t.style.transform=""}},[r]),Kr("header",{ref:n,class:"_pillar-header pillar-header",children:[r&&Kr("div",{class:"_pillar-drag-indicator pillar-drag-indicator",children:Kr("div",{class:"_pillar-drag-indicator-pill"})}),Kr("div",{class:"_pillar-header-left pillar-header-left",children:[i&&Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-back-btn",onClick:()=>{bo()},"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>'}}),a&&!l&&Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-home-btn",onClick:()=>{vo()},"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>'}})]}),Kr("div",{class:"_pillar-header-right pillar-header-right",children:[l&&Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-new-chat-btn",onClick:()=>{vo()},"aria-label":"New chat",title:"New chat",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z"/></svg>'}}),Kr(hp,{onSelectConversation:o}),Kr("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-close-btn",onClick:()=>{ga()},"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>'}})]})]})}function mp(e){switch(e){case"navigate":return"pillar-tool-badge--navigate";case"query":return"pillar-tool-badge--query";case"trigger_tool":return"pillar-tool-badge--trigger";case"inline_ui":return"pillar-tool-badge--inline";default:return"pillar-tool-badge--default"}}function bp(e){switch(e){case"defined":return"defineTool";case"registered":return"registerTool";case"registry":return"onTask";default:return e}}function vp({onClose:e}){const[t,n]=si([]),[r,i]=si(""),[a,l]=si(null),[o,s]=si("{}"),[c,p]=si(null),[d,u]=si(!1),[h,g]=si(null);ci(()=>{const e="pillar-tool-debug-panel-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent="/**\n * Tool Debug Panel Styles\n * Matches the debug panel theme and styling patterns\n */\n\n.pillar-tool-debug-panel {\n display: flex;\n flex-direction: column;\n height: 100%;\n background-color: #1e1e1e;\n color: #d4d4d4;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 13px;\n}\n\n/* Header */\n.pillar-tool-debug-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 16px;\n background-color: #252526;\n border-bottom: 1px solid #333;\n flex-shrink: 0;\n}\n\n.pillar-tool-debug-title {\n font-size: 14px;\n font-weight: 600;\n margin: 0;\n color: #e5e5e5;\n}\n\n.pillar-tool-debug-header-actions {\n display: flex;\n gap: 8px;\n}\n\n.pillar-tool-debug-btn {\n background-color: transparent;\n border: 1px solid #555;\n color: #d4d4d4;\n padding: 4px 10px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n font-family: inherit;\n transition: background-color 0.15s, border-color 0.15s;\n}\n\n.pillar-tool-debug-btn:hover {\n background-color: #333;\n border-color: #666;\n}\n\n/* Content Layout */\n.pillar-tool-debug-content {\n display: flex;\n flex: 1;\n overflow: hidden;\n}\n\n/* Tool List */\n.pillar-tool-debug-list {\n width: 280px;\n min-width: 220px;\n display: flex;\n flex-direction: column;\n border-right: 1px solid #333;\n background-color: #1e1e1e;\n}\n\n.pillar-tool-debug-search {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 12px;\n background-color: #252526;\n border-bottom: 1px solid #333;\n}\n\n.pillar-tool-debug-search-input {\n flex: 1;\n background-color: #3c3c3c;\n border: 1px solid transparent;\n color: #d4d4d4;\n padding: 6px 10px;\n font-size: 12px;\n font-family: inherit;\n outline: none;\n border-radius: 4px;\n transition: border-color 0.15s;\n}\n\n.pillar-tool-debug-search-input:focus {\n border-color: #3b82f6;\n}\n\n.pillar-tool-debug-search-input::placeholder {\n color: #6b7280;\n}\n\n.pillar-tool-debug-count {\n color: #6b7280;\n font-size: 11px;\n white-space: nowrap;\n}\n\n.pillar-tool-debug-tools {\n flex: 1;\n overflow-y: auto;\n padding: 4px 0;\n}\n\n.pillar-tool-debug-empty {\n padding: 24px 16px;\n color: #6b7280;\n text-align: center;\n font-size: 12px;\n}\n\n/* Tool Item */\n.pillar-tool-debug-tool-item {\n display: block;\n width: 100%;\n padding: 10px 12px;\n background: none;\n border: none;\n border-bottom: 1px solid #2d2d2d;\n text-align: left;\n cursor: pointer;\n color: #d4d4d4;\n font-family: inherit;\n transition: background-color 0.15s;\n}\n\n.pillar-tool-debug-tool-item:hover {\n background-color: #252526;\n}\n\n.pillar-tool-debug-tool-item--selected {\n background-color: #2d4a7c;\n}\n\n.pillar-tool-debug-tool-item--selected:hover {\n background-color: #2d4a7c;\n}\n\n.pillar-tool-debug-tool-header {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-bottom: 4px;\n}\n\n.pillar-tool-debug-tool-name {\n font-weight: 600;\n font-size: 12px;\n color: #e5e5e5;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.pillar-tool-debug-tool-desc {\n font-size: 11px;\n color: #9ca3af;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin-bottom: 4px;\n}\n\n.pillar-tool-debug-tool-meta {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 10px;\n}\n\n.pillar-tool-source {\n color: #6b7280;\n background-color: #2d2d2d;\n padding: 1px 5px;\n border-radius: 3px;\n}\n\n.pillar-tool-handler {\n color: #6b7280;\n}\n\n.pillar-tool-handler--active {\n color: #10b981;\n}\n\n/* Type Badges */\n.pillar-tool-badge {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n padding: 2px 5px;\n border-radius: 3px;\n white-space: nowrap;\n letter-spacing: 0.5px;\n}\n\n.pillar-tool-badge--navigate {\n background-color: #3b82f6;\n color: white;\n}\n\n.pillar-tool-badge--query {\n background-color: #8b5cf6;\n color: white;\n}\n\n.pillar-tool-badge--trigger {\n background-color: #10b981;\n color: white;\n}\n\n.pillar-tool-badge--inline {\n background-color: #f59e0b;\n color: black;\n}\n\n.pillar-tool-badge--default {\n background-color: #4b5563;\n color: white;\n}\n\n/* Tool Detail */\n.pillar-tool-debug-detail {\n flex: 1;\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n padding: 16px;\n background-color: #1e1e1e;\n}\n\n.pillar-tool-debug-no-selection {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: #6b7280;\n text-align: center;\n padding: 24px;\n}\n\n.pillar-tool-debug-detail-header {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 8px;\n}\n\n.pillar-tool-debug-detail-name {\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n color: #e5e5e5;\n}\n\n.pillar-tool-debug-detail-desc {\n color: #9ca3af;\n margin: 0 0 16px 0;\n font-size: 13px;\n line-height: 1.5;\n}\n\n.pillar-tool-debug-section-title {\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n margin: 0 0 8px 0;\n}\n\n/* Schema Display */\n.pillar-tool-debug-schema {\n margin-bottom: 16px;\n}\n\n.pillar-tool-debug-schema-content {\n background-color: #252526;\n border: 1px solid #333;\n border-radius: 6px;\n padding: 12px;\n margin: 0;\n font-size: 11px;\n line-height: 1.5;\n overflow-x: auto;\n max-height: 200px;\n color: #d4d4d4;\n}\n\n/* Input Editor */\n.pillar-tool-debug-input {\n margin-bottom: 16px;\n}\n\n.pillar-tool-debug-textarea {\n width: 100%;\n background-color: #252526;\n border: 1px solid #333;\n color: #d4d4d4;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 12px;\n line-height: 1.5;\n padding: 12px;\n border-radius: 6px;\n resize: vertical;\n outline: none;\n transition: border-color 0.15s;\n box-sizing: border-box;\n}\n\n.pillar-tool-debug-textarea:focus {\n border-color: #3b82f6;\n}\n\n.pillar-tool-debug-textarea--error {\n border-color: #ef4444;\n}\n\n.pillar-tool-debug-json-error {\n color: #ef4444;\n font-size: 11px;\n margin-top: 4px;\n}\n\n/* Actions */\n.pillar-tool-debug-actions {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-bottom: 16px;\n}\n\n.pillar-tool-debug-execute-btn {\n background-color: #3b82f6;\n border: none;\n color: white;\n padding: 8px 16px;\n border-radius: 6px;\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n transition: background-color 0.15s;\n}\n\n.pillar-tool-debug-execute-btn:hover:not(:disabled) {\n background-color: #2563eb;\n}\n\n.pillar-tool-debug-execute-btn:disabled {\n background-color: #4b5563;\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.pillar-tool-debug-no-handler {\n color: #f59e0b;\n font-size: 12px;\n}\n\n/* Execution Result */\n.pillar-tool-debug-result {\n border-radius: 6px;\n padding: 12px;\n margin-top: auto;\n}\n\n.pillar-tool-debug-result--success {\n background-color: rgba(16, 185, 129, 0.1);\n border: 1px solid rgba(16, 185, 129, 0.3);\n}\n\n.pillar-tool-debug-result--error {\n background-color: rgba(239, 68, 68, 0.1);\n border: 1px solid rgba(239, 68, 68, 0.3);\n}\n\n.pillar-tool-debug-result--success .pillar-tool-debug-section-title {\n color: #10b981;\n}\n\n.pillar-tool-debug-result--error .pillar-tool-debug-section-title {\n color: #ef4444;\n}\n\n.pillar-tool-debug-result-content {\n margin: 0;\n font-size: 11px;\n line-height: 1.5;\n white-space: pre-wrap;\n word-break: break-word;\n color: #d4d4d4;\n}\n\n/* Scrollbar Styling */\n.pillar-tool-debug-tools::-webkit-scrollbar,\n.pillar-tool-debug-detail::-webkit-scrollbar,\n.pillar-tool-debug-schema-content::-webkit-scrollbar {\n width: 8px;\n}\n\n.pillar-tool-debug-tools::-webkit-scrollbar-track,\n.pillar-tool-debug-detail::-webkit-scrollbar-track,\n.pillar-tool-debug-schema-content::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.pillar-tool-debug-tools::-webkit-scrollbar-thumb,\n.pillar-tool-debug-detail::-webkit-scrollbar-thumb,\n.pillar-tool-debug-schema-content::-webkit-scrollbar-thumb {\n background-color: #4b5563;\n border-radius: 4px;\n}\n\n.pillar-tool-debug-tools::-webkit-scrollbar-thumb:hover,\n.pillar-tool-debug-detail::-webkit-scrollbar-thumb:hover,\n.pillar-tool-debug-schema-content::-webkit-scrollbar-thumb:hover {\n background-color: #6b7280;\n}\n",document.head.appendChild(t)}},[]),ci(()=>{const e=Ta();if(!e)return;n(e.getTools());return e.on("tools:change",t=>{const r=e.getTools();n(r),"remove"===t.action&&l(e=>e&&e.name===t.name?(g(null),null):e)})},[]);const f=di(()=>{if(!r)return t;const e=r.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.type?.toLowerCase().includes(e))},[t,r]),m=ui(e=>{l(e),g(null);const t=function(e){if(!e?.properties)return{};const t={};for(const[n,r]of Object.entries(e.properties)){const e=r;if(void 0!==e.default)t[n]=e.default;else if(e.enum&&e.enum.length>0)t[n]=e.enum[0];else switch(e.type){case"string":t[n]="";break;case"number":t[n]=0;break;case"boolean":t[n]=!1;break;case"array":t[n]=[];break;case"object":t[n]={};break;default:t[n]=null}}return t}(e.inputSchema);s(JSON.stringify(t,null,2)),p(null)},[]),b=ui(e=>{s(e);try{JSON.parse(e),p(null)}catch(e){p(e instanceof Error?e.message:"Invalid JSON")}},[]),v=ui(async()=>{if(!a||c)return;const e=Ta();if(e){u(!0),g(null);try{const t=JSON.parse(o),n=await e.executeToolForDebug(a.name,t);g(n)}catch(e){g({success:!1,error:e instanceof Error?e.message:String(e)})}finally{u(!1)}}},[a,o,c]),_=ui(()=>{const e=Ta();e&&n(e.getTools())},[]);return Kr("div",{class:"pillar-tool-debug-panel",children:[Kr("div",{class:"pillar-tool-debug-header",children:[Kr("h2",{class:"pillar-tool-debug-title",children:"Tool Debugger"}),Kr("div",{class:"pillar-tool-debug-header-actions",children:[Kr("button",{class:"pillar-tool-debug-btn",onClick:_,title:"Refresh tools list",children:"Refresh"}),e&&Kr("button",{class:"pillar-tool-debug-btn",onClick:e,children:"Close"})]})]}),Kr("div",{class:"pillar-tool-debug-content",children:[Kr("div",{class:"pillar-tool-debug-list",children:[Kr("div",{class:"pillar-tool-debug-search",children:[Kr("input",{type:"text",class:"pillar-tool-debug-search-input",placeholder:"Search tools...",value:r,onInput:e=>i(e.target.value)}),Kr("span",{class:"pillar-tool-debug-count",children:[f.length," tool",1!==f.length?"s":""]})]}),Kr("div",{class:"pillar-tool-debug-tools",children:0===f.length?Kr("div",{class:"pillar-tool-debug-empty",children:0===t.length?"No tools registered":"No tools match your search"}):f.map(e=>Kr("button",{class:"pillar-tool-debug-tool-item "+(a?.name===e.name?"pillar-tool-debug-tool-item--selected":""),onClick:()=>m(e),children:[Kr("div",{class:"pillar-tool-debug-tool-header",children:[Kr("span",{class:"pillar-tool-debug-tool-name",children:e.name}),e.type&&Kr("span",{class:`pillar-tool-badge ${mp(e.type)}`,children:e.type})]}),Kr("div",{class:"pillar-tool-debug-tool-desc",children:e.description||"No description"}),Kr("div",{class:"pillar-tool-debug-tool-meta",children:[Kr("span",{class:"pillar-tool-source",children:bp(e.source)}),e.hasHandler?Kr("span",{class:"pillar-tool-handler pillar-tool-handler--active",children:"handler"}):Kr("span",{class:"pillar-tool-handler",children:"no handler"})]})]},e.name))})]}),Kr("div",{class:"pillar-tool-debug-detail",children:a?Kr($,{children:[Kr("div",{class:"pillar-tool-debug-detail-header",children:[Kr("h3",{class:"pillar-tool-debug-detail-name",children:a.name}),a.type&&Kr("span",{class:`pillar-tool-badge ${mp(a.type)}`,children:a.type})]}),Kr("p",{class:"pillar-tool-debug-detail-desc",children:a.description||"No description provided"}),a.inputSchema&&Kr("div",{class:"pillar-tool-debug-schema",children:[Kr("h4",{class:"pillar-tool-debug-section-title",children:"Input Schema"}),Kr("pre",{class:"pillar-tool-debug-schema-content",children:JSON.stringify(a.inputSchema,null,2)})]}),Kr("div",{class:"pillar-tool-debug-input",children:[Kr("h4",{class:"pillar-tool-debug-section-title",children:"Input Parameters"}),Kr("textarea",{class:"pillar-tool-debug-textarea "+(c?"pillar-tool-debug-textarea--error":""),value:o,onInput:e=>b(e.target.value),rows:8,spellcheck:!1}),c&&Kr("div",{class:"pillar-tool-debug-json-error",children:c})]}),Kr("div",{class:"pillar-tool-debug-actions",children:[Kr("button",{class:"pillar-tool-debug-execute-btn",onClick:v,disabled:d||!!c||!a.hasHandler,children:d?"Executing...":"Execute Tool"}),!a.hasHandler&&Kr("span",{class:"pillar-tool-debug-no-handler",children:"No handler registered"})]}),h&&Kr("div",{class:"pillar-tool-debug-result "+(h.success?"pillar-tool-debug-result--success":"pillar-tool-debug-result--error"),children:[Kr("h4",{class:"pillar-tool-debug-section-title",children:h.success?"Result":"Error"}),Kr("pre",{class:"pillar-tool-debug-result-content",children:h.success?JSON.stringify(h.result,null,2)||"undefined":h.error})]})]}):Kr("div",{class:"pillar-tool-debug-no-selection",children:Kr("p",{children:"Select a tool from the list to view details and test execution"})})})]})]})}function _p(){const e=zo(),t=ho.value,n=ea.value,r="chat"===t.type,i="home"===t.type,a=()=>{switch(n){case"tools":return Kr(vp,{});case"support":return Kr("div",{style:{padding:"24px",textAlign:"center"},children:[Kr("h2",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:"Hello World"}),Kr("p",{style:{color:"var(--pillar-text-muted)",fontSize:"14px"},children:"Support tab content goes here."})]});default:return null}};return Kr("div","tools"===n?{class:"_pillar-panel-ui pillar-panel-ui",children:Kr(vp,{})}:"assistant"!==n?{class:"_pillar-panel-ui pillar-panel-ui",children:[Kr(fp,{currentView:"home"}),Kr("div",{class:"_pillar-content pillar-content",children:a()})]}:{class:"_pillar-panel-ui pillar-panel-ui",children:[Kr(fp,{currentView:t.type,hideNavigation:r}),Kr("div",{class:"_pillar-content pillar-content",children:(()=>{switch(t.type){case"home":default:return Kr(Wo,{});case"chat":return Kr(dp,{})}})()}),!r&&!i&&Kr("div",{class:"_pillar-chat-input-area pillar-chat-input-area",children:Kr(Bo,{placeholder:e.inputPlaceholder})})]})}class xp{constructor(e,t,n,r){this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,this.resizeHandle=null,this.unsubscribe=null,this.isManualMount=!1,this.themeObserver=null,this._isResizing=!1,this._resizeStartX=0,this._resizeStartWidth=0,this._resizeRafId=null,this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,this.handleResizeStart=e=>{if(!Yi.value||!this.config.panel.resizable)return;e.preventDefault(),e.stopPropagation();const t="touches"in e?e.touches[0].clientX:e.clientX;this._isResizing=!0,this._resizeStartX=t,this._resizeStartWidth=ra.value,this._boundHandleResizeMove=this.handleResizeMove.bind(this),this._boundHandleResizeEnd=this.handleResizeEnd.bind(this),document.addEventListener("mousemove",this._boundHandleResizeMove),document.addEventListener("mouseup",this._boundHandleResizeEnd),document.addEventListener("touchmove",this._boundHandleResizeMove,{passive:!1}),document.addEventListener("touchend",this._boundHandleResizeEnd),document.addEventListener("touchcancel",this._boundHandleResizeEnd),document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",document.documentElement.style.cursor="col-resize",document.documentElement.style.transition="none",this.panelElement?.classList.add("_pillar-panel--resizing","pillar-panel--resizing")},this.handleResizeEnd=e=>{this._isResizing&&(null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this._isResizing=!1,Zi(ra.value),this._boundHandleResizeMove&&(document.removeEventListener("mousemove",this._boundHandleResizeMove),document.removeEventListener("touchmove",this._boundHandleResizeMove)),this._boundHandleResizeEnd&&(document.removeEventListener("mouseup",this._boundHandleResizeEnd),document.removeEventListener("touchend",this._boundHandleResizeEnd),document.removeEventListener("touchcancel",this._boundHandleResizeEnd)),this._boundHandleResizeMove=null,this._boundHandleResizeEnd=null,document.body.style.userSelect="",document.body.style.webkitUserSelect="",document.documentElement.style.cursor="",document.documentElement.style.transition="padding 0.3s ease",this.panelElement?.classList.remove("_pillar-panel--resizing","pillar-panel--resizing"))},this.handleKeyDown=e=>{"Escape"===e.key&&Yi.value&&ga()},this.config=e,this.api=t,this.events=n,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 Yi.value}async init(){var e,t,n;if(e=this.config.panel.position,ta.value=e,(e=>{na.value=e})(this.config.panel.mode),t=this.config.panel.hoverBreakpoint,ia.value=t,n=this.config.panel.hoverBackdrop,aa.value=n,this.config.panel.resizable){const e=Xi();fa(null!==e?e:this.config.panel.width)}else fa(this.config.panel.width);this.createHost(),this.isManualMount||this.createBackdrop(),this.createPanel(),this.renderPreact(),this.bindEvents(),this.subscribeToState()}open(e){if(e?.search&&(Fl(e.search),mo("chat"),Kl()),Yi.value)return e?.view&&mo(e.view),void(e?.focusInput&&Gl());Yi.value=!0,Ji(!0),"overlay"===ha.value&&(document.body.style.overflow="hidden"),e?.view&&!e?.search&&mo(e.view),e?.focusInput?Gl():this.setupFocusTrap()}close(){Yi.value&&ga()}navigate(e,t){Yi.value?mo(e,t):this.open({view:e})}destroy(){this.close(),this._isResizing&&this.handleResizeEnd(new MouseEvent("mouseup")),null!==this._resizeRafId&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.resizeHandle&&(this.resizeHandle.removeEventListener("mousedown",this.handleResizeStart),this.resizeHandle.removeEventListener("touchstart",this.handleResizeStart),this.resizeHandle=null),this.isManualMount||this.removePushModeStyles(),this.unsubscribe?.(),this.unsubscribe=null,ca?.(),ca=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),ma(),_o(),no()}handleResizeMove(e){this._isResizing&&("touches"in e&&e.preventDefault(),null===this._resizeRafId&&(this._resizeRafId=requestAnimationFrame(()=>{if(this._resizeRafId=null,!this._isResizing)return;const t="touches"in e?e.touches[0].clientX:e.clientX,n=this._resizeStartX-t,r="right"===ta.value?n:-n,i=window.innerWidth-100,a=Math.max(xp.MIN_PANEL_WIDTH,Math.min(i,this._resizeStartWidth+r));fa(a)})))}subscribeToState(){if(this.isManualMount)return void(this.unsubscribe=Yi.subscribe(e=>{e||this.events.emit("panel:close")}));let e=Yi.value,t=ha.value;const n=()=>{const e=Yi.value,t="push"===ha.value,n=ra.value,r=ta.value,i=pa.value&&aa.value||da.value;e?(t?(this.applyPushModeStyles(n,r),this.setBackdropVisible(!1)):(this.removePushModeStyles(),document.body.style.overflow="hidden",this.setBackdropVisible(i)),this.panelElement?.classList.add("_pillar-panel--open","pillar-panel--open")):(this.removePushModeStyles(),document.body.style.overflow="",this.setBackdropVisible(!1),this.panelElement?.classList.remove("_pillar-panel--open","pillar-panel--open"))};n();const r=Yi.subscribe(t=>{t!==e&&(e=t,n(),t||this.events.emit("panel:close"))}),i=ha.subscribe(e=>{e!==t&&(t=e,n())});let a=ua.value;const l=ua.subscribe(e=>{e!==a&&(a=e,e?this.panelElement?.classList.add("_pillar-panel--full-width","pillar-panel--full-width"):this.panelElement?.classList.remove("_pillar-panel--full-width","pillar-panel--full-width"))});let o=da.value;const s=da.subscribe(e=>{e!==o&&(o=e,e?this.panelElement?.classList.add("_pillar-panel--mobile","pillar-panel--mobile"):this.panelElement?.classList.remove("_pillar-panel--mobile","pillar-panel--mobile"),n())});let c=ra.value;const p=ra.subscribe(e=>{e!==c&&(c=e,this.panelElement?.style.setProperty("--pillar-panel-width",`${e}px`),Yi.value&&n())});this.unsubscribe=()=>{r(),i(),l(),s(),p()}}setBackdropVisible(e){this.backdrop&&(e?(this.backdrop.style.opacity="1",this.backdrop.style.visibility="visible",this.backdrop.classList.add("_pillar-backdrop--visible","pillar-backdrop--visible")):(this.backdrop.style.opacity="0",this.backdrop.style.visibility="hidden",this.backdrop.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")))}getPushTargetElement(){const e=this.config.panel.pushTarget;return e?"string"==typeof e?document.querySelector(e)||document.documentElement:e:document.documentElement}applyPushModeStyles(e,t){const n=this.getPushTargetElement();n.style.transition="padding 0.3s ease","right"===t?(n.style.paddingRight=`${e}px`,document.documentElement.style.setProperty("--pillar-inset-right",`${e}px`),document.documentElement.style.setProperty("--pillar-inset-left","0px")):(n.style.paddingLeft=`${e}px`,document.documentElement.style.setProperty("--pillar-inset-left",`${e}px`),document.documentElement.style.setProperty("--pillar-inset-right","0px"))}removePushModeStyles(){const e=this.getPushTargetElement();e.style.paddingLeft="",e.style.paddingRight="",document.documentElement.style.removeProperty("--pillar-inset-right"),document.documentElement.style.removeProperty("--pillar-inset-left"),setTimeout(()=>{Yi.value||(e.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 t=wo,n=this.transformStylesForRegularDOM(t),r=document.createElement("style");r.id=e,r.textContent=n,document.head.appendChild(r);const i=So(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=wo,this.shadow.appendChild(e);const t=So(this.config.theme);if(t){const e=document.createElement("style");e.textContent=t,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 t=this.rootContainer||document.body;let n=null;"string"==typeof e?(n=document.querySelector(e),n||(p.warn(`[Pillar] Container element not found: ${e}, falling back to root container`),n=t)):n=e instanceof HTMLElement?e:t,n.appendChild(this.host)}mountTo(e){this.host?(this.host.parentElement&&this.host.parentElement.removeChild(this.host),e.appendChild(this.host)):p.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.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.4s cubic-bezier(0.32, 0.72, 0, 1);\n z-index: 99998;\n ",this.backdrop.addEventListener("click",()=>{ga()});(this.rootContainer||document.body).appendChild(this.backdrop)}createPanel(){const e=this.renderContainer;if(!e)return;this.panelElement=document.createElement("div");const t=this.isManualMount?" _pillar-panel--manual pillar-panel--manual":"",n=`_pillar-panel--${ta.value} pillar-panel--${ta.value}`,r=da.value?" _pillar-panel--mobile pillar-panel--mobile":"",i=ua.value?" _pillar-panel--full-width pillar-panel--full-width":"";this.panelElement.className=`_pillar-panel pillar-panel ${n}${t}${r}${i}`,this.panelElement.style.setProperty("--pillar-panel-width",`${ra.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),!this.config.panel.resizable||this.isManualMount||this.config.edgeTrigger.enabled||(this.resizeHandle=document.createElement("div"),this.resizeHandle.className="_pillar-resize-handle pillar-resize-handle",this.resizeHandle.addEventListener("mousedown",this.handleResizeStart),this.resizeHandle.addEventListener("touchstart",this.handleResizeStart,{passive:!1}),this.panelElement.appendChild(this.resizeHandle)),e.appendChild(this.panelElement)}renderPreact(){this.renderRoot&&Y(Kr(Po,{api:this.api,events:this.events,config:this.config,children:Kr(_p,{})}),this.renderRoot)}bindEvents(){document.addEventListener("keydown",this.handleKeyDown)}setupFocusTrap(){setTimeout(()=>{const e=this.renderContainer,t=e?.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');t?.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 t=So(this.config.theme);if(this.shadow){const e=this.shadow.querySelector("style[data-pillar-theme]");if(e&&t)e.textContent=t;else if(t&&!e){const e=document.createElement("style");e.textContent=t,e.setAttribute("data-pillar-theme","");const n=this.shadow.querySelector("style");n?.nextSibling?this.shadow.insertBefore(e,n.nextSibling):this.shadow.appendChild(e)}}else{const e=this.transformStylesForRegularDOM(t),n=document.getElementById("pillar-sdk-theme");if(n&&e)n.textContent=e;else if(e&&!n){const t=document.createElement("style");t.id="pillar-sdk-theme",t.textContent=e,document.head.appendChild(t)}}}}xp.MIN_PANEL_WIDTH=200;function yp({label:e,x:t,y:n,isVisible:r,onClick:i}){const a=pi(null),[l,o]=si({x:t,y:n}),[s,c]=si(!1),p=ui(()=>{if(!a.current||!r)return;const e=a.current.getBoundingClientRect(),i=window.innerWidth;let l=t,s=n,p=!1;l=t-e.width/2,l<10?l=10:l+e.width>i-10&&(l=i-e.width-10),s=n-e.height-10,s<10&&(s=n+10,p=!0),o({x:l,y:s}),c(p)},[t,n,r]);ci(()=>{r&&requestAnimationFrame(p)},[r,p,t,n]);return Kr("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:[Kr("div",{class:"pillar-text-selection-popover__content",children:[Kr("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>'}}),Kr("span",{children:e})]}),Kr("div",{class:"pillar-text-selection-popover__arrow"})]})}const wp="pillar-text-selection-styles";class kp{constructor(e,t,n){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}),Ql({type:"highlighted_text",url_origin:window.location.href,text_content:this.currentSelection}),this.hidePopover(),window.getSelection()?.removeAllRanges(),this.openPanel())},this.config=e,this.events=t,this.openPanel=n}init(){this.stylesInjected||(ba(document,"/* Pillar Text Selection Popover Styles */\n.pillar-text-selection-popover {\n position: absolute;\n z-index: 99999;\n padding: 6px 12px;\n font-family: var(--pillar-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",wp),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(wp)?.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 t=window.getSelection();if(!t||t.isCollapsed)return;const n=t.toString().trim();if(n.length<3)return;const r=t.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=n,this.showPopover(o,s)}showPopover(e,t){this.container&&(this.isVisible=!0,Y(Kr(yp,{label:this.config.textSelection.label,x:e,y:t,isVisible:!0,onClick:this.handlePopoverClick}),this.container),this.events.emit("textSelection:shown",{text:this.currentSelection}))}hidePopover(){this.container&&this.isVisible&&(this.isVisible=!1,Y(Kr(yp,{label:this.config.textSelection.label,x:0,y:0,isVisible:!1,onClick:()=>{}}),this.container))}}const Sp={recentActions:[]},Cp={},Pp=Mi({...Sp}),Ep=Mi({...Cp});Di(()=>{const e=Pp.value;return!!(e.currentPage||e.currentFeature||e.userRole||e.errorState||e.recentActions&&e.recentActions.length>0)}),Di(()=>!!Pp.value.errorState);const Tp=e=>{Ep.value={...e}},zp=Mi(null),Rp=Mi([]);Di(()=>null!==zp.value),Di(()=>zp.value&&zp.value.steps[zp.value.current_step]||null);const Ip=Di(()=>zp.value?zp.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);function Mp(e,t){if(!zp.value)return;const n=zp.value.steps.map((n,r)=>r===e?{...n,status:t}:n);zp.value={...zp.value,steps:n}}function Ap(){if(!zp.value)return null;const e=zp.value.current_step+1;if(e>=zp.value.steps.length)return null;const t=zp.value.steps[e].auto_run?"active":"awaiting_initiation",n=zp.value.steps.map((n,r)=>r===e?{...n,status:t}:n);return zp.value={...zp.value,steps:n,current_step:e},zp.value.steps[e]}function $p(){if(!zp.value)return null;const e=zp.value;return Rp.value=[...Rp.value,e],zp.value=null,e}Di(()=>zp.value?Ip.value/zp.value.total_steps:0);const Lp=/^[a-zA-Z_][a-zA-Z0-9_.\-:]{0,63}$/;const Op={tools:new Map,clientInfo:null};function Dp(e,t){Op.clientInfo={platform:e,version:t}}function jp(){return Op.clientInfo}function Hp(e){const t=Op.tools.get(e);return t?.handler}function Np(e){return Op.tools.get(e)}function Up(e){return Op.tools.has(e)}function Bp(){return Array.from(Op.tools.keys())}function Fp(e,t,n){const r=[];for(const[e,t]of Op.tools){const n={name:e,description:t.description,type:t.type};t.examples?.length&&(n.examples=t.examples),t.path&&(n.path=t.path),t.externalUrl&&(n.external_url=t.externalUrl),t.autoRun&&(n.auto_run=t.autoRun),t.autoComplete&&(n.auto_complete=t.autoComplete),t.returns&&(n.returns_data=t.returns),t.dataSchema&&(n.data_schema=t.dataSchema),t.defaultData&&(n.default_data=t.defaultData),t.requiredContext&&(n.required_context=t.requiredContext),r.push(n)}return{platform:e,version:t,gitSha:n,generatedAt:(new Date).toISOString(),tools:r}}function qp(){Op.tools.clear(),Op.clientInfo=null}function Wp(){return Op.tools.size}const Vp=Np,Kp=Up,Gp=Bp,Qp=Wp;class Jp{constructor(e={}){this._callback=null,this._debounceTimer=null,this._lastRoute=null,this._running=!1,this._originalPushState=null,this._originalReplaceState=null,this._handleRouteChange=()=>{this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{const e=this._getCurrentUrl();e!==this._lastRoute&&(this._lastRoute=e,this._callback&&this._callback(this.getCurrentRoute()))},this._debounceMs)},this._debounceMs=e.debounceMs??100}get running(){return this._running}onRouteChange(e){this._callback=e}start(){this._running||"undefined"!=typeof window&&(this._running=!0,this._lastRoute=this._getCurrentUrl(),this._patchHistory(),window.addEventListener("popstate",this._handleRouteChange),window.addEventListener("hashchange",this._handleRouteChange))}stop(){this._running&&(this._running=!1,this._restoreHistory(),window.removeEventListener("popstate",this._handleRouteChange),window.removeEventListener("hashchange",this._handleRouteChange),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null))}getCurrentRoute(){return{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,url:window.location.href,title:document.title}}_patchHistory(){this._originalPushState=history.pushState.bind(history),this._originalReplaceState=history.replaceState.bind(history),history.pushState=(...e)=>{this._originalPushState(...e),this._handleRouteChange()},history.replaceState=(...e)=>{this._originalReplaceState(...e),this._handleRouteChange()}}_restoreHistory(){this._originalPushState&&(history.pushState=this._originalPushState),this._originalReplaceState&&(history.replaceState=this._originalReplaceState),this._originalPushState=null,this._originalReplaceState=null}_getCurrentUrl(){return window.location.pathname+window.location.search+window.location.hash}}const Xp="pillar-";const Zp=[{id:"assistant",label:"Assistant",enabled:!0,order:0}],Yp={apiBaseUrl:"https://help-api.trypillar.com",assistantDisplayName:"Copilot",inputPlaceholder:"Ask anything...",welcomeMessage:"Hi! How can I help you today?",panel:{enabled:!0,position:"right",mode:"push",width:380,useShadowDOM:!1,hoverBreakpoint:1200,hoverBackdrop:!0,fullWidthBreakpoint:500,initialOpen:!1,resizable:!0},edgeTrigger:{enabled:!0,resizable:!0},mobileTrigger:{enabled:!0,breakpoint:700,position:"bottom-right",icon:"sparkle",iconColor:"white",size:"medium",label:"Get help",offset:24},urlParams:{enabled:!0,prefix:"pillar-",clearAfterOpen:!0},textSelection:{enabled:!0,label:"Ask AI"},domScanning:{enabled:!1,includeText:!0,maxDepth:20,visibleOnly:!0,maxTextLength:500,interactionHighlight:{enabled:!0,outlineColor:"#3b82f6",outlineWidth:2,outlineOffset:2,duration:2e3,scrollIntoView:!0,scrollBehavior:"smooth"}},suggestions:{enabled:!0,debounceMs:100,displayLimit:3},theme:{mode:"auto"},zIndex:{push:1,hover:9999},excludeRoutes:["/login","/signup"]};function ed(e){if(!e||0===e.length)return Zp;const t=new Map;for(const e of Zp)t.set(e.id,{...e});for(const n of e)t.set(n.id,{...n});const n=t.get("assistant");return n&&(n.enabled=!0),Array.from(t.values()).sort((e,t)=>e.order-t.order)}function td(e){const t=e.agentSlug??e.productKey;if(!t)throw new Error("[Pillar] agentSlug (or productKey) is required");return{productKey:t,agentSlug:e.agentSlug,apiBaseUrl:e.apiBaseUrl||Yp.apiBaseUrl,assistantDisplayName:e.assistantDisplayName||Yp.assistantDisplayName,inputPlaceholder:e.inputPlaceholder||Yp.inputPlaceholder,welcomeMessage:e.welcomeMessage||Yp.welcomeMessage,platform:e.platform||"web",version:e.version,debug:e.debug??!1,tracing:e.tracing??e.debug??!1,panel:{...Yp.panel,...e.panel},edgeTrigger:{...Yp.edgeTrigger,...e.edgeTrigger},mobileTrigger:{...Yp.mobileTrigger,...e.mobileTrigger},urlParams:{...Yp.urlParams,...e.urlParams},textSelection:{...Yp.textSelection,...e.textSelection},domScanning:{...Yp.domScanning,...e.domScanning,enabled:!1,interactionHighlight:{...Yp.domScanning.interactionHighlight,...e.domScanning?.interactionHighlight}},suggestions:{...Yp.suggestions,...e.suggestions},sidebarTabs:ed(e.sidebarTabs),theme:{mode:e.theme?.mode??Yp.theme.mode,colors:{...e.theme?.colors},darkColors:{...e.theme?.darkColors},fontFamily:e.theme?.fontFamily},customCSS:e.customCSS,zIndex:{...Yp.zIndex,...e.zIndex},excludeRoutes:e.excludeRoutes??Yp.excludeRoutes,onReady:e.onReady,onError:e.onError}}class nd{_persistExternalUserId(e){if("undefined"!=typeof window)try{null===e?localStorage.removeItem(nd.EXTERNAL_USER_ID_STORAGE_KEY):localStorage.setItem(nd.EXTERNAL_USER_ID_STORAGE_KEY,e)}catch{}}_getStoredExternalUserId(){if("undefined"==typeof window)return null;try{return localStorage.getItem(nd.EXTERNAL_USER_ID_STORAGE_KEY)}catch{return null}}get _registeredActions(){return this._registeredTools}constructor(){this._state="uninitialized",this._config=null,this._api=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._initPromise=null,this._rootContainer=null,this._unsubscribeHoverMode=null,this._context={...Sp},this._userProfile={...Cp},this._externalUserId=null,this._taskHandlers=new Map,this._anyTaskHandler=null,this._registeredTools=new Map,this._definedTools=new Map,this._cardRenderers=new Map,this._debugPanelContainer=null,this._routeObserver=null,this._isRouteExcluded=!1,this._suggestionPool=[],this._highlightedElement=null,this._highlightTimeout=null,this._fadeOutTimeout=null,this._originalStyles=null,this._events=new u}_createRootContainer(){const{push:e,hover:t}=this._config.zIndex;let n=document.getElementById("pillar-root");if(n)return this._subscribeToHoverModeForRoot(n,e,t),n;n=document.createElement("div"),n.id="pillar-root";const r=pa.value?t:e;return n.style.cssText=`isolation: isolate; z-index: ${r}; position: relative;`,document.body.appendChild(n),this._subscribeToHoverModeForRoot(n,e,t),n}_subscribeToHoverModeForRoot(e,t,n){this._unsubscribeHoverMode?.();let r=pa.value;this._unsubscribeHoverMode=pa.subscribe(i=>{i!==r&&(r=i,e.style.zIndex=String(i?n:t))})}static async init(e){if(!e.agentSlug&&!e.productKey)throw new Error("[Pillar] agentSlug (or productKey) is required");return nd.instance||(nd.instance=new nd,Ea(nd.instance)),await nd.instance._init(e),nd.instance}static getInstance(){return nd.instance}static destroy(){nd.instance&&(nd.instance._destroy(),nd.instance=null,Ea(null))}get state(){return this._state}get isReady(){return"ready"===this._state}get isPanelOpen(){return Yi.value}get config(){return this._config}get isDebugEnabled(){return this._config?.debug??!1}getDebugLog(){return this._config?.debug?o.getEntries():[]}onDebugLog(e){return o.subscribe(e)}clearDebugLog(){o.clear()}getTools(){if(!this._config?.debug)return[];const e=[],t=new Set;for(const[n,r]of this._definedTools){t.add(n);const i="inline_ui"===r.type;e.push({name:n,description:r.description,type:r.type,inputSchema:r.inputSchema,source:"defined",hasHandler:i?this._cardRenderers.has(n):"function"==typeof r.execute})}for(const[n,r]of this._registeredTools)t.has(n)||(t.add(n),e.push({name:n,description:r.description||"",type:r.type,inputSchema:r.dataSchema,source:"registered",hasHandler:this._taskHandlers.has(n)}));for(const n of Bp()){if(t.has(n))continue;t.add(n);const r=Np(n);e.push({name:n,description:r?.description||"",type:r?.type,inputSchema:r?.dataSchema,source:"registry",hasHandler:this._taskHandlers.has(n)})}return e.sort((e,t)=>e.name.localeCompare(t.name))}async executeToolForDebug(e,t){if(!this._config?.debug)return{success:!1,error:"Debug mode not enabled"};try{const n=this._definedTools.get(e);if(n){if("inline_ui"===n.type)return{success:!1,error:`Tool "${e}" is an inline_ui tool. It renders UI via its card renderer instead of executing a handler.`};if(n.execute){return{success:!0,result:await n.execute(t)}}}const r=this._taskHandlers.get(e);if(r){return{success:!0,result:await r(t)}}return{success:!1,error:`No handler found for tool: ${e}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}on(e,t){return this._events.on(e,t)}open(e){this._panel&&!this._isRouteExcluded&&(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,t){this._panel?.navigate(e,t),this._events.emit("panel:navigate",{view:e,params:t})}setContext(e){this._context={...this._context,...e},(e=>{Pp.value={...Pp.value,...e}})(e),this._events.emit("context:change",{context:this._context})}getChatContext(){const e=Na.value,t=Ua.value;return 0===e.length?null:{conversationId:t,messages:e.map(e=>({role:e.role,content:e.content}))}}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 kp(this._config,this._events,()=>this.open()),this._textSelectionManager.init()):this._textSelectionManager&&(this._textSelectionManager.destroy(),this._textSelectionManager=null),this._events.emit("textSelection:change",{enabled:e}))}setDOMScanningEnabled(e){}get isDOMScanningEnabled(){return!1}highlightElement(e){const t=this._config?.domScanning.interactionHighlight;if(!t?.enabled)return;this.clearHighlight(!0),t.scrollIntoView&&e.scrollIntoView({behavior:t.scrollBehavior,block:"center",inline:"nearest"}),this._originalStyles={outline:e.style.outline,outlineOffset:e.style.outlineOffset,transition:e.style.transition},this._highlightedElement=e;const n=e.style.transition,r="outline-color 0.3s ease-in-out";e.style.transition=n?`${n}, ${r}`:r,e.style.outline=`${t.outlineWidth}px solid transparent`,e.style.outlineOffset=`${t.outlineOffset}px`,e.offsetHeight,e.style.outline=`${t.outlineWidth}px solid ${t.outlineColor}`,p.log("[Pillar] Element highlighted with fade-in:",e.tagName),t.duration>0&&(this._highlightTimeout=setTimeout(()=>{this.clearHighlight()},t.duration))}clearHighlight(e=!1){if(this._highlightTimeout&&(clearTimeout(this._highlightTimeout),this._highlightTimeout=null),this._fadeOutTimeout&&(clearTimeout(this._fadeOutTimeout),this._fadeOutTimeout=null),this._highlightedElement&&this._originalStyles){const t=this._highlightedElement,n=this._originalStyles;e?(t.style.outline=n.outline,t.style.outlineOffset=n.outlineOffset,t.style.transition=n.transition,p.log("[Pillar] Highlight cleared immediately")):(t.style.outline=t.style.outline.replace(/[^,\s]+$/,"transparent"),this._fadeOutTimeout=setTimeout(()=>{t.style.outline=n.outline,t.style.outlineOffset=n.outlineOffset,t.style.transition=n.transition,p.log("[Pillar] Highlight fade-out complete"),this._fadeOutTimeout=null},300)),this._highlightedElement=null,this._originalStyles=null}}getElement(e){return document.querySelector(e)}clickElement(e){p.log("[Pillar] clickElement called with selector:",e);const t=this.getElement(e);if(p.log("[Pillar] clickElement found element:",t),t instanceof HTMLElement){p.log("[Pillar] clickElement clicking element:",t.tagName,t.textContent?.slice(0,50)),this.highlightElement(t);const e=t.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height/2,i={bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:r,button:0,buttons:1};return t.dispatchEvent(new MouseEvent("mousedown",i)),t.dispatchEvent(new MouseEvent("mouseup",i)),t.dispatchEvent(new MouseEvent("click",i)),p.log("[Pillar] clickElement full mouse sequence executed"),!0}return p.warn("[Pillar] clickElement element not found or not HTMLElement"),!1}typeInElement(e,t){p.log("[Pillar] typeInElement called with selector:",e,"text:",t);const n=this.getElement(e);if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){p.log("[Pillar] typeInElement found input/textarea:",n.tagName,n.type),this.highlightElement(n),n.focus();const e=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,r=Object.getOwnPropertyDescriptor(e,"value")?.set;return r?(r.call(n,t),p.log("[Pillar] typeInElement set value via native setter")):(n.value=t,p.log("[Pillar] typeInElement set value directly (fallback)")),n.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),n.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),n.dispatchEvent(new Event("change",{bubbles:!0})),p.log("[Pillar] typeInElement complete - events fired"),!0}return n instanceof HTMLElement&&"true"===n.getAttribute("contenteditable")?(p.log("[Pillar] typeInElement found contenteditable element"),this.highlightElement(n),n.focus(),n.textContent=t,n.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),n.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),p.log("[Pillar] typeInElement contenteditable complete"),!0):(p.warn("[Pillar] typeInElement element not found or not an input:",n),!1)}selectOption(e,t){p.log("[Pillar] selectOption called with selector:",e,"value:",t);const n=this.getElement(e);if(n instanceof HTMLSelectElement){p.log("[Pillar] selectOption found select element"),this.highlightElement(n),n.focus();const e=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;return e?(e.call(n,t),p.log("[Pillar] selectOption set value via native setter")):(n.value=t,p.log("[Pillar] selectOption set value directly (fallback)")),n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})),p.log("[Pillar] selectOption complete"),!0}return p.warn("[Pillar] selectOption element not found or not a select:",n),!1}focusElement(e){p.log("[Pillar] focusElement called with selector:",e);const t=this.getElement(e);return t instanceof HTMLElement?(p.log("[Pillar] focusElement found element:",t.tagName),this.highlightElement(t),t.focus(),t.dispatchEvent(new FocusEvent("focusin",{bubbles:!0})),p.log("[Pillar] focusElement complete"),!0):(p.warn("[Pillar] focusElement element not found:",t),!1)}toggleElement(e){p.log("[Pillar] toggleElement called with selector:",e);const t=this.getElement(e);if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type)){p.log("[Pillar] toggleElement found checkbox/radio:",t.type,"current checked:",t.checked),this.highlightElement(t),t.focus();const e=t.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height/2,i={bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:r,button:0,buttons:1};return t.dispatchEvent(new MouseEvent("mousedown",i)),t.dispatchEvent(new MouseEvent("mouseup",i)),t.dispatchEvent(new MouseEvent("click",i)),t.dispatchEvent(new Event("input",{bubbles:!0})),p.log("[Pillar] toggleElement complete - new checked:",t.checked),!0}return p.warn("[Pillar] toggleElement element not found or not checkbox/radio:",t),!1}async handlePageInteraction(e){if(p.log("[Pillar] handlePageInteraction called with params:",e),!ys(e.ref))return p.warn("[Pillar] handlePageInteraction rejected invalid ref format:",e.ref),{success:!1,error:"Invalid ref format"};const t=ws(e.ref);p.log("[Pillar] handlePageInteraction built selector:",t);const n=this.getElement(t);if(!n)return p.warn("[Pillar] handlePageInteraction element not found for ref:",e.ref),{success:!1,error:"Element not found"};if(n.getAttribute("data-pillar-ref")!==e.ref)return p.warn("[Pillar] handlePageInteraction ref attribute mismatch"),{success:!1,error:"Ref attribute mismatch"};if(vs(n)){const t=n.textContent?.trim().slice(0,50)||n.getAttribute("aria-label")||e.operation;p.log("[Pillar] handlePageInteraction detected destructive element:",t);const{requestConfirmation:r}=await Promise.resolve().then(function(){return rs});if(!await r(`Agent wants to ${e.operation} "${t}"`))return p.log("[Pillar] handlePageInteraction destructive action denied by user"),{success:!1,error:"User denied destructive action"};p.log("[Pillar] handlePageInteraction destructive action confirmed by user")}let r;switch(e.operation){case"click":r={success:this.clickElement(t)};break;case"type":if(!e.value){r={success:!1,error:"value required for type operation"};break}r={success:this.typeInElement(t,e.value)};break;case"select":if(!e.value){r={success:!1,error:"value required for select operation"};break}r={success:this.selectOption(t,e.value)};break;case"focus":r={success:this.focusElement(t)};break;case"toggle":r={success:this.toggleElement(t)};break;default:r={success:!1,error:`Unknown operation: ${e.operation}`}}return p.log("[Pillar] handlePageInteraction result:",r),r}mountPanelTo(e){this._panel?.mountTo(e)}getPanelHostElement(){return this._panel?.getHostElement()??null}get context(){return{...this._context}}get userProfile(){return{...this._userProfile}}setUserProfile(e){this._userProfile={...e},Tp(this._userProfile),this._events.emit("profile:change",{profile:this._userProfile})}async identify(e,t,n){if(this._api)if(e)if(null===this._externalUserId||String(this._externalUserId)!==String(e))try{await this._api.identify(e,t),this._externalUserId=e,this._persistExternalUserId(e),this._userProfile={...this._userProfile,userId:e,...t?.name&&{name:t.name}},Tp(this._userProfile),this._api.setExternalUserId(e),n?.preserveConversation||no(),Fa.value+=1,this._events.emit("user:identified",{userId:e,profile:t})}catch(e){throw p.error("[Pillar] Failed to identify user:",e),e}else p.log("[Pillar] Already identified as this user, skipping");else p.warn("[Pillar] userId is required for identify()");else p.warn("[Pillar] SDK not initialized, cannot identify user")}logout(e){this._externalUserId=null,this._persistExternalUserId(null),this._userProfile={...Cp},Tp(this._userProfile),this._api?.clearExternalUserId(),this._api?.regenerateVisitorId(),e?.preserveConversation||no(),Fa.value+=1,this._events.emit("user:logout",{})}get externalUserId(){return this._externalUserId}get isIdentified(){return null!==this._externalUserId}reportAction(e,t){const n=[...(this._context.recentActions||[]).slice(-9),e];this._context={...this._context,recentActions:n},(e=>{const t=Pp.value.recentActions||[];Pp.value={...Pp.value,recentActions:[...t.slice(-9),e]}})(e),this._events.emit("action:report",{action:e,metadata:t})}clearErrorState(){if(this._context.errorState){const{errorState:e,...t}=this._context;this._context=t,(()=>{const{errorState:e,...t}=Pp.value;Pp.value=t})(),this._events.emit("context:change",{context:this._context})}}setErrorState(e,t){this._context={...this._context,errorState:{code:e,message:t}},((e,t)=>{Pp.value={...Pp.value,errorState:{code:e,message:t}}})(e,t),this._events.emit("context:change",{context:this._context})}async getSuggestions(){if(!this._api)return p.warn("[Pillar] SDK not initialized, cannot get suggestions"),[];try{return await this._api.getSuggestions(this._context,this._userProfile)}catch(e){return p.error("[Pillar] Failed to get suggestions:",e),[]}}getAssistantContext(){return{product:this._context,user:this._userProfile}}onTask(e,t){return this._taskHandlers.set(e,t),()=>this._taskHandlers.delete(e)}defineTool(e){if(!e.name)return p.warn("[Pillar] defineTool called without a name"),()=>{};const t=function(e){if(!e||"string"!=typeof e)return{valid:!1,error:"Tool name is required"};if(e.length>64)return{valid:!1,error:`Tool name exceeds 64 characters (got ${e.length})`};if(!/^[a-zA-Z_]/.test(e))return{valid:!1,error:`Tool name must start with a letter or underscore, got "${e[0]}"`};if(!Lp.test(e)){const t=e.match(/[^a-zA-Z0-9_.\-:]/g);return{valid:!1,error:`Tool name contains invalid characters: ${[...new Set(t)].map(e=>`"${e}"`).join(", ")}. Only letters, numbers, underscores, dots, colons, and dashes are allowed.`}}return{valid:!0}}(e.name);if(!t.valid)return p.error(`[Pillar] Invalid tool name "${e.name}": ${t.error}. Tool names must start with a letter or underscore and contain only letters, numbers, underscores, dots, colons, or dashes (max 64 chars). Example: "add_to_cart" or "get-user-profile"`),()=>{};this._definedTools.set(e.name,e),p.log(`[Pillar] Defined tool: ${e.name}`),this._events.emit("tools:change",{action:"add",name:e.name});const n=[];"inline_ui"===e.type&&e.render&&n.push(this.registerCard(e.name,e.render));let r=!1;if(e.webMCP&&"inline_ui"!==e.type&&"execute"in e&&"function"==typeof e.execute){const t=e;if("undefined"!=typeof navigator&&navigator.modelContext)try{navigator.modelContext.registerTool({name:e.name,description:e.description,inputSchema:e.inputSchema,execute:async(n,r)=>{const i=performance.now();let a,l,o="success";try{l=await t.execute(n),l&&"object"==typeof l&&!Array.isArray(l)&&!1===l.success&&(o="failure",a=l.error||l.message)}catch(e){throw o="failure",a=e instanceof Error?e.message:String(e),e}finally{const t=Math.round(performance.now()-i);this._api?.trackWebMCPExecution(e.name,o,{duration_ms:t,error:a,input:n})}return l&&"object"==typeof l&&"content"in l?l:{content:[{type:"text",text:"string"==typeof l?l:JSON.stringify(l??{success:!0})}]}}}),r=!0,p.log(`[Pillar] Registered tool with WebMCP: ${e.name}`)}catch(t){p.warn(`[Pillar] Failed to register tool with WebMCP: ${e.name}`,t)}else p.log(`[Pillar] WebMCP not available, skipping WebMCP registration for: ${e.name}`)}return()=>{if(this._definedTools.delete(e.name),this._events.emit("tools:change",{action:"remove",name:e.name}),n.forEach(e=>e()),r&&navigator.modelContext)try{navigator.modelContext.unregisterTool(e.name),p.log(`[Pillar] Unregistered tool from WebMCP: ${e.name}`)}catch(t){p.warn(`[Pillar] Failed to unregister tool from WebMCP: ${e.name}`,t)}}}defineAction(e){return this.defineTool(e)}registerTool(e){const{name:t,...n}=e;t?(this._registeredTools.set(t,{name:t,...n,returns:n.returnsData||n.returns||!1,autoRun:n.autoRun??n.auto_run??!1,autoComplete:n.autoComplete??n.auto_complete??!0}),p.log(`[Pillar] Registered tool: ${t}`),this._events.emit("tools:change",{action:"add",name:t})):p.warn("[Pillar] registerTool called without a name")}registerAction(e){this.registerTool(e)}getRegisteredTool(e){return this._registeredTools.get(e)}getRegisteredAction(e){return this.getRegisteredTool(e)}getHandler(e){const t=this._definedTools.get(e);if(t){if(t.execute)return t.execute;if("inline_ui"===t.type&&this._cardRenderers.has(e))return t=>({...t,card_type:e})}const n=Up(e)?Np(e):void 0;if(n?.handler)return n.handler;const r=this._taskHandlers.get(e);return r||void 0}onAnyTask(e){return this._anyTaskHandler=e,()=>{this._anyTaskHandler=null}}offTask(e){this._taskHandlers.delete(e)}executeTask(e){const{name:t,data:n,taskType:r,path:i,externalUrl:a}=e;if(this._events.emit("task:execute",e),this._anyTaskHandler)try{this._anyTaskHandler(t,n)}catch(e){p.error("[Pillar] Error in onAnyTask handler:",e)}const l=this._definedTools.get(t),s=l?.execute,c=Up(t)?Np(t):void 0,d=this._registeredTools.get(t),u=c?.handler,h=this._taskHandlers.get(t),g=r?this._taskHandlers.get(r):void 0,f=s||u||h||g,m=!!l||c?.returns||d?.returns;if(f){const e=performance.now();o.add({event:"handler:execute",data:{action:t,taskType:r,params:n},source:"handler",level:"info"});try{const a=f("navigate"===r&&i?{...n,path:i}:n);if(m&&void 0!==a)Promise.resolve(a).then(async r=>{const i=Math.round(performance.now()-e);if(void 0!==r){const e=os(r);await this.sendToolResult(t,e);let n=!0;if(e&&"object"==typeof e&&!Array.isArray(e)){!1===e.success&&(n=!1)}o.add({event:"handler:complete",data:{action:t,duration:i,success:n,returnsData:!0},source:"handler",level:n?"info":"warn"}),this._events.emit("task:complete",{name:t,success:n,data:r})}else o.add({event:"handler:complete",data:{action:t,duration:i,success:!0},source:"handler",level:"info"}),this._events.emit("task:complete",{name:t,success:!0,data:n})}).catch(r=>{const i=Math.round(performance.now()-e);o.add({event:"handler:error",data:{action:t,duration:i,error:r instanceof Error?r.message:String(r)},source:"handler",level:"error"}),p.error(`[Pillar] Error in query action "${t}":`,r),this._events.emit("task:complete",{name:t,success:!1,data:n})});else{const r=Math.round(performance.now()-e);o.add({event:"handler:complete",data:{action:t,duration:r,success:!0},source:"handler",level:"info"}),this._events.emit("task:complete",{name:t,success:!0,data:n})}}catch(r){const i=Math.round(performance.now()-e);o.add({event:"handler:error",data:{action:t,duration:i,error:r instanceof Error?r.message:String(r)},source:"handler",level:"error"}),p.error(`[Pillar] Error executing task "${t}":`,r),this._events.emit("task:complete",{name:t,success:!1,data:n})}}else switch(r){case"navigate":i&&"undefined"!=typeof window&&(p.warn("[Pillar] No 'navigate' handler registered. Using window.location.href as fallback."),window.location.href=i,this._events.emit("task:complete",{name:t,success:!0,data:n}));break;case"external_link":a&&"undefined"!=typeof window&&(window.open(a,"_blank","noopener,noreferrer"),this._events.emit("task:complete",{name:t,success:!0,data:n}));break;case"copy_text":n.text&&"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(String(n.text)).then(()=>{this._events.emit("task:complete",{name:t,success:!0,data:n})}).catch(()=>{this._events.emit("task:complete",{name:t,success:!1,data:n})});break;default:p.warn(`[Pillar] No handler registered for task "${t}". Register one with pillar.onTask('${t}', handler)`),this._events.emit("task:complete",{name:t,success:!1,data:{error:"No handler registered"}})}}completeTask(e,t=!0,n){this._events.emit("task:complete",{name:e,success:t,data:n})}async completeTool(e,t=!0,n){this._events.emit("task:complete",{name:e,success:t,data:n})}async completeAction(e,t=!0,n){return this.completeTool(e,t,n)}confirmTaskExecution(e,t,n){e?this._api?this._api.confirmTaskExecution(e,t,n):p.warn("[Pillar] SDK not initialized, cannot confirm task execution"):p.warn("[Pillar] confirmTaskExecution called without taskId")}registerCard(e,t){return this._cardRenderers.set(e,t),()=>this._cardRenderers.delete(e)}getCardRenderer(e){return this._cardRenderers.get(e)}hasCardRenderer(e){return this._cardRenderers.has(e)}getLatestCardPosition(){const e=Na.value;for(let t=e.length-1;t>=0;t--){const n=e[t].segments;if(n)for(let e=n.length-1;e>=0;e--)if("card"===n[e].type)return{messageIndex:t,segmentIndex:e}}return null}isPositionLatest(e,t){return e===Na.value.length-1}subscribeToMessages(e){return Na.subscribe(e)}get isChatLoading(){return Ga.value}subscribeToLoadingState(e){return Ga.subscribe(e)}get workflow(){return zp.value}startWorkflow(e){!function(e){zp.value&&(Rp.value=[...Rp.value,zp.value]);const t=e.steps.map((e,t)=>0===t?{...e,status:e.auto_run?"active":"awaiting_initiation"}:{...e,status:"pending"});zp.value={...e,steps:t,current_step:0}}(e),this._events.emit("workflow:start",zp.value);const t=zp.value.steps[0];t.auto_run&&this._executeWorkflowStep(t)}initiateWorkflowStep(e){const t=zp.value;if(!t)return void p.warn("[Pillar] No active workflow");const n=e??t.current_step,r=t.steps[n];r?"awaiting_initiation"===r.status?this._executeWorkflowStep(r):p.warn(`[Pillar] Step ${n} is not awaiting initiation`):p.warn(`[Pillar] Invalid step index: ${n}`)}confirmWorkflowStep(e,t){const n=zp.value;if(!n)return;const r=t??n.current_step;if(n.steps[r],Mp(r,e?"completed":"failed"),this._events.emit("workflow:step:complete",{workflow:zp.value,step:zp.value.steps[r],success:e}),!e)return;const i=Ap();if(!i)return this._events.emit("workflow:complete",zp.value),void $p();this._events.emit("workflow:step:active",{workflow:zp.value,step:i}),i.auto_run&&this._executeWorkflowStep(i)}skipWorkflowStep(e){const t=zp.value;if(!t)return;const n=e??t.current_step;t.steps[n],Mp(n,"skipped"),this._events.emit("workflow:step:skip",{workflow:zp.value,step:zp.value.steps[n]});const r=Ap();if(!r)return this._events.emit("workflow:complete",zp.value),void $p();this._events.emit("workflow:step:active",{workflow:zp.value,step:r}),r.auto_run&&this._executeWorkflowStep(r)}cancelWorkflow(){const e=zp.value;e&&(this._events.emit("workflow:cancel",e),function(){if(!zp.value)return null;const e=zp.value;zp.value=null}())}_executeWorkflowStep(e){Mp(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)}async sendToolResult(e,t,n){this._api?(p.log(`[Pillar] Sending tool result for "${e}" (tool_call_id: ${n}):`,t),await this._api.mcp.sendToolResult(e,t,n),this._events.emit("tool:result",{toolName:e,result:t,toolCallId:n}),this._events.emit("action:result",{actionName:e,result:t,toolCallId:n})):p.warn("[Pillar] SDK not initialized, cannot send tool result")}async sendActionResult(e,t,n){return this.sendToolResult(e,t,n)}sendToolResultAsMessage(e,t){if(Ga.value)return void p.warn(`[Pillar] sendResult for "${e}" ignored — a message is still being processed. Wait for context.isReady before calling sendResult.`);p.log(`[Pillar] Sending tool result as message for "${e}":`,t);const n=`[Tool result from ${e}]: ${JSON.stringify(t)}`;Wl(n),Kl(),this._events.emit("tool:result",{toolName:e,result:t})}async executeQueryTool(e,t={},n){const r=performance.now(),i=Nr().startSpan("query_tool.execute",{attributes:{"query_tool.name":e}});if(!e||"string"!=typeof e||""===e.trim())return p.error("[Pillar] executeQueryTool called with missing or invalid toolName:",e),i.setStatus({code:lt.ERROR,message:"invalid toolName"}),void i.end();if(p.log(`[Pillar] Starting query tool "${e}"`,t),n?.properties){const r=this._validateQueryParams(t,n);if(r)return p.error(`[Pillar] Query param validation failed: ${r}`),void await this.sendToolResult(e,{success:!1,error:r})}const a=this._definedTools.get(e),l=a?.execute,s=Up(e)?Np(e):void 0;this._registeredTools.get(e);const c=s?.handler,d=this._taskHandlers.get(e),u=this._taskHandlers.get("query"),h=l||c||d||u;if(!h)return p.error(`[Pillar] No handler registered for query tool "${e}". Register one with: pillar.onTask('${e}', async (data) => { ... return result; })`),void await this.sendToolResult(e,{error:`No handler registered for tool "${e}"`,success:!1});o.add({event:"handler:execute",data:{tool:e,type:"query",params:t},source:"handler",level:"info"});try{const n=performance.now(),a=await Promise.resolve(h(t)),l=Math.round(performance.now()-n);if(p.log(`[Pillar] Query tool "${e}" handler completed in ${l}ms`,a),void 0!==a){o.add({event:"handler:complete",data:{tool:e,duration:l,success:!0,returnsData:!0},source:"handler",level:"info"});const t=os(a);await this.sendToolResult(e,t);const n=Math.round(performance.now()-r);i.setAttribute("query_tool.duration_ms",n),i.setAttribute("query_tool.success",!0),i.end(),p.log(`[Pillar] Query tool "${e}" total time: ${n}ms`)}else o.add({event:"handler:complete",data:{tool:e,duration:l,success:!1,error:"returned undefined"},source:"handler",level:"warn"}),p.warn(`[Pillar] Query tool "${e}" returned undefined. Make sure your handler returns data for the agent.`),i.setAttribute("query_tool.success",!1),i.end(),await this.sendToolResult(e,{error:"Handler returned undefined",success:!1})}catch(t){const n=Math.round(performance.now()-r);i.setStatus({code:lt.ERROR,message:t.message}),i.end(),o.add({event:"handler:error",data:{tool:e,duration:n,error:t instanceof Error?t.message:String(t)},source:"handler",level:"error"}),p.error(`[Pillar] Error executing query tool "${e}" after ${n}ms:`,t),await this.sendToolResult(e,{error:t instanceof Error?t.message:String(t),success:!1})}}async executeQueryAction(e,t={},n){return this.executeQueryTool(e,t,n)}_validateQueryParams(e,t){const n=t.properties||{},r=t.required||[],i=Object.keys(n),a=r.filter(t=>!(t in e));if(a.length>0)return`Missing required parameters: ${a.join(", ")}. Expected: ${i.join(", ")}`;const l=Object.keys(e).filter(e=>!(e in n));return l.length>0?`Unknown parameters: ${l.join(", ")}. Expected: ${i.join(", ")}`:null}async _init(e){if("initializing"===this._state&&this._initPromise)return p.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):p.log("[Pillar] Already initialized")}async _doInit(e){try{e.debug&&(t(!0),o.add({event:"sdk:init:start",data:{productKey:e.productKey,debug:!0},source:"sdk",level:"info"})),await new Promise(e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e(),{once:!0}):e()});const r=td(e),i=new Wr(r),a=await i.fetchEmbedConfig().catch(e=>(p.warn("[Pillar] Failed to fetch server config, using local config only:",e),null));if(!1===a?.security?.originAllowed)throw new Error("[Pillar] This domain is not authorized to use this product. Add it to your allowed domains in the Pillar dashboard.");!function(e,t){if(!t)return;const n=[];e.assistantDisplayName&&t.assistantDisplayName&&e.assistantDisplayName!==t.assistantDisplayName&&n.push(`assistantDisplayName: local="${e.assistantDisplayName}" vs server="${t.assistantDisplayName}"`),e.inputPlaceholder&&t.inputPlaceholder&&e.inputPlaceholder!==t.inputPlaceholder&&n.push(`inputPlaceholder: local="${e.inputPlaceholder}" vs server="${t.inputPlaceholder}"`),e.welcomeMessage&&t.welcomeMessage&&e.welcomeMessage!==t.welcomeMessage&&n.push(`welcomeMessage: local="${e.welcomeMessage}" vs server="${t.welcomeMessage}"`);const r=e.theme?.colors?.primary,i=t.theme?.colors?.primary;r&&i&&r!==i&&n.push(`theme.colors.primary: local="${r}" vs server="${i}"`),n.length>0&&console.warn(`[Pillar] Config mismatch detected (local config will take precedence):\n - ${n.join("\n - ")}`)}(e,a);const l=function(e,t){if(!t)return e;const n={...e};return t.panel&&(n.panel={...t.panel,...e.panel}),t.theme?.colors?.primary&&(n.theme={...n.theme,colors:{primary:e.theme?.colors?.primary??t.theme.colors.primary,...e.theme?.colors}}),t.assistantDisplayName&&!e.assistantDisplayName&&(n.assistantDisplayName=t.assistantDisplayName),t.inputPlaceholder&&!e.inputPlaceholder&&(n.inputPlaceholder=t.inputPlaceholder),t.welcomeMessage&&!e.welcomeMessage&&(n.welcomeMessage=t.welcomeMessage),n}(e,a);this._config=td(l),this._config.platform&&this._config.version&&Dp(this._config.platform,this._config.version),this._api=new Wr(this._config);const s=this._getStoredExternalUserId();s&&(this._externalUserId=s,this._api.setExternalUserId(s),p.log("[Pillar] Restored external user ID from localStorage")),p.configure(this._api.mcp,{forwardToServer:!0}),this._config.debug&&this._setupDebugEventCapture(),this._config.tracing&&(!function(e,t={}){if(jr)return Hr;const n=new Dr({url:`${e}/mcp/telemetry/v1/traces`,headers:{}}),r=Mn({"service.name":"pillar-sdk-browser",...t});jr=new ir({resource:r,spanProcessors:[new Vn(n,{maxQueueSize:100,maxExportBatchSize:30,scheduledDelayMillis:5e3})]}),jr.register({propagator:new sn}),Hr=St.getTracer("pillar-sdk","0.1.0")}(this._config.apiBaseUrl,{"pillar.product_key":this._config.productKey,"pillar.platform":this._config.platform||"web"}),p.log("[Pillar] OpenTelemetry tracing enabled")),this._rootContainer=this._createRootContainer(),n=this._config.mobileTrigger.breakpoint,la.value=n,(e=>{oa.value=e})(this._config.panel.fullWidthBreakpoint),(()=>{if("undefined"==typeof window)return;ca?.();let e=null;const t=()=>{null===e&&(e=requestAnimationFrame(()=>{e=null,sa.value=window.innerWidth}))};sa.value=window.innerWidth,window.addEventListener("resize",t),ca=()=>{null!==e&&cancelAnimationFrame(e),window.removeEventListener("resize",t)}})(),this._config.panel.enabled&&(this._panel=new xp(this._config,this._api,this._events,this._rootContainer),await this._panel.init()),this._config.edgeTrigger.enabled&&(this._edgeTrigger=new ya(this._config,this._events,()=>this.toggle(),this._rootContainer),this._edgeTrigger.init()),this._config.mobileTrigger.enabled&&(this._mobileTrigger=new Ca(this._config,this._events,()=>this.toggle(),this._rootContainer),this._mobileTrigger.init()),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new kp(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),this._state="ready",this._events.emit("ready"),this._config.onReady?.(),p.log("[Pillar] SDK initialized successfully"),this._config.debug&&this._mountDebugPanel(),this._routeObserver=new Jp({debounceMs:this._config.suggestions.debounceMs}),this._routeObserver.onRouteChange(e=>{this._syncCurrentPage(e),this._applyRouteExclusion(e.pathname),this._config?.suggestions.enabled&&this._handleRouteChange(e)}),this._routeObserver.start();const c=this._routeObserver.getCurrentRoute();this._syncCurrentPage(c),this._applyRouteExclusion(c.pathname),this._config.suggestions.enabled&&this._initSuggestions().catch(e=>{p.warn("[Pillar] Background suggestions init failed:",e)}),await this._recoverSession(),this._config.urlParams.enabled&&await this._handleUrlParams(),this._config.panel.initialOpen&&!Yi.value&&(this.open(),p.log("[Pillar] Panel auto-opened via initialOpen config")),await this._restoreConversation()}catch(e){this._state="error";const t=e instanceof Error?e:new Error(String(e));throw this._events.emit("error",t),this._config?.onError?.(t),p.error("[Pillar] Failed to initialize:",e),e}var n}async _recoverSession(){if(!this._config||!this._api)return void p.warn("[Pillar] _recoverSession skipped: config or api not available");const e=this._config.productKey;p.log("[Pillar] Checking for saved session hint with siteId:",e);const{loadActiveSession:t,clearActiveSession:n}=await Promise.resolve().then(function(){return ls}),{setInterruptedSession:r,setConversationId:i}=await Promise.resolve().then(function(){return po}),a=t(e);if(a){p.log("[Pillar] Found saved session hint, checking with server...");try{const t=await this._api.mcp.getConversationStatus(a.conversationId);if(!t||!t.resumable)return p.log("[Pillar] Session is no longer resumable, clearing hint"),void n(e);p.log("[Pillar] Session is resumable, setting up resume state"),i(a.conversationId),r({conversationId:a.conversationId,userMessage:t.user_message??"",partialResponse:t.partial_response??"",displayTrace:t.display_trace??[],elapsedMs:t.elapsed_ms??0}),p.log("[Pillar] Resume state set up successfully")}catch(t){p.warn("[Pillar] Failed to check session status:",t),n(e)}}else p.log("[Pillar] No saved session found for siteId:",e)}async _restoreConversation(){if(!this._api)return;const{getStoredConversationId:e,messages:t,loadConversation:n,isLoadingHistory:r,interruptedSession:i,setInterruptedSession:a}=await Promise.resolve().then(function(){return po}),{navigate:l,currentView:o}=await Promise.resolve().then(function(){return yo}),s=e();if(s&&!(t.value.length>0)){p.log("[Pillar] Restoring conversation from localStorage:",s);try{r.value=!0,"chat"!==o.value.type&&l("chat");const e=await this._api.getConversation(s);if(e&&e.messages.length>0){let t=e.messages;const l=t[t.length-1],o="assistant"===l.role&&!l.content?.trim();if(o&&(p.log("[Pillar] Stripped trailing empty assistant message from restored conversation"),t=t.slice(0,-1)),t.length>0?n(e.id,t):r.value=!1,o&&!i.value&&this._api.mcp){p.log("[Pillar] Checking conversation status as fallback for resume...");try{const e=await this._api.mcp.getConversationStatus(s);e&&e.resumable&&(p.log("[Pillar] Fallback: session is resumable, setting up resume state"),a({conversationId:s,userMessage:e.user_message??"",partialResponse:e.partial_response??"",displayTrace:e.display_trace??[],elapsedMs:e.elapsed_ms??0}))}catch(e){p.warn("[Pillar] Fallback resume check failed:",e)}}}else r.value=!1}catch(e){p.warn("[Pillar] Failed to restore conversation:",e),r.value=!1}}}async _handleUrlParams(){if(!this._config)return;(function(e=Xp){if("undefined"==typeof window||!window.location)return{};const t=new URLSearchParams(window.location.search),n={};t.has(`${e}open`)&&(n.open=!0);const r=t.get(`${e}article`);r&&(n.article=r);const i=t.get(`${e}article-id`);i&&!n.article&&(n.article=i);const a=t.get(`${e}category`);a&&(n.category=a);const l=t.get(`${e}search`);return l&&(n.search=l),n})(this._config.urlParams.prefix).open&&(this.open(),this._config.urlParams.clearAfterOpen&&function(e=Xp){if("undefined"==typeof window||!window.location||!window.history)return;const t=new URL(window.location.href),n=[`${e}open`,`${e}article`,`${e}article-id`,`${e}category`,`${e}search`];let r=!1;for(const e of n)t.searchParams.has(e)&&(t.searchParams.delete(e),r=!0);r&&window.history.replaceState({},"",t.toString())}(this._config.urlParams.prefix))}_mountDebugPanel(){this._debugPanelContainer=document.createElement("div"),this._debugPanelContainer.id="pillar-debug-panel-root",document.body.appendChild(this._debugPanelContainer),Y(M(La,null),this._debugPanelContainer),o.add({event:"debug:panel:mounted",source:"sdk",level:"info"})}_setupDebugEventCapture(){this._events.on("task:execute",e=>{o.add({event:"task:execute",data:{name:e.name,taskType:e.taskType},source:"sdk",level:"info"})}),this._events.on("task:complete",e=>{o.add({event:"task:complete",data:{name:e.name,success:e.success},source:"sdk",level:e.success?"info":"error"})}),this._events.on("action:result",e=>{o.add({event:"action:result",data:{actionName:e.actionName,hasResult:!!e.result},source:"sdk",level:"info"})}),this._events.on("ready",()=>{o.add({event:"sdk:ready",source:"sdk",level:"info"})}),this._events.on("error",e=>{o.add({event:"sdk:error",data:{message:e.message},source:"sdk",level:"error"})}),p.log("[Pillar] Debug event capture enabled")}_syncCurrentPage(e){this.setContext({currentPage:e.pathname})}_applyRouteExclusion(e){if(!this._config)return;const t=this._config.excludeRoutes.some(t=>e===t||e.startsWith(t+"/"));t!==this._isRouteExcluded&&(this._isRouteExcluded=t,t?(this._panel?.close(),this._edgeTrigger?.hide(),this._mobileTrigger?.hide(),this._textSelectionManager?.destroy(),p.log(`[Pillar] UI hidden — route "${e}" is excluded`)):(this._edgeTrigger?.show(),this._mobileTrigger?.show(),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new kp(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),p.log(`[Pillar] UI restored — route "${e}" is not excluded`)))}async _initSuggestions(){if(this._api&&this._config){p.log("[Pillar] Initializing page-aware suggestions"),Do(!0);try{const e=await this._api.getSuggestedQuestions();if(p.log(`[Pillar] Fetched ${e.length} suggestions for pool`),this._suggestionPool=e,function(e){Ro.value=e}(e),this._routeObserver){const e=this._routeObserver.getCurrentRoute();this._handleRouteChange(e)}Do(!1)}catch(e){p.error("[Pillar] Failed to initialize suggestions:",e),function(e){Ao.value=e,Mo.value=!1}(e instanceof Error?e.message:String(e)),Do(!1)}}}_handleRouteChange(e){if(!this._config)return;const{pathname:t,title:n}=e,r=this._config.suggestions.displayLimit;p.log(`[Pillar] Route changed to: ${t}, sorting suggestions`);const i=Lo(this._suggestionPool,t,n,r);!function(e,t){Io.value=e,$o.value=t}(i,t),this._events.emit("suggestions:updated",{suggestions:i.map(e=>({id:e.id,text:e.text})),route:t}),p.log(`[Pillar] Sorted ${i.length} suggestions for page`)}_destroy(){this._routeObserver?.stop(),this._routeObserver=null,this._suggestionPool=[],Ro.value=[],Io.value=[],Mo.value=!1,Ao.value=null,$o.value=null,this._textSelectionManager?.destroy(),this._panel?.destroy(),this._edgeTrigger?.destroy(),this._mobileTrigger?.destroy(),this._api?.cancelAllRequests(),this._events.removeAllListeners(),this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=null,this._rootContainer?.remove(),this._rootContainer=null,this._debugPanelContainer&&(Y(null,this._debugPanelContainer),this._debugPanelContainer.remove(),this._debugPanelContainer=null),ma(),_o(),no(),Pp.value={...Sp},Ep.value={...Cp},zp.value=null,Rp.value=[],this._context={...Sp},this._userProfile={...Cp},this._taskHandlers.clear(),this._anyTaskHandler=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._api=null,this._config=null,this._state="uninitialized",p.log("[Pillar] SDK destroyed")}}nd.version="0.2.0",nd.instance=null,nd.EXTERNAL_USER_ID_STORAGE_KEY="pillar:external_user_id";var rd=Object.freeze({__proto__:null,Pillar:nd,getApiClient:za});if("undefined"!=typeof window){window.Pillar=nd;const e=()=>{const e=document.currentScript,t=e?.dataset.agentSlug??e?.dataset.productKey;t&&nd.init({agentSlug:t}).catch(p.error)};if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",e);else{const e=document.querySelectorAll("script[data-agent-slug], script[data-product-key]");if(e.length>0){const t=e[e.length-1],n=t.dataset.agentSlug??t.dataset.productKey;n&&nd.init({agentSlug:n}).catch(p.error)}}}export{Wr as APIClient,ss as DEFAULT_SCAN_OPTIONS,Zp as DEFAULT_SIDEBAR_TABS,u as EventEmitter,ps as INTERACTABLE_ROLES,cs as INTERACTABLE_TAGS,nd as Pillar,ds as SKIP_TAGS,qr as actionToTaskButton,ws as buildSelectorFromRef,hs as clearPillarRefs,qp as clearRegistry,nd as default,Oa as generateContextId,Qp as getActionCount,Vp as getActionDefinition,Gp as getActionNames,za as getApiClient,jp as getClientInfo,Ha as getContextDisplayLabel,Hp as getHandler,Fp as getManifest,Ta as getPillarInstance,Wp as getToolCount,Np as getToolDefinition,Bp as getToolNames,Kp as hasAction,Up as hasTool,ja as isDOMSnapshotContext,vs as isDestructiveElement,Da as isHighlightedTextContext,_s as isInteractable,ms as isRedacted,ys as isValidPillarRef,os as normalizeToolResult,Ps as scanPageDirect,Dp as setClientInfo,Fr as toolToTaskButton};
2
2
  //# sourceMappingURL=pillar.esm.js.map