{"version":3,"sources":["jsdelivr-header.js","/npm/diagram-js@15.17.0/lib/Diagram.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNS,aAAgB,cAElB,eAAgB,kBA6BvB,SAAS,UAAU,GACjB,IAAI,EAAW,IAAI,SAAS,GAI5B,OAFA,EAAS,OAEF,CACT,CAUA,SAAS,eAAe,GAatB,OAAO,UAFO,CAJK,CACjB,OAAU,CAAE,QANd,EAAU,GAAW,CAAC,IASQ,YAAa,OAAO,EAAQ,SAAW,IAGvE,gBAoDe,SAAS,QAAQ,EAAS,GAKvC,KAAK,UAAY,GAAY,eAAe,GAuB5C,KAAK,IAAI,YAAY,KAAK,eAC5B,CA8CA,QAAQ,UAAU,IAAM,SAAS,EAAM,GACrC,OAAO,KAAK,UAAU,IAAI,EAAM,EAClC,EA2BA,QAAQ,UAAU,OAAS,SAAS,EAAM,EAAS,GACjD,OAAO,KAAK,UAAU,OAAO,EAAM,EAAS,EAC9C,EAKA,QAAQ,UAAU,QAAU,WAC1B,KAAK,IAAI,YAAY,KAAK,kBAC5B,EAKA,QAAQ,UAAU,MAAQ,WACxB,KAAK,IAAI,YAAY,KAAK,gBAC5B","file":"/npm/diagram-js@15.17.0/lib/Diagram.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/diagram-js@15.17.0/lib/Diagram.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { Injector } from 'didi';\n\nimport CoreModule from './core/index.js';\n\n/**\n * @typedef {import('didi').InjectionContext} InjectionContext\n * @typedef {import('didi').LocalsMap} LocalsMap\n * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration\n *\n * @typedef { {\n *   modules?: ModuleDeclaration[];\n * } & Record<string, any> } DiagramOptions\n */\n\n/**\n * @template T\n * @typedef {import('didi').FactoryFunction<T>} FactoryFunction\n */\n\n/**\n * @template T\n * @typedef {import('didi').ArrayFunc<T>} ArrayFunc\n */\n\n/**\n * Bootstrap an injector from a list of modules, instantiating a number of default components\n *\n * @param {ModuleDeclaration[]} modules\n *\n * @return {Injector} a injector to use to access the components\n */\nfunction bootstrap(modules) {\n  var injector = new Injector(modules);\n\n  injector.init();\n\n  return injector;\n}\n\n/**\n * Creates an injector from passed options.\n *\n * @template ServiceMap\n * @param {DiagramOptions} [options]\n *\n * @return {Injector<ServiceMap>}\n */\nfunction createInjector(options) {\n\n  options = options || {};\n\n  /**\n   * @type { ModuleDeclaration }\n   */\n  var configModule = {\n    'config': [ 'value', options ]\n  };\n\n  var modules = [ configModule, CoreModule ].concat(options.modules || []);\n\n  return bootstrap(modules);\n}\n\n\n/**\n * The main diagram-js entry point that bootstraps the diagram with the given\n * configuration.\n *\n * To register extensions with the diagram, pass them as Array<Module> to the constructor.\n *\n * @class\n * @constructor\n * @template [ServiceMap=null]\n *\n * @example Creating a plug-in that logs whenever a shape is added to the canvas.\n *\n * ```javascript\n * // plug-in implementation\n * function MyLoggingPlugin(eventBus) {\n *   eventBus.on('shape.added', function(event) {\n *     console.log('shape ', event.shape, ' was added to the diagram');\n *   });\n * }\n *\n * // export as module\n * export default {\n *   __init__: [ 'myLoggingPlugin' ],\n *     myLoggingPlugin: [ 'type', MyLoggingPlugin ]\n * };\n * ```\n *\n * Use the plug-in in a Diagram instance:\n *\n * ```javascript\n * import MyLoggingModule from 'path-to-my-logging-plugin';\n *\n * var diagram = new Diagram({\n *   modules: [\n *     MyLoggingModule\n *   ]\n * });\n *\n * diagram.invoke([ 'canvas', function(canvas) {\n *   // add shape to drawing canvas\n *   canvas.addShape({ x: 10, y: 10 });\n * });\n *\n * // 'shape ... was added to the diagram' logged to console\n * ```\n *\n * @param {DiagramOptions} [options]\n * @param {Injector<ServiceMap>} [injector] An (optional) injector to bootstrap the diagram with.\n */\nexport default function Diagram(options, injector) {\n\n  /**\n   * @type {Injector<ServiceMap>}\n   */\n  this._injector = injector || createInjector(options);\n\n  // init\n\n  /**\n   * An event indicating that all plug-ins are loaded.\n   *\n   * Use this event to fire other events to interested plug-ins\n   *\n   * @memberOf Diagram\n   *\n   * @event diagram.init\n   *\n   * @example\n   *\n   * ```javascript\n   * eventBus.on('diagram.init', function() {\n   *   eventBus.fire('my-custom-event', { foo: 'BAR' });\n   * });\n   * ```\n   *\n   * @type {Object}\n   */\n  this.get('eventBus').fire('diagram.init');\n}\n\n/**\n * @overlord\n *\n * Resolves a diagram service.\n *\n * @template {keyof ServiceMap} Name\n *\n * @param {Name} name The name of the service to get.\n *\n * @return {ServiceMap[Name]}\n */\n/**\n * @overlord\n *\n * Resolves a diagram service.\n *\n * @template T\n *\n * @param {string} name The name of the service to get.\n * @param {true} strict If false, resolve missing services to null.\n *\n * @return {T}\n */\n/**\n * @overlord\n *\n * Resolves a diagram service.\n *\n * @template T\n *\n * @param {string} name The name of the service to get.\n * @param {boolean} strict If false, resolve missing services to null.\n *\n * @return {T|null}\n */\n/**\n * Resolves a diagram service.\n *\n * @template T\n *\n * @param {string} name The name of the service to get.\n *\n * @return {T}\n */\nDiagram.prototype.get = function(name, strict) {\n  return this._injector.get(name, strict);\n};\n\n/**\n * @overlord\n *\n * Invoke the given function, injecting dependencies. Return the result.\n *\n * @template T\n *\n * @param {FactoryFunction<T>} func\n * @param {InjectionContext} [context]\n * @param {LocalsMap} [locals]\n *\n * @return {T}\n */\n/**\n * Invoke the given function, injecting dependencies provided in\n * array notation. Return the result.\n *\n * @template T\n *\n * @param {ArrayFunc<T>} func function to be invoked\n * @param {InjectionContext} [context] context of the invocation\n * @param {LocalsMap} [locals] locals provided\n *\n * @return {T}\n */\nDiagram.prototype.invoke = function(func, context, locals) {\n  return this._injector.invoke(func, context, locals);\n};\n\n/**\n * Destroys the diagram\n */\nDiagram.prototype.destroy = function() {\n  this.get('eventBus').fire('diagram.destroy');\n};\n\n/**\n * Clear the diagram, removing all contents.\n */\nDiagram.prototype.clear = function() {\n  this.get('eventBus').fire('diagram.clear');\n};\n"]}