1import { defineComponent as sr, useTemplateRef as oi, ref as rr, computed as nr, onMounted as or, onUnmounted as ar, openBlock as ai, createElementBlock as li, Fragment as lr, createElementVNode as we, mergeProps as cr, unref as ur } from "vue"; 2var dr = Object.defineProperty, hr = (i, e, t) => e in i ? dr(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Pt = (i, e, t) => (hr(i, typeof e != "symbol" ? e + "" : e, t), t); 3function fr(i) { 4 let e = (t) => { 5 var s; 6 for (let r in t) 7 ((s = t[r]) == null ? void 0 : s.constructor) === Object && (t[r] = e(t[r])); 8 return { ...t }; 9 }; 10 return e(i); 11} 12var A = class { 13 constructor(i) { 14 i.constructor === Object ? this.store = fr(i) : (this._storeIsProxy = !0, this.store = i), this.callbackMap = /* @__PURE__ */ Object.create(null); 15 } 16 static warn(i, e) { 17 console.warn(`Symbiote Data: cannot ${i}. Prop name: ` + e); 18 } 19 read(i) { 20 return !this._storeIsProxy && !this.store.hasOwnProperty(i) ? (A.warn("read", i), null) : this.store[i]; 21 } 22 has(i) { 23 return this._storeIsProxy ? this.store[i] !== void 0 : this.store.hasOwnProperty(i); 24 } 25 add(i, e, t = !1) { 26 !t && Object.keys(this.store).includes(i) || (this.store[i] = e, this.notify(i)); 27 } 28 pub(i, e) { 29 if (!this._storeIsProxy && !this.store.hasOwnProperty(i)) { 30 A.warn("publish", i); 31 return; 32 } 33 this.store[i] = e, this.notify(i); 34 } 35 multiPub(i) { 36 for (let e in i) 37 this.pub(e, i[e]); 38 } 39 notify(i) { 40 this.callbackMap[i] && this.callbackMap[i].forEach((e) => { 41 e(this.store[i]); 42 }); 43 } 44 sub(i, e, t = !0) { 45 return !this._storeIsProxy && !this.store.hasOwnProperty(i) ? (A.warn("subscribe", i), null) : (this.callbackMap[i] || (this.callbackMap[i] = /* @__PURE__ */ new Set()), this.callbackMap[i].add(e), t && e(this.store[i]), { 46 remove: () => { 47 this.callbackMap[i].delete(e), this.callbackMap[i].size || delete this.callbackMap[i]; 48 }, 49 callback: e 50 }); 51 } 52 static registerCtx(i, e = /* @__PURE__ */ Symbol()) { 53 let t = A.globalStore.get(e); 54 return t ? console.warn('State: context UID "' + e + '" already in use') : (t = new A(i), A.globalStore.set(e, t)), t; 55 } 56 static deleteCtx(i) { 57 A.globalStore.delete(i); 58 } 59 static getCtx(i, e = !0) { 60 return A.globalStore.get(i) || (e && console.warn('State: wrong context UID - "' + i + '"'), null); 61 } 62}; 63A.globalStore = /* @__PURE__ */ new Map(); 64var y = Object.freeze({ 65 BIND_ATTR: "set", 66 ATTR_BIND_PRFX: "@", 67 EXT_DATA_CTX_PRFX: "*", 68 NAMED_DATA_CTX_SPLTR: "/", 69 CTX_NAME_ATTR: "ctx-name", 70 CTX_OWNER_ATTR: "ctx-owner", 71 CSS_CTX_PROP: "--ctx-name", 72 EL_REF_ATTR: "ref", 73 AUTO_TAG_PRFX: "sym", 74 REPEAT_ATTR: "repeat", 75 REPEAT_ITEM_TAG_ATTR: "repeat-item-tag", 76 SET_LATER_KEY: "__toSetLater__", 77 USE_TPL: "use-template", 78 ROOT_STYLE_ATTR_NAME: "sym-component" 79}), zi = "1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm", pr = zi.length - 1, st = class { 80 static generate(i = "XXXXXXXXX-XXX") { 81 let e = ""; 82 for (let t = 0; t < i.length; t++) 83 e += i[t] === "-" ? i[t] : zi.charAt(Math.random() * pr); 84 return e; 85 } 86}; 87function Bi(i, e, t) { 88 let s = !0, r, n = e.split("."); 89 return n.forEach((o, a) => { 90 a < n.length - 1 ? i = i[o] : r = o; 91 }), i ? i[r] = t : s = !1, s; 92} 93function mr(i) { 94 return i.split("-").map((e, t) => e && t ? e[0].toUpperCase() + e.slice(1) : e).join("").split("_").map((e, t) => e && t ? e.toUpperCase() : e).join(""); 95} 96function gr(i, e) { 97 [...i.querySelectorAll(`[${y.REPEAT_ATTR}]`)].forEach((t) => { 98 let s = t.getAttribute(y.REPEAT_ITEM_TAG_ATTR), r; 99 if (s && (r = window.customElements.get(s)), !r) { 100 r = class extends e.BaseComponent { 101 constructor() { 102 super(), s || (this.style.display = "contents"); 103 } 104 }; 105 let o = t.innerHTML; 106 r.template = o, r.reg(s); 107 } 108 for (; t.firstChild; ) 109 t.firstChild.remove(); 110 let n = t.getAttribute(y.REPEAT_ATTR); 111 e.sub(n, (o) => { 112 if (!o) { 113 for (; t.firstChild; ) 114 t.firstChild.remove(); 115 return; 116 } 117 let a = [...t.children], l, c = (d) => { 118 d.forEach((h, f) => { 119 if (a[f]) 120 if (a[f].set$) 121 setTimeout(() => { 122 a[f].set$(h); 123 }); 124 else 125 for (let p in h) 126 a[f][p] = h[p]; 127 else { 128 l || (l = new DocumentFragment()); 129 let p = new r(); 130 Object.assign(p.init$, h), l.appendChild(p); 131 } 132 }), l && t.appendChild(l); 133 let u = a.slice(d.length, a.length); 134 for (let h of u) 135 h.remove(); 136 }; 137 if (o.constructor === Array) 138 c(o); 139 else if (o.constructor === Object) { 140 let d = []; 141 for (let u in o) { 142 let h = o[u]; 143 Object.defineProperty(h, "_KEY_", { 144 value: u, 145 enumerable: !0 146 }), d.push(h); 147 } 148 c(d); 149 } else 150 console.warn("Symbiote repeat data type error:"), console.log(o); 151 }), t.removeAttribute(y.REPEAT_ATTR), t.removeAttribute(y.REPEAT_ITEM_TAG_ATTR); 152 }); 153} 154var ci = "__default__"; 155function br(i, e) { 156 if (e.shadowRoot) 157 return; 158 let t = [...i.querySelectorAll("slot")]; 159 if (!t.length) 160 return; 161 let s = {}; 162 t.forEach((r) => { 163 let n = r.getAttribute("name") || ci; 164 s[n] = { 165 slot: r, 166 fr: document.createDocumentFragment() 167 }; 168 }
168), e.initChildren.forEach((r) => { 169 var n; 170 let o = ci; 171 r instanceof Element && r.hasAttribute("slot") && (o = r.getAttribute("slot"), r.removeAttribute("slot")), (n = s[o]) == null || n.fr.appendChild(r); 172 }), Object.values(s).forEach((r) => { 173 if (r.fr.childNodes.length) 174 r.slot.parentNode.replaceChild(r.fr, r.slot); 175 else if (r.slot.childNodes.length) { 176 let n = document.createDocumentFragment(); 177 n.append(...r.slot.childNodes), r.slot.parentNode.replaceChild(n, r.slot); 178 } else 179 r.slot.remove(); 180 }); 181} 182function _r(i, e) { 183 [...i.querySelectorAll(`[${y.EL_REF_ATTR}]`)].forEach((t) => { 184 let s = t.getAttribute(y.EL_REF_ATTR); 185 e.ref[s] = t, t.removeAttribute(y.EL_REF_ATTR); 186 }); 187} 188function yr(i, e) { 189 [...i.querySelectorAll(`[${y.BIND_ATTR}]`)].forEach((t) => { 190 let r = t.getAttribute(y.BIND_ATTR).split(";"); 191 [...t.attributes].forEach((n) => { 192 if (n.name.startsWith("-") && n.value) { 193 let o = mr(n.name.replace("-", "")); 194 r.push(o + ":" + n.value), t.removeAttribute(n.name); 195 } 196 }), r.forEach((n) => { 197 if (!n) 198 return; 199 let o = n.split(":").map((d) => d.trim()), a = o[0], l; 200 a.indexOf(y.ATTR_BIND_PRFX) === 0 && (l = !0, a = a.replace(y.ATTR_BIND_PRFX, "")); 201 let c = o[1].split(",").map((d) => d.trim()); 202 for (let d of c) { 203 let u; 204 d.startsWith("!!") ? (u = "double", d = d.replace("!!", "")) : d.startsWith("!") && (u = "single", d = d.replace("!", "")), e.sub(d, (h) => { 205 u === "double" ? h = !!h : u === "single" && (h = !h), l ? h?.constructor === Boolean ? h ? t.setAttribute(a, "") : t.removeAttribute(a) : t.setAttribute(a, h) : Bi(t, a, h) || (t[y.SET_LATER_KEY] || (t[y.SET_LATER_KEY] = /* @__PURE__ */ Object.create(null)), t[y.SET_LATER_KEY][a] = h); 206 }); 207 } 208 }), t.removeAttribute(y.BIND_ATTR); 209 }); 210} 211var Ye = "{{", Re = "}}", vr = "skip-text"; 212function wr(i) { 213 let e, t = [], s = document.createTreeWalker(i, NodeFilter.SHOW_TEXT, { 214 acceptNode: (r) => { 215 var n; 216 return !((n = r.parentElement) != null && n.hasAttribute(vr)) && r.textContent.includes(Ye) && r.textContent.includes(Re) && 1; 217 } 218 }); 219 for (; e = s.nextNode(); ) 220 t.push(e); 221 return t; 222} 223var Cr = function(i, e) { 224 wr(i).forEach((s) => { 225 let r = [], n; 226 for (; s.textContent.includes(Re); ) 227 s.textContent.startsWith(Ye) ? (n = s.textContent.indexOf(Re) + Re.length, s.splitText(n), r.push(s)) : (n = s.textContent.indexOf(Ye), s.splitText(n)), s = s.nextSibling; 228 r.forEach((o) => { 229 let a = o.textContent.replace(Ye, "").replace(Re, ""); 230 o.textContent = "", e.sub(a, (l) => { 231 o.textContent = l; 232 }); 233 }); 234 }); 235}, Ar = [gr, br, _r, yr, Cr], Qe = "'", xe = '"', Er = /\\([0-9a-fA-F]{1,6} ?)/g; 236function Tr(i) { 237 return (i[0] === xe || i[0] === Qe) && (i[i.length - 1] === xe || i[i.length - 1] === Qe); 238} 239function xr(i) { 240 return (i[0] === xe || i[0] === Qe) && (i = i.slice(1)), (i[i.length - 1] === xe || i[i.length - 1] === Qe) && (i = i.slice(0, -1)), i; 241} 242function Sr(i) { 243 let e = "", t = ""; 244 for (var s = 0; s < i.length; s++) { 245 const r = i[s + 1]; 246 i[s] === "\\" && r === '"' ? (e += '\\"', s++) : i[s] === '"' && t !== "\\" ? e += '\\"' : e += i[s], t = i[s]; 247 } 248 return e; 249} 250function $r(i) { 251 let e = i; 252 Tr(i) && (e = xr(e), e = e.replace(Er, (t, s) => String.fromCodePoint(parseInt(s.trim(), 16))), e = e.replaceAll(`\\ 253`, "\\n"), e = Sr(e), e = xe + e + xe); 254 try { 255 return JSON.parse(e); 256 } catch { 257 throw new Error(`Failed to parse CSS property value: ${e}. Original input: ${i}`); 258 } 259} 260var ui = 0, Ce = null, Q = null, re = class extends HTMLElement { 261 constructor() { 262 super(), Pt(this, "updateCssData", () => { 263 var i; 264 this.dropCssDataCache(), (i = this.__boundCssProps) == null || i.forEach((e) => { 265 let t = this.getCssData(this.__extractCssName(e), !0); 266 t !== null && this.$[e] !== t && (this.$[e] = t); 267 }); 268 }), this.init$ = /* @__PURE__ */ Object.create(null), this.cssInit$ = /* @__PURE__ */ Object.create(null), this.tplProcessors = /* @__PURE__ */ new Set(), this.ref = /* @__PURE__ */ Object.create(null), this.allSubs = /* @__PURE__ */ new Set(), this.pauseRender = !1, this.renderShadow = !1, this.readyToDestroy = !0, this.processInnerHtml = !1, this.allowCustomTemplate = !1, this.ctxOwner = !1; 269 } 270 get BaseComponent() { 271 return re; 272 } 273 initCallback() { 274 }
275 __initCallback() { 276 var i; 277 this.__initialized || (this.__initialized = !0, (i = this.initCallback) == null || i.call(this)); 278 } 279 render(i, e = this.renderShadow) { 280 let t; 281 if ((e || this.constructor.__shadowStylesUrl) && !this.shadowRoot && this.attachShadow({ 282 mode: "open" 283 }), this.allowCustomTemplate) { 284 let r = this.getAttribute(y.USE_TPL); 285 if (r) { 286 let n = this.getRootNode(), o = n?.querySelector(r) || document.querySelector(r); 287 o ? i = o.content.cloneNode(!0) : console.warn(`Symbiote template "${r}" is not found...`); 288 } 289 } 290 if (this.processInnerHtml) 291 for (let r of this.tplProcessors) 292 r(this, this); 293 if (i || this.constructor.template) { 294 if (this.constructor.template && !this.constructor.__tpl && (this.constructor.__tpl = document.createElement("template"), this.constructor.__tpl.innerHTML = this.constructor.template), i?.constructor === DocumentFragment) 295 t = i; 296 else if (i?.constructor === String) { 297 let r = document.createElement("template"); 298 r.innerHTML = i, t = r.content.cloneNode(!0); 299 } else this.constructor.__tpl && (t = this.constructor.__tpl.content.cloneNode(!0)); 300 for (let r of this.tplProcessors) 301 r(t, this); 302 } 303 let s = () => { 304 t && (e && this.shadowRoot.appendChild(t) || this.appendChild(t)), this.__initCallback(); 305 }; 306 if (this.constructor.__shadowStylesUrl) { 307 e = !0; 308 let r = document.createElement("link"); 309 r.rel = "stylesheet", r.href = this.constructor.__shadowStylesUrl, r.onload = s, this.shadowRoot.prepe
309nd(r); 310 } else 311 s(); 312 } 313 addTemplateProcessor(i) { 314 this.tplProcessors.add(i); 315 } 316 get autoCtxName() { 317 return this.__autoCtxName || (this.__autoCtxName = st.generate(), this.style.setProperty(y.CSS_CTX_PROP, `'${this.__autoCtxName}'`)), this.__autoCtxName; 318 } 319 get cssCtxName() { 320 return this.getCssData(y.CSS_CTX_PROP, !0); 321 } 322 get ctxName() { 323 var i; 324 let e = ((i = this.getAttribute(y.CTX_NAME_ATTR)) == null ? void 0 : i.trim()) || this.cssCtxName || this.__cachedCtxName || this.autoCtxName; 325 return this.__cachedCtxName = e, e; 326 } 327 get localCtx() { 328 return this.__localCtx || (this.__localCtx = A.registerCtx({}, this)), this.__localCtx; 329 } 330 get nodeCtx() { 331 return A.getCtx(this.ctxName, !1) || A.registerCtx({}, this.ctxName); 332 } 333 static __parseProp(i, e) { 334 let t, s; 335 if (i.startsWith(y.EXT_DATA_CTX_PRFX)) 336 t = e.nodeCtx, s = i.replace(y.EXT_DATA_CTX_PRFX, ""); 337 else if (i.includes(y.NAMED_DATA_CTX_SPLTR)) { 338 let r = i.split(y.NAMED_DATA_CTX_SPLTR); 339 t = A.getCtx(r[0]), s = r[1]; 340 } else 341 t = e.localCtx, s = i; 342 return { 343 ctx: t, 344 name: s 345 }; 346 } 347 sub(i, e, t = !0) { 348 let s = (n) => { 349 this.isConnected && e(n); 350 }, r = re.__parseProp(i, this); 351 r.ctx.has(r.name) ? this.allSubs.add(r.ctx.sub(r.name, s, t)) : window.setTimeout(() => { 352 this.allSubs.add(r.ctx.sub(r.name, s, t)); 353 }); 354 } 355 notify(i) { 356 let e = re.__parseProp(i, this); 357 e.ctx.notify(e.name); 358 } 359 has(i) { 360 let e = re.__parseProp(i, this); 361 return e.ctx.has(e.name); 362 } 363 add(i, e, t = !1) { 364 let s = re.__parseProp(i, this); 365 s.ctx.add(s.name, e, t); 366 } 367 add$(i, e = !1) { 368 for (let t in i) 369 this.add(t, i[t], e); 370 } 371 get $() { 372 if (!this.__stateProxy) { 373 let i = /* @__PURE__ */ Object.create(null); 374 this.__stateProxy = new Proxy(i, { 375 set: (e, t, s) => { 376 let r = re.__parseProp(t, this); 377 return r.ctx.pub(r.name, s), !0; 378 }, 379 get: (e, t) => { 380 let s = re.__parseProp(t, this); 381 return s.ctx.read(s.name); 382 } 383 }); 384 } 385 return this.__stateProxy; 386 } 387 set$(i, e = !1) { 388 for (let t in i) { 389 let s = i[t]; 390 e || ![String, Number, Boolean].includes(s?.constructor) ? this.$[t] = s : this.$[t] !== s && (this.$[t] = s); 391 } 392 } 393 get __ctxOwner() { 394 return this.ctxOwner || this.hasAttribute(y.CTX_OWNER_ATTR) && this.getAttribute(y.CTX_OWNER_ATTR) !== "fal
394se"; 395 } 396 __initDataCtx() { 397 let i = this.constructor.__attrDesc; 398 if (i) 399 for (let e of Object.values(i)) 400 Object.keys(this.init$).includes(e) || (this.init$[e] = ""); 401 for (let e in this.init$) 402 if (e.startsWith(y.EXT_DATA_CTX_PRFX)) 403 this.nodeCtx.add(e.replace(y.EXT_DATA_CTX_PRFX, ""), this.init$[e], this.__ctxOwner); 404 else if (e.includes(y.NAMED_DATA_CTX_SPLTR)) { 405 let t = e.split(y.NAMED_DATA_CTX_SPLTR), s = t[0].trim(), r = t[1].trim(); 406 if (s && r) { 407 let n = A.getCtx(s, !1); 408 n || (n = A.registerCtx({}, s)), n.add(r, this.init$[e]); 409 } 410 } else 411 this.localCtx.add(e, this.init$[e]); 412 for (let e in this.cssInit$) 413 this.bindCssData(e, this.cssInit$[e]); 414 this.__dataCtxInitialized = !0; 415 } 416 connectedCallback() { 417 var i; 418 if (this.isConnected) { 419 if (this.__disconnectTimeout && window.clearTimeout(this.__disconnectTimeout), !this.connectedOnce) { 420 let e = (i = this.getAttribute(y.CTX_NAME_ATTR)) == null ? void 0 : i.trim(); 421 if (e && this.style.setProperty(y.CSS_CTX_PROP, `'${e}'`), this.__initDataCtx(), this[y.SET_LATER_KEY]) { 422 for (let t in this[y.SET_LATER_KEY]) 423 Bi(this, t, this[y.SET_LATER_KEY][t]); 424 delete this[y.SET_LATER_KEY]; 425 } 426 this.initChildren = [...this.childNodes]; 427 for (let t of Ar) 428 this.addTemplateProcessor(t); 429 if (this.pauseRender) 430 this.__initCallback(); 431 else if (this.constructor.__rootStylesLink) { 432 let t = this.getRootNode(); 433 if (!t) 434 return; 435 if (t?.querySelector(`link[${y.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)) { 436 this.render(); 437 return; 438 } 439 let r = this.constructor.__rootStylesLink.cloneNode(!0); 440 r.setAttribute(y.ROOT_STYLE_ATTR_NAME, this.constructor.is), r.onload = () => { 441 this.render(); 442 }, t.nodeType === Node.DOCUMENT_NODE ? t.head.appendChild(r) : t.prepend(r); 443 } else 444 this.render(); 445 } 446 this.connectedOnce = !0; 447 } 448 } 449 destroyCallback() { 450 } 451 disconnectedCallback() { 452 this.connectedOnce && (this.dropCssDataCache(), this.readyToDestroy && (this.__disconnectTimeout && window.clearTimeout(this.__disconnectTimeout), this.__disconnectTimeout = window.setTimeout(() => { 453 this.destroyCallback(); 454 for (let i of this.allSubs) 455 i.remove(), this.allSubs.delete(i); 456 for (let i of this.tplProcessors) 457 this.tplProcessors.delete(i); 458 Q?.delete(this.updateCssData), Q?.size || (Ce?.disconnect(), Ce = null, Q = null); 459 }, 100))); 460 } 461 static reg(i, e = !1) { 462 i || (ui++, i = `${y.AUTO_TAG_PRFX}-${ui}`), this.__tag = i; 463 let t = window.customElements.get(i); 464 if (t) { 465 !e && t !== this && console.warn([ 466 `Element with tag name "${i}" already registered.`, 467 `You're trying to override it with another class "${this.name}".`, 468 "This is most likely a mistake.", 469 "New element will not be registered." 470 ].join(` 471`)); 472 return; 473 } 474 window.customElements.define(i, e ? class extends this { 475 } : this); 476 } 477 static get is() { 478 return this.__tag || this.reg(), this.__tag; 479 } 480 static bindAttributes(i) {
481 this.observedAttributes = Object.keys(i), this.__attrDesc = i; 482 } 483 attributeChangedCallback(i, e, t) { 484 var s; 485 if (e === t) 486 return; 487 let r = (s = this.constructor.__attrDesc) == null ? void 0 : s[i]; 488 r ? this.__dataCtxInitialized ? this.$[r] = t : this.init$[r] = t : this[i] = t; 489 } 490 getCssData(i, e = !1) { 491 if (this.__cssDataCache || (this.__cssDataCache = /* @__PURE__ */ Object.create(null)), !Object.keys(this.__cssDataCache).includes(i)) { 492 this.__computedStyle || (this.__computedStyle = window.getComputedStyle(this)); 493 let t = this.__computedStyle.getPropertyValue(i).trim(); 494 try { 495 this.__cssDataCache[i] = $r(t); 496 } catch { 497 !e && console.warn(`CSS Data error: ${i}`), this.__cssDataCache[i] = null; 498 } 499 } 500 return this.__cssDataCache[i]; 501 } 502 __extractCssName(i) { 503 return i.split("--").map((e, t) => t === 0 ? "" : e).join("--"); 504 } 505 __initStyleAttrObserver() { 506 Q || (Q = /* @__PURE__ */ new Set()), Q.add(this.updateCssData), Ce || (Ce = new MutationObserver((i) => { 507 i[0].type === "attributes" && Q.forEach((e) => { 508 e(); 509 }); 510 }), Ce.observe(document, { 511 childList: !0, 512 subtree: !0, 513 attributes: !0, 514 attributeFilter: ["style"] 515 })); 516 } 517 bindCssData(i, e = "") { 518 this.__boundCssProps || (this.__boundCssProps = /* @__PURE__ */ new Set()), this.__boundCssProps.add(i); 519 let t = this.getCssData(this.__extractCssName(i), !0); 520 t === null && (t = e), this.add(i, t), this.__initStyleAttrObserver(); 521 } 522 dropCssDataCache() { 523 this.__cssDataCache = null, this.__computedStyle = null; 524 } 525 defineAccessor(i, e, t) { 526 let s = "__" + i; 527 this[s] = this[i], Object.defineProperty(this, i, { 528 set: (r) => { 529 this[s] = r, t ? window.setTimeout(() => { 530 e?.(r); 531 }) : e?.(r); 532 }, 533 get: () => this[s] 534 }), this[i] = this[s]; 535 } 536 static set shadowStyles(i) { 537 let e = new Blob([i], { 538 type: "text/css" 539 }); 540 this.__shadowStylesUrl = URL.createObjectURL(e); 541 } 542 static set rootStyles(i) { 543 if (!this.__rootStylesLink) { 544 let e = new Blob([i], { 545 type: "text/css" 546 }), t = URL.createObjectURL(e), s = document.createElement("link"); 547 s.href = t, s.rel = "stylesheet", this.__rootStylesLink = s; 548 } 549 } 550}, ze = re; 551Pt(ze, "template"); 552function Mt(i, e) { 553 for (let t in e) 554 t.includes("-") ? i.style.setProperty(t, e[t]) : i.style[t] = e[t]; 555} 556function kr(i, e) { 557 for (let t in e) 558 e[t].constructor === Boolean ? e[t] ? i.setAttribute(t, "") : i.removeAttribute(t) : i.setAttribute(t, e[t]); 559} 560function Hi(i = { tag: "div" }) { 561 let e = document.createElement(i.tag); 562 if (i.attributes && kr(e, i.attributes), i.styles && Mt(e, i.styles), i.properties) 563 for (let t in i.properties) 564 e[t] = i.properties[t]; 565 return i.processors && i.processors.forEach((t) => { 566 t(e); 567 }), i.children && i.children.forEach((t) => { 568 let s = Hi(t); 569 e.appendChild(s); 570 }), e; 571} 572var ji = "idb-store-ready", Ir = "symbiote-db", Or = "symbiote-idb-update_", Lr = class { 573 _notifyWhenReady(i = null) { 574 window.dispatchEvent(new CustomEvent(ji, { 575 detail: { 576 dbName: this.name, 577 storeName: this.storeName, 578 event: i 579 } 580 })); 581 } 582 get _updEventName() { 583 return Or + this.name; 584 } 585 _getUpdateEvent(i) { 586 return new CustomEvent(this._updEventName, { 587 detail: { 588 key: this.name, 589 newValue: i 590 } 591 }); 592 } 593 _notifySubscribers(i) { 594 window.localStorage.removeItem(this.name), window.localStorage.setItem(this.name, i), window.dispatchEvent(this._getUpdateEvent(i)); 595 } 596 constructor(i, e) { 597 this.name = i, this.storeName = e, this.version = 1, this.request = window.indexedDB.open(this.name, this.version), this.request.onupgradeneeded = (t) => { 598 this.db = t.target.result, this.objStore = this.db.createObjectStore(e, { 599 keyPath: "_key" 600 }), this.objStore.transaction.oncomplete = (s) => { 601 this._notifyWhenReady(s); 602 }; 603 }, this.request.onsuccess = (t) => { 604 this.db = t.target.result, this._notifyWhenReady(t); 605 }, this.request.onerror = (t) => { 606 console.error(t); 607 }, this._subscriptionsMap = {}, this._updateHandler = (t) => { 608 t.key === this.name && this._subscriptionsMap[t.newValue] && this._subscriptionsMap[t.newValue].forEach(async (r) => { 609 r(await this.read(t.newValue)); 610 }); 611 }, this._localUpdateHandler = (t) => { 612 this._updateHandler(t.detail); 613 }, window.addEventListener("storage", this._updateHandler), window.addEventListener(this._updEventName, this._localUpdateHandler); 614 } 615 read(i) { 616 let t = this.db.transaction(this.storeName, "readwrite").objectStore(this.storeName).get(i); 617 return new Promise((s, r) => { 618 t.onsuccess = (n) => { 619 var o; 620 (o = n.target.result) != null && o._value ? s(n.target.result._value) : (s(null), console.warn(`IDB: cannot read "${i}"`)); 621 }, t.onerror = (n) => { 622 r(n); 623 }; 624 }); 625 } 626 write(i, e, t = !1) { 627 let s = { 628 _key: i, 629 _value: e 630 }, n = this.db.transaction(this.storeName, "readwrite").objectStore(this.storeName).put(s); 631 return new Promise((o, a) => { 632 n.onsuccess = (l) => { 633 t || this._notifySubscribers(i), o(l.target.result); 634 }, n.onerror = (l) => { 635 a(l); 636 }; 637 }); 638 } 639 delete(i, e = !1) { 640 let s = this.db.transaction(this.storeName, "readwrite").objectStore(this.storeName).delete(i); 641 return new Promise((r, n) => { 642 s.onsuccess = (o) => { 643 e || this._notifySubscribers(i), r(o); 644 }, s.onerror = (o) => { 645 n(o); 646 }; 647 }); 648 } 649 getAll() { 650 let e = this.db.transaction(this.storeName, "readwrite").objectStore(this.storeName).getAll(); 651 return new Promise((t, s) => { 652 e.onsuccess = (r) => { 653 let n = r.target.result; 654 t(n.map((o) => o._value)); 655 }, e.onerror = (r) => { 656 s(r); 657 }; 658 }); 659 } 660 subscribe(i, e) { 661 this._subscriptionsMap[i] || (this._subscriptionsMap[i] = /* @__PURE__ */ new Set()); 662 let t = this._subscriptionsMap[i]; 663 return t.add(e), { 664 remove: () => { 665 t.delete(e), t.size || delete this._subscriptionsMap[i]; 666 } 667 }; 668 } 669 stop() { 670 window.removeEventListener("storage", this._updateHandler), this._subscriptionsMap = null, Gi.clear(this.name); 671 } 672}, Gi = class { 673 static get readyEventName() { 674 return ji; 675 } 676 static open(i = Ir, e = "store") { 677 let t = i + "/" + e; 678 return this._reg[t] || (this._reg[t] = new Lr(i, e)), this._reg[t]; 679 } 680 static clear(i) { 681 window.indexedDB.deleteDatabase(i); 682 for (let e in this._reg) 683 e.split("/")[0] === i && delete this._reg[e]; 684 } 685};
686Pt(Gi, "_reg", /* @__PURE__ */ Object.create(null)); 687const Wi = (i) => { 688 if (typeof i != "string" || !i) 689 return ""; 690 let e = i.trim(); 691 return e.startsWith("-/") ? e = e.slice(2) : e.startsWith("/") && (e = e.slice(1)), e.endsWith("/") && (e = e.slice(0, e.length - 1)), e; 692}, Rt = (...i) => i.filter((e) => typeof e == "string" && e).map((e) => Wi( 693 /** @type {String} */ 694 e 695)).join("/-/"), le = (...i) => { 696 let e = Rt(...i); 697 return e ? `-/${e}/` : ""; 698}; 699function Dt(i) { 700 let e = new URL(i), t = e.pathname + e.search + e.hash, s = t.lastIndexOf("http"), r = t.lastIndexOf("/"), n = ""; 701 return s >= 0 ? n = t.slice(s) : r >= 0 && (n = t.slice(r + 1)), n; 702} 703function qi(i) { 704 let e = new URL(i), { pathname: t } = e; 705 const s = t.indexOf("/"), r = t.indexOf("/", s + 1); 706 return t.substring(s + 1, r); 707} 708function Xi(i) { 709 let e = Zi(i), t = new URL(e), s = t.pathname.indexOf("/-/"); 710 return s === -1 ? "" : t.pathname.substring(s).slice(1); 711} 712function Ur(i) { 713 return Xi(i).split("/-/").filter(Boolean).map((t) => Wi(t)); 714} 715function Zi(i) { 716 let e = new URL(i), t = Dt(i), s = Ki(t) ? Yi(t).pathname : t; 717 return e.pathname = e.pathname.replace(s, ""), e.search = "", e.hash = "", e.toString(); 718} 719function Ki(i) { 720 return i.startsWith("http"); 721} 722function Yi(i) { 723 let e = new URL(i); 724 return { 725 pathname: e.origin + e.pathname || "", 726 search: e.search || "", 727 hash: e.hash || "" 728 }; 729} 730const j = (i, e, t) => { 731 let s = new URL(Zi(i)); 732 if (t = t || Dt(i), s.pathname.startsWith("//") && (s.pathname = s.pathname.replace("//", "/")), Ki(t)) { 733 let r = Yi(t); 734 s.pathname = s.pathname + (e || "") + (r.pathname || ""), s.search = r.search, s.hash = r.hash; 735 } else 736 s.pathname = s.pathname + (e || "") + (t || ""); 737 return s.toString(); 738}, Ve = (i, e) => { 739 let t = new URL(i); 740 return t.pathname = e + "/", t.toString(); 741}, ce = (i, e = ",") => i.trim().split(e).map((t) => t.trim()).filter((t) => t.length > 0), B = Object.freeze({ 742 brightness: 0, 743 exposure: 0, 744 gamma: 100, 745 contrast: 0, 746 saturation: 0, 747 vibrance: 0, 748 warmth: 0, 749 enhance: 0, 750 filter: 0, 751 rotate: 0, 752 mirror: !1, 753 flip: !1, 754 crop: void 0 755}), Ji = ( 756 /** @type {const} */ 757 [ 758 "enhance", 759 "brightness", 760 "exposure", 761 "gamma", 762 "contrast", 763 "saturation", 764 "vibrance", 765 "warmth", 766 "filter", 767 "mirror", 768 "flip", 769 "rotate", 770 "crop" 771 ] 772); 773function Pr(i, e) { 774 if (typeof e == "number") { 775 const t = e; 776 return B[i] !== t ? `${i}/${t}` : ""; 777 } 778 if (typeof e == "boolean") { 779 const t = e; 780 return B[i] !== t ? `${i}` : ""; 781 } 782 if (i === "filter" && e) { 783 const { name: t, amount: s } = ( 784 /** @type {NonNullable<import('../types').Transformations['filter']>} */ 785 e 786 ); 787 return B.filter === s ? "" : `${i}/${t}/${s}`; 788 } 789 if (i === "crop" && e) { 790 let { dimensions: t, coords: s } = ( 791 /** @type {NonNullable<import('../types').Transformations['crop']>} */ 792 e 793 ); 794 return `${i}/${t.join("x")}/${s.join(",")}`; 795 } 796 return ""; 797} 798function rt(i) { 799 return Rt( 800 ...Ji.filter( 801 (e) => typeof i[e] < "u" && i[e] !== null 802 ).map((e) => { 803 let t = i[e]; 804 return Pr(e, t); 805 }).filter((e) => !!e) 806 ); 807} 808const Qi = Rt("format/auto", "progressive/yes"), ee = ([i]) => typeof i < "u" ? Number(i) : void 0, di = () => !0, Mr = ([i, e]) => ({ 809 name: i, 810 amount: typeof e < "u" ? Number(e) : 100 811}), Rr = ([i, e]) => { 812 if (!/\d+x\d+/.test(i) || !/\d+,\d+/.test(e)) 813 throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported."); 814 return ( 815 /** @type {{ dimensions: [number, number]; coords: [number, number] }} */ 816 { 817 dimensions: ce(i, "x").map(Number), 818 coords: ce(e).map(Number) 819 } 820 ); 821}, Dr = Object.freeze({ 822 enhance: ee, 823 brightness: ee, 824 exposure: ee, 825 gamma: ee, 826 contrast: ee, 827 saturation: ee, 828 vibrance: ee, 829 warmth: ee, 830 filter: Mr, 831 mirror: di, 832 flip: di, 833 rotate: ee, 834 crop: Rr 835}); 836function Fr(i) { 837 const e = {}; 838 for (const t of i) { 839 const [s, ...r] = t.split("/"); 840 if (!Ji.includes(s)) 841 continue; 842 const n = ( 843 /** @type {(typeof SUPPORTED_OPERATIONS_ORDERED)[number]} */ 844 s 845 ), o = Dr[n]; 846 try { 847 const a = o(r); 848 e[n] = a; 849 } catch (a) { 850 console.warn( 851 [ 852 `Failed to parse URL operation "${t}". It will be ignored.`, 853 a instanceof Error ? `Error message: "${a.message}"` : a, 854 "If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new" 855 ].join(` 856`) 857 ); 858 } 859 } 860 return ( 861 /** @type {import('../types.js').Transformations} */ 862 e 863 ); 864} 865const I = Object.freeze({ 866 CROP: "crop", 867 TUNING: "tuning", 868 FILTERS: "filters" 869}), J = [I.CROP, I.TUNING, I.FILTERS], Vr = [ 870 "brightness", 871 "exposure", 872 "gamma", 873 "contrast", 874 "saturation", 875 "vibrance", 876 "warmth", 877 "enhance" 878], Nr = [ 879 "adaris", 880 "briaril", 881 "calarel", 882 "carris", 883 "cynarel", 884 "cyren", 885 "elmet", 886 "elonni", 887 "enzana", 888 "erydark", 889 "fenralan", 890 "ferand", 891 "galen", 892 "gavin", 893 "gethriel", 894 "iorill", 895 "iothari", 896 "iselva", 897 "jadis", 898 "lavra", 899 "misiara", 900 "namala", 901 "nerion", 902 "nethari", 903 "pamaya", 904 "sarnar", 905 "sedis", 906 "sewen", 907 "sorahel", 908 "sorlen", 909 "tarian", 910 "thellassan", 911 "varriel", 912 "varven", 913 "vevera", 914 "virkas", 915 "yedis", 916 "yllara", 917 "zatvel", 918 "zevcen" 919], zr = ["rotate", "mirror", "flip"], Se = Object.freeze({ 920 brightness: { 921 zero: B.brightness, 922 range: [-100, 100], 923 keypointsNumber: 2 924 }, 925 exposure: { 926 zero: B.exposure, 927 range: [-500, 500], 928 keypointsNumber: 2 929 }, 930 gamma: { 931 zero: B.gamma, 932 range: [0, 1e3], 933 keypointsNumber: 2 934 }, 935 contrast: { 936 zero: B.contrast, 937 range: [-100, 500], 938 keypointsNumber: 2 939 }, 940 saturation: { 941 zero: B.saturation, 942 range: [-100, 500], 943 keypointsNumber: 1 944 }, 945 vibrance: { 946 zero: B.vibrance, 947 range: [-100, 500], 948 keypointsNumber: 1 949 }, 950 warmth: { 951 zero: B.warmth, 952 range: [-100, 100], 953 keypointsNumber: 1 954 }, 955 enhance: { 956 zero: B.enhance, 957 range: [0, 100], 958 keypointsNumber: 1 959 }, 960 filter: { 961 zero: B.filter, 962 range: [0, 100], 963 keypointsNumber: 1 964 } 965}), Br = (i) => i ? i.split(",").map((e) => e.trim()) : [], Ft = (i) => i ? i.join(",") : "", Hr = "https://ucarecdn.com", jr = "https://upload.uploadcare.com", Gr = "https://social.uploadcare.com", oe = { 966 pubkey: "", 967 multiple: !0, 968 multipleMin: 0, 969 multipleMax: Number.MAX_SAFE_INTEGER, 970 confirmUpload: !1, 971 imgOnly: !1, 972 accept: "", 973 externalSourcesPreferredTypes: "", 974 externalSourcesEmbedCss: "", 975 store: "auto", 976 cameraMirror: !1, 977 cameraCapture: "", 978 sourceList: "local, url, camera, dropbox, gdrive", 979 cloudImageEditorTabs: Ft(J), 980 maxLocalFileSizeBytes: 0, 981 thumbSize: 76, 982 showEmptyList: !1, 983 useLocalImageEditor: !1, 984 useCloudImageEditor: !0, 985 removeCopyright: !1, 986 cropPreset: "", 987 imageShrink: "", 988 modalScrollLock: !0, 989 modalBackdropStrokes: !1, 990 sourceListWrap: !0, 991 remoteTabSessionKey: "", 992 cdnCname: Hr, 993 baseUrl: jr, 994 socialBaseUrl: Gr, 995 secureSignature: "", 996 secureExpire: "", 997 secureDeliveryProxy: "", 998 retryThrottledRequestMaxTimes: 1, 999 multipartMinFileSize: 26214400, 1000 multipartChunkSize: 5242880, 1001 maxConcurrentRequests: 10, 1002 multipartMaxConcurrentRequests: 4, 1003 multipartMaxAttempts: 3, 1004 checkForUrlDuplicates: !1, 1005 saveUrlForRecurrentUploads: !1, 1006 groupOutput: !1, 1007 userAgentIntegration: "", 1008 debug: !1, 1009 metadata: null, 1010 localeName: "en", 1011 localeDefinitionOverride: null, 1012 secureUploadsExpireThreshold: 600 * 1e3, 1013 secureUploadsSignatureResolver: null, 1014 secureDeliveryProxyUrlResolver: null, 1015 iconHrefResolver: null, 1016 fileValidators: [], 1017 collectionValidators: [], 1018 defaultCameraMode: "photo", 1019 enableAudioRecording: !0, 1020 enableVideoRecording: !0, 1021 maxVideoRecordingDuration: null, 1022 mediaRecorerOptions: null 1023}, Wr = 20, O = Object.freeze({ 1024 FILE_ADDED: "file-added", 1025 FILE_REMOVED: "file-removed", 1026 FILE_UPLOAD_START: "file-upload-start", 1027 FILE_UPLOAD_PROGRESS: "file-upload-progress", 1028 FILE_UPLOAD_SUCCESS: "file-upload-success", 1029 FILE_UPLOAD_FAILED: "file-upload-failed", 1030 FILE_URL_CHANGED: "file-url-changed", 1031 MODAL_OPEN: "modal-open", 1032 MODAL_CLOSE: "modal-close", 1033 DONE_CLICK: "done-click", 1034 UPLOAD_CLICK: "upload-click", 1035 ACTIVITY_CHANGE: "activity-change", 1036 COMMON_UPLOAD_START: "common-upload-start", 1037 COMMON_UPLOAD_PROGRESS: "common-upload-progress", 1038 COMMON_UPLOAD_SUCCESS: "common-upload-success", 1039 COMMON_UPLOAD_FAILED: "common-upload-failed", 1040 CHANGE: "change", 1041 GROUP_CREATED: "group-created" 1042}); 1043class qr { 1044 /** 1045 * @private 1046 * @type {Map<string, number>} 1047 */ 1048 _timeoutStore = /* @__PURE__ */ new Map(); 1049 /** 1050 * @private 1051 * @type {Set<import('../../abstract/Block.js').Block>} 1052 */ 1053 _targets = /* @__PURE__ */ new Set(); 1054 /** 1055 * @private 1056 * @type {((...args: unknown[]) => void) | null} 1057 */ 1058 _debugPrint = null; 1059 /** @param {(...args: unknown[]) => void} debugPrint */ 1060 constructor(e) { 1061 this._debugPrint = e; 1062 } 1063 /** @param {import('../../abstract/Block.js').Block} target */ 1064 bindTarget(e) { 1065 this._targets.add(e); 1066 } 1067 /** @param {import('../../abstract/Block.js').Block} target */ 1068 unbindTarget(e) { 1069 this._targets.delete(e); 1070 } 1071 /** 1072 * @private 1073 * @template {(typeof EventType)[keyof typeof EventType]} T 1074 * @param {T} type 1075 * @param {unknown} [payload] 1076 */ 1077 _dispatch(e, t) { 1078 for (const s of this._targets) 1079 s.dispatchEvent( 1080 new CustomEvent(e, { 1081 detail: t 1082 }) 1083 ); 1084 this._debugPrint?.(() => { 1085 const s = t && typeof t == "object" ? { ...t } : t; 1086 return [`event "${e}"`, s]; 1087 }); 1088 } 1089 /** 1090 * @template {(typeof EventType)[keyof typeof EventType]} T 1091 * @template {boolean | number | undefined} TDebounce 1092 * @param {T} type 1093 * @param {TDebounce extends false | undefined ? unknown : () => unknown} [payload] 1094 * @param {{ debounce?: TDebounce }} [options] 1095 */ 1096 emit(e, t, { debounce: s } = {}) { 1097 if (typeof s != "number" && !s) { 1098 this._dispatch(e, typeof t == "function" ? t() : t); 1099 return; 1100 } 1101 this._timeoutStore.has(e) && window.clearTimeout(this._timeoutStore.get(e)); 1102 const r = typeof s == "number" ? s : Wr, n = window.setTimeout(() => { 1103 this._dispatch(e, typeof t == "function" ? t() : t), this._timeoutStore.delete(e); 1104 }, r); 1105 this._timeoutStore.set(e, n); 1106 } 1107} 1108function G(i, e) { 1109 let t; 1110 const s = ( 1111 /** @param {...any} args */ 1112 (...r) => { 1113 clearTimeout(t), t = setTimeout(() => i(...r), e); 1114 } 1115 ); 1116 return s.cancel = () => { 1117 clearTimeout(t); 1118 }, /** @type {T & { cancel: () => void }} } */ 1119 s; 1120} 1121const hi = "--uploadcare-blocks-window-height"; 1122class fi { 1123 /** 1124 * @private 1125 * @type {Set<unknown>} 1126 */ 1127 static clientsRegistry = /* @__PURE__ */ new Set(); 1128 /** @private */ 1129 static flush = G(() => { 1130 document.documentElement.style.setProperty(hi, `${window.innerHeight}px`); 1131 }, 100); 1132 /** 1133 * @param {unknown} client 1134 * @public 1135 */ 1136 static registerClient(e) { 1137 this.clientsRegistry.size === 0 && this.attachTracker(), this.clientsRegistry.add(e); 1138 } 1139 /** 1140 * @param {unknown} client 1141 * @public 1142 */ 1143 static unregisterClient(e) { 1144 this.clientsRegistry.delete(e), this.clientsRegistry.size === 0 && this.detachTracker(); 1145 } 1146 /** @private */ 1147 static attachTracker() { 1148 window.addEventListener("resize", this.flush, { passive: !0, capture: !0 }), this.flush(); 1149 } 1150 /** @private */ 1151 static detachTracker() { 1152 window.removeEventListener("resize", this.flush, { capture: !0 }), document.documentElement.style.removeProperty(hi); 1153 } 1154} 1155const Xr = (i) => { 1156 const e = ( 1157 /** @type {any} */ 1158 new Intl.Locale(i) 1159 ); 1160 let t = "ltr"; 1161 return typeof e.getTextInfo == "function" && e.getTextInfo().direction ? t = e.getTextInfo().direction : "textInfo" in e && e.textInfo?.direction && (t = e.textInfo.direction), t; 1162}, es = (i, e) => new Intl.PluralRules(i).select(e), Zr = (i) => i, $t = "{{", ts = "}}", pi = "plural:"; 1163function kt(i, e, t = {}) { 1164 let { openToken: s = $t, closeToken: r = ts, transform: n = Zr } = t; 1165 for (let o in e) { 1166 let a = e[o]?.toString(); 1167 i = i.replaceAll(s + o + r, typeof a == "string" ? n(a) : a); 1168 } 1169 return i; 1170} 1171function Kr(i) { 1172 const e = []; 1173 let t = i.indexOf($t); 1174 for (; t !== -1; ) { 1175 const s = i.indexOf(ts, t), r = i.substring(t + 2, s); 1176 if (r.startsWith(pi)) { 1177 const n = i.substring(t + 2, s).replace(pi, ""), o = n.substring(0, n.indexOf("(")), a = n.substring(n.indexOf("(") + 1, n.indexOf(")")); 1178 e.push({ variable: r, pluralKey: o, countVariable: a }); 1179 } 1180 t = i.indexOf($t, s); 1181 } 1182 return e; 1183}
1184const Yr = ({ element: i, attribute: e, onSuccess: t, onTimeout: s, timeout: r = 300 }) => { 1185 const n = i.getAttribute(e); 1186 if (n !== null) { 1187 t(n); 1188 return; 1189 } 1190 const o = new MutationObserver((c) => { 1191 const d = c[c.length - 1]; 1192 l(d); 1193 }); 1194 o.observe(i, { 1195 attributes: !0, 1196 attributeFilter: [e] 1197 }); 1198 const a = setTimeout(() => { 1199 o.disconnect(), s(); 1200 }, r), l = (c) => { 1201 const d = i.getAttribute(e); 1202 c.type === "attributes" && c.attributeName === e && d !== null && (clearTimeout(a), o.disconnect(), t(d)); 1203 }; 1204}; 1205function mi(i) { 1206 return Object.prototype.toString.call(i) === "[object Object]"; 1207} 1208const Jr = /\W|_/g; 1209function Qr(i) { 1210 return i.split(Jr).map((e, t) => e.charAt(0)[t > 0 ? "toUpperCase" : "toLowerCase"]() + e.slice(1)).join(""); 1211} 1212function gi(i, { ignoreKeys: e } = { ignoreKeys: [] }) { 1213 return Array.isArray(i) ? i.map((t) => se(t, { ignoreKeys: e })) : i; 1214} 1215function se(i, { ignoreKeys: e } = { ignoreKeys: [] }) { 1216 if (Array.isArray(i)) 1217 return gi(i, { ignoreKeys: e }); 1218 if (!mi(i)) 1219 return i; 1220 const t = {}; 1221 for (const s of Object.keys(i)) { 1222 let r = i[s]; 1223 if (e.includes(s)) { 1224 t[s] = r; 1225 continue; 1226 } 1227 mi(r) ? r = se(r, { ignoreKeys: e }) : Array.isArray(r) && (r = gi(r, { ignoreKeys: e })), t[Qr(s)] = r; 1228 } 1229 return t; 1230} 1231const is = (i, e) => new Promise((t) => { 1232 if (e?.aborted) { 1233 t(); 1234 return; 1235 } 1236 const s = () => { 1237 clearTimeout(r), e?.removeEventListener("abort", s), t(); 1238 }, r = setTimeout(s, i); 1239 e?.addEventListener("abort", s, { once: !0 }); 1240}); 1241function ss({ libraryName: i, libraryVersion: e, userAgent: t, publicKey: s = "", integration: r = "" }) { 1242 const n = "JavaScript"; 1243 if (typeof t == "string") 1244 return t; 1245 if (typeof t == "function") 1246 return t({ 1247 publicKey: s, 1248 libraryName: i, 1249 libraryVersion: e, 1250 languageName: n, 1251 integration: r 1252 }); 1253 const o = [i, e, s].filter(Boolean).join("/"), a = [n, r].filter(Boolean).join("; "); 1254 return `${o} (${a})`; 1255} 1256const en = { 1257 factor: 2, 1258 time: 100 1259}; 1260function tn(i, e = en) { 1261 let t = 0; 1262 function s(r) { 1263 const n = Math.round(e.time * e.factor ** t); 1264 return r({ 1265 attempt: t, 1266 retry: (a) => is(a ?? n).then(() => (t += 1, s(r))) 1267 }); 1268 } 1269 return s(i); 1270} 1271class Vt extends Error { 1272} 1273class Be extends Vt { 1274 originalProgressEvent; 1275 constructor(e) { 1276 super(), this.name = "NetworkError", this.message = "Network error", Object.setPrototypeOf(this, Be.prototype), this.originalProgressEvent = e; 1277 } 1278} 1279const Nt = (i, e) => { 1280 i && (i.aborted ? Promise.resolve().then(e) : i.addEventListener("abort", () => e(), { once: !0 })); 1281}; 1282class te extends Vt { 1283 isCancel = !0; 1284 constructor(e = "Request canceled") { 1285 super(e), this.name = "CancelError", Object.setPrototypeOf(this, te.prototype); 1286 } 1287} 1288const sn = 500, rs = async ({ check: i, interval: e = sn, timeout: t, signal: s }) => { 1289 const r = Date.now(), n = () => t === void 0 ? 1 / 0 : t - (Date.now() - r); 1290 for (; ; ) { 1291 if (s?.aborted) 1292 throw new te("Poll cancelled"); 1293 if (n() <= 0) 1294 throw new te("Timed out"); 1295 let o; 1296 try { 1297 o = await i(s); 1298 } catch (a) { 1299 throw s?.aborted ? new te("Poll cancelled") : a; 1300 } 1301 if (s?.aborted) 1302 throw new te("Poll cancelled"); 1303 if (o) 1304 return o; 1305 await is(Math.min(e, n()), s); 1306 } 1307}, w = { 1308 baseCDN: "https://ucarecdn.com", 1309 prefixedBaseCDN: "https://ucarecd.net", 1310 baseURL: "https://upload.uploadcare.com", 1311 retryThrottledRequestMaxTimes: 1, 1312 retryNetworkErrorMaxTimes: 3, 1313 multipartMinFileSize: 25 * 1024 * 1024, 1314 // 25 MB 1315 multipartChunkSize: 5 * 1024 * 1024, 1316 // 5 MB 1317 maxConcurrentRequests: 4, 1318 pusherKey: "79ae88bd931ea68464d9" 1319}, nt = "application/octet-stream", ns = "original", ue = ({ method: i, url: e, data: t, headers: s = {}, signal: r, onProgress: n }) => new Promise((o, a) => { 1320 const l = new XMLHttpRequest(), c = i?.toUpperCase() || "GET"; 1321 let d = !1; 1322 l.open(c, e, !0), s && Object.entries(s).forEach((u) => { 1323 const [h, f] = u; 1324 typeof f < "u" && !Array.isArray(f) && l.setRequestHeader(h, f); 1325 }), l.responseType = "text", Nt(r, () => { 1326 d = !0, l.abort(), a(new te()); 1327 }), l.onload = () => { 1328 if (l.status != 200) 1329 a(new Error(`Error ${l.status}: ${l.statusText}`)); 1330 else { 1331 const u = { 1332 method: c, 1333 url: e, 1334 data: t, 1335 headers: s || void 0, 1336 signal: r, 1337 onProgress: n 1338 }, h = l.getAllResponseHeaders().trim().split(/[\r\n]+/), f = {}; 1339 h.forEach(function(b) { 1340 const C = b.split(": "), E = C.shift(), T = C.join(": "); 1341 E && typeof E < "u" && (f[E] = T); 1342 }); 1343 const p = l.response, m = l.status; 1344 o({ 1345 request: u, 1346 data: p, 1347 headers: f, 1348 status: m 1349 }); 1350 } 1351 }, l.onerror = (u) => { 1352 d || a(new Be(u)); 1353 }, n && typeof n == "function" && (l.upload.onprogress = (u) => { 1354 u.lengthComputable ? n({ 1355 isComputable: !0, 1356 value: u.loaded / u.total 1357 }) : n({ isComputable: !1 }); 1358 }), t ? l.send(t) : l.send(); 1359}); 1360function rn(i, ...e) { 1361 return i; 1362} 1363const nn = ({ name: i }) => i ? [i] : [], on = rn; 1364var an = () => new FormData(); 1365const os = (i) => !1, ot = (i) => typeof Blob < "u" && i instanceof Blob, at = (i) => typeof File < "u" && i instanceof File, lt = (i) => !!i && typeof i == "object" && !Array.isArray(i) && "uri" in i && typeof i.uri == "string", Ie = (i) => ot(i) || at(i) || os() || lt(i), ln = (i) => typeof i == "string" || typeof i == "number" || typeof i > "u", cn = (i) => !!i && typeof i == "object" && !Array.isArray(i), un = (i) => !!i && typeof i == "object" && "data" in i && Ie(i.data); 1366function as(i, e, t) { 1367 if (Array.isArray(t)) 1368 for (const s of t) 1369 as(i, `${e}[]`, s); 1370 else if (un(t)) { 1371 const { name: s, contentType: r } = t, n = on(t.data, s, r ?? nt), o = nn({ name: s }); 1372 i.push([e, n, ...o]); 1373 } else if (cn(t)) 1374 for (const [s, r] of Object.entries(t)) 1375 typeof r < "u" && i.push([`${e}[${s}
1375]`, String(r)]); 1376 else ln(t) && t && i.push([e, t.toString()]); 1377} 1378function dn(i) { 1379 const e = []; 1380 for (const [t, s] of Object.entries(i)) 1381 as(e, t, s); 1382 return e; 1383} 1384function ct(i) { 1385 const e = an(), t = dn(i); 1386 for (const s of t) { 1387 const [r, n, ...o] = s; 1388 e.append(r, n, ...o); 1389 } 1390 return e; 1391} 1392class F extends Vt { 1393 code; 1394 request; 1395 response; 1396 headers; 1397 constructor(e, t, s, r, n) { 1398 super(), this.name = "UploadError", this.message = e, this.code = t, this.request = s, this.response = r, this.headers = n, Object.setPrototypeOf(this, F.prototype); 1399 } 1400} 1401const hn = (i) => { 1402 const e = new URLSearchParams(); 1403 for (const [t, s] of Object.entries(i)) 1404 s && typeof s == "object" && !Array.isArray(s) ? Object.entries(s).filter((r) => r[1] ?? !1).forEach((r) => e.set(`${t}[${r[0]}]`, String(r[1]))) : Array.isArray(s) ? s.forEach((r) => { 1405 e.append(`${t}[]`, r); 1406 }) : typeof s == "string" && s ? e.set(t, s) : typeof s == "number" && e.set(t, s.toString()); 1407 return e.toString(); 1408}, ie = (i, e, t) => { 1409 const s = new URL(i); 1410 return s.pathname = (s.pathname + e).replace("//", "/"), t && (s.search = hn(t)), s.toString(); 1411}; 1412var fn = "6.21.0"; 1413const pn = "UploadcareUploadClient", mn = fn; 1414function ye(i) { 1415 return ss({ 1416 libraryName: pn, 1417 libraryVersion: mn, 1418 ...i 1419 }); 1420} 1421const gn = "RequestThrottledError", bi = 15e3, bn = 1e3; 1422function _n(i) { 1423 const { headers: e } = i || {}; 1424 if (!e || typeof e["retry-after"] != "string") 1425 return bi; 1426 const t = parseInt(e["retry-after"], 10); 1427 return Number.isFinite(t) ? t * 1e3 : bi; 1428} 1429function de(i, e) { 1430 const { retryThrottledRequestMaxTimes: t, retryNetworkErrorMaxTimes: s } = e; 1431 return tn(({ attempt: r, retry: n }) => i().catch((o) => { 1432 if ("response" in o && o?.code === gn && r < t) 1433 return n(_n(o)); 1434 if (o instanceof Be && r < s) 1435 return n((r + 1) * bn); 1436 throw o; 1437 })); 1438} 1439const ls = (i) => { 1440 let e = ""; 1441 return (ot(i) || at(i) || lt(i)) && (e = i.type), e || nt; 1442}, cs = (i) => { 1443 let e = ""; 1444 return at(i) && i.name ? e = i.name : ot(i) || os() ? e = "" : lt(i) && i.name && (e = i.name), e || ns; 1445}; 1446function zt(i) { 1447 return typeof i > "u" || i === "auto" ? "auto" : i ? "1" : "0"; 1448} 1449function Bt(i) { 1450 return Array.isArray(i) ? i.join(",") : typeof i == "string" ? i : void 0; 1451} 1452function yn(i, { publicKey: e, fileName: t, contentType: s, baseURL: r = w.baseURL, secureSignature: n, secureExpire: o, store: a, signal: l, onProgress: c, source: d = "local", integration: u, userAgent: h, retryThrottledRequestMaxTimes: f = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: p = w.retryNetworkErrorMaxTimes, metadata: m, tags: b }) { 1453 return de(() => ue({ 1454 method: "POST", 1455 url: ie(r, "/base/", { 1456 jsonerrors: 1 1457 }), 1458 headers: { 1459 "X-UC-User-Agent": ye({ publicKey: e, integration: u, userAgent: h }) 1460 }, 1461 data: ct({ 1462 file: { 1463 data: i, 1464 name: t || cs(i), 1465 contentType: s || ls(i) 1466 }, 1467 UPLOADCARE_PUB_KEY: e, 1468 UPLOADCARE_STORE: zt(a), 1469 signature: n, 1470 expire: o, 1471 source: d, 1472 metadata: m, 1473 tags: Bt(b) 1474 }), 1475 signal: l, 1476 onProgress: c 1477 }).then(({ data: C, headers: E, request: T }) => { 1478 const g = se(JSON.parse(C)); 1479 if ("error" in g) 1480 throw new F(g.error.content, g.error.errorCode, T, g, E); 1481 return g; 1482 }), { retryNetworkErrorMaxTimes: p, retryThrottledRequestMaxTimes: f }); 1483} 1484var It; 1485(function(i) { 1486 i.Token = "token", i.FileInfo = "file_info"; 1487})(It || (It = {})); 1488function vn(i, { publicKey: e, baseURL: t = w.baseURL, store: s, fileName: r, checkForUrlDuplicates: n, saveUrlForRecurrentUploads: o, secureSignature: a, secureExpire: l, source: c = "url", signal: d, integration: u, userAgent: h, retryThrottledRequestMaxTimes: f = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: p = w.retryNetworkErrorMaxTimes, metadata: m, tags: b }) { 1489 return de(() => ue({ 1490 method: "POST", 1491 headers: { 1492 "X-UC-User-Agent": ye({ publicKey: e, integration: u, userAgent: h }) 1493 }, 1494 url: ie(t, "/from_url/", { 1495 jsonerrors: 1, 1496 pub_key: e, 1497 source_url: i, 1498 store: zt(s), 1499 filename: r, 1500 check_URL_duplicates: n ? 1 : void 0, 1501 save_URL_duplicates: o ? 1 : void 0, 1502 signature: a, 1503 expire: l, 1504 source: c, 1505 metadata: m, 1506 tags: Bt(b) 1507 }), 1508 signal: d 1509 }).then(({ data: C, headers: E, request: T }) => { 1510 const g = se(JSON.parse(C)); 1511 if ("error" in g) 1512 throw new F(g.error.content, g.error.errorCode, T, g, E); 1513 return g; 1514 }), { retryNetworkErrorMaxTimes: p, retryThrottledRequestMaxTimes: f }); 1515} 1516var D; 1517(function(i) { 1518 i.Unknown = "unknown", i.Waiting = "waiting", i.Progress = "progress", i.Error = "error", i.Success = "success"; 1519})(D || (D = {})); 1520const wn = (i) => "status" in i && i.status === D.Error; 1521function Cn(i, { publicKey: e, baseURL: t = w.baseURL, signal: s, integration: r, userAgent: n, retryThrottledRequestMaxTimes: o = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: a = w.retryNetworkErrorMaxTimes } = {}) { 1522 return de(() => ue({ 1523 method: "GET", 1524 headers: e ? { 1525 "X-UC-User-Agent": ye({ 1526 publicKey: e, 1527 integration: r, 1528 userAgent: n 1529 }) 1530 } : void 0, 1531 url: ie(t, "/from_url/status/", { 1532 jsonerrors: 1, 1533 token: i 1534 }), 1535 signal: s 1536 }).then(({ data: l, headers: c, request: d }) => { 1537 const u = se(JSON.parse(l)); 1538 if ("error" in u && !wn(u)) 1539 throw new F(u.error.content, u.error.errorCode, d, u, c); 1540 return u; 1541 }), { retryNetworkErrorMaxTimes: a, retryThrottledRequestMaxTimes: o }); 1542} 1543function An(i, { publicKey: e, baseURL: t = w.baseURL, jsonpCallback: s, secureSignature: r, secureExpire: n, signal: o, source: a, integration: l, userAgent: c, retryThrottledRequestMaxTimes: d = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: u = w.retryNetworkErrorMaxTimes }) { 1544 return de(() => ue({ 1545 method: "POST", 1546 headers: { 1547 "X-UC-User-Agent": ye({ publicKey: e, integration: l, userAgent: c }) 1548 }, 1549 url: ie(t, "/group/", { 1550 jsonerrors: 1 1551 }), 1552 data: ct({ 1553 files: i, 1554 callback: s, 1555 pub_key: e, 1556 signature: r, 1557 expire: n, 1558 source: a 1559 }), 1560 signal: o 1561 }).then(({ data: h, headers: f, request: p }) => { 1562 const m = se(JSON.parse(h)); 1563 if ("error" in m) 1564 throw new F(m.error.content, m.error.errorCode, p, m, f); 1565 return m; 1566 }), { retryNetworkErrorMaxTimes: u, retryThrottledRequestMaxTimes: d }); 1567} 1568function En(i, { publicKey: e, baseURL: t = w.baseURL, signal: s, source: r, integration: n, userAgent: o, retryThrottledRequestMaxTimes: a = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: l = w.retryNetworkErrorMaxTimes }) { 1569 return de(() => ue({ 1570 method: "GET", 1571 headers: { 1572 "X-UC-User-Agent": ye({ publicKey: e, integration: n, userAgent: o }) 1573 }, 1574 url: ie(t, "/info/", { 1575 jsonerrors: 1, 1576 pub_key: e, 1577 file_id: i, 1578 source: r 1579 }), 1580 signal: s 1581 }).then(({ data: c, headers: d, request: u }) => { 1582 const h = se(JSON.parse(c)); 1583 if ("error" in h) 1584 throw new F(h.error.content, h.error.errorCode, u, h, d); 1585 return h; 1586 }), { retryThrottledRequestMaxTimes: a, retryNetworkErrorMaxTimes: l }); 1587} 1588function Tn(i, { publicKey: e, contentType: t, fileName: s, multipartChunkSize: r = w.multipartChunkSize, baseURL: n = "", secureSignature: o, secureExpire: a, store: l, signal: c, source: d = "local", integration: u, userAgent: h, retryThrottledRequestMaxTimes: f = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: p = w.retryNetworkErrorMaxTimes, metadata: m, tags: b }) { 1589 return de(() => ue({ 1590 method: "POST", 1591 url: ie(n, "/multipart/start/", { jsonerrors: 1 }), 1592 headers: { 1593 "X-UC-User-Agent": ye({ publicKey: e, integration: u, userAgent: h }) 1594 }, 1595 data: ct({ 1596 filename: s || ns, 1597 size: i, 1598 content_type: t || nt, 1599 part_size: r, 1600 UPLOADCARE_STORE: zt(l), 1601 UPLOADCARE_PUB_KEY: e, 1602 signature: o, 1603 expire: a, 1604 source: d, 1605 metadata: m, 1606 tags: Bt(b) 1607 }), 1608 signal: c 1609 }).then(({ data: C, headers: E, request: T }) => { 1610 const g = se(JSON.parse(C)); 1611 if ("error" in g) 1612 throw new F(g.error.content, g.error.errorCode, T, g, E); 1613 return g.parts = Object.keys(g.parts).map((M) => g.parts[Number(M)]), g; 1614 }), { retryThrottledRequestMaxTimes: f, retryNetworkErrorMaxTimes: p }); 1615} 1616function xn(i, e, { contentType: t, signal: s, onProgress: r, retryThrottledRequestMaxTimes: n = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: o = w.retryNetworkErrorMaxTimes }) { 1617 return de(() => ue({ 1618 method: "PUT", 1619 url: e, 1620 data: i, 1621 // Upload request can't be non-computable because we always know exact size 1622 onProgress: r, 1623 signal: s, 1624 headers: { 1625 "Content-Type": t || nt 1626 } 1627 }).then((a) => (r && r({ 1628 isComputable: !0, 1629 value: 1 1630 }), a)).then(({ status: a }) => ({ code: a })), { 1631 retryThrottledRequestMaxTimes: n, 1632 retryNetworkErrorMaxTimes: o 1633 }); 1634} 1635function Sn(i, { publicKey: e, baseURL: t = w.baseURL, source: s = "local", signal: r, integration: n, userAgent: o, retryThrottledRequestMaxTimes: a = w.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: l = w.retryNetworkErrorMaxTimes }) { 1636 return de(() => ue({ 1637 method: "POST", 1638 url: ie(t, "/multipart/complete/", { jsonerrors: 1 }), 1639 headers: { 1640 "X-UC-User-Agent": ye({ publicKey: e, integration: n, userAgent: o }) 1641 }, 1642 data: ct({ 1643 uuid: i, 1644 UPLOADCARE_PUB_KEY: e, 1645 source: s 1646 }), 1647 signal: r 1648 }).then(({ data: c, headers: d, request: u }) => { 1649 const h = se(JSON.parse(c)); 1650 if ("error" in h) 1651 throw new F(h.error.content, h.error.errorCode, u, h, d); 1652 return h; 1653 }), { retryThrottledRequestMaxTimes: a, retryNetworkErrorMaxTimes: l }); 1654} 1655function ut(i, { publicKey: e, baseURL: t, source: s, integration: r, userAgent: n, retryThrottledRequestMaxTimes: o, retryNetworkErrorMaxTimes: a, signal: l, onProgress: c }) { 1656 return rs({ 1657 check: (d) => En(i, {
1658 publicKey: e, 1659 baseURL: t, 1660 signal: d, 1661 source: s, 1662 integration: r, 1663 userAgent: n, 1664 retryThrottledRequestMaxTimes: o, 1665 retryNetworkErrorMaxTimes: a 1666 }).then((u) => u.isReady ? (c && c({ isComputable: !0, value: 1 }), u) : !1), 1667 signal: l 1668 }); 1669} 1670const $n = (i, e) => { 1671 const t = new URL(e); 1672 return t.hostname = `${i}.${t.hostname}`, t.toString().replace(/\/$/, ""); 1673}, kn = (i) => i.toString(36).slice(0, 10), In = (i, e) => { 1674 try { 1675 const t = new URL(i).hostname, s = new URL(e).hostname; 1676 return t === s || t.endsWith(`.${s}`); 1677 } catch { 1678 return !1; 1679 } 1680}, On = (i) => { 1681 const e = new DataView(i); 1682 let t = 0n; 1683 for (let s = 0; s < i.byteLength; s += 8) 1684 t = t << 64n | e.getBigUint64(s); 1685 return t; 1686}, Ln = async (i) => On( 1687 await globalThis.crypto.subtle.digest( 1688 "SHA-256", 1689 new TextEncoder().encode(i) 1690 ) 1691), Un = async (i) => kn(await Ln(i)), Pn = async (i, e) => { 1692 const t = await Un(i); 1693 return $n(t, e); 1694}, Mn = (i, e) => Pn(i, e), us = ({ publicKey: i, baseCDN: e, prefixedBaseCDN: t = w.prefixedBaseCDN }) => i ? e === void 0 || In(e, t) ? Mn(i, t) : Promise.resolve(e) : Promise.resolve(e ?? w.baseCDN); 1695function Rn(i) { 1696 return "defaultEffects" in i; 1697} 1698class Ht { 1699 uuid; 1700 name; 1701 size; 1702 isStored; 1703 isImage; 1704 mimeType; 1705 cdnUrl; 1706 s3Url; 1707 originalFilename; 1708 imageInfo; 1709 videoInfo; 1710 contentInfo; 1711 metadata; 1712 tags; 1713 s3Bucket; 1714 defaultEffects = null; 1715 constructor(e, { baseCDN: t = w.baseCDN, fileName: s } = {}) { 1716 const { uuid: r, s3Bucket: n } = e, o = ie(t, `${r}/`), a = n ? ie(`https://${n}.s3.amazonaws.com/`, `${r}/${e.filename}`) : null; 1717 this.uuid = r, this.name = s || e.filename, this.size = e.size, this.isStored = e.isStored, this.isImage = e.isImage, this.mimeType = e.mimeType, this.cdnUrl = o, this.originalFilename = e.originalFilename, this.imageInfo = e.imageInfo, this.videoInfo = e.videoInfo, this.contentInfo = e.contentInfo, this.metadata = e.metadata || null, this.tags = e.tags || null, this.s3Bucket = n || null, this.s3Url = a, Rn(e) && (this.defaultEffects = e.defaultEffects); 1718 } 1719} 1720const dt = async (i, { publicKey: e, baseCDN: t, prefixedBaseCDN: s, fileName: r }) => { 1721 const n = await us({ 1722 publicKey: e, 1723 baseCDN: t, 1724 prefixedBaseCDN: s 1725 }); 1726 return new Ht(i, { baseCDN: n, fileName: r }); 1727}, Dn = (i, { publicKey: e, fileName: t, baseURL: s, secureSignature: r, secureExpire: n, store: o, contentType: a, signal: l, onProgress: c, source: d, integration: u, userAgent: h, retryThrottledRequestMaxTimes: f, retryNetworkErrorMaxTimes: p, baseCDN: m, prefixedBaseCDN: b, metadata: C, tags: E }) => yn(i, { 1728 publicKey: e, 1729 fileName: t, 1730 contentType: a, 1731 baseURL: s, 1732 secureSignature: r, 1733 secureExpire: n, 1734 store: o, 1735 signal: l, 1736 onProgress: c, 1737 source: d, 1738 integration: u, 1739 userAgent: h, 1740 retryThrottledRequestMaxTimes: f, 1741 retryNetworkErrorMaxTimes: p, 1742 metadata: C, 1743 tags: E 1744}).then(({ file: T }) => ut(T, { 1745 publicKey: e, 1746 baseURL: s, 1747 source: d, 1748 integration: u, 1749 userAgent: h, 1750 retryThrottledRequestMaxTimes: f, 1751 retryNetworkErrorMaxTimes: p, 1752 onProgress: c, 1753 signal: l 1754})).then((T) => dt(T, { publicKey: e, baseCDN: m, prefixedBaseCDN: b })), Fn = (i, { publicKey: e, fileName: t, baseURL: s, signal: r, onProgress: n, source: o, integration: a, userAgent: l, retryThrottledRequestMaxTimes: c, retryNetworkErrorMaxTimes: d, baseCDN: u, prefixedBaseCDN: h }) => ut(i, { 1755 publicKey: e, 1756 baseURL: s, 1757 signal: r, 1758 onProgress: n, 1759 source: o, 1760 integration: a, 1761 userAgent: l, 1762 retryThrottledRequestMaxTimes: c, 1763 retryNetworkErrorMaxTimes: d 1764}).then((f) => dt(f, { 1765 publicKey: e, 1766 baseCDN: u, 1767 prefixedBaseCDN: h, 1768 fileName: t 1769})), Vn = (i, { signal: e } = {}) => { 1770 let t = null, s = null; 1771 const r = i.map(() => new AbortController()), n = (o) => () => { 1772 s = o, r.forEach((a, l) => l !== o && a.abort()); 1773 }; 1774 return Nt(e, () => { 1775 r.forEach((o) => o.abort()); 1776 }), Promise.all(i.map((o, a) => { 1777 const l = n(a); 1778 return Promise.resolve().then(() => o({ stopRace: l, signal: r[a].signal })).then((c) => (l(), c)).catch((c) => (t = c, null)); 1779 })).then((o) => { 1780 if (s === null) 1781 throw t; 1782 return o[s]; 1783 }); 1784}; 1785var Nn = window.WebSocket; 1786class zn { 1787 events = /* @__PURE__ */ Object.create({});
1788 emit(e, t) { 1789 this.events[e]?.forEach((s) => s(t)); 1790 } 1791 on(e, t) { 1792 this.events[e] = this.events[e] || [], this.events[e].push(t); 1793 } 1794 off(e, t) { 1795 t ? this.events[e] = this.events[e].filter((s) => s !== t) : this.events[e] = []; 1796 } 1797} 1798const Bn = (i, e) => i === "success" ? { status: D.Success, ...e } : i === "progress" ? { status: D.Progress, ...e } : { status: D.Error, ...e }; 1799class Hn { 1800 key; 1801 disconnectTime; 1802 ws = void 0; 1803 queue = []; 1804 isConnected = !1; 1805 subscribers = 0; 1806 emmitter = new zn(); 1807 disconnectTimeoutId = null; 1808 constructor(e, t = 3e4) { 1809 this.key = e, this.disconnectTime = t; 1810 } 1811 connect() { 1812 if (this.disconnectTimeoutId && clearTimeout(this.disconnectTimeoutId), !this.isConnected && !this.ws) { 1813 const e = `wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`; 1814 this.ws = new Nn(e), this.ws.addEventListener("error", (t) => { 1815 this.emmitter.emit("error", new Error(t.message)); 1816 }), this.emmitter.on("connected", () => { 1817 this.isConnected = !0, this.queue.forEach((t) => this.send(t.event, t.data)), this.queue = []; 1818 }), this.ws.addEventListener("message", (t) => { 1819 const s = JSON.parse(t.data.toString()); 1820 switch (s.event) { 1821 case "pusher:connection_established": { 1822 this.emmitter.emit("connected", void 0); 1823 break; 1824 } 1825 case "pusher:ping": { 1826 this.send("pusher:pong", {}); 1827 break; 1828 } 1829 case "progress": 1830 case "success": 1831 case "fail": 1832 this.emmitter.emit(s.channel, Bn(s.event, JSON.parse(s.data))); 1833 } 1834 }); 1835 } 1836 } 1837 disconnect() { 1838 const e = () => { 1839 this.ws?.close(), this.ws = void 0, this.isConnected = !1; 1840 }; 1841 this.disconnectTime ? this.disconnectTimeoutId = setTimeout(() => { 1842 e(); 1843 }, this.disconnectTime) : e(); 1844 } 1845 send(e, t) { 1846 const s = JSON.stringify({ event: e, data: t }); 1847 this.ws?.send(s); 1848 } 1849 subscribe(e, t) { 1850 this.subscribers += 1, this.connect(); 1851 const s = `task-status-${e}`, r = { 1852 event: "pusher:subscribe", 1853 data: { channel: s } 1854 }; 1855 this.emmitter.on(s, t), this.isConnected ? this.send(r.event, r.data) : this.queue.push(r); 1856 } 1857 unsubscribe(e) { 1858 this.subscribers -= 1; 1859 const t = `task-status-${e}`, s = { 1860 event: "pusher:unsubscribe", 1861 data: { channel: t } 1862 }; 1863 this.emmitter.off(t), this.isConnected ? this.send(s.event, s.data) : this.queue = this.queue.filter((r) => r.data.channel !== t), this.subscribers === 0 && this.disconnect(); 1864 } 1865 onError(e) { 1866 return this.emmitter.on("error", e), () => this.emmitter.off("error", e); 1867 } 1868} 1869let vt = null; 1870const jt = (i) => { 1871 if (!vt) { 1872 const e = typeof window > "u" ? 0 : 3e4; 1873 vt = new Hn(i, e); 1874 } 1875 return vt; 1876}, jn = (i) => { 1877 jt(i).connect(); 1878}; 1879function Gn({ token: i, publicKey: e, baseURL: t, integration: s, userAgent: r, retryThrottledRequestMaxTimes: n, retryNetworkErrorMaxTimes: o, onProgress: a, signal: l }) { 1880 return rs({ 1881 check: (c) => Cn(i, { 1882 publicKey: e, 1883 baseURL: t, 1884 integration: s, 1885 userAgent: r, 1886 retryThrottledRequestMaxTimes: n, 1887 retryNetworkErrorMaxTimes: o, 1888 signal: c 1889 }).then((d) => { 1890 switch (d.status) { 1891 case D.Error: 1892 return new F(d.error, d.errorCode); 1893 case D.Waiting: 1894 return !1; 1895 case D.Unknown: 1896 return new F(`Token "${i}" was not found.`); 1897 case D.Progress: 1898 return a && (d.total === "unknown" ? a({ isComputable: !1 }) : a({ 1899 isComputable: !0, 1900 value: d.done / d.total 1901 })), !1; 1902 case D.Success: 1903 return a && a({ 1904 isComputable: !0, 1905 value: d.done / d.total 1906 }), d; 1907 default: 1908 throw new Error("Unknown status"); 1909 } 1910 }), 1911 signal: l 1912 }); 1913} 1914const Wn = ({ token: i, pusherKey: e, signal: t, onProgress: s }) => new Promise((r, n) => { 1915 const o = jt(e), a = o.onError(n), l = () => { 1916 a(), o.unsubscribe(i); 1917 }; 1918 Nt(t, () => { 1919 l(), n(new te("pusher cancelled")); 1920 }), o.subscribe(i, (c) => { 1921 switch (c.status) { 1922 case D.Progress: { 1923 s && (c.total === "unknown" ? s({ isComputable: !1 }) : s({ 1924 isComputable: !0, 1925 value: c.done / c.total 1926 })); 1927 break; 1928 } 1929 case D.Success: { 1930 l(), s && s({ 1931 isComputable: !0, 1932 value: c.done / c.total 1933 }), r(c); 1934 break; 1935 } 1936 case D.Error: 1937 l(), n(new F(c.msg, c.error_code)); 1938 } 1939 }); 1940}), qn = (i, { publicKey: e, fileName: t, baseURL: s, baseCDN: r, prefixedBaseCDN: n, checkForUrlDuplicates: o, saveUrlForRecurrentUploads: a, secureSignature: l, secureExpire: c, store: d, signal: u, onProgress: h, source: f, integration: p, userAgent: m, retryThrottledRequestMaxTimes: b, pusherKey: C = w.pusherKey, metadata: E, tags: T }) => Promise.resolve(jn(C)).then(() => vn(i, { 1941 publicKey: e, 1942 fileName: t, 1943 baseURL: s, 1944 checkForUrlDuplicates: o, 1945 saveUrlForRecurrentUploads: a, 1946 secureSignature: l, 1947 secureExpire: c, 1948 store: d, 1949 signal: u, 1950 source: f, 1951 integration: p, 1952 userAgent: m, 1953 retryThrottledRequestMaxTimes: b, 1954 metadata: E, 1955 tags: T 1956})).catch((g) => (jt(C)?.disconnect(), Promise.reject(g))).then((g) => g.type === It.FileInfo ? g : Vn([ 1957 ({ signal: M }) => Gn({ 1958 token: g.token, 1959 publicKey: e, 1960 baseURL: s, 1961 integration: p, 1962 userAgent: m, 1963 retryThrottledRequestMaxTimes: b, 1964 onProgress: h, 1965 signal: M 1966 }), 1967 ({ signal: M }) => Wn({ 1968 token: g.token, 1969 pusherKey: C, 1970 signal: M, 1971 onProgress: h 1972 }) 1973], { signal: u })).then((g) => { 1974 if (g instanceof F) 1975 throw g; 1976 return g; 1977}).then((g) => g.isReady ? g : ut(g.uuid, { 1978 publicKey: e, 1979 baseURL: s, 1980 integration: p, 1981 userAgent: m, 1982 retryThrottledRequestMaxTimes: b, 1983 onProgress: h, 1984 signal: u 1985})).then((g) => dt(g, { publicKey: e, baseCDN: r, prefixedBaseCDN: n })), wt = /* @__PURE__ */ new WeakMap(), Xn = async (i) => { 1986 if (wt.has(i)) 1987 return wt.get(i); 1988 const e = await fetch(i.uri).then((t) => t.blob()); 1989 return wt.set(i, e), e; 1990}, ds = async (i) => { 1991 if (at(i) || ot(i)) 1992 return i.size; 1993 if (lt(i)) 1994 return (await Xn(i)).size; 1995 throw new Error("Unknown file type. Cannot determine file size."); 1996}, Zn = (i, e = w.multipartMinFileSize) => i >= e, hs = (i) => { 1997 const e = "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}", t = new RegExp(e); 1998 return !Ie(i) && t.test(i); 1999}, Gt = (i) => { 2000 const e = "^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}
2000|localhost[\\:?\\d]*)\\S*$", t = new RegExp(e); 2001 return !Ie(i) && t.test(i); 2002}, Kn = (i, e) => new Promise((t, s) => { 2003 const r = []; 2004 let n = !1, o = e.length; 2005 const a = [...e], l = () => { 2006 const c = e.length - a.length, d = a.shift(); 2007 d && d().then((u) => { 2008 n || (r[c] = u, o -= 1, o ? l() : t(r)); 2009 }).catch((u) => { 2010 n = !0, s(u); 2011 }); 2012 }; 2013 for (let c = 0; c < i; c++) 2014 l(); 2015}), Yn = (i, e, t, s) => { 2016 const r = s * e, n = Math.min(r + s, t); 2017 return i.slice(r, n); 2018}, Jn = async (i, e, t) => (s) => Yn(i, s, e, t), Qn = (i, e, { publicKey: t, contentType: s, onProgress: r, signal: n, integration: o, retryThrottledRequestMaxTimes: a, retryNetworkErrorMaxTimes: l }) => xn(i, e, { 2019 contentType: s, 2020 onProgress: r, 2021 signal: n, 2022 retryThrottledRequestMaxTimes: a, 2023 retryNetworkErrorMaxTimes: l 2024}), eo = async (i, { publicKey: e, fileName: t, fileSize: s, baseURL: r, secureSignature: n, secureExpire: o, store: a, signal: l, onProgress: c, source: d, integration: u, userAgent: h, retryThrottledRequestMaxTimes: f, retryNetworkErrorMaxTimes: p, contentType: m, multipartChunkSize: b = w.multipartChunkSize, maxConcurrentRequests: C = w.maxConcurrentRequests, baseCDN: E, prefixedBaseCDN: T, metadata: g, tags: M }) => { 2025 const he = s ?? await ds(i); 2026 let Z; 2027 const fe = (S, V) => { 2028 if (!c) 2029 return; 2030 Z || (Z = Array(S).fill(0)); 2031 const pe = (W) => W.reduce((ve, yt) => ve + yt, 0); 2032 return (W) => { 2033 W.isComputable && (Z[V] = W.value, c({ 2034 isComputable: !0, 2035 value: pe(Z) / S 2036 })); 2037 }; 2038 }; 2039 return m ||= ls(i), Tn(he, { 2040 publicKey: e, 2041 contentType: m, 2042 fileName: t || cs(i), 2043 baseURL: r, 2044 secureSignature: n, 2045 secureExpire: o, 2046 store: a, 2047 signal: l, 2048 source: d, 2049 integration: u, 2050 userAgent: h, 2051 retryThrottledRequestMaxTimes: f, 2052 retryNetworkErrorMaxTimes: p, 2053 metadata: g, 2054 tags: M, 2055 multipartChunkSize: b 2056 }).then(async ({ uuid: S, parts: V }) => { 2057 const pe = await Jn(i, he, b); 2058 return Promise.all([ 2059 S, 2060 Kn(C, V.map((W, ve) => () => Qn(pe(ve), W, { 2061 publicKey: e, 2062 contentType: m, 2063 onProgress: fe(V.length, ve), 2064 signal: l, 2065 integration: u, 2066 retryThrottledRequestMaxTimes: f, 2067 retryNetworkErrorMaxTimes: p 2068 }))) 2069 ]); 2070 }).then(([S]) => Sn(S, { 2071 publicKey: e, 2072 baseURL: r, 2073 source: d, 2074 integration: u, 2075 userAgent: h, 2076 retryThrottledRequestMaxTimes: f, 2077 retryNetworkErrorMaxTimes: p 2078 })).then((S) => S.isReady ? S : ut(S.uuid, { 2079 publicKey: e, 2080 baseURL: r, 2081 source: d, 2082 integration: u, 2083 userAgent: h, 2084 retryThrottledRequestMaxTimes: f, 2085 retryNetworkErrorMaxTimes: p, 2086 onProgress: c, 2087 signal: l 2088 })).then((S) => dt(S, { publicKey: e, baseCDN: E, prefixedBaseCDN: T })); 2089}; 2090async function fs(i, { 2091 publicKey: e, 2092 fileName: t, 2093 baseURL: s = w.baseURL, 2094 secureSignature: r, 2095 secureExpire: n, 2096 store: o, 2097 signal: a, 2098 onProgress: l, 2099 source: c, 2100 integration: d, 2101 userAgent: u, 2102 retryThrottledRequestMaxTimes: h, 2103 retryNetworkErrorMaxTimes: f, 2104 contentType: p, 2105 multipartMinFileSize: m, 2106 multipartChunkSize: b, 2107 maxConcurrentRequests: C, 2108 // Left undefined on purpose when the caller omits it, so `resolveCdnBase` 2109 // can distinguish "not set" (→ prefixed default) from an explicit base 2110 // (→ used verbatim, e.g. the legacy `https://ucarecdn.com`). 2111 baseCDN: E, 2112 prefixedBaseCDN: T = w.prefixedBaseCDN, 2113 checkForUrlDuplicates: g, 2114 saveUrlForRecurrentUploads: M, 2115 pusherKey: he, 2116 metadata: Z, 2117 tags: fe 2118}) { 2119 if (Ie(i)) { 2120 const S = await ds(i); 2121 return Zn(S, m) ? eo(i, { 2122 publicKey: e, 2123 contentType: p, 2124 multipartChunkSize: b, 2125 fileSize: S, 2126 fileName: t, 2127 baseURL: s, 2128 secureSignature: r, 2129 secureExpire: n, 2130 store: o, 2131 signal: a, 2132 onProgress: l, 2133 source: c, 2134 integration: d, 2135 userAgent: u, 2136 maxConcurrentRequests: C, 2137 retryThrottledRequestMaxTimes: h, 2138 retryNetworkErrorMaxTimes: f, 2139 baseCDN: E, 2140 prefixedBaseCDN: T, 2141 metadata: Z, 2142 tags: fe 2143 }) : Dn(i, { 2144 publicKey: e, 2145 fileName: t, 2146 contentType: p, 2147 baseURL: s, 2148 secureSignature: r, 2149 secureExpire: n, 2150 store: o, 2151 signal: a, 2152 onProgress: l, 2153 source: c, 2154 integration: d, 2155 userAgent: u, 2156 retryThrottledRequestMaxTimes: h, 2157 retryNetworkErrorMaxTimes: f, 2158 baseCDN: E, 2159 prefixedBaseCDN: T, 2160 metadata: Z, 2161 tags: fe 2162 }); 2163 } 2164 if (Gt(i)) 2165 return qn(i, { 2166 publicKey: e, 2167 fileName: t, 2168 baseURL: s, 2169 baseCDN: E, 2170 prefixedBaseCDN: T, 2171 checkForUrlDuplicates: g, 2172 saveUrlForRecurrentUploads: M, 2173 secureSignature: r, 2174 secureExpire: n, 2175 store: o, 2176 signal: a, 2177 onProgress: l, 2178 source: c, 2179 integration: d, 2180 userAgent: u, 2181 retryThrottledRequestMaxTimes: h, 2182 pusherKey: he, 2183 metadata: Z, 2184 tags: fe 2185 }); 2186 if (hs(i)) 2187 return Fn(i, { 2188 publicKey: e, 2189 fileName: t, 2190 baseURL: s, 2191 signal: a, 2192 onProgress: l, 2193 source: c, 2194 integration: d, 2195 userAgent: u, 2196 retryThrottledRequestMaxTimes: h, 2197 retryNetworkErrorMaxTimes: f, 2198 baseCDN: E, 2199 prefixedBaseCDN: T 2200 }); 2201 throw new TypeError(`File uploading from "${i}" is not supported`); 2202} 2203const to = (i, e) => { 2204 try { 2205 const t = new URL(i), s = new URL(e); 2206 return t.protocol = s.protocol, t.hostname = s.hostname, t.port = s.port, t.toString(); 2207 } catch { 2208 return i; 2209 } 2210}; 2211class io { 2212 uuid; 2213 filesCount; 2214 totalSize; 2215 isStored; 2216 isImage; 2217 cdnUrl; 2218 files; 2219 createdAt; 2220 storedAt = null; 2221 constructor(e, { baseCDN: t = w.baseCDN } = {}) { 2222 this.uuid = e.id, this.filesCount = e.filesCount;
2223 const s = e.files.filter(Boolean); 2224 this.totalSize = Object.values(s).reduce((r, n) => r + n.size, 0), this.isStored = !!e.datetimeStored, this.isImage = !!Object.values(s).filter((r) => r.isImage).length, this.cdnUrl = to(e.cdnUrl, t), this.files = s.map((r) => new Ht(r, { baseCDN: t })), this.createdAt = e.datetimeCreated, this.storedAt = e.datetimeStored; 2225 } 2226} 2227const so = async (i, { publicKey: e, baseCDN: t, prefixedBaseCDN: s }) => { 2228 const r = await us({ 2229 publicKey: e, 2230 baseCDN: t, 2231 prefixedBaseCDN: s 2232 }); 2233 return new io(i, { baseCDN: r }); 2234}, ro = (i) => { 2235 for (const e of i) 2236 if (!Ie(e)) 2237 return !1; 2238 return !0; 2239}, no = (i) => { 2240 for (const e of i) 2241 if (!hs(e)) 2242 return !1; 2243 return !0; 2244}, oo = (i) => { 2245 for (const e of i) 2246 if (!Gt(e)) 2247 return !1; 2248 return !0; 2249}; 2250function ao(i, { 2251 publicKey: e, 2252 fileName: t, 2253 baseURL: s = w.baseURL, 2254 secureSignature: r, 2255 secureExpire: n, 2256 store: o, 2257 signal: a, 2258 onProgress: l, 2259 source: c, 2260 integration: d, 2261 userAgent: u, 2262 retryThrottledRequestMaxTimes: h, 2263 retryNetworkErrorMaxTimes: f, 2264 contentType: p, 2265 multipartChunkSize: m = w.multipartChunkSize, 2266 // Left undefined on purpose when the caller omits it, so `resolveCdnBase` 2267 // can distinguish "not set" (→ prefixed default) from an explicit base 2268 // (→ used verbatim, e.g. the legacy `https://ucarecdn.com`). 2269 baseCDN: b, 2270 prefixedBaseCDN: C = w.prefixedBaseCDN, 2271 checkForUrlDuplicates: E, 2272 saveUrlForRecurrentUploads: T, 2273 jsonpCallback: g 2274}) { 2275 if (!ro(i) && !oo(i) && !no(i)) 2276 throw new TypeError(`Group uploading from "${i}" is not supported`); 2277 let M, he = !0; 2278 const Z = i.length, fe = (S, V) => { 2279 if (!l) 2280 return; 2281 M || (M = Array(S).fill(0)); 2282 const pe = (W) => W.reduce((ve, yt) => ve + yt) / S; 2283 return (W) => { 2284 if (!W.isComputable || !he) { 2285 he = !1, l({ isComputable: !1 }); 2286 return; 2287 } 2288 M[V] = W.value, l({ isComputable: !0, value: pe(M) }); 2289 }; 2290 }; 2291 return Promise.all(i.map((S, V) => Ie(S) || Gt(S) ? fs(S, { 2292 publicKey: e, 2293 fileName: t, 2294 baseURL: s, 2295 secureSignature: r, 2296 secureExpire: n, 2297 store: o, 2298 signal: a, 2299 onProgress: fe(Z, V), 2300 source: c, 2301 integration: d, 2302 userAgent: u, 2303 retryThrottledRequestMaxTimes: h, 2304 retryNetworkErrorMaxTimes: f, 2305 contentType: p, 2306 multipartChunkSize: m, 2307 baseCDN: b, 2308 prefixedBaseCDN: C, 2309 checkForUrlDuplicates: E, 2310 saveUrlForRecurrentUploads: T 2311 }).then((pe) => pe.uuid) : S)).then((S) => An(S, {
2312 publicKey: e, 2313 baseURL: s, 2314 jsonpCallback: g, 2315 secureSignature: r, 2316 secureExpire: n, 2317 signal: a, 2318 source: c, 2319 integration: d, 2320 userAgent: u, 2321 retryThrottledRequestMaxTimes: h, 2322 retryNetworkErrorMaxTimes: f 2323 }).then((V) => so(V, { publicKey: e, baseCDN: b, prefixedBaseCDN: C })).then((V) => (l && l({ isComputable: !0, value: 1 }), V))); 2324} 2325class lo { 2326 _concurrency = 1; 2327 _pending = []; 2328 _running = 0; 2329 _resolvers = /* @__PURE__ */ new Map(); 2330 _rejectors = /* @__PURE__ */ new Map(); 2331 constructor(e) { 2332 this._concurrency = e; 2333 } 2334 /** Run tasks from the queue up to the concurrency limit */ 2335 run() { 2336 const e = this._concurrency - this._running; 2337 for (let t = 0; t < e; t++) { 2338 const s = this._pending.shift(); 2339 if (!s) 2340 return; 2341 const r = this._resolvers.get(s), n = this._rejectors.get(s); 2342 if (!r || !n) 2343 throw new Error("Unexpected behavior: resolver or rejector is undefined"); 2344 this._running += 1, s().finally(() => { 2345 this._resolvers.delete(s), this._rejectors.delete(s), this._running -= 1, this.run(); 2346 }).then((o) => r(o)).catch((o) => n(o)); 2347 } 2348 } 2349 /** 2350 * Add a task to the queue 2351 * 2352 * If you want to add a lot of tasks at once, consider setting `autoRun` to 2353 * false and calling `run()` manually after adding all tasks to avoid multiple 2354 * redundant calls to `run()`. 2355 * 2356 * @param task The task to add 2357 * @param autoRun Whether to automatically run the queue after adding the task 2358 * (default: true) 2359 * @returns A promise that resolves or rejects with the task's result 2360 */ 2361 add(e, { autoRun: t } = { autoRun: !0 }) { 2362 return new Promise((s, r) => { 2363 this._resolvers.set(e, s), this._rejectors.set(e, r), this._pending.push(e), t && this.run(); 2364 }); 2365 } 2366 get pending() { 2367 return this._pending.length; 2368 } 2369 get running() { 2370 return this._running; 2371 } 2372 set concurrency(e) { 2373 this._concurrency = e, this.run(); 2374 } 2375 get concurrency() { 2376 return this._concurrency; 2377 } 2378} 2379const ps = () => ({}), ms = (i) => ({ 2380 ...ps(), 2381 "*currentActivity": null, 2382 "*currentActivityParams": {}, 2383 "*history": [], 2384 "*historyBack": null, 2385 "*closeModal": () => { 2386 i.set$({ 2387 "*currentActivity": null, 2388 "*modalActive": !1 2389 }); 2390 } 2391}), gs = (i) => ({ 2392 ...ms(i), 2393 "*commonProgress": 0, 2394 "*uploadList": [], 2395 "*uploadQueue": new lo(1), 2396 /** @type {ReturnType<import('../types').OutputErrorCollection>[]} */ 2397 "*collectionErrors": [], 2398 /** @type {import('../types').OutputCollectionState | null} */ 2399 "*collectionState": null, 2400 /** @type {import('@uploadcare/upload-client').UploadcareGroup | null} */ 2401 "*groupInfo": null, 2402 /** @type {Set<string>} */ 2403 "*uploadTrigger": /* @__PURE__ */ new Set(), 2404 /** @type {import('./SecureUploadsManager.js').SecureUploadsManager | null} */ 2405 "*secureUploadsManager": null 2406}), Wt = { 2407 "locale-id": "en", 2408 "social-source-lang": "en", 2409 "upload-file": "Upload file", 2410 "upload-files": "Upload files", 2411 "choose-file": "Choose file", 2412 "choose-files": "Choose files", 2413 "drop-files-here": "Drop files here", 2414 "select-file-source": "Select file source", 2415 selected: "Selected", 2416 upload: "Upload", 2417 "add-more": "Add more", 2418 cancel: "Cancel", 2419 "start-from-cancel": "Cancel", 2420 clear: "Clear", 2421 "camera-shot": "Shot", 2422 "upload-url": "Import", 2423 "upload-url-placeholder": "Paste link here", 2424 "edit-image": "Edit image", 2425 "edit-detail": "Details", 2426 back: "Back", 2427 done: "Done", 2428 ok: "Ok", 2429 "remove-from-list": "Remove", 2430 no: "No", 2431 yes: "Yes", 2432 "confirm-your-action": "Confirm your action", 2433 "are-you-sure": "Are you sure?", 2434 "selected-count": "{{count}} of {{total}} selected", 2435 "select-all": "Select all", 2436 "deselect-all": "Deselect all", 2437 "upload-error": "Upload error", 2438 "validation-error": "Validation error", 2439 "no-files": "No files selected", 2440 browse: "Browse", 2441 "not-uploaded-yet": "Not uploaded yet...", 2442 file__one: "file", 2443 file__other: "files", 2444 error__one: "error", 2445 error__other: "errors", 2446 "header-uploading": "Uploading {{count}} {{plural:file(count)}}", 2447 "header-failed": "{{count}} {{plural:error(count)}}", 2448 "header-succeed": "{{count}} {{plural:file(count)}} uploaded", 2449 "header-total": "{{count}} {{plural:file(count)}} selected", 2450 "src-type-local": "From device", 2451 "src-type-from-url": "From link", 2452 "src-type-camera": "Camera", 2453 "src-type-draw": "Draw", 2454 "src-type-facebook": "Facebook", 2455 "src-type-dropbox": "Dropbox", 2456 "src-type-gdrive": "Google Drive", 2457 "src-type-gphotos": "Google Photos", 2458 "src-type-flickr": "Flickr", 2459 "src-type-vk": "VK", 2460 "src-type-evernote": "Evernote", 2461 "src-type-box": "Box", 2462 "src-type-onedrive": "Onedrive", 2463 "src-type-huddle": "Huddle", 2464 "src-type-other": "Other", 2465 "caption-from-url": "Import from link", 2466 "caption-camera": "Camera", 2467 "caption-draw": "Draw", 2468 "caption-edit-file": "Edit file", 2469 "file-no-name": "No name...", 2470 "toggle-fullscreen": "Toggle fullscreen", 2471 "toggle-guides": "Toggle guides", 2472 rotate: "Rotate",
2473 "flip-vertical": "Flip vertical", 2474 "flip-horizontal": "Flip horizontal", 2475 apply: "Apply", 2476 brightness: "Brightness", 2477 contrast: "Contrast", 2478 saturation: "Saturation", 2479 exposure: "Exposure", 2480 gamma: "Gamma", 2481 vibrance: "Vibrance", 2482 warmth: "Warmth", 2483 enhance: "Enhance", 2484 original: "Original", 2485 resize: "Resize image", 2486 crop: "Crop", 2487 "select-color": "Select color", 2488 text: "Text", 2489 draw: "Draw", 2490 "cancel-edit": "Cancel edit", 2491 "tab-view": "Preview", 2492 "tab-details": "Details", 2493 "file-name": "Name", 2494 "file-size": "Size", 2495 "cdn-url": "CDN URL", 2496 "file-size-unknown": "Unknown", 2497 "camera-permissions-denied": "Camera access denied", 2498 "camera-permissions-prompt": "Please allow access to the camera", 2499 "camera-permissions-request": "Request access", 2500 "files-count-limit-error-title": "Files count limit overflow", 2501 "files-count-limit-error-too-few": "You’ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.", 2502 "files-count-limit-error-too-many": "You’ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.", 2503 "files-max-size-limit-error": "File is too big. Max file size is {{maxFileSize}}.", 2504 "has-validation-errors": "File validation error ocurred. Please, check your files before upload.", 2505 "images-only-accepted": "Only image files are accepted.", 2506 "file-type-not-allowed": "Uploading of these file types is not allowed.", 2507 "some-files-were-not-uploaded": "Some files were not uploaded.", 2508 "file-item-edit-button": "Edit", 2509 "file-item-remove-button": "Remove", 2510 "a11y-editor-tab-filters": "Filters", 2511 "a11y-editor-tab-tuning": "Tuning", 2512 "a11y-editor-tab-crop": "Crop", 2513 "a11y-activity-header-button-close": "Close", 2514 flip: "Flip", 2515 mirror: "Mirror", 2516 "a11y-cloud-editor-apply-filter": "Apply {{name}} filter", 2517 "a11y-cloud-editor-apply-crop": "Apply {{name}} operation", 2518 "a11y-cloud-editor-apply-tuning": "Apply {{name}} tuning", 2519 finished: "Finished", 2520 failed: "Failed", 2521 uploading: "Uploading", 2522 idle: "Idle", 2523 "a11y-file-item-status": "File {{fileName}} in status {{status}}" 2524}, et = /* @__PURE__ */ new Map(), Ot = /* @__PURE__ */ new Map(), bs = (i, e) => { 2525 et.has(i) && console.log(`Locale ${i} is already defined. Overwriting...`), et.set(i, { ...Wt, ...e }); 2526}, co = (i, e) => { 2527 Ot.set(i, e); 2528}, _s = (i, e) => { 2529 typeof e == "function" ? co(i, e) : bs(i, e); 2530}, uo = async (i) => { 2531 if (!et.has(i)) { 2532 if (!Ot.has(i)) 2533 throw new Error(`Locale ${i} is not defined`); 2534 const t = await /** @type {LocaleDefinitionResolver} */ 2535 Ot.get(i)(); 2536 bs(i, t); 2537 } 2538 return ( 2539 /** @type {LocaleDefinition} */ 2540 et.get(i) 2541 ); 2542}; 2543_s("en", Wt); 2544const be = (i) => `*l10n/${i}`, ho = "en"; 2545class fo { 2546 /** 2547 * @private 2548 * @type {import('./Block.js').Block | null} 2549 */ 2550 _blockInstance = null; 2551 /** @private */ 2552 _localeName = ""; 2553 /** 2554 * @private 2555 * @type {Set<() => void>} 2556 */ 2557 _callbacks = /* @__PURE__ */ new Set(); 2558 /** 2559 * @private 2560 * @type {Map<import('./Block.js').Block, Map<string, () => void>>} 2561 */ 2562 _boundBlocks = /* @__PURE__ */ new Map(); 2563 /** @param {import('./Block.js').Block} blockInstance */ 2564 constructor(e) { 2565 this._blockInstance = e; 2566 for (let [t, s] of Object.entries(Wt)) 2567 this._blockInstance.add(be(t), s, !1); 2568 setTimeout(() => { 2569 e.subConfigValue("localeName", async (t) => { 2570 if (!this._blockInstance || !t) 2571 return; 2572 this._localeName = t; 2573 const s = await uo(t); 2574 if (t !== ho && this._localeName !== t) 2575 return; 2576 const r = this._blockInstance.cfg.localeDefinitionOverride?.[t]; 2577 for (const [n, o] of Object.entries(s)) { 2578 const a = r?.[n]; 2579 this._blockInstance.add(be(n), a ?? o, !0); 2580 for (const l of this._callbacks) 2581 l(); 2582 } 2583 }), e.subConfigValue("localeDefinitionOverride", (t) => { 2584 if (!t) 2585 return; 2586 const s = t[this._localeName]; 2587 if (s) 2588 for (const [r, n] of Object.entries(s)) { 2589 this._blockInstance?.add(be(r), n, !0); 2590 for (const o of this._callbacks) 2591 o(); 2592 } 2593 }); 2594 }); 2595 } 2596 /** 2597 * @param {() => void} callback 2598 * @returns {() => void} 2599 */ 2600 onLocaleChange(e) { 2601 const t = G(e, 0); 2602 return this._callbacks.add(t), () => { 2603 this._callbacks.delete(t); 2604 }; 2605 } 2606 /** 2607 * @param {import('./Block.js').Block} block 2608 * @param {string} key 2609 * @param {() => void} resolver 2610 */ 2611 bindL10n(e, t, s) { 2612 e.$[t] = s(), this._boundBlocks.has(e) || this._boundBlocks.set(e, /* @__P
2612URE__ */ new Map()), this._boundBlocks.get(e)?.get(t)?.(); 2613 const r = this.onLocaleChange(() => { 2614 e.$[t] = s(); 2615 }); 2616 this._boundBlocks.get(e)?.set(t, r); 2617 } 2618 /** @param {import('./Block.js').Block} block */ 2619 destroyL10nBindings(e) { 2620 const t = this._boundBlocks.get(e); 2621 if (t) { 2622 for (const s of t.values()) 2623 s(); 2624 this._boundBlocks.delete(e); 2625 } 2626 } 2627 destroy() { 2628 this._callbacks.clear(); 2629 } 2630} 2631function po(i, e) { 2632 [...i.querySelectorAll("[l10n]")].forEach((t) => { 2633 let s = t.getAttribute("l10n"); 2634 if (!s) 2635 return; 2636 let r = "textContent", n = !1; 2637 if (s.includes(":")) { 2638 const l = s.split(":"); 2639 r = l[0], s = l[1], r.startsWith("@") && (r = r.slice(1), n = !0); 2640 } 2641 const o = s; 2642 e.has(o) && e.sub(o, (l) => { 2643 if (!l) 2644 return; 2645 e.l10nProcessorSubs.has(o) || e.l10nProcessorSubs.set(o, /* @__PURE__ */ new Set()); 2646 const c = e.l10nProcessorSubs.get(o); 2647 c?.forEach( 2648 /** @param {{ remove: () => void }} sub */ 2649 (h) => { 2650 h.remove(), c.delete(h), e.allSubs.delete(h); 2651 } 2652 ); 2653 const d = be(l).replace("*", ""); 2654 e.nodeCtx.has(d) || e.nodeCtx.add(d, l); 2655 const u = e.nodeCtx.sub(d, () => { 2656 t[ 2657 /** @type {'textContent'} */ 2658 r 2659 ] = e.l10n(l); 2660 }); 2661 c?.add(u), e.allSubs.add(u), t.removeAttribute("l10n"); 2662 }); 2663 const a = be(s); 2664 e.has(a) || e.add(a, ""), e.sub(a, () => { 2665 s = /** @type {string} */ 2666 s, n ? t.setAttribute(r, e.l10n(s)) : t[ 2667 /** @type {'textContent'} */ 2668 r 2669 ] = e.l10n(s); 2670 }), t.removeAttribute("l10n"); 2671 }); 2672} 2673const H = (i) => `*cfg/${i}`, mo = { 2674 button: ["toolbar"], 2675 checkbox: ["toolbar"], 2676 menuitem: ["menu", "menubar"], 2677 option: ["listbox"], 2678 tab: ["tablist"] 2679}; 2680function Oe(i, e) { 2681 e.tabIndex = 0, e.focus(), i.tabIndex = -1; 2682} 2683function Ct(i) { 2684 let e = i.role || i.type || i.tagName; 2685 if (!e) return null; 2686 let t = mo[e.toLowerCase()]; 2687 if (!t) return null; 2688 for (let s of t) { 2689 let r = i.closest(`[role=${s}]`); 2690 if (r) return r; 2691 } 2692} 2693function At(i, e) { 2694 return e.role === "toolbar" ? go(e) : e.querySelectorAll(`[role=${i.role}]`); 2695} 2696function go(i) { 2697 return [...i.querySelectorAll("*")].filter((t) => t.role === "button" || t.type === "button" || t.role === "checkbox" || t.type === "checkbox"); 2698} 2699function bo(i) { 2700 let e = i.getAttribute("aria-orientation"); 2701 if (e === "vertical") return !1; 2702 if (e === "horizontal") return !0; 2703 let t = i.role; 2704 return t === "menubar" || t === "tablist" || t === "toolbar"; 2705} 2706function _o(i) { 2707 return (e) => { 2708 let t = !1, s = 300, r = 0, n = ""; 2709 function o(u) { 2710 let h = Ct(u.target); 2711 if (!h) { 2712 a(); 2713 return; 2714 } 2715 let f = At(u.target, h), p = Array.from(f).indexOf(u.target), m = "ArrowDown", b = "ArrowUp"; 2716 if (bo(h) && (e.document.dir === "rtl" ? (m = "ArrowLeft", b = "ArrowRight") : (m = "ArrowRight", b = "ArrowLeft")), u.key === m) 2717 u.preventDefault(), Oe(u.target, f[p + 1] || f[0]); 2718 else if (u.key === b) 2719 u.preventDefault(), Oe(u.target, f[p - 1] || f[f.length - 1]); 2720 else if (u.key === "Home") 2721 u.preventDefault(), Oe(u.target, f[0]); 2722 else if (u.key === "End") 2723 u.preventDefault(), Oe(u.target, f[f.length - 1]); 2724 else if (u.key.length === 1 && h.role !== "tablist") { 2725 let C = Date.now(); 2726 C - r <= s ? n += u.key.toLowerCase() : n = u.key.toLowerCase(), r = C; 2727 let E = Array.from(f).find((T) => T.textContent?.trim()?.toLowerCase()?.startsWith(n)); 2728 E && (u.preventDefault(), Oe(u.target, E)); 2729 } 2730 } 2731 function a() { 2732 t = !1, e.removeEventListener("keydown", o); 2733 } 2734 function l(u) { 2735 let h = Ct(u.target); 2736 if (h) { 2737 t || (t = !0, e.addEventListener("keydown", o)); 2738 let f = At(u.target, h); 2739 for (let p of f) 2740 p !== u.target && p.setAttribute("tabindex", -1); 2741 } else t && a(); 2742 } 2743 function c(u) { 2744 (!u.relatedTarget || u.relatedTarget === e.document) && a(); 2745 } 2746 function d(u) {
2747 let h = Ct(u.target); 2748 if (h) { 2749 let f = At(u.target, h); 2750 for (let p of f) 2751 p !== u.target && p.setAttribute("tabindex", -1); 2752 u.target.setAttribute("tabindex", 0); 2753 } 2754 } 2755 return e.addEventListener("click", d), e.addEventListener("focusin", l), e.addEventListener("focusout", c), () => { 2756 a(), e.removeEventListener("click", d), e.removeEventListener("focusin", l), e.removeEventListener("focusout", c); 2757 }; 2758 }; 2759} 2760function yo() { 2761 return (i) => { 2762 let e, t; 2763 function s(n) { 2764 if (n.target.getAttribute("aria-hidden") === "true") { 2765 e = n.target, e.setAttribute("aria-hidden", "false"), t = e.hidden, t && (e.hidden = !1); 2766 let o = n.target.querySelector( 2767 'a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])' 2768 ); 2769 o && (o.tabIndex = 0); 2770 } 2771 } 2772 function r(n) { 2773 e && e.contains(n.target) && (!n.relatedTarget || !e.contains(n.relatedTarget)) && (n.target.tabIndex = -1, e.setAttribute("aria-hidden", "true"), t && (e.hidden = !0), e = null); 2774 } 2775 return i.addEventListener("keyuxJump", s), i.addEventListener("focusout", r), () => { 2776 i.removeEventListener("keyuxJump", s), i.removeEventListener("focusout", r); 2777 }; 2778 }; 2779} 2780function vo() { 2781 return (i) => { 2782 let e = []; 2783 function t(l) { 2784 let c = i.document.activeElement; 2785 c && c !== i.document.body && e.push(new WeakRef(c)), l.focus({ focusVisible: !0 }); 2786 } 2787 function s() { 2788 let l = e.pop(); 2789 if (!l) { 2790 i.document.activeElement.blur(); 2791 return; 2792 } 2793 let c = l.deref(); 2794 c && c.isConnected ? c.focus() : s(); 2795 } 2796 let r = 0, n; 2797 function o(l) { 2798 clearInterval(n); 2799 let c = l.getAttribute("aria-controls"); 2800 n = setInterval(() => { 2801 if (r++ > 50) { 2802 clearInterval(n); 2803 return; 2804 } 2805 let d = i.document.getElementById(c); 2806 if (d) { 2807 let u = d.querySelector( 2808 'a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])' 2809 ); 2810 u && (clearInterval(n), d.dispatchEvent( 2811 new i.CustomEvent("keyuxJump", { bubbles: !0 }) 2812 ), t(u)); 2813 } 2814 }, 50); 2815 } 2816 function a(l) { 2817 l.target.getAttribute("aria-controls") && l.key === "Enter" && o(l.target), l.key === "Escape" && s(); 2818 } 2819 return i.addEventListener("keydown", a), () => { 2820 i.removeEventListener("keydown", a); 2821 }; 2822 }; 2823} 2824function wo(i) { 2825 let e, t = i.split(" "), s; 2826 function r(a) { 2827 a.key === "Enter" && (a.target.tagName === "BUTTON" || a.target.tagName === "A") && (n(), a.target.classList.add(...t), e = a.target, s = a.target); 2828 } 2829 function n() { 2830 e && e.classList.remove(...t), s = null; 2831 } 2832 function o(a) { 2833 a.clientX === 0 && a.clientY === 0 && s !== a.target && (n(), a.target.classList.add(...t), e = a.target); 2834 } 2835 return (a) => (a.addEventListener("click", o), a.addEventListener("keydown", r), a.addEventListener("keyup", n), () => { 2836 a.removeEventListener("click", o), a.removeEventListener("keydown", r), a.removeEventListener("keyup", n); 2837 }); 2838} 2839function Co(i, e) { 2840 let t = e.map((s) => s(i)); 2841 return () => { 2842 t.forEach((s) => s()); 2843 }; 2844} 2845class Ao { 2846 /** 2847 * @private 2848 * @type {Map<Function, (event: Event) => void>} 2849 */ 2850 _listeners = /* @__PURE__ */ new Map(); 2851 /** 2852 * @private 2853 * @type {Node[]} 2854 */ 2855 _scope = []; 2856 /** 2857 * @param {'keydown' | 'keyup'} type 2858 * @param {(event: Event) => void} listener 2859 */ 2860 addEventListener(e, t) { 2861 const s = (r) => { 2862 const n = r.target; 2863 n && this._scope.some((o) => o === r.target || o.contains( 2864 /** @type {Node} */ 2865 n 2866 )) && t(r); 2867 }; 2868 this._listeners.set(t, s), window.addEventListener(e, s); 2869 } 2870 /** 2871 * @param {'keydown' | 'keyup'} type 2872 * @param {(event: {}) => void} listener 2873 */ 2874 removeEventListener(e, t) { 2875 const s = this._listeners.get(t); 2876 s && window.removeEventListener(e, s), this._listeners.delete(t); 2877 } 2878 get CustomEvent() { 2879 return window.CustomEvent; 2880 } 2881 get document() { 2882 return window.document; 2883 } 2884 get navigator() { 2885 return window.navigator; 2886 } 2887 /** @param {Node} scope */ 2888 registerScope(e) { 2889 this._scope.push(e); 2890 } 2891 destroy() {
2892 this._scope = [], this._listeners.forEach((e, t) => { 2893 window.removeEventListener("keydown", e), window.removeEventListener("keyup", e), this._listeners.delete(t); 2894 }); 2895 } 2896} 2897class Eo { 2898 /** 2899 * @private 2900 * @type {(() => void) | undefined} 2901 */ 2902 _destroyKeyUX; 2903 /** 2904 * @private 2905 * @type {ScopedMinimalWindow} 2906 */ 2907 _scopedWindow; 2908 constructor() { 2909 this._scopedWindow = new Ao(), this._destroyKeyUX = Co(this._scopedWindow, [ 2910 _o(), 2911 wo("is-pressed"), 2912 vo(), 2913 yo() 2914 ]); 2915 } 2916 /** @param {import('./Block.js').Block} scope */ 2917 registerBlock(e) { 2918 this._scopedWindow.registerScope(e); 2919 } 2920 destroy() { 2921 this._destroyKeyUX?.(), this._scopedWindow.destroy(); 2922 } 2923} 2924const To = "uc-"; 2925class k extends ze { 2926 /** @type {string | null} */ 2927 static StateConsumerScope = null; 2928 /** @type {string[]} */ 2929 static styleAttrs = []; 2930 /** @protected */ 2931 requireCtxName = !1; 2932 /** @type {import('./ActivityBlock.js').ActivityType} */ 2933 activityType = null; 2934 init$ = ps(); 2935 /** 2936 * @param {String} str 2937 * @param {{ [key: string]: string | number }} variables 2938 * @returns {String} 2939 */ 2940 l10n(e, t = {}) { 2941 if (!e) 2942 return ""; 2943 let s = this.$[be(e)] || e, r = Kr(s); 2944 for (let o of r) 2945 t[o.variable] = this.pluralize( 2946 o.pluralKey, 2947 Number(t[o.countVariable]) 2948 ); 2949 return kt(s, t); 2950 } 2951 /** 2952 * @private 2953 * @param {string} key 2954 * @param {number} count 2955 * @returns {string} 2956 */ 2957 pluralize(e, t) { 2958 const s = this.l10n("locale-id") || "en", r = es(s, t); 2959 return this.l10n(`${e}__${r}`); 2960 } 2961 /** 2962 * @param {string} key 2963 * @param {() => void} resolver 2964 * @protected 2965 */ 2966 bindL10n(e, t) { 2967 this.localeManager?.bindL10n(this, e, t); 2968 } 2969 constructor() { 2970 super(), this.l10nProcessorSubs = /* @__PURE__ */ new Map(), this.addTemplateProcessor(po); 2971 } 2972 /** 2973 * @param {Parameters<import('../blocks/UploadCtxProvider/EventEmitter.js').EventEmitter['emit']>[0]} type 2974 * @param {Parameters<import('../blocks/UploadCtxProvider/EventEmitter.js').EventEmitter['emit']>[1]} [payload] 2975 * @param {Parameters<import('../blocks/UploadCtxProvider/EventEmitter.js').EventEmitter['emit']>[2]} [options] 2976 */ 2977 emit(e, t, s) { 2978 const r = this.has("*eventEmitter") && this.$["*eventEmitter"]; 2979 r && r.emit(e, t, s); 2980 } 2981 /** 2982 * @param {(block: Block) => boolean} callback 2983 * @returns {Boolean} 2984 */ 2985 hasBlockInCtx(e) { 2986 for (let t of this.blocksRegistry) 2987 if (e(t)) 2988 return !0; 2989 return !1; 2990 } 2991 /** 2992 * @param {String} prop 2993 * @param {any} newVal 2994 */ 2995 setOrAddState(e, t) { 2996 this.add$( 2997 { 2998 [e]: t 2999 }, 3000 !0 3001 ); 3002 } 3003 /** @protected */ 3004 connectedCallback() { 3005 /** @type {typeof Block} */ 3006 this.constructor.styleAttrs.forEach((t) => { 3007 this.setAttribute(t, ""); 3008 }), this.hasAttribute("retpl") && (this.constructor.template = null, this.processInnerHtml = !0), this.requireCtxName ? Yr({ 3009 element: this, 3010 attribute: "ctx-name", 3011 onSuccess: () => { 3012 super.connectedCallback(); 3013 }, 3014 onTimeout: () => { 3015 console.error("Attribute `ctx-name` is required and it is not set."); 3016 } 3017 }) : super.connectedCallback(), fi.registerClient(this); 3018 } 3019 /** @protected */ 3020 disconnectedCallback() { 3021 super.disconnectedCallback(), fi.unregisterClient(this); 3022 } 3023 /** @protected */ 3024 initCallback() { 3025 this.has("*blocksRegistry") || this.add("*blocksRegistry", /* @__PURE__ */ new Set()), this.$["*blocksRegistry"].add(this), this.has("*eventEmitter") || this.add("*eventEmitter", new qr(this.debugPrint.bind(this))), this.has("*localeManager") || this.add("*localeManager", new fo(this)), this.has("*a11y") || this.add("*a11y", new Eo()), this.sub(be("locale-id"), (t) => { 3026 const s = Xr(t); 3027 this.style.direction = s === "ltr" ? "" : s; 3028 }); 3029 } 3030 /** 3031 * @private 3032 * @returns {LocaleManager | null} 3033 */ 3034 get localeManager() { 3035 return this.has("*localeManager") ? this.$["*localeManager"] : null; 3036 } 3037 /** 3038 * @returns {A11y | null} 3039 * @protected 3040 */ 3041 get a11y() { 3042 return this.has("*a11y") ? this.$["*a11y"] : null; 3043 } 3044 /** @type {Set<Block>} */ 3045 get blocksRegistry() { 3046 return this.$["*blocksRegistry"]; 3047 } 3048 /** @protected */ 3049 destroyCallback() { 3050 super.destroyCallback(); 3051 let e = this.blocksRegistry; 3052 e?.delete(this), this.localeManager?.destroyL10nBindings(this), this.l10nProcessorSubs = /* @__PURE__ */ new Map(), A.deleteCtx(this), e?.size === 0 && setTimeout(() => { 3053 this.destroyCtxCallback(); 3054 }, 0); 3055 } 3056 /** 3057 * Called when the last block is removed from the context. Note that inheritors must run their callback before that. 3058 * 3059 * @protected 3060 */ 3061 destroyCtxCallback() { 3062 A.deleteCtx(this.ctxName), this.localeManager?.destroy(); 3063 } 3064 /** 3065 * @param {String} url 3066 * @returns {Promise<String>} 3067 * @protected 3068 */ 3069 async proxyUrl(e) { 3070 if (this.cfg.secureDeliveryProxy && this.cfg.secureDeliveryProxyUrlResolver && console.warn( 3071 "Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used." 3072 ), this.cfg.secureDeliveryProxyUrlResolver)
3073 try { 3074 return await this.cfg.secureDeliveryProxyUrlResolver(e, { 3075 uuid: qi(e), 3076 cdnUrlModifiers: Xi(e), 3077 fileName: Dt(e) 3078 }); 3079 } catch (t) { 3080 return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.", t), e; 3081 } 3082 return this.cfg.secureDeliveryProxy ? kt( 3083 this.cfg.secureDeliveryProxy, 3084 { previewUrl: e }, 3085 { transform: (t) => window.encodeURIComponent(t) } 3086 ) : e; 3087 } 3088 /** @returns {import('../types').ConfigType} } */ 3089 get cfg() { 3090 if (!this.__cfgProxy) { 3091 let e = /* @__PURE__ */ Object.create(null); 3092 this.__cfgProxy = new Proxy(e, { 3093 set: (t, s, r) => { 3094 if (typeof s != "string") 3095 return !1; 3096 const n = H( 3097 /** @type {keyof import('../types').ConfigType} */ 3098 s 3099 ); 3100 return this.has(n) || this.add(n, oe[ 3101 /** @type {keyof import('../types').ConfigType} */ 3102 s 3103 ]), this.$[n] = r, !0; 3104 }, 3105 /** 3106 * @param {never} obj 3107 * @param {keyof import('../types').ConfigType} key 3108 */ 3109 get: (t, s) => { 3110 const r = H(s); 3111 return this.has(r) || this.add(r, oe[s]), this.$[H(s)]; 3112 } 3113 }); 3114 } 3115 return this.__cfgProxy; 3116 } 3117 /** 3118 * @template {keyof import('../types').ConfigType} T 3119 * @param {T} key 3120 * @param {(value: import('../types').ConfigType[T]) => void} callback 3121 */ 3122 subConfigValue(e, t) { 3123 const s = H(e); 3124 this.has(s) || this.add(s, oe[e]), this.sub(s, t); 3125 } 3126 /** @param {unknown[]} args */ 3127 debugPrint(...e) { 3128 if (!this.cfg.debug) 3129 return; 3130 let t = e; 3131 if (typeof e?.[0] == "function") { 3132 const s = e[0]; 3133 t = s(); 3134 } 3135 console.log(`[${this.ctxName}]`, ...t); 3136 } 3137 /** @param {String} [name] */ 3138 static reg(e) { 3139 if (!e) { 3140 super.reg(); 3141 return; 3142 } 3143 e.startsWith(To) && super.reg(e); 3144 } 3145} 3146const xo = "<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.71
31465-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z
vendor: 15,962 bytes, line 3146
3146'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-
3146onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>"; 3147class ht extends k {
3148 static styleAttrs = ["uc-wgt-common"]; 3149 requireCtxName = !0; 3150 init$ = gs(this); 3151 _template = null; 3152 initCallback() { 3153 super.initCallback(), this.a11y?.registerBlock(this); 3154 } 3155 static set template(e) { 3156 this._template = xo + e + /** HTML */ 3157 "<slot></slot>"; 3158 } 3159 static get template() { 3160 return this._template; 3161 } 3162} 3163const _i = "active", Le = "___ACTIVITY_IS_ACTIVE___"; 3164class _ extends k { 3165 /** @protected */ 3166 historyTracked = !1; 3167 init$ = ms(this); 3168 _debouncedHistoryFlush = G(this._historyFlush.bind(this), 10); 3169 /** @private */ 3170 _deactivate() { 3171 let e = _._activityCallbacks.get(this); 3172 this[Le] = !1, this.removeAttribute(_i), e?.deactivateCallback?.(); 3173 } 3174 /** @private */ 3175 _activate() { 3176 let e = _._activityCallbacks.get(this); 3177 this.$["*historyBack"] = this.historyBack.bind(this), this[Le] = !0, this.setAttribute(_i, ""), e?.activateCallback?.(), this._debouncedHistoryFlush(), this.emit(O.ACTIVITY_CHANGE, { 3178 activity: this.activityType 3179 }); 3180 } 3181 /** @protected */ 3182 initCallback() { 3183 super.initCallback(), this.hasAttribute("current-activity") && this.sub("*currentActivity", (e) => { 3184 this.setAttribute("current-activity", e); 3185 }), this.activityType && (this.hasAttribute("activity") || this.setAttribute("activity", this.activityType), this.sub("*currentActivity", (e) => { 3186 try { 3187 this.activityType !== e && this[Le] ? this._deactivate() : this.activityType === e && !this[Le] && this._activate(); 3188 } catch (t) { 3189 console.error(`Error in activity "${this.activityType}". `, t), this.$["*currentActivity"] = this.$["*history"][this.$["*history"].length - 1] ?? null; 3190 } 3191 e || (this.$["*history"] = []); 3192 }), this.has("*modalActive") && this.sub("*modalActive", (e) => { 3193 !e && this.activityType === this.$["*currentActivity"] && (this.$["*currentActivity"] = null); 3194 })); 3195 } 3196 /** @private */ 3197 _historyFlush() { 3198 let e = this.$["*history"]; 3199 e && (e.length > 10 && (e = e.slice(e.length - 11, e.length - 1)), this.historyTracked && e[e.length - 1] !== this.activityType && e.push(this.activityType), this.$["*history"] = e); 3200 } 3201 /** @private */ 3202 _isActivityRegistered() { 3203 return this.activityType && _._activityCallbacks.has(this); 3204 } 3205 /** 3206 * @private 3207 * @type {Map< 3208 * ActivityBlock, 3209 * { activateCallback: (() => void) | undefined; deactivateCallback: (() => void) | undefined } 3210 * >} 3211 */ 3212 static _activityCallbacks = /* @__PURE__ */ new Map(); 3213 get isActivityActive() { 3214 return this[Le]; 3215 } 3216 get couldOpenActivity() { 3217 return !0; 3218 } 3219 /** 3220 * TODO: remove name argument 3221 * 3222 * @param {String} name 3223 * @param {Object} [options] 3224 * @param {() => void} [options.onActivate] 3225 * @param {() => void} [options.onDeactivate] 3226 */ 3227 registerActivity(e, t = {}) { 3228 const { onActivate: s, onDeactivate: r } = t; 3229 _._activityCallbacks.set(this, { 3230 activateCallback: s, 3231 deactivateCallback: r 3232 }); 3233 } 3234 unregisterActivity() { 3235 this.isActivityActive && this._deactivate(), _._activityCallbacks.delete(this); 3236 } 3237 /** @protected */ 3238 destroyCallback() { 3239 super.destroyCallback(), this._isActivityRegistered() && this.unregisterActivity(); 3240 const e = this.$["*currentActivity"]; 3241 [...this.blocksRegistry].find( 3242 (s) => s instanceof _ && s.activityType === e 3243 ) || (this.$["*currentActivity"] = null, this.setOrAddState("*modalActive", !1)); 3244 } 3245 get activityKey() { 3246 return this.ctxName + this.activityType; 3247 } 3248 /** @type {ActivityParamsMap[keyof ActivityParamsMap]} */ 3249 get activityParams() { 3250 return this.$["*currentActivityParams"]; 3251 } 3252 /** @type {String} */ 3253 get initActivity() { 3254 return this.getCssData("--cfg-init-activity"); 3255 } 3256 /** @type {String} */ 3257 get doneActivity() { 3258 return this.getCssData("--cfg-done-activity"); 3259 } 3260 historyBack() { 3261 let e = this.$["*history"]; 3262 if (e) { 3263 let t = e.pop(); 3264 for (; t === this.activityType; ) 3265 t = e.pop(); 3266 let s = !!t; 3267 t && (s = /** @type {ActivityBlock} */ 3268 [...this.blocksRegistry].find((n) => n.activityType === t)?.couldOpenActivity ?? !1), t = s ? t : void 0, this.$["*currentActivity"] = t, this.$["*history"] = e, t || this.setOrAddState("*modalActive", !1); 3269 } 3270 } 3271} 3272_.activities = Object.freeze({ 3273 START_FROM: "start-from", 3274 CAMERA: "camera", 3275 DRAW: "draw",
3276 UPLOAD_LIST: "upload-list", 3277 URL: "url", 3278 CLOUD_IMG_EDIT: "cloud-image-edit", 3279 EXTERNAL: "external" 3280}); 3281const So = 20, Lt = 24, De = 34, ys = 3, Y = ys / 2, me = 1, je = 100 / 3, v = 1, yi = 24, $o = 6; 3282function Ee(i, e) { 3283 for (let t in e) i.setAttributeNS(null, t, e[t].toString()); 3284} 3285function q(i, e = {}) { 3286 let t = document.createElementNS("http://www.w3.org/2000/svg", i); 3287 return Ee(t, e), t; 3288} 3289function ko(i, e, t) { 3290 let { x: s, y: r, width: n, height: o } = i, a = e.includes("w") ? 0 : 1, l = e.includes("n") ? 0 : 1, c = [-1, 1][a], d = [-1, 1][l], u = [ 3291 s + a * n + Y * c, 3292 r + l * o + Y * d - Lt * t * d 3293 ], h = [s + a * n + Y * c, r + l * o + Y * d], f = [ 3294 s + a * n - Lt * t * c + Y * c, 3295 r + l * o + Y * d 3296 ]; 3297 return { 3298 d: `M ${u[0]} ${u[1]} L ${h[0]} ${h[1]} L ${f[0]} ${f[1]}`, 3299 center: h 3300 }; 3301} 3302function Io(i, e, t) { 3303 let { x: s, y: r, width: n, height: o } = i, a = ["n", "s"].includes(e) ? 0.5 : { w: 0, e: 1 }[ 3304 /** @type {Extract<import('./types.js').Direction, 'w' | 'e'>} */ 3305 e 3306 ], l = ["w", "e"].includes(e) ? 0.5 : { n: 0, s: 1 }[ 3307 /** @type {Extract<import('./types.js').Direction, 'n' | 's'>} */ 3308 e 3309 ], c = [-1, 1][a], d = [-1, 1][l], u, h; 3310 ["n", "s"].includes(e) ? (u = [s + a * n - De * t / 2, r + l * o + Y * d], h = [s + a * n + De * t / 2, r + l * o + Y * d]) : (u = [s + a * n + Y * c, r + l * o - De * t / 2], h = [s + a * n + Y * c, r + l * o + De * t / 2]); 3311 let f = `M ${u[0]} ${u[1]} L ${h[0]} ${h[1]}`, p = [h[0] - (h[0] - u[0]) / 2, h[1] - (h[1] - u[1]) / 2]; 3312 return { d: f, center: p }; 3313} 3314function Oo(i) { 3315 return i === "" ? "move" : ["e", "w"].includes(i) ? "ew-resize" : ["n", "s"].includes(i) ? "ns-resize" : ["nw", "se"].includes(i) ? "nwse-resize" : "nesw-resize"; 3316} 3317function Lo({ rect: i, delta: [e, t], imageBox: s }) { 3318 return tt( 3319 { 3320 ...i, 3321 x: i.x + e, 3322 y: i.y + t 3323 }, 3324 s 3325 ); 3326} 3327function tt(i, e) { 3328 let { x: t } = i, { y: s } = i; 3329 return i.x < e.x ? t = e.x : i.x + i.width > e.x + e.width && (t = e.x + e.width - i.width), i.y < e.y ? s = e.y : i.y + i.height > e.y + e.height && (s = e.y + e.height - i.height), { 3330 ...i, 3331 x: t, 3332 y: s 3333 }; 3334} 3335function Uo({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3336 const [, r] = e; 3337 let { y: n, width: o, height: a } = i; 3338 n += r, a -= r, t && (o = a * t); 3339 let l = i.x + i.width / 2 - o / 2; 3340 return n <= s.y && (n = s.y, a = i.y + i.height - n, t && (o = a * t, l = i.x + i.width / 2 - o / 2)), l <= s.x && (l = s.x, n = i.y + i.height - a), l + o >= s.x + s.width && (l = Math.max(s.x, s.x + s.width - o), o = s.x + s.width - l, t && (a = o / t), n = i.y + i.height - a), a < v && (a = v, t && (o = a * t, l = i.x + i.width / 2 - o / 2), n = i.y + i.height - a), o < v && (o = v, t && (a = o / t, l = i.x + i.width / 2 - o / 2), n = i.y + i.height - a), { x: l, y: n, width: o, height: a }; 3341} 3342function Po({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3343 const [r] = e; 3344 let { x: n, width: o, height: a } = i; 3345 n += r, o -= r, t && (a = o / t); 3346 let l = i.y + i.height / 2 - a / 2; 3347 return n <= s.x && (n = s.x, o = i.x + i.width - n, t && (a = o / t, l = i.y + i.height / 2 - a / 2)), l <= s.y && (l = s.y, n = i.x + i.width - o), l + a >= s.y + s.height && (l = Math.max(s.y, s.y + s.height - a), a = s.y + s.height - l, t && (o = a * t), n = i.x + i.width - o), a < v && (a = v, t && (o = a * t), l = i.y + i.height / 2 - a / 2, n = i.x + i.width - o), o < v && (o = v, t && (a = o / t), l = i.y + i.height / 2 - a / 2, n = i.x + i.width - o), { x: n, y: l, width: o, height: a }; 3348} 3349function Mo({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3350 const [, r] = e; 3351 let { y: n, width: o, height: a } = i; 3352 a += r, t && (o = a * t); 3353 let l = i.x + i.width / 2 - o / 2; 3354 return n + a >= s.y + s.height && (a = s.y + s.height - n, t && (o = a * t), l = i.x + i.width / 2 - o / 2), l <= s.x && (l = s.x, n = i.y), l + o >= s.x + s.width && (l = Math.max(s.x, s.x + s.width - o), o = s.x + s.width - l, t && (a = o / t), n = i.y), a < v && (a = v, t && (o = a * t), l = i.x + i.width / 2 - o / 2), o < v && (o = v, t && (a = o / t), l = i.x + i.width / 2 - o / 2), { x: l, y: n, width: o, height: a }; 3355} 3356function Ro({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3357 const [r] = e; 3358 let { x: n, width: o, height: a } = i; 3359 o += r, t && (a = o / t); 3360 let l = i.y + i.height / 2 - a / 2; 3361 return n + o >= s.x + s.width && (o = s.x + s.width - n, t && (a = o / t), l = i.y + i.height / 2 - a / 2), l <= s.y && (l = s.y, n = i.x), l + a >= s.y + s.height && (l = Math.max(s.y, s.y + s.height - a), a = s.y + s.height - l, t && (o = a * t), n = i.x), a < v && (a = v, t && (o = a * t), l = i.y + i.height / 2 - a / 2), o < v && (o = v, t && (a = o / t), l = i.y + i.height / 2 - a / 2), { x: n, y: l, width: o, height: a }; 3362} 3363function Do({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3364 let [r, n] = e, { x: o, y: a, width: l, height: c } = i; 3365 return o + r < s.x && (r = s.x - o), a + n < s.y && (n = s.y - a), o += r, l -= r, a += n, c -= n, t && Math.abs(l / c) > t ? (n = l / t - c, c += n, a -= n, a <= s.y && (c = c - (s.y - a), l = c * t, o = i.x + i.width - l, a = s.y)) : t && (r = c * t - l, l = l + r, o -= r, o <= s.x && (l = l - (s.x - o), c = l / t, o = s.x, a = i.y + i.height - c)), c < v && (c = v, t && (l = c * t), o = i.x + i.width - l, a = i.y + i.height - c), l < v && (l = v, t && (c = l / t), o = i.x + i.width - l, a = i.y + i.height - c), { x: o, y: a, width: l, height: c }; 3366} 3367function Fo({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3368 let [r, n] = e, { x: o, y: a, width: l, height: c } = i; 3369 return o + l + r > s.x + s.width && (r = s.x + s.width - o - l), a + n < s.y && (n = s.y - a), l += r, a += n, c -= n, t && Math.abs(l / c) > t ? (n = l / t - c, c += n, a -= n, a <= s.y && (c = c - (s.y - a), l = c * t, o = i.x, a = s.y)) : t && (r = c * t - l, l += r, o + l >= s.x + s.width && (l = s.x + s.width - o, c = l / t, o = s.x + s.width - l, a = i.y + i.height - c)), c < v && (c = v, t && (l = c * t), a = i.y + i.height - c), l < v && (l = v, t && (c = l / t), a = i.y + i.height - c), { x: o, y: a, width: l, height: c }; 3370} 3371function Vo({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3372 let [r, n] = e, { x: o, y: a, width: l, height: c } = i; 3373 return o + r < s.x && (r = s.x - o), a + c + n > s.y + s.height && (n = s.y + s.height - a - c), o += r, l -= r, c += n, t && Math.abs(l / c) > t ? (n = l / t - c, c += n, a + c >= s.y + s.height && (c = s.y + s.height - a, l = c * t, o = i.x + i.width - l, a = s.y + s.height - c)) : t && (r = c * t - l, l += r, o -= r, o <= s.x && (l = l - (s.x - o), c = l / t, o = s.x, a = i.y)), c < v && (c = v, t && (l = c * t), o = i.x + i.width - l), l < v && (l = v, t && (c = l / t), o = i.x + i.width - l), { x: o, y: a, width: l, height: c }; 3374} 3375function No({ rect: i, delta: e, aspectRatio: t, imageBox: s }) { 3376 let [r, n] = e, { x: o, y: a, width: l, height: c } = i; 3377 return o + l + r > s.x + s.width && (r = s.x + s.width - o - l), a + c + n > s.y + s.height && (n = s.y + s.height - a - c), l += r, c += n, t && Math.abs(l / c) > t ? (n = l / t - c, c += n, a + c >= s.y + s.height && (c = s.y + s.height - a, l = c * t, o = i.x, a = s.y + s.height - c)) : t && (r = c * t - l, l += r, o + l >= s.x + s.width && (l = s.x + s.width - o, c = l / t, o = s.x + s.width - l, a = i.y)), c < v && (c = v, t && (l = c * t)), l < v && (l = v, t && (c = l / t)), { x: o, y: a, width: l, height: c }; 3378} 3379function zo({ direction: i, ...e }) { 3380 switch (i) { 3381 case "n": 3382 return Uo(e); 3383 case "w": 3384 return Po(e); 3385 case "s": 3386 return Mo(e); 3387 case "e": 3388 return Ro(e); 3389 case "nw": 3390 return Do(e); 3391 case "ne": 3392 return Fo(e); 3393 case "sw": 3394 return Vo(e); 3395 case "se": 3396 return No(e); 3397 default: 3398 return e.rect; 3399 } 3400} 3401function Bo(i, [e, t]) { 3402 return i.x <= e && e <= i.x + i.width && i.y <= t && t <= i.y + i.height; 3403} 3404function Ho(i, e) { 3405 return i.x >= e.x && i.y >= e.y && i.x + i.width <= e.x + e.width && i.y + i.height <= e.y + e.height; 3406} 3407function jo(i, e) { 3408 return Math.abs(i.width / i.height - e) < 0.1; 3409} 3410function Ue({ width: i, height: e }, t) { 3411 let s = t / 90 % 2 !== 0; 3412 return { width: s ? e : i, height: s ? i : e }; 3413} 3414function Go(i, e, t) { 3415 const s = i / e; 3416 let r, n; 3417 s > t ? (r = Math.round(e * t), n = e) : (r = i, n = Math.round(i / t)); 3418 const o = Math.round((i - r) / 2), a = Math.round((e - n) / 2); 3419 return o + r > i && (r = i - o), a + n > e && (n = e - a), { x: o, y: a, width: r, height: n }; 3420} 3421function Je(i) { 3422 return { 3423 x: Math.round(i.x), 3424 y: Math.round(i.y), 3425 width: Math.round(i.width), 3426 height: Math.round(i.height) 3427 }; 3428} 3429function Te(i, e, t) { 3430 return Math.min(Math.max(i, e), t); 3431} 3432const vs = (i) => { 3433 if (!i) return []; 3434 const [e, t] = i.split(":").map(Number); 3435 if (!Number.isFinite(e) || !Number.isFinite(t)) { 3436 console.error(`Invalid crop preset: ${i}`); 3437 return; 3438 } 3439 return [{ type: "aspect-ratio", width: e, height: t }]; 3440}, ft = "blocks", pt = "1.12.0"; 3441function Wo(i) { 3442 return ss({ 3443 ...i, 3444 libraryName: ft, 3445 libraryVersion: pt 3446 }); 3447} 3448const vi = (i) => Math.floor(i / 1e3), qo = (i, { threshold: e }) => { 3449 const { secureExpire: t } = i, s = vi(Date.now()), r = Number(t), n = vi(e); 3450 return s + n >= r; 3451}; 3452class Xo { 3453 /** 3454 * @private 3455 * @type {import('./UploaderBlock.js').UploaderBlock} 3456 */ 3457 _block; 3458 /** 3459 * @private 3460 * @type {import('../types').SecureUploadsSignatureAndExpire | null} 3461 */ 3462 _secureToken = null; 3463 /** @param {import('./UploaderBlock.js').UploaderBlock} block */ 3464 constructor(e) { 3465 this._block = e; 3466 } 3467 /** 3468 * @private 3469 * @param {unknown[]} args 3470 */ 3471 _debugPrint(...e) { 3472 this._block.debugPrint("[secure-uploads]", ...e); 3473 } 3474 /** @returns {Promise<import('../types').SecureUploadsSignatureAndExpire | null>} */ 3475 async getSecureToken() { 3476 const { secureSignature: e, secureExpire: t, secureUploadsSignatureResolver: s } = this._block.cfg; 3477 if ((e || t) && s && console.warn( 3478 "Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used." 3479 ), s) { 3480 if (!this._secureToken || qo(this._secureToken, { threshold: this._block.cfg.secureUploadsExpireThreshold })) { 3481 this._secureToken ? this._debugPrint("Secure signature is expired. Resolving a new one...") : this._debugPrint("Secure signature is not set yet."); 3482 try { 3483 const r = await s(); 3484 r ? !r.secureSignature || !r.secureExpire ? console.error("Secure signature resolver returned an invali
3484d result:", r) : (this._debugPrint("Secure signature resolved:", r), this._debugPrint( 3485 "Secure signature will expire in", 3486 new Date(Number(r.secureExpire) * 1e3).toISOString() 3487 ), this._secureToken = r) : (this._debugPrint("Secure signature resolver returned nothing."), this._secureToken = null); 3488 } catch (r) { 3489 console.error("Secure signature resolving failed. Falling back to the previous one.", r); 3490 } 3491 } 3492 return this._secureToken; 3493 } 3494 return e && t ? (this._debugPrint("Secure signature and expire are set. Using them...", { 3495 secureSignature: e, 3496 secureExpire: t 3497 }), { 3498 secureSignature: e, 3499 secureExpire: t 3500 }) : null; 3501 } 3502} 3503const wi = "[Typed State] Wrong property name: ", Zo = "[Typed State] Wrong property type: "; 3504class Ko { 3505 /** 3506 * @param {Object<string, { type: any; value: any; nullable?: Boolean }>} typedSchema 3507 * @param {String} [ctxName] 3508 */ 3509 constructor(e, t) { 3510 this.__typedSchema = e, this.__ctxId = t || st.generate(), this.__schema = Object.keys(e).reduce((s, r) => (s[r] = e[r].value, s), {}), this.__data = A.registerCtx(this.__schema, this.__ctxId); 3511 } 3512 /** @returns {String} */ 3513 get uid() { 3514 return this.__ctxId; 3515 } 3516 /** 3517 * @param {String} prop 3518 * @param {any} value 3519 */ 3520 setValue(e, t) { 3521 if (!this.__typedSchema.hasOwnProperty(e)) { 3522 console.warn(wi + e); 3523 return; 3524 } 3525 let s = this.__typedSchema[e]; 3526 if (t?.constructor === s.type || t instanceof s.type || s.nullable && t === null) { 3527 this.__data.pub(e, t); 3528 return; 3529 } 3530 console.warn(Zo + e); 3531 } 3532 /** @param {Object<string, any>} updObj */ 3533 setMultipleValues(e) { 3534 for (let t in e) 3535 this.setValue(t, e[t]); 3536 } 3537 /** @param {String} prop */ 3538 getValue(e) { 3539 if (!this.__typedSchema.hasOwnProperty(e)) { 3540 console.warn(wi + e); 3541 return; 3542 } 3543 return this.__data.read(e); 3544 } 3545 /** 3546 * @param {String} prop 3547 * @param {(newVal: any) => void} handler 3548 */ 3549 subscribe(e, t) { 3550 return this.__data.sub(e, t); 3551 } 3552 remove() { 3553 A.deleteCtx(this.__ctxId); 3554 } 3555} 3556class Yo { 3557 /** 3558 * @param {Object} options 3559 * @param {Object<string, { type: any; value: any }>} options.typedSchema 3560 * @param {String[]} [options.watchList] 3561 * @param {(list: string[], added: Set<any>, removed: Set<any>) => void} [options.handler] 3562 * @param {String} [options.ctxName] 3563 */ 3564 constructor(e) { 3565 this.__typedSchema = e.typedSchema, this.__ctxId = e.ctxName || st.generate(), this.__data = A.registerCtx({}, this.__ctxId), this.__watchList = e.watchList || [], this.__subsMap = /* @__PURE__ */ Object.create(null), this.__propertyObservers = /* @__PURE__ */ new Set(), this.__collectionObservers = /* @__PURE__ */ new Set(), this.__items = /* @__PURE__ */ new Set(), this.__removed = /* @__PURE__ */ new Set(), this.__added = /* @__PURE__ */ new Set(); 3566 let t = /* @__PURE__ */ Object.create(null); 3567 this.__notifyObservers = (s, r) => { 3568 this.__observeTimeout && window.clearTimeout(this.__observeTimeout), t[s] || (t[s] = /* @__PURE__ */ new Set()), t[s].add(r), this.__observeTimeout = window.setTimeout(() => { 3569 Object.keys(t).length !== 0 && (this.__propertyObservers.forEach((n) => { 3570 n({ ...t }); 3571 }), t = /* @__PURE__ */ Object.create(null)); 3572 }); 3573 }; 3574 } 3575 notify() { 3576 this.__notifyTimeout && window.clearTimeout(this.__notifyTimeout), this.__notifyTimeout = window.setTimeout(() => { 3577 let e = new Set(this.__added), t = new Set(this.__removed); 3578 this.__added.clear(), this.__removed.clear(); 3579 for (const s of this.__collectionObservers) 3580 s?.([...this.__items], e, t); 3581 }); 3582 } 3583 /** @param {(list: string[], added: Set<any>, removed: Set<any>) => void} handler */ 3584 observeCollection(e) { 3585 return this.__collectionObservers.add(e), this.__items.size > 0 && this.notify(), () => { 3586 this.unobserveCollection(e); 3587 }; 3588 } 3589 /** @param {Function} handler */ 3590 unobserveCollection(e) { 3591 this.__collectionObservers?.delete(e); 3592 } 3593 /** 3594 * @param {Object<string, any>} init 3595 * @returns {string} 3596 */ 3597 add(e) { 3598 let t = new Ko(this.__typedSchema); 3599 for (let s in e) 3600 t.setValue(s, e[s]); 3601 return this.__items.add(t.uid), this.notify(), this.__data.add(t.uid, t), this.__added.add(t), this.__watchList.forEach((s) => { 3602 this.__subsMap[t.uid] || (this.__subsMap[t.uid] = []), this.__subsMap[t.uid].push( 3603 t.subscribe(s, () => { 3604 this.__notifyObservers(s, t.uid); 3605 }) 3606 ); 3607 }), t.uid; 3608 } 3609 /** 3610 * @param {String} id 3611 * @returns {TypedData}
3611 3612 */ 3613 read(e) { 3614 return this.__data.read(e); 3615 } 3616 /** 3617 * @param {String} id 3618 * @param {String} propName 3619 * @returns {any} 3620 */ 3621 readProp(e, t) { 3622 return this.read(e).getValue(t); 3623 } 3624 /** 3625 * @template T 3626 * @param {String} id 3627 * @param {String} propName 3628 * @param {T} value 3629 */ 3630 publishProp(e, t, s) { 3631 this.read(e).setValue(t, s); 3632 } 3633 /** @param {String} id */ 3634 remove(e) { 3635 this.__removed.add(this.__data.read(e)), this.__items.delete(e), this.notify(), this.__data.pub(e, null), delete this.__subsMap[e]; 3636 } 3637 clearAll() { 3638 this.__items.forEach((e) => { 3639 this.remove(e); 3640 }); 3641 } 3642 /** @param {Function} handler */ 3643 observeProperties(e) { 3644 return this.__propertyObservers.add(e), () => { 3645 this.unobserveProperties(e); 3646 }; 3647 } 3648 /** @param {Function} handler */ 3649 unobserveProperties(e) { 3650 this.__propertyObservers?.delete(e); 3651 } 3652 /** 3653 * @param {(item: TypedData) => Boolean} checkFn 3654 * @returns {String[]} 3655 */ 3656 findItems(e) { 3657 let t = []; 3658 return this.__items.forEach((s) => { 3659 let r = this.read(s); 3660 e(r) && t.push(s); 3661 }), t; 3662 } 3663 items() { 3664 return [...this.__items]; 3665 } 3666 get size() { 3667 return this.__items.size; 3668 } 3669 destroy() { 3670 A.deleteCtx(this.__ctxId), this.__propertyObservers = null, this.__collectionObservers = null; 3671 for (let e in this.__subsMap) 3672 this.__subsMap[e].forEach((t) => { 3673 t.remove(); 3674 }), delete this.__subsMap[e]; 3675 } 3676} 3677const mt = Object.freeze({ 3678 FACEBOOK: "facebook", 3679 DROPBOX: "dropbox", 3680 GDRIVE: "gdrive", 3681 GPHOTOS: "gphotos", 3682 FLICKR: "flickr", 3683 VK: "vk", 3684 EVERNOTE: "evernote", 3685 BOX: "box", 3686 ONEDRIVE: "onedrive", 3687 HUDDLE: "huddle" 3688}), P = Object.freeze({ 3689 LOCAL: "local", 3690 DROP_AREA: "drop-area", 3691 CAMERA: "camera", 3692 EXTERNAL: "external", 3693 API: "js-api", 3694 URL: "url", 3695 DRAW: "draw", 3696 ...mt 3697}), qt = [ 3698 "image/*", 3699 "image/heif", 3700 "image/heif-sequence", 3701 "image/heic", 3702 "image/heic-sequence", 3703 "image/avif", 3704 "image/avif-sequence", 3705 ".heif", 3706 ".heifs", 3707 ".heic", 3708 ".heics", 3709 ".avif", 3710 ".avifs" 3711], ws = (i) => i ? i.filter((e) => typeof e == "string").map((e) => ce(e)).flat() : [], Cs = (i, e) => e.some((t) => t.endsWith("*") ? (t = t.replace("*", ""), i.startsWith(t)) : i === t), Jo = (i, e) => e.some((t) => t.startsWith(".") ? i.toLowerCase().endsWith(t.toLowerCase()) : !1), Qo = (i) => { 3712 let e = i?.type; 3713 return e ? Cs(e, qt) : !1; 3714}, ea = /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i, ta = new RegExp(`^/?(${ea.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`, "i"), ia = ({ url: i, cdnBase: e }) => { 3715 const t = new URL(e), s = new URL(i); 3716 if (t.host !== s.host) 3717 return null; 3718 const [, r, n, o] = ta.exec(s.pathname); 3719 return { 3720 uuid: r, 3721 cdnUrlModifiers: n || "", 3722 filename: o || null 3723 }; 3724}, sa = (i) => { 3725 const e = /* @__PURE__ */ new Map(); 3726 return ( 3727 /** @type {T} */ 3728 ((...t) => { 3729 const s = JSON.stringify(t); 3730 if (e.has(s)) 3731 return e.get(s); 3732 const r = i(...t); 3733 return e.set(s, r), r; 3734 }) 3735 ); 3736}, Ci = /* @__PURE__ */ new Set(); 3737function ra(i) { 3738 Ci.has(i) || (Ci.add(i), console.warn(i)); 3739} 3740function na(i) { 3741 let e = !1; 3742 return setTimeout(() => { 3743 e = !0; 3744 }, 0), (s) => ( 3745 /** @type {T} */ 3746 ((...r) => (e && ra(i), s(...r))) 3747 ); 3748} 3749function oa(i) { 3750 const e = { 3751 /** @returns {number} */ 3752 progress: () => i.$["*commonProgress"], 3753 /** @returns {ReturnType<import('../types').OutputErrorFile>[]} */ 3754 errors: () => i.$["*collectionErrors"], 3755 /** @returns {import('@uploadcare/upload-client').UploadcareGroup | null} */ 3756 group: () => i.$["*groupInfo"], 3757 totalCount: () => i.uploadCollection.size, 3758 failedCount: () => t.failedEntries.length, 3759 successCount: () => t.successEntries.length, 3760 uploadingCount: () => t.uploadingEntries.length, 3761 status: () => t.isFailed ? "failed" : t.isUploading ? "uploading" : t.isSuccess ? "success" : "idle", 3762 isSuccess: () => t.allEntries.length > 0 && t.errors.length === 0 && t.successEntries.length === t.allEntries.length, 3763 isUploading: () => t.allEntries.some((r) => r.status === "uploading"), 3764 isFailed: () => t.errors.length > 0 || t.failedEntries.length > 0, 3765 allEntries: () => i.getOutputData(), 3766 successEntries: () => t.allEntries.filter((r) => r.status === "success"), 3767 failedEntries: () => t.allEntries.filter((r) => r.status === "failed"), 3768 uploadingEntries: () => t.allEntries.filter((r) => r.status === "uploading"), 3769 idleEntries: () => t.allEntries.filter((r) => r.status === "idle") 3770 }, t = ( 3771 /** @type {import('../index.js').OutputCollectionState<TCollectionStatus, TGroupFlag>} */ 3772 /** @type {unknown} */ 3773 {} 3774 ), s = na( 3775 "You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than
3775it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`" 3776 ); 3777 for (const [r, n] of Object.entries(e)) { 3778 const o = ( 3779 /** @type {keyof typeof getters} */ 3780 r 3781 ), l = sa(s( 3782 /** @type {(typeof getters)[name]} */ 3783 n 3784 )); 3785 Object.defineProperty(t, o, { 3786 get: l, 3787 enumerable: !0 3788 }); 3789 } 3790 return t; 3791} 3792class aa { 3793 /** 3794 * @private 3795 * @type {import('./UploaderBlock.js').UploaderBlock} 3796 */ 3797 _ctx; 3798 /** @param {import('./UploaderBlock.js').UploaderBlock} ctx */ 3799 constructor(e) { 3800 this._ctx = e; 3801 } 3802 /** @private */ 3803 get _uploadCollection() { 3804 return this._ctx.uploadCollection; 3805 } 3806 get cfg() { 3807 return this._ctx.cfg; 3808 } 3809 get l10n() { 3810 return this._ctx.l10n.bind(this._ctx); 3811 } 3812 /** 3813 * TODO: Probably we should not allow user to override `source` property 3814 * 3815 * @param {string} url 3816 * @param {{ silent?: boolean; fileName?: string; source?: string }} [options] 3817 * @returns {import('../types').OutputFileEntry<'idle'>} 3818 */ 3819 addFileFromUrl = (e, { silent: t, fileName: s, source: r } = {}) => { 3820 const n = this._uploadCollection.add({ 3821 externalUrl: e, 3822 fileName: s ?? null, 3823 silent: t ?? !1, 3824 source: r ?? P.API 3825 }); 3826 return this.getOutputItem(n); 3827 }; 3828 /** 3829 * @param {string} uuid 3830 * @param {{ silent?: boolean; fileName?: string; source?: string }} [options] 3831 * @returns {import('../types').OutputFileEntry<'idle'>} 3832 */ 3833 addFileFromUuid = (e, { silent: t, fileName: s, source: r } = {}) => { 3834 const n = this._uploadCollection.add({ 3835 uuid: e, 3836 fileName: s ?? null, 3837 silent: t ?? !1, 3838 source: r ?? P.API 3839 }); 3840 return this.getOutputItem(n); 3841 }; 3842 /** 3843 * @param {string} cdnUrl 3844 * @param {{ silent?: boolean; fileName?: string; source?: string }} [options] 3845 * @returns {import('../types').OutputFileEntry<'idle'>} 3846 */ 3847 addFileFromCdnUrl = (e, { silent: t, fileName: s, source: r } = {}) => { 3848 const n = ia({ url: e, cdnBase: this.cfg.cdnCname }); 3849 if (!n) 3850 throw new Error("Invalid CDN URL"); 3851 const o = this._uploadCollection.add({ 3852 uuid: n.uuid, 3853 cdnUrl: e, 3854 cdnUrlModifiers: n.cdnUrlModifiers, 3855 fileName: s ?? n.filename ?? null, 3856 silent: t ?? !1, 3857 source: r ?? P.API 3858 }); 3859 return this.getOutputItem(o); 3860 }; 3861 /** 3862 * @param {File} file 3863 * @param {{ silent?: boolean; fileName?: string; source?: string; fullPath?: string }} [options] 3864 * @returns {import('../types').OutputFileEntry<'idle'>} 3865 */ 3866 addFileFromObject = (e, { silent: t, fileName: s, source: r, fullPath: n } = {}) => { 3867 const o = this._uploadCollection.add({ 3868 file: e, 3869 isImage: Qo(e), 3870 mimeType: e.type, 3871 fileName: s ?? e.name, 3872 fileSize: e.size, 3873 silent: t ?? !1, 3874 source: r ?? P.API, 3875 fullPath: n ?? null 3876 }); 3877 return this.getOutputItem(o); 3878 }; 3879 /** @param {string} internalId */ 3880 removeFileByInternalId = (e) => { 3881 if (!this._uploadCollection.read(e)) 3882 throw new Error(`File with internalId ${e} not found`); 3883 this._uploadCollection.remove(e); 3884 }; 3885 removeAllFiles() { 3886 this._uploadCollection.clearAll(); 3887 } 3888 uploadAll = () => { 3889 const e = this._uploadCollection.items().filter((t) => { 3890 const s = this._uploadCollection.read(t); 3891 return !s.getValue("isRemoved") && !s.getValue("isUploading") && !s.getValue("fileInfo"); 3892 }); 3893 e.length !== 0 && (this._ctx.$["*uploadTrigger"] = new Set(e), this._ctx.emit( 3894 O.COMMON_UPLOAD_START, 3895 /** @type {import('../types').OutputCollectionState<'uploading'>} */ 3896 this.getOutputCollectionState() 3897 )); 3898 }; 3899 /** @param {{ captureCamera?: boolean }} options */ 3900 openSystemDialog = (e = {}) => { 3901 const t = Ft( 3902 ws([this.cfg.accept ?? "", ...this.cfg.imgOnly ? qt : []]) 3903 ); 3904 this.cfg.accept && this.cfg.imgOnly && console.warn( 3905 "There could be a mistake.\nBoth `accept` and `imgOnly` parameters are set.\nThe value of `accept` will be concatenated with the internal image mime types list." 3906 ); 3907 const s = "uploadcare-file-input", r = document.createElement("input"); 3908 r.setAttribute(s, ""), Mt(r, { 3909 opacity: 0, 3910 height: 0, 3911 width: 0, 3912 visibility: "hidden" 3913 }), r.type = "file", r.multiple = this.cfg.multiple, e.captureCamera ? (r.capture = this.cfg.cameraCapture, r.accept = this.cfg.enableVideoRecording ? ["image/*", "video/*"].join(",") : "image/*") : r.accept = t, r.addEventListener( 3914 "change", 3915 () => {
3916 r.files && ([...r.files].forEach( 3917 (n) => this.addFileFromObject(n, { source: e.captureCamera ? P.CAMERA : P.LOCAL }) 3918 ), this._ctx.$["*currentActivity"] = _.activities.UPLOAD_LIST, this._ctx.setOrAddState("*modalActive", !0), r.remove()); 3919 }, 3920 { 3921 once: !0 3922 } 3923 ), document.querySelectorAll(`[${s}]`).forEach((n) => n.remove()), document.body.appendChild(r), r.dispatchEvent(new MouseEvent("click")); 3924 }; 3925 /** 3926 * @template {import('../types').OutputFileStatus} TStatus 3927 * @param {string} entryId 3928 * @returns {import('../types/exported.js').OutputFileEntry<TStatus>} 3929 */ 3930 getOutputItem = (e) => { 3931 const t = ( 3932 /** @type {import('./uploadEntrySchema.js').UploadEntry} */ 3933 A.getCtx(e).store 3934 ), s = t.fileInfo; 3935 let r = t.isRemoved ? "removed" : t.errors.length > 0 ? "failed" : t.fileInfo ? "success" : t.isUploading ? "uploading" : "idle"; 3936 return { 3937 uuid: s?.uuid ?? t.uuid ?? null, 3938 internalId: e, 3939 name: s?.originalFilename ?? t.fileName, 3940 size: s?.size ?? t.fileSize, 3941 isImage: s?.isImage ?? t.isImage, 3942 mimeType: s?.mimeType ?? t.mimeType, 3943 file: t.file, 3944 externalUrl: t.externalUrl, 3945 cdnUrlModifiers: t.cdnUrlModifiers, 3946 cdnUrl: t.cdnUrl ?? s?.cdnUrl ?? null, 3947 fullPath: t.fullPath, 3948 uploadProgress: t.uploadProgress, 3949 fileInfo: s ?? null, 3950 metadata: t.metadata ?? s?.metadata ?? null, 3951 isSuccess: r === "success", 3952 isUploading: r === "uploading", 3953 isFailed: r === "failed", 3954 isRemoved: r === "removed", 3955 errors: ( 3956 /** @type {import('../types/exported.js').OutputFileEntry['errors']} */ 3957 t.errors 3958 ), 3959 status: r, 3960 source: t?.source 3961 }; 3962 }; 3963 /** @template {import('../types').OutputCollectionStatus} TStatus */ 3964 getOutputCollectionState = () => ( 3965 /** @type {ReturnType<typeof buildOutputCollectionState<TStatus>>} */ 3966 oa(this._ctx) 3967 ); 3968 /** @param {Boolean} [force] */ 3969 initFlow = (e = !1) => { 3970 if (this._uploadCollection.size > 0 && !e) 3971 this._ctx.set$({ 3972 "*currentActivity": _.activities.UPLOAD_LIST 3973 }), this._ctx.setOrAddState("*modalActive", !0); 3974 else if (this._sourceList?.length === 1) { 3975 const t = this._sourceList[0]; 3976 if (t === "local") { 3977 this._ctx.$["*currentActivity"] = _.activities.UPLOAD_LIST, this.openSystemDialog(); 3978 return; 3979 } 3980 const s = this._ctx.$["*blocksRegistry"], r = (o) => "type" in o && o.type === t; 3981 [...s].find(r)?.activate(), this._ctx.$["*currentActivity"] && this._ctx.setOrAddState("*modalActive", !0); 3982 } else 3983 this._ctx.set$({ 3984 "*currentActivity": _.activities.START_FROM 3985 }), this._ctx.setOrAddState("*modalActive", !0); 3986 }; 3987 doneFlow = () => { 3988 this._ctx.set$({ 3989 "*currentActivity": this._ctx.doneActivity, 3990 "*history": this._ctx.doneActivity ? [this._ctx.doneActivity] : [] 3991 }), this._ctx.$["*currentActivity"] || this._ctx.setOrAddState("*modalActive", !1); 3992 }; 3993 /** 3994 * @type {<T extends import('./ActivityBlock.js').ActivityType>( 3995 * activityType: T, 3996 * ...params: T extends keyof import('./ActivityBlock.js').ActivityParamsMap 3997 * ? [import('./ActivityBlock.js').ActivityParamsMap[T]] 3998 * : T extends import('./ActivityBlock.js').RegisteredActivityType 3999 * ? [undefined?] 4000 * : [any?] 4001 * ) => void} 4002 */ 4003 setCurrentActivity = (e, t = void 0) => { 4004 if (this._ctx.hasBlockInCtx((s) => s.activityType === e)) { 4005 this._ctx.set$({ 4006 "*currentActivityParams": t ?? {}, 4007 "*currentActivity": e 4008 }); 4009 return; 4010 } 4011 console.warn(`Activity type "${e}" not found in the context`); 4012 }; 4013 /** @returns {import('./ActivityBlock.js').ActivityType} */ 4014 getCurrentActivity = () => this._ctx.$["*currentActivity"]; 4015 /** @param {boolean} opened */ 4016 setModalState = (e) => { 4017 if (e && !this._ctx.$["*currentActivity"]) { 4018 console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`); 4019 return; 4020 } 4021 this._ctx.setOrAddState("*modalActive", e); 4022 }; 4023 /** 4024 * @private 4025 * @type {string[]} 4026 */ 4027 get _sourceList() { 4028 let e = []; 4029 return this.cfg.sourceList && (e = ce(this.cfg.sourceList)), e; 4030 } 4031} 4032const la = (i, e) => { 4033 const t = e.cfg.imgOnly, s = i.isImage; 4034 if (!(!t || s) && !(!i.fileInfo && i.externalUrl) && !(!i.fileInfo && !i.mimeType)) 4035 return { 4036 type: "NOT_AN_IMAGE", 4037 message: e.l10n("images-only-accepted"), 4038 payload: { entry: i } 4039 }; 4040}, ca = (i, e) => { 4041 const t = e.cfg.imgOnly, s = e.cfg.accept, r = ws([...t ? qt : [], s]); 4042 if (!r.length) return; 4043 const n = i.mimeType, o = i.name; 4044 if (!n || !o) 4045 return; 4046 const a = Cs(n, r), l = Jo(o, r); 4047 if (!a && !l) 4048 return { 4049 type: "FORBIDDEN_FILE_TYPE", 4050 message: e.l10n("file-type-not-allowed"), 4051 payload: { entry: i } 4052 }; 4053}, K = 1e3, ge = Object.freeze({ 4054 AUTO: "auto", 4055 BYTE: "byte", 4056 KB: "kb", 4057 MB: "mb", 4058 GB: "gb", 4059 TB: "tb", 4060 PB: "pb" 4061}), Pe = (i) =>
4061 Math.ceil(i * 100) / 100, ua = (i, e = ge.AUTO) => { 4062 const t = e === ge.AUTO; 4063 if (e === ge.BYTE || t && i < K ** 1) { 4064 const s = ( 4065 /** @type {Extract<import('./getPluralForm').PluralForm, 'one' | 'other'>} */ 4066 es("en-US", i) 4067 ), r = { 4068 one: "byte", 4069 other: "bytes" 4070 }[s]; 4071 return `${i} ${r}`; 4072 } 4073 return e === ge.KB || t && i < K ** 2 ? `${Pe(i / K ** 1)} KB` : e === ge.MB || t && i < K ** 3 ? `${Pe(i / K ** 2)} MB` : e === ge.GB || t && i < K ** 4 ? `${Pe(i / K ** 3)} GB` : e === ge.TB || t && i < K ** 5 ? `${Pe(i / K ** 4)} TB` : `${Pe(i / K ** 5)} PB`; 4074}, da = (i, e) => { 4075 const t = e.cfg.maxLocalFileSizeBytes, s = i.size; 4076 if (t && s && s > t) 4077 return { 4078 type: "FILE_SIZE_EXCEEDED", 4079 message: e.l10n("files-max-size-limit-error", { maxFileSize: ua(t) }), 4080 payload: { entry: i } 4081 }; 4082}, ha = (i, e) => { 4083 const { internalId: t } = i, r = e._uploadCollection.read(t)?.getValue("uploadError"); 4084 if (!r) 4085 return; 4086 if (r instanceof F) 4087 return { 4088 type: "UPLOAD_ERROR", 4089 message: r.message, 4090 payload: { 4091 entry: i, 4092 error: r 4093 } 4094 }; 4095 if (r instanceof Be) 4096 return { 4097 type: "NETWORK_ERROR", 4098 message: r.message, 4099 payload: { 4100 entry: i, 4101 error: r 4102 } 4103 }; 4104 const n = r instanceof Error ? r : new Error("Unknown error", { cause: r }); 4105 return { 4106 type: "UNKNOWN_ERROR", 4107 message: n.message, 4108 payload: { 4109 entry: i, 4110 error: n 4111 } 4112 }; 4113}, fa = (i, e) => { 4114 if (i.failedCount > 0) 4115 return { 4116 type: "SOME_FILES_HAS_ERRORS", 4117 message: e.l10n("some-files-were-not-uploaded") 4118 }; 4119}, pa = (i, e) => { 4120 const t = i.totalCount, s = e.cfg.multiple ? e.cfg.multipleMin : 0, r = e.cfg.multiple ? e.cfg.multipleMax : 1; 4121 if (s && t < s) 4122 return { 4123 type: "TOO_FEW_FILES", 4124 message: e.l10n("files-count-limit-error-too-few", { 4125 min: s, 4126 max: r, 4127 total: t 4128 }), 4129 payload: { 4130 total: t, 4131 min: s, 4132 max: r 4133 } 4134 }; 4135 if (r && t > r) 4136 return { 4137 type: "TOO_MANY_FILES", 4138 message: e.l10n("files-count-limit-error-too-many", { 4139 min: s, 4140 max: r, 4141 total: t 4142 }), 4143 payload: { 4144 total: t, 4145 min: s, 4146 max: r 4147 } 4148 }; 4149}, Ge = { 4150 file: "File validator execution has failed", 4151 collection: "Collection validator execution has failed", 4152 message: "Missing message. We recommend adding message: value." 4153}; 4154class ma { 4155 /** 4156 * @private 4157 * @type {import('./UploaderBlock.js').UploaderBlock} 4158 */ 4159 _blockInstance; 4160 /** @type {FuncFileValidator[]} */ 4161 _fileValidators = [la, ca, da, ha]; 4162 /** @type {FuncCollectionValidator[]} */ 4163 _collectionValidators = [pa, fa]; 4164 /** @param {import('./UploaderBlock.js').UploaderBlock} blockInstance */ 4165 constructor(e) { 4166 this._blockInstance = e, this._uploadCollection = this._blockInstance.uploadCollection; 4167 const t = () => { 4168 this.runFileValidators(), this.runCollectionValidators(); 4169 }; 4170 this._blockInstance.subConfigValue("maxLocalFileSizeBytes", t), this._blockInstance.subConfigValue("multipleMin", t), this._blockInstance.subConfigValue("multipleMax", t), this._blockInstance.subConfigValue("multiple", t), this._blockInstance.subConfigValue("imgOnly", t), this._blockInstance.subConfigValue("accept", t); 4171 } 4172 /** @param {string[]} [entryIds] */ 4173 runFileValidators(e) { 4174 const t = e ?? this._uploadCollection.items(); 4175 for (const s of t) { 4176 const r = this._uploadCollection.read(s); 4177 r && this._runFileValidatorsForEntry(r); 4178 } 4179 } 4180 runCollectionValidators() { 4181 const e = this._blockInstance.api.getOutputCollectionState(), t = []; 4182 for (const s of [ 4183 ...this._collectionValidators, 4184 ...this._addCustomTypeToValidators(this._blockInstance.cfg.collectionValidators) 4185 ]) 4186 try { 4187 const r = s(e, this._blockInstance.api); 4188 if (!r) 4189 continue; 4190 r && (t.push(r), r.message || console.warn(Ge.message)); 4191 } catch (r) { 4192 console.warn(Ge.collection, r); 4193 } 4194 this._blockInstance.$["*collectionErrors"] = t, t.length > 0 && this._blockInstance.emit( 4195 O.COMMON_UPLOAD_FAILED, 4196 () => ( 4197 /** @type {import('../types').OutputCollectionState<'failed'>} */ 4198 this._blockInstance.api.getOutputCollectionState() 4199 ), 4200 { debounce: !0 } 4201 ); 4202 } 4203 /** 4204 * @private 4205 * @param {import('./TypedData.js').TypedData}
4205 entry 4206 */ 4207 _runFileValidatorsForEntry(e) { 4208 const t = this._blockInstance.api.getOutputItem(e.uid), s = []; 4209 for (const r of [ 4210 ...this._fileValidators, 4211 ...this._addCustomTypeToValidators(this._blockInstance.cfg.fileValidators) 4212 ]) 4213 try { 4214 const n = r(t, this._blockInstance.api); 4215 if (!n) 4216 continue; 4217 n && (s.push(n), n.message || console.warn(Ge.message)); 4218 } catch (n) { 4219 console.warn(Ge.file, n); 4220 } 4221 e.setValue("errors", s); 4222 } 4223 /** 4224 * @template T 4225 * @param {T[]} validators 4226 * @returns {T[]} 4227 */ 4228 _addCustomTypeToValidators(e) { 4229 return e.map((t) => (...s) => { 4230 const r = t(...s); 4231 return r ? { ...r, type: "CUSTOM_ERROR" } : void 0; 4232 }); 4233 } 4234} 4235const ga = Object.freeze({ 4236 file: { 4237 type: File, 4238 value: null 4239 }, 4240 externalUrl: { 4241 type: String, 4242 value: null 4243 }, 4244 fileName: { 4245 type: String, 4246 value: null, 4247 nullable: !0 4248 }, 4249 fileSize: { 4250 type: Number, 4251 value: null, 4252 nullable: !0 4253 }, 4254 lastModified: { 4255 type: Number, 4256 value: Date.now() 4257 }, 4258 uploadProgress: { 4259 type: Number, 4260 value: 0 4261 }, 4262 uuid: { 4263 type: String, 4264 value: null 4265 }, 4266 isImage: { 4267 type: Boolean, 4268 value: !1 4269 }, 4270 mimeType: { 4271 type: String, 4272 value: null, 4273 nullable: !0 4274 }, 4275 ctxName: { 4276 type: String, 4277 value: null 4278 }, 4279 cdnUrl: { 4280 type: String, 4281 value: null 4282 }, 4283 cdnUrlModifiers: { 4284 type: String, 4285 value: null 4286 }, 4287 fileInfo: { 4288 type: Ht, 4289 value: null 4290 }, 4291 isUploading: { 4292 type: Boolean, 4293 value: !1 4294 }, 4295 abortController: { 4296 type: AbortController, 4297 value: null, 4298 nullable: !0 4299 }, 4300 thumbUrl: { 4301 type: String, 4302 value: null, 4303 nullable: !0 4304 }, 4305 silent: { 4306 type: Boolean, 4307 value: !1 4308 }, 4309 source: { 4310 type: String, 4311 value: !1, 4312 nullable: !0 4313 }, 4314 fullPath: { 4315 type: String, 4316 value: null, 4317 nullable: !0 4318 }, 4319 metadata: { 4320 type: Object, 4321 value: null, 4322 nullable: !0 4323 }, 4324 errors: { 4325 type: Array, 4326 value: [] 4327 }, 4328 uploadError: { 4329 type: Error, 4330 value: null, 4331 nullable: !0 4332 }, 4333 isRemoved: { 4334 type: Boolean, 4335 value: !1 4336 } 4337}); 4338class U extends _ { 4339 /** @protected */ 4340 couldBeCtxOwner = !1; 4341 /** @private */ 4342 isCtxOwner = !1; 4343 init$ = gs(this); 4344 /** @private */ 4345 get hasCtxOwner() { 4346 return this.hasBlockInCtx((e) => e instanceof U ? e.isCtxOwner && e.isConnected && e !== this : !1); 4347 } 4348 /** @protected */ 4349 initCallback() { 4350 if (super.initCallback(), !this.has("*uploadCollection")) { 4351 let e = new Yo({ 4352 typedSchema: ga, 4353 watchList: ["uploadProgress", "uploadError", "fileInfo", "errors", "cdnUrl", "isUploading"] 4354 }); 4355 this.add("*uploadCollection", e); 4356 } 4357 this.has("*publicApi") || this.add("*publicApi", new aa(this)), this.has("*validationManager") || this.add("*validationManager", new ma(this)), !this.hasCtxOwner && this.couldBeCtxOwner && this.initCtxOwner(); 4358 } 4359 /** 4360 * @returns {ValidationManager} 4361 * @protected 4362 */ 4363 get validationManager() { 4364 if (!this.has("*validationManager")) 4365 throw new Error("Unexpected error: ValidationManager is not initialized"); 4366 return this.$["*validationManager"]; 4367 } 4368 /** @returns {UploaderPublicApi} */ 4369 get api() { 4370 if (!this.has("*publicApi")) 4371 throw new Error("Unexpected error: UploaderPublicApi is not initialized"); 4372 return this.$["*publicApi"]; 4373 } 4374 getAPI() { 4375 return this.api; 4376 } 4377 /** @returns {TypedCollection} */ 4378 get uploadCollection() { 4379 if (!this.has("*uploadCollection")) 4380 throw new Error("Unexpected error: TypedCollection is not initialized"); 4381 return this.$["*uploadCollection"]; 4382 } 4383 /** @protected */ 4384 destroyCtxCallback() { 4385 this._unobserveCollectionProperties?.(), this._unobserveCollection?.(), this.uploadCollection.destroy(), this.$["*uploadCollection"] = null, super.destroyCtxCallback(); 4386 } 4387 /** @private */ 4388 initCtxOwner() { 4389 this.isCtxOwner = !0, this._unobserveCollection = this.uploadCollection.observeCollection(this._handleCollectionUpdate), this._unobserveCollectionProperties = this.uploadCollection.observeProperties( 4390 this._handleCollectionPropertiesUpdate 4391 ), this.subConfigValue("maxConcurrentRequests", (e) => { 4392 this.$["*uploadQueue"].concurrency = Number(e) || 1; 4393 }), this.$["*secureUploadsManager"] || (this.$["*secureUploadsManager"] = new Xo(this)), this.has("*modalActive") && this.sub("*modalActive", (e) => { 4394 e && !this.$["*currentActivity"] && (this.$["*modalActive"] = !1); 4395 }); 4396 } 4397 /** 4398 * @private 4399 * @param {import('../types').OutputCollectionState} collectionState 4400 */ 4401 async _createGroup(e) { 4402 const t = await this.getUploadClientOptions(), s = e.allEntries.map((a) => a.uuid + (a.cdnUrlModifiers ? `/${a.cdnUrlModifiers}` : "")), r = new AbortController(), n = await ao(s, { ...t, signal: r.signal }); 4403 if (this.$["*collectionState"] !== e) { 4404 r.abort(); 4405 return; 4406 } 4407 this.$["*groupInfo"] = n; 4408 const o = ( 4409 /** @type {import('../types').OutputCollectionState<'success', 'has-group'>} */ 4410 this.api.getOutputCollectionState() 4411 );
4412 this.emit(O.GROUP_CREATED, o), this.emit(O.CHANGE, () => this.api.getOutputCollectionState(), { debounce: !0 }), this.$["*collectionState"] = o; 4413 } 4414 /** @private */ 4415 _flushOutputItems = G(async () => { 4416 if (this.getOutputData().length !== this.uploadCollection.size) 4417 return; 4418 const t = this.api.getOutputCollectionState(); 4419 this.$["*collectionState"] = t, this.emit(O.CHANGE, () => this.api.getOutputCollectionState(), { debounce: !0 }), this.cfg.groupOutput && t.totalCount > 0 && t.status === "success" && this._createGroup(t); 4420 }, 300); 4421 /** 4422 * @private 4423 * @type {Parameters<import('./TypedCollection.js').TypedCollection['observeCollection']>[0]} 4424 * @param {Set<import('./TypedData.js').TypedData>} removed 4425 */ 4426 _handleCollectionUpdate = (e, t, s) => { 4427 (t.size || s.size) && (this.$["*groupInfo"] = null), this.validationManager.runFileValidators(), this.validationManager.runCollectionValidators(); 4428 for (const r of t) 4429 r.getValue("silent") || this.emit(O.FILE_ADDED, this.api.getOutputItem(r.uid)); 4430 for (const r of s) 4431 this.$["*uploadTrigger"].delete(r.uid), r.getValue("abortController")?.abort(), r.setMultipleValues({ 4432 isRemoved: !0, 4433 abortController: null, 4434 isUploading: !1, 4435 uploadProgress: 0 4436 }), URL.revokeObjectURL(r?.getValue("thumbUrl")), this.emit(O.FILE_REMOVED, this.api.getOutputItem(r.uid)); 4437 this.$["*uploadList"] = e.map((r) => ({ uid: r })), this._flushCommonUploadProgress(), this._flushOutputItems(); 4438 }; 4439 /** 4440 * @private 4441 * @param {Record<keyof import('./uploadEntrySchema.js').UploadEntry, Set<string>>} changeMap 4442 */ 4443 _handleCollectionPropertiesUpdate = (e) => { 4444 this._flushOutputItems(); 4445 const t = this.uploadCollection, s = [ 4446 ...new Set( 4447 Object.entries(e).filter(([r]) => ["uploadError", "fileInfo"].includes(r)).map(([, r]) => [...r]).flat() 4448 ) 4449 ]; 4450 if (s.length > 0 && setTimeout(() => { 4451 this.validationManager.runFileValidators(s); 4452 }), e.uploadProgress) { 4453 for (const r of e.uploadProgress) { 4454 const { isUploading: n, silent: o } = A.getCtx(r).store; 4455 n && !o && this.emit(O.FILE_UPLOAD_PROGRESS, this.api.getOutputItem(r)); 4456 } 4457 this._flushCommonUploadProgress(); 4458 } 4459 if (e.isUploading) 4460 for (const r of e.isUploading) { 4461 const { isUploading: n, silent: o } = A.getCtx(r).store; 4462 n && !o && this.emit(O.FILE_UPLOAD_START, this.api.getOutputItem(r)); 4463 } 4464 if (e.fileInfo) { 4465 for (const r of e.fileInfo) { 4466 const { fileInfo: n, silent: o } = A.getCtx(r).store; 4467 n && !o && this.emit(O.FILE_UPLOAD_SUCCESS, this.api.getOutputItem(r)); 4468 } 4469 this.cfg.cropPreset && this.setInitialCrop(); 4470 } 4471 if (e.errors) { 4472 for (const o of e.errors) { 4473 const { errors: a } = A.getCtx(o).store; 4474 a.length >
4474 0 && (this.emit(O.FILE_UPLOAD_FAILED, this.api.getOutputItem(o)), this.emit( 4475 O.COMMON_UPLOAD_FAILED, 4476 () => ( 4477 /** @type {import('../types').OutputCollectionState<'failed'>} */ 4478 this.api.getOutputCollectionState() 4479 ), 4480 { debounce: !0 } 4481 )); 4482 } 4483 const r = t.findItems((o) => !!o.getValue("fileInfo")), n = t.findItems((o) => o.getValue("errors").length > 0); 4484 t.size > 0 && n.length === 0 && t.size === r.length && this.$["*collectionErrors"].length === 0 && this.emit( 4485 O.COMMON_UPLOAD_SUCCESS, 4486 /** @type {import('../types').OutputCollectionState<'success'>} */ 4487 this.api.getOutputCollectionState() 4488 ); 4489 } 4490 e.cdnUrl && ([...e.cdnUrl].filter((n) => !!this.uploadCollection.read(n)?.getValue("cdnUrl")).forEach((n) => { 4491 this.emit(O.FILE_URL_CHANGED, this.api.getOutputItem(n)); 4492 }), this.$["*groupInfo"] = null); 4493 }; 4494 /** @private */ 4495 _flushCommonUploadProgress = () => { 4496 let e = 0; 4497 const s = [...this.$["*uploadTrigger"]].filter((n) => !!this.uploadCollection.read(n));
4498 s.forEach((n) => { 4499 const o = this.uploadCollection.readProp(n, "uploadProgress"); 4500 e += o; 4501 }); 4502 const r = s.length ? Math.round(e / s.length) : 0; 4503 this.$["*commonProgress"] !== r && (this.$["*commonProgress"] = r, this.emit( 4504 O.COMMON_UPLOAD_PROGRESS, 4505 /** @type {import('../types').OutputCollectionState<'uploading'>} */ 4506 this.api.getOutputCollectionState() 4507 )); 4508 }; 4509 /** @private */ 4510 setInitialCrop() { 4511 const e = vs(this.cfg.cropPreset); 4512 if (e) { 4513 const [t] = e, s = this.uploadCollection.findItems( 4514 (r) => r.getValue("fileInfo") && r.getValue("isImage") && !r.getValue("cdnUrlModifiers")?.includes("/crop/") 4515 ).map((r) => this.uploadCollection.read(r)); 4516 for (const r of s) { 4517 const n = r.getValue("fileInfo"), { width: o, height: a } = n.imageInfo, l = t.width / t.height, c = Go(o, a, l), d = le( 4518 `crop/${c.width}x${c.height}/${c.x},${c.y}`, 4519 "preview" 4520 ); 4521 r.setMultipleValues({ 4522 cdnUrlModifiers: d, 4523 cdnUrl: j(r.getValue("cdnUrl"), d) 4524 }), this.uploadCollection.size === 1 && this.cfg.useCloudImageEditor && this.hasBlockInCtx((u) => u.activityType === _.activities.CLOUD_IMG_EDIT) && (this.$["*currentActivityParams"] = { 4525 internalId: r.uid 4526 }, this.$["*currentActivity"] = _.activities.CLOUD_IMG_EDIT); 4527 } 4528 } 4529 } 4530 /** 4531 * @param {string} entryId 4532 * @protected 4533 */ 4534 async getMetadataFor(e) { 4535 const t = this.cfg.metadata || void 0; 4536 if (typeof t == "function") { 4537 const s = this.api.getOutputItem(e); 4538 return await t(s); 4539 } 4540 return t; 4541 } 4542 /** 4543 * @returns {Promise<import('@uploadcare/upload-client').FileFromOptions>} 4544 * @protected 4545 */ 4546 async getUploadClientOptions() { 4547 const t = await this.$["*secureUploadsManager"].getSecureToken().catch(() => null); 4548 return { 4549 store: this.cfg.store, 4550 publicKey: this.cfg.pubkey, 4551 baseCDN: this.cfg.cdnCname, 4552 baseURL: this.cfg.baseUrl, 4553 userAgent: Wo, 4554 integration: this.cfg.userAgentIntegration, 4555 secureSignature: t?.secureSignature, 4556 secureExpire: t?.secureExpire, 4557 retryThrottledRequestMaxTimes: this.cfg.retryThrottledRequestMaxTimes, 4558 multipartMinFileSize: this.cfg.multipartMinFileSize, 4559 multipartChunkSize: this.cfg.multipartChunkSize, 4560 maxConcurrentRequests: this.cfg.multipartMaxConcurrentRequests, 4561 multipartMaxAttempts: this.cfg.multipartMaxAttempts, 4562 checkForUrlDuplicates: !!this.cfg.checkForUrlDuplicates, 4563 saveUrlForRecurrentUploads: !!this.cfg.saveUrlForRecurrentUploads 4564 }; 4565 } 4566 /** @returns {import('../types/exported.js').OutputFileEntry[]} */ 4567 getOutputData() { 4568 return this.uploadCollection.items().map((s) => this.api.getOutputItem(s)); 4569 } 4570} 4571U.extSrcList = Object.freeze({ 4572 ...mt 4573}); 4574U.sourceTypes = Object.freeze({ 4575 ...P 4576}); 4577const gt = (i) => i.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map((e) => e.toLowerCase()).join("-"), L = (i) => String(i), N = (i) => { 4578 const e = Number(i); 4579 if (Number.isNaN(e)) 4580 throw new Error(`Invalid number: "${i}"`); 4581 return e; 4582}, $ = (i) => { 4583 if (typeof i > "u" || i === null) return !1; 4584 if (typeof i == "boolean") return i; 4585 if (i === "true" || i === "") return !0; 4586 if (i === "false") return !1; 4587 throw new Error(`Invalid boolean: "${i}"`); 4588}, ba = (i) => i === "auto" ? i : $(i), _a = (i) => { 4589 const e = L(i); 4590 if (e !== "user" && e !== "environment" && e !== "") 4591 throw new Error(`Invalid "cameraCapture" value: "${e}"`); 4592 return e; 4593}, ya = (i) => { 4594 const e = L(i); 4595 if (e !== "photo" && e !== "video") 4596 throw new Error(`Invalid "CameraTab" value: "${e}"`); 4597 return e; 4598}, va = (i) => { 4599 if (typeof i == "object" && !Array.isArray(i) || typeof i == "function") 4600 return ( 4601 /** @type {import('../../types').MetadataCallback} */ 4602 i 4603 ); 4604 throw new Error("Invalid metadata value. Must be an object or function."); 4605}, Ai = (i) => { 4606 if (typeof i == "object") 4607 return ( 4608 /** @type {T} */ 4609 i 4610 ); 4611 throw new Error("Invalid value. Must be an object."); 4612}, Et = (i) => { 4613 if (typeof i == "function") 4614 return ( 4615 /** @type {T} */ 4616 i 4617 ); 4618 throw new Error("Invalid value. Must be a function."); 4619}, Ei = (i) => { 4620 if (Array.isArray(i)) 4621 return ( 4622 /** @type {T} */ 4623 i 4624 );
4625 throw new Error("Must be an array."); 4626}, wa = { 4627 pubkey: L, 4628 multiple: $, 4629 multipleMin: N, 4630 multipleMax: N, 4631 confirmUpload: $, 4632 imgOnly: $, 4633 accept: L, 4634 externalSourcesPreferredTypes: L, 4635 externalSourcesEmbedCss: L, 4636 store: ba, 4637 cameraMirror: $, 4638 cameraCapture: _a, 4639 sourceList: L, 4640 maxLocalFileSizeBytes: N, 4641 thumbSize: N, 4642 showEmptyList: $, 4643 useLocalImageEditor: $, 4644 useCloudImageEditor: $, 4645 cloudImageEditorTabs: L, 4646 removeCopyright: $, 4647 cropPreset: L, 4648 imageShrink: L, 4649 modalScrollLock: $, 4650 modalBackdropStrokes: $, 4651 sourceListWrap: $, 4652 remoteTabSessionKey: L, 4653 cdnCname: L, 4654 baseUrl: L, 4655 socialBaseUrl: L, 4656 secureSignature: L, 4657 secureExpire: L, 4658 secureDeliveryProxy: L, 4659 retryThrottledRequestMaxTimes: N, 4660 multipartMinFileSize: N, 4661 multipartChunkSize: N, 4662 maxConcurrentRequests: N, 4663 multipartMaxConcurrentRequests: N, 4664 multipartMaxAttempts: N, 4665 checkForUrlDuplicates: $, 4666 saveUrlForRecurrentUploads: $, 4667 groupOutput: $, 4668 userAgentIntegration: L, 4669 debug: $, 4670 localeName: L, 4671 metadata: va, 4672 secureUploadsExpireThreshold: N, 4673 localeDefinitionOverride: ( 4674 /** @type {typeof asObject<import('../../types').LocaleDefinitionOverride>} */ 4675 Ai 4676 ), 4677 secureUploadsSignatureResolver: ( 4678 /** @type {typeof asFunction<import('../../types').SecureUploadsSignatureResolver>} */ 4679 Et 4680 ), 4681 secureDeliveryProxyUrlResolver: ( 4682 /** @type {typeof asFunction<import('../../types').SecureDeliveryProxyUrlResolver>} */ 4683 Et 4684 ), 4685 iconHrefResolver: ( 4686 /** @type {typeof asFunction<import('../../types').IconHrefResolver>} */ 4687 Et 4688 ), 4689 fileValidators: ( 4690 /** @type {typeof asArray<import('../../types').FileValidators>} */ 4691 Ei 4692 ), 4693 collectionValidators: ( 4694 /** @type {typeof asArray<import('../../types').CollectionValidators>} */ 4695 Ei 4696 ), 4697 defaultCameraMode: ya, 4698 enableAudioRecording: $, 4699 enableVideoRecording: $, 4700 mediaRecorerOptions: Ai, 4701 maxVideoRecordingDuration: N 4702}, Ca = (i, e) => { 4703 if (!(typeof e > "u" || e === null)) 4704 try { 4705 return wa[i](e); 4706 } catch (t) { 4707 return console.error(`Invalid value for config key "${i}".`, t), oe[i]; 4708 } 4709}, Xt = ( 4710 /** @type {(keyof import('../../types').ConfigType)[]} */ 4711 [ 4712 // "debug" option should go first to be able to print debug messages from the very beginning 4713 .../* @__PURE__ */ new Set(["debug", ...Object.keys(oe)]) 4714 ] 4715), Aa = [ 4716 "metadata", 4717 "localeDefinitionOverride", 4718 "secureUploadsSignatureResolver", 4719 "secureDeliveryProxyUrlResolver", 4720 "iconHrefResolver", 4721 "fileValidators", 4722 "collectionValidators", 4723 "mediaRecorerOptions" 4724], Ea = (i) => Aa.includes(i), $e = ( 4725 /** @type {(keyof import('../../types').ConfigPlainType)[]} */ 4726 Xt.filter((i) => !Ea(i)) 4727), Ta = ( 4728 /** @type {Record<keyof import('../../types').ConfigAttributesType, keyof import('../../types').ConfigPlainType>} */ 4729 { 4730 ...Object.fromEntries($e.map((i) => [gt(i), i])), 4731 ...Object.fromEntries($e.map((i) => [i.toLowerCase(), i])) 4732 } 4733), xa = ( 4734 /** @type {Record<keyof import('../../types').ConfigAttributesType, string>} */ 4735 { 4736 ...Object.fromEntries($e.map((i) => [gt(i), H(i)])), 4737 ...Object.fromEntries($e.map((i) => [i.toLowerCase(), H(i)])) 4738 } 4739), Ti = (i) => "__" + i; 4740class Zt extends k { 4741 requireCtxName = !0; 4742 constructor() { 4743 super(), this.init$ = { 4744 ...this.init$, 4745 ...Object.fromEntries( 4746 Object.entries(oe).map(([e, t]) => [ 4747 H( 4748 /** @type {keyof import('../../types').ConfigType} */ 4749 e 4750 ), 4751 t 4752 ]) 4753 ) 4754 }; 4755 } 4756 /** 4757 * @private 4758 * @param {keyof import('../../types').ConfigType} key 4759 * @param {unknown} value 4760 */ 4761 _flushValueToAttribute(e, t) { 4762 if ($e.includes(e)) { 4763 const s = [.../* @__PURE__ */ new Set([gt(e), e.toLowerCase()])]; 4764 for (const r of s) 4765 typeof t > "u" || t === null ? this.removeAttribute(r) : this.getAttribute(r) !== t.toString() && this.setAttribute(r, t.toString()); 4766 } 4767 } 4768 /** 4769 * @private 4770 * @param {keyof import('../../types').ConfigType} key 4771 * @param {unknown} value 4772 */ 4773 _flushValueToState(e, t) { 4774 this.$[H(e)] !== t && (typeof t > "u" || t === null ? this.$[H(e)] = oe[e] : this.$[H(e)] = t); 4775 } 4776 /** 4777 * @private 4778 * @param {keyof import('../../types').ConfigType} key 4779 * @param {unknown} value 4780 */ 4781 _setValue(e, t) { 4782 const s = ( 4783 /** @type {typeof this & any} */ 4784 this 4785 ), r = Ca(e, t), n = Ti(e);
4786 s[n] !== r && (this._assertSameValueDifferentReference(e, s[n], r), s[n] = r, this._flushValueToAttribute(e, r), this._flushValueToState(e, r), this.debugPrint(`[uc-config] "${e}"`, r)); 4787 } 4788 /** 4789 * @private 4790 * @param {keyof import('../../types').ConfigType} key 4791 */ 4792 _getValue(e) { 4793 const t = ( 4794 /** @type {typeof this & any} */ 4795 this 4796 ), s = Ti(e); 4797 return t[s]; 4798 } 4799 /** 4800 * @param {string} key 4801 * @param {unknown} previousValue 4802 * @param {unknown} nextValue 4803 */ 4804 _assertSameValueDifferentReference(e, t, s) { 4805 this.cfg.debug && s !== t && typeof s == "object" && typeof t == "object" && JSON.stringify(s) === JSON.stringify(t) && (console.warn( 4806 `[uc-config] Option "${e}" value is the same as the previous one but the reference is different` 4807 ), console.warn( 4808 "[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations" 4809 ), console.warn(`[uc-config] "${e}" previous value:`, t), console.warn(`[uc-config] "${e}" new value:`, s)); 4810 } 4811 initCallback() { 4812 super.initCallback(); 4813 const e = ( 4814 /** @type {typeof this & any} */ 4815 this 4816 ); 4817 for (const t of $e) 4818 this.sub( 4819 H(t), 4820 (s) => { 4821 this._setValue(t, s); 4822 }, 4823 !1 4824 ); 4825 for (const t of Xt) { 4826 const s = e[t] ?? this.$[H(t)]; 4827 s !== oe[t] && this._setValue(t, s), Object.defineProperty(this, t, { 4828 /** @param {unknown} value */ 4829 set: (r) => { 4830 this._setValue(t, r); 4831 }, 4832 get: () => this._getValue(t) 4833 }); 4834 } 4835 } 4836 /** 4837 * @param {keyof typeof attrStateMapping} name 4838 * @param {string} oldVal 4839 * @param {string} newVal 4840 */ 4841 attributeChangedCallback(e, t, s) { 4842 if (t === s) return; 4843 const r = ( 4844 /** @type {typeof this & any} */ 4845 this 4846 ), n = Ta[e]; 4847 r[n] = s; 4848 } 4849} 4850Zt.bindAttributes(xa); 4851for (const i of Xt) 4852 Zt.prototype[i] = void 0; 4853const Sa = ( 4854 /** @type {Config} */ 4855 /** @type {unknown} */ 4856 Zt 4857); 4858class Kt extends k { 4859 constructor() { 4860 super(), this.init$ = { 4861 ...this.init$, 4862 name: "", 4863 href: "" 4864 }; 4865 } 4866 initCallback() { 4867 super.initCallback(), this.sub("name", (e) => { 4868 if (!e) 4869 return; 4870 let t = `#uc-icon-${e}`; 4871 this.subConfigValue("iconHrefResolver", (s) => { 4872 s && (t = s(e) ?? t), this.$.href = t; 4873 }); 4874 }); 4875 } 4876} 4877Kt.template = /* HTML */ 4878` 4879 <svg ref="svg" xmlns="http://www.w3.org/2000/svg"> 4880 <use set="@href: href;"></use> 4881 </svg> 4882`; 4883Kt.bindAttributes({ 4884 name: "name" 4885}); 4886const $a = (i) => [...new Set(i)], ka = (i) => Object.entries(i).filter(([e, t]) => t !== void 0 && t !== "").map(([e, t]) => e === "cdn-operations" || e === "analytics" ? t : `${e}/${t}`), Ia = "https://ucarecdn.com", it = Object.freeze({ 4887 "dev-mode": {}, 4888 pubkey: {}, 4889 uuid: {}, 4890 src: {}, 4891 // alt: {}, 4892 // 'placeholder-src': {}, // available via CSS 4893 lazy: { 4894 default: 1 4895 }, 4896 intersection: {}, 4897 breakpoints: { 4898 // '200, 300, 400' 4899 }, 4900 "cdn-cname": { 4901 default: Ia 4902 }, 4903 "proxy-cname": {}, 4904 "secure-delivery-proxy": {}, 4905 "hi-res-support": { 4906 default: 1 4907 }, 4908 "ultra-res-support": {}, 4909 // ? 4910 format: {}, 4911 "cdn-operations": {}, 4912 progressive: {}, 4913 quality: {}, 4914 "is-background-for": {}, 4915 "is-preview-blur": { 4916 default: 1 4917 } 4918}), Fe = "--uc-img-", xi = "unresolved", We = 2, qe = 3, Si = !window.location.host.trim() || window.location.host.includes(":") || window.location.hostname.includes("localhost"), $i = 3e3, ki = 5e3, Ii = Object.freeze({ 4919 PREVIEW: "PREVIEW", 4920 MAIN: "MAIN" 4921}), As = /* @__PURE__ */ Object.create(null); 4922for (let i in it) 4923 As[Fe + i] = it[i]?.default || ""; 4924class Oa extends ze { 4925 cssInit$ = As; 4926 /** 4927 * @param {String} key 4928 * @returns {any} 4929 */ 4930 $$(e) { 4931 return this.$[Fe + e]; 4932 } 4933 /** @param {Object<String, String | Number>} kvObj */ 4934 set$$(e) { 4935 for (let t in e) 4936 this.$[Fe + t] = e[t]; 4937 } 4938 /** 4939 * @param {String} key 4940 * @param {(val: any) => void} kbFn 4941 */ 4942 sub$$(e, t) { 4943 this.sub(Fe + e, (s) => { 4944 s === null || s === "" || t(s); 4945 }); 4946 } 4947 analyticsParams() { 4948 return `-/@clib/${ft}/${pt}/uc-img/`; 4949 } 4950 initAttributes(e) {
4951 [...this.attributes].forEach((t) => { 4952 it[t.name] || e.setAttribute(t.name, t.value); 4953 }); 4954 } 4955 /** 4956 * @param {HTMLElement} el 4957 * @param {() => void} cbkFn 4958 */ 4959 initIntersection(e, t) { 4960 let s = { 4961 root: null, 4962 rootMargin: "0px" 4963 }; 4964 this._isnObserver = new IntersectionObserver((r) => { 4965 r.forEach((n) => { 4966 n.isIntersecting && (t(), this._isnObserver.unobserve(e)); 4967 }); 4968 }, s), this._isnObserver.observe(e), this._observed || (this._observed = /* @__PURE__ */ new Set()), this._observed.add(e); 4969 } 4970 destroyCallback() { 4971 super.destroyCallback(), this._isnObserver && (this._observed.forEach((e) => { 4972 this._isnObserver.unobserve(e); 4973 }), this._isnObserver = null), A.deleteCtx(this); 4974 } 4975 static get observedAttributes() { 4976 return Object.keys(it); 4977 } 4978 attributeChangedCallback(e, t, s) { 4979 window.setTimeout(() => { 4980 this.$[Fe + e] = s; 4981 }); 4982 } 4983} 4984class La extends Oa { 4985 _img = new Image(); 4986 _imgPreview = new Image(); 4987 /** 4988 * @private 4989 * @param {String} src 4990 */ 4991 _fmtAbs(e) { 4992 return !e.includes("//") && !Si && (e = new URL(e, document.baseURI).href), e; 4993 } 4994 /** 4995 * Validate size 4996 * 4997 * @param {String} [size] 4998 * @returns {String | Number} 4999 */ 5000 _validateSize(e) { 5001 if (e?.trim() !== "") { 5002 let t = e.match(/\d+/)[0], s = e.match(/[a-zA-Z]+/)[0]; 5003 const r = parseInt(t, 10); 5004 if (Number(r) > ki && this.hasFormatJPG) 5005 return ki + s; 5006 if (Number(r) > $i && !this.hasFormatJPG) 5007 return $i + s; 5008 } 5009 return e; 5010 } 5011 /** 5012 * Image operations 5013 * 5014 * @param {String} [size] 5015 * @param {String} [blur] 5016 */ 5017 _getCdnModifiers(e, t) { 5018 const s = { 5019 format: this.$$("format"), 5020 quality: this.$$("quality"), 5021 resize: this._validateSize(e), 5022 blur: t, 5023 "cdn-operations": this.$$("cdn-operations"), 5024 analytics: this.analyticsParams() 5025 }; 5026 return le(...ka(s)); 5027 } 5028 /** 5029 * @private 5030 * @param {String} [size] 5031 * @param {String} [blur] 5032 * @returns {any} 5033 */ 5034 _getUrlBase(e = "", t = "") { 5035 if (this.$$("src").startsWith("data:") || this.$$("src").startsWith("blob:")) 5036 return this.$$("src"); 5037 if (Si && this.$$("src") && !this.$$("src").includes("//")) 5038 return this._proxyUrl(this.$$("src")); 5039 let s = this._getCdnModifiers(e, t); 5040 if (this.$$("src").startsWith(this.$$("cdn-cname"))) 5041 return j(this.$$("src"), s); 5042 if (this.$$("cdn-cname") && this.$$("uuid")) 5043 return this._proxyUrl( 5044 j( 5045 // 5046 Ve(this.$$("cdn-cname"), this.$$("uuid")), 5047 s 5048 ) 5049 ); 5050 if (this.$$("uuid")) 5051 return this._proxyUrl( 5052 j( 5053 // 5054 Ve(this.$$("cdn-cname"), this.$$("uuid")), 5055 s 5056 ) 5057 ); 5058 if (this.$$("proxy-cname")) 5059 return this._proxyUrl( 5060 j( 5061 // 5062 this.$$("proxy-cname"), 5063 s, 5064 this._fmtAbs(this.$$("src")) 5065 ) 5066 ); 5067 if (this.$$("pubkey")) 5068 return this._proxyUrl( 5069 j( 5070 // 5071 `https://${this.$$("pubkey")}.ucr.io/`, 5072 s, 5073 this._fmtAbs(this.$$("src")) 5074 ) 5075 ); 5076 } 5077 /** 5078 * @private 5079 * @param {String} url 5080 * @returns {String} 5081 */ 5082 _proxyUrl(e) { 5083 return this.$$("secure-delivery-proxy") ? kt( 5084 this.$$("secure-delivery-proxy"), 5085 { previewUrl: e }, 5086 { transform: (s) => window.encodeURIComponent(s) } 5087 ) : e; 5088 } 5089 /** 5090 * @param {HTMLElement} el 5091 * @param {Number} [k] 5092 * @param {Boolean} [wOnly] 5093 */ 5094 _getElSize(e, t = 1, s = !0) { 5095 let r = e.getBoundingClientRect(), n = t * Math.round(r.width), o = s ? "" : t * Math.round(r.height); 5096 return n || o ? `${n || ""}x${o || ""}` : null; 5097 } 5098 /** @param {HTMLImageElement} img */ 5099 _setupEventProxy(e) { 5100 let t = (r) => { 5101 r.stopPropagation(); 5102 let n = new Event(r.type, r); 5103 this.dispatchEvent(n); 5104 }, s = ["load", "error"]; 5105 for (let r of s) 5106 e.addEventListener(r, t); 5107 } 5108 /** @type {HTMLImageElement} */ 5109 get img() { 5110 return this.hasPreviewImage || (this._setupConfigForImage({ elNode: this._img }), this.appendChild(this._img)), this._img; 5111 } 5112 get currentImg() { 5113 return this.hasPreviewImage ? { 5114 type: Ii.PREVIEW, 5115 img: this._imgPreview 5116 } : { 5117 type: Ii.MAIN, 5118 img: this.img 5119 }; 5120 } 5121 get hasPreviewImage() { 5122 return this.$$("is-preview-blur"); 5123 } 5124 get bgSelector() { 5125 return this.$$("is-background-for"); 5126 } 5127 get breakpoints() { 5128 if (this.$$("breakpoints")) { 5129 const e = ce(this.$$("breakpoints")); 5130 return $a(e.map((t) => parseInt(t, 10))); 5131 } else 5132 return null; 5133 } 5134 get hasFormatJPG() { 5135 return this.$$("format").toLowerCase() === "jpeg"; 5136 } 5137 /** @param {HTMLElement} el */ 5138 renderBg(e) { 5139 let t = /* @__PURE__ */ new Set(); 5140 t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`), this.$$("hi-res-support") && t.add(`url("${this._getUrlBase(this._getElSize(e, We))}") ${We}x`), this.$$("ultra-res-support") && t.add(`url("${this._getUrlBase(this._getElSize(e, qe))}") ${qe}x`); 5141 let s = `image-set(${[...t].join(", ")})`; 5142 e.style.setProperty("background-image", s), e.style.setProperty("background-image", "-webkit-" + s); 5143 } 5144 getSrcset() { 5145 let e = /* @__PURE__ */ new Set();
5146 return this.breakpoints ? this.breakpoints.forEach((t) => { 5147 e.add(this._getUrlBase(t + "x") + ` ${this._validateSize(t + "w")}`), this.$$("hi-res-support") && e.add(this._getUrlBase(t * We + "x") + ` ${this._validateSize(t * We + "w")}`), this.$$("ultra-res-support") && e.add(this._getUrlBase(t * qe + "x") + ` ${this._validateSize(t * qe + "w")}`); 5148 }) : (e.add(this._getUrlBase(this._getElSize(this.currentImg.img)) + " 1x"), this.$$("hi-res-support") && e.add(this._getUrlBase(this._getElSize(this.currentImg.img, 2)) + " 2x"), this.$$("ultra-res-support") && e.add(this._getUrlBase(this._getElSize(this.currentImg.img, 3)) + " 3x")), [...e].join(); 5149 } 5150 getSrc() { 5151 return this._getUrlBase(); 5152 } 5153 get srcUrlPreview() { 5154 return this._getUrlBase("100x", "100"); 5155 } 5156 renderBackground() { 5157 [...document.querySelectorAll(this.bgSelector)].forEach((e) => { 5158 this.$$("intersection") ? this.initIntersection(e, () => { 5159 this.renderBg(e); 5160 }) : this.renderBg(e); 5161 }); 5162 } 5163 _appendURL({ elNode: e, src: t, srcset: s }) { 5164 t && (e.src = t), s && (e.srcset = s); 5165 } 5166 _setupConfigForImage({ elNode: e }) { 5167 this._setupEventProxy(e), this.initAttributes(e); 5168 } 5169 loaderImage({ src: e, srcset: t, elNode: s }) { 5170 return new Promise((r, n) => { 5171 this._setupConfigForImage({ elNode: s }), s.setAttribute(xi, ""), s.addEventListener("load", () => { 5172 s.removeAttribute(xi), r(s); 5173 }), s.addEventListener("error", () => { 5174 n(!1); 5175 }), this._appendURL({ 5176 elNode: s, 5177 src: e, 5178 srcset: t 5179 }); 5180 }); 5181 } 5182 async renderImage() { 5183 if (this.$$("intersection")) { 5184 this.hasPreviewImage && (this._setupConfigForImage({ elNode: this._imgPreview }), this.appendChild(this._imgPreview)), this.initIntersection(this.currentImg.img, async () => { 5185 this.hasPreviewImage && (this._imgPreview.src = this.srcUrlPreview); 5186 try { 5187 await this.loaderImage({ 5188 src: this.getSrc(), 5189 srcset: this.getSrcset(), 5190 elNode: this._img 5191 }), this.hasPreviewImage && await this._imgPreview.remove(), this.appendChild(this._img); 5192 } catch { 5193 this.hasPreviewImage && await this._imgPreview?.remove(), this.appendChild(this._img); 5194 } 5195 }); 5196 return; 5197 } 5198 try { 5199 this.hasPreviewImage && (await this.loaderImage({ 5200 src: this.srcUrlPreview, 5201 elNode: this._imgPreview 5202 }), this.appendChild(this._imgPreview)), await this.loaderImage({ 5203 src: this.getSrc(), 5204 srcset: this.getSrcset(), 5205 elNode: this._img 5206 }), this.hasPreviewImage && await this._imgPreview?.remove(), this.appendChild(this._img); 5207 } catch { 5208 this.hasPreviewImage && await this._imgPreview?.remove(), this.appendChild(this._img); 5209 } 5210 } 5211 init() { 5212 this.bgSelector ? this.renderBackground() : this.renderImage(); 5213 } 5214} 5215class Ua extends La { 5216 initCallback() { 5217 super.initCallback(), this.sub$$("src", () => { 5218 this.init(); 5219 }), this.sub$$("uuid", () => { 5220 this.init(); 5221 }), this.sub$$("lazy", (e) => { 5222 !this.$$("is-background-for") && !this.$$("is-preview-blur") && (this.img.loading = e ? "lazy" : "eager"); 5223 }); 5224 } 5225} 5226class Yt extends U { 5227 static styleAttrs = [...super.styleAttrs, "uc-simple-btn"]; 5228 couldBeCtxOwner = !0; 5229 constructor() { 5230 super(), this.init$ = { 5231 ...this.init$, 5232 withDropZone: !0, 5233 onClick: () => { 5234 this.api.initFlow(); 5235 }, 5236 "button-text": "" 5237 }; 5238 } 5239 initCallback() { 5240 super.initCallback(), this.defineAccessor( 5241 "dropzone", 5242 /** @param {unknown} val */ 5243 (e) => { 5244 typeof e > "u" || (this.$.withDropZone = $(e)); 5245 } 5246 ), this.subConfigValue("multiple", (e) => { 5247 this.$["button-text"] = e ? "upload-files" : "upload-file"; 5248 }); 5249 } 5250} 5251Yt.template = /* HTML */ 5252` 5253 <uc-drop-area set="@disabled: !withDropZone"> 5254 <button type="button" set="onclick: onClick"> 5255 <uc-icon name="upload"></uc-icon> 5256 <span l10n="button-text"></span> 5257 <slot></slot> 5258 <div class="uc-visual-drop-area" l10n="drop-files-here"></div> 5259 </button> 5260 </uc-drop-area> 5261`; 5262Yt.bindAttributes({ 5263 // @ts-expect-error TODO: we need to update symbiote types 5264 dropzone: null 5265}); 5266class Es extends _ { 5267 historyTracked = !0; 5268 /** @type {import('../../abstract/ActivityBlock.js').ActivityType} */ 5269 activityType = "start-from"; 5270 initCallback() { 5271 super.initCallback(), this.registerActivity(this.activityType); 5272 } 5273} 5274Es.template = /* HTML */ 5275' <div class="uc-content"><slot></slot></div> '; 5276function Pa(i) { 5277 return new Promise((e) => { 5278 typeof window.FileReader != "function" && e(!1); 5279 try { 5280 let t = new FileReader(); 5281 t.onerror = () => { 5282 e(!0); 5283 }; 5284 let s = (r) => { 5285 r.type !== "loadend" && t.abort(), e(!1); 5286 };
5287 t.onloadend = s, t.onprogress = s, t.readAsDataURL(i); 5288 } catch { 5289 e(!1); 5290 } 5291 }); 5292} 5293function Ma(i, e) { 5294 return new Promise((t) => { 5295 let s = 0; 5296 const r = [], n = (a) => { 5297 a || (console.warn("Unexpectedly received empty content entry", { scope: "drag-and-drop" }), t(null)), a.isFile ? (s++, a.file((l) => { 5298 s--; 5299 const c = new File([l], l.name, { type: l.type || e }); 5300 r.push({ 5301 type: "file", 5302 file: c, 5303 fullPath: a.fullPath 5304 }), s === 0 && t(r); 5305 })) : a.isDirectory && o( 5306 /** @type {FileSystemDirectoryEntry} */ 5307 a.createReader() 5308 ); 5309 }; 5310 let o = (a) => { 5311 s++, a.readEntries((l) => { 5312 s--; 5313 for (let c of l) 5314 n(c); 5315 s === 0 && t(r); 5316 }); 5317 }; 5318 n(i); 5319 }); 5320} 5321function Ra(i) { 5322 const e = [], t = []; 5323 for (let s = 0; s < i.items.length; s++) { 5324 let r = i.items[s]; 5325 if (r) 5326 if (r.kind === "file") { 5327 const n = r.type; 5328 if (typeof r.webkitGetAsEntry == "function" || typeof /** @type {any} */ 5329 r.getAsEntry == "function") { 5330 let a = typeof r.webkitGetAsEntry == "function" ? r.webkitGetAsEntry() : ( 5331 /** @type {any} */ 5332 r.getAsEntry() 5333 ); 5334 t.push( 5335 Ma(a, n).then((l) => { 5336 l && e.push(...l); 5337 }) 5338 ); 5339 continue; 5340 } 5341 const o = r.getAsFile(); 5342 o && t.push( 5343 Pa(o).then((a) => { 5344 a || e.push({ 5345 type: "file", 5346 file: o 5347 }); 5348 }) 5349 ); 5350 } else r.kind === "string" && r.type.match("^text/uri-list") && t.push( 5351 new Promise((n) => { 5352 r.getAsString((o) => { 5353 e.push({ 5354 type: "url", 5355 url: o 5356 }), n(void 0); 5357 }); 5358 }) 5359 ); 5360 } 5361 return Promise.all(t).then(() => e); 5362} 5363const R = { 5364 ACTIVE: 0, 5365 INACTIVE: 1, 5366 NEAR: 2, 5367 OVER: 3 5368}; 5369let Oi = ["focus"], Da = 100, Tt = /* @__PURE__ */ new Map(); 5370function Fa(i, e) { 5371 let t = Math.max(Math.min(i[0], e.x + e.width), e.x), s = Math.max(Math.min(i[1], e.y + e.height), e.y); 5372 return Math.sqrt((i[0] - t) * (i[0] - t) + (i[1] - s) * (i[1] - s)); 5373} 5374function Li(i) { 5375 let e = 0, t = document.body, s = /* @__PURE__ */ new Set(), r = (p) => s.add(p), n = R.INACTIVE, o = (p) => { 5376 i.shouldIgnore() && p !== R.INACTIVE || (n !== p && s.forEach((m) => m(p)), n = p); 5377 }, a = () => e > 0; 5378 r((p) => i.onChange(p)); 5379 let l = () => { 5380 e = 0, o(R.INACTIVE); 5381 }, c = () => { 5382 e += 1, n === R.INACTIVE && o(R.ACTIVE); 5383 }, d = () => { 5384 e -= 1, a() || o(R.INACTIVE); 5385 }, u = (p) => { 5386 p.preventDefault(), e = 0, o(R.INACTIVE); 5387 }, h = (p) => { 5388 if (i.shouldIgnore()) 5389 return; 5390 a() || (e += 1); 5391 let m = [p.x, p.y], b = i.element.getBoundingClientRect(), C = Math.floor(Fa(m, b)), E = C < Da, T = p.composedPath().includes(i.element); 5392 Tt.set(i.element, C); 5393 let g = Math.min(...Tt.values()) === C; 5394 T && g ? (p.preventDefault(), o(R.OVER)) : o(E && g ? R.NEAR : R.ACTIVE); 5395 }, f = async (p) => { 5396 if (i.shouldIgnore()) 5397 return; 5398 p.preventDefault(); 5399 let m = await Ra(p.dataTransfer); 5400 i.onItems(m), o(R.INACTIVE); 5401 }; 5402 return t.addEventListener("drop", u), t.addEventListener("dragleave", d), t.addEventListener("dragenter", c), t.addEventListener("dragover", h), i.element.addEventListener("drop", f), Oi.forEach((p) => { 5403 window.addEventListener(p, l); 5404 }), () => { 5405 Tt.delete(i.element), t.removeEventListener("drop", u), t.removeEventListener("dragleave", d), t.removeEventListener("dragenter", c), t.removeEventListener("dragover", h), i.element.removeEventListener("drop", f), Oi.forEach((p) => { 5406 window.removeEventListener(p, l); 5407 }); 5408 }; 5409} 5410const Ts = "uc-drop-area", Ae = `${Ts}/registry`; 5411class Jt extends U { 5412 static styleAttrs = [...super.styleAttrs, "uc-drop-area"]; 5413 constructor() { 5414 super(), this.init$ = { 5415 ...this.init$, 5416 state: R.INACTIVE, 5417 withIcon: !1, 5418 isClickable: !1, 5419 isFullscreen: !1, 5420 isEnabled: !0, 5421 isVisible: !0, 5422 text: "", 5423 [Ae]: null 5424 }; 5425 } 5426 isActive() { 5427 if (!this.$.isEnabled) 5428 return !1; 5429 const e = this.getBoundingClientRect(), t = e.width > 0 && e.height > 0, s = e.top >= 0 && e.left >= 0 && e.bottom <= (window.innerHeight || document.documentElement.clientHeight) && e.right <= (window.innerWidth || document.documentElement.clientWidth), r = window.getComputedStyle(this), n = r.visibility !== "hidden" && r.display !== "none"; 5430 return t && n && s; 5431 } 5432 initCallback() { 5433 super.initCallback(), this.bindL10n("text", () => this.l10n("drop-files-here")), this.$[Ae] || (this.$[Ae] = /* @__PURE__ */ new Set()), this.$[Ae].add(this), this.defineAccessor( 5434 "disabled", 5435 /** @param {unknown} value */ 5436 (t) => { 5437 this.set$({ isEnabled: !$(t) }); 5438 } 5439 ), this.defineAccessor( 5440 "clickable", 5441 /** @param {unknown} value */ 5442 (t) => { 5443 this.set$({ isClickable: $(t) }); 5444 } 5445 ), this.defineAccessor( 5446 "with-icon", 5447 /** @param {unknown} value */ 5448 (t) => { 5449 this.set$({ withIcon: $(t) }); 5450 } 5451 ), this.defineAccessor( 5452 "fullscreen", 5453 /** @param {unknown} value */ 5454 (t) => { 5455 this.set$({ isFullscreen: $(t) }); 5456 } 5457 ), this.defineAccessor( 5458 "text", 5459 /** @param {unknown} value */ 5460 (t) => { 5461 typeof t == "string" ? this.bindL10n("text", () => this.l10n(t) || t) : this.bindL10n("text", () => this.l10n("drop-files-here")); 5462 } 5463 ), this._destroyDropzone = Li({ 5464 element: this, 5465 shouldIgnore: () => this._shouldIgnore(), 5466 /** @param {DropzoneState} state */ 5467 onChange: (t) => { 5468 this.$.state = t; 5469 }, 5470 /** @param {import('./getDropItems.js').DropItem[]} items */ 5471 onItems: (t) => { 5472 t.length && (t.forEach((s) => { 5473 s.type === "url" ? this.api.addFileFromUrl(s.url, { source: P.DROP_AREA }) : s.type === "file" && this.api.addFileFromObject(s.file, { source: P.DROP_AREA, fullPath: s.fullPath }); 5474 }), this.uploadCollection.size && (this.set$({ 5475 "*currentActivity": _.activities.UPLOAD_LIST 5476 }), this.setOrAddState("*modalActive", !0))); 5477 } 5478 }); 5479 let e = this.ref["content-wrapper"]; 5480 e && (this._destroyContentWrapperDropzone = Li({ 5481 element: e, 5482 /** @param {DropzoneState} state */ 5483 onChange: (t) => { 5484 const s = Object.entries(R).find(([, r]) => r === t)?.[0].toLowerCase(); 5485 s && e.setAttribute("drag-state", s); 5486 }, 5487 onItems: () => { 5488 }, 5489 shouldIgnore: () => this._shouldIgnore() 5490 })), this.sub("state", (t) => { 5491 const s = Object.entries(R).find(([, r]) => r === t)?.[0].toLowerCase(); 5492 s && this.setAttribute("drag-state", s); 5493 }), this.subConfigValue("sourceList", (t) => { 5494 const s = ce(t); 5495 this.$.isEnabled = s.includes(P.LOCAL), this.$.isVisible = this.$.isEnabled || !this.querySelector("[data-default-slot]"); 5496 }), this.sub("isVisible", (t) => { 5497 this.toggleAttribute("hidden", !t); 5498 }), this.sub("isClickable", (t) => { 5499 this.toggleAttribute("clickable", t); 5500 }), this.$.isClickable && (this._onAreaClicked = (t) => { 5501 t.type === "keydown" ? (t.code === "Space" || t.code === "Enter") && this.api.openSystemDialog() : t.type === "click" && this.api.openSystemDialog(); 5502 }, this.addEventListener("keydown", this._onAreaClicked), this.addEventListener("click", this._onAreaClicked)); 5503 } 5504 /** 5505 * Ignore drop events if there are other visible drop areas on the page 5506 * 5507 * @private 5508 * @returns {Boolean} 5509 */ 5510 _shouldIgnore() { 5511 return !this.$.isEnabled || !this._couldHandleFiles() ? !0 : this.$.isFullscreen ? [...this.$[Ae]].filter((s) => s !== this).filter((s) => s.isActive()).length > 0 : !1; 5512 } 5513 /** @private */
5514 _couldHandleFiles() { 5515 let e = this.cfg.multiple, t = this.cfg.multipleMax, s = this.uploadCollection.size; 5516 return !(e && t && s >= t || !e && s > 0); 5517 } 5518 destroyCallback() { 5519 super.destroyCallback(); 5520 const e = this.$[Ae]; 5521 e && (e.delete(this), e.size === 0 && A.deleteCtx(Ts)), this._destroyDropzone?.(), this._destroyContentWrapperDropzone?.(), this._onAreaClicked && (this.removeEventListener("keydown", this._onAreaClicked), this.removeEventListener("click", this._onAreaClicked)); 5522 } 5523} 5524Jt.template = /* HTML */ 5525` 5526 <slot> 5527 <div data-default-slot hidden></div> 5528 <div ref="content-wrapper" class="uc-content-wrapper" set="@hidden: !isVisible"> 5529 <div class="uc-icon-container" set="@hidden: !withIcon"> 5530 <uc-icon name="default"></uc-icon> 5531 <uc-icon name="arrow-down"></uc-icon> 5532 </div> 5533 <span class="uc-text">{{text}}</span> 5534 </div> 5535 </slot> 5536`; 5537Jt.bindAttributes({ 5538 // @ts-expect-error TODO: fix types inside symbiote 5539 "with-icon": null, 5540 // @ts-expect-error TODO: fix types inside symbiote 5541 clickable: null, 5542 // @ts-expect-error TODO: fix types inside symbiote 5543 text: null, 5544 // @ts-expect-error TODO: fix types inside symbiote 5545 fullscreen: null, 5546 // @ts-expect-error TODO: fix types inside symbiote 5547 disabled: null 5548}); 5549const Va = "src-type-"; 5550class Qt extends U { 5551 couldBeCtxOwner = !0; 5552 /** @type {string | undefined} */ 5553 type = void 0; 5554 /** 5555 * @private 5556 * @type {Record<string, TConfig>} 5557 */ 5558 _registeredTypes = {}; 5559 constructor() { 5560 super(), this.init$ = { 5561 ...this.init$, 5562 iconName: "default", 5563 "src-type": "" 5564 }; 5565 } 5566 initTypes() { 5567 this.registerType({ 5568 type: P.LOCAL, 5569 activate: () => (this.api.openSystemDialog(), !1) 5570 }), this.registerType({ 5571 type: P.URL, 5572 activity: _.activities.URL, 5573 textKey: "from-url" 5574 }), this.registerType({ 5575 type: P.CAMERA, 5576 activity: _.activities.CAMERA, 5577 activate: () => { 5578 const e = "capture" in document.createElement("input"); 5579 return e && this.api.openSystemDialog({ captureCamera: !0 }), !e; 5580 } 5581 }), this.registerType({ 5582 type: "draw", 5583 activity: _.activities.DRAW, 5584 icon: "edit-draw" 5585 }); 5586 for (let e of Object.values(mt)) 5587 this.registerType({ 5588 type: e, 5589 activity: _.activities.EXTERNAL, 5590 activityParams: { 5591 externalSourceType: e 5592 } 5593 }); 5594 } 5595 initCallback() { 5596 super.initCallback(), this.initTypes(), this.defineAccessor( 5597 "type", 5598 /** @param {string} val */ 5599 (e) => { 5600 e && this.applyType(e); 5601 } 5602 ); 5603 } 5604 /** @param {TConfig} typeConfig */ 5605 registerType(e) { 5606 this._registeredTypes[e.type] = e; 5607 } 5608 /** @param {string} type */ 5609 getType(e) { 5610 return this._registeredTypes[e]; 5611 } 5612 activate() { 5613 if (!this.type) 5614 return; 5615 const e = this._registeredTypes[this.type], { activity: t, activate: s, activityParams: r = {} } = e; 5616 (s ? s() : t) && this.set$({ 5617 "*currentActivityParams": r, 5618 "*currentActivity": t 5619 }); 5620 } 5621 /** @param {string} type */ 5622 applyType(e) { 5623 const t = this._registeredTypes[e]; 5624 if (!t) { 5625 console.warn("Unsupported source type: " + e); 5626 return; 5627 } 5628 const { textKey: s = e, icon: r = e } = t; 5629 this.$["src-type"] = `${Va}${s}`, this.$.iconName = r, this.onclick = () => { 5630 this.activate(); 5631 }; 5632 } 5633} 5634Qt.template = /* HTML */ 5635` 5636 <button type="button"> 5637 <uc-icon set="@name: iconName"></uc-icon> 5638 <div class="uc-txt" l10n="src-type"></div> 5639 </button> 5640`; 5641Qt.bindAttributes({ 5642 // @ts-expect-error symbiote types bug 5643 type: null 5644}); 5645class Na extends k { 5646 initCallback() { 5647 super.initCallback(), this.subConfigValue("sourceList", (e) => { 5648 let t = ce(e), s = ""; 5649 t.forEach((r) => { 5650 if (r === "instagram") { 5651 console.error( 5652 "Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here:https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US" 5653 ); 5654 return; 5655 } 5656 s += /* HTML */ 5657 `<uc-source-btn type="${r}"></uc-source-btn>`; 5658 }), this.cfg.sourceListWrap ? this.innerHTML = s : this.outerHTML = s; 5659 }); 5660 } 5661} 5662const bt = () => { 5663 const i = []; 5664 return { 5665 stack: i, 5666 promiseReadJpegChunks: (t) => new Promise((s, r) => { 5667 let n = 2; 5668 const o = (c, d) => { 5669 const u = new FileReader(); 5670 u.addEventListener("load", () => { 5671 d(new DataView(u.result)); 5672 }), u.addEventListener("error", (h) => { 5673 r(`Reader error: ${h}`); 5674 }), u.readAsArrayBuffer(c); 5675 }, a = () => o(t.slice(n, n + 128), (c) => { 5676 let d, u, h; 5677 for (d = u = 0, h = c.byteLength; h >= 0 ? u < h : u > h; d = h >= 0 ? ++u : --u) 5678 if (c.getUint8(d) === 255) { 5679 n += d; 5680 break; 5681 } 5682 l(); 5683 }), l = () => { 5684 const c = n; 5685 return o(t.slice(n, n += 4), (d) => { 5686 if (d.byteLength !== 4 || d.getUint8(0) !== 255) { 5687 r("Corrupted"); 5688 return; 5689 } 5690 const u = d.getUint8(1); 5691 if (u === 218) { 5692 s(!0); 5693 return; 5694 } 5695 const h = d.getUint16(2) - 2; 5696 return o(t.slice(n, n += h), (f) => { 5697 if (f.byteLength !== h) { 5698 r("Corrupted"); 5699 return; 5700 } 5701 i.push({ startPos: c, length: h, marker: u, view: f }), a(); 5702 }); 5703 }); 5704 }; 5705 FileReader && DataView || r("Not Support"), o(t.slice(0, 2), (c) => { 5706 c.getUint16(0) !== 65496 && r("Not jpeg"), a(); 5707 }); 5708 }) 5709 }; 5710}, za = async (i) => { 5711 const e = [], { promiseReadJpegChunks: t, stack: s } = bt();
5712 return await t(i), s.forEach(({ marker: r, view: n }) => { 5713 r === 226 && // check for "ICC_PROFILE\0" 5714 n.getUint32(0) === 1229144927 && n.getUint32(4) === 1347571526 && n.getUint32(8) === 1229735168 && e.push(n); 5715 }), e; 5716}, xs = async (i, e, t) => { 5717 { 5718 const s = [], r = [], { promiseReadJpegChunks: n, stack: o } = bt(); 5719 await n(i), o.forEach((c) => { 5720 if (c.marker === e) 5721 return s.push(c.startPos), r.push(c.length); 5722 }); 5723 const a = [i.slice(0, 2)]; 5724 for (const c of t) { 5725 const d = new DataView(new ArrayBuffer(4)); 5726 d.setUint16(0, 65280 + e), d.setUint16(2, c.byteLength + 2), a.push(d.buffer), a.push(c); 5727 } 5728 let l = 2; 5729 for (let c = 0; c < s.length; c++) 5730 s[c] > l && a.push(i.slice(l, s[c])), l = s[c] + r[c] + 4; 5731 return a.push(i.slice(l, i.size)), new Blob(a, { 5732 type: i.type 5733 }); 5734 } 5735}, Ba = 226, Ss = (i, e) => xs(i, Ba, e.map((t) => t.buffer)), Ha = async (i) => { 5736 try { 5737 return await Ss(i, []); 5738 } catch (e) { 5739 throw new Error(`Failed to strip ICC profile: ${e}`); 5740 } 5741}, ja = (i, e, t) => new Promise((s, r) => { 5742 const n = (o) => { 5743 if (!o) { 5744 r("Failed to convert canvas to blob"); 5745 return; 5746 } 5747 s(o); 5748 }; 5749 i.toBlob(n, e, t), i.width = i.height = 1; 5750}), Ne = () => { 5751 const i = document.createElement("canvas"), e = i.getContext("2d"); 5752 return { 5753 canvas: i, 5754 ctx: e 5755 }; 5756}, Ga = (i) => { 5757 const { ctx: t, canvas: s } = Ne(); 5758 s.width = s.height = 50, t.drawImage(i, 0, 0, 50, 50); 5759 const r = t.getImageData(0, 0, 50, 50).data; 5760 s.width = s.height = 1; 5761 for (let n = 3; n < r.length; n += 4) 5762 if (r[n] < 254) 5763 return !0; 5764 return !1; 5765}, Wa = async (i) => { 5766 let e = null; 5767 const { promiseReadJpegChunks: t, stack: s } = bt(); 5768 return await t(i), s.forEach(({ marker: r, view: n }) => { 5769 if (!e && r === 225 && n.byteLength >= 14 && // check for "Exif\0" 5770 n.getUint32(0) === 1165519206 && n.getUint16(4) === 0) { 5771 e = n; 5772 return; 5773 } 5774 }), e; 5775}, qa = "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k="; 5776let Xe; 5777const Xa = () => new Promise((i) => { 5778 if (Xe !== void 0) 5779 i(Xe); 5780 else { 5781 const e = new Image(); 5782 e.addEventListener("load", () => { 5783 Xe = e.naturalWidth < e.naturalHeight, e.src = "//:0", i(Xe); 5784 }), e.src = qa; 5785 } 5786}), Za = (i, e) => { 5787 let t, s, r, n; 5788 if (!i || i.byteLength < 14 || i.getUint32(0) !== 1165519206 || i.getUint16(4) !== 0) 5789 return; 5790 if (i.getUint16(6) === 18761) 5791 s = !0; 5792 else if (i.getUint16(6) === 19789) 5793 s = !1; 5794 else 5795 return; 5796 if (i.getUint16(8, s) !== 42) 5797 return; 5798 r = 8 + i.getUint32(10, s); 5799 const o = i.getUint16(r - 2, s); 5800 for (t = 0, n = o; n >= 0 ? t < n : t > n; n >= 0 ? ++t : --t) { 5801 if (i.byteLength < r + 10) 5802 return; 5803 i.getUint16(r, s) === 274 && e(r + 8, s), r += 12; 5804 } 5805}, Ka = (i, e) => { 5806 Za(i, (t, s) => i.setUint16(t, e, s)); 5807}, Ya = async (i, e, t) => (t && Ka(e, 1), xs(i, 225, [e.buffer])), Ja = (i, e) => new Promise((t, s) => { 5808 e && (i.src = e), i.complete ? t(i) : (i.addEventListener("load", () => { 5809 t(i); 5810 }), i.addEventListener("error", () => { 5811 s(new Error("Failed to load image. Probably not an image.")); 5812 })); 5813}), Qa = (i) => Ja(new Image(), i), el = [ 5814 1, 5815 // L (black-white) 5816 3 5817 // RGB 5818], tl = [ 5819 192, 5820 // ("SOF0", "Baseline DCT", SOF) 5821 193, 5822 // ("SOF1", "Extended Sequential DCT", SOF) 5823 194, 5824 // ("SOF2", "Progressive DCT", SOF) 5825 195, 5826 // ("SOF3", "Spatial lossless", SOF) 5827 197, 5828 // ("SOF5", "Differential sequential DCT", SOF) 5829 198, 5830 // ("SOF6", "Differential progressive DCT", SOF) 5831 199, 5832 // ("SOF7", "Differential spatial", SOF) 5833 201, 5834 // ("SOF9", "Extended sequential DCT (AC)", SOF) 5835 202, 5836 // ("SOF10", "Progressive DCT (AC)", SOF) 5837 203, 5838 // ("SOF11", "Spatial lossless DCT (AC)", SOF) 5839 205, 5840 // ("SOF13", "Differential sequential DCT (AC)", SOF) 5841 206, 5842 // ("SOF14", "Differential progressive DCT (AC)", SOF) 5843 207 5844 // ("SOF15", "Differential spatial (AC)", SOF) 5845], Ui = { 5846 squareSide: [ 5847 // Safari (iOS < 9, ram >= 256) 5848 // We are supported mobile safari < 9 since widget v2, by 5 Mpx limit 5849 // so it's better to continue support despite the absence of this browser in the support table 5850 Math.floor(Math.sqrt(5 * 1e3 * 1e3)), 5851 // IE Mobile (Windows Phone 8.x) 5852 // Safari (iOS >= 9) 5853 4096, 5854 // IE 9 (Win) 5855 8192, 5856 // Firefox 63 (Mac, Win) 5857 11180, 5858 // Chrome 68 (Android 6) 5859 10836, 5860 // Chrome 68 (Android 5) 5861 11402, 5862 // Chrome 68 (Android 7.1-9) 5863 14188, 5864 // Chrome 70 (Mac, Win) 5865 // Chrome 68 (Android 4.4) 5866 // Edge 17 (Win) 5867 // Safari 7-12 (Mac) 5868 16384 5869 ], 5870 dimension: [ 5871 // IE Mobile (Windows Phone 8.x) 5872 4096, 5873 // IE 9 (Win) 5874 8192, 5875 // Edge 17 (Win) 5876 // IE11 (Win) 5877 16384, 5878 // Chrome 70 (Mac, Win) 5879 // Chrome 68 (Android 4.4-9) 5880 // Firefox 63 (Mac, Win) 5881 32767, 5882 // Chrome 83 (Mac, Win) 5883 // Safari 7-12 (Mac) 5884 // Safari (iOS 9-12)
5885 // Actually Safari has a much bigger limits - 4194303 of width and 8388607 of height, 5886 // but we will not use them 5887 65535 5888 ] 5889}, il = async (i) => { 5890 let e = !1; 5891 const { promiseReadJpegChunks: t, stack: s } = bt(); 5892 return await t(i).then(() => (s.forEach(({ marker: r, view: n }) => { 5893 if (!e && tl.indexOf(r) >= 0) { 5894 const o = n.getUint8(5); 5895 el.indexOf(o) < 0 && (e = !0); 5896 } 5897 }), e)).catch(() => e); 5898}, $s = (i, e) => { 5899 const t = {}; 5900 return (...s) => { 5901 const r = e(s, t); 5902 return r in t ? t[r] : t[r] = i(...s); 5903 }; 5904}, ks = (i, e) => { 5905 const [t] = i, s = Object.keys(e).map((r) => parseInt(r, 10)).sort((r, n) => r - n); 5906 for (let r = 0; r < s.length; r++) { 5907 const n = s[r], o = !!e[n]; 5908 if (n > t && o || n < t && !o) 5909 return n; 5910 } 5911 return t; 5912}, ne = { 5913 R: 55, 5914 G: 110, 5915 B: 165, 5916 A: 255 5917}, sl = `rgba(${ne.R}, ${ne.G}, ${ne.B}, ${ne.A / 255})`, Is = (i, e) => { 5918 try { 5919 const t = [i - 1, e - 1, 1, 1], { canvas: s, ctx: r } = Ne(); 5920 s.width = 1, s.height = 1; 5921 const { canvas: n, ctx: o } = Ne(); 5922 n.width = i, n.height = e, o && (o.fillStyle = sl, o.fillRect(...t), r.drawImage(n, i - 1, e - 1, 1, 1, 0, 0, 1, 1)); 5923 const a = r && r.getImageData(0, 0, 1, 1).data; 5924 let l = !1; 5925 return a && (l = a[0] === ne.R && a[1] === ne.G && a[2] === ne.B && a[3] === ne.A), n.width = n.height = 1, l; 5926 } catch { 5927 return console.error(`Failed to test for max canvas size of ${i}x${e}.`), !1; 5928 } 5929}; 5930function Os(i) { 5931 return (...e) => new Promise((t) => { 5932 setTimeout(() => { 5933 const s = i(...e); 5934 t(s); 5935 }, 0); 5936 }); 5937} 5938const rl = Os($s(Is, ks)), nl = Os($s(Is, ks)), Ls = async (i, e) => { 5939 const t = Ui.squareSide.find((o) => o * o >= i * e), s = Ui.dimension.find((o) => o >= i && o >= e); 5940 if (!t || !s) 5941 throw new Error("Not supported"); 5942 const [r, n] = await Promise.all([ 5943 rl(t, t), 5944 nl(s, 1) 5945 ]); 5946 if (r && n) 5947 return !0; 5948 throw new Error("Not supported"); 5949}, Us = async (i, e, t) => { 5950 try { 5951 const { ctx: s, canvas: r } = Ne(); 5952 return r.width = e, r.height = t, s.imageSmoothingQuality = "high", s.drawImage(i, 0, 0, e, t), i instanceof HTMLImageElement && (i.src = "//:0"), i instanceof HTMLCanvasElement && (i.width = i.height = 1), r; 5953 } catch (s) { 5954 throw new Error("Canvas resize error", { cause: s }); 5955 } 5956}, ol = ({ img: i, targetW: e, targetH: t }) => Us(i, e, t), al = function({ sourceW: i, targetW: e, targetH: t, step: s }) { 5957 const r = []; 5958 let n = e, o = t; 5959 do 5960 r.push([n, o]), n = Math.round(n / s), o = Math.round(o / s); 5961 while (n < i * s); 5962 return r.reverse(); 5963}, ll = ({ img: i, sourceW: e, targetW: t, targetH: s, step: r }) => { 5964 const n = al({ sourceW: e, targetW: t, targetH: s, step: r }); 5965 return n.reduce((o, [a, l], c) => o.then((d) => Ls(a, l).then(() => Us(d, a, l)).catch(() => { 5966 if (c === n.length - 1) 5967 throw new Error("Not supported"); 5968 return d; 5969 })), Promise.resolve(i)); 5970}, cl = () => /iPad|iPhone|iPod/.test(navigator.platform) ? !0 : navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && /MacIntel/.test(navigator.platform), ul = navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && /MacIntel/.test(navigator.platform), xt = 0.71, dl = (i, e) => { 5971 if (i.width * xt * i.height * xt < e.size) 5972 throw new Error("Not required"); 5973 const t = i.width, s = i.height, r = t / s, n = Math.floor(Math.sqrt(e.size * r)), o = Math.floor(e.size / Math.sqrt(e.size * r)); 5974 return Ls(n, o).then(() => { 5975 const { ctx: a } = Ne(); 5976 return "imageSmoothingQuality" in a && !cl() && !ul ? ol({ img: i, targetW: n, targetH: o }) : ll({ img: i, sourceW: t, targetW: n, targetH: o, step: xt }); 5977 }).catch(() => Promise.reject("Not supported")); 5978}, hl = async (i, e) => { 5979 try { 5980 if (await il(i)) 5981 throw new Error("Should skipped"); 5982 const s = await Promise.allSettled([ 5983 Wa(i), 5984 Xa(), 5985 za(i) 5986 ]), n = !s.some((m) => m.status === "rejected"), [o, a, l] = s, c = await Ha(i).catch(() => i), d = await Qa(URL.createObjectURL(c)); 5987 URL.revokeObjectURL(d.src); 5988 const u = await dl(d, e); 5989 let h = "image/jpeg", f = e?.quality || 0.8; 5990 !n && Ga(u) && (h = "image/png", f = void 0); 5991 let p = await ja(u, h, f); 5992 if (n && o.status === "fulfilled" && o.value) { 5993 const m = o.value, b = a.status === "fulfilled" ? a.value : !1; 5994 p = await Ya(p, m, b); 5995 } 5996 return n && l.status === "fulfilled" && l.value.length > 0 && (p = await Ss(p, l.value)), p; 5997 } catch (t) { 5998 let s; 5999 throw t instanceof Error && (s = t.message), typeof t == "string" && (s = t), new Error(`Failed to shrink image. ${s ? `Message: "${s}".` : ""}`, { cause: t }); 6000 } 6001}; 6002function fl(i) { 6003 let e = new Blob([i], { 6004 type: "image/svg+xml" 6005 }); 6006 return URL.createObjectURL(e); 6007} 6008function Pi(i = "hsl(209, 21%, 65%)", e = 32, t = 32) { 6009 return fl( 6010 /*svg*/ 6011 ` 6012 <svg width="${e}" height="${t}
6012" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"> 6013 <path fill-rule="evenodd" fill="${i}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/> 6014 </svg> 6015 ` 6016 ); 6017} 6018function pl(i, e = 40) { 6019 if (i.type === "image/svg+xml") 6020 return URL.createObjectURL(i); 6021 let t = document.createElement("canvas"), s = t.getContext("2d"), r = new Image(), n = new Promise((o, a) => { 6022 r.onload = () => { 6023 let l = r.height / r.width; 6024 l > 1 ? (t.width = e, t.height = e * l) : (t.height = e, t.width = e / l), s.fillStyle = "rgb(240, 240, 240)", s.fillRect(0, 0, t.width, t.height), s.drawImage(r, 0, 0, t.width, t.height), t.toBlob((c) => { 6025 if (!c) { 6026 a(); 6027 return; 6028 } 6029 let d = URL.createObjectURL(c); 6030 o(d); 6031 }); 6032 }, r.onerror = (l) => { 6033 a(l); 6034 }; 6035 }); 6036 return r.src = URL.createObjectURL(i), n; 6037} 6038const Mi = 16384, ml = /^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i, gl = (i) => { 6039 const e = ml.exec(i?.toLocaleLowerCase()) || []; 6040 if (!e.length) 6041 return !1; 6042 const t = e[1] * e[2], s = Mi * Mi; 6043 return t > s ? (console.warn( 6044 `Shrinked size can not be larger than ${Math.floor(s / 1e3 / 1e3)}MP. You have set ${e[1]}x${e[2]} (${Math.ceil(t / 1e3 / 100) / 10}MP).` 6045 ), !1) : { 6046 quality: e[3] ? e[3] / 100 : void 0, 6047 size: t 6048 }; 6049}, z = Object.freeze({ 6050 FINISHED: /* @__PURE__ */ Symbol("FINISHED"), 6051 FAILED: /* @__PURE__ */ Symbol("FAILED"), 6052 UPLOADING: /* @__PURE__ */ Symbol("UPLOADING"), 6053 IDLE: /* @__PURE__ */ Symbol("IDLE") 6054}); 6055class _e extends U { 6056 couldBeCtxOwner = !0; 6057 pauseRender = !0; 6058 /** @private */ 6059 _entrySubs = /* @__PURE__ */ new Set(); 6060 /** 6061 * @private 6062 * @type {any} TODO: Add types for upload entry 6063 */ 6064 _entry = null; 6065 /** @private */ 6066 _isIntersecting = !1; 6067 /** @private */ 6068 _debouncedGenerateThumb = G(this._generateThumbnail.bind(this), 100); 6069 /** @private */ 6070 _debouncedCalculateState = G(this._calculateState.bind(this), 100); 6071 /** @private */ 6072 _renderedOnce = !1; 6073 constructor() { 6074 super(), this.init$ = { 6075 ...this.init$, 6076 uid: "", 6077 itemName: "", 6078 errorText: "", 6079 thumbUrl: "", 6080 progressValue: 0, 6081 progressVisible: !1, 6082 badgeIcon: "", 6083 isFinished: !1, 6084 isFailed: !1, 6085 isUploading: !1, 6086 isFocused: !1, 6087 isEditable: !1, 6088 state: z.IDLE, 6089 ariaLabelStatusFile: "", 6090 onEdit: () => { 6091 this.$["*currentActivityParams"] = { 6092 internalId: this._entry.uid 6093 }, this.$["*currentActivity"] = _.activities.CLOUD_IMG_EDIT; 6094 }, 6095 onRemove: () => { 6096 this.uploadCollection.remove(this.$.uid); 6097 }, 6098 onUpload: () => { 6099 this.upload(); 6100 } 6101 }; 6102 } 6103 _reset() { 6104 for (let e of this._entrySubs) 6105 e.remove(); 6106 this._debouncedGenerateThumb.cancel(), this._debouncedCalculateState.cancel(), this._entrySubs = /* @__PURE__ */ new Set(), this._entry = null; 6107 } 6108 /** 6109 * @private 6110 * @param {IntersectionObserverEntry[]} entries 6111 */ 6112 _observerCallback(e) { 6113 let [t] = e; 6114 this._isIntersecting = t.isIntersecting, t.isIntersecting && !this._renderedOnce && (this.render(), this._renderedOnce = !0), t.intersectionRatio === 0 ? this._debouncedGenerateThumb.cancel() : this._debouncedGenerateThumb(); 6115 } 6116 /** @private */ 6117 _calculateState() { 6118 if (!this._entry) 6119 return; 6120 let e = this._entry, t = z.IDLE; 6121 e.getValue("errors").length > 0 ? t = z.FAILED : e.getValue("isUploading") ? t = z.UPLOADING : e.getValue("fileInfo") && (t = z.FINISHED), this.$.state = t; 6122 } 6123 /** @private */ 6124 async _generateThumbnail() { 6125 if (!this._entry) 6126 return; 6127 let e = this._entry; 6128 if (e.getValue("fileInfo") && e.getValue("isImage")) { 6129 let t = this.cfg.thumbSize, s = await this.proxyUrl( 6130 j( 6131 Ve(this.cfg.cdnCname, this._entry.getValue("uuid")), 6132 le(e.getValue("cdnUrlModifiers"), `scale_crop/${t}x${t}/center`) 6133 ) 6134 ), r = e.getValue("thumbUrl"); 6135 r !== s && (e.setValue("thumbUrl", s), r?.startsWith("blob:") && URL.revokeObjectURL(r)); 6136 return; 6137 } 6138 if (!e.getValue("thumbUrl")) 6139 if (e.getValue("file")?.type.includes("image")) 6140 try { 6141 let t = await pl(e.getValue("file"), this.cfg.thumbSize); 6142 e.setValue("thumbUrl", t); 6143 } catch { 6144 let s = window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground"); 6145 e.setValue("thumbUrl", Pi(s)); 6146 } 6147 else { 6148 let t = window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground"); 6149 e.setValue("thumbUrl", Pi(t)); 6150 } 6151 } 6152 /** 6153 * @private 6154 * @param {string} prop 6155 * @param {(value: any) => void} handler 6156 */ 6157 _subEntry(e, t) { 6158 let s = this._entry.subscribe( 6159 e, 6160 /** @param {any} value */ 6161 (r) => { 6162 this.isConnected && t(r); 6163 } 6164 ); 6165 this._entrySubs.add(s); 6166 } 6167 /** 6168 * @private 6169 * @param {String} id 6170 */ 6171 _handleEntryId(e) { 6172 this._reset(); 6173 let t = this.uploadCollection?.read(e); 6174 this._entry = t, t && (this._subEntry("uploadProgress", (s) => { 6175 this.$.progressValue = s; 6176 }), this._subEntry("fileName", (s) => { 6177 this.$.itemName = s || t.getValue("externalUrl") || this.l10n("file-no-name"), this._debouncedCalculateState(); 6178 }), this._subEntry("externalUrl", (s) => { 6179 this.$.itemName = t.getValue("fileName") || s || this.l10n("file-no-name"); 6180 }), this._subEntry("fileInfo", (s) => { 6181 this._debouncedCalculateState(), s && this._isIntersecting && this._debouncedGenerateThumb(); 6182 }), this._subEntry("cdnUrlModifiers", () => { 6183 this._isIntersecting && this._debouncedGenerateThumb(); 6184 }), this._subEntry("thumbUrl", (s) => { 6185 this.$.thumbUrl = s ? `url(${s})` : ""; 6186 }), this._subEntry("errors", () => this._debouncedCalculateState()), this._subEntry("isUploading", () => this._debouncedCalculateState()), this._subEntry("fileSize", () => this._debouncedCalculateState()), this._subEntry("mimeType", () => this._debouncedCalculateState()), this._subEntry("isImage", () => this._debouncedCalculateState()), this._isIntersecting && this._debouncedGenerateThumb()); 6187 } 6188 initCallback() { 6189 super.initCallback(), this.sub("uid", (e) => { 6190 this._handleEntryId(e); 6191 }), this.sub("state", (e) => { 6192 this._handleState(e); 6193 }), this.subConfigValue("useCloudImageEditor", () => this._debouncedCalculateState()), this.onclick = () => {
6194 _e.activeInstances.forEach((e) => { 6195 e === this ? e.setAttribute("focused", "") : e.removeAttribute("focused"); 6196 }); 6197 }, this.sub( 6198 "*uploadTrigger", 6199 /** @param {Set<string>} itemsToUpload */ 6200 (e) => { 6201 e.has(this._entry.uid) && setTimeout(() => this.isConnected && this.upload()); 6202 } 6203 ), _e.activeInstances.add(this); 6204 } 6205 /** @param {(typeof FileItemState)[keyof typeof FileItemState]} state */ 6206 _handleState(e) { 6207 e === z.FAILED ? this.$.badgeIcon = "badge-error" : e === z.FINISHED && (this.$.badgeIcon = "badge-success"), e === z.UPLOADING ? this.$.isFocused = !1 : this.$.progressValue = 0, this.set$({ 6208 isFailed: e === z.FAILED, 6209 isUploading: e === z.UPLOADING, 6210 isFinished: e === z.FINISHED, 6211 progressVisible: e === z.UPLOADING, 6212 isEditable: this.cfg.useCloudImageEditor && this._entry?.getValue("isImage") && this._entry?.getValue("cdnUrl"), 6213 errorText: this._entry.getValue("errors")?.[0]?.message, 6214 ariaLabelStatusFile: this.l10n("a11y-file-item-status", { 6215 fileName: this._entry?.getValue("fileName"), 6216 status: this.l10n(e?.description?.toLocaleLowerCase() ?? "").toLocaleLowerCase() 6217 }) 6218 }); 6219 } 6220 destroyCallback() { 6221 super.destroyCallback(), _e.activeInstances.delete(this), this._reset(); 6222 } 6223 connectedCallback() { 6224 super.connectedCallback(), this._observer = new window.IntersectionObserver(this._observerCallback.bind(this), { 6225 threshold: [0, 1] 6226 }), this._observer.observe(this); 6227 } 6228 disconnectedCallback() { 6229 super.disconnectedCallback(), this._debouncedGenerateThumb.cancel(), this._observer?.disconnect(); 6230 } 6231 _settingsOfShrink() { 6232 return gl(this.cfg.imageShrink); 6233 } 6234 /** 6235 * @private 6236 * @param {File} file 6237 */ 6238 _processShrink(e) { 6239 return hl(e, this._settingsOfShrink()); 6240 } 6241 async upload() { 6242 let e = this._entry; 6243 if (!this.uploadCollection.read(e.uid) || e.getValue("fileInfo") || e.getValue("isUploading") || e.getValue("errors").length > 0) 6244 return; 6245 const t = this.cfg.multiple ? this.cfg.multipleMax : 1; 6246 if (!(t && this.uploadCollection.size > t)) { 6247 this._debouncedCalculateState(), e.setValue("isUploading", !0), e.setValue("errors", []); 6248 try { 6249 let s = new AbortController(); 6250 e.setValue("abortController", s); 6251 const r = async () => { 6252 let o = e.getValue("file"); 6253 o && this.cfg.imageShrink && (o = await this._processShrink(o).catch(() => o)); 6254 const a = o || e.getValue("externalUrl") || e.getValue("uuid"), c = { 6255 ...await this.getUploadClientOptions(), 6256 fileName: e.getValue("fileName"), 6257 source: e.getValue("source"), 6258 onProgress: (d) => { 6259 if (d.isComputable) { 6260 let u = d.value * 100; 6261 e.setValue("uploadProgress", u); 6262 } 6263 }, 6264 signal: s.signal, 6265 metadata: await this.getMetadataFor(e.uid) 6266 }; 6267 return this.debugPrint("upload options", a, c), fs(a, c); 6268 }; 6269 let n = await this.$["*uploadQueue"].add(r); 6270 e.setMultipleValues({ 6271 fileInfo: n, 6272 isUploading: !1, 6273 fileName: n.originalFilename, 6274 fileSize: n.size, 6275 isImage: n.isImage, 6276 mimeType: n.contentInfo?.mime?.mime ?? n.mimeType, 6277 uuid: n.uuid, 6278 cdnUrl: e.getValue("cdnUrl") ?? n.cdnUrl, 6279 cdnUrlModifiers: e.getValue("cdnUrlModifiers") ?? "", 6280 uploadProgress: 100, 6281 source: e.getValue("source") ?? null 6282 }), e === this._entry && this._debouncedCalculateState(); 6283 } catch (s) { 6284 s instanceof te && s.isCancel ? e.setMultipleValues({ 6285 isUploading: !1, 6286 uploadProgress: 0 6287 }) : e.setMultipleValues({ 6288 isUploading: !1, 6289 uploadProgress: 0, 6290 uploadError: s 6291 }), e === this._entry && this._debouncedCalculateState(); 6292 } 6293 } 6294 } 6295} 6296_e.template = /* HTML */ 6297` 6298 <div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused"> 6299 <div class="uc-thumb" set="style.backgroundImage: thumbUrl"> 6300 <div class="uc-badge"> 6301 <uc-icon set="@name: badgeIcon"></uc-icon> 6302 </div> 6303 </div> 6304 <div aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;">
6305 <span class="uc-file-name" set="@title: itemName">{{itemName}}</span> 6306 <span class="uc-file-error" set="@hidden: !errorText">{{errorText}}</span> 6307 </div> 6308 <div class="uc-file-actions"> 6309 <button 6310 type="button" 6311 l10n="@title:file-item-edit-button" 6312 class="uc-edit-btn uc-mini-btn" 6313 set="onclick: onEdit; @hidden: !isEditable" 6314 > 6315 <uc-icon name="edit-file"></uc-icon> 6316 </button> 6317 <button 6318 type="button" 6319 l10n="@title:file-item-remove-button" 6320 class="uc-remove-btn uc-mini-btn" 6321 set="onclick: onRemove;" 6322 > 6323 <uc-icon name="remove-file"></uc-icon> 6324 </button> 6325 <button type="button" class="uc-upload-btn uc-mini-btn" set="onclick: onUpload;"> 6326 <uc-icon name="upload"></uc-icon> 6327 </button> 6328 </div> 6329 <uc-progress-bar class="uc-progress-bar" set="value: progressValue; visible: progressVisible;"> </uc-progress-bar> 6330 </div> 6331`; 6332_e.activeInstances = /* @__PURE__ */ new Set(); 6333class Ps extends k { 6334 static styleAttrs = [...super.styleAttrs, "uc-modal"]; 6335 static StateConsumerScope = "modal"; 6336 constructor() { 6337 super(), this.init$ = { 6338 ...this.init$, 6339 "*modalActive": !1, 6340 isOpen: !1, 6341 closeClicked: this._handleDialogClose 6342 }; 6343 } 6344 _handleBackdropClick = () => { 6345 this._closeDialog(); 6346 }; 6347 _closeDialog = () => { 6348 this.setOrAddState("*modalActive", !1); 6349 }; 6350 _handleDialogClose = () => { 6351 this._closeDialog(); 6352 }; 6353 /** @param {Event} e */ 6354 _handleDialogMouseDown = (e) => { 6355 this._mouseDownTarget = e.target; 6356 }; 6357 /** @param {Event} e */ 6358 _handleDialogMouseUp = (e) => { 6359 e.target === this.ref.dialog && e.target === this._mouseDownTarget && this._closeDialog(); 6360 }; 6361 show() { 6362 this.ref.dialog.showModal ? this.ref.dialog.showModal() : this.ref.dialog.setAttribute("open", ""); 6363 } 6364 hide() { 6365 this.ref.dialog.close ? this.ref.dialog.close() : this.ref.dialog.removeAttribute("open"); 6366 } 6367 initCallback() { 6368 super.initCallback(), this.ref.dialog.addEventListener("close", this._handleDialogClose), this.ref.dialog.addEventListener("mousedown", this._handleDialogMouseDown), this.ref.dialog.addEventListener("mouseup", this._handleDialogMouseUp), this.sub("*modalActive", (e) => { 6369 this.$.isOpen !== e && (this.$.isOpen = e), e && this.cfg.modalScrollLock ? document.body.style.overflow = "hidden" : document.body.style.overflow = ""; 6370 }), this.subConfigValue("modalBackdropStrokes", (e) => { 6371 e ? this.setAttribute("strokes", "") : this.removeAttribute("strokes"); 6372 }), this.sub("isOpen", (e) => { 6373 e ? (this.show(), this.setAttribute("aria-modal", "true")) : (this.hide(), this.setAttribute("aria-modal", "false")); 6374 }); 6375 } 6376 destroyCallback() { 6377 super.destroyCallback(), document.body.style.overflow = "", this._mouseDownTarget = void 0, this.ref.dialog.removeEventListener("close", this._handleDialogClose), this.ref.dialog.removeEventListener("mousedown", this._handleDialogMouseDown), this.ref.dialog.removeEventListener("mouseup", this._handleDialogMouseUp); 6378 } 6379} 6380Ps.template = /* HTML */ 6381` 6382 <dialog ref="dialog"> 6383 <slot></slot> 6384 </dialog> 6385`; 6386const Ms = (i, e) => { 6387 let t, s, r; 6388 const n = (...o) => { 6389 t ? (clearTimeout(s), s = setTimeout( 6390 () => { 6391 Date.now() - r >= e && (i(...o), r = Date.now()); 6392 }, 6393 Math.max(e - (Date.now() - r), 0) 6394 )) : (i(...o), r = Date.now(), t = !0); 6395 }; 6396 return Object.defineProperty(n, "cancel", { 6397 configurable: !1, 6398 writable: !1, 6399 enumerable: !1, 6400 value: () => { 6401 clearTimeout(s); 6402 } 6403 }), /** @type {T & { readonly cancel: () => void }} */ 6404 /** @type {unknown} */ 6405 n; 6406}; 6407class Rs extends U { 6408 // Context owner should have access to CSS l10n 6409 // TODO: We need to move away l10n from CSS 6410 couldBeCtxOwner = !0; 6411 historyTracked = !0; 6412 activityType = _.activities.UPLOAD_LIST; 6413 constructor() { 6414 super(), this.init$ = { 6415 ...this.init$, 6416 doneBtnVisible: !1, 6417 doneBtnEnabled: !1, 6418 uploadBtnVisible: !1, 6419 addMoreBtnVisible: !1, 6420 addMoreBtnEnabled: !1, 6421 headerText: "", 6422 commonErrorMessage: "", 6423 hasFiles: !1, 6424 onAdd: () => { 6425 this.api.initFlow(!0); 6426 }, 6427 onUpload: () => {
6428 this.emit(O.UPLOAD_CLICK), this.api.uploadAll(), this._throttledHandleCollectionUpdate(); 6429 }, 6430 onDone: () => { 6431 this.emit(O.DONE_CLICK, this.api.getOutputCollectionState()), this.api.doneFlow(); 6432 }, 6433 onCancel: () => { 6434 this.uploadCollection.clearAll(); 6435 } 6436 }; 6437 } 6438 /** @private */ 6439 _throttledHandleCollectionUpdate = Ms(() => { 6440 this.isConnected && (this._updateUploadsState(), !this.couldOpenActivity && this.$["*currentActivity"] === this.activityType && this.historyBack()); 6441 }, 300); 6442 /** @private */ 6443 _updateUploadsState() { 6444 const e = this.api.getOutputCollectionState(), t = { 6445 total: e.totalCount, 6446 succeed: e.successCount, 6447 uploading: e.uploadingCount, 6448 failed: e.failedCount 6449 }, s = !e.errors.some( 6450 (u) => u.type === "TOO_MANY_FILES" || u.type === "TOO_FEW_FILES" 6451 ), r = e.errors.some((u) => u.type === "TOO_MANY_FILES"), n = e.totalCount === (this.cfg.multiple ? this.cfg.multipleMax : 1), o = t.failed === 0 && e.errors.length === 0; 6452 let a = !1, l = !1, c = !1; 6453 if (t.total - t.succeed - t.uploading - t.failed > 0 && s) 6454 a = !0; 6455 else { 6456 l = !0; 6457 const u = this.cfg.groupOutput ? !!e.group : !0; 6458 c = t.total === t.succeed && s && o && u; 6459 } 6460 this.set$({ 6461 doneBtnVisible: l, 6462 doneBtnEnabled: c, 6463 uploadBtnVisible: a, 6464 addMoreBtnEnabled: t.total === 0 || !r && !n, 6465 addMoreBtnVisible: !n || this.cfg.multiple 6466 }), this.bindL10n("headerText", () => this._getHeaderText(t)); 6467 } 6468 /** 6469 * @private 6470 * @param {Summary} summary 6471 */ 6472 _getHeaderText(e) { 6473 const t = (s) => { 6474 const r = e[s]; 6475 return this.l10n(`header-${s}`, { 6476 count: r 6477 }); 6478 }; 6479 return e.uploading > 0 ? t("uploading") : e.failed > 0 ? t("failed") : e.succeed > 0 ? t("succeed") : t("total"); 6480 } 6481 get couldOpenActivity() { 6482 return this.cfg.showEmptyList || this.uploadCollection.size > 0; 6483 } 6484 initCallback() { 6485 super.initCallback(), this.registerActivity(this.activityType), this.subConfigValue("multiple", this._throttledHandleCollectionUpdate), this.subConfigValue("multipleMin", this._throttledHandleCollectionUpdate), this.subConfigValue("multipleMax", this._throttledHandleCollectionUpdate), this.sub("*groupInfo", (e) => { 6486 e && this._throttledHandleCollectionUpdate(); 6487 }), this.sub("*currentActivity", (e) => { 6488 !this.couldOpenActivity && e === this.activityType && (this.$["*currentActivity"] = this.initActivity); 6489 }), this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate), this.sub( 6490 "*uploadList", 6491 (e) => { 6492 this._throttledHandleCollectionUpdate(), this.set$({ 6493 hasFiles: e.length > 0 6494 }), this.cfg.confirmUpload || this.api.uploadAll(); 6495 }, 6496 !1 6497 ), this.sub( 6498 "*collectionErrors", 6499 /** @param {import('../../types').OutputError<import('../../types').OutputCollectionErrorType>[]} errors */ 6500 (e) => { 6501 const t = e.filter((s) => s.type !== "SOME_FILES_HAS_ERRORS")[0]; 6502 if (!t) { 6503 this.set$({ 6504 commonErrorMessage: null 6505 }); 6506 return; 6507 } 6508 this.set$({ 6509 commonErrorMessage: t.message 6510 }); 6511 } 6512 ); 6513 } 6514 destroyCallback() { 6515 super.destroyCallback(), this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate); 6516 } 6517} 6518Rs.template = /* HTML */ 6519` 6520 <uc-activity-header> 6521 <span aria-live="polite" class="uc-header-text">{{headerText}}</span> 6522 <button 6523 type="button" 6524 class="uc-mini-btn uc-close-btn" 6525 set="onclick: *closeModal" 6526 l10n="@title:a11y-activity-header-button-close" 6527 > 6528 <uc-icon name="close"></uc-icon> 6529 </button> 6530 </uc-activity-header> 6531 6532 <div class="uc-no-files" set="@hidden: hasFiles"> 6533 <slot name="empty"><span l10n="no-files"></span></slot> 6534 </div> 6535 6536 <div class="uc-files" repeat="*uploadList" repeat-item-tag="uc-file-item"></div> 6537 6538 <div class="uc-common-error" set="@hidden: !commonErrorMessage; textContent: commonErrorMessage;"></div> 6539 6540 <div class="uc-toolbar"> 6541 <button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel;" l10n="clear"></button> 6542 <div class="uc-toolbar-spacer"></div> 6543 <button 6544 type="button" 6545 class="uc-add-more-btn uc-secondary-btn"
6546 set="onclick: onAdd; @disabled: !addMoreBtnEnabled; @hidden: !addMoreBtnVisible" 6547 > 6548 <uc-icon name="add"></uc-icon><span l10n="add-more"></span> 6549 </button> 6550 <button 6551 type="button" 6552 class="uc-upload-btn uc-primary-btn" 6553 set="@hidden: !uploadBtnVisible; onclick: onUpload;" 6554 l10n="upload" 6555 ></button> 6556 <button 6557 type="button" 6558 class="uc-done-btn uc-primary-btn" 6559 set="@hidden: !doneBtnVisible; onclick: onDone; @disabled: !doneBtnEnabled" 6560 l10n="done" 6561 ></button> 6562 </div> 6563 6564 <uc-drop-area ghost></uc-drop-area> 6565`; 6566class Ds extends U { 6567 couldBeCtxOwner = !0; 6568 activityType = _.activities.URL; 6569 init$ = { 6570 ...this.init$, 6571 importDisabled: !0, 6572 onUpload: (e) => { 6573 e.preventDefault(); 6574 let t = this.ref.input.value; 6575 this.api.addFileFromUrl(t, { source: P.URL }), this.$["*currentActivity"] = _.activities.UPLOAD_LIST; 6576 }, 6577 onCancel: () => { 6578 this.historyBack(); 6579 }, 6580 onInput: (e) => { 6581 let t = ( 6582 /** @type {HTMLInputElement} */ 6583 e.target.value 6584 ); 6585 this.set$({ importDisabled: !t }); 6586 } 6587 }; 6588 initCallback() { 6589 super.initCallback(), this.registerActivity(this.activityType, { 6590 onActivate: () => { 6591 this.ref.input.value = "", this.ref.input.focus(); 6592 } 6593 }); 6594 } 6595} 6596Ds.template = /* HTML */ 6597` 6598 <uc-activity-header> 6599 <button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back"> 6600 <uc-icon name="back"></uc-icon> 6601 </button> 6602 <div> 6603 <uc-icon name="url"></uc-icon> 6604 <span l10n="caption-from-url"></span> 6605 </div> 6606 <button 6607 type="button" 6608 class="uc-mini-btn uc-close-btn" 6609 set="onclick: *closeModal" 6610 l10n="@title:a11y-activity-header-button-close" 6611 > 6612 <uc-icon name="close"></uc-icon> 6613 </button> 6614 </uc-activity-header> 6615 <form class="uc-content"> 6616 <input placeholder="https://" class="uc-url-input" type="text" ref="input" set="oninput: onInput" /> 6617 <button 6618 type="submit" 6619 class="uc-url-upload-btn uc-primary-btn" 6620 set="onclick: onUpload; @disabled: importDisabled" 6621 l10n="upload-url" 6622 ></button> 6623 </form> 6624`; 6625const bl = () => typeof navigator.permissions < "u", _l = { 6626 width: { 6627 ideal: 1920 6628 }, 6629 height: { 6630 ideal: 1080 6631 }, 6632 frameRate: { 6633 ideal: 30 6634 } 6635}, Ri = ["camera", "microphone"]; 6636function Ze(i) { 6637 const e = Math.floor(i / 60).toString().padStart(2, "0"), t = Math.floor(i % 60).toString().padStart(2, "0"); 6638 return `${e}:${t}`; 6639} 6640const Di = "image/jpeg", Fi = "video/webm"; 6641class x extends U { 6642 couldBeCtxOwner = !0; 6643 activityType = _.activities.CAMERA; 6644 /** @private */ 6645 _unsubPermissions = null; 6646 /** @type {BlobPart[]} */ 6647 _chunks = []; 6648 /** @type {MediaRecorder | null} */ 6649 _mediaRecorder = null; 6650 /** @type {MediaStream | null} */ 6651 _stream = null; 6652 /** @type {string | null} */ 6653 _selectedAudioId = null; 6654 /** @type {string | null} */ 6655 _selectedCameraId = null; 6656 constructor() { 6657 super(), this.init$ = { 6658 ...this.init$, 6659 video: null, 6660 videoTransformCss: null, 6661 videoHidden: !0, 6662 messageHidden: !0, 6663 requestBtnHidden: bl(), 6664 cameraSelectOptions: null, 6665 cameraSelectHidden: !0, 6666 l10nMessage: "", 6667 // This is refs 6668 switcher: null, 6669 panels: null, 6670 timer: null, 6671 timerHidden: !0, 6672 cameraHidden: !0, 6673 cameraActionsHidden: !0, 6674 audioSelectOptions: null, 6675 audioSelectHidden: !0, 6676 audioSelectDisabled: !0, 6677 audioToggleMicorphoneHidden: !0, 6678 tabCameraHidden: !0, 6679 tabVideoHidden: !0, 6680 currentIcon: "camera-full", 6681 currentTimelineIcon: "play", 6682 toggleMicorphoneIcon: "microphone", 6683 /** @type {Number} */ 6684 _startTime: 0, 6685 /** @type {Number} */ 6686 _elapsedTime: 0, 6687 _animationFrameId: null, 6688 mutableClassButton: "uc-shot-btn uc-camera-action", 6689 /** @param {Event} e */ 6690 onCameraSelectChange: (e) => { 6691 this._selectedCameraId = e.target.value, this._capture(); 6692 }, 6693 /** @param {Event} e */ 6694 onAudioSelectChange: (e) => { 6695 this._selectedAudioId = e.target.value, this._capture(); 6696 }, 6697 onCancel: () => { 6698 this.historyBack(); 6699 }, 6700 onShot: () => this._shot(), 6701 onRequestPermissions: () => this._capture(), 6702 /** General method for photo and video capture */ 6703 onStartCamera: () => this._chooseActionWithCamera(), 6704 onStartRecording: () => this._startRecording(), 6705 onStopRecording: () => this._stopRecording(), 6706 onToggleRecording: () => this._toggleRecording(), 6707 onToggleAudio: () => this._toggleEnableAudio(), 6708 onRetake: () => this._retake(), 6709 onAccept: () => this._accept(), 6710 /** @param {MouseEvent} e */ 6711 onClickTab: (e) => { 6712 const t = ( 6713 /** @type {HTMLElement} */ 6714 e.currentTarget.getAttribute("data-id") 6715 ); 6716 t && this._handleActiveTab( 6717 /** @type {CameraTabId} */ 6718 t 6719 ); 6720 } 6721 }; 6722 } 6723 _chooseActionWithCamera = () => { 6724 if (this._activeTab === x.types.PHOTO && this._shot(), this._activeTab === x.types.VIDEO) { 6725 if (this._mediaRecorder?.state === "recording") { 6726 this._stopRecording(); 6727 return; 6728 } 6729 this._startRecording(); 6730 } 6731 }; 6732 _updateTimer = () => { 6733 const e = Math.floor((performance.now() - this.$._startTime + this.$._elapsedTime) / 1e3); 6734 if (typeof this.cfg.maxVideoRecordingDuration == "number" && this.cfg.maxVideoRecordingDuration > 0) { 6735 const t = this.cfg.maxVideoRecordingDuration - e; 6736 if (t <= 0) { 6737 this.ref.timer.textContent = Ze(t), this._stopRecording(); 6738 return; 6739 } 6740 this.ref.timer.textContent = Ze(t); 6741 } else 6742 this.ref.timer.textContent = Ze(e); 6743 this._animationFrameId = requestAnimationFrame(this._updateTimer); 6744 }; 6745 _startTimer = () => { 6746 this.$._startTime = performance.now(), this.$._elapsedTime = 0, this._updateTimer(); 6747 }; 6748 _stopTimer = () => { 6749 this._animationFrameId && cancelAnimationFrame(this._animationFrameId); 6750 }; 6751 _startTimeline = () => { 6752 const e = this.ref.video.currentTime, t = this.ref.video.duration; 6753 this.ref.line.style.transform = `scaleX(${e / t})`, this.ref.timer.textContent = Ze(e), this._animationFrameId = requestAnimationFrame(this._startTimeline); 6754 }; 6755 _stopTimeline = () => { 6756 this._animationFrameId && cancelAnimationFrame(this._animationFrameId); 6757 }; 6758 _startRecording = () => { 6759 try { 6760 this._chunks = [], this._options = { 6761 ...this.cfg.mediaRecorerOptions 6762 }; 6763 const { mimeType: e } = this.cfg.mediaRecorerOptions || {};
6764 e && MediaRecorder.isTypeSupported(e) ? this._options.mimeType = e : MediaRecorder.isTypeSupported(Fi) ? this._options.mimeType = Fi : this._options.mimeType = "video/mp4", this._stream && (this._mediaRecorder = new MediaRecorder(this._stream, this._options), this._mediaRecorder.start(), this._mediaRecorder.addEventListener("dataavailable", (t) => { 6765 this._chunks.push(t.data); 6766 }), this._startTimer(), this.classList.add("uc-recording"), this._setCameraState(x.events.PLAY)); 6767 } catch (e) { 6768 console.error("Failed to start recording", e); 6769 } 6770 }; 6771 /** @private */ 6772 _stopRecording = () => { 6773 this._mediaRecorder?.addEventListener("stop", () => { 6774 this._previewVideo(), this._stopTimer(), this._setCameraState(x.events.STOP); 6775 }), this._mediaRecorder?.stop(), this.classList.remove("uc-recording"); 6776 }; 6777 /** This method is used to toggle recording pause/resume */ 6778 _toggleRecording = () => { 6779 this._mediaRecorder?.state !== "recording" && (!this.ref.video.paused && !this.ref.video.ended && this.ref.video.readyState > 2 ? this.ref.video.pause() : this.ref.video.paused && this.ref.video.play()); 6780 }; 6781 _toggleEnableAudio = () => { 6782 this._stream?.getAudioTracks().forEach((e) => { 6783 e.enabled = !e.enabled, this.$.toggleMicorphoneIcon = e.enabled ? "microphone" : "microphone-mute", this.$.audioSelectDisabled = !e.enabled; 6784 }); 6785 }; 6786 /** 6787 * Previewing the video that was recorded on the camera 6788 * 6789 * @private 6790 */ 6791 _previewVideo = () => { 6792 try { 6793 const e = new Blob(this._chunks, { 6794 type: this._mediaRecorder?.mimeType 6795 }), t = URL.createObjectURL(e); 6796 this.ref.video.muted = !1, this.ref.video.volume = 1, this.$.video = null, this.ref.video.src = t, this.ref.video.addEventListener("play", () => { 6797 this._startTimeline(), this.set$({ 6798 currentTimelineIcon: "pause" 6799 }); 6800 }), this.ref.video.addEventListener("pause", () => { 6801 this.set$({ 6802 currentTimelineIcon: "play" 6803 }), this._stopTimeline(); 6804 }); 6805 } catch (e) { 6806 console.error("Failed to preview video", e); 6807 } 6808 }; 6809 _retake = () => { 6810 this._setCameraState(x.events.RETAKE), this._activeTab === x.types.VIDEO && (this.$.video = this._stream, this.ref.video.muted = !0), this.ref.video.play(); 6811 }; 6812 _accept = () => { 6813 if (this._setCameraState(x.events.ACCEPT), this._activeTab === x.types.PHOTO) { 6814 this._canvas?.toBlob((r) => { 6815 const n = this._createFile("camera", "jpeg", Di, r); 6816 this._toSend(n); 6817 }, Di); 6818 return; 6819 } 6820 const e = new Blob(this._chunks, { 6821 type: this._mediaRecorder?.mimeType 6822 }), t = this._guessExtensionByMime(this._mediaRecorder?.mimeType), s = this._createFile("video", t, `video/${t}`, e); 6823 this._toSend(s), this._chunks = []; 6824 }; 6825 /** @param {CameraStatus} status */ 6826 _handlePhoto = (e) => { 6827 e === x.events.SHOT && this.set$({ 6828 tabVideoHidden: !0, 6829 cameraHidden: !0, 6830 tabCameraHidden: !0, 6831 cameraActionsHidden: !1, 6832 cameraSelectHidden: !0 6833 }), (e === x.events.RETAKE || e === x.events.ACCEPT) && this.set$({ 6834 tabVideoHidden: !this.cfg.enableVideoRecording, 6835 cameraHidden: !1, 6836 tabCameraHidden: !1, 6837 cameraActionsHidden: !0, 6838 cameraSelectHidden: this.cameraDevices.length <= 1 6839 }); 6840 }; 6841 /** @param {CameraStatus} status */ 6842 _handleVideo = (e) => { 6843 e === x.events.PLAY && this.set$({ 6844 timerHidden: !1, 6845 tabCameraHidden: !0, 6846 cameraSelectHidden: !0, 6847 audioSelectHidden: !0, 6848 currentTimelineIcon: "pause", 6849 currentIcon: "square", 6850 mutableClassButton: "uc-shot-btn uc-camera-action uc-stop-record" 6851 }), e === x.events.STOP && this.set$({ 6852 timerHidden: !1, 6853 cameraHidden: !0, 6854 audioToggleMicorphoneHidden: !0, 6855 cameraActionsHidden: !1 6856 }), (e === x.events.RETAKE || e === x.events.ACCEPT) && this.set$({ 6857 timerHidden: !0, 6858 tabCameraHidden: !1, 6859 cameraHidden: !1, 6860 cameraActionsHidden: !0, 6861 audioToggleMicorphoneHidden: !this.cfg.enableAudioRecording, 6862 currentIcon: "video-camera-full",
6863 mutableClassButton: "uc-shot-btn uc-camera-action", 6864 audioSelectHidden: !this.cfg.enableAudioRecording || this.audioDevices.length <= 1, 6865 cameraSelectHidden: this.cameraDevices.length <= 1 6866 }); 6867 }; 6868 /** 6869 * @private 6870 * @param {CameraStatus} status 6871 */ 6872 _setCameraState = (e) => { 6873 this._activeTab === x.types.PHOTO && (e === "shot" || e === "retake" || e === "accept") && this._handlePhoto(e), this._activeTab === x.types.VIDEO && (e === "play" || e === "stop" || e === "retake" || e === "accept" || e === "pause" || e === "resume") && this._handleVideo(e); 6874 }; 6875 /** @private */ 6876 _shot() { 6877 if (this._setCameraState("shot"), this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), !this._ctx) 6878 throw new Error("Failed to get canvas context"); 6879 this._canvas.height = this.ref.video.videoHeight, this._canvas.width = this.ref.video.videoWidth, this.cfg.cameraMirror && (this._ctx.translate(this._canvas.width, 0), this._ctx.scale(-1, 1)), this._ctx.drawImage(this.ref.video, 0, 0), this.ref.video.pause(); 6880 } 6881 /** 6882 * @private 6883 * @param {CameraTabId} tabId 6884 */ 6885 _handleActiveTab = (e) => { 6886 this.ref.switcher.querySelectorAll("button").forEach((t) => { 6887 t.classList.toggle("uc-active", t.getAttribute("data-id") === e); 6888 }), e === x.types.PHOTO && this.set$({ 6889 currentIcon: "camera-full", 6890 audioSelectHidden: !0, 6891 audioToggleMicorphoneHidden: !0 6892 }), e === x.types.VIDEO && this.set$({ 6893 currentTimelineIcon: "play", 6894 currentIcon: "video-camera-full", 6895 audioSelectHidden: !this.cfg.enableAudioRecording || this.audioDevices.length <= 1, 6896 audioToggleMicorphoneHidden: !this.cfg.enableAudioRecording 6897 }), this._activeTab = e; 6898 }; 6899 /** 6900 * @param {'camera' | 'video'} type 6901 * @param {'jpeg' | 'webm'} ext 6902 * @param {String} format 6903 * @param {Blob} blob 6904 */ 6905 _createFile = (e, t, s, r) => { 6906 const n = Date.now(), o = `${e}-${n}.${t}`; 6907 return new File([r], o, { 6908 lastModified: n, 6909 type: s 6910 }); 6911 }; 6912 /** @param {String | undefined} mime */ 6913 _guessExtensionByMime(e) { 6914 const t = { 6915 mp4: "mp4", 6916 ogg: "ogg", 6917 webm: "webm", 6918 quicktime: "mov", 6919 "x-matroska": "mkv" 6920 }; 6921 if (e === "") 6922 return "webm"; 6923 if (e && (e = e.split("/"), e?.[0] === "video")) { 6924 e = e.slice(1).join("/"); 6925 const s = e?.split(";")[0]; 6926 if (t[s]) 6927 return t[s]; 6928 } 6929 return "avi"; 6930 } 6931 /** 6932 * The send file to the server 6933 * 6934 * @param {File} file 6935 */ 6936 _toSend = (e) => { 6937 this.api.addFileFromObject(e, { source: P.CAMERA }), this.set$({ 6938 "*currentActivity": _.activities.UPLOAD_LIST 6939 }); 6940 }; 6941 /** 6942 * @private 6943 * @param {'granted' | 'denied' | 'prompt'} state 6944 */ 6945 _setPermissionsState = G((e) => { 6946 this.classList.toggle("uc-initialized", e === "granted"); 6947 const t = this._activeTab === x.types.VIDEO && this.cfg.enableAudioRecording, s = this._activeTab === x.types.PHOTO ? "camera-full" : "video-camera-full"; 6948 e === "granted" ? this.set$({ 6949 videoHidden: !1, 6950 cameraHidden: !1, 6951 tabCameraHidden: !1, 6952 messageHidden: !0, 6953 timerHidden: !0, 6954 currentIcon: s, 6955 audioToggleMicorphoneHidden: !t, 6956 audioSelectHidden: !t 6957 }) : e === "prompt" ? (this.$.l10nMessage = "camera-permissions-prompt", this.set$({ 6958 videoHidden: !0, 6959 cameraHidden: !0, 6960 tabCameraHidden: !0, 6961 messageHidden: !1 6962 }), this._stopCapture()) : (this.$.l10nMessage = "camera-permissions-denied", this.set$({ 6963 videoHidden: !0, 6964 messageHidden: !1, 6965 tabCameraHidden: !1, 6966 tabVideoHidden: !this.cfg.enableVideoRecording, 6967 cameraActionsHidden: !0, 6968 mutableClassButton: "uc-shot-btn uc-camera-action" 6969 }), this._stopCapture()); 6970 }, 300); 6971 _makeStreamInactive = () => { 6972 if (!this._stream) return !1; 6973 const e = this._stream?.getAudioTracks(), t = this._stream?.getVideoTracks(); 6974 e.forEach((s) => s.stop()), t.forEach((s) => s.stop()); 6975 }; 6976 _stopCapture = () => { 6977 this._capturing && (this.ref.video.volume = 0, this.$.video?.getTracks()[0].stop(), this.$.video = null, this._makeStreamInactive(), this._stopTimer(), this._capturing = !1); 6978 }; 6979 _capture = async () => { 6980 const e = { 6981 video: _l, 6982 audio: this.cfg.enableAudioRecording ? {} : !1 6983 }; 6984 this._selectedCameraId && (e.video = { 6985 deviceId: { 6986 exact: this._selectedCameraId 6987 } 6988 }), this._selectedAudioId && this.cfg.enableAudioRecording && (e.audio = { 6989 deviceId: { 6990 exact: this._selectedAudioId 6991 } 6992 }), this.ref.video.volume = 0; 6993 try { 6994 this._setPermissionsState("prompt"), this._stream = await navigator.mediaDevices.getUserMedia(e), this._stream.addEventListener("inactive", () => { 6995 this._setPermissionsState("denied"); 6996 }), this.$.video = this._stream, this._capturing = !0, this._setPermissionsState("granted"); 6997 } catch (t) { 6998 this._setPermissionsState("denied"), console.log("Failed to capture camera", t); 6999 } 7000 }; 7001 _handlePermissionsChange = () => { 7002 this._capture(); 7003 }; 7004 _permissionAccess = async () => { 7005 try { 7006 for (const e of Ri) 7007 this[`${e}Response`] = await navigator.permissions.query({ name: e }), this[`${e}Response`].addEventListener("change", this._handlePermissionsChange); 7008 } catch (e) { 7009 console.log("Failed to use permissions API. Fallback to manual request mode.", e), this._capture(); 7010 } 7011 }; 7012 _getPermission = () => { 7013 }; 7014 _requestDeviceAccess = async () => { 7015 try { 7016 await navigator.mediaDevices.getUserMedia({ video: !0, audio: this.cfg.enableAudioRecording }), await this._getDevices(), navigator.mediaDevices.addEventListener("devicechange", this._getDevices); 7017 } catch (e) { 7018 console.log("Failed to get user media", e); 7019 } 7020 }; 7021 _getDevices = async () => { 7022 try { 7023 const e = await navigator.mediaDevices.enumerateDevices(); 7024 this.cameraDevices = e.filter((t) => t.kind === "videoinput").map((t, s) => ({ 7025 text: t.label.trim() || `${this.l10n("caption-camera")} ${s + 1}`, 7026 value: t.deviceId 7027 })), this.audioDevices = this.cfg.enableAudioRecording && e.filter((t) => t.kind === "audioinput").map((t) => ({ 7028 text: t.label.trim(), 7029 value: t.deviceId 7030 })), this.cameraDevices.length > 1 && this.set$({ 7031 cameraSelectOptions: this.cameraDevices, 7032 cameraSelectHidden: !1 7033 }), this._selectedCameraId = this.cameraDevices[0]?.value, this.audioDevices.length > 1 && this.set$({ 7034 audioSelectOptions: this.audioDevices, 7035 audioSelectHidden: !1 7036 }), this._selectedAudioId = this.audioDevices[0]?.value; 7037 } catch (e) { 7038 console.log("Failed to get devices", e); 7039 } 7040 }; 7041 _onActivate = async () => { 7042 await this._permissionAccess(), await this._requestDeviceAccess(), await this._capture(); 7043 }; 7044 _onDeactivate = async () => { 7045 this._unsubPermissions && this._unsubPermissions(), window.chrome || this._setPermissionsState("denied"), this._stopCapture(); 7046 }; 7047 initCallback() { 7048 super.initCallback(), this.registerActivity(this.activityType, { 7049 onActivate: this._onActivate, 7050 onDeactivate: this._onDeactivate 7051 }), this.subConfigValue("cameraMirror", (e) => { 7052 this.$.videoTransformCss = e ? "scaleX(-1)" : null; 7053 }), this.subConfigValue("enableAudioRecording", (e) => { 7054 this.$.audioToggleMicorphoneHidden = !e, this.$.audioSelectDisabled = !e; 7055 }), this.subConfigValue("enableVideoRecording", (e) => { 7056 this.$.tabVideoHidden = !e; 7057 }), this.subConfigValue("defaultCameraMode", (e) => { 7058 if (this.cfg.enableVideoRecording) { 7059 this._handleActiveTab(e); 7060 return; 7061 } 7062 this._handleActiveTab("photo"); 7063 }); 7064 } 7065 _destroy() { 7066 for (const e of Ri) 7067 this[`${e}Response`]?.removeEventListener("change", this._handlePermissionsChange); 7068 navigator.mediaDevices?.removeEventListener("devicechange", this._getDevices); 7069 } 7070 async destroyCallback() { 7071 super.destroyCallback(), this._destroy(); 7072 } 7073} 7074x.types = Object.freeze({ 7075 PHOTO: "photo", 7076 VIDEO: "video" 7077}); 7078x.events = Object.freeze({ 7079 IDLE: "idle", 7080 SHOT: "shot", 7081 PLAY: "play", 7082 PAUSE: "pause", 7083 RESUME: "resume", 7084 STOP: "stop", 7085 RETAKE: "retake", 7086 ACCEPT: "accept" 7087}); 7088x.template = /* HTML */ 7089` 7090 <uc-activity-header> 7091 <button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back"> 7092 <uc-icon name="back"></uc-icon> 7093 </button> 7094 <div set="@hidden: !cameraSelectHidden"> 7095 <uc-icon name="camera"></uc-icon>
7096 <span l10n="caption-camera"></span> 7097 </div> 7098 <uc-select 7099 class="uc-camera-select" 7100 set="$.options: cameraSelectOptions; @hidden: cameraSelectHidden; onchange: onCameraSelectChange" 7101 > 7102 </uc-select> 7103 <button 7104 type="button" 7105 class="uc-mini-btn uc-close-btn" 7106 set="onclick: *closeModal" 7107 l10n="@title:a11y-activity-header-button-close" 7108 > 7109 <uc-icon name="close"></uc-icon> 7110 </button> 7111 </uc-activity-header> 7112 <div class="uc-content"> 7113 <video 7114 muted 7115 autoplay 7116 playsinline 7117 set="srcObject: video; style.transform: videoTransformCss; @hidden: videoHidden" 7118 ref="video" 7119 ></video> 7120 <div class="uc-message-box" set="@hidden: messageHidden"> 7121 <span l10n="l10nMessage"></span> 7122 <button 7123 type="button" 7124 set="onclick: onRequestPermissions; @hidden: requestBtnHidden" 7125 l10n="camera-permissions-request" 7126 ></button> 7127 </div> 7128 </div> 7129 7130 <div class="uc-controls"> 7131 <div ref="switcher" class="uc-switcher" set="@hidden:!timerHidden"> 7132 <button 7133 data-id="photo" 7134 type="button" 7135 class="uc-switch uc-mini-btn" 7136 set="onclick: onClickTab; @hidden: tabCameraHidden" 7137 > 7138 <uc-icon name="camera"></uc-icon> 7139 </button> 7140 <button 7141 data-id="video" 7142 type="button" 7143 class="uc-switch uc-mini-btn" 7144 set="onclick: onClickTab; @hidden: tabVideoHidden" 7145 > 7146 <uc-icon name="video-camera"></uc-icon> 7147 </button> 7148 </div> 7149 7150 <button class="uc-secondary-btn uc-recording-timer" set="@hidden:timerHidden; onclick: onToggleRecording"> 7151 <uc-icon set="@name: currentTimelineIcon"></uc-icon> 7152 <span ref="timer"> 00:00 </span> 7153 <span ref="line" class="uc-line"></span> 7154 </button> 7155 7156 <div class="uc-camera-actions uc-camera-action" set="@hidden: cameraActionsHidden"> 7157 <button type="button" class="uc-secondary-btn" set="onclick: onRetake">Retake</button> 7158 <button type="button" class="uc-primary-btn" set="onclick: onAccept">Accept</button> 7159 </div> 7160 7161 <button 7162 type="button" 7163 class="uc-shot-btn uc-camera-action" 7164 set="onclick: onStartCamera; @class: mutableClassButton; @hidden: cameraHidden;" 7165 > 7166 <uc-icon set="@name: currentIcon"></uc-icon> 7167 </button> 7168 7169 <div class="uc-select"> 7170 <button class="uc-mini-btn uc-btn-microphone" set="onclick: onToggleAudio; @hidden: audioToggleMicorphoneHidden;"> 7171 <uc-icon set="@name:toggleMicorphoneIcon"></uc-icon> 7172 </button> 7173 7174 <uc-select 7175 class="uc-audio-select" 7176 set="$.options: audioSelectOptions; onchange: onAudioSelectChange; @hidden: audioSelectHidden; @disabled: audioSelectDisabled" 7177 > 7178 </uc-select> 7179 </div> 7180 </div> 7181`; 7182class Fs extends U { 7183 requireCtxName = !0; 7184 initCallback() { 7185 super.initCallback(), this.$["*eventEmitter"].bindTarget(this); 7186 } 7187 destroyCallback() { 7188 super.destroyCallback(), this.$["*eventEmitter"].unbindTarget(this); 7189 } 7190} 7191Fs.EventType = O; 7192const yl = ( 7193 /** @type {UploadCtxProvider} */ 7194 /** @type {unknown} */ 7195 Fs 7196); 7197class Vs extends U { 7198 init$ = { 7199 ...this.init$, 7200 visible: !1, 7201 value: 0, 7202 "*commonProgress": 0 7203 }; 7204 initCallback() { 7205 super.initCallback(), this._unobserveCollection = this.uploadCollection.observeProperties(() => { 7206 let e = this.uploadCollection.items().some((t) => this.uploadCollection.read(t).getValue("isUploading")); 7207 this.$.visible = e; 7208 }), this.sub("visible", (e) => { 7209 e ? this.setAttribute("active", "") : this.removeAttribute("active"); 7210 }), this.sub("*commonProgress", (e) => { 7211 this.$.value = e; 7212 }); 7213 } 7214 destroyCallback() { 7215 super.destroyCallback(), this._unobserveCollection?.(); 7216 } 7217} 7218Vs.template = /* HTML */ 7219' <uc-progress-bar set="visible: visible; value: value"></uc-progress-bar> '; 7220class Ns extends k { 7221 /** @type {Number} */ 7222 _value = 0; 7223 init$ = { 7224 ...this.init$, 7225 width: 0, 7226 opacity: 0 7227 }; 7228 initCallback() { 7229 super.initCallback(), this.defineAccessor("value", (e) => { 7230 if (e === void 0) 7231 return; 7232 const t = this._value; 7233 if (this._value = e, e === 0 && t > 0) { 7234 this.ref.line.addEventListener("transitionend", () => { 7235 this.style.setProperty("--l-width", this._value.toString()); 7236 }); 7237 return; 7238 } 7239 this.style.setProperty("--l-width", this._value.toString()); 7240 }), this.defineAccessor("visible", (e) => { 7241 this.ref.line.classList.toggle("uc-progress--hidden", !e); 7242 }); 7243 } 7244} 7245Ns.template = /* HTML */ 7246' <div ref="line" class="uc-progress"></div> '; 7247const ke = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; 7248function zs(...i) { 7249 return i.reduce((e, t) => { 7250 if (typeof t == "string") 7251 return e[t] = !0, e; 7252 for (let s of Object.keys(t)) 7253 e[s] = t[s]; 7254 return e; 7255 }, {}); 7256} 7257function X(...i) { 7258 let e = zs(...i); 7259 return Object.keys(e).reduce((t, s) => (e[s] && t.push(s), t), []).join(" "); 7260} 7261function vl(i, ...e) { 7262 let t = zs(...e); 7263 for (let s of Object.keys(t)) 7264 i.classList.toggle(s, t[s]); 7265} 7266const wl = (i) => { 7267 if (!i) return J; 7268 const e = Br(i).filter((t) => J.includes(t)); 7269 return e.length === 0 ? J : e; 7270}; 7271function Cl(i) { 7272 return { 7273 "*originalUrl": null, 7274 "*faderEl": null, 7275 "*cropperEl": null, 7276 "*imgEl": null, 7277 "*imgContainerEl": null, 7278 "*networkProblems": !1, 7279 "*imageSize": null, 7280 /** @type {import('./types.js').Transformations} */ 7281 "*editorTransformations": {}, 7282 /** @type {import('./types.js').CropPresetList} */ 7283 "*cropPresetList": [], 7284 "*tabList": J, 7285 "*tabId": I.CROP, 7286 entry: null, 7287 extension: null, 7288 editorMode: !1, 7289 modalCaption: "", 7290 isImage: !1, 7291 msg: "", 7292 src: ke, 7293 fileType: "", 7294 showLoader: !1, 7295 // options 7296 uuid: null, 7297 cdnUrl: null, 7298 cropPreset: "", 7299 tabs: Ft(J), 7300 "presence.networkProblems": !1, 7301 "presence.modalCaption": !0, 7302 "presence.editorToolbar": !1, 7303 "presence.viewerToolbar": !0, 7304 // TODO: beware of wrong ctx in case of element re-creation: 7305 "*on.retryNetwork": () => { 7306 let e = i.querySelectorAll("img"); 7307 for (let t of e) { 7308 let s = t.src; 7309 t.src = ke, t.src = s; 7310 } 7311 i.$["*networkProblems"] = !1; 7312 }, 7313 /** @param {import('./types.js').Transformations} transformations */ 7314 "*on.apply": (e) => { 7315 if (!e) 7316 return; 7317 let t = i.$["*originalUrl"], s = le(rt(e), "preview"), r = j(t, s), n = { 7318 originalUrl: t, 7319 cdnUrlModifiers: s, 7320 cdnUrl: r, 7321 transformations: e 7322 }; 7323 i.dispatchEvent( 7324 new CustomEvent("apply", { 7325 detail: n, 7326 bubbles: !0, 7327 composed: !0 7328 }) 7329 ), i.remove(); 7330 }, 7331 "*on.cancel": () => { 7332 i.remove(), i.dispatchEvent( 7333 new CustomEvent("cancel", { 7334 bubbles: !0, 7335 composed: !0 7336 }) 7337 ); 7338 } 7339 }; 7340} 7341const Al = "<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMa
7341x' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='puc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs>
7341<circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#puc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#suc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#suc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#suc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#suc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#suc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#suc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#suc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#suc-icon-id__h)'/><defs><linearGradient id='suc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.3
734115-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>", El = ( 7342 /* HTML */ 7343 ` 7344 ${Al} 7345 <div class="uc-wrapper uc-wrapper_desktop"> 7346 <uc-presence-toggle class="uc-network_problems_splash" set="visible: presence.networkProblems;"> 7347 <div class="uc-network_problems_content"> 7348 <div class="uc-network_problems_icon"> 7349 <uc-icon name="sad"></uc-icon> 7350 </div> 7351 <div class="uc-network_problems_text">Network error</div> 7352 </div> 7353 <div class="uc-network_problems_footer"> 7354 <uc-btn-ui theme="primary" text="Retry" set="onclick: *on.retryNetwork"></uc-btn-ui> 7355 </div> 7356 </uc-presence-toggle> 7357 <div class="uc-viewport"> 7358 <div class="uc-file_type_outer"> 7359 <div class="uc-file_type">{{fileType}}</div> 7360 </div> 7361 <div class="uc-image_container" ref="img-container-el"> 7362 <img src="${ke}" class="uc-image uc-image_visible_from_editor" ref="img-el" /> 7363 <uc-editor-image-cropper ref="cropper-el"></uc-editor-image-cropper> 7364 <uc-editor-image-fader ref="fader-el"></uc-editor-image-fader> 7365 </div> 7366 <div class="uc-info_pan">{{msg}}</div> 7367 </div> 7368 <div class="uc-toolbar"> 7369 <uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui> 7370 <div class="uc-toolbar_content uc-toolbar_content__editor"> 7371 <uc-editor-toolbar></uc-editor-toolbar> 7372 </div> 7373 </div> 7374 </div> 7375` 7376); 7377class He extends k { 7378 ctxOwner = !0; 7379 static styleAttrs = ["uc-cloud-image-editor"]; 7380 constructor() { 7381 super(), this.init$ = { 7382 ...this.init$, 7383 ...Cl(this) 7384 }; 7385 } 7386 /** @private */ 7387 _debouncedShowLoader = G(this._showLoader.bind(this), 300); 7388 /** 7389 * @private 7390 * @param {boolean} show 7391 */ 7392 _showLoader(e) { 7393 this.$.showLoader = e; 7394 } 7395 /** 7396 * To proper work, we need non-zero size the element. So, we'll wait for it. 7397 * 7398 * @private 7399 * @returns {Promise<void>} 7400 */ 7401 _waitForSize() { 7402 return new Promise((t, s) => { 7403 const r = setTimeout(() => { 7404 s(new Error("[cloud-image-editor] timeout waiting for non-zero container size")); 7405 }, 3e3), n = new ResizeObserver(([o]) => { 7406 o.contentRect.width > 0 && o.contentRect.height > 0 && (t(), clearTimeout(r), n.disconnect()); 7407 }); 7408 n.observe(this); 7409 }); 7410 } 7411 initCallback() { 7412 super.initCallback(), this.$["*faderEl"] = this.ref["fader-el"], this.$["*cropperEl"] = this.ref["cropper-el"], this.$["*imgContainerEl"] = this.ref["img-container-el"], this.initEditor(); 7413 } 7414 async updateImage() { 7415 if (this.isConnected) { 7416 if (await this._waitForSize(), this.$.cdnUrl) { 7417 const e = qi(this.$.cdnUrl), t = Ve(this.$.cdnUrl, e); 7418 if (t === this.$["*originalUrl"]) 7419 return; 7420 this.$["*originalUrl"] = t; 7421 const s = Ur(this.$.cdnUrl), r = Fr(s); 7422 this.$["*editorTransformations"] = r; 7423 } else if (this.$.uuid) { 7424 const e = Ve(this.cfg.cdnCname, this.$.uuid); 7425 if (e === this.$["*originalUrl"]) 7426 return; 7427 this.$["*originalUrl"] = e, this.$["*editorTransformations"] = {}; 7428 } else 7429 throw new Error("No UUID nor CDN URL provided"); 7430 this.$["*tabId"] === I.CROP ? this.$["*cropperEl"].deactivate({ reset: !0 }) : this.$["*faderEl"].deactivate(); 7431 try { 7432 const e = await this.proxyUrl(j(this.$["*originalUrl"], le("json"))), t = await fetch(e).then((n) => n.json()), { width: s, height: r } = ( 7433 /** @type {{ width: number; height: number }} */ 7434 t 7435 ); 7436 this.$["*imageSize"] = { width: s, height: r }, this.$["*tabId"] === I.CROP ? this.$["*cropperEl"].activate(this.$["*imageSize"]) : this.$["*faderEl"].activate({ url: this.$["*originalUrl"] }); 7437 } catch (e) { 7438 e && console.error("Failed to load image info", e); 7439 } 7440 } 7441 }
7442 async initEditor() { 7443 try { 7444 await this._waitForSize(); 7445 } catch (e) { 7446 this.isConnected && console.error(e.message); 7447 return; 7448 } 7449 this.ref["img-el"].addEventListener("load", () => { 7450 this._imgLoading = !1, this._debouncedShowLoader(!1), this.$.src !== ke && (this.$["*networkProblems"] = !1); 7451 }), this.ref["img-el"].addEventListener("error", () => { 7452 this._imgLoading = !1, this._debouncedShowLoader(!1), this.$["*networkProblems"] = !0; 7453 }), this.sub("src", (e) => { 7454 let t = this.ref["img-el"]; 7455 t.src !== e && (this._imgLoading = !0, t.src = e || ke); 7456 }), this.sub("cropPreset", (e) => { 7457 this.$["*cropPresetList"] = vs(e); 7458 }), this.sub( 7459 "tabs", 7460 /** @param {string} val */ 7461 (e) => { 7462 this.$["*tabList"] = wl(e); 7463 } 7464 ), this.sub("*tabId", (e) => { 7465 this.ref["img-el"].className = X("uc-image", { 7466 "uc-image_hidden_to_cropper": e === I.CROP, 7467 "uc-image_hidden_effects": e !== I.CROP 7468 }); 7469 }), this.classList.add("uc-editor_ON"), this.sub("*networkProblems", (e) => { 7470 this.$["presence.networkProblems"] = e, this.$["presence.modalCaption"] = !e; 7471 }), this.sub( 7472 "*editorTransformations", 7473 (e) => { 7474 if (Object.keys(e).length === 0) 7475 return; 7476 let t = this.$["*originalUrl"], s = le(rt(e), "preview"), r = j(t, s), n = { 7477 originalUrl: t, 7478 cdnUrlModifiers: s, 7479 cdnUrl: r, 7480 transformations: e 7481 }; 7482 this.dispatchEvent( 7483 new CustomEvent("change", { 7484 detail: n, 7485 bubbles: !0, 7486 composed: !0 7487 }) 7488 ); 7489 }, 7490 !1 7491 ), this.sub("uuid", (e) => e && this.updateImage()), this.sub("cdnUrl", (e) => e && this.updateImage()); 7492 } 7493} 7494He.template = El; 7495He.bindAttributes({ 7496 uuid: "uuid", 7497 "cdn-url": "cdnUrl", 7498 "crop-preset": "cropPreset", 7499 tabs: "tabs" 7500}); 7501class Bs extends k { 7502 constructor() { 7503 super(), this.init$ = { 7504 ...this.init$, 7505 dragging: !1 7506 }, this._handlePointerUp = this._handlePointerUp_.bind(this), this._handlePointerMove = this._handlePointerMove_.bind(this), this._handleSvgPointerMove = this._handleSvgPointerMove_.bind(this); 7507 } 7508 /** 7509 * @private 7510 * @param {import('./types.js').Direction} direction 7511 */ 7512 _shouldThumbBeDisabled(e) { 7513 let t = this.$["*imageBox"]; 7514 if (!t) 7515 return; 7516 if (e === "" && t.height <= v && t.width <= v) 7517 return !0; 7518 let s = t.height <= v && (e.includes("n") || e.includes("s")), r = t.width <= v && (e.includes("e") || e.includes("w")); 7519 return s || r; 7520 } 7521 /** @private */ 7522 _createBackdrop() { 7523 let e = this.$["*cropBox"]; 7524 if (!e) 7525 return; 7526 let { x: t, y: s, width: r, height: n } = e, o = this.ref["svg-el"], a = q("mask", { id: "backdrop-mask" }), l = q("rect", { 7527 x: 0, 7528 y: 0, 7529 width: "100%", 7530 height: "100%", 7531 fill: "white" 7532 }), c = q("rect", { 7533 x: t, 7534 y: s, 7535 width: r, 7536 height: n, 7537 fill: "black" 7538 }); 7539 a.appendChild(l), a.appendChild(c); 7540 let d = q("rect", { 7541 x: 0, 7542 y: 0, 7543 width: "100%", 7544 height: "100%", 7545 fill: "var(--color-image-background)", 7546 "fill-opacity": 0.85, 7547 mask: "url(#backdrop-mask)" 7548 }); 7549 o.appendChild(d), o.appendChild(a), this._backdropMask = a, this._backdropMaskInner = c; 7550 } 7551 /** 7552 * @private Super Tricky workaround for the chromium bug See 7553 * https://bugs.chromium.org/p/chromium/issues/detail?id=330815 7554 */ 7555 _resizeBackdrop() { 7556 this._backdropMask && (this._backdropMask.style.display = "none", window.requestAnimationFrame(() => { 7557 this._backdropMask && (this._backdropMask.style.display = "block"); 7558 })); 7559 } 7560 /** @private */ 7561 _updateBackdrop() { 7562 let e = this.$["*cropBox"]; 7563 if (!e) 7564 return; 7565 let { x: t, y: s, width: r, height: n } = e; 7566 this._backdropMaskInner && Ee(this._backdropMaskInner, { x: t, y: s, width: r, height: n }); 7567 } 7568 /** @private */ 7569 _updateFrame() { 7570 let e = this.$["*cropBox"];
7571 if (!(!e || !this._frameGuides || !this._frameThumbs)) { 7572 for (let t of Object.values(this._frameThumbs)) { 7573 let { direction: s, pathNode: r, interactionNode: n, groupNode: o } = t, a = s === "", l = s.length === 2, { x: c, y: d, width: u, height: h } = e; 7574 if (a) 7575 Ee(n, { 7576 x: c, 7577 y: d, 7578 width: u, 7579 height: h 7580 }); 7581 else { 7582 const p = Te( 7583 Math.min(u, h) / (Lt * 2 + De) / 2, 7584 0, 7585 1 7586 ); 7587 let { d: m, center: b } = l ? ko(e, s, p) : Io( 7588 e, 7589 /** @type {Extract<import('./types.js').Direction, 'n' | 's' | 'w' | 'e'>} */ 7590 s, 7591 p 7592 ); 7593 const C = Math.max( 7594 yi * Te(Math.min(u, h) / yi / 3, 0, 1), 7595 $o 7596 ); 7597 Ee(n, { 7598 x: b[0] - C, 7599 y: b[1] - C, 7600 width: C * 2, 7601 height: C * 2 7602 }), Ee(r, { d: m }); 7603 } 7604 let f = this._shouldThumbBeDisabled(s); 7605 o.setAttribute( 7606 "class", 7607 X("uc-thumb", { 7608 "uc-thumb--hidden": f, 7609 "uc-thumb--visible": !f 7610 }) 7611 ); 7612 } 7613 Ee(this._frameGuides, { 7614 x: e.x - me * 0.5, 7615 y: e.y - me * 0.5, 7616 width: e.width + me, 7617 height: e.height + me 7618 }); 7619 } 7620 } 7621 /** 7622 * @param {import('./types.js').FrameThumbs} frameThumbs 7623 * @param {import('./types.js').Direction} direction 7624 */ 7625 _createThumb(e, t) { 7626 let s = q("g"); 7627 s.classList.add("uc-thumb"), s.setAttribute("with-effects", ""); 7628 let r = q("rect", { 7629 fill: "transparent" 7630 }), n = q("path", { 7631 stroke: "currentColor", 7632 fill: "none", 7633 "stroke-width": ys 7634 }); 7635 s.appendChild(n), s.appendChild(r), e[t] = { 7636 direction: t, 7637 pathNode: n, 7638 interactionNode: r, 7639 groupNode: s 7640 }, t === "" && (s.style.cursor = "move"), r.addEventListener("pointerdown", this._handlePointerDown.bind(this, t)); 7641 } 7642 /** @private */ 7643 _createThumbs() { 7644 const e = {}; 7645 for (let t = 0; t < 3; t++) 7646 for (let s = 0; s < 3; s++) { 7647 let r = ( 7648 /** @type {import('./types.js').Direction} */ 7649 `${["n", "", "s"][t]}${["w", "", "e"][s]}` 7650 ); 7651 r !== "" && this._createThumb(e, r); 7652 } 7653 return this._createThumb(e, ""), e; 7654 } 7655 /** @private */ 7656 _createGuides() { 7657 let e = q("svg"), t = q("rect", { 7658 x: 0, 7659 y: 0, 7660 width: "100%", 7661 height: "100%", 7662 fill: "none", 7663 stroke: "currentColor", 7664 "stroke-width": me, 7665 "stroke-opacity": 0.5 7666 }); 7667 e.appendChild(t); 7668 for (let s = 1; s <= 2; s++) { 7669 let r = q("line", { 7670 x1: `${je * s}%`, 7671 y1: "0%", 7672 x2: `${je * s}%`, 7673 y2: "100%", 7674 stroke: "currentColor", 7675 "stroke-width": me, 7676 "stroke-opacity": 0.3 7677 }); 7678 e.appendChild(r); 7679 } 7680 for (let s = 1; s <= 2; s++) { 7681 let r = q("line", { 7682 x1: "0%", 7683 y1: `${je * s}%`, 7684 x2: "100%", 7685 y2: `${je * s}%`, 7686 stroke: "currentColor", 7687 "stroke-width": me, 7688 "stroke-opacity": 0.3 7689 }); 7690 e.appendChild(r); 7691 } 7692 return e.classList.add("uc-guides", "uc-guides--semi-hidden"), e; 7693 } 7694 /** @private */ 7695 _createFrame() { 7696 let e = this.ref["svg-el"], t = document.createDocumentFragment(), s = this._createGuides(); 7697 t.appendChild(s); 7698 let r = this._createThumbs(); 7699 for (let { groupNode: n } of Object.values(r)) 7700 t.appendChild(n); 7701 e.appendChild(t), this._frameThumbs = r, this._frameGuides = s; 7702 } 7703 /** 7704 * @private 7705 * @param {import('./types.js').Direction} direction 7706 * @param {PointerEvent} e 7707 */ 7708 _handlePointerDown(e, t) { 7709 if (!this._frameThumbs) return; 7710 let s = this._frameThumbs[e]; 7711 if (this._shouldThumbBeDisabled(e)) 7712 return; 7713 let r = this.$["*cropBox"], { x: n, y: o } = this.ref["svg-el"].getBoundingClientRect(), a = t.x - n, l = t.y - o; 7714 this.$.dragging = !0, this._draggingThumb = s, this._dragStartPoint = [a, l], this._dragStartCrop = { ...r }; 7715 } 7716 /** 7717 * @private 7718 * @param {PointerEvent} e 7719 */ 7720 _handlePointerUp_(e) {
7721 this._updateCursor(), this.$.dragging && (e.stopPropagation(), e.preventDefault(), this.$.dragging = !1); 7722 } 7723 /** 7724 * @private 7725 * @param {PointerEvent} e 7726 */ 7727 _handlePointerMove_(e) { 7728 if (!this.$.dragging || !this._dragStartPoint || !this._draggingThumb) 7729 return; 7730 e.stopPropagation(), e.preventDefault(); 7731 let t = this.ref["svg-el"], { x: s, y: r } = t.getBoundingClientRect(), n = e.x - s, o = e.y - r, a = n - this._dragStartPoint[0], l = o - this._dragStartPoint[1], { direction: c } = this._draggingThumb; 7732 const d = this._calcCropBox(c, [a, l]); 7733 d && (this.$["*cropBox"] = d); 7734 } 7735 /** 7736 * @private 7737 * @param {import('./types.js').Direction} direction 7738 * @param {[Number, Number]} delta 7739 */ 7740 _calcCropBox(e, t) { 7741 const [s, r] = t; 7742 let n = this.$["*imageBox"], o = ( 7743 /** @type {import('./types.js').Rectangle} */ 7744 this._dragStartCrop ?? this.$["*cropBox"] 7745 ); 7746 const a = this.$["*cropPresetList"]?.[0], l = a ? a.width / a.height : void 0; 7747 if (e === "" ? o = Lo({ rect: o, delta: [s, r], imageBox: n }) : o = zo({ rect: o, delta: [s, r], direction: e, aspectRatio: l, imageBox: n }), !Object.values(o).every((c) => Number.isFinite(c) && c >= 0)) { 7748 console.error("CropFrame is trying to create invalid rectangle", { 7749 payload: o 7750 }); 7751 return; 7752 } 7753 return tt(Je(o), this.$["*imageBox"]); 7754 } 7755 /** 7756 * @private 7757 * @param {PointerEvent} e 7758 */ 7759 _handleSvgPointerMove_(e) { 7760 if (!this._frameThumbs) return; 7761 let t = Object.values(this._frameThumbs).find((s) => { 7762 if (this._shouldThumbBeDisabled(s.direction)) 7763 return !1; 7764 let n = s.interactionNode.getBoundingClientRect(), o = { 7765 x: n.x, 7766 y: n.y, 7767 width: n.width, 7768 height: n.height 7769 }; 7770 return Bo(o, [e.x, e.y]); 7771 }); 7772 this._hoverThumb = t, this._updateCursor(); 7773 } 7774 /** @private */ 7775 _updateCursor() { 7776 let e = this._hoverThumb; 7777 this.ref["svg-el"].style.cursor = e ? Oo(e.direction) : "initial"; 7778 } 7779 /** @private */ 7780 _render() { 7781 this._updateBackdrop(), this._updateFrame(); 7782 } 7783 /** @param {boolean} visible */ 7784 toggleThumbs(e) { 7785 this._frameThumbs && Object.values(this._frameThumbs).map(({ groupNode: t }) => t).forEach((t) => { 7786 t.setAttribute( 7787 "class", 7788 X("uc-thumb", { 7789 "uc-thumb--hidden": !e, 7790 "uc-thumb--visible": e 7791 }) 7792 ); 7793 }); 7794 } 7795 initCallback() { 7796 super.initCallback(), this._createBackdrop(), this._createFrame(), this.sub("*imageBox", () => { 7797 this._resizeBackdrop(), window.requestAnimationFrame(() => { 7798 this._render(); 7799 }); 7800 }), this.sub("*cropBox", (e) => { 7801 e && (this._guidesHidden = e.height <= v || e.width <= v, window.requestAnimationFrame(() => { 7802 this._render(); 7803 })); 7804 }), this.sub("dragging", (e) => { 7805 this._frameGuides && this._frameGuides.setAttribute( 7806 "class", 7807 X({ 7808 "uc-guides--hidden": this._guidesHidden, 7809 "uc-guides--visible": !this._guidesHidden && e, 7810 "uc-guides--semi-hidden": !this._guidesHidden && !e 7811 }) 7812 ); 7813 }), this.ref["svg-el"].addEventListener("pointermove", this._handleSvgPointerMove, !0), document.addEventListener("pointermove", this._handlePointerMove, !0), document.addEventListener("pointerup", this._handlePointerUp, !0); 7814 } 7815 destroyCallback() { 7816 super.destroyCallback(), document.removeEventListener("pointermove", this._handlePointerMove), document.removeEventListener("pointerup", this._handlePointerUp); 7817 } 7818} 7819Bs.template = /* HTML */ 7820' <svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg> '; 7821class _t extends k { 7822 init$ = { 7823 ...this.init$, 7824 active: !1, 7825 title: "", 7826 icon: "", 7827 "on.click": null, 7828 "title-prop": "" 7829 }; 7830 initCallback() { 7831 super.initCallback(), this._titleEl = this.ref["title-el"], this._iconEl = this.ref["icon-el"], this.sub("title", (e) => { 7832 this._titleEl && (this._titleEl.style.display = e ? "block" : "none"); 7833 }), this.sub("active", (e) => { 7834 this.className = X({ 7835 "uc-active": e, 7836 "uc-not_active": !e 7837 }); 7838 }), this.sub("on.click", (e) => { 7839 this.onclick = e; 7840 }); 7841 } 7842} 7843_t.template = /* HTML */ 7844` 7845 <button type="button" role="option" l10n="@title:title-prop"> 7846 <uc-icon set="@name: icon;"></uc-icon> 7847 <div class="uc-title" ref="title-el">{{title}}</div> 7848 </button> 7849`; 7850function Tl(i) { 7851 let e = i + 90; 7852 return e = e >= 360 ? 0 : e, e; 7853} 7854function xl(i, e) { 7855 return i === "rotate" ? Tl(e) : ["mirror", "flip"].includes(i) ? !e : null; 7856} 7857class Hs extends _t { 7858 initCallback() { 7859 super.initCallback(), this.defineAccessor("operation", (e) => { 7860 e && (this._operation = e, this.$.icon = e, this.bindL10n( 7861 "title-prop", 7862 () => this.l10n("a11y-cloud-editor-apply-crop", { 7863 name: this.l10n(e).toLowerCase() 7864 }) 7865 )); 7866 }), this.$["on.click"] = () => { 7867 let e = this.$["*cropperEl"].getValue(this._operation), t = xl(this._operation, e); 7868 this.$["*cropperEl"].setValue(this._operation, t); 7869 }; 7870 } 7871} 7872const Me = { 7873 FILTER: "filter", 7874 COLOR_OPERATION: "color_operation" 7875}, ae = "original"; 7876class js extends k { 7877 init$ = { 7878 ...this.init$, 7879 disabled: !1, 7880 min: 0, 7881 max: 100, 7882 value: 0, 7883 defaultValue: 0, 7884 zero: 0, 7885 "on.input": (e) => { 7886 this.$["*faderEl"].set(e), this.$.value = e; 7887 } 7888 }; 7889 /** 7890 * @param {String} operation 7891 * @param {String} [filter] 7892 */ 7893 setOperation(e, t) { 7894 this._controlType = e === "filter" ? Me.FILTER : Me.COLOR_OPERATION, this._operation = e, this._iconName = e, this._title = e.toUpperCase(), this._filter = t, this._initializeValues(), this.$["*faderEl"].activate({ 7895 url: this.$["*originalUrl"], 7896 operation: this._operation, 7897 value: this._filter === ae ? void 0 : this.$.value, 7898 filter: this._filter === ae ? void 0 : this._filter, 7899 fromViewer: !1 7900 }); 7901 } 7902 /** @private */ 7903 _initializeValues() { 7904 let { range: e, zero: t } = Se[this._operation], [s, r] = e; 7905 this.$.min = s, this.$.max = r, this.$.zero = t; 7906 let n = this.$["*editorTransformations"][this._operation]; 7907 if (this._controlType === Me.FILTER) { 7908 let o = r; 7909 if (n) { 7910 let { name: a, amount: l } = n; 7911 o = a === this._filter ? l : r; 7912 } 7913 this.$.value = o, this.$.defaultValue = o; 7914 } 7915 if (this._controlType === Me.COLOR_OPERATION) { 7916 let o = typeof n < "u" ? n : t; 7917 this.$.value = o, this.$.defaultValue = o; 7918 } 7919 } 7920 apply() { 7921 let e; 7922 this._controlType === Me.FILTER ? this._filter === ae ? e = null : e = { name: this._filter, amount: this.$.value } : e = this.$.value; 7923 let t = { 7924 ...this.$["*editorTransformations"], 7925 [this._operation]: e 7926 };
7927 this.$["*editorTransformations"] = t; 7928 } 7929 cancel() { 7930 this.$["*faderEl"].deactivate({ hide: !1 }); 7931 } 7932 initCallback() { 7933 super.initCallback(), this.sub("*originalUrl", (e) => { 7934 this._originalUrl = e; 7935 }), this.sub("value", (e) => { 7936 let t = `${this._filter || this._operation} ${e}`; 7937 this.$["*operationTooltip"] = t; 7938 }); 7939 } 7940} 7941js.template = /* HTML */ 7942` 7943 <uc-slider-ui 7944 ref="slider-el" 7945 set="disabled: disabled; min: min; max: max; defaultValue: defaultValue; zero: zero; onInput: on.input;" 7946 ></uc-slider-ui> 7947`; 7948function ei(i) { 7949 let e = new Image(); 7950 return { promise: new Promise((r, n) => { 7951 e.src = i, e.onload = r, e.onerror = n; 7952 }), image: e, cancel: () => { 7953 e.naturalWidth === 0 && (e.src = ke); 7954 } }; 7955} 7956function Ut(i) { 7957 let e = []; 7958 for (let n of i) { 7959 let o = ei(n); 7960 e.push(o); 7961 } 7962 let t = e.map((n) => n.image); 7963 return { promise: Promise.allSettled(e.map((n) => n.promise)), images: t, cancel: () => { 7964 e.forEach((n) => { 7965 n.cancel(); 7966 }); 7967 } }; 7968} 7969class ti extends _t { 7970 constructor() { 7971 super(), this.init$ = { 7972 ...this.init$, 7973 active: !1, 7974 title: "", 7975 icon: "", 7976 isOriginal: !1, 7977 iconSize: "20", 7978 "on.click": null 7979 }; 7980 } 7981 _previewSrc() { 7982 let e = parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"), 10), t = window.devicePixelRatio, s = Math.ceil(t * e), r = t >= 2 ? "lightest" : "normal", n = 100, o = { ...this.$["*editorTransformations"] }; 7983 return o[this._operation] = this._filter !== ae ? { 7984 name: this._filter, 7985 amount: n 7986 } : void 0, j( 7987 this._originalUrl, 7988 le( 7989 Qi, 7990 rt(o), 7991 `quality/${r}`, 7992 `scale_crop/${s}x${s}/center` 7993 ) 7994 ); 7995 } 7996 /** 7997 * @param {IntersectionObserverEntry[]} entries 7998 * @param {IntersectionObserver} observer 7999 */ 8000 async _observerCallback(e, t) { 8001 if (e[0].isIntersecting) { 8002 let r = await this.proxyUrl(this._previewSrc()), n = this.ref["preview-el"], { promise: o, cancel: a } = ei(r); 8003 this._cancelPreload = a, o.catch((l) => { 8004 this.$["*networkProblems"] = !0, console.error("Failed to load image", { error: l }); 8005 }).finally(() => { 8006 n.style.backgroundImage = `url(${r})`, n.setAttribute("loaded", ""), t.unobserve(this); 8007 }); 8008 } else 8009 this._cancelPreload?.(); 8010 } 8011 initCallback() { 8012 super.initCallback(), this.$["on.click"] = () => { 8013 this.$.active ? this.$.isOriginal || (this.$["*sliderEl"].setOperation(this._operation, this._filter), this.$["*showSlider"] = !0) : (this.$["*sliderEl"].setOperation(this._operation, this._filter), this.$["*sliderEl"].apply()), this.$["*currentFilter"] = this._filter; 8014 }, this.defineAccessor( 8015 "filter", 8016 /** @param {string} filter */ 8017 (t) => { 8018 this._operation = "filter", this._filter = t, this.$.isOriginal = t === ae, this.$.icon = this.$.isOriginal ? "original" : "slider", this.bindL10n( 8019 "title-prop", 8020 () => this.l10n("a11y-cloud-editor-apply-filter", { 8021 name: t.toLowerCase() 8022 }) 8023 ); 8024 } 8025 ), this._observer = new window.IntersectionObserver(this._observerCallback.bind(this), { 8026 threshold: [0, 1] 8027 }); 8028 let e = this.$["*originalUrl"]; 8029 this._originalUrl = e, this.$.isOriginal ? this.ref["icon-el"].classList.add("uc-original-icon") : this._observer.observe(this), this.sub("*currentFilter", (t) => { 8030 this.$.active = t && t === this._filter; 8031 }), this.sub("isOriginal", (t) => { 8032 this.$.iconSize = t ? 40 : 20; 8033 }), this.sub("active", (t) => { 8034 if (this.$.isOriginal) 8035 return; 8036 let s = this.ref["icon-el"]; 8037 s.style.opacity = t ? "1" : "0"; 8038 let r = this.ref["preview-el"]; 8039 t ? r.style.opacity = "0" : r.style.backgroundImage && (r.style.opacity = "1"); 8040 }), this.sub("*networkProblems", async (t) => { 8041 if (!t) { 8042 let s = await this.proxyUrl(this._previewSrc()), r = this.ref["preview-el"]; 8043 r.style.backgroundImage && (r.style.backgroundImage = "none", r.style.backgroundImage = `url(${s})`); 8044 } 8045 }); 8046 } 8047 destroyCallback() { 8048 super.destroyCallback(), this._observer?.disconnect(), this._cancelPreload?.(); 8049 } 8050} 8051ti.template = /* HTML */ 8052` 8053 <button type="button" role="option" l10n="@title:title-prop"> 8054 <div class="uc-preview" ref="preview-el"></div> 8055 <uc-icon ref="icon-el" set="@name: icon; @size: iconSize;"></uc-icon> 8056 </button> 8057`; 8058class Gs extends _t { 8059 /** 8060 * @private 8061 * @type {String} 8062 */ 8063 _operation = ""; 8064 initCallback() { 8065 super.initCallback(), this.$["on.click"] = (e) => { 8066 this.$["*sliderEl"].setOperation(this._operation), this.$["*showSlider"] = !0, this.$["*currentOperation"] = this._operation; 8067 }, this.defineAccessor("operation", (e) => { 8068 e && (this._operation = e, this.$.icon = e, this.bindL10n( 8069 "title-prop", 8070 () => this.l10n("a11y-cloud-editor-apply-tuning", { 8071 name: this.l10n(e).toLowerCase() 8072 }) 8073 ), this.bindL10n("title", () => this.l10n(e))); 8074 }), this.sub("*editorTransformations", (e) => { 8075 if (!this._operation) 8076 return; 8077 let { zero: t } = Se[this._operation], s = e[this._operation], r = typeof s < "u" ? s !== t : !1; 8078 this.$.active = r; 8079 }); 8080 } 8081} 8082function Sl(i, e) { 8083 let t = {}; 8084 for (let s of e) { 8085 let r = i[s]; 8086 (i.hasOwnProperty(s) || r !== void 0) && (t[s] = r); 8087 } 8088 return t; 8089} 8090function ii(i, e, t) { 8091 let r = window.devicePixelRatio, n = Math.min(Math.ceil(e * r), 3e3), o = r >= 2 ? "lightest" : "normal"; 8092 return j( 8093 i, 8094 le( 8095 Qi, 8096 rt(t), 8097 `quality/${o}`, 8098 `stretch/off/-/resize/${n}x`, 8099 `@clib/${ft}/${pt}/uc-cloud-image-editor/` 8100 ) 8101 ); 8102} 8103function $l(i) { 8104 return i ? [
8105 ({ dimensions: t, coords: s }) => [...t, ...s].every((r) => Number.isInteger(r) && Number.isFinite(r)), 8106 ({ dimensions: t, coords: s }) => t.every((r) => r > 0) && s.every((r) => r >= 0) 8107 ].every((t) => t(i)) : !0; 8108} 8109class Ws extends k { 8110 ctxOwner = !0; 8111 constructor() { 8112 super(), this.init$ = { 8113 ...this.init$, 8114 image: null, 8115 "*padding": So, 8116 /** @type {Operations} */ 8117 "*operations": { 8118 rotate: 0, 8119 mirror: !1, 8120 flip: !1 8121 }, 8122 /** @type {import('./types.js').Rectangle} */ 8123 "*imageBox": { 8124 x: 0, 8125 y: 0, 8126 width: 0, 8127 height: 0 8128 }, 8129 /** @type {import('./types.js').Rectangle} */ 8130 "*cropBox": { 8131 x: 0, 8132 y: 0, 8133 width: 0, 8134 height: 0 8135 } 8136 }, this._commitDebounced = G(this._commit.bind(this), 300), this._handleResizeThrottled = Ms(this._handleResize.bind(this), 100), this._imageSize = { width: 0, height: 0 }; 8137 } 8138 /** @private */ 8139 _handleResize() { 8140 !this.isConnected || !this._isActive || (this._initCanvas(), this._syncTransformations(), this._alignImage(), this._alignCrop(), this._draw()); 8141 } 8142 /** @private */ 8143 _syncTransformations() { 8144 let e = this.$["*editorTransformations"], t = Sl(e, Object.keys(this.$["*operations"])), s = { ...this.$["*operations"], ...t }; 8145 this.$["*operations"] = s; 8146 } 8147 /** @private */ 8148 _initCanvas() { 8149 let e = this.ref["canvas-el"], t = e.getContext("2d"), s = this.offsetWidth, r = this.offsetHeight, n = window.devicePixelRatio; 8150 e.style.width = `${s}px`, e.style.height = `${r}px`, e.width = s * n, e.height = r * n, t?.scale(n, n), this._canvas = e, this._ctx = t; 8151 } 8152 /** @private */ 8153 _alignImage() { 8154 if (!this._isActive || !this.$.image) 8155 return; 8156 let e = this.$.image, t = this.$["*padding"], s = this.$["*operations"], { rotate: r } = s, n = { width: this.offsetWidth, height: this.offsetHeight }, o = Ue({ width: e.naturalWidth, height: e.naturalHeight }, r), a; 8157 if (o.width > n.width - t * 2 || o.height > n.height - t * 2) { 8158 let l = o.width / o.height, c = n.width / n.height; 8159 if (l > c) { 8160 let d = n.width - t * 2, u = d / l, h = 0 + t, f = t + (n.height - t * 2) / 2 - u / 2; 8161 a = { x: h, y: f, width: d, height: u }; 8162 } else { 8163 let d = n.height - t * 2, u = d * l, h = t + (n.width - t * 2) / 2 - u / 2, f = 0 + t; 8164 a = { x: h, y: f, width: u, height: d }; 8165 } 8166 } else { 8167 let { width: l, height: c } = o, d = t + (n.width - t * 2) / 2 - l / 2, u = t + (n.height - t * 2) / 2 - c / 2; 8168 a = { x: d, y: u, width: l, height: c }; 8169 } 8170 this.$["*imageBox"] = Je(a); 8171 } 8172 /** @private */ 8173 _alignCrop() { 8174 let e = this.$["*cropBox"], t = this.$["*imageBox"], s = this.$["*operations"], { rotate: r } = s, n = this.$["*editorTransformations"].crop, { width: o, x: a, y: l } = this.$["*imageBox"]; 8175 if (n) { 8176 let { 8177 dimensions: [u, h], 8178 coords: [f, p] 8179 } = n, { width: m } = Ue(this._imageSize, r), b = o / m; 8180 e = tt( 8181 Je({ 8182 x: a + f * b, 8183 y: l + p * b, 8184 width: u * b, 8185 height: h * b 8186 }), 8187 this.$["*imageBox"] 8188 ); 8189 } 8190 const c = this.$["*cropPresetList"]?.[0], d = c ? c.width / c.height : void 0; 8191 if (!Ho(e, t) || d && !jo(e, d)) { 8192 const u = t.width / t.height; 8193 let h = t.width, f = t.height; 8194 d && (u > d ? h = Math.min(t.height * d, t.width) : f = Math.min(t.width / d, t.height)), e = { 8195 x: t.x + t.width / 2 - h / 2, 8196 y: t.y + t.height / 2 - f / 2, 8197 width: h, 8198 height: f 8199 }; 8200 } 8201 this.$["*cropBox"] = tt(Je(e), this.$["*imageBox"]); 8202 } 8203 /** @private */ 8204 _drawImage() { 8205 let e = this._ctx; 8206 if (!e) return; 8207 let t = this.$.image, s = this.$["*imageBox"], r = this.$["*operations"], { mirror: n, flip: o, rotate: a } = r, l = Ue({ width: s.width, height: s.height }, a); 8208 e.save(), e.translate(s.x + s.width / 2, s.y + s.height / 2), e.rotate(a * Math.PI * -1 / 180), e.scale(n ? -1 : 1, o ? -1 : 1), e.drawImage(t, -l.width / 2, -l.height / 2, l.width, l.height), e.restore(
8208); 8209 } 8210 /** @private */ 8211 _draw() { 8212 if (!this._isActive || !this.$.image || !this._canvas || !this._ctx) 8213 return; 8214 let e = this._canvas; 8215 this._ctx.clearRect(0, 0, e.width, e.height), this._drawImage(); 8216 } 8217 /** 8218 * @private 8219 * @param {{ fromViewer?: boolean }} options 8220 */ 8221 _animateIn({ fromViewer: e }) { 8222 this.$.image && (this.ref["frame-el"].toggleThumbs(!0), this._transitionToImage(), setTimeout(() => { 8223 this.className = X({ 8224 "uc-active_from_viewer": e, 8225 "uc-active_from_editor": !e, 8226 "uc-inactive_to_editor": !1 8227 }); 8228 })); 8229 } 8230 /** 8231 * @private 8232 * @returns {NonNullable<import('./types.js').Transformations['crop']>['dimensions']} 8233 */ 8234 _getCropDimensions() { 8235 let e = this.$["*cropBox"], t = this.$["*imageBox"], s = this.$["*operations"], { rotate: r } = s, { width: n, height: o } = t, { width: a, height: l } = Ue(this._imageSize, r), { width: c, height: d } = e, u = n / a, h = o / l; 8236 return [ 8237 Te(Math.round(c / u), 1, a), 8238 Te(Math.round(d / h), 1, l) 8239 ]; 8240 } 8241 /** 8242 * @private 8243 * @returns {import('./types.js').Transformations['crop']} 8244 */ 8245 _getCropTransformation() { 8246 let e = this.$["*cropBox"], t = this.$["*imageBox"], s = this.$["*operations"], { rotate: r } = s, { width: n, height: o, x: a, y: l } = t, { width: c, height: d } = Ue(this._imageSize, r), { x: u, y: h } = e, f = n / c, p = o / d, m = this._getCropDimensions(), b = { 8247 dimensions: m, 8248 coords: ( 8249 /** @type {[Number, Number]} */ 8250 [ 8251 Te(Math.round((u - a) / f), 0, c - m[0]), 8252 Te(Math.round((h - l) / p), 0, d - m[1]) 8253 ] 8254 ) 8255 }; 8256 if (!$l(b)) { 8257 console.error("Cropper is trying to create invalid crop object", { 8258 payload: b 8259 }); 8260 return; 8261 } 8262 if (!(m[0] === c && m[1] === d)) 8263 return b; 8264 } 8265 /** @private */ 8266 _commit() { 8267 if (!this.isConnected || !this._imageSize) 8268 return; 8269 let e = this.$["*operations"], { rotate: t, mirror: s, flip: r } = e, n = this._getCropTransformation(), a = { 8270 ...this.$["*editorTransformations"], 8271 crop: n, 8272 rotate: t, 8273 mirror: s, 8274 flip: r 8275 }; 8276 this.$["*editorTransformations"] = a; 8277 } 8278 /** 8279 * @param {String} operation 8280 * @param {Number} value 8281 * @returns {void} 8282 */ 8283 setValue(e, t) { 8284 this.$["*operations"] = { 8285 ...this.$["*operations"], 8286 [e]: t 8287 }, this._isActive && (this._alignImage(), this._alignCrop(), this._draw()); 8288 } 8289 /** 8290 * @param {keyof Operations} operation 8291 * @returns {Number | boolean} 8292 */ 8293 getValue(e) { 8294 return this.$["*operations"][e]; 8295 } 8296 /** 8297 * @param {import('./types.js').ImageSize} imageSize 8298 * @param {{ fromViewer?: boolean }} options 8299 */ 8300 async activate(e, { fromViewer: t } = {}) { 8301 if (!this._isActive) { 8302 this._isActive = !0, this._imageSize = e, this.removeEventListener("transitionend", this._reset); 8303 try { 8304 this.$.image = await this._waitForImage(this.$["*originalUrl"], this.$["*editorTransformations"]), this._syncTransformations(), this._animateIn({ fromViewer: t }); 8305 } catch (s) { 8306 console.error("Failed to activate cropper", { error: s }); 8307 } 8308 this._observer = new ResizeObserver(([s]) => { 8309 s.contentRect.width > 0 && s.contentRect.height > 0 && this._isActive && this.$.image && this._handleResizeThrottled(); 8310 }), this._observer.observe(this); 8311 } 8312 } 8313 deactivate({ reset: e = !1 } = {}) { 8314 this._isActive && (!e && this._commit(), this._isActive = !1, this._transitionToCrop(), this.className = X({ 8315 "uc-active_from_viewer": !1, 8316 "uc-active_from_editor": !1, 8317 "uc-inactive_to_editor": !0 8318 }), this.ref["frame-el"].toggleThumbs(!1), this.addEventListener("transitionend", this._reset, { once: !0 }), this._observer?.disconnect()); 8319 } 8320 /** @private */ 8321 _transitionToCrop() { 8322 let e = this._getCropDimensions(), t = Math.min(this.offsetWidth, e[0]) / this.$["*cropBox"].width, s = Math.min(this.offsetHeight, e[1]) / this.$["*cropBox"].height, r = Math.min(t, s), n = this.$["*cropBox"].x + this.$["*cropBox"].width / 2, o = this.$["*cropBox"].y + this.$["*cropBox"].height / 2; 8323 this.style.transform = `scale(${r}) translate(${(this.offsetWidth / 2 - n) / r}px, ${(this.offsetHeight / 2 - o) / r}px)`, this.style.transformOrigin = `${n}px ${o}px`; 8324 } 8325 /** @private */ 8326 _transitionToImage() { 8327 let e = this.$["*cropBox"].x + this.$["*cropBox"].width / 2, t = this.$["*cropBox"].y + this.$["*cropBox"].height / 2; 8328 this.style.transform = "scale(1)", this.style.transformOrigin = `${e}px ${t}px`; 8329 } 8330 /** @private */ 8331 _reset() { 8332 this._isActive || (this.$.image = null); 8333 } 8334 /** 8335 * @private 8336 * @param {String} originalUrl 8337 * @param {import('./types.js').Transformations} transformations 8338 * @returns {Promise<HTMLImageElement>} 8339 */ 8340 async _waitForImage(e, t) { 8341 let s = this.offsetWidth; 8342 t = { 8343 ...t, 8344 crop: void 0, 8345 rotate: void 0, 8346 flip: void 0, 8347 mirror: void 0 8348 }; 8349 let r = await this.proxyUrl(ii(e, s, t)), { promise: n, cancel: o, image: a } = ei(r), l = this._handleImageLoading(r); 8350 return a.addEventListener("load", l, { once: !0 }), a.addEventListener("error", l, { once: !0 }), this._cancelPreload?.(), this._cancelPreload = o, n.then(() => a).catch((c) => (console.error("Failed to load image", { error: c }), this.$["*networkProblems"] = !0, Promise.resolve(a))); 8351 } 8352 /** 8353 * @private 8354 * @param {String} src 8355 * @returns {() => void} Destructor 8356 */ 8357 _handleImageLoading(e) { 8358 let t = "crop", s = this.$["*loadingOperations"];
8359 return s.get(t) || s.set(t, /* @__PURE__ */ new Map()), s.get(t).get(e) || (s.set(t, s.get(t).set(e, !0)), this.$["*loadingOperations"] = s), () => { 8360 s?.get(t)?.has(e) && (s.get(t).delete(e), this.$["*loadingOperations"] = s); 8361 }; 8362 } 8363 initCallback() { 8364 super.initCallback(), this.sub("*imageBox", () => { 8365 this._draw(); 8366 }), this.sub("*cropBox", () => { 8367 this.$.image && this._commitDebounced(); 8368 }), this.sub("*cropPresetList", () => { 8369 this._alignCrop(); 8370 }), setTimeout(() => { 8371 this.sub("*networkProblems", (e) => { 8372 e || this._isActive && this.activate(this._imageSize, { fromViewer: !1 }); 8373 }); 8374 }, 0); 8375 } 8376 destroyCallback() { 8377 super.destroyCallback(), this._observer?.disconnect(); 8378 } 8379} 8380Ws.template = /* HTML */ 8381` 8382 <canvas class="uc-canvas" ref="canvas-el"></canvas> 8383 <uc-crop-frame ref="frame-el"></uc-crop-frame> 8384`; 8385function Vi(i, e, t) { 8386 let s = Array(t); 8387 t--; 8388 for (let r = t; r >= 0; r--) 8389 s[r] = Math.ceil((r * e + (t - r) * i) / t); 8390 return s; 8391} 8392function kl(i) { 8393 return i.reduce( 8394 (e, t, s) => s < i.length - 1 ? [...e, [t, i[s + 1]]] : e, 8395 [] 8396 ); 8397} 8398function Il(i, e, t) { 8399 let s = kl(i).find(([r, n]) => r <= e && e <= n); 8400 return i.map((r) => { 8401 let n = Math.abs(s[0] - s[1]), o = Math.abs(e - s[0]) / n; 8402 return s[0] === r ? e > t ? 1 : 1 - o : s[1] === r ? e >= t ? o : 1 : 0; 8403 }); 8404} 8405function Ol(i, e) { 8406 return i.map((t, s) => t < e ? i.length - s : s); 8407} 8408function Ni(i, e) { 8409 let t = Se[i].keypointsNumber, { range: s, zero: r } = Se[i]; 8410 return [.../* @__PURE__ */ new Set([...Vi(s[0], r, t + 1), ...Vi(r, s[1], t + 1), r, e])].sort( 8411 (n, o) => n - o 8412 ); 8413} 8414class Ll extends k { 8415 constructor() { 8416 super(), this._isActive = !1, this._hidden = !0, this._addKeypointDebounced = G(this._addKeypoint.bind(this), 600), this.classList.add("uc-inactive_to_cropper"); 8417 } 8418 /** 8419 * @private 8420 * @param {String} src 8421 * @returns {() => void} Destructor 8422 */ 8423 _handleImageLoading(e) { 8424 let t = this._operation, s = this.$["*loadingOperations"]; 8425 return s.get(t) || s.set(t, /* @__PURE__ */ new Map()), s.get(t).get(e) || (s.set(t, s.get(t).set(e, !0)), this.$["*loadingOperations"] = s), () => { 8426 s?.get(t)?.has(e) && (s.get(t).delete(e), this.$["*loadingOperations"] = s); 8427 }; 8428 } 8429 /** @private */ 8430 _flush() { 8431 window.cancelAnimationFrame(this._raf), this._raf = window.requestAnimationFrame(() => { 8432 for (let e of this._keypoints) { 8433 let { image: t } = e; 8434 t && (t.style.opacity = e.opacity.toString(), t.style.zIndex = e.zIndex.toString()); 8435 } 8436 }); 8437 } 8438 /** 8439 * @private 8440 * @param {Object} options 8441 * @param {String} [options.url] 8442 * @param {String} [options.filter] 8443 * @param {String} [options.operation] 8444 * @param {Number} [options.value] 8445 * @returns {Promise<String>} 8446 */ 8447 async _imageSrc({ url: e = this._url, filter: t = this._filter, operation: s, value: r } = {}) { 8448 let n = { ...this._transformations }; 8449 s && (n[s] = t ? { name: t, amount: r } : r); 8450 let o = this.offsetWidth; 8451 return await this.proxyUrl(ii(e, o, n)); 8452 } 8453 /** 8454 * @private 8455 * @param {String} operation 8456 * @param {Number} value 8457 * @returns {Promise<Keypoint>} 8458 */ 8459 async _constructKeypoint(e, t) { 8460 return { 8461 src: await this._imageSrc({ operation: e, value: t }), 8462 image: null, 8463 opacity: 0, 8464 zIndex: 0, 8465 value: t 8466 }; 8467 } 8468 /** 8469 * Check if current operation and filter equals passed ones 8470 * 8471 * @private 8472 * @param {String} operation 8473 * @param {String} [filter] 8474 * @returns {Boolean} 8475 */ 8476 _isSame(e, t) { 8477 return this._operation === e && this._filter === t; 8478 } 8479 /** 8480 * @private 8481 * @param {String} operation 8482 * @param {String | null} filter 8483 * @param {Number} value 8484 */ 8485 async _addKeypoint(e, t, s) { 8486 let r = () => !this._isSame(e, t) || this._value !== s || !!this._keypoints.find((l) => l.value === s); 8487 if (r()) 8488 return; 8489 let n = await this._constructKeypoint(e, s), o = new Image(); 8490 o.src = n.src; 8491 let a = this._handleImageLoading(n.src); 8492 o.addEventListener("load", a, { once: !0 }), o.addEventListener("error", a, { once: !0 }), n.image = o, o.classList.add("uc-fader-image"), o.addEventListener( 8493 "load", 8494 () => { 8495 if (r()) 8496 return; 8497 let l = this._keypoints, c = l.findIndex((u) => u.value > s), d = c < l.length ? l[c].image : null; 8498 !this._container || d && !this._container.contains(d) || (l.splice(c, 0, n), this._container.insertBefore(o, d), this._update(e, s)); 8499 }, 8500 { once: !0 } 8501 ), o.addEventListener( 8502 "error", 8503 () => { 8504 this.$["*networkProblems"] = !0; 8505 }, 8506 { once: !0 } 8507 ); 8508 } 8509 /** @param {String | Number} value */ 8510 set(e) { 8511 e = typeof e == "string" ? parseInt(e, 10) : e, this._update(this._operation, e), this._addKeypointDebounced(this._operation, this._filter, e); 8512 } 8513 /** 8514 * @private 8515 * @param {String} operation 8516 * @param {Number} value 8517 */ 8518 _update(e, t) { 8519 this._operation = e, this._value = t; 8520 let { zero: s } = Se[e], r = this._keypoints.map((a) => a.value), n = Il(r, t, s), o = Ol(r, s); 8521 for (let [a, l] of Object.entries(this._keypoints)) 8522 l.opacity = n[a], l.zIndex = o[a]; 8523 this._flush(); 8524 } 8525 /** @private */ 8526 _createPreviewImage() { 8527 let e = new Image(); 8528 return e.classList.add("uc-fader-image", "uc-fader-image--preview"), e.style.opacity = "0", e; 8529 } 8530 /** @private */ 8531 async _initNodes() { 8532 let e = document.createDocumentFragment(); 8533 this._previewImage = this._previewImage || this._createPreviewImage(), !this.contains(this._previewImage) && e.appendChild(this._previewImage); 8534 let t = document.createElement("div"); 8535 e.appendChild(t); 8536 let s = this._keypoints.map((c) => c.src), { images: r, promise: n, cancel: o } = Ut(s); 8537 r.forEach((c) => { 8538 let d = this._handleImageLoading(c.src); 8539 c.addEventListener("load", d), c.addEventListener("error", d); 8540 }), this._cancelLastImages = () => { 8541 o(), this._cancelLastImages = void 0; 8542 }; 8543 let a = this._operation, l = this._filter; 8544 await n, this._isActive && this._isSame(a, l) && (this._container && this._container.remove(), this._container = t, this._keypoints.forEac
8544h((c, d) => { 8545 let u = r[d]; 8546 u.classList.add("uc-fader-image"), c.image = u, this._container.appendChild(u); 8547 }), this.appendChild(e), this._flush()); 8548 } 8549 /** @param {import('./types.js').Transformations} transformations */ 8550 async setTransformations(e) { 8551 if (this._transformations = e, this._previewImage) { 8552 let t = await this._imageSrc(), s = this._handleImageLoading(t); 8553 this._previewImage.src = t, this._previewImage.addEventListener("load", s, { once: !0 }), this._previewImage.addEventListener("error", s, { once: !0 }), this._previewImage.style.opacity = "1", this._previewImage.addEventListener( 8554 "error", 8555 () => { 8556 this.$["*networkProblems"] = !0; 8557 }, 8558 { once: !0 } 8559 ); 8560 } 8561 } 8562 /** 8563 * @param {object} options 8564 * @param {String} options.url 8565 * @param {String} options.operation 8566 * @param {Number} options.value 8567 * @param {String} [options.filter] 8568 */ 8569 async preload({ url: e, filter: t, operation: s, value: r }) { 8570 this._cancelBatchPreload && this._cancelBatchPreload(); 8571 let n = Ni(s, r), o = await Promise.all(n.map((l) => this._imageSrc({ url: e, filter: t, operation: s, value: l }))), { cancel: a } = Ut(o); 8572 this._cancelBatchPreload = a; 8573 } 8574 /** @private */ 8575 _setOriginalSrc(e) { 8576 let t = this._previewImage || this._createPreviewImage(); 8577 if (!this.contains(t) && this.appendChild(t), this._previewImage = t, t.src === e) { 8578 t.style.opacity = "1", t.style.transform = "scale(1)", this.className = X({ 8579 "uc-active_from_viewer": this._fromViewer, 8580 "uc-active_from_cropper": !this._fromViewer, 8581 "uc-inactive_to_cropper": !1 8582 }); 8583 return; 8584 } 8585 t.style.opacity = "0"; 8586 let s = this._handleImageLoading(e); 8587 t.addEventListener("error", s, { once: !0 }), t.src = e, t.addEventListener( 8588 "load", 8589 () => { 8590 s(), t && (t.style.opacity = "1", t.style.transform = "scale(1)", this.className = X({ 8591 "uc-active_from_viewer": this._fromViewer, 8592 "uc-active_from_cropper": !this._fromViewer, 8593 "uc-inactive_to_cropper": !1 8594 })); 8595 }, 8596 { once: !0 } 8597 ), t.addEventListener( 8598 "error", 8599 () => { 8600 this.$["*networkProblems"] = !0; 8601 }, 8602 { once: !0 } 8603 ); 8604 } 8605 /** 8606 * @param {object} options 8607 * @param {String} options.url 8608 * @param {String} [options.operation] 8609 * @param {Number} [options.value] 8610 * @param {String} [options.filter] 8611 * @param {Boolean} [options.fromViewer] 8612 */ 8613 async activate({ url: e, operation: t, value: s, filter: r, fromViewer: n }) { 8614 if (this._isActive = !0, this._hidden = !1, this._url = e, this._operation = t || "initial", this._value = s, this._filter = r, this._fromViewer = n, typeof s != "number" && !r) { 8615 let a = await this._imageSrc({ operation: t, value: s }); 8616 this._setOriginalSrc(a), this._container && this._container.remove(); 8617 return; 8618 } 8619 this._keypoints = await Promise.all( 8620 Ni(t, s).map((a) => this._constructKeypoint(t, a)) 8621 ), this._update(t, s), this._initNodes(); 8622 } 8623 /** @param {{ hide?: Boolean }} options */ 8624 deactivate({ hide: e = !0 } = {}) { 8625 this._isActive = !1, this._cancelLastImages && this._cancelLastImages(), this._cancelBatchPreload && this._cancelBatchPreload(), e && !this._hidden ? (this._hidden = !0, this._previewImage && (this._previewImage.style.transform = "scale(1)"), this.className = X({ 8626 "uc-active_from_viewer": !1, 8627 "uc-active_from_cropper": !1, 8628 "uc-inactive_to_cropper": !0 8629 }), this.addEventListener( 8630 "transitionend", 8631 () => { 8632 this._container && this._container.remove(); 8633 }, 8634 { once: !0 } 8635 )) : this._container && this._container.remove(); 8636 } 8637} 8638const Ul = 1; 8639class qs extends k { 8640 initCallback() { 8641 super.initCallback(), this.addEventListener( 8642 "wheel", 8643 (e) => { 8644 e.preventDefault(); 8645 let { deltaY: t, deltaX: s } = e; 8646 Math.abs(s) > Ul ? this.scrollLeft += s : this.scrollLeft += t; 8647 }, 8648 { 8649 passive: !1 8650 } 8651 ), this.addEventListener("scroll", () => { 8652 }, {
8653 passive: !0 8654 }); 8655 } 8656} 8657qs.template = /* HTML */ 8658" <slot></slot> "; 8659function Pl(i) { 8660 return ( 8661 /* HTML */ 8662 ` 8663 <uc-presence-toggle 8664 class="uc-tab-toggle" 8665 set="visible: presence.tabToggle.${i}; styles: presence.tabToggleStyles;" 8666 > 8667 <uc-btn-ui 8668 theme="tab" 8669 ref="tab-toggle-${i}" 8670 data-id="${i}" 8671 icon="${i}" 8672 set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${i}; title-prop: a11y-editor-tab-${i}" 8673 > 8674 </uc-btn-ui> 8675 </uc-presence-toggle> 8676 ` 8677 ); 8678} 8679function Ml(i) { 8680 return ( 8681 /* HTML */ 8682 ` 8683 <uc-presence-toggle 8684 id="tab_${i}" 8685 class="uc-tab-content" 8686 set="visible: presence.tabContent.${i}; styles: presence.tabContentStyles" 8687 > 8688 <uc-editor-scroller hidden-scrollbar> 8689 <div class="uc-controls-list_align"> 8690 <div 8691 role="listbox" 8692 aria-orientation="horizontal" 8693 class="uc-controls-list_inner" 8694 ref="controls-list-${i}" 8695 ></div> 8696 </div> 8697 </uc-editor-scroller> 8698 </uc-presence-toggle> 8699 ` 8700 ); 8701} 8702class Xs extends k { 8703 constructor() { 8704 super(), this.init$ = { 8705 ...this.init$, 8706 "*sliderEl": null, 8707 /** @type {import('./types.js').LoadingOperations} */ 8708 "*loadingOperations": /* @__PURE__ */ new Map(), 8709 "*showSlider": !1, 8710 "*currentFilter": ae, 8711 "*currentOperation": null, 8712 showLoader: !1, 8713 filters: Nr, 8714 colorOperations: Vr, 8715 cropOperations: zr, 8716 "*operationTooltip": null, 8717 "presence.mainToolbar": !0, 8718 "presence.subToolbar": !1, 8719 "presence.tabToggles": !0, 8720 "presence.tabContent.crop": !1, 8721 "presence.tabContent.tuning": !1, 8722 "presence.tabContent.filters": !1, 8723 "presence.tabToggle.crop": !0, 8724 "presence.tabToggle.tuning": !0, 8725 "presence.tabToggle.filters": !0, 8726 "presence.subTopToolbarStyles": { 8727 hidden: "uc-sub-toolbar--top-hidden", 8728 visible: "uc-sub-toolbar--visible" 8729 }, 8730 "presence.subBottomToolbarStyles": { 8731 hidden: "uc-sub-toolbar--bottom-hidden", 8732 visible: "uc-sub-toolbar--visible" 8733 }, 8734 "presence.tabContentStyles": { 8735 hidden: "uc-tab-content--hidden", 8736 visible: "uc-tab-content--visible" 8737 }, 8738 "presence.tabToggleStyles": { 8739 hidden: "uc-tab-toggle--hidden", 8740 visible: "uc-tab-toggle--visible" 8741 }, 8742 "presence.tabTogglesStyles": { 8743 hidden: "uc-tab-toggles--hidden", 8744 visible: "uc-tab-toggles--visible" 8745 }, 8746 "on.cancel": () => { 8747 this._cancelPreload?.(), this.$["*on.cancel"](); 8748 }, 8749 "on.apply": () => { 8750 this.$["*on.apply"](this.$["*editorTransformations"]); 8751 }, 8752 "on.applySlider": () => { 8753 this.ref["slider-el"].apply(), this._onSliderClose(); 8754 }, 8755 "on.cancelSlider": () => { 8756 this.ref["slider-el"].cancel(), this._onSliderClose(); 8757 }, 8758 /** @param {MouseEvent} e */ 8759 "on.clickTab": (e) => { 8760 const t = ( 8761 /** @type {HTMLElement} */ 8762 e.currentTarget.getAttribute("data-id") 8763 ); 8764 t && this._activateTab(t, { fromViewer: !1 }); 8765 }, 8766 tab_role: "tab", 8767 [`tab_${I.TUNING}`]: `tab_${I.TUNING}`, 8768 [`tab_${I.CROP}`]: `tab_${I.CROP}`, 8769 [`tab_${I.FILTERS}`]: `tab_${I.FILTERS}`, 8770 cancel: "cancel", 8771 apply: "apply", 8772 "a11y-editor-tab-filters": "a11y-editor-tab-filters", 8773 "a11y-editor-tab-tuning": "a11y-editor-tab-tuning", 8774 "a11y-editor-tab-crop": "a11y-editor-tab-crop" 8775 }, this._debouncedShowLoader = G(this._showLoader.bind(this), 500); 8776 } 8777 /** @private */ 8778 _onSliderClose() { 8779 this.$["*showSlider"] = !1, this.$["*tabId"] === I.TUNING && this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible", !1); 8780 } 8781 /** 8782 * @private 8783 * @param {String} operation 8784 */ 8785 _createOperationControl(e) { 8786 let t = new Gs(); 8787 return t.operation = e, t; 8788 } 8789 /** 8790 * @private 8791 * @param {String} filter 8792 */ 8793 _createFilterControl(e) { 8794 let t = new ti(); 8795 return t.filter = e, t; 8796 } 8797 /** 8798 * @private 8799 * @param {String} operation 8800 */ 8801 _createToggleControl(e) { 8802 let t = new Hs(); 8803 return t.operation = e, t; 8804 } 8805 /** 8806 * @private 8807 * @param {String} tabId 8808 */ 8809 _renderControlsList(e) { 8810 let t = this.ref[`controls-list-${e}`], s = document.createDocumentFragment(); 8811 e === I.CROP ? this.$.cropOperations.forEach( 8812 /** @param {string} operation */ 8813 (r) => { 8814 let n = this._createToggleControl(r); 8815 s.appendChild(n); 8816 }
8817 ) : e === I.FILTERS ? [ae, ...this.$.filters].forEach((r) => { 8818 let n = this._createFilterControl(r); 8819 s.appendChild(n); 8820 }) : e === I.TUNING && this.$.colorOperations.forEach( 8821 /** @param {string} operation */ 8822 (r) => { 8823 let n = this._createOperationControl(r); 8824 s.appendChild(n); 8825 } 8826 ), [...s.children].forEach((r, n) => { 8827 n === s.childNodes.length - 1 && r.classList.add("uc-controls-list_last-item"); 8828 }), t.innerHTML = "", t.appendChild(s); 8829 } 8830 /** 8831 * @private 8832 * @param {String} id 8833 * @param {{ fromViewer?: Boolean }} options 8834 */ 8835 _activateTab(e, { fromViewer: t }) { 8836 this.$["*tabId"] = e, e === I.CROP ? (this.$["*faderEl"].deactivate(), this.$["*cropperEl"].activate(this.$["*imageSize"], { fromViewer: t })) : (this.$["*faderEl"].activate({ url: this.$["*originalUrl"], fromViewer: t }), this.$["*cropperEl"].deactivate()); 8837 for (let s of J) { 8838 let r = s === e, n = this.ref[`tab-toggle-${s}`]; 8839 n.active = r, r ? (this._renderControlsList(e), this._syncTabIndicator()) : this._unmountTabControls(s), this.$[`presence.tabContent.${s}`] = r; 8840 } 8841 } 8842 /** 8843 * @private 8844 * @param {String} tabId 8845 */ 8846 _unmountTabControls(e) { 8847 let t = this.ref[`controls-list-${e}`]; 8848 t && (t.innerHTML = ""); 8849 } 8850 /** @private */ 8851 _syncTabIndicator() { 8852 let e = this.ref[`tab-toggle-${this.$["*tabId"]}`], t = this.ref["tabs-indicator"]; 8853 t.style.transform = `translateX(${e.offsetLeft}px)`; 8854 } 8855 /** @private */ 8856 async _preloadEditedImage() { 8857 if (this.$["*imgContainerEl"] && this.$["*originalUrl"]) { 8858 let e = this.$["*imgContainerEl"].offsetWidth, t = await this.proxyUrl(ii(this.$["*originalUrl"], e, this.$["*editorTransformations"])); 8859 this._cancelPreload?.(); 8860 let { cancel: s } = Ut([t]); 8861 this._cancelPreload = () => { 8862 s(), this._cancelPreload = void 0; 8863 }; 8864 } 8865 } 8866 /** 8867 * @private 8868 * @param {boolean} show 8869 */ 8870 _showLoader(e) { 8871 this.$.showLoader = e; 8872 } 8873 _updateInfoTooltip = G(() => { 8874 const e = this.$["*editorTransformations"], t = this.$["*currentOperation"]; 8875 let s = "", r = !1; 8876 if (this.$["*tabId"] === I.FILTERS) 8877 if (r = !0, this.$["*currentFilter"] && e?.filter?.name === this.$["*currentFilter"]) { 8878 let n = e?.filter?.amount || 100; 8879 s = this.$["*currentFilter"] + " " + n; 8880 } else 8881 s = this.l10n(ae); 8882 else if (this.$["*tabId"] === I.TUNING && t) { 8883 r = !0; 8884 let n = e?.[t] || Se[t].zero; 8885 s = this.l10n(t) + " " + n; 8886 } 8887 r && (this.$["*operationTooltip"] = s), this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible", r); 8888 }, 0); 8889 initCallback() { 8890 super.initCallback(), this.$["*sliderEl"] = this.ref["slider-el"], this.sub("*imageSize", (e) => { 8891 e && setTimeout(() => { 8892 this._activateTab(this.$["*tabId"], { fromViewer: !0 }); 8893 }, 0); 8894 }), this.sub("*editorTransformations", (e) => { 8895 let t = e?.filter?.name; 8896 this.$["*currentFilter"] !== t && (this.$["*currentFilter"] = t); 8897 }), this.sub("*currentFilter", () => { 8898 this._updateInfoTooltip(); 8899 }), this.sub("*currentOperation", () => { 8900 this._updateInfoTooltip(); 8901 }), this.sub("*tabId", () => { 8902 this._updateInfoTooltip(); 8903 }), this.sub("*originalUrl", () => { 8904 this.$["*faderEl"] && this.$["*faderEl"].deactivate(); 8905 }), this.sub("*editorTransformations", (e) => { 8906 this._preloadEditedImage(), this.$["*faderEl"] && this.$["*faderEl"].setTransformations(e); 8907 }), this.sub("*loadingOperations", (e) => { 8908 let t = !1; 8909 for (let [, s] of e.entries()) { 8910 if (t) 8911 break; 8912 for (let [, r] of s.entries()) 8913 if (r) { 8914 t = !0; 8915 break; 8916 } 8917 } 8918 this._debouncedShowLoader(t); 8919 }), this.sub("*showSlider", (e) => { 8920 this.$["presence.subToolbar"] = e, this.$["presence.mainToolbar"] = !e; 8921 }), this.sub("*tabList", (e) => { 8922 this.$["presence.tabToggles"] = e.length > 1; 8923 for (const t of J) { 8924 this.$[`presence.tabToggle.${t}`] = e.includes(t); 8925 const s = this.ref[`tab-toggle-${t}`]; 8926 s.style.gridColumn = e.indexOf(t) + 1; 8927 } 8928 e.includes(this.$["*tabId"]) || this._activateTab(e[0], { fromViewer: !1 }); 8929 }), this._updateInfoTooltip(); 8930 } 8931} 8932Xs.template = /* HTML */ 8933` 8934 <uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui> 8935 <div class="uc-info-tooltip_container"> 8936 <div class="uc-info-tooltip_wrapper"> 8937 <div ref="tooltip-el" class="uc-info-tooltip uc-info-tooltip_hidden">{{*operationTooltip}}</div> 8938 </div> 8939 </div> 8940 <div class="uc-toolbar-container"> 8941 <uc-presence-toggle 8942 role="tablist" 8943 class="uc-sub-toolbar"
8944 set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles" 8945 > 8946 <div class="uc-tab-content-row">${J.map(Ml).join("")}</div> 8947 <div class="uc-controls-row"> 8948 <uc-presence-toggle 8949 class="uc-tab-toggles" 8950 set="visible: presence.tabToggles; styles: presence.tabTogglesStyles" 8951 > 8952 <div ref="tabs-indicator" class="uc-tab-toggles_indicator"></div> 8953 ${J.map(Pl).join("")} 8954 </uc-presence-toggle> 8955 <uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" set="onclick: on.cancel; title-prop:cancel"> 8956 </uc-btn-ui> 8957 <uc-btn-ui theme="primary-icon" icon="done" set="onclick: on.apply; title-prop:apply"> </uc-btn-ui> 8958 </div> 8959 </uc-presence-toggle> 8960 <uc-presence-toggle 8961 class="uc-sub-toolbar" 8962 set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles" 8963 > 8964 <div class="uc-slider"> 8965 <uc-editor-slider ref="slider-el"></uc-editor-slider> 8966 </div> 8967 <div class="uc-controls-row"> 8968 <uc-btn-ui theme="secondary" set="onclick: on.cancelSlider" l10n="@text:cancel"> </uc-btn-ui> 8969 <uc-btn-ui theme="primary" set="onclick: on.applySlider" l10n="@text:apply"> </uc-btn-ui> 8970 </div> 8971 </uc-presence-toggle> 8972 </div> 8973`; 8974class si extends k { 8975 constructor() { 8976 super(), this._iconReversed = !1, this._iconSingle = !1, this._iconHidden = !1, this.init$ = { 8977 ...this.init$, 8978 text: "", 8979 icon: "", 8980 iconCss: this._iconCss(), 8981 theme: null, 8982 "aria-role": "", 8983 "aria-controls": "", 8984 "title-prop": "" 8985 }, this.defineAccessor("active", (e) => { 8986 e ? this.setAttribute("active", "") : this.removeAttribute("active"); 8987 }); 8988 } 8989 _iconCss() { 8990 return X("uc-icon", { 8991 "uc-icon_left": !this._iconReversed, 8992 "uc-icon_right": this._iconReversed, 8993 "uc-icon_hidden": this._iconHidden, 8994 "uc-icon_single": this._iconSingle 8995 }); 8996 } 8997 initCallback() { 8998 super.initCallback(), this.sub("icon", (e) => { 8999 this._iconSingle = !this.$.text, this._iconHidden = !e, this.$.iconCss = this._iconCss(); 9000 }), this.sub("theme", (e) => { 9001 e !== "custom" && (this.className = `uc-${e}`); 9002 }), this.sub("text", (e) => { 9003 this._iconSingle = !1; 9004 }), this.hasAttribute("theme") || this.setAttribute("theme", "default"), this.defineAccessor("aria-role", (e) => { 9005 this.$["aria-role"] = e || ""; 9006 }), this.defineAccessor("aria-controls", (e) => { 9007 this.$["aria-controls"] = e || ""; 9008 }), this.defineAccessor("title-prop", (e) => { 9009 this.$["title-prop"] = e || ""; 9010 }); 9011 } 9012 set reverse(e) { 9013 this.hasAttribute("reverse") ? (this.style.flexDirection = "row-reverse", this._iconReversed = !0) : (this._iconReversed = !1, this.style.flexDirection = null); 9014 } 9015} 9016si.bindAttributes({ text: "text", icon: "icon", reverse: "reverse", theme: "theme" }); 9017si.template = /* HTML */ 9018` 9019 <button type="button" set="@role:aria-role; @aria-controls: aria-controls;" l10n="@title:title-prop"> 9020 <uc-icon set="className: iconCss; @name: icon; @hidden: !icon"></uc-icon> 9021 <div class="uc-text">{{text}}</div> 9022 </button> 9023`; 9024class Zs extends k { 9025 constructor() { 9026 super(), this._active = !1, this._handleTransitionEndRight = () => { 9027 let e = this.ref["line-el"]; 9028 e.style.transition = "initial", e.style.opacity = "0", e.style.transform = "translateX(-101%)", this._active && this._start(); 9029 }; 9030 } 9031 initCallback() { 9032 super.initCallback(), this.defineAccessor("active", (e) => { 9033 typeof e == "boolean" && (e ? this._start() : this._stop()); 9034 }); 9035 } 9036 _start() { 9037 this._active = !0; 9038 let { width: e } = this.getBoundingClientRect(), t = this.ref["line-el"]; 9039 t.style.transition = "transform 1s", t.style.opacity = "1", t.style.transform = `translateX(${e}px)`, t.addEventListener("transitionend", this._handleTransitionEndRight, { 9040 once: !0 9041 }); 9042 } 9043 _stop() { 9044 this._active = !1; 9045 } 9046} 9047Zs.template = /* HTML */ 9048` 9049 <div class="uc-inner"> 9050 <div class="uc-line" ref="line-el"></div> 9051 </div> 9052`; 9053const Ke = { 9054 transition: "uc-transition", 9055 visible: "uc-visible", 9056 hidden: "uc-hidden" 9057}; 9058class Ks extends k { 9059 constructor() { 9060 super(), this._visible = !1, this._visibleStyle = Ke.visible, this._hiddenStyle = Ke.hidden, this._externalTransitions = !1, this.defineAccessor("styles", (e) => { 9061 e && (this._externalTransitions = !0, this._visibleStyle = e.visible, this._hiddenStyle = e.hidden); 9062 }), this.defineAccessor("visible", (e) => { 9063 typeof e == "boolean" && (this._visible = e, this._handleVisible()); 9064 }); 9065 } 9066 _handleVisible() { 9067 this.style.visibility = this._visible ? "inherit" : "hidden", vl(this, {
9068 [Ke.transition]: !this._externalTransitions, 9069 [this._visibleStyle]: this._visible, 9070 [this._hiddenStyle]: !this._visible 9071 }), this.setAttribute("aria-hidden", this._visible ? "false" : "true"); 9072 } 9073 initCallback() { 9074 super.initCallback(), this.classList.toggle("uc-initial", !0), this._externalTransitions || this.classList.add(Ke.transition), this._handleVisible(), setTimeout(() => { 9075 this.classList.toggle("uc-initial", !1); 9076 }, 0); 9077 } 9078} 9079Ks.template = /* HTML */ 9080"<slot></slot> "; 9081class Ys extends k { 9082 init$ = { 9083 ...this.init$, 9084 disabled: !1, 9085 min: 0, 9086 max: 100, 9087 onInput: null, 9088 onChange: null, 9089 defaultValue: null, 9090 "on.sliderInput": () => { 9091 let e = parseInt(this.ref["input-el"].value, 10); 9092 this._updateValue(e), this.$.onInput && this.$.onInput(e); 9093 }, 9094 "on.sliderChange": () => { 9095 let e = parseInt(this.ref["input-el"].value, 10); 9096 this.$.onChange && this.$.onChange(e); 9097 } 9098 }; 9099 constructor() { 9100 super(), this.setAttribute("with-effects", ""); 9101 } 9102 initCallback() { 9103 super.initCallback(), this.defineAccessor("disabled", (t) => { 9104 this.$.disabled = t; 9105 }), this.defineAccessor("min", (t) => { 9106 this.$.min = t; 9107 }), this.defineAccessor("max", (t) => { 9108 this.$.max = t; 9109 }), this.defineAccessor("defaultValue", (t) => { 9110 this.$.defaultValue = t, this.ref["input-el"].value = t, this._updateValue(t); 9111 }), this.defineAccessor("zero", (t) => { 9112 this._zero = t; 9113 }), this.defineAccessor("onInput", (t) => { 9114 t && (this.$.onInput = t); 9115 }), this.defineAccessor("onChange", (t) => { 9116 t && (this.$.onChange = t); 9117 }), this._updateSteps(), this._observer = new ResizeObserver(() => { 9118 this._updateSteps(); 9119 let t = parseInt(this.ref["input-el"].value, 10); 9120 this._updateValue(t); 9121 }), this._observer.observe(this), this._thumbSize = parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"), 10), setTimeout(() => { 9122 let t = parseInt(this.ref["input-el"].value, 10); 9123 this._updateValue(t); 9124 }, 0), this.sub("disabled", (t) => { 9125 let s = this.ref["input-el"]; 9126 t ? s.setAttribute("disabled", "disabled") : s.removeAttribute("disabled"); 9127 }); 9128 let e = this.ref["input-el"]; 9129 e.addEventListener("focus", () => { 9130 this.style.setProperty("--color-effect", "var(--hover-color-rgb)"); 9131 }), e.addEventListener("blur", () => { 9132 this.style.setProperty("--color-effect", "var(--idle-color-rgb)"); 9133 }); 9134 } 9135 _updateValue(e) { 9136 this._updateZeroDot(e); 9137 let { width: t } = this.getBoundingClientRect(), n = 100 / (this.$.max - this.$.min) * (e - this.$.min) * (t - this._thumbSize) / 100; 9138 window.requestAnimationFrame(() => { 9139 this.ref["thumb-el"].style.transform = `translateX(${n}px)`; 9140 }); 9141 } 9142 _updateZeroDot(e) { 9143 if (!this._zeroDotEl) 9144 return; 9145 e === this._zero ? this._zeroDotEl.style.opacity = "0" : this._zeroDotEl.style.opacity = "1"; 9146 let { width: t } = this.getBoundingClientRect(), n = 100 / (this.$.max - this.$.min) * (this._zero - this.$.min) * (t - this._thumbSize) / 100; 9147 window.requestAnimationFrame(() => { 9148 this._zeroDotEl.style.transform = `translateX(${n}px)`; 9149 }); 9150 } 9151 _updateSteps() { 9152 let t = this.ref["steps-el"], { width: s } = t.getBoundingClientRect(), r = Math.ceil(s / 2), n = Math.ceil(r / 15) - 2; 9153 if (this._stepsCount === n) 9154 return; 9155 let o = document.createDocumentFragment(), a = document.createElement("div"), l = document.createElement("div"); 9156 a.className = "uc-minor-step", l.className = "uc-border-step", o.appendChild(l); 9157 for (let d = 0; d < n; d++) 9158 o.appendChild(a.cloneNode()); 9159 o.appendChild(l.cloneNode()); 9160 for (let d = 0; d < n; d++) 9161 o.appendChild(a.cloneNode()); 9162 o.appendChild(l.cloneNode()); 9163 let c = document.createElement("div"); 9164 c.className = "uc-zero-dot", o.appendChild(c), this._zeroDotEl = c, t.innerHTML = "", t.appendChild(o), this._stepsCount = n; 9165 } 9166 destroyCallback() { 9167 super.destroyCallback(), this._observer?.disconnect(); 9168 } 9169} 9170Ys.template = /* HTML */ 9171` 9172 <div class="uc-steps" ref="steps-el"></div> 9173 <div ref="thumb-el" class="uc-thumb"></div> 9174 <input 9175 class="uc-input" 9176 type="range" 9177 ref="input-el" 9178 set="oninput: on.sliderInput; onchange: on.sliderChange; @min: min; @max: max; @value: defaultValue;" 9179 /> 9180`; 9181class Rl extends U { 9182 couldBeCtxOwner = !0; 9183 activityType = _.activities.CLOUD_IMG_EDIT; 9184 /** 9185 * @private 9186 * @type {import('../../abstract/TypedData.js').TypedData | undefined} 9187 */ 9188 _entry; 9189 /** 9190 * @private 9191 * @type {CloudImageEditorBlock | undefined} 9192 */ 9193 _instance; 9194 /** @type {ActivityParams} */ 9195 get activityParams() { 9196 const e = super.activityParams; 9197 if ("internalId" in e) 9198 return e; 9199 throw new Error("Cloud Image Editor activity params not found"); 9200 } 9201 initCallback() { 9202 super.initCallback(), this.registerActivity(this.activityType, { 9203 onActivate: () => this.mountEditor(), 9204 onDeactivate: () => this.unmountEditor() 9205 }), this.subConfigValue("cropPreset", (e) => { 9206 this._instance && this._instance.getAttribute("crop-preset") !== e && this._instance.setAttribute("crop-preset", e); 9207 }), this.subConfigValue("cloudImageEditorTabs", (e) => { 9208 this._instance && this._instance.getAttribute("tabs") !== e && this._instance.setAttribute("tabs", e); 9209 }); 9210 } 9211 /** @param {CustomEvent<import('../CloudImageEditor/src/types.js').ApplyResult>} e */ 9212 handleApply(e) { 9213 if (!this._entry) 9214 return; 9215 let t = e.detail; 9216 this._entry.setMultipleValues({ 9217 cdnUrl: t.cdnUrl, 9218 cdnUrlModifiers: t.cdnUrlModifiers 9219 }), this.historyBack(); 9220 } 9221 handleCancel() { 9222 this.historyBack(); 9223 } 9224 mountEditor() { 9225 const { internalId: e } = this.activityParams; 9226 if (this._entry = this.uploadCollection.read(e), !this._entry) 9227 throw new Error(`Entry with internalId "${e}" not found`); 9228 const t = this._entry.getValue("cdnUrl"); 9229 if (!t) 9230 throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`); 9231 const s = new He(), r = this.cfg.cropPreset, n = this.cfg.cloudImageEditorTabs; 9232 s.setAttribute("ctx-name", this.ctxName), s.setAttribute("cdn-url", t), r && s.setAttribute("crop-preset", r), n && s.setAttribute("tabs", n), s.addEventListener("apply", (o) => { 9233 const a = ( 9234 /** @type {CustomEvent<import('../CloudImageEditor/src/types.js').ApplyResult>} */ 9235 o 9236 ); 9237 this.handleApply(a), this.debugPrint('editor event "apply"', a.detail); 9238 }), s.addEventListener("cancel", (o) => { 9239 const a = ( 9240 /** @type {CustomEvent<void>} */ 9241 o 9242 ); 9243 this.handleCancel(), this.debugPrint('editor event "cancel"', a.detail); 9244 }), s.addEventListener("change", (o) => { 9245 const a = ( 9246 /** @type {CustomEvent<import('../CloudImageEditor/src/types.js').ChangeResult>} */ 9247 o 9248 ); 9249 this.debugPrint('editor event "change"', a.detail); 9250 }), this.innerHTML = "", this.appendChild(s), this._instance = s; 9251 } 9252 unmountEditor() { 9253 this._instance = void 0, this._entry = void 0, this.innerHTML = ""; 9254 } 9255} 9256const Dl = function(i) { 9257 return i.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 9258}, Fl = function(i, e = "i") { 9259 const t = i.split("*").map(Dl); 9260 return new RegExp("^" + t.join(".+") + "$", e); 9261}; 9262function Vl(i, e) { 9263 return window.getComputedStyle(i).getPropertyValue(e).trim(); 9264} 9265const Nl = ( 9266 /** @type {(keyof import('./types.js').ThemeDefinition)[]} */ 9267 [ 9268 "--uc-font-family", 9269 "--uc-font-size", 9270 "--uc-line-height", 9271 "--uc-button-size", 9272 "--uc-preview-size", 9273 "--uc-input-size", 9274 "--uc-padding", 9275 "--uc-radius", 9276 "--uc-transition", 9277 "--uc-background", 9278 "--uc-foreground", 9279 "--uc-primary", 9280 "--uc-primary-hover", 9281 "--uc-primary-transparent", 9282 "--uc-primary-foreground", 9283 "--uc-secondary", 9284 "--uc-secondary-hover", 9285 "--uc-secondary-foreground", 9286 "--uc-muted", 9287 "--uc-muted-foreground", 9288 "--uc-destructive", 9289 "--uc-destructive-foreground", 9290 "--uc-border" 9291 ] 9292); 9293function zl(i) { 9294 return Nl.reduce( 9295 (e, t) => { 9296 const s = Vl(i, t); 9297 return s && (e[t] = s), e; 9298 },
9299 /** @type {Record<keyof import('./types.js').ThemeDefinition, string>} */ 9300 {} 9301 ); 9302} 9303const Bl = ["selected-files-change"], Hl = (i) => !i || typeof i != "object" ? !1 : "type" in i && Bl.includes( 9304 /** @type {import('./types').InputMessageType} */ 9305 i.type 9306); 9307class jl { 9308 /** @type {Map<string, Set<import('./types').InputMessageHandler<import('./types').InputMessageType>>>} */ 9309 _handlerMap = /* @__PURE__ */ new Map(); 9310 /** @type {Window} */ 9311 _context; 9312 /** @param {Window} context */ 9313 constructor(e) { 9314 this._context = e, window.addEventListener("message", this._handleMessage); 9315 } 9316 /** @param {MessageEvent} e */ 9317 _handleMessage = (e) => { 9318 if (e.source !== this._context) 9319 return; 9320 const t = e.data; 9321 if (!Hl(t)) 9322 return; 9323 const s = this._handlerMap.get(t.type); 9324 if (s) 9325 for (const r of s) 9326 r(t); 9327 }; 9328 /** 9329 * @template {import('./types').InputMessageType} T 9330 * @param {T} type 9331 * @param {import('./types').InputMessageHandler<T>} handler 9332 */ 9333 on(e, t) { 9334 const s = this._handlerMap.get(e) ?? /* @__PURE__ */ new Set(); 9335 this._handlerMap.has(e) || this._handlerMap.set(e, s), s.add( 9336 /** @type {import('./types').InputMessageHandler<import('./types').InputMessageType>} */ 9337 t 9338 ); 9339 } 9340 /** @param {import('./types').OutputMessage} message */ 9341 send(e) { 9342 this._context.postMessage(e, "*"); 9343 } 9344 destroy() { 9345 window.removeEventListener("message", this._handleMessage); 9346 } 9347} 9348function Gl(i) { 9349 let e = []; 9350 for (let [t, s] of Object.entries(i)) 9351 s == null || typeof s == "string" && s.length === 0 || e.push(`${t}=${encodeURIComponent(s)}`); 9352 return e.join("&"); 9353} 9354class Js extends U { 9355 couldBeCtxOwner = !0; 9356 activityType = _.activities.EXTERNAL; 9357 constructor() { 9358 super(), this.init$ = { 9359 ...this.init$, 9360 activityIcon: "", 9361 activityCaption: "", 9362 /** @type {import('./types.js').InputMessageMap['selected-files-change']['selectedFiles']} */ 9363 selectedList: [], 9364 total: 0, 9365 isSelectionReady: !1, 9366 isDoneBtnEnabled: !1, 9367 couldSelectAll: !1, 9368 couldDeselectAll: !1, 9369 showSelectionStatus: !1, 9370 counterText: "", 9371 doneBtnTextClass: "uc-hidden", 9372 onDone: () => { 9373 for (const e of this.$.selectedList) { 9374 const t = this.extractUrlFromSelectedFile(e), { filename: s } = e, { externalSourceType: r } = this.activityParams; 9375 this.api.addFileFromUrl(t, { fileName: s, source: r }); 9376 } 9377 this.$["*currentActivity"] = _.activities.UPLOAD_LIST; 9378 }, 9379 onCancel: () => { 9380 this.historyBack(); 9381 }, 9382 onSelectAll: () => { 9383 this._messageBridge?.send({ type: "select-all" }); 9384 }, 9385 onDeselectAll: () => { 9386 this._messageBridge?.send({ type: "deselect-all" }); 9387 } 9388 }; 9389 } 9390 /** @type {ActivityParams} */ 9391 get activityParams() { 9392 const e = super.activityParams; 9393 if ("externalSourceType" in e) 9394 return e; 9395 throw new Error("External Source activity params not found"); 9396 } 9397 initCallback() { 9398 super.initCallback(), this.registerActivity(this.activityType, { 9399 onActivate: () => { 9400 let { externalSourceType: e } = ( 9401 /** @type {ActivityParams} */ 9402 this.activityParams 9403 ); 9404 if (!e) { 9405 this.$["*currentActivity"] = null, this.setOrAddState("*modalActive", !1), console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`); 9406 return; 9407 } 9408 this.set$({ 9409 activityCaption: `${e?.[0].toUpperCase()}${e?.slice(1)}`, 9410 activityIcon: e 9411 }), this.mountIframe(); 9412 } 9413 }), this.sub("*currentActivityParams", (e) => { 9414 this.isActivityActive && (this.unmountIframe(), this.mountIframe()); 9415 }), this.sub("*currentActivity", (e) => { 9416 e !== this.activityType && this.unmountIframe(); 9417 }), this.subConfigValue("multiple", (e) => { 9418 this.$.showSelectionStatus = e; 9419 }), this.subConfigValue("localeName", (e) => { 9420 this.setupL10n(); 9421 }), this.subConfigValue("externalSourcesEmbedCss", (e) => { 9422 this.applyEmbedCss(e); 9423 }); 9424 } 9425 /** 9426 * @private 9427 * @param {NonNullable<import('./types.js').InputMessageMap['selected-files-change']['selectedFiles']>[number]} selectedFile 9428 */ 9429 extractUrlFromSelectedFile(e) { 9430 if (e.alternatives) { 9431 const t = ce(this.cfg.externalSourcesPreferredTypes); 9432 for (const s of t) { 9433 const r = Fl(s); 9434 for (const [n, o] of Object.entries(e.alternatives)) 9435 if (r.test(n)) 9436 return o; 9437 } 9438 } 9439 return e.url; 9440 } 9441 /** 9442 * @private 9443 * @param {import('./types.js').InputMessageMap['selected-files-change']} message 9444 */ 9445 async handleSelectedFilesChange(e) { 9446 if (this.cfg.multiple !== e.isMultipleMode) { 9447 console.error("Multiple mode mismatch"); 9448 return; 9449 } 9450 this.bindL10n( 9451 "counterText", 9452 () => this.l10n("selected-count", { 9453 count: e.selectedCount, 9454 total: e.total 9455 }) 9456 ), this.set$({ 9457 doneBtnTextClass: e.isReady ? "" : "uc-hidden", 9458 isSelectionReady: e.isReady, 9459 isDoneBtnEnabled: e.isReady && e.selectedFiles.length > 0, 9460 showSelectionStatus: e.isMultipleMode && e.total > 0, 9461 couldSelectAll: e.selectedCount < e.total, 9462 couldDeselectAll: e.selectedCount === e.total, 9463 selectedList: e.selectedFiles 9464 }); 9465 } 9466 /** @private */ 9467 handleIframeLoad() { 9468 this.applyEmbedCss(this.cfg.externalSourcesEmbedCss), this.applyTheme(), this.setupL10n(); 9469 } 9470 /** @private */ 9471 applyTheme() { 9472 this._messageBridge?.send({ 9473 type: "set-theme-definition", 9474 theme: zl(this) 9475 }); 9476 } 9477 /** 9478 * @private 9479 * @param {string} css 9480 */ 9481 applyEmbedCss(e) { 9482 this._messageBridge?.send({ 9483 type: "set-embed-css", 9484 css: e 9485 }); 9486 } 9487 /** @private */ 9488 setupL10n() { 9489 this._messageBridge?.send({ 9490 type: "set-locale-definition", 9491 localeDefinition: this.cfg.localeName 9492 }); 9493 } 9494 /** @private */ 9495 remoteUrl() { 9496 const { pubkey: e, remoteTabSessionKey: t, socialBaseUrl: s, multiple: r }
9496 = this.cfg, { externalSourceType: n } = this.activityParams, a = { 9497 lang: this.l10n("social-source-lang")?.split("-")?.[0] || "en", 9498 public_key: e, 9499 images_only: "false", 9500 session_key: t, 9501 wait_for_theme: !0, 9502 multiple: r.toString() 9503 }, l = new URL(`/window4/${n}`, s); 9504 return l.search = Gl(a), l.toString(); 9505 } 9506 /** @private */ 9507 mountIframe() { 9508 let e = Hi({ 9509 tag: "iframe", 9510 attributes: { 9511 src: this.remoteUrl(), 9512 marginheight: 0, 9513 marginwidth: 0, 9514 frameborder: 0, 9515 allowTransparency: !0 9516 } 9517 }); 9518 e.addEventListener("load", this.handleIframeLoad.bind(this)), this.ref.iframeWrapper.innerHTML = "", this.ref.iframeWrapper.appendChild(e), e.contentWindow && (this._messageBridge?.destroy(), this._messageBridge = new jl(e.contentWindow), this._messageBridge.on("selected-files-change", this.handleSelectedFilesChange.bind(this)), this.resetSelectionStatus()); 9519 } 9520 /** @private */ 9521 unmountIframe() { 9522 this._messageBridge?.destroy(), this._messageBridge = void 0, this.ref.iframeWrapper.innerHTML = "", this.resetSelectionStatus(); 9523 } 9524 /** @private */ 9525 resetSelectionStatus() { 9526 this.set$({ 9527 selectedList: [], 9528 total: 0, 9529 isDoneBtnEnabled: !1, 9530 couldSelectAll: !1, 9531 couldDeselectAll: !1, 9532 showSelectionStatus: !1 9533 }); 9534 } 9535} 9536Js.template = /* HTML */ 9537` 9538 <uc-activity-header> 9539 <button 9540 type="button" 9541 class="uc-mini-btn uc-close-btn" 9542 set="onclick: *historyBack" 9543 l10n="@title:a11y-activity-header-button-close" 9544 > 9545 <uc-icon name="close"></uc-icon> 9546 </button> 9547 </uc-activity-header> 9548 <div class="uc-content"> 9549 <div ref="iframeWrapper" class="uc-iframe-wrapper"></div> 9550 <div class="uc-toolbar"> 9551 <button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel" l10n="cancel"></button> 9552 <div set="@hidden: !showSelectionStatus" class="uc-selection-status-box"> 9553 <span>{{counterText}}</span> 9554 <button type="button" set="onclick: onSelectAll; @hidden: !couldSelectAll" l10n="select-all"></button> 9555 <button type="button" set="onclick: onDeselectAll; @hidden: !couldDeselectAll" l10n="deselect-all"></button> 9556 </div> 9557 <button type="button" class="uc-done-btn uc-primary-btn" set="onclick: onDone; @disabled: !isDoneBtnEnabled;"> 9558 <uc-spinner set="@hidden: isSelectionReady"></uc-spinner> 9559 <span l10n="done" set="@class: doneBtnTextClass"></span> 9560 </button> 9561 </div> 9562 </div> 9563`; 9564class Wl extends U { 9565 requireCtxName = !0; 9566 _createValidationInput() { 9567 const e = document.createElement("input"); 9568 return e.type = "text", e.name = this.ctxName, e.required = this.cfg.multipleMin > 0, e.tabIndex = -1, Mt(e, { 9569 opacity: 0, 9570 height: 0, 9571 width: 0 9572 }), e; 9573 } 9574 initCallback() { 9575 super.initCallback(), this._validationInputElement = this._createValidationInput(), this.appendChild(this._validationInputElement), this.sub( 9576 "*collectionState", 9577 (e) => { 9578 { 9579 if (this._dynamicInputsContainer || (this._dynamicInputsContainer = document.createElement("div"), this.appendChild(this._dynamicInputsContainer)), !this._validationInputElement) { 9580 const n = this._createValidationInput(); 9581 this.appendChild(n), this._validationInputElement = n; 9582 } 9583 if (this._dynamicInputsContainer.innerHTML = "", e.status === "uploading" || e.status === "idle") { 9584 this._validationInputElement.value = "", this._validationInputElement.setCustomValidity(""); 9585 return; 9586 } 9587 if (e.status === "failed") { 9588 const n = e.errors[0]?.message; 9589 this._validationInputElement.value = "", this._validationInputElement.setCustomValidity(n); 9590 return; 9591 } 9592 const t = e.group ? e.group : null; 9593 if (t) { 9594 this._validationInputElement.value = t.cdnUrl, this._validationInputElement.setCustomValidity(""); 9595 return; 9596 } 9597 const s = e.allEntries.map((n) => n.cdnUrl); 9598 if (!this.cfg.multiple && s.length === 1) {
9599 this._validationInputElement.value = s[0], this._validationInputElement.setCustomValidity(""); 9600 return; 9601 } 9602 this._validationInputElement.remove(), this._validationInputElement = null; 9603 const r = new DocumentFragment(); 9604 for (let n of s) { 9605 const o = document.createElement("input"); 9606 o.type = "hidden", o.name = `${this.ctxName}[]`, o.value = n, r.appendChild(o); 9607 } 9608 this._dynamicInputsContainer.replaceChildren(r); 9609 } 9610 }, 9611 !1 9612 ); 9613 } 9614} 9615class ql extends _ { 9616} 9617class Qs extends k { 9618 init$ = { 9619 ...this.init$, 9620 currentText: "", 9621 options: [], 9622 selectHtml: "", 9623 onSelect: (e) => { 9624 e.preventDefault(), e.stopPropagation(), this.value = this.ref.select.value, this.$.currentText = this.$.options.find((t) => t.value == this.value)?.text || "", this.dispatchEvent(new Event("change")); 9625 } 9626 }; 9627 initCallback() { 9628 super.initCallback(), this.sub("options", (e) => { 9629 this.$.currentText = e?.[0]?.text || ""; 9630 let t = ""; 9631 e?.forEach((s) => { 9632 t += /* HTML */ 9633 `<option value="${s.value}">${s.text}</option>`; 9634 }), this.$.selectHtml = t; 9635 }); 9636 } 9637} 9638Qs.template = /* HTML */ 9639' <select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select> '; 9640class Xl extends k { 9641 initCallback() { 9642 super.initCallback(), this.subConfigValue( 9643 "removeCopyright", 9644 /** @param {number} value */ 9645 (e) => { 9646 this.toggleAttribute("hidden", !!e); 9647 } 9648 ); 9649 } 9650 static template = ( 9651 /* HTML */ 9652 ` 9653 <a 9654 href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" 9655 target="_blank noopener" 9656 class="uc-credits" 9657 >Powered by Uploadcare</a 9658 > 9659 ` 9660 ); 9661} 9662class er extends ze { 9663} 9664er.template = /* HTML */ 9665' <div class="uc-spinner"></div> '; 9666class ri extends ht { 9667 static styleAttrs = [...super.styleAttrs, "uc-file-uploader-regular"]; 9668 constructor() { 9669 super(), this.init$ = { 9670 ...this.init$, 9671 isHidden: !1 9672 }; 9673 } 9674 initCallback() { 9675 super.initCallback(), this.defineAccessor( 9676 "headless", 9677 /** @param {unknown} value */ 9678 (e) => { 9679 this.set$({ isHidden: $(e) }); 9680 } 9681 ), this.sub( 9682 "*modalActive", 9683 (e) => { 9684 this._lastModalActive !== e && this.emit(e ? O.MODAL_OPEN : O.MODAL_CLOSE, void 0, { debounce: !0 }), this._lastModalActive = e; 9685 }, 9686 !1 9687 ); 9688 } 9689} 9690ri.template = /* HTML */ 9691` 9692 <uc-simple-btn set="@hidden: isHidden"></uc-simple-btn> 9693 9694 <uc-modal strokes block-body-scrolling> 9695 <uc-start-from> 9696 <uc-drop-area with-icon clickable></uc-drop-area> 9697 <uc-source-list wrap></uc-source-list> 9698 <button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button> 9699 <uc-copyright></uc-copyright> 9700 </uc-start-from> 9701 <uc-upload-list></uc-upload-list> 9702 <uc-camera-source></uc-camera-source> 9703 <uc-url-source></uc-url-source> 9704 <uc-external-source></uc-external-source> 9705 <uc-cloud-image-editor-activity></uc-cloud-image-editor-activity> 9706 </uc-modal> 9707`; 9708ri.bindAttributes({ 9709 // @ts-expect-error TODO: fix types inside symbiote 9710 headless: null 9711}); 9712class tr extends ht { 9713 static styleAttrs = [...super.styleAttrs, "uc-file-uploader-minimal"]; 9714 initCallback() { 9715 super.initCallback(); 9716 const e = this.ref.uBlock; 9717 this.sub("*currentActivity", (t) => { 9718 t || (this.$["*currentActivity"] = e.initActivity || _.activities.START_FROM); 9719 }), this.sub("*uploadList", (t) => { 9720 t?.length > 0 ? this.$["*currentActivity"] = _.activities.UPLOAD_LIST : this.$["*currentActivity"] = e.initActivity || _.activities.START_FROM; 9721 }), this.subConfigValue("sourceList", (t) => { 9722 t !== "local" && (this.cfg.sourceList = "local"); 9723 }), this.subConfigValue("confirmUpload", (t) => { 9724 t !== !1 && (this.cfg.confirmUpload = !1); 9725 }); 9726 } 9727} 9728tr.template = /* HTML */ 9729` 9730 <uc-start-from> 9731 <uc-drop-area tabindex="0" clickable l10n="choose-file"></uc-drop-area> 9732 <uc-copyright></uc-copyright> 9733 </uc-start-from> 9734 <uc-upload-list ref="uBlock"></uc-upload-list> 9735`; 9736class ir extends ht { 9737 static styleAttrs = [...super.styleAttrs, "uc-file-uploader-inline"]; 9738 constructor() { 9739 super(), this.init$ = { 9740 ...this.init$, 9741 couldCancel: !1, 9742 cancel: () => { 9743 this.couldHistoryBack ? this.$["*historyBack"]() : this.couldShowList && (this.$["*currentActivity"] = _.activities.UPLOAD_LIST); 9744 } 9745 }; 9746 } 9747 get couldHistoryBack() { 9748 const e = this.$["*history"]; 9749 return e.length > 1 && e[e.length - 1] !== _.activities.START_FROM; 9750 } 9751 get couldShowList() { 9752 return this.cfg.showEmptyList || this.$["*uploadList"].length > 0; 9753 } 9754 initCallback() { 9755 super.initCallback(); 9756 const e = this.ref.uBlock; 9757 this.sub("*currentActivity", (t) => { 9758 t || (this.$["*currentActivity"] = e.initActivity || _.activities.START_FROM); 9759 }), this.sub("*uploadList", (t) => { 9760 t?.length > 0 && this.$["*currentActivity"] === (e.initActivity || _.activities.START_FROM) && (this.$["*currentActivity"] = _.activities.UPLOAD_LIST); 9761 }), this.sub("*history", () => { 9762 this.$.couldCancel = this.couldHistoryBack || this.couldShowList; 9763 }); 9764 } 9765} 9766ir.template = /* HTML */ 9767` 9768 <uc-start-from> 9769 <uc-drop-area with-icon clickable></uc-drop-area> 9770 <uc-source-list wrap></uc-source-list> 9771 <button 9772 type="button" 9773 l10n="start-from-cancel" 9774 class="uc-cancel-btn uc-secondary-btn"
9775 set="onclick: cancel; @hidden: !couldCancel" 9776 ></button> 9777 <uc-copyright></uc-copyright> 9778 </uc-start-from> 9779 <uc-upload-list ref="uBlock"></uc-upload-list> 9780 <uc-camera-source></uc-camera-source> 9781 <uc-url-source></uc-url-source> 9782 <uc-external-source></uc-external-source> 9783 <uc-cloud-image-editor-activity></uc-cloud-image-editor-activity> 9784`; 9785class Zl extends He { 9786 static styleAttrs = [...super.styleAttrs, "uc-wgt-common"]; 9787 initCallback() { 9788 super.initCallback(), this.a11y?.registerBlock(this); 9789 } 9790} 9791function ni(i) { 9792 for (let e in i) { 9793 let t = [...e].reduce((s, r) => (r.toUpperCase() === r && (r = "-" + r.toLowerCase()), s += r), ""); 9794 t.startsWith("-") && (t = t.replace("-", "")), t.startsWith("uc-") || (t = "uc-" + t), i[e].reg && i[e].reg(t); 9795 } 9796} 9797const St = "UC"; 9798async function Kl(i, e = !1) { 9799 return new Promise((t, s) => { 9800 if (typeof document != "object") { 9801 t(null); 9802 return; 9803 } 9804 if (typeof window == "object" && window[St]) { 9805 t(window[St]); 9806 return; 9807 } 9808 let r = document.createElement("script"); 9809 r.async = !0, r.src = i, r.onerror = () => { 9810 s(); 9811 }, r.onload = () => { 9812 let n = window[St]; 9813 e && ni(n), t(n); 9814 }, document.head.appendChild(r); 9815 }); 9816} 9817const Yl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ 9818 __proto__: null, 9819 ActivityBlock: _, 9820 ActivityHeader: ql, 9821 BaseComponent: ze, 9822 Block: k, 9823 BtnUi: si, 9824 CameraSource: x, 9825 CloudImageEditor: Zl, 9826 CloudImageEditorActivity: Rl, 9827 CloudImageEditorBlock: He, 9828 Config: Sa, 9829 Copyright: Xl, 9830 CropFrame: Bs, 9831 Data: A, 9832 DropArea: Jt, 9833 EditorCropButtonControl: Hs, 9834 EditorFilterControl: ti, 9835 EditorImageCropper: Ws, 9836 EditorImageFader: Ll, 9837 EditorOperationControl: Gs, 9838 EditorScroller: qs, 9839 EditorSlider: js, 9840 EditorToolbar: Xs, 9841 ExternalSource: Js, 9842 ExternalUploadSource: mt, 9843 FileItem: _e, 9844 FileUploaderInline: ir, 9845 FileUploaderMinimal: tr, 9846 FileUploaderRegular: ri, 9847 FormInput: Wl, 9848 Icon: Kt, 9849 Img: Ua, 9850 LineLoaderUi: Zs, 9851 Modal: Ps, 9852 PACKAGE_NAME: ft, 9853 PACKAGE_VERSION: pt, 9854 PresenceToggle: Ks, 9855 ProgressBar: Ns, 9856 ProgressBarCommon: Vs, 9857 Select: Qs, 9858 SimpleBtn: Yt, 9859 SliderUi: Ys, 9860 SolutionBlock: ht, 9861 SourceBtn: Qt, 9862 SourceList: Na, 9863 Spinner: er, 9864 StartFrom: Es, 9865 UID: st, 9866 UploadCtxProvider: yl, 9867 UploadList: Rs, 9868 UploadSource: P, 9869 UploaderBlock: U, 9870 UrlSource: Ds, 9871 defineComponents: ni, 9872 defineLocale: _s, 9873 loadFileUploaderFrom: Kl, 9874 toKebabCase: gt 9875}, Symbol.toStringTag, { value: "Module" })), Jl = ["ctx-name", "pubkey", "multiple", "max-local-file-size-bytes", "use-cloud-image-editor", "crop-preset"], Ql = ["ctx-name"], ec = ["ctx-name"], tc = { 9876 xmlns: "http://www.w3.org/2000/svg", 9877 style: { display: "none" } 9878}, ic = /* @__PURE__ */ sr({ 9879 __name: "uc-file-uploader", 9880 props: { 9881 ctxName: {}, 9882 multiple: { type: Boolean, default: !1 }, 9883 maxLocalFileSizeBytes: { default: 10485760 }, 9884 useCloudImageEditor: { type: Boolean }, 9885 cropPreset: {} 9886 }, 9887 setup(i, { expose: e }) { 9888 ni(Yl); 9889 const t = "c1d6ce04c47e2145d20b", s = oi("uploadcare-config"), r = oi("uploader-ctx"), n = rr(), o = nr(() => n.value === "image/gif"); 9890 e({ 9891 uploaderCtx: r 9892 }); 9893 const a = ((d) => { 9894 if (d === "default") 9895 return "#uc-custom-icon-default"; 9896 }), l = { 9897 en: { 9898 "drop-files-here": "Drop file here" 9899 } 9900 }; 9901 function c(d) { 9902 n.value = d.detail.mimeType; 9903 } 9904 return or(() => { 9905 s.value && (s.value.iconHrefResolver = a, s.value.localeDefinitionOverride = l, r.value?.addEventListener("file-added", c)); 9906 }), ar(() => { 9907 r.value?.removeEventListener("file-added", c); 9908 }), (d, u) => (ai(), li(lr, null, [ 9909 we("uc-config", cr({ 9910 ref: "uploadcare-config", 9911 "ctx-name": i.ctxName, 9912 pubkey: ur(t), 9913 multiple: i.multiple, 9914 "max-local-file-size-bytes": i.maxLocalFileSizeBytes, 9915 "use-cloud-image-editor": o.value ? !1 : i.useCloudImageEditor, 9916 "crop-preset": o.value ? "" : i.cropPreset 9917 }, d.$attrs), null, 16, Jl), 9918 we("uc-upload-ctx-provider", { 9919 ref: "uploader-ctx", 9920 "ctx-name": i.ctxName 9921 }, null, 8, Ql), 9922 we("uc-file-uploader-regular", { 9923 "ctx-name": i.ctxName, 9924 headless: "true",
9925 class: "uc-light" 9926 }, null, 8, ec), 9927 (ai(), li("svg", tc, [...u[0] || (u[0] = [ 9928 we("symbol", { 9929 id: "uc-custom-icon-default", 9930 viewBox: "0 0 26 26", 9931 fill: "none" 9932 }, [ 9933 we("rect", { 9934 width: "26", 9935 height: "26", 9936 rx: "13", 9937 style: { fill: "rgb(var(--color-primary))" } 9938 }), 9939 we("path", { 9940 fill: "white", 9941 d: "M13.75 7.25C13.75 6.83437 13.4156 6.5 13 6.5C12.5844 6.5 12.25 6.83437 12.25 7.25V12.25H7.25C6.83437 12.25 6.5 12.5844 6.5 13C6.5 13.4156 6.83437 13.75 7.25 13.75H12.25V18.75C12.25 19.1656 12.5844 19.5 13 19.5C13.4156 19.5 13.75 19.1656 13.75 18.75V13.75H18.75C19.1656 13.75 19.5 13.4156 19.5 13C19.5 12.5844 19.1656 12.25 18.75 12.25H13.75V7.25Z" 9942 }) 9943 ], -1) 9944 ])])) 9945 ], 64)); 9946 } 9947}), sc = (i, e) => { 9948 const t = i.__vccOpts || i; 9949 for (const [s, r] of e) 9950 t[s] = r; 9951 return t; 9952}, nc = /* @__PURE__ */ sc(ic, [["__scopeId", "data-v-dfa144f5"]]); 9953export { 9954 nc as UcFileUploader 9955}; 9956//# sourceMappingURL=uploadcare.js.map 9957(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(':where([uc-wgt-common]){--cfg-init-activity: "start-from";--cfg-done-activity: ""}:where([uc-wgt-common]){--uc-font-family: system-ui;--uc-font-size: 14px;--uc-line-height: normal;--uc-simple-btn-font-family: system-ui;--uc-simple-btn-font-size: 14px;--uc-button-size: 32px;--uc-preview-size: 32px;--uc-padding: 10px;--uc-radius: 8px;--uc-transition: .2s ease;--uc-dialog-width: 430px;--uc-dialog-max-width: 920px;--uc-dialog-max-height: 675px;--uc-simple-btn-padding: 7px 14px;--uc-background: var(--uc-background-light);--uc-foreground: var(--uc-foreground-light);--uc-primary: var(--uc-primary-light);--uc-primary-hover: var(--uc-primary-hover-light);--uc-primary-transparent: var(--uc-primary-transparent-light);--uc-primary-foreground: var(--uc-primary-foreground-light);--uc-secondary: var(--uc-secondary-light);--uc-secondary-hover: var(--uc-secondary-hover-light);--uc-secondary-foreground: var(--uc-secondary-foreground-light);--uc-muted: var(--uc-muted-light);--uc-muted-foreground: var(--uc-muted-foreground-light);--uc-destructive: var(--uc-destructive-light);--uc-destructive-foreground: var(--uc-destructive-foreground-light);--uc-border: var(--uc-border-light);--uc-dialog-shadow: var(--uc-dialog-shadow-light);--uc-simple-btn: var(--uc-simple-btn-light);--uc-simple-btn-hover: var(--uc-simple-btn-hover-light);--uc-simple-btn-foreground: var(--uc-simple-btn-foreground-light)}@supports not (color: oklch(0% 0 0)){:where([uc-wgt-common]){--uc-primary-rgb-light: 23 75 215;--uc-primary-light: rgb(var(--uc-primary-rgb-light));--uc-primary-hover-light: rgb(var(--uc-primary-rgb-light) / 90%);--uc-primary-transparent-light: rgb(var(--uc-primary-rgb-light) / 10%);--uc-background-light: rgb(255 255 255);--uc-foreground-light: rgb(24 24 24);--uc-primary-foreground-light: #fff;--uc-secondary-light: rgb(24 24 24 / 5%);--uc-secondary-hover-light: rgb(24 24 24 / 8%);--uc-secondary-foreground-light: rgb(24 24 24);--uc-muted-light: rgb(245 245 245);--uc-muted-foreground-light: rgb(113 113 113);--uc-destructive-light: rgb(232 19 20 / 5%);--uc-destructive-foreground-light: rgb(232 19 20);--uc-border-light: rgb(228 228 232);--uc-dialog-shadow-light: 0px 6px 20px rgb(0 0 0 / 10%);--uc-simple-btn-light: rgb(235 235 235);--uc-simple-btn-hover-light: rgb(228 228 228);--uc-simple-btn-foreground-light: rgb(24 24 24);--uc-primary-rgb-dark: 87 154 255;--uc-primary-dark: rgb(var(--uc-primary-rgb-dark));--uc-primary-hover-dark: rgb(var(--uc-primary-rgb-dark) / 90%);--uc-primary-transparent-dark: rgb(var(--uc-primary-rgb-dark) / 7%);--uc-background-dark: rgb(27 27 27);--uc-foreground-dark: rgb(225 225 225);--uc-primary-foreground-dark: rgb(0 0 0);--uc-secondary-dark: rgb(225 225 225 / 7%);--uc-secondary-hover-dark: rgb(225 225 225 / 10%);--uc-secondary-foreground-dark: rgb(225 225 225);--uc-muted-dark: rgb(36 36 36);--uc-muted-foreground-dark: rgb(152 152 152);--uc-destructive-dark: rgb(244 90 79 / 10%);--uc-destructive-foreground-dark: rgb(244 90 79);--uc-border-dark: rgb(61 61 61);--uc-dialog-shadow-dark: 0px 6px 20px rgb(0 0 0 / 25%);--uc-simple-btn-dark: rgb(36 36 36);--uc-simple-btn-hover-dark: rgb(43 43 43);--uc-simple-btn-foreground-dark: rgb(255 255 255)}}@supports (color: oklch(0% 0 0)){:where([uc-wgt-common]){--uc-primary-oklch-light: 47% .22 264;--uc-primary-light: oklch(var(--uc-primary-oklch-light));--uc-primary-hover-light: oklch(var(--uc-primary-oklch-light) / 90%);--uc-primary-transparent-light: oklch(var(--uc-primary-oklch-light) / 7%);--uc-background-light: oklch(100% 0 0);--uc-foreground-light: oklch(21% 0 0);--uc-primary-foreground-light: oklch(100% 0 0);--uc-secondary-light: oklch(21% 0 0 / .05);--uc-secondary-hover-light: oklch(21% 0 0 / .08);--uc-secondary-foreground-light: oklch(21% 0 0);--uc-muted-light: oklch(97% 0 0);--uc-muted-foreground-light: oklch(40% 0 0);--uc-destructive-light: oklch(59% .235 28.5 / .05);--uc-destructive-foreground-light: oklch(59% .235 28.5);--uc-border-light: oklch(92% 0 0);--uc-dialog-shadow-light: 0px 6px 20px oklch(0% 0 0 / .1);
9957--uc-simple-btn-light: oklch(94% 0 0);--uc-simple-btn-hover-light: oklch(92% 0 0);--uc-simple-btn-foreground-light: oklch(20% 0 0);--uc-primary-oklch-dark: 69% .1768 258.4;--uc-primary-dark: oklch(var(--uc-primary-oklch-dark));--uc-primary-hover-dark: oklch(var(--uc-primary-oklch-dark) / 90%);--uc-primary-transparent-dark: oklch(var(--uc-primary-oklch-dark) / 7%);--uc-background-dark: oklch(22% 0 0);--uc-foreground-dark: oklch(91% 0 0);--uc-primary-foreground-dark: oklch(0% 0 0);--uc-secondary-dark: oklch(91% 0 0 / .07);--uc-secondary-hover-dark: oklch(91% 0 0 / .1);--uc-secondary-foreground-dark: oklch(91% 0 0);--uc-muted-dark: oklch(26% 0 0);--uc-muted-foreground-dark: oklch(68% 0 0);--uc-destructive-dark: oklch(67% .191 27.5 / .1);--uc-destructive-foreground-dark: oklch(67% .191 27.5);--uc-border-dark: oklch(36% 0 0);--uc-dialog-shadow-dark: 0px 6px 20px oklch(0% 0 0 / .25);--uc-simple-btn-dark: oklch(26% 0 0);--uc-simple-btn-hover-dark: oklch(29% 0 0);--uc-simple-btn-foreground-dark: oklch(100% 0 0)}}@media only screen and (max-height:600px){:where([uc-wgt-common]){--uc-dialog-max-height: 100%}}@media only screen and (max-width:430px){:where([uc-wgt-common]){--uc-dialog-max-width: 100vw;--uc-dialog-max-height: var(--uploadcare-blocks-window-height)}}@media(prefers-color-scheme:light){:where([uc-wgt-common]){--uc-background: var(--uc-background-light);--uc-foreground: var(--uc-foreground-light);--uc-primary: var(--uc-primary-light);--uc-primary-hover: var(--uc-primary-hover-light);--uc-primary-transparent: var(--uc-primary-transparent-light);--uc-primary-foreground: var(--uc-primary-foreground-light);--uc-secondary: var(--uc-secondary-light);--uc-secondary-hover: var(--uc-secondary-hover-light);--uc-secondary-foreground: var(--uc-secondary-foreground-light);--uc-muted: var(--uc-muted-light);--uc-muted-foreground: var(--uc-muted-foreground-light);--uc-destructive: var(--uc-destructive-light);--uc-destructive-foreground: var(--uc-destructive-foreground-light);--uc-border: var(--uc-border-light);--uc-dialog-shadow: var(--uc-dialog-shadow-light);--uc-simple-btn: var(--uc-simple-btn-light);--uc-simple-btn-hover: var(--uc-simple-btn-hover-light);--uc-simple-btn-foreground: var(--uc-simple-btn-foreground-light)}}@media(prefers-color-scheme:dark){:where([uc-wgt-common]){--uc-background: var(--uc-background-dark);--uc-foreground: var(--uc-foreground-dark);--uc-primary: var(--uc-primary-dark);--uc-primary-hover: var(--uc-primary-hover-dark);--uc-primary-transparent: var(--uc-primary-transparent-dark);--uc-primary-foreground: var(--uc-primary-foreground-dark);--uc-secondary: var(--uc-secondary-dark);--uc-secondary-hover: var(--uc-secondary-hover-dark);--uc-secondary-foreground: var(--uc-secondary-foreground-dark);--uc-muted: var(--uc-muted-dark);--uc-muted-foreground: var(--uc-muted-foreground-dark);--uc-destructive: var(--uc-destructive-dark);--uc-destructive-foreground: var(--uc-destructive-foreground-dark);--uc-border: var(--uc-border-dark);--uc-dialog-shadow: var(--uc-dialog-shadow-dark);--uc-simple-btn: var(--uc-simple-btn-dark);--uc-simple-btn-hover: var(--uc-simple-btn-hover-dark);--uc-simple-btn-foreground: var(--uc-simple-btn-foreground-dark)}}:where(.uc-light){--uc-background: var(--uc-background-light);--uc-foreground: var(--uc-foreground-light);--uc-primary: var(--uc-primary-light);--uc-primary-hover: var(--uc-primary-hover-light);--uc-primary-transparent: var(--uc-primary-transparent-light);--uc-primary-foreground: var(--uc-primary-foreground-light);--uc-secondary: var(--uc-secondary-light);--uc-secondary-hover: var(--uc-secondary-hover-light);--uc-secondary-foreground: var(--uc-secondary-foreground-light);--uc-muted: var(--uc-muted-light);--uc-muted-foreground: var(--uc-muted-foreground-light);--uc-destructive: var(--uc-destructive-light);--uc-destructive-foreground: var(--uc-destructive-foreground-light);--uc-border: var(--uc-border-light);--uc-dialog-shadow: var(--uc-dialog-shadow-light);--uc-simple-btn: var(--uc-simple-btn-light);--uc-simple-btn-hover: var(--uc-simple-btn-hover-light);--uc-simple-btn-foreground: var(--uc-simple-btn-foreground-light)}:where(.uc-dark){--uc-background: var(--uc-background-dark);--uc-foreground: var(--uc-foreground-dark);--uc-primary: var(--uc-primary-dark);--uc-primary-hover: var(--uc-primary-hover-dark);--uc-primary-transparent: var(--uc-primary-transparent-dark);--uc-primary-foreground: var(--uc-primary-foreground-dark);--uc-secondary: var(--uc-secondary-dark);--uc-secondary-hover: var(--uc-secondary-hover-dark);--uc-secondary-foreground: var(--uc-secondary-foreground-dark);--uc-muted: var(--uc-muted-dark);--uc-muted-foreground: var(--uc-muted-foreground-dark);--uc-destructive: var(--uc-destructive-dark);--uc-destructive-foreground: var(--uc-destructive-foreground-dark);--uc-border: var(--uc-border-dark);--uc-dialog-shadow: var(--uc-dialog-shadow-dark);--uc-simple-btn: var(--uc-simple-btn-dark);--uc-simple-btn-hover: var(--uc-simple-btn-hover-dark);--uc-simple-btn-foreground: var(--uc-simple-btn-foreground-dark)}:where(.uc-purple){--uc-primary-oklch-light: 47% .22 300;--uc-primary-oklch-dark: 69% .1768 300}:where(.uc-red){--uc-primary-oklch-light: 47% .21 21;--uc-primary-oklch-dark: 71% .1768 21}:where(.uc-orange){--uc-primary-oklch-light: 47% .1376 51.88;--uc-primary-oklch-dark: 69% .1768 51.88}:where(.uc-green){--uc-primary-oklch-light: 45% .14 130;--uc-primary-oklch-dark: 69% .1768 130}:where(.uc-turquoise){--uc-primary-oklch-light: 45% .0854 174;--uc-primary-oklch-dark: 69% .1768 174}:where(.uc-gray){--uc-primary-oklch-light: 10% 0 0;--uc-primary-oklch-dark: 97% 0 0}:where(.uc-contrast){--uc-border-light: oklch(50% 0 0);--uc-border-dark: oklch(50% 0 0);--uc-muted-light: oklch(98% 0 0);
9957--uc-muted-dark: oklch(16% 0 0);--uc-muted-foreground-light: oklch(20% 0 0);--uc-muted-foreground-dark: oklch(80% 0 0);--uc-background-light: oklch(100% 0 0);--uc-foreground-light: oklch(0% 0 0);--uc-background-dark: oklch(10% 0 0);--uc-foreground-dark: oklch(100% 0 0)}:where([uc-wgt-common]){color:var(--uc-foreground);font-size:var(--uc-font-size);line-height:var(--uc-line-height);font-family:var(--uc-font-family)}:where([uc-wgt-common]) *{box-sizing:border-box}:where([uc-wgt-common]) [hidden]{display:none!important}:where([uc-wgt-common]) [activity]:not([active]){display:none}:where([uc-wgt-common]) dialog:not([open]) [activity]{display:none}:where([uc-wgt-common]) button{display:flex;align-items:center;justify-content:center;height:var(--uc-button-size);padding-right:14px;padding-left:14px;font-size:1em;font-family:inherit;white-space:nowrap;border:none;border-radius:var(--uc-radius);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--uc-transition)}:where([uc-wgt-common]) button.uc-primary-btn{color:var(--uc-primary-foreground);background-color:var(--uc-primary)}:where([uc-wgt-common]) button.uc-primary-btn:hover{background-color:var(--uc-primary-hover)}:where([uc-wgt-common]) button.uc-secondary-btn{color:var(--uc-secondary-foreground);background-color:var(--uc-secondary)}:where([uc-wgt-common]) button.uc-secondary-btn:hover{background-color:var(--uc-secondary-hover)}:where([uc-wgt-common].uc-contrast) button.uc-secondary-btn{border:1px solid var(--uc-border)}:where([uc-wgt-common]) button.uc-mini-btn{height:var(--uc-button-size);padding:0;background-color:transparent;color:var(--uc-secondary-foreground)}:where([uc-wgt-common]) button.uc-mini-btn:hover{background-color:var(--uc-secondary)}:where([uc-wgt-common]) :is(button[disabled],button.uc-primary-btn[disabled],button.uc-secondary-btn[disabled]){opacity:.5;pointer-events:none}:where([uc-wgt-common]) a{color:var(--uc-primary);text-decoration:none}:where([uc-wgt-common]) a[disabled]{pointer-events:none}:where([uc-wgt-common]) input[type=text]{display:flex;width:100%;height:var(--uc-button-size);padding-right:10px;padding-left:10px;color:var(--uc-foreground);font-size:1em;font-family:inherit;background-color:var(--uc-background);border:1px solid var(--uc-border);outline:1px solid transparent;border-radius:var(--uc-radius);transition:border-color var(--uc-transition),outline-color var(--uc-transition)}:where([uc-wgt-common]) input[type=text]::placeholder{color:var(--uc-muted-foreground)}:where([uc-wgt-common]) input[type=text]:focus{outline-color:var(--uc-primary-hover);border-color:var(--uc-primary-hover)}:where([uc-wgt-common]) input[disabled]{opacity:.6;pointer-events:none}:where([uc-wgt-common]) uc-select[disabled],:where([uc-wgt-common]) select[disabled]{opacity:.6;pointer-events:none}uc-icon{display:inline-flex;align-items:center;justify-content:center;width:var(--uc-button-size);height:var(--uc-button-size)}uc-icon svg{width:calc(var(--uc-button-size) / 2);height:calc(var(--uc-button-size) / 2)}uc-range{position:relative;display:inline-flex;align-items:center;justify-content:center;height:var(--uc-button-size)}uc-range datalist{display:none}uc-range input{width:100%;height:100%;opacity:0}uc-range .uc-track-wrapper{position:absolute;right:10px;left:10px;display:flex;align-items:center;justify-content:center;height:2px;-webkit-user-select:none;user-select:none;pointer-events:none}uc-range .uc-track{position:absolute;right:0;left:0;display:flex;align-items:center;justify-content:center;height:2px;background-color:currentColor;border-radius:2px;opacity:.5}uc-range .uc-slider{position:absolute;width:16px;height:16px;background-color:currentColor;border-radius:100%;transform:translate(-50%)}uc-range .uc-bar{position:absolute;left:0;height:100%;background-color:currentColor;border-radius:2px}uc-range .uc-caption{position:absolute;display:inline-flex;justify-content:center}uc-config{display:none}:where([uc-simple-btn]){position:relative;display:inline-flex}:where([uc-simple-btn]) button{height:auto;gap:.5em;padding:var(--uc-simple-btn-padding);background-color:var(--uc-simple-btn);color:var(--uc-simple-btn-foreground);font-size:var(--uc-simple-btn-font-size);font-family:var(--uc-simple-btn-font-family)}:where([uc-simple-btn]) button uc-icon{width:auto;height:auto}:where([uc-simple-btn]) button uc-icon svg{width:.9em;height:.9em}:where([uc-simple-btn]) button:hover{background-color:var(--uc-simple-btn-hover)}:where([uc-simple-btn])>uc-drop-area{display:contents}:where([uc-simple-btn]) .uc-visual-drop-area{position:absolute;top:0;left:0;display:flex;align-items:center;justify-content:center;width:100%;height:100%;padding:var(--uc-simple-btn-padding);background-color:transparent;color:transparent;font-size:var(--uc-simple-btn-font-size);border:1px dashed var(--uc-simple-btn-foreground);border-radius:inherit;opacity:0;transition:opacity var(--uc-transition)}:where([uc-simple-btn])>uc-drop-area[drag-state=active] .uc-visual-drop-area{opacity:1}:where([uc-simple-btn])>uc-drop-area[drag-state=inactive] .uc-visual-drop-area{opacity:0}
9957:where([uc-simple-btn])>uc-drop-area[drag-state=near] .uc-visual-drop-area{opacity:1}:where([uc-simple-btn])>uc-drop-area[drag-state=over] .uc-visual-drop-area{opacity:1}uc-source-btn>button{display:flex;align-items:center;margin-bottom:2px;padding:2px var(--uc-padding);color:var(--uc-foreground);border-radius:var(--uc-radius);cursor:pointer;transition:background-color var(--uc-transition),color var(--uc-transition);-webkit-user-select:none;user-select:none;width:100%;background-color:unset;height:unset}uc-source-btn:last-child>button{margin-bottom:0}uc-source-btn>button:hover{background-color:var(--uc-primary-transparent)}:where(.uc-contrast) uc-source-btn>button:hover{background-color:var(--uc-secondary);color:var(--uc-foreground)}uc-source-btn uc-icon{display:inline-flex;flex-grow:1;justify-content:center;min-width:var(--uc-button-size);margin-right:var(--uc-padding);opacity:.8}:where(.uc-contrast) uc-source-btn uc-icon{opacity:1}uc-source-btn .uc-txt{display:flex;align-items:center;box-sizing:border-box;width:100%;height:var(--uc-button-size);padding:0;white-space:nowrap;border:none}:where([uc-drop-area]){padding:2px;overflow:hidden;border:1px dashed var(--uc-border);border-radius:calc(var(--uc-radius) * 1.75);transition:border var(--uc-transition),border-radius var(--uc-transition)}:where([uc-drop-area]),:where([uc-drop-area]) .uc-content-wrapper{display:flex;align-items:center;justify-content:center;width:100%;height:100%}:where([uc-drop-area]) .uc-text{position:relative;margin:var(--uc-padding);color:var(--uc-muted-foreground);transition:color var(--uc-transition)}:where([uc-drop-area])[ghost][drag-state=inactive]{display:none}:where([uc-drop-area])[ghost]:not([fullscreen]):is([drag-state=active],[drag-state=near],[drag-state=over]){background:var(--uc-background)}:where([uc-drop-area]):is([drag-state=active],[drag-state=near],[drag-state=over],:hover){background:var(--uc-primary-transparent);border-color:var(--uc-primary-transparent)}:where(.uc-contrast) :where([uc-drop-area]):is([drag-state=active],[drag-state=near],[drag-state=over],:hover){color:var(--uc-foreground);background:transparent;border-color:var(--uc-foreground);border-width:2px;border-style:solid}:where([uc-drop-area]):is([drag-state=active],[drag-state=near]){opacity:1}:where([uc-drop-area])[drag-state=over]{border-color:var(--uc-primary);opacity:1}:where([uc-drop-area])[with-icon]{min-height:180px}:where([uc-drop-area])[with-icon] .uc-content-wrapper{display:flex;flex-direction:column}:where([uc-drop-area])[with-icon] .uc-text{color:var(--uc-foreground);font-weight:500;font-size:1.1em}:where([uc-drop-area])[with-icon] .uc-icon-container{position:relative;width:64px;height:64px;margin:var(--uc-padding);overflow:hidden;color:var(--uc-foreground);background-color:var(--uc-muted);border-radius:50%;transition:color var(--uc-transition),background-color var(--uc-transition)}:where([uc-drop-area])[with-icon] uc-icon{position:absolute;width:32px;height:32px;top:calc(50% - 16px);left:calc(50% - 16px);transition:transform var(--uc-transition)}:where([uc-drop-area])[with-icon] uc-icon:last-child{transform:translateY(48px)}:where(.uc-contrast) :where([uc-drop-area])[with-icon]:hover .uc-icon-container,:where(.uc-contrast) :where([uc-drop-area])[with-icon]:hover .uc-text{color:var(--uc-foreground)}:where([uc-drop-area])[with-icon]:hover .uc-icon-container{background-color:var(--uc-primary-transparent)}:where(.uc-contrast) :where([uc-drop-area])[with-icon]:hover .uc-icon-container{background-color:var(--uc-muted)}:where([uc-drop-area])[with-icon]>.uc-content-wrapper:is([drag-state=active],[drag-state=near],[drag-state=over]) .uc-icon-container{color:var(--uc-primary-foreground);background-color:var(--uc-primary)}:where([uc-drop-area])[with-icon]>.uc-content-wrapper:is([drag-state=active],[drag-state=near],[drag-state=over]) .uc-text{color:var(--uc-foreground)}:where(.uc-contrast) :where([uc-drop-area])[with-icon]>.uc-content-wrapper:is([drag-state=active],[drag-state=near],[drag-state=over]) .uc-text{color:var(--uc-foreground)}:where([uc-drop-area])[with-icon]>.uc-content-wrapper:is([drag-state=active],[drag-state=near],[drag-state=over]) uc-icon:first-child{transform:translateY(-48px)}
9957:where([uc-drop-area])[with-icon]>.uc-content-wrapper:is([drag-state=active],[drag-state=near],[drag-state=over]) uc-icon:last-child{transform:translateY(0)}:where([uc-drop-area])[with-icon]>.uc-content-wrapper[drag-state=near] uc-icon:last-child{transform:scale(1.3)}:where([uc-drop-area])[with-icon]>.uc-content-wrapper[drag-state=over] uc-icon:last-child{transform:scale(1.5)}:where([uc-drop-area])[fullscreen]{position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;width:calc(100vw - var(--uc-padding) * 2);height:calc(100vh - var(--uc-padding) * 2);margin:var(--uc-padding)}:where([uc-drop-area])[fullscreen] .uc-content-wrapper{width:100%;max-width:calc(var(--uc-dialog-width) * .8);height:180px;color:var(--uc-foreground);background-color:var(--uc-background);border-radius:calc(var(--uc-radius) * 1.75);box-shadow:var(--uc-dialog-shadow);transition:color var(--uc-transition),background-color var(--uc-transition),box-shadow var(--uc-transition),border-radius var(--uc-transition),transform var(--uc-transition)}:where([uc-drop-area])[with-icon][fullscreen][drag-state=active]>.uc-content-wrapper,:where([uc-drop-area])[with-icon][fullscreen][drag-state=near]>.uc-content-wrapper{transform:translateY(10px);opacity:0}:where([uc-drop-area])[with-icon][fullscreen][drag-state=over]>.uc-content-wrapper{transform:translateY(0);opacity:1}:is(:where([uc-drop-area])[with-icon][fullscreen])>.uc-content-wrapper uc-icon:first-child{transform:translateY(-48px)}:where([uc-drop-area])[clickable]{cursor:pointer}@supports selector(dialog::backdrop){:where([uc-modal])>dialog::backdrop{background-color:#0000001a}:where([uc-modal])[strokes]>dialog::backdrop{background-image:var(--modal-backdrop-background-image)}}:where([uc-modal])>dialog[open]{transform:translateY(0);visibility:visible;opacity:1}:where([uc-modal])>dialog:not([open]){transform:translateY(20px);visibility:hidden;opacity:0}:where([uc-modal])>dialog{display:flex;flex-direction:column;width:min(var(--uc-dialog-width),100%);max-width:min(calc(100% - var(--uc-padding) * 2),var(--uc-dialog-max-width));min-height:var(--uc-button-size);max-height:min(calc(100% - var(--uc-padding) * 2),var(--uc-dialog-max-height));margin:auto;padding:0;overflow:hidden;background-color:var(--uc-background);border:0;border-radius:calc(var(--uc-radius) * 1.75);box-shadow:var(--uc-dialog-shadow);transition:transform .4s ease,opacity .4s ease}:where(.uc-contrast) :where([uc-modal])>dialog{outline:1px solid var(--uc-border)}uc-url-source{display:block;background-color:var(--uc-background)}uc-url-source>.uc-content{display:grid;grid-gap:4px;grid-template-columns:1fr min-content;padding:var(--uc-padding);padding-top:0}uc-url-source .uc-url-input{display:flex}uc-camera-source{position:relative;display:flex;flex-direction:column;width:100%;height:100%;max-height:100%;overflow:hidden;background-color:var(--uc-background);border-radius:var(--uc-radius)}[uc-modal]>dialog:has(uc-camera-source[active]){width:100%;height:100%}uc-camera-source:not(.uc-initialized) .uc-controls{display:none}uc-camera-source video{display:block;width:100%;max-height:100%;object-fit:contain;object-position:center center;background-color:var(--uc-muted);border-radius:var(--uc-radius)}uc-camera-source .uc-toolbar{position:absolute;bottom:0;display:flex;justify-content:space-between;width:100%;padding:var(--uc-padding);background-color:var(--uc-background)}uc-camera-source .uc-content{display:flex;flex:1;justify-content:center;width:100%;height:100%;padding:var(--uc-padding);padding-top:0;overflow:hidden}uc-camera-source .uc-message-box{display:flex;flex-direction:column;grid-gap:40px;align-items:center;justify-content:center;padding:40px 40px 0;color:var(--uc-foreground)}uc-camera-source .uc-message-box button{color:var(--uc-primary-foreground);background-color:var(--uc-primary)}uc-camera-source .uc-shot-btn{width:58px;height:58px;color:var(--uc-background);background-color:var(--uc-primary-light);border-radius:50%;opacity:.85;transition:bottom var(--uc-transition),opacity var(--uc-transition),transform var(--uc-transition)}uc-camera-source .uc-shot-btn:hover{transform:scale(1.05);opacity:1}uc-camera-source .uc-shot-btn:active{transform:scale(1);opacity:1}uc-camera-source .uc-shot-btn[disabled]{bottom:-80px}uc-camera-source .uc-shot-btn uc-icon svg{width:20px;height:20px}uc-camera-source .uc-controls{position:relative;display:flex;align-items:center;flex-wrap:wrap;justify-content:space-between;padding:0 var(--uc-padding) var(--uc-padding);min-height:74px}uc-camera-source .uc-switcher{display:flex}uc-camera-source .uc-switch.uc-active{background-color:var(--uc-secondary)}uc-camera-source .uc-camera-actions{display:flex;justify-content:center;align-items:center;gap:5px}uc-camera-source .uc-stop-record{background-color:var(--uc-destructive-foreground-light);opacity:1}:where(uc-camera-source:is(.uc-recording)) .uc-recording-timer uc-icon{display:none}:where(uc-camera-source:is(.uc-recording)) .uc-recording-timer{pointer-events:none}uc-camera-source .uc-recording-timer{z-index:1;position:relative;overflow:hidden}:where(uc-camera-source) .uc-recording-timer uc-icon{width:10px;height:10px;margin-right:10px}uc-camera-source .uc-recording-timer .uc-line{position:absolute;content:"";bottom:0;left:0;right:0;height:2px;background-color:var(--uc-foreground-light);
9957transform:scaleX(0);transform-origin:left;transition:transform var(--uc-transition)}uc-camera-source .uc-btn-microphone{z-index:1}uc-camera-source .uc-select{display:flex}uc-camera-source .uc-audio-select{width:98px}uc-camera-source .uc-audio-select select{width:100%}uc-camera-source .uc-camera-action{position:absolute;inset:0 var(--uc-padding) var(--uc-padding);margin:0 auto}uc-external-source{display:flex;flex-direction:column;width:100%;height:100%;background-color:var(--uc-background);overflow:hidden;position:relative}[uc-modal]>dialog:has(uc-external-source[active]){width:100%;height:100%}uc-external-source>.uc-content{position:relative;display:grid;flex:1;grid-template-rows:1fr min-content}uc-external-source iframe{display:block;width:100%;height:100%;border:none}uc-external-source .uc-iframe-wrapper{overflow:hidden}uc-external-source .uc-toolbar{display:flex;width:100%;grid-gap:var(--uc-padding);align-items:center;justify-content:space-between;padding:var(--uc-padding);border-top:1px solid var(--uc-border)}uc-external-source .uc-back-btn{padding-left:0}uc-external-source .uc-selection-status-box{color:var(--uc-foreground);display:flex;flex-direction:column;align-items:center;justify-content:center}uc-external-source .uc-selection-status-box button{color:var(--uc-primary);height:auto;padding:0;background:none}uc-external-source .uc-selection-status-box button:hover{text-decoration:underline}uc-external-source uc-activity-header{position:absolute;width:100%;justify-content:flex-end;z-index:1;left:0;top:0;right:0;pointer-events:none}uc-external-source uc-activity-header .uc-close-btn{pointer-events:auto}uc-external-source .uc-done-btn>span.uc-hidden{visibility:hidden;pointer-events:none}uc-external-source .uc-done-btn>uc-spinner{position:absolute;width:100%;height:100%;display:flex;align-items:center;justify-content:center}uc-upload-list{display:flex;flex-direction:column;width:100%;height:max-content;overflow:hidden;background-color:var(--uc-background);transition:opacity var(--uc-transition)}uc-upload-list .uc-no-files{height:32px;padding:20px}uc-upload-list .uc-files{display:block;flex:1;min-height:32px;padding:0 var(--uc-padding);overflow:auto}uc-upload-list .uc-toolbar{display:flex;gap:4px;justify-content:space-between;padding:var(--uc-padding);background-color:var(--uc-background)}uc-upload-list .uc-toolbar-spacer{flex:1}uc-upload-list uc-drop-area{position:absolute;top:0;left:0;width:calc(100% - var(--uc-padding) * 2);height:calc(100% - var(--uc-padding) * 2);margin:var(--uc-padding);border-radius:var(--uc-radius)}uc-upload-list uc-activity-header>.uc-header-text{padding:0 var(--uc-padding)}uc-upload-list .uc-common-error{border-radius:var(--uc-radius);color:var(--uc-destructive-foreground);background-color:var(--uc-destructive);display:flex;align-items:center;justify-content:center;padding:var(--uc-padding);margin:4px var(--uc-padding) 0 var(--uc-padding);font-size:.925em}uc-upload-list .uc-add-more-btn uc-icon{display:none}uc-start-from{display:block;overflow-y:auto}uc-start-from .uc-content{display:grid;grid-auto-flow:row;gap:calc(var(--uc-padding) * 2);width:100%;height:100%;padding:calc(var(--uc-padding) * 2);background-color:var(--uc-background)}[uc-modal]>dialog:has(uc-start-from[active]){width:var(--uc-dialog-width)}[uc-modal] uc-start-from uc-drop-area{border-radius:var(--uc-radius)}@media only screen and (max-width:430px){[uc-modal] uc-start-from uc-drop-area{display:none}}uc-file-item{--uc-file-item-gap: 4px;--uc-file-item-height: calc(var(--uc-preview-size) + var(--uc-padding) * 2 + var(--uc-file-item-gap));display:block;overflow:hidden;min-height:var(--uc-file-item-height)}uc-file-item:last-of-type{--uc-file-item-gap: 0}uc-file-item>.uc-inner{position:relative;display:grid;grid-template-columns:var(--uc-preview-size) 1fr max-content;gap:2px;align-items:center;margin-bottom:var(--uc-file-item-gap);padding:var(--uc-padding);overflow:hidden;font-size:.925em;background-color:var(--uc-muted);border-radius:var(--uc-radius);transition:background-color var(--uc-transition)}uc-file-item>.uc-inner[focused]{background-color:transparent}uc-file-item>.uc-inner[uploading] .uc-edit-btn{display:none}uc-file-item>:where(.uc-inner[failed],.uc-inner[limit-overflow]){background-color:var(--uc-destructive)}uc-file-item .uc-thumb{position:relative;display:inline-flex;width:var(--uc-preview-size);height:var(--uc-preview-size);background-color:var(--uc-secondary);background-position:center center;background-size:cover;border-radius:var(--uc-radius)}uc-file-item .uc-file-name-wrapper{text-align:left;display:flex;flex-direction:column;align-items:flex-start;justify-content:center;max-width:100%;padding-right:var(--uc-padding);padding-left:var(--uc-padding);overflow:hidden;color:var(--uc-muted-foreground)}uc-file-item .uc-file-name{max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}uc-file-item .uc-file-error{display:none;color:var(--uc-destructive-foreground);font-size:.85em}uc-file-item button.uc-remove-btn,uc-file-item button.uc-edit-btn{color:var(--uc-muted-foreground)}uc-file-item button svg{pointer-events:none}uc-file-item button.uc-upload-btn{display:none}uc-file-item .uc-badge{position:absolute;bottom:2px;right:2px;width:14px;
9957height:14px;color:var(--uc-background);background-color:var(--uc-foreground);border-radius:50%;transform:scale(.3);opacity:0;transition:opacity var(--uc-transition),transform var(--uc-transition);display:flex;justify-content:center;align-items:center}uc-file-item>.uc-inner:where([failed],[limit-overflow],[finished]) .uc-badge{transform:scale(1);opacity:1}uc-file-item>.uc-inner:where([failed],[limit-overflow]) .uc-badge{background-color:var(--uc-destructive-foreground)}uc-file-item>.uc-inner:where([failed],[limit-overflow]) .uc-file-error{display:block}uc-file-item .uc-badge uc-icon,uc-file-item .uc-badge uc-icon svg{width:100%;height:100%}uc-file-item .uc-progress-bar{opacity:.7;top:calc(100% - 2px);height:2px}:where(.uc-contrast) uc-file-item .uc-progress-bar{opacity:1}uc-file-item .uc-file-actions{display:flex;gap:2px;align-items:center;justify-content:center}uc-progress-bar-common{position:fixed;right:0;bottom:0;left:0;z-index:10000;display:block;height:10px;background-color:var(--uc-background);transition:opacity .3s}uc-progress-bar-common:not([active]){opacity:0;pointer-events:none}uc-progress-bar{position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none}uc-progress-bar .uc-progress{width:calc(var(--l-width) * 1%);height:100%;background-color:var(--uc-primary);transform:translate(0);opacity:1;transition:width .6s,opacity .3s}uc-progress-bar .uc-progress--hidden{opacity:0}
9957uc-activity-header{display:flex;justify-content:space-between;gap:var(--uc-padding);padding:var(--uc-padding);color:var(--uc-foreground);font-weight:500;font-size:1em}uc-activity-header>*{display:flex;align-items:center}uc-copyright{display:flex;width:100%;justify-content:center}uc-copyright .uc-credits{all:unset;position:absolute;bottom:12px;background-color:var(--uc-background);padding:2px 5px;border-radius:6px;color:var(--uc-muted-foreground);font-weight:400;font-size:12px;opacity:.9;cursor:pointer;transition:opacity var(--uc-transition),background-color var(--uc-transition)}uc-copyright .uc-credits:focus-visible{outline:1px auto -webkit-focus-ring-color}uc-copyright .uc-credits:hover{opacity:1;background-color:var(--uc-muted)}[uc-cloud-image-editor]{--color-primary-accent: var(--uc-primary);--color-text-base: var(--uc-foreground);--color-text-accent-contrast: var(--uc-background);--color-fill-contrast: var(--uc-background);--color-modal-backdrop: oklch(0 0 0 / .1);--color-image-background: var(--uc-muted);--color-focus-ring: var(--color-primary-accent);--color-crop-guides: var(--uc-foreground);--font-size-ui: var(--uc-font-size);--size-touch-area: var(--uc-button-size);--size-panel-heading: calc(var(--uc-button-size) + var(--uc-padding) * 2);--size-ui-min-width: 130px;--size-line-width: 1px;--size-modal-width: 650px;--size-icon: calc(var(--uc-button-size) / 2);--border-radius-editor: var(--uc-radius);--border-radius-thumb: var(--uc-radius);--border-radius-ui: var(--uc-radius);--border-radius-base: var(--uc-radius);--cldtr-gap-min: 5px;--cldtr-gap-mid-1: 10px;--cldtr-gap-mid-2: 15px;--cldtr-gap-max: 20px;--transition-duration-2: var(--transition-duration-all, .2s);--transition-duration-3: var(--transition-duration-all, .3s);--transition-duration-4: var(--transition-duration-all, .4s);--transition-duration-5: var(--transition-duration-all, .5s);--modal-header-opacity: 1;--modal-header-height: var(--size-panel-heading);--modal-toolbar-height: var(--size-panel-heading);--transparent-pixel: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=);display:block;width:100%;height:100%;max-height:100%}[uc-cloud-image-editor] :is([can-handle-paste]:hover,[can-handle-paste]:focus){--can-handle-paste: "true"}[uc-cloud-image-editor] :is([tabindex][focus-visible],[tabindex]:hover,[with-effects][focus-visible],[with-effects]:hover){--filter-effect: var(--hover-filter) !important;--opacity-effect: var(--hover-opacity) !important;--color-effect: var(--hover-color-rgb) !important;--background-effect: var(--hover-background) !important}[uc-cloud-image-editor] :is([tabindex]:active,[with-effects]:active){--filter-effect: var(--down-filter) !important;--opacity-effect: var(--down-opacity) !important;--color-effect: var(--down-color-rgb) !important;--background-effect: var(--down-background) !important}[uc-cloud-image-editor] :is([tabindex][active],[with-effects][active]){--filter-effect: var(--active-filter) !important;--opacity-effect: var(--active-opacity) !important;--color-effect: var(--active-color-rgb) !important;--background-effect: var(--active-background) !important}[uc-cloud-image-editor] [hidden-scrollbar]::-webkit-scrollbar{display:none}[uc-cloud-image-editor] [hidden-scrollbar]{-ms-overflow-style:none;scrollbar-width:none}[uc-cloud-image-editor].uc-editor_ON{--modal-header-opacity: 0;--modal-header-height: 0px;--modal-toolbar-height: calc(var(--size-panel-heading) * 2)}[uc-cloud-image-editor].uc-editor_OFF{--modal-header-opacity: 1;--modal-header-height: var(--size-panel-heading);--modal-toolbar-height: var(--size-panel-heading)}[uc-cloud-image-editor]>.uc-wrapper{--l-min-img-height: var(--modal-toolbar-height);--l-max-img-height: 100%;--l-edit-button-width: 120px;--l-toolbar-horizontal-padding: var(--cldtr-gap-mid-1);position:relative;display:grid;grid-template-rows:minmax(var(--l-min-img-height),var(--l-max-img-height)) minmax(var(--modal-toolbar-height),auto);height:100%;overflow:hidden;overflow-y:auto}@media only screen and (max-width:800px){[uc-cloud-image-editor]>.uc-wrapper{--l-edit-button-width: 70px;--l-toolbar-horizontal-padding: var(--cldtr-gap-min)}}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport{display:flex;align-items:center;justify-content:center;overflow:hidden}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-image_container>.uc-image{--viewer-image-opacity: 1;position:absolute;top:0;left:0;z-index:10;display:block;box-sizing:border-box;width:100%;height:100%;object-fit:scale-down;background-color:var(--color-image-background);transform:scale(1);opacity:var(--viewer-image-opacity);-webkit-user-select:none;user-select:none;pointer-events:auto}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-image_container>.uc-image.uc-image_visible_viewer{transition:opacity var(--transition-duration-3) ease-in-out,transform var(--transition-duration-4)}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-image_container>.uc-image.uc-image_hidden_to_cropper{--viewer-image-opacity: 0;background-image:var(--transparent-pixel);transform:scale(1);transition:transform var(--transition-duration-4),opacity var(--transition-duration-3) steps(1,jump-end);pointer-events:none}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-image_container>.uc-image.uc-image_hidden_effects{--viewer-image-opacity: 0;transform:scale(1);transition:opacity var(--transition-duration-3) cubic-bezier(.5,0,1,1),transform var(--transition-duration-4);pointer-events:none}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-image_container{position:relative;display:block;width:100%;height:100%;background-color:var(--color-image-background);transition:var(--transition-duration-3)}[uc-cloud-image-editor]>.uc-wrapper>.uc-toolbar{position:relative;transition:.3s}[uc-cloud-image-editor]>.uc-wrapper>.uc-toolbar>.uc-toolbar_content{position:absolute;bottom:0;left:0;box-sizing:border-box;width:100%;height:var(--modal-toolbar-height);min-height:var(--size-panel-heading);background-color:var(--color-fill-contrast)}[uc-cloud-image-editor]>.uc-wrapper>.uc-toolbar>.uc-toolbar_content.uc-toolbar_content__viewer{display:flex;align-items:center;justify-content:space-between;
9957height:var(--size-panel-heading);padding-right:var(--l-toolbar-horizontal-padding);padding-left:var(--l-toolbar-horizontal-padding)}[uc-cloud-image-editor]>.uc-wrapper>.uc-toolbar>.uc-toolbar_content.uc-toolbar_content__editor{display:flex}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-info_pan{position:absolute;-webkit-user-select:none;user-select:none}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-file_type_outer{position:absolute;z-index:2;display:flex;max-width:120px;transform:translate(-40px);-webkit-user-select:none;user-select:none}[uc-cloud-image-editor]>.uc-wrapper>.uc-viewport>.uc-file_type_outer>.uc-file_type{padding:4px .8em}[uc-cloud-image-editor]>.uc-wrapper>.uc-network_problems_splash{position:absolute;z-index:4;display:flex;flex-direction:column;width:100%;height:100%;background-color:var(--color-fill-contrast)}[uc-cloud-image-editor]>.uc-wrapper>.uc-network_problems_splash>.uc-network_problems_content{display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center}[uc-cloud-image-editor]>.uc-wrapper>.uc-network_problems_splash>.uc-network_problems_content>.uc-network_problems_icon{display:flex;align-items:center;justify-content:center;width:40px;height:40px;color:var(--uc-foreground);background-color:var(--uc-muted);border-radius:50%}[uc-cloud-image-editor]>.uc-wrapper>.uc-network_problems_splash>.uc-network_problems_content>.uc-network_problems_text{margin-top:var(--cldtr-gap-max);font-size:var(--font-size-ui);color:var(--uc-foreground)}[uc-cloud-image-editor]>.uc-wrapper>.uc-network_problems_splash>.uc-network_problems_footer{display:flex;align-items:center;justify-content:center;height:var(--size-panel-heading)}uc-crop-frame>.uc-svg{position:absolute;top:0;left:0;z-index:2;width:100%;height:100%;border-top-left-radius:var(--border-radius-base);border-top-right-radius:var(--border-radius-base);opacity:inherit;transition:var(--transition-duration-3)}uc-crop-frame>.uc-thumb{--idle-color-rgb: var(--color-text-base);--hover-color-rgb: var(--color-primary-accent);--focus-color-rgb: var(--color-primary-accent);--down-color-rgb: var(--color-primary-accent);--color-effect: var(--idle-color-rgb);color:var(--color-effect);transition:color var(--transition-duration-3),opacity var(--transition-duration-3)}uc-crop-frame>.uc-thumb--visible{opacity:1;pointer-events:auto}uc-crop-frame>.uc-thumb--hidden{opacity:0;pointer-events:none}uc-crop-frame>.uc-guides{transition:var(--transition-duration-3)}uc-crop-frame>.uc-guides--hidden{opacity:0}
9957uc-crop-frame>.uc-guides--semi-hidden{opacity:.2}uc-crop-frame>.uc-guides--visible{opacity:1}uc-editor-button-control,uc-editor-crop-button-control,uc-editor-filter-control,uc-editor-operation-control{--l-base-min-width: var(--uc-button-size);--l-base-height: var(--uc-button-size);--opacity-effect: var(--idle-opacity);--color-effect: var(--idle-color-rgb);--background-effect: var(--idle-background);--filter-effect: var(--idle-filter);--idle-color-rgb: var(--uc-secondary-foreground);--idle-opacity: 1;--idle-filter: 1;--idle-background: var(--uc-secondary);--hover-color-rgb: var(--uc-secondary-foreground);--hover-opacity: 1;--hover-filter: .8;--hover-background: var(--uc-secondary-hover);--down-color-rgb: var(--hover-color-rgb);--down-opacity: 1;--down-filter: .6;--down-background: var(--uc-secondary);border-radius:var(--uc-radius)}uc-editor-button-control>button,uc-editor-crop-button-control>button,uc-editor-filter-control>button,uc-editor-operation-control>button{all:unset;position:relative;display:grid;grid-template-columns:var(--l-base-min-width) auto;grid-template-rows:100%;align-items:center;height:var(--l-base-height);color:var(--color-effect);opacity:var(--opacity-effect);outline:none;cursor:pointer;transition:var(--l-width-transition)}:where(uc-editor-button-control,uc-editor-crop-button-control,uc-editor-filter-control,uc-editor-operation-control)>uc-icon>svg{width:var(--size-icon);height:var(--size-icon)}uc-editor-filter-control>uc-icon.uc-original-icon>svg{width:100%;height:100%}uc-editor-button-control.uc-active,uc-editor-operation-control.uc-active,uc-editor-crop-button-control.uc-active,uc-editor-filter-control.uc-active{--idle-color-rgb: var(--uc-primary-foreground);--idle-background: var(--uc-primary);--idle-opacity: 1;--hover-color-rgb: var(--uc-primary-foreground);--hover-background: var(--uc-primary);--hover-opacity: 1}uc-editor-filter-control.uc-not_active .uc-preview[loaded]{opacity:1}uc-editor-filter-control.uc-active .uc-preview{opacity:0}
9957uc-editor-button-control.uc-not_active,uc-editor-operation-control.uc-not_active,uc-editor-crop-button-control.uc-not_active,uc-editor-filter-control.uc-not_active{--idle-color-rgb: var(--uc-secondary-foreground)}:where(.uc-contrast) uc-editor-button-control.uc-not_active,:where(.uc-contrast) uc-editor-operation-control.uc-not_active,:where(.uc-contrast) uc-editor-crop-button-control.uc-not_active,:where(.uc-contrast) uc-editor-filter-control.uc-not_active{--idle-background: transparent;--hover-background: var(--uc-secondary);outline:1px solid var(--uc-border);outline-offset:-1px}uc-editor-button-control>button:before,uc-editor-operation-control>button:before,uc-editor-crop-button-control>button:before,uc-editor-filter-control>button:before{position:absolute;content:"";right:0;left:0;z-index:-1;width:100%;height:100%;background-color:var(--background-effect);border-radius:var(--border-radius-editor);transition:var(--transition-duration-3)}uc-editor-button-control>button .uc-title,uc-editor-operation-control>button .uc-title,uc-editor-crop-button-control>button .uc-title,uc-editor-filter-control>button .uc-title{padding-right:var(--cldtr-gap-mid-1);font-size:.7em;letter-spacing:1.004px;text-transform:uppercase}uc-editor-button-control>button uc-icon,uc-editor-operation-control>button uc-icon,uc-editor-crop-button-control>button uc-icon,uc-editor-filter-control>button uc-icon{pointer-events:none}uc-editor-filter-control>button .uc-preview{position:absolute;right:0;left:0;z-index:-1;width:100%;height:var(--l-base-height);background-repeat:no-repeat;background-size:contain;border-radius:var(--border-radius-editor);opacity:0;filter:brightness(var(--filter-effect));transition:var(--transition-duration-3)}uc-editor-filter-control>.uc-original-icon{color:var(--color-effect);opacity:.3}uc-editor-image-cropper{position:absolute;top:0;left:0;z-index:10;display:block;width:100%;height:100%;opacity:0;pointer-events:none;touch-action:none;color:var(--color-crop-guides)}uc-editor-image-cropper.uc-active_from_editor{transform:scale(1) translate(0);opacity:1;transition:transform var(--transition-duration-4) cubic-bezier(.37,0,.63,1) .4s,opacity var(--transition-duration-3);pointer-events:auto}uc-editor-image-cropper.uc-active_from_viewer{transform:scale(1) translate(0);opacity:1;transition:transform var(--transition-duration-4) cubic-bezier(.37,0,.63,1) .4s,opacity var(--transition-duration-3);pointer-events:auto}uc-editor-image-cropper.uc-inactive_to_editor{opacity:0;transition:transform var(--transition-duration-4) cubic-bezier(.37,0,.63,1),opacity var(--transition-duration-3) calc(var(--transition-duration-3) + .05s);pointer-events:none}uc-editor-image-cropper>.uc-canvas{position:absolute;top:0;left:0;z-index:1;display:block;width:100%;height:100%}uc-editor-image-fader{position:absolute;top:0;left:0;display:block;width:100%;height:100%}uc-editor-image-fader.uc-active_from_viewer{z-index:3;transform:scale(1);opacity:1;transition:transform var(--transition-duration-4),opacity var(--transition-duration-3) steps(1,jump-start);pointer-events:auto}uc-editor-image-fader.uc-active_from_cropper{z-index:3;transform:scale(1);opacity:1;transition:transform var(--transition-duration-4),opacity var(--transition-duration-3) steps(1,jump-end);pointer-events:auto}uc-editor-image-fader.uc-inactive_to_cropper{z-index:3;transform:scale(1);opacity:0;transition:transform var(--transition-duration-4),opacity var(--transition-duration-3) steps(1,jump-end);pointer-events:none}uc-editor-image-fader .uc-fader-image{position:absolute;top:0;left:0;display:block;width:100%;height:100%;object-fit:scale-down;transform:scale(1);-webkit-user-select:none;user-select:none;content-visibility:auto}uc-editor-image-fader .uc-fader-image--preview{background-color:var(--color-image-background);border-top-left-radius:var(--border-radius-base);border-top-right-radius:var(--border-radius-base);transform:scale(1);opacity:0;transition:var(--transition-duration-3)}uc-editor-scroller{display:flex;align-items:center;width:100%;height:100%;overflow-x:scroll}uc-editor-slider{display:flex;align-items:center;justify-content:center;width:100%;height:var(--size-panel-heading)}uc-editor-toolbar{position:relative;width:100%;height:100%}@media only screen and (max-width:600px){uc-editor-toolbar{--l-tab-gap: var(--cldtr-gap-mid-1);--l-slider-padding: var(--uc-padding);
9957--l-controls-padding: var(--uc-padding)}}@media only screen and (min-width:601px){uc-editor-toolbar{--l-tab-gap: var(--cldtr-gap-max);--l-slider-padding: var(--uc-padding);--l-controls-padding: var(--uc-padding)}}uc-editor-toolbar>.uc-toolbar-container{position:relative;width:100%;height:100%;overflow:hidden}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar{position:absolute;display:grid;grid-template-rows:1fr 1fr;width:100%;height:100%;background-color:var(--color-fill-contrast);transition:opacity var(--transition-duration-3) ease-in-out,transform var(--transition-duration-3) ease-in-out,visibility var(--transition-duration-3) ease-in-out}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar.uc-sub-toolbar--visible{transform:translateY(0);opacity:1;pointer-events:auto}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar.uc-sub-toolbar--top-hidden{transform:translateY(100%);opacity:0;pointer-events:none}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar.uc-sub-toolbar--bottom-hidden{transform:translateY(-100%);opacity:0;pointer-events:none}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row{display:flex;align-items:center;justify-content:space-between;padding-right:var(--l-controls-padding);padding-left:var(--l-controls-padding)}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row>.uc-tab-toggles{position:relative;display:grid;grid-auto-flow:column;grid-gap:0px var(--l-tab-gap);align-items:center;height:100%}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row>.uc-tab-toggles>.uc-tab-toggles_indicator{position:absolute;bottom:0;left:0;width:var(--size-touch-area);height:2px;background-color:var(--uc-secondary-foreground);transform:translate(0);transition:transform var(--transition-duration-3)}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-tab-content-row{position:relative}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-tab-content-row>.uc-tab-content{position:absolute;top:0;left:0;display:flex;width:100%;height:100%;overflow:hidden;opacity:0;content-visibility:auto}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-tab-content-row>.uc-tab-content.uc-tab-content--visible{opacity:1;pointer-events:auto}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-tab-content-row>.uc-tab-content.uc-tab-content--hidden{opacity:0;pointer-events:none}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row>.uc-tab-toggles>.uc-tab-toggle.uc-tab-toggle--visible{display:contents}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row>.uc-tab-toggles>.uc-tab-toggle.uc-tab-toggle--hidden{display:none}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row>.uc-tab-toggles.uc-tab-toggles--hidden{display:none}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row>.uc-tab-toggles>.uc-tab-toggle>uc-btn-ui{width:var(--uc-button-size)}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-controls-row>.uc-tab-toggles>.uc-tab-toggle>uc-btn-ui>uc-icon>svg{width:var(--size-icon);height:var(--size-icon)}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-tab-content-row>.uc-tab-content .uc-controls-list_align{display:grid;grid-template-areas:". inner .";grid-template-columns:1fr auto 1fr;box-sizing:border-box;min-width:100%;padding-left:var(--uc-padding)}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-tab-content-row>.uc-tab-content .uc-controls-list_inner{display:grid;grid-area:inner;grid-auto-flow:column;gap:6px}uc-editor-toolbar>.uc-toolbar-container>.uc-sub-toolbar>.uc-tab-content-row>.uc-tab-content .uc-controls-list_inner:last-child{padding-right:var(--uc-padding)}uc-editor-toolbar .uc-controls-list_last-item{margin-right:var(--cldtr-gap-max)}uc-editor-toolbar .uc-info-tooltip_container{position:absolute;display:flex;align-items:flex-start;justify-content:center;width:100%;height:100%}uc-editor-toolbar .uc-info-tooltip_wrapper{position:absolute;top:calc(-100% - var(--cldtr-gap-mid-2));display:flex;flex-direction:column;justify-content:flex-end;height:100%;pointer-events:none}uc-editor-toolbar .uc-info-tooltip{z-index:3;padding:3px 6px;color:var(--color-text-base);font-size:.7em;letter-spacing:1px;text-transform:uppercase;background-color:var(--color-text-accent-contrast);border-radius:var(--border-radius-editor);transform:translateY(100%);opacity:0;transition:var(--transition-duration-3)}uc-editor-toolbar .uc-info-tooltip_visible{transform:translateY(0);opacity:1}uc-editor-toolbar .uc-slider{padding-right:var(--l-slider-padding);padding-left:var(--l-slider-padding)}uc-btn-ui>button{--filter-effect: var(--idle-brightness);--opacity-effect: var(--idle-opacity);--color-effect: var(--idle-color-rgb);--background-effect: var(--idle-background);--l-transition-effect: var( --css-transition, color var(--transition-duration-2), background-color var(--transition-duration-2), filter var(--transition-duration-2) );all:unset;display:inline-flex;align-items:center;box-sizing:var(--css-box-sizing, border-box);height:var(--css-height, var(--uc-button-size));padding-right:var(--css-padding-right, 14px);padding-left:var(--css-padding-left, 14px);font-size:1em;color:var(--color-effect);background-color:var(--background-effect);border-radius:var(--uc-radius);opacity:var(--opacity-effect);outline:none;cursor:pointer;filter:brightness(var(--filter-effect));transition:var(--l-transition-effect);-webkit-user-select:none;user-select:none}uc-btn-ui>button>uc-icon{pointer-events:none}uc-btn-ui .uc-text{white-space:nowrap}uc-btn-ui .uc-icon{display:flex;align-items:center;justify-content:center;color:var(--color-effect);filter:brightness(var(--filter-effect));transition:var(--l-transition-effect)}uc-btn-ui .uc-icon_left{margin-right:var(--cldtr-gap-mid-1);margin-left:0}uc-btn-ui .uc-icon_right{margin-right:0;margin-left:var(--cldtr-gap-mid-1)}uc-btn-ui .uc-icon_single{margin-right:0;margin-left:0}uc-btn-ui .uc-icon_hidden{display:none;margin:0}uc-btn-ui.uc-primary>button{--idle-color-rgb: var(--uc-primary-foreground);--idle-brightness: 1;--idle-opacity: 1;--idle-background: var(--uc-primary);--hover-color-rgb: var(--uc-primary-foreground);--hover-brightness: 1;
9957--hover-opacity: 1;--hover-background: var(--uc-primary-hover);--down-color-rgb: var(--uc-primary-foreground);--down-brightness: .75;--down-opacity: 1;--down-background: var(--uc-primary);--active-color-rgb: var(--uc-primary-foreground);--active-brightness: 1;--active-opacity: 1;--active-background: var(--uc-primary)}uc-btn-ui.uc-primary-icon>button{--idle-color-rgb: var(--uc-primary);--idle-brightness: 1;--idle-opacity: 1;--idle-background: transparent;--hover-color-rgb: var(--uc-primary);--hover-brightness: 1;--hover-opacity: 1;--hover-background: var(--uc-primary-transparent);--down-color-rgb: var(--uc-primary);--down-brightness: .75;--down-opacity: 1;--down-background: var(--uc-primary-transparent);--active-color-rgb: var(--uc-primary-foreground);--active-brightness: 1;--active-opacity: 1;--active-background: var(--uc-primary);padding:0;width:var(--uc-button-size)}uc-btn-ui.uc-secondary>button{--idle-color-rgb: var(--uc-secondary-foreground);--idle-brightness: 1;--idle-opacity: 1;--idle-background: var(--uc-secondary);--hover-color-rgb: var(--uc-secondary-foreground);--hover-brightness: 1;--hover-opacity: 1;--hover-background: var(--uc-secondary-hover);--down-color-rgb: var(--uc-secondary-foreground);--down-brightness: 1;--down-opacity: 1;--down-background: var(--uc-secondary-hover);--active-color-rgb: var(--uc-secondary-foreground);--active-brightness: 1;--active-opacity: 1;--active-background: transparent}:where(.uc-contrast) uc-btn-ui.uc-secondary>button{border:1px solid var(--uc-border)}uc-btn-ui.uc-secondary-icon>button{--idle-color-rgb: var(--uc-secondary-foreground);--idle-brightness: 1;--idle-opacity: 1;--idle-background: transparent;--hover-color-rgb: var(--uc-secondary-foreground);--hover-brightness: 1;--hover-opacity: 1;--hover-background: var(--uc-secondary);--down-color-rgb: var(--uc-secondary-foreground);--down-brightness: 1;--down-opacity: 1;--down-background: var(--uc-secondary);--active-color-rgb: var(--uc-secondary-foreground);--active-brightness: 1;--active-opacity: 1;--active-background: transparent;padding:0;width:var(--uc-button-size)}uc-btn-ui.uc-tab>button{--idle-color-rgb: var(--uc-secondary-foreground);--idle-brightness: 1;--idle-opacity: 1;--idle-background: transparent;--hover-color-rgb: var(--uc-secondary-foreground);--hover-brightness: 1;--hover-opacity: 1;--hover-background: var(--uc-secondary);--down-color-rgb: var(--uc-secondary-foreground);--down-brightness: 1;--down-opacity: 1;--down-background: var(--uc-secondary);--active-color-rgb: var(--uc-secondary-foreground);--active-brightness: 1;--active-opacity: 1;--active-background: transparent;padding:0;width:var(--uc-button-size)}uc-btn-ui.uc-default>button{--idle-color-rgb: var(--uc-secondary-foreground);--idle-brightness: 1;--idle-opacity: 1;--idle-background: var(--uc-secondary);--hover-color-rgb: var(--uc-secondary-foreground);--hover-brightness: 1;--hover-opacity: 1;--hover-background: var(--uc-secondary-hover);--down-color-rgb: var(--uc-secondary-foreground);--down-brightness: .75;--down-opacity: 1;--down-background: var(--uc-secondary);--active-color-rgb: var(--uc-primary);--active-brightness: 1;--active-opacity: 1;--active-background: var(--uc-primary-transparent)}:where(.uc-contrast) uc-btn-ui.uc-default>button{--idle-background: transparent;--hover-background: var(--uc-secondary);--active-background: var(--uc-foreground);--active-color-rgb: var(--uc-background)}uc-line-loader-ui{position:absolute;top:0;left:0;z-index:9999;width:100%;height:2px;opacity:.5}uc-line-loader-ui .uc-inner{width:25%;max-width:200px;height:100%}uc-line-loader-ui .uc-line{width:100%;height:100%;background-color:var(--uc-primary);transform:translate(-101%);transition:transform 1s}uc-slider-ui{--l-thumb-size: 24px;--l-zero-dot-size: 5px;--l-zero-dot-offset: 2px;--idle-color-rgb: var(--uc-foreground);--hover-color-rgb: var(--uc-primary);--down-color-rgb: var(--uc-primary);--color-effect: var(--idle-color-rgb);--l-color: var(--color-effect);position:relative;display:flex;align-items:center;justify-content:center;width:100%;
9957height:calc(var(--l-thumb-size) + (var(--l-zero-dot-size) + var(--l-zero-dot-offset)) * 2)}uc-slider-ui .uc-thumb{position:absolute;left:0;width:var(--l-thumb-size);height:var(--l-thumb-size);background-color:var(--l-color);border-radius:50%;transform:translate(0);opacity:1;transition:opacity var(--transition-duration-2),background-color var(--transition-duration-2)}uc-slider-ui .uc-steps{position:absolute;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;width:100%;height:100%;padding-right:calc(var(--l-thumb-size) / 2);padding-left:calc(var(--l-thumb-size) / 2)}uc-slider-ui .uc-border-step{width:0px;height:10px;border-right:1px solid var(--uc-foreground);opacity:1;transition:border-color var(--transition-duration-2)}uc-slider-ui .uc-minor-step{width:0px;height:4px;border-right:1px solid var(--uc-foreground);opacity:.6;transition:border-color var(--transition-duration-2)}uc-slider-ui .uc-zero-dot{position:absolute;top:calc(100% - var(--l-zero-dot-offset) * 2);left:calc(var(--l-thumb-size) / 2 - var(--l-zero-dot-size) / 2);width:var(--l-zero-dot-size);height:var(--l-zero-dot-size);background-color:var(--color-primary-accent);border-radius:50%;opacity:0;transition:var(--transition-duration-3)}uc-slider-ui .uc-input{position:absolute;width:calc(100% - 10px);height:100%;margin:0;cursor:pointer;opacity:0}uc-presence-toggle.uc-transition{transition:opacity var(--transition-duration-3),visibility var(--transition-duration-3)}uc-presence-toggle.uc-visible{opacity:1;pointer-events:inherit}uc-presence-toggle.uc-hidden{opacity:0;pointer-events:none}uc-presence-toggle.uc-initial{display:none!important;transition:none!important}[uc-cloud-image-editor] [role=button]:focus-visible,[uc-cloud-image-editor] button:focus-visible{outline:1px auto -webkit-focus-ring-color}:where([uc-cloud-image-editor]) uc-icon{display:flex;align-items:center;justify-content:center;width:100%;height:100%}:where([uc-cloud-image-editor]) uc-icon svg{width:calc(var(--uc-button-size) / 2);height:calc(var(--uc-button-size) / 2)}uc-cloud-image-editor-activity{position:relative;display:flex;width:100%;height:100%;overflow:hidden;background-color:var(--uc-background)}[uc-modal]>dialog:has(uc-cloud-image-editor-activity[active]){width:100%;height:100%}uc-select{display:inline-flex}uc-select select{position:relative;display:inline-flex;align-items:center;justify-content:center;height:var(--uc-button-size);padding:0 14px;font-size:1em;font-family:inherit;white-space:nowrap;border:none;border-radius:var(--uc-radius);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--uc-transition);color:var(--uc-secondary-foreground);background-color:var(--uc-secondary)}@keyframes uc-spinner-keyframes{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.uc-spinner{width:1em;height:1em;border:solid 2px transparent;border-top-color:currentColor;border-left-color:currentColor;border-radius:50%;animation:uc-spinner-keyframes .4s linear infinite}:where([uc-wgt-common]) uc-source-btn[type]{all:unset}uc-file-uploader-regular[data-v-dfa144f5]{--uc-font-family: Mulish, sans-serif;--uc-button-size: 38px;--uc-radius: calc(8px / 1.75);
9957--uc-dialog-shadow-light: var(--box-shadow);--uc-foreground-light: var(--color-gray-500);--uc-primary-rgb-light: var(--color-primary);--uc-secondary-foreground-light: var(--color-gray-500)}uc-file-uploader-regular[data-v-dfa144f5] :where(.uc-cancel-btn,.uc-done-btn,.uc-url-upload-btn){padding-right:14px;padding-left:14px}uc-file-uploader-regular[data-v-dfa144f5] uc-drop-area{border-radius:6px;border:2px dashed rgb(var(--color-gray-200));background-color:rgb(var(--color-primary-50))}uc-file-uploader-regular[data-v-dfa144f5] uc-drop-area uc-icon[name=default]>svg{width:32px;height:32px}uc-file-uploader-regular[data-v-dfa144f5] uc-drop-area .uc-content-wrapper .uc-text{font-weight:700}uc-file-uploader-regular[data-v-dfa144f5] uc-start-from .uc-secondary-btn{border-radius:30px;padding:10px 22px;border:1px solid rgb(var(--color-gray-200));background-color:#fff;font-weight:600}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.