/* 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 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}`;let t={colorize:"C",colorhex:"(?:[0-9a-fA-F]{3}){1,2}",colorname:"[a-zA-Z]+",padding:"P[0-9]{2}",zoom:"Z(?:[0-9]+(?:\\.[0-9]+)?|x)",classbase:"-?[_a-zA-Z][_a-zA-Z0-9-]{0,100}",id:"[a-zA-Z][_a-zA-Z0-9-]{0,100}"};t.colorbase=`(?:${t.colorhex}|${t.colorname})`,t.color=`_${t.colorbase}_`,t.colors=`_${t.colorbase}(?:,${t.colorbase})?_`,t.background=`G${t.color}`,t.detail=`D${t.colors}`,t.detailsym=`D[0-9]{2}${t.colors}`,t.classes=`${t.classbase}(?: ${t.classbase})*`,t.full=`-(${t.colorize})?(${t.padding})?(${t.background})?(${t.detail})?(${t.zoom})?(?:-((?:${t.detailsym})*))?(?:-(${t.classes})?!(?:(${t.id})!)?)?`;const e=o=>(new RegExp(`^${t.colorhex}$`).test(o)?"#":"")+o,s=o=>{const s=`^${t.full}`,r=("string"==typeof o?o.match(new RegExp(s)):[])||[];return i={colorize:r[1]?!!r[1]:void 0,padding:r[2]?parseInt(r[2].slice(1)):void 0,background:r[3]?e(r[3].slice(2,-1)):void 0,detail:r[4]?r[4].slice(2,-1).split(",").map(e):void 0,zoom:r[5]?"Zx"===r[5]?"x":parseFloat(r[5].slice(1)):void 0,detailsym:r[6]?r[6].match(new RegExp(t.detailsym,"g")).map((o=>{const t=o.split("_"),s=t[1].split(",").map(e);return{index:parseInt(t[0].slice(1)),detail:s}})):void 0,classes:r[7]?r[7]:void 0,id:r[8]?r[8]:void 0},Object.fromEntries(Object.entries(i).filter((([o,t])=>void 0!==t)));var i},r=o=>parseInt(o.codePointAt(0))-120844+250,i=o=>[r(o.slice(0,2)),r(o.slice(2,4))],n=o=>o.map((o=>(o=>String.fromCodePoint(120844+parseInt(o)-250))(o))).join(""),l=o=>parseInt(o.codePointAt(0)),a={symbol:e=>{const s=`^(${o.symbol})(${o.coord})?(${t.full})?`,r="string"==typeof e?e.match(new RegExp(s)):void 0;return{symbol:r?r[1]:void 0,coord:r&&r[2]?i(r[2]):void 0,style:r?r[3]:void 0}},sign:e=>{const s=`^(${o.prefix})?(${o.signbox})(${t.full})?`,r="string"==typeof e?e.match(new RegExp(s)):void 0;return r?{sequence:r[1]?r[1].slice(2).match(/.{2}/g):void 0,box:r[2].slice(0,2),max:i(r[2].slice(2,6)),spatials:r[2].length<7?void 0:r[2].slice(6).match(/(.{6})/g).map((o=>({symbol:o.slice(0,2),coord:i(o.slice(2))}))),style:r[3]}:{}},text:e=>{if("string"!=typeof e)return[];const s=`(${o.sign}(${t.full})?|${o.spatial}(${t.full})?)`,r=e.match(new RegExp(s,"g"));return r?[...r]:[]}},c={symbol:e=>{if("object"==typeof e&&null!==e&&"string"==typeof e.symbol){const s=(e.symbol.match(o.symbol)||[""])[0];if(s){const o=e.coord&&e.coord[0]||"",r=e.coord&&e.coord[1]||"";return s+(o&&r?n([o,r]):"")+("string"==typeof e.style&&(e.style.match(t.full)||[""])[0]||"")}}},sign:e=>{if("object"!=typeof e||null===e)return;let s="string"!=typeof e.box?"𝠃":(e.box+"𝠃").match(o.box);const r=e.max&&e.max[0]||"",i=e.max&&e.max[1]||"",l=r&&i?n([r,i]):void 0;if(!l)return;let a="";e.sequence&&Array.isArray(e.sequence)&&(a=e.sequence.map((t=>(t.match(o.symbol)||[""])[0])).join(""),a=a?"𝠀"+a:"");let c="";e.spatials&&Array.isArray(e.spatials)&&(c=e.spatials.map((t=>{if("string"==typeof t.symbol){const e=(t.symbol.match(o.symbol)||[""])[0];if(e){const o=t.coord&&t.coord[0]||"",s=t.coord&&t.coord[1]||"",r=o&&s?n([o,s]):"";if(r)return e+r}}return""})).join(""));return a+s+l+c+("string"==typeof e.style&&(e.style.match(t.full)||[""])[0]||"")}},p=o=>{let t,e,r,i,n,l,c,p,d=a.sign(o);d.spatials?(i=Math.min(...d.spatials.map((o=>o.coord[0]))),n=d.max[0],t=n-i,l=Math.min(...d.spatials.map((o=>o.coord[1]))),c=d.max[1],e=c-l,r="sign",p=d.box):(d=a.symbol(o),p="𝠃",d.coord?(i=d.coord[0],t=2*(500-i),l=d.coord[1],e=2*(500-l),r="symbol"):(i=490,t=20,l=490,e=20,r="none"));let u=s(d.style),m=u.zoom||1,f=u.padding||0;return{minX:i,minY:l,width:t,height:e,segment:r,lane:{"𝠁":0,"𝠂":-1,"𝠃":0,"𝠄":1}[p],padding:f,zoom:m}},d={height:500,width:150,offset:50,pad:20,margin:5,dynamic:!1,background:void 0,punctuation:{spacing:!0,pad:30,pull:!0},style:{detail:["black","white"],zoom:1}},u=o=>("object"!=typeof o&&(o={}),{...d,...o,punctuation:{...d.punctuation,...o.punctuation},style:{...d.style,...o.style}}),m=[262145,287201,310433,311201,321761,323489,324257],f={all:[262145,324736],writing:[262145,323488],hand:[262145,287200],movement:[287201,310432],dynamic:[310433,311200],head:[311201,321760],hcenter:[311201,321760],vcenter:[311201,322624],trunk:[321761,322624],limb:[322625,323488],location:[323489,324256],punctuation:[324257,324736]},g=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"];exports.category=m,exports.colorize=o=>{const t=a.symbol(o);let e="#000000";if(t.symbol){const o=l(t.symbol),s=m.findIndex((t=>t>o));e=g[s<0?6:s-1]}return e},exports.colors=g,exports.columnDefaults=d,exports.columnDefaultsMerge=u,exports.columns=(o,t)=>{if("string"!=typeof o)return{};const e=u(t);let s=a.text(o),r=0,i=[],n=[],l=0,c=parseInt(e.width/2),d=e.height-e.margin,m=!0,f=!1;for(let o of s){let t=p(o);r+=l,e.punctuation.spacing?r+="sign"==t.segment?e.pad:0:r+=e.pad,f=r+t.height>d,f&&"symbol"==t.segment&&e.punctuation.pull&&m&&(f=!1,m=!1),0==n.length&&(f=!1),f&&(r=e.pad,i.push(n),n=[],m=!0),n.push(Object.assign(t,{x:c+e.offset*t.lane-(500-t.minX)*t.zoom*e.style.zoom,y:r,text:o})),r+=t.height*t.zoom*e.style.zoom,l=e.punctuation.spacing?"sign"==t.segment?e.pad:e.punctuation.pad:e.pad}if(n.length&&i.push(n),e.punctuation.pull)for(let o of i){let t=o[o.length-1],s=t.y+t.height-(e.height-e.margin);if(s>0){let t=parseInt(s/o.length)+1;for(let e in o)o[e].y-=t*e+t}}let g=[];for(let o of i){let t=[c-e.offset-e.pad],s=[c+e.offset+e.pad];for(let r of o)t.push(r.x-e.pad),s.push(r.x+r.width+e.pad);t=Math.min(...t),s=Math.max(...s);let r=e.width,i=0;e.dynamic?(r=s-t,i=-t):i=c-parseInt((t+s)/2);for(let t of o)t.x+=i;g.push(r)}return{options:e,widths:g,columns:i}},exports.compose=c,exports.decode=o=>o.replace(/\\u([0-9A-F]{4})/g,(function(o,t){return String.fromCharCode(parseInt(t,16))})),exports.encode=o=>o.replace(/[\u007F-\uFFFF]/g,(function(o){return"\\u"+("0000"+o.charCodeAt(0).toString(16)).substr(-4).toUpperCase()})),exports.group=[262145,263489,265025,268673,269441,275009,277889,280001,281825,285665,287201,288833,290753,294881,296417,299777,302657,304289,307169,308513,310433,311201,312257,315329,316961,319841,321761,322625,323489,324257],exports.info=p,exports.isType=(o,t)=>{const e=a.symbol(o);if(e.symbol){const o=l(e.symbol),s=f[t];if(s)return s[0]<=o&&s[1]>=o}return!1},exports.kind=[262145,323489,324257],exports.pair=o=>[o.charCodeAt(0).toString(16).toUpperCase(),o.charCodeAt(1).toString(16).toUpperCase()],exports.parse=a,exports.ranges=f,exports.re=o;