nui-chatbot-pkg 1.0.24 → 1.0.26

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 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:1rem;line-height:1.55}.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;font-family:inherit}.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-typing{display:flex;gap:.25rem;padding:.25rem .5rem;font-size:.98rem;line-height:1.55;min-height:1.5em;align-items:center}.mb-content-wrapper{font-size:.98rem;line-height:1.55;display:block;min-height:1.5em}.mb-content-wrapper>div{margin:0;padding:0;font-size:.98rem;line-height:1.55;display:block}.mb-content-wrapper strong,.mb-content-wrapper em,.mb-content-wrapper code{word-break:break-word}.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-subtitle div{margin:0;padding:0;display:block}.chat-welcome-subtitle strong,.chat-welcome-subtitle em,.chat-welcome-subtitle code{word-break:break-word}.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)}}.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}}
package/dist/index.js CHANGED
@@ -1,10 +1,5 @@
1
- "use strict";"use client";var he=Object.create;var W=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,be=Object.prototype.hasOwnProperty;var we=(e,t)=>{for(var o in t)W(e,o,{get:t[o],enumerable:!0})},ee=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ge(t))!be.call(e,r)&&r!==o&&W(e,r,{get:()=>t[r],enumerable:!(a=fe(t,r))||a.enumerable});return e};var xe=(e,t,o)=>(o=e!=null?he(ue(e)):{},ee(t||!e||!e.__esModule?W(o,"default",{value:e,enumerable:!0}):o,e)),ye=e=>ee(W({},"__esModule",{value:!0}),e);var ze={};we(ze,{ChatBot:()=>X,ChatHeader:()=>U,ChatInput:()=>V,Chatbot:()=>X,ICONS:()=>S,MessageBubble:()=>Q,Suggestions:()=>K});module.exports=ye(ze);var k=require("react");var u=require("react/jsx-runtime"),S={MessageCircle:({size:e=24,className:t=""})=>(0,u.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,u.jsx)("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})}),Bot:({size:e=24,className:t=""})=>(0,u.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,u.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,u.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,u.jsx)("path",{d:"M18 6 6 18M6 6l12 12"})}),Send:({size:e=24,className:t=""})=>(0,u.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,u.jsx)("path",{d:"m22 2-7 20-4-9-9-4Z"}),(0,u.jsx)("path",{d:"M22 2 11 13"})]}),Sparkles:({size:e=24,className:t=""})=>(0,u.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,u.jsx)("path",{d:"M12 2l1.8 4.6L18 8l-4.2 1.4L12 14l-1.8-4.6L6 8l4.2-1.4L12 2z"}),(0,u.jsx)("path",{d:"M5 16l.9 2.3L8 19l-2.1.7L5 22l-.9-2.3L2 19l2.1-.7L5 16z"}),(0,u.jsx)("path",{d:"M19 14l.9 2.3L22 17l-2.1.7L19 20l-.9-2.3L16 17l2.1-.7L19 14z"})]})};var L=require("react/jsx-runtime"),ve=({isExpanded:e,onOpen:t,theming:o})=>(0,L.jsx)("div",{onClick:t,className:`chat-floating-btn ${e?"chat-btn-hidden":"chat-btn-visible"}`,children:(0,L.jsx)("div",{className:"chat-btn-border seamless-border",children:(0,L.jsxs)("div",{className:"chat-btn-inner",children:[(0,L.jsx)("div",{className:"chat-btn-gradient",style:{background:o?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary)0%, var(--cb-secondary)100%)"}}),(0,L.jsx)(S.Sparkles,{size:30,className:"chat-btn-icon"})]})})}),te=ve;var Y=require("react");var B=(e,t)=>t?`${e} ${t}`:e;var w=require("react/jsx-runtime"),ke=({onClose:e,title:t,theming:o,strapiUrl:a})=>{let[r,c]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!a)return;(async()=>{try{let i=await(await fetch(`${a}/api/faq-ai-bot/suggestion-and-logo`)).json();i?.logoUrl&&c(`${a}${i.logoUrl}`)}catch(s){console.error("Failed to fetch logo",s)}})()},[a]);let p=B("chat-header",o?.header);return(0,w.jsxs)("header",{className:p,style:o?.headerStyle,children:[(0,w.jsxs)("div",{className:"chat-header-left",children:[(0,w.jsx)("div",{className:"chat-header-logo-placeholder",children:"A"}),(0,w.jsxs)("div",{className:"chat-header-title-wrap",children:[(0,w.jsxs)("div",{className:"chat-header-title-row",children:[(0,w.jsx)("span",{className:"chat-header-title",children:"Aria"}),(0,w.jsx)("span",{className:"chat-header-badge",children:t||"Assistant"})]}),(0,w.jsxs)("span",{className:"chat-header-status",children:[(0,w.jsx)("span",{className:"chat-header-status-dot"}),"Online \xB7 usually replies instantly"]})]})]}),(0,w.jsx)("div",{className:"chat-header-actions",children:(0,w.jsx)("button",{onClick:e,className:"chat-header-close-btn","aria-label":"Close chat",children:(0,w.jsx)(S.X,{size:20})})})]})},U=ke;var G=require("react");var N=require("react/jsx-runtime"),Ce=({input:e,onInputChange:t,onSendMessage:o,isLoading:a,theming:r})=>{let c=r?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%)",n=(0,G.useRef)(null),g=B("chat-input-container",r?.input);(0,G.useEffect)(()=>{a||n.current?.focus()},[a]);let s=d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&i()},i=()=>{e.trim()&&!a&&o()};return(0,N.jsx)("div",{className:"chat-input-outer",children:(0,N.jsx)("div",{className:"chat-input-wrap",children:(0,N.jsxs)("div",{className:"chat-input-row",children:[(0,N.jsx)("div",{className:g,style:{...r?.inputStyle,borderRadius:"9999px"},children:(0,N.jsx)("div",{className:"chat-input-inner",children:(0,N.jsx)("input",{ref:n,type:"text",className:"chat-input-field",placeholder:a?"AI is thinking...":"Type a message...",value:e,onChange:d=>t(d.target.value),onKeyDown:s,disabled:a,"aria-label":"User message"})})}),(0,N.jsx)("button",{onClick:i,disabled:a||!e.trim(),style:{background:c},className:"chat-input-send-btn","aria-label":"Send message",children:a?(0,N.jsx)("div",{className:"chat-input-spinner"}):(0,N.jsx)(S.Send,{className:"chat-input-send-icon"})})]})})})},V=Ce;var ae=require("react");var T=xe(require("react")),Ne=e=>e.replace(/\*\*(.+?)\*\*/g,"$1").replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"$1").replace(/`([^`]+)`/g,"$1"),Re=e=>{let t=e.split(`
2
- `),o=new Set,a=[];for(let r of t){let c=Ne(r);o.has(c.trim())||(o.add(c.trim()),a.push(r))}return a.join(`
3
- `)},Ie=e=>{let t=e.replace(/([.!?])\s*(\d+\.)/g,`$1
4
- $2`);return t=t.replace(/([.!?])\s*(-\s)/g,`$1
5
- $2`),t},A=e=>{if(!e)return[];let t=Re(e);t=Ie(t);let o=t.split(`
6
- `),a=[];return o.forEach((r,c)=>{if(!r.trim()){a.length>0&&a.push(T.default.createElement("br",{key:`br-${c}`}));return}let n=[],p=0,g=/\*\*(.+?)\*\*/g,s=/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,i=/`([^`]+)`/g,d=[],l;for(g.lastIndex=0;(l=g.exec(r))!==null;)d.push({type:"bold",start:l.index,end:l.index+l[0].length,content:l[1]});for(s.lastIndex=0;(l=s.exec(r))!==null;)d.some(h=>h.start<=l.index&&h.end>l.index)||d.push({type:"italic",start:l.index,end:l.index+l[0].length,content:l[1]});for(i.lastIndex=0;(l=i.exec(r))!==null;)d.push({type:"code",start:l.index,end:l.index+l[0].length,content:l[1]});d.sort((h,I)=>h.start-I.start),d.forEach((h,I)=>{h.start>p&&n.push(r.substring(p,h.start)),h.type==="bold"?n.push(T.default.createElement("strong",{key:`bold-${c}-${I}`},h.content)):h.type==="italic"?n.push(T.default.createElement("em",{key:`italic-${c}-${I}`},h.content)):h.type==="code"&&n.push(T.default.createElement("code",{key:`code-${c}-${I}`,style:{backgroundColor:"rgba(0, 0, 0, 0.1)",padding:"2px 6px",borderRadius:"3px",fontFamily:"monospace",fontSize:"0.9em"}},h.content)),p=h.end}),p<r.length&&n.push(r.substring(p)),n.length>0&&a.push(T.default.createElement("div",{key:`line-${c}`},n.length===0?r:n))}),a.length===0?[e]:a};var m=require("react/jsx-runtime"),Se=({message:e,cardRegistry:t,themeStyles:o,theming:a})=>{let r=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase(),c=g=>{let s=g?.__collectionUid?.split(".").pop()?.toLowerCase();return t.find(i=>i.id===s)||t.find(i=>i.id==="default")},n=e.record?c(e.record)?.component:null,p={background:a?.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(),i=t.find(d=>d.id===g)?.component;return(0,m.jsxs)("div",{className:"mb-card-container",children:[e.content&&(0,m.jsx)("div",{className:"mb-card-content",children:A(e.content)}),i&&e.items.items.map((d,l)=>(0,m.jsx)(i,{items:d,style:o},l))]})}return(0,m.jsxs)("div",{className:`mb-row ${e.role==="user"?"mb-row-user":"mb-row-assistant"}`,children:[n&&e.record?(0,m.jsx)("div",{className:"mb-card-wrapper",children:(0,m.jsx)(n,{record:e.record,style:o})}):(0,m.jsx)("div",{style:e.role==="user"?{...p,...a?.userBubbleStyle}:{},className:`mb-bubble ${e.role==="user"?"mb-bubble-user":"mb-bubble-assistant"}`,children:e.loading&&!e.content?(0,m.jsxs)("div",{className:"mb-typing",children:[(0,m.jsx)("span",{className:"mb-dot mb-dot-1"}),(0,m.jsx)("span",{className:"mb-dot mb-dot-2"}),(0,m.jsx)("span",{className:"mb-dot mb-dot-3"})]}):(0,m.jsx)("div",{className:"mb-content-wrapper",children:A(e.content)})}),e.role==="assistant"&&!n&&(0,m.jsxs)("div",{className:"mb-assistant-meta",children:[(0,m.jsx)("span",{className:"mb-assistant-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),(0,m.jsxs)("span",{className:"mb-assistant-time",children:[r," "]})]}),e.role==="user"&&!n&&(0,m.jsxs)("div",{className:"mb-user-meta",children:[(0,m.jsxs)("span",{className:"mb-user-time",children:[r," "]}),(0,m.jsx)("span",{className:"mb-user-tick","aria-label":"Delivered",children:"\u2713\u2713"})]})]})},Q=Se;var R=require("react/jsx-runtime"),Le=({messages:e,scrollRef:t,resolvedRegistry:o,theming:a})=>{let r=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(0,ae.useEffect)(()=>{let n=t.current;n&&n.scrollTo({top:n.scrollHeight,behavior:"auto"})},[e,t]),(0,R.jsxs)("div",{ref:t,className:"chat-messages-container",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[e.length===0&&(0,R.jsx)("div",{className:"chat-welcome",children:(0,R.jsxs)("div",{className:"chat-welcome-message",children:[(0,R.jsx)("p",{className:"chat-welcome-subtitle",children:A(r)}),(0,R.jsxs)("div",{className:"chat-welcome-meta",children:[(0,R.jsx)("span",{className:"chat-welcome-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),(0,R.jsx)("span",{className:"chat-welcome-time",children:c})]})]})}),e.map(n=>(0,R.jsx)(Q,{message:n,cardRegistry:o,theming:a},n.id))]})},re=Le;var j=require("react");var x=require("react/jsx-runtime"),Me=({strapiUrl:e,onSelectQuestion:t,variant:o,theming:a})=>{let[r,c]=(0,j.useState)([]),[n,p]=(0,j.useState)(!0);(0,j.useEffect)(()=>{let s=new AbortController;return p(!0),fetch(`${e}/api/faq-ai-bot/suggestion-and-logo`,{signal:s.signal}).then(i=>i.json()).then(i=>{c(i.suggestedQuestions||[]),p(!1)}).catch(i=>{i.name!=="AbortError"&&(console.error("Suggestions fetch failed",i),p(!1))}),()=>s.abort()},[e]);let g=()=>o==="floating"?(0,x.jsxs)("div",{className:"sug-skeleton-float",children:[[1,2].map(s=>(0,x.jsx)("div",{className:"sug-skeleton-item",style:{backgroundColor:a?.primaryColor?`${a.primaryColor}`:"hsla(178, 100%, 51%, 0.05)",transform:s%2===0?"rotate(1deg)":"rotate(-1deg)"}},s)),(0,x.jsx)("div",{className:"sug-skeleton-more"})]}):(0,x.jsx)("div",{className:"sug-skeleton-list",children:[1,2,3].map(s=>(0,x.jsx)("div",{className:"sug-skeleton-chip"},s))});return n&&r.length===0?(0,x.jsx)(g,{}):o==="floating"?(0,x.jsx)("div",{className:"sug-float-wrap",children:r.map((s,i)=>(0,x.jsx)("button",{onClick:()=>t(s),className:"sug-float-btn",style:{borderColor:"#bfdbfe",animationDelay:`${i*.1}s`},children:(0,x.jsx)("span",{className:"sug-float-text",children:s})},`float-${i}-${s}`))}):(0,x.jsx)("div",{className:"sug-list-wrap",children:r.map((s,i)=>(0,x.jsx)("button",{onClick:()=>t(s),className:"sug-list-btn",style:{animationDelay:`${i*.05}s`},children:s},`list-${i}-${s}`))})},K=Me;var v=require("react/jsx-runtime"),Ee=({isExpanded:e,setIsExpanded:t,messages:o,scrollRef:a,sendMessage:r,strapiUrl:c,resolvedRegistry:n,input:p,setInput:g,isLoading:s,title:i,theming:d})=>{let l=B(`chat-window ${e?"chat-window-open":"chat-window-closed"}`,d?.container);return(0,v.jsxs)("div",{className:l,style:d?.containerStyle,children:[(0,v.jsx)("div",{className:"chat-window-header",children:(0,v.jsx)(U,{title:i,onClose:()=>t(!1),theming:d,strapiUrl:c})}),(0,v.jsx)(re,{messages:o,scrollRef:a,resolvedRegistry:n,theming:d}),(0,v.jsxs)("div",{className:"chat-window-footer",children:[(0,v.jsx)("div",{className:"chat-window-suggestions",children:(0,v.jsx)(K,{onSelectQuestion:r,strapiUrl:c,variant:"floating",theming:d})}),(0,v.jsx)(V,{input:p,onInputChange:g,onSendMessage:r,isLoading:s,theming:d}),(0,v.jsx)("div",{className:"chat-window-powered",children:(0,v.jsx)("span",{className:"chat-powered-text",children:"Talk to a human \xB7 Privacy policy"})})]})]})},oe=Ee;var H=require("react/jsx-runtime"),$e=({strapiUrl:e,cardRegistry:t,theme:o,title:a,streamSpeed:r})=>{let[c,n]=(0,k.useState)([]),[p,g]=(0,k.useState)(""),[s,i]=(0,k.useState)(!1),[d,l]=(0,k.useState)(!1),h=(0,k.useRef)(null),[I,ne]=(0,k.useState)([]),ie=(0,k.useRef)(null),se={"--cb-primary":o?.primaryColor||"#2999d6","--cb-secondary":o?.secondaryColor||"#179fa3","--cb-accent":o?.accentColor||o?.secondaryColor||"#179fa3"};return(0,k.useEffect)(()=>{t.length>0&&ne(t)},[t]),(0,k.useEffect)(()=>()=>h.current?.abort(),[]),(0,H.jsxs)("div",{className:"chatbot-container",style:se,children:[(0,H.jsx)(te,{isExpanded:d,onOpen:()=>l(!0),theming:o}),(0,H.jsx)(oe,{isExpanded:d,setIsExpanded:l,messages:c,scrollRef:ie,sendMessage:async de=>{let q=de||p;if(!q.trim())return;h.current?.abort(),h.current=new AbortController,l(!0),g(""),i(!0);let le={role:"user",content:q,id:Date.now()},M=Date.now()+1;n(E=>[...E,le,{role:"assistant",content:"",items:null,loading:!0,id:M}]);try{let E=await fetch(`${e}/api/faq-ai-bot/ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:q,history:c.slice(-4).map(b=>({role:b.role,content:b.content}))}),signal:h.current.signal});if(!E.ok)throw new Error("Network response was not ok");let O=E.body?.getReader(),P=new TextDecoder;if(!O)throw new Error("No reader available");let F=[],Z=!1,ce=(async()=>{for(;!Z||F.length>0;)if(F.length>0){let b=F.shift();if(b?.type==="text")if(r&&r>0)for(let f of b.content)n(y=>y.map(C=>C.id===M?{...C,content:C.content+f}:C)),await new Promise(y=>setTimeout(y,r));else n(f=>f.map(y=>y.id===M?{...y,content:y.content+b.content}:y));else if(b?.type==="card")try{let f=b.data;n(y=>y.map(C=>C.id===M?{...C,items:{items:f.items,schema:f.schema,collection:f.title,title:f.title,cardStyle:f.cardStyle}}:C))}catch(f){console.error("Error processing card data:",f)}}else await new Promise(b=>setTimeout(b,20));i(!1),n(b=>b.map(f=>f.id===M?{...f,loading:!1}:f))})(),J="";for(;;){let{value:b,done:f}=await O.read();if(f)break;let y=P.decode(b,{stream:!0});J+=y;let C=J.split(`
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(`
7
2
 
8
- `);J=C.pop()||"";for(let me of C){let pe=me.split(`
9
- `),_="message",D="";for(let $ of pe)if($.startsWith("event:"))_=$.slice(6).trim();else if($.startsWith("data:")){let z=$.slice(5);if(z.startsWith(" ")&&(z=z.slice(1)),z.trim()==="[DONE]"||z.trim()==="[Done]")continue;D+=(D?`
10
- `:"")+z}if(_==="cards"){let $=JSON.parse(D);F.push({type:"card",data:$})}else D&&F.push({type:"text",content:D})}}Z=!0,await ce}catch(E){E.name!=="AbortError"&&n(O=>O.map(P=>P.id===M?{...P,content:"I'm sorry, I'm having trouble connecting right now.",loading:!1}:P)),i(!1)}},strapiUrl:e,resolvedRegistry:I,input:p,setInput:g,isLoading:s,title:a,theming:o})]})},X=$e;0&&(module.exports={ChatBot,ChatHeader,ChatInput,Chatbot,ICONS,MessageBubble,Suggestions});
3
+ `);K=v.pop()||"";for(let fe of v){let ge=fe.split(`
4
+ `),_="message",P="";for(let L of ge)if(L.startsWith("event:"))_=L.slice(6).trim();else if(L.startsWith("data:")){let B=L.slice(5);if(B.startsWith(" ")&&(B=B.slice(1)),B.trim()==="[DONE]"||B.trim()==="[Done]")continue;P+=(P?`
5
+ `:"")+B}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(z=>z.id===M?{...z,content:"I'm sorry, I'm having trouble connecting right now.",loading:!1}:z)),o(!1)}},strapiUrl:e,resolvedRegistry:se,input:g,setInput:u,isLoading:i,title:a,theming:r})]})},X=Be;0&&(module.exports={ChatBot,ChatHeader,ChatInput,Chatbot,ICONS,MessageBubble,Suggestions});
package/dist/index.mjs CHANGED
@@ -1,10 +1,5 @@
1
- "use client";import{useState as j,useEffect as re,useRef as oe}from"react";import{jsx as w,jsxs as X}from"react/jsx-runtime";var E={MessageCircle:({size:e=24,className:t=""})=>w("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:w("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})}),Bot:({size:e=24,className:t=""})=>w("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:w("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=""})=>w("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:w("path",{d:"M18 6 6 18M6 6l12 12"})}),Send:({size:e=24,className:t=""})=>X("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[w("path",{d:"m22 2-7 20-4-9-9-4Z"}),w("path",{d:"M22 2 11 13"})]}),Sparkles:({size:e=24,className:t=""})=>X("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[w("path",{d:"M12 2l1.8 4.6L18 8l-4.2 1.4L12 14l-1.8-4.6L6 8l4.2-1.4L12 2z"}),w("path",{d:"M5 16l.9 2.3L8 19l-2.1.7L5 22l-.9-2.3L2 19l2.1-.7L5 16z"}),w("path",{d:"M19 14l.9 2.3L22 17l-2.1.7L19 20l-.9-2.3L16 17l2.1-.7L19 14z"})]})};import{jsx as O,jsxs as ue}from"react/jsx-runtime";var ge=({isExpanded:e,onOpen:t,theming:s})=>O("div",{onClick:t,className:`chat-floating-btn ${e?"chat-btn-hidden":"chat-btn-visible"}`,children:O("div",{className:"chat-btn-border seamless-border",children:ue("div",{className:"chat-btn-inner",children:[O("div",{className:"chat-btn-gradient",style:{background:s?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary)0%, var(--cb-secondary)100%)"}}),O(E.Sparkles,{size:30,className:"chat-btn-icon"})]})})}),Z=ge;import{useEffect as be,useState as we}from"react";var $=(e,t)=>t?`${e} ${t}`:e;import{jsx as N,jsxs as P}from"react/jsx-runtime";var xe=({onClose:e,title:t,theming:s,strapiUrl:a})=>{let[n,c]=we(null);be(()=>{if(!a)return;(async()=>{try{let o=await(await fetch(`${a}/api/faq-ai-bot/suggestion-and-logo`)).json();o?.logoUrl&&c(`${a}${o.logoUrl}`)}catch(i){console.error("Failed to fetch logo",i)}})()},[a]);let m=$("chat-header",s?.header);return P("header",{className:m,style:s?.headerStyle,children:[P("div",{className:"chat-header-left",children:[N("div",{className:"chat-header-logo-placeholder",children:"A"}),P("div",{className:"chat-header-title-wrap",children:[P("div",{className:"chat-header-title-row",children:[N("span",{className:"chat-header-title",children:"Aria"}),N("span",{className:"chat-header-badge",children:t||"Assistant"})]}),P("span",{className:"chat-header-status",children:[N("span",{className:"chat-header-status-dot"}),"Online \xB7 usually replies instantly"]})]})]}),N("div",{className:"chat-header-actions",children:N("button",{onClick:e,className:"chat-header-close-btn","aria-label":"Close chat",children:N(E.X,{size:20})})})]})},U=xe;import{useRef as ye,useEffect as ve}from"react";import{jsx as v,jsxs as Ce}from"react/jsx-runtime";var ke=({input:e,onInputChange:t,onSendMessage:s,isLoading:a,theming:n})=>{let c=n?.showGradient===!1?"var(--cb-primary)":"linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%)",r=ye(null),f=$("chat-input-container",n?.input);ve(()=>{a||r.current?.focus()},[a]);let i=d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&o()},o=()=>{e.trim()&&!a&&s()};return v("div",{className:"chat-input-outer",children:v("div",{className:"chat-input-wrap",children:Ce("div",{className:"chat-input-row",children:[v("div",{className:f,style:{...n?.inputStyle,borderRadius:"9999px"},children:v("div",{className:"chat-input-inner",children:v("input",{ref:r,type:"text",className:"chat-input-field",placeholder:a?"AI is thinking...":"Type a message...",value:e,onChange:d=>t(d.target.value),onKeyDown:i,disabled:a,"aria-label":"User message"})})}),v("button",{onClick:o,disabled:a||!e.trim(),style:{background:c},className:"chat-input-send-btn","aria-label":"Send message",children:a?v("div",{className:"chat-input-spinner"}):v(E.Send,{className:"chat-input-send-icon"})})]})})})},G=ke;import{useEffect as Le}from"react";import F from"react";var Ne=e=>e.replace(/\*\*(.+?)\*\*/g,"$1").replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"$1").replace(/`([^`]+)`/g,"$1"),Re=e=>{let t=e.split(`
2
- `),s=new Set,a=[];for(let n of t){let c=Ne(n);s.has(c.trim())||(s.add(c.trim()),a.push(n))}return a.join(`
3
- `)},Ie=e=>{let t=e.replace(/([.!?])\s*(\d+\.)/g,`$1
4
- $2`);return t=t.replace(/([.!?])\s*(-\s)/g,`$1
5
- $2`),t},D=e=>{if(!e)return[];let t=Re(e);t=Ie(t);let s=t.split(`
6
- `),a=[];return s.forEach((n,c)=>{if(!n.trim()){a.length>0&&a.push(F.createElement("br",{key:`br-${c}`}));return}let r=[],m=0,f=/\*\*(.+?)\*\*/g,i=/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,o=/`([^`]+)`/g,d=[],l;for(f.lastIndex=0;(l=f.exec(n))!==null;)d.push({type:"bold",start:l.index,end:l.index+l[0].length,content:l[1]});for(i.lastIndex=0;(l=i.exec(n))!==null;)d.some(p=>p.start<=l.index&&p.end>l.index)||d.push({type:"italic",start:l.index,end:l.index+l[0].length,content:l[1]});for(o.lastIndex=0;(l=o.exec(n))!==null;)d.push({type:"code",start:l.index,end:l.index+l[0].length,content:l[1]});d.sort((p,C)=>p.start-C.start),d.forEach((p,C)=>{p.start>m&&r.push(n.substring(m,p.start)),p.type==="bold"?r.push(F.createElement("strong",{key:`bold-${c}-${C}`},p.content)):p.type==="italic"?r.push(F.createElement("em",{key:`italic-${c}-${C}`},p.content)):p.type==="code"&&r.push(F.createElement("code",{key:`code-${c}-${C}`,style:{backgroundColor:"rgba(0, 0, 0, 0.1)",padding:"2px 6px",borderRadius:"3px",fontFamily:"monospace",fontSize:"0.9em"}},p.content)),m=p.end}),m<n.length&&r.push(n.substring(m)),r.length>0&&a.push(F.createElement("div",{key:`line-${c}`},r.length===0?n:r))}),a.length===0?[e]:a};import{jsx as x,jsxs as R}from"react/jsx-runtime";var Se=({message:e,cardRegistry:t,themeStyles:s,theming:a})=>{let n=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase(),c=f=>{let i=f?.__collectionUid?.split(".").pop()?.toLowerCase();return t.find(o=>o.id===i)||t.find(o=>o.id==="default")},r=e.record?c(e.record)?.component:null,m={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(),o=t.find(d=>d.id===f)?.component;return R("div",{className:"mb-card-container",children:[e.content&&x("div",{className:"mb-card-content",children:D(e.content)}),o&&e.items.items.map((d,l)=>x(o,{items:d,style:s},l))]})}return R("div",{className:`mb-row ${e.role==="user"?"mb-row-user":"mb-row-assistant"}`,children:[r&&e.record?x("div",{className:"mb-card-wrapper",children:x(r,{record:e.record,style:s})}):x("div",{style:e.role==="user"?{...m,...a?.userBubbleStyle}:{},className:`mb-bubble ${e.role==="user"?"mb-bubble-user":"mb-bubble-assistant"}`,children:e.loading&&!e.content?R("div",{className:"mb-typing",children:[x("span",{className:"mb-dot mb-dot-1"}),x("span",{className:"mb-dot mb-dot-2"}),x("span",{className:"mb-dot mb-dot-3"})]}):x("div",{className:"mb-content-wrapper",children:D(e.content)})}),e.role==="assistant"&&!r&&R("div",{className:"mb-assistant-meta",children:[x("span",{className:"mb-assistant-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),R("span",{className:"mb-assistant-time",children:[n," "]})]}),e.role==="user"&&!r&&R("div",{className:"mb-user-meta",children:[R("span",{className:"mb-user-time",children:[n," "]}),x("span",{className:"mb-user-tick","aria-label":"Delivered",children:"\u2713\u2713"})]})]})},V=Se;import{jsx as A,jsxs as Q}from"react/jsx-runtime";var Me=({messages:e,scrollRef:t,resolvedRegistry:s,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.",c=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).toLowerCase();return Le(()=>{let r=t.current;r&&r.scrollTo({top:r.scrollHeight,behavior:"auto"})},[e,t]),Q("div",{ref:t,className:"chat-messages-container",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[e.length===0&&A("div",{className:"chat-welcome",children:Q("div",{className:"chat-welcome-message",children:[A("p",{className:"chat-welcome-subtitle",children:D(n)}),Q("div",{className:"chat-welcome-meta",children:[A("span",{className:"chat-welcome-avatar",style:{background:a?.showGradient===!1?"#3B82F6":"linear-gradient(135deg, var(--cb-primary), var(--cb-secondary))"},children:"A"}),A("span",{className:"chat-welcome-time",children:c})]})]})}),e.map(r=>A(V,{message:r,cardRegistry:s,theming:a},r.id))]})},_=Me;import{useState as ee,useEffect as Ee}from"react";import{jsx as y,jsxs as ze}from"react/jsx-runtime";var $e=({strapiUrl:e,onSelectQuestion:t,variant:s,theming:a})=>{let[n,c]=ee([]),[r,m]=ee(!0);Ee(()=>{let i=new AbortController;return m(!0),fetch(`${e}/api/faq-ai-bot/suggestion-and-logo`,{signal:i.signal}).then(o=>o.json()).then(o=>{c(o.suggestedQuestions||[]),m(!1)}).catch(o=>{o.name!=="AbortError"&&(console.error("Suggestions fetch failed",o),m(!1))}),()=>i.abort()},[e]);let f=()=>s==="floating"?ze("div",{className:"sug-skeleton-float",children:[[1,2].map(i=>y("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)),y("div",{className:"sug-skeleton-more"})]}):y("div",{className:"sug-skeleton-list",children:[1,2,3].map(i=>y("div",{className:"sug-skeleton-chip"},i))});return r&&n.length===0?y(f,{}):s==="floating"?y("div",{className:"sug-float-wrap",children:n.map((i,o)=>y("button",{onClick:()=>t(i),className:"sug-float-btn",style:{borderColor:"#bfdbfe",animationDelay:`${o*.1}s`},children:y("span",{className:"sug-float-text",children:i})},`float-${o}-${i}`))}):y("div",{className:"sug-list-wrap",children:n.map((i,o)=>y("button",{onClick:()=>t(i),className:"sug-list-btn",style:{animationDelay:`${o*.05}s`},children:i},`list-${o}-${i}`))})},K=$e;import{jsx as k,jsxs as te}from"react/jsx-runtime";var Be=({isExpanded:e,setIsExpanded:t,messages:s,scrollRef:a,sendMessage:n,strapiUrl:c,resolvedRegistry:r,input:m,setInput:f,isLoading:i,title:o,theming:d})=>{let l=$(`chat-window ${e?"chat-window-open":"chat-window-closed"}`,d?.container);return te("div",{className:l,style:d?.containerStyle,children:[k("div",{className:"chat-window-header",children:k(U,{title:o,onClose:()=>t(!1),theming:d,strapiUrl:c})}),k(_,{messages:s,scrollRef:a,resolvedRegistry:r,theming:d}),te("div",{className:"chat-window-footer",children:[k("div",{className:"chat-window-suggestions",children:k(K,{onSelectQuestion:n,strapiUrl:c,variant:"floating",theming:d})}),k(G,{input:m,onInputChange:f,onSendMessage:n,isLoading:i,theming:d}),k("div",{className:"chat-window-powered",children:k("span",{className:"chat-powered-text",children:"Talk to a human \xB7 Privacy policy"})})]})]})},ae=Be;import{jsx as ne,jsxs as Pe}from"react/jsx-runtime";var Te=({strapiUrl:e,cardRegistry:t,theme:s,title:a,streamSpeed:n})=>{let[c,r]=j([]),[m,f]=j(""),[i,o]=j(!1),[d,l]=j(!1),p=oe(null),[C,se]=j([]),de=oe(null),le={"--cb-primary":s?.primaryColor||"#2999d6","--cb-secondary":s?.secondaryColor||"#179fa3","--cb-accent":s?.accentColor||s?.secondaryColor||"#179fa3"};return re(()=>{t.length>0&&se(t)},[t]),re(()=>()=>p.current?.abort(),[]),Pe("div",{className:"chatbot-container",style:le,children:[ne(Z,{isExpanded:d,onOpen:()=>l(!0),theming:s}),ne(ae,{isExpanded:d,setIsExpanded:l,messages:c,scrollRef:de,sendMessage:async ce=>{let W=ce||m;if(!W.trim())return;p.current?.abort(),p.current=new AbortController,l(!0),f(""),o(!0);let me={role:"user",content:W,id:Date.now()},I=Date.now()+1;r(S=>[...S,me,{role:"assistant",content:"",items:null,loading:!0,id:I}]);try{let S=await fetch(`${e}/api/faq-ai-bot/ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:W,history:c.slice(-4).map(g=>({role:g.role,content:g.content}))}),signal:p.current.signal});if(!S.ok)throw new Error("Network response was not ok");let H=S.body?.getReader(),z=new TextDecoder;if(!H)throw new Error("No reader available");let B=[],q=!1,pe=(async()=>{for(;!q||B.length>0;)if(B.length>0){let g=B.shift();if(g?.type==="text")if(n&&n>0)for(let h of g.content)r(u=>u.map(b=>b.id===I?{...b,content:b.content+h}:b)),await new Promise(u=>setTimeout(u,n));else r(h=>h.map(u=>u.id===I?{...u,content:u.content+g.content}:u));else if(g?.type==="card")try{let h=g.data;r(u=>u.map(b=>b.id===I?{...b,items:{items:h.items,schema:h.schema,collection:h.title,title:h.title,cardStyle:h.cardStyle}}:b))}catch(h){console.error("Error processing card data:",h)}}else await new Promise(g=>setTimeout(g,20));o(!1),r(g=>g.map(h=>h.id===I?{...h,loading:!1}:h))})(),Y="";for(;;){let{value:g,done:h}=await H.read();if(h)break;let u=z.decode(g,{stream:!0});Y+=u;let b=Y.split(`
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(`
7
2
 
8
- `);Y=b.pop()||"";for(let he of b){let fe=he.split(`
9
- `),J="message",T="";for(let L of fe)if(L.startsWith("event:"))J=L.slice(6).trim();else if(L.startsWith("data:")){let M=L.slice(5);if(M.startsWith(" ")&&(M=M.slice(1)),M.trim()==="[DONE]"||M.trim()==="[Done]")continue;T+=(T?`
10
- `:"")+M}if(J==="cards"){let L=JSON.parse(T);B.push({type:"card",data:L})}else T&&B.push({type:"text",content:T})}}q=!0,await pe}catch(S){S.name!=="AbortError"&&r(H=>H.map(z=>z.id===I?{...z,content:"I'm sorry, I'm having trouble connecting right now.",loading:!1}:z)),o(!1)}},strapiUrl:e,resolvedRegistry:C,input:m,setInput:f,isLoading:i,title:a,theming:s})]})},ie=Te;export{ie as ChatBot,U as ChatHeader,G as ChatInput,ie as Chatbot,E as ICONS,V as MessageBubble,K as Suggestions};
3
+ `);H=u.pop()||"";for(let he of u){let fe=he.split(`
4
+ `),V="message",z="";for(let I of fe)if(I.startsWith("event:"))V=I.slice(6).trim();else if(I.startsWith("data:")){let S=I.slice(5);if(S.startsWith(" ")&&(S=S.slice(1)),S.trim()==="[DONE]"||S.trim()==="[Done]")continue;z+=(z?`
5
+ `:"")+S}if(V==="cards"){let I=JSON.parse(z);E.push({type:"card",data:I})}else z&&E.push({type:"text",content:z})}}Q=!0,await pe}catch(N){N.name!=="AbortError"&&i($=>$.map(B=>B.id===C?{...B,content:"I'm sorry, I'm having trouble connecting right now.",loading:!1}:B)),r(!1)}},strapiUrl:e,resolvedRegistry:ne,input:h,setInput:f,isLoading:o,title:a,theming:n})]})},ie=Te;export{ie as ChatBot,O as ChatHeader,W as ChatInput,ie as Chatbot,M as ICONS,Y as MessageBubble,U as Suggestions};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nui-chatbot-pkg",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -31,10 +31,14 @@
31
31
  "devDependencies": {
32
32
  "@types/react": "^19.0.0",
33
33
  "@types/react-dom": "^19.0.0",
34
- "tsup": "^8.5.1",
35
- "typescript": "^5.7.0",
36
- "tailwindcss": "^3.4.0",
34
+ "autoprefixer": "^10.4.0",
37
35
  "postcss": "^8.4.0",
38
- "autoprefixer": "^10.4.0"
36
+ "tailwindcss": "^3.4.0",
37
+ "tsup": "^8.5.1",
38
+ "typescript": "^5.7.0"
39
+ },
40
+ "dependencies": {
41
+ "react-markdown": "^10.1.0",
42
+ "remark-gfm": "^4.0.1"
39
43
  }
40
44
  }