All files / app/elements/chat-widget chat-widget.component.html

100% Statements 357/357
100% Branches 2/2
100% Functions 1/1
100% Lines 357/357

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 3581x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
@if (!showSupportOptions && selectedSupport === 'hubspot') {
	<div class="chat-popover pointer">
		<div (click)="closeHubSpotAndGoBack(); hideHubspot()">
			<svg
				xmlns="http://www.w3.org/2000/svg"
				width="24"
				height="24"
				viewBox="0 0 24 24"
				fill="none"
				stroke="currentColor"
				stroke-width="2"
				stroke-linecap="round"
				stroke-linejoin="round"
				class="lucide lucide-bot w-6 h-6 text-chat-header-foreground"
			>
				<path d="M12 8V4H8"></path>
				<rect width="16" height="12" x="4" y="8" rx="2"></rect>
				<path d="M2 14h2"></path>
				<path d="M20 14h2"></path>
				<path d="M15 13v2"></path>
				<path d="M9 13v2"></path>
			</svg>
		</div>
	</div>
}
<!-- Popover Notification -->
@if (showPopover && !isOpen) {
	<div class="chat-popover" [@popoverAnimation]>
		<button class="popover-close" (click)="closePopover()" aria-label="Close notification">
			<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
				<line x1="18" y1="6" x2="6" y2="18"></line>
				<line x1="6" y1="6" x2="18" y2="18"></line>
			</svg>
		</button>
		<div class="popover-content">
			<div class="popover-icon">👋</div>
			<p class="popover-text">{{ popoverMessage }}</p>
		</div>
		<div class="popover-arrow"></div>
	</div>
}
 
<!-- Floating Button with Notification Badge -->
<div
	class="chat-button"
	(click)="toggleChat()"
	[class.chat-open]="isOpen"
	[class.d-none]="hide"
	role="button"
	tabindex="0"
	(keydown.enter)="toggleChat()"
	(keydown.space)="$event.preventDefault(); toggleChat()"
	aria-label="Open GoReal Travel assistant"
>
	<svg
		class="chat-icon"
		[class.hidden]="isOpen"
		xmlns="http://www.w3.org/2000/svg"
		viewBox="0 0 24 24"
		fill="none"
		stroke="currentColor"
		stroke-width="2"
	>
		<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
	</svg>
	<svg
		class="close-icon"
		[class.hidden]="!isOpen"
		xmlns="http://www.w3.org/2000/svg"
		viewBox="0 0 24 24"
		fill="none"
		stroke="currentColor"
		stroke-width="2"
	>
		<line x1="18" y1="6" x2="6" y2="18"></line>
		<line x1="6" y1="6" x2="18" y2="18"></line>
	</svg>
</div>
 
<!-- Chat Popup -->
<div class="chat-popup-container" [class.open]="isOpen">
	<div class="chat-popup">
		<!-- Header -->
		<div class="chat-header">
			<div class="header-content">
				@if (!showSupportOptions) {
					<button class="back-button" (click)="goBackToSupportOptions()" aria-label="back chat">
						<svg
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 24 24"
							fill="none"
							stroke="currentColor"
							stroke-width="2"
						>
							<line x1="19" y1="12" x2="5" y2="12"></line>
							<polyline points="12 19 5 12 12 5"></polyline>
						</svg>
					</button>
				}
				<div class="avatar">
					<svg
						xmlns="http://www.w3.org/2000/svg"
						viewBox="0 0 24 24"
						fill="none"
						stroke="currentColor"
						stroke-width="2"
					>
						<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
						<polyline points="9 22 9 12 15 12 15 22"></polyline>
					</svg>
				</div>
				<div class="header-text">
					<h3>GoReal Travel Assistant</h3>
					<span class="status">
						<span class="status-dot"></span>
						Online
					</span>
				</div>
			</div>
			<button class="close-button" (click)="toggleChat()" aria-label="Close chat">
				<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
					<line x1="18" y1="6" x2="6" y2="18"></line>
					<line x1="6" y1="6" x2="18" y2="18"></line>
				</svg>
			</button>
		</div>
 
		<!-- Messages Body -->
		<div class="chat-body" #chatBody>
			<!-- Support Options Selection Screen -->
			@if (showSupportOptions) {
				<div class="support-options-screen">
					<h3 class="support-title">Welcome! Choose your support option</h3>
 
					<div class="support-options">
						<button class="support-option" (click)="selectAIAssistant()">
							<div class="option-icon ai-icon">
								<svg
									xmlns="http://www.w3.org/2000/svg"
									width="24"
									height="24"
									viewBox="0 0 24 24"
									fill="none"
									stroke="currentColor"
									stroke-width="2"
									stroke-linecap="round"
									stroke-linejoin="round"
									class="lucide lucide-bot w-6 h-6 text-chat-header-foreground"
								>
									<path d="M12 8V4H8"></path>
									<rect width="16" height="12" x="4" y="8" rx="2"></rect>
									<path d="M2 14h2"></path>
									<path d="M20 14h2"></path>
									<path d="M15 13v2"></path>
									<path d="M9 13v2"></path>
								</svg>
							</div>
							<div class="option-content">
								<div class="option-header">
									<span class="option-badge instant">âš¡ Instant</span>
								</div>
								<h4 class="option-title">GoRealTravel Assistant</h4>
								<p class="option-description">
									<svg
										class="info-icon"
										xmlns="http://www.w3.org/2000/svg"
										viewBox="0 0 24 24"
										fill="none"
										stroke="currentColor"
										stroke-width="2"
									>
										<circle cx="12" cy="12" r="10"></circle>
										<polyline points="12 6 12 12 16 14"></polyline>
									</svg>
									No waiting - available 24/7
								</p>
							</div>
							<svg
								class="option-arrow"
								xmlns="http://www.w3.org/2000/svg"
								viewBox="0 0 24 24"
								fill="none"
								stroke="currentColor"
								stroke-width="2"
							>
								<polyline points="9 18 15 12 9 6"></polyline>
							</svg>
						</button>
 
						<button class="support-option" (click)="selectHubSpot()">
							<div class="option-icon ai-icon">
								<svg
									xmlns="http://www.w3.org/2000/svg"
									viewBox="0 0 24 24"
									fill="none"
									stroke="currentColor"
									stroke-width="2"
								>
									<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
									<circle cx="12" cy="7" r="4"></circle>
								</svg>
							</div>
							<div class="option-content">
								<div class="option-header">
									<span class="option-badge human">👤 Real human</span>
								</div>
								<h4 class="option-title">Consultant Live Chat</h4>
								<p class="option-description">
									<svg
										class="info-icon"
										xmlns="http://www.w3.org/2000/svg"
										viewBox="0 0 24 24"
										fill="none"
										stroke="currentColor"
										stroke-width="2"
									>
										<circle cx="12" cy="12" r="10"></circle>
										<polyline points="12 6 12 12 16 14"></polyline>
									</svg>
									Usually responds in 2-5 minutes
								</p>
							</div>
							<svg
								class="option-arrow"
								xmlns="http://www.w3.org/2000/svg"
								viewBox="0 0 24 24"
								fill="none"
								stroke="currentColor"
								stroke-width="2"
							>
								<polyline points="9 18 15 12 9 6"></polyline>
							</svg>
						</button>
					</div>
 
					<div class="support-footer">
						<small>Powered by GoRealTravel AI</small>
					</div>
				</div>
			}
 
			<!-- AI Assistant Chat Screen -->
			@if (!showSupportOptions && selectedSupport === 'ai') {
				@for (msg of messages; track msg.id) {
					<div
						class="message-wrapper"
						[class.user-wrapper]="msg.sender === 'user'"
						[class.bot-wrapper]="msg.sender === 'bot'"
						[@messageAnimation]
					>
						@if (msg.sender === 'bot') {
							<div class="message-avatar bot-avatar">
								<svg
									xmlns="http://www.w3.org/2000/svg"
									viewBox="0 0 24 24"
									fill="none"
									stroke="currentColor"
									stroke-width="2"
								>
									<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
									<polyline points="9 22 9 12 15 12 15 22"></polyline>
								</svg>
							</div>
						}
 
						<div class="message-content">
							<div class="message" [class.user]="msg.sender === 'user'" [class.bot]="msg.sender === 'bot'">
								<div class="message-text" [innerHTML]="msg.text | markdown"></div>
								<div class="message-time">{{ msg.timestamp | date: 'shortTime' }}</div>
							</div>
						</div>
 
						@if (msg.sender === 'user') {
							<div class="message-avatar user-avatar">
								<svg
									xmlns="http://www.w3.org/2000/svg"
									viewBox="0 0 24 24"
									fill="none"
									stroke="currentColor"
									stroke-width="2"
								>
									<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
									<circle cx="12" cy="7" r="4"></circle>
								</svg>
							</div>
						}
					</div>
				}
 
				@if (isTyping) {
					<div class="message-wrapper bot-wrapper" [@messageAnimation]>
						<div class="message-avatar bot-avatar">
							<svg
								xmlns="http://www.w3.org/2000/svg"
								viewBox="0 0 24 24"
								fill="none"
								stroke="currentColor"
								stroke-width="2"
							>
								<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
								<polyline points="9 22 9 12 15 12 15 22"></polyline>
							</svg>
						</div>
						<div class="message-content">
							<div class="message bot typing-indicator">
								<span></span>
								<span></span>
								<span></span>
							</div>
						</div>
					</div>
				}
			}
		</div>
 
		<!-- Input Footer (only show for AI chat) -->
		@if (!showSupportOptions && selectedSupport === 'ai') {
			<div class="chat-footer">
				<div class="input-container">
					<input
						type="text"
						[(ngModel)]="input"
						placeholder="Type your message..."
						(keydown.enter)="sendMessage()"
						(input)="onInputChange()"
						[disabled]="isLoading"
						aria-label="Message input"
						#messageInput
					/>
 
					<button
						class="send-button"
						(click)="sendMessage()"
						[disabled]="!input.trim() || isLoading"
						aria-label="Send message"
					>
						<svg
							class="send-icon"
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 24 24"
							fill="none"
							stroke="currentColor"
							stroke-width="2"
						>
							<line x1="22" y1="2" x2="11" y2="13"></line>
							<polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
						</svg>
					</button>
				</div>
 
				<div class="footer-info">
					<small>Powered by GoReal Travel • We typically reply instantly</small>
				</div>
			</div>
		}
	</div>
</div>