{"version":3,"sources":["AX6UIGrid_excel.js"],"names":["_jqmin","require","base64","s","window","btoa","unescape","encodeURIComponent","uri","getExcelTmpl","tableToExcel","table","fileName","output","concat","render","worksheet","arr","a","tables","forEach","t","ti","ax5","mustache","body","navigator","userAgent","indexOf","isIE","document","documentMode","$iframe","iframe","anchor","msSaveOrOpenBlob","blob1","Blob","type","isChrome","open","this","id","write","blankWindow","execCommand","appendChild","createElement","close","remove","removeChild"],"mappings":"4IAAA,IAAAA,OAAAC,QAAA,gDAEMC,OAAS,SAAUC,GACvB,OAAOC,OAAOC,KAAKC,SAASC,mBAAmBJ,MAHjDK,IAAA,wCAQMC,aAAe,WACnB,MAAA,8CAPFC,aAAA,SAAAC,EAAAC,GAaE,IAAaC,OAAAA,EATTL,KAAMM,OAAAH,GAEZE,EAAMJ,IAAAA,SAAeM,OAAfN,gBACJO,UAAA,WADF,IAAAC,KAOYC,OAMNC,EAAOC,QAAQ,SAAUC,EAAGC,GAP5BZ,EAAAA,MAAAA,KAAe,SAAfA,EAAe,OACTQ,EANV,GAMAC,OACEA,WAWE,IAAIF,KANJE,OAHJN,EAASU,QAAIC,SAAgBf,EAAAA,GAC3BO,EAAAA,MAAYS,KAAAJ,MAEHD,EALTD,KASC,IACDA,IAR2CO,UAAAC,UAAAC,QAAA,WAAA,IAQtBF,UAAAC,UAAAC,QAAA,WAAA,EACnBC,IAAAC,SAAAC,aAEEd,OAAAA,EAASe,OAAAA,EAATC,OAAAA,EAAAC,OAAAA,EA4CF,OA1CAR,UAAAS,kBACDC,EANO,IAAAC,MAAAxB,IAAAyB,KAAA,cARVlC,OAAAsB,UAAAS,iBAAAC,EAAAxB,IAiBI2B,GAaYnC,OAAOoC,KAAK,cAAeC,KAAKC,GAAK,gBAAiB,wBATlEN,SAAJO,MAAA9B,GAAW+B,MAA8BV,GAAzC,oBAAAG,MAGED,GAAYC,EAAAA,QAAAA,SAAMxB,eAAgB4B,KAAAC,GAAP,kDAC3BtC,EAAAA,QAAAA,SAAOsB,SAAUS,MAAAA,OAAAA,IAGjBF,EAAA7B,OAAAqC,KAAAC,GAAA,kBACAZ,SAAAU,KAAA,YAAA,WACAI,EAAAA,SAAcxC,MAAOoC,GACrBI,EAAAA,SAAYd,QACZc,EAAAA,QALGX,EAOAH,SAAAe,YAAA,UAAA,EAAAjC,GACHoB,EAAIH,UAQFI,aALAD,EAAAA,SAAUP,KAAAqB,YACVhB,SAAAiB,cAAOjB,SAKPG,EAAOH,SAASkB,EAEhBf,EAAOH,KAASe,IAAAA,OAAYhC,GAC5BmB,EAAQiB,QAZVnB,SAaOL,KAAAyB,YAAAhB,KAOL,oBAIEA,OAAAA","file":"AX6UIGrid_excel.js","sourcesContent":["import jQuery from \"jqmin\";\n\nconst base64 = function (s) {\n  return window.btoa(unescape(encodeURIComponent(s)));\n};\n\nconst uri = \"data:application/vnd.ms-excel;base64,\";\n\nconst getExcelTmpl = function () {\n  return `\\ufeff\n{{#tables}}{{{body}}}{{/tables}}\n`;\n};\n\nconst tableToExcel = function (table, fileName) {\n  let link, a, output,\n    tables = [].concat(table);\n\n  output = ax5.mustache.render(getExcelTmpl(), {\n    worksheet: (function () {\n      var arr = [];\n      tables.forEach(function (t, ti) {\n        arr.push({name: \"Sheet\" + (ti + 1)});\n      });\n      return arr;\n    })(),\n    tables: (function () {\n      var arr = [];\n      tables.forEach(function (t, ti) {\n        arr.push({body: t});\n      });\n      return arr;\n    })()\n  });\n\n  let isChrome = navigator.userAgent.indexOf(\"Chrome\") > -1,\n    isSafari = !isChrome && navigator.userAgent.indexOf(\"Safari\") > -1,\n    isIE = /*@cc_on!@*/false || !!document.documentMode; // this works with IE10 and IE11 both :)\n\n  let blob1, blankWindow, $iframe, iframe, anchor;\n\n  if (navigator.msSaveOrOpenBlob) {\n    blob1 = new Blob([output], {type: \"text/html\"});\n    window.navigator.msSaveOrOpenBlob(blob1, fileName);\n  }\n  else if (isSafari) {\n    // 사파리는 지원이 안되므로 그냥 테이블을 클립보드에 복사처리\n    //tables\n    blankWindow = window.open('about:blank', this.id + '-excel-export', 'width=600,height=400');\n    blankWindow.document.write(output);\n    blankWindow = null;\n  }\n  else {\n    if (isIE && typeof Blob === \"undefined\") {\n      //otherwise use the iframe and save\n      //requires a blank iframe on page called txtArea1\n      $iframe = jQuery('<iframe id=\"' + this.id + '-excel-export\" style=\"display:none\"></iframe>');\n      jQuery(document.body).append($iframe);\n\n      iframe = window[this.id + '-excel-export'];\n      iframe.document.open(\"text/html\", \"replace\");\n      iframe.document.write(output);\n      iframe.document.close();\n      iframe.focus();\n      iframe.document.execCommand(\"SaveAs\", true, fileName);\n      $iframe.remove();\n    } else {\n      // Attempt to use an alternative method\n      anchor = document.body.appendChild(\n        document.createElement(\"a\")\n      );\n\n      // If the [download] attribute is supported, try to use it\n      if (\"download\" in anchor) {\n        anchor.download = fileName;\n        //anchor.href = URL.createObjectURL( blob );\n        anchor.href = uri + base64(output);\n        anchor.click();\n        document.body.removeChild(anchor);\n      }\n    }\n  }\n\n  return true;\n};\n\nexport default {\n  export: tableToExcel\n};"]}