define(['jquery','ko','module','../template/renderer','mage/translate'],function($,ko,module,renderer){'use strict';var locations={'legend':'Caption for the fieldset element','label':'Label for an input element.','button':'Push button','a':'Link label','b':'Bold text','strong':'Strong emphasized text','i':'Italic text','em':'Emphasized text','u':'Underlined text','sup':'Superscript text','sub':'Subscript text','span':'Span element','small':'Smaller text','big':'Bigger text','address':'Contact information','blockquote':'Long quotation','q':'Short quotation','cite':'Citation','caption':'Table caption','abbr':'Abbreviated phrase','acronym':'An acronym','var':'Variable part of a text','dfn':'Term','strike':'Strikethrough text','del':'Deleted text','ins':'Inserted text','h1':'Heading level 1','h2':'Heading level 2','h3':'Heading level 3','h4':'Heading level 4','h5':'Heading level 5','h6':'Heading level 6','center':'Centered text','select':'List options','img':'Image','input':'Form element'},composeTranslateAttr=function(translationData,location){var obj=[{'shown':translationData.shown,'translated':translationData.translated,'original':translationData.original,'location':locations[location]||'Text'}];return JSON.stringify(obj);},setText=function(el,text){$(el).text(text);},setTranslateProp=function(el,original){var location=$(el).prop('tagName').toLowerCase(),translated=$.mage.__(original),translationData={shown:translated,translated:translated,original:original},translateAttr=composeTranslateAttr(translationData,location);$(el).attr('data-translate',translateAttr);setText(el,translationData.shown);},isVirtualElement=function(node){return node.nodeType===8;},getRealElement=function(el,isUpdate){if(isVirtualElement(el)){if(isUpdate){return $(el).next('span');} return $('').insertAfter(el);} return el;},execute=function(element,valueAccessor,isUpdate){var original=ko.unwrap(valueAccessor()||''),el=getRealElement(element,isUpdate),inlineTranslation=(module.config()||{}).inlineTranslation;if(inlineTranslation){setTranslateProp(el,original);}else{setText(el,$.mage.__(original));}};ko.bindingHandlers.i18n={init:function(element,valueAccessor){execute(element,valueAccessor);},update:function(element,valueAccessor){execute(element,valueAccessor,true);}};ko.virtualElements.allowedBindings.i18n=true;renderer.addNode('translate',{binding:'i18n'}).addAttribute('translate',{binding:'i18n'});});