"use strict";var y=Object.defineProperty,P=Object.defineProperties;var g=Object.getOwnPropertyDescriptors;var f=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var F=(t,e,i)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,u=(t,e)=>{for(var i in e||(e={}))z.call(e,i)&&F(t,i,e[i]);if(f)for(var i of f(e))M.call(e,i)&&F(t,i,e[i]);return t},n=(t,e)=>P(t,g(e));var d=require("../../../../common/vendor.js");function l(t,e){return["[object Object]","[object File]"].includes(Object.prototype.toString.call(t))?Object.keys(t).reduce((i,c)=>(e.includes(c)||(i[c]=t[c]),i),{}):{}}function T(t){return t.tempFiles.map(e=>n(u({},l(e,["path"])),{type:"image",url:e.path,thumb:e.path,size:e.size}))}function w(t){return[n(u({},l(t,["tempFilePath","thumbTempFilePath","errMsg"])),{type:"video",url:t.tempFilePath,thumb:t.thumbTempFilePath,size:t.size})]}function k(t){return t.tempFiles.map(e=>n(u({},l(e,["fileType","thumbTempFilePath","tempFilePath"])),{type:t.type,url:e.tempFilePath,thumb:t.type==="video"?e.thumbTempFilePath:e.tempFilePath,size:e.size}))}function b(t){return t.tempFiles.map(e=>n(u({},l(e,["path"])),{url:e.path,size:e.size}))}function O({accept:t,multiple:e,capture:i,compressed:c,maxDuration:p,sizeType:r,camera:m,maxCount:h}){return new Promise((a,o)=>{switch(t){case"image":d.index.chooseImage({count:e?Math.min(h,9):1,sourceType:i,sizeType:r,success:s=>a(T(s)),fail:o});break;case"media":wx.chooseMedia({count:e?Math.min(h,9):1,sourceType:i,maxDuration:p,sizeType:r,camera:m,success:s=>a(k(s)),fail:o});break;case"video":d.index.chooseVideo({sourceType:i,compressed:c,maxDuration:p,camera:m,success:s=>a(w(s)),fail:o});break;case"file":wx.chooseMessageFile({count:e?h:1,type:t,success:s=>a(b(s)),fail:o});break;default:wx.chooseMessageFile({count:e?h:1,type:"all",success:s=>a(b(s)),fail:o})}})}exports.chooseFile=O;
