{"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { WebPlugin } from '@capacitor/core';\nexport class ClipboardWeb extends WebPlugin {\n write(options) {\n var _this = this;\n return _asyncToGenerator(function* () {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw _this.unavailable('Clipboard API not available in this browser');\n }\n if (options.string !== undefined) {\n yield _this.writeText(options.string);\n } else if (options.url) {\n yield _this.writeText(options.url);\n } else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = yield (yield fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({\n [blob.type]: blob\n });\n yield navigator.clipboard.write([clipboardItemInput]);\n } catch (err) {\n throw new Error('Failed to write image');\n }\n } else {\n throw _this.unavailable('Writing images to the clipboard is not supported in this browser');\n }\n } else {\n throw new Error('Nothing to write');\n }\n })();\n }\n read() {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw _this2.unavailable('Clipboard API not available in this browser');\n }\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = yield navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = yield clipboardItems[0].getType(type);\n const data = yield _this2._getBlobData(clipboardBlob, type);\n return {\n value: data,\n type\n };\n } catch (err) {\n return _this2.readText();\n }\n } else {\n return _this2.readText();\n }\n })();\n }\n readText() {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.readText) {\n throw _this3.unavailable('Reading from clipboard not supported in this browser');\n }\n const text = yield navigator.clipboard.readText();\n return {\n value: text,\n type: 'text/plain'\n };\n })();\n }\n writeText(text) {\n var _this4 = this;\n return _asyncToGenerator(function* () {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.writeText) {\n throw _this4.unavailable('Writting to clipboard not supported in this browser');\n }\n yield navigator.clipboard.writeText(text);\n })();\n }\n _getBlobData(clipboardBlob, type) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n } else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result;\n resolve(r);\n };\n reader.onerror = e => {\n reject(e);\n };\n });\n }\n}","map":{"version":3,"names":["WebPlugin","ClipboardWeb","write","options","_this","_asyncToGenerator","navigator","clipboard","unavailable","string","undefined","writeText","url","image","ClipboardItem","blob","fetch","clipboardItemInput","type","err","Error","read","_this2","clipboardItems","types","clipboardBlob","getType","data","_getBlobData","value","readText","_this3","text","_this4","Promise","resolve","reject","reader","FileReader","includes","readAsDataURL","readAsText","onloadend","r","result","onerror","e"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@capacitor/clipboard/dist/esm/web.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class ClipboardWeb extends WebPlugin {\n async write(options) {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (options.string !== undefined) {\n await this.writeText(options.string);\n }\n else if (options.url) {\n await this.writeText(options.url);\n }\n else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = await (await fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({ [blob.type]: blob });\n await navigator.clipboard.write([clipboardItemInput]);\n }\n catch (err) {\n throw new Error('Failed to write image');\n }\n }\n else {\n throw this.unavailable('Writing images to the clipboard is not supported in this browser');\n }\n }\n else {\n throw new Error('Nothing to write');\n }\n }\n async read() {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = await navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = await clipboardItems[0].getType(type);\n const data = await this._getBlobData(clipboardBlob, type);\n return { value: data, type };\n }\n catch (err) {\n return this.readText();\n }\n }\n else {\n return this.readText();\n }\n }\n async readText() {\n if (typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.readText) {\n throw this.unavailable('Reading from clipboard not supported in this browser');\n }\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n async writeText(text) {\n if (typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.writeText) {\n throw this.unavailable('Writting to clipboard not supported in this browser');\n }\n await navigator.clipboard.writeText(text);\n }\n _getBlobData(clipboardBlob, type) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n }\n else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result;\n resolve(r);\n };\n reader.onerror = e => {\n reject(e);\n };\n });\n }\n}\n"],"mappings":";AAAA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,OAAO,MAAMC,YAAY,SAASD,SAAS,CAAC;EAClCE,KAAKA,CAACC,OAAO,EAAE;IAAA,IAAAC,KAAA;IAAA,OAAAC,iBAAA;MACjB,IAAI,OAAOC,SAAS,KAAK,WAAW,IAAI,CAACA,SAAS,CAACC,SAAS,EAAE;QAC1D,MAAMH,KAAI,CAACI,WAAW,CAAC,6CAA6C,CAAC;MACzE;MACA,IAAIL,OAAO,CAACM,MAAM,KAAKC,SAAS,EAAE;QAC9B,MAAMN,KAAI,CAACO,SAAS,CAACR,OAAO,CAACM,MAAM,CAAC;MACxC,CAAC,MACI,IAAIN,OAAO,CAACS,GAAG,EAAE;QAClB,MAAMR,KAAI,CAACO,SAAS,CAACR,OAAO,CAACS,GAAG,CAAC;MACrC,CAAC,MACI,IAAIT,OAAO,CAACU,KAAK,EAAE;QACpB,IAAI,OAAOC,aAAa,KAAK,WAAW,EAAE;UACtC,IAAI;YACA,MAAMC,IAAI,SAAS,OAAOC,KAAK,CAACb,OAAO,CAACU,KAAK,C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