1"use strict";const keysListByCommand={m:["x","y"],l:["x","y"],h:["x"],v:["y"],c:["x","y","x1","y1","x2","y2"],s:["x","y","x1","y1"],q:["x","y","x1","y1"],t:["x","y","x1","y1"],a:["rx","ry","x-axis-rotation","large-arc-flag","sweep-flag","x","y"]},PathConverter=function(params){this.srcText=params.srcText,this.demoPath=params.demoPath,this.coords=this.srcText,this.isRemoveOffset=!0,this.lastUsedCoords={},this.resultPath="",this.fullCodes={spaces:{}},this.pathSizes=this.demoPath.getBBox();const coordsListSrc=[...normalizePathCoords(this.coords).matchAll(/[a-z][^(a-z)]{1,}/gi)].map(item=>item[0]);let coordsList=coordsListSrc.slice();coordsList=this.addOmittedCommands(coordsListSrc.slice()),this.isRemoveOffset&&(coordsList=this.removeOffset(coordsList)),this.results=coordsList.toString()};function findMinSpaces(str){const spaces=str.match(/(^\s{1,})/gm);if(!spaces)return 0;return spaces.reduce((prev,item)=>{const spacesLength=item.length;return null==prev||spacesLength<prev?prev=spacesLength:prev},null)}function parseCoordsItem(item){const commandSrc=item.substring(0,1),command=commandSrc.toLowerCase();return{commandSrc:commandSrc,command:command,isCommandUpperCase:command!==commandSrc,keysList:keysListByCommand[command],coordsList:item.substring(1).replace(/,$/,"").split(",").map(item=>+item)}}function normalizePathCoords(coords){let result=coords.replace(/([a-z]) /gi,"$1").replace(/([a-z])/gi," $1").trim().replace(/(\d{1,})(-)/gi,"$1 $2").replace(/\s00/gi," 0 0 ").replace(/z/gi," ").replace(/,\s{1,}/gi,",").replace(/\s{1,},/gi,",").replace(/\s{1,}/gi,",");for(;result.match(/\.\d{1,}\.\d{1,}/gi);)result=result.replace(/(\.\d{1,})(\.\d{1,})/gi,"$1,$2");return result}function round(num){return Math.round(1e3*num)/1e3}PathConverter.prototype.findItemMinXY=function(keysList,coordsList,itemCommand){let valuesList=coordsList,minXY={x:null,y:null};let counter=0;if("v"===itemCommand?valuesList=[this.lastUsedCoords.x,valuesList[0]]:"h"===itemCommand?valuesList=[valuesList[0],this.lastUsedCoords.y]:"a"===itemCommand&&(valuesList=valuesList.splice(-2)),2===valuesList.length){const[x,y]=valuesList;return minXY={x:x,y:y},this.lastUsedCoords={x:x,y:y},minXY}for(;valuesList.length>0&&counter<1e4;){let[x,y]=valuesList.splice(0,2);null!==minXY.x?(x>=0&&x<minXY.x&&(minXY.x=x),y>=0&&y<minXY.y&&(minXY.y=y),counter++):minXY={x:x,y:y}}return minXY},PathConverter.prototype.relItemCoordToAbs=function(keysList,coordsList,prevCoords,itemCommand){const valuesList=coordsList,prevCoordsData=parseCoordsItem(prevCoords),prevCoordsList=prevCoordsData.coordsList;let[prevX,prevY]=prevCoordsList.splice(-2);"v"===prevCoordsData.command?(prevY=prevX,prevX=this.lastUsedCoords.x):"h"===prevCoordsData.command&&(prevY=this.lastUsedCoords.y);return valuesList.map((item,index)=>{const key=keysList[index];if(!isFinite(item))return console.log("Not finite item:",item),item;if(key&&(key.includes("rotation")||key.includes("flag")||"rx"===key||"ry"===key))return item;if(!key&&"a"!==itemCommand){if(index%2==0){const newX=item+prevX;return"l"===itemCommand&&(prevX=newX),this.lastUsedCoords.x=newX,newX}{const newY=item+prevY;return"l"===itemCommand&&(prevY=newY),this.lastUsedCoords.y=newY,newY}}if(key.includes("x")){const newX=item+prevX;return"l"===itemCommand&&(prevX=newX),this.lastUsedCoords.x=newX,newX}if(key.includes("y")){const newY=item+prevY;return"l"===itemCommand&&(prevY=newY),this.lastUsedCoords.y=newY,newY}return item})},PathConverter.prototype.relCommandsToAbs=function(initialCoordsList){return(initialCoordsList=initialCoordsList.slice()).reduce((prev,value,index)=>{let{commandSrc:commandSrc,command:command,coordsList:coordsList,keysList:keysList,isCommandUpperCase:isCommandUpperCase}=parseCoordsItem(value);if("m"===command){const[x,y]=coordsList;this.lastUsedCoords.x=x,this.lastUsedCoords.y=y}if(!isCommandUpperCase){const prevCoords=prev[index-1],absItemCoords=this.relItemCoordToAbs(keysList,coordsList,prevCoords,command);value=`${commandSrc.toUpperCase()}${absItemCoords.join(",")}`}return prev.push(value),prev},[])},PathConverter.prototype.removeOffset=function(srcCoordsList){srcCoordsList=srcCoordsList.slice();const absCoordsList=this.relCommandsToAbs(srcCoordsList.slice());srcCoordsList=absCoordsList,this.minXY=this.findOffset(absCoordsList);const coordsWithoutOffset=[];let counter=0;for(;srcCoordsList.length>0&&counter<5e3;){let value=srcCoordsList.shift(),{commandSrc:commandSrc,command:command,coordsList:coordsList,keysList:keysList,isCommandUpperCase:isCommandUpperCase}=parseCoordsItem(value);if(keysList){if(isCommandUpperCase){value=`${commandSrc}${this.removeOffsetFromValues(keysList,coordsList,command).join(",")}`}coordsWithoutOffset.push(value)}else console.log("Unrecognized command: ",command);counter++}return coordsWithoutOffset},PathConverter.prototype.removeOffsetFromValues=function(keysList,coordsList,itemCommand){return coordsList.map((item,index)=>
1keysList[index]||"a"===itemCommand?keysList[index].includes("rotation")||keysList[index].includes("flag")||"rx"===keysList[index]||"ry"===keysList[index]?item:keysList[index].includes("x")?item-this.minXY.x:keysList[index].includes("y")?item-this.minXY.y:item:index%2==0?item-this.minXY.x:item-this.minXY.y)},PathConverter.prototype.findOffset=function(srcCoordsList){srcCoordsList=srcCoordsList.slice();let minXY={x:null,y:null};let counter=0;for(;srcCoordsList.length>0&&counter<5e3;){let value=srcCoordsList.shift(),{commandSrc:commandSrc,command:command,coordsList:coordsList,keysList:keysList,isCommandUpperCase:isCommandUpperCase}=parseCoordsItem(value);if(!isCommandUpperCase)continue;if("m"==command&&null===minXY.x){const[x,y]=coordsList;minXY={x:x,y:y},this.lastUsedCoords={x:x,y:y};continue}const itemMinXY=this.findItemMinXY(keysList,coordsList,command);itemMinXY.x>=0&&itemMinXY.x<minXY.x&&(minXY.x=itemMinXY.x),itemMinXY.y>=0&&itemMinXY.y<minXY.y&&(minXY.y=itemMinXY.y),counter++}return minXY},PathConverter.prototype.addOmittedCommands=function(srcCoordsList){srcCoordsList=srcCoordsList.slice();const coordsFixed=[];let counter=0;const handledCommands={a:!0,t:!0,c:!0,s:!0,q:!0};for(;srcCoordsList.length>0&&counter<5e3;){let value=srcCoordsList.shift(),{commandSrc:commandSrc,command:command,coordsList:coordsList,keysList:keysList}=parseCoordsItem(value);if(keysList){let coords;if(handledCommands[command]&&coordsList.length>keysList.length){const cuttedTail=coordsList.splice(keysList.length);coords=coordsList.join(","),cuttedTail.length%keysList.length===0?(cuttedTail[0]=`${commandSrc}${cuttedTail[0]}`,srcCoordsList.unshift(cuttedTail.join(","))):console.log("\nCommand is broken, check params:",coordsList)}else coords=coordsList.join(",");value=`${commandSrc}${coords}`}else console.log("Unrecognized command: ",command);coordsFixed.push(value),counter++}return coordsFixed},PathConverter.prototype.removeStartSpaces=function(str,key){str=str.trim();let minSpace=this.fullCodes.spaces[key];void 0===minSpace&&(minSpace=findMinSpaces(str),this.fullCodes.spaces[key]=minSpace);const regexp=new RegExp(`^\\s{${minSpace}}`,"gm");return str.replace(regexp,"")}; 2//# sourceURL=https://146011624.fs1.hubspotusercontent-eu1.net/hubfs/146011624/hub_generated/template_assets/1/385640003802/1790178818068/template_remove-svg-offset.js
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.