@sutton-signwriting/core
Version:
a javascript package for node and browsers that supports general processing of the Sutton SignWriting script
3 lines (2 loc) • 38.5 kB
JavaScript
/* Sutton SignWriting Core Module v2.0.0 (https://github.com/sutton-signwriting/core), author: Steve Slevinski (https://SteveSlevinski.me), license: MIT */
let e={null:"S00000",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.nullorsymbol=`(?:${e.null}|${e.symbol})`,e.prefix=`(?:${e.sort}${e.nullorsymbol}+)`,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 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 r=e=>(new RegExp(`^${t.colorhex}$`).test(e)?"#":"")+e,o=e=>{const o=`^${t.full}`,s=("string"==typeof e?e.match(new RegExp(o)):[])||[];return n={colorize:s[1]?!!s[1]:void 0,padding:s[2]?parseInt(s[2].slice(1)):void 0,background:s[3]?r(s[3].slice(2,-1)):void 0,detail:s[4]?s[4].slice(2,-1).split(",").map(r):void 0,zoom:s[5]?"Zx"===s[5]?"x":parseFloat(s[5].slice(1)):void 0,detailsym:s[6]?s[6].match(new RegExp(t.detailsym,"g")).map((e=>{const t=e.split("_"),o=t[1].split(",").map(r);return{index:parseInt(t[0].slice(1)),detail:o}})):void 0,classes:s[7]?s[7]:void 0,id:s[8]?s[8]:void 0},Object.fromEntries(Object.entries(n).filter((([e,t])=>void 0!==t)));var n},s=e=>"string"!=typeof e?[0,0,0]:e.replace(/rgba?\((.+?)\)/gi,((e,t)=>t)).split(",").map(Number),n=e=>e.slice(0,3).map((e=>e.toString(16).padStart(2,"0"))).join("");var a=Object.freeze({__proto__:null,re:t,parse:o,compose:e=>{if("object"!=typeof e||null===e)return;let r="-";r+=e.colorize?"C":"";const o=parseInt(e.padding);r+=!o||o<=0||o>99?"":"P"+(o>9?o:"0"+o);const s=e.background&&"string"==typeof e.background?e.background.match(t.colorbase)[0]:void 0;r+=s?"G_"+s+"_":"";const n=e.detail&&e.detail[0]&&"string"==typeof e.detail[0]?e.detail[0].match(t.colorbase)[0]:void 0,a=e.detail&&e.detail[1]&&"string"==typeof e.detail[1]?e.detail[1].match(t.colorbase)[0]:void 0;n&&(r+="D_"+n,a&&(r+=","+a),r+="_");const i="x"===e.zoom?"x":parseFloat(e.zoom);r+=!i||i<=0?"":"Z"+i;let l="";const c=e.detailsym&&Array.isArray(e.detailsym)?e.detailsym.map((e=>{const r=parseInt(e.index);if(!r||r<=0||r>99)return"";let o="D"+(r>9?r:"0"+r);const s=e.detail&&e.detail[0]?e.detail[0].match(t.colorbase)[0]:void 0,n=e.detail&&e.detail[1]?e.detail[1].match(t.colorbase)[0]:void 0;return s&&(o+="_"+s,n&&(o+=","+n),o+="_"),o})):[];l+=c.join("");let p="";const u=e.classes&&"string"==typeof e.classes?e.classes.match(t.classes)[0]:void 0;p+=u||"";const d=e.id&&"string"==typeof e.id?e.id.match(t.id)[0]:void 0;return p+=u||d?"!":"",p+=d?d+"!":"",r+(l||p?"-"+l:"")+(p?"-"+p:"")},merge:(e,t)=>{"object"!=typeof e&&(e={}),"object"!=typeof t&&(t={});const r="zoom"in e?e.zoom:1,o="zoom"in t?t.zoom:1;return{...e,...t,zoom:r*o}},rgb2hex:(e,t=0)=>{const r=s(e);return 4==r.length&&r[3]<=t?"transparent":n(r)},rgba2hex:(e,t)=>{const r=s(t),o=s(e),a=4==o.length?o[3]:1;return 0==a?"transparent":n(o.map(((e,t)=>parseInt((1-a)*r[t]+a*e))))}});let i={null:"",symbol:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:\ud836[\udc0c-\uddff]){2}",sort:"𝠀",box:"\ud836[\udc01-\udc04]"};i.nullorsymbol=`(?:${i.null}|${i.symbol})`,i.prefix=`(?:${i.sort}(?:${i.nullorsymbol})+)`,i.spatial=`${i.symbol}${i.coord}`,i.signbox=`${i.box}${i.coord}(?:${i.spatial})*`,i.sign=`${i.prefix}?${i.signbox}`,i.sortable=`${i.prefix}${i.signbox}`;const l=["101011","101021","101031","101041","101051","101061","101071","101081","101091","101101","101111","101121","101131","101141","102011","102021","102031","102041","102051","102061","102071","102081","102091","102101","102111","102121","102131","102141","102151","102161","103011","103021","103031","103041","103051","103061","103071","103081","103091","103101","103111","103121","103131","103141","103151","103161","103171","103181","103191","103201","103211","103221","103231","103241","103251","103261","103271","103281","103291","103301","103311","103321","103331","103341","103351","103361","103371","103381","104011","104021","104031","104041","104051","104061","104071","104081","105011","105021","105031","105041","105051","105061","105071","105081","105091","105101","105111","105121","105131","105141","105151","105161","105171","105181","105191","105201","105211","105221","105231","105241","105251","105261","105271","105281","105291","105301","105311","105321","105331","105341","105351","105361","105371","105381","105391","105401","105411","105421","105431","105441","105451","105461","105471","105481","105491","105501","105511","105521","105531","105541","105551","105561","105571","105581","106011","106021","106031","106041","106051","106061","106071","106081","106091","106101","106111","106121","106131","106141","106151","106161","106171","106181","106191","106201","106211","106221","106231","106241","106251","106261","106271","106281","106291","106301","107011","107021","107031","107041","107051","107061","107071","107081","107091","107101","107111","107121","107131","107141","107151","107161","107171","107181","107191","107201","107211","107221","108011","108021","108031","108041","108051","108061","108071","108081","108091","108101","108111","108121","108131","108141","108151","108161","108171","108181","108191","109011","109021","109031","109041","109051","109061","109071","109081","109091","109101","109111","109121","109131","109141","109151","109161","109171","109181","109191","109201","109211","109221","109231","109241","109251","109261","109271","109281","109291","109301","109311","109321","109331","109341","109351","109361","109371","109381","109391","109401","110011","110021","110031","110041","110051","110061","110071","110081","110091","110101","110111","110121","110131","110141","110151","110161","201011","201021","201031","201041","201051","201061","201071","201081","201091","201101","201111","201121","201131","201141","201151","201161","201171","202011","202012","202021","202022","202031","202041","202042","202051","202052","202061","202071","202081","202082","202091","202092","202101","202102","202111","202121","202131","203011","203012","203013","203014","203015","203021","203022","203031","203032","203041","203051","203052","203061","203062","203071","203072","203073","203081","203082","203083","203084","203091","203092","203093","203101","203102","203103","203111","203112","203113","203121","203122","203123","203131","203141","203151","203161","203171","203181","203191","203201","203202","203203","204011","204012","204013","204014","204021","204022","204023","204024","204031","204032","204033","204034","204041","204042","204043","204044","205011","205012","205013","205014","205015","205021","205022","205031","205032","205041","205051","205052","205061","205062","205071","205081","205082","205083","205091","205101","205102","205103","205111","205112","205113","205121","205122","205123","205131","205141","205151","205161","205171","205181","205191","206011","206012","206013","206014","206021","206022","206023","206024","206031","206032","206041","206042","206043","206051","206052","206053","206054","206061","206062","206063","206064","206065","206066","206071","206072","206073","206081","206091","206101","206111","207011","207021","207031","207041","207051","207061","207071","207091","207101","207111","207121","207131","207141","207151","207161","207162","207163","208011","208012","208021","208022","208023","208024","208031","208032","208033","208034","208041","208042","208051","208061","208071","208081","208082","208091","208092","208093","208094","208101","208102","208103","208104","208111","208112","208121","208131","208141","209011","209012","209013","209014","209015","209021","209031","209041","209042","209043","209051","209061","209071","209081","210011","210012","210021","210022","210031","210032","210033","210041","210042","210043","210051","210052","210061","210062","210071","210072","210073","210074","210081","210082","301011","301021","301031","301032","301041","301042","301043","301044","401011","401021","401031","401041","401051","401061","401071","401081","401091","401101","401102","402011","402012","402013","402021","402022","402023","402024","402031","402032","402033","402041","402042","402043","402044","402045","402051","402052","402053","402054","402055","402061","402062","402063","402071","402072","402073","402081","402082","402083","402091","402101","402111","403011","403012","403013","403021","403022","403023","403031","403041","403042","403043","403044","403051","403052","403061","403062","403071","403072","404011","404012","404013","404021","404022","404023","404031","404032","404033","404041","404042","404043","404051","404052","404053","404061","404062","404063","404071","404072","404073","404081","404082","404083","404091","404092","404093","404101","404111","404112","405011","405012","405013","405014","405015","405021","405031","405041","405051","405052","405061","405062","405071","405072","405081","405091","405101","405111","405121","405131","501011","501021","501031","501041","501051","501061","501071","501081","501091","502011","502021","502022","502023","502024","502031","502032","502033","502041","601011","601012","601021","601031","601041","601051","601061","601071","701011","701012","701021","701022","701031"],c=e=>({A:"𝠀",B:"𝠁",L:"𝠂",M:"𝠃",R:"𝠄"}[e]),p=e=>parseInt(e.codePointAt(0))-120844+250,u=e=>String.fromCodePoint(120844+parseInt(e)-250),d=e=>[p(e.slice(0,2)),p(e.slice(2,4))],f=e=>e.map((e=>u(e))).join(""),g=e=>e.split("x").map((e=>parseInt(e))),m=e=>parseInt(e.codePointAt(0)),h=e=>String.fromCodePoint(e),y=e=>{if(""===e)return"S00000";const t=m(e)-262145,r=parseInt(t/96),o=parseInt((t-96*r)/16),s=parseInt(t-96*r-16*o);return"S"+(r+256).toString(16)+o.toString(16)+s.toString(16)},b=e=>h("S00000"===e?262144:262145+96*(parseInt(e.slice(1,4),16)-256)+16*parseInt(e.slice(4,5),16)+parseInt(e.slice(5,6),16)),x=e=>{if(!/^\d{6}(?:\d{3})?$/.test(e))return"";let t=`0${e.charAt(0)}-${e.charAt(1)}${e.charAt(2)}-0${e.charAt(3)}${e.charAt(4)}-0${e.charAt(5)}`;return e.length>6&&(t+=`-0${e.charAt(6)}-${e.charAt(7)}${e.charAt(8)}`),t};var $=Object.freeze({__proto__:null,swu2mark:e=>({"𝠀":"A","𝠁":"B","𝠂":"L","𝠃":"M","𝠄":"R"}[e]),mark2swu:c,swu2num:p,num2swu:u,swu2coord:d,coord2swu:f,fsw2coord:g,coord2fsw:e=>e.join("x"),swu2code:m,code2swu:h,swu2id:e=>m(e)-262144,id2swu:e=>h(e+262144),key2id:e=>"S00000"===e?0:1+96*(parseInt(e.slice(1,4),16)-256)+16*parseInt(e.slice(4,5),16)+parseInt(e.slice(5,6),16),id2key:e=>{if(0===e)return"S00000";const t=e-1,r=parseInt(t/96),o=parseInt((t-96*r)/16),s=parseInt(t-96*r-16*o);return"S"+(r+256).toString(16)+o.toString(16)+s.toString(16)},swu2key:y,key2swu:b,swu2fsw:e=>{if(!e)return"";let t=e.replace(/𝠀/g,"A").replace(/𝠁/g,"B").replace(/𝠂/g,"L").replace(/𝠃/g,"M").replace(/𝠄/g,"R");const r=t.match(new RegExp(i.nullorsymbol,"g"));r&&r.forEach((function(e){t=t.replace(e,y(e))}));const o=t.match(new RegExp(i.coord,"g"));return o&&o.forEach((function(e){t=t.replace(e,d(e).join("x"))})),t},fsw2swu:t=>{if(!t)return"";const r=t.match(new RegExp(e.prefix,"g"));r&&r.forEach((function(e){t=t.replace(e,"𝠀"+e.slice(1).match(/.{6}/g).map((e=>b(e))).join(""))}));const o=t.match(new RegExp(e.box+e.coord,"g"));o&&o.forEach((function(e){t=t.replace(e,c(e.slice(0,1))+f(g(e.slice(1,8))))}));const s=t.match(new RegExp(e.spatial,"g"));return s&&s.forEach((function(e){t=t.replace(e,b(e.slice(0,6))+f(g(e.slice(6,13))))})),t},symidArr:l,symidMax:x,symidMin:e=>{const t=e.match(/^0(\d)-(\d{2})-0(\d{2})-0(\d)(?:-0(\d)-(\d{2}))?$/);return t?t[5]?t[1]+t[2]+t[3]+t[4]+t[5]+t[6]:t[1]+t[2]+t[3]+t[4]:""},symid2key:e=>{const t=e.match(/^0(\d)-(\d{2})-0(\d{2})-0(\d)(?:-0(\d)-(\d{2}))?$/);if(!t)return"";const r=t[1]+t[2]+t[3]+t[4],o=l.indexOf(r);return-1===o?"":t[5]?"S"+(256+o).toString(16)+(parseInt(t[5],10)-1)+(parseInt(t[6],10)-1).toString(16):"S"+(256+o).toString(16)},key2symid:e=>{const t=e.match(/^S([1-3][0-9a-f]{2})(?:([0-5])([0-9a-f]))?$/);if(!t)return"";const r=parseInt(t[1],16)-256;return r>=l.length?"":t[3]?x(l[r])+"-0"+(1+parseInt(t[2]))+"-"+(parseInt(t[3],16)+1).toString().padStart(2,"0"):x(l[r])}});const w={symbol:r=>{const o=`^(${e.symbol})(${e.coord})?(${t.full})?`,s="string"==typeof r?r.match(new RegExp(o)):void 0;return{symbol:s?s[1]:void 0,coord:s&&s[2]?g(s[2]):void 0,style:s?s[3]:void 0}},sign:r=>{const o=`^(${e.prefix})?(${e.signbox})(${t.full})?`,s="string"==typeof r?r.match(new RegExp(o)):void 0;return s?{sequence:s[1]?s[1].slice(1).match(/.{6}/g):void 0,box:s[2][0],max:g(s[2].slice(1,8)),spatials:s[2].length<9?void 0:s[2].slice(8).match(/(.{13})/g).map((e=>({symbol:e.slice(0,6),coord:[parseInt(e.slice(6,9)),parseInt(e.slice(10,13))]}))),style:s[3]}:{}},text:r=>{if("string"!=typeof r)return[];const o=`(${e.sign}(${t.full})?|${e.spatial}(${t.full})?)`,s=r.match(new RegExp(o,"g"));return s?[...s]:[]}},v={symbol:r=>{if("string"==typeof r.symbol){const o=(r.symbol.match(e.symbol)||[""])[0];if(o){return o+((((r.coord&&r.coord[0]||"").toString()+"x"+(r.coord&&r.coord[1]||"").toString()).match(e.coord)||[""])[0]||"")+("string"==typeof r.style&&(r.style.match(t.full)||[""])[0]||"")}}},sign:r=>{let o="string"!=typeof r.box?"M":(r.box+"M").match(e.box);const s=(((r.max&&r.max[0]||"").toString()+"x"+(r.max&&r.max[1]||"").toString()).match(e.coord)||[""])[0]||"";if(!s)return;let n="";r.sequence&&Array.isArray(r.sequence)&&(n=r.sequence.map((t=>(t.match(e.nullorsymbol)||[""])[0])).join(""),n=n?"A"+n:"");let a="";r.spatials&&Array.isArray(r.spatials)&&(a=r.spatials.map((t=>{if("string"==typeof t.symbol){const r=(t.symbol.match(e.symbol)||[""])[0];if(r){const o=(((t.coord&&t.coord[0]||"").toString()+"x"+(t.coord&&t.coord[1]||"").toString()).match(e.coord)||[""])[0]||"";if(o)return r+o}}return""})).join(""));return n+o+s+a+("string"==typeof r.style&&(r.style.match(t.full)||[""])[0]||"")}},A=e=>{let t,r,s,n,a,i,l,c,p=w.sign(e);p.spatials?(n=Math.min(...p.spatials.map((e=>e.coord[0]))),a=p.max[0],t=a-n,i=Math.min(...p.spatials.map((e=>e.coord[1]))),l=p.max[1],r=l-i,s="sign",c=p.box):(p=w.symbol(e),c="M",p.coord?(n=p.coord[0],t=2*(500-n),i=p.coord[1],r=2*(500-i),s="symbol"):(n=490,t=20,i=490,r=20,s="none"));let u=o(p.style),d=u.zoom||1,f=u.padding||0;return{minX:n,minY:i,width:t,height:r,segment:s,lane:{B:0,L:-1,M:0,R:1}[c],padding:f,zoom:d}},I=[{index:0,name:"UNK",value:"[UNK]"},{index:1,name:"PAD",value:"[PAD]"},{index:2,name:"CLS",value:"[CLS]"},{index:3,name:"SEP",value:"[SEP]"}],S=(e,{sequence:t=!0,signbox:r=!0,sep:o="[SEP]"}={})=>{const s=e=>[e.slice(0,4),`c${e.charAt(4)}`,`r${e.charAt(5)}`],n=e=>e.map((e=>`p${e}`));return w.text(e).map((e=>{if(/[BLMR]/.test(e)){const a=w.sign(e),i=[];return a.sequence&&t&&i.push("A",...a.sequence.map((e=>s(e))).flat()),r&&i.push(a.box,...n(a.max),...a.spatials.flatMap((e=>[...s(e.symbol),...n(e.coord)]))),o?[...i,o]:i}{const a=w.symbol(e);if(!r&&!t)return[];let i=[];return i=!r&&t?["A",...s(a.symbol)]:["M",...n(a.coord.map((e=>1e3-e))),...s(a.symbol),...n(a.coord)],i.length>0&&o?[...i,o]:i}})).flatMap((e=>e))},k=(e,t=I)=>{const r=new Set(t.map((e=>e.value)));return e.filter((e=>!r.has(e))).join(" ").replace(/\bp(\d{3})\s+p(\d{3})/g,"$1x$2").replace(/ c(\d)\d? r(.)/g,"$1$2").replace(/ c(\d)\d?/g,"$10").replace(/ r(.)/g,"0$1").replace(/ /g,"").replace(/(\d)([BLMR])/g,"$1 $2").replace(/(\d)(AS)/g,"$1 $2").replace(/(A(?:S00000|S[123][0-9a-f]{2}[0-5][0-9a-f])+)( )([BLMR])/g,"$1$3")},R={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}},E=e=>("object"!=typeof e&&(e={}),{...R,...e,punctuation:{...R.punctuation,...e.punctuation},style:{...R.style,...e.style}}),j=[256,517,759,767,877,895,903],z={all:[256,907],writing:[256,894],hand:[256,516],movement:[517,758],dynamic:[759,766],head:[767,876],hcenter:[767,876],vcenter:[767,885],trunk:[877,885],limb:[886,894],location:[895,902],punctuation:[903,907]},_=["#0000CC","#CC0000","#FF0099","#006600","#000000","#884411","#FF9900"];var C=Object.freeze({__proto__:null,re:e,parse:w,compose:v,info:A,tokenize:S,detokenize:k,createTokenizer:(e=I,t=null)=>{const r=(e=>{const t={},r={},o={},s=new Set;return e.forEach((e=>{if(s.has(e.index))throw new Error(`Duplicate token index: ${e.index}`);s.add(e.index),t[e.index]=e,r[e.name]=e,o[e.value]=e})),{byIndex:t,byName:r,byValue:o,getByIndex:r=>t[r]||t[e.find((e=>"UNK"===e.name)).index],getByName:e=>r[e]||r.UNK,getByValue:e=>o[e]||r.UNK,getAllValues:()=>e.map((e=>e.value)),getAllIndices:()=>e.map((e=>e.index))}})(e),o=t??(r.getAllIndices().length>0?Math.max(...r.getAllIndices())+1:0),s=(()=>{const e=(e,t)=>Array.from({length:t-e},((t,r)=>e+r)),t=(t,r)=>e(t,r+1).map((e=>e.toString(16)));return["A","B","L","M","R","S000",...e(256,908).map((e=>`S${e.toString(16)}`)),...t(0,15).map((e=>`r${e}`)),...t(0,5).map((e=>`c${e}`)),...e(250,750).map((e=>`p${e}`))]})(),{i2s:n,s2i:a}=((e,t,r)=>{const o={},s={};return Object.values(t.byIndex).forEach((e=>{o[e.index]=e.value,s[e.value]=e.index})),e.forEach(((e,t)=>{const n=r+t;o[n]=e,s[e]=n})),{i2s:o,s2i:s}})(s,r,o),i={i2s:n,s2i:a,specialTokens:r,length:Object.keys(n).length,vocab:()=>Object.values(n),encodeTokens:e=>e.map((e=>void 0!==a[e]?a[e]:r.getByValue(e).index)),decodeTokens:e=>e.map((e=>n[e]||r.getByName("UNK").value)),encode:(e,t={})=>{const o=S(e,{...t,sep:r.getByName("SEP").value});return i.encodeTokens(o)},decode:t=>{if(0===t.length)return"";if(Array.isArray(t[0])){const r=t.map((e=>i.decodeTokens(e)));return k(r.flat(),e)}const r=i.decodeTokens(t);return k(r,e)},chunk:(e,t)=>((e,t,{cls:r="[CLS]",sep:o="[SEP]",pad:s="[PAD]"}={})=>{if(t<60)throw new Error("Chunk size must be at least 60 tokens to accommodate a typical sign");const n=[];let a=[],i=0;for(;i<e.length;){for(a=[r];i<e.length;){e[i];let r=i;for(;r<e.length&&e[r]!==o;)r++;const s=r-i+1;if(a.length+s>t-1)break;for(;i<=r;)a.push(e[i]),i++}for(;a.length<t;)a.push(s);n.push(a)}return n})(e,t,{cls:r.getByName("CLS").value,sep:r.getByName("SEP").value,pad:r.getByName("PAD").value})};return i},columnDefaults:R,columnDefaultsMerge:E,columns:(e,t)=>{if("string"!=typeof e)return{};const r=E(t);let o=w.text(e),s=0,n=[],a=[],i=0,l=parseInt(r.width/2),c=r.height-r.margin,p=!0,u=!1;for(let e of o){let t=A(e);s+=i,r.punctuation.spacing?s+="sign"==t.segment?r.pad:0:s+=r.pad,u=s+t.height>c,u&&"symbol"==t.segment&&r.punctuation.pull&&p&&(u=!1,p=!1),0==a.length&&(u=!1),u&&(s=r.pad,n.push(a),a=[],p=!0),a.push(Object.assign(t,{x:l+r.offset*t.lane-(500-t.minX)*t.zoom*r.style.zoom,y:s,text:e})),s+=t.height*t.zoom*r.style.zoom,i=r.punctuation.spacing?"sign"==t.segment?r.pad:r.punctuation.pad:r.pad}if(a.length&&n.push(a),r.punctuation.pull)for(let e of n){let t=e[e.length-1],o=t.y+t.height-(r.height-r.margin);if(o>0){let t=parseInt(o/e.length)+1;for(let r in e)e[r].y-=t*r+t}}let d=[];for(let e of n){let t=[l-r.offset-r.pad],o=[l+r.offset+r.pad];for(let s of e)t.push(s.x-r.pad),o.push(s.x+s.width+r.pad);t=Math.min(...t),o=Math.max(...o);let s=r.width,n=0;r.dynamic?(s=o-t,n=-t):n=l-parseInt((t+o)/2);for(let t of e)t.x+=n;d.push(s)}return{options:r,widths:d,columns:n}},kind:[256,895,903],category:j,group:[256,270,286,324,332,390,420,442,461,501,517,534,554,597,613,648,678,695,725,739,759,767,778,810,827,857,877,886,895,903],ranges:z,isType:(e,t)=>{const r=w.symbol(e);if(r.symbol){const e=parseInt(r.symbol.slice(1,4),16),o=z[t];if(o)return o[0]<=e&&o[1]>=e}return!1},colors:_,colorize:e=>{const t=w.symbol(e);let r="#000000";if(t.symbol){const e=parseInt(t.symbol.slice(1,4),16),o=j.findIndex((t=>t>e));r=_[o<0?6:o-1]}return r}});let F={null:"S00000",base:"[123][0-9a-f]{2}",coord:"(?:[0-9]{3}x[0-9]{3})?",var:"V[0-9]+"};F.symbol=`S${F.base}[0-5u][0-9a-fu]`,F.nullorsymbol=`(?:${F.null}|${F.symbol})`,F.range=`R${F.base}t${F.base}`,F.item=`(?:${F.null}|${F.symbol}|${F.range})`,F.list=`${F.item}(?:o${F.item})*`,F.prefix=`(?:A(?:${F.list})+)?T`,F.signbox=`(?:${F.list}${F.coord})*`,F.full=`Q(${F.prefix})?(${F.signbox})?(${F.var})?(-?)`;const O=e=>e.match(new RegExp(`(${F.list}${F.coord})`,"g")).map((e=>{let t,r;return e.includes("x")?(t=g(e.slice(-7)),r=e.slice(0,-7)):r=e,r.includes("o")?{or:r.split("o").map((e=>e.includes("S")?e:e.slice(1).split("t"))),coord:t,coord:t}:r.includes("S")?{symbol:r,coord:t}:{range:r.slice(1).split("t"),coord:t}})),M=(e,t,r)=>{let o,s,n,a,i,l,c;if(r||(r=""),o="",(e=("000"+e).slice(-3))===(t=""+t))return e;if(s=[],(e[0]!=t[0]||e[1]!=t[1])&&"0"!=e[2])if(o=e[0]+e[1],r){switch(e[2]){case"f":o+="f";break;case"e":o+="[ef]";break;case"d":case"c":case"b":case"a":o+="["+e[2]+"-f]";break;default:switch(e[2]){case"9":o+="[9a-f]";break;case"8":o+="[89a-f]";break;default:o+="["+e[2]+"-9a-f]"}}n=15-parseInt(e[2],16)+1,e=""+(parseInt(e,16)+n).toString(16),s.push(o)}else{switch(e[2]){case"9":o+="9";break;case"8":o+="[89]";break;default:o+="["+e[2]+"-9]"}n=9-e[2]+1,e=""+(1*e+n),s.push(o)}if(o="",e[0]!=t[0]&&"0"!=e[1])if(r){switch(o=e[0],e[1]){case"f":o+="f";break;case"e":o+="[ef]";break;case"d":case"c":case"b":case"a":o+="["+e[1]+"-f]";break;case"9":o+="[9a-f]";break;case"8":o+="[89a-f]";break;default:o+="["+e[1]+"-9a-f]"}o+="[0-9a-f]",n=15-parseInt(e[1],16)+1,e=""+(parseInt(e,16)+16*n).toString(16),s.push(o)}else{switch(o=e[0],n=9-e[1]+1,e[1]){case"9":o+="9";break;case"8":o+="[89]";break;default:o+="["+e[1]+"-9]"}o+="[0-9]",n=9-e[1]+1,e=""+(1*e+10*n),s.push(o)}if(o="",e[0]!=t[0])if(r){switch(n=parseInt(t[0],16)-parseInt(e[0],16),a=(parseInt(e[0],16)+n-1).toString(16),n){case 1:o=e[0];break;case 2:o="["+e[0]+a+"]";break;default:switch(l=parseInt(e[0],16)>9?"h":"d",c=parseInt(a,16)>9?"h":"d",l+c){case"dd":case"hh":o+="["+e[0]+"-"+a+"]";break;case"dh":switch(n=9-e[0],n){case 0:o+="[9";break;case 1:o+="[89";break;default:o+="["+e[0]+"-9"}switch(a[0]){case"a":o+="a]";break;case"b":o+="ab]";break;default:o+="a-"+a+"]"}}}o+="[0-9a-f][0-9a-f]",n=parseInt(t[0],16)-parseInt(e[0],16),e=""+(parseInt(e,16)+256*n).toString(16),s.push(o)}else{switch(n=t[0]-e[0],a=1*e[0]+n-1,n){case 1:o=e[0];break;case 2:o="["+e[0]+a+"]";break;default:o="["+e[0]+"-"+a+"]"}o+="[0-9][0-9]",e=""+(1*e+100*n),s.push(o)}if(o="",e[1]!=t[1])if(r){switch(n=parseInt(t[1],16)-parseInt(e[1],16),a=(parseInt(e[1],16)+n-1).toString(16),o=e[0],n){case 1:o+=e[1];break;case 2:o+="["+e[1]+a+"]";break;default:switch(l=parseInt(e[1],16)>9?"h":"d",c=parseInt(a,16)>9?"h":"d",l+c){case"dd":o+="["+e[1],n>1&&(o+="-"),o+=a+"]";break;case"dh":switch(n=9-e[1],n){case 0:o+="[9";break;case 1:o+="[89";break;default:o+="["+e[1]+"-9"}switch(t[1]){case"a":o+="]";break;case"b":o+="a]";break;default:o+="a-"+(parseInt(t[1],16)-1).toString(16)+"]"}break;case"hh":o+="["+e[1],n>1&&(o+="-"),o+=(parseInt(t[1],16)-1).toString(16)+"]"}}o+="[0-9a-f]",n=parseInt(t[1],16)-parseInt(e[1],16),e=""+(parseInt(e,16)+16*n).toString(16),s.push(o)}else{switch(n=t[1]-e[1],a=1*e[1]+n-1,o=e[0],n){case 1:o+=e[1];break;case 2:o+="["+e[1]+a+"]";break;default:o+="["+e[1]+"-"+a+"]"}o+="[0-9]",e=""+(1*e+10*n),s.push(o)}if(o="",e[2]!=t[2])if(r){switch(o=e[0]+e[1],n=parseInt(t[2],16)-parseInt(e[2],16),l=parseInt(e[2],16)>9?"h":"d",c=parseInt(t[2],16)>9?"h":"d",l+c){case"dd":case"hh":o+="["+e[2],n>1&&(o+="-"),o+=t[2]+"]";break;case"dh":switch(n=9-e[2],n){case 0:o+="[9";break;case 1:o+="[89";break;default:o+="["+e[2]+"-9"}switch(t[2]){case"a":o+="a]";break;case"b":o+="ab]";break;default:o+="a-"+t[2]+"]"}}n=parseInt(t[2],16)-parseInt(e[2],16),e=""+(parseInt(e,16)+n).toString(16),s.push(o)}else{switch(n=t[2]-e[2],o=e[0]+e[1],n){case 0:o+=e[2];break;case 1:o+="["+e[2]+t[2]+"]";break;default:o+="["+e[2]+"-"+t[2]+"]"}e=""+(1*e+n),s.push(o)}return o="","0"==e[2]&&"0"==t[2]&&(o=t,s.push(o)),o="",i=s.length,1==i?o=s[0]:(o=s.join(")|("),o="(("+o+"))"),o},q=e=>{let t=e.slice(0,4),r=e.slice(4,5);t+="u"==r?"[0-5]":r;let o=e.slice(5,6);return t+="u"==o?"[0-9a-f]":o,t},T=e=>{let t=e.slice(1,4),r=e.slice(5,8);return"S"+M(t,r,"hex")+"[0-5][0-9a-f]"},D=r=>{if(!(r=r.match(new RegExp(`^${F.full}`))[0]))return"";var o,s,n,a,i,l,c,p,u,d,f,m=20,h="(?:"+t.full+")?";if("Q"==r)return[e.prefix+"?"+e.signbox];if("Q-"==r)return[e.prefix+"?"+e.signbox+h];if("QT"==r)return[e.prefix+e.signbox];if("QT-"==r)return[e.prefix+e.signbox+h];var y=[],b=r.indexOf("T")+1;if(b){f="(?:A";var x=r.slice(0,b);if(r=r.replace(x,""),"QT"==x)f+=e.nullorsymbol+"+)";else if(o=x.match(new RegExp(F.list,"g"))){for(i=0;i<o.length;i+=1)if(a=[],s=o[i].match(new RegExp(F.item,"g"))){for(l=0;l<s.length;l+=1)(n=s[l].match(new RegExp(F.nullorsymbol)))?a.push(q(n[0])):a.push(T(s[l]));1==a.length?f+=a[0]:f+="(?:"+a.join("|")+")"}f+=e.nullorsymbol+"*)"}}if((o=r.match(new RegExp(F.var,"g")))&&(m=1*o.toString().slice(1)),o=r.match(new RegExp(F.list+F.coord,"g")))for(i=0;i<o.length;i+=1){if(a=[],s=o[i].match(new RegExp("("+F.symbol+"|"+F.range+")","g"))){for(l=0;l<s.length;l+=1)(n=s[l].match(new RegExp(F.symbol)))?a.push(q(n[0])):a.push(T(s[l]));c=1==a.length?a[0]:"(?:"+a.join("|")+")"}o[i].includes("x")?(u=(p=g(o[i].slice(-7)))[0],d=p[1],c+=M(u-m,u+m),c+="x",c+=M(d-m,d+m)):c+=e.coord,c=e.signbox+c+"(?:"+e.symbol+e.coord+")*",c=b?f+c:e.prefix+"?"+c,r.indexOf("-")>0&&(c+=h),y.push(c)}return y.length||(r.indexOf("-")>0&&(c+=h),y.push(f+e.signbox)),y};var B=Object.freeze({__proto__:null,re:F,parse:e=>{const t="string"==typeof e?e.match(new RegExp(`^${F.full}`)):void 0;return{query:!!t||void 0,prefix:t&&t[1]?(r=t[1],{required:!0,parts:"T"==r?void 0:r.match(new RegExp(`${F.list}`,"g")).map((e=>e.includes("o")?["or"].concat(e.match(new RegExp(`(${F.item})`,"g")).map((e=>"S"==e[0]?e:e.slice(1).split("t")))):"S"==e[0]?e:e.slice(1).split("t")))}):void 0,signbox:t&&t[2]?O(t[2]):void 0,variance:t&&t[3]?parseInt(t[3].slice(1)):void 0,style:!(!t||!t[4])||void 0};var r},compose:e=>{if(!e||!e.query)return;let t="Q";return e.prefix&&e.prefix.required&&(Array.isArray(e.prefix.parts)&&(t+="A",t+=e.prefix.parts.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}t${e[1]}`:Array.isArray(e)&&e.length>2&&"or"==e[0]?(e.shift(),e.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}t${e[1]}`:void 0)).join("o")):void 0)).join("")),t+="T"),Array.isArray(e.signbox)&&(t+=e.signbox.map((e=>{let t;return e.or?t=e.or.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}t${e[1]}`:void 0)).join("o"):e.symbol?t=e.symbol:e.range&&Array.isArray(e.range)&&2==e.range.length&&(t=`R${e.range[0]}t${e.range[1]}`),t+(Array.isArray(e.coord)&&2==e.coord.length?e.coord.join("x"):"")})).join("")),t+=e.style?"-":"",t=t.match(new RegExp(`^${F.full}`))[0],t},fsw2query:(e,t)=>{let r="";const o=w.sign(e);if(o.box){const e=t.indexOf("A")>-1,s=t.indexOf("a")>-1,n=t.indexOf("S")>-1,a=t.indexOf("s")>-1,i=t.indexOf("L")>-1;return(e||s||n||a)&&((e||s)&&o.sequence&&(r+="A",r+=o.sequence.map((e=>e.slice(0,4)+(s?"uu":e.slice(4,6)))).join(""),r+="T"),(n||a)&&o.spatials&&(r+=o.spatials.map((e=>e.symbol.slice(0,4)+(a?"uu":e.symbol.slice(4,6))+(i?e.coord.join("x"):""))).join(""))),r?"Q"+r:void 0}},range:M,regex:D,results:(e,t)=>{if(!t)return[];let r,o,s,n,a,i=D(e);if(!i)return[];for(a=0;a<i.length;a+=1)r=i[a],o=t.match(new RegExp(r,"g")),t=o?o.join(" "):"";return t?(s=t.split(" "),n=s.filter((function(e){return!(e in s)&&(s[e]=!0)}),{})):n=[],n},lines:(e,t)=>{if(!t)return[];let r,o,s,n,a,i=D(e);if(!i)return[];for(a=0;a<i.length;a+=1)r=i[a],r="^"+r+".*",o=t.match(new RegExp(r,"mg")),t=o?o.join("\n"):"";return t?(s=t.split("\n"),n=s.filter((function(e){return!(e in s)&&(s[e]=!0)}),{})):n=[],n}});const P={symbol:e=>{const r=`^(${i.symbol})(${i.coord})?(${t.full})?`,o="string"==typeof e?e.match(new RegExp(r)):void 0;return{symbol:o?o[1]:void 0,coord:o&&o[2]?d(o[2]):void 0,style:o?o[3]:void 0}},sign:e=>{const r=`^(${i.prefix})?(${i.signbox})(${t.full})?`,o="string"==typeof e?e.match(new RegExp(r)):void 0;return o?{sequence:o[1]?o[1].slice(2).match(/.{2}/g):void 0,box:o[2].slice(0,2),max:d(o[2].slice(2,6)),spatials:o[2].length<7?void 0:o[2].slice(6).match(/(.{6})/g).map((e=>({symbol:e.slice(0,2),coord:d(e.slice(2))}))),style:o[3]}:{}},text:e=>{if("string"!=typeof e)return[];const r=`(${i.sign}(${t.full})?|${i.spatial}(${t.full})?)`,o=e.match(new RegExp(r,"g"));return o?[...o]:[]}},Q=e=>e.replace(/\\u([0-9A-F]{4})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})),L=e=>[e.charCodeAt(0).toString(16).toUpperCase(),e.charCodeAt(1).toString(16).toUpperCase()],N={symbol:e=>{if("object"==typeof e&&null!==e&&"string"==typeof e.symbol){const r=(e.symbol.match(i.symbol)||[""])[0];if(r){const o=e.coord&&e.coord[0]||"",s=e.coord&&e.coord[1]||"";return r+(o&&s?f([o,s]):"")+("string"==typeof e.style&&(e.style.match(t.full)||[""])[0]||"")}}},sign:e=>{if("object"!=typeof e||null===e)return;let r="string"!=typeof e.box?"𝠃":(e.box+"𝠃").match(i.box);const o=e.max&&e.max[0]||"",s=e.max&&e.max[1]||"",n=o&&s?f([o,s]):void 0;if(!n)return;let a="";e.sequence&&Array.isArray(e.sequence)&&(a=e.sequence.map((e=>(e.match(i.nullorsymbol)||[""])[0])).join(""),a=a?"𝠀"+a:"");let l="";e.spatials&&Array.isArray(e.spatials)&&(l=e.spatials.map((e=>{if("string"==typeof e.symbol){const t=(e.symbol.match(i.symbol)||[""])[0];if(t){const r=e.coord&&e.coord[0]||"",o=e.coord&&e.coord[1]||"",s=r&&o?f([r,o]):"";if(s)return t+s}}return""})).join(""));return a+r+n+l+("string"==typeof e.style&&(e.style.match(t.full)||[""])[0]||"")}},U=e=>{let t,r,s,n,a,i,l,c,p=P.sign(e);p.spatials?(n=Math.min(...p.spatials.map((e=>e.coord[0]))),a=p.max[0],t=a-n,i=Math.min(...p.spatials.map((e=>e.coord[1]))),l=p.max[1],r=l-i,s="sign",c=p.box):(p=P.symbol(e),c="𝠃",p.coord?(n=p.coord[0],t=2*(500-n),i=p.coord[1],r=2*(500-i),s="symbol"):(n=490,t=20,i=490,r=20,s="none"));let u=o(p.style),d=u.zoom||1,f=u.padding||0;return{minX:n,minY:i,width:t,height:r,segment:s,lane:{"𝠁":0,"𝠂":-1,"𝠃":0,"𝠄":1}[c],padding:f,zoom:d}},Z={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}},V=e=>("object"!=typeof e&&(e={}),{...Z,...e,punctuation:{...Z.punctuation,...e.punctuation},style:{...Z.style,...e.style}}),K=[262145,287201,310433,311201,321761,323489,324257],X={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"];var Y=Object.freeze({__proto__:null,re:i,parse:P,encode:e=>e.replace(/[\u007F-\uFFFF]/g,(function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).substr(-4).toUpperCase()})),decode:Q,pair:L,compose:N,info:U,columnDefaults:Z,columnDefaultsMerge:V,columns:(e,t)=>{if("string"!=typeof e)return{};const r=V(t);let o=P.text(e),s=0,n=[],a=[],i=0,l=parseInt(r.width/2),c=r.height-r.margin,p=!0,u=!1;for(let e of o){let t=U(e);s+=i,r.punctuation.spacing?s+="sign"==t.segment?r.pad:0:s+=r.pad,u=s+t.height>c,u&&"symbol"==t.segment&&r.punctuation.pull&&p&&(u=!1,p=!1),0==a.length&&(u=!1),u&&(s=r.pad,n.push(a),a=[],p=!0),a.push(Object.assign(t,{x:l+r.offset*t.lane-(500-t.minX)*t.zoom*r.style.zoom,y:s,text:e})),s+=t.height*t.zoom*r.style.zoom,i=r.punctuation.spacing?"sign"==t.segment?r.pad:r.punctuation.pad:r.pad}if(a.length&&n.push(a),r.punctuation.pull)for(let e of n){let t=e[e.length-1],o=t.y+t.height-(r.height-r.margin);if(o>0){let t=parseInt(o/e.length)+1;for(let r in e)e[r].y-=t*r+t}}let d=[];for(let e of n){let t=[l-r.offset-r.pad],o=[l+r.offset+r.pad];for(let s of e)t.push(s.x-r.pad),o.push(s.x+s.width+r.pad);t=Math.min(...t),o=Math.max(...o);let s=r.width,n=0;r.dynamic?(s=o-t,n=-t):n=l-parseInt((t+o)/2);for(let t of e)t.x+=n;d.push(s)}return{options:r,widths:d,columns:n}},kind:[262145,323489,324257],category:K,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],ranges:X,isType:(e,t)=>{const r=P.symbol(e);if(r.symbol){const e=m(r.symbol),o=X[t];if(o)return o[0]<=e&&o[1]>=e}return!1},colors:G,colorize:e=>{const t=P.symbol(e);let r="#000000";if(t.symbol){const e=m(t.symbol),o=K.findIndex((t=>t>e));r=G[o<0?6:o-1]}return r}});let H={null:"",base:"(?:(?:\ud8c0[\udc01-\udfff])|(?:[\ud8c1-\ud8fc][\udc00-\udfff])|(?:\ud8fd[\udc00-\udc80]))",coord:"(?:(?:\ud836[\udc0c-\uddff]){2})?",var:"V[0-9]+"};H.symbol=`${H.base}f?r?`,H.nullorsymbol=`(?:${H.null}|${H.symbol})`,H.range=`R${H.base}${H.base}`,H.item=`(?:${H.null}|${H.symbol}|${H.range})`,H.list=`${H.item}(?:o${H.item})*`,H.prefix=`(?:A(?:${H.list})+)?T`,H.signbox=`(?:${H.list}${H.coord})*`,H.full=`Q(${H.prefix})?(${H.signbox})?(${H.var})?(-?)`;const J=e=>e.match(new RegExp(`(${H.list}${H.coord})`,"g")).map((e=>{let t,r;return t=e.match(new RegExp(`${i.coord}`)),t?(t=d(t[0]),r=e.slice(0,-4)):(t=void 0,r=e),r.includes("o")?{or:r.split("o").map((e=>e.includes("R")?[e.slice(1,3),e.slice(3,5)]:e)),coord:t,coord:t}:r.includes("R")?{range:[r.slice(1,3),r.slice(3,5)],coord:t}:{symbol:r,coord:t}})),W=(e,t)=>{if(e>t)return"";let r,o="",s=[];if(e=L(e),t=L(t),2!=e.length&&2!=t.length)return"";if(e[0]==t[0])e[1]==t[1]?(o="\\u"+e[0]+"\\u"+e[1],s.push(o)):(o="\\u"+e[0]+"[\\u"+e[1]+"-\\u"+t[1]+"]",s.push(o));else{o="DFFF"==e[1]?"\\u"+e[0]+"\\uDFFF":"\\u"+e[0]+"[\\u"+e[1]+"-\\uDFFF]",s.push(o);let r=parseInt(t[0],16)-parseInt(e[0],16);2==r&&(o="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),o+="[\\uDC00-\\uDFFF]",s.push(o)),r>2&&(o="[",o+="\\u"+(parseInt(e[0],16)+1).toString(16).toUpperCase(),o+="-\\u"+(parseInt(t[0],16)-1).toString(16).toUpperCase(),o+="][\\uDC00-\\uDFFF]",s.push(o)),o="DC00"==t[1]?"\\u"+t[0]+"\\uDC00":"\\u"+t[0]+"[\\uDC00-\\u"+t[1]+"]",s.push(o)}return r=s.length,1==r?o=s[0]:(o=s.join(")|("),o="(("+o+"))"),Q(o)},ee=e=>{let t=e.match(new RegExp(H.symbol));if(t){let e,r,o=t[0].slice(0,2),s=y(o),n=s.slice(0,4);if("fr"==t[0].slice(-2))return e=b(n+"00"),r=b(n+"5f"),W(e,r);if("r"==t[0].slice(-1))return e=b(s.slice(0,5)+"0"),r=b(s.slice(0,5)+"f"),W(e,r);if("f"==t[0].slice(-1)){return"("+[0,1,2,3,4,5].map((function(e){return b(n+e+s.slice(-1))})).join("|")+")"}return o}return""},te=e=>{let t=y(e.slice(1,3)),r=y(e.slice(-2));return t=b(t.slice(0,4)+"00"),r=b(r.slice(0,4)+"5f"),W(t,r)},re=e=>{if(!(e=e.match(new RegExp(`^${H.full}`))[0]))return"";let r,o,s,n,a,l,c,p,f,g,m,h=20,y=i.box+i.coord+"(?:"+i.symbol+i.coord+")*",b="(?:"+i.sort+i.nullorsymbol+"+)",x="(?:"+t.full+")?";if("Q"==e)return[i.sign];if("Q-"==e)return[i.sign+"("+t.full+")?"];if("QT"==e)return[i.sortable];if("QT-"==e)return[i.sortable+"("+t.full+")?"];let $=[],w=e.indexOf("T")+1;if(w){m="(?:"+i.sort;let t=e.slice(0,w);if(e=e.replace(t,""),"QT"==t)m+=i.nullorsymbol+"+)";else if(r=t.match(new RegExp(H.list,"g")),r){for(a=0;a<r.length;a+=1)if(n=[],o=r[a].match(new RegExp(H.item,"g")),o){for(l=0;l<o.length;l+=1)s=o[l].match(new RegExp(H.range)),s?n.push(te(o[l])):n.push(ee(o[l]));1==n.length?m+=n[0]:m+="(?:"+n.join("|")+")"}m+=i.nullorsymbol+"*)"}}if(r=e.match(new RegExp("(?:V[0-9]+)","g")),r&&(h=1*r.toString().slice(1)),r=e.match(new RegExp(H.list+H.coord,"g")),r)for(a=0;a<r.length;a+=1){if(n=[],o=r[a].match(new RegExp("("+H.range+"|"+H.symbol+")","g")),o){for(l=0;l<o.length;l+=1)s=o[l].match(new RegExp(H.range)),s?n.push(te(o[l])):n.push(ee(o[l]));p=1==n.length?n[0]:"(?:"+n.join("|")+")"}c=r[a].match(new RegExp(`${i.coord}`)),c?(c=d(c[0]),f=c[0],g=c[1],p+=W(u(f-h),u(f+h)),p+=W(u(g-h),u(g+h))):p+=i.coord,p=y+p+"(?:"+i.symbol+i.coord+")*",p=w?m+p:b+"?"+p,e.indexOf("-")>0&&(p+=x),$.push(p)}return $.length||(e.indexOf("-")>0&&(p+=x),$.push(m+y)),$};var oe=Object.freeze({__proto__:null,re:H,parse:e=>{const t="string"==typeof e?e.match(new RegExp(`^${H.full}`)):void 0;return{query:!!t||void 0,prefix:t&&t[1]?(r=t[1],{required:!0,parts:"T"==r?void 0:r.match(new RegExp(`(${H.list})`,"g")).map((e=>e.includes("o")?["or"].concat(e.match(new RegExp(`(${H.item})`,"g")).map((e=>"R"!=e[0]?e:[e.slice(1,3),e.slice(3,5)]))):"R"!=e[0]?e:[e.slice(1,3),e.slice(3,5)]))}):void 0,signbox:t&&t[2]?J(t[2]):void 0,variance:t&&t[3]?parseInt(t[3].slice(1)):void 0,style:!(!t||!t[4])||void 0};var r},compose:e=>{if(!e||!e.query)return;let t="Q";return e.prefix&&e.prefix.required&&(Array.isArray(e.prefix.parts)&&(t+="A",t+=e.prefix.parts.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}${e[1]}`:Array.isArray(e)&&e.length>2&&"or"==e[0]?(e.shift(),e.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}${e[1]}`:void 0)).join("o")):void 0)).join("")),t+="T"),Array.isArray(e.signbox)&&(t+=e.signbox.map((e=>{let t;return e.or?t=e.or.map((e=>"string"==typeof e?e:Array.isArray(e)&&2==e.length?`R${e[0]}${e[1]}`:void 0)).join("o"):e.symbol?t=e.symbol:e.range&&Array.isArray(e.range)&&2==e.range.length&&(t=`R${e.range[0]}${e.range[1]}`),t+(Array.isArray(e.coord)&&2==e.coord.length?f(e.coord):"")})).join("")),t+=e.style?"-":"",t=t.match(new RegExp(`^${H.full}`))[0],t},swu2query:(e,t)=>{let r="";const o=P.sign(e);if(o.box){const e=t.indexOf("A")>-1,s=t.indexOf("a")>-1,n=t.indexOf("S")>-1,a=t.indexOf("s")>-1,i=t.indexOf("L")>-1;return(e||s||n||a)&&((e||s)&&o.sequence&&(r+="A",r+=o.sequence.map((e=>e+(s?"fr":""))).join(""),r+="T"),(n||a)&&o.spatials&&(r+=o.spatials.map((e=>e.symbol+(a?"fr":"")+(i?f(e.coord):""))).join(""))),r?"Q"+r:void 0}},range:W,symbolRanges:ee,regex:re,results:(e,t)=>{if(!t)return[];let r,o,s,n,a,i=re(e);if(!i)return[];for(a=0;a<i.length;a+=1)r=i[a],o=t.match(new RegExp(r,"g")),t=o?o.join(" "):"";return t?(s=t.split(" "),n=s.filter((function(e){return!(e in s)&&(s[e]=!0)}),{})):n=[],n},lines:(e,t)=>{if(!t)return[];let r,o,s,n,a,i=re(e);if(!i)return[];for(a=0;a<i.length;a+=1)r=i[a],r="^"+r+".*",o=t.match(new RegExp(r,"mg")),t=o?o.join("\n"):"";return t?(s=t.split("\n"),n=s.filter((function(e){return!(e in s)&&(s[e]=!0)}),{})):n=[],n}});export{$ as convert,C as fsw,B as fswquery,a as style,Y as swu,oe as swuquery};