{"version":3,"file":"imagehandler.min.js","sources":["https:\/\/moodle.sonsbeekmedia.nl\/caie_39\/mod\/teachingtools\/amd\/src\/imagehandler.js"],"sourcesContent":["\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/**\n * Image handler for the teaching tools.\n *\n * @module mod_teachingtools\/imagehandler\n * @copyright 2023 Moodle\n * @author Bas Brands \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\nimport Ajax from 'core\/ajax';\nimport Notification from 'core\/notification';\n\nconst saveImage = (cmid, app, file, data) => {\n let ajaxParams = {\n imagefilename: file.name,\n imagedata: data.split('base64,')[1],\n filearea: app,\n cmid: cmid,\n };\n\n return store({params: ajaxParams});\n};\n\n\n\/**\n * Store an image from the image handler\n * @param {Object} args The request arguments\n * @return {Promise} Resolved with an array file the stored file url.\n *\/\n const store = args => {\n const request = {\n methodname: 'mod_teachingtools_update_image',\n args: args\n };\n\n let promise = Ajax.call([request])[0]\n .fail(Notification.exception);\n\n return promise;\n};\n\n\/**\n * Get an image from the image handler\n * @param {Object} args The request arguments\n * @return {Promise} Resolved with an file url.\n *\/\nconst getImage = args => {\n const request = {\n methodname: 'mod_teachingtools_get_image',\n args: args\n };\n\n let promise = Ajax.call([request])[0]\n .fail(Notification.exception);\n\n return promise;\n};\n\nexport default {\n saveImage: saveImage,\n getImage: getImage\n};"],"names":["store","args","request","methodname","Ajax","call","fail","Notification","exception","saveImage","cmid","app","file","data","ajaxParams","imagefilename","name","imagedata","split","filearea","params","getImage"],"mappings":";;;;;;;;mLA4COA,MAAQC,aACLC,QAAU,CACZC,WAAY,iCACZF,KAAMA,aAGIG,cAAKC,KAAK,CAACH,UAAU,GAC9BI,KAAKC,sBAAaC,yBAsBZ,CACXC,UA\/Cc,CAACC,KAAMC,IAAKC,KAAMC,YAC5BC,WAAa,CACbC,cAAeH,KAAKI,KACpBC,UAAWJ,KAAKK,MAAM,WAAW,GACjCC,SAAUR,IACVD,KAAMA,aAGHV,MAAM,CAACoB,OAAQN,cAwCtBO,SAdapB,aACPC,QAAU,CACZC,WAAY,8BACZF,KAAMA,aAGIG,cAAKC,KAAK,CAACH,UAAU,GAC9BI,KAAKC,sBAAaC"}