(function(){const t=["aac","flac","m4a","mp3","ogg","pcm","wav","wma"];const e=["apng","avif","gif","jpg","jpeg","jfif","pjpeg","pjp","png","svg","webp"];const n=["avi","flv","mkv","mov","mp4","mpeg","webm","wmv"];const i=["7z","cab","gz","rar","tar","zip"];const s=["pdf"];const r=["doc","docx","xls","xlsx","ppt","pptx","key","numbers","pages","epub","txt"];const c=["pkpass","mobileprovision"];var C;(function(t){t[t["NO_ACCEPT"]=0]="NO_ACCEPT";t[t["MIXED_ACCEPT"]=1]="MIXED_ACCEPT";t[t["UNKNOWN_ACCEPT"]=2]="UNKNOWN_ACCEPT";t[t["IMAGE_ACCEPT"]=3]="IMAGE_ACCEPT";t[t["VIDEO_ACCEPT"]=4]="VIDEO_ACCEPT";t[t["AUDIO_ACCEPT"]=5]="AUDIO_ACCEPT";t[t["ARCHIVE_ACCEPT"]=6]="ARCHIVE_ACCEPT";t[t["PDF_ACCEPT"]=7]="PDF_ACCEPT";t[t["DOC_ACCEPT"]=8]="DOC_ACCEPT";t[t["APPLE_ACCEPT"]=9]="APPLE_ACCEPT"})(C||(C={}));function o(o){let u=o.trim().toLowerCase();if(u===""){return C.NO_ACCEPT}if(u.startsWith("image/")){return C.IMAGE_ACCEPT}if(u.startsWith("video/")){return C.VIDEO_ACCEPT}if(u.startsWith("audio/")){return C.AUDIO_ACCEPT}if(u.startsWith(".")){u=u.substring(1)}if(e.includes(u)){return C.IMAGE_ACCEPT}if(n.includes(u)){return C.VIDEO_ACCEPT}if(t.includes(u)){return C.AUDIO_ACCEPT}if(i.includes(u)){return C.ARCHIVE_ACCEPT}if(s.includes(u)){return C.PDF_ACCEPT}if(r.includes(u)){return C.DOC_ACCEPT}if(c.includes(u)){return C.APPLE_ACCEPT}return C.UNKNOWN_ACCEPT}function u(t){const e=t.split(",");let n=C.NO_ACCEPT;for(const t of e){const e=o(t);if(n===C.NO_ACCEPT||n===C.UNKNOWN_ACCEPT){n=e;continue}if(n===e||e===C.UNKNOWN_ACCEPT||e===C.NO_ACCEPT){continue}return C.MIXED_ACCEPT}return n}function a(t){const e=t.charCodeAt(0);if(e<32||e>127){return false}switch(t){case"(":case")":case"<":case">":case"@":case",":case";":case":":case"\\":case'"':case"/":case"[":case"]":case"?":case"=":case"{":case"}":case String.fromCharCode(32):case String.fromCharCode(9):case String.fromCharCode(127):return false;default:return true}}function f(t){const e=t.indexOf("/");if(e===-1||e===t.length-1||e===0){return false}for(let n=0;n<t.length;n++){if(!a(t[n])&&n!==e){return false}}return true}function l(t){if(t.length<2){return false}for(let e=0;e<t.length;e++){if(!a(t[e])){return false}}return t[0]==="."}function E(t){const e=t.split(",");const n=[];for(const t of e){const e=t.trim();if(f(e)){n.push(e)}}return n.join(",")}function A(t){const e=t.split(",");const n=[];for(const t of e){const e=t.trim();if(l(e)){n.push(e)}}return n.join(",")}function P(t){if(t.type.toLowerCase()!=="file"){return null}let e=C.NO_ACCEPT;let n=t.getAttribute("accept");if(n){e=u(n)}let i=false;if(t.files&&t.files.length>0){i=true}n=n?n:"";return{hasMultiple:t.hasAttribute("multiple"),acceptType:e,mimeTypes:E(n),fileExtensions:A(n),hasSelectedFile:i,documentContainsInput:document.contains(t)}}function p(t,e){try{const n=window.webkit;delete window["webkit"];window.webkit.messageHandlers[t].postMessage(e);window.webkit=n}catch(t){}}const T="ChooseFileHandler";let _=true;function d(t){if(!_){return}if(!t.target||!(t.target instanceof HTMLInputElement)){return}const e=t.target;const n=P(e);if(n){p(T,n)}}function g(){window.addEventListener("click",d,{capture:true,passive:true})}g();function m(){const t=HTMLInputElement.prototype.click;HTMLInputElement.prototype.click=function(){_=false;t.call(this);_=true;const e=P(this);if(e){p(T,e)}}}m()})();