{"id":23940,"date":"2025-08-28T16:17:13","date_gmt":"2025-08-28T14:17:13","guid":{"rendered":"https:\/\/telemedi.com\/?page_id=23940"},"modified":"2026-01-07T16:59:59","modified_gmt":"2026-01-07T15:59:59","slug":"formularz-sprawa-assistance","status":"publish","type":"page","link":"https:\/\/telemedi.com\/pl\/formularz-sprawa-assistance\/","title":{"rendered":"Sprawa Assistance &#8211; Formularz"},"content":{"rendered":"\n<div class=\"bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen py-8\">\n<div class=\"container mx-auto px-4\">\n\n    <!-- Komunikat dla wy\u0142\u0105czonego JavaScript -->\n    <div class=\"js-disabled-message max-w-2xl mx-auto\">\n        <div class=\"bg-yellow-50 border-l-4 border-yellow-400 p-6 rounded-r-lg shadow-lg\">\n            <div class=\"flex items-center\">\n                <div class=\"flex-shrink-0\">\n                    <svg class=\"h-8 w-8 text-yellow-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                <\/div>\n                <div class=\"ml-4\">\n                    <h3 class=\"text-lg font-medium text-yellow-800\">JavaScript jest wy\u0142\u0105czony<\/h3>\n                    <p class=\"mt-2 text-sm text-yellow-700\">\n                        Ten formularz wymaga w\u0142\u0105czonego JavaScript aby dzia\u0142a\u0107 poprawnie.\n                        Prosz\u0119 w\u0142\u0105czy\u0107 JavaScript w przegl\u0105darce i od\u015bwie\u017cy\u0107 stron\u0119.\n                    <\/p>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Komunikat o brakuj\u0105cych parametrach URL -->\n    <div id=\"missing-params-warning\" class=\"max-w-2xl mx-auto\" style=\"display: none;\">\n        <div class=\"bg-red-50 border-l-4 border-red-400 p-6 rounded-r-lg shadow-lg\">\n            <div class=\"flex items-center\">\n                <div class=\"flex-shrink-0\">\n                    <svg class=\"h-8 w-8 text-red-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                <\/div>\n                <div class=\"ml-4\">\n                    <h3 class=\"text-lg font-medium text-red-800\">Nieprawid\u0142owy dost\u0119p<\/h3>\n                    <p class=\"mt-2 text-sm text-red-700\">\n                        Brak wymaganych parametr\u00f3w w adresie URL. Formularz mo\u017ce by\u0107 dost\u0119pny tylko przez oficjalny link z systemu.\n                    <\/p>\n                    <p class=\"mt-2 text-sm text-red-700\">\n                        Je\u015bli otrzyma\u0142e\u015b link bezpo\u015brednio, sprawd\u017a czy zosta\u0142 skopiowany w ca\u0142o\u015bci.\n                    <\/p>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Loader -->\n    <div id=\"loader\" class=\"max-w-2xl mx-auto text-center\" style=\"display: none;\">\n        <div class=\"bg-white p-8 rounded-lg shadow-lg\">\n            <div class=\"flex flex-col items-center\">\n                <div class=\"animate-spin rounded-full h-12 w-12 border-b-4 border-teal-600 mb-4\"><\/div>\n                <h3 class=\"text-lg font-medium text-gray-800 mb-2\">\u0141adowanie danych&#8230;<\/h3>\n                <p class=\"text-sm text-gray-600\">Pobieramy informacje o Twoim zdarzeniu<\/p>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Komunikat b\u0142\u0119du API -->\n    <div id=\"api-error-message\" class=\"max-w-2xl mx-auto\" style=\"display: none;\">\n        <div class=\"bg-red-50 border-l-4 border-red-400 p-6 rounded-r-lg shadow-lg\">\n            <div class=\"flex items-center\">\n                <div class=\"flex-shrink-0\">\n                    <svg class=\"h-8 w-8 text-red-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                <\/div>\n                <div class=\"ml-4\">\n                    <h3 id=\"api-error-title\" class=\"text-lg font-medium text-red-800\">Wyst\u0105pi\u0142 b\u0142\u0105d<\/h3>\n                    <p id=\"api-error-text\" class=\"mt-2 text-sm text-red-700\"><\/p>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Success Box -->\n    <div id=\"success-box\" class=\"max-w-2xl mx-auto\" style=\"display: none;\">\n        <div class=\"fade-in\">\n            <div class=\"bg-green-50 border-l-4 border-green-400 p-6 rounded-r-lg shadow-lg\">\n                <div class=\"flex items-center\">\n                    <div class=\"flex-shrink-0\">\n                        <svg class=\"h-8 w-8 text-green-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                            <path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clip-rule=\"evenodd\"><\/path>\n                        <\/svg>\n                    <\/div>\n                    <div class=\"ml-4\">\n                        <h3 class=\"text-lg font-medium text-green-800\">Dzi\u0119kujemy za zg\u0142oszenie! Formularz zosta\u0142 pomy\u015blnie przes\u0142any.<\/h3>\n                        <p id=\"success-message-text\" class=\"mt-2 text-sm text-green-700\">\n                            Nasz zesp\u00f3\u0142 skontaktuje si\u0119 z Pa\u0144stwem najszybciej jak to mo\u017cliwe.\n                        <\/p>\n                    <\/div>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Formularz preferencji (widoczny tylko gdy JS jest w\u0142\u0105czony i parametry s\u0105 poprawne) -->\n    <div class=\"form-container max-w-4xl mx-auto\" style=\"display: none;\">\n        <div class=\"fade-in\">\n            <div class=\"text-center mb-8\">\n                <div class=\"mb-6\">\n                    <img decoding=\"async\" src=\"https:\/\/telemedi.com\/wp-content\/themes\/telemedico-home-page\/src\/icons\/telemedi.svg\"\n                         alt=\"Telemedi Logo\"\n                         class=\"mx-auto h-16 w-auto\">\n                <\/div>\n                <h1 id=\"form-title\" class=\"text-3xl font-bold text-gray-800 mb-2\">Sprawa Assistance &#8211; wype\u0142nij formularz<\/h1>\n\n                <!-- Dane o zdarzeniu -->\n                <div id=\"event-info\" class=\"bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6 mt-6\" style=\"display: none;\">\n                    <h3 class=\"text-sm font-medium text-blue-800 mb-2\">Dane o zdarzeniu:<\/h3>\n                    <div id=\"event-details\" class=\"text-sm text-blue-700\">\n                        <!-- Dane b\u0119d\u0105 dodane dynamicznie z JavaScript -->\n                    <\/div>\n                <\/div>\n            <\/div>\n\n            <form id=\"preferencesForm\" method=\"POST\"\n                  class=\"bg-white p-6 rounded-lg shadow-md w-full max-w-4xl mx-auto\"\n                  novalidate>\n\n                <!-- Dane o zdarzeniu -->\n                <div id=\"event-data-section\" class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Dane o zdarzeniu<\/h3>\n                    \n                    <!-- Data zdarzenia - full width -->\n                    <div class=\"mb-4\">\n                        <label for=\"eventDate\" class=\"block text-sm font-medium text-gray-700 mb-1\">Data zdarzenia *<\/label>\n                        <p class=\"text-xs text-gray-600 mb-2\">Wpisz dat\u0119 wyst\u0105pienia zdarzenia ubezpieczeniowego (rozpoznania choroby, wyst\u0105pienia objaw\u00f3w nag\u0142ego zachorowania, urodzenia dziecka, nieszcz\u0119\u015bliwego wypadku lub innych sytuacji obj\u0119tych ubezpieczeniem)<\/p>\n                        <input type=\"date\" id=\"eventDate\" name=\"eventDate\" required max=\"\"\n                               class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                    <\/div>\n                    \n                    <!-- Przyczyna zdarzenia -->\n                    <div class=\"mb-4\">\n                        <label for=\"eventCause\" class=\"block text-sm font-medium text-gray-700 mb-1\">Co by\u0142o przyczyn\u0105 zdarzenia *<\/label>\n                        <select id=\"eventCause\" name=\"eventCause\" required\n                                class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                            <option value=\"\">Wybierz przyczyn\u0119<\/option>\n                            <option value=\"Choroba\">Choroba<\/option>\n                            <option value=\"Wypadek\">Wypadek<\/option>\n                            <option value=\"Inne\">Inne<\/option>\n                        <\/select>\n                    <\/div>\n\n                    <div class=\"mb-4\">\n                        <label for=\"eventDescription\" class=\"block text-sm font-medium text-gray-700 mb-1\">Opis choroby\/wypadku *<\/label>\n                        <p class=\"text-xs text-gray-600 mb-2\">Opisz szczeg\u00f3\u0142owo rodzaj zdarzenia ubezpieczeniowego &#8211; co si\u0119 sta\u0142o i w jakich okoliczno\u015bciach?<\/p>\n                        <textarea id=\"eventDescription\" name=\"eventDescription\" rows=\"3\" required\n                                  placeholder=\"Opisz szczeg\u00f3\u0142owo przebieg zdarzenia...\"\n                                  class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\" maxlength=\"1000\"><\/textarea>\n                        <div class=\"text-xs text-gray-500 mt-1\">\n                            <span id=\"eventDescriptionCounter\">0\/1000<\/span>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Jakie us\u0142ugi chcesz um\u00f3wi\u0107 -->\n                <div id=\"services-section\" class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Jak\u0105\/Jakie us\u0142ugi chcesz um\u00f3wi\u0107?<\/h3>\n                    <div class=\"mb-4\">\n                        <label for=\"services\" class=\"block text-sm font-medium text-gray-700 mb-1\">Opisz jakie us\u0142ugi chcesz um\u00f3wi\u0107 *<\/label>\n                        <p class=\"text-xs text-gray-600 mb-2\">Wpisz rodzaj us\u0142ug, kt\u00f3re chcesz zg\u0142osi\u0107 w zwi\u0105zku ze zdarzeniem w ramach posiadanej polisy (konsultacja lekarska, badania diagnostyczne, fizykoterapia, opieka nad dzieckiem itp.)<\/p>\n                        <textarea id=\"services\" name=\"services\" rows=\"3\" required\n                                  placeholder=\"Opisz szczeg\u00f3\u0142owo jakie us\u0142ugi medyczne chcesz um\u00f3wi\u0107...\"\n                                  class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\" maxlength=\"255\"><\/textarea>\n                        <div class=\"text-xs text-gray-500 mt-1\">\n                            <span id=\"servicesCounter\">0\/255<\/span>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Gdzie i kiedy chcesz t\u0119 us\u0142ug\u0119 -->\n                <div id=\"location-section\" class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Twoje aktualne miejsce pobytu<\/h3>\n                    \n                    <!-- Info box -->\n                    <div class=\"mb-6 bg-blue-50 border border-blue-200 rounded-lg p-4\">\n                        <div class=\"flex items-start\">\n                            <svg class=\"w-5 h-5 text-blue-600 mt-0.5 mr-2 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                                <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clip-rule=\"evenodd\"><\/path>\n                            <\/svg>\n                            <p class=\"text-sm text-blue-800\">Podana miejscowo\u015b\u0107 b\u0119dzie punktem odniesienia do um\u00f3wienia Twojej us\u0142ugi<\/p>\n                        <\/div>\n                    <\/div>\n\n                    <div class=\"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4\">\n                        <div>\n                            <label for=\"city\" class=\"block text-sm font-medium text-gray-700 mb-1\">Miasto *<\/label>\n                            <input type=\"text\" id=\"city\" name=\"city\" required\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                        <div>\n                            <label for=\"postalCode\" class=\"block text-sm font-medium text-gray-700 mb-1\">Kod pocztowy *<\/label>\n                            <input type=\"text\" id=\"postalCode\" name=\"postalCode\" required placeholder=\"XX-XXX\"\n                                   class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\">\n                        <\/div>\n                    <\/div>\n\n                    <!-- Radio buttony w jednej linii -->\n                    <div class=\"mb-6\" style=\"display: none;\">\n                        <div class=\"flex items-center gap-8\">\n                            <div class=\"flex items-center\">\n                                <input type=\"radio\" id=\"hasPreferences\" name=\"appointmentType\" value=\"preferences\"\n                                       class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                <label for=\"hasPreferences\" class=\"ml-2 text-sm text-gray-700\">Mam preferencje<\/label>\n                            <\/div>\n                            <div class=\"flex items-center\">\n                                <input type=\"radio\" id=\"visitDate\" name=\"appointmentType\" value=\"nearest\" checked\n                                       class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300\">\n                                <label for=\"visitDate\" class=\"ml-2 text-sm text-gray-700\">Nie mam preferencji \/ najbli\u017cszy wolny termin<\/label>\n                            <\/div>\n                        <\/div>\n                        \n                        <!-- Ostrze\u017cenie dla preferencji -->\n                        <div id=\"preferencesWarning\" class=\"mt-3 p-3 bg-amber-50 border border-amber-200 rounded-lg\" style=\"display: none;\">\n                            <div class=\"flex items-start\">\n                                <svg class=\"w-4 h-4 text-amber-600 mt-0.5 mr-2 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                                    <path fill-rule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                                <\/svg>\n                                <p class=\"text-sm text-amber-800\">Pami\u0119taj, \u017ce mo\u017ce to wyd\u0142u\u017cy\u0107 proces. Nie gwarantujemy spe\u0142nienia preferencji.<\/p>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n\n                    <div id=\"preferencesSection\" class=\"mb-6\" style=\"display: none;\">\n                        <div class=\"mb-6\">\n                            <label class=\"block text-sm font-medium text-gray-700 mb-3\">Wybierz rodzaje preferencji: *<\/label>\n                            \n                            <!-- Preferencje co do lekarza -->\n                            <div class=\"mb-4\">\n                                <div class=\"flex items-start\">\n                                    <input type=\"checkbox\" id=\"prefDoctor\" name=\"prefDoctor\" \n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                                    <div class=\"ml-3 flex-1\">\n                                        <label for=\"prefDoctor\" class=\"text-sm text-gray-700 font-medium\">Preferencje co do lekarza<\/label>\n                                        <textarea id=\"prefDoctorText\" name=\"prefDoctorText\" rows=\"2\" placeholder=\"Opisz swoje preferencje co do lekarza...\"\n                                                  class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent mt-2\" \n                                                  maxlength=\"500\" disabled><\/textarea>\n                                        <div class=\"text-xs text-gray-500 mt-1\">\n                                            <span id=\"prefDoctorCounter\">0\/500<\/span>\n                                        <\/div>\n                                    <\/div>\n                                <\/div>\n                            <\/div>\n\n                            <!-- Preferencje co do godziny -->\n                            <div class=\"mb-4\">\n                                <div class=\"flex items-start\">\n                                    <input type=\"checkbox\" id=\"prefTime\" name=\"prefTime\" \n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                                    <div class=\"ml-3 flex-1\">\n                                        <label for=\"prefTime\" class=\"text-sm text-gray-700 font-medium\">Preferencje co do godziny<\/label>\n                                        <textarea id=\"prefTimeText\" name=\"prefTimeText\" rows=\"2\" placeholder=\"Opisz swoje preferencje co do godziny...\"\n                                                  class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent mt-2\" \n                                                  maxlength=\"500\" disabled><\/textarea>\n                                        <div class=\"text-xs text-gray-500 mt-1\">\n                                            <span id=\"prefTimeCounter\">0\/500<\/span>\n                                        <\/div>\n                                    <\/div>\n                                <\/div>\n                            <\/div>\n\n                            <!-- Preferencje co do daty -->\n                            <div class=\"mb-4\">\n                                <div class=\"flex items-start\">\n                                    <input type=\"checkbox\" id=\"prefDate\" name=\"prefDate\" \n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                                    <div class=\"ml-3 flex-1\">\n                                        <label for=\"prefDate\" class=\"text-sm text-gray-700 font-medium\">Preferencje co do daty<\/label>\n                                        <textarea id=\"prefDateText\" name=\"prefDateText\" rows=\"2\" placeholder=\"Opisz swoje preferencje co do daty...\"\n                                                  class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent mt-2\" \n                                                  maxlength=\"500\" disabled><\/textarea>\n                                        <div class=\"text-xs text-gray-500 mt-1\">\n                                            <span id=\"prefDateCounter\">0\/500<\/span>\n                                        <\/div>\n                                    <\/div>\n                                <\/div>\n                            <\/div>\n\n                            <!-- Preferencje co do plac\u00f3wki -->\n                            <div class=\"mb-4\">\n                                <div class=\"flex items-start\">\n                                    <input type=\"checkbox\" id=\"prefFacility\" name=\"prefFacility\" \n                                           class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                                    <div class=\"ml-3 flex-1\">\n                                        <label for=\"prefFacility\" class=\"text-sm text-gray-700 font-medium\">Preferencje co do plac\u00f3wki<\/label>\n                                        <textarea id=\"prefFacilityText\" name=\"prefFacilityText\" rows=\"2\" placeholder=\"Opisz swoje preferencje co do plac\u00f3wki...\"\n                                                  class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent mt-2\" \n                                                  maxlength=\"500\" disabled><\/textarea>\n                                        <div class=\"text-xs text-gray-500 mt-1\">\n                                            <span id=\"prefFacilityCounter\">0\/500<\/span>\n                                        <\/div>\n                                    <\/div>\n                                <\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>                \n\n                <!-- Za\u0142\u0105czniki -->\n                <div id=\"attachments-section\" class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Za\u0142\u0105czniki<\/h3>\n                    \n                    <!-- Informacja o wymaganych dokumentach (widoczna tylko dla waiting_for_documentation_again) -->\n                    <div id=\"requested-documents-info\" class=\"mb-6 bg-blue-50 border border-blue-200 rounded-lg p-4\" style=\"display: none;\">\n                        <h4 class=\"text-sm font-medium text-blue-800 mb-2\">Wymagane dokumenty:<\/h4>\n                        <p id=\"requested-documents-text\" class=\"text-sm text-blue-700\">Faktura \/ Skierowanie<\/p>\n                    <\/div>\n\n                    <div class=\"mb-6\">\n                        <h4 class=\"text-md font-semibold text-gray-800 mb-3\">Jakie za\u0142\u0105czniki s\u0105 wymagane?<\/h4>\n                        <div class=\"bg-blue-50 border border-blue-200 rounded-lg p-4\">\n                            <div class=\"text-sm text-blue-800 space-y-2\">\n                                <div><strong>Wizyta lekarska<\/strong> \u2013 dokumentacja medyczna potwierdzaj\u0105ca zdarzenie<\/div>\n                                <div><strong>Rehabilitacja \/ sprz\u0119t rehabilitacyjny<\/strong> \u2013 skierowanie na rehabilitacj\u0119 (rodzaj i liczba zabieg\u00f3w), zalecenie stosowania sprz\u0119tu rehabilitacyjnego, dokumentacja medyczna potwierdzaj\u0105ca zdarzenie ubezpieczeniowe<\/div>\n                                <div><strong>Transport medyczny<\/strong> \u2013 zalecenie transportu medycznego z wyszczeg\u00f3lnion\u0105 pozycj\u0105 poszkodowanego<\/div>\n                                <div><strong>Wizyta piel\u0119gniarki<\/strong> \u2013 zlecenie lekarza prowadz\u0105cego, dokumentacja medyczna potwierdzaj\u0105ca zdarzenie<\/div>\n                                <div><strong>Wizyta po\u0142o\u017cnej<\/strong> \u2013 za\u015bwiadczenie o urodzeniu dziecka<\/div>\n                                <div><strong>Pomoc psychologa<\/strong> \u2013 akt zgonu, akt urodzenia lub dokumentacja medyczna potwierdzaj\u0105ca chorob\u0119<\/div>\n                                <div><strong>Opieka po hospitalizacji \/ pomoc medyczna dla rodzic\u00f3w \/ dostarczenie lek\u00f3w<\/strong> \u2013 dokumentacja potwierdzaj\u0105ca hospitalizacj\u0119 (z oznaczeniem pozycji poszkodowanego)<\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                    \n                    <div class=\"mb-4\">\n                        <label class=\"block text-sm font-medium text-gray-700 mb-2\">Dodaj za\u0142\u0105czniki <span class=\"text-red-500\">*<\/span><\/label>\n                        <div class=\"file-upload-area\" id=\"fileUploadArea\">\n                            <div class=\"mb-4\">\n                                <svg class=\"mx-auto h-12 w-12 text-gray-400\" stroke=\"currentColor\" fill=\"none\" viewBox=\"0 0 48 48\">\n                                    <path d=\"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" \/>\n                                <\/svg>\n                                <div class=\"mt-4\">\n                                    <label class=\"cursor-pointer\">\n                                        <span class=\"mt-2 block text-sm font-medium text-gray-900\">\n                                            Kliknij aby wybra\u0107 pliki\n                                        <\/span>\n                                        <span class=\"mt-1 block text-xs text-gray-500\">\n                                            lub przeci\u0105gnij i upu\u015b\u0107 pliki tutaj\n                                        <\/span>\n                                    <\/label>\n                                    <input id=\"file-upload\" name=\"file-upload\" type=\"file\" class=\"sr-only\" multiple>\n                                <\/div>\n                            <\/div>\n                            <p class=\"text-xs text-gray-500\">\n                                Obs\u0142ugiwane formaty: PDF, JPEG, PNG (maks. 10MB ka\u017cdy plik)\n                            <\/p>\n                        <\/div>\n                        \n                        <!-- Lista dodanych plik\u00f3w -->\n                        <div id=\"fileList\" class=\"file-list mt-4\" style=\"display: none;\">\n                            <h4 class=\"text-sm font-medium text-gray-700 mb-2\">Dodane pliki:<\/h4>\n                            <div id=\"fileItems\">\n                                <!-- Pliki b\u0119d\u0105 dodawane dynamicznie -->\n                            <\/div>\n                        <\/div>\n                        \n                        <!-- Potwierdzenie do\u0142\u0105czenia dokumentacji -->\n                        <div class=\"mt-6\">\n                            <div class=\"flex items-start\">\n                                <input type=\"checkbox\" id=\"documentationConfirm\" name=\"documentationConfirm\" required\n                                       class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                                <label for=\"documentationConfirm\" class=\"ml-3 text-sm text-gray-700\">\n                                    Potwierdzam do\u0142\u0105czenie wymaganej dokumentacji medycznej do formularza <span class=\"text-red-500\">*<\/span>\n                                <\/label>\n                            <\/div>\n                        <\/div>\n                        \n                        <!-- Pole komentarza (widoczne tylko dla waiting_for_documentation_again) -->\n                        <div id=\"comment-section\" class=\"mt-6\" style=\"display: none;\">\n                            <label for=\"comment\" class=\"block text-sm font-medium text-gray-700 mb-1\">Dodatkowy komentarz (opcjonalnie)<\/label>\n                            <p class=\"text-xs text-gray-600 mb-2\">Je\u015bli chcesz przekaza\u0107 nam dodatkowe informacje dotycz\u0105ce przesy\u0142anych dokument\u00f3w<\/p>\n                            <textarea id=\"comment\" name=\"comment\" rows=\"3\"\n                                      placeholder=\"Tw\u00f3j komentarz...\"\n                                      class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\" maxlength=\"1000\"><\/textarea>\n                            <div class=\"text-xs text-gray-500 mt-1\">\n                                <span id=\"commentCounter\">0\/1000<\/span>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Zgody i o\u015bwiadczenia -->\n                <div id=\"consents-section\" class=\"mb-8\">\n                    <h3 class=\"text-lg font-semibold text-gray-800 mb-4 border-b border-teal-500 pb-2\">Zgody i o\u015bwiadczenia<\/h3>\n                    \n                    <div class=\"space-y-4\">\n                        <!-- Zgoda 1 -->\n                        <div class=\"flex items-start\">\n                            <input type=\"checkbox\" id=\"consent1\" name=\"consent1\" required\n                                   class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                            <label for=\"consent1\" class=\"ml-3 text-sm text-gray-700\">\n                                Administratorem Twoich danych osobowych b\u0119dzie Telmedicin sp. z o.o. Twoje dane b\u0119dziemy przetwarza\u0107 w celu obs\u0142ugi zg\u0142oszenia (jako nasz prawnie uzasadniony interes). Szczeg\u00f3\u0142owe informacje o zasadach ochrony Twoich danych osobowych i przys\u0142uguj\u0105cych Ci prawach znajdziesz w naszej <a href=\"https:\/\/telemedi.com\/pl\/privacy-policy\/\" class=\"text-blue-600 hover:text-blue-800 underline\">Polityce Prywatno\u015bci<\/a>. <span class=\"text-red-500\">*<\/span>\n                            <\/label>\n                        <\/div>\n\n                        <!-- Zgoda 2 -->\n                        <div class=\"flex items-start\">\n                            <input type=\"checkbox\" id=\"consent2\" name=\"consent2\" required\n                                   class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                            <label for=\"consent2\" class=\"ml-3 text-sm text-gray-700\">\n                                Upowa\u017cniam Telmedicin sp. z o.o. do dost\u0119pu do dokumentacji medycznej oraz weryfikacji  udost\u0119pnionej dokumentacji z podmiotem kt\u00f3ry j\u0105 wystawi\u0142 w celu weryfikacji zasadno\u015bci realizacji wniosku. <span class=\"text-red-500\">*<\/span>\n                            <\/label>\n                        <\/div>\n\n                        <!-- Zgoda 3 -->\n                        <div class=\"flex items-start\">\n                            <input type=\"checkbox\" id=\"consent3\" name=\"consent3\" required\n                                   class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                            <label for=\"consent3\" class=\"ml-3 text-sm text-gray-700\">\n                                O\u015bwiadczam, \u017ce wszystkie dane zawarte w formularzu s\u0105 zgodne ze stanem faktycznym oraz jestem \u015bwiadomy\/ \u015bwiadoma odpowiedzialno\u015bci za zeznanie nieprawdy lub zatajenie okoliczno\u015bci, mog\u0105cych mie\u0107 wp\u0142yw na proces likwidacyjny <span class=\"text-red-500\">*<\/span>\n                            <\/label>\n                        <\/div>\n\n                        <!-- Zgoda 4 -->\n                        <div class=\"flex items-start\">\n                            <input type=\"checkbox\" id=\"consent4\" name=\"consent4\" required\n                                   class=\"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-1\">\n                            <label for=\"consent4\" class=\"ml-3 text-sm text-gray-700\">\n                                O\u015bwiadczam, \u017ce wyra\u017cam zgod\u0119 na przekazywanie informacji dotycz\u0105cych umowy ubezpieczenia z wykorzystaniem \u015brodk\u00f3w porozumiewania si\u0119 na odleg\u0142o\u015b\u0107 na wskazany przeze mnie w formularzu adres e-mail <span class=\"text-red-500\">*<\/span>\n                            <\/label>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Adnotacja o edytowalno\u015bci preferencji -->\n                <div class=\"mt-6 max-w-4xl mx-auto mb-6\">\n                    <div class=\"bg-amber-50 border-l-4 border-amber-400 p-4 rounded-r-lg shadow-sm\">\n                        <div class=\"flex items-start\">\n                            <div class=\"flex-shrink-0\">\n                                <svg class=\"h-5 w-5 text-amber-400\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                                    <path fill-rule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                                <\/svg>\n                            <\/div>\n                            <div class=\"ml-3\">\n                                <p class=\"text-sm text-amber-700\">\n                                    <strong>Wa\u017cne:<\/strong> Po zapisaniu, nie b\u0119dzie mo\u017cliwo\u015bci ich edycji przez formularz.\n                                    W przypadku potrzeby zmiany zapisanych danych, prosimy o kontakt telefoniczny.\n                                <\/p>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- Przycisk wy\u015blij -->\n                <div class=\"text-center\">\n                    <button type=\"submit\"\n                            class=\"bg-teal-600 hover:bg-teal-700 text-white font-bold py-3 px-8 rounded-lg transition duration-200 ease-in-out transform hover:scale-105\">\n                        Zapisz\n                    <\/button>\n                <\/div>\n            <\/form>\n        <\/div>\n    <\/div>\n<\/div>\n<\/div>\n\n\n\n<script data-cookieconsent=\"ignore\">\n    \/\/ W\u0142\u0105cz JavaScript body class\n    document.body.classList.add('js-enabled');\n\n    \/\/ Konfiguracja API\n    const API_BASE_URL = 'https:\/\/ims-backend.tmdi00.com';\n\n    \/\/ Globalna zmienna do przechowywania danych z API\n    let apiData = null;\n    let selectedFiles = [];\n\n    \/\/ Funkcja do pokazywania\/ukrywania element\u00f3w\n    function showElement(elementId) {\n        const element = document.getElementById(elementId);\n        if (element) element.style.display = 'block';\n    }\n\n    function hideElement(elementId) {\n        const element = document.getElementById(elementId);\n        if (element) element.style.display = 'none';\n    }\n\n    \/\/ Funkcja do pokazywania\/ukrywania element\u00f3w po klasie\n    function showElementByClass(className) {\n        const element = document.querySelector('.' + className);\n        if (element) element.style.display = 'block';\n    }\n\n    function hideElementByClass(className) {\n        const element = document.querySelector('.' + className);\n        if (element) element.style.display = 'none';\n    }\n\n    \/\/ Funkcja do ustawiania tytu\u0142u i tre\u015bci b\u0142\u0119du API\n    function showApiError(errorMessage) {\n        const errorTitle = document.getElementById('api-error-title');\n        const errorText = document.getElementById('api-error-text');\n\n        \/\/ Ustaw odpowiedni tytu\u0142 na podstawie tre\u015bci b\u0142\u0119du\n        if (errorMessage.includes('Preferencje zosta\u0142y ju\u017c uzupe\u0142nione')) {\n            errorTitle.textContent = 'Preferencje zosta\u0142y ju\u017c uzupe\u0142nione';\n        } else {\n            errorTitle.textContent = 'Wyst\u0105pi\u0142 b\u0142\u0105d';\n        }\n\n        errorText.textContent = errorMessage;\n        showElement('api-error-message');\n    }\n\n    \/\/ Funkcja do wywo\u0142ania API\n    async function fetchIssueData(issueId, hash) {\n        try {\n            const response = await fetch(`${API_BASE_URL}\/api\/assistance\/issue?issueId=${encodeURIComponent(issueId)}&hash=${encodeURIComponent(hash)}`);\n\n            if (!response.ok) {\n                const errorData = await response.json();\n                throw new Error(errorData.error || `HTTP ${response.status}`);\n            }\n\n            return await response.json();\n        } catch (error) {\n            throw error;\n        }\n    }\n\n    \/\/ Funkcja do wysy\u0142ania preferencji do API\n    async function updatePreferences(formData) {\n        try {\n            \/\/ Konwertuj dane na FormData\n            const formDataToSend = new FormData();\n            \n            \/\/ Dodaj podstawowe pola\n            Object.keys(formData).forEach(key => {\n                if (key === 'attachments') {\n                    \/\/ Pliki b\u0119d\u0105 dodane osobno\n                    return;\n                }\n                \n                const value = formData[key];\n                if (value !== null && value !== undefined) {\n                    formDataToSend.append(key, value);\n                }\n            });\n            \n            \/\/ Dodaj pliki z selectedFiles\n            if (selectedFiles && selectedFiles.length > 0) {\n                selectedFiles.forEach(file => {\n                    formDataToSend.append('attachments[]', file);\n                });\n            }\n\n            const response = await fetch(`${API_BASE_URL}\/api\/assistance\/issue\/update`, {\n                method: 'POST',\n                body: formDataToSend\n            });\n\n            const responseData = await response.json();\n\n            if (!response.ok || !responseData.successful) {\n                \/\/ Je\u015bli response zawiera b\u0142\u0119dy walidacji\n                if (responseData.errors && Array.isArray(responseData.errors)) {\n                    const error = new Error(responseData.message || 'B\u0142\u0119dy walidacji');\n                    error.validationErrors = responseData.errors;\n                    throw error;\n                } else {\n                    throw new Error(responseData.error || responseData.message || `HTTP ${response.status}`);\n                }\n            }\n\n            return responseData;\n        } catch (error) {\n            throw error;\n        }\n    }\n\n    \/\/ Funkcja do wy\u015bwietlania danych o zdarzeniu\n    function displayEventInfo(eventData) {\n        const eventDetailsContainer = document.getElementById('event-details');\n        const eventInfo = document.getElementById('event-info');\n\n        if (!eventData) {\n            hideElement('event-info');\n            return;\n        }\n\n        \/\/ Wyczy\u015b\u0107 poprzednie dane\n        eventDetailsContainer.innerHTML = '';\n\n        \/\/ Dodaj dane o zdarzeniu\n        if (eventData.eventNumber) {\n            const eventNumber = document.createElement('div');\n            eventNumber.className = 'mb-1';\n            eventNumber.innerHTML = `<strong>Numer zdarzenia:<\/strong> ${eventData.eventNumber}`;\n            eventDetailsContainer.appendChild(eventNumber);\n        }\n\n        if (eventData.eventDate) {\n            const eventDate = document.createElement('div');\n            eventDate.className = 'mb-1';\n            eventDate.innerHTML = `<strong>Data zdarzenia:<\/strong> ${eventData.eventDate}`;\n            eventDetailsContainer.appendChild(eventDate);\n        }\n\n        if (eventData.description) {\n            const eventDescription = document.createElement('div');\n            eventDescription.className = 'mb-1';\n            eventDescription.innerHTML = `<strong>Opis:<\/strong> ${eventData.description}`;\n            eventDetailsContainer.appendChild(eventDescription);\n        }\n\n        showElement('event-info');\n    }\n\n    \/\/ Funkcja do aktualizacji tytu\u0142u formularza na podstawie statusu\n    function updateFormTitle(responseData) {\n        const titleElement = document.getElementById('form-title');\n        if (!titleElement) return;\n\n        \/\/ Sprawd\u017a czy status to \"waiting_for_documentation_again\" lub \"waiting_for_documentation_existing_incident\"\n        if (responseData.status === 'waiting_for_documentation_again') {\n            \/\/ Zmie\u0144 tytu\u0142 dla trybu uzupe\u0142niania dokumentacji\n            if (responseData.issueNumber) {\n                titleElement.textContent = `Uzupe\u0142nienie dokumentacji do sprawy Assistance nr ${responseData.issueNumber}`;\n            }\n            \n            \/\/ Ukryj wszystkie sekcje opr\u00f3cz za\u0142\u0105cznik\u00f3w\n            hideElement('event-data-section');\n            hideElement('services-section');\n            hideElement('location-section');\n            hideElement('consents-section');\n            \n            \/\/ Poka\u017c dodatkowe elementy dla uzupe\u0142niania dokumentacji\n            showElement('comment-section');\n\n            if (responseData.requestedDocuments) {\n                showElement('requested-documents-info');\n\n                const requestedDocsText = document.getElementById('requested-documents-text');\n                if (requestedDocsText) {\n                    const documentsText = responseData.requestedDocuments;\n                    requestedDocsText.textContent = documentsText;\n                }\n            }\n            \n            \/\/ Ustaw wymagane dokumenty\n            const requestedDocsText = document.getElementById('requested-documents-text');\n            if (requestedDocsText) {\n\n                if (responseData.requestedDocuments) {\n                    const documentsText = responseData.requestedDocuments || 'Faktura \/ Skierowanie';\n                    requestedDocsText.textContent = documentsText;\n                }\n            }\n            \n            \/\/ Usu\u0144 wymagalno\u015b\u0107 z ukrytych p\u00f3l\n            removeRequiredFromHiddenFields();\n        } else if (responseData.status === 'waiting_for_documentation_existing_incident') {\n            \/\/ Zmie\u0144 tytu\u0142 dla trybu uzupe\u0142niania dokumentacji\n            hideElement('event-data-section');\n            showElement('requested-documents-info');\n\n            const requestedDocsText = document.getElementById('requested-documents-text');\n            if (requestedDocsText) {\n                const documentsText = responseData.requestedDocuments || 'Faktura \/ Skierowanie';\n                requestedDocsText.textContent = documentsText;\n            }\n\n            if (responseData.issueNumber) {\n                titleElement.textContent = `Sprawa Assistance nr ${responseData.issueNumber} - wype\u0142nij formularz`;\n            }\n        } else {\n            \/\/ Dla wszystkich innych status\u00f3w - domy\u015blny tytu\u0142 z numerem sprawy\n            if (responseData.issueNumber) {\n                titleElement.textContent = `Sprawa Assistance nr ${responseData.issueNumber} - wype\u0142nij formularz`;\n            }\n        }\n    }\n    \n    \/\/ Funkcja do usuwania wymagalno\u015bci z ukrytych p\u00f3l\n    function removeRequiredFromHiddenFields() {\n        const fieldsToMakeOptional = [\n            'eventDate', 'eventCause', 'eventDescription', \n            'services', 'city', 'postalCode', \n            'prefDoctor', 'prefTime', 'prefDate', 'prefFacility',\n            'prefDoctorText', 'prefTimeText', 'prefDateText', 'prefFacilityText',\n            'consent1', 'consent2', 'consent3', 'consent4'\n        ];\n        \n        fieldsToMakeOptional.forEach(fieldId => {\n            const field = document.getElementById(fieldId);\n            if (field) {\n                field.removeAttribute('required');\n            }\n        });\n    }\n\n    \/\/ Funkcje obs\u0142ugi plik\u00f3w\n    function formatFileSize(bytes) {\n        if (bytes === 0) return '0 Bytes';\n        const k = 1024;\n        const sizes = ['Bytes', 'KB', 'MB', 'GB'];\n        const i = Math.floor(Math.log(bytes) \/ Math.log(k));\n        return parseFloat((bytes \/ Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n    }\n\n    function isValidFile(file) {\n        const allowedTypes = [\n            'application\/pdf',\n            'image\/jpeg',\n            'image\/png'\n        ];\n        const maxSize = 10 * 1024 * 1024; \/\/ 10MB\n\n        return allowedTypes.includes(file.type) && file.size <= maxSize;\n    }\n\n    function addFileToList(file) {\n        if (!isValidFile(file)) {\n            alert('Nieprawid\u0142owy typ pliku lub plik jest za du\u017cy. Obs\u0142ugiwane formaty: PDF, JPEG, PNG (maks. 10MB)');\n            return;\n        }\n\n        \/\/ Sprawd\u017a czy plik ju\u017c nie jest dodany\n        if (selectedFiles.some(f => f.name === file.name && f.size === file.size)) {\n            alert('Ten plik zosta\u0142 ju\u017c dodany');\n            return;\n        }\n\n        selectedFiles.push(file);\n        renderFileList();\n        \n        \/\/ Wyczy\u015b\u0107 b\u0142\u0119dy walidacji za\u0142\u0105cznik\u00f3w po dodaniu pliku\n        const uploadArea = document.getElementById('fileUploadArea');\n        if (uploadArea) {\n            const existingError = uploadArea.querySelector('.attachment-error');\n            if (existingError) {\n                existingError.remove();\n            }\n            uploadArea.classList.remove('border-red-400', 'bg-red-50');\n            uploadArea.classList.add('border-gray-300');\n        }\n    }\n\n    function removeFileFromList(index) {\n        selectedFiles.splice(index, 1);\n        renderFileList();\n        \n        \/\/ Je\u015bli usuni\u0119to wszystkie pliki, poka\u017c b\u0142\u0105d walidacji (ale tylko je\u015bli formularz by\u0142 ju\u017c sprawdzany)\n        if (selectedFiles.length === 0) {\n            const uploadArea = document.getElementById('fileUploadArea');\n            if (uploadArea && uploadArea.classList.contains('border-red-400')) {\n                validateAttachments(); \/\/ To poka\u017ce b\u0142\u0105d\n            }\n        }\n    }\n\n    function renderFileList() {\n        const fileList = document.getElementById('fileList');\n        const fileItems = document.getElementById('fileItems');\n\n        if (selectedFiles.length === 0) {\n            hideElement('fileList');\n            return;\n        }\n\n        fileItems.innerHTML = '';\n\n        selectedFiles.forEach((file, index) => {\n            const fileItem = document.createElement('div');\n            fileItem.className = 'file-item';\n            fileItem.innerHTML = `\n                <div class=\"flex items-center\">\n                    <svg class=\"h-5 w-5 text-gray-400 mr-2\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                    <span class=\"text-sm text-gray-700\">${file.name}<\/span>\n                    <span class=\"text-xs text-gray-500 ml-2\">(${formatFileSize(file.size)})<\/span>\n                <\/div>\n                <button type=\"button\" onclick=\"removeFileFromList(${index})\" class=\"text-red-600 hover:text-red-800 text-sm\">\n                    <svg class=\"h-4 w-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                <\/button>\n            `;\n            fileItems.appendChild(fileItem);\n        });\n\n        showElement('fileList');\n    }\n\n    \/\/ G\u0142\u00f3wna funkcja inicjalizuj\u0105ca\n    async function initializeForm() {\n        const urlParams = new URLSearchParams(window.location.search);\n        const issueId = urlParams.get('issueId');\n        const hash = urlParams.get('hash');\n\n        \/\/ Ukryj wszystkie sekcje na pocz\u0105tku\n        hideElement('missing-params-warning');\n        hideElement('loader');\n        hideElement('api-error-message');\n        hideElement('success-box');\n        hideElementByClass('form-container');\n\n        \/\/ Sprawd\u017a parametry URL\n        if (!issueId || !hash) {\n            showElement('missing-params-warning');\n            return;\n        }\n\n        \/\/ Poka\u017c loader\n        showElement('loader');\n\n        try {\n            \/\/ Wywo\u0142aj API\n            apiData = await fetchIssueData(issueId, hash);\n\n            if (apiData.successful && apiData.data) {\n                \/\/ Sukces - poka\u017c formularz\n                displayEventInfo(apiData.data.eventInfo);\n                updateFormTitle(apiData.data);\n            } else {\n                throw new Error('Invalid API response structure');\n            }\n\n            hideElement('loader');\n            showElementByClass('form-container');\n\n        } catch (error) {\n            \/\/ B\u0142\u0105d - poka\u017c komunikat b\u0142\u0119du\n            hideElement('loader');\n            const errorMessage = error.message === 'Failed to fetch'\n                ? 'Wyst\u0105pi\u0142 b\u0142\u0105d podczas pobierania danych z systemu'\n                : error.message;\n\n            showApiError(errorMessage);\n        }\n    }\n\n    \/\/ Wywo\u0142aj inicjalizacj\u0119 przy za\u0142adowaniu strony\n    initializeForm();\n\n\n\n    \/\/ Obs\u0142uga drag & drop oraz wyboru plik\u00f3w\n    const fileUploadArea = document.getElementById('fileUploadArea');\n    const fileInput = document.getElementById('file-upload');\n\n    fileUploadArea.addEventListener('click', function() {\n        fileInput.click();\n    });\n\n    fileInput.addEventListener('change', function(e) {\n        const files = Array.from(e.target.files);\n        files.forEach(file => addFileToList(file));\n        \/\/ Wyczy\u015b\u0107 input aby umo\u017cliwi\u0107 ponowne dodanie tego samego pliku\n        e.target.value = '';\n    });\n\n    \/\/ Drag & Drop functionality\n    fileUploadArea.addEventListener('dragover', function(e) {\n        e.preventDefault();\n        fileUploadArea.classList.add('dragover');\n    });\n\n    fileUploadArea.addEventListener('dragleave', function(e) {\n        e.preventDefault();\n        fileUploadArea.classList.remove('dragover');\n    });\n\n    fileUploadArea.addEventListener('drop', function(e) {\n        e.preventDefault();\n        fileUploadArea.classList.remove('dragover');\n        \n        const files = Array.from(e.dataTransfer.files);\n        files.forEach(file => addFileToList(file));\n    });\n\n    \/\/ System walidacji\n    function showError(fieldId, message) {\n        const field = document.getElementById(fieldId);\n        if (!field) return;\n\n        \/\/ Usu\u0144 poprzednie b\u0142\u0119dy\n        clearError(fieldId);\n\n        \/\/ Dodaj klas\u0119 b\u0142\u0119du do pola\n        field.classList.add('field-error');\n\n        \/\/ Stw\u00f3rz kontener b\u0142\u0119du\n        const errorDiv = document.createElement('div');\n        errorDiv.id = `${fieldId}-error`;\n        errorDiv.className = 'error-message text-red-600 text-sm mt-1 flex items-center';\n        errorDiv.innerHTML = `\n                <svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                    <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                <\/svg>\n                ${message}\n            `;\n\n        \/\/ Sprawd\u017a czy to checkbox (zgody lub potwierdzenie dokumentacji)\n        if (field.type === 'checkbox' && (fieldId.startsWith('consent') || fieldId === 'documentationConfirm')) {\n            \/\/ Dla checkbox\u00f3w ze zgodami, dodaj b\u0142\u0105d pod ca\u0142ym kontenerem zgody\n            const consentContainer = field.parentNode; \/\/ div z \"flex items-start\"\n            const parentContainer = consentContainer.parentNode; \/\/ kontener zg\u00f3d\n            \n            \/\/ Dodaj b\u0142\u0105d po kontenerze zgody, ale przed nast\u0119pnym elementem\n            const nextElement = consentContainer.nextElementSibling;\n            if (nextElement) {\n                parentContainer.insertBefore(errorDiv, nextElement);\n            } else {\n                parentContainer.appendChild(errorDiv);\n            }\n        } else {\n            \/\/ Dla pozosta\u0142ych p\u00f3l, dodaj b\u0142\u0105d po polu jak dotychczas\n            field.parentNode.appendChild(errorDiv);\n        }\n    }\n\n    function clearError(fieldId) {\n        const field = document.getElementById(fieldId);\n        if (field) {\n            field.classList.remove('field-error');\n            const errorDiv = document.getElementById(`${fieldId}-error`);\n            if (errorDiv) {\n                errorDiv.remove();\n            }\n        }\n    }\n\n    function clearAllErrors() {\n        document.querySelectorAll('.field-error').forEach(field => {\n            field.classList.remove('field-error');\n        });\n        document.querySelectorAll('.error-message').forEach(error => {\n            error.remove();\n        });\n        \n        \/\/ Wyczy\u015b\u0107 b\u0142\u0119dy za\u0142\u0105cznik\u00f3w\n        const uploadArea = document.getElementById('fileUploadArea');\n        if (uploadArea) {\n            const existingError = uploadArea.querySelector('.attachment-error');\n            if (existingError) {\n                existingError.remove();\n            }\n            uploadArea.classList.remove('border-red-400', 'bg-red-50');\n            uploadArea.classList.add('border-gray-300');\n        }\n        \n        \/\/ Wyczy\u015b\u0107 b\u0142\u0105d wyboru preferencji\n        const preferencesError = document.getElementById('preferences-selection-error');\n        if (preferencesError) {\n            preferencesError.remove();\n        }\n    }\n\n    function validateRequired(fieldId, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return false;\n\n        const value = field.value.trim();\n        if (!value) {\n            showError(fieldId, `${fieldName} jest wymagane`);\n            return false;\n        }\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateEventDescription(fieldId, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return false;\n\n        const value = field.value.trim();\n        if (!value) {\n            showError(fieldId, `${fieldName} jest wymagane`);\n            return false;\n        }\n        if (value.length < 10) {\n            showError(fieldId, `${fieldName} musi mie\u0107 co najmniej 10 znak\u00f3w`);\n            return false;\n        }\n        if (value.length > 1000) {\n            showError(fieldId, `${fieldName} mo\u017ce mie\u0107 maksymalnie 1000 znak\u00f3w`);\n            return false;\n        }\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateSelect(fieldId, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return false;\n\n        const value = field.value;\n        if (!value || value === '') {\n            showError(fieldId, `${fieldName} jest wymagane`);\n            return false;\n        }\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateCheckbox(fieldId, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return false;\n\n        if (!field.checked) {\n            showError(fieldId, `${fieldName} jest wymagane`);\n            return false;\n        }\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateEventDate(fieldId, fieldName) {\n        const field = document.getElementById(fieldId);\n        if (!field) return false;\n\n        const selectedDate = field.value;\n        if (!selectedDate) {\n            showError(fieldId, `${fieldName} jest wymagane`);\n            return false;\n        }\n\n        const today = new Date();\n        const selected = new Date(selectedDate);\n        \n        \/\/ Ustawiamy godzin\u0119 na p\u00f3\u0142noc aby por\u00f3wna\u0107 tylko daty\n        today.setHours(0, 0, 0, 0);\n        selected.setHours(0, 0, 0, 0);\n\n        if (selected > today) {\n            showError(fieldId, `${fieldName} nie mo\u017ce by\u0107 dat\u0105 przysz\u0142\u0105`);\n            return false;\n        }\n\n        clearError(fieldId);\n        return true;\n    }\n\n    function validateAttachments() {\n        if (selectedFiles.length === 0) {\n            \/\/ Poka\u017c b\u0142\u0105d w obszarze upload\n            const uploadArea = document.getElementById('fileUploadArea');\n            if (uploadArea) {\n                \/\/ Usu\u0144 poprzednie b\u0142\u0119dy\n                const existingError = uploadArea.querySelector('.attachment-error');\n                if (existingError) {\n                    existingError.remove();\n                }\n                \n                \/\/ Dodaj klas\u0119 b\u0142\u0119du\n                uploadArea.classList.add('border-red-400', 'bg-red-50');\n                uploadArea.classList.remove('border-gray-300');\n                \n                \/\/ Stw\u00f3rz komunikat b\u0142\u0119du\n                const errorDiv = document.createElement('div');\n                errorDiv.className = 'attachment-error text-red-600 text-sm mt-2 flex items-center';\n                errorDiv.innerHTML = `\n                    <svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                    Za\u0142\u0105czniki s\u0105 wymagane\n                `;\n                uploadArea.appendChild(errorDiv);\n            }\n            return false;\n        }\n        \n        \/\/ Wyczy\u015b\u0107 b\u0142\u0119dy\n        const uploadArea = document.getElementById('fileUploadArea');\n        if (uploadArea) {\n            const existingError = uploadArea.querySelector('.attachment-error');\n            if (existingError) {\n                existingError.remove();\n            }\n            uploadArea.classList.remove('border-red-400', 'bg-red-50');\n            uploadArea.classList.add('border-gray-300');\n        }\n        \n        return true;\n    }\n\n    function validatePostalCode(fieldId) {\n        const field = document.getElementById(fieldId);\n        if (!field) return true;\n\n        const value = field.value.trim();\n        if (!value) {\n            showError(fieldId, 'Kod pocztowy jest wymagany');\n            return false;\n        }\n\n        if (!\/^\\d{2}-\\d{3}$\/.test(value)) {\n            showError(fieldId, 'Kod pocztowy musi by\u0107 w formacie XX-XXX');\n            return false;\n        }\n\n        clearError(fieldId);\n        return true;\n    }\n\n    \/\/ Walidacja preferencji - sprawdza czy przynajmniej jeden checkbox jest zaznaczony\n    function validatePreferencesSelection() {\n        const selectedAppointmentType = document.querySelector('input[name=\"appointmentType\"]:checked');\n        if (!selectedAppointmentType || selectedAppointmentType.value !== 'preferences') {\n            return true; \/\/ Nie ma preferencji, wi\u0119c walidacja przechodzi\n        }\n\n        const preferenceCheckboxes = ['prefDoctor', 'prefTime', 'prefDate', 'prefFacility'];\n        const hasAnyChecked = preferenceCheckboxes.some(checkboxId => {\n            const checkbox = document.getElementById(checkboxId);\n            return checkbox && checkbox.checked;\n        });\n\n        if (!hasAnyChecked) {\n            \/\/ Poka\u017c b\u0142\u0105d przy sekcji preferencji\n            const preferencesSection = document.getElementById('preferencesSection');\n            if (preferencesSection) {\n                const errorDiv = document.createElement('div');\n                errorDiv.id = 'preferences-selection-error';\n                errorDiv.className = 'error-message text-red-600 text-sm mt-2 flex items-center';\n                errorDiv.innerHTML = `\n                    <svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                        <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                    <\/svg>\n                    Wybierz przynajmniej jeden rodzaj preferencji\n                `;\n                preferencesSection.appendChild(errorDiv);\n            }\n            return false;\n        }\n\n        \/\/ Wyczy\u015b\u0107 b\u0142\u0105d je\u015bli istnieje\n        const existingError = document.getElementById('preferences-selection-error');\n        if (existingError) {\n            existingError.remove();\n        }\n\n        return true;\n    }\n\n    \/\/ Walidacja pojedynczego pola preferencji\n    function validatePreferenceField(checkboxId, textFieldId, fieldName) {\n        const checkbox = document.getElementById(checkboxId);\n        const textField = document.getElementById(textFieldId);\n        \n        if (!checkbox || !textField) return true;\n\n        if (checkbox.checked) {\n            const value = textField.value.trim();\n            if (!value) {\n                showError(textFieldId, 'To pole jest wymagane gdy preferencja jest zaznaczona');\n                return false;\n            }\n            if (value.length > 500) {\n                showError(textFieldId, `${fieldName} mo\u017ce mie\u0107 maksymalnie 500 znak\u00f3w`);\n                return false;\n            }\n        }\n\n        clearError(textFieldId);\n        return true;\n    }\n\n    \/\/ Funkcja do budowania stringa preferencji z zaznaczonych checkbox\u00f3w\n    function buildPreferencesString() {\n        const preferences = [];\n        \n        const preferenceFields = [\n            { checkbox: 'prefDoctor', textField: 'prefDoctorText', label: 'Preferencje co do lekarza' },\n            { checkbox: 'prefTime', textField: 'prefTimeText', label: 'Preferencje co do godziny' },\n            { checkbox: 'prefDate', textField: 'prefDateText', label: 'Preferencje co do daty' },\n            { checkbox: 'prefFacility', textField: 'prefFacilityText', label: 'Preferencje co do plac\u00f3wki' }\n        ];\n\n        preferenceFields.forEach(({ checkbox, textField, label }) => {\n            const checkboxElement = document.getElementById(checkbox);\n            const textFieldElement = document.getElementById(textField);\n            \n            if (checkboxElement && checkboxElement.checked && textFieldElement && textFieldElement.value.trim()) {\n                preferences.push(`${label}: ${textFieldElement.value.trim()}`);\n            }\n        });\n\n        return preferences.join('; ');\n    }\n\n    \/\/ Funkcja do zbierania danych z formularza\n    function collectFormData() {\n        const urlParams = new URLSearchParams(window.location.search);\n        const issueId = urlParams.get('issueId');\n        const hash = urlParams.get('hash');\n\n        \/\/ Sprawd\u017a czy jeste\u015bmy w trybie uzupe\u0142niania dokumentacji (tylko waiting_for_documentation_again)\n        const isDocumentationMode = apiData && apiData.data && apiData.data.status === 'waiting_for_documentation_again';\n        \n        \/\/ Sprawd\u017a czy jeste\u015bmy w trybie existing incident (ukrywamy tylko dane zdarzenia)\n        const isExistingIncidentMode = apiData && apiData.data && apiData.data.status === 'waiting_for_documentation_existing_incident';\n        \n        const formData = {\n            issueId: issueId,\n            hash: hash,\n            attachments: selectedFiles.map(file => ({\n                name: file.name,\n                size: file.size,\n                type: file.type\n            }))\n        };\n        \n        \/\/ Dodaj dane w zale\u017cno\u015bci od trybu\n        if (isDocumentationMode) {\n            \/\/ W trybie uzupe\u0142niania dokumentacji dodaj tylko komentarz je\u015bli zosta\u0142 wype\u0142niony\n            const commentField = document.getElementById('comment');\n            if (commentField && commentField.value.trim()) {\n                formData.comment = commentField.value.trim();\n            }\n        } else if (isExistingIncidentMode) {\n            \/\/ W trybie existing incident - dodaj wszystkie dane opr\u00f3cz danych zdarzenia\n            formData.requestedService = document.getElementById('services').value.trim();\n            formData.preferredLocation = document.getElementById('city').value.trim() + \", \" + document.getElementById('postalCode').value.trim();\n            \n            \/\/ Obs\u0142uga radio button\u00f3w dla typu wizyty\n            const selectedAppointmentType = document.querySelector('input[name=\"appointmentType\"]:checked');\n            if (selectedAppointmentType) {\n                formData.nearestAvailableTerm = selectedAppointmentType.value === 'nearest';\n                formData.preferences = selectedAppointmentType.value === 'preferences' ?\n                    buildPreferencesString() : null;\n            } else {\n                formData.nearestAvailableTerm = true; \/\/ domy\u015blnie najbli\u017cszy termin\n                formData.preferences = null;\n            }\n        } else {\n            \/\/ W normalnym trybie - dodaj wszystkie dane\n            formData.eventDate = document.getElementById('eventDate').value;\n            formData.eventCause = document.getElementById('eventCause').value;\n            formData.eventDescription = document.getElementById('eventDescription').value.trim();\n            formData.requestedService = document.getElementById('services').value.trim();\n            formData.preferredLocation = document.getElementById('city').value.trim() + \", \" + document.getElementById('postalCode').value.trim();\n            \n            \/\/ Obs\u0142uga radio button\u00f3w dla typu wizyty\n            const selectedAppointmentType = document.querySelector('input[name=\"appointmentType\"]:checked');\n            if (selectedAppointmentType) {\n                formData.nearestAvailableTerm = selectedAppointmentType.value === 'nearest';\n                formData.preferences = selectedAppointmentType.value === 'preferences' ?\n                    buildPreferencesString() : null;\n            } else {\n                formData.nearestAvailableTerm = true; \/\/ domy\u015blnie najbli\u017cszy termin\n                formData.preferences = null;\n            }\n        }\n\n        return formData;\n    }\n\n    function validateForm() {\n        let isValid = true;\n        \n        \/\/ Sprawd\u017a czy jeste\u015bmy w trybie uzupe\u0142niania dokumentacji (tylko waiting_for_documentation_again)\n        const isDocumentationMode = apiData && apiData.data && apiData.data.status === 'waiting_for_documentation_again';\n        \n        \/\/ Sprawd\u017a czy jeste\u015bmy w trybie existing incident (ukrywamy tylko dane zdarzenia)\n        const isExistingIncidentMode = apiData && apiData.data && apiData.data.status === 'waiting_for_documentation_existing_incident';\n\n        if (!isDocumentationMode && !isExistingIncidentMode) {\n            \/\/ Walidacja danych o zdarzeniu (tylko w normalnym trybie)\n            if (!validateEventDate('eventDate', 'Data zdarzenia')) isValid = false;\n            if (!validateSelect('eventCause', 'Przyczyna zdarzenia')) isValid = false;\n            if (!validateEventDescription('eventDescription', 'Opis zdarzenia')) isValid = false;\n\n            \/\/ Walidacja us\u0142ug\n            if (!validateRequired('services', 'Opis us\u0142ug')) isValid = false;\n\n            \/\/ Walidacja miasta\n            if (!validateRequired('city', 'Miasto')) isValid = false;\n\n            \/\/ Walidacja kodu pocztowego\n            if (!validatePostalCode('postalCode')) isValid = false;\n\n            \/\/ Walidacja preferencji (tylko je\u015bli \"Mam preferencje\" jest zaznaczone)\n            if (!validatePreferencesSelection()) isValid = false;\n            \n            \/\/ Walidacja poszczeg\u00f3lnych p\u00f3l preferencji\n            if (!validatePreferenceField('prefDoctor', 'prefDoctorText', 'Preferencje co do lekarza')) isValid = false;\n            if (!validatePreferenceField('prefTime', 'prefTimeText', 'Preferencje co do godziny')) isValid = false;\n            if (!validatePreferenceField('prefDate', 'prefDateText', 'Preferencje co do daty')) isValid = false;\n            if (!validatePreferenceField('prefFacility', 'prefFacilityText', 'Preferencje co do plac\u00f3wki')) isValid = false;\n            \n            \/\/ Walidacja zg\u00f3d (tylko w normalnym trybie)\n            if (!validateCheckbox('consent1', 'Zgoda na dost\u0119p do dokumentacji medycznej')) isValid = false;\n            if (!validateCheckbox('consent2', 'Zgoda na przetwarzanie danych osobowych')) isValid = false;\n            if (!validateCheckbox('consent3', 'O\u015bwiadczenie o prawdziwo\u015bci danych')) isValid = false;\n            if (!validateCheckbox('consent4', 'Zgoda na komunikacj\u0119 elektroniczn\u0105')) isValid = false;\n        } else if (isExistingIncidentMode) {\n            \/\/ Tryb existing incident - walidujemy wszystko opr\u00f3cz danych zdarzenia\n            \n            \/\/ Walidacja us\u0142ug\n            if (!validateRequired('services', 'Opis us\u0142ug')) isValid = false;\n\n            \/\/ Walidacja miasta\n            if (!validateRequired('city', 'Miasto')) isValid = false;\n\n            \/\/ Walidacja kodu pocztowego\n            if (!validatePostalCode('postalCode')) isValid = false;\n\n            \/\/ Walidacja preferencji (tylko je\u015bli \"Mam preferencje\" jest zaznaczone)\n            if (!validatePreferencesSelection()) isValid = false;\n            \n            \/\/ Walidacja poszczeg\u00f3lnych p\u00f3l preferencji\n            if (!validatePreferenceField('prefDoctor', 'prefDoctorText', 'Preferencje co do lekarza')) isValid = false;\n            if (!validatePreferenceField('prefTime', 'prefTimeText', 'Preferencje co do godziny')) isValid = false;\n            if (!validatePreferenceField('prefDate', 'prefDateText', 'Preferencje co do daty')) isValid = false;\n            if (!validatePreferenceField('prefFacility', 'prefFacilityText', 'Preferencje co do plac\u00f3wki')) isValid = false;\n            \n            \/\/ Walidacja zg\u00f3d\n            if (!validateCheckbox('consent1', 'Zgoda na dost\u0119p do dokumentacji medycznej')) isValid = false;\n            if (!validateCheckbox('consent2', 'Zgoda na przetwarzanie danych osobowych')) isValid = false;\n            if (!validateCheckbox('consent3', 'O\u015bwiadczenie o prawdziwo\u015bci danych')) isValid = false;\n            if (!validateCheckbox('consent4', 'Zgoda na komunikacj\u0119 elektroniczn\u0105')) isValid = false;\n        }\n\n        \/\/ Walidacja za\u0142\u0105cznik\u00f3w (zawsze wymagana)\n        if (!validateAttachments()) isValid = false;\n        if (!validateCheckbox('documentationConfirm', 'Potwierdzenie do\u0142\u0105czenia dokumentacji')) isValid = false;\n\n        return isValid;\n    }\n\n    \/\/ Walidacja formularza przy submit\n    const form = document.getElementById('preferencesForm');\n\n    if (form) {\n        form.addEventListener('submit', async function(e) {\n            e.preventDefault();\n            clearAllErrors();\n            hideElement('api-error-message'); \/\/ Ukryj poprzednie b\u0142\u0119dy API\n\n            \/\/ Pobierz referencje do przycisku na pocz\u0105tku\n            const submitButton = form.querySelector('button[type=\"submit\"]');\n            const originalButtonText = submitButton.textContent;\n\n            if (!validateForm()) {\n                const firstError = document.querySelector('.field-error, .error-message');\n                if (firstError) {\n                    firstError.scrollIntoView({ behavior: 'smooth', block: 'center' });\n                }\n                return false;\n            }\n\n            \/\/ Je\u015bli walidacja przesz\u0142a, wy\u015blij dane do API\n            try {\n                \/\/ Poka\u017c loader na przycisku\n                submitButton.disabled = true;\n                submitButton.innerHTML = `\n                        <svg class=\"animate-spin -ml-1 mr-3 h-5 w-5 text-white inline\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n                            <circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\"><\/circle>\n                            <path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"><\/path>\n                        <\/svg>\n                        Zapisywanie...\n                    `;\n\n                \/\/ Zbierz dane z formularza\n                const formData = collectFormData();\n\n                \/\/ Wy\u015blij do API\n                const responseData = await updatePreferences(formData);\n\n                \/\/ Sukces - poka\u017c success box i ukryj formularz\n                hideElementByClass('form-container');\n\n                \/\/ Ustaw komunikat z API je\u015bli dost\u0119pny\n                if (responseData.message) {\n                    const successText = document.getElementById('success-message-text');\n                    successText.textContent = 'Nasz zesp\u00f3\u0142 skontaktuje si\u0119 z Pa\u0144stwem najszybciej jak to mo\u017cliwe.';\n                }\n\n                showElement('success-box');\n\n                \/\/ Przewi\u0144 do success box\n                document.getElementById('success-box').scrollIntoView({\n                    behavior: 'smooth',\n                    block: 'center'\n                });\n\n            } catch (error) {\n                \/\/ Przywr\u00f3\u0107 przycisk najpierw\n                submitButton.disabled = false;\n                submitButton.textContent = originalButtonText;\n\n                console.log('Submit error:', error);\n                console.log('Validation errors:', error.validationErrors);\n\n                \/\/ Sprawd\u017a czy to b\u0142\u0105d z walidacj\u0105 p\u00f3l\n                if (error.validationErrors && Array.isArray(error.validationErrors)) {\n                    \/\/ Poka\u017c b\u0142\u0119dy walidacji przy konkretnych polach\n                    let hasFieldErrors = false;\n\n                    error.validationErrors.forEach(validationError => {\n                        console.log('Processing validation error:', validationError);\n                        if (validationError.field && validationError.message) {\n                            \/\/ Mapowanie nazw p\u00f3l z backendu na ID element\u00f3w w formularzu\n                            const fieldMapping = {\n                                'eventDate': 'eventDate',\n                                'eventCause': 'eventCause',\n                                'eventDescription': 'eventDescription',\n                                'services': 'services',\n                                'city': 'city',\n                                'postalCode': 'postalCode',\n                                'preferences': 'preferences',\n                                'prefDoctor': 'prefDoctor',\n                                'prefTime': 'prefTime',\n                                'prefDate': 'prefDate',\n                                'prefFacility': 'prefFacility',\n                                'prefDoctorText': 'prefDoctorText',\n                                'prefTimeText': 'prefTimeText',\n                                'prefDateText': 'prefDateText',\n                                'prefFacilityText': 'prefFacilityText',\n                                'attachments': 'attachments',\n                                'consent1': 'consent1',\n                                'consent2': 'consent2',\n                                'consent3': 'consent3',\n                                'consent4': 'consent4'\n                            };\n\n                            const fieldId = fieldMapping[validationError.field];\n                            console.log('Field mapping:', validationError.field, '->', fieldId);\n                            if (fieldId) {\n                                console.log('Showing error for field:', fieldId, 'Message:', validationError.message);\n                                \n                                \/\/ Specjalne traktowanie dla za\u0142\u0105cznik\u00f3w\n                                if (validationError.field === 'attachments') {\n                                    \/\/ Poka\u017c b\u0142\u0105d w obszarze upload\n                                    const uploadArea = document.getElementById('fileUploadArea');\n                                    if (uploadArea) {\n                                        \/\/ Usu\u0144 poprzednie b\u0142\u0119dy\n                                        const existingError = uploadArea.querySelector('.attachment-error');\n                                        if (existingError) {\n                                            existingError.remove();\n                                        }\n                                        \n                                        \/\/ Dodaj klas\u0119 b\u0142\u0119du\n                                        uploadArea.classList.add('border-red-400', 'bg-red-50');\n                                        uploadArea.classList.remove('border-gray-300');\n                                        \n                                        \/\/ Stw\u00f3rz komunikat b\u0142\u0119du\n                                        const errorDiv = document.createElement('div');\n                                        errorDiv.className = 'attachment-error text-red-600 text-sm mt-2 flex items-center';\n                                        errorDiv.innerHTML = `\n                                            <svg class=\"w-4 h-4 mr-1 flex-shrink-0\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n                                                <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"><\/path>\n                                            <\/svg>\n                                            ${validationError.message}\n                                        `;\n                                        uploadArea.appendChild(errorDiv);\n                                    }\n                                } else {\n                                    showError(fieldId, validationError.message);\n                                }\n                                hasFieldErrors = true;\n                            } else {\n                                console.log('No mapping found for field:', validationError.field);\n                            }\n                        }\n                    });\n\n                    if (hasFieldErrors) {\n                        \/\/ Przewi\u0144 do pierwszego b\u0142\u0119du\n                        const firstError = document.querySelector('.field-error, .error-message');\n                        if (firstError) {\n                            firstError.scrollIntoView({ behavior: 'smooth', block: 'center' });\n                        }\n                    } else {\n                        \/\/ Je\u015bli nie ma b\u0142\u0119d\u00f3w p\u00f3l, poka\u017c og\u00f3lny b\u0142\u0105d\n                        showApiError('Wyst\u0105pi\u0142y b\u0142\u0119dy walidacji');\n                    }\n                } else {\n                    \/\/ Og\u00f3lny b\u0142\u0105d - poka\u017c komunikat b\u0142\u0119du\n                    const errorMessage = error.message === 'Failed to fetch'\n                        ? 'Wyst\u0105pi\u0142 nieoczekiwany b\u0142\u0105d'\n                        : error.message;\n\n                    showApiError(errorMessage);\n\n                    \/\/ Przewi\u0144 do b\u0142\u0119du\n                    document.getElementById('api-error-message').scrollIntoView({\n                        behavior: 'smooth',\n                        block: 'center'\n                    });\n                }\n            }\n        });\n    }\n\n    \/\/ Walidacja real-time dla kluczowych p\u00f3l\n    ['eventDate', 'eventCause', 'eventDescription', 'services', 'city', 'postalCode'].forEach(fieldId => {\n        const field = document.getElementById(fieldId);\n        if (field) {\n            field.addEventListener('blur', function() {\n                if (this.value.trim()) {\n                    if (fieldId === 'postalCode') {\n                        validatePostalCode(fieldId);\n                    } else if (fieldId === 'eventDescription') {\n                        validateEventDescription(fieldId, 'Opis zdarzenia');\n                    } else {\n                        clearError(fieldId);\n                    }\n                } else if (this.hasAttribute('required')) {\n                    const fieldName = this.previousElementSibling.textContent.replace(' *', '');\n                    showError(fieldId, `${fieldName} jest wymagane`);\n                }\n            });\n        }\n    });\n\n    \/\/ Walidacja real-time dla p\u00f3l preferencji\n    ['prefDoctorText', 'prefTimeText', 'prefDateText', 'prefFacilityText'].forEach(fieldId => {\n        const field = document.getElementById(fieldId);\n        if (field) {\n            field.addEventListener('blur', function() {\n                const checkboxId = fieldId.replace('Text', '');\n                \n                if (this.value.trim()) {\n                    clearError(fieldId);\n                } else {\n                    const checkbox = document.getElementById(checkboxId);\n                    if (checkbox && checkbox.checked) {\n                        showError(fieldId, 'To pole jest wymagane gdy preferencja jest zaznaczona');\n                    }\n                }\n            });\n        }\n    });\n\n    \/\/ Obs\u0142uga pola select dla przyczyny zdarzenia\n    const eventCauseSelect = document.getElementById('eventCause');\n    if (eventCauseSelect) {\n        eventCauseSelect.addEventListener('change', function() {\n            if (this.value) {\n                clearError('eventCause');\n            }\n        });\n    }\n\n    \/\/ Obs\u0142uga radio button\u00f3w dla typu wizyty\n    const appointmentTypeRadios = document.querySelectorAll('input[name=\"appointmentType\"]');\n    appointmentTypeRadios.forEach(radio => {\n        radio.addEventListener('change', function() {\n            const preferencesSection = document.getElementById('preferencesSection');\n            const preferencesWarning = document.getElementById('preferencesWarning');\n\n            if (this.value === 'preferences') {\n                \/\/ Poka\u017c sekcj\u0119 preferencji i ostrze\u017cenie\n                preferencesSection.style.display = 'block';\n                preferencesWarning.style.display = 'block';\n            } else {\n                \/\/ Ukryj sekcj\u0119 preferencji i ostrze\u017cenie\n                preferencesSection.style.display = 'none';\n                preferencesWarning.style.display = 'none';\n                \/\/ Wyczy\u015b\u0107 wszystkie checkboxy i pola tekstowe\n                clearAllPreferences();\n            }\n        });\n    });\n\n    \/\/ Obs\u0142uga checkbox\u00f3w preferencji\n    const preferenceCheckboxes = [\n        { checkbox: 'prefDoctor', textField: 'prefDoctorText' },\n        { checkbox: 'prefTime', textField: 'prefTimeText' },\n        { checkbox: 'prefDate', textField: 'prefDateText' },\n        { checkbox: 'prefFacility', textField: 'prefFacilityText' }\n    ];\n\n    preferenceCheckboxes.forEach(({ checkbox, textField }) => {\n        const checkboxElement = document.getElementById(checkbox);\n        const textFieldElement = document.getElementById(textField);\n        \n        if (checkboxElement && textFieldElement) {\n            checkboxElement.addEventListener('change', function() {\n                if (this.checked) {\n                    \/\/ W\u0142\u0105cz pole tekstowe\n                    textFieldElement.disabled = false;\n                    textFieldElement.classList.remove('disabled-input');\n                } else {\n                    \/\/ Wy\u0142\u0105cz pole tekstowe i wyczy\u015b\u0107 warto\u015b\u0107\n                    textFieldElement.disabled = true;\n                    textFieldElement.classList.add('disabled-input');\n                    textFieldElement.value = '';\n                    \/\/ Wyczy\u015b\u0107 b\u0142\u0119dy walidacji\n                    clearError(textField);\n                    \/\/ Zaktualizuj licznik\n                    const counter = document.getElementById(textField.replace('Text', 'Counter'));\n                    if (counter) counter.textContent = '0\/500';\n                }\n            });\n        }\n    });\n\n    \/\/ Funkcja do czyszczenia wszystkich preferencji\n    function clearAllPreferences() {\n        preferenceCheckboxes.forEach(({ checkbox, textField }) => {\n            const checkboxElement = document.getElementById(checkbox);\n            const textFieldElement = document.getElementById(textField);\n            \n            if (checkboxElement && textFieldElement) {\n                checkboxElement.checked = false;\n                textFieldElement.disabled = true;\n                textFieldElement.classList.add('disabled-input');\n                textFieldElement.value = '';\n                clearError(textField);\n                \n                \/\/ Zaktualizuj licznik\n                const counter = document.getElementById(textField.replace('Text', 'Counter'));\n                if (counter) counter.textContent = '0\/500';\n            }\n        });\n    }\n\n    \/\/ Obs\u0142uga checkbox\u00f3w ze zgodami\n    ['consent1', 'consent2', 'consent3', 'consent4', 'documentationConfirm'].forEach(consentId => {\n        const consentCheckbox = document.getElementById(consentId);\n        if (consentCheckbox) {\n            consentCheckbox.addEventListener('change', function() {\n                if (this.checked) {\n                    clearError(consentId);\n                }\n            });\n        }\n    });\n\n    \/\/ Formatowanie kodu pocztowego\n    document.getElementById('postalCode').addEventListener('input', function() {\n        let value = this.value.replace(\/\\D\/g, ''); \/\/ Usu\u0144 wszystkie nie-cyfry\n        if (value.length >= 2) {\n            value = value.substring(0, 2) + '-' + value.substring(2, 5);\n        }\n        this.value = value;\n    });\n\n    \/\/ Obs\u0142uga licznika znak\u00f3w dla p\u00f3l tekstowych\n    const eventDescriptionField = document.getElementById('eventDescription');\n    const eventDescriptionCounter = document.getElementById('eventDescriptionCounter');\n    const servicesField = document.getElementById('services');\n    const servicesCounter = document.getElementById('servicesCounter');\n    \n    if (eventDescriptionField && eventDescriptionCounter) {\n        \/\/ Funkcja aktualizuj\u0105ca licznik opisu zdarzenia\n        function updateEventDescriptionCounter() {\n            const currentLength = eventDescriptionField.value.length;\n            eventDescriptionCounter.textContent = `${currentLength}\/1000`;\n        }\n        \n        \/\/ Dodaj event listenery\n        eventDescriptionField.addEventListener('input', updateEventDescriptionCounter);\n        eventDescriptionField.addEventListener('paste', function() {\n            \/\/ Ma\u0142e op\u00f3\u017anienie aby przegl\u0105darka mog\u0142a wklei\u0107 tekst\n            setTimeout(updateEventDescriptionCounter, 10);\n        });\n        \n        \/\/ Zaktualizuj licznik przy starcie\n        updateEventDescriptionCounter();\n    }\n    \n    if (servicesField && servicesCounter) {\n        \/\/ Funkcja aktualizuj\u0105ca licznik us\u0142ug\n        function updateServicesCounter() {\n            const currentLength = servicesField.value.length;\n            servicesCounter.textContent = `${currentLength}\/255`;\n        }\n        \n        \/\/ Dodaj event listenery\n        servicesField.addEventListener('input', updateServicesCounter);\n        servicesField.addEventListener('paste', function() {\n            \/\/ Ma\u0142e op\u00f3\u017anienie aby przegl\u0105darka mog\u0142a wklei\u0107 tekst\n            setTimeout(updateServicesCounter, 10);\n        });\n        \n        \/\/ Zaktualizuj licznik przy starcie\n        updateServicesCounter();\n    }\n    \n    \/\/ Obs\u0142uga licznik\u00f3w znak\u00f3w dla nowych p\u00f3l preferencji\n    const preferenceFields = [\n        { field: 'prefDoctorText', counter: 'prefDoctorCounter' },\n        { field: 'prefTimeText', counter: 'prefTimeCounter' },\n        { field: 'prefDateText', counter: 'prefDateCounter' },\n        { field: 'prefFacilityText', counter: 'prefFacilityCounter' }\n    ];\n\n    preferenceFields.forEach(({ field, counter }) => {\n        const fieldElement = document.getElementById(field);\n        const counterElement = document.getElementById(counter);\n        \n        if (fieldElement && counterElement) {\n            \/\/ Funkcja aktualizuj\u0105ca licznik\n            function updateCounter() {\n                const currentLength = fieldElement.value.length;\n                counterElement.textContent = `${currentLength}\/500`;\n            }\n            \n            \/\/ Dodaj event listenery\n            fieldElement.addEventListener('input', updateCounter);\n            fieldElement.addEventListener('paste', function() {\n                \/\/ Ma\u0142e op\u00f3\u017anienie aby przegl\u0105darka mog\u0142a wklei\u0107 tekst\n                setTimeout(updateCounter, 10);\n            });\n            \n            \/\/ Zaktualizuj licznik przy starcie\n            updateCounter();\n        }\n    });\n    \n    \/\/ Obs\u0142uga licznika znak\u00f3w dla komentarza\n    const commentField = document.getElementById('comment');\n    const commentCounter = document.getElementById('commentCounter');\n    \n    if (commentField && commentCounter) {\n        \/\/ Funkcja aktualizuj\u0105ca licznik komentarza\n        function updateCommentCounter() {\n            const currentLength = commentField.value.length;\n            commentCounter.textContent = `${currentLength}\/1000`;\n        }\n        \n        \/\/ Dodaj event listenery\n        commentField.addEventListener('input', updateCommentCounter);\n        commentField.addEventListener('paste', function() {\n            \/\/ Ma\u0142e op\u00f3\u017anienie aby przegl\u0105darka mog\u0142a wklei\u0107 tekst\n            setTimeout(updateCommentCounter, 10);\n        });\n        \n        \/\/ Zaktualizuj licznik przy starcie\n        updateCommentCounter();\n    }\n\n    \/\/ Ustaw maksymaln\u0105 dat\u0119 na dzisiaj dla pola \"Data zdarzenia\"\n    const eventDateField = document.getElementById('eventDate');\n    if (eventDateField) {\n        const today = new Date();\n        const todayString = today.getFullYear() + '-' + \n                           String(today.getMonth() + 1).padStart(2, '0') + '-' + \n                           String(today.getDate()).padStart(2, '0');\n        eventDateField.setAttribute('max', todayString);\n    }\n<\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript jest wy\u0142\u0105czony Ten formularz wymaga w\u0142\u0105czonego JavaScript aby dzia\u0142a\u0107 poprawnie. Prosz\u0119 w\u0142\u0105czy\u0107 JavaScript w przegl\u0105darce i od\u015bwie\u017cy\u0107 stron\u0119. Nieprawid\u0142owy dost\u0119p Brak wymaganych parametr\u00f3w w adresie URL. Formularz mo\u017ce by\u0107 dost\u0119pny tylko przez oficjalny link z systemu. Je\u015bli otrzyma\u0142e\u015b link bezpo\u015brednio, sprawd\u017a czy zosta\u0142 skopiowany w ca\u0142o\u015bci. \u0141adowanie danych&#8230; Pobieramy informacje o Twoim zdarzeniu Wyst\u0105pi\u0142 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-full-width.php","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"class_list":["post-23940","page","type-page","status-publish","hentry"],"acf":[],"lang":"pl","translations":{"pl":23940},"_links":{"self":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages\/23940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/comments?post=23940"}],"version-history":[{"count":5,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages\/23940\/revisions"}],"predecessor-version":[{"id":24578,"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/pages\/23940\/revisions\/24578"}],"wp:attachment":[{"href":"https:\/\/telemedi.com\/tm-api\/wp\/v2\/media?parent=23940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}