slthcore 0.6.1__tar.gz → 0.6.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of slthcore might be problematic. Click here for more details.
- {slthcore-0.6.1/slthcore.egg-info → slthcore-0.6.2}/PKG-INFO +1 -1
- {slthcore-0.6.1 → slthcore-0.6.2}/setup.py +1 -1
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/auth.py +1 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/forms.py +8 -3
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/management/commands/sync.py +4 -2
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/models.py +15 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/queryset.py +14 -6
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/static/js/slth.min.js +1 -1
- slthcore-0.6.2/slth/storage/__init__.py +99 -0
- slthcore-0.6.2/slth/storage/s3.py +383 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/views.py +7 -2
- {slthcore-0.6.1 → slthcore-0.6.2/slthcore.egg-info}/PKG-INFO +1 -1
- {slthcore-0.6.1 → slthcore-0.6.2}/slthcore.egg-info/SOURCES.txt +2 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/MANIFEST.in +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/setup.cfg +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/application.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/apps.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/configure/__main__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/__main__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/__pycache__/__main__.cpython-312.pyc +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/.DS_Store +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/.gitignore +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/asgi.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/endpoints/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/models.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/settings.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/tests.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/urls.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/api/wsgi.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/entrypoint.sh +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/manage.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/backend/requirements.txt +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/base.env +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/docker-compose.yml +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/frontend/package.json +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/frontend/src/main.jsx +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/frontend/vite.config.js +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/local.env +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/run.sh +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/selenium/run.sh +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/cmd/init/boilerplate/test.sh +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/components.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/db/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/db/generic.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/db/models.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/deletion.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/dev.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/email.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/job.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/log.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/profile.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/pushsubscription.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/report.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/role.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/settings.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/task.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/timezone.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/user.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/endpoints/whatsappnotification.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/exceptions.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/factory.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/geo/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/deepseek/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/google/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/google/gemini.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/google/places.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/google/vision.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/justvoip/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/mercadopago/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/openai/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/openai/chatgpt.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/viacep/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/integrations/whatsapp/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/management/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/management/commands/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/management/commands/api.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/management/commands/integration_test.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/management/commands/worker.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/middleware/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/middleware/timezone.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0001_initial.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0002_email_role_pushsubscription_error.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0003_rename_photo_profile_alter_profile_options.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0004_alter_profile_photo.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0005_alter_profile_photo.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0006_user.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0007_deletion_log.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0008_alter_deletion_datetime_alter_log_datetime.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0009_remove_email_from_email_email_action_email_attempt_and_more.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0010_email_key_alter_email_action_alter_email_attempt_and_more.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0011_usertimezone.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0012_timezone_remove_usertimezone_key_and_more.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0013_whatsappnotification.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0014_settings.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/0015_auto_20250412_1126.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/migrations/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/notifications.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/oauth.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/pdf/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/pdf/tests.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/permissions.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/printer.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/roles.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/selenium/__init__.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/selenium/browser.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/serializer.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/static/.DS_Store +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/static/css/.DS_Store +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/static/css/slth.css +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/static/images/placeholder.png +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/static/js/index.min.js +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/static/js/react.min.js +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/statistics.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/tasks.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/templates/email.html +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/templates/index.html +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/templates/report.html +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/templates/service-worker.js +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/templates/signature.html +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/tests.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/threadlocal.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/timezone.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/urls.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slth/utils.py +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slthcore.egg-info/dependency_links.txt +0 -0
- {slthcore-0.6.1 → slthcore-0.6.2}/slthcore.egg-info/top_level.txt +0 -0
|
@@ -10,6 +10,7 @@ from . import PublicEndpoint, Endpoint, ChildInstanceEndpoint
|
|
|
10
10
|
from django.utils import timezone
|
|
11
11
|
|
|
12
12
|
def login_response(user, redirect='/api/dashboard/'):
|
|
13
|
+
Token.objects.filter(user=user).delete()
|
|
13
14
|
token = Token.objects.create(user=user)
|
|
14
15
|
current_timezone = timezone.get_current_timezone()
|
|
15
16
|
current_timezone_name = current_timezone.__str__()
|
|
@@ -397,9 +397,14 @@ class FormMixin:
|
|
|
397
397
|
self.request, f"choices={fname}"
|
|
398
398
|
))
|
|
399
399
|
if ftype == "boolean":
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
400
|
+
if isinstance(field, NullBooleanField):
|
|
401
|
+
data.update(choices=[
|
|
402
|
+
{"id": "true", "value": "Sim"}, {"id": "false", "value": "Não"}, {"id": "null", "value": "Não Informado"}
|
|
403
|
+
])
|
|
404
|
+
else:
|
|
405
|
+
data.update(choices=[
|
|
406
|
+
{"id": "true", "value": "Sim"}, {"id": "false", "value": "Não"}
|
|
407
|
+
])
|
|
403
408
|
|
|
404
409
|
attr_name = f"on_{prefix}__{name}_change" if prefix else f"on_{name}_change"
|
|
405
410
|
on_change_name = f"{prefix}__{name}" if prefix else name
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
|
-
import os
|
|
4
|
-
|
|
5
3
|
from django.conf import settings
|
|
6
4
|
from django.contrib.auth.models import User
|
|
7
5
|
from django.core.management import call_command
|
|
6
|
+
from django.contrib.staticfiles.storage import staticfiles_storage
|
|
8
7
|
from django.core.management.base import BaseCommand
|
|
9
8
|
from django.utils import termcolors
|
|
10
9
|
|
|
@@ -34,3 +33,6 @@ class Command(BaseCommand):
|
|
|
34
33
|
user.set_password(password)
|
|
35
34
|
user.save()
|
|
36
35
|
print('Superuser "admin" with password "{}" was created.'.format(password))
|
|
36
|
+
|
|
37
|
+
if getattr(settings, 'USE_S3'):
|
|
38
|
+
staticfiles_storage.collectstatic()
|
|
@@ -523,6 +523,21 @@ class Token(models.Model):
|
|
|
523
523
|
|
|
524
524
|
def __str__(self):
|
|
525
525
|
return self.key
|
|
526
|
+
|
|
527
|
+
def is_valid(self):
|
|
528
|
+
seconds = (datetime.now() - self.created).seconds
|
|
529
|
+
life_time = getattr(settings, 'TOKEN_LIFE_TIME', 15)
|
|
530
|
+
refresh_time = getattr(settings, 'TOKEN_REFRESH_TIME', 5)
|
|
531
|
+
if seconds > life_time * 60:
|
|
532
|
+
# print(f'Token {self.key} for {self.user} created at {self.created.isoformat()} is expired.')
|
|
533
|
+
return False
|
|
534
|
+
elif seconds > refresh_time * 60:
|
|
535
|
+
# print(f'Refreshing token {self.key} for {self.user} created at {self.created.isoformat()}...')
|
|
536
|
+
Token.objects.filter(pk=self.pk).update(created=datetime.now())
|
|
537
|
+
return True
|
|
538
|
+
else:
|
|
539
|
+
# print(f'Token {self.key} for {self.user} created at {self.created.isoformat()} is still valid.')
|
|
540
|
+
return True
|
|
526
541
|
|
|
527
542
|
|
|
528
543
|
class LogQuerySet(models.QuerySet):
|
|
@@ -452,10 +452,15 @@ class QuerySet(models.QuerySet):
|
|
|
452
452
|
options = filter.choices(self)
|
|
453
453
|
value = self.parameter(name)
|
|
454
454
|
if isinstance(options, list) or isinstance(options, tuple):
|
|
455
|
+
add_null = False
|
|
455
456
|
field_type = 'choice'
|
|
456
457
|
choices = [{'id': '', 'value':''}]
|
|
457
|
-
|
|
458
|
-
|
|
458
|
+
for k, v in options:
|
|
459
|
+
choices.append({'id': k, 'value': v})
|
|
460
|
+
if k == 'null':
|
|
461
|
+
add_null = False
|
|
462
|
+
if add_null:
|
|
463
|
+
choices.append({'id': 'null', 'value':'Nulo'})
|
|
459
464
|
else:
|
|
460
465
|
field_type = 'choice'
|
|
461
466
|
choices = append_url(base_url, f'choices={name}')
|
|
@@ -484,8 +489,6 @@ class QuerySet(models.QuerySet):
|
|
|
484
489
|
elif isinstance(field, models.BooleanField):
|
|
485
490
|
field_type = 'choice'
|
|
486
491
|
value = self.parameter(name)
|
|
487
|
-
if value:
|
|
488
|
-
value = value == 'true'
|
|
489
492
|
choices = [dict(id='', value=''), dict(id='true', value='Sim'), dict(id='false', value='Não'), dict(id='null', value='Nulo')]
|
|
490
493
|
elif isinstance(field, models.DateField):
|
|
491
494
|
field_type = 'text' if suffix in ('year', 'month') else 'date'
|
|
@@ -505,10 +508,15 @@ class QuerySet(models.QuerySet):
|
|
|
505
508
|
field_type = 'choice'
|
|
506
509
|
choices = append_url(base_url, f'choices={name}')
|
|
507
510
|
if getattr(field, 'choices'):
|
|
511
|
+
add_null = False
|
|
508
512
|
field_type = 'choice'
|
|
509
513
|
choices = [{'id': '', 'value':''}]
|
|
510
|
-
|
|
511
|
-
|
|
514
|
+
for k, v in field.choices:
|
|
515
|
+
choices.append({'id': k, 'value': v})
|
|
516
|
+
if k == 'null':
|
|
517
|
+
add_null = False
|
|
518
|
+
if add_null:
|
|
519
|
+
choices.append({'id': 'null', 'value':'Nulo'})
|
|
512
520
|
label = label or str(field.verbose_name).title()
|
|
513
521
|
symbol = symbols.get(suffix) if suffix else None
|
|
514
522
|
label = label + symbol if symbol else label
|
|
@@ -143,7 +143,7 @@ import{j as t,r as M,c as Y,R as Re}from"./react.min.js";const T={colors:{primar
|
|
|
143
143
|
.tooltip:hover .tooltiptext {
|
|
144
144
|
visibility: visible;
|
|
145
145
|
}
|
|
146
|
-
`),t.jsxs("div",{className:"tooltip",children:[e.children,t.jsx("div",{className:"tooltiptext",children:V(e.text)})]})}return n()}const Ct=["text","password","email","number","date","datetime-local","file","image","range","search","tel","time","url","week","hidden","color"],ae={padding:15,border:"var(--input-border)",borderRadius:5,backgroundColor:"var(--input-background)"};function Et(e,n){const a=new FormData(e);for(let[i,r]of Array.from(a.entries())){const o=e[i];r!==""&&r!==null||n!=i&&(o.tagName=="SELECT"&&r!==""||o.tagName==null&&r!==""||o.type=="radio"&&r!==""||o.type=="checkbox"&&r!==""||a.delete(i))}return new URLSearchParams(a).toString()}function ee(e,n,a){const i=e.indexOf("?")<0?"?":"&",r=Et(n,a);return e=e+(r?i+r:""),e}function he(e){if(e){const a=[".png",".jpeg",".jpeg",".gif"];for(var n=0;n<a.length;n++)if(e.toLowerCase().indexOf(a[n])>0)return!0}}function re(e,n){O("GET",ee(n,e.closest("form"),e.name),qe)}function Tt(e){if(e){var n=document.querySelector(".form-fieldset."+e);n&&(n.style.display="none");var a=document.querySelector(".form-group."+e);a&&(a.style.display="none");var i=document.querySelector(".form-field."+e);i&&(i.style.display="none")}}function Mt(e){if(e){var n=document.querySelector(".form-fieldset."+e);n&&(n.style.display="block");var a=document.querySelector(".form-group."+e);a&&(a.style.display="block");var i=document.querySelector(".form-field."+e);i&&(i.style.display="block")}}function It(e){const n="reload-"+e+"-field";window[n]&&window[n]()}function Nt(e,n){var a=document.querySelector(".form-group."+e),i=a.querySelectorAll('*[name="'+e+'"]');if(i.length>1)i.forEach(function(o){n==null?o.checked=!1:n.id!=null?o.checked=o.value.toString()==n.id.toString():o.checked=o.value.toString()==n.toString()});else{const o=i[0];if(o.tagName=="INPUT"||o.tagName=="TEXTAREA")o.value=n;else if(o.tagName=="SELECT"){if(o.style.display!="none")o.dispatchEvent(new CustomEvent("customchange",{detail:{value:n}}));else for(var r=0;r<o.options.length;r++)if(o.options[r].value==n){o.selectedIndex=r;break}}}}function qe(e){if(e){for(var n=0;n<e.hide.length;n++)Tt(e.hide[n]);for(var n=0;n<e.show.length;n++)Mt(e.show[n]);for(var n=0;n<e.reload.length;n++)It(e.reload[n]);for(var a in e.set)Nt(a,e.set[a])}}function Lt(e){function n(){const a={color:"white",display:"none",backgroundColor:"#e52207",marginTop:2,marginBottom:2,padding:8};return t.jsxs("div",{style:a,id:e.id,className:"error",children:[t.jsx(C,{icon:"xmark-circle",style:{marginRight:5}}),t.jsx("span",{})]})}return n()}function At(e){function n(){const a={marginTop:2,marginBottom:2,fontStyle:"italic"};return t.jsx("div",{style:a,children:t.jsx("span",{children:e.text})})}return n()}function le(e){const n=e.data.name+Math.random();function a(){const l={display:"flex",justifyContent:"space-between",alignItems:"baseline"};return e.data.action&&(e.data.action.icon=null,e.data.action.modal=!0,e.data.action.urlfunc=function(){return ee(e.data.action.url,document.getElementById(n).closest("form"))}),t.jsxs("div",{style:l,children:[t.jsxs("label",{className:"bold",children:[e.data.label," ",e.data.label&&e.data.required?"*":""]}),e.data.action&&t.jsx(U,{data:e.data.action,style:{padding:0,margin:0},tabIndex:"-1"})]})}function i(){return e.data.type=="datetime"&&(e.data.type="datetime-local"),Ct.indexOf(e.data.type)>=0?t.jsx(ke,{data:e.data}):e.data.type=="choice"&&Array.isArray(e.data.choices)?e.data.pick?Array.isArray(e.data.value)?t.jsx(Se,{data:e.data}):t.jsx(me,{data:e.data}):t.jsx(Dt,{data:e.data}):e.data.type=="choice"?e.data.pick?Array.isArray(e.data.value)?t.jsx(Se,{data:e.data}):t.jsx(me,{data:e.data}):t.jsx(Be,{data:e.data}):e.data.type=="decimal"?t.jsx(ke,{data:e.data}):e.data.type=="boolean"?t.jsx(Bt,{data:e.data}):e.data.type=="textarea"?t.jsx(qt,{data:e.data}):e.data.type=="scheduler"?(e.data.scheduler.input_name=e.data.name,t.jsx(Ae,{data:e.data.scheduler})):t.jsx("span",{children:e.data.name})}function r(){return t.jsx("div",{children:t.jsx(Lt,{id:e.data.name+"_error"})})}function o(){return e.data.help_text&&t.jsx(At,{text:e.data.help_text})}function s(){const l={display:e.data.type=="hidden"?"none":"flex",flexDirection:"column",padding:5,width:"calc(100%-5px)",position:"relative"};return t.jsxs("div",{id:n,style:l,className:"form-group "+e.data.name,children:[a(),i(),o(),r()]})}return s()}function ke(e){var n="";const a=e.data.name+Math.random();e.data.mask=="decimal"&&(n="decimal",e.data.value&&(e.data.value=Math.round(parseFloat(e.data.value)).toFixed(2).replace(".",","))),M.useEffect(()=>{function s(u,d,h){var m=h.target,x=m.value.replace(/\D/g,""),b=m.value.length>d?1:0;VMasker(m).unMask(),VMasker(m).maskPattern(u[b]),m.value=VMasker.toPattern(x,u[b])}if(e.data.mask){var l=document.getElementById(a);if(e.data.mask=="decimal")VMasker(l).maskMoney({precision:2,separator:",",delimiter:"."});else if(e.data.mask.indexOf("|")>0){var c=e.data.mask.split("|");VMasker(l).maskPattern(c[0]),l.addEventListener("input",s.bind(void 0,c,14),!1)}else VMasker(l).maskPattern(e.data.mask)}},[]);function i(s){re(s.target,e.data.onchange)}function r(s){if(e.data.type=="file"&&s.target.files){let c=s.target.files[0];var l=new FileReader;l.onload=function(u){if(he(c.name)){const x="display"+a;var d=document.createElement("img");d.id=s.target.id+"img",d.style.width="200px",d.style.display="block",d.style.margin="auto",d.style.marginTop="20px",d.onload=function(b){const p=e.data.width>e.data.height?e.data.width/d.width:e.data.height/d.height;var B=document.createElement("canvas");const j=B.getContext("2d");B.height=B.width*(d.height/d.width);const D=document.createElement("canvas"),q=D.getContext("2d");D.width=d.width*p,D.height=d.height*p,q.drawImage(d,0,0,D.width,D.height),j.drawImage(D,0,0,D.width*p,D.height*p,0,0,B.width,B.height),D.toBlob(function(w){const E=new DataTransfer;E.items.add(new File([w],c.name)),s.target.files=E.files});var v=document.getElementById(x);v==null?(v=document.createElement("div"),v.id=x):v.removeChild(v.childNodes[0]),v.appendChild(d),s.target.parentNode.appendChild(v)},d.src=u.target.result}const h=document.getElementById("fileinfo"+a);var m=c.size/1024;m<1024?m=parseInt(m)+" Kb":m=(m/1024).toFixed(2)+" Mb",h.innerHTML=c.name+" / "+m,e.data.max_size&&c.size/1024/1024>e.data.max_size&&alert("O limite de tamanho é "+e.data.max_size+"Mb. O arquivo informado possui "+m+". Por favor, adicione um arquivo menor.")},l.readAsDataURL(c)}}function o(){var s=e.data.type;if(s=="datetime"&&(s="datetime-regional"),s=="decimal"&&(s="text"),s=="file"){const u={alignContent:"center",minHeight:75,padding:5,maxWidth:"100%",margin:"auto"};var l=null;return e.data.extensions&&e.data.extensions.length>0&&(l=e.data.extensions.map(d=>"."+d).join(", ")),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:window.innerWidth<800?"block":"flex",justifyContent:"space-between",backgroundColor:"rgba(15, 145, 210, 0.05)",border:"1px dashed rgba(15, 145, 210, 0.4)",borderRadius:10,textAlign:"center"},children:[t.jsx("div",{style:u,children:t.jsx(C,{icon:"cloud-upload",style:{fontSize:"2.5rem",color:T.colors.primary}})}),t.jsxs("div",{style:u,children:[e.data.value&&he(e.data.value)&&t.jsx("div",{style:{textAlign:"center"},children:t.jsx("img",{src:e.data.value,height:50})}),e.data.value&&!he(e.data.value)&&t.jsx("div",{style:{textAlign:"center"},children:e.data.value}),"Selecione um arquivo clicando no botão ao lado.",t.jsxs("div",{className:"bold",id:"fileinfo"+a,children:["O arquivo",e.data.max_size&&"deve possuir até "+e.data.max_size+" Mb e ","deve ter extensão"," ",e.data.extensions.map(d=>"."+d).join(" ou "),"."]})]}),t.jsx("div",{style:u,align:"center",children:t.jsx(z,{label:"Selecionar Arquivo",onClick:()=>document.getElementById(a).click()})})]}),t.jsx("input",{className:"form-control "+n,type:s,name:e.data.name,id:a,"data-label":I(e.data.label),readOnly:e.data.read_only,onBlur:e.data.onchange?i:null,onChange:r,style:{zIndex:"-1",marginTop:-20},accept:l})]})}else{var c=ae;return s=="color"&&(c={...ae},c.width="100%",c.height=47.5),t.jsx("input",{className:"form-control "+n,type:s,name:e.data.name,id:a,defaultValue:e.data.value,"data-label":I(e.data.label),readOnly:e.data.read_only,onBlur:e.data.onchange?i:null,onChange:r,style:c})}}return o()}function Be(e){var n=[];Array.isArray(e.data.value)?e.data.value.forEach(function(v,w){n.push({id:v.id,value:v.label})}):e.data.value!=null&&n.push({id:e.data.value.id,value:e.data.value.label}),e.data.id==null&&(e.data.id=Math.random()),e.data.id2==null&&(e.data.id2=e.data.id+"__autocomplete");const a=e.data.id,i=e.data.id2,r=Array.isArray(e.data.value),[o,s]=M.useState(!1),[l,c]=M.useState(null);var u=!1;let d;M.useEffect(()=>{j(n,!0),document.getElementById(a).addEventListener("customchange",function(v){j(v.detail.value);const w=document.getElementById(e.data.name);w&&reactTriggerChange(w)})},[]);function h(){const v=document.getElementById(a);if(r){const w={padding:5,display:"inline"},E={cursor:"pointer",marginRight:5},_={fontSize:"0.8rem"};return t.jsxs("div",{children:[v==null&&n.map((F,A)=>t.jsxs("div",{style:w,children:[t.jsx("span",{onClick:()=>D(A),style:E,children:t.jsx(C,{icon:"trash-can",style:_})}),F.value]},Math.random())),v!=null&&Array.from(v.options).map((F,A)=>t.jsxs("div",{style:w,children:[t.jsx("span",{onClick:()=>D(A),style:E,children:t.jsx(C,{icon:"trash-can",style:_})}),F.innerHTML]},Math.random()))]})}}function m(){return t.jsx("select",{id:a,name:e.data.name,multiple:r,readOnly:!0,style:{display:"contents"}})}function x(){const v={...ae,...e.style||{}},w={padding:0,margin:0,border:"solid 1px #d9d9d9",marginTop:-1,borderRadius:5,maxHeight:150,overflowY:"auto",zIndex:99999};w.position="absolute",w.backgroundColor="var(--default-background)";const E=document.getElementById(i);if(e.data.icon&&(v.paddingLeft=30),E){let A=E,y=null;for(;!y&&(A=A.parentElement)instanceof HTMLElement;)A.matches("dialog")&&(y=A);const k=E.getBoundingClientRect();w.width=k.width,w.top=80,w.left=5}const _={cursor:"pointer",padding:10},F=!r&&n.length>0&&n[0].value||"";return t.jsxs(t.Fragment,{children:[t.jsx(C,{icon:"search",style:{position:"absolute",right:20,top:45}}),t.jsx("input",{id:i,name:e.data.name+"__autocomplete",type:"text",className:"form-control",onFocus:A=>{A.target.select(),B(A)},onChange:B,onMouseLeave:b,onBlur:b,defaultValue:F,style:v,"data-label":I(e.data.label)}),l&&o&&t.jsxs("ul",{style:w,onMouseLeave:p,onMouseEnter:function(A){u=!0},children:[l.length==0&&t.jsx("li",{style:_,children:"Nenhuma opção encontrada."}),l.map(A=>t.jsx("li",{onClick:()=>{s(!1),e.onSelect?e.onSelect(A):j(A)},style:_,className:"autocomplete-item","data-label":I(A.value),children:A.value},Math.random()))]})]})}function b(v){u=!1,setTimeout(function(){u||p(v)},250)}function p(v){const w=document.getElementById(a);if(w){const E=document.getElementById(i);r||(w.options.length==0||w.options.length>0&&E.value!=w.options[0].innerHTML)&&(w.innerHTML="",E.value="",s(!1),e.data.onchange&&re(E,e.data.onchange)),v.target.tagName=="UL"?s(!1):u||s(!1)}}function B(v){clearTimeout(d),d=setTimeout(function(){const w=v.target.closest("form"),E=e.data.choices.indexOf("?")<0?"?":"&";s(!0),O("GET",ee(e.data.choices+E+"term="+v.target.value,w),function(F){c(F)})},1e3)}function j(v,w=!1){const E=document.getElementById(a),_=document.getElementById(i);E.innerHTML==null&&(E.innerHTML=""),Array.isArray(v)?E.innerHTML=v.map(F=>`<option selected value="${F.id}">${F.value}</option>`).join(""):v?r?(E.innerHTML+=`<option selected value="${v.id}">${v.value}</option>`,_.value=""):(E.innerHTML=`<option selected value="${v.id}">${v.value}</option>`,_.value=v.value):(E.innerHTML="",_.value=""),e.data.onchange&&!w&&re(_,e.data.onchange)}function D(v){const w=document.getElementById(a);var E=Array.from(w.options);w.innerHTML=E.slice(0,v).concat(E.slice(v+1)).map(_=>`<option selected value="${_.value}">${_.innerHTML}</option>`).join(""),c([])}function q(){return t.jsxs(t.Fragment,{children:[m(),x(),h()]})}return q()}function qt(e){function n(){var a={...ae};return a.height=100,t.jsx("textarea",{id:e.data.name,name:e.data.name,"data-label":I(e.data.label),style:a,defaultValue:e.data.value||"",className:"form-control"})}return n()}function Bt(e){return t.jsx(me,{data:e.data})}function me(e){const[n,a]=M.useState(e.data.choices);var i=Math.random(),r=e.data;function o(u){return r.value!=null&&r.value.toString()==u.id.toString()||r.value!=null&&r.value.id!=null&&r.value.id.toString()==u.id.toString()||r.value==null&&u.id.toString()=="null"}function s(u){var d=document.getElementById(u);r.checked&&(d.checked=!1),e.data.onchange&&re(d,e.data.onchange)}function l(u){var d=document.getElementById(u);r.checked=d.checked}function c(){return window["reload-"+r.name+"-field"]=function(){O("GET",ee(e.data.pick,document.querySelector(".radio-group."+r.name).closest("form")),function(d){a(d)})},n.length>0?t.jsx("div",{className:"radio-group "+r.name,children:n.map((u,d)=>(u.id||u.id===!1)&&t.jsxs("div",{style:{paddingTop:10,display:"inline-block",marginRight:25,width:window.innerWidth>800?"auto":"100%"},children:[t.jsx("input",{id:r.name+i+d,type:"radio",name:r.name,defaultValue:u.id,defaultChecked:o(u),"data-label":I(u.value),onClick:function(){s(r.name+i+d)},onMouseEnter:function(){l(r.name+i+d)}}),t.jsx("label",{htmlFor:r.name+i+d,children:u.value})]},i+d))}):t.jsx("div",{className:"radio-group empty "+r.name,children:t.jsx(ie,{data:{text:"Nenhuma opção disponível para seleção."}})})}return c()}function Se(e){const[n,a]=M.useState(e.data.choices);var i=Math.random(),r=e.data;function o(c){var u=!1;if(r.value)for(var d=0;d<r.value.length;d++){var h=r.value[d];(h==c.id||h.id==c.id)&&(u=!0)}return u}function s(c){e.data.onchange&&re(c.target,e.data.onchange)}function l(){return window["reload-"+r.name+"-field"]=function(){O("GET",ee(e.data.pick,document.querySelector(".checkbox-group."+r.name).closest("form")),function(u){a(u)})},n.length>0?t.jsx("div",{className:"checkbox-group "+r.name,children:n.map((c,u)=>(c.id||c.id===!1)&&t.jsxs("div",{style:{paddingTop:10,display:"inline-block",marginRight:25,width:window.innerWidth>800?"auto":"100%"},children:[t.jsx("input",{id:r.name+i+u,type:"checkbox",name:r.name,onClick:s,defaultValue:c.id,defaultChecked:o(c),"data-label":I(c.value)}),t.jsx("label",{htmlFor:r.name+i+u,children:c.value})]},i+u))}):t.jsx("div",{className:"checkbox-group empty "+r.name,children:t.jsx(ie,{data:{text:"Nenhuma opção disponível para seleção."}})})}return l()}function Dt(e){var n=e.data;return t.jsx(t.Fragment,{children:t.jsx("select",{className:"form-control",id:n.name,name:n.name,"data-label":I(n.label),defaultValue:n.value,style:ae,children:n.choices.map(a=>t.jsx("option",{value:a.id,children:a.value},Math.random()))})})}function Rt(e){const n=Math.random(),a=e.data.value[0],i=a.fields?a.fields[0]:a.fieldsets[0].fields[0][0];function r(){return!e.data.required&&t.jsx("div",{id:"info-"+n,children:t.jsxs(ie,{data:{text:"Esta informação é opcional. Controle seu preenchimento com o botão ao lado."},children:[t.jsx(z,{primary:!0,icon:"pen-clip",onClick:()=>o(!0),id:"show-"+n,display:i.value?"none":"inline"}),t.jsx(z,{primary:!0,icon:"trash",onClick:()=>o(!1),id:"hide-"+n,display:i.value?"inline":"none"})]})})}function o(c){const u=document.querySelector("input[name="+i.name+"]"),d=document.getElementById("inline-form-"+n),h=document.getElementById("show-"+n),m=document.getElementById("hide-"+n);d.style.display=c?"block":"none",h.style.display=c?"none":"inline",m.style.display=c?"inline":"none",c?u.value===""?u.value=0:u.value=-parseInt(u.value):parseInt(u.value)==0?u.value="":u.value=-parseInt(u.value)}function s(){const c={display:i.value?"block":"none"};return e.data.required&&(c.display="block",i.value===""&&(i.value=0)),t.jsx("div",{className:"fieldset-inline-forms",style:c,id:"inline-form-"+n,children:e.data.value.map(function(u){return t.jsx(ye,{data:u},Math.random())})})}function l(){const c={margin:0};return t.jsxs("div",{className:"form-fieldset "+e.data.name,children:[t.jsx("h2",{style:c,"data-label":I(e.data.label),children:e.data.label}),r(),s()]})}return l()}function Ot(e){var n=0;const a=Math.random();e.data.template==null&&(e.data.template=e.data.value.pop());function i(d,h){const m=n;return n+=1,t.jsxs("div",{style:{display:"block"},id:"form-"+m+"-"+a,children:[t.jsx(ye,{data:d}),t.jsxs("div",{style:{textAlign:"center",marginTop:10,marginBottom:10},children:[t.jsx(z,{primary:!0,icon:"plus",onClick:()=>o(),id:"extra-add-"+m+"-",display:h}),t.jsx(z,{primary:!0,icon:"trash",onClick:()=>s(m),display:"inline"})]})]},Math.random())}function r(){const d=l(),h=d.length>0?"none":"inline";document.getElementById("add-"+a).style.display=h;for(var m=0;m<n;m++){var x=document.getElementById("extra-add-"+m+"-");x.style.display="none"}if(d.length>0){var x=document.getElementById("extra-add-"+d[d.length-1]+"-");x.style.display="inline"}}function o(){r();var d=JSON.parse(JSON.stringify(e.data.template));d.fields?(d.fields.map(function(h){h.name=h.name.replace("__n__","__"+n+"__")}),d.fields[0].value=0):d.fieldsets.map(function(h){h.fields.map(function(m){m.map(function(x){x.name=x.name.replace("__n__","__"+n+"__")}),m[0].value=0})}),Y.createRoot(document.getElementById(a).appendChild(document.createElement("div"))).render(i(d,"inline")),setTimeout(r,100)}function s(d){const h=e.data.template,x=(h.fields?h.fields[0]:h.fieldsets[0].fields[0][0]).name.replace("__n__","__"+d+"__"),b=document.querySelector("input[name="+x+"]");parseInt(b.value)==0?b.value="":b.value=-parseInt(b.value),document.getElementById("form-"+d+"-"+a).style.display="none",r()}function l(){for(var d=[],h=0;h<n;h++)document.getElementById("form-"+h+"-"+a).style.display=="block"&&d.push(h);return d}function c(){return t.jsx("div",{id:"info-"+a,children:t.jsx(ie,{data:{text:'Clique no botão com o ícone de "+" para adicionar e com o ícone da "lixeira" para remover.'},children:t.jsx(z,{primary:!0,icon:"add",onClick:()=>o(),id:"add-"+a,display:e.data.value.length>0?"none":"inline"})})})}function u(){const d={margin:0};return t.jsxs("div",{className:"form-fieldset "+e.data.name,children:[t.jsx("h2",{style:d,"data-label":I(e.data.label),children:e.data.label}),t.jsx("div",{children:!1}),t.jsxs("div",{id:a,className:"fieldset-inline-forms",children:[c(),e.data.value.map(function(h,m){return i(h,m==e.data.value.length-1?"inline":"none")})]})]})}return u()}function ye(e){M.useEffect(()=>{e.data.controls&&qe(e.data.controls)},[]);function n(i){return i.type=="inline"?i.max==i.min==1?t.jsx(Rt,{data:i},Math.random()):t.jsx(Ot,{data:i},Math.random()):t.jsx(le,{data:i},Math.random())}function a(){return e.data.fields?e.data.fields.length>0?t.jsx("div",{className:"form-fields default-fieldset",children:e.data.fields.map(i=>n(i))}):null:e.data.fieldsets.map(i=>t.jsx("div",{className:"form-fieldset "+i.name,children:i.type=="inline"?n(i):t.jsxs(t.Fragment,{children:[t.jsx("h2",{"data-label":I(i.title),style:{margin:0},children:i.title}),i.fields.map(r=>t.jsx("div",{children:r.map(o=>t.jsx("div",{className:"form-field "+o.name,style:{verticalAlign:"bottom",width:(window.innerWidth>600?100/r.length:100)+"%",display:o.type=="hidden"?"none":"inline-block"},children:n(o)},Math.random()))},Math.random()))]})},Math.random()))}return a()}function _t(e){const n=Math.random();M.useEffect(()=>{e.data.autosubmit&&setInterval(h,e.data.autosubmit*1e3)},[]);function a(){const m={margin:0,color:T.colors.primary};return t.jsx("h1",{style:m,children:e.data.title})}function i(){return e.data.info&&t.jsx(K,{data:{text:e.data.info}})}function r(){if(e.data.display)return t.jsxs(t.Fragment,{children:[e.data.display.map(m=>t.jsx(g,{data:m},Math.random())),t.jsx("div",{style:{marginTop:30}})]})}function o(){return t.jsx(ye,{data:e.data})}function s(){return t.jsxs("div",{style:{marginTop:20,textAlign:"right"},children:[t.jsx(z,{onClick:d,label:"Cancelar",default:!0,display:"inline"}),t.jsx(z,{onClick:h,label:e.data.submit_label,primary:!0,display:"inline",icon:e.data.submit_icon,spin:!0})]})}function l(){return t.jsx("div",{id:"output",style:{marginTop:30}})}function c(){if(e.data.image)return t.jsx("div",{style:{margin:"auto",width:"100%",textAlign:"center"},children:t.jsx("img",{src:e.data.image})})}function u(){return t.jsxs("form",{id:n,className:e.data.key,action:e.data.url,style:{margin:"auto"},method:e.data.method,children:[t.jsx("div",{children:!1}),t.jsxs("div",{style:{padding:5},children:[a(),c(),i(),r(),o(),s(),l()]})]})}function d(){Z()}function h(m){m&&m.preventDefault();var x=e.data.url,b=document.getElementById(n),p=new FormData(b);if(b.method.toUpperCase()=="GET"){const B=x.indexOf("?")>=0?"&":"?";x=x+B+"form="+e.data.key+"&"+new URLSearchParams(p).toString(),p=null}e.data.autosubmit&&m==null&&(x+="&autosubmit=1"),O(b.method.toUpperCase(),x,function(j){if(b.querySelectorAll(".error").forEach(q=>q.style.display="none"),m&&m.target.dataset.spinning&&(m.target.querySelector("i.fa-spin").style.display="none",m.target.querySelector("i.fa-"+m.target.dataset.spinning).style.display="inline-block"),j.type=="response")if(j.store&&Me(j.store),j.redirect&&j.redirect.length>2)j.message&&localStorage.setItem("message",j.message),document.location.href=$(j.redirect);else if(j.message&&G(j.message),j.task){let q=function(){O("GET","/api/job/progress/"+j.task+"/",function(E){E==null||E.progress==100?m.target.innerHTML=v:(m.target.innerHTML="Aguarde... ("+(E.progress||0)+"%)",setTimeout(q,5e3))})};const v=m.target.innerHTML;m.target.innerHTML="Aguarde... (0%)",q()}else j.redirect==".."&&(document.getElementsByTagName("dialog").length==0?history.back():Z()),j.redirect=="."&&(document.getElementsByTagName("dialog").length==0?b.reset():Z()),j.dispose&&(b.style.display="none"),dt();else if(j.type=="error"){var D=j.text;console.log(j),Object.keys(j.errors).map(function(q){if(q=="__all__")D=j.errors[q];else{const v=b.querySelector("#"+q+"_error");v==null?D=q+":"+j.errors[q]:(v.querySelector("span").innerHTML=j.errors[q],v.style.display="block")}}),G(D,!0)}else if(j.type!="redirect"){const q=document.querySelector("#output");q.innerHTML="",Y.createRoot(q.appendChild(document.createElement("div"))).render(t.jsx(g,{data:j}))}},p)}return u()}function Wt(e){W(`
|
|
146
|
+
`),t.jsxs("div",{className:"tooltip",children:[e.children,t.jsx("div",{className:"tooltiptext",children:V(e.text)})]})}return n()}const Ct=["text","password","email","number","date","datetime-local","file","image","range","search","tel","time","url","week","hidden","color"],ae={padding:15,border:"var(--input-border)",borderRadius:5,backgroundColor:"var(--input-background)"};function Et(e,n){const a=new FormData(e);for(let[i,r]of Array.from(a.entries())){const o=e[i];r!==""&&r!==null||n!=i&&(o.tagName=="SELECT"&&r!==""||o.tagName==null&&r!==""||o.type=="radio"&&r!==""||o.type=="checkbox"&&r!==""||a.delete(i))}return new URLSearchParams(a).toString()}function ee(e,n,a){const i=e.indexOf("?")<0?"?":"&",r=Et(n,a);return e=e+(r?i+r:""),e}function he(e){if(e){const a=[".png",".jpeg",".jpeg",".gif"];for(var n=0;n<a.length;n++)if(e.toLowerCase().indexOf(a[n])>0)return!0}}function re(e,n){O("GET",ee(n,e.closest("form"),e.name),qe)}function Tt(e){if(e){var n=document.querySelector(".form-fieldset."+e);n&&(n.style.display="none");var a=document.querySelector(".form-group."+e);a&&(a.style.display="none");var i=document.querySelector(".form-field."+e);i&&(i.style.display="none")}}function Mt(e){if(e){var n=document.querySelector(".form-fieldset."+e);n&&(n.style.display="block");var a=document.querySelector(".form-group."+e);a&&(a.style.display="block");var i=document.querySelector(".form-field."+e);i&&(i.style.display="block")}}function It(e){const n="reload-"+e+"-field";window[n]&&window[n]()}function Nt(e,n){var a=document.querySelector(".form-group."+e),i=a.querySelectorAll('*[name="'+e+'"]');if(i.length>1)i.forEach(function(o){n==null?o.checked=!1:n.id!=null?o.checked=o.value.toString()==n.id.toString():o.checked=o.value.toString()==n.toString()});else{const o=i[0];if(o.tagName=="INPUT"||o.tagName=="TEXTAREA")o.value=n;else if(o.tagName=="SELECT"){if(o.style.display!="none")o.dispatchEvent(new CustomEvent("customchange",{detail:{value:n}}));else for(var r=0;r<o.options.length;r++)if(o.options[r].value==n){o.selectedIndex=r;break}}}}function qe(e){if(e){for(var n=0;n<e.hide.length;n++)Tt(e.hide[n]);for(var n=0;n<e.show.length;n++)Mt(e.show[n]);for(var n=0;n<e.reload.length;n++)It(e.reload[n]);for(var a in e.set)Nt(a,e.set[a])}}function Lt(e){function n(){const a={color:"white",display:"none",backgroundColor:"#e52207",marginTop:2,marginBottom:2,padding:8};return t.jsxs("div",{style:a,id:e.id,className:"error",children:[t.jsx(C,{icon:"xmark-circle",style:{marginRight:5}}),t.jsx("span",{})]})}return n()}function At(e){function n(){const a={marginTop:2,marginBottom:2,fontStyle:"italic"};return t.jsx("div",{style:a,children:t.jsx("span",{children:e.text})})}return n()}function le(e){const n=e.data.name+Math.random();function a(){const l={display:"flex",justifyContent:"space-between",alignItems:"baseline"};return e.data.action&&(e.data.action.icon=null,e.data.action.modal=!0,e.data.action.urlfunc=function(){return ee(e.data.action.url,document.getElementById(n).closest("form"))}),t.jsxs("div",{style:l,children:[t.jsxs("label",{className:"bold",children:[e.data.label," ",e.data.label&&e.data.required?"*":""]}),e.data.action&&t.jsx(U,{data:e.data.action,style:{padding:0,margin:0},tabIndex:"-1"})]})}function i(){return e.data.type=="datetime"&&(e.data.type="datetime-local"),Ct.indexOf(e.data.type)>=0?t.jsx(ke,{data:e.data}):e.data.type=="choice"&&Array.isArray(e.data.choices)?e.data.pick?Array.isArray(e.data.value)?t.jsx(Se,{data:e.data}):t.jsx(me,{data:e.data}):t.jsx(Dt,{data:e.data}):e.data.type=="choice"?e.data.pick?Array.isArray(e.data.value)?t.jsx(Se,{data:e.data}):t.jsx(me,{data:e.data}):t.jsx(Be,{data:e.data}):e.data.type=="decimal"?t.jsx(ke,{data:e.data}):e.data.type=="boolean"?t.jsx(Bt,{data:e.data}):e.data.type=="textarea"?t.jsx(qt,{data:e.data}):e.data.type=="scheduler"?(e.data.scheduler.input_name=e.data.name,t.jsx(Ae,{data:e.data.scheduler})):t.jsx("span",{children:e.data.name})}function r(){return t.jsx("div",{children:t.jsx(Lt,{id:e.data.name+"_error"})})}function o(){return e.data.help_text&&t.jsx(At,{text:e.data.help_text})}function s(){const l={display:e.data.type=="hidden"?"none":"flex",flexDirection:"column",padding:5,width:"calc(100%-5px)",position:"relative"};return t.jsxs("div",{id:n,style:l,className:"form-group "+e.data.name,children:[a(),i(),o(),r()]})}return s()}function ke(e){var n="";const a=e.data.name+Math.random();e.data.mask=="decimal"&&(n="decimal",e.data.value&&(e.data.value=Math.round(parseFloat(e.data.value)).toFixed(2).replace(".",","))),M.useEffect(()=>{function s(u,d,h){var m=h.target,x=m.value.replace(/\D/g,""),b=m.value.length>d?1:0;VMasker(m).unMask(),VMasker(m).maskPattern(u[b]),m.value=VMasker.toPattern(x,u[b])}if(e.data.mask){var l=document.getElementById(a);if(e.data.mask=="decimal")VMasker(l).maskMoney({precision:2,separator:",",delimiter:"."});else if(e.data.mask.indexOf("|")>0){var c=e.data.mask.split("|");VMasker(l).maskPattern(c[0]),l.addEventListener("input",s.bind(void 0,c,14),!1)}else VMasker(l).maskPattern(e.data.mask)}},[]);function i(s){re(s.target,e.data.onchange)}function r(s){if(e.data.type=="file"&&s.target.files){let c=s.target.files[0];var l=new FileReader;l.onload=function(u){if(he(c.name)){const x="display"+a;var d=document.createElement("img");d.id=s.target.id+"img",d.style.width="200px",d.style.display="block",d.style.margin="auto",d.style.marginTop="20px",d.onload=function(b){const p=e.data.width>e.data.height?e.data.width/d.width:e.data.height/d.height;var B=document.createElement("canvas");const j=B.getContext("2d");B.height=B.width*(d.height/d.width);const D=document.createElement("canvas"),q=D.getContext("2d");D.width=d.width*p,D.height=d.height*p,q.drawImage(d,0,0,D.width,D.height),j.drawImage(D,0,0,D.width*p,D.height*p,0,0,B.width,B.height),D.toBlob(function(w){const E=new DataTransfer;E.items.add(new File([w],c.name)),s.target.files=E.files});var v=document.getElementById(x);v==null?(v=document.createElement("div"),v.id=x):v.removeChild(v.childNodes[0]),v.appendChild(d),s.target.parentNode.appendChild(v)},d.src=u.target.result}const h=document.getElementById("fileinfo"+a);var m=c.size/1024;m<1024?m=parseInt(m)+" Kb":m=(m/1024).toFixed(2)+" Mb",h.innerHTML=c.name+" / "+m,e.data.max_size&&c.size/1024/1024>e.data.max_size&&alert("O limite de tamanho é "+e.data.max_size+"Mb. O arquivo informado possui "+m+". Por favor, adicione um arquivo menor.")},l.readAsDataURL(c)}}function o(){var s=e.data.type;if(s=="datetime"&&(s="datetime-regional"),s=="decimal"&&(s="text"),s=="file"){const u={alignContent:"center",minHeight:75,padding:5,maxWidth:"100%",margin:"auto"};var l=null;return e.data.extensions&&e.data.extensions.length>0&&(l=e.data.extensions.map(d=>"."+d).join(", ")),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:window.innerWidth<800?"block":"flex",justifyContent:"space-between",backgroundColor:"rgba(15, 145, 210, 0.05)",border:"1px dashed rgba(15, 145, 210, 0.4)",borderRadius:10,textAlign:"center"},children:[t.jsx("div",{style:u,children:t.jsx(C,{icon:"cloud-upload",style:{fontSize:"2.5rem",color:T.colors.primary}})}),t.jsxs("div",{style:u,children:[e.data.value&&he(e.data.value)&&t.jsx("div",{style:{textAlign:"center"},children:t.jsx("img",{src:e.data.value,height:50})}),e.data.value&&!he(e.data.value)&&t.jsx("div",{style:{textAlign:"center"},children:e.data.value}),"Selecione um arquivo clicando no botão ao lado.",t.jsxs("div",{className:"bold",id:"fileinfo"+a,children:["O arquivo",e.data.max_size&&"deve possuir até "+e.data.max_size+" Mb e ","deve ter extensão"," ",e.data.extensions.map(d=>"."+d).join(" ou "),"."]})]}),t.jsx("div",{style:u,align:"center",children:t.jsx(z,{label:"Selecionar Arquivo",onClick:()=>document.getElementById(a).click()})})]}),t.jsx("input",{className:"form-control "+n,type:s,name:e.data.name,id:a,"data-label":I(e.data.label),readOnly:e.data.read_only,onBlur:e.data.onchange?i:null,onChange:r,style:{zIndex:"-1",marginTop:-20},accept:l})]})}else{var c=ae;return s=="color"&&(c={...ae},c.width="100%",c.height=47.5),t.jsx("input",{className:"form-control "+n,type:s,name:e.data.name,id:a,defaultValue:e.data.value,"data-label":I(e.data.label),readOnly:e.data.read_only,onBlur:e.data.onchange?i:null,onChange:r,style:c})}}return o()}function Be(e){var n=[];Array.isArray(e.data.value)?e.data.value.forEach(function(v,w){n.push({id:v.id,value:v.label})}):e.data.value!=null&&n.push({id:e.data.value.id,value:e.data.value.label}),e.data.id==null&&(e.data.id=Math.random()),e.data.id2==null&&(e.data.id2=e.data.id+"__autocomplete");const a=e.data.id,i=e.data.id2,r=Array.isArray(e.data.value),[o,s]=M.useState(!1),[l,c]=M.useState(null);var u=!1;let d;M.useEffect(()=>{j(n,!0),document.getElementById(a).addEventListener("customchange",function(v){j(v.detail.value);const w=document.getElementById(e.data.name);w&&reactTriggerChange(w)})},[]);function h(){const v=document.getElementById(a);if(r){const w={padding:5,display:"inline"},E={cursor:"pointer",marginRight:5},_={fontSize:"0.8rem"};return t.jsxs("div",{children:[v==null&&n.map((F,A)=>t.jsxs("div",{style:w,children:[t.jsx("span",{onClick:()=>D(A),style:E,children:t.jsx(C,{icon:"trash-can",style:_})}),F.value]},Math.random())),v!=null&&Array.from(v.options).map((F,A)=>t.jsxs("div",{style:w,children:[t.jsx("span",{onClick:()=>D(A),style:E,children:t.jsx(C,{icon:"trash-can",style:_})}),F.innerHTML]},Math.random()))]})}}function m(){return t.jsx("select",{id:a,name:e.data.name,multiple:r,readOnly:!0,style:{display:"contents"}})}function x(){const v={...ae,...e.style||{}},w={padding:0,margin:0,border:"solid 1px #d9d9d9",marginTop:-1,borderRadius:5,maxHeight:150,overflowY:"auto",zIndex:99999};w.position="absolute",w.backgroundColor="var(--default-background)";const E=document.getElementById(i);if(e.data.icon&&(v.paddingLeft=30),E){let A=E,y=null;for(;!y&&(A=A.parentElement)instanceof HTMLElement;)A.matches("dialog")&&(y=A);const k=E.getBoundingClientRect();w.width=k.width,w.top=80,w.left=5}const _={cursor:"pointer",padding:10},F=!r&&n.length>0&&n[0].value||"";return t.jsxs(t.Fragment,{children:[t.jsx(C,{icon:"search",style:{position:"absolute",right:20,top:45}}),t.jsx("input",{id:i,name:e.data.name+"__autocomplete",type:"text",className:"form-control",autocomplete:"off",onFocus:A=>{A.target.select(),B(A)},onChange:B,onMouseLeave:b,onBlur:b,defaultValue:F,style:v,"data-label":I(e.data.label)}),l&&o&&t.jsxs("ul",{style:w,onMouseLeave:p,onMouseEnter:function(A){u=!0},children:[l.length==0&&t.jsx("li",{style:_,children:"Nenhuma opção encontrada."}),l.map(A=>t.jsx("li",{onClick:()=>{s(!1),e.onSelect?e.onSelect(A):j(A)},style:_,className:"autocomplete-item","data-label":I(A.value),children:A.value},Math.random()))]})]})}function b(v){u=!1,setTimeout(function(){u||p(v)},250)}function p(v){const w=document.getElementById(a);if(w){const E=document.getElementById(i);r||(w.options.length==0||w.options.length>0&&E.value!=w.options[0].innerHTML)&&(w.innerHTML="",E.value="",s(!1),e.data.onchange&&re(E,e.data.onchange)),v.target.tagName=="UL"?s(!1):u||s(!1)}}function B(v){clearTimeout(d),d=setTimeout(function(){const w=v.target.closest("form"),E=e.data.choices.indexOf("?")<0?"?":"&";s(!0),O("GET",ee(e.data.choices+E+"term="+v.target.value,w),function(F){c(F)})},1e3)}function j(v,w=!1){const E=document.getElementById(a),_=document.getElementById(i);E.innerHTML==null&&(E.innerHTML=""),Array.isArray(v)?E.innerHTML=v.map(F=>`<option selected value="${F.id}">${F.value}</option>`).join(""):v?r?(E.innerHTML+=`<option selected value="${v.id}">${v.value}</option>`,_.value=""):(E.innerHTML=`<option selected value="${v.id}">${v.value}</option>`,_.value=v.value):(E.innerHTML="",_.value=""),e.data.onchange&&!w&&re(_,e.data.onchange)}function D(v){const w=document.getElementById(a);var E=Array.from(w.options);w.innerHTML=E.slice(0,v).concat(E.slice(v+1)).map(_=>`<option selected value="${_.value}">${_.innerHTML}</option>`).join(""),c([])}function q(){return t.jsxs(t.Fragment,{children:[m(),x(),h()]})}return q()}function qt(e){function n(){var a={...ae};return a.height=100,t.jsx("textarea",{id:e.data.name,name:e.data.name,"data-label":I(e.data.label),style:a,defaultValue:e.data.value||"",className:"form-control"})}return n()}function Bt(e){return t.jsx(me,{data:e.data})}function me(e){const[n,a]=M.useState(e.data.choices);var i=Math.random(),r=e.data;function o(u){return r.value!=null&&r.value.toString()==u.id.toString()||r.value!=null&&r.value.id!=null&&r.value.id.toString()==u.id.toString()||r.value==null&&u.id.toString()=="null"}function s(u){var d=document.getElementById(u);r.checked&&(d.checked=!1),e.data.onchange&&re(d,e.data.onchange)}function l(u){var d=document.getElementById(u);r.checked=d.checked}function c(){return window["reload-"+r.name+"-field"]=function(){O("GET",ee(e.data.pick,document.querySelector(".radio-group."+r.name).closest("form")),function(d){a(d)})},n.length>0?t.jsx("div",{className:"radio-group "+r.name,children:n.map((u,d)=>(u.id||u.id===!1)&&t.jsxs("div",{style:{paddingTop:10,display:"inline-block",marginRight:25,width:window.innerWidth>800?"auto":"100%"},children:[t.jsx("input",{id:r.name+i+d,type:"radio",name:r.name,defaultValue:u.id,defaultChecked:o(u),"data-label":I(u.value),onClick:function(){s(r.name+i+d)},onMouseEnter:function(){l(r.name+i+d)}}),t.jsx("label",{htmlFor:r.name+i+d,children:u.value})]},i+d))}):t.jsx("div",{className:"radio-group empty "+r.name,children:t.jsx(ie,{data:{text:"Nenhuma opção disponível para seleção."}})})}return c()}function Se(e){const[n,a]=M.useState(e.data.choices);var i=Math.random(),r=e.data;function o(c){var u=!1;if(r.value)for(var d=0;d<r.value.length;d++){var h=r.value[d];(h==c.id||h.id==c.id)&&(u=!0)}return u}function s(c){e.data.onchange&&re(c.target,e.data.onchange)}function l(){return window["reload-"+r.name+"-field"]=function(){O("GET",ee(e.data.pick,document.querySelector(".checkbox-group."+r.name).closest("form")),function(u){a(u)})},n.length>0?t.jsx("div",{className:"checkbox-group "+r.name,children:n.map((c,u)=>(c.id||c.id===!1)&&t.jsxs("div",{style:{paddingTop:10,display:"inline-block",marginRight:25,width:window.innerWidth>800?"auto":"100%"},children:[t.jsx("input",{id:r.name+i+u,type:"checkbox",name:r.name,onClick:s,defaultValue:c.id,defaultChecked:o(c),"data-label":I(c.value)}),t.jsx("label",{htmlFor:r.name+i+u,children:c.value})]},i+u))}):t.jsx("div",{className:"checkbox-group empty "+r.name,children:t.jsx(ie,{data:{text:"Nenhuma opção disponível para seleção."}})})}return l()}function Dt(e){var n=e.data;return t.jsx(t.Fragment,{children:t.jsx("select",{className:"form-control",id:n.name,name:n.name,"data-label":I(n.label),defaultValue:n.value,style:ae,children:n.choices.map(a=>t.jsx("option",{value:a.id,children:a.value},Math.random()))})})}function Rt(e){const n=Math.random(),a=e.data.value[0],i=a.fields?a.fields[0]:a.fieldsets[0].fields[0][0];function r(){return!e.data.required&&t.jsx("div",{id:"info-"+n,children:t.jsxs(ie,{data:{text:"Esta informação é opcional. Controle seu preenchimento com o botão ao lado."},children:[t.jsx(z,{primary:!0,icon:"pen-clip",onClick:()=>o(!0),id:"show-"+n,display:i.value?"none":"inline"}),t.jsx(z,{primary:!0,icon:"trash",onClick:()=>o(!1),id:"hide-"+n,display:i.value?"inline":"none"})]})})}function o(c){const u=document.querySelector("input[name="+i.name+"]"),d=document.getElementById("inline-form-"+n),h=document.getElementById("show-"+n),m=document.getElementById("hide-"+n);d.style.display=c?"block":"none",h.style.display=c?"none":"inline",m.style.display=c?"inline":"none",c?u.value===""?u.value=0:u.value=-parseInt(u.value):parseInt(u.value)==0?u.value="":u.value=-parseInt(u.value)}function s(){const c={display:i.value?"block":"none"};return e.data.required&&(c.display="block",i.value===""&&(i.value=0)),t.jsx("div",{className:"fieldset-inline-forms",style:c,id:"inline-form-"+n,children:e.data.value.map(function(u){return t.jsx(ye,{data:u},Math.random())})})}function l(){const c={margin:0};return t.jsxs("div",{className:"form-fieldset "+e.data.name,children:[t.jsx("h2",{style:c,"data-label":I(e.data.label),children:e.data.label}),r(),s()]})}return l()}function Ot(e){var n=0;const a=Math.random();e.data.template==null&&(e.data.template=e.data.value.pop());function i(d,h){const m=n;return n+=1,t.jsxs("div",{style:{display:"block"},id:"form-"+m+"-"+a,children:[t.jsx(ye,{data:d}),t.jsxs("div",{style:{textAlign:"center",marginTop:10,marginBottom:10},children:[t.jsx(z,{primary:!0,icon:"plus",onClick:()=>o(),id:"extra-add-"+m+"-",display:h}),t.jsx(z,{primary:!0,icon:"trash",onClick:()=>s(m),display:"inline"})]})]},Math.random())}function r(){const d=l(),h=d.length>0?"none":"inline";document.getElementById("add-"+a).style.display=h;for(var m=0;m<n;m++){var x=document.getElementById("extra-add-"+m+"-");x.style.display="none"}if(d.length>0){var x=document.getElementById("extra-add-"+d[d.length-1]+"-");x.style.display="inline"}}function o(){r();var d=JSON.parse(JSON.stringify(e.data.template));d.fields?(d.fields.map(function(h){h.name=h.name.replace("__n__","__"+n+"__")}),d.fields[0].value=0):d.fieldsets.map(function(h){h.fields.map(function(m){m.map(function(x){x.name=x.name.replace("__n__","__"+n+"__")}),m[0].value=0})}),Y.createRoot(document.getElementById(a).appendChild(document.createElement("div"))).render(i(d,"inline")),setTimeout(r,100)}function s(d){const h=e.data.template,x=(h.fields?h.fields[0]:h.fieldsets[0].fields[0][0]).name.replace("__n__","__"+d+"__"),b=document.querySelector("input[name="+x+"]");parseInt(b.value)==0?b.value="":b.value=-parseInt(b.value),document.getElementById("form-"+d+"-"+a).style.display="none",r()}function l(){for(var d=[],h=0;h<n;h++)document.getElementById("form-"+h+"-"+a).style.display=="block"&&d.push(h);return d}function c(){return t.jsx("div",{id:"info-"+a,children:t.jsx(ie,{data:{text:'Clique no botão com o ícone de "+" para adicionar e com o ícone da "lixeira" para remover.'},children:t.jsx(z,{primary:!0,icon:"add",onClick:()=>o(),id:"add-"+a,display:e.data.value.length>0?"none":"inline"})})})}function u(){const d={margin:0};return t.jsxs("div",{className:"form-fieldset "+e.data.name,children:[t.jsx("h2",{style:d,"data-label":I(e.data.label),children:e.data.label}),t.jsx("div",{children:!1}),t.jsxs("div",{id:a,className:"fieldset-inline-forms",children:[c(),e.data.value.map(function(h,m){return i(h,m==e.data.value.length-1?"inline":"none")})]})]})}return u()}function ye(e){M.useEffect(()=>{e.data.controls&&qe(e.data.controls)},[]);function n(i){return i.type=="inline"?i.max==i.min==1?t.jsx(Rt,{data:i},Math.random()):t.jsx(Ot,{data:i},Math.random()):t.jsx(le,{data:i},Math.random())}function a(){return e.data.fields?e.data.fields.length>0?t.jsx("div",{className:"form-fields default-fieldset",children:e.data.fields.map(i=>n(i))}):null:e.data.fieldsets.map(i=>t.jsx("div",{className:"form-fieldset "+i.name,children:i.type=="inline"?n(i):t.jsxs(t.Fragment,{children:[t.jsx("h2",{"data-label":I(i.title),style:{margin:0},children:i.title}),i.fields.map(r=>t.jsx("div",{children:r.map(o=>t.jsx("div",{className:"form-field "+o.name,style:{verticalAlign:"bottom",width:(window.innerWidth>600?100/r.length:100)+"%",display:o.type=="hidden"?"none":"inline-block"},children:n(o)},Math.random()))},Math.random()))]})},Math.random()))}return a()}function _t(e){const n=Math.random();M.useEffect(()=>{e.data.autosubmit&&setInterval(h,e.data.autosubmit*1e3)},[]);function a(){const m={margin:0,color:T.colors.primary};return t.jsx("h1",{style:m,children:e.data.title})}function i(){return e.data.info&&t.jsx(K,{data:{text:e.data.info}})}function r(){if(e.data.display)return t.jsxs(t.Fragment,{children:[e.data.display.map(m=>t.jsx(g,{data:m},Math.random())),t.jsx("div",{style:{marginTop:30}})]})}function o(){return t.jsx(ye,{data:e.data})}function s(){return t.jsxs("div",{style:{marginTop:20,textAlign:"right"},children:[t.jsx(z,{onClick:d,label:"Cancelar",default:!0,display:"inline"}),t.jsx(z,{onClick:h,label:e.data.submit_label,primary:!0,display:"inline",icon:e.data.submit_icon,spin:!0})]})}function l(){return t.jsx("div",{id:"output",style:{marginTop:30}})}function c(){if(e.data.image)return t.jsx("div",{style:{margin:"auto",width:"100%",textAlign:"center"},children:t.jsx("img",{src:e.data.image})})}function u(){return t.jsxs("form",{id:n,className:e.data.key,action:e.data.url,style:{margin:"auto"},method:e.data.method,children:[t.jsx("div",{children:!1}),t.jsxs("div",{style:{padding:5},children:[a(),c(),i(),r(),o(),s(),l()]})]})}function d(){Z()}function h(m){m&&m.preventDefault();var x=e.data.url,b=document.getElementById(n),p=new FormData(b);if(b.method.toUpperCase()=="GET"){const B=x.indexOf("?")>=0?"&":"?";x=x+B+"form="+e.data.key+"&"+new URLSearchParams(p).toString(),p=null}e.data.autosubmit&&m==null&&(x+="&autosubmit=1"),O(b.method.toUpperCase(),x,function(j){if(b.querySelectorAll(".error").forEach(q=>q.style.display="none"),m&&m.target.dataset.spinning&&(m.target.querySelector("i.fa-spin").style.display="none",m.target.querySelector("i.fa-"+m.target.dataset.spinning).style.display="inline-block"),j.type=="response")if(j.store&&Me(j.store),j.redirect&&j.redirect.length>2)j.message&&localStorage.setItem("message",j.message),document.location.href=$(j.redirect);else if(j.message&&G(j.message),j.task){let q=function(){O("GET","/api/job/progress/"+j.task+"/",function(E){E==null||E.progress==100?m.target.innerHTML=v:(m.target.innerHTML="Aguarde... ("+(E.progress||0)+"%)",setTimeout(q,5e3))})};const v=m.target.innerHTML;m.target.innerHTML="Aguarde... (0%)",q()}else j.redirect==".."&&(document.getElementsByTagName("dialog").length==0?history.back():Z()),j.redirect=="."&&(document.getElementsByTagName("dialog").length==0?b.reset():Z()),j.dispose&&(b.style.display="none"),dt();else if(j.type=="error"){var D=j.text;console.log(j),Object.keys(j.errors).map(function(q){if(q=="__all__")D=j.errors[q];else{const v=b.querySelector("#"+q+"_error");v==null?D=q+":"+j.errors[q]:(v.querySelector("span").innerHTML=j.errors[q],v.style.display="block")}}),G(D,!0)}else if(j.type!="redirect"){const q=document.querySelector("#output");q.innerHTML="",Y.createRoot(q.appendChild(document.createElement("div"))).render(t.jsx(g,{data:j}))}},p)}return u()}function Wt(e){W(`
|
|
147
147
|
.calendar table{
|
|
148
148
|
width: 100%;
|
|
149
149
|
border-spacing: 0px;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import tempfile
|
|
3
|
+
from django.apps import apps
|
|
4
|
+
from django.core.files.storage import Storage
|
|
5
|
+
from django.conf import settings
|
|
6
|
+
from django.contrib.staticfiles.finders import AppDirectoriesFinder
|
|
7
|
+
from .s3 import Client
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
if USE_S3:
|
|
11
|
+
S3_URL = os.environ.get('S3_URL', 'https://api.minio.aplicativo.click/test3')
|
|
12
|
+
S3_ACCESS_KEY = os.environ.get('S3_ACCESS_KEY', 'admin')
|
|
13
|
+
S3_SECRET_KEY = os.environ.get('S3_SECRET_KEY', '')
|
|
14
|
+
STORAGES = {
|
|
15
|
+
"default": {"BACKEND": "slth.storage.S3Storage"},
|
|
16
|
+
"staticfiles": {"BACKEND": "slth.storage.StaticStorage"}
|
|
17
|
+
}
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
class File:
|
|
21
|
+
def __init__(self, client, name, mode='rb'):
|
|
22
|
+
self.client = client
|
|
23
|
+
self.name = name
|
|
24
|
+
self.mode = mode
|
|
25
|
+
|
|
26
|
+
def read(self):
|
|
27
|
+
content = self.client.get_object(self.name)
|
|
28
|
+
return content if 'b' in self.mode else content.decode()
|
|
29
|
+
|
|
30
|
+
def write(self, content):
|
|
31
|
+
content = content if 'b' in self.mode else content.encode()
|
|
32
|
+
return self.client.put_object(self.name, content)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class S3Storage(Storage):
|
|
36
|
+
|
|
37
|
+
def __init__(self):
|
|
38
|
+
url = settings.S3_URL
|
|
39
|
+
access_key = settings.S3_ACCESS_KEY
|
|
40
|
+
secret_key = settings.S3_SECRET_KEY
|
|
41
|
+
self.client = Client(url, access_key, secret_key)
|
|
42
|
+
|
|
43
|
+
def _open(self, name, mode='rb'):
|
|
44
|
+
return File(self.client, name, mode=mode)
|
|
45
|
+
|
|
46
|
+
def _save(self, name, content):
|
|
47
|
+
return self._open(name, mode='wb').write(content)
|
|
48
|
+
|
|
49
|
+
def path(self, name):
|
|
50
|
+
tmp_path = tempfile.mktemp()
|
|
51
|
+
with open(tmp_path, 'wb') as file:
|
|
52
|
+
file.write(self._open(name).read())
|
|
53
|
+
return tmp_path
|
|
54
|
+
|
|
55
|
+
def exists(self, name):
|
|
56
|
+
return bool(self.client.list_objects(name))
|
|
57
|
+
|
|
58
|
+
def delete(self, name):
|
|
59
|
+
self.client.delete_object(name)
|
|
60
|
+
|
|
61
|
+
def url(self, name):
|
|
62
|
+
return self.client.get_object(name, only_url=True)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class StaticStorage(S3Storage):
|
|
66
|
+
|
|
67
|
+
def url(self, name):
|
|
68
|
+
return f'{self.client.url}/static/{name}'
|
|
69
|
+
|
|
70
|
+
def collectstatic(self):
|
|
71
|
+
local = {}
|
|
72
|
+
finder = AppDirectoriesFinder()
|
|
73
|
+
ignore_patterns = ['CVS', '.*', '*~']
|
|
74
|
+
for name, storage in finder.list(ignore_patterns):
|
|
75
|
+
path = storage.path(name)
|
|
76
|
+
md5 = s3.md5(path)
|
|
77
|
+
local[f'static/{name}'] = dict(path=path, md5=md5, status=None)
|
|
78
|
+
remote = self.client.list_objects('static/')
|
|
79
|
+
print(remote)
|
|
80
|
+
for name, info in local.items():
|
|
81
|
+
md5 = remote.get(name)
|
|
82
|
+
if md5:
|
|
83
|
+
del remote[name]
|
|
84
|
+
if info['md5'] == md5:
|
|
85
|
+
info['status'] = 'equals'
|
|
86
|
+
else:
|
|
87
|
+
info['status'] = 'updated'
|
|
88
|
+
else:
|
|
89
|
+
info['status'] = 'created'
|
|
90
|
+
|
|
91
|
+
if info['status'] in ('created', 'updated'):
|
|
92
|
+
with open(info['path'], 'rb') as file:
|
|
93
|
+
self.open(name, 'wb').write(file.read())
|
|
94
|
+
|
|
95
|
+
print(name, info['status'])
|
|
96
|
+
for name in remote:
|
|
97
|
+
self.delete(name)
|
|
98
|
+
print(name, 'deleted')
|
|
99
|
+
return local
|