CoolFace
Apppublic

fmatituy/selectospromanager

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
sos_service.cpython-313.pyc334 linesDownload Raw Back to __pycache__
1�

2;��iW_��6�SSKJrJr SSKrSSKJr SSKrSrg)�)�ui�appN)�datetimec��^^^^	^3^�UU4Sjn[R"SUS9RS5n[R"SURS35 [R"S5 [R4"S5 [
5m5[R"5RS	5m	T	RS65 [R7"S5 T	 [R"S5RS
5mSSS5 UU	4SjmU8U4Sjn[R"SU5 g!,(df   N4=f![an[SU35 SnAgSnAff=f)z]9Initializes the SOS emergency system.10Separated from main layout to prevent global crashes.11c	���># �[R"SSS9IShv�NnU(d[R"SSSS9 gSnS	n[R"US12S9IShv�NnU(a)[U[5(aSU;aSUSS
US3n[[R"55nUT	T13[R"5RS5U[R"5S.n[[R R"R%S/55nUR'U5 U[R R"S'[R R"R)5 S[R R*;a/[R R*S'U[R R*S;a,[R R*SR'U5 [R"SSSSSSS9 gGN�GN�![14an[
SU35 SnAGN�SnAff=f![15an[
SU35 SnAgSnAff=f7f)Nzbreturn /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);g@��timeoutuZSOS BLOQUEADO: La activación de pánico solo está permitida desde dispositivos móviles.�warning�top��type�positionu�16                if (window.lastPreciseLocation) {17                    return window.lastPreciseLocation;18                }19                return new Promise((resolve, reject) => {20                    if (!navigator.geolocation) {21                        resolve({err: 'Geolocalización no soportada'});22                    } else {23                        navigator.geolocation.getCurrentPosition(24                            pos => resolve({lat: pos.coords.latitude, lng: pos.coords.longitude}),25                            err => resolve({err: err.message}),26                            { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }27                        );28                    }29                });30                u$Ubicación desconocida o GPS apagadog@�latzhttps://www.google.com/maps?q=�,�lngzSOS SERVICE - Geoloc error: z%H:%M:%S)�id�usuario�rol�hora�	ubicacion�	timestamp�
active_panics�my_active_panicsuA🚨 PÁNICO SOS ACTIVADO 🚨31Notificando centro de monitoreo...�negative�centeri�Tzfont-black p-4 text-center)r
rr	�32multi_line�classeszSOS SERVICE - Trigger error: )r�run_javascript�notify�33isinstance�dict�	Exception�print�str�uuid�uuid4r�now�strftime�time�listr�storage�general�get�append�update�user)�	is_mobile�loc_js�
location_text�res�ex�alarm_id�alarm�current_panics�e�user_nombre�user_rols         ���]C:\Users\faust\.gemini\antigravity\scratch\selectos_promanager\src\modules\sst\sos_service.py�
panic_trigger�&init_sos_system.<locals>.panic_trigger
s����:
;�"$�"3�"3�5Y�cf�#g�g�	� ��I�I�z�BK�V[�\���� !G�
�?� "� 1� 1�&�#� F�F�C��z�#�t�4�4��#��*H��U���TU�VY�Z_�V`�Ua�(b�
��t�z�z�|�,��"�*�#�$�L�L�N�3�3�J�?�!.�!%����
��"&�c�k�k�&9�&9�&=�&=�o�r�&R�!S���%�%�e�,�7E����#�#�O�4����#�#�*�*�,�%�S�[�[�-=�-=�=�;=�C�K�K�$�$�%7�8��3�;�;�#3�#3�4F�#G�G��K�K�$�$�%7�8�?�?��I��	�	�^�)�H�d�W[�">�@�ig�2G��!�?��8���=�>�>��?��6�
;��5�a�S�9�:�:��
;�s��I*�I�H�!I�I*�I�H�H�4H�FI�I*�I�H�34I�)H=�7I�=I�I�35I'�I"�I*�"I'�'I*�panic��on_click�hiddenzB36            <script>37                window.currentSosPanicId = "u�";38                39                if (!window.sosSystemInitialized) {40                    window.sosSystemInitialized = true;41                    42                    // Inject Styles43                    const style = document.createElement('style');44                    style.innerHTML = `45                        #sos-vol-bar {46                            position: fixed; top: 0; left: 0; height: 12px; width: 0%; 47                            background: linear-gradient(90deg, #ef4444, #f59e0b); 48                            z-index: 999999; transition: none; pointer-events: none;49                            box-shadow: 0 5px 20px rgba(239, 68, 68, 0.5);50                            display: none;51                        }52                        .sos-vol-active { display: block !important; width: 100% !important; transition: width 4s linear !important; }53                        .sos-vol-ready { background: #10b981 !important; transform: scaleY(1.5); }54                        55                        #sos-sent-overlay {56                            position: fixed; inset: 0; background: rgba(220, 38, 38, 0.95);57                            display: none; flex-direction: column; align-items: center; justify-content: center;58                            z-index: 1000000; color: white; padding: 2rem; text-align: center;59                        }60                    `;61                    document.head.appendChild(style);62                    63                    // Inject HTML Components64                    const bar = document.createElement('div'); bar.id = 'sos-vol-bar'; document.body.appendChild(bar);65                    const overlay = document.createElement('div'); overlay.id = 'sos-sent-overlay';66                    overlay.innerHTML = `67                        <div style="font-size: 80px; margin-bottom: 2rem;">🚑</div>68                        <h1 style="font-weight: 900; font-size: 2.5rem; letter-spacing: -2px; line-height: 1;">ALERTA TRANSMITIDA</h1>69                        <p style="margin-top: 1rem; font-weight: 700; opacity: 0.9; max-width: 300px;">SARA IA ha notificado al centro de monitoreo. Mantente a salvo, la ayuda va en camino.</p>70                        <button id="close-sos-sent" style="margin-top: 2rem; background: white; color: #dc2626; border: none; padding: 0.8rem 2rem; border-radius: 1rem; font-weight: 900; cursor: pointer;">CERRAR</button>71                    `;72                    document.body.appendChild(overlay);73                    document.getElementById('close-sos-sent').onclick = () => overlay.style.display = 'none';74 75                    // VOLUME TRIGGER ENGINE76                    let sosTimer = null;77                    let sosBar = bar;78                    79                    window.triggerSosSystem = function() {80                        const btn = document.getElementById(window.currentSosPanicId);81                        if(btn) btn.click();82                        document.getElementById('sos-sent-overlay').style.display = 'flex';83                        if ("vibrate" in navigator) navigator.vibrate([100, 50, 100, 50, 500]);84                    };85 86                    const startSosCheck = () => {87                        if (sosTimer) return;88                        sosBar.classList.add('sos-vol-active');89                        sosTimer = setTimeout(() => {90                            sosBar.classList.add('sos-vol-ready');91                            window.triggerSosSystem();92                            sosTimer = null;93                        }, 4000);94                    };95 96                    const cancelSosCheck = () => {97                        if (sosTimer) clearTimeout(sosTimer);98                        sosTimer = null;99                        sosBar.classList.remove('sos-vol-active', 'sos-vol-ready');100                    };101 102                    // Listen to Volume Changes103                    const k = document.createElement('audio'); 104                    k.id = 'sos_vol_listener';105                    document.body.appendChild(k);106                    107                    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {108                        k.onvolumechange = () => {109                             startSosCheck();110                             setTimeout(cancelSosCheck, 5000); // Auto-reset111                        };112                    }113                    114                    // Voice Commands (Sara SOS)115                    window.showHelpIsOnTheWay = () => {116                         if ('speechSynthesis' in window) {117                             const u = new SpeechSynthesisUtterance("He alertado al equipo médico. Mantén la calma, la ayuda está en camino.");118                             u.lang = 'es-ES';119                             window.speechSynthesis.speak(u);120                         }121                         ui.notify("SARA IA: Ayuda en camino", type='positive');122                    };123                }124            </script>125        uY126            <div id="sos-drawer-root" class="sos-drawer-container">127                <div id="sos-content" class="sos-content-wrapper shadow-2xl">128                    <div class="flex flex-col items-center justify-center gap-8 w-full h-full relative">129                        <div class="text-white text-center">130                            <div class="bg-white/10 w-16 h-16 rounded-full flex items-center justify-center mb-4 mx-auto border border-white/20 animate-pulse">131                                <span class="text-2xl">🆘</span>132                            </div>133                            <h2 class="text-2xl font-black tracking-tighter mb-1 uppercase">MODO PÁNICO</h2>134                            <p class="text-[10px] font-bold opacity-70 tracking-[0.2em] leading-none">MANTÉN PRESIONADO PARA ACTIVAR</p>135                        </div>136                        137                        <div id="sos-main-trigger" class="sos-btn-element cursor-pointer ring-offset-[10px] ring-offset-red-900 ring-4 ring-white/30">138                            <span class="text-white text-4xl font-black">SOS</span>139                        </div>140                        141                        <div class="bg-black/20 px-6 py-4 rounded-3xl border border-white/10 backdrop-blur-xl max-w-[260px]">142                            <p class="text-[11px] text-white/80 font-medium text-center leading-relaxed">143                                Se enviará su geolocalización en tiempo real y alerta de emergencia al equipo SST.144                            </p>145                        </div>146                        147                        <button id="sos-cancel" class="mt-4 text-white/30 font-black text-[9px] tracking-[0.4em] hover:text-white uppercase transition-all">148                            DESLIZAR PARA CERRAR →149                        </button>150                    </div>151                </div>152            </div>153            154            <div id="sos-side-handle" class="sos-side-handle">155                <div class="sos-handle-inner"></div>156            </div>157 158            <script>159                (function() {160                    const drawer = document.getElementById('sos-drawer-root');161                    const content = document.getElementById('sos-content');162                    const handle = document.getElementById('sos-side-handle');163                    const trigger = document.getElementById('sos-main-trigger');164                    const cancel = document.getElementById('sos-cancel');165                    let startX = 0;166                    let currentX = 0;167                    let isOpen = false;168 169                    const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);170                    if (!isMobile) {171                        drawer.style.display = 'none';172                        handle.style.display = 'none';173                        return;174                    }175 176                    const openDrawer = () => {177                        document.body.classList.add('drawer-open');178                        drawer.classList.add('active');179                        handle.classList.add('hidden-handle');180                        isOpen = true;181                    };182 183                    const closeDrawer = () => {184                        document.body.classList.remove('drawer-open');185                        drawer.classList.remove('active');186                        handle.classList.remove('hidden-handle');187                        isOpen = false;188                    };189 190                    // Swipe Detection (Right to Left)191                    handle.addEventListener('touchstart', (e) => {192                        startX = e.touches[0].clientX;193                    }, {passive: true});194 195                    handle.addEventListener('touchmove', (e) => {196                        currentX = e.touches[0].clientX;197                        if (!isOpen && startX - currentX > 40) {198                            openDrawer();199                        }200                    }, {passive: true});201 202                    // Swipe to Close (Left to Right)203                    content.addEventListener('touchstart', (e) => {204                        startX = e.touches[0].clientX;205                    }, {passive: true});206 207                    content.addEventListener('touchmove', (e) => {208                        currentX = e.touches[0].clientX;209                        if (isOpen && currentX - startX > 60) {210                            closeDrawer();211                        }212                    }, {passive: true});213 214                    handle.addEventListener('click', openDrawer);215                    cancel.onclick = closeDrawer;216 217                    // SOS Long Press218                    let pressTimer = null;219                    trigger.addEventListener('touchstart', (e) => {220                        e.preventDefault();221                        trigger.style.transform = 'scale(0.85)';222                        pressTimer = setTimeout(() => {223                            if(window.triggerSosSystem) window.triggerSosSystem();224                            closeDrawer();225                        }, 1500);226                    });227 228                    trigger.addEventListener('touchend', () => {229                        clearTimeout(pressTimer);230                        trigger.style.transform = 'scale(1)';231                    });232                })();233            </script>234        az	235            <style>236                .sos-side-handle {237                    position: fixed; top: 50%; right: 0; transform: translateY(-50%);238                    width: 24px; height: 80px; 239                    background: rgba(220, 38, 38, 0.4); 240                    backdrop-blur-sm; border-radius: 40px 0 0 40px;241                    border: 1.5px solid rgba(255, 255, 255, 0.15);242                    border-right: none; z-index: 100000;243                    display: flex; align-items: center; justify-content: center;244                    cursor: pointer; transition: all 0.3s;245                    box-shadow: -5px 0 20px rgba(0,0,0,0.1);246                }247                .sos-side-handle:active { background: rgba(220, 38, 38, 0.8); width: 32px; }248                .sos-handle-inner {249                    width: 4px; height: 30px; background: white; opacity: 0.6;250                    border-radius: 2px; margin-left: 2px;251                }252                .hidden-handle { opacity: 0; pointer-events: none; transform: translateY(-50%) translateX(100%); }253 254                .sos-drawer-container {255                    position: fixed; inset: 0; background: transparent;256                    pointer-events: none; z-index: 100001; transition: background 0.4s;257                }258                .sos-drawer-container.active { background: rgba(0,0,0,0.6); pointer-events: auto; }259                260                .sos-content-wrapper {261                    position: absolute; top: 0; right: 0; width: 85%; height: 100%;262                    background: linear-gradient(165deg, #7f1d1d 0%, #450a0a 100%);263                    transform: translateX(100%); transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);264                    border-left: 1px solid rgba(255,255,255,0.1);265                    display: flex; flex-direction: column;266                }267                .sos-drawer-container.active .sos-content-wrapper { transform: translateX(0); }268                269                .sos-btn-element {270                    width: 150px; height: 150px; border-radius: 50%;271                    background: #dc2626; border: 10px solid rgba(255,255,255,0.95);272                    display: flex; align-items: center; justify-content: center;273                    box-shadow: 0 0 60px rgba(220, 38, 38, 0.7);274                    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);275                }276            </style>277        z0bg-red-700 items-center justify-center z-[99999]z>persistent transition-show=fade transition-hide=fade maximizedaN278            <style>279                @keyframes alert-flash {280                    0% { background-color: #b91c1c; }281                    50% { background-color: #ef4444; }282                    100% { background-color: #b91c1c; }283                }284                .alert-fullscreen {285                    animation: alert-flash 0.5s infinite;286                    display: flex; flex-direction: column; align-items: center; justify-content: center;287                    width: 100vw; height: 100vh; padding: 2rem; margin: 0; box-sizing: border-box;288                }289            </style>290        �divzalert-fullscreenNc�>^�TR5 T Sn[R"STSSUS35 [R"SSSS	9R	S2915 [R292"S5R	S5 [R"5R	S
5 [R293"S5R	S5 [R"5R	S5 [R294"S5R	S5 [R295"TS5R	S5 SSS5 [R"5R	S5 [R296"S5R	S5 [R297"TS5R	S5 SSS5 ST;a�TSRS5(a{[R"5R	S5RSU4Sj5 [R"SSS9 [R298"S 5R	S!5 SSS5 UU4S"jn[R"S#US$9RS%5R	S&5 SSS5 SSS5 TR5 g!,(df   GN~=f!,(df   GN=f!,(df   N�=f!,(df   N\=f!,(df   Ne=f)'NzAhttps://assets.mixkit.co/active_storage/sfx/2869/2869-preview.mp3z<audio id="sfx_rz" autoplay loop><source src="z" type="audio/mpeg"></audio>�report_problem�120px�white)�size�colorzanimate-bounce mb-4u(🚨 EMERGENCIA: ACCIDENTE EN CURSO 🚨zVtext-5xl md:text-6xl font-black text-white mb-8 tracking-tighter text-center uppercasezbg-white/10 backdrop-blur-xl border-4 border-white/20 p-8 rounded-[2rem] max-w-2xl w-full flex flex-col items-center shadow-2xlzDETALLES DEL REPORTEzCtext-[12px] font-black tracking-[0.3em] text-red-200 mb-6 uppercasezZw-full justify-between items-center bg-black/20 p-6 rounded-2xl mb-4 border border-white/5z	PERSONAL:ztext-red-100 font-bold text-lgrz7text-white font-black text-2xl uppercase tracking-tightzHORA EXACTA:rztext-white font-black text-2xlrzhttps://z�w-full bg-white text-red-700 p-6 rounded-2xl mb-8 items-center justify-center gap-3 cursor-pointer hover:bg-red-50 transition-colors shadow-xl�clickc�F>�[RRTSSS9$)NrT)�new_tab)r�navigate�to)�ps�r<�<lambda>�<init_sos_system.<locals>.show_alarm_dialog.<locals>.<lambda>wsP���UW�U`�U`�Uc�Uc�de�fq�dr�|@�Uc�UA��location_on�md)rHuVER UBICACIÓN EN TIEMPO REALz-font-black text-xl tracking-tighter uppercasec�>�[R"STSS3SS9 TR5 [RR299R
S/5nTSU;aYURTS5 U[RR300S'[RR301R5 [R"SSS	S3029 g)Nz'const a = document.getElementById('sfx_rz'); if(a) a.pause();�@r�panics_acknowledgedu5✅ Confirmación enviada al emisor. Ayuda en camino.�positiverr)303rr�closerr+r,r-r.r/r)�current_ack�alarm_dialogrOs ��r<�confirmar_recepcion�Ginit_sos_system.<locals>.show_alarm_dialog.<locals>.confirmar_recepcion{s�����)�)�,S�TU�VZ�T[�S\�\p�*q�{~��$�*�*�,�&)�k�k�&9�&9�&=�&=�>S�UW�&X���T�7�+�5�'�.�.�q��w�7�IT�C�K�K�/�/�0E�F��K�K�/�/�6�6�8��	�	�"Y�`j�uz�{rRu#CONFIRMAR RECEPCIÓN Y ENVIAR AYUDAr@z?unelevated size=xl color=white text-color=red-7 hover:scale-105zLw-full rounded-2xl font-black tracking-widest py-6 shadow-2xl transition-all)
�clearr�html�iconr�label�card�row�304startswith�on�button�props�open)rO�	sound_urlr\�
alarm_contentr[s`  ��r<�show_alarm_dialog�*init_sos_system.<locals>.show_alarm_dialogbs|������!��_�	����/�!�D�'��2O�PY�{�Zv�w�x����(�w�g�F�N�N�Od�e����C�D�L�L�Nf�g��W�W�Y�&�&�(i�j��H�H�3�4�<�<�>C�D�����)�)�+G�H�����-�5�5�6V�W�����9��.�6�6�7p�q�H�����)�)�+G�H�����0�8�8�9Y�Z�����6��+�3�3�4T�U�H�#�a�'�A�k�N�,E�,E�j�,Q�,Q��V�V�X�-�-�/�@�C�C�DK�MA�B��G�G�M��=��H�H�%D�E�M�M�N}�~�B�305|��I�I�C�Na�b�h�h�jk�l�t�t�uC�D�9j��J
����7H�H��H�H��306B�B��j�j����sq�BK;�&A307K*�0AJ5�>,K*�*AK�8AK*�;K�AK*�K;�5308K�?K*�309K�K*�310K'�#K*�*311K8	�4K;�;312L	c�>�[RR(a)[RRR(dg[	[313RRRS/55n[	[314RRRS/55nSSK	nUR"5nUVs/sHoDRSU5US-315:�dMUPM! nn[U5[U5:waU[316RRS'UHKnUST317;dMUSU;dMT318RUS5 [R"SSS	S3199 T"U5 MM [320RRRS/5nU(a�[	U5n[	U5H[nX�;dM321[RRR(dM5[R"SS
S9 URU5 M] U[322RRS'ggs snf![ a:n	S[#U	5R%5;a['SU	35 Sn	A	gSn	A	gSn	A	ff=f)NrrWrri ru🚨 EMERGENCIA RECIBIDA 🚨rrrrz:if(window.showHelpIsOnTheWay) window.showHelpIsOnTheWay();rVrzparent slotzSOS MONITOR ERROR: )r�context�client�	connectedr*rr+r,r-r)�len�addrr0r�remover"r$�lowerr#)�panics�323panics_ackr)�current_timerO�valid_panics�	my_panics�
new_my_panics�my_pr9�local_alarms_seenrks          ��r<�check_alarms�%init_sos_system.<locals>.check_alarms�s����&
5��z�z�(�(��324�325�0A�0A�0K�0K���c�k�k�1�1�5�5�o�r�J�K��!�#�+�+�"5�"5�"9�"9�:O�QS�"T�U�326��#�y�y�{��+1�l�6�a�U�U�;��5U�Xd�gk�Xk�5k��6��l��v�;�#�l�"3�3�<H�S�[�[�(�(��9�%�A���w�&7�7��T�7�*�4�.�2�2�1�T�7�;��Y�Y�'F�Z�bj�k�.�q�1�&� �K�K�,�,�0�0�1C�R�H�	��$(��O�M� $�]� 3���-�!�z�z�0�0�:�:�:� "� 1� 1�2n�x{� |� -� 4� 4�T� :�	!4�327<I�C�K�K�$�$�%7�8��� m��.�
5� ��A�����6��/��s�3�4�4�7��
5�sR�AI�A?I�H>�+H>�1AI�8I�BI�328'I�5AI�>I�329J�
+J�JrVzCRITICAL SOS SYSTEM ERROR: )
rrfr�
add_body_htmlr�
add_head_html�set�dialogrg�element�timerr"r#)r:r;�330is_tecnico�is_manager_funcr=�hidden_panicr}r9rjr[r|rks``      @@@@r<�init_sos_systemr�s:���331n1�;	;�|�y�y��=�A�I�I�(�S��	���-�-9�_�_�,=�X>	�Z�Z	
�z	���m�m	
�`	���+�+	
�^ �E���y�y�{�*�*�+]�^�����[�\�332���
�
	
���J�J�u�-�5�5�6H�I�M��'	 �R'	5�V	����l�#�o�\��r�1�
�+�A�3�/�0�0��1�s0�CD?�&D.�-D?�.333D<�8D?�?334E!�	E�E!)�niceguirrr%rr)r��rRr<�<module>r�s������s1rR