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