@xpert-ai/chatkit-powerpoint-addin 0.12.1 → 0.12.2
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.
|
@@ -51,7 +51,7 @@ Error generating stack: `+n.message+`
|
|
|
51
51
|
@keyframes chatkit-pet-summary-spin {
|
|
52
52
|
to { transform: rotate(360deg); }
|
|
53
53
|
}
|
|
54
|
-
`;const c=document.createElement("div");c.setAttribute("data-chatkit-host-pet",""),c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.pointerEvents="auto",c.style.touchAction="none",c.style.userSelect="none",c.style.willChange="transform",c.addEventListener("pointerenter",this.handlePointerEnter),c.addEventListener("pointerleave",this.handlePointerLeave),c.addEventListener("pointerdown",this.handlePointerDown),c.addEventListener("lostpointercapture",this.handleLostPointerCapture),c.addEventListener("contextmenu",this.handleContextMenu),c.addEventListener("click",this.handleClick),u.append(s,c),this.root.append(u),this.overlayElement=u,this.petElement=c}removeOverlay(){var u;this.cancelActiveDrag(),this.clearRestingDelayTimer(),this.clearTimers(),this.closeContextMenu(),this.petElement&&(this.petElement.removeEventListener("pointerenter",this.handlePointerEnter),this.petElement.removeEventListener("pointerleave",this.handlePointerLeave),this.petElement.removeEventListener("pointerdown",this.handlePointerDown),this.petElement.removeEventListener("lostpointercapture",this.handleLostPointerCapture),this.petElement.removeEventListener("contextmenu",this.handleContextMenu),this.petElement.removeEventListener("click",this.handleClick)),this.isHovering=!1,this.removeSummaryElements(),(u=this.overlayElement)==null||u.remove(),this.overlayElement=null,this.petElement=null,this.mediaElement=null}removeSummaryElements(){var u,s;(u=this.summaryElement)==null||u.remove(),(s=this.summaryToggleElement)==null||s.remove(),this.summaryElement=null,this.summaryToggleElement=null,this.replyInputElement=null,this.summaryRenderKey=null}getSize(){if(!this.options||!this.resolved)return{width:0,height:0};const u=rm(this.options.position.scale),s={width:this.resolved.atlas.cellWidth,height:this.resolved.atlas.cellHeight};return{width:s.width*u,height:s.height*u}}getCurrentPosition(u){const s=this.options;if(!s)return{x:0,y:0};const c=na(),r=Tf(s.position.boundsPadding),d=s.position.pin===void 0?"bottom-right":s.position.pin,y=d?_0(d,u,c,r):null;return Ne(this.dragPosition??this.position??y??{x:r.left,y:r.top},u,c,r)}persistPosition(u){if(!this.options)return;const s=this.getSize(),c=Ne(u,s,na(),Tf(this.options.position.boundsPadding));this.position=c,w0(sm,this.options.position.persist,c)}getActiveAnimationName(){return this.options?this.isDragging?this.dragAnimation??"running":this.transient?this.transient.name:this.options.behavior==="manual"?"idle":this.currentState:"idle"}getActiveAnimationMode(){return this.isDragging?"loop":this.transient?"once":"loop"}resetAnimationIfNeeded(u,s){this.activeAnimationName===u&&this.activeAnimationMode===s||(this.clearTimers(),this.activeAnimationName=u,this.activeAnimationMode=s,this.frame=0,this.completed=!1)}render(){if(!this.options||!this.resolved){this.clearTimers(),this.petElement&&this.petElement.replaceChildren(),this.removeSummaryElements(),this.mediaElement=null,this.activeAnimationName=null,this.activeAnimationMode=null,this.frame=0,this.completed=!1;return}this.ensureOverlay();const u=this.overlayElement,s=this.petElement;if(!u||!s)return;const c=this.getSize(),r=this.getCurrentPosition(c),d=this.getActiveAnimationName(),y=this.getActiveAnimationMode();this.resetAnimationIfNeeded(d,y),u.style.zIndex=String(this.options.position.zIndex),s.style.width=`${c.width}px`,s.style.height=`${c.height}px`,s.style.transform=`translate3d(${r.x}px, ${r.y}px, 0)`,s.style.cursor=this.options.position.draggable?this.isDragging?"grabbing":"grab":"default",s.dataset.petAnimation=d,s.setAttribute("aria-label",this.options.ariaLabel),s.setAttribute("role","img"),this.renderAtlas(d,y),this.renderThreadSummary(r,c),this.scheduleNextFrame(d,y)}renderThreadSummary(u,s){var y,v,E;const c=this.summary,r=dm(c);if(!c||!r||this.dismissedSummaryKey===r){this.removeSummaryElements();return}if(this.isSummaryCollapsed){this.renderCollapsedSummary(u,s);return}const d=[this.copyLocale,this.isSummaryExpanded?"expanded":"compact",this.isSummaryHovering?"hover":"rest",this.isReplyOpen?"reply":"closed",this.isReplySubmitting?"submitting":"ready",this.replyError??""].join("|");(!this.summaryElement||this.summaryRenderKey!==d)&&((y=this.summaryElement)==null||y.remove(),(v=this.summaryToggleElement)==null||v.remove(),this.summaryElement=this.createSummaryBubble(c),this.summaryToggleElement=this.createSummaryToggleButton("v"),(E=this.overlayElement)==null||E.append(this.summaryElement,this.summaryToggleElement),this.summaryRenderKey=d,this.isReplyOpen&&!this.isReplySubmitting&&window.setTimeout(()=>{var S;return(S=this.replyInputElement)==null?void 0:S.focus()},0)),this.updateSummaryBubbleContent(c),this.positionSummaryBubble(u,s)}renderCollapsedSummary(u,s){var c,r;(c=this.summaryElement)==null||c.remove(),this.summaryElement=null,this.summaryRenderKey=null,this.summaryToggleElement||(this.summaryToggleElement=this.createSummaryToggleButton("1"),(r=this.overlayElement)==null||r.append(this.summaryToggleElement)),this.summaryToggleElement.textContent="1",this.positionSummaryToggleBadge(u,s)}positionSummaryToggleBadge(u,s){const c=this.summaryToggleElement;if(!c)return;const r=na(),d=ii(this.theme).toggleSize,y=Vl(u.x+s.width-d*.35,ke,r.width-d-ke),v=Vl(u.y-d*.35,ke,r.height-d-ke);c.style.width=`${d}px`,c.style.height=`${d}px`,c.style.transform=`translate3d(${y}px, ${v}px, 0)`,c.style.borderRadius="999px"}positionSummaryBubble(u,s){const c=this.summaryElement,r=this.summaryToggleElement;if(!c||!r)return;const d=na(),y=Math.min(x0,d.width-ke*2);c.style.width=`${y}px`;const v=c.offsetHeight||96,E=u.y-v-fm,N=E>=ke?E:Vl(u.y+s.height+fm,ke,d.height-v-ke),B=Vl(u.x+s.width/2-y/2,ke,d.width-y-ke);c.style.transform=`translate3d(${B}px, ${N}px, 0)`,this.positionSummaryToggleBadge(u,s)}createSummaryBubble(u){const s=this.isSummaryHovering&&!this.isReplyOpen,c=ii(this.theme),r=document.createElement("div");r.setAttribute("data-chatkit-pet-summary",""),r.addEventListener("pointerenter",this.handleSummaryPointerEnter),r.addEventListener("pointerleave",this.handleSummaryPointerLeave),r.addEventListener("click",this.handleSummaryClick),r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.boxSizing="border-box",r.style.pointerEvents="auto",r.style.padding=c.padding,r.style.border="1px solid rgba(148, 163, 184, 0.22)",r.style.borderRadius=`${c.radius}px`,r.style.background="rgba(255, 255, 255, 0.94)",r.style.color="#1f2937",r.style.boxShadow="0 8px 24px rgba(15, 23, 42, 0.1)",r.style.font=`500 ${c.bodySize}px/1.35 ${c.fontFamily}`,r.style.backdropFilter="blur(10px)";const d=document.createElement("div");d.style.display="flex",d.style.alignItems="center",d.style.gap=`${c.gap}px`,(this.isSummaryHovering||this.isReplyOpen)&&d.append(this.createSummaryActionButton("x",this.copy.hideMessage,this.handleSummaryDelete));const y=document.createElement("div");y.textContent=u.title,y.style.minWidth="0",y.style.flex="1",y.style.overflow="hidden",y.style.textOverflow="ellipsis",y.style.whiteSpace="nowrap",y.style.fontWeight="700",y.style.fontSize=`${c.titleSize}px`,y.dataset.chatkitPetSummaryTitle="",d.append(y),this.isSummaryHovering||this.isReplyOpen?d.append(this.createSummaryActionButton(this.isSummaryExpanded?"-":">",this.isSummaryExpanded?this.copy.collapseMessage:this.copy.expandMessage,this.handleSummaryExpandToggle)):d.append(this.createStatusIcon(u.status));const v=document.createElement("div");if(v.textContent=u.message,v.style.marginTop=`${c.marginTop}px`,v.style.fontWeight="400",v.style.color="#374151",v.style.overflow="hidden",this.isSummaryExpanded?(v.style.maxHeight="7em",v.style.overflowY="auto"):(v.style.display="-webkit-box",v.style.setProperty("-webkit-line-clamp","2"),v.style.setProperty("-webkit-box-orient","vertical")),v.dataset.chatkitPetSummaryMessage="",r.append(d,v),s){const E=this.createTextButton(this.copy.replyButton,this.handleReplyOpen);E.style.position="absolute",E.style.right="14px",E.style.bottom="10px",r.append(E)}return this.isReplyOpen&&r.append(this.createReplyForm()),r}updateSummaryBubbleContent(u){var d,y,v;const s=(d=this.summaryElement)==null?void 0:d.querySelector("[data-chatkit-pet-summary-title]");s&&s.textContent!==u.title&&(s.textContent=u.title);const c=(y=this.summaryElement)==null?void 0:y.querySelector("[data-chatkit-pet-summary-message]");c&&c.textContent!==u.message&&(c.textContent=u.message);const r=(v=this.summaryElement)==null?void 0:v.querySelector("[data-chatkit-pet-summary-status]");if(r&&r.dataset.chatkitPetSummaryStatus!==u.status){const E=this.createStatusIcon(u.status);r.replaceWith(E)}}createSummaryToggleButton(u){const s=ii(this.theme),c=document.createElement("button");return c.type="button",c.textContent=u,c.title=u==="1"?this.copy.restoreMessage:this.copy.collapseMessage,c.addEventListener("click",Ru),c.addEventListener("click",this.handleSummaryCollapseToggle),c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.pointerEvents="auto",c.style.border="1px solid rgba(148, 163, 184, 0.28)",c.style.background="rgba(248, 250, 252, 0.94)",c.style.color="#475569",c.style.boxShadow="0 6px 18px rgba(15, 23, 42, 0.1)",c.style.cursor="pointer",c.style.font=`600 ${s.titleSize}px/1 ${s.fontFamily}`,c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c}createStatusIcon(u){const c=ii(this.theme).iconSize,r=document.createElement("span");if(r.setAttribute("aria-hidden","true"),r.dataset.chatkitPetSummaryStatus=u,r.style.display="inline-flex",r.style.width=`${c}px`,r.style.height=`${c}px`,r.style.alignItems="center",r.style.justifyContent="center",r.style.flex="0 0 auto",u==="running")return r.style.border="2px solid rgba(71, 85, 105, 0.32)",r.style.borderTopColor="#64748b",r.style.borderRadius="999px",r.style.animation="chatkit-pet-summary-spin 900ms linear infinite",r;if(r.style.borderRadius="999px",r.style.fontSize=`${Math.max(10,c-4)}px`,r.style.fontWeight="700",u==="failed")return r.textContent="!",r.style.background="#fee2e2",r.style.color="#b91c1c",r;r.textContent="",r.style.border="2px solid #22c55e",r.style.position="relative";const d=document.createElement("span");return d.style.width=`${Math.round(c*.44)}px`,d.style.height=`${Math.round(c*.25)}px`,d.style.borderLeft="2px solid #22c55e",d.style.borderBottom="2px solid #22c55e",d.style.transform="rotate(-45deg) translate(1px, -1px)",r.append(d),r}createSummaryActionButton(u,s,c){const r=ii(this.theme),d=document.createElement("button");return d.type="button",d.textContent=u,d.title=s,d.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),c()}),d.style.width=`${r.actionSize}px`,d.style.height=`${r.actionSize}px`,d.style.border="0",d.style.borderRadius="999px",d.style.background="rgba(241, 245, 249, 0.96)",d.style.color="#475569",d.style.cursor="pointer",d.style.font=`600 ${r.titleSize}px/1 ${r.fontFamily}`,d}createTextButton(u,s){const c=document.createElement("button");return c.type="button",c.textContent=u,c.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),s()}),c.style.border="1px solid rgba(148, 163, 184, 0.28)",c.style.borderRadius="999px",c.style.background="rgba(248, 250, 252, 0.95)",c.style.color="#334155",c.style.cursor="pointer",c.style.padding="3px 10px",c.style.font='600 12px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',c}createReplyForm(){const u=document.createElement("form");u.addEventListener("click",Ru),u.addEventListener("submit",this.handleReplySubmit),u.addEventListener("keydown",this.handleReplyKeyDown),u.style.display="flex",u.style.gap="6px",u.style.alignItems="center",u.style.marginTop="8px";const s=document.createElement("input");s.type="text",s.value=this.replyDraft,s.disabled=this.isReplySubmitting,s.placeholder=this.copy.replyPlaceholder,s.addEventListener("input",this.handleReplyInput),s.style.minWidth="0",s.style.flex="1",s.style.border="1px solid rgba(148, 163, 184, 0.35)",s.style.borderRadius="999px",s.style.padding="6px 10px",s.style.font='400 13px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',this.replyInputElement=s;const c=document.createElement("button");if(c.type="submit",c.textContent=this.isReplySubmitting?this.copy.sendingButton:this.copy.sendButton,c.disabled=this.isReplySubmitting,c.style.border="0",c.style.borderRadius="999px",c.style.background="#22c55e",c.style.color="#052e16",c.style.cursor=this.isReplySubmitting?"default":"pointer",c.style.padding="6px 10px",c.style.font='700 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',u.append(s,c),this.replyError){const r=document.createElement("div");r.textContent=this.copy.sendFailed,r.style.flexBasis="100%",r.style.color="#b91c1c",r.style.fontSize="12px",u.style.flexWrap="wrap",u.append(r)}return u}createContextMenu(){const u=document.createElement("div");u.setAttribute("data-chatkit-pet-context-menu",""),u.setAttribute("role","menu"),u.addEventListener("contextmenu",this.handleContextMenuEvent),u.addEventListener("pointerdown",Ru),u.addEventListener("click",Ru),u.style.position="absolute",u.style.top="0",u.style.left="0",u.style.boxSizing="border-box",u.style.minWidth="132px",u.style.padding="4px",u.style.pointerEvents="auto",u.style.border="1px solid rgba(148, 163, 184, 0.28)",u.style.borderRadius="10px",u.style.background="rgba(255, 255, 255, 0.96)",u.style.color="#1f2937",u.style.boxShadow="0 12px 28px rgba(15, 23, 42, 0.16)",u.style.font='500 13px/1.3 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',u.style.backdropFilter="blur(10px)";const s=document.createElement("button");return s.type="button",s.textContent=this.copy.closePetMenuItem,s.setAttribute("role","menuitem"),s.addEventListener("click",this.handleClosePetMenuItemClick),s.style.display="block",s.style.width="100%",s.style.border="0",s.style.borderRadius="7px",s.style.background="transparent",s.style.color="inherit",s.style.cursor="pointer",s.style.padding="7px 10px",s.style.textAlign="left",s.style.font="inherit",u.append(s),u}openContextMenu(u){var r;const s=this.overlayElement;if(!s)return;this.closeContextMenu();const c=this.createContextMenu();s.append(c),this.contextMenuElement=c,this.positionContextMenu(u),(r=c.querySelector("button"))==null||r.focus({preventScroll:!0}),window.addEventListener("pointerdown",this.handleContextMenuOutsidePointerDown,!0),window.addEventListener("keydown",this.handleContextMenuKeyDown)}closeContextMenu(){var u;(u=this.contextMenuElement)==null||u.remove(),this.contextMenuElement=null,window.removeEventListener("pointerdown",this.handleContextMenuOutsidePointerDown,!0),window.removeEventListener("keydown",this.handleContextMenuKeyDown)}positionContextMenu(u){const s=this.contextMenuElement;if(!s)return;const c=na(),r=s.offsetWidth||132,d=s.offsetHeight||40,y=Math.max(la,c.width-r-la),v=Math.max(la,c.height-d-la),E=Vl(u.x,la,y),S=Vl(u.y,la,v);s.style.transform=`translate3d(${E}px, ${S}px, 0)`}renderAtlas(u,s){var et;if(!this.petElement||((et=this.resolved)==null?void 0:et.kind)!=="atlas"||!this.options)return;if(!(this.mediaElement instanceof HTMLDivElement)){const gt=document.createElement("div");gt.setAttribute("aria-hidden","true"),this.petElement.replaceChildren(gt),this.mediaElement=gt}const c=this.mediaElement,r=this.resolved.atlas,d=r.animations[u]??r.animations.idle,y=s==="once"&&this.completed?Math.max(0,d.frames-1):Math.min(this.frame,Math.max(0,d.frames-1)),v=rm(this.options.position.scale),E=r.cellWidth,S=r.cellHeight,N=r.columns*E,B=r.rows*S;c.style.width=`${E}px`,c.style.height=`${S}px`,c.style.overflow="hidden",c.style.transform=`scale(${v})`,c.style.transformOrigin="top left",c.style.pointerEvents="none",c.style.backgroundImage=`url("${R0(this.resolved.src)}")`,c.style.backgroundRepeat="no-repeat",c.style.backgroundSize=`${N}px ${B}px`,c.style.backgroundPosition=`${-y*E}px ${-d.row*S}px`,c.style.imageRendering=this.options.imageRendering,c.dataset.petFrame=String(y)}scheduleNextFrame(u,s){if(this.prefersReducedMotion||this.completed||!this.resolved){this.clearTimers();return}if(this.frameTimer!==null)return;const c=this.resolved.atlas,r=c.animations[u]??c.animations.idle,y=(r.frameDurations[this.frame]??r.frameDurations[r.frameDurations.length-1]??150)*M0,v=this.isHovering||this.isDragging?y:y*O0;this.frameTimer=window.setTimeout(()=>{this.frameTimer=null;const E=this.frame+1;if(E>=r.frames){if(s==="once"){this.completed=!0,this.frame=Math.max(0,r.frames-1),this.finishTransient();return}this.frame=0,this.render();return}this.frame=E,this.render()},v)}clearTimers(){this.frameTimer!==null&&(window.clearTimeout(this.frameTimer),this.frameTimer=null)}clearRestingDelayTimer(){this.restingDelayTimer!==null&&(window.clearTimeout(this.restingDelayTimer),this.restingDelayTimer=null)}finishTransient(){this.transient=null,this.activeAnimationName=null,this.activeAnimationMode=null,this.render()}rescheduleAnimation(){this.clearTimers(),this.render()}enterRestingAfterDelay(){this.clearRestingDelayTimer(),this.isHovering=!0,this.restingDelayTimer=window.setTimeout(()=>{this.restingDelayTimer=null,!this.isDragging&&(this.isHovering=!1,this.rescheduleAnimation())},z0)}isPointOverPet(u,s){var r;const c=(r=this.petElement)==null?void 0:r.getBoundingClientRect();return c?u>=c.left&&u<=c.right&&s>=c.top&&s<=c.bottom:!1}isPointerOverPet(u){return this.isPointOverPet(u.clientX,u.clientY)}async submitReply(){var s;const u=this.replyDraft.trim();if(!(!u||this.isReplySubmitting)){this.isReplySubmitting=!0,this.replyError=null,this.render();try{await((s=this.onReply)==null?void 0:s.call(this,u)),this.replyDraft="",this.isReplyOpen=!1,this.isSummaryHovering=!1}catch{this.replyError="Failed to send"}finally{this.isReplySubmitting=!1,this.render()}}}captureActivePointer(){const u=this.activePointerId,s=this.petElement;if(!(u===null||typeof(s==null?void 0:s.setPointerCapture)!="function"))try{s.setPointerCapture(u)}catch{}}releaseActivePointer(){const u=this.activePointerId,s=this.petElement;if(this.activePointerId=null,!(u===null||typeof(s==null?void 0:s.hasPointerCapture)!="function"||typeof s.releasePointerCapture!="function"))try{s.hasPointerCapture(u)&&s.releasePointerCapture(u)}catch{}}isActiveDragPointer(u){return this.isDragging&&u.pointerId===this.activePointerId}getNextDragPosition(u){return this.options?Ne({x:u.clientX-this.dragOffset.x,y:u.clientY-this.dragOffset.y},this.getSize(),na(),Tf(this.options.position.boundsPadding)):{x:0,y:0}}finishDrag(u,s){this.isDragging=!1,this.dragPosition=null,this.dragAnimation=null,this.lastDragClientX=null,this.removeDragListeners(),this.releaseActivePointer(),this.persistPosition(u),s.pointerType==="mouse"&&this.isPointerOverPet(s)?(this.isHovering=!0,this.rescheduleAnimation()):(this.enterRestingAfterDelay(),this.rescheduleAnimation())}cancelActiveDrag(){this.isDragging=!1,this.dragPosition=null,this.dragAnimation=null,this.lastDragPosition=null,this.lastDragClientX=null,this.removeDragListeners(),this.releaseActivePointer()}installDragListeners(){window.addEventListener("pointermove",this.handlePointerMove),window.addEventListener("pointerup",this.handlePointerUp),window.addEventListener("pointercancel",this.handlePointerUp)}removeDragListeners(){window.removeEventListener("pointermove",this.handlePointerMove),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp)}}var Q0=Object.create,Om=Object.defineProperty,Z0=Object.getOwnPropertyDescriptor,zm=(f,u)=>(u=Symbol[f])?u:Symbol.for("Symbol."+f),Qu=f=>{throw TypeError(f)},V0=(f,u,s)=>u in f?Om(f,u,{enumerable:!0,configurable:!0,writable:!0,value:s}):f[u]=s,K0=f=>[,,,Q0((f==null?void 0:f[zm("metadata")])??null)],xm=["class","method","getter","setter","accessor","field","value","get","set"],Cm=f=>f!==void 0&&typeof f!="function"?Qu("Function expected"):f,J0=(f,u,s,c,r)=>({kind:xm[f],name:u,metadata:c,addInitializer:d=>s._?Qu("Already initialized"):r.push(Cm(d||null))}),k0=(f,u)=>V0(u,zm("metadata"),f[3]),W0=(f,u,s,c)=>{for(var r=0,d=f[u>>1],y=d&&d.length;r<y;r++)d[r].call(s);return c},Be=(f,u,s,c,r,d)=>{for(var y,v,E,S,N=u&7,B=!1,et=!1,gt=2,Et=xm[N+5],Ct=f[gt]||(f[gt]=[]),Gt=(r=r.prototype,Z0(r,s)),Mt=c.length-1;Mt>=0;Mt--)E=J0(N,s,v={},f[3],Ct),E.static=B,E.private=et,S=E.access={has:Wt=>s in Wt},S.get=Wt=>Wt[s],y=(0,c[Mt])(Gt[Et],E),v._=1,Cm(y)&&(Gt[Et]=y);return Gt&&Om(r,s,Gt),r},Bf=(f,u,s)=>u.has(f)||Qu("Cannot "+s),z=(f,u,s)=>(Bf(f,u,"read from private field"),s?s.call(f):u.get(f)),Nt=(f,u,s)=>u.has(f)?Qu("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(f):u.set(f,s),kt=(f,u,s,c)=>(Bf(f,u,"write to private field"),u.set(f,s),s),G=(f,u,s)=>(Bf(f,u,"access private method"),s),Dm,wm,Rm,Um,Nm,Hm,Bm,Lm,Ym,qm,jm,Xm,wf,at,Kl,pl,vl,yn,Lu,Lf,Zu,sa,gn,We,He,Yu,Xt,si,ft,j,Zl,Yf,Fe,Vu,Gm,Ku,Qm,Zm,qf,Jl,oi,Rf,Vm,Km,Jm,km,qu,Wm,$m,Fm,ju,ca,Uf,ee;function Im(f){return Df(f)}function Ue(f,u){const s=String(u.name);return function(...c){if(!this.capabilities.commands.has(s))throw new Ft(`ChatKit command "${String(s)}" is not available for the "${this.profile}" profile.`);return f.apply(this,c)}}class he extends(wf=HTMLElement,Xm=[Ue],jm=[Ue],qm=[Ue],Ym=[Ue],Lm=[Ue],Bm=[Ue],Hm=[Ue],Nm=[Ue],Um=[Ue],Rm=[Ue],wm=[Ue],Dm=[Ue],wf){constructor({profile:u}){super(),W0(ee,5,this),Nt(this,j),this.profile=void 0,this.capabilities=void 0,Nt(this,at),Nt(this,Kl),Nt(this,pl),Nt(this,vl),Nt(this,yn),Nt(this,Lu),Nt(this,Lf,!1),Nt(this,Zu,!1),Nt(this,sa),Nt(this,gn,!1),Nt(this,We,this.attachShadow({mode:"open"})),Nt(this,He,new G0(z(this,We),{onActivate:()=>G(this,j,Vm).call(this),onClose:()=>G(this,j,Km).call(this),onReply:s=>G(this,j,Jm).call(this,s),onThreadSummaryActivate:s=>void G(this,j,km).call(this,s)})),Nt(this,Yu),Nt(this,Xt,new Promise(s=>{kt(this,Yu,s)})),Nt(this,si,Am()),Nt(this,ft,new g0({channelId:z(this,si)??void 0,fetch:((...s)=>{var r;const c=((r=z(this,at))==null?void 0:r.api)&&"fetch"in z(this,at).api&&z(this,at).api.fetch;return c?c(...s):fetch(...s)}),target:()=>{var s;return((s=z(this,pl))==null?void 0:s.contentWindow)??null},targetOrigin:window.location.origin,handlers:{onRealtimeVoiceCommand:s=>{var r;const c=(r=z(this,at))==null?void 0:r.realtimeVoice;if(!c||s.type==="start"&&!c.enabled)throw new Ft("Realtime voice is unavailable.");return c.onCommand(s)},onFileInputClick:({inputAttributes:s})=>new Promise(c=>{const r=document.createElement("input");for(const[y,v]of Object.entries(s))r.setAttribute(y,String(v));const d=()=>{c(Array.from(r.files||[])),z(this,We).contains(r)&&z(this,We).removeChild(r)};r.addEventListener("cancel",d),r.addEventListener("change",d),z(this,We).appendChild(r),r.click()}),onApprovalDecision:async s=>{var r,d;const c=(d=(r=z(this,at))==null?void 0:r.approvals)==null?void 0:d.onDecision;if(!c)throw new Ft("Add approvals.onDecision to handle host approvals.");return c(s)},onApprovalAction:async s=>{var r,d;const c=(d=(r=z(this,at))==null?void 0:r.approvals)==null?void 0:d.onAction;if(!c)throw new Ft("Add approvals.onAction to handle approval actions.");return c(s)},onClientToolCall:async({name:s,params:c,id:r,tool_call_id:d})=>{var v;const y=(v=z(this,at))==null?void 0:v.onClientTool;return y||G(this,j,Zl).call(this,new Ft("No handler for client tool calls. You'll need to add onClientTool to your ChatKit options.")),y({name:s,params:c,id:r,tool_call_id:d})},onToolOutputAttachmentPreview:async s=>{var r,d;const c=(d=(r=z(this,at))==null?void 0:r.toolOutputAttachments)==null?void 0:d.onRequestPreview;return c||G(this,j,Zl).call(this,new Ft("No handler for tool-output attachment previews. Add toolOutputAttachments.onRequestPreview to your ChatKit options.")),c(s)},onConnectWorkspaceConnector:async s=>{var r,d,y;const c=(y=(d=(r=z(this,at))==null?void 0:r.composer)==null?void 0:d.resources)==null?void 0:y.onConnect;return c||G(this,j,Zl).call(this,new Ft("Add composer.resources.onConnect to handle workspace Connector connections.")),c(s)},onWorkbenchClientCommand:async({commandKey:s,payload:c,hostType:r,hostId:d,viewKey:y})=>{var E,S;const v=(S=(E=z(this,at))==null?void 0:E.workbench)==null?void 0:S.onClientCommand;return v?v({commandKey:s,payload:c,hostType:r,hostId:d,viewKey:y}):{success:!1,code:"unsupported",commandKey:s}},onWidgetAction:async({action:s,widgetItem:c})=>{var d,y;const r=(y=(d=z(this,at))==null?void 0:d.widgets)==null?void 0:y.onAction;return r||G(this,j,Zl).call(this,new Ft("No handler for widget actions. You'll need to add widgets.onAction to your ChatKit options.")),r(s,c)},onEntitySearch:async({query:s})=>{var c,r,d;return((d=(r=(c=z(this,at))==null?void 0:c.entities)==null?void 0:r.onTagSearch)==null?void 0:d.call(r,s))??[]},onEntityClick:async({entity:s})=>{var c,r,d;return(d=(r=(c=z(this,at))==null?void 0:c.entities)==null?void 0:r.onClick)==null?void 0:d.call(r,s)},onEntityPreview:async({entity:s})=>{var c,r,d;return((d=(r=(c=z(this,at))==null?void 0:c.entities)==null?void 0:r.onRequestPreview)==null?void 0:d.call(r,s))??{preview:null}},onGetClientSecret:async s=>((!z(this,at)||!("getClientSecret"in z(this,at).api)||!z(this,at).api.getClientSecret)&&G(this,j,Zl).call(this,new Ft("Could not refresh the session because ChatKitOptions.api.getClientSecret is not configured.")),z(this,at).api.getClientSecret(s??null)),onAddMetadataToRequest:({op:s,params:c})=>{throw new Ft("ChatKit: onAddMetadataToRequest is unimplemented.")}}})),Nt(this,qu,()=>{G(this,j,Jl).call(this,!1)}),Nt(this,ju,()=>{var s;this.dataset.loaded="true",this.dispatchEvent(new CustomEvent("chatkit.ready",{bubbles:!0,composed:!0})),(s=z(this,Yu))==null||s.call(this)}),Nt(this,ca,!1),this.profile=u,this.capabilities=um(u)}setProfile(u){this.profile=u,this.capabilities=um(u)}connectedCallback(){z(this,He).connect();const u=document.createElement("style");u.textContent=`
|
|
54
|
+
`;const c=document.createElement("div");c.setAttribute("data-chatkit-host-pet",""),c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.pointerEvents="auto",c.style.touchAction="none",c.style.userSelect="none",c.style.willChange="transform",c.addEventListener("pointerenter",this.handlePointerEnter),c.addEventListener("pointerleave",this.handlePointerLeave),c.addEventListener("pointerdown",this.handlePointerDown),c.addEventListener("lostpointercapture",this.handleLostPointerCapture),c.addEventListener("contextmenu",this.handleContextMenu),c.addEventListener("click",this.handleClick),u.append(s,c),this.root.append(u),this.overlayElement=u,this.petElement=c}removeOverlay(){var u;this.cancelActiveDrag(),this.clearRestingDelayTimer(),this.clearTimers(),this.closeContextMenu(),this.petElement&&(this.petElement.removeEventListener("pointerenter",this.handlePointerEnter),this.petElement.removeEventListener("pointerleave",this.handlePointerLeave),this.petElement.removeEventListener("pointerdown",this.handlePointerDown),this.petElement.removeEventListener("lostpointercapture",this.handleLostPointerCapture),this.petElement.removeEventListener("contextmenu",this.handleContextMenu),this.petElement.removeEventListener("click",this.handleClick)),this.isHovering=!1,this.removeSummaryElements(),(u=this.overlayElement)==null||u.remove(),this.overlayElement=null,this.petElement=null,this.mediaElement=null}removeSummaryElements(){var u,s;(u=this.summaryElement)==null||u.remove(),(s=this.summaryToggleElement)==null||s.remove(),this.summaryElement=null,this.summaryToggleElement=null,this.replyInputElement=null,this.summaryRenderKey=null}getSize(){if(!this.options||!this.resolved)return{width:0,height:0};const u=rm(this.options.position.scale),s={width:this.resolved.atlas.cellWidth,height:this.resolved.atlas.cellHeight};return{width:s.width*u,height:s.height*u}}getCurrentPosition(u){const s=this.options;if(!s)return{x:0,y:0};const c=na(),r=Tf(s.position.boundsPadding),d=s.position.pin===void 0?"bottom-right":s.position.pin,y=d?_0(d,u,c,r):null;return Ne(this.dragPosition??this.position??y??{x:r.left,y:r.top},u,c,r)}persistPosition(u){if(!this.options)return;const s=this.getSize(),c=Ne(u,s,na(),Tf(this.options.position.boundsPadding));this.position=c,w0(sm,this.options.position.persist,c)}getActiveAnimationName(){return this.options?this.isDragging?this.dragAnimation??"running":this.transient?this.transient.name:this.options.behavior==="manual"?"idle":this.currentState:"idle"}getActiveAnimationMode(){return this.isDragging?"loop":this.transient?"once":"loop"}resetAnimationIfNeeded(u,s){this.activeAnimationName===u&&this.activeAnimationMode===s||(this.clearTimers(),this.activeAnimationName=u,this.activeAnimationMode=s,this.frame=0,this.completed=!1)}render(){if(!this.options||!this.resolved){this.clearTimers(),this.petElement&&this.petElement.replaceChildren(),this.removeSummaryElements(),this.mediaElement=null,this.activeAnimationName=null,this.activeAnimationMode=null,this.frame=0,this.completed=!1;return}this.ensureOverlay();const u=this.overlayElement,s=this.petElement;if(!u||!s)return;const c=this.getSize(),r=this.getCurrentPosition(c),d=this.getActiveAnimationName(),y=this.getActiveAnimationMode();this.resetAnimationIfNeeded(d,y),u.style.zIndex=String(this.options.position.zIndex),s.style.width=`${c.width}px`,s.style.height=`${c.height}px`,s.style.transform=`translate3d(${r.x}px, ${r.y}px, 0)`,s.style.cursor=this.options.position.draggable?this.isDragging?"grabbing":"grab":"default",s.dataset.petAnimation=d,s.setAttribute("aria-label",this.options.ariaLabel),s.setAttribute("role","img"),this.renderAtlas(d,y),this.renderThreadSummary(r,c),this.scheduleNextFrame(d,y)}renderThreadSummary(u,s){var y,v,E;const c=this.summary,r=dm(c);if(!c||!r||this.dismissedSummaryKey===r){this.removeSummaryElements();return}if(this.isSummaryCollapsed){this.renderCollapsedSummary(u,s);return}const d=[this.copyLocale,this.isSummaryExpanded?"expanded":"compact",this.isSummaryHovering?"hover":"rest",this.isReplyOpen?"reply":"closed",this.isReplySubmitting?"submitting":"ready",this.replyError??""].join("|");(!this.summaryElement||this.summaryRenderKey!==d)&&((y=this.summaryElement)==null||y.remove(),(v=this.summaryToggleElement)==null||v.remove(),this.summaryElement=this.createSummaryBubble(c),this.summaryToggleElement=this.createSummaryToggleButton("v"),(E=this.overlayElement)==null||E.append(this.summaryElement,this.summaryToggleElement),this.summaryRenderKey=d,this.isReplyOpen&&!this.isReplySubmitting&&window.setTimeout(()=>{var S;return(S=this.replyInputElement)==null?void 0:S.focus()},0)),this.updateSummaryBubbleContent(c),this.positionSummaryBubble(u,s)}renderCollapsedSummary(u,s){var c,r;(c=this.summaryElement)==null||c.remove(),this.summaryElement=null,this.summaryRenderKey=null,this.summaryToggleElement||(this.summaryToggleElement=this.createSummaryToggleButton("1"),(r=this.overlayElement)==null||r.append(this.summaryToggleElement)),this.summaryToggleElement.textContent="1",this.positionSummaryToggleBadge(u,s)}positionSummaryToggleBadge(u,s){const c=this.summaryToggleElement;if(!c)return;const r=na(),d=ii(this.theme).toggleSize,y=Vl(u.x+s.width-d*.35,ke,r.width-d-ke),v=Vl(u.y-d*.35,ke,r.height-d-ke);c.style.width=`${d}px`,c.style.height=`${d}px`,c.style.transform=`translate3d(${y}px, ${v}px, 0)`,c.style.borderRadius="999px"}positionSummaryBubble(u,s){const c=this.summaryElement,r=this.summaryToggleElement;if(!c||!r)return;const d=na(),y=Math.min(x0,d.width-ke*2);c.style.width=`${y}px`;const v=c.offsetHeight||96,E=u.y-v-fm,N=E>=ke?E:Vl(u.y+s.height+fm,ke,d.height-v-ke),B=Vl(u.x+s.width/2-y/2,ke,d.width-y-ke);c.style.transform=`translate3d(${B}px, ${N}px, 0)`,this.positionSummaryToggleBadge(u,s)}createSummaryBubble(u){const s=this.isSummaryHovering&&!this.isReplyOpen,c=ii(this.theme),r=document.createElement("div");r.setAttribute("data-chatkit-pet-summary",""),r.addEventListener("pointerenter",this.handleSummaryPointerEnter),r.addEventListener("pointerleave",this.handleSummaryPointerLeave),r.addEventListener("click",this.handleSummaryClick),r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.boxSizing="border-box",r.style.pointerEvents="auto",r.style.padding=c.padding,r.style.border="1px solid rgba(148, 163, 184, 0.22)",r.style.borderRadius=`${c.radius}px`,r.style.background="rgba(255, 255, 255, 0.94)",r.style.color="#1f2937",r.style.boxShadow="0 8px 24px rgba(15, 23, 42, 0.1)",r.style.font=`500 ${c.bodySize}px/1.35 ${c.fontFamily}`,r.style.backdropFilter="blur(10px)";const d=document.createElement("div");d.style.display="flex",d.style.alignItems="center",d.style.gap=`${c.gap}px`,(this.isSummaryHovering||this.isReplyOpen)&&d.append(this.createSummaryActionButton("x",this.copy.hideMessage,this.handleSummaryDelete));const y=document.createElement("div");y.textContent=u.title,y.style.minWidth="0",y.style.flex="1",y.style.overflow="hidden",y.style.textOverflow="ellipsis",y.style.whiteSpace="nowrap",y.style.fontWeight="700",y.style.fontSize=`${c.titleSize}px`,y.dataset.chatkitPetSummaryTitle="",d.append(y),this.isSummaryHovering||this.isReplyOpen?d.append(this.createSummaryActionButton(this.isSummaryExpanded?"-":">",this.isSummaryExpanded?this.copy.collapseMessage:this.copy.expandMessage,this.handleSummaryExpandToggle)):d.append(this.createStatusIcon(u.status));const v=document.createElement("div");if(v.textContent=u.message,v.style.marginTop=`${c.marginTop}px`,v.style.fontWeight="400",v.style.color="#374151",v.style.overflow="hidden",this.isSummaryExpanded?(v.style.maxHeight="7em",v.style.overflowY="auto"):(v.style.display="-webkit-box",v.style.setProperty("-webkit-line-clamp","2"),v.style.setProperty("-webkit-box-orient","vertical")),v.dataset.chatkitPetSummaryMessage="",r.append(d,v),s){const E=this.createTextButton(this.copy.replyButton,this.handleReplyOpen);E.style.position="absolute",E.style.right="14px",E.style.bottom="10px",r.append(E)}return this.isReplyOpen&&r.append(this.createReplyForm()),r}updateSummaryBubbleContent(u){var d,y,v;const s=(d=this.summaryElement)==null?void 0:d.querySelector("[data-chatkit-pet-summary-title]");s&&s.textContent!==u.title&&(s.textContent=u.title);const c=(y=this.summaryElement)==null?void 0:y.querySelector("[data-chatkit-pet-summary-message]");c&&c.textContent!==u.message&&(c.textContent=u.message);const r=(v=this.summaryElement)==null?void 0:v.querySelector("[data-chatkit-pet-summary-status]");if(r&&r.dataset.chatkitPetSummaryStatus!==u.status){const E=this.createStatusIcon(u.status);r.replaceWith(E)}}createSummaryToggleButton(u){const s=ii(this.theme),c=document.createElement("button");return c.type="button",c.textContent=u,c.title=u==="1"?this.copy.restoreMessage:this.copy.collapseMessage,c.addEventListener("click",Ru),c.addEventListener("click",this.handleSummaryCollapseToggle),c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.pointerEvents="auto",c.style.border="1px solid rgba(148, 163, 184, 0.28)",c.style.background="rgba(248, 250, 252, 0.94)",c.style.color="#475569",c.style.boxShadow="0 6px 18px rgba(15, 23, 42, 0.1)",c.style.cursor="pointer",c.style.font=`600 ${s.titleSize}px/1 ${s.fontFamily}`,c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c}createStatusIcon(u){const c=ii(this.theme).iconSize,r=document.createElement("span");if(r.setAttribute("aria-hidden","true"),r.dataset.chatkitPetSummaryStatus=u,r.style.display="inline-flex",r.style.width=`${c}px`,r.style.height=`${c}px`,r.style.alignItems="center",r.style.justifyContent="center",r.style.flex="0 0 auto",u==="running")return r.style.border="2px solid rgba(71, 85, 105, 0.32)",r.style.borderTopColor="#64748b",r.style.borderRadius="999px",r.style.animation="chatkit-pet-summary-spin 900ms linear infinite",r;if(r.style.borderRadius="999px",r.style.fontSize=`${Math.max(10,c-4)}px`,r.style.fontWeight="700",u==="failed")return r.textContent="!",r.style.background="#fee2e2",r.style.color="#b91c1c",r;r.textContent="",r.style.border="2px solid #22c55e",r.style.position="relative";const d=document.createElement("span");return d.style.width=`${Math.round(c*.44)}px`,d.style.height=`${Math.round(c*.25)}px`,d.style.borderLeft="2px solid #22c55e",d.style.borderBottom="2px solid #22c55e",d.style.transform="rotate(-45deg) translate(1px, -1px)",r.append(d),r}createSummaryActionButton(u,s,c){const r=ii(this.theme),d=document.createElement("button");return d.type="button",d.textContent=u,d.title=s,d.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),c()}),d.style.width=`${r.actionSize}px`,d.style.height=`${r.actionSize}px`,d.style.border="0",d.style.borderRadius="999px",d.style.background="rgba(241, 245, 249, 0.96)",d.style.color="#475569",d.style.cursor="pointer",d.style.font=`600 ${r.titleSize}px/1 ${r.fontFamily}`,d}createTextButton(u,s){const c=document.createElement("button");return c.type="button",c.textContent=u,c.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),s()}),c.style.border="1px solid rgba(148, 163, 184, 0.28)",c.style.borderRadius="999px",c.style.background="rgba(248, 250, 252, 0.95)",c.style.color="#334155",c.style.cursor="pointer",c.style.padding="3px 10px",c.style.font='600 12px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',c}createReplyForm(){const u=document.createElement("form");u.addEventListener("click",Ru),u.addEventListener("submit",this.handleReplySubmit),u.addEventListener("keydown",this.handleReplyKeyDown),u.style.display="flex",u.style.gap="6px",u.style.alignItems="center",u.style.marginTop="8px";const s=document.createElement("input");s.type="text",s.value=this.replyDraft,s.disabled=this.isReplySubmitting,s.placeholder=this.copy.replyPlaceholder,s.addEventListener("input",this.handleReplyInput),s.style.minWidth="0",s.style.flex="1",s.style.border="1px solid rgba(148, 163, 184, 0.35)",s.style.borderRadius="999px",s.style.padding="6px 10px",s.style.font='400 13px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',this.replyInputElement=s;const c=document.createElement("button");if(c.type="submit",c.textContent=this.isReplySubmitting?this.copy.sendingButton:this.copy.sendButton,c.disabled=this.isReplySubmitting,c.style.border="0",c.style.borderRadius="999px",c.style.background="#22c55e",c.style.color="#052e16",c.style.cursor=this.isReplySubmitting?"default":"pointer",c.style.padding="6px 10px",c.style.font='700 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',u.append(s,c),this.replyError){const r=document.createElement("div");r.textContent=this.copy.sendFailed,r.style.flexBasis="100%",r.style.color="#b91c1c",r.style.fontSize="12px",u.style.flexWrap="wrap",u.append(r)}return u}createContextMenu(){const u=document.createElement("div");u.setAttribute("data-chatkit-pet-context-menu",""),u.setAttribute("role","menu"),u.addEventListener("contextmenu",this.handleContextMenuEvent),u.addEventListener("pointerdown",Ru),u.addEventListener("click",Ru),u.style.position="absolute",u.style.top="0",u.style.left="0",u.style.boxSizing="border-box",u.style.minWidth="132px",u.style.padding="4px",u.style.pointerEvents="auto",u.style.border="1px solid rgba(148, 163, 184, 0.28)",u.style.borderRadius="10px",u.style.background="rgba(255, 255, 255, 0.96)",u.style.color="#1f2937",u.style.boxShadow="0 12px 28px rgba(15, 23, 42, 0.16)",u.style.font='500 13px/1.3 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',u.style.backdropFilter="blur(10px)";const s=document.createElement("button");return s.type="button",s.textContent=this.copy.closePetMenuItem,s.setAttribute("role","menuitem"),s.addEventListener("click",this.handleClosePetMenuItemClick),s.style.display="block",s.style.width="100%",s.style.border="0",s.style.borderRadius="7px",s.style.background="transparent",s.style.color="inherit",s.style.cursor="pointer",s.style.padding="7px 10px",s.style.textAlign="left",s.style.font="inherit",u.append(s),u}openContextMenu(u){var r;const s=this.overlayElement;if(!s)return;this.closeContextMenu();const c=this.createContextMenu();s.append(c),this.contextMenuElement=c,this.positionContextMenu(u),(r=c.querySelector("button"))==null||r.focus({preventScroll:!0}),window.addEventListener("pointerdown",this.handleContextMenuOutsidePointerDown,!0),window.addEventListener("keydown",this.handleContextMenuKeyDown)}closeContextMenu(){var u;(u=this.contextMenuElement)==null||u.remove(),this.contextMenuElement=null,window.removeEventListener("pointerdown",this.handleContextMenuOutsidePointerDown,!0),window.removeEventListener("keydown",this.handleContextMenuKeyDown)}positionContextMenu(u){const s=this.contextMenuElement;if(!s)return;const c=na(),r=s.offsetWidth||132,d=s.offsetHeight||40,y=Math.max(la,c.width-r-la),v=Math.max(la,c.height-d-la),E=Vl(u.x,la,y),S=Vl(u.y,la,v);s.style.transform=`translate3d(${E}px, ${S}px, 0)`}renderAtlas(u,s){var et;if(!this.petElement||((et=this.resolved)==null?void 0:et.kind)!=="atlas"||!this.options)return;if(!(this.mediaElement instanceof HTMLDivElement)){const gt=document.createElement("div");gt.setAttribute("aria-hidden","true"),this.petElement.replaceChildren(gt),this.mediaElement=gt}const c=this.mediaElement,r=this.resolved.atlas,d=r.animations[u]??r.animations.idle,y=s==="once"&&this.completed?Math.max(0,d.frames-1):Math.min(this.frame,Math.max(0,d.frames-1)),v=rm(this.options.position.scale),E=r.cellWidth,S=r.cellHeight,N=r.columns*E,B=r.rows*S;c.style.width=`${E}px`,c.style.height=`${S}px`,c.style.overflow="hidden",c.style.transform=`scale(${v})`,c.style.transformOrigin="top left",c.style.pointerEvents="none",c.style.backgroundImage=`url("${R0(this.resolved.src)}")`,c.style.backgroundRepeat="no-repeat",c.style.backgroundSize=`${N}px ${B}px`,c.style.backgroundPosition=`${-y*E}px ${-d.row*S}px`,c.style.imageRendering=this.options.imageRendering,c.dataset.petFrame=String(y)}scheduleNextFrame(u,s){if(this.prefersReducedMotion||this.completed||!this.resolved){this.clearTimers();return}if(this.frameTimer!==null)return;const c=this.resolved.atlas,r=c.animations[u]??c.animations.idle,y=(r.frameDurations[this.frame]??r.frameDurations[r.frameDurations.length-1]??150)*M0,v=this.isHovering||this.isDragging?y:y*O0;this.frameTimer=window.setTimeout(()=>{this.frameTimer=null;const E=this.frame+1;if(E>=r.frames){if(s==="once"){this.completed=!0,this.frame=Math.max(0,r.frames-1),this.finishTransient();return}this.frame=0,this.render();return}this.frame=E,this.render()},v)}clearTimers(){this.frameTimer!==null&&(window.clearTimeout(this.frameTimer),this.frameTimer=null)}clearRestingDelayTimer(){this.restingDelayTimer!==null&&(window.clearTimeout(this.restingDelayTimer),this.restingDelayTimer=null)}finishTransient(){this.transient=null,this.activeAnimationName=null,this.activeAnimationMode=null,this.render()}rescheduleAnimation(){this.clearTimers(),this.render()}enterRestingAfterDelay(){this.clearRestingDelayTimer(),this.isHovering=!0,this.restingDelayTimer=window.setTimeout(()=>{this.restingDelayTimer=null,!this.isDragging&&(this.isHovering=!1,this.rescheduleAnimation())},z0)}isPointOverPet(u,s){var r;const c=(r=this.petElement)==null?void 0:r.getBoundingClientRect();return c?u>=c.left&&u<=c.right&&s>=c.top&&s<=c.bottom:!1}isPointerOverPet(u){return this.isPointOverPet(u.clientX,u.clientY)}async submitReply(){var s;const u=this.replyDraft.trim();if(!(!u||this.isReplySubmitting)){this.isReplySubmitting=!0,this.replyError=null,this.render();try{await((s=this.onReply)==null?void 0:s.call(this,u)),this.replyDraft="",this.isReplyOpen=!1,this.isSummaryHovering=!1}catch{this.replyError="Failed to send"}finally{this.isReplySubmitting=!1,this.render()}}}captureActivePointer(){const u=this.activePointerId,s=this.petElement;if(!(u===null||typeof(s==null?void 0:s.setPointerCapture)!="function"))try{s.setPointerCapture(u)}catch{}}releaseActivePointer(){const u=this.activePointerId,s=this.petElement;if(this.activePointerId=null,!(u===null||typeof(s==null?void 0:s.hasPointerCapture)!="function"||typeof s.releasePointerCapture!="function"))try{s.hasPointerCapture(u)&&s.releasePointerCapture(u)}catch{}}isActiveDragPointer(u){return this.isDragging&&u.pointerId===this.activePointerId}getNextDragPosition(u){return this.options?Ne({x:u.clientX-this.dragOffset.x,y:u.clientY-this.dragOffset.y},this.getSize(),na(),Tf(this.options.position.boundsPadding)):{x:0,y:0}}finishDrag(u,s){this.isDragging=!1,this.dragPosition=null,this.dragAnimation=null,this.lastDragClientX=null,this.removeDragListeners(),this.releaseActivePointer(),this.persistPosition(u),s.pointerType==="mouse"&&this.isPointerOverPet(s)?(this.isHovering=!0,this.rescheduleAnimation()):(this.enterRestingAfterDelay(),this.rescheduleAnimation())}cancelActiveDrag(){this.isDragging=!1,this.dragPosition=null,this.dragAnimation=null,this.lastDragPosition=null,this.lastDragClientX=null,this.removeDragListeners(),this.releaseActivePointer()}installDragListeners(){window.addEventListener("pointermove",this.handlePointerMove),window.addEventListener("pointerup",this.handlePointerUp),window.addEventListener("pointercancel",this.handlePointerUp)}removeDragListeners(){window.removeEventListener("pointermove",this.handlePointerMove),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp)}}var Q0=Object.create,Om=Object.defineProperty,Z0=Object.getOwnPropertyDescriptor,zm=(f,u)=>(u=Symbol[f])?u:Symbol.for("Symbol."+f),Qu=f=>{throw TypeError(f)},V0=(f,u,s)=>u in f?Om(f,u,{enumerable:!0,configurable:!0,writable:!0,value:s}):f[u]=s,K0=f=>[,,,Q0((f==null?void 0:f[zm("metadata")])??null)],xm=["class","method","getter","setter","accessor","field","value","get","set"],Cm=f=>f!==void 0&&typeof f!="function"?Qu("Function expected"):f,J0=(f,u,s,c,r)=>({kind:xm[f],name:u,metadata:c,addInitializer:d=>s._?Qu("Already initialized"):r.push(Cm(d||null))}),k0=(f,u)=>V0(u,zm("metadata"),f[3]),W0=(f,u,s,c)=>{for(var r=0,d=f[u>>1],y=d&&d.length;r<y;r++)d[r].call(s);return c},Be=(f,u,s,c,r,d)=>{for(var y,v,E,S,N=u&7,B=!1,et=!1,gt=2,Et=xm[N+5],Ct=f[gt]||(f[gt]=[]),Gt=(r=r.prototype,Z0(r,s)),Mt=c.length-1;Mt>=0;Mt--)E=J0(N,s,v={},f[3],Ct),E.static=B,E.private=et,S=E.access={has:Wt=>s in Wt},S.get=Wt=>Wt[s],y=(0,c[Mt])(Gt[Et],E),v._=1,Cm(y)&&(Gt[Et]=y);return Gt&&Om(r,s,Gt),r},Bf=(f,u,s)=>u.has(f)||Qu("Cannot "+s),z=(f,u,s)=>(Bf(f,u,"read from private field"),s?s.call(f):u.get(f)),Nt=(f,u,s)=>u.has(f)?Qu("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(f):u.set(f,s),kt=(f,u,s,c)=>(Bf(f,u,"write to private field"),u.set(f,s),s),G=(f,u,s)=>(Bf(f,u,"access private method"),s),Dm,wm,Rm,Um,Nm,Hm,Bm,Lm,Ym,qm,jm,Xm,wf,at,Kl,pl,vl,yn,Lu,Lf,Zu,sa,gn,We,He,Yu,Xt,si,ft,j,Zl,Yf,Fe,Vu,Gm,Ku,Qm,Zm,qf,Jl,oi,Rf,Vm,Km,Jm,km,qu,Wm,$m,Fm,ju,ca,Uf,ee;function Im(f){return Df(f)}function Ue(f,u){const s=String(u.name);return function(...c){if(!this.capabilities.commands.has(s))throw new Ft(`ChatKit command "${String(s)}" is not available for the "${this.profile}" profile.`);return f.apply(this,c)}}class he extends(wf=HTMLElement,Xm=[Ue],jm=[Ue],qm=[Ue],Ym=[Ue],Lm=[Ue],Bm=[Ue],Hm=[Ue],Nm=[Ue],Um=[Ue],Rm=[Ue],wm=[Ue],Dm=[Ue],wf){constructor({profile:u}){super(),W0(ee,5,this),Nt(this,j),this.profile=void 0,this.capabilities=void 0,Nt(this,at),Nt(this,Kl),Nt(this,pl),Nt(this,vl),Nt(this,yn),Nt(this,Lu),Nt(this,Lf,!1),Nt(this,Zu,!1),Nt(this,sa),Nt(this,gn,!1),Nt(this,We,this.attachShadow({mode:"open"})),Nt(this,He,new G0(z(this,We),{onActivate:()=>G(this,j,Vm).call(this),onClose:()=>G(this,j,Km).call(this),onReply:s=>G(this,j,Jm).call(this,s),onThreadSummaryActivate:s=>void G(this,j,km).call(this,s)})),Nt(this,Yu),Nt(this,Xt,new Promise(s=>{kt(this,Yu,s)})),Nt(this,si,Am()),Nt(this,ft,new g0({channelId:z(this,si)??void 0,fetch:((...s)=>{var r;const c=((r=z(this,at))==null?void 0:r.api)&&"fetch"in z(this,at).api&&z(this,at).api.fetch;return c?c(...s):fetch(...s)}),target:()=>{var s;return((s=z(this,pl))==null?void 0:s.contentWindow)??null},targetOrigin:window.location.origin,handlers:{onRealtimeVoiceCommand:s=>{var r;const c=(r=z(this,at))==null?void 0:r.realtimeVoice;if(!c||s.type==="start"&&!c.enabled)throw new Ft("Realtime voice is unavailable.");return c.onCommand(s)},onFileInputClick:({inputAttributes:s})=>new Promise(c=>{const r=document.createElement("input");for(const[y,v]of Object.entries(s))r.setAttribute(y,String(v));const d=()=>{c(Array.from(r.files||[])),z(this,We).contains(r)&&z(this,We).removeChild(r)};r.addEventListener("cancel",d),r.addEventListener("change",d),z(this,We).appendChild(r),r.click()}),onApprovalDecision:async s=>{var r,d;const c=(d=(r=z(this,at))==null?void 0:r.approvals)==null?void 0:d.onDecision;if(!c)throw new Ft("Add approvals.onDecision to handle host approvals.");return c(s)},onApprovalAction:async s=>{var r,d;const c=(d=(r=z(this,at))==null?void 0:r.approvals)==null?void 0:d.onAction;if(!c)throw new Ft("Add approvals.onAction to handle approval actions.");return c(s)},onClientToolCall:async({name:s,params:c,id:r,tool_call_id:d})=>{var v;const y=(v=z(this,at))==null?void 0:v.onClientTool;return y||G(this,j,Zl).call(this,new Ft("No handler for client tool calls. You'll need to add onClientTool to your ChatKit options.")),y({name:s,params:c,id:r,tool_call_id:d})},onToolOutputAttachmentPreview:async s=>{var r,d;const c=(d=(r=z(this,at))==null?void 0:r.toolOutputAttachments)==null?void 0:d.onRequestPreview;return c||G(this,j,Zl).call(this,new Ft("No handler for tool-output attachment previews. Add toolOutputAttachments.onRequestPreview to your ChatKit options.")),c(s)},onConnectWorkspaceConnector:async s=>{var r,d,y;const c=(y=(d=(r=z(this,at))==null?void 0:r.composer)==null?void 0:d.resources)==null?void 0:y.onConnect;return c||G(this,j,Zl).call(this,new Ft("Add composer.resources.onConnect to handle workspace Connector connections.")),c(s)},onWorkbenchClientCommand:async({commandKey:s,payload:c,hostType:r,hostId:d,viewKey:y,userActivated:v})=>{var S,N;const E=(N=(S=z(this,at))==null?void 0:S.workbench)==null?void 0:N.onClientCommand;return E?E({commandKey:s,payload:c,hostType:r,hostId:d,viewKey:y,...v!==void 0?{userActivated:v}:{}}):{success:!1,code:"unsupported",commandKey:s}},onWidgetAction:async({action:s,widgetItem:c})=>{var d,y;const r=(y=(d=z(this,at))==null?void 0:d.widgets)==null?void 0:y.onAction;return r||G(this,j,Zl).call(this,new Ft("No handler for widget actions. You'll need to add widgets.onAction to your ChatKit options.")),r(s,c)},onEntitySearch:async({query:s})=>{var c,r,d;return((d=(r=(c=z(this,at))==null?void 0:c.entities)==null?void 0:r.onTagSearch)==null?void 0:d.call(r,s))??[]},onEntityClick:async({entity:s})=>{var c,r,d;return(d=(r=(c=z(this,at))==null?void 0:c.entities)==null?void 0:r.onClick)==null?void 0:d.call(r,s)},onEntityPreview:async({entity:s})=>{var c,r,d;return((d=(r=(c=z(this,at))==null?void 0:c.entities)==null?void 0:r.onRequestPreview)==null?void 0:d.call(r,s))??{preview:null}},onGetClientSecret:async s=>((!z(this,at)||!("getClientSecret"in z(this,at).api)||!z(this,at).api.getClientSecret)&&G(this,j,Zl).call(this,new Ft("Could not refresh the session because ChatKitOptions.api.getClientSecret is not configured.")),z(this,at).api.getClientSecret(s??null)),onAddMetadataToRequest:({op:s,params:c})=>{throw new Ft("ChatKit: onAddMetadataToRequest is unimplemented.")}}})),Nt(this,qu,()=>{G(this,j,Jl).call(this,!1)}),Nt(this,ju,()=>{var s;this.dataset.loaded="true",this.dispatchEvent(new CustomEvent("chatkit.ready",{bubbles:!0,composed:!0})),(s=z(this,Yu))==null||s.call(this)}),Nt(this,ca,!1),this.profile=u,this.capabilities=um(u)}setProfile(u){this.profile=u,this.capabilities=um(u)}connectedCallback(){z(this,He).connect();const u=document.createElement("style");u.textContent=`
|
|
55
55
|
:host {
|
|
56
56
|
display: block;
|
|
57
57
|
position: relative;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>XpertAI PowerPoint Copilot</title>
|
|
7
7
|
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
|
|
8
|
-
<script type="module" crossorigin src="/assets/taskpane-
|
|
8
|
+
<script type="module" crossorigin src="/assets/taskpane-HodxySWw.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/taskpane-DQ4lBAsH.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/chatkit-powerpoint-addin",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "PowerPoint task pane add-in that embeds Xpert ChatKit and exposes Office.js client tools.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"react": "^19.0.0",
|
|
26
26
|
"react-dom": "^19.0.0",
|
|
27
|
-
"@xpert-ai/chatkit-react": "~0.12.
|
|
28
|
-
"@xpert-ai/chatkit-types": "~0.12.
|
|
27
|
+
"@xpert-ai/chatkit-react": "~0.12.2",
|
|
28
|
+
"@xpert-ai/chatkit-types": "~0.12.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.19.0",
|