@webority/chat-elements 0.165.3 → 0.165.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-elements.js +1 -1
- package/dist/chat.global.js +1 -1
- package/package.json +3 -3
package/dist/chat.global.js
CHANGED
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
`)){var p=new XQ;p.newline=!0,s.add(p)}else{var m=n.getSeriesByName(f)[0];if(!c.get(f)){if(m){var h=m.getData(),g=h.getVisual(`legendLineStyle`)||{},_=h.getVisual(`legendIcon`),v=h.getVisual(`style`),y=this._createItem(m,f,a,i,t,e,g,v,_,l,r);y.on(`click`,JQ(tj,f,null,r,d)).on(`mouseover`,JQ(nj,m.name,null,r,d)).on(`mouseout`,JQ(rj,m.name,null,r,d)),n.ssr&&y.eachChild(function(e){var t=Jz(e);t.seriesIndex=m.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&y.eachChild(function(e){o.packEventData(e,t,m,a,f)}),c.set(f,!0)}else n.eachRawSeries(function(o){var s=this;if(!c.get(f)&&o.legendVisualProvider){var p=o.legendVisualProvider;if(!p.containName(f))return;var m=p.indexOfName(f),h=p.getItemVisual(m,`style`),g=p.getItemVisual(m,`legendIcon`),_=Il(h.fill);_&&_[3]===0&&(_[3]=.2,h=I(I({},h),{fill:Wl(_,`rgba`)}));var v=this._createItem(o,f,a,i,t,e,{},h,g,l,r);v.on(`click`,JQ(tj,null,f,r,d)).on(`mouseover`,JQ(nj,null,f,r,d)).on(`mouseout`,JQ(rj,null,f,r,d)),n.ssr&&v.eachChild(function(e){var t=Jz(e);t.seriesIndex=o.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&v.eachChild(function(e){s.packEventData(e,t,o,a,f)}),c.set(f,!0)}},this)}}},this),i&&this._createSelector(i,t,r,a,o)},t.prototype.packEventData=function(e,t,n,r,i){var a={componentType:`legend`,componentIndex:t.componentIndex,dataIndex:r,value:i,seriesIndex:n.seriesIndex};Jz(e).eventData=a},t.prototype._createSelector=function(e,t,n,r,i){var a=this.getSelectorGroup();YQ(e,function(e){var r=e.type,i=new yz({style:{x:0,y:0,align:`center`,verticalAlign:`middle`},onclick:function(){n.dispatchAction({type:r===`all`?`legendAllSelect`:`legendInverseSelect`,legendId:t.id})}});a.add(i),zm(i,{normal:t.getModel(`selectorLabel`),emphasis:t.getModel([`emphasis`,`selectorLabel`])},{defaultText:e.title}),hp(i)})},t.prototype._createItem=function(e,t,n,r,i,a,o,s,c,l,u){var d=e.visualDrawType,f=i.get(`itemWidth`),p=i.get(`itemHeight`),m=i.isSelected(t),h=r.get(`symbolRotate`),g=r.get(`symbolKeepAspect`),_=r.get(`icon`);c=_||c||`roundRect`;var v=$A(c,r,o,s,d,m,u),y=new XQ,b=r.getModel(`textStyle`);if(B(e.getLegendIcon)&&(!_||_===`inherit`))y.add(e.getLegendIcon({itemWidth:f,itemHeight:p,icon:c,iconRotate:h,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}));else{var x=_===`inherit`&&e.getData().getVisual(`symbol`)?h===`inherit`?e.getData().getVisual(`symbolRotate`):h:0;y.add(ej({itemWidth:f,itemHeight:p,icon:c,iconRotate:x,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}))}var S=a===`left`?f+5:-5,C=a,w=i.get(`formatter`),T=t;V(w)&&w?T=w.replace(`{name}`,t??``):B(w)&&(T=w(t));var E=m?b.getTextColor():r.get(`inactiveColor`);y.add(new yz({style:Vm(b,{text:T,x:S,y:p/2,fill:E,align:C,verticalAlign:`middle`},{inheritColor:E})}));var D=new mz({shape:y.getBoundingRect(),style:{fill:`transparent`}}),O=r.getModel(`tooltip`);return O.get(`show`)&&wm({el:D,componentModel:i,itemName:t,itemTooltipOption:O.option}),y.add(D),y.eachChild(function(e){e.silent=!0}),D.silent=!l,this.getContentGroup().add(y),hp(y),y.__legendDataIndex=n,y},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getContentGroup(),s=this.getSelectorGroup();NU(e.get(`orient`),o,e.get(`itemGap`),n.width,n.height);var c=o.getBoundingRect(),l=[-c.x,-c.y];if(s.markRedraw(),o.markRedraw(),i){NU(`horizontal`,s,e.get(`selectorItemGap`,!0));var u=s.getBoundingRect(),d=[-u.x,-u.y],f=e.get(`selectorButtonGap`,!0),p=e.getOrient().index,m=p===0?`width`:`height`,h=p===0?`height`:`width`,g=p===0?`y`:`x`;a===`end`?d[p]+=c[m]+f:l[p]+=u[m]+f,d[1-p]+=c[h]/2-u[h]/2,s.x=d[0],s.y=d[1],o.x=l[0],o.y=l[1];var _={x:0,y:0};return _[m]=c[m]+f+u[m],_[h]=Math.max(c[h],u[h]),_[g]=Math.min(0,u[g]+d[1-p]),_}return o.x=l[0],o.y=l[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type=`legend.plain`,t}(Mq),QQ=jf(sj),$Q=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.setScrollDataIndex=function(e){this.option.scrollDataIndex=e},t.prototype.init=function(t,n,r){var i=e_(t);e.prototype.init.call(this,t,n,r),lj(this,t,i)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),lj(this,this.option,t)},t.type=`legend.scroll`,t.defaultOption=tg(qQ.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:`end`,pageFormatter:`{current}/{total}`,pageIcons:{horizontal:[`M0,0L12,-10L12,10z`,`M0,0L-12,-10L-12,10z`],vertical:[`M0,0L20,0L10,-20z`,`M0,0L20,0L10,20z`]},pageIconColor:X.color.accent50,pageIconInactiveColor:X.color.accent10,pageIconSize:15,pageTextStyle:{color:X.color.tertiary},animationDurationUpdate:800}),t}(qQ),e$=NB,t$=[`width`,`height`],n$=[`x`,`y`],r$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!0,n._currentIndex=0,n}return t.prototype.init=function(){e.prototype.init.call(this),this.group.add(this._containerGroup=new e$),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new e$)},t.prototype.resetInner=function(){e.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(t,n,r,i,a,o,s){var c=this;e.prototype.renderInner.call(this,t,n,r,i,a,o,s);var l=this._controllerGroup,u=n.get(`pageIconSize`,!0),d=z(u)?u:[u,u];p(`pagePrev`,0);var f=n.getModel(`pageTextStyle`);l.add(new yz({name:`pageText`,style:{text:`xx/xx`,fill:f.getTextColor(),font:f.getFont(),verticalAlign:`middle`,align:`center`},silent:!0})),p(`pageNext`,1);function p(e,t){var r=e+`DataIndex`,a=_m(n.get(`pageIcons`,!0)[n.getOrient().name][t],{onclick:q(c._pageGo,c,r,n,i)},{x:-d[0]/2,y:-d[1]/2,width:d[0],height:d[1]});a.name=e,l.add(a)}},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getSelectorGroup(),s=e.getOrient().index,c=t$[s],l=n$[s],u=t$[1-s],d=n$[1-s];i&&NU(`horizontal`,o,e.get(`selectorItemGap`,!0));var f=e.get(`selectorButtonGap`,!0),p=o.getBoundingRect(),m=[-p.x,-p.y],h=ps(n);i&&(h[c]=n[c]-p[c]-f);var g=this._layoutContentAndController(e,r,h,s,c,u,d,l);if(i){if(a===`end`)m[s]+=g[c]+f;else{var _=p[c]+f;m[s]-=_,g[l]-=_}g[c]+=p[c]+f,m[1-s]+=g[d]+g[u]/2-p[u]/2,g[u]=Math.max(g[u],p[u]),g[d]=Math.min(g[d],p[d]+m[1-s]),o.x=m[0],o.y=m[1],o.markRedraw()}return g},t.prototype._layoutContentAndController=function(e,t,n,r,i,a,o,s){var c=this.getContentGroup(),l=this._containerGroup,u=this._controllerGroup;NU(e.get(`orient`),c,e.get(`itemGap`),r?n.width:null,r?null:n.height),NU(`horizontal`,u,e.get(`pageButtonItemGap`,!0));var d=c.getBoundingRect(),f=u.getBoundingRect(),p=this._showController=d[i]>n[i],m=[-d.x,-d.y];t||(m[r]=c[s]);var h=[0,0],g=[-f.x,-f.y],_=U(e.get(`pageButtonGap`,!0),e.get(`itemGap`,!0));p&&(e.get(`pageButtonPosition`,!0)===`end`?g[r]+=n[i]-f[i]:h[r]+=f[i]+_),g[1-r]+=d[a]/2-f[a]/2,c.setPosition(m),l.setPosition(h),u.setPosition(g);var v={x:0,y:0};if(v[i]=p?n[i]:d[i],v[a]=Math.max(d[a],f[a]),v[o]=Math.min(0,f[o]+g[1-r]),l.__rectSize=n[i],p){var y={x:0,y:0};y[i]=Math.max(n[i]-f[i]-_,0),y[a]=v[a],l.setClipPath(new mz({shape:y})),l.__rectSize=y[i]}else u.eachChild(function(e){e.attr({invisible:!0,silent:!0})});var b=this._getPageInfo(e);return b.pageIndex!=null&&Kp(c,{x:b.contentPosition[0],y:b.contentPosition[1]},p?e:null),this._updatePageInfoView(e,b),v},t.prototype._pageGo=function(e,t,n){var r=this._getPageInfo(t)[e];r!=null&&n.dispatchAction({type:`legendScroll`,scrollDataIndex:r,legendId:t.id})},t.prototype._updatePageInfoView=function(e,t){var n=this._controllerGroup;L([`pagePrev`,`pageNext`],function(r){var i=t[r+`DataIndex`]!=null,a=n.childOfName(r);a&&(a.setStyle(`fill`,i?e.get(`pageIconColor`,!0):e.get(`pageIconInactiveColor`,!0)),a.cursor=i?`pointer`:`default`)});var r=n.childOfName(`pageText`),i=e.get(`pageFormatter`),a=t.pageIndex,o=a==null?0:a+1,s=t.pageCount;r&&i&&r.setStyle(`text`,V(i)?i.replace(`{current}`,o==null?``:o+``).replace(`{total}`,s==null?``:s+``):i({current:o,total:s}))},t.prototype._getPageInfo=function(e){var t=e.get(`scrollDataIndex`,!0),n=this.getContentGroup(),r=this._containerGroup.__rectSize,i=e.getOrient().index,a=t$[i],o=n$[i],s=this._findTargetItemIndex(t),c=n.children(),l=c[s],u=c.length,d=+!!u,f={contentPosition:[n.x,n.y],pageCount:d,pageIndex:d-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!l)return f;var p=v(l);f.contentPosition[i]=-p.s;for(var m=s+1,h=p,g=p,_=null;m<=u;++m)_=v(c[m]),(!_&&g.e>h.s+r||_&&!y(_,h.s))&&(h=g.i>h.i?g:_,h&&(f.pageNextDataIndex??=h.i,++f.pageCount)),g=_;for(var m=s-1,h=p,g=p,_=null;m>=-1;--m)_=v(c[m]),(!_||!y(g,_.s))&&h.i<g.i&&(g=h,f.pagePrevDataIndex??=h.i,++f.pageCount,++f.pageIndex),h=_;return f;function v(e){if(e){var t=e.getBoundingRect(),n=t[o]+e[o];return{s:n,e:n+t[a],i:e.__legendDataIndex}}}function y(e,t){return e.e>=t&&e.s<=t+r}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var t,n=this.getContentGroup(),r;return n.eachChild(function(n,i){var a=n.__legendDataIndex;r==null&&a!=null&&(r=i),a===e&&(t=i)}),t??r},t.type=`legend.scroll`,t}(ZQ),i$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.type=`dataZoom.inside`,t.defaultOption=tg(yQ.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(yQ),a$=af(),o$=function(e){F(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;return t.type=`dataZoom.inside`,t}return t.prototype.render=function(t,n,r){e.prototype.render.apply(this,arguments),t.noTarget()?this._clear():(this.range=t.getPercentRange(),pj(r,t,{pan:q(s$.pan,this),zoom:q(s$.zoom,this),scrollMove:q(s$.scrollMove,this)}))},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){mj(this.api,this.dataZoomModel),this.range=null},t.type=`dataZoom.inside`,t}(bQ),s$={zoom:function(e,t,n,r){var i=this.range,a=i.slice(),o=e.axisModels[0];if(o){var s=c$[t](null,[r.originX,r.originY],o,n,e),c=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(a[1]-a[0])+a[0],l=Math.max(1/r.scale,0);a[0]=(a[0]-c)*l+c,a[1]=(a[1]-c)*l+c;var u=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(_O(0,a,[0,100],0,u.minSpan,u.maxSpan),this.range=a,i[0]!==a[0]||i[1]!==a[1])return a}},pan:xj(function(e,t,n,r,i,a){var o=c$[r]([a.oldX,a.oldY],[a.newX,a.newY],t,i,n);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:xj(function(e,t,n,r,i,a){return c$[r]([0,0],[a.scrollDelta,a.scrollDelta],t,i,n).signal*(e[1]-e[0])*a.scrollDelta})},c$={grid:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem.getRect();return e||=[0,0],a.dim===`x`?(o.pixel=t[0]-e[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=a.inverse?-1:1),o},polar:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem,c=s.getRadiusAxis().getExtent(),l=s.getAngleAxis().getExtent();return e=e?s.pointToCoord(e):[0,0],t=s.pointToCoord(t),n.mainType===`radiusAxis`?(o.pixel=t[0]-e[0],o.pixelLength=c[1]-c[0],o.pixelStart=c[0],o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=a.inverse?-1:1),o},singleAxis:function(e,t,n,r,i){var a=n.axis,o=i.model.coordinateSystem.getRect(),s={};return e||=[0,0],a.orient===`horizontal`?(s.pixel=t[0]-e[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=a.inverse?1:-1):(s.pixel=t[1]-e[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=a.inverse?-1:1),s}},l$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.type=`dataZoom.slider`,t.layoutMode=`box`,t.defaultOption=tg(yQ.defaultOption,{show:!0,right:`ph`,top:`ph`,width:`ph`,height:`ph`,left:null,bottom:null,borderColor:X.color.accent10,borderRadius:0,backgroundColor:X.color.transparent,dataBackground:{lineStyle:{color:X.color.accent30,width:.5},areaStyle:{color:X.color.accent20,opacity:.2}},selectedDataBackground:{lineStyle:{color:X.color.accent40,width:.5},areaStyle:{color:X.color.accent20,opacity:.3}},fillerColor:`rgba(135,175,274,0.2)`,handleIcon:`path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z`,handleSize:`100%`,handleStyle:{color:X.color.neutral00,borderColor:X.color.accent20},moveHandleSize:7,moveHandleIcon:`path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z`,moveHandleStyle:{color:X.color.accent40,opacity:.5},showDetail:!0,showDataShadow:`auto`,realtime:!0,zoomLock:!1,textStyle:{color:X.color.tertiary},brushSelect:!0,brushStyle:{color:X.color.accent30,opacity:.3},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:X.color.accent40},moveHandleStyle:{opacity:.8}},defaultLocationEdgeGap:15}),t}(yQ),u$=mz,d$=1,f$=30,p$=7,m$=`horizontal`,h$=`vertical`,g$=5,_$=[`line`,`bar`,`candlestick`,`scatter`],v$={easing:`cubicOut`,duration:100,delay:0},y$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n._displayables={},n}return t.prototype.init=function(e,t){this.api=t,this._onBrush=q(this._onBrush,this),this._onBrushEnd=q(this._onBrushEnd,this)},t.prototype.render=function(t,n,r,i){e.prototype.render.apply(this,arguments),Jx(this,`_dispatchZoomAction`,t.get(`throttle`),`fixRate`),this._orient=t.getOrient(),t.get(`show`)===!1?this.group.removeAll():t.noTarget()?(this._clear(),this.group.removeAll()):(i&&i.type===`dataZoom`&&i.from===this.uid||this._buildView(),this._updateView())},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){Yx(this,`_dispatchZoomAction`);var e=this.api.getZr();e.off(`mousemove`,this._onBrush),e.off(`mouseup`,this._onBrushEnd)},t.prototype._buildView=function(){var e=this.group;e.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval();var t=this._displayables.sliderGroup=new NB;this._renderBackground(),this._renderHandle(),this._renderDataShadow(),e.add(t),this._positionGroup()},t.prototype._resetLocation=function(){var e=this.dataZoomModel,t=this.api,n=e.get(`brushSelect`)?p$:0,r=Yg(e,t).refContainer,i=this._findCoordRect(),a=e.get(`defaultLocationEdgeGap`,!0)||0,o=this._orient===m$?{right:r.width-i.x-i.width,top:r.height-f$-a-n,width:i.width,height:f$}:{right:a,top:i.y,width:f$,height:i.height},s=e_(e.option);L([`right`,`top`,`width`,`height`],function(e){s[e]===`ph`&&(s[e]=o[e])});var c=Jg(s,r);this._location={x:c.x,y:c.y},this._size=[c.width,c.height],this._orient===h$&&this._size.reverse()},t.prototype._positionGroup=function(){var e=this.group,t=this._location,n=this._orient,r=this.dataZoomModel.getFirstTargetAxisModel(),i=r&&r.get(`inverse`),a=this._displayables.sliderGroup,o=(this._dataShadowInfo||{}).otherAxisInverse;a.attr(n===m$&&!i?{scaleY:o?1:-1,scaleX:1}:n===m$&&i?{scaleY:o?1:-1,scaleX:-1}:n===h$&&!i?{scaleY:o?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:o?-1:1,scaleX:-1,rotation:Math.PI/2});var s=e.getBoundingRect([a]),c=isNaN(s.x)?0:s.x,l=isNaN(s.y)?0:s.y;e.x=t.x-c,e.y=t.y-l,e.markRedraw()},t.prototype._getViewExtent=function(){return[0,this._size[0]]},t.prototype._renderBackground=function(){var e=this.dataZoomModel,t=this._size,n=this._displayables.sliderGroup,r=e.get(`brushSelect`);n.add(new u$({silent:!0,shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:e.get(`backgroundColor`)},z2:-40}));var i=new u$({shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:`transparent`},z2:0,onclick:q(this._onClickPanel,this)}),a=this.api.getZr();r?(i.on(`mousedown`,this._onBrushStart,this),i.cursor=`crosshair`,a.on(`mousemove`,this._onBrush),a.on(`mouseup`,this._onBrushEnd)):(a.off(`mousemove`,this._onBrush),a.off(`mouseup`,this._onBrushEnd)),n.add(i)},t.prototype._renderDataShadow=function(){var e=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],!e)return;var t=this._size,n=this._shadowSize||[],r=e.series,i=r.getRawData(),a=r.getShadowDim&&r.getShadowDim(),o=a&&i.getDimensionInfo(a)?r.getShadowDim():e.otherDim;if(o==null)return;var s=this._shadowPolygonPts,c=this._shadowPolylinePts;if(i!==this._shadowData||o!==this._shadowDim||t[0]!==n[0]||t[1]!==n[1]){var l=i.getDataExtent(e.thisDim),u=i.getDataExtent(o),d=(u[1]-u[0])*.3;u=[u[0]-d,u[1]+d];var f=[0,t[1]],p=[0,t[0]],m=[[t[0],0],[0,0]],h=[],g=p[1]/Math.max(1,i.count()-1),_=t[0]/(l[1]-l[0]),v=e.thisAxis.type===`time`,y=-g,b=Math.round(i.count()/t[0]),x;i.each([e.thisDim,o],function(e,t,n){if(b>0&&n%b)v||(y+=g);else{y=v?(+e-l[0])*_:y+g;var r=t==null||isNaN(t)||t===``,i=r?0:ud(t,u,f,!0);r&&!x&&n?(m.push([m[m.length-1][0],0]),h.push([h[h.length-1][0],0])):!r&&x&&(m.push([y,0]),h.push([y,0])),r||(m.push([y,i]),h.push([y,i])),x=r}}),s=this._shadowPolygonPts=m,c=this._shadowPolylinePts=h}this._shadowData=i,this._shadowDim=o,this._shadowSize=[t[0],t[1]];var S=this.dataZoomModel;function C(e){var t=S.getModel(e?`selectedDataBackground`:`dataBackground`),n=new NB,r=new eV({shape:{points:s},segmentIgnoreThreshold:1,style:t.getModel(`areaStyle`).getAreaStyle(),silent:!0,z2:-20}),i=new nV({shape:{points:c},segmentIgnoreThreshold:1,style:t.getModel(`lineStyle`).getLineStyle(),silent:!0,z2:-19});return n.add(r),n.add(i),n}for(var w=0;w<3;w++){var T=C(w===1);this._displayables.sliderGroup.add(T),this._displayables.dataShadowSegs.push(T)}},t.prototype._prepareDataShadowInfo=function(){var e=this.dataZoomModel,t=e.get(`showDataShadow`);if(t!==!1){var n,r=this.ecModel;return e.eachTargetAxis(function(i,a){L(e.getAxisProxy(i,a).getTargetSeriesModels(),function(e){if(!n&&!(t!==!0&&_s(_$,e.get(`type`))<0)){var o=r.getComponent(Zk(i),a).axis,s=wj(i),c,l=e.coordinateSystem;s!=null&&l.getOtherAxis&&(c=l.getOtherAxis(o).inverse),s=e.getData().mapDimension(s),n={thisAxis:o,series:e,thisDim:e.getData().mapDimension(i),otherDim:s,otherAxisInverse:c}}},this)},this),n}},t.prototype._renderHandle=function(){var e=this.group,t=this._displayables,n=t.handles=[null,null],r=t.handleLabels=[null,null],i=this._displayables.sliderGroup,a=this._size,o=this.dataZoomModel,s=this.api,c=o.get(`borderRadius`)||0,l=o.get(`brushSelect`),u=t.filler=new u$({silent:l,style:{fill:o.get(`fillerColor`)},textConfig:{position:`inside`}});i.add(u),i.add(new u$({silent:!0,subPixelOptimize:!0,shape:{x:0,y:0,width:a[0],height:a[1],r:c},style:{stroke:o.get(`dataBackgroundColor`)||o.get(`borderColor`),lineWidth:d$,fill:X.color.transparent}})),L([0,1],function(t){var a=o.get(`handleIcon`);!iW[a]&&a.indexOf(`path://`)<0&&a.indexOf(`image://`)<0&&(a=`path://`+a);var s=Y_(a,-1,0,2,2,null,!0);s.attr({cursor:Tj(this._orient),draggable:!0,drift:q(this._onDragMove,this,t),ondragend:q(this._onDragEnd,this),onmouseover:q(this._onOverDataInfoTriggerArea,this,!0),onmouseout:q(this._onOverDataInfoTriggerArea,this,!1),z2:5});var c=s.getBoundingRect(),l=o.get(`handleSize`);this._handleHeight=Y(l,this._size[1]),this._handleWidth=c.width/c.height*this._handleHeight,s.setStyle(o.getModel(`handleStyle`).getItemStyle()),s.style.strokeNoScale=!0,s.rectHover=!0,s.ensureState(`emphasis`).style=o.getModel([`emphasis`,`handleStyle`]).getItemStyle(),hp(s);var u=o.get(`handleColor`);u!=null&&(s.style.fill=u),i.add(n[t]=s);var d=o.getModel(`textStyle`),f=(o.get(`handleLabel`)||{}).show||!1;e.add(r[t]=new yz({silent:!0,invisible:!f,style:Vm(d,{x:0,y:0,text:``,verticalAlign:`middle`,align:`center`,fill:d.getTextColor(),font:d.getFont()}),z2:10}))},this);var d=u;if(l){var f=Y(o.get(`moveHandleSize`),a[1]),p=t.moveHandle=new mz({style:o.getModel(`moveHandleStyle`).getItemStyle(),silent:!0,shape:{r:[0,0,2,2],y:a[1]-.5,height:f}}),m=f*.8,h=t.moveHandleIcon=Y_(o.get(`moveHandleIcon`),-m/2,-m/2,m,m,X.color.neutral00,!0);h.silent=!0,h.y=a[1]+f/2-.5,p.ensureState(`emphasis`).style=o.getModel([`emphasis`,`moveHandleStyle`]).getItemStyle();var g=Math.min(a[1]/2,Math.max(f,10));d=t.moveZone=new mz({invisible:!0,shape:{y:a[1]-g,height:f+g}}),d.on(`mouseover`,function(){s.enterEmphasis(p)}).on(`mouseout`,function(){s.leaveEmphasis(p)}),i.add(p),i.add(h),i.add(d)}d.attr({draggable:!0,cursor:`grab`,drift:q(this._onActualMoveZoneDrift,this),ondragstart:q(this._onActualMoveZoneDragStart,this),ondragend:q(this._onActualMoveZoneDragEnd,this),onmouseover:q(this._onOverDataInfoTriggerArea,this,!0),onmouseout:q(this._onOverDataInfoTriggerArea,this,!1)})},t.prototype._resetInterval=function(){var e=this._range=this.dataZoomModel.getPercentRange(),t=this._getViewExtent();this._handleEnds=[ud(e[0],[0,100],t,!0),ud(e[1],[0,100],t,!0)]},t.prototype._updateInterval=function(e,t){var n=this.dataZoomModel,r=this._handleEnds,i=this._getViewExtent(),a=n.findRepresentativeAxisProxy().getMinMaxSpan(),o=[0,100];_O(t,r,i,n.get(`zoomLock`)?`all`:e,a.minSpan==null?null:ud(a.minSpan,o,i,!0),a.maxSpan==null?null:ud(a.maxSpan,o,i,!0));var s=this._range,c=this._range=gd([ud(r[0],i,o,!0),ud(r[1],i,o,!0)]);return!s||s[0]!==c[0]||s[1]!==c[1]},t.prototype._updateView=function(e){var t=this._displayables,n=this._handleEnds,r=gd(n.slice()),i=this._size;L([0,1],function(e){var r=t.handles[e],a=this._handleHeight;r.attr({scaleX:a/2,scaleY:a/2,x:n[e]+(e?-1:1),y:i[1]/2-a/2})},this),t.filler.setShape({x:r[0],y:0,width:r[1]-r[0],height:i[1]});var a={x:r[0],width:r[1]-r[0]};t.moveHandle&&(t.moveHandle.setShape(a),t.moveZone.setShape(a),t.moveZone.getBoundingRect(),t.moveHandleIcon&&t.moveHandleIcon.attr(`x`,a.x+a.width/2));for(var o=t.dataShadowSegs,s=[0,r[0],r[1],i[0]],c=0;c<o.length;c++){var l=o[c],u=l.getClipPath();u||(u=new mz,l.setClipPath(u)),u.setShape({x:s[c],y:0,width:s[c+1]-s[c],height:i[1]})}this._updateDataInfo(e)},t.prototype._updateDataInfo=function(e){var t=this.dataZoomModel,n=this._displayables,r=n.handleLabels,i=this._orient,a=[``,``];if(t.get(`showDetail`)){var o=t.findRepresentativeAxisProxy(),s=o.getAxisModel().axis.scale;if(o){var c=this._range,l;if(e){var u={start:c[0],end:c[1]},d=rA(t,o);if(d){var f=d.calculateDataWindow(u).percentInverted;u={start:f[0],end:f[1]}}l=o.calculateDataWindow(u)}else l=o.getWindow();a=[Cj(t,0,l,s),Cj(t,1,l,s)]}}var p=gd(this._handleEnds.slice());m.call(this,0),m.call(this,1);function m(e){var t=lm(n.handles[e].parent,this.group),o=dm(e===0?`right`:`left`,t),s=this._handleWidth/2+g$,c=um([p[e]+(e===0?-s:s),this._size[1]/2],t);r[e].setStyle({x:c[0],y:c[1],verticalAlign:i===m$?`middle`:o,align:i===m$?o:`center`,text:a[e]})}},t.prototype._onOverDataInfoTriggerArea=function(e){this._isOverDataInfoTriggerArea=e,this._showDataInfo(e)},t.prototype._showDataInfo=function(e){var t=(this.dataZoomModel.get(`handleLabel`)||{}).show||!1,n=this.dataZoomModel.getModel([`emphasis`,`handleLabel`]).get(`show`)||!1,r=e||this._dragging?n:t,i=this._displayables,a=i.handleLabels;a[0].attr(`invisible`,!r),a[1].attr(`invisible`,!r),i.moveHandle&&this.api[r?`enterEmphasis`:`leaveEmphasis`](i.moveHandle,1)},t.prototype._onActualMoveZoneDrift=function(e,t,n){this.api.getZr().setCursorStyle(`grabbing`),this._onDragMove(`all`,e,t,n)},t.prototype._onActualMoveZoneDragStart=function(e){e.target.attr(`cursor`,`grabbing`),this._showDataInfo(!0)},t.prototype._onActualMoveZoneDragEnd=function(e){e.target.attr(`cursor`,`grab`),this._onDragEnd()},t.prototype._onDragMove=function(e,t,n,r){this._dragging=!0,IK(r.event);var i=this._displayables.sliderGroup.getLocalTransform(),a=um([t,n],i,!0),o=this._updateInterval(e,a[0]),s=this.dataZoomModel.get(`realtime`);this._updateView(!s),o&&s&&this._dispatchZoomAction(!0)},t.prototype._onDragEnd=function(){this._dragging=!1,this._isOverDataInfoTriggerArea||this._showDataInfo(!1),!this.dataZoomModel.get(`realtime`)&&this._dispatchZoomAction(!1)},t.prototype._onClickPanel=function(e){var t=this._size,n=this._displayables.sliderGroup.transformCoordToLocal(e.offsetX,e.offsetY);if(!(n[0]<0||n[0]>t[0]||n[1]<0||n[1]>t[1])){var r=this._handleEnds,i=(r[0]+r[1])/2,a=this._updateInterval(`all`,n[0]-i);this._updateView(),a&&this._dispatchZoomAction(!1)}},t.prototype._onBrushStart=function(e){var t=e.offsetX,n=e.offsetY;this._brushStart=new FI(t,n),this._brushing=!0,this._brushStartTime=+new Date},t.prototype._onBrushEnd=function(e){if(this._brushing){var t=this._displayables.brushRect;if(this._brushing=!1,t){t.attr(`ignore`,!0);var n=t.shape;if(!(+new Date-this._brushStartTime<200&&Math.abs(n.width)<5)){var r=this._getViewExtent(),i=[0,100],a=this._handleEnds=[n.x,n.x+n.width],o=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();_O(0,a,r,0,o.minSpan==null?null:ud(o.minSpan,i,r,!0),o.maxSpan==null?null:ud(o.maxSpan,i,r,!0)),this._range=gd([ud(a[0],r,i,!0),ud(a[1],r,i,!0)]),this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(e){this._brushing&&(IK(e.event),this._updateBrushRect(e.offsetX,e.offsetY))},t.prototype._updateBrushRect=function(e,t){var n=this._displayables,r=this.dataZoomModel,i=n.brushRect;i||(i=n.brushRect=new u$({silent:!0,style:r.getModel(`brushStyle`).getItemStyle()}),n.sliderGroup.add(i)),i.attr(`ignore`,!1);var a=this._brushStart,o=this._displayables.sliderGroup,s=o.transformCoordToLocal(e,t),c=o.transformCoordToLocal(a.x,a.y),l=this._size;s[0]=Math.max(Math.min(l[0],s[0]),0),i.setShape({x:c[0],y:0,width:s[0]-c[0],height:l[1]})},t.prototype._dispatchZoomAction=function(e){var t=this._range;this.api.dispatchAction({type:`dataZoom`,from:this.uid,dataZoomId:this.dataZoomModel.id,animation:e?v$:null,start:t[0],end:t[1]})},t.prototype._findCoordRect=function(){var e,t=$k(this.dataZoomModel).infoList;if(!e&&t.length){var n=t[0].model.coordinateSystem;e=n.getRect&&n.getRect()}if(!e){var r=this.api.getWidth(),i=this.api.getHeight();e={x:r*.2,y:i*.2,width:r*.6,height:i*.6}}return e},t.type=`dataZoom.slider`,t}(bQ),b$={get:function(e,t,n){var r=ps((x$[e]||{})[t]);return n&&z(r)?r[r.length-1]:r}},x$={color:{active:[`#006edd`,`#e0ffff`],inactive:[X.color.transparent]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:[`circle`,`roundRect`,`diamond`],inactive:[`none`]},symbolSize:{active:[10,50],inactive:[0,0]}},S$=iZ.mapVisual,C$=iZ.eachVisual,w$=z,T$=L,E$=gd,D$=ud,O$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.stateList=[`inRange`,`outOfRange`],n.replacableOptionKeys=[`inRange`,`outOfRange`,`target`,`controller`,`color`],n.layoutMode={type:`box`,ignoreSize:!0},n.dataBound=[-1/0,1/0],n.targetVisuals={},n.controllerVisuals={},n}return t.prototype.init=function(e,t,n){this.mergeDefaultAndTheme(e,n)},t.prototype.optionUpdated=function(e,t){var n=this.option;!t&&MA(n,e,this.replacableOptionKeys),this.textStyleModel=this.getModel(`textStyle`),this.resetItemSize(),this.completeVisualOption()},t.prototype.resetVisual=function(e){var t=this.stateList;e=q(e,this),this.controllerVisuals=jA(this.option.controller,t,e),this.targetVisuals=jA(this.option.target,t,e)},t.prototype.getItemSymbol=function(){return null},t.prototype.getTargetSeriesIndices=function(){var e=this,t=this.option.seriesTargets;if(t){var n=[];return T$(t,function(t){if(t.seriesIndex!=null)n.push(t.seriesIndex);else if(t.seriesId!=null){var r;e.ecModel.eachSeries(function(e){e.id===t.seriesId&&(r=e)}),r&&n.push(r.componentIndex)}}),n}var r=this.option.seriesId,i=this.option.seriesIndex;i==null&&r==null&&(i=`all`);var a=cf(this.ecModel,`series`,{index:i,id:r},{useDefault:!1,enableAll:!0,enableNone:!1}).models;return R(a,function(e){return e.componentIndex})},t.prototype.eachTargetSeries=function(e,t){L(this.getTargetSeriesIndices(),function(n){var r=this.ecModel.getSeriesByIndex(n);r&&e.call(t,r)},this)},t.prototype.isTargetSeries=function(e){var t=!1;return this.eachTargetSeries(function(n){n===e&&(t=!0)}),t},t.prototype.formatValueText=function(e,t,n){var r=this.option,i=r.precision,a=this.dataBound,o=r.formatter,s;n||=[`<`,`>`],z(e)&&(e=e.slice(),s=!0);var c=t?e:s?[l(e[0]),l(e[1])]:l(e);return V(o)?o.replace(`{value}`,s?c[0]:c).replace(`{value2}`,s?c[1]:c):B(o)?s?o(e[0],e[1]):o(e):s?e[0]===a[0]?n[0]+` `+c[1]:e[1]===a[1]?n[1]+` `+c[0]:c[0]+` - `+c[1]:c;function l(e){return e===a[0]?`min`:e===a[1]?`max`:(+e).toFixed(Math.min(i,20))}},t.prototype.resetExtent=function(){var e=this.option,t=E$([e.min,e.max]);this._dataExtent=t},t.prototype.getDimension=function(e){var t=this,n=this.option.seriesTargets;if(n){var r=Cs(n,function(n){return n.seriesIndex!=null&&n.seriesIndex===e||n.seriesId!=null&&n.seriesId===t.ecModel.getSeriesByIndex(e).id});if(r)return r.dimension}return this.option.dimension},t.prototype.getDataDimensionIndex=function(e){var t=e.hostModel.seriesIndex,n=this.getDimension(t);if(n!=null)return e.getDimensionIndex(n);for(var r=e.dimensions,i=r.length-1;i>=0;i--){var a=r[i],o=e.getDimensionInfo(a);if(!o.isCalculationCoord)return o.storeDimIndex}},t.prototype.getExtent=function(){return this._dataExtent.slice()},t.prototype.completeVisualOption=function(){var e=this.ecModel,t=this.option,n={inRange:t.inRange,outOfRange:t.outOfRange},r=t.target||={},i=t.controller||={};ms(r,n),ms(i,n);var a=this.isCategory();o.call(this,r),o.call(this,i),s.call(this,r,`inRange`,`outOfRange`),c.call(this,i);function o(n){w$(t.color)&&!n.inRange&&(n.inRange={color:t.color.slice().reverse()}),n.inRange=n.inRange||{color:e.get(`gradientColor`)}}function s(e,t,n){var r=e[t],i=e[n];r&&!i&&(i=e[n]={},T$(r,function(e,t){if(iZ.isValidType(t)){var n=b$.get(t,`inactive`,a);n!=null&&(i[t]=n,t===`color`&&!i.hasOwnProperty(`opacity`)&&!i.hasOwnProperty(`colorAlpha`)&&(i.opacity=[0,0]))}}))}function c(e){var t=(e.inRange||{}).symbol||(e.outOfRange||{}).symbol,n=(e.inRange||{}).symbolSize||(e.outOfRange||{}).symbolSize,r=this.get(`inactiveColor`),i=this.getItemSymbol()||`roundRect`;T$(this.stateList,function(o){var s=this.itemSize,c=e[o];c||=e[o]={color:a?r:[r]},c.symbol??(c.symbol=t&&ps(t)||(a?i:[i])),c.symbolSize??(c.symbolSize=n&&ps(n)||(a?s[0]:[s[0],s[0]])),c.symbol=S$(c.symbol,function(e){return e===`none`?i:e});var l=c.symbolSize;if(l!=null){var u=-1/0;C$(l,function(e){e>u&&(u=e)}),c.symbolSize=S$(l,function(e){return D$(e,[0,u],[0,s[0]],!0)})}},this)}},t.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get(`itemWidth`)),parseFloat(this.get(`itemHeight`))]},t.prototype.isCategory=function(){return!!this.option.categories},t.prototype.setSelected=function(e){},t.prototype.getSelected=function(){return null},t.prototype.getValueState=function(e){return null},t.prototype.getVisualMeta=function(e){return null},t.type=`visualMap`,t.dependencies=[`series`],t.defaultOption={show:!0,z:4,min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:`vertical`,backgroundColor:X.color.transparent,borderColor:X.color.borderTint,contentColor:X.color.theme[0],inactiveColor:X.color.disabled,borderWidth:0,padding:X.size.m,textGap:10,precision:0,textStyle:{color:X.color.secondary}},t}(IU),k$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.autoPositionValues={left:1,right:1,top:1,bottom:1},n}return t.prototype.init=function(e,t){this.ecModel=e,this.api=t},t.prototype.render=function(e,t,n,r){this.visualMapModel=e,e.get(`show`)===!1?this.group.removeAll():this.doRender(e,t,n,r)},t.prototype.renderBackground=function(e){var t=this.visualMapModel,n=DU(t.get(`padding`)||0),r=e.getBoundingRect();e.add(new mz({z2:-1,silent:!0,shape:{x:r.x-n[3],y:r.y-n[0],width:r.width+n[3]+n[1],height:r.height+n[0]+n[2]},style:{fill:t.get(`backgroundColor`),stroke:t.get(`borderColor`),lineWidth:t.get(`borderWidth`)}}))},t.prototype.getControllerVisual=function(e,t,n){n||={};var r=n.forceState,i=this.visualMapModel,a={};t===`color`&&(a.color=i.get(`contentColor`));function o(e){return a[e]}function s(e,t){a[e]=t}var c=i.controllerVisuals[r||i.getValueState(e)];return L(iZ.prepareVisualTypes(c),function(r){var i=c[r];n.convertOpacityToAlpha&&r===`opacity`&&(r=`colorAlpha`,i=c.__alphaForOpacity),iZ.dependsOn(r,t)&&i&&i.applyVisual(e,o,s)}),a[t]},t.prototype.positionGroup=function(e){var t=this.visualMapModel,n=this.api,r=Yg(t,n).refContainer;Xg(e,t.getBoxLayoutParams(),r)},t.prototype.doRender=function(e,t,n,r){},t.type=`visualMap`,t}(Mq),A$=[[`left`,`right`,`width`],[`top`,`bottom`,`height`]],j$={type:`selectDataRange`,event:`dataRangeSelected`,update:`update`},M$=function(e,t){t.eachComponent({mainType:`visualMap`,query:e},function(t){t.setSelected(e.selected)})},N$=[{createOnAllSeries:!0,reset:function(e,t){var n=[];return t.eachComponent(`visualMap`,function(t){var r=e.pipelineContext;!t.isTargetSeries(e)||r&&r.large||n.push(NA(t.stateList,t.targetVisuals,q(t.getValueState,t),t.getDataDimensionIndex(e.getData())))}),n}},{createOnAllSeries:!0,reset:function(e,t){var n=e.getData(),r=[];t.eachComponent(`visualMap`,function(t){if(t.isTargetSeries(e)){var i=t.getVisualMeta(q(Aj,null,e,t))||{stops:[],outerColors:[]},a=t.getDataDimensionIndex(n);a>=0&&(i.dimension=a,r.push(i))}}),e.getData().setVisual(`visualMeta`,r)}}],P$=L,F$=!1,I$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n._pieceList=[],n}return t.prototype.optionUpdated=function(t,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var r=this._mode=this._determineMode();this._pieceList=[],L$[this._mode].call(this,this._pieceList),this._resetSelected(t,n);var i=this.option.categories;this.resetVisual(function(e,t){r===`categories`?(e.mappingMethod=`category`,e.categories=ps(i)):(e.dataExtent=this.getExtent(),e.mappingMethod=`piecewise`,e.pieceList=R(this._pieceList,function(e){return e=ps(e),t!==`inRange`&&(e.visual=null),e}))})},t.prototype.completeVisualOption=function(){var t=this.option,n={},r=iZ.listVisualTypes(),i=this.isCategory();L(t.pieces,function(e){L(r,function(t){e.hasOwnProperty(t)&&(n[t]=1)})}),L(n,function(e,n){var r=!1;L(this.stateList,function(e){r=r||a(t,e,n)||a(t.target,e,n)},this),!r&&L(this.stateList,function(e){(t[e]||(t[e]={}))[n]=b$.get(n,e===`inRange`?`active`:`inactive`,i)})},this);function a(e,t,n){return e&&e[t]&&e[t].hasOwnProperty(n)}e.prototype.completeVisualOption.apply(this,arguments)},t.prototype._resetSelected=function(e,t){var n=this.option,r=this._pieceList,i=(t?n:e).selected||{};if(n.selected=i,L(r,function(e,t){var n=this.getSelectedMapKey(e);i.hasOwnProperty(n)||(i[n]=!0)},this),n.selectedMode===`single`){var a=!1;L(r,function(e,t){var n=this.getSelectedMapKey(e);i[n]&&(a?i[n]=!1:a=!0)},this)}},t.prototype.getItemSymbol=function(){return this.get(`itemSymbol`)},t.prototype.getSelectedMapKey=function(e){return this._mode===`categories`?e.value+``:e.index+``},t.prototype.getPieceList=function(){return this._pieceList},t.prototype._determineMode=function(){var e=this.option;return e.pieces&&e.pieces.length>0?`pieces`:this.option.categories?`categories`:`splitNumber`},t.prototype.setSelected=function(e){this.option.selected=ps(e)},t.prototype.getValueState=function(e){var t=iZ.findPieceIndex(e,this._pieceList);return t==null?`outOfRange`:this.option.selected[this.getSelectedMapKey(this._pieceList[t])]?`inRange`:`outOfRange`},t.prototype.findTargetDataIndices=function(e){var t=[],n=this._pieceList;return this.eachTargetSeries(function(r){var i=[],a=r.getData();a.each(this.getDataDimensionIndex(a),function(t,r){iZ.findPieceIndex(t,n)===e&&i.push(r)},this),t.push({seriesId:r.id,dataIndex:i})},this),t},t.prototype.getRepresentValue=function(e){var t;if(this.isCategory())t=e.value;else if(e.value!=null)t=e.value;else{var n=e.interval||[];t=n[0]===-1/0&&n[1]===1/0?0:(n[0]+n[1])/2}return t},t.prototype.getVisualMeta=function(e){if(this.isCategory())return;var t=[],n=[``,``],r=this;function i(i,a){var o=r.getRepresentValue({interval:i});a||=r.getValueState(o);var s=e(o,a);i[0]===-1/0?n[0]=s:i[1]===1/0?n[1]=s:t.push({value:i[0],color:s},{value:i[1],color:s})}var a=this._pieceList.slice();if(!a.length)a.push({interval:[-1/0,1/0]});else{var o=a[0].interval[0];o!==-1/0&&a.unshift({interval:[-1/0,o]}),o=a[a.length-1].interval[1],o!==1/0&&a.push({interval:[o,1/0]})}var s=-1/0;return L(a,function(e){var t=e.interval;t&&(t[0]>s&&i([s,t[0]],`outOfRange`),i(t.slice()),s=t[1])},this),{stops:t,outerColors:n}},t.type=`visualMap.piecewise`,t.defaultOption=tg(O$.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:`auto`,itemWidth:20,itemHeight:14,itemSymbol:`roundRect`,pieces:null,categories:null,splitNumber:5,selectedMode:`multiple`,itemGap:10,hoverLink:!0}),t}(O$),L$={splitNumber:function(e){var t=this.option,n=Math.min(t.precision,20),r=this.getExtent(),i=t.splitNumber;i=Math.max(parseInt(i,10),1),t.splitNumber=i;for(var a=(r[1]-r[0])/i;+a.toFixed(n)!==a&&n<5;)n++;t.precision=n,a=+a.toFixed(n),t.minOpen&&e.push({interval:[-1/0,r[0]],close:[0,0]});for(var o=0,s=r[0];o<i;s+=a,o++){var c=o===i-1?r[1]:s+a;e.push({interval:[s,c],close:[1,1]})}t.maxOpen&&e.push({interval:[r[1],1/0],close:[0,0]}),Od(e),L(e,function(e,t){e.index=t,e.text=this.formatValueText(e.interval)},this)},categories:function(e){var t=this.option;L(t.categories,function(t){e.push({text:this.formatValueText(t,!0),value:t})},this),Pj(t,e)},pieces:function(e){var t=this.option;L(t.pieces,function(t,n){H(t)||(t={value:t});var r={text:``,index:n};if(t.label!=null&&(r.text=t.label),t.hasOwnProperty(`value`)){var i=r.value=t.value;r.interval=[i,i],r.close=[1,1]}else{for(var a=r.interval=[],o=r.close=[0,0],s=[1,0,1],c=[-1/0,1/0],l=[],u=0;u<2;u++){for(var d=[[`gte`,`gt`,`min`],[`lte`,`lt`,`max`]][u],f=0;f<3&&a[u]==null;f++)a[u]=t[d[f]],o[u]=s[f],l[u]=f===2;a[u]??(a[u]=c[u])}l[0]&&a[1]===1/0&&(o[0]=0),l[1]&&a[0]===-1/0&&(o[1]=0),a[0]===a[1]&&o[0]&&o[1]&&(r.value=a[0])}r.visual=iZ.retrieveVisuals(t),e.push(r)},this),Pj(t,e),Od(e),L(e,function(e){var t=e.close,n=[[`<`,`≤`][t[1]],[`>`,`≥`][t[0]]];e.text=e.text||this.formatValueText(e.value==null?e.interval:e.value,!1,n)},this)}},R$=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.doRender=function(){var e=this.group;e.removeAll();var t=this.visualMapModel,n=t.get(`textGap`),r=t.textStyleModel,i=this._getItemAlign(),a=t.itemSize,o=this._getViewData(),s=o.endsText,c=Fs(t.get(`showLabel`,!0),!s),l=!t.get(`selectedMode`);s&&this._renderEndsText(e,s[0],a,c,i),L(o.viewPieceList,function(o){var s=o.piece,u=new NB;u.onclick=q(this._onItemClick,this,s),this._enableHoverLink(u,o.indexInModelPieceList);var d=t.getRepresentValue(s);if(this._createItemSymbol(u,d,[0,0,a[0],a[1]],l),c){var f=this.visualMapModel.getValueState(d),p=r.get(`align`)||i;u.add(new yz({style:Vm(r,{x:p===`right`?-n:a[0]+n,y:a[1]/2,text:s.text,verticalAlign:r.get(`verticalAlign`)||`middle`,align:p,opacity:U(r.get(`opacity`),f===`outOfRange`?.5:1)}),silent:l}))}e.add(u)},this),s&&this._renderEndsText(e,s[1],a,c,i),NU(t.get(`orient`),e,t.get(`itemGap`)),this.renderBackground(e),this.positionGroup(e)},t.prototype._enableHoverLink=function(e,t){var n=this;e.on(`mouseover`,function(){return r(`highlight`)}).on(`mouseout`,function(){return r(`downplay`)});var r=function(e){var r=n.visualMapModel;r.option.hoverLink&&n.api.dispatchAction({type:e,batch:kj(r.findTargetDataIndices(t),r)})}},t.prototype._getItemAlign=function(){var e=this.visualMapModel,t=e.option;if(t.orient===`vertical`)return Oj(e,this.api,e.itemSize);var n=t.align;return n&&n!==`auto`||(n=`left`),n},t.prototype._renderEndsText=function(e,t,n,r,i){if(t){var a=new NB,o=this.visualMapModel.textStyleModel;a.add(new yz({style:Vm(o,{x:r?i===`right`?n[0]:0:n[0]/2,y:n[1]/2,verticalAlign:`middle`,align:r?i:`center`,text:t})})),e.add(a)}},t.prototype._getViewData=function(){var e=this.visualMapModel,t=R(e.getPieceList(),function(e,t){return{piece:e,indexInModelPieceList:t}}),n=e.get(`text`),r=e.get(`orient`),i=e.get(`inverse`);return(r===`horizontal`?i:!i)?t.reverse():n&&=n.slice().reverse(),{viewPieceList:t,endsText:n}},t.prototype._createItemSymbol=function(e,t,n,r){var i=Y_(this.getControllerVisual(t,`symbol`),n[0],n[1],n[2],n[3],this.getControllerVisual(t,`color`));i.silent=r,e.add(i)},t.prototype._onItemClick=function(e){var t=this.visualMapModel,n=t.option,r=n.selectedMode;if(r){var i=ps(n.selected),a=t.getSelectedMapKey(e);r===`single`||r===!0?(i[a]=!0,L(i,function(e,t){i[t]=t===a})):i[a]=!i[a],this.api.dispatchAction({type:`selectDataRange`,from:this.uid,visualMapId:this.visualMapModel.id,selected:i})}},t.type=`visualMap.piecewise`,t}(k$),z$=[`align`,`verticalAlign`,`width`,`height`,`fontSize`],B$=new bL,V$=af(),H$=af(),U$=[`x`,`y`,`rotation`],W$=function(){function e(){this._labelList=[],this._chartViewList=[]}return e.prototype.clearLabels=function(){this._labelList=[],this._chartViewList=[]},e.prototype._addLabel=function(e,t,n,r,i){var a=r.style,o=r.__hostTarget.textConfig||{},s=r.getComputedTransform(),c=r.getBoundingRect().plain();J.applyTransform(c,c,s),s?B$.setLocalTransform(s):(B$.x=B$.y=B$.rotation=B$.originX=B$.originY=0,B$.scaleX=B$.scaleY=1),B$.rotation=Lu(B$.rotation);var l=r.__hostTarget,u;if(l){u=l.getBoundingRect().plain();var d=l.getComputedTransform();J.applyTransform(u,u,d)}var f=u&&l.getTextGuideLine();this._labelList.push({label:r,labelLine:f,seriesModel:n,dataIndex:e,dataType:t,layoutOptionOrCb:i,layoutOption:null,rect:c,hostRect:u,priority:u?u.width*u.height:0,defaultAttr:{ignore:r.ignore,labelGuideIgnore:f&&f.ignore,x:B$.x,y:B$.y,scaleX:B$.scaleX,scaleY:B$.scaleY,rotation:B$.rotation,style:{x:a.x,y:a.y,align:a.align,verticalAlign:a.verticalAlign,width:a.width,height:a.height,fontSize:a.fontSize},cursor:r.cursor,attachedPos:o.position,attachedRot:o.rotation}})},e.prototype.addLabelsOfSeries=function(e){var t=this;this._chartViewList.push(e);var n=e.__model,r=n.get(`labelLayout`);(B(r)||ws(r).length)&&e.group.traverse(function(e){if(e.ignore)return!0;var i=e.getTextContent(),a=Jz(e);i&&!i.disableLabelLayout&&t._addLabel(a.dataIndex,a.dataType,n,i,r)})},e.prototype.updateLayoutConfig=function(e){var t=e.getWidth(),n=e.getHeight();function r(e,t){return function(){ES(e,t)}}for(var i=0;i<this._labelList.length;i++){var a=this._labelList[i],o=a.label,s=o.__hostTarget,c=a.defaultAttr,l=void 0;l=B(a.layoutOptionOrCb)?a.layoutOptionOrCb(Lj(a,s)):a.layoutOptionOrCb,l||={},a.layoutOption=l;var u=Math.PI/180;s&&s.setTextConfig({local:!1,position:l.x!=null||l.y!=null?null:c.attachedPos,rotation:l.rotate==null?c.attachedRot:l.rotate*u,offset:[l.dx||0,l.dy||0]});var d=!1;if(l.x==null?(o.x=c.x,o.setStyle(`x`,c.style.x)):(o.x=Y(l.x,t),o.setStyle(`x`,0),d=!0),l.y==null?(o.y=c.y,o.setStyle(`y`,c.style.y)):(o.y=Y(l.y,n),o.setStyle(`y`,0),d=!0),l.labelLinePoints){var f=s.getTextGuideLine();f&&(f.setShape({points:l.labelLinePoints}),d=!1)}var p=V$(o);p.needsUpdateLabelLine=d,o.rotation=l.rotate==null?c.rotation:l.rotate*u,o.scaleX=c.scaleX,o.scaleY=c.scaleY;for(var m=0;m<z$.length;m++){var h=z$[m];o.setStyle(h,l[h]==null?c.style[h]:l[h])}if(l.draggable){if(o.draggable=!0,o.cursor=`move`,s){var g=a.seriesModel;a.dataIndex!=null&&(g=a.seriesModel.getData(a.dataType).getItemModel(a.dataIndex)),o.on(`drag`,r(s,g.getModel(`labelLine`)))}}else o.off(`drag`),o.cursor=c.cursor}},e.prototype.layout=function(e){var t=e.getWidth(),n=e.getHeight(),r=[];L(this._labelList,function(e){e.defaultAttr.ignore||r.push(Ib({},e))});var i=Ss(r,function(e){return e.layoutOption.moveOverlap===`shiftX`}),a=Ss(r,function(e){return e.layoutOption.moveOverlap===`shiftY`});Rb(i,0,0,t),Rb(a,1,0,n);var o=Ss(r,function(e){return e.layoutOption.hideOverlap});zb(o),Bb(o)},e.prototype.processLabelsOverall=function(){var e=this;L(this._chartViewList,function(t){var n=t.__model,r=t.ignoreLabelLineUpdate,i=n.isAnimationEnabled();t.group.traverse(function(t){if(t.ignore&&!t.forceLabelAnimation)return!0;var a=!r,o=t.getTextContent();!a&&o&&(a=V$(o).needsUpdateLabelLine),a&&e._updateLabelLine(t,n),i&&e._animateLabels(t,n)})})},e.prototype._updateLabelLine=function(e,t){var n=e.getTextContent(),r=Jz(e),i=r.dataIndex;if(n&&i!=null){var a=t.getData(r.dataType),o=a.getItemModel(i),s={},c=a.getItemVisual(i,`style`);c&&(s.stroke=c[a.getVisual(`drawType`)]);var l=o.getModel(`labelLine`);jS(e,MS(o),s),ES(e,l)}},e.prototype._animateLabels=function(e,t){var n=e.getTextContent(),r=e.getTextGuideLine();if(n&&(e.forceLabelAnimation||!n.ignore&&!n.invisible&&!e.disableLabelAnimation&&!Jp(e))){var i=V$(n),a=i.oldLayout,o=Jz(e),s=o.dataIndex,c={x:n.x,y:n.y,rotation:n.rotation},l=t.getData(o.dataType);if(a){n.attr(a);var u=e.prevStates;u&&(_s(u,`select`)>=0&&n.attr(i.oldLayoutSelect),_s(u,`emphasis`)>=0&&n.attr(i.oldLayoutEmphasis)),Kp(n,c,t,s)}else if(n.attr(c),!VV(n).valueAnimation){var d=U(n.style.opacity,1);n.style.opacity=0,qp(n,{style:{opacity:d}},t,s)}if(i.oldLayout=c,n.states.select){var f=i.oldLayoutSelect={};Rj(f,c,U$),Rj(f,n.states.select,U$)}if(n.states.emphasis){var p=i.oldLayoutEmphasis={};Rj(p,c,U$),Rj(p,n.states.emphasis,U$)}Jm(n,s,l,t,t)}if(r&&!r.ignore&&!r.invisible){var i=H$(r),a=i.oldLayout,m={points:r.shape.points};a?(r.attr({shape:a}),Kp(r,{shape:m},t)):(r.setShape(m),r.style.strokePercent=0,qp(r,{style:{strokePercent:1}},t)),i.oldLayout=m}},e}(),G$=af(),K$=function(){function e(t,n){Av(this,e.decoratedMethods),this._outOfBrk=Iv(null,n);var r=this._linear=Iv(null,n);jv(this,r),this.breaks=t&&t.breaks||[]}return e.prototype.hasBreaks=function(){return!!this.breaks.length},e.prototype.calcNiceTickMultiple=function(e,t){for(var n=0;n<this.breaks.length;n++){var r=this.breaks[n];if(r.vmin<e&&e<r.vmax)return t(e,r.vmax)}return 0},e.decoratedMethods={needTransform:function(){return!this.breaks.length},getExtent:function(){return this._outOfBrk.getExtent()},getExtentUnsafe:function(e,t){return t==null||t===2?this._outOfBrk.getExtentUnsafe(e,null):this._linear.getExtentUnsafe(e,null)},setExtent:function(e,t){this.setExtent2(0,e,t)},setExtent2:function(e,t,n){xf(t,n)&&(e===0&&Vj(this,[t,n]),this._outOfBrk.setExtent2(e,t,n),this._linear.setExtent2(e,this.transformIn(t,null),this.transformIn(n,null)))},normalize:function(e){return this._linear.normalize(this.transformIn(e,null))},scale:function(e){return this.transformOut(this._linear.scale(e),null)},contain:function(e){return this._outOfBrk.contain(e)},transformIn:function(e,t){if(t&&t.depth===2)return e;for(var n=q$,r=J$,i=!0,a=0;a<this.breaks.length;a++){var o=this.breaks[a];if(e<=o.vmax){e>o.vmin?n+=o.vmin-r+(e-o.vmin)/(o.vmax-o.vmin)*o.gapReal:n+=e-r,r=o.vmax,i=!1;break}n+=o.vmin-r+o.gapReal,r=o.vmax}return i&&(n+=e-r),n},transformOut:function(e,t){if(t&&t.depth===2)return e;for(var n=q$,r=J$,i=!0,a=0,o=0;o<this.breaks.length;o++){var s=this.breaks[o],c=n+s.vmin-r,l=c+s.gapReal;if(e<=l){a=e>c?s.vmin+(e-c)/(l-c)*(s.vmax-s.vmin):r+e-n,r=s.vmax,i=!1;break}n=l,r=s.vmax}return i&&(a=r+e-n),a}},e}(),q$=0,J$=0,Y$={vmin:`start`,vmax:`end`},X$=af(),Z$=Math.sin,Q$=Math.cos,$$=Math.PI,e1=Math.PI*2,t1=180/$$,n1=function(){function e(){}return e.prototype.reset=function(e){this._start=!0,this._d=[],this._str=``,this._p=10**(e||4)},e.prototype.moveTo=function(e,t){this._add(`M`,e,t)},e.prototype.lineTo=function(e,t){this._add(`L`,e,t)},e.prototype.bezierCurveTo=function(e,t,n,r,i,a){this._add(`C`,e,t,n,r,i,a)},e.prototype.quadraticCurveTo=function(e,t,n,r){this._add(`Q`,e,t,n,r)},e.prototype.arc=function(e,t,n,r,i,a){this.ellipse(e,t,n,n,0,r,i,a)},e.prototype.ellipse=function(e,t,n,r,i,a,o,s){var c=o-a,l=!s,u=Math.abs(c),d=Jl(u-e1)||(l?c>=e1:-c>=e1),f=c>0?c%e1:c%e1+e1,p=!1;p=d?!0:!Jl(u)&&f>=$$==!!l;var m=e+n*Q$(a),h=t+r*Z$(a);this._start&&this._add(`M`,m,h);var g=Math.round(i*t1);if(d){var _=1/this._p,v=(l?1:-1)*(e1-_);this._add(`A`,n,r,g,1,+l,e+n*Q$(a+v),t+r*Z$(a+v)),_>.01&&this._add(`A`,n,r,g,0,+l,m,h)}else{var y=e+n*Q$(o),b=t+r*Z$(o);this._add(`A`,n,r,g,+p,+l,y,b)}},e.prototype.rect=function(e,t,n,r){this._add(`M`,e,t),this._add(`l`,n,0),this._add(`l`,0,r),this._add(`l`,-n,0),this._add(`Z`)},e.prototype.closePath=function(){this._d.length>0&&this._add(`Z`)},e.prototype._add=function(e,t,n,r,i,a,o,s,c){for(var l=[],u=this._p,d=1;d<arguments.length;d++){var f=arguments[d];if(isNaN(f)){this._invalid=!0;return}l.push(Math.round(f*u)/u)}this._d.push(e+l.join(` `)),this._start=e===`Z`},e.prototype.generateStr=function(){this._str=this._invalid?``:this._d.join(``),this._d=[]},e.prototype.getStr=function(){return this._str},e}(),r1=`none`,i1=Math.round,a1=[`lineCap`,`miterLimit`,`lineJoin`],o1=R(a1,function(e){return`stroke-`+e.toLowerCase()}),s1=`http://www.w3.org/2000/svg`,c1=`http://www.w3.org/1999/xlink`,l1=`http://www.w3.org/2000/xmlns/`,u1=`http://www.w3.org/XML/1998/namespace`,d1=`ecmeta_`,f1=0,p1={cubicIn:`0.32,0,0.67,0`,cubicOut:`0.33,1,0.68,1`,cubicInOut:`0.65,0,0.35,1`,quadraticIn:`0.11,0,0.5,0`,quadraticOut:`0.5,1,0.89,1`,quadraticInOut:`0.45,0,0.55,1`,quarticIn:`0.5,0,0.75,0`,quarticOut:`0.25,1,0.5,1`,quarticInOut:`0.76,0,0.24,1`,quinticIn:`0.64,0,0.78,0`,quinticOut:`0.22,1,0.36,1`,quinticInOut:`0.83,0,0.17,1`,sinusoidalIn:`0.12,0,0.39,0`,sinusoidalOut:`0.61,1,0.88,1`,sinusoidalInOut:`0.37,0,0.63,1`,exponentialIn:`0.7,0,0.84,0`,exponentialOut:`0.16,1,0.3,1`,exponentialInOut:`0.87,0,0.13,1`,circularIn:`0.55,0,1,0.45`,circularOut:`0,0.55,0.45,1`,circularInOut:`0.85,0,0.15,1`},m1=`transform-origin`,h1={fill:`fill`,opacity:`opacity`,lineWidth:`stroke-width`,lineDashOffset:`stroke-dashoffset`},g1=Math.round,_1={circle:[LM([`cx`,`cy`,`r`])],polyline:[FM,IM],polygon:[FM,IM]},v1=58,y1=120,b1=fM(``,``),x1=0,S1=function(){function e(e,t,n){if(this.type=`svg`,this.configLayer=dN(`configLayer`),this.storage=t,this._opts=n=I({},n),this.root=e,this._id=`zr`+x1++,this._oldVNode=vM(n.width,n.height),e&&!n.ssr){var r=this._viewport=document.createElement(`div`);r.style.cssText=`position:relative;overflow:hidden`;var i=this._svgDom=this._oldVNode.elm=dM(`svg`);sN(null,this._oldVNode),r.appendChild(i),e.appendChild(r)}this.resize(n.width,n.height)}return e.prototype.getType=function(){return this.type},e.prototype.getViewportRoot=function(){return this._viewport},e.prototype.getViewportRootOffset=function(){var e=this.getViewportRoot();if(e)return{offsetLeft:e.offsetLeft||0,offsetTop:e.offsetTop||0}},e.prototype.getSvgDom=function(){return this._svgDom},e.prototype.refresh=function(){if(this.root){var e=this.renderToVNode({willUpdate:!0});e.attrs.style=`position:absolute;left:0;top:0;user-select:none`,uN(this._oldVNode,e),this._oldVNode=e}},e.prototype.renderOneToVNode=function(e){return HM(e,_M(this._id))},e.prototype.renderToVNode=function(e){e||={};var t=this.storage.getDisplayList(!0),n=this._width,r=this._height,i=_M(this._id);i.animation=e.animation,i.willUpdate=e.willUpdate,i.compress=e.compress,i.emphasis=e.emphasis,i.ssr=this._opts.ssr;var a=[],o=this._bgVNode=fN(n,r,this._backgroundColor,i);o&&a.push(o);var s=e.compress?null:this._mainVNode=fM(`g`,`main`,{},[]);this._paintList(t,i,s?s.children:a),s&&a.push(s);var c=R(ws(i.defs),function(e){return i.defs[e]});if(c.length&&a.push(fM(`defs`,`defs`,{},c)),e.animation){var l=gM(i.cssNodes,i.cssAnims,{newline:!0});if(l){var u=fM(`style`,`stl`,{},[],l);a.push(u)}}return vM(n,r,a,e.useViewBox)},e.prototype.renderToString=function(e){return e||={},hM(this.renderToVNode({animation:U(e.cssAnimation,!0),emphasis:U(e.cssEmphasis,!0),willUpdate:!1,compress:!0,useViewBox:U(e.useViewBox,!0)}),{newline:!0})},e.prototype.setBackgroundColor=function(e){this._backgroundColor=e},e.prototype.getSvgRoot=function(){return this._mainVNode&&this._mainVNode.elm},e.prototype._paintList=function(e,t,n){for(var r=e.length,i=[],a=0,o,s,c=0,l=0;l<r;l++){var u=e[l];if(!u.invisible){var d=u.__clipPaths,f=d&&d.length||0,p=s&&s.length||0,m=void 0;for(m=Math.max(f-1,p-1);m>=0&&!(d&&s&&d[m]===s[m]);m--);for(var h=p-1;h>m;h--)a--,o=i[a-1];for(var g=m+1;g<f;g++){var _={};KM(d[g],_,t);var v=fM(`g`,`clip-g-`+c++,_,[]);(o?o.children:n).push(v),i[a++]=v,o=v}s=d;var y=HM(u,t);y&&(o?o.children:n).push(y)}}},e.prototype.resize=function(e,t){var n=this._opts,r=this.root,i=this._viewport;if(e!=null&&(n.width=e),t!=null&&(n.height=t),r&&i&&(i.style.display=`none`,e=jw(r,0,n),t=jw(r,1,n),i.style.display=``),this._width!==e||this._height!==t){if(this._width=e,this._height=t,i){var a=i.style;a.width=e+`px`,a.height=t+`px`}if(Ql(this._backgroundColor))this.refresh();else{var o=this._svgDom;o&&(o.setAttribute(`width`,e),o.setAttribute(`height`,t));var s=this._bgVNode&&this._bgVNode.elm;s&&(s.setAttribute(`width`,e),s.setAttribute(`height`,t))}}},e.prototype.getWidth=function(){return this._width},e.prototype.getHeight=function(){return this._height},e.prototype.dispose=function(){this.root&&(this.root.innerHTML=``),this._svgDom=this._viewport=this.storage=this._oldVNode=this._bgVNode=this._mainVNode=null},e.prototype.clear=function(){this._svgDom&&(this._svgDom.innerHTML=null),this._oldVNode=null},e.prototype.toDataURL=function(e){var t=this.renderToString(),n=`data:image/svg+xml;`;return e?(t=HL(t),t&&n+`base64,`+t):n+`charset=UTF-8,`+encodeURIComponent(t)},e}(),C1=function(e){F(t,e);function t(t,n,r){var i=e.call(this)||this;i.motionBlur=!1,i.lastFrameAlpha=.7,i.dpr=1,i.virtual=!1,i.config={},i.zlevel=0,i.zlevel2=0,i.maxRepaintRectCount=5,i.__dirty=!0,i.__firstTimePaint=!0,i.__prevIdx={startIdx:0,endIdx:0};var a;r||=nR,typeof t==`string`?a=mN(t,n,r):H(t)&&(a=t,t=a.id),i.id=t,i.dom=a;var o=a.style;return o&&(Ks(a),a.onselectstart=function(){return!1},o.padding=`0`,o.margin=`0`,o.borderWidth=`0`),i.painter=n,i.dpr=r,i}return t.prototype.afterBrush=function(){this.__prevIdx=gN(this)},t.prototype.initContext=function(){this.ctx=this.dom.getContext(`2d`),this.ctx.dpr=this.dpr},t.prototype.setUnpainted=function(){this.__firstTimePaint=!0},t.prototype.createBackBuffer=function(){var e=this.dpr;this.domBack=mN(`back-`+this.id,this.painter,e),this.ctxBack=this.domBack.getContext(`2d`),e!==1&&this.ctxBack.scale(e,e)},t.prototype.createRepaintRects=function(e,t,n,r){if(this.__firstTimePaint)return this.__firstTimePaint=!1,null;var i=[],a=this.maxRepaintRectCount,o=!1,s=new J(0,0,0,0);function c(e){if(e.isFinite()&&!e.isZero()){if(i.length===0){var t=new J(0,0,0,0);t.copy(e),i.push(t)}else{for(var n=!1,r=1/0,c=0,l=0;l<i.length;++l){var u=i[l];if(u.intersect(e)){var d=new J(0,0,0,0);d.copy(u),d.union(e),i[l]=d,n=!0;break}if(o){s.copy(e),s.union(u);var f=e.width*e.height,p=u.width*u.height,m=s.width*s.height-f-p;m<r&&(r=m,c=l)}}if(o&&(i[c].union(e),n=!0),!n){var t=new J(0,0,0,0);t.copy(e),i.push(t)}o||=i.length>=a}}}for(var l=gN(this),u=l.startIdx;u<l.endIdx;++u){var d=e[u];if(d){var f=d.shouldBePainted(n,r,!0,!0),p=d.__isRendered&&(d.__dirty&1||!f)?d.getPrevPaintRect():null;p&&c(p);var m=f&&(d.__dirty&1||!d.__isRendered)?d.getPaintRect():null;m&&c(m)}}for(var h=this.__prevIdx,u=h.startIdx;u<h.endIdx;++u){var d=t[u],f=d&&d.shouldBePainted(n,r,!0,!0);if(d&&(!f||!d.__zr)&&d.__isRendered){var p=d.getPrevPaintRect();p&&c(p)}}var g;do{g=!1;for(var u=0;u<i.length;)if(i[u].isZero())i.splice(u,1);else{for(var _=u+1;_<i.length;)i[u].intersect(i[_])?(g=!0,i[u].union(i[_]),i.splice(_,1)):_++;u++}}while(g);return this._paintRects=i,i},t.prototype.debugGetPaintRects=function(){return(this._paintRects||[]).slice()},t.prototype.resize=function(e,t){var n=this.dpr,r=this.dom,i=r.style,a=this.domBack;i&&(i.width=e+`px`,i.height=t+`px`),r.width=e*n,r.height=t*n,a&&(a.width=e*n,a.height=t*n,n!==1&&this.ctxBack.scale(n,n))},t.prototype.clear=function(e,t,n){var r=this.dom,i=this.ctx,a=r.width,o=r.height;t||=this.clearColor;var s=this.motionBlur&&!e,c=this.lastFrameAlpha,l=this.dpr,u=this;s&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation=`copy`,this.ctxBack.drawImage(r,0,0,a/l,o/l));var d=this.domBack;function f(e,n,r,a){if(i.clearRect(e,n,r,a),t&&t!==`transparent`){var o=void 0;Ms(t)?(o=(t.global||t.__width===r&&t.__height===a)&&t.__canvasGradient||Ow(i,t,{x:0,y:0,width:r,height:a}),t.__canvasGradient=o,t.__width=r,t.__height=a):Ns(t)&&(t.scaleX=t.scaleX||l,t.scaleY=t.scaleY||l,o=zw(i,t,{dirty:function(){u.setUnpainted(),u.painter.refresh()}})),i.save(),i.fillStyle=o||t,i.fillRect(e,n,r,a),i.restore()}s&&(i.save(),i.globalAlpha=c,i.drawImage(d,e,n,r,a),i.restore())}!n||s?f(0,0,a,o):n.length&&L(n,function(e){f(e.x*l,e.y*l,e.width*l,e.height*l)})},t}(eR),w1=1e5,T1=314159,E1=void 0,D1=1,O1=2,k1=1,A1=2,j1=4,M1=k1|j1,N1=function(){function e(e,t,n,r){this.type=`canvas`,this._prevDisplayList=[],this._layerConfig={},this._needsManuallyCompositing=!1,this.type=`canvas`,this._i={layerStack:[],layers:[]};var i=!e.nodeName||e.nodeName.toUpperCase()===`CANVAS`;if(this._opts=n=I({},n||{}),this.dpr=n.devicePixelRatio||nR,this._singleCanvas=i,this.root=e,e.style&&(Ks(e),e.innerHTML=``),this.storage=t,this._prevDisplayList=[],i){var a=e,o=a.width,s=a.height;n.width!=null&&(o=n.width),n.height!=null&&(s=n.height),this.dpr=n.devicePixelRatio||1,a.width=o*this.dpr,a.height=s*this.dpr,this._width=o,this._height=s;var c=yN(a,this,T1,0);c.initContext(),this._insertLayer(c,T1,0,!0),this._domRoot=e}else{this._width=jw(e,0,n),this._height=jw(e,1,n);var l=this._domRoot=vN(this._width,this._height);e.appendChild(l)}}return e.prototype.getType=function(){return`canvas`},e.prototype.isSingleCanvas=function(){return this._singleCanvas},e.prototype.getViewportRoot=function(){return this._domRoot},e.prototype.getViewportRootOffset=function(){var e=this.getViewportRoot();if(e)return{offsetLeft:e.offsetLeft||0,offsetTop:e.offsetTop||0}},e.prototype.refresh=function(e){var t=e&&!H(e)?{paintAll:!!e}:e||{},n=U(t.refresh,!0),r=U(t.refreshHover,!1);if(r&&(this._hoverLayerDirty=O1),!n)return r&&this._paintHoverList(this.storage.getDisplayList(!1)),this;var i=this.storage.getDisplayList(!0);this._updateLayerStatus(i,t.paintAll),this._redrawId=Math.random();var a=this._prevDisplayList;this._paintList(i,a,this._redrawId);var o=this._backgroundColor;return TN(this._i,function(e,t,n,r){e.refresh&&e.refresh(r===0?o:null)},A1),this._opts.useDirtyRect&&(this._prevDisplayList=i.slice()),this},e.prototype._paintHoverList=function(e){var t=this._i.hoverlayer,n=this._hoverLayerDirty;if(this._hoverLayerDirty=E1,n!==E1&&(!t&&n===O1&&(t=this._i.hoverlayer=this._ensureLayer(w1)),t)){t.clear();for(var r={inHover:!0,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{}},i,a=0,o=e.length;a<o;a++){var s=e[a];if(s.__inHover){i||(i=t.ctx,i.save());var c=s.__hoverStyle,l=void 0;c&&(l=s.style,s.style=c),Qw(i,s,r),c&&(s.style=l)}}i&&($w(i,r),i.restore())}},e.prototype.getHoverLayer=function(){return this._ensureLayer(w1)},e.prototype.paintOne=function(e,t){Zw(e,t)},e.prototype._paintList=function(e,t,n){if(this._redrawId===n){var r=this._doPaintList(e,t);if(this._needsManuallyCompositing&&this._compositeManually(),r)TN(this._i,function(e){e.afterBrush&&e.afterBrush()},M1),this._paintHoverList(e);else{var i=this;YK(function(){i._paintList(e,t,n)})}}},e.prototype._compositeManually=function(){var e=this._ensureLayer(T1).ctx,t=this._domRoot.width,n=this._domRoot.height;e.clearRect(0,0,t,n),TN(this._i,function(r){r.virtual&&e.drawImage(r.dom,0,0,t,n)},k1)},e.prototype._doPaintList=function(e,t){var n=this,r=!0;return TN(this._i,function(i){var a=!1;if(CN(i,function(e){(e.drawIdx<e.endIdx||e.notClearIdx>=0)&&(a=!0)}),a||i.__dirty){var o=n._opts.useDirtyRect&&!hN(i)?i.createRepaintRects(e,t,n._width,n._height):null,s=n._i.layerStack[0],c=!0;if(i.__dirty){c=!1,i.__dirty=!1;var l=i.zlevel===s.zl&&i.zlevel2===s.zl2?n._backgroundColor:null;i.clear(!1,l,o)}CN(i,function(t){var a=n._paintPerCursor(i,t,e,o,c);r&&=a})}},M1),SI.wxa&&TN(this._i,function(e){e&&e.ctx&&e.ctx.draw&&e.ctx.draw()}),r},e.prototype._paintPerCursor=function(e,t,n,r,i){var a=e.ctx;if(r){if(!r.length)t.drawIdx=t.endIdx;else for(var o=this.dpr,s=0;s<r.length;++s){var c=r[s];a.save(),a.beginPath(),a.rect(c.x*o,c.y*o,c.width*o,c.height*o),a.clip(),this._paintPerCursorInRect(e,t,n,c,i),a.restore()}}else a.save(),this._paintPerCursorInRect(e,t,n,null,i),a.restore();return t.drawIdx>=t.endIdx},e.prototype._paintPerCursorInRect=function(e,t,n,r,i){for(var a={inHover:!1,allClipped:!1,prevEl:null,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{contentRetained:i}},o=e.ctx,s=hN(e),c=s&&nI.getTime(),l=t.drawIdx,u=t.notClearIdx,d=u>=0?Math.min(u,l):l;d<t.endIdx;d++){var f=n[d];if(!(d<l&&!f.notClear)){if(f.__inHover&&(this._hoverLayerDirty=O1),r!=null){var p=f.getPaintRect();p&&p.intersect(r)&&(Qw(o,f,a),f.setPrevPaintRect(p))}else Qw(o,f,a);if(s&&nI.getTime()-c>15){d++;break}}}$w(o,a),t.drawIdx=Math.max(d,l)},e.prototype.getLayer=function(e,t){return this._ensureLayer(e,0,t)},e.prototype._ensureLayer=function(e,t,n){t||=0;var r=this._singleCanvas;r&&!this._needsManuallyCompositing&&(e=T1,t=0);var i=wN(this._i,e)[t];return i||(i=yN(`zr_`+e+`.`+t,this,e,t),this._layerConfig[e]&&ms(i,this._layerConfig[e],!0),(n||r&&e!==T1)&&(i.virtual=!0),this._insertLayer(i,e,t,!1),i.initContext()),i},e.prototype.insertLayer=function(e,t){this._insertLayer(t,e,0,!1)},e.prototype._insertLayer=function(e,t,n,r){var i=this._i,a=i.layers,o=i.layerStack,s=this._domRoot,c=null;if(!(a[t]&&a[t][n])&&_N(e)){for(var l=o.length,u=0;u<l&&(o[u].zl<t||o[u].zl===t&&o[u].zl2<n);)u++;if(u>0&&(c=wN(i,o[u-1].zl)[o[u-1].zl2]),o.splice(u,0,{zl:t,zl2:n}),wN(i,t)[n]=e,!r&&!e.virtual){if(c){var d=c.dom;d.nextSibling?s.insertBefore(e.dom,d.nextSibling):s.appendChild(e.dom)}else s.firstChild?s.insertBefore(e.dom,s.firstChild):s.appendChild(e.dom)}e.painter||=this}},e.prototype.eachLayer=function(e,t){return TN(this._i,function(n,r){e.call(t,n,r)})},e.prototype.eachBuiltinLayer=function(e,t){return TN(this._i,function(n,r){e.call(t,n,r)},k1)},e.prototype.eachOtherLayer=function(e,t){return TN(this._i,function(n,r){e.call(t,n,r)},A1)},e.prototype.getLayers=function(){var e={};return TN(this._i,function(t,n,r){e[t.id]=t}),e},e.prototype._updateLayerStatus=function(e,t){var n=this;if(n._singleCanvas)for(var r=1;r<e.length;r++){var i=e[r];if(i.zlevel!==e[r-1].zlevel||i.incremental){n._needsManuallyCompositing=!0;break}}TN(n._i,function(e){e.__dirty=!1,CN(e,function(e){e.used=!1,e.endIdxNew=0,e.notClearIdx=-1})},M1);for(var a,o=null,s=null,c=!1,l=0,u=e.length;l<u;l++){var i=e[l],d=i.zlevel,f=i.incremental,p=void 0;if(a!==d&&(a=d,c=!1),f?(c=!0,p=1):p=c?2:0,(!o||d!==o.zlevel||p!==o.zlevel2)&&(o=n._ensureLayer(d,p),s=null,!o.__builtin__))fs(`ZLevel `+d+` has been used by unknown layer `+o.id);else{if((!s||f!==s.key)&&(s=SN(o,f),!s.used)){if(s.used=!0,!t&&s.first===i.id){var m=l-s.startIdx;s.startIdx=l,s.drawIdx+=m,s.endIdx+=m}else o.__dirty=!0,s.first=i.id,s.startIdx=s.drawIdx=l,s.endIdx=l+1}s.endIdxNew=l+1,i.__dirty&1&&!i.__inHover&&((!f||!i.notClear&&l<s.drawIdx)&&(o.__dirty=!0),f&&i.notClear&&s.notClearIdx<0&&(s.notClearIdx=l))}}TN(n._i,function(t){for(var r=t.__cursorStack,i=t.__cursors,a=r.length-1;a>=0;a--){var o=i.get(r[a]);if(!o.used)t.__dirty=!0,i.removeKey(r[a]),r.splice(a,1);else{var s=o.endIdxNew;(hN(t)?s<o.drawIdx:s!==o.endIdx||!s||e[s-1].id!==o.last)&&(t.__dirty=!0),o.endIdx=o.endIdxNew,o.last=s?e[s-1].id:NaN}}t.__dirty&&(CN(t,function(e){e.drawIdx=e.startIdx}),n._hoverLayerDirty===E1&&(n._hoverLayerDirty=D1))},M1)},e.prototype.clear=function(){return TN(this._i,function(e){e.clear(),bN(e)},k1),this},e.prototype.setBackgroundColor=function(e){this._backgroundColor=e,TN(this._i,function(e){e.setUnpainted()})},e.prototype.configLayer=function(e,t){if(t){var n=this._layerConfig;n[e]?ms(n[e],t,!0):n[e]=t,TN(this._i,function(e,t){ms(e,n[t],!0)})}},e.prototype.delLayer=function(e){for(var t=this._i.layerStack,n=this._i.layers,r=t.length-1;r>=0;r--){var i=t[r];if(i.zl===e){var a=n[e][i.zl2];if(a.__builtin__)continue;if(t.splice(r,1),n[e][i.zl2]=void 0,!a.virtual){var o=a.dom.parentNode;o&&o.removeChild(a.dom)}}}},e.prototype.resize=function(e,t){if(this._domRoot.style){var n=this._domRoot;n.style.display=`none`;var r=this._opts,i=this.root;e!=null&&(r.width=e),t!=null&&(r.height=t),e=jw(i,0,r),t=jw(i,1,r),n.style.display=``,(this._width!==e||t!==this._height)&&(n.style.width=e+`px`,n.style.height=t+`px`,TN(this._i,function(n){n.resize(e,t)}),this.refresh({paintAll:!0})),this._width=e,this._height=t}else{if(e==null||t==null)return;this._width=e,this._height=t,this._ensureLayer(T1).resize(e,t)}return this},e.prototype.clearLayer=function(e){L(this._i.layers[e],function(e){e&&!e.__builtin__&&e.clear()})},e.prototype.dispose=function(){this.root.innerHTML=``,this.root=this.storage=this._domRoot=this._i=null},e.prototype.getRenderedCanvas=function(e){if(e||={},this._singleCanvas&&!this._compositeManually)return this._i.layers[T1][0].dom;var t=new C1(`image`,this,e.pixelRatio||this.dpr);t.initContext(),t.clear(!1,e.backgroundColor||this._backgroundColor);var n=t.ctx;if(e.pixelRatio<=this.dpr){this.refresh();var r=t.dom.width,i=t.dom.height;TN(this._i,function(e){e.__builtin__?n.drawImage(e.dom,0,0,r,i):e.renderToCanvas&&(n.save(),e.renderToCanvas(n),n.restore())})}else{for(var a={inHover:!1,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{}},o=this.storage.getDisplayList(!0),s=0,c=o.length;s<c;s++){var l=o[s];Qw(n,l,a)}$w(n,a)}return t.dom},e.prototype.getWidth=function(){return this._width},e.prototype.getHeight=function(){return this._height},e}(),P1=Object.freeze({INR:`₹`,USD:`$`,EUR:`€`,GBP:`£`,JPY:`¥`}),F1=e=>typeof e==`string`&&/^[A-Z]{3}$/.test(e),I1=(e=`INR`)=>P1[e]??`${e} `,L1=`en-IN`,R1=/\{([A-Za-z0-9_]+)\}/g,z1=(e,t)=>Object.getOwnPropertyDescriptor(e,t)!==void 0,B1=new Map,V1=0,H1=new Map,U1=e=>e===1?`one`:`other`,W1=e=>Math.trunc(Math.abs(e))===0||e===1?`one`:`other`,G1={en:U1,ta:U1,te:U1,ml:U1,mr:U1,ne:U1,or:U1,ur:U1,hi:W1,bn:W1,gu:W1,kn:W1,as:W1,pa:W1},K1={aprShortLabel:`Apr`,aprilLabel:`April`,augShortLabel:`Aug`,augustLabel:`August`,decShortLabel:`Dec`,decemberLabel:`December`,emptyValueLabel:`-`,febShortLabel:`Feb`,februaryLabel:`February`,friMinLabel:`Fr`,friShortLabel:`Fri`,fridayLabel:`Friday`,janShortLabel:`Jan`,januaryLabel:`January`,julShortLabel:`Jul`,julyLabel:`July`,junShortLabel:`Jun`,juneLabel:`June`,marShortLabel:`Mar`,marchLabel:`March`,mayLabel:`May`,mayShortLabel:`May`,monMinLabel:`Mo`,monShortLabel:`Mon`,mondayLabel:`Monday`,novShortLabel:`Nov`,novemberLabel:`November`,octShortLabel:`Oct`,octoberLabel:`October`,satMinLabel:`Sa`,satShortLabel:`Sat`,saturdayLabel:`Saturday`,sepShortLabel:`Sep`,septemberLabel:`September`,sunMinLabel:`Su`,sunShortLabel:`Sun`,sundayLabel:`Sunday`,thuMinLabel:`Th`,thuShortLabel:`Thu`,thursdayLabel:`Thursday`,tueMinLabel:`Tu`,tueShortLabel:`Tue`,tuesdayLabel:`Tuesday`,wedMinLabel:`We`,wedShortLabel:`Wed`,wednesdayLabel:`Wednesday`},q1=`Asia/Kolkata`,J1=198e5,Y1=new Map,X1=[`number`,`currency`,`percent`,`compact`,`duration`,`date`],Z1=[`rupees`,`paise`],Q1=[`ms`,`s`,`min`,`h`],$1=[`day`,`month`,`year`,`datetime`,`time`],e0=()=>jN(`formatters`,K1),t0=()=>e0().emptyValueLabel,n0=`−`,r0=[`janShortLabel`,`febShortLabel`,`marShortLabel`,`aprShortLabel`,`mayShortLabel`,`junShortLabel`,`julShortLabel`,`augShortLabel`,`sepShortLabel`,`octShortLabel`,`novShortLabel`,`decShortLabel`],i0={short:[`sunShortLabel`,`monShortLabel`,`tueShortLabel`,`wedShortLabel`,`thuShortLabel`,`friShortLabel`,`satShortLabel`],long:[`sundayLabel`,`mondayLabel`,`tuesdayLabel`,`wednesdayLabel`,`thursdayLabel`,`fridayLabel`,`saturdayLabel`],min:[`sunMinLabel`,`monMinLabel`,`tueMinLabel`,`wedMinLabel`,`thuMinLabel`,`friMinLabel`,`satMinLabel`]},a0=(e,t)=>e0()[kN(e[t],`no date name at index ${t}`)],o0=e=>a0(r0,e),s0=(e,t)=>kN(e[t],`no compact unit at index ${t}`),c0=[[1e7,`Cr`],[1e5,`L`],[1e3,`K`]],l0=[[1e9,`B`],[1e6,`M`],[1e3,`K`]],u0=e=>!e||e===`INR`?`en-IN`:`en-US`,d0=(e,t)=>typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=20?e:t,f0=new Map,p0=(e,t=`en-IN`)=>{let n=`${t}:${e}`,r=f0.get(n);return r||(r=new Intl.NumberFormat(t,{minimumFractionDigits:0,maximumFractionDigits:e}),f0.set(n,r)),r},m0=new Map,h0=(e,t=`en-IN`)=>{let n=`${t}:${e}`,r=m0.get(n);return r||(r=new Intl.NumberFormat(t,{minimumFractionDigits:e,maximumFractionDigits:e}),m0.set(n,r)),r},g0=e=>typeof e==`number`&&Number.isFinite(e),_0=e=>e<0&&!Object.is(Math.abs(e),0)?n0:``,v0=(e,t)=>t===`paise`?Number(VN(e)):e,y0=2,b0=(e,t,n)=>{let r=Math.min(t,y0),i=10n**BigInt(y0-r),a=(BigInt(VN(e).replace(`.`,``))+i/2n)/i,o=10n**BigInt(r),s=h0(0,n).format(a/o);return t===0?s:`${s}.${(a%o).toString().padStart(r,`0`)}${`0`.repeat(t-r)}`},x0=e=>e>0&&e<.1?Math.min(20,1-Math.floor(Math.log10(e))):2,S0={ms:1,s:1e3,min:6e4,h:36e5},C0={aboveLabel:`Above`,areaChartLabel:`Area chart`,arrowKeysText:`{title}: use the arrow keys to read the values`,bandLabel:`Band`,barChartLabel:`Bar chart`,belowLabel:`Below`,bubbleChartLabel:`Bubble chart`,calendarHeatmapLabel:`Calendar heatmap`,calendarRangeText:`, from {first} to {last}`,calendarSummaryTextOne:`Calendar heatmap of {label}, {n} day.`,calendarSummaryTextOther:`Calendar heatmap of {label}, {n} days{range}.`,categoryLabel:`Category`,centerLabel:`Total`,changeLabel:`Change`,chartLabel:`chart`,columnChartLabel:`Column chart`,columnFallbackLabel:`column`,columnXLabel:`X`,constantSpanText:`{label} is {lo}.`,currencyFormatText:`This chart's currency format needs a currency code, such as "INR", in its currency field.`,dataSuffixLabel:`data`,dateLabel:`Date`,donutChartLabel:`Donut chart`,donutLargestText:`{top} is the largest, at {share}.`,donutSummaryTextOne:`Donut chart of {label} in {rows} part, {total} in all.`,donutSummaryTextOther:`Donut chart of {label} in {rows} parts, {total} in all.`,emptyText:`No data to show for this chart.`,errorText:`This chart couldn't load. Try again in a moment.`,everySeriesHiddenText:`Every series is hidden.`,firstStageLabel:`first stage`,fromLabel:`From`,funnelChartLabel:`Funnel chart`,funnelPreviousStepText:`{share} of previous step`,funnelStartText:`{first} is {firstValue} and {last} is {lastValue}, {share} of the start.`,funnelSummaryText:`Funnel chart of {label} in {n} stages.`,gaugeBandText:`, in the {band} band`,gaugeLabel:`Gauge`,gaugeSummaryText:`{type}: {label} is {value} on a scale from {min} to {max}{band}.`,groupLabel:`Group`,groupsTextOne:` in {count} group: {groups}`,groupsTextOther:` in {count} groups: {groups}`,heatmapLabel:`Heatmap`,heatmapSummaryText:`Heatmap of {label} by {group} and {x}, {n} cells.`,highestAtLowestAtText:`Highest is {highValue} at {highGroup}, {high}; lowest is {lowValue} at {lowGroup}, {low}.`,highestLowestText:`Highest is {maxValue} on {max}; lowest is {minValue} on {min}.`,itemLabel:`Item`,largestFallText:`The largest fall is {xText}, {signed}.`,largestFlowText:`The largest flow is {xText} to {toText}, {fmtAt}.`,largestRiseText:`The largest rise is {xText}, {signed}.`,latestText:`Latest {latest}`,legendLabel:`Legend`,lessLabel:`Less`,lineChartLabel:`Line chart`,loadingText:`Loading chart`,measureLabel:`Measure`,moreLabel:`More`,ofFirstStepText:`Of {first}`,ofPreviousStepLabel:`Of previous step`,openingShareText:`{share} of opening`,opensAtClosesAtText:`It opens at {opening} and closes at {closing}.`,otherLabel:`Other`,pointsSummaryTextOne:`{n} point, {first}.`,pointsSummaryTextOther:`{n} points, from {first} to {last}.`,rangeSpanText:`{label} runs from {lo} to {hi}.`,rowFallbackLabel:`row`,rowLabel:`Row`,runningTotalLabel:`Running total`,sankeyLabel:`Sankey diagram`,sankeySummaryText:`Sankey diagram of {label}: {n} flows between {nodes} places.`,scaleLabel:`Scale`,scaleRangeText:`{min} to {max}`,scatterPlotLabel:`Scatter plot`,scatterSummaryText:`{type} of {label} against {xLabel}, {count} points{groups}.`,shareLabel:`Share`,shareOfAllLabel:`Share of all`,shareOfGroupLabel:`Share of group`,shareOfParentText:`Share of {parent}`,shareOfStepText:`{share} of {first}`,sharedAxisText:`, sharing one x axis`,showingFirstRowsDownloadText:`Showing the first {rows} of {total} rows. Download the CSV for all of them.`,smallMultiplesLabel:`Small multiples`,soFarText:`so far`,stackedPercentText:`, stacked to 100%`,stackedText:`, stacked`,stageLabel:`Stage`,stepLabel:`Step`,summaryText:`{type} of {series}{stacked}{sharedAxis}.`,targetGapText:`{direction} {label} by {gap}`,targetLabel:`target`,toLabel:`To`,tooManyGroupsText:`This chart has more groups than it can show clearly.`,tooManySeriesText:`This chart has more series than it can show clearly.`,totalText:`Total {total}`,treemapEmptyText:`Treemap of {label}: no items.`,treemapLabel:`Treemap`,treemapLargestGroupText:`{name} is the largest group, at {share}.`,treemapSummaryText:`Treemap of {label}: {n} items in {totals} groups, {total} in all.`,trendLabel:`Trend`,untitledLabel:`Chart`,waterfallLabel:`Waterfall chart`,waterfallSummaryText:`Waterfall chart of {label}.`},w0={applyLabel:`Apply`,dayCountOne:`1 day`,dayCountOther:`{count} days`,financialYearText:`FY {startYear}-{endYear}`,label:`Period`,nextMonthLabel:`Next month`,previousMonthLabel:`Previous month`,quarterPrefixText:`Q`,shortDaySuffixText:`d`,startEndPlaceholder:`Start to End`},Q=()=>jN(`chart`,C0),T0=[`line`,`area`,`column`,`bar`,`donut`,`heatmap`,`calendar`,`funnel`,`gauge`,`waterfall`,`treemap`,`sankey`,`scatter`,`bubble`,`multiples`],E0=[`none`,`stacked`,`percent`],D0=[`category`,`time`,`value`],O0=[`auto`,`svg`,`canvas`],k0=[`ready`,`loading`,`empty`,`error`],A0=[`chart`,`table`],j0=[`chart-1`,`chart-2`,`chart-3`,`chart-4`,`chart-5`,`chart-6`,`chart-7`,`chart-8`],M0={line:`lineChartLabel`,area:`areaChartLabel`,column:`columnChartLabel`,bar:`barChartLabel`,donut:`donutChartLabel`,heatmap:`heatmapLabel`,calendar:`calendarHeatmapLabel`,funnel:`funnelChartLabel`,gauge:`gaugeLabel`,waterfall:`waterfallLabel`,treemap:`treemapLabel`,sankey:`sankeyLabel`,scatter:`scatterPlotLabel`,bubble:`bubbleChartLabel`,multiples:`smallMultiplesLabel`},N0=e=>Q()[M0[e]],P0=[`donut`,`heatmap`,`calendar`,`funnel`,`gauge`,`waterfall`,`treemap`,`sankey`,`scatter`,`bubble`],F0=e=>P0.includes(e),I0=[`area`,`column`,`bar`],L0=[`line`,`area`,`column`,`bar`,`multiples`],R0={line:[`category`,`time`],area:[`category`,`time`],column:[`category`,`time`],bar:[`category`,`time`],multiples:[`category`,`time`],calendar:[`time`],scatter:[`value`],bubble:[`value`]},z0={group:[`heatmap`,`treemap`,`scatter`,`bubble`],to:[`sankey`],size:[`bubble`],trend:[`scatter`,`bubble`],zoom:[`line`,`area`],bands:[`gauge`],centerLabel:[`donut`],sliceValues:[`donut`],valueLabels:[`line`,`column`,`bar`],incompleteLast:[`line`,`area`,`column`,`bar`]},B0={gauge:240,calendar:200,treemap:340,sankey:340},V0=100,H0=72,U0=32,W0=`type.title.description.data.x.series.group.to.size.trend.zoom.bands.stack.y.target.centerLabel.sliceValues.valueLabels.incompleteLast.height.state.emptyText.errorText.loadingText.renderer.timeZone.financialYearStart`.split(`.`),G0=[`key`,`kind`,`format`,`label`,`labelFit`],K0=[`auto`,`all`,`rotate`,`ellipsis`],q0=[`key`,`label`,`format`,`colour`],J0=[`key`,`label`],Y0=[`key`,`label`,`format`],X0=[`upTo`,`label`],Z0=[`label`,`format`,`min`,`max`,`wholeNumbers`],Q0=[`value`,`label`],$0=[`style`,`currency`,`unit`,`decimals`,`pattern`],e2=[...Z1,...Q1],t2=new Set,n2=e=>e.map(e=>`"${e}"`).join(` | `),r2=e=>typeof e==`number`&&Number.isFinite(e),i2=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=12,a2=e=>typeof e==`object`&&!!e&&!Array.isArray(e),o2=(e,t)=>Reflect.get(e,t),s2=e=>e===null||typeof e==`string`||typeof e==`number`,c2=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,s2(t)?t:null])),l2=(e,t)=>e.some(e=>e===t),u2=e=>[...new Set(e)],d2=e=>e.reduce((e,t)=>Number.isNaN(t)?e:Math.min(e,t),1/0),f2=e=>e.reduce((e,t)=>Number.isNaN(t)?e:Math.max(e,t),-1/0),p2=(e,t)=>e.data.map((n,r)=>K(e,t,r)).filter(e=>e!=null),m2=(e,t)=>t?G((e??0)/t,{style:`percent`}):t0(),h2=(e,t)=>t==null?t0():JN(yP(e,t),`gauge band`).label,g2=(e,t,n)=>{if(!t.length)return null;let r=d2(t),i=f2(t);return r===i?MN(Q().constantSpanText,{label:e,lo:G(r,n)}):MN(Q().rangeSpanText,{label:e,lo:G(r,n),hi:G(i,n)})},_2=(e,t)=>{let n=eP(e);return G(K(e,n.key,t),n.format)},v2=864e5,y2={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1},b2=e=>y2[e]??0,x2=[`donut`,`funnel`,`waterfall`,`treemap`,`sankey`,`scatter`,`bubble`],S2=()=>jN(`chart`,C0),_T([Hy,mS,VS,NO,gO,dO,YD,AO,eE,Pk,kA,fj,QA,Yk,Lk,Fj,Dj,PA,sM,zj,pN,EN]),C2=e=>typeof e==`number`,w2=e=>C2(e)?e:null,T2=[`series`,`graphic`,`grid`,`xAxis`,`yAxis`,`title`,`visualMap`,`calendar`,`dataZoom`],E2=e=>String(e).replace(/[{}]/g,e=>e===`{`?`{`:`}`),D2=(e,t)=>{let n=e.filter(e=>typeof e==`number`&&Number.isFinite(e));return[Math.min(...t?[0,...n]:n),Math.max(...t?[0,...n]:n)]},O2=24,k2=4,A2=.6,j2=(e,t)=>String(e).length*t*A2,M2=(e,t)=>{let n=e[t];if(n===void 0)throw Error(`chart palette has no colour at slot ${t}`);return n},N2=[.2126,.7152,.0722],P2=e=>e.map(e=>e/255).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4).reduce((e,t,n)=>e+t*(N2[n]??0),0),F2=(e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05),I2=(e,t)=>({type:`linear`,x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:nF(e,t)},{offset:1,color:nF(e,0)}]}),L2=(e,t)=>e+RN(e,t),R2=e=>[...new Set(e)],z2=(e,t)=>e.data.map((n,r)=>K(e,t,r)),B2=(e,t,n={})=>({type:`category`,data:t,axisLine:{lineStyle:{color:e.axis}},axisTick:{show:!1},axisLabel:{color:e.label,fontSize:12,margin:12,hideOverlap:!0},...n}),V2=(e,t,n={})=>({type:`value`,splitNumber:4,axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:e.grid,type:`solid`,width:1}},axisLabel:{color:e.label,fontSize:12,formatter:t},...n}),H2=6048e5,U2=(e,t)=>{let n=LN(e,t);return`${n.year}-${String(n.month+1).padStart(2,`0`)}-${String(n.day).padStart(2,`0`)}`},W2=e=>e.reduce((e,t)=>Number.isNaN(t)?e:Math.min(t,e),1/0),G2=e=>e.reduce((e,t)=>Number.isNaN(t)?e:Math.max(t,e),-1/0),K2=9,q2=24,J2=4,Y2=72,X2=12,Z2=(e,t)=>Math.floor(t/Math.max(1,e)-J2),Q2=12,$2=44,e4=28,t4=8,n4=32,r4=8,i4=26,a4={donut:lF,heatmap:fF,calendar:mF,funnel:hF,gauge:gF,waterfall:SF,treemap:wF,sankey:EF,scatter:OF,bubble:OF,multiples:kF},o4=`@webority/ui-elements needs a browser DOM; import its types or helpers entry on the server`,typeof HTMLElement>`u`)throw Error(o4);s4=HTMLElement,c4=(e,t)=>Object.getOwnPropertyDescriptor(e,t)!==void 0,l4=()=>jN(`chart`,C0),u4=`wui-chart:select`,d4=`wui-chart:legend-change`,f4=`wui-chart:ready`,p4=[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`,`Escape`],m4=`(prefers-color-scheme: dark)`,h4=`(prefers-reduced-motion: reduce)`,g4=`(forced-colors: active)`,_4=`(prefers-contrast: more)`,v4=`print`,y4=e=>typeof window.matchMedia==`function`?window.matchMedia(e):null,b4=!1,x4=new Map,S4=[...[1,2,3,4,5,6,7,8].map(e=>`--color-chart-${e}`),...[0,1,2,3,4,5,6].map(e=>`--color-chart-seq-${e}`),`--color-chart-neutral`,`--wui-chart-rise`,`--wui-chart-fall`,`--color-chart-grid`,`--color-chart-axis`,`--color-chart-label`,`--color-surface`,`--color-text`,`--color-text-body`,`--color-text-muted`],C4=new Set,w4=null,T4=0,E4=class extends s4{static get observedAttributes(){return[`view`]}constructor(){super(),HF(this,`uid`,void 0),HF(this,`_spec`,void 0),HF(this,`_normal`,void 0),HF(this,`_hidden`,void 0),HF(this,`_focus`,void 0),HF(this,`_awaitingSpec`,!1),HF(this,`_parts`,null),HF(this,`_theme`,null),HF(this,`_width`,null),HF(this,`_visible`,!1),HF(this,`_resizeObserver`,null),HF(this,`_intersection`,null),HF(this,`_engine`,null),HF(this,`_drawn`,!1),HF(this,`_drawnType`,null),HF(this,`_announcedReady`,!1),HF(this,`_legendSignature`,null),HF(this,`_tableSpec`,null),T4+=1,this.uid=`wui-chart-${T4}`,this._spec=null,this._normal=null,this._hidden=new Set,this._focus=null}get spec(){return this._spec}set spec(e){this._spec=e??null,this._normal=null,this._clearFocus(),this._parts&&this._update()}get view(){return this.getAttribute(`view`)===`table`?`table`:`chart`}set view(e){this.setAttribute(`view`,String(e??`chart`))}connectedCallback(){if(c4(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}if(this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._parts&&this._update()})),this._build(),GF(this),this._theme=WF(this),this._width=this.clientWidth,this._resizeObserver=new ResizeObserver(()=>this._resized()),this._resizeObserver.observe(this),typeof IntersectionObserver==`function`){this._visible=!1;let e=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&(e.disconnect(),this._visible=!0,this._update())},{threshold:.05});this._intersection=e,e.observe(this)}else this._visible=!0;this._update()}disconnectedCallback(){KF(this),this._resizeObserver?.disconnect(),this._intersection?.disconnect(),this._engine?.dispose(),this._engine=null,this._drawn=!1,this._parts=null,this.removeAttribute(`data-ready`)}attributeChangedCallback(e,t,n){t!==n&&this._parts&&(YN(`view`,n,A0),this._update())}toCsv(){let{spec:e}=this._normalized();return e?IP(e):``}toPng(){let{spec:e}=this._normalized();return e?NF(e,this._theme??WF(this),this._size(e),{hidden:this._hidden,renderer:uP(e)}):``}exportCsv(e){let t=URL.createObjectURL(new Blob([this.toCsv()],{type:`text/csv;charset=utf-8`}));qF(t,e??`${LP(this._normalized().spec)}.csv`),setTimeout(()=>URL.revokeObjectURL(t),2e3)}exportPng(e){let t=this.toPng();t&&qF(t,e??`${LP(this._normalized().spec)}.png`)}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return ON(`[@webority/ui-elements] <wui-chart> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_normalized(){return this._normal??=$N(this._spec),this._normal}_build(){let e=AN(`div`,{class:`wui-chart-legend`});e.setAttribute(`role`,`group`),e.setAttribute(`aria-label`,l4().legendLabel),e.hidden=!0,e.addEventListener(`click`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-chart-legend-item`):null;t instanceof HTMLElement&&this._toggle(t.dataset.key)});let t=AN(`div`,{class:`wui-chart-surface`});t.tabIndex=0,t.setAttribute(`role`,`group`),t.setAttribute(`aria-roledescription`,l4().chartLabel),t.addEventListener(`keydown`,e=>this._onKey(e)),t.addEventListener(`blur`,()=>this._clearFocus());let n=AN(`div`,{class:`wui-chart-canvas`});n.setAttribute(`aria-hidden`,`true`),t.append(n);let r=AN(`div`,{class:`wui-chart-state`});r.setAttribute(`role`,`status`),r.hidden=!0;let i=AN(`div`,{class:`wui-chart-table-wrap visually-hidden`}),a=AN(`p`,{class:`visually-hidden`});a.id=`${this.uid}-summary`;let o=AN(`div`,{class:`visually-hidden`});o.setAttribute(`aria-live`,`polite`),this.replaceChildren(e,t,r,i,a,o),this.setAttribute(`role`,`figure`),this.setAttribute(`aria-describedby`,a.id),this._parts={legend:e,surface:t,canvas:n,state:r,tableWrap:i,summary:a,live:o},this._legendSignature=null,this._tableSpec=null}_size(e){return{width:this._parts?.surface.clientWidth||this.clientWidth||800,height:e.height}}_update(){if(!this._parts||this._awaitingSpec&&this._spec==null)return;let{spec:e,problem:t}=this._normalized(),n=this._parts,r=e===null?`error`:e.state===`ready`&&(!e.data.length||!nP(e))?`empty`:e.state,i=`${e?.height??320}px`,a=this.view===`table`,o=e!==null&&(r===`ready`||r===`loading`&&this._drawn),s=r===`loading`&&o;if(this.setAttribute(`aria-label`,e?.title||l4().untitledLabel),r===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`),this.setAttribute(`data-state`,r),n.surface.setAttribute(`aria-label`,MN(l4().arrowKeysText,{title:e?.title||l4().untitledLabel})),n.summary.textContent=e?RP(e,this._hidden):``,e){if(!s){let t=new Set(dP(e));for(let e of this._hidden)t.has(e)||this._hidden.delete(e)}this._renderTable(e)}else n.tableWrap.replaceChildren();s||this._renderLegend(e,o&&!a),this._renderState(r,e===null?t:r===`error`?e.errorText:r===`loading`?e.loadingText??l4().loadingText:e.emptyText,i,o);let c=r===`ready`&&!a;s||this.toggleAttribute(`data-ready`,!c);let l=n.surface.hidden&&o&&!a;n.surface.hidden=!o||a,n.surface.style.height=i,n.tableWrap.className=a&&e?`wui-chart-table-wrap`:`wui-chart-table-wrap visually-hidden`,n.tableWrap.style.height=a&&e?i:``,a&&e?(n.tableWrap.tabIndex=0,n.tableWrap.setAttribute(`role`,`region`),n.tableWrap.setAttribute(`aria-label`,`${e.title||l4().untitledLabel} ${l4().dataSuffixLabel}`)):(n.tableWrap.removeAttribute(`tabindex`),n.tableWrap.removeAttribute(`role`),n.tableWrap.removeAttribute(`aria-label`)),l&&this._engine?.resize(),r===`ready`&&!a&&this._visible&&this._draw()}_renderState(e,t,n,r){let i=this._parts?.state;if(!i)return;let a=!r&&e!==`ready`;i.hidden=!a,a?(i.style.height=n,e===`loading`?i.replaceChildren(AN(`div`,{class:`skeleton wui-chart-skeleton`}),AN(`span`,{class:`visually-hidden`},t)):i.replaceChildren(AN(`p`,{class:`wui-chart-state-text`},t))):i.replaceChildren()}_colour(e,t){let n=this._theme;if(!n)return;if(e.type===`donut`)return wP(e,t,n);let r=e.series[t],i=e.type===`line`||e.type===`area`||e.type===`column`||e.type===`bar`;return n.palette[r&&i?kP(r,t):t]}_renderLegend(e,t){let n=this._parts?.legend;if(!n)return;let r=e?dP(e):[],i=!!e&&t&&r.length>=2;if(n.hidden=!i,!e||!i)return;let a=fP(e),o=r.map((t,n)=>this._colour(e,n)),s=JSON.stringify([e.type,r,a,o]);s!==this._legendSignature&&(this._legendSignature=s,n.replaceChildren(...r.map((t,n)=>{let r=AN(`button`,{class:`wui-chart-legend-item`});r.type=`button`,r.dataset.key=t;let i=AN(`span`,{class:e.type===`line`?`wui-chart-legend-swatch wui-chart-legend-swatch-line`:`wui-chart-legend-swatch`}),s=o[n];return s!==void 0&&(i.style.background=s),r.append(i,AN(`span`,{class:`wui-chart-legend-label`},a[n])),r})));for(let e of n.children){if(!(e instanceof HTMLElement))throw Error(`Expected a legend item to be an HTMLElement.`);let t=e.dataset.key;e.setAttribute(`aria-pressed`,String(t===void 0||!this._hidden.has(t)))}}_renderTable(e){if(this._tableSpec===e||!this._parts)return;this._tableSpec=e;let t=NP(e),n=AN(`table`,{class:`wui-chart-table`});n.append(AN(`caption`,{class:`visually-hidden`},t.caption));let r=AN(`tr`);t.head.forEach((e,t)=>{let n=AN(`th`,t?{class:`wui-chart-num`}:null,e);n.scope=`col`,r.append(n)});let i=AN(`thead`);i.append(r),n.append(i);let a=AN(`tbody`);for(let e of t.rows){let t=AN(`tr`),n=AN(`th`,null,e.head);n.scope=`row`,t.append(n,...e.cells.map(e=>AN(`td`,{class:`wui-chart-num`},e))),a.append(t)}n.append(a);let o=[n];t.truncated&&o.push(AN(`p`,{class:`wui-chart-table-note`},MN(l4().showingFirstRowsDownloadText,{rows:t.rows.length,total:t.total}))),this._parts.tableWrap.replaceChildren(...o)}_draw(){let{spec:e}=this._normalized();if(!e||!this._parts||!this._theme)return;let t=uP(e),n=e.type!==this._drawnType;this._engine&&this._engine.renderer!==t&&(this._engine.dispose(),this._engine=null);let r=`${e.height}px`,i=this._parts.canvas.style.height!==r;this._parts.canvas.style.height=r,i&&this._engine?.resize(),this._engine||(this._engine=PF(this._parts.canvas,{renderer:t}),this._engine.onSelect(({seriesIndex:e,dataIndex:t})=>this._select(e,t)),this._engine.onFinished(()=>{this.setAttribute(`data-ready`,``),this._announcedReady||(this._announcedReady=!0,this.dispatchEvent(new CustomEvent(f4,{bubbles:!0,detail:{renderer:t}})))}),n=!0),this._engine.render(e,this._theme,this._size(e),{hidden:this._hidden,renderer:t},{replace:n}),this._drawnType=e.type,this._drawn=!0}_themeChanged(e=!1){if(!this._parts)return;let t=WF(this);JSON.stringify(t)!==JSON.stringify(this._theme)&&(this._theme=t,this._update(),e&&this._engine?.flush())}_resized(){let e=this.clientWidth;e!==this._width&&(this._width=e,this._engine&&this._drawn&&this._parts&&(this._parts.surface.hidden||this._engine.resize(),this._update()))}_toggle(e){let{spec:t}=this._normalized();if(!t||e==null)return;this._hidden.has(e)?this._hidden.delete(e):this._hidden.add(e),this._clearFocus(),this._update();let n=Object.fromEntries(dP(t).map(e=>[e,!this._hidden.has(e)]));this.dispatchEvent(new CustomEvent(d4,{bubbles:!0,detail:{visible:n}}))}_onKey(e){let{spec:t}=this._normalized();if(!t||!this._engine||!this._theme||this.view===`table`||e.altKey||e.ctrlKey||e.metaKey)return;if(IF(e)){if(!this._focus)return;e.preventDefault(),this._select(this._focus.series,this._focus.index);return}if(!p4.includes(e.key)||e.key===`Escape`&&!this._focus)return;e.preventDefault();let n=HP(t,this._focus,RF(e.key,LF(this)),this._hidden);n?(this._focus=n,this._engine.focusPoint(n.series,n.index),this._announce(jP(TP(t,n.index,this._hidden,this._theme)))):this._clearFocus()}_announce(e){let t=this._parts?.live;t&&(t.textContent=e===t.textContent?`${e} `:e)}_clearFocus(){this._focus&&(this._focus=null,this._engine?.clearFocus(),this._parts&&(this._parts.live.textContent=``))}_select(e,t){let{spec:n}=this._normalized();if(!n)return;let r=n.series[F0(n.type)?0:e];if(!r)return;let i=n.data[t]??null;this.dispatchEvent(new CustomEvent(u4,{bubbles:!0,detail:{series:r.key,label:r.label,x:i?.[n.x.key]??null,value:K(n,r.key,t),row:i,index:t}}))}},ls(`wui-chart`,E4)})),O4=null;async function k4(){await Promise.resolve().then(()=>(D4(),cs)),await customElements.whenDefined(`wui-chart`)}async function A4(){return O4??=k4().catch(e=>{throw O4=null,e}),O4}var j4={sub:`wui-chat-sub`,sup:`wui-chat-sup`};function M4(e,t){let n=e.ownerDocument??document;for(let r of t)if(r.kind===`sub`||r.kind===`sup`){let t=n.createElement(r.kind);t.className=j4[r.kind],t.textContent=r.text,e.append(t)}else e.append(n.createTextNode(r.text))}function N4(e,t){e.replaceChildren(),M4(e,vn(String(t??``)))}function P4(e){return yn(String(e??``))}function F4(e){return bn(e)}var I4=8,L4=8,R4={Bar:`column`,Line:`line`,Donut:`donut`};function z4(e,t){return e===`Bar`&&t>4?300:240}function B4(e,t){let n=e.chartType===`Donut`,r=n?e.series.slice(0,1):e.series.slice(0,I4),i=r.map((e,n)=>({key:`s${n}`,label:P4(e.name)||t.chart})),a=Object.fromEntries(i.map(e=>[e.key,null])),o=new Map;r.forEach((e,t)=>{for(let n of e.points){let e=String(n.label),r=o.get(e);r===void 0&&(r={label:P4(e),...a},o.set(e,r)),r[`s${t}`]=n.value}});let s=[...o.values()],c={type:R4[e.chartType],title:P4(e.title)||t.chart,x:{key:`label`,kind:`category`},series:i,data:s,height:z4(e.chartType,s.length)};return e.chartType===`Bar`&&s.length<=L4&&(c.x.labelFit=`all`,c.valueLabels=!0),!n&&e.unit&&(c.y={label:P4(e.unit)}),s.length===0&&(c.state=`empty`,c.emptyText=t.chartEmpty),c}Yo(`wui-chat-part-chart`,class extends Jo{#e=null;#t=0;#n=null;#r=null;#i=null;#a=null;renderPart(e,t,n){let r=JSON.stringify(e);if(r===this.#e)return;this.#e=r,this.#t+=1;let i=this.#t,a=this.ownerDocument??document,o=this.#o(a);if(this.#r?.remove(),this.#r=null,e.title){let t=P(a,`figcaption`,`wui-chat-chart-title`);N4(t,e.title),o.figure.prepend(t),this.#r=t}let s=this.#i;if(s!==null){let t=B4(e,n.labels);Object.assign(s,{spec:t}),this.#s(o,s,t.state!==`empty`,n.labels)}else A4().then(()=>{if(i!==this.#t||!this.isConnected)return;let t=B4(e,n.labels),r=a.createElement(`wui-chart`);Object.assign(r,{spec:t}),this.#i=r,o.body.replaceChildren(r),this.#s(o,r,t.state!==`empty`,n.labels)},()=>{i===this.#t&&this.isConnected&&this.#l(o.body,n.labels)})}disposePart(){this.#t+=1,this.#e=null}#o(e){if(this.#n===null){let t=P(e,`figure`,`wui-chat-chart`),n=P(e,`div`,`wui-chat-chart-body`);t.append(n),this.replaceChildren(t),this.#n={figure:t,body:n}}return this.#n}#s(e,t,n,r){if(!n){this.#a?.remove(),this.#a=null;return}if(!this.#a){let n=P(this.ownerDocument??document,`button`,`btn btn-link btn-sm wui-chat-chart-toggle`);n.type=`button`,n.addEventListener(`click`,()=>this.#c(e,t)),e.figure.append(n),this.#a=n}let i=t.getAttribute(`view`)===`table`;this.#a.setAttribute(`aria-pressed`,String(i)),this.#a.textContent=i?r.chartShowChart:r.chartShowTable}#c(e,t){let n=this.activeTurn,r=t.getAttribute(`view`)!==`table`;t.setAttribute(`view`,r?`table`:`chart`),this.#s(e,t,!0,n.labels)}#l(e,t){let n=P(this.ownerDocument??document,`p`,`wui-chat-chart-error`,t.chartLoadFailed);n.setAttribute(`role`,`status`),e.replaceChildren(n),this.#a?.remove(),this.#a=null}});var V4={Positive:`wui-metric-tone-success`,Caution:`wui-metric-tone-warning`,Negative:`wui-metric-tone-danger`},H4=new Set([`Positive`,`Caution`,`Negative`]),U4=.001;function W4(e,t,n){let r=V4[t.status],i=P(e,`div`,r?`wui-metric ${r}`:`wui-metric`);i.dataset.status=t.status;let a=P(e,`div`,`wui-metric-label`);N4(a,t.label);let o=P(e,`div`,`wui-metric-value`);if(M4(o,t.value!==0&&Math.abs(t.value)<U4?F4(t.value):[{kind:`text`,text:Qi(t.value)}]),t.unit){let n=P(e,`span`,`wui-chat-figure-unit`);N4(n,t.unit),n.prepend(` `),o.append(n)}return H4.has(t.status)&&o.append(P(e,`span`,`visually-hidden`,n.figureStatus(t.status))),i.append(a,o),i}Yo(`wui-chat-part-figures`,class extends Jo{#e=null;renderPart(e,t,n){let r=JSON.stringify(e);if(r===this.#e)return;if(this.#e=r,!e.figures||e.figures.length===0){this.replaceChildren();return}let i=this.ownerDocument??document,a=P(i,`div`,`wui-chat-figures`),o=P(i,`div`,`wui-metric-strip wui-metric-strip-sm wui-chat-figures-strip`);o.setAttribute(`role`,`group`),o.setAttribute(`aria-label`,n.labels.figures);for(let t of e.figures)o.append(W4(i,t,n.labels));a.append(o),this.replaceChildren(a)}}),Yo(`wui-chat-part-file`,class extends Jo{renderPart(e,t,n){let r=n.openAttachment,i=typeof r==`function`,a=document.createElement(i?`button`:`span`);a.className=`wui-chat-file-chip`,i&&(a.setAttribute(`type`,`button`),a.setAttribute(`aria-label`,n.labels.fileOpen(e.fileName)),a.addEventListener(`click`,()=>r(e)));let o=Xo(document,`document-text`,16),s=document.createElement(`span`);s.className=`wui-chat-file-name`,s.textContent=e.fileName;let c=document.createElement(`span`);c.className=`wui-chat-file-size`,c.textContent=sr(e.length),a.append(...[o,s,c].filter(e=>e!==null));let l=document.createElement(`div`);l.className=`wui-chat-file`,l.append(a),this.replaceChildren(l)}});var G4=`--_wui-chat-launcher-block`;function K4(e,t){let n=()=>{let n=t.offsetHeight;n>0&&e.style.setProperty(G4,`${n}px`)};if(n(),typeof ResizeObserver>`u`)return()=>void 0;let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()}var q4=`(prefers-reduced-motion: reduce)`;function J4(e,t){let n=e.style.animation;e.style.animation=`none`;let r=e.getBoundingClientRect();e.style.animation=n,e.style.transformOrigin=`${t.left+t.width/2-r.left}px ${t.top+t.height/2-r.top}px`}function Y4(e,t){let n=typeof window.matchMedia==`function`?window.matchMedia(q4):null,r=new Set,i=()=>e.motion===`Reduced`||t?.motion===!1||n?.matches===!0,a=i();function o(){let e=i();if(e!==a){a=e;for(let e of r)e(a)}}return n?.addEventListener(`change`,o),{get reduced(){return a},subscribe(e){return r.add(e),()=>{r.delete(e)}},destroy(){n?.removeEventListener(`change`,o),r.clear()}}}var X4=`AppButton`,Z4={primary:`btn-primary`,secondary:`btn-soft-primary`,ghost:`btn-ghost-primary`,outline:`btn-outline-primary`,neutral:`btn-soft-neutral`,danger:`btn-danger`};function Q4(e,t){return Object.getOwnPropertyDescriptor(e,t)!==void 0}function $(e,t,n){let r=document.createElement(e);if(t&&(r.className=t),n)for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return r}function $4(e,t=16){return To(e,{size:t})??$(`span`,`d-inline-flex`)}function e3(e=`primary`,t=`md`){if(!Q4(Z4,e))throw Error(`Unknown button variant "${e}". Use one of ${Object.keys(Z4).join(`, `)}.`);return`btn ${Z4[e]}${t===`sm`?` btn-sm`:``}`}function t3(e,t,n,r){let i=$(`button`,`${e3(e,`sm`)} wui-chat-action-btn`,{type:`button`});return i.dataset.wui=X4,n&&i.append($4(n,14)),i.append(document.createTextNode(t)),i.addEventListener(`click`,r),i}function n3(e,t,n){let r=$(`button`,`wui-chat-icon-btn`,{type:`button`,"aria-label":e,title:e});return r.append($4(t,20)),r.addEventListener(`click`,n),r}function r3(e,t){let n=e.getAttribute(t);if(n!=null&&n!==``)try{return JSON.parse(n)}catch(e){throw Error(`<wui-chat ${t}> must be valid JSON.`,{cause:e})}}var i3=0;function a3(e){return e.querySelector(`:scope > [slot="mark"]`)}function o3(e,t){for(let t of e.querySelectorAll(`script`))t.remove();let n=[e,...e.querySelectorAll(`*`)],r=[];for(let e of n){for(let t of e.getAttributeNames())t.startsWith(`on`)&&e.removeAttribute(t);let n=e.getAttribute(`id`);if(n){let i=`${n}-${t}`;r.push([n,i]),e.setAttribute(`id`,i)}}let i=e=>r.reduce((e,[t,n])=>e.split(`url(#${t})`).join(`url(#${n})`),e);for(let e of n){for(let t of e.getAttributeNames()){let n=e.getAttribute(t);n?.includes(`url(#`)&&e.setAttribute(t,i(n))}let t=e.localName===`style`?e.textContent:null;t?.includes(`url(#`)&&(e.textContent=i(t))}}function s3(e){return(t,n)=>{if(e===null)return null;let r=e.cloneNode(!0);if(!(r instanceof Element))return null;r.removeAttribute(`slot`),i3+=1,o3(r,`mark${i3}`);let i=$(`span`,`wui-chat-mark`,{"aria-hidden":`true`,"data-place":t,"data-state":n});return i.append(r),i}}function c3(e){let t;return n=>{let r=e.dataset.state;if((!n||r!==`open`&&r!==`opening`)&&(n||r!==`closed`&&r!==`closing`)){if(clearTimeout(t),n)e.dataset.state=`opening`,t=setTimeout(()=>{e.dataset.state=`open`},620);else{e.dataset.state=`closing`;let n=e.classList.contains(`wui-chat--panel-motion-none`)?0:300;t=setTimeout(()=>{e.dataset.state=`closed`},n)}}}}function l3(e,t){if(t.position!==void 0&&(e.classList.toggle(`wui-chat--end`,t.position===`end`),e.classList.toggle(`wui-chat--start`,t.position===`start`)),t.reduced!==void 0&&e.classList.toggle(`wui-chat--reduced`,!!t.reduced),t.expressive!==void 0&&e.classList.toggle(`wui-chat--expressive`,t.expressive===!0),t.sendReveal!==void 0&&e.classList.toggle(`wui-chat--send-always`,t.sendReveal===`Always`),t.inputRing!==void 0&&e.classList.toggle(`wui-chat--input-ring-off`,t.inputRing===!1),t.panelMotion!==void 0&&(e.classList.toggle(`wui-chat--panel-motion-gentle`,t.panelMotion===`Gentle`),e.classList.toggle(`wui-chat--panel-motion-none`,t.panelMotion===`None`)),t.offsetX!==void 0&&e.style.setProperty(`--_wui-chat-offset-x`,`${t.offsetX}px`),t.offsetY!==void 0&&e.style.setProperty(`--_wui-chat-offset-y`,`${t.offsetY}px`),t.width!==void 0&&e.style.setProperty(`--_wui-chat-width`,t.width),t.maxHeight!==void 0&&e.style.setProperty(`--_wui-chat-panel-max-height`,`${t.maxHeight}px`),t.bottomGap!==void 0&&e.style.setProperty(`--_wui-chat-bottom-gap`,`${t.bottomGap}px`),t.panelHeight!==void 0&&e.classList.toggle(`wui-chat--panel-height-content`,t.panelHeight===`Content`),t.panelPlacement!==void 0&&e.classList.toggle(`wui-chat--placement-side`,t.panelPlacement===`Side`),t.inputMark!==void 0&&e.classList.toggle(`wui-chat--input-mark-avatar`,t.inputMark===`Avatar`),t.phoneHideLauncher!==void 0&&e.classList.toggle(`wui-chat--phone-hide-launcher`,t.phoneHideLauncher),t.avatar!==void 0&&(t.avatar?(e.style.setProperty(`--_wui-chat-avatar`,`url(${JSON.stringify(t.avatar)})`),e.style.setProperty(`--_wui-chat-typing-mark`,`url(${JSON.stringify(t.avatar)})`)):(e.style.removeProperty(`--_wui-chat-avatar`),e.style.removeProperty(`--_wui-chat-typing-mark`))),t.avatarMotion!==void 0){let n=e.style.getPropertyValue(`--_wui-chat-avatar`)!==``;e.classList.toggle(`wui-chat--avatar-drift`,t.avatarMotion===`Drift`&&!n)}t.replyAvatars!==void 0&&(e.classList.toggle(`wui-chat--reply-avatars-off`,t.replyAvatars===`None`),e.classList.toggle(`wui-chat--reply-avatars-every`,t.replyAvatars===`Every`)),t.footerLayout!==void 0&&e.classList.toggle(`wui-chat--footer-inline`,t.footerLayout===`Inline`),t.inputEdge!==void 0&&e.classList.toggle(`wui-chat--input-edge-gradient`,t.inputEdge===`Gradient`),t.inputBusyEdge!==void 0&&e.classList.toggle(`wui-chat--input-busy-edge-sweep`,t.inputBusyEdge===`Sweep`),t.inputPlaceholder!==void 0&&e.classList.toggle(`wui-chat--placeholder-gradient`,t.inputPlaceholder===`Gradient`),t.startersStyle!==void 0&&e.classList.toggle(`wui-chat--starters-rows`,t.startersStyle===`Rows`)}var u3=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],d3={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function f3(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function p3({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a,mark:o}){let s=$(`div`,`wui-chat ${d3[t]} wui-chat--${n}`),c=$(`section`,`wui-chat-panel`,{id:e,role:r}),l=i?c3(s):null;s.dataset.state=i?`closed`:`open`;let u=null,d=null,f=null,p=null,m=null,h=null,g=null,_=null,v=`round`,y=!1,b=`bubble`,x=null,S=null,C=!1,w=`icon`,T=!1;function E(){if(!u)return;let e=u.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&x&&t.push(`wui-chat-launcher--entrance-${x}`),(e===`idle`||S===`ring`&&(e===`hidden`||e===`peeking`))&&S&&S!==`none`&&t.push(`wui-chat-launcher--idle-${S}`),u.className=t.join(` `)}function D(e){u&&(u.dataset.launcher=e,E())}function O(){if(!d)return;let e=[...d.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${v}`];v===`expanding`&&t.push(`wui-chat-launcher--pill`),v===`pill`&&y&&t.push(`wui-chat-launcher--compact`),w!==`icon`&&t.push(`wui-chat-launcher--mark-${w}`),t.push(`wui-chat-launcher--reveal-${b}`,...e),d.className=t.join(` `)}function k(){h&&g&&(h.textContent=_||g.launcher)}function A(){if(!d||!m||!g)return;let e=_||g.launcher;d.setAttribute(`aria-label`,T?g.launcherClose:e),m.textContent=e}if(i){let t=$(`div`,`wui-chat-launcher-wrap`);u=t,t.dataset.launcher=`idle`;let n=$(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e});d=n;let r=$(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`});f=r,p=o?.(`launcher`,`rest`)??null,r.append(p??$4(`chat`,24));let i=$(`span`,`wui-chat-launcher-close`,{"aria-hidden":`true`});i.append($4(`x`,24));let l=$(`span`,`wui-chat-launcher-label`);m=l,n.append(r,i,l),n.addEventListener(`click`,()=>a()),n.addEventListener(`animationend`,e=>{e.target===n&&n.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`)});let g=$(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`});h=g,t.append(n,g),K4(s,n),t.addEventListener(`animationend`,e=>{e.target===t&&t.dataset.launcher===`entering`&&(t.dataset.launcher=`idle`,E())}),O(),E(),s.append(t,c)}else s.append(c);function j(e){if(!l)return;let t=e&&!T&&d!==null&&d?d.getBoundingClientRect():null;e!==T&&d&&(d.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),d.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),T=e,l(e),t&&J4(c,t),d&&(d.setAttribute(`aria-expanded`,String(e)),A())}function M(e){g=e,d&&(A(),k())}function ee(e){if(l3(s,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?s.dataset.theme=e.theme:delete s.dataset.theme),!d||!u||!f)return;e.launcherStyle!==void 0&&(v=f3(e.launcherStyle)),e.compact!==void 0&&(y=e.compact),e.labelReveal!==void 0&&(b=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(x=e.entrance===`None`?null:f3(e.entrance)),e.idle!==void 0&&(S=e.idle===`None`?`none`:f3(e.idle)),e.phone!==void 0&&(C=e.phone),e.hoverLabel!==void 0&&(_=e.hoverLabel||null),e.launcherMark!==void 0&&(w=f3(e.launcherMark)),p===null&&e.icon!==void 0&&e.icon!==f.dataset.icon&&(f.dataset.icon=e.icon,f.replaceChildren($4(e.icon,24)));let t=e.launcherState??u.dataset.launcher;C&&t===`entering`&&(t=`idle`),t===`entering`&&!x&&(t=`idle`),u.dataset.launcher=t,O(),E(),k(),A()}return{root:s,panel:c,setOpen:j,setLabels:M,setAppearance:ee,setLauncherState:D,nudgeHost:u,launcherButton:d,role:r}}var m3={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`neutral`,Cancelled:`neutral`},h3=/^\/[/\\]/,g3=/^https?:\/\//i,_3=/[\t\r\n]/g;function v3(e){return typeof e==`string`&&e.trim()!==``}function y3(e){return e.replace(_3,``)}function b3(e){if(typeof e!=`string`)return!1;let t=y3(e);return t.startsWith(`/`)?!h3.test(t):g3.test(t)}function x3(e){if(typeof e!=`string`)return`?`;let t=e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>([...e][0]??``).toUpperCase()).join(``);return t===``?`?`:t}function S3(e,t){let n=e?.displayName,r=x3(v3(n)?n:t),i=$(`span`,`wui-chat-avatar`,{"aria-hidden":`true`}),a=e?.avatarUrl,o=typeof a==`string`?y3(a):null;if(b3(o)){let e=$(`img`,null,{alt:``,src:o,loading:`lazy`});e.addEventListener(`error`,()=>{i.textContent=r}),i.append(e)}else i.textContent=r;return i}function C3(e,t){let n=$(`div`,`wui-chat-agent-head`),r=$(`span`,`wui-chat-agent-name`),i=e?.displayName;r.textContent=v3(i)?i:t.agent;let a=$(`span`,`wui-chat-agent-role wui-chat-agent-tag`);return a.textContent=t.agent,n.append(S3(e,t.agent),r,a),n}function w3(e,t){let n=e.displayName,r=$(`li`,`wui-chat-message wui-chat-message--agent wui-chat-message--typing`),i=$(`span`,`wui-chat-typing`);for(let e=0;e<3;e+=1)i.append($(`span`,`wui-chat-typing-dot`,{"aria-hidden":`true`}));let a=$(`span`,`visually-hidden`);return a.textContent=t.agentTyping(v3(n)?n:t.agent),r.append(C3({kind:`Agent`,displayName:n,avatarUrl:null},t),i,a),r}function T3(e){return typeof e==`string`&&Q4(m3,e)?m3[e]??null:null}function E3(e,t){return T3(e)===null?``:t.ticketStatus(e)}var D3=new Set([`Requested`,`Waiting`]),O3=new Set([`Requested`,`Waiting`,`Joined`]),k3=O3;function A3(e,t){let n=e?.displayName;return typeof n==`string`&&n.trim()!==``?n:t.handoffAgentFallback}function j3(){let e=$(`div`,`wui-chat-handoff-pulses`);for(let t=0;t<3;t+=1)e.append($(`span`,`wui-chat-handoff-pulse`,{"aria-hidden":`true`}));return e}function M3(e,t,n){let r=$(e,t);return r.textContent=n,r}function N3(e,t){let n=$(`div`,`wui-chat-handoff-body`);return n.append(M3(`strong`,`wui-chat-handoff-title`,e),M3(`p`,`wui-chat-handoff-text`,t)),n}function P3(e,t){if(typeof e.queuePosition!=`number`){let e=$(`span`,`wui-chat-system-line-stack`);return e.append(M3(`p`,`wui-chat-handoff-text`,t.handoffWaiting),M3(`p`,`wui-chat-handoff-text`,t.handoffQueuedText)),[j3(),e]}let n=$(`span`,`wui-chat-handoff-position`,{"aria-hidden":`true`});return n.textContent=String(e.queuePosition),[n,N3(t.handoffQueued(e.queuePosition),t.handoffQueuedText)]}function F3(e,t){let n=A3(e.agent,t),r=$(`span`,`wui-chat-handoff-agent`);return r.append(S3(e.agent,t.handoffAgentFallback),$(`span`,`wui-chat-handoff-online`,{"aria-hidden":`true`})),[r,N3(t.handoffJoined(n),t.handoffJoinedText(n))]}function I3(e,t){switch(e.state){case`Requested`:return[j3(),M3(`p`,`wui-chat-handoff-text`,t.handoffRequested)];case`Waiting`:return P3(e,t);case`Joined`:return F3(e,t);case`Left`:return[N3(t.handoffLeft(A3(e.agent,t)),t.handoffLeftText)];case`Ended`:return[N3(t.handoffEnded,t.handoffEndedText)];default:return null}}Yo(`wui-chat-part-handoff`,class extends Jo{_signature;constructor(){super(),this._signature=null}renderPart(e,t,n){let r=n.isLast,i=n.handoffSettled===!0&&D3.has(e.state),a=JSON.stringify([e.state,e.queuePosition,e.agent,r,n.features.HumanHandoff,n.busy,i]);if(a===this._signature)return;if(this._signature=a,i){this.replaceChildren();return}let o=I3(e,n.labels);if(o===null){this.replaceChildren();return}let s=$(`div`,`wui-chat-handoff wui-chat-handoff--${e.state.toLowerCase()}`);if(r&&D3.has(e.state)&&s.classList.add(`wui-chat-handoff--live`),r&&O3.has(e.state)&&s.setAttribute(`role`,`status`),k3.has(e.state)){s.classList.add(`wui-chat-system-line`);let e=$(`span`,`wui-chat-system-line-content`);e.append(...o),s.append(e)}else s.append(...o);this.replaceChildren(s)}});function L3(e,t){if(typeof customElements>`u`||customElements.get(e))return;let n=[];if(typeof document<`u`)for(let r of document.querySelectorAll(e))for(let i of Object.keys(r)){let a=Object.getOwnPropertyDescriptor(t.prototype,i);if(a&&(a.set||a.get)&&(n.push([r,i,Reflect.get(r,i)]),!Reflect.deleteProperty(r,i)))throw Error(`defineElement: could not clear the early "${i}" property on <${e}>.`)}customElements.define(e,t);for(let[t,r,i]of n)if(!Reflect.set(t,r,i))throw Error(`defineElement: could not restore the "${r}" property on <${e}>.`)}var R3=`@webority/ui-elements needs a browser DOM; import its types or helpers entry on the server`;if(typeof HTMLElement>`u`)throw Error(R3);var z3=HTMLElement,B3={closeLabel:`Close`,countText:`{position} of {total}`,downloadLabel:`Download`,imageFailedMessage:`This image can't be shown.`,label:`Image viewer`,nextImageLabel:`Next image`,previousImageLabel:`Previous image`,zoomInLabel:`Zoom in`,zoomOutLabel:`Zoom out`},V3=`a.wui-lightbox-item`,H3=1,U3=4,W3=.5,G3=2,K3=50,q3=6,J3=300,Y3=300;function X3(e){return Number.isFinite(e)?Math.min(U3,Math.max(H3,e)):H3}function Z3(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function Q3(e,t){return Math.abs(e)<K3||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function $3(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var e6=()=>Mi(`lightbox`,B3);function t6(e,t,n){let r=Vi(`button`,{class:`u-action wui-lightbox-btn ${n}`,type:`button`,"aria-label":t,title:t});r.style.setProperty(`--wui-action-size`,`40px`);let i=To(e,{size:20});return r.replaceChildren(...i?[i]:[]),r}L3(`wui-lightbox`,class extends z3{_ui;_index;_zoom;_pan;_pointers;_gesture;_lastTap;_returnTo;_release;_onClick;static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=H3,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(V3):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||e6().label}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${e}".`)}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(V3)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||$3(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let e=Vi(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),t=Vi(`div`,{class:`wui-lightbox-bar`}),n=Vi(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),r=Vi(`div`,{class:`wui-lightbox-tools`}),i=t6(`zoom-out`,e6().zoomOutLabel,`wui-lightbox-zoom-out`),a=t6(`zoom-in`,e6().zoomInLabel,`wui-lightbox-zoom-in`),o=Vi(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":e6().downloadLabel,title:e6().downloadLabel});o.style.setProperty(`--wui-action-size`,`40px`);let s=To(`download`,{size:20});o.replaceChildren(...s?[s]:[]),o.hidden=!this.download;let c=t6(`x`,e6().closeLabel,`wui-lightbox-close`);r.append(i,a,o,c),t.append(n,r);let l=Vi(`div`,{class:`wui-lightbox-stage`}),u=t6(`chevron-left`,e6().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),d=t6(`chevron-right`,e6().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),f=Vi(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),p=Vi(`p`,{class:`wui-lightbox-status`,role:`status`});l.append(f,p,u,d);let m=Vi(`p`,{class:`wui-lightbox-caption`});e.append(t,l,m);let h={root:e,count:n,zoomOut:i,zoomIn:a,download:o,close:c,stage:l,prev:u,next:d,image:f,status:p,caption:m};this._ui=h,c.addEventListener(`click`,()=>this.close()),u.addEventListener(`click`,()=>this.step(-1)),d.addEventListener(`click`,()=>this.step(1)),i.addEventListener(`click`,()=>this._setZoom(this._zoom-W3)),a.addEventListener(`click`,()=>this._setZoom(this._zoom+W3)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),l.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),l.addEventListener(`pointermove`,e=>this._onPointerMove(e)),l.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),l.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),l.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),f.addEventListener(`load`,()=>{this._ui===h&&(p.textContent=``,l.removeAttribute(`aria-busy`),f.hidden=!1,this._applyTransform())}),f.addEventListener(`error`,()=>{this._ui===h&&(l.removeAttribute(`aria-busy`),f.hidden=!0,p.textContent=e6().imageFailedMessage)}),this.append(e),this._release=Uo(e,{escape:!0,backdrop:!1,focus:`panel`,onRequestClose:()=>this.close()})}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,t){let n=this._view,r=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),i=t[r];if(!i)throw Error(`<wui-lightbox> image missing.`);let a=r!==this._index||!n.image.getAttribute(`src`);if(this._index=r,this._zoom=H3,this._pan={x:0,y:0},n.count.textContent=Pi(e6().countText,{position:Qi(r+1,{decimals:0}),total:Qi(t.length,{decimals:0})}),n.caption.textContent=i.caption,n.caption.hidden=!i.caption,n.download.href=i.src,n.download.setAttribute(`download`,i.name),n.prev.hidden=n.next.hidden=t.length<2,n.stage.setAttribute(`aria-busy`,`true`),n.status.textContent=``,n.image.hidden=!1,n.image.alt=i.alt||i.caption,n.image.src=i.src,this._applyTransform(),this._syncZoomButtons(),t.length>1){let e=t[(r+1)%t.length],n=t[(r-1+t.length)%t.length];if(!e||!n)throw Error(`<wui-lightbox> neighbour image missing.`);for(let t of[e,n])new Image().src=t.src}a&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:r}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=H3,e.zoomIn.disabled=this._zoom>=U3;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=X3(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return Z3(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>H3)}_onKeyDown(e){let t=ko(e.key,Oo(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+W3)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-W3)):e.key===`0`&&(e.preventDefault(),this._setZoom(H3))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>q3&&(t.moved=!0),this._zoom>H3&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===H3&&this.step(Q3(r,i)):e.timeStamp-n.startTime>J3||(n.onImage?e.timeStamp-this._lastTap<Y3?(this._lastTap=-1/0,this._setZoom(this._zoom>H3?H3:G3)):this._lastTap=e.timeStamp:this.close())}}),Yo(`wui-chat-part-image`,class extends Jo{#e=null;#t=0;#n=null;renderPart(e,t,n){if(e.attachmentId===this.#e)return;this.#e=e.attachmentId;let r=this.ownerDocument??document,i=P(r,`figure`,`wui-chat-image`),a=P(r,`div`,`wui-chat-image-frame`);this.#n=a;let{width:o,height:s}=e;o!==null&&s!==null&&Number.isFinite(o)&&Number.isFinite(s)&&o>0&&s>0&&(a.style.aspectRatio=`${o} / ${s}`),i.append(a),this.replaceChildren(i),this.#r(e,n)}disposePart(){this.#t+=1,this.#e=null}#r(e,t){this.#t+=1;let n=this.#t,r=this.ownerDocument??document,i=this.#n;if(i===null)return;let a=P(r,`div`,`wui-chat-image-skeleton`);a.setAttribute(`aria-hidden`,`true`);let o=P(r,`span`,`visually-hidden`,t.labels.imageLoading);o.setAttribute(`role`,`status`),i.replaceChildren(a,o),typeof t.loadAttachmentUrl==`function`?t.loadAttachmentUrl(e.attachmentId).then(r=>{n===this.#t&&this.isConnected&&this.#i(r,e,t)},()=>{n===this.#t&&this.isConnected&&this.#a(e,t)}):this.#a(e,t)}#i(e,t,n){let r=this.#n;if(r===null)return;let i=this.ownerDocument??document,a=P4(t.alt),o=i.createElement(`wui-lightbox`);o.setAttribute(`label`,n.labels.imageViewer),o.setAttribute(`layout`,`single`);let s=P(i,`a`,`wui-lightbox-item`);s.setAttribute(`href`,e),s.dataset.caption=a,s.dataset.name=a;let c=i.createElement(`img`);c.src=e,c.alt=a,c.decoding=`async`,s.append(c),o.append(s),r.replaceChildren(o)}#a(e,t){let n=this.#n;if(n===null)return;let r=this.ownerDocument??document,i=P(r,`p`,`wui-chat-image-error`,t.labels.imageFailed);i.setAttribute(`role`,`status`);let a=P(r,`button`,`btn btn-soft-primary btn-sm`,t.labels.retry);a.type=`button`,a.addEventListener(`click`,()=>this.#r(e,t)),n.replaceChildren(i,a)}});var n6={Email:{type:`email`,autocomplete:`email`},Phone:{type:`tel`,autocomplete:`tel`},Name:{type:`text`,autocomplete:`name`},Company:{type:`text`,autocomplete:`organization`},Text:{type:`text`,autocomplete:null},LongText:{type:`text`,autocomplete:null}},r6=[`Open`,`Answered`,`Skipped`,`Expired`],i6=0;function a6(e){return i6+=1,`${e}-${i6}`}function o6(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r}function s6(){let e=o6(`p`,`wui-chat-field-error`);return e.id=a6(`wui-chat-field-error`),e.setAttribute(`role`,`alert`),e.hidden=!0,e}function c6(e,t){return e.required?[]:[o6(`span`,`wui-chat-field-hint`,t.inputOptional)]}function l6(e,t,n){let r=a6(`wui-chat-field`),i=n6[t],a=t===`LongText`&&!e.secret,o;if(a){let e=o6(`textarea`,`form-control wui-chat-input-control`);e.rows=3,o=e}else{let t=o6(`input`,`form-control wui-chat-input-control`);t.type=e.secret?`password`:i.type,e.secret?t.autocomplete=`off`:i.autocomplete&&(t.autocomplete=i.autocomplete),o=t}o.id=r,o.name=e.key,e.placeholder!=null&&(o.placeholder=e.placeholder),e.maxLength!=null&&(o.maxLength=e.maxLength),e.required&&o.setAttribute(`aria-required`,`true`);let s=o6(`label`,`form-label`,e.label);s.htmlFor=r;let c=s6();o.setAttribute(`aria-describedby`,c.id);let l=o6(`div`,`wui-chat-field`);return l.dataset.key=e.key,l.append(s,...c6(e,n),o,c),{field:e,element:l,controls:[o],focus:o,invalid:o,error:c,control:o,read:()=>e.secret?o.value:o.value.trim()}}function u6(e,t,n,r,i){let a=e.control,o=o6(`button`,`btn btn-soft-primary`,n.inputSendCode);o.type=`button`,o.dataset.wui=`AppButton`;let s=o6(`p`,`wui-chat-field-hint`);s.setAttribute(`aria-live`,`polite`);let c=a6(`wui-chat-field`),l=o6(`label`,`form-label`,n.inputEnterCode);l.htmlFor=c,l.hidden=!0;let u=o6(`input`,`form-control wui-chat-input-control`);return u.type=`text`,u.id=c,u.inputMode=`numeric`,u.autocomplete=`one-time-code`,u.hidden=!0,o.addEventListener(`click`,async()=>{o.disabled=!0;try{await r.sendOtp(i,{fieldKey:t.key,value:a.value.trim()}),s.textContent=n.inputCodeSent,l.hidden=!1,u.hidden=!1}catch{s.textContent=n.inputCodeFailed}finally{o.disabled=!1}}),e.element.insertBefore(o,e.error),e.element.insertBefore(s,e.error),e.element.insertBefore(l,e.error),e.element.insertBefore(u,e.error),{...e,controls:[...e.controls,o,u],codeRead:()=>u.value.trim()}}function d6(e,t){let n=a6(`wui-chat-field-label`),r=o6(`span`,`form-label`,e.label);r.id=n;let i=o6(`div`);i.setAttribute(`role`,`radiogroup`),i.setAttribute(`aria-labelledby`,n);let a=s6();i.setAttribute(`aria-describedby`,a.id);let o=[];for(let t of e.options??[]){let n=o6(`div`,`form-check`),r=o6(`input`,`form-check-input`);r.type=`radio`,r.name=e.key,r.value=t.id,r.id=a6(`wui-chat-option`);let a=o6(`label`,`form-check-label`,t.label);a.htmlFor=r.id,n.append(r,a),i.append(n),o.push(r)}o.length===0&&(i.tabIndex=-1);let s=o6(`div`,`wui-chat-field`);return s.dataset.key=e.key,s.append(r,...c6(e,t),i,a),{field:e,element:s,controls:o,focus:o[0]??i,invalid:i,error:a,read:()=>o.find(e=>e.checked)?.value??``}}function f6(e,t){let n=a6(`wui-chat-field-label`),r=o6(`span`,`form-label`,e.label);r.id=n;let i=o6(`div`,`wui-chat-input-choices`);i.setAttribute(`role`,`group`),i.setAttribute(`aria-labelledby`,n);let a=s6();i.setAttribute(`aria-describedby`,a.id);let o=[];for(let t of e.options??[]){let n=o6(`div`,`form-check`),r=o6(`input`,`form-check-input`);r.type=`checkbox`,r.name=e.key,r.value=t.id,r.id=a6(`wui-chat-option`);let a=o6(`label`,`form-check-label`,t.label);a.htmlFor=r.id,n.append(r,a),i.append(n),o.push(r)}o.length===0&&(i.tabIndex=-1);let s=o6(`div`,`wui-chat-field`);return s.dataset.key=e.key,s.append(r,...c6(e,t),i,a),{field:e,element:s,controls:o,focus:o[0]??i,invalid:i,error:a,read:()=>JSON.stringify(o.filter(e=>e.checked).map(e=>e.value))}}function p6(e,t){let n=a6(`wui-chat-field-label`),r=o6(`span`,`form-label`,e.label);r.id=n;let i=o6(`div`,`wui-chat-input-slots`);i.setAttribute(`role`,`radiogroup`),i.setAttribute(`aria-labelledby`,n);let a=s6();i.setAttribute(`aria-describedby`,a.id);let o=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`}),s=[];for(let t of e.slots??[]){let n=o6(`input`,`wui-chat-input-slot-radio`);n.type=`radio`,n.name=e.key,n.value=t.id,n.id=a6(`wui-chat-slot`);let r=o6(`label`,`btn btn-soft-primary wui-chat-input-slot`,o.format(new Date(t.startDateTimeUtc)));r.htmlFor=n.id,i.append(n,r),s.push(n)}s.length===0&&(i.tabIndex=-1);let c=o6(`div`,`wui-chat-field`);return c.dataset.key=e.key,c.append(r,...c6(e,t),i,a),{field:e,element:c,controls:s,focus:s[0]??i,invalid:i,error:a,read:()=>s.find(e=>e.checked)?.value??``}}function m6(e,t,n){let r=a6(`wui-chat-field-label`),i=o6(`span`,`form-label`,e.label);i.id=r;let a=s6(),o=o6(`input`);o.type=`file`,o.name=e.key,o.id=a6(`wui-chat-field`),o.hidden=!0,e.accept?.length&&(o.accept=e.accept.join(`,`));let s=o6(`button`,`btn btn-soft-primary`,t.inputChooseFile);s.type=`button`,s.dataset.wui=`AppButton`,s.setAttribute(`aria-describedby`,a.id),s.addEventListener(`click`,()=>o.click());let c=o6(`span`,`wui-chat-input-file-status`);c.setAttribute(`aria-live`,`polite`);let l=o6(`button`,`btn btn-link-primary`);l.type=`button`,l.dataset.wui=`AppButton`,l.hidden=!0;let u=o6(`div`,`wui-chat-input-file`);u.setAttribute(`role`,`group`),u.setAttribute(`aria-labelledby`,r),u.append(s,c,l,o);let d=`empty`,f=``,p=``,m=0,h=()=>{c.textContent=d===`uploading`?`${t.attachmentUploading} ${f}`:f,l.hidden=f===``,l.textContent=f===``?``:t.inputRemoveFile(f);let e=d===`failed`;a.textContent=e?t.attachmentFailed:``,a.hidden=!e,e?u.setAttribute(`aria-invalid`,`true`):u.removeAttribute(`aria-invalid`)},g=async e=>{m+=1;let t=m;d=`uploading`,f=e.name,p=``,h();try{let r=await n.uploadInputFile(e);if(t!==m)return;p=r,d=`ready`}catch{if(t!==m)return;d=`failed`}h()};o.addEventListener(`change`,()=>{let e=o.files?.[0];e&&g(e)}),l.addEventListener(`click`,()=>{m+=1,d=`empty`,f=``,p=``,o.value=``,h()}),h();let _=o6(`div`,`wui-chat-field`);return _.dataset.key=e.key,_.append(i,...c6(e,t),u,a),{field:e,element:_,controls:[s,l,o],focus:s,invalid:u,error:a,read:()=>d===`ready`?p:``,uploadProblem:()=>d===`uploading`?t.attachmentUploading:d===`failed`?t.attachmentFailed:null}}function h6(e){let t=o6(`input`,`form-check-input`);t.type=`checkbox`,t.name=e.key,t.id=a6(`wui-chat-field`);let n=o6(`label`,`form-check-label`,e.consentText||e.label);n.htmlFor=t.id;let r=s6();t.setAttribute(`aria-describedby`,r.id);let i=o6(`div`,`form-check`);i.append(t,n);let a=o6(`div`,`wui-chat-field`);return a.dataset.key=e.key,a.append(i,r),{field:e,element:a,controls:[t],focus:t,invalid:t,error:r,read:()=>t.checked?`true`:`false`}}function g6(e,t,n,r){if(e.type===`Choice`)return d6(e,t);if(e.type===`MultiChoice`)return f6(e,t);if(e.type===`TimeSlot`)return p6(e,t);if(e.type===`File`)return m6(e,t,n);if(e.type===`Consent`)return h6(e);let i=l6(e,e.type,t);return e.verify===`Otp`?u6(i,e,t,n,r):i}function _6(e,t,n){let r=e.uploadProblem?.();if(r)return r;let{field:i}=e;return i.required?i.type===`Consent`?t===`true`?null:n.inputConsentRequired:i.type===`MultiChoice`?t===`[]`?n.inputRequired:null:t===``?n.inputRequired:null:null}function v6(e,t){return e.state===`Answered`?o6(`p`,`wui-chat-input-summary`,e.answeredSummary||t.inputAnswered):o6(`p`,`wui-chat-input-summary`,e.state===`Skipped`?t.inputSkipped:t.inputExpired)}Yo(`wui-chat-part-input-request`,class extends Jo{_signature;_generation;constructor(){super(),this._signature=null,this._generation=0}renderPart(e,t,n){for(let t of r6)this.classList.toggle(`wui-chat-input-request--${t.toLowerCase()}`,e.state===t);let r=JSON.stringify([e.requestId,e.state,e.answeredSummary,e.fields]);r!==this._signature&&(this._signature=r,this._generation+=1,this.replaceChildren(this._content(e,n)))}_content(e,t){return e.state===`Open`?this._form(e,this._generation):v6(e,t.labels)}_form(e,t){let n=this.activeTurn,r=n.labels,i=n.features,a=o6(`form`,`wui-chat-input-form`);a.noValidate=!0,a.setAttribute(`aria-label`,e.title||e.submitLabel),e.title&&a.append(o6(`h3`,`wui-chat-input-title`,e.title));let o=e.fields.map(t=>g6(t,r,n,e.requestId));for(let e of o)a.append(e.element);let s=o6(`p`,`wui-chat-input-error`);s.setAttribute(`role`,`status`),s.hidden=!0,a.append(s);let c=o6(`button`,`btn btn-primary`,e.submitLabel);c.type=`submit`,c.dataset.wui=`AppButton`;let l=o6(`div`,`d-flex flex-wrap gap-2`);l.append(c);let u=[c];if(i.LeadShortcuts&&e.fields.length===1&&!e.fields[0]?.required){let t=o6(`button`,`btn btn-soft-primary`,r.skip);t.type=`button`,t.dataset.wui=`AppButton`,t.addEventListener(`click`,()=>this.activeTurn.skipInput(e.requestId)),l.append(t),u.push(t)}if(i.LeadShortcuts&&e.cancellable){let e=o6(`button`,`btn btn-link-primary`,r.cancel);e.type=`button`,e.dataset.wui=`AppButton`,e.addEventListener(`click`,()=>this.activeTurn.cancelLead()),l.append(e),u.push(e)}a.append(l),e.allowTyped&&a.append(o6(`p`,`wui-chat-input-typed`,r.typeAnswer));let d=!1,f=t=>{for(let e of o)for(let n of e.controls)n.disabled=t;for(let e of u)e.disabled=t;c.textContent=t?r.inputSubmitting:e.submitLabel},p=()=>{for(let e of o)e.error.hidden=!0,e.error.textContent=``,e.invalid.removeAttribute(`aria-invalid`);s.hidden=!0,s.textContent=``},m=(e,t)=>{e.error.textContent=t,e.error.hidden=!1,e.invalid.setAttribute(`aria-invalid`,`true`)};return a.addEventListener(`submit`,async n=>{if(n.preventDefault(),d)return;p();let i={},a={},l=[];for(let e of o){let t=e.read();i[e.field.key]=t,e.codeRead&&(a[e.field.key]=e.codeRead());let n=_6(e,t,r);n&&l.push([e,n])}let[u]=l;if(u){for(let[e,t]of l)m(e,t);u[0].focus.focus();return}d=!0,f(!0);let h;try{h=await this.activeTurn.answerInput(e.requestId,i,Object.keys(a).length>0?a:null)}catch{h={ok:!1,errors:{},message:r.errorGeneric}}if(t!==this._generation||h.ok)return;d=!1;let g=null;for(let e of o){let t=h.errors?.[e.field.key];t&&(m(e,t),g??=e)}h.message!=null&&(s.textContent=h.message,s.hidden=!1),f(!1),g?g.focus.focus():o[0]?o[0].focus.focus():c.focus()}),a}});var y6={ActionLimitReached:`warning`,ConversationTooLong:`warning`,AssistantUnavailable:`danger`},b6={info:`info`,warning:`alert-triangle`,danger:`alert-circle`};function x6(e,t){let n=P(e,`a`,`wui-chat-notice-row`);if(n.href=t.href,/^https?:/i.test(t.href)&&(n.target=`_blank`,n.rel=`noopener noreferrer`),t.icon){let r=P(e,`span`,`wui-chat-notice-row-icon`);r.setAttribute(`aria-hidden`,`true`);let i=Xo(e,t.icon,18);i&&r.append(i),n.append(r)}let r=P(e,`span`,`wui-chat-notice-row-text`);r.append(P(e,`strong`,`wui-chat-notice-row-title`,t.title)),t.detail&&r.append(P(e,`span`,`wui-chat-notice-row-detail`,t.detail));let i=P(e,`span`,`wui-chat-notice-row-arrow`);i.setAttribute(`aria-hidden`,`true`);let a=Xo(e,`arrow-right`,16);return a&&i.append(a),n.append(r,i),n}Yo(`wui-chat-part-notice`,class extends Jo{renderPart(e){let t=this.ownerDocument??document,n=y6[e.code]??`info`,r=P(t,`div`,`wui-chat-notice wui-chat-notice--${n}`);r.setAttribute(`role`,n===`danger`?`alert`:`status`);let i=P(t,`span`,`wui-chat-notice-icon`);i.setAttribute(`aria-hidden`,`true`);let a=Xo(t,b6[n],16);a&&i.append(a);let o=P(t,`div`,`wui-chat-notice-body`);o.append(P(t,`span`,`wui-chat-notice-text`,e.text));let s=e.action;if(s){let e=P(t,`button`,`wui-chat-notice-action`,s.label);e.type=`button`,e.addEventListener(`click`,()=>s.run()),o.append(e)}let c=(e.actions??[]).filter(e=>jr(e.href));if(c.length>0){let e=P(t,`div`,`wui-chat-notice-rows`);for(let n of c)e.append(x6(t,n));o.append(e)}r.append(i,o),this.replaceChildren(r)}});function S6(e){switch(e){case`Primary`:return`wui-chat-quick-reply--primary`;case`Cta`:return`wui-chat-quick-reply--cta`;case`Default`:case null:return``}}Yo(`wui-chat-part-quick-replies`,class extends Jo{#e=null;renderPart(e,t,n){let r=n.features.SuggestedReplies===!0&&n.isLast===!0&&n.busy===!1&&e.replies.length>0,i=typeof n.openTarget==`function`,a=typeof n.beginHandoff==`function`,o=n.handoffPause===!0,s=JSON.stringify([r,e.replies,e.placement,n.labels.quickReplies,n.labels.handoffMoment,i,a,o,n.handoffHosts??null,n.features.LinkHandoff===!0]);if(s===this.#e)return;this.#e=s;let c=this.querySelector(`:scope > .wui-chat-quick-replies:not(.wui-chat-quick-replies--leaving)`);if(!r&&c){this.#t(c);return}if(this.replaceChildren(),!r)return;let l=this.ownerDocument,u=e.placement===`Composer`,d=P(l,`div`,u?`wui-chat-quick-replies wui-chat-quick-replies--composer`:`wui-chat-quick-replies`);d.setAttribute(`role`,`group`),d.setAttribute(`aria-label`,n.labels.quickReplies);let f=u?null:e.replies.find(e=>e.id===`handoff.request`&&e.action===`Send`),p=0;f&&(d.classList.add(`wui-chat-quick-replies--offer`),d.append(this.#n(l,f,n)),p+=1);for(let t of e.replies){if(t===f||t.action===`Open`&&(!t.target||!i))continue;let e=null;if(t.action===`Navigate`){if(n.features.LinkHandoff!==!0)continue;if(Dr(t.target,n.handoffHosts))e=t.target;else{let r=t.target===null?null:n.resolveLink?.(t.target);e=typeof r==`string`&&r!==``?r:null}if(e===null){d.append(P(l,`span`,null,t.label));continue}if(!a)continue}d.append(this.#r(l,t,p,n,f?`wui-chat-quick-reply--quiet`:``,e)),p+=1}if(o){let e=P(l,`span`,`visually-hidden`,n.labels.handoffMoment);e.setAttribute(`role`,`status`),d.append(e)}d.childElementCount>0&&this.append(d)}#t(e){e.classList.add(`wui-chat-quick-replies--leaving`);let t=this.ownerDocument.defaultView,n=Number.parseFloat(t?t.getComputedStyle(e).animationDuration:``)*1e3;t===null||!(n>0)?e.remove():t.setTimeout(()=>e.remove(),n)}#n(e,t,n){let r=P(e,`div`,`wui-chat-offer`);return r.style.setProperty(`--wui-chat-i`,`0`),r.append(P(e,`div`,`wui-chat-offer-title`,t.label)),r.append(this.#r(e,{...t,variant:`Primary`},0,n,`wui-chat-offer-action`)),r}#r(e,t,n,r,i=``,a=null){let o=e.createElement(`button`);o.type=`button`,o.className=[`wui-chat-quick-reply`,S6(t.variant),i].filter(Boolean).join(` `),o.style.setProperty(`--wui-chat-i`,String(n));let s=t.action===`Navigate`,c=s&&r.handoffPause===!0;if(o.disabled=c,t.icon){let n=Xo(e,t.icon,16);if(n){let t=P(e,`span`,`wui-chat-quick-reply-icon`);t.setAttribute(`aria-hidden`,`true`),t.append(n),o.append(t)}}return o.append(P(e,`span`,`wui-chat-quick-reply-label`,c?r.labels.handoffMoment:t.label)),o.addEventListener(`click`,()=>{if(t.action===`Open`){let{openTarget:e}=this.activeTurn;if(t.target===null||e===void 0)throw Error(`${this.localName} drew an Open chip without a target or openTarget`);e.call(this.activeTurn,t.target)}else if(s){let{beginHandoff:e}=this.activeTurn;if(a===null||e===void 0)throw Error(`${this.localName} drew a Navigate chip without a destination or beginHandoff`);e.call(this.activeTurn,t,()=>this.#i(a))}else this.activeTurn.chooseQuickReply(t),this.closest(`.wui-chat`)?.querySelector(`.wui-chat-input`)?.focus()}),o}#i(e){typeof this.activeTurn.openTarget==`function`?this.activeTurn.openTarget(e):globalThis.location.assign(e)}});var C6=new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]);function w6(e){return C6.has(e)}function T6(e,t,n,r=!0){let i=e=>r?vn(e):[{kind:`text`,text:e}];if(t==null||t===``)return[{kind:`text`,text:Gi()}];if(e===`Date`||e===`DateTimeUtc`)return[{kind:`text`,text:Tr(t,e,n)}];if(w6(e)){let r=Number(t);return i(Number.isFinite(r)?Tr(r,e,n):String(t))}return i(String(t))}var E6=0;function D6(e){return E6+=1,`${e}-${E6}`}Yo(`wui-chat-part-record-card`,class extends Jo{#e=null;renderPart(e,t,n){let r=!!e.target&&typeof n.openRecord==`function`,i=n.features?.FigureText===!0,a=JSON.stringify([e,r,i]);if(a===this.#e)return;this.#e=a;let o=this.ownerDocument,s=P(o,`article`,`wui-chat-record`),c=D6(`wui-chat-record-title`);s.setAttribute(`aria-labelledby`,c);let l=P(o,`div`,`wui-chat-record-head`),u=P(o,`strong`,`wui-chat-record-title`);if(u.id=c,u.setAttribute(`role`,`heading`),u.setAttribute(`aria-level`,`3`),i?N4(u,e.title):u.textContent=String(e.title??``),l.append(u),e.subtitle){let t=P(o,`span`,`wui-chat-record-subtitle`);i?N4(t,e.subtitle):t.textContent=String(e.subtitle??``),l.append(t)}if(s.append(l),e.fields?.length>0){let t=P(o,`dl`,`wui-chat-record-fields`);for(let n of e.fields){let e=P(o,`div`),r=P(o,`dt`);i?N4(r,n.label):r.textContent=String(n.label??``);let a=P(o,`dd`);w6(n.type)&&(a.className=`wui-chat-num`),M4(a,T6(n.type,n.value,null,i)),e.append(r,a),t.append(e)}s.append(t)}if(r){let t=P(o,`button`,`btn btn-soft-primary btn-sm wui-chat-record-open`,n.labels.recordOpen);t.type=`button`,t.setAttribute(`aria-label`,n.labels.recordOpenFor(P4(e.title))),t.addEventListener(`click`,()=>{let{openRecord:t}=this.activeTurn;if(t===void 0)throw Error(`${this.localName} lost openRecord after it drew the button`);t.call(this.activeTurn,e)}),s.append(t)}this.replaceChildren(s)}});var O6=/^https?:\/\//i;Yo(`wui-chat-part-sources`,class extends Jo{renderPart(e,t,n){if(this.replaceChildren(),!n.features.Sources||e.sources.length===0)return;let r=this.ownerDocument,i=P(r,`div`,`wui-chat-sources`);i.append(P(r,`p`,`wui-chat-sources-label`,n.labels.sources));let a=P(r,`ul`,`wui-chat-sources-list`);a.setAttribute(`aria-label`,n.labels.sources);for(let t of e.sources){let e=r.createElement(`li`);e.append(this.#e(r,t,n)),a.append(e)}i.append(a),this.append(i)}#e(e,t,n){let r;if(typeof t.url==`string`&&O6.test(t.url)){let i=P(e,`a`,`wui-chat-source`);i.setAttribute(`href`,t.url),i.setAttribute(`target`,`_blank`),i.setAttribute(`rel`,`noopener noreferrer`),i.setAttribute(`aria-label`,n.labels.openSource(t.title)),r=i}else r=P(e,`span`,`wui-chat-source`),r.tabIndex=-1;return r.dataset.marker=String(t.marker),r.append(P(e,`span`,`wui-chat-source-marker`,String(t.marker)),P(e,`span`,`wui-chat-source-title`,t.title)),r}});var k6=25,A6=0;function j6(e,t,n){let r=e.createElement(`tr`);for(let i of t.columns){let t=e.createElement(`th`);t.setAttribute(`scope`,`col`),w6(i.type)&&(t.className=`wui-chat-num`),n?N4(t,i.label):t.textContent=String(i.label??``),r.append(t)}return r}function M6(e,t,n,r){let i=e.createElement(`tr`);return t.columns.forEach((a,o)=>{let s=o===0&&a.type===`Text`,c=e.createElement(s?`th`:`td`);s&&c.setAttribute(`scope`,`row`),w6(a.type)&&(c.className=`wui-chat-num`);let l=n[o];l==null||l===``?c.append(P(c.ownerDocument,`span`,`wui-chat-null`,Gi())):M4(c,T6(a.type,l,t.currency,r)),i.append(c)}),i}function N6(e,t){let n=()=>{let n=t.scrollWidth-t.clientWidth;e.dataset.scroll=n<=1?`none`:t.scrollLeft>=n-1?`end`:t.scrollLeft>0?`middle`:`start`};t.addEventListener(`scroll`,n,{passive:!0}),typeof ResizeObserver<`u`&&new ResizeObserver(n).observe(t),n()}function P6(e,t,n,r,i){let a=e.ownerDocument;for(let o of t.rows.slice(n,r))e.append(M6(a,t,o,i))}Yo(`wui-chat-part-table`,class extends Jo{#e=null;renderPart(e,t,n){let r=n.features?.FigureText===!0,i=JSON.stringify([e,r]);if(i===this.#e)return;if(this.#e=i,!e.columns||e.columns.length===0){this.replaceChildren();return}let a=this.ownerDocument,o=P(a,`figure`,`wui-chat-table`),s=null;if(e.title){A6+=1,s=`wui-chat-table-${A6}`;let t=P(a,`figcaption`,`wui-chat-table-title`);t.id=s,r?N4(t,e.title):t.textContent=String(e.title??``),o.append(t)}let c=P(a,`div`,`table-wrap wui-chat-table-wrap`);c.tabIndex=0,c.setAttribute(`role`,`region`),s?c.setAttribute(`aria-labelledby`,s):c.setAttribute(`aria-label`,n.labels.table);let l=P(a,`table`,`table table-sm wui-chat-table-grid`),u=a.createElement(`thead`);u.append(j6(a,e,r));let d=a.createElement(`tbody`);P6(d,e,0,Math.min(e.rows.length,k6),r),l.append(u,d),c.append(l);let f=P(a,`div`,`wui-chat-table-frame`),p=P(a,`span`,`wui-chat-table-cue`);if(p.setAttribute(`aria-hidden`,`true`),f.append(c,p),o.append(f),N6(f,c),e.rows.length>k6){let t=P(a,`button`,`btn btn-soft-primary btn-sm wui-chat-table-more`,n.labels.tableShowAll(e.rows.length));t.type=`button`,t.addEventListener(`click`,()=>{P6(d,e,k6,e.rows.length,r),t.remove()}),o.append(t)}this.replaceChildren(o)}});var F6=/\[([^[\]\n]+)\](?!\()/g,I6=new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),L6=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,R6=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,z6=new RegExp(F6.source,`y`),B6=e=>/[\p{L}\p{N}]/u.test(e);function V6(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function H6(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),o=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),s=n===`_`&&B6(e.charAt(i+n.length));if(a&&!o&&!s&&!V6(e,i))return i}return-1}function U6(e,t){let n=t?.isCitation,r=[],i=``,a=()=>{i&&=(r.push({type:`text`,text:i}),``)},o=0;for(;o<e.length;){let s=e.charAt(o),c=e.charAt(o+1);if(s===`\\`&&I6.has(c)){i+=c,o+=2;continue}if(s==="`"){let t=e.indexOf("`",o+1);if(t>o+1){a(),r.push({type:`code`,text:e.slice(o+1,t)}),o=t+1;continue}}let l=s+c;if(l===`**`||l===`__`||l===`~~`){let n=H6(e,o+2,l);if(n!==-1&&!(l===`__`&&B6(e.charAt(o-1)))){a();let i=U6(e.slice(o+2,n),t);l===`~~`?r.push({type:`strike`,children:i}):r.push({type:`strong`,children:i}),o=n+2;continue}i+=l,o+=2}else{if(s===`*`||s===`_`){let n=H6(e,o+1,s);if(n!==-1&&!(s===`_`&&B6(e.charAt(o-1)))){a(),r.push({type:`em`,children:U6(e.slice(o+1,n),t)}),o=n+1;continue}}if(s===`[`){L6.lastIndex=o;let t=L6.exec(e);if(t){let e=t[1],n=t[2];if(e===void 0||n===void 0)throw Error(`The link pattern always captures its label and href`);a(),r.push({type:`link`,href:n,children:U6(e)}),o+=t[0].length;continue}if(n){z6.lastIndex=o;let t=z6.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The citation pattern always captures its inner text`);if(n(e)){a(),r.push({type:`citation`,text:e}),o+=t[0].length;continue}}}}if(s===`!`){R6.lastIndex=o;let t=R6.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The image pattern always captures its alt text`);a(),r.push({type:`image`,children:U6(e)}),o+=t[0].length;continue}}i+=s,o+=1}}return a(),r.map((e,t)=>({...e,key:t}))}var W6=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,G6=/^https?:/i,K6=/^(mailto|tel):/i,q6=/^(?:\/(?![/\\])|#|\?|\.{1,2}\/)/,J6=/^https:\/\/[^/?#@\\\s]+$/i,Y6=/^[a-z][a-z0-9+.-]*:/i;function X6(e){if(typeof e!=`string`)return null;let t=e.endsWith(`/`)?e.slice(0,-1):e;return J6.test(t)?t:null}function Z6(e,t,n,r,i){if(n&&(t===`page`||W6.test(e))){let t=n(e);if(t!=null)return{kind:`app`,target:t}}if(t===`app`)return null;let a=i==null?null:X6(i),o=a===null?e:Q6(e,a);return o===null?null:q6.test(o)?{kind:`page`,href:o}:t===`page`&&!(G6.test(o)&&r&&e8(o,r))?null:G6.test(o)?{kind:r&&e8(o,r)?`page`:`web`,href:o}:K6.test(o)?{kind:`contact`,href:o}:null}function Q6(e,t){if(Y6.test(e))return e;if(e.startsWith(`//`))return`https:${e}`;if(e===``)return null;let n=e.indexOf(`#`),r=n<0?``:e.slice(n),i=n<0?e:e.slice(0,n),a=i.indexOf(`?`),o=a<0?i:i.slice(0,a),s=a<0?``:i.slice(a);return o===``?`${t}${s}${r}`:`${t}${$6(o.startsWith(`/`)?o:`/${o}`)}${s}${r}`}function $6(e){let t=e.split(`/`),n=[];return t.forEach((e,r)=>{let i=r===t.length-1;e===`.`?i&&n.push(``):e===`..`?(n.length>1&&n.pop(),i&&n.push(``)):n.push(e)}),n.join(`/`)}function e8(e,t){if(e.slice(0,t.length).toLowerCase()!==t.toLowerCase())return!1;let n=e[t.length];return n===void 0||n===`/`||n===`?`||n===`#`}function t8(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var n8=/^\s*```/,r8=/^\s*```\s*(\S*)/,i8=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,a8=/^\s*([-*_])(\s*\1){2,}\s*$/,o8=/^(\s*)[-*+]\s+(.*)$/,s8=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,c8=/^\s*>\s?(.*)$/,l8=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,u8=[1,2,3,4,5,6],d8=e=>e.includes(`|`);function f8(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function p8(e,t){let n=e[t];if(n===void 0)throw Error(`startsTable was called past the last source line`);let r=e[t+1];return r!==void 0&&d8(n)&&r.includes(`|`)&&l8.test(r)}function m8(e,t){let n=e[t];if(n===void 0)throw Error(`startsBlock was called past the last source line`);return n8.test(n)||c8.test(n)||o8.test(n)||s8.test(n)||i8.test(n)||a8.test(n)||p8(e,t)}function h8(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function g8(e){let t=s8.exec(e);if(t){let e=t[1],n=t[2],r=t[3];if(e===void 0||n===void 0||r===void 0)throw Error(`The ordered list pattern always captures its indent, number and text`);return{text:r,depth:h8(e),ordered:!0,number:Number(n)}}let n=o8.exec(e);if(n){let e=n[1],t=n[2];if(e===void 0||t===void 0)throw Error(`The bullet list pattern always captures its indent and text`);return{text:t,depth:h8(e),ordered:!1,number:0}}return null}function _8(e){let t=(e??``).replace(/\r\n?/g,`
|
|
42
42
|
`).split(`
|
|
43
43
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()){r+=1;continue}if(n8.test(e)){let i=r8.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(n8.test(e))break;a.push(e),r+=1}r+=1,n.push({type:`code`,text:a.join(`
|
|
44
|
-
`),language:i});continue}if(p8(t,r)){let i=f8(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!d8(e))break;a.push(f8(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(a8.test(e)){n.push({type:`rule`}),r+=1;continue}let i=i8.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=u8[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(c8.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=c8.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=g8(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=g8(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(m8(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||m8(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var v8=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],y8=[`razor`,`cshtml`],b8=[`app`,`web`,`page`],x8=e=>e!==void 0&&b8.includes(e);function S8(e,t,n,r,i=null){let a=C8(n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function C8(e,t){let n={links:x8(t.links)?t.links:`web`,headings:t.headings===`text`?`text`:`outline`,resolveLink:t.resolveLink,isCitation:t.isCitation,figureText:typeof t.figureText==`function`?t.figureText:void 0,base:typeof t.base==`string`?t.base:void 0},r=t.resolverGeneration??0;return _8(e).map(e=>({sig:`${JSON.stringify(e)}|${n.links}|${n.headings}|${n.base??``}|${r}`,build:()=>T8(n,e)}))}var w8=class extends z3{_drawn;_blocks;_observer;_connected;_resolveLink;_isCitation;_resolverGeneration;_figureText;static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=S8(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,base:this.getAttribute(`base`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,figureText:this._figureText,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function T8(e,t){switch(t.type){case`paragraph`:return[Vi(`p`,null,...E8(e,t.lines))];case`heading`:return[D8(e,t)];case`list`:return O8(e,t.items);case`table`:return[A8(e,t)];case`code`:return[M8(t)];case`quote`:return[Vi(`blockquote`,null,...E8(e,t.lines))];case`rule`:return[Vi(`hr`)];default:return[]}}function E8(e,t){let n=[];return t.forEach((t,r)=>{r>0&&n.push(Vi(`br`)),n.push(...N8(e,t))}),n}function D8(e,t){let n=N8(e,t.text);return e.headings===`text`?Vi(`p`,{class:`fw-semibold`},...n):Vi(`h2`,null,...n)}function O8(e,t){let n=[];for(let r=0;r<t.length;){let i=k8(e,t,r);n.push(i.list),r=i.next}return n}function k8(e,t,n){let r=t[n];if(!r)throw Error(`List run starts past its items.`);let{depth:i,ordered:a,number:o}=r,s=Vi(a?`ol`:`ul`,a&&o!==1?{start:o}:null),c=null,l=n,u=t[l];for(;u&&u.depth>=i;){if(u.depth===i)c=Vi(`li`,null,...N8(e,u.text)),s.append(c),l+=1;else{let n=k8(e,t,l);if(!c)throw Error(`Nested list has no item before it.`);c.append(n.list),l=n.next}u=t[l]}return{list:s,next:l}}function A8(e,t){let n=t.header.map(t=>Vi(`th`,{scope:`col`},...N8(e,t))),r=t.rows.map(n=>Vi(`tr`,null,...t.header.map((t,r)=>Vi(`td`,null,...N8(e,n[r]??``)))));return Vi(`div`,{class:`table-responsive`},Vi(`table`,{class:`table`},Vi(`thead`,null,Vi(`tr`,null,...n)),Vi(`tbody`,null,...r)))}function j8(e){return e===null?`text`:y8.includes(e.toLowerCase())?`razor`:v8.includes(e)?e:`text`}function M8(e){let t=Vi(`pre`,{class:`wui-code-source`},Vi(`code`,null,e.text));return Vi(`wui-code-block`,{class:`wui-code-block`,language:j8(e.language)},t)}function N8(e,t){return P8(e,U6(t,{isCitation:e.isCitation}))}function P8(e,t){return t.flatMap(t=>F8(e,t))}function F8(e,t){switch(t.type){case`code`:return[Vi(`code`,null,t.text)];case`strong`:return[Vi(`strong`,null,...P8(e,t.children))];case`em`:return[Vi(`em`,null,...P8(e,t.children))];case`strike`:return[Vi(`del`,null,...P8(e,t.children))];case`image`:return[document.createTextNode(`[`),...P8(e,t.children),document.createTextNode(`]`)];case`link`:return L8(e,t);case`citation`:return[z8(t.text)];case`text`:return e.figureText?R8(e.figureText,t.text):[document.createTextNode(t.text)];default:return[document.createTextNode(I8(t))]}}function I8(e){let t=e;return typeof t==`object`&&t&&`text`in t?String(t.text):`undefined`}function L8(e,t){let n=P8(e,t.children),r=Z6(t.href,e.links,e.resolveLink,globalThis.location?.origin,e.base);if(!r)return n;if(r.kind===`app`){let e=t8(r.target);return e?[B8(e,n,!1)]:n}return[B8(r.href,n,r.kind===`web`)]}function R8(e,t){return e(t).map(e=>e.kind===`sub`||e.kind===`sup`?Vi(e.kind,null,e.text):document.createTextNode(e.text))}function z8(e){let t=Vi(`span`,{class:`chip-label`},e),n=Vi(`button`,{type:`button`,class:`chip-body`,"aria-label":e},t);return n.addEventListener(`click`,()=>{n.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:e}}))}),Vi(`span`,{class:`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,"data-wui":`AppChip`},n)}function B8(e,t,n){let r=Vi(`span`,{class:`wui-link__label`},...t);return Vi(`a`,{class:`wui-link wui-link--static`,"data-wui":`AppLink`,href:e,target:n?`_blank`:void 0,rel:n?`noopener noreferrer`:void 0},r)}L3(`wui-markdown`,w8);var V8=`AppButton`,H8=new Set([`primary`,`success`,`warning`,`danger`,`info`,`neutral`]),U8={solid:e=>`btn-${e}`,soft:e=>`btn-soft-${e}`,outline:e=>`btn-outline-${e}`,ghost:e=>`btn-ghost-${e}`,link:e=>`btn-link-${e}`,glass:()=>`btn-glass`};function W8(e){return $i(U8,e)}function G8(e=`primary`,t=`solid`,n=`md`){if(!H8.has(e))throw RangeError(`buttonClass: unknown tone "${e}"`);if(!W8(t))throw RangeError(`buttonClass: unknown variant "${t}"`);let r=U8[t](e);return n===`md`?`btn ${r}`:`btn ${r} btn-${n}`}var K8={copiedLabel:`Copied`,copyLabel:`Copy`,label:`Code`};Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`]);var q8=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,razor:`Razor`,css:`CSS`}),J8=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),Y8=`(?![\\s\\S])`,X8=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${Y8})`).source,Z8=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,J8([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],Q8=[[`comment`,RegExp(`//[^\\n]*|${X8}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,J8(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,J8([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],$8=[[`comment`,RegExp(`//[^\\n]*|${X8}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,J8(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,J8([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],e5=[[`comment`,RegExp(`--[^\\n]*|${X8}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,J8(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,J8([`true`,`false`])],[`type`,J8([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],t5=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,J8([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,J8(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],n5=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],r5=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${Y8})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],i5={json:Z8,js:Q8,cs:$8,sql:e5,bash:t5,http:n5,css:[[`comment`,new RegExp(X8)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:r5,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},a5=e=>$i(i5,e),o5=new Map;function s5(e){let t=o5.get(e);if(!t){let n=i5[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},o5.set(e,t)}return t}function c5(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function l5(e,t,n=[]){let{re:r,types:i}=s5(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;c5(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?l5(`htmlTag`,r,n):c5(n,i[s]??`plain`,r),a=o.index+r.length}return c5(n,`plain`,t.slice(a)),n}function u5(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return l5(`http`,e);let n=t[0]??``,r=l5(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?l5(`json`,i,r):a===`<`?l5(`html`,i,r):(c5(r,`plain`,i),r)}function d5(e,t){let n=String(e??``);if(!n||n.length>1e5)return n?[[`plain`,n]]:[];if(t===`http`)return u5(n);let r=t===`razor`?`html`:t;return!a5(r)||r===`htmlTag`?[[`plain`,n]]:l5(r,n)}function f5(e,t){let n=[],r=[n];for(let[i,a]of d5(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}var p5=()=>Mi(`codeBlock`,K8);function m5(e){return $i(q8,e)}var h5=class extends z3{_title;_view;_codeEl;_copyIcon;_copyText;_chrome=null;_copied=!1;_observer=null;_timer=0;_cancelFrame=null;constructor(){super();let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=t!==null&&m5(t)?t:`text`,r=this.getAttribute(`label`)||``,i=f5(this._code(),n);this._title.textContent=r||q8[n],this._view.setAttribute(`aria-label`,r||p5().label),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>g5(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`;let n=e.createElement(`button`);return n.type=`button`,n.className=`${G8(`primary`,`ghost`,`sm`)} wui-code-copy`,n.dataset.wui=V8,n.setAttribute(`aria-live`,`polite`),this._setCopied(!1),n.append(this._copyIcon,this._copyText),n.addEventListener(`click`,async()=>{await zi(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),2e3))}),t.append(this._title,n),t}_setCopied(e){this._copied=e;let t=To(e?`check`:`files`,{size:14});this._copyIcon.replaceChildren(...t?[t]:[]),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||p5().copiedLabel:this.getAttribute(`copy-label`)||p5().copyLabel}};function g5(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}L3(`wui-code-block`,h5);var _5=new Set([`Visitor`,`Customer`]),v5=/^\d+$/;function y5(e,t){return e?.features?.Sources===!0?typeof e?.isCitation==`function`?e.isCitation(t):v5.test(t):!1}function b5(e,t){if(Dr(e,t?.handoffHosts))return e;let n=t?.resolveLink?.(e);return typeof n==`string`&&n!==``?n:null}function x5(e,t){let n=globalThis.location?.origin;for(let r of e.querySelectorAll(`a[href]`)){let e=r.dataset.linkSource??r.getAttribute(`href`)??``;r.dataset.linkSource=e;let i=b5(e,t);i===null?r.replaceWith(r.ownerDocument.createTextNode(r.textContent??``)):(i!==r.getAttribute(`href`)&&r.setAttribute(`href`,i),Ln(i,`web`,void 0,n)?.kind===`web`?(r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`)):(r.removeAttribute(`target`),r.removeAttribute(`rel`)))}}function S5(e,t){x5(e,t)}Yo(`wui-chat-part-text`,class extends Jo{#e=null;#t=null;#n=!1;#r=null;constructor(){super(),this.addEventListener(`wui-markdown-citation`,e=>{let t=this.turn;typeof t?.openCitation==`function`&&t.openCitation(Number(e.detail.citation))}),this.addEventListener(`click`,e=>this.#a(e))}renderPart(e,t,n){let r=_5.has(t.author.kind)?`plain`:`markdown`,i=this.#e;if((i===null||i.mode!==r)&&(i=r===`plain`?{mode:r,node:this.#s()}:this.#c(e.text),this.#e=i,this.#t=null,this.replaceChildren(i.node)),i.mode===`plain`){let t=this.turn?.features?.FigureText===!0,n=JSON.stringify([e.text,t]);n!==this.#t&&(this.#t=n,i.node.replaceChildren(),t?M4(i.node,vn(e.text)):i.node.append(this.ownerDocument.createTextNode(e.text)))}else this.#o(i.node),i.source.textContent!==e.text&&(i.source.textContent=e.text);this.toggleAttribute(`data-streaming`,t.streaming===!0),this.#n||(this.#n=!0,this.closest(`[data-restored]`)||this.classList.add(`wui-chat-part-enter`)),this.#i()}disposePart(){this.#r?.disconnect(),this.#r=null}#i(){this.#r||(this.#r=new MutationObserver(()=>S5(this,this.turn)),this.#r.observe(this,{childList:!0,subtree:!0,characterData:!0}),S5(this,this.turn))}#a(e){let t=e.target instanceof Element?e.target.closest(`a[href]`):null,n=this.turn;if(!t||!this.contains(t))return;let r=t.getAttribute(`href`)??``;r.startsWith(`#`)||(r.startsWith(`/`)&&typeof n?.onNavigate==`function`?(e.preventDefault(),n.onNavigate(r)):typeof n?.openTarget==`function`&&(e.preventDefault(),n.openTarget(r)))}#o(e){let t=this.turn?.features?.FigureText===!0?vn:void 0;e.figureText!==t&&(e.figureText=t)}#s(){return P(this.ownerDocument,`div`,`wui-chat-bubble`)}#c(e){let t=this.ownerDocument,n=P(t,`wui-markdown`,`wui-markdown wui-chat-text`);n.setAttribute(`links`,`web`),n.setAttribute(`headings`,`text`),n.isCitation=e=>y5(this.turn,e);let r=P(t,`pre`,`wui-markdown-source`,e);return n.append(r),{mode:`markdown`,node:n,source:r}}}),Yo(`wui-chat-part-ticket`,class extends Jo{renderPart(e,t,n){let{labels:r}=n,i=$(`article`,`wui-chat-ticket`,{"aria-label":r.ticketAria(e.number)}),a=$(`div`,`wui-chat-ticket-head`),o=$(`span`,`wui-chat-ticket-number`);o.textContent=r.ticketAria(e.number),a.append(o);let s=T3(e.status);if(s!==null){let t=$(`span`,`wui-chat-ticket-badge wui-chat-ticket-badge--${s}`);t.textContent=E3(e.status,r),a.append(t)}let c=$(`strong`,`wui-chat-ticket-title`);if(c.textContent=e.subject,i.append(a,c),typeof n.openTicket==`function`){let t=$(`div`,`wui-chat-ticket-foot`),a=$(`button`,`wui-chat-ticket-link`,{type:`button`});a.textContent=r.ticketView,a.addEventListener(`click`,()=>{let{openTicket:t}=n;if(t===void 0)throw Error(`${this.localName} lost openTicket after it drew the link`);t.call(n,{ticketId:e.ticketId,number:e.number})}),t.append(a),i.append(t)}this.replaceChildren(i)}});var C5=`http://www.w3.org/2000/svg`,w5={mic:`M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.92V21h2v-2.08A7 7 0 0 0 19 12z`,stop:`M6 6h12v12H6z`,play:`M8 5v14l11-7z`,pause:`M6 5h4v14H6zm8 0h4v14h-4z`,speaker:`M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z`};function T5(e,t=18){if(!Q4(w5,e))throw Error(`Unknown voice icon "${e}".`);let n=document.createElementNS(C5,`svg`);n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),n.setAttribute(`fill`,`currentColor`);let r=document.createElementNS(C5,`path`);return r.setAttribute(`d`,w5[e]),n.append(r),n}var E5=40,D5=null;function O5(e){let t=P(document,`span`,`wui-chat-clip-bar`);return t.style.setProperty(`--wui-chat-bar-height`,`${Math.round(e*100)}%`),t}function k5(e,t){e.replaceChildren(...wi(t,E5).map(O5))}Yo(`wui-chat-part-voice-clip`,class extends Jo{#e=null;#t=!1;#n=0;#r=0;#i=!1;#a=null;#o=null;#s=null;#c=0;#l=!1;renderPart(e,t,n){if(!n.features.VoiceClips){this.#u(e.transcript);return}let r=this.#e??this.#d(e.attachmentId);e.attachmentId!==r.attachmentId&&(this.disposePart(),r.attachmentId=e.attachmentId,this.#r=0,k5(r.wave,e.attachmentId)),this.#n=e.durationMs,this.#f(r,e)}disposePart(){this.#c+=1,this.#a?.pause(),this.#s!==null&&URL.revokeObjectURL(this.#s),D5===this&&(D5=null),this.#a=null,this.#o=null,this.#s=null,this.#i=!1}#u(e){if(this.disposePart(),this.#e=null,typeof e==`string`&&e!==``){let t=P(document,`p`,`wui-chat-clip-transcript`);t.textContent=e,this.replaceChildren(t)}else this.replaceChildren()}#d(e){let t=P(document,`div`,`wui-chat-clip`);t.setAttribute(`role`,`group`);let n=P(document,`div`,`wui-chat-clip-row`),r=P(document,`button`,`wui-chat-clip-play`);r.type=`button`;let i=P(document,`div`,`wui-chat-clip-wave`);i.setAttribute(`aria-hidden`,`true`);let a=P(document,`span`,`wui-chat-clip-time`);n.append(r,i,a);let o=P(document,`p`,`wui-chat-clip-error`);o.setAttribute(`role`,`status`),o.hidden=!0,t.append(n,o);let s={attachmentId:e,root:t,play:r,wave:i,time:a,error:o,transcript:null};return r.addEventListener(`click`,()=>this.#C(s)),k5(i,e),this.#e=s,this.replaceChildren(t),s}#f(e,t){let n=this.activeTurn.labels;e.root.setAttribute(`aria-label`,n.voiceClip),e.play.disabled=this.#l||typeof this.activeTurn.readAttachment!=`function`,this.#p(e),this.#m(e),this.#h(e,t.transcript)}#p(e){let t=this.activeTurn.labels,n=this.#i?t.voiceClipPause:t.voiceClipPlay;e.play.setAttribute(`aria-label`,n),e.play.title=n,e.play.replaceChildren(T5(this.#i?`pause`:`play`,18))}#m(e){let t=this.#n/1e3,n=t>0?Math.min(1,this.#r/t):0,r=Math.floor(n*E5);[...e.wave.children].forEach((e,t)=>{e.classList.toggle(`wui-chat-clip-bar--played`,t<r)});let i=Ti(Math.max(1,Math.round(t)));e.time.textContent=this.activeTurn.labels.voiceClipTime(Ti(this.#r),i)}#h(e,t){if(typeof t!=`string`||t===``){e.transcript?.toggle.remove(),e.transcript?.text.remove(),e.transcript=null;return}let n=e.transcript??this.#g(e);n.text.textContent=t,this.#_(n)}#g(e){let t=P(document,`button`,`wui-chat-clip-toggle`);t.type=`button`;let n=P(document,`p`,`wui-chat-clip-transcript`);n.hidden=!this.#t;let r={toggle:t,text:n};return t.addEventListener(`click`,()=>{this.#t=!this.#t,n.hidden=!this.#t,this.#_(r)}),e.transcript=r,e.root.append(t,n),r}#_(e){let t=this.activeTurn.labels;e.toggle.setAttribute(`aria-expanded`,String(this.#t)),e.toggle.textContent=this.#t?t.voiceClipHideTranscript:t.voiceClipShowTranscript}#v(e){return this.#o??=this.#y(e).catch(e=>{throw this.#o=null,e}),this.#o}async#y(e){let t=this.#c,{readAttachment:n}=this.activeTurn;if(n===void 0)throw Error(`${this.localName} loaded a clip on a turn without readAttachment`);let i=await n.call(this.activeTurn,e.attachmentId),a=URL.createObjectURL(new Blob([i],{type:r(i)}));if(t!==this.#c)return URL.revokeObjectURL(a),null;this.#s!==null&&URL.revokeObjectURL(this.#s),this.#s=a;let o=new Audio(this.#s);return o.addEventListener(`timeupdate`,()=>{this.#r=o.currentTime,this.#m(e)}),o.addEventListener(`ended`,()=>{this.#r=0,this.#b(),this.#m(e)}),o.addEventListener(`error`,()=>{this.#b(),this.#o=null,this.#S(e)}),this.#a=o,o}#b(){this.#a?.pause(),this.#x(!1)}#x(e){this.#i=e,e?(D5&&D5!==this&&D5.#b(),D5=this):D5===this&&(D5=null);let t=this.#e;t!==null&&this.#p(t)}#S(e){e.error.textContent=this.activeTurn.labels.voiceClipFailed,e.error.hidden=!1}async#C(e){if(this.#i)this.#b();else{e.error.hidden=!0,this.#l=!0,e.play.disabled=!0,e.play.setAttribute(`aria-busy`,`true`);try{let t=await this.#v(e);if(t===null)return;this.#x(!0),await t.play()}catch{this.#b(),this.#o=null,this.#S(e)}finally{this.#l=!1,e.play.removeAttribute(`aria-busy`),e.play.disabled=typeof this.activeTurn.readAttachment!=`function`}}}});var A5={Text:`wui-chat-part-text`,Sources:`wui-chat-part-sources`,QuickReplies:`wui-chat-part-quick-replies`,InputRequest:`wui-chat-part-input-request`,Action:`wui-chat-part-action`,Notice:`wui-chat-part-notice`,Table:`wui-chat-part-table`,Chart:`wui-chat-part-chart`,Figures:`wui-chat-part-figures`,RecordCard:`wui-chat-part-record-card`,Image:`wui-chat-part-image`,File:`wui-chat-part-file`,Ticket:`wui-chat-part-ticket`,Handoff:`wui-chat-part-handoff`,VoiceClip:`wui-chat-part-voice-clip`},j5=n({SpeechConfig:()=>void 0}),M5=t((()=>{})),N5=1e4,P5=2e3,F5=3e5,I5=new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),L5=new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function R5(e){return I5.has(B5(e,`name`))?new Jt(`Blocked`,{message:V5(e)}):L5.has(B5(e,`name`))?new Jt(`NoMicrophone`,{message:V5(e)}):z5(e)}function z5(e){return e instanceof Jt?e:new Jt(`Failed`,{message:V5(e)??String(e)})}function B5(e,t){return typeof e==`object`&&e||typeof e==`function`?Reflect.get(e,t):void 0}function V5(e){let t=B5(e,`message`);return t==null?void 0:String(t)}function H5(e){return typeof e==`object`&&!!e}function U5(e){let t=B5(e,`SpeechConfig`),n=B5(e,`AudioConfig`),r=B5(e,`NoMatchDetails`);return typeof B5(t,`fromAuthorizationToken`)==`function`&&typeof B5(n,`fromDefaultMicrophoneInput`)==`function`&&typeof B5(n,`fromSpeakerOutput`)==`function`&&typeof B5(r,`fromResult`)==`function`&&typeof B5(e,`SpeechRecognizer`)==`function`&&typeof B5(e,`SpeakerAudioDestination`)==`function`&&typeof B5(e,`SpeechSynthesizer`)==`function`&&H5(B5(e,`PropertyId`))&&H5(B5(e,`ResultReason`))&&H5(B5(e,`NoMatchReason`))&&H5(B5(e,`CancellationReason`))}function W5(e){if(!U5(e))throw new Jt(`Unavailable`,{message:`Speech is not available in this browser.`});return e}var G5=null;function K5(){let e=globalThis,t=`SpeechSDK`in e?e.SpeechSDK:void 0;return t?Promise.resolve(W5(t)):(G5===null&&(G5=Promise.resolve().then(()=>(M5(),j5)).then(e=>W5(B5(e,`SpeechConfig`)?e:B5(e,`default`))).catch(e=>{throw G5=null,e})),G5)}function q5(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function J5(e){let t=e.getToken,n=e.loadSdk??K5,r=e.getLanguage??q5,i=typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`,a=typeof window<`u`&&window.isSecureContext===!0,o=i&&a,s=typeof window<`u`,c=null,l=null,u=null;function d(){return c!==null&&Date.parse(c.expiresDateTimeUtc)-Date.now()>6e4?Promise.resolve(c):(l===null&&(l=Promise.resolve().then(()=>t()).then(e=>(c=e,l=null,e),e=>{throw l=null,z5(e)})),l)}function f(){return u===null&&(u=Promise.resolve().then(()=>n()).then(e=>{if(!e?.SpeechConfig)throw new Jt(`Unavailable`,{message:`Speech is not available in this browser.`});return e}).catch(e=>{throw u=null,z5(e)})),u}function p(e={}){let{signal:t,onText:n,onEnd:i}=e;if(t?.aborted)return i?.(),Promise.resolve();let a=()=>{},s=()=>{},c=new Promise((e,t)=>{a=e,s=t}),l=!1,u=!1,p=null,m=!1,h=``,g=[],_,v,y,b=()=>{clearTimeout(_),clearTimeout(v),clearTimeout(y)},x=e=>{if(!l){l=!0,b(),t?.removeEventListener(`abort`,S);try{p?.close()}finally{try{i?.()}finally{e?s(e):a()}}}};async function S(){if(!(l||u)){u=!0,b();try{let e=p;e!==null&&await new Promise(t=>e.stopContinuousRecognitionAsync(()=>t(),()=>t()))}finally{x(null)}}}let C=()=>[...g,h].filter(e=>e!==``).join(` `).trim(),w=(e,t)=>{m||(m=!0,clearTimeout(_)),clearTimeout(v),v=setTimeout(S,P5),n?.(C(),t)};async function T(){if(t?.addEventListener(`abort`,S),!o){x(new Jt(`Unavailable`,{message:`Dictation is not available in this browser.`}));return}let n;try{n=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){x(R5(e));return}for(let e of n.getTracks())e.stop();if(!l)try{let t=await f(),n=await d();if(l)return;let i=t.SpeechConfig.fromAuthorizationToken(n.token,n.region);i.speechRecognitionLanguage=e.language||r(),i.setProperty(t.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(N5));let a=new t.SpeechRecognizer(i,t.AudioConfig.fromDefaultMicrophoneInput());if(p=a,a.recognizing=(e,t)=>{if(l)return;let n=t.result?.text;n&&(h=n,w(n,!1))},a.recognized=(e,n)=>{if(l)return;let{reason:r,text:i}=n.result;r===t.ResultReason.RecognizedSpeech&&i?(g.push(i),h=``,w(i,!0)):r===t.ResultReason.NoMatch&&t.NoMatchDetails.fromResult(n.result).reason===t.NoMatchReason.InitialSilenceTimeout&&x(new Jt(`NoSpeech`,{message:`No speech was heard.`}))},a.canceled=(e,n)=>{l||(n.reason===t.CancellationReason.Error?x(new Jt(`Failed`,{message:n.errorDetails})):x(null))},a.sessionStopped=()=>x(null),await new Promise((e,t)=>a.startContinuousRecognitionAsync(()=>e(),t)),l)return;e.onStarted?.(),_=setTimeout(()=>{m||x(new Jt(`NoSpeech`,{message:`No speech was heard.`}))},N5),y=setTimeout(S,F5)}catch(e){x(z5(e))}}return T(),c}async function m(e,t={}){let{signal:n}=t;if(!n?.aborted)try{let i=await f(),a=await d();if(n?.aborted)return;let o=i.SpeechConfig.fromAuthorizationToken(a.token,a.region);o.speechSynthesisLanguage=t.language||r();let s=new i.SpeakerAudioDestination,c=new i.SpeechSynthesizer(o,i.AudioConfig.fromSpeakerOutput(s));await new Promise((t,r)=>{let a=!1,o=()=>{n?.removeEventListener(`abort`,d),c.close(),s.close()},l=()=>{a||(a=!0,o(),t())},u=e=>{a||(a=!0,o(),r(z5(e)))};function d(){s.pause(),l()}n?.addEventListener(`abort`,d),s.onAudioEnd=l;try{c.speakTextAsync(e,e=>{e.reason!==i.ResultReason.SynthesizingAudioCompleted&&u(new Jt(`Failed`,{message:`The reply could not be synthesised.`}))},e=>u(e))}catch(e){u(e)}})}catch(e){throw z5(e)}}return{dictation:o,readAloud:s,streamsText:!0,startDictation:p,speak:m}}var Y5=8e3,X5=6e3,Z5=new Set([`Blocked`,`NoMicrophone`]);function Q5(e){let t=e instanceof Jt?e.code:`Failed`;return{code:t,source:`Dictation`,sticky:Z5.has(t)}}function $5(e){let t=fr(e.filter(e=>e.kind===`Text`)).replace(/ ?\[\d+\]/g,``).replace(/\s+/g,` `).trim();if(t.length<=6e3)return t;let n=t.slice(0,X5),r=n.lastIndexOf(`. `);return r===-1?n.trim():n.slice(0,r+1)}function e7(e,t){switch(e.code){case`Blocked`:return t.dictationBlocked;case`NoMicrophone`:return t.dictationNoMicrophone;case`NoSpeech`:return t.dictationNotHeard;case`Unavailable`:return t.dictationUnavailable;case`Failed`:return t.dictationFailed;case`SpeakFailed`:return t.readAloudFailed;default:throw Error(`Unknown voice note code "${e.code}".`)}}function t7(e){let t=e.getState,n=e.speech??J5({getToken:e.getToken}),r=`Idle`,i=null,a=null,o=null,s=null,c=0,l=null,u=new Set,d=()=>({mode:r,messageId:i,startedAtMs:a,note:o});function f(){let e=d();for(let t of[...u])t(e)}function p(e){r=e.mode,i=e.messageId??null,a=e.startedAtMs??null,f()}function m(){l!==null&&clearTimeout(l),l=null}function h(e){m(),o=e,e&&!e.sticky&&(l=setTimeout(()=>{l=null,o=null,f()},Y5)),f()}function g(){o!==null&&(m(),o=null,f())}function _(){c+=1;let e={id:c,controller:new AbortController,stopped:!1};return s=e,e}function v(e){s===e&&(s=null,p({mode:`Idle`}))}function y(){let e=s;s=null,e&&(e.stopped=!0,e.controller.abort()),r!==`Idle`&&p({mode:`Idle`})}function b(){let e=t();return!!(e.features.Dictation&&e.profile?.speechAvailable&&n.dictation)}function x(){let e=t();return!!(e.features.ReadAloud&&e.profile?.speechAvailable&&n.readAloud)}async function S(e){if(r===`Dictating`){y();return}if(y(),h(null),!b())return;let t=e.getText(),i=t!==``&&!/\s$/.test(t)?`${t} `:t,a=_();p({mode:`Dictating`});try{await n.startDictation({signal:a.controller.signal,onText:t=>{s===a&&e.setText(i+t)},onEnd:()=>v(a)})}catch(e){if(a.stopped)return;v(a),h(Q5(e))}}async function C(e,t){if(r===`Speaking`&&i===e){y();return}y(),h(null);let a=$5(t);if(a===``)return;let o=_();p({mode:`Speaking`,messageId:e});try{await n.speak(a,{signal:o.controller.signal}),v(o)}catch{if(o.stopped)return;v(o),h({code:`SpeakFailed`,source:`ReadAloud`,sticky:!1,messageId:e})}}function w(e){return u.add(e),()=>{u.delete(e)}}function T(){y(),m(),o=null,u.clear()}return{canDictate:b,canSpeak:x,getStatus:d,subscribe:w,toggleDictation:S,toggleSpeak:C,stop:y,dismissNote:g,destroy:T}}var n7=new Set([`Shift`,`Control`,`Alt`,`Meta`,`Escape`]);function r7(e,t){e.isTrusted&&!n7.has(e.key)&&t.getStatus().mode===`Dictating`&&t.stop()}function i7({voice:e,getLabels:t,textarea:n,onTextChanged:r}){let i=null,a=$(`button`,`wui-chat-tool wui-chat-mic`,{type:`button`});a.append(T5(`mic`,20)),a.hidden=!0,a.addEventListener(`click`,()=>{e.toggleDictation({getText:()=>n.value,setText:e=>{n.value=n.maxLength>0?e.slice(0,n.maxLength):e,r(),n.setSelectionRange(n.value.length,n.value.length)}})});let o=$(`p`,`wui-chat-voice-note`,{role:`status`});o.hidden=!0;let s=$(`span`,`visually-hidden`,{"aria-live":`polite`});function c(e){let n=t(),r=e.note?.source===`ReadAloud`?null:e.note,i=e.mode===`Dictating`,c=i?n.dictateStop:n.dictate;a.setAttribute(`aria-pressed`,String(i)),a.setAttribute(`aria-label`,c),a.title=c;let l=r?.code===`Blocked`||r?.code===`NoMicrophone`;r===null?(o.hidden=!0,o.textContent=``):(o.hidden=!1,o.textContent=e7(r,n),o.setAttribute(`role`,r.sticky?`alert`:`status`)),o.classList.toggle(`wui-chat-voice-note--blocked`,l),s.textContent=i?n.dictateListening:``}function l(t){let{state:n}=t;a.hidden=!e.canDictate();let r=e.getStatus().mode===`Speaking`,i=n.messagesLeftToday===0;a.disabled=i||r||n.handoffPause===!0}function u(e){c(e),i!==null&&l(i)}let d=e.subscribe(u);function f(t){i=t,l(t),c(e.getStatus())}function p(){d()}return{buttons:[a],note:o,announcer:s,paint:f,destroy:p}}var a7=10,o7=.9,s7=0;function c7(e){for(let t of e.toReversed())for(let e of t.parts.toReversed())if(e.kind===`InputRequest`&&e.state===`Open`)return e.fields[0]?.label??e.title??null;return null}function l7(e){s7+=1;let t=`wui-chat-composer-hint-${s7}`,n=$(`p`,`wui-chat-allowance`,{role:`status`});n.hidden=!0;let r=$(`span`),i=$(`button`,`btn btn-ghost-primary btn-sm wui-chat-action-btn`,{type:`button`});i.addEventListener(`click`,()=>e.onCancelEdit());let a=$(`div`,`wui-chat-editing`);a.hidden=!0,a.append(r,i);let o=$(`div`,`wui-chat-attachments`);o.hidden=!0;let s=$(`button`,`wui-chat-tool`,{type:`button`});s.append($4(`paperclip`,20)),s.hidden=!0;let c=$(`input`,null,{type:`file`,multiple:``,tabindex:`-1`});c.hidden=!0,c.addEventListener(`change`,()=>{let t=[...c.files??[]];c.value=``,t.length>0&&e.onAttach(t)}),s.addEventListener(`click`,()=>c.click());let l=$(`textarea`,`wui-chat-input`,{rows:`1`,"aria-describedby":t}),u=$(`span`,`visually-hidden`,{id:t}),d=$(`span`,`wui-chat-counter`);d.hidden=!0;let f=$(`button`,`wui-chat-send`,{type:`submit`});f.append($4(`arrow-up`,18));let p=$(`button`,`wui-chat-send wui-chat-send--stop`,{type:`button`});p.append($4(`stop`,16)),p.hidden=!0,p.addEventListener(`click`,()=>e.onStop());let m=$(`form`,`wui-chat-composer`);m.append(s,c,l,d,u,p,f);let h=e.mark?.(`input`,`rest`)??null,g=null,_=null,v=null,y=0,b=null;function x(){l.style.height=`auto`,l.style.height=`${l.scrollHeight}px`;let e=getComputedStyle(l),t=l.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom);m.classList.toggle(`wui-chat-composer--multiline`,t>(parseFloat(e.lineHeight)||22)*1.5)}function S(){return b?.attachments.some(e=>e.status===`Uploading`)??!1}function C(){return b?.attachments.some(e=>e.status===`Ready`)??!1}function w(){let e=l.value.length,t=y>0&&e>y*o7;d.hidden=!t,t&&v&&(d.textContent=v.counter(e,y))}function T(){let e=b?.messagesLeftToday??null,t=l.value.trim()===``&&!C();f.disabled=!!b?.streaming||e===0||S()||t||b?.handoffPause===!0,m.classList.toggle(`wui-chat-composer--has-text`,!t)}function E(){if(f.disabled)return;let t=l.value.trim();l.value=``,x(),w(),T(),e.voice?.stop(),e.voice?.dismissNote(),e.onSubmit(t)}l.addEventListener(`input`,()=>{x(),w(),T(),l.value!==``&&e.onTyping?.()}),l.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),E())}),m.addEventListener(`submit`,e=>{e.preventDefault(),E()});let D=e.voice,O=D?i7({voice:D,getLabels:()=>{if(v===null)throw Error(`composer labels are read before the first render`);return v},textarea:l,onTextChanged:()=>{x(),w(),T()}}):null;if(D&&O){let e=O.buttons[0];e&&m.insertBefore(e,f),l.addEventListener(`keydown`,e=>r7(e,D))}function k(t,n){let r=t.map(t=>{let r=$(`span`,`wui-chat-chip`),i=$(`span`,null,t.status===`Failed`?{title:t.error??``}:null);i.textContent=t.fileName;let a=$(`button`,`wui-chat-chip-remove`,{type:`button`,"aria-label":n.removeAttachment(t.fileName)});a.append($4(`x`,14)),a.addEventListener(`click`,()=>e.onRemove(t.key));let o=[];if(t.status===`Uploading`){let e=$(`progress`,`wui-chat-chip-progress`,{max:`1`});typeof t.progress==`number`&&(e.value=t.progress);let r=$(`span`,`wui-chat-chip-status`);r.textContent=n.attachmentUploading,o.push(e,r)}if(t.status===`Failed`){let e=$(`span`,`wui-chat-chip-error`,{"aria-live":`polite`});e.textContent=t.error||n.attachmentFailed,o.push(e)}return r.append(i,...o,a),r});o.replaceChildren(...r),o.hidden=r.length===0}function A(t){b=t.state,v=t.labels,y=t.maxLength,t.sendIcon&&f.dataset.icon!==t.sendIcon&&(f.dataset.icon=t.sendIcon,f.replaceChildren($4(t.sendIcon,18)));let o=b.messagesLeftToday;m.setAttribute(`aria-label`,v.composer),u.textContent=v.composerHint,l.setAttribute(`aria-label`,v.composer),l.maxLength=y,l.placeholder=b.handoffPause?v.handoffMoment:c7(b.messages)??v.placeholder,l.disabled=o===0||b.handoffPause===!0,n.hidden=!(o!==null&&o<=a7),!n.hidden&&o!==null&&(n.textContent=v.allowance(o));let d=b.editing?.messageId??null;if(d!==g){let t=g!==null;g=d,b.editing?(e.voice?.stop(),l.value=b.editing.text,x()):t&&(l.value=``,x())}a.hidden=!b.editing,r.textContent=v.editing,i.textContent=v.cancel;let S=t.draft??null;typeof S==`string`&&S!==``&&S!==_&&(_=S,l.value=S,l.dispatchEvent(new Event(`input`)),l.focus(),e.onDraftApplied?.()),k(b.attachments,v);let C=b.features.Attachments&&(b.profile?.limits.maxAttachments??0)>0&&b.handoffPause!==!0;s.hidden=!C,s.setAttribute(`aria-label`,v.attach),s.title=v.attachHint,c.accept=t.accept??``;let E=b.streaming&&b.features.Stop===!0;p.hidden=!E,p.setAttribute(`aria-label`,v.stop),f.hidden=E,f.setAttribute(`aria-label`,v.send),w(),T(),h!==null&&(h.dataset.state=t.busy===!0?`busy`:`rest`,t.inputMark===`Avatar`?h.parentNode!==m&&m.insertBefore(h,l):h.remove()),O?.paint({state:b})}function j(){l.focus()}function M(){O?.destroy();for(let e of ee)e.remove()}let ee=[n,a,o,...O?[O.note,O.announcer]:[],m];return{nodes:ee,paint:A,focus:j,destroy:M,getDraft:()=>l.value}}var u7=`https://policies.google.com/privacy`,d7=`https://policies.google.com/terms`;function f7(e,t){let n=$(`a`,`wui-chat-footer-link`,{href:t,target:`_blank`,rel:`noopener noreferrer`});return n.textContent=e,n}function p7(){let e=$(`p`,`wui-chat-footer`);e.hidden=!0;function t(t){let{labels:n,profile:r,hideDisclaimer:i}=t,a=[];if(r){if(!i){let e=$(`span`,`wui-chat-footer-text`);e.textContent=r.footer.disclaimer||n.disclaimer,a.push(e)}let{privacyText:e}=r.footer,t=Nr(r.footer.privacyUrl)?r.footer.privacyUrl:null;if(t){let r=$(`span`,`wui-chat-footer-privacy`),i=$(`a`,`wui-chat-footer-link`,{href:t});i.textContent=e||n.footerPrivacyFallback,r.append(i),a.push(r)}else if(e){let t=$(`span`,`wui-chat-footer-privacy`);t.textContent=e,a.push(t)}if(r.footer.assuranceText){let e=$(`span`);e.textContent=r.footer.assuranceText,a.push(e)}if(Le(r)){let e=$(`span`,`wui-chat-footer-captcha`),t=$(`span`,`wui-chat-footer-captcha-tail`);t.append(f7(n.captchaPrivacyPolicy,u7),document.createTextNode(n.captchaNoticeAnd),f7(n.captchaTerms,d7),document.createTextNode(n.captchaNoticeAfter)),e.append(document.createTextNode(n.captchaNoticeBefore),t),a.push(e)}}e.replaceChildren(...a),e.hidden=a.length===0}return{el:e,paint:t}}function m7(e,t,n){e.setAttribute(`aria-label`,t),e.title=t,e.dataset.icon!==n&&(e.dataset.icon=n,e.replaceChildren($4(n,20)))}function h7(e){let t=e.mark?.(`header`,`rest`)??$(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),n=$(`strong`,`wui-chat-title`);e.titleId&&(n.id=e.titleId);let r=$(`span`,`wui-chat-tagline`),i=$(`span`,`wui-chat-status`),a=$(`div`,`wui-chat-header-text`);a.append(n,r,i);let o=$(`span`,`wui-chat-header-conversation`);o.hidden=!0;let s=n3(``,`history`,()=>e.onHistory()),c=n3(``,`volume-high`,()=>e.onMute()),l=n3(``,`plus`,()=>e.onNew()),u=n3(``,`maximize-4`,()=>e.onSwitch());u.classList.add(`wui-chat-switch-btn`,`wui-chat-switch-btn--full`);let d=n3(``,`panel-left-open`,()=>e.onSwitch());d.classList.add(`wui-chat-switch-btn`,`wui-chat-switch-btn--side`);let f=n3(``,`x`,()=>e.onClose());f.classList.add(`wui-chat-close-btn`);let p=$(`div`,`wui-chat-header-actions`);p.append(o,s,c,l,u,d,f);let m=$(`header`,`wui-chat-header`);m.append(t,a,p);function h(e){let{labels:t}=e;m.hidden=!1,n.textContent=e.title??``,r.textContent=e.tagline??``,r.hidden=!e.tagline,i.textContent=e.status??``,s.hidden=!e.showHistory,e.viewingHistory?m7(s,t.backToChat,`arrow-left`):m7(s,t.history,`history`),c.hidden=!e.showMute,m7(c,e.muted?t.unmuteSounds:t.muteSounds,e.muted?`volume-mute`:`volume-high`),l.hidden=!!e.viewingHistory||e.showNew===!1,l.disabled=!e.canNew,m7(l,t.newChat,`plus`),u.hidden=e.switchTo!==`full-page`,u.disabled=!e.canSwitch,m7(u,t.openFullScreen,`maximize-4`),d.hidden=e.switchTo!==`docked`,d.disabled=!e.canSwitch,m7(d,t.openSidePanel,`panel-left-open`),f.hidden=!e.showClose,m7(f,t.close,`x`)}return{el:m,conversation:o,paint:h}}var g7=120;function _7(e,t,n=`outline`){let r=$(`button`,`${e3(n,`sm`)} wui-chat-action-btn`,{type:`button`});return r.textContent=e,r.addEventListener(`click`,t),r}function v7(e){let t=$(`div`,`wui-chat-history`);t.hidden=!0;let n=null,r=null,i=null,a=null,o=null,s=!1;function c(){return n||(n=qt({client:e.getClient()}),r=n.subscribe(()=>_()),n)}function l(e){i={id:e.publicId,kind:`rename`,draft:e.title??``,saving:!1},a=null,o=null,s=!0,_()}function u(e){i={id:e.publicId,kind:`delete`,saving:!1},a=null,o=null,_()}function d(){i=null,a=null,o=null,_()}async function f(){let t=i;if(t?.kind!==`rename`||t.saving)return;let n=t.draft.trim();if(n){t.saving=!0,_();try{await c().rename(t.id,n),i===t&&(i=null),a=null,o=null}catch{if(i!==t)return;t.saving=!1,o=e.getLabels().renameFailed}_()}}async function p(){let t=i;if(!(t?.kind!==`delete`||t.saving)){t.saving=!0,_();try{await c().remove(t.id),i===t&&(i=null),a=null,e.onDeleted(t.id)}catch{if(i!==t)return;t.saving=!1,a=e.getLabels().deleteFailed}_()}}function m(e,t){let n=$(`li`,`wui-chat-history-row wui-chat-history-row--editing`),r=$(`input`,`wui-chat-history-input`,{type:`text`,"aria-label":e.conversationTitle,maxlength:String(g7)});r.value=t.draft,r.addEventListener(`input`,()=>{t.draft=r.value,i.disabled=t.saving||!t.draft.trim()}),r.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.isComposing&&e.keyCode!==229?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),d())});let i=_7(e.renameSave,()=>f(),`primary`);if(i.disabled=t.saving||!t.draft.trim(),n.append(r,i,_7(e.cancel,()=>d(),`ghost`)),o!==null){let e=$(`p`,`wui-chat-history-error`,{role:`alert`});e.textContent=o,n.append(e)}return s&&(s=!1,queueMicrotask(()=>r.focus())),n}function h(e,t){let n=$(`li`,`wui-chat-history-row wui-chat-history-row--confirm`),r=$(`p`);r.textContent=e.deleteConfirmTitle;let i=$(`p`);i.textContent=e.deleteConfirmMessage;let a=_7(e.deleteConfirm,()=>p(),`danger`);return a.disabled=t.saving,n.append(r,i,a,_7(e.cancel,()=>d(),`ghost`)),n}function g(t,n,r){if(i?.id===t.publicId&&i.kind===`rename`)return m(n,i);if(i?.id===t.publicId&&i.kind===`delete`)return h(n,i);let a=$(`li`,`wui-chat-history-row`),o=$(`button`,`wui-chat-history-open`,{type:`button`}),s=$(`span`,`wui-chat-history-title`);s.textContent=t.title||n.untitled;let c=$(`span`,`wui-chat-history-time`);return c.textContent=lr(t.lastActivityDateTimeUtc),o.append(s,c),o.addEventListener(`click`,()=>e.onOpen(t.publicId)),a.append(o),r.Rename&&a.append(n3(n.rename,`pencil`,()=>l(t))),r.Delete&&a.append(n3(n.deleteChat,`trash`,()=>u(t))),a}function _(){let r=e.getLabels(),i=e.getFeatures(),o=n?n.getState():{items:[],totalCount:null,loading:!1,error:null,hasMore:!1},s=[];if(o.error||a){let e=$(`p`,`wui-chat-history-error`,{role:`alert`});o.error?(e.append(document.createTextNode(r.loadFailed),document.createTextNode(` `)),e.append(_7(r.retry,()=>c().load(),`outline`))):e.textContent=a,s.push(e)}if(o.loading&&o.items.length===0){let e=$(`p`,`wui-chat-history-empty`,{role:`status`});e.textContent=r.loadingConversation,s.push(e)}if(o.items.length===0&&!o.loading&&!o.error){let e=$(`p`,`wui-chat-history-empty`),t=$(`span`);t.textContent=r.historyEmptyTitle;let n=$(`span`);n.textContent=r.historyEmptyText,e.append(t,n),s.push(e)}if(o.items.length>0){let e=$(`ul`,`wui-chat-history-list`,{"aria-label":r.history});e.append(...o.items.map(e=>g(e,r,i))),s.push(e)}o.hasMore&&!o.loading&&s.push(_7(r.loadMore,()=>c().loadMore(),`outline`)),t.replaceChildren(...s)}function v(){t.hidden=!1,Promise.allSettled([c().load()]),_()}function y(){t.hidden=!0}function b(){r?.(),r=null,n?.dispose(),n=null}return{el:t,show:v,hide:y,paint:_,dispose:b}}var y7=new Set([`GET`,`HEAD`]);function b7(){let e=document.querySelector(`meta[name="wui-csrf"]`),t=e?.getAttribute(`content`);return t?{token:t,header:e?.getAttribute(`data-header`)||`RequestVerificationToken`}:null}async function x7(e,{lenient:t=!1}={}){let n=await e.text();if(n){if((e.headers.get(`content-type`)||``).includes(`json`)){if(!t)return JSON.parse(n);try{return JSON.parse(n)}catch{return n}}return n}}async function S7(e,t,n){let r=new TextDecoder,i=e.getReader(),a=``;for(;;){let{done:e,value:o}=await i.read();if(e)break;a+=r.decode(o,{stream:!0}),n({event:{target:{responseText:a,status:t}}})}return a+=r.decode(),a}function C7({fetch:e=(...e)=>globalThis.fetch(...e)}={}){async function t(t,n,r,i={}){let a={...i.headers},o;if(typeof FormData<`u`&&r instanceof FormData){for(let e of Object.keys(a))e.toLowerCase()===`content-type`&&delete a[e];o=r}else r!==void 0&&(a[`Content-Type`]=`application/json`,o=JSON.stringify(r));if(!y7.has(t)){let e=b7();e&&(a[e.header]=e.token)}let s=i.signal,c=s,l,u,d=()=>l?.abort(s?.reason);(i.timeout??0)>0&&(l=new AbortController,c=l.signal,s?.aborted?l.abort(s.reason):s?.addEventListener(`abort`,d,{once:!0}),u=setTimeout(()=>l?.abort(new DOMException(`The request timed out.`,`TimeoutError`)),i.timeout));try{let r={method:t,headers:a,credentials:`same-origin`};o!==void 0&&(r.body=o),c&&(r.signal=c);let s=await e(n,r);if(!s.ok){let e=Error(`Request failed with status ${s.status}`);throw e.response={status:s.status,data:await x7(s,{lenient:!0})},e}let l;return l=i.responseType===`arraybuffer`?await s.arrayBuffer():typeof i.onDownloadProgress==`function`&&s.body?await S7(s.body,s.status,i.onDownloadProgress):await x7(s),{data:l,status:s.status}}finally{clearTimeout(u),s?.removeEventListener(`abort`,d)}}return{get:(e,n)=>t(`GET`,e,void 0,n),post:(e,n,r)=>t(`POST`,e,n,r),put:(e,n,r)=>t(`PUT`,e,n,r),delete:(e,n)=>t(`DELETE`,e,void 0,n)}}function w7(e){let t,n=!1,r=!1,i=$(`div`,`wui-chat-nudge`,{role:`status`});i.hidden=!0;let a=$(`button`,`wui-chat-nudge-text`,{type:`button`}),o=$(`button`,`wui-chat-nudge-close`,{type:`button`});o.append($4(`x`,14)),i.append(a,o);function s(){clearTimeout(t),t=void 0}function c(){s(),r=!0,i.hidden=!0}a.addEventListener(`click`,()=>{i.hidden=!0,e.onActivate()}),o.addEventListener(`click`,()=>{c(),e.onDismiss()});function l(e){s(),r||n||(t=setTimeout(()=>{t=void 0,a.textContent=e.text,o.setAttribute(`aria-label`,e.label),i.hidden=!1,n=!0},e.delaySeconds*1e3))}function u(){s(),i.remove()}return{el:i,schedule:l,cancel:s,dismiss:c,isShown:()=>n,destroy:u}}function T7(e,t){e.addEventListener(`click`,()=>t()),e.addEventListener(`keydown`,e=>{(Do(e)||e.key===` `)&&(e.preventDefault(),t())})}function E7(e){let{list:t,getLabels:n,getFeatures:r,onOpen:i}=e,a=$(`div`,`wui-chat-empty-rows wui-chat-empty-rows--past`);a.hidden=!0;let o=!1;function s(e,t){let n=$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}),r=$(`div`,`card-body wui-chat-empty-row-body`),a=$(`span`,`wui-chat-empty-row-title`);a.textContent=e.title||t.earlierChat;let o=$(`span`,`wui-chat-empty-row-time`,{title:gr(e.lastActivityDateTimeUtc)});return o.textContent=lr(e.lastActivityDateTimeUtc),r.append(a,o),n.append(r),T7(n,()=>i(e.publicId)),n}function c(){if(o)return;let e=t.getState().items;if(r().History!==!0||e.length===0){a.replaceChildren(),a.hidden=!0;return}let i=n();a.replaceChildren(...e.slice(0,20).map(e=>s(e,i))),a.hidden=!1}let l=t.subscribe(c);return{el:a,refresh(){r().History===!0&&t.load().catch(e=>globalThis.reportError?.(e))},paint:c,dispose(){o=!0,l()}}}var D7=`https://www.google.com/recaptcha/api.js?render=`;function O7(e){return e!==void 0&&typeof e.ready==`function`&&typeof e.execute==`function`}var k7=new Map;function A7(e){let t=k7.get(e);if(t!==void 0)return t;let n=new Promise((t,n)=>{let r=globalThis.grecaptcha;if(O7(r)){t(r);return}let i=document.createElement(`script`);i.src=D7+encodeURIComponent(e),i.async=!0;let a=t=>{k7.delete(e),n(Object.assign(Error(t),{code:`captcha_unavailable`}))};i.addEventListener(`load`,()=>{let e=globalThis.grecaptcha;e===void 0||typeof e.ready!=`function`?a(`The reCAPTCHA script loaded without grecaptcha.`):e.ready(()=>{let e=globalThis.grecaptcha;O7(e)?t(e):a(`reCAPTCHA became ready without execute.`)})}),i.addEventListener(`error`,()=>{k7.delete(e),n(Error(`The reCAPTCHA script did not load.`))}),document.head.append(i)});return k7.set(e,n),n}async function j7(e,t){let n=await A7(e);await new Promise(e=>n.ready(()=>e()));let r=await n.execute(e,{action:t});if(!r)throw Object.assign(Error(`reCAPTCHA returned no token.`),{code:`captcha_unavailable`});return r}var M7=`data-wchat-printing`,N7=`data-wchat-print-hide`,P7=`data-wchat-print-path`,F7=`data-wchat-print-target`,Ste=new Set([`script`,`style`,`link`,`template`]),I7=null;function L7(){if(I7!==null){for(let e of I7.marked)e.removeAttribute(N7),e.removeAttribute(P7),e.removeAttribute(F7);I7.heading.remove(),document.documentElement.removeAttribute(M7),window.removeEventListener(`afterprint`,I7.onAfterPrint),I7=null}}function R7(e,t,n,r,i){L7();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[],s=a;for(;s!==null&&s!==document.documentElement;){s.setAttribute(P7,``),o.push(s);let e=s.parentElement;if(e===null)throw Error(`print walk left the chat root`);for(let t of e.children)t===s||Ste.has(t.localName)||(t.setAttribute(N7,``),o.push(t));s=e}for(let e of n)e.setAttribute(N7,``),o.push(e);r!==null&&(r.setAttribute(F7,``),o.push(r));let c=document.createElement(`div`);c.className=`wui-chat-print-heading`;let l=document.createElement(`h1`);l.textContent=i.title;let u=document.createElement(`p`);u.textContent=i.printedOn,c.append(l,u),a.prepend(c),document.documentElement.setAttribute(M7,t);let d=()=>L7();window.addEventListener(`afterprint`,d,{once:!0}),I7={marked:o,heading:c,onAfterPrint:d};try{window.print()}catch(e){throw L7(),e}}function Cte(e,t){R7(e,`conversation`,[],null,t)}function wte(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);R7(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function z7(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function B7({title:e,text:t}){if(!z7())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?`cancelled`:`failed`}}var Tte=new Set([`Assistant`,`Agent`,`Script`]),V7=new WeakMap;function Ete(e,t,n){let{labels:r,features:i,title:a,busy:o,assistantName:s}=n;if(fr(t.parts)!==``){if(i.Share&&z7()){let n=t3(`ghost`,r.share,`share`,()=>void(async()=>{let e=U7([t],i,r,a,!1,s);e!==``&&await B7({title:a,text:e})===`failed`&&q7(n.parentElement,r.shareFailed)})());n.disabled=o===!0,e.append(n)}if(i.Print){let t=t3(`ghost`,r.print,`printer`,()=>{try{let e=t.closest(`.wui-chat`),n=t.closest(`li.wui-chat-message`);if(!(e instanceof HTMLElement)||!(n instanceof HTMLElement))throw Error(`printReply needs a message inside the wui-chat root`);wte(e,n,{title:a,printedOn:G7(r)})}catch{K7(t,r.printFailed)}});e.append(t)}}}function Dte(e,t,n){if(t.streaming||t.thinking||t.loading||t.conversationId===null||t.messages.filter(e=>e.stored&&Tte.has(e.author.kind)&&fr(e.parts)!==``).length===0){e.hidden=!0;return}let{labels:r,features:i}=n,a=!!i.Share&&z7(),o=!!i.Print;if(!a&&!o){e.hidden=!0;return}let s=[a,o,t.messages.length,r.shareConversation,r.printConversation].join(`|`);e.dataset.sig!==s&&(e.dataset.sig=s,e.replaceChildren(),a&&e.append(Ote(e,r,i,n)),o&&e.append(kte(e,r,n))),e.hidden=!1}function H7(e,t,n,r){return e.iconOnly?n3(t,n,r):t3(`ghost`,t,n,r)}function Ote(e,t,n,r){return H7(r,t.shareConversation,`share`,()=>void(async()=>{let i=r.getState(),a=W7(i,r);await B7({title:a,text:U7(i.messages.filter(e=>e.stored),n,t,a,!0,i.profile?.assistant.name)})===`failed`&&q7(e,t.shareFailed)})())}function kte(e,t,n){let r=H7(n,t.printConversation,`printer`,()=>{try{let r=e.closest(`.wui-chat`);if(!(r instanceof HTMLElement))throw Error(`printConversation needs the wui-chat root`);Cte(r,{title:W7(n.getState(),n),printedOn:G7(t)})}catch{n.iconOnly?q7(e,t.printFailed):K7(r,t.printFailed)}});return r}function U7(e,t,n,r,i,a){return xi(yi(e,{labels:n,title:r,figureText:t.FigureText,...a===void 0?{}:{assistantName:a}}),{heading:i,speakers:i})}function W7(e,t){return typeof e.title==`string`&&e.title!==``?e.title:t.title}function G7(e){return e.printedOn(lr(new Date().toISOString()))}function K7(e,t){let n=e.lastChild;if(!(n instanceof Text))return;let r=V7.get(n);r&&clearTimeout(r.timer);let i=r??{original:n.data};n.data=t,i.timer=setTimeout(()=>{n.data=i.original,V7.delete(n)},Ri),V7.set(n,i)}function q7(e,t){if(!e)return;let n=document.createElement(`span`);n.className=`wui-chat-action-notice`,n.setAttribute(`role`,`status`),n.textContent=t,e.append(n),setTimeout(()=>n.remove(),Ri)}var J7=`data-wchat-docked`,Y7=`--wui-chat-docked-width`,Ate=420,X7=new Set;function jte(e,t){let n=document.documentElement;n.setAttribute(J7,e),n.style.setProperty(Y7,t)}function Mte(){let e=document.documentElement;e.removeAttribute(J7),e.style.removeProperty(Y7)}function Nte(e){let t=p3({...e,layout:`docked`,role:`dialog`,launcher:!0}),n={},r=e.position,i=!1,a=null,o=()=>`${Math.round(t.panel.getBoundingClientRect().width)||Ate}px`;function s(){X7.add(n),jte(r,o()),typeof ResizeObserver==`function`&&(a=new ResizeObserver(()=>document.documentElement.style.setProperty(Y7,o())),a.observe(t.panel))}function c(){a?.disconnect(),a=null,X7.delete(n),X7.size===0&&Mte()}function l(e){t.setOpen(e),e&&!i?(i=!0,s()):!e&&i&&(i=!1,c())}function u(e){t.setAppearance(e),e.position!==void 0&&(r=e.position,i&&document.documentElement.setAttribute(J7,r))}function d(){l(!1)}return{...t,setOpen:l,setAppearance:u,destroy:d}}function Pte(e){return p3({...e,layout:`embedded`,role:`region`,launcher:!1})}var Z7=`wchat:peeked`,Fte=576,Ite=200;function Lte(e){let t=p3({...e,layout:`launcher`,role:`dialog`,launcher:!0}),{root:n,panel:r,setLauncherState:i}=t;if(!t.nudgeHost||!t.launcherButton)throw Error(`a launcher shell always has its launcher`);let a=t.nudgeHost,o=t.launcherButton,s={peek:!1,peekSeconds:3,hideWhileOpen:!1,expressive:!1};o.dataset.state=`closed`;let c=!1,l=!1,u,d,f=()=>s.hideWhileOpen||s.expressive;function p(){!s.peek||c||l||a.dataset.launcher!==`idle`||globalThis.innerWidth<Fte||globalThis.sessionStorage.getItem(Z7)!==null||(globalThis.sessionStorage.setItem(Z7,`1`),i(`peeking`),u=setTimeout(()=>{u=void 0,a.dataset.launcher===`peeking`&&i(`idle`)},s.peekSeconds*1e3))}a.addEventListener(`animationend`,e=>{e.target===a&&a.dataset.launcher===`idle`&&p()});function m(e){if(e!==l){if(l=e,clearTimeout(u),u=void 0,e)clearTimeout(d),d=void 0,f()?(i(`hidden`),a.toggleAttribute(`inert`,!0)):a.dataset.launcher===`peeking`&&i(`idle`);else if(f()){let e=r.contains(document.activeElement);d=setTimeout(()=>{d=void 0,a.toggleAttribute(`inert`,!1),i(`idle`),e&&o.focus()},Ite)}}o.dataset.state=e?`open`:`closed`,t.setOpen(e)}function h(e){e.reduced!==void 0&&(c=!!e.reduced),e.peek!==void 0&&(s.peek=e.peek),e.peekSeconds!==void 0&&(s.peekSeconds=e.peekSeconds),e.hideWhileOpen!==void 0&&(s.hideWhileOpen=e.hideWhileOpen),e.expressive!==void 0&&(s.expressive=e.expressive===!0),e.phoneMode!==void 0&&n.classList.toggle(`wui-chat--sheet`,e.phoneMode===`Sheet`),e.sheetHeightDvh!==void 0&&n.style.setProperty(`--_wui-chat-sheet-height`,`${e.sheetHeightDvh}dvh`),e.sheetMaxHeightPx!==void 0&&n.style.setProperty(`--_wui-chat-sheet-max-height`,`${e.sheetMaxHeightPx}px`),t.setAppearance(e),!f()&&a.dataset.launcher===`hidden`&&!l&&i(`idle`),a.dataset.launcher===`idle`&&p()}return{...t,nudgeHost:a,launcherButton:o,setOpen:m,setAppearance:h}}function Rte(e){return p3({...e,layout:`full-page`,role:`region`,launcher:!1})}var zte=new Set([`Agent`,`Customer`]);function Bte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-typing`,e.setAttribute(`aria-hidden`,`true`),e.hidden=!0;let t=document.createElement(`span`);t.className=`wui-chat-loader-typing-orb`;let n=document.createElement(`span`);n.className=`wui-chat-loader-typing-dots`;for(let e=0;e<3;e++){let e=document.createElement(`span`);e.className=`wui-chat-loader-typing-dot`,n.append(e)}e.append(t,n);function r({active:n,reduced:r,authorKind:i}){e.hidden=!n,e.classList.toggle(`wui-chat-loader--reduced`,r===!0),t.hidden=zte.has(i)}function i(){e.remove()}return{el:e,update:r,destroy:i}}var Vte=3,Hte={Primary:`wui-chat-starter--primary`,Cta:`wui-chat-starter--cta`};function Q7(e,t){e.addEventListener(`click`,()=>t()),e.addEventListener(`keydown`,e=>{(Do(e)||e.key===` `)&&(e.preventDefault(),t())})}function Ute(e){let t=$(`h2`,`wui-chat-greeting`),n=$(`div`,`wui-chat-empty-hero`),r=$(`p`,`wui-chat-empty-intro`);r.hidden=!0;let i=e.mark?.(`greeting`,`rest`)??$(`span`,`wui-chat-orb`,{"aria-hidden":`true`});n.append(i,t,r);let a=$(`div`,`wui-chat-empty-extra`);a.hidden=!0;let o=$(`div`,`wui-chat-starters`,{role:`group`}),s=$(`div`,`wui-chat-empty-rows`),c=$(`div`,`wui-chat-empty-past`),l=$(`div`,`wui-chat-empty`,{role:`group`}),u=Bte();l.append(u.el,n,a,o,s,c);let d;function f(t,n){let r=$(`button`,[`wui-chat-starter`,(t.variant===null?void 0:Hte[t.variant])??``].filter(Boolean).join(` `),{type:`button`});if(r.style.setProperty(`--wui-chat-i`,String(n)),t.icon){let e=$(`span`,`wui-chat-starter-icon`,{"aria-hidden":`true`});e.append($4(t.icon,16)),r.append(e)}return r.append(document.createTextNode(t.label)),r.addEventListener(`click`,()=>e.onStarter(t)),r}function p(t,n){let r=$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}),i=$(`div`,`card-body wui-chat-empty-row-body`),a=$(`span`,`wui-chat-empty-row-label`);a.textContent=n.resumeLast;let o=$(`span`,`wui-chat-empty-row-title`,{title:t.title||n.untitled});o.textContent=t.title||n.untitled;let s=$(`span`,`wui-chat-empty-row-time`);return s.textContent=lr(t.lastActivityDateTimeUtc),i.append(a,o,s),r.append(i),Q7(r,()=>e.onResume()),r}function m(t,n){let r=$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}),i=$(`div`,`card-body wui-chat-empty-row-body`),a=$(`span`,`wui-chat-empty-row-title`,{title:t.title||n.untitled});a.textContent=t.title||n.untitled;let o=$(`span`,`wui-chat-empty-row-time`);return o.textContent=lr(t.lastActivityDateTimeUtc),i.append(a,o),r.append(i),Q7(r,()=>e.onOpenConversation(t.publicId)),r}function h(t,n,r){let i=r?$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}):$(`div`,`card card-pad-sm wui-chat-empty-row`),a=$(`div`,`card-body wui-chat-empty-row-body`),o=$(`span`,`wui-chat-empty-row-label`);o.textContent=n.ticketAria(t.number);let s=$(`span`,`wui-chat-empty-row-title`);s.textContent=t.subject;let c=$(`span`,`wui-chat-empty-row-status`);return c.textContent=E3(t.status,n),a.append(o,s,c),i.append(a),r&&Q7(i,()=>e.onTicket(t)),i}function g(e,t){if(e.features?.OpenTickets!==!0||!e.openTickets?.length)return null;let n=$(`div`,`wui-chat-open-tickets`,{role:`group`,"aria-label":t.openTickets});return n.append(...e.openTickets.slice(0,Vte).map(n=>h(n,t,e.ticketsClickable===!0))),n}function _(e){let{labels:n}=e;t.textContent=e.greeting??``;let i=e.intro??``;r.textContent=i,r.hidden=!i,l.setAttribute(`aria-label`,n.emptyTitle);let a=e.starters??[];o.setAttribute(`aria-label`,n.starters),o.hidden=!e.showStarters||a.length===0,o.replaceChildren(...a.map(f));let c=e.resume??null,u=e.recent.length===0?null:$(`div`,`wui-chat-recent`,{role:`group`,"aria-label":n.recentChats});u?.append(...e.recent.map(e=>m(e,n)));let d=g(e,n),h=u??(c===null?null:p(c,n));s.hidden=h===null&&d===null,s.replaceChildren(...[h,d].filter(e=>e!==null))}function v(e){clearTimeout(d),l.classList.remove(`wui-chat-empty--revealed`),l.classList.add(`wui-chat-empty--intro`),u.update({active:!0,reduced:!1,authorKind:`Assistant`}),d=setTimeout(()=>{d=void 0,u.update({active:!1,reduced:!1,authorKind:`Assistant`}),l.classList.replace(`wui-chat-empty--intro`,`wui-chat-empty--revealed`)},e)}return{el:l,paint:_,intro:v,extraHost:a,pastHost:c}}function Wte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-orb`;let t=document.createElement(`span`);t.className=`wui-chat-loader-orb-mark`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-orb-glow`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`span`);r.className=`wui-chat-loader-orb-disc`,r.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=document.createElement(`span`);i.className=`wui-chat-loader-orb-label`,e.append(t,i);let a=t;return{el:e,render(n,r=null){i.textContent!==n.label&&(i.textContent=n.label);let o=r??t;o!==a&&(a.parentNode===e?a.replaceWith(o):e.prepend(o),a=o)}}}var Gte=150,$7=1800;function Kte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-phrases`;let t=document.createElement(`span`);t.className=`wui-chat-loader-phrases-orb`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-phrases-stage`,e.append(t,n);let r=null,i=null;function a(){return e.closest(`.wui-chat-loader`)?.classList.contains(`wui-chat-loader--reduced`)===!0}function o(e){if(e.label===r)return;r=e.label;let t=i,o=document.createElement(`span`);o.className=`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--in`,o.textContent=e.label,o.style.animationDelay=`-${Math.round(performance.now()%$7)}ms, 0s`,n.append(o),i=o,t&&(t.classList.remove(`wui-chat-loader-phrases-text--in`),t.classList.add(`wui-chat-loader-phrases-text--out`),t.style.animationDelay=`-${Math.round(performance.now()%$7)}ms, 0s`,a()?t.remove():setTimeout(()=>t.remove(),Gte))}return{el:e,render:o}}var qte=3;function Jte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-pulse`;let t=document.createElement(`span`);t.className=`wui-chat-loader-pulse-disc`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-pulse-label`;let r=document.createElement(`span`);r.className=`wui-chat-loader-pulse-dots`,r.setAttribute(`aria-hidden`,`true`);for(let e=0;e<qte;e+=1){let e=document.createElement(`span`);e.className=`wui-chat-loader-pulse-dot`,r.append(e)}e.append(t,n,r);let i=t;return{el:e,render(r,a=null){n.textContent!==r.label&&(n.textContent=r.label);let o=a??t;o!==i&&(i.parentNode===e?i.replaceWith(o):e.prepend(o),i=o)}}}var Yte=[`95%`,`80%`,`60%`];function Xte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-skeleton`;let t=document.createElement(`div`);t.className=`wui-chat-loader-skeleton-label`;let n=document.createElement(`div`);n.className=`wui-chat-loader-skeleton-body`;let r=document.createElement(`span`);r.className=`wui-chat-loader-skeleton-avatar`,r.setAttribute(`aria-hidden`,`true`),n.append(r);for(let e of Yte){let t=document.createElement(`span`);t.className=`wui-chat-loader-skeleton-line`,t.setAttribute(`aria-hidden`,`true`),t.style.width=e,n.append(t)}return e.append(t,n),{el:e,render(e){t.textContent!==e.label&&(t.textContent=e.label)}}}var e9=`http://www.w3.org/2000/svg`;function Zte(e){if(e===`done`){let e=document.createElementNS(e9,`svg`);e.setAttribute(`viewBox`,`0 0 16 16`),e.setAttribute(`class`,`wui-chat-loader-steps-check`);let t=document.createElementNS(e9,`path`);return t.setAttribute(`d`,`M3 8.5 6.5 12 13 4.5`),t.setAttribute(`pathLength`,`1`),e.append(t),e}let t=document.createElement(`span`);return t.className=e===`active`?`wui-chat-loader-steps-ring`:`wui-chat-loader-steps-dot`,t}function Qte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-steps`;let t=document.createElement(`span`);t.className=`wui-chat-loader-steps-pill`;let n=document.createElement(`ol`);n.className=`wui-chat-loader-steps-list`,e.append(t,n);let r=[],i=null;function a(){let e=document.createElement(`li`);e.className=`wui-chat-loader-steps-item`;let t=document.createElement(`span`);t.className=`wui-chat-loader-steps-icon`,t.setAttribute(`aria-hidden`,`true`);let i=document.createElement(`span`);i.className=`wui-chat-loader-steps-text`,e.append(t,i);let a={li:e,icon:t,text:i,state:null};return r.push(a),n.append(e),a}function o(o,s=null){s!==i&&(i?.remove(),i=s,s!==null&&e.prepend(s));let c=o.steps.length===0;for(t.hidden=!c,n.hidden=c,c&&t.textContent!==o.label&&(t.textContent=o.label),o.steps.forEach((e,t)=>{let n=r[t]??a();n.text.textContent!==e&&(n.text.textContent=e);let i=t<o.activeIndex?`done`:t===o.activeIndex?`active`:`pending`;n.state!==i&&(n.state=i,n.li.dataset.state=i,n.icon.replaceChildren(Zte(i)))});r.length>o.steps.length;)r.pop()?.li.remove()}return{el:e,render:o}}var t9={Steps:Qte,Phrases:Kte,Orb:Wte,Skeleton:Xte,PulseAndDots:Jte},$te=500;function ene(){let e=document.createElement(`div`);e.className=`wui-chat-loader`,e.setAttribute(`role`,`status`),e.hidden=!0;let t=document.createElement(`span`);t.className=`wui-chat-loader-avatar`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`div`);n.className=`wui-chat-loader-body`;let r=document.createElement(`span`);r.className=`visually-hidden`,e.append(t,n,r);let i=null,a=null,o=0,s=null,c=0,l=null,u=!1;function d(){s!==null&&clearInterval(s),s=null}function f(){e.isConnected?(o+=1,p()):d()}function p(){if(!a||!i)return;let t=Re(i.style,i.steps,i.phrases,o);a.render(t,i.mark),e.setAttribute(`aria-label`,t.label)}function m(){l!==null&&clearTimeout(l),l=null,u=!1,r.textContent=``}function h(e){!u&&l===null&&e&&(l=setTimeout(()=>{l=null,u=!0,r.textContent=e},$te))}function g(t){if(!t.active)i=null,e.hidden=!0,e.removeAttribute(`data-loading`),d(),m();else{if(!Q4(t9,t.style))throw Error(`Unknown loader style. Use Steps, Phrases, Orb, Skeleton or PulseAndDots.`);if(!(t.intervalMs>0))throw Error(`Loader intervalMs must be a positive number.`);if(i={...t,steps:t.steps??[],phrases:t.phrases??[],mark:t.mark??null},e.hidden=!1,e.setAttribute(`data-loading`,`true`),e.classList.toggle(`wui-chat-loader--reduced`,t.reduced===!0),!a||a.style!==t.style){let r=t9[t.style]();n.replaceChildren(r.el),a={style:t.style,render:r.render},e.dataset.style=t.style,o=0}h(t.announce),t.reduced===!0?(d(),o=0):(s===null||c!==t.intervalMs)&&(d(),c=t.intervalMs,s=setInterval(f,c)),p()}}function _(){d(),m(),a=null,i=null,e.remove()}return{el:e,update:g,destroy:_}}function tne({voice:e,getLabels:t,message:n}){if(n.streaming||!e.canSpeak()||$5(n.parts)===``)return null;let r=e.getStatus(),i=r.mode===`Speaking`&&r.messageId===n.id,a=t(),o=i?a.readAloudStop:a.readAloud,s=$(`button`,`wui-chat-action-btn wui-chat-speak`,{type:`button`,"aria-pressed":String(i),"aria-label":o,title:o});return s.append(T5(i?`stop`:`speaker`,16)),s.addEventListener(`click`,()=>{e.toggleSpeak(n.id,n.parts)}),s}function nne({voice:e,getLabels:t,message:n}){let r=e.getStatus().note;if(r?.code!==`SpeakFailed`||r.messageId!==n.id)return null;let i=$(`span`,`wui-chat-action-notice`,{role:`status`});return i.textContent=e7(r,t()),i}function rne(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function n9(e,t){let n=rne(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}function ine(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.author.kind===`Visitor`&&n.stored)return n}}var ane=new Set([`Assistant`,`Agent`]),r9=new Set([`Assistant`,`Agent`,`Script`]),i9=new Set([`Visitor`,`Customer`]),one=48,sne=120,cne={author:{kind:`Assistant`,displayName:null,avatarUrl:null}},lne={warning:`alert-triangle`,danger:`alert-circle`};function a9(e,t,n,r,i){n!==null&&(n.dataset.state=i?`busy`:`rest`,r?n.parentNode!==e&&e.insertBefore(n,t):n.remove())}function o9(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=one}function s9(e){let{kind:t,displayName:n}=e.author;return t===`Agent`?`Agent:${n??``}`:t===`Script`?`Assistant`:t}function une(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function dne(e){let t=e.textContent?.trim();t&&!e.hasAttribute(`aria-label`)&&(e.setAttribute(`aria-label`,t),e.setAttribute(`title`,t))}function fne(e){return e.reduced===!0}function c9(e,t,n){let r=$(`button`,`${e3(`ghost`,`sm`)} wui-chat-action-btn`,{type:`button`,"aria-label":e,title:e}),i=$(`span`);return i.textContent=e,r.append($4(t,14),i),r.addEventListener(`click`,n),{node:r,text:i}}function pne(e,t){return e.profile?.assistant.name||t.assistant}function mne(e,t,n){return e.author.displayName==null?e.author.kind===`Visitor`||e.author.kind===`Customer`?n.you:e.author.kind===`Agent`?n.agent:t.profile?.assistant.name??n.assistant:e.author.displayName}function hne(e){let t=$(`li`,`wui-chat-day`,{role:`presentation`}),n=$(`span`);return n.textContent=e,t.append(n),t}function gne(e){let t=$(`ol`,`wui-chat-thread`),n=$(`div`,`wui-chat-log`,{role:`log`,"aria-live":`polite`});n.append(t);let r=ene(),i=$(`li`,`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`),a=$(`div`,`wui-chat-loader-slot`);a.append(r.el);let o=e.mark?.(`loader`,`busy`)??null;i.append(a);let s=!1,c,l=$(`li`,`wui-chat-message wui-chat-message--assistant wui-chat-message--greeting`,{"data-run-start":``,"data-restored":``}),u=$(`div`,`wui-chat-message-body`),d=$(`p`,`wui-chat-text`);u.append(d),l.append(u);let f=e.mark?.(`reply`,`rest`)??null,p=$(`button`,`wui-chat-jump`,{type:`button`}),m=$(`div`,`wui-chat-jump-slot`);m.hidden=!0,m.append(p);let h=null,g=!0,_=null,v=null,y=new Map,b=``,x=null;function S(e,t){return{kind:e.kind,part:e,tag:t[e.kind]}}function C(t,n,r){return Object.assign(document.createElement(t),{message:r,turn:e.makeTurnApi(r.id),chatPart:n})}function w(e){return $(`div`,`wui-chat-part wui-chat-part--${e.toLowerCase()}`)}function T(e,t,n,r){e.parts=[];let i=[],a=e=>{let r=S(e,n),i=w(r.kind);return i.append(C(r.tag,r.part,t)),i};for(let e of r(t))if(Array.isArray(e)){let t=$(`div`,`wui-chat-part-group`);t.append(...e.map(a)),i.push(t)}else i.push(a(e));e.body.replaceChildren(...i)}function E(t,n,r){let i=[];n.parts.forEach((a,o)=>{let s=S(a,r),c=t.parts[o];if(c&&c.kind===s.kind&&c.tag===s.tag){c.part!==s.part&&(c.element.message=n,c.element.turn=e.makeTurnApi(n.id),c.element.chatPart=s.part,c.part=s.part),i.push(c);return}let l=w(s.kind),u=C(s.tag,s.part,n);l.append(u),i.push({kind:s.kind,tag:s.tag,part:s.part,element:u,wrapper:l})}),t.parts=i,D(t.body,i.map(e=>e.wrapper))}function D(e,t){let n=new Set(t);for(let t of[...e.children])n.has(t)||t.remove();t.forEach((t,n)=>{e.children[n]!==t&&e.insertBefore(t,e.children[n]??null)})}function O(e,t,n){let r=$(`div`,`wui-chat-rating`,{role:`group`,"aria-label":`${n.rateUp} / ${n.rateDown}`}),i=[[`Up`,n.rateUp,`thumbs-up`],[`Down`,n.rateDown,`thumbs-down`]];for(let[a,o,s]of i){let i=t.rating===a,c=$(`button`,`${e3(i?`neutral`:`ghost`,`sm`)} wui-chat-action-btn`,{type:`button`,"aria-pressed":String(i),"data-rating":a,"aria-label":o,title:o}),l=$(`span`);l.textContent=o,c.append($4(s,14),l),c.addEventListener(`click`,()=>k(e,t,a,n)),r.append(c)}if(e.ratingNote){let t=$(`span`,null,{role:`status`});t.textContent=e.ratingNote,r.append(t)}return r}async function k(t,n,r,i){try{await e.onRate(n.id,r),t.ratingNote=i.rated}catch{t.ratingNote=i.ratingFailed}x&&ue(x.state,x.context)}function A(t,n,r,i,a){let{labels:o}=i,s=r.features,c=n.author.kind,l=fr(n.parts),u=[];if(s.Copy&&r9.has(c)&&l){let e=c9(o.copy,`copy`,()=>void(async()=>{await zi(l)&&(e.text.textContent=o.copied,e.node.dataset.done=``,e.node.setAttribute(`aria-label`,o.copied),e.node.title=o.copied,clearTimeout(t.copyTimer),t.copyTimer=setTimeout(()=>{e.text.textContent=o.copy,delete e.node.dataset.done,e.node.setAttribute(`aria-label`,o.copy),e.node.title=o.copy},Ri))})());u.push(e.node)}let d=e.getVoice?.();if(d&&r9.has(c)){let e=tne({voice:d,getLabels:()=>o,message:n});e&&u.push(e);let t=nne({voice:d,getLabels:()=>o,message:n});t&&u.push(t)}if(r9.has(c)){let e=$(`div`);Ete(e,n,{labels:o,features:s,title:pne(r,o),assistantName:r.profile?.assistant.name,busy:r.streaming||r.thinking});for(let t of e.children)dne(t);u.push(...e.childNodes)}let f=r.messages.some(e=>e.author.kind===`Visitor`&&e.stored);a&&c===`Assistant`&&!r.streaming&&!r.thinking&&s.Regenerate&&f&&u.push(c9(o.regenerate,`refresh`,()=>e.onRegenerate()).node);let p=ine(r.messages);s.Edit&&p?.id===n.id&&!r.streaming&&!r.thinking&&u.push(c9(o.edit,`pencil`,()=>e.getSession().startEdit(n.id)).node),s.Rating&&n.stored&&ane.has(c)&&u.push(O(t,n,o)),t.actions.hidden=u.length===0,t.actions.replaceChildren(...u)}function j(t){let n=y.get(t.id);if(n)return n;let r=$(`li`,`wui-chat-message`),i=$(`span`,`wui-chat-author visually-hidden`),a=$(`div`,`wui-chat-message-body`),o=$(`div`,`wui-chat-message-actions`);r.append(i,a,o);let s={li:r,author:i,body:a,actions:o,head:null,parts:[],copyTimer:void 0,ratingNote:null,mark:t.author.kind===`Assistant`?e.mark?.(`reply`,`rest`)??null:null};return y.set(t.id,s),s}function M(e,t,n,r){let i=n?.author.kind===`Agent`&&t.author.kind===`Agent`&&(n.author.displayName??``)===(t.author.displayName??``);e.head?.remove(),e.head=t.author.kind===`Agent`&&!i?C3(t.author,r):null,e.head&&e.li.insertBefore(e.head,e.body)}function ee(t,n,r,i,a,o){let{labels:s}=i;t.li.className=`wui-chat-message wui-chat-message--${n.author.kind.toLowerCase()}`,t.li.toggleAttribute(`data-restored`,n.restored===!0);let c=!o||s9(o)!==s9(n);t.li.toggleAttribute(`data-run-start`,c);let l=i.replyAvatars??`First`,u=n.author.kind===`Assistant`&&(l===`Every`||l===`First`&&c);a9(t.li,t.body,t.mark,u,n.streaming),n.streaming?t.li.setAttribute(`aria-busy`,`true`):t.li.removeAttribute(`aria-busy`),t.author.textContent=`${mne(n,r,s)}: `,M(t,n,o,s);let d=e.getRenderers(),f=e.getLayoutParts();typeof f==`function`?T(t,n,d,f):E(t,n,d),n.streaming?(t.actions.hidden=!0,t.actions.replaceChildren()):A(t,n,r,i,a)}function te(e,t){let n=$(`li`,`wui-chat-message wui-chat-message--system wui-chat-message--notice`),r=$(`div`,`wui-chat-notice wui-chat-notice--${e}`,{role:e===`danger`?`alert`:`status`}),i=$(`span`,`wui-chat-notice-icon`,{"aria-hidden":`true`});i.append($4(lne[e],16));let a=$(`div`,`wui-chat-notice-body`),o=$(`span`,`wui-chat-notice-text`);return o.textContent=t,a.append(o),r.append(i,a),n.append(r),n}function ne(e,t){let n=e.resetsDateTimeUtc?` ${t.dailyLimitRefresh(n9(e.resetsDateTimeUtc))}`:``;return te(`warning`,`${e.message}${n}`)}function re(t,n){let{labels:r}=n,i=t.turnError,a=i?.code??``;if(i&&a===`daily_limit`)return ne(i,r);if(a.endsWith(`feature_off`))return te(`danger`,t.turnError?.message||r.stopped);let o=$(`li`,`wui-chat-message wui-chat-message--system wui-chat-message--error`),s=$(`p`,`wui-chat-error`,{role:`alert`});s.textContent=t.turnError?.message||r.stopped;let c=$4(`alert-circle`,16);if(c.setAttribute(`aria-hidden`,`true`),o.append(c,s),t.features.Retry){let t=$(`div`,`wui-chat-message-actions`);t.append(c9(r.retry,`rotate-ccw`,()=>e.onRetry()).node),o.append(t)}return o}function ie(){return t.closest(`.wui-chat`)}function ae(){return t.closest(`.wui-chat-body`)??une(t)}function oe(e){ie()?.classList.toggle(`wui-chat--scrolled`,e.scrollTop>0),o9(e)&&(m.hidden=!0)}function se(){h!==null&&(g=o9(h),oe(h))}function ce(e){n.nextElementSibling!==m&&n.parentNode&&n.after(m),e!==h&&(h?.removeEventListener(`scroll`,se),h=e,e.addEventListener(`scroll`,se,{passive:!0}),!_&&typeof ResizeObserver==`function`&&(_=new ResizeObserver(()=>{g&&h&&(h.scrollTop=h.scrollHeight)}),_.observe(t)))}p.addEventListener(`click`,()=>{let e=ae(),t=x?.context.reduced===!0;e?.scrollTo({top:e.scrollHeight,behavior:t?`auto`:`smooth`}),m.hidden=!0,p.blur()});function le(e,t){let n=e.messages[e.messages.length-1],r=n?`${n.id}|${n.parts.length}|${fr(n.parts).length}`:``;if(r===b)return;let i=b===``||e.conversationId!==v;b=r,v=e.conversationId;let a=ae();a&&(ce(a),i||t||n!==void 0&&i9.has(n.author.kind)?(a.scrollTop=a.scrollHeight,m.hidden=!0,g=!0):(m.hidden=!1,g=!1),oe(a))}function ue(e,a){x={state:e,context:a};let{labels:m}=a;n.setAttribute(`aria-label`,m.thread),p.textContent=m.newMessages??`New messages`;let h=ae();h&&ce(h);let g=h===null||h.clientHeight===0||o9(h),_=[],v=new Set,b=e.messages.filter(e=>!(e.streaming&&e.parts.length===0)),S=b[0],C=S!==void 0&&i9.has(S.author.kind)&&e.greeting?e.greeting:null,w=null,T=e=>{let t=dr(e.createdDateTimeUtc,m);t!==w&&(w=t,_.push(hne(t)))};C&&S&&(T(S),d.textContent=C,a9(l,u,f,(a.replyAvatars??`First`)!==`None`,!1),_.push(l)),b.forEach((t,n)=>{let r=j(t);v.add(t.id),T(t);let i=b[n-1]??(C?cne:null);ee(r,t,e,a,n===b.length-1,i),_.push(r.li)});for(let e of[...y.keys()])v.has(e)||y.delete(e);e.agentTyping&&_.push(w3(e.agentTyping,m)),e.thinking?(clearTimeout(c),c=void 0,i.classList.remove(`wui-chat-message--leaving`),s=!0,r.update({active:!0,mark:o,style:a.loaderStyle,steps:e.steps,phrases:a.phrases,intervalMs:a.intervalMs,reduced:a.reduced,announce:a.assistantName?.trim()?m.preparingAnswer(a.assistantName):void 0}),_.push(i)):s&&c===void 0&&!fne(a)?(i.classList.add(`wui-chat-message--leaving`),c=setTimeout(()=>{c=void 0,s=!1,i.classList.remove(`wui-chat-message--leaving`),r.update({active:!1}),x&&ue(x.state,x.context)},sne),_.push(i)):c===void 0?(s=!1,r.update({active:!1})):_.push(i),!e.streaming&&(e.turnError||e.stopped)&&_.push(re(e,a)),D(t,_),le(e,g)}function de(e){return y.get(e)?.li??null}function fe(){clearTimeout(c),r.destroy(),h?.removeEventListener(`scroll`,se),_?.disconnect(),y.clear(),x=null,n.remove()}return{el:n,paint:ue,find:de,destroy:fe}}var l9=`wchat:auto-opened`,_ne=`wchat:dismissed`,vne=`button, a[href], input, select, textarea`,u9=`input, textarea`;function d9(e){return!e.closest(`.wui-chat`)}function yne(e){return e instanceof Element&&e.matches(u9)&&d9(e)}function bne(){return[...document.querySelectorAll(u9)].some(e=>d9(e)&&e.value!==e.defaultValue)}function f9(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function xne(e){return e?[...document.querySelectorAll(vne)].some(t=>{if(!d9(t))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}):!1}function Sne(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(l9)||e.rememberDismissal&&sessionStorage.getItem(_ne)||window.innerWidth<e.skipBelowWidthPx)return!0;let r=window.location.pathname;if(e.skipPathPrefixes.some(e=>r.startsWith(e)))return!0;let i=t.avoid.autoOpenOptOutSelector;return i&&document.querySelector(i)||e.skipWhenFormTouched&&bne()||n.isOpen()?!0:e.skipWhenCoversControl&&xne(n.panelRect())}function Cne(e){return yne(document.activeElement)||f9(e.avoid.menuSelectors)||f9(e.avoid.autoOpenBusySelectors)}function wne(e,t,n){let r;function i(){r=void 0,Sne(e,t,n)||(Cne(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(l9,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=void 0}}}var Tne=.4,Ene=.5,Dne=`rgba(0, 0, 0, 0)`,One=20,kne=`wui-consent-banner[open]`;function p9(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Ane(e){let t=e.createElement(`canvas`);t.width=1,t.height=1;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)throw Error(`A 2D canvas context is needed to read the colour under the launcher.`);return e=>{n.clearRect(0,0,1,1),n.fillStyle=Dne,n.fillStyle=e,n.fillRect(0,0,1,1);let[t=0,r=0,i=0,a=0]=n.getImageData(0,0,1,1).data;return{r:t,g:r,b:i,alpha:a/255}}}function jne({r:e,g:t,b:n}){return .2126*p9(e)+.7152*p9(t)+.0722*p9(n)}function Mne(e,t,n){let r=e.getBoundingClientRect(),i=document.elementsFromPoint?.(r.left+r.width/2,r.top+r.height/2)??[],a=t.length?t.join(`,`):null;for(let t of i){if(e.contains(t))continue;if(a&&t.closest(a))return!0;let r=n(getComputedStyle(t).backgroundColor);if(!(r.alpha<Ene))return jne(r)<Tne}return!1}function m9(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function Nne(e,t){let n=0;for(let r of e){let e=r.getBoundingClientRect();e.height!==0&&e.left<t.right&&e.right>t.left&&(n=Math.max(n,window.innerHeight-e.top))}return n>0?n+One:0}function Pne(e){if(e.length===0)return!1;for(let t of document.querySelectorAll(e.join(`,`))){let e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return!0}return!1}function Fne(e,t,n,r=e=>{n.dataset.launcher=e}){let i=n.ownerDocument.documentElement,a=t.switchOnDark?Ane(n.ownerDocument):null,o=0,s=!1,c=null;function l(){o=0;let l=[...t.liftAboveFooter?m9(e.liftSelectors):[],...t.liftAboveBanner?m9([kne]):[]];if(c)for(let e of l)c.observe(e);n.style.setProperty(`--wui-chat-lift`,`${Nne(l,n.getBoundingClientRect())}px`);let u=n.getBoundingClientRect(),d=u.height===0?0:Math.round(window.innerHeight-u.top);i.style.setProperty(`--wui-chat-launcher-block`,`${d}px`);let f=t.stepAsideForMenus&&Pne(e.menuSelectors);f&&!s?(r(`hidden`),n.inert=!0,s=!0):!f&&s&&(r(`idle`),n.inert=!1,s=!1);let p=a!==null&&Mne(n,e.darkSelectors,a);p&&n.dataset.onDark===void 0&&(n.dataset.onDark=``),!p&&n.dataset.onDark!==void 0&&delete n.dataset.onDark}function u(){o||=requestAnimationFrame(l)}typeof ResizeObserver==`function`&&(c=new ResizeObserver(u));let d=new MutationObserver(u);return d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`open`,`data-menu-open`]}),document.addEventListener(`scroll`,u,{capture:!0,passive:!0}),window.addEventListener(`resize`,u),window.addEventListener(`load`,u),n.addEventListener(`animationend`,u),u(),{destroy(){o&&cancelAnimationFrame(o),o=0,c?.disconnect(),d.disconnect(),document.removeEventListener(`scroll`,u,{capture:!0}),window.removeEventListener(`resize`,u),window.removeEventListener(`load`,u),n.removeEventListener(`animationend`,u),s&&=(n.inert=!1,!1),delete n.dataset.onDark,n.style.removeProperty(`--wui-chat-lift`),i.style.removeProperty(`--wui-chat-launcher-block`)}}}var h9=`wchat:session-start`,g9=`wchat:pages`,_9=`wchat:services`;function v9(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function y9(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function Ine(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function Lne(e){sessionStorage.getItem(h9)||sessionStorage.setItem(h9,String(Date.now()));let t=0;function n(){let e=document.documentElement.scrollHeight;if(e<=0)return;let n=(window.scrollY+window.innerHeight)/e*100;n>t&&(t=n)}return window.addEventListener(`scroll`,n,{passive:!0}),function(){n();let r=window.location.pathname,i=v9(g9);i.includes(r)||(i.push(r),y9(g9,i));let a=Ine(r,e),o=v9(_9);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),y9(_9,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(h9)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var b9=8,Rne=`(min-width: 992px)`,zne=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,x9=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],S9=0;function C9(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Bne(e){let{trigger:t,request:n,isEmpty:r,renderAnswer:i,renderFooter:a,session:o,timings:s,onStateChange:c,returnFocusTo:l}=e??{};if(!(t instanceof HTMLElement))throw TypeError(`createExplainPopover needs a "trigger" element.`);if(typeof n!=`function`)throw TypeError(`createExplainPopover needs a "request" function.`);if(typeof i!=`function`)throw TypeError(`createExplainPopover needs a "renderAnswer" function.`);S9+=1;let u=e.title??``,d=e.showNotCounted??!0,f=`wui-chat-explain-${S9}`,p=()=>Ae(e.labels??{}),m=()=>({labels:p(),close:ae}),h=Zt({request:n,...r===void 0?{}:{isEmpty:r},...s}),g=Object.fromEntries(x9.map(e=>[e,t.getAttribute(e)])),_=t.hidden,v;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,f);let y=null,b=null,x=null,S,C=null,w=[],T=[],E=()=>o?.getState().features.Explain===!1;function D(){h.getSnapshot().offline?(v===void 0&&(v=t.getAttribute(`title`)),t.setAttribute(`title`,p().explainOffline),t.setAttribute(`aria-disabled`,`true`),t.setAttribute(`data-offline`,``)):(v!==void 0&&C9(t,`title`,v),v=void 0,t.removeAttribute(`aria-disabled`),t.removeAttribute(`data-offline`)),o&&(t.hidden=E())}function O(e){if(b?.replaceChildren(),e.pillVisible){let t=$(`span`,`wui-chat-explain-pill`),n=$(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=$(`span`);r.textContent=e.state===`slow`?p().explainSlow:p().thinking,t.append(n,r);let i=$(`div`,`wui-chat-explain-thinking`,{role:`status`});i.append(t),b?.append(i)}else if(e.state===`answered`){e.answer!==S&&(x=i(e.answer,m())??null,S=e.answer);let t=$(`div`,`wui-chat-explain-answer`);x&&t.append(x),b?.append(t)}else if(e.state===`empty`){let e=$(`p`,`wui-chat-explain-text`);e.textContent=p().explainEmpty,b?.append(e)}else if(e.state===`capacity`){let t=$(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=$(`p`);n.textContent=e.resetsDateTimeUtc?p().explainCapacity(n9(e.resetsDateTimeUtc)):p().explainCapacityNoDate,t.append(n),b?.append(t)}else if(e.state===`error`){let e=$(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=$(`p`);t.textContent=p().explainError,e.append(t,t3(`ghost`,p().retry,`rotate-ccw`,()=>h.ask())),b?.append(e)}}function k(){let e=y?.querySelector(`.wui-chat-explain-foot`);e?.replaceChildren();let t=a?.(m());if(t&&e?.append(t),d){let t=$(`p`,`wui-chat-explain-note`);t.textContent=p().explainNotCounted,e?.append(t)}}function A(){if(!y)return;let e=h.getSnapshot();y.dataset.state=e.state,O(e),k(),c?.(e)}function j(){if(!y)return;if(!t.isConnected){ae({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wchat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Rne)?.matches===!0){y.dataset.beside=e,y.style.left=``,y.style.top=``,y.style.maxHeight=``;return}delete y.dataset.beside,y.style.position=`fixed`;let n=t.getBoundingClientRect(),r=y.offsetWidth,i=y.offsetHeight,a=globalThis.innerHeight-n.bottom-b9,o=a<i&&n.top>a,s=o?n.top-b9:a,c=o?Math.max(b9,n.top-i-b9):n.bottom+b9,l=Math.max(b9,Math.min(n.left,globalThis.innerWidth-r-b9));y.style.top=`${c}px`,y.style.left=`${l}px`,y.style.maxHeight=s<i?`${Math.max(0,s)}px`:``}function M(e){e.key===`Escape`&&(document.documentElement.hasAttribute(`data-wchat-docked`)||(e.stopPropagation(),ae()))}function ee(e){let n=e.target;n instanceof Node&&(y?.contains(n)||t.contains(n))||n instanceof Element&&n.closest(`.wui-chat-panel`)||ae({restoreFocus:!1})}function te(e){e.target instanceof Node&&y?.contains(e.target)||j()}function ne(){h.getSnapshot().offline||oe()}function re(){for(let[e,t,n,r]of w)e.removeEventListener(t,n,r);w=[];for(let e of T)e.disconnect();T=[]}function ie(){if(y||E()||h.getSnapshot().offline)return;y=$(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":u,popover:`manual`,id:f});let e=$(`header`,`wui-chat-explain-head`),n=$(`strong`,`wui-chat-explain-title`);n.textContent=u,C=n3(p().close,`x`,()=>ae()),C.classList.add(`wui-chat-explain-close`),e.append(n,C),b=$(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),y.append(e,b,$(`div`,`wui-chat-explain-foot`)),y.dataset.state=h.getSnapshot().state,document.body.append(y),y.showPopover?.(),t.setAttribute(`aria-expanded`,`true`),h.ask(),j(),(y.querySelector(zne)??C).focus({preventScroll:!0}),w=[[document,`keydown`,M,!0],[document,`pointerdown`,ee,!0],[window,`resize`,j,!1],[document,`scroll`,te,!0]];for(let[e,t,n,r]of w)e.addEventListener(t,n,r);if(typeof ResizeObserver==`function`){let e=new ResizeObserver(()=>j());e.observe(y),T.push(e)}let r=new MutationObserver(()=>j());r.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-wchat-docked`]}),T.push(r)}function ae(e={restoreFocus:!0}){y&&(h.reset(),re(),y.remove(),y=null,b=null,x=null,S=void 0,C=null,t.setAttribute(`aria-expanded`,`false`),D(),e?.restoreFocus!==!1&&(l?.()??t).focus({preventScroll:!0}))}function oe(){y?ae():ie()}let se=h.subscribe(()=>{D(),h.getSnapshot().offline&&y?ae():A()}),ce=o?.subscribe(()=>{D(),E()&&y&&ae({restoreFocus:!1})});return t.addEventListener(`click`,ne),D(),{open:ie,close:ae,toggle:oe,isOpen:()=>y!==null,destroy(){ae({restoreFocus:!1}),se(),ce?.(),h.dispose(),t.removeEventListener(`click`,ne);for(let e of x9)C9(t,e,g[e]);t.hidden=_}}}var Vne=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Hne(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(Vne)].filter(e=>e.tabIndex>=0&&!e.hidden),r=n[0],i=n[n.length-1];if(!r||!i){t.preventDefault();return}let a=e.ownerDocument.activeElement,o=e.contains(a);t.shiftKey?o&&a!==r||(t.preventDefault(),i.focus()):o&&a!==i||(t.preventDefault(),r.focus())}function Une(e){e?.isConnected&&e.focus()}function Wne(e,t){if(t||typeof navigator>`u`)return;let n=navigator;typeof n.vibrate==`function`&&n.vibrate(e)}var w9=`wui-chat-lock`,T9=`wui-chat-scroll-lock`;function Gne(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(w9);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(T9,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(w9);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(T9,{detail:{locked:!1}}))}}}var Kne={open:{from:420,to:920,seconds:.16,peak:.16},reply:{from:680,to:540,seconds:.11,peak:.06},sent:{from:540,to:760,seconds:.09,peak:.05}},E9=[`pointerdown`,`keydown`,`touchstart`],D9=`wchat:muted`,qne=1e-4;function Jne(e,t){let n=t.get(D9)===`1`,r=null;function i(){for(let e of E9)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume().catch(e=>globalThis.reportError?.(e)),i()}for(let e of E9)document.addEventListener(e,a);return{play(t){let i=Kne[t];if(!i||n||!r||!e[t]||!(e.volume>0))return;let a=r.currentTime,o=r.createOscillator(),s=r.createGain();o.type=`sine`,o.frequency.setValueAtTime(i.from,a),o.frequency.linearRampToValueAtTime(i.to,a+i.seconds),s.gain.setValueAtTime(i.peak*e.volume,a),s.gain.exponentialRampToValueAtTime(qne,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(D9,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close().catch(e=>globalThis.reportError?.(e)),r=null}}}var Yne=2e3,Xne=500,Zne=32,O9=16,k9=`data-wchat-switching`;function Qne(e){return new Promise(t=>setTimeout(t,e))}function A9(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=O9,setTimeout(i,O9))};setTimeout(i,O9)})}async function $ne(e,t={}){let n=t.reduced??globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;if(typeof document.startViewTransition!=`function`||n){await e();return}let r=document.documentElement;r.setAttribute(k9,``);try{let n=()=>!t.target||document.querySelector(`.wui-chat--${t.target}`)!==null,r=()=>(typeof t.pageReady!=`function`||t.pageReady())&&n(),i=document.startViewTransition(async()=>{await e(),await A9(t.routeReady,Yne),await A9(r,Xne),await Qne(Zne)});Promise.allSettled([i.ready]);try{await i.updateCallbackDone}finally{await Promise.allSettled([i.finished])}}finally{r.removeAttribute(k9)}}var ere=100,j9=12,tre=220;function nre(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=void 0,window.innerWidth>t.phone.maxWidthPx){a();return}if(!r)return;let o=Math.max(0,window.innerHeight-r.height-r.offsetTop),s=window.innerHeight-r.height>j9,c=r.height-(n||s?j9:0);n&&(c=Math.min(t.phone.sheetMaxHeightPx,Math.max(tre,c))),e.style.bottom=`${o}px`,e.style.maxHeight=`${c}px`}function s(){clearTimeout(i),i=setTimeout(o,ere)}return r?.addEventListener(`resize`,s),r?.addEventListener(`scroll`,s),window.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),o(),{destroy(){clearTimeout(i),r?.removeEventListener(`resize`,s),r?.removeEventListener(`scroll`,s),window.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s),a()}}}var M9=[`launcher`,`docked`,`full-page`,`embedded`],N9=[`end`,`start`],P9={steps:`Steps`,phrases:`Phrases`,orb:`Orb`,skeleton:`Skeleton`,"pulse-and-dots":`PulseAndDots`},rre={on:`On`,reduced:`Reduced`},ire={still:`Still`,drift:`Drift`},are=[`auto`,`light`,`dark`];function ore(e){return are.find(t=>t===e)??`auto`}var sre=`wchat:muted`,cre=`wchat:open`,lre=6e4,ure=400,dre=[`labels`,`pageContext`,`compact`,`expressive`,`open`,`layoutParts`,`getCaptchaToken`,`attribution`,`openAttachment`,`openCitation`,`openTarget`,`openTicket`,`onNavigate`,`resolveLink`,`emptyContent`,`onPanelSwitch`,`preloadPanelSwitch`],F9={...A5};function I9(e,t){if(!u3.includes(e))throw Error(`Unknown part kind "${e}". Use one of ${u3.join(`, `)}.`);if(typeof t!=`string`||!t.includes(`-`))throw Error(`Renderer tag "${t}" must be a custom element name containing a hyphen.`)}function fre(e,t){I9(e,t),F9[e]=t}function L9(e,t){return n=>{let r=n.toLowerCase(),i=Q4(t,r)?t[r]:void 0;if(i===void 0)throw Error(`<wui-chat ${e}> must be one of ${Object.keys(t).join(`, `)}, got "${n}".`);return i}}function R9(e,t){return n=>{let r=Number(n),i=t===void 0?`of pixels`:`from 0 to ${t}`;if(!Number.isInteger(r)||r<0||t!==void 0&&r>t)throw Error(`<wui-chat ${e}> must be a whole number ${i}, got "${n}".`);return r}}function z9(e){return t=>{if(t===``||t===`true`)return!0;if(t===`false`)return!1;throw Error(`<wui-chat ${e}> must be true or false, got "${t}".`)}}var B9=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),V9=[[`launcher-style`,`launcher`,`style`,L9(`launcher-style`,{round:`Round`,pill:`Pill`,expanding:`Expanding`})],[`entrance`,`launcher`,`entrance`,L9(`entrance`,{"slide-up":`SlideUp`,"bounce-in":`BounceIn`,"fade-in-pulse":`FadeInPulse`,"spin-scale":`SpinScale`,"wiggle-in":`WiggleIn`,"elastic-in":`ElasticIn`,rise:`Rise`,none:`None`})],[`idle`,`launcher`,`idle`,L9(`idle`,{"float-and-pulse":`FloatAndPulse`,ring:`Ring`,none:`None`})],[`label-reveal`,`launcher`,`labelReveal`,L9(`label-reveal`,{bubble:`Bubble`,expand:`Expand`})],[`compact`,`launcher`,`compact`,z9(`compact`)],[`launcher-mark`,`launcher`,`mark`,L9(`launcher-mark`,{icon:`Icon`,avatar:`Avatar`,orb:`Orb`})],[`panel-height`,`panel`,`height`,L9(`panel-height`,{fixed:`Fixed`,content:`Content`})],[`panel-placement`,`panel`,`placement`,L9(`panel-placement`,{floating:`Floating`,side:`Side`})],[`reply-avatars`,`panel`,`replyAvatars`,L9(`reply-avatars`,{none:`None`,first:`First`,every:`Every`})],[`greeting-loader-ms`,`panel`,`greetingLoaderMs`,R9(`greeting-loader-ms`)],[`panel-motion`,`panel`,`motion`,L9(`panel-motion`,{spring:`Spring`,gentle:`Gentle`,none:`None`})],[`panel-width`,`panel`,`widthPx`,R9(`panel-width`)],[`panel-max-height`,`panel`,`maxHeightPx`,R9(`panel-max-height`)],[`panel-bottom-gap`,`panel`,`bottomGapPx`,R9(`panel-bottom-gap`)],[`phone-max-width`,`phone`,`maxWidthPx`,R9(`phone-max-width`)],[`phone-mode`,`phone`,`mode`,L9(`phone-mode`,{"full-screen":`FullScreen`,sheet:`Sheet`})],[`sheet-height-dvh`,`phone`,`sheetHeightDvh`,R9(`sheet-height-dvh`)],[`sheet-max-height`,`phone`,`sheetMaxHeightPx`,R9(`sheet-max-height`)],[`phone-hide-launcher`,`phone`,`hideLauncher`,z9(`phone-hide-launcher`)],[`input-ring`,`input`,`ring`,z9(`input-ring`)],[`send-reveal`,`input`,`sendReveal`,L9(`send-reveal`,{"on-text":`OnText`,always:`Always`})],[`send-icon`,`input`,`sendIcon`,e=>e],[`input-mark`,`input`,`mark`,L9(`input-mark`,{none:`None`,avatar:`Avatar`})],[`footer-layout`,`footer`,`layout`,L9(`footer-layout`,{stacked:`Stacked`,inline:`Inline`})],[`input-edge`,`input`,`edge`,L9(`input-edge`,{none:`None`,gradient:`Gradient`})],[`input-placeholder`,`input`,`placeholder`,L9(`input-placeholder`,{plain:`Plain`,gradient:`Gradient`})],[`input-busy-edge`,`input`,`busyEdge`,L9(`input-busy-edge`,{off:`Off`,sweep:`Sweep`})],[`starters-style`,`starters`,`style`,L9(`starters-style`,{chips:`Chips`,rows:`Rows`})],[`recent-rows`,`starters`,`recentRows`,R9(`recent-rows`,5)],[`footer-disclaimer`,`footer`,`disclaimer`,L9(`footer-disclaimer`,{show:`Show`,hide:`Hide`})],[`lift-selectors`,`avoid`,`liftSelectors`,B9],[`menu-selectors`,`avoid`,`menuSelectors`,B9],[`dark-selectors`,`avoid`,`darkSelectors`,B9],[`autoopen-busy-selectors`,`avoid`,`autoOpenBusySelectors`,B9],[`autoopen-optout-selector`,`avoid`,`autoOpenOptOutSelector`,e=>e]],H9={layout:`launcher`,position:`end`,"offset-x":`24`,"offset-y":`24`,loader:`steps`,motion:`on`,icon:`chat`},U9=[`base`,`layout`,`position`,`offset-x`,`offset-y`,`loader`,`screen`,`motion`,`theme`,`icon`,`avatar`,`avatar-motion`,`narrow`,...V9.map(([e])=>e).filter(e=>e!==`compact`)],W9=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase());function G9(e){let t={launcher:{},panel:{},phone:{},input:{},avoid:{},footer:{},starters:{}};for(let[n,r,i,a]of V9){let o=e.getAttribute(n);o!=null&&(t[r][i]=a(o))}let n=e.getAttribute(`motion`),r=e.getAttribute(`avatar`),i=e.getAttribute(`avatar-motion`),a=e.getAttribute(`expressive`);return Fr({...t,...n==null?{}:{motion:L9(`motion`,rre)(n)},...r?{avatar:r}:{},...i==null?{}:{avatarMotion:L9(`avatar-motion`,ire)(i)},...a==null?{}:{expressive:z9(`expressive`)(a)}})}function pre(e){let t=e.getAttribute(`loader`)??`steps`,n=Q4(P9,t)?P9[t]:void 0;if(n===void 0)throw Error(`<wui-chat loader> must be one of ${Object.keys(P9).join(`, `)}, got "${t}".`);return n}function mre(e){let t=e.getAttribute(`narrow`);if(t!=null&&t!==``)return Object.fromEntries(B9(t).map(e=>[e,!1]))}function K9(e){return e===sre?globalThis.localStorage:globalThis.sessionStorage}var q9={get:e=>K9(e).getItem(e),set:(e,t)=>K9(e).setItem(e,t)};function J9(e){return globalThis.innerWidth<=e.phone.maxWidthPx}function hre(e){let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}function gre(e){return e.features.HumanHandoff===!0&&e.conversationState===`Open`&&e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`)&&!e.streaming&&!e.thinking}function _re(e,t){if(e.conversationState===`WaitingForAgent`)return t.statusWaitingForAgent;if(e.conversationState===`WithAgent`){let n=e.agent?.displayName;return t.statusWithAgent(typeof n==`string`&&n.trim()!==``?n:t.handoffAgentFallback)}return t.headerStatus}function Y9(e,t,n){return t.PanelSwitch!==!0||typeof n!=`function`?null:e===`docked`?`full-page`:e===`full-page`?`docked`:null}function vre(e){if(!M9.some(t=>t===e))throw Error(`<wui-chat layout> must be one of ${M9.join(`, `)}, got "${e}".`)}function X9(e){if(!N9.some(t=>t===e))throw Error(`<wui-chat position> must be one of ${N9.join(`, `)}, got "${e}".`)}function yre(e,t){let n=e[t];delete e[t],e[t]=n}function bre(e){return e==null?{}:Object(e)}var Z9=0,Q9=class extends qo{static get observedAttributes(){return[...U9,`compact`,`expressive`,`open`,`labels`,`page-context`,`narrow`].filter((e,t,n)=>n.indexOf(e)===t)}constructor(){super(),Z9+=1,this._uid=`wui-chat-${Z9}`,this._built=!1,this._session=null,this._unsubscribe=null,this._voice=null,this._voiceConversationId=void 0,this._labelsProp=void 0,this._pageContextProp=void 0,this._layoutParts=null,this._renderers={...F9},this._rendererApi={define:(e,t)=>{I9(e,t),this._renderers[e]=t,this._render()},map:this._renderers},this._captchaToken=null,this._attribution=null,this._openAttachmentProp=null,this._openCitationProp=null,this._openTargetProp=null,this._resolveLinkProp=null,this._openTicketProp=void 0,this._emptyContentProp=null,this._onPanelSwitchProp=null,this._preloadPanelSwitchProp=null,this._preloaded=!1,this._pastList=null,this._past=null,this._pastRefreshed=!1,this._historyShown=!1,this._openedConversation=null,this._lastOpen=!1,this._openTrigger=`manual`,this._focusTimer=null,this._nudgeArmed=!1,this._seeded=!1,this._wasLoading=!1,this._seen=new Set,this._sound=null,this._behaviour=null,this._autoOpen=null,this._avoid=null,this._motion=null,this._phone=null,this._requesting=!1,this._onKeyDown=e=>{e.key===`Escape`&&this._session?.getState().open&&(e.stopPropagation(),this._session.close(`escape`))}}get session(){return this._session??null}get conversationId(){return this._session?.getState().conversationId??null}get labels(){return Ae({...bre(r3(this,`labels`)),...this._labelsProp})}set labels(e){this._labelsProp=e??void 0,this._render()}get pageContext(){return this._pageContextProp===void 0?r3(this,`page-context`):this._pageContextProp}set pageContext(e){this._pageContextProp=e===null?void 0:e}get compact(){let e=this.getAttribute(`compact`);return e!=null&&z9(`compact`)(e)}set compact(e){this.toggleAttribute(`compact`,e===!0||e===``||e===`true`)}get expressive(){let e=this.getAttribute(`expressive`);return e!=null&&z9(`expressive`)(e)}set expressive(e){this.toggleAttribute(`expressive`,e===!0||e===``||e===`true`)}get open(){return this.hasAttribute(`open`)}set open(e){this.toggleAttribute(`open`,e===!0||e===``||e===`true`)}get renderers(){return this._rendererApi}get layoutParts(){return this._layoutParts}set layoutParts(e){this._layoutParts=typeof e==`function`?e:null,this._render()}get getCaptchaToken(){return this._captchaToken}set getCaptchaToken(e){this._captchaToken=typeof e==`function`?e:null}get attribution(){return this._attribution}set attribution(e){this._attribution=typeof e==`function`?e:null}get openAttachment(){return this._openAttachmentProp??(e=>this._defaultOpenAttachment(e))}set openAttachment(e){this._openAttachmentProp=typeof e==`function`?e:null}get openCitation(){return this._openCitationProp??((e,t)=>this._defaultOpenCitation(e,t))}set openCitation(e){this._openCitationProp=typeof e==`function`?e:null}get openTarget(){return this._openTargetProp??(e=>this._defaultOpenTarget(e))}set openTarget(e){this._openTargetProp=typeof e==`function`?e:null}get openTicket(){return this._openTicketProp}set openTicket(e){this._openTicketProp=typeof e==`function`?e:void 0}get onNavigate(){return this._onNavigateProp}set onNavigate(e){this._onNavigateProp=typeof e==`function`?e:void 0}get resolveLink(){return this._resolveLinkProp}set resolveLink(e){this._resolveLinkProp=typeof e==`function`?e:null}get emptyContent(){return this._emptyContentProp}set emptyContent(e){if(e!==null&&!(e instanceof Node))throw TypeError(`emptyContent must be a Node or null`);this._emptyContentProp=e,this._applyEmptyContent()}get onPanelSwitch(){return this._onPanelSwitchProp}set onPanelSwitch(e){this._onPanelSwitchProp=typeof e==`function`?e:null}get preloadPanelSwitch(){return this._preloadPanelSwitchProp}set preloadPanelSwitch(e){this._preloadPanelSwitchProp=typeof e==`function`?e:null}connectedCallback(){this._adoptEarlyProperties(),!this._built&&this.querySelector(`:scope > [data-wui-chat-placeholder]`)!==null&&(this._launcherPlayed=!0);let e=this._assertLayout();if(this._assertPosition(),this.base.trim()===``)throw TypeError(`<wui-chat> needs a base path, e.g. base="/api/assistant".`);this._built||this._build(),this._shell||this._buildShell(e),this._session||this._createSession(),this._past||this._createPast(),this._unsubscribe||=this.requireSession().subscribe(()=>this._render()),this._render()}_adoptEarlyProperties(){for(let e of dre)Q4(this,e)&&yre(this,e)}disconnectedCallback(){this._voice?.stop(),this._session?.stop(),this._unsubscribe?.(),this._unsubscribe=null,this._disposePast(),this._shell?.destroy?.(),document.removeEventListener(`keydown`,this._onKeyDown),this._avoid?.destroy(),this._avoid=null,this._autoOpen?.cancel(),this._autoOpen=null,this._motion?.destroy(),this._motion=null}attributeChangedCallback(e,t,n){if(this._built&&t!==n){if(e===`layout`)this._buildShell(this._assertLayout());else if(e===`position`)this._assertPosition();else if(e===`base`||e===`screen`||e===`narrow`)this._resetSession();else if(e===`motion`)this._motion?.destroy(),this._motion=null;else if(e===`open`&&this._session){let e=this._session.getState().open;this.open!==e&&this._setOpen(this.open,`manual`)}this._render()}}toggle(){this._session&&(this._session.getState().open?this._session.close(`button`):this._setOpen(!0,`manual`))}close(){this._voice?.stop(),this._session?.close(`button`)}newConversation(){this._voice?.stop(),this._session?.newConversation(),this._past?.refresh()}reset(){this._voice?.stop(),this._session?.reset()}_setOpen(e,t){this._session&&(e?(this._openTrigger=t,this._session.open({trigger:t})):this._session.close(`button`))}_assertLayout(){let e=this.layout;return vre(e),e}_assertPosition(){X9(this.position)}get _position(){let e=this.position;return X9(e),e}_isLauncherLike(){return this.layout===`launcher`||this.layout===`docked`}requireSession(){if(!this._session)throw TypeError(`wui-chat: _session is not ready; the element is not connected`);return this._session}requireVoice(){if(!this._voice)throw TypeError(`wui-chat: _voice is not ready; the element is not connected`);return this._voice}requireMotion(){if(!this._motion)throw TypeError(`wui-chat: _motion is not ready; the element is not connected`);return this._motion}requirePastList(){if(!this._pastList)throw TypeError(`wui-chat: _pastList is not ready; the element is not connected`);return this._pastList}requireNudgeHost(){if(!this._shell.nudgeHost)throw TypeError(`wui-chat: the launcher shell has no nudge host`);return this._shell.nudgeHost}_build(){this._built=!0,this._markMaker=s3(a3(this)),this._header=h7({onNew:()=>this.newConversation(),onHistory:()=>this._toggleHistory(),onClose:()=>this.close(),onMute:()=>{this._session&&this._session.setMuted(!this._session.getState().muted)},onSwitch:()=>this._switchPanel(),titleId:`${this._uid}-title`,mark:this._markMaker}),this._starters=Ute({mark:this._markMaker,onStarter:e=>this.requireSession().submit(e.message),onResume:()=>this.requireSession().resumeLast(),onTicket:e=>{typeof this.openTicket==`function`&&this.openTicket({ticketId:e.ticketId,number:e.number})},onOpenConversation:e=>{Promise.allSettled([this.requireSession().openConversation(e)])}}),this._applyEmptyContent(),this._voice=t7({getState:()=>this.requireSession().getState(),getToken:()=>this.requireSession().client.getSpeechToken()}),this._voice.subscribe(()=>this._render()),this._thread=gne({mark:this._markMaker,getRenderers:()=>this._renderers,getLayoutParts:()=>this._layoutParts,makeTurnApi:e=>this._makeTurnApi(e),onRetry:()=>this.requireSession().retry(),onRegenerate:()=>this.requireSession().regenerate(),onRate:(e,t)=>this.requireSession().rate(e,t),getSession:()=>this.requireSession(),getVoice:()=>this._voice}),this._composer=l7({mark:this._markMaker,voice:this._voice,onSubmit:e=>this.requireSession().submit(e),onStop:()=>this.requireSession().stop(),onAttach:e=>this.requireSession().attach(e),onRemove:e=>this.requireSession().removeAttachment(e),onCancelEdit:()=>this.requireSession().cancelEdit(),onTyping:()=>this.requireSession().notifyTyping(),onDraftApplied:()=>this.requireSession().consumeDraft()}),this._footer=p7(),this._history=v7({getClient:()=>this.requireSession().client,getLabels:()=>this.labels,getFeatures:()=>this.requireSession().getState().features,onOpen:e=>{Promise.allSettled([this.requireSession().openConversation(e)]),this._toggleHistory(!1)},onDeleted:e=>{e===this.conversationId&&this.requireSession().newConversation()}}),this._nudge=w7({onActivate:()=>this._setOpen(!0,`manual`),onDismiss:()=>{}}),this._status=$(`p`,null,{role:`status`}),this._status.hidden=!0,this._errorEl=$(`p`,`wui-chat-profile-error`,{role:`alert`}),this._errorEl.hidden=!0,this._liveStatus=$(`p`,`wui-chat-live-status`,{role:`status`}),this._liveStatus.hidden=!0,this._talk=$(`button`,`${e3(`outline`,`sm`)} wui-chat-handoff-request`,{type:`button`}),this._talk.addEventListener(`click`,()=>this._requestHandoff()),this._liveRetry=$(`button`,e3(`ghost`,`sm`),{type:`button`}),this._liveRetry.addEventListener(`click`,()=>this.requireSession().resumeLive()),this._liveError=$(`p`,`wui-chat-live-error`,{role:`alert`}),this._liveError.hidden=!0,this._live=$(`div`,`wui-chat-live`),this._live.append(this._liveStatus,this._talk,this._liveRetry,this._liveError),this._live.hidden=!0,this._body=$(`div`,`wui-chat-body`),this._body.append(this._starters.el,this._thread.el,this._live,this._history.el,this._status,this._errorEl),this._foot=$(`div`,`wui-chat-foot`),this._foot.append(...this._composer.nodes,this._footer.el)}_buildShell(e){let t={launcher:Lte,docked:Nte,"full-page":Rte,embedded:Pte};this._shell?.destroy?.(),this._avoid?.destroy(),this._avoid=null,this._autoOpen?.cancel(),this._autoOpen=null,this._lastOpen=!1,this._launcherPlayed=!1;let n=t[e]({mark:this._markMaker,id:`${this._uid}-panel`,position:this._position,onToggle:()=>this.toggle()});n.panel.append(this._header.el,this._body,this._foot),n.panel.setAttribute(`aria-labelledby`,`${this._uid}-title`),n.panel.addEventListener(`keydown`,e=>{e.key===`Tab`&&Hne(n.panel,e)}),n.nudgeHost&&n.nudgeHost.prepend(this._nudge.el),this._shell=n,this.replaceChildren(n.root)}_createSession(){let e=Wt(C7(),{base:this.base}),t=mre(this);this._session=ii(e,{...this.screen?{screen:this.screen}:{},...t===void 0?{}:{narrow:t},recentConversations:G9(this).starters.recentRows,pageContext:()=>this.pageContext,attribution:()=>this._attribution?.()??null,behaviour:()=>this._session?.getState().features.BehaviourStarters?this._behaviour?.()??null:null,prefs:q9,reducedMotion:()=>this._motion?.reduced??!1,schedule:hre,getCaptchaToken:e=>{if(this._captchaToken)return this._captchaToken(e);let t=this._session?.getState().profile?.captcha?.siteKey;return t?j7(t,e):Promise.resolve(null)},onEvent:(e,t)=>{this.dispatchEvent(new CustomEvent(`wui-chat-event`,{bubbles:!0,detail:{name:e,data:t}}))},onError:()=>{},labels:this.labels}),this._unsubscribe=null,this._lastOpen=!1,this._openApplied=!1,this._seeded=!1,this._wasLoading=!1,this._seen=new Set,this._pastRefreshed=!1}_createPast(){this._pastList=qt({client:this.requireSession().client,pageSize:20}),this._past=E7({list:this._pastList,getLabels:()=>this.labels,getFeatures:()=>this.requireSession().getState().features,onOpen:e=>{Promise.allSettled([this.requireSession().openConversation(e)])}}),this._starters.pastHost.append(this._past.el)}_disposePast(){this._past&&(this._past.el.remove(),this._past.dispose(),this.requirePastList().dispose(),this._past=null,this._pastList=null)}_applyEmptyContent(){if(!this._starters)return;let e=this._starters.extraHost;e.replaceChildren(...this._emptyContentProp?[this._emptyContentProp]:[]),e.hidden=!this._emptyContentProp}_switchPanel(){let e=this.requireSession().getState(),t=this._onPanelSwitchProp,n=Y9(this.layout,e.features,t);if(t===null||n===null)return;n===`full-page`&&this.close();let r={from:this.layout,to:n,conversationId:e.conversationId,draft:this._composer.getDraft()};$ne(()=>t.call(this,r),{target:n,reduced:this._motion?.reduced===!0}).then(()=>document.querySelector(`.wui-chat--${n} .wui-chat-input`)?.focus()).catch(e=>globalThis.reportError?.(e))}async _requestHandoff(){this._requesting=!0,this._liveError.hidden=!0,this._render();try{await this.requireSession().requestHandoff()}catch(e){let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;this._liveError.textContent=typeof t==`string`&&t||this.labels.errorGeneric,this._liveError.hidden=!1}finally{this._requesting=!1,this._render()}}_paintLive(e,t,n){let r=e.live===`Lost`,i=gre(e);this._liveStatus.hidden=!r,this._liveStatus.textContent=r?t.liveLost:``,this._liveRetry.hidden=!r,this._liveRetry.textContent=t.retry,this._talk.hidden=!i,this._talk.textContent=t.talkToPerson,this._talk.disabled=this._requesting,this._live.hidden=n||!r&&!i}_resetSession(){this._voice?.stop(),this._unsubscribe?.(),this._unsubscribe=null,this._session?.dispose(),this._session=null,this._disposePast(),this._history.dispose(),this.isConnected&&(this._createSession(),this._createPast(),this._unsubscribe=this.requireSession().subscribe(()=>this._render()))}_toggleHistory(e=!this._historyShown){this._historyShown=e,e?this._history.show():this._history.hide(),this._render()}_makeTurnApi(e){let t=oi(this.requireSession(),{messageId:e,labels:this.labels,openAttachment:e=>this.openAttachment(e),openCitation:t=>this.openCitation(e,t),openTarget:e=>this.openTarget(e),openTicket:this.openTicket,onNavigate:this.onNavigate});return t.resolveLink=this.resolveLink,t}_defaultOpenAttachment(e){this.requireSession().client.getAttachment(e.attachmentId).then(t=>{let n=URL.createObjectURL(new Blob([t],{type:e.contentType}));window.open(n,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(n),lre)}).catch(e=>globalThis.reportError?.(e))}_defaultOpenCitation(e,t){let n=this._thread.find(e);if(n){for(let e of n.querySelectorAll(`[data-marker]`))if(e.dataset.marker===String(t)){e.focus();return}}}_defaultOpenTarget(e){/^https?:\/\//i.test(e)?window.open(e,`_blank`,`noopener`):window.location.assign(e)}_render(){this._built&&this._session&&this._paint(this._session.getState())}_paint(e){this._shell.root.toggleAttribute(`data-busy`,e.streaming||e.thinking),e.conversationId!==this._voiceConversationId&&(this._voiceConversationId=e.conversationId,this.requireVoice().stop());let t=this.labels,n=e.profile,r=this._isLauncherLike();if(!n){this.hidden=r,this._header.el.hidden=!0,this._starters.el.hidden=!0,this._thread.el.hidden=!0,this._history.el.hidden=!0,this._foot.hidden=!0,this._errorEl.hidden=e.profileError==null,e.profileError&&(this._errorEl.textContent=e.profileError.message),this._status.hidden=e.profileError!=null,this._status.textContent=t.loadingConversation,this._shell.panel.setAttribute(`aria-busy`,String(e.profileError==null));return}if(this._shell.panel.removeAttribute(`aria-busy`),!e.features.VisitorChat){this.hidden=!0,this._status.hidden=!0;return}this.hidden=!1;let i=e.features,a=G9(this);this._ensureRuntime(e,n,a,t);let o=e.loading,s=e.loadError,c=e.messages.length===0&&!o,l=this._historyShown&&i.History===!0,u=e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`),d=Y9(this.layout,i,this._onPanelSwitchProp),f=e.streaming||e.thinking;this._header.paint({labels:t,title:t.panelTitle||n.assistant.name||t.assistant,tagline:n.assistant.tagline,status:_re(e,t),canNew:!f,showNew:this.layout===`full-page`||u,showHistory:i.History,showClose:r||this.layout===`full-page`&&d!==null,switchTo:d,canSwitch:!f,viewingHistory:l,showMute:i.Sounds&&n.experience.sound.muteControl,muted:e.muted}),Dte(this._header.conversation,e,{labels:t,features:i,title:n.assistant.name||t.assistant,getState:()=>this.requireSession().getState(),iconOnly:!0}),l&&(this._header.conversation.hidden=!0),this._starters.el.hidden=!c||l,c&&e.open&&!this._introPlayed&&a.panel.greetingLoaderMs>0&&!this.requireMotion().reduced&&(this._introPlayed=!0,this._starters.intro(a.panel.greetingLoaderMs)),c&&this._starters.paint({labels:t,greeting:e.greeting,intro:n.assistant.intro,starters:e.starters,showStarters:i.Starters&&!e.streaming,resume:!i.History&&i.ResumeLast?e.lastConversation:null,recent:e.recentConversations,openTickets:e.openTickets,features:e.features,ticketsClickable:typeof this.openTicket==`function`}),i.History&&!this._pastRefreshed&&(this._pastRefreshed=!0,this._past?.refresh()),this._past?.paint(),this._starters.pastHost.hidden=e.recentConversations.length>0;let p=!c&&!o&&!s&&!l;this._thread.el.hidden=!p,p&&this._thread.paint(e,{labels:t,loaderStyle:pre(this),reduced:this._motion?.reduced??!1,phrases:n.experience.pacing.thinkingPhrases,intervalMs:n.experience.pacing.phraseIntervalMs,assistantName:n.assistant.name,replyAvatars:a.panel.replyAvatars}),this._paintLive(e,t,l),this._status.hidden=!o||l,this._status.textContent=t.loadingConversation,this._errorEl.hidden=!s||l,s&&(this._errorEl.textContent=s.message),this._foot.hidden=l,this._composer.paint({state:e,labels:t,maxLength:n.limits.maxMessageLength,accept:n.limits.contentTypes.join(`,`),draft:e.draft??null,sendIcon:a.input.sendIcon,inputMark:a.input.mark,busy:e.streaming||e.thinking}),this._footer.paint({labels:t,profile:n,hideDisclaimer:a.footer.disclaimer===`Hide`}),this._history.el.hidden=!l,this._syncOpen(e,n,i,t,r),this._syncConversation(e),this._playSounds(e)}_ensureRuntime(e,t,n,r){let i=e.features;this._motion||(this._motion=Y4(n,t.experience),this._motion.subscribe(()=>this._render())),i.Sounds&&!this._sound&&(this._sound=Jne(t.experience.sound,q9)),!i.Sounds&&this._sound&&(this._sound=null),i.BehaviourStarters&&!this._behaviour&&(this._behaviour=Lne(t.start.behaviour?.servicePathPrefixes??[]));let a=this._isLauncherLike();a&&!this._avoid&&this.layout===`launcher`&&(this._avoid=Fne(n.avoid,t.experience.launcher,this.requireNudgeHost(),this._shell.setLauncherState)),this.layout===`launcher`&&i.AutoOpen&&!this._autoOpen&&(this._autoOpen=wne(t.experience.autoOpen,n,{open:()=>this._setOpen(!0,`auto`),isOpen:()=>this.requireSession().getState().open,panelRect:()=>this._shell.panel.getBoundingClientRect()}));let o=J9(n);this._shell.setLabels(r),this._shell.setAppearance({position:this._position,offsetX:this.hasAttribute(`offset-x`)?R9(`offset-x`)(this.getAttribute(`offset-x`)??``):void 0,offsetY:this.hasAttribute(`offset-y`)?R9(`offset-y`)(this.getAttribute(`offset-y`)??``):void 0,width:`${n.panel.widthPx}px`,maxHeight:n.panel.maxHeightPx,bottomGap:n.panel.bottomGapPx,reduced:this._motion.reduced,sendReveal:n.input.sendReveal,inputRing:n.input.ring,panelMotion:n.panel.motion,theme:ore(this.getAttribute(`theme`)),icon:this.icon,launcherStyle:n.launcher.style,compact:n.launcher.compact,labelReveal:n.launcher.labelReveal,entrance:n.launcher.entrance,idle:n.launcher.idle,launcherMark:n.launcher.mark,panelHeight:n.panel.height,panelPlacement:n.panel.placement,inputMark:n.input.mark,inputEdge:n.input.edge,inputBusyEdge:n.input.busyEdge,inputPlaceholder:n.input.placeholder,phoneHideLauncher:n.phone.hideLauncher,replyAvatars:n.panel.replyAvatars,footerLayout:n.footer.layout,startersStyle:n.starters.style,avatar:n.avatar,avatarMotion:n.avatarMotion,expressive:n.expressive,phone:o,hoverLabel:t.experience.launcher.hoverLabel,peek:t.experience.launcher.peek,peekSeconds:t.experience.launcher.peekSeconds,hideWhileOpen:t.experience.launcher.hideWhileOpen,phoneMode:n.phone.mode,sheetHeightDvh:n.phone.sheetHeightDvh,sheetMaxHeightPx:n.phone.sheetMaxHeightPx,launcherState:this._launcherPlayed?void 0:`entering`}),this._launcherPlayed=!0,this._shell.root.classList.toggle(`wui-chat--phone`,a&&J9(n))}_syncOpen(e,t,n,r,i){if(i){if(!this._openApplied&&(this._openApplied=!0,this.hasAttribute(`open`)&&!e.open))this._setOpen(!0,`manual`);else if(this._shell.setOpen(e.open),this.toggleAttribute(`open`,e.open),e.open!==this._lastOpen&&(this._lastOpen=e.open,q9.set(cre,e.open?`1`:`0`),this._onOpenChange(e.open)),e.open)this._nudge.cancel(),this._nudgeArmed=!1,this._autoOpen?.cancel();else if(n.Nudges&&this.layout===`launcher`&&!this._nudgeArmed){let e=Ie(t,n);e&&(this._nudge.schedule({text:e.text,delaySeconds:e.delaySeconds,label:r.nudgeDismiss}),this._nudgeArmed=!0)}}}_onOpenChange(e){let t=J9(G9(this));if(e){if(document.addEventListener(`keydown`,this._onKeyDown),this._sound?.play(`open`),this._past?.refresh(),this.layout===`docked`&&!this._preloaded&&typeof this._preloadPanelSwitchProp==`function`){this._preloaded=!0;let e=this._preloadPanelSwitchProp;Promise.allSettled([new Promise(t=>t(e.call(this)))]).then(e=>{for(let t of e)t.status===`rejected`&&globalThis.reportError?.(t.reason)})}if(t){let e=G9(this);this._phone={fit:nre(this._shell.panel,e),unlock:Gne(this._thread.el)}}else this._openTrigger===`manual`&&(this._focusTimer=setTimeout(()=>{this._focusTimer=null,this._composer.focus()},ure))}else document.removeEventListener(`keydown`,this._onKeyDown),clearTimeout(this._focusTimer??void 0),this._focusTimer=null,this._phone?.fit.destroy(),this._phone?.unlock(),this._phone=null,this._historyShown&&(this._historyShown=!1,this._history.hide(),this._render()),Une(this._shell.launcherButton)}_syncConversation(e){let t=this.getAttribute(`conversation-id`);t&&t!==this._openedConversation&&!e.loading&&(this._openedConversation=t,e.conversationId!==t&&Promise.allSettled([this.requireSession().openConversation(t)]))}_playSounds(e){if(e.loading){this._wasLoading=!0;for(let t of e.messages)this._seen.add(t.id)}else if(this._wasLoading||!this._seeded){this._wasLoading=!1,this._seeded=!0;for(let t of e.messages)this._seen.add(t.id)}else for(let t of e.messages)this._seen.has(t.id)||(this._seen.add(t.id),this._announce(t))}_announce(e){if(!this._sound||e.restored||e.parts.some(e=>e.kind===`Notice`))return;let t=e.author.kind;if(t===`Visitor`)e.stored||this._sound.play(`sent`);else if(t===`Assistant`||t===`Script`||t===`Agent`){this._sound.play(`reply`);let e=this.requireSession().getState().profile;e?.experience.sound.vibrate&&Wne(e.experience.sound.vibrateMs,this._sound.isMuted())}}};Object.defineProperty(Q9.prototype,"layout",{get(){return this.getAttribute(`layout`)??H9.layout},set(e){this.setAttribute(`layout`,String(e))}});for(let e of U9)e!==`layout`&&Object.defineProperty(Q9.prototype,W9(e),{configurable:!0,get(){return this.getAttribute(e)??H9[e]??``},set(t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}});function $9(){typeof customElements<`u`&&!customElements.get(`wui-chat`)&&customElements.define(`wui-chat`,Q9)}$9(),$9(),globalThis.WeborityChat=Object.assign(globalThis.WeborityChat||{},{session:e=>e.session,renderers:{define:fre},createExplainPopover:Bne})})();
|
|
44
|
+
`),language:i});continue}if(p8(t,r)){let i=f8(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!d8(e))break;a.push(f8(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(a8.test(e)){n.push({type:`rule`}),r+=1;continue}let i=i8.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=u8[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(c8.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=c8.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=g8(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=g8(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(m8(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||m8(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var v8=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],y8=[`razor`,`cshtml`],b8=[`app`,`web`,`page`],x8=e=>e!==void 0&&b8.includes(e);function S8(e,t,n,r,i=null){let a=C8(n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function C8(e,t){let n={links:x8(t.links)?t.links:`web`,headings:t.headings===`text`?`text`:`outline`,resolveLink:t.resolveLink,isCitation:t.isCitation,figureText:typeof t.figureText==`function`?t.figureText:void 0,base:typeof t.base==`string`?t.base:void 0},r=t.resolverGeneration??0;return _8(e).map(e=>({sig:`${JSON.stringify(e)}|${n.links}|${n.headings}|${n.base??``}|${r}`,build:()=>T8(n,e)}))}var w8=class extends z3{_drawn;_blocks;_observer;_connected;_resolveLink;_isCitation;_resolverGeneration;_figureText;static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=S8(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,base:this.getAttribute(`base`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,figureText:this._figureText,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function T8(e,t){switch(t.type){case`paragraph`:return[Vi(`p`,null,...E8(e,t.lines))];case`heading`:return[D8(e,t)];case`list`:return O8(e,t.items);case`table`:return[A8(e,t)];case`code`:return[M8(t)];case`quote`:return[Vi(`blockquote`,null,...E8(e,t.lines))];case`rule`:return[Vi(`hr`)];default:return[]}}function E8(e,t){let n=[];return t.forEach((t,r)=>{r>0&&n.push(Vi(`br`)),n.push(...N8(e,t))}),n}function D8(e,t){let n=N8(e,t.text);return e.headings===`text`?Vi(`p`,{class:`fw-semibold`},...n):Vi(`h2`,null,...n)}function O8(e,t){let n=[];for(let r=0;r<t.length;){let i=k8(e,t,r);n.push(i.list),r=i.next}return n}function k8(e,t,n){let r=t[n];if(!r)throw Error(`List run starts past its items.`);let{depth:i,ordered:a,number:o}=r,s=Vi(a?`ol`:`ul`,a&&o!==1?{start:o}:null),c=null,l=n,u=t[l];for(;u&&u.depth>=i;){if(u.depth===i)c=Vi(`li`,null,...N8(e,u.text)),s.append(c),l+=1;else{let n=k8(e,t,l);if(!c)throw Error(`Nested list has no item before it.`);c.append(n.list),l=n.next}u=t[l]}return{list:s,next:l}}function A8(e,t){let n=t.header.map(t=>Vi(`th`,{scope:`col`},...N8(e,t))),r=t.rows.map(n=>Vi(`tr`,null,...t.header.map((t,r)=>Vi(`td`,null,...N8(e,n[r]??``)))));return Vi(`div`,{class:`table-responsive`},Vi(`table`,{class:`table`},Vi(`thead`,null,Vi(`tr`,null,...n)),Vi(`tbody`,null,...r)))}function j8(e){return e===null?`text`:y8.includes(e.toLowerCase())?`razor`:v8.includes(e)?e:`text`}function M8(e){let t=Vi(`pre`,{class:`wui-code-source`},Vi(`code`,null,e.text));return Vi(`wui-code-block`,{class:`wui-code-block`,language:j8(e.language)},t)}function N8(e,t){return P8(e,U6(t,{isCitation:e.isCitation}))}function P8(e,t){return t.flatMap(t=>F8(e,t))}function F8(e,t){switch(t.type){case`code`:return[Vi(`code`,null,t.text)];case`strong`:return[Vi(`strong`,null,...P8(e,t.children))];case`em`:return[Vi(`em`,null,...P8(e,t.children))];case`strike`:return[Vi(`del`,null,...P8(e,t.children))];case`image`:return[document.createTextNode(`[`),...P8(e,t.children),document.createTextNode(`]`)];case`link`:return L8(e,t);case`citation`:return[z8(t.text)];case`text`:return e.figureText?R8(e.figureText,t.text):[document.createTextNode(t.text)];default:return[document.createTextNode(I8(t))]}}function I8(e){let t=e;return typeof t==`object`&&t&&`text`in t?String(t.text):`undefined`}function L8(e,t){let n=P8(e,t.children),r=Z6(t.href,e.links,e.resolveLink,globalThis.location?.origin,e.base);if(!r)return n;if(r.kind===`app`){let e=t8(r.target);return e?[B8(e,n,!1)]:n}return[B8(r.href,n,r.kind===`web`)]}function R8(e,t){return e(t).map(e=>e.kind===`sub`||e.kind===`sup`?Vi(e.kind,null,e.text):document.createTextNode(e.text))}function z8(e){let t=Vi(`span`,{class:`chip-label`},e),n=Vi(`button`,{type:`button`,class:`chip-body`,"aria-label":e},t);return n.addEventListener(`click`,()=>{n.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:e}}))}),Vi(`span`,{class:`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,"data-wui":`AppChip`},n)}function B8(e,t,n){let r=Vi(`span`,{class:`wui-link__label`},...t);return Vi(`a`,{class:`wui-link wui-link--static`,"data-wui":`AppLink`,href:e,target:n?`_blank`:void 0,rel:n?`noopener noreferrer`:void 0},r)}L3(`wui-markdown`,w8);var V8=`AppButton`,H8=new Set([`primary`,`success`,`warning`,`danger`,`info`,`neutral`]),U8={solid:e=>`btn-${e}`,soft:e=>`btn-soft-${e}`,outline:e=>`btn-outline-${e}`,ghost:e=>`btn-ghost-${e}`,link:e=>`btn-link-${e}`,glass:()=>`btn-glass`};function W8(e){return $i(U8,e)}function G8(e=`primary`,t=`solid`,n=`md`){if(!H8.has(e))throw RangeError(`buttonClass: unknown tone "${e}"`);if(!W8(t))throw RangeError(`buttonClass: unknown variant "${t}"`);let r=U8[t](e);return n===`md`?`btn ${r}`:`btn ${r} btn-${n}`}var K8={copiedLabel:`Copied`,copyLabel:`Copy`,label:`Code`};Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`]);var q8=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,razor:`Razor`,css:`CSS`}),J8=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),Y8=`(?![\\s\\S])`,X8=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${Y8})`).source,Z8=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,J8([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],Q8=[[`comment`,RegExp(`//[^\\n]*|${X8}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,J8(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,J8([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],$8=[[`comment`,RegExp(`//[^\\n]*|${X8}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,J8(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,J8([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],e5=[[`comment`,RegExp(`--[^\\n]*|${X8}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,J8(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,J8([`true`,`false`])],[`type`,J8([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],t5=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,J8([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,J8(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],n5=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],r5=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${Y8})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],i5={json:Z8,js:Q8,cs:$8,sql:e5,bash:t5,http:n5,css:[[`comment`,new RegExp(X8)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:r5,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},a5=e=>$i(i5,e),o5=new Map;function s5(e){let t=o5.get(e);if(!t){let n=i5[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},o5.set(e,t)}return t}function c5(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function l5(e,t,n=[]){let{re:r,types:i}=s5(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;c5(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?l5(`htmlTag`,r,n):c5(n,i[s]??`plain`,r),a=o.index+r.length}return c5(n,`plain`,t.slice(a)),n}function u5(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return l5(`http`,e);let n=t[0]??``,r=l5(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?l5(`json`,i,r):a===`<`?l5(`html`,i,r):(c5(r,`plain`,i),r)}function d5(e,t){let n=String(e??``);if(!n||n.length>1e5)return n?[[`plain`,n]]:[];if(t===`http`)return u5(n);let r=t===`razor`?`html`:t;return!a5(r)||r===`htmlTag`?[[`plain`,n]]:l5(r,n)}function f5(e,t){let n=[],r=[n];for(let[i,a]of d5(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}var p5=()=>Mi(`codeBlock`,K8);function m5(e){return $i(q8,e)}var h5=class extends z3{_title;_view;_codeEl;_copyIcon;_copyText;_chrome=null;_copied=!1;_observer=null;_timer=0;_cancelFrame=null;constructor(){super();let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=t!==null&&m5(t)?t:`text`,r=this.getAttribute(`label`)||``,i=f5(this._code(),n);this._title.textContent=r||q8[n],this._view.setAttribute(`aria-label`,r||p5().label),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>g5(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`;let n=e.createElement(`button`);return n.type=`button`,n.className=`${G8(`primary`,`ghost`,`sm`)} wui-code-copy`,n.dataset.wui=V8,n.setAttribute(`aria-live`,`polite`),this._setCopied(!1),n.append(this._copyIcon,this._copyText),n.addEventListener(`click`,async()=>{await zi(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),2e3))}),t.append(this._title,n),t}_setCopied(e){this._copied=e;let t=To(e?`check`:`files`,{size:14});this._copyIcon.replaceChildren(...t?[t]:[]),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||p5().copiedLabel:this.getAttribute(`copy-label`)||p5().copyLabel}};function g5(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}L3(`wui-code-block`,h5);var _5=new Set([`Visitor`,`Customer`]),v5=/^\d+$/;function y5(e,t){return e?.features?.Sources===!0?typeof e?.isCitation==`function`?e.isCitation(t):v5.test(t):!1}function b5(e,t){if(Dr(e,t?.handoffHosts))return e;let n=t?.resolveLink?.(e);return typeof n==`string`&&n!==``?n:null}function x5(e,t){let n=globalThis.location?.origin;for(let r of e.querySelectorAll(`a[href]`)){let e=r.dataset.linkSource??r.getAttribute(`href`)??``;r.dataset.linkSource=e;let i=b5(e,t);i===null?r.replaceWith(r.ownerDocument.createTextNode(r.textContent??``)):(i!==r.getAttribute(`href`)&&r.setAttribute(`href`,i),Ln(i,`web`,void 0,n)?.kind===`web`?(r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`)):(r.removeAttribute(`target`),r.removeAttribute(`rel`)))}}function S5(e,t){x5(e,t)}Yo(`wui-chat-part-text`,class extends Jo{#e=null;#t=null;#n=!1;#r=null;constructor(){super(),this.addEventListener(`wui-markdown-citation`,e=>{let t=this.turn;typeof t?.openCitation==`function`&&t.openCitation(Number(e.detail.citation))}),this.addEventListener(`click`,e=>this.#a(e))}renderPart(e,t,n){let r=_5.has(t.author.kind)?`plain`:`markdown`,i=this.#e;if((i===null||i.mode!==r)&&(i=r===`plain`?{mode:r,node:this.#s()}:this.#c(e.text),this.#e=i,this.#t=null,this.replaceChildren(i.node)),i.mode===`plain`){let t=this.turn?.features?.FigureText===!0,n=JSON.stringify([e.text,t]);n!==this.#t&&(this.#t=n,i.node.replaceChildren(),t?M4(i.node,vn(e.text)):i.node.append(this.ownerDocument.createTextNode(e.text)))}else this.#o(i.node),i.source.textContent!==e.text&&(i.source.textContent=e.text);this.toggleAttribute(`data-streaming`,t.streaming===!0),this.#n||(this.#n=!0,this.closest(`[data-restored]`)||this.classList.add(`wui-chat-part-enter`)),this.#i()}disposePart(){this.#r?.disconnect(),this.#r=null}#i(){this.#r||(this.#r=new MutationObserver(()=>S5(this,this.turn)),this.#r.observe(this,{childList:!0,subtree:!0,characterData:!0}),S5(this,this.turn))}#a(e){let t=e.target instanceof Element?e.target.closest(`a[href]`):null,n=this.turn;if(!t||!this.contains(t))return;let r=t.getAttribute(`href`)??``;r.startsWith(`#`)||(r.startsWith(`/`)&&typeof n?.onNavigate==`function`?(e.preventDefault(),n.onNavigate(r)):typeof n?.openTarget==`function`&&(e.preventDefault(),n.openTarget(r)))}#o(e){let t=this.turn?.features?.FigureText===!0?vn:void 0;e.figureText!==t&&(e.figureText=t)}#s(){return P(this.ownerDocument,`div`,`wui-chat-bubble`)}#c(e){let t=this.ownerDocument,n=P(t,`wui-markdown`,`wui-markdown wui-chat-text`);n.setAttribute(`links`,`web`),n.setAttribute(`headings`,`text`),n.isCitation=e=>y5(this.turn,e);let r=P(t,`pre`,`wui-markdown-source`,e);return n.append(r),{mode:`markdown`,node:n,source:r}}}),Yo(`wui-chat-part-ticket`,class extends Jo{renderPart(e,t,n){let{labels:r}=n,i=$(`article`,`wui-chat-ticket`,{"aria-label":r.ticketAria(e.number)}),a=$(`div`,`wui-chat-ticket-head`),o=$(`span`,`wui-chat-ticket-number`);o.textContent=r.ticketAria(e.number),a.append(o);let s=T3(e.status);if(s!==null){let t=$(`span`,`wui-chat-ticket-badge wui-chat-ticket-badge--${s}`);t.textContent=E3(e.status,r),a.append(t)}let c=$(`strong`,`wui-chat-ticket-title`);if(c.textContent=e.subject,i.append(a,c),typeof n.openTicket==`function`){let t=$(`div`,`wui-chat-ticket-foot`),a=$(`button`,`wui-chat-ticket-link`,{type:`button`});a.textContent=r.ticketView,a.addEventListener(`click`,()=>{let{openTicket:t}=n;if(t===void 0)throw Error(`${this.localName} lost openTicket after it drew the link`);t.call(n,{ticketId:e.ticketId,number:e.number})}),t.append(a),i.append(t)}this.replaceChildren(i)}});var C5=`http://www.w3.org/2000/svg`,w5={mic:`M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.92V21h2v-2.08A7 7 0 0 0 19 12z`,stop:`M6 6h12v12H6z`,play:`M8 5v14l11-7z`,pause:`M6 5h4v14H6zm8 0h4v14h-4z`,speaker:`M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z`};function T5(e,t=18){if(!Q4(w5,e))throw Error(`Unknown voice icon "${e}".`);let n=document.createElementNS(C5,`svg`);n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),n.setAttribute(`fill`,`currentColor`);let r=document.createElementNS(C5,`path`);return r.setAttribute(`d`,w5[e]),n.append(r),n}var E5=40,D5=null;function O5(e){let t=P(document,`span`,`wui-chat-clip-bar`);return t.style.setProperty(`--wui-chat-bar-height`,`${Math.round(e*100)}%`),t}function k5(e,t){e.replaceChildren(...wi(t,E5).map(O5))}Yo(`wui-chat-part-voice-clip`,class extends Jo{#e=null;#t=!1;#n=0;#r=0;#i=!1;#a=null;#o=null;#s=null;#c=0;#l=!1;renderPart(e,t,n){if(!n.features.VoiceClips){this.#u(e.transcript);return}let r=this.#e??this.#d(e.attachmentId);e.attachmentId!==r.attachmentId&&(this.disposePart(),r.attachmentId=e.attachmentId,this.#r=0,k5(r.wave,e.attachmentId)),this.#n=e.durationMs,this.#f(r,e)}disposePart(){this.#c+=1,this.#a?.pause(),this.#s!==null&&URL.revokeObjectURL(this.#s),D5===this&&(D5=null),this.#a=null,this.#o=null,this.#s=null,this.#i=!1}#u(e){if(this.disposePart(),this.#e=null,typeof e==`string`&&e!==``){let t=P(document,`p`,`wui-chat-clip-transcript`);t.textContent=e,this.replaceChildren(t)}else this.replaceChildren()}#d(e){let t=P(document,`div`,`wui-chat-clip`);t.setAttribute(`role`,`group`);let n=P(document,`div`,`wui-chat-clip-row`),r=P(document,`button`,`wui-chat-clip-play`);r.type=`button`;let i=P(document,`div`,`wui-chat-clip-wave`);i.setAttribute(`aria-hidden`,`true`);let a=P(document,`span`,`wui-chat-clip-time`);n.append(r,i,a);let o=P(document,`p`,`wui-chat-clip-error`);o.setAttribute(`role`,`status`),o.hidden=!0,t.append(n,o);let s={attachmentId:e,root:t,play:r,wave:i,time:a,error:o,transcript:null};return r.addEventListener(`click`,()=>this.#C(s)),k5(i,e),this.#e=s,this.replaceChildren(t),s}#f(e,t){let n=this.activeTurn.labels;e.root.setAttribute(`aria-label`,n.voiceClip),e.play.disabled=this.#l||typeof this.activeTurn.readAttachment!=`function`,this.#p(e),this.#m(e),this.#h(e,t.transcript)}#p(e){let t=this.activeTurn.labels,n=this.#i?t.voiceClipPause:t.voiceClipPlay;e.play.setAttribute(`aria-label`,n),e.play.title=n,e.play.replaceChildren(T5(this.#i?`pause`:`play`,18))}#m(e){let t=this.#n/1e3,n=t>0?Math.min(1,this.#r/t):0,r=Math.floor(n*E5);[...e.wave.children].forEach((e,t)=>{e.classList.toggle(`wui-chat-clip-bar--played`,t<r)});let i=Ti(Math.max(1,Math.round(t)));e.time.textContent=this.activeTurn.labels.voiceClipTime(Ti(this.#r),i)}#h(e,t){if(typeof t!=`string`||t===``){e.transcript?.toggle.remove(),e.transcript?.text.remove(),e.transcript=null;return}let n=e.transcript??this.#g(e);n.text.textContent=t,this.#_(n)}#g(e){let t=P(document,`button`,`wui-chat-clip-toggle`);t.type=`button`;let n=P(document,`p`,`wui-chat-clip-transcript`);n.hidden=!this.#t;let r={toggle:t,text:n};return t.addEventListener(`click`,()=>{this.#t=!this.#t,n.hidden=!this.#t,this.#_(r)}),e.transcript=r,e.root.append(t,n),r}#_(e){let t=this.activeTurn.labels;e.toggle.setAttribute(`aria-expanded`,String(this.#t)),e.toggle.textContent=this.#t?t.voiceClipHideTranscript:t.voiceClipShowTranscript}#v(e){return this.#o??=this.#y(e).catch(e=>{throw this.#o=null,e}),this.#o}async#y(e){let t=this.#c,{readAttachment:n}=this.activeTurn;if(n===void 0)throw Error(`${this.localName} loaded a clip on a turn without readAttachment`);let i=await n.call(this.activeTurn,e.attachmentId),a=URL.createObjectURL(new Blob([i],{type:r(i)}));if(t!==this.#c)return URL.revokeObjectURL(a),null;this.#s!==null&&URL.revokeObjectURL(this.#s),this.#s=a;let o=new Audio(this.#s);return o.addEventListener(`timeupdate`,()=>{this.#r=o.currentTime,this.#m(e)}),o.addEventListener(`ended`,()=>{this.#r=0,this.#b(),this.#m(e)}),o.addEventListener(`error`,()=>{this.#b(),this.#o=null,this.#S(e)}),this.#a=o,o}#b(){this.#a?.pause(),this.#x(!1)}#x(e){this.#i=e,e?(D5&&D5!==this&&D5.#b(),D5=this):D5===this&&(D5=null);let t=this.#e;t!==null&&this.#p(t)}#S(e){e.error.textContent=this.activeTurn.labels.voiceClipFailed,e.error.hidden=!1}async#C(e){if(this.#i)this.#b();else{e.error.hidden=!0,this.#l=!0,e.play.disabled=!0,e.play.setAttribute(`aria-busy`,`true`);try{let t=await this.#v(e);if(t===null)return;this.#x(!0),await t.play()}catch{this.#b(),this.#o=null,this.#S(e)}finally{this.#l=!1,e.play.removeAttribute(`aria-busy`),e.play.disabled=typeof this.activeTurn.readAttachment!=`function`}}}});var A5={Text:`wui-chat-part-text`,Sources:`wui-chat-part-sources`,QuickReplies:`wui-chat-part-quick-replies`,InputRequest:`wui-chat-part-input-request`,Action:`wui-chat-part-action`,Notice:`wui-chat-part-notice`,Table:`wui-chat-part-table`,Chart:`wui-chat-part-chart`,Figures:`wui-chat-part-figures`,RecordCard:`wui-chat-part-record-card`,Image:`wui-chat-part-image`,File:`wui-chat-part-file`,Ticket:`wui-chat-part-ticket`,Handoff:`wui-chat-part-handoff`,VoiceClip:`wui-chat-part-voice-clip`},j5=n({SpeechConfig:()=>void 0}),M5=t((()=>{})),N5=1e4,P5=2e3,F5=3e5,I5=new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),L5=new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function R5(e){return I5.has(B5(e,`name`))?new Jt(`Blocked`,{message:V5(e)}):L5.has(B5(e,`name`))?new Jt(`NoMicrophone`,{message:V5(e)}):z5(e)}function z5(e){return e instanceof Jt?e:new Jt(`Failed`,{message:V5(e)??String(e)})}function B5(e,t){return typeof e==`object`&&e||typeof e==`function`?Reflect.get(e,t):void 0}function V5(e){let t=B5(e,`message`);return t==null?void 0:String(t)}function H5(e){return typeof e==`object`&&!!e}function U5(e){let t=B5(e,`SpeechConfig`),n=B5(e,`AudioConfig`),r=B5(e,`NoMatchDetails`);return typeof B5(t,`fromAuthorizationToken`)==`function`&&typeof B5(n,`fromDefaultMicrophoneInput`)==`function`&&typeof B5(n,`fromSpeakerOutput`)==`function`&&typeof B5(r,`fromResult`)==`function`&&typeof B5(e,`SpeechRecognizer`)==`function`&&typeof B5(e,`SpeakerAudioDestination`)==`function`&&typeof B5(e,`SpeechSynthesizer`)==`function`&&H5(B5(e,`PropertyId`))&&H5(B5(e,`ResultReason`))&&H5(B5(e,`NoMatchReason`))&&H5(B5(e,`CancellationReason`))}function W5(e){if(!U5(e))throw new Jt(`Unavailable`,{message:`Speech is not available in this browser.`});return e}var G5=null;function K5(){let e=globalThis,t=`SpeechSDK`in e?e.SpeechSDK:void 0;return t?Promise.resolve(W5(t)):(G5===null&&(G5=Promise.resolve().then(()=>(M5(),j5)).then(e=>W5(B5(e,`SpeechConfig`)?e:B5(e,`default`))).catch(e=>{throw G5=null,e})),G5)}function q5(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function J5(e){let t=e.getToken,n=e.loadSdk??K5,r=e.getLanguage??q5,i=typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`,a=typeof window<`u`&&window.isSecureContext===!0,o=i&&a,s=typeof window<`u`,c=null,l=null,u=null;function d(){return c!==null&&Date.parse(c.expiresDateTimeUtc)-Date.now()>6e4?Promise.resolve(c):(l===null&&(l=Promise.resolve().then(()=>t()).then(e=>(c=e,l=null,e),e=>{throw l=null,z5(e)})),l)}function f(){return u===null&&(u=Promise.resolve().then(()=>n()).then(e=>{if(!e?.SpeechConfig)throw new Jt(`Unavailable`,{message:`Speech is not available in this browser.`});return e}).catch(e=>{throw u=null,z5(e)})),u}function p(e={}){let{signal:t,onText:n,onEnd:i}=e;if(t?.aborted)return i?.(),Promise.resolve();let a=()=>{},s=()=>{},c=new Promise((e,t)=>{a=e,s=t}),l=!1,u=!1,p=null,m=!1,h=``,g=[],_,v,y,b=()=>{clearTimeout(_),clearTimeout(v),clearTimeout(y)},x=e=>{if(!l){l=!0,b(),t?.removeEventListener(`abort`,S);try{p?.close()}finally{try{i?.()}finally{e?s(e):a()}}}};async function S(){if(!(l||u)){u=!0,b();try{let e=p;e!==null&&await new Promise(t=>e.stopContinuousRecognitionAsync(()=>t(),()=>t()))}finally{x(null)}}}let C=()=>[...g,h].filter(e=>e!==``).join(` `).trim(),w=(e,t)=>{m||(m=!0,clearTimeout(_)),clearTimeout(v),v=setTimeout(S,P5),n?.(C(),t)};async function T(){if(t?.addEventListener(`abort`,S),!o){x(new Jt(`Unavailable`,{message:`Dictation is not available in this browser.`}));return}let n;try{n=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){x(R5(e));return}for(let e of n.getTracks())e.stop();if(!l)try{let t=await f(),n=await d();if(l)return;let i=t.SpeechConfig.fromAuthorizationToken(n.token,n.region);i.speechRecognitionLanguage=e.language||r(),i.setProperty(t.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(N5));let a=new t.SpeechRecognizer(i,t.AudioConfig.fromDefaultMicrophoneInput());if(p=a,a.recognizing=(e,t)=>{if(l)return;let n=t.result?.text;n&&(h=n,w(n,!1))},a.recognized=(e,n)=>{if(l)return;let{reason:r,text:i}=n.result;r===t.ResultReason.RecognizedSpeech&&i?(g.push(i),h=``,w(i,!0)):r===t.ResultReason.NoMatch&&t.NoMatchDetails.fromResult(n.result).reason===t.NoMatchReason.InitialSilenceTimeout&&x(new Jt(`NoSpeech`,{message:`No speech was heard.`}))},a.canceled=(e,n)=>{l||(n.reason===t.CancellationReason.Error?x(new Jt(`Failed`,{message:n.errorDetails})):x(null))},a.sessionStopped=()=>x(null),await new Promise((e,t)=>a.startContinuousRecognitionAsync(()=>e(),t)),l)return;e.onStarted?.(),_=setTimeout(()=>{m||x(new Jt(`NoSpeech`,{message:`No speech was heard.`}))},N5),y=setTimeout(S,F5)}catch(e){x(z5(e))}}return T(),c}async function m(e,t={}){let{signal:n}=t;if(!n?.aborted)try{let i=await f(),a=await d();if(n?.aborted)return;let o=i.SpeechConfig.fromAuthorizationToken(a.token,a.region);o.speechSynthesisLanguage=t.language||r();let s=new i.SpeakerAudioDestination,c=new i.SpeechSynthesizer(o,i.AudioConfig.fromSpeakerOutput(s));await new Promise((t,r)=>{let a=!1,o=()=>{n?.removeEventListener(`abort`,d),c.close(),s.close()},l=()=>{a||(a=!0,o(),t())},u=e=>{a||(a=!0,o(),r(z5(e)))};function d(){s.pause(),l()}n?.addEventListener(`abort`,d),s.onAudioEnd=l;try{c.speakTextAsync(e,e=>{e.reason!==i.ResultReason.SynthesizingAudioCompleted&&u(new Jt(`Failed`,{message:`The reply could not be synthesised.`}))},e=>u(e))}catch(e){u(e)}})}catch(e){throw z5(e)}}return{dictation:o,readAloud:s,streamsText:!0,startDictation:p,speak:m}}var Y5=8e3,X5=6e3,Z5=new Set([`Blocked`,`NoMicrophone`]);function Q5(e){let t=e instanceof Jt?e.code:`Failed`;return{code:t,source:`Dictation`,sticky:Z5.has(t)}}function $5(e){let t=fr(e.filter(e=>e.kind===`Text`)).replace(/ ?\[\d+\]/g,``).replace(/\s+/g,` `).trim();if(t.length<=6e3)return t;let n=t.slice(0,X5),r=n.lastIndexOf(`. `);return r===-1?n.trim():n.slice(0,r+1)}function e7(e,t){switch(e.code){case`Blocked`:return t.dictationBlocked;case`NoMicrophone`:return t.dictationNoMicrophone;case`NoSpeech`:return t.dictationNotHeard;case`Unavailable`:return t.dictationUnavailable;case`Failed`:return t.dictationFailed;case`SpeakFailed`:return t.readAloudFailed;default:throw Error(`Unknown voice note code "${e.code}".`)}}function t7(e){let t=e.getState,n=e.speech??J5({getToken:e.getToken}),r=`Idle`,i=null,a=null,o=null,s=null,c=0,l=null,u=new Set,d=()=>({mode:r,messageId:i,startedAtMs:a,note:o});function f(){let e=d();for(let t of[...u])t(e)}function p(e){r=e.mode,i=e.messageId??null,a=e.startedAtMs??null,f()}function m(){l!==null&&clearTimeout(l),l=null}function h(e){m(),o=e,e&&!e.sticky&&(l=setTimeout(()=>{l=null,o=null,f()},Y5)),f()}function g(){o!==null&&(m(),o=null,f())}function _(){c+=1;let e={id:c,controller:new AbortController,stopped:!1};return s=e,e}function v(e){s===e&&(s=null,p({mode:`Idle`}))}function y(){let e=s;s=null,e&&(e.stopped=!0,e.controller.abort()),r!==`Idle`&&p({mode:`Idle`})}function b(){let e=t();return!!(e.features.Dictation&&e.profile?.speechAvailable&&n.dictation)}function x(){let e=t();return!!(e.features.ReadAloud&&e.profile?.speechAvailable&&n.readAloud)}async function S(e){if(r===`Dictating`){y();return}if(y(),h(null),!b())return;let t=e.getText(),i=t!==``&&!/\s$/.test(t)?`${t} `:t,a=_();p({mode:`Dictating`});try{await n.startDictation({signal:a.controller.signal,onText:t=>{s===a&&e.setText(i+t)},onEnd:()=>v(a)})}catch(e){if(a.stopped)return;v(a),h(Q5(e))}}async function C(e,t){if(r===`Speaking`&&i===e){y();return}y(),h(null);let a=$5(t);if(a===``)return;let o=_();p({mode:`Speaking`,messageId:e});try{await n.speak(a,{signal:o.controller.signal}),v(o)}catch{if(o.stopped)return;v(o),h({code:`SpeakFailed`,source:`ReadAloud`,sticky:!1,messageId:e})}}function w(e){return u.add(e),()=>{u.delete(e)}}function T(){y(),m(),o=null,u.clear()}return{canDictate:b,canSpeak:x,getStatus:d,subscribe:w,toggleDictation:S,toggleSpeak:C,stop:y,dismissNote:g,destroy:T}}var n7=new Set([`Shift`,`Control`,`Alt`,`Meta`,`Escape`]);function r7(e,t){e.isTrusted&&!n7.has(e.key)&&t.getStatus().mode===`Dictating`&&t.stop()}function i7({voice:e,getLabels:t,textarea:n,onTextChanged:r}){let i=null,a=$(`button`,`wui-chat-tool wui-chat-mic`,{type:`button`});a.append(T5(`mic`,20)),a.hidden=!0,a.addEventListener(`click`,()=>{e.toggleDictation({getText:()=>n.value,setText:e=>{n.value=n.maxLength>0?e.slice(0,n.maxLength):e,r(),n.setSelectionRange(n.value.length,n.value.length)}})});let o=$(`p`,`wui-chat-voice-note`,{role:`status`});o.hidden=!0;let s=$(`span`,`visually-hidden`,{"aria-live":`polite`});function c(e){let n=t(),r=e.note?.source===`ReadAloud`?null:e.note,i=e.mode===`Dictating`,c=i?n.dictateStop:n.dictate;a.setAttribute(`aria-pressed`,String(i)),a.setAttribute(`aria-label`,c),a.title=c;let l=r?.code===`Blocked`||r?.code===`NoMicrophone`;r===null?(o.hidden=!0,o.textContent=``):(o.hidden=!1,o.textContent=e7(r,n),o.setAttribute(`role`,r.sticky?`alert`:`status`)),o.classList.toggle(`wui-chat-voice-note--blocked`,l),s.textContent=i?n.dictateListening:``}function l(t){let{state:n}=t;a.hidden=!e.canDictate();let r=e.getStatus().mode===`Speaking`,i=n.messagesLeftToday===0;a.disabled=i||r||n.handoffPause===!0}function u(e){c(e),i!==null&&l(i)}let d=e.subscribe(u);function f(t){i=t,l(t),c(e.getStatus())}function p(){d()}return{buttons:[a],note:o,announcer:s,paint:f,destroy:p}}var a7=10,o7=.9,s7=0;function c7(e){for(let t of e.toReversed())for(let e of t.parts.toReversed())if(e.kind===`InputRequest`&&e.state===`Open`)return e.fields[0]?.label??e.title??null;return null}function l7(e){s7+=1;let t=`wui-chat-composer-hint-${s7}`,n=$(`p`,`wui-chat-allowance`,{role:`status`});n.hidden=!0;let r=$(`span`),i=$(`button`,`btn btn-ghost-primary btn-sm wui-chat-action-btn`,{type:`button`});i.addEventListener(`click`,()=>e.onCancelEdit());let a=$(`div`,`wui-chat-editing`);a.hidden=!0,a.append(r,i);let o=$(`div`,`wui-chat-attachments`);o.hidden=!0;let s=$(`button`,`wui-chat-tool`,{type:`button`});s.append($4(`paperclip`,20)),s.hidden=!0;let c=$(`input`,null,{type:`file`,multiple:``,tabindex:`-1`});c.hidden=!0,c.addEventListener(`change`,()=>{let t=[...c.files??[]];c.value=``,t.length>0&&e.onAttach(t)}),s.addEventListener(`click`,()=>c.click());let l=$(`textarea`,`wui-chat-input`,{rows:`1`,"aria-describedby":t}),u=$(`span`,`visually-hidden`,{id:t}),d=$(`span`,`wui-chat-counter`);d.hidden=!0;let f=$(`button`,`wui-chat-send`,{type:`submit`});f.append($4(`arrow-up`,18));let p=$(`button`,`wui-chat-send wui-chat-send--stop`,{type:`button`});p.append($4(`stop`,16)),p.hidden=!0,p.addEventListener(`click`,()=>e.onStop());let m=$(`form`,`wui-chat-composer`);m.append(s,c,l,d,u,p,f);let h=e.mark?.(`input`,`rest`)??null,g=null,_=null,v=null,y=0,b=null;function x(){l.style.height=`auto`,l.style.height=`${l.scrollHeight}px`;let e=getComputedStyle(l),t=l.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom);m.classList.toggle(`wui-chat-composer--multiline`,t>(parseFloat(e.lineHeight)||22)*1.5)}function S(){return b?.attachments.some(e=>e.status===`Uploading`)??!1}function C(){return b?.attachments.some(e=>e.status===`Ready`)??!1}function w(){let e=l.value.length,t=y>0&&e>y*o7;d.hidden=!t,t&&v&&(d.textContent=v.counter(e,y))}function T(){let e=b?.messagesLeftToday??null,t=l.value.trim()===``&&!C();f.disabled=!!b?.streaming||e===0||S()||t||b?.handoffPause===!0,m.classList.toggle(`wui-chat-composer--has-text`,!t)}function E(){if(f.disabled)return;let t=l.value.trim();l.value=``,x(),w(),T(),e.voice?.stop(),e.voice?.dismissNote(),e.onSubmit(t)}l.addEventListener(`input`,()=>{x(),w(),T(),l.value!==``&&e.onTyping?.()}),l.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),E())}),m.addEventListener(`submit`,e=>{e.preventDefault(),E()});let D=e.voice,O=D?i7({voice:D,getLabels:()=>{if(v===null)throw Error(`composer labels are read before the first render`);return v},textarea:l,onTextChanged:()=>{x(),w(),T()}}):null;if(D&&O){let e=O.buttons[0];e&&m.insertBefore(e,f),l.addEventListener(`keydown`,e=>r7(e,D))}function k(t,n){let r=t.map(t=>{let r=$(`span`,`wui-chat-chip`),i=$(`span`,null,t.status===`Failed`?{title:t.error??``}:null);i.textContent=t.fileName;let a=$(`button`,`wui-chat-chip-remove`,{type:`button`,"aria-label":n.removeAttachment(t.fileName)});a.append($4(`x`,14)),a.addEventListener(`click`,()=>e.onRemove(t.key));let o=[];if(t.status===`Uploading`){let e=$(`progress`,`wui-chat-chip-progress`,{max:`1`});typeof t.progress==`number`&&(e.value=t.progress);let r=$(`span`,`wui-chat-chip-status`);r.textContent=n.attachmentUploading,o.push(e,r)}if(t.status===`Failed`){let e=$(`span`,`wui-chat-chip-error`,{"aria-live":`polite`});e.textContent=t.error||n.attachmentFailed,o.push(e)}return r.append(i,...o,a),r});o.replaceChildren(...r),o.hidden=r.length===0}function A(t){b=t.state,v=t.labels,y=t.maxLength,t.sendIcon&&f.dataset.icon!==t.sendIcon&&(f.dataset.icon=t.sendIcon,f.replaceChildren($4(t.sendIcon,18)));let o=b.messagesLeftToday;m.setAttribute(`aria-label`,v.composer),u.textContent=v.composerHint,l.setAttribute(`aria-label`,v.composer),l.maxLength=y,l.placeholder=b.handoffPause?v.handoffMoment:c7(b.messages)??v.placeholder,l.disabled=o===0||b.handoffPause===!0,n.hidden=!(o!==null&&o<=a7),!n.hidden&&o!==null&&(n.textContent=v.allowance(o));let d=b.editing?.messageId??null;if(d!==g){let t=g!==null;g=d,b.editing?(e.voice?.stop(),l.value=b.editing.text,x()):t&&(l.value=``,x())}a.hidden=!b.editing,r.textContent=v.editing,i.textContent=v.cancel;let S=t.draft??null;typeof S==`string`&&S!==``&&S!==_&&(_=S,l.value=S,l.dispatchEvent(new Event(`input`)),l.focus(),e.onDraftApplied?.()),k(b.attachments,v);let C=b.features.Attachments&&(b.profile?.limits.maxAttachments??0)>0&&b.handoffPause!==!0;s.hidden=!C,s.setAttribute(`aria-label`,v.attach),s.title=v.attachHint,c.accept=t.accept??``;let E=b.streaming&&b.features.Stop===!0;p.hidden=!E,p.setAttribute(`aria-label`,v.stop),f.hidden=E,f.setAttribute(`aria-label`,v.send),w(),T(),h!==null&&(h.dataset.state=t.busy===!0?`busy`:`rest`,t.inputMark===`Avatar`?h.parentNode!==m&&m.insertBefore(h,l):h.remove()),O?.paint({state:b})}function j(){l.focus()}function M(){O?.destroy();for(let e of ee)e.remove()}let ee=[n,a,o,...O?[O.note,O.announcer]:[],m];return{nodes:ee,paint:A,focus:j,destroy:M,getDraft:()=>l.value}}var u7=`https://policies.google.com/privacy`,d7=`https://policies.google.com/terms`;function f7(e,t){let n=$(`a`,`wui-chat-footer-link`,{href:t,target:`_blank`,rel:`noopener noreferrer`});return n.textContent=e,n}function p7(){let e=$(`p`,`wui-chat-footer`);e.hidden=!0;function t(t){let{labels:n,profile:r,hideDisclaimer:i}=t,a=[];if(r){if(!i){let e=$(`span`,`wui-chat-footer-text`);e.textContent=r.footer.disclaimer||n.disclaimer,a.push(e)}let{privacyText:e}=r.footer,t=Nr(r.footer.privacyUrl)?r.footer.privacyUrl:null;if(t){let r=$(`span`,`wui-chat-footer-privacy`),i=$(`a`,`wui-chat-footer-link`,{href:t});i.textContent=e||n.footerPrivacyFallback,r.append(i),a.push(r)}else if(e){let t=$(`span`,`wui-chat-footer-privacy`);t.textContent=e,a.push(t)}if(r.footer.assuranceText){let e=$(`span`);e.textContent=r.footer.assuranceText,a.push(e)}if(Le(r)){let e=$(`span`,`wui-chat-footer-captcha`),t=$(`span`,`wui-chat-footer-captcha-tail`);t.append(f7(n.captchaPrivacyPolicy,u7),document.createTextNode(n.captchaNoticeAnd),f7(n.captchaTerms,d7),document.createTextNode(n.captchaNoticeAfter)),e.append(document.createTextNode(n.captchaNoticeBefore),t),a.push(e)}}e.replaceChildren(...a),e.hidden=a.length===0}return{el:e,paint:t}}function m7(e,t,n){e.setAttribute(`aria-label`,t),e.title=t,e.dataset.icon!==n&&(e.dataset.icon=n,e.replaceChildren($4(n,20)))}function h7(e){let t=e.mark?.(`header`,`rest`)??$(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),n=$(`strong`,`wui-chat-title`);e.titleId&&(n.id=e.titleId);let r=$(`span`,`wui-chat-tagline`),i=$(`span`,`wui-chat-status`),a=$(`div`,`wui-chat-header-text`);a.append(n,r,i);let o=$(`span`,`wui-chat-header-conversation`);o.hidden=!0;let s=n3(``,`history`,()=>e.onHistory()),c=n3(``,`volume-high`,()=>e.onMute()),l=n3(``,`plus`,()=>e.onNew()),u=n3(``,`maximize-4`,()=>e.onSwitch());u.classList.add(`wui-chat-switch-btn`,`wui-chat-switch-btn--full`);let d=n3(``,`panel-left-open`,()=>e.onSwitch());d.classList.add(`wui-chat-switch-btn`,`wui-chat-switch-btn--side`);let f=n3(``,`x`,()=>e.onClose());f.classList.add(`wui-chat-close-btn`);let p=$(`div`,`wui-chat-header-actions`);p.append(o,s,c,l,u,d,f);let m=$(`header`,`wui-chat-header`);m.append(t,a,p);function h(e){let{labels:t}=e;m.hidden=!1,n.textContent=e.title??``,r.textContent=e.tagline??``,r.hidden=!e.tagline,i.textContent=e.status??``,s.hidden=!e.showHistory,e.viewingHistory?m7(s,t.backToChat,`arrow-left`):m7(s,t.history,`history`),c.hidden=!e.showMute,m7(c,e.muted?t.unmuteSounds:t.muteSounds,e.muted?`volume-mute`:`volume-high`),l.hidden=!!e.viewingHistory||e.showNew===!1,l.disabled=!e.canNew,m7(l,t.newChat,`plus`),u.hidden=e.switchTo!==`full-page`,u.disabled=!e.canSwitch,m7(u,t.openFullScreen,`maximize-4`),d.hidden=e.switchTo!==`docked`,d.disabled=!e.canSwitch,m7(d,t.openSidePanel,`panel-left-open`),f.hidden=!e.showClose,m7(f,t.close,`x`)}return{el:m,conversation:o,paint:h}}var g7=120;function _7(e,t,n=`outline`){let r=$(`button`,`${e3(n,`sm`)} wui-chat-action-btn`,{type:`button`});return r.textContent=e,r.addEventListener(`click`,t),r}function v7(e){let t=$(`div`,`wui-chat-history`);t.hidden=!0;let n=null,r=null,i=null,a=null,o=null,s=!1;function c(){return n||(n=qt({client:e.getClient()}),r=n.subscribe(()=>_()),n)}function l(e){i={id:e.publicId,kind:`rename`,draft:e.title??``,saving:!1},a=null,o=null,s=!0,_()}function u(e){i={id:e.publicId,kind:`delete`,saving:!1},a=null,o=null,_()}function d(){i=null,a=null,o=null,_()}async function f(){let t=i;if(t?.kind!==`rename`||t.saving)return;let n=t.draft.trim();if(n){t.saving=!0,_();try{await c().rename(t.id,n),i===t&&(i=null),a=null,o=null}catch{if(i!==t)return;t.saving=!1,o=e.getLabels().renameFailed}_()}}async function p(){let t=i;if(!(t?.kind!==`delete`||t.saving)){t.saving=!0,_();try{await c().remove(t.id),i===t&&(i=null),a=null,e.onDeleted(t.id)}catch{if(i!==t)return;t.saving=!1,a=e.getLabels().deleteFailed}_()}}function m(e,t){let n=$(`li`,`wui-chat-history-row wui-chat-history-row--editing`),r=$(`input`,`wui-chat-history-input`,{type:`text`,"aria-label":e.conversationTitle,maxlength:String(g7)});r.value=t.draft,r.addEventListener(`input`,()=>{t.draft=r.value,i.disabled=t.saving||!t.draft.trim()}),r.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.isComposing&&e.keyCode!==229?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),d())});let i=_7(e.renameSave,()=>f(),`primary`);if(i.disabled=t.saving||!t.draft.trim(),n.append(r,i,_7(e.cancel,()=>d(),`ghost`)),o!==null){let e=$(`p`,`wui-chat-history-error`,{role:`alert`});e.textContent=o,n.append(e)}return s&&(s=!1,queueMicrotask(()=>r.focus())),n}function h(e,t){let n=$(`li`,`wui-chat-history-row wui-chat-history-row--confirm`),r=$(`p`);r.textContent=e.deleteConfirmTitle;let i=$(`p`);i.textContent=e.deleteConfirmMessage;let a=_7(e.deleteConfirm,()=>p(),`danger`);return a.disabled=t.saving,n.append(r,i,a,_7(e.cancel,()=>d(),`ghost`)),n}function g(t,n,r){if(i?.id===t.publicId&&i.kind===`rename`)return m(n,i);if(i?.id===t.publicId&&i.kind===`delete`)return h(n,i);let a=$(`li`,`wui-chat-history-row`),o=$(`button`,`wui-chat-history-open`,{type:`button`}),s=$(`span`,`wui-chat-history-title`);s.textContent=t.title||n.untitled;let c=$(`span`,`wui-chat-history-time`);return c.textContent=lr(t.lastActivityDateTimeUtc),o.append(s,c),o.addEventListener(`click`,()=>e.onOpen(t.publicId)),a.append(o),r.Rename&&a.append(n3(n.rename,`pencil`,()=>l(t))),r.Delete&&a.append(n3(n.deleteChat,`trash`,()=>u(t))),a}function _(){let r=e.getLabels(),i=e.getFeatures(),o=n?n.getState():{items:[],totalCount:null,loading:!1,error:null,hasMore:!1},s=[];if(o.error||a){let e=$(`p`,`wui-chat-history-error`,{role:`alert`});o.error?(e.append(document.createTextNode(r.loadFailed),document.createTextNode(` `)),e.append(_7(r.retry,()=>c().load(),`outline`))):e.textContent=a,s.push(e)}if(o.loading&&o.items.length===0){let e=$(`p`,`wui-chat-history-empty`,{role:`status`});e.textContent=r.loadingConversation,s.push(e)}if(o.items.length===0&&!o.loading&&!o.error){let e=$(`p`,`wui-chat-history-empty`),t=$(`span`);t.textContent=r.historyEmptyTitle;let n=$(`span`);n.textContent=r.historyEmptyText,e.append(t,n),s.push(e)}if(o.items.length>0){let e=$(`ul`,`wui-chat-history-list`,{"aria-label":r.history});e.append(...o.items.map(e=>g(e,r,i))),s.push(e)}o.hasMore&&!o.loading&&s.push(_7(r.loadMore,()=>c().loadMore(),`outline`)),t.replaceChildren(...s)}function v(){t.hidden=!1,Promise.allSettled([c().load()]),_()}function y(){t.hidden=!0}function b(){r?.(),r=null,n?.dispose(),n=null}return{el:t,show:v,hide:y,paint:_,dispose:b}}var y7=new Set([`GET`,`HEAD`]);function b7(){let e=document.querySelector(`meta[name="wui-csrf"]`),t=e?.getAttribute(`content`);return t?{token:t,header:e?.getAttribute(`data-header`)||`RequestVerificationToken`}:null}async function x7(e,{lenient:t=!1}={}){let n=await e.text();if(n){if((e.headers.get(`content-type`)||``).includes(`json`)){if(!t)return JSON.parse(n);try{return JSON.parse(n)}catch{return n}}return n}}async function S7(e,t,n){let r=new TextDecoder,i=e.getReader(),a=``;for(;;){let{done:e,value:o}=await i.read();if(e)break;a+=r.decode(o,{stream:!0}),n({event:{target:{responseText:a,status:t}}})}return a+=r.decode(),a}function C7({fetch:e=(...e)=>globalThis.fetch(...e)}={}){async function t(t,n,r,i={}){let a={...i.headers},o;if(typeof FormData<`u`&&r instanceof FormData){for(let e of Object.keys(a))e.toLowerCase()===`content-type`&&delete a[e];o=r}else r!==void 0&&(a[`Content-Type`]=`application/json`,o=JSON.stringify(r));if(!y7.has(t)){let e=b7();e&&(a[e.header]=e.token)}let s=i.signal,c=s,l,u,d=()=>l?.abort(s?.reason);(i.timeout??0)>0&&(l=new AbortController,c=l.signal,s?.aborted?l.abort(s.reason):s?.addEventListener(`abort`,d,{once:!0}),u=setTimeout(()=>l?.abort(new DOMException(`The request timed out.`,`TimeoutError`)),i.timeout));try{let r={method:t,headers:a,credentials:`same-origin`};o!==void 0&&(r.body=o),c&&(r.signal=c);let s=await e(n,r);if(!s.ok){let e=Error(`Request failed with status ${s.status}`);throw e.response={status:s.status,data:await x7(s,{lenient:!0})},e}let l;return l=i.responseType===`arraybuffer`?await s.arrayBuffer():typeof i.onDownloadProgress==`function`&&s.body?await S7(s.body,s.status,i.onDownloadProgress):await x7(s),{data:l,status:s.status}}finally{clearTimeout(u),s?.removeEventListener(`abort`,d)}}return{get:(e,n)=>t(`GET`,e,void 0,n),post:(e,n,r)=>t(`POST`,e,n,r),put:(e,n,r)=>t(`PUT`,e,n,r),delete:(e,n)=>t(`DELETE`,e,void 0,n)}}function w7(e){let t,n=!1,r=!1,i=$(`div`,`wui-chat-nudge`,{role:`status`});i.hidden=!0;let a=$(`button`,`wui-chat-nudge-text`,{type:`button`}),o=$(`button`,`wui-chat-nudge-close`,{type:`button`});o.append($4(`x`,14)),i.append(a,o);function s(){clearTimeout(t),t=void 0}function c(){s(),r=!0,i.hidden=!0}a.addEventListener(`click`,()=>{i.hidden=!0,e.onActivate()}),o.addEventListener(`click`,()=>{c(),e.onDismiss()});function l(e){s(),r||n||(t=setTimeout(()=>{t=void 0,a.textContent=e.text,o.setAttribute(`aria-label`,e.label),i.hidden=!1,n=!0},e.delaySeconds*1e3))}function u(){s(),i.remove()}return{el:i,schedule:l,cancel:s,dismiss:c,isShown:()=>n,destroy:u}}function T7(e,t){e.addEventListener(`click`,()=>t()),e.addEventListener(`keydown`,e=>{(Do(e)||e.key===` `)&&(e.preventDefault(),t())})}function E7(e){let{list:t,getLabels:n,getFeatures:r,onOpen:i}=e,a=$(`div`,`wui-chat-empty-rows wui-chat-empty-rows--past`);a.hidden=!0;let o=!1;function s(e,t){let n=$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}),r=$(`div`,`card-body wui-chat-empty-row-body`),a=$(`span`,`wui-chat-empty-row-title`);a.textContent=e.title||t.earlierChat;let o=$(`span`,`wui-chat-empty-row-time`,{title:gr(e.lastActivityDateTimeUtc)});return o.textContent=lr(e.lastActivityDateTimeUtc),r.append(a,o),n.append(r),T7(n,()=>i(e.publicId)),n}function c(){if(o)return;let e=t.getState().items;if(r().History!==!0||e.length===0){a.replaceChildren(),a.hidden=!0;return}let i=n();a.replaceChildren(...e.slice(0,20).map(e=>s(e,i))),a.hidden=!1}let l=t.subscribe(c);return{el:a,refresh(){r().History===!0&&t.load().catch(e=>globalThis.reportError?.(e))},paint:c,dispose(){o=!0,l()}}}var D7=`https://www.google.com/recaptcha/api.js?render=`;function O7(e){return e!==void 0&&typeof e.ready==`function`&&typeof e.execute==`function`}var k7=new Map;function A7(e){let t=k7.get(e);if(t!==void 0)return t;let n=new Promise((t,n)=>{let r=globalThis.grecaptcha;if(O7(r)){t(r);return}let i=document.createElement(`script`);i.src=D7+encodeURIComponent(e),i.async=!0;let a=t=>{k7.delete(e),n(Object.assign(Error(t),{code:`captcha_unavailable`}))};i.addEventListener(`load`,()=>{let e=globalThis.grecaptcha;e===void 0||typeof e.ready!=`function`?a(`The reCAPTCHA script loaded without grecaptcha.`):e.ready(()=>{let e=globalThis.grecaptcha;O7(e)?t(e):a(`reCAPTCHA became ready without execute.`)})}),i.addEventListener(`error`,()=>{k7.delete(e),n(Error(`The reCAPTCHA script did not load.`))}),document.head.append(i)});return k7.set(e,n),n}async function j7(e,t){let n=await A7(e);await new Promise(e=>n.ready(()=>e()));let r=await n.execute(e,{action:t});if(!r)throw Object.assign(Error(`reCAPTCHA returned no token.`),{code:`captcha_unavailable`});return r}var M7=`data-wchat-printing`,N7=`data-wchat-print-hide`,P7=`data-wchat-print-path`,F7=`data-wchat-print-target`,Ste=new Set([`script`,`style`,`link`,`template`]),I7=null;function L7(){if(I7!==null){for(let e of I7.marked)e.removeAttribute(N7),e.removeAttribute(P7),e.removeAttribute(F7);I7.heading.remove(),document.documentElement.removeAttribute(M7),window.removeEventListener(`afterprint`,I7.onAfterPrint),I7=null}}function R7(e,t,n,r,i){L7();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[],s=a;for(;s!==null&&s!==document.documentElement;){s.setAttribute(P7,``),o.push(s);let e=s.parentElement;if(e===null)throw Error(`print walk left the chat root`);for(let t of e.children)t===s||Ste.has(t.localName)||(t.setAttribute(N7,``),o.push(t));s=e}for(let e of n)e.setAttribute(N7,``),o.push(e);r!==null&&(r.setAttribute(F7,``),o.push(r));let c=document.createElement(`div`);c.className=`wui-chat-print-heading`;let l=document.createElement(`h1`);l.textContent=i.title;let u=document.createElement(`p`);u.textContent=i.printedOn,c.append(l,u),a.prepend(c),document.documentElement.setAttribute(M7,t);let d=()=>L7();window.addEventListener(`afterprint`,d,{once:!0}),I7={marked:o,heading:c,onAfterPrint:d};try{window.print()}catch(e){throw L7(),e}}function Cte(e,t){R7(e,`conversation`,[],null,t)}function wte(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);R7(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function z7(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function B7({title:e,text:t}){if(!z7())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?`cancelled`:`failed`}}var Tte=new Set([`Assistant`,`Agent`,`Script`]),V7=new WeakMap;function Ete(e,t,n){let{labels:r,features:i,title:a,busy:o,assistantName:s}=n;if(fr(t.parts)!==``){if(i.Share&&z7()){let n=t3(`ghost`,r.share,`share`,()=>void(async()=>{let e=U7([t],i,r,a,!1,s);e!==``&&await B7({title:a,text:e})===`failed`&&q7(n.parentElement,r.shareFailed)})());n.disabled=o===!0,e.append(n)}if(i.Print){let t=t3(`ghost`,r.print,`printer`,()=>{try{let e=t.closest(`.wui-chat`),n=t.closest(`li.wui-chat-message`);if(!(e instanceof HTMLElement)||!(n instanceof HTMLElement))throw Error(`printReply needs a message inside the wui-chat root`);wte(e,n,{title:a,printedOn:G7(r)})}catch{K7(t,r.printFailed)}});e.append(t)}}}function Dte(e,t,n){if(t.streaming||t.thinking||t.loading||t.conversationId===null||t.messages.filter(e=>e.stored&&Tte.has(e.author.kind)&&fr(e.parts)!==``).length===0){e.hidden=!0;return}let{labels:r,features:i}=n,a=!!i.Share&&z7(),o=!!i.Print;if(!a&&!o){e.hidden=!0;return}let s=[a,o,t.messages.length,r.shareConversation,r.printConversation].join(`|`);e.dataset.sig!==s&&(e.dataset.sig=s,e.replaceChildren(),a&&e.append(Ote(e,r,i,n)),o&&e.append(kte(e,r,n))),e.hidden=!1}function H7(e,t,n,r){return e.iconOnly?n3(t,n,r):t3(`ghost`,t,n,r)}function Ote(e,t,n,r){return H7(r,t.shareConversation,`share`,()=>void(async()=>{let i=r.getState(),a=W7(i,r);await B7({title:a,text:U7(i.messages.filter(e=>e.stored),n,t,a,!0,i.profile?.assistant.name)})===`failed`&&q7(e,t.shareFailed)})())}function kte(e,t,n){let r=H7(n,t.printConversation,`printer`,()=>{try{let r=e.closest(`.wui-chat`);if(!(r instanceof HTMLElement))throw Error(`printConversation needs the wui-chat root`);Cte(r,{title:W7(n.getState(),n),printedOn:G7(t)})}catch{n.iconOnly?q7(e,t.printFailed):K7(r,t.printFailed)}});return r}function U7(e,t,n,r,i,a){return xi(yi(e,{labels:n,title:r,figureText:t.FigureText,...a===void 0?{}:{assistantName:a}}),{heading:i,speakers:i})}function W7(e,t){return typeof e.title==`string`&&e.title!==``?e.title:t.title}function G7(e){return e.printedOn(lr(new Date().toISOString()))}function K7(e,t){let n=e.lastChild;if(!(n instanceof Text))return;let r=V7.get(n);r&&clearTimeout(r.timer);let i=r??{original:n.data};n.data=t,i.timer=setTimeout(()=>{n.data=i.original,V7.delete(n)},Ri),V7.set(n,i)}function q7(e,t){if(!e)return;let n=document.createElement(`span`);n.className=`wui-chat-action-notice`,n.setAttribute(`role`,`status`),n.textContent=t,e.append(n),setTimeout(()=>n.remove(),Ri)}var J7=`data-wchat-docked`,Y7=`--wui-chat-docked-width`,Ate=420,X7=new Set;function jte(e,t){let n=document.documentElement;n.setAttribute(J7,e),n.style.setProperty(Y7,t)}function Mte(){let e=document.documentElement;e.removeAttribute(J7),e.style.removeProperty(Y7)}function Nte(e){let t=p3({...e,layout:`docked`,role:`dialog`,launcher:!0}),n={},r=e.position,i=!1,a=null,o=()=>`${Math.round(t.panel.getBoundingClientRect().width)||Ate}px`;function s(){X7.add(n),jte(r,o()),typeof ResizeObserver==`function`&&(a=new ResizeObserver(()=>document.documentElement.style.setProperty(Y7,o())),a.observe(t.panel))}function c(){a?.disconnect(),a=null,X7.delete(n),X7.size===0&&Mte()}function l(e){t.setOpen(e),e&&!i?(i=!0,s()):!e&&i&&(i=!1,c())}function u(e){t.setAppearance(e),e.position!==void 0&&(r=e.position,i&&document.documentElement.setAttribute(J7,r))}function d(){l(!1)}return{...t,setOpen:l,setAppearance:u,destroy:d}}function Pte(e){return p3({...e,layout:`embedded`,role:`region`,launcher:!1})}var Z7=`wchat:peeked`,Fte=576,Ite=200;function Lte(e){let t=p3({...e,layout:`launcher`,role:`dialog`,launcher:!0}),{root:n,panel:r,setLauncherState:i}=t;if(!t.nudgeHost||!t.launcherButton)throw Error(`a launcher shell always has its launcher`);let a=t.nudgeHost,o=t.launcherButton,s={peek:!1,peekSeconds:3,hideWhileOpen:!1,expressive:!1};o.dataset.state=`closed`;let c=!1,l=!1,u,d,f=()=>s.hideWhileOpen||s.expressive;function p(){!s.peek||c||l||a.dataset.launcher!==`idle`||globalThis.innerWidth<Fte||globalThis.sessionStorage.getItem(Z7)!==null||(globalThis.sessionStorage.setItem(Z7,`1`),i(`peeking`),u=setTimeout(()=>{u=void 0,a.dataset.launcher===`peeking`&&i(`idle`)},s.peekSeconds*1e3))}a.addEventListener(`animationend`,e=>{e.target===a&&a.dataset.launcher===`idle`&&p()});function m(e){if(e!==l){if(l=e,clearTimeout(u),u=void 0,e)clearTimeout(d),d=void 0,f()?(i(`hidden`),a.toggleAttribute(`inert`,!0)):a.dataset.launcher===`peeking`&&i(`idle`);else if(f()){let e=r.contains(document.activeElement);d=setTimeout(()=>{d=void 0,a.toggleAttribute(`inert`,!1),i(`idle`),e&&o.focus()},Ite)}}o.dataset.state=e?`open`:`closed`,t.setOpen(e)}function h(e){e.reduced!==void 0&&(c=!!e.reduced),e.peek!==void 0&&(s.peek=e.peek),e.peekSeconds!==void 0&&(s.peekSeconds=e.peekSeconds),e.hideWhileOpen!==void 0&&(s.hideWhileOpen=e.hideWhileOpen),e.expressive!==void 0&&(s.expressive=e.expressive===!0),e.phoneMode!==void 0&&n.classList.toggle(`wui-chat--sheet`,e.phoneMode===`Sheet`),e.sheetHeightDvh!==void 0&&n.style.setProperty(`--_wui-chat-sheet-height`,`${e.sheetHeightDvh}dvh`),e.sheetMaxHeightPx!==void 0&&n.style.setProperty(`--_wui-chat-sheet-max-height`,`${e.sheetMaxHeightPx}px`),t.setAppearance(e),!f()&&a.dataset.launcher===`hidden`&&!l&&i(`idle`),a.dataset.launcher===`idle`&&p()}return{...t,nudgeHost:a,launcherButton:o,setOpen:m,setAppearance:h}}function Rte(e){return p3({...e,layout:`full-page`,role:`region`,launcher:!1})}var zte=new Set([`Agent`,`Customer`]);function Bte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-typing`,e.setAttribute(`aria-hidden`,`true`),e.hidden=!0;let t=document.createElement(`span`);t.className=`wui-chat-loader-typing-orb`;let n=document.createElement(`span`);n.className=`wui-chat-loader-typing-dots`;for(let e=0;e<3;e++){let e=document.createElement(`span`);e.className=`wui-chat-loader-typing-dot`,n.append(e)}e.append(t,n);function r({active:n,reduced:r,authorKind:i}){e.hidden=!n,e.classList.toggle(`wui-chat-loader--reduced`,r===!0),t.hidden=zte.has(i)}function i(){e.remove()}return{el:e,update:r,destroy:i}}var Vte=3,Hte={Primary:`wui-chat-starter--primary`,Cta:`wui-chat-starter--cta`};function Q7(e,t){e.addEventListener(`click`,()=>t()),e.addEventListener(`keydown`,e=>{(Do(e)||e.key===` `)&&(e.preventDefault(),t())})}function Ute(e){let t=$(`h2`,`wui-chat-greeting`),n=$(`div`,`wui-chat-empty-hero`),r=$(`p`,`wui-chat-empty-intro`);r.hidden=!0;let i=e.mark?.(`greeting`,`rest`)??$(`span`,`wui-chat-orb`,{"aria-hidden":`true`});n.append(i,t,r);let a=$(`div`,`wui-chat-empty-extra`);a.hidden=!0;let o=$(`div`,`wui-chat-starters`,{role:`group`}),s=$(`div`,`wui-chat-empty-rows`),c=$(`div`,`wui-chat-empty-past`),l=$(`div`,`wui-chat-empty`,{role:`group`}),u=Bte();l.append(u.el,n,a,o,s,c);let d;function f(t,n){let r=$(`button`,[`wui-chat-starter`,(t.variant===null?void 0:Hte[t.variant])??``].filter(Boolean).join(` `),{type:`button`});if(r.style.setProperty(`--wui-chat-i`,String(n)),t.icon){let e=$(`span`,`wui-chat-starter-icon`,{"aria-hidden":`true`});e.append($4(t.icon,16)),r.append(e)}return r.append(document.createTextNode(t.label)),r.addEventListener(`click`,()=>e.onStarter(t)),r}function p(t,n){let r=$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}),i=$(`div`,`card-body wui-chat-empty-row-body`),a=$(`span`,`wui-chat-empty-row-label`);a.textContent=n.resumeLast;let o=$(`span`,`wui-chat-empty-row-title`,{title:t.title||n.untitled});o.textContent=t.title||n.untitled;let s=$(`span`,`wui-chat-empty-row-time`);return s.textContent=lr(t.lastActivityDateTimeUtc),i.append(a,o,s),r.append(i),Q7(r,()=>e.onResume()),r}function m(t,n){let r=$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}),i=$(`div`,`card-body wui-chat-empty-row-body`),a=$(`span`,`wui-chat-empty-row-title`,{title:t.title||n.untitled});a.textContent=t.title||n.untitled;let o=$(`span`,`wui-chat-empty-row-time`);return o.textContent=lr(t.lastActivityDateTimeUtc),i.append(a,o),r.append(i),Q7(r,()=>e.onOpenConversation(t.publicId)),r}function h(t,n,r){let i=r?$(`div`,`card card-pad-sm card-clickable wui-chat-empty-row`,{role:`button`,tabindex:`0`}):$(`div`,`card card-pad-sm wui-chat-empty-row`),a=$(`div`,`card-body wui-chat-empty-row-body`),o=$(`span`,`wui-chat-empty-row-label`);o.textContent=n.ticketAria(t.number);let s=$(`span`,`wui-chat-empty-row-title`);s.textContent=t.subject;let c=$(`span`,`wui-chat-empty-row-status`);return c.textContent=E3(t.status,n),a.append(o,s,c),i.append(a),r&&Q7(i,()=>e.onTicket(t)),i}function g(e,t){if(e.features?.OpenTickets!==!0||!e.openTickets?.length)return null;let n=$(`div`,`wui-chat-open-tickets`,{role:`group`,"aria-label":t.openTickets});return n.append(...e.openTickets.slice(0,Vte).map(n=>h(n,t,e.ticketsClickable===!0))),n}function _(e){let{labels:n}=e;t.textContent=e.greeting??``;let i=e.intro??``;r.textContent=i,r.hidden=!i,l.setAttribute(`aria-label`,n.emptyTitle);let a=e.starters??[];o.setAttribute(`aria-label`,n.starters),o.hidden=!e.showStarters||a.length===0,o.replaceChildren(...a.map(f));let c=e.resume??null,u=e.recent.length===0?null:$(`div`,`wui-chat-recent`,{role:`group`,"aria-label":n.recentChats});u?.append(...e.recent.map(e=>m(e,n)));let d=g(e,n),h=u??(c===null?null:p(c,n));s.hidden=h===null&&d===null,s.replaceChildren(...[h,d].filter(e=>e!==null))}function v(e){clearTimeout(d),l.classList.remove(`wui-chat-empty--revealed`),l.classList.add(`wui-chat-empty--intro`),u.update({active:!0,reduced:!1,authorKind:`Assistant`}),d=setTimeout(()=>{d=void 0,u.update({active:!1,reduced:!1,authorKind:`Assistant`}),l.classList.replace(`wui-chat-empty--intro`,`wui-chat-empty--revealed`)},e)}return{el:l,paint:_,intro:v,extraHost:a,pastHost:c}}function Wte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-orb`;let t=document.createElement(`span`);t.className=`wui-chat-loader-orb-mark`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-orb-glow`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`span`);r.className=`wui-chat-loader-orb-disc`,r.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=document.createElement(`span`);i.className=`wui-chat-loader-orb-label`,e.append(t,i);let a=t;return{el:e,render(n,r=null){i.textContent!==n.label&&(i.textContent=n.label);let o=r??t;o!==a&&(a.parentNode===e?a.replaceWith(o):e.prepend(o),a=o)}}}var Gte=150,$7=1800;function Kte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-phrases`;let t=document.createElement(`span`);t.className=`wui-chat-loader-phrases-orb`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-phrases-stage`,e.append(t,n);let r=null,i=null;function a(){return e.closest(`.wui-chat-loader`)?.classList.contains(`wui-chat-loader--reduced`)===!0}function o(e){if(e.label===r)return;r=e.label;let t=i,o=document.createElement(`span`);o.className=`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--in`,o.textContent=e.label,o.style.animationDelay=`-${Math.round(performance.now()%$7)}ms, 0s`,n.append(o),i=o,t&&(t.classList.remove(`wui-chat-loader-phrases-text--in`),t.classList.add(`wui-chat-loader-phrases-text--out`),t.style.animationDelay=`-${Math.round(performance.now()%$7)}ms, 0s`,a()?t.remove():setTimeout(()=>t.remove(),Gte))}return{el:e,render:o}}var qte=3;function Jte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-pulse`;let t=document.createElement(`span`);t.className=`wui-chat-loader-pulse-disc`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);n.className=`wui-chat-loader-pulse-label`;let r=document.createElement(`span`);r.className=`wui-chat-loader-pulse-dots`,r.setAttribute(`aria-hidden`,`true`);for(let e=0;e<qte;e+=1){let e=document.createElement(`span`);e.className=`wui-chat-loader-pulse-dot`,r.append(e)}e.append(t,n,r);let i=t;return{el:e,render(r,a=null){n.textContent!==r.label&&(n.textContent=r.label);let o=a??t;o!==i&&(i.parentNode===e?i.replaceWith(o):e.prepend(o),i=o)}}}var Yte=[`95%`,`80%`,`60%`];function Xte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-skeleton`;let t=document.createElement(`div`);t.className=`wui-chat-loader-skeleton-label`;let n=document.createElement(`div`);n.className=`wui-chat-loader-skeleton-body`;let r=document.createElement(`span`);r.className=`wui-chat-loader-skeleton-avatar`,r.setAttribute(`aria-hidden`,`true`),n.append(r);for(let e of Yte){let t=document.createElement(`span`);t.className=`wui-chat-loader-skeleton-line`,t.setAttribute(`aria-hidden`,`true`),t.style.width=e,n.append(t)}return e.append(t,n),{el:e,render(e){t.textContent!==e.label&&(t.textContent=e.label)}}}var e9=`http://www.w3.org/2000/svg`;function Zte(e){if(e===`done`){let e=document.createElementNS(e9,`svg`);e.setAttribute(`viewBox`,`0 0 16 16`),e.setAttribute(`class`,`wui-chat-loader-steps-check`);let t=document.createElementNS(e9,`path`);return t.setAttribute(`d`,`M3 8.5 6.5 12 13 4.5`),t.setAttribute(`pathLength`,`1`),e.append(t),e}let t=document.createElement(`span`);return t.className=e===`active`?`wui-chat-loader-steps-ring`:`wui-chat-loader-steps-dot`,t}function Qte(){let e=document.createElement(`div`);e.className=`wui-chat-loader-steps`;let t=document.createElement(`span`);t.className=`wui-chat-loader-steps-pill`;let n=document.createElement(`ol`);n.className=`wui-chat-loader-steps-list`,e.append(t,n);let r=[],i=null;function a(){let e=document.createElement(`li`);e.className=`wui-chat-loader-steps-item`;let t=document.createElement(`span`);t.className=`wui-chat-loader-steps-icon`,t.setAttribute(`aria-hidden`,`true`);let i=document.createElement(`span`);i.className=`wui-chat-loader-steps-text`,e.append(t,i);let a={li:e,icon:t,text:i,state:null};return r.push(a),n.append(e),a}function o(o,s=null){s!==i&&(i?.remove(),i=s,s!==null&&e.prepend(s));let c=o.steps.length===0;for(t.hidden=!c,n.hidden=c,c&&t.textContent!==o.label&&(t.textContent=o.label),o.steps.forEach((e,t)=>{let n=r[t]??a();n.text.textContent!==e&&(n.text.textContent=e);let i=t<o.activeIndex?`done`:t===o.activeIndex?`active`:`pending`;n.state!==i&&(n.state=i,n.li.dataset.state=i,n.icon.replaceChildren(Zte(i)))});r.length>o.steps.length;)r.pop()?.li.remove()}return{el:e,render:o}}var t9={Steps:Qte,Phrases:Kte,Orb:Wte,Skeleton:Xte,PulseAndDots:Jte},$te=500;function ene(){let e=document.createElement(`div`);e.className=`wui-chat-loader`,e.setAttribute(`role`,`status`),e.hidden=!0;let t=document.createElement(`span`);t.className=`wui-chat-loader-avatar`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`div`);n.className=`wui-chat-loader-body`;let r=document.createElement(`span`);r.className=`visually-hidden`,e.append(t,n,r);let i=null,a=null,o=0,s=null,c=0,l=null,u=!1;function d(){s!==null&&clearInterval(s),s=null}function f(){e.isConnected?(o+=1,p()):d()}function p(){if(!a||!i)return;let t=Re(i.style,i.steps,i.phrases,o);a.render(t,i.mark),e.setAttribute(`aria-label`,t.label)}function m(){l!==null&&clearTimeout(l),l=null,u=!1,r.textContent=``}function h(e){!u&&l===null&&e&&(l=setTimeout(()=>{l=null,u=!0,r.textContent=e},$te))}function g(t){if(!t.active)i=null,e.hidden=!0,e.removeAttribute(`data-loading`),d(),m();else{if(!Q4(t9,t.style))throw Error(`Unknown loader style. Use Steps, Phrases, Orb, Skeleton or PulseAndDots.`);if(!(t.intervalMs>0))throw Error(`Loader intervalMs must be a positive number.`);if(i={...t,steps:t.steps??[],phrases:t.phrases??[],mark:t.mark??null},e.hidden=!1,e.setAttribute(`data-loading`,`true`),e.classList.toggle(`wui-chat-loader--reduced`,t.reduced===!0),!a||a.style!==t.style){let r=t9[t.style]();n.replaceChildren(r.el),a={style:t.style,render:r.render},e.dataset.style=t.style,o=0}h(t.announce),t.reduced===!0?(d(),o=0):(s===null||c!==t.intervalMs)&&(d(),c=t.intervalMs,s=setInterval(f,c)),p()}}function _(){d(),m(),a=null,i=null,e.remove()}return{el:e,update:g,destroy:_}}function tne({voice:e,getLabels:t,message:n}){if(n.streaming||!e.canSpeak()||$5(n.parts)===``)return null;let r=e.getStatus(),i=r.mode===`Speaking`&&r.messageId===n.id,a=t(),o=i?a.readAloudStop:a.readAloud,s=$(`button`,`wui-chat-action-btn wui-chat-speak`,{type:`button`,"aria-pressed":String(i),"aria-label":o,title:o});return s.append(T5(i?`stop`:`speaker`,16)),s.addEventListener(`click`,()=>{e.toggleSpeak(n.id,n.parts)}),s}function nne({voice:e,getLabels:t,message:n}){let r=e.getStatus().note;if(r?.code!==`SpeakFailed`||r.messageId!==n.id)return null;let i=$(`span`,`wui-chat-action-notice`,{role:`status`});return i.textContent=e7(r,t()),i}function rne(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function n9(e,t){let n=rne(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}function ine(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.author.kind===`Visitor`&&n.stored)return n}}var ane=new Set([`Assistant`,`Agent`]),r9=new Set([`Assistant`,`Agent`,`Script`]),i9=new Set([`Visitor`,`Customer`]),one=48,sne=120,cne={author:{kind:`Assistant`,displayName:null,avatarUrl:null}},lne={warning:`alert-triangle`,danger:`alert-circle`};function a9(e,t,n,r,i){n!==null&&(n.dataset.state=i?`busy`:`rest`,r?n.parentNode!==e&&e.insertBefore(n,t):n.remove())}function o9(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=one}function s9(e){let{kind:t,displayName:n}=e.author;return t===`Agent`?`Agent:${n??``}`:t===`Script`?`Assistant`:t}function une(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function dne(e){let t=e.textContent?.trim();t&&!e.hasAttribute(`aria-label`)&&(e.setAttribute(`aria-label`,t),e.setAttribute(`title`,t))}function fne(e){return e.reduced===!0}function c9(e,t,n){let r=$(`button`,`${e3(`ghost`,`sm`)} wui-chat-action-btn`,{type:`button`,"aria-label":e,title:e}),i=$(`span`);return i.textContent=e,r.append($4(t,14),i),r.addEventListener(`click`,n),{node:r,text:i}}function pne(e,t){return e.profile?.assistant.name||t.assistant}function mne(e,t,n){return e.author.displayName==null?e.author.kind===`Visitor`||e.author.kind===`Customer`?n.you:e.author.kind===`Agent`?n.agent:t.profile?.assistant.name??n.assistant:e.author.displayName}function hne(e){let t=$(`li`,`wui-chat-day`,{role:`presentation`}),n=$(`span`);return n.textContent=e,t.append(n),t}function gne(e){let t=$(`ol`,`wui-chat-thread`),n=$(`div`,`wui-chat-log`,{role:`log`,"aria-live":`polite`});n.append(t);let r=ene(),i=$(`li`,`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`),a=$(`div`,`wui-chat-loader-slot`);a.append(r.el);let o=e.mark?.(`loader`,`busy`)??null;i.append(a);let s=!1,c,l=$(`li`,`wui-chat-message wui-chat-message--assistant wui-chat-message--greeting`,{"data-run-start":``,"data-restored":``}),u=$(`div`,`wui-chat-message-body`),d=$(`p`,`wui-chat-text`);u.append(d),l.append(u);let f=e.mark?.(`reply`,`rest`)??null,p=$(`button`,`wui-chat-jump`,{type:`button`}),m=$(`div`,`wui-chat-jump-slot`);m.hidden=!0,m.append(p);let h=null,g=!0,_=null,v=null,y=new Map,b=``,x=null;function S(e,t){return{kind:e.kind,part:e,tag:t[e.kind]}}function C(t,n,r){return Object.assign(document.createElement(t),{message:r,turn:e.makeTurnApi(r.id),chatPart:n})}function w(e){return $(`div`,`wui-chat-part wui-chat-part--${e.toLowerCase()}`)}function T(e,t,n,r){e.parts=[];let i=[],a=e=>{let r=S(e,n),i=w(r.kind);return i.append(C(r.tag,r.part,t)),i};for(let e of r(t))if(Array.isArray(e)){let t=$(`div`,`wui-chat-part-group`);t.append(...e.map(a)),i.push(t)}else i.push(a(e));e.body.replaceChildren(...i)}function E(t,n,r){let i=[];n.parts.forEach((a,o)=>{let s=S(a,r),c=t.parts[o];if(c&&c.kind===s.kind&&c.tag===s.tag){c.part!==s.part&&(c.element.message=n,c.element.turn=e.makeTurnApi(n.id),c.element.chatPart=s.part,c.part=s.part),i.push(c);return}let l=w(s.kind),u=C(s.tag,s.part,n);l.append(u),i.push({kind:s.kind,tag:s.tag,part:s.part,element:u,wrapper:l})}),t.parts=i,D(t.body,i.map(e=>e.wrapper))}function D(e,t){let n=new Set(t);for(let t of[...e.children])n.has(t)||t.remove();t.forEach((t,n)=>{e.children[n]!==t&&e.insertBefore(t,e.children[n]??null)})}function O(e,t,n){let r=$(`div`,`wui-chat-rating`,{role:`group`,"aria-label":`${n.rateUp} / ${n.rateDown}`}),i=[[`Up`,n.rateUp,`thumbs-up`],[`Down`,n.rateDown,`thumbs-down`]];for(let[a,o,s]of i){let i=t.rating===a,c=$(`button`,`${e3(i?`neutral`:`ghost`,`sm`)} wui-chat-action-btn`,{type:`button`,"aria-pressed":String(i),"data-rating":a,"aria-label":o,title:o}),l=$(`span`);l.textContent=o,c.append($4(s,14),l),c.addEventListener(`click`,()=>k(e,t,a,n)),r.append(c)}if(e.ratingNote){let t=$(`span`,null,{role:`status`});t.textContent=e.ratingNote,r.append(t)}return r}async function k(t,n,r,i){try{await e.onRate(n.id,r),t.ratingNote=i.rated}catch{t.ratingNote=i.ratingFailed}x&&ue(x.state,x.context)}function A(t,n,r,i,a){let{labels:o}=i,s=r.features,c=n.author.kind,l=fr(n.parts),u=[];if(s.Copy&&r9.has(c)&&l){let e=c9(o.copy,`copy`,()=>void(async()=>{await zi(l)&&(e.text.textContent=o.copied,e.node.dataset.done=``,e.node.setAttribute(`aria-label`,o.copied),e.node.title=o.copied,clearTimeout(t.copyTimer),t.copyTimer=setTimeout(()=>{e.text.textContent=o.copy,delete e.node.dataset.done,e.node.setAttribute(`aria-label`,o.copy),e.node.title=o.copy},Ri))})());u.push(e.node)}let d=e.getVoice?.();if(d&&r9.has(c)){let e=tne({voice:d,getLabels:()=>o,message:n});e&&u.push(e);let t=nne({voice:d,getLabels:()=>o,message:n});t&&u.push(t)}if(r9.has(c)){let e=$(`div`);Ete(e,n,{labels:o,features:s,title:pne(r,o),assistantName:r.profile?.assistant.name,busy:r.streaming||r.thinking});for(let t of e.children)dne(t);u.push(...e.childNodes)}let f=r.messages.some(e=>e.author.kind===`Visitor`&&e.stored);a&&c===`Assistant`&&!r.streaming&&!r.thinking&&s.Regenerate&&f&&u.push(c9(o.regenerate,`refresh`,()=>e.onRegenerate()).node);let p=ine(r.messages);s.Edit&&p?.id===n.id&&!r.streaming&&!r.thinking&&u.push(c9(o.edit,`pencil`,()=>e.getSession().startEdit(n.id)).node),s.Rating&&n.stored&&ane.has(c)&&u.push(O(t,n,o)),t.actions.hidden=u.length===0,t.actions.replaceChildren(...u)}function j(t){let n=y.get(t.id);if(n)return n;let r=$(`li`,`wui-chat-message`),i=$(`span`,`wui-chat-author visually-hidden`),a=$(`div`,`wui-chat-message-body`),o=$(`div`,`wui-chat-message-actions`);r.append(i,a,o);let s={li:r,author:i,body:a,actions:o,head:null,parts:[],copyTimer:void 0,ratingNote:null,mark:t.author.kind===`Assistant`?e.mark?.(`reply`,`rest`)??null:null};return y.set(t.id,s),s}function M(e,t,n,r){let i=n?.author.kind===`Agent`&&t.author.kind===`Agent`&&(n.author.displayName??``)===(t.author.displayName??``);e.head?.remove(),e.head=t.author.kind===`Agent`&&!i?C3(t.author,r):null,e.head&&e.li.insertBefore(e.head,e.body)}function ee(t,n,r,i,a,o){let{labels:s}=i;t.li.className=`wui-chat-message wui-chat-message--${n.author.kind.toLowerCase()}`,t.li.toggleAttribute(`data-restored`,n.restored===!0);let c=!o||s9(o)!==s9(n);t.li.toggleAttribute(`data-run-start`,c);let l=i.replyAvatars??`First`,u=n.author.kind===`Assistant`&&(l===`Every`||l===`First`&&c);a9(t.li,t.body,t.mark,u,n.streaming),n.streaming?t.li.setAttribute(`aria-busy`,`true`):t.li.removeAttribute(`aria-busy`),t.author.textContent=`${mne(n,r,s)}: `,M(t,n,o,s);let d=e.getRenderers(),f=e.getLayoutParts();typeof f==`function`?T(t,n,d,f):E(t,n,d),n.streaming?(t.actions.hidden=!0,t.actions.replaceChildren()):A(t,n,r,i,a)}function te(e,t){let n=$(`li`,`wui-chat-message wui-chat-message--system wui-chat-message--notice`),r=$(`div`,`wui-chat-notice wui-chat-notice--${e}`,{role:e===`danger`?`alert`:`status`}),i=$(`span`,`wui-chat-notice-icon`,{"aria-hidden":`true`});i.append($4(lne[e],16));let a=$(`div`,`wui-chat-notice-body`),o=$(`span`,`wui-chat-notice-text`);return o.textContent=t,a.append(o),r.append(i,a),n.append(r),n}function ne(e,t){let n=e.resetsDateTimeUtc?` ${t.dailyLimitRefresh(n9(e.resetsDateTimeUtc))}`:``;return te(`warning`,`${e.message}${n}`)}function re(t,n){let{labels:r}=n,i=t.turnError,a=i?.code??``;if(i&&a===`daily_limit`)return ne(i,r);if(a.endsWith(`feature_off`))return te(`danger`,t.turnError?.message||r.stopped);let o=$(`li`,`wui-chat-message wui-chat-message--system wui-chat-message--error`),s=$(`p`,`wui-chat-error`,{role:`alert`});s.textContent=t.turnError?.message||r.stopped;let c=$4(`alert-circle`,16);if(c.setAttribute(`aria-hidden`,`true`),o.append(c,s),t.features.Retry){let t=$(`div`,`wui-chat-message-actions`);t.append(c9(r.retry,`rotate-ccw`,()=>e.onRetry()).node),o.append(t)}return o}function ie(){return t.closest(`.wui-chat`)}function ae(){return t.closest(`.wui-chat-body`)??une(t)}function oe(e){ie()?.classList.toggle(`wui-chat--scrolled`,e.scrollTop>0),o9(e)&&(m.hidden=!0)}function se(){h!==null&&(g=o9(h),oe(h))}function ce(e){n.nextElementSibling!==m&&n.parentNode&&n.after(m),e!==h&&(h?.removeEventListener(`scroll`,se),h=e,e.addEventListener(`scroll`,se,{passive:!0}),!_&&typeof ResizeObserver==`function`&&(_=new ResizeObserver(()=>{g&&h&&(h.scrollTop=h.scrollHeight)}),_.observe(t)))}p.addEventListener(`click`,()=>{let e=ae(),t=x?.context.reduced===!0;e?.scrollTo({top:e.scrollHeight,behavior:t?`auto`:`smooth`}),m.hidden=!0,p.blur()});function le(e,t){let n=e.messages[e.messages.length-1],r=n?`${n.id}|${n.parts.length}|${fr(n.parts).length}`:``;if(r===b)return;let i=b===``||e.conversationId!==v;b=r,v=e.conversationId;let a=ae();a&&(ce(a),i||t||n!==void 0&&i9.has(n.author.kind)?(a.scrollTop=a.scrollHeight,m.hidden=!0,g=!0):(m.hidden=!1,g=!1),oe(a))}function ue(e,a){x={state:e,context:a};let{labels:m}=a;n.setAttribute(`aria-label`,m.thread),p.textContent=m.newMessages??`New messages`;let h=ae();h&&ce(h);let g=h===null||h.clientHeight===0||o9(h),_=[],v=new Set,b=e.messages.filter(e=>!(e.streaming&&e.parts.length===0)),S=b[0],C=S!==void 0&&i9.has(S.author.kind)&&e.greeting?e.greeting:null,w=null,T=e=>{let t=dr(e.createdDateTimeUtc,m);t!==w&&(w=t,_.push(hne(t)))};C&&S&&(T(S),d.textContent=C,a9(l,u,f,(a.replyAvatars??`First`)!==`None`,!1),_.push(l)),b.forEach((t,n)=>{let r=j(t);v.add(t.id),T(t);let i=b[n-1]??(C?cne:null);ee(r,t,e,a,n===b.length-1,i),_.push(r.li)});for(let e of[...y.keys()])v.has(e)||y.delete(e);e.agentTyping&&_.push(w3(e.agentTyping,m)),e.thinking?(clearTimeout(c),c=void 0,i.classList.remove(`wui-chat-message--leaving`),s=!0,r.update({active:!0,mark:o,style:a.loaderStyle,steps:e.steps,phrases:a.phrases,intervalMs:a.intervalMs,reduced:a.reduced,announce:a.assistantName?.trim()?m.preparingAnswer(a.assistantName):void 0}),_.push(i)):s&&c===void 0&&!fne(a)?(i.classList.add(`wui-chat-message--leaving`),c=setTimeout(()=>{c=void 0,s=!1,i.classList.remove(`wui-chat-message--leaving`),r.update({active:!1}),x&&ue(x.state,x.context)},sne),_.push(i)):c===void 0?(s=!1,r.update({active:!1})):_.push(i),!e.streaming&&(e.turnError||e.stopped)&&_.push(re(e,a)),D(t,_),le(e,g)}function de(e){return y.get(e)?.li??null}function fe(){clearTimeout(c),r.destroy(),h?.removeEventListener(`scroll`,se),_?.disconnect(),y.clear(),x=null,n.remove()}return{el:n,paint:ue,find:de,destroy:fe}}var l9=`wchat:auto-opened`,_ne=`wchat:dismissed`,vne=`button, a[href], input, select, textarea`,u9=`input, textarea`;function d9(e){return!e.closest(`.wui-chat`)}function yne(e){return e instanceof Element&&e.matches(u9)&&d9(e)}function bne(){return[...document.querySelectorAll(u9)].some(e=>d9(e)&&e.value!==e.defaultValue)}function f9(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function xne(e){return e?[...document.querySelectorAll(vne)].some(t=>{if(!d9(t))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}):!1}function Sne(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(l9)||e.rememberDismissal&&sessionStorage.getItem(_ne)||window.innerWidth<e.skipBelowWidthPx)return!0;let r=window.location.pathname;if(e.skipPathPrefixes.some(e=>r.startsWith(e)))return!0;let i=t.avoid.autoOpenOptOutSelector;return i&&document.querySelector(i)||e.skipWhenFormTouched&&bne()||n.isOpen()?!0:e.skipWhenCoversControl&&xne(n.panelRect())}function Cne(e){return yne(document.activeElement)||f9(e.avoid.menuSelectors)||f9(e.avoid.autoOpenBusySelectors)}function wne(e,t,n){let r;function i(){r=void 0,Sne(e,t,n)||(Cne(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(l9,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=void 0}}}var Tne=.4,Ene=.5,Dne=`rgba(0, 0, 0, 0)`,One=20,kne=`wui-consent-banner[open]`;function p9(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Ane(e){let t=e.createElement(`canvas`);t.width=1,t.height=1;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)throw Error(`A 2D canvas context is needed to read the colour under the launcher.`);return e=>{n.clearRect(0,0,1,1),n.fillStyle=Dne,n.fillStyle=e,n.fillRect(0,0,1,1);let[t=0,r=0,i=0,a=0]=n.getImageData(0,0,1,1).data;return{r:t,g:r,b:i,alpha:a/255}}}function jne({r:e,g:t,b:n}){return .2126*p9(e)+.7152*p9(t)+.0722*p9(n)}function Mne(e,t,n){let r=e.getBoundingClientRect(),i=document.elementsFromPoint?.(r.left+r.width/2,r.top+r.height/2)??[],a=t.length?t.join(`,`):null;for(let t of i){if(e.contains(t))continue;if(a&&t.closest(a))return!0;let r=n(getComputedStyle(t).backgroundColor);if(!(r.alpha<Ene))return jne(r)<Tne}return!1}function m9(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function Nne(e,t){let n=0;for(let r of e){let e=r.getBoundingClientRect();e.height!==0&&e.left<t.right&&e.right>t.left&&(n=Math.max(n,window.innerHeight-e.top))}return n>0?n+One:0}function Pne(e){if(e.length===0)return!1;for(let t of document.querySelectorAll(e.join(`,`))){let e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return!0}return!1}function Fne(e,t,n,r=e=>{n.dataset.launcher=e}){let i=n.ownerDocument.documentElement,a=t.switchOnDark?Ane(n.ownerDocument):null,o=0,s=!1,c=null;function l(){o=0;let l=[...t.liftAboveFooter?m9(e.liftSelectors):[],...t.liftAboveBanner?m9([kne]):[]];if(c)for(let e of l)c.observe(e);n.style.setProperty(`--wui-chat-lift`,`${Nne(l,n.getBoundingClientRect())}px`);let u=n.getBoundingClientRect(),d=u.height===0?0:Math.round(window.innerHeight-u.top);i.style.setProperty(`--wui-chat-launcher-block`,`${d}px`);let f=t.stepAsideForMenus&&Pne(e.menuSelectors);f&&!s?(r(`hidden`),n.inert=!0,s=!0):!f&&s&&(r(`idle`),n.inert=!1,s=!1);let p=a!==null&&Mne(n,e.darkSelectors,a);p&&n.dataset.onDark===void 0&&(n.dataset.onDark=``),!p&&n.dataset.onDark!==void 0&&delete n.dataset.onDark}function u(){o||=requestAnimationFrame(l)}typeof ResizeObserver==`function`&&(c=new ResizeObserver(u));let d=new MutationObserver(u);return d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`open`,`data-menu-open`]}),document.addEventListener(`scroll`,u,{capture:!0,passive:!0}),window.addEventListener(`resize`,u),window.addEventListener(`load`,u),n.addEventListener(`animationend`,u),u(),{destroy(){o&&cancelAnimationFrame(o),o=0,c?.disconnect(),d.disconnect(),document.removeEventListener(`scroll`,u,{capture:!0}),window.removeEventListener(`resize`,u),window.removeEventListener(`load`,u),n.removeEventListener(`animationend`,u),s&&=(n.inert=!1,!1),delete n.dataset.onDark,n.style.removeProperty(`--wui-chat-lift`),i.style.removeProperty(`--wui-chat-launcher-block`)}}}var h9=`wchat:session-start`,g9=`wchat:pages`,_9=`wchat:services`;function v9(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function y9(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function Ine(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function Lne(e){sessionStorage.getItem(h9)||sessionStorage.setItem(h9,String(Date.now()));let t=0;function n(){let e=document.documentElement.scrollHeight;if(e<=0)return;let n=(window.scrollY+window.innerHeight)/e*100;n>t&&(t=n)}return window.addEventListener(`scroll`,n,{passive:!0}),function(){n();let r=window.location.pathname,i=v9(g9);i.includes(r)||(i.push(r),y9(g9,i));let a=Ine(r,e),o=v9(_9);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),y9(_9,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(h9)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var b9=8,Rne=`(min-width: 992px)`,zne=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,x9=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],S9=0;function C9(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Bne(e){let{trigger:t,request:n,isEmpty:r,renderAnswer:i,renderFooter:a,session:o,timings:s,onStateChange:c,returnFocusTo:l}=e??{};if(!(t instanceof HTMLElement))throw TypeError(`createExplainPopover needs a "trigger" element.`);if(typeof n!=`function`)throw TypeError(`createExplainPopover needs a "request" function.`);if(typeof i!=`function`)throw TypeError(`createExplainPopover needs a "renderAnswer" function.`);S9+=1;let u=e.title??``,d=e.showNotCounted??!0,f=`wui-chat-explain-${S9}`,p=()=>Ae(e.labels??{}),m=()=>({labels:p(),close:ae}),h=Zt({request:n,...r===void 0?{}:{isEmpty:r},...s}),g=Object.fromEntries(x9.map(e=>[e,t.getAttribute(e)])),_=t.hidden,v;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,f);let y=null,b=null,x=null,S,C=null,w=[],T=[],E=()=>o?.getState().features.Explain===!1;function D(){h.getSnapshot().offline?(v===void 0&&(v=t.getAttribute(`title`)),t.setAttribute(`title`,p().explainOffline),t.setAttribute(`aria-disabled`,`true`),t.setAttribute(`data-offline`,``)):(v!==void 0&&C9(t,`title`,v),v=void 0,t.removeAttribute(`aria-disabled`),t.removeAttribute(`data-offline`)),o&&(t.hidden=E())}function O(e){if(b?.replaceChildren(),e.pillVisible){let t=$(`span`,`wui-chat-explain-pill`),n=$(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=$(`span`);r.textContent=e.state===`slow`?p().explainSlow:p().thinking,t.append(n,r);let i=$(`div`,`wui-chat-explain-thinking`,{role:`status`});i.append(t),b?.append(i)}else if(e.state===`answered`){e.answer!==S&&(x=i(e.answer,m())??null,S=e.answer);let t=$(`div`,`wui-chat-explain-answer`);x&&t.append(x),b?.append(t)}else if(e.state===`empty`){let e=$(`p`,`wui-chat-explain-text`);e.textContent=p().explainEmpty,b?.append(e)}else if(e.state===`capacity`){let t=$(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=$(`p`);n.textContent=e.resetsDateTimeUtc?p().explainCapacity(n9(e.resetsDateTimeUtc)):p().explainCapacityNoDate,t.append(n),b?.append(t)}else if(e.state===`error`){let e=$(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=$(`p`);t.textContent=p().explainError,e.append(t,t3(`ghost`,p().retry,`rotate-ccw`,()=>h.ask())),b?.append(e)}}function k(){let e=y?.querySelector(`.wui-chat-explain-foot`);e?.replaceChildren();let t=a?.(m());if(t&&e?.append(t),d){let t=$(`p`,`wui-chat-explain-note`);t.textContent=p().explainNotCounted,e?.append(t)}}function A(){if(!y)return;let e=h.getSnapshot();y.dataset.state=e.state,O(e),k(),c?.(e)}function j(){if(!y)return;if(!t.isConnected){ae({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wchat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Rne)?.matches===!0){y.dataset.beside=e,y.style.left=``,y.style.top=``,y.style.maxHeight=``;return}delete y.dataset.beside,y.style.position=`fixed`;let n=t.getBoundingClientRect(),r=y.offsetWidth,i=y.offsetHeight,a=globalThis.innerHeight-n.bottom-b9,o=a<i&&n.top>a,s=o?n.top-b9:a,c=o?Math.max(b9,n.top-i-b9):n.bottom+b9,l=Math.max(b9,Math.min(n.left,globalThis.innerWidth-r-b9));y.style.top=`${c}px`,y.style.left=`${l}px`,y.style.maxHeight=s<i?`${Math.max(0,s)}px`:``}function M(e){e.key===`Escape`&&(document.documentElement.hasAttribute(`data-wchat-docked`)||(e.stopPropagation(),ae()))}function ee(e){let n=e.target;n instanceof Node&&(y?.contains(n)||t.contains(n))||n instanceof Element&&n.closest(`.wui-chat-panel`)||ae({restoreFocus:!1})}function te(e){e.target instanceof Node&&y?.contains(e.target)||j()}function ne(){h.getSnapshot().offline||oe()}function re(){for(let[e,t,n,r]of w)e.removeEventListener(t,n,r);w=[];for(let e of T)e.disconnect();T=[]}function ie(){if(y||E()||h.getSnapshot().offline)return;y=$(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":u,popover:`manual`,id:f});let e=$(`header`,`wui-chat-explain-head`),n=$(`strong`,`wui-chat-explain-title`);n.textContent=u,C=n3(p().close,`x`,()=>ae()),C.classList.add(`wui-chat-explain-close`),e.append(n,C),b=$(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),y.append(e,b,$(`div`,`wui-chat-explain-foot`)),y.dataset.state=h.getSnapshot().state,document.body.append(y),y.showPopover?.(),t.setAttribute(`aria-expanded`,`true`),h.ask(),j(),(y.querySelector(zne)??C).focus({preventScroll:!0}),w=[[document,`keydown`,M,!0],[document,`pointerdown`,ee,!0],[window,`resize`,j,!1],[document,`scroll`,te,!0]];for(let[e,t,n,r]of w)e.addEventListener(t,n,r);if(typeof ResizeObserver==`function`){let e=new ResizeObserver(()=>j());e.observe(y),T.push(e)}let r=new MutationObserver(()=>j());r.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-wchat-docked`]}),T.push(r)}function ae(e={restoreFocus:!0}){y&&(h.reset(),re(),y.remove(),y=null,b=null,x=null,S=void 0,C=null,t.setAttribute(`aria-expanded`,`false`),D(),e?.restoreFocus!==!1&&(l?.()??t).focus({preventScroll:!0}))}function oe(){y?ae():ie()}let se=h.subscribe(()=>{D(),h.getSnapshot().offline&&y?ae():A()}),ce=o?.subscribe(()=>{D(),E()&&y&&ae({restoreFocus:!1})});return t.addEventListener(`click`,ne),D(),{open:ie,close:ae,toggle:oe,isOpen:()=>y!==null,destroy(){ae({restoreFocus:!1}),se(),ce?.(),h.dispose(),t.removeEventListener(`click`,ne);for(let e of x9)C9(t,e,g[e]);t.hidden=_}}}var Vne=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Hne(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(Vne)].filter(e=>e.tabIndex>=0&&!e.hidden),r=n[0],i=n[n.length-1];if(!r||!i){t.preventDefault();return}let a=e.ownerDocument.activeElement,o=e.contains(a);t.shiftKey?o&&a!==r||(t.preventDefault(),i.focus()):o&&a!==i||(t.preventDefault(),r.focus())}function Une(e){e?.isConnected&&e.focus()}function Wne(e,t){if(t||typeof navigator>`u`)return;let n=navigator;typeof n.vibrate==`function`&&n.vibrate(e)}var w9=`wui-chat-lock`,T9=`wui-chat-scroll-lock`;function Gne(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(w9);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(T9,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(w9);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(T9,{detail:{locked:!1}}))}}}var Kne={open:{from:420,to:920,seconds:.16,peak:.16},reply:{from:680,to:540,seconds:.11,peak:.06},sent:{from:540,to:760,seconds:.09,peak:.05}},E9=[`pointerdown`,`keydown`,`touchstart`],D9=`wchat:muted`,qne=1e-4;function Jne(e,t){let n=t.get(D9)===`1`,r=null;function i(){for(let e of E9)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume().catch(e=>globalThis.reportError?.(e)),i()}for(let e of E9)document.addEventListener(e,a);return{play(t){let i=Kne[t];if(!i||n||!r||!e[t]||!(e.volume>0))return;let a=r.currentTime,o=r.createOscillator(),s=r.createGain();o.type=`sine`,o.frequency.setValueAtTime(i.from,a),o.frequency.linearRampToValueAtTime(i.to,a+i.seconds),s.gain.setValueAtTime(i.peak*e.volume,a),s.gain.exponentialRampToValueAtTime(qne,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(D9,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close().catch(e=>globalThis.reportError?.(e)),r=null}}}var Yne=2e3,Xne=500,Zne=32,O9=16,k9=`data-wchat-switching`;function Qne(e){return new Promise(t=>setTimeout(t,e))}function A9(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=O9,setTimeout(i,O9))};setTimeout(i,O9)})}async function $ne(e,t={}){let n=t.reduced??globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;if(typeof document.startViewTransition!=`function`||n){await e();return}let r=document.documentElement;r.setAttribute(k9,``);try{let n=()=>!t.target||document.querySelector(`.wui-chat--${t.target}`)!==null,r=()=>(typeof t.pageReady!=`function`||t.pageReady())&&n(),i=document.startViewTransition(async()=>{await e(),await A9(t.routeReady,Yne),await A9(r,Xne),await Qne(Zne)});Promise.allSettled([i.ready]);try{await i.updateCallbackDone}finally{await Promise.allSettled([i.finished])}}finally{r.removeAttribute(k9)}}var ere=100,j9=12,tre=220;function nre(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=void 0,window.innerWidth>t.phone.maxWidthPx){a();return}if(!r)return;let o=Math.max(0,window.innerHeight-r.height-r.offsetTop),s=window.innerHeight-r.height>j9,c=r.height-(n||s?j9:0);n&&(c=Math.min(t.phone.sheetMaxHeightPx,Math.max(tre,c))),e.style.bottom=`${o}px`,e.style.maxHeight=`${c}px`}function s(){clearTimeout(i),i=setTimeout(o,ere)}return r?.addEventListener(`resize`,s),r?.addEventListener(`scroll`,s),window.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),o(),{destroy(){clearTimeout(i),r?.removeEventListener(`resize`,s),r?.removeEventListener(`scroll`,s),window.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s),a()}}}var M9=[`launcher`,`docked`,`full-page`,`embedded`],N9=[`end`,`start`],P9={steps:`Steps`,phrases:`Phrases`,orb:`Orb`,skeleton:`Skeleton`,"pulse-and-dots":`PulseAndDots`},rre={on:`On`,reduced:`Reduced`},ire={still:`Still`,drift:`Drift`},are=[`auto`,`light`,`dark`];function ore(e){return are.find(t=>t===e)??`auto`}var sre=`wchat:muted`,cre=`wchat:open`,lre=6e4,ure=400,dre=[`labels`,`pageContext`,`compact`,`expressive`,`open`,`layoutParts`,`getCaptchaToken`,`attribution`,`openAttachment`,`openCitation`,`openTarget`,`openTicket`,`onNavigate`,`resolveLink`,`emptyContent`,`onPanelSwitch`,`preloadPanelSwitch`],F9={...A5};function I9(e,t){if(!u3.includes(e))throw Error(`Unknown part kind "${e}". Use one of ${u3.join(`, `)}.`);if(typeof t!=`string`||!t.includes(`-`))throw Error(`Renderer tag "${t}" must be a custom element name containing a hyphen.`)}function fre(e,t){I9(e,t),F9[e]=t}function L9(e,t){return n=>{let r=n.toLowerCase(),i=Q4(t,r)?t[r]:void 0;if(i===void 0)throw Error(`<wui-chat ${e}> must be one of ${Object.keys(t).join(`, `)}, got "${n}".`);return i}}function R9(e,t){return n=>{let r=Number(n),i=t===void 0?`of pixels`:`from 0 to ${t}`;if(!Number.isInteger(r)||r<0||t!==void 0&&r>t)throw Error(`<wui-chat ${e}> must be a whole number ${i}, got "${n}".`);return r}}function z9(e){return t=>{if(t===``||t===`true`)return!0;if(t===`false`)return!1;throw Error(`<wui-chat ${e}> must be true or false, got "${t}".`)}}var B9=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),V9=[[`launcher-style`,`launcher`,`style`,L9(`launcher-style`,{round:`Round`,pill:`Pill`,expanding:`Expanding`})],[`entrance`,`launcher`,`entrance`,L9(`entrance`,{"slide-up":`SlideUp`,"bounce-in":`BounceIn`,"fade-in-pulse":`FadeInPulse`,"spin-scale":`SpinScale`,"wiggle-in":`WiggleIn`,"elastic-in":`ElasticIn`,rise:`Rise`,none:`None`})],[`idle`,`launcher`,`idle`,L9(`idle`,{"float-and-pulse":`FloatAndPulse`,ring:`Ring`,none:`None`})],[`label-reveal`,`launcher`,`labelReveal`,L9(`label-reveal`,{bubble:`Bubble`,expand:`Expand`})],[`compact`,`launcher`,`compact`,z9(`compact`)],[`launcher-mark`,`launcher`,`mark`,L9(`launcher-mark`,{icon:`Icon`,avatar:`Avatar`,orb:`Orb`})],[`panel-height`,`panel`,`height`,L9(`panel-height`,{fixed:`Fixed`,content:`Content`})],[`panel-placement`,`panel`,`placement`,L9(`panel-placement`,{floating:`Floating`,side:`Side`})],[`reply-avatars`,`panel`,`replyAvatars`,L9(`reply-avatars`,{none:`None`,first:`First`,every:`Every`})],[`greeting-loader-ms`,`panel`,`greetingLoaderMs`,R9(`greeting-loader-ms`)],[`panel-motion`,`panel`,`motion`,L9(`panel-motion`,{spring:`Spring`,gentle:`Gentle`,none:`None`})],[`panel-width`,`panel`,`widthPx`,R9(`panel-width`)],[`panel-max-height`,`panel`,`maxHeightPx`,R9(`panel-max-height`)],[`panel-bottom-gap`,`panel`,`bottomGapPx`,R9(`panel-bottom-gap`)],[`phone-max-width`,`phone`,`maxWidthPx`,R9(`phone-max-width`)],[`phone-mode`,`phone`,`mode`,L9(`phone-mode`,{"full-screen":`FullScreen`,sheet:`Sheet`})],[`sheet-height-dvh`,`phone`,`sheetHeightDvh`,R9(`sheet-height-dvh`)],[`sheet-max-height`,`phone`,`sheetMaxHeightPx`,R9(`sheet-max-height`)],[`phone-hide-launcher`,`phone`,`hideLauncher`,z9(`phone-hide-launcher`)],[`input-ring`,`input`,`ring`,z9(`input-ring`)],[`send-reveal`,`input`,`sendReveal`,L9(`send-reveal`,{"on-text":`OnText`,always:`Always`})],[`send-icon`,`input`,`sendIcon`,e=>e],[`input-mark`,`input`,`mark`,L9(`input-mark`,{none:`None`,avatar:`Avatar`})],[`footer-layout`,`footer`,`layout`,L9(`footer-layout`,{stacked:`Stacked`,inline:`Inline`})],[`input-edge`,`input`,`edge`,L9(`input-edge`,{none:`None`,gradient:`Gradient`})],[`input-placeholder`,`input`,`placeholder`,L9(`input-placeholder`,{plain:`Plain`,gradient:`Gradient`})],[`input-busy-edge`,`input`,`busyEdge`,L9(`input-busy-edge`,{off:`Off`,sweep:`Sweep`})],[`starters-style`,`starters`,`style`,L9(`starters-style`,{chips:`Chips`,rows:`Rows`})],[`recent-rows`,`starters`,`recentRows`,R9(`recent-rows`,5)],[`footer-disclaimer`,`footer`,`disclaimer`,L9(`footer-disclaimer`,{show:`Show`,hide:`Hide`})],[`lift-selectors`,`avoid`,`liftSelectors`,B9],[`menu-selectors`,`avoid`,`menuSelectors`,B9],[`dark-selectors`,`avoid`,`darkSelectors`,B9],[`autoopen-busy-selectors`,`avoid`,`autoOpenBusySelectors`,B9],[`autoopen-optout-selector`,`avoid`,`autoOpenOptOutSelector`,e=>e]],H9={layout:`launcher`,position:`end`,"offset-x":`24`,"offset-y":`24`,loader:`steps`,motion:`on`,icon:`chat`},U9=[`base`,`layout`,`position`,`offset-x`,`offset-y`,`loader`,`screen`,`motion`,`theme`,`icon`,`avatar`,`avatar-motion`,`narrow`,...V9.map(([e])=>e).filter(e=>e!==`compact`)],W9=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase());function G9(e){let t={launcher:{},panel:{},phone:{},input:{},avoid:{},footer:{},starters:{}};for(let[n,r,i,a]of V9){let o=e.getAttribute(n);o!=null&&(t[r][i]=a(o))}let n=e.getAttribute(`motion`),r=e.getAttribute(`avatar`),i=e.getAttribute(`avatar-motion`),a=e.getAttribute(`expressive`);return Fr({...t,...n==null?{}:{motion:L9(`motion`,rre)(n)},...r?{avatar:r}:{},...i==null?{}:{avatarMotion:L9(`avatar-motion`,ire)(i)},...a==null?{}:{expressive:z9(`expressive`)(a)}})}function pre(e){let t=e.getAttribute(`loader`)??`steps`,n=Q4(P9,t)?P9[t]:void 0;if(n===void 0)throw Error(`<wui-chat loader> must be one of ${Object.keys(P9).join(`, `)}, got "${t}".`);return n}function mre(e){let t=e.getAttribute(`narrow`);if(t!=null&&t!==``)return Object.fromEntries(B9(t).map(e=>[e,!1]))}function K9(e){return e===sre?globalThis.localStorage:globalThis.sessionStorage}var q9={get:e=>K9(e).getItem(e),set:(e,t)=>K9(e).setItem(e,t)};function J9(e){return globalThis.innerWidth<=e.phone.maxWidthPx}function hre(e){let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}function gre(e){return e.features.HumanHandoff===!0&&e.conversationState===`Open`&&e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`)&&!e.streaming&&!e.thinking}function _re(e,t){if(e.conversationState===`WaitingForAgent`)return t.statusWaitingForAgent;if(e.conversationState===`WithAgent`){let n=e.agent?.displayName;return t.statusWithAgent(typeof n==`string`&&n.trim()!==``?n:t.handoffAgentFallback)}return t.headerStatus}function Y9(e,t,n){return t.PanelSwitch!==!0||typeof n!=`function`?null:e===`docked`?`full-page`:e===`full-page`?`docked`:null}function vre(e){if(!M9.some(t=>t===e))throw Error(`<wui-chat layout> must be one of ${M9.join(`, `)}, got "${e}".`)}function X9(e){if(!N9.some(t=>t===e))throw Error(`<wui-chat position> must be one of ${N9.join(`, `)}, got "${e}".`)}function yre(e,t){let n=e[t];delete e[t],e[t]=n}function bre(e){return e==null?{}:Object(e)}var Z9=0,Q9=class extends qo{static get observedAttributes(){return[...U9,`compact`,`expressive`,`open`,`labels`,`page-context`,`narrow`].filter((e,t,n)=>n.indexOf(e)===t)}constructor(){super(),Z9+=1,this._uid=`wui-chat-${Z9}`,this._built=!1,this._session=null,this._unsubscribe=null,this._voice=null,this._voiceConversationId=void 0,this._labelsProp=void 0,this._pageContextProp=void 0,this._layoutParts=null,this._renderers={...F9},this._rendererApi={define:(e,t)=>{I9(e,t),this._renderers[e]=t,this._render()},map:this._renderers},this._captchaToken=null,this._attribution=null,this._openAttachmentProp=null,this._openCitationProp=null,this._openTargetProp=null,this._resolveLinkProp=null,this._openTicketProp=void 0,this._emptyContentProp=null,this._onPanelSwitchProp=null,this._preloadPanelSwitchProp=null,this._preloaded=!1,this._pastList=null,this._past=null,this._pastRefreshed=!1,this._historyShown=!1,this._openedConversation=null,this._lastOpen=!1,this._openTrigger=`manual`,this._focusTimer=null,this._nudgeArmed=!1,this._seeded=!1,this._wasLoading=!1,this._seen=new Set,this._sound=null,this._behaviour=null,this._autoOpen=null,this._avoid=null,this._motion=null,this._phone=null,this._requesting=!1,this._onKeyDown=e=>{e.key===`Escape`&&this._session?.getState().open&&(e.stopPropagation(),this._session.close(`escape`))}}get session(){return this._session??null}get conversationId(){return this._session?.getState().conversationId??null}get labels(){return Ae({...bre(r3(this,`labels`)),...this._labelsProp})}set labels(e){this._labelsProp=e??void 0,this._render()}get pageContext(){return this._pageContextProp===void 0?r3(this,`page-context`):this._pageContextProp}set pageContext(e){this._pageContextProp=e===null?void 0:e}get compact(){let e=this.getAttribute(`compact`);return e!=null&&z9(`compact`)(e)}set compact(e){this.toggleAttribute(`compact`,e===!0||e===``||e===`true`)}get expressive(){let e=this.getAttribute(`expressive`);return e!=null&&z9(`expressive`)(e)}set expressive(e){this.toggleAttribute(`expressive`,e===!0||e===``||e===`true`)}get open(){return this.hasAttribute(`open`)}set open(e){this.toggleAttribute(`open`,e===!0||e===``||e===`true`)}get renderers(){return this._rendererApi}get layoutParts(){return this._layoutParts}set layoutParts(e){this._layoutParts=typeof e==`function`?e:null,this._render()}get getCaptchaToken(){return this._captchaToken}set getCaptchaToken(e){this._captchaToken=typeof e==`function`?e:null}get attribution(){return this._attribution}set attribution(e){this._attribution=typeof e==`function`?e:null}get openAttachment(){return this._openAttachmentProp??(e=>this._defaultOpenAttachment(e))}set openAttachment(e){this._openAttachmentProp=typeof e==`function`?e:null}get openCitation(){return this._openCitationProp??((e,t)=>this._defaultOpenCitation(e,t))}set openCitation(e){this._openCitationProp=typeof e==`function`?e:null}get openTarget(){return this._openTargetProp??(e=>this._defaultOpenTarget(e))}set openTarget(e){this._openTargetProp=typeof e==`function`?e:null}get openTicket(){return this._openTicketProp}set openTicket(e){this._openTicketProp=typeof e==`function`?e:void 0}get onNavigate(){return this._onNavigateProp}set onNavigate(e){this._onNavigateProp=typeof e==`function`?e:void 0}get resolveLink(){return this._resolveLinkProp}set resolveLink(e){this._resolveLinkProp=typeof e==`function`?e:null}get emptyContent(){return this._emptyContentProp}set emptyContent(e){if(e!==null&&!(e instanceof Node))throw TypeError(`emptyContent must be a Node or null`);this._emptyContentProp=e,this._applyEmptyContent()}get onPanelSwitch(){return this._onPanelSwitchProp}set onPanelSwitch(e){this._onPanelSwitchProp=typeof e==`function`?e:null}get preloadPanelSwitch(){return this._preloadPanelSwitchProp}set preloadPanelSwitch(e){this._preloadPanelSwitchProp=typeof e==`function`?e:null}connectedCallback(){this._adoptEarlyProperties();let e=this._assertLayout();if(this._assertPosition(),this.base.trim()===``)throw TypeError(`<wui-chat> needs a base path, e.g. base="/api/assistant".`);this._built||this._build(),this._shell||this._buildShell(e),this._session||this._createSession(),this._past||this._createPast(),this._unsubscribe||=this.requireSession().subscribe(()=>this._render()),this._render()}_adoptEarlyProperties(){for(let e of dre)Q4(this,e)&&yre(this,e)}disconnectedCallback(){this._voice?.stop(),this._session?.stop(),this._unsubscribe?.(),this._unsubscribe=null,this._disposePast(),this._shell?.destroy?.(),document.removeEventListener(`keydown`,this._onKeyDown),this._avoid?.destroy(),this._avoid=null,this._autoOpen?.cancel(),this._autoOpen=null,this._motion?.destroy(),this._motion=null}attributeChangedCallback(e,t,n){if(this._built&&t!==n){if(e===`layout`)this._buildShell(this._assertLayout());else if(e===`position`)this._assertPosition();else if(e===`base`||e===`screen`||e===`narrow`)this._resetSession();else if(e===`motion`)this._motion?.destroy(),this._motion=null;else if(e===`open`&&this._session){let e=this._session.getState().open;this.open!==e&&this._setOpen(this.open,`manual`)}this._render()}}toggle(){this._session&&(this._session.getState().open?this._session.close(`button`):this._setOpen(!0,`manual`))}close(){this._voice?.stop(),this._session?.close(`button`)}newConversation(){this._voice?.stop(),this._session?.newConversation(),this._past?.refresh()}reset(){this._voice?.stop(),this._session?.reset()}_setOpen(e,t){this._session&&(e?(this._openTrigger=t,this._session.open({trigger:t})):this._session.close(`button`))}_assertLayout(){let e=this.layout;return vre(e),e}_assertPosition(){X9(this.position)}get _position(){let e=this.position;return X9(e),e}_isLauncherLike(){return this.layout===`launcher`||this.layout===`docked`}requireSession(){if(!this._session)throw TypeError(`wui-chat: _session is not ready; the element is not connected`);return this._session}requireVoice(){if(!this._voice)throw TypeError(`wui-chat: _voice is not ready; the element is not connected`);return this._voice}requireMotion(){if(!this._motion)throw TypeError(`wui-chat: _motion is not ready; the element is not connected`);return this._motion}requirePastList(){if(!this._pastList)throw TypeError(`wui-chat: _pastList is not ready; the element is not connected`);return this._pastList}requireNudgeHost(){if(!this._shell.nudgeHost)throw TypeError(`wui-chat: the launcher shell has no nudge host`);return this._shell.nudgeHost}_build(){this._built=!0,this._markMaker=s3(a3(this)),this._header=h7({onNew:()=>this.newConversation(),onHistory:()=>this._toggleHistory(),onClose:()=>this.close(),onMute:()=>{this._session&&this._session.setMuted(!this._session.getState().muted)},onSwitch:()=>this._switchPanel(),titleId:`${this._uid}-title`,mark:this._markMaker}),this._starters=Ute({mark:this._markMaker,onStarter:e=>this.requireSession().submit(e.message),onResume:()=>this.requireSession().resumeLast(),onTicket:e=>{typeof this.openTicket==`function`&&this.openTicket({ticketId:e.ticketId,number:e.number})},onOpenConversation:e=>{Promise.allSettled([this.requireSession().openConversation(e)])}}),this._applyEmptyContent(),this._voice=t7({getState:()=>this.requireSession().getState(),getToken:()=>this.requireSession().client.getSpeechToken()}),this._voice.subscribe(()=>this._render()),this._thread=gne({mark:this._markMaker,getRenderers:()=>this._renderers,getLayoutParts:()=>this._layoutParts,makeTurnApi:e=>this._makeTurnApi(e),onRetry:()=>this.requireSession().retry(),onRegenerate:()=>this.requireSession().regenerate(),onRate:(e,t)=>this.requireSession().rate(e,t),getSession:()=>this.requireSession(),getVoice:()=>this._voice}),this._composer=l7({mark:this._markMaker,voice:this._voice,onSubmit:e=>this.requireSession().submit(e),onStop:()=>this.requireSession().stop(),onAttach:e=>this.requireSession().attach(e),onRemove:e=>this.requireSession().removeAttachment(e),onCancelEdit:()=>this.requireSession().cancelEdit(),onTyping:()=>this.requireSession().notifyTyping(),onDraftApplied:()=>this.requireSession().consumeDraft()}),this._footer=p7(),this._history=v7({getClient:()=>this.requireSession().client,getLabels:()=>this.labels,getFeatures:()=>this.requireSession().getState().features,onOpen:e=>{Promise.allSettled([this.requireSession().openConversation(e)]),this._toggleHistory(!1)},onDeleted:e=>{e===this.conversationId&&this.requireSession().newConversation()}}),this._nudge=w7({onActivate:()=>this._setOpen(!0,`manual`),onDismiss:()=>{}}),this._status=$(`p`,null,{role:`status`}),this._status.hidden=!0,this._errorEl=$(`p`,`wui-chat-profile-error`,{role:`alert`}),this._errorEl.hidden=!0,this._liveStatus=$(`p`,`wui-chat-live-status`,{role:`status`}),this._liveStatus.hidden=!0,this._talk=$(`button`,`${e3(`outline`,`sm`)} wui-chat-handoff-request`,{type:`button`}),this._talk.addEventListener(`click`,()=>this._requestHandoff()),this._liveRetry=$(`button`,e3(`ghost`,`sm`),{type:`button`}),this._liveRetry.addEventListener(`click`,()=>this.requireSession().resumeLive()),this._liveError=$(`p`,`wui-chat-live-error`,{role:`alert`}),this._liveError.hidden=!0,this._live=$(`div`,`wui-chat-live`),this._live.append(this._liveStatus,this._talk,this._liveRetry,this._liveError),this._live.hidden=!0,this._body=$(`div`,`wui-chat-body`),this._body.append(this._starters.el,this._thread.el,this._live,this._history.el,this._status,this._errorEl),this._foot=$(`div`,`wui-chat-foot`),this._foot.append(...this._composer.nodes,this._footer.el)}_buildShell(e){let t={launcher:Lte,docked:Nte,"full-page":Rte,embedded:Pte};this._shell?.destroy?.(),this._avoid?.destroy(),this._avoid=null,this._autoOpen?.cancel(),this._autoOpen=null,this._lastOpen=!1,this._launcherPlayed=this.querySelector(`:scope > [data-wui-chat-placeholder]`)!==null;let n=t[e]({mark:this._markMaker,id:`${this._uid}-panel`,position:this._position,onToggle:()=>this.toggle()});n.panel.append(this._header.el,this._body,this._foot),n.panel.setAttribute(`aria-labelledby`,`${this._uid}-title`),n.panel.addEventListener(`keydown`,e=>{e.key===`Tab`&&Hne(n.panel,e)}),n.nudgeHost&&n.nudgeHost.prepend(this._nudge.el),this._shell=n,this.replaceChildren(n.root)}_createSession(){let e=Wt(C7(),{base:this.base}),t=mre(this);this._session=ii(e,{...this.screen?{screen:this.screen}:{},...t===void 0?{}:{narrow:t},recentConversations:G9(this).starters.recentRows,pageContext:()=>this.pageContext,attribution:()=>this._attribution?.()??null,behaviour:()=>this._session?.getState().features.BehaviourStarters?this._behaviour?.()??null:null,prefs:q9,reducedMotion:()=>this._motion?.reduced??!1,schedule:hre,getCaptchaToken:e=>{if(this._captchaToken)return this._captchaToken(e);let t=this._session?.getState().profile?.captcha?.siteKey;return t?j7(t,e):Promise.resolve(null)},onEvent:(e,t)=>{this.dispatchEvent(new CustomEvent(`wui-chat-event`,{bubbles:!0,detail:{name:e,data:t}}))},onError:()=>{},labels:this.labels}),this._unsubscribe=null,this._lastOpen=!1,this._openApplied=!1,this._seeded=!1,this._wasLoading=!1,this._seen=new Set,this._pastRefreshed=!1}_createPast(){this._pastList=qt({client:this.requireSession().client,pageSize:20}),this._past=E7({list:this._pastList,getLabels:()=>this.labels,getFeatures:()=>this.requireSession().getState().features,onOpen:e=>{Promise.allSettled([this.requireSession().openConversation(e)])}}),this._starters.pastHost.append(this._past.el)}_disposePast(){this._past&&(this._past.el.remove(),this._past.dispose(),this.requirePastList().dispose(),this._past=null,this._pastList=null)}_applyEmptyContent(){if(!this._starters)return;let e=this._starters.extraHost;e.replaceChildren(...this._emptyContentProp?[this._emptyContentProp]:[]),e.hidden=!this._emptyContentProp}_switchPanel(){let e=this.requireSession().getState(),t=this._onPanelSwitchProp,n=Y9(this.layout,e.features,t);if(t===null||n===null)return;n===`full-page`&&this.close();let r={from:this.layout,to:n,conversationId:e.conversationId,draft:this._composer.getDraft()};$ne(()=>t.call(this,r),{target:n,reduced:this._motion?.reduced===!0}).then(()=>document.querySelector(`.wui-chat--${n} .wui-chat-input`)?.focus()).catch(e=>globalThis.reportError?.(e))}async _requestHandoff(){this._requesting=!0,this._liveError.hidden=!0,this._render();try{await this.requireSession().requestHandoff()}catch(e){let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;this._liveError.textContent=typeof t==`string`&&t||this.labels.errorGeneric,this._liveError.hidden=!1}finally{this._requesting=!1,this._render()}}_paintLive(e,t,n){let r=e.live===`Lost`,i=gre(e);this._liveStatus.hidden=!r,this._liveStatus.textContent=r?t.liveLost:``,this._liveRetry.hidden=!r,this._liveRetry.textContent=t.retry,this._talk.hidden=!i,this._talk.textContent=t.talkToPerson,this._talk.disabled=this._requesting,this._live.hidden=n||!r&&!i}_resetSession(){this._voice?.stop(),this._unsubscribe?.(),this._unsubscribe=null,this._session?.dispose(),this._session=null,this._disposePast(),this._history.dispose(),this.isConnected&&(this._createSession(),this._createPast(),this._unsubscribe=this.requireSession().subscribe(()=>this._render()))}_toggleHistory(e=!this._historyShown){this._historyShown=e,e?this._history.show():this._history.hide(),this._render()}_makeTurnApi(e){let t=oi(this.requireSession(),{messageId:e,labels:this.labels,openAttachment:e=>this.openAttachment(e),openCitation:t=>this.openCitation(e,t),openTarget:e=>this.openTarget(e),openTicket:this.openTicket,onNavigate:this.onNavigate});return t.resolveLink=this.resolveLink,t}_defaultOpenAttachment(e){this.requireSession().client.getAttachment(e.attachmentId).then(t=>{let n=URL.createObjectURL(new Blob([t],{type:e.contentType}));window.open(n,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(n),lre)}).catch(e=>globalThis.reportError?.(e))}_defaultOpenCitation(e,t){let n=this._thread.find(e);if(n){for(let e of n.querySelectorAll(`[data-marker]`))if(e.dataset.marker===String(t)){e.focus();return}}}_defaultOpenTarget(e){/^https?:\/\//i.test(e)?window.open(e,`_blank`,`noopener`):window.location.assign(e)}_render(){this._built&&this._session&&this._paint(this._session.getState())}_paint(e){this._shell.root.toggleAttribute(`data-busy`,e.streaming||e.thinking),e.conversationId!==this._voiceConversationId&&(this._voiceConversationId=e.conversationId,this.requireVoice().stop());let t=this.labels,n=e.profile,r=this._isLauncherLike();if(!n){this.hidden=r,this._header.el.hidden=!0,this._starters.el.hidden=!0,this._thread.el.hidden=!0,this._history.el.hidden=!0,this._foot.hidden=!0,this._errorEl.hidden=e.profileError==null,e.profileError&&(this._errorEl.textContent=e.profileError.message),this._status.hidden=e.profileError!=null,this._status.textContent=t.loadingConversation,this._shell.panel.setAttribute(`aria-busy`,String(e.profileError==null));return}if(this._shell.panel.removeAttribute(`aria-busy`),!e.features.VisitorChat){this.hidden=!0,this._status.hidden=!0;return}this.hidden=!1;let i=e.features,a=G9(this);this._ensureRuntime(e,n,a,t);let o=e.loading,s=e.loadError,c=e.messages.length===0&&!o,l=this._historyShown&&i.History===!0,u=e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`),d=Y9(this.layout,i,this._onPanelSwitchProp),f=e.streaming||e.thinking;this._header.paint({labels:t,title:t.panelTitle||n.assistant.name||t.assistant,tagline:n.assistant.tagline,status:_re(e,t),canNew:!f,showNew:this.layout===`full-page`||u,showHistory:i.History,showClose:r||this.layout===`full-page`&&d!==null,switchTo:d,canSwitch:!f,viewingHistory:l,showMute:i.Sounds&&n.experience.sound.muteControl,muted:e.muted}),Dte(this._header.conversation,e,{labels:t,features:i,title:n.assistant.name||t.assistant,getState:()=>this.requireSession().getState(),iconOnly:!0}),l&&(this._header.conversation.hidden=!0),this._starters.el.hidden=!c||l,c&&e.open&&!this._introPlayed&&a.panel.greetingLoaderMs>0&&!this.requireMotion().reduced&&(this._introPlayed=!0,this._starters.intro(a.panel.greetingLoaderMs)),c&&this._starters.paint({labels:t,greeting:e.greeting,intro:n.assistant.intro,starters:e.starters,showStarters:i.Starters&&!e.streaming,resume:!i.History&&i.ResumeLast?e.lastConversation:null,recent:e.recentConversations,openTickets:e.openTickets,features:e.features,ticketsClickable:typeof this.openTicket==`function`}),i.History&&!this._pastRefreshed&&(this._pastRefreshed=!0,this._past?.refresh()),this._past?.paint(),this._starters.pastHost.hidden=e.recentConversations.length>0;let p=!c&&!o&&!s&&!l;this._thread.el.hidden=!p,p&&this._thread.paint(e,{labels:t,loaderStyle:pre(this),reduced:this._motion?.reduced??!1,phrases:n.experience.pacing.thinkingPhrases,intervalMs:n.experience.pacing.phraseIntervalMs,assistantName:n.assistant.name,replyAvatars:a.panel.replyAvatars}),this._paintLive(e,t,l),this._status.hidden=!o||l,this._status.textContent=t.loadingConversation,this._errorEl.hidden=!s||l,s&&(this._errorEl.textContent=s.message),this._foot.hidden=l,this._composer.paint({state:e,labels:t,maxLength:n.limits.maxMessageLength,accept:n.limits.contentTypes.join(`,`),draft:e.draft??null,sendIcon:a.input.sendIcon,inputMark:a.input.mark,busy:e.streaming||e.thinking}),this._footer.paint({labels:t,profile:n,hideDisclaimer:a.footer.disclaimer===`Hide`}),this._history.el.hidden=!l,this._syncOpen(e,n,i,t,r),this._syncConversation(e),this._playSounds(e)}_ensureRuntime(e,t,n,r){let i=e.features;this._motion||(this._motion=Y4(n,t.experience),this._motion.subscribe(()=>this._render())),i.Sounds&&!this._sound&&(this._sound=Jne(t.experience.sound,q9)),!i.Sounds&&this._sound&&(this._sound=null),i.BehaviourStarters&&!this._behaviour&&(this._behaviour=Lne(t.start.behaviour?.servicePathPrefixes??[]));let a=this._isLauncherLike();a&&!this._avoid&&this.layout===`launcher`&&(this._avoid=Fne(n.avoid,t.experience.launcher,this.requireNudgeHost(),this._shell.setLauncherState)),this.layout===`launcher`&&i.AutoOpen&&!this._autoOpen&&(this._autoOpen=wne(t.experience.autoOpen,n,{open:()=>this._setOpen(!0,`auto`),isOpen:()=>this.requireSession().getState().open,panelRect:()=>this._shell.panel.getBoundingClientRect()}));let o=J9(n);this._shell.setLabels(r),this._shell.setAppearance({position:this._position,offsetX:this.hasAttribute(`offset-x`)?R9(`offset-x`)(this.getAttribute(`offset-x`)??``):void 0,offsetY:this.hasAttribute(`offset-y`)?R9(`offset-y`)(this.getAttribute(`offset-y`)??``):void 0,width:`${n.panel.widthPx}px`,maxHeight:n.panel.maxHeightPx,bottomGap:n.panel.bottomGapPx,reduced:this._motion.reduced,sendReveal:n.input.sendReveal,inputRing:n.input.ring,panelMotion:n.panel.motion,theme:ore(this.getAttribute(`theme`)),icon:this.icon,launcherStyle:n.launcher.style,compact:n.launcher.compact,labelReveal:n.launcher.labelReveal,entrance:n.launcher.entrance,idle:n.launcher.idle,launcherMark:n.launcher.mark,panelHeight:n.panel.height,panelPlacement:n.panel.placement,inputMark:n.input.mark,inputEdge:n.input.edge,inputBusyEdge:n.input.busyEdge,inputPlaceholder:n.input.placeholder,phoneHideLauncher:n.phone.hideLauncher,replyAvatars:n.panel.replyAvatars,footerLayout:n.footer.layout,startersStyle:n.starters.style,avatar:n.avatar,avatarMotion:n.avatarMotion,expressive:n.expressive,phone:o,hoverLabel:t.experience.launcher.hoverLabel,peek:t.experience.launcher.peek,peekSeconds:t.experience.launcher.peekSeconds,hideWhileOpen:t.experience.launcher.hideWhileOpen,phoneMode:n.phone.mode,sheetHeightDvh:n.phone.sheetHeightDvh,sheetMaxHeightPx:n.phone.sheetMaxHeightPx,launcherState:this._launcherPlayed?void 0:`entering`}),this._launcherPlayed=!0,this._shell.root.classList.toggle(`wui-chat--phone`,a&&J9(n))}_syncOpen(e,t,n,r,i){if(i){if(!this._openApplied&&(this._openApplied=!0,this.hasAttribute(`open`)&&!e.open))this._setOpen(!0,`manual`);else if(this._shell.setOpen(e.open),this.toggleAttribute(`open`,e.open),e.open!==this._lastOpen&&(this._lastOpen=e.open,q9.set(cre,e.open?`1`:`0`),this._onOpenChange(e.open)),e.open)this._nudge.cancel(),this._nudgeArmed=!1,this._autoOpen?.cancel();else if(n.Nudges&&this.layout===`launcher`&&!this._nudgeArmed){let e=Ie(t,n);e&&(this._nudge.schedule({text:e.text,delaySeconds:e.delaySeconds,label:r.nudgeDismiss}),this._nudgeArmed=!0)}}}_onOpenChange(e){let t=J9(G9(this));if(e){if(document.addEventListener(`keydown`,this._onKeyDown),this._sound?.play(`open`),this._past?.refresh(),this.layout===`docked`&&!this._preloaded&&typeof this._preloadPanelSwitchProp==`function`){this._preloaded=!0;let e=this._preloadPanelSwitchProp;Promise.allSettled([new Promise(t=>t(e.call(this)))]).then(e=>{for(let t of e)t.status===`rejected`&&globalThis.reportError?.(t.reason)})}if(t){let e=G9(this);this._phone={fit:nre(this._shell.panel,e),unlock:Gne(this._thread.el)}}else this._openTrigger===`manual`&&(this._focusTimer=setTimeout(()=>{this._focusTimer=null,this._composer.focus()},ure))}else document.removeEventListener(`keydown`,this._onKeyDown),clearTimeout(this._focusTimer??void 0),this._focusTimer=null,this._phone?.fit.destroy(),this._phone?.unlock(),this._phone=null,this._historyShown&&(this._historyShown=!1,this._history.hide(),this._render()),Une(this._shell.launcherButton)}_syncConversation(e){let t=this.getAttribute(`conversation-id`);t&&t!==this._openedConversation&&!e.loading&&(this._openedConversation=t,e.conversationId!==t&&Promise.allSettled([this.requireSession().openConversation(t)]))}_playSounds(e){if(e.loading){this._wasLoading=!0;for(let t of e.messages)this._seen.add(t.id)}else if(this._wasLoading||!this._seeded){this._wasLoading=!1,this._seeded=!0;for(let t of e.messages)this._seen.add(t.id)}else for(let t of e.messages)this._seen.has(t.id)||(this._seen.add(t.id),this._announce(t))}_announce(e){if(!this._sound||e.restored||e.parts.some(e=>e.kind===`Notice`))return;let t=e.author.kind;if(t===`Visitor`)e.stored||this._sound.play(`sent`);else if(t===`Assistant`||t===`Script`||t===`Agent`){this._sound.play(`reply`);let e=this.requireSession().getState().profile;e?.experience.sound.vibrate&&Wne(e.experience.sound.vibrateMs,this._sound.isMuted())}}};Object.defineProperty(Q9.prototype,"layout",{get(){return this.getAttribute(`layout`)??H9.layout},set(e){this.setAttribute(`layout`,String(e))}});for(let e of U9)e!==`layout`&&Object.defineProperty(Q9.prototype,W9(e),{configurable:!0,get(){return this.getAttribute(e)??H9[e]??``},set(t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}});function $9(){typeof customElements<`u`&&!customElements.get(`wui-chat`)&&customElements.define(`wui-chat`,Q9)}$9(),$9(),globalThis.WeborityChat=Object.assign(globalThis.WeborityChat||{},{session:e=>e.session,renderers:{define:fre},createExplainPopover:Bne})})();
|