{"version":3,"file":"createFile-browser.mjs","sourceRoot":"","sources":["../../../src/util/createFile-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,SAAS,cAAc,CAAC,MAAkB;IACxC,OAAO,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,SAAS,aAAa,CAAC,MAAkB;IACvC,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,oDAAoD;IACpD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CACxB,OAAmB,EACnB,IAAY,EACZ,UAA6B,EAAE;IAE/B,OAAO,IAAI,IAAI,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CreateFileOptions } from \"./file.js\";\n\nfunction hasArrayBuffer(source: Uint8Array): source is Uint8Array<ArrayBuffer> {\n  return \"resize\" in source.buffer;\n}\n\nfunction toArrayBuffer(source: Uint8Array): Uint8Array<ArrayBuffer> {\n  if (hasArrayBuffer(source)) {\n    return source;\n  }\n  // SharedArrayBuffer — copy to a regular ArrayBuffer\n  return source.map((x) => x);\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to create a File object for use in RequestBodyType.formData in environments\n * where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n  content: Uint8Array,\n  name: string,\n  options: CreateFileOptions = {},\n): File {\n  return new File([toArrayBuffer(content)], name, options);\n}\n"]}