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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class CustomSolarIntegratorForm extends HTMLElement {
  constructor() {
    super();
    this.currentStep = 1;
    this.totalSteps = 3;
    this.formData = {
      company_id: '',
      integrator_type: 'RESIDENTIAL_INSTALLER',
      certification_level: 'LEVEL_1',
      license_number: '',
      license_expiry_date: '',
      years_of_experience: 0,
      completed_projects: 0,
      warranty_offered: '',
      insurance_coverage: '',
      specialization: [],
      coverage_area: [],
      certifications: [],
      equipment_brands: [],
      minimum_project_size: '',
      maximum_project_size: '',
      installation_time_frame: '',
      warranty_period: 10,
      maintenance_services: false,
      emergency_support: false,
      design_services: false,
      project_management: false,
    };
  }

  connectedCallback() {
    this.attachShadow({ mode: 'open' });
    this.render();
  }

  handleInputChange(e) {
    const { name, value, type, checked } = e.target;
    if (type === 'checkbox') {
      this.formData[name] = checked;
    } else {
      this.formData[name] = value;
    }
    this.render();
  }

  handleArrayChange(name, value) {
    const currentArray = this.formData[name];
    const newArray = currentArray.includes(value)
      ? currentArray.filter(item => item !== value)
      : [...currentArray, value];
    this.formData[name] = newArray;
    this.render();
  }

  nextStep() {
    if (this.currentStep < this.totalSteps) {
      this.currentStep++;
      this.render();
    }
  }

  prevStep() {
    if (this.currentStep > 1) {
      this.currentStep--;
      this.render();
    }
  }

  renderStep1() {
    return `
      <div class="space-y-4">
        <h3 class="text-lg font-semibold">Informações Básicas</h3>
        
        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
          <div>
            <label class="text-sm font-medium text-gray-700">Tipo de Integrador *</label>
            <select
              name="integrator_type"
              value="${this.formData.integrator_type}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            >
              <option value="RESIDENTIAL_INSTALLER">Instalador Residencial</option>
              <option value="COMMERCIAL_INSTALLER">Instalador Comercial</option>
              <option value="UTILITY_INSTALLER">Instalador de Utilidade</option>
              <option value="DESIGNER">Designer</option>
              <option value="DISTRIBUTOR">Distribuidor</option>
            </select>
          </div>

          <div>
            <label class="text-sm font-medium text-gray-700">Nível de Certificação</label>
            <select
              name="certification_level"
              value="${this.formData.certification_level}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            >
              <option value="LEVEL_1">Nível 1</option>
              <option value="LEVEL_2">Nível 2</option>
              <option value="LEVEL_3">Nível 3</option>
              <option value="MASTER">Master</option>
            </select>
          </div>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
          <div>
            <label class="text-sm font-medium text-gray-700">Número da Licença</label>
            <input
              type="text"
              name="license_number"
              value="${this.formData.license_number}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            />
          </div>

          <div>
            <label class="text-sm font-medium text-gray-700">Data de Expiração da Licença</label>
            <input
              type="date"
              name="license_expiry_date"
              value="${this.formData.license_expiry_date}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            />
          </div>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
          <div>
            <label class="text-sm font-medium text-gray-700">Anos de Experiência</label>
            <input
              type="number"
              name="years_of_experience"
              value="${this.formData.years_of_experience}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            />
          </div>

          <div>
            <label class="text-sm font-medium text-gray-700">Projetos Completados</label>
            <input
              type="number"
              name="completed_projects"
              value="${this.formData.completed_projects}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            />
          </div>

          <div>
            <label class="text-sm font-medium text-gray-700">Período de Garantia (anos)</label>
            <input
              type="number"
              name="warranty_period"
              value="${this.formData.warranty_period}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            />
          </div>
        </div>
      </div>
    `;
  }

  renderStep2() {
    return `
      <div class="space-y-4">
        <h3 class="text-lg font-semibold">Serviços e Capabilities</h3>
        
        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
          <div>
            <label class="text-sm font-medium text-gray-700">Áreas de Especialização</label>
            <div class="mt-1 space-y-2">
              ${['roof_mount', 'ground_mount', 'tracking_systems', 'commercial', 'residential'].map(spec => `
                <div key="${spec}" class="flex items-center">
                  <input
                    id="spec-${spec}"
                    name="specialization"
                    type="checkbox"
                    ${this.formData.specialization.includes(spec) ? 'checked' : ''}
                    onchange="this.getRootNode().host.handleArrayChange('specialization', '${spec}')"
                    class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
                  />
                  <label for="spec-${spec}" class="ml-2 block text-sm text-gray-900 capitalize">
                    ${spec.replace('_', ' ')}
                  </label>
                </div>
              `).join('')}
            </div>
          </div>

          <div>
            <label class="text-sm font-medium text-gray-700">Marcas de Equipamentos</label>
            <textarea
              name="equipment_brands"
              value="${this.formData.equipment_brands.join(', ')}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              placeholder="Digite marcas separadas por vírgula"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            ></textarea>
          </div>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
          <div>
            <label class="text-sm font-medium text-gray-700">Tamanho Mínimo do Projeto</label>
            <input
              type="text"
              name="minimum_project_size"
              value="${this.formData.minimum_project_size}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              placeholder="ex: 5kW"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            />
          </div>

          <div>
            <label class="text-sm font-medium text-gray-700">Tamanho Máximo do Projeto</label>
            <input
              type="text"
              name="maximum_project_size"
              value="${this.formData.maximum_project_size}"
              onchange="this.getRootNode().host.handleInputChange(event)"
              placeholder="ex: 1MW"
              class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
            />
          </div>
        </div>

        <div>
          <label class="text-sm font-medium text-gray-700">Prazo de Instalação</label>
          <input
            type="text"
            name="installation_time_frame"
            value="${this.formData.installation_time_frame}"
            onchange="this.getRootNode().host.handleInputChange(event)"
            placeholder="ex: 4-6 semanas"
            class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
          />
        </div>

        <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
          <div class="flex items-center">
            <input
              id="maintenance_services"
              name="maintenance_services"
              type="checkbox"
              ${this.formData.maintenance_services ? 'checked' : ''}
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
            />
            <label for="maintenance_services" class="ml-2 block text-sm text-gray-900">
              Serviços de Manutenção
            </label>
          </div>

          <div class="flex items-center">
            <input
              id="emergency_support"
              name="emergency_support"
              type="checkbox"
              ${this.formData.emergency_support ? 'checked' : ''}
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
            />
            <label for="emergency_support" class="ml-2 block text-sm text-gray-900">
              Suporte de Emergência
            </label>
          </div>

          <div class="flex items-center">
            <input
              id="design_services"
              name="design_services"
              type="checkbox"
              ${this.formData.design_services ? 'checked' : ''}
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
            />
            <label for="design_services" class="ml-2 block text-sm text-gray-900">
              Serviços de Design
            </label>
          </div>

          <div class="flex items-center">
            <input
              id="project_management"
              name="project_management"
              type="checkbox"
              ${this.formData.project_management ? 'checked' : ''}
              onchange="this.getRootNode().host.handleInputChange(event)"
              class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
            />
            <label for="project_management" class="ml-2 block text-sm text-gray-900">
              Gerenciamento de Projetos
            </label>
          </div>
        </div>
      </div>
    `;
  }

  renderStep3() {
    return `
      <div class="space-y-4">
        <h3 class="text-lg font-semibold">Cobertura e Certificações</h3>
        
        <div>
          <label class="text-sm font-medium text-gray-700">Áreas de Cobertura</label>
          <textarea
            name="coverage_area"
            value="${this.formData.coverage_area.join(', ')}"
            onchange="this.getRootNode().host.handleInputChange(event)"
            placeholder="Digite áreas separadas por vírgula, ex: São Paulo, Rio de Janeiro"
            class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
          ></textarea>
        </div>

        <div>
          <label class="text-sm font-medium text-gray-700">Certificações</label>
          <textarea
            name="certifications"
            value="${this.formData.certifications.join(', ')}"
            onchange="this.getRootNode().host.handleInputChange(event)"
            placeholder="Digite certificações separadas por vírgula, ex: NABCEP, UL, CSA"
            class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
          ></textarea>
        </div>

        <div>
          <label class="text-sm font-medium text-gray-700">Cobertura de Seguro</label>
          <input
            type="text"
            name="insurance_coverage"
            value="${this.formData.insurance_coverage}"
            onchange="this.getRootNode().host.handleInputChange(event)"
            placeholder="ex: 500k de responsabilidade civil"
            class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
          />
        </div>

        <div>
          <label class="text-sm font-medium text-gray-700">Garantia Oferecida</label>
          <input
            type="text"
            name="warranty_offered"
            value="${this.formData.warranty_offered}"
            onchange="this.getRootNode().host.handleInputChange(event)"
            placeholder="ex: 20 anos"
            class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
          />
        </div>
      </div>
    `;
  }

  render() {
    this.shadowRoot.innerHTML = `
      <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
        
        :host {
          display: block;
          font-family: 'Inter', sans-serif;
        }
        
        .space-y-4 > * + * {
          margin-top: 1rem;
        }
        
        .space-y-6 > * + * {
          margin-top: 1.5rem;
        }
        
        .grid {
          display: grid;
        }
        
        .gap-4 {
          gap: 1rem;
        }
        
        .rounded-md {
          border-radius: 0.375rem;
        }
        
        .border-gray-300 {
          border-color: #d1d5db;
        }
        
        .focus\\:border-indigo-500:focus {
          border-color: #6366f1;
        }
        
        .focus\\:ring-indigo-500:focus {
          --tw-ring-color: #6366f1;
        }
        
        .shadow-sm {
          box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        }
        
        .text-sm {
          font-size: 0.875rem;
          line-height: 1.25rem;
        }
        
        .text-lg {
          font-size: 1.125rem;
          line-height: 1.75rem;
        }
        
        .text-xl {
          font-size: 1.25rem;
          line-height: 1.75rem;
        }
        
        .font-semibold {
          font-weight: 600;
        }
        
        .font-bold {
          font-weight: 700;
        }
        
        .text-gray-700 {
          color: #374151;
        }
        
        .text-gray-900 {
          color: #111827;
        }
        
        .text-gray-500 {
          color: #6b7280;
        }
        
        .text-indigo-600 {
          color: #4f46e5;
        }
        
        .bg-gray-200 {
          background-color: #e5e7eb;
        }
        
        .bg-blue-600 {
          background-color: #2563eb;
        }
        
        .h-2\\.5 {
          height: 0.625rem;
        }
        
        .rounded-full {
          border-radius: 9999px;
        }
        
        .transition-all {
          transition-property: all;
        }
        
        .duration-300 {
          transition-duration: 300ms;
        }
        
        .w-full {
          width: 100%;
        }
        
        .block {
          display: block;
        }
        
        .flex {
          display: flex;
        }
        
        .items-center {
          align-items: center;
        }
        
        .justify-between {
          justify-content: space-between;
        }
        
        .mt-1 {
          margin-top: 0.25rem;
        }
        
        .mb-4 {
          margin-bottom: 1rem;
        }
        
        .mb-6 {
          margin-bottom: 1.5rem;
        }
        
        .ml-2 {
          margin-left: 0.5rem;
        }
        
        .pt-4 {
          padding-top: 1rem;
        }
        
        .p-6 {
          padding: 1.5rem;
        }
        
        .p-8 {
          padding: 2rem;
        }
        
        .space-x-3 > * + * {
          margin-left: 0.75rem;
        }
        
        @media (min-width: 768px) {
          .md\\:grid-cols-2 {
            grid-template-columns: repeat(2, minmax(0, 1fr));
          }
          
          .md\\:grid-cols-3 {
            grid-template-columns: repeat(3, minmax(0, 1fr));
          }
          
          .md\\:grid-cols-4 {
            grid-template-columns: repeat(4, minmax(0, 1fr));
          }
        }
      </style>
      
      <form class="space-y-6">
        <div class="mb-6">
          <div class="flex items-center justify-between mb-4">
            <h2 class="text-xl font-bold">Registro de Integrador Solar</h2>
            <div class="text-sm text-gray-500">
              Passo ${this.currentStep} de ${this.totalSteps}
            </div>
          </div>
          
          <div class="w-full bg-gray-200 rounded-full h-2.5">
            <div 
              class="bg-blue-600 h-2.5 rounded-full transition-all duration-300" 
              style="width: ${(this.currentStep / this.totalSteps) * 100}%"
            ></div>
          </div>
        </div>

        ${this.currentStep === 1 ? this.renderStep1() : ''}
        ${this.currentStep === 2 ? this.renderStep2() : ''}
        ${this.currentStep === 3 ? this.renderStep3() : ''}

        <div class="flex justify-between pt-4">
          <div>
            ${this.currentStep > 1 ? `
              <button
                type="button"
                onclick="this.getRootNode().host.prevStep()"
                class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
              >
                Voltar
              </button>
            ` : ''}
          </div>
          
          <div class="flex space-x-3">
            ${this.currentStep < this.totalSteps ? `
              <button
                type="button"
                onclick="this.getRootNode().host.nextStep()"
                class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
              >
                Próximo
              </button>
            ` : `
              <button
                type="button"
                onclick="this.getRootNode().host.dispatchEvent(new CustomEvent('cancel'))"
                class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
              >
                Cancelar
              </button>
              <button
                type="button"
                onclick="this.getRootNode().host.dispatchEvent(new CustomEvent('submit', { detail: this.getRootNode().host.formData }))"
                class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
              >
                Cadastrar
              </button>
            `}
          </div>
        </div>
      </form>
    `;
  }
}

customElements.define('custom-solar-integrator-form', CustomSolarIntegratorForm);