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AAY,6BAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,CAAC;CACJ;AAnED,sEAmEC","sourcesContent":["import * as Path from 'path';\n\nimport { Component, AbstractComponent } from '../utils/component';\nimport { ProjectReflection, DeclarationReflection } from '../models/reflections/index';\nimport { Renderer } from './renderer';\nimport { RendererEvent, PageEvent } from './events';\n\nexport { Component };\n\nexport abstract class RendererComponent extends AbstractComponent<Renderer> { }\n\n/**\n * A plugin for the renderer that reads the current render context.\n */\nexport abstract class ContextAwareRendererComponent extends RendererComponent {\n /**\n * The project that is currently processed.\n */\n protected project?: ProjectReflection;\n\n /**\n * The reflection that is currently processed.\n */\n protected reflection?: DeclarationReflection;\n\n /**\n * The url of the document that is being currently generated.\n * Set when a page begins rendering.\n */\n private location!: string;\n\n /**\n * Regular expression to test if a string looks like an external url.\n */\n protected urlPrefix: RegExp = /^(http|ftp)s?:\\/\\//;\n\n /**\n * Create a new ContextAwareRendererPlugin instance.\n *\n * @param renderer The renderer this plugin should be attached to.\n */\n protected initialize() {\n this.listenTo(this.owner, {\n [RendererEvent.BEGIN]: this.onBeginRenderer,\n [PageEvent.BEGIN]: this.onBeginPage\n });\n }\n\n /**\n * Transform the given absolute path into a relative path.\n *\n * @param absolute The absolute path to transform.\n * @returns A path relative to the document currently processed.\n */\n public getRelativeUrl(absolute: string): string {\n if (this.urlPrefix.test(absolute)) {\n return absolute;\n } else {\n const relative = Path.relative(Path.dirname(this.location), Path.dirname(absolute));\n return Path.join(relative, Path.basename(absolute)).replace(/\\\\/g, '/');\n }\n }\n\n /**\n * Triggered before the renderer starts rendering a project.\n *\n * @param event An event object describing the current render operation.\n */\n protected onBeginRenderer(event: RendererEvent) {\n this.project = event.project;\n }\n\n /**\n * Triggered before a document will be rendered.\n *\n * @param page An event object describing the current render operation.\n */\n protected onBeginPage(page: PageEvent) {\n this.location = page.url;\n this.reflection = page.model instanceof DeclarationReflection ? page.model : undefined;\n }\n}\n"]}
\No newline at end of file