class PersonalityBuilder extends HTMLElement { constructor() { super(); this.personalityData = { personalityTraits: [], communicationStyle: '', interests: [], background: '', voiceTone: '', emotionalRange: 50, humorLevel: 50, intelligence: 50 }; this.traits = [ 'Adventurous', 'Ambitious', 'Analytical', 'Artistic', 'Assertive', 'Caring', 'Charismatic', 'Confident', 'Creative', 'Curious', 'Dependable', 'Determined', 'Easygoing', 'Empathetic', 'Enthusiastic', 'Friendly', 'Funny', 'Generous', 'Gentle', 'Honest', 'Humorous', 'Imaginative', 'Independent', 'Intelligent', 'Kind', 'Loyal', 'Optimistic', 'Passionate', 'Patient', 'Perceptive', 'Persistent', 'Practical', 'Rational', 'Reliable', 'Respectful', 'Responsible', 'Sensitive', 'Sincere', 'Thoughtful', 'Witty' ]; this.communicationStyles = [ 'Direct', 'Indirect', 'Formal', 'Casual', 'Humorous', 'Serious', 'Sarcastic', 'Sympathetic', 'Persuasive', 'Inquisitive' ]; this.voiceTones = [ 'Warm', 'Calm', 'Energetic', 'Soft-spoken', 'Authoritative', 'Playful', 'Mysterious', 'Professional', 'Friendly', 'Intense' ]; this.interests = [ 'Art', 'Books', 'Cooking', 'Dancing', 'Fashion', 'Gaming', 'Gardening', 'History', 'Languages', 'Movies', 'Music', 'Nature', 'Photography', 'Politics', 'Science', 'Sports', 'Technology', 'Travel', 'Writing', 'Yoga' ]; } connectedCallback() { this.attachShadow({ mode: 'open' }); this.render(); this.setupEventListeners(); } render() { this.shadowRoot.innerHTML = `
Core Personality Traits
${this.traits.map(trait => `
${trait}
`).join('')}
Communication Style
${this.communicationStyles.map(style => `
${style}
`).join('')}
Voice Tone
${this.voiceTones.map(tone => `
${tone}
`).join('')}
Interests & Hobbies
${this.interests.map(interest => `
${interest}
`).join('')}
Background Story
Emotional Characteristics
Emotional Range ${this.personalityData.emotionalRange}%
Humor Level ${this.personalityData.humorLevel}%
Intelligence ${this.personalityData.intelligence}%
`; } setupEventListeners() { // Trait selection this.shadowRoot.querySelectorAll('.trait-chip[data-trait]').forEach(chip => { chip.addEventListener('click', (e) => { const trait = e.target.dataset.trait; if (this.personalityData.personalityTraits.includes(trait)) { this.personalityData.personalityTraits = this.personalityData.personalityTraits.filter(t => t !== trait); } else { this.personalityData.personalityTraits.push(trait); } this.render(); }); }); // Communication style selection this.shadowRoot.querySelectorAll('.trait-chip[data-style]').forEach(chip => { chip.addEventListener('click', (e) => { const style = e.target.dataset.style; this.personalityData.communicationStyle = style; this.render(); }); }); // Voice tone selection this.shadowRoot.querySelectorAll('.trait-chip[data-tone]').forEach(chip => { chip.addEventListener('click', (e) => { const tone = e.target.dataset.tone; this.personalityData.voiceTone = tone; this.render(); }); }); // Interest selection this.shadowRoot.querySelectorAll('.trait-chip[data-interest]').forEach(chip => { chip.addEventListener('click', (e) => { const interest = e.target.dataset.interest; if (this.personalityData.interests.includes(interest)) { this.personalityData.interests = this.personalityData.interests.filter(i => i !== interest); } else { this.personalityData.interests.push(interest); } this.render(); }); }); // Background input this.shadowRoot.getElementById('background-input').addEventListener('input', (e) => { this.personalityData.background = e.target.value; }); // Slider inputs this.shadowRoot.getElementById('emotional-range').addEventListener('input', (e) => { this.personalityData.emotionalRange = parseInt(e.target.value); this.render(); }); this.shadowRoot.getElementById('humor-level').addEventListener('input', (e) => { this.personalityData.humorLevel = parseInt(e.target.value); this.render(); }); this.shadowRoot.getElementById('intelligence').addEventListener('input', (e) => { this.personalityData.intelligence = parseInt(e.target.value); this.render(); }); // Navigation buttons this.shadowRoot.getElementById('back-step').addEventListener('click', () => { this.dispatchEvent(new CustomEvent('step-change', { detail: { step: 1 } })); }); this.shadowRoot.getElementById('next-step').addEventListener('click', () => { this.dispatchEvent(new CustomEvent('step-change', { detail: { step: 3 } })); }); } } customElements.define('personality-builder', PersonalityBuilder);