/**
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import"./prism-import.js";import{Polymer as e}from"../polymer/lib/legacy/polymer-fn.js";import{Base as t}from"../polymer/polymer-legacy.js";var i="syntax-highlight";e({is:"prism-highlighter",properties:{languages:{type:Object,value:function(){return{}}}},ready:function(){this._handler=this._highlight.bind(this)},attached:function(){(this.parentNode.host||this.parentElement).addEventListener(i,this._handler)},detached:function(){(this.parentNode.host||this.parentElement).removeEventListener(i,this._handler)},_highlight:function(e){if(e.detail&&e.detail.code){e.stopPropagation();var a=e.detail;a.code=Prism.highlight(a.code,this._detectLang(a.code,a.lang))}else t._warn("Malformed",i,"event:",e.detail)},_detectLang:function(e,t){if(!t)return e.match(/^\s*</)?Prism.languages.markup:Prism.languages.javascript;if(this.languages[t])return this.languages[t];if(Prism.languages[t])return Prism.languages[t];switch(t.substr(0,2)){case"js":case"es":return Prism.languages.javascript;case"c":return Prism.languages.clike;default:return Prism.languages.markup}}});