@cat-of-summer/st-script 1.0.2
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.
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/app/form.esm.min.js +1 -0
- package/dist/app/form.min.js +2 -0
- package/dist/app.esm.min.js +1 -0
- package/dist/app.min.js +2 -0
- package/dist/cookie.esm.min.js +1 -0
- package/dist/cookie.min.js +2 -0
- package/dist/core.esm.min.js +1 -0
- package/dist/core.min.js +2 -0
- package/dist/index.esm.min.js +1 -0
- package/dist/index.min.js +2 -0
- package/dist/loader.esm.min.js +1 -0
- package/dist/loader.min.js +2 -0
- package/dist/modal.esm.min.js +1 -0
- package/dist/modal.min.js +2 -0
- package/dist/route.esm.min.js +1 -0
- package/dist/route.min.js +2 -0
- package/dist/select.esm.min.js +1 -0
- package/dist/select.min.js +2 -0
- package/dist/st_button_widget.esm.min.js +1 -0
- package/dist/st_button_widget.min.js +2 -0
- package/dist/st_links_widget.esm.min.js +1 -0
- package/dist/st_links_widget.min.js +2 -0
- package/dist/st_mask.esm.min.js +1 -0
- package/dist/st_mask.min.js +2 -0
- package/dist/st_observer.esm.min.js +1 -0
- package/dist/st_observer.min.js +2 -0
- package/dist/st_typograf.esm.min.js +1 -0
- package/dist/st_typograf.min.js +2 -0
- package/dist/st_validator.esm.min.js +1 -0
- package/dist/st_validator.min.js +2 -0
- package/dist/toggle.esm.min.js +1 -0
- package/dist/toggle.min.js +2 -0
- package/dist/uploader.esm.min.js +1 -0
- package/dist/uploader.min.js +2 -0
- package/package.json +35 -0
- package/src/_traits/hasInstanceSymbol.js +29 -0
- package/src/app/form/index.js +357 -0
- package/src/app/index.js +1040 -0
- package/src/cookie/index.js +141 -0
- package/src/core/index.js +159 -0
- package/src/index.js +16 -0
- package/src/loader/index.js +169 -0
- package/src/modal/index.js +297 -0
- package/src/route/index.js +208 -0
- package/src/select/index.js +210 -0
- package/src/st_button_widget/README.txt +62 -0
- package/src/st_button_widget/index.js +322 -0
- package/src/st_links_widget/README.txt +54 -0
- package/src/st_links_widget/index.js +294 -0
- package/src/st_mask/index.js +183 -0
- package/src/st_observer/index.js +426 -0
- package/src/st_typograf/index.js +200 -0
- package/src/st_validator/index.js +57 -0
- package/src/toggle/index.js +181 -0
- package/src/uploader/index.js +297 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cat-of-summer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# ST-script
|
|
2
|
+
|
|
3
|
+
Standalone JavaScript classes / components, authored as ES modules and shipped in
|
|
4
|
+
two flavours per module:
|
|
5
|
+
|
|
6
|
+
- **ESM** (`*.esm.min.js`) — for `import` (npm bundlers, `<script type="module">`).
|
|
7
|
+
- **IIFE / global** (`*.min.js`) — for a plain CDN `<script defer>` (exposes a
|
|
8
|
+
global named after the module).
|
|
9
|
+
|
|
10
|
+
| Module | Global / element | Notes |
|
|
11
|
+
| --------------------- | ------------------- | ------------------------------------------------ |
|
|
12
|
+
| `st_modal` | `window.st_modal` | Modal windows. |
|
|
13
|
+
| `st_typograf` | `window.st_typograf`| Typography fixer. |
|
|
14
|
+
| `st_cookie` | `window.st_cookie` | Cookie helpers. |
|
|
15
|
+
| `st_system` | `window.st_system` | Utilities (`merge`, `generate_*`). |
|
|
16
|
+
| `st_observer` | `window.st_observer`| IntersectionObserver wrapper. |
|
|
17
|
+
| `toggle` | `window.toggle` | State toggler (accordions, switches, hover-menus).|
|
|
18
|
+
| `select` | `window.select` | Custom `<select>` dropdown (hooks, multiple, hover).|
|
|
19
|
+
| `st_mask` | `window.st_mask` | Input masks. |
|
|
20
|
+
| `uploader` | `window.uploader` | File uploader. |
|
|
21
|
+
| `st_validator` | `window.st_validator`| Form/field validation. |
|
|
22
|
+
| `st_button_widget` | `window.st_button_widget`| Floating button widget. |
|
|
23
|
+
| `st_links_widget` | `window.st_links_widget`| Links widget. |
|
|
24
|
+
| `loader` | `window.loader` | Ajax list loader (cards: подгрузка/фильтр/сортировка) via `Core.fetch`. |
|
|
25
|
+
| `st_app` | `<st-app>` element | **Web Component** — `<script defer>` only (self-registers). |
|
|
26
|
+
| `st_app/form` | `window.form` | Form app **config object** — register with `App.create(form)`; no `st_app` bundled. |
|
|
27
|
+
|
|
28
|
+
> `st_widget` / `st_widget/button` are work-in-progress stubs (no output yet).
|
|
29
|
+
|
|
30
|
+
## Development
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install # installs esbuild, builds dist/ via the prepare script
|
|
34
|
+
npm run build # compile src/ → dist/*.min.js (ESM + IIFE)
|
|
35
|
+
npm run watch # rebuild on change
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Source layout — **every `src/**/index.js` is a bundle**; its folder path becomes
|
|
39
|
+
the output name:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
src/
|
|
43
|
+
index.js # aggregate barrel → re-exports every module
|
|
44
|
+
st_modal/index.js # → dist/st_modal.esm.min.js + dist/st_modal.min.js
|
|
45
|
+
st_app/index.js # → dist/st_app.{esm.min,min}.js
|
|
46
|
+
st_app/form/index.js # → dist/st_app/form.{esm.min,min}.js
|
|
47
|
+
…
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Conventions** (`scripts/build.mjs` relies on these — no script edits to extend):
|
|
51
|
+
|
|
52
|
+
- A folder with an `index.js` is a *bundle*; drop `src/<name>/index.js` and it is
|
|
53
|
+
built automatically into `dist/<name>.esm.min.js` (ESM) and `dist/<name>.min.js`
|
|
54
|
+
(IIFE global, default export unwrapped onto `window.<name>`).
|
|
55
|
+
- A file or folder whose name starts with `_` is shared content (a partial),
|
|
56
|
+
imported via `import` and never built on its own.
|
|
57
|
+
|
|
58
|
+
`dist/` is generated and git-ignored. It is built on `npm install` (`prepare`),
|
|
59
|
+
on `npm publish` (`prepack`), and in CI to attach release artifacts.
|
|
60
|
+
|
|
61
|
+
## A. Use via npm
|
|
62
|
+
|
|
63
|
+
Пакет опубликован в GitHub Packages (приватный реестр). Для установки нужен
|
|
64
|
+
read-only токен GitHub.
|
|
65
|
+
|
|
66
|
+
### 1. Получить токен
|
|
67
|
+
|
|
68
|
+
GitHub → Settings → Developer settings → Fine-grained personal access tokens → Generate new token:
|
|
69
|
+
|
|
70
|
+
- **Repository access**: `cat-of-summer/ST-script---framework`
|
|
71
|
+
- **Permissions**: `read:packages`
|
|
72
|
+
|
|
73
|
+
### 2. Скопировать `.npmrc` в проект потребителя
|
|
74
|
+
|
|
75
|
+
Скопируйте файл `.npmrc` из корня этого репозитория к себе в проект — токен уже вписан.
|
|
76
|
+
|
|
77
|
+
### 3. Установить
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm install @cat-of-summer/st-script
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 4. Использовать
|
|
84
|
+
|
|
85
|
+
Per-module (рекомендуется — только то, что нужно):
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import st_modal from '@cat-of-summer/st-script/st_modal';
|
|
89
|
+
import st_typograf from '@cat-of-summer/st-script/st_typograf';
|
|
90
|
+
|
|
91
|
+
const modal = new st_modal({ content: '#promo', overlay: true });
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Или весь пакет через barrel-экспорт:
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
import { st_modal, st_cookie, App } from '@cat-of-summer/st-script';
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Web Component регистрирует себя при импорте:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
import App from '@cat-of-summer/st-script/st_app';
|
|
104
|
+
import formConfig from '@cat-of-summer/st-script/st_app/form';
|
|
105
|
+
App.create(formConfig); // теперь работает <st-app app="form">
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Releasing
|
|
109
|
+
|
|
110
|
+
Releases are triggered by **pushing a tag** (not by ordinary pushes):
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# bump "version" in package.json, commit, then:
|
|
114
|
+
git tag v0.1.0
|
|
115
|
+
git push origin v0.1.0
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`.github/workflows/release.yml` builds `dist/` and creates a GitHub Release with
|
|
119
|
+
the configured artifacts. Ordinary pushes run `ci.yml`, which validates the build.
|
|
120
|
+
Both are driven by repository **environment variables** (Settings → Environments
|
|
121
|
+
→ your branch):
|
|
122
|
+
|
|
123
|
+
- `BUILD_COMMAND` = `npm ci && npm run build`
|
|
124
|
+
- `RELEASE_FILES` = `dist/*` (files attached to the release)
|
|
125
|
+
- `CI_COMMAND` (optional) — extra checks/tests in CI.
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
See `examples/` for runnable HTML pages. `examples/cdn-demo.html` exercises both
|
|
130
|
+
the ESM and the IIFE/global builds from `dist/`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=class{static merge(...e){let s=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&(Object.getPrototypeOf(t)??Object.prototype)===Object.prototype,n=(t,o)=>{if(typeof t=="function"&&typeof o=="function")return(...a)=>n(t(...a),o(...a));if(!(Array.isArray(t)&&Array.isArray(o)||s(t)&&s(o)))return o;let d=Array.isArray(t)?t.slice():{...t};for(let[a,u]of Object.entries(o))d[a]=a in d?n(d[a],u):u;return d};return e.reduce(n,{})}static generate_unique_prefix(e){return e={characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",length:16,...e},[...Array(e.length)].map(s=>e.characters[Math.random()*e.characters.length|0]).join("")}static fetch(e){e instanceof HTMLFormElement&&(e={url:e.getAttribute("action")||"",method:e.getAttribute("method")||"",data:new FormData(e)}),e={url:"",method:"",data:null,headers:{},timeout:0,response_type:"",...e};let s={beforeSend:[e.before_send],onSend:[e.on_send],onSuccess:[e.on_success],onComplete:[e.on_complete],onFailed:[e.on_failed]},n,t,o,d=!1,a=new Promise((i,c)=>(t=i,o=c)),u=(i,c)=>{for(let h of s[i])if(h)try{h(c)}catch(f){console.error(`st_ajax: ${i} error`,f)}},l={then:(i,c)=>a.then(i,c),catch:i=>a.catch(i),finally:i=>a.finally(i),abort:()=>n?.abort()};for(let i of Object.keys(s))l[i]=c=>(s[i].push(c),l);let p=i=>{if(d)return;d=!0;let c=i instanceof XMLHttpRequest?{status:i.status,status_text:i.statusText,response:i.responseText,request:i}:{status:void 0,status_text:"",response:i};u("onFailed",c),o(c)};return queueMicrotask(()=>{try{let i=e.url,c=e.method,h;if(u("beforeSend",e),e.data instanceof FormData?h=e.data:e.data instanceof HTMLFormElement?(i=i||e.data.getAttribute("action"),c=c||e.data.getAttribute("method"),h=new FormData(e.data)):h=e.data,i=i||window.location.href,c=c?c.toUpperCase():"GET",h&&typeof h=="object")if(c=="GET"){let f=h instanceof FormData?new URLSearchParams(h).toString():Object.entries(h).map(([y,b])=>`${encodeURIComponent(y)}=${encodeURIComponent(b)}`).join("&");f&&(i+=(/\?.+=/.test(i)?"&":"?")+f),h=null}else h instanceof FormData||(h=JSON.stringify(e.data),Object.keys(e.headers).some(f=>f.toLowerCase()=="content-type")||(e.headers["Content-Type"]="application/json"));if(n=new XMLHttpRequest,e.response_type)try{n.responseType=e.response_type}catch{}e.timeout>0&&Number.isFinite(e.timeout)&&(n.timeout=e.timeout),n.onerror=n.ontimeout=()=>p(n),n.onreadystatechange=()=>{if(n.readyState!==4)return;let f;if(n.status>=200&&n.status<300){if(n.responseType)f=n.response;else{let y=n.getResponseHeader("Content-Type")||e.response_type||"";if(y.includes("/json"))try{f=JSON.parse(n.responseText)}catch{f=n.responseText}else y.includes("/xml")?f=new DOMParser().parseFromString(n.responseText,"application/xml"):y.includes("/html")?f=new DOMParser().parseFromString(n.responseText,"text/html"):f=n.responseText}u("onSuccess",{data:f,request:n}),d=!0,t({data:f,request:n})}else p(n);u("onComplete",{data:f,request:n})},n.open(c,i,!0);for(let f in e.headers)if(Object.prototype.hasOwnProperty.call(e.headers,f))try{n.setRequestHeader(f,e.headers[f])}catch{}n.send(h),u("onSend",{detail:e})}catch(i){p(i)}}),l}};var E={app:"form",action:null,method:null,headers:null,validators:{},validate(r){this.validators={...this.validators,...r}},configure(r){let e=this;e.addEventListener("setup",()=>{if(r.validate&&e.validate(r.validate),r.form)for(let[s,n]of Object.entries(r.form))e.addEventListener(`form:${s}`,n);if(r.field)for(let[s,n]of Object.entries(r.field))e.addEventListener(`field:${s}`,n)}),r.setup&&(e.form?queueMicrotask(r.setup.bind(e)):e.addEventListener("rendered",r.setup.bind(e),{once:!0}))},setup(){this._validators=new WeakMap},events:{rendered:function(){let r=this;if(!(r._form=r.querySelector("form")))return console.error("form: <form> not found");r.form.querySelector("input[type=file]")&&(r.form.enctype="multipart/form-data"),r.action&&(r.form.action=r.action),r.method&&(r.form.method=r.method),r.form.app=r,r.form.addEventListener("input",e=>{let s=e.target;s.name&&(r._validators.has(s)&&s.setCustomValidity(""),r.dispatchEvent("field:input",{field:s,name:s.name,value:s.type==="checkbox"?s.checked:s.value},{bubbles:!0}))}),r.form.addEventListener("focus",e=>{let s=e.target;s.name&&r.dispatchEvent("field:focus",{field:s,name:s.name,value:s.type==="checkbox"?s.checked:s.value},{bubbles:!0})},!0),r.form.addEventListener("invalid",e=>{let s=e.target;r.dispatchEvent("field:invalid",{field:s,name:s.name||s.id||null,value:s.type==="checkbox"?s.checked:s.value},{bubbles:!0})||e.preventDefault()},!0),r.form.addEventListener("submit",e=>{e.preventDefault(),r._submit()}),r.watch("validators",e=>{if(r.form)for(let[s,n]of Object.entries(e))r.fields(s).forEach(t=>{if(r._validators.set(t,n),t.__validatorPatched)return;t.__validatorPatched=!0;let o=t.checkValidity.bind(t),d=t.reportValidity.bind(t);t.checkValidity=()=>{let a=r._validators.get(t);if(a){let u=a(t);t.setCustomValidity(u||"")}return o()},t.reportValidity=()=>(t.checkValidity(),d())})},{immediate:!0})}},get form(){return this._form},fields(r=null){return r?r.includes(" ")||r.includes("#")||r.includes(".")||r.includes("[")||r.includes(">")||r.includes(":")?this.form.querySelectorAll(r):this.form.querySelectorAll(`[name="${CSS.escape(r)}"]`):Array.from(this.form.elements)},field(r){let e=this.fields(r);return e.length?e[0]:null},appendField(r,e,s={}){let{tag:n="input",...t}=s,o=this.field(r);if(o){Object.assign(o,{...t,value:e});return}o=document.createElement(n),Object.assign(o,{type:"hidden",...t,name:r,value:e}),this.form.appendChild(o)},removeField(r){let e=this.field(r);if(!e)return;let s=e.id||r,n=this.form.querySelector(`label[for="${s}"]`)||e.closest("label");n&&n.remove(),e.remove()},resetField(r){let e=Array.from(this.fields(r));if(!e.length)return;let s=e.every(o=>o.type==="checkbox"),n=e.every(o=>o.type==="radio"),t=e.every(o=>o.type==="file");s||n?e.forEach(o=>{o.checked=!1}):t?e.forEach(o=>{o.value=""}):e.length===1&&e[0].multiple?Array.from(e[0].options).forEach(o=>{o.selected=!1}):e[0].value=""},reset(){this.form.reset(),this.dispatchEvent("form:reset")},fill(r){let e=this,s=(n,t)=>{let o=d=>{let a=new DataTransfer;a.items.add(d),n.files=a.files};if(t instanceof File){o(t);return}if(typeof t=="string"&&t.startsWith("data:")){let[d,a]=t.split(","),u=d.match(/:(.*?);/)?.[1]||"application/octet-stream",l=atob(a),p=new Uint8Array(l.length);for(let c=0;c<l.length;c++)p[c]=l.charCodeAt(c);let i=new Blob([p],{type:u});o(new File([i],"file",{type:u}));return}if(typeof t=="string"){let d=t.split("/").pop().split("?")[0]||"file";fetch(t).then(a=>a.blob()).then(a=>o(new File([a],d,{type:a.type}))).catch(()=>{})}};for(let[n,t]of Object.entries(r)){let o=Array.from(e.fields(n));if(!o.length)continue;let d=o.every(l=>l.type==="file"),a=o.every(l=>l.type==="checkbox"),u=o.every(l=>l.type==="radio");if(d){let l=Array.isArray(t)?t:[t];o.forEach((p,i)=>{let c=l[i]!==void 0?l[i]:l[0];c!=null&&s(p,c)})}else if(a)o.forEach(l=>{typeof t=="boolean"?l.checked=t:Array.isArray(t)?l.checked=t.map(String).includes(l.value):l.checked=String(l.value)===String(t)});else if(u)o.forEach(l=>{l.checked=String(l.value)===String(t)});else if(o.length===1&&o[0].multiple&&Array.isArray(t)){let l=o[0];Array.from(l.options).forEach(p=>{p.selected=t.map(String).includes(p.value)})}else Array.isArray(t)?o.forEach((l,p)=>{t[p]!==void 0&&(l.value=t[p])}):o[0].value=t??""}},hide(){this.style.display="none"},show(){this.style.display=""},_submit(){let r=this,e=r.form,s=r.fields();s.forEach(t=>{r._validators.has(t)&&t.setCustomValidity("")}),s.forEach(t=>{if(!r._validators.has(t))return;let o=r._validators.get(t)(t);t.setCustomValidity(o||"")});let n={};if(s.forEach(t=>{if(!t.validity.valid){let o=t.name||t.id||null;o&&(n[o]=t.validationMessage)}}),Object.keys(n).length){r.dispatchEvent("form:invalid",{errors:n},{bubbles:!0})&&e.reportValidity();return}r._send()},_send(){let r=this,e=r.form,s={url:r.action||e.getAttribute("action")||window.location.href,method:r.method||e.getAttribute("method")||"GET",headers:r.headers||{},data:new FormData(e)};r.dispatchEvent("form:before_send",s,{bubbles:!0});let n=!1;m.fetch(s).onSend(({detail:t})=>{r.dispatchEvent("form:send",{detail:t},{bubbles:!0})}).onSuccess(({data:t,request:o})=>{if(t&&typeof t=="object"&&t.redirect){n=!0;let d=r.dispatchEvent("form:redirect",{url:t.redirect,data:t,request:o},{bubbles:!0});r.dispatchEvent("form:complete",{data:t,request:o},{bubbles:!0}),d&&(window.location.href=t.redirect);return}r.dispatchEvent("form:success",{data:t,request:o},{bubbles:!0})}).onFailed(t=>{r.dispatchEvent("form:failed",t,{bubbles:!0})}).onComplete(({data:t,request:o})=>{n||r.dispatchEvent("form:complete",{data:t,request:o},{bubbles:!0})})}};export{E as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var form=(()=>{var b=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var s in e)b(r,s,{get:e[s],enumerable:!0})},S=(r,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of E(e))!_.call(r,t)&&t!==s&&b(r,t,{get:()=>e[t],enumerable:!(o=g(e,t))||o.enumerable});return r};var k=r=>S(b({},"__esModule",{value:!0}),r);var j={};A(j,{default:()=>F});var m=class{static merge(...e){let s=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&(Object.getPrototypeOf(t)??Object.prototype)===Object.prototype,o=(t,n)=>{if(typeof t=="function"&&typeof n=="function")return(...a)=>o(t(...a),n(...a));if(!(Array.isArray(t)&&Array.isArray(n)||s(t)&&s(n)))return n;let d=Array.isArray(t)?t.slice():{...t};for(let[a,u]of Object.entries(n))d[a]=a in d?o(d[a],u):u;return d};return e.reduce(o,{})}static generate_unique_prefix(e){return e={characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",length:16,...e},[...Array(e.length)].map(s=>e.characters[Math.random()*e.characters.length|0]).join("")}static fetch(e){e instanceof HTMLFormElement&&(e={url:e.getAttribute("action")||"",method:e.getAttribute("method")||"",data:new FormData(e)}),e={url:"",method:"",data:null,headers:{},timeout:0,response_type:"",...e};let s={beforeSend:[e.before_send],onSend:[e.on_send],onSuccess:[e.on_success],onComplete:[e.on_complete],onFailed:[e.on_failed]},o,t,n,d=!1,a=new Promise((i,c)=>(t=i,n=c)),u=(i,c)=>{for(let h of s[i])if(h)try{h(c)}catch(f){console.error(`st_ajax: ${i} error`,f)}},l={then:(i,c)=>a.then(i,c),catch:i=>a.catch(i),finally:i=>a.finally(i),abort:()=>o?.abort()};for(let i of Object.keys(s))l[i]=c=>(s[i].push(c),l);let p=i=>{if(d)return;d=!0;let c=i instanceof XMLHttpRequest?{status:i.status,status_text:i.statusText,response:i.responseText,request:i}:{status:void 0,status_text:"",response:i};u("onFailed",c),n(c)};return queueMicrotask(()=>{try{let i=e.url,c=e.method,h;if(u("beforeSend",e),e.data instanceof FormData?h=e.data:e.data instanceof HTMLFormElement?(i=i||e.data.getAttribute("action"),c=c||e.data.getAttribute("method"),h=new FormData(e.data)):h=e.data,i=i||window.location.href,c=c?c.toUpperCase():"GET",h&&typeof h=="object")if(c=="GET"){let f=h instanceof FormData?new URLSearchParams(h).toString():Object.entries(h).map(([y,v])=>`${encodeURIComponent(y)}=${encodeURIComponent(v)}`).join("&");f&&(i+=(/\?.+=/.test(i)?"&":"?")+f),h=null}else h instanceof FormData||(h=JSON.stringify(e.data),Object.keys(e.headers).some(f=>f.toLowerCase()=="content-type")||(e.headers["Content-Type"]="application/json"));if(o=new XMLHttpRequest,e.response_type)try{o.responseType=e.response_type}catch{}e.timeout>0&&Number.isFinite(e.timeout)&&(o.timeout=e.timeout),o.onerror=o.ontimeout=()=>p(o),o.onreadystatechange=()=>{if(o.readyState!==4)return;let f;if(o.status>=200&&o.status<300){if(o.responseType)f=o.response;else{let y=o.getResponseHeader("Content-Type")||e.response_type||"";if(y.includes("/json"))try{f=JSON.parse(o.responseText)}catch{f=o.responseText}else y.includes("/xml")?f=new DOMParser().parseFromString(o.responseText,"application/xml"):y.includes("/html")?f=new DOMParser().parseFromString(o.responseText,"text/html"):f=o.responseText}u("onSuccess",{data:f,request:o}),d=!0,t({data:f,request:o})}else p(o);u("onComplete",{data:f,request:o})},o.open(c,i,!0);for(let f in e.headers)if(Object.prototype.hasOwnProperty.call(e.headers,f))try{o.setRequestHeader(f,e.headers[f])}catch{}o.send(h),u("onSend",{detail:e})}catch(i){p(i)}}),l}};var F={app:"form",action:null,method:null,headers:null,validators:{},validate(r){this.validators={...this.validators,...r}},configure(r){let e=this;e.addEventListener("setup",()=>{if(r.validate&&e.validate(r.validate),r.form)for(let[s,o]of Object.entries(r.form))e.addEventListener(`form:${s}`,o);if(r.field)for(let[s,o]of Object.entries(r.field))e.addEventListener(`field:${s}`,o)}),r.setup&&(e.form?queueMicrotask(r.setup.bind(e)):e.addEventListener("rendered",r.setup.bind(e),{once:!0}))},setup(){this._validators=new WeakMap},events:{rendered:function(){let r=this;if(!(r._form=r.querySelector("form")))return console.error("form: <form> not found");r.form.querySelector("input[type=file]")&&(r.form.enctype="multipart/form-data"),r.action&&(r.form.action=r.action),r.method&&(r.form.method=r.method),r.form.app=r,r.form.addEventListener("input",e=>{let s=e.target;s.name&&(r._validators.has(s)&&s.setCustomValidity(""),r.dispatchEvent("field:input",{field:s,name:s.name,value:s.type==="checkbox"?s.checked:s.value},{bubbles:!0}))}),r.form.addEventListener("focus",e=>{let s=e.target;s.name&&r.dispatchEvent("field:focus",{field:s,name:s.name,value:s.type==="checkbox"?s.checked:s.value},{bubbles:!0})},!0),r.form.addEventListener("invalid",e=>{let s=e.target;r.dispatchEvent("field:invalid",{field:s,name:s.name||s.id||null,value:s.type==="checkbox"?s.checked:s.value},{bubbles:!0})||e.preventDefault()},!0),r.form.addEventListener("submit",e=>{e.preventDefault(),r._submit()}),r.watch("validators",e=>{if(r.form)for(let[s,o]of Object.entries(e))r.fields(s).forEach(t=>{if(r._validators.set(t,o),t.__validatorPatched)return;t.__validatorPatched=!0;let n=t.checkValidity.bind(t),d=t.reportValidity.bind(t);t.checkValidity=()=>{let a=r._validators.get(t);if(a){let u=a(t);t.setCustomValidity(u||"")}return n()},t.reportValidity=()=>(t.checkValidity(),d())})},{immediate:!0})}},get form(){return this._form},fields(r=null){return r?r.includes(" ")||r.includes("#")||r.includes(".")||r.includes("[")||r.includes(">")||r.includes(":")?this.form.querySelectorAll(r):this.form.querySelectorAll(`[name="${CSS.escape(r)}"]`):Array.from(this.form.elements)},field(r){let e=this.fields(r);return e.length?e[0]:null},appendField(r,e,s={}){let{tag:o="input",...t}=s,n=this.field(r);if(n){Object.assign(n,{...t,value:e});return}n=document.createElement(o),Object.assign(n,{type:"hidden",...t,name:r,value:e}),this.form.appendChild(n)},removeField(r){let e=this.field(r);if(!e)return;let s=e.id||r,o=this.form.querySelector(`label[for="${s}"]`)||e.closest("label");o&&o.remove(),e.remove()},resetField(r){let e=Array.from(this.fields(r));if(!e.length)return;let s=e.every(n=>n.type==="checkbox"),o=e.every(n=>n.type==="radio"),t=e.every(n=>n.type==="file");s||o?e.forEach(n=>{n.checked=!1}):t?e.forEach(n=>{n.value=""}):e.length===1&&e[0].multiple?Array.from(e[0].options).forEach(n=>{n.selected=!1}):e[0].value=""},reset(){this.form.reset(),this.dispatchEvent("form:reset")},fill(r){let e=this,s=(o,t)=>{let n=d=>{let a=new DataTransfer;a.items.add(d),o.files=a.files};if(t instanceof File){n(t);return}if(typeof t=="string"&&t.startsWith("data:")){let[d,a]=t.split(","),u=d.match(/:(.*?);/)?.[1]||"application/octet-stream",l=atob(a),p=new Uint8Array(l.length);for(let c=0;c<l.length;c++)p[c]=l.charCodeAt(c);let i=new Blob([p],{type:u});n(new File([i],"file",{type:u}));return}if(typeof t=="string"){let d=t.split("/").pop().split("?")[0]||"file";fetch(t).then(a=>a.blob()).then(a=>n(new File([a],d,{type:a.type}))).catch(()=>{})}};for(let[o,t]of Object.entries(r)){let n=Array.from(e.fields(o));if(!n.length)continue;let d=n.every(l=>l.type==="file"),a=n.every(l=>l.type==="checkbox"),u=n.every(l=>l.type==="radio");if(d){let l=Array.isArray(t)?t:[t];n.forEach((p,i)=>{let c=l[i]!==void 0?l[i]:l[0];c!=null&&s(p,c)})}else if(a)n.forEach(l=>{typeof t=="boolean"?l.checked=t:Array.isArray(t)?l.checked=t.map(String).includes(l.value):l.checked=String(l.value)===String(t)});else if(u)n.forEach(l=>{l.checked=String(l.value)===String(t)});else if(n.length===1&&n[0].multiple&&Array.isArray(t)){let l=n[0];Array.from(l.options).forEach(p=>{p.selected=t.map(String).includes(p.value)})}else Array.isArray(t)?n.forEach((l,p)=>{t[p]!==void 0&&(l.value=t[p])}):n[0].value=t??""}},hide(){this.style.display="none"},show(){this.style.display=""},_submit(){let r=this,e=r.form,s=r.fields();s.forEach(t=>{r._validators.has(t)&&t.setCustomValidity("")}),s.forEach(t=>{if(!r._validators.has(t))return;let n=r._validators.get(t)(t);t.setCustomValidity(n||"")});let o={};if(s.forEach(t=>{if(!t.validity.valid){let n=t.name||t.id||null;n&&(o[n]=t.validationMessage)}}),Object.keys(o).length){r.dispatchEvent("form:invalid",{errors:o},{bubbles:!0})&&e.reportValidity();return}r._send()},_send(){let r=this,e=r.form,s={url:r.action||e.getAttribute("action")||window.location.href,method:r.method||e.getAttribute("method")||"GET",headers:r.headers||{},data:new FormData(e)};r.dispatchEvent("form:before_send",s,{bubbles:!0});let o=!1;m.fetch(s).onSend(({detail:t})=>{r.dispatchEvent("form:send",{detail:t},{bubbles:!0})}).onSuccess(({data:t,request:n})=>{if(t&&typeof t=="object"&&t.redirect){o=!0;let d=r.dispatchEvent("form:redirect",{url:t.redirect,data:t,request:n},{bubbles:!0});r.dispatchEvent("form:complete",{data:t,request:n},{bubbles:!0}),d&&(window.location.href=t.redirect);return}r.dispatchEvent("form:success",{data:t,request:n},{bubbles:!0})}).onFailed(t=>{r.dispatchEvent("form:failed",t,{bubbles:!0})}).onComplete(({data:t,request:n})=>{o||r.dispatchEvent("form:complete",{data:t,request:n},{bubbles:!0})})}};return k(j);})();
|
|
2
|
+
if(typeof form!=="undefined"&&form&&form.default)globalThis.form=form.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=class y extends HTMLElement{static#C=new Set(["disabled","checked","readonly","required","selected","hidden","open","autofocus"]);static#d=new Map;static#p=new Set;static create(e){let{app:t,setup:i=()=>{},template:l="",events:r={}}=e;if(y.#d.has(t))throw new Error(`Application "${t}" already exists!`);y.#d.set(t,{setup:i,template:l,events:r,config:e}),y.#p.forEach(s=>{s.#i!==!0&&s.#P()})}static extend(e,t={}){let i=y.#d.get(e);if(!i)throw new Error(`Application "${e}" not found!`);let l=i.config,r={...l,...t};return(l.events||t.events)&&(r.events={...l.events,...t.events}),y.create(r)}#i=!1;#u="";#S=!1;#s=new Map;#y=null;#h=new Set;#m=!1;#e=[];#r=null;#M=new Map;#l=null;#t=[];#b=new Set;#x=!1;#n=new Map;#k=0;constructor(){super(),y.#p.add(this)}#g(e){!e||!e.length||e.forEach(t=>{if(t.type==="event"&&t.element&&t.handler)t.element.removeEventListener(t.eventName,t.handler);else if(t.type==="model"&&t.element&&t.handler){let i=t.element.tagName==="SELECT"?"change":"input";t.element.removeEventListener(i,t.handler)}else t.type==="attrSync"&&t.unwatch&&t.unwatch();t.effect&&(this.#s.forEach((i,l)=>{i.delete(t.effect),i.size===0&&this.#s.delete(l)}),this.#h.delete(t.effect))})}get template(){return this.#u}get attrs(){return{get:e=>this.getAttribute(e),set:(e,t)=>this.setAttribute(e,t),remove:e=>this.removeAttribute(e),has:e=>this.hasAttribute(e),toggle:(e,t)=>this.toggleAttribute(e,t),keys:()=>Array.from(this.attributes).map(e=>e.name),entries:()=>Array.from(this.attributes).map(e=>[e.name,e.value])}}addEventListener(e,t,i){if((e==="setup"||e==="rendered")&&this.#S){queueMicrotask(()=>t(new CustomEvent(e)));return}super.addEventListener(e,t,i)}dispatchEvent(e,t=null,i={}){if(typeof e=="string"){let l=new CustomEvent(e,{cancelable:!0,...i,detail:t});return super.dispatchEvent(l)}return super.dispatchEvent(e)}applyTemplate(e=""){let t=e||this.#u;if(this.#g(this.#e),this.#e=[],this.innerHTML="",t){let l=document.createElement("template");l.innerHTML=t.trim();let r=l.content.cloneNode(!0);Array.from(r.childNodes).forEach(s=>this.#E(s)),this.#$(r)}let i=++this.#k;new Promise(l=>{let r=null,s,n=()=>{clearTimeout(r),r=setTimeout(()=>{s.disconnect(),this.#A(Array.from(this.children)).then(l)},0)};s=new MutationObserver(h=>{h.some(a=>a.type==="childList")&&n()}),s.observe(this,{childList:!0}),n()}).then(()=>{i===this.#k&&(this.#S=!0,this.dispatchEvent("rendered"))})}#$(e){HTMLElement.prototype.appendChild.call(this,e)}clone(e={}){let t=this.attrs.get("app");return y.extend(t,e)}watch(e,t,i={}){if(typeof t!="function")return()=>{};let{deep:l=!1,immediate:r=!1}=i;if(typeof e=="string"&&e.endsWith("()")){let s=e.slice(0,-2),n=this[s];if(typeof n!="function")return()=>{};let h=this.#n.get(s);if(!h){h={original:n,handlers:[]},this.#n.set(s,h);let f=(...o)=>{let u=n.apply(this,o),c=d=>{for(let p of[...h.handlers])p.callback(o,d,p.unwatch)};return u instanceof Promise?u.then(d=>(c(d),d)):(c(u),u)};this[s]=f}let a=()=>{let f=h.handlers.findIndex(o=>o.unwatch===a);f!==-1&&h.handlers.splice(f,1),h.handlers.length===0&&(this[s]=h.original,this.#n.delete(s))};return h.handlers.push({callback:t,unwatch:a}),a}if(typeof e=="string"){let s=e,n=()=>{let a=this.#t.findIndex(f=>f.unwatch===n);a!==-1&&this.#t.splice(a,1)},h={type:"key",key:s,callback:t,deep:l,immediate:r,lastValue:void 0,unwatch:n};if(this.#t.push(h),r){let a=this.#T(s);h.lastValue=l&&a!==null&&typeof a=="object"?JSON.parse(JSON.stringify(a)):a,t(a,void 0,n)}return n}if(typeof e=="function"){let s=e,n,h={type:"getter",getter:s,callback:t,deep:l,lastValue:n,effect:null,unwatch:null};this.#t.push(h);let a=()=>{let u=this.#t.indexOf(h);u!==-1&&this.#t.splice(u,1),h.effect&&(this.#s.forEach((c,d)=>{c.delete(h.effect),c.size===0&&this.#s.delete(d)}),this.#h.delete(h.effect))};h.unwatch=a;let f=()=>{let u=s.call(this);if(l?!this.#N(u,n):u!==n){let d=n;n=l&&u!==null&&typeof u=="object"?JSON.parse(JSON.stringify(u)):u,t(u,d,h.unwatch)}},o=this.#f(f);return h.effect=o,a}return()=>{}}unwatch(){[...this.#t].forEach(e=>e.unwatch()),this.#n.forEach(e=>{[...e.handlers].forEach(t=>t.unwatch())})}hasWatchers(){let e=0;return this.#n.forEach(t=>{e+=t.handlers.length}),this.#t.length+e}watched(e,t,i={}){if(typeof e=="string"&&e.endsWith("()")){let l=e.slice(0,-2),r=this.#n.get(l);r&&[...r.handlers].forEach(s=>s.unwatch())}else typeof e=="string"?this.#t.filter(l=>l.type==="key"&&l.key===e).forEach(l=>l.unwatch()):typeof e=="function"&&this.#t.filter(l=>l.type==="getter"&&l.getter===e).forEach(l=>l.unwatch());return this.watch(e,t,i)}#v(e){this.#y&&(this.#s.has(e)||this.#s.set(e,new Set),this.#s.get(e).add(this.#y))}#a(e){this.#b.add(e);let t=this.#s.get(e);if(t&&t.forEach(l=>this.#h.add(l)),this.#m){this.#x=!0;return}this.#m=!0;let i=()=>{this.#h.forEach(s=>{try{s()}catch(n){console.error("Effect execution error:",n)}}),this.#h.clear();let l=Array.from(this.#b),r=new Set;for(let s of l)for(let n of this.#t){if(n.type!=="key")continue;(n.key===s||n.deep&&(s===n.key||s.startsWith(n.key+".")))&&r.add(n)}for(let s of r){if(s.type!=="key")continue;let n=this.#T(s.key);if(!(s.deep?!this.#N(n,s.lastValue):n!==s.lastValue))continue;let a=s.lastValue;s.lastValue=s.deep&&n!==null&&typeof n=="object"?JSON.parse(JSON.stringify(n)):n,s.callback(n,a,s.unwatch)}this.#b.clear(),this.#m=!1,this.#x&&(this.#x=!1,this.#m=!0,Promise.resolve().then(i))};Promise.resolve().then(i)}#T(e){return e.split(".").reduce((t,i)=>t?.[i],this)}#N(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;let i=Object.keys(e),l=Object.keys(t);if(i.length!==l.length)return!1;for(let r of i)if(!l.includes(r)||!this.#N(e[r],t[r]))return!1;return!0}#c(e,t=[]){if(e===null||typeof e!="object"||e.__isReactive)return e;let i=this;return new Proxy(e,{get(r,s,n){if(s==="__isReactive")return!0;let h=typeof s=="symbol"?"<symbol>":s,a=[...t,h].join(".");i.#v(a);let f=Reflect.get(r,s,n);return f!==null&&typeof f=="object"&&!f.__isReactive?i.#c(f,[...t,h]):f},set(r,s,n,h){if(r[s]===n)return!0;let f=Reflect.set(r,s,n,h),o=typeof s=="symbol"?"<symbol>":s,u=[...t,o].join(".");if(i.#a(u),Array.isArray(r)&&(s==="length"||!isNaN(s))){let c=t.join(".");c&&i.#a(c)}return f},deleteProperty(r,s){let n=Reflect.deleteProperty(r,s),h=typeof s=="symbol"?"<symbol>":s,a=[...t,h].join(".");return i.#a(a),n}})}#j(e,t){let i=this;return new Proxy(e,{apply(l,r,s){let n=Reflect.apply(l,i,s);return n instanceof Promise?n.then(h=>(i.#a(t),h)):(i.#a(t),n)}})}#f(e){let t=this.#r?{...this.#r}:null,i=()=>{let l=null;if(t){l={};for(let r of Object.keys(t))l[r]=this[r],this[r]=t[r]}this.#y=i;try{e()}finally{if(this.#y=null,l)for(let r of Object.keys(l))l[r]!==void 0?this[r]=l[r]:delete this[r]}};return i(),i}#o(e){try{return new Function("$event",`with(this) { return (${e}); }`).call(this)}catch(t){console.warn("Expression evaluation error:",e,t);return}}#L(e,t=null){try{return new Function("$event",`with(this) { ${e} }`).call(this,t)}catch(i){console.error("Statement execution error:",e,i)}}#V(e){let t=e.nodeValue,i=[],l=[],r=0,s=/\{\{(.+?)\}\}/g,n;for(;(n=s.exec(t))!==null;){n.index>r&&i.push(t.substring(r,n.index));let a=n[1].trim();i.push(null),l.push({index:i.length-1,expr:a}),r=s.lastIndex}r<t.length&&i.push(t.substring(r));let h=this.#f(()=>{l.forEach(({index:a,expr:f})=>{let o=this.#o(f);i[a]=o==null?"":String(o)}),e.nodeValue=i.join("")});this.#e.push({type:"text",node:e,effect:h})}#I(e,t){let i=t.name.slice(1),l=t.value,r=this.#r?{...this.#r}:null,s=n=>{if(r){let h={};for(let a of Object.keys(r))h[a]=this[a],this[a]=r[a];this.#L(l,n);for(let a of Object.keys(h))h[a]!==void 0?this[a]=h[a]:delete this[a]}else this.#L(l,n)};e.addEventListener(i,s),this.#e.push({type:"event",element:e,eventName:i,handler:s})}#B(e,t){let i=t.value,l=this.#f(()=>{this.#o(i)?e.style.display="":e.style.display="none"});this.#e.push({type:"show",element:e,effect:l})}#R(e,t){let i=t.value,l=this.#f(()=>{let h=this.#o(i);e.tagName==="INPUT"&&e.type==="checkbox"?e.checked=!!h:e.tagName==="INPUT"&&e.type==="radio"?e.checked=e.value===h:e.tagName==="SELECT"?e.value=h:e.value=h??""}),r=this.#r?{...this.#r}:null,s=e.tagName==="SELECT"?"change":"input",n=h=>{let a;if(e.type==="checkbox"?a=e.checked:e.type==="number"||e.type==="range"?a=e.valueAsNumber:a=e.value,r){let f={};for(let o of Object.keys(r))f[o]=this[o],this[o]=r[o];try{new Function("value",`with(this) { ${i} = value; }`).call(this,a)}catch(o){console.error("Model binding error:",i,o)}for(let o of Object.keys(f))f[o]!==void 0?this[o]=f[o]:delete this[o]}else try{new Function("value",`with(this) { ${i} = value; }`).call(this,a)}catch(f){console.error("Model binding error:",i,f)}};e.addEventListener(s,n),this.#e.push({type:"model",element:e,effect:l,handler:n})}#W(e,t){let i=t.value,l=document.createComment(`if: ${i}`);e.parentNode.insertBefore(l,e);let r=[{expr:i,element:e,bindings:[],processed:!1}],s=e.nextElementSibling;for(;s;)if(s.hasAttribute("#else-if")){let a=s.getAttribute("#else-if");r.push({expr:a,element:s,bindings:[],processed:!1}),s.removeAttribute("#else-if");let f=s.nextElementSibling;s.remove(),s=f}else if(s.hasAttribute("#else")){r.push({expr:"true",element:s,bindings:[],processed:!1}),s.removeAttribute("#else"),s.remove();break}else break;e.removeAttribute(t.name),e.remove();let n=null,h=this.#f(()=>{let a=null;for(let f of r)if(this.#o(f.expr)){a=f;break}if(n!==a){if(n&&(n.element&&n.element.parentNode&&n.element.remove(),this.#g(n.bindings),n.bindings=[]),a&&(l.parentNode.insertBefore(a.element,l.nextSibling),!a.processed)){let f=this.#e.length;this.#E(a.element),a.bindings=this.#e.slice(f),a.processed=!0}n=a}});this.#e.push({type:"conditional",placeholder:l,chain:r,effect:h})}#F(e,t){let i=t.value,l=i.match(/^\s*(\w+)\s+in\s+(.+)$/);if(!l){console.error("Invalid for syntax:",i);return}let r=l[1],s=l[2],n=e.parentNode,h=e.nextSibling;e.removeAttribute(t.name);let a=e.cloneNode(!0);e.remove();let f=[],o=this.#f(()=>{let u=this.#o(s);f.forEach(p=>{p.node&&p.node.parentNode&&p.node.remove(),this.#g(p.bindings)}),f=[];let c;if(Array.isArray(u))c=u.map((p,m)=>({value:p,key:void 0,index:m}));else if(u!==null&&typeof u=="object")c=Object.entries(u).map(([p,m],b)=>({value:m,key:p,index:b}));else return;if(c.length===0)return;let d=document.createDocumentFragment();c.forEach(({value:p,key:m,index:b})=>{let g=a.cloneNode(!0),E=this[r],w=this.$index,x=this.$key;this[r]=p,this.$index=b,m!==void 0&&(this.$key=m);let N=this.#r,A={...N,[r]:p,$index:b};m!==void 0&&(A.$key=m),this.#r=A;let O=this.#e.length;this.#E(g);let S=this.#e.slice(O);this.#r=N,E!==void 0?this[r]=E:delete this[r],w!==void 0?this.$index=w:delete this.$index,x!==void 0?this.$key=x:delete this.$key,d.appendChild(g),f.push({node:g,bindings:S})}),n.insertBefore(d,h)});this.#e.push({type:"loop",parent:n,nextSibling:h,template:a,effect:o})}#D(e,t){let i=t.name,l=t.value,r=[],s=[],n=0,h=/\{\{(.+?)\}\}/g,a;for(;(a=h.exec(l))!==null;){a.index>n&&r.push(l.substring(n,a.index));let o=a[1].trim();r.push(null),s.push({index:r.length-1,expr:o}),n=h.lastIndex}n<l.length&&r.push(l.substring(n));let f=this.#f(()=>{s.forEach(({index:u,expr:c})=>{let d=this.#o(c);r[u]=d==null?"":String(d)});let o=r.join("");y.#C.has(i)?o===""||o==="false"||o==="0"||o==="null"||o==="undefined"||!o?e.removeAttribute(i):e.setAttribute(i,""):e.setAttribute(i,o)});this.#e.push({type:"attribute",element:e,attrName:i,effect:f})}#J(e){let t=Array.from(e.attributes);for(let i of t){if(i.name==="#if")return this.#W(e,i),e.removeAttribute(i.name),!0;if(i.name==="#for")return this.#F(e,i),e.removeAttribute(i.name),!0;if(i.name==="#show")this.#B(e,i),e.removeAttribute(i.name);else if(i.name==="#model")this.#R(e,i),e.removeAttribute(i.name);else if(i.name==="#once")e.removeAttribute(i.name);else{if(i.name==="#pre")return e.removeAttribute(i.name),!0;i.name.startsWith("@")?(this.#I(e,i),e.removeAttribute(i.name)):/\{\{.+?\}\}/.test(i.value)&&this.#D(e,i)}}return!1}#E(e){if(e.nodeType===Node.ELEMENT_NODE){let t=this.#J(e);if(e.localName==="st-app")return;!t&&(e.parentNode||e.childNodes.length>0)&&Array.from(e.childNodes).forEach(i=>this.#E(i))}else e.nodeType===Node.TEXT_NODE&&/\{\{.+?\}\}/.test(e.nodeValue)&&this.#V(e)}#P(){let e=this.attrs.get("app"),t=y.#d.get(e);if(t){this.addEventListener("setup",t.setup),Object.entries(t.events).forEach(([s,n])=>this.addEventListener(s,n)),this.#u=t.template;let i=t.config,l=Object.getOwnPropertyDescriptors(i),r=new Set(["app","setup","template","events"]);Object.entries(l).forEach(([s,n])=>{if(!r.has(s)){if(n.get){let h=n.get;this.#M.set(s,h),Object.defineProperty(this,s,{get(){return this.#v(s),h.call(this)},enumerable:n.enumerable,configurable:!0})}else if(n.value!==void 0){let h=n.value,a=h;typeof h=="object"&&h!==null?a=this.#c(h,[s]):typeof h=="function"&&(a=this.#j(h,s)),Object.defineProperty(this,s,{get(){return this.#v(s),a},set(f){a!==f&&(typeof f=="object"&&f!==null?a=this.#c(f,[s]):a=f,this.#a(s))},enumerable:!0,configurable:!0})}}}),typeof this.#i=="function"&&this.#i(),this.#i=!0}else this.attrs.get("app")||(typeof this.#i=="function"&&this.#i(),this.#i=!0)}async#A(e){await Promise.all(e.map(t=>new Promise(i=>{let l=null,r=()=>{clearTimeout(l),l=setTimeout(()=>{s.disconnect(),this.#A(Array.from(t.children)).then(i)},0)},s=new MutationObserver(n=>{n.some(h=>h.type==="childList")&&r()});s.observe(t,{childList:!0}),r()})))}#O(e){return e==null?"":e===!0?"true":e===!1?"false":typeof e=="number"?String(e):typeof e=="object"?JSON.stringify(e):String(e)}#w(e){if(!e.startsWith(":")||e==="app")return;let t=e.replace(/^:+/,""),i=this.getAttribute(e),l=Object.getOwnPropertyDescriptor(this,t),r=i;if(!i&&l&&(l.get||l.value!==void 0)){let s=this[t],n=this.#O(s);this.getAttribute(e)!==n&&this.setAttribute(e,n),r=s,l=null}if(!(l&&l.set===void 0&&l.writable===!1)&&!(l&&l.get!==void 0&&l.set===void 0)){if(i)if(i==="true")r=!0;else if(i==="false")r=!1;else if(/^-?\d+(\.\d+)?$/.test(i))r=Number(i);else try{r=JSON.parse(i)}catch{r=i}if(!l||!l.set){let s=r;typeof r=="object"&&r!==null?s=this.#c(r,[t]):typeof r=="function"&&(s=this.#j(r,t));let n=e;if(Object.defineProperty(this,t,{get(){return this.#v(t),s},set(h){if(s!==h){typeof h=="object"&&h!==null?s=this.#c(h,[t]):s=h,this.#a(t);let a=this.#O(h);this.getAttribute(n)!==a&&this.setAttribute(n,a)}},enumerable:!0,configurable:!0}),typeof r=="object"&&r!==null){let h=this.watch(t,()=>{let a=this[t],f=this.#O(a);this.getAttribute(e)!==f&&this.setAttribute(e,f)},{deep:!0});this.#e.push({type:"attrSync",unwatch:h})}}else this[t]=r}}attributeChangedCallback(e,t,i){e.startsWith(":")&&e!=="app"&&t!==i&&this.#i===!0&&this.#w(e)}connectedCallback(){if(y.#p.add(this),this.#i===!0){this.#l||(this.#l=new MutationObserver(e=>{for(let t of e)t.type==="attributes"&&t.attributeName&&t.attributeName.startsWith(":")&&t.attributeName!=="app"&&this.#w(t.attributeName)}),this.#l.observe(this,{attributes:!0}));return}this.#P(),Promise.all([new Promise(e=>{if(this.#i===!0)return e();this.#i=e}),new Promise(e=>{let t=null,i=()=>{clearTimeout(t),t=setTimeout(()=>{l.disconnect(),this.#A(Array.from(this.children)).then(e)},0)},l=new MutationObserver(r=>{r.some(s=>s.type==="childList")&&i()});l.observe(this,{childList:!0}),i()})]).then(()=>{this.dispatchEvent("setup");for(let t of this.attrs.keys())!t.startsWith(":")||t==="app"||this.#w(t);let e=!1;this.childNodes.length>0&&Array.from(this.childNodes).some(i=>i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE&&i.textContent.trim()!=="")&&(this.#u?(this.applyTemplate(this.innerHTML),e=!0):this.#u=this.innerHTML),e||this.applyTemplate(),this.#i===!0&&!this.#l&&(this.#l=new MutationObserver(t=>{for(let i of t)i.type==="attributes"&&i.attributeName&&i.attributeName.startsWith(":")&&i.attributeName!=="app"&&this.#w(i.attributeName)}),this.#l.observe(this,{attributes:!0}))})}disconnectedCallback(){this.#l&&(this.#l.disconnect(),this.#l=null),this.#g(this.#e),this.#e=[];for(let e of this.#t)e.type==="getter"&&e.effect&&(this.#s.forEach((t,i)=>{t.delete(e.effect),t.size===0&&this.#s.delete(i)}),this.#h.delete(e.effect));this.#t=[],this.#n.forEach((e,t)=>{this[t]=e.original}),this.#n.clear(),this.#b.clear(),this.#s.clear(),this.#h.clear(),y.#p.delete(this)}toggleAttribute(e,t="",i=""){let l=this.getAttribute(e);this[t==""&&i==""&&(l||this.hasAttribute(e))?"removeAttribute":"setAttribute"](e,l!=t?t:i)}static{customElements.define("st-app",this)}};export{v as default};
|
package/dist/app.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var app=(()=>{var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var P=(c,e)=>{for(var t in e)E(c,t,{get:e[t],enumerable:!0})},C=(c,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of j(e))!L.call(c,r)&&r!==t&&E(c,r,{get:()=>e[r],enumerable:!(i=T(e,r))||i.enumerable});return c};var M=c=>C(E({},"__esModule",{value:!0}),c);var $={};P($,{default:()=>g});var g=class c extends HTMLElement{static#C=new Set(["disabled","checked","readonly","required","selected","hidden","open","autofocus"]);static#d=new Map;static#p=new Set;static create(e){let{app:t,setup:i=()=>{},template:r="",events:l={}}=e;if(c.#d.has(t))throw new Error(`Application "${t}" already exists!`);c.#d.set(t,{setup:i,template:r,events:l,config:e}),c.#p.forEach(s=>{s.#i!==!0&&s.#P()})}static extend(e,t={}){let i=c.#d.get(e);if(!i)throw new Error(`Application "${e}" not found!`);let r=i.config,l={...r,...t};return(r.events||t.events)&&(l.events={...r.events,...t.events}),c.create(l)}#i=!1;#u="";#S=!1;#s=new Map;#y=null;#h=new Set;#m=!1;#e=[];#r=null;#M=new Map;#l=null;#t=[];#b=new Set;#x=!1;#n=new Map;#k=0;constructor(){super(),c.#p.add(this)}#g(e){!e||!e.length||e.forEach(t=>{if(t.type==="event"&&t.element&&t.handler)t.element.removeEventListener(t.eventName,t.handler);else if(t.type==="model"&&t.element&&t.handler){let i=t.element.tagName==="SELECT"?"change":"input";t.element.removeEventListener(i,t.handler)}else t.type==="attrSync"&&t.unwatch&&t.unwatch();t.effect&&(this.#s.forEach((i,r)=>{i.delete(t.effect),i.size===0&&this.#s.delete(r)}),this.#h.delete(t.effect))})}get template(){return this.#u}get attrs(){return{get:e=>this.getAttribute(e),set:(e,t)=>this.setAttribute(e,t),remove:e=>this.removeAttribute(e),has:e=>this.hasAttribute(e),toggle:(e,t)=>this.toggleAttribute(e,t),keys:()=>Array.from(this.attributes).map(e=>e.name),entries:()=>Array.from(this.attributes).map(e=>[e.name,e.value])}}addEventListener(e,t,i){if((e==="setup"||e==="rendered")&&this.#S){queueMicrotask(()=>t(new CustomEvent(e)));return}super.addEventListener(e,t,i)}dispatchEvent(e,t=null,i={}){if(typeof e=="string"){let r=new CustomEvent(e,{cancelable:!0,...i,detail:t});return super.dispatchEvent(r)}return super.dispatchEvent(e)}applyTemplate(e=""){let t=e||this.#u;if(this.#g(this.#e),this.#e=[],this.innerHTML="",t){let r=document.createElement("template");r.innerHTML=t.trim();let l=r.content.cloneNode(!0);Array.from(l.childNodes).forEach(s=>this.#E(s)),this.#$(l)}let i=++this.#k;new Promise(r=>{let l=null,s,n=()=>{clearTimeout(l),l=setTimeout(()=>{s.disconnect(),this.#A(Array.from(this.children)).then(r)},0)};s=new MutationObserver(h=>{h.some(a=>a.type==="childList")&&n()}),s.observe(this,{childList:!0}),n()}).then(()=>{i===this.#k&&(this.#S=!0,this.dispatchEvent("rendered"))})}#$(e){HTMLElement.prototype.appendChild.call(this,e)}clone(e={}){let t=this.attrs.get("app");return c.extend(t,e)}watch(e,t,i={}){if(typeof t!="function")return()=>{};let{deep:r=!1,immediate:l=!1}=i;if(typeof e=="string"&&e.endsWith("()")){let s=e.slice(0,-2),n=this[s];if(typeof n!="function")return()=>{};let h=this.#n.get(s);if(!h){h={original:n,handlers:[]},this.#n.set(s,h);let f=(...o)=>{let u=n.apply(this,o),d=p=>{for(let y of[...h.handlers])y.callback(o,p,y.unwatch)};return u instanceof Promise?u.then(p=>(d(p),p)):(d(u),u)};this[s]=f}let a=()=>{let f=h.handlers.findIndex(o=>o.unwatch===a);f!==-1&&h.handlers.splice(f,1),h.handlers.length===0&&(this[s]=h.original,this.#n.delete(s))};return h.handlers.push({callback:t,unwatch:a}),a}if(typeof e=="string"){let s=e,n=()=>{let a=this.#t.findIndex(f=>f.unwatch===n);a!==-1&&this.#t.splice(a,1)},h={type:"key",key:s,callback:t,deep:r,immediate:l,lastValue:void 0,unwatch:n};if(this.#t.push(h),l){let a=this.#T(s);h.lastValue=r&&a!==null&&typeof a=="object"?JSON.parse(JSON.stringify(a)):a,t(a,void 0,n)}return n}if(typeof e=="function"){let s=e,n,h={type:"getter",getter:s,callback:t,deep:r,lastValue:n,effect:null,unwatch:null};this.#t.push(h);let a=()=>{let u=this.#t.indexOf(h);u!==-1&&this.#t.splice(u,1),h.effect&&(this.#s.forEach((d,p)=>{d.delete(h.effect),d.size===0&&this.#s.delete(p)}),this.#h.delete(h.effect))};h.unwatch=a;let f=()=>{let u=s.call(this);if(r?!this.#N(u,n):u!==n){let p=n;n=r&&u!==null&&typeof u=="object"?JSON.parse(JSON.stringify(u)):u,t(u,p,h.unwatch)}},o=this.#f(f);return h.effect=o,a}return()=>{}}unwatch(){[...this.#t].forEach(e=>e.unwatch()),this.#n.forEach(e=>{[...e.handlers].forEach(t=>t.unwatch())})}hasWatchers(){let e=0;return this.#n.forEach(t=>{e+=t.handlers.length}),this.#t.length+e}watched(e,t,i={}){if(typeof e=="string"&&e.endsWith("()")){let r=e.slice(0,-2),l=this.#n.get(r);l&&[...l.handlers].forEach(s=>s.unwatch())}else typeof e=="string"?this.#t.filter(r=>r.type==="key"&&r.key===e).forEach(r=>r.unwatch()):typeof e=="function"&&this.#t.filter(r=>r.type==="getter"&&r.getter===e).forEach(r=>r.unwatch());return this.watch(e,t,i)}#v(e){this.#y&&(this.#s.has(e)||this.#s.set(e,new Set),this.#s.get(e).add(this.#y))}#a(e){this.#b.add(e);let t=this.#s.get(e);if(t&&t.forEach(r=>this.#h.add(r)),this.#m){this.#x=!0;return}this.#m=!0;let i=()=>{this.#h.forEach(s=>{try{s()}catch(n){console.error("Effect execution error:",n)}}),this.#h.clear();let r=Array.from(this.#b),l=new Set;for(let s of r)for(let n of this.#t){if(n.type!=="key")continue;(n.key===s||n.deep&&(s===n.key||s.startsWith(n.key+".")))&&l.add(n)}for(let s of l){if(s.type!=="key")continue;let n=this.#T(s.key);if(!(s.deep?!this.#N(n,s.lastValue):n!==s.lastValue))continue;let a=s.lastValue;s.lastValue=s.deep&&n!==null&&typeof n=="object"?JSON.parse(JSON.stringify(n)):n,s.callback(n,a,s.unwatch)}this.#b.clear(),this.#m=!1,this.#x&&(this.#x=!1,this.#m=!0,Promise.resolve().then(i))};Promise.resolve().then(i)}#T(e){return e.split(".").reduce((t,i)=>t?.[i],this)}#N(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let l of i)if(!r.includes(l)||!this.#N(e[l],t[l]))return!1;return!0}#c(e,t=[]){if(e===null||typeof e!="object"||e.__isReactive)return e;let i=this;return new Proxy(e,{get(l,s,n){if(s==="__isReactive")return!0;let h=typeof s=="symbol"?"<symbol>":s,a=[...t,h].join(".");i.#v(a);let f=Reflect.get(l,s,n);return f!==null&&typeof f=="object"&&!f.__isReactive?i.#c(f,[...t,h]):f},set(l,s,n,h){if(l[s]===n)return!0;let f=Reflect.set(l,s,n,h),o=typeof s=="symbol"?"<symbol>":s,u=[...t,o].join(".");if(i.#a(u),Array.isArray(l)&&(s==="length"||!isNaN(s))){let d=t.join(".");d&&i.#a(d)}return f},deleteProperty(l,s){let n=Reflect.deleteProperty(l,s),h=typeof s=="symbol"?"<symbol>":s,a=[...t,h].join(".");return i.#a(a),n}})}#j(e,t){let i=this;return new Proxy(e,{apply(r,l,s){let n=Reflect.apply(r,i,s);return n instanceof Promise?n.then(h=>(i.#a(t),h)):(i.#a(t),n)}})}#f(e){let t=this.#r?{...this.#r}:null,i=()=>{let r=null;if(t){r={};for(let l of Object.keys(t))r[l]=this[l],this[l]=t[l]}this.#y=i;try{e()}finally{if(this.#y=null,r)for(let l of Object.keys(r))r[l]!==void 0?this[l]=r[l]:delete this[l]}};return i(),i}#o(e){try{return new Function("$event",`with(this) { return (${e}); }`).call(this)}catch(t){console.warn("Expression evaluation error:",e,t);return}}#L(e,t=null){try{return new Function("$event",`with(this) { ${e} }`).call(this,t)}catch(i){console.error("Statement execution error:",e,i)}}#V(e){let t=e.nodeValue,i=[],r=[],l=0,s=/\{\{(.+?)\}\}/g,n;for(;(n=s.exec(t))!==null;){n.index>l&&i.push(t.substring(l,n.index));let a=n[1].trim();i.push(null),r.push({index:i.length-1,expr:a}),l=s.lastIndex}l<t.length&&i.push(t.substring(l));let h=this.#f(()=>{r.forEach(({index:a,expr:f})=>{let o=this.#o(f);i[a]=o==null?"":String(o)}),e.nodeValue=i.join("")});this.#e.push({type:"text",node:e,effect:h})}#I(e,t){let i=t.name.slice(1),r=t.value,l=this.#r?{...this.#r}:null,s=n=>{if(l){let h={};for(let a of Object.keys(l))h[a]=this[a],this[a]=l[a];this.#L(r,n);for(let a of Object.keys(h))h[a]!==void 0?this[a]=h[a]:delete this[a]}else this.#L(r,n)};e.addEventListener(i,s),this.#e.push({type:"event",element:e,eventName:i,handler:s})}#B(e,t){let i=t.value,r=this.#f(()=>{this.#o(i)?e.style.display="":e.style.display="none"});this.#e.push({type:"show",element:e,effect:r})}#R(e,t){let i=t.value,r=this.#f(()=>{let h=this.#o(i);e.tagName==="INPUT"&&e.type==="checkbox"?e.checked=!!h:e.tagName==="INPUT"&&e.type==="radio"?e.checked=e.value===h:e.tagName==="SELECT"?e.value=h:e.value=h??""}),l=this.#r?{...this.#r}:null,s=e.tagName==="SELECT"?"change":"input",n=h=>{let a;if(e.type==="checkbox"?a=e.checked:e.type==="number"||e.type==="range"?a=e.valueAsNumber:a=e.value,l){let f={};for(let o of Object.keys(l))f[o]=this[o],this[o]=l[o];try{new Function("value",`with(this) { ${i} = value; }`).call(this,a)}catch(o){console.error("Model binding error:",i,o)}for(let o of Object.keys(f))f[o]!==void 0?this[o]=f[o]:delete this[o]}else try{new Function("value",`with(this) { ${i} = value; }`).call(this,a)}catch(f){console.error("Model binding error:",i,f)}};e.addEventListener(s,n),this.#e.push({type:"model",element:e,effect:r,handler:n})}#W(e,t){let i=t.value,r=document.createComment(`if: ${i}`);e.parentNode.insertBefore(r,e);let l=[{expr:i,element:e,bindings:[],processed:!1}],s=e.nextElementSibling;for(;s;)if(s.hasAttribute("#else-if")){let a=s.getAttribute("#else-if");l.push({expr:a,element:s,bindings:[],processed:!1}),s.removeAttribute("#else-if");let f=s.nextElementSibling;s.remove(),s=f}else if(s.hasAttribute("#else")){l.push({expr:"true",element:s,bindings:[],processed:!1}),s.removeAttribute("#else"),s.remove();break}else break;e.removeAttribute(t.name),e.remove();let n=null,h=this.#f(()=>{let a=null;for(let f of l)if(this.#o(f.expr)){a=f;break}if(n!==a){if(n&&(n.element&&n.element.parentNode&&n.element.remove(),this.#g(n.bindings),n.bindings=[]),a&&(r.parentNode.insertBefore(a.element,r.nextSibling),!a.processed)){let f=this.#e.length;this.#E(a.element),a.bindings=this.#e.slice(f),a.processed=!0}n=a}});this.#e.push({type:"conditional",placeholder:r,chain:l,effect:h})}#F(e,t){let i=t.value,r=i.match(/^\s*(\w+)\s+in\s+(.+)$/);if(!r){console.error("Invalid for syntax:",i);return}let l=r[1],s=r[2],n=e.parentNode,h=e.nextSibling;e.removeAttribute(t.name);let a=e.cloneNode(!0);e.remove();let f=[],o=this.#f(()=>{let u=this.#o(s);f.forEach(y=>{y.node&&y.node.parentNode&&y.node.remove(),this.#g(y.bindings)}),f=[];let d;if(Array.isArray(u))d=u.map((y,m)=>({value:y,key:void 0,index:m}));else if(u!==null&&typeof u=="object")d=Object.entries(u).map(([y,m],b)=>({value:m,key:y,index:b}));else return;if(d.length===0)return;let p=document.createDocumentFragment();d.forEach(({value:y,key:m,index:b})=>{let v=a.cloneNode(!0),w=this[l],x=this.$index,N=this.$key;this[l]=y,this.$index=b,m!==void 0&&(this.$key=m);let A=this.#r,O={...A,[l]:y,$index:b};m!==void 0&&(O.$key=m),this.#r=O;let S=this.#e.length;this.#E(v);let k=this.#e.slice(S);this.#r=A,w!==void 0?this[l]=w:delete this[l],x!==void 0?this.$index=x:delete this.$index,N!==void 0?this.$key=N:delete this.$key,p.appendChild(v),f.push({node:v,bindings:k})}),n.insertBefore(p,h)});this.#e.push({type:"loop",parent:n,nextSibling:h,template:a,effect:o})}#D(e,t){let i=t.name,r=t.value,l=[],s=[],n=0,h=/\{\{(.+?)\}\}/g,a;for(;(a=h.exec(r))!==null;){a.index>n&&l.push(r.substring(n,a.index));let o=a[1].trim();l.push(null),s.push({index:l.length-1,expr:o}),n=h.lastIndex}n<r.length&&l.push(r.substring(n));let f=this.#f(()=>{s.forEach(({index:u,expr:d})=>{let p=this.#o(d);l[u]=p==null?"":String(p)});let o=l.join("");c.#C.has(i)?o===""||o==="false"||o==="0"||o==="null"||o==="undefined"||!o?e.removeAttribute(i):e.setAttribute(i,""):e.setAttribute(i,o)});this.#e.push({type:"attribute",element:e,attrName:i,effect:f})}#J(e){let t=Array.from(e.attributes);for(let i of t){if(i.name==="#if")return this.#W(e,i),e.removeAttribute(i.name),!0;if(i.name==="#for")return this.#F(e,i),e.removeAttribute(i.name),!0;if(i.name==="#show")this.#B(e,i),e.removeAttribute(i.name);else if(i.name==="#model")this.#R(e,i),e.removeAttribute(i.name);else if(i.name==="#once")e.removeAttribute(i.name);else{if(i.name==="#pre")return e.removeAttribute(i.name),!0;i.name.startsWith("@")?(this.#I(e,i),e.removeAttribute(i.name)):/\{\{.+?\}\}/.test(i.value)&&this.#D(e,i)}}return!1}#E(e){if(e.nodeType===Node.ELEMENT_NODE){let t=this.#J(e);if(e.localName==="st-app")return;!t&&(e.parentNode||e.childNodes.length>0)&&Array.from(e.childNodes).forEach(i=>this.#E(i))}else e.nodeType===Node.TEXT_NODE&&/\{\{.+?\}\}/.test(e.nodeValue)&&this.#V(e)}#P(){let e=this.attrs.get("app"),t=c.#d.get(e);if(t){this.addEventListener("setup",t.setup),Object.entries(t.events).forEach(([s,n])=>this.addEventListener(s,n)),this.#u=t.template;let i=t.config,r=Object.getOwnPropertyDescriptors(i),l=new Set(["app","setup","template","events"]);Object.entries(r).forEach(([s,n])=>{if(!l.has(s)){if(n.get){let h=n.get;this.#M.set(s,h),Object.defineProperty(this,s,{get(){return this.#v(s),h.call(this)},enumerable:n.enumerable,configurable:!0})}else if(n.value!==void 0){let h=n.value,a=h;typeof h=="object"&&h!==null?a=this.#c(h,[s]):typeof h=="function"&&(a=this.#j(h,s)),Object.defineProperty(this,s,{get(){return this.#v(s),a},set(f){a!==f&&(typeof f=="object"&&f!==null?a=this.#c(f,[s]):a=f,this.#a(s))},enumerable:!0,configurable:!0})}}}),typeof this.#i=="function"&&this.#i(),this.#i=!0}else this.attrs.get("app")||(typeof this.#i=="function"&&this.#i(),this.#i=!0)}async#A(e){await Promise.all(e.map(t=>new Promise(i=>{let r=null,l=()=>{clearTimeout(r),r=setTimeout(()=>{s.disconnect(),this.#A(Array.from(t.children)).then(i)},0)},s=new MutationObserver(n=>{n.some(h=>h.type==="childList")&&l()});s.observe(t,{childList:!0}),l()})))}#O(e){return e==null?"":e===!0?"true":e===!1?"false":typeof e=="number"?String(e):typeof e=="object"?JSON.stringify(e):String(e)}#w(e){if(!e.startsWith(":")||e==="app")return;let t=e.replace(/^:+/,""),i=this.getAttribute(e),r=Object.getOwnPropertyDescriptor(this,t),l=i;if(!i&&r&&(r.get||r.value!==void 0)){let s=this[t],n=this.#O(s);this.getAttribute(e)!==n&&this.setAttribute(e,n),l=s,r=null}if(!(r&&r.set===void 0&&r.writable===!1)&&!(r&&r.get!==void 0&&r.set===void 0)){if(i)if(i==="true")l=!0;else if(i==="false")l=!1;else if(/^-?\d+(\.\d+)?$/.test(i))l=Number(i);else try{l=JSON.parse(i)}catch{l=i}if(!r||!r.set){let s=l;typeof l=="object"&&l!==null?s=this.#c(l,[t]):typeof l=="function"&&(s=this.#j(l,t));let n=e;if(Object.defineProperty(this,t,{get(){return this.#v(t),s},set(h){if(s!==h){typeof h=="object"&&h!==null?s=this.#c(h,[t]):s=h,this.#a(t);let a=this.#O(h);this.getAttribute(n)!==a&&this.setAttribute(n,a)}},enumerable:!0,configurable:!0}),typeof l=="object"&&l!==null){let h=this.watch(t,()=>{let a=this[t],f=this.#O(a);this.getAttribute(e)!==f&&this.setAttribute(e,f)},{deep:!0});this.#e.push({type:"attrSync",unwatch:h})}}else this[t]=l}}attributeChangedCallback(e,t,i){e.startsWith(":")&&e!=="app"&&t!==i&&this.#i===!0&&this.#w(e)}connectedCallback(){if(c.#p.add(this),this.#i===!0){this.#l||(this.#l=new MutationObserver(e=>{for(let t of e)t.type==="attributes"&&t.attributeName&&t.attributeName.startsWith(":")&&t.attributeName!=="app"&&this.#w(t.attributeName)}),this.#l.observe(this,{attributes:!0}));return}this.#P(),Promise.all([new Promise(e=>{if(this.#i===!0)return e();this.#i=e}),new Promise(e=>{let t=null,i=()=>{clearTimeout(t),t=setTimeout(()=>{r.disconnect(),this.#A(Array.from(this.children)).then(e)},0)},r=new MutationObserver(l=>{l.some(s=>s.type==="childList")&&i()});r.observe(this,{childList:!0}),i()})]).then(()=>{this.dispatchEvent("setup");for(let t of this.attrs.keys())!t.startsWith(":")||t==="app"||this.#w(t);let e=!1;this.childNodes.length>0&&Array.from(this.childNodes).some(i=>i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE&&i.textContent.trim()!=="")&&(this.#u?(this.applyTemplate(this.innerHTML),e=!0):this.#u=this.innerHTML),e||this.applyTemplate(),this.#i===!0&&!this.#l&&(this.#l=new MutationObserver(t=>{for(let i of t)i.type==="attributes"&&i.attributeName&&i.attributeName.startsWith(":")&&i.attributeName!=="app"&&this.#w(i.attributeName)}),this.#l.observe(this,{attributes:!0}))})}disconnectedCallback(){this.#l&&(this.#l.disconnect(),this.#l=null),this.#g(this.#e),this.#e=[];for(let e of this.#t)e.type==="getter"&&e.effect&&(this.#s.forEach((t,i)=>{t.delete(e.effect),t.size===0&&this.#s.delete(i)}),this.#h.delete(e.effect));this.#t=[],this.#n.forEach((e,t)=>{this[t]=e.original}),this.#n.clear(),this.#b.clear(),this.#s.clear(),this.#h.clear(),c.#p.delete(this)}toggleAttribute(e,t="",i=""){let r=this.getAttribute(e);this[t==""&&i==""&&(r||this.hasAttribute(e))?"removeAttribute":"setAttribute"](e,r!=t?t:i)}static{customElements.define("st-app",this)}};return M($);})();
|
|
2
|
+
if(typeof app!=="undefined"&&app&&app.default)globalThis.app=app.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=class l{static set(t,i,e={}){if(e={path:"/",expires:3600,...e},!(e.expires instanceof Date)){let n=e.expires;e.expires=new Date(typeof n=="number"?Date.now()+n*1e3:Date.parse(n)||Date.parse(n.replace(/-/g,"/")))}document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(i)+"; expires="+e.expires.toUTCString()+"; path="+e.path+(e.domain?"; domain="+e.domain:"")+(e.secure?"; secure":"")+(e.sameSite?"; samesite="+e.sameSite:"")}static get(t){t=encodeURIComponent(t);let i=document.cookie.split(";");for(let e=0;e<i.length;e++){let n=i[e].trim();if(n.startsWith(t+"=")){let o=decodeURIComponent(n.substring(t.length+1));try{return JSON.parse(o)}catch{return o}}}return null}static delete(t,i={}){l.set(t,"",{expires:0,...i})}static callback(t,i,e={}){e={interval:0,delay:0,value:!0,...e};let n=setInterval(()=>{l.get(t)===null&&(l.set(t,e.value,e),setTimeout(()=>{i(t)},e.delay*1e3)),e.interval||clearInterval(n)},e.interval*1e3)}static consent(t){t={content:"<div><span>\u042D\u0442\u043E\u0442 \u0441\u0430\u0439\u0442 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043B\u044B cookies \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044B \u0441\u0431\u043E\u0440\u0430 \u0442\u0435\u0445\u043D\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u0434\u0430\u043D\u043D\u044B\u0445 \u043F\u043E\u0441\u0435\u0442\u0438\u0442\u0435\u043B\u0435\u0439 (\u0434\u0430\u043D\u043D\u044B\u0435 \u043E\u0431 IP-\u0430\u0434\u0440\u0435\u0441\u0435, \u043C\u0435\u0441\u0442\u043E\u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0438 \u0438 \u0442.\u0434.) \u0434\u043B\u044F \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0435\u043D\u0438\u044F \u0440\u0430\u0431\u043E\u0442\u043E\u0441\u043F\u043E\u0441\u043E\u0431\u043D\u043E\u0441\u0442\u0438 \u0438 \u0443\u043B\u0443\u0447\u0448\u0435\u043D\u0438\u044F \u043A\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u043D\u0438\u044F.</span><div><button action='accept'>\u041F\u0440\u0438\u043D\u044F\u0442\u044C</button><button action='decline'>\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C</button></div></div>",container:"body",location:"bottom",zIndex:1e3,name:"cookie_consent",interval:5,...t};let i=document.createElement("container");if(t.container=="body"&&Object.assign(i.style,{position:"absolute",overflow:"hidden",width:"max-content",height:"max-content",maxWidth:"100vw",maxHeight:"100vh",zIndex:t.zIndex,transition:"inherit",pointerEvents:"all",display:"none",...(()=>{let e=(t.location||"").toLowerCase().split(/\s+/),n={top:e.includes("top")?0:e.includes("bottom")?void 0:"50%",bottom:e.includes("bottom")?0:void 0,left:e.includes("left")?0:e.includes("right")?void 0:"50%",right:e.includes("right")?0:void 0},o=n.left==="50%"?"translateX(-50%)":"",c=n.top==="50%"?"translateY(-50%)":"";return(o||c)&&(n.transform=`${o} ${c}`.trim()),n})()}),document.querySelector(t.container).append(i),!(t.content instanceof Element)){let e=t.content;t.content=e.trim().startsWith("<")?new DOMParser().parseFromString(e,"text/html").body.firstElementChild:document.querySelector(e)??(()=>{throw new Error("\u0421\u0435\u043B\u0435\u043A\u0442\u043E\u0440 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D")})()}i.append(t.content),l.callback(t.name,e=>{["accept","decline"].forEach(n=>{i.querySelectorAll(`[action=${n}]`).forEach(o=>{o.addEventListener("click",c=>{l.set(t.name,n=="accept",t),i.style.display="none"})})}),i.style.display=""},{...t,value:null})}};export{d as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var cookie=(()=>{var r=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(o,t)=>{for(var i in t)r(o,i,{get:t[i],enumerable:!0})},h=(o,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of u(t))!a.call(o,n)&&n!==i&&r(o,n,{get:()=>t[n],enumerable:!(e=s(t,n))||e.enumerable});return o};var v=o=>h(r({},"__esModule",{value:!0}),o);var y={};f(y,{default:()=>c});var c=class o{static set(t,i,e={}){if(e={path:"/",expires:3600,...e},!(e.expires instanceof Date)){let n=e.expires;e.expires=new Date(typeof n=="number"?Date.now()+n*1e3:Date.parse(n)||Date.parse(n.replace(/-/g,"/")))}document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(i)+"; expires="+e.expires.toUTCString()+"; path="+e.path+(e.domain?"; domain="+e.domain:"")+(e.secure?"; secure":"")+(e.sameSite?"; samesite="+e.sameSite:"")}static get(t){t=encodeURIComponent(t);let i=document.cookie.split(";");for(let e=0;e<i.length;e++){let n=i[e].trim();if(n.startsWith(t+"=")){let l=decodeURIComponent(n.substring(t.length+1));try{return JSON.parse(l)}catch{return l}}}return null}static delete(t,i={}){o.set(t,"",{expires:0,...i})}static callback(t,i,e={}){e={interval:0,delay:0,value:!0,...e};let n=setInterval(()=>{o.get(t)===null&&(o.set(t,e.value,e),setTimeout(()=>{i(t)},e.delay*1e3)),e.interval||clearInterval(n)},e.interval*1e3)}static consent(t){t={content:"<div><span>\u042D\u0442\u043E\u0442 \u0441\u0430\u0439\u0442 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043B\u044B cookies \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044B \u0441\u0431\u043E\u0440\u0430 \u0442\u0435\u0445\u043D\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u0434\u0430\u043D\u043D\u044B\u0445 \u043F\u043E\u0441\u0435\u0442\u0438\u0442\u0435\u043B\u0435\u0439 (\u0434\u0430\u043D\u043D\u044B\u0435 \u043E\u0431 IP-\u0430\u0434\u0440\u0435\u0441\u0435, \u043C\u0435\u0441\u0442\u043E\u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0438 \u0438 \u0442.\u0434.) \u0434\u043B\u044F \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0435\u043D\u0438\u044F \u0440\u0430\u0431\u043E\u0442\u043E\u0441\u043F\u043E\u0441\u043E\u0431\u043D\u043E\u0441\u0442\u0438 \u0438 \u0443\u043B\u0443\u0447\u0448\u0435\u043D\u0438\u044F \u043A\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u043D\u0438\u044F.</span><div><button action='accept'>\u041F\u0440\u0438\u043D\u044F\u0442\u044C</button><button action='decline'>\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C</button></div></div>",container:"body",location:"bottom",zIndex:1e3,name:"cookie_consent",interval:5,...t};let i=document.createElement("container");if(t.container=="body"&&Object.assign(i.style,{position:"absolute",overflow:"hidden",width:"max-content",height:"max-content",maxWidth:"100vw",maxHeight:"100vh",zIndex:t.zIndex,transition:"inherit",pointerEvents:"all",display:"none",...(()=>{let e=(t.location||"").toLowerCase().split(/\s+/),n={top:e.includes("top")?0:e.includes("bottom")?void 0:"50%",bottom:e.includes("bottom")?0:void 0,left:e.includes("left")?0:e.includes("right")?void 0:"50%",right:e.includes("right")?0:void 0},l=n.left==="50%"?"translateX(-50%)":"",d=n.top==="50%"?"translateY(-50%)":"";return(l||d)&&(n.transform=`${l} ${d}`.trim()),n})()}),document.querySelector(t.container).append(i),!(t.content instanceof Element)){let e=t.content;t.content=e.trim().startsWith("<")?new DOMParser().parseFromString(e,"text/html").body.firstElementChild:document.querySelector(e)??(()=>{throw new Error("\u0421\u0435\u043B\u0435\u043A\u0442\u043E\u0440 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D")})()}i.append(t.content),o.callback(t.name,e=>{["accept","decline"].forEach(n=>{i.querySelectorAll(`[action=${n}]`).forEach(l=>{l.addEventListener("click",d=>{o.set(t.name,n=="accept",t),i.style.display="none"})})}),i.style.display=""},{...t,value:null})}};return v(y);})();
|
|
2
|
+
if(typeof cookie!=="undefined"&&cookie&&cookie.default)globalThis.cookie=cookie.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=class{static merge(...e){let d=s=>s!==null&&typeof s=="object"&&!Array.isArray(s)&&(Object.getPrototypeOf(s)??Object.prototype)===Object.prototype,t=(s,u)=>{if(typeof s=="function"&&typeof u=="function")return(...c)=>t(s(...c),u(...c));if(!(Array.isArray(s)&&Array.isArray(u)||d(s)&&d(u)))return u;let l=Array.isArray(s)?s.slice():{...s};for(let[c,f]of Object.entries(u))l[c]=c in l?t(l[c],f):f;return l};return e.reduce(t,{})}static generate_unique_prefix(e){return e={characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",length:16,...e},[...Array(e.length)].map(d=>e.characters[Math.random()*e.characters.length|0]).join("")}static fetch(e){e instanceof HTMLFormElement&&(e={url:e.getAttribute("action")||"",method:e.getAttribute("method")||"",data:new FormData(e)}),e={url:"",method:"",data:null,headers:{},timeout:0,response_type:"",...e};let d={beforeSend:[e.before_send],onSend:[e.on_send],onSuccess:[e.on_success],onComplete:[e.on_complete],onFailed:[e.on_failed]},t,s,u,l=!1,c=new Promise((o,r)=>(s=o,u=r)),f=(o,r)=>{for(let i of d[o])if(i)try{i(r)}catch(n){console.error(`st_ajax: ${o} error`,n)}},y={then:(o,r)=>c.then(o,r),catch:o=>c.catch(o),finally:o=>c.finally(o),abort:()=>t?.abort()};for(let o of Object.keys(d))y[o]=r=>(d[o].push(r),y);let h=o=>{if(l)return;l=!0;let r=o instanceof XMLHttpRequest?{status:o.status,status_text:o.statusText,response:o.responseText,request:o}:{status:void 0,status_text:"",response:o};f("onFailed",r),u(r)};return queueMicrotask(()=>{try{let o=e.url,r=e.method,i;if(f("beforeSend",e),e.data instanceof FormData?i=e.data:e.data instanceof HTMLFormElement?(o=o||e.data.getAttribute("action"),r=r||e.data.getAttribute("method"),i=new FormData(e.data)):i=e.data,o=o||window.location.href,r=r?r.toUpperCase():"GET",i&&typeof i=="object")if(r=="GET"){let n=i instanceof FormData?new URLSearchParams(i).toString():Object.entries(i).map(([a,b])=>`${encodeURIComponent(a)}=${encodeURIComponent(b)}`).join("&");n&&(o+=(/\?.+=/.test(o)?"&":"?")+n),i=null}else i instanceof FormData||(i=JSON.stringify(e.data),Object.keys(e.headers).some(n=>n.toLowerCase()=="content-type")||(e.headers["Content-Type"]="application/json"));if(t=new XMLHttpRequest,e.response_type)try{t.responseType=e.response_type}catch{}e.timeout>0&&Number.isFinite(e.timeout)&&(t.timeout=e.timeout),t.onerror=t.ontimeout=()=>h(t),t.onreadystatechange=()=>{if(t.readyState!==4)return;let n;if(t.status>=200&&t.status<300){if(t.responseType)n=t.response;else{let a=t.getResponseHeader("Content-Type")||e.response_type||"";if(a.includes("/json"))try{n=JSON.parse(t.responseText)}catch{n=t.responseText}else a.includes("/xml")?n=new DOMParser().parseFromString(t.responseText,"application/xml"):a.includes("/html")?n=new DOMParser().parseFromString(t.responseText,"text/html"):n=t.responseText}f("onSuccess",{data:n,request:t}),l=!0,s({data:n,request:t})}else h(t);f("onComplete",{data:n,request:t})},t.open(r,o,!0);for(let n in e.headers)if(Object.prototype.hasOwnProperty.call(e.headers,n))try{t.setRequestHeader(n,e.headers[n])}catch{}t.send(i),f("onSend",{detail:e})}catch(o){h(o)}}),y}};export{p as default};
|
package/dist/core.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var core=(()=>{var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var O=(f,e)=>{for(var c in e)g(f,c,{get:e[c],enumerable:!0})},A=(f,e,c,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!_.call(f,n)&&n!==c&&g(f,n,{get:()=>e[n],enumerable:!(t=x(e,n))||t.enumerable});return f};var S=f=>A(g({},"__esModule",{value:!0}),f);var F={};O(F,{default:()=>h});var h=class{static merge(...e){let c=n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&(Object.getPrototypeOf(n)??Object.prototype)===Object.prototype,t=(n,l)=>{if(typeof n=="function"&&typeof l=="function")return(...u)=>t(n(...u),l(...u));if(!(Array.isArray(n)&&Array.isArray(l)||c(n)&&c(l)))return l;let d=Array.isArray(n)?n.slice():{...n};for(let[u,a]of Object.entries(l))d[u]=u in d?t(d[u],a):a;return d};return e.reduce(t,{})}static generate_unique_prefix(e){return e={characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",length:16,...e},[...Array(e.length)].map(c=>e.characters[Math.random()*e.characters.length|0]).join("")}static fetch(e){e instanceof HTMLFormElement&&(e={url:e.getAttribute("action")||"",method:e.getAttribute("method")||"",data:new FormData(e)}),e={url:"",method:"",data:null,headers:{},timeout:0,response_type:"",...e};let c={beforeSend:[e.before_send],onSend:[e.on_send],onSuccess:[e.on_success],onComplete:[e.on_complete],onFailed:[e.on_failed]},t,n,l,d=!1,u=new Promise((o,s)=>(n=o,l=s)),a=(o,s)=>{for(let i of c[o])if(i)try{i(s)}catch(r){console.error(`st_ajax: ${o} error`,r)}},p={then:(o,s)=>u.then(o,s),catch:o=>u.catch(o),finally:o=>u.finally(o),abort:()=>t?.abort()};for(let o of Object.keys(c))p[o]=s=>(c[o].push(s),p);let b=o=>{if(d)return;d=!0;let s=o instanceof XMLHttpRequest?{status:o.status,status_text:o.statusText,response:o.responseText,request:o}:{status:void 0,status_text:"",response:o};a("onFailed",s),l(s)};return queueMicrotask(()=>{try{let o=e.url,s=e.method,i;if(a("beforeSend",e),e.data instanceof FormData?i=e.data:e.data instanceof HTMLFormElement?(o=o||e.data.getAttribute("action"),s=s||e.data.getAttribute("method"),i=new FormData(e.data)):i=e.data,o=o||window.location.href,s=s?s.toUpperCase():"GET",i&&typeof i=="object")if(s=="GET"){let r=i instanceof FormData?new URLSearchParams(i).toString():Object.entries(i).map(([y,j])=>`${encodeURIComponent(y)}=${encodeURIComponent(j)}`).join("&");r&&(o+=(/\?.+=/.test(o)?"&":"?")+r),i=null}else i instanceof FormData||(i=JSON.stringify(e.data),Object.keys(e.headers).some(r=>r.toLowerCase()=="content-type")||(e.headers["Content-Type"]="application/json"));if(t=new XMLHttpRequest,e.response_type)try{t.responseType=e.response_type}catch{}e.timeout>0&&Number.isFinite(e.timeout)&&(t.timeout=e.timeout),t.onerror=t.ontimeout=()=>b(t),t.onreadystatechange=()=>{if(t.readyState!==4)return;let r;if(t.status>=200&&t.status<300){if(t.responseType)r=t.response;else{let y=t.getResponseHeader("Content-Type")||e.response_type||"";if(y.includes("/json"))try{r=JSON.parse(t.responseText)}catch{r=t.responseText}else y.includes("/xml")?r=new DOMParser().parseFromString(t.responseText,"application/xml"):y.includes("/html")?r=new DOMParser().parseFromString(t.responseText,"text/html"):r=t.responseText}a("onSuccess",{data:r,request:t}),d=!0,n({data:r,request:t})}else b(t);a("onComplete",{data:r,request:t})},t.open(s,o,!0);for(let r in e.headers)if(Object.prototype.hasOwnProperty.call(e.headers,r))try{t.setRequestHeader(r,e.headers[r])}catch{}t.send(i),a("onSend",{detail:e})}catch(o){b(o)}}),p}};return S(F);})();
|
|
2
|
+
if(typeof core!=="undefined"&&core&&core.default)globalThis.core=core.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var W=Symbol(),k=h=>{try{return h instanceof Element?h:document.querySelector(h)}catch{return}},E=h=>{if(h==null)return[];if(h instanceof Element)return[h];if(h instanceof NodeList||h instanceof HTMLCollection)return[...h];if(Array.isArray(h))return h.flatMap(E);try{return[...document.querySelectorAll(h)]}catch{return[]}},x=h=>k(h)?.[W],w=(h,e)=>(h&&(h[W]=e),h);var C=class{static merge(...e){let t=s=>s!==null&&typeof s=="object"&&!Array.isArray(s)&&(Object.getPrototypeOf(s)??Object.prototype)===Object.prototype,i=(s,n)=>{if(typeof s=="function"&&typeof n=="function")return(...o)=>i(s(...o),n(...o));if(!(Array.isArray(s)&&Array.isArray(n)||t(s)&&t(n)))return n;let r=Array.isArray(s)?s.slice():{...s};for(let[o,l]of Object.entries(n))r[o]=o in r?i(r[o],l):l;return r};return e.reduce(i,{})}static generate_unique_prefix(e){return e={characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",length:16,...e},[...Array(e.length)].map(t=>e.characters[Math.random()*e.characters.length|0]).join("")}static fetch(e){e instanceof HTMLFormElement&&(e={url:e.getAttribute("action")||"",method:e.getAttribute("method")||"",data:new FormData(e)}),e={url:"",method:"",data:null,headers:{},timeout:0,response_type:"",...e};let t={beforeSend:[e.before_send],onSend:[e.on_send],onSuccess:[e.on_success],onComplete:[e.on_complete],onFailed:[e.on_failed]},i,s,n,r=!1,o=new Promise((u,c)=>(s=u,n=c)),l=(u,c)=>{for(let p of t[u])if(p)try{p(c)}catch(d){console.error(`st_ajax: ${u} error`,d)}},a={then:(u,c)=>o.then(u,c),catch:u=>o.catch(u),finally:u=>o.finally(u),abort:()=>i?.abort()};for(let u of Object.keys(t))a[u]=c=>(t[u].push(c),a);let f=u=>{if(r)return;r=!0;let c=u instanceof XMLHttpRequest?{status:u.status,status_text:u.statusText,response:u.responseText,request:u}:{status:void 0,status_text:"",response:u};l("onFailed",c),n(c)};return queueMicrotask(()=>{try{let u=e.url,c=e.method,p;if(l("beforeSend",e),e.data instanceof FormData?p=e.data:e.data instanceof HTMLFormElement?(u=u||e.data.getAttribute("action"),c=c||e.data.getAttribute("method"),p=new FormData(e.data)):p=e.data,u=u||window.location.href,c=c?c.toUpperCase():"GET",p&&typeof p=="object")if(c=="GET"){let d=p instanceof FormData?new URLSearchParams(p).toString():Object.entries(p).map(([g,y])=>`${encodeURIComponent(g)}=${encodeURIComponent(y)}`).join("&");d&&(u+=(/\?.+=/.test(u)?"&":"?")+d),p=null}else p instanceof FormData||(p=JSON.stringify(e.data),Object.keys(e.headers).some(d=>d.toLowerCase()=="content-type")||(e.headers["Content-Type"]="application/json"));if(i=new XMLHttpRequest,e.response_type)try{i.responseType=e.response_type}catch{}e.timeout>0&&Number.isFinite(e.timeout)&&(i.timeout=e.timeout),i.onerror=i.ontimeout=()=>f(i),i.onreadystatechange=()=>{if(i.readyState!==4)return;let d;if(i.status>=200&&i.status<300){if(i.responseType)d=i.response;else{let g=i.getResponseHeader("Content-Type")||e.response_type||"";if(g.includes("/json"))try{d=JSON.parse(i.responseText)}catch{d=i.responseText}else g.includes("/xml")?d=new DOMParser().parseFromString(i.responseText,"application/xml"):g.includes("/html")?d=new DOMParser().parseFromString(i.responseText,"text/html"):d=i.responseText}l("onSuccess",{data:d,request:i}),r=!0,s({data:d,request:i})}else f(i);l("onComplete",{data:d,request:i})},i.open(c,u,!0);for(let d in e.headers)if(Object.prototype.hasOwnProperty.call(e.headers,d))try{i.setRequestHeader(d,e.headers[d])}catch{}i.send(p),l("onSend",{detail:e})}catch(u){f(u)}}),a}};var S=class h{#e={};#t=null;static find=x;static HOOKS=["before_load","on_load","before_paste","on_paste","on_failed","on_complete","before_init","on_init"];static html(e,...t){let i=Array.isArray(e)?e.reduce((s,n,r)=>s+t[r-1]+n):e;return new DOMParser().parseFromString(i,"text/html").body.firstElementChild}get params(){let e={};for(let[t,i]of Object.entries(this.#e))typeof i!="function"&&t!="formats"&&(e[t]=i);return e}get loading(){return!!this.#t}html=h.html;clone(e={}){return new h({...this.#e,...e,formats:{...this.#e.formats,...e.formats},parent:this})}constructor(e){this.#e={target:null,source:null,mode:"append",multiple:!0,allow_interrupt:!1,formats:{},render(t){return t},before_load:()=>{},on_load:()=>{},before_paste:()=>{},on_paste:()=>{},on_failed:()=>{},on_complete:()=>{},before_init:()=>{},on_init:()=>{},...e},this.#e.before_init.call(this,this.#e),this.target=k(this.#e.target),this.target&&w(this.target,this),this.#e.on_init.call(this,this.#e)}#s(e){return e instanceof Document?"html":typeof e=="string"?"text":"json"}#o(e){let t=this.#e,i=t.formats?.[e]??{},s={};for(let n of new Set([...Object.keys(t),...Object.keys(i)])){if(n=="formats")continue;let r=t[n],o=i[n],l;n in i&&n in t&&h.HOOKS.includes(n)&&typeof r=="function"&&typeof o=="function"?l=n=="on_load"?(a,f,u)=>{let c=r.call(this,a,f,u)??f;return o.call(this,a,c,u)??c}:(...a)=>{r.apply(this,a),o.apply(this,a)}:l=n in i?o:r,s[n]=typeof l=="function"?l.bind(this):l}return s}#c(e,t,i){if(i=="html"){let s=e.body??e.documentElement??e;return t.source?t.multiple?[...s.querySelectorAll(t.source)]:s.querySelector(t.source):t.multiple?[...s.children]:s.firstElementChild}return i=="json"&&t.source?t.source.split(".").reduce((s,n)=>s?.[n],e):e}load(e={}){let{mode:t,...i}=typeof e=="string"?{url:e}:e;if(this.#t){if(!this.#e.allow_interrupt)return this;this.#t.abort()}this.target?.setAttribute("state","loading"),this.#e.before_load.call(this,i);let s=C.fetch(i).onSuccess(({data:n,request:r})=>{let o=this.#s(n),l=this.#o(o),a=this.#c(n,l,o);a=l.on_load(n,a,r)??a;let f=[],u=l.multiple?a?.length??0:1;for(let d=0;d<u;d++){let g=l.multiple?a?.[d]:a,y=l.render(g,d);y instanceof Node&&f.push(y)}l.before_paste(f);let c=document.createDocumentFragment();f.forEach(d=>c.append(d));let p=t??l.mode;this.target&&(p=="replace"?this.target.replaceChildren(c):p=="prepend"?this.target.prepend(c):this.target.append(c)),l.on_paste(f,n)}).onFailed(n=>this.#e.on_failed.call(this,n)).onComplete(n=>this.#e.on_complete.call(this,n));return s.finally(()=>{this.#t===s&&(this.#t=null,this.target?.setAttribute("state","loaded"))}),this.#t=s,this}abort(){return this.#t?.abort(),this}};var T=class h extends HTMLElement{static#e=new Set(["disabled","checked","readonly","required","selected","hidden","open","autofocus"]);static#t=new Map;static#s=new Set;static create(e){let{app:t,setup:i=()=>{},template:s="",events:n={}}=e;if(h.#t.has(t))throw new Error(`Application "${t}" already exists!`);h.#t.set(t,{setup:i,template:s,events:n,config:e}),h.#s.forEach(r=>{r.#o!==!0&&r.#R()})}static extend(e,t={}){let i=h.#t.get(e);if(!i)throw new Error(`Application "${e}" not found!`);let s=i.config,n={...s,...t};return(s.events||t.events)&&(n.events={...s.events,...t.events}),h.create(n)}#o=!1;#c="";#h=!1;#n=new Map;#d=null;#l=new Set;#p=!1;#i=[];#r=null;#f=new Map;#u=null;#a=[];#g=new Set;#k=!1;#m=new Map;#T=0;constructor(){super(),h.#s.add(this)}#v(e){!e||!e.length||e.forEach(t=>{if(t.type==="event"&&t.element&&t.handler)t.element.removeEventListener(t.eventName,t.handler);else if(t.type==="model"&&t.element&&t.handler){let i=t.element.tagName==="SELECT"?"change":"input";t.element.removeEventListener(i,t.handler)}else t.type==="attrSync"&&t.unwatch&&t.unwatch();t.effect&&(this.#n.forEach((i,s)=>{i.delete(t.effect),i.size===0&&this.#n.delete(s)}),this.#l.delete(t.effect))})}get template(){return this.#c}get attrs(){return{get:e=>this.getAttribute(e),set:(e,t)=>this.setAttribute(e,t),remove:e=>this.removeAttribute(e),has:e=>this.hasAttribute(e),toggle:(e,t)=>this.toggleAttribute(e,t),keys:()=>Array.from(this.attributes).map(e=>e.name),entries:()=>Array.from(this.attributes).map(e=>[e.name,e.value])}}addEventListener(e,t,i){if((e==="setup"||e==="rendered")&&this.#h){queueMicrotask(()=>t(new CustomEvent(e)));return}super.addEventListener(e,t,i)}dispatchEvent(e,t=null,i={}){if(typeof e=="string"){let s=new CustomEvent(e,{cancelable:!0,...i,detail:t});return super.dispatchEvent(s)}return super.dispatchEvent(e)}applyTemplate(e=""){let t=e||this.#c;if(this.#v(this.#i),this.#i=[],this.innerHTML="",t){let s=document.createElement("template");s.innerHTML=t.trim();let n=s.content.cloneNode(!0);Array.from(n.childNodes).forEach(r=>this.#x(r)),this.#j(n)}let i=++this.#T;new Promise(s=>{let n=null,r,o=()=>{clearTimeout(n),n=setTimeout(()=>{r.disconnect(),this.#L(Array.from(this.children)).then(s)},0)};r=new MutationObserver(l=>{l.some(a=>a.type==="childList")&&o()}),r.observe(this,{childList:!0}),o()}).then(()=>{i===this.#T&&(this.#h=!0,this.dispatchEvent("rendered"))})}#j(e){HTMLElement.prototype.appendChild.call(this,e)}clone(e={}){let t=this.attrs.get("app");return h.extend(t,e)}watch(e,t,i={}){if(typeof t!="function")return()=>{};let{deep:s=!1,immediate:n=!1}=i;if(typeof e=="string"&&e.endsWith("()")){let r=e.slice(0,-2),o=this[r];if(typeof o!="function")return()=>{};let l=this.#m.get(r);if(!l){l={original:o,handlers:[]},this.#m.set(r,l);let f=(...u)=>{let c=o.apply(this,u),p=d=>{for(let g of[...l.handlers])g.callback(u,d,g.unwatch)};return c instanceof Promise?c.then(d=>(p(d),d)):(p(c),c)};this[r]=f}let a=()=>{let f=l.handlers.findIndex(u=>u.unwatch===a);f!==-1&&l.handlers.splice(f,1),l.handlers.length===0&&(this[r]=l.original,this.#m.delete(r))};return l.handlers.push({callback:t,unwatch:a}),a}if(typeof e=="string"){let r=e,o=()=>{let a=this.#a.findIndex(f=>f.unwatch===o);a!==-1&&this.#a.splice(a,1)},l={type:"key",key:r,callback:t,deep:s,immediate:n,lastValue:void 0,unwatch:o};if(this.#a.push(l),n){let a=this.#O(r);l.lastValue=s&&a!==null&&typeof a=="object"?JSON.parse(JSON.stringify(a)):a,t(a,void 0,o)}return o}if(typeof e=="function"){let r=e,o,l={type:"getter",getter:r,callback:t,deep:s,lastValue:o,effect:null,unwatch:null};this.#a.push(l);let a=()=>{let c=this.#a.indexOf(l);c!==-1&&this.#a.splice(c,1),l.effect&&(this.#n.forEach((p,d)=>{p.delete(l.effect),p.size===0&&this.#n.delete(d)}),this.#l.delete(l.effect))};l.unwatch=a;let f=()=>{let c=r.call(this);if(s?!this.#C(c,o):c!==o){let d=o;o=s&&c!==null&&typeof c=="object"?JSON.parse(JSON.stringify(c)):c,t(c,d,l.unwatch)}},u=this.#_(f);return l.effect=u,a}return()=>{}}unwatch(){[...this.#a].forEach(e=>e.unwatch()),this.#m.forEach(e=>{[...e.handlers].forEach(t=>t.unwatch())})}hasWatchers(){let e=0;return this.#m.forEach(t=>{e+=t.handlers.length}),this.#a.length+e}watched(e,t,i={}){if(typeof e=="string"&&e.endsWith("()")){let s=e.slice(0,-2),n=this.#m.get(s);n&&[...n.handlers].forEach(r=>r.unwatch())}else typeof e=="string"?this.#a.filter(s=>s.type==="key"&&s.key===e).forEach(s=>s.unwatch()):typeof e=="function"&&this.#a.filter(s=>s.type==="getter"&&s.getter===e).forEach(s=>s.unwatch());return this.watch(e,t,i)}#E(e){this.#d&&(this.#n.has(e)||this.#n.set(e,new Set),this.#n.get(e).add(this.#d))}#y(e){this.#g.add(e);let t=this.#n.get(e);if(t&&t.forEach(s=>this.#l.add(s)),this.#p){this.#k=!0;return}this.#p=!0;let i=()=>{this.#l.forEach(r=>{try{r()}catch(o){console.error("Effect execution error:",o)}}),this.#l.clear();let s=Array.from(this.#g),n=new Set;for(let r of s)for(let o of this.#a){if(o.type!=="key")continue;(o.key===r||o.deep&&(r===o.key||r.startsWith(o.key+".")))&&n.add(o)}for(let r of n){if(r.type!=="key")continue;let o=this.#O(r.key);if(!(r.deep?!this.#C(o,r.lastValue):o!==r.lastValue))continue;let a=r.lastValue;r.lastValue=r.deep&&o!==null&&typeof o=="object"?JSON.parse(JSON.stringify(o)):o,r.callback(o,a,r.unwatch)}this.#g.clear(),this.#p=!1,this.#k&&(this.#k=!1,this.#p=!0,Promise.resolve().then(i))};Promise.resolve().then(i)}#O(e){return e.split(".").reduce((t,i)=>t?.[i],this)}#C(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let n of i)if(!s.includes(n)||!this.#C(e[n],t[n]))return!1;return!0}#w(e,t=[]){if(e===null||typeof e!="object"||e.__isReactive)return e;let i=this;return new Proxy(e,{get(n,r,o){if(r==="__isReactive")return!0;let l=typeof r=="symbol"?"<symbol>":r,a=[...t,l].join(".");i.#E(a);let f=Reflect.get(n,r,o);return f!==null&&typeof f=="object"&&!f.__isReactive?i.#w(f,[...t,l]):f},set(n,r,o,l){if(n[r]===o)return!0;let f=Reflect.set(n,r,o,l),u=typeof r=="symbol"?"<symbol>":r,c=[...t,u].join(".");if(i.#y(c),Array.isArray(n)&&(r==="length"||!isNaN(r))){let p=t.join(".");p&&i.#y(p)}return f},deleteProperty(n,r){let o=Reflect.deleteProperty(n,r),l=typeof r=="symbol"?"<symbol>":r,a=[...t,l].join(".");return i.#y(a),o}})}#M(e,t){let i=this;return new Proxy(e,{apply(s,n,r){let o=Reflect.apply(s,i,r);return o instanceof Promise?o.then(l=>(i.#y(t),l)):(i.#y(t),o)}})}#_(e){let t=this.#r?{...this.#r}:null,i=()=>{let s=null;if(t){s={};for(let n of Object.keys(t))s[n]=this[n],this[n]=t[n]}this.#d=i;try{e()}finally{if(this.#d=null,s)for(let n of Object.keys(s))s[n]!==void 0?this[n]=s[n]:delete this[n]}};return i(),i}#b(e){try{return new Function("$event",`with(this) { return (${e}); }`).call(this)}catch(t){console.warn("Expression evaluation error:",e,t);return}}#N(e,t=null){try{return new Function("$event",`with(this) { ${e} }`).call(this,t)}catch(i){console.error("Statement execution error:",e,i)}}#F(e){let t=e.nodeValue,i=[],s=[],n=0,r=/\{\{(.+?)\}\}/g,o;for(;(o=r.exec(t))!==null;){o.index>n&&i.push(t.substring(n,o.index));let a=o[1].trim();i.push(null),s.push({index:i.length-1,expr:a}),n=r.lastIndex}n<t.length&&i.push(t.substring(n));let l=this.#_(()=>{s.forEach(({index:a,expr:f})=>{let u=this.#b(f);i[a]=u==null?"":String(u)}),e.nodeValue=i.join("")});this.#i.push({type:"text",node:e,effect:l})}#q(e,t){let i=t.name.slice(1),s=t.value,n=this.#r?{...this.#r}:null,r=o=>{if(n){let l={};for(let a of Object.keys(n))l[a]=this[a],this[a]=n[a];this.#N(s,o);for(let a of Object.keys(l))l[a]!==void 0?this[a]=l[a]:delete this[a]}else this.#N(s,o)};e.addEventListener(i,r),this.#i.push({type:"event",element:e,eventName:i,handler:r})}#$(e,t){let i=t.value,s=this.#_(()=>{this.#b(i)?e.style.display="":e.style.display="none"});this.#i.push({type:"show",element:e,effect:s})}#I(e,t){let i=t.value,s=this.#_(()=>{let l=this.#b(i);e.tagName==="INPUT"&&e.type==="checkbox"?e.checked=!!l:e.tagName==="INPUT"&&e.type==="radio"?e.checked=e.value===l:e.tagName==="SELECT"?e.value=l:e.value=l??""}),n=this.#r?{...this.#r}:null,r=e.tagName==="SELECT"?"change":"input",o=l=>{let a;if(e.type==="checkbox"?a=e.checked:e.type==="number"||e.type==="range"?a=e.valueAsNumber:a=e.value,n){let f={};for(let u of Object.keys(n))f[u]=this[u],this[u]=n[u];try{new Function("value",`with(this) { ${i} = value; }`).call(this,a)}catch(u){console.error("Model binding error:",i,u)}for(let u of Object.keys(f))f[u]!==void 0?this[u]=f[u]:delete this[u]}else try{new Function("value",`with(this) { ${i} = value; }`).call(this,a)}catch(f){console.error("Model binding error:",i,f)}};e.addEventListener(r,o),this.#i.push({type:"model",element:e,effect:s,handler:o})}#z(e,t){let i=t.value,s=document.createComment(`if: ${i}`);e.parentNode.insertBefore(s,e);let n=[{expr:i,element:e,bindings:[],processed:!1}],r=e.nextElementSibling;for(;r;)if(r.hasAttribute("#else-if")){let a=r.getAttribute("#else-if");n.push({expr:a,element:r,bindings:[],processed:!1}),r.removeAttribute("#else-if");let f=r.nextElementSibling;r.remove(),r=f}else if(r.hasAttribute("#else")){n.push({expr:"true",element:r,bindings:[],processed:!1}),r.removeAttribute("#else"),r.remove();break}else break;e.removeAttribute(t.name),e.remove();let o=null,l=this.#_(()=>{let a=null;for(let f of n)if(this.#b(f.expr)){a=f;break}if(o!==a){if(o&&(o.element&&o.element.parentNode&&o.element.remove(),this.#v(o.bindings),o.bindings=[]),a&&(s.parentNode.insertBefore(a.element,s.nextSibling),!a.processed)){let f=this.#i.length;this.#x(a.element),a.bindings=this.#i.slice(f),a.processed=!0}o=a}});this.#i.push({type:"conditional",placeholder:s,chain:n,effect:l})}#H(e,t){let i=t.value,s=i.match(/^\s*(\w+)\s+in\s+(.+)$/);if(!s){console.error("Invalid for syntax:",i);return}let n=s[1],r=s[2],o=e.parentNode,l=e.nextSibling;e.removeAttribute(t.name);let a=e.cloneNode(!0);e.remove();let f=[],u=this.#_(()=>{let c=this.#b(r);f.forEach(g=>{g.node&&g.node.parentNode&&g.node.remove(),this.#v(g.bindings)}),f=[];let p;if(Array.isArray(c))p=c.map((g,y)=>({value:g,key:void 0,index:y}));else if(c!==null&&typeof c=="object")p=Object.entries(c).map(([g,y],_)=>({value:y,key:g,index:_}));else return;if(p.length===0)return;let d=document.createDocumentFragment();p.forEach(({value:g,key:y,index:_})=>{let m=a.cloneNode(!0),v=this[n],b=this.$index,L=this.$key;this[n]=g,this.$index=_,y!==void 0&&(this.$key=y);let A=this.#r,D={...A,[n]:g,$index:_};y!==void 0&&(D.$key=y),this.#r=D;let V=this.#i.length;this.#x(m);let B=this.#i.slice(V);this.#r=A,v!==void 0?this[n]=v:delete this[n],b!==void 0?this.$index=b:delete this.$index,L!==void 0?this.$key=L:delete this.$key,d.appendChild(m),f.push({node:m,bindings:B})}),o.insertBefore(d,l)});this.#i.push({type:"loop",parent:o,nextSibling:l,template:a,effect:u})}#P(e,t){let i=t.name,s=t.value,n=[],r=[],o=0,l=/\{\{(.+?)\}\}/g,a;for(;(a=l.exec(s))!==null;){a.index>o&&n.push(s.substring(o,a.index));let u=a[1].trim();n.push(null),r.push({index:n.length-1,expr:u}),o=l.lastIndex}o<s.length&&n.push(s.substring(o));let f=this.#_(()=>{r.forEach(({index:c,expr:p})=>{let d=this.#b(p);n[c]=d==null?"":String(d)});let u=n.join("");h.#e.has(i)?u===""||u==="false"||u==="0"||u==="null"||u==="undefined"||!u?e.removeAttribute(i):e.setAttribute(i,""):e.setAttribute(i,u)});this.#i.push({type:"attribute",element:e,attrName:i,effect:f})}#D(e){let t=Array.from(e.attributes);for(let i of t){if(i.name==="#if")return this.#z(e,i),e.removeAttribute(i.name),!0;if(i.name==="#for")return this.#H(e,i),e.removeAttribute(i.name),!0;if(i.name==="#show")this.#$(e,i),e.removeAttribute(i.name);else if(i.name==="#model")this.#I(e,i),e.removeAttribute(i.name);else if(i.name==="#once")e.removeAttribute(i.name);else{if(i.name==="#pre")return e.removeAttribute(i.name),!0;i.name.startsWith("@")?(this.#q(e,i),e.removeAttribute(i.name)):/\{\{.+?\}\}/.test(i.value)&&this.#P(e,i)}}return!1}#x(e){if(e.nodeType===Node.ELEMENT_NODE){let t=this.#D(e);if(e.localName==="st-app")return;!t&&(e.parentNode||e.childNodes.length>0)&&Array.from(e.childNodes).forEach(i=>this.#x(i))}else e.nodeType===Node.TEXT_NODE&&/\{\{.+?\}\}/.test(e.nodeValue)&&this.#F(e)}#R(){let e=this.attrs.get("app"),t=h.#t.get(e);if(t){this.addEventListener("setup",t.setup),Object.entries(t.events).forEach(([r,o])=>this.addEventListener(r,o)),this.#c=t.template;let i=t.config,s=Object.getOwnPropertyDescriptors(i),n=new Set(["app","setup","template","events"]);Object.entries(s).forEach(([r,o])=>{if(!n.has(r)){if(o.get){let l=o.get;this.#f.set(r,l),Object.defineProperty(this,r,{get(){return this.#E(r),l.call(this)},enumerable:o.enumerable,configurable:!0})}else if(o.value!==void 0){let l=o.value,a=l;typeof l=="object"&&l!==null?a=this.#w(l,[r]):typeof l=="function"&&(a=this.#M(l,r)),Object.defineProperty(this,r,{get(){return this.#E(r),a},set(f){a!==f&&(typeof f=="object"&&f!==null?a=this.#w(f,[r]):a=f,this.#y(r))},enumerable:!0,configurable:!0})}}}),typeof this.#o=="function"&&this.#o(),this.#o=!0}else this.attrs.get("app")||(typeof this.#o=="function"&&this.#o(),this.#o=!0)}async#L(e){await Promise.all(e.map(t=>new Promise(i=>{let s=null,n=()=>{clearTimeout(s),s=setTimeout(()=>{r.disconnect(),this.#L(Array.from(t.children)).then(i)},0)},r=new MutationObserver(o=>{o.some(l=>l.type==="childList")&&n()});r.observe(t,{childList:!0}),n()})))}#S(e){return e==null?"":e===!0?"true":e===!1?"false":typeof e=="number"?String(e):typeof e=="object"?JSON.stringify(e):String(e)}#A(e){if(!e.startsWith(":")||e==="app")return;let t=e.replace(/^:+/,""),i=this.getAttribute(e),s=Object.getOwnPropertyDescriptor(this,t),n=i;if(!i&&s&&(s.get||s.value!==void 0)){let r=this[t],o=this.#S(r);this.getAttribute(e)!==o&&this.setAttribute(e,o),n=r,s=null}if(!(s&&s.set===void 0&&s.writable===!1)&&!(s&&s.get!==void 0&&s.set===void 0)){if(i)if(i==="true")n=!0;else if(i==="false")n=!1;else if(/^-?\d+(\.\d+)?$/.test(i))n=Number(i);else try{n=JSON.parse(i)}catch{n=i}if(!s||!s.set){let r=n;typeof n=="object"&&n!==null?r=this.#w(n,[t]):typeof n=="function"&&(r=this.#M(n,t));let o=e;if(Object.defineProperty(this,t,{get(){return this.#E(t),r},set(l){if(r!==l){typeof l=="object"&&l!==null?r=this.#w(l,[t]):r=l,this.#y(t);let a=this.#S(l);this.getAttribute(o)!==a&&this.setAttribute(o,a)}},enumerable:!0,configurable:!0}),typeof n=="object"&&n!==null){let l=this.watch(t,()=>{let a=this[t],f=this.#S(a);this.getAttribute(e)!==f&&this.setAttribute(e,f)},{deep:!0});this.#i.push({type:"attrSync",unwatch:l})}}else this[t]=n}}attributeChangedCallback(e,t,i){e.startsWith(":")&&e!=="app"&&t!==i&&this.#o===!0&&this.#A(e)}connectedCallback(){if(h.#s.add(this),this.#o===!0){this.#u||(this.#u=new MutationObserver(e=>{for(let t of e)t.type==="attributes"&&t.attributeName&&t.attributeName.startsWith(":")&&t.attributeName!=="app"&&this.#A(t.attributeName)}),this.#u.observe(this,{attributes:!0}));return}this.#R(),Promise.all([new Promise(e=>{if(this.#o===!0)return e();this.#o=e}),new Promise(e=>{let t=null,i=()=>{clearTimeout(t),t=setTimeout(()=>{s.disconnect(),this.#L(Array.from(this.children)).then(e)},0)},s=new MutationObserver(n=>{n.some(r=>r.type==="childList")&&i()});s.observe(this,{childList:!0}),i()})]).then(()=>{this.dispatchEvent("setup");for(let t of this.attrs.keys())!t.startsWith(":")||t==="app"||this.#A(t);let e=!1;this.childNodes.length>0&&Array.from(this.childNodes).some(i=>i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE&&i.textContent.trim()!=="")&&(this.#c?(this.applyTemplate(this.innerHTML),e=!0):this.#c=this.innerHTML),e||this.applyTemplate(),this.#o===!0&&!this.#u&&(this.#u=new MutationObserver(t=>{for(let i of t)i.type==="attributes"&&i.attributeName&&i.attributeName.startsWith(":")&&i.attributeName!=="app"&&this.#A(i.attributeName)}),this.#u.observe(this,{attributes:!0}))})}disconnectedCallback(){this.#u&&(this.#u.disconnect(),this.#u=null),this.#v(this.#i),this.#i=[];for(let e of this.#a)e.type==="getter"&&e.effect&&(this.#n.forEach((t,i)=>{t.delete(e.effect),t.size===0&&this.#n.delete(i)}),this.#l.delete(e.effect));this.#a=[],this.#m.forEach((e,t)=>{this[t]=e.original}),this.#m.clear(),this.#g.clear(),this.#n.clear(),this.#l.clear(),h.#s.delete(this)}toggleAttribute(e,t="",i=""){let s=this.getAttribute(e);this[t==""&&i==""&&(s||this.hasAttribute(e))?"removeAttribute":"setAttribute"](e,s!=t?t:i)}static{customElements.define("st-app",this)}};var $=class h{static DEFAULT_ICONS={arrow:'<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"><style type="text/css">.st0{fill:#77B3D4;}.st1{opacity:0.2;}.st2{fill:#231F20;}.st3{fill:#FFFFFF;}</style><g id="Layer_1"><g><circle class="st0" cx="32" cy="32" r="32"/></g><g class="st1"><path class="st2" d="M49.5,33.9L35.3,15.7c-1.8-2.3-4.7-2.3-6.5,0L14.5,33.9c-1.8,2.3-1,4.1,1.7,4.1H24v12c0,2.2,1.8,4,4,4h8c2.2,0,4-1.8,4-4V38h7.8C50.6,38,51.3,36.1,49.5,33.9z"/></g><g><path class="st3" d="M40,48c0,2.2-1.8,4-4,4h-8c-2.2,0-4-1.8-4-4V24c0-2.2,1.8-4,4-4h8c2.2,0,4,1.8,4,4V48z"/></g><g><path class="st3" d="M16.2,36c-2.7,0-3.5-1.9-1.7-4.1l14.3-18.1c1.8-2.3,4.7-2.3,6.5,0l14.3,18.1c1.8,2.3,1,4.1-1.7,4.1H16.2z"/></g></g><g id="Layer_2"></g></svg>'};static#e={settings:{position:"bottom-right"},condition:{name:"scroll",options:{hiding_type:"opacity",transition:"0.3s",attribute:[],margin_top:Math.min(window.innerHeight,document.documentElement.clientHeight),margin_left:void 0,margin_right:void 0,margin_bottom:void 0}},action:{name:"scroll",options:{selector:void 0,hiding_type:"opacity",setAttribute:void 0,removeAttribute:void 0,toggleAttribute:void 0,top:0,left:void 0,behavior:"smooth",hook:function(){}}},widget_container:{id:void 0,class:void 0,style:{}},widget:{id:void 0,class:void 0,style:{}},button_container:{id:void 0,class:void 0,style:{}},button:{src:h.DEFAULT_ICONS.arrow}};static#t={widget_container:{position:"fixed",width:"60px",height:"60px",margin:"30px"},widget:{position:"absolute"},button_container:{display:"flex","justify-content":"center","align-items":"center",overflow:"hidden",width:"60px",height:"60px","border-radius":"50%",cursor:"pointer"},button:{width:"100%",height:"100%","object-fit":"cover"}};static#s(...e){function t(s,n){function r(o,l,a){if(typeof l[o]=="object")for(let f in l[o])a[o]||(a[o]={}),r(f,l[o],a[o]);else a[o]=l[o]}for(let o in s)r(o,s,n)}let i={};for(let s of e)t(s,i);return i}static#o(e){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i="";for(let s=0;s<e;s++)i+=t.charAt(Math.floor(Math.random()*t.length));return i}static#c={opacity:"0",visibility:"hidden",display:"none"};#h="st_"+h.#o(16);#n=this.#h+"_wc";#d=this.#h+"_w";#l=this.#h+"_bc";#p=this.#h+"_b";#i=document.createElement("style");#r=document.createElement("div");#f=document.createElement("div");#u=document.createElement("div");#a(e,t,i){new RegExp(e+"{.*?"+t+":.*?;.*?}").test(this.#i.innerHTML)?this.#i.innerHTML=this.#i.innerHTML.replace(new RegExp("("+e+"{.*?"+t+":).*?(;.*?})"),"$1"+i+"$2"):new RegExp(e+"{.*?}").test(this.#i.innerHTML)?this.#i.innerHTML=this.#i.innerHTML.replace(new RegExp("("+e+"{.*?)(})"),"$1"+t+":"+i+";$2"):this.#i.innerHTML+=e+"{"+t+":"+i+";}"}#g(e,t){for(let i in t)this.#a(e,i,t[i])}constructor(e){function t(r,o,l=!1){return{show:function(){r.style.removeProperty(o)},hide:function(){r.style.setProperty(o,l?"unset":h.#c[o])}}}function i(r){switch(r){case"top-left":return{top:"0",left:"0"};case"top-right":return{top:"0",right:"0"};case"bottom-left":return{bottom:"0",left:"0"};case"bottom-right":default:return{bottom:"0",right:"0"}}}function s(r){return r?typeof r=="object"?[r[0]??"st_active",r[1]??"",r[2]??""]:[r??"st_active","",""]:null}let n=h.#s(h.#e,e);if(this.#g("."+this.#n,h.#t.widget_container),this.#g("."+this.#d,h.#t.widget),this.#g("."+this.#l,h.#t.button_container),this.#g("."+this.#p,h.#t.button),this.#g("."+this.#n,i(n.settings.position)),this.#g("."+this.#d,i(n.settings.position)),this.#r.classList.add(this.#n),this.#g("."+this.#n,n.widget_container.style),n.widget_container.class&&this.#r.classList.add(n.widget_container.class),n.widget_container.id&&(this.#r.id=n.widget_container.id),this.#f.classList.add(this.#d),this.#g("."+this.#d,n.widget.style),n.widget.class&&this.#f.classList.add(n.widget.class),n.widget.id&&(this.#f.id=n.widget.id),this.#u.classList.add(this.#l),this.#g("."+this.#l,n.button_container.style),n.button_container.class&&this.#u.classList.add(n.button_container.class),n.button_container.id&&(this.#u.id=n.button_container.id),n.condition){let r=function(a,f){let u=s(f);return{set:function(){u&&(u[1]?a.setAttribute(u[0],u[1]):a.setAttribute(u[0],""))},remove:function(){u&&(u[1]?u[2]?a.setAttribute(u[0],u[2]):a.setAttribute(u[0],""):a.removeAttribute(u[0]))}}};if(!n.condition.options.hiding_type in h.#c)return;let o=t(this.#f,n.condition.options.hiding_type),l=r(this.#f,n.condition.options.attribute);switch(o.hide(),l.remove(),n.condition.name){case"hover":this.#r.addEventListener("mouseenter",function(){o.show(),l.set()}),this.#r.addEventListener("mouseleave",function(){o.hide(),l.remove()});break;case"scroll":default:let a=Math.min(window.innerHeight,document.documentElement.clientHeight),f=Math.min(window.innerWidth,document.documentElement.clientWidth),u=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight),c=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.body.clientWidth,document.documentElement.clientWidth),p=n.condition.options.margin_top,d=n.condition.options.margin_bottom,g=n.condition.options.margin_right,y=n.condition.options.margin_left;window.addEventListener("scroll",function(){let _=window.pageYOffset||window.scrollY||document.documentElement.scrollTop,m=_+a,v=window.pageXOffset||window.scrollX||document.documentElement.scrollLeft,b=v+f;_>p||m<u-d||b<c-g||v>y?(o.show(),l.set()):(o.hide(),l.remove())});break}n.condition.options.transition&&this.#f.style.setProperty("transition",n.condition.options.transition)}if(n.action)switch(n.action.name){case"show_popup":if(!n.action.options.selector||!n.action.options.hiding_type in h.#c)return;this.#u.addEventListener("click",function(){for(let r of document.querySelectorAll(n.action.options.selector)){let o=t(r,n.action.options.hiding_type,!0);if(r.style[h.#c[n.action.options.hiding_type]]?o.show():o.hide(),n.action.options.setAttribute){let l=s(n.action.options.setAttribute);r.setAttribute(l[0],l[1])}n.action.options.removeAttribute&&r.removeAttribute(n.action.options.removeAttribute),n.action.options.toggleAttribute&&r.toggleAttribute(n.action.options.toggleAttribute)}});break;case"function":this.#u.addEventListener("click",n.action.options.hook);break;case"scroll":default:this.#u.addEventListener("click",function(){window.scrollTo({top:n.action.options.top,left:n.action.options.left,behavior:n.action.options.behavior})});break}new RegExp("^<svg.*?</svg>$").test(n.button.src)?this.#u.innerHTML=n.button.src:this.#u.innerHTML="<img src="+n.button.src+' alt="icon">',this.#u.childNodes[0].classList.add(this.#p),this.#i.setAttribute("widget",this.#h),document.head.appendChild(this.#i),this.#f.appendChild(this.#u),this.#r.appendChild(this.#f),document.querySelector("body").appendChild(this.#r)}},U=$;var O=class h{static set(e,t,i={}){if(i={path:"/",expires:3600,...i},!(i.expires instanceof Date)){let s=i.expires;i.expires=new Date(typeof s=="number"?Date.now()+s*1e3:Date.parse(s)||Date.parse(s.replace(/-/g,"/")))}document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+"; expires="+i.expires.toUTCString()+"; path="+i.path+(i.domain?"; domain="+i.domain:"")+(i.secure?"; secure":"")+(i.sameSite?"; samesite="+i.sameSite:"")}static get(e){e=encodeURIComponent(e);let t=document.cookie.split(";");for(let i=0;i<t.length;i++){let s=t[i].trim();if(s.startsWith(e+"=")){let n=decodeURIComponent(s.substring(e.length+1));try{return JSON.parse(n)}catch{return n}}}return null}static delete(e,t={}){h.set(e,"",{expires:0,...t})}static callback(e,t,i={}){i={interval:0,delay:0,value:!0,...i};let s=setInterval(()=>{h.get(e)===null&&(h.set(e,i.value,i),setTimeout(()=>{t(e)},i.delay*1e3)),i.interval||clearInterval(s)},i.interval*1e3)}static consent(e){e={content:"<div><span>\u042D\u0442\u043E\u0442 \u0441\u0430\u0439\u0442 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043B\u044B cookies \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044B \u0441\u0431\u043E\u0440\u0430 \u0442\u0435\u0445\u043D\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u0434\u0430\u043D\u043D\u044B\u0445 \u043F\u043E\u0441\u0435\u0442\u0438\u0442\u0435\u043B\u0435\u0439 (\u0434\u0430\u043D\u043D\u044B\u0435 \u043E\u0431 IP-\u0430\u0434\u0440\u0435\u0441\u0435, \u043C\u0435\u0441\u0442\u043E\u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0438 \u0438 \u0442.\u0434.) \u0434\u043B\u044F \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0435\u043D\u0438\u044F \u0440\u0430\u0431\u043E\u0442\u043E\u0441\u043F\u043E\u0441\u043E\u0431\u043D\u043E\u0441\u0442\u0438 \u0438 \u0443\u043B\u0443\u0447\u0448\u0435\u043D\u0438\u044F \u043A\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u043D\u0438\u044F.</span><div><button action='accept'>\u041F\u0440\u0438\u043D\u044F\u0442\u044C</button><button action='decline'>\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C</button></div></div>",container:"body",location:"bottom",zIndex:1e3,name:"cookie_consent",interval:5,...e};let t=document.createElement("container");if(e.container=="body"&&Object.assign(t.style,{position:"absolute",overflow:"hidden",width:"max-content",height:"max-content",maxWidth:"100vw",maxHeight:"100vh",zIndex:e.zIndex,transition:"inherit",pointerEvents:"all",display:"none",...(()=>{let i=(e.location||"").toLowerCase().split(/\s+/),s={top:i.includes("top")?0:i.includes("bottom")?void 0:"50%",bottom:i.includes("bottom")?0:void 0,left:i.includes("left")?0:i.includes("right")?void 0:"50%",right:i.includes("right")?0:void 0},n=s.left==="50%"?"translateX(-50%)":"",r=s.top==="50%"?"translateY(-50%)":"";return(n||r)&&(s.transform=`${n} ${r}`.trim()),s})()}),document.querySelector(e.container).append(t),!(e.content instanceof Element)){let i=e.content;e.content=i.trim().startsWith("<")?new DOMParser().parseFromString(i,"text/html").body.firstElementChild:document.querySelector(i)??(()=>{throw new Error("\u0421\u0435\u043B\u0435\u043A\u0442\u043E\u0440 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D")})()}t.append(e.content),h.callback(e.name,i=>{["accept","decline"].forEach(s=>{t.querySelectorAll(`[action=${s}]`).forEach(n=>{n.addEventListener("click",r=>{h.set(e.name,s=="accept",e),t.style.display="none"})})}),t.style.display=""},{...e,value:null})}};var I=class h{static DEFAULT_ICONS={link:'<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><g id="chain"><circle cx="16" cy="16" fill="#33d9b2" r="16" style="fill: rgb(119, 179, 212);"></circle><g fill="#fff" fill-rule="evenodd"><path d="m16.75 10h-7.5a.5.5 0 0 0 -.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5v-7.5a.5.5 0 0 0 -1 0v7h-11v-11h7a.5.5 0 0 0 0-1z" fill="#fff" style="fill: rgb(255, 255, 255);"></path><path d="m21.543 9.5-6.643 6.646a.5.5 0 0 0 .708.707l6.646-6.646v1.793a.5.5 0 0 0 1 0v-3a.5.5 0 0 0 -.5-.5h-3a.5.5 0 0 0 0 1z" fill="#fff" style="fill: rgb(255, 255, 255);"></path></g></g></svg>',email:'<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"><style type="text/css">.st0{fill:#77B3D4;}.st1{opacity:0.2;}.st2{fill:#231F20;}.st3{fill:#E0E0D1;}.st4{fill:#FFFFFF;}</style><g id="Layer_1"><g><circle class="st0" cx="32" cy="32" r="32"/></g><g><g class="st1"><path class="st2" d="M52,44c0,2.2-1.8,4-4,4H16c-2.2,0-4-1.8-4-4V24c0-2.2,1.8-4,4-4h32c2.2,0,4,1.8,4,4V44z"/></g><g><path class="st3" d="M52,42c0,2.2-1.8,4-4,4H16c-2.2,0-4-1.8-4-4V22c0-2.2,1.8-4,4-4h32c2.2,0,4,1.8,4,4V42z"/></g><g class="st1"><g><path class="st2" d="M35.5,30.2c-1.9-2.1-5.1-2.1-7,0L13,43.2c-0.2,0.2-0.3,0.4-0.5,0.6c0.7,1.3,2,2.2,3.4,2.2h32c1.5,0,2.7-0.9,3.4-2.2c-0.1-0.2-0.3-0.4-0.5-0.6L35.5,30.2z"/></g></g><g><g><path class="st3" d="M35.5,32c-1.9-1.9-5.1-1.9-7,0L13,43.5c-0.2,0.2-0.3,0.3-0.5,0.5c0.7,1.2,2,1.9,3.4,1.9h32c1.5,0,2.7-0.8,3.4-1.9c-0.1-0.2-0.3-0.3-0.5-0.5L35.5,32z"/></g></g><g class="st1"><g><path class="st2" d="M12.6,20.2c0.7-1.3,2-2.2,3.4-2.2h32c1.5,0,2.7,0.9,3.4,2.2c-0.1,0.2-0.3,0.4-0.5,0.6l-15.4,13c-1.9,2.1-5.1,2.1-7,0L12.6,20.2z"/></g></g><g><g><path class="st4" d="M28.5,32c1.9,1.9,5.1,1.9,7,0L51,20.5c0.2-0.2,0.3-0.3,0.5-0.5c-0.7-1.2-2-1.9-3.4-1.9H16c-1.5,0-2.7,0.8-3.4,1.9c0.1,0.2,0.3,0.3,0.5,0.5L28.5,32z"/></g></g></g></g><g id="Layer_2"></g></svg>',telegram:'<svg viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid"><g><path d="M128,0 C57.307,0 0,57.307 0,128 L0,128 C0,198.693 57.307,256 128,256 L128,256 C198.693,256 256,198.693 256,128 L256,128 C256,57.307 198.693,0 128,0 L128,0 Z" fill="#40B3E0"></path><path d="M190.2826,73.6308 L167.4206,188.8978 C167.4206,188.8978 164.2236,196.8918 155.4306,193.0548 L102.6726,152.6068 L83.4886,143.3348 L51.1946,132.4628 C51.1946,132.4628 46.2386,130.7048 45.7586,126.8678 C45.2796,123.0308 51.3546,120.9528 51.3546,120.9528 L179.7306,70.5928 C179.7306,70.5928 190.2826,65.9568 190.2826,73.6308" fill="#FFFFFF"></path><path d="M98.6178,187.6035 C98.6178,187.6035 97.0778,187.4595 95.1588,181.3835 C93.2408,175.3085 83.4888,143.3345 83.4888,143.3345 L161.0258,94.0945 C161.0258,94.0945 165.5028,91.3765 165.3428,94.0945 C165.3428,94.0945 166.1418,94.5735 163.7438,96.8115 C161.3458,99.0505 102.8328,151.6475 102.8328,151.6475" fill="#D2E5F1"></path><path d="M122.9015,168.1154 L102.0335,187.1414 C102.0335,187.1414 100.4025,188.3794 98.6175,187.6034 L102.6135,152.2624" fill="#B5CFE4"></path></g></svg>',whatsapp:'<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>Whatsapp-color</title><desc>Created with Sketch.</desc><defs></defs><g id="Icons" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Color-" transform="translate(-700.000000, -360.000000)" fill="#67C15E"><path d="M723.993033,360 C710.762252,360 700,370.765287 700,383.999801 C700,389.248451 701.692661,394.116025 704.570026,398.066947 L701.579605,406.983798 L710.804449,404.035539 C714.598605,406.546975 719.126434,408 724.006967,408 C737.237748,408 748,397.234315 748,384.000199 C748,370.765685 737.237748,360.000398 724.006967,360.000398 L723.993033,360.000398 L723.993033,360 Z M717.29285,372.190836 C716.827488,371.07628 716.474784,371.034071 715.769774,371.005401 C715.529728,370.991464 715.262214,370.977527 714.96564,370.977527 C714.04845,370.977527 713.089462,371.245514 712.511043,371.838033 C711.806033,372.557577 710.056843,374.23638 710.056843,377.679202 C710.056843,381.122023 712.567571,384.451756 712.905944,384.917648 C713.258648,385.382743 717.800808,392.55031 724.853297,395.471492 C730.368379,397.757149 732.00491,397.545307 733.260074,397.27732 C735.093658,396.882308 737.393002,395.527239 737.971421,393.891043 C738.54984,392.25405 738.54984,390.857171 738.380255,390.560912 C738.211068,390.264652 737.745308,390.095816 737.040298,389.742615 C736.335288,389.389811 732.90737,387.696673 732.25849,387.470894 C731.623543,387.231179 731.017259,387.315995 730.537963,387.99333 C729.860819,388.938653 729.198006,389.89831 728.661785,390.476494 C728.238619,390.928051 727.547144,390.984595 726.969123,390.744481 C726.193254,390.420348 724.021298,389.657798 721.340985,387.273388 C719.267356,385.42535 717.856938,383.125756 717.448104,382.434484 C717.038871,381.729275 717.405907,381.319529 717.729948,380.938852 C718.082653,380.501232 718.421026,380.191036 718.77373,379.781688 C719.126434,379.372738 719.323884,379.160897 719.549599,378.681068 C719.789645,378.215575 719.62006,377.735746 719.450874,377.382942 C719.281687,377.030139 717.871269,373.587317 717.29285,372.190836 Z" id="Whatsapp"></path></g></g></svg>'};static#e={settings:{position:"bottom-right"},condition:{name:"scroll",options:{hiding_type:"opacity",transition:"0.3s",attribute:[],margin_top:Math.min(window.innerHeight,document.documentElement.clientHeight),margin_left:void 0,margin_right:void 0,margin_bottom:void 0}},widget_container:{id:void 0,class:void 0,style:{}},widget:{id:void 0,class:void 0,style:{}},links_container:{id:void 0,class:void 0,style:{}},links:{0:{href:"undefined",src:h.DEFAULT_ICONS.link,id:void 0,class:void 0,style:{}}}};static#t={widget_container:{position:"fixed",width:"60px",height:"60px",margin:"30px"},widget:{position:"absolute",display:"flex","flex-direction":"column",gap:"15px"},links_container:{display:"flex","justify-content":"center","align-items":"center",overflow:"hidden",width:"60px",height:"60px","border-radius":"50%",cursor:"pointer"},link:{width:"100%",height:"100%","object-fit":"cover"}};static#s(...e){function t(s,n){function r(o,l,a){if(typeof l[o]=="object")for(let f in l[o])a[o]||(a[o]={}),r(f,l[o],a[o]);else a[o]=l[o]}for(let o in s)r(o,s,n)}let i={};for(let s of e)t(s,i);return i}static#o(e){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i="";for(let s=0;s<e;s++)i+=t.charAt(Math.floor(Math.random()*t.length));return i}static#c={opacity:"0",visibility:"hidden",display:"none"};#h="st_"+h.#o(16);#n=this.#h+"_wc";#d=this.#h+"_w";#l=this.#h+"_ic";#p=this.#h+"_i";#i=document.createElement("style");#r=document.createElement("div");#f=document.createElement("div");#u(e,t,i){new RegExp(e+"{.*?"+t+":.*?;.*?}").test(this.#i.innerHTML)?this.#i.innerHTML=this.#i.innerHTML.replace(new RegExp("("+e+"{.*?"+t+":).*?(;.*?})"),"$1"+i+"$2"):new RegExp(e+"{.*?}").test(this.#i.innerHTML)?this.#i.innerHTML=this.#i.innerHTML.replace(new RegExp("("+e+"{.*?)(})"),"$1"+t+":"+i+";$2"):this.#i.innerHTML+=e+"{"+t+":"+i+";}"}#a(e,t){for(let i in t)this.#u(e,i,t[i])}constructor(e){function t(n,r,o=!1){return{show:function(){n.style.removeProperty(r)},hide:function(){n.style.setProperty(r,o?"unset":h.#c[r])}}}function i(n){switch(n){case"top-left":return{top:"0",left:"0"};case"top-right":return{top:"0",right:"0"};case"bottom-left":return{bottom:"0",left:"0"};case"bottom-right":default:return{bottom:"0",right:"0"}}}let s=h.#s(h.#e,e);if(this.#a("."+this.#n,h.#t.widget_container),this.#a("."+this.#d,h.#t.widget),this.#a("."+this.#l,h.#t.links_container),this.#a("."+this.#p,h.#t.link),this.#a("."+this.#n,i(s.settings.position)),this.#a("."+this.#d,i(s.settings.position)),this.#a("."+this.#l,s.links_container.style),this.#f.classList.add(this.#n),this.#a("."+this.#n,s.widget_container.style),s.widget_container.class&&this.#f.classList.add(s.widget_container.class),s.widget_container.id&&(this.#f.id=s.widget_container.id),this.#r.classList.add(this.#d),this.#a("."+this.#d,s.widget.style),s.widget.class&&this.#r.classList.add(s.widget.class),s.widget.id&&(this.#r.id=s.widget.id),s.condition){let n=function(l,a){function f(c){return c?typeof c=="object"?[c[0]??"st_active",c[1]??"",c[2]??""]:[c??"st_active","",""]:null}let u=f(a);return{set:function(){u&&(u[1]?l.setAttribute(u[0],u[1]):l.setAttribute(u[0],""))},remove:function(){u&&(u[1]?u[2]?l.setAttribute(u[0],u[2]):l.setAttribute(u[0],""):l.removeAttribute(u[0]))}}};if(!s.condition.options.hiding_type in h.#c)return;let r=t(this.#r,s.condition.options.hiding_type),o=n(this.#r,s.condition.options.attribute);switch(r.hide(),o.remove(),s.condition.name){case"hover":this.#f.addEventListener("mouseenter",function(){r.show(),o.set()}),this.#f.addEventListener("mouseleave",function(){r.hide(),o.remove()});break;case"scroll":default:let l=Math.min(window.innerHeight,document.documentElement.clientHeight),a=Math.min(window.innerWidth,document.documentElement.clientWidth),f=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight),u=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.body.clientWidth,document.documentElement.clientWidth),c=s.condition.options.margin_top,p=s.condition.options.margin_bottom,d=s.condition.options.margin_right,g=s.condition.options.margin_left;window.addEventListener("scroll",function(){let y=window.pageYOffset||window.scrollY||document.documentElement.scrollTop,_=y+l,m=window.pageXOffset||window.scrollX||document.documentElement.scrollLeft,v=m+a;y>c||_<f-p||v<u-d||m>g?(r.show(),o.set()):(r.hide(),o.remove())});break}s.condition.options.transition&&this.#r.style.setProperty("transition",s.condition.options.transition)}for(let n in s.links){let r=document.createElement("a");r.classList.add(this.#l),s.links_container.class&&r.classList.add(s.links_container.class),s.links[n].class&&r.classList.add(s.links[n].class),s.links[n].id&&(r.id=s.links[n].id,this.#a("#"+s.links[n].id,s.links[n].style)),r.setAttribute("href",s.links[n].href),r.setAttribute("target","_blank"),r.setAttribute("rel","nofollow noopener noreferrer"),new RegExp("^<svg.*?</svg>$").test(s.links[n].src)?r.innerHTML=s.links[n].src:r.innerHTML="<img src="+s.links[n].src+' alt="icon">',r.childNodes[0].classList.add(this.#p),this.#r.appendChild(r)}this.#i.setAttribute("widget",this.#h),document.head.appendChild(this.#i),this.#f.appendChild(this.#r),document.querySelector("body").appendChild(this.#f)}},X=I;var z=class{#e="_";#t=!0;#s=[];#o=[];#c(e,t){let i="",s=0,n=0;for(let r of t)for(;n+s<e.length;){let[o,l,a]=e[n+s];if(!l)i+=o,s++;else{new RegExp(`^${o}$`).test(r)&&(i+=r,n++);break}}if(this.#e&&this.#t)for(;n+s<e.length;)i+=e[n+s++][1]?e[n+s-1][2]:e[n+s-1][0];else n?n+s<e.length&&!e[n+s][1]&&(i+=e[n+s++][0]):i="";return[i,n,e.filter(r=>r[1]).length==n]}#h(e){return this.#s.map(t=>this.#c(t,e)).reduce((t,i,s)=>!t||i[1]>t[0][1]?[i,s]:t,null)}#n(e){return e.replace(/{(\d+)\*{([^}]*?)}(.*?)}/g,(t,i,s,n)=>`{{${s}}${n}}`.repeat(i)).split(/({{.*?}.*?})/).filter(Boolean).map(t=>{let[,i]=t.match(/^{{(.*?)}.*?}$/)||[],[,s]=t.match(/^{{.*?}=(.*?)}$/)||[];return[i||t,!!i,s||this.#e]})}#d(e=null){if(this.#l()){console.warn("\u041F\u043E\u043F\u044B\u0442\u043A\u0430 \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u043C\u0430\u0441\u043A\u0443 \u043F\u043E\u0441\u043B\u0435 \u0443\u0434\u0430\u043B\u0435\u043D\u0438\u044F \u043F\u0440\u0430\u0432\u0438\u043B",this);return}(e?[e]:this.#o).forEach(t=>{t.best_mask=this.#h(t.value),t.input.value=t.best_mask[0][0],Object.assign(t.input.dataset,{mask_id:t.best_mask[1],progress:t.best_mask[0][1],is_full:t.best_mask[0][2]})})}#l(){return!this.#s.some(e=>!e!=null)}add_mask(e){return this.#s.push(this.#n(e)),this.#d(),this.#s.length-1}remove_mask(e){delete this.#s[e],this.#d()}set_masks(e){this.#s=e.map(t=>this.#n(t)),this.#d()}constructor(e){let t=this;t.#e=e.default_filler??t.#e,t.#t=e.placeholder??t.#t,(e.inputs?e.inputs instanceof Element?[e.inputs]:Array.from(e.inputs):Array.from(document.querySelectorAll(e.selector))).forEach(s=>{let n={input:s,value:s.value.split().filter(Boolean)};s.addEventListener("input",r=>{if(r.preventDefault(),this.#l()){console.error("\u041D\u0435\u0442 \u043C\u0430\u0441\u043E\u043A \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u043E\u043B\u044F.",this);return}if(r.data===null){let o=[];for(let l of n.value)if(o.push(l),this.#c(this.#s[n.best_mask[1]],o)[1]==n.best_mask[0][1]){o.pop();break}n.value=o}else n.value.push(...r.data);t.#d(n),typeof e.on_input=="function"&&e.on_input(s,{mask_id:n.best_mask[1],progress:n.best_mask[0][1],is_full:n.best_mask[0][2]})}),t.#o.push(n),s.closest("form")?.addEventListener("reset",()=>{n.value=[],t.#d(n)})}),e.masks&&t.set_masks(e.masks)}};var Y=z;var M=class h{modal;overlay;area;container;content;#e={};#t={};#s="hidden";static find=x;get state(){return this.#s}get params(){return this.#e}clone(e){let t=this.content.cloneNode(!0);return t.id=e.id??(t.id||"modal").replace(/#+$/,"")+(e.suffix??"_copy"),new h({...this.#e,...this.#t,content:t,...e,parent:this})}constructor(e){e={zIndex:1e3,duration:0,container:"body",overlay:!0,overlay_shading:.5,overlay_blur:"5px",overlay_scroll_lock:!0,content:"<div></div>",location:"center center",trigger:null,close_by_overlay:!0,close_by_esc:!0,auto_close:-1,allow_interrupt:!1,before_show:()=>{},on_show:()=>{},before_hide:()=>{},on_hide:()=>{},before_init:()=>{},on_init:()=>{},...e};let t,i,s;for(let[o,l]of Object.entries(e))typeof l=="function"?(this[o]=l.bind(this),this.#t[o]=l):this.#e[o]=l;this.before_init(this.#e),this.modal=document.createElement("modal"),w(this.modal,this),Object.assign(this.modal.style,{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",zIndex:this.#e.zIndex,transition:`all ${this.#e.duration}s`,pointerEvents:"none",display:"none",overflow:"hidden"}),this.modal.setAttribute("state","hidden");try{k(this.#e.container).append(this.modal)}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E \u0432 \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440")}this.#e.overlay&&(this.overlay=document.createElement("modal-overlay"),w(this.overlay,this),Object.assign(this.overlay.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:`rgba(0, 0, 0, ${this.#e.overlay_shading})`,backdropFilter:`blur(${this.#e.overlay_blur})`,zIndex:++this.#e.zIndex,transition:"inherit"}),this.modal.append(this.overlay));let n=(this.#e.location||"").toLowerCase().split(/\s+/);this.area=document.createElement("modal-area"),w(this.area,this),Object.assign(this.area.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",overflowY:"auto",overflowX:"clip",display:"flex",alignItems:"flex-start",justifyContent:n.includes("left")?"flex-start":n.includes("right")?"flex-end":"center",zIndex:++this.#e.zIndex,pointerEvents:"all",transition:"inherit"}),this.modal.append(this.area),this.#e.close_by_overlay&&this.area.addEventListener("click",o=>{this.container.contains(o.target)||this.hide(o)}),this.container=document.createElement("modal-container"),w(this.container,this),Object.assign(this.container.style,{position:"relative",flexShrink:"0",width:"max-content",height:"max-content",maxWidth:"100vw",zIndex:++this.#e.zIndex,transition:"inherit",pointerEvents:"all",marginTop:n.includes("top")?"0":"auto",marginBottom:n.includes("bottom")?"0":"auto",marginLeft:n.includes("left")?"0":"auto",marginRight:n.includes("right")?"0":"auto"}),this.area.append(this.container);try{this.content=k(this.#e.content)??new DOMParser().parseFromString(this.#e.content,"text/html").body.firstElementChild}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u0434\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u0432 \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E")}this.container.append(this.content),w(this.content,this),this.content.style.transition="inherit",this.content.querySelectorAll('[action="close"]').forEach(o=>{o.addEventListener("click",()=>this.hide())});let r=o=>{o.before_func(o.data),clearTimeout(t),this.modal.style.display="flex",requestAnimationFrame(()=>{this.#s=o.process,this.modal.setAttribute("state",this.#s),requestAnimationFrame(()=>{t=setTimeout(()=>{this.#s=o.final,this.modal.setAttribute("state",this.#s),o.hide&&(this.modal.style.display="none"),o.after_func(o.data)},this.#e.duration*1e3)})})};this.show=(o=null)=>{(this.#s=="hidden"||this.#e.allow_interrupt&&this.#s=="hiding")&&(r({before_func:this.before_show,after_func:this.on_show,process:"showing",final:"shown",hide:!1,data:o}),this.#e.overlay_scroll_lock&&this.overlay&&(s=document.documentElement.style.scrollBehavior,i=document.body.style,i={position:i.position,top:i.top,left:i.left,width:i.width,scroll_Y:window.scrollY||document.documentElement.scrollTop,scroll_X:window.scrollX||document.documentElement.scrollLeft},document.documentElement.style.scrollBehavior="unset",Object.assign(document.body.style,{position:"fixed",width:"100vw",top:`-${i.scroll_Y}px`,left:`-${i.scroll_X}px`})),this.#e.auto_close>0&&(clearTimeout(t),t=setTimeout(()=>{this.hide()},this.#e.auto_close*1e3)))},this.hide=(o=null)=>{(this.#s=="shown"||this.#e.allow_interrupt&&this.#s=="showing")&&(r({before_func:this.before_hide,after_func:this.on_hide,process:"hiding",final:"hidden",hide:!0,data:o}),clearTimeout(t),t=setTimeout(()=>{i&&(Object.assign(document.body.style,i),window.scrollTo(i.scroll_X,i.scroll_Y)),s!=null&&(document.documentElement.style.scrollBehavior=s)},this.#e.duration*1e3))},this.#e.close_by_esc&&document.addEventListener("keydown",o=>{(o.code==="Escape"||o.keyCode===27)&&this.hide(o)}),this.#e.trigger&&document.querySelectorAll(this.#e.trigger).forEach(o=>{o.addEventListener("click",()=>this.show(o))}),this.on_init(this.#e)}};var H=class h{static#e=new Map;constructor(e={}){let t=Object.assign({selector:null,root:null,rootMargin:"0px",threshold:0,before_init:()=>{},on_init:()=>{}},e);if(!t.selector)throw new Error("st_observer: selector required");let i=typeof t.selector=="string"?t.selector:Symbol("selector");if(h.#e.has(i))return this._internal=h.#e.get(i),this;let s={key:i,selector:t.selector,options:{root:t.root,rootMargin:t.rootMargin,threshold:t.threshold},observer:null,callbacks:new WeakMap,elements:new Set,_connected:!1,crossRules:new Map};t.before_init();let n=()=>({on_show:new Set,once_show:new Set,while_show:new Set,on_hide:new Set,once_hide:new Set,while_hide:new Set,_once_shown:!1,_once_hidden:!1,_wasIntersecting:!1}),r=(d,...g)=>{try{d(...g)}catch(y){console.error(y)}},o=(d,g)=>!(d.right<=g.left||d.left>=g.right||d.bottom<=g.top||d.top>=g.bottom),l=d=>d?typeof d=="string"?Array.from(document.querySelectorAll(d)):d instanceof Element?[d]:NodeList.prototype.isPrototypeOf(d)||Array.isArray(d)?Array.from(d):[]:typeof s.selector=="string"?Array.from(document.querySelectorAll(s.selector)):s.selector instanceof Element?[s.selector]:NodeList.prototype.isPrototypeOf(s.selector)||Array.isArray(s.selector)?Array.from(s.selector):[],a=d=>({goals:new Set(d),on_cross:new Set,once_cross:new Set,while_cross:new Set,_once_done:new Set,_wasCrossing:new Map}),f=d=>{let g=s.crossRules.get(d);if(!g||!g.length||!document.contains(d))return;let y=d.getBoundingClientRect();for(let _ of g)for(let m of _.goals){if(!document.contains(m)){_._wasCrossing.set(m,!1);continue}let v=m.getBoundingClientRect(),b=o(y,v);b&&_.while_cross.forEach(A=>r(A,{target:d,goal:m},d,m)),!!!_._wasCrossing.get(m)&&b&&_.on_cross.forEach(A=>r(A,{target:d,goal:m},d,m)),b&&!_._once_done.has(m)&&(_.once_cross.forEach(A=>r(A,{target:d,goal:m},d,m)),_._once_done.add(m)),_._wasCrossing.set(m,!!b)}},u=()=>{for(let d of Array.from(s.crossRules.keys()))if(document.contains(d))try{f(d)}catch(g){console.error(g)}},c=()=>d=>{for(let g of d){let y=g.target,_=s.callbacks.get(y);_||(_=n(),s.callbacks.set(y,_)),g.isIntersecting?(_.while_show.forEach(m=>r(m,g,y)),_._wasIntersecting||_.on_show.forEach(m=>r(m,g,y)),_._once_shown||(_._once_shown=!0,_.once_show.forEach(m=>r(m,g,y))),_._wasIntersecting=!0):(_.while_hide.forEach(m=>r(m,g,y)),_._wasIntersecting&&_.on_hide.forEach(m=>r(m,g,y)),_._once_hidden||(_._once_hidden=!0,_.once_hide.forEach(m=>r(m,g,y))),_._wasIntersecting=!1)}u()};this._internal=s,this._createCbObj=n,this._resolveTargets=l,this._createCrossRule=a,this._checkCrossForTarget=f,this._runAllCrossChecks=u,this._makeIoCallback=c;let p=l();for(let d of p)s.elements.add(d),t.on_init(d),s.callbacks.get(d)||s.callbacks.set(d,n());h.#e.set(i,s),this.connect()}enableAutoCrossChecks(e={}){let t=Object.assign({strategy:"all",watchScrollAncestors:!0,watchResize:!0,rAFWhileAnimating:!1},e);if(this._autoChecks)return this._autoChecks.cfg=t,this;let i=this._internal,s=this,n=!1,r=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1,(t.strategy==="all"||t.strategy==="entryOnly")&&s._runAllCrossChecks()}))},o=c=>{let p=new Set,d=c.parentNode;for(;d&&d!==document;){if(d instanceof HTMLElement){let g=getComputedStyle(d),y=g.overflow+g.overflowX+g.overflowY;/(auto|scroll|overlay)/.test(y)&&p.add(d)}d=d.parentNode}return p.add(window),Array.from(p)},l=()=>r(),a=new Set;if(t.watchScrollAncestors)for(let c of Array.from(i.elements))o(c).forEach(d=>{a.has(d)||(d.addEventListener("scroll",l,{passive:!0}),a.add(d))});else window.addEventListener("scroll",l,{passive:!0}),a.add(window);t.watchResize&&window.addEventListener("resize",l,{passive:!0});let f=null,u=()=>{s._runAllCrossChecks(),f=requestAnimationFrame(u)};return this._autoChecks={cfg:t,scrollTargets:a,onScrollOrResize:l,rafId:f,startRaf:()=>{f||u()},stopRaf:()=>{f&&(cancelAnimationFrame(f),f=null)}},this}disableAutoCrossChecks(){if(!this._autoChecks)return this;let e=this._autoChecks;e.scrollTargets.forEach(t=>{try{t.removeEventListener("scroll",e.onScrollOrResize)}catch{}});try{window.removeEventListener("resize",e.onScrollOrResize)}catch{}return e.stopRaf(),this._autoChecks=null,this}_register(e,t,i){if(typeof t!="function")return this;let s=this._internal,n=this._resolveTargets(i);for(let r of n){let o=s.callbacks.get(r);if(o||(o=this._createCbObj(),s.callbacks.set(r,o)),o[e].add(t),!s.elements.has(r)&&(s.elements.add(r),s._connected&&s.observer))try{s.observer.observe(r)}catch{}}return this}on_show(e,t){return this._register("on_show",e,t)}while_show(e,t){return this._register("while_show",e,t)}once_show(e,t){return this._register("once_show",e,t)}on_hide(e,t){return this._register("on_hide",e,t)}while_hide(e,t){return this._register("while_hide",e,t)}once_hide(e,t){return this._register("once_hide",e,t)}observe(e){let t=this._resolveTargets(e);for(let i of t)if(this._internal.callbacks.get(i)||this._internal.callbacks.set(i,this._createCbObj()),this._internal.elements.add(i),this._internal._connected&&this._internal.observer)try{this._internal.observer.observe(i)}catch{}return this}unobserve(e){let t=this._resolveTargets(e);for(let i of t){try{this._internal.observer&&this._internal.observer.unobserve(i)}catch{}this._internal.callbacks.delete(i),this._internal.elements.delete(i)}return this}disconnect(){try{this._internal.observer&&this._internal.observer.disconnect()}catch{}return this._internal.observer=null,this._internal._connected=!1,this}connect(e={}){if(this._internal._connected)return this;if(e.root!==void 0&&(this._internal.options.root=e.root),e.rootMargin!==void 0&&(this._internal.options.rootMargin=e.rootMargin),e.threshold!==void 0&&(this._internal.options.threshold=e.threshold),this._internal.observer=new IntersectionObserver(this._makeIoCallback(),this._internal.options),e.resetFlags)for(let t of Array.from(this._internal.elements)){let i=this._internal.callbacks.get(t);i&&(i._once_shown=!1,i._once_hidden=!1,i._wasIntersecting=!1)}for(let t of Array.from(this._internal.elements))try{this._internal.observer.observe(t)}catch{}return this._internal._connected=!0,this}reconnect(e={}){return this.connect(e)}resetOnceFlags(e){let t=e?this._resolveTargets(e):Array.from(this._internal.elements);for(let i of t){let s=this._internal.callbacks.get(i);s&&(s._once_shown=!1,s._once_hidden=!1,s._wasIntersecting=!1)}return this}isConnected(){return!!this._internal._connected}getObservedElements(){return Array.from(this._internal.elements)}_registerCross(e,t,i,s){if(typeof t!="function")return this;let n=this._internal;s===void 0&&(typeof i=="string"||i instanceof Element||NodeList.prototype.isPrototypeOf(i)||Array.isArray(i))&&(s=i,i=void 0);let r=this._resolveTargets(i),o=this._resolveTargets(s);if(!o.length)return console.warn("st_observer: cross registration no goals"),this;for(let l of r){n.callbacks.get(l)||n.callbacks.set(l,this._createCbObj()),n.elements.add(l);let a=n.crossRules.get(l);a||(a=[],n.crossRules.set(l,a));let f=a.find(u=>{if(u.goals.size!==o.length)return!1;for(let c of o)if(!u.goals.has(c))return!1;return!0});f||(f=this._createCrossRule(o),a.push(f)),f[e].add(t);for(let u of o)n.elements.add(u)}return this._runAllCrossChecks(),this}on_cross(e,t,i){return this._registerCross("on_cross",e,t,i)}once_cross(e,t,i){return this._registerCross("once_cross",e,t,i)}while_cross(e,t,i){return this._registerCross("while_cross",e,t,i)}resetCrossOnceFlags(e,t){let i=this._internal,s=e?this._resolveTargets(e):Array.from(i.crossRules.keys()),n=t?this._resolveTargets(t):null;for(let r of s){let o=i.crossRules.get(r);if(o)for(let l of o)if(!n)l._once_done.clear();else for(let a of n)l._once_done.delete(a)}return this}},J=H;var N=class h{#e={};#t={};#s=new WeakMap;static find=x;get params(){return this.#e}get value(){return E(this.#e.target).map(e=>e.multiple?[...e.selectedOptions].map(t=>t.value):e.value)}clone(e){return new h({...this.#e,...this.#t,...e,parent:this})}constructor(e){e={target:"select",location:"bottom center",action:"click",duration:0,allow_interrupt:!1,close_on_select:!0,close_on_outside:!0,before_open:()=>{},on_open:()=>{},before_close:()=>{},on_close:()=>{},before_change:()=>{},on_change:()=>{},before_init:()=>{},on_init:()=>{},...e};for(let[t,i]of Object.entries(e))typeof i=="function"&&t!="target"?(this[t]=i.bind(this),this.#t[t]=i):this.#e[t]=i;this.before_init(this.#e);for(let t of E(this.#e.target))this.#c(t);this.on_init(this.#e)}#o(e){let t=(this.#e.location||"").toLowerCase().split(/\s+/);Object.assign(e.style,{position:"absolute",top:t.includes("top")?"auto":"100%",bottom:t.includes("top")?"100%":"auto",left:t.includes("right")?"auto":t.includes("center")?"50%":"0",right:t.includes("right")?"0":"auto",transform:t.includes("center")&&!t.includes("right")?"translateX(-50%)":"none"})}#c(e){let t=document.createElement("select-container");w(t,this),Object.assign(t.style,{position:"relative",display:"inline-block"});let i=document.createElement("select-trigger");w(i,this),Object.assign(i.style,{display:"block",cursor:"pointer"});let s=document.createElement("select-options");w(s,this),Object.assign(s.style,{transition:`all ${this.#e.duration}s`}),this.#o(s),Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)"}),e.parentNode.insertBefore(t,e),t.append(i,e,s),t.setAttribute("state","closed");for(let n of[...e.options]){let r=document.createElement("select-option");w(r,this),r.textContent=n.textContent,r.style.cursor="pointer",n.disabled&&r.setAttribute("disabled",""),r.toggleAttribute("selected",n.selected),r.addEventListener("click",()=>{n.disabled||this.#h(t,e,n,r)}),s.append(r)}this.#n(e,i),this.#e.action=="hover"?(t.addEventListener("mouseenter",()=>this.open(t)),t.addEventListener("mouseleave",()=>this.close(t))):i.addEventListener(this.#e.action,()=>this.toggle(t)),this.#e.close_on_outside&&document.addEventListener("click",n=>{t.contains(n.target)||this.close(t)})}#h(e,t,i,s){this.before_change(i,t)!==!1&&(t.multiple?(i.selected=!i.selected,s.toggleAttribute("selected",i.selected)):(t.value=i.value,[...e.querySelectorAll("select-option")].forEach(n=>n.toggleAttribute("selected",n===s))),t.dispatchEvent(new Event("change",{bubbles:!0})),this.#n(t,e.querySelector("select-trigger")),this.on_change(i,t),!t.multiple&&this.#e.close_on_select&&this.close(e))}#n(e,t){e.multiple?t.textContent=[...e.selectedOptions].map(i=>i.textContent).join(", "):t.textContent=(e.selectedOptions[0]??e.options[0])?.textContent??""}#d(e,t,i,s,n){s(e),clearTimeout(this.#s.get(e)),requestAnimationFrame(()=>{e.setAttribute("state",t),requestAnimationFrame(()=>{this.#s.set(e,setTimeout(()=>(e.setAttribute("state",i),n(e)),this.#e.duration*1e3))})})}#l(e,t){let i=e.getAttribute("state")??"closed",s=this.#e.allow_interrupt;(t?i=="closed"||s&&i=="closing":i=="open"||s&&i=="opening")&&this.#d(e,t?"opening":"closing",t?"open":"closed",t?this.before_open:this.before_close,t?this.on_open:this.on_close)}open(e){E(e).map(this.#p).forEach(t=>t&&this.#l(t,!0))}close(e){E(e).map(this.#p).forEach(t=>t&&this.#l(t,!1))}toggle(e){E(e).map(this.#p).forEach(t=>{t&&this.#l(t,!["open","opening"].includes(t.getAttribute("state")))})}#p=e=>e?.closest?.("select-container")??(e?.tagName?.toLowerCase()=="select"?e.parentElement:null)};var R=class h{#e={};#t={};#s=[];#o=[];#c=!1;params={};query={};#h="";#n="";clone(e){return new h({...this.#e,...this.#t,...e,parent:this})}constructor(e){e={point:"/",name:"",match_all:!0,strict_mode:!0,before_init:()=>{},on_init:()=>{},...e};for(let[t,i]of Object.entries(e))typeof i=="function"?(this[t]=i.bind(this),this.#t[t]=i):this.#e[t]=i;this.before_init(this.#e),this.#o.push({prefix:this.#e.point,middlewares:[]}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.#a()):queueMicrotask(()=>this.#a()),this.on_init(this.#e)}#d(){return this.#o[this.#o.length-1]}prefix(e){let t=this.#d();return this.#o.push({prefix:"/"+this.#l(t.prefix)+"/"+this.#l(e)+"/",middlewares:[...t.middlewares]}),this}group(e){e(),this.#o.length>1&&this.#o.pop()}middleware(e){let t=this.#d();return t.middlewares=t.middlewares.concat(Array.isArray(e)?e:[e]),this}get(e,t,i={}){return this.#p(e,t,i)}#l(e){return String(e).replace(/^\/+|\/+$/g,"")}#p(e,t,i={}){if(typeof t!="function")throw new Error("Route: \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0437\u0430\u043C\u044B\u043A\u0430\u043D\u0438\u0435\u043C");typeof i=="string"&&(i={alias:i});let s=this.#d(),n=i.strict_mode??this.#e.strict_mode,r=n?("/"+this.#l(s.prefix)+"/"+this.#l(e)+"/").replace(/\/{2,}/g,"/"):(this.#l(s.prefix)+"/"+this.#l(e)).replace(/\/{2,}/g,"/");for(let a of this.#s)if(a.pattern===r)throw new Error(`Route: \u0434\u0443\u0431\u043B\u0438\u043A\u0430\u0442 \u043C\u0430\u0440\u0448\u0440\u0443\u0442\u0430: ${r}`);let{regex:o,names:l}=this.#i(r);return this.#s.push({pattern:r,uri:e,alias:i.alias??null,closure:t,middlewares:s.middlewares,names:l,regex:o,strict_mode:n}),this}#i(e){let t=[],i=r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n="^"+e.replace(/\{(\w+)\}|\*|[^{*]+/g,(r,o)=>o!==void 0?(t.push(o),"([^/]+)"):r==="*"?(t.push("*"),"(.*)"):i(r)).replace(/\/+$/,"")+"/?$";return{regex:new RegExp(n),names:t}}#r(){return this.#e.name?"route:"+this.#e.name:"route"}#f(e){return"route:"+this.#e.name+":"+e}#u(e,t){document.dispatchEvent(new CustomEvent(e,{detail:t}))}#a(){if(!this.#c){this.#c=!0,this.#h=location.pathname,this.#n=location.href,this.query=Object.fromEntries(new URLSearchParams(location.search)),this.#u(this.#r(),{name:this.#e.name,path:this.#h,query:this.query,url:this.#n});for(let e of this.#s){let t=e.regex.exec(this.#h);if(!t)continue;let i=t.slice(1).map(h.#g);if(this.params={},e.names.forEach((n,r)=>{this.params[n]=i[r]}),e.middlewares.some(n=>!n.call(this,...i)))continue;e.closure.call(this,...i);let s={name:this.#e.name,pattern:e.pattern,uri:e.uri,alias:e.alias,params:this.params,values:i,query:this.query,path:this.#h,url:this.#n};if(e.alias&&this.#u(this.#f(e.alias),s),e.uri&&this.#u(this.#f(e.uri),s),!this.#e.match_all)break}}}get routes(){return this.#s}get path(){return this.#h}get url(){return this.#n}static#g(e){if(e==null)return e;try{return decodeURIComponent(e)}catch{return e}}};var j=class h{#e={};#t={};#s=new WeakMap;#o=new Map;#c=null;static find=x;get params(){return this.#e}clone(e){return new h({...this.#e,...this.#t,...e,parent:this})}constructor(e){e={duration:0,trigger:"[trigger]",target:null,allow_interrupt:!1,action:"click",anchor:!1,keep_history:!1,before_activate:()=>{},on_activate:()=>{},before_deactivate:()=>{},on_deactivate:()=>{},before_activated:()=>{},on_activated:()=>{},before_deactivated:()=>{},on_deactivated:()=>{},before_init:()=>{},on_init:()=>{},...e},e.keep_history&&(e.anchor=!0);for(let[i,s]of Object.entries(e))typeof s=="function"&&i!="target"?(this[i]=s.bind(this),this.#t[i]=s):this.#e[i]=s;this.before_init(this.#e);let t=i=>i.hasAttribute("state")||i.setAttribute("state","inactive");for(let i of E(this.#e.trigger)){w(i,this),t(i),this.#h(i).forEach(t);let s=this.#n(i);s&&this.#o.set(s,i),this.#e.action=="hover"?(i.addEventListener("mouseenter",()=>this.activate(i)),i.addEventListener("mouseleave",()=>this.deactivate(i))):i.addEventListener(this.#e.action,()=>this.toggle(i))}this.#e.anchor&&(this.#p(),this.#e.keep_history&&window.addEventListener("hashchange",()=>this.#p())),this.on_init(this.#e)}#h(e){let t=this.#e.target;return typeof t=="function"&&(t=t(e)),t??=e.getAttribute("target"),E(t)}#n(e){if(!this.#e.anchor)return null;if(e.id)return e.id;let t=this.#h(e);return t.length===1&&t[0].id?t[0].id:null}#d(e){let t="#"+e;location.hash!==t&&(this.#e.keep_history?history.pushState(null,"",t):history.replaceState(null,"",t))}#l(){if(!location.hash)return;let e=location.pathname+location.search;this.#e.keep_history?history.pushState(null,"",e):history.replaceState(null,"",e)}#p(){let e=this.#o.get(location.hash.slice(1));e?this.activate(e):this.#e.keep_history&&this.#c&&(this.deactivate(this.#c),this.#c=null)}#i(e,t,i,s,n){e.forEach(r=>(s(r),clearTimeout(this.#s.get(r)))),requestAnimationFrame(()=>{e.forEach(r=>r.setAttribute("state",t)),requestAnimationFrame(()=>{let r=setTimeout(()=>e.forEach(o=>(o.setAttribute("state",i),n(o))),this.#e.duration*1e3);e.forEach(o=>this.#s.set(o,r))})})}#r(e,t){let i=e.getAttribute("state")??"inactive",s=this.#e.allow_interrupt;if(!(t?i=="inactive"||s&&i=="deactivating":i=="active"||s&&i=="activating"))return;let n=t?"activate":"deactivate",r=t?"activating":"deactivating",o=t?"active":"inactive",l=this.#h(e),a=this.#n(e);a&&(t?(this.#d(a),this.#c=e):location.hash.slice(1)===a&&(this.#l(),this.#c=null)),this.#i([e],r,o,f=>this[`before_${n}`](f,l),f=>this[`on_${n}`](f,l)),this.#i(l,r,o,f=>this[`before_${n}d`](f,e),f=>this[`on_${n}d`](f,e))}toggle(e){E(e).forEach(t=>this.#r(t,!["active","activating"].includes(t.getAttribute("state"))))}activate(e){E(e).forEach(t=>this.#r(t,!0))}deactivate(e){E(e).forEach(t=>this.#r(t,!1))}};var F=class h{static#e=Symbol();static#t=new WeakMap;static#s=new WeakMap;static#o=new Set(["\u0432","\u0432\u043E","\u043D\u0430","\u043F\u043E","\u0441","\u0441\u043E","\u043A","\u043A\u043E","\u0443","\u043E","\u043E\u0431","\u043E\u0431\u043E","\u0437\u0430","\u0438\u0437","\u0438\u0437\u043E","\u0434\u043E","\u043E\u0442","\u043F\u0440\u0438","\u043F\u043E\u0434","\u043F\u043E\u0434\u043E","\u043D\u0430\u0434","\u043D\u0430\u0434\u043E","\u0431\u0435\u0437","\u0434\u043B\u044F","\u043F\u0440\u043E","\u0447\u0435\u0440\u0435\u0437","\u0441\u043A\u0432\u043E\u0437\u044C","\u043C\u0435\u0436\u0434\u0443","\u043C\u0435\u0436","\u043F\u0435\u0440\u0435\u0434","\u043F\u0435\u0440\u0435\u0434\u043E","\u043E\u043A\u043E\u043B\u043E","\u0441\u0440\u0435\u0434\u0438","\u043A\u0440\u043E\u043C\u0435","\u0432\u043E\u043A\u0440\u0443\u0433","\u0432\u0434\u043E\u043B\u044C","\u043F\u0440\u043E\u0442\u0438\u0432","\u0440\u0430\u0434\u0438","\u0432\u043C\u0435\u0441\u0442\u043E","\u0432\u043D\u0443\u0442\u0440\u0438","\u0441\u0432\u0435\u0440\u0445\u0443","\u0441\u043D\u0438\u0437\u0443","\u0432\u043E\u0437\u043B\u0435","\u043D\u0430\u043F\u0440\u043E\u0442\u0438\u0432","\u0431\u043B\u0430\u0433\u043E\u0434\u0430\u0440\u044F","\u0441\u043E\u0433\u043B\u0430\u0441\u043D\u043E","\u0432\u043E\u043F\u0440\u0435\u043A\u0438","\u0438","\u0430","\u043D\u043E","\u0434\u0430","\u0438\u043B\u0438","\u043B\u0438\u0431\u043E","\u0447\u0442\u043E","\u0447\u0442\u043E\u0431","\u0447\u0442\u043E\u0431\u044B","\u043A\u0430\u043A","\u0435\u0441\u043B\u0438","\u0438\u0431\u043E","\u0445\u043E\u0442\u044F","\u043F\u043E\u043A\u0430","\u043A\u043E\u0433\u0434\u0430","\u043A\u0443\u0434\u0430","\u043E\u0442\u043A\u0443\u0434\u0430","\u0437\u0430\u0447\u0435\u043C","\u043F\u043E\u0447\u0435\u043C\u0443","\u0436\u0435","\u043B\u0438","\u0431\u044B","\u0431","\u0432\u0435\u0434\u044C","\u043B\u0438\u0448\u044C","\u0443\u0436","\u0430\u0436","\u0442\u043E","\u043D\u0438","\u043D\u0435","\u043D\u0443","\u0432\u043E\u043D","\u0432\u043E\u0442"]);static#c=new Set(["SCRIPT","STYLE","NOSCRIPT","CODE","PRE","TEXTAREA","KBD","SAMP"]);static#h=(()=>{let e=[...this.#o].sort((t,i)=>i.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`(?<=^|[\\s(\xAB\u201E"'\\[])(${e})(\\s+)(?=\\S)`,"gi")})();static#n=/(\d) +(?=\S)/g;static#d=/ +(?=[—–] )/g;static preventWidows(e){let t=k(e);if(!t||t[h.#e])return;h.#i(t);let i=h.#r(t);for(let s of i)h.#t.set(s,s.nodeValue),s[h.#e]=!0,h.#p(s);h.#g(t)}static#l(e){return e.replace(h.#h,(t,i)=>i+"\xA0").replace(h.#n,"$1\xA0").replace(h.#d,"\xA0")}static#p(e){h.#t.has(e)||h.#t.set(e,e.nodeValue);let t=h.#l(h.#t.get(e));e.nodeValue!==t&&(e.nodeValue=t)}static#i(e){e[h.#e]=!0;let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),i;for(;i=t.nextNode();)i[h.#e]=!0}static#r(e){let t=[],i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:n=>{if(!n.nodeValue||!n.nodeValue.trim())return NodeFilter.FILTER_REJECT;for(let r=n.parentElement;r&&r!==e.parentElement;r=r.parentElement){if(h.#c.has(r.tagName))return NodeFilter.FILTER_REJECT;let o=r.getAttribute&&r.getAttribute("contenteditable");if(o===""||o==="true")return NodeFilter.FILTER_REJECT}return NodeFilter.FILTER_ACCEPT}}),s;for(;s=i.nextNode();)t.push(s);return t}static#f(e){let t=h.#r(e);for(let i of t)i[h.#e]||(h.#t.set(i,i.nodeValue),i[h.#e]=!0),h.#p(i)}static#u(e,t){e.mutating=!0;try{t()}finally{e.mutation&&e.mutation.takeRecords(),e.mutating=!1}}static#a(e,t){let i=window.requestIdleCallback?window.requestIdleCallback.bind(window):s=>setTimeout(s,0);t.flush_scheduled||(t.flush_scheduled=!0,i(()=>{t.flush_scheduled=!1,h.#u(t,()=>{for(let s of t.queue)s.parentNode&&(h.#t.has(s)||h.#t.set(s,s.nodeValue),s[h.#e]=!0,h.#p(s));t.queue.clear()})}))}static#g(e){let t={mutation:null,intersection:null,resize:null,mutating:!1,visible:!1,pending_resize:!1,flush_scheduled:!1,queue:new Set};h.#s.set(e,t),t.mutation=new MutationObserver(i=>{if(!t.mutating){for(let s of i){if(s.type==="characterData"){s.target.parentNode&&s.target.nodeValue&&s.target.nodeValue.trim()&&t.queue.add(s.target);continue}if(s.type==="childList"){for(let n of s.addedNodes)if(n.nodeType===Node.TEXT_NODE)n.nodeValue&&n.nodeValue.trim()&&t.queue.add(n);else if(n.nodeType===Node.ELEMENT_NODE){h.#i(n);for(let r of h.#r(n))t.queue.add(r)}}}t.visible&&t.queue.size&&h.#a(e,t)}}),t.mutation.observe(e,{subtree:!0,childList:!0,characterData:!0}),t.intersection=new IntersectionObserver(i=>{for(let s of i)t.visible=s.isIntersecting,s.isIntersecting&&(t.queue.size&&h.#a(e,t),t.pending_resize&&(t.pending_resize=!1,h.#u(t,()=>h.#f(e))))},{rootMargin:"200px"}),t.intersection.observe(e),t.resize=new ResizeObserver(()=>{if(!t.mutating){if(!t.visible){t.pending_resize=!0;return}h.#u(t,()=>h.#f(e))}}),t.resize.observe(e)}};var q=class h{static find=x;static formatSize(e){let t=["\u0411","\u041A\u0411","\u041C\u0411","\u0413\u0411","\u0422\u0411"],i=0;for(;e>=1024&&i<t.length-1;)e/=1024,i++;return e.toFixed(1)+" "+t[i]}constructor(e){e={target:null,input_name:null,entry:"*[file-item]",delete_name:null,before_init:()=>{},on_init:()=>{},before_files_add:()=>{},on_files_add:()=>{},before_file_delete:()=>{},on_file_delete:()=>{},before_drop:()=>{},on_drop:()=>{},handle_exception:null,...e,limits:{files:0,file_size:0,total_size:0,mimes:[],...e.limits??{}}};let t=e.input_name.replace(/\[\]$/,"");e.input_name=t+(e.limits.files!=1?"[]":""),e.delete_name=(e.delete_name?e.delete_name.replace(/\[\]$/,""):t+"_to_delete")+(e.limits.files!=1?"[]":""),document.querySelectorAll(e.target).forEach(i=>{if(x(i))throw new Error("Already inited");w(i,this);for(let[c,p]of Object.entries(e))typeof p=="function"&&(i[c]=p.bind(i));i.before_init(e);let s=(c,p,d=null)=>e.handle_exception?i.handle_exception(Object.assign(new Error(p),{file:c,code:d})):(alert(p),!1),n=()=>Object.assign(document.createElement("input"),{type:"file",name:e.input_name,multiple:e.limits.files!=1,hidden:!0}),r=i.querySelector("*[files-list]"),o=null;i.files=new Map,i.total_size=0;let l=c=>{let p=new DOMParser().parseFromString(o,"text/html").body.firstElementChild;c._id=crypto.randomUUID(),i.files.set(c._id,c),i.total_size+=c.size;let d=p.querySelectorAll("img[preview]"),g=p.querySelectorAll("*[filename]"),y=p.querySelectorAll("*[fileweight]"),_=p.querySelectorAll("*[delete-button]");if(c.type.startsWith("image/")){let b=new FileReader;b.onload=L=>d.forEach(A=>A.src=L.target.result),b.readAsDataURL(c)}else d.forEach(b=>b.remove());g.forEach(b=>b.textContent=c.name),y.forEach(b=>{b.textContent=h.formatSize(c.size),b.setAttribute("size",c.size)}),_.forEach(b=>b.addEventListener("click",()=>{i.before_file_delete(c)!==!1&&(i.total_size=Math.max(0,i.total_size-parseInt(c.size)),i.files.delete(c._id),p.remove(),i.on_file_delete(c))}));let m=n(),v=new DataTransfer;return v.items.add(c),m.files=v.files,p.appendChild(m),p},a=c=>{let p=c.querySelector(`input[name^="${t}"]`)??c.querySelector("input[type='hidden'][value]")??c.querySelector("input[value]"),d=c.querySelectorAll("*[delete-button]");if(p){let g=c.querySelector("img[preview]"),y=c.querySelector("*[filename]"),_=c.querySelector("*[fileweight]"),m={_id:crypto.randomUUID(),preview:g?.src||"",value:p.value,name:y?.textContent||"",size:parseFloat(_?.getAttribute("size")??_?.textContent??0)||0};i.files.set(m._id,m),d.forEach(v=>v.addEventListener("click",()=>{if(i.before_file_delete(m)===!1)return;let b=Object.assign(document.createElement("input"),{type:"hidden",name:e.delete_name,hidden:!0,value:p.value});i.appendChild(b),i.files.delete(m._id),i.on_file_delete(m),c.remove()})),p.remove()}else c.remove();return c},f=c=>{if(e.limits.files>0&&i.files.size>=e.limits.files)return s(c,`\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C \u0444\u0430\u0439\u043B\u043E\u0432: ${e.limits.files}`,0);if(e.limits.file_size>0&&c.size>e.limits.file_size)return s(c,`\u0424\u0430\u0439\u043B "${c.name}" \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0439! \u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C ${h.formatSize(e.limits.file_size)}.`,1);if(e.limits.total_size>0&&i.total_size+c.size>e.limits.total_size)return s(c,`\u041F\u0440\u0435\u0432\u044B\u0448\u0435\u043D \u043E\u0431\u0449\u0438\u0439 \u043B\u0438\u043C\u0438\u0442! \u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0430\u044F \u0441\u0443\u043C\u043C\u0430 \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043B\u043E\u0432 ${h.formatSize(e.limits.total_size)}.`,2);if(e.limits.mimes.length>0){let p=c.type.trim(),d=p.split(";")[0].trim().toLowerCase();for(let g of e.limits.mimes){if(g.endsWith("/*")&&!/[\\^$.*+?()[\]{}|]/.test(g.slice(0,-2))){if(d.startsWith(g.slice(0,-1).toLowerCase()))return!0;continue}if(/[\\^$.*+?()[\]{}|]/.test(g)){try{let y=new RegExp(g,"i");if(y.test(p)||y.test(d))return!0}catch{}continue}if(d===g.toLowerCase())return!0}return s(c,`\u0424\u0430\u0439\u043B "${c.name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0439 \u0442\u0438\u043F: ${d}.`,3)}return!0},u=c=>{let p=Array.from(c);if(i.before_files_add(p),p=p.filter(f),p.length>0){let d=document.createDocumentFragment();p.forEach(g=>{d.appendChild(l(g))}),r.appendChild(d)}i.on_files_add(p)};try{let c=i.querySelectorAll(e.entry);c.length>0&&c.forEach(p=>{let d=a(p);o||(o=d.outerHTML)})}catch{o=e.entry}o=o.trim(),i.querySelectorAll("*[drop-zone]").forEach(c=>{let p=!1;["dragenter","dragover"].forEach(d=>c.addEventListener(d,g=>{g.preventDefault(),c.setAttribute("dragover",""),p||(i.before_drop(),p=!0)})),["dragleave","drop"].forEach(d=>c.addEventListener(d,g=>{g.preventDefault(),c.removeAttribute("dragover"),p=!1})),c.addEventListener("drop",d=>{d.preventDefault(),i.on_drop(),u(d.dataTransfer.files)})}),i.querySelectorAll("*[add-button]").forEach(c=>c.addEventListener("click",()=>{let p=n();p.addEventListener("change",()=>{u(p.files)}),document.body.appendChild(p),p.click()})),i.on_init(e)})}};var P=class{#e=null;#t=null;constructor(e){this.#e=function(t){(!e.validator||e.validator(t))&&(()=>{if(e.regexp){let i=new RegExp(e.regexp);return!e.attribute&&!e.property?i.test(t.value):e.attribute&&e.property?t.hasAttribute(e.attribute)&&i.test(t[e.property]):(e.attribute?i.test(t.getAttribute(e.attribute)):!0)&&(e.property?i.test(t[e.property]):!0)}else return e.attribute?t.hasAttribute(e.attribute):!0})()?e.on_valid(t):e.on_invalid(t),e.after_check&&e.after_check(t)},this.#t=e.selector,typeof e.onload=="function"?e.onload(this.#t):e.onload===!0&&this.apply(),document.querySelectorAll(this.#t).forEach(t=>{(e.events??["input","blur"]).forEach(i=>{t.addEventListener(i,()=>{this.#e(t)})})})}apply(e){document.querySelectorAll(e??this.#t).forEach(this.#e,this)}},K=P;export{T as App,O as Cookie,C as Core,S as Loader,M as Modal,R as Route,N as Select,j as Toggle,q as Uploader,U as st_button_widget,X as st_links_widget,Y as st_mask,J as st_observer,F as st_typograf,K as st_validator};
|