{"ast":null,"code":"import { HttpHeaders } from '@angular/common/http';\nimport { environment } from '../environments/environment';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/common/http\";\nimport * as i2 from \"../services/client.service\";\nimport * as i3 from \"@angular/common\";\nimport * as i4 from \"@angular/forms\";\nimport * as i5 from \"../clock/clock.component\";\nconst _c0 = () => ({\n  standalone: true\n});\nfunction AjustePatioComponent_option_6_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"option\", 16);\n    i0.ɵɵtext(1);\n    i0.ɵɵelementEnd();\n  }\n  if (rf & 2) {\n    const ground_r1 = ctx.$implicit;\n    i0.ɵɵproperty(\"ngValue\", ground_r1);\n    i0.ɵɵadvance();\n    i0.ɵɵtextInterpolate(ground_r1.name_ground);\n  }\n}\nfunction AjustePatioComponent_tr_28_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"tr\")(1, \"td\");\n    i0.ɵɵtext(2);\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(3, \"td\");\n    i0.ɵɵtext(4);\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(5, \"td\");\n    i0.ɵɵtext(6);\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(7, \"td\");\n    i0.ɵɵtext(8);\n    i0.ɵɵelementEnd()();\n  }\n  if (rf & 2) {\n    const ground_r2 = ctx.$implicit;\n    i0.ɵɵadvance(2);\n    i0.ɵɵtextInterpolate(ground_r2.name_ground);\n    i0.ɵɵadvance(2);\n    i0.ɵɵtextInterpolate(ground_r2.parking_ground_total);\n    i0.ɵɵadvance(2);\n    i0.ɵɵtextInterpolate(ground_r2.parking_ground_free);\n    i0.ɵɵadvance(2);\n    i0.ɵɵtextInterpolate(ground_r2.parking_ground_busy);\n  }\n}\nexport let AjustePatioComponent = /*#__PURE__*/(() => {\n  class AjustePatioComponent {\n    constructor(http, clientService) {\n      this.http = http;\n      this.clientService = clientService;\n      this.grounds = [];\n      this.selectedGround = {};\n      this.qtyFree = 0;\n      // Novas propriedades para gerenciamento de usuários e clientes\n      this.userName = '';\n      this.userRole = '';\n      this.clients = [];\n      this.selectedClient = '';\n      this.clientLogo = 'assets/img/path-to-client-logo.png';\n      this.clientId_adjustment = 0;\n    }\n    ngOnInit() {\n      // Captura o cliente selecionado assim que o componente é inicializado\n      this.clientService.selectedClient$.subscribe(clientId => {\n        if (clientId) {\n          this.clientId_adjustment = parseInt(clientId, 10);\n          this.getParkingData(this.clientId_adjustment);\n        }\n      });\n      // Caso queira capturar o cliente ao iniciar sem aguardar uma nova seleção\n      const clientId = this.clientService.getSelectedClient();\n      if (clientId) {\n        this.clientId_adjustment = clientId;\n        this.getParkingData(clientId);\n      }\n    }\n    getParkingData(clientId) {\n      const apiUrl = `${environment.apiUrlBackEndExternaCache}/v1/spark-customers/ground/{\"id_customer\":${clientId},\"id_park\":1}`;\n      const headers = new HttpHeaders().set('device', 'manager');\n      this.http.get(apiUrl, {\n        headers\n      }).subscribe(data => {\n        this.grounds = data;\n        if (this.grounds.length > 0) {\n          this.selectedGround = this.grounds[0];\n        }\n      }, error => {\n        console.error('Erro ao buscar dados dos grounds', error);\n      });\n    }\n    /////\n    enviarAjuste(clientId) {\n      const apiUrl = `${environment.apiUrlBackEndExternaApiDB}/v1/update-parking-ground?key=${clientId}-1`;\n      const headers = new HttpHeaders().set('device', 'manager').set('Content-Type', 'application/json');\n      const payload = [{\n        id_ground: this.selectedGround.id_ground,\n        qty_free: this.qtyFree\n      }];\n      this.http.post(apiUrl, payload, {\n        headers\n      }).subscribe(response => {\n        alert('Ajuste de Pátio realizado com sucesso!');\n      }, error => {\n        console.error('Erro ao enviar ajuste de pátio', error);\n      });\n    }\n    static #_ = this.ɵfac = function AjustePatioComponent_Factory(t) {\n      return new (t || AjustePatioComponent)(i0.ɵɵdirectiveInject(i1.HttpClient), i0.ɵɵdirectiveInject(i2.ClientService));\n    };\n    static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: AjustePatioComponent,\n      selectors: [[\"app-ajuste-patio\"]],\n      decls: 38,\n      vars: 9,\n      consts: [[1, \"ajuste-patio-container\"], [1, \"main-content\"], [1, \"form-group\"], [\"for\", \"groundSelect\"], [\"id\", \"groundSelect\", 3, \"ngModelChange\", \"ngModel\", \"ngModelOptions\"], [3, \"ngValue\", 4, \"ngFor\", \"ngForOf\"], [\"for\", \"qtyFree\"], [\"id\", \"qtyFree\", \"type\", \"number\", 3, \"ngModelChange\", \"ngModel\"], [3, \"click\"], [1, \"parking-info\"], [1, \"parking-table\"], [4, \"ngFor\", \"ngForOf\"], [1, \"sidebar-right\"], [1, \"user-info\"], [1, \"user-details\"], [\"alt\", \"Client Logo\", 1, \"client-logo\", 3, \"src\"], [3, \"ngValue\"]],\n      template: function AjustePatioComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          i0.ɵɵelementStart(0, \"div\", 0)(1, \"div\", 1)(2, \"div\", 2)(3, \"label\", 3);\n          i0.ɵɵtext(4, \"Selecionar Ground\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(5, \"select\", 4);\n          i0.ɵɵtwoWayListener(\"ngModelChange\", function AjustePatioComponent_Template_select_ngModelChange_5_listener($event) {\n            i0.ɵɵtwoWayBindingSet(ctx.selectedGround, $event) || (ctx.selectedGround = $event);\n            return $event;\n          });\n          i0.ɵɵtemplate(6, AjustePatioComponent_option_6_Template, 2, 2, \"option\", 5);\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelementStart(7, \"div\", 2)(8, \"label\", 6);\n          i0.ɵɵtext(9, \"Quantidade de Vagas Livres\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(10, \"input\", 7);\n          i0.ɵɵtwoWayListener(\"ngModelChange\", function AjustePatioComponent_Template_input_ngModelChange_10_listener($event) {\n            i0.ɵɵtwoWayBindingSet(ctx.qtyFree, $event) || (ctx.qtyFree = $event);\n            return $event;\n          });\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelementStart(11, \"button\", 8);\n          i0.ɵɵlistener(\"click\", function AjustePatioComponent_Template_button_click_11_listener() {\n            return ctx.enviarAjuste(ctx.clientId_adjustment);\n          });\n          i0.ɵɵtext(12, \"Enviar Ajuste de P\\u00E1tio\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(13, \"div\", 9)(14, \"h1\");\n          i0.ɵɵtext(15, \"Informa\\u00E7\\u00F5es de Estacionamento\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(16, \"table\", 10)(17, \"thead\")(18, \"tr\")(19, \"th\");\n          i0.ɵɵtext(20, \"Andar\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(21, \"th\");\n          i0.ɵɵtext(22, \"Total de Vagas\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(23, \"th\");\n          i0.ɵɵtext(24, \"Vagas Livres\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(25, \"th\");\n          i0.ɵɵtext(26, \"Vagas Ocupadas\");\n          i0.ɵɵelementEnd()()();\n          i0.ɵɵelementStart(27, \"tbody\");\n          i0.ɵɵtemplate(28, AjustePatioComponent_tr_28_Template, 9, 4, \"tr\", 11);\n          i0.ɵɵelementEnd()()()();\n          i0.ɵɵelementStart(29, \"div\", 12)(30, \"div\", 13);\n          i0.ɵɵelement(31, \"app-clock\");\n          i0.ɵɵelementStart(32, \"div\", 14)(33, \"div\");\n          i0.ɵɵtext(34);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(35, \"div\");\n          i0.ɵɵtext(36);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelement(37, \"img\", 15);\n          i0.ɵɵelementEnd()()()();\n        }\n        if (rf & 2) {\n          i0.ɵɵadvance(5);\n          i0.ɵɵtwoWayProperty(\"ngModel\", ctx.selectedGround);\n          i0.ɵɵproperty(\"ngModelOptions\", i0.ɵɵpureFunction0(8, _c0));\n          i0.ɵɵadvance();\n          i0.ɵɵproperty(\"ngForOf\", ctx.grounds);\n          i0.ɵɵadvance(4);\n          i0.ɵɵtwoWayProperty(\"ngModel\", ctx.qtyFree);\n          i0.ɵɵadvance(18);\n          i0.ɵɵproperty(\"ngForOf\", ctx.grounds);\n          i0.ɵɵadvance(6);\n          i0.ɵɵtextInterpolate(ctx.userName);\n          i0.ɵɵadvance(2);\n          i0.ɵɵtextInterpolate(ctx.userRole);\n          i0.ɵɵadvance();\n          i0.ɵɵproperty(\"src\", ctx.clientLogo, i0.ɵɵsanitizeUrl);\n        }\n      },\n      dependencies: [i3.NgForOf, i4.NgSelectOption, i4.ɵNgSelectMultipleOption, i4.DefaultValueAccessor, i4.NumberValueAccessor, i4.SelectControlValueAccessor, i4.NgControlStatus, i4.NgModel, i5.ClockComponent],\n      styles: [\".ajuste-patio-container[_ngcontent-%COMP%]{display:flex;flex-direction:row;justify-content:space-between;padding:20px;font-family:Arial,sans-serif}.main-content[_ngcontent-%COMP%]{flex:2;margin-right:20px;background-color:#f9f9f9;padding:20px;border-radius:10px;box-shadow:0 4px 6px #0000001a}h1[_ngcontent-%COMP%]{color:#333}.form-group[_ngcontent-%COMP%]{margin-bottom:20px}label[_ngcontent-%COMP%]{display:block;font-weight:700;margin-bottom:5px}input[type=number][_ngcontent-%COMP%], select[_ngcontent-%COMP%]{width:100%;padding:8px;margin-bottom:10px;border:1px solid #ccc;border-radius:4px;font-size:16px}button[_ngcontent-%COMP%]{background-color:#4caf50;color:#fff;border:none;padding:10px 20px;cursor:pointer;font-size:16px;border-radius:5px}button[_ngcontent-%COMP%]:hover{background-color:#45a049}table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;margin-top:20px}table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%], table[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]{border:1px solid #ddd;padding:8px;text-align:left}table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]{background-color:#f2f2f2;font-weight:700}.parking-info[_ngcontent-%COMP%]{margin-top:30px}.sidebar-right[_ngcontent-%COMP%]{flex:1;background-color:#fff;padding:20px;border-radius:10px;box-shadow:0 4px 6px #0000001a}.user-info[_ngcontent-%COMP%]{text-align:center}.client-selection[_ngcontent-%COMP%]{margin-bottom:20px}.client-logo[_ngcontent-%COMP%]{width:150px;height:auto;margin-top:20px}.user-details[_ngcontent-%COMP%]{margin-top:20px;font-size:16px}.user-details[_ngcontent-%COMP%]   div[_ngcontent-%COMP%]{margin-bottom:10px;font-weight:700}.client-selection[_ngcontent-%COMP%]   select[_ngcontent-%COMP%]{width:100%;padding:8px;border:1px solid #ccc;border-radius:4px}@media screen and (max-width: 768px){.ajuste-patio-container[_ngcontent-%COMP%]{flex-direction:column;padding:10px}.main-content[_ngcontent-%COMP%]{margin-right:0;margin-bottom:20px}.sidebar-right[_ngcontent-%COMP%]{margin-top:20px;padding:15px}table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%], table[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]{font-size:14px;padding:6px}button[_ngcontent-%COMP%]{padding:8px 16px;font-size:14px}}@media screen and (max-width: 480px){.main-content[_ngcontent-%COMP%], .sidebar-right[_ngcontent-%COMP%]{padding:10px}.form-group[_ngcontent-%COMP%]   label[_ngcontent-%COMP%]{font-size:14px}input[type=number][_ngcontent-%COMP%], select[_ngcontent-%COMP%]{font-size:14px;padding:6px}table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%], table[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]{font-size:12px;padding:4px}button[_ngcontent-%COMP%]{width:100%;padding:10px;font-size:14px}.client-logo[_ngcontent-%COMP%]{width:100px}.user-details[_ngcontent-%COMP%]   div[_ngcontent-%COMP%]{font-size:14px}}\"]\n    });\n  }\n  return AjustePatioComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}