{"version":3,"file":"fundamental-ngx-ui5-webcomponents-ai-button.mjs","sources":["../../../../libs/ui5-webcomponents-ai/button/index.ts","../../../../libs/ui5-webcomponents-ai/button/fundamental-ngx-ui5-webcomponents-ai-button.ts"],"sourcesContent":["\nimport {\n  ChangeDetectionStrategy,\n  Component,\n  ElementRef,\n  input,\n  output,\n  AfterViewInit,\n  effect,\n  runInInjectionContext,\n  inject,\n  Injector,\n  booleanAttribute,\n  computed,\n  signal,\n  DestroyRef\n} from '@angular/core';\nimport '@ui5/webcomponents-ai/dist/Button.js';\nimport { default as _Button } from '@ui5/webcomponents-ai/dist/Button.js';\nimport { UI5CustomEvent } from '@ui5/webcomponents-base';\nimport {\n  ContentDensityObserver,\n  contentDensityObserverProviders,\n  ContentDensityMode\n} from '@fundamental-ngx/core/content-density';\n\n\nimport { AIButtonAccessibilityAttributes } from '@ui5/webcomponents-ai/dist/Button.js';\nimport { default as ButtonDesign } from '@ui5/webcomponents/dist/types/ButtonDesign.js';\n\n@Component({\n  standalone: true,\n  selector: 'ui5-ai-button, [ui5-ai-button]',\n  template: '<ng-content></ng-content>',\n  exportAs: 'ui5Button',\n  providers: [\n    contentDensityObserverProviders({\n      supportedContentDensity: [ContentDensityMode.COMPACT, ContentDensityMode.COZY]\n    })\n  ],\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class Button implements AfterViewInit {\n\n  /**\n   * Defines the additional accessibility attributes that will be applied to the component.\n\nThis property allows for fine-tuned control of ARIA attributes for screen reader support.\nIt accepts an object with the following optional fields:\n\n- **root**: Accessibility attributes that will be applied to the root element.\n - **hasPopup**: Indicates the availability and type of interactive popup element (such as a menu or dialog).\n   Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n - **roleDescription**: Defines a human-readable description for the button's role.\n   Accepts any string value.\n - **title**: Specifies a tooltip or description for screen readers.\n   Accepts any string value.\n- **ariaKeyShortcuts**: Defines keyboard shortcuts that activate or focus the button.\n\n- **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.\n - **hasPopup**: Indicates the type of popup triggered by the arrow button.\n   Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.\n   Accepts boolean values: `true` or `false`.\n   */\n  accessibilityAttributes = input<typeof _Button.prototype.accessibilityAttributes | undefined>({});\n\n  /**\n   * Defines the active state of the arrow button in split mode.\nSet to true when the button is in split mode and a menu with additional options\nis opened by the arrow button. Set back to false when the menu is closed.\n   */\n  arrowButtonPressed = input(false, { transform: booleanAttribute });\n\n  /**\n   * Defines the component design.\n   */\n  design = input<typeof _Button.prototype.design | undefined>(\"Default\");\n\n  /**\n   * Defines whether the component is disabled.\nA disabled component can't be pressed or\nfocused, and it is not in the tab chain.\n   */\n  disabled = input(false, { transform: booleanAttribute });\n\n  /**\n   * Defines the current state of the component.\n   */\n  state = input<typeof _Button.prototype.state | undefined>(); // className is now passed\n\n\n\n  /**\n   * Fired when the component is in split mode and after the arrow button\nis activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],\n[Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.\n   */\n  ui5ArrowButtonClick = output<UI5CustomEvent<_Button, 'arrow-button-click'>>();\n\n  /**\n   * Fired when the component is activated either with a\nmouse/tap or by using the Enter or Space key.\n   */\n  ui5Click = output<UI5CustomEvent<_Button, 'click'>>();\n\n  /**\n   * Available slots for content projection in this component.\n   *\n   * Slots allow you to insert custom content into predefined areas of the web component.\n   * Use the `slot` attribute on child elements to target specific slots.\n   *\n   * - **(default)**: Defines the available states of the component.\n**Note:** Although this slot accepts HTML Elements, it is strongly recommended that\nyou only use `ui5-ai-button-state` components in order to preserve the intended design.\n   *\n   * @example\n   * ```html\n   * <ui5-ai-button>\n   *   <div slot=\"header\">Custom header content</div>\n   *   <p>Default slot content</p>\n   * </ui5-ai-button>\n   * ```\n   *\n   * @readonly\n   * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots | MDN Web Components Slots}\n   */\n  readonly slots = [\n      {\n          \"name\": \"default\",\n          \"description\": \"Defines the available states of the component.\\n**Note:** Although this slot accepts HTML Elements, it is strongly recommended that\\nyou only use `ui5-ai-button-state` components in order to preserve the intended design.\"\n      }\n  ];\n\n\n  public elementRef: ElementRef<_Button> = inject(ElementRef);\n  public injector = inject(Injector);\n\n  /**\n   * Content density observer is injected to activate automatic CSS class and\n   * UI5 attribute application. The observer self-initializes, no explicit subscribe() needed.\n   * @private\n   */\n  private readonly _contentDensityObserver = inject(ContentDensityObserver);\n  private readonly _destroyRef = inject(DestroyRef);\n\n  get element(): _Button {\n    return this.elementRef.nativeElement;\n  }\n\n  ngAfterViewInit(): void {\n    const wcElement = this.element;\n    \n    const inputsToSync = [\n      'accessibilityAttributes',\n      'arrowButtonPressed',\n      'design',\n      'disabled',\n      'state',\n    ];\n    \n    // Synchronize inputs (properties)\n    for (const inputName of inputsToSync) {\n      // Find the corresponding camelCase signal property on the Angular component\n      const signalName = inputName.replace(/-./g, (x: string) => x[1].toUpperCase());\n\n      // Use the Injector to run the effect in the correct context\n      if (this[signalName] && typeof this[signalName] === 'function') {\n        runInInjectionContext(this.injector, (): void => {\n          effect((): void => {\n            // Read the signal value\n            const value = this[signalName]();\n            if (wcElement) {\n              // Skip writes when the signal is undefined and the property is already truthy\n              // This prevents clobbering imperatively-set values (e.g., from RouterLink)\n              if (value === undefined && wcElement[inputName]) {\n                return;\n              }\n              // Write the value to the Web Component's property\n              wcElement[inputName] = value;\n            }\n          });\n        });\n      }\n    }\n  \n    \n    const outputsToSync = [\n      'ui5ArrowButtonClick',\n      'ui5Click',\n    ];\n    \n    // Synchronize outputs (events)\n    const _listeners: Array<() => void> = [];\n    for (const outputName of outputsToSync) {\n      // Map Angular output name to UI5 web component event name\n      const eventName = outputName.replace('ui5', '').replace(/([A-Z])/g, '-$1').toLowerCase().substring(1);\n      // Ensure the output property exists and has an emit function before adding listener\n      if (this[outputName] && typeof this[outputName].emit === 'function' && wcElement.addEventListener) {\n        // Cast the listener to the correct type to satisfy TypeScript\n        const listener = (e: Event): void => {\n\n          this[outputName].emit(e as CustomEvent<any>);\n        };\n        wcElement.addEventListener(eventName, listener);\n        _listeners.push(() => wcElement.removeEventListener(eventName, listener));\n      }\n    }\n    this._destroyRef.onDestroy(() => _listeners.forEach((fn) => fn()));\n  \n\n  }\n}\n\n// Re-export types for convenience\nexport { AIButtonAccessibilityAttributes } from '@ui5/webcomponents-ai/dist/Button.js';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MA0Ca,MAAM,CAAA;AAZnB,IAAA,WAAA,GAAA;AAcE;;;;;;;;;;;;;;;;;;;;AAoBG;QACH,IAAA,CAAA,uBAAuB,GAAG,KAAK,CAA+D,EAAE;oGAAC;AAEjG;;;;AAIG;QACH,IAAA,CAAA,kBAAkB,GAAG,KAAK,CAAC,KAAK,0FAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAElE;;AAEG;QACH,IAAA,CAAA,MAAM,GAAG,KAAK,CAA8C,SAAS;mFAAC;AAEtE;;;;AAIG;QACH,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAExD;;AAEG;AACH,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK;AAA8C,QAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,OAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAA,CAAC;AAI5D;;;;AAIG;QACH,IAAA,CAAA,mBAAmB,GAAG,MAAM,EAAiD;AAE7E;;;AAGG;QACH,IAAA,CAAA,QAAQ,GAAG,MAAM,EAAoC;AAErD;;;;;;;;;;;;;;;;;;;;AAoBG;AACM,QAAA,IAAA,CAAA,KAAK,GAAG;AACb,YAAA;AACI,gBAAA,MAA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