/*! For license information please see wp-media.js.LICENSE.txt */
!function(){"use strict";var e={react:function(e){e.exports=window.React},"@elementor/query":function(e){e.exports=window.elementorV2.query},"@elementor/utils":function(e){e.exports=window.elementorV2.utils}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=function(e,t){for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};!function(){n.r(o),n.d(o,{getMediaAttachment:function(){return c},useWpMediaAttachment:function(){return p},useWpMediaFrame:function(){return w}});var e=n("@elementor/query"),t=n("@elementor/utils"),r=n("react"),i=(0,t.createError)({code:"wp_media_not_available",message:"`wp.media` is not available, make sure the `media-models` handle is set in the dependencies array"}),a=(0,t.createError)({code:"wp_plupload_settings_not_available",message:"`_wpPluploadSettings` is not available, make sure a wp media uploader is open"}),u=window,l=()=>{if(!u.wp?.media)throw new i;return u.wp.media};function s(e){const{filesizeInBytes:t,filesizeHumanReadable:n,author:o,authorName:r,...i}=e;return{...i,filesize:{inBytes:t,humanReadable:n},author:{id:parseInt(o),name:r}}}async function c({id:e}){if(!e)return null;const t=l().attachment(e),n=t.toJSON();if("url"in n)return s(n);try{return s(await t.fetch())}catch{return null}}function p(t){return(0,e.useQuery)({queryKey:["wp-attachment",t],queryFn:()=>c({id:t}),enabled:!!t})}var d=window,f=()=>{if(!d._wpPluploadSettings)throw new a;return d._wpPluploadSettings},m=["avif","bmp","gif","ico","jpe","jpeg","jpg","png","webp"];function w(e){const t=(0,r.useRef)();return(0,r.useEffect)((()=>()=>{y(t.current)}),[]),{open:(n={})=>{y(t.current),t.current=function({onSelect:e,multiple:t,types:n,selected:o,title:r,mode:i="browse",allowedExtensions:a}){const u=l()({title:r,multiple:t,library:{type:n}}).on("open",(()=>{!function(e){e.uploader.uploader.param("uploadTypeCaller","elementor-wp-media-upload")}(u),function(e,t="browse"){e.content.mode(t)}(u,i),function(e,t){const n=("number"==typeof t?[t]:t)?.filter((e=>!!e)).map((e=>l().attachment(e)));e.state().get("selection").set(n||[])}(u,o)})).on("close",(()=>y(u))).on("insert select",(()=>function(e,t,n){const o=e.state().get("selection").toJSON().map(s);n(t?o:o[0])}(u,t,e)));return function(e,t){const n=f().defaults.filters.mime_types?.[0]?.extensions;e.on("ready",(()=>{f().defaults.filters.mime_types=[{extensions:b(t)}]})),e.on("close",(()=>{f().defaults.filters.mime_types=n?[{extensions:n}]:[]}))}(u,a),u}({...e,...n}),t.current?.open()}}}function y(e){e?.detach(),e?.remove()}function b(e){let t=[...m];return e?t=e:function(){const e=window;return Boolean(e.elementorCommon.config.filesUpload.unfilteredFiles)}()&&t.push("svg"),t.join(",")}}(),(window.elementorV2=window.elementorV2||{}).wpMedia=o}();