"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.params=exports.name=exports.run=undefined;var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/* @preserve TW-Guard */
/*\
title: $:/plugins/felixhayashi/tiddlymap/js/macro/tmap
type: application/javascript
module-type: macro

@preserve

\*/
/* @preserve TW-Guard */var _EdgeType=require("$:/plugins/felixhayashi/tiddlymap/js/EdgeType");var _EdgeType2=_interopRequireDefault(_EdgeType);var _ViewAbstraction=require("$:/plugins/felixhayashi/tiddlymap/js/ViewAbstraction");var _ViewAbstraction2=_interopRequireDefault(_ViewAbstraction);var _utils=require("$:/plugins/felixhayashi/tiddlymap/js/utils");var _utils2=_interopRequireDefault(_utils);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var name="tmap";var params=getParamSlots(5);function run(){this.substVarRefs=this.substituteVariableReferences;var e=command[arguments[0]];var t=null;if(typeof e==="function"){var r=Array.prototype.slice.call(arguments,1);t=e.apply(this,r)}return typeof t==="string"?t:""}function getParamSlots(e){var t=[];for(var r=0;r<e;r++){t.push({name:"arg"+r})}return t}var command=_utils2.default.makeHashMap();command.basename=function(e){var t=this.getVariable("currentTiddler");return _utils2.default.getBasename(t,e)};command.datauri=function(e,t){return _utils2.default.getDataUri(e,t,true)};command.testJSON=function(e){var t=$tw.wiki.getTiddler(this.getVariable("currentTiddler"));try{JSON.parse(t.fields[e]);return"valid"}catch(e){return"malformed"}};command.splitAndSelect=function(e,t){var r=this.getVariable("currentTiddler");var a=r.split(e)[t];return a!=null?a:r};command.concat=function(){var e="";for(var t=1,r=arguments.length;t<r;t++){e+=arguments[t]}return e};command.uuid=function(){return _utils2.default.genUUID()};command.regRepl=function(){var e=this.substVarRefs(arguments[0]);var t=arguments[1];var r=this.substVarRefs(arguments[2]);var a=this.substVarRefs(arguments[4]);return e.replace(new RegExp(t,a),r)};command.halfOfString=function(){var e=this.substVarRefs(arguments[0]);if(!e){return""}return e.substr(0,Math.ceil(e.length/2))};command.isETyVisible=function(e,t){e=new _ViewAbstraction2.default(e);var r=command.getETyId.call(this,e,t);return""+e.isEdgeTypeVisible(r)};command.getETyId=function(e,t){e=new _ViewAbstraction2.default(e);var r=_EdgeType2.default.getInstance(t||this.getVariable("currentTiddler"));if(!r.namespace){var a=_EdgeType2.default.getIdParts(r.id),n=a.marker,i=a.name;var u=e.getConfig("edge_type_namespace");r=_EdgeType2.default.getInstance(_EdgeType2.default.getId(n,u,i))}return r.id};command.scale=function(){var e="";for(var t=1,r=parseInt(arguments[0]);t<r;t++){e+="[["+t+"]]"}return e};command.mergeFields=function(){var e=_utils2.default.getTiddler(arguments[0]);var t=arguments[1];var r=arguments[2]||" ";if(!e)return;var a=_utils2.default.getPropertiesByPrefix(e.fields,t);var n="";for(var i in a){if(typeof a[i]==="string"){n+=a[i]+r}}return n};command.option=function(e,t){if(typeof $tm=="undefined"){return""}var r=$tm;var a=e.split(".");for(var n=0;n<a.length;n++){if((typeof r==="undefined"?"undefined":_typeof(r))=="object"&&r[a[n]]){r=r[a[n]]}}if(t&&typeof r==="string"&&_utils2.default.hasSubString(t)&&r.lastIndexOf(t)+t.length===r.length){r=r+t}return r};exports.run=run;exports.name=name;exports.params=params;
//# sourceMappingURL=./maps/felixhayashi/tiddlymap/js/macro/MapMacro.js.map
