/*! For license information please see aizen-widget.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],e):"object"==typeof exports?exports.AizenWidget=e(require("React"),require("ReactDOM")):t.AizenWidget=e(t.React,t.ReactDOM)}(globalThis,(t,e)=>(()=>{var n={146(t,e,n){"use strict";var r=n(404),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function c(t){return r.isMemo(t)?a:s[t.$$typeof]||i}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=a;var l=Object.defineProperty,p=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,u=Object.getOwnPropertyDescriptor,m=Object.getPrototypeOf,f=Object.prototype;t.exports=function t(e,n,r){if("string"!=typeof n){if(f){var i=m(n);i&&i!==f&&t(e,i,r)}var a=p(n);d&&(a=a.concat(d(n)));for(var s=c(e),h=c(n),g=0;g{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.nc=void 0;var o={};return(()=>{"use strict";i.d(o,{default:()=>$n});var t=i(883),e=i.n(t),n=i(338);const r=new class{constructor(){this.baseURL="https://chat.ai-zens.com"}setBaseURL(t){t&&"string"==typeof t&&(this.baseURL=t.replace(/\/$/,""))}setGetToken(t){this.getToken=t}async openConversation(){try{const t=await fetch(`${this.baseURL}/chat/open`,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`,"Content-Type":"application/json"}});if(!t.ok){const e=await t.json().catch(()=>({}));throw new Error(e.detail||e.message||`開啟對話失敗: ${t.status}`)}return await t.json()}catch(t){throw t}}async getConversationHistory(t){let{offset:e=0,limit:n=20}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{const r=new URLSearchParams({offset:e.toString(),limit:Math.min(n,100).toString()}),i=`${this.baseURL}/chat/history/${t}?${r}`,o=await fetch(i,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`,"Content-Type":"application/json"}});if(!o.ok){const t=await o.json().catch(()=>({}));throw new Error(t.detail||t.message||`獲取歷史失敗: ${o.status}`)}return await o.json()}catch(t){throw t}}async sendMessage(t,e){let{message:n=null,trigger_intent:r=null,location_href:i=null,metadata:o=null}=e;"function"==typeof siteSendEvent&&siteSendEvent("chat_event",{type:"sent",conversation_id:t,content:{message:n,trigger_intent:r,metadata:o}}).catch(()=>{});try{const e={message:n,trigger_intent:r,location_href:i,metadata:o},a=await fetch(`${this.baseURL}/chat/send/${t}`,{method:"POST",headers:{Authorization:`Bearer ${this.getToken()}`,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){const t=await a.json().catch(()=>({}));throw new Error(t.detail||t.message||`發送消息失敗: ${a.status}`)}return await a.json()}catch(t){throw t}}async closeConversation(t){try{const e=await fetch(`${this.baseURL}/chat/close/${t}`,{method:"POST",headers:{Authorization:`Bearer ${this.getToken()}`,"Content-Type":"application/json"}});if(!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.detail||t.message||`關閉對話失敗: ${e.status}`)}return await e.json()}catch(t){throw t}}async healthCheck(){try{return(await fetch(`${this.baseURL}/health`,{method:"GET"})).ok}catch(t){return!1}}},a="https://cdn.prod.website-files.com/64420a3911d6832c7ba8b105/6a0fcab0d75a0345e5b92c36_Aire%20avatar-small.webp";var s=i(363),c=i(833),l=i.n(c);const p=function(t){function e(t,r,c,l,u){for(var m,f,h,g,w,k=0,S=0,C=0,$=0,j=0,L=0,O=h=m=0,z=0,M=0,P=0,B=0,N=c.length,G=N-1,U="",F="",Y="",W="";zm)&&(B=(U=U.replace(" ",":")).length),0r&&(r=(e=e.trim()).charCodeAt(0)),r){case 38:return e.replace(g,"$1"+t.trim());case 58:return t.trim()+e.replace(g,"$1"+t.trim());default:if(0<1*n&&0c.charCodeAt(8))break;case 115:a=a.replace(c,"-webkit-"+c)+";"+a;break;case 207:case 102:a=a.replace(c,"-webkit-"+(102r.charCodeAt(0)&&(r=r.trim()),r=[r],01?e-1:0),r=1;r0?" Args: "+n.join(", "):""))}var I=function(){function t(t){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=t}var e=t.prototype;return e.indexOfGroup=function(t){for(var e=0,n=0;n=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,i=r;t>=i;)(i<<=1)<0&&_(16,""+t);this.groupSizes=new Uint32Array(i),this.groupSizes.set(n),this.length=i;for(var o=r;o=this.length||0===this.groupSizes[t])return e;for(var n=this.groupSizes[t],r=this.indexOfGroup(t),i=r+n,o=r;o=R&&(R=e+1),T.set(t,e),L.set(e,t)},M="style["+$+'][data-styled-version="5.3.11"]',P=new RegExp("^"+$+'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)'),B=function(t,e,n){for(var r,i=n.split(","),o=0,a=i.length;o=0;n--){var r=e[n];if(r&&1===r.nodeType&&r.hasAttribute($))return r}}(n),o=void 0!==i?i.nextSibling:null;r.setAttribute($,"active"),r.setAttribute("data-styled-version","5.3.11");var a=G();return a&&r.setAttribute("nonce",a),n.insertBefore(r,o),r},F=function(){function t(t){var e=this.element=U(t);e.appendChild(document.createTextNode("")),this.sheet=function(t){if(t.sheet)return t.sheet;for(var e=document.styleSheets,n=0,r=e.length;n=0){var n=document.createTextNode(e),r=this.nodes[t];return this.element.insertBefore(n,r||null),this.length++,!0}return!1},e.deleteRule=function(t){this.element.removeChild(this.nodes[t]),this.length--},e.getRule=function(t){return t0&&(l+=t+",")}),r+=""+s+c+'{content:"'+l+'"}/*!sc*/\n'}}}return r}(this)},t}(),Z=/(a)(d)/gi,X=function(t){return String.fromCharCode(t+(t>25?39:97))};function Q(t){var e,n="";for(e=Math.abs(t);e>52;e=e/52|0)n=X(e%52)+n;return(X(e%52)+n).replace(Z,"$1-$2")}var K=function(t,e){for(var n=e.length;n;)t=33*t^e.charCodeAt(--n);return t},J=function(t){return K(5381,t)};function tt(t){for(var e=0;e>>0);if(!e.hasNameForId(r,a)){var s=n(o,"."+a,void 0,r);e.insertRules(r,a,s)}i.push(a),this.staticRulesId=a}else{for(var c=this.rules.length,l=K(this.baseHash,n.hash),p="",d=0;d>>0);if(!e.hasNameForId(r,h)){var g=n(p,"."+h,void 0,r);e.insertRules(r,h,g)}i.push(h)}}return i.join(" ")},t}(),rt=/^\s*\/\/.*$/gm,it=[":","[",".","#"];function ot(t){var e,n,r,i,o=void 0===t?v:t,a=o.options,s=void 0===a?v:a,c=o.plugins,l=void 0===c?w:c,d=new p(s),u=[],m=function(t){function e(e){if(e)try{t(e+"}")}catch(t){}}return function(n,r,i,o,a,s,c,l,p,d){switch(n){case 1:if(0===p&&64===r.charCodeAt(0))return t(r+";"),"";break;case 2:if(0===l)return r+"/*|*/";break;case 3:switch(l){case 102:case 112:return t(i[0]+r),"";default:return r+(0===d?"/*|*/":"")}case-2:r.split("/*|*/}").forEach(e)}}}(function(t){u.push(t)}),f=function(t,r,o){return 0===r&&-1!==it.indexOf(o[n.length])||o.match(i)?t:"."+e};function h(t,o,a,s){void 0===s&&(s="&");var c=t.replace(rt,""),l=o&&a?a+" "+o+" { "+c+" }":c;return e=s,n=o,r=new RegExp("\\"+n+"\\b","g"),i=new RegExp("(\\"+n+"\\b){2,}"),d(a||!o?"":o,l)}return d.use([].concat(l,[function(t,e,i){2===t&&i.length&&i[0].lastIndexOf(n)>0&&(i[0]=i[0].replace(r,f))},m,function(t){if(-2===t){var e=u;return u=[],e}}])),h.hash=l.length?l.reduce(function(t,e){return e.name||_(15),K(t,e.name)},5381).toString():"",h}var at=e().createContext(),st=(at.Consumer,e().createContext()),ct=(st.Consumer,new V),lt=ot();function pt(){return(0,t.useContext)(at)||ct}function dt(){return(0,t.useContext)(st)||lt}function ut(n){var r=(0,t.useState)(n.stylisPlugins),i=r[0],o=r[1],a=pt(),s=(0,t.useMemo)(function(){var t=a;return n.sheet?t=n.sheet:n.target&&(t=t.reconstructWithOptions({target:n.target},!1)),n.disableCSSOMInjection&&(t=t.reconstructWithOptions({useCSSOMInjection:!1})),t},[n.disableCSSOMInjection,n.sheet,n.target]),c=(0,t.useMemo)(function(){return ot({options:{prefix:!n.disableVendorPrefixes},plugins:i})},[n.disableVendorPrefixes,i]);return(0,t.useEffect)(function(){l()(i,n.stylisPlugins)||o(n.stylisPlugins)},[n.stylisPlugins]),e().createElement(at.Provider,{value:s},e().createElement(st.Provider,{value:c},n.children))}var mt=function(){function t(t,e){var n=this;this.inject=function(t,e){void 0===e&&(e=lt);var r=n.name+e.hash;t.hasNameForId(n.id,r)||t.insertRules(n.id,r,e(n.rules,r,"@keyframes"))},this.toString=function(){return _(12,String(n.name))},this.name=t,this.id="sc-keyframes-"+t,this.rules=e}return t.prototype.getName=function(t){return void 0===t&&(t=lt),this.name+t.hash},t}(),ft=/([A-Z])/,ht=/([A-Z])/g,gt=/^ms-/,xt=function(t){return"-"+t.toLowerCase()};function yt(t){return ft.test(t)?t.replace(ht,xt).replace(gt,"-ms-"):t}var bt=function(t){return null==t||!1===t||""===t};function wt(t,e,n,r){if(Array.isArray(t)){for(var i,o=[],a=0,s=t.length;a1?e-1:0),r=1;r?@[\\\]^`{|}~-]+/g,$t=/(^-|-$)/g;function jt(t){return t.replace(Ct,"-").replace($t,"")}var At=function(t){return Q(J(t)>>>0)};function Et(t){return"string"==typeof t&&!0}var _t=function(t){return"function"==typeof t||"object"==typeof t&&null!==t&&!Array.isArray(t)},It=function(t){return"__proto__"!==t&&"constructor"!==t&&"prototype"!==t};function Tt(t,e,n){var r=t[n];_t(e)&&_t(r)?Lt(r,e):t[n]=e}function Lt(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r=0||(i[n]=t[n]);return i}(r,["componentId"]),o=e&&e+"-"+(Et(t)?t:jt(S(t)));return Dt(t,x({},n,{attrs:h,componentId:o}),i)},Object.defineProperty(b,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(t){this._foldedDefaultProps=o?Lt({},n.defaultProps,t):t}}),Object.defineProperty(b,"toString",{value:function(){return"."+b.styledComponentId}}),a&&g()(b,n,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0,withComponent:!0}),b}var zt=function(t){return function t(e,n,r){if(void 0===r&&(r=v),!(0,s.isValidElementType)(n))return _(1,String(n));var i=function(){return e(n,r,kt.apply(void 0,arguments))};return i.withConfig=function(i){return t(e,n,x({},r,{},i))},i.attrs=function(i){return t(e,n,x({},r,{attrs:Array.prototype.concat(r.attrs,i).filter(Boolean)}))},i}(Dt,t)};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","textPath","tspan"].forEach(function(t){zt[t]=zt(t)});var Mt,Pt=function(){function t(t,e){this.rules=t,this.componentId=e,this.isStatic=tt(t),V.registerId(this.componentId+1)}var e=t.prototype;return e.createStyles=function(t,e,n,r){var i=r(wt(this.rules,e,n,r).join(""),""),o=this.componentId+t;n.insertRules(o,o,i)},e.removeStyles=function(t,e){e.clearRules(this.componentId+t)},e.renderStyles=function(t,e,n,r){t>2&&V.registerId(this.componentId+t),this.removeStyles(t,n),this.createStyles(t,e,n,r)},t}();function Bt(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r"+e+""},this.getStyleTags=function(){return t.sealed?_(2):t._emitSheetCSS()},this.getStyleElement=function(){var n;if(t.sealed)return _(2);var r=((n={})[$]="",n["data-styled-version"]="5.3.11",n.dangerouslySetInnerHTML={__html:t.instance.toString()},n),i=G();return i&&(r.nonce=i),[e().createElement("style",x({},r,{key:"sc-0-0"}))]},this.seal=function(){t.sealed=!0},this.instance=new V({isServer:!0}),this.sealed=!1}.prototype).collectStyles=function(t){return this.sealed?_(2):e().createElement(ut,{sheet:this.instance},t)},Mt.interleaveWithNodeStream=function(t){return _(3)};const Nt=zt;var Gt=i(848);const Ut="#ffffff",Ft=Nt.div` background: ${Ut}; color: #000; padding: 10px; display: flex; justify-content: space-between; align-items: center; position: relative; &::after { content: ""; /* 偽元素必須要有 content 屬性 */ display: block; /* 線的樣式 */ height: 1px; background-color: #d9d9d9; /* 寬度和定位 */ width: 95%; /* 設定為總寬度的 90% */ position: absolute; bottom: 0; /* 讓線貼齊 Header 的底部 */ left: 50%; /* 將線的左邊緣移到 Header 中間 */ transform: translateX(-50%); /* 將線向左移動其自身寬度的一半,實現置中 */ } `,Yt=Nt.div` display: flex; align-items: center; gap: 12px; `,Wt=Nt.div` position: relative; img { width: 40px; height: 40px; object-fit: contain; } /* 為不同動畫狀態添加特效 */ &.talking img { animation: pulse 1s ease-in-out infinite; } &.nodding img { animation: nod 0.8s ease-in-out; } &.thinking img { animation: glow 2s ease-in-out infinite; } @keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } } @keyframes nod { 0%, 100% { transform: translateY(0); } 25% { transform: translateY(-2px); } 75% { transform: translateY(2px); } } @keyframes glow { 0%, 100% { box-shadow: 0 0 0 rgba(105, 227, 109, 0); } 50% { box-shadow: 0 0 15px rgba(105, 227, 109, 0.5); } } `,Ht=Nt.div` .user-name { font-weight: 400; font-size: 16px; letter-spacing: 0.8px; } .user-status { font-size: 14px; font-weight: 480; display: flex; align-items: center; gap: 4px; } `,qt=Nt.button` width: 32px; height: 32px; border-radius: 50%; border: none; background: transparent; color: ${Ut}; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; &:hover { background: rgba(255, 255, 255, 0.1); } svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; } `,Vt=Nt.div` display: flex; gap: ${"8px"}; align-items: center; `,Zt=Nt(qt)` display: none; /* 桌面端隐藏 */ @media (max-width: 600px) { display: flex; /* 移动端显示 */ } svg { width: 15px; height: 15px; } &:hover { opacity: 0.7; } `,Xt=e=>{let{onReset:n,onClose:r,onBackgroundChange:i,currentBackground:o,animationState:a="idle",isAiTyping:s=!1}=e;const[c,l]=(0,t.useState)(!1),[p,d]=(0,t.useState)("idle");return(0,t.useEffect)(()=>{s?d("thinking"):a&&d(a)},[s,a]),(0,Gt.jsxs)(Ft,{children:[(0,Gt.jsxs)(Yt,{children:[(0,Gt.jsx)(Wt,{className:p,children:(0,Gt.jsx)("img",{src:"https://cdn.prod.website-files.com/64420a3911d6832c7ba8b105/6a0ec52bb9a94d62edd21060_Aire-body%20(1)-%E8%BD%89%E6%AA%94%E5%89%8D%E6%A0%BC%E5%BC%8F-%E7%82%BA-png.webp",alt:"Aire",onLoad:()=>{"undefined"!=typeof window&&window.__AIZEN_DEBUG__},onError:t=>{}})}),(0,Gt.jsx)(Ht,{children:(0,Gt.jsx)("div",{className:"user-name",children:"Aire"})})]}),(0,Gt.jsxs)(Vt,{children:[(0,Gt.jsx)(qt,{onClick:n,title:"重新開始對話",children:(0,Gt.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,Gt.jsx)("path",{d:"M13.1306 1.87308V0.915948C13.1306 0.826703 13.2968 0.554957 13.3741 0.484764C13.927 -0.0211245 14.6836 0.363431 14.7415 1.10246C14.8148 2.04404 14.6836 3.07939 14.7405 4.0315C14.6886 4.4321 14.4106 4.71137 14.0109 4.76351C13.0328 4.69683 11.9419 4.85125 10.9772 4.76501C10.2012 4.69532 9.99964 3.64795 10.6629 3.28345C10.6993 3.26339 10.8465 3.18718 10.8665 3.18718H12.158C12.1814 3.09844 12.135 3.12351 12.1101 3.10145C9.78505 1.01823 6.05826 1.13455 3.75472 3.18618C0.246009 6.31176 1.16573 12.048 5.4709 13.8896C9.51457 15.6193 14.1286 12.7775 14.3682 8.38645C14.3926 7.93873 14.2434 7.16209 14.44 6.80712C14.8168 6.12725 15.8264 6.3614 15.9342 7.15006C16.54 11.5707 12.8791 15.7366 8.51052 15.9858C1.38081 16.3929 -2.72275 7.94524 2.06998 2.62313C4.92795 -0.550077 9.87388 -0.898031 13.1306 1.87308Z",fill:"#2C2C2B"})})}),(0,Gt.jsx)(Zt,{onClick:r,title:"關閉聊天",children:(0,Gt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",children:[(0,Gt.jsx)("path",{d:"M0.899689 0.849609L13.8995 13.8496",stroke:"#2C2C2B",strokeWidth:"1.75",strokeLinecap:"round"}),(0,Gt.jsx)("path",{d:"M13.8995 0.849609L0.899655 13.8496",stroke:"#2C2C2B",strokeWidth:"1.75",strokeLinecap:"round"})]})})]})]})},Qt=e().memo(Xt),Kt="#0073DF",Jt="#ffffff",te="#f8f9fa",ee="#e5e7eb",ne="#F6F6F6",re="#A3A3A3",ie="#6b7280",oe=" #2C2C2B",ae="4px",se="8px",ce="12px",le="13px",pe="16px",de="20px",ue=Bt` 0% { opacity: 0; transform: translateY(0px); } 100% { opacity: 1; transform: translateY(0px); } `,me=Bt` 0% { opacity: 0; transform: translateY(0px); } 100% { opacity: 1; transform: translateY(0); } `,fe=((function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;ot.$hide?"none":"block"}; background: transparent !important; background-color: transparent !important; /* 🛡️ 樣式隔離:防止外部濾鏡或混合模式污染 */ isolation: isolate !important; color-scheme: light !important; @media (max-width: 600px) { position: fixed !important; bottom: 20px !important; right: 15px !important; left: auto !important; top: auto !important; width: auto !important; height: auto !important; margin: 0 !important; padding: 0 !important; pointer-events: none !important; /* 🎯 關閉時不攔截點擊,防止干擾輸入框 */ overscroll-behavior: auto !important; touch-action: auto; /* 🎯 關閉時不阻擋 Webflow 背景頁面滑動 */ /* 🎯 只有在開啟時才恢復攔截點擊 */ ${t=>t.$isOpen&&kt` inset: 0 !important; width: 100% !important; height: 100% !important; pointer-events: auto !important; touch-action: none !important; background: transparent !important; /* 🎯 這裡原本會帶有 $background 或 #fff 白色背景,導致 Android Chrome 彈出時閃爍白底。改為完全透明,讓 ChatWindow 自己的背景負責渲染就好 */ `} } `),he=Nt.button` width: 45px !important; height: 45px !important; border-radius: 50% !important; background-color: ${t=>t.isOpen?Kt:"transparent"} !important; background: ${t=>t.isOpen?Kt:"transparent"} !important; border: none !important; cursor: pointer !important; transition: all 0.3s ease !important; display: flex !important; align-items: center !important; justify-content: center !important; position: relative !important; overflow: visible !important; bottom: -5px !important; right: 0px !important; /* 🎯 恢復為 0,讓容器回歸預設位置 */ z-index: 10 !important; padding: 0 !important; box-shadow: ${t=>t.isOpen?"0 4px 12px rgba(0,0,0,0.15)":"none"} !important; pointer-events: auto !important; /* 🎯 確保按鈕可點擊 */ svg { width: 24px !important; height: 24px !important; display: block !important; } /* 🍎 iOS 特殊重置 */ -webkit-tap-highlight-color: transparent !important; -webkit-appearance: none !important; appearance: none !important; outline: none !important; box-shadow: none !important; filter: none !important; -webkit-filter: none !important; /* 🚀 強制開啟乾淨的 GPU 層,避免渲染殘影 */ transform: translate3d(0, 0, 0) !important; -webkit-transform: translate3d(0, 0, 0) !important; backface-visibility: hidden !important; -webkit-backface-visibility: hidden !important; @media (max-width: 600px) { &.active { display: none !important; } } `,ge=Nt.div` position: absolute; bottom: 28px; right: -28px; opacity: ${t=>t.show?1:0}; transform: ${t=>t.show?"translateY(0)":"translateY(10px)"}; transition: transform 0.3s ease, opacity 0.3s ease, right 0.3s ease, bottom 0.3s ease; pointer-events: ${t=>t.show?"auto":"none"}; z-index: 5; @media (max-width: 600px) { right: 72px; /* 🎯 長句時 bottom: 21px, 短句時維持 10px */ bottom: ${t=>t.$isLong?"-42px":"-40px"}; max-width: 260px; /* 讓 SVG 泡泡能完整顯示 */ } `,xe=(Nt.div` display: none; @media (max-width: 600px) { display: ${t=>t.show?"block":"none"}; position: fixed; bottom: 0; left: 0; width: 100%; height: ${t=>t.$isLong?"160px":"120px"}; /* 🎯 根據字數調整高度 */ background-image: ${t=>`url(${t.$bgImage})`}; background-size: 100% 100%; /* 🎯 強制填滿高度與寬度,展現完整漸層 */ background-position: bottom; background-repeat: no-repeat; z-index: -1; /* 確保在所有內容最底層 */ pointer-events: none; opacity: ${t=>t.show?1:0}; transition: opacity 0.3s ease; } `,Nt.div` position: relative; display: inline-flex; align-items: center; gap: 0; right: 20px; /* ✅ 移除 gap,改用絕對定位讓按鈕在左側外面 */ bottom: 32px; /* ✅ 桌機:close 按鈕在左側外面,只有 hover 時才顯示 */ /* ClosePromptButton 放在左側外面 */ > button { position: absolute; left: -5px; /* 在泡泡左邊外側 */ top: 20%; transform: translateY(-5%); } &:hover > button, &:focus-within > button { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; } @media (max-width: 600px) { position: relative; top: auto; right: -5px; /* 覆寫桌機的 bottom:32px。父層 PromptWrapper 高度常為 0,若同時設 top+bottom 會被算成極小高度(Safari 約 3px),從綠界返回後更易錯位 */ bottom: 32px !important; height: auto; font-size: 13px; padding: 0; /* 移除 padding,改由 PromptText 控制 */ white-space: normal; max-width: 260px; /* 讓 SVG 泡泡能完整顯示 */ min-width: 249px; width: auto; gap: 8px; /* 手機版保留 gap */ /* ✅ 右边对齐,文字增加時往左擴展 */ margin-left: auto; left: auto; > button { position: absolute; left: 0px; /* 在泡泡左邊外側 */ top: 0%; transform: translateY(0%); } /* ✅ 移除 ::after 小三角,改用 PromptText 的 SVG 背景(已包含箭頭) */ } `),ye=Nt.div` display: flex !important; flex-direction: column !important; align-items: center !important; justify-content: center !important; text-align: flex-start !important; line-height: 1.5 !important; color: #000000 !important; font-weight: 400 !important; font-family: "Noto Sans TC", sans-serif !important; font-size: 15px !important; width: fit-content !important; max-width: 280px !important; min-width: 217px !important; min-height: 56px !important; height: auto !important; box-sizing: border-box !important; padding: 15px !important; background: #ffffff !important; border-radius: 18px !important; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important; position: relative !important; /* 🎯 桌機版泡泡尾巴 (指向底部的機器人圖標) */ &::after { content: "" !important; position: absolute !important; bottom: -10px !important; right: 26px !important; width: 20px !important; height: 15px !important; background: #ffffff !important; clip-path: polygon(0 0, 100% 0, 50% 100%) !important; } /* ✅ 手機版適配 */ @media (max-width: 600px) { width: 217px !important; max-width: 255px !important; min-height: ${t=>t.$isLong?"46px !important":"21px !important"}; /* 手機版尾巴:長句時靠下,短句時垂直居中 */ &::after { right: -10px !important; top: ${t=>t.$isLong?"auto !important":"50% !important"}; bottom: ${t=>t.$isLong?"18px !important":"auto !important"}; transform: ${t=>t.$isLong?"none !important":"translateY(-50%) !important"}; width: 15px !important; height: 20px !important; clip-path: polygon(0 0, 0 100%, 100% 50%) !important; } } `,be=Nt.button` width: 24px !important; height: 24px !important; min-width: 24px !important; min-height: 24px !important; border-radius: 50% !important; border: none !important; cursor: pointer !important; background-color: #ffffff !important; color: #111827 !important; /* svg stroke="currentColor" */ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important; transition: all 0.2s ease !important; display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 !important; flex-shrink: 0 !important; position: relative !important; z-index: 10 !important; /* ✅ 手機版強制顯示 */ @media (max-width: 1024px) { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; } /* ✅ 桌機預設隱藏(hover PromptBubble 才出現) */ @media (min-width: 1025px) { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; } svg { width: 20px !important; height: 20px !important; display: block !important; } `,we=Nt.div` width: 100% !important; height: 100% !important; display: flex !important; justify-content: center !important; align-items: center !important; position: relative !important; z-index: 999 !important; /* left: -15px; <-- 🎯 找到元兇!這行會讓內容往左偏移 15px */ background: transparent !important; background-color: transparent !important; overflow: visible !important; pointer-events: none !important; img { width: 135px !important; height: 135px !important; max-width: none !important; max-height: none !important; object-fit: contain !important; border-radius: 0% !important; display: block !important; position: absolute !important; top: 25% !important; left: 5% !important; transform: translate(-35%, -40%) !important; background: transparent !important; background-color: transparent !important; border: none !important; box-shadow: none !important; will-change: auto !important; } `,ve=Nt.div` position: fixed; bottom: 78px; right: 15px; width: 354px; height: calc(90vh - 100px); max-height: 583px; background: ${t=>t.background||Jt}; border-radius: 18px; box-shadow: ${"0 8px 32px rgba(0, 0, 0, 0.15)"}; display: flex; flex-direction: column; overflow: hidden; z-index: 99999; transform-origin: bottom right; /* 🎯 从右下角展开/收起 */ /* 🎬 收放动画效果 */ opacity: ${t=>t.isOpen?"1":"0"}; transform: ${t=>t.isOpen?"scale(1) translateY(0)":"scale(0.85) translateY(20px)"}; visibility: ${t=>t.isOpen?"visible":"hidden"}; pointer-events: ${t=>t.isOpen?"auto":"none"}; /* 🎯 关闭时禁用交互 */ transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease; @media (max-width: 600px) { position: fixed; /* 🎯 恢復為 fixed 以配合 overscroll-behavior */ inset: 0; width: 100%; height: 100%; max-height: none; bottom: 0; right: 0; border-radius: 0; box-shadow: none; transform-origin: center bottom; /* 🎯 移动端从底部展开/收起 */ overscroll-behavior: none; /* 🎯 防止橡皮筋效果 */ /* 🎬 移动端收放动画(从底部滑入/滑出) */ transform: ${t=>t.isOpen?"translateY(0)":"translateY(100%)"}; } `,ke=Nt.div` padding: 0px ${le} ${ce} ${le}; background: #ffff; display: flex; align-items: center; position: relative; /* 🎯 填補 Android Chrome 鍵盤彈出/收起時的微小高度跳動,並保留原本的底部間距 */ @media (max-width: 600px) { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important; } `,Se=Nt.input` flex: 1; padding: ${pe} 92px ${pe} 16px; border: 1px solid ${re}; border-radius: 18px; font-size: 16px; outline: none; `,Ce=Nt.button` background-color: transparent; display: flex; align-items: center; border-radius: 50%; position: absolute; right: 26px; top: 50%; transform: translateY(-50%) scale(1); scale: 1.4; border: none; color: ${Kt}; cursor: pointer; opacity: 1; transition: all 0.2s ease; `,$e=Nt.div` margin-bottom: ${t=>t.isLastMessage?t.isUser?"34px !important":"10px !important":t.isUser?"46px":"infoCards"===t.$messageType&&t.message?.isSplitInfo&&!t.message?.isLastSplit?"6px !important":"10px !important"}; margin-top: ${t=>t.isUser?"34px":"0px"}; text-align: ${t=>t.isUser?"right":"left"}; `,je=Nt.div` display: flex; align-items: flex-end; /* 🎯 统一对齐到底部,确保所有消息类型的底部在同一基准线 */ gap: ${t=>(t.isHorizontalCards,se)}; justify-content: ${t=>t.isUser?"flex-end":"flex-start"}; width: ${t=>"100%"}; position: relative; /* 🎯 互動模式切換: - 未回覆前:padding 為 0,頭像緊貼氣泡(流動模式)。 - 回覆後:套用您確定的 22px 地板(固定模式)。 - 如果是最後一則訊息:padding 為 0,讓 ChatContent 的 padding-bottom (12px) 決定距離。 */ ${t=>!t.isUser&&"\n margin: 0 !important;\n padding: 0 !important;\n "} `,Ae=Nt.div` display: flex; flex-direction: column; /* 🎯 根據發送者對齊,確保 User 訊息靠右,Bot 訊息靠左 */ align-items: ${t=>t.isUser?"flex-end":"flex-start"}; flex: 1; margin: 0; padding: 0; /* 🎬 讓機器人訊息平滑向上湧出 */ ${t=>t.isUser?"":kt` opacity: 0; ${t.$isOpen&&kt` animation: ${ue} 4s cubic-bezier(0.22, 1, 0.36, 1) forwards; `} `} `,Ee=Nt.div` width: 26px; height: 26px; flex-shrink: 0; margin: 0 !important; padding: 0 !important; align-self: flex-end; position: relative; /* 🎯 對齊氣泡底部 */ bottom: 0px; z-index: 10; /* 🎯 根據接力邏輯控制顯示 */ visibility: ${t=>t.show?"visible":"hidden"}; opacity: ${t=>t.show?1:0}; transform: ${t=>t.show?"translateY(0)":"translateY(0px)"}; ${t=>t.show&&t.$isOpen&&kt` opacity: 1; `} /* 🎯 關鍵:當訊息是 infoCards 時,讓頭像跟著最後一張卡片一起浮現 */ ${t=>"infoCards"===t.$messageType&&t.show?`\n opacity: 0;\n animation: avatarRiseIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important;\n /* 延遲時間計算:(卡片總數 - 1) * 0.5s 延遲 */\n animation-delay: ${.5*(t.$itemCount-1)}s !important;\n /* 🎯 重要:both 確保在延遲期間維持 0% 的狀態(即隱藏) */\n animation-fill-mode: both !important;\n @keyframes avatarRiseIn {\n 0% {\n opacity: 0;\n transform: translateY(0px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0px);\n }\n }\n `:""} img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; background: white; } `,_e=Nt.div` position: absolute; left: 12px; /* 對齊 ChatContent 的內邊距 */ bottom: 10px; /* 🎯 修正:從 16px 降為 10px,補平與 MessageAvatar 的 6px 落差 (82px -> 76px) */ width: 26px; height: 26px; border-radius: 50%; overflow: hidden; z-index: 1000; pointer-events: none; background: white; opacity: 0; visibility: ${t=>t.show?"visible":"hidden"}; transform: ${t=>t.show?"translateY(0)":"translateY(0px)"}; ${t=>t.show&&kt` animation: ${me} 4s cubic-bezier(0.22, 1, 0.36, 1) 0s forwards; `} img { width: 100%; height: 100%; object-fit: cover; } @media (max-width: 600px) { bottom: 10px; /* 🎯 手機版同步修正 */ left: 12px; } `,Ie=(Nt.div` height: 10px; margin-top: 5px; opacity: 0; pointer-events: none; visibility: hidden; `,Nt.div` display: inline-block; max-width: 240px; /* 🎯 稍微調整為 240px,確保「時光」能留在同一行,同時維持緊湊感 */ padding: 12px 14px; border-radius: 18px; /* 基礎圓角 */ font-size: 14px; line-height: 150%; letter-spacing: 0.28px; margin: 0; /* 🎯 統一底部對齊,移除 margin */ font-weight: 400; word-wrap: break-word; background: ${t=>t.isUser?Kt:ne}; color: ${t=>t.isUser?Jt:oe}; white-space: pre-wrap; word-break: break-all; /* 🎯 確保中文換行更靈活 */ text-align: left; @media (max-width: 600px) { max-width: 280px; margin: 0; } @media (max-width: 375px) { max-width: 240px; margin: 0; } /* ======================================= ✨ 連續訊息的邊角樣式優化 (核心修改部分) ======================================= */ ${t=>{const e="0px",n="9px",r=!t.isFirstInGroup||!t.isLastInGroup;return t.isUser?`\n border-radius: ${n} ${n} ${e} ${n};\n `:r?t.isFirstInGroup&&!t.isLastInGroup?`\n border-radius: ${n} ${n} ${n} ${e};\n `:!t.isFirstInGroup&&t.isLastInGroup?`\n border-radius: ${e} ${n} ${n} ${n};\n `:t.isFirstInGroup||t.isLastInGroup?`border-radius: ${n};`:`\n border-radius: ${e} ${n} ${n} ${e};\n `:`border-radius:${n} ${n} ${n} ${e};`}} `),Te=Nt.div` flex: 1; position: relative; display: flex; flex-direction: column; overflow: hidden; `,Le=Nt.div` flex: 1; padding: 12px 12px 0 12px; overflow-y: auto; overflow-x: hidden; background: #ffff; position: relative; @media (max-width: 600px) { padding: 12px 12px 0 12px; overscroll-behavior: contain; /* 🎯 允許內部捲動但防止橡皮筋傳遞 */ -webkit-overflow-scrolling: touch; } &::-webkit-scrollbar { width: 4px; } &::-webkit-scrollbar-track { background: transparent; } &::-webkit-scrollbar-thumb { background: ${ee}; border-radius: 2px; } `,Re=Nt.div` margin-bottom: 0px; display: flex; flex-direction: column; gap: 0px !important; `,Oe=Nt.div` display: flex; align-items: center; gap: ${ae}; padding: 8px 8px; border-radius: 9px 9px 9px 0px; `,De=Nt.span` width: 6px; height: 6px; background: #7b7b7b; border-radius: 50%; opacity: 0.5; animation: typing-bounce 1s infinite alternate; &:nth-child(2) { animation-delay: 0.2s; } &:nth-child(3) { animation-delay: 0.4s; } @keyframes typing-bounce { 0% { opacity: 0.5; transform: translateY(0); } 100% { opacity: 1; transform: translateY(-3px); } } `,ze=Nt.div` display: flex; flex-direction: column; gap: ${se}; margin: 0; /* ✅ 移除 margin 确保头像对齐 */ align-items: flex-start; /* 🎬 整組按鈕一起進場動畫 */ opacity: 0; transform: translateY(10px); animation: suggestionGroupSlideIn 1s ease forwards; @keyframes suggestionGroupSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateX(0); } } `,Me=Nt.div` display: flex; align-items: center; padding: 5px 16px; font-size: 14px; color: ${Kt}; background: ${Jt}; border: 1px solid ${Kt}; border-radius: 999px; cursor: pointer; transition: all 0.2s ease; font-weight: 400; white-space: nowrap; line-height: 150%; /* 21px */ letter-spacing: 0.28px; &:hover { background: ${Kt}; color: ${Jt}; } &:active { background: ${Kt}; color: ${Jt}; } `,Pe=Nt.div` display: flex; align-items: center; justify-content: center; margin: 0px 12px 12px 12px; /* 🎯 移除頂部 margin,讓 ChatContent 的 12px padding 決定距離 */ text-align: center; `,Be=Nt.div` color: ${re}; border-radius: 12px; font-size: 12px; font-weight: 500; `,Ne=Nt.div` display: flex; flex-direction: column; align-items: center; justify-content: center; padding: ${de}; gap: ${ce}; `,Ge=Nt.div` color: ${ie}; font-size: 14px; `,Ue=(Nt.button` display: block; width: calc(100% - 24px); margin: ${ce} ${ce} 0 ${ce}; padding: ${ce}; background: ${Jt}; border: 1px solid ${ee}; border-radius: 8px; color: ${Kt}; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; gap: ${se}; &:hover { background: ${te}; border-color: ${Kt}; } &:disabled { cursor: not-allowed; opacity: 0.6; } svg { animation: ${t=>t.isLoading?"spin 1s linear infinite":"none"}; } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } `,e=>{let{onSend:n}=e;const[r,i]=(0,t.useState)(""),o=t=>{if(t&&t.preventDefault(),r.trim()){n(r),i("");const t=document.activeElement;t&&"INPUT"===t.tagName&&/android/i.test(navigator.userAgent)&&t.focus()}};return(0,Gt.jsxs)(ke,{"data-chat-input-container":"true",children:[(0,Gt.jsx)(Se,{value:r,onChange:t=>i(t.target.value),onKeyPress:t=>"Enter"===t.key&&o(),placeholder:"輸入你想改善的情況..."}),(0,Gt.jsx)(Ce,{visible:r.trim(),onClick:o,onPointerDown:t=>t.preventDefault(),children:r.trim()?(0,Gt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"23",height:"23",viewBox:"0 0 26 26",fill:"none",children:[(0,Gt.jsx)("rect",{width:"26",height:"26",rx:"13",fill:"#2783DE"}),(0,Gt.jsx)("path",{d:"M18.5963 7.00834C19.3413 6.92406 19.9823 7.48924 20 8.2182C18.6343 12.5728 17.0789 16.8762 15.6336 21.2091C15.2593 22.2426 13.7127 22.2691 13.3 21.2539L11.0071 15.4691L4.6349 13.3248C3.70677 12.8326 3.82488 11.5281 4.80212 11.1788L18.5963 7.00834Z",fill:"white"})]}):(0,Gt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"23",height:"23",viewBox:"0 0 26 26",fill:"none",children:[(0,Gt.jsx)("rect",{width:"26",height:"26",rx:"13",fill:"#D9D9D9"}),(0,Gt.jsx)("path",{d:"M18.5963 7.00834C19.3413 6.92406 19.9823 7.48924 20 8.2182C18.6343 12.5728 17.0789 16.8762 15.6336 21.2091C15.2593 22.2426 13.7127 22.2691 13.3 21.2539L11.0071 15.4691L4.6349 13.3248C3.70677 12.8326 3.82488 11.5281 4.80212 11.1788L18.5963 7.00834Z",fill:"white"})]})})]})}),Fe=Nt.div` position: relative !important; /* 🎯 貼合左邊邊界核心:抵銷 parent padding (16px) + 頭像寬度 (32px) + 間距 (8px) = 56px */ width: 100% !important; /* 56px 左偏移 + 16px 右 padding */ max-width: 472px !important; height: 220px !important; margin: 0 !important; margin-left: -56px !important; /* 🎯 往左推到邊界 */ padding: 0 !important; box-sizing: border-box !important; -webkit-tap-highlight-color: transparent !important; /* 🍎 移除 iOS 点击高亮 */ user-select: none !important; /* 🚫 防止文字選擇,提升拖動體驗 */ overflow: visible !important; /* ✅ 改為 visible 让按钮完全显示 */ /* 🎬 整个轮播组件进场动画 */ opacity: 0; transform: translateY(10px); animation: messageSlideIn 0.5s ease forwards; @keyframes messageSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } @media (max-width: 600px) { width: 100vw !important; /* 🎯 移動版:直接使用視窗寬度 */ max-width: 100vw !important; /* 🎯 移動版:限制為視窗寬度,防止溢出 */ height: 220px !important; /* ✅ 移動版也增加高度 */ margin-left: -56px !important; /* 🎯 移動端也要貼邊 */ padding: 0 !important; /* ✅ 移除 padding,讓 Viewport 佔滿全寬 */ } `,Ye=Nt.div` position: relative !important; width: 100% !important; height: 100% !important; /* 🎯 填满父容器 */ overflow-x: auto !important; overflow-y: hidden !important; -webkit-overflow-scrolling: touch !important; overscroll-behavior-x: contain !important; padding: 0 !important; box-sizing: border-box !important; background: transparent !important; /* 🎯 確保背景透明 */ touch-action: pan-x pan-y !important; /* ⛔ Hide horizontal scrollbar (ALL platforms) */ scrollbar-width: none; /* Firefox */ -ms-overflow-style: none; /* IE / legacy Edge */ &::-webkit-scrollbar { display: none; /* Chrome / Safari / iOS */ } `,We=Nt.div` display: flex !important; padding-left: 56px !important; /* 🎯 初始狀態對齊訊息文字 (抵銷 56px 負偏移) */ padding-right: 102px !important; gap: 10px !important; box-sizing: border-box !important; width: max-content !important; @media (max-width: 600px) { padding-right: 40px !important; } `,He=Nt.div` position: absolute !important; width: auto !important; min-width: 82px !important; height: 26px !important; top: 0px !important; left: 0px !important; background-color: #000 !important; border-radius: 900px !important; margin: 6px !important; z-index: 10 !important; box-sizing: border-box !important; display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 10px !important; /* 🚀 修正閃爍:強制開啟 GPU 加速並鎖定渲染層 */ backface-visibility: hidden !important; transform: translateZ(0) !important; -webkit-font-smoothing: antialiased !important; `,qe=Nt.div` display: flex !important; justify-content: center !important; align-items: center !important; color: white !important; font-size: 10px !important; font-weight: 700 !important; margin: 0 !important; letter-spacing: 0.5px !important; z-index: 10 !important; line-height: 1 !important; box-sizing: border-box !important; white-space: nowrap !important; /* 🚀 確保文字在滑動中不抖動 */ transform: translateZ(0) !important; `,Ve=Nt.div` background: #fff !important; border-radius: 9px !important; overflow: hidden !important; /* ✅ 1~2 張:不要用 auto 置中,確保在 mobile 也能對齊對話起點 */ margin: ${t=>t.$isSingle||t.$isStatic?"0":"0 auto"} !important; opacity: 1 !important; cursor: pointer !important; pointer-events: auto !important; position: relative !important; box-sizing: border-box !important; flex-shrink: 0 !important; width: ${t=>t.$isSingle?"100%":"158px"} !important; max-width: ${t=>t.$isSingle?"100%":"158px"} !important; min-width: ${t=>t.$isSingle?"0":"158px"} !important; transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1) !important; /* 🎯 平滑的卡片過渡 */ will-change: transform !important; /* 🚀 GPU 加速 */ /* 🚀 修正閃爍:強制開啟 3D 渲染空間與隱藏背面,避免滑動時絕對定位元素閃爍 */ transform-style: preserve-3d !important; backface-visibility: hidden !important; transform: translateZ(0) !important; /* ✅ 手機版:就算只有一張卡片,也固定卡片寬度 158px(避免單張卡片變滿版) */ @media (max-width: 600px) { width: 158px !important; max-width: 158px !important; min-width: 158px !important; } `,Ze=Nt.img` width: 158px !important; height: 158px !important; aspect-ratio: 1/1 !important; border-radius: 9px !important; display: block !important; object-fit: cover !important; box-sizing: border-box !important; backface-visibility: hidden !important; /* 🚀 防止闪烁 */ transform: translateZ(0) !important; /* 🚀 GPU 加速 */ `,Xe=Nt.a` display: block !important; text-decoration: none !important; color: inherit !important; cursor: pointer !important; `,Qe=Nt.div` padding: 6px 14px 5px 0px !important; box-sizing: border-box !important; `,Ke=Nt.div` display: flex !important; /* 啟用 Flexbox */ flex-direction: column !important; box-sizing: border-box !important; `,Je=Nt.div` font-size: 15px !important; font-weight: 500 !important; color: #111827 !important; line-height: 1.4 !important; margin: 0 !important; padding: 0 !important; `,tn=Nt.a` width: 100% !important; height: auto !important; font-weight: 300 !important; color: #7b7b7b !important; text-decoration: none !important; font-size: 13px !important; line-height: 1.4 !important; display: block !important; margin: 0 !important; padding: 0 !important; `,en=Nt.button` position: absolute !important; top: 40% !important; transform: translateY(-50%) !important; width: 43px !important; height: 100% !important; background-color: transparent !important; border-color: transparent !important; border: none !important; cursor: pointer !important; z-index: 10 !important; transition: all 0.2s ease !important; padding: 0 !important; margin: 0 !important; ${t=>t.isNext?"\n /* 🎯 電腦版:鎖定在 354px 寬度區域內 (56px 偏移 + 354px 寬 - 約 45px 按鈕寬) */\n left: auto !important;\n right: 60px !important;\n ":"left: 15px !important;"} @media (max-width: 600px) { /* 📱 手機版:維持原本相對右側定位,因為手機版通常是滿版 100vw */ ${t=>t.isNext?"right: 0px !important; left: auto !important;":"left: 15px !important;"} } `,nn=e=>{let{items:n,onQuickAction:r}=e;const i=(0,t.useRef)(null),o=t=>{const e=i.current;if(!e)return;const n=e.scrollWidth-e.clientWidth,r=Math.min(Math.max(0,e.scrollLeft),n);let o=0;o=t<0?Math.max(168*t,-r):Math.min(168*t,n-r),e.scrollBy({left:o,behavior:"smooth"})},[a,s]=(0,t.useState)({});(0,t.useEffect)(()=>{s({})},[n]);const c=n?.length||0,l=1===c,p=c>=2,d=!p;return(0,Gt.jsxs)(Fe,{children:[p&&(0,Gt.jsx)(en,{onClick:()=>o(-1),children:(0,Gt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"43",height:"43",viewBox:"0 0 43 43",fill:"none",children:[(0,Gt.jsx)("g",{filter:"url(#filter0_dd_1345_1137)",children:(0,Gt.jsx)("circle",{cx:"21.5",cy:"20.5",r:"17.5",fill:"#D9D9D9"})}),(0,Gt.jsx)("path",{d:"M23.9746 30L25 28.9717L17.0509 21L25 13.0283L23.9746 12L15 21L23.9746 30Z",fill:"white"}),(0,Gt.jsx)("defs",{children:(0,Gt.jsxs)("filter",{id:"filter0_dd_1345_1137",x:"0",y:"0",width:"43",height:"43",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,Gt.jsx)("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),(0,Gt.jsx)("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),(0,Gt.jsx)("feOffset",{dy:"1"}),(0,Gt.jsx)("feGaussianBlur",{stdDeviation:"2"}),(0,Gt.jsx)("feComposite",{in2:"hardAlpha",operator:"out"}),(0,Gt.jsx)("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.0470588 0 0 0 0 0.0470588 0 0 0 0 0.0509804 0 0 0 0.05 0"}),(0,Gt.jsx)("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1345_1137"}),(0,Gt.jsx)("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),(0,Gt.jsx)("feOffset",{dy:"1"}),(0,Gt.jsx)("feGaussianBlur",{stdDeviation:"2"}),(0,Gt.jsx)("feComposite",{in2:"hardAlpha",operator:"out"}),(0,Gt.jsx)("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.0470588 0 0 0 0 0.0470588 0 0 0 0 0.0509804 0 0 0 0.1 0"}),(0,Gt.jsx)("feBlend",{mode:"normal",in2:"effect1_dropShadow_1345_1137",result:"effect2_dropShadow_1345_1137"}),(0,Gt.jsx)("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect2_dropShadow_1345_1137",result:"shape"})]})})]})}),(0,Gt.jsx)(Ye,{ref:i,children:(0,Gt.jsx)(We,{children:n.map((t,e)=>(0,Gt.jsxs)(Ve,{$isSingle:l,$isStatic:d,className:[a[t.id]?"entered":""].filter(Boolean).join(" "),style:{"--card-index":e},onAnimationEnd:()=>{s(e=>e[t.id]?e:{...e,[t.id]:!0})},children:[(0,Gt.jsx)(He,{children:(0,Gt.jsxs)(qe,{children:[t.tagText," · ",t.duration,"min"]})}),(0,Gt.jsx)(Xe,{onClick:e=>{e.preventDefault(),e.stopPropagation(),r&&r(t)},children:(0,Gt.jsx)(Ze,{src:t.image,alt:t.title,draggable:"false",onDragStart:t=>t.preventDefault(),style:{userSelect:"none"}})}),(0,Gt.jsx)(Qe,{children:(0,Gt.jsxs)(Ke,{children:[(0,Gt.jsx)(Je,{children:t.title}),(0,Gt.jsx)(tn,{onClick:e=>{e.preventDefault(),e.stopPropagation(),r&&r(t)},children:t.description})]})})]},t.id))})}),p&&(0,Gt.jsx)(en,{isNext:!0,onClick:()=>o(1),children:(0,Gt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"43",height:"43",viewBox:"0 0 43 43",fill:"none",children:[(0,Gt.jsx)("g",{filter:"url(#filter0_dd_1345_1140)",children:(0,Gt.jsx)("circle",{cx:"21.5",cy:"20.5",r:"17.5",fill:"#D9D9D9"})}),(0,Gt.jsx)("path",{d:"M19.0254 30L18 28.9717L25.9491 21L18 13.0283L19.0254 12L28 21L19.0254 30Z",fill:"white"}),(0,Gt.jsx)("defs",{children:(0,Gt.jsxs)("filter",{id:"filter0_dd_1345_1140",x:"0",y:"0",width:"43",height:"43",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,Gt.jsx)("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),(0,Gt.jsx)("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),(0,Gt.jsx)("feOffset",{dy:"1"}),(0,Gt.jsx)("feGaussianBlur",{stdDeviation:"2"}),(0,Gt.jsx)("feComposite",{in2:"hardAlpha",operator:"out"}),(0,Gt.jsx)("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.0470588 0 0 0 0 0.0470588 0 0 0 0 0.0509804 0 0 0 0.05 0"}),(0,Gt.jsx)("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1345_1140"}),(0,Gt.jsx)("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),(0,Gt.jsx)("feOffset",{dy:"1"}),(0,Gt.jsx)("feGaussianBlur",{stdDeviation:"2"}),(0,Gt.jsx)("feComposite",{in2:"hardAlpha",operator:"out"}),(0,Gt.jsx)("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.0470588 0 0 0 0 0.0470588 0 0 0 0 0.0509804 0 0 0 0.1 0"}),(0,Gt.jsx)("feBlend",{mode:"normal",in2:"effect1_dropShadow_1345_1140",result:"effect2_dropShadow_1345_1140"}),(0,Gt.jsx)("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect2_dropShadow_1345_1140",result:"shape"})]})})]})})]})},rn=e().memo(nn),on=Nt.div` position: relative !important; width: 100% !important; /* 🎯 占据可用宽度(会自动扣除头像空间) */ max-width: 100% !important; margin: 0 !important; /* ✅ 移除 margin 确保头像对齐 */ padding: 0 !important; box-sizing: border-box !important; overflow: hidden !important; `,an=Nt.div` position: relative !important; width: 100% !important; max-width: 100% !important; overflow-y: hidden !important; overflow-x: hidden !important; height: auto !important; /* 🎯 自动高度,根据内容调整 */ max-height: 500px !important; /* 🎯 最大高度限制 */ padding: 0 !important; box-sizing: border-box !important; `,sn=Nt.div` display: flex !important; flex-direction: column !important; gap: 6px !important; width: 100% !important; box-sizing: border-box !important; ${t=>t.animateGroup?"\n /* 🎬 整組卡片一次進場(整行/整個區塊一起出現) */\n opacity: 0;\n transform: translateY(10px);\n animation: infoCardsGroupIn 0.3s ease both;\n\n @keyframes infoCardsGroupIn {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n ":""} `,cn=Nt.div` width: 82px; height: 26px; margin-top: 2px; top: 0px; left: 0px; background-color: #000; border-radius: 900px; margin: 0px; z-index: 10; `,ln=Nt.div` display: flex; justify-content: center; align-items: center; color: white; font-size: 10px; font-weight: 700; margin: 2px; letter-spacing: 0.5px; z-index: 10; `,pn=Nt.div` background: #ffff !important; border: 0.5px solid #d9d9d9 !important; width: 100% !important; /* 🎯 占据容器全宽(约 360px,已扣除头像空间) */ width: 276px !important; /* 🎯 最大宽度限制 */ min-height: 85px !important; height: auto !important; border-radius: 9px !important; overflow: hidden !important; margin: 0 !important; cursor: pointer !important; pointer-events: auto !important; position: relative !important; box-sizing: border-box !important; box-shadow: 0 8px 8px -4px rgba(0, 0, 0, 0.1), 0 2px 2px -1px rgba(0, 0, 0, 0.05) !important; display: flex !important; /* ✨ 將卡片內部設為 Flex 容器 */ align-items: center !important; /* ✨ 垂直居中對齊圖片和內容 */ transition: transform 0.2s ease, box-shadow 0.2s ease !important; &:hover { z-index: 5 !important; box-shadow: 0 12px 16px -4px rgba(0, 0, 0, 0.15), 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important; } ${t=>t.animateItems?"\n /* 🎬 單張卡片進場(一張一張出現,間隔 0.5s) */\n opacity: 0;\n transform: translateY(20px);\n animation: infoCardRiseIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;\n animation-delay: calc(var(--card-index) * 0.5s); /* 🎯 每張卡片間隔 0.5s */\n will-change: transform, opacity;\n\n @keyframes infoCardRiseIn {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n ":"\n /* ❌ 沒有動畫時隱藏卡片 */\n opacity: 0;\n visibility: hidden;\n height: 0;\n min-height: 0;\n overflow: hidden;\n pointer-events: none;\n "} &:hover { box-shadow: 0 12px 16px -4px rgba(0, 0, 0, 0.15), 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important; } `,dn=Nt.img` width: 73px !important; height: 73px !important; min-width: 73px !important; min-height: 73px !important; margin: 6px 0px 6px 6px !important; aspect-ratio: 1/1 !important; border-radius: 9px !important; display: block !important; object-fit: cover !important; flex-shrink: 0 !important; `,un=Nt.a` display: flex; align-items: center; text-decoration: none; color: inherit; `,mn=Nt.div` padding: 9px 7px 6px 6px; `,fn=Nt.div` display: flex; /* 啟用 Flexbox */ flex-direction: column; gap: 5px; `,hn=Nt.div` display: flex; justify-content: center; height: 42px; font-size: 15px; font-weight: 500; color: #111827; `,gn=(Nt.a` width: 100%; height: auto; font-weight: 300; color: #7b7b7b; text-decoration: none; font-size: 13px; `,function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:24,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:22;return t?t.length>e?t.slice(0,n)+"......":t:""}),xn=e=>{let{items:n,animateGroup:r=!0,animateItems:i=!1,onQuickAction:o}=e;const{currentIndex:a,setCurrentIndex:s,isMobile:c,isDragging:l,dragX:p,handleDragStart:d,handleDragMove:u,handleDragEnd:m}=(()=>{const[e,n]=(0,t.useState)(0),[r,i]=(0,t.useState)(window.innerWidth<=600),[o,a]=(0,t.useState)(!1),[s,c]=(0,t.useState)(!1),[l,p]=(0,t.useState)(0),[d,u]=(0,t.useState)(0),[m,f]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>i(window.innerWidth<=600);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),{currentIndex:e,baseOffset:m,isMobile:r,isDragging:o,isClickBlocked:s,dragX:l,handleDragStart:t=>{a(!0),c(!1),u(t),p(0)},handleDragMove:(t,e,n)=>{if(!o)return;let r=t-d,i=r;const a=m+i,s=-e*n;if(a>0)i=.4*r;else if(a5&&c(!0),p(i)},handleDragEnd:(t,r)=>{if(!o)return;let i=e;l<-5&&e5&&e>0&&(i=e-1),f(-i*r),n(i),a(!1),p(0),setTimeout(()=>{c(!1)},100)},goToIndex:(t,e)=>{f(-t*e),n(t)}}})(),f=(0,t.useRef)(null);return(0,Gt.jsx)(on,{children:(0,Gt.jsx)(an,{children:(0,Gt.jsx)(sn,{ref:f,animateGroup:r,isMobile:c,currentIndex:a,totalItems:n.length,dragX:p,isDragging:l,onMouseDown:t=>d(t.clientX),onMouseMove:t=>u(t.clientX,n.length-1),onMouseUp:m,onMouseLeave:m,onTouchStart:t=>d(t.touches[0].clientX),onTouchMove:t=>u(t.touches[0].clientX,n.length-1),onTouchEnd:m,children:n.map((t,e)=>(0,Gt.jsxs)(pn,{animateItems:i,style:{"--card-index":e},"data-card-index":e,role:t.link||o?"link":void 0,tabIndex:t.link||o?0:void 0,onClick:()=>{l||o&&o(t)},onKeyDown:e=>{l||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t))},children:[(0,Gt.jsx)(un,{as:"div",onClick:e=>{l?e.preventDefault():(o&&o(t),e.stopPropagation())},children:(0,Gt.jsx)(dn,{src:t.image,alt:t.title,draggable:"false",onDragStart:t=>t.preventDefault(),style:{userSelect:"none"}})}),(0,Gt.jsx)(mn,{children:(0,Gt.jsxs)(fn,{children:[(0,Gt.jsx)(hn,{title:t.title,children:gn(t.title)}),(0,Gt.jsx)(cn,{children:(0,Gt.jsxs)(ln,{children:[t.tagText," · ",t.duration,"min"," "]})})]})})]},t.id))})})})},yn=e().memo(xn),bn=t=>{let{size:e=14,style:n}=t;return(0,Gt.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"inline-block",verticalAlign:"middle",...n},children:[(0,Gt.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,Gt.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,Gt.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})},wn=t=>{let{message:n,isOpen:r,isSafari:i,isFirstInGroup:o,isLastInGroup:s,isLastMessage:c,onQuickAction:l,isLatestBotGroup:p,isBotActive:d}=t;const u=!0,m=e().useRef(null),f=e().useRef(null),h=("cards"===n.type||"infoCards"===n.type||n.type,"cards"===n.type),g=s&&(!p||!d);return e().useEffect(()=>{},[]),"typing"===n.type?(0,Gt.jsx)($e,{isUser:!1,isLastInGroup:!0,isLastMessage:c,hasUserRepliedOnce:u,$messageType:"typing",children:(0,Gt.jsxs)(je,{isUser:!1,isFirstInGroup:!0,isHorizontalCards:!1,hasUserRepliedOnce:u,isLastMessage:c,children:[(0,Gt.jsx)(Ee,{ref:m,hasUserRepliedOnce:u,$isOpen:r,$isSafari:i,show:!1,children:(0,Gt.jsx)("img",{src:a,alt:"冥想教練"})}),(0,Gt.jsx)(Ae,{isUser:!1,hasUserRepliedOnce:u,$isOpen:r,children:(0,Gt.jsx)("div",{style:{margin:0,padding:0,display:"flex",flexDirection:"column",alignItems:"flex-start"},children:(0,Gt.jsx)(Ie,{isUser:!1,isFirstInGroup:!0,isLastInGroup:!0,children:(0,Gt.jsx)(Oe,{style:{margin:0,padding:"2px 0"},children:[1,2,3].map(t=>(0,Gt.jsx)(De,{},t))})})})})]})}):(0,Gt.jsx)($e,{isUser:"user"===n.sender,isLastInGroup:s,isLastMessage:c,hasUserRepliedOnce:u,$messageType:n.type,children:(0,Gt.jsxs)(je,{ref:f,isUser:"user"===n.sender,isFirstInGroup:o,isHorizontalCards:h,hasUserRepliedOnce:u,isLastMessage:c,children:["bot"===n.sender&&(0,Gt.jsx)(Ee,{ref:m,$hasUserRepliedOnce:u,$isOpen:r,$isSafari:i,$messageType:n.type,$itemCount:n.items?.length||0,show:g,children:(0,Gt.jsx)("img",{src:a,alt:"冥想教練"})}),(0,Gt.jsx)(Ae,{isUser:"user"===n.sender,hasUserRepliedOnce:u,$isOpen:r,children:(0,Gt.jsx)("div",{style:{margin:0,padding:0,display:"flex",flexDirection:"column",alignItems:"flex-start"},children:"cards"===n.type?(0,Gt.jsx)("div",{style:{marginBottom:0},children:(0,Gt.jsx)("div",{"data-avatar-anchor":"bot-cards",children:(0,Gt.jsx)(rn,{items:n.items,onQuickAction:l})})}):"infoCards"===n.type?(0,Gt.jsx)("div",{style:{marginBottom:0},children:(0,Gt.jsx)("div",{"data-avatar-anchor":"bot-infoCards",style:{paddingBottom:0},children:(0,Gt.jsx)(yn,{items:n.items,animateItems:!0,animateGroup:!1,onQuickAction:l})})}):"quickActions"===n.type?(0,Gt.jsx)("div",{style:{marginBottom:0},children:(0,Gt.jsx)(ze,{"data-avatar-anchor":"bot-quickActions",children:n.actions.map((t,e)=>(0,Gt.jsxs)(Me,{onClick:()=>{l(t?.action??t?.message??t?.url??t?.link??t?.href??t)},children:[t?.text??t?.name??t?.label??"",(t?.action?.link||t?.action?.url||t?.action?.href)&&(0,Gt.jsx)(bn,{size:14,style:{marginLeft:4}})]},e))})}):(0,Gt.jsx)("div",{style:{marginBottom:0},children:(0,Gt.jsx)(Ie,{isUser:"user"===n.sender,isFirstInGroup:o,isLastInGroup:s,children:(0,Gt.jsx)("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.text??""})})})})})]})})},vn=n=>{let{conversationId:i,teaserText:o="冥想課程嗎6545645646?",displayMode:s="icon_with_teaser",avatarIcon:c="normal",demoMode:l=!1,onChatTeaserClose:p}=n;const[d,u]=(0,t.useState)(!1),m=(0,t.useRef)(!1),[f,h]=(0,t.useState)(!1);(0,t.useEffect)(()=>{m.current=d},[d]),(0,t.useEffect)(()=>{if("undefined"==typeof document)return;const t=new MutationObserver(t=>{const e=document.querySelector(".w-nav-button, .menu-button-custom");e&&h(e.classList.contains("w--open"))}),e=document.querySelector(".w-nav-button, .menu-button-custom");return e&&(t.observe(e,{attributes:!0,attributeFilter:["class"]}),h(e.classList.contains("w--open"))),()=>t.disconnect()},[]);const[g,x]=(0,t.useState)("#ffffff"),[y,b]=(0,t.useState)(!1),[w,v]=(0,t.useState)(!1),[k,S]=(0,t.useState)(!1),[C,$]=(0,t.useState)(0),[j,A]=(0,t.useState)("undefined"!=typeof window?window.innerHeight:0),[E,_]=(0,t.useState)(0),[I,T]=(0,t.useState)(!1),L=(0,t.useRef)(0),R=(0,t.useRef)(!1);(0,t.useRef)(null),(0,t.useEffect)(()=>{if("undefined"==typeof window||!window.visualViewport)return;const t=()=>{const t=window.visualViewport;if(t){const e=()=>{const e=document.activeElement,n=e&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName),r=t.heightt+1),m.current&&window.innerWidth<=600&&(window.scrollTo(0,0),document.body.scrollTop=0,document.documentElement.scrollTop=0)};e(),setTimeout(e,100),setTimeout(e,300),setTimeout(e,500)}};window.visualViewport.addEventListener("resize",t),window.visualViewport.addEventListener("scroll",t);const e=()=>setTimeout(t,50),n=()=>setTimeout(t,50);document.addEventListener("focusin",e),document.addEventListener("focusout",n);const r=()=>{!m.current||window.innerWidth>600||0===window.scrollY&&0===document.documentElement.scrollTop&&0===document.body.scrollTop||(window.scrollTo(0,0),document.body.scrollTop=0,document.documentElement.scrollTop=0)};return window.addEventListener("scroll",r,{passive:!0}),()=>{window.visualViewport.removeEventListener("resize",t),window.visualViewport.removeEventListener("scroll",t),document.removeEventListener("focusin",e),document.removeEventListener("focusout",n),window.removeEventListener("scroll",r)}},[]),(0,t.useEffect)(()=>{if("undefined"!=typeof document&&d&&window.innerWidth<=600){const t=window.scrollY,e=document.body.style.overflow,n=document.body.style.position,r=document.body.style.width,i=document.body.style.top;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${t}px`,()=>{document.body.style.overflow=e,document.body.style.position=n,document.body.style.width=r,document.body.style.top=i,window.scrollTo(0,t)}}},[d]),(0,t.useEffect)(()=>{const t=setTimeout(()=>{"true"===sessionStorage.getItem("chatTeaserClose")||S(t=>!d||t)},3e3);return()=>clearTimeout(t)},[d]);const O=(0,t.useRef)(null),D=(0,t.useRef)(null),z=(0,t.useRef)(null),M=(0,t.useRef)(null),P=(0,t.useMemo)(()=>{if("undefined"==typeof navigator)return!1;const t=navigator.userAgent.toLowerCase();return-1!==t.indexOf("safari")&&-1===t.indexOf("chrome")},[]),B=(0,t.useRef)(null),N=(0,t.useRef)(null),G=(0,t.useRef)(null),U=(0,t.useMemo)(()=>(o||"").length>15,[o]),{messages:F,messagesEndRef:Y,sendMessage:W,resetChat:H,refreshMessages:q,loadMoreHistory:V,hasMoreHistory:Z,isLoading:X,isInitialized:Q,isBotStreaming:K,avatarIcon:J}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=(0,t.useRef)(Boolean(e?.demoMode)),i=(0,t.useRef)(!1),[o,a]=(0,t.useState)([]),[s,c]=(0,t.useState)(!1),[l,p]=(0,t.useState)(e?.avatarIcon||"normal"),[d,u]=(0,t.useState)(e.conversationId),[m,f]=(0,t.useState)(!1),[h,g]=(0,t.useState)(!0),[x,y]=(0,t.useState)(!1),b=(0,t.useRef)(null),w=(0,t.useRef)(!0),v=(0,t.useRef)(!1),k=(0,t.useRef)(Date.now()),S=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth";setTimeout(()=>{if(b.current){const e=b.current.closest('[data-chat-scroll-container="true"]');e?"smooth"===t?e.scrollTo({top:e.scrollHeight,behavior:"smooth"}):e.scrollTop=e.scrollHeight:b.current.scrollIntoView({behavior:t})}},100)},C=async()=>{if(m&&d&&!v.current&&!s&&!n.current){v.current=!0;try{const t=await r.getConversationHistory(d,{offset:-100,limit:100}),e=$(t);e.length>0&&(t.avatar_icon&&p(t.avatar_icon),a(t=>{const n=t.filter(t=>"typing"!==t.id);return n.length!==e.length||e.some((t,e)=>{const r=n[e];return!r||r.id!==t.id||r.text!==t.text})?e:t}))}catch(t){}finally{v.current=!1}}};(0,t.useEffect)(()=>{if("undefined"==typeof document)return;const t=()=>{"visible"===document.visibilityState&&C()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,d,s]),(0,t.useEffect)(()=>{o.length>0&&(w.current?(S("auto"),w.current=!1):S("smooth"))},[o,d]),(0,t.useEffect)(()=>{(async()=>{try{if(n.current)return u("demo_conversation"),y(!1),f(!0),void g(!1);let t=e?.conversationId;if(!t)throw new Error("useChat: conversationId is required");try{const e=await r.getConversationHistory(t,{offset:-100,limit:100}),n=e.turns||e.messages||e.history||[],i=$(e);e.avatar_icon&&p(e.avatar_icon),u(t),i.length>0&&(a(i),y(n.length>=100))}catch(t){throw t}f(!0)}catch(t){f(!0)}finally{g(!1)}})()},[e?.conversationId]);const $=t=>{const e=[];let n=k.current,r=null;const i=t.turns||t.messages||t.history||t;return Array.isArray(i)?(i.forEach((t,n)=>{let i=(t=>{if(!t)return null;let e=t;"string"!=typeof t||t.includes("Z")||t.includes("+")||!t.includes("T")||(e=t+"Z");const n=new Date(e);return isNaN(n.getTime())?null:n})(t.timestamp||t.created_at||t.time);!i&&r?i=r:i&&(r=i);const o=String(t.role||"").toLowerCase();if("user"===o){let r=null;if(t.content&&Array.isArray(t.content)){const e=t.content.find(t=>t.message||t.text||t.name||t.trigger_intent);r=e?.message||e?.text||e?.name||e?.trigger_intent}if(r||(r=t.message||t.text||t.name||t.trigger_intent),r){const o=t.id||`u-${i?.getTime()||n}-${r.length}`;e.push({id:o,text:r,sender:"user",timestamp:i||new Date})}}else if("bot"===o||"assistant"===o)if(t.content&&Array.isArray(t.content)){const r=D(t.content).map((e,r)=>{const o=e.id||(t.id?`b-${t.id}-${r}`:`b-${i?.getTime()||n}-${r}`);return{...e,id:o,timestamp:i||new Date}});e.push(...r)}else if(t.message||t.text){const r=t.message||t.text,o=t.id||`b-${i?.getTime()||n}-${r.length}`;e.push({id:o,text:r,sender:"bot",senderName:"冥想教練",timestamp:i||new Date})}}),k.current=n,e.length>1&&e[0].timestamp.getTime()>e[e.length-1].timestamp.getTime()&&e.reverse(),e):[]},j=(0,t.useRef)([]),A=(0,t.useRef)(0),E=(0,t.useRef)(!1),_=(0,t.useRef)(null),I=t=>new Promise(e=>setTimeout(e,t)),T=()=>{A.current+=1,j.current=[],E.current=!1,_.current=null},L=async t=>{if(!Array.isArray(t)||0===t.length)return;if(j.current=[...j.current,...t],E.current)return;E.current=!0,c(!0);const e=A.current;_.current=e;try{for(;j.current.length>0&&A.current===e;){const t=j.current.shift();if(!t)continue;a(e=>[...e,t]);const e=O(t);await I(e)}}finally{_.current===e&&(E.current=!1,_.current=null,c(!1))}},R=()=>{T(),a(t=>t.filter(t=>"typing"!==t.id));const t=()=>k.current++;a(e=>[...e,{id:t(),sender:"user",text:"我想要減壓的冥想課程",timestamp:new Date}]),a(t=>[...t,{id:"typing",type:"typing",sender:"bot"}]),setTimeout(()=>{a(t=>t.filter(t=>"typing"!==t.id));const e=[{id:t(),sender:"bot",senderName:"冥想教練",text:"太好了!我先問你一個小問題:你想偏放鬆還是偏專注?",timestamp:new Date},{id:t(),type:"quickActions",sender:"bot",senderName:"冥想教練",timestamp:new Date,actions:[{text:"🌿 放鬆",action:{message:"放鬆"}},{text:"🎯 專注",action:{message:"專注"}},{text:"😴 睡眠",action:{message:"睡眠"}}]},{id:t(),sender:"bot",senderName:"冥想教練",text:"這裡有兩個精選課程,你可以直接點卡片圖片開連結:",timestamp:new Date},{id:t(),type:"cards",sender:"bot",senderName:"冥想教練",timestamp:new Date,items:[{id:"t1",title:"深度放鬆冥想",description:"釋放壓力,找回內心平靜",image:"https://images.unsplash.com/photo-1506126613408-eca07ce68773?w=400",tagText:"减压",duration:"15",link:"https://example.com/course/1"},{id:"t2",title:"正念呼吸練習",description:"專注當下,調節呼吸節奏",image:"https://images.unsplash.com/photo-1508672019048-805c876b67e2?w=400",tagText:"呼吸",duration:"10",link:"https://example.com/course/2"}]},{id:t(),sender:"bot",senderName:"冥想教練",text:"如果你想先看科普,我也整理了幾個主題:",timestamp:new Date},{id:t(),type:"infoCards",sender:"bot",senderName:"冥想教練",timestamp:new Date,items:[{id:"i1",title:"什麼是正念冥想?",image:"https://images.unsplash.com/photo-1506126613408-eca07ce68773?w=400",tagText:"科普",link:"https://example.com/info/1"},{id:"i2",title:"冥想對大腦的影響",image:"https://images.unsplash.com/photo-1499209974431-9dddcece7f88?w=400",tagText:"科普",link:"https://example.com/info/2"}]}];L(e)},600)};(0,t.useEffect)(()=>{if("undefined"!=typeof window&&(!0===window.__AIZEN_DEBUG__||!0===n.current))return window.__AIZEN_WIDGET_DEBUG__=window.__AIZEN_WIDGET_DEBUG__||{},window.__AIZEN_WIDGET_DEBUG__.injectTestSequence=R,window.__AIZEN_WIDGET_DEBUG__.replay=R,()=>{window.__AIZEN_WIDGET_DEBUG__&&(delete window.__AIZEN_WIDGET_DEBUG__.injectTestSequence,delete window.__AIZEN_WIDGET_DEBUG__.replay)}},[]),(0,t.useEffect)(()=>{n.current&&(i.current||m&&!h&&d&&(i.current=!0,setTimeout(()=>R(),500)))},[m,h,d]);const O=t=>{let e;return e="infoCards"===t.type||"cards"===t.type||"quickActions"===t.type?1500:(t.text?t.text.length:0)>100?1800:1500,e},D=t=>{const e=[];let n=k.current;return t.forEach(t=>{if(t.text&&e.push({id:n++,text:t.text,sender:"bot",senderName:"冥想教練",timestamp:new Date}),t.lessons&&t.lessons.length>0){const r=t.lessons;if(r.length>0&&r.every(t=>"科普"===t.category))r.forEach((t,i)=>{e.push({id:"info-"+n++,type:"infoCards",sender:"bot",senderName:"冥想教練",timestamp:new Date,items:[{...t,isCard:!0,id:t.id||"l-"+n++,title:t.title,image:t.button_image,tagText:t.category||t.subtitle||"",description:t.subtitle||"",duration:t.duration,category:t.category,link:t.url}],isSplitInfo:!0,splitIndex:i,isLastSplit:i===r.length-1})});else{const t=r.map(t=>({...t,isCard:!0,id:t.id||n++,title:t.title,image:t.button_image,tagText:t.category||t.subtitle||"",description:t.subtitle||"",duration:t.duration,category:t.category,link:t.url,ctaText:"進入課程",ctaLink:t.url}));e.push({id:n++,type:"cards",sender:"bot",senderName:"冥想教練",timestamp:new Date,items:t})}}t.actions&&t.actions.length>0&&e.push({id:n++,type:"quickActions",sender:"bot",senderName:"冥想教練",timestamp:new Date,actions:t.actions.map(t=>({text:t.name||t.text||t.label||t.message||"點擊",action:t}))})}),k.current=n,e};return{messages:o,messagesEndRef:b,sendMessage:async t=>{let i="",o=null,s=null,l=null;if("object"==typeof t&&null!==t){if(l=t,s=l.link||l.ctaLink||l.url||l.href,s||l.isCard)return s&&window.open(s,"_blank","noopener,noreferrer"),void(e.onCardAction&&e.onCardAction());i=l.name||l.text||l.message||l.title||"",o=l.trigger_intent,e.onCardAction&&e.onCardAction()}else i=t;if(i||o)if(a(t=>{const e=[...t.filter(t=>"typing"!==t.id)];return i&&"string"==typeof i&&i.trim()&&e.push({id:k.current++,text:i,sender:"user",timestamp:new Date}),e.push({id:"typing",type:"typing",sender:"bot"}),e}),n.current&&T(),!n.current&&m&&d){T();try{const t=await r.sendMessage(d,{message:i||void 0,trigger_intent:o||void 0,location_href:window.location.href});setTimeout(()=>{c(!0),a(t=>t.filter(t=>"typing"!==t.id)),t.avatar_icon&&p(t.avatar_icon),L(D(t.content))},300)}catch(t){setTimeout(()=>{a(t=>[...t.filter(t=>"typing"!==t.id),{id:k.current++,text:"抱歉,我現在無法正常回應。請檢查網路連線或稍後再試。",sender:"bot",senderName:"冥想教練",timestamp:new Date}])},800)}}else n.current&&setTimeout(()=>{a(t=>t.filter(t=>"typing"!==t.id))},500)},resetChat:async()=>{if(n.current)return a(t=>[...t.filter(t=>"typing"!==t.id),{id:"typing",type:"typing",sender:"bot"}]),T(),void setTimeout(()=>{a(t=>t.filter(t=>"typing"!==t.id));const t=()=>k.current++;L([{id:t(),sender:"bot",senderName:"冥想教練",text:"(Demo)我們重新開始囉!你想先看「課程」還是「科普」?",timestamp:new Date},{id:t(),type:"quickActions",sender:"bot",senderName:"冥想教練",timestamp:new Date,actions:[{text:"🎓 課程",action:{message:"課程"}},{text:"📚 科普",action:{message:"科普"}}]}])},500);if(d)try{a(t=>[...t.filter(t=>"typing"!==t.id),{id:"typing",type:"typing",sender:"bot"}]);const t=await r.sendMessage(d,{trigger_intent:"welcome",location_href:window.location.href});setTimeout(()=>{a(t=>t.filter(t=>"typing"!==t.id)),L(D(t.content))},800)}catch(t){a(t=>[...t.filter(t=>"typing"!==t.id),{id:k.current++,text:"重新開始對話時發生錯誤,請稍後再試。",sender:"bot",senderName:"冥想教練",timestamp:new Date}])}},refreshMessages:C,loadMoreHistory:async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;if(!d)return 0;try{const n=await r.getConversationHistory(d,{offset:t,limit:e}),i=$(n);return i.length>0?(a(t=>[...i,...t]),y(i.length>=e)):y(!1),i.length}catch(t){return 0}},isLoading:h,isBotStreaming:s,isInitialized:m,avatarIcon:l,conversationId:d,hasMoreHistory:x}}({demoMode:l,conversationId:i,avatarIcon:c}),tt=(0,t.useCallback)(()=>{u(t=>{const e=!t;return e&&k&&S(!1),e})},[k]),et=(0,t.useCallback)(()=>{u(!1)},[]),nt=(0,t.useCallback)(()=>{"function"==typeof H&&H()},[H]);(0,t.useEffect)(()=>{},[d,Q]),(0,t.useEffect)(()=>{},[d]);const rt=(()=>{let t=-1;for(let e=F.length-1;e>=0;e--){const n=F[e];if("bot"!==n.sender&&"typing"!==n.type)break;t=e}return t})(),it=F.some(t=>"typing"===t.type),ot=it||K,at="undefined"!=typeof navigator&&/iphone|ipad|ipod/i.test(navigator.userAgent),st=(0,t.useRef)(!1),ct=(0,t.useRef)(ot),[lt,pt]=(0,t.useState)(0);at&&ct.current&&!ot&&(st.current=!0),ct.current=ot;const dt=ot||st.current,ut=(0,t.useCallback)(()=>{D.current&&(D.current.scrollTop=D.current.scrollHeight)},[]),mt=(0,t.useRef)(null),ft=(0,t.useRef)(!1);(0,t.useEffect)(()=>{ot&&(st.current=!1)},[ot]),(0,t.useLayoutEffect)(()=>{if("undefined"==typeof window||!d||window.innerWidth>600||!at)return;if(!st.current||ot)return;ut();let t=!1,e=0;return window.requestAnimationFrame(()=>{t||(ut(),window.requestAnimationFrame(()=>{t||(ut(),e=window.setTimeout(()=>{t||(ut(),st.current=!1,pt(t=>t+1))},32))}))}),()=>{t=!0,window.clearTimeout(e)}},[ot,at,d,ut]),(0,t.useLayoutEffect)(()=>{"undefined"==typeof window||!d||window.innerWidth>600||ft.current&&!ot&&ut(),ft.current=ot},[ot,d,ut]);const ht=t=>{W(t)},gt=F,xt=t=>{const e=new Date(t);return isNaN(e.getTime())?"":`${e.getMonth()+1}/${e.getDate()} ${["星期日","星期一","星期二","星期三","星期四","星期五","星期六"][e.getDay()]}`};(0,t.useEffect)(()=>{if("undefined"==typeof window)return;const t=()=>$(t=>t+1);window.addEventListener("resize",t),window.addEventListener("orientationchange",t);const e=window.visualViewport,n=()=>t();return e&&(e.addEventListener("resize",n),e.addEventListener("scroll",n)),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t),e&&(e.removeEventListener("resize",n),e.removeEventListener("scroll",n))}},[]),(0,t.useEffect)(()=>{if("undefined"==typeof window)return;let t;const e=()=>{clearTimeout(t),t=window.setTimeout(()=>{$(t=>t+1),requestAnimationFrame(()=>{const t=window.scrollY;window.scrollTo(0,t)})},0)},n=()=>e(),r=()=>{"visible"===document.visibilityState&&e()};return window.addEventListener("pageshow",n),document.addEventListener("visibilitychange",r),window.addEventListener("focus",e),()=>{clearTimeout(t),window.removeEventListener("pageshow",n),document.removeEventListener("visibilitychange",r),window.removeEventListener("focus",e)}},[]),(0,t.useEffect)(()=>{const t=localStorage.getItem("aizen-chat-background");t&&x(t)},[]),(0,t.useEffect)(()=>{d&&F.length>0&&D.current&&requestAnimationFrame(()=>{D.current&&(D.current.scrollTop=D.current.scrollHeight)})},[d,F.length]),(0,t.useLayoutEffect)(()=>{if(R.current&&D.current){const t=D.current.scrollHeight-L.current;t>0&&(D.current.scrollTop+=t),R.current=!1}},[F.length]),(0,t.useEffect)(()=>{if(!Z||y||!d)return;const t=new IntersectionObserver(t=>{t[0].isIntersecting&&(async()=>{if(!y&&Z&&D.current){L.current=D.current.scrollHeight,R.current=!0,b(!0);try{await V(F.length,20)}finally{b(!1)}}})()},{root:D.current,threshold:.1}),e=z.current;return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[Z,y,d,F.length]);const yt="undefined"!=typeof window&&window.innerWidth<=991;return(0,Gt.jsxs)(fe,{ref:N,$hide:yt&&f,$isOpen:d,children:[(0,Gt.jsx)(ge,{ref:G,show:k&&!d&&"icon_only"!==s,$isLong:U,children:(0,Gt.jsxs)(xe,{ref:B,children:[(0,Gt.jsx)(be,{onClick:t=>{t.stopPropagation(),S(!1),p&&p()},children:(0,Gt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"52",height:"52",viewBox:"0 0 52 52",fill:"none",children:[(0,Gt.jsx)("circle",{cx:"26",cy:"25",r:"10",fill:"white"}),(0,Gt.jsx)("path",{d:"M18 17L34 33",stroke:"#7B7B7B",strokeWidth:"4.25",strokeLinecap:"round"}),(0,Gt.jsx)("path",{d:"M34 17L18 33",stroke:"#7B7B7B",strokeWidth:"4.25",strokeLinecap:"round"})]})}),(0,Gt.jsx)(ye,{ref:M,$isLong:U,children:o})]})},o),(0,Gt.jsx)(he,{isOpen:d,onClick:tt,className:"aizen-toggle-button "+(d?"active":""),children:(0,Gt.jsx)(we,{children:d?(0,Gt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[(0,Gt.jsx)("path",{d:"M6 6L18 18",stroke:"white",strokeWidth:"2",strokeLinecap:"round"}),(0,Gt.jsx)("path",{d:"M18 6L6 18",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):(0,Gt.jsx)("img",{src:"lesson"===J?"https://cdn.prod.website-files.com/64420a3911d6832c7ba8b105/6a0fb84565cf2316df073f49_Aire%20%E9%A0%AD%E8%B2%BC-%E9%96%89%E7%9C%BC%E8%A1%A8%E6%83%85.webp":"https://cdn.prod.website-files.com/64420a3911d6832c7ba8b105/6a0fb84c6a0d5ae8dc12f059_Aire%20%E9%A0%AD%E8%B2%BC.webp",alt:"Aire"})})}),(0,Gt.jsxs)(ve,{"data-chat-window":"true",background:g,isOpen:d,style:d&&"undefined"!=typeof window&&window.innerWidth<=600?I?{height:`${j}px`,top:`${E}px`,bottom:"auto",position:"fixed",transition:"none"}:{height:"100%",top:"0px",bottom:"0px",position:"fixed"}:{},children:[(0,Gt.jsx)(Qt,{onReset:nt,onClose:et,onBackgroundChange:t=>{x(t),localStorage.setItem("aizen-chat-background",t)},currentBackground:g,isAiTyping:it,animationState:it?"thinking":"idle"}),(0,Gt.jsxs)(Te,{children:[(0,Gt.jsx)(Le,{ref:D,"data-chat-scroll-container":"true",children:X?(0,Gt.jsxs)(Ne,{children:[(0,Gt.jsx)(Oe,{children:[1,2,3].map(t=>(0,Gt.jsx)(De,{},t))}),(0,Gt.jsx)(Ge,{children:"載入對話中..."})]}):(0,Gt.jsxs)(Re,{ref:O,children:[Z&&(0,Gt.jsx)("div",{ref:z,style:{height:"20px",width:"100%",opacity:0}}),gt.map((t,n,r)=>{const i=r[n-1],o=!i||!((t,e)=>{if(!t||!e)return!1;const n=new Date(t),r=new Date(e);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()})(i.timestamp,t.timestamp),a=!r[n+1]||r[n+1].sender!==t.sender;return(0,Gt.jsxs)(e().Fragment,{children:[o&&t.timestamp&&(0,Gt.jsx)(Pe,{children:(0,Gt.jsx)(Be,{children:xt(t.timestamp)})}),(0,Gt.jsx)(wn,{message:t,isOpen:d,isSafari:P,isLastMessage:n===r.length-1,isFirstInGroup:!r[n-1]||r[n-1].sender!==t.sender,isLastInGroup:a,onQuickAction:ht,hasUserRepliedOnce:!0,isLatestBotGroup:n>=rt,isBotActive:dt})]},`${t.id}-${n}`)}),(0,Gt.jsx)("div",{ref:Y})]})}),d&&(0,Gt.jsx)(_e,{ref:mt,"data-chat-floating-avatar":"true",show:dt,$isOpen:d,$isSafari:P,children:(0,Gt.jsx)("img",{src:a,alt:"冥想教練"})})]}),(0,Gt.jsx)(Ue,{onSend:ht})]})]})},kn="aizen-chat-container";let Sn=null;const Cn={init:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Sn)return;if(!t.getTokenFn||"function"!=typeof t.getTokenFn)throw new Error("AIZEN Widget initialization failed: getTokenFn function is required");if(r.setGetToken(t.getTokenFn),!t.conversationId)throw new Error("AIZEN Widget initialization failed: conversationId is required");t.apiHost&&r.setBaseURL(t.apiHost);const i={...t,teaserText:t.teaserText||"需要幫助嗎?",displayMode:t.displayMode||"icon_with_teaser",demoMode:!0===t.demoMode},o=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kn,e=document.getElementById(t);return e||(e=document.createElement("div"),e.id=t,document.body.appendChild(e)),e}(t.containerId||kn);Sn=(0,n.H)(o),Sn.render(e().createElement(vn,i))},destroy:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Sn)return;Sn.unmount(),Sn=null;const e=t.containerId||kn,n=document.getElementById(e);n&&n.parentNode&&n.parentNode.removeChild(n)},show:()=>{if(Sn){const t=document.getElementById(kn);t&&(t.style.display="block")}},hide:()=>{if(Sn){const t=document.getElementById(kn);t&&(t.style.display="none")}}};"undefined"!=typeof window&&(window.AizenWidget=window.AizenWidget||Cn,window.AizenWidget.version="v1.0.80-FIXLEFT");const $n=Cn})(),o.default})());