/* Sutton SignWriting Core Module v1.2.0 (https://github.com/sutton-signwriting/core), author: Steve Slevinski (https://SteveSlevinski.me), license: MIT */ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});let re={symbol:"S[123][0-9a-f]{2}[0-5][0-9a-f]",coord:"[0-9]{3}x[0-9]{3}",sort:"A",box:"[BLMR]"};re.prefix=`(?:${re.sort}(?:${re.symbol})+)`,re.spatial=`${re.symbol}${re.coord}`,re.signbox=`${re.box}${re.coord}(?:${re.spatial})*`,re.sign=`${re.prefix}?${re.signbox}`,re.sortable=`${re.prefix}${re.signbox}`;let re$1={symbol:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:\ud836[\udc0c-\uddff]){2}",sort:"𝠀",box:"\ud836[\udc01-\udc04]"};re$1.prefix=`(?:${re$1.sort}(?:${re$1.symbol})+)`,re$1.spatial=`${re$1.symbol}${re$1.coord}`,re$1.signbox=`${re$1.box}${re$1.coord}(?:${re$1.spatial})*`,re$1.sign=`${re$1.prefix}?${re$1.signbox}`,re$1.sortable=`${re$1.prefix}${re$1.signbox}`;const swu2mark=e=>({"𝠀":"A","𝠁":"B","𝠂":"L","𝠃":"M","𝠄":"R"})[e],mark2swu=e=>({A:"𝠀",B:"𝠁",L:"𝠂",M:"𝠃",R:"𝠄"})[e],swu2num=e=>parseInt(e.codePointAt(0))-120844+250,num2swu=e=>String.fromCodePoint(120844+parseInt(e)-250),swu2coord=e=>[swu2num(e.slice(0,2)),swu2num(e.slice(2,4))],coord2swu=e=>e.map(e=>num2swu(e)).join(""),fsw2coord=e=>e.split("x").map(e=>parseInt(e)),coord2fsw=e=>e.join("x"),swu2code=e=>parseInt(e.codePointAt(0)),code2swu=e=>String.fromCodePoint(e),swu2id=e=>swu2code(e)-262144,id2swu=e=>code2swu(e+262144),key2id=e=>1+96*(parseInt(e.slice(1,4),16)-256)+16*parseInt(e.slice(4,5),16)+parseInt(e.slice(5,6),16),id2key=e=>{const r=e-1,s=parseInt(r/96),o=parseInt((r-96*s)/16),t=parseInt(r-96*s-16*o);return"S"+(s+256).toString(16)+o.toString(16)+t.toString(16)},swu2key=e=>{const r=swu2code(e)-262145,s=parseInt(r/96),o=parseInt((r-96*s)/16),t=parseInt(r-96*s-16*o);return"S"+(s+256).toString(16)+o.toString(16)+t.toString(16)},key2swu=e=>code2swu(262145+96*(parseInt(e.slice(1,4),16)-256)+16*parseInt(e.slice(4,5),16)+parseInt(e.slice(5,6),16)),swu2fsw=e=>{if(!e)return"";let r=e.replace(/𝠀/g,"A").replace(/𝠁/g,"B").replace(/𝠂/g,"L").replace(/𝠃/g,"M").replace(/𝠄/g,"R");const s=r.match(new RegExp(re$1.symbol,"g"));s&&s.forEach((function(e){r=r.replace(e,swu2key(e))}));const o=r.match(new RegExp(re$1.coord,"g"));return o&&o.forEach((function(e){r=r.replace(e,swu2coord(e).join("x"))})),r},fsw2swu=e=>{if(!e)return"";const r=e.match(new RegExp(re.prefix,"g"));r&&r.forEach((function(r){e=e.replace(r,"𝠀"+r.slice(1).match(/.{6}/g).map(e=>key2swu(e)).join(""))}));const s=e.match(new RegExp(re.box+re.coord,"g"));s&&s.forEach((function(r){e=e.replace(r,mark2swu(r.slice(0,1))+coord2swu(fsw2coord(r.slice(1,8))))}));const o=e.match(new RegExp(re.spatial,"g"));return o&&o.forEach((function(r){e=e.replace(r,key2swu(r.slice(0,6))+coord2swu(fsw2coord(r.slice(6,13))))})),e};exports.code2swu=code2swu,exports.coord2fsw=coord2fsw,exports.coord2swu=coord2swu,exports.fsw2coord=fsw2coord,exports.fsw2swu=fsw2swu,exports.id2key=id2key,exports.id2swu=id2swu,exports.key2id=key2id,exports.key2swu=key2swu,exports.mark2swu=mark2swu,exports.num2swu=num2swu,exports.swu2code=swu2code,exports.swu2coord=swu2coord,exports.swu2fsw=swu2fsw,exports.swu2id=swu2id,exports.swu2key=swu2key,exports.swu2mark=swu2mark,exports.swu2num=swu2num;