nui-chatbot-pkg 1.0.26 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap";.chat-floating-btn{position:relative;width:3.5rem;height:3.5rem;cursor:pointer;transition:all .5s ease-in-out}@media(max-width:359px){.chat-floating-btn{width:3rem;height:3rem}}@media(min-width:360px)and (max-width:639px){.chat-floating-btn{width:4rem;height:4rem}}@media(min-width:640px){.chat-floating-btn{width:5rem;height:5rem}}.chat-btn-visible{transform:scale(1);opacity:1;pointer-events:auto}.chat-btn-visible:hover{transform:scale(1.1)}.chat-btn-hidden{transform:scale(0);opacity:0;pointer-events:none}.chat-btn-border{position:relative;width:100%;height:100%;border-radius:9999px;overflow:hidden;background-color:transparent}.chat-btn-inner{position:absolute;inset:0;margin:auto;width:85%;height:85%;z-index:10;border-radius:9999px;display:flex;align-items:center;justify-content:center;overflow:hidden;background-color:transparent}.chat-btn-gradient{position:absolute;inset:0}.chat-btn-icon{position:relative;z-index:20;transition:transform .3s ease;color:#f5f9ff}.chat-floating-btn:hover .chat-btn-icon{transform:rotate(12deg)}@keyframes scaleIn{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.animate-scaleIn{animation:scaleIn .2s ease-out}.glow-container{position:absolute;width:120%;height:300%}@keyframes spin-slow{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin-slow{animation:spin-slow 10s linear infinite}@keyframes rotate-border{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes float{0%,to{transform:translateY(0) rotate(3deg)}50%{transform:translateY(-10px) rotate(0)}}.chat-header{display:flex;align-items:center;justify-content:space-between;padding:.9rem 1rem;position:sticky;top:0;z-index:10;background:transparent}.chat-header-left{display:flex;align-items:center;gap:.75rem}.chat-header-logo{width:2.6rem;height:2.6rem;border-radius:9999px;object-fit:cover;border:2px solid rgba(255,255,255,.22)}.chat-header-logo-placeholder{width:2.6rem;height:2.6rem;border-radius:9999px;background:#59a0fff2;display:flex;align-items:center;justify-content:center;font-weight:700;color:#f8fbff}.chat-header-bot-icon{color:#f8fbff}.chat-header-title-wrap{display:flex;flex-direction:column;gap:.2rem}.chat-header-title-row{display:flex;align-items:center;gap:.45rem}.chat-header-title{font-weight:700;color:#f5f9ff;font-size:1.03rem;line-height:1.1}.chat-header-badge{font-size:.74rem;line-height:1;color:#d8e8ff;padding:.19rem .5rem;border-radius:9999px;background:#ffffff24;border:1px solid rgba(255,255,255,.08)}.chat-header-status{display:flex;align-items:center;gap:.33rem;font-size:.84rem;color:#b7c8e9}.chat-header-status-dot{width:.45rem;height:.45rem;border-radius:9999px;background:#22d56f;flex:none}.chat-header-actions{display:flex;align-items:center;gap:.5rem}.chat-header-close-btn{padding:.375rem;border-radius:9999px;color:#d2def4;background:transparent;border:none;cursor:pointer;transition:color .2s ease,background-color .2s ease}.chat-header-close-btn:hover{background:#ffffff1f;color:#fff}.chat-input-outer{padding:.75rem .95rem .6rem;display:flex;justify-content:center;width:100%;background:#fff}@media(max-width:639px){.chat-input-outer{padding:.75rem .95rem .6rem}}.chat-input-wrap{position:relative;width:100%;max-width:none}@keyframes chat-pulse{0%,to{opacity:.6}50%{opacity:.9}}.chat-input-row{display:flex;align-items:center;gap:.65rem}.chat-input-container{position:relative;display:flex;align-items:center;background:#f9fafb;border-radius:9999px;border:1.5px solid #E5E7EB;box-shadow:none;width:100%;min-height:2.7rem}.chat-input-inner{position:relative;display:flex;align-items:center;width:100%;padding:.15rem 1.1rem}.chat-input-field{flex:1;font-size:1rem;outline:none;padding:.52rem 0;color:#000;background:transparent;border:none}.chat-input-container:focus-within{border-color:#3b82f6}.chat-input-field::placeholder{color:#8b909b}.chat-input-send-btn{position:relative;z-index:20;display:flex;align-items:center;justify-content:center;height:2.65rem;width:2.65rem;min-height:2.65rem;min-width:2.65rem;aspect-ratio:1 / 1;flex-shrink:0;border-radius:9999px;border:none;color:#fff;box-shadow:none;cursor:pointer;transition:transform .2s ease}@media(max-width:639px){.chat-input-send-btn{height:2.55rem;width:2.55rem;min-height:2.55rem;min-width:2.55rem}}.chat-input-send-btn:active{transform:scale(.9)}.chat-input-send-btn:enabled:hover{transform:scale(1.03)}.chat-input-send-btn:disabled{opacity:.65;cursor:not-allowed}.chat-input-spinner{height:1.25rem;width:1.25rem;border-radius:9999px;border:2px solid white;border-top-color:transparent;animation:chat-spin 1s linear infinite}@keyframes chat-spin{to{transform:rotate(360deg)}}.chat-input-send-icon{height:1.3rem;width:1.3rem}.mb-row{display:flex;width:100%}.mb-row-user{justify-content:flex-end;flex-direction:column;align-items:flex-end}.mb-row-assistant{justify-content:flex-start;flex-direction:column;align-items:flex-start}.mb-card-container{display:flex;flex-direction:column;gap:1rem;width:100%}.mb-card-content{background:#f3f4f6;color:#27272a;padding:1rem;border-radius:1rem;font-size:.875rem}.mb-card-wrapper{max-width:90%;animation:mb-in .3s ease forwards}.mb-bubble{max-width:88%;padding:.78rem 1rem;font-size:.98rem;border-radius:1.15rem;line-height:1.55;box-shadow:0 2px 8px #0f172a14;animation:mb-in .3s ease forwards;white-space:pre-wrap;word-break:break-word;transition:all .3s ease}.mb-bubble-user{color:#fff;border-bottom-right-radius:8px}.mb-bubble-assistant{background:#eceef1;color:#1f2937;border:1px solid #d6dbe2;margin-left:30px}.mb-assistant-meta{display:flex;align-items:center;gap:.55rem;margin-top:-.1rem;padding-left:.1rem}.mb-assistant-avatar{margin-top:.15rem;width:2rem;height:2rem;border-radius:9999px;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;flex:none}.mb-assistant-time{font-size:.95rem;color:#99a3b3}.mb-user-meta{display:flex;align-items:center;gap:.18rem;margin-top:.2rem}.mb-user-time{font-size:.85rem;color:#99a3b3}.mb-user-tick{font-size:.78rem;line-height:1;color:#2f89ff;letter-spacing:-.12rem}@keyframes mb-in{0%{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}.mb-typing{display:flex;gap:.25rem;padding:.25rem .5rem}.mb-dot{width:.5rem;height:.5rem;background:#3b82f6;border-radius:10px;animation:mb-bounce 1.4s infinite both}.mb-dot-1{animation-delay:-.3s}.mb-dot-2{animation-delay:-.15s}.mb-dot-3{animation-delay:0s}@keyframes mb-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chat-messages-container{flex:1;overflow-y:auto;overflow-x:hidden;padding:1rem;display:flex;flex-direction:column;gap:.85rem;background:#f1f5fb;-ms-overflow-style:none;scrollbar-width:none}.chat-messages-container::-webkit-scrollbar{display:none;width:0}.chat-welcome{display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;min-height:100%;text-align:left;gap:1rem;overflow:visible}.chat-welcome-message{width:100%;max-width:360px}@media(max-width:639px){.chat-messages-container{padding:.75rem 1rem;gap:1rem}.chat-welcome{gap:1rem;padding:.75rem}}.chat-welcome-subtitle{font-size:1rem;color:#232c39;line-height:1.6;background:#eceef1;border:1px solid #d6dbe2;border-radius:1.15rem;padding:.78rem 1rem;margin:0;box-shadow:0 2px 8px #0f172a14;margin-bottom:.5rem;margin-left:30px}.chat-welcome-meta{display:flex;align-items:center;gap:.55rem;margin-top:-.1rem;padding-left:.1rem}.chat-welcome-avatar{width:2rem;height:2rem;border-radius:9999px;background:#2551a2;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;flex:none}.chat-welcome-time{font-size:.95rem;color:#99a3b3}@media(max-width:639px){.chat-welcome-subtitle{font-size:.9rem;padding:.75rem .9rem}}.chat-welcome-suggestions{width:100%;max-height:fit-content;margin-top:auto;padding-top:.2rem}.sug-skeleton-float{display:flex;flex-direction:column;align-items:center;gap:.75rem;padding:.25rem 1rem 0;width:100%;animation:sug-pulse 1.5s ease-in-out infinite}.sug-skeleton-item{height:2.5rem;width:70%;border-radius:.5rem;opacity:.7}.sug-skeleton-more{height:1.5rem;width:3rem;border-radius:9999px;margin-top:.5rem;background:#0000000d}.sug-skeleton-list{display:flex;gap:.5rem;overflow-x:auto;padding:.5rem 0;justify-content:flex-start;animation:sug-pulse 1.5s ease-in-out infinite}@media(min-width:640px){.sug-skeleton-list{justify-content:center}}.sug-skeleton-chip{height:2rem;width:6rem;background:#f3f4f6;border-radius:.5rem}@keyframes sug-pulse{0%,to{opacity:.6}50%{opacity:1}}.sug-float-wrap{display:flex;flex-direction:row;align-items:center;gap:.55rem;padding:0 .95rem .35rem;margin-bottom:0;width:100%;overflow-x:scroll;overflow-y:hidden;scrollbar-width:auto;scrollbar-color:#a6acb3 #f9fafb}.sug-float-btn{background:#fff;border:2px solid transparent;padding:.5rem .95rem;border-radius:9999px;box-shadow:0 1px 2px #1e3a8a2e;font-size:1rem;font-weight:500;max-width:none;width:auto;cursor:pointer;animation:none;opacity:1;transition:transform .15s ease,box-shadow .15s ease;flex:none;color:#bfdbfe;line-height:1;white-space:nowrap;margin-bottom:1px}.sug-float-btn:hover{box-shadow:0 2px 6px #1e3a8a33}.sug-float-btn:active{transform:scale(.97)}.sug-float-text{color:#2150bf}.sug-more-btn{margin-top:.25rem;background:#f6f9ff;padding:.375rem 1.25rem;border-radius:9999px;cursor:pointer;box-shadow:0 1px 2px #0000000d;transition:background-color .2s ease,transform .1s ease;animation:sug-fade-up .4s ease-out forwards;opacity:0;border:none}.sug-more-btn:hover{background:#e5e7eb}.sug-more-btn:active{transform:scale(.95)}.sug-more-dots{display:flex;align-items:center;gap:.25rem}.sug-more-dots span{width:.375rem;height:.375rem;background:currentColor;border-radius:9999px}.sug-float-wrap::-webkit-scrollbar{height:14px}.sug-float-wrap::-webkit-scrollbar-track{background:#f9fafb;border-radius:0}.sug-float-wrap::-webkit-scrollbar-thumb{background:#a6acb3;border-radius:9999px;border:2px solid #f9fafb}.sug-float-wrap::-webkit-scrollbar-thumb:hover{background:#b4bac1}.sug-float-wrap::-webkit-scrollbar-button:horizontal{background:#f9fafb;width:12px}.sug-list-wrap{display:flex;gap:.5rem;overflow-x:auto;padding:.5rem 0;justify-content:flex-start}@media(min-width:640px){.sug-list-wrap{justify-content:center}}.sug-list-btn{white-space:nowrap;border:none;padding:.375rem 1rem;border-radius:.5rem;font-size:.75rem;color:#4b5563;background:#fff;box-shadow:0 4px 12px color-mix(in srgb,var(--cb-primary) 22%,transparent);cursor:pointer;transition:background-color .2s ease,transform .15s ease,box-shadow .15s ease;animation:sug-fade .3s ease-out forwards;opacity:0}.sug-list-btn:hover{background:#f9fafb;box-shadow:0 6px 18px color-mix(in srgb,var(--cb-primary) 35%,transparent);transform:translateY(-1px)}@keyframes sug-fade-up{0%{opacity:0;transform:translateY(10px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes sug-fade{0%{opacity:0}to{opacity:1}}.sug-list-wrap::-webkit-scrollbar{display:none}.chat-window{position:fixed;display:flex;flex-direction:column;background:#d8dce2;border-radius:1rem;box-shadow:0 18px 45px -16px #0f172a80;overflow:hidden;transform-origin:bottom right;transition:all .5s cubic-bezier(.4,0,.2,1);bottom:1.25rem;right:1.25rem;top:auto;z-index:40;width:85vw;max-height:80vh}@media(max-width:359px){.chat-window{width:80vw;bottom:.5rem;right:.5rem;border-radius:1.5rem;max-height:70vh}}@media(min-width:360px)and (max-width:639px){.chat-window{width:90vw;max-height:75vh}}@media(min-width:640px){.chat-window{width:400px;max-height:600px}}@media(min-width:768px){.chat-window{width:420px;max-height:620px}}@media(min-width:1024px){.chat-window{width:450px;max-height:650px}}.chat-window-open{height:65vh;opacity:1;transform:scale(1) translateY(0);pointer-events:auto}@media(min-width:640px){.chat-window-open{height:560px}}@media(min-width:768px){.chat-window-open{height:580px}}@media(min-width:1024px){.chat-window-open{height:600px}}.chat-window-closed{height:0;opacity:0;transform:scale(.95) translateY(2.5rem);pointer-events:none}.chat-window-header{flex:none;z-index:20;background:linear-gradient(135deg,#2450a0,#1b3f87);border-bottom:1px solid rgba(255,255,255,.14)}.chat-window-footer{flex:none;background:#fff;padding:0;border-top:1px solid #d4d8e0}@media(min-width:640px){.chat-window-footer{padding:0}}.chat-window-suggestions{border-bottom:1px solid #d4d8e0;padding:.5rem 0 0;background:#f1f5fb}.chat-window-powered{text-align:center;margin-top:0;padding:.1rem 1rem .45rem;border-top:1px solid #e2e5ea;background:#fff}.chat-powered-text{font-size:12px;color:#9da5b5;letter-spacing:.01em}.chat-powered-link{color:#9ca3af;font-weight:600;text-decoration:none;transition:color .2s ease}.chat-powered-link:hover{color:#2563eb}.chatbot-container{position:fixed;bottom:1rem;right:1rem;z-index:50;display:flex;flex-direction:column;align-items:flex-end;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif}@media(max-width:359px){.chatbot-container{bottom:.5rem;right:.5rem}}@media(min-width:640px){.chatbot-container{bottom:1.5rem;right:1.5rem}}@media(min-width:768px){.chatbot-container{bottom:2rem;right:2rem}}
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap";.chat-floating-btn{position:relative;width:3.5rem;height:3.5rem;cursor:pointer;transition:all .5s ease-in-out}@media(max-width:359px){.chat-floating-btn{width:3rem;height:3rem}}@media(min-width:360px)and (max-width:639px){.chat-floating-btn{width:4rem;height:4rem}}@media(min-width:640px){.chat-floating-btn{width:5rem;height:5rem}}.chat-btn-visible{transform:scale(1);opacity:1;pointer-events:auto}.chat-btn-visible:hover{transform:scale(1.1)}.chat-btn-hidden{transform:scale(0);opacity:0;pointer-events:none}.chat-btn-border{position:relative;width:100%;height:100%;border-radius:9999px;overflow:hidden;background-color:transparent}.chat-btn-inner{position:absolute;inset:0;margin:auto;width:85%;height:85%;z-index:10;border-radius:9999px;display:flex;align-items:center;justify-content:center;overflow:hidden;background-color:transparent}.chat-btn-gradient{position:absolute;inset:0}.chat-btn-icon{position:relative;z-index:20;transition:transform .3s ease;color:#f5f9ff}.chat-floating-btn:hover .chat-btn-icon{transform:rotate(12deg)}@keyframes scaleIn{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.animate-scaleIn{animation:scaleIn .2s ease-out}.glow-container{position:absolute;width:120%;height:300%}@keyframes spin-slow{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin-slow{animation:spin-slow 10s linear infinite}@keyframes rotate-border{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes float{0%,to{transform:translateY(0) rotate(3deg)}50%{transform:translateY(-10px) rotate(0)}}.chat-header{display:flex;align-items:center;justify-content:space-between;padding:.9rem 1rem;position:sticky;top:0;z-index:10;background:transparent}.chat-header-left{display:flex;align-items:center;gap:.75rem}.chat-header-logo{width:2.6rem;height:2.6rem;border-radius:9999px;object-fit:cover;border:2px solid rgba(255,255,255,.22)}.chat-header-logo-placeholder{width:2.6rem;height:2.6rem;border-radius:9999px;background:#59a0fff2;display:flex;align-items:center;justify-content:center;font-weight:700;color:#f8fbff}.chat-header-bot-icon{color:#f8fbff}.chat-header-title-wrap{display:flex;flex-direction:column;gap:.2rem}.chat-header-title-row{display:flex;align-items:center;gap:.45rem}.chat-header-title{font-weight:700;color:#f5f9ff;font-size:1.03rem;line-height:1.1}.chat-header-badge{font-size:.74rem;line-height:1;color:#d8e8ff;padding:.19rem .5rem;border-radius:9999px;background:#ffffff24;border:1px solid rgba(255,255,255,.08)}.chat-header-status{display:flex;align-items:center;gap:.33rem;font-size:.84rem;color:#b7c8e9}.chat-header-status-dot{width:.45rem;height:.45rem;border-radius:9999px;background:#22d56f;flex:none}.chat-header-actions{display:flex;align-items:center;gap:.5rem}.chat-header-close-btn{padding:.375rem;border-radius:9999px;color:#d2def4;background:transparent;border:none;cursor:pointer;transition:color .2s ease,background-color .2s ease}.chat-header-close-btn:hover{background:#ffffff1f;color:#fff}.chat-input-outer{padding:.75rem .95rem .6rem;display:flex;justify-content:center;width:100%;background:#fff}@media(max-width:639px){.chat-input-outer{padding:.75rem .95rem .6rem}}.chat-input-wrap{position:relative;width:100%;max-width:none}@keyframes chat-pulse{0%,to{opacity:.6}50%{opacity:.9}}.chat-input-row{display:flex;align-items:center;gap:.65rem}.chat-input-container{position:relative;display:flex;align-items:center;background:#f9fafb;border-radius:9999px;border:1.5px solid #E5E7EB;box-shadow:none;width:100%;min-height:2.7rem}.chat-input-inner{position:relative;display:flex;align-items:center;width:100%;padding:.15rem 1.1rem}.chat-input-field{flex:1;font-size:1rem;outline:none;padding:.52rem 0;color:#000;background:transparent;border:none}.chat-input-container:focus-within{border-color:#3b82f6}.chat-input-field::placeholder{color:#8b909b}.chat-input-send-btn{position:relative;z-index:20;display:flex;align-items:center;justify-content:center;height:2.65rem;width:2.65rem;min-height:2.65rem;min-width:2.65rem;aspect-ratio:1 / 1;flex-shrink:0;border-radius:9999px;border:none;color:#fff;box-shadow:none;cursor:pointer;transition:transform .2s ease}@media(max-width:639px){.chat-input-send-btn{height:2.55rem;width:2.55rem;min-height:2.55rem;min-width:2.55rem}}.chat-input-send-btn:active{transform:scale(.9)}.chat-input-send-btn:enabled:hover{transform:scale(1.03)}.chat-input-send-btn:disabled{opacity:.65;cursor:not-allowed}.chat-input-spinner{height:1.25rem;width:1.25rem;border-radius:9999px;border:2px solid white;border-top-color:transparent;animation:chat-spin 1s linear infinite}@keyframes chat-spin{to{transform:rotate(360deg)}}.chat-input-send-icon{height:1.3rem;width:1.3rem}.mb-row{display:flex;width:100%}.mb-row-user{justify-content:flex-end;flex-direction:column;align-items:flex-end}.mb-row-assistant{justify-content:flex-start;flex-direction:column;align-items:flex-start}.mb-card-container{display:flex;flex-direction:column;gap:1rem;width:100%}.mb-card-content{background:#f3f4f6;color:#27272a;padding:1rem;border-radius:1rem;font-size:.875rem}.mb-card-wrapper{max-width:90%;animation:mb-in .3s ease forwards}.mb-bubble{max-width:88%;padding:.78rem 1rem;font-size:.98rem;border-radius:1.15rem;line-height:1.55;box-shadow:0 2px 8px #0f172a14;animation:mb-in .3s ease forwards;white-space:pre-wrap;word-break:break-word;transition:all .3s ease}.mb-bubble-user{color:#fff;border-bottom-right-radius:8px}.mb-bubble-assistant{background:#eceef1;color:#1f2937;border:1px solid #d6dbe2;margin-left:30px}.mb-assistant-meta{display:flex;align-items:center;gap:.55rem;margin-top:-.1rem;padding-left:.1rem}.mb-assistant-avatar{margin-top:.15rem;width:2rem;height:2rem;border-radius:9999px;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;flex:none}.mb-assistant-time{font-size:.95rem;color:#99a3b3}.mb-user-meta{display:flex;align-items:center;gap:.18rem;margin-top:.2rem}.mb-user-time{font-size:.85rem;color:#99a3b3}.mb-user-tick{font-size:.78rem;line-height:1;color:#2f89ff;letter-spacing:-.12rem}@keyframes mb-in{0%{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}.mb-typing{display:flex;gap:.25rem;padding:.25rem .5rem}.mb-dot{width:.5rem;height:.5rem;background:#3b82f6;border-radius:10px;animation:mb-bounce 1.4s infinite both}.mb-dot-1{animation-delay:-.3s}.mb-dot-2{animation-delay:-.15s}.mb-dot-3{animation-delay:0s}@keyframes mb-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.mb-content-wrapper h1,.mb-content-wrapper h2,.mb-content-wrapper h3,.mb-content-wrapper h4,.mb-content-wrapper h5,.mb-content-wrapper h6{margin:1rem 0 .5rem;font-weight:600;line-height:1.3}.mb-content-wrapper h1{font-size:1.5rem}.mb-content-wrapper h2{font-size:1.3rem}.mb-content-wrapper h3{font-size:1.1rem}.mb-content-wrapper h4,.mb-content-wrapper h5,.mb-content-wrapper h6{font-size:1rem}.mb-content-wrapper ul,.mb-content-wrapper ol{margin:.5rem 0;padding-left:1.5rem}.mb-content-wrapper li{margin:.25rem 0}.mb-content-wrapper code{background-color:#0000001a;padding:.2rem .4rem;border-radius:3px;font-family:Courier New,monospace;font-size:.9em}.mb-content-wrapper pre{background-color:#00000026;padding:1rem;border-radius:6px;overflow-x:auto;margin:.5rem 0}.mb-content-wrapper pre code{background-color:transparent;padding:0;border-radius:0}.mb-content-wrapper a{color:#2563eb;text-decoration:underline;cursor:pointer}.mb-content-wrapper a:hover{color:#1d4ed8}.mb-content-wrapper strong{font-weight:600}.mb-content-wrapper em{font-style:italic}.mb-content-wrapper blockquote{border-left:4px solid #d1d5db;margin:.5rem 0;padding-left:1rem;color:#6b7280;font-style:italic}.mb-content-wrapper table{border-collapse:collapse;width:100%;margin:.5rem 0}.mb-content-wrapper table th,.mb-content-wrapper table td{border:1px solid #d1d5db;padding:.5rem;text-align:left}.mb-content-wrapper table th{background-color:#00000014;font-weight:600}.mb-content-wrapper img{max-width:100%;height:auto;border-radius:6px;margin:.5rem 0}.mb-card-content h1,.mb-card-content h2,.mb-card-content h3,.mb-card-content h4,.mb-card-content h5,.mb-card-content h6{margin:.5rem 0 .25rem;font-weight:600}.mb-card-content code{background-color:#00000026;padding:.2rem .4rem;border-radius:3px}.chat-messages-container{flex:1;overflow-y:auto;overflow-x:hidden;padding:1rem;display:flex;flex-direction:column;gap:.85rem;background:#f1f5fb;-ms-overflow-style:none;scrollbar-width:none}.chat-messages-container::-webkit-scrollbar{display:none;width:0}.chat-welcome{display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;min-height:100%;text-align:left;gap:1rem;overflow:visible}.chat-welcome-message{width:100%;max-width:360px}@media(max-width:639px){.chat-messages-container{padding:.75rem 1rem;gap:1rem}.chat-welcome{gap:1rem;padding:.75rem}}.chat-welcome-subtitle{font-size:1rem;color:#232c39;line-height:1.6;background:#eceef1;border:1px solid #d6dbe2;border-radius:1.15rem;padding:.78rem 1rem;margin:0;box-shadow:0 2px 8px #0f172a14;margin-bottom:.5rem;margin-left:30px}.chat-welcome-meta{display:flex;align-items:center;gap:.55rem;margin-top:-.1rem;padding-left:.1rem}.chat-welcome-avatar{width:2rem;height:2rem;border-radius:9999px;background:#2551a2;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;flex:none}.chat-welcome-time{font-size:.95rem;color:#99a3b3}@media(max-width:639px){.chat-welcome-subtitle{font-size:.9rem;padding:.75rem .9rem}}.chat-welcome-suggestions{width:100%;max-height:fit-content;margin-top:auto;padding-top:.2rem}.chat-welcome-subtitle h1,.chat-welcome-subtitle h2,.chat-welcome-subtitle h3,.chat-welcome-subtitle h4,.chat-welcome-subtitle h5,.chat-welcome-subtitle h6{margin:.5rem 0 .25rem;font-weight:600;font-size:1rem}.chat-welcome-subtitle ul,.chat-welcome-subtitle ol{margin:.25rem 0;padding-left:1.5rem}.chat-welcome-subtitle li{margin:.15rem 0}.chat-welcome-subtitle code{background-color:#0000001a;padding:.2rem .4rem;border-radius:3px;font-family:Courier New,monospace;font-size:.85em}.chat-welcome-subtitle pre{background-color:#0000001a;padding:.5rem;border-radius:4px;overflow-x:auto;margin:.25rem 0;font-size:.85rem}.chat-welcome-subtitle a{color:#2563eb;text-decoration:underline}.chat-welcome-subtitle a:hover{color:#1d4ed8}.chat-welcome-subtitle strong{font-weight:600}.chat-welcome-subtitle em{font-style:italic}.chat-welcome-subtitle blockquote{border-left:4px solid #d1d5db;margin:.25rem 0;padding-left:.75rem;color:#6b7280}.chat-welcome-subtitle p{margin:.25rem 0}.sug-skeleton-float{display:flex;flex-direction:column;align-items:center;gap:.75rem;padding:.25rem 1rem 0;width:100%;animation:sug-pulse 1.5s ease-in-out infinite}.sug-skeleton-item{height:2.5rem;width:70%;border-radius:.5rem;opacity:.7}.sug-skeleton-more{height:1.5rem;width:3rem;border-radius:9999px;margin-top:.5rem;background:#0000000d}.sug-skeleton-list{display:flex;gap:.5rem;overflow-x:auto;padding:.5rem 0;justify-content:flex-start;animation:sug-pulse 1.5s ease-in-out infinite}@media(min-width:640px){.sug-skeleton-list{justify-content:center}}.sug-skeleton-chip{height:2rem;width:6rem;background:#f3f4f6;border-radius:.5rem}@keyframes sug-pulse{0%,to{opacity:.6}50%{opacity:1}}.sug-float-wrap{display:flex;flex-direction:row;align-items:center;gap:.55rem;padding:0 .95rem .35rem;margin-bottom:0;width:100%;overflow-x:scroll;overflow-y:hidden;scrollbar-width:auto;scrollbar-color:#a6acb3 #f9fafb}.sug-float-btn{background:#fff;border:2px solid transparent;padding:.5rem .95rem;border-radius:9999px;box-shadow:0 1px 2px #1e3a8a2e;font-size:1rem;font-weight:500;max-width:none;width:auto;cursor:pointer;animation:none;opacity:1;transition:transform .15s ease,box-shadow .15s ease;flex:none;color:#bfdbfe;line-height:1;white-space:nowrap;margin-bottom:1px}.sug-float-btn:hover{box-shadow:0 2px 6px #1e3a8a33}.sug-float-btn:active{transform:scale(.97)}.sug-float-text{color:#2150bf}.sug-more-btn{margin-top:.25rem;background:#f6f9ff;padding:.375rem 1.25rem;border-radius:9999px;cursor:pointer;box-shadow:0 1px 2px #0000000d;transition:background-color .2s ease,transform .1s ease;animation:sug-fade-up .4s ease-out forwards;opacity:0;border:none}.sug-more-btn:hover{background:#e5e7eb}.sug-more-btn:active{transform:scale(.95)}.sug-more-dots{display:flex;align-items:center;gap:.25rem}.sug-more-dots span{width:.375rem;height:.375rem;background:currentColor;border-radius:9999px}.sug-float-wrap::-webkit-scrollbar{height:14px}.sug-float-wrap::-webkit-scrollbar-track{background:#f9fafb;border-radius:0}.sug-float-wrap::-webkit-scrollbar-thumb{background:#a6acb3;border-radius:9999px;border:2px solid #f9fafb}.sug-float-wrap::-webkit-scrollbar-thumb:hover{background:#b4bac1}.sug-float-wrap::-webkit-scrollbar-button:horizontal{background:#f9fafb;width:12px}.sug-list-wrap{display:flex;gap:.5rem;overflow-x:auto;padding:.5rem 0;justify-content:flex-start}@media(min-width:640px){.sug-list-wrap{justify-content:center}}.sug-list-btn{white-space:nowrap;border:none;padding:.375rem 1rem;border-radius:.5rem;font-size:.75rem;color:#4b5563;background:#fff;box-shadow:0 4px 12px color-mix(in srgb,var(--cb-primary) 22%,transparent);cursor:pointer;transition:background-color .2s ease,transform .15s ease,box-shadow .15s ease;animation:sug-fade .3s ease-out forwards;opacity:0}.sug-list-btn:hover{background:#f9fafb;box-shadow:0 6px 18px color-mix(in srgb,var(--cb-primary) 35%,transparent);transform:translateY(-1px)}@keyframes sug-fade-up{0%{opacity:0;transform:translateY(10px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes sug-fade{0%{opacity:0}to{opacity:1}}.sug-list-wrap::-webkit-scrollbar{display:none}.chat-window{position:fixed;display:flex;flex-direction:column;background:#d8dce2;border-radius:1rem;box-shadow:0 18px 45px -16px #0f172a80;overflow:hidden;transform-origin:bottom right;transition:all .5s cubic-bezier(.4,0,.2,1);bottom:1.25rem;right:1.25rem;top:auto;z-index:40;width:85vw;max-height:80vh}@media(max-width:359px){.chat-window{width:80vw;bottom:.5rem;right:.5rem;border-radius:1.5rem;max-height:70vh}}@media(min-width:360px)and (max-width:639px){.chat-window{width:90vw;max-height:75vh}}@media(min-width:640px){.chat-window{width:400px;max-height:600px}}@media(min-width:768px){.chat-window{width:420px;max-height:620px}}@media(min-width:1024px){.chat-window{width:450px;max-height:650px}}.chat-window-open{height:65vh;opacity:1;transform:scale(1) translateY(0);pointer-events:auto}@media(min-width:640px){.chat-window-open{height:560px}}@media(min-width:768px){.chat-window-open{height:580px}}@media(min-width:1024px){.chat-window-open{height:600px}}.chat-window-closed{height:0;opacity:0;transform:scale(.95) translateY(2.5rem);pointer-events:none}.chat-window-header{flex:none;z-index:20;background:linear-gradient(135deg,#2450a0,#1b3f87);border-bottom:1px solid rgba(255,255,255,.14)}.chat-window-footer{flex:none;background:#fff;padding:0;border-top:1px solid #d4d8e0}@media(min-width:640px){.chat-window-footer{padding:0}}.chat-window-suggestions{border-bottom:1px solid #d4d8e0;padding:.5rem 0 0;background:#f1f5fb}.chat-window-powered{text-align:center;margin-top:0;padding:.1rem 1rem .45rem;border-top:1px solid #e2e5ea;background:#fff}.chat-powered-text{font-size:12px;color:#9da5b5;letter-spacing:.01em}.chat-powered-link{color:#9ca3af;font-weight:600;text-decoration:none;transition:color .2s ease}.chat-powered-link:hover{color:#2563eb}.chatbot-container{position:fixed;bottom:1rem;right:1rem;z-index:50;display:flex;flex-direction:column;align-items:flex-end;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif}@media(max-width:359px){.chatbot-container{bottom:.5rem;right:.5rem}}@media(min-width:640px){.chatbot-container{bottom:1.5rem;right:1.5rem}}@media(min-width:768px){.chatbot-container{bottom:2rem;right:2rem}}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";"use client";var ue=Object.create;var j=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var r in t)j(e,r,{get:t[r],enumerable:!0})},ee=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of we(t))!ye.call(e,n)&&n!==r&&j(e,n,{get:()=>t[n],enumerable:!(a=be(t,n))||a.enumerable});return e};var H=(e,t,r)=>(r=e!=null?ue(xe(e)):{},ee(t||!e||!e.__esModule?j(r,"default",{value:e,enumerable:!0}):r,e)),ke=e=>ee(j({},"__esModule",{value:!0}),e);var Ee={};ve(Ee,{ChatBot:()=>X,ChatHeader:()=>W,ChatInput:()=>G,Chatbot:()=>X,ICONS:()=>I,MessageBubble:()=>U,Suggestions:()=>Q});module.exports=ke(Ee);var y=require("react");var p=require("react/jsx-runtime"),I={MessageCircle:({size:e=24,className:t=""})=>(0,p.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,p.jsx)("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})}),Bot:({size:e=24,className:t=""})=>(0,p.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,p.jsx)("path",{d:"M12 8V4m8 4V4M4 8V4M2 11h20m-1 0v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V11m5 5v2m8-2v2"})}),X:({size:e=24,className:t=""})=>(0,p.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,p.jsx)("path",{d:"M18 6 6 18M6 6l12 12"})}),Send:({size:e=24,className:t=""})=>(0,p.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,p.jsx)("path",{d:"m22 2-7 20-4-9-9-4Z"}),(0,p.jsx)("path",{d:"M22 2 11 13"})]}),Sparkles:({size:e=24,className:t=""})=>(0,p.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,p.jsx)("path",{d:"M12 2l1.8 4.6L18 8l-4.2 1.4L12 14l-1.8-4.6L6 8l4.2-1.4L12 2z"}),(0,p.jsx)("path",{d:"M5 16l.9 2.3L8 19l-2.1.7L5 22l-.9-2.3L2 19l2.1-.7L5 16z"}),(0,p.jsx)("path",{d:"M19 14l.9 2.3L22 17l-2.1.7L19 20l-.9-2.3L16 17l2.1-.7L19 14z"})]})};var S=require("react/jsx-runtime"),Ce=({isExpanded:e,onOpen:t,theming:r})=>(0,S.jsx)("div",{onClick:t,className:`chat-floating-btn ${e?"chat-btn-hidden":"chat-btn-visible"}`,children:(0,S.jsx)("div",{className:"chat-btn-border seamless-border",children:(0,S.jsxs)("div",{className:"chat-btn-inner",children:[(0,S.jsx)("div",{className:"chat-btn-gradient",style:{background:r?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary)0%, var(--cb-secondary)100%)"}}),(0,S.jsx)(I.Sparkles,{size:30,className:"chat-btn-icon"})]})})}),te=Ce;var O=require("react");var E=(e,t)=>t?`${e} ${t}`:e;var f=require("react/jsx-runtime"),Ne=({onClose:e,title:t,theming:r,strapiUrl:a})=>{let[n,m]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!a)return;(async()=>{try{let o=await(await fetch(`${a}/api/faq-ai-bot/suggestion-and-logo`)).json();o?.logoUrl&&m(`${a}${o.logoUrl}`)}catch(i){console.error("Failed to fetch logo",i)}})()},[a]);let g=E("chat-header",r?.header);return(0,f.jsxs)("header",{className:g,style:r?.headerStyle,children:[(0,f.jsxs)("div",{className:"chat-header-left",children:[(0,f.jsx)("div",{className:"chat-header-logo-placeholder",children:"A"}),(0,f.jsxs)("div",{className:"chat-header-title-wrap",children:[(0,f.jsxs)("div",{className:"chat-header-title-row",children:[(0,f.jsx)("span",{className:"chat-header-title",children:"Aria"}),(0,f.jsx)("span",{className:"chat-header-badge",children:t||"Assistant"})]}),(0,f.jsxs)("span",{className:"chat-header-status",children:[(0,f.jsx)("span",{className:"chat-header-status-dot"}),"Online \xB7 usually replies instantly"]})]})]}),(0,f.jsx)("div",{className:"chat-header-actions",children:(0,f.jsx)("button",{onClick:e,className:"chat-header-close-btn","aria-label":"Close chat",children:(0,f.jsx)(I.X,{size:20})})})]})},W=Ne;var Y=require("react");var k=require("react/jsx-runtime"),Ie=({input:e,onInputChange:t,onSendMessage:r,isLoading:a,theming:n})=>{let m=n?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%)",s=(0,Y.useRef)(null),u=E("chat-input-container",n?.input);(0,Y.useEffect)(()=>{a||s.current?.focus()},[a]);let i=l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&o()},o=()=>{e.trim()&&!a&&r()};return(0,k.jsx)("div",{className:"chat-input-outer",children:(0,k.jsx)("div",{className:"chat-input-wrap",children:(0,k.jsxs)("div",{className:"chat-input-row",children:[(0,k.jsx)("div",{className:u,style:{...n?.inputStyle,borderRadius:"9999px"},children:(0,k.jsx)("div",{className:"chat-input-inner",children:(0,k.jsx)("input",{ref:s,type:"text",className:"chat-input-field",placeholder:a?"AI is thinking...":"Type a message...",value:e,onChange:l=>t(l.target.value),onKeyDown:i,disabled:a,"aria-label":"User message"})})}),(0,k.jsx)("button",{onClick:o,disabled:a||!e.trim(),style:{background:m},className:"chat-input-send-btn","aria-label":"Send message",children:a?(0,k.jsx)("div",{className:"chat-input-spinner"}):(0,k.jsx)(I.Send,{className:"chat-input-send-icon"})})]})})})},G=Ie;var ae=require("react"),re=H(require("react-markdown")),oe=H(require("remark-gfm"));var q=H(require("react-markdown")),J=H(require("remark-gfm"));var d=require("react/jsx-runtime"),Se=({message:e,cardRegistry:t,themeStyles:r,theming:a})=>{let n=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase(),m=u=>{let i=u?.__collectionUid?.split(".").pop()?.toLowerCase();return t.find(o=>o.id===i)||t.find(o=>o.id==="default")},s=e.record?m(e.record)?.component:null,g={background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%)"};if(e.items?.items?.length){let u=e.items.cardStyle?.toLowerCase()||e.items.collection?.toLowerCase()||e.items.title?.toLowerCase(),o=t.find(l=>l.id===u)?.component;return(0,d.jsxs)("div",{className:"mb-card-container",children:[e.content&&(0,d.jsx)("div",{className:"mb-card-content",children:(0,d.jsx)(q.default,{remarkPlugins:[J.default],children:e.content})}),o&&e.items.items.map((l,N)=>(0,d.jsx)(o,{items:l,style:r},N))]})}return(0,d.jsxs)("div",{className:`mb-row ${e.role==="user"?"mb-row-user":"mb-row-assistant"}`,children:[s&&e.record?(0,d.jsx)("div",{className:"mb-card-wrapper",children:(0,d.jsx)(s,{record:e.record,style:r})}):(0,d.jsx)("div",{style:e.role==="user"?{...g,...a?.userBubbleStyle}:{},className:`mb-bubble ${e.role==="user"?"mb-bubble-user":"mb-bubble-assistant"}`,children:e.loading&&!e.content?(0,d.jsxs)("div",{className:"mb-typing",children:[(0,d.jsx)("span",{className:"mb-dot mb-dot-1"}),(0,d.jsx)("span",{className:"mb-dot mb-dot-2"}),(0,d.jsx)("span",{className:"mb-dot mb-dot-3"})]}):(0,d.jsx)("div",{className:"mb-content-wrapper",children:(0,d.jsx)(q.default,{remarkPlugins:[J.default],children:e.content||""})})}),e.role==="assistant"&&!s&&(0,d.jsxs)("div",{className:"mb-assistant-meta",children:[(0,d.jsx)("span",{className:"mb-assistant-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),(0,d.jsx)("span",{className:"mb-assistant-time",children:n})]}),e.role==="user"&&!s&&(0,d.jsxs)("div",{className:"mb-user-meta",children:[(0,d.jsx)("span",{className:"mb-user-time",children:n}),(0,d.jsx)("span",{className:"mb-user-tick","aria-label":"Delivered",children:"\u2713\u2713"})]})]})},U=Se;var C=require("react/jsx-runtime"),Me=({messages:e,scrollRef:t,resolvedRegistry:r,theming:a})=>{let n=a?.welcomeDescription||"Hi! I'm Aria, your Harbour Air travel assistant. I'm here to help you book flights, check fees, understand baggage rules, and anything else you need.",m=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase();return(0,ae.useEffect)(()=>{let s=t.current;s&&s.scrollTo({top:s.scrollHeight,behavior:"auto"})},[e,t]),(0,C.jsxs)("div",{ref:t,className:"chat-messages-container",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[e.length===0&&(0,C.jsx)("div",{className:"chat-welcome",children:(0,C.jsxs)("div",{className:"chat-welcome-message",children:[(0,C.jsx)("p",{className:"chat-welcome-subtitle",children:(0,C.jsx)(re.default,{remarkPlugins:[oe.default],children:n})}),(0,C.jsxs)("div",{className:"chat-welcome-meta",children:[(0,C.jsx)("span",{className:"chat-welcome-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),(0,C.jsx)("span",{className:"chat-welcome-time",children:m})]})]})}),e.map(s=>(0,C.jsx)(U,{message:s,cardRegistry:r,themeStyles:{"--cb-primary":a?.primaryColor||"#2999d6","--cb-secondary":a?.secondaryColor||"#179fa3","--cb-accent":a?.accentColor||a?.secondaryColor||"#179fa3"},theming:a},s.id))]})},ie=Me;var D=require("react");var b=require("react/jsx-runtime"),Re=({strapiUrl:e,onSelectQuestion:t,variant:r,theming:a})=>{let[n,m]=(0,D.useState)([]),[s,g]=(0,D.useState)(!0);(0,D.useEffect)(()=>{let i=new AbortController;return g(!0),fetch(`${e}/api/faq-ai-bot/suggestion-and-logo`,{signal:i.signal}).then(o=>o.json()).then(o=>{m(o.suggestedQuestions||[]),g(!1)}).catch(o=>{o.name!=="AbortError"&&(console.error("Suggestions fetch failed",o),g(!1))}),()=>i.abort()},[e]);let u=()=>r==="floating"?(0,b.jsxs)("div",{className:"sug-skeleton-float",children:[[1,2].map(i=>(0,b.jsx)("div",{className:"sug-skeleton-item",style:{backgroundColor:a?.primaryColor?`${a.primaryColor}`:"hsla(178, 100%, 51%, 0.05)",transform:i%2===0?"rotate(1deg)":"rotate(-1deg)"}},i)),(0,b.jsx)("div",{className:"sug-skeleton-more"})]}):(0,b.jsx)("div",{className:"sug-skeleton-list",children:[1,2,3].map(i=>(0,b.jsx)("div",{className:"sug-skeleton-chip"},i))});return s&&n.length===0?(0,b.jsx)(u,{}):r==="floating"?(0,b.jsx)("div",{className:"sug-float-wrap",children:n.map((i,o)=>(0,b.jsx)("button",{onClick:()=>t(i),className:"sug-float-btn",style:{borderColor:"#bfdbfe",animationDelay:`${o*.1}s`},children:(0,b.jsx)("span",{className:"sug-float-text",children:i})},`float-${o}-${i}`))}):(0,b.jsx)("div",{className:"sug-list-wrap",children:n.map((i,o)=>(0,b.jsx)("button",{onClick:()=>t(i),className:"sug-list-btn",style:{animationDelay:`${o*.05}s`},children:i},`list-${o}-${i}`))})},Q=Re;var x=require("react/jsx-runtime"),Le=({isExpanded:e,setIsExpanded:t,messages:r,scrollRef:a,sendMessage:n,strapiUrl:m,resolvedRegistry:s,input:g,setInput:u,isLoading:i,title:o,theming:l})=>{let N=E(`chat-window ${e?"chat-window-open":"chat-window-closed"}`,l?.container);return(0,x.jsxs)("div",{className:N,style:l?.containerStyle,children:[(0,x.jsx)("div",{className:"chat-window-header",children:(0,x.jsx)(W,{title:o,onClose:()=>t(!1),theming:l,strapiUrl:m})}),(0,x.jsx)(ie,{messages:r,scrollRef:a,resolvedRegistry:s,theming:l}),(0,x.jsxs)("div",{className:"chat-window-footer",children:[(0,x.jsx)("div",{className:"chat-window-suggestions",children:(0,x.jsx)(Q,{onSelectQuestion:n,strapiUrl:m,variant:"floating",theming:l})}),(0,x.jsx)(G,{input:g,onInputChange:u,onSendMessage:n,isLoading:i,theming:l}),(0,x.jsx)("div",{className:"chat-window-powered",children:(0,x.jsx)("span",{className:"chat-powered-text",children:"Talk to a human \xB7 Privacy policy"})})]})]})},ne=Le;var F=require("react/jsx-runtime"),Be=({strapiUrl:e,cardRegistry:t,theme:r,title:a,streamSpeed:n})=>{let[m,s]=(0,y.useState)([]),[g,u]=(0,y.useState)(""),[i,o]=(0,y.useState)(!1),[l,N]=(0,y.useState)(!1),$=(0,y.useRef)(null),[se,de]=(0,y.useState)([]),le=(0,y.useRef)(null),ce={"--cb-primary":r?.primaryColor||"#2999d6","--cb-secondary":r?.secondaryColor||"#179fa3","--cb-accent":r?.accentColor||r?.secondaryColor||"#179fa3"};return(0,y.useEffect)(()=>{t.length>0&&de(t)},[t]),(0,y.useEffect)(()=>()=>$.current?.abort(),[]),(0,F.jsxs)("div",{className:"chatbot-container",style:ce,children:[(0,F.jsx)(te,{isExpanded:l,onOpen:()=>N(!0),theming:r}),(0,F.jsx)(ne,{isExpanded:l,setIsExpanded:N,messages:m,scrollRef:le,sendMessage:async me=>{let V=me||g;if(!V.trim())return;$.current?.abort(),$.current=new AbortController,N(!0),u(""),o(!0);let pe={role:"user",content:V,id:Date.now()},M=Date.now()+1;s(R=>[...R,pe,{role:"assistant",content:"",items:null,loading:!0,id:M}]);try{let R=await fetch(`${e}/api/faq-ai-bot/ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:V,history:m.slice(-4).map(h=>({role:h.role,content:h.content}))}),signal:$.current.signal});if(!R.ok)throw new Error("Network response was not ok");let A=R.body?.getReader(),z=new TextDecoder;if(!A)throw new Error("No reader available");let T=[],Z=!1,he=(async()=>{for(;!Z||T.length>0;)if(T.length>0){let h=T.shift();if(h?.type==="text")if(n&&n>0)for(let c of h.content)s(w=>w.map(v=>v.id===M?{...v,content:v.content+c}:v)),await new Promise(w=>setTimeout(w,n));else s(c=>c.map(w=>w.id===M?{...w,content:w.content+h.content}:w));else if(h?.type==="card")try{let c=h.data;s(w=>w.map(v=>v.id===M?{...v,items:{items:c.items,schema:c.schema,collection:c.title,title:c.title,cardStyle:c.cardStyle}}:v))}catch(c){console.error("Error processing card data:",c)}}else await new Promise(h=>setTimeout(h,20));o(!1),s(h=>h.map(c=>c.id===M?{...c,loading:!1}:c))})(),K="";for(;;){let{value:h,done:c}=await A.read();if(c)break;let w=z.decode(h,{stream:!0});K+=w;let v=K.split(`
|
|
1
|
+
"use strict";"use client";var ge=Object.create;var j=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var a in t)j(e,a,{get:t[a],enumerable:!0})},ee=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of we(t))!ye.call(e,i)&&i!==a&&j(e,i,{get:()=>t[i],enumerable:!(r=ue(t,i))||r.enumerable});return e};var H=(e,t,a)=>(a=e!=null?ge(xe(e)):{},ee(t||!e||!e.__esModule?j(a,"default",{value:e,enumerable:!0}):a,e)),ke=e=>ee(j({},"__esModule",{value:!0}),e);var Be={};ve(Be,{ChatBot:()=>X,ChatHeader:()=>W,ChatInput:()=>G,Chatbot:()=>X,ICONS:()=>M,MessageBubble:()=>U,Suggestions:()=>q});module.exports=ke(Be);var y=require("react");var p=require("react/jsx-runtime"),M={MessageCircle:({size:e=24,className:t=""})=>(0,p.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,p.jsx)("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})}),Bot:({size:e=24,className:t=""})=>(0,p.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,p.jsx)("path",{d:"M12 8V4m8 4V4M4 8V4M2 11h20m-1 0v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V11m5 5v2m8-2v2"})}),X:({size:e=24,className:t=""})=>(0,p.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,p.jsx)("path",{d:"M18 6 6 18M6 6l12 12"})}),Send:({size:e=24,className:t=""})=>(0,p.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,p.jsx)("path",{d:"m22 2-7 20-4-9-9-4Z"}),(0,p.jsx)("path",{d:"M22 2 11 13"})]}),Sparkles:({size:e=24,className:t=""})=>(0,p.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,p.jsx)("path",{d:"M12 2l1.8 4.6L18 8l-4.2 1.4L12 14l-1.8-4.6L6 8l4.2-1.4L12 2z"}),(0,p.jsx)("path",{d:"M5 16l.9 2.3L8 19l-2.1.7L5 22l-.9-2.3L2 19l2.1-.7L5 16z"}),(0,p.jsx)("path",{d:"M19 14l.9 2.3L22 17l-2.1.7L19 20l-.9-2.3L16 17l2.1-.7L19 14z"})]})};var I=require("react/jsx-runtime"),Ce=({isExpanded:e,onOpen:t,theming:a})=>(0,I.jsx)("div",{onClick:t,className:`chat-floating-btn ${e?"chat-btn-hidden":"chat-btn-visible"}`,children:(0,I.jsx)("div",{className:"chat-btn-border seamless-border",children:(0,I.jsxs)("div",{className:"chat-btn-inner",children:[(0,I.jsx)("div",{className:"chat-btn-gradient",style:{background:a?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary)0%, var(--cb-secondary)100%)"}}),(0,I.jsx)(M.Sparkles,{size:30,className:"chat-btn-icon"})]})})}),te=Ce;var O=require("react");var B=(e,t)=>t?`${e} ${t}`:e;var f=require("react/jsx-runtime"),Ne=({onClose:e,title:t,theming:a,strapiUrl:r})=>{let[i,m]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!r)return;(async()=>{try{let o=await(await fetch(`${r}/api/faq-ai-bot/suggestion-and-logo`)).json();o?.logoUrl&&m(`${r}${o.logoUrl}`)}catch(n){console.error("Failed to fetch logo",n)}})()},[r]);let b=B("chat-header",a?.header);return(0,f.jsxs)("header",{className:b,style:a?.headerStyle,children:[(0,f.jsxs)("div",{className:"chat-header-left",children:[(0,f.jsx)("div",{className:"chat-header-logo-placeholder",children:"A"}),(0,f.jsxs)("div",{className:"chat-header-title-wrap",children:[(0,f.jsxs)("div",{className:"chat-header-title-row",children:[(0,f.jsx)("span",{className:"chat-header-title",children:"Aria"}),(0,f.jsx)("span",{className:"chat-header-badge",children:t||"Assistant"})]}),(0,f.jsxs)("span",{className:"chat-header-status",children:[(0,f.jsx)("span",{className:"chat-header-status-dot"}),"Online \xB7 usually replies instantly"]})]})]}),(0,f.jsx)("div",{className:"chat-header-actions",children:(0,f.jsx)("button",{onClick:e,className:"chat-header-close-btn","aria-label":"Close chat",children:(0,f.jsx)(M.X,{size:20})})})]})},W=Ne;var Y=require("react");var k=require("react/jsx-runtime"),Me=({input:e,onInputChange:t,onSendMessage:a,isLoading:r,theming:i})=>{let m=i?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%)",s=(0,Y.useRef)(null),g=B("chat-input-container",i?.input);(0,Y.useEffect)(()=>{r||s.current?.focus()},[r]);let n=l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&o()},o=()=>{e.trim()&&!r&&a()};return(0,k.jsx)("div",{className:"chat-input-outer",children:(0,k.jsx)("div",{className:"chat-input-wrap",children:(0,k.jsxs)("div",{className:"chat-input-row",children:[(0,k.jsx)("div",{className:g,style:{...i?.inputStyle,borderRadius:"9999px"},children:(0,k.jsx)("div",{className:"chat-input-inner",children:(0,k.jsx)("input",{ref:s,type:"text",className:"chat-input-field",placeholder:r?"AI is thinking...":"Type a message...",value:e,onChange:l=>t(l.target.value),onKeyDown:n,disabled:r,"aria-label":"User message"})})}),(0,k.jsx)("button",{onClick:o,disabled:r||!e.trim(),style:{background:m},className:"chat-input-send-btn","aria-label":"Send message",children:r?(0,k.jsx)("div",{className:"chat-input-spinner"}):(0,k.jsx)(M.Send,{className:"chat-input-send-icon"})})]})})})},G=Me;var re=require("react"),ae=H(require("react-markdown")),oe=H(require("remark-gfm"));var K=H(require("react-markdown")),J=H(require("remark-gfm"));var d=require("react/jsx-runtime"),Ie=({message:e,cardRegistry:t,themeStyles:a,theming:r})=>{let i=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase(),m=g=>{let n=g?.__collectionUid?.split(".").pop()?.toLowerCase();return t.find(o=>o.id===n)||t.find(o=>o.id==="default")},s=e.record?m(e.record)?.component:null,b={background:r?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%)"};if(e.items?.items?.length){let g=e.items.cardStyle?.toLowerCase()||e.items.collection?.toLowerCase()||e.items.title?.toLowerCase(),o=t.find(l=>l.id===g)?.component;return(0,d.jsxs)("div",{className:"mb-card-container",children:[e.content&&(0,d.jsx)("div",{className:"mb-card-content",children:(0,d.jsx)(K.default,{remarkPlugins:[J.default],children:e.content})}),o&&e.items.items.map((l,N)=>(0,d.jsx)(o,{items:l,style:a},N))]})}return(0,d.jsxs)("div",{className:`mb-row ${e.role==="user"?"mb-row-user":"mb-row-assistant"}`,children:[s&&e.record?(0,d.jsx)("div",{className:"mb-card-wrapper",children:(0,d.jsx)(s,{record:e.record,style:a})}):(0,d.jsx)("div",{style:e.role==="user"?{...b,...r?.userBubbleStyle}:{},className:`mb-bubble ${e.role==="user"?"mb-bubble-user":"mb-bubble-assistant"}`,children:e.loading&&!e.content?(0,d.jsxs)("div",{className:"mb-typing",children:[(0,d.jsx)("span",{className:"mb-dot mb-dot-1"}),(0,d.jsx)("span",{className:"mb-dot mb-dot-2"}),(0,d.jsx)("span",{className:"mb-dot mb-dot-3"})]}):(0,d.jsx)("div",{className:"mb-content-wrapper",children:(0,d.jsx)(K.default,{remarkPlugins:[J.default],children:e.content||""})})}),e.role==="assistant"&&!s&&(0,d.jsxs)("div",{className:"mb-assistant-meta",children:[(0,d.jsx)("span",{className:"mb-assistant-avatar",style:{background:r?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),(0,d.jsx)("span",{className:"mb-assistant-time",children:i})]}),e.role==="user"&&!s&&(0,d.jsxs)("div",{className:"mb-user-meta",children:[(0,d.jsx)("span",{className:"mb-user-time",children:i}),(0,d.jsx)("span",{className:"mb-user-tick","aria-label":"Delivered",children:"\u2713\u2713"})]})]})},U=Ie;var C=require("react/jsx-runtime"),Se=({messages:e,scrollRef:t,resolvedRegistry:a,theming:r})=>{let i=r?.welcomeDescription||"Hi! I'm Aria, your Harbour Air travel assistant. I'm here to help you book flights, check fees, understand baggage rules, and anything else you need.",m=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase();return(0,re.useEffect)(()=>{let s=t.current;s&&s.scrollTo({top:s.scrollHeight,behavior:"auto"})},[e,t]),(0,C.jsxs)("div",{ref:t,className:"chat-messages-container",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[e.length===0&&(0,C.jsx)("div",{className:"chat-welcome",children:(0,C.jsxs)("div",{className:"chat-welcome-message",children:[(0,C.jsx)("p",{className:"chat-welcome-subtitle",children:(0,C.jsx)(ae.default,{remarkPlugins:[oe.default],children:i})}),(0,C.jsxs)("div",{className:"chat-welcome-meta",children:[(0,C.jsx)("span",{className:"chat-welcome-avatar",style:{background:r?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),(0,C.jsx)("span",{className:"chat-welcome-time",children:m})]})]})}),e.map(s=>(0,C.jsx)(U,{message:s,cardRegistry:a,themeStyles:{"--cb-primary":r?.primaryColor||"#2999d6","--cb-secondary":r?.secondaryColor||"#179fa3","--cb-accent":r?.accentColor||r?.secondaryColor||"#179fa3"},theming:r},s.id))]})},ne=Se;var D=require("react");var u=require("react/jsx-runtime"),Re=({strapiUrl:e,onSelectQuestion:t,variant:a,theming:r})=>{let[i,m]=(0,D.useState)([]),[s,b]=(0,D.useState)(!0);(0,D.useEffect)(()=>{let n=new AbortController;return b(!0),fetch(`${e}/api/faq-ai-bot/suggestion-and-logo`,{signal:n.signal}).then(o=>o.json()).then(o=>{m(o.suggestedQuestions||[]),b(!1)}).catch(o=>{o.name!=="AbortError"&&(console.error("Suggestions fetch failed",o),b(!1))}),()=>n.abort()},[e]);let g=()=>a==="floating"?(0,u.jsxs)("div",{className:"sug-skeleton-float",children:[[1,2].map(n=>(0,u.jsx)("div",{className:"sug-skeleton-item",style:{backgroundColor:r?.primaryColor?`${r.primaryColor}`:"hsla(178, 100%, 51%, 0.05)",transform:n%2===0?"rotate(1deg)":"rotate(-1deg)"}},n)),(0,u.jsx)("div",{className:"sug-skeleton-more"})]}):(0,u.jsx)("div",{className:"sug-skeleton-list",children:[1,2,3].map(n=>(0,u.jsx)("div",{className:"sug-skeleton-chip"},n))});return s&&i.length===0?(0,u.jsx)(g,{}):a==="floating"?(0,u.jsx)("div",{className:"sug-float-wrap",children:i.map((n,o)=>(0,u.jsx)("button",{onClick:()=>t(n),className:"sug-float-btn",style:{borderColor:"#bfdbfe",animationDelay:`${o*.1}s`},children:(0,u.jsx)("span",{className:"sug-float-text",children:n})},`float-${o}-${n}`))}):(0,u.jsx)("div",{className:"sug-list-wrap",children:i.map((n,o)=>(0,u.jsx)("button",{onClick:()=>t(n),className:"sug-list-btn",style:{animationDelay:`${o*.05}s`},children:n},`list-${o}-${n}`))})},q=Re;var x=require("react/jsx-runtime"),Le=({isExpanded:e,setIsExpanded:t,messages:a,scrollRef:r,sendMessage:i,strapiUrl:m,resolvedRegistry:s,input:b,setInput:g,isLoading:n,title:o,theming:l})=>{let N=B(`chat-window ${e?"chat-window-open":"chat-window-closed"}`,l?.container);return(0,x.jsxs)("div",{className:N,style:l?.containerStyle,children:[(0,x.jsx)("div",{className:"chat-window-header",children:(0,x.jsx)(W,{title:o,onClose:()=>t(!1),theming:l,strapiUrl:m})}),(0,x.jsx)(ne,{messages:a,scrollRef:r,resolvedRegistry:s,theming:l}),(0,x.jsxs)("div",{className:"chat-window-footer",children:[(0,x.jsx)("div",{className:"chat-window-suggestions",children:(0,x.jsx)(q,{onSelectQuestion:i,strapiUrl:m,variant:"floating",theming:l})}),(0,x.jsx)(G,{input:b,onInputChange:g,onSendMessage:i,isLoading:n,theming:l}),(0,x.jsx)("div",{className:"chat-window-powered",children:(0,x.jsx)("span",{className:"chat-powered-text",children:"Talk to a human \xB7 Privacy policy"})})]})]})},ie=Le;var F=require("react/jsx-runtime"),ze=({strapiUrl:e,cardRegistry:t,theme:a,title:r,streamSpeed:i})=>{let[m,s]=(0,y.useState)([]),[b,g]=(0,y.useState)(""),[n,o]=(0,y.useState)(!1),[l,N]=(0,y.useState)(!1),$=(0,y.useRef)(null),[se,de]=(0,y.useState)([]),le=(0,y.useRef)(null),ce={"--cb-primary":a?.primaryColor||"#2999d6","--cb-secondary":a?.secondaryColor||"#179fa3","--cb-accent":a?.accentColor||a?.secondaryColor||"#179fa3"};return(0,y.useEffect)(()=>{t.length>0&&de(t)},[t]),(0,y.useEffect)(()=>()=>$.current?.abort(),[]),(0,F.jsxs)("div",{className:"chatbot-container",style:ce,children:[(0,F.jsx)(te,{isExpanded:l,onOpen:()=>N(!0),theming:a}),(0,F.jsx)(ie,{isExpanded:l,setIsExpanded:N,messages:m,scrollRef:le,sendMessage:async me=>{let Q=me||b;if(!Q.trim())return;$.current?.abort(),$.current=new AbortController,N(!0),g(""),o(!0);let pe={role:"user",content:Q,id:Date.now()},S=Date.now()+1;s(R=>[...R,pe,{role:"assistant",content:"",items:null,loading:!0,id:S}]);try{let R=await fetch(`${e}/api/faq-ai-bot/ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:Q,history:m.slice(-4).map(h=>({role:h.role,content:h.content}))}),signal:$.current.signal});if(!R.ok)throw new Error("Network response was not ok");let A=R.body?.getReader(),E=new TextDecoder;if(!A)throw new Error("No reader available");let T=[],Z=!1,he=(async()=>{for(;!Z||T.length>0;)if(T.length>0){let h=T.shift();if(h?.type==="text")if(i&&i>0)for(let c of h.content)s(w=>w.map(v=>v.id===S?{...v,content:v.content+c}:v)),await new Promise(w=>setTimeout(w,i));else s(c=>c.map(w=>w.id===S?{...w,content:w.content+h.content}:w));else if(h?.type==="card")try{let c=h.data;s(w=>w.map(v=>v.id===S?{...v,items:{items:c.items,schema:c.schema,collection:c.title,title:c.title,cardStyle:c.cardStyle}}:v))}catch(c){console.error("Error processing card data:",c)}}else await new Promise(h=>setTimeout(h,20));o(!1),s(h=>h.map(c=>c.id===S?{...c,loading:!1}:c))})(),V="";for(;;){let{value:h,done:c}=await A.read();if(c)break;let w=E.decode(h,{stream:!0});V+=w;let v=V.split(`
|
|
2
2
|
|
|
3
|
-
`);
|
|
4
|
-
`),_="message",P="";for(let L of
|
|
5
|
-
`:"")+
|
|
3
|
+
`);V=v.pop()||"";for(let fe of v){let be=fe.split(`
|
|
4
|
+
`),_="message",P="";for(let L of be)if(L.startsWith("event:"))_=L.slice(6).trim();else if(L.startsWith("data:")){let z=L.slice(5);if(z.startsWith(" ")&&(z=z.slice(1)),z.trim()==="[DONE]"||z.trim()==="[Done]")continue;P+=(P?`
|
|
5
|
+
`:"")+z}if(_==="cards"){let L=JSON.parse(P);T.push({type:"card",data:L})}else P&&T.push({type:"text",content:P})}}Z=!0,await he}catch(R){R.name!=="AbortError"&&s(A=>A.map(E=>E.id===S?{...E,content:"I'm sorry, I'm having trouble connecting right now.",loading:!1}:E)),o(!1)}},strapiUrl:e,resolvedRegistry:se,input:b,setInput:g,isLoading:n,title:r,theming:a})]})},X=ze;0&&(module.exports={ChatBot,ChatHeader,ChatInput,Chatbot,ICONS,MessageBubble,Suggestions});
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use client";import{useState as D,useEffect as ae,useRef as re}from"react";import{jsx as b,jsxs as K}from"react/jsx-runtime";var M={MessageCircle:({size:e=24,className:t=""})=>b("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:b("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})}),Bot:({size:e=24,className:t=""})=>b("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:b("path",{d:"M12 8V4m8 4V4M4 8V4M2 11h20m-1 0v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V11m5 5v2m8-2v2"})}),X:({size:e=24,className:t=""})=>b("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:b("path",{d:"M18 6 6 18M6 6l12 12"})}),Send:({size:e=24,className:t=""})=>K("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[b("path",{d:"m22 2-7 20-4-9-9-4Z"}),b("path",{d:"M22 2 11 13"})]}),Sparkles:({size:e=24,className:t=""})=>K("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[b("path",{d:"M12 2l1.8 4.6L18 8l-4.2 1.4L12 14l-1.8-4.6L6 8l4.2-1.4L12 2z"}),b("path",{d:"M5 16l.9 2.3L8 19l-2.1.7L5 22l-.9-2.3L2 19l2.1-.7L5 16z"}),b("path",{d:"M19 14l.9 2.3L22 17l-2.1.7L19 20l-.9-2.3L16 17l2.1-.7L19 14z"})]})};import{jsx as A,jsxs as ue}from"react/jsx-runtime";var ge=({isExpanded:e,onOpen:t,theming:n})=>A("div",{onClick:t,className:`chat-floating-btn ${e?"chat-btn-hidden":"chat-btn-visible"}`,children:A("div",{className:"chat-btn-border seamless-border",children:ue("div",{className:"chat-btn-inner",children:[A("div",{className:"chat-btn-gradient",style:{background:n?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary)0%, var(--cb-secondary)100%)"}}),A(M.Sparkles,{size:30,className:"chat-btn-icon"})]})})}),q=ge;import{useEffect as be,useState as we}from"react";var R=(e,t)=>t?`${e} ${t}`:e;import{jsx as k,jsxs as T}from"react/jsx-runtime";var xe=({onClose:e,title:t,theming:n,strapiUrl:a})=>{let[s,c]=we(null);be(()=>{if(!a)return;(async()=>{try{let r=await(await fetch(`${a}/api/faq-ai-bot/suggestion-and-logo`)).json();r?.logoUrl&&c(`${a}${r.logoUrl}`)}catch(o){console.error("Failed to fetch logo",o)}})()},[a]);let h=R("chat-header",n?.header);return T("header",{className:h,style:n?.headerStyle,children:[T("div",{className:"chat-header-left",children:[k("div",{className:"chat-header-logo-placeholder",children:"A"}),T("div",{className:"chat-header-title-wrap",children:[T("div",{className:"chat-header-title-row",children:[k("span",{className:"chat-header-title",children:"Aria"}),k("span",{className:"chat-header-badge",children:t||"Assistant"})]}),T("span",{className:"chat-header-status",children:[k("span",{className:"chat-header-status-dot"}),"Online \xB7 usually replies instantly"]})]})]}),k("div",{className:"chat-header-actions",children:k("button",{onClick:e,className:"chat-header-close-btn","aria-label":"Close chat",children:k(M.X,{size:20})})})]})},O=xe;import{useRef as ye,useEffect as ve}from"react";import{jsx as x,jsxs as Ce}from"react/jsx-runtime";var ke=({input:e,onInputChange:t,onSendMessage:n,isLoading:a,theming:s})=>{let c=s?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%)",i=ye(null),f=R("chat-input-container",s?.input);ve(()=>{a||i.current?.focus()},[a]);let o=d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&r()},r=()=>{e.trim()&&!a&&n()};return x("div",{className:"chat-input-outer",children:x("div",{className:"chat-input-wrap",children:Ce("div",{className:"chat-input-row",children:[x("div",{className:f,style:{...s?.inputStyle,borderRadius:"9999px"},children:x("div",{className:"chat-input-inner",children:x("input",{ref:i,type:"text",className:"chat-input-field",placeholder:a?"AI is thinking...":"Type a message...",value:e,onChange:d=>t(d.target.value),onKeyDown:o,disabled:a,"aria-label":"User message"})})}),x("button",{onClick:r,disabled:a||!e.trim(),style:{background:c},className:"chat-input-send-btn","aria-label":"Send message",children:a?x("div",{className:"chat-input-spinner"}):x(M.Send,{className:"chat-input-send-icon"})})]})})})},W=ke;import{useEffect as Ie}from"react";import Se from"react-markdown";import Me from"remark-gfm";import J from"react-markdown";import X from"remark-gfm";import{jsx as m,jsxs as P}from"react/jsx-runtime";var Ne=({message:e,cardRegistry:t,themeStyles:n,theming:a})=>{let s=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase(),c=f=>{let o=f?.__collectionUid?.split(".").pop()?.toLowerCase();return t.find(r=>r.id===o)||t.find(r=>r.id==="default")},i=e.record?c(e.record)?.component:null,h={background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%)"};if(e.items?.items?.length){let f=e.items.cardStyle?.toLowerCase()||e.items.collection?.toLowerCase()||e.items.title?.toLowerCase(),r=t.find(d=>d.id===f)?.component;return P("div",{className:"mb-card-container",children:[e.content&&m("div",{className:"mb-card-content",children:m(J,{remarkPlugins:[X],children:e.content})}),r&&e.items.items.map((d,v)=>m(r,{items:d,style:n},v))]})}return P("div",{className:`mb-row ${e.role==="user"?"mb-row-user":"mb-row-assistant"}`,children:[i&&e.record?m("div",{className:"mb-card-wrapper",children:m(i,{record:e.record,style:n})}):m("div",{style:e.role==="user"?{...h,...a?.userBubbleStyle}:{},className:`mb-bubble ${e.role==="user"?"mb-bubble-user":"mb-bubble-assistant"}`,children:e.loading&&!e.content?P("div",{className:"mb-typing",children:[m("span",{className:"mb-dot mb-dot-1"}),m("span",{className:"mb-dot mb-dot-2"}),m("span",{className:"mb-dot mb-dot-3"})]}):m("div",{className:"mb-content-wrapper",children:m(J,{remarkPlugins:[X],children:e.content||""})})}),e.role==="assistant"&&!i&&P("div",{className:"mb-assistant-meta",children:[m("span",{className:"mb-assistant-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),m("span",{className:"mb-assistant-time",children:s})]}),e.role==="user"&&!i&&P("div",{className:"mb-user-meta",children:[m("span",{className:"mb-user-time",children:s}),m("span",{className:"mb-user-tick","aria-label":"Delivered",children:"\u2713\u2713"})]})]})},Y=Ne;import{jsx as L,jsxs as G}from"react/jsx-runtime";var Re=({messages:e,scrollRef:t,resolvedRegistry:n,theming:a})=>{let s=a?.welcomeDescription||"Hi! I'm Aria, your Harbour Air travel assistant. I'm here to help you book flights, check fees, understand baggage rules, and anything else you need.",c=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase();return Ie(()=>{let i=t.current;i&&i.scrollTo({top:i.scrollHeight,behavior:"auto"})},[e,t]),G("div",{ref:t,className:"chat-messages-container",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[e.length===0&&L("div",{className:"chat-welcome",children:G("div",{className:"chat-welcome-message",children:[L("p",{className:"chat-welcome-subtitle",children:L(Se,{remarkPlugins:[Me],children:s})}),G("div",{className:"chat-welcome-meta",children:[L("span",{className:"chat-welcome-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),L("span",{className:"chat-welcome-time",children:c})]})]})}),e.map(i=>L(Y,{message:i,cardRegistry:n,themeStyles:{"--cb-primary":a?.primaryColor||"#2999d6","--cb-secondary":a?.secondaryColor||"#179fa3","--cb-accent":a?.accentColor||a?.secondaryColor||"#179fa3"},theming:a},i.id))]})},Z=Re;import{useState as _,useEffect as Le}from"react";import{jsx as w,jsxs as Ee}from"react/jsx-runtime";var Be=({strapiUrl:e,onSelectQuestion:t,variant:n,theming:a})=>{let[s,c]=_([]),[i,h]=_(!0);Le(()=>{let o=new AbortController;return h(!0),fetch(`${e}/api/faq-ai-bot/suggestion-and-logo`,{signal:o.signal}).then(r=>r.json()).then(r=>{c(r.suggestedQuestions||[]),h(!1)}).catch(r=>{r.name!=="AbortError"&&(console.error("Suggestions fetch failed",r),h(!1))}),()=>o.abort()},[e]);let f=()=>n==="floating"?Ee("div",{className:"sug-skeleton-float",children:[[1,2].map(o=>w("div",{className:"sug-skeleton-item",style:{backgroundColor:a?.primaryColor?`${a.primaryColor}`:"hsla(178, 100%, 51%, 0.05)",transform:o%2===0?"rotate(1deg)":"rotate(-1deg)"}},o)),w("div",{className:"sug-skeleton-more"})]}):w("div",{className:"sug-skeleton-list",children:[1,2,3].map(o=>w("div",{className:"sug-skeleton-chip"},o))});return i&&s.length===0?w(f,{}):n==="floating"?w("div",{className:"sug-float-wrap",children:s.map((o,r)=>w("button",{onClick:()=>t(o),className:"sug-float-btn",style:{borderColor:"#bfdbfe",animationDelay:`${r*.1}s`},children:w("span",{className:"sug-float-text",children:o})},`float-${r}-${o}`))}):w("div",{className:"sug-list-wrap",children:s.map((o,r)=>w("button",{onClick:()=>t(o),className:"sug-list-btn",style:{animationDelay:`${r*.05}s`},children:o},`list-${r}-${o}`))})},U=Be;import{jsx as y,jsxs as ee}from"react/jsx-runtime";var ze=({isExpanded:e,setIsExpanded:t,messages:n,scrollRef:a,sendMessage:s,strapiUrl:c,resolvedRegistry:i,input:h,setInput:f,isLoading:o,title:r,theming:d})=>{let v=R(`chat-window ${e?"chat-window-open":"chat-window-closed"}`,d?.container);return ee("div",{className:v,style:d?.containerStyle,children:[y("div",{className:"chat-window-header",children:y(O,{title:r,onClose:()=>t(!1),theming:d,strapiUrl:c})}),y(Z,{messages:n,scrollRef:a,resolvedRegistry:i,theming:d}),ee("div",{className:"chat-window-footer",children:[y("div",{className:"chat-window-suggestions",children:y(U,{onSelectQuestion:s,strapiUrl:c,variant:"floating",theming:d})}),y(W,{input:h,onInputChange:f,onSendMessage:s,isLoading:o,theming:d}),y("div",{className:"chat-window-powered",children:y("span",{className:"chat-powered-text",children:"Talk to a human \xB7 Privacy policy"})})]})]})},te=ze;import{jsx as oe,jsxs as Pe}from"react/jsx-runtime";var Te=({strapiUrl:e,cardRegistry:t,theme:n,title:a,streamSpeed:s})=>{let[c,i]=D([]),[h,f]=D(""),[o,r]=D(!1),[d,v]=D(!1),F=re(null),[ne,se]=D([]),de=re(null),le={"--cb-primary":n?.primaryColor||"#2999d6","--cb-secondary":n?.secondaryColor||"#179fa3","--cb-accent":n?.accentColor||n?.secondaryColor||"#179fa3"};return ae(()=>{t.length>0&&se(t)},[t]),ae(()=>()=>F.current?.abort(),[]),Pe("div",{className:"chatbot-container",style:le,children:[oe(q,{isExpanded:d,onOpen:()=>v(!0),theming:n}),oe(te,{isExpanded:d,setIsExpanded:v,messages:c,scrollRef:de,sendMessage:async ce=>{let j=ce||h;if(!j.trim())return;F.current?.abort(),F.current=new AbortController,v(!0),f(""),r(!0);let me={role:"user",content:j,id:Date.now()},C=Date.now()+1;i(N=>[...N,me,{role:"assistant",content:"",items:null,loading:!0,id:C}]);try{let N=await fetch(`${e}/api/faq-ai-bot/ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:j,history:c.slice(-4).map(p=>({role:p.role,content:p.content}))}),signal:F.current.signal});if(!N.ok)throw new Error("Network response was not ok");let $=N.body?.getReader(),B=new TextDecoder;if(!$)throw new Error("No reader available");let E=[],Q=!1,pe=(async()=>{for(;!Q||E.length>0;)if(E.length>0){let p=E.shift();if(p?.type==="text")if(s&&s>0)for(let l of p.content)i(g=>g.map(u=>u.id===C?{...u,content:u.content+l}:u)),await new Promise(g=>setTimeout(g,s));else i(l=>l.map(g=>g.id===C?{...g,content:g.content+p.content}:g));else if(p?.type==="card")try{let l=p.data;i(g=>g.map(u=>u.id===C?{...u,items:{items:l.items,schema:l.schema,collection:l.title,title:l.title,cardStyle:l.cardStyle}}:u))}catch(l){console.error("Error processing card data:",l)}}else await new Promise(p=>setTimeout(p,20));r(!1),i(p=>p.map(l=>l.id===C?{...l,loading:!1}:l))})(),H="";for(;;){let{value:p,done:l}=await $.read();if(l)break;let g=B.decode(p,{stream:!0});H+=g;let u=H.split(`
|
|
1
|
+
"use client";import{useState as D,useEffect as re,useRef as ae}from"react";import{jsx as u,jsxs as V}from"react/jsx-runtime";var S={MessageCircle:({size:e=24,className:t=""})=>u("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:u("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})}),Bot:({size:e=24,className:t=""})=>u("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:u("path",{d:"M12 8V4m8 4V4M4 8V4M2 11h20m-1 0v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V11m5 5v2m8-2v2"})}),X:({size:e=24,className:t=""})=>u("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:u("path",{d:"M18 6 6 18M6 6l12 12"})}),Send:({size:e=24,className:t=""})=>V("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[u("path",{d:"m22 2-7 20-4-9-9-4Z"}),u("path",{d:"M22 2 11 13"})]}),Sparkles:({size:e=24,className:t=""})=>V("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[u("path",{d:"M12 2l1.8 4.6L18 8l-4.2 1.4L12 14l-1.8-4.6L6 8l4.2-1.4L12 2z"}),u("path",{d:"M5 16l.9 2.3L8 19l-2.1.7L5 22l-.9-2.3L2 19l2.1-.7L5 16z"}),u("path",{d:"M19 14l.9 2.3L22 17l-2.1.7L19 20l-.9-2.3L16 17l2.1-.7L19 14z"})]})};import{jsx as A,jsxs as ge}from"react/jsx-runtime";var be=({isExpanded:e,onOpen:t,theming:i})=>A("div",{onClick:t,className:`chat-floating-btn ${e?"chat-btn-hidden":"chat-btn-visible"}`,children:A("div",{className:"chat-btn-border seamless-border",children:ge("div",{className:"chat-btn-inner",children:[A("div",{className:"chat-btn-gradient",style:{background:i?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary)0%, var(--cb-secondary)100%)"}}),A(S.Sparkles,{size:30,className:"chat-btn-icon"})]})})}),K=be;import{useEffect as ue,useState as we}from"react";var R=(e,t)=>t?`${e} ${t}`:e;import{jsx as k,jsxs as T}from"react/jsx-runtime";var xe=({onClose:e,title:t,theming:i,strapiUrl:r})=>{let[s,c]=we(null);ue(()=>{if(!r)return;(async()=>{try{let a=await(await fetch(`${r}/api/faq-ai-bot/suggestion-and-logo`)).json();a?.logoUrl&&c(`${r}${a.logoUrl}`)}catch(o){console.error("Failed to fetch logo",o)}})()},[r]);let h=R("chat-header",i?.header);return T("header",{className:h,style:i?.headerStyle,children:[T("div",{className:"chat-header-left",children:[k("div",{className:"chat-header-logo-placeholder",children:"A"}),T("div",{className:"chat-header-title-wrap",children:[T("div",{className:"chat-header-title-row",children:[k("span",{className:"chat-header-title",children:"Aria"}),k("span",{className:"chat-header-badge",children:t||"Assistant"})]}),T("span",{className:"chat-header-status",children:[k("span",{className:"chat-header-status-dot"}),"Online \xB7 usually replies instantly"]})]})]}),k("div",{className:"chat-header-actions",children:k("button",{onClick:e,className:"chat-header-close-btn","aria-label":"Close chat",children:k(S.X,{size:20})})})]})},O=xe;import{useRef as ye,useEffect as ve}from"react";import{jsx as x,jsxs as Ce}from"react/jsx-runtime";var ke=({input:e,onInputChange:t,onSendMessage:i,isLoading:r,theming:s})=>{let c=s?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%)",n=ye(null),f=R("chat-input-container",s?.input);ve(()=>{r||n.current?.focus()},[r]);let o=d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&a()},a=()=>{e.trim()&&!r&&i()};return x("div",{className:"chat-input-outer",children:x("div",{className:"chat-input-wrap",children:Ce("div",{className:"chat-input-row",children:[x("div",{className:f,style:{...s?.inputStyle,borderRadius:"9999px"},children:x("div",{className:"chat-input-inner",children:x("input",{ref:n,type:"text",className:"chat-input-field",placeholder:r?"AI is thinking...":"Type a message...",value:e,onChange:d=>t(d.target.value),onKeyDown:o,disabled:r,"aria-label":"User message"})})}),x("button",{onClick:a,disabled:r||!e.trim(),style:{background:c},className:"chat-input-send-btn","aria-label":"Send message",children:r?x("div",{className:"chat-input-spinner"}):x(S.Send,{className:"chat-input-send-icon"})})]})})})},W=ke;import{useEffect as Me}from"react";import Ie from"react-markdown";import Se from"remark-gfm";import J from"react-markdown";import X from"remark-gfm";import{jsx as m,jsxs as P}from"react/jsx-runtime";var Ne=({message:e,cardRegistry:t,themeStyles:i,theming:r})=>{let s=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase(),c=f=>{let o=f?.__collectionUid?.split(".").pop()?.toLowerCase();return t.find(a=>a.id===o)||t.find(a=>a.id==="default")},n=e.record?c(e.record)?.component:null,h={background:r?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%)"};if(e.items?.items?.length){let f=e.items.cardStyle?.toLowerCase()||e.items.collection?.toLowerCase()||e.items.title?.toLowerCase(),a=t.find(d=>d.id===f)?.component;return P("div",{className:"mb-card-container",children:[e.content&&m("div",{className:"mb-card-content",children:m(J,{remarkPlugins:[X],children:e.content})}),a&&e.items.items.map((d,v)=>m(a,{items:d,style:i},v))]})}return P("div",{className:`mb-row ${e.role==="user"?"mb-row-user":"mb-row-assistant"}`,children:[n&&e.record?m("div",{className:"mb-card-wrapper",children:m(n,{record:e.record,style:i})}):m("div",{style:e.role==="user"?{...h,...r?.userBubbleStyle}:{},className:`mb-bubble ${e.role==="user"?"mb-bubble-user":"mb-bubble-assistant"}`,children:e.loading&&!e.content?P("div",{className:"mb-typing",children:[m("span",{className:"mb-dot mb-dot-1"}),m("span",{className:"mb-dot mb-dot-2"}),m("span",{className:"mb-dot mb-dot-3"})]}):m("div",{className:"mb-content-wrapper",children:m(J,{remarkPlugins:[X],children:e.content||""})})}),e.role==="assistant"&&!n&&P("div",{className:"mb-assistant-meta",children:[m("span",{className:"mb-assistant-avatar",style:{background:r?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),m("span",{className:"mb-assistant-time",children:s})]}),e.role==="user"&&!n&&P("div",{className:"mb-user-meta",children:[m("span",{className:"mb-user-time",children:s}),m("span",{className:"mb-user-tick","aria-label":"Delivered",children:"\u2713\u2713"})]})]})},Y=Ne;import{jsx as L,jsxs as G}from"react/jsx-runtime";var Re=({messages:e,scrollRef:t,resolvedRegistry:i,theming:r})=>{let s=r?.welcomeDescription||"Hi! I'm Aria, your Harbour Air travel assistant. I'm here to help you book flights, check fees, understand baggage rules, and anything else you need.",c=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase();return Me(()=>{let n=t.current;n&&n.scrollTo({top:n.scrollHeight,behavior:"auto"})},[e,t]),G("div",{ref:t,className:"chat-messages-container",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[e.length===0&&L("div",{className:"chat-welcome",children:G("div",{className:"chat-welcome-message",children:[L("p",{className:"chat-welcome-subtitle",children:L(Ie,{remarkPlugins:[Se],children:s})}),G("div",{className:"chat-welcome-meta",children:[L("span",{className:"chat-welcome-avatar",style:{background:r?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),L("span",{className:"chat-welcome-time",children:c})]})]})}),e.map(n=>L(Y,{message:n,cardRegistry:i,themeStyles:{"--cb-primary":r?.primaryColor||"#2999d6","--cb-secondary":r?.secondaryColor||"#179fa3","--cb-accent":r?.accentColor||r?.secondaryColor||"#179fa3"},theming:r},n.id))]})},Z=Re;import{useState as _,useEffect as Le}from"react";import{jsx as w,jsxs as Be}from"react/jsx-runtime";var ze=({strapiUrl:e,onSelectQuestion:t,variant:i,theming:r})=>{let[s,c]=_([]),[n,h]=_(!0);Le(()=>{let o=new AbortController;return h(!0),fetch(`${e}/api/faq-ai-bot/suggestion-and-logo`,{signal:o.signal}).then(a=>a.json()).then(a=>{c(a.suggestedQuestions||[]),h(!1)}).catch(a=>{a.name!=="AbortError"&&(console.error("Suggestions fetch failed",a),h(!1))}),()=>o.abort()},[e]);let f=()=>i==="floating"?Be("div",{className:"sug-skeleton-float",children:[[1,2].map(o=>w("div",{className:"sug-skeleton-item",style:{backgroundColor:r?.primaryColor?`${r.primaryColor}`:"hsla(178, 100%, 51%, 0.05)",transform:o%2===0?"rotate(1deg)":"rotate(-1deg)"}},o)),w("div",{className:"sug-skeleton-more"})]}):w("div",{className:"sug-skeleton-list",children:[1,2,3].map(o=>w("div",{className:"sug-skeleton-chip"},o))});return n&&s.length===0?w(f,{}):i==="floating"?w("div",{className:"sug-float-wrap",children:s.map((o,a)=>w("button",{onClick:()=>t(o),className:"sug-float-btn",style:{borderColor:"#bfdbfe",animationDelay:`${a*.1}s`},children:w("span",{className:"sug-float-text",children:o})},`float-${a}-${o}`))}):w("div",{className:"sug-list-wrap",children:s.map((o,a)=>w("button",{onClick:()=>t(o),className:"sug-list-btn",style:{animationDelay:`${a*.05}s`},children:o},`list-${a}-${o}`))})},U=ze;import{jsx as y,jsxs as ee}from"react/jsx-runtime";var Ee=({isExpanded:e,setIsExpanded:t,messages:i,scrollRef:r,sendMessage:s,strapiUrl:c,resolvedRegistry:n,input:h,setInput:f,isLoading:o,title:a,theming:d})=>{let v=R(`chat-window ${e?"chat-window-open":"chat-window-closed"}`,d?.container);return ee("div",{className:v,style:d?.containerStyle,children:[y("div",{className:"chat-window-header",children:y(O,{title:a,onClose:()=>t(!1),theming:d,strapiUrl:c})}),y(Z,{messages:i,scrollRef:r,resolvedRegistry:n,theming:d}),ee("div",{className:"chat-window-footer",children:[y("div",{className:"chat-window-suggestions",children:y(U,{onSelectQuestion:s,strapiUrl:c,variant:"floating",theming:d})}),y(W,{input:h,onInputChange:f,onSendMessage:s,isLoading:o,theming:d}),y("div",{className:"chat-window-powered",children:y("span",{className:"chat-powered-text",children:"Talk to a human \xB7 Privacy policy"})})]})]})},te=Ee;import{jsx as oe,jsxs as Pe}from"react/jsx-runtime";var Te=({strapiUrl:e,cardRegistry:t,theme:i,title:r,streamSpeed:s})=>{let[c,n]=D([]),[h,f]=D(""),[o,a]=D(!1),[d,v]=D(!1),F=ae(null),[ie,se]=D([]),de=ae(null),le={"--cb-primary":i?.primaryColor||"#2999d6","--cb-secondary":i?.secondaryColor||"#179fa3","--cb-accent":i?.accentColor||i?.secondaryColor||"#179fa3"};return re(()=>{t.length>0&&se(t)},[t]),re(()=>()=>F.current?.abort(),[]),Pe("div",{className:"chatbot-container",style:le,children:[oe(K,{isExpanded:d,onOpen:()=>v(!0),theming:i}),oe(te,{isExpanded:d,setIsExpanded:v,messages:c,scrollRef:de,sendMessage:async ce=>{let j=ce||h;if(!j.trim())return;F.current?.abort(),F.current=new AbortController,v(!0),f(""),a(!0);let me={role:"user",content:j,id:Date.now()},C=Date.now()+1;n(N=>[...N,me,{role:"assistant",content:"",items:null,loading:!0,id:C}]);try{let N=await fetch(`${e}/api/faq-ai-bot/ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:j,history:c.slice(-4).map(p=>({role:p.role,content:p.content}))}),signal:F.current.signal});if(!N.ok)throw new Error("Network response was not ok");let $=N.body?.getReader(),z=new TextDecoder;if(!$)throw new Error("No reader available");let B=[],q=!1,pe=(async()=>{for(;!q||B.length>0;)if(B.length>0){let p=B.shift();if(p?.type==="text")if(s&&s>0)for(let l of p.content)n(b=>b.map(g=>g.id===C?{...g,content:g.content+l}:g)),await new Promise(b=>setTimeout(b,s));else n(l=>l.map(b=>b.id===C?{...b,content:b.content+p.content}:b));else if(p?.type==="card")try{let l=p.data;n(b=>b.map(g=>g.id===C?{...g,items:{items:l.items,schema:l.schema,collection:l.title,title:l.title,cardStyle:l.cardStyle}}:g))}catch(l){console.error("Error processing card data:",l)}}else await new Promise(p=>setTimeout(p,20));a(!1),n(p=>p.map(l=>l.id===C?{...l,loading:!1}:l))})(),H="";for(;;){let{value:p,done:l}=await $.read();if(l)break;let b=z.decode(p,{stream:!0});H+=b;let g=H.split(`
|
|
2
2
|
|
|
3
|
-
`);H=
|
|
4
|
-
`),
|
|
5
|
-
`:"")+
|
|
3
|
+
`);H=g.pop()||"";for(let he of g){let fe=he.split(`
|
|
4
|
+
`),Q="message",E="";for(let M of fe)if(M.startsWith("event:"))Q=M.slice(6).trim();else if(M.startsWith("data:")){let I=M.slice(5);if(I.startsWith(" ")&&(I=I.slice(1)),I.trim()==="[DONE]"||I.trim()==="[Done]")continue;E+=(E?`
|
|
5
|
+
`:"")+I}if(Q==="cards"){let M=JSON.parse(E);B.push({type:"card",data:M})}else E&&B.push({type:"text",content:E})}}q=!0,await pe}catch(N){N.name!=="AbortError"&&n($=>$.map(z=>z.id===C?{...z,content:"I'm sorry, I'm having trouble connecting right now.",loading:!1}:z)),a(!1)}},strapiUrl:e,resolvedRegistry:ie,input:h,setInput:f,isLoading:o,title:r,theming:i})]})},ne=Te;export{ne as ChatBot,O as ChatHeader,W as ChatInput,ne as Chatbot,S as ICONS,Y as MessageBubble,U as Suggestions};
|