{"version":3,"sources":["jsdelivr-header.js","/npm/think_controller@2.0.6/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACCA,MAAM,IAAM,QAAQ,aAYd,KAAO,SAAU,EAAK,EAAK,EAAS,EAAO,EAAY,GACzD,EAAQ,GAAS,GAEjB,EAAS,GAAU,IADnB,EAAa,GAAc,KAGvB,EAAI,MAAM,IAAK,yBAEnB,IAAI,EAAU,EAAK,EAAS,EAAI,aAAe,CAAC,EAChD,IAGQ,EADA,EACM,EAAO,GAAG,KAAS,KAEnB,EAAO,GAEZ,GACD,EAAI,MAAM,IAAK,yBAEnB,EAAW,IAAI,EAAI,EAAK,EAC5B,CAAE,MAAO,GACL,EAAI,MAAM,IAAK,EAAI,UAAY,EAAI,cAAc,EAAQ,EAAQ,IAAM,KAAK,eAChF,CAEA,MAAM,EAAS,EAAQ,eAAiB,SAClC,EAAQ,EAAQ,cAAgB,UACtC,IAAI,EAAM,GAAG,IAAS,KACjB,EAAS,IAAQ,EAAS,KAC3B,EAAM,GAEL,EAAS,IACV,EAAI,MAAM,IAAK,UAAU,gBAG7B,MAAM,EAAa,EAAQ,eAAiB,WACtC,EAAa,GAAG,EAAQ,aAAe,aAAa,IAE1D,IAAI,EAAW,QAAQ,UAcvB,OAZI,EAAS,KACT,EAAW,EAAS,MAAK,IACd,EAAS,QAIpB,EAAS,KACT,EAAW,EAAS,MAAK,IACd,EAAS,QAIjB,EAAS,MAAK,IACV,EAAS,MAExB,EAIM,eAAiB,CACnB,cAAe,SACf,aAAc,UACd,cAAe,WACf,YAAa,YAGjB,OAAO,QAAU,SAAU,EAAS,GAEhC,OADA,EAAU,EAAU,IAAI,OAAO,eAAgB,GAAS,GAAQ,eACzD,SAAU,EAAK,GAClB,OAAO,KAAK,EAAK,EAAK,EAAS,EAAI,MAAO,EAAI,WAAY,EAAI,OAClE,CACJ","file":"/npm/think_controller@2.0.6/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/think_controller@2.0.6/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n *\n * @author     richen\n * @copyright  Copyright (c) 2017 - <richenlin(at)gmail.com>\n * @license    MIT\n * @version    17/6/1\n */\nconst lib = require('think_lib');\n/**\n * \n * \n * @param {any} app \n * @param {any} ctx \n * @param {any} options \n * @param {any} group \n * @param {any} controller \n * @param {any} action \n * @returns \n */\nconst exec = function (app, ctx, options, group, controller, action) {\n    group = group || '';\n    controller = controller || '';\n    action = action || '';\n    if (!controller) {\n        ctx.throw(404, 'Controller not found.');\n    }\n    let instance, cls, caches = app.controllers || {};\n    try {\n        //multi mod\n        if (group) {\n            cls = caches[`${group}/${controller}`];\n        } else {\n            cls = caches[controller];\n        }\n        if (!cls) {\n            ctx.throw(404, 'Controller not found.');\n        }\n        instance = new cls(ctx, app);\n    } catch (e) {\n        ctx.throw(404, app.app_debug ? e : `Controller ${group ? group + '/' : ''}${controller} not found.`);\n    }\n    //exec action\n    const suffix = options.action_suffix || 'Action';\n    const empty = options.empty_action || '__empty';\n    let act = `${action}${suffix}`;\n    if (!instance[act] && instance[empty]) {\n        act = empty;\n    }\n    if (!instance[act]) {\n        ctx.throw(404, `Action ${action} not found.`);\n    }\n\n    const commBefore = options.common_before || '__before';\n    const selfBefore = `${options.self_before || '_before_'}${action}`;\n\n    let promises = Promise.resolve();\n    //common befroe\n    if (instance[commBefore]) {\n        promises = promises.then(() => {\n            return instance[commBefore]();\n        });\n    }\n    //self before\n    if (instance[selfBefore]) {\n        promises = promises.then(() => {\n            return instance[selfBefore]();\n        });\n    }\n    //action\n    return promises.then(() => {\n        return instance[act]();\n    });\n};\n/**\n * default options\n */\nconst defaultOptions = {\n    action_suffix: 'Action', //方法后缀,带后缀的方法为公共方法\n    empty_action: '__empty', //空方法,如果访问控制器中不存在的方法,默认调用\n    common_before: '__before', //控制器类公共前置方法,除私有方法外其他方法执行时自动调用\n    self_before: '_before_', //控制器类某个方法自身的前置方法(前缀),该方法执行时自动调用\n};\n\nmodule.exports = function (options, app) {\n    options = options ? lib.extend(defaultOptions, options, true) : defaultOptions;\n    return function (ctx, next) {\n        return exec(app, ctx, options, ctx.group, ctx.controller, ctx.action);\n    };\n};"]}