/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@callstack/react-native-asset@3.1.0/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const fs=require("fs"),path=require("path"),copyAssetsIos=require("./copy-assets/ios"),cleanAssetsIos=require("./clean-assets/ios"),copyAssetsAndroid=require("./copy-assets/android"),cleanAssetsAndroid=require("./clean-assets/android"),getManifest=require("./manifest/index"),log=require("npmlog"),sha1File=require("sha1-file"),_=require("lodash"),getConfig=require("./get-config"),{fontTypes:fontTypes,imageTypes:imageTypes}=require("./file-types"),cwd=process.cwd(),unl=(e,t)=>void 0!==e?e:t,clearDuplicated=e=>_.uniqBy(e,(e=>path.parse(e.path).base)),filesToIgnore=[".DS_Store","Thumbs.db"],filterFilesToIgnore=({path:e})=>-1===filesToIgnore.indexOf(path.basename(e)),getAbsolute=({filePath:e,dirPath:t})=>path.isAbsolute(e)?e:path.resolve(t,e),getRelative=({filePath:e,dirPath:t})=>path.isAbsolute(e)?path.relative(t,e):e,filterFileByFilesWhichNotExists=(e,{normalizeAbsolutePathsTo:t})=>s=>{const{path:i,sha1:a}=s,o=getRelative({filePath:i,dirPath:t});return-1===e.map((e=>Object.assign({},e,{path:getRelative({filePath:e.path,dirPath:t})}))).findIndex((e=>{const{path:t,sha1:s}=e;return o===t&&a===s}))};let showAndroidRelinkingWarning=!1;const linkPlatform=({rootPath:e,shouldUnlink:t})=>({name:s,manifest:i,config:a,linkOptionsPerExt:o,otherLinkOptions:n,cleanAssets:r,copyAssets:l,assets:d})=>{let p=[];try{p=i.read().map((e=>Object.assign({},e,{path:e.path.split("/").join(path.sep)})))}catch(e){}let h=[];const f=t=>{const s=getAbsolute({filePath:t,dirPath:e});if(fs.lstatSync(s).isDirectory())fs.readdirSync(s).map((e=>path.resolve(s,e))).forEach(f);else{const e=sha1File(s);h=h.concat({path:s,sha1:e})}};d.forEach(f),h=clearDuplicated(h);[].concat(Object.keys(o).map((e=>({name:e,filter:({path:t})=>path.extname(t)===`.${e}`,options:o[e]})))).concat({name:"custom",filter:({path:e})=>-1===Object.keys(o).indexOf(path.extname(e).substr(1)),options:n}).forEach((({name:i,filter:o,options:n})=>{const d=p.filter(o).filter(filterFileByFilesWhichNotExists(h,{normalizeAbsolutePathsTo:e})),f=p.filter(o).filter((e=>e.shouldRelinkAndroidFonts)),c=h.filter(o).filter(filterFileByFilesWhichNotExists(p,{normalizeAbsolutePathsTo:e})).filter(filterFilesToIgnore);f.length>0&&(showAndroidRelinkingWarning=!0,log.info(null,`Relinking old ${i} assets from ${s} project to use XML resources`),r(f.map((({path:t})=>getAbsolute({filePath:t,dirPath:e}))),a,{...n,linkWithFontXMLFiles:!1},i),l(f.filter((e=>!d.some((t=>t.path===e.path)))).map((({path:e})=>e)),a,n,i)),t&&d.length>0&&(log.info(null,`Cleaning previously linked ${i} assets from ${s} project`),r(d.filter((e=>!f.some((t=>t.path===e.path)))).map((({path:t})=>getAbsolute({filePath:t,dirPath:e}))),a,n)),c.length>0&&(log.info(null,`Linking ${i} assets to ${s} project`),l(c.map((({path:e})=>e)),a,n))})),i.write(h.filter(filterFilesToIgnore).map((t=>Object.assign({},t,{path:path.relative(e,t.path).split(path.sep).join("/")}))))};module.exports=({rootPath:e=cwd,shouldUnlink:t=!0,platforms:s})=>{if(!fs.lstatSync(e).isDirectory())throw new Error(`'rootPath' must be a valid path, got ${e}`);if("boolean"!=typeof t)throw new Error("'shouldUnlink' must be a boolean, got "+typeof t);if([s.ios,s.android].find((({assets:e})=>!Array.isArray(e))))throw new Error("'platforms[\"platform\"].assets' must be an array");const i=path.isAbsolute(e)?e:path.resolve(cwd,e),a={ios:{enabled:unl(s.ios.enabled,!0),assets:s.ios.assets},android:{enabled:unl(s.android.enabled,!0),assets:s.android.assets}},o=getConfig({rootPath:i}),{android:{path:n},ios:{path:r}}=o,l={android:{path:path.resolve(n,"app","src","main","assets","fonts"),linkWithFontXMLFiles:!0},ios:{addFont:!0}},d=fontTypes.reduce(((e,t)=>({...e,[t]:l})),{}),p={android:{path:path.resolve(n,"app","src","main","res","drawable"),linkWithFontXMLFiles:!1},ios:{addFont:!1}},h={...d,...imageTypes.reduce(((e,t)=>({...e,[t]:p})),{}),mp3:{android:{path:path.resolve(n,"app","src","main","res","raw"),linkWithFontXMLFiles:!1},ios:{addFont:!1}}},f={android:{path:path.resolve(n,"app","src","main","assets","custom"),linkWithFontXMLFiles:!1},ios:{addFont:!1}};[{name:"iOS",enabled:a.ios.enabled,assets:a.ios.assets,manifest:getManifest(r,"ios"),config:o.ios,cleanAssets:cleanAssetsIos,copyAssets:copyAssetsIos,linkOptionsPerExt:{otf:h.otf.ios,ttf:h.ttf.ios,mp3:h.mp3.ios},otherLinkOptions:f.ios},{name:"Android",enabled:a.android.enabled,assets:a.android.assets,manifest:getManifest(n,"android"),config:o.android,cleanAssets:cleanAssetsAndroid,copyAssets:copyAssetsAndroid,linkOptionsPerExt:{otf:h.otf.android,ttf:h.ttf.android,png:h.png.android,jpg:h.jpg.android,gif:h.gif.android,mp3:h.mp3.android},otherLinkOptions:f.android}].filter((({enabled:e,config:t})=>e&&t.exists)).forEach(linkPlatform({rootPath:i,shouldUnlink:t})),showAndroidRelinkingWarning&&log.warn(null,"The old Android font assets were relinked in order to use XML resources. Please refer to this guide to update your application's code as well: https://github.com/callstack/react-native-asset#font-assets-linking-and-usage")};
//# sourceMappingURL=/sm/5985f037ce4052ce4aba93c6d307c18e1034524fa8b2090782cbe34302f55721.map