(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 a=o.trim().toLowerCase();if(a===""){return c.NO_ACCEPT}if(a.startsWith("image/")){return c.IMAGE_ACCEPT}if(a.startsWith("video/")){return c.VIDEO_ACCEPT}if(a.startsWith("audio/")){return c.AUDIO_ACCEPT}if(a.startsWith(".")){a=a.substring(1)}if(e.includes(a)){return c.IMAGE_ACCEPT}if(n.includes(a)){return c.VIDEO_ACCEPT}if(t.includes(a)){return c.AUDIO_ACCEPT}if(i.includes(a)){return c.ARCHIVE_ACCEPT}if(s.includes(a)){return c.PDF_ACCEPT}if(r.includes(a)){return c.DOC_ACCEPT}if(C.includes(a)){return c.APPLE_ACCEPT}return c.UNKNOWN_ACCEPT}function a(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 u(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(!u(t[n])&&n!==e){return false}}return true}function E(t){if(t.length<2){return false}for(let e=0;e<t.length;e++){if(!u(t[e])){return false}}return t[0]==="."}function A(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 l(t){const e=t.split(",");const n=[];for(const t of e){const e=t.trim();if(E(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=a(n)}let i=false;if(t.files&&t.files.length>0){i=true}n=n?n:"";return{hasMultiple:t.hasAttribute("multiple"),acceptType:e,mimeTypes:A(n),fileExtensions:l(n),hasSelectedFile:i,documentContainsInput:document.contains(t)}}function T(t,e){try{const n=window.webkit;delete window["webkit"];window.webkit.messageHandlers[t].postMessage(e);window.webkit=n}catch(t){}}const p="ChooseFileHandler";function _(t){if(!t.target||!(t.target instanceof HTMLInputElement)){return}const e=P(t.target);if(e){T(p,e)}}function d(){window.addEventListener("click",_,{capture:true,passive:true})}d()})();