var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
    var _, done = false;
    for (var i = decorators.length - 1; i >= 0; i--) {
        var context = {};
        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
        if (kind === "accessor") {
            if (result === void 0) continue;
            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
            if (_ = accept(result.get)) descriptor.get = _;
            if (_ = accept(result.set)) descriptor.set = _;
            if (_ = accept(result.init)) initializers.unshift(_);
        }
        else if (_ = accept(result)) {
            if (kind === "field") initializers.unshift(_);
            else descriptor[key] = _;
        }
    }
    if (target) Object.defineProperty(target, contextIn.name, descriptor);
    done = true;
};
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
    var useValue = arguments.length > 2;
    for (var i = 0; i < initializers.length; i++) {
        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
    }
    return useValue ? value : void 0;
};
import { DeesElement, customElement, html, css, cssManager, property, } from '@design.estate/dees-element';
let SzLoginView = (() => {
    let _classDecorators = [customElement('sz-login-view')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = DeesElement;
    let _loading_decorators;
    let _loading_initializers = [];
    let _loading_extraInitializers = [];
    let _error_decorators;
    let _error_initializers = [];
    let _error_extraInitializers = [];
    let _title_decorators;
    let _title_initializers = [];
    let _title_extraInitializers = [];
    let _subtitle_decorators;
    let _subtitle_initializers = [];
    let _subtitle_extraInitializers = [];
    var SzLoginView = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _loading_decorators = [property({ type: Boolean })];
            _error_decorators = [property({ type: String })];
            _title_decorators = [property({ type: String })];
            _subtitle_decorators = [property({ type: String })];
            __esDecorate(this, null, _loading_decorators, { kind: "accessor", name: "loading", static: false, private: false, access: { has: obj => "loading" in obj, get: obj => obj.loading, set: (obj, value) => { obj.loading = value; } }, metadata: _metadata }, _loading_initializers, _loading_extraInitializers);
            __esDecorate(this, null, _error_decorators, { kind: "accessor", name: "error", static: false, private: false, access: { has: obj => "error" in obj, get: obj => obj.error, set: (obj, value) => { obj.error = value; } }, metadata: _metadata }, _error_initializers, _error_extraInitializers);
            __esDecorate(this, null, _title_decorators, { kind: "accessor", name: "title", static: false, private: false, access: { has: obj => "title" in obj, get: obj => obj.title, set: (obj, value) => { obj.title = value; } }, metadata: _metadata }, _title_initializers, _title_extraInitializers);
            __esDecorate(this, null, _subtitle_decorators, { kind: "accessor", name: "subtitle", static: false, private: false, access: { has: obj => "subtitle" in obj, get: obj => obj.subtitle, set: (obj, value) => { obj.subtitle = value; } }, metadata: _metadata }, _subtitle_initializers, _subtitle_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            SzLoginView = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        static demo = () => html `
    <div style="height: 600px; display: flex; align-items: center; justify-content: center; background: #09090b;">
      <sz-login-view></sz-login-view>
    </div>
  `;
        #loading_accessor_storage = __runInitializers(this, _loading_initializers, false);
        get loading() { return this.#loading_accessor_storage; }
        set loading(value) { this.#loading_accessor_storage = value; }
        #error_accessor_storage = (__runInitializers(this, _loading_extraInitializers), __runInitializers(this, _error_initializers, ''));
        get error() { return this.#error_accessor_storage; }
        set error(value) { this.#error_accessor_storage = value; }
        #title_accessor_storage = (__runInitializers(this, _error_extraInitializers), __runInitializers(this, _title_initializers, 'serve.zone'));
        get title() { return this.#title_accessor_storage; }
        set title(value) { this.#title_accessor_storage = value; }
        #subtitle_accessor_storage = (__runInitializers(this, _title_extraInitializers), __runInitializers(this, _subtitle_initializers, 'Sign in to your onebox'));
        get subtitle() { return this.#subtitle_accessor_storage; }
        set subtitle(value) { this.#subtitle_accessor_storage = value; }
        static styles = [
            cssManager.defaultStyles,
            css `
      :host {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        width: 100%;
        background: ${cssManager.bdTheme('#f4f4f5', '#09090b')};
      }

      .login-container {
        width: 100%;
        max-width: 400px;
        padding: 24px;
      }

      .login-card {
        background: ${cssManager.bdTheme('#ffffff', '#18181b')};
        border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')};
        border-radius: 12px;
        padding: 32px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
      }

      .logo-section {
        text-align: center;
        margin-bottom: 32px;
      }

      .logo {
        width: 64px;
        height: 64px;
        background: ${cssManager.bdTheme('#18181b', '#fafafa')};
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 16px;
      }

      .logo svg {
        width: 36px;
        height: 36px;
        color: ${cssManager.bdTheme('#fafafa', '#18181b')};
      }

      .title {
        font-size: 24px;
        font-weight: 700;
        color: ${cssManager.bdTheme('#18181b', '#fafafa')};
        margin-bottom: 4px;
      }

      .subtitle {
        font-size: 14px;
        color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
      }

      .form {
        display: flex;
        flex-direction: column;
        gap: 20px;
      }

      .form-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
      }

      .form-label {
        font-size: 14px;
        font-weight: 500;
        color: ${cssManager.bdTheme('#18181b', '#fafafa')};
      }

      .form-input {
        width: 100%;
        padding: 12px 14px;
        background: ${cssManager.bdTheme('#ffffff', '#09090b')};
        border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')};
        border-radius: 8px;
        font-size: 14px;
        color: ${cssManager.bdTheme('#18181b', '#fafafa')};
        outline: none;
        transition: border-color 200ms ease, box-shadow 200ms ease;
        box-sizing: border-box;
      }

      .form-input:focus {
        border-color: ${cssManager.bdTheme('#3b82f6', '#60a5fa')};
        box-shadow: 0 0 0 3px ${cssManager.bdTheme('rgba(59, 130, 246, 0.1)', 'rgba(96, 165, 250, 0.1)')};
      }

      .form-input::placeholder {
        color: ${cssManager.bdTheme('#a1a1aa', '#52525b')};
      }

      .form-input.error {
        border-color: ${cssManager.bdTheme('#ef4444', '#f87171')};
      }

      .error-message {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 14px;
        background: ${cssManager.bdTheme('#fef2f2', 'rgba(239, 68, 68, 0.1)')};
        border: 1px solid ${cssManager.bdTheme('#fecaca', 'rgba(239, 68, 68, 0.2)')};
        border-radius: 8px;
        font-size: 14px;
        color: ${cssManager.bdTheme('#dc2626', '#f87171')};
      }

      .error-message svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
      }

      .submit-button {
        width: 100%;
        padding: 12px 20px;
        background: ${cssManager.bdTheme('#18181b', '#fafafa')};
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 600;
        color: ${cssManager.bdTheme('#fafafa', '#18181b')};
        cursor: pointer;
        transition: opacity 200ms ease, transform 200ms ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
      }

      .submit-button:hover:not(:disabled) {
        opacity: 0.9;
      }

      .submit-button:active:not(:disabled) {
        transform: scale(0.98);
      }

      .submit-button:disabled {
        opacity: 0.6;
        cursor: not-allowed;
      }

      .spinner {
        width: 18px;
        height: 18px;
        border: 2px solid transparent;
        border-top-color: currentColor;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
      }

      @keyframes spin {
        to {
          transform: rotate(360deg);
        }
      }

      .footer {
        margin-top: 24px;
        text-align: center;
        font-size: 13px;
        color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
      }

      .footer a {
        color: ${cssManager.bdTheme('#3b82f6', '#60a5fa')};
        text-decoration: none;
      }

      .footer a:hover {
        text-decoration: underline;
      }
    `,
        ];
        render() {
            return html `
      <div class="login-container">
        <div class="login-card">
          <div class="logo-section">
            <div class="logo">
              <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
                <polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
                <line x1="12" y1="22.08" x2="12" y2="12"></line>
              </svg>
            </div>
            <div class="title">${this.title}</div>
            <div class="subtitle">${this.subtitle}</div>
          </div>

          <form class="form" @submit=${this.handleSubmit}>
            ${this.error ? html `
              <div class="error-message">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                  <circle cx="12" cy="12" r="10"></circle>
                  <line x1="12" y1="8" x2="12" y2="12"></line>
                  <line x1="12" y1="16" x2="12.01" y2="16"></line>
                </svg>
                ${this.error}
              </div>
            ` : ''}

            <div class="form-group">
              <label class="form-label" for="username">Username</label>
              <input
                type="text"
                id="username"
                class="form-input ${this.error ? 'error' : ''}"
                placeholder="Enter your username"
                autocomplete="username"
                ?disabled=${this.loading}
                required
              >
            </div>

            <div class="form-group">
              <label class="form-label" for="password">Password</label>
              <input
                type="password"
                id="password"
                class="form-input ${this.error ? 'error' : ''}"
                placeholder="Enter your password"
                autocomplete="current-password"
                ?disabled=${this.loading}
                required
              >
            </div>

            <button type="submit" class="submit-button" ?disabled=${this.loading}>
              ${this.loading ? html `
                <div class="spinner"></div>
                Signing in...
              ` : 'Sign in'}
            </button>
          </form>

          <div class="footer">
            Powered by <a href="https://serve.zone" target="_blank">serve.zone</a>
          </div>
        </div>
      </div>
    `;
        }
        handleSubmit(e) {
            e.preventDefault();
            const usernameInput = this.shadowRoot?.getElementById('username');
            const passwordInput = this.shadowRoot?.getElementById('password');
            if (!usernameInput || !passwordInput)
                return;
            const username = usernameInput.value.trim();
            const password = passwordInput.value;
            if (!username || !password) {
                this.error = 'Please enter both username and password';
                return;
            }
            this.error = '';
            this.dispatchEvent(new CustomEvent('login', {
                detail: { username, password },
                bubbles: true,
                composed: true,
            }));
        }
        clearForm() {
            const usernameInput = this.shadowRoot?.getElementById('username');
            const passwordInput = this.shadowRoot?.getElementById('password');
            if (usernameInput)
                usernameInput.value = '';
            if (passwordInput)
                passwordInput.value = '';
            this.error = '';
        }
        focusUsername() {
            const usernameInput = this.shadowRoot?.getElementById('username');
            if (usernameInput)
                usernameInput.focus();
        }
        constructor() {
            super(...arguments);
            __runInitializers(this, _subtitle_extraInitializers);
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return SzLoginView = _classThis;
})();
export { SzLoginView };
//# sourceMappingURL=data:application/json;base64, 