(function(e,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(e=typeof globalThis<"u"?globalThis:e||self,o(e.BookingWidgetButton={}))})(this,(function(e){"use strict";/*!
 * BookiFlex Booking Widget Button
 * License: GPL-2.0-or-later
 * © 2026 BookiFlex
 */class o extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.isLoading=!1,this.isPulsing=!1,this.handleClick=this.handleClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.render(),this.setupEventListeners()}static get observedAttributes(){return["text","position","color","text-color","border-color","border-width","border-radius","font-size","padding","pulse","loading","theme","icon","disabled","admin-preview"]}attributeChangedCallback(t,i,n){i!==n&&(this.updateStyles(),this.updateContent())}render(){this.shadowRoot.innerHTML=`
                    <style>
                        :host {
                            /* CSS Custom Properties для конфигурации */
                            --btn-bg-color: ${this.getAttribute("color")||"#007bff"};
                            --btn-text-color: ${this.getAttribute("text-color")||"#ffffff"};
                            --btn-border-color: ${this.getAttribute("border-color")||"transparent"};
                            --btn-border-width: ${this.getAttribute("border-width")||"2px"};
                            --btn-border-radius: ${this.getAttribute("border-radius")||"25px"};
                            --btn-font-size: ${this.getAttribute("font-size")||"16px"};
                            --btn-font-weight: 600;
                            --btn-padding: ${this.getAttribute("padding")||"12px 24px"};
                            --btn-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
                            --btn-hover-transform: translateY(-2px);
                            --btn-hover-shadow: 0 8px 25px rgba(0, 123, 255, 0.4);
                            --btn-active-transform: translateY(0);
                            --btn-active-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
                            --btn-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                            
                            /* Позиционирование */
                            --desktop-bottom: 30px;
                            --desktop-side: 30px;
                            --mobile-bottom: 20px;
                            --btn-border-style: initial;
                            
                            /* Анимации */
                            --btn-pulse-color: rgba(0, 123, 255, 0.4);
                            
                            /* Позиционирование хоста */
                            position: fixed;
                            z-index: 99999;
                            bottom: var(--desktop-bottom);
                            border-style: var(--btn-border-style) !important;
                            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
                        }
                        
                        /* Позиционирование для desktop */
                        @media (min-width: 769px) {
                            :host([position="bottom-left"]) {
                                left: var(--desktop-side);
                            }
                            
                            :host([position="bottom-right"]) {
                                right: var(--desktop-side);
                            }
                            
                            :host([position="bottom-center"]) {
                                left: 50%;
                                transform: translateX(-50%);
                            }
                        }
                        
                        /* Мобильное позиционирование */
                        @media (max-width: 768px) {
                            :host {
                                left: 50%;
                                transform: translateX(-50%);
                                bottom: var(--mobile-bottom);
                            }
                        }
                        
                        /* Основные стили кнопки */
                        .booking-button {
                            display: inline-flex;
                            align-items: center;
                            justify-content: center;
                            gap: 8px;
                            
                            background-color: var(--btn-bg-color);
                            color: var(--btn-text-color);
                            border: var(--btn-border-width) solid var(--btn-border-color);
                            border-radius: var(--btn-border-radius);
                            font-size: var(--btn-font-size);
                            font-weight: var(--btn-font-weight);
                            padding: var(--btn-padding);
                            
                            box-shadow: var(--btn-shadow);
                            cursor: pointer;
                            user-select: none;
                            
                            transition: var(--btn-transition);
                            
                            position: relative;
                            overflow: hidden;
                            
                            outline: none;
                            white-space: nowrap;
                            text-decoration: none;
                        }
                        
                        /* Состояния кнопки */
                        .booking-button:hover:not(:disabled) {
                            transform: var(--btn-hover-transform);
                            box-shadow: var(--btn-hover-shadow);
                            filter: brightness(1.1);
                        }
                        
                        .booking-button:active:not(:disabled) {
                            transform: var(--btn-active-transform);
                            box-shadow: var(--btn-active-shadow);
                        }
                        
                        .booking-button:disabled {
                            opacity: 0.6;
                            cursor: not-allowed;
                        }
                        
                        /* Иконка */
                        .booking-icon {
                            width: 20px;
                            height: 20px;
                            fill: currentColor;
                        }
                        
                        /* Спиннер загрузки */
                        .loading-spinner {
                            width: 16px;
                            height: 16px;
                            border: 2px solid rgba(255, 255, 255, 0.3);
                            border-top: 2px solid currentColor;
                            border-radius: 50%;
                            animation: spin 1s linear infinite;
                        }
                        
                        @keyframes spin {
                            0% { transform: rotate(0deg); }
                            100% { transform: rotate(360deg); }
                        }
                        
                        /* Скрытие элементов */
                        .booking-button:not(.loading) .loading-spinner {
                            display: none;
                        }
                        
                        .booking-button.loading .booking-text {
                            opacity: 0.5;
                        }
                        
                        .booking-button.loading .booking-icon {
                            display: none;
                        }
                        
                        /* Ripple эффект */
                        .booking-button::before {
                            content: '';
                            position: absolute;
                            top: 50%;
                            left: 50%;
                            width: 0;
                            height: 0;
                            background: rgba(255, 255, 255, 0.3);
                            border-radius: 50%;
                            transform: translate(-50%, -50%);
                            transition: width 0.3s ease, height 0.3s ease;
                        }
                        
                        .booking-button:active::before {
                            width: 200px;
                            height: 200px;
                        }
                        
                        /* Пульсация */
                        @keyframes pulse {
                            0% {
                                box-shadow: var(--btn-shadow);
                            }
                            50% {
                                box-shadow: var(--btn-shadow), 0 0 0 10px var(--btn-pulse-color);
                            }
                            100% {
                                box-shadow: var(--btn-shadow), 0 0 0 0 var(--btn-pulse-color);
                            }
                        }
                        
                        .booking-button.pulse {
                            animation: pulse 2s infinite;
                        }
                        
                        /* Фокус для accessibility */
                        .booking-button:focus-visible {
                            outline: 3px solid var(--btn-pulse-color);
                            outline-offset: 2px;
                        }
                        
                        /* Адаптивность */
                        @media (max-width: 480px) {
                            :host {
                                --btn-font-size: 14px;
                                --btn-padding: 10px 20px;
                            }
                        }
                        
                        /* Темная тема */
                        :host([theme="dark"]) {
                            --btn-bg-color: #1a1a1a;
                            --btn-text-color: #ffffff;
                            --btn-border-color: #333333;
                            --btn-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
                            --btn-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
                            --btn-active-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
                            --btn-pulse-color: rgba(255, 255, 255, 0.2);
                        }
                        
                        /* Скрытие хоста */
                        :host([hidden]) {
                            display: none !important;
                        }

                        /* Admin preview badge */
                        .button-wrapper {
                            position: relative;
                            display: inline-block;
                        }

                        .admin-badge {
                            display: none;
                            position: absolute;
                            top: -8px;
                            right: -8px;
                            background: #f59e0b;
                            color: #fff;
                            font-size: 10px;
                            font-weight: 600;
                            padding: 2px 6px;
                            border-radius: 8px;
                            white-space: nowrap;
                            pointer-events: none;
                            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
                            z-index: 1;
                        }

                        :host([admin-preview="true"]) .admin-badge {
                            display: block;
                        }
                    </style>

                    <div class="button-wrapper">
                        <button class="booking-button" role="button" aria-label="Open booking widget">
                            <svg class="booking-icon" viewBox="0 0 24 24" aria-hidden="true">
                                <path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"/>
                            </svg>
                            <span class="booking-text">${this.getAttribute("text")||"Book Now"}</span>
                            <div class="loading-spinner" aria-hidden="true"></div>
                        </button>
                        <span class="admin-badge">Admin only</span>
                    </div>
                `,this.buttonElement=this.shadowRoot.querySelector(".booking-button"),this.updateStyles(),this.updateContent()}setupEventListeners(){this.buttonElement.addEventListener("click",this.handleClick),this.buttonElement.addEventListener("keydown",this.handleKeyDown)}handleClick(t){if(this.isLoading||this.hasAttribute("disabled"))return;const i=new CustomEvent("booking-click",{detail:{text:this.getAttribute("text"),position:this.getAttribute("position"),timestamp:Date.now()},bubbles:!0,composed:!0});this.dispatchEvent(i)}handleKeyDown(t){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.handleClick(t))}updateStyles(){if(!this.buttonElement)return;this.shadowRoot.querySelector("style")&&(this.style.setProperty("--btn-bg-color",this.getAttribute("color")||"#007bff"),this.style.setProperty("--btn-text-color",this.getAttribute("text-color")||"#ffffff"),this.style.setProperty("--btn-border-color",this.getAttribute("border-color")||"transparent"),this.style.setProperty("--btn-border-width",this.getAttribute("border-width")||"2px"),this.style.setProperty("--btn-border-radius",this.getAttribute("border-radius")||"25px"),this.style.setProperty("--btn-font-size",this.getAttribute("font-size")||"16px"),this.style.setProperty("--btn-padding",this.getAttribute("padding")||"12px 24px")),this.buttonElement.classList.toggle("pulse",this.getAttribute("pulse")==="true"),this.buttonElement.classList.toggle("loading",this.getAttribute("loading")==="true")}updateContent(){if(!this.buttonElement)return;const t=this.shadowRoot.querySelector(".booking-text");t&&(t.textContent=this.getAttribute("text")||"Book Now"),this.buttonElement.setAttribute("aria-label",`Open booking widget: ${this.getAttribute("text")||"Book Now"}`)}configure(t={}){return Object.entries(t).forEach(([i,n])=>{const s=i.replace(/([A-Z])/g,"-$1").toLowerCase();this.setAttribute(s,n)}),this}setLoading(t=!0){return this.isLoading=t,this.setAttribute("loading",t.toString()),this}setPulse(t=!0){return this.isPulsing=t,this.setAttribute("pulse",t.toString()),this}show(){return this.removeAttribute("hidden"),this}hide(){return this.setAttribute("hidden",""),this}disconnectedCallback(){this.buttonElement&&(this.buttonElement.removeEventListener("click",this.handleClick),this.buttonElement.removeEventListener("keydown",this.handleKeyDown))}}customElements.get("booking-widget-button")||customElements.define("booking-widget-button",o),e.BookingWidgetButton=o,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
