/*! VDM Uikit Uploader v2.0.5 | https://git.vdm.dev/joomla/uikit | (c) 2020 - 2024 Llewellyn van der Merwe | MIT License */ !function(){"use strict";function t(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function e(t,e,n,r,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(o,a){var i=t.apply(n,r);function c(t){e(i,o,a,c,u,"next",t)}function u(t){e(i,o,a,c,u,"throw",t)}c(void 0)}))}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(e,n){return e.get(t(e,n))}function a(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function i(e,n,r){return e.set(t(e,n),r),r}function c(t,e){for(var n=0;n=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;T(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:A(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function f(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}var h,p=new WeakMap,v=new WeakMap,y=new WeakMap,m=new WeakMap,g=u((function t(e){var c=this;r(this,t),a(this,p,void 0),a(this,v,{}),s(this,"set",(function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;o(v,c)[t]=o(v,c)[t]||{},"object"===d(e)?Object.assign(o(v,c)[t],e):o(v,c)[t][e]=n})),s(this,"get",(function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=o(v,c)[t];return a?null===n?a:null!==(e=a[n])&&void 0!==e?e:r:r})),s(this,"init",function(){var t=n(l().mark((function t(e,n){var r,a,i,u,s=arguments;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>2&&void 0!==s[2]&&s[2],!o(v,c)[e]||r){t.next=4;break}return t.abrupt("return");case 4:return t.prev=4,a=o(m,c).call(c,o(p,c),n),i=!1,t.next=9,o(y,c).call(c,a);case 9:if(u=t.sent,"true"===i&&console.log("Data fetched:",u),null==u||!u.data||"object"!==d(u.data)){t.next=15;break}c.set(e,u.data),t.next=17;break;case 15:if(null==u||!u.error){t.next=17;break}throw new Error(u.error||"An error occurred during the file type request.");case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(4),"true"===DEBUG&&console.error("Error during initialization:",t.t0);case 22:case"end":return t.stop()}}),t,null,[[4,19]])})));return function(e,n){return t.apply(this,arguments)}}()),a(this,y,function(){var t=n(l().mark((function t(e){var n;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});case 2:if((n=t.sent).ok){t.next=6;break}return t.abrupt("return");case 6:return t.next=8,n.json();case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),s(this,"getParams",(function(t){var e={};return Array.isArray(t)&&0!==t.length?(t.forEach((function(t){var n=document.getElementById(t);n&&(e[t]=n.value)})),e):e})),a(this,m,(function(t,e){var n=t.includes("?")?"&":"?";return"".concat(t).concat(n,"guid=").concat(e)})),i(p,this,e)})),w=new WeakMap,b=u((function t(){var e=this;r(this,t),s(this,"set",function(){var t=n(l().mark((function t(n,r,a){var i,c,u;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=o(w,e).call(e,n,a),t.next=4,fetch(i,{method:"GET",headers:{"Content-Type":"application/json"}});case 4:if((c=t.sent).ok){t.next=8;break}return t.abrupt("return");case 8:return t.next=10,c.json();case 10:(u=t.sent).data&&""!==u.data.trim()?r.innerHTML=u.data:r.innerHTML="",t.next=18;break;case 14:t.prev=14,t.t0=t.catch(0),r.innerHTML="";case 18:case"end":return t.stop()}}),t,null,[[0,14]])})));return function(e,n,r){return t.apply(this,arguments)}}()),a(this,w,(function(t,e){var n=t.includes("?")?"&":"?",r=new URLSearchParams(e);return"".concat(t).concat(n).concat(r.toString())}))})),x=new WeakMap,E=new WeakMap,k=new WeakMap,L=new WeakMap,I=new WeakMap,j=new WeakMap,O=new WeakMap,P=u((function t(e,c,u){var s=this;r(this,t),a(this,x,void 0),a(this,E,void 0),a(this,k,void 0),a(this,L,{}),a(this,I,(function(t,e){var r=e.bar,a=e.typeId,i=e.endpoint,c=e.successId,u=e.errorId,f=e.allowedFormatId,d=e.fileTypeId,h=e.displayId,p=e.displayEndpoint,v=document.getElementById(a),y={message:"error.message",status:"danger",timeout:7e3},m=function(){var e=n(l().mark((function e(n){return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n&&n.length>1)){e.next=10;break}return e.prev=1,e.next=4,o(j,s).call(s,t,n,r,i,c,u,f,d,h,p);case 4:e.next=10;break;case 6:e.prev=6,e.t0=e.catch(1),y.message=e.t0.message,o(k,s).notification(y);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(t){return e.apply(this,arguments)}}();v&&(v.addEventListener("change",n(l().mark((function t(){return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,m(v.value);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),m(v.value).catch((function(t){y.message=t.message,o(k,s).notification(y)})))})),a(this,j,function(){var t=n(l().mark((function t(e,n,r,a,i,c,u,f,d,h){var p,v,y,m,g,w,b;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,p=e+n,t.next=4,o(x,s).init(p,n);case 4:v=document.getElementById(r),y=document.getElementById(i),m=document.getElementById(c),g=document.getElementById(d),w=document.getElementById(u),b=document.getElementById(f),o(L,s)[e]&&o(L,s)[e].$destroy(!0),y&&y.setAttribute("hidden","hidden"),m&&m.setAttribute("hidden","hidden"),w&&(w.textContent=o(x,s).get(p,"allow_span","")),b&&(w.textContent=o(x,s).get(p,"file_type_span","file")),h&&g&&o(E,s).set(h,g,o(x,s).getParams(o(x,s).get(p,"display_fields"))),o(L,s)[e]=o(k,s).upload("#".concat(e),{url:o(O,s).call(s,a,n),multiple:!0,allow:function(){return o(x,s).get(p,"allow")||!1},name:function(){return o(x,s).get(p,"name")||"files"},beforeSend:function(t){t.data.params=o(x,s).getParams(o(x,s).get(p,"param_fields"))},beforeAll:function(){},load:function(){},error:function(t){m&&(m.removeAttribute("hidden"),m.textContent="Upload failed.")},complete:function(){y&&(y.removeAttribute("hidden"),y.textContent="Upload completed successfully.")},loadStart:function(t){v&&(v.removeAttribute("hidden"),v.max=t.total,v.value=t.loaded)},progress:function(t){v&&(v.max=t.total,v.value=t.loaded)},loadEnd:function(t){v&&(v.max=t.total,v.value=t.loaded)},completeAll:function(){v&&setTimeout((function(){v.setAttribute("hidden","hidden"),m&&y.setAttribute("hidden","hidden"),m&&m.setAttribute("hidden","hidden")}),1e3),h&&g&&o(E,s).set(h,g,o(x,s).getParams(o(x,s).get(p,"display_fields")))}}),t.next=22;break;case 19:throw t.prev=19,t.t0=t.catch(0),t.t0;case 22:case"end":return t.stop()}}),t,null,[[0,19]])})));return function(e,n,r,o,a,i,c,u,s,l){return t.apply(this,arguments)}}()),a(this,O,(function(t,e){var n=t.includes("?")?"&":"?";return"".concat(t).concat(n,"guid=").concat(e)})),i(x,this,new g(c)),i(E,this,new b),i(k,this,u),Object.keys(e).forEach((function(t){var n=e[t];o(I,s).call(s,t,n)}))})),_=["endpoint","targetClass"];h=window,document.addEventListener("DOMContentLoaded",(function(){var t;t=h.UIkit?h.UIkit:require("uikit").default;var e=h.vdmUploaderConfig||{},n=e.endpoint,r=e.targetClass;if(function(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.includes(r))continue;n[r]=t[r]}return n}(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r0&&new P(a,n,t)}}))}();