All files / src/components/widgets/implementationguide SecurityResourcesWidget.tsx

80% Statements 60/75
78% Branches 78/100
65.21% Functions 15/23
80% Lines 60/75

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 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709                                                                                                                                                                                                                                                                                                                  6x                           48x     48x 48x 48x 48x     48x 31x 31x 21x       10x                       31x           31x                         31x             31x 31x   31x 69x 69x 36x 36x         31x   26x       26x         26x 26x                               48x 31x 31x 36x 22x     31x       48x 31x     31x             31x 1x 1x   2x                 31x       48x 31x 31x 31x       48x           48x   1x 1x           48x         48x     48x 31x 31x 21x     10x                         30x                       48x                                                                                                                             20x                                                                                                                                                             24x                                                           3x                                                                                                                                                                                                                                                                                                                                                              
import React, { useCallback, useMemo, useState } from "react";
import { WIDGET_ICONS, WIDGET_TITLES } from "../../../constants/appConstants";
import { SECURITY_RESOURCES_TEST_IDS } from "../../../constants/testIds";
import { useCIAContentService } from "../../../hooks/useCIAContentService";
import { SecurityLevel } from "../../../types/cia";
import { SecurityResource } from "../../../types/securityResources";
import {
  isArray,
  isNullish,
  isObject,
  isString,
} from "../../../utils/typeGuards";
import ResourceCard from "../../common/ResourceCard";
import WidgetContainer from "../../common/WidgetContainer";
import WidgetErrorBoundary from "../../common/WidgetErrorBoundary";
 
/**
 * Props for SecurityResourcesWidget component
 * 
 * Defines the configuration for displaying security resources and implementation
 * guides based on selected security levels across all CIA components.
 * 
 * @example
 * ```tsx
 * <SecurityResourcesWidget
 *   availabilityLevel="High"
 *   integrityLevel="Very High"
 *   confidentialityLevel="Moderate"
 *   limit={10}
 *   showTopResourcesOnly={true}
 *   className="mt-4"
 *   testId="security-resources"
 * />
 * ```
 */
export interface SecurityResourcesWidgetProps {
  /**
   * Selected availability level
   * 
   * Determines which availability-specific resources and guides to display.
   * 
   * @example 'High'
   */
  availabilityLevel: SecurityLevel;
 
  /**
   * Selected integrity level
   * 
   * Determines which integrity-specific resources and guides to display.
   * 
   * @example 'Very High'
   */
  integrityLevel: SecurityLevel;
 
  /**
   * Selected confidentiality level
   * 
   * Determines which confidentiality-specific resources and guides to display.
   * 
   * @example 'Moderate'
   */
  confidentialityLevel: SecurityLevel;
 
  /**
   * Optional CSS class name for custom styling
   * 
   * Allows consumers to apply custom CSS classes via Tailwind or custom styles.
   * 
   * @default ""
   * @example "mt-4 shadow-lg rounded-lg"
   */
  className?: string;
 
  /**
   * Optional test ID for automated testing
   * 
   * Used by Cypress and Vitest for component identification in tests.
   * Defaults to SECURITY_RESOURCES_TEST_IDS.WIDGET constant.
   * 
   * @default SECURITY_RESOURCES_TEST_IDS.WIDGET
   * @example "custom-security-resources"
   */
  testId?: string;
 
  /**
   * Optional limit for the number of resources to display
   * 
   * Controls how many resource cards are shown. Higher limits provide
   * more comprehensive guidance but require more screen space.
   * 
   * @default 8
   * @example 10
   */
  limit?: number;
 
  /**
   * Optional flag to show only top/priority resources
   * 
   * When true, filters to show only the most relevant and high-priority
   * resources for the selected security levels, providing focused guidance.
   * 
   * @default false
   * @example true
   */
  showTopResourcesOnly?: boolean;
}
 
/**
 * Widget that displays security resources and implementation guides
 * 
 * This component provides security practitioners with relevant resources,
 * implementation guides, and best practices to help implement appropriate
 * security controls for the selected security levels. It bridges the gap
 * between security requirements and practical implementation.
 * 
 * ## Features
 * - Dynamic resource filtering based on security levels
 * - Categorized display of resources by CIA component
 * - Support for limiting displayed resources
 * - Top resources filtering for focused guidance
 * - Loading and error states
 * - Accessible and responsive design
 * 
 * ## Business Perspective
 * 
 * This widget accelerates security implementation by providing practitioners
 * with immediately actionable guidance, reducing research time and ensuring
 * best practices are followed. It improves security ROI by helping teams
 * implement controls correctly the first time. 📚
 * 
 * @component
 * 
 * @example
 * ```tsx
 * // Basic usage with uniform security levels
 * <SecurityResourcesWidget
 *   availabilityLevel="Moderate"
 *   integrityLevel="Moderate"
 *   confidentialityLevel="Moderate"
 * />
 * 
 * // Advanced usage with custom configuration
 * <SecurityResourcesWidget
 *   availabilityLevel="High"
 *   integrityLevel="Very High"
 *   confidentialityLevel="Moderate"
 *   limit={12}
 *   showTopResourcesOnly={true}
 *   className="border-2 border-gray-200 p-4"
 *   testId="main-security-resources"
 * />
 * ```
 */
const SecurityResourcesWidget: React.FC<SecurityResourcesWidgetProps> = ({
  availabilityLevel,
  integrityLevel,
  confidentialityLevel,
  className = "",
  testId = SECURITY_RESOURCES_TEST_IDS.WIDGET,
  limit = 8,
  showTopResourcesOnly = false,
}) => {
  // Use the CIA content service
  const {
    ciaContentService,
    error: serviceError,
    isLoading,
  } = useCIAContentService();
 
  // State for resource filtering and pagination
  const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
  const [searchTerm, setSearchTerm] = useState("");
  const [currentPage, setCurrentPage] = useState(1);
  const [resourcesPerPage, setResourcesPerPage] = useState(limit);
 
  // Calculate security resources with proper error handling and type safety
  const securityResources = useMemo((): SecurityResource[] => {
    try {
      if (isNullish(ciaContentService)) {
        return [];
      }
 
      // Get resources for each security level
      const availabilityResources = isArray(
        ciaContentService.getSecurityResources?.(
          "availability",
          availabilityLevel
        )
      )
        ? ciaContentService.getSecurityResources?.(
            "availability",
            availabilityLevel
          )
        : [];
 
      const integrityResources = isArray(
        ciaContentService.getSecurityResources?.("integrity", integrityLevel)
      )
        ? ciaContentService.getSecurityResources?.("integrity", integrityLevel)
        : [];
 
      const confidentialityResources = isArray(
        ciaContentService.getSecurityResources?.(
          "confidentiality",
          confidentialityLevel
        )
      )
        ? ciaContentService.getSecurityResources?.(
            "confidentiality",
            confidentialityLevel
          )
        : [];
 
      // Combine all resources
      const allResources = [
        ...(availabilityResources || []),
        ...(integrityResources || []),
        ...(confidentialityResources || []),
      ];
 
      // Deduplicate resources by URL (or title if URL is not available)
      const uniqueResources: SecurityResource[] = [];
      const resourceKeys = new Set();
 
      allResources.forEach((resource) => {
        const key = isString(resource.url) ? resource.url : resource.title;
        if (!resourceKeys.has(key)) {
          resourceKeys.add(key);
          uniqueResources.push(resource);
        }
      });
 
      // Sort by relevance score if available, otherwise by title
      return uniqueResources.sort((a, b) => {
        // Use type safe approach to access properties
        const aScore =
          isObject(a) && "relevanceScore" in a
            ? (a.relevanceScore as number)
            : 0;
        const bScore =
          isObject(b) && "relevanceScore" in b
            ? (b.relevanceScore as number)
            : 0;
 
        Eif (aScore !== undefined && bScore !== undefined) {
          return bScore - aScore;
        }
        return a.title.localeCompare(b.title);
      });
    } catch (err) {
      console.error("Error getting security resources:", err);
      return [];
    }
  }, [
    ciaContentService,
    availabilityLevel,
    integrityLevel,
    confidentialityLevel,
  ]);
 
  // Get unique resource categories for filtering
  const resourceCategories = useMemo(() => {
    const categories = new Set<string>();
    securityResources.forEach((resource) => {
      if (resource.category) {
        categories.add(resource.category);
      }
    });
    return Array.from(categories).sort();
  }, [securityResources]);
 
  // Filter resources based on category and search term
  const filteredResources = useMemo(() => {
    let filtered = securityResources;
 
    // Apply category filter
    Iif (selectedCategory) {
      filtered = filtered.filter(
        (resource) => resource.category === selectedCategory
      );
    }
 
    // Apply search filter
    if (searchTerm.trim()) {
      const normalizedSearch = searchTerm.toLowerCase().trim();
      filtered = filtered.filter(
        (resource) =>
          resource.title.toLowerCase().includes(normalizedSearch) ||
          resource.description?.toLowerCase().includes(normalizedSearch) ||
          (resource.tags &&
            resource.tags.some((tag) =>
              tag.toLowerCase().includes(normalizedSearch)
            ))
      );
    }
 
    return filtered;
  }, [securityResources, selectedCategory, searchTerm]);
 
  // Paginate resources
  const currentResources = useMemo(() => {
    const indexOfLastResource = currentPage * resourcesPerPage;
    const indexOfFirstResource = indexOfLastResource - resourcesPerPage;
    return filteredResources.slice(indexOfFirstResource, indexOfLastResource);
  }, [filteredResources, currentPage, resourcesPerPage]);
 
  // Handle category selection
  const handleCategorySelect = useCallback((category: string | null) => {
    setSelectedCategory(category);
    setCurrentPage(1); // Reset to first page when changing filters
  }, []);
 
  // Handle search input change
  const handleSearchChange = useCallback(
    (e: React.ChangeEvent<HTMLInputElement>) => {
      setSearchTerm(e.target.value);
      setCurrentPage(1); // Reset to first page when changing search
    },
    []
  );
 
  // Handle page change
  const handlePageChange = useCallback((pageNumber: number) => {
    setCurrentPage(pageNumber);
  }, []);
 
  // Determine total pages
  const totalPages = Math.ceil(filteredResources.length / resourcesPerPage);
 
  // Get implementation guides - component-specific guidance
  const implementationGuides = useMemo(() => {
    try {
      if (isNullish(ciaContentService)) {
        return [];
      }
 
      return [
        ciaContentService.getTechnicalImplementation?.(
          "availability",
          availabilityLevel
        ),
        ciaContentService.getTechnicalImplementation?.(
          "integrity",
          integrityLevel
        ),
        ciaContentService.getTechnicalImplementation?.(
          "confidentiality",
          confidentialityLevel
        ),
      ].filter((guide) => guide !== undefined);
    } catch (err) {
      console.error("Error getting implementation guides:", err);
      return [];
    }
  }, [
    ciaContentService,
    availabilityLevel,
    integrityLevel,
    confidentialityLevel,
  ]);
 
  return (
    <WidgetErrorBoundary widgetName="Security Resources">
      <WidgetContainer
        title={WIDGET_TITLES.SECURITY_RESOURCES || "Security Resources"}
        icon={WIDGET_ICONS.SECURITY_RESOURCES || "📚"}
        className={className}
        testId={testId}
        isLoading={isLoading}
        error={serviceError}
      >
      <div className="p-4">
        {/* Widget introduction */}
        <div className="mb-4 p-3 bg-blue-50 dark:bg-blue-900 dark:bg-opacity-20 rounded-lg">
          <p className="text-sm">
            This widget provides curated security resources to help implement
            controls that align with your selected security levels across the
            CIA triad.
          </p>
        </div>
 
        <div className="flex flex-col md:flex-row gap-4">
          {/* Filters and search - left column on larger screens */}
          <div className="md:w-1/4">
            <div className="mb-4">
              <label
                htmlFor="resource-search"
                className="block text-sm font-medium mb-1"
              >
                Search Resources
              </label>
              <div className="relative">
                <input
                  id="resource-search"
                  type="text"
                  className="w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-md dark:bg-gray-800 focus:outline-none focus:ring-blue-500 focus:border-blue-500"
                  placeholder="Search by title, description..."
                  value={searchTerm}
                  onChange={handleSearchChange}
                  data-testid={`${testId}-search`}
                />
                <span className="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500 dark:text-gray-400">
                  🔍
                </span>
              </div>
            </div>
 
            {resourceCategories.length > 0 && (
              <div className="mb-4">
                <h3 className="text-sm font-medium mb-2">Categories</h3>
                <div className="space-y-2">
                  <div
                    className={`px-3 py-2 rounded-md cursor-pointer text-sm ${
                      selectedCategory === null
                        ? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:bg-opacity-30 dark:text-blue-300"
                        : "bg-gray-100 hover:bg-gray-200 text-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
                    }`}
                    onClick={() => handleCategorySelect(null)}
                    data-testid={`${testId}-category-all`}
                  >
                    All Resources
                  </div>
 
                  {resourceCategories.map((category, index) => (
                    <div
                      key={category}
                      className={`px-3 py-2 rounded-md cursor-pointer text-sm ${
                        selectedCategory === category
                          ? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:bg-opacity-30 dark:text-blue-300"
                          : "bg-gray-100 hover:bg-gray-200 text-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
                      }`}
                      onClick={() => handleCategorySelect(category)}
                      data-testid={`${testId}-category-${index}`}
                    >
                      {category}
                    </div>
                  ))}
                </div>
              </div>
            )}
 
            {/* Implementation Guidelines */}
            <div className="mb-4">
              <h3 className="text-sm font-medium mb-2">
                Implementation Guidelines
              </h3>
              <div className="bg-gray-50 dark:bg-gray-800 p-3 rounded-lg text-sm">
                <p className="mb-2 font-medium">Selected Security Levels:</p>
                <div className="mb-2 text-xs">
                  <div className="flex justify-between">
                    <span>Confidentiality:</span>
                    <span className="font-medium">{confidentialityLevel}</span>
                  </div>
                  <div className="flex justify-between mb-1">
                    <span>Integrity:</span>
                    <span className="font-medium">{integrityLevel}</span>
                  </div>
                  <div className="flex justify-between mb-1">
                    <span>Availability:</span>
                    <span className="font-medium">{availabilityLevel}</span>
                  </div>
                </div>
 
                <p className="mb-2 text-xs text-gray-600 dark:text-gray-400">
                  Focus on implementing controls that satisfy all three
                  components for a balanced security posture.
                </p>
              </div>
            </div>
          </div>
 
          {/* Resources grid - right column on larger screens */}
          <div className="md:w-3/4">
            {/* Resources list */}
            <div className="mb-4">
              <div className="flex justify-between items-center mb-2">
                <h3 className="text-lg font-medium">Security Resources</h3>
                <div className="text-sm text-gray-600 dark:text-gray-400">
                  {filteredResources.length}{" "}
                  {filteredResources.length === 1 ? "resource" : "resources"}{" "}
                  found
                </div>
              </div>
 
              {/* Empty state */}
              {filteredResources.length === 0 && (
                <div
                  className="p-4 bg-gray-50 dark:bg-gray-800 rounded-lg text-center text-gray-500 dark:text-gray-400"
                  data-testid={`${testId}-no-resources`}
                >
                  <p className="mb-2">No resources found.</p>
                  <p className="text-sm">
                    {searchTerm
                      ? "Try adjusting your search terms or clearing filters."
                      : "Resources will appear here when available."}
                  </p>
                </div>
              )}
 
              {/* Resources grid */}
              {filteredResources.length > 0 && (
                <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
                  {currentResources.map((resource, index) => (
                    <ResourceCard
                      key={`${resource.url || ""}-${index}`}
                      resource={resource}
                      testId={`${testId}-resource-${index}`}
                    />
                  ))}
                </div>
              )}
 
              {/* Pagination controls */}
              {totalPages > 1 && (
                <div className="mt-4 flex justify-center">
                  <nav
                    className="relative z-0 inline-flex rounded-md shadow-sm -space-x-px"
                    aria-label="Pagination"
                  >
                    <button
                      onClick={() => handlePageChange(currentPage - 1)}
                      disabled={currentPage === 1}
                      className={`relative inline-flex items-center px-2 py-2 rounded-l-md border ${
                        currentPage === 1
                          ? "bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-600 cursor-not-allowed"
                          : "bg-white text-gray-500 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
                      } text-sm font-medium`}
                    >
                      Previous
                    </button>
 
                    {/* Page numbers */}
                    {Array.from({ length: totalPages }).map((_, index) => (
                      <button
                        key={index}
                        onClick={() => handlePageChange(index + 1)}
                        className={`relative inline-flex items-center px-4 py-2 border text-sm font-medium ${
                          currentPage === index + 1
                            ? "z-10 bg-blue-50 border-blue-500 text-blue-600 dark:bg-blue-900 dark:bg-opacity-30 dark:text-blue-300"
                            : "bg-white text-gray-500 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
                        }`}
                      >
                        {index + 1}
                      </button>
                    ))}
 
                    <button
                      onClick={() => handlePageChange(currentPage + 1)}
                      disabled={currentPage === totalPages}
                      className={`relative inline-flex items-center px-2 py-2 rounded-r-md border ${
                        currentPage === totalPages
                          ? "bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-600 cursor-not-allowed"
                          : "bg-white text-gray-500 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
                      } text-sm font-medium`}
                    >
                      Next
                    </button>
                  </nav>
                </div>
              )}
            </div>
 
            {/* Implementation Tips Section */}
            <div className="mt-6">
              <h3 className="text-lg font-medium mb-3">Implementation Tips</h3>
 
              <div className="space-y-4">
                {/* General implementation tips */}
                <div className="p-3 bg-gray-50 dark:bg-gray-800 rounded-lg">
                  <h4 className="text-md font-medium mb-2">
                    Getting Started with Implementation
                  </h4>
                  <ol className="list-decimal list-inside space-y-2 text-sm text-gray-600 dark:text-gray-400 pl-2">
                    <li>
                      Begin with a thorough assessment of your current security
                      controls
                    </li>
                    <li>
                      Prioritize implementations based on risk exposure and
                      business impact
                    </li>
                    <li>
                      Implement controls gradually, starting with foundational
                      elements
                    </li>
                    <li>
                      Document your implementation process and security
                      configurations
                    </li>
                    <li>Test and validate controls after implementation</li>
                  </ol>
                </div>
 
                {/* Component-specific tips */}
                {implementationGuides.length > 0 && (
                  <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
                    {/* Confidentiality Implementation */}
                    {implementationGuides[2] && (
                      <div className="p-3 bg-purple-50 dark:bg-purple-900 dark:bg-opacity-20 rounded-lg border border-purple-100 dark:border-purple-800">
                        <h4 className="text-md font-medium mb-2 text-purple-700 dark:text-purple-300 flex items-center">
                          <span className="mr-2">🔒</span>Confidentiality (
                          {confidentialityLevel})
                        </h4>
                        <div className="text-sm text-gray-600 dark:text-gray-400">
                          <p className="mb-2">
                            {implementationGuides[2].description ||
                              "Focus on data protection and access controls."}
                          </p>
                          <div className="text-xs">
                            <span className="font-medium">Expertise:</span>{" "}
                            {implementationGuides[2].expertiseLevel ||
                              "Standard"}
                          </div>
                          <div className="text-xs">
                            <span className="font-medium">Effort:</span>{" "}
                            {implementationGuides[2].developmentEffort ||
                              "Medium"}
                          </div>
                        </div>
                      </div>
                    )}
 
                    {/* Integrity Implementation */}
                    {implementationGuides[1] && (
                      <div className="p-3 bg-green-50 dark:bg-green-900 dark:bg-opacity-20 rounded-lg border border-green-100 dark:border-green-800">
                        <h4 className="text-md font-medium mb-2 text-green-700 dark:text-green-300 flex items-center">
                          <span className="mr-2">✓</span>Integrity (
                          {integrityLevel})
                        </h4>
                        <div className="text-sm text-gray-600 dark:text-gray-400">
                          <p className="mb-2">
                            {implementationGuides[1].description ||
                              "Focus on data accuracy and validation mechanisms."}
                          </p>
                          <div className="text-xs">
                            <span className="font-medium">Expertise:</span>{" "}
                            {implementationGuides[1].expertiseLevel ||
                              "Standard"}
                          </div>
                          <div className="text-xs">
                            <span className="font-medium">Effort:</span>{" "}
                            {implementationGuides[1].developmentEffort ||
                              "Medium"}
                          </div>
                        </div>
                      </div>
                    )}
 
                    {/* Availability Implementation */}
                    {implementationGuides[0] && (
                      <div className="p-3 bg-blue-50 dark:bg-blue-900 dark:bg-opacity-20 rounded-lg border border-blue-100 dark:border-blue-800">
                        <h4 className="text-md font-medium mb-2 text-blue-700 dark:text-blue-300 flex items-center">
                          <span className="mr-2">⏱️</span>Availability (
                          {availabilityLevel})
                        </h4>
                        <div className="text-sm text-gray-600 dark:text-gray-400">
                          <p className="mb-2">
                            {implementationGuides[0].description ||
                              "Focus on systems uptime and recovery capabilities."}
                          </p>
                          <div className="text-xs">
                            <span className="font-medium">Expertise:</span>{" "}
                            {implementationGuides[0].expertiseLevel ||
                              "Standard"}
                          </div>
                          <div className="text-xs">
                            <span className="font-medium">Effort:</span>{" "}
                            {implementationGuides[0].developmentEffort ||
                              "Medium"}
                          </div>
                        </div>
                      </div>
                    )}
                  </div>
                )}
 
                {/* Common Implementation Challenges */}
                <div className="p-3 bg-yellow-50 dark:bg-yellow-900 dark:bg-opacity-20 rounded-lg border border-yellow-100 dark:border-yellow-800">
                  <h4 className="text-md font-medium mb-2 text-yellow-700 dark:text-yellow-300 flex items-center">
                    <span className="mr-2">⚠️</span>Common Implementation
                    Challenges
                  </h4>
                  <ul className="list-disc list-inside space-y-1 text-sm text-gray-600 dark:text-gray-400 pl-2">
                    <li>Balancing security with usability and performance</li>
                    <li>
                      Maintaining consistent controls across different
                      environments
                    </li>
                    <li>Integration with legacy systems and applications</li>
                    <li>
                      Building security expertise and awareness across teams
                    </li>
                    <li>
                      Allocating sufficient resources for ongoing maintenance
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </WidgetContainer>
    </WidgetErrorBoundary>
  );
};
 
export default SecurityResourcesWidget;