{"version":3,"sources":["../src/truncate/truncate-middle.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,SAAgB,cAAc,CAAE,GAAW,EAAE,WAAmB,EAAE,aAAsB;IACtF,IAAI,GAAG,CAAC,MAAM,IAAI,WAAW,EAAE;QAC7B,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,2BAAmC,CAAC;IACxC,IAAI,cAAsB,CAAC;IAE3B,IAAG,aAAa,IAAI,IAAI,EAAE;QACxB,aAAa,GAAG,UAAU,CAAC;QAC3B,2BAA2B,GAAG,CAAC,CAAC;QAChC,cAAc,GAAG,CAAC,CAAC;KACpB;SAAM;QACL,2BAA2B,GAAG,aAAa,CAAC,MAAM,CAAC;QACnD,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC;KACvC;IAED,IAAI,eAAe,GAAG,WAAW,GAAG,cAAc,CAAC;IACnD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,eAAe,GAAG,CAAC,EAAE;QACvB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAC,IAAI,CAAC,KAAK,CAAC,eAAe,GAAC,CAAC,CAAC,CAAC,CAAC;KACtD;IACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,GAAC,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,GAAG,2BAA2B,CAAC,CAAC;AACtI,CAAC;AAvBD,wCAuBC","file":"truncate-middle.js","sourcesContent":["/**\n * Date: 2015-10-05\n * Author: Kasper Søfren (https://github.com/kafoso)\n *\n * A truncation feature, where the ellipsis will be placed in the dead-center of the URL.\n *\n * @param {String} url A URL.\n * @param {Number} truncateLen The maximum length of the truncated output URL string.\n * @param {String} ellipsisChars The characters to place within the url, e.g. \"..\".\n * @return {String} The truncated URL.\n */\nexport function truncateMiddle( url: string, truncateLen: number, ellipsisChars?: string ){\n if (url.length <= truncateLen) {\n return url;\n }\n\n let ellipsisLengthBeforeParsing: number;\n let ellipsisLength: number;\n\n if(ellipsisChars == null) {\n ellipsisChars = '…';\n ellipsisLengthBeforeParsing = 8;\n ellipsisLength = 3;\n } else {\n ellipsisLengthBeforeParsing = ellipsisChars.length;\n ellipsisLength = ellipsisChars.length;\n }\n\n let availableLength = truncateLen - ellipsisLength;\n let end = \"\";\n if (availableLength > 0) {\n end = url.substr((-1)*Math.floor(availableLength/2));\n }\n return (url.substr(0, Math.ceil(availableLength/2)) + ellipsisChars + end).substr(0, availableLength + ellipsisLengthBeforeParsing);\n}\n"]}