/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
// ***************************
// js.compressed/blueimp/jquery.fileupload.min.js
// ***************************
/*
 jQuery File Upload Plugin
 https://github.com/blueimp/jQuery-File-Upload

 Copyright 2010, Sebastian Tschan
 https://blueimp.net

 Licensed under the MIT license:
 https://opensource.org/licenses/MIT
*/
(function(d){"function"===typeof define&&define.amd?define(["jquery","jquery-ui/ui/widget"],d):"object"===typeof exports?d(require("jquery"),require("./vendor/jquery.ui.widget")):d(window.jQuery)})(function(d){function u(a){var b="dragover"===a;return function(c){c.dataTransfer=c.originalEvent&&c.originalEvent.dataTransfer;var e=c.dataTransfer;e&&-1!==d.inArray("Files",e.types)&&!1!==this._trigger(a,d.Event(a,{delegatedEvent:c}))&&(c.preventDefault(),b&&(e.dropEffect="copy"))}}d.support.fileInput=
!(/(Android (1\.[0156]|2\.[01]))|(Windows Phone (OS 7|8\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1\.0|2\.[05]|3\.0))/.test(window.navigator.userAgent)||d('<input type="file"/>').prop("disabled"));d.support.xhrFileUpload=!(!window.ProgressEvent||!window.FileReader);d.support.xhrFormDataFileUpload=!!window.FormData;d.support.blobSlice=window.Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice);d.widget("blueimp.fileupload",{options:{dropZone:d(document),
pasteZone:void 0,fileInput:void 0,replaceFileInput:!0,paramName:void 0,singleFileUploads:!0,limitMultiFileUploads:void 0,limitMultiFileUploadSize:void 0,limitMultiFileUploadSizeOverhead:512,sequentialUploads:!1,limitConcurrentUploads:void 0,forceIframeTransport:!1,redirect:void 0,redirectParamName:void 0,postMessage:void 0,multipart:!0,maxChunkSize:void 0,uploadedBytes:void 0,recalculateProgress:!0,progressInterval:100,bitrateInterval:500,autoUpload:!0,messages:{uploadedBytes:"Uploaded bytes exceed file size"},
i18n:function(a,b){a=this.messages[a]||a.toString();b&&d.each(b,function(b,e){a=a.replace("{"+b+"}",e)});return a},formData:function(a){return a.serializeArray()},add:function(a,b){if(a.isDefaultPrevented())return!1;(b.autoUpload||!1!==b.autoUpload&&d(this).fileupload("option","autoUpload"))&&b.process().done(function(){b.submit()})},processData:!1,contentType:!1,cache:!1,timeout:0},_specialOptions:["fileInput","dropZone","pasteZone","multipart","forceIframeTransport"],_blobSlice:d.support.blobSlice&&
function(){return(this.slice||this.webkitSlice||this.mozSlice).apply(this,arguments)},_BitrateTimer:function(){this.timestamp=Date.now?Date.now():(new Date).getTime();this.bitrate=this.loaded=0;this.getBitrate=function(a,b,c){var e=a-this.timestamp;if(!this.bitrate||!c||e>c)this.bitrate=1E3/e*(b-this.loaded)*8,this.loaded=b,this.timestamp=a;return this.bitrate}},_isXHRUpload:function(a){return!a.forceIframeTransport&&(!a.multipart&&d.support.xhrFileUpload||d.support.xhrFormDataFileUpload)},_getFormData:function(a){if("function"===
d.type(a.formData))return a.formData(a.form);if(d.isArray(a.formData))return a.formData;if("object"===d.type(a.formData)){var b=[];d.each(a.formData,function(a,e){b.push({name:a,value:e})});return b}return[]},_getTotal:function(a){var b=0;d.each(a,function(a,e){b+=e.size||1});return b},_initProgressObject:function(a){var b={loaded:0,total:0,bitrate:0};a._progress?d.extend(a._progress,b):a._progress=b},_initResponseObject:function(a){var b;if(a._response)for(b in a._response)a._response.hasOwnProperty(b)&&
delete a._response[b];else a._response={}},_onProgress:function(a,b){if(a.lengthComputable){var c=Date.now?Date.now():(new Date).getTime();if(!(b._time&&b.progressInterval&&c-b._time<b.progressInterval&&a.loaded!==a.total)){b._time=c;var e=Math.floor(a.loaded/a.total*(b.chunkSize||b._progress.total))+(b.uploadedBytes||0);this._progress.loaded+=e-b._progress.loaded;this._progress.bitrate=this._bitrateTimer.getBitrate(c,this._progress.loaded,b.bitrateInterval);b._progress.loaded=b.loaded=e;b._progress.bitrate=
b.bitrate=b._bitrateTimer.getBitrate(c,e,b.bitrateInterval);this._trigger("progress",d.Event("progress",{delegatedEvent:a}),b);this._trigger("progressall",d.Event("progressall",{delegatedEvent:a}),this._progress)}}},_initProgressListener:function(a){var b=this,c=a.xhr?a.xhr():d.ajaxSettings.xhr();c.upload&&(d(c.upload).on("progress",function(c){var e=c.originalEvent;c.lengthComputable=e.lengthComputable;c.loaded=e.loaded;c.total=e.total;b._onProgress(c,a)}),a.xhr=function(){return c})},_deinitProgressListener:function(a){a=
a.xhr?a.xhr():d.ajaxSettings.xhr();a.upload&&d(a.upload).off("progress")},_isInstanceOf:function(a,b){return Object.prototype.toString.call(b)==="[object "+a+"]"},_initXHRData:function(a){var b=this,c=a.files[0],e=a.multipart||!d.support.xhrFileUpload,g="array"===d.type(a.paramName)?a.paramName[0]:a.paramName;a.headers=d.extend({},a.headers);a.contentRange&&(a.headers["Content-Range"]=a.contentRange);e&&!a.blob&&this._isInstanceOf("File",c)||(a.headers["Content-Disposition"]='attachment; filename="'+
encodeURI(c.uploadName||c.name)+'"');if(!e)a.contentType=c.type||"application/octet-stream",a.data=a.blob||c;else if(d.support.xhrFormDataFileUpload){if(a.postMessage){var f=this._getFormData(a);a.blob?f.push({name:g,value:a.blob}):d.each(a.files,function(b,c){f.push({name:"array"===d.type(a.paramName)&&a.paramName[b]||g,value:c})})}else b._isInstanceOf("FormData",a.formData)?f=a.formData:(f=new FormData,d.each(this._getFormData(a),function(a,b){f.append(b.name,b.value)})),a.blob?f.append(g,a.blob,
c.uploadName||c.name):d.each(a.files,function(c,e){(b._isInstanceOf("File",e)||b._isInstanceOf("Blob",e))&&f.append("array"===d.type(a.paramName)&&a.paramName[c]||g,e,e.uploadName||e.name)});a.data=f}a.blob=null},_initIframeSettings:function(a){var b=d("<a></a>").prop("href",a.url).prop("host");a.dataType="iframe "+(a.dataType||"");a.formData=this._getFormData(a);a.redirect&&b&&b!==location.host&&a.formData.push({name:a.redirectParamName||"redirect",value:a.redirect})},_initDataSettings:function(a){this._isXHRUpload(a)?
(this._chunkedUpload(a,!0)||(a.data||this._initXHRData(a),this._initProgressListener(a)),a.postMessage&&(a.dataType="postmessage "+(a.dataType||""))):this._initIframeSettings(a)},_getParamName:function(a){var b=d(a.fileInput),c=a.paramName;c?d.isArray(c)||(c=[c]):(c=[],b.each(function(){var a=d(this),b=a.prop("name")||"files[]";for(a=(a.prop("files")||[1]).length;a;)c.push(b),--a}),c.length||(c=[b.prop("name")||"files[]"]));return c},_initFormSettings:function(a){a.form&&a.form.length||(a.form=d(a.fileInput.prop("form")),
a.form.length||(a.form=d(this.options.fileInput.prop("form"))));a.paramName=this._getParamName(a);a.url||(a.url=a.form.prop("action")||location.href);a.type=(a.type||"string"===d.type(a.form.prop("method"))&&a.form.prop("method")||"").toUpperCase();"POST"!==a.type&&"PUT"!==a.type&&"PATCH"!==a.type&&(a.type="POST");a.formAcceptCharset||(a.formAcceptCharset=a.form.attr("accept-charset"))},_getAJAXSettings:function(a){a=d.extend({},this.options,a);this._initFormSettings(a);this._initDataSettings(a);
return a},_getDeferredState:function(a){return a.state?a.state():a.isResolved()?"resolved":a.isRejected()?"rejected":"pending"},_enhancePromise:function(a){a.success=a.done;a.error=a.fail;a.complete=a.always;return a},_getXHRPromise:function(a,b,c){var e=d.Deferred(),g=e.promise();b=b||this.options.context||g;!0===a?e.resolveWith(b,c):!1===a&&e.rejectWith(b,c);g.abort=e.promise;return this._enhancePromise(g)},_addConvenienceMethods:function(a,b){var c=this,e=function(a){return d.Deferred().resolveWith(c,
a).promise()};b.process=function(a,f){if(a||f)b._processQueue=this._processQueue=(this._processQueue||e([this])).then(function(){return b.errorThrown?d.Deferred().rejectWith(c,[b]).promise():e(arguments)}).then(a,f);return this._processQueue||e([this])};b.submit=function(){"pending"!==this.state()&&(b.jqXHR=this.jqXHR=!1!==c._trigger("submit",d.Event("submit",{delegatedEvent:a}),this)&&c._onSend(a,this));return this.jqXHR||c._getXHRPromise()};b.abort=function(){if(this.jqXHR)return this.jqXHR.abort();
this.errorThrown="abort";c._trigger("fail",null,this);return c._getXHRPromise(!1)};b.state=function(){if(this.jqXHR)return c._getDeferredState(this.jqXHR);if(this._processQueue)return c._getDeferredState(this._processQueue)};b.processing=function(){return!this.jqXHR&&this._processQueue&&"pending"===c._getDeferredState(this._processQueue)};b.progress=function(){return this._progress};b.response=function(){return this._response}},_getUploadedBytes:function(a){return(a=(a=(a=a.getResponseHeader("Range"))&&
a.split("-"))&&1<a.length&&parseInt(a[1],10))&&a+1},_chunkedUpload:function(a,b){a.uploadedBytes=a.uploadedBytes||0;var c=this,e=a.files[0],g=e.size,f=a.uploadedBytes,k=a.maxChunkSize||g,h=this._blobSlice,m=d.Deferred(),p=m.promise(),l;if(!(this._isXHRUpload(a)&&h&&(f||("function"===d.type(k)?k(a):k)<g))||a.data)return!1;if(b)return!0;if(f>=g)return e.error=a.i18n("uploadedBytes"),this._getXHRPromise(!1,a.context,[null,"error",e.error]);var n=function(){var b=d.extend({},a),p=b._progress.loaded;b.blob=
h.call(e,f,f+("function"===d.type(k)?k(b):k),e.type);b.chunkSize=b.blob.size;b.contentRange="bytes "+f+"-"+(f+b.chunkSize-1)+"/"+g;c._trigger("chunkbeforesend",null,b);c._initXHRData(b);c._initProgressListener(b);l=(!1!==c._trigger("chunksend",null,b)&&d.ajax(b)||c._getXHRPromise(!1,b.context)).done(function(e,k,h){f=c._getUploadedBytes(h)||f+b.chunkSize;p+b.chunkSize-b._progress.loaded&&c._onProgress(d.Event("progress",{lengthComputable:!0,loaded:f-b.uploadedBytes,total:f-b.uploadedBytes}),b);a.uploadedBytes=
b.uploadedBytes=f;b.result=e;b.textStatus=k;b.jqXHR=h;c._trigger("chunkdone",null,b);c._trigger("chunkalways",null,b);f<g?n():m.resolveWith(b.context,[e,k,h])}).fail(function(a,e,d){b.jqXHR=a;b.textStatus=e;b.errorThrown=d;c._trigger("chunkfail",null,b);c._trigger("chunkalways",null,b);m.rejectWith(b.context,[a,e,d])}).always(function(){c._deinitProgressListener(b)})};this._enhancePromise(p);p.abort=function(){return l.abort()};n();return p},_beforeSend:function(a,b){0===this._active&&(this._trigger("start"),
this._bitrateTimer=new this._BitrateTimer,this._progress.loaded=this._progress.total=0,this._progress.bitrate=0);this._initResponseObject(b);this._initProgressObject(b);b._progress.loaded=b.loaded=b.uploadedBytes||0;b._progress.total=b.total=this._getTotal(b.files)||1;b._progress.bitrate=b.bitrate=0;this._active+=1;this._progress.loaded+=b.loaded;this._progress.total+=b.total},_onDone:function(a,b,c,e){var g=e._progress.total,f=e._response;e._progress.loaded<g&&this._onProgress(d.Event("progress",
{lengthComputable:!0,loaded:g,total:g}),e);f.result=e.result=a;f.textStatus=e.textStatus=b;f.jqXHR=e.jqXHR=c;this._trigger("done",null,e)},_onFail:function(a,b,c,e){var d=e._response;e.recalculateProgress&&(this._progress.loaded-=e._progress.loaded,this._progress.total-=e._progress.total);d.jqXHR=e.jqXHR=a;d.textStatus=e.textStatus=b;d.errorThrown=e.errorThrown=c;this._trigger("fail",null,e)},_onAlways:function(a,b,c,e){this._trigger("always",null,e)},_onSend:function(a,b){b.submit||this._addConvenienceMethods(a,
b);var c=this,e,g,f=c._getAJAXSettings(b),k=function(){c._sending+=1;f._bitrateTimer=new c._BitrateTimer;return e=e||((g||!1===c._trigger("send",d.Event("send",{delegatedEvent:a}),f))&&c._getXHRPromise(!1,f.context,g)||c._chunkedUpload(f)||d.ajax(f)).done(function(a,b,e){c._onDone(a,b,e,f)}).fail(function(a,b,e){c._onFail(a,b,e,f)}).always(function(a,b,e){c._deinitProgressListener(f);c._onAlways(a,b,e,f);--c._sending;--c._active;if(f.limitConcurrentUploads&&f.limitConcurrentUploads>c._sending)for(a=
c._slots.shift();a;){if("pending"===c._getDeferredState(a)){a.resolve();break}a=c._slots.shift()}0===c._active&&c._trigger("stop")})};this._beforeSend(a,f);if(this.options.sequentialUploads||this.options.limitConcurrentUploads&&this.options.limitConcurrentUploads<=this._sending){if(1<this.options.limitConcurrentUploads){var h=d.Deferred();this._slots.push(h);b=h.then(k)}else b=this._sequence=this._sequence.then(k,k);b.abort=function(){g=[void 0,"abort","abort"];return e?e.abort():(h&&h.rejectWith(f.context,
g),k())};return this._enhancePromise(b)}return k()},_onAdd:function(a,b){var c=this,e=!0,g=d.extend({},this.options,b),f=b.files,k=f.length,h=g.limitMultiFileUploads,m=g.limitMultiFileUploadSize,p=g.limitMultiFileUploadSizeOverhead,l=0,n=this._getParamName(g),t=0;if(!k)return!1;m&&void 0===f[0].size&&(m=void 0);if((g.singleFileUploads||h||m)&&this._isXHRUpload(g))if(g.singleFileUploads||m||!h)if(!g.singleFileUploads&&m){var q=[];var r=[];for(g=0;g<k;g+=1)if(l+=f[g].size+p,g+1===k||l+f[g+1].size+p>
m||h&&g+1-t>=h)q.push(f.slice(t,g+1)),l=n.slice(t,g+1),l.length||(l=n),r.push(l),t=g+1,l=0}else r=n;else for(q=[],r=[],g=0;g<k;g+=h)q.push(f.slice(g,g+h)),l=n.slice(g,g+h),l.length||(l=n),r.push(l);else q=[f],r=[n];b.originalFiles=f;d.each(q||f,function(g,f){var h=d.extend({},b);h.files=q?f:[f];h.paramName=r[g];c._initResponseObject(h);c._initProgressObject(h);c._addConvenienceMethods(a,h);return e=c._trigger("add",d.Event("add",{delegatedEvent:a}),h)});return e},_replaceFileInput:function(a){var b=
a.fileInput,c=b.clone(!0),e=b.is(document.activeElement);a.fileInputClone=c;d("<form></form>").append(c)[0].reset();b.after(c).detach();e&&c.focus();d.cleanData(b.unbind("remove"));this.options.fileInput=this.options.fileInput.map(function(a,e){return e===b[0]?c[0]:e});b[0]===this.element[0]&&(this.element=c)},_handleFileTreeEntry:function(a,b){var c=this,e=d.Deferred(),g=[],f=function(b){b&&!b.entry&&(b.entry=a);e.resolve([b])},k=function(d){c._handleFileTreeEntries(d,b+a.name+"/").done(function(a){e.resolve(a)}).fail(f)},
h=function(){m.readEntries(function(a){a.length?(g=g.concat(a),h()):k(g)},f)};b=b||"";if(a.isFile)a._file?(a._file.relativePath=b,e.resolve(a._file)):a.file(function(a){a.relativePath=b;e.resolve(a)},f);else if(a.isDirectory){var m=a.createReader();h()}else e.resolve([]);return e.promise()},_handleFileTreeEntries:function(a,b){var c=this;return d.when.apply(d,d.map(a,function(a){return c._handleFileTreeEntry(a,b)})).then(function(){return Array.prototype.concat.apply([],arguments)})},_getDroppedFiles:function(a){a=
a||{};var b=a.items;return b&&b.length&&(b[0].webkitGetAsEntry||b[0].getAsEntry)?this._handleFileTreeEntries(d.map(b,function(a){var b;if(a.webkitGetAsEntry){if(b=a.webkitGetAsEntry())b._file=a.getAsFile();return b}return a.getAsEntry()})):d.Deferred().resolve(d.makeArray(a.files)).promise()},_getSingleFileInputFiles:function(a){a=d(a);var b=a.prop("webkitEntries")||a.prop("entries");if(b&&b.length)return this._handleFileTreeEntries(b);b=d.makeArray(a.prop("files"));if(b.length)void 0===b[0].name&&
b[0].fileName&&d.each(b,function(a,b){b.name=b.fileName;b.size=b.fileSize});else{a=a.prop("value");if(!a)return d.Deferred().resolve([]).promise();b=[{name:a.replace(/^.*\\/,"")}]}return d.Deferred().resolve(b).promise()},_getFileInputFiles:function(a){return a instanceof d&&1!==a.length?d.when.apply(d,d.map(a,this._getSingleFileInputFiles)).then(function(){return Array.prototype.concat.apply([],arguments)}):this._getSingleFileInputFiles(a)},_onChange:function(a){var b=this,c={fileInput:d(a.target),
form:d(a.target.form)};this._getFileInputFiles(c.fileInput).always(function(e){c.files=e;b.options.replaceFileInput&&b._replaceFileInput(c);!1!==b._trigger("change",d.Event("change",{delegatedEvent:a}),c)&&b._onAdd(a,c)})},_onPaste:function(a){var b=a.originalEvent&&a.originalEvent.clipboardData&&a.originalEvent.clipboardData.items,c={files:[]};b&&b.length&&(d.each(b,function(a,b){(a=b.getAsFile&&b.getAsFile())&&c.files.push(a)}),!1!==this._trigger("paste",d.Event("paste",{delegatedEvent:a}),c)&&
this._onAdd(a,c))},_onDrop:function(a){a.dataTransfer=a.originalEvent&&a.originalEvent.dataTransfer;var b=this,c=a.dataTransfer,e={};c&&c.files&&c.files.length&&(a.preventDefault(),this._getDroppedFiles(c).always(function(c){e.files=c;!1!==b._trigger("drop",d.Event("drop",{delegatedEvent:a}),e)&&b._onAdd(a,e)}))},_onDragOver:u("dragover"),_onDragEnter:u("dragenter"),_onDragLeave:u("dragleave"),_initEventHandlers:function(){this._isXHRUpload(this.options)&&(this._on(this.options.dropZone,{dragover:this._onDragOver,
drop:this._onDrop,dragenter:this._onDragEnter,dragleave:this._onDragLeave}),this._on(this.options.pasteZone,{paste:this._onPaste}));d.support.fileInput&&this._on(this.options.fileInput,{change:this._onChange})},_destroyEventHandlers:function(){this._off(this.options.dropZone,"dragenter dragleave dragover drop");this._off(this.options.pasteZone,"paste");this._off(this.options.fileInput,"change")},_destroy:function(){this._destroyEventHandlers()},_setOption:function(a,b){var c=-1!==d.inArray(a,this._specialOptions);
c&&this._destroyEventHandlers();this._super(a,b);c&&(this._initSpecialOptions(),this._initEventHandlers())},_initSpecialOptions:function(){var a=this.options;void 0===a.fileInput?a.fileInput=this.element.is('input[type="file"]')?this.element:this.element.find('input[type="file"]'):a.fileInput instanceof d||(a.fileInput=d(a.fileInput));a.dropZone instanceof d||(a.dropZone=d(a.dropZone));a.pasteZone instanceof d||(a.pasteZone=d(a.pasteZone))},_getRegExp:function(a){a=a.split("/");var b=a.pop();a.shift();
return new RegExp(a.join("/"),b)},_isRegExpOption:function(a,b){return"url"!==a&&"string"===d.type(b)&&/^\/.*\/[igm]{0,3}$/.test(b)},_initDataAttributes:function(){var a=this,b=this.options,c=this.element.data();d.each(this.element[0].attributes,function(e,d){e=d.name.toLowerCase();/^data-/.test(e)&&(e=e.slice(5).replace(/-[a-z]/g,function(a){return a.charAt(1).toUpperCase()}),d=c[e],a._isRegExpOption(e,d)&&(d=a._getRegExp(d)),b[e]=d)})},_create:function(){this._initDataAttributes();this._initSpecialOptions();
this._slots=[];this._sequence=this._getXHRPromise(!0);this._sending=this._active=0;this._initProgressObject(this);this._initEventHandlers()},active:function(){return this._active},progress:function(){return this._progress},add:function(a){var b=this;a&&!this.options.disabled&&(a.fileInput&&!a.files?this._getFileInputFiles(a.fileInput).always(function(c){a.files=c;b._onAdd(null,a)}):(a.files=d.makeArray(a.files),this._onAdd(null,a)))},send:function(a){if(a&&!this.options.disabled){if(a.fileInput&&
!a.files){var b=this,c=d.Deferred(),e=c.promise(),g,f;e.abort=function(){f=!0;if(g)return g.abort();c.reject(null,"abort","abort");return e};this._getFileInputFiles(a.fileInput).always(function(d){f||(d.length?(a.files=d,g=b._onSend(null,a),g.then(function(a,b,d){c.resolve(a,b,d)},function(a,b,d){c.reject(a,b,d)})):c.reject())});return this._enhancePromise(e)}a.files=d.makeArray(a.files);if(a.files.length)return this._onSend(null,a)}return this._getXHRPromise(!1,a&&a.context)}})});
;

// ***************************
// js.compressed/fileupload.js
// ***************************
vBulletin.precache("add_caption attach_files click_to_add_caption drop_files_here_to_upload enter_url_file error_uploading_image invalid_image_allowed_filetypes_are remove_all_photos_confirmation_message remove_all_photos_q upload upload_more uploading you_are_already_editing_continue".split(" "),[]);
vBulletin.upload=((a,p,r,v,K,F,C)=>{function w(b,e){a(".b-button--upload .js-upload-label",b).each((f,m)=>{f=a(m);m=f.data("default-text");m||(m=f.text(),f.data("default-text",m));f.text(void 0===e?m:r.get(e))})}async function L(b){b=await (await fetch(b)).blob();let e="dataurl"+String(Date.now()).slice(-6)+"."+b.type.split("/")[1];return new File([b],e)}async function M(b,e){return new Promise((f,m)=>{var c=new FormData,d=()=>m(Error("Upload Failed"));c.append("uploadFrom","newContent");c.append("files",
b);v.ajax({call:"/uploader/upload",data:c,success:function(k){for(var h of k)if(k=h.error){if(Array.isArray(k)||(k=[k]),k=[h.name,...k.map(g=>r.get(g))],0<k.length){C.openAlertDialog({title:r.get("upload"),message:k.join("<br />\n"),iconType:"warning"});d();return}}else{k=D(a(".b-content-entry-panel__content--attachment",e),h);f({upload:h,panelitem:k});return}d()},error_phrase:"error_uploading_image",after_error:d})})}function D(b,e){b=b.find(".js-attach-list");var f=a(".js-uploadFrom").val();e.name||
p.error("upload","unknown_error");var m=!1;if(e.name.match(/\.(gif|jpg|jpeg|jpe|png|bmp|webp)$/i)){var c=a("<img />").attr("src",pageData.baseurl+"/filedata/fetch?type=thumb&filedataid="+e.filedataid).addClass("b-attach-item__image");m=!0}else c=a("<span />").addClass("b-icon-fa b-icon-fa--16 fa-solid fa-file-lines");var d=b.find(".js-attach-item-sample").first().clone(!0);d.removeClass("js-attach-item-sample");d.find(".js-attach-item-image").append(c);d.find(".js-attach-item-filename").text(e.name);
d.append(a("<input />").attr({type:"hidden",name:"filedataids[]"}).val(e.filedataid)).append(a("<input />").attr({type:"hidden",name:"filenames[]"}).val(e.name));d.data({fileext:e.extension,filebasetype:e.basetype,filename:e.name,filedataid:e.filedataid,attachnodeid:0});e=(k,h)=>k.find(".js-attach-ctrl").filter((g,l)=>h.includes(a(l).data("action")));"signature"==f?(b.find(".js-attach-item").not(".js-attach-item-sample").remove(),e(d,["insert_image","insert_label"]).addClass("h-hide"),e(d,["insert"]).html(r.get("insert")).data("action",
"insert_sigpic").attr("data-action","insert_sigpic")):m||(e(d,["insert_image","insert_label"]).addClass("h-hide"),e(d,["insert"]).html(r.get("insert")));p.ckeditor.checkEnvironment()||e(d,["insert","insert_image","insert_label"]).addClass("h-hide");d.appendTo(b).removeClass("h-hide");b.removeClass("h-hide");return d}function E(b){function e(c){z(c,0<a(".photo-display .photo-item-wrapper:not(.h-hide)",c).length)}function f(c){c.length||(c=a("<form>"));let d=c.find('input[name="securitytoken"]');d.length||
(d=a('<input type="hidden" name="securitytoken" />'),c.append(d));d.val(pageData.securitytoken);return c.find(":input").filter((k,h)=>!a(h).parent().hasClass("js-photo-postdata")).serializeArray()}function m(c){var d=[["error_uploading_image"]];c&&0<c.files.length&&"acceptFileTypes"==c.files[0].error&&(d=[["invalid_image_allowed_filetypes_are"]]);v.showApiError(d,{},{title:"upload"})}console.log("Fileupload: vBulletin.upload.initializePhotoUpload");if(!b||0==b.length)if(b=a("body"),1<a(".js-photo-display",
b).length)return console.log("Fileupload: multiple upload forms, abort"),!1;a(".js-continue-button",b).offon("click",function(c){console.log("Fileupload: continue");var d=a(document).data("gallery-container"),k=d.find(".js-photo-postdata");c=k.closest(".js-contententry-form").find('input[name="nodeid"]');c=c.length&&c[0].value||0;var h={},g=a(this).closest(".js-photo-display"),l=[],n=0;k.empty();0<c&&p.gallery.clearCacheForNodeid(c);g.find(".photo-item-wrapper:not(.h-hide)").each(function(){var t=
a(this).find(".filedataid"),q=t.val();t=t.data("nodeid");var G=a.trim(a(this).find(".caption-box").val()),H=a.trim(a(this).find(".js-photo-title").val());a(this).removeClass("tmp-photo");"undefined"!==typeof t&&(a(this).removeClass("tmp-photo"),-1==a.inArray(t,A)&&A.push(t));n++;k.append(a("<input />").attr({type:"hidden",name:"filedataid[]"}).val(q)).append(a("<input />").attr({type:"hidden",name:"title_"+q}).val(H)).append(a("<input />").attr({type:"hidden",name:"caption_"+q}).val(G)).append(a("<input />").attr({type:"hidden",
name:"displayorder_"+q}).val(n));l.push({filedataid:q,caption:G,title:H,displayorder:n})});h.photocount=l.length;h.photos=l;h.isAjaxTemplateRenderWithData=!0;g.find(".photo-item-wrapper:hidden").remove();g.dialog("close");0<h.photos.length?(v.ajax({call:"/ajax/render/editor_gallery_photoblock",data:h,type:"POST",dataType:"json",success:function(t){var q=a(t.template);q.find(".b-gallery-thumbnail-list__aside").addClass("h-invisible");d.find(".js-gallery-content").removeClass("h-hide").find(".js-panel-content").empty().append(q);
setTimeout(function(){q.find(".b-gallery-thumbnail-list__aside").removeClass("h-invisible")},500);E(d);a(document).data("gallery-container",null)},silent:!0}),a(".js-edit-photos",d).removeClass("h-hide"),w(d,"upload_more")):(a(".js-panel-content",d).empty(),a(".js-edit-photos",d).addClass("h-hide"),w(d))});a(".js-edit-photos",b).offon("click",function(c){console.log("Fileupload: edit photos");a(document).data("gallery-container",a(this).closest(".b-content-entry-panel__content--gallery"));c=x(!1);
y(c.find(".photo-item-wrapper"));e(c);c.dialog("open");u(c);a(".b-button--upload",c).trigger("focus")});a(".js-cancel-button",b).offon("click",function(c){console.log("Fileupload: cancel");c=a(this).closest(".js-photo-display");var d=a(document).data("gallery-container");a(".photo-item-wrapper.tmp-photo",c).remove();a(".photo-item-wrapper",c).removeClass("h-hide");w(d,0<a(".js-slideshow--item",d).length?"upload_more":void 0);c.dialog("close")});a(".b-content-entry-panel__content--attachment",b).offon("click",
".js-upload-from-url",function(c){let d=a(this);C.openPromptDialogSimple({title:"enter_url_file",message:"",onClickOk:k=>{let h=d.parent().find(".js-upload-progress");h.removeClass("h-hide");v.ajax({call:"/uploader/url",data:{urlupload:k,attachment:1,uploadFrom:a(".js-uploadFrom",b).val()},skipdefaultsuccess:!0,complete:()=>{h.addClass("h-hide")},success:g=>{g.imageUrl&&($panel=a(".b-content-entry-panel__content--attachment"),g.name=g.filename,D($panel,g))},title_phrase:"error_uploading_image"})}});
return!1});a(".b-content-entry-panel__content--gallery, .js-profile-media-photoupload-dialog",b).fileupload({dropZone:"vb-self",dataType:"json",url:p.getAjaxBaseurl()+"/uploader/upload-photo",type:"POST",formData:c=>f(c.find(".b-content-entry-panel__content--gallery")),add:function(c,d){console.log("Fileupload: gallery add");c=a(this);a(document).data("gallery-container",c);c=x(!0);a(".js-upload-progress",c).removeClass("h-hide");w(c,"uploading");d.submit();a(".b-button--upload",c).trigger("focus")},
done:function(c,d){c=a(this);var k=d&&d.result&&d.result.errors&&0<d.result.errors.length;a(document).data("gallery-container",c);var h=x(!1);if(d&&d.result&&!k&&d.result.edit){d=a(d.result.edit);var g=a(".photo-display",h),l=h.parent();c=a(".photo-item-wrapper:not(.h-hide)",g).length;d.addClass("tmp-photo");0==(c+1)%3&&d.addClass("last-in-row");c+1>F.ATTACHLIMIT&&a(".js-attach-limit-warning",h).show();u(h);g.append(d);d.fadeIn("fast",function(){h.dialog("option","position",{of:window});l.hasClass("has-scrollbar")&&
g.animate({scrollTop:g[0].scrollHeight-g.height()},"fast")})}else d=k?d.result.errors[0]:"unknown_error",p.warning("upload",d)},fail:(c,d)=>{m(d)},always:function(c,d){c=x(!1);c.find(".js-upload-progress").addClass("h-hide");e(c)}});a(".b-content-entry-panel__content--attachment",b).fileupload({dropZone:"vb-self",dataType:"json",url:p.getAjaxBaseurl()+"/uploader/upload",type:"POST",previewAsCanvas:!1,autoUpload:!0,formData:c=>f(c.find(".b-content-entry-panel__content--attachment")),add:function(c,
d){console.log("Fileupload: attachments add");b.find(".js-upload-progress").removeClass("h-hide");d.submit()},done:function(c,d){c=[];var k=[],h={};if(d&&d.result)if(h=d.result,h.error)c=[h.error];else if(h.errors)c=h.errors;else for(var g of d.result)(d=g.error)?(Array.isArray(d)||(d=[d]),k.push(g.name,...d.map(l=>r.get(l)))):D(a(this),g);else c=[["invalid_server_response_please_try_again"]];0<c.length?v.showApiError(c,h,{title:"upload"}):0<k.length&&C.openAlertDialog({title:r.get("upload"),message:k.join("<br />\n"),
iconType:"warning"})},fail:(c,d)=>{m(d)},always:function(c,d){b.find(".js-upload-progress").addClass("h-hide")}});a(document).offon("click.photoadd",".js-photo-selector-continue",function(){console.log("Fileupload: continue 2");let c=a(this).closest(".js-photo-selector-container"),d={},k=c.data("selected-nodes")||{},h=c.data("selected-nodes-meta")||{};k.length?k.forEach(g=>{var l=h[g];if(l){const n=l.filedataid;l=l.title;d[g]={imgUrl:p.getAjaxBaseurl()+"/filedata/fetch?filedataid="+n+"&thumb=1",filedataid:n,
title:l}}}):c.find(".photo-item-wrapper").each(function(){var g=a(this).find(".filedataid"),l=g.data("nodeid");if(g.is(":checked")){g=g.val();var n=a.trim(a(this).find(".photo-title").text());d[l]={imgUrl:p.getAjaxBaseurl()+"/filedata/fetch?filedataid="+g+"&thumb=1",filedataid:g,title:n}}});a.isEmptyObject(d)||v.ajax({call:"/ajax/render/photo_item",data:{items:d,wrapperClass:"tmp-photo",isAjaxTemplateRenderWithData:!0},success:function(g){var l=x(!1),n=a(".photo-display",l);n.append(g.template);g=
a(".photo-item-wrapper:not(.h-hide)",n);y(g);z(l,0<g.length);u(l);l.dialog("option","position",{of:window});l.dialog("open")}});a(".photo-selector-galleries",c).tabs("destroy");c.dialog("close")});a(".js-photo-selector-cancel",b).offon("click",function(){console.log("Fileupload: cancel 2");a(document).data("gallery-container",null);var c=a(this).closest(".js-photo-selector-container");a(".photo-selector-galleries",c).tabs("destroy");c.dialog("close")})}function x(b,e){if(e&&0!=e.length)a(document).data("gallery-container",
e);else if(e=a(document).data("gallery-container"),!e)return a();if(e.hasClass("profile-media-photoupload-dialog")){var f=e;b&&(f.dialog("open"),u(f));return f}f=e.find(".js-photo-display");0==f.length?a(".js-photo-display").each(function(){if(a(this).data("associated-editor")==e.get(0))return f=a(this),!1}):(f.dialog({modal:!0,width:606,autoOpen:!1,showCloseButton:!1,closeOnEscape:!1,resizable:!1,showTitleBar:!1,dialogClass:"dialog-container upload-photo-dialog-container dialog-box"}),f.data("orig-width",
f.dialog("option","width")),f.data("associated-editor",e.get(0)),f.find(".b-form-input__file--hidden").prop("disabled",!1));b&&(f.dialog("open"),u(f));N(f);return f}function N(b){var e=b.find(".js-sortable-on-edit"),f=b.css("overflow")||"auto";e.length&&!e.data("sortable")&&e.sortable({forcePlaceholderSize:!1,placeholder:"photo-item-wrapper h-left sortable-placeholder",containment:"parent",tolerance:"pointer",start:function(m,c){a(".photo-item-wrapper:not(.h-hide)",e).removeClass("last-in-row");b.css("overflow",
"hidden")},update:function(m,c){m=a(".photo-item-wrapper:not(.h-hide)",e);y(m);z(b,0<m.length);u(b);b.css("overflow",f)}})}function u(b){var e=a(".photo-display",b),f=b.parent();e=a(".photo-item-wrapper:not(.h-hide)",e).length;!f.hasClass("has-scrollbar")&&6<=e&&(e=p.getScrollbarWidth(),f.addClass("has-scrollbar"),b.dialog("option","width",b.dialog("option","width")+e+11))}function y(b){b.removeClass("last-in-row").filter(":not(.h-hide)").filter(e=>2==e%3).addClass("last-in-row")}function z(b,e){a(".js-continue-button, .btnPhotoUploadSave",
b).toggle(e);w(b,e?"upload_more":void 0)}function O(){a(document).offon("click.removephoto",".photo-display .photo-item .js-remove-icon",function(){var b=a(this).closest(".photo-item-wrapper"),e=a(".filedataid",b).data("nodeid"),f=b.parents(".js-photo-display").last();"undefined"!==typeof e&&(e=a.inArray(e,A),-1!=e&&A.splice(e,1));b.addClass("h-hide");b=f.find(".photo-item-wrapper:not(.h-hide)");b.length<=F.ATTACHLIMIT&&a(".js-attach-limit-warning",f).hide();y(b);6>=b.length&&(f.parent().removeClass("has-scrollbar"),
f.dialog("option","width",f.data("orig-width")));z(f,0<b.length)});a(document).offon("blur.photocaption",".photo-display .photo-caption .caption-box",function(){a(this).scrollTop(0)});K.bindEditFormEventHandlers("gallery")}function P(){var b=jQuery.fn.fileupload;jQuery.fn.fileupload=function(){arguments&&arguments[0]&&arguments[0].dropZone&&"vb-self"==arguments[0].dropZone&&(arguments[0].dropZone=a(this));arguments&&arguments[0]&&arguments[0].dropZone&&arguments[0].dropZone.addClass("js-fileupload-dropzone");
return b.apply(this,arguments)}}function I(b){b&&b.each((e,f)=>{e=a(f);e.data("vb-dropzone-overlay-initialized")||(a("<div />").html(r.get("drop_files_here_to_upload")).addClass("h-hide-imp js-fileupload-dropzone-overlay fileupload-dropzone-overlay").appendTo(e),e.css("position","relative").data("vb-dropzone-overlay-initialized","1"))});a(".js-fileupload-dropzone-overlay").toggleClass("h-hide-imp",!b)}function Q(b){var e=a(".js-fileupload-dropzone"),f=e.filter(":visible"),m=e.filter(".b-content-entry-panel__content--attachment");
b.preventDefault();if(!(1>e.length)&&(0==f.length&&1==m.length&&(a(".js-content-entry").find(".js-toolbar-secondary .b-toolbar__item").filter(function(){return"b-content-entry-panel__content--attachment"==a(this).data("panel")}).trigger("click"),f=e.filter(":visible")),0<f.length)){I(f);a(".js-fileupload-dropzone-overlay").removeClass("fileupload-dropzone-overlay--active");let c=b.originalEvent.dataTransfer;c.dropEffect="none";c.effectAllowed="none";a(b.target).parents().each(function(){var d=a(this);
if(d.is(".js-fileupload-dropzone"))return d.find(".js-fileupload-dropzone-overlay").addClass("fileupload-dropzone-overlay--active"),c.dropEffect="copy",c.effectAllowed="copy",!1})}}function J(b){b.preventDefault();I(!1)}function R(){B&&(clearTimeout(B),B=0)}function S(b){var e=this;B=setTimeout(()=>{J.call(e,b)},200)}let A=[],B=0;a(()=>{P();a:{if("FormData"in window&&"FileReader"in window){var b=document.createElement("div");if("draggable"in b||"ondragstart"in b&&"ondrop"in b){b=!0;break a}}b=!1}b&&
(b=a(document),b.on("dragover.contentdragstart",Q),b.on("drop{0} dragend{0}".format(".contentdragstart"),J),b.on("dragenter{0} dragover{0}".format(".contentdragenter"),R),b.on("dragleave.contentdragenter",S));E();O()});return{uploadFile:async function(b,e){"string"==typeof b&&(b=await L(b));return M(b,e)},setUploadButtonText:w,initializePhotoUpload:E,getUploadedPhotosDlg:x,adjustPhotoDialogForScrollbar:u,relocateLastInRowClass:y}})(jQuery,vBulletin,vBulletin.phrase,vBulletin.ajaxtools,vBulletin.conversation,
vBulletin.contentEntryBox,vBulletin.dialogtools);
;

