@uploadcare/file-uploader 1.25.0-alpha.2 → 1.25.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/abstract/loadFileUploaderFrom.js +4 -79
  2. package/dist/env.js +4 -33
  3. package/dist/index.css +5 -2664
  4. package/dist/index.d.ts +933 -927
  5. package/dist/index.js +6 -13594
  6. package/dist/index.layered.css +4 -2720
  7. package/dist/index.ssr.js +34 -29
  8. package/dist/locales/file-uploader/ar.js +4 -165
  9. package/dist/locales/file-uploader/az.js +4 -157
  10. package/dist/locales/file-uploader/ca.js +4 -159
  11. package/dist/locales/file-uploader/cs.js +4 -161
  12. package/dist/locales/file-uploader/da.js +4 -157
  13. package/dist/locales/file-uploader/de.js +4 -157
  14. package/dist/locales/file-uploader/el.js +4 -157
  15. package/dist/locales/file-uploader/en.js +4 -157
  16. package/dist/locales/file-uploader/es.js +4 -159
  17. package/dist/locales/file-uploader/et.js +4 -157
  18. package/dist/locales/file-uploader/fi.js +4 -157
  19. package/dist/locales/file-uploader/fr.js +4 -159
  20. package/dist/locales/file-uploader/he.js +4 -159
  21. package/dist/locales/file-uploader/hy.js +4 -157
  22. package/dist/locales/file-uploader/is.js +4 -157
  23. package/dist/locales/file-uploader/it.js +4 -159
  24. package/dist/locales/file-uploader/ja.js +4 -157
  25. package/dist/locales/file-uploader/ka.js +4 -157
  26. package/dist/locales/file-uploader/kk.js +4 -157
  27. package/dist/locales/file-uploader/ko.js +4 -157
  28. package/dist/locales/file-uploader/lv.js +4 -159
  29. package/dist/locales/file-uploader/nb.js +4 -157
  30. package/dist/locales/file-uploader/nl.js +4 -157
  31. package/dist/locales/file-uploader/pl.js +4 -161
  32. package/dist/locales/file-uploader/pt.js +4 -159
  33. package/dist/locales/file-uploader/ro.js +4 -159
  34. package/dist/locales/file-uploader/ru.js +4 -161
  35. package/dist/locales/file-uploader/sk.js +4 -161
  36. package/dist/locales/file-uploader/sr.js +4 -159
  37. package/dist/locales/file-uploader/sv.js +4 -157
  38. package/dist/locales/file-uploader/tr.js +4 -157
  39. package/dist/locales/file-uploader/uk.js +4 -161
  40. package/dist/locales/file-uploader/vi.js +4 -157
  41. package/dist/locales/file-uploader/zh-TW.js +4 -157
  42. package/dist/locales/file-uploader/zh.js +4 -157
  43. package/package.json +12 -11
  44. package/types/jsx.d.ts +75 -48
  45. package/web/file-uploader.iife.min.d.ts +935 -929
  46. package/web/file-uploader.iife.min.js +6 -31
  47. package/web/file-uploader.iife.min.js.LEGAL.txt +71 -0
  48. package/web/file-uploader.min.d.ts +935 -929
  49. package/web/file-uploader.min.js +5 -29
  50. package/web/file-uploader.min.js.LEGAL.txt +71 -0
  51. package/web/uc-basic.layered.min.css +4 -23
  52. package/web/uc-basic.min.css +4 -23
  53. package/web/uc-cloud-image-editor.layered.min.css +4 -23
  54. package/web/uc-cloud-image-editor.min.css +4 -23
  55. package/web/uc-cloud-image-editor.min.d.ts +489 -494
  56. package/web/uc-cloud-image-editor.min.js +5 -29
  57. package/web/uc-cloud-image-editor.min.js.LEGAL.txt +70 -0
  58. package/web/uc-file-uploader-inline.layered.min.css +4 -23
  59. package/web/uc-file-uploader-inline.min.css +4 -23
  60. package/web/uc-file-uploader-inline.min.d.ts +935 -929
  61. package/web/uc-file-uploader-inline.min.js +5 -29
  62. package/web/uc-file-uploader-inline.min.js.LEGAL.txt +71 -0
  63. package/web/uc-file-uploader-minimal.layered.min.css +4 -23
  64. package/web/uc-file-uploader-minimal.min.css +4 -23
  65. package/web/uc-file-uploader-minimal.min.d.ts +935 -929
  66. package/web/uc-file-uploader-minimal.min.js +5 -29
  67. package/web/uc-file-uploader-minimal.min.js.LEGAL.txt +71 -0
  68. package/web/uc-file-uploader-regular.layered.min.css +4 -23
  69. package/web/uc-file-uploader-regular.min.css +4 -23
  70. package/web/uc-file-uploader-regular.min.d.ts +935 -929
  71. package/web/uc-file-uploader-regular.min.js +5 -29
  72. package/web/uc-file-uploader-regular.min.js.LEGAL.txt +71 -0
  73. package/web/uc-img.min.d.ts +28 -38
  74. package/web/uc-img.min.js +5 -25
  75. package/web/uc-img.min.js.LEGAL.txt +24 -0
@@ -1,32 +1,8 @@
1
1
  /**
2
2
  * @license
3
- * MIT License
4
- *
5
- * Copyright (c) 2025 Uploadcare (hello@uploadcare.com). All rights reserved.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- *
3
+ * Package: @uploadcare/file-uploader@1.25.0-alpha.4 (MIT)
4
+ * License: https://github.com/uploadcare/file-uploader/blob/main/LICENSE
5
+ * Built: 2025-12-09T11:47:51.284Z
25
6
  */
26
- var yo=Object.defineProperty;var bo=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Rn=Object.prototype.hasOwnProperty;var vo=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of Ln(i))!Rn.call(o,r)&&r!==e&&yo(o,r,{get:()=>i[r],enumerable:!(t=bo(i,r))||t.enumerable});return o},v=(o,i,e)=>(vo(o,i,"default"),e&&vo(e,i,"default"));var h=(o,i,e,t)=>{for(var r=t>1?void 0:t?bo(i,e):i,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(t?n(i,e,r):n(r))||r);return t&&r&&yo(i,e,r),r};var X={BIND_ATTR:"bind",ATTR_BIND_PX:"@",SHARED_CTX_PX:"*",PARENT_CTX_PX:"^",NAMED_CTX_SPLTR:"/",COMPUTED_PX:"+",CSS_DATA_PX:"--",CTX_NAME_ATTR:"ctx",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx",EL_REF_ATTR:"ref",AUTO_TAG_PX:"sym",LIST_ATTR:"itemize",LIST_ITEM_TAG_ATTR:"item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL_ATTR:"use-template",DEFAULT_SLOT_KEY:"__default__",TEXT_NODE_SKIP_ATTR:"skip-text-nodes",TEXT_NODE_OPEN_TOKEN:"{{",TEXT_NODE_CLOSE_TOKEN:"}}"};function Pn(o){let i=e=>{for(let t in e)e[t]?.constructor===Object&&(e[t]=i(e[t]));return{...e}};return i(o)}var U=class o{#i;#r;#e;constructor(i){i.constructor===Object?this.store=Pn(i):(this.#e=!0,this.store=i),this.callbackMap=Object.create(null)}static#t(i,e){console.warn(`Symbiote PubSub: cannot ${i}. Prop name: `+e)}read(i){if(!this.#e&&!this.store.hasOwnProperty(i))return o.#t("read",i),null;if(typeof i=="string"&&i.startsWith(X.COMPUTED_PX)){let e=this.store[i];if(e?.constructor!==Function){o.#t("compute",i);return}this.__computedMap||(this.__computedMap={});let t=e();return Object.keys(this.__computedMap).includes(i)||(this.__computedMap[i]=t,this.notify(i)),t}else return this.store[i]}has(i){return this.#e?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this.#e&&!this.store.hasOwnProperty(i)){o.#t("publish",i);return}if(i?.startsWith(X.COMPUTED_PX)&&e.constructor!==Function){o.#t("publish computed",i);return}!(this.store[i]===null||e===null)&&typeof this.store[i]!=typeof e&&console.warn(`Symbiote PubSub: type warning for "${i}" [${typeof this.store[i]} -> ${typeof e}]`),this.store[i]=e,this.notify(i)}get proxy(){if(!this.#r){let i=Object.create(null);this.#r=new Proxy(i,{set:(e,t,r)=>(this.pub(t,r),!0),get:(e,t)=>{this.read(t)}})}return this.#r}multiPub(i){for(let e in i)this.pub(e,i[e])}static#o(i,e){this.globalStore.forEach(t=>{t.__computedMap&&Object.keys(t.__computedMap).forEach(r=>{if(t===i&&e===r)return;let s=`__${r}_timeout`;t[s]&&window.clearTimeout(t[s]),t[s]=window.setTimeout(()=>{let n=t.read(r);n!==t.__computedMap[r]&&(t.__computedMap[r]=n,t.notify(r))})})})}notify(i){let e=i?.startsWith(X.COMPUTED_PX);if(this.callbackMap[i]){let t=this.read(i);this.callbackMap[i].forEach(r=>{r(t)}),e&&(this.__computedMap[i]=t)}!e&&o.#o(this,i)}sub(i,e,t=!0){return!this.#e&&!this.store.hasOwnProperty(i)?(o.#t("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.read(i)),{remove:()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},callback:e})}set uid(i){!this.#i&&(this.#i=i)}get uid(){return this.#i}static registerCtx(i,e=Symbol()){let t=o.globalStore.get(e);return t?console.warn('PubSub: context UID "'+e+'" is already in use'):(t=new o(i),t.uid=e,o.globalStore.set(e,t)),t}static deleteCtx(i){o.globalStore.delete(i)}static getCtx(i,e=!0){return o.globalStore.get(i)||(e&&console.warn('PubSub: wrong context UID - "'+i+'"'),null)}};U.globalStore=new Map;var _o="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Un=_o.length-1,ge=class{static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:_o.charAt(Math.random()*Un);return e}};var Zc=[X.LIST_ATTR,X.LIST_ITEM_TAG_ATTR,X.EL_REF_ATTR,X.USE_TPL_ATTR,X.CTX_NAME_ATTR,X.CTX_OWNER_ATTR];function ve(o,...i){let e="",t=new CSSStyleSheet;return o.forEach((r,s)=>{e+=r+i[s]}),ve.processors.forEach(r=>{e=r(e)}),ve.clearProcessors(),t.replaceSync(e),t}ve.processors=[];ve.clearProcessors=function(){ve.processors=[]};ve.useProcessor=function(...o){return ve.processors=[...ve.processors,...o],ve};function kt(o,i){for(let e in i)e.includes("-")?o.style.setProperty(e,i[e]):o.style[e]=i[e]}var Vn=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function tr(o){for(let i in o){if(Vn.includes(i))continue;let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r=`-${r.toLowerCase()}`),t+=r,t),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),o[i].reg&&o[i].reg(e)}}var ir="UC";function Fn(o,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[ir]){e(window[ir]);return}let r=document.createElement("script");r.async=!0,r.src=o,r.onerror=()=>{t()},r.onload=()=>{let s=window[ir];i&&tr(s),e(s)},document.head.appendChild(r)})}var Ot={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"OneDrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var Zt=new Map,rr=new Map,Co=(o,i)=>{Zt.has(o)&&console.log(`Locale ${o} is already defined. Overwriting...`),Zt.set(o,{...Ot,...i})},Nn=(o,i)=>{rr.set(o,i)},To=(o,i)=>{typeof i=="function"?Nn(o,i):Co(o,i)},Eo=async o=>{if(!Zt.has(o)){if(!rr.has(o))throw new Error(`Locale ${o} is not defined`);let e=await rr.get(o)();Co(o,e)}return Zt.get(o)};To("en",Ot);var z=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Qt=class{constructor(i){this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;this._block=i}_debugPrint(...i){this._block.debugPrint("[modal-manager]",...i)}registerModal(i,e){this._modals.set(i,e),this._notify(z.ADD,{id:i,modal:e})}deleteModal(i){if(!this._modals.has(i))return!1;let e=this._modals.get(i);return this._modals.delete(i),this._activeModals.delete(i),this._notify(z.DELETE,{id:i,modal:e}),!0}open(i){if(!this._modals.has(i))return this._debugPrint(`Modal with ID "${i}" not found`),!1;let e=this._modals.get(i);return this._activeModals.add(i),this._notify(z.OPEN,{modal:e,id:i}),!0}close(i){if(!this._modals.has(i)||!this._activeModals.has(i))return this._debugPrint(`Modal with ID "${i}" not found or not active`),!1;let e=this._modals.get(i);return this._activeModals.delete(i),this._notify(z.CLOSE,{id:i,modal:e}),!0}toggle(i){return this._modals.has(i)?this._activeModals.has(i)?this.close(i):this.open(i):(this._debugPrint(`Modal with ID "${i}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let i=Array.from(this._activeModals).pop();return i?this.close(i):!1}closeAll(){let i=this._activeModals.size;return this._activeModals.clear(),this._notify(z.CLOSE_ALL,{}),i}subscribe(i,e){return this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(e),()=>this.unsubscribe(i,e)}unsubscribe(i,e){this._subscribers.has(i)&&this._subscribers.get(i)?.delete(e)}_notify(i,e){if(this._subscribers.has(i))for(let t of this._subscribers.get(i)??new Set)try{t(e)}catch(r){this._block.telemetryManager.sendEventError(r,"modal subscriber"),this._debugPrint("Error in modal subscriber:",r)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(z.DESTROY,{})}};function xo(o){return Object.prototype.toString.call(o)==="[object Object]"}var Bn=/\W|_/g;function zn(o){return o.split(Bn).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}function So(o,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(o)?o.map(e=>Oe(e,{ignoreKeys:i})):o}function Oe(o,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(o))return So(o,{ignoreKeys:i});if(!xo(o))return o;let e={};for(let t of Object.keys(o)){let r=o[t];if(i.includes(t)){e[t]=r;continue}xo(r)?r=Oe(r,{ignoreKeys:i}):Array.isArray(r)&&(r=So(r,{ignoreKeys:i})),e[zn(t)]=r}return e}var Hn=o=>new Promise(i=>setTimeout(i,o));function dr({libraryName:o,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){let s="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:o,libraryVersion:i,languageName:s,integration:r});let n=[o,i,t].filter(Boolean).join("/"),a=[s,r].filter(Boolean).join("; ");return`${n} (${a})`}var jn={factor:2,time:100};function Kn(o,i=jn){let e=0;function t(r){let s=Math.round(i.time*i.factor**e);return r({attempt:e,retry:a=>Hn(a??s).then(()=>(e+=1,t(r)))})}return t(o)}var Ye=class extends Error{},lt=class o extends Ye{originalProgressEvent;constructor(i){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,o.prototype),this.originalProgressEvent=i}},Yt=(o,i)=>{o&&(o.aborted?Promise.resolve().then(i):o.addEventListener("abort",()=>i(),{once:!0}))},$e=class o extends Ye{isCancel=!0;constructor(i="Request canceled"){super(i),this.name="CancelError",Object.setPrototypeOf(this,o.prototype)}},Gn=500,Io=({check:o,interval:i=Gn,timeout:e,signal:t})=>new Promise((r,s)=>{let n,a;Yt(t,()=>{n&&clearTimeout(n),s(new $e("Poll cancelled"))}),e&&(a=setTimeout(()=>{n&&clearTimeout(n),s(new $e("Timed out"))},e));let l=()=>{try{Promise.resolve(o(t)).then(d=>{d?(a&&clearTimeout(a),r(d)):n=setTimeout(l,i)}).catch(d=>{a&&clearTimeout(a),s(d)})}catch(d){a&&clearTimeout(a),s(d)}};n=setTimeout(l,0)}),O={baseCDN:"https://ucarecdn.com",baseURL:"https://upload.uploadcare.com",maxContentLength:50*1024*1024,retryThrottledRequestMaxTimes:1,retryNetworkErrorMaxTimes:3,multipartMinFileSize:25*1024*1024,multipartChunkSize:5*1024*1024,multipartMinLastPartSize:1024*1024,maxConcurrentRequests:4,pollingTimeoutMilliseconds:1e4,pusherKey:"79ae88bd931ea68464d9"},Jt="application/octet-stream",ko="original",Ve=({method:o,url:i,data:e,headers:t={},signal:r,onProgress:s})=>new Promise((n,a)=>{let l=new XMLHttpRequest,d=o?.toUpperCase()||"GET",u=!1;l.open(d,i,!0),t&&Object.entries(t).forEach(p=>{let[f,g]=p;typeof g<"u"&&!Array.isArray(g)&&l.setRequestHeader(f,g)}),l.responseType="text",Yt(r,()=>{u=!0,l.abort(),a(new $e)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let p={method:d,url:i,data:e,headers:t||void 0,signal:r,onProgress:s},f=l.getAllResponseHeaders().trim().split(/[\r\n]+/),g={};f.forEach(function(C){let E=C.split(": "),x=E.shift(),k=E.join(": ");x&&typeof x<"u"&&(g[x]=k)});let y=l.response,w=l.status;n({request:p,data:y,headers:g,status:w})}},l.onerror=p=>{u||a(new lt(p))},s&&typeof s=="function"&&(l.upload.onprogress=p=>{p.lengthComputable?s({isComputable:!0,value:p.loaded/p.total}):s({isComputable:!1})}),e?l.send(e):l.send()});function Wn(o,...i){return o}var qn=({name:o})=>o?[o]:[],Xn=Wn,Zn=()=>new FormData,Oo=o=>!1,ei=o=>typeof Blob<"u"&&o instanceof Blob,ti=o=>typeof File<"u"&&o instanceof File,ii=o=>!!o&&typeof o=="object"&&!Array.isArray(o)&&"uri"in o&&typeof o.uri=="string",ct=o=>ei(o)||ti(o)||Oo()||ii(o),Qn=o=>typeof o=="string"||typeof o=="number"||typeof o>"u",Yn=o=>!!o&&typeof o=="object"&&!Array.isArray(o),Jn=o=>!!o&&typeof o=="object"&&"data"in o&&ct(o.data);function Mo(o,i,e){if(Array.isArray(e))for(let t of e)Mo(o,`${i}[]`,t);else if(Jn(e)){let{name:t,contentType:r}=e,s=Xn(e.data,t,r??Jt),n=qn({name:t,contentType:r});o.push([i,s,...n])}else if(Yn(e))for(let[t,r]of Object.entries(e))typeof r<"u"&&o.push([`${i}[${t}]`,String(r)]);else Qn(e)&&e&&o.push([i,e.toString()])}function ea(o){let i=[];for(let[e,t]of Object.entries(o))Mo(i,e,t);return i}function ri(o){let i=Zn(),e=ea(o);for(let t of e){let[r,s,...n]=t;i.append(r,s,...n)}return i}var Q=class o extends Ye{code;request;response;headers;constructor(i,e,t,r,s){super(),this.name="UploadError",this.message=i,this.code=e,this.request=t,this.response=r,this.headers=s,Object.setPrototypeOf(this,o.prototype)}},ta=o=>{let i=new URLSearchParams;for(let[e,t]of Object.entries(o))t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).filter(r=>r[1]??!1).forEach(r=>i.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(t)?t.forEach(r=>{i.append(`${e}[]`,r)}):typeof t=="string"&&t?i.set(e,t):typeof t=="number"&&i.set(e,t.toString());return i.toString()},Ie=(o,i,e)=>{let t=new URL(o);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=ta(e)),t.toString()},ia="6.18.2",ra="UploadcareUploadClient",oa=ia;function Je(o){return dr({libraryName:ra,libraryVersion:oa,...o})}var sa="RequestThrottledError",Ao=15e3,na=1e3;function aa(o){let{headers:i}=o||{};if(!i||typeof i["retry-after"]!="string")return Ao;let e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:Ao}function Fe(o,i){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return Kn(({attempt:r,retry:s})=>o().catch(n=>{if("response"in n&&n?.code===sa&&r<e)return s(aa(n));if(n instanceof lt&&r<t)return s((r+1)*na);throw n}))}var Lo=o=>{let i="";return(ei(o)||ti(o)||ii(o))&&(i=o.type),i||Jt},Ro=o=>{let i="";return ti(o)&&o.name?i=o.name:ei(o)||Oo()?i="":ii(o)&&o.name&&(i=o.name),i||ko};function ur(o){return typeof o>"u"||o==="auto"?"auto":o?"1":"0"}function la(o,{publicKey:i,fileName:e,contentType:t,baseURL:r=O.baseURL,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:d,source:u="local",integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",url:Ie(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},data:ri({file:{data:o,name:e||Ro(o),contentType:t||Lo(o)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:ur(a),signature:s,expire:n,source:u,metadata:w}),signal:l,onProgress:d}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k}),{retryNetworkErrorMaxTimes:y,retryThrottledRequestMaxTimes:g})}var nr;(function(o){o.Token="token",o.FileInfo="file_info"})(nr||(nr={}));function ca(o,{publicKey:i,baseURL:e=O.baseURL,store:t,fileName:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:d="url",signal:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},url:Ie(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:o,store:ur(t),filename:r,check_URL_duplicates:s?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:d,metadata:w}),signal:u}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k}),{retryNetworkErrorMaxTimes:y,retryThrottledRequestMaxTimes:g})}var re;(function(o){o.Unknown="unknown",o.Waiting="waiting",o.Progress="progress",o.Error="error",o.Success="success"})(re||(re={}));var da=o=>"status"in o&&o.status===re.Error;function ua(o,{publicKey:i,baseURL:e=O.baseURL,signal:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=O.retryNetworkErrorMaxTimes}={}){return Fe(()=>Ve({method:"GET",headers:i?{"X-UC-User-Agent":Je({publicKey:i,integration:r,userAgent:s})}:void 0,url:Ie(e,"/from_url/status/",{jsonerrors:1,token:o}),signal:t}).then(({data:l,headers:d,request:u})=>{let p=Oe(JSON.parse(l));if("error"in p&&!da(p))throw new Q(p.error.content,p.error.errorCode,u,p,d);return p}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function pa(o,{publicKey:i,baseURL:e=O.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:s,signal:n,source:a,integration:l,userAgent:d,retryThrottledRequestMaxTimes:u=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"POST",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:l,userAgent:d})},url:Ie(e,"/group/",{jsonerrors:1}),data:ri({files:o,callback:t,pub_key:i,signature:r,expire:s,source:a}),signal:n}).then(({data:f,headers:g,request:y})=>{let w=Oe(JSON.parse(f));if("error"in w)throw new Q(w.error.content,w.error.errorCode,y,w,g);return w}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:u})}function Po(o,{publicKey:i,baseURL:e=O.baseURL,signal:t,source:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"GET",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:s,userAgent:n})},url:Ie(e,"/info/",{jsonerrors:1,pub_key:i,file_id:o,source:r}),signal:t}).then(({data:d,headers:u,request:p})=>{let f=Oe(JSON.parse(d));if("error"in f)throw new Q(f.error.content,f.error.errorCode,p,f,u);return f}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function ha(o,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=O.multipartChunkSize,baseURL:s="",secureSignature:n,secureExpire:a,store:l,signal:d,source:u="local",integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",url:Ie(s,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},data:ri({filename:t||ko,size:o,content_type:e||Jt,part_size:r,UPLOADCARE_STORE:ur(l),UPLOADCARE_PUB_KEY:i,signature:n,expire:a,source:u,metadata:w}),signal:d}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k.parts=Object.keys(k.parts).map(ue=>k.parts[Number(ue)]),k}),{retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})}function ma(o,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:s=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"PUT",url:i,data:o,onProgress:r,signal:t,headers:{"Content-Type":e||Jt}}).then(a=>(r&&r({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n})}function fa(o,{publicKey:i,baseURL:e=O.baseURL,source:t="local",signal:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"POST",url:Ie(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:s,userAgent:n})},data:ri({uuid:o,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:d,headers:u,request:p})=>{let f=Oe(JSON.parse(d));if("error"in f)throw new Q(f.error.content,f.error.errorCode,p,f,u);return f}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function pr(o,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:d}){return Io({check:u=>Po(o,{publicKey:i,baseURL:e,signal:u,source:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(p=>p.isReady?p:(d&&d({isComputable:!0,value:1}),!1)),signal:l})}function ga(o){return"defaultEffects"in o}var ke=class{uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(i,{baseCDN:e=O.baseCDN,fileName:t}={}){let{uuid:r,s3Bucket:s}=i,n=Ie(e,`${r}/`),a=s?Ie(`https://${s}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=t||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=n,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=s||null,this.s3Url=a,ga(i)&&(this.defaultEffects=i.defaultEffects)}},va=(o,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,contentType:a,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,baseCDN:w,metadata:C})=>la(o,{publicKey:i,fileName:e,contentType:a,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,metadata:C}).then(({file:E})=>pr(E,{publicKey:i,baseURL:t,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,onProgress:d,signal:l})).then(E=>new ke(E,{baseCDN:w})),ya=(o,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:s,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u,baseCDN:p})=>Po(o,{publicKey:i,baseURL:t,signal:r,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u}).then(f=>new ke(f,{baseCDN:p,fileName:e})).then(f=>(s&&s({isComputable:!0,value:1}),f)),ba=(o,{signal:i}={})=>{let e=null,t=null,r=o.map(()=>new AbortController),s=n=>()=>{t=n,r.forEach((a,l)=>l!==n&&a.abort())};return Yt(i,()=>{r.forEach(n=>n.abort())}),Promise.all(o.map((n,a)=>{let l=s(a);return Promise.resolve().then(()=>n({stopRace:l,signal:r[a].signal})).then(d=>(l(),d)).catch(d=>(e=d,null))})).then(n=>{if(t===null)throw e;return n[t]})},_a=window.WebSocket,ar=class{events=Object.create({});emit(i,e){this.events[i]?.forEach(t=>t(e))}on(i,e){this.events[i]=this.events[i]||[],this.events[i].push(e)}off(i,e){e?this.events[i]=this.events[i].filter(t=>t!==e):this.events[i]=[]}},wa=(o,i)=>o==="success"?{status:re.Success,...i}:o==="progress"?{status:re.Progress,...i}:{status:re.Error,...i},lr=class{key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new ar;disconnectTimeoutId=null;constructor(i,e=3e4){this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new _a(i),this.ws.addEventListener("error",e=>{this.emmitter.emit("error",new Error(e.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(e=>this.send(e.event,e.data)),this.queue=[]}),this.ws.addEventListener("message",e=>{let t=JSON.parse(e.data.toString());switch(t.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(t.channel,wa(t.event,JSON.parse(t.data)))}})}}disconnect(){let i=()=>{this.ws?.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){let t=JSON.stringify({event:i,data:e});this.ws?.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();let t=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:t}};this.emmitter.on(t,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}unsubscribe(i){this.subscribers-=1;let e=`task-status-${i}`,t={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(t.event,t.data):this.queue=this.queue.filter(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}},or=null,hr=o=>{if(!or){let i=typeof window>"u"?0:3e4;or=new lr(o,i)}return or},Ca=o=>{hr(o).connect()};function Ta({token:o,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Io({check:d=>ua(o,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,signal:d}).then(u=>{switch(u.status){case re.Error:return new Q(u.error,u.errorCode);case re.Waiting:return!1;case re.Unknown:return new Q(`Token "${o}" was not found.`);case re.Progress:return a&&(u.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:u.done/u.total})),!1;case re.Success:return a&&a({isComputable:!0,value:u.done/u.total}),u;default:throw new Error("Unknown status")}}),signal:l})}var Ea=({token:o,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,s)=>{let n=hr(i),a=n.onError(s),l=()=>{a(),n.unsubscribe(o)};Yt(e,()=>{l(),s(new $e("pusher cancelled"))}),n.subscribe(o,d=>{switch(d.status){case re.Progress:{t&&(d.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:d.done/d.total}));break}case re.Success:{l(),t&&t({isComputable:!0,value:d.done/d.total}),r(d);break}case re.Error:l(),s(new Q(d.msg,d.error_code))}})}),xa=(o,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:d,signal:u,onProgress:p,source:f,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,pusherKey:C=O.pusherKey,metadata:E})=>Promise.resolve(Ca(C)).then(()=>ca(o,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:d,signal:u,source:f,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,metadata:E})).catch(x=>(hr(C)?.disconnect(),Promise.reject(x))).then(x=>x.type===nr.FileInfo?x:ba([({signal:k})=>Ta({token:x.token,publicKey:i,baseURL:t,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,onProgress:p,signal:k}),({signal:k})=>Ea({token:x.token,pusherKey:C,signal:k,onProgress:p})],{signal:u})).then(x=>{if(x instanceof Q)throw x;return x}).then(x=>pr(x.uuid,{publicKey:i,baseURL:t,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,onProgress:p,signal:u})).then(x=>new ke(x,{baseCDN:r})),sr=new WeakMap,Sa=async o=>{if(sr.has(o))return sr.get(o);let i=await fetch(o.uri).then(e=>e.blob());return sr.set(o,i),i},Uo=async o=>{if(ti(o)||ei(o))return o.size;if(ii(o))return(await Sa(o)).size;throw new Error("Unknown file type. Cannot determine file size.")},Aa=(o,i=O.multipartMinFileSize)=>o>=i,$o=o=>{let i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(i);return!ct(o)&&e.test(o)},mr=o=>{let i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!ct(o)&&e.test(o)},Ia=(o,i)=>new Promise((e,t)=>{let r=[],s=!1,n=i.length,a=[...i],l=()=>{let d=i.length-a.length,u=a.shift();u&&u().then(p=>{s||(r[d]=p,n-=1,n?l():e(r))}).catch(p=>{s=!0,t(p)})};for(let d=0;d<o;d++)l()}),ka=(o,i,e,t)=>{let r=t*i,s=Math.min(r+t,e);return o.slice(r,s)},Oa=async(o,i,e)=>t=>ka(o,t,i,e),Ma=(o,i,{publicKey:e,contentType:t,onProgress:r,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>ma(o,i,{publicKey:e,contentType:t,onProgress:r,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),La=async(o,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,contentType:w,multipartChunkSize:C=O.multipartChunkSize,maxConcurrentRequests:E=O.maxConcurrentRequests,baseCDN:x,metadata:k})=>{let ue=t??await Uo(o),pe,Qe=(W,ie)=>{if(!d)return;pe||(pe=Array(W).fill(0));let fe=Ce=>Ce.reduce((Ae,er)=>Ae+er,0);return Ce=>{Ce.isComputable&&(pe[ie]=Ce.value,d({isComputable:!0,value:fe(pe)/W}))}};return w||=Lo(o),ha(ue,{publicKey:i,contentType:w,fileName:e||Ro(o),baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,metadata:k,multipartChunkSize:C}).then(async({uuid:W,parts:ie})=>{let fe=await Oa(o,ue,C);return Promise.all([W,Ia(E,ie.map((Ce,Ae)=>()=>Ma(fe(Ae),Ce,{publicKey:i,contentType:w,onProgress:Qe(ie.length,Ae),signal:l,integration:p,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})))])}).then(([W])=>fa(W,{publicKey:i,baseURL:r,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})).then(W=>W.isReady?W:pr(W.uuid,{publicKey:i,baseURL:r,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,onProgress:d,signal:l})).then(W=>new ke(W,{baseCDN:x}))};async function fr(o,{publicKey:i,fileName:e,baseURL:t=O.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartMinFileSize:w,multipartChunkSize:C,maxConcurrentRequests:E,baseCDN:x=O.baseCDN,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:ue,pusherKey:pe,metadata:Qe}){if(ct(o)){let W=await Uo(o);return Aa(W,w)?La(o,{publicKey:i,contentType:y,multipartChunkSize:C,fileSize:W,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,maxConcurrentRequests:E,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x,metadata:Qe}):va(o,{publicKey:i,fileName:e,contentType:y,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x,metadata:Qe})}if(mr(o))return xa(o,{publicKey:i,fileName:e,baseURL:t,baseCDN:x,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:ue,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,pusherKey:pe,metadata:Qe});if($o(o))return ya(o,{publicKey:i,fileName:e,baseURL:t,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x});throw new TypeError(`File uploading from "${o}" is not supported`)}var cr=class{uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(i,{baseCDN:e=O.baseCDN}={}){this.uuid=i.id,this.filesCount=i.filesCount;let t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,s)=>r+s.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(t).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=t.map(r=>new ke(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}},Ra=o=>{for(let i of o)if(!ct(i))return!1;return!0},Pa=o=>{for(let i of o)if(!$o(i))return!1;return!0},Ua=o=>{for(let i of o)if(!mr(i))return!1;return!0};function Do(o,{publicKey:i,fileName:e,baseURL:t=O.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartChunkSize:w=O.multipartChunkSize,baseCDN:C=O.baseCDN,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x,jsonpCallback:k}){if(!Ra(o)&&!Ua(o)&&!Pa(o))throw new TypeError(`Group uploading from "${o}" is not supported`);let ue,pe=!0,Qe=o.length,W=(ie,fe)=>{if(!l)return;ue||(ue=Array(ie).fill(0));let Ce=Ae=>Ae.reduce((er,Mn)=>er+Mn)/ie;return Ae=>{if(!Ae.isComputable||!pe){pe=!1,l({isComputable:!1});return}ue[fe]=Ae.value,l({isComputable:!0,value:Ce(ue)})}};return Promise.all(o.map((ie,fe)=>ct(ie)||mr(ie)?fr(ie,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:W(Qe,fe),source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartChunkSize:w,baseCDN:C,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x}).then(Ce=>Ce.uuid):ie)).then(ie=>pa(ie,{publicKey:i,baseURL:t,jsonpCallback:k,secureSignature:r,secureExpire:s,signal:a,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g}).then(fe=>new cr(fe,{baseCDN:C})).then(fe=>(l&&l({isComputable:!0,value:1}),fe)))}var De=class{_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(i){this._concurrency=i}run(){let i=this._concurrency-this._running;for(let e=0;e<i;e++){let t=this._pending.shift();if(!t)return;let r=this._resolvers.get(t),s=this._rejectors.get(t);if(!r||!s)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this.run()}).then(n=>r(n)).catch(n=>s(n))}}add(i,{autoRun:e}={autoRun:!0}){return new Promise((t,r)=>{this._resolvers.set(i,t),this._rejectors.set(i,r),this._pending.push(i),e&&this.run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this.run()}get concurrency(){return this._concurrency}};var gr=()=>({}),vr=o=>({...gr(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{o.modalManager?.close(o.$["*currentActivity"]),o.set$({"*currentActivity":null})}}),yr=o=>({...vr(o),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new De(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),Vo=o=>({...yr(o),"*solution":null});var P=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),I=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created"}),oi=class{constructor(i){this._timeoutStore=new Map;this._targets=new Set;this._debugPrint=null;this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){for(let t of this._targets)t.dispatchEvent(new CustomEvent(i,{detail:e}));this._debugPrint?.(()=>{let t=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,t]})}emit(i,e,t={}){let{debounce:r}=t;if(typeof r!="number"&&!r){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let s=typeof r=="number"?r:20,n=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},s);this._timeoutStore.set(i,n)}};function L(o,i){let e,t=((...r)=>{e&&clearTimeout(e),e=setTimeout(()=>o(...r),i)});return t.cancel=()=>{e&&clearTimeout(e)},t}var m={};v(m,Yd);v(m,Jd);import"@lit/reactive-element";import"lit-html";import*as Yd from"lit-element/lit-element.js";import*as Jd from"lit-html/is-server.js";var $a={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function Mt(o,i){i.tabIndex=0,i.focus(),o.tabIndex=-1}function br(o){let i=o.role||o.type||o.tagName;if(!i)return null;let e=$a[i.toLowerCase()];if(!e)return null;for(let t of e){let r=o.closest(`[role=${t}]`);if(r)return r}}function _r(o,i){return i.role==="toolbar"?Da(i):i.querySelectorAll(`[role=${o.role}]`)}function Da(o){return[...o.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function Va(o){let i=o.getAttribute("aria-orientation");if(i==="vertical")return!1;if(i==="horizontal")return!0;let e=o.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function Fo(o){return i=>{let e=!1,t=o?.searchDelayMs||300,r=0,s="";function n(p){let f=br(p.target);if(!f){a();return}let g=_r(p.target,f),y=Array.from(g).indexOf(p.target),w="ArrowDown",C="ArrowUp";if(Va(f)&&(i.document.dir==="rtl"?(w="ArrowLeft",C="ArrowRight"):(w="ArrowRight",C="ArrowLeft")),p.key===w)p.preventDefault(),Mt(p.target,g[y+1]||g[0]);else if(p.key===C)p.preventDefault(),Mt(p.target,g[y-1]||g[g.length-1]);else if(p.key==="Home")p.preventDefault(),Mt(p.target,g[0]);else if(p.key==="End")p.preventDefault(),Mt(p.target,g[g.length-1]);else if(p.key.length===1&&f.role!=="tablist"){let E=Date.now();E-r<=t?s+=p.key.toLowerCase():s=p.key.toLowerCase(),r=E;let x=Array.from(g).find(k=>k.textContent?.trim()?.toLowerCase()?.startsWith(s));x&&(p.preventDefault(),Mt(p.target,x))}}function a(){e=!1,i.removeEventListener("keydown",n)}function l(p){let f=br(p.target);if(f){e||(e=!0,i.addEventListener("keydown",n));let g=_r(p.target,f);for(let y of g)y!==p.target&&y.setAttribute("tabindex",-1)}else e&&a()}function d(p){(!p.relatedTarget||p.relatedTarget===i.document)&&a()}function u(p){let f=br(p.target);if(f){let g=_r(p.target,f);for(let y of g)y!==p.target&&y.setAttribute("tabindex",-1);p.target.setAttribute("tabindex",0)}}return i.addEventListener("click",u),i.addEventListener("focusin",l),i.addEventListener("focusout",d),()=>{a(),i.removeEventListener("click",u),i.removeEventListener("focusin",l),i.removeEventListener("focusout",d)}}}function No(){return o=>{let i,e;function t(s){if(s.target.getAttribute("aria-hidden")==="true"){i=s.target,i.setAttribute("aria-hidden","false"),e=i.hidden,e&&(i.hidden=!1);let n=s.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function r(s){i&&i.contains(s.target)&&(!s.relatedTarget||!i.contains(s.relatedTarget))&&(s.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),e&&(i.hidden=!0),i=null)}return o.addEventListener("keyuxJump",t),o.addEventListener("focusout",r),()=>{o.removeEventListener("keyuxJump",t),o.removeEventListener("focusout",r)}}}function Bo(){return o=>{let i=[];function e(l){let d=o.document.activeElement;d&&d!==o.document.body&&i.push(new WeakRef(d)),l.focus({focusVisible:!0})}function t(){let l=i.pop();if(!l){o.document.activeElement.blur();return}let d=l.deref();d&&d.isConnected?d.focus():t()}let r=0,s;function n(l){clearInterval(s);let d=l.getAttribute("aria-controls");s=setInterval(()=>{if(r++>50){clearInterval(s);return}let u=o.document.getElementById(d);if(u){let p=u.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');p&&(clearInterval(s),u.dispatchEvent(new o.CustomEvent("keyuxJump",{bubbles:!0})),e(p))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&t()}return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}}}function zo(o){let i,e=o.split(" "),t;function r(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(s(),a.target.classList.add(...e),i=a.target,t=a.target)}function s(){i&&i.classList.remove(...e),t=null}function n(a){a.clientX===0&&a.clientY===0&&t!==a.target&&(s(),a.target.classList.add(...e),i=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",r),a.addEventListener("keyup",s),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",r),a.removeEventListener("keyup",s)})}function Ho(o,i){let e=i.map(t=>t(o));return()=>{e.forEach(t=>t())}}var wr=class{constructor(){this._listeners=new Map;this._scope=[]}addEventListener(i,e){let t=r=>{let s=r.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&e(r)};this._listeners.set(e,t),window.addEventListener(i,t)}removeEventListener(i,e){let t=this._listeners.get(e);t&&window.removeEventListener(i,t),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this._scope.push(i)}destroy(){this._scope=[];for(let i of this._listeners.values())window.removeEventListener("keydown",i),window.removeEventListener("keyup",i);this._listeners.clear()}},si=class{constructor(){this._scopedWindow=new wr,this._destroyKeyUX=Ho(this._scopedWindow,[Fo(),zo("is-pressed"),Bo(),No()])}registerBlock(i){this._scopedWindow.registerScope(i)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var Ne=o=>`*l10n/${o}`,Fa="en",ni=class{constructor(i){this._blockInstance=null;this._localeName="";this._blockInstance=i;for(let[e,t]of Object.entries(Ot)){let r=this._blockInstance.has(Ne(e))?!this._blockInstance.$[Ne(e)]:!0;this._blockInstance.add(Ne(e),t,r)}setTimeout(()=>{i.subConfigValue("localeName",async e=>{if(!this._blockInstance||!e)return;this._localeName=e;let t=await Eo(e);if(e!==Fa&&this._localeName!==e)return;let r=this._blockInstance.cfg.localeDefinitionOverride?.[e];for(let[s,n]of Object.entries(t)){let a=r?.[s];this._blockInstance.add(Ne(s),a??n,!0)}}),i.subConfigValue("localeDefinitionOverride",e=>{if(!e)return;let t=e[this._localeName];if(t)for(let[r,s]of Object.entries(t))this._blockInstance?.add(Ne(r),s,!0)})})}};function Na(o){return o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`).replace(/__/g,"_")}function Tr(o){return Array.isArray(o)?o.map(i=>typeof i=="object"&&i!==null?Tr(i):i):typeof o!="object"||o===null?o:Object.fromEntries(Object.entries(o).map(([i,e])=>{let t=Na(i);return typeof e=="object"&&e!==null?[t,Tr(e)]:[t,e]}))}function Ba(o){return{ok:!0,value:o}}function Cr(o){return{ok:!1,error:o}}var za="https://tlm.uploadcare.com/api/",Er=class{constructor(i=za){this.baseUrl=i}async base(i,e={}){let t=`${this.baseUrl}${i}`;try{let r=await fetch(t,e);if(!r.ok)return Cr(new Error(`Got non-200 response from "${t}". Status: ${r.status.toString()}`));try{let s=await r.json();return Ba(s)}catch(s){return Cr(new Error(`Error parsing JSON from "${t}". Error: ${s}`))}}catch(r){return Cr(new Error(`Error fetching data from "${t}". Error: ${r}`))}}async post(i,e,t={}){return await this.base(i,{...t,method:"POST",body:JSON.stringify(Tr(e)),headers:{"Content-Type":"application/json",...t.headers||{}}})}async get(i,e={}){return await this.base(i,{method:"GET",...e})}},Ha=async(o,i)=>({success:!0,data:i}),ai=class extends Er{constructor(){super()}async sendEvent(i,e){let t=await Ha(void 0,i);if(!t.success)throw console.error("TelemetryAPIService: events: body is invalid",t.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",i,e)}};var oe=o=>o?o.split(",").map(i=>i.trim()).filter(Boolean):[],Me=o=>o.join(",");var jo=o=>{if(typeof o!="string"||!o)return"";let i=o.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},li=(...o)=>o.filter(i=>typeof i=="string"&&!!i).map(i=>jo(i)).join("/-/"),Y=(...o)=>{let i=li(...o);return i?`-/${i}/`:""};function ci(o){let i=new URL(o),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),s="";return t>=0?s=e.slice(t):r>=0&&(s=e.slice(r+1)),s}function di(o){let i=new URL(o),{pathname:e}=i,t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}function xr(o){let i=Ko(o),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}function Sr(o){return xr(o).split("/-/").filter(Boolean).map(e=>jo(e))}function Ko(o){let i=new URL(o),e=ci(o),t=Go(e)?Wo(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}function Go(o){return o.startsWith("http")}function Wo(o){let i=new URL(o);return{pathname:`${i.origin}${i.pathname??""}`,search:i.search??"",hash:i.hash??""}}var H=(o,i,e)=>{let t=new URL(Ko(o)),r=e??ci(o),s=i??"";if(t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),r&&Go(r)){let n=Wo(r);t.pathname=`${t.pathname}${s}${n.pathname||""}`,t.search=n.search,t.hash=n.hash}else t.pathname=`${t.pathname}${s}${r||""}`;return t.toString()},Be=(o,i)=>{let e=new URL(o);return e.pathname=`${i}/`,e.toString()};var j=(o,i=",")=>o.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0);var Lt=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:!1,flip:!1,crop:void 0}),Xo=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function ja(o,i){if(typeof i=="number"){let e=i;return Lt[o]!==e?`${o}/${e}`:""}if(typeof i=="boolean"){let e=i;return Lt[o]!==e?`${o}`:""}if(o==="filter"&&i){let{name:e,amount:t}=i;return Lt.filter===t?"":`${o}/${e}/${t}`}if(o==="crop"&&i){let{dimensions:e,coords:t}=i;return`${o}/${e.join("x")}/${t.join(",")}`}return""}function ze(o){return li(...Xo.filter(i=>typeof o[i]<"u"&&o[i]!==null).map(i=>{let e=o[i];return ja(i,e)}).filter(i=>!!i))}var ui=li("format/auto","progressive/yes"),Le=([o])=>typeof o<"u"?Number(o):void 0,qo=()=>!0,Ka=([o,i])=>({name:o,amount:typeof i<"u"?Number(i):100}),Ga=([o,i])=>{if(!/\d+x\d+/.test(o)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:j(o,"x").map(Number),coords:j(i).map(Number)}},Wa=Object.freeze({enhance:Le,brightness:Le,exposure:Le,gamma:Le,contrast:Le,saturation:Le,vibrance:Le,warmth:Le,filter:Ka,mirror:qo,flip:qo,rotate:Le,crop:o=>{let[i,e]=o,{dimensions:t,coords:r}=Ga([i,e]);return{dimensions:t,coords:r}}});function Ar(o){let i={};for(let e of o){let[t,...r]=e.split("/");if(!t||!Xo.includes(t))continue;let s=t,n=Wa[s];try{let a=n(r);i[s]=a}catch(a){console.warn([`Failed to parse URL operation "${e}". It will be ignored.`,a instanceof Error?`Error message: "${a.message}"`:a,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
27
- `))}}return i}var V=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),J=Object.freeze([V.CROP,V.TUNING,V.FILTERS]),Zo=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Qo=Object.freeze(["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"]),Yo=Object.freeze(["rotate","mirror","flip"]),Re=Lt,ye=Object.freeze({brightness:{zero:Re.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Re.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Re.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Re.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Re.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Re.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Re.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Re.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Re.filter,range:[0,100],keypointsNumber:1}});var Rt="https://ucarecdn.com",qa="https://upload.uploadcare.com",Xa="https://social.uploadcare.com",Za="https://ucarecd.net",Qa={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Me(J),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Rt,cdnCnamePrefixed:Za,baseUrl:qa,socialBaseUrl:Xa,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},se=Object.freeze(Qa);var Jo="1.25.0-alpha.2";var He="blocks",je=Jo;var pi=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(se);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new ai,this._queue=new De(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:P.CHANGE_CONFIG}),this._setConfig(e,t)})}_init(i){i===P.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===P.INIT_SOLUTION||i.eventType===P.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:je,appName:He,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[I.CHANGE,I.COMMON_UPLOAD_PROGRESS,I.FILE_ADDED,I.FILE_REMOVED,I.FILE_UPLOAD_START,I.FILE_UPLOAD_PROGRESS,I.FILE_UPLOAD_SUCCESS,I.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:P.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s of t)if(!Object.hasOwn(e,s)||!this._checkObj(i[s],e[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var q=o=>`*cfg/${o}`;var es=o=>{let i=new Intl.Locale(o),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e};var hi=(o,i)=>new Intl.PluralRules(o).select(i);var Ja=o=>o;var ts="plural:";function Pt(o,i={},e={}){let{openToken:t="{{",closeToken:r="}}",transform:s=Ja}=e;for(let n in i){let a=i[n],l=a?.toString(),d=typeof l=="string"?s(l):String(l);o=o.replaceAll(t+n+r,d)}return o}function is(o){let i=[],e=o.indexOf("{{");for(;e!==-1;){let t=o.indexOf("}}",e);if(t===-1)break;let r=o.substring(e+2,t);if(r.startsWith(ts)){let s=o.substring(e+2,t).replace(ts,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=o.indexOf("{{",t)}return i}var rs="--uploadcare-blocks-window-height",Ut=class o{static{this.clientsRegistry=new Set}static{this.flush=L(()=>{document.documentElement.style.setProperty(rs,`${window.innerHeight}px`)},100)}static registerClient(i){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(i)}static unregisterClient(i){o.clientsRegistry.delete(i),o.clientsRegistry.size===0&&o.detachTracker()}static attachTracker(){window.addEventListener("resize",o.flush,{passive:!0,capture:!0}),o.flush()}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:!0}),document.documentElement.style.removeProperty(rs)}};var el=/\\([0-9a-fA-F]{1,6} ?)/g;function tl(o){return o.length<2?!1:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function il(o){let i=o;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function rl(o){let i="",e="";for(let t=0;t<o.length;t++){let r=o[t+1];o[t]==="\\"&&r==='"'?(i+='\\"',t++):o[t]==='"'&&e!=="\\"?i+='\\"':i+=o[t],e=o[t]??""}return i}function os(o){let i=o;tl(o)&&(i=il(i),i=i.replace(el,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
28
- `,"\\n"),i=rl(i),i='"'+i+'"');try{return JSON.parse(i)}catch{return}}function mi(o){class i extends o{constructor(){super(...arguments);this.cssDataCache=null;this.computedStyle=null}getCssData(r,s=!1){let n=this.cssDataCache??Object.create(null);if(!Object.keys(n).includes(r)||!n[r]){this.computedStyle||(this.computedStyle=window.getComputedStyle(this));let a=this.computedStyle.getPropertyValue(r).trim();try{n[r]=os(a)}catch(l){s||console.warn(`CSS Data error: ${r}`,l),n[r]=null}}return this.cssDataCache=n,n[r]}}return i}function ss(o){class i extends o{constructor(){super(...arguments);this.__slots={};this.__willYield=!0;this.__initialLightDomChildren=null;this.__hasAdoptedChildren=!1}createRenderRoot(){return this}connectedCallback(){this.__initialLightDomChildren||(this.__initialLightDomChildren=Array.from(this.childNodes)),super.connectedCallback()}__adoptChildren(){if(this.__hasAdoptedChildren)return;this.__hasAdoptedChildren=!0,this.__slots={};let r=Array.from(this.childNodes),s=r.length?r:this.__initialLightDomChildren??[];for(let n of s){let a=this.__getSlotNameForChild(n),l=this.__slots[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this.__slots[a]=l}this.__initialLightDomChildren=null}__getSlotNameForChild(r){return r instanceof Comment&&r.nextSibling instanceof Element?this.__getSlotNameForChild(r.nextSibling):"contentFor"in r?r.contentFor||"":r instanceof Element&&r.hasAttribute("content-for")&&r.getAttribute("content-for")||""}__isTextNodeEmpty(r){return!r.textContent||!r.textContent.trim()}__isSlotEmpty(r){let s=this.__slots[r];return!s||s.every(n=>n instanceof Comment||n instanceof Text&&this.__isTextNodeEmpty(n))}update(r){!this.hasUpdated&&this.__willYield&&this.__adoptChildren(),super.update(r)}yield(r,s){if(r===""&&!this.__slots[r]&&!this.__hasAdoptedChildren&&this.__initialLightDomChildren?.length){let a=[];for(let l of this.__initialLightDomChildren)l instanceof Element&&(l.removeAttribute("slot"),l.removeAttribute("content-for")),a.push(l);this.__slots[r]=a,this.__hasAdoptedChildren=!0,this.__initialLightDomChildren=null}let n=this.__slots[r];return m.html`
29
- ${n}
30
- ${this.__isSlotEmpty(r)?s:void 0}
31
- `}}return i}function fi(o){class i extends o{static reg(t){let r=this,s=window.customElements.get(t);if(s){s!==r&&console.warn([`Element with tag name "${t}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
32
- `));return}window.customElements.define(t,r)}}return i}var Ke=class extends Event{constructor(i,e,t,r){super("context-request",{bubbles:!0,composed:!0}),this.context=i,this.contextTarget=e,this.callback=t,this.subscribe=r??!1}};var dt=class{constructor(i,e,t,r){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(s,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(s,n)),this.unsubscribe=n},this.host=i,e.context!==void 0){let s=e;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=r??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Ke(this.context,this.host,this.t,this.subscribe))}};var gi=class{get value(){return this.o}set value(i){this.setValue(i)}setValue(i,e=!1){let t=e||!Object.is(i,this.o);this.o=i,t&&this.updateObservers()}constructor(i){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},i!==void 0&&(this.value=i)}addCallback(i,e,t){if(!t)return void i(this.value);this.subscriptions.has(i)||this.subscriptions.set(i,{disposer:()=>{this.subscriptions.delete(i)},consumerHost:e});let{disposer:r}=this.subscriptions.get(i);i(this.value,r)}clearCallbacks(){this.subscriptions.clear()}};var Ir=class extends Event{constructor(i,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=i,this.contextTarget=e}},ut=class extends gi{constructor(i,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=r=>{if(r.context!==this.context)return;let s=r.contextTarget??r.composedPath()[0];s!==this.host&&(r.stopPropagation(),this.addCallback(r.callback,s,r.subscribe))},this.onProviderRequest=r=>{if(r.context!==this.context||(r.contextTarget??r.composedPath()[0])===this.host)return;let s=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)s.has(n)||(s.add(n),a.dispatchEvent(new Ke(this.context,a,n,!0)));r.stopPropagation()},this.host=i,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new Ir(this.context,this.host))}};var c={};v(c,wp);v(c,Cp);v(c,Tp);v(c,Ep);v(c,xp);v(c,Sp);v(c,Ap);v(c,Ip);v(c,kp);import*as wp from"@lit/reactive-element/decorators/custom-element.js";import*as Cp from"@lit/reactive-element/decorators/property.js";import*as Tp from"@lit/reactive-element/decorators/state.js";import*as Ep from"@lit/reactive-element/decorators/event-options.js";import*as xp from"@lit/reactive-element/decorators/query.js";import*as Sp from"@lit/reactive-element/decorators/query-all.js";import*as Ap from"@lit/reactive-element/decorators/query-async.js";import*as Ip from"@lit/reactive-element/decorators/query-assigned-elements.js";import*as kp from"@lit/reactive-element/decorators/query-assigned-nodes.js";var ns="ctx-name-context";function as(o){class i extends o{constructor(...r){super(...r);this._symbioteSharedPubSub=null;this._symbioteFirstUpdated=!1;this._needsReconnectInit=!1;this._ctxNameProvider=void 0;this._warnedAboutLocalState=!1;this._pendingSharedAdds=new Map;this._symbioteSubscriptions=new Set;this.init$={};this.ctxOwner=!1;this._ctxNameAttr=void 0;this._pendingCtxInitOnConnect=!1;this.ctxName=this.effectiveCtxName;this.isInitialized=!1;this._ctxNameAttr=this.getAttribute("ctx-name")||void 0,this.ctxName=this.effectiveCtxName,this._ctxNameConsumer=new dt(this,{context:ns,callback:s=>{if(!s){console.error("SymbioteMixin: Received invalid ctx-name from context");return}this._ctxNameFromContext=s,this._handleCtxNameSourceChange()},subscribe:!0})}get ctxNameAttr(){return this._ctxNameAttr}set ctxNameAttr(r){let s=r??void 0;this._ctxNameAttr!==s&&(this._ctxNameAttr=s,this._handleCtxNameSourceChange())}shouldUpdate(r){return this.isInitialized?super.shouldUpdate(r):!1}get effectiveCtxName(){return this.ctxNameAttr||this._ctxNameFromContext||void 0}_handleCtxNameSourceChange(){if(this.ctxName=this.effectiveCtxName,!(!this.ctxName||this._symbioteFirstUpdated)){if(this.isConnected){this._performInitialization();return}this._pendingCtxInitOnConnect=!0}}willUpdate(r){super.willUpdate(r),this.ctxName=this.effectiveCtxName,this.ctxName&&(this._ctxNameProvider?this._ctxNameProvider.setValue(this.ctxName):this._ctxNameProvider=new ut(this,{context:ns,initialValue:this.ctxName}))}_getSharedInitEntries(){let r=Object.entries(this.init$||{}),s=[],n=[];for(let[a,l]of r)a.startsWith("*")?s.push([a,l]):n.push(a);return n.length>0&&!this._warnedAboutLocalState&&(console.warn("SymbioteMixin: Local state entries are no longer supported and will be ignored:",n),this._warnedAboutLocalState=!0),s}_getSharedInitSchema(){return Object.fromEntries(this._getSharedInitEntries())}_ensureSharedSchema(){if(!Object.hasOwn(this,"_sharedSchema")){let r=Object.fromEntries(this._getSharedInitEntries().map(([s,n])=>[s.slice(1),n]));Object.defineProperty(this,"_sharedSchema",{value:r,writable:!0,configurable:!0})}}_getSharedSchemaRecord(){return this._ensureSharedSchema(),this._sharedSchema??{}}_requireSharedKey(r){if(!r.startsWith("*"))throw new Error(`SymbioteMixin: Local state key "${r}" is no longer supported. Use shared keys prefixed with "*".`);return r.slice(1)}_applyPendingSharedAdds(){if(!(!this._symbioteSharedPubSub||this._pendingSharedAdds.size===0)){for(let[r,{value:s,rewrite:n}]of this._pendingSharedAdds)this._symbioteSharedPubSub.add(r,s,n);this._pendingSharedAdds.clear()}}_getSharedPubSub(){return!this._symbioteSharedPubSub&&this.effectiveCtxName&&this._initSharedContext(),this._symbioteSharedPubSub&&this._applyPendingSharedAdds(),this._symbioteSharedPubSub}_requireSharedPubSub(){let r=this._getSharedPubSub();if(!r)throw new Error("SymbioteMixin: Shared context is not initialized.");return r}_initSharedContext(){let r=this._getSharedSchemaRecord(),s=this.effectiveCtxName;if(!s){console.error("SymbioteMixin: ctx-name is required for components with shared properties (*)");return}if(!this._symbioteSharedPubSub){this._symbioteSharedPubSub=U.getCtx(s,!1),this._symbioteSharedPubSub||(this._symbioteSharedPubSub=U.registerCtx(r,s));for(let[n,a]of Object.entries(r))this._symbioteSharedPubSub.add(n,a,this.ctxOwner);this._applyPendingSharedAdds()}}get sharedCtx(){return this._requireSharedPubSub()}get $(){return this.effectiveCtxName&&this._initSharedContext(),new Proxy({},{get:(r,s)=>{if(typeof s!="string")return;let n=this._requireSharedKey(s);return this._symbioteSharedPubSub?.read(n)},set:(r,s,n)=>{if(typeof s!="string")return!0;let a=this._requireSharedKey(s);return this._symbioteSharedPubSub?.pub(a,n),!0}})}sub(r,s,n=!0){let a=this._requireSharedKey(r),l=this._requireSharedPubSub().sub(a,s,n);if(!l||typeof l.remove!="function")return()=>{};let d=l.remove.bind(l),u=!1,p=()=>{u||(u=!0,d(),this._symbioteSubscriptions.delete(p))};return this._symbioteSubscriptions.add(p),p}pub(r,s){let n=this._requireSharedKey(r);this._requireSharedPubSub().pub(n,s)}set$(r){for(let[s,n]of Object.entries(r))this.pub(s,n)}has(r){let s=this._requireSharedKey(r);return this._symbioteSharedPubSub?.has(s)??!1}add(r,s,n=!1){let a=this._requireSharedKey(r),l=this._getSharedPubSub();if(!l){if(!n&&this._pendingSharedAdds.has(a))return;this._pendingSharedAdds.set(a,{value:s,rewrite:n});return}this._pendingSharedAdds.delete(a),l.add(a,s,n)}add$(r,s=!1){for(let[n,a]of Object.entries(r))this.add(n,a,s)}connectedCallback(){super.connectedCallback(),this._symbioteFirstUpdated?this.isInitialized&&this._needsReconnectInit&&(this._needsReconnectInit=!1,this.initCallback()):this.ctxName?(this._pendingCtxInitOnConnect=!1,this._performInitialization()):this._pendingCtxInitOnConnect&&this.effectiveCtxName&&(this._pendingCtxInitOnConnect=!1,this._performInitialization())}_performInitialization(){if(this._symbioteFirstUpdated)return;this._symbioteFirstUpdated=!0,this._initSharedContext();let r=this._getSharedInitSchema();if(Object.keys(r).length>0){let s=this._requireSharedPubSub();for(let[n,a]of Object.entries(r)){let l=this._requireSharedKey(n);s.read(l)===void 0&&s.pub(l,a),this.sub(n,L(async()=>{await this.updateComplete,this.requestUpdate()},0),!1)}}this.initCallback(),this.isInitialized=!0,this.requestUpdate()}firstUpdated(r){super.firstUpdated(r)}updated(r){super.updated(r);let s=this._getSharedInitSchema();Object.keys(s).length>0&&r.forEach((n,a)=>{if(typeof a=="string"&&Object.hasOwn(s,a)){let l=this._requireSharedKey(a),d=this[a],u=this._symbioteSharedPubSub;u&&u.read(l)!==d&&u.pub(l,d)}})}disconnectedCallback(){this._cleanupSymbioteSubscriptions(),super.disconnectedCallback(),this._symbioteFirstUpdated&&(this._needsReconnectInit=!0)}_cleanupSymbioteSubscriptions(){if(this._symbioteSubscriptions.size!==0){for(let r of[...this._symbioteSubscriptions])r();this._symbioteSubscriptions.clear()}}initCallback(){}}return h([(0,c.property)({type:String,attribute:"ctx-name",noAccessor:!0})],i.prototype,"ctxNameAttr",1),h([(0,c.state)()],i.prototype,"_ctxNameFromContext",2),h([(0,c.state)()],i.prototype,"ctxName",2),h([(0,c.state)()],i.prototype,"isInitialized",2),i}var sl=o=>o.tagName?.includes("-")??!1,vi=class{constructor(i){this.host=i;this.trackedElements=new Set;this.originalValues=new Map;this.enabled=!1;this.host.addController(this)}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0,this.trackedElements.clear(),this.originalValues.clear()}hostUpdated(){if(!this.unsubscribe&&this.host.has(q("testMode"))){let i=this.host.subConfigValue("testMode",e=>{this.enabled=!!e,this.applyTestMode()});this.unsubscribe=i}this.collectElements(),this.applyTestMode()}collectElements(){let i=this.host,e=i.renderRoot??i;if(!e)return;let t=this.host,r=t.tagName?.toLowerCase(),s=Array.from(e.querySelectorAll("[data-testid]")).filter(n=>!sl(n));for(let n of s)if(!(r&&n.closest(r)!==t)&&!this.trackedElements.has(n)){let a=n.getAttribute("data-testid");if(!a)continue;this.trackedElements.add(n),this.originalValues.set(n,a)}for(let n of Array.from(this.trackedElements))(!n.isConnected||r&&n.closest(r)!==t)&&(this.trackedElements.delete(n),this.originalValues.delete(n))}applyTestMode(){if(!this.trackedElements.size)return;let i=this.host.testId||"";for(let e of this.trackedElements){let t=this.originalValues.get(e);t&&(this.enabled?e.setAttribute("data-testid",`${i}--${t}`):e.removeAttribute("data-testid"))}}};var nl=fi(as(mi(ss(m.LitElement)))),T=class extends nl{constructor(){super();this.activityType=null;this.init$=gr();new vi(this)}static{this.styleAttrs=[]}l10n(e,t={}){if(!e)return"";let r=this.$[Ne(e)]||e,s=is(r);for(let a of s)t[a.variable]=this.pluralize(a.pluralKey,Number(t[a.countVariable]));return Pt(r,t)}pluralize(e,t){let r=this.l10n("locale-id")||"en",s=hi(r,t);return this.l10n(`${e}__${s}`)}emit(e,t,r){let s=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;if(!s)return;s.emit(e,t,r);let n=typeof t=="function"?t():t;this.telemetryManager.sendEvent({eventType:e,payload:n??void 0})}hasBlockInCtx(e){for(let t of this.blocksRegistry)if(e(t))return!0;return!1}setOrAddState(e,t){this.add$({[e]:t},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(t=>{this.setAttribute(t,"")}),super.connectedCallback(),Ut.registerClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new oi(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new ni(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new pi(this)),this.has("*a11y")||this.add("*a11y",new si),this.has("*modalManager")||this.add("*modalManager",new Qt(this)),this.sub(Ne("locale-id"),t=>{let r=es(t);this.style.direction=r==="ltr"?"":r,this.requestUpdate()}),this.subConfigValue("testMode",t=>{if(!t||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId)})}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this.has("*modalManager")?this.$["*modalManager"]:void 0}get telemetryManager(){return this.cfg.qualityInsights?this.has("*telemetryManager")&&this.$["*telemetryManager"]:{sendEvent:()=>{},sendEventCloudImageEditor:()=>{},sendEventError:()=>{}}}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}disconnectedCallback(){super.disconnectedCallback(),Ut.unregisterClient(this);let e=this.blocksRegistry;e?.delete(this),e?.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){U.deleteCtx(this.ctxName),this.modalManager?.destroy()}async proxyUrl(e){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(e,{uuid:di(e),cdnUrlModifiers:xr(e),fileName:ci(e)})}catch(t){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",t),this.telemetryManager.sendEventError(t,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?Pt(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:t=>window.encodeURIComponent(t)}):e}get cfg(){if(!this.__cfgProxy){let e={};this.__cfgProxy=new Proxy(e,{set:(t,r,s)=>{if(typeof r!="string"||!(r in se))return!1;let n=r,a=q(n);return this.has(a)||this.add(a,se[n]),this.$[a]=s,!0},get:(t,r)=>{let s=q(r);return this.has(s)||this.add(s,se[r]),this.$[s]}})}return this.__cfgProxy}subConfigValue(e,t){let r=q(e);return this.has(r)||this.add(r,se[e]),this.sub(r,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof e?.[0]=="function"){let r=e[0];t=r()}console.log(`[${this.ctxName}]`,...t)}};var ls="active",pt="___ACTIVITY_IS_ACTIVE___",cs,_=class o extends(cs=T,pt,cs){constructor(){super(...arguments);this.historyTracked=!1;this.init$=vr(this);this._debouncedHistoryFlush=L(this._historyFlush.bind(this),10)}_deactivate(){let e=o._activityCallbacks.get(this);this[pt]=!1,this.removeAttribute(ls),e?.deactivateCallback?.()}_activate(){let e=o._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[pt]=!0,this.setAttribute(ls,""),e?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(I.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{try{this.activityType!==e&&this[pt]?this._deactivate():this.activityType===e&&!this[pt]&&this._activate()}catch(t){this.telemetryManager.sendEventError(t,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,t),this.$["*currentActivity"]=this.$["*history"][this.$["*history"].length-1]??null}e||(this.$["*history"]=[])}))}_historyFlush(){let e=this.$["*history"];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)}_isActivityRegistered(){return!!this.activityType&&o._activityCallbacks.has(this)}static{this._activityCallbacks=new Map}get isActivityActive(){return!!this[pt]}get couldOpenActivity(){return!0}registerActivity(e,t={}){let{onActivate:r,onDeactivate:s}=t;o._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:s})}unregisterActivity(){this.isActivityActive&&this._deactivate(),o._activityCallbacks.delete(this)}disconnectedCallback(){super.disconnectedCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];this.blocksRegistry&&([...this.blocksRegistry].find(r=>r instanceof o&&r.activityType===e)||(this.$["*currentActivity"]=null,this.modalManager?.closeAll()))}get activityKey(){return this.ctxName+this.activityType}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")??null}get doneActivity(){return this.getCssData("--cfg-done-activity")??null}historyBack(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let r=!!t;t&&(r=[...this.blocksRegistry].find(n=>n.activityType===t)?.couldOpenActivity??!1),t=r?t:void 0,t&&this.modalManager?.open(t),this.$["*currentActivity"]=t??null,this.$["*history"]=e,t||this.modalManager?.closeAll()}}};_.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var kr=class extends _{};var ds=o=>typeof o!="number"?0:Math.floor(o/1e3),us=(o,{threshold:i})=>{let{secureExpire:e}=o,t=ds(Date.now()),r=Number(e),s=ds(i);return t+s>=r};var yi=class{constructor(i){this._secureToken=null;this._block=i}_debugPrint(...i){this._block.debugPrint("[secure-uploads]",...i)}async getSecureToken(){let{secureSignature:i,secureExpire:e,secureUploadsSignatureResolver:t}=this._block.cfg;if((i||e)&&t&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),t){if(!this._secureToken||us(this._secureToken,{threshold:this._block.cfg.secureUploadsExpireThreshold})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let r=await t();r?!r.secureSignature||!r.secureExpire?console.error("Secure signature resolver returned an invalid result:",r):(this._debugPrint("Secure signature resolved:",r),this._debugPrint("Secure signature will expire in",new Date(Number(r.secureExpire)*1e3).toISOString()),this._secureToken=r):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(r){console.error("Secure signature resolving failed. Falling back to the previous one.",r),this._block.telemetryManager.sendEventError(r,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.")}}return this._secureToken}return i&&e?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:i,secureExpire:e}),{secureSignature:i,secureExpire:e}):null}};var Or=(o,i)=>{if(o.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:i.l10n("some-files-were-not-uploaded")}};var Mr=(o,i)=>{let e=o.totalCount,t=i.cfg.multiple?i.cfg.multipleMin:0,r=i.cfg.multiple?i.cfg.multipleMax:1;if(t&&e<t)return{type:"TOO_FEW_FILES",message:i.l10n("files-count-limit-error-too-few",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}};if(r&&e>r)return{type:"TOO_MANY_FILES",message:i.l10n("files-count-limit-error-too-many",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}}};var al=()=>{let o=navigator.userAgent;return/Macintosh|Windows/.test(o)&&/Version\/[\d.]+.*Safari/.test(o)&&!/Chrome|Chromium|Edg|OPR/.test(o)},ll=()=>"capture"in document.createElement("input"),cl=()=>({safariDesktop:al()}),dl=()=>({htmlMediaCapture:ll()}),ps=cl(),et=dl();var $t="image/*",Lr="video/*",ul=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],pl=()=>ps.safariDesktop?[$t]:[$t,...ul],Dt=pl(),bi=o=>o?o.filter(i=>typeof i=="string").flatMap(i=>j(i)):[],Rr=(o,i)=>i.some(e=>{if(e.endsWith("*")){let t=e.replace("*","");return o.startsWith(t)}return o===e}),hs=(o,i)=>i.some(e=>e.startsWith(".")?o.toLowerCase().endsWith(e.toLowerCase()):!1),ms=o=>{let i=o?.type;return i?Rr(i,Dt):!1};var Pr=(o,i)=>{let e=i.cfg.imgOnly,t=i.cfg.accept,r=bi([...e?Dt:[],t]);if(!r.length)return;let s=o.mimeType,n=o.name;if(!s||!n)return;let a=Rr(s,r),l=hs(n,r);if(!a&&!l)return{type:"FORBIDDEN_FILE_TYPE",message:i.l10n("file-type-not-allowed"),payload:{entry:o}}};var Ur=(o,i)=>{let e=i.cfg.imgOnly,t=o.isImage;if(!(!e||t)&&!(!o.fileInfo&&o.externalUrl)&&!(!o.fileInfo&&!o.mimeType))return{type:"NOT_AN_IMAGE",message:i.l10n("images-only-accepted"),payload:{entry:o}}};var Te=1e3,tt=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),Vt=o=>Math.ceil(o*100)/100,fs=(o,i=tt.AUTO)=>{let e=i===tt.AUTO;if(i===tt.BYTE||e&&o<Te**1){let r=hi("en-US",o)==="one"?"byte":"bytes";return`${o} ${r}`}return i===tt.KB||e&&o<Te**2?`${Vt(o/Te**1)} KB`:i===tt.MB||e&&o<Te**3?`${Vt(o/Te**2)} MB`:i===tt.GB||e&&o<Te**4?`${Vt(o/Te**3)} GB`:i===tt.TB||e&&o<Te**5?`${Vt(o/Te**4)} TB`:`${Vt(o/Te**5)} PB`};var $r=(o,i)=>{let e=i.cfg.maxLocalFileSizeBytes,t=o.size;if(e&&t&&t>e)return{type:"FILE_SIZE_EXCEEDED",message:i.l10n("files-max-size-limit-error",{maxFileSize:fs(e)}),payload:{entry:o}}};var Dr=(o,i)=>{let{internalId:e}=o,r=i._uploadCollection.read(e)?.getValue("uploadError");if(!r)return;if(r instanceof Q)return{type:"UPLOAD_ERROR",message:r.message,payload:{entry:o,error:r}};if(r instanceof lt)return{type:"NETWORK_ERROR",message:r.message,payload:{entry:o,error:r}};let s=r instanceof Error?r:new Error("Unknown error",{cause:r});return{type:"UNKNOWN_ERROR",message:s.message,payload:{entry:o,error:s}}};var gs=()=>{let o=()=>{},i=()=>{};return{promise:new Promise((t,r)=>{o=t,i=r}),resolve:o,reject:i}};var ht={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},hl=o=>typeof o=="function"?{runOn:"change",validator:o}:o,_i=class{constructor(i){this._commonFileValidators=[Ur,Pr,$r,Dr];this._commonCollectionValidators=[Mr,Or];this._queue=new De(20);this._runQueueDebounced=L(()=>{this._queue.run()},500);this._entryValidationState=new Map;this._blockInstance=i,this._uploadCollection=this._blockInstance.uploadCollection;let e=L(()=>{this.runFileValidators("change"),this.runCollectionValidators()},0);this._blockInstance.subConfigValue("maxLocalFileSizeBytes",e),this._blockInstance.subConfigValue("multipleMin",e),this._blockInstance.subConfigValue("multipleMax",e),this._blockInstance.subConfigValue("multiple",e),this._blockInstance.subConfigValue("imgOnly",e),this._blockInstance.subConfigValue("accept",e),this._blockInstance.subConfigValue("validationConcurrency",t=>{this._queue.concurrency=t})}runFileValidators(i,e){let t=e??this._uploadCollection.items();for(let r of t){let s=this._uploadCollection.read(r);s&&this._runFileValidatorsForEntry(s,i)}}runCollectionValidators(){let i=this._blockInstance.api.getOutputCollectionState(),e=[];for(let t of[...this._commonCollectionValidators,...this._blockInstance.cfg.collectionValidators])try{let r=t(i,this._blockInstance.api);if(!r)continue;r&&(e.push(this._addCustomTypeToValidationError(r)),r.message||console.warn(ht.MISSING_ERROR_MESSAGE))}catch(r){console.warn(ht.COLLECTION_VALIDATION_FAILED,r)}this._blockInstance.$["*collectionErrors"]=e,e.length>0&&this._blockInstance.emit(I.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}cleanupValidationForEntry(i){let e=this._entryValidationState.get(i.uid);e&&(e.abortController?.abort(),this._entryValidationState.delete(i.uid))}async _runFileValidatorsForEntry(i,e){let t=this._getValidatorDescriptorsForEntry(i,e);if(t.length===0)return;i.setMultipleValues({isQueuedForValidation:!0,isValidationPending:!0});let r=this._blockInstance.api.getOutputItem(i.uid),s=this._getEntryValidationState(i);s.promise&&await s.promise;let{promise:n,resolve:a}=gs();s.promise=n;let l=new AbortController;s.abortController=l;let d=this._blockInstance.cfg.validationTimeout,u=this._getValidatorDescriptors(),p=new Set(t.map(y=>y.validator)),f=[];for(let y of u)if(!p.has(y.validator)){let w=s.lastErrorThrownByValidator.get(y.validator);w&&f.push(w)}let g=t.map(y=>async()=>{if(!this._blockInstance.isConnected)return;let w=setTimeout(()=>{s.skippedValidators.add(y.validator),l.abort(),console.warn(ht.FILE_VALIDATION_TIMEOUT)},d);try{let C=await y.validator(r,this._blockInstance.api,{signal:l.signal});if(!C||l.signal.aborted){s.lastErrorThrownByValidator.set(y.validator,void 0);return}let E=this._addCustomTypeToValidationError(C);s.lastErrorThrownByValidator.set(y.validator,E),f.push(E),C.message||console.warn(ht.MISSING_ERROR_MESSAGE)}catch(C){l.signal.aborted||(s.skippedValidators.add(y.validator),console.warn(ht.FILE_VALIDATION_FAILED,C),this._blockInstance.telemetryManager.sendEventError(C,`file validator. ${ht.FILE_VALIDATION_FAILED}`))}finally{clearTimeout(w),y.runOn!=="change"&&s.skippedValidators.add(y.validator)}});if(this._runQueueDebounced(),await this._queue.add(async()=>{i.setValue("isQueuedForValidation",!1),await Promise.all(g.map(y=>y())).catch(()=>{})},{autoRun:!1}),l.signal.aborted){i.setMultipleValues({isQueuedForValidation:!1,isValidationPending:!1}),a();return}i.setMultipleValues({isValidationPending:!1,isQueuedForValidation:!1,errors:f}),a()}_addCustomTypeToValidationError(i){return{...i,type:i.type??"CUSTOM_ERROR"}}_getEntryValidationState(i){let e=this._entryValidationState.get(i.uid);if(e)return e;let t={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(i.uid,t),t}_getValidatorDescriptors(){return[...this._commonFileValidators,...this._blockInstance.cfg.fileValidators].map(hl)}_getValidatorDescriptorsForEntry(i,e){let t=this._getEntryValidationState(i);return this._getValidatorDescriptors().filter(r=>!t.skippedValidators.has(r.validator)).filter(r=>r.runOn===e)}};var vs="[Typed State] Wrong property name: ",ml="[Typed State] Wrong property type: ",wi=class{constructor(i,e){this.__typedSchema=i,this.__ctxId=e||ge.generate(),this.__schema=Object.keys(i).reduce((t,r)=>(i[r]&&(t[r]=i[r].value),t),{}),this.__data=U.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(i,e){if(!Object.hasOwn(this.__typedSchema,i)||!this.__typedSchema[i]){console.warn(vs+i);return}let t=this.__typedSchema[i],r=this.__data.read(i)!==e,s=e?.constructor===t.type,n=e instanceof t.type,a=t.nullable&&e===null;if(r&&(s||n||a)){this.__data.pub(i,e);return}else r&&console.warn(ml+i)}setMultipleValues(i){for(let[e,t]of Object.entries(i))this.setValue(e,t)}getValue(i){return Object.hasOwn(this.__typedSchema,i)||console.warn(vs+i),this.__data.read(i)}subscribe(i,e){return this.__data.sub(i,e)}remove(){U.deleteCtx(this.__ctxId)}};var Ci=class{constructor(i){this.__subsMap=Object.create(null);this.__propertyObservers=new Set;this.__collectionObservers=new Set;this.__items=new Set;this.__removed=new Set;this.__added=new Set;this.__typedSchema=i.typedSchema,this.__ctxId=i.ctxName||ge.generate(),this.__data=U.registerCtx({},this.__ctxId),this.__watchList=i.watchList||[];let e=Object.create(null);this.__notifyObservers=(t,r)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[t]||(e[t]=new Set),e[t].add(r),this.__observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this.__propertyObservers.forEach(s=>{s({...e})}),e=Object.create(null))})},i.handler&&this.observeCollection(i.handler)}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let i=new Set(this.__added),e=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(let t of this.__collectionObservers)t?.([...this.__items],i,e)})}observeCollection(i){return this.__collectionObservers.add(i),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(i)}}unobserveCollection(i){this.__collectionObservers.delete(i)}add(i){let e=new wi(this.__typedSchema);for(let[t,r]of Object.entries(i))r!==void 0&&e.setValue(t,r);return this.__items.add(e.uid),this.notify(),this.__data.add(e.uid,e),this.__added.add(e),this.__watchList.forEach(t=>{this.__subsMap[e.uid]||(this.__subsMap[e.uid]=[]),this.__subsMap[e.uid]?.push(e.subscribe(t,()=>{this.__notifyObservers(t,e.uid)}))}),e.uid}read(i){return this.__data.read(i)}readProp(i,e){let t=this.read(i);return t?t.getValue(e):(console.warn(`Item with id ${i} not found`),null)}publishProp(i,e,t){let r=this.read(i);if(!r){console.warn(`Item with id ${i} not found`);return}r.setValue(e,t)}remove(i){let e=this.read(i);e&&this.__removed.add(e),this.__items.delete(i),this.notify(),this.__data.pub(i,null),delete this.__subsMap[i]}clearAll(){this.__items.forEach(i=>{this.remove(i)})}observeProperties(i){return this.__propertyObservers.add(i),()=>{this.unobserveProperties(i)}}unobserveProperties(i){this.__propertyObservers.delete(i)}findItems(i){let e=[];return this.__items.forEach(t=>{let r=this.read(t);r&&i(r)&&e.push(t)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){U.deleteCtx(this.__ctxId),this.__propertyObservers=new Set,this.__collectionObservers=new Set;for(let i in this.__subsMap)this.__subsMap[i]?.forEach(e=>{e.remove()}),delete this.__subsMap[i]}};var S=Object.freeze({PHOTO:"photo",VIDEO:"video"}),he=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Vr=o=>({isVideoRecordingEnabled:oe(o.cameraModes).includes(S.VIDEO),isPhotoEnabled:oe(o.cameraModes).includes(S.PHOTO)});var fl=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,gl=new RegExp(`^/?(${fl.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),ys=({url:o,cdnBase:i})=>{let e=new URL(i),t=new URL(Rt),r=new URL(o);if(e.host!==r.host&&t.host!==r.host)return null;let s=gl.exec(r.pathname);if(!s)return null;let[,n,a,l]=s;return n?{uuid:n,cdnUrlModifiers:a||"",filename:l||null}:null};var Ee=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Fr=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),B=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Fr,...Ee});function bs(o){let i=new Map;return(...t)=>{let r=JSON.stringify(t);if(i.has(r))return i.get(r);let s=o(...t);return i.set(r,s),s}}var _s=new Set;function Ti(o){_s.has(o)||(_s.add(o),console.warn(o))}function vl(o){let i=!1;return setTimeout(()=>{i=!0},0),t=>((...r)=>(i&&Ti(o),t(...r)))}function ws(o){let i={},e={progress:()=>o.$["*commonProgress"],errors:()=>o.$["*collectionErrors"],group:()=>o.$["*groupInfo"],totalCount:()=>o.uploadCollection.size,failedCount:()=>i.failedEntries.length,successCount:()=>i.successEntries.length,uploadingCount:()=>i.uploadingEntries.length,status:()=>i.isFailed?"failed":i.isUploading?"uploading":i.isSuccess?"success":"idle",isSuccess:()=>i.allEntries.length>0&&i.errors.length===0&&i.successEntries.length===i.allEntries.length,isUploading:()=>i.allEntries.some(r=>r.status==="uploading"),isFailed:()=>i.errors.length>0||i.failedEntries.length>0,allEntries:()=>o.getOutputData(),successEntries:()=>i.allEntries.filter(r=>r.status==="success"),failedEntries:()=>i.allEntries.filter(r=>r.status==="failed"),uploadingEntries:()=>i.allEntries.filter(r=>r.status==="uploading"),idleEntries:()=>i.allEntries.filter(r=>r.status==="idle")},t=vl("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it 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}`");for(let[r,s]of Object.entries(e)){let n=r,l=bs(t(s));Object.defineProperty(i,n,{get:l,enumerable:!0})}return i}var Ei=class{constructor(i){this.addFileFromUrl=(i,{silent:e,fileName:t,source:r}={})=>{let s=this._uploadCollection.add({externalUrl:i,fileName:t??null,silent:e??!1,source:r??B.API});return this.getOutputItem(s)};this.addFileFromUuid=(i,{silent:e,fileName:t,source:r}={})=>{let s=this._uploadCollection.add({uuid:i,fileName:t??null,silent:e??!1,source:r??B.API});return this.getOutputItem(s)};this.addFileFromCdnUrl=(i,{silent:e,fileName:t,source:r}={})=>{let s=ys({url:i,cdnBase:this.cfg.cdnCname});if(!s)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:s.uuid,cdnUrl:i,cdnUrlModifiers:s.cdnUrlModifiers,fileName:t??s.filename??null,silent:e??!1,source:r??B.API});return this.getOutputItem(n)};this.addFileFromObject=(i,{silent:e,fileName:t,source:r,fullPath:s}={})=>{let n=this._uploadCollection.add({file:i,isImage:ms(i),mimeType:i.type,fileName:t??i.name,fileSize:i.size,silent:e??!1,source:r??B.API,fullPath:s??null});return this.getOutputItem(n)};this.removeFileByInternalId=i=>{if(!this._uploadCollection.read(i))throw new Error(`File with internalId ${i} not found`);this._uploadCollection.remove(i)};this.uploadAll=()=>{let i=this._uploadCollection.items().filter(e=>{let t=this._uploadCollection.read(e);return t?!t.getValue("isRemoved")&&!t.getValue("isUploading")&&!t.getValue("fileInfo")&&t.getValue("errors").length===0&&!t.getValue("isValidationPending")&&!t.getValue("isQueuedForValidation"):!1});i.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(i),this._ctx.emit(I.COMMON_UPLOAD_START,this.getOutputCollectionState()))};this.openSystemDialog=(i={})=>{let e=Me(bi([this.cfg.accept??"",...this.cfg.imgOnly?Dt:[]])),t="uploadcare-file-input",r=document.createElement("input");if(r.setAttribute(t,""),kt(r,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),r.type="file",r.multiple=this.cfg.multiple,i.captureCamera){r.capture=this.cfg.cameraCapture;let{isPhotoEnabled:s,isVideoRecordingEnabled:n}=Vr(this.cfg);i.modeCamera===S.PHOTO&&s?r.accept=$t:i.modeCamera===S.VIDEO&&n?r.accept=Lr:r.accept=[$t,n&&Lr].filter(Boolean).join(",")}else r.accept=e;r.addEventListener("change",()=>{r.files&&([...r.files].forEach(s=>{this.addFileFromObject(s,{source:i.captureCamera?B.CAMERA:B.LOCAL})}),this._ctx.modalManager?.open(_.activities.UPLOAD_LIST),this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,r.remove())},{once:!0}),document.querySelectorAll(`[${t}]`).forEach(s=>{s.remove()}),document.body.appendChild(r),r.dispatchEvent(new MouseEvent("click"))};this.initFlow=(i=!1)=>{if(this._uploadCollection.size>0&&!i)this._ctx.modalManager?.open(_.activities.UPLOAD_LIST),this._ctx.set$({"*currentActivity":_.activities.UPLOAD_LIST});else if(this._sourceList?.length===1){let e=this._sourceList[0];if(e==="local"){this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.openSystemDialog();return}if(e==="camera"&&et.htmlMediaCapture){let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=Vr(this.cfg);if(n&&a){this._ctx.set$({"*currentActivity":_.activities.START_FROM});return}else if(n||a){this.openSystemDialog({captureCamera:!0,modeCamera:n?S.PHOTO:S.VIDEO});return}else this.openSystemDialog({captureCamera:!0,modeCamera:S.PHOTO})}let t=this._ctx.$["*blocksRegistry"],r=n=>"type"in n&&n.type===e;[...t].find(r)?.activate(),this._ctx.$["*currentActivity"]&&this._ctx.modalManager?.open(this._ctx.$["*currentActivity"])}else this._ctx.modalManager?.open(_.activities.START_FROM),this._ctx.set$({"*currentActivity":_.activities.START_FROM})};this.doneFlow=()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.modalManager?.closeAll()};this.setCurrentActivity=(i,...e)=>{if(this._ctx.hasBlockInCtx(t=>t.activityType===i)){this._ctx.set$({"*currentActivityParams":e??{},"*currentActivity":i});return}console.warn(`Activity type "${i}" not found in the context`)};this.getCurrentActivity=()=>this._ctx.$["*currentActivity"];this.setModalState=i=>{if(i&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}i?this._ctx.modalManager?.open(this._ctx.$["*currentActivity"]):(this._ctx.modalManager?.close(this._ctx.$["*currentActivity"]),this._ctx.$["*currentActivity"]=null)};this._ctx=i}get _uploadCollection(){return this._ctx.uploadCollection}get cfg(){return this._ctx.cfg}get l10n(){return this._ctx.l10n.bind(this._ctx)}removeAllFiles(){this._uploadCollection.clearAll()}getOutputItem(i){let e=U.getCtx(i).store,t=e.fileInfo,r=e.isRemoved?"removed":e.errors.length>0?"failed":e.fileInfo?"success":e.isUploading?"uploading":"idle";return{uuid:t?.uuid??e.uuid??null,internalId:i,name:t?.originalFilename??e.fileName,size:t?.size??e.fileSize,isImage:t?.isImage??e.isImage,mimeType:t?.mimeType??e.mimeType,file:e.file,externalUrl:e.externalUrl,cdnUrlModifiers:e.cdnUrlModifiers,cdnUrl:e.cdnUrl??t?.cdnUrl??null,fullPath:e.fullPath,uploadProgress:e.uploadProgress,fileInfo:t??null,metadata:e.metadata??t?.metadata??null,isSuccess:r==="success",isUploading:r==="uploading",isFailed:r==="failed",isRemoved:r==="removed",isValidationPending:e.isValidationPending,errors:e.errors,status:r,source:e?.source}}getOutputCollectionState(){return ws(this._ctx)}get _sourceList(){let i=[];return this.cfg.sourceList&&(i=j(this.cfg.sourceList)),i}};var Cs=Object.freeze({file:Object.freeze({type:File,value:null,nullable:!0}),externalUrl:Object.freeze({type:String,value:null,nullable:!0}),fileName:Object.freeze({type:String,value:null,nullable:!0}),fileSize:Object.freeze({type:Number,value:null,nullable:!0}),lastModified:Object.freeze({type:Number,value:Date.now()}),uploadProgress:Object.freeze({type:Number,value:0}),uuid:Object.freeze({type:String,value:null,nullable:!0}),isImage:Object.freeze({type:Boolean,value:!1}),mimeType:Object.freeze({type:String,value:null,nullable:!0}),ctxName:Object.freeze({type:String,value:null,nullable:!0}),cdnUrl:Object.freeze({type:String,value:null,nullable:!0}),cdnUrlModifiers:Object.freeze({type:String,value:null,nullable:!0}),fileInfo:Object.freeze({type:ke,value:null,nullable:!0}),isUploading:Object.freeze({type:Boolean,value:!1}),abortController:Object.freeze({type:AbortController,value:null,nullable:!0}),thumbUrl:Object.freeze({type:String,value:null,nullable:!0}),silent:Object.freeze({type:Boolean,value:!1}),source:Object.freeze({type:String,value:null,nullable:!0}),fullPath:Object.freeze({type:String,value:null,nullable:!0}),metadata:Object.freeze({type:Object,value:null,nullable:!0}),errors:Object.freeze({type:Array,value:[]}),uploadError:Object.freeze({type:Error,value:null,nullable:!0}),isRemoved:Object.freeze({type:Boolean,value:!1}),isQueuedForUploading:Object.freeze({type:Boolean,value:!1}),isValidationPending:Object.freeze({type:Boolean,value:!1}),isQueuedForValidation:Object.freeze({type:Boolean,value:!1})});var Ft=33.333333333333336,A=1,Nr=24,Ts=6;function Ge(o,i){for(let[e,t]of Object.entries(i))o.setAttributeNS(null,e,t.toString())}function ae(o,i={}){let e=document.createElementNS("http://www.w3.org/2000/svg",o);return Ge(e,i),e}function Es(o,i,e){let{x:t,y:r,width:s,height:n}=o,a=i.includes("w")?0:1,l=i.includes("n")?0:1,d=a===0?-1:1,u=l===0?-1:1,p=[t+a*s+1.5*d,r+l*n+1.5*u-24*e*u],f=[t+a*s+1.5*d,r+l*n+1.5*u],g=[t+a*s-24*e*d+1.5*d,r+l*n+1.5*u],y=`M ${p[0]} ${p[1]} L ${f[0]} ${f[1]} L ${g[0]} ${g[1]}`,w=[f[0],f[1]];return{d:y,center:w}}function xs(o,i,e){let{x:t,y:r,width:s,height:n}=o,a=i==="n"||i==="s",l=i==="w"||i==="e",d=a?.5:i==="w"?0:1,u=l?.5:i==="n"?0:1,p=i==="w"?-1:i==="e"?1:0,f=i==="n"?-1:i==="s"?1:0,g,y;a?(g=[t+d*s-34*e/2,r+u*n+1.5*f],y=[t+d*s+34*e/2,r+u*n+1.5*f]):(g=[t+d*s+1.5*p,r+u*n-34*e/2],y=[t+d*s+1.5*p,r+u*n+34*e/2]);let w=`M ${g[0]} ${g[1]} L ${y[0]} ${y[1]}`,C=[(g[0]+y[0])/2,(g[1]+y[1])/2];return{d:w,center:C}}function Ss(o){return o===""?"move":["e","w"].includes(o)?"ew-resize":["n","s"].includes(o)?"ns-resize":["nw","se"].includes(o)?"nwse-resize":"nesw-resize"}function As({rect:o,delta:[i,e],imageBox:t}){return ft({...o,x:o.x+i,y:o.y+e},t)}function ft(o,i){let{x:e}=o,{y:t}=o;return o.x<i.x?e=i.x:o.x+o.width>i.x+i.width&&(e=i.x+i.width-o.width),o.y<i.y?t=i.y:o.y+o.height>i.y+i.height&&(t=i.y+i.height-o.height),{...o,x:e,y:t}}function yl({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:s,width:n,height:a}=o;s+=r,a-=r,e&&(n=a*e);let l=o.x+o.width/2-n/2;return s<=t.y&&(s=t.y,a=o.y+o.height-s,e&&(n=a*e,l=o.x+o.width/2-n/2)),l<=t.x&&(l=t.x,s=o.y+o.height-a),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),s=o.y+o.height-a),a<A&&(a=A,e&&(n=a*e,l=o.x+o.width/2-n/2),s=o.y+o.height-a),n<A&&(n=A,e&&(a=n/e,l=o.x+o.width/2-n/2),s=o.y+o.height-a),{x:l,y:s,width:n,height:a}}function bl({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:s,width:n,height:a}=o;s+=r,n-=r,e&&(a=n/e);let l=o.y+o.height/2-a/2;return s<=t.x&&(s=t.x,n=o.x+o.width-s,e&&(a=n/e,l=o.y+o.height/2-a/2)),l<=t.y&&(l=t.y,s=o.x+o.width-n),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),s=o.x+o.width-n),a<A&&(a=A,e&&(n=a*e),l=o.y+o.height/2-a/2,s=o.x+o.width-n),n<A&&(n=A,e&&(a=n/e),l=o.y+o.height/2-a/2,s=o.x+o.width-n),{x:s,y:l,width:n,height:a}}function _l({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:s,width:n,height:a}=o;a+=r,e&&(n=a*e);let l=o.x+o.width/2-n/2;return s+a>=t.y+t.height&&(a=t.y+t.height-s,e&&(n=a*e),l=o.x+o.width/2-n/2),l<=t.x&&(l=t.x,s=o.y),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),s=o.y),a<A&&(a=A,e&&(n=a*e),l=o.x+o.width/2-n/2),n<A&&(n=A,e&&(a=n/e),l=o.x+o.width/2-n/2),{x:l,y:s,width:n,height:a}}function wl({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:s,width:n,height:a}=o;n+=r,e&&(a=n/e);let l=o.y+o.height/2-a/2;return s+n>=t.x+t.width&&(n=t.x+t.width-s,e&&(a=n/e),l=o.y+o.height/2-a/2),l<=t.y&&(l=t.y,s=o.x),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),s=o.x),a<A&&(a=A,e&&(n=a*e),l=o.y+o.height/2-a/2),n<A&&(n=A,e&&(a=n/e),l=o.y+o.height/2-a/2),{x:s,y:l,width:n,height:a}}function Cl({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[r,s]=i,{x:n,y:a,width:l,height:d}=o;return n+r<t.x&&(r=t.x-n),a+s<t.y&&(s=t.y-a),n+=r,l-=r,a+=s,d-=s,e&&Math.abs(l/d)>e?(s=l/e-d,d+=s,a-=s,a<=t.y&&(d=d-(t.y-a),l=d*e,n=o.x+o.width-l,a=t.y)):e&&(r=d*e-l,l=l+r,n-=r,n<=t.x&&(l=l-(t.x-n),d=l/e,n=t.x,a=o.y+o.height-d)),d<A&&(d=A,e&&(l=d*e),n=o.x+o.width-l,a=o.y+o.height-d),l<A&&(l=A,e&&(d=l/e),n=o.x+o.width-l,a=o.y+o.height-d),{x:n,y:a,width:l,height:d}}function Tl({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[r,s]=i,{x:n,y:a,width:l,height:d}=o;return n+l+r>t.x+t.width&&(r=t.x+t.width-n-l),a+s<t.y&&(s=t.y-a),l+=r,a+=s,d-=s,e&&Math.abs(l/d)>e?(s=l/e-d,d+=s,a-=s,a<=t.y&&(d=d-(t.y-a),l=d*e,n=o.x,a=t.y)):e&&(r=d*e-l,l+=r,n+l>=t.x+t.width&&(l=t.x+t.width-n,d=l/e,n=t.x+t.width-l,a=o.y+o.height-d)),d<A&&(d=A,e&&(l=d*e),a=o.y+o.height-d),l<A&&(l=A,e&&(d=l/e),a=o.y+o.height-d),{x:n,y:a,width:l,height:d}}function El({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[r,s]=i,{x:n,y:a,width:l,height:d}=o;return n+r<t.x&&(r=t.x-n),a+d+s>t.y+t.height&&(s=t.y+t.height-a-d),n+=r,l-=r,d+=s,e&&Math.abs(l/d)>e?(s=l/e-d,d+=s,a+d>=t.y+t.height&&(d=t.y+t.height-a,l=d*e,n=o.x+o.width-l,a=t.y+t.height-d)):e&&(r=d*e-l,l+=r,n-=r,n<=t.x&&(l=l-(t.x-n),d=l/e,n=t.x,a=o.y)),d<A&&(d=A,e&&(l=d*e),n=o.x+o.width-l),l<A&&(l=A,e&&(d=l/e),n=o.x+o.width-l),{x:n,y:a,width:l,height:d}}function xl({rect:o,delta:i,aspectRatio:e,imageBox:t}){let[r,s]=i,{x:n,y:a,width:l,height:d}=o;return n+l+r>t.x+t.width&&(r=t.x+t.width-n-l),a+d+s>t.y+t.height&&(s=t.y+t.height-a-d),l+=r,d+=s,e&&Math.abs(l/d)>e?(s=l/e-d,d+=s,a+d>=t.y+t.height&&(d=t.y+t.height-a,l=d*e,n=o.x,a=t.y+t.height-d)):e&&(r=d*e-l,l+=r,n+l>=t.x+t.width&&(l=t.x+t.width-n,d=l/e,n=t.x+t.width-l,a=o.y)),d<A&&(d=A,e&&(l=d*e)),l<A&&(l=A,e&&(d=l/e)),{x:n,y:a,width:l,height:d}}function Is({direction:o,...i}){switch(o){case"n":return yl(i);case"w":return bl(i);case"s":return _l(i);case"e":return wl(i);case"nw":return Cl(i);case"ne":return Tl(i);case"sw":return El(i);case"se":return xl(i);default:return i.rect}}function ks(o,[i,e]){return o.x<=i&&i<=o.x+o.width&&o.y<=e&&e<=o.y+o.height}function Os(o,i){return o.x>=i.x&&o.y>=i.y&&o.x+o.width<=i.x+i.width&&o.y+o.height<=i.y+i.height}function Ms(o,i){return Math.abs(o.width/o.height-i)<.1}function gt({width:o,height:i},e){let t=e/90%2!==0;return{width:t?i:o,height:t?o:i}}function Ls(o,i,e){let t=o/i,r,s;t>e?(r=Math.round(i*e),s=i):(r=o,s=Math.round(o/e));let n=Math.round((o-r)/2),a=Math.round((i-s)/2);return n+r>o&&(r=o-n),a+s>i&&(s=i-a),{x:n,y:a,width:r,height:s}}function vt(o){return{x:Math.round(o.x),y:Math.round(o.y),width:Math.round(o.width),height:Math.round(o.height)}}function We(o,i,e){return Math.min(Math.max(o,i),e)}var Nt=["free"],Si=o=>{let i=j(o);if(!i||i.length===0)return[];let e=[];for(let t of i){let r=t.trim();if(!r)continue;let s=r.indexOf(":");if(s===-1&&!Nt.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}let n=Number(r.slice(0,s)),a=Number(r.slice(s+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!Nt.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}e.push({id:ge.generate(),type:"aspect-ratio",width:Nt.includes(r)?0:n,height:Nt.includes(r)?0:a,hasFreeform:Nt.includes(r)})}return e},Rs=(o,i,e,t=.1)=>{let r=o/i,s=null,n=1/0;for(let a of e){let[l,d]=[a.width,a.height],u=l/d,p=Math.abs(r-u);p<n&&(n=p,s=a)}if(s){let[a,l]=[s.width,s.height],d=a/l;if(Math.abs(r-d)/d>t)return null}return s};function Ps(o){return dr({...o,libraryName:He,libraryVersion:je})}var M=class o extends _{constructor(){super(...arguments);this.couldBeCtxOwner=!1;this.isCtxOwner=!1;this.init$=yr(this);this._flushOutputItems=L(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(I.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300);this._handleCollectionUpdate=(e,t,r)=>{(t.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...t].map(s=>s.uid));for(let s of t)s.getValue("silent")||this.emit(I.FILE_ADDED,this.api.getOutputItem(s.uid));this.validationManager.runCollectionValidators();for(let s of r){this.$["*uploadTrigger"].delete(s.uid),this.validationManager.cleanupValidationForEntry(s),s.getValue("abortController")?.abort(),s.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0});let n=s?.getValue("thumbUrl");n&&URL.revokeObjectURL(n),this.emit(I.FILE_REMOVED,this.api.getOutputItem(s.uid))}this.$["*uploadList"]=e.map(s=>({uid:s})),this._flushCommonUploadProgress(),this._flushOutputItems()};this._handleCollectionPropertiesUpdate=e=>{this._flushOutputItems();let t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([s])=>["uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(s)).flatMap(([,s])=>[...s]))];if(r.length>0&&setTimeout(()=>{let s=r.filter(n=>e.fileInfo?.has(n)&&!!U.getCtx(n).store.fileInfo);s.length>0&&this.validationManager.runFileValidators("upload",s),this.validationManager.runFileValidators("change",r)}),e.uploadProgress){for(let s of e.uploadProgress){let{isUploading:n,silent:a}=U.getCtx(s).store;n&&!a&&this.emit(I.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(s))}this._flushCommonUploadProgress()}if(e.isUploading)for(let s of e.isUploading){let{isUploading:n,silent:a}=U.getCtx(s).store;n&&!a&&this.emit(I.FILE_UPLOAD_START,this.api.getOutputItem(s))}if(e.fileInfo){for(let s of e.fileInfo){let{fileInfo:n,silent:a}=U.getCtx(s).store;n&&!a&&this.emit(I.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(s))}this.cfg.cropPreset&&this.setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this.openCloudImageEditor()}if(e.errors){this.validationManager.runCollectionValidators();for(let a of e.errors){let{errors:l}=U.getCtx(a).store;l.length>0&&(this.emit(I.FILE_UPLOAD_FAILED,this.api.getOutputItem(a)),this.emit(I.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let s=t.findItems(a=>!!a.getValue("fileInfo")),n=t.findItems(a=>a.getValue("errors").length>0);t.size>0&&n.length===0&&t.size===s.length&&this.$["*collectionErrors"].length===0&&this.emit(I.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}e.cdnUrl&&([...e.cdnUrl].filter(n=>!!this.uploadCollection.read(n)?.getValue("cdnUrl")).forEach(n=>{this.emit(I.FILE_URL_CHANGED,this.api.getOutputItem(n))}),this.$["*groupInfo"]=null)};this._flushCommonUploadProgress=()=>{let e=0,r=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));r.forEach(n=>{let a=this.uploadCollection.readProp(n,"uploadProgress");typeof a=="number"&&(e+=a)});let s=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==s&&(this.$["*commonProgress"]=s,this.emit(I.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))}}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof o?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new Ci({typedSchema:Cs,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new Ei(this)),this.has("*validationManager")||this.add("*validationManager",new _i(this)),!this.hasCtxOwner&&this.couldBeCtxOwner&&this._initCtxOwner()}get validationManager(){if(!this.has("*validationManager"))throw new Error("Unexpected error: ValidationManager is not initialized");return this.$["*validationManager"]}get api(){if(!this.has("*publicApi"))throw new Error("Unexpected error: UploaderPublicApi is not initialized");return this.$["*publicApi"]}getAPI(){return this.api}get uploadCollection(){if(!this.has("*uploadCollection"))throw new Error("Unexpected error: TypedCollection is not initialized");return this.$["*uploadCollection"]}destroyCtxCallback(){this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}disconnectedCallback(){super.disconnectedCallback(),this.isCtxOwner&&this._unobserveUploadCollection(),this._flushOutputItems.cancel()}connectedCallback(){super.connectedCallback(),this.isCtxOwner&&this._observeUploadCollection()}_initCtxOwner(){this.isCtxOwner=!0,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new yi(this))}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate)}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0}async _createGroup(e){let t=await this.getUploadClientOptions(),r=e.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),s=new AbortController,n=await Do(r,{...t,signal:s.signal});if(this.$["*collectionState"]!==e){s.abort();return}this.$["*groupInfo"]=n;let a=this.api.getOutputCollectionState();this.emit(I.GROUP_CREATED,a),this.emit(I.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=a}openCloudImageEditor(){let[e]=this.uploadCollection.findItems(t=>!!t.getValue("fileInfo")&&t.getValue("isImage")).map(t=>this.uploadCollection.read(t));e&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(t=>t.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:e.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT,this.modalManager?.open(_.activities.CLOUD_IMG_EDIT))}setInitialCrop(){let e=Si(this.cfg.cropPreset);if(e){let[t]=e,r=this.uploadCollection.findItems(s=>!!s.getValue("fileInfo")&&s.getValue("isImage")&&!s.getValue("cdnUrlModifiers")?.includes("/crop/")).map(s=>this.uploadCollection.read(s)).filter(Boolean);for(let s of r){let n=s.getValue("fileInfo");if(!n||!n.imageInfo){console.warn("Failed to get image info for entry",s.uid);continue}let{width:a,height:l}=n.imageInfo,d=typeof t?.width=="number"&&typeof t?.height=="number"&&t.width>0&&t.height>0?t.width/t.height:1,u=Ls(a,l,d),p=Y(`crop/${u.width}x${u.height}/${u.x},${u.y}`,"preview"),f=s.getValue("cdnUrl");if(!f){console.warn("Failed to get cdnUrl for entry",s.uid);continue}s.setMultipleValues({cdnUrlModifiers:p,cdnUrl:H(f,p)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(g=>g.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:s.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT,this.modalManager?.open(_.activities.CLOUD_IMG_EDIT))}}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let r=this.api.getOutputItem(e);return await t(r)}return t}async getUploadClientOptions(){let t=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:Ps,integration:this.cfg.userAgentIntegration,secureSignature:t?.secureSignature,secureExpire:t?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return this.uploadCollection.items().map(r=>this.api.getOutputItem(r))}};M.extSrcList=Object.freeze({...Ee});M.sourceTypes=Object.freeze({...B});var Us=()=>typeof navigator.permissions<"u";var b={};v(b,rf);import*as rf from"lit-html/directives/ref.js";var le={};v(le,of);import*as of from"lit-html/directives/style-map.js";var Sl={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},$s=["camera","microphone"];function Ai(o){let i=Math.floor(o/60).toString().padStart(2,"0"),e=Math.floor(o%60).toString().padStart(2,"0");return`${i}:${e}`}var Ds="image/jpeg",Vs="video/webm",D=class extends M{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.CAMERA;this._unsubPermissions=null;this._capturing=!1;this._chunks=[];this._mediaRecorder=null;this._stream=null;this._selectedAudioId=null;this._selectedCameraId=null;this._activeTab=null;this._options={};this._canvas=null;this._ctx=null;this._cameraDevices=[];this._audioDevices=[];this._permissionResponses={};this.timerRef=(0,b.createRef)();this.lineRef=(0,b.createRef)();this.videoRef=(0,b.createRef)();this.switcherRef=(0,b.createRef)();this._startTime=0;this._elapsedTime=0;this.video=null;this.videoTransformCss=null;this.videoHidden=!0;this.messageHidden=!0;this.requestBtnHidden=Us();this.cameraSelectOptions=[];this.cameraSelectHidden=!0;this.l10nMessage="";this.timerHidden=!0;this.cameraHidden=!0;this.cameraActionsHidden=!0;this.audioSelectOptions=[];this.audioSelectHidden=!0;this.audioSelectDisabled=!0;this.audioToggleMicrophoneHidden=!0;this.tabCameraHidden=!0;this.tabVideoHidden=!0;this.currentIcon="camera-full";this.currentTimelineIcon="play";this.toggleMicrophoneIcon="microphone";this.mutableClassButton="uc-shot-btn uc-camera-action";this._chooseActionWithCamera=()=>{if(this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this._activeTab}}}),this._activeTab===S.PHOTO&&this._shot(),this._activeTab===S.VIDEO){if(this._mediaRecorder?.state==="recording"){this._stopRecording();return}this._startRecording()}};this._handleCameraSelectChange=e=>{let t=e.target;t&&(this._selectedCameraId=t.value,this._capture())};this._handleAudioSelectChange=e=>{let t=e.target;t&&(this._selectedAudioId=t.value,this._capture())};this._handleRequestPermissions=()=>{this._capture()};this._handleStartCamera=()=>{this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this._activeTab}}}),this._chooseActionWithCamera()};this._handleToggleRecording=()=>{this._toggleRecording()};this._handleToggleAudio=()=>{this._toggleEnableAudio()};this._handleRetake=()=>{this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this._activeTab}}}),this._retake()};this._handleAccept=()=>{this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this._activeTab}}}),this._accept()};this._handleClickTab=e=>{let r=e.currentTarget?.getAttribute("data-id");r&&this._handleActiveTab(r)};this._updateTimer=()=>{let e=Math.floor((performance.now()-this._startTime+this._elapsedTime)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){let s=this.timerRef.value;s&&(s.textContent=Ai(t)),this._stopRecording();return}let r=this.timerRef.value;r&&(r.textContent=Ai(t))}else{let t=this.timerRef.value;t&&(t.textContent=Ai(e))}this._animationFrameId=requestAnimationFrame(this._updateTimer)};this._startTimer=()=>{this._startTime=performance.now(),this._elapsedTime=0,this._updateTimer()};this._stopTimer=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)};this._startTimeline=()=>{let e=this.videoRef.value;if(!e)return;let t=e.currentTime,r=e.duration||1,s=this.lineRef.value;s&&(s.style.transform=`scaleX(${t/r})`);let n=this.timerRef.value;n&&(n.textContent=Ai(t)),this._animationFrameId=requestAnimationFrame(this._startTimeline)};this._stopTimeline=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)};this._animationFrameId=null;this._startRecording=()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(Vs)?this._options.mimeType=Vs:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(he.PLAY))}catch(e){console.error("Failed to start recording",e),this.telemetryManager.sendEventError(e,"camera recording. Failed to start recording")}};this._stopRecording=()=>{this._mediaRecorder?.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(he.STOP)}),this._mediaRecorder?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this._activeTab}}})};this._toggleRecording=()=>{if(this._mediaRecorder?.state==="recording")return;let e=this.videoRef.value;e&&(!e.paused&&!e.ended&&e.readyState>2?e.pause():e.paused&&e.play())};this._toggleEnableAudio=()=>{this._stream?.getAudioTracks().forEach(e=>{e.enabled=!e.enabled,this.toggleMicrophoneIcon=e.enabled?"microphone":"microphone-mute",this.audioSelectDisabled=!e.enabled})};this._previewVideo=()=>{try{let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=URL.createObjectURL(e),r=this.videoRef.value;if(!r)return;r.muted=!1,r.volume=1,this.video=null,r.src=t,r.addEventListener("play",()=>{this._startTimeline(),this.currentTimelineIcon="pause"}),r.addEventListener("pause",()=>{this.currentTimelineIcon="play",this._stopTimeline()})}catch(e){console.error("Failed to preview video",e),this.telemetryManager.sendEventError(e,"camera previewing. Failed to preview video")}};this._retake=()=>{if(this._setCameraState(he.RETAKE),this._activeTab===S.VIDEO){this.video=this._stream;let e=this.videoRef.value;e&&(e.muted=!0)}this.videoRef.value?.play?.()};this._accept=()=>{if(this._setCameraState(he.ACCEPT),this._activeTab===S.PHOTO){this._canvas?.toBlob(s=>{if(!s)return;let n=this._createFile("camera","jpeg",Ds,s);this._toSend(n)},Ds);return}let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=this._guessExtensionByMime(this._mediaRecorder?.mimeType),r=this._createFile("video",t,`video/${t}`,e);this._toSend(r),this._chunks=[]};this._handlePhoto=e=>{e===he.SHOT&&(this.tabVideoHidden=!0,this.cameraHidden=!0,this.tabCameraHidden=!0,this.cameraActionsHidden=!1,this.cameraSelectHidden=!0),(e===he.RETAKE||e===he.ACCEPT)&&(this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.cameraHidden=!1,this.cameraActionsHidden=!0,this.cameraSelectHidden=this._cameraDevices.length<=1)};this._handleVideo=e=>{e===he.PLAY&&(this.timerHidden=!1,this.tabCameraHidden=!0,this.cameraSelectHidden=!0,this.audioSelectHidden=!0,this.currentTimelineIcon="pause",this.currentIcon="square",this.mutableClassButton="uc-shot-btn uc-camera-action uc-stop-record"),e===he.STOP&&(this.timerHidden=!1,this.cameraHidden=!0,this.audioToggleMicrophoneHidden=!0,this.cameraActionsHidden=!1),(e===he.RETAKE||e===he.ACCEPT)&&(this.timerHidden=!0,this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.cameraHidden=!1,this.cameraActionsHidden=!0,this.audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording,this.currentIcon="video-camera-full",this.mutableClassButton="uc-shot-btn uc-camera-action",this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this.cameraSelectHidden=this._cameraDevices.length<=1)};this._setCameraState=e=>{this._activeTab===S.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===S.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e)};this._handleActiveTab=e=>{this.switcherRef.value?.querySelectorAll("button").forEach(r=>{r.classList.toggle("uc-active",r.getAttribute("data-id")===e)}),e===S.PHOTO&&(this.currentIcon="camera-full",this.audioSelectHidden=!0,this.audioToggleMicrophoneHidden=!0),e===S.VIDEO&&(this.currentTimelineIcon="play",this.currentIcon="video-camera-full",this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this.audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording),this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:e}}}),this._activeTab=e};this._createFile=(e,t,r,s)=>{let n=Date.now(),a=`${e}-${n}.${t}`;return new File([s],a,{lastModified:n,type:r})};this._toSend=e=>{this.api.addFileFromObject(e,{source:B.CAMERA}),this.set$({"*currentActivity":_.activities.UPLOAD_LIST}),this.modalManager?.open(_.activities.UPLOAD_LIST)};this._setPermissionsState=L(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===S.VIDEO&&this.cfg.enableAudioRecording,r=this._activeTab===S.PHOTO?"camera-full":"video-camera-full";e==="granted"?(this.videoHidden=!1,this.cameraHidden=!1,this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.messageHidden=!0,this.timerHidden=!0,this.currentIcon=r,this.audioToggleMicrophoneHidden=!t,this.audioSelectHidden=!t):e==="prompt"?(this.l10nMessage="camera-permissions-prompt",this.videoHidden=!0,this.cameraHidden=!0,this.tabCameraHidden=!0,this.messageHidden=!1,this._stopCapture()):(this.l10nMessage="camera-permissions-denied",this.videoHidden=!0,this.messageHidden=!1,this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.cameraActionsHidden=!0,this.mutableClassButton="uc-shot-btn uc-camera-action",this._stopCapture())},300);this._makeStreamInactive=()=>{if(!this._stream)return!1;let e=this._stream?.getAudioTracks(),t=this._stream?.getVideoTracks();return e.forEach(r=>{r.stop()}),t.forEach(r=>{r.stop()}),!0};this._stopCapture=()=>{this._capturing&&(this.videoRef.value&&(this.videoRef.value.volume=0),this.video?.getTracks?.()?.[0]?.stop(),this.video=null,this._makeStreamInactive(),this._stopTimer(),this._capturing=!1)};this._capture=async()=>{let e={video:{...Sl},audio:this.cfg.enableAudioRecording?{}:!1};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this.videoRef.value&&(this.videoRef.value.volume=0);try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied")}),this.video=this._stream,this._capturing=!0,this._setPermissionsState("granted")}catch(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t),this.telemetryManager.sendEventError(t,"camera capturing. Failed to capture camera")}};this._handlePermissionsChange=()=>{this._capture()};this._permissionAccess=async()=>{try{for(let e of $s){let t=await navigator.permissions.query({name:e});this._permissionResponses[e]=t,t.addEventListener("change",this._handlePermissionsChange)}}catch(e){console.log("Failed to use permissions API. Fallback to manual request mode.",e),this.telemetryManager.sendEventError(e,"camera permissions. Failed to use permissions API"),this._capture()}};this._getPermission=()=>{};this._requestDeviceAccess=async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices)}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get user media"),console.log("Failed to get user media",e)}};this._getDevices=async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=e.filter(t=>t.kind==="videoinput").map((t,r)=>({text:t.label.trim()||`${this.l10n("caption-camera")} ${r+1}`,value:t.deviceId})),this._audioDevices=this.cfg.enableAudioRecording?e.filter(t=>t.kind==="audioinput").map(t=>({text:t.label.trim(),value:t.deviceId})):[],this.cameraSelectOptions=this._cameraDevices,this.cameraSelectHidden=this._cameraDevices.length<=1,this._selectedCameraId=this._cameraDevices[0]?.value??null,this.audioSelectOptions=this._audioDevices,this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._selectedAudioId=this._audioDevices[0]?.value??null}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get devices"),console.log("Failed to get devices",e)}};this._onActivate=async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes)};this._onDeactivate=async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()};this._handleCameraModes=e=>{this.tabVideoHidden=!e.includes(S.VIDEO),this.tabCameraHidden=!e.includes(S.PHOTO);let t=e[0];t&&(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t)}}_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");let e=this.videoRef.value;if(!e)throw new Error("Video element not found");this._canvas.height=e.videoHeight,this._canvas.width=e.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(e,0,0),e.pause()}_guessExtensionByMime(e){let t={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return"webm";if(e){let r=e.split("/");if(r?.[0]==="video"){let n=r.slice(1).join("/")?.split(";")[0];if(n&&t[n])return t[n]}}return"avi"}get _cameraModes(){return j(this.cfg.cameraModes).filter(e=>e===S.PHOTO||e===S.VIDEO)}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:this._onActivate,onDeactivate:this._onDeactivate}),this.subConfigValue("cameraMirror",e=>{this.videoTransformCss=e?"scaleX(-1)":null}),this.subConfigValue("enableAudioRecording",e=>{this.audioToggleMicrophoneHidden=!e,this.audioSelectDisabled=!e}),this.subConfigValue("cameraModes",e=>{if(!this.isActivityActive)return;let t=oe(e);this._handleCameraModes(t.filter(r=>r===S.PHOTO||r===S.VIDEO))})}_destroy(){for(let e of $s)this._permissionResponses[e]?.removeEventListener("change",this._handlePermissionsChange);navigator.mediaDevices?.removeEventListener("devicechange",this._getDevices)}disconnectedCallback(){super.disconnectedCallback(),this._destroy()}render(){return m.html`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.$["*historyBack"]} title=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div ?hidden=${!this.cameraSelectHidden}><uc-icon name="camera"></uc-icon><span>${this.l10n("caption-camera")}</span></div><uc-select class="uc-camera-select" .options=${this.cameraSelectOptions} ?hidden=${this.cameraSelectHidden} @change=${this._handleCameraSelectChange} ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline .srcObject=${this.video} style=${(0,le.styleMap)({transform:this.videoTransformCss})} ?hidden=${this.videoHidden} ${(0,b.ref)(this.videoRef)} ></video><div class="uc-message-box" ?hidden=${this.messageHidden}><span>${this.l10n(this.l10nMessage)}</span><button type="button" @click=${this._handleRequestPermissions} ?hidden=${this.requestBtnHidden} >${this.l10n("camera-permissions-request")}</button></div></div><div class="uc-controls"><div ${(0,b.ref)(this.switcherRef)} class="uc-switcher" ?hidden=${!this.timerHidden}><button data-id="photo" type="button" class="uc-switch uc-mini-btn" @click=${this._handleClickTab} ?hidden=${this.tabCameraHidden} ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class="uc-switch uc-mini-btn" @click=${this._handleClickTab} ?hidden=${this.tabVideoHidden} ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" @click=${this._handleToggleRecording} ?hidden=${this.timerHidden} ><uc-icon name=${this.currentTimelineIcon}></uc-icon><span ${(0,b.ref)(this.timerRef)}> 00:00 </span><span ${(0,b.ref)(this.lineRef)} class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" ?hidden=${this.cameraActionsHidden} ><button type="button" class="uc-secondary-btn" @click=${this._handleRetake}> Retake </button><button type="button" class="uc-primary-btn" @click=${this._handleAccept} data-testid="accept" > Accept </button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" @click=${this._handleStartCamera} class=${this.mutableClassButton} ?hidden=${this.cameraHidden} ><uc-icon name=${this.currentIcon}></uc-icon></button><div class="uc-select"><button type="button" class="uc-mini-btn uc-btn-microphone" @click=${this._handleToggleAudio} ?hidden=${this.audioToggleMicrophoneHidden} ><uc-icon name=${this.toggleMicrophoneIcon}></uc-icon></button><uc-select class="uc-audio-select" .options=${this.audioSelectOptions} ?hidden=${this.audioSelectHidden} ?disabled=${this.audioSelectDisabled} @change=${this._handleAudioSelectChange} ></uc-select></div></div>`}};h([(0,c.state)()],D.prototype,"video",2),h([(0,c.state)()],D.prototype,"videoTransformCss",2),h([(0,c.state)()],D.prototype,"videoHidden",2),h([(0,c.state)()],D.prototype,"messageHidden",2),h([(0,c.state)()],D.prototype,"requestBtnHidden",2),h([(0,c.state)()],D.prototype,"cameraSelectOptions",2),h([(0,c.state)()],D.prototype,"cameraSelectHidden",2),h([(0,c.state)()],D.prototype,"l10nMessage",2),h([(0,c.state)()],D.prototype,"timerHidden",2),h([(0,c.state)()],D.prototype,"cameraHidden",2),h([(0,c.state)()],D.prototype,"cameraActionsHidden",2),h([(0,c.state)()],D.prototype,"audioSelectOptions",2),h([(0,c.state)()],D.prototype,"audioSelectHidden",2),h([(0,c.state)()],D.prototype,"audioSelectDisabled",2),h([(0,c.state)()],D.prototype,"audioToggleMicrophoneHidden",2),h([(0,c.state)()],D.prototype,"tabCameraHidden",2),h([(0,c.state)()],D.prototype,"tabVideoHidden",2),h([(0,c.state)()],D.prototype,"currentIcon",2),h([(0,c.state)()],D.prototype,"currentTimelineIcon",2),h([(0,c.state)()],D.prototype,"toggleMicrophoneIcon",2),h([(0,c.state)()],D.prototype,"mutableClassButton",2);var yt={};v(yt,wf);import*as wf from"lit-html/directives/unsafe-svg.js";var qe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function Fs(...o){return o.reduce((i,e)=>{if(typeof e=="string")return i[e]=!0,i;for(let t of Object.keys(e))i[t]=e[t];return i},{})}function ce(...o){let i=Fs(...o);return Object.keys(i).reduce((e,t)=>(i[t]&&e.push(t),e),[]).join(" ")}function Ns(o,...i){let e=Fs(...i);for(let t of Object.keys(e))o.classList.toggle(t,!!e[t])}var Al=o=>J.includes(o),Bs=o=>{if(!o)return J;let i=oe(o).filter(Al);return i.length===0?J:i};function zs(o){return{"*originalUrl":null,"*loadingOperations":new Map,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":J,"*tabId":V.CROP,"*on.retryNetwork":()=>{let i=o.querySelectorAll("img");for(let e of i){let t=e.src;e.src=qe,e.src=t}o.$["*networkProblems"]=!1},"*on.apply":i=>{if(!i)return;let e=o.$["*originalUrl"],t=Y(ze(i),"preview"),r=H(e,t),s={originalUrl:e,cdnUrlModifiers:t,cdnUrl:r,transformations:i};o.dispatchEvent(new CustomEvent("apply",{detail:s,bubbles:!0,composed:!0})),o.remove()},"*on.cancel":()=>{o.remove(),o.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Hs="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><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-closeMax' 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='ruc-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><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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.315-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>";var it={};v(it,Rf);import*as Rf from"lit-html/directives/when.js";var js=Me([...J]),F=class extends T{constructor(){super(...arguments);this.ctxOwner=!0;this.entry=null;this.extension=null;this.editorMode=!1;this.modalCaption="";this.isImage=!1;this.msg="";this.src=qe;this.fileType="";this.showLoader=!1;this.uuid=null;this.cdnUrl=null;this.cropPreset="";this.tabs=js;this.presenceNetworkProblems=!1;this.presenceModalCaption=!0;this.presenceEditorToolbar=!1;this.presenceViewerToolbar=!0;this.isInitialized=!1;this.pendingInitUpdate=null;this._debouncedShowLoader=L(e=>{this.showLoader=e},300);this.imgRef=(0,b.createRef)();this.cropperRef=(0,b.createRef)();this.faderRef=(0,b.createRef)();this.imgContainerRef=(0,b.createRef)();this.handleImageLoad=()=>{this._debouncedShowLoader(!1),this.src!==qe&&(this.$["*networkProblems"]=!1)};this.handleImageError=()=>{this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0};this.handleRetryNetwork=()=>{let e=this.$["*on.retryNetwork"];e?.()};this.init$={...this.init$,...zs(this)}}static{this.styleAttrs=["uc-cloud-image-editor"]}scheduleInitialization(){this.isInitialized||this.pendingInitUpdate||(this.pendingInitUpdate=this.updateComplete.then(()=>{this.pendingInitUpdate=null,this.isInitialized=!0}))}initCallback(){super.initCallback(),this.syncTabListFromProp(),this.syncCropPresetState()}assignSharedElements(){let e=this.faderRef.value;e&&(this.$["*faderEl"]=e);let t=this.cropperRef.value;t&&(this.$["*cropperEl"]=t);let r=this.imgContainerRef.value;r&&(this.$["*imgContainerEl"]=r);let s=this.imgRef.value;s&&(this.$["*imgEl"]=s)}attachImageListeners(){let e=this.imgRef.value;e&&(e.addEventListener("load",this.handleImageLoad),e.addEventListener("error",this.handleImageError))}detachImageListeners(){let e=this.imgRef.value;e&&(e.removeEventListener("load",this.handleImageLoad),e.removeEventListener("error",this.handleImageError))}get imageClassName(){let e=this.$["*tabId"];return ce("uc-image",{"uc-image_hidden_to_cropper":e===V.CROP,"uc-image_hidden_effects":e!==V.CROP})}_waitForSize(){return new Promise((t,r)=>{let s=window.setTimeout(()=>{r(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),n=new ResizeObserver(a=>{let[l]=a;l&&l.contentRect.width>0&&l.contentRect.height>0&&(window.clearTimeout(s),n.disconnect(),window.setTimeout(()=>t(),0))});n.observe(this)})}firstUpdated(e){super.firstUpdated(e),this.assignSharedElements(),this.attachImageListeners(),this.initEditor();let t=!!(this.uuid||this.cdnUrl),r=e.has("uuid")||e.has("cdnUrl");t&&!r&&this.updateImage()}disconnectedCallback(){this.detachImageListeners(),super.disconnectedCallback()}render(){let e=this.fileType??"",t=this.msg??"",r=this.src||qe,s=this.showLoader,n=this.presenceNetworkProblems;return m.html`${(0,yt.unsafeSVG)(Hs)} <div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" .visible=${n}><div class="uc-network_problems_content"><div class="uc-network_problems_icon"><uc-icon name="sad"></uc-icon></div><div class="uc-network_problems_text">Network error</div></div><div class="uc-network_problems_footer"><uc-btn-ui theme="primary" text="Retry" @click=${this.handleRetryNetwork}></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">${e}</div></div><div class="uc-image_container" ${(0,b.ref)(this.imgContainerRef)}><img src=${r} class=${this.imageClassName} ${(0,b.ref)(this.imgRef)} /> ${(0,it.when)(this.isInitialized,()=>m.html`<uc-editor-image-cropper ${(0,b.ref)(this.cropperRef)}></uc-editor-image-cropper>`)} <uc-editor-image-fader ${(0,b.ref)(this.faderRef)}></uc-editor-image-fader></div><div class="uc-info_pan">${t}</div></div><div class="uc-toolbar"><uc-line-loader-ui .active=${s}></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor"> ${(0,it.when)(this.isInitialized,()=>m.html`<uc-editor-toolbar></uc-editor-toolbar>`)} </div></div></div>`}updated(e){super.updated(e),e.has("uuid")&&this.uuid&&this.updateImage(),e.has("cdnUrl")&&this.cdnUrl&&this.updateImage(),e.has("tabs")&&this.syncTabListFromProp(),(e.has("cropPreset")||e.has("cdnUrl"))&&this.syncCropPresetState()}syncTabListFromProp(){let e=this.tabs||js;this.$["*tabList"]=Bs(e)}syncCropPresetState(){let e=Si(this.cropPreset??""),t=null;if(this.cdnUrl){let r=Sr(this.cdnUrl),s=Ar(r);if(Array.isArray(s?.crop?.dimensions)){let[n,a]=s.crop.dimensions;t=Rs(n,a,e,.1)}}this.$["*cropPresetList"]=e,this.$["*currentAspectRatio"]=t??e?.[0]??null}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.cdnUrl){let e=this.cdnUrl,t=di(e),r=Be(e,t);if(r===this.$["*originalUrl"])return;this.$["*originalUrl"]=r;let s=Sr(e),n=Ar(s);this.$["*editorTransformations"]=n}else if(this.uuid){let e=Be(this.cfg.cdnCname,this.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===V.CROP?this.$["*cropperEl"]?.deactivate({reset:!0}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(H(e,Y("json"))),r=await fetch(t).then(a=>a.json()),{width:s,height:n}=r;this.$["*imageSize"]={width:s,height:n},this.$["*tabId"]===V.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:e})}catch(e){e&&(this.telemetryManager.sendEventError(e,"cloud editor image. Failed to load image info"),console.error("Failed to load image info",e))}this.scheduleInitialization()}}async initEditor(){try{await this._waitForSize()}catch(e){this.isConnected&&console.error(e.message);return}this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{let t=!!e;this.presenceNetworkProblems=t,this.presenceModalCaption=!t}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],r=Y(ze(e),"preview"),s=H(t,r),n={originalUrl:t,cdnUrlModifiers:r,cdnUrl:s,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:!0,composed:!0}))},!1)}};h([(0,c.property)({attribute:!1})],F.prototype,"entry",2),h([(0,c.property)({attribute:!1})],F.prototype,"extension",2),h([(0,c.property)({type:Boolean,attribute:!1})],F.prototype,"editorMode",2),h([(0,c.property)({type:String,attribute:!1})],F.prototype,"modalCaption",2),h([(0,c.property)({type:Boolean,attribute:!1})],F.prototype,"isImage",2),h([(0,c.property)({type:String,attribute:!1})],F.prototype,"msg",2),h([(0,c.property)({type:String,attribute:!1})],F.prototype,"src",2),h([(0,c.property)({type:String,attribute:!1})],F.prototype,"fileType",2),h([(0,c.property)({type:Boolean,attribute:!1})],F.prototype,"showLoader",2),h([(0,c.property)({type:String,reflect:!0})],F.prototype,"uuid",2),h([(0,c.property)({type:String,attribute:"cdn-url",reflect:!0})],F.prototype,"cdnUrl",2),h([(0,c.property)({type:String,attribute:"crop-preset",reflect:!0})],F.prototype,"cropPreset",2),h([(0,c.property)({type:String,reflect:!0})],F.prototype,"tabs",2),h([(0,c.property)({type:Boolean,attribute:!1})],F.prototype,"presenceNetworkProblems",2),h([(0,c.property)({type:Boolean,attribute:!1})],F.prototype,"presenceModalCaption",2),h([(0,c.property)({type:Boolean,attribute:!1})],F.prototype,"presenceEditorToolbar",2),h([(0,c.property)({type:Boolean,attribute:!1})],F.prototype,"presenceViewerToolbar",2),h([(0,c.state)()],F.prototype,"isInitialized",2);var Ii=class extends T{constructor(){super(...arguments);this._guidesHidden=!1;this._dragging=!1;this.svgRef=(0,b.createRef)();this._svgReady=!1;this._pendingMaskHref=null;this._handlePointerUp=e=>{this._updateCursor(),this.dragging&&(e.stopPropagation(),e.preventDefault(),this.dragging=!1)};this._handlePointerMove=e=>{if(!this.dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this._svgElement;if(!t)return;let{x:r,y:s}=t.getBoundingClientRect(),n=e.x-r,a=e.y-s,l=n-this._dragStartPoint[0],d=a-this._dragStartPoint[1],{direction:u}=this._draggingThumb,p=this._calcCropBox(u,[l,d]);p&&(this.$["*cropBox"]=p)};this._handleSvgPointerMove=e=>{if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(r=>{if(!r||this._shouldThumbBeDisabled(r.direction))return!1;let n=r.interactionNode.getBoundingClientRect(),a={x:n.x,y:n.y,width:n.width,height:n.height};return ks(a,[e.x,e.y])});this._hoverThumb=t,this._updateCursor()}}get _svgElement(){return this.svgRef.value??null}get dragging(){return this._dragging}set dragging(e){this._dragging!==e&&(this._dragging=e,this._applyGuidesDragState())}_applyGuidesDragState(){this._frameGuides&&this._frameGuides.setAttribute("class",ce({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&this._dragging,"uc-guides--semi-hidden":!this._guidesHidden&&!this._dragging}))}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return!1;if(e===""&&t.height<=A&&t.width<=A)return!0;let r=t.height<=A&&(e.includes("n")||e.includes("s")),s=t.width<=A&&(e.includes("e")||e.includes("w"));return r||s}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:s,height:n}=e,a=this._svgElement;if(!a)return;let l=ae("mask",{id:"backdrop-mask"}),d=ae("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),u=ae("rect",{x:t,y:r,width:s,height:n,fill:"black"});l.appendChild(d),l.appendChild(u);let p=ae("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});a.appendChild(p),a.appendChild(l),this._backdropMask=l,this._backdropMaskInner=u}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block")}))}_updateBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:s,height:n}=e;this._backdropMaskInner&&Ge(this._backdropMaskInner,{x:t,y:r,width:s,height:n})}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:r,pathNode:s,interactionNode:n,groupNode:a}=t,l=r==="",d=r.length===2,{x:u,y:p,width:f,height:g}=e;if(l)Ge(n,{x:u,y:p,width:f,height:g});else{let w=We(Math.min(f,g)/82/2,0,1),C=d?Es(e,r,w):xs(e,r,w),E=C.center;if(!E)continue;let x=Math.max(Nr*We(Math.min(f,g)/Nr/3,0,1),Ts);Ge(n,{x:E[0]-x,y:E[1]-x,width:x*2,height:x*2}),Ge(s,{d:C.d})}let y=this._shouldThumbBeDisabled(r);a.setAttribute("class",ce("uc-thumb",{"uc-thumb--hidden":y,"uc-thumb--visible":!y}))}Ge(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1})}}_createThumb(e,t){let r=ae("g");r.classList.add("uc-thumb"),r.setAttribute("with-effects","");let s=ae("rect",{fill:"transparent"}),n=ae("path",{stroke:"currentColor",fill:"none","stroke-width":3});r.appendChild(n),r.appendChild(s),e[t]={direction:t,pathNode:n,interactionNode:s,groupNode:r},t===""&&(r.style.cursor="move"),s.addEventListener("pointerdown",this._handlePointerDown.bind(this,t))}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let r=0;r<3;r++){let s=`${["n","","s"][t]}${["w","","e"][r]}`;s!==""&&this._createThumb(e,s)}return this._createThumb(e,""),e}_createGuides(){let e=ae("svg"),t=ae("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let r=1;r<=2;r++){let s=ae("line",{x1:`${Ft*r}%`,y1:"0%",x2:`${Ft*r}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s)}for(let r=1;r<=2;r++){let s=ae("line",{x1:"0%",y1:`${Ft*r}%`,x2:"100%",y2:`${Ft*r}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s)}return e.classList.add("uc-guides","uc-guides--semi-hidden"),e}_createFrame(){let e=this._svgElement;if(!e)return;let t=document.createDocumentFragment(),r=this._createGuides();t.appendChild(r);let s=this._createThumbs();for(let{groupNode:n}of Object.values(s))t.appendChild(n);e.appendChild(t),this._frameThumbs=s,this._frameGuides=r,this._applyGuidesDragState()}_handlePointerDown(e,t){if(!this._frameThumbs)return;let r=this._frameThumbs[e];if(!r||this._shouldThumbBeDisabled(e))return;let s=this.$["*cropBox"],n=this._svgElement;if(!n)return;let{x:a,y:l}=n.getBoundingClientRect(),d=t.x-a,u=t.y-l;this.dragging=!0,this._draggingThumb=r,this._dragStartPoint=[d,u],this._dragStartCrop={...s}}_calcCropBox(e,t){let[r,s]=t,n=this.$["*imageBox"],a=this._dragStartCrop??this.$["*cropBox"],l=this.$["*currentAspectRatio"],d=l?l.width/l.height:void 0;if(e===""?a=As({rect:a,delta:[r,s],imageBox:n}):a=Is({rect:a,delta:[r,s],direction:e,aspectRatio:d,imageBox:n}),!Object.values(a).every(u=>Number.isFinite(u)&&u>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:a});return}return ft(vt(a),n)}_updateCursor(){let e=this._hoverThumb,t=this._svgElement;t&&(t.style.cursor=e?Ss(e.direction):"initial")}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this._svgElement;if(!t){this._pendingMaskHref=e;return}this._pendingMaskHref=null;let r=document.createDocumentFragment(),s=ae("image",{href:e});s.setAttribute("class","uc-cloud-mask"),r.appendChild(s),t.appendChild(r),this._frameImage=s}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:r,width:s,height:n}=e;Ge(this._frameImage,{x:t,y:r,height:n,width:s})}_render(){this._svgReady&&(this._updateBackdrop(),this._updateFrame(),this._updateMask())}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:r}=t;r.setAttribute("class",ce("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}))}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._resizeBackdrop(),this._svgReady&&window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",e=>{e&&(this._guidesHidden=e.height<=A||e.width<=A,this._applyGuidesDragState(),this._svgReady&&window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",e=>{e&&this._createMask(e)}),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}firstUpdated(e){super.firstUpdated(e),this._initializeSvg()}_initializeSvg(){let e=this._svgElement;if(!(!e||this._svgReady)){if(this._createBackdrop(),this._createFrame(),this._svgReady=!0,e.addEventListener("pointermove",this._handleSvgPointerMove,!0),this._pendingMaskHref){let t=this._pendingMaskHref;this._pendingMaskHref=null,this._createMask(t)}this._render()}}disconnectedCallback(){super.disconnectedCallback(),this._svgElement?.removeEventListener("pointermove",this._handleSvgPointerMove,!0),document.removeEventListener("pointermove",this._handlePointerMove,!0),document.removeEventListener("pointerup",this._handlePointerUp,!0)}render(){return m.html`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${(0,b.ref)(this.svgRef)}></svg>`}};h([(0,c.state)()],Ii.prototype,"_dragging",2);var ne={};v(ne,lg);import*as lg from"lit-html/directives/class-map.js";var R={};v(R,cg);import*as cg from"lit-html/directives/if-defined.js";var ee=class extends T{constructor(){super(...arguments);this.active=!1;this.title="";this.icon="";this.titleProp=""}get buttonClasses(){let e=this.active;return{"uc-active":e,"uc-not_active":!e}}updateHostStateClasses(){let e=this.buttonClasses;for(let[t,r]of Object.entries(e))this.classList.toggle(t,r)}onClick(e){}connectedCallback(){super.connectedCallback(),this.updateHostStateClasses()}updated(e){super.updated(e),e.has("active")&&this.updateHostStateClasses()}render(){let e=this.onClick,t=this.title;return m.html`<button role="option" type="button" aria-label=${(0,R.ifDefined)(this.titleProp)} title=${(0,R.ifDefined)(this.titleProp)} @click=${e} ><uc-icon name=${this.icon}></uc-icon><div class="uc-title" ?hidden=${!t}>${t}</div></button>`}};h([(0,c.state)()],ee.prototype,"active",2),h([(0,c.state)()],ee.prototype,"title",2),h([(0,c.state)()],ee.prototype,"icon",2),h([(0,c.state)()],ee.prototype,"titleProp",2);var ki=12,Oi=16,kl=o=>{let i=12,e=12;return o.width/o.height>=1?(i=ki,e=Math.round(ki*o.height/o.width)):(e=ki,i=Math.round(ki*o.width/o.height)),{width:i,height:e}},Br=class extends ee{initCallback(){super.initCallback(),this.icon="arrow-dropdown",this.sub("*currentAspectRatio",i=>{let e=this.computeTitle(i);this.title=e,this.titleProp=e})}onClick(){this.$["*showListAspectRatio"]=!0}computeTitle(i){return i?i.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}):""}render(){let i=this.onClick,e=this.title;return m.html`<button role="option" type="button" class=${(0,ne.classMap)(this.buttonClasses)} aria-label=${(0,R.ifDefined)(this.titleProp)} title=${(0,R.ifDefined)(this.titleProp)} @click=${i} ><div class="uc-title" ?hidden=${!e}>${e}</div><uc-icon name=${this.icon}></uc-icon></button>`}},Mi=class extends ee{get aspectRatio(){return this._aspectRatio}set aspectRatio(i){if(this._aspectRatio===i)return;let e=this._aspectRatio;this._aspectRatio=i,this.requestUpdate("aspectRatio",e),i?this.updateAspectRatioPresentation(i):(this.removeAttribute("uc-aspect-ratio-freeform"),this.title="",this.titleProp="")}initCallback(){super.initCallback(),this._aspectRatio&&this.updateAspectRatioPresentation(this._aspectRatio),this.sub("*currentAspectRatio",i=>{this.active=i&&i.id===this._aspectRatio?.id||i?.width===this._aspectRatio?.width&&i?.height===this._aspectRatio?.height})}onClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio)}updateAspectRatioPresentation(i){let e=!!i.hasFreeform;this.toggleAttribute("uc-aspect-ratio-freeform",e);let t=()=>{let s=e?this.l10n("custom"):`${i.width}:${i.height}`;return this.title=s,s},r=()=>{let s=this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:e?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}).toLowerCase(),value:""});return this.titleProp=s,s};t(),r(),e||this.requestUpdate()}renderIcon(){let i=this._aspectRatio;if(!i||i.hasFreeform)return m.html`<uc-icon name=${this.icon}></uc-icon>`;let{width:e,height:t}=kl(i),r=(Oi-e)/2,s=(Oi-t)/2;return m.html`<svg viewBox="0 0 ${Oi} ${Oi}" aria-hidden="true" focusable="false" ><rect x=${r} y=${s} width=${e} height=${t} rx="2" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" ></rect></svg>`}render(){let i=this.onClick,e=this.title;return m.html`<button role="option" type="button" class=${(0,ne.classMap)(this.buttonClasses)} aria-label=${(0,R.ifDefined)(this.titleProp)} title=${(0,R.ifDefined)(this.titleProp)} @click=${i} ><uc-icon>${this.renderIcon()}</uc-icon><div class="uc-title" ?hidden=${!e}>${e}</div></button>`}};h([(0,c.property)({attribute:!1})],Mi.prototype,"aspectRatio",1);function Ol(o){let i=o+90;return i=i>=360?0:i,i}function Ml(o,i){if(o==="rotate")return Ol(typeof i=="number"?i:0);if(o==="mirror"||o==="flip")return!i;throw new Error(`Unsupported operation: ${o}`)}var Li=class extends ee{constructor(){super(...arguments);this.operation=void 0}willUpdate(e){super.willUpdate(e),this.operation?(this.titleProp=this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(this.operation).toLowerCase()}),this.icon=this.operation):(this.icon="",this.titleProp="")}onClick(e){if(!this.operation)return;let t=this.$["*cropperEl"],r=t.getValue(this.operation),s=Ml(this.operation,r);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this.operation,next:s,prev:r}),t.setValue(this.operation,s)}};h([(0,c.property)({type:String})],Li.prototype,"operation",2);function ot(o){let i=new Image;return{promise:new Promise((r,s)=>{i.src=o,i.onload=()=>r(),i.onerror=n=>s(n)}),image:i,cancel:()=>{i.naturalWidth===0&&(i.src=qe)}}}function Bt(o){let i=[];for(let s of o){let n=ot(s);i.push(n)}let e=i.map(s=>s.image);return{promise:Promise.allSettled(i.map(s=>s.promise)),images:e,cancel:()=>{i.forEach(s=>{s.cancel()})}}}var Se="original",Ri=class extends T{constructor(){super(...arguments);this.state={operation:"filter",filter:void 0,originalUrl:"",disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0};this.handleInput=e=>{let{value:t}=e.detail;this.$["*faderEl"]?.set(t),this.state={...this.state,value:t}}}setOperation(e,t){this.state={...this.state,operation:e,filter:t},this._initializeValues();let r=this.$["*faderEl"],s=this.state.originalUrl||this.$["*originalUrl"];r&&s&&r.activate({url:s,operation:this.state.operation,value:this.state.filter===Se?void 0:this.state.value,filter:this.state.filter===Se?void 0:this.state.filter,fromViewer:!1})}_initializeValues(){let e=this.state.operation,{range:t,zero:r}=ye[e],[s,n]=t;this.state={...this.state,min:s,max:n,zero:r};let l=this.$["*editorTransformations"][e];if(e==="filter"){let u=Number(n),p=l;if(p){let{name:f,amount:g}=p;u=f===this.state.filter?g:n}this.state={...this.state,value:u,defaultValue:u};return}let d=typeof l<"u"?l:r;this.state={...this.state,value:d,defaultValue:d}}apply(){let t={...this.$["*editorTransformations"]};this.state.operation==="filter"?!this.state.filter||this.state.filter===Se?delete t.filter:t.filter={name:this.state.filter,amount:this.state.value}:t[this.state.operation]=this.state.value,this.$["*editorTransformations"]=t}cancel(){this.$["*faderEl"]?.deactivate({hide:!1})}initCallback(){this.sub("*originalUrl",e=>{this.state={...this.state,originalUrl:e}})}updated(e){if(super.updated(e),e.has("state")){let t=`${this.state.filter??this.state.operation} ${this.state.value}`;this.$["*operationTooltip"]=t}}render(){return m.html`<uc-slider-ui .disabled=${this.state.disabled} .min=${this.state.min} .max=${this.state.max} .defaultValue=${this.state.defaultValue} .zero=${this.state.zero} @slider-input=${this.handleInput} ></uc-slider-ui>`}};h([(0,c.state)()],Ri.prototype,"state",2);function bt(o){let i=o.match(/^([A-Za-z]+)\s+(\d+)$/);if(!i)return null;let[,e,t]=i;return!e||typeof t>"u"?null:{filter:e,value:Number(t)}}var Xe=class extends ee{constructor(){super(...arguments);this._operation="";this._filter="";this._originalUrl="";this._lastPreviewRequestId=0;this.previewImage=null;this.previewLoaded=!1;this.isOriginal=!1;this.iconSize=20}get filter(){return this._filter}set filter(e){let t=e??"";if(this._filter===t)return;let r=this._filter;this._filter=t,this._operation="filter",this.isOriginal=t===Se,this.icon=this.isOriginal?"original":"slider",this.iconSize=this.isOriginal?40:20,this.requestUpdate("filter",r),this.updateFilterLabels(t)}onClick(e){if(this.active)this.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0);else{let t=this.$["*sliderEl"];t.setOperation(this._operation,this._filter),t.apply()}this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:bt(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=Number.isFinite(e)&&e>0?e:this.iconSize||32,r=window.devicePixelRatio,s=Math.ceil(r*t),n=r>=2?"lightest":"normal",a=100,l={...this.$["*editorTransformations"]};return l[this._operation]=this._filter!==Se?{name:this._filter,amount:a}:void 0,H(this._originalUrl,Y(ui,ze(l),`quality/${n}`,`scale_crop/${s}x${s}/center`))}async _observerCallback(e,t){e[0]?.isIntersecting?await this.loadPreview(t):this._cancelPreload?.()}initCallback(){super.initCallback(),"IntersectionObserver"in window&&(this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}));let e=this.$["*originalUrl"];this._originalUrl=e??"",this.sub("*originalUrl",t=>{this._originalUrl=t??"",!this.isOriginal&&this._originalUrl&&this.isConnected&&!this.previewImage&&(this._observer?.observe(this),this.schedulePreviewVisibilityCheck())}),this.isOriginal||(this._observer?.observe(this),this.schedulePreviewVisibilityCheck()),this._filter&&this.updateFilterLabels(this._filter),this.sub("*currentFilter",t=>{this.active=!!(t&&t===this._filter)}),this.sub("*networkProblems",async t=>{t||(this.previewImage?await this.loadPreview():this.schedulePreviewVisibilityCheck())})}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._cancelPreload?.(),this.clearPreviewVisibilityChecks()}updated(e){super.updated(e),e.has("isOriginal")&&(this.isOriginal?this._observer?.unobserve(this):(this._observer?.observe(this),this.schedulePreviewVisibilityCheck()))}updateFilterLabels(e){if(!e){this.titleProp="";return}let t=this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()});this.titleProp=t}async loadPreview(e){if(!this.isConnected){e?.unobserve(this),this._cancelPreload?.(),this._cancelPreload=void 0;return}if(!this._originalUrl){!this.previewVisibilityCheckTimeout&&!this.previewVisibilityCheckRaf&&this.schedulePreviewVisibilityCheck();return}let t=++this._lastPreviewRequestId,r="";try{r=await this.proxyUrl(this._previewSrc())}catch(a){this.$["*networkProblems"]=!0,console.error("Failed to resolve preview URL",{error:a});return}this.previewLoaded=!1,this._cancelPreload?.();let{promise:s,cancel:n}=ot(r);this._cancelPreload=()=>{n(),this._lastPreviewRequestId===t&&(this._cancelPreload=void 0)};try{if(await s,this._lastPreviewRequestId!==t||!this.isConnected)return;this.previewImage=r,this.previewLoaded=!0,this.clearPreviewVisibilityChecks(),(e??this._observer)?.unobserve(this)}catch(a){this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:a}),this.schedulePreviewVisibilityCheck()}finally{this._lastPreviewRequestId===t&&(this._cancelPreload=void 0)}}schedulePreviewVisibilityCheck(){if(!this.isConnected||this.previewImage||this.previewLoaded||this.isOriginal){this.clearPreviewVisibilityChecks();return}this.previewVisibilityCheckRaf&&cancelAnimationFrame(this.previewVisibilityCheckRaf),this.previewVisibilityCheckRaf=requestAnimationFrame(()=>{if(this.previewVisibilityCheckRaf=void 0,!this.isConnected||this.previewImage||this.previewLoaded||this.isOriginal){this.clearPreviewVisibilityChecks();return}let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight;if(t&&e.bottom>0&&e.right>0&&e.top<s&&e.left<r){this.loadPreview();return}this.previewVisibilityCheckTimeout=window.setTimeout(()=>{this.previewVisibilityCheckTimeout=void 0,this.schedulePreviewVisibilityCheck()},500)})}clearPreviewVisibilityChecks(){this.previewVisibilityCheckRaf&&(cancelAnimationFrame(this.previewVisibilityCheckRaf),this.previewVisibilityCheckRaf=void 0),this.previewVisibilityCheckTimeout&&(window.clearTimeout(this.previewVisibilityCheckTimeout),this.previewVisibilityCheckTimeout=void 0)}get shouldShowPreview(){return!!(this.previewLoaded&&!this.active&&!this.isOriginal)}render(){let e=this.onClick,t={opacity:this.shouldShowPreview?"1":"0"};this.previewImage&&(t.backgroundImage=`url(${this.previewImage})`);let r={opacity:this.shouldShowPreview?"0":"1"};return m.html`<button role="option" type="button" class=${(0,ne.classMap)(this.buttonClasses)} aria-label=${(0,R.ifDefined)(this.titleProp)} title=${(0,R.ifDefined)(this.titleProp)} @click=${e} ><div class="uc-preview" ?loaded=${this.previewLoaded} style=${(0,le.styleMap)(t)}></div><uc-icon class=${(0,ne.classMap)({"uc-original-icon":this.isOriginal})} name=${this.icon} style=${(0,le.styleMap)(r)} ></uc-icon></button>`}};h([(0,c.state)()],Xe.prototype,"previewImage",2),h([(0,c.state)()],Xe.prototype,"previewLoaded",2),h([(0,c.property)({type:Boolean,reflect:!0})],Xe.prototype,"isOriginal",2),h([(0,c.property)({type:Number})],Xe.prototype,"iconSize",2),h([(0,c.property)({type:String})],Xe.prototype,"filter",1);var _t=(o,i)=>{let e=!1,t,r=0,s=((...n)=>{e?(t&&clearTimeout(t),t=setTimeout(()=>{Date.now()-r>=i&&(o(...n),r=Date.now())},Math.max(i-(Date.now()-r),0))):(o(...n),r=Date.now(),e=!0)});return Object.defineProperty(s,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{t&&clearTimeout(t)}}),s};function Ks(o,i){let e={};for(let t of i){let r=o[t];(Object.hasOwn(o,t)||r!==void 0)&&(e[t]=r)}return e}function wt(o,i,e){let r=window.devicePixelRatio,s=Math.min(Math.ceil(i*r),3e3),n=r>=2?"lightest":"normal";return H(o,Y(ui,ze(e),`quality/${n}`,`stretch/off/-/resize/${s}x`,`@clib/${He}/${je}/uc-cloud-image-editor/`))}function Ll(o){return o?[({dimensions:e,coords:t})=>[...e,...t].every(r=>Number.isInteger(r)&&Number.isFinite(r)),({dimensions:e,coords:t})=>e.every(r=>r>0)&&t.every(r=>r>=0)].every(e=>e(o)):!0}var Pi=class extends T{constructor(){super();this.ctxOwner=!0;this._imageSize={width:0,height:0};this._ctx=null;this._isActive=!1;this._image=null;this.canvasRef=(0,b.createRef)();this.frameRef=(0,b.createRef)();this.init$={...this.init$,"*padding":20,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=L(this._commit.bind(this),300),this._handleResizeThrottled=_t(()=>{!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())},100)}firstUpdated(e){super.firstUpdated(e),this._initCanvas()}_syncTransformations(){let e=this.$["*editorTransformations"],t=Ks(e,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...t};this.$["*operations"]=r}_initCanvas(){let e=this.canvasRef.value;if(!e)return;let t=e.getContext("2d"),r=this.offsetWidth,s=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${r}px`,e.style.height=`${s}px`,e.width=r*n,e.height=s*n,t?.scale(n,n),this._canvas=e,this._ctx=t}_alignImage(){if(!this._isActive||!this._image)return;let e=this._image,t=this.$["*padding"],r=this.$["*operations"],{rotate:s}=r,n={width:this.offsetWidth,height:this.offsetHeight},a=gt({width:e.naturalWidth,height:e.naturalHeight},s),l;if(a.width>n.width-t*2||a.height>n.height-t*2){let d=a.width/a.height,u=n.width/n.height;if(d>u){let p=n.width-t*2,f=p/d,g=0+t,y=t+(n.height-t*2)/2-f/2;l={x:g,y,width:p,height:f}}else{let p=n.height-t*2,f=p*d,g=t+(n.width-t*2)/2-f/2,y=0+t;l={x:g,y,width:f,height:p}}}else{let{width:d,height:u}=a,p=t+(n.width-t*2)/2-d/2,f=t+(n.height-t*2)/2-u/2;l={x:p,y:f,width:d,height:u}}this.$["*imageBox"]=vt(l)}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:s}=r,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:d}=t;if(n){let{dimensions:[f,g],coords:[y,w]}=n,{width:C}=gt(this._imageSize,s),E=a/C;e=ft(vt({x:l+y*E,y:d+w*E,width:f*E,height:g*E}),t)}let u=this.$["*currentAspectRatio"],p=u?u.width/u.height:void 0;if(!Os(e,t)||p&&!Ms(e,p)){let f=t.width/t.height,g=t.width,y=t.height;p&&(f>p?g=Math.min(t.height*p,t.width):y=Math.min(t.width/p,t.height)),e={x:t.x+t.width/2-g/2,y:t.y+t.height/2-y/2,width:g,height:y}}this.$["*cropBox"]=ft(vt(e),t)}_drawImage(){let e=this._ctx;if(!e)return;let t=this._image;if(!t)return;let r=this.$["*imageBox"],s=this.$["*operations"],{mirror:n,flip:a,rotate:l}=s,d=gt({width:r.width,height:r.height},l);e.save(),e.translate(r.x+r.width/2,r.y+r.height/2),e.rotate(l*Math.PI*-1/180),e.scale(n?-1:1,a?-1:1),e.drawImage(t,-d.width/2,-d.height/2,d.width,d.height),e.restore()}_draw(){if(!this._isActive||!this._image||!this._canvas||!this._ctx)return;let e=this._canvas;this._ctx.clearRect(0,0,e.width,e.height),this._drawImage()}_animateIn({fromViewer:e}){this._image&&(this.frameRef.value?.toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=ce({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:s}=r,{width:n,height:a}=t,{width:l,height:d}=gt(this._imageSize,s),{width:u,height:p}=e,f=n/l,g=a/d;return[We(Math.round(u/f),1,l),We(Math.round(p/g),1,d)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:s}=r,{width:n,height:a,x:l,y:d}=t,{width:u,height:p}=gt(this._imageSize,s),{x:f,y:g}=e,y=n/u,w=a/p,C=this._getCropDimensions(),E={dimensions:C,coords:[We(Math.round((f-l)/y),0,u-C[0]),We(Math.round((g-d)/w),0,p-C[1])]};if(!Ll(E)){console.error("Cropper is trying to create invalid crop object",{payload:E});return}if(!(C[0]===u&&C[1]===p))return E}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:r,flip:s}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:t,mirror:r,flip:s};this.$["*editorTransformations"]=l}setValue(e,t){this.$["*operations"]={...this.$["*operations"],[e]:t},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:t}={}){if(!this._isActive){this._isActive=!0,await this.updateComplete,this._initCanvas(),this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{let r=this.$["*originalUrl"],s=this.$["*editorTransformations"];this._image=await this._waitForImage(r,s),this._syncTransformations(),this._handleResizeThrottled(),this._animateIn({fromViewer:t})}catch(r){console.error("Failed to activate cropper",{error:r}),this.telemetryManager.sendEventError(r,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(r=>{let[s]=r;if(!s)return;s.contentRect.width>0&&s.contentRect.height>0&&this._isActive&&this._image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=ce({"uc-active_from_viewer":!1,"uc-active_from_editor":!1,"uc-inactive_to_editor":!0}),this.frameRef.value?.toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),this._observer?.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],r=Math.min(this.offsetWidth,e[0])/t.width,s=Math.min(this.offsetHeight,e[1])/t.height,n=Math.min(r,s),a=t.x+t.width/2,l=t.y+t.height/2;this.style.transform=`scale(${n}) translate(${(this.offsetWidth/2-a)/n}px, ${(this.offsetHeight/2-l)/n}px)`,this.style.transformOrigin=`${a}px ${l}px`}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,r=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${r}px`}_reset(){this._isActive||(this._image=null)}async _waitForImage(e,t){let r=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let s=await this.proxyUrl(wt(e,r,t)),{promise:n,cancel:a,image:l}=ot(s),d=this._handleImageLoading(s);return l.addEventListener("load",d,{once:!0}),l.addEventListener("error",d,{once:!0}),this._cancelPreload?.(),this._cancelPreload=a,n.then(()=>l).catch(u=>(console.error("Failed to load image",{error:u}),this.$["*networkProblems"]=!0,l))}_handleImageLoading(e){let t="crop",r=this.$["*loadingOperations"],s=r.get(t);return s||(s=new Map,r.set(t,s)),s.get(e)||(s.set(e,!0),this.$["*loadingOperations"]=r),()=>{let n=r.get(t);n?.has(e)&&(n.delete(e),this.$["*loadingOperations"]=r)}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw()}),this.sub("*cropBox",()=>{this._image&&this._commitDebounced()}),this.sub("*currentAspectRatio",()=>{this._alignCrop()}),setTimeout(()=>{this.sub("*networkProblems",e=>{e||this._isActive&&this._imageSize&&this.activate(this._imageSize,{fromViewer:!1})})},0)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._image&&(this._image=null)}render(){return m.html`<canvas class="uc-canvas" ${(0,b.ref)(this.canvasRef)}></canvas><uc-crop-frame ${(0,b.ref)(this.frameRef)}></uc-crop-frame>`}};h([(0,c.state)()],Pi.prototype,"_image",2);function zr(o,i,e){let t=e,r=e-1,s=new Array(t);for(let n=r;n>=0;n-=1)s[n]=Math.ceil((n*i+(r-n)*o)/r);return s}function Rl(o){return typeof o=="string"&&o in ye}function Pl(o){let i=[];for(let e=0;e<o.length-1;e+=1){let t=o[e],r=o[e+1];typeof t=="number"&&typeof r=="number"&&i.push([t,r])}return i}function Ul(o,i,e){let t=Pl(o).find(([n,a])=>n<=i&&i<=a);if(!t)return o.map(()=>0);let[r,s]=t;return o.map(n=>{let a=Math.abs(r-s)||1,l=Math.abs(i-r)/a;return r===n?i>e?1:1-l:s===n?i>=e?l:1:0})}function $l(o,i){return o.map((e,t)=>e<i?o.length-t:t)}function Gs(o,i){let e=ye[o].keypointsNumber,{range:t,zero:r}=ye[o];return[...new Set([...zr(t[0],r,e+1),...zr(r,t[1],e+1),r,i])].sort((s,n)=>s-n)}var Hr=class extends T{constructor(){super();this._isActive=!1;this._hidden=!0;this._operation="initial";this._transformations={};this._keypoints=[];this._raf=0;this._previewHostRef=(0,b.createRef)();this._layersHostRef=(0,b.createRef)();this.classList.add("uc-inactive_to_cropper"),this._addKeypointDebounced=L(async(e,t,r)=>{let s=()=>!this._isSame(e,t)||this._value!==r||!!this._keypoints.find(d=>d.value===r);if(s())return;let n=await this._constructKeypoint(e,r),a=new Image;a.src=n.src;let l=this._handleImageLoading(n.src);a.addEventListener("load",l,{once:!0}),a.addEventListener("error",l,{once:!0}),n.image=a,a.classList.add("uc-fader-image"),a.addEventListener("load",()=>{if(s())return;let d=this._keypoints,u=d.findIndex(y=>y.value>r);u===-1&&(u=d.length);let f=d[u]?.image,g=this._layersHostRef.value;!g||f&&!g.contains(f)||(d.splice(u,0,n),f?g.insertBefore(a,f):g.appendChild(a),this._update(e,r))},{once:!0}),a.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})},600)}_handleImageLoading(e){let t=this._operation,r=this.$["*loadingOperations"];r.has(t)||r.set(t,new Map);let s=r.get(t);return s&&!s.get(e)&&(s.set(e,!0),this.$["*loadingOperations"]=r),()=>{let n=r.get(t);n?.has(e)&&(n.delete(e),this.$["*loadingOperations"]=r)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let e of this._keypoints){let{image:t}=e;t&&(t.style.opacity=e.opacity.toString(),t.style.zIndex=e.zIndex.toString())}})}_imageSrc({url:e=this._url,filter:t=this._filter??void 0,operation:r,value:s}={}){if(!e)throw new Error("URL is not defined");let n={...this._transformations};r&&(r==="filter"?t&&typeof s=="number"&&(n.filter={name:t,amount:s}):typeof s=="number"&&(n[r]=s));let a=this.offsetWidth;return this.proxyUrl(wt(e,a,n))}async _constructKeypoint(e,t){return{src:await this._imageSrc({operation:e,value:t}),image:void 0,opacity:0,zIndex:0,value:t}}_isSame(e,t){return this._operation===e&&this._filter===t}set(e){let t=typeof e=="string"?parseInt(e,10):e;!Rl(this._operation)||!Number.isFinite(t)||(this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t))}_update(e,t){this._operation=e,this._value=t;let{zero:r}=ye[e],s=this._keypoints.map(l=>l.value),n=Ul(s,t,r),a=$l(s,r);this._keypoints.forEach((l,d)=>{let u=n[d],p=a[d];typeof u=="number"&&(l.opacity=u),typeof p=="number"&&(l.zIndex=p)}),this._flush()}_createPreviewImage(){let e=new Image;return e.classList.add("uc-fader-image","uc-fader-image--preview"),e.style.opacity="0",e}async _initNodes(){this._previewImage=this._previewImage||this._createPreviewImage();let e=this._previewImage;e&&this._ensurePreviewAttached(e);let t=this._keypoints.map(d=>d.src),{images:r,promise:s,cancel:n}=Bt(t);r.forEach(d=>{let u=this._handleImageLoading(d.src);d.addEventListener("load",u),d.addEventListener("error",u)}),this._cancelLastImages=()=>{n(),this._cancelLastImages=void 0};let a=this._operation,l=this._filter;if(await s,this._isActive&&this._isSame(a,l)){let d=this._layersHostRef.value;if(!d)return;d.replaceChildren(),this._keypoints.forEach((u,p)=>{let f=r[p];f&&(f.classList.add("uc-fader-image"),u.image=f,d.appendChild(f))}),this._flush()}}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),r=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",r,{once:!0}),this._previewImage.addEventListener("error",r,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:e,filter:t,operation:r,value:s}){if(!r||typeof s!="number")return;this._cancelBatchPreload?.();let n=Gs(r,s),a=await Promise.all(n.map(d=>this._imageSrc({url:e,filter:t,operation:r,value:d}))),{cancel:l}=Bt(a);this._cancelBatchPreload=l}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this._ensurePreviewAttached(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=ce({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}t.style.opacity="0";let r=this._handleImageLoading(e);t.addEventListener("error",r,{once:!0}),t.src=e,t.addEventListener("load",()=>{r(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=ce({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),t.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:e,operation:t,value:r,filter:s,fromViewer:n}){if(this._isActive=!0,this._hidden=!1,await this.updateComplete,this._url=e,this._operation=t??"initial",this._value=r,this._filter=s,this._fromViewer=n,typeof r!="number"&&!s){let l=await this._imageSrc({operation:t,value:r});this._setOriginalSrc(l),this._clearLayersHost();return}!t||typeof r!="number"||(this._keypoints=await Promise.all(Gs(t,r).map(l=>this._constructKeypoint(t,l))),this._update(t,r),this._initNodes())}deactivate({hide:e=!0}={}){this._isActive=!1,this._cancelLastImages?.(),this._cancelBatchPreload?.(),e&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=ce({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._clearLayersHost()},{once:!0})):this._clearLayersHost()}_ensurePreviewAttached(e){let t=this._previewHostRef.value;t&&(t.contains(e)||t.appendChild(e))}_clearLayersHost(){this._layersHostRef.value?.replaceChildren()}render(){return m.html`<div class="uc-fader-preview-host" ${(0,b.ref)(this._previewHostRef)}></div><div class="uc-fader-layers-host" ${(0,b.ref)(this._layersHostRef)}></div>`}};var Ui=class extends ee{constructor(){super(...arguments);this._operation=""}get operation(){return this._operation}set operation(e){let t=e??"";if(this._operation===t)return;let r=this._operation;this._operation=t,this.requestUpdate("operation",r),t&&this.updateOperationMetadata(t)}updateOperationMetadata(e){this.icon=e;let t=()=>{let s=this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()});return this.titleProp=s,s},r=()=>{let s=this.l10n(e);return this.title=s,s};t(),r()}initCallback(){super.initCallback(),this._operation&&this.updateOperationMetadata(this._operation),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=ye[this._operation],r=e[this._operation],s=typeof r<"u"?r!==t:!1;this.active=s})}onClick(e){this.$["*sliderEl"]?.setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation,this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:bt(this.$["*operationTooltip"])})}};h([(0,c.property)({type:String})],Ui.prototype,"operation",1);var Dl=1,Ws=()=>{},jr=class extends T{constructor(){super(...arguments);this.handleWheel=e=>{e.preventDefault();let{deltaY:t,deltaX:r}=e;if(Math.abs(r)>Dl){this.scrollLeft+=r;return}this.scrollLeft+=t}}connectedCallback(){super.connectedCallback(),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("scroll",Ws,{passive:!0})}disconnectedCallback(){this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("scroll",Ws),super.disconnectedCallback()}};var de=class extends T{constructor(){super(...arguments);this.showLoader=!1;this.showMainToolbar=!0;this.showSubToolbar=!1;this.showTabToggles=!0;this.tabList=[...J];this.activeTab=V.CROP;this.useSliderPanel=!0;this.tooltipVisible=!1;this.operationTooltip=null;this.tabIndicatorOffset=0;this.tabIndicatorWidth=0;this.sliderRef=(0,b.createRef)();this.tabIndicatorRef=(0,b.createRef)();this.tabToggleRefs={[V.CROP]:(0,b.createRef)(),[V.TUNING]:(0,b.createRef)(),[V.FILTERS]:(0,b.createRef)()};this.handleWindowResize=()=>{this._syncTabIndicator()};this.cropPresets=[];this._debouncedShowLoader=L(e=>{this.showLoader=e},500);this._updateInfoTooltip=L(()=>{let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],r="",s=!1;if(this.$["*tabId"]===V.FILTERS)if(s=!0,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let n=e?.filter?.amount||100;r=`${this.$["*currentFilter"]} ${n}`}else r=this.l10n(Se);else if(this.showSubToolbar&&this.$["*tabId"]===V.TUNING&&t){s=!0;let n=e?.[t]||ye[t].zero;r=`${this.l10n(t)} ${n}`}s&&(this.$["*operationTooltip"]=r),this.tooltipVisible=s},0);this.subTopToolbarStyles={hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"};this.subBottomToolbarStyles={hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"};this.tabContentStyles={hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"};this.tabToggleStyles={hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"};this.tabTogglesStyles={hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"};this.init$={...this.init$,"*sliderEl":null,"*showSlider":!1,"*showListAspectRatio":!1,"*currentFilter":Se,"*currentOperation":null,"*operationTooltip":null};this.handleCancel=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t?.()};this.handleApply=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t?.(this.$["*editorTransformations"])};this.handleApplySlider=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:bt(this.$["*operationTooltip"])}),this.sliderRef.value?.apply(),this._onSliderClose()};this.handleCancelSlider=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this.sliderRef.value?.cancel(),this._onSliderClose()};this.handleTabClick=e=>{let r=e.currentTarget?.getAttribute("data-id");r&&(this.telemetryManager.sendEventCloudImageEditor(e,r),this._activateTab(r,{fromViewer:!1}))}}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===V.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===V.TUNING&&(this.tooltipVisible=!1)}_activateTab(e,{fromViewer:t=!1,force:r=!1}={}){this.$["*tabId"]!==e&&(this.$["*tabId"]=e),this.applyTabState(e,{fromViewer:t,force:r})}applyTabState(e,{fromViewer:t,force:r=!1}){if(!r&&this.activeTab===e){this._syncTabIndicator();return}this.activeTab=e;let s=this.$["*faderEl"],n=this.$["*cropperEl"];e===V.CROP?(s?.deactivate(),this.$["*imageSize"]&&n?.activate(this.$["*imageSize"],{fromViewer:t})):(s?.activate({url:this.$["*originalUrl"],fromViewer:t}),n?.deactivate());for(let a of J){let l=a===e,u=this.tabToggleRefs[a]?.value;u&&(u.active=l),l&&this._syncTabIndicator()}}_syncTabIndicator(){let t=this.tabToggleRefs[this.activeTab]?.value,r=this.tabIndicatorRef.value;if(!t||!r)return;let s=t.offsetLeft,n=t.offsetWidth||Number(getComputedStyle(t).width.replace("px",""));(this.tabIndicatorOffset!==s||this.tabIndicatorWidth!==n)&&(this.tabIndicatorOffset=s,this.tabIndicatorWidth=n,r.style.transform=`translateX(${s}px)`,r.style.width=`${n}px`)}get hasAspectRatioPicker(){return this.cropPresets.length>=3}renderControlsByTab(e){switch(e){case V.CROP:return this.renderCropTabControls();case V.FILTERS:return this.renderFilterTabControls();case V.TUNING:return this.renderTuningTabControls();default:return[]}}renderCropTabControls(){let e=[];if(this.hasAspectRatioPicker)e.push(()=>this.renderFreeformControl());else for(let t of this.cropPresets)e.push(()=>this.renderAspectRatioControl(t));for(let t of Yo)e.push(()=>this.renderCropOperationControl(t));return this.renderControlGroup(e)}renderFilterTabControls(){let t=[Se,...Qo].map(r=>()=>this.renderFilterControl(r));return this.renderControlGroup(t)}renderTuningTabControls(){let e=Zo.map(t=>()=>this.renderOperationControl(t));return this.renderControlGroup(e)}renderControlGroup(e){return e.length?e.map(r=>r()):[]}renderFreeformControl(){return m.html`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`}renderAspectRatioControl(e){return m.html`<uc-editor-aspect-ratio-button-control .aspectRatio=${e}></uc-editor-aspect-ratio-button-control>`}renderCropOperationControl(e){return m.html`<uc-editor-crop-button-control .operation=${e}></uc-editor-crop-button-control>`}renderFilterControl(e){return m.html`<uc-editor-filter-control .filter=${e}></uc-editor-filter-control>`}renderOperationControl(e){return m.html`<uc-editor-operation-control .operation=${e}></uc-editor-operation-control>`}renderAspectRatioList(){return this.hasAspectRatioPicker?this.cropPresets.map(e=>this.renderAspectRatioControl(e)):[]}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(wt(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:r}=Bt([t]);this._cancelPreload=()=>{r(),this._cancelPreload=void 0}}}initCallback(){super.initCallback();let e=this.$["*cropPresetList"]??[];this.cropPresets=[...e],this.sub("*cropPresetList",t=>{this.cropPresets=[...t??[]]}),this.sub("*imageSize",t=>{t&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",t=>{let r=t?.filter?.name;this.$["*currentFilter"]!==r&&(this.$["*currentFilter"]=r??"")}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",t=>{this.applyTabState(t,{fromViewer:!1,force:!0}),this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate()}),this.sub("*editorTransformations",t=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(t)}),this.sub("*loadingOperations",t=>{let r=!1;for(let[,s]of t.entries()){if(r)break;for(let[,n]of s.entries())if(n){r=!0;break}}this._debouncedShowLoader(r)}),this.sub("*showSlider",t=>{t?(this.showSubToolbar=!0,this.showMainToolbar=!1,this.useSliderPanel=!0):this.$["*showListAspectRatio"]||(this.showSubToolbar=!1,this.showMainToolbar=!0)}),this.sub("*showListAspectRatio",t=>{t?(this.showSubToolbar=!0,this.showMainToolbar=!1,this.useSliderPanel=!1):this.$["*showSlider"]||(this.showSubToolbar=!1,this.showMainToolbar=!0)}),this.sub("*tabList",t=>{if(this.tabList=t,this.showTabToggles=t.length>1,!t.includes(this.$["*tabId"])&&t.length>0){let[r]=t;r&&this._activateTab(r,{fromViewer:!1});return}this._syncTabIndicator()}),this.sub("*operationTooltip",t=>{this.operationTooltip=t}),this._updateInfoTooltip()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleWindowResize)}firstUpdated(e){super.firstUpdated(e),this.assignSharedElements(),this._syncTabIndicator()}updated(e){super.updated(e),(e.has("activeTab")||e.has("tabList"))&&this.updateComplete.then(()=>this._syncTabIndicator()),(e.has("showSubToolbar")||e.has("showMainToolbar"))&&this.assignSharedElements()}disconnectedCallback(){window.removeEventListener("resize",this.handleWindowResize),super.disconnectedCallback(),this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}assignSharedElements(){let e=this.sliderRef.value;e&&(this.$["*sliderEl"]=e)}renderTabToggle(e){let t=this.tabList.includes(e),r=this.activeTab===e,s=this.tabList.indexOf(e),n=s>=0?(0,le.styleMap)({gridColumn:`${s+1}`}):m.nothing;return m.html` <uc-presence-toggle class="uc-tab-toggle" .visible=${t} .styles=${this.tabToggleStyles}><uc-btn-ui theme="tab" data-id=${e} icon=${e} role="tab" aria-controls=${`tab_${e}`} aria-selected=${r?"true":"false"} title-prop=${`a11y-editor-tab-${e}`} .active=${r} style=${n} @click=${this.handleTabClick} ${(0,b.ref)(this.tabToggleRefs[e])} ></uc-btn-ui></uc-presence-toggle>`}renderTabContent(e){let t=this.activeTab===e,r=this.renderControlsByTab(e);return m.html` <uc-presence-toggle id=${`tab_${e}`} class="uc-tab-content" .visible=${t} .styles=${this.tabContentStyles} ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner"> ${r.length?r:m.nothing} </div></div></uc-editor-scroller></uc-presence-toggle>`}render(){let e=["uc-info-tooltip",this.tooltipVisible?"uc-info-tooltip_visible":"uc-info-tooltip_hidden"].join(" "),t=this.hasAspectRatioPicker;return m.html`<uc-line-loader-ui .active=${this.showLoader}></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div class=${e}>${this.operationTooltip??""}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" .visible=${this.showMainToolbar} .styles=${this.subTopToolbarStyles} ><div class="uc-tab-content-row"> ${J.map(r=>this.renderTabContent(r))} </div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" .visible=${this.showTabToggles} .styles=${this.tabTogglesStyles} @initial-render=${()=>this._syncTabIndicator()} ><div class="uc-tab-toggles_indicator" ${(0,b.ref)(this.tabIndicatorRef)} ></div> ${J.map(r=>this.renderTabToggle(r))} </uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" title-prop="cancel" @click=${this.handleCancel} ></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this.handleApply}></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this.subBottomToolbarStyles}><div class="uc-slider" ?hidden=${!this.useSliderPanel}><uc-editor-slider ${(0,b.ref)(this.sliderRef)}></uc-editor-slider></div><div class="uc-list-aspect-ratio-container" ?hidden=${this.useSliderPanel||!t}> ${t?m.html`<div class="uc-list-aspect-ratio">${this.renderAspectRatioList()}</div>`:m.nothing} </div><div class="uc-controls-row"><uc-btn-ui theme="secondary" @click=${this.handleCancelSlider} text=${this.l10n("cancel")}></uc-btn-ui><uc-btn-ui theme="primary" @click=${this.handleApplySlider} text=${this.l10n("apply")}></uc-btn-ui></div></uc-presence-toggle></div>`}};h([(0,c.state)()],de.prototype,"showLoader",2),h([(0,c.state)()],de.prototype,"showMainToolbar",2),h([(0,c.state)()],de.prototype,"showSubToolbar",2),h([(0,c.state)()],de.prototype,"showTabToggles",2),h([(0,c.state)()],de.prototype,"tabList",2),h([(0,c.state)()],de.prototype,"activeTab",2),h([(0,c.state)()],de.prototype,"useSliderPanel",2),h([(0,c.state)()],de.prototype,"tooltipVisible",2),h([(0,c.state)()],de.prototype,"operationTooltip",2),h([(0,c.state)()],de.prototype,"cropPresets",2);var be=class extends T{constructor(){super(...arguments);this.text="";this.icon="";this.active=!1;this.reverse=!1;this.theme="default";this.ariaRole="";this.ariaControls="";this.titleProp=""}firstUpdated(e){super.firstUpdated(e),this.applyReverse(),this.applyThemeClass()}updated(e){super.updated(e),e.has("reverse")&&this.applyReverse(),e.has("theme")&&this.applyThemeClass()}applyReverse(){this.style.flexDirection=this.reverse?"row-reverse":""}applyThemeClass(){this.theme&&this.theme!=="custom"&&(this.className=`uc-${this.theme}`)}get iconClassMap(){let e=this.computedIconHidden;return{"uc-icon":!0,"uc-icon_left":!this.reverse,"uc-icon_right":this.reverse,"uc-icon_hidden":e,"uc-icon_single":this.computedIconSingle}}get computedIconHidden(){return!this.icon}get computedIconSingle(){return!this.text&&!this.computedIconHidden}render(){return m.html`<button type="button" role=${(0,R.ifDefined)(this.ariaRole||void 0)} aria-controls=${(0,R.ifDefined)(this.ariaControls||void 0)} aria-label=${(0,R.ifDefined)(this.l10n(this.titleProp))} title=${(0,R.ifDefined)(this.l10n(this.titleProp))} ><uc-icon class=${(0,ne.classMap)(this.iconClassMap)} name=${(0,R.ifDefined)(this.icon||void 0)} ?hidden=${this.computedIconHidden} ></uc-icon><div class="uc-text">${this.text}</div></button>`}};h([(0,c.property)({type:String})],be.prototype,"text",2),h([(0,c.property)({type:String})],be.prototype,"icon",2),h([(0,c.property)({type:Boolean,reflect:!0})],be.prototype,"active",2),h([(0,c.property)({type:Boolean,reflect:!0})],be.prototype,"reverse",2),h([(0,c.property)({type:String,reflect:!0})],be.prototype,"theme",2),h([(0,c.property)({attribute:"aria-role"})],be.prototype,"ariaRole",2),h([(0,c.property)({attribute:"aria-controls"})],be.prototype,"ariaControls",2),h([(0,c.property)({attribute:"title-prop"})],be.prototype,"titleProp",2);var $i=class extends T{constructor(){super(...arguments);this.active=!1;this.lineRef=(0,b.createRef)();this._isAnimating=!1;this.handleTransitionEndRight=()=>{let e=this.lineRef.value;e&&(this.resetLine(e),this._isAnimating&&this.active&&this.start())}}firstUpdated(e){super.firstUpdated(e),this.active&&this.start()}updated(e){super.updated(e),e.has("active")&&(this.active?this.start():this.stop())}start(){let e=this.lineRef.value;if(!e)return;this._isAnimating=!0;let{width:t}=this.getBoundingClientRect();e.removeEventListener("transitionend",this.handleTransitionEndRight),e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this.handleTransitionEndRight,{once:!0})}stop(){let e=this.lineRef.value;e&&(this._isAnimating=!1,e.removeEventListener("transitionend",this.handleTransitionEndRight),this.resetLine(e))}resetLine(e){e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)"}render(){return m.html`<div class="uc-inner"><div class="uc-line" ${(0,b.ref)(this.lineRef)}></div></div>`}};h([(0,c.property)({type:Boolean,reflect:!0})],$i.prototype,"active",2);var st={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},zt=class extends T{constructor(){super(...arguments);this._visible=!1;this._styles=st;this._visibleStyle=st.visible;this._hiddenStyle=st.hidden;this._externalTransitions=!1;this.initialRenderComplete=!1}set visible(e){this._visible=e,this._handleVisible()}get visible(){return this._visible}set styles(e){this._styles=e,this._externalTransitions=!0,this._visibleStyle=e.visible??st.visible,this._hiddenStyle=e.hidden??st.hidden}get styles(){return this._styles}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",Ns(this,{[st.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.toggleAttribute("inert",!this._visible)}dispatchInitialRenderEvent(){this.initialRenderComplete||(this.initialRenderComplete=!0,this.dispatchEvent(new CustomEvent("initial-render",{bubbles:!0,composed:!0})))}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",!0),this._externalTransitions||this.classList.add(st.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1),this.dispatchInitialRenderEvent()},0)}};h([(0,c.property)({type:Boolean})],zt.prototype,"visible",1),h([(0,c.property)({attribute:!1})],zt.prototype,"styles",1);var Pe=class extends T{constructor(){super();this._thumbSize=0;this.inputRef=(0,b.createRef)();this.thumbRef=(0,b.createRef)();this.stepsRef=(0,b.createRef)();this.disabled=!1;this.min=0;this.max=100;this.defaultValue=0;this.zero=0;this._currentValue=0;this.handleSliderInput=e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this.emitSliderEvent("slider-input",t))};this.handleSliderChange=e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this.emitSliderEvent("slider-change",t))};this.handleInputFocus=()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")};this.handleInputBlur=()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")};this.setAttribute("with-effects","")}emitSliderEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:{value:t},bubbles:!0,composed:!0}))}firstUpdated(e){super.firstUpdated(e),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10)||0,this._syncInputValue(this._currentValue),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps(),this._updateValue(this._currentValue)}),this._observer.observe(this);let t=this.inputRef.value;t?.addEventListener("focus",this.handleInputFocus),t?.addEventListener("blur",this.handleInputBlur),window.setTimeout(()=>{this._updateValue(this._currentValue)},0)}willUpdate(e){super.willUpdate(e),e.has("defaultValue")&&this.defaultValue!==this._currentValue&&this._setCurrentValue(this.defaultValue),(e.has("min")||e.has("max"))&&this.hasUpdated&&(this._updateSteps(),this._updateValue(this._currentValue)),e.has("zero")&&this.hasUpdated&&this._updateZeroDot(this._currentValue)}_updateValue(e){this._updateZeroDot(e);let t=this.max-this.min;if(t===0)return;let{width:r}=this.getBoundingClientRect(),a=100/t*(e-this.min)*(r-this._thumbSize)/100;window.requestAnimationFrame(()=>{let l=this.thumbRef.value;l&&(l.style.transform=`translateX(${a}px)`)})}_updateZeroDot(e){if(!this._zeroDotEl)return;let t=this.max-this.min;if(t===0)return;this._zeroDotEl.style.opacity=e===this.zero?"0":"1";let{width:r}=this.getBoundingClientRect(),a=100/t*(this.zero-this.min)*(r-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${a}px)`)})}_updateSteps(){let t=this.stepsRef.value;if(!t)return;let{width:r}=t.getBoundingClientRect(),s=Math.ceil(r/2),n=Math.ceil(s/15)-2;if(this._stepsCount===n)return;let a=document.createDocumentFragment(),l=document.createElement("div"),d=document.createElement("div");l.className="uc-minor-step",d.className="uc-border-step",a.appendChild(d);for(let p=0;p<n;p+=1)a.appendChild(l.cloneNode());a.appendChild(d.cloneNode());for(let p=0;p<n;p+=1)a.appendChild(l.cloneNode());a.appendChild(d.cloneNode());let u=document.createElement("div");u.className="uc-zero-dot",a.appendChild(u),this._zeroDotEl=u,t.innerHTML="",t.appendChild(a),this._stepsCount=n}disconnectedCallback(){super.disconnectedCallback();let e=this.inputRef.value;e?.removeEventListener("focus",this.handleInputFocus),e?.removeEventListener("blur",this.handleInputBlur),this._observer?.disconnect(),this._observer=void 0}_setCurrentValue(e){Number.isFinite(e)&&(this._currentValue=e,this.hasUpdated&&(this._syncInputValue(e),this._updateValue(e)))}_syncInputValue(e){let t=this.inputRef.value;t&&(t.value=String(e))}_extractEventValue(e){let t=e.currentTarget;if(!t)return null;let r=Number.parseInt(t.value,10);return Number.isFinite(r)?r:null}render(){return m.html`<div class="uc-steps" ${(0,b.ref)(this.stepsRef)}></div><div class="uc-thumb" ${(0,b.ref)(this.thumbRef)}></div><input class="uc-input" type="range" ${(0,b.ref)(this.inputRef)} .min=${String(this.min)} .max=${String(this.max)} .value=${String(this._currentValue)} ?disabled=${this.disabled} @input=${this.handleSliderInput} @change=${this.handleSliderChange} />`}};h([(0,c.property)({type:Boolean,reflect:!0})],Pe.prototype,"disabled",2),h([(0,c.property)({type:Number})],Pe.prototype,"min",2),h([(0,c.property)({type:Number})],Pe.prototype,"max",2),h([(0,c.property)({type:Number,attribute:!1})],Pe.prototype,"defaultValue",2),h([(0,c.property)({type:Number})],Pe.prototype,"zero",2),h([(0,c.state)()],Pe.prototype,"_currentValue",2);var Di=class extends M{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.CLOUD_IMG_EDIT;this.editorConfig=null}get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.mountEditor(),onDeactivate:()=>this.unmountEditor()}),this.subConfigValue("cropPreset",e=>{if(!this.editorConfig)return;let t=e||void 0;this.editorConfig.cropPreset!==t&&(this.editorConfig={...this.editorConfig,cropPreset:t})}),this.subConfigValue("cloudImageEditorTabs",e=>{if(!this.editorConfig)return;let t=e||void 0;this.editorConfig.tabs!==t&&(this.editorConfig={...this.editorConfig,tabs:t})})}handleApply(e){if(!this._entry)return;this.debugPrint('editor event "apply"',e.detail);let t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager?.close(_.activities.CLOUD_IMG_EDIT),this.historyBack()}handleCancel(e){let t=e instanceof CustomEvent?e.detail:void 0;this.debugPrint('editor event "cancel"',t),this.modalManager?.close(_.activities.CLOUD_IMG_EDIT),this.historyBack()}handleChange(e){this.debugPrint('editor event "change"',e.detail)}mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);this.editorConfig=this._createEditorConfig(r)}unmountEditor(){this._entry=void 0,this.editorConfig=null}render(){if(!this.editorConfig)return m.nothing;let{cdnUrl:e,cropPreset:t,tabs:r}=this.editorConfig;return m.html`<uc-cloud-image-editor cdn-url=${e} crop-preset=${(0,R.ifDefined)(t)} tabs=${(0,R.ifDefined)(r)} @apply=${this.handleApply} @cancel=${this.handleCancel} @change=${this.handleChange} ></uc-cloud-image-editor>`}_createEditorConfig(e){let t={cdnUrl:e},r=this.cfg.cropPreset;r&&(t.cropPreset=r);let s=this.cfg.cloudImageEditorTabs;return s&&(t.tabs=s),t}};h([(0,c.state)()],Di.prototype,"editorConfig",2);var Ht=o=>o.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(i=>i.toLowerCase()).join("-");var Vl=[{test:o=>!!o.accept&&!!o.imgOnly,message:"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."},{test:o=>o.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:o=>o.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],qs=L(o=>{for(let{test:i,message:e}of Vl)i(o)&&Ti(e)},0);var Xs=(o,i)=>{let e=new URL(i);return e.hostname=`${o}.${e.hostname}`,e.toString().replace(/\/$/,"")},Fl="0123456789abcdefghijklmnopqrstuvwxyz",Zs=o=>{if(o<=0n)return"0";let i="";for(;o>0n;){let e=o%36n;i=Fl[Number(e)]+i,o=o/36n}return i},Kr=(o,i)=>{try{let e=new URL(o),t=new URL(i);return e.hostname.endsWith(t.hostname)}catch{return!1}};var Nl=async o=>{let i=new TextEncoder().encode(o),e=await window.crypto.subtle.digest("SHA-256",i),t=Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("");return BigInt(`0x${t}`)},Bl=10,zl=async o=>{let i=await Nl(o);return Zs(i).slice(0,Bl)},Qs=async(o,i)=>{let e=await zl(o);return Xs(e,i)};var Ys=o=>o instanceof Promise||!!(o&&typeof o=="object"&&"then"in o&&typeof o.then=="function");var Gr=o=>o,Hl=[Gr({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:o,enableVideoRecording:i})=>{if(i===null)return o;let e=oe(o);return i&&!e.includes("video")?e=e.concat("video"):i||(e=e.filter(t=>t!=="video")),Me(e)}}),Gr({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:o,defaultCameraMode:i})=>{if(i===null)return o;let e=oe(o);return e=e.sort((t,r)=>t===i?-1:r===i?1:0),Me(e)}}),Gr({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:o,cdnCname:i,cdnCnamePrefixed:e})=>o&&(i===Rt||Kr(i,e))?Qs(o,e):i})],Js=({key:o,setValue:i,getValue:e,computationControllers:t})=>{for(let r of Hl)if(r.deps.includes(o)){let s={[r.key]:e(r.key)};for(let l of r.deps)s[l]=e(l);let n=new AbortController;t.get(r.key)?.abort(),t.set(r.key,n);let a;try{a=r.fn(s,{signal:n.signal})}catch(l){t.get(r.key)===n&&t.delete(r.key),console.error(`Failed to compute value for "${r.key}"`,l);return}Ys(a)?a.then(l=>{n.signal.aborted||i(r.key,l)}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${r.key}"`,l)}).finally(()=>{t.get(r.key)===n&&t.delete(r.key)}):i(r.key,a)}};var $=o=>String(o),Z=o=>{let i=Number(o);if(Number.isNaN(i))throw new Error(`Invalid number: "${o}"`);return i},N=o=>{if(typeof o>"u"||o===null)return!1;if(typeof o=="boolean")return o;if(o==="true"||o==="")return!0;if(o==="false")return!1;throw new Error(`Invalid boolean: "${o}"`)},en=o=>o==="auto"?o:N(o),tn=o=>{let i=$(o);if(i!=="user"&&i!=="environment"&&i!=="")throw new Error(`Invalid value: "${i}"`);return i},rn=o=>{let i=$(o);if(!Object.values(S).includes(i))throw new Error(`Invalid value: "${i}"`);return i},on=o=>{let i=$(o),e=oe(i);if(e.some(t=>!Object.values(S).includes(t)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return i},sn=o=>{if(typeof o=="object"&&!Array.isArray(o)||typeof o=="function")return o;throw new Error("Invalid metadata value. Must be an object or function.")},Wr=o=>{if(typeof o=="object")return o;throw new Error("Invalid value. Must be an object.")},Vi=o=>{if(typeof o=="function")return o;throw new Error("Invalid value. Must be a function.")},qr=o=>{if(Array.isArray(o))return o;throw new Error("Must be an array.")},nn=o=>{let i=$(o);if(["grid","list"].includes(i))return i;throw new Error(`Invalid value: "${i}"`)};var jl={pubkey:$,multiple:N,multipleMin:Z,multipleMax:Z,confirmUpload:N,imgOnly:N,accept:$,externalSourcesPreferredTypes:$,externalSourcesEmbedCss:$,store:en,cameraMirror:N,cameraCapture:tn,sourceList:$,topLevelOrigin:$,maxLocalFileSizeBytes:Z,thumbSize:Z,showEmptyList:N,useLocalImageEditor:N,useCloudImageEditor:N,cloudImageEditorTabs:$,removeCopyright:N,cropPreset:$,imageShrink:$,modalScrollLock:N,modalBackdropStrokes:N,sourceListWrap:N,remoteTabSessionKey:$,cdnCname:$,cdnCnamePrefixed:$,baseUrl:$,socialBaseUrl:$,secureSignature:$,secureExpire:$,secureDeliveryProxy:$,retryThrottledRequestMaxTimes:Z,retryNetworkErrorMaxTimes:Z,multipartMinFileSize:Z,multipartChunkSize:Z,maxConcurrentRequests:Z,multipartMaxConcurrentRequests:Z,multipartMaxAttempts:Z,checkForUrlDuplicates:N,saveUrlForRecurrentUploads:N,groupOutput:N,userAgentIntegration:$,debug:N,localeName:$,metadata:sn,secureUploadsExpireThreshold:Z,localeDefinitionOverride:o=>Wr(o),secureUploadsSignatureResolver:o=>Vi(o),secureDeliveryProxyUrlResolver:o=>Vi(o),iconHrefResolver:o=>Vi(o),fileValidators:qr,collectionValidators:qr,validationTimeout:Z,validationConcurrency:Z,cameraModes:on,defaultCameraMode:rn,enableAudioRecording:N,enableVideoRecording:N,mediaRecorderOptions:Wr,maxVideoRecordingDuration:Z,filesViewMode:nn,gridShowFileNames:N,cloudImageEditorAutoOpen:N,cloudImageEditorMaskHref:$,testMode:N,qualityInsights:N},an=(o,i)=>{if(!(typeof i>"u"||i===null))try{return jl[o](i)}catch(e){return console.error(`Invalid value for config key "${o}".`,e),se[o]}};var Fi=[...new Set(["debug",...Object.keys(se)])],Kl=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],dn=o=>Kl.includes(o),jt=Fi.filter(o=>!dn(o)),ln={...Object.fromEntries(jt.map(o=>[Ht(o),o])),...Object.fromEntries(jt.map(o=>[o.toLowerCase(),o]))},Gl={...Object.fromEntries(jt.map(o=>[Ht(o),q(o)])),...Object.fromEntries(jt.map(o=>[o.toLowerCase(),q(o)]))},cn=o=>`__${o}`,Ni=class extends T{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(se).map(([e,t])=>[q(e),t]))};this.computationControllers=new Map}_flushValueToAttribute(e,t){if(!dn(e)){let r=[...new Set([Ht(e),e.toLowerCase()])];for(let s of r)typeof t>"u"||t===null?this.removeAttribute(s):this.getAttribute(s)!==t.toString()&&this.setAttribute(s,t.toString())}}_flushValueToState(e,t){this.$[q(e)]!==t&&(typeof t>"u"||t===null?this.$[q(e)]=se[e]:this.$[q(e)]=t)}_setValue(e,t){let r=this,s=an(e,t),n=cn(e);r[n]!==s&&(this._assertSameValueDifferentReference(e,r[n],s),r[n]=s,this._flushValueToAttribute(e,s),this._flushValueToState(e,s),this.debugPrint(`[uc-config] "${e}"`,s),qs(this.cfg))}_getValue(e){let t=this,r=cn(e);return t[r]??this.$[q(e)]}_assertSameValueDifferentReference(e,t,r){this.cfg.debug&&r!==t&&typeof r=="object"&&typeof t=="object"&&JSON.stringify(r)===JSON.stringify(t)&&(console.warn(`[uc-config] Option "${e}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${e}" previous value:`,t),console.warn(`[uc-config] "${e}" new value:`,r))}initCallback(){super.initCallback();let e=this;for(let t of jt)this.sub(q(t),r=>{this._setValue(t,r)},!1);for(let t of Fi){let r=e[t]??this.$[q(t)];r!==se[t]&&this._setValue(t,r),Object.defineProperty(this,t,{set:s=>{this._setValue(t,s)},get:()=>this._getValue(t)})}for(let t of Fi)this.sub(q(t),()=>{Js({key:t,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this.computationControllers})})}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),t===r)return;let s=this,n=ln[e];n&&(s[n]=r),Gl[e]&&(this[e]=r)}static get observedAttributes(){return[...super.observedAttributes,...Object.keys(ln)]}};for(let o of Fi)Ni.prototype[o]=void 0;var Xr=class extends T{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i)})}render(){return m.html`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`}};function Wl(o){return new Promise(i=>{typeof window.FileReader!="function"&&i(!1);try{let e=new FileReader;e.onerror=()=>{i(!0)};let t=r=>{r.type!=="loadend"&&e.abort(),i(!1)};e.onloadend=t,e.onprogress=t,e.readAsDataURL(o)}catch{i(!1)}})}function ql(o,i){return new Promise(e=>{let t=0,r=[],s=a=>{if(!a){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),e(null);return}a.isFile?(t++,a.file(l=>{t--;let d=new File([l],l.name,{type:l.type||i});r.push({type:"file",file:d,fullPath:a.fullPath}),t===0&&e(r)})):a.isDirectory&&n(a.createReader())},n=a=>{t++,a.readEntries(l=>{t--;for(let d of l)s(d);t===0&&e(r)})};s(o)})}function un(o){let i=[],e=[];for(let t=0;t<o.items.length;t++){let r=o.items[t];if(r)if(r.kind==="file"){let s=r.type,n=r;if(typeof n.webkitGetAsEntry=="function"||typeof n.getAsEntry=="function"){let l=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():n.getAsEntry?.();l&&e.push(ql(l,s).then(d=>{d&&i.push(...d)}));continue}let a=r.getAsFile();a&&e.push(Wl(a).then(l=>{l||i.push({type:"file",file:a})}))}else r.kind==="string"&&/^text\/uri-list/.test(r.type)&&e.push(new Promise(s=>{r.getAsString(n=>{i.push({type:"url",url:n}),s()})}))}return Promise.all(e).then(()=>i)}var te=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),pn=["focus"],Xl=100,Zr=new Map;function Zl(o,i){let e=Math.max(Math.min(o[0],i.x+i.width),i.x),t=Math.max(Math.min(o[1],i.y+i.height),i.y);return Math.sqrt((o[0]-e)*(o[0]-e)+(o[1]-t)*(o[1]-t))}function Qr(o){let i=0,e=document.body,t=new Set,r=y=>{t.add(y)},s=te.INACTIVE,n=y=>{o.shouldIgnore()&&y!==te.INACTIVE||(s!==y&&t.forEach(w=>{w(y)}),s=y)},a=()=>i>0;r(y=>o.onChange(y));let l=()=>{i=0,n(te.INACTIVE)},d=()=>{i+=1,s===te.INACTIVE&&n(te.ACTIVE)},u=()=>{i-=1,a()||n(te.INACTIVE)},p=y=>{y.preventDefault(),i=0,n(te.INACTIVE)},f=y=>{if(o.shouldIgnore())return;a()||(i+=1);let w=[y.x,y.y],C=o.element.getBoundingClientRect(),E=Math.floor(Zl(w,C)),x=E<Xl,k=y.composedPath().includes(o.element);Zr.set(o.element,E);let pe=Math.min(...Zr.values())===E;k&&pe?(y.preventDefault(),n(te.OVER)):n(x&&pe?te.NEAR:te.ACTIVE)},g=async y=>{if(o.shouldIgnore())return;y.preventDefault();let{dataTransfer:w}=y;if(!w)return;let C=await un(w);o.onItems(C),n(te.INACTIVE)};return e.addEventListener("drop",p),e.addEventListener("dragleave",u),e.addEventListener("dragenter",d),e.addEventListener("dragover",f),o.element.addEventListener("drop",g),pn.forEach(y=>{window.addEventListener(y,l)}),()=>{Zr.delete(o.element),e.removeEventListener("drop",p),e.removeEventListener("dragleave",u),e.removeEventListener("dragenter",d),e.removeEventListener("dragover",f),o.element.removeEventListener("drop",g),pn.forEach(y=>{window.removeEventListener(y,l)})}}var Yr=new Set,_e=class extends M{constructor(){super(...arguments);this.disabled=!1;this.clickable=!1;this.withIcon=!1;this.fullscreen=!1;this.initflow=!1;this.isEnabled=!0;this.isVisible=!0;this._destroyDropzone=null;this._destroyContentWrapperDropzone=null;this.contentWrapperRef=(0,b.createRef)();this.handleAreaInteraction=e=>{if(e instanceof KeyboardEvent){if(e.code!=="Space"&&e.code!=="Enter")return}else if(!(e instanceof MouseEvent))return;if(this.initflow){this.api.initFlow();return}this.api.openSystemDialog()};this.sourceListAllowsLocal=!0;this.clickableListenersAttached=!1}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-area"]}get localizedText(){let e=this.text;return typeof e=="string"&&e.length>0?this.l10n(e)||e:this.l10n("drop-files-here")}isActive(){if(!this.isEnabled)return!1;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),s=window.getComputedStyle(this),n=s.visibility!=="hidden"&&s.display!=="none";return t&&n&&r}initCallback(){super.initCallback(),Yr.add(this),this.updateIsEnabled(),this.updateVisibility(),this.updateClickableListeners(),this.updateDragStateAttribute(te.INACTIVE),this._destroyDropzone=Qr({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:t=>{this.updateDragStateAttribute(t)},onItems:t=>{t.length&&(t.forEach(r=>{r.type==="url"?this.api.addFileFromUrl(r.url,{source:B.DROP_AREA}):r.type==="file"&&this.api.addFileFromObject(r.file,{source:B.DROP_AREA,fullPath:r.fullPath})}),this.uploadCollection.size&&(this.modalManager?.open(_.activities.UPLOAD_LIST),this.set$({"*currentActivity":_.activities.UPLOAD_LIST})))}});let e=this.contentWrapperRef.value;e&&(this._destroyContentWrapperDropzone=Qr({element:e,onChange:t=>{let r=Object.entries(te).find(([,s])=>s===t)?.[0].toLowerCase();r&&e.setAttribute("drag-state",r)},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()})),this.subConfigValue("sourceList",t=>{let r=j(t);this.sourceListAllowsLocal=r.includes(B.LOCAL),this.updateIsEnabled(),this.updateVisibility()})}willUpdate(e){super.willUpdate(e),e.has("disabled")&&(this.updateIsEnabled(),this.updateVisibility())}updated(e){super.updated(e),e.has("clickable")&&this.updateClickableListeners()}_shouldIgnore(){if(!this.isEnabled||!this._couldHandleFiles())return!0;if(!this.fullscreen)return!1;let e=Yr;return e.size===0?!1:[...e].filter(s=>s!==this).filter(s=>s.isActive()).length>0}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,r=this.uploadCollection.size;return!(e&&t&&r>=t||!e&&r>0)}updateIsEnabled(){let e=this.sourceListAllowsLocal&&!this.disabled;this.isEnabled=e}updateVisibility(){let e=this.isEnabled||!this.querySelector("[data-default-slot]");this.isVisible=e,this.hidden=!e}updateDragStateAttribute(e){let t=Object.entries(te).find(([,r])=>r===e)?.[0].toLowerCase();t&&this.setAttribute("drag-state",t)}updateClickableListeners(){this.clickable&&!this.clickableListenersAttached?(this.addEventListener("keydown",this.handleAreaInteraction),this.addEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!0):!this.clickable&&this.clickableListenersAttached&&(this.removeEventListener("keydown",this.handleAreaInteraction),this.removeEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!1)}disconnectedCallback(){super.disconnectedCallback(),Yr.delete(this),this._destroyDropzone?.(),this._destroyContentWrapperDropzone?.(),this.clickableListenersAttached&&(this.removeEventListener("keydown",this.handleAreaInteraction),this.removeEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!1)}render(){return m.html` ${this.yield("",m.html`<div data-default-slot hidden></div><div ${(0,b.ref)(this.contentWrapperRef)} class="uc-content-wrapper" ?hidden=${!this.isVisible}><div class="uc-icon-container" ?hidden=${!this.withIcon}><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">${this.localizedText}</span></div>`)} `}};h([(0,c.property)({type:Boolean,reflect:!0})],_e.prototype,"disabled",2),h([(0,c.property)({type:Boolean,reflect:!0})],_e.prototype,"clickable",2),h([(0,c.property)({type:Boolean,attribute:"with-icon",reflect:!0})],_e.prototype,"withIcon",2),h([(0,c.property)({type:Boolean,reflect:!0})],_e.prototype,"fullscreen",2),h([(0,c.property)({type:Boolean,reflect:!0})],_e.prototype,"initflow",2),h([(0,c.property)({type:String})],_e.prototype,"text",2),h([(0,c.state)()],_e.prototype,"isEnabled",2),h([(0,c.state)()],_e.prototype,"isVisible",2);var hn=()=>{let o=globalThis.top??globalThis.parent??globalThis.self;try{return o.location.origin}catch(i){return console.warn("Unable to access top-level window location:",i),globalThis.location.origin}};var Ql=o=>o.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),mn=(o,i="i")=>{let e=o.split("*").map(Ql);return new RegExp(`^${e.join(".+")}$`,i)};var Yl=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],Jl=(o,i)=>window.getComputedStyle(o).getPropertyValue(i).trim(),fn=o=>{let i={};for(let e of Yl){let t=Jl(o,e);t&&(i[e]=t)}return i};var ec=["selected-files-change","toolbar-state-change"],tc=o=>{if(!o||typeof o!="object"||!("type"in o))return!1;let i=o.type;return!(typeof i!="string"||!ec.includes(i))},Bi=class{constructor(i,e){this._handlerMap=new Map;this._handleMessage=i=>{if(i.source!==this._context)return;let e=i.data;if(!tc(e))return;let t=this._handlerMap.get(e.type);if(t)for(let r of t)r(e)};this._context=i,this._getTargetOrigin=e,window.addEventListener("message",this._handleMessage)}on(i,e){let t=this._handlerMap.get(i)??new Set;this._handlerMap.has(i)||this._handlerMap.set(i,t),t.add(e)}send(i){let e=this._getTargetOrigin();this._context.postMessage(i,e)}destroy(){window.removeEventListener("message",this._handleMessage)}};function gn(o){let i=[];for(let[e,t]of Object.entries(o))t==null||typeof t=="string"&&t.length===0||i.push(`${e}=${encodeURIComponent(t)}`);return i.join("&")}var ic={[Ee.GDRIVE]:"ngdrive"},me=class extends M{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.EXTERNAL;this.iframeRef=(0,b.createRef)();this._latestSelectionSummary=null;this.selectedList=[];this.isSelectionReady=!1;this.isDoneBtnEnabled=!1;this.couldSelectAll=!1;this.couldDeselectAll=!1;this.showSelectionStatus=!1;this.showDoneBtn=!1;this.doneBtnTextClass="uc-hidden";this.toolbarVisible=!0;this._handleDone=()=>{for(let e of this.selectedList){let t=this.extractUrlFromSelectedFile(e),{filename:r}=e,{externalSourceType:s}=this.activityParams;this.api.addFileFromUrl(t,{fileName:r,source:s})}this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.modalManager?.open(_.activities.UPLOAD_LIST)};this._handleCancel=()=>{this.historyBack()};this._handleSelectAll=()=>{this._messageBridge?.send({type:"select-all"})};this._handleDeselectAll=()=>{this._messageBridge?.send({type:"deselect-all"})}}get counterText(){if(!this._latestSelectionSummary)return"";let{selectedCount:e,total:t}=this._latestSelectionSummary;return this.l10n("selected-count",{count:e,total:t})}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:e}=this.activityParams;if(!e){this.modalManager?.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.mountIframe()}}),this.sub("*currentActivityParams",()=>{this.isActivityActive&&(this.unmountIframe(),this.mountIframe())}),this.sub("*currentActivity",e=>{e!==this.activityType&&this.unmountIframe()}),this.subConfigValue("multiple",e=>{this.showSelectionStatus=e}),this.subConfigValue("localeName",()=>{this.setupL10n()}),this.subConfigValue("externalSourcesEmbedCss",e=>{this.applyEmbedCss(e)})}extractUrlFromSelectedFile(e){if(e.alternatives){let t=j(this.cfg.externalSourcesPreferredTypes);for(let r of t){let s=mn(r);for(let[n,a]of Object.entries(e.alternatives))if(s.test(n))return a}}return e.url}handleToolbarStateChange(e){this.toolbarVisible=e.isVisible}async handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this._setSelectionSummary(e.selectedCount,e.total),this.doneBtnTextClass=e.isReady?"":"uc-hidden",this.isSelectionReady=e.isReady,this.isDoneBtnEnabled=e.isReady&&e.selectedFiles.length>0,this.showSelectionStatus=e.isMultipleMode&&e.total>0,this.couldSelectAll=e.selectedCount<e.total,this.couldDeselectAll=e.selectedCount===e.total,this.selectedList=e.selectedFiles??[],this.showDoneBtn=e.total>0}handleIframeLoad(){this.applyEmbedCss(this.cfg.externalSourcesEmbedCss),this.applyTheme(),this.setupL10n()}applyTheme(){this._messageBridge?.send({type:"set-theme-definition",theme:fn(this)})}applyEmbedCss(e){this._messageBridge?.send({type:"set-embed-css",css:e})}setupL10n(){this._messageBridge?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:r,multiple:s}=this.cfg,{externalSourceType:n}=this.activityParams,a=ic[n]??n,d={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:!0,multiple:s.toString(),origin:this.cfg.topLevelOrigin||hn(),debug:this.cfg.debug},u=new URL(`/window4/${a}`,r);return u.search=gn(d),u.toString()}_setSelectionSummary(e,t){this._latestSelectionSummary={selectedCount:e,total:t}}mountIframe(){let e=document.createElement("iframe");e.src=this.remoteUrl(),e.marginHeight=0,e.marginWidth=0,e.frameBorder="0",e.allowTransparency=!0,e.addEventListener("load",this.handleIframeLoad.bind(this)),e.addEventListener("load",this.handleIframeLoad.bind(this)),this.iframeRef.value&&(this.iframeRef.value.innerHTML="",this.iframeRef.value.appendChild(e)),e.contentWindow&&(this._messageBridge?.destroy(),this._messageBridge=new Bi(e.contentWindow,()=>this.cfg.socialBaseUrl),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this.handleToolbarStateChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){this._messageBridge?.destroy(),this._messageBridge=void 0,this.iframeRef.value&&(this.iframeRef.value.innerHTML=""),this.resetSelectionStatus()}resetSelectionStatus(){this.selectedList=[],this.isSelectionReady=!1,this.isDoneBtnEnabled=!1,this.couldSelectAll=!1,this.couldDeselectAll=!1,this.showSelectionStatus=!1,this.showDoneBtn=!1,this.doneBtnTextClass="uc-hidden",this._latestSelectionSummary=null}render(){return m.html`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*historyBack"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ${(0,b.ref)(this.iframeRef)} class="uc-iframe-wrapper"></div><div class="uc-toolbar" ?hidden=${!this.toolbarVisible}><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("cancel")}</button><div class="uc-selection-status-box" ?hidden=${!this.showSelectionStatus}><span>${this.counterText}</span><button type="button" @click=${this._handleSelectAll} ?hidden=${!this.couldSelectAll}>${this.l10n("select-all")}</button><button type="button" @click=${this._handleDeselectAll} ?hidden=${!this.couldDeselectAll}>${this.l10n("deselect-all")}</button></div><button type="button" class="uc-done-btn uc-primary-btn" @click=${this._handleDone} ?disabled=${!this.isDoneBtnEnabled} ?hidden=${!this.showDoneBtn} ><uc-spinner ?hidden=${this.isSelectionReady} ></uc-spinner><span class=${this.doneBtnTextClass}>${this.l10n("done")}</span></button></div></div>`}};h([(0,c.state)()],me.prototype,"selectedList",2),h([(0,c.state)()],me.prototype,"isSelectionReady",2),h([(0,c.state)()],me.prototype,"isDoneBtnEnabled",2),h([(0,c.state)()],me.prototype,"couldSelectAll",2),h([(0,c.state)()],me.prototype,"couldDeselectAll",2),h([(0,c.state)()],me.prototype,"showSelectionStatus",2),h([(0,c.state)()],me.prototype,"showDoneBtn",2),h([(0,c.state)()],me.prototype,"doneBtnTextClass",2),h([(0,c.state)()],me.prototype,"toolbarVisible",2);var Hi=()=>{let o=[];return{stack:o,promiseReadJpegChunks:e=>new Promise((t,r)=>{let s=2,n=(d,u)=>{let p=new FileReader;p.addEventListener("load",()=>{u(new DataView(p.result))}),p.addEventListener("error",f=>{r(`Reader error: ${f}`)}),p.readAsArrayBuffer(d)},a=()=>n(e.slice(s,s+128),d=>{let u,p,f;for(u=p=0,f=d.byteLength;f>=0?p<f:p>f;u=f>=0?++p:--p)if(d.getUint8(u)===255){s+=u;break}l()}),l=()=>{let d=s;return n(e.slice(s,s+=4),u=>{if(u.byteLength!==4||u.getUint8(0)!==255){r("Corrupted");return}let p=u.getUint8(1);if(p===218){t(!0);return}let f=u.getUint16(2)-2;return n(e.slice(s,s+=f),g=>{if(g.byteLength!==f){r("Corrupted");return}o.push({startPos:d,length:f,marker:p,view:g}),a()})})};FileReader&&DataView||r("Not Support"),n(e.slice(0,2),d=>{d.getUint16(0)!==65496&&r("Not jpeg"),a()})})}},rc=async o=>{let i=[],{promiseReadJpegChunks:e,stack:t}=Hi();return await e(o),t.forEach(({marker:r,view:s})=>{r===226&&s.getUint32(0)===1229144927&&s.getUint32(4)===1347571526&&s.getUint32(8)===1229735168&&i.push(s)}),i},yn=async(o,i,e)=>{{let t=[],r=[],{promiseReadJpegChunks:s,stack:n}=Hi();await s(o),n.forEach(d=>{if(d.marker===i)return t.push(d.startPos),r.push(d.length)});let a=[o.slice(0,2)];for(let d of e){let u=new DataView(new ArrayBuffer(4));u.setUint16(0,65280+i),u.setUint16(2,d.byteLength+2),a.push(u.buffer),a.push(d)}let l=2;for(let d=0;d<t.length;d++)t[d]>l&&a.push(o.slice(l,t[d])),l=t[d]+r[d]+4;return a.push(o.slice(l,o.size)),new Blob(a,{type:o.type})}};var bn=(o,i)=>yn(o,226,i.map(e=>e.buffer)),oc=async o=>{try{return await bn(o,[])}catch(i){throw new Error(`Failed to strip ICC profile: ${i}`)}},sc=(o,i,e)=>new Promise((t,r)=>{let s=n=>{if(!n){r("Failed to convert canvas to blob");return}t(n)};o.toBlob(s,i,e),o.width=o.height=1}),Kt=()=>{let o=document.createElement("canvas"),i=o.getContext("2d");return{canvas:o,ctx:i}},nc=o=>{let{ctx:e,canvas:t}=Kt();t.width=t.height=50,e.drawImage(o,0,0,50,50);let r=e.getImageData(0,0,50,50).data;t.width=t.height=1;for(let s=3;s<r.length;s+=4)if(r[s]<254)return!0;return!1},ac=async o=>{let i=null,{promiseReadJpegChunks:e,stack:t}=Hi();return await e(o),t.forEach(({marker:r,view:s})=>{if(!i&&r===225&&s.byteLength>=14&&s.getUint32(0)===1165519206&&s.getUint16(4)===0){i=s;return}}),i},lc="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",zi,cc=()=>new Promise(o=>{if(zi!==void 0)o(zi);else{let i=new Image;i.addEventListener("load",()=>{zi=i.naturalWidth<i.naturalHeight,i.src="//:0",o(zi)}),i.src=lc}}),dc=(o,i)=>{let e,t,r,s;if(!o||o.byteLength<14||o.getUint32(0)!==1165519206||o.getUint16(4)!==0)return;if(o.getUint16(6)===18761)t=!0;else if(o.getUint16(6)===19789)t=!1;else return;if(o.getUint16(8,t)!==42)return;r=8+o.getUint32(10,t);let n=o.getUint16(r-2,t);for(e=0,s=n;s>=0?e<s:e>s;s>=0?++e:--e){if(o.byteLength<r+10)return;o.getUint16(r,t)===274&&i(r+8,t),r+=12}},uc=(o,i)=>{dc(o,(e,t)=>o.setUint16(e,i,t))},pc=async(o,i,e)=>(e&&uc(i,1),yn(o,225,[i.buffer])),hc=(o,i)=>new Promise((e,t)=>{i&&(o.src=i),o.complete?e(o):(o.addEventListener("load",()=>{e(o)}),o.addEventListener("error",()=>{t(new Error("Failed to load image. Probably not an image."))}))}),mc=o=>hc(new Image,o),fc=[1,3],gc=[192,193,194,195,197,198,199,201,202,203,205,206,207],vn={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},vc=async o=>{let i=!1,{promiseReadJpegChunks:e,stack:t}=Hi();return await e(o).then(()=>(t.forEach(({marker:r,view:s})=>{if(!i&&gc.indexOf(r)>=0){let n=s.getUint8(5);fc.indexOf(n)<0&&(i=!0)}}),i)).catch(()=>i)},_n=(o,i)=>{let e={};return(...t)=>{let r=i(t,e);return r in e?e[r]:e[r]=o(...t)}},wn=(o,i)=>{let[e]=o,t=Object.keys(i).map(r=>parseInt(r,10)).sort((r,s)=>r-s);for(let r=0;r<t.length;r++){let s=t[r],n=!!i[s];if(s>e&&n||s<e&&!n)return s}return e},Ze={R:55,G:110,B:165,A:255},yc=`rgba(${Ze.R}, ${Ze.G}, ${Ze.B}, ${Ze.A/255})`,Cn=(o,i)=>{try{let e=[o-1,i-1,1,1],{canvas:t,ctx:r}=Kt();t.width=1,t.height=1;let{canvas:s,ctx:n}=Kt();s.width=o,s.height=i,n&&(n.fillStyle=yc,n.fillRect(...e),r.drawImage(s,o-1,i-1,1,1,0,0,1,1));let a=r&&r.getImageData(0,0,1,1).data,l=!1;return a&&(l=a[0]===Ze.R&&a[1]===Ze.G&&a[2]===Ze.B&&a[3]===Ze.A),s.width=s.height=1,l}catch{return console.error(`Failed to test for max canvas size of ${o}x${i}.`),!1}};function Tn(o){return(...i)=>new Promise(e=>{setTimeout(()=>{let t=o(...i);e(t)},0)})}var bc=Tn(_n(Cn,wn)),_c=Tn(_n(Cn,wn)),En=async(o,i)=>{let e=vn.squareSide.find(n=>n*n>=o*i),t=vn.dimension.find(n=>n>=o&&n>=i);if(!e||!t)throw new Error("Not supported");let[r,s]=await Promise.all([bc(e,e),_c(t,1)]);if(r&&s)return!0;throw new Error("Not supported")},xn=async(o,i,e)=>{try{let{ctx:t,canvas:r}=Kt();return r.width=i,r.height=e,t.imageSmoothingQuality="high",t.drawImage(o,0,0,i,e),o instanceof HTMLImageElement&&(o.src="//:0"),o instanceof HTMLCanvasElement&&(o.width=o.height=1),r}catch(t){throw new Error("Canvas resize error",{cause:t})}},wc=({img:o,targetW:i,targetH:e})=>xn(o,i,e),Cc=function({sourceW:o,targetW:i,targetH:e,step:t}){let r=[],s=i,n=e;do r.push([s,n]),s=Math.round(s/t),n=Math.round(n/t);while(s<o*t);return r.reverse()},Tc=({img:o,sourceW:i,targetW:e,targetH:t,step:r})=>{let s=Cc({sourceW:i,targetW:e,targetH:t,step:r});return s.reduce((n,[a,l],d)=>n.then(u=>En(a,l).then(()=>xn(u,a,l)).catch(()=>{if(d===s.length-1)throw new Error("Not supported");return u})),Promise.resolve(o))},Ec=()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),xc=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Jr=.71,Sc=(o,i)=>{if(o.width*Jr*o.height*Jr<i.size)throw new Error("Not required");let e=o.width,t=o.height,r=e/t,s=Math.floor(Math.sqrt(i.size*r)),n=Math.floor(i.size/Math.sqrt(i.size*r));return En(s,n).then(()=>{let{ctx:a}=Kt();return"imageSmoothingQuality"in a&&!Ec()&&!xc?wc({img:o,targetW:s,targetH:n}):Tc({img:o,sourceW:e,targetW:s,targetH:n,step:Jr})}).catch(()=>Promise.reject("Not supported"))},Sn=async(o,i)=>{try{if(await vc(o))throw new Error("Should skipped");let t=await Promise.allSettled([ac(o),cc(),rc(o)]),s=!t.some(w=>w.status==="rejected"),[n,a,l]=t,d=await oc(o).catch(()=>o),u=await mc(URL.createObjectURL(d));URL.revokeObjectURL(u.src);let p=await Sc(u,i),f="image/jpeg",g=i?.quality||.8;!s&&nc(p)&&(f="image/png",g=void 0);let y=await sc(p,f,g);if(s&&n.status==="fulfilled"&&n.value){let w=n.value,C=a.status==="fulfilled"?a.value:!1;y=await pc(y,w,C)}return s&&l.status==="fulfilled"&&l.value.length>0&&(y=await bn(y,l.value)),y}catch(e){let t;throw e instanceof Error&&(t=e.message),typeof e=="string"&&(t=e),new Error(`Failed to shrink image. ${t?`Message: "${t}".`:""}`,{cause:e})}};var Ac=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,An=o=>{if(typeof o!="string")return!1;let i=Ac.exec(o.toLocaleLowerCase())??[];if(i.length===0)return!1;let e=Number(i[1])*Number(i[2]),t=16384*16384;return e>t?(console.warn(`Shrinked size can not be larger than ${Math.floor(t/1e3/1e3)}MP. You have set ${i[1]}x${i[2]} (${Math.ceil(e/1e3/100)/10}MP).`),!1):{quality:i[3]?Number(i[3])/100:void 0,size:e}};var Ct=class extends M{constructor(){super(...arguments);this._entrySubs=new Set;this._entry=null}_withEntry(e){return(...t)=>{let r=this._entry;if(!r){console.warn("No entry found");return}return e(r,...t)}}_subEntry(e,t){this._withEntry((r,s,n)=>{let a=r.subscribe(s,l=>{this.isConnected&&n(l)});this._entrySubs.add(a)})(e,t)}_reset(){for(let e of this._entrySubs)e.remove();this._entrySubs=new Set,this._entry=null}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set}};var G=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),K=class K extends Ct{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.pauseRender=!0;this.uid="";this.itemName="";this.errorText="";this.hint="";this.progressValue=0;this.progressVisible=!1;this.badgeIcon="";this.isFinished=!1;this.isFailed=!1;this.isUploading=!1;this.isFocused=!1;this.isEditable=!1;this.showFileNames=!1;this.ariaLabelStatusFile="";this._renderedOnce=!1;this._isIntersecting=!1;this._handleEdit=this._withEntry(e=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"edit-file",node:this.tagName}}}),this.$["*currentActivityParams"]={internalId:e.uid},this.modalManager?.open(_.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT});this._handleRemove=()=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uid&&this.uploadCollection.remove(this.uid)};this._handleUploadClick=()=>{this.upload()};this._debouncedCalculateState=L(()=>this._calculateState(),100);this._updateHintAndProgress=this._withEntry(_t((e,t)=>{let r=e.getValue("errors")?.[0]?.message??"",s=e.getValue("source"),n=e.getValue("externalUrl"),a=t===G.FINISHED,l=t===G.UPLOADING,d=t===G.QUEUED_UPLOADING,u=t===G.QUEUED_VALIDATION,p=t===G.VALIDATION,f=e.getValue("fileName"),g="";r?g="":!a&&n&&s&&Object.values(Ee).includes(s)&&(g=this.l10n("waiting-for",{source:this.l10n(`src-type-${s}`)})),this.hint=g,this.errorText=r,this.progressVisible=l||d||u||p,this.progressValue=u||p?0:e.getValue("uploadProgress"),this.ariaLabelStatusFile=f?this.l10n("a11y-file-item-status",{fileName:f,status:this.l10n(t?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()}):""},100));this.upload=this._withEntry(async e=>{if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0||e.getValue("isValidationPending"))return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){e.setMultipleValues({isUploading:!0,errors:[],isQueuedForUploading:!0}),this._debouncedCalculateState();try{let r=new AbortController;e.setValue("abortController",r);let s=async()=>{e.setValue("isQueuedForUploading",!1);let a=e.getValue("file");if(a instanceof File&&this.cfg.imageShrink)try{let p=An(this.cfg.imageShrink);p?a=await Sn(a,p):console.warn("Image shrink settings are invalid, skipping shrinking")}catch{}let l=a||e.getValue("externalUrl")||e.getValue("uuid");if(!l)throw new Error("No file input");let u={...await this.getUploadClientOptions(),fileName:e.getValue("fileName")??void 0,source:e.getValue("source")??void 0,onProgress:p=>{if(p.isComputable){let f=p.value*100;e.setValue("uploadProgress",f)}},signal:r.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",l,u),fr(l,u)},n=await this.$["*uploadQueue"].add(s);e.setMultipleValues({fileInfo:n,isQueuedForUploading:!1,isUploading:!1,fileName:n.originalFilename,fileSize:n.size,isImage:n.isImage??!1,mimeType:n.contentInfo?.mime?.mime??n.mimeType,uuid:n.uuid,cdnUrl:e.getValue("cdnUrl")??n.cdnUrl,cdnUrlModifiers:e.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:e.getValue("source")??null}),e===this._entry&&this._debouncedCalculateState()}catch(r){this.telemetryManager.sendEventError(r,"file upload. Failed to upload file"),r instanceof $e&&r.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):r instanceof Ye?e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:r}):(console.error("Unknown upload error",r),e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:r})})),e===this._entry&&this._debouncedCalculateState()}}})}_calculateState(){let e=this._entry;if(!e)return;let t=G.IDLE;e.getValue("errors").length>0?t=G.FAILED:e.getValue("isQueuedForUploading")?t=G.QUEUED_UPLOADING:e.getValue("isQueuedForValidation")?t=G.QUEUED_VALIDATION:e.getValue("isValidationPending")?t=G.VALIDATION:e.getValue("isUploading")?t=G.UPLOADING:e.getValue("fileInfo")&&(t=G.FINISHED),this._handleState(e,t)}_handleState(e,t){t===G.FAILED?this.badgeIcon="badge-error":t===G.FINISHED&&(this.badgeIcon="badge-success"),t===G.UPLOADING&&(this.isFocused=!1,this.removeAttribute("focused")),this.isFailed=t===G.FAILED,this.isUploading=t===G.UPLOADING,this.isFinished=t===G.FINISHED,this.isEditable=!!(this.cfg.useCloudImageEditor&&e.getValue("isImage")&&e.getValue("cdnUrl")),this._updateHintAndProgress(t)}_reset(){super._reset(),this._debouncedCalculateState.cancel()}_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,this._thumbRect=t.boundingClientRect,t.isIntersecting&&!this._renderedOnce&&(this.pauseRender=!1,this._renderedOnce=!0))}_handleEntryId(e){this._reset();let t=this.uploadCollection?.read(e);this._entry=t,t&&(this._subEntry("isQueuedForValidation",()=>{this._debouncedCalculateState()}),this._subEntry("isValidationPending",()=>{this._debouncedCalculateState()}),this._subEntry("uploadProgress",()=>{this._debouncedCalculateState()}),this._subEntry("isQueuedForUploading",()=>{this._debouncedCalculateState()}),this._subEntry("fileName",r=>{this.itemName=r||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",r=>{this.itemName=t.getValue("fileName")||r||this.l10n("file-no-name")}),this._subEntry("fileInfo",()=>{this._debouncedCalculateState()}),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._calculateState())}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this.showFileNames=!0;return}this.showFileNames=e}willUpdate(e){super.willUpdate(e),e.has("uid")&&this._handleEntryId(this.uid)}initCallback(){super.initCallback(),this._handleEntryId(this.uid),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.subConfigValue("filesViewMode",e=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",e)}),this.subConfigValue("gridShowFileNames",e=>{this._updateShowFileNames(e)}),this.onclick=()=>{K.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{this._entry&&!e.has(this._entry.uid)||setTimeout(()=>this.isConnected&&this.upload())}),K.activeInstances.add(this)}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),K.activeInstances.delete(this),this._reset()}static{this.activeInstances=new Set}shouldUpdate(e){return this.pauseRender===!1}render(){return m.html`<div class="uc-inner" ?finished=${this.isFinished} ?uploading=${this.isUploading} ?failed=${this.isFailed} ?focused=${this.isFocused}><uc-thumb .uid=${this.uid} .badgeIcon=${this.badgeIcon}></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" aria-label=${this.ariaLabelStatusFile}><span class="uc-file-name" ?hidden=${!this.showFileNames}>${this.itemName}</span><span class="uc-file-error" ?hidden=${!this.errorText}>${this.errorText}</span><span class="uc-file-hint" ?hidden=${!this.hint}>${this.hint}</span></div><div class="uc-file-actions"><button type="button" @click=${this._handleEdit} ?hidden=${!this.isEditable} title=${this.l10n("file-item-edit-button")} aria-label=${this.l10n("file-item-edit-button")} class="uc-edit-btn uc-mini-btn" ><uc-icon name="edit-file"></uc-icon></button><button type="button" @click=${this._handleRemove} title=${this.l10n("file-item-remove-button")} aria-label=${this.l10n("file-item-remove-button")} class="uc-remove-btn uc-mini-btn" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" @click=${this._handleUploadClick}><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" .value=${this.progressValue} .visible=${this.progressVisible} ?hasFileName=${this.showFileNames}></uc-progress-bar></div>`}};h([(0,c.property)({type:String,attribute:!1})],K.prototype,"uid",2),h([(0,c.state)()],K.prototype,"itemName",2),h([(0,c.state)()],K.prototype,"errorText",2),h([(0,c.state)()],K.prototype,"hint",2),h([(0,c.state)()],K.prototype,"progressValue",2),h([(0,c.state)()],K.prototype,"progressVisible",2),h([(0,c.state)()],K.prototype,"badgeIcon",2),h([(0,c.state)()],K.prototype,"isFinished",2),h([(0,c.state)()],K.prototype,"isFailed",2),h([(0,c.state)()],K.prototype,"isUploading",2),h([(0,c.state)()],K.prototype,"isFocused",2),h([(0,c.state)()],K.prototype,"isEditable",2),h([(0,c.state)()],K.prototype,"showFileNames",2),h([(0,c.state)()],K.prototype,"ariaLabelStatusFile",2);var eo=K;var to=class extends M{constructor(){super(...arguments);this._validationInputElement=null;this._dynamicInputsContainer=null}_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,kt(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{{if(!this._dynamicInputsContainer){let n=document.createElement("div");this.appendChild(n),this._dynamicInputsContainer=n}if(!this._validationInputElement){let n=this._createValidationInput();this.appendChild(n),this._validationInputElement=n}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let n=e.errors[0]?.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(n??"");return}let t=e.group?e.group:null;if(t){this._validationInputElement.value=t.cdnUrl??"",this._validationInputElement.setCustomValidity("");return}let r=e.allEntries.map(n=>n.cdnUrl).filter(n=>typeof n=="string");if(!this.cfg.multiple&&r.length===1&&r[0]){this._validationInputElement.value=r[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let s=new DocumentFragment;for(let n of r){let a=document.createElement("input");a.type="hidden",a.name=`${this.ctxName}[]`,a.value=n,s.appendChild(a)}this._dynamicInputsContainer.replaceChildren(s)}},!1)}};var Gt=class extends T{constructor(){super(...arguments);this.name="";this.resolvedHref="";this.iconHrefResolver=null}initCallback(){super.initCallback(),this.setAttribute("aria-hidden","true"),this.subConfigValue("iconHrefResolver",e=>{this.iconHrefResolver=e,this.updateResolvedHref()})}willUpdate(e){super.willUpdate(e),e.has("name")&&this.updateResolvedHref()}updateResolvedHref(){if(!this.name){this.resolvedHref="";return}let e=`#uc-icon-${this.name}`,t=this.iconHrefResolver?.(this.name);this.resolvedHref=t??e}render(){return m.html` ${this.yield("",m.html`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use href=${this.resolvedHref}></use></svg>`)} `}};h([(0,c.property)({type:String})],Gt.prototype,"name",2),h([(0,c.state)()],Gt.prototype,"resolvedHref",2);var In=o=>[...new Set(o)];var nt="--uc-img-",io="unresolved";var ro=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),oo=3e3,so=5e3,no=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var Ic="https://ucarecdn.com",Tt=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Ic},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var ji=class extends mi(fi(m.LitElement)){constructor(){super();this._state={};this._subscribers=new Map;this._isnObserver=null;this._observed=null;for(let e in Tt){let t=Tt[e];this._state[nt+e]=t?.default||""}}createRenderRoot(){return this}$$(e){return this._state[nt+e]}set$$(e){for(let t in e){let r=nt+t,s=e[t];this._state[r]=s,this._notify(r,s)}}sub$$(e,t){let r=nt+e;this._subscribers.has(r)||this._subscribers.set(r,new Set),this._subscribers.get(r).add(t);let s=this._state[r];s!==null&&s!==""&&t(s)}_notify(e,t){this._subscribers.has(e)&&this._subscribers.get(e).forEach(r=>{t===null||t===""||r(t)})}analyticsParams(){return`-/@clib/${He}/${je}/uc-img/`}initAttributes(e){Array.from(this.attributes).forEach(t=>{let r=t;Tt[r.name]||e.setAttribute(r.name,r.value)})}initIntersection(e,t){let r={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(s=>{s.forEach(n=>{n.isIntersecting&&(t(),this._isnObserver.unobserve(e))})},r),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e)}connectedCallback(){super.connectedCallback(),this._initCssProperties()}_initCssProperties(){for(let e in Tt){let t=nt+e,r=this.getCssData(t,!0);r!=null&&(this._state[t]=r)}}disconnectedCallback(){super.disconnectedCallback(),this._isnObserver&&(this._observed?.forEach(e=>{this._isnObserver?.unobserve(e)}),this._isnObserver=null),this._subscribers.clear()}static get observedAttributes(){return Object.keys(Tt)}attributeChangedCallback(e,t,r){window.setTimeout(()=>{let s=nt+e;this._state[s]=r,this._notify(s,r)})}};var kn=o=>Object.entries(o).filter(([i,e])=>e!==void 0&&e!=="").map(([i,e])=>i==="cdn-operations"||i==="analytics"?e:`${i}/${e}`);var Wi=class extends ji{constructor(){super(...arguments);this._img=new Image;this._imgPreview=new Image}_fmtAbs(e){return!e.includes("//")&&!ro&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if(e?.trim()!==""){let t=e,r=t.match(/\d+/)[0],s=t.match(/[a-zA-Z]+/)[0],n=parseInt(r,10);if(Number(n)>so&&this.hasFormatJPG)return so+s;if(Number(n)>oo&&!this.hasFormatJPG)return oo+s}return e}_getCdnModifiers(e,t){let r={format:this._getTypedCssValue("format"),quality:this._getTypedCssValue("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this._getTypedCssValue("cdn-operations")??void 0,analytics:this.analyticsParams()};return Y(...kn(r))}_getTypedCssValue(e){let t=this.$$(e);if(t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t}_getUrlBase(e="",t=""){let r=this.$$("src");if(r.startsWith("data:")||r.startsWith("blob:"))return r;if(ro&&r&&!r.includes("//"))return this._proxyUrl(r);let s=this._getCdnModifiers(e,t),n=this.$$("cdn-cname"),a=n;if(r.startsWith(String(n)))return H(r,s);let l=this.$$("uuid");if(a&&l)return this._proxyUrl(H(Be(a,l),s));if(l)return this._proxyUrl(H(Be(a,l),s));let d=this.$$("proxy-cname");if(d)return this._proxyUrl(H(d,s,this._fmtAbs(r)));let u=this.$$("pubkey");if(u)return this._proxyUrl(H(`https://${u}.ucr.io/`,s,this._fmtAbs(r)))}_proxyUrl(e){let t=this.$$("secure-delivery-proxy");return t?Pt(t,{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}_getElSize(e,t=1,r=!0){let s=e.getBoundingClientRect(),n=t*Math.round(s.width),a=r?"":t*Math.round(s.height);return n||a?`${n||""}x${a||""}`:null}_setupEventProxy(e){let t=s=>{s.stopPropagation();let n=new Event(s.type,s);this.dispatchEvent(n)},r=["load","error"];for(let s of r)e.addEventListener(s,t)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:no.PREVIEW,img:this._imgPreview}:{type:no.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){let e=this.$$("breakpoints");if(e){let t=j(e);return In(t.map(r=>parseInt(r,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let r=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",r),e.style.setProperty("background-image","-webkit-"+r)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(t=>{e.add(`${this._getUrlBase(`${t}x`)} ${this._validateSize(`${t}w`)}`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(`${t*2}x`)} ${this._validateSize(`${t*2}w`)}`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(`${t*3}x`)} ${this._validateSize(`${t*3}w`)}`)}):(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()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){let e=this.bgSelector;[...document.querySelectorAll(e)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this.renderBg(t)}):this.renderBg(t)})}_appendURL({elNode:e,src:t,srcset:r}){t&&(e.src=t),r&&(e.srcset=r)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:t,elNode:r}){return new Promise((s,n)=>{this._setupConfigForImage({elNode:r}),r.setAttribute(io,""),r.addEventListener("load",()=>{r.removeAttribute(io),s(r)}),r.addEventListener("error",()=>{n(!1)}),this._appendURL({elNode:r,src:e,srcset:t})})}async renderImage(){if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var ao=class extends Wi{connectedCallback(){super.connectedCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",i=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=i?"lazy":"eager")})}};var lo=null,co=class extends T{constructor(){super(...arguments);this.dialogEl=(0,b.createRef)();this._handleBackdropClick=()=>{this._closeDialog()};this._closeDialog=()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="")};this._handleDialogClose=()=>{this._closeDialog()};this._handleDialogMouseDown=e=>{this._mouseDownTarget=e.target};this._handleDialogMouseUp=e=>{let t=e.target;t===this.dialogEl.value&&t===this._mouseDownTarget&&this._closeDialog()}}static{this.styleAttrs=[...super.styleAttrs,"uc-modal"]}show(){let e=this.dialogEl.value;typeof e.showModal=="function"?(this.setAttribute("aria-modal","true"),e.showModal()):e.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden")}hide(){let e=this.dialogEl.value;typeof e.close=="function"?(this.setAttribute("aria-modal","false"),e.close()):e.removeAttribute("open")}_handleModalOpen({id:e}){e===this.id?(lo=e,this.show(),this.emit(I.MODAL_OPEN,{modalId:e},{debounce:!0})):this.hide()}_handleModalClose({id:e}){e===this.id&&(this.hide(),this.emit(I.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0}))}_handleModalCloseAll(e){this.hide(),lo===this.id&&this.emit(I.MODAL_CLOSE,{modalId:lo,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0})}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this),this.subConfigValue("modalBackdropStrokes",e=>{e?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.handleModalCloseAll=this._handleModalCloseAll.bind(this),this.modalManager?.subscribe(z.OPEN,this.handleModalOpen),this.modalManager?.subscribe(z.CLOSE,this.handleModalClose),this.modalManager?.subscribe(z.CLOSE_ALL,this.handleModalCloseAll)}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0,this.modalManager?.unsubscribe(z.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(z.CLOSE,this.handleModalClose),this.modalManager?.unsubscribe(z.CLOSE_ALL,this.handleModalCloseAll)}handleDialogRef(e){this.dialogEl={value:e},this.dialogEl.value?.addEventListener("close",this._handleDialogClose),this.dialogEl.value?.addEventListener("mousedown",this._handleDialogMouseDown),this.dialogEl.value?.addEventListener("mouseup",this._handleDialogMouseUp)}render(){return m.html`<dialog ${(0,b.ref)(this.handleDialogRef)}> ${this.yield("")} </dialog>`}};var Wt=class extends T{constructor(){super(...arguments);this.value=0;this.visible=!0;this._progressValue=0;this.fakeProgressLineRef=(0,b.createRef)();this.handleFakeProgressAnimation=()=>{let e=this.fakeProgressLineRef.value;if(e){if(!this.visible){e.classList.add("uc-fake-progress--hidden");return}this._progressValue>0&&e.classList.add("uc-fake-progress--hidden")}}}firstUpdated(e){super.firstUpdated(e),this._progressValue=this.normalizeProgressValue(this.value),this.updateProgressValueStyle(),this.fakeProgressLineRef.value?.addEventListener("animationiteration",this.handleFakeProgressAnimation)}updated(e){if(super.updated(e),e.has("value")){let t=this.normalizeProgressValue(this.value);if(!this.visible)this._progressValue=t;else{let r=Math.max(this._progressValue,t);r!==this._progressValue&&(this._progressValue=r,this.updateProgressValueStyle())}}e.has("visible")&&(this.classList.toggle("uc-progress-bar--hidden",!this.visible),this.visible?this.updateProgressValueStyle():this._progressValue=this.normalizeProgressValue(this.value))}disconnectedCallback(){super.disconnectedCallback(),this.fakeProgressLineRef.value?.removeEventListener("animationiteration",this.handleFakeProgressAnimation)}normalizeProgressValue(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}updateProgressValueStyle(){this.visible&&this.style.setProperty("--l-progress-value",this._progressValue.toString())}render(){return m.html`<div ${(0,b.ref)(this.fakeProgressLineRef)} class="uc-fake-progress"></div><div class="uc-progress"></div>`}};h([(0,c.property)({type:Number})],Wt.prototype,"value",2),h([(0,c.property)({type:Boolean,reflect:!0})],Wt.prototype,"visible",2);var qt=class extends M{constructor(){super();this.visible=!1;this.value=0;this.init$={...this.init$,"*commonProgress":0}}initCallback(){super.initCallback(),this._unobserveCollectionCb=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(t=>this.uploadCollection.read(t)?.getValue("isUploading")??!1);this.visible=e}),this.sub("*commonProgress",e=>{this.value=e})}updated(e){super.updated(e),e.has("visible")&&(this.visible?this.setAttribute("active",""):this.removeAttribute("active"))}disconnectedCallback(){super.disconnectedCallback(),this._unobserveCollectionCb?.(),this._unobserveCollectionCb=void 0}render(){return m.html`<uc-progress-bar .value=${this.value} .visible=${this.visible}></uc-progress-bar>`}};h([(0,c.state)()],qt.prototype,"visible",2),h([(0,c.state)()],qt.prototype,"value",2);var Et=class extends T{constructor(){super(...arguments);this.value="";this.disabled=!1;this.options=[];this._handleChange=e=>{if(this.disabled){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation();let t=e.currentTarget;t&&(this.value=t.value,this.dispatchEvent(new Event("change")))}}render(){return m.html` <select @change=${this._handleChange} .value=${this.value} ?disabled=${this.disabled}> ${this.options.map(e=>m.html`<option value=${e.value}>${e.text}</option>`)} </select>`}};h([(0,c.property)({type:String,attribute:!1})],Et.prototype,"value",2),h([(0,c.property)({type:Boolean,reflect:!0})],Et.prototype,"disabled",2),h([(0,c.property)({type:Array,attribute:!1})],Et.prototype,"options",2);var Xt=class extends M{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.dropzone=!0;this.buttonTextKey="upload-file";this.handleClick=()=>{this.api.initFlow()}}static{this.styleAttrs=[...super.styleAttrs,"uc-simple-btn"]}initCallback(){super.initCallback(),this.subConfigValue("multiple",e=>{this.buttonTextKey=e?"upload-files":"upload-file"})}render(){return m.html`<uc-drop-area .disabled=${!this.dropzone}><button type="button" @click=${this.handleClick}><uc-icon name="upload"></uc-icon><span>${this.l10n(this.buttonTextKey)}</span> ${this.yield("")} <div class="uc-visual-drop-area">${this.l10n("drop-files-here")}</div></button></uc-drop-area>`}};h([(0,c.property)({attribute:"dropzone",type:Boolean})],Xt.prototype,"dropzone",2),h([(0,c.state)()],Xt.prototype,"buttonTextKey",2);var kc="src-type-",xt=class extends M{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this._registeredTypes={};this.iconName="default";this.srcTypeKey=""}initTypes(){this.registerType({type:B.LOCAL,activate:()=>(this.api.openSystemDialog(),!1)}),this.registerType({type:B.URL,activity:_.activities.URL,textKey:"from-url"}),this.registerType({type:B.CAMERA,activity:_.activities.CAMERA,activate:()=>{let e=et.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:!0}),!e}}),this.registerType({type:"draw",activity:_.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(Fr))this.registerType({type:e,activity:_.activities.CAMERA,activate:()=>{let t=et.htmlMediaCapture;return t&&this.api.openSystemDialog({captureCamera:!0,modeCamera:e==="mobile-photo-camera"?S.PHOTO:S.VIDEO}),!t}});for(let e of Object.values(Ee))this.registerType({type:e,activity:_.activities.EXTERNAL,activityParams:{externalSourceType:e}})}initCallback(){super.initCallback(),this.initTypes(),this.type&&this.applyType(this.type)}registerType(e){this._registeredTypes[e.type]=e}getType(e){return this._registeredTypes[e]}activate(){if(!this.type)return;let e=this._registeredTypes[this.type];if(!e)return;let{activity:t,activate:r,activityParams:s={}}=e;(r?r():!!t)&&t&&(this.modalManager?.open(t),this.set$({"*currentActivityParams":s,"*currentActivity":t}))}applyType(e){let t=this._registeredTypes[e];if(!t){console.warn(`Unsupported source type: ${e}`);return}let{textKey:r=e,icon:s=e}=t;this.srcTypeKey=`${kc}${r}`,this.iconName=s}willUpdate(e){super.willUpdate(e),e.has("type")&&(this.type?this.applyType(this.type):(this.srcTypeKey="",this.iconName="default"))}render(){return m.html`<button type="button" @click=${this.activate}><uc-icon name=${this.iconName}></uc-icon><div class="uc-txt">${this.l10n(this.srcTypeKey)}</div></button>`}};h([(0,c.property)({type:String})],xt.prototype,"type",2),h([(0,c.state)()],xt.prototype,"iconName",2),h([(0,c.state)()],xt.prototype,"srcTypeKey",2);var qi=class extends T{constructor(){super(...arguments);this._rawSourceList=[];this._cameraModes=[];this._resolvedSources=[];this.sources=[]}initCallback(){super.initCallback(),this.subConfigValue("sourceList",e=>{this._rawSourceList=j(e),this._updateSources()}),this.subConfigValue("cameraModes",e=>{this._cameraModes=oe(e),this._updateSources()})}updated(e){super.updated(e),this.cfg.sourceListWrap?this.style.removeProperty("display"):this.style.display="contents"}_updateSources(){let e=[];for(let t of this._rawSourceList){if(t==="instagram"){console.error("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");continue}if(t==="camera"&&et.htmlMediaCapture){let r=this._cameraModes.length?this._cameraModes.map(s=>`mobile-${s}-camera`):["mobile-photo-camera"];e.push(...r);continue}e.push(t)}this.sources=e}render(){return m.html`${this.sources.map(e=>m.html`<uc-source-btn role="listitem" type=${e}></uc-source-btn>`)}`}};h([(0,c.state)()],qi.prototype,"sources",2);var uo=class extends T{render(){return m.html`<div class="uc-spinner"></div>`}};var po=class extends _{constructor(){super(...arguments);this.historyTracked=!0;this.activityType=_.activities.START_FROM}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"")}render(){return m.html`<div class="uc-content">${this.yield("")}</div>`}};function ho(o,i=40){if(o.type==="image/svg+xml")return URL.createObjectURL(o);let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return Promise.reject(new Error("Canvas context not supported"));let r=new Image,s=new Promise((n,a)=>{r.onload=()=>{let l=r.height/r.width;l>1?(e.width=i,e.height=i*l):(e.height=i,e.width=i/l),t.fillStyle="rgb(240, 240, 240)",t.fillRect(0,0,e.width,e.height),t.drawImage(r,0,0,e.width,e.height),e.toBlob(d=>{if(!d){a();return}let u=URL.createObjectURL(d);n(u)})},r.onerror=l=>{a(l)}});return r.src=URL.createObjectURL(o),s}function Oc(o){let i=new Blob([o],{type:"image/svg+xml"});return URL.createObjectURL(i)}function Xi(o="hsl(209, 21%, 65%)",i=32,e=32){return Oc(`<svg width="${i}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${o}" 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"/></svg>`)}var Mc=3e3,St=class extends Ct{constructor(){super(...arguments);this.badgeIcon="";this.uid="";this.thumbUrl="";this.renderedGridOnce=!1;this.thumbRect=null;this.isIntersecting=!1;this.firstViewMode=this.cfg.filesViewMode;this.generateThumbnail=this._withEntry(async(e,t=!1)=>{let r=e.getValue("fileInfo"),s=e.getValue("isImage"),n=e.getValue("uuid"),a=e.getValue("thumbUrl"),l=this.calculateThumbSize(t);if(r&&s&&n){let u=await this.proxyUrl(H(Be(this.cfg.cdnCname,n),Y(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${l}x${l}/center`)));if(a===u)return;let{promise:p}=ot(u);p.then(()=>{e.setValue("thumbUrl",u),a?.startsWith("blob:")&&URL.revokeObjectURL(a)}).catch(async()=>{if(!a?.startsWith("blob:"))try{let f=e.getValue("file");if(!f)return;let g=await ho(f,l);e.setValue("thumbUrl",g)}catch(f){this.telemetryManager.sendEventError(f,"thumbnail generation. Failed to generate thumb from file");let g=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xi(g))}});return}if(e.getValue("thumbUrl"))return;let d=e.getValue("file");if(d?.type.includes("image"))try{let u=await ho(d,l);e.setValue("thumbUrl",u)}catch(u){this.telemetryManager.sendEventError(u,"thumbnail generation. Failed to generate thumb from file");let p=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xi(p))}else{let u=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xi(u))}});this.debouncedGenerateThumb=L(this.generateThumbnail.bind(this),100)}calculateThumbSize(e=!1){e&&(this.thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(this?.thumbRect?.height||0),10),parseInt(String(this?.thumbRect?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,Mc)}decodeImage(e,t){return new Promise((r,s)=>{let n=new Image;n.decoding="async";let a=()=>{n.src="",t?.removeEventListener("abort",l)},l=()=>{a(),s(new DOMException("Aborted","AbortError"))};if(t){if(t.aborted){l();return}t.addEventListener("abort",l,{once:!0})}let d=()=>{a(),r()},u=p=>{a(),s(p)};if(typeof n.decode=="function"){n.src=e,n.decode().then(d).catch(u);return}n.onload=d,n.onerror=u,n.src=e})}cancelPendingThumbUpdate(){this.pendingThumbUpdate?.cancel(),this.pendingThumbUpdate=void 0}scheduleThumbUpdate(e){if(this.cancelPendingThumbUpdate(),!e){this.thumbUrl&&(this.thumbUrl="");return}if(e===this.thumbUrl)return;let t=new AbortController,r={controller:t,cancel:()=>{t.abort(),r.rafId!==void 0&&window.cancelAnimationFrame(r.rafId)}};this.pendingThumbUpdate=r,this.decodeImage(e,t.signal).catch(()=>{}).then(()=>{t.signal.aborted||(r.rafId=window.requestAnimationFrame(()=>{t.signal.aborted||(this.thumbUrl=e)}))})}requestThumbGeneration(e=!1){if(this._entry){if(e){this.generateThumbnail(!0);return}this.isIntersecting&&this.debouncedGenerateThumb()}}firstUpdated(e){super.firstUpdated(e),this.bindToEntry()}updated(e){super.updated(e),e.has("uid")&&this.bindToEntry()}_observerCallback(e){let[t]=e;t&&(this.isIntersecting=t.isIntersecting,t.isIntersecting&&(this.thumbRect=t.boundingClientRect,this.requestThumbGeneration(),this.observer?.disconnect()),t.intersectionRatio===0&&this.debouncedGenerateThumb.cancel())}_reset(){super._reset(),this.debouncedGenerateThumb.cancel(),this.cancelPendingThumbUpdate(),this.thumbUrl&&(this.thumbUrl="")}bindToEntry(){let e=this.uid?.trim();if(!e){this._entry&&this._reset();return}let t=this.uploadCollection?.read(e);if(!t||t===this._entry)return;this._reset(),this._entry=t;let r=()=>{this.requestThumbGeneration()};this._subEntry("fileInfo",s=>{s?.isImage&&r()}),this._subEntry("thumbUrl",s=>{this.scheduleThumbUpdate(s??void 0)}),this._subEntry("cdnUrlModifiers",r),this.requestThumbGeneration(!0)}initCallback(){super.initCallback(),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this.renderedGridOnce&&(this.firstViewMode==="list"&&this.requestThumbGeneration(!0),this.renderedGridOnce=!0)}),this.setAttribute("role","img")}connectedCallback(){super.connectedCallback(),this.observer?.disconnect(),this.observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this.observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.debouncedGenerateThumb.cancel(),this.cancelPendingThumbUpdate(),this.observer?.disconnect()}render(){return m.html`<div class="uc-thumb"><img class="uc-thumb__img" src=${this.thumbUrl||""} alt="" ?hidden=${!this.thumbUrl} draggable="false" /><div class="uc-badge"><uc-icon name=${this.badgeIcon}></uc-icon></div></div>`}};h([(0,c.property)({type:String})],St.prototype,"badgeIcon",2),h([(0,c.property)({type:String})],St.prototype,"uid",2),h([(0,c.state)()],St.prototype,"thumbUrl",2);var mo=class extends M{static{this.styleAttrs=["uc-wgt-common"]}static{this.EventType=I}initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}disconnectedCallback(){super.disconnectedCallback(),this.$["*eventEmitter"].unbindTarget(this)}};var At={};v(At,q_);import*as q_ from"lit-html/directives/repeat.js";var we=class extends M{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.historyTracked=!0;this.activityType=_.activities.UPLOAD_LIST;this.doneBtnVisible=!1;this.doneBtnEnabled=!1;this.uploadBtnVisible=!1;this.addMoreBtnVisible=!1;this.addMoreBtnEnabled=!1;this.commonErrorMessage=null;this.hasFiles=!1;this._latestSummary=null;this._handleAdd=()=>{this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(!0)};this._handleUpload=()=>{this.emit(I.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()};this._handleDone=()=>{this.emit(I.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()};this._handleCancel=()=>{this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll()};this._throttledHandleCollectionUpdate=_t(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll())},300)}get headerText(){return this._latestSummary?this._getHeaderText(this._latestSummary):""}_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount,validatingBeforeUploading:e.idleEntries.filter(g=>g.isValidationPending).length},r=!e.errors.some(g=>g.type==="TOO_MANY_FILES"||g.type==="TOO_FEW_FILES"),s=e.errors.some(g=>g.type==="TOO_MANY_FILES"),n=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),a=e.allEntries.some(g=>g.isValidationPending),l=t.failed===0&&e.errors.length===0&&!a,d=!1,u=!1,p=!1;if(t.total-t.succeed-t.uploading-t.failed>0&&r&&l)d=!0;else{u=!0;let g=this.cfg.groupOutput?!!e.group:!0;p=t.total===t.succeed&&r&&l&&g}this.doneBtnVisible=u,this.doneBtnEnabled=p,this.uploadBtnVisible=d,this.addMoreBtnEnabled=t.total===0||!s&&!n,this.addMoreBtnVisible=!n||this.cfg.multiple,this.hasFiles=t.total>0,this._latestSummary=t}_getHeaderText(e){let t=r=>{let s=e[r];return r==="uploading"&&(s+=e.validatingBeforeUploading),this.l10n(`header-${r}`,{count:s})};return e.uploading>0||e.validatingBeforeUploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){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=>{e&&this._throttledHandleCollectionUpdate()}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e)}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity)}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this.sub("*collectionErrors",e=>{let t=e.filter(r=>r.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this.commonErrorMessage=null;return}this.commonErrorMessage=t.message})}disconnectedCallback(){super.disconnectedCallback(),this.has("*uploadCollection")&&(this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.unobserveCollection(this._throttledHandleCollectionUpdate))}render(){return m.html`<uc-activity-header><span aria-live="polite" class="uc-header-text">${this.headerText}</span><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" ?hidden=${this.hasFiles}> ${this.yield("empty",m.html`<span>${this.l10n("no-files")}</span>`)} </div><div class="uc-files"><div class="uc-files-wrapper"> ${(0,At.repeat)(this.$["*uploadList"]??[],({uid:e})=>e,({uid:e})=>m.html`<uc-file-item .uid=${e}></uc-file-item>`)} </div><button type="button" class="uc-add-more-btn uc-secondary-btn" @click=${this._handleAdd} ?disabled=${!this.addMoreBtnEnabled} ?hidden=${!this.addMoreBtnVisible} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button></div><div class="uc-common-error" ?hidden=${!this.commonErrorMessage} > ${this.commonErrorMessage??""} </div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("clear")}</button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" ?hidden=${!this.addMoreBtnVisible} ?disabled=${!this.addMoreBtnEnabled} @click=${this._handleAdd} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button><button type="button" class="uc-upload-btn uc-primary-btn" ?hidden=${!this.uploadBtnVisible} @click=${this._handleUpload} >${this.l10n("upload")}</button><button type="button" class="uc-done-btn uc-primary-btn" ?hidden=${!this.doneBtnVisible} ?disabled=${!this.doneBtnEnabled} @click=${this._handleDone} > ${this.l10n("done")} </button></div><uc-drop-area ghost></uc-drop-area>`}};h([(0,c.state)()],we.prototype,"doneBtnVisible",2),h([(0,c.state)()],we.prototype,"doneBtnEnabled",2),h([(0,c.state)()],we.prototype,"uploadBtnVisible",2),h([(0,c.state)()],we.prototype,"addMoreBtnVisible",2),h([(0,c.state)()],we.prototype,"addMoreBtnEnabled",2),h([(0,c.state)()],we.prototype,"commonErrorMessage",2),h([(0,c.state)()],we.prototype,"hasFiles",2),h([(0,c.state)()],we.prototype,"_latestSummary",2);var Zi=class extends M{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.URL;this.formState={importDisabled:!0};this.inputRef=(0,b.createRef)();this.handleInput=e=>{let t=e.target?.value??"";this.formState={importDisabled:!t}};this.handleUpload=e=>{e.preventDefault(),this.telemetryManager.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let r=this.inputRef.value?.value?.trim();r&&(this.api.addFileFromUrl(r,{source:B.URL}),this.modalManager?.open(_.activities.UPLOAD_LIST),this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"",{onActivate:()=>{let e=this.inputRef.value;e&&(e.value="",e.focus()),this.formState={importDisabled:!0}}})}render(){return m.html`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.historyBack} title=${this.l10n("back")} aria-label=${this.l10n("back")}><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span>${this.l10n("caption-from-url")}</span></div><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content" @submit=${this.handleUpload}><label><input ${(0,b.ref)(this.inputRef)} placeholder="https://" class="uc-url-input" type="text" @input=${this.handleInput} /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" ?disabled=${this.formState.importDisabled} >${this.l10n("upload-url")}</button></form>`}};h([(0,c.state)()],Zi.prototype,"formState",2);var On="<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.715-.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'/></symbol><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></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-mobile-photo-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 24 24' id='uc-icon-mobile-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 24 24' id='uc-icon-ngdrive' 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-onedrive' 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>";var It={};v(It,yw);import*as yw from"lit-html/directives/unsafe-html.js";var Ue=class extends T{constructor(){super(...arguments);this.init$=Vo(this)}static{this.styleAttrs=["uc-wgt-common"]}initCallback(){super.initCallback(),this.a11y?.registerBlock(this)}render(){return m.html`${(0,It.unsafeHTML)(On)}`}};var fo=class extends F{static{this.styleAttrs=[...super.styleAttrs,"uc-wgt-common"]}constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:P.INIT_SOLUTION}),this.a11y?.registerBlock(this)}};var Qi=class extends Ue{constructor(){super();this.couldCancel=!1;this._handleCancel=()=>{if(this.couldHistoryBack){let e=this.$["*historyBack"];e?.();return}this.couldShowList&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)};this.init$={...this.init$,"*solution":this.tagName}}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"]}get couldHistoryBack(){let e=this.$["*history"];return!e||e.length<=1?!1:e[e.length-1]!==_.activities.START_FROM}get couldShowList(){let e=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(e)&&e.length>0}_getInitActivity(){return this.getCssData("--cfg-init-activity")||_.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:P.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0&&this.$["*currentActivity"]===e&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.couldCancel=this.couldHistoryBack||this.couldShowList})}render(){return m.html`${super.render()} <uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel} ?hidden=${!this.couldCancel} > ${this.l10n("start-from-cancel")} </button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`}};h([(0,c.state)()],Qi.prototype,"couldCancel",2);var go="active",Yi="",at=class extends Ue{constructor(){super();this.singleUpload=!1;this.isHiddenStartFrom=!1;this.classUploadList=Yi;this.classStartFrom=Yi;this.init$={...this.init$,"*solution":this.tagName}}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"]}_getInitActivity(){return this.getCssData("--cfg-init-activity")||_.activities.START_FROM}_handleModalOpen(e){e.id===_.activities.CLOUD_IMG_EDIT&&(this.classUploadList=go),this.$["*currentActivity"]===_.activities.UPLOAD_LIST&&(this.classUploadList=go,this.isHiddenStartFrom=!0);let t=this.$["*uploadList"];(!t||t.length<=0)&&(this.classStartFrom=go)}_handleModalClose(e){e.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.isHiddenStartFrom=!1),e.id===_.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:P.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t===_.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),t||(this.$["*currentActivity"]=e)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0?(this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.classStartFrom=Yi):(this.classUploadList=Yi,this.isHiddenStartFrom=!1,this.$["*currentActivity"]=e)}),this.subConfigValue("confirmUpload",t=>{t!==!1&&(this.cfg.confirmUpload=!1)}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t),this.subConfigValue("multiple",r=>{t==="grid"?(r?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.singleUpload=!r):(this.style.removeProperty("--uc-grid-col"),this.singleUpload=!1)})}),this.handleModalOpen=t=>{this._handleModalOpen(t)},this.handleModalClose=t=>{this._handleModalClose(t)},this.modalManager?.subscribe(z.OPEN,this.handleModalOpen),this.modalManager?.subscribe(z.CLOSE,this.handleModalClose)}disconnectedCallback(){super.disconnectedCallback(),this.modalManager?.unsubscribe(z.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(z.CLOSE,this.handleModalClose)}render(){return m.html`${super.render()} <uc-start-from ?hidden=${this.isHiddenStartFrom} class=${this.classStartFrom}><uc-drop-area ?single=${this.singleUpload} initflow clickable tabindex="0" >${this.l10n("choose-file")}</uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list class=${this.classUploadList}></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]} >${this.l10n("start-from-cancel")}</button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};h([(0,c.state)()],at.prototype,"singleUpload",2),h([(0,c.state)()],at.prototype,"isHiddenStartFrom",2),h([(0,c.state)()],at.prototype,"classUploadList",2),h([(0,c.state)()],at.prototype,"classStartFrom",2);var Ji=class extends Ue{constructor(){super();this.headless=!1;this.init$={...this.init$,"*solution":this.tagName}}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"]}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:P.INIT_SOLUTION})}render(){return m.html`${super.render()} <uc-simple-btn ?hidden=${this.headless}></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]}>${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};h([(0,c.property)({type:Boolean})],Ji.prototype,"headless",2);export{_ as ActivityBlock,kr as ActivityHeader,T as Block,be as BtnUi,D as CameraSource,fo as CloudImageEditor,Di as CloudImageEditorActivity,F as CloudImageEditorBlock,Ni as Config,Xr as Copyright,Ii as CropFrame,U as Data,_e as DropArea,Mi as EditorAspectRatioButtonControl,Li as EditorCropButtonControl,Xe as EditorFilterControl,Br as EditorFreeformButtonControl,Pi as EditorImageCropper,Hr as EditorImageFader,Ui as EditorOperationControl,jr as EditorScroller,Ri as EditorSlider,de as EditorToolbar,me as ExternalSource,Ee as ExternalUploadSource,eo as FileItem,Qi as FileUploaderInline,at as FileUploaderMinimal,Ji as FileUploaderRegular,to as FormInput,Gt as Icon,ao as Img,$i as LineLoaderUi,co as Modal,z as ModalEvents,He as PACKAGE_NAME,je as PACKAGE_VERSION,zt as PresenceToggle,Wt as ProgressBar,qt as ProgressBarCommon,U as PubSub,Et as Select,Xt as SimpleBtn,Pe as SliderUi,Ue as SolutionBlock,xt as SourceBtn,qi as SourceList,uo as Spinner,po as StartFrom,St as Thumb,ge as UID,mo as UploadCtxProvider,we as UploadList,B as UploadSource,M as UploaderBlock,Zi as UrlSource,tr as defineComponents,To as defineLocale,Fn as loadFileUploaderFrom,Ht as toKebabCase}; /*! Bundled license information: @lit/context/lib/context-request-event.js: @lit/context/lib/create-context.js: @lit/context/lib/controllers/context-consumer.js: @lit/context/lib/value-notifier.js: @lit/context/lib/controllers/context-provider.js: @lit/context/lib/context-root.js: (** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) @lit/context/lib/decorators/provide.js: (** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) @lit/context/lib/decorators/consume.js: (** * @license * Copyright 2022 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) */
7
+ var Qa=Object.defineProperty;var Ya=Object.getOwnPropertyDescriptor;var p=(o,i,t,e)=>{for(var r=e>1?void 0:e?Ya(i,t):i,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(e?n(i,t,r):n(r))||r);return e&&r&&Qa(i,t,r),r};var bt=[],zt=0,bi=4,gs=o=>{let i=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(e){return t.lc=i.push(e),()=>{for(let s=zt+bi;s<bt.length;)bt[s]===e?bt.splice(s,bi):s+=bi;let r=i.indexOf(e);~r&&(i.splice(r,1),--t.lc||t.off());}},notify(e,r){let s=!bt.length;for(let n of i)bt.push(n,t.value,e,r);if(s){for(zt=0;zt<bt.length;zt+=bi)bt[zt](bt[zt+1],bt[zt+2],bt[zt+3]);bt.length=0;}},off(){},set(e){let r=t.value;r!==e&&(t.value=e,t.notify(r));},subscribe(e){let r=t.listen(e);return e(t.value),r},value:o};return t};function zr(o,i,t){let e=new Set(i).add(void 0);return o.listen((r,s,n)=>{e.has(n)&&t(r,s,n);})}var Br=(o={})=>{let i=gs(o);return i.setKey=function(t,e){let r=i.value;typeof e>"u"&&t in i.value?(i.value={...i.value},delete i.value[t],i.notify(r,t)):i.value[t]!==e&&(i.value={...i.value,[t]:e},i.notify(r,t));},i};var N=class o{static{this.Me=new Map;}constructor(i,t){this.Z=t;}pub(i,t){i in this.Z.get()||console.warn(`PubSub#pub: Key "${String(i)}" not found`),this.Z.setKey(i,t);}sub(i,t,e=true){return i in this.Z.get()||console.warn(`PubSub#sub: Key "${String(i)}" not found`),e&&t(this.Z.get()[i]),{remove:zr(this.Z,[i],s=>{t(s[i]);})}}read(i){return i in this.Z.get()||console.warn(`PubSub#read: Key "${String(i)}" not found`),this.Z.get()[i]}add(i,t,e=false){(!(i in this.Z.get())||e)&&this.Z.setKey(i,t);}has(i){return i in this.Z.get()}get store(){return this.Z.get()}static registerCtx(i,t){if(o.Me.has(t))throw new Error(`PubSub: Context with id "${t}" already exists`);let e=Br(i);return o.Me.set(t,e),new o(t,e)}static deleteCtx(i){o.Me.delete(i);}static getCtx(i){let t=o.Me.get(i);return t?new o(i,t):null}static hasCtx(i){return o.Me.has(i)}};var wi=globalThis,Ei=wi.ShadowRoot&&(wi.ShadyCSS===void 0||wi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,bs=Symbol(),ys=new WeakMap,xi=class{constructor(i,t,e){if(this.Pl=true,e!==bs)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=i,this.t=t;}get styleSheet(){let i=this.o,t=this.t;if(Ei&&i===void 0){let e=t!==void 0&&t.length===1;e&&(i=ys.get(t)),i===void 0&&((this.o=i=new CSSStyleSheet).replaceSync(this.cssText),e&&ys.set(t,i));}return i}toString(){return this.cssText}},ws=o=>new xi(typeof o=="string"?o:o+"",void 0,bs);var xs=(o,i)=>{if(Ei)o.adoptedStyleSheets=i.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(let t of i){let e=document.createElement("style"),r=wi.litNonce;r!==void 0&&e.setAttribute("nonce",r),e.textContent=t.cssText,o.appendChild(e);}},Hr=Ei?o=>o:o=>o instanceof CSSStyleSheet?(i=>{let t="";for(let e of i.cssRules)t+=e.cssText;return ws(t)})(o):o;var{is:tl,defineProperty:el,getOwnPropertyDescriptor:il,getOwnPropertyNames:rl,getOwnPropertySymbols:ol,getPrototypeOf:sl}=Object,Ti=globalThis,Es=Ti.trustedTypes,nl=Es?Es.emptyScript:"",al=Ti.reactiveElementPolyfillSupport,Ke=(o,i)=>o,Ge={toAttribute(o,i){switch(i){case Boolean:o=o?nl:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o);}return o},fromAttribute(o,i){let t=o;switch(i){case Boolean:t=o!==null;break;case Number:t=o===null?null:Number(o);break;case Object:case Array:try{t=JSON.parse(o);}catch{t=null;}}return t}},Ci=(o,i)=>!tl(o,i),Ts={attribute:true,type:String,converter:Ge,reflect:false,useDefault:false,hasChanged:Ci};Symbol.metadata??=Symbol("metadata"),Ti.litPropertyMetadata??=new WeakMap;var Lt=class extends HTMLElement{static addInitializer(i){this.cr(),(this.l??=[]).push(i);}static get observedAttributes(){return this.finalize(),this.ni&&[...this.ni.keys()]}static createProperty(i,t=Ts){if(t.state&&(t.attribute=false),this.cr(),this.prototype.hasOwnProperty(i)&&((t=Object.create(t)).wrapped=true),this.elementProperties.set(i,t),!t.noAccessor){let e=Symbol(),r=this.getPropertyDescriptor(i,e,t);r!==void 0&&el(this.prototype,i,r);}}static getPropertyDescriptor(i,t,e){let{get:r,set:s}=il(this.prototype,i)??{get(){return this[t]},set(n){this[t]=n;}};return {get:r,set(n){let a=r?.call(this);s?.call(this,n),this.requestUpdate(i,a,e);},configurable:true,enumerable:true}}static getPropertyOptions(i){return this.elementProperties.get(i)??Ts}static cr(){if(this.hasOwnProperty(Ke("elementProperties")))return;let i=sl(this);i.finalize(),i.l!==void 0&&(this.l=[...i.l]),this.elementProperties=new Map(i.elementProperties);}static finalize(){if(this.hasOwnProperty(Ke("finalized")))return;if(this.finalized=true,this.cr(),this.hasOwnProperty(Ke("properties"))){let t=this.properties,e=[...rl(t),...ol(t)];for(let r of e)this.createProperty(r,t[r]);}let i=this[Symbol.metadata];if(i!==null){let t=litPropertyMetadata.get(i);if(t!==void 0)for(let[e,r]of t)this.elementProperties.set(e,r);}this.ni=new Map;for(let[t,e]of this.elementProperties){let r=this.ur(t,e);r!==void 0&&this.ni.set(r,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(i){let t=[];if(Array.isArray(i)){let e=new Set(i.flat(1/0).reverse());for(let r of e)t.unshift(Hr(r));}else i!==void 0&&t.push(Hr(i));return t}static ur(i,t){let e=t.attribute;return e===false?void 0:typeof e=="string"?e:typeof i=="string"?i.toLowerCase():void 0}constructor(){super(),this.ai=void 0,this.isUpdatePending=false,this.hasUpdated=false,this.se=null,this.$l();}$l(){this.dr=new Promise((i=>this.enableUpdating=i)),this.Nt=new Map,this.Dl(),this.requestUpdate(),this.constructor.l?.forEach((i=>i(this)));}addController(i){(this.Le??=new Set).add(i),this.renderRoot!==void 0&&this.isConnected&&i.hostConnected?.();}removeController(i){this.Le?.delete(i);}Dl(){let i=new Map,t=this.constructor.elementProperties;for(let e of t.keys())this.hasOwnProperty(e)&&(i.set(e,this[e]),delete this[e]);i.size>0&&(this.ai=i);}createRenderRoot(){let i=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return xs(i,this.constructor.elementStyles),i}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this.Le?.forEach((i=>i.hostConnected?.()));}enableUpdating(i){}disconnectedCallback(){this.Le?.forEach((i=>i.hostDisconnected?.()));}attributeChangedCallback(i,t,e){this.pr(i,e);}Vl(i,t){let e=this.constructor.elementProperties.get(i),r=this.constructor.ur(i,e);if(r!==void 0&&e.reflect===true){let s=(e.converter?.toAttribute!==void 0?e.converter:Ge).toAttribute(t,e.type);this.se=i,s==null?this.removeAttribute(r):this.setAttribute(r,s),this.se=null;}}pr(i,t){let e=this.constructor,r=e.ni.get(i);if(r!==void 0&&this.se!==r){let s=e.getPropertyOptions(r),n=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Ge;this.se=r;let a=n.fromAttribute(t,s.type);this[r]=a??this.hr?.get(r)??a,this.se=null;}}requestUpdate(i,t,e){if(i!==void 0){let r=this.constructor,s=this[i];if(e??=r.getPropertyOptions(i),!((e.hasChanged??Ci)(s,t)||e.useDefault&&e.reflect&&s===this.hr?.get(i)&&!this.hasAttribute(r.ur(i,e))))return;this.C(i,t,e);}this.isUpdatePending===false&&(this.dr=this.Fl());}C(i,t,{useDefault:e,reflect:r,wrapped:s},n){e&&!(this.hr??=new Map).has(i)&&(this.hr.set(i,n??t??this[i]),s!==true||n!==void 0)||(this.Nt.has(i)||(this.hasUpdated||e||(t=void 0),this.Nt.set(i,t)),r===true&&this.se!==i&&(this.us??=new Set).add(i));}async Fl(){this.isUpdatePending=true;try{await this.dr;}catch(t){Promise.reject(t);}let i=this.scheduleUpdate();return i!=null&&await i,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this.ai){for(let[r,s]of this.ai)this[r]=s;this.ai=void 0;}let e=this.constructor.elementProperties;if(e.size>0)for(let[r,s]of e){let{wrapped:n}=s,a=this[r];n!==true||this.Nt.has(r)||a===void 0||this.C(r,void 0,s,a);}}let i=false,t=this.Nt;try{i=this.shouldUpdate(t),i?(this.willUpdate(t),this.Le?.forEach((e=>e.hostUpdate?.())),this.update(t)):this.fr();}catch(e){throw i=false,this.fr(),e}i&&this._l(t);}willUpdate(i){}_l(i){this.Le?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(i)),this.updated(i);}fr(){this.Nt=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.dr}shouldUpdate(i){return true}update(i){this.us&&=this.us.forEach((t=>this.Vl(t,this[t]))),this.fr();}updated(i){}firstUpdated(i){}};Lt.elementStyles=[],Lt.shadowRootOptions={mode:"open"},Lt[Ke("elementProperties")]=new Map,Lt[Ke("finalized")]=new Map,al?.({ReactiveElement:Lt}),(Ti.reactiveElementVersions??=[]).push("2.1.1");var Kr=globalThis,Ai=Kr.trustedTypes,Cs=Ai?Ai.createPolicy("lit-html",{createHTML:o=>o}):void 0,Gr="$lit$",Ut=`lit$${Math.random().toFixed(9).slice(2)}$`,qr="?"+Ut,ll=`<${qr}>`,le=document,We=()=>le.createComment(""),Ze=o=>o===null||typeof o!="object"&&typeof o!="function",Wr=Array.isArray,Ms=o=>Wr(o)||typeof o?.[Symbol.iterator]=="function",jr=`[ \f\r]`,qe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,As=/-->/g,Ss=/>/g,ne=RegExp(`>|${jr}(?:([^\\s"'>=/]+)(${jr}*=${jr}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),ks=/'/g,Os=/"/g,Ls=/^(?:script|style|textarea|title)$/i,Zr=o=>(i,...t)=>({zt:o,strings:i,values:t}),g=Zr(1),Q=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),Is=new WeakMap,ae=le.createTreeWalker(le,129);function Us(o,i){if(!Wr(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Cs!==void 0?Cs.createHTML(i):i}var Rs=(o,i)=>{let t=o.length-1,e=[],r,s=i===2?"<svg>":i===3?"<math>":"",n=qe;for(let a=0;a<t;a++){let l=o[a],c,d,u=-1,h=0;for(;h<l.length&&(n.lastIndex=h,d=n.exec(l),d!==null);)h=n.lastIndex,n===qe?d[1]==="!--"?n=As:d[1]!==void 0?n=Ss:d[2]!==void 0?(Ls.test(d[2])&&(r=RegExp("</"+d[2],"g")),n=ne):d[3]!==void 0&&(n=ne):n===ne?d[0]===">"?(n=r??qe,u=-1):d[1]===void 0?u=-2:(u=n.lastIndex-d[2].length,c=d[1],n=d[3]===void 0?ne:d[3]==='"'?Os:ks):n===Os||n===ks?n=ne:n===As||n===Ss?n=qe:(n=ne,r=void 0);let f=n===ne&&o[a+1].startsWith("/>")?" ":"";s+=n===qe?l+ll:u>=0?(e.push(c),l.slice(0,u)+Gr+l.slice(u)+Ut+f):l+Ut+(u===-2?a:f);}return [Us(o,s+(o[t]||"<?>")+(i===2?"</svg>":i===3?"</math>":"")),e]},Xe=class o{constructor({strings:i,zt:t},e){let r;this.parts=[];let s=0,n=0,a=i.length-1,l=this.parts,[c,d]=Rs(i,t);if(this.el=o.createElement(c,e),ae.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes);}for(;(r=ae.nextNode())!==null&&l.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let u of r.getAttributeNames())if(u.endsWith(Gr)){let h=d[n++],f=r.getAttribute(u).split(Ut),m=/([.?@])?(.*)/.exec(h);l.push({type:1,index:s,name:m[2],strings:f,ctor:m[1]==="."?ki:m[1]==="?"?Oi:m[1]==="@"?Ii:ue}),r.removeAttribute(u);}else u.startsWith(Ut)&&(l.push({type:6,index:s}),r.removeAttribute(u));if(Ls.test(r.tagName)){let u=r.textContent.split(Ut),h=u.length-1;if(h>0){r.textContent=Ai?Ai.emptyScript:"";for(let f=0;f<h;f++)r.append(u[f],We()),ae.nextNode(),l.push({type:2,index:++s});r.append(u[h],We());}}}else if(r.nodeType===8)if(r.data===qr)l.push({type:2,index:s});else {let u=-1;for(;(u=r.data.indexOf(Ut,u+1))!==-1;)l.push({type:7,index:s}),u+=Ut.length-1;}s++;}}static createElement(i,t){let e=le.createElement("template");return e.innerHTML=i,e}};function ce(o,i,t=o,e){if(i===Q)return i;let r=e!==void 0?t.Nl?.[e]:t.zl,s=Ze(i)?void 0:i.mr;return r?.constructor!==s&&(r?.ds?.(false),s===void 0?r=void 0:(r=new s(o),r.vr(o,t,e)),e!==void 0?(t.Nl??=[])[e]=r:t.zl=r),r!==void 0&&(i=ce(o,r.Bl(o,i.values),r,e)),i}var Si=class{constructor(i,t){this.ps=[],this.mt=void 0,this.hs=i,this.c=t;}get parentNode(){return this.c.parentNode}get X(){return this.c.X}u(i){let{el:{content:t},parts:e}=this.hs,r=(i?.creationScope??le).importNode(t,true);ae.currentNode=r;let s=ae.nextNode(),n=0,a=0,l=e[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new Te(s,s.nextSibling,this,i):l.type===1?c=new l.ctor(s,l.name,l.strings,this,i):l.type===6&&(c=new Mi(s,this,i)),this.ps.push(c),l=e[++a];}n!==l?.index&&(s=ae.nextNode(),n++);}return ae.currentNode=le,r}p(i){let t=0;for(let e of this.ps)e!==void 0&&(e.strings!==void 0?(e.vt(i,e,t),t+=e.strings.length-2):e.vt(i[t])),t++;}},Te=class o{get X(){return this.c?.X??this.fs}constructor(i,t,e,r){this.type=2,this.r=U,this.mt=void 0,this.Tt=i,this.ne=t,this.c=e,this.options=r,this.fs=r?.isConnected??true;}get parentNode(){let i=this.Tt.parentNode,t=this.c;return t!==void 0&&i?.nodeType===11&&(i=t.parentNode),i}get startNode(){return this.Tt}get endNode(){return this.ne}vt(i,t=this){i=ce(this,i,t),Ze(i)?i===U||i==null||i===""?(this.r!==U&&this.ae(),this.r=U):i!==this.r&&i!==Q&&this.ms(i):i.zt!==void 0?this.$(i):i.nodeType!==void 0?this.T(i):Ms(i)?this.k(i):this.ms(i);}O(i){return this.Tt.parentNode.insertBefore(i,this.ne)}T(i){this.r!==i&&(this.ae(),this.r=this.O(i));}ms(i){this.r!==U&&Ze(this.r)?this.Tt.nextSibling.data=i:this.T(le.createTextNode(i)),this.r=i;}$(i){let{values:t,zt:e}=i,r=typeof e=="number"?this.Hl(i):(e.el===void 0&&(e.el=Xe.createElement(Us(e.h,e.h[0]),this.options)),e);if(this.r?.hs===r)this.r.p(t);else {let s=new Si(r,this),n=s.u(this.options);s.p(t),this.T(n),this.r=s;}}Hl(i){let t=Is.get(i.strings);return t===void 0&&Is.set(i.strings,t=new Xe(i)),t}k(i){Wr(this.r)||(this.r=[],this.ae());let t=this.r,e,r=0;for(let s of i)r===t.length?t.push(e=new o(this.O(We()),this.O(We()),this,this.options)):e=t[r],e.vt(s),r++;r<t.length&&(this.ae(e&&e.ne.nextSibling,r),t.length=r);}ae(i=this.Tt.nextSibling,t){for(this.li?.(false,true,t);i!==this.ne;){let e=i.nextSibling;i.remove(),i=e;}}setConnected(i){this.c===void 0&&(this.fs=i,this.li?.(i));}},ue=class{get tagName(){return this.element.tagName}get X(){return this.c.X}constructor(i,t,e,r,s){this.type=1,this.r=U,this.mt=void 0,this.element=i,this.name=t,this.c=r,this.options=s,e.length>2||e[0]!==""||e[1]!==""?(this.r=Array(e.length-1).fill(new String),this.strings=e):this.r=U;}vt(i,t=this,e,r){let s=this.strings,n=false;if(s===void 0)i=ce(this,i,t,0),n=!Ze(i)||i!==this.r&&i!==Q,n&&(this.r=i);else {let a=i,l,c;for(i=s[0],l=0;l<s.length-1;l++)c=ce(this,a[e+l],t,l),c===Q&&(c=this.r[l]),n||=!Ze(c)||c!==this.r[l],c===U?i=U:i!==U&&(i+=(c??"")+s[l+1]),this.r[l]=c;}n&&!r&&this.j(i);}j(i){i===U?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,i??"");}},ki=class extends ue{constructor(){super(...arguments),this.type=3;}j(i){this.element[this.name]=i===U?void 0:i;}},Oi=class extends ue{constructor(){super(...arguments),this.type=4;}j(i){this.element.toggleAttribute(this.name,!!i&&i!==U);}},Ii=class extends ue{constructor(i,t,e,r,s){super(i,t,e,r,s),this.type=5;}vt(i,t=this){if((i=ce(this,i,t,0)??U)===Q)return;let e=this.r,r=i===U&&e!==U||i.capture!==e.capture||i.once!==e.once||i.passive!==e.passive,s=i!==U&&(e===U||r);r&&this.element.removeEventListener(this.name,this,e),s&&this.element.addEventListener(this.name,this,i),this.r=i;}handleEvent(i){typeof this.r=="function"?this.r.call(this.options?.host??this.element,i):this.r.handleEvent(i);}},Mi=class{constructor(i,t,e){this.element=i,this.type=6,this.mt=void 0,this.c=t,this.options=e;}get X(){return this.c.X}vt(i){ce(this,i);}},Ps={I:Te},cl=Kr.litHtmlPolyfillSupport;cl?.(Xe,Te),(Kr.litHtmlVersions??=[]).push("3.3.1");var $s=(o,i,t)=>{let e=t?.renderBefore??i,r=e.jl;if(r===void 0){let s=t?.renderBefore??null;e.jl=r=new Te(i.insertBefore(We(),s),s,void 0,t??{});}return r.vt(o),r};var Xr=globalThis,ft=class extends Lt{constructor(){super(...arguments),this.renderOptions={host:this},this.gr=void 0;}createRenderRoot(){let i=super.createRenderRoot();return this.renderOptions.renderBefore??=i.firstChild,i}update(i){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(i),this.gr=$s(t,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this.gr?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this.gr?.setConnected(false);}render(){return Q}};ft.Zd=true,ft.finalized=true,Xr.litElementHydrateSupport?.({LitElement:ft});var ul=Xr.litElementPolyfillSupport;ul?.({LitElement:ft});(Xr.litElementVersions??=[]).push("4.2.1");var dl=/\\([0-9a-fA-F]{1,6} ?)/g;function pl(o){return o.length<2?false:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function hl(o){let i=o;return (i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function fl(o){let i="",t="";for(let e=0;e<o.length;e++){let r=o[e+1];o[e]==="\\"&&r==='"'?(i+='\\"',e++):o[e]==='"'&&t!=="\\"?i+='\\"':i+=o[e],t=o[e]??"";}return i}function Ds(o){let i=o;pl(o)&&(i=hl(i),i=i.replace(dl,(t,e)=>String.fromCodePoint(parseInt(e.trim(),16))),i=i.replaceAll(`\\ `,"\\n"),i=fl(i),i='"'+i+'"');try{return JSON.parse(i)}catch{return}}function Ce(o){class i extends o{constructor(){super(...arguments);this.vs=null;this.yr=null;}getCssData(r,s=false){let n=this.vs??Object.create(null);if(!Object.keys(n).includes(r)||!n[r]){this.yr||(this.yr=window.getComputedStyle(this));let a=this.yr.getPropertyValue(r).trim();try{n[r]=Ds(a);}catch(l){s||console.warn(`CSS Data error: ${r}`,l),n[r]=null;}}return this.vs=n,n[r]}}return i}function Li(o){class i extends o{constructor(){super(...arguments);this.willYield=true;this.Bt={};this.Ht=null;this.ci=false;}createRenderRoot(){return this}connectedCallback(){this.Ht||(this.Ht=Array.from(this.childNodes)),super.connectedCallback();}Kl(){if(this.ci)return;this.ci=true,this.Bt={};let r=Array.from(this.childNodes),s=r.length?r:this.Ht??[];for(let n of s){let a=this.gs(n),l=this.Bt[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this.Bt[a]=l;}this.Ht=null;}gs(r){return r instanceof Comment&&r.nextSibling instanceof Element?this.gs(r.nextSibling):"contentFor"in r?r.contentFor||"":r instanceof Element&&r.hasAttribute("content-for")&&r.getAttribute("content-for")||""}Gl(r){return !r.textContent||!r.textContent.trim()}ql(r){let s=this.Bt[r];return !s||s.every(n=>n instanceof Comment||n instanceof Text&&this.Gl(n))}update(r){!this.hasUpdated&&this.willYield&&this.Kl(),super.update(r);}yield(r,s){if(r===""&&!this.Bt[r]&&!this.ci&&this.Ht?.length){let a=[];for(let l of this.Ht)l instanceof Element&&(l.removeAttribute("slot"),l.removeAttribute("content-for")),a.push(l);this.Bt[r]=a,this.ci=true,this.Ht=null;}let n=this.Bt[r];return g` ${n} ${this.ql(r)?s:void 0} `}}return i}function Ae(o){class i extends o{static reg(e){let r=this,s=window.customElements.get(e);if(s){s!==r&&console.warn([`Element with tag name "${e}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(` `));return}window.customElements.define(e,r);}}return i}var Bt=class extends Event{constructor(i,t,e,r){super("context-request",{bubbles:true,composed:true}),this.context=i,this.contextTarget=t,this.callback=e,this.subscribe=r??false;}};var Se=class{constructor(i,t,e,r){if(this.subscribe=false,this.provided=false,this.value=void 0,this.t=(s,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=false,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=true,this.callback&&this.callback(s,n)),this.unsubscribe=n;},this.host=i,t.context!==void 0){let s=t;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??false;}else this.context=t,this.callback=e,this.subscribe=r??false;this.host.addController(this);}hostConnected(){this.dispatchRequest();}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0);}dispatchRequest(){this.host.dispatchEvent(new Bt(this.context,this.host,this.t,this.subscribe));}};var Ui=class{get value(){return this.o}set value(i){this.setValue(i);}setValue(i,t=false){let e=t||!Object.is(i,this.o);this.o=i,e&&this.updateObservers();}constructor(i){this.subscriptions=new Map,this.updateObservers=()=>{for(let[t,{disposer:e}]of this.subscriptions)t(this.o,e);},i!==void 0&&(this.value=i);}addCallback(i,t,e){if(!e)return void i(this.value);this.subscriptions.has(i)||this.subscriptions.set(i,{disposer:()=>{this.subscriptions.delete(i);},consumerHost:t});let{disposer:r}=this.subscriptions.get(i);i(this.value,r);}clearCallbacks(){this.subscriptions.clear();}};var Qr=class extends Event{constructor(i,t){super("context-provider",{bubbles:true,composed:true}),this.context=i,this.contextTarget=t;}},ke=class extends Ui{constructor(i,t,e){super(t.context!==void 0?t.initialValue:e),this.onContextRequest=r=>{if(r.context!==this.context)return;let s=r.contextTarget??r.composedPath()[0];s!==this.host&&(r.stopPropagation(),this.addCallback(r.callback,s,r.subscribe));},this.onProviderRequest=r=>{if(r.context!==this.context||(r.contextTarget??r.composedPath()[0])===this.host)return;let s=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)s.has(n)||(s.add(n),a.dispatchEvent(new Bt(this.context,a,n,true)));r.stopPropagation();},this.host=i,t.context!==void 0?this.context=t.context:this.context=t,this.attachListeners(),this.host.addController?.(this);}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest);}hostConnected(){this.host.dispatchEvent(new Qr(this.context,this.host));}};var vl={attribute:true,type:String,converter:Ge,reflect:false,hasChanged:Ci},gl=(o=vl,i,t)=>{let{kind:e,metadata:r}=t,s=globalThis.litPropertyMetadata.get(r);if(s===void 0&&globalThis.litPropertyMetadata.set(r,s=new Map),e==="setter"&&((o=Object.create(o)).wrapped=true),s.set(t.name,o),e==="accessor"){let{name:n}=t;return {set(a){let l=i.get.call(this);i.set.call(this,a),this.requestUpdate(n,l,o);},init(a){return a!==void 0&&this.C(n,void 0,o,a),a}}}if(e==="setter"){let{name:n}=t;return function(a){let l=this[n];i.call(this,a),this.requestUpdate(n,l,o);}}throw Error("Unsupported decorator location: "+e)};function w(o){return (i,t)=>typeof t=="object"?gl(o,i,t):((e,r,s)=>{let n=r.hasOwnProperty(s);return r.constructor.createProperty(s,e),n?Object.getOwnPropertyDescriptor(r,s):void 0})(o,i,t)}function v(o){return w({...o,state:true,attribute:false})}function P(o,i){let t,e=((...r)=>{t&&clearTimeout(t),t=setTimeout(()=>o(...r),i);});return e.cancel=()=>{t&&clearTimeout(t);},e}var Vs="ctx-name-context";function Pi(){return function(o){class i extends o{constructor(...r){super(...r);this.tt=null;this.Ue=false;this.br=false;this.wr=void 0;this.le=new Map;this.Re=new Set;this.init$={};this.ctxOwner=false;this.ui=void 0;this.di=false;this.ctxName=this.Mt;this.Lt=false;this.ui=this.getAttribute("ctx-name")||void 0,this.ctxName=this.Mt,this.Wl=new Se(this,{context:Vs,callback:s=>{if(!s){console.error("SymbioteMixin: Received invalid ctx-name from context");return}this.xs=s,this.bs();},subscribe:true});}get ys(){return this.ui}set ys(r){let s=r??void 0;this.ui!==s&&(this.ui=s,this.bs());}shouldUpdate(r){return this.Lt?super.shouldUpdate(r):false}get Mt(){return this.ys||this.xs||void 0}bs(){if(this.ctxName=this.Mt,!(!this.ctxName||this.Ue)){if(this.isConnected){this.xr();return}this.di=true;}}willUpdate(r){super.willUpdate(r),this.ctxName=this.Mt,this.ctxName&&(this.wr?this.wr.setValue(this.ctxName):this.wr=new ke(this,{context:Vs,initialValue:this.ctxName}));}Es(){if(!(!this.tt||this.le.size===0)){for(let[r,{value:s,rewrite:n}]of this.le)this.tt.add(r,s,n);this.le.clear();}}Ts(){return !this.tt&&this.Mt&&this.Er(),this.tt&&this.Es(),this.tt}Tr(){let r=this.Ts();if(!r)throw new Error("SymbioteMixin: Shared context is not initialized.");return r}Er(){let r=this.init$,s=this.Mt;if(!s){console.error("SymbioteMixin: ctx-name is required for components with shared properties (*)");return}if(!this.tt){this.tt=N.getCtx(s)??N.registerCtx(r,s);for(let[n,a]of Object.entries(this.init$))this.tt.add(n,a,this.ctxOwner);this.Es();}}get $(){return this.Mt&&this.Er(),new Proxy({},{get:(r,s)=>{if(typeof s=="string")return this.tt?.read(s)},set:(r,s,n)=>(typeof s!="string"||this.tt?.pub(s,n),true)})}sub(r,s,n=true){let a=this.Tr().sub(r,s,n);if(!a||typeof a.remove!="function")return ()=>{};let l=a.remove.bind(a),c=false,d=()=>{c||(c=true,l(),this.Re.delete(d));};return this.Re.add(d),d}pub(r,s){this.Tr().pub(r,s);}set$(r){for(let[s,n]of Object.entries(r))this.pub(s,n);}has(r){return this.tt?.has(r)??false}add(r,s,n=false){let a=this.Ts();if(!a){if(!n&&this.le.has(r))return;this.le.set(r,{value:s,rewrite:n});return}this.le.delete(r),a.add(r,s,n);}add$(r,s=false){for(let[n,a]of Object.entries(r))this.add(n,a,s);}connectedCallback(){super.connectedCallback(),this.Ue?this.Lt&&this.br&&(this.br=false,this.initCallback()):this.ctxName?(this.di=false,this.xr()):this.di&&this.Mt&&(this.di=false,this.xr());}xr(){if(this.Ue)return;this.Ue=true,this.Er();let r=this.init$;if(Object.keys(r).length>0){let s=this.Tr();for(let[n,a]of Object.entries(r))s.read(n)===void 0&&s.pub(n,a),this.sub(n,P(async()=>{this.isConnected&&(await this.updateComplete,this.requestUpdate());},0),false);}this.initCallback(),this.Lt=true,this.requestUpdate();}firstUpdated(r){super.firstUpdated(r);}disconnectedCallback(){this.Zl(),super.disconnectedCallback(),this.Ue&&(this.br=true);}Zl(){if(this.Re.size!==0){for(let r of [...this.Re])r();this.Re.clear();}}initCallback(){}}return p([w({type:String,attribute:"ctx-name",noAccessor:true})],i.prototype,"ys",1),p([v()],i.prototype,"xs",2),p([v()],i.prototype,"ctxName",2),p([v()],i.prototype,"Lt",2),i}}var Yr=class extends Ae(Pi()(Ce(Li(ft)))){};var Rt=class{static generate(){return `uid-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}};var yl=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function Jr(o){for(let i in o){if(yl.includes(i))continue;let t=[...i].reduce((e,r)=>(r.toUpperCase()===r&&(r=`-${r.toLowerCase()}`),e+=r,e),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("uc-")||(t=`uc-${t}`),o[i].reg&&o[i].reg(t);}}var to="UC";function bl(o,i=false){return new Promise((t,e)=>{if(typeof document!="object"){t(null);return}if(typeof window=="object"&&window[to]){t(window[to]);return}let r=document.createElement("script");r.async=true,r.src=o,r.onerror=()=>{e();},r.onload=()=>{let s=window[to];i&&Jr(s),t(s);},document.head.appendChild(r);})}var Qe={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"OneDrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var eo=new Map,Fs=new Map,_s=(o,i)=>{eo.has(o)&&console.log(`Locale ${o} is already defined. Overwriting...`);let t={...Qe,...i};return eo.set(o,t),t},wl=(o,i)=>{Fs.set(o,i);},Ns=(o,i)=>{typeof i=="function"?wl(o,i):_s(o,i);},zs=async o=>{let i=eo.get(o);if(!i){let t=Fs.get(o);if(!t)throw new Error(`Locale ${o} is not defined`);let e=await t();i=_s(o,e);}return i};Ns("en",Qe);var j=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),$i=class{constructor(i){this.jt=new Map;this.gt=new Set;this.E=new Map;this.m=i;}v(...i){this.m.debugPrint("[modal-manager]",...i);}registerModal(i,t){this.jt.set(i,t),this.q(j.ADD,{id:i,modal:t});}deleteModal(i){let t=this.jt.get(i);return t?(this.jt.delete(i),this.gt.delete(i),this.q(j.DELETE,{id:i,modal:t}),true):false}open(i){let t=this.jt.get(i);return t?(this.gt.add(i),this.q(j.OPEN,{modal:t,id:i}),true):(this.v(`Modal with ID "${i}" not found`),false)}close(i){let t=this.jt.get(i);return !t||!this.gt.has(i)?(this.v(`Modal with ID "${i}" not found or not active`),false):(this.gt.delete(i),this.q(j.CLOSE,{id:i,modal:t}),true)}toggle(i){return this.jt.has(i)?this.gt.has(i)?this.close(i):this.open(i):(this.v(`Modal with ID "${i}" not found`),false)}get hasActiveModals(){return this.gt.size>0}back(){if(this.gt.size===0)return this.v("No active modals to go back from"),false;let i=Array.from(this.gt).pop();return i?this.close(i):false}closeAll(){let i=this.gt.size;return this.gt.clear(),this.q(j.CLOSE_ALL,{}),i}subscribe(i,t){return this.E.has(i)||this.E.set(i,new Set),this.E.get(i)?.add(t),()=>this.unsubscribe(i,t)}unsubscribe(i,t){this.E.has(i)&&this.E.get(i)?.delete(t);}q(i,t){if(this.E.has(i))for(let e of this.E.get(i)??new Set)try{e(t);}catch(r){this.m.telemetryManager.sendEventError(r,"modal subscriber"),this.v("Error in modal subscriber:",r);}}destroy(){this.closeAll(),this.jt.clear(),this.E.clear(),this.q(j.DESTROY,{});}};var Ye=o=>o.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(i=>i.toLowerCase()).join("-");function Bs(o){return Object.prototype.toString.call(o)==="[object Object]"}var xl=/\W|_/g;function El(o){return o.split(xl).map((i,t)=>i.charAt(0)[t>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}function Hs(o,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(o)?o.map(t=>$t(t,{ignoreKeys:i})):o}function $t(o,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(o))return Hs(o,{ignoreKeys:i});if(!Bs(o))return o;let t={};for(let e of Object.keys(o)){let r=o[e];if(i.includes(e)){t[e]=r;continue}Bs(r)?r=$t(r,{ignoreKeys:i}):Array.isArray(r)&&(r=Hs(r,{ignoreKeys:i})),t[El(e)]=r;}return t}var Tl=o=>new Promise(i=>setTimeout(i,o));function lo({libraryName:o,libraryVersion:i,userAgent:t,publicKey:e="",integration:r=""}){let s="JavaScript";if(typeof t=="string")return t;if(typeof t=="function")return t({publicKey:e,libraryName:o,libraryVersion:i,languageName:s,integration:r});let n=[o,i,e].filter(Boolean).join("/"),a=[s,r].filter(Boolean).join("; ");return `${n} (${a})`}var Cl={factor:2,time:100};function Al(o,i=Cl){let t=0;function e(r){let s=Math.round(i.time*i.factor**t);return r({attempt:t,retry:a=>Tl(a??s).then(()=>(t+=1,e(r)))})}return e(o)}var de=class extends Error{},Oe=class o extends de{originalProgressEvent;constructor(i){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,o.prototype),this.originalProgressEvent=i;}},Di=(o,i)=>{o&&(o.aborted?Promise.resolve().then(i):o.addEventListener("abort",()=>i(),{once:true}));},Ht=class o extends de{isCancel=true;constructor(i="Request canceled"){super(i),this.name="CancelError",Object.setPrototypeOf(this,o.prototype);}},Sl=500,Ks=({check:o,interval:i=Sl,timeout:t,signal:e})=>new Promise((r,s)=>{let n,a;Di(e,()=>{n&&clearTimeout(n),s(new Ht("Poll cancelled"));}),t&&(a=setTimeout(()=>{n&&clearTimeout(n),s(new Ht("Timed out"));},t));let l=()=>{try{Promise.resolve(o(e)).then(c=>{c?(a&&clearTimeout(a),r(c)):n=setTimeout(l,i);}).catch(c=>{a&&clearTimeout(a),s(c);});}catch(c){a&&clearTimeout(a),s(c);}};n=setTimeout(l,0);}),L={baseCDN:"https://ucarecdn.com",baseURL:"https://upload.uploadcare.com",retryThrottledRequestMaxTimes:1,retryNetworkErrorMaxTimes:3,multipartMinFileSize:25*1024*1024,multipartChunkSize:5*1024*1024,maxConcurrentRequests:4,pusherKey:"79ae88bd931ea68464d9"},Vi="application/octet-stream",Gs="original",Kt=({method:o,url:i,data:t,headers:e={},signal:r,onProgress:s})=>new Promise((n,a)=>{let l=new XMLHttpRequest,c=o?.toUpperCase()||"GET",d=false;l.open(c,i,true),e&&Object.entries(e).forEach(u=>{let[h,f]=u;typeof f<"u"&&!Array.isArray(f)&&l.setRequestHeader(h,f);}),l.responseType="text",Di(r,()=>{d=true,l.abort(),a(new Ht);}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else {let u={method:c,url:i,data:t,headers:e||void 0,signal:r,onProgress:s},h=l.getAllResponseHeaders().trim().split(/[\r\n]+/),f={};h.forEach(function(x){let T=x.split(": "),C=T.shift(),M=T.join(": ");C&&typeof C<"u"&&(f[C]=M);});let m=l.response,b=l.status;n({request:u,data:m,headers:f,status:b});}},l.onerror=u=>{d||a(new Oe(u));},s&&typeof s=="function"&&(l.upload.onprogress=u=>{u.lengthComputable?s({isComputable:true,value:u.loaded/u.total}):s({isComputable:false});}),t?l.send(t):l.send();});function kl(o,...i){return o}var Ol=({name:o})=>o?[o]:[],Il=kl,Ml=()=>new FormData,qs=o=>false,Fi=o=>typeof Blob<"u"&&o instanceof Blob,_i=o=>typeof File<"u"&&o instanceof File,Ni=o=>!!o&&typeof o=="object"&&!Array.isArray(o)&&"uri"in o&&typeof o.uri=="string",Ie=o=>Fi(o)||_i(o)||qs()||Ni(o),Ll=o=>typeof o=="string"||typeof o=="number"||typeof o>"u",Ul=o=>!!o&&typeof o=="object"&&!Array.isArray(o),Rl=o=>!!o&&typeof o=="object"&&"data"in o&&Ie(o.data);function Ws(o,i,t){if(Array.isArray(t))for(let e of t)Ws(o,`${i}[]`,e);else if(Rl(t)){let{name:e,contentType:r}=t,s=Il(t.data,e,r??Vi),n=Ol({name:e});o.push([i,s,...n]);}else if(Ul(t))for(let[e,r]of Object.entries(t))typeof r<"u"&&o.push([`${i}[${e}]`,String(r)]);else Ll(t)&&t&&o.push([i,t.toString()]);}function Pl(o){let i=[];for(let[t,e]of Object.entries(o))Ws(i,t,e);return i}function zi(o){let i=Ml(),t=Pl(o);for(let e of t){let[r,s,...n]=e;i.append(r,s,...n);}return i}var Y=class o extends de{code;request;response;headers;constructor(i,t,e,r,s){super(),this.name="UploadError",this.message=i,this.code=t,this.request=e,this.response=r,this.headers=s,Object.setPrototypeOf(this,o.prototype);}},$l=o=>{let i=new URLSearchParams;for(let[t,e]of Object.entries(o))e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).filter(r=>r[1]??false).forEach(r=>i.set(`${t}[${r[0]}]`,String(r[1]))):Array.isArray(e)?e.forEach(r=>{i.append(`${t}[]`,r);}):typeof e=="string"&&e?i.set(t,e):typeof e=="number"&&i.set(t,e.toString());return i.toString()},Pt=(o,i,t)=>{let e=new URL(o);return e.pathname=(e.pathname+i).replace("//","/"),t&&(e.search=$l(t)),e.toString()},Dl="6.18.2",Vl="UploadcareUploadClient",Fl=Dl;function he(o){return lo({libraryName:Vl,libraryVersion:Fl,...o})}var _l="RequestThrottledError",js=15e3,Nl=1e3;function zl(o){let{headers:i}=o||{};if(!i||typeof i["retry-after"]!="string")return js;let t=parseInt(i["retry-after"],10);return Number.isFinite(t)?t*1e3:js}function Gt(o,i){let{retryThrottledRequestMaxTimes:t,retryNetworkErrorMaxTimes:e}=i;return Al(({attempt:r,retry:s})=>o().catch(n=>{if("response"in n&&n?.code===_l&&r<t)return s(zl(n));if(n instanceof Oe&&r<e)return s((r+1)*Nl);throw n}))}var Zs=o=>{let i="";return (Fi(o)||_i(o)||Ni(o))&&(i=o.type),i||Vi},Xs=o=>{let i="";return _i(o)&&o.name?i=o.name:Fi(o)||qs()?i="":Ni(o)&&o.name&&(i=o.name),i||Gs};function co(o){return typeof o>"u"||o==="auto"?"auto":o?"1":"0"}function Bl(o,{publicKey:i,fileName:t,contentType:e,baseURL:r=L.baseURL,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:c,source:d="local",integration:u,userAgent:h,retryThrottledRequestMaxTimes:f=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=L.retryNetworkErrorMaxTimes,metadata:b}){return Gt(()=>Kt({method:"POST",url:Pt(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":he({publicKey:i,integration:u,userAgent:h})},data:zi({file:{data:o,name:t||Xs(o),contentType:e||Zs(o)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:co(a),signature:s,expire:n,source:d,metadata:b}),signal:l,onProgress:c}).then(({data:x,headers:T,request:C})=>{let M=$t(JSON.parse(x));if("error"in M)throw new Y(M.error.content,M.error.errorCode,C,M,T);return M}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}var oo;(function(o){o.Token="token",o.FileInfo="file_info";})(oo||(oo={}));function Hl(o,{publicKey:i,baseURL:t=L.baseURL,store:e,fileName:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:c="url",signal:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=L.retryNetworkErrorMaxTimes,metadata:b}){return Gt(()=>Kt({method:"POST",headers:{"X-UC-User-Agent":he({publicKey:i,integration:u,userAgent:h})},url:Pt(t,"/from_url/",{jsonerrors:1,pub_key:i,source_url:o,store:co(e),filename:r,check_URL_duplicates:s?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:c,metadata:b}),signal:d}).then(({data:x,headers:T,request:C})=>{let M=$t(JSON.parse(x));if("error"in M)throw new Y(M.error.content,M.error.errorCode,C,M,T);return M}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}var st;(function(o){o.Unknown="unknown",o.Waiting="waiting",o.Progress="progress",o.Error="error",o.Success="success";})(st||(st={}));var jl=o=>"status"in o&&o.status===st.Error;function Kl(o,{publicKey:i,baseURL:t=L.baseURL,signal:e,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=L.retryNetworkErrorMaxTimes}={}){return Gt(()=>Kt({method:"GET",headers:i?{"X-UC-User-Agent":he({publicKey:i,integration:r,userAgent:s})}:void 0,url:Pt(t,"/from_url/status/",{jsonerrors:1,token:o}),signal:e}).then(({data:l,headers:c,request:d})=>{let u=$t(JSON.parse(l));if("error"in u&&!jl(u))throw new Y(u.error.content,u.error.errorCode,d,u,c);return u}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function Gl(o,{publicKey:i,baseURL:t=L.baseURL,jsonpCallback:e,secureSignature:r,secureExpire:s,signal:n,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:u=L.retryNetworkErrorMaxTimes}){return Gt(()=>Kt({method:"POST",headers:{"X-UC-User-Agent":he({publicKey:i,integration:l,userAgent:c})},url:Pt(t,"/group/",{jsonerrors:1}),data:zi({files:o,callback:e,pub_key:i,signature:r,expire:s,source:a}),signal:n}).then(({data:h,headers:f,request:m})=>{let b=$t(JSON.parse(h));if("error"in b)throw new Y(b.error.content,b.error.errorCode,m,b,f);return b}),{retryNetworkErrorMaxTimes:u,retryThrottledRequestMaxTimes:d})}function Qs(o,{publicKey:i,baseURL:t=L.baseURL,signal:e,source:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=L.retryNetworkErrorMaxTimes}){return Gt(()=>Kt({method:"GET",headers:{"X-UC-User-Agent":he({publicKey:i,integration:s,userAgent:n})},url:Pt(t,"/info/",{jsonerrors:1,pub_key:i,file_id:o,source:r}),signal:e}).then(({data:c,headers:d,request:u})=>{let h=$t(JSON.parse(c));if("error"in h)throw new Y(h.error.content,h.error.errorCode,u,h,d);return h}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function ql(o,{publicKey:i,contentType:t,fileName:e,multipartChunkSize:r=L.multipartChunkSize,baseURL:s="",secureSignature:n,secureExpire:a,store:l,signal:c,source:d="local",integration:u,userAgent:h,retryThrottledRequestMaxTimes:f=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=L.retryNetworkErrorMaxTimes,metadata:b}){return Gt(()=>Kt({method:"POST",url:Pt(s,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":he({publicKey:i,integration:u,userAgent:h})},data:zi({filename:e,size:o,content_type:t||Vi,part_size:r,UPLOADCARE_STORE:co(l),UPLOADCARE_PUB_KEY:i,signature:n,expire:a,source:d,metadata:b}),signal:c}).then(({data:x,headers:T,request:C})=>{let M=$t(JSON.parse(x));if("error"in M)throw new Y(M.error.content,M.error.errorCode,C,M,T);return M.parts=Object.keys(M.parts).map(pt=>M.parts[Number(pt)]),M}),{retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})}function Wl(o,i,{contentType:t,signal:e,onProgress:r,retryThrottledRequestMaxTimes:s=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=L.retryNetworkErrorMaxTimes}){return Gt(()=>Kt({method:"PUT",url:i,data:o,onProgress:r,signal:e,headers:{"Content-Type":t||Vi}}).then(a=>(r&&r({isComputable:true,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n})}function Zl(o,{publicKey:i,baseURL:t=L.baseURL,source:e="local",signal:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=L.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=L.retryNetworkErrorMaxTimes}){return Gt(()=>Kt({method:"POST",url:Pt(t,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":he({publicKey:i,integration:s,userAgent:n})},data:zi({uuid:o,UPLOADCARE_PUB_KEY:i,source:e}),signal:r}).then(({data:c,headers:d,request:u})=>{let h=$t(JSON.parse(c));if("error"in h)throw new Y(h.error.content,h.error.errorCode,u,h,d);return h}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function uo(o,{publicKey:i,baseURL:t,source:e,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:c}){return Ks({check:d=>Qs(o,{publicKey:i,baseURL:t,signal:d,source:e,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(u=>u.isReady?u:(c&&c({isComputable:true,value:1}),false)),signal:l})}function Xl(o){return "defaultEffects"in o}var pe=class{uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(i,{baseCDN:t=L.baseCDN,fileName:e}={}){let{uuid:r,s3Bucket:s}=i,n=Pt(t,`${r}/`),a=s?Pt(`https://${s}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=e||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=n,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=s||null,this.s3Url=a,Xl(i)&&(this.defaultEffects=i.defaultEffects);}},Ql=(o,{publicKey:i,fileName:t,baseURL:e,secureSignature:r,secureExpire:s,store:n,contentType:a,signal:l,onProgress:c,source:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:b,metadata:x})=>Bl(o,{publicKey:i,fileName:t,contentType:a,baseURL:e,secureSignature:r,secureExpire:s,store:n,signal:l,onProgress:c,source:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,metadata:x}).then(({file:T})=>uo(T,{publicKey:i,baseURL:e,source:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,onProgress:c,signal:l})).then(T=>new pe(T,{baseCDN:b})),Yl=(o,{publicKey:i,fileName:t,baseURL:e,signal:r,onProgress:s,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d,baseCDN:u})=>Qs(o,{publicKey:i,baseURL:e,signal:r,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d}).then(h=>new pe(h,{baseCDN:u,fileName:t})).then(h=>(s&&s({isComputable:true,value:1}),h)),Jl=(o,{signal:i}={})=>{let t=null,e=null,r=o.map(()=>new AbortController),s=n=>()=>{e=n,r.forEach((a,l)=>l!==n&&a.abort());};return Di(i,()=>{r.forEach(n=>n.abort());}),Promise.all(o.map((n,a)=>{let l=s(a);return Promise.resolve().then(()=>n({stopRace:l,signal:r[a].signal})).then(c=>(l(),c)).catch(c=>(t=c,null))})).then(n=>{if(e===null)throw t;return n[e]})},tc=window.WebSocket,so=class{events=Object.create({});emit(i,t){this.events[i]?.forEach(e=>e(t));}on(i,t){this.events[i]=this.events[i]||[],this.events[i].push(t);}off(i,t){t?this.events[i]=this.events[i].filter(e=>e!==t):this.events[i]=[];}},ec=(o,i)=>o==="success"?{status:st.Success,...i}:o==="progress"?{status:st.Progress,...i}:{status:st.Error,...i},no=class{key;disconnectTime;ws=void 0;queue=[];isConnected=false;subscribers=0;emmitter=new so;disconnectTimeoutId=null;constructor(i,t=3e4){this.key=i,this.disconnectTime=t;}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new tc(i),this.ws.addEventListener("error",t=>{this.emmitter.emit("error",new Error(t.message));}),this.emmitter.on("connected",()=>{this.isConnected=true,this.queue.forEach(t=>this.send(t.event,t.data)),this.queue=[];}),this.ws.addEventListener("message",t=>{let e=JSON.parse(t.data.toString());switch(e.event){case "pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case "pusher:ping":{this.send("pusher:pong",{});break}case "progress":case "success":case "fail":this.emmitter.emit(e.channel,ec(e.event,JSON.parse(e.data)));}});}}disconnect(){let i=()=>{this.ws?.close(),this.ws=void 0,this.isConnected=false;};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i();},this.disconnectTime):i();}send(i,t){let e=JSON.stringify({event:i,data:t});this.ws?.send(e);}subscribe(i,t){this.subscribers+=1,this.connect();let e=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:e}};this.emmitter.on(e,t),this.isConnected?this.send(r.event,r.data):this.queue.push(r);}unsubscribe(i){this.subscribers-=1;let t=`task-status-${i}`,e={event:"pusher:unsubscribe",data:{channel:t}};this.emmitter.off(t),this.isConnected?this.send(e.event,e.data):this.queue=this.queue.filter(r=>r.data.channel!==t),this.subscribers===0&&this.disconnect();}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}},io=null,po=o=>{if(!io){let i=typeof window>"u"?0:3e4;io=new no(o,i);}return io},ic=o=>{po(o).connect();};function rc({token:o,publicKey:i,baseURL:t,integration:e,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Ks({check:c=>Kl(o,{publicKey:i,baseURL:t,integration:e,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,signal:c}).then(d=>{switch(d.status){case st.Error:return new Y(d.error,d.errorCode);case st.Waiting:return false;case st.Unknown:return new Y(`Token "${o}" was not found.`);case st.Progress:return a&&(d.total==="unknown"?a({isComputable:false}):a({isComputable:true,value:d.done/d.total})),false;case st.Success:return a&&a({isComputable:true,value:d.done/d.total}),d;default:throw new Error("Unknown status")}}),signal:l})}var oc=({token:o,pusherKey:i,signal:t,onProgress:e})=>new Promise((r,s)=>{let n=po(i),a=n.onError(s),l=()=>{a(),n.unsubscribe(o);};Di(t,()=>{l(),s(new Ht("pusher cancelled"));}),n.subscribe(o,c=>{switch(c.status){case st.Progress:{e&&(c.total==="unknown"?e({isComputable:false}):e({isComputable:true,value:c.done/c.total}));break}case st.Success:{l(),e&&e({isComputable:true,value:c.done/c.total}),r(c);break}case st.Error:l(),s(new Y(c.msg,c.error_code));}});}),sc=(o,{publicKey:i,fileName:t,baseURL:e,baseCDN:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,onProgress:u,source:h,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,pusherKey:x=L.pusherKey,metadata:T})=>Promise.resolve(ic(x)).then(()=>Hl(o,{publicKey:i,fileName:t,baseURL:e,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,source:h,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,metadata:T})).catch(C=>(po(x)?.disconnect(),Promise.reject(C))).then(C=>C.type===oo.FileInfo?C:Jl([({signal:M})=>rc({token:C.token,publicKey:i,baseURL:e,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,onProgress:u,signal:M}),({signal:M})=>oc({token:C.token,pusherKey:x,signal:M,onProgress:u})],{signal:d})).then(C=>{if(C instanceof Y)throw C;return C}).then(C=>uo(C.uuid,{publicKey:i,baseURL:e,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,onProgress:u,signal:d})).then(C=>new pe(C,{baseCDN:r})),ro=new WeakMap,nc=async o=>{if(ro.has(o))return ro.get(o);let i=await fetch(o.uri).then(t=>t.blob());return ro.set(o,i),i},Ys=async o=>{if(_i(o)||Fi(o))return o.size;if(Ni(o))return (await nc(o)).size;throw new Error("Unknown file type. Cannot determine file size.")},ac=(o,i=L.multipartMinFileSize)=>o>=i,Js=o=>{let i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",t=new RegExp(i);return !Ie(o)&&t.test(o)},ho=o=>{let i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",t=new RegExp(i);return !Ie(o)&&t.test(o)},lc=(o,i)=>new Promise((t,e)=>{let r=[],s=false,n=i.length,a=[...i],l=()=>{let c=i.length-a.length,d=a.shift();d&&d().then(u=>{s||(r[c]=u,n-=1,n?l():t(r));}).catch(u=>{s=true,e(u);});};for(let c=0;c<o;c++)l();}),cc=(o,i,t,e)=>{let r=e*i,s=Math.min(r+e,t);return o.slice(r,s)},uc=async(o,i,t)=>e=>cc(o,e,i,t),dc=(o,i,{publicKey:t,contentType:e,onProgress:r,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>Wl(o,i,{contentType:e,onProgress:r,signal:s,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),pc=async(o,{publicKey:i,fileName:t,fileSize:e,baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:c,source:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:b,multipartChunkSize:x=L.multipartChunkSize,maxConcurrentRequests:T=L.maxConcurrentRequests,baseCDN:C,metadata:M})=>{let pt=e??await Ys(o),ht,se=(W,ot)=>{if(!c)return;ht||(ht=Array(W).fill(0));let yt=Ct=>Ct.reduce((Mt,Nr)=>Mt+Nr,0);return Ct=>{Ct.isComputable&&(ht[ot]=Ct.value,c({isComputable:true,value:yt(ht)/W}));}};return b||=Zs(o),ql(pt,{publicKey:i,contentType:b,fileName:t||Xs(o),baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,source:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,metadata:M,multipartChunkSize:x}).then(async({uuid:W,parts:ot})=>{let yt=await uc(o,pt,x);return Promise.all([W,lc(T,ot.map((Ct,Mt)=>()=>dc(yt(Mt),Ct,{publicKey:i,contentType:b,onProgress:se(ot.length,Mt),signal:l,integration:u,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})))])}).then(([W])=>Zl(W,{publicKey:i,baseURL:r,source:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})).then(W=>W.isReady?W:uo(W.uuid,{publicKey:i,baseURL:r,source:d,integration:u,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,onProgress:c,signal:l})).then(W=>new pe(W,{baseCDN:C}))};async function fo(o,{publicKey:i,fileName:t,baseURL:e=L.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:h,retryNetworkErrorMaxTimes:f,contentType:m,multipartMinFileSize:b,multipartChunkSize:x,maxConcurrentRequests:T,baseCDN:C=L.baseCDN,checkForUrlDuplicates:M,saveUrlForRecurrentUploads:pt,pusherKey:ht,metadata:se}){if(Ie(o)){let W=await Ys(o);return ac(W,b)?pc(o,{publicKey:i,contentType:m,multipartChunkSize:x,fileSize:W,fileName:t,baseURL:e,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,maxConcurrentRequests:T,retryThrottledRequestMaxTimes:h,retryNetworkErrorMaxTimes:f,baseCDN:C,metadata:se}):Ql(o,{publicKey:i,fileName:t,contentType:m,baseURL:e,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:h,retryNetworkErrorMaxTimes:f,baseCDN:C,metadata:se})}if(ho(o))return sc(o,{publicKey:i,fileName:t,baseURL:e,baseCDN:C,checkForUrlDuplicates:M,saveUrlForRecurrentUploads:pt,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:h,pusherKey:ht,metadata:se});if(Js(o))return Yl(o,{publicKey:i,fileName:t,baseURL:e,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:h,retryNetworkErrorMaxTimes:f,baseCDN:C});throw new TypeError(`File uploading from "${o}" is not supported`)}var ao=class{uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(i,{baseCDN:t=L.baseCDN}={}){this.uuid=i.id,this.filesCount=i.filesCount;let e=i.files.filter(Boolean);this.totalSize=Object.values(e).reduce((r,s)=>r+s.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(e).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=e.map(r=>new pe(r,{baseCDN:t})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored;}},hc=o=>{for(let i of o)if(!Ie(i))return false;return true},fc=o=>{for(let i of o)if(!Js(i))return false;return true},mc=o=>{for(let i of o)if(!ho(i))return false;return true};function tn(o,{publicKey:i,fileName:t,baseURL:e=L.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:h,retryNetworkErrorMaxTimes:f,contentType:m,multipartChunkSize:b=L.multipartChunkSize,baseCDN:x=L.baseCDN,checkForUrlDuplicates:T,saveUrlForRecurrentUploads:C,jsonpCallback:M}){if(!hc(o)&&!mc(o)&&!fc(o))throw new TypeError(`Group uploading from "${o}" is not supported`);let pt,ht=true,se=o.length,W=(ot,yt)=>{if(!l)return;pt||(pt=Array(ot).fill(0));let Ct=Mt=>Mt.reduce((Nr,Xa)=>Nr+Xa)/ot;return Mt=>{if(!Mt.isComputable||!ht){ht=false,l({isComputable:false});return}pt[yt]=Mt.value,l({isComputable:true,value:Ct(pt)});}};return Promise.all(o.map((ot,yt)=>Ie(ot)||ho(ot)?fo(ot,{publicKey:i,fileName:t,baseURL:e,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:W(se,yt),source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:h,retryNetworkErrorMaxTimes:f,contentType:m,multipartChunkSize:b,baseCDN:x,checkForUrlDuplicates:T,saveUrlForRecurrentUploads:C}).then(Ct=>Ct.uuid):ot)).then(ot=>Gl(ot,{publicKey:i,baseURL:e,jsonpCallback:M,secureSignature:r,secureExpire:s,signal:a,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:h,retryNetworkErrorMaxTimes:f}).then(yt=>new ao(yt,{baseCDN:x})).then(yt=>(l&&l({isComputable:true,value:1}),yt)))}var jt=class{pi=1;Cr=[];hi=0;Ar=new Map;Sr=new Map;constructor(i){this.pi=i;}run(){let i=this.pi-this.hi;for(let t=0;t<i;t++){let e=this.Cr.shift();if(!e)return;let r=this.Ar.get(e),s=this.Sr.get(e);if(!r||!s)throw new Error("Unexpected behavior: resolver or rejector is undefined");this.hi+=1,e().finally(()=>{this.Ar.delete(e),this.Sr.delete(e),this.hi-=1,this.run();}).then(n=>r(n)).catch(n=>s(n));}}add(i,{autoRun:t}={autoRun:true}){return new Promise((e,r)=>{this.Ar.set(i,e),this.Sr.set(i,r),this.Cr.push(i),t&&this.run();})}get pending(){return this.Cr.length}get running(){return this.hi}set concurrency(i){this.pi=i,this.run();}get concurrency(){return this.pi}};var mo=()=>({}),vo=o=>({...mo(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{o.modalManager?.close(o.$["*currentActivity"]),o.pub("*currentActivity",null);}}),go=o=>({...vo(o),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new jt(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),en=o=>({...go(o),"*solution":null});var vc={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function Je(o,i){i.tabIndex=0,i.focus(),o.tabIndex=-1;}function yo(o){let i=o.role||o.type||o.tagName;if(!i)return null;let t=vc[i.toLowerCase()];if(!t)return null;for(let e of t){let r=o.closest(`[role=${e}]`);if(r)return r}}function bo(o,i){return i.role==="toolbar"?gc(i):i.querySelectorAll(`[role=${o.role}]`)}function gc(o){return [...o.querySelectorAll("*")].filter(t=>t.role==="button"||t.type==="button"||t.role==="checkbox"||t.type==="checkbox")}function yc(o){let i=o.getAttribute("aria-orientation");if(i==="vertical")return false;if(i==="horizontal")return true;let t=o.role;return t==="menubar"||t==="tablist"||t==="toolbar"}function rn(o){return i=>{let t=false,e=300,r=0,s="";function n(u){let h=yo(u.target);if(!h){a();return}let f=bo(u.target,h),m=Array.from(f).indexOf(u.target),b="ArrowDown",x="ArrowUp";if(yc(h)&&(i.document.dir==="rtl"?(b="ArrowLeft",x="ArrowRight"):(b="ArrowRight",x="ArrowLeft")),u.key===b)u.preventDefault(),Je(u.target,f[m+1]||f[0]);else if(u.key===x)u.preventDefault(),Je(u.target,f[m-1]||f[f.length-1]);else if(u.key==="Home")u.preventDefault(),Je(u.target,f[0]);else if(u.key==="End")u.preventDefault(),Je(u.target,f[f.length-1]);else if(u.key.length===1&&h.role!=="tablist"){let T=Date.now();T-r<=e?s+=u.key.toLowerCase():s=u.key.toLowerCase(),r=T;let C=Array.from(f).find(M=>M.textContent?.trim()?.toLowerCase()?.startsWith(s));C&&(u.preventDefault(),Je(u.target,C));}}function a(){t=false,i.removeEventListener("keydown",n);}function l(u){let h=yo(u.target);if(h){t||(t=true,i.addEventListener("keydown",n));let f=bo(u.target,h);for(let m of f)m!==u.target&&m.setAttribute("tabindex",-1);}else t&&a();}function c(u){(!u.relatedTarget||u.relatedTarget===i.document)&&a();}function d(u){let h=yo(u.target);if(h){let f=bo(u.target,h);for(let m of f)m!==u.target&&m.setAttribute("tabindex",-1);u.target.setAttribute("tabindex",0);}}return i.addEventListener("click",d),i.addEventListener("focusin",l),i.addEventListener("focusout",c),()=>{a(),i.removeEventListener("click",d),i.removeEventListener("focusin",l),i.removeEventListener("focusout",c);}}}function on(){return o=>{let i,t;function e(s){if(s.target.getAttribute("aria-hidden")==="true"){i=s.target,i.setAttribute("aria-hidden","false"),t=i.hidden,t&&(i.hidden=false);let n=s.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0);}}function r(s){i&&i.contains(s.target)&&(!s.relatedTarget||!i.contains(s.relatedTarget))&&(s.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),t&&(i.hidden=true),i=null);}return o.addEventListener("keyuxJump",e),o.addEventListener("focusout",r),()=>{o.removeEventListener("keyuxJump",e),o.removeEventListener("focusout",r);}}}function sn(){return o=>{let i=[];function t(l){let c=o.document.activeElement;c&&c!==o.document.body&&i.push(new WeakRef(c)),l.focus({focusVisible:true});}function e(){let l=i.pop();if(!l){o.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():e();}let r=0,s;function n(l){clearInterval(s);let c=l.getAttribute("aria-controls");s=setInterval(()=>{if(r++>50){clearInterval(s);return}let d=o.document.getElementById(c);if(d){let u=d.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');u&&(clearInterval(s),d.dispatchEvent(new o.CustomEvent("keyuxJump",{bubbles:true})),t(u));}},50);}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&e();}return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a);}}}function nn(o){let i,t=o.split(" "),e;function r(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(s(),a.target.classList.add(...t),i=a.target,e=a.target);}function s(){i&&i.classList.remove(...t),e=null;}function n(a){a.clientX===0&&a.clientY===0&&e!==a.target&&(s(),a.target.classList.add(...t),i=a.target);}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",r),a.addEventListener("keyup",s),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",r),a.removeEventListener("keyup",s);})}function an(o,i){let t=i.map(e=>e(o));return ()=>{t.forEach(e=>e());}}var wo=class{constructor(){this.Pe=new Map;this.kr=[];}addEventListener(i,t){let e=r=>{let s=r.target;s instanceof Node&&this.kr.some(n=>n===s||n.contains(s))&&t(r);};this.Pe.set(t,e),window.addEventListener(i,e);}removeEventListener(i,t){let e=this.Pe.get(t);e&&window.removeEventListener(i,e),this.Pe.delete(t);}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this.kr.push(i);}destroy(){this.kr=[];for(let i of this.Pe.values())window.removeEventListener("keydown",i),window.removeEventListener("keyup",i);this.Pe.clear();}},Bi=class{constructor(){this.fi=new wo,this.Cs=an(this.fi,[rn(),nn("is-pressed"),sn(),on()]);}registerBlock(i){this.fi.registerScope(i);}destroy(){this.Cs?.(),this.fi.destroy();}};var qt=o=>`*l10n/${o}`,bc="en",Hi=class{constructor(i){this.i=null;this.Or="";this.i=i;for(let[t,e]of Object.entries(Qe)){let r=this.i.has(qt(t))?!this.i.$[qt(t)]:true;this.i.add(qt(t),e,r);}setTimeout(()=>{i.subConfigValue("localeName",async t=>{if(!this.i||!t)return;this.Or=t;let e=await zs(t);if(t!==bc&&this.Or!==t)return;let r=this.i.cfg.localeDefinitionOverride?.[t];for(let[s,n]of Object.entries(e)){let a=r?.[s];this.i.add(qt(s),a??n,true);}}),i.subConfigValue("localeDefinitionOverride",t=>{if(!t)return;let e=t[this.Or];if(e)for(let[r,s]of Object.entries(e))this.i?.add(qt(r),s,true);});});}};function wc(o){return o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`).replace(/__/g,"_")}function Eo(o){return Array.isArray(o)?o.map(i=>typeof i=="object"&&i!==null?Eo(i):i):typeof o!="object"||o===null?o:Object.fromEntries(Object.entries(o).map(([i,t])=>{let e=wc(i);return typeof t=="object"&&t!==null?[e,Eo(t)]:[e,t]}))}function xc(o){return {ok:true,value:o}}function xo(o){return {ok:false,error:o}}var Ec="https://tlm.uploadcare.com/api/",To=class{constructor(i=Ec){this.baseUrl=i;}async base(i,t={}){let e=`${this.baseUrl}${i}`;try{let r=await fetch(e,t);if(!r.ok)return xo(new Error(`Got non-200 response from "${e}". Status: ${r.status.toString()}`));try{let s=await r.json();return xc(s)}catch(s){return xo(new Error(`Error parsing JSON from "${e}". Error: ${s}`))}}catch(r){return xo(new Error(`Error fetching data from "${e}". Error: ${r}`))}}async post(i,t,e={}){return await this.base(i,{...e,method:"POST",body:JSON.stringify(Eo(t)),headers:{"Content-Type":"application/json",...e.headers||{}}})}async get(i,t={}){return await this.base(i,{method:"GET",...t})}},Tc=async(o,i)=>({success:true,data:i}),ji=class extends To{constructor(){super();}async sendEvent(i,t){let e=await Tc(void 0,i);if(!e.success)throw console.error("TelemetryAPIService: events: body is invalid",e.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",i,t)}};var nt=o=>o?o.split(",").map(i=>i.trim()).filter(Boolean):[],Dt=o=>o.join(",");var ln=o=>{if(typeof o!="string"||!o)return "";let i=o.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},Ki=(...o)=>o.filter(i=>typeof i=="string"&&!!i).map(i=>ln(i)).join("/-/"),J=(...o)=>{let i=Ki(...o);return i?`-/${i}/`:""};function Gi(o){let i=new URL(o),t=i.pathname+i.search+i.hash,e=t.lastIndexOf("http"),r=t.lastIndexOf("/"),s="";return e>=0?s=t.slice(e):r>=0&&(s=t.slice(r+1)),s}function qi(o){let i=new URL(o),{pathname:t}=i,e=t.indexOf("/"),r=t.indexOf("/",e+1);return t.substring(e+1,r)}function Co(o){let i=cn(o),t=new URL(i),e=t.pathname.indexOf("/-/");return e===-1?"":t.pathname.substring(e).slice(1)}function Ao(o){return Co(o).split("/-/").filter(Boolean).map(t=>ln(t))}function cn(o){let i=new URL(o),t=Gi(o),e=un(t)?dn(t).pathname:t;return i.pathname=i.pathname.replace(e,""),i.search="",i.hash="",i.toString()}function un(o){return o.startsWith("http")}function dn(o){let i=new URL(o);return {pathname:`${i.origin}${i.pathname??""}`,search:i.search??"",hash:i.hash??""}}var K=(o,i,t)=>{let e=new URL(cn(o)),r=t??Gi(o),s=i??"";if(e.pathname.startsWith("//")&&(e.pathname=e.pathname.replace("//","/")),r&&un(r)){let n=dn(r);e.pathname=`${e.pathname}${s}${n.pathname||""}`,e.search=n.search,e.hash=n.hash;}else e.pathname=`${e.pathname}${s}${r||""}`;return e.toString()},Wt=(o,i)=>{let t=new URL(o);return t.pathname=`${i}/`,t.toString()};var G=(o,i=",")=>o.trim().split(i).map(t=>t.trim()).filter(t=>t.length>0);var ti=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:false,flip:false,crop:void 0}),hn=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Cc(o,i){if(typeof i=="number"){let t=i;return ti[o]!==t?`${o}/${t}`:""}if(typeof i=="boolean"){let t=i;return ti[o]!==t?`${o}`:""}if(o==="filter"&&i){let{name:t,amount:e}=i;return ti.filter===e?"":`${o}/${t}/${e}`}if(o==="crop"&&i){let{dimensions:t,coords:e}=i;return `${o}/${t.join("x")}/${e.join(",")}`}return ""}function Zt(o){return Ki(...hn.filter(i=>typeof o[i]<"u"&&o[i]!==null).map(i=>{let t=o[i];return Cc(i,t)}).filter(i=>!!i))}var Wi=Ki("format/auto","progressive/yes"),Vt=([o])=>typeof o<"u"?Number(o):void 0,pn=()=>true,Ac=([o,i])=>({name:o,amount:typeof i<"u"?Number(i):100}),Sc=([o,i])=>{if(!/\d+x\d+/.test(o)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return {dimensions:G(o,"x").map(Number),coords:G(i).map(Number)}},kc=Object.freeze({enhance:Vt,brightness:Vt,exposure:Vt,gamma:Vt,contrast:Vt,saturation:Vt,vibrance:Vt,warmth:Vt,filter:Ac,mirror:pn,flip:pn,rotate:Vt,crop:o=>{let[i,t]=o,{dimensions:e,coords:r}=Sc([i,t]);return {dimensions:e,coords:r}}});function So(o){let i={};for(let t of o){let[e,...r]=t.split("/");if(!e||!hn.includes(e))continue;let s=e,n=kc[s];try{let a=n(r);i[s]=a;}catch(a){console.warn([`Failed to parse URL operation "${t}". It will be ignored.`,a instanceof Error?`Error message: "${a.message}"`:a,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(` `));}}return i}var V=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),tt=Object.freeze([V.CROP,V.TUNING,V.FILTERS]),fn=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),mn=Object.freeze(["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"]),vn=Object.freeze(["rotate","mirror","flip"]),Ft=ti,wt=Object.freeze({brightness:{zero:Ft.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Ft.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Ft.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Ft.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Ft.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Ft.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Ft.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Ft.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Ft.filter,range:[0,100],keypointsNumber:1}});var ei="https://ucarecdn.com",Oc="https://upload.uploadcare.com",Ic="https://social.uploadcare.com",Mc="https://ucarecd.net",Lc={pubkey:"",multiple:true,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:false,imgOnly:false,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:false,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Dt(tt),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:false,useLocalImageEditor:false,useCloudImageEditor:true,removeCopyright:false,cropPreset:"",imageShrink:"",modalScrollLock:true,modalBackdropStrokes:false,sourceListWrap:true,remoteTabSessionKey:"",cdnCname:ei,cdnCnamePrefixed:Mc,baseUrl:Oc,socialBaseUrl:Ic,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:false,saveUrlForRecurrentUploads:false,groupOutput:false,userAgentIntegration:"",debug:false,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:true,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:false,cloudImageEditorAutoOpen:false,cloudImageEditorMaskHref:null,testMode:false,qualityInsights:true},at=Object.freeze(Lc);var $=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),O=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created"}),Zi=class{constructor(i){this.mi=new Map;this.Ir=new Set;this.v=null;this.v=i;}bindTarget(i){return this.Ir.add(i),()=>{this.Ir.delete(i);}}As(i,t){for(let e of this.Ir)e.dispatchEvent(new CustomEvent(i,{detail:t}));this.v?.(()=>{let e=t&&typeof t=="object"?{...t}:t;return [`event "${i}"`,e]});}emit(i,t,e={}){let{debounce:r}=e;if(typeof r!="number"&&!r){this.As(i,typeof t=="function"?t():t);return}this.mi.has(i)&&window.clearTimeout(this.mi.get(i));let s=typeof r=="number"?r:20,n=window.setTimeout(()=>{try{let a=typeof t=="function"?t():t;this.As(i,a),this.mi.delete(i);}catch(a){this.v?.(()=>`Error while getting payload for event "${i}"`,a);}},s);this.mi.set(i,n);}};var gn="1.25.0-alpha.4";var Xt="blocks",Qt=gn;var Xi=class{constructor(i){this.Xl=crypto.randomUUID();this.ce=structuredClone(at);this.Mr=false;this.Lr=null;this.m=i,this.Ss=new ji,this.ue=new jt(10);for(let t of Object.keys(this.ce))this.m.subConfigValue(t,e=>{this.Mr&&this.ce[t]!==e&&this.sendEvent({eventType:$.CHANGE_CONFIG}),this.Yl(t,e);});}Ql(i){i===$.INIT_SOLUTION&&!this.Mr&&(this.Mr=true);}Yl(i,t){this.ce[i]!==t&&(this.ce[i]=t);}Jl(i){let t=i.payload?{...i.payload}:{};t.activity&&(t.activity=void 0);let e={...i};return (i.eventType===$.INIT_SOLUTION||i.eventType===$.CHANGE_CONFIG)&&(e.config=this.ce),{...e,appVersion:Qt,appName:Xt,sessionId:this.Xl,component:this.tc,activity:this.ec,projectPubkey:this.ce.pubkey,userAgent:navigator.userAgent,eventType:e.eventType??"",eventTimestamp:this.ic,payload:{location:this.rc,...t}}}oc(i){return !!(i&&[O.CHANGE,O.COMMON_UPLOAD_PROGRESS,O.FILE_ADDED,O.FILE_REMOVED,O.FILE_UPLOAD_START,O.FILE_UPLOAD_PROGRESS,O.FILE_UPLOAD_SUCCESS,O.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let t=this.Jl({eventType:i.eventType,payload:i.payload,config:i.config});this.Ql(i.eventType),!(this.oc(i.eventType)||this.Lr&&this.ks(this.Lr,t))&&this.ue.add(async()=>{this.Lr=t,await this.Ss.sendEvent(t);});}sendEventError(i,t="unknown"){this.sendEvent({eventType:$.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${t}`,error:i.message}}});}sendEventCloudImageEditor(i,t,e={}){this.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{tabId:t,node:i.currentTarget?.tagName,event:i.type,...e}}});}ks(i,t){if(JSON.stringify(i)===JSON.stringify(t))return true;if(typeof i!="object"||typeof t!="object"||i==null||t==null)return false;let e=Object.keys(i),r=Object.keys(t);if(e.length!==r.length)return false;for(let s of e)if(!Object.hasOwn(t,s)||!this.ks(i[s],t[s]))return false;return true}get ic(){return Date.now()}get tc(){if(!this.m.has("*solution"))return null;let i=this.m.$["*solution"];return i?i.toLowerCase():null}get ec(){return this.m.has("*currentActivity")?this.m.$["*currentActivity"]??null:null}get rc(){return location.origin}};var Z=o=>`*cfg/${o}`;var yn=o=>{let i=new Intl.Locale(o),t="ltr",e=i.getTextInfo?.().direction;return e?t=e:i.textInfo?.direction&&(t=i.textInfo.direction),t};var Qi=(o,i)=>new Intl.PluralRules(o).select(i);var Rc=o=>o;var bn="plural:";function ii(o,i={},t={}){let{openToken:e="{{",closeToken:r="}}",transform:s=Rc}=t;for(let n in i){let a=i[n],l=a?.toString(),c=typeof l=="string"?s(l):String(l);o=o.replaceAll(e+n+r,c);}return o}function wn(o){let i=[],t=o.indexOf("{{");for(;t!==-1;){let e=o.indexOf("}}",t);if(e===-1)break;let r=o.substring(t+2,e);if(r.startsWith(bn)){let s=o.substring(t+2,e).replace(bn,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a});}t=o.indexOf("{{",e);}return i}var xn="--uploadcare-blocks-window-height",ri=class o{static{this.clientsRegistry=new Set;}static{this.flush=P(()=>{document.documentElement.style.setProperty(xn,`${window.innerHeight}px`);},100);}static registerClient(i){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(i);}static unregisterClient(i){o.clientsRegistry.delete(i),o.clientsRegistry.size===0&&o.detachTracker();}static attachTracker(){window.addEventListener("resize",o.flush,{passive:true,capture:true}),o.flush();}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:true}),document.documentElement.style.removeProperty(xn);}};var Pc=o=>o.tagName?.includes("-")??false,Yi=class{constructor(i){this.Kt=new Set;this.vi=new Map;this.Os=false;this.Gt=i,this.Gt.addController(this);}hostDisconnected(){this.gi?.(),this.gi=void 0,this.Kt.clear(),this.vi.clear();}hostUpdated(){if(!this.gi&&this.Gt.has(Z("testMode"))){let i=this.Gt.subConfigValue("testMode",t=>{this.Os=!!t,this.Is();});this.gi=i;}this.sc(),this.Is();}sc(){let i=this.Gt,t=i.renderRoot??i;if(!t)return;let e=this.Gt,r=e.tagName?.toLowerCase(),s=Array.from(t.querySelectorAll("[data-testid]")).filter(n=>!Pc(n));for(let n of s)if(!(r&&n.closest(r)!==e)&&!this.Kt.has(n)){let a=n.getAttribute("data-testid");if(!a)continue;this.Kt.add(n),this.vi.set(n,a);}for(let n of Array.from(this.Kt))(!n.isConnected||r&&n.closest(r)!==e)&&(this.Kt.delete(n),this.vi.delete(n));}Is(){if(!this.Kt.size)return;let i=this.Gt.testId||"";for(let t of this.Kt){let e=this.vi.get(t);e&&(this.Os?t.setAttribute("data-testid",`${i}--${e}`):t.removeAttribute("data-testid"));}}};var $c=Ae(Pi()(Ce(Li(ft)))),E=class extends $c{constructor(){super();this.yi=new Map;this.activityType=null;this.init$=mo();new Yi(this);}static{this.styleAttrs=[];}l10n(t,e={}){if(!t)return "";let r=this.$[qt(t)]||t,s=wn(r);for(let a of s)e[a.variable]=this.nc(a.pluralKey,Number(e[a.countVariable]));return ii(r,e)}nc(t,e){let r=this.l10n("locale-id")||"en",s=Qi(r,e);return this.l10n(`${t}__${s}`)}emit(t,e,r){let s=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;if(!s)return;s.emit(t,e,r);let n=typeof e=="function"?e():e;this.telemetryManager.sendEvent({eventType:t,payload:n??void 0});}hasBlockInCtx(t){for(let e of this.blocksRegistry)if(t(e))return true;return false}connectedCallback(){this.constructor.styleAttrs.forEach(e=>{this.setAttribute(e,"");}),super.connectedCallback(),ri.registerClient(this);}initCallback(){this.addSharedContextInstance("*blocksRegistry",()=>new Set,{persist:true}),this.addSharedContextInstance("*eventEmitter",()=>new Zi(this.debugPrint.bind(this)),{persist:true}),this.addSharedContextInstance("*localeManager",()=>new Hi(this)),this.addSharedContextInstance("*modalManager",()=>new $i(this)),this.addSharedContextInstance("*a11y",()=>new Bi,{persist:true}),this.addSharedContextInstance("*telemetryManager",()=>this.cfg.qualityInsights?new Xi(this):{sendEvent:()=>{},sendEventError:()=>{},sendEventCloudImageEditor:()=>{}}),this.sub(qt("locale-id"),t=>{let e=yn(t);this.style.direction=e==="ltr"?"":e,this.requestUpdate();}),this.subConfigValue("testMode",t=>{if(!t||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId);}),this.blocksRegistry.add(this);}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this.getSharedContextInstance("*modalManager",false)}get telemetryManager(){return this.getSharedContextInstance("*telemetryManager")}get localeManager(){return this.getSharedContextInstance("*localeManager")}get a11y(){return this.getSharedContextInstance("*a11y")}get blocksRegistry(){return this.getSharedContextInstance("*blocksRegistry")}get eventEmitter(){return this.getSharedContextInstance("*eventEmitter")}disconnectedCallback(){super.disconnectedCallback(),ri.unregisterClient(this);let t=this.blocksRegistry;t?.delete(this),this.Ms(),t?.size===0&&setTimeout(()=>{!this.isConnected||t?.size>0||this.destroyCtxCallback();},0);}destroyCtxCallback(){this.Ms(true),N.deleteCtx(this.ctxName);}addSharedContextInstance(t,e,{persist:r=false}={}){if(!this.yi.has(t)&&(!this.has(t)||!this.$[t])){let s=e();this.add(t,s,true),this.yi.set(t,{persist:r,instance:s});return}}Ms(t=false){for(let[e,r]of this.yi.entries()){let{persist:s,instance:n}=r;s&&!t||(n?.destroy?.(),this.pub(e,null),this.yi.delete(e));}}getSharedContextInstance(t,e=true){if(this.has(t)&&this.$[t])return this.$[t];if(!e)return this.$[t];throw new Error(`Unexpected error: context manager for key "${String(t)}" is not available`)}async proxyUrl(t){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(t,{uuid:qi(t),cdnUrlModifiers:Co(t),fileName:Gi(t)})}catch(e){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",e),this.telemetryManager.sendEventError(e,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),t}return this.cfg.secureDeliveryProxy?ii(this.cfg.secureDeliveryProxy,{previewUrl:t},{transform:e=>window.encodeURIComponent(e)}):t}get cfg(){if(!this.Ur){let t={};this.Ur=new Proxy(t,{set:(e,r,s)=>{if(typeof r!="string"||!(r in at))return false;let n=r,a=Z(n);return this.has(a)||this.add(a,at[n]),this.$[a]=s,true},get:(e,r)=>{let s=Z(r);return this.has(s)||this.add(s,at[r]),this.$[s]}});}return this.Ur}subConfigValue(t,e){let r=Z(t);return this.has(r)||this.add(r,at[t]),this.sub(r,e)}debugPrint(...t){if(!this.cfg.debug)return;let e=t;if(typeof t?.[0]=="function"){let r=t[0];e=r();}console.log(`[${this.ctxName}]`,...e);}};var oi=class extends E{constructor(){super(...arguments);this.name="";this.Rr="";this.Ls=null;}initCallback(){super.initCallback(),this.setAttribute("aria-hidden","true"),this.subConfigValue("iconHrefResolver",t=>{this.Ls=t,this.Us();});}willUpdate(t){super.willUpdate(t),t.has("name")&&this.Us();}Us(){if(!this.name){this.Rr="";return}let t=`#uc-icon-${this.name}`,e=this.Ls?.(this.name);this.Rr=e??t;}render(){return g` ${this.yield("",g`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use href=${this.Rr}></use></svg>`)} `}};p([w({type:String})],oi.prototype,"name",2),p([v()],oi.prototype,"Rr",2);var En=o=>[...new Set(o)];var fe="--uc-img-",ko="unresolved";var Oo=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),Io=3e3,Mo=5e3,Lo=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var Dc="https://ucarecdn.com",Me=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Dc},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Ji=class extends Ce(Ae(ft)){constructor(){super();this.de={};this.E=new Map;this.pe=null;this.bi=null;for(let t in Me){let e=Me[t];this.de[fe+t]=e?.default||"";}}createRenderRoot(){return this}$$(t){return this.de[fe+t]}set$$(t){for(let e in t){let r=fe+e,s=t[e];this.de[r]=s,this.q(r,s);}}sub$$(t,e){let r=fe+t;this.E.has(r)||this.E.set(r,new Set),this.E.get(r)?.add(e);let s=this.de[r];s!==null&&s!==""&&e(s);}q(t,e){this.E.has(t)&&this.E.get(t)?.forEach(r=>{e===null||e===""||r(e);});}analyticsParams(){return `-/@clib/${Xt}/${Qt}/uc-img/`}initAttributes(t){Array.from(this.attributes).forEach(e=>{let r=e;Me[r.name]||t.setAttribute(r.name,r.value);});}initIntersection(t,e){let r={root:null,rootMargin:"0px"};this.pe=new IntersectionObserver(s=>{s.forEach(n=>{n.isIntersecting&&(e(),this.pe?.unobserve(t));});},r),this.pe.observe(t),this.bi||(this.bi=new Set),this.bi.add(t);}connectedCallback(){super.connectedCallback(),this.ac();}ac(){for(let t in Me){let e=fe+t,r=this.getCssData(e,true);r!=null&&(this.de[e]=r);}}disconnectedCallback(){super.disconnectedCallback(),this.pe&&(this.bi?.forEach(t=>{this.pe?.unobserve(t);}),this.pe=null),this.E.clear();}static get observedAttributes(){return Object.keys(Me)}attributeChangedCallback(t,e,r){window.setTimeout(()=>{let s=fe+t;this.de[s]=r,this.q(s,r);});}};var Tn=o=>Object.entries(o).filter(([i,t])=>t!==void 0&&t!=="").map(([i,t])=>i==="cdn-operations"||i==="analytics"?t:`${i}/${t}`);var ir=class extends Ji{constructor(){super(...arguments);this.Ct=new Image;this.yt=new Image;}Rs(t){return !t.includes("//")&&!Oo&&(t=new URL(t,document.baseURI).href),t}wi(t){if(!t)return;let e=t,r=e.match(/\d+/)?.[0],s=e.match(/[a-zA-Z]+/)?.[0];if(!r||!s)return;let n=parseInt(r,10);return Number(n)>Mo&&this.Ps?Mo+s:Number(n)>Io&&!this.Ps?Io+s:t}cc(t,e){let r={format:this.Pr("format"),quality:this.Pr("quality"),resize:this.wi(t),blur:e,"cdn-operations":this.Pr("cdn-operations")??void 0,analytics:this.analyticsParams()};return J(...Tn(r))}Pr(t){let e=this.$$(t);if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e}et(t="",e=""){let r=this.$$("src");if(r.startsWith("data:")||r.startsWith("blob:"))return r;if(Oo&&r&&!r.includes("//"))return this.$e(r);let s=this.cc(t,e),n=this.$$("cdn-cname"),a=n;if(r.startsWith(String(n)))return K(r,s);let l=this.$$("uuid");if(a&&l)return this.$e(K(Wt(a,l),s));if(l)return this.$e(K(Wt(a,l),s));let c=this.$$("proxy-cname");if(c)return this.$e(K(c,s,this.Rs(r)));let d=this.$$("pubkey");if(d)return this.$e(K(`https://${d}.ucr.io/`,s,this.Rs(r)))}$e(t){let e=this.$$("secure-delivery-proxy");return e?ii(e,{previewUrl:t},{transform:r=>window.encodeURIComponent(r)}):t}he(t,e=1,r=true){let s=t.getBoundingClientRect(),n=e*Math.round(s.width),a=r?"":e*Math.round(s.height);return n||a?`${n||""}x${a||""}`:null}uc(t){let e=s=>{s.stopPropagation();let n=new Event(s.type,s);this.dispatchEvent(n);},r=["load","error"];for(let s of r)t.addEventListener(s,e);}get img(){return this.At||(this.$r({elNode:this.Ct}),this.appendChild(this.Ct)),this.Ct}get xi(){return this.At?{type:Lo.PREVIEW,img:this.yt}:{type:Lo.MAIN,img:this.img}}get At(){return this.$$("is-preview-blur")}get $s(){return this.$$("is-background-for")}get Ds(){let t=this.$$("breakpoints");if(t){let e=G(t);return En(e.map(r=>parseInt(r,10)))}else return null}get Ps(){return this.$$("format").toLowerCase()==="jpeg"}Vs(t){let e=new Set;e.add(`url("${this.et(this.he(t))}") 1x`),this.$$("hi-res-support")&&e.add(`url("${this.et(this.he(t,2))}") ${2}x`),this.$$("ultra-res-support")&&e.add(`url("${this.et(this.he(t,3))}") ${3}x`);let r=`image-set(${[...e].join(", ")})`;t.style.setProperty("background-image",r),t.style.setProperty("background-image",`-webkit-${r}`);}Fs(){let t=new Set;return this.Ds?this.Ds.forEach(e=>{t.add(`${this.et(`${e}x`)} ${this.wi(`${e}w`)}`),this.$$("hi-res-support")&&t.add(`${this.et(`${e*2}x`)} ${this.wi(`${e*2}w`)}`),this.$$("ultra-res-support")&&t.add(`${this.et(`${e*3}x`)} ${this.wi(`${e*3}w`)}`);}):(t.add(`${this.et(this.he(this.xi.img))} 1x`),this.$$("hi-res-support")&&t.add(`${this.et(this.he(this.xi.img,2))} 2x`),this.$$("ultra-res-support")&&t.add(`${this.et(this.he(this.xi.img,3))} 3x`)),[...t].join()}_s(){return this.et()}get Ns(){return this.et("100x","100")}dc(){let t=this.$s;[...document.querySelectorAll(t)].forEach(e=>{this.$$("intersection")?this.initIntersection(e,()=>{this.Vs(e);}):this.Vs(e);});}pc({elNode:t,src:e,srcset:r}){e&&(t.src=e),r&&(t.srcset=r);}$r({elNode:t}){this.uc(t),this.initAttributes(t);}Dr({src:t,srcset:e,elNode:r}){return new Promise((s,n)=>{this.$r({elNode:r}),r.setAttribute(ko,""),r.addEventListener("load",()=>{r.removeAttribute(ko),s(r);}),r.addEventListener("error",()=>{n(false);}),this.pc({elNode:r,src:t,srcset:e});})}async hc(){if(this.$$("intersection")){this.At&&(this.$r({elNode:this.yt}),this.appendChild(this.yt)),this.initIntersection(this.xi.img,async()=>{this.At&&(this.yt.src=this.Ns);try{await this.Dr({src:this._s(),srcset:this.Fs(),elNode:this.Ct}),this.At&&await this.yt.remove(),this.appendChild(this.Ct);}catch{this.At&&await this.yt?.remove(),this.appendChild(this.Ct);}});return}try{this.At&&(await this.Dr({src:this.Ns,elNode:this.yt}),this.appendChild(this.yt)),await this.Dr({src:this._s(),srcset:this.Fs(),elNode:this.Ct}),this.At&&await this.yt?.remove(),this.appendChild(this.Ct);}catch{this.At&&await this.yt?.remove(),this.appendChild(this.Ct);}}init(){this.$s?this.dc():this.hc();}};var Uo=class extends ir{connectedCallback(){super.connectedCallback(),this.sub$$("src",()=>{this.init();}),this.sub$$("uuid",()=>{this.init();}),this.sub$$("lazy",i=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=i?"lazy":"eager");});}};var{I:Vc}=Ps;var An=o=>o.strings===void 0,Cn=()=>document.createComment(""),Le=(o,i,t)=>{let e=o.Tt.parentNode,r=i===void 0?o.ne:i.Tt;if(t===void 0){let s=e.insertBefore(Cn(),r),n=e.insertBefore(Cn(),r);t=new Vc(s,n,o,o.options);}else {let s=t.ne.nextSibling,n=t.c,a=n!==o;if(a){let l;t.fc?.(o),t.c=o,t.li!==void 0&&(l=o.X)!==n.X&&t.li(l);}if(s!==r||a){let l=t.Tt;for(;l!==s;){let c=l.nextSibling;e.insertBefore(l,r),l=c;}}}return t},Yt=(o,i,t=o)=>(o.vt(i,t),o),Fc={},Sn=(o,i=Fc)=>o.r=i,kn=o=>o.r,rr=o=>{o.ae(),o.Tt.remove();};var At={ATTRIBUTE:1,CHILD:2},lt=o=>(...i)=>({mr:o,values:i}),mt=class{constructor(i){}get X(){return this.c.X}vr(i,t,e){this.Ei=i,this.c=t,this.mc=e;}Bl(i,t){return this.update(i,t)}update(i,t){return this.render(...t)}};var si=(o,i)=>{let t=o.mt;if(t===void 0)return false;for(let e of t)e.ds?.(i,false),si(e,i);return true},or=o=>{let i,t;do{if((i=o.c)===void 0)break;t=i.mt,t.delete(o),o=i;}while(t?.size===0)},On=o=>{for(let i;i=o.c;o=i){let t=i.mt;if(t===void 0)i.mt=t=new Set;else if(t.has(o))break;t.add(o),zc(i);}};function _c(o){this.mt!==void 0?(or(this),this.c=o,On(this)):this.c=o;}function Nc(o,i=false,t=0){let e=this.r,r=this.mt;if(r!==void 0&&r.size!==0)if(i)if(Array.isArray(e))for(let s=t;s<e.length;s++)si(e[s],false),or(e[s]);else e!=null&&(si(e,false),or(e));else si(this,o);}var zc=o=>{o.type==At.CHILD&&(o.li??=Nc,o.fc??=_c);},sr=class extends mt{constructor(){super(...arguments),this.mt=void 0;}vr(i,t,e){super.vr(i,t,e),On(this),this.isConnected=i.X;}ds(i,t=true){i!==this.isConnected&&(this.isConnected=i,i?this.reconnected?.():this.disconnected?.()),t&&(si(this,i),or(this));}setValue(i){if(An(this.Ei))this.Ei.vt(i,this);else {let t=[...this.Ei.r];t[this.mc]=i,this.Ei.vt(t,this,0);}}disconnected(){}reconnected(){}};var A=()=>new Po,Po=class{},Ro=new WeakMap,I=lt(class extends sr{render(o){return U}update(o,[i]){let t=i!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=i,this.ht=o.options?.host,this.rt(this.ct=o.element)),U}rt(o){if(this.isConnected||(o=void 0),typeof this.G=="function"){let i=this.ht??globalThis,t=Ro.get(i);t===void 0&&(t=new WeakMap,Ro.set(i,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,o),o!==void 0&&this.G.call(this.ht,o);}else this.G.value=o;}get lt(){return typeof this.G=="function"?Ro.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0);}reconnected(){this.rt(this.ct);}});var $o=null,Do=class extends E{constructor(){super(...arguments);this.qt=A();this.zs=()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="");};this.vc=()=>{this.zs();};this.gc=t=>{this.Vr=t.target;};this.yc=t=>{let e=t.target;e===this.qt.value&&e===this.Vr&&this.zs();};this.De=({id:t})=>{t===this.id?($o=t,this.show(),this.emit(O.MODAL_OPEN,{modalId:t},{debounce:true})):this.hide();};this.Ve=({id:t})=>{t===this.id&&(this.hide(),this.emit(O.MODAL_CLOSE,{modalId:t,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:true}));};this.Bs=t=>{this.hide(),$o===this.id&&this.emit(O.MODAL_CLOSE,{modalId:$o,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:true});};}static{this.styleAttrs=[...super.styleAttrs,"uc-modal"];}show(){let t=this.qt.value;typeof t.showModal=="function"?(this.setAttribute("aria-modal","true"),t.showModal()):t.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden");}hide(){let t=this.qt.value;typeof t.close=="function"?(this.setAttribute("aria-modal","false"),t.close()):t.removeAttribute("open");}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this),this.subConfigValue("modalBackdropStrokes",t=>{t?this.setAttribute("strokes",""):this.removeAttribute("strokes");}),this.modalManager?.subscribe(j.OPEN,this.De),this.modalManager?.subscribe(j.CLOSE,this.Ve),this.modalManager?.subscribe(j.CLOSE_ALL,this.Bs);}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this.Vr=void 0,this.modalManager?.unsubscribe(j.OPEN,this.De),this.modalManager?.unsubscribe(j.CLOSE,this.Ve),this.modalManager?.unsubscribe(j.CLOSE_ALL,this.Bs);}bc(t){this.qt={value:t},this.qt.value?.addEventListener("close",this.vc),this.qt.value?.addEventListener("mousedown",this.gc),this.qt.value?.addEventListener("mouseup",this.yc);}render(){return g`<dialog ${I(this.bc)}>${this.yield("")}</dialog>`}};var In=o=>typeof o!="number"?0:Math.floor(o/1e3),Mn=(o,{threshold:i})=>{let{secureExpire:t}=o,e=In(Date.now()),r=Number(t),s=In(i);return e+s>=r};var nr=class{constructor(i){this.fe=null;this.m=i;}v(...i){this.m.debugPrint("[secure-uploads]",...i);}async getSecureToken(){let{secureSignature:i,secureExpire:t,secureUploadsSignatureResolver:e}=this.m.cfg;if((i||t)&&e&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),e){if(!this.fe||Mn(this.fe,{threshold:this.m.cfg.secureUploadsExpireThreshold})){this.fe?this.v("Secure signature is expired. Resolving a new one..."):this.v("Secure signature is not set yet.");try{let r=await e();r?!r.secureSignature||!r.secureExpire?console.error("Secure signature resolver returned an invalid result:",r):(this.v("Secure signature resolved:",r),this.v("Secure signature will expire in",new Date(Number(r.secureExpire)*1e3).toISOString()),this.fe=r):(this.v("Secure signature resolver returned nothing."),this.fe=null);}catch(r){console.error("Secure signature resolving failed. Falling back to the previous one.",r),this.m.telemetryManager.sendEventError(r,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.");}}return this.fe}return i&&t?(this.v("Secure signature and expire are set. Using them...",{secureSignature:i,secureExpire:t}),{secureSignature:i,secureExpire:t}):null}};var Vo=(o,i)=>{if(o.failedCount>0)return {type:"SOME_FILES_HAS_ERRORS",message:i.l10n("some-files-were-not-uploaded")}};var Fo=(o,i)=>{let t=o.totalCount,e=i.cfg.multiple?i.cfg.multipleMin:0,r=i.cfg.multiple?i.cfg.multipleMax:1;if(e&&t<e)return {type:"TOO_FEW_FILES",message:i.l10n("files-count-limit-error-too-few",{min:e,max:r,total:t}),payload:{total:t,min:e,max:r}};if(r&&t>r)return {type:"TOO_MANY_FILES",message:i.l10n("files-count-limit-error-too-many",{min:e,max:r,total:t}),payload:{total:t,min:e,max:r}}};var Bc=()=>{let o=navigator.userAgent;return /Macintosh|Windows/.test(o)&&/Version\/[\d.]+.*Safari/.test(o)&&!/Chrome|Chromium|Edg|OPR/.test(o)},Hc=()=>"capture"in document.createElement("input"),jc=()=>({safariDesktop:Bc()}),Kc=()=>({htmlMediaCapture:Hc()}),Ln=jc(),me=Kc();var ni="image/*",_o="video/*",Gc=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],qc=()=>Ln.safariDesktop?[ni]:[ni,...Gc],ai=qc(),ar=o=>o?o.filter(i=>typeof i=="string").flatMap(i=>G(i)):[],No=(o,i)=>i.some(t=>{if(t.endsWith("*")){let e=t.replace("*","");return o.startsWith(e)}return o===t}),Un=(o,i)=>i.some(t=>t.startsWith(".")?o.toLowerCase().endsWith(t.toLowerCase()):false),Rn=o=>{let i=o?.type;return i?No(i,ai):false};var zo=(o,i)=>{let t=i.cfg.imgOnly,e=i.cfg.accept,r=ar([...t?ai:[],e]);if(!r.length)return;let s=o.mimeType,n=o.name;if(!s||!n)return;let a=No(s,r),l=Un(n,r);if(!a&&!l)return {type:"FORBIDDEN_FILE_TYPE",message:i.l10n("file-type-not-allowed"),payload:{entry:o}}};var Bo=(o,i)=>{let t=i.cfg.imgOnly,e=o.isImage;if(!(!t||e)&&!(!o.fileInfo&&o.externalUrl)&&!(!o.fileInfo&&!o.mimeType))return {type:"NOT_AN_IMAGE",message:i.l10n("images-only-accepted"),payload:{entry:o}}};var St=1e3,ve=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),li=o=>Math.ceil(o*100)/100,Pn=(o,i=ve.AUTO)=>{let t=i===ve.AUTO;if(i===ve.BYTE||t&&o<St**1){let r=Qi("en-US",o)==="one"?"byte":"bytes";return `${o} ${r}`}return i===ve.KB||t&&o<St**2?`${li(o/St**1)} KB`:i===ve.MB||t&&o<St**3?`${li(o/St**2)} MB`:i===ve.GB||t&&o<St**4?`${li(o/St**3)} GB`:i===ve.TB||t&&o<St**5?`${li(o/St**4)} TB`:`${li(o/St**5)} PB`};var Ho=(o,i)=>{let t=i.cfg.maxLocalFileSizeBytes,e=o.size;if(t&&e&&e>t)return {type:"FILE_SIZE_EXCEEDED",message:i.l10n("files-max-size-limit-error",{maxFileSize:Pn(t)}),payload:{entry:o}}};var jo=(o,i)=>{let{internalId:t}=o,r=i.S.read(t)?.getValue("uploadError");if(!r)return;if(r instanceof Y)return {type:"UPLOAD_ERROR",message:r.message,payload:{entry:o,error:r}};if(r instanceof Oe)return {type:"NETWORK_ERROR",message:r.message,payload:{entry:o,error:r}};let s=r instanceof Error?r:new Error("Unknown error",{cause:r});return {type:"UNKNOWN_ERROR",message:s.message,payload:{entry:o,error:s}}};var Ue={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},Wc=o=>typeof o=="function"?{runOn:"change",validator:o}:o,lr=class{constructor(i){this.wc=[Bo,zo,Ho,jo];this.xc=[Fo,Vo];this.ue=new jt(20);this.Ec=P(()=>{this.i.isConnected&&this.ue.run();},500);this.Ti=new Map;this.i=i,this.S=this.i.uploadCollection;let t=P(()=>{this.i.isConnected&&(this.runFileValidators("change"),this.runCollectionValidators());},0);this.i.subConfigValue("maxLocalFileSizeBytes",t),this.i.subConfigValue("multipleMin",t),this.i.subConfigValue("multipleMax",t),this.i.subConfigValue("multiple",t),this.i.subConfigValue("imgOnly",t),this.i.subConfigValue("accept",t),this.i.subConfigValue("validationConcurrency",e=>{this.ue.concurrency=e;});}runFileValidators(i,t){let e=t??this.S.items();for(let r of e){let s=this.S.read(r);s&&this.Tc(s,i);}}runCollectionValidators(){let i=this.i.api.getOutputCollectionState(),t=[];for(let e of [...this.xc,...this.i.cfg.collectionValidators])try{let r=e(i,this.i.api);if(!r)continue;r&&(t.push(this.Hs(r)),r.message||console.warn(Ue.MISSING_ERROR_MESSAGE));}catch(r){console.warn(Ue.COLLECTION_VALIDATION_FAILED,r);}this.i.$["*collectionErrors"]=t,t.length>0&&this.i.emit(O.COMMON_UPLOAD_FAILED,()=>this.i.api.getOutputCollectionState(),{debounce:true});}cleanupValidationForEntry(i){let t=this.Ti.get(i.uid);t&&(t.abortController?.abort(),this.Ti.delete(i.uid));}async Tc(i,t){let e=this.js(i),r=e.promise??Promise.resolve(),s=(async()=>{if(await r,!this.i.isConnected)return;let n=this.Cc(i,t);if(n.length===0)return;i.setMultipleValues({isQueuedForValidation:true,isValidationPending:true});let a=this.i.api.getOutputItem(i.uid),l=new AbortController;e.abortController=l;let c=this.i.cfg.validationTimeout,d=this.Ks(),u=new Set(n.map(m=>m.validator)),h=[];for(let m of d)if(!u.has(m.validator)){let b=e.lastErrorThrownByValidator.get(m.validator);b&&h.push(b);}let f=n.map(m=>async()=>{if(!this.i.isConnected)return;let b=setTimeout(()=>{e.skippedValidators.add(m.validator),l.abort(),console.warn(Ue.FILE_VALIDATION_TIMEOUT);},c);try{let x=await m.validator(a,this.i.api,{signal:l.signal});if(!x||l.signal.aborted){e.lastErrorThrownByValidator.set(m.validator,void 0);return}let T=this.Hs(x);e.lastErrorThrownByValidator.set(m.validator,T),h.push(T),x.message||console.warn(Ue.MISSING_ERROR_MESSAGE);}catch(x){l.signal.aborted||(e.skippedValidators.add(m.validator),console.warn(Ue.FILE_VALIDATION_FAILED,x),this.i.telemetryManager.sendEventError(x,`file validator. ${Ue.FILE_VALIDATION_FAILED}`));}finally{clearTimeout(b),m.runOn!=="change"&&e.skippedValidators.add(m.validator);}});if(this.Ec(),await this.ue.add(async()=>{i.setValue("isQueuedForValidation",false),await Promise.all(f.map(m=>m())).catch(()=>{});},{autoRun:false}),l.signal.aborted){i.setMultipleValues({isQueuedForValidation:false,isValidationPending:false});return}i.setMultipleValues({isValidationPending:false,isQueuedForValidation:false,errors:h});})();e.promise=s;try{await s;}finally{e.promise===s&&(e.promise=void 0);}}Hs(i){return {...i,type:i.type??"CUSTOM_ERROR"}}js(i){let t=this.Ti.get(i.uid);if(t)return t;let e={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this.Ti.set(i.uid,e),e}Ks(){return [...this.wc,...this.i.cfg.fileValidators].map(Wc)}Cc(i,t){let e=this.js(i);return this.Ks().filter(r=>!e.skippedValidators.has(r.validator)).filter(r=>r.runOn===t)}};var $n="[Typed State] Wrong property name: ",cr=class{constructor(i){this.Ut=Rt.generate(),this.Y=N.registerCtx(i,this.Ut);}get uid(){return this.Ut}setValue(i,t){if(!this.Y.has(i)){console.warn(`${$n}${String(i)}`);return}this.Y.read(i)!==t&&this.Y.pub(i,t);}setMultipleValues(i){for(let[t,e]of Object.entries(i))this.setValue(t,e);}getValue(i){return this.Y.has(i)||console.warn(`${$n}${String(i)}`),this.Y.read(i)}subscribe(i,t){return this.Y.sub(i,t)}remove(){N.deleteCtx(this.Ut);}};var ur=class{constructor(i){this.Wt=Object.create(null);this.Ci=new Set;this.Ai=new Set;this.Rt=new Set;this.Fr=new Set;this._r=new Set;this.Ws=i.initialValue,this.Ut=Rt.generate(),this.Y=N.registerCtx({},this.Ut),this.Gs=i.watchList||[];let t=Object.create(null);this.qs=(e,r)=>{this.Nr&&window.clearTimeout(this.Nr),t[e]||(t[e]=new Set),t[e].add(r),this.Nr=window.setTimeout(()=>{Object.keys(t).length!==0&&(this.Ci.forEach(s=>{s({...t});}),t=Object.create(null));});},i.handler&&this.observeCollection(i.handler);}q(){this.zr&&window.clearTimeout(this.zr),this.zr=window.setTimeout(()=>{let i=new Set(this._r),t=new Set(this.Fr);this._r.clear(),this.Fr.clear();for(let e of this.Ai)e?.([...this.Rt],i,t);});}observeCollection(i){return this.Ai.add(i),this.Rt.size>0&&this.q(),()=>{this.unobserveCollection(i);}}unobserveCollection(i){this.Ai.delete(i);}add(i){let t=new cr(this.Ws);for(let[e,r]of Object.entries(i))t.setValue(e,r);return this.Rt.add(t.uid),this.q(),this.Y.add(t.uid,t),this._r.add(t),this.Gs.forEach(e=>{this.Wt[t.uid]||(this.Wt[t.uid]=[]),this.Wt[t.uid]?.push(t.subscribe(e,()=>{this.qs(e,t.uid);}));}),t.uid}read(i){return this.Y.read(i)}readProp(i,t){let e=this.read(i);if(!e)throw new Error(`TypedCollection#readProp: Item with id ${i} not found`);return e.getValue(t)}publishProp(i,t,e){let r=this.read(i);if(!r)throw new Error(`TypedCollection#publishProp: Item with id ${i} not found`);r.setValue(t,e);}remove(i){let t=this.read(i);t&&this.Fr.add(t),this.Rt.delete(i),this.q(),this.Y.pub(i,void 0),delete this.Wt[i];}clearAll(){this.Rt.forEach(i=>{this.remove(i);});}observeProperties(i){return this.Ci.add(i),()=>{this.unobserveProperties(i);}}unobserveProperties(i){this.Ci.delete(i);}findItems(i){let t=[];return this.Rt.forEach(e=>{let r=this.read(e);r&&i(r)&&t.push(e);}),t}items(){return [...this.Rt]}get size(){return this.Rt.size}destroy(){N.deleteCtx(this.Ut),this.Ci=new Set,this.Ai=new Set;for(let i of Object.keys(this.Wt))this.Wt[i]?.forEach(t=>{t.remove();}),delete this.Wt[i];}};var S=Object.freeze({PHOTO:"photo",VIDEO:"video"}),vt=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Ko=o=>({isVideoRecordingEnabled:nt(o.cameraModes).includes(S.VIDEO),isPhotoEnabled:nt(o.cameraModes).includes(S.PHOTO)});var Dn="active",Re="___ACTIVITY_IS_ACTIVE___",Vn,y=class o extends(Vn=E,Vn){constructor(){super(...arguments);this.historyTracked=false;this.init$=vo(this);this.Ac=P(this.Sc.bind(this),10);}Zs(){let t=o.Fe.get(this);this[Re]=false,this.removeAttribute(Dn),t?.deactivateCallback?.();}kc(){let t=o.Fe.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[Re]=true,this.setAttribute(Dn,""),t?.activateCallback?.(),this.Ac(),this.emit(O.ACTIVITY_CHANGE,{activity:this.activityType});}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",t=>{try{this.activityType!==t&&this[Re]?this.Zs():this.activityType===t&&!this[Re]&&this.kc();}catch(e){this.telemetryManager.sendEventError(e,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,e),this.$["*currentActivity"]=this.$["*history"][this.$["*history"].length-1]??null;}t||(this.$["*history"]=[]);}));}Sc(){let t=this.$["*history"];t&&(t.length>10&&(t=t.slice(t.length-11,t.length-1)),this.historyTracked&&t[t.length-1]!==this.activityType&&t.push(this.activityType),this.$["*history"]=t);}Oc(){return !!this.activityType&&o.Fe.has(this)}static{this.Fe=new Map;}get isActivityActive(){return !!this[Re]}get couldOpenActivity(){return true}registerActivity(t,e={}){let{onActivate:r,onDeactivate:s}=e;o.Fe.set(this,{activateCallback:r,deactivateCallback:s});}Ic(){this.isActivityActive&&this.Zs(),o.Fe.delete(this);}disconnectedCallback(){super.disconnectedCallback(),this.Oc()&&this.Ic();let t=this.$["*currentActivity"];this.blocksRegistry&&([...this.blocksRegistry].find(r=>r instanceof o&&r.activityType===t)||(this.$["*currentActivity"]=null,this.modalManager?.closeAll()));}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")??null}get doneActivity(){return this.getCssData("--cfg-done-activity")??null}historyBack(){let t=this.$["*history"];if(t){let e=t.pop();for(;e===this.activityType;)e=t.pop();let r=!!e;e&&(r=[...this.blocksRegistry].find(n=>n.activityType===e)?.couldOpenActivity??false),e=r?e:void 0,e&&this.modalManager?.open(e),this.$["*currentActivity"]=e??null,this.$["*history"]=t,e||this.modalManager?.closeAll();}}};y.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});function dr(o,i){for(let t in i)t.includes("-")?o.style.setProperty(t,String(i[t])):o.style[t]=String(i[t]);}var Zc=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,Xc=new RegExp(`^/?(${Zc.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),Fn=({url:o,cdnBase:i})=>{let t=new URL(i),e=new URL(ei),r=new URL(o);if(t.host!==r.host&&e.host!==r.host)return null;let s=Xc.exec(r.pathname);if(!s)return null;let[,n,a,l]=s;return n?{uuid:n,cdnUrlModifiers:a||"",filename:l||null}:null};var kt=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Go=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),z=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Go,...kt});function _n(o){let i=new Map;return (...e)=>{let r=JSON.stringify(e);if(i.has(r))return i.get(r);let s=o(...e);return i.set(r,s),s}}var Nn=new Set;function pr(o){Nn.has(o)||(Nn.add(o),console.warn(o));}function Qc(o){let i=false;return setTimeout(()=>{i=true;},0),e=>((...r)=>(i&&pr(o),e(...r)))}function zn(o){let i={},t={progress:()=>o.$["*commonProgress"],errors:()=>o.$["*collectionErrors"],group:()=>o.$["*groupInfo"],totalCount:()=>o.uploadCollection.size,failedCount:()=>i.failedEntries.length,successCount:()=>i.successEntries.length,uploadingCount:()=>i.uploadingEntries.length,status:()=>i.isFailed?"failed":i.isUploading?"uploading":i.isSuccess?"success":"idle",isSuccess:()=>i.allEntries.length>0&&i.errors.length===0&&i.successEntries.length===i.allEntries.length,isUploading:()=>i.allEntries.some(r=>r.status==="uploading"),isFailed:()=>i.errors.length>0||i.failedEntries.length>0,allEntries:()=>o.getOutputData(),successEntries:()=>i.allEntries.filter(r=>r.status==="success"),failedEntries:()=>i.allEntries.filter(r=>r.status==="failed"),uploadingEntries:()=>i.allEntries.filter(r=>r.status==="uploading"),idleEntries:()=>i.allEntries.filter(r=>r.status==="idle")},e=Qc("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it 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}`");for(let[r,s]of Object.entries(t)){let n=r,l=_n(e(s));Object.defineProperty(i,n,{get:l,enumerable:true});}return i}var hr=class{constructor(i){this.addFileFromUrl=(i,{silent:t,fileName:e,source:r}={})=>{let s=this.S.add({externalUrl:i,fileName:e??null,silent:t??false,source:r??z.API});return this.getOutputItem(s)};this.addFileFromUuid=(i,{silent:t,fileName:e,source:r}={})=>{let s=this.S.add({uuid:i,fileName:e??null,silent:t??false,source:r??z.API});return this.getOutputItem(s)};this.addFileFromCdnUrl=(i,{silent:t,fileName:e,source:r}={})=>{let s=Fn({url:i,cdnBase:this.cfg.cdnCname});if(!s)throw new Error("Invalid CDN URL");let n=this.S.add({uuid:s.uuid,cdnUrl:i,cdnUrlModifiers:s.cdnUrlModifiers,fileName:e??s.filename??null,silent:t??false,source:r??z.API});return this.getOutputItem(n)};this.addFileFromObject=(i,{silent:t,fileName:e,source:r,fullPath:s}={})=>{let n=this.S.add({file:i,isImage:Rn(i),mimeType:i.type,fileName:e??i.name,fileSize:i.size,silent:t??false,source:r??z.API,fullPath:s??null});return this.getOutputItem(n)};this.removeFileByInternalId=i=>{if(!this.S.read(i))throw new Error(`File with internalId ${i} not found`);this.S.remove(i);};this.uploadAll=()=>{let i=this.S.items().filter(t=>{let e=this.S.read(t);return e?!e.getValue("isRemoved")&&!e.getValue("isUploading")&&!e.getValue("fileInfo")&&e.getValue("errors").length===0&&!e.getValue("isValidationPending")&&!e.getValue("isQueuedForValidation"):false});i.length!==0&&(this.e.$["*uploadTrigger"]=new Set(i),this.e.emit(O.COMMON_UPLOAD_START,this.getOutputCollectionState()));};this.openSystemDialog=(i={})=>{let t=Dt(ar([this.cfg.accept??"",...this.cfg.imgOnly?ai:[]])),e="uploadcare-file-input",r=document.createElement("input");if(r.setAttribute(e,""),dr(r,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),r.type="file",r.multiple=this.cfg.multiple,i.captureCamera){r.capture=this.cfg.cameraCapture;let{isPhotoEnabled:s,isVideoRecordingEnabled:n}=Ko(this.cfg);i.modeCamera===S.PHOTO&&s?r.accept=ni:i.modeCamera===S.VIDEO&&n?r.accept=_o:r.accept=[ni,n&&_o].filter(Boolean).join(",");}else r.accept=t;r.addEventListener("change",()=>{r.files&&([...r.files].forEach(s=>{this.addFileFromObject(s,{source:i.captureCamera?z.CAMERA:z.LOCAL});}),this.e.modalManager?.open(y.activities.UPLOAD_LIST),this.e.$["*currentActivity"]=y.activities.UPLOAD_LIST,r.remove());},{once:true}),document.querySelectorAll(`[${e}]`).forEach(s=>{s.remove();}),document.body.appendChild(r),r.dispatchEvent(new MouseEvent("click"));};this.initFlow=(i=false)=>{if(this.S.size>0&&!i)this.e.modalManager?.open(y.activities.UPLOAD_LIST),this.e.pub("*currentActivity",y.activities.UPLOAD_LIST);else if(this.Xs?.length===1){let t=this.Xs[0];if(t==="local"){this.e.$["*currentActivity"]=y.activities.UPLOAD_LIST,this.openSystemDialog();return}if(t==="camera"&&me.htmlMediaCapture){let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=Ko(this.cfg);if(n&&a){this.e.pub("*currentActivity",y.activities.START_FROM);return}else if(n||a){this.openSystemDialog({captureCamera:true,modeCamera:n?S.PHOTO:S.VIDEO});return}else this.openSystemDialog({captureCamera:true,modeCamera:S.PHOTO});}let e=this.e.blocksRegistry,r=n=>"type"in n&&n.type===t;[...e].find(r)?.activate(),this.e.$["*currentActivity"]&&this.e.modalManager?.open(this.e.$["*currentActivity"]);}else this.e.modalManager?.open(y.activities.START_FROM),this.e.pub("*currentActivity",y.activities.START_FROM);};this.doneFlow=()=>{this.e.set$({"*currentActivity":this.e.doneActivity,"*history":this.e.doneActivity?[this.e.doneActivity]:[]}),this.e.$["*currentActivity"]||this.e.modalManager?.closeAll();};this.setCurrentActivity=(i,...t)=>{if(this.e.hasBlockInCtx(e=>e.activityType===i)){this.e.set$({"*currentActivityParams":t[0]??{},"*currentActivity":i});return}console.warn(`Activity type "${i}" not found in the context`);};this.getCurrentActivity=()=>this.e.$["*currentActivity"];this.setModalState=i=>{if(i&&!this.e.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}i?this.e.modalManager?.open(this.e.$["*currentActivity"]):(this.e.modalManager?.close(this.e.$["*currentActivity"]),this.e.$["*currentActivity"]=null);};this.e=i;}get S(){return this.e.uploadCollection}get cfg(){return this.e.cfg}get l10n(){return this.e.l10n.bind(this.e)}removeAllFiles(){this.S.clearAll();}getOutputItem(i){let t=N.getCtx(i);if(!t)throw new Error(`UploaderPublicApi#getOutputItem: Entry with ID "${i}" not found in the upload collection`);let e=t.store,r=e.fileInfo,s=e.isRemoved?"removed":e.errors.length>0?"failed":e.fileInfo?"success":e.isUploading?"uploading":"idle";return {uuid:r?.uuid??e.uuid??null,internalId:i,name:r?.originalFilename??e.fileName,size:r?.size??e.fileSize,isImage:r?.isImage??e.isImage,mimeType:r?.mimeType??e.mimeType,file:e.file,externalUrl:e.externalUrl,cdnUrlModifiers:e.cdnUrlModifiers,cdnUrl:e.cdnUrl??r?.cdnUrl??null,fullPath:e.fullPath,uploadProgress:e.uploadProgress,fileInfo:r??null,metadata:e.metadata??r?.metadata??null,isSuccess:s==="success",isUploading:s==="uploading",isFailed:s==="failed",isRemoved:s==="removed",isValidationPending:e.isValidationPending,errors:e.errors,status:s,source:e?.source}}getOutputCollectionState(){return zn(this.e)}get Xs(){let i=[];return this.cfg.sourceList&&(i=G(this.cfg.sourceList)),i}};var Bn={file:null,externalUrl:null,fileName:null,fileSize:null,lastModified:Date.now(),uploadProgress:0,uuid:null,isImage:false,mimeType:null,ctxName:null,cdnUrl:null,cdnUrlModifiers:null,fileInfo:null,isUploading:false,abortController:null,thumbUrl:null,silent:false,source:null,fullPath:null,metadata:null,errors:[],uploadError:null,isRemoved:false,isQueuedForUploading:false,isValidationPending:false,isQueuedForValidation:false};var ci=33.333333333333336,k=1,qo=24,Hn=6;function Jt(o,i){for(let[t,e]of Object.entries(i))o.setAttributeNS(null,t,e.toString());}function ct(o,i={}){let t=document.createElementNS("http://www.w3.org/2000/svg",o);return Jt(t,i),t}function jn(o,i,t){let{x:e,y:r,width:s,height:n}=o,a=i.includes("w")?0:1,l=i.includes("n")?0:1,c=a===0?-1:1,d=l===0?-1:1,u=[e+a*s+1.5*c,r+l*n+1.5*d-24*t*d],h=[e+a*s+1.5*c,r+l*n+1.5*d],f=[e+a*s-24*t*c+1.5*c,r+l*n+1.5*d],m=`M ${u[0]} ${u[1]} L ${h[0]} ${h[1]} L ${f[0]} ${f[1]}`,b=[h[0],h[1]];return {d:m,center:b}}function Kn(o,i,t){let{x:e,y:r,width:s,height:n}=o,a=i==="n"||i==="s",l=i==="w"||i==="e",c=a?.5:i==="w"?0:1,d=l?.5:i==="n"?0:1,u=i==="w"?-1:i==="e"?1:0,h=i==="n"?-1:i==="s"?1:0,f,m;a?(f=[e+c*s-34*t/2,r+d*n+1.5*h],m=[e+c*s+34*t/2,r+d*n+1.5*h]):(f=[e+c*s+1.5*u,r+d*n-34*t/2],m=[e+c*s+1.5*u,r+d*n+34*t/2]);let b=`M ${f[0]} ${f[1]} L ${m[0]} ${m[1]}`,x=[(f[0]+m[0])/2,(f[1]+m[1])/2];return {d:b,center:x}}function Gn(o){return o===""?"move":["e","w"].includes(o)?"ew-resize":["n","s"].includes(o)?"ns-resize":["nw","se"].includes(o)?"nwse-resize":"nesw-resize"}function qn({rect:o,delta:[i,t],imageBox:e}){return $e({...o,x:o.x+i,y:o.y+t},e)}function $e(o,i){let{x:t}=o,{y:e}=o;return o.x<i.x?t=i.x:o.x+o.width>i.x+i.width&&(t=i.x+i.width-o.width),o.y<i.y?e=i.y:o.y+o.height>i.y+i.height&&(e=i.y+i.height-o.height),{...o,x:t,y:e}}function Yc({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[,r]=i,{y:s,width:n,height:a}=o;s+=r,a-=r,t&&(n=a*t);let l=o.x+o.width/2-n/2;return s<=e.y&&(s=e.y,a=o.y+o.height-s,t&&(n=a*t,l=o.x+o.width/2-n/2)),l<=e.x&&(l=e.x,s=o.y+o.height-a),l+n>=e.x+e.width&&(l=Math.max(e.x,e.x+e.width-n),n=e.x+e.width-l,t&&(a=n/t),s=o.y+o.height-a),a<k&&(a=k,t&&(n=a*t,l=o.x+o.width/2-n/2),s=o.y+o.height-a),n<k&&(n=k,t&&(a=n/t,l=o.x+o.width/2-n/2),s=o.y+o.height-a),{x:l,y:s,width:n,height:a}}function Jc({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[r]=i,{x:s,width:n,height:a}=o;s+=r,n-=r,t&&(a=n/t);let l=o.y+o.height/2-a/2;return s<=e.x&&(s=e.x,n=o.x+o.width-s,t&&(a=n/t,l=o.y+o.height/2-a/2)),l<=e.y&&(l=e.y,s=o.x+o.width-n),l+a>=e.y+e.height&&(l=Math.max(e.y,e.y+e.height-a),a=e.y+e.height-l,t&&(n=a*t),s=o.x+o.width-n),a<k&&(a=k,t&&(n=a*t),l=o.y+o.height/2-a/2,s=o.x+o.width-n),n<k&&(n=k,t&&(a=n/t),l=o.y+o.height/2-a/2,s=o.x+o.width-n),{x:s,y:l,width:n,height:a}}function tu({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[,r]=i,{y:s,width:n,height:a}=o;a+=r,t&&(n=a*t);let l=o.x+o.width/2-n/2;return s+a>=e.y+e.height&&(a=e.y+e.height-s,t&&(n=a*t),l=o.x+o.width/2-n/2),l<=e.x&&(l=e.x,s=o.y),l+n>=e.x+e.width&&(l=Math.max(e.x,e.x+e.width-n),n=e.x+e.width-l,t&&(a=n/t),s=o.y),a<k&&(a=k,t&&(n=a*t),l=o.x+o.width/2-n/2),n<k&&(n=k,t&&(a=n/t),l=o.x+o.width/2-n/2),{x:l,y:s,width:n,height:a}}function eu({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[r]=i,{x:s,width:n,height:a}=o;n+=r,t&&(a=n/t);let l=o.y+o.height/2-a/2;return s+n>=e.x+e.width&&(n=e.x+e.width-s,t&&(a=n/t),l=o.y+o.height/2-a/2),l<=e.y&&(l=e.y,s=o.x),l+a>=e.y+e.height&&(l=Math.max(e.y,e.y+e.height-a),a=e.y+e.height-l,t&&(n=a*t),s=o.x),a<k&&(a=k,t&&(n=a*t),l=o.y+o.height/2-a/2),n<k&&(n=k,t&&(a=n/t),l=o.y+o.height/2-a/2),{x:s,y:l,width:n,height:a}}function iu({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[r,s]=i,{x:n,y:a,width:l,height:c}=o;return n+r<e.x&&(r=e.x-n),a+s<e.y&&(s=e.y-a),n+=r,l-=r,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=e.y&&(c=c-(e.y-a),l=c*t,n=o.x+o.width-l,a=e.y)):t&&(r=c*t-l,l=l+r,n-=r,n<=e.x&&(l=l-(e.x-n),c=l/t,n=e.x,a=o.y+o.height-c)),c<k&&(c=k,t&&(l=c*t),n=o.x+o.width-l,a=o.y+o.height-c),l<k&&(l=k,t&&(c=l/t),n=o.x+o.width-l,a=o.y+o.height-c),{x:n,y:a,width:l,height:c}}function ru({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[r,s]=i,{x:n,y:a,width:l,height:c}=o;return n+l+r>e.x+e.width&&(r=e.x+e.width-n-l),a+s<e.y&&(s=e.y-a),l+=r,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=e.y&&(c=c-(e.y-a),l=c*t,n=o.x,a=e.y)):t&&(r=c*t-l,l+=r,n+l>=e.x+e.width&&(l=e.x+e.width-n,c=l/t,n=e.x+e.width-l,a=o.y+o.height-c)),c<k&&(c=k,t&&(l=c*t),a=o.y+o.height-c),l<k&&(l=k,t&&(c=l/t),a=o.y+o.height-c),{x:n,y:a,width:l,height:c}}function ou({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[r,s]=i,{x:n,y:a,width:l,height:c}=o;return n+r<e.x&&(r=e.x-n),a+c+s>e.y+e.height&&(s=e.y+e.height-a-c),n+=r,l-=r,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=e.y+e.height&&(c=e.y+e.height-a,l=c*t,n=o.x+o.width-l,a=e.y+e.height-c)):t&&(r=c*t-l,l+=r,n-=r,n<=e.x&&(l=l-(e.x-n),c=l/t,n=e.x,a=o.y)),c<k&&(c=k,t&&(l=c*t),n=o.x+o.width-l),l<k&&(l=k,t&&(c=l/t),n=o.x+o.width-l),{x:n,y:a,width:l,height:c}}function su({rect:o,delta:i,aspectRatio:t,imageBox:e}){let[r,s]=i,{x:n,y:a,width:l,height:c}=o;return n+l+r>e.x+e.width&&(r=e.x+e.width-n-l),a+c+s>e.y+e.height&&(s=e.y+e.height-a-c),l+=r,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=e.y+e.height&&(c=e.y+e.height-a,l=c*t,n=o.x,a=e.y+e.height-c)):t&&(r=c*t-l,l+=r,n+l>=e.x+e.width&&(l=e.x+e.width-n,c=l/t,n=e.x+e.width-l,a=o.y)),c<k&&(c=k,t&&(l=c*t)),l<k&&(l=k,t&&(c=l/t)),{x:n,y:a,width:l,height:c}}function Wn({direction:o,...i}){switch(o){case "n":return Yc(i);case "w":return Jc(i);case "s":return tu(i);case "e":return eu(i);case "nw":return iu(i);case "ne":return ru(i);case "sw":return ou(i);case "se":return su(i);default:return i.rect}}function Zn(o,[i,t]){return o.x<=i&&i<=o.x+o.width&&o.y<=t&&t<=o.y+o.height}function Xn(o,i){return o.x>=i.x&&o.y>=i.y&&o.x+o.width<=i.x+i.width&&o.y+o.height<=i.y+i.height}function Qn(o,i){return Math.abs(o.width/o.height-i)<.1}function De({width:o,height:i},t){let e=t/90%2!==0;return {width:e?i:o,height:e?o:i}}function Yn(o,i,t){let e=o/i,r,s;e>t?(r=Math.round(i*t),s=i):(r=o,s=Math.round(o/t));let n=Math.round((o-r)/2),a=Math.round((i-s)/2);return n+r>o&&(r=o-n),a+s>i&&(s=i-a),{x:n,y:a,width:r,height:s}}function Ve(o){return {x:Math.round(o.x),y:Math.round(o.y),width:Math.round(o.width),height:Math.round(o.height)}}function te(o,i,t){return Math.min(Math.max(o,i),t)}var ui=["free"],mr=o=>{let i=G(o);if(!i||i.length===0)return [];let t=[];for(let e of i){let r=e.trim();if(!r)continue;let s=r.indexOf(":");if(s===-1&&!ui.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}let n=Number(r.slice(0,s)),a=Number(r.slice(s+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!ui.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}t.push({id:Rt.generate(),type:"aspect-ratio",width:ui.includes(r)?0:n,height:ui.includes(r)?0:a,hasFreeform:ui.includes(r)});}return t},Jn=(o,i,t,e=.1)=>{let r=o/i,s=null,n=1/0;for(let a of t){let[l,c]=[a.width,a.height],d=l/c,u=Math.abs(r-d);u<n&&(n=u,s=a);}if(s){let[a,l]=[s.width,s.height],c=a/l;if(Math.abs(r-c)/c>e)return null}return s};function ta(o){return lo({...o,libraryName:Xt,libraryVersion:Qt})}var R=class o extends y{constructor(){super(...arguments);this.couldBeCtxOwner=false;this.Si=false;this.init$=go(this);this.jr=P(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let e=this.api.getOutputCollectionState();this.$["*collectionState"]=e,this.emit(O.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.cfg.groupOutput&&e.totalCount>0&&e.status==="success"&&this.Pc(e);},300);this.Uc=(t,e,r)=>{if(this.isConnected){(e.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...e].map(s=>s.uid));for(let s of e)s.getValue("silent")||this.emit(O.FILE_ADDED,this.api.getOutputItem(s.uid));this.validationManager.runCollectionValidators();for(let s of r){this.$["*uploadTrigger"].delete(s.uid),this.validationManager.cleanupValidationForEntry(s),s.getValue("abortController")?.abort(),s.setMultipleValues({isRemoved:true,abortController:null,isUploading:false,uploadProgress:0});let n=s?.getValue("thumbUrl");n&&URL.revokeObjectURL(n),this.emit(O.FILE_REMOVED,this.api.getOutputItem(s.uid));}this.$["*uploadList"]=t.map(s=>({uid:s})),this.Js(),this.jr();}};this.Rc=t=>{if(!this.isConnected)return;this.jr();let e=this.uploadCollection,r=[...new Set(Object.entries(t).filter(([s])=>["uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(s)).flatMap(([,s])=>[...s]))];if(r.length>0&&setTimeout(()=>{if(!this.isConnected)return;let s=r.filter(n=>t.fileInfo?.has(n)&&!!N.getCtx(n)?.store.fileInfo);s.length>0&&this.validationManager.runFileValidators("upload",s),this.validationManager.runFileValidators("change",r);}),t.uploadProgress){for(let s of t.uploadProgress){let n=N.getCtx(s);if(!n)continue;let{isUploading:a,silent:l}=n.store;a&&!l&&this.emit(O.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(s));}this.Js();}if(t.isUploading)for(let s of t.isUploading){let n=N.getCtx(s);if(!n)continue;let{isUploading:a,silent:l}=n.store;a&&!l&&this.emit(O.FILE_UPLOAD_START,this.api.getOutputItem(s));}if(t.fileInfo){for(let s of t.fileInfo){let n=N.getCtx(s);if(!n)continue;let{fileInfo:a,silent:l}=n.store;a&&!l&&this.emit(O.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(s));}this.cfg.cropPreset&&this.$c(),this.cfg.cloudImageEditorAutoOpen&&this.Dc();}if(t.errors){this.validationManager.runCollectionValidators();for(let a of t.errors){let l=N.getCtx(a);if(!l)continue;let{errors:c}=l.store;c.length>0&&(this.emit(O.FILE_UPLOAD_FAILED,this.api.getOutputItem(a)),this.emit(O.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:true}));}let s=e.findItems(a=>!!a.getValue("fileInfo")),n=e.findItems(a=>a.getValue("errors").length>0);e.size>0&&n.length===0&&e.size===s.length&&this.$["*collectionErrors"].length===0&&this.emit(O.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState());}t.cdnUrl&&([...t.cdnUrl].filter(n=>!!this.uploadCollection.read(n)?.getValue("cdnUrl")).forEach(n=>{this.emit(O.FILE_URL_CHANGED,this.api.getOutputItem(n));}),this.$["*groupInfo"]=null);};this.Js=()=>{let t=0,r=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));r.forEach(n=>{let a=this.uploadCollection.readProp(n,"uploadProgress");typeof a=="number"&&(t+=a);});let s=r.length?Math.round(t/r.length):0;this.$["*commonProgress"]!==s&&(this.$["*commonProgress"]=s,this.emit(O.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()));};}get Mc(){return this.hasBlockInCtx(t=>t instanceof o?t.Si&&t.isConnected&&t!==this:false)}initCallback(){super.initCallback(),this.addSharedContextInstance("*uploadCollection",()=>new ur({initialValue:Bn,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]}),{persist:true}),this.addSharedContextInstance("*secureUploadsManager",()=>new nr(this)),this.addSharedContextInstance("*validationManager",()=>new lr(this)),this.addSharedContextInstance("*publicApi",()=>new hr(this)),!this.Mc&&this.couldBeCtxOwner&&this.Lc();}get validationManager(){return this.getSharedContextInstance("*validationManager")}get api(){return this.getSharedContextInstance("*publicApi")}getAPI(){return this.api}get uploadCollection(){return this.getSharedContextInstance("*uploadCollection")}get secureUploadsManager(){return this.getSharedContextInstance("*secureUploadsManager")}disconnectedCallback(){super.disconnectedCallback(),this.Si&&this.Ys(),this.jr.cancel();}connectedCallback(){super.connectedCallback(),this.Si&&this.Qs();}Lc(){this.Si=true,this.Qs(),this.subConfigValue("maxConcurrentRequests",t=>{this.$["*uploadQueue"].concurrency=Number(t)||1;});}Qs(){this.Ys(),this.Br=this.uploadCollection.observeCollection(this.Uc),this.Hr=this.uploadCollection.observeProperties(this.Rc);}Ys(){this.Hr?.(),this.Br?.(),this.Hr=void 0,this.Br=void 0;}async Pc(t){let e=await this.getUploadClientOptions(),r=t.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),s=new AbortController,n=await tn(r,{...e,signal:s.signal});if(this.$["*collectionState"]!==t){s.abort();return}this.$["*groupInfo"]=n;let a=this.api.getOutputCollectionState();this.emit(O.GROUP_CREATED,a),this.emit(O.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.$["*collectionState"]=a;}Dc(){let[t]=this.uploadCollection.findItems(e=>!!e.getValue("fileInfo")&&e.getValue("isImage")).map(e=>this.uploadCollection.read(e));t&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(e=>e.activityType===y.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:t.uid},this.$["*currentActivity"]=y.activities.CLOUD_IMG_EDIT,this.modalManager?.open(y.activities.CLOUD_IMG_EDIT));}$c(){let t=mr(this.cfg.cropPreset);if(t){let[e]=t,r=this.uploadCollection.findItems(s=>!!s.getValue("fileInfo")&&s.getValue("isImage")&&!s.getValue("cdnUrlModifiers")?.includes("/crop/")).map(s=>this.uploadCollection.read(s)).filter(Boolean);for(let s of r){let n=s.getValue("fileInfo");if(!n||!n.imageInfo){console.warn("Failed to get image info for entry",s.uid);continue}let{width:a,height:l}=n.imageInfo,c=typeof e?.width=="number"&&typeof e?.height=="number"&&e.width>0&&e.height>0?e.width/e.height:1,d=Yn(a,l,c),u=J(`crop/${d.width}x${d.height}/${d.x},${d.y}`,"preview"),h=s.getValue("cdnUrl");if(!h){console.warn("Failed to get cdnUrl for entry",s.uid);continue}s.setMultipleValues({cdnUrlModifiers:u,cdnUrl:K(h,u)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(f=>f.activityType===y.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:s.uid},this.$["*currentActivity"]=y.activities.CLOUD_IMG_EDIT,this.modalManager?.open(y.activities.CLOUD_IMG_EDIT));}}}async getMetadataFor(t){let e=this.cfg.metadata||void 0;if(typeof e=="function"){let r=this.api.getOutputItem(t);return await e(r)}return e}async getUploadClientOptions(){let t=await this.secureUploadsManager.getSecureToken().catch(()=>null);return {store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:ta,integration:this.cfg.userAgentIntegration,secureSignature:t?.secureSignature,secureExpire:t?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return this.uploadCollection.items().map(r=>this.api.getOutputItem(r))}};R.extSrcList=Object.freeze({...kt});R.sourceTypes=Object.freeze({...z});var Wo=class extends R{constructor(){super(...arguments);this.z=null;this.ki=null;}tn(){let t=document.createElement("input");return t.type="text",t.name=this.ctxName,t.required=this.cfg.multipleMin>0,t.tabIndex=-1,dr(t,{opacity:0,height:0,width:0}),t}initCallback(){super.initCallback(),this.z=this.tn(),this.appendChild(this.z),this.sub("*collectionState",t=>{if(!t)return;if(!this.ki){let n=document.createElement("div");this.appendChild(n),this.ki=n;}if(!this.z){let n=this.tn();this.appendChild(n),this.z=n;}if(this.ki.innerHTML="",t.status==="uploading"||t.status==="idle"){this.z.value="",this.z.setCustomValidity("");return}if(t.status==="failed"){let n=t.errors[0]?.message;this.z.value="",this.z.setCustomValidity(n??"");return}let e=t.group?t.group:null;if(e){this.z.value=e.cdnUrl??"",this.z.setCustomValidity("");return}let r=t.allEntries.map(n=>n.cdnUrl).filter(n=>typeof n=="string");if(!this.cfg.multiple&&r.length===1&&r[0]){this.z.value=r[0],this.z.setCustomValidity("");return}this.z.remove(),this.z=null;let s=new DocumentFragment;for(let n of r){let a=document.createElement("input");a.type="hidden",a.name=`${this.ctxName}[]`,a.value=n,s.appendChild(a);}this.ki.replaceChildren(s);},false);}};var Zo=class extends E{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i);});}render(){return g`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`}};var di=class extends E{constructor(){super(...arguments);this.value=0;this.visible=true;this.ot=0;this.Oi=A();this.en=()=>{let t=this.Oi.value;if(t){if(!this.visible){t.classList.add("uc-fake-progress--hidden");return}this.ot>0&&t.classList.add("uc-fake-progress--hidden");}};}firstUpdated(t){super.firstUpdated(t),this.ot=this.Kr(this.value),this.Gr(),this.Oi.value?.addEventListener("animationiteration",this.en);}updated(t){if(super.updated(t),t.has("value")){let e=this.Kr(this.value);if(!this.visible)this.ot=e;else {let r=Math.max(this.ot,e);r!==this.ot&&(this.ot=r,this.Gr());}}t.has("visible")&&(this.classList.toggle("uc-progress-bar--hidden",!this.visible),this.visible?this.Gr():this.ot=this.Kr(this.value));}disconnectedCallback(){super.disconnectedCallback(),this.Oi.value?.removeEventListener("animationiteration",this.en);}Kr(t){return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}Gr(){this.visible&&this.style.setProperty("--l-progress-value",this.ot.toString());}render(){return g`<div ${I(this.Oi)} class="uc-fake-progress"></div><div class="uc-progress"></div>`}};p([w({type:Number})],di.prototype,"value",2),p([w({type:Boolean,reflect:true})],di.prototype,"visible",2);var pi=class extends R{constructor(){super();this.bt=false;this.me=0;this.init$={...this.init$,"*commonProgress":0};}initCallback(){super.initCallback(),this.qr=this.uploadCollection.observeProperties(()=>{let t=this.uploadCollection.items().some(e=>this.uploadCollection.read(e)?.getValue("isUploading")??false);this.bt=t;}),this.sub("*commonProgress",t=>{this.me=t;});}updated(t){super.updated(t),t.has("visible")&&(this.bt?this.setAttribute("active",""):this.removeAttribute("active"));}disconnectedCallback(){super.disconnectedCallback(),this.qr?.(),this.qr=void 0;}render(){return g`<uc-progress-bar .value=${this.me} .visible=${this.bt}></uc-progress-bar>`}};p([v()],pi.prototype,"bt",2),p([v()],pi.prototype,"me",2);var Fe=class extends E{constructor(){super(...arguments);this.value="";this.disabled=false;this.options=[];this.Vc=t=>{if(this.disabled){t.preventDefault(),t.stopPropagation();return}t.preventDefault(),t.stopPropagation();let e=t.currentTarget;e&&(this.value=e.value,this.dispatchEvent(new Event("change")));};}render(){return g`<select @change=${this.Vc} .value=${this.value} ?disabled=${this.disabled}>${this.options.map(t=>g`<option value=${t.value}>${t.text}</option>`)}</select>`}};p([w({type:String,attribute:false})],Fe.prototype,"value",2),p([w({type:Boolean,reflect:true})],Fe.prototype,"disabled",2),p([w({type:Array,attribute:false})],Fe.prototype,"options",2);var nu="src-type-",_e=class extends R{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.Wr={};this.Zr="default";this.Xr="";}Fc(){this.ve({type:z.LOCAL,activate:()=>(this.api.openSystemDialog(),false)}),this.ve({type:z.URL,activity:y.activities.URL,textKey:"from-url"}),this.ve({type:z.CAMERA,activity:y.activities.CAMERA,activate:()=>{let t=me.htmlMediaCapture;return t&&this.api.openSystemDialog({captureCamera:true}),!t}}),this.ve({type:"draw",activity:y.activities.DRAW,icon:"edit-draw"});for(let t of Object.values(Go))this.ve({type:t,activity:y.activities.CAMERA,activate:()=>{let e=me.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:true,modeCamera:t==="mobile-photo-camera"?S.PHOTO:S.VIDEO}),!e}});for(let t of Object.values(kt))this.ve({type:t,activity:y.activities.EXTERNAL,activityParams:{externalSourceType:t}});}initCallback(){super.initCallback(),this.Fc(),this.type&&this.rn(this.type);}ve(t){this.Wr[t.type]=t;}activate(){if(!this.type)return;let t=this.Wr[this.type];if(!t)return;let{activity:e,activate:r,activityParams:s={}}=t;(r?r():e)&&e&&(this.modalManager?.open(e),this.set$({"*currentActivityParams":s,"*currentActivity":e}));}rn(t){let e=this.Wr[t];if(!e){console.warn(`Unsupported source type: ${t}`);return}let{textKey:r=t,icon:s=t}=e;this.Xr=`${nu}${r}`,this.Zr=s;}willUpdate(t){super.willUpdate(t),t.has("type")&&(this.type?this.rn(this.type):(this.Xr="",this.Zr="default"));}render(){return g`<button type="button" @click=${this.activate}><uc-icon name=${this.Zr}></uc-icon><div class="uc-txt">${this.l10n(this.Xr)}</div></button>`}};p([w({type:String})],_e.prototype,"type",2),p([v()],_e.prototype,"Zr",2),p([v()],_e.prototype,"Xr",2);var vr=class extends E{constructor(){super(...arguments);this.sn=[];this.W=[];this.an=[];}initCallback(){super.initCallback(),this.subConfigValue("sourceList",t=>{this.sn=G(t),this.nn();}),this.subConfigValue("cameraModes",t=>{this.W=nt(t),this.nn();});}updated(t){super.updated(t),this.cfg.sourceListWrap?this.style.removeProperty("display"):this.style.display="contents";}nn(){let t=[];for(let e of this.sn){if(e==="instagram"){console.error("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");continue}if(e==="camera"&&me.htmlMediaCapture){let r=this.W.length?this.W.map(s=>`mobile-${s}-camera`):["mobile-photo-camera"];t.push(...r);continue}t.push(e);}this.an=t;}render(){return g`${this.an.map(t=>g`<uc-source-btn role="listitem" type=${t}></uc-source-btn>`)}`}};p([v()],vr.prototype,"an",2);var Xo=class extends E{render(){return g`<div class="uc-spinner"></div>`}};var ee="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function ge(o){let i=new Image;return {promise:new Promise((r,s)=>{i.src=o,i.onload=()=>r(),i.onerror=n=>s(n);}),image:i,cancel:()=>{i.naturalWidth===0&&(i.src=ee);}}}function hi(o){let i=[];for(let s of o){let n=ge(s);i.push(n);}let t=i.map(s=>s.image);return {promise:Promise.allSettled(i.map(s=>s.promise)),images:t,cancel:()=>{i.forEach(s=>{s.cancel();});}}}function Qo(o,i=40){if(o.type==="image/svg+xml")return URL.createObjectURL(o);let t=document.createElement("canvas"),e=t.getContext("2d");if(!e)return Promise.reject(new Error("Canvas context not supported"));let r=new Image,s=new Promise((n,a)=>{r.onload=()=>{let l=r.height/r.width;l>1?(t.width=i,t.height=i*l):(t.height=i,t.width=i/l),e.fillStyle="rgb(240, 240, 240)",e.fillRect(0,0,t.width,t.height),e.drawImage(r,0,0,t.width,t.height),t.toBlob(c=>{if(!c){a();return}let d=URL.createObjectURL(c);n(d);});},r.onerror=l=>{a(l);};});return r.src=URL.createObjectURL(o),s}var Ne=class extends R{constructor(){super(...arguments);this.Ii=new Set;this.entry=null;}withEntry(t){return (...e)=>{let r=this.entry;if(!r){console.warn("No entry found");return}return t(r,...e)}}subEntry(t,e){this.withEntry((r,s,n)=>{let a=r.subscribe(s,l=>{this.isConnected&&n(l);});this.Ii.add(a);})(t,e);}reset(){for(let t of this.Ii)t.remove();this.Ii=new Set,this.entry=null;}disconnectedCallback(){super.disconnectedCallback(),this.Ii=new Set;}};function au(o){let i=new Blob([o],{type:"image/svg+xml"});return URL.createObjectURL(i)}function gr(o="hsl(209, 21%, 65%)",i=32,t=32){return au(`<svg width="${i}" height="${t}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${o}" 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"/></svg>`)}var lu=3e3,ze=class extends Ne{constructor(){super(...arguments);this.badgeIcon="";this.uid="";this.Pt="";this.ln=false;this.Mi=null;this.cn=false;this._c=this.cfg.filesViewMode;this.un=this.withEntry(async(t,e=false)=>{let r=t.getValue("fileInfo"),s=t.getValue("isImage"),n=t.getValue("uuid"),a=t.getValue("thumbUrl"),l=this.Nc(e);if(r&&s&&n){let d=await this.proxyUrl(K(Wt(this.cfg.cdnCname,n),J(t.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${l}x${l}/center`)));if(a===d)return;let{promise:u}=ge(d);u.then(()=>{t.setValue("thumbUrl",d),a?.startsWith("blob:")&&URL.revokeObjectURL(a);}).catch(async()=>{if(!a?.startsWith("blob:"))try{let h=t.getValue("file");if(!h)return;let f=await Qo(h,l);t.setValue("thumbUrl",f);}catch(h){this.telemetryManager.sendEventError(h,"thumbnail generation. Failed to generate thumb from file");let f=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");t.setValue("thumbUrl",gr(f));}});return}if(t.getValue("thumbUrl"))return;let c=t.getValue("file");if(c?.type.includes("image"))try{let d=await Qo(c,l);t.setValue("thumbUrl",d);}catch(d){this.telemetryManager.sendEventError(d,"thumbnail generation. Failed to generate thumb from file");let u=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");t.setValue("thumbUrl",gr(u));}else {let d=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");t.setValue("thumbUrl",gr(d));}});this.Li=P(this.un.bind(this),100);}Nc(t=false){t&&(this.Mi=this.getBoundingClientRect());let e=Math.max(parseInt(String(this?.Mi?.height||0),10),parseInt(String(this?.Mi?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(e*=window.devicePixelRatio),Math.min(e,lu)}zc(t,e){return new Promise((r,s)=>{let n=new Image;n.decoding="async";let a=()=>{n.src="",e?.removeEventListener("abort",l);},l=()=>{a(),s(new DOMException("Aborted","AbortError"));};if(e){if(e.aborted){l();return}e.addEventListener("abort",l,{once:true});}let c=()=>{a(),r();},d=u=>{a(),s(u);};if(typeof n.decode=="function"){n.src=t,n.decode().then(c).catch(d);return}n.onload=c,n.onerror=d,n.src=t;})}Qr(){this.Yr?.cancel(),this.Yr=void 0;}Bc(t){if(this.Qr(),!t){this.Pt&&(this.Pt="");return}if(t===this.Pt)return;let e=new AbortController,r={controller:e,cancel:()=>{e.abort(),r.rafId!==void 0&&window.cancelAnimationFrame(r.rafId);}};this.Yr=r,this.zc(t,e.signal).catch(()=>{}).then(()=>{e.signal.aborted||(r.rafId=window.requestAnimationFrame(()=>{e.signal.aborted||(this.Pt=t);}));});}Ui(t=false){if(this.entry){if(t){this.un(true);return}this.cn&&this.Li();}}firstUpdated(t){super.firstUpdated(t),this.dn();}updated(t){super.updated(t),t.has("uid")&&this.dn();}_e(t){let[e]=t;e&&(this.cn=e.isIntersecting,e.isIntersecting&&(this.Mi=e.boundingClientRect,this.Ui(),this.s?.disconnect()),e.intersectionRatio===0&&this.Li.cancel());}reset(){super.reset(),this.Li.cancel(),this.Qr(),this.Pt&&(this.Pt="");}dn(){let t=this.uid?.trim();if(!t){this.entry&&this.reset();return}let e=this.uploadCollection?.read(t);if(!e||e===this.entry)return;this.reset(),this.entry=e;let r=()=>{this.Ui();};this.subEntry("fileInfo",s=>{s?.isImage&&r();}),this.subEntry("thumbUrl",s=>{this.Bc(s??void 0);}),this.subEntry("cdnUrlModifiers",r),this.Ui(true);}initCallback(){super.initCallback(),this.subConfigValue("filesViewMode",t=>{t==="grid"&&!this.ln&&(this._c==="list"&&this.Ui(true),this.ln=true);}),this.setAttribute("role","img");}connectedCallback(){super.connectedCallback(),this.s?.disconnect(),this.s=new window.IntersectionObserver(this._e.bind(this),{threshold:.1}),this.s.observe(this);}disconnectedCallback(){super.disconnectedCallback(),this.Li.cancel(),this.Qr(),this.s?.disconnect();}render(){return g`<div class="uc-thumb"><img class="uc-thumb__img" src=${this.Pt||""} alt="" ?hidden=${!this.Pt} draggable="false" /><div class="uc-badge"><uc-icon name=${this.badgeIcon}></uc-icon></div></div>`}};p([w({type:String})],ze.prototype,"badgeIcon",2),p([w({type:String})],ze.prototype,"uid",2),p([v()],ze.prototype,"Pt",2);var Yo=class extends y{};var Jo=class extends y{constructor(){super(...arguments);this.historyTracked=true;this.activityType=y.activities.START_FROM;}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"");}render(){return g`<div class="uc-content">${this.yield("")}</div>`}};var ts=class extends R{constructor(){super(...arguments);this.pn=null;}static{this.styleAttrs=["uc-wgt-common"];}static{this.EventType=O;}initCallback(){super.initCallback(),this.pn=this.eventEmitter.bindTarget(this);}disconnectedCallback(){super.disconnectedCallback(),this.pn?.();}};var Be=(o,i)=>{let t=false,e,r=0,s=((...n)=>{t?(e&&clearTimeout(e),e=setTimeout(()=>{Date.now()-r>=i&&(o(...n),r=Date.now());},Math.max(i-(Date.now()-r),0))):(o(...n),r=Date.now(),t=true);});return Object.defineProperty(s,"cancel",{configurable:false,writable:false,enumerable:false,value:()=>{e&&clearTimeout(e);}}),s};var ea=(o,i,t)=>{let e=new Map;for(let r=i;r<=t;r++)e.set(o[r],r);return e},ia=lt(class extends mt{constructor(o){if(super(o),o.type!==At.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,i,t){let e;t===void 0?t=i:i!==void 0&&(e=i);let r=[],s=[],n=0;for(let a of o)r[n]=e?e(a,n):n,s[n]=t(a,n),n++;return {values:s,keys:r}}render(o,i,t){return this.dt(o,i,t).values}update(o,[i,t,e]){let r=kn(o),{values:s,keys:n}=this.dt(i,t,e);if(!Array.isArray(r))return this.ut=n,s;let a=this.ut??=[],l=[],c,d,u=0,h=r.length-1,f=0,m=s.length-1;for(;u<=h&&f<=m;)if(r[u]===null)u++;else if(r[h]===null)h--;else if(a[u]===n[f])l[f]=Yt(r[u],s[f]),u++,f++;else if(a[h]===n[m])l[m]=Yt(r[h],s[m]),h--,m--;else if(a[u]===n[m])l[m]=Yt(r[u],s[m]),Le(o,l[m+1],r[u]),u++,m--;else if(a[h]===n[f])l[f]=Yt(r[h],s[f]),Le(o,r[u],r[h]),h--,f++;else if(c===void 0&&(c=ea(n,f,m),d=ea(a,u,h)),c.has(a[u]))if(c.has(a[h])){let b=d.get(n[f]),x=b!==void 0?r[b]:null;if(x===null){let T=Le(o,r[u]);Yt(T,s[f]),l[f]=T;}else l[f]=Yt(x,s[f]),Le(o,r[u],x),r[b]=null;f++;}else rr(r[h]),h--;else rr(r[u]),u++;for(;f<=m;){let b=Le(o,l[m+1]);Yt(b,s[f]),l[f++]=b;}for(;u<=h;){let b=r[u++];b!==null&&rr(b);}return this.ut=n,Sn(o,l),Q}});var xt=class extends R{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.historyTracked=true;this.activityType=y.activities.UPLOAD_LIST;this.hn=false;this.mn=false;this.vn=false;this.Jr=false;this.to=false;this.Ri=null;this.gn=false;this.eo=null;this.yn=()=>{this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(true);};this.io=()=>{this.emit(O.UPLOAD_CLICK),this.api.uploadAll(),this.St();};this.ro=()=>{this.emit(O.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow();};this.kt=()=>{this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll();};this.St=Be(()=>{this.isConnected&&(this.Kc(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll());},300);}get Hc(){return this.eo?this.jc(this.eo):""}Kc(){let t=this.api.getOutputCollectionState(),e={total:t.totalCount,succeed:t.successCount,uploading:t.uploadingCount,failed:t.failedCount,validatingBeforeUploading:t.idleEntries.filter(f=>f.isValidationPending).length},r=!t.errors.some(f=>f.type==="TOO_MANY_FILES"||f.type==="TOO_FEW_FILES"),s=t.errors.some(f=>f.type==="TOO_MANY_FILES"),n=t.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),a=t.allEntries.some(f=>f.isValidationPending),l=e.failed===0&&t.errors.length===0&&!a,c=false,d=false,u=false;if(e.total-e.succeed-e.uploading-e.failed>0&&r&&l)c=true;else {d=true;let f=this.cfg.groupOutput?!!t.group:true;u=e.total===e.succeed&&r&&l&&f;}this.hn=d,this.mn=u,this.vn=c,this.to=e.total===0||!s&&!n,this.Jr=!n||this.cfg.multiple,this.gn=e.total>0,this.eo=e;}jc(t){let e=r=>{let s=t[r];return r==="uploading"&&(s+=t.validatingBeforeUploading),this.l10n(`header-${r}`,{count:s})};return t.uploading>0||t.validatingBeforeUploading>0?e("uploading"):t.failed>0?e("failed"):t.succeed>0?e("succeed"):e("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this.St),this.subConfigValue("multipleMin",this.St),this.subConfigValue("multipleMax",this.St),this.sub("*groupInfo",t=>{t&&this.St();}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t);}),this.sub("*currentActivity",t=>{!this.couldOpenActivity&&t===this.activityType&&(this.$["*currentActivity"]=this.initActivity);}),this.uploadCollection.observeProperties(this.St),this.uploadCollection.observeCollection(this.St),this.sub("*collectionErrors",t=>{let e=t.filter(r=>r.type!=="SOME_FILES_HAS_ERRORS")[0];if(!e){this.Ri=null;return}this.Ri=e.message;});}disconnectedCallback(){super.disconnectedCallback(),this.has("*uploadCollection")&&(this.uploadCollection.unobserveProperties(this.St),this.uploadCollection.unobserveCollection(this.St));}render(){return g`<uc-activity-header><span aria-live="polite" class="uc-header-text">${this.Hc}</span><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" ?hidden=${this.gn}>${this.yield("empty",g`<span>${this.l10n("no-files")}</span>`)}</div><div class="uc-files"><div class="uc-files-wrapper">${ia(this.$["*uploadList"]??[],({uid:t})=>t,({uid:t})=>g`<uc-file-item .uid=${t}></uc-file-item>`)}</div><button type="button" class="uc-add-more-btn uc-secondary-btn" @click=${this.yn} ?disabled=${!this.to} ?hidden=${!this.Jr} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button></div><div class="uc-common-error" ?hidden=${!this.Ri} >${this.Ri??""}</div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this.kt}>${this.l10n("clear")}</button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" ?hidden=${!this.Jr} ?disabled=${!this.to} @click=${this.yn} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button><button type="button" class="uc-upload-btn uc-primary-btn" ?hidden=${!this.vn} @click=${this.io} >${this.l10n("upload")}</button><button type="button" class="uc-done-btn uc-primary-btn" ?hidden=${!this.hn} ?disabled=${!this.mn} @click=${this.ro} >${this.l10n("done")}</button></div><uc-drop-area ghost></uc-drop-area>`}};p([v()],xt.prototype,"hn",2),p([v()],xt.prototype,"mn",2),p([v()],xt.prototype,"vn",2),p([v()],xt.prototype,"Jr",2),p([v()],xt.prototype,"to",2),p([v()],xt.prototype,"Ri",2),p([v()],xt.prototype,"gn",2),p([v()],xt.prototype,"eo",2);var yr=class extends R{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.activityType=y.activities.URL;this.oo={importDisabled:true};this.$t=A();this.so=t=>{let e=t.target?.value??"";this.oo={importDisabled:!e};};this.io=t=>{t.preventDefault(),this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let r=this.$t.value?.value?.trim();r&&(this.api.addFileFromUrl(r,{source:z.URL}),this.modalManager?.open(y.activities.UPLOAD_LIST),this.$["*currentActivity"]=y.activities.UPLOAD_LIST);};}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"",{onActivate:()=>{let t=this.$t.value;t&&(t.value="",t.focus()),this.oo={importDisabled:true};}});}render(){return g`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.historyBack} title=${this.l10n("back")} aria-label=${this.l10n("back")}><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span>${this.l10n("caption-from-url")}</span></div><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content" @submit=${this.io}><label><input ${I(this.$t)} placeholder="https://" class="uc-url-input" type="text" @input=${this.so} /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" ?disabled=${this.oo.importDisabled} >${this.l10n("upload-url")}</button></form>`}};p([v()],yr.prototype,"oo",2);var ra=()=>typeof navigator.permissions<"u";var oa="important",cu=" !"+oa,ye=lt(class extends mt{constructor(o){if(super(o),o.type!==At.ATTRIBUTE||o.name!=="style"||o.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce(((i,t)=>{let e=o[t];return e==null?i:i+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${e};`}),"")}update(o,[i]){let{style:t}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(i)),this.render(i);for(let e of this.ft)i[e]==null&&(this.ft.delete(e),e.includes("-")?t.removeProperty(e):t[e]=null);for(let e in i){let r=i[e];if(r!=null){this.ft.add(e);let s=typeof r=="string"&&r.endsWith(cu);e.includes("-")||s?t.setProperty(e,s?r.slice(0,-11):r,s?oa:""):t[e]=r;}}return Q}});var uu={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},du=["camera","microphone"];function br(o){let i=Math.floor(o/60).toString().padStart(2,"0"),t=Math.floor(o%60).toString().padStart(2,"0");return `${i}:${t}`}var sa="image/jpeg",na="video/webm",F=class extends R{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.activityType=y.activities.CAMERA;this.Pi=null;this.ao=false;this.Ne=[];this.wt=null;this.xt=null;this.$i=null;this.Di=null;this.g=null;this.ze={};this.Et=null;this.e=null;this.ge=[];this.ye=[];this.Gc={};this.Vi=[];this.Fi=null;this.bn=()=>{this.wn(),this.Be="pause";};this.xn=()=>{this.Be="play",this.qc();};this.He=A();this.Zt=A();this.K=A();this.En=A();this.Tn=0;this.Cn=0;this.An=null;this._i=true;this.Ni=true;this.Wc=ra();this.Sn=[];this.Xt=true;this.lo="";this.be=true;this.Yt=true;this.we=true;this.kn=[];this.Qt=true;this.co=true;this.Jt=true;this.Ot=true;this.te=true;this.xe="camera-full";this.Be="play";this.On="microphone";this.zi="uc-shot-btn uc-camera-action";this.Zc=()=>{if(this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this.g}}}),this.g===S.PHOTO&&this.Xc(),this.g===S.VIDEO){if(this.wt?.state==="recording"){this.In();return}this.Yc();}};this.Qc=t=>{let e=t.target;e&&(this.Di=e.value,this.Ee());};this.Jc=t=>{let e=t.target;e&&(this.$i=e.value,this.Ee());};this.tu=()=>{this.Ee();};this.eu=()=>{this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this.g}}}),this.Zc();};this.iu=()=>{this.ru();};this.ou=()=>{this.su();};this.nu=()=>{this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this.g}}}),this.au();};this.lu=()=>{this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this.g}}}),this.cu();};this.Mn=t=>{let r=t.currentTarget?.getAttribute("data-id");r&&this.Ln(r);};this.Un=()=>{let t=Math.floor((performance.now()-this.Tn+this.Cn)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let e=this.cfg.maxVideoRecordingDuration-t;if(e<=0){let s=this.He.value;s&&(s.textContent=br(e)),this.In();return}let r=this.He.value;r&&(r.textContent=br(e));}else {let e=this.He.value;e&&(e.textContent=br(t));}this.Te=requestAnimationFrame(this.Un);};this.uu=()=>{this.Tn=performance.now(),this.Cn=0,this.Un();};this.Rn=()=>{this.Te&&cancelAnimationFrame(this.Te);};this.wn=()=>{let t=this.K.value;if(!t)return;let e=t.currentTime,r=t.duration||1,s=this.Zt.value;s&&(s.style.transform=`scaleX(${e/r})`);let n=this.He.value;n&&(n.textContent=br(e)),this.Te=requestAnimationFrame(this.wn);};this.qc=()=>{this.Te&&cancelAnimationFrame(this.Te);};this.Te=null;this.Yc=()=>{try{this.Ne=[],this.ze={...this.cfg.mediaRecorderOptions};let{mimeType:t}=this.cfg.mediaRecorderOptions||{};t&&MediaRecorder.isTypeSupported(t)?this.ze.mimeType=t:MediaRecorder.isTypeSupported(na)?this.ze.mimeType=na:this.ze.mimeType="video/mp4",this.xt&&(this.wt=new MediaRecorder(this.xt,this.ze),this.wt.start(),this.wt.addEventListener("dataavailable",e=>{this.Ne.push(e.data);}),this.uu(),this.classList.add("uc-recording"),this.je(vt.PLAY));}catch(t){console.error("Failed to start recording",t),this.telemetryManager.sendEventError(t,"camera recording. Failed to start recording");}};this.In=()=>{this.wt?.addEventListener("stop",()=>{this.du(),this.Rn(),this.je(vt.STOP);}),this.wt?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this.g}}});};this.ru=()=>{if(this.wt?.state==="recording")return;let t=this.K.value;t&&(!t.paused&&!t.ended&&t.readyState>2?t.pause():t.paused&&t.play());};this.su=()=>{this.xt?.getAudioTracks().forEach(t=>{t.enabled=!t.enabled,this.On=t.enabled?"microphone":"microphone-mute",this.co=!t.enabled;});};this.du=()=>{try{let t=new Blob(this.Ne,{type:this.wt?.mimeType}),e=URL.createObjectURL(t),r=this.K.value;if(!r)return;r.muted=!1,r.volume=1,this.Ke(null),r.src=e,this.pu(r);}catch(t){console.error("Failed to preview video",t),this.telemetryManager.sendEventError(t,"camera previewing. Failed to preview video");}};this.au=()=>{if(this.je(vt.RETAKE),this.g===S.VIDEO){this.Ke(this.xt);let t=this.K.value;t&&(t.muted=true);}this.K.value?.play?.();};this.cu=()=>{if(this.je(vt.ACCEPT),this.g===S.PHOTO){this.Et?.toBlob(s=>{if(!s)return;let n=this.Pn("camera","jpeg",sa,s);this.$n(n);},sa);return}let t=new Blob(this.Ne,{type:this.wt?.mimeType}),e=this.hu(this.wt?.mimeType),r=this.Pn("video",e,`video/${e}`,t);this.$n(r),this.Ne=[];};this.fu=t=>{t===vt.SHOT&&(this.te=true,this.Yt=true,this.Ot=true,this.we=false,this.Xt=true),(t===vt.RETAKE||t===vt.ACCEPT)&&(this.te=!this.W.includes(S.VIDEO),this.Ot=!this.W.includes(S.PHOTO),this.Yt=false,this.we=true,this.Xt=this.ge.length<=1);};this.mu=t=>{t===vt.PLAY&&(this.be=false,this.Ot=true,this.Xt=true,this.Qt=true,this.Be="pause",this.xe="square",this.zi="uc-shot-btn uc-camera-action uc-stop-record"),t===vt.STOP&&(this.be=false,this.Yt=true,this.Jt=true,this.we=false),(t===vt.RETAKE||t===vt.ACCEPT)&&(this.be=true,this.te=!this.W.includes(S.VIDEO),this.Ot=!this.W.includes(S.PHOTO),this.Yt=false,this.we=true,this.Jt=!this.cfg.enableAudioRecording,this.xe="video-camera-full",this.zi="uc-shot-btn uc-camera-action",this.Qt=!this.cfg.enableAudioRecording||this.ye.length<=1,this.Xt=this.ge.length<=1);};this.je=t=>{this.g===S.PHOTO&&(t==="shot"||t==="retake"||t==="accept")&&this.fu(t),this.g===S.VIDEO&&(t==="play"||t==="stop"||t==="retake"||t==="accept"||t==="pause"||t==="resume")&&this.mu(t);};this.Ln=t=>{this.En.value?.querySelectorAll("button").forEach(r=>{r.classList.toggle("uc-active",r.getAttribute("data-id")===t);}),t===S.PHOTO&&(this.xe="camera-full",this.Qt=true,this.Jt=true),t===S.VIDEO&&(this.Be="play",this.xe="video-camera-full",this.Qt=!this.cfg.enableAudioRecording||this.ye.length<=1,this.Jt=!this.cfg.enableAudioRecording),this.telemetryManager.sendEvent({eventType:$.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:t}}}),this.g=t;};this.Pn=(t,e,r,s)=>{let n=Date.now(),a=`${t}-${n}.${e}`;return new File([s],a,{lastModified:n,type:r})};this.$n=t=>{this.api.addFileFromObject(t,{source:z.CAMERA}),this.set$({"*currentActivity":y.activities.UPLOAD_LIST}),this.modalManager?.open(y.activities.UPLOAD_LIST);};this.Ge=P(t=>{this.classList.toggle("uc-initialized",t==="granted");let e=this.g===S.VIDEO&&this.cfg.enableAudioRecording,r=this.g===S.PHOTO?"camera-full":"video-camera-full";t==="granted"?(this._i=false,this.Yt=false,this.Ot=!this.W.includes(S.PHOTO),this.te=!this.W.includes(S.VIDEO),this.Ni=true,this.be=true,this.xe=r,this.Jt=!e,this.Qt=!e):t==="prompt"?(this.lo="camera-permissions-prompt",this._i=true,this.Yt=true,this.Ot=true,this.Ni=false,this.ho()):(this.lo="camera-permissions-denied",this._i=true,this.Ni=false,this.Ot=!this.W.includes(S.PHOTO),this.te=!this.W.includes(S.VIDEO),this.we=true,this.zi="uc-shot-btn uc-camera-action",this.ho());},300);this.vu=()=>{if(!this.xt)return false;let t=this.xt?.getAudioTracks(),e=this.xt?.getVideoTracks();return t.forEach(r=>{r.stop();}),e.forEach(r=>{r.stop();}),true};this.ho=()=>{this.ao&&(this.K.value&&(this.K.value.volume=0),this.Fi?.getTracks?.()?.[0]?.stop(),this.uo(this.K.value),this.Ke(null),this.vu(),this.Rn(),this.ao=false);};this.Ee=async()=>{let t={video:{...uu},audio:this.cfg.enableAudioRecording?{}:false};this.Di&&(t.video={deviceId:{exact:this.Di}}),this.$i&&this.cfg.enableAudioRecording&&(t.audio={deviceId:{exact:this.$i}}),this.K.value&&(this.K.value.volume=0);try{this.Ge("prompt"),this.xt=await navigator.mediaDevices.getUserMedia(t),this.xt.addEventListener("inactive",()=>{this.Ge("denied");}),this.Ke(this.xt),this.ao=!0,this.Ge("granted");}catch(e){this.Ge("denied"),console.log("Failed to capture camera",e),this.telemetryManager.sendEventError(e,"camera capturing. Failed to capture camera");}};this.Dn=()=>{this.Ee();};this.gu=async()=>{try{this.Bi();for(let t of du){let e=await navigator.permissions.query({name:t});this.Gc[t]=e,e.addEventListener("change",this.Dn),this.Vi.push(()=>{e.removeEventListener("change",this.Dn);});}this.Pi=()=>{this.Bi();};}catch(t){this.Bi(),console.log("Failed to use permissions API. Fallback to manual request mode.",t),this.telemetryManager.sendEventError(t,"camera permissions. Failed to use permissions API"),this.Ee();}};this.yu=async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this.fo(),navigator.mediaDevices.addEventListener("devicechange",this.fo);}catch(t){this.telemetryManager.sendEventError(t,"camera devices. Failed to get user media"),console.log("Failed to get user media",t);}};this.fo=async()=>{try{let t=await navigator.mediaDevices.enumerateDevices();this.ge=t.filter(e=>e.kind==="videoinput").map((e,r)=>({text:e.label.trim()||`${this.l10n("caption-camera")} ${r+1}`,value:e.deviceId})),this.ye=this.cfg.enableAudioRecording?t.filter(e=>e.kind==="audioinput").map(e=>({text:e.label.trim(),value:e.deviceId})):[],this.Sn=this.ge,this.Xt=this.ge.length<=1,this.Di=this.ge[0]?.value??null,this.kn=this.ye,this.Qt=!this.cfg.enableAudioRecording||this.ye.length<=1,this.$i=this.ye[0]?.value??null;}catch(t){this.telemetryManager.sendEventError(t,"camera devices. Failed to get devices"),console.log("Failed to get devices",t);}};this.bu=async()=>{await this.gu(),await this.yu(),await this.Ee(),this.Vn(this.W);};this.wu=async()=>{this.Pi&&this.Pi(),window.chrome||this.Ge("denied"),this.ho();};this.Vn=t=>{this.te=!t.includes(S.VIDEO),this.Ot=!t.includes(S.PHOTO);let e=t[0];e&&(!this.g||!t.includes(this.g))&&this.Ln(e);};}pu(t){this.uo(t),t.addEventListener("play",this.bn),t.addEventListener("pause",this.xn);}uo(t){t?.removeEventListener("play",this.bn),t?.removeEventListener("pause",this.xn);}Ke(t){this.Fi!==t&&(this.Fi=t,this.po());}po(){let t=this.K.value;if(!t)return;let e=this.Fi??null;t.srcObject!==e&&(t.srcObject=e);}Xc(){if(this.je("shot"),this.Et=document.createElement("canvas"),this.e=this.Et.getContext("2d"),!this.e)throw new Error("Failed to get canvas context");let t=this.K.value;if(!t)throw new Error("Video element not found");this.Et.height=t.videoHeight,this.Et.width=t.videoWidth,this.cfg.cameraMirror&&(this.e.translate(this.Et.width,0),this.e.scale(-1,1)),this.e.drawImage(t,0,0),t.pause();}hu(t){let e={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(t==="")return "webm";if(t){let r=t.split("/");if(r?.[0]==="video"){let n=r.slice(1).join("/")?.split(";")[0];if(n&&e[n])return e[n]}}return "avi"}get W(){return G(this.cfg.cameraModes).filter(t=>t===S.PHOTO||t===S.VIDEO)}Bi(){if(this.Vi.length!==0){for(let t of this.Vi)t();this.Vi=[],this.Pi=null;}}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:this.bu,onDeactivate:this.wu}),this.subConfigValue("cameraMirror",t=>{this.An=t?"scaleX(-1)":null;}),this.subConfigValue("enableAudioRecording",t=>{this.Jt=!t,this.co=!t;}),this.subConfigValue("cameraModes",t=>{if(!this.isActivityActive)return;let e=nt(t);this.Vn(e.filter(r=>r===S.PHOTO||r===S.VIDEO));});}firstUpdated(t){super.firstUpdated(t),this.po();}updated(t){super.updated(t),this.po();}xu(){this.Bi(),navigator.mediaDevices?.removeEventListener("devicechange",this.fo),this.uo(this.K.value),this.Ke(null);}disconnectedCallback(){super.disconnectedCallback(),this.xu();}render(){return g`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.$["*historyBack"]} title=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div ?hidden=${!this.Xt}><uc-icon name="camera"></uc-icon><span>${this.l10n("caption-camera")}</span></div><uc-select class="uc-camera-select" .options=${this.Sn} ?hidden=${this.Xt} @change=${this.Qc} ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline style=${ye({transform:this.An})} ?hidden=${this._i} ${I(this.K)} ></video><div class="uc-message-box" ?hidden=${this.Ni}><span>${this.l10n(this.lo)}</span><button type="button" @click=${this.tu} ?hidden=${this.Wc} >${this.l10n("camera-permissions-request")}</button></div></div><div class="uc-controls"><div ${I(this.En)} class="uc-switcher" ?hidden=${!this.be}><button data-id="photo" type="button" class="uc-switch uc-mini-btn" @click=${this.Mn} ?hidden=${this.Ot} ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class="uc-switch uc-mini-btn" @click=${this.Mn} ?hidden=${this.te} ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" @click=${this.iu} ?hidden=${this.be} ><uc-icon name=${this.Be}></uc-icon><span ${I(this.He)}> 00:00 </span><span ${I(this.Zt)} class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" ?hidden=${this.we} ><button type="button" class="uc-secondary-btn" @click=${this.nu}> Retake </button><button type="button" class="uc-primary-btn" @click=${this.lu} data-testid="accept" > Accept </button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" @click=${this.eu} class=${this.zi} ?hidden=${this.Yt} ><uc-icon name=${this.xe}></uc-icon></button><div class="uc-select"><button type="button" class="uc-mini-btn uc-btn-microphone" @click=${this.ou} ?hidden=${this.Jt} ><uc-icon name=${this.On}></uc-icon></button><uc-select class="uc-audio-select" .options=${this.kn} ?hidden=${this.Qt} ?disabled=${this.co} @change=${this.Jc} ></uc-select></div></div>`}};p([v()],F.prototype,"An",2),p([v()],F.prototype,"_i",2),p([v()],F.prototype,"Ni",2),p([v()],F.prototype,"Wc",2),p([v()],F.prototype,"Sn",2),p([v()],F.prototype,"Xt",2),p([v()],F.prototype,"lo",2),p([v()],F.prototype,"be",2),p([v()],F.prototype,"Yt",2),p([v()],F.prototype,"we",2),p([v()],F.prototype,"kn",2),p([v()],F.prototype,"Qt",2),p([v()],F.prototype,"co",2),p([v()],F.prototype,"Jt",2),p([v()],F.prototype,"Ot",2),p([v()],F.prototype,"te",2),p([v()],F.prototype,"xe",2),p([v()],F.prototype,"Be",2),p([v()],F.prototype,"On",2),p([v()],F.prototype,"zi",2);var be=class extends mt{constructor(i){if(super(i),this.it=U,i.type!==At.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(i){if(i===U||i==null)return this.Fn=void 0,this.it=i;if(i===Q)return i;if(typeof i!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(i===this.it)return this.Fn;this.it=i;let t=[i];return t.raw=t,this.Fn={zt:this.constructor.resultType,strings:t,values:[]}}};be.directiveName="unsafeHTML",be.resultType=1;var fi=class extends be{};fi.directiveName="unsafeSVG",fi.resultType=2;var wr=lt(fi);function es(o,i,t){return o?i(o):t?.(o)}function aa(...o){return o.reduce((i,t)=>{if(typeof t=="string")return i[t]=true,i;for(let e of Object.keys(t))i[e]=t[e];return i},{})}function ut(...o){let i=aa(...o);return Object.keys(i).reduce((t,e)=>(i[e]&&t.push(e),t),[]).join(" ")}function la(o,...i){let t=aa(...i);for(let e of Object.keys(t))o.classList.toggle(e,!!t[e]);}var pu=o=>tt.includes(o),ca=o=>{if(!o)return tt;let i=nt(o).filter(pu);return i.length===0?tt:i};function ua(o){return {"*originalUrl":null,"*loadingOperations":new Map,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":false,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":tt,"*tabId":V.CROP,"*on.retryNetwork":()=>{let i=o.querySelectorAll("img");for(let t of i){let e=t.src;t.src=ee,t.src=e;}o.$["*networkProblems"]=false;},"*on.apply":i=>{if(!i)return;let t=o.$["*originalUrl"];if(!t){console.warn("Original URL is null, cannot apply transformations");return}let e=J(Zt(i),"preview"),r=K(t,e),s={originalUrl:t,cdnUrlModifiers:e,cdnUrl:r,transformations:i};o.dispatchEvent(new CustomEvent("apply",{detail:s,bubbles:true,composed:true})),o.remove();},"*on.cancel":()=>{o.remove(),o.dispatchEvent(new CustomEvent("cancel",{bubbles:true,composed:true}));}}}var da="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><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-closeMax' 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='ruc-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><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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.315-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>";var pa=Dt([...tt]),et=class extends E{constructor(){super(...arguments);this.ctxOwner=true;this.Eu="";this.ee=ee;this.Tu="";this.qe=false;this.uuid=null;this.cdnUrl=null;this.cropPreset="";this.tabs=pa;this._n=false;this.Lt=false;this.mo=null;this.Hi=P(t=>{this.qe=t;},300);this.ji=A();this.Nn=A();this.zn=A();this.Bn=A();this.Hn=()=>{this.Hi(false),this.ee!==ee&&(this.$["*networkProblems"]=false);};this.jn=()=>{this.Hi(false),this.$["*networkProblems"]=true;};this.Cu=()=>{let t=this.$["*on.retryNetwork"];t?.();};this.init$={...this.init$,...ua(this)};}static{this.styleAttrs=["uc-cloud-image-editor"];}Au(){this.Lt||this.mo||(this.mo=this.updateComplete.then(()=>{this.mo=null,this.Lt=true;}));}initCallback(){super.initCallback(),this.Kn(),this.Gn();}Ki(){let t=this.zn.value;t&&(this.$["*faderEl"]=t);let e=this.Nn.value;e&&(this.$["*cropperEl"]=e);let r=this.Bn.value;r&&(this.$["*imgContainerEl"]=r);let s=this.ji.value;s&&(this.$["*imgEl"]=s);}Su(){let t=this.ji.value;t&&(t.addEventListener("load",this.Hn),t.addEventListener("error",this.jn));}ku(){let t=this.ji.value;t&&(t.removeEventListener("load",this.Hn),t.removeEventListener("error",this.jn));}get Ou(){let t=this.$["*tabId"];return ut("uc-image",{"uc-image_hidden_to_cropper":t===V.CROP,"uc-image_hidden_effects":t!==V.CROP})}qn(){return new Promise((e,r)=>{let s=window.setTimeout(()=>{r(new Error("[cloud-image-editor] timeout waiting for non-zero container size"));},3e3),n=new ResizeObserver(a=>{let[l]=a;l&&l.contentRect.width>0&&l.contentRect.height>0&&(window.clearTimeout(s),n.disconnect(),window.setTimeout(()=>e(),0));});n.observe(this);})}firstUpdated(t){super.firstUpdated(t),this.Ki(),this.Su(),this.initEditor();let e=!!(this.uuid||this.cdnUrl),r=t.has("uuid")||t.has("cdnUrl");e&&!r&&this.updateImage();}disconnectedCallback(){this.ku(),super.disconnectedCallback();}render(){let t=this.Tu??"",e=this.Eu??"",r=this.ee||ee,s=this.qe,n=this._n;return g` ${wr(da)}<div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" .visible=${n}><div class="uc-network_problems_content"><div class="uc-network_problems_icon"><uc-icon name="sad"></uc-icon></div><div class="uc-network_problems_text">Network error</div></div><div class="uc-network_problems_footer"><uc-btn-ui theme="primary" text="Retry" @click=${this.Cu}></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">${t}</div></div><div class="uc-image_container" ${I(this.Bn)}><img src=${r} class=${this.Ou} ${I(this.ji)} />${es(this.Lt,()=>g`<uc-editor-image-cropper ${I(this.Nn)}></uc-editor-image-cropper>`)}<uc-editor-image-fader ${I(this.zn)}></uc-editor-image-fader></div><div class="uc-info_pan">${e}</div></div><div class="uc-toolbar"><uc-line-loader-ui .active=${s}></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor">${es(this.Lt,()=>g`<uc-editor-toolbar></uc-editor-toolbar>`)}</div></div></div>`}updated(t){super.updated(t),t.has("uuid")&&this.uuid&&this.updateImage(),t.has("cdnUrl")&&this.cdnUrl&&this.updateImage(),t.has("tabs")&&this.Kn(),(t.has("cropPreset")||t.has("cdnUrl"))&&this.Gn();}Kn(){let t=this.tabs||pa;this.$["*tabList"]=ca(t);}Gn(){let t=mr(this.cropPreset??""),e=null;if(this.cdnUrl){let r=Ao(this.cdnUrl),s=So(r);if(Array.isArray(s?.crop?.dimensions)){let[n,a]=s.crop.dimensions;e=Jn(n,a,t,.1);}}this.$["*cropPresetList"]=t,this.$["*currentAspectRatio"]=e??t?.[0]??null;}async updateImage(){if(this.isConnected){if(await this.qn(),this.cdnUrl){let t=this.cdnUrl,e=qi(t),r=Wt(t,e);if(r===this.$["*originalUrl"])return;this.$["*originalUrl"]=r;let s=Ao(t),n=So(s);this.$["*editorTransformations"]=n;}else if(this.uuid){let t=Wt(this.cfg.cdnCname,this.uuid);if(t===this.$["*originalUrl"])return;this.$["*originalUrl"]=t,this.$["*editorTransformations"]={};}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===V.CROP?this.$["*cropperEl"]?.deactivate({reset:true}):this.$["*faderEl"]?.deactivate();try{let t=this.$["*originalUrl"],e=await this.proxyUrl(K(t,J("json"))),r=await fetch(e).then(a=>a.json()),{width:s,height:n}=r;this.$["*imageSize"]={width:s,height:n},this.$["*tabId"]===V.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:t});}catch(t){t&&(this.telemetryManager.sendEventError(t,"cloud editor image. Failed to load image info"),console.error("Failed to load image info",t));}this.Au();}}async initEditor(){try{await this.qn();}catch(t){this.isConnected&&console.error(t.message);return}this.classList.add("uc-editor_ON"),this.sub("*networkProblems",t=>{let e=!!t;this._n=e;}),this.sub("*editorTransformations",t=>{if(Object.keys(t).length===0)return;let e=this.$["*originalUrl"],r=J(Zt(t),"preview"),s=K(e,r),n={originalUrl:e,cdnUrlModifiers:r,cdnUrl:s,transformations:t};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:true,composed:true}));},false);}};p([v()],et.prototype,"Eu",2),p([v()],et.prototype,"ee",2),p([v()],et.prototype,"Tu",2),p([v()],et.prototype,"qe",2),p([w({type:String,reflect:true})],et.prototype,"uuid",2),p([w({type:String,attribute:"cdn-url",reflect:true})],et.prototype,"cdnUrl",2),p([w({type:String,attribute:"crop-preset",reflect:true})],et.prototype,"cropPreset",2),p([w({type:String,reflect:true})],et.prototype,"tabs",2),p([v()],et.prototype,"_n",2),p([v()],et.prototype,"Lt",2);var xr=class extends E{constructor(){super(...arguments);this.qi=false;this.Ye=false;this.Xn=A();this.Qe=false;this.Je=null;this.Qn=t=>{this.Jn(),this.ti&&(t.stopPropagation(),t.preventDefault(),this.ti=false);};this.ta=t=>{if(!this.ti||!this.Gi||!this.go)return;t.stopPropagation(),t.preventDefault();let e=this.Dt;if(!e)return;let{x:r,y:s}=e.getBoundingClientRect(),n=t.x-r,a=t.y-s,l=n-this.Gi[0],c=a-this.Gi[1],{direction:d}=this.go,u=this.Vu(d,[l,c]);u&&(this.$["*cropBox"]=u);};this.ea=t=>{if(!this.It)return;let e=Object.values(this.It).find(r=>{if(!r||this.bo(r.direction))return false;let n=r.interactionNode.getBoundingClientRect(),a={x:n.x,y:n.y,width:n.width,height:n.height};return Zn(a,[t.x,t.y])});this.Wn=e,this.Jn();};}get Dt(){return this.Xn.value??null}get ti(){return this.Ye}set ti(t){this.Ye!==t&&(this.Ye=t,this.yo());}yo(){this.Ze&&this.Ze.setAttribute("class",ut({"uc-guides--hidden":this.qi,"uc-guides--visible":!this.qi&&this.Ye,"uc-guides--semi-hidden":!this.qi&&!this.Ye}));}bo(t){let e=this.$["*imageBox"];if(!e)return false;if(t===""&&e.height<=k&&e.width<=k)return true;let r=e.height<=k&&(t.includes("n")||t.includes("s")),s=e.width<=k&&(t.includes("e")||t.includes("w"));return r||s}Iu(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:r,width:s,height:n}=t,a=this.Dt;if(!a)return;let l=ct("mask",{id:"backdrop-mask"}),c=ct("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),d=ct("rect",{x:e,y:r,width:s,height:n,fill:"black"});l.appendChild(c),l.appendChild(d);let u=ct("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});a.appendChild(u),a.appendChild(l),this.We=l,this.vo=d;}Mu(){this.We&&(this.We.style.display="none",window.requestAnimationFrame(()=>{this.We&&(this.We.style.display="block");}));}Lu(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:r,width:s,height:n}=t;this.vo&&Jt(this.vo,{x:e,y:r,width:s,height:n});}Uu(){let t=this.$["*cropBox"];if(!(!t||!this.Ze||!this.It)){for(let e of Object.values(this.It)){if(!e)continue;let{direction:r,pathNode:s,interactionNode:n,groupNode:a}=e,l=r==="",c=r.length===2,{x:d,y:u,width:h,height:f}=t;if(l)Jt(n,{x:d,y:u,width:h,height:f});else {let b=te(Math.min(h,f)/82/2,0,1),x=c?jn(t,r,b):Kn(t,r,b),T=x.center;if(!T)continue;let C=Math.max(qo*te(Math.min(h,f)/qo/3,0,1),Hn);Jt(n,{x:T[0]-C,y:T[1]-C,width:C*2,height:C*2}),Jt(s,{d:x.d});}let m=this.bo(r);a.setAttribute("class",ut("uc-thumb",{"uc-thumb--hidden":m,"uc-thumb--visible":!m}));}Jt(this.Ze,{x:t.x-1*.5,y:t.y-1*.5,width:t.width+1,height:t.height+1});}}Yn(t,e){let r=ct("g");r.classList.add("uc-thumb"),r.setAttribute("with-effects","");let s=ct("rect",{fill:"transparent"}),n=ct("path",{stroke:"currentColor",fill:"none","stroke-width":3});r.appendChild(n),r.appendChild(s),t[e]={direction:e,pathNode:n,interactionNode:s,groupNode:r},e===""&&(r.style.cursor="move"),s.addEventListener("pointerdown",this.Ru.bind(this,e));}Pu(){let t={};for(let e=0;e<3;e++)for(let r=0;r<3;r++){let s=`${["n","","s"][e]}${["w","","e"][r]}`;s!==""&&this.Yn(t,s);}return this.Yn(t,""),t}$u(){let t=ct("svg"),e=ct("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});t.appendChild(e);for(let r=1;r<=2;r++){let s=ct("line",{x1:`${ci*r}%`,y1:"0%",x2:`${ci*r}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s);}for(let r=1;r<=2;r++){let s=ct("line",{x1:"0%",y1:`${ci*r}%`,x2:"100%",y2:`${ci*r}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s);}return t.classList.add("uc-guides","uc-guides--semi-hidden"),t}Du(){let t=this.Dt;if(!t)return;let e=document.createDocumentFragment(),r=this.$u();e.appendChild(r);let s=this.Pu();for(let{groupNode:n}of Object.values(s))e.appendChild(n);t.appendChild(e),this.It=s,this.Ze=r,this.yo();}Ru(t,e){if(!this.It)return;let r=this.It[t];if(!r||this.bo(t))return;let s=this.$["*cropBox"],n=this.Dt;if(!n)return;let{x:a,y:l}=n.getBoundingClientRect(),c=e.x-a,d=e.y-l;this.ti=true,this.go=r,this.Gi=[c,d],this.Zn={...s};}Vu(t,e){let[r,s]=e,n=this.$["*imageBox"],a=this.Zn??this.$["*cropBox"],l=this.$["*currentAspectRatio"],c=l?l.width/l.height:void 0;if(t===""?a=qn({rect:a,delta:[r,s],imageBox:n}):a=Wn({rect:a,delta:[r,s],direction:t,aspectRatio:c,imageBox:n}),!Object.values(a).every(d=>Number.isFinite(d)&&d>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:a});return}return $e(Ve(a),n)}Jn(){let t=this.Wn,e=this.Dt;e&&(e.style.cursor=t?Gn(t.direction):"initial");}ia(t){if(this.Xe){this.Xe.setAttribute("href",t);return}let e=this.Dt;if(!e){this.Je=t;return}this.Je=null;let r=document.createDocumentFragment(),s=ct("image",{href:t});s.setAttribute("class","uc-cloud-mask"),r.appendChild(s),e.appendChild(r),this.Xe=s;}Fu(){let t=this.$["*cropBox"];if(!t||!this.Xe)return;let{x:e,y:r,width:s,height:n}=t;Jt(this.Xe,{x:e,y:r,height:n,width:s});}wo(){this.Qe&&(this.Lu(),this.Uu(),this.Fu());}toggleThumbs(t){if(this.It)for(let e of Object.values(this.It)){if(!e)continue;let{groupNode:r}=e;r.setAttribute("class",ut("uc-thumb",{"uc-thumb--hidden":!t,"uc-thumb--visible":t}));}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this.Mu(),this.Qe&&window.requestAnimationFrame(()=>{this.wo();});}),this.sub("*cropBox",t=>{t&&(this.qi=t.height<=k||t.width<=k,this.yo(),this.Qe&&window.requestAnimationFrame(()=>{this.wo();}));}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this.ia(t);}),document.addEventListener("pointermove",this.ta,true),document.addEventListener("pointerup",this.Qn,true);}firstUpdated(t){super.firstUpdated(t),this._u();}_u(){let t=this.Dt;if(!(!t||this.Qe)){if(this.Iu(),this.Du(),this.Qe=true,t.addEventListener("pointermove",this.ea,true),this.Je){let e=this.Je;this.Je=null,this.ia(e);}this.wo();}}disconnectedCallback(){super.disconnectedCallback(),this.Dt?.removeEventListener("pointermove",this.ea,true),document.removeEventListener("pointermove",this.ta,true),document.removeEventListener("pointerup",this.Qn,true);}render(){return g`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${I(this.Xn)}></svg>`}};p([v()],xr.prototype,"Ye",2);var ie=lt(class extends mt{constructor(o){if(super(o),o.type!==At.ATTRIBUTE||o.name!=="class"||o.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(o){return " "+Object.keys(o).filter((i=>o[i])).join(" ")+" "}update(o,[i]){if(this.st===void 0){this.st=new Set,o.strings!==void 0&&(this.nt=new Set(o.strings.join(" ").split(/\s/).filter((e=>e!==""))));for(let e in i)i[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(i)}let t=o.element.classList;for(let e of this.st)e in i||(t.remove(e),this.st.delete(e));for(let e in i){let r=!!i[e];r===this.st.has(e)||this.nt?.has(e)||(r?(t.add(e),this.st.add(e)):(t.remove(e),this.st.delete(e)));}return Q}});var B=o=>o??U;var it=class extends E{constructor(){super(...arguments);this.active=false;this.title="";this.icon="";this.titleProp="";}get buttonClasses(){let t=this.active;return {"uc-active":t,"uc-not_active":!t}}ra(){let t=this.buttonClasses;for(let[e,r]of Object.entries(t))this.classList.toggle(e,r);}onClick(t){}connectedCallback(){super.connectedCallback(),this.ra();}updated(t){super.updated(t),t.has("active")&&this.ra();}render(){let t=this.onClick,e=this.title;return g`<button role="option" type="button" aria-label=${B(this.titleProp)} title=${B(this.titleProp)} @click=${t} ><uc-icon name=${this.icon}></uc-icon><div class="uc-title" ?hidden=${!e}>${e}</div></button>`}};p([v()],it.prototype,"active",2),p([v()],it.prototype,"title",2),p([v()],it.prototype,"icon",2),p([v()],it.prototype,"titleProp",2);var Er=12,Tr=16,fu=o=>{let i=12,t=12;return o.width/o.height>=1?(i=Er,t=Math.round(Er*o.height/o.width)):(t=Er,i=Math.round(Er*o.width/o.height)),{width:i,height:t}},is=class extends it{initCallback(){super.initCallback(),this.icon="arrow-dropdown",this.sub("*currentAspectRatio",i=>{let t=this.Nu(i);this.title=t,this.titleProp=t;});}onClick(){this.$["*showListAspectRatio"]=true;}Nu(i){return i?i.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}):""}render(){let i=this.onClick,t=this.title;return g`<button role="option" type="button" class=${ie(this.buttonClasses)} aria-label=${B(this.titleProp)} title=${B(this.titleProp)} @click=${i} ><div class="uc-title" ?hidden=${!t}>${t}</div><uc-icon name=${this.icon}></uc-icon></button>`}},Cr=class extends it{constructor(){super(...arguments);this.Q=null;}get aspectRatio(){return this.Q}set aspectRatio(t){if(this.Q===t)return;let e=this.Q;this.Q=t,this.requestUpdate("aspectRatio",e),t?this.oa(t):(this.removeAttribute("uc-aspect-ratio-freeform"),this.title="",this.titleProp="");}initCallback(){super.initCallback(),this.Q&&this.oa(this.Q),this.sub("*currentAspectRatio",t=>{this.active=t&&t.id===this.Q?.id||t?.width===this.Q?.width&&t?.height===this.Q?.height;});}onClick(){this.$["*currentAspectRatio"]?.id!==this.Q?.id&&(this.$["*currentAspectRatio"]=this.Q);}oa(t){let e=!!t.hasFreeform;this.toggleAttribute("uc-aspect-ratio-freeform",e);let r=()=>{let n=e?this.l10n("custom"):`${t.width}:${t.height}`;return this.title=n,n},s=()=>{let n=this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:e?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${t.width}:${t.height}`}).toLowerCase(),value:""});return this.titleProp=n,n};r(),s(),e||this.requestUpdate();}zu(){let t=this.Q;if(!t||t.hasFreeform)return g`<uc-icon name=${this.icon}></uc-icon>`;let{width:e,height:r}=fu(t),s=(Tr-e)/2,n=(Tr-r)/2;return g`<uc-icon><svg viewBox="0 0 ${Tr} ${Tr}" aria-hidden="true" focusable="false" ><rect x=${s} y=${n} width=${e} height=${r} rx="2" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" ></rect></svg></uc-icon>`}render(){let t=this.onClick,e=this.title;return g`<button role="option" type="button" class=${ie(this.buttonClasses)} aria-label=${B(this.titleProp)} title=${B(this.titleProp)} @click=${t} >${this.zu()}<div class="uc-title" ?hidden=${!e}>${e}</div></button>`}};p([w({attribute:false})],Cr.prototype,"aspectRatio",1);function mu(o){let i=o+90;return i=i>=360?0:i,i}function vu(o,i){if(o==="rotate")return mu(typeof i=="number"?i:0);if(o==="mirror"||o==="flip")return !i;throw new Error(`Unsupported operation: ${o}`)}var Ar=class extends it{constructor(){super(...arguments);this.operation=void 0;}willUpdate(t){super.willUpdate(t),this.operation?(this.titleProp=this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(this.operation).toLowerCase()}),this.icon=this.operation):(this.icon="",this.titleProp="");}onClick(t){if(!this.operation)return;let e=this.$["*cropperEl"],r=e.getValue(this.operation),s=vu(this.operation,r);this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:this.operation,next:s,prev:r}),e.setValue(this.operation,s);}};p([w({type:String})],Ar.prototype,"operation",2);var It="original",Sr=class extends E{constructor(){super(...arguments);this.state={operation:"filter",filter:void 0,originalUrl:"",disabled:false,min:0,max:100,value:0,defaultValue:0,zero:0};this.so=t=>{let{value:e}=t.detail;this.$["*faderEl"]?.set(e),this.state={...this.state,value:e};};}setOperation(t,e){this.state={...this.state,operation:t,filter:e},this.Bu();let r=this.$["*faderEl"],s=this.state.originalUrl||this.$["*originalUrl"];r&&s&&r.activate({url:s,operation:this.state.operation,value:this.state.filter===It?void 0:this.state.value,filter:this.state.filter===It?void 0:this.state.filter,fromViewer:false});}Bu(){let t=this.state.operation,{range:e,zero:r}=wt[t],[s,n]=e;this.state={...this.state,min:s,max:n,zero:r};let l=this.$["*editorTransformations"][t];if(t==="filter"){let d=Number(n),u=l;if(u){let{name:h,amount:f}=u;d=h===this.state.filter?f:n;}this.state={...this.state,value:d,defaultValue:d};return}let c=typeof l<"u"?l:r;this.state={...this.state,value:c,defaultValue:c};}apply(){let e={...this.$["*editorTransformations"]};this.state.operation==="filter"?!this.state.filter||this.state.filter===It?delete e.filter:e.filter={name:this.state.filter,amount:this.state.value}:e[this.state.operation]=this.state.value,this.$["*editorTransformations"]=e;}cancel(){this.$["*faderEl"]?.deactivate({hide:false});}initCallback(){this.sub("*originalUrl",t=>{t&&(this.state={...this.state,originalUrl:t});});}updated(t){if(super.updated(t),t.has("state")){let e=`${this.state.filter??this.state.operation} ${this.state.value}`;this.$["*operationTooltip"]=e;}}render(){return g`<uc-slider-ui .disabled=${this.state.disabled} .min=${this.state.min} .max=${this.state.max} .defaultValue=${this.state.defaultValue} .zero=${this.state.zero} @slider-input=${this.so} ></uc-slider-ui>`}};p([v()],Sr.prototype,"state",2);function He(o){if(!o)return null;let i=o.match(/^([A-Za-z]+)\s+(\d+)$/);if(!i)return null;let[,t,e]=i;return !t||typeof e>"u"?null:{filter:t,value:Number(e)}}var re=class extends it{constructor(){super(...arguments);this.n="";this.f="";this.ei="";this.Wi=0;this.a=null;this.Ae=false;this.isOriginal=false;this.sa=20;}get filter(){return this.f}set filter(t){let e=t??"";if(this.f===e)return;let r=this.f;this.f=e,this.n="filter",this.isOriginal=e===It,this.icon=this.isOriginal?"original":"slider",this.sa=this.isOriginal?40:20,this.requestUpdate("filter",r),this.na(e);}onClick(t){if(this.active)this.isOriginal||(this.$["*sliderEl"].setOperation(this.n,this.f),this.$["*showSlider"]=true);else {let e=this.$["*sliderEl"];e.setOperation(this.n,this.f),e.apply();}this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:He(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this.f;}Hu(){let t=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),e=Number.isFinite(t)&&t>0?t:this.sa||32,r=window.devicePixelRatio,s=Math.ceil(r*e),n=r>=2?"lightest":"normal",a=100,l={...this.$["*editorTransformations"]};return l[this.n]=this.f!==It?{name:this.f,amount:a}:void 0,K(this.ei,J(Wi,Zt(l),`quality/${n}`,`scale_crop/${s}x${s}/center`))}async _e(t,e){t[0]?.isIntersecting?await this.xo(e):this.b?.();}initCallback(){super.initCallback(),"IntersectionObserver"in window&&(this.s=new window.IntersectionObserver(this._e.bind(this),{threshold:[0,1]}));let t=this.$["*originalUrl"];this.ei=t??"",this.sub("*originalUrl",e=>{this.ei=e??"",!this.isOriginal&&this.ei&&this.isConnected&&!this.a&&(this.s?.observe(this),this.ie());}),this.isOriginal||(this.s?.observe(this),this.ie()),this.f&&this.na(this.f),this.sub("*currentFilter",e=>{this.active=!!(e&&e===this.f);}),this.sub("*networkProblems",async e=>{e||(this.a?await this.xo():this.ie());});}disconnectedCallback(){super.disconnectedCallback(),this.s?.disconnect(),this.b?.(),this.Zi();}updated(t){super.updated(t),t.has("isOriginal")&&(this.isOriginal?this.s?.unobserve(this):(this.s?.observe(this),this.ie()));}na(t){if(!t){this.titleProp="";return}let e=this.l10n("a11y-cloud-editor-apply-filter",{name:t.toLowerCase()});this.titleProp=e;}async xo(t){if(!this.isConnected){t?.unobserve(this),this.b?.(),this.b=void 0;return}if(!this.ei){!this.Ce&&!this.Vt&&this.ie();return}let e=++this.Wi,r="";try{r=await this.proxyUrl(this.Hu());}catch(a){this.$["*networkProblems"]=true,console.error("Failed to resolve preview URL",{error:a});return}this.Ae=false,this.b?.();let{promise:s,cancel:n}=ge(r);this.b=()=>{n(),this.Wi===e&&(this.b=void 0);};try{if(await s,this.Wi!==e||!this.isConnected)return;this.a=r,this.Ae=!0,this.Zi(),(t??this.s)?.unobserve(this);}catch(a){this.$["*networkProblems"]=true,console.error("Failed to load image",{error:a}),this.ie();}finally{this.Wi===e&&(this.b=void 0);}}ie(){if(!this.isConnected||this.a||this.Ae||this.isOriginal){this.Zi();return}this.Vt&&cancelAnimationFrame(this.Vt),this.Vt=requestAnimationFrame(()=>{if(this.Vt=void 0,!this.isConnected||this.a||this.Ae||this.isOriginal){this.Zi();return}let t=this.getBoundingClientRect(),e=t.width>0&&t.height>0,r=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight;if(e&&t.bottom>0&&t.right>0&&t.top<s&&t.left<r){this.xo();return}this.Ce=window.setTimeout(()=>{this.Ce=void 0,this.ie();},500);});}Zi(){this.Vt&&(cancelAnimationFrame(this.Vt),this.Vt=void 0),this.Ce&&(window.clearTimeout(this.Ce),this.Ce=void 0);}get aa(){return !!(this.Ae&&!this.active&&!this.isOriginal)}render(){let t=this.onClick,e={opacity:this.aa?"1":"0"};this.a&&(e.backgroundImage=`url(${this.a})`);let r={opacity:this.aa?"0":"1"};return g`<button role="option" type="button" class=${ie(this.buttonClasses)} aria-label=${B(this.titleProp)} title=${B(this.titleProp)} @click=${t} ><div class="uc-preview" ?loaded=${this.Ae} style=${ye(e)}></div><uc-icon class=${ie({"uc-original-icon":this.isOriginal})} name=${this.icon} style=${ye(r)} ></uc-icon></button>`}};p([v()],re.prototype,"a",2),p([v()],re.prototype,"Ae",2),p([v()],re.prototype,"isOriginal",2),p([v()],re.prototype,"sa",2),p([w({type:String})],re.prototype,"filter",1);function ha(o,i){let t={};for(let e of i){let r=o[e];(Object.hasOwn(o,e)||r!==void 0)&&(t[e]=r);}return t}function je(o,i,t){let r=window.devicePixelRatio,s=Math.min(Math.ceil(i*r),3e3),n=r>=2?"lightest":"normal";return K(o,J(Wi,Zt(t),`quality/${n}`,`stretch/off/-/resize/${s}x`,`@clib/${Xt}/${Qt}/uc-cloud-image-editor/`))}function gu(o){return o?[({dimensions:t,coords:e})=>[...t,...e].every(r=>Number.isInteger(r)&&Number.isFinite(r)),({dimensions:t,coords:e})=>t.every(r=>r>0)&&e.every(r=>r>=0)].every(t=>t(o)):true}var kr=class extends E{constructor(){super();this.ctxOwner=true;this.re={width:0,height:0};this.e=null;this._=false;this.at=null;this.ca=A();this.To=A();this.init$={...this.init$,"*padding":20,"*operations":{rotate:0,mirror:false,flip:false},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this.la=P(this.ua.bind(this),300),this.Eo=Be(()=>{!this.isConnected||!this._||(this.Co(),this.da(),this.pa(),this.Ao(),this.So());},100);}firstUpdated(t){super.firstUpdated(t),this.Co();}da(){let t=this.$["*editorTransformations"],e=ha(t,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...e};this.$["*operations"]=r;}Co(){let t=this.ca.value;if(!t)return;let e=t.getContext("2d"),r=this.offsetWidth,s=this.offsetHeight,n=window.devicePixelRatio;t.style.width=`${r}px`,t.style.height=`${s}px`,t.width=r*n,t.height=s*n,e?.scale(n,n),this.Et=t,this.e=e;}pa(){if(!this._||!this.at)return;let t=this.at,e=this.$["*padding"],r=this.$["*operations"],{rotate:s}=r,n={width:this.offsetWidth,height:this.offsetHeight},a=De({width:t.naturalWidth,height:t.naturalHeight},s),l;if(a.width>n.width-e*2||a.height>n.height-e*2){let c=a.width/a.height,d=n.width/n.height;if(c>d){let u=n.width-e*2,h=u/c,f=0+e,m=e+(n.height-e*2)/2-h/2;l={x:f,y:m,width:u,height:h};}else {let u=n.height-e*2,h=u*c,f=e+(n.width-e*2)/2-h/2,m=0+e;l={x:f,y:m,width:h,height:u};}}else {let{width:c,height:d}=a,u=e+(n.width-e*2)/2-c/2,h=e+(n.height-e*2)/2-d/2;l={x:u,y:h,width:c,height:d};}this.$["*imageBox"]=Ve(l);}Ao(){let t=this.$["*cropBox"],e=this.$["*imageBox"],r=this.$["*operations"],{rotate:s}=r,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=e;if(n){let{dimensions:[h,f],coords:[m,b]}=n,{width:x}=De(this.re,s),T=a/x;t=$e(Ve({x:l+m*T,y:c+b*T,width:h*T,height:f*T}),e);}let d=this.$["*currentAspectRatio"],u=d?d.width/d.height:void 0;if(!Xn(t,e)||u&&!Qn(t,u)){let h=e.width/e.height,f=e.width,m=e.height;u&&(h>u?f=Math.min(e.height*u,e.width):m=Math.min(e.width/u,e.height)),t={x:e.x+e.width/2-f/2,y:e.y+e.height/2-m/2,width:f,height:m};}this.$["*cropBox"]=$e(Ve(t),e);}ju(){let t=this.e;if(!t)return;let e=this.at;if(!e)return;let r=this.$["*imageBox"],s=this.$["*operations"],{mirror:n,flip:a,rotate:l}=s,c=De({width:r.width,height:r.height},l);t.save(),t.translate(r.x+r.width/2,r.y+r.height/2),t.rotate(l*Math.PI*-1/180),t.scale(n?-1:1,a?-1:1),t.drawImage(e,-c.width/2,-c.height/2,c.width,c.height),t.restore();}So(){if(!this._||!this.at||!this.Et||!this.e)return;let t=this.Et;this.e.clearRect(0,0,t.width,t.height),this.ju();}Ku({fromViewer:t}){this.at&&(this.To.value?.toggleThumbs(true),this.Gu(),setTimeout(()=>{this.className=ut({"uc-active_from_viewer":t,"uc-active_from_editor":!t,"uc-inactive_to_editor":false});}));}ha(){let t=this.$["*cropBox"],e=this.$["*imageBox"],r=this.$["*operations"],{rotate:s}=r,{width:n,height:a}=e,{width:l,height:c}=De(this.re,s),{width:d,height:u}=t,h=n/l,f=a/c;return [te(Math.round(d/h),1,l),te(Math.round(u/f),1,c)]}qu(){let t=this.$["*cropBox"],e=this.$["*imageBox"],r=this.$["*operations"],{rotate:s}=r,{width:n,height:a,x:l,y:c}=e,{width:d,height:u}=De(this.re,s),{x:h,y:f}=t,m=n/d,b=a/u,x=this.ha(),T={dimensions:x,coords:[te(Math.round((h-l)/m),0,d-x[0]),te(Math.round((f-c)/b),0,u-x[1])]};if(!gu(T)){console.error("Cropper is trying to create invalid crop object",{payload:T});return}if(!(x[0]===d&&x[1]===u))return T}ua(){if(!this.isConnected||!this.re)return;let t=this.$["*operations"],{rotate:e,mirror:r,flip:s}=t,n=this.qu(),l={...this.$["*editorTransformations"],crop:n,rotate:e,mirror:r,flip:s};this.$["*editorTransformations"]=l;}setValue(t,e){this.$["*operations"]={...this.$["*operations"],[t]:e},this._&&(this.pa(),this.Ao(),this.So());}getValue(t){return this.$["*operations"][t]}async activate(t,{fromViewer:e}={}){if(!this._){this._=true,await this.updateComplete,this.Co(),this.re=t,this.removeEventListener("transitionend",this.fa);try{let r=this.$["*originalUrl"],s=this.$["*editorTransformations"];this.at=await this.Wu(r,s),this.da(),this.Eo(),this.Ku({fromViewer:e});}catch(r){console.error("Failed to activate cropper",{error:r}),this.telemetryManager.sendEventError(r,"cloud editor image. Failed to activate cropper");}this.s=new ResizeObserver(r=>{let[s]=r;if(!s)return;s.contentRect.width>0&&s.contentRect.height>0&&this._&&this.at&&this.Eo();}),this.s.observe(this);}}deactivate({reset:t=false}={}){this._&&(!t&&this.ua(),this._=false,this.Zu(),this.className=ut({"uc-active_from_viewer":false,"uc-active_from_editor":false,"uc-inactive_to_editor":true}),this.To.value?.toggleThumbs(false),this.addEventListener("transitionend",this.fa,{once:true}),this.s?.disconnect());}Zu(){let t=this.ha(),e=this.$["*cropBox"],r=Math.min(this.offsetWidth,t[0])/e.width,s=Math.min(this.offsetHeight,t[1])/e.height,n=Math.min(r,s),a=e.x+e.width/2,l=e.y+e.height/2;this.style.transform=`scale(${n}) translate(${(this.offsetWidth/2-a)/n}px, ${(this.offsetHeight/2-l)/n}px)`,this.style.transformOrigin=`${a}px ${l}px`;}Gu(){let t=this.$["*cropBox"],e=t.x+t.width/2,r=t.y+t.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${e}px ${r}px`;}fa(){this._||(this.at=null);}async Wu(t,e){let r=this.offsetWidth;e={...e,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let s=await this.proxyUrl(je(t,r,e)),{promise:n,cancel:a,image:l}=ge(s),c=this.Se(s);return l.addEventListener("load",c,{once:true}),l.addEventListener("error",c,{once:true}),this.b?.(),this.b=a,n.then(()=>l).catch(d=>(console.error("Failed to load image",{error:d}),this.$["*networkProblems"]=true,l))}Se(t){let e="crop",r=this.$["*loadingOperations"],s=r.get(e);return s||(s=new Map,r.set(e,s)),s.get(t)||(s.set(t,true),this.$["*loadingOperations"]=r),()=>{let n=r.get(e);n?.has(t)&&(n.delete(t),this.$["*loadingOperations"]=r);}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this.So();}),this.sub("*cropBox",()=>{this.at&&this.la();}),this.sub("*currentAspectRatio",()=>{this.Ao();}),setTimeout(()=>{this.sub("*networkProblems",t=>{t||this._&&this.re&&this.activate(this.re,{fromViewer:false});});},0);}disconnectedCallback(){super.disconnectedCallback(),this.s?.disconnect(),this.at&&(this.at=null);}render(){return g`<canvas class="uc-canvas" ${I(this.ca)}></canvas><uc-crop-frame ${I(this.To)}></uc-crop-frame>`}};p([v()],kr.prototype,"at",2);function rs(o,i,t){let e=t,r=t-1,s=new Array(e);for(let n=r;n>=0;n-=1)s[n]=Math.ceil((n*i+(r-n)*o)/r);return s}function yu(o){return typeof o=="string"&&o in wt}function bu(o){let i=[];for(let t=0;t<o.length-1;t+=1){let e=o[t],r=o[t+1];typeof e=="number"&&typeof r=="number"&&i.push([e,r]);}return i}function wu(o,i,t){let e=bu(o).find(([n,a])=>n<=i&&i<=a);if(!e)return o.map(()=>0);let[r,s]=e;return o.map(n=>{let a=Math.abs(r-s)||1,l=Math.abs(i-r)/a;return r===n?i>t?1:1-l:s===n?i>=t?l:1:0})}function xu(o,i){return o.map((t,e)=>t<i?o.length-e:e)}function fa(o,i){let t=wt[o].keypointsNumber,{range:e,zero:r}=wt[o];return [...new Set([...rs(e[0],r,t+1),...rs(r,e[1],t+1),r,i])].sort((s,n)=>s-n)}var os=class extends E{constructor(){super();this._=false;this.ko=true;this.n="initial";this.ma={};this.Ft=[];this.ga=0;this.ba=A();this.Xi=A();this.classList.add("uc-inactive_to_cropper"),this.ya=P(async(t,e,r)=>{let s=()=>!this.wa(t,e)||this.me!==r||!!this.Ft.find(c=>c.value===r);if(s())return;let n=await this.xa(t,r),a=new Image;a.src=n.src;let l=this.Se(n.src);a.addEventListener("load",l,{once:true}),a.addEventListener("error",l,{once:true}),n.image=a,a.classList.add("uc-fader-image"),a.addEventListener("load",()=>{if(s())return;let c=this.Ft,d=c.findIndex(m=>m.value>r);d===-1&&(d=c.length);let h=c[d]?.image,f=this.Xi.value;!f||h&&!f.contains(h)||(c.splice(d,0,n),h?f.insertBefore(a,h):f.appendChild(a),this.Mo(t,r));},{once:true}),a.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});},600);}Se(t){let e=this.n,r=this.$["*loadingOperations"];r.has(e)||r.set(e,new Map);let s=r.get(e);return s&&!s.get(t)&&(s.set(t,true),this.$["*loadingOperations"]=r),()=>{let n=r.get(e);n?.has(t)&&(n.delete(t),this.$["*loadingOperations"]=r);}}Ea(){window.cancelAnimationFrame(this.ga),this.ga=window.requestAnimationFrame(()=>{for(let t of this.Ft){let{image:e}=t;e&&(e.style.opacity=t.opacity.toString(),e.style.zIndex=t.zIndex.toString());}});}ee({url:t=this.va,filter:e=this.f??void 0,operation:r,value:s}={}){if(!t)throw new Error("URL is not defined");let n={...this.ma};r&&(r==="filter"?e&&typeof s=="number"&&(n.filter={name:e,amount:s}):typeof s=="number"&&(n[r]=s));let a=this.offsetWidth;return this.proxyUrl(je(t,a,n))}async xa(t,e){return {src:await this.ee({operation:t,value:e}),image:void 0,opacity:0,zIndex:0,value:e}}wa(t,e){return this.n===t&&this.f===e}set(t){let e=typeof t=="string"?parseInt(t,10):t;!yu(this.n)||!Number.isFinite(e)||(this.Mo(this.n,e),this.ya(this.n,this.f,e));}Mo(t,e){this.n=t,this.me=e;let{zero:r}=wt[t],s=this.Ft.map(l=>l.value),n=wu(s,e,r),a=xu(s,r);this.Ft.forEach((l,c)=>{let d=n[c],u=a[c];typeof d=="number"&&(l.opacity=d),typeof u=="number"&&(l.zIndex=u);}),this.Ea();}Ta(){let t=new Image;return t.classList.add("uc-fader-image","uc-fader-image--preview"),t.style.opacity="0",t}async Xu(){this.a=this.a||this.Ta();let t=this.a;t&&this.Ca(t);let e=this.Ft.map(c=>c.src),{images:r,promise:s,cancel:n}=hi(e);r.forEach(c=>{let d=this.Se(c.src);c.addEventListener("load",d),c.addEventListener("error",d);}),this.Oo=()=>{n(),this.Oo=void 0;};let a=this.n,l=this.f;if(await s,this._&&this.wa(a,l)){let c=this.Xi.value;if(!c)return;c.replaceChildren(),this.Ft.forEach((d,u)=>{let h=r[u];h&&(h.classList.add("uc-fader-image"),d.image=h,c.appendChild(h));}),this.Ea();}}async setTransformations(t){if(this.ma=t,this.a){let e=await this.ee(),r=this.Se(e);this.a.src=e,this.a.addEventListener("load",r,{once:true}),this.a.addEventListener("error",r,{once:true}),this.a.style.opacity="1",this.a.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}}async preload({url:t,filter:e,operation:r,value:s}){if(!r||typeof s!="number")return;this.Io?.();let n=fa(r,s),a=await Promise.all(n.map(c=>this.ee({url:t,filter:e,operation:r,value:c}))),{cancel:l}=hi(a);this.Io=l;}Yu(t){let e=this.a||this.Ta();if(this.Ca(e),this.a=e,e.src===t){e.style.opacity="1",e.style.transform="scale(1)",this.className=ut({"uc-active_from_viewer":this.ii,"uc-active_from_cropper":!this.ii,"uc-inactive_to_cropper":false});return}e.style.opacity="0";let r=this.Se(t);e.addEventListener("error",r,{once:true}),e.src=t,e.addEventListener("load",()=>{r(),e&&(e.style.opacity="1",e.style.transform="scale(1)",this.className=ut({"uc-active_from_viewer":this.ii,"uc-active_from_cropper":!this.ii,"uc-inactive_to_cropper":false}));},{once:true}),e.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}async activate({url:t,operation:e,value:r,filter:s,fromViewer:n}){if(this._=true,this.ko=false,await this.updateComplete,this.va=t,this.n=e??"initial",this.me=r,this.f=s,this.ii=n,typeof r!="number"&&!s){let l=await this.ee({operation:e,value:r});this.Yu(l),this.Lo();return}!e||typeof r!="number"||(this.Ft=await Promise.all(fa(e,r).map(l=>this.xa(e,l))),this.Mo(e,r),this.Xu());}deactivate({hide:t=true}={}){this._=false,this.Oo?.(),this.Io?.(),t&&!this.ko?(this.ko=true,this.a&&(this.a.style.transform="scale(1)"),this.className=ut({"uc-active_from_viewer":false,"uc-active_from_cropper":false,"uc-inactive_to_cropper":true}),this.addEventListener("transitionend",()=>{this.Lo();},{once:true})):this.Lo();}Ca(t){let e=this.ba.value;e&&(e.contains(t)||e.appendChild(t));}Lo(){this.Xi.value?.replaceChildren();}render(){return g`<div class="uc-fader-preview-host" ${I(this.ba)}></div><div class="uc-fader-layers-host" ${I(this.Xi)}></div>`}};var Or=class extends it{constructor(){super(...arguments);this.n="";}get operation(){return this.n}set operation(t){let e=t??"";if(this.n===e)return;let r=this.n;this.n=e,this.requestUpdate("operation",r),e&&this.Aa(e);}Aa(t){this.icon=t;let e=()=>{let s=this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(t).toLowerCase()});return this.titleProp=s,s},r=()=>{let s=this.l10n(t);return this.title=s,s};e(),r();}initCallback(){super.initCallback(),this.n&&this.Aa(this.n),this.sub("*editorTransformations",t=>{if(!this.n)return;let{zero:e}=wt[this.n],r=t[this.n],s=typeof r<"u"?r!==e:false;this.active=s;});}onClick(t){this.$["*sliderEl"]?.setOperation(this.n),this.$["*showSlider"]=true,this.$["*currentOperation"]=this.n,this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:He(this.$["*operationTooltip"])});}};p([w({type:String})],Or.prototype,"operation",1);var Eu=1,ma=()=>{},ss=class extends E{constructor(){super(...arguments);this.Sa=t=>{t.preventDefault();let{deltaY:e,deltaX:r}=t;if(Math.abs(r)>Eu){this.scrollLeft+=r;return}this.scrollLeft+=e;};}connectedCallback(){super.connectedCallback(),this.addEventListener("wheel",this.Sa,{passive:false}),this.addEventListener("scroll",ma,{passive:true});}disconnectedCallback(){this.removeEventListener("wheel",this.Sa),this.removeEventListener("scroll",ma),super.disconnectedCallback();}};var dt=class extends E{constructor(){super(...arguments);this.qe=false;this.showMainToolbar=true;this.showSubToolbar=false;this.ka=true;this.tabList=[...tt];this.activeTab=V.CROP;this.Yi=true;this.Uo=false;this.Oa=null;this.Ia=0;this.Ma=0;this.Qi=A();this.La=A();this.tabToggleRefs={[V.CROP]:A(),[V.TUNING]:A(),[V.FILTERS]:A()};this.Ua=()=>{this.oe();};this.ri=[];this.Hi=P(t=>{this.qe=t;},500);this.Ji=P(()=>{let t=this.$["*editorTransformations"],e=this.$["*currentOperation"],r="",s=false;if(this.$["*tabId"]===V.FILTERS)if(s=true,this.$["*currentFilter"]&&t?.filter?.name===this.$["*currentFilter"]){let n=t?.filter?.amount||100;r=`${this.$["*currentFilter"]} ${n}`;}else r=this.l10n(It);else if(this.showSubToolbar&&this.$["*tabId"]===V.TUNING&&e){s=true;let n=t?.[e]||wt[e].zero;r=`${this.l10n(e)} ${n}`;}s&&(this.$["*operationTooltip"]=r),this.Uo=s;},0);this.Qu={hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"};this.Ju={hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"};this.td={hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"};this.ed={hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"};this.rd={hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"};this.init$={...this.init$,"*sliderEl":null,"*showSlider":false,"*showListAspectRatio":false,"*currentFilter":It,"*currentOperation":null,"*operationTooltip":null};this.kt=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"cancel"}),this.b?.();let e=this.$["*on.cancel"];e?.();};this.Do=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"apply"});let e=this.$["*on.apply"];e?.(this.$["*editorTransformations"]);};this.fd=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"apply-slider",operation:He(this.$["*operationTooltip"])}),this.Qi.value?.apply(),this.Ra();};this.md=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"cancel-slider"}),this.Qi.value?.cancel(),this.Ra();};this.vd=t=>{let r=t.currentTarget?.getAttribute("data-id");r&&(this.telemetryManager.sendEventCloudImageEditor(t,r),this.Ro(r,{fromViewer:false}));};}Ra(){this.$["*showSlider"]=false,this.$["*tabId"]===V.CROP&&(this.$["*showListAspectRatio"]=false),this.$["*tabId"]===V.TUNING&&(this.Uo=false);}Ro(t,{fromViewer:e=false,force:r=false}={}){this.$["*tabId"]!==t&&(this.$["*tabId"]=t),this.Pa(t,{fromViewer:e,force:r});}Pa(t,{fromViewer:e,force:r=false}){if(!r&&this.activeTab===t){this.oe();return}this.activeTab=t;let s=this.$["*faderEl"],n=this.$["*cropperEl"];t===V.CROP?(s?.deactivate(),this.$["*imageSize"]&&n?.activate(this.$["*imageSize"],{fromViewer:e})):(s?.activate({url:this.$["*originalUrl"],fromViewer:e}),n?.deactivate());for(let a of tt){let l=a===t,d=this.tabToggleRefs[a]?.value;d&&(d.active=l),l&&this.oe();}}oe(){let e=this.tabToggleRefs[this.activeTab]?.value,r=this.La.value;if(!e||!r)return;let s=e.offsetLeft,n=e.offsetWidth||Number(getComputedStyle(e).width.replace("px",""));(this.Ia!==s||this.Ma!==n)&&(this.Ia=s,this.Ma=n,r.style.transform=`translateX(${s}px)`,r.style.width=`${n}px`);}get Po(){return this.ri.length>=3}od(t){switch(t){case V.CROP:return this.sd();case V.FILTERS:return this.nd();case V.TUNING:return this.ad();default:return []}}sd(){let t=[];if(this.Po)t.push(()=>this.ld());else for(let e of this.ri)t.push(()=>this.$a(e));for(let e of vn)t.push(()=>this.cd(e));return this.$o(t)}nd(){let e=[It,...mn].map(r=>()=>this.ud(r));return this.$o(e)}ad(){let t=fn.map(e=>()=>this.dd(e));return this.$o(t)}$o(t){return t.length?t.map(r=>r()):[]}ld(){return g`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`}$a(t){return g`<uc-editor-aspect-ratio-button-control .aspectRatio=${t}></uc-editor-aspect-ratio-button-control>`}cd(t){return g`<uc-editor-crop-button-control .operation=${t}></uc-editor-crop-button-control>`}ud(t){return g`<uc-editor-filter-control .filter=${t}></uc-editor-filter-control>`}dd(t){return g`<uc-editor-operation-control .operation=${t}></uc-editor-operation-control>`}pd(){return this.Po?this.ri.map(t=>this.$a(t)):[]}async hd(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let t=this.$["*imgContainerEl"].offsetWidth,e=await this.proxyUrl(je(this.$["*originalUrl"],t,this.$["*editorTransformations"]));this.b?.();let{cancel:r}=hi([e]);this.b=()=>{r(),this.b=void 0;};}}initCallback(){super.initCallback();let t=this.$["*cropPresetList"]??[];this.ri=[...t],this.sub("*cropPresetList",e=>{this.ri=[...e??[]];}),this.sub("*imageSize",e=>{e&&setTimeout(()=>{this.Ro(this.$["*tabId"],{fromViewer:true});},0);}),this.sub("*editorTransformations",e=>{let r=e?.filter?.name;this.$["*currentFilter"]!==r&&(this.$["*currentFilter"]=r??"");}),this.sub("*currentFilter",()=>{this.Ji();}),this.sub("*currentOperation",()=>{this.Ji();}),this.sub("*tabId",e=>{this.Pa(e,{fromViewer:false,force:true}),this.Ji();}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate();}),this.sub("*editorTransformations",e=>{this.hd(),this.$["*faderEl"]?.setTransformations(e);}),this.sub("*loadingOperations",e=>{let r=false;for(let[,s]of e.entries()){if(r)break;for(let[,n]of s.entries())if(n){r=true;break}}this.Hi(r);}),this.sub("*showSlider",e=>{e?(this.showSubToolbar=true,this.showMainToolbar=false,this.Yi=true):this.$["*showListAspectRatio"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*showListAspectRatio",e=>{e?(this.showSubToolbar=true,this.showMainToolbar=false,this.Yi=false):this.$["*showSlider"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*tabList",e=>{if(this.tabList=e,this.ka=e.length>1,!e.includes(this.$["*tabId"])&&e.length>0){let[r]=e;r&&this.Ro(r,{fromViewer:false});return}this.oe();}),this.sub("*operationTooltip",e=>{this.Oa=e;}),this.Ji();}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.Ua);}firstUpdated(t){super.firstUpdated(t),this.Ki(),this.oe();}updated(t){super.updated(t),(t.has("activeTab")||t.has("tabList"))&&this.updateComplete.then(()=>this.oe()),(t.has("showSubToolbar")||t.has("showMainToolbar"))&&this.Ki();}disconnectedCallback(){window.removeEventListener("resize",this.Ua),super.disconnectedCallback(),this.$["*showSlider"]=false,this.$["*showListAspectRatio"]=false;}Ki(){let t=this.Qi.value;t&&(this.$["*sliderEl"]=t);}gd(t){let e=this.tabList.includes(t),r=this.activeTab===t,s=this.tabList.indexOf(t),n=s>=0?ye({gridColumn:`${s+1}`}):U;return g`<uc-presence-toggle class="uc-tab-toggle" .visible=${e} .styles=${this.ed}><uc-btn-ui theme="tab" data-id=${t} icon=${t} role="tab" aria-controls=${`tab_${t}`} aria-selected=${r?"true":"false"} title-prop=${`a11y-editor-tab-${t}`} .active=${r} style=${n} @click=${this.vd} ${I(this.tabToggleRefs[t])} ></uc-btn-ui></uc-presence-toggle>`}yd(t){let e=this.activeTab===t,r=this.od(t);return g`<uc-presence-toggle id=${`tab_${t}`} class="uc-tab-content" .visible=${e} .styles=${this.td} ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner">${r.length?r:U}</div></div></uc-editor-scroller></uc-presence-toggle>`}render(){let t=["uc-info-tooltip",this.Uo?"uc-info-tooltip_visible":"uc-info-tooltip_hidden"].join(" "),e=this.Po;return g`<uc-line-loader-ui .active=${this.qe}></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div class=${t}>${this.Oa??""}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" .visible=${this.showMainToolbar} .styles=${this.Qu} ><div class="uc-tab-content-row">${tt.map(r=>this.yd(r))}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" .visible=${this.ka} .styles=${this.rd} @initial-render=${()=>this.oe()} ><div class="uc-tab-toggles_indicator" ${I(this.La)} ></div>${tt.map(r=>this.gd(r))}</uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" title-prop="cancel" @click=${this.kt} ></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this.Do}></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this.Ju}><div class="uc-slider" ?hidden=${!this.Yi}><uc-editor-slider ${I(this.Qi)}></uc-editor-slider></div><div class="uc-list-aspect-ratio-container" ?hidden=${this.Yi||!e}>${e?g`<div class="uc-list-aspect-ratio">${this.pd()}</div>`:U}</div><div class="uc-controls-row"><uc-btn-ui theme="secondary" @click=${this.md} text=${this.l10n("cancel")}></uc-btn-ui><uc-btn-ui theme="primary" @click=${this.fd} text=${this.l10n("apply")}></uc-btn-ui></div></uc-presence-toggle></div>`}};p([v()],dt.prototype,"qe",2),p([v()],dt.prototype,"showMainToolbar",2),p([v()],dt.prototype,"showSubToolbar",2),p([v()],dt.prototype,"ka",2),p([v()],dt.prototype,"tabList",2),p([v()],dt.prototype,"activeTab",2),p([v()],dt.prototype,"Yi",2),p([v()],dt.prototype,"Uo",2),p([v()],dt.prototype,"Oa",2),p([v()],dt.prototype,"ri",2);var Et=class extends E{constructor(){super(...arguments);this.text="";this.icon="";this.active=false;this.reverse=false;this.theme="default";this.ariaRole="";this.ariaControls="";this.titleProp="";}firstUpdated(t){super.firstUpdated(t),this.Da(),this.Va();}updated(t){super.updated(t),t.has("reverse")&&this.Da(),t.has("theme")&&this.Va();}Da(){this.style.flexDirection=this.reverse?"row-reverse":"";}Va(){this.theme&&this.theme!=="custom"&&(this.className=`uc-${this.theme}`);}get bd(){let t=this.Vo;return {"uc-icon":true,"uc-icon_left":!this.reverse,"uc-icon_right":this.reverse,"uc-icon_hidden":t,"uc-icon_single":this.wd}}get Vo(){return !this.icon}get wd(){return !this.text&&!this.Vo}render(){return g`<button type="button" role=${B(this.ariaRole||void 0)} aria-controls=${B(this.ariaControls||void 0)} aria-label=${B(this.l10n(this.titleProp))} title=${B(this.l10n(this.titleProp))} ><uc-icon class=${ie(this.bd)} name=${B(this.icon||void 0)} ?hidden=${this.Vo} ></uc-icon><div class="uc-text">${this.text}</div></button>`}};p([w({type:String})],Et.prototype,"text",2),p([w({type:String})],Et.prototype,"icon",2),p([w({type:Boolean,reflect:true})],Et.prototype,"active",2),p([w({type:Boolean,reflect:true})],Et.prototype,"reverse",2),p([w({type:String,reflect:true})],Et.prototype,"theme",2),p([w({attribute:"aria-role"})],Et.prototype,"ariaRole",2),p([w({attribute:"aria-controls"})],Et.prototype,"ariaControls",2),p([w({attribute:"title-prop"})],Et.prototype,"titleProp",2);var Ir=class extends E{constructor(){super(...arguments);this.active=false;this.Zt=A();this.Fo=false;this._o=()=>{let t=this.Zt.value;t&&(this.Fa(t),this.Fo&&this.active&&this.No());};}firstUpdated(t){super.firstUpdated(t),this.active&&this.No();}updated(t){super.updated(t),t.has("active")&&(this.active?this.No():this.xd());}No(){let t=this.Zt.value;if(!t)return;this.Fo=true;let{width:e}=this.getBoundingClientRect();t.removeEventListener("transitionend",this._o),t.style.transition="transform 1s",t.style.opacity="1",t.style.transform=`translateX(${e}px)`,t.addEventListener("transitionend",this._o,{once:true});}xd(){let t=this.Zt.value;t&&(this.Fo=false,t.removeEventListener("transitionend",this._o),this.Fa(t));}Fa(t){t.style.transition="initial",t.style.opacity="0",t.style.transform="translateX(-101%)";}render(){return g`<div class="uc-inner"><div class="uc-line" ${I(this.Zt)}></div></div>`}};p([w({type:Boolean,reflect:true})],Ir.prototype,"active",2);var xe={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},mi=class extends E{constructor(){super(...arguments);this.bt=false;this._a=xe;this.Na=xe.visible;this.za=xe.hidden;this.zo=false;this.Ba=false;}set visible(t){this.bt=t,this.Ha();}get visible(){return this.bt}set styles(t){this._a=t,this.zo=true,this.Na=t.visible??xe.visible,this.za=t.hidden??xe.hidden;}get styles(){return this._a}Ha(){this.style.visibility=this.bt?"inherit":"hidden",la(this,{[xe.transition]:!this.zo,[this.Na]:this.bt,[this.za]:!this.bt}),this.toggleAttribute("inert",!this.bt);}Ed(){this.Ba||(this.Ba=true,this.dispatchEvent(new CustomEvent("initial-render",{bubbles:true,composed:true})));}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",true),this.zo||this.classList.add(xe.transition),this.Ha(),setTimeout(()=>{this.classList.toggle("uc-initial",false),this.Ed();},0);}};p([w({type:Boolean})],mi.prototype,"visible",1),p([w({attribute:false})],mi.prototype,"styles",1);var _t=class extends E{constructor(){super();this.Bo=0;this.$t=A();this.Ka=A();this.Ga=A();this.disabled=false;this.min=0;this.max=100;this.defaultValue=0;this.zero=0;this._t=0;this.Td=t=>{t.stopPropagation();let e=this.Wa(t);e!==null&&(this.Ho(e),this.qa("slider-input",e));};this.Cd=t=>{t.stopPropagation();let e=this.Wa(t);e!==null&&(this.Ho(e),this.qa("slider-change",e));};this.Za=()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)");};this.Xa=()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)");};this.setAttribute("with-effects","");}qa(t,e){this.dispatchEvent(new CustomEvent(t,{detail:{value:e},bubbles:true,composed:true}));}firstUpdated(t){super.firstUpdated(t),this.Bo=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10)||0,this.Ya(this._t),this.jo(),this.s=new ResizeObserver(()=>{this.jo(),this.tr(this._t);}),this.s.observe(this);let e=this.$t.value;e?.addEventListener("focus",this.Za),e?.addEventListener("blur",this.Xa),window.setTimeout(()=>{this.tr(this._t);},0);}willUpdate(t){super.willUpdate(t),t.has("defaultValue")&&this.defaultValue!==this._t&&this.Ho(this.defaultValue),(t.has("min")||t.has("max"))&&this.hasUpdated&&(this.jo(),this.tr(this._t)),t.has("zero")&&this.hasUpdated&&this.Qa(this._t);}tr(t){this.Qa(t);let e=this.max-this.min;if(e===0)return;let{width:r}=this.getBoundingClientRect(),a=100/e*(t-this.min)*(r-this.Bo)/100;window.requestAnimationFrame(()=>{let l=this.Ka.value;l&&(l.style.transform=`translateX(${a}px)`);});}Qa(t){if(!this.oi)return;let e=this.max-this.min;if(e===0)return;this.oi.style.opacity=t===this.zero?"0":"1";let{width:r}=this.getBoundingClientRect(),a=100/e*(this.zero-this.min)*(r-this.Bo)/100;window.requestAnimationFrame(()=>{this.oi&&(this.oi.style.transform=`translateX(${a}px)`);});}jo(){let e=this.Ga.value;if(!e)return;let{width:r}=e.getBoundingClientRect(),s=Math.ceil(r/2),n=Math.ceil(s/15)-2;if(this.ja===n)return;let a=document.createDocumentFragment(),l=document.createElement("div"),c=document.createElement("div");l.className="uc-minor-step",c.className="uc-border-step",a.appendChild(c);for(let u=0;u<n;u+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let u=0;u<n;u+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let d=document.createElement("div");d.className="uc-zero-dot",a.appendChild(d),this.oi=d,e.innerHTML="",e.appendChild(a),this.ja=n;}disconnectedCallback(){super.disconnectedCallback();let t=this.$t.value;t?.removeEventListener("focus",this.Za),t?.removeEventListener("blur",this.Xa),this.s?.disconnect(),this.s=void 0;}Ho(t){Number.isFinite(t)&&(this._t=t,this.hasUpdated&&(this.Ya(t),this.tr(t)));}Ya(t){let e=this.$t.value;e&&(e.value=String(t));}Wa(t){let e=t.currentTarget;if(!e)return null;let r=Number.parseInt(e.value,10);return Number.isFinite(r)?r:null}render(){return g`<div class="uc-steps" ${I(this.Ga)}></div><div class="uc-thumb" ${I(this.Ka)}></div><input class="uc-input" type="range" ${I(this.$t)} .min=${String(this.min)} .max=${String(this.max)} .value=${String(this._t)} ?disabled=${this.disabled} @input=${this.Td} @change=${this.Cd} />`}};p([w({type:Boolean,reflect:true})],_t.prototype,"disabled",2),p([w({type:Number})],_t.prototype,"min",2),p([w({type:Number})],_t.prototype,"max",2),p([w({type:Number,attribute:false})],_t.prototype,"defaultValue",2),p([w({type:Number})],_t.prototype,"zero",2),p([v()],_t.prototype,"_t",2);var Mr=class extends R{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.activityType=y.activities.CLOUD_IMG_EDIT;this.J=null;}get activityParams(){let t=super.activityParams;if("internalId"in t)return t;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.Ad(),onDeactivate:()=>this.Sd()}),this.subConfigValue("cropPreset",t=>{if(!this.J)return;let e=t||void 0;this.J.cropPreset!==e&&(this.J={...this.J,cropPreset:e});}),this.subConfigValue("cloudImageEditorTabs",t=>{if(!this.J)return;let e=t||void 0;this.J.tabs!==e&&(this.J={...this.J,tabs:e});});}Do(t){if(!this.si)return;this.debugPrint('editor event "apply"',t.detail);let e=t.detail;this.si.setMultipleValues({cdnUrl:e.cdnUrl,cdnUrlModifiers:e.cdnUrlModifiers}),this.modalManager?.close(y.activities.CLOUD_IMG_EDIT),this.historyBack();}kt(t){let e=t instanceof CustomEvent?t.detail:void 0;this.debugPrint('editor event "cancel"',e),this.modalManager?.close(y.activities.CLOUD_IMG_EDIT),this.historyBack();}handleChange(t){this.debugPrint('editor event "change"',t.detail);}Ad(){let{internalId:t}=this.activityParams,e=this.uploadCollection.read(t);if(!e)throw new Error(`Entry with internalId "${t}" not found`);this.si=e;let r=this.si.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${t}" hasn't uploaded yet`);this.J=this.kd(r);}Sd(){this.si=void 0,this.J=null;}render(){if(!this.J)return U;let{cdnUrl:t,cropPreset:e,tabs:r}=this.J;return g`<uc-cloud-image-editor cdn-url=${t} crop-preset=${B(e)} tabs=${B(r)} @apply=${this.Do} @cancel=${this.kt} @change=${this.handleChange} ></uc-cloud-image-editor>`}kd(t){let e={cdnUrl:t},r=this.cfg.cropPreset;r&&(e.cropPreset=r);let s=this.cfg.cloudImageEditorTabs;return s&&(e.tabs=s),e}};p([v()],Mr.prototype,"J",2);var Tu=[{test:o=>!!o.accept&&!!o.imgOnly,message:"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."},{test:o=>o.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:o=>o.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],va=P(o=>{for(let{test:i,message:t}of Tu)i(o)&&pr(t);},0);var ga=(o,i)=>{let t=new URL(i);return t.hostname=`${o}.${t.hostname}`,t.toString().replace(/\/$/,"")},Cu="0123456789abcdefghijklmnopqrstuvwxyz",ya=o=>{if(o<=0n)return "0";let i="";for(;o>0n;){let t=o%36n;i=Cu[Number(t)]+i,o=o/36n;}return i},ns=(o,i)=>{try{let t=new URL(o),e=new URL(i);return t.hostname.endsWith(e.hostname)}catch{return false}};var Au=async o=>{let i=new TextEncoder().encode(o),t=await window.crypto.subtle.digest("SHA-256",i),e=Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("");return BigInt(`0x${e}`)},Su=10,ku=async o=>{let i=await Au(o);return ya(i).slice(0,Su)},ba=async(o,i)=>{let t=await ku(o);return ga(t,i)};var wa=o=>o instanceof Promise||!!(o&&typeof o=="object"&&"then"in o&&typeof o.then=="function");var as=o=>o,Ou=[as({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:o,enableVideoRecording:i})=>{if(i===null)return o;let t=nt(o);return i&&!t.includes("video")?t=t.concat("video"):i||(t=t.filter(e=>e!=="video")),Dt(t)}}),as({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:o,defaultCameraMode:i})=>{if(i===null)return o;let t=nt(o);return t=t.sort((e,r)=>e===i?-1:r===i?1:0),Dt(t)}}),as({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:o,cdnCname:i,cdnCnamePrefixed:t})=>o&&(i===ei||ns(i,t))?ba(o,t):i})],xa=({key:o,setValue:i,getValue:t,computationControllers:e})=>{for(let r of Ou)if(r.deps.includes(o)){let s={[r.key]:t(r.key)};for(let l of r.deps)s[l]=t(l);let n=new AbortController;e.get(r.key)?.abort(),e.set(r.key,n);let a;try{a=r.fn(s,{signal:n.signal});}catch(l){e.get(r.key)===n&&e.delete(r.key),console.error(`Failed to compute value for "${r.key}"`,l);return}wa(a)?a.then(l=>{n.signal.aborted||i(r.key,l);}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${r.key}"`,l);}).finally(()=>{e.get(r.key)===n&&e.delete(r.key);}):i(r.key,a);}};var D=o=>String(o),X=o=>{let i=Number(o);if(Number.isNaN(i))throw new Error(`Invalid number: "${o}"`);return i},_=o=>{if(typeof o>"u"||o===null)return false;if(typeof o=="boolean")return o;if(o==="true"||o==="")return true;if(o==="false")return false;throw new Error(`Invalid boolean: "${o}"`)},Ea=o=>o==="auto"?o:_(o),Ta=o=>{let i=D(o);if(i!=="user"&&i!=="environment"&&i!=="")throw new Error(`Invalid value: "${i}"`);return i},Ca=o=>{let i=D(o);if(!Object.values(S).includes(i))throw new Error(`Invalid value: "${i}"`);return i},Aa=o=>{let i=D(o),t=nt(i);if(t.some(e=>!Object.values(S).includes(e)))throw new Error(`Invalid value: "${JSON.stringify(t)}"`);return i},Sa=o=>{if(typeof o=="object"&&!Array.isArray(o)||typeof o=="function")return o;throw new Error("Invalid metadata value. Must be an object or function.")},ls=o=>{if(typeof o=="object")return o;throw new Error("Invalid value. Must be an object.")},Lr=o=>{if(typeof o=="function")return o;throw new Error("Invalid value. Must be a function.")},cs=o=>{if(Array.isArray(o))return o;throw new Error("Must be an array.")},ka=o=>{let i=D(o);if(["grid","list"].includes(i))return i;throw new Error(`Invalid value: "${i}"`)};var Iu={pubkey:D,multiple:_,multipleMin:X,multipleMax:X,confirmUpload:_,imgOnly:_,accept:D,externalSourcesPreferredTypes:D,externalSourcesEmbedCss:D,store:Ea,cameraMirror:_,cameraCapture:Ta,sourceList:D,topLevelOrigin:D,maxLocalFileSizeBytes:X,thumbSize:X,showEmptyList:_,useLocalImageEditor:_,useCloudImageEditor:_,cloudImageEditorTabs:D,removeCopyright:_,cropPreset:D,imageShrink:D,modalScrollLock:_,modalBackdropStrokes:_,sourceListWrap:_,remoteTabSessionKey:D,cdnCname:D,cdnCnamePrefixed:D,baseUrl:D,socialBaseUrl:D,secureSignature:D,secureExpire:D,secureDeliveryProxy:D,retryThrottledRequestMaxTimes:X,retryNetworkErrorMaxTimes:X,multipartMinFileSize:X,multipartChunkSize:X,maxConcurrentRequests:X,multipartMaxConcurrentRequests:X,multipartMaxAttempts:X,checkForUrlDuplicates:_,saveUrlForRecurrentUploads:_,groupOutput:_,userAgentIntegration:D,debug:_,localeName:D,metadata:Sa,secureUploadsExpireThreshold:X,localeDefinitionOverride:o=>ls(o),secureUploadsSignatureResolver:o=>Lr(o),secureDeliveryProxyUrlResolver:o=>Lr(o),iconHrefResolver:o=>Lr(o),fileValidators:cs,collectionValidators:cs,validationTimeout:X,validationConcurrency:X,cameraModes:Aa,defaultCameraMode:Ca,enableAudioRecording:_,enableVideoRecording:_,mediaRecorderOptions:ls,maxVideoRecordingDuration:X,filesViewMode:ka,gridShowFileNames:_,cloudImageEditorAutoOpen:_,cloudImageEditorMaskHref:D,testMode:_,qualityInsights:_},Oa=(o,i)=>{if(!(typeof i>"u"||i===null))try{return Iu[o](i)}catch(t){return console.error(`Invalid value for config key "${o}".`,t),at[o]}};var Ur=[...new Set(["debug",...Object.keys(at)])],Mu=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],La=o=>Mu.includes(o),vi=Ur.filter(o=>!La(o)),Ia={...Object.fromEntries(vi.map(o=>[Ye(o),o])),...Object.fromEntries(vi.map(o=>[o.toLowerCase(),o]))},Lu={...Object.fromEntries(vi.map(o=>[Ye(o),Z(o)])),...Object.fromEntries(vi.map(o=>[o.toLowerCase(),Z(o)]))},Ma=o=>`__${o}`,Rr=class extends E{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(at).map(([t,e])=>[Z(t),e]))};this.Od=new Map;}Id(t,e){if(!La(t)){let r=[...new Set([Ye(t),t.toLowerCase()])];for(let s of r)typeof e>"u"||e===null?this.removeAttribute(s):this.getAttribute(s)!==e.toString()&&this.setAttribute(s,e.toString());}}Md(t,e){this.$[Z(t)]!==e&&(typeof e>"u"||e===null?this.$[Z(t)]=at[t]:this.$[Z(t)]=e);}er(t,e){let r=this,s=Oa(t,e),n=Ma(t);r[n]!==s&&(this.Ld(t,r[n],s),r[n]=s,this.Id(t,s),this.Md(t,s),this.debugPrint(`[uc-config] "${t}"`,s),va(this.cfg));}Ja(t){let e=this,r=Ma(t);return e[r]??this.$[Z(t)]}Ld(t,e,r){this.cfg.debug&&r!==e&&typeof r=="object"&&typeof e=="object"&&JSON.stringify(r)===JSON.stringify(e)&&(console.warn(`[uc-config] Option "${t}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${t}" previous value:`,e),console.warn(`[uc-config] "${t}" new value:`,r));}initCallback(){super.initCallback();let t=this;for(let e of vi)this.sub(Z(e),r=>{this.er(e,r);},false);for(let e of Ur){let r=t[e]??this.$[Z(e)];r!==at[e]&&this.er(e,r),Object.defineProperty(this,e,{set:s=>{this.er(e,s);},get:()=>this.Ja(e)});}for(let e of Ur)this.sub(Z(e),()=>{xa({key:e,setValue:this.er.bind(this),getValue:this.Ja.bind(this),computationControllers:this.Od});});}attributeChangedCallback(t,e,r){if(super.attributeChangedCallback(t,e,r),e===r)return;let s=this,n=Ia[t];n&&(s[n]=r),Lu[t]&&(this[t]=r);}static get observedAttributes(){return [...super.observedAttributes,...Object.keys(Ia)]}};for(let o of Ur)Rr.prototype[o]=void 0;function Uu(o){return new Promise(i=>{typeof window.FileReader!="function"&&i(false);try{let t=new FileReader;t.onerror=()=>{i(!0);};let e=r=>{r.type!=="loadend"&&t.abort(),i(!1);};t.onloadend=e,t.onprogress=e,t.readAsDataURL(o);}catch{i(false);}})}function Ru(o,i){return new Promise(t=>{let e=0,r=[],s=a=>{if(!a){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),t(null);return}a.isFile?(e++,a.file(l=>{e--;let c=new File([l],l.name,{type:l.type||i});r.push({type:"file",file:c,fullPath:a.fullPath}),e===0&&t(r);})):a.isDirectory&&n(a.createReader());},n=a=>{e++,a.readEntries(l=>{e--;for(let c of l)s(c);e===0&&t(r);});};s(o);})}function Ua(o){let i=[],t=[];for(let e=0;e<o.items.length;e++){let r=o.items[e];if(r)if(r.kind==="file"){let s=r.type,n=r;if(typeof n.webkitGetAsEntry=="function"||typeof n.getAsEntry=="function"){let l=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():n.getAsEntry?.();l&&t.push(Ru(l,s).then(c=>{c&&i.push(...c);}));continue}let a=r.getAsFile();a&&t.push(Uu(a).then(l=>{l||i.push({type:"file",file:a});}));}else r.kind==="string"&&/^text\/uri-list/.test(r.type)&&t.push(new Promise(s=>{r.getAsString(n=>{i.push({type:"url",url:n}),s();});}));}return Promise.all(t).then(()=>i)}var rt=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),Ra=["focus"],Pu=100,us=new Map;function $u(o,i){let t=Math.max(Math.min(o[0],i.x+i.width),i.x),e=Math.max(Math.min(o[1],i.y+i.height),i.y);return Math.sqrt((o[0]-t)*(o[0]-t)+(o[1]-e)*(o[1]-e))}function ds(o){let i=0,t=document.body,e=new Set,r=m=>{e.add(m);},s=rt.INACTIVE,n=m=>{o.shouldIgnore()&&m!==rt.INACTIVE||(s!==m&&e.forEach(b=>{b(m);}),s=m);},a=()=>i>0;r(m=>o.onChange(m));let l=()=>{i=0,n(rt.INACTIVE);},c=()=>{i+=1,s===rt.INACTIVE&&n(rt.ACTIVE);},d=()=>{i-=1,a()||n(rt.INACTIVE);},u=m=>{m.preventDefault(),i=0,n(rt.INACTIVE);},h=m=>{if(o.shouldIgnore())return;a()||(i+=1);let b=[m.x,m.y],x=o.element.getBoundingClientRect(),T=Math.floor($u(b,x)),C=T<Pu,M=m.composedPath().includes(o.element);us.set(o.element,T);let ht=Math.min(...us.values())===T;M&&ht?(m.preventDefault(),n(rt.OVER)):n(C&&ht?rt.NEAR:rt.ACTIVE);},f=async m=>{if(o.shouldIgnore())return;m.preventDefault();let{dataTransfer:b}=m;if(!b)return;let x=await Ua(b);o.onItems(x),n(rt.INACTIVE);};return t.addEventListener("drop",u),t.addEventListener("dragleave",d),t.addEventListener("dragenter",c),t.addEventListener("dragover",h),o.element.addEventListener("drop",f),Ra.forEach(m=>{window.addEventListener(m,l);}),()=>{us.delete(o.element),t.removeEventListener("drop",u),t.removeEventListener("dragleave",d),t.removeEventListener("dragenter",c),t.removeEventListener("dragover",h),o.element.removeEventListener("drop",f),Ra.forEach(m=>{window.removeEventListener(m,l);});}}var ps=new Set,Tt=class extends R{constructor(){super(...arguments);this.disabled=false;this.clickable=false;this.withIcon=false;this.fullscreen=false;this.initflow=false;this.ir=true;this.tl=true;this.il=null;this.rl=null;this.ol=A();this.ke=t=>{if(t instanceof KeyboardEvent){if(t.code!=="Space"&&t.code!=="Enter")return}else if(!(t instanceof MouseEvent))return;if(this.initflow){this.api.initFlow();return}this.api.openSystemDialog();};this.sl=true;this.Oe=false;}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-area"];}get Ud(){let t=this.text;return typeof t=="string"&&t.length>0?this.l10n(t)||t:this.l10n("drop-files-here")}isActive(){if(!this.ir)return false;let t=this.getBoundingClientRect(),e=t.width>0&&t.height>0,r=t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth),s=window.getComputedStyle(this),n=s.visibility!=="hidden"&&s.display!=="none";return e&&n&&r}initCallback(){super.initCallback(),ps.add(this),this.Ko(),this.Go(),this.nl(),this.al(rt.INACTIVE),this.il=ds({element:this,shouldIgnore:()=>this.ll(),onChange:e=>{this.al(e);},onItems:e=>{e.length&&(e.forEach(r=>{r.type==="url"?this.api.addFileFromUrl(r.url,{source:z.DROP_AREA}):r.type==="file"&&this.api.addFileFromObject(r.file,{source:z.DROP_AREA,fullPath:r.fullPath});}),this.uploadCollection.size&&(this.modalManager?.open(y.activities.UPLOAD_LIST),this.set$({"*currentActivity":y.activities.UPLOAD_LIST})));}});let t=this.ol.value;t&&(this.rl=ds({element:t,onChange:e=>{let r=Object.entries(rt).find(([,s])=>s===e)?.[0].toLowerCase();r&&t.setAttribute("drag-state",r);},onItems:()=>{},shouldIgnore:()=>this.ll()})),this.subConfigValue("sourceList",e=>{let r=G(e);this.sl=r.includes(z.LOCAL),this.Ko(),this.Go();});}willUpdate(t){super.willUpdate(t),t.has("disabled")&&(this.Ko(),this.Go());}updated(t){super.updated(t),t.has("clickable")&&this.nl();}ll(){if(!this.ir||!this.Rd())return true;if(!this.fullscreen)return false;let t=ps;return t.size===0?false:[...t].filter(s=>s!==this).filter(s=>s.isActive()).length>0}Rd(){let t=this.cfg.multiple,e=this.cfg.multipleMax,r=this.uploadCollection.size;return !(t&&e&&r>=e||!t&&r>0)}Ko(){let t=this.sl&&!this.disabled;this.ir=t;}Go(){let t=this.ir||!this.querySelector("[data-default-slot]");this.tl=t,this.hidden=!t;}al(t){let e=Object.entries(rt).find(([,r])=>r===t)?.[0].toLowerCase();e&&this.setAttribute("drag-state",e);}nl(){this.clickable&&!this.Oe?(this.addEventListener("keydown",this.ke),this.addEventListener("click",this.ke),this.Oe=true):!this.clickable&&this.Oe&&(this.removeEventListener("keydown",this.ke),this.removeEventListener("click",this.ke),this.Oe=false);}disconnectedCallback(){super.disconnectedCallback(),ps.delete(this),this.il?.(),this.rl?.(),this.Oe&&(this.removeEventListener("keydown",this.ke),this.removeEventListener("click",this.ke),this.Oe=false);}render(){return g` ${this.yield("",g`<div data-default-slot hidden></div><div ${I(this.ol)} class="uc-content-wrapper" ?hidden=${!this.tl}><div class="uc-icon-container" ?hidden=${!this.withIcon}><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">${this.Ud}</span></div>`)} `}};p([w({type:Boolean,reflect:true})],Tt.prototype,"disabled",2),p([w({type:Boolean,reflect:true})],Tt.prototype,"clickable",2),p([w({type:Boolean,attribute:"with-icon",reflect:true})],Tt.prototype,"withIcon",2),p([w({type:Boolean,reflect:true})],Tt.prototype,"fullscreen",2),p([w({type:Boolean,reflect:true})],Tt.prototype,"initflow",2),p([w({type:String})],Tt.prototype,"text",2),p([v()],Tt.prototype,"ir",2),p([v()],Tt.prototype,"tl",2);var Pa=()=>{let o=globalThis.top??globalThis.parent??globalThis.self;try{return o.location.origin}catch(i){return console.warn("Unable to access top-level window location:",i),globalThis.location.origin}};var Du=o=>o.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),$a=(o,i="i")=>{let t=o.split("*").map(Du);return new RegExp(`^${t.join(".+")}$`,i)};var Vu=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],Fu=(o,i)=>window.getComputedStyle(o).getPropertyValue(i).trim(),Da=o=>{let i={};for(let t of Vu){let e=Fu(o,t);e&&(i[t]=e);}return i};var _u=["selected-files-change","toolbar-state-change"],Nu=o=>{if(!o||typeof o!="object"||!("type"in o))return false;let i=o.type;return !(typeof i!="string"||!_u.includes(i))},Pr=class{constructor(i,t){this.rr=new Map;this.ul=i=>{if(i.source!==this.qo)return;let t=i.data;if(!Nu(t))return;let e=this.rr.get(t.type);if(e)for(let r of e)r(t);};this.qo=i,this.cl=t,window.addEventListener("message",this.ul);}on(i,t){let e=this.rr.get(i)??new Set;this.rr.has(i)||this.rr.set(i,e),e.add(t);}send(i){let t=this.cl();this.qo.postMessage(i,t);}destroy(){window.removeEventListener("message",this.ul);}};function Va(o){let i=[];for(let[t,e]of Object.entries(o))e==null||typeof e=="string"&&e.length===0||i.push(`${t}=${encodeURIComponent(e)}`);return i.join("&")}var zu={[kt.GDRIVE]:"ngdrive"},gt=class extends R{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.activityType=y.activities.EXTERNAL;this.Ie=A();this.or=null;this.Wo=[];this.Zo=false;this.Xo=false;this.Yo=false;this.Qo=false;this.sr=false;this.Jo=false;this.ts="uc-hidden";this.dl=true;this.ro=()=>{for(let t of this.Wo){let e=this.$d(t),{filename:r}=t,{externalSourceType:s}=this.activityParams;this.api.addFileFromUrl(e,{fileName:r,source:s});}this.$["*currentActivity"]=y.activities.UPLOAD_LIST,this.modalManager?.open(y.activities.UPLOAD_LIST);};this.kt=()=>{this.historyBack();};this.zd=()=>{this.pt?.send({type:"select-all"});};this.Bd=()=>{this.pt?.send({type:"deselect-all"});};}get Pd(){if(!this.or)return "";let{selectedCount:t,total:e}=this.or;return this.l10n("selected-count",{count:t,total:e})}get activityParams(){let t=super.activityParams;if("externalSourceType"in t)return t;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:t}=this.activityParams;if(!t){this.modalManager?.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.pl();}}),this.sub("*currentActivityParams",()=>{this.isActivityActive&&(this.es(),this.pl());}),this.sub("*currentActivity",t=>{t!==this.activityType&&this.es();}),this.subConfigValue("multiple",t=>{this.sr=t;}),this.subConfigValue("localeName",()=>{this.hl();}),this.subConfigValue("externalSourcesEmbedCss",t=>{this.fl(t);});}$d(t){if(t.alternatives){let e=G(this.cfg.externalSourcesPreferredTypes);for(let r of e){let s=$a(r);for(let[n,a]of Object.entries(t.alternatives))if(s.test(n))return a}}return t.url}Dd(t){this.dl=t.isVisible;}async Vd(t){if(this.cfg.multiple!==t.isMultipleMode){console.error("Multiple mode mismatch");return}this.Fd(t.selectedCount,t.total),this.ts=t.isReady?"":"uc-hidden",this.Zo=t.isReady,this.Xo=t.isReady&&t.selectedFiles.length>0,this.sr=t.isMultipleMode&&t.total>0,this.Yo=t.selectedCount<t.total,this.Qo=t.selectedCount===t.total,this.Wo=t.selectedFiles??[],this.Jo=t.total>0;}ml(){this.fl(this.cfg.externalSourcesEmbedCss),this._d(),this.hl();}_d(){this.pt?.send({type:"set-theme-definition",theme:Da(this)});}fl(t){this.pt?.send({type:"set-embed-css",css:t});}hl(){this.pt?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName});}Nd(){let{pubkey:t,remoteTabSessionKey:e,socialBaseUrl:r,multiple:s}=this.cfg,{externalSourceType:n}=this.activityParams,a=zu[n]??n,c={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:t,images_only:"false",session_key:e,wait_for_theme:true,multiple:s.toString(),origin:this.cfg.topLevelOrigin||Pa(),debug:this.cfg.debug},d=new URL(`/window4/${a}`,r);return d.search=Va(c),d.toString()}Fd(t,e){this.or={selectedCount:t,total:e};}pl(){let t=document.createElement("iframe");t.src=this.Nd(),t.marginHeight=0,t.marginWidth=0,t.frameBorder="0",t.allowTransparency=true,t.addEventListener("load",this.ml.bind(this)),t.addEventListener("load",this.ml.bind(this)),this.Ie.value&&(this.Ie.value.innerHTML="",this.Ie.value.appendChild(t)),t.contentWindow&&(this.pt?.destroy(),this.pt=new Pr(t.contentWindow,()=>this.cfg.socialBaseUrl),this.pt.on("selected-files-change",this.Vd.bind(this)),this.pt.on("toolbar-state-change",this.Dd.bind(this)),this.vl());}es(){this.pt?.destroy(),this.pt=void 0,this.Ie.value&&(this.Ie.value.innerHTML=""),this.vl();}vl(){this.Wo=[],this.Zo=false,this.Xo=false,this.Yo=false,this.Qo=false,this.sr=false,this.Jo=false,this.ts="uc-hidden",this.or=null;}disconnectedCallback(){super.disconnectedCallback(),this.es();}render(){return g`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*historyBack"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ${I(this.Ie)} class="uc-iframe-wrapper"></div><div class="uc-toolbar" ?hidden=${!this.dl}><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this.kt}>${this.l10n("cancel")}</button><div class="uc-selection-status-box" ?hidden=${!this.sr}><span>${this.Pd}</span><button type="button" @click=${this.zd} ?hidden=${!this.Yo}>${this.l10n("select-all")}</button><button type="button" @click=${this.Bd} ?hidden=${!this.Qo}>${this.l10n("deselect-all")}</button></div><button type="button" class="uc-done-btn uc-primary-btn" @click=${this.ro} ?disabled=${!this.Xo} ?hidden=${!this.Jo} ><uc-spinner ?hidden=${this.Zo}></uc-spinner><span class=${this.ts}>${this.l10n("done")}</span></button></div></div>`}};p([v()],gt.prototype,"Wo",2),p([v()],gt.prototype,"Zo",2),p([v()],gt.prototype,"Xo",2),p([v()],gt.prototype,"Yo",2),p([v()],gt.prototype,"Qo",2),p([v()],gt.prototype,"sr",2),p([v()],gt.prototype,"Jo",2),p([v()],gt.prototype,"ts",2),p([v()],gt.prototype,"dl",2);var Dr=()=>{let o=[];return {stack:o,promiseReadJpegChunks:t=>new Promise((e,r)=>{let s=2,n=(c,d)=>{let u=new FileReader;u.addEventListener("load",()=>{d(new DataView(u.result));}),u.addEventListener("error",h=>{r(`Reader error: ${h}`);}),u.readAsArrayBuffer(c);},a=()=>n(t.slice(s,s+128),c=>{let d,u,h;for(d=u=0,h=c.byteLength;h>=0?u<h:u>h;d=h>=0?++u:--u)if(c.getUint8(d)===255){s+=d;break}l();}),l=()=>{let c=s;return n(t.slice(s,s+=4),d=>{if(d.byteLength!==4||d.getUint8(0)!==255){r("Corrupted");return}let u=d.getUint8(1);if(u===218){e(true);return}let h=d.getUint16(2)-2;return n(t.slice(s,s+=h),f=>{if(f.byteLength!==h){r("Corrupted");return}o.push({startPos:c,length:h,marker:u,view:f}),a();})})};FileReader&&DataView||r("Not Support"),n(t.slice(0,2),c=>{c.getUint16(0)!==65496&&r("Not jpeg"),a();});})}},Bu=async o=>{let i=[],{promiseReadJpegChunks:t,stack:e}=Dr();return await t(o),e.forEach(({marker:r,view:s})=>{r===226&&s.getUint32(0)===1229144927&&s.getUint32(4)===1347571526&&s.getUint32(8)===1229735168&&i.push(s);}),i},_a=async(o,i,t)=>{{let e=[],r=[],{promiseReadJpegChunks:s,stack:n}=Dr();await s(o),n.forEach(c=>{if(c.marker===i)return e.push(c.startPos),r.push(c.length)});let a=[o.slice(0,2)];for(let c of t){let d=new DataView(new ArrayBuffer(4));d.setUint16(0,65280+i),d.setUint16(2,c.byteLength+2),a.push(d.buffer),a.push(c);}let l=2;for(let c=0;c<e.length;c++)e[c]>l&&a.push(o.slice(l,e[c])),l=e[c]+r[c]+4;return a.push(o.slice(l,o.size)),new Blob(a,{type:o.type})}};var Na=(o,i)=>_a(o,226,i.map(t=>t.buffer)),Hu=async o=>{try{return await Na(o,[])}catch(i){throw new Error(`Failed to strip ICC profile: ${i}`)}},ju=(o,i,t)=>new Promise((e,r)=>{let s=n=>{if(!n){r("Failed to convert canvas to blob");return}e(n);};o.toBlob(s,i,t),o.width=o.height=1;}),gi=()=>{let o=document.createElement("canvas"),i=o.getContext("2d");return {canvas:o,ctx:i}},Ku=o=>{let{ctx:t,canvas:e}=gi();e.width=e.height=50,t.drawImage(o,0,0,50,50);let r=t.getImageData(0,0,50,50).data;e.width=e.height=1;for(let s=3;s<r.length;s+=4)if(r[s]<254)return true;return false},Gu=async o=>{let i=null,{promiseReadJpegChunks:t,stack:e}=Dr();return await t(o),e.forEach(({marker:r,view:s})=>{if(!i&&r===225&&s.byteLength>=14&&s.getUint32(0)===1165519206&&s.getUint16(4)===0){i=s;return}}),i},qu="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",$r,Wu=()=>new Promise(o=>{if($r!==void 0)o($r);else {let i=new Image;i.addEventListener("load",()=>{$r=i.naturalWidth<i.naturalHeight,i.src="//:0",o($r);}),i.src=qu;}}),Zu=(o,i)=>{let t,e,r,s;if(!o||o.byteLength<14||o.getUint32(0)!==1165519206||o.getUint16(4)!==0)return;if(o.getUint16(6)===18761)e=true;else if(o.getUint16(6)===19789)e=false;else return;if(o.getUint16(8,e)!==42)return;r=8+o.getUint32(10,e);let n=o.getUint16(r-2,e);for(t=0,s=n;s>=0?t<s:t>s;s>=0?++t:--t){if(o.byteLength<r+10)return;o.getUint16(r,e)===274&&i(r+8,e),r+=12;}},Xu=(o,i)=>{Zu(o,(t,e)=>o.setUint16(t,i,e));},Qu=async(o,i,t)=>(t&&Xu(i,1),_a(o,225,[i.buffer])),Yu=(o,i)=>new Promise((t,e)=>{i&&(o.src=i),o.complete?t(o):(o.addEventListener("load",()=>{t(o);}),o.addEventListener("error",()=>{e(new Error("Failed to load image. Probably not an image."));}));}),Ju=o=>Yu(new Image,o),td=[1,3],ed=[192,193,194,195,197,198,199,201,202,203,205,206,207],Fa={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},id=async o=>{let i=false,{promiseReadJpegChunks:t,stack:e}=Dr();return await t(o).then(()=>(e.forEach(({marker:r,view:s})=>{if(!i&&ed.indexOf(r)>=0){let n=s.getUint8(5);td.indexOf(n)<0&&(i=true);}}),i)).catch(()=>i)},za=(o,i)=>{let t={};return (...e)=>{let r=i(e,t);return r in t?t[r]:t[r]=o(...e)}},Ba=(o,i)=>{let[t]=o,e=Object.keys(i).map(r=>parseInt(r,10)).sort((r,s)=>r-s);for(let r=0;r<e.length;r++){let s=e[r],n=!!i[s];if(s>t&&n||s<t&&!n)return s}return t},oe={R:55,G:110,B:165,A:255},rd=`rgba(${oe.R}, ${oe.G}, ${oe.B}, ${oe.A/255})`,Ha=(o,i)=>{try{let t=[o-1,i-1,1,1],{canvas:e,ctx:r}=gi();e.width=1,e.height=1;let{canvas:s,ctx:n}=gi();s.width=o,s.height=i,n&&(n.fillStyle=rd,n.fillRect(...t),r.drawImage(s,o-1,i-1,1,1,0,0,1,1));let a=r&&r.getImageData(0,0,1,1).data,l=!1;return a&&(l=a[0]===oe.R&&a[1]===oe.G&&a[2]===oe.B&&a[3]===oe.A),s.width=s.height=1,l}catch{return console.error(`Failed to test for max canvas size of ${o}x${i}.`),false}};function ja(o){return (...i)=>new Promise(t=>{setTimeout(()=>{let e=o(...i);t(e);},0);})}var od=ja(za(Ha,Ba)),sd=ja(za(Ha,Ba)),Ka=async(o,i)=>{let t=Fa.squareSide.find(n=>n*n>=o*i),e=Fa.dimension.find(n=>n>=o&&n>=i);if(!t||!e)throw new Error("Not supported");let[r,s]=await Promise.all([od(t,t),sd(e,1)]);if(r&&s)return true;throw new Error("Not supported")},Ga=async(o,i,t)=>{try{let{ctx:e,canvas:r}=gi();return r.width=i,r.height=t,e.imageSmoothingQuality="high",e.drawImage(o,0,0,i,t),o instanceof HTMLImageElement&&(o.src="//:0"),o instanceof HTMLCanvasElement&&(o.width=o.height=1),r}catch(e){throw new Error("Canvas resize error",{cause:e})}},nd=({img:o,targetW:i,targetH:t})=>Ga(o,i,t),ad=function({sourceW:o,targetW:i,targetH:t,step:e}){let r=[],s=i,n=t;do r.push([s,n]),s=Math.round(s/e),n=Math.round(n/e);while(s<o*e);return r.reverse()},ld=({img:o,sourceW:i,targetW:t,targetH:e,step:r})=>{let s=ad({sourceW:i,targetW:t,targetH:e,step:r});return s.reduce((n,[a,l],c)=>n.then(d=>Ka(a,l).then(()=>Ga(d,a,l)).catch(()=>{if(c===s.length-1)throw new Error("Not supported");return d})),Promise.resolve(o))},cd=()=>/iPad|iPhone|iPod/.test(navigator.platform)?true:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),ud=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),hs=.71,dd=(o,i)=>{if(o.width*hs*o.height*hs<i.size)throw new Error("Not required");let t=o.width,e=o.height,r=t/e,s=Math.floor(Math.sqrt(i.size*r)),n=Math.floor(i.size/Math.sqrt(i.size*r));return Ka(s,n).then(()=>{let{ctx:a}=gi();return "imageSmoothingQuality"in a&&!cd()&&!ud?nd({img:o,targetW:s,targetH:n}):ld({img:o,sourceW:t,targetW:s,targetH:n,step:hs})}).catch(()=>Promise.reject("Not supported"))},qa=async(o,i)=>{try{if(await id(o))throw new Error("Should skipped");let e=await Promise.allSettled([Gu(o),Wu(),Bu(o)]),s=!e.some(b=>b.status==="rejected"),[n,a,l]=e,c=await Hu(o).catch(()=>o),d=await Ju(URL.createObjectURL(c));URL.revokeObjectURL(d.src);let u=await dd(d,i),h="image/jpeg",f=i?.quality||.8;!s&&Ku(u)&&(h="image/png",f=void 0);let m=await ju(u,h,f);if(s&&n.status==="fulfilled"&&n.value){let b=n.value,x=a.status==="fulfilled"?a.value:!1;m=await Qu(m,b,x);}return s&&l.status==="fulfilled"&&l.value.length>0&&(m=await Na(m,l.value)),m}catch(t){let e;throw t instanceof Error&&(e=t.message),typeof t=="string"&&(e=t),new Error(`Failed to shrink image. ${e?`Message: "${e}".`:""}`,{cause:t})}};var pd=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,Wa=o=>{if(typeof o!="string")return false;let i=pd.exec(o.toLocaleLowerCase())??[];if(i.length===0)return false;let t=Number(i[1])*Number(i[2]),e=16384*16384;return t>e?(console.warn(`Shrinked size can not be larger than ${Math.floor(e/1e3/1e3)}MP. You have set ${i[1]}x${i[2]} (${Math.ceil(t/1e3/100)/10}MP).`),false):{quality:i[3]?Number(i[3])/100:void 0,size:t}};var q=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),H=class H extends Ne{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.gl=true;this.uid="";this.rs="";this.os="";this.ss="";this.ot=0;this.yl=false;this.ns="";this.bl=false;this.wl=false;this.xl=false;this.El=false;this.Tl=false;this.nr=false;this.Cl="";this.Al=false;this.Hd=this.withEntry(t=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"edit-file",node:this.tagName}}}),this.$["*currentActivityParams"]={internalId:t.uid},this.modalManager?.open(y.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=y.activities.CLOUD_IMG_EDIT;});this.jd=()=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uid&&this.uploadCollection.remove(this.uid);};this.Kd=()=>{this.Sl();};this.w=P(()=>this.kl(),100);this.qd=this.withEntry(Be((t,e)=>{let r=t.getValue("errors")?.[0]?.message??"",s=t.getValue("source"),n=t.getValue("externalUrl"),a=e===q.FINISHED,l=e===q.UPLOADING,c=e===q.QUEUED_UPLOADING,d=e===q.QUEUED_VALIDATION,u=e===q.VALIDATION,h=t.getValue("fileName"),f="";r?f="":!a&&n&&s&&Object.values(kt).includes(s)&&(f=this.l10n("waiting-for",{source:this.l10n(`src-type-${s}`)})),this.ss=f,this.os=r,this.yl=l||c||d||u,this.ot=d||u?0:t.getValue("uploadProgress"),this.Cl=h?this.l10n("a11y-file-item-status",{fileName:h,status:this.l10n(e?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()}):"";},100));this.Sl=this.withEntry(async t=>{if(!this.uploadCollection.read(t.uid)||t.getValue("fileInfo")||t.getValue("isUploading")||t.getValue("errors").length>0||t.getValue("isValidationPending"))return;let e=this.cfg.multiple?this.cfg.multipleMax:1;if(!(e&&this.uploadCollection.size>e)){t.setMultipleValues({isUploading:true,errors:[],isQueuedForUploading:true}),this.w();try{let r=new AbortController;t.setValue("abortController",r);let s=async()=>{t.setValue("isQueuedForUploading",!1);let a=t.getValue("file");if(a instanceof File&&this.cfg.imageShrink)try{let u=Wa(this.cfg.imageShrink);u?a=await qa(a,u):console.warn("Image shrink settings are invalid, skipping shrinking");}catch{}let l=a||t.getValue("externalUrl")||t.getValue("uuid");if(!l)throw new Error("No file input");let d={...await this.getUploadClientOptions(),fileName:t.getValue("fileName")??void 0,source:t.getValue("source")??void 0,onProgress:u=>{if(u.isComputable){let h=u.value*100;t.setValue("uploadProgress",h);}},signal:r.signal,metadata:await this.getMetadataFor(t.uid)};return this.debugPrint("upload options",l,d),fo(l,d)},n=await this.$["*uploadQueue"].add(s);t.setMultipleValues({fileInfo:n,isQueuedForUploading:!1,isUploading:!1,fileName:n.originalFilename,fileSize:n.size,isImage:n.isImage??!1,mimeType:n.contentInfo?.mime?.mime??n.mimeType,uuid:n.uuid,cdnUrl:t.getValue("cdnUrl")??n.cdnUrl,cdnUrlModifiers:t.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:t.getValue("source")??null}),t===this.entry&&this.w();}catch(r){this.telemetryManager.sendEventError(r,"file upload. Failed to upload file"),r instanceof Ht&&r.isCancel?t.setMultipleValues({isUploading:false,uploadProgress:0}):r instanceof de?t.setMultipleValues({isUploading:false,uploadProgress:0,uploadError:r}):(console.error("Unknown upload error",r),t.setMultipleValues({isUploading:false,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:r})})),t===this.entry&&this.w();}}});}kl(){let t=this.entry;if(!t)return;let e=q.IDLE;t.getValue("errors").length>0?e=q.FAILED:t.getValue("isQueuedForUploading")?e=q.QUEUED_UPLOADING:t.getValue("isQueuedForValidation")?e=q.QUEUED_VALIDATION:t.getValue("isValidationPending")?e=q.VALIDATION:t.getValue("isUploading")?e=q.UPLOADING:t.getValue("fileInfo")&&(e=q.FINISHED),this.Gd(t,e);}Gd(t,e){e===q.FAILED?this.ns="badge-error":e===q.FINISHED&&(this.ns="badge-success"),e===q.UPLOADING&&(this.El=false,this.removeAttribute("focused")),this.wl=e===q.FAILED,this.xl=e===q.UPLOADING,this.bl=e===q.FINISHED,this.Tl=!!(this.cfg.useCloudImageEditor&&t.getValue("isImage")&&t.getValue("cdnUrl")),this.qd(e);}reset(){super.reset(),this.w.cancel();}_e(t){let[e]=t;e&&e.isIntersecting&&!this.Al&&(this.gl=false,this.Al=true);}Ol(t){this.reset();let e=this.uploadCollection?.read(t);this.entry=e,e&&(this.subEntry("isQueuedForValidation",()=>{this.w();}),this.subEntry("isValidationPending",()=>{this.w();}),this.subEntry("uploadProgress",()=>{this.w();}),this.subEntry("isQueuedForUploading",()=>{this.w();}),this.subEntry("fileName",r=>{this.rs=r||e.getValue("externalUrl")||this.l10n("file-no-name"),this.w();}),this.subEntry("externalUrl",r=>{this.rs=e.getValue("fileName")||r||this.l10n("file-no-name");}),this.subEntry("fileInfo",()=>{this.w();}),this.subEntry("errors",()=>this.w()),this.subEntry("isUploading",()=>this.w()),this.subEntry("fileSize",()=>this.w()),this.subEntry("mimeType",()=>this.w()),this.subEntry("isImage",()=>this.w()),this.kl());}Il(t){if(this.cfg.filesViewMode==="list"){this.nr=true;return}this.nr=t;}willUpdate(t){super.willUpdate(t),t.has("uid")&&this.Ol(this.uid);}initCallback(){super.initCallback(),this.Ol(this.uid),this.subConfigValue("useCloudImageEditor",()=>this.w()),this.subConfigValue("filesViewMode",t=>{this.Il(this.cfg.gridShowFileNames),this.setAttribute("mode",t);}),this.subConfigValue("gridShowFileNames",t=>{this.Il(t);}),this.onclick=()=>{H.activeInstances.forEach(t=>{t===this?t.setAttribute("focused",""):t.removeAttribute("focused");});},this.sub("*uploadTrigger",t=>{this.entry&&!t.has(this.entry.uid)||setTimeout(()=>this.isConnected&&this.Sl());}),H.activeInstances.add(this);}connectedCallback(){super.connectedCallback(),this.s=new window.IntersectionObserver(this._e.bind(this),{threshold:[0,1]}),this.s.observe(this);}disconnectedCallback(){super.disconnectedCallback(),this.s?.disconnect(),H.activeInstances.delete(this),this.reset();}static{this.activeInstances=new Set;}shouldUpdate(t){return this.gl?false:super.shouldUpdate(t)}render(){return g`<div class="uc-inner" ?finished=${this.bl} ?uploading=${this.xl} ?failed=${this.wl} ?focused=${this.El}><uc-thumb .uid=${this.uid} .badgeIcon=${this.ns}></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" aria-label=${this.Cl}><span class="uc-file-name" ?hidden=${!this.nr}>${this.rs}</span><span class="uc-file-error" ?hidden=${!this.os}>${this.os}</span><span class="uc-file-hint" ?hidden=${!this.ss}>${this.ss}</span></div><div class="uc-file-actions"><button type="button" @click=${this.Hd} ?hidden=${!this.Tl} title=${this.l10n("file-item-edit-button")} aria-label=${this.l10n("file-item-edit-button")} class="uc-edit-btn uc-mini-btn" ><uc-icon name="edit-file"></uc-icon></button><button type="button" @click=${this.jd} title=${this.l10n("file-item-remove-button")} aria-label=${this.l10n("file-item-remove-button")} class="uc-remove-btn uc-mini-btn" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" @click=${this.Kd}><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" .value=${this.ot} .visible=${this.yl} ?hasFileName=${this.nr}></uc-progress-bar></div>`}};p([v()],H.prototype,"gl",2),p([w({type:String,attribute:false})],H.prototype,"uid",2),p([v()],H.prototype,"rs",2),p([v()],H.prototype,"os",2),p([v()],H.prototype,"ss",2),p([v()],H.prototype,"ot",2),p([v()],H.prototype,"yl",2),p([v()],H.prototype,"ns",2),p([v()],H.prototype,"bl",2),p([v()],H.prototype,"wl",2),p([v()],H.prototype,"xl",2),p([v()],H.prototype,"El",2),p([v()],H.prototype,"Tl",2),p([v()],H.prototype,"nr",2),p([v()],H.prototype,"Cl",2);var fs=H;var yi=class extends R{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.dropzone=true;this.Ml="upload-file";this.Wd=()=>{this.api.initFlow();};}static{this.styleAttrs=[...super.styleAttrs,"uc-simple-btn"];}initCallback(){super.initCallback(),this.subConfigValue("multiple",t=>{this.Ml=t?"upload-files":"upload-file";});}render(){return g`<uc-drop-area .disabled=${!this.dropzone}><button type="button" @click=${this.Wd}><uc-icon name="upload"></uc-icon><span>${this.l10n(this.Ml)}</span>${this.yield("")}<div class="uc-visual-drop-area">${this.l10n("drop-files-here")}</div></button></uc-drop-area>`}};p([w({attribute:"dropzone",type:Boolean})],yi.prototype,"dropzone",2),p([v()],yi.prototype,"Ml",2);var Za="<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.715-.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'/></symbol><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></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-mobile-photo-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 24 24' id='uc-icon-mobile-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 24 24' id='uc-icon-ngdrive' 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-onedrive' 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>";var Nt=class extends E{constructor(){super(...arguments);this.init$=en(this);}static{this.styleAttrs=["uc-wgt-common"];}initCallback(){super.initCallback(),this.a11y?.registerBlock(this);}render(){return g`${wr(Za)}`}};var Vr=class extends Nt{constructor(){super();this.headless=false;this.init$={...this.init$,"*solution":this.tagName};}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"];}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:$.INIT_SOLUTION});}render(){return g` ${super.render()}<uc-simple-btn ?hidden=${this.headless}></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]}>${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};p([w({type:Boolean})],Vr.prototype,"headless",2);var ms=class extends et{static{this.styleAttrs=[...super.styleAttrs,"uc-wgt-common"];}constructor(){super(),this.init$={...this.init$,"*solution":this.tagName};}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:$.INIT_SOLUTION}),this.a11y?.registerBlock(this);}};var Fr=class extends Nt{constructor(){super();this.Ll=false;this.kt=()=>{if(this.Ul){let t=this.$["*historyBack"];t?.();return}this.Rl&&(this.$["*currentActivity"]=y.activities.UPLOAD_LIST);};this.init$={...this.init$,"*solution":this.tagName};}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"];}get Ul(){let t=this.$["*history"];return !t||t.length<=1?false:t[t.length-1]!==y.activities.START_FROM}get Rl(){let t=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(t)&&t.length>0}as(){return this.getCssData("--cfg-init-activity")||y.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:$.INIT_SOLUTION});let t=this.as();this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=t);}),this.sub("*uploadList",e=>{Array.isArray(e)&&e.length>0&&this.$["*currentActivity"]===t&&(this.$["*currentActivity"]=y.activities.UPLOAD_LIST);}),this.sub("*history",()=>{this.Ll=this.Ul||this.Rl;});}render(){return g` ${super.render()}<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this.kt} ?hidden=${!this.Ll} >${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`}};p([v()],Fr.prototype,"Ll",2);var vs="active",_r="",Ee=class extends Nt{constructor(){super();this.ls=false;this.ar=false;this.lr=_r;this.cs=_r;this.De=t=>{t.id===y.activities.CLOUD_IMG_EDIT&&(this.lr=vs),this.$["*currentActivity"]===y.activities.UPLOAD_LIST&&(this.lr=vs,this.ar=true);let e=this.$["*uploadList"];(!e||e.length<=0)&&(this.cs=vs);};this.Ve=t=>{t.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=y.activities.UPLOAD_LIST,this.ar=false),t.id===y.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=y.activities.UPLOAD_LIST);};this.init$={...this.init$,"*solution":this.tagName};}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"];}as(){return this.getCssData("--cfg-init-activity")||y.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:$.INIT_SOLUTION});let t=this.as();this.sub("*currentActivity",e=>{e===y.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),e||(this.$["*currentActivity"]=t);}),this.sub("*uploadList",e=>{Array.isArray(e)&&e.length>0?(this.$["*currentActivity"]=y.activities.UPLOAD_LIST,this.cs=_r):(this.lr=_r,this.ar=false,this.$["*currentActivity"]=t);}),this.subConfigValue("confirmUpload",e=>{e!==false&&(this.cfg.confirmUpload=false);}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e),this.subConfigValue("multiple",r=>{e==="grid"?(r?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.ls=!r):(this.style.removeProperty("--uc-grid-col"),this.ls=false);});}),this.modalManager?.subscribe(j.OPEN,this.De),this.modalManager?.subscribe(j.CLOSE,this.Ve);}disconnectedCallback(){super.disconnectedCallback(),this.modalManager?.unsubscribe(j.OPEN,this.De),this.modalManager?.unsubscribe(j.CLOSE,this.Ve);}render(){return g` ${super.render()}<uc-start-from ?hidden=${this.ar} class=${this.cs}><uc-drop-area ?single=${this.ls} initflow clickable tabindex="0" ><span>${this.l10n("choose-file")}</span></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list class=${this.lr}></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]} >${this.l10n("start-from-cancel")}</button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};p([v()],Ee.prototype,"ls",2),p([v()],Ee.prototype,"ar",2),p([v()],Ee.prototype,"lr",2),p([v()],Ee.prototype,"cs",2);/*! For license information please see uc-file-uploader-regular.min.js.LEGAL.txt */
8
+ export{y as ActivityBlock,Yo as ActivityHeader,Yr as BaseComponent,E as Block,Et as BtnUi,F as CameraSource,ms as CloudImageEditor,Mr as CloudImageEditorActivity,et as CloudImageEditorBlock,Rr as Config,Zo as Copyright,xr as CropFrame,N as Data,Tt as DropArea,Cr as EditorAspectRatioButtonControl,Ar as EditorCropButtonControl,re as EditorFilterControl,is as EditorFreeformButtonControl,kr as EditorImageCropper,os as EditorImageFader,Or as EditorOperationControl,ss as EditorScroller,Sr as EditorSlider,dt as EditorToolbar,gt as ExternalSource,kt as ExternalUploadSource,fs as FileItem,Fr as FileUploaderInline,Ee as FileUploaderMinimal,Vr as FileUploaderRegular,Wo as FormInput,oi as Icon,Uo as Img,Ir as LineLoaderUi,Do as Modal,j as ModalEvents,Xt as PACKAGE_NAME,Qt as PACKAGE_VERSION,mi as PresenceToggle,di as ProgressBar,pi as ProgressBarCommon,Fe as Select,yi as SimpleBtn,_t as SliderUi,Nt as SolutionBlock,_e as SourceBtn,vr as SourceList,Xo as Spinner,Jo as StartFrom,ze as Thumb,Rt as UID,ts as UploadCtxProvider,xt as UploadList,z as UploadSource,R as UploaderBlock,yr as UrlSource,Jr as defineComponents,Ns as defineLocale,bl as loadFileUploaderFrom,Ye as toKebabCase};