@sekyro/web 0.1.0-rc.33 → 0.1.0-rc.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/assets.generated-DpkbvoII.d.cts +249 -0
  3. package/dist/assets.generated-DpkbvoII.d.ts +249 -0
  4. package/dist/{capture-session-doc-FAMDLRRZ.js → capture-session-doc-GCL2FYQH.js} +1 -1
  5. package/dist/{chunk-B5H5ED6O.js → chunk-7KI6HWCZ.js} +1 -1
  6. package/dist/chunk-AJPVHUZR.js +3 -0
  7. package/dist/{chunk-ZKF2XMNX.js → chunk-BD4KIQQD.js} +1 -1
  8. package/dist/{chunk-NO22WG7R.js → chunk-CHWTIUYK.js} +1 -1
  9. package/dist/chunk-DSNJ2ERA.js +1 -0
  10. package/dist/{chunk-G2BD6INN.js → chunk-ERCKQV6V.js} +1 -1
  11. package/dist/chunk-ISMVEF7H.js +1 -0
  12. package/dist/{chunk-HFRU66NW.js → chunk-JFTEP2WJ.js} +1 -1
  13. package/dist/chunk-JULJQOVT.js +1 -0
  14. package/dist/chunk-LTMDEMCV.js +1 -0
  15. package/dist/chunk-M3KW2MY3.js +1 -0
  16. package/dist/{chunk-C4WK5D33.js → chunk-NXNQQXYJ.js} +1 -1
  17. package/dist/chunk-QB62OPX5.js +1 -0
  18. package/dist/{chunk-65YTEYLU.js → chunk-UVZ5R4CI.js} +1 -1
  19. package/dist/chunk-Y5C4YJQT.js +1 -0
  20. package/dist/client/index.cjs +1 -1
  21. package/dist/client/index.d.cts +2 -2
  22. package/dist/client/index.d.ts +2 -2
  23. package/dist/client/index.js +1 -1
  24. package/dist/core/index.cjs +1 -1
  25. package/dist/core/index.js +1 -1
  26. package/dist/core/ocr/worker.bundle.js +13 -14
  27. package/dist/core/ocr/worker.cjs +12 -13
  28. package/dist/core/ocr/worker.d.cts +13 -0
  29. package/dist/core/ocr/worker.d.ts +13 -0
  30. package/dist/core/ocr/worker.js +11 -12
  31. package/dist/create-document-capture-IMDGCTMM.js +1 -0
  32. package/dist/{create-verification-BAoA5Z9o.d.cts → create-verification-DmK48vdr.d.cts} +107 -4
  33. package/dist/{create-verification-C1Svvmup.d.ts → create-verification-YC-R5v_z.d.ts} +107 -4
  34. package/dist/{detector-scanic-S4PB2RNW.js → detector-scanic-QVQVJI3C.js} +1 -1
  35. package/dist/{icao-gate-BBStoG81.d.ts → icao-gate-BGhxz9O2.d.ts} +7 -1
  36. package/dist/{icao-gate-C731iewN.d.cts → icao-gate-Dj4kIwna.d.cts} +7 -1
  37. package/dist/{icao-policy-Dy5Z1vSp.d.ts → icao-policy-D48k64KJ.d.ts} +1 -1
  38. package/dist/{icao-policy-R7Jk5qF_.d.cts → icao-policy-D4QqzA0b.d.cts} +1 -1
  39. package/dist/index.cjs +3 -3
  40. package/dist/index.d.cts +4 -4
  41. package/dist/index.d.ts +4 -4
  42. package/dist/index.js +1 -1
  43. package/dist/internal/index.cjs +3 -3
  44. package/dist/internal/index.d.cts +15 -99
  45. package/dist/internal/index.d.ts +15 -99
  46. package/dist/internal/index.js +1 -1
  47. package/dist/plan-runner-HBUVNDGH.js +1 -0
  48. package/package.json +1 -1
  49. package/sbom.cdx.json +19 -19
  50. package/dist/chunk-DFTCAWMP.js +0 -1
  51. package/dist/chunk-DK5YPBDQ.js +0 -1
  52. package/dist/chunk-G6LKLN4U.js +0 -1
  53. package/dist/chunk-IUNPV67T.js +0 -1
  54. package/dist/chunk-MJKHDXCU.js +0 -1
  55. package/dist/chunk-W6Y2335Q.js +0 -1
  56. package/dist/chunk-YDG77RHN.js +0 -1
  57. package/dist/chunk-YL2B72KC.js +0 -3
  58. package/dist/create-document-capture-WFTNVMCE.js +0 -1
  59. package/dist/plan-runner-LSQTIO6L.js +0 -1
@@ -1,6 +1,7 @@
1
- var Y={fp12:"08390000c48a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro-ocr.wasm":{bytes:3550608,sha256:"c15968a6de3d2225e2fdbf36d71a9214c2910419056c6878444fd2d0567bb748",tier:"live",contentType:"application/wasm"},"sekyro-ocr.mjs":{bytes:4270,sha256:"209a78d96ca53344996a0c2300aed4ff8a5c69e142713216975a2840eec08cac",tier:"bundled",contentType:"text/javascript"},"det.param":{bytes:24252,sha256:"c39ba0b1195e8ad37cfc5bdd7acedcfc1d9cb901e7b8eb1c9c4f6e5a66c04eb3",tier:"live",contentType:"text/plain"},"det.bin":{bytes:4685856,sha256:"652bafe366565109a1a5766caf482bc46f01481f8044d3a785bd9a1be67c63bb",tier:"live",contentType:"application/octet-stream"},"mrz-rec.param":{bytes:3510,sha256:"bc69b1b9683e35f6605b21001fadeb81468063459c00c0fc83c67c139f23df01",tier:"live",contentType:"text/plain"},"mrz-rec.bin":{bytes:494196,sha256:"de93a2aa2f08670cc7dedd17ba378d2f5d7cf6ae409054a9eac863a02c2febae",tier:"live",contentType:"application/octet-stream"},"mrz_dict.txt":{bytes:73,sha256:"b19858a4de2ccbbbdd4b53982188ea2c7664013183bbd1ae9d20ab52c661f97f",tier:"live",contentType:"text/plain"},"latin-rec.param":{bytes:19602,sha256:"2ae30dfdc7ee482c6cbbc0419c16ee125e880e9eaf69053d61953694bb0fcf4c",tier:"lazy",contentType:"text/plain"},"latin-rec.bin":{bytes:10750388,sha256:"f91ebdcf4d6b58c58a87704160e59d07ae56bc2d5021eae09d095c5a20bf7525",tier:"lazy",contentType:"application/octet-stream"},"ppocr_keys_v1.txt":{bytes:26249,sha256:"28b2362ad4ab2dc38769aa72feb535e3a9ddb3fd2a7585a05920e6393b1dc7f7",tier:"lazy",contentType:"text/plain"},"arabic-rec.param":{bytes:9858,sha256:"4e5cc85667dfaaa0c67d3f308400645a578c08bd43f952cab6c55b7bce143ea9",tier:"lazy",contentType:"text/plain"},"arabic-rec.bin":{bytes:8853572,sha256:"5acc3265a1738dc31316258383830d5dbdfa5e8ebc2e710f9001f832ecfbffb0",tier:"lazy",contentType:"application/octet-stream"},"arabic_dict.txt":{bytes:405,sha256:"637c27c88512c22089bef927b34ada08f748dc132ac70facd68d8202384c2726",tier:"lazy",contentType:"text/plain"}}};var ut="sekyro-mrz-1";function dt(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}async function be(e){return dt(await crypto.subtle.digest("SHA-256",e))}function Ne(e,t){return be(new TextEncoder().encode(`${ut}\0${e}\0${t.join(`
2
- `)}`))}var G=class extends Error{constructor(t){super(t),this.name="AssetFailure",this.reason=t}},_e=Object.keys(Y.files).filter(e=>Y.files[e].tier==="live"),rn=Object.keys(Y.files).filter(e=>Y.files[e].tier==="lazy");function ft(e,t){return`${e.replace(/\/+$/,"")}/${Y.fp12}/${t}`}async function mt(e,t,n,s=fetch,r=()=>performance.now()){let o=Y.files[t],i=r(),l=async b=>{try{let f=await s(ft(e,t),{cache:b,signal:n,credentials:"omit"});if(!f.ok)throw new G("download");return await f.arrayBuffer()}catch(f){throw f instanceof G?f:new G("download")}},a=async b=>b.byteLength===o.bytes&&await be(b)===o.sha256,d=await l("force-cache");if(!await a(d)&&(d=await l("reload"),!await a(d)))throw new G("integrity");return{bytes:d,ms:r()-i}}async function Te(e,t,n,s=fetch,r=()=>performance.now()){let o=new AbortController,i=new Map,l=t.reduce((f,p)=>f+Y.files[p].bytes,0),a=r(),d=!0,b=0;for(let f of t){let p=await mt(e,f,o.signal,s,r);i.set(f,p.bytes),p.ms>=50&&(d=!1),b+=p.bytes.byteLength;let y=r()-a;if(b<l&&y>0&&y*l/b>n)throw o.abort(),new G("download")}return{files:i,downloadMs:Math.round(r()-a),cached:d}}var I=class extends Error{constructor(t){super(t),this.name="OcrFailure",this.code=t}};function Oe(e){return[...e.split(`
3
- `)," "]}function Le(e,t,n,s,r){if(n<2||e.length===0||e.length!==t.length||s.length<n-1)throw new I("OCR_INFERENCE_FAILED");let o="",i=-1,l=0,a=0;for(let b=0;b<e.length;b++){let f=e[b];if(!Number.isInteger(f)||f<0||f>=n)throw new I("OCR_INFERENCE_FAILED");f!==0&&f!==i&&(o+=s[f-1],l+=Math.fround(t[b]),a++),i=f}return{text:r?Array.from(o).reverse().join(""):o,score:a===0?0:l/a}}var we=e=>e.reduce((t,n)=>t+n,0)/e.length;function De(e){let t=e.filter(r=>r.score>=.5);if(t.length===0)return[];if(t.some(r=>r.box.length!==4||!Number.isFinite(r.score)||r.box.some(o=>!Number.isFinite(o.x)||!Number.isFinite(o.y))))throw new I("OCR_INFERENCE_FAILED");let n=we(t.map(r=>r.box[2].y-r.box[0].y)),s=[];for(let r of t){let o=(r.box[0].y+r.box[2].y)/2,i=s.find(l=>Math.abs((l[0].box[0].y+l[0].box[2].y)/2-o)<n/2);i===void 0?s.push([r]):i.push(r)}for(let r of s)r.sort((o,i)=>o.box[0].x-i.box[0].x);return s.sort((r,o)=>r[0].box[0].y-o[0].box[0].y),s.map(r=>{let o=r[0].box,i=r[r.length-1].box,l=[o[0],i[1],i[2],o[3]];return{text:r.map(a=>a.text).join(" "),x:Math.min(...l.map(a=>a.x)),y:Math.min(...l.map(a=>a.y)),x2:Math.max(...l.map(a=>a.x)),y2:Math.max(...l.map(a=>a.y)),score:we(r.map(a=>a.score))}})}var j={of(e,t,n){return!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||t<1||t>12||n<1||n>new Date(Date.UTC(e,t,0)).getUTCDate()?null:{year:e,month:t,day:n}},iso(e){return`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`},parse(e){let[t,n,s]=e.split("-").map(Number);return{year:t,month:n,day:s}},today(){let e=new Date;return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}}},ve=30,Pe=36,Ue=44,ge="MRT",bt=[7,3,1],gt=/^[0-9]{6}$/,ye=/^[0-9]{10}$/,Fe=e=>e!==void 0&&e.length===1&&e>="0"&&e<="9";function pt(e){return e>="0"&&e<="9"?e.charCodeAt(0)-48:e>="A"&&e<="Z"?e.charCodeAt(0)-55:0}function ue(e){let t=0;for(let n=0;n<e.length;n++)t+=pt(e[n])*bt[n%3];return String(t%10)}function D(e,t){return t==="<"?null:Fe(t)?ue(e)===t:!1}function ce(e){return e.trim().toUpperCase().replaceAll(" ","")}function yt(e,t){return(ce(e)+"<".repeat(t)).slice(0,t)}function k(e){return e.replace(/^<+|<+$/g,"")}var ht=new Set(`ABW AFG AGO AIA ALA ALB AND ARE ARG ARM ASM ATA ATF ATG AUS AUT AZE BDI BEL BEN BES BFA BGD BGR BHR
1
+ var k={fp12:"936b9c4ccc4a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro-ocr.wasm":{bytes:3550687,sha256:"00d6b1a4e42da8146e662ab0283b97485397811acc806299046933ce1943fb09",tier:"live",contentType:"application/wasm"},"sekyro-ocr.mjs":{bytes:4270,sha256:"209a78d96ca53344996a0c2300aed4ff8a5c69e142713216975a2840eec08cac",tier:"bundled",contentType:"text/javascript"},"det.param":{bytes:24252,sha256:"c39ba0b1195e8ad37cfc5bdd7acedcfc1d9cb901e7b8eb1c9c4f6e5a66c04eb3",tier:"live",contentType:"text/plain"},"det.bin":{bytes:4685856,sha256:"652bafe366565109a1a5766caf482bc46f01481f8044d3a785bd9a1be67c63bb",tier:"live",contentType:"application/octet-stream"},"mrz-rec.param":{bytes:3510,sha256:"bc69b1b9683e35f6605b21001fadeb81468063459c00c0fc83c67c139f23df01",tier:"live",contentType:"text/plain"},"mrz-rec.bin":{bytes:494196,sha256:"de93a2aa2f08670cc7dedd17ba378d2f5d7cf6ae409054a9eac863a02c2febae",tier:"live",contentType:"application/octet-stream"},"mrz_dict.txt":{bytes:73,sha256:"b19858a4de2ccbbbdd4b53982188ea2c7664013183bbd1ae9d20ab52c661f97f",tier:"live",contentType:"text/plain"},"v5-latin-fp16.param":{bytes:19800,sha256:"843964335e9863681bb17d876c69e7315844e0850e3c04f91b11a3f0c2a57bc6",tier:"lazy",group:"latin",contentType:"text/plain"},"v5-latin-fp16.bin":{bytes:3995900,sha256:"0516474d30cff75a6365869992699d27fbc03f00fcf3d7274c3eed651ee6ea90",tier:"lazy",group:"latin",contentType:"application/octet-stream"},"latin.dict.txt":{bytes:2615,sha256:"c3ab00106e4a4d151a8575b1129b91901a68a35b79a81fd63faab00418b87d75",tier:"lazy",group:"latin",contentType:"text/plain"},"v5-arabic-fp16.param":{bytes:19791,sha256:"1d1e219d277bb1a76909741573f56cfae465f11b61a9be4ca4c29580758c8760",tier:"lazy",group:"arabic",contentType:"text/plain"},"v5-arabic-fp16.bin":{bytes:3974364,sha256:"4ced47b32ab4e7ad16ddebc074f31594eb42b912465a8ed7458bb2842af9efe1",tier:"lazy",group:"arabic",contentType:"application/octet-stream"},"arabic.dict.txt":{bytes:2368,sha256:"8f239c13f6c8b1bdf15f332a65a05002ddd4d99b9286a4bfaf6f0327c36ebbec",tier:"lazy",group:"arabic",contentType:"text/plain"},"v5-cyrillic-fp16.param":{bytes:19806,sha256:"c87b42bfa343509b319dd193dcca4c0e20bb13b1d07bfbf4925a9f5d045966d4",tier:"lazy",group:"cyrillic",contentType:"text/plain"},"v5-cyrillic-fp16.bin":{bytes:3999288,sha256:"97446e221c0d2d84cb76dca6d4217a850efad4d5ec85e3fadc78db353cf97afa",tier:"lazy",group:"cyrillic",contentType:"application/octet-stream"},"cyrillic.dict.txt":{bytes:2780,sha256:"2de016b31edd687acfc1bf72170f4feff9f0c4893edac87cef30b2c5a82443ec",tier:"lazy",group:"cyrillic",contentType:"text/plain"},"v5-greek-fp16.param":{bytes:19815,sha256:"1cc1d47d3aa3fce86d3dbe901a553fd29412f44934a4919d986c155d23f63207",tier:"lazy",group:"greek",contentType:"text/plain"},"v5-greek-fp16.bin":{bytes:3879256,sha256:"04190cd4ee2b023665346d4cd239ee118965f837812108869d3d9894d30c4db3",tier:"lazy",group:"greek",contentType:"application/octet-stream"},"greek.dict.txt":{bytes:1102,sha256:"60e017885fd98fd0fb5c402da86179f1fe24ae229b374b3b96d313f99a09de59",tier:"lazy",group:"greek",contentType:"text/plain"},"v5-devanagari-fp16.param":{bytes:19807,sha256:"c6540a818cbb46c5b511dc4dd20ebfeae9038ec64e5cf175cd2d25f1b9f95c51",tier:"lazy",group:"devanagari",contentType:"text/plain"},"v5-devanagari-fp16.bin":{bytes:3931044,sha256:"d3086391eb2298c4d4e5a6d20a7fc58a8d0f3ce0a12395c88e9d485c5d595828",tier:"lazy",group:"devanagari",contentType:"application/octet-stream"},"devanagari.dict.txt":{bytes:1942,sha256:"c66d17ef6ced6fbfb4413810e75f0f788cfde37d4192bd17af7923fa190066c8",tier:"lazy",group:"devanagari",contentType:"text/plain"},"v5-thai-fp16.param":{bytes:19786,sha256:"4422df9dcc960e42082166adcca42da2aa6df62abebc75daf0c887e89381c039",tier:"lazy",group:"thai",contentType:"text/plain"},"v5-thai-fp16.bin":{bytes:3920396,sha256:"3458d7c5f0a7f88cb804d084c6596dea3f67c5ea99082654938d71a4eb72a079",tier:"lazy",group:"thai",contentType:"application/octet-stream"},"thai.dict.txt":{bytes:1766,sha256:"e0f32101004cc828ed4505bba80126be06e282700c4c79175ed2b21a4d454dfa",tier:"lazy",group:"thai",contentType:"text/plain"},"v5-hangul-fp16.param":{bytes:19804,sha256:"8daec1a4aa09d3bc92a476438330921c910263b8e61d62334d79e2d1dd14247c",tier:"lazy",group:"hangul",contentType:"text/plain"},"v5-hangul-fp16.bin":{bytes:6684280,sha256:"1d38192b59765cf71c1909ea4b972ee3c8588537a53844e6830f57fbf47976a4",tier:"lazy",group:"hangul",contentType:"application/octet-stream"},"hangul.dict.txt":{bytes:47450,sha256:"a7872c929cd25cf615cdfea08579cf800db1943900fe683468df4dcff6f848bb",tier:"lazy",group:"hangul",contentType:"text/plain"}},scripts:{latin:{classes:838,rtl:!1,param:"v5-latin-fp16.param",bin:"v5-latin-fp16.bin",dict:"latin.dict.txt"},arabic:{classes:749,rtl:!0,param:"v5-arabic-fp16.param",bin:"v5-arabic-fp16.bin",dict:"arabic.dict.txt"},cyrillic:{classes:852,rtl:!1,param:"v5-cyrillic-fp16.param",bin:"v5-cyrillic-fp16.bin",dict:"cyrillic.dict.txt"},greek:{classes:356,rtl:!1,param:"v5-greek-fp16.param",bin:"v5-greek-fp16.bin",dict:"greek.dict.txt"},devanagari:{classes:570,rtl:!1,param:"v5-devanagari-fp16.param",bin:"v5-devanagari-fp16.bin",dict:"devanagari.dict.txt"},thai:{classes:526,rtl:!1,param:"v5-thai-fp16.param",bin:"v5-thai-fp16.bin",dict:"thai.dict.txt"},hangul:{classes:11947,rtl:!1,param:"v5-hangul-fp16.param",bin:"v5-hangul-fp16.bin",dict:"hangul.dict.txt"}}};var bt="sekyro-mrz-1";function gt(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}async function be(e){return gt(await crypto.subtle.digest("SHA-256",e))}function Ce(e,t){return be(new TextEncoder().encode(`${bt}\0${e}\0${t.join(`
2
+ `)}`))}var z=class extends Error{constructor(t){super(t),this.name="AssetFailure",this.reason=t}},_e=Object.keys(k.files).filter(e=>k.files[e].tier==="live"),ln=Object.keys(k.files).filter(e=>k.files[e].tier==="lazy");function yt(e,t){return`${e.replace(/\/+$/,"")}/${k.fp12}/${t}`}async function ht(e,t,n,r=fetch,i=()=>performance.now()){let s=k.files[t],o=i(),c=async p=>{try{let f=await r(yt(e,t),{cache:p,signal:n,credentials:"omit"});if(!f.ok)throw new z("download");return await f.arrayBuffer()}catch(f){throw f instanceof z?f:new z("download")}},a=async p=>p.byteLength===s.bytes&&await be(p)===s.sha256,d=await c("force-cache");if(!await a(d)&&(d=await c("reload"),!await a(d)))throw new z("integrity");return{bytes:d,ms:i()-o}}async function Oe(e,t,n,r=fetch,i=()=>performance.now()){let s=new AbortController,o=new Map,c=t.reduce((f,g)=>f+k.files[g].bytes,0),a=i(),d=!0,p=0;for(let f of t){let g=await ht(e,f,s.signal,r,i);o.set(f,g.bytes),g.ms>=50&&(d=!1),p+=g.bytes.byteLength;let b=i()-a;if(p<c&&b>0&&b*c/p>n)throw s.abort(),new z("download")}return{files:o,downloadMs:Math.round(i()-a),cached:d}}var I=class extends Error{constructor(t){super(t),this.name="OcrFailure",this.code=t}};function ue(e){return[...e.split(`
3
+ `)," "]}function Le(e,t,n,r,i){if(n<2||e.length===0||e.length!==t.length||r.length<n-1)throw new I("OCR_INFERENCE_FAILED");let s="",o=-1,c=0,a=0;for(let p=0;p<e.length;p++){let f=e[p];if(!Number.isInteger(f)||f<0||f>=n)throw new I("OCR_INFERENCE_FAILED");f!==0&&f!==o&&(s+=r[f-1],c+=Math.fround(t[p]),a++),o=f}return{text:i?Array.from(s).reverse().join(""):s,score:a===0?0:c/a}}var ge="latin",pn=Object.keys(k.scripts);function we(e){return Object.prototype.hasOwnProperty.call(k.scripts,e)}function De(e){let t=k.scripts[e];return{script:e,classes:t.classes,rtl:t.rtl,param:t.param,bin:t.bin,dict:t.dict}}function ve(e,t){let n=ue(e);if(e.endsWith(`
4
+ `)||n.length!==t-1)throw new I("OCR_ASSET_INVALID");return n}var ke=e=>e.reduce((t,n)=>t+n,0)/e.length;function Be(e){let t=e.filter(i=>i.score>=.5);if(t.length===0)return[];if(t.some(i=>i.box.length!==4||!Number.isFinite(i.score)||i.box.some(s=>!Number.isFinite(s.x)||!Number.isFinite(s.y))))throw new I("OCR_INFERENCE_FAILED");let n=ke(t.map(i=>i.box[2].y-i.box[0].y)),r=[];for(let i of t){let s=(i.box[0].y+i.box[2].y)/2,o=r.find(c=>Math.abs((c[0].box[0].y+c[0].box[2].y)/2-s)<n/2);o===void 0?r.push([i]):o.push(i)}for(let i of r)i.sort((s,o)=>s.box[0].x-o.box[0].x);return r.sort((i,s)=>i[0].box[0].y-s[0].box[0].y),r.map(i=>{let s=i[0].box,o=i[i.length-1].box,c=[s[0],o[1],o[2],s[3]];return{text:i.map(a=>a.text).join(" "),x:Math.min(...c.map(a=>a.x)),y:Math.min(...c.map(a=>a.y)),x2:Math.max(...c.map(a=>a.x)),y2:Math.max(...c.map(a=>a.y)),score:ke(i.map(a=>a.score))}})}var j={of(e,t,n){return!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||t<1||t>12||n<1||n>new Date(Date.UTC(e,t,0)).getUTCDate()?null:{year:e,month:t,day:n}},iso(e){return`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`},parse(e){let[t,n,r]=e.split("-").map(Number);return{year:t,month:n,day:r}},today(){let e=new Date;return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}}},Ue=30,Ge=36,ze=44,ye="MRT",xt=[7,3,1],At=/^[0-9]{6}$/,xe=/^[0-9]{10}$/,He=e=>e!==void 0&&e.length===1&&e>="0"&&e<="9";function Mt(e){return e>="0"&&e<="9"?e.charCodeAt(0)-48:e>="A"&&e<="Z"?e.charCodeAt(0)-55:0}function fe(e){let t=0;for(let n=0;n<e.length;n++)t+=Mt(e[n])*xt[n%3];return String(t%10)}function v(e,t){return t==="<"?null:He(t)?fe(e)===t:!1}function de(e){return e.trim().toUpperCase().replaceAll(" ","")}function St(e,t){return(de(e)+"<".repeat(t)).slice(0,t)}function B(e){return e.replace(/^<+|<+$/g,"")}var Rt=new Set(`ABW AFG AGO AIA ALA ALB AND ARE ARG ARM ASM ATA ATF ATG AUS AUT AZE BDI BEL BEN BES BFA BGD BGR BHR
4
5
  BHS BIH BLM BLR BLZ BMU BOL BRA BRB BRN BTN BVT BWA CAF CAN CCK CHE CHL CHN CIV CMR COD COG COK COL
5
6
  COM CPV CRI CUB CUW CXR CYM CYP CZE DEU DJI DMA DNK DOM DZA ECU EGY ERI ESH ESP EST ETH FIN FJI FLK
6
7
  FRA FRO FSM GAB GBR GEO GGY GHA GIB GIN GLP GMB GNB GNQ GRC GRD GRL GTM GUF GUM GUY HKG HMD HND HRV
@@ -9,8 +10,8 @@ var Y={fp12:"08390000c48a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro
9
10
  MNP MOZ MRT MSR MTQ MUS MWI MYS MYT NAM NCL NER NFK NGA NIC NIU NLD NOR NPL NRU NZL OMN PAK PAN PCN
10
11
  PER PHL PLW PNG POL PRI PRK PRT PRY PSE PYF QAT REU ROU RUS RWA SAU SDN SEN SGP SGS SHN SJM SLB SLE
11
12
  SLV SMR SOM SPM SRB SSD STP SUR SVK SVN SWE SWZ SXM SYC SYR TCA TCD TGO THA TJK TKL TKM TLS TON TTO
12
- TUN TUR TUV TWN TZA UGA UKR UMI URY USA UZB VAT VCT VEN VGB VIR VNM VUT WLF WSM XKK YEM ZAF ZMB ZWE`.trim().split(/\s+/)),At=new Set(`D GBD GBN GBO GBP GBS RKS UNK UNO UNA EUE XBA XIM XCC XCE XCO XDC XEC XES XMP XOM XPO XXA XXB XXC
13
- XXX ANT NTZ UTO`.trim().split(/\s+/));function xt(e){return ht.has(e)||At.has(e)}var Mt="012568",Rt="OIZSGB",St="OQDILZSGB",It="000112568";function pe(e){let t=Mt.indexOf(e);return e.length!==1||t<0?e:Rt[t]}function Ct(e){let t=St.indexOf(e);return e.length!==1||t<0?e:It[t]}var Et=[["\xAB","<<"],["\u2039","<"],["\uFF1C","<"],["\u3008","<"],["\xD7","X"]],Ge=[`aaccc${"x".repeat(9)}n${"x".repeat(15)}`,`${"n".repeat(7)}x${"n".repeat(7)}ccc${"x".repeat(11)}n`,"a".repeat(30)],Ke=[`aaccc${"a".repeat(31)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(7)}n`],ze=[`aaccc${"a".repeat(39)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(14)}nn`];function Nt(e,t){let n="",s=0;for(;s<t.length;){let r=t[s];if(r==="c"){let i=e.substring(s,s+3),l=Array.from(i,pe).join("");n+=l!==i&&xt(l.replaceAll("<",""))?l:i,s+=3;continue}let o=e[s];n+=r==="a"?pe(o):r==="n"?Ct(o):o,s++}return n}function ee(e,t,n){return n.slice(0,e.length).map((s,r)=>{let o=Et.reduce((i,[l,a])=>i.replaceAll(l,a),ce(e[r]));return Nt(yt(o,t),s)})}function He(e,t){let n=e.filter(s=>s.trim().length>0);return t==="TD1"?ee(n.slice(0,3),ve,Ge):t==="TD2"?ee(n.slice(0,2),Pe,Ke):ee(n.slice(0,2),Ue,ze)}function he(e){let t=`${e.toUpperCase()}<<`.slice(0,2);return t==="AC"?"unknown":t==="IR"||t==="AR"||t[0]==="A"||t[0]==="C"?"residence_permit":t[0]==="P"?"passport":t[0]==="I"?"carte_identite":"unknown"}function _t(e){return ye.test(e)&&Number(e)%97===1}function Tt(e,t,n){if(!gt.test(e))return null;let s=Number(e.slice(0,2)),r=t?2e3+s:s>n.year%100?1900+s:2e3+s;return j.of(r,Number(e.slice(2,4)),Number(e.slice(4,6)))}function te(e,t,n){let s=Tt(e,t,n);return s?j.iso(s):""}function Ae(e){let t=e.split("<<").filter(n=>k(n).length>0);return[(t[0]??"").replaceAll("<"," ").trim(),(t[1]??"").replaceAll("<"," ").trim()]}var xe=e=>e==="M"||e==="F"?e:"",Ot=e=>e.substring(0,2).replaceAll("<",""),oe=e=>e.substring(2,5).replaceAll("<","");function We(e,t,n){if(t==="<"&&k(n).length>0){let s=n.indexOf("<"),r=s<0?n:n.slice(0,s);if(r.length>=2){let o=e+r.slice(0,-1);if(D(o,r[r.length-1])===!0)return{value:k(o),ok:!0,warn:null}}return{value:k(e),ok:!1,warn:"docnum_cd_mismatch"}}return{value:k(e),ok:D(e,t),warn:null}}var K=(e,t)=>({success:!1,error:e,fields:{},checkDigits:{},hardCdFail:!1,warns:[],...t===void 0?{}:{linesCount:t}});function Me(e,t,n,s,r,o,i){return{success:!0,documentType:e,format:t,documentCode:Ot(n),fields:s,checkDigits:r,hardCdFail:o,warns:i}}function Lt(e,t){if(e.length<3)return K("mrz_incomplete");let[n,s,r]=ee(e.slice(0,3),ve,Ge),o=oe(n)===ge||s.substring(15,18)===ge||_t(n.substring(15,25)),i=[],l={},a,d,b=!1;if(o){a=k(n.substring(5,14));let A=n[14];Fe(A)?(d=ue(n.substring(5,14))===A,d||i.push("td1_docnum_cd_mismatch")):d=null}else{let A=We(n.substring(5,14),n[14],n.substring(15,30));if(A.ok===null)return K("mrz_incomplete");a=A.value,d=A.ok,b=A.ok===!1&&A.warn===null,A.warn!==null&&i.push(A.warn)}l.document_number=d;let f=D(s.substring(0,6),s[6]),p=D(s.substring(8,14),s[14]);if(l.birth_date=f,l.expiry_date=p,f===null||p===null)return K("mrz_incomplete");let y=D(n.substring(5,30)+s.substring(0,7)+s.substring(8,15)+s.substring(18,29),s[29]);l.composite=y,y===!1&&i.push("composite_cd_mismatch");let m=o?n.substring(15,25):"",[u,R]=Ae(r),S=f===!1||p===!1||b;return Me(he(n.substring(0,2)),"TD1",n,{issuing_state:oe(n),document_number:a,nni:ye.test(m)?m:"",birth_date:te(s.substring(0,6),!1,t),expiry_date:te(s.substring(8,14),!0,t),sex:xe(s[7]),nationality:k(s.substring(15,18)),surname:u,given_names:R},l,S,i)}function wt(e,t){if(e.length<2)return K("mrz_incomplete");let[n,s]=ee(e.slice(0,2),Pe,Ke),r=[],o=We(s.substring(0,9),s[9],s.substring(28,35));o.warn!==null&&r.push(o.warn);let i=D(s.substring(13,19),s[19]),l=D(s.substring(21,27),s[27]),a={document_number:o.ok,birth_date:i,expiry_date:l};if(o.ok===null||i===null||l===null)return K("mrz_incomplete");let d=D(s.substring(0,10)+s.substring(13,20)+s.substring(21,35),s[35]);a.composite=d,d===!1&&r.push("composite_cd_mismatch");let[b,f]=Ae(n.substring(5,36)),p=o.ok===!1&&o.warn===null||i===!1||l===!1;return Me(he(n.substring(0,2)),"TD2",n,{issuing_state:oe(n),document_number:o.value,nni:"",birth_date:te(s.substring(13,19),!1,t),expiry_date:te(s.substring(21,27),!0,t),sex:xe(s[20]),nationality:k(s.substring(10,13)),surname:b,given_names:f},a,p,r)}function ke(e,t){if(e.length<2)return K("mrz_incomplete");let[n,s]=ee(e.slice(0,2),Ue,ze),r=oe(n)===ge,o=[],i={},l=s.substring(0,9),a=D(l,s[9]),d=D(s.substring(13,19),s[19]),b=D(s.substring(21,27),s[27]);if(i.document_number=a,i.birth_date=d,i.expiry_date=b,a===null||d===null||b===null)return K("mrz_incomplete");let f=s.substring(28,42),p="";if(k(f).length>0){let S=D(f,s[42]);i.personal_number=S;let A=k(f);r&&S!==!1&&ye.test(A)&&(p=A)}let y=D(s.substring(0,10)+s.substring(13,20)+s.substring(21,43),s[43]);i.composite=y,y===!1&&o.push("composite_cd_mismatch");let[m,u]=Ae(n.substring(5,44)),R=a===!1||d===!1||b===!1;return Me(he(n.substring(0,2)),"TD3",n,{issuing_state:oe(n),document_number:k(l),nni_candidate:p,birth_date:te(s.substring(13,19),!1,t),expiry_date:te(s.substring(21,27),!0,t),sex:xe(s[20]),nationality:k(s.substring(10,13)),surname:m,given_names:u},i,R,o)}var Be=new Set(["A","C","I"]);function Ve(e,t=j.today()){let n=e.filter(r=>r.trim().length>0);if(n.length===0)return K("mrz_unrecognized",0);let s=Array.from(ce(n[0]).slice(0,1),pe).join("");return n.length===3&&Be.has(s)?Lt(n,t):n.length===2&&s==="P"?ke(n,t):n.length===2&&Be.has(s)?Math.max(...n.map(r=>ce(r).length))>40?ke(n,t):wt(n,t):K("mrz_unrecognized",n.length)}var Dt=new Map([...(`ABWAW AFGAF AGOAO AIAAI ALAAX ALBAL ANDAD AREAE ARGAR ARMAM ASMAS ATAAQ
13
+ TUN TUR TUV TWN TZA UGA UKR UMI URY USA UZB VAT VCT VEN VGB VIR VNM VUT WLF WSM XKK YEM ZAF ZMB ZWE`.trim().split(/\s+/)),It=new Set(`D GBD GBN GBO GBP GBS RKS UNK UNO UNA EUE XBA XIM XCC XCE XCO XDC XEC XES XMP XOM XPO XXA XXB XXC
14
+ XXX ANT NTZ UTO`.trim().split(/\s+/));function Nt(e){return Rt.has(e)||It.has(e)}var Tt="012568",Et="OIZSGB",Ct="OQDILZSGB",_t="000112568";function he(e){let t=Tt.indexOf(e);return e.length!==1||t<0?e:Et[t]}function Ot(e){let t=Ct.indexOf(e);return e.length!==1||t<0?e:_t[t]}var Lt=[["\xAB","<<"],["\u2039","<"],["\uFF1C","<"],["\u3008","<"],["\xD7","X"]],Ke=[`aaccc${"x".repeat(9)}n${"x".repeat(15)}`,`${"n".repeat(7)}x${"n".repeat(7)}ccc${"x".repeat(11)}n`,"a".repeat(30)],We=[`aaccc${"a".repeat(31)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(7)}n`],Ve=[`aaccc${"a".repeat(39)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(14)}nn`];function wt(e,t){let n="",r=0;for(;r<t.length;){let i=t[r];if(i==="c"){let o=e.substring(r,r+3),c=Array.from(o,he).join("");n+=c!==o&&Nt(c.replaceAll("<",""))?c:o,r+=3;continue}let s=e[r];n+=i==="a"?he(s):i==="n"?Ot(s):s,r++}return n}function ee(e,t,n){return n.slice(0,e.length).map((r,i)=>{let s=Lt.reduce((o,[c,a])=>o.replaceAll(c,a),de(e[i]));return wt(St(s,t),r)})}function Ye(e,t){let n=e.filter(r=>r.trim().length>0);return t==="TD1"?ee(n.slice(0,3),Ue,Ke):t==="TD2"?ee(n.slice(0,2),Ge,We):ee(n.slice(0,2),ze,Ve)}function Ae(e){let t=`${e.toUpperCase()}<<`.slice(0,2);return t==="AC"?"unknown":t==="IR"||t==="AR"||t[0]==="A"||t[0]==="C"?"residence_permit":t[0]==="P"?"passport":t[0]==="I"?"carte_identite":"unknown"}function Dt(e){return xe.test(e)&&Number(e)%97===1}function vt(e,t,n){if(!At.test(e))return null;let r=Number(e.slice(0,2)),i=t?2e3+r:r>n.year%100?1900+r:2e3+r;return j.of(i,Number(e.slice(2,4)),Number(e.slice(4,6)))}function te(e,t,n){let r=vt(e,t,n);return r?j.iso(r):""}function Me(e){let t=e.split("<<").filter(n=>B(n).length>0);return[(t[0]??"").replaceAll("<"," ").trim(),(t[1]??"").replaceAll("<"," ").trim()]}var Se=e=>e==="M"||e==="F"?e:"",kt=e=>e.substring(0,2).replaceAll("<",""),se=e=>e.substring(2,5).replaceAll("<","");function Ze(e,t,n){if(t==="<"&&B(n).length>0){let r=n.indexOf("<"),i=r<0?n:n.slice(0,r);if(i.length>=2){let s=e+i.slice(0,-1);if(v(s,i[i.length-1])===!0)return{value:B(s),ok:!0,warn:null}}return{value:B(e),ok:!1,warn:"docnum_cd_mismatch"}}return{value:B(e),ok:v(e,t),warn:null}}var H=(e,t)=>({success:!1,error:e,fields:{},checkDigits:{},hardCdFail:!1,warns:[],...t===void 0?{}:{linesCount:t}});function Re(e,t,n,r,i,s,o){return{success:!0,documentType:e,format:t,documentCode:kt(n),fields:r,checkDigits:i,hardCdFail:s,warns:o}}function Bt(e,t){if(e.length<3)return H("mrz_incomplete");let[n,r,i]=ee(e.slice(0,3),Ue,Ke),s=se(n)===ye||r.substring(15,18)===ye||Dt(n.substring(15,25)),o=[],c={},a,d,p=!1;if(s){a=B(n.substring(5,14));let x=n[14];He(x)?(d=fe(n.substring(5,14))===x,d||o.push("td1_docnum_cd_mismatch")):d=null}else{let x=Ze(n.substring(5,14),n[14],n.substring(15,30));if(x.ok===null)return H("mrz_incomplete");a=x.value,d=x.ok,p=x.ok===!1&&x.warn===null,x.warn!==null&&o.push(x.warn)}c.document_number=d;let f=v(r.substring(0,6),r[6]),g=v(r.substring(8,14),r[14]);if(c.birth_date=f,c.expiry_date=g,f===null||g===null)return H("mrz_incomplete");let b=v(n.substring(5,30)+r.substring(0,7)+r.substring(8,15)+r.substring(18,29),r[29]);c.composite=b,b===!1&&o.push("composite_cd_mismatch");let l=s?n.substring(15,25):"",[u,S]=Me(i),R=f===!1||g===!1||p;return Re(Ae(n.substring(0,2)),"TD1",n,{issuing_state:se(n),document_number:a,nni:xe.test(l)?l:"",birth_date:te(r.substring(0,6),!1,t),expiry_date:te(r.substring(8,14),!0,t),sex:Se(r[7]),nationality:B(r.substring(15,18)),surname:u,given_names:S},c,R,o)}function Pt(e,t){if(e.length<2)return H("mrz_incomplete");let[n,r]=ee(e.slice(0,2),Ge,We),i=[],s=Ze(r.substring(0,9),r[9],r.substring(28,35));s.warn!==null&&i.push(s.warn);let o=v(r.substring(13,19),r[19]),c=v(r.substring(21,27),r[27]),a={document_number:s.ok,birth_date:o,expiry_date:c};if(s.ok===null||o===null||c===null)return H("mrz_incomplete");let d=v(r.substring(0,10)+r.substring(13,20)+r.substring(21,35),r[35]);a.composite=d,d===!1&&i.push("composite_cd_mismatch");let[p,f]=Me(n.substring(5,36)),g=s.ok===!1&&s.warn===null||o===!1||c===!1;return Re(Ae(n.substring(0,2)),"TD2",n,{issuing_state:se(n),document_number:s.value,nni:"",birth_date:te(r.substring(13,19),!1,t),expiry_date:te(r.substring(21,27),!0,t),sex:Se(r[20]),nationality:B(r.substring(10,13)),surname:p,given_names:f},a,g,i)}function Pe(e,t){if(e.length<2)return H("mrz_incomplete");let[n,r]=ee(e.slice(0,2),ze,Ve),i=se(n)===ye,s=[],o={},c=r.substring(0,9),a=v(c,r[9]),d=v(r.substring(13,19),r[19]),p=v(r.substring(21,27),r[27]);if(o.document_number=a,o.birth_date=d,o.expiry_date=p,a===null||d===null||p===null)return H("mrz_incomplete");let f=r.substring(28,42),g="";if(B(f).length>0){let R=v(f,r[42]);o.personal_number=R;let x=B(f);i&&R!==!1&&xe.test(x)&&(g=x)}let b=v(r.substring(0,10)+r.substring(13,20)+r.substring(21,43),r[43]);o.composite=b,b===!1&&s.push("composite_cd_mismatch");let[l,u]=Me(n.substring(5,44)),S=a===!1||d===!1||p===!1;return Re(Ae(n.substring(0,2)),"TD3",n,{issuing_state:se(n),document_number:B(c),nni_candidate:g,birth_date:te(r.substring(13,19),!1,t),expiry_date:te(r.substring(21,27),!0,t),sex:Se(r[20]),nationality:B(r.substring(10,13)),surname:l,given_names:u},o,S,s)}var Fe=new Set(["A","C","I"]);function Xe(e,t=j.today()){let n=e.filter(i=>i.trim().length>0);if(n.length===0)return H("mrz_unrecognized",0);let r=Array.from(de(n[0]).slice(0,1),he).join("");return n.length===3&&Fe.has(r)?Bt(n,t):n.length===2&&r==="P"?Pe(n,t):n.length===2&&Fe.has(r)?Math.max(...n.map(i=>de(i).length))>40?Pe(n,t):Pt(n,t):H("mrz_unrecognized",n.length)}var Ft=new Map([...(`ABWAW AFGAF AGOAO AIAAI ALAAX ALBAL ANDAD AREAE ARGAR ARMAM ASMAS ATAAQ
14
15
  ATFTF ATGAG AUSAU AUTAT AZEAZ BDIBI BELBE BENBJ BESBQ BFABF BGDBD BGRBG
15
16
  BHRBH BHSBS BIHBA BLMBL BLRBY BLZBZ BMUBM BOLBO BRABR BRBBB BRNBN BTNBT
16
17
  BVTBV BWABW CAFCF CANCA CCKCC CHECH CHLCL CHNCN CIVCI CMRCM CODCD COGCG
@@ -30,13 +31,11 @@ var Y={fp12:"08390000c48a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro
30
31
  SRBRS SSDSS STPST SURSR SVKSK SVNSI SWESE SWZSZ SXMSX SYCSC SYRSY TCATC
31
32
  TCDTD TGOTG THATH TJKTJ TKLTK TKMTM TLSTL TONTO TTOTT TUNTN TURTR TUVTV
32
33
  TWNTW TZATZ UGAUG UKRUA UMIUM URYUY USAUS UZBUZ VATVA VCTVC VENVE VGBVG
33
- VIRVI VNMVN VUTVU WLFWF WSMWS YEMYE ZAFZA ZMBZM ZWEZW`.match(/[A-Z]{5}/g)??[]).map(e=>[e.slice(0,3),e.slice(3)]),["D","DE"]]),Ye={of(e){return Dt.get(e.replaceAll("<",""))??null}};var Se=e=>ue(e);function Qe(e){return e.slice(0,5e4).split(/\r?\n/).slice(0,200).map(t=>t.toUpperCase().replace(/[«‹〈]/g,"<").replace(/[^A-Z0-9<]/g,"")).filter(t=>t.length>0)}var Ze=e=>e.replace(/[OQ]/g,"0").replace(/[IL]/g,"1").replaceAll("Z","2").replaceAll("S","5").replaceAll("B","8");function Xe(e,t){let n=Ze(e),s=Ze(t);if(!/^\d{6}$/.test(n)||Se(n)!==s)return null;let r=2e3+Number(n.slice(0,2)),o=Number(n.slice(2,4)),i=Number(n.slice(4,6));return o>=1&&o<=12&&i>=1&&i<=new Date(Date.UTC(r,o,0)).getUTCDate()?n:null}function Re(e,t){let n=e.replace(/<+$/,"");return/^[A-Z0-9]+$/.test(n)&&Se(e)===t?n:null}function kt(e){if(e.length<15)return null;if(e[14]!=="<")return Re(e.substring(5,14),e[14]);let t=/^([A-Z0-9]+)</.exec(e.substring(15,Math.min(30,e.length)))?.[1];return t===void 0||t.length<2?null:Re(e.substring(5,14)+t.slice(0,-1),t[t.length-1])}var x=(e,t,n)=>t>=e.length?"":e.substring(t,Math.min(n,e.length)),Z=(e,t)=>t<e.length?e[t]:"",$e=/^[IAC][A-Z<][A-Z<]{3}/,Bt=/^P[A-Z<][A-Z<]{3}/,qe=/^[PIAC][A-Z<][A-Z<]{3}/;function vt(e){let t=Qe(e),n=[],s=[];for(let o=0;o<t.length;o++){let i="",l=0;for(;l<6&&o+l<t.length&&(i+=t[o+l],!(i.length>300));)s.push(i),l++}let r=(o,i,l)=>{if(i.length<(l?15:28))return;let a=new Map,d=l?kt(o):Re(x(i,0,9),Z(i,9)),b=Xe(l?x(i,0,6):x(i,13,19),l?Z(i,6):Z(i,19)),f=Xe(l?x(i,8,14):x(i,21,27),l?Z(i,14):Z(i,27));d!==null&&a.set("docNumber",d),b!==null&&a.set("dob6",b),f!==null&&a.set("expiry6",f),a.size>0&&n.push({fields:a,country:Ye.of(x(o,2,5))})};for(let o of s)$e.test(o)&&(o.length>=45&&r(o.substring(0,30),o.substring(30),!0),o.length>=64&&r(o.substring(0,36),o.substring(36),!1)),Bt.test(o)&&o.length>=72&&r(o.substring(0,44),o.substring(44),!1);for(let o=0;o<t.length-1;o++){let i=t[o],l=t[o+1];$e.test(i)&&i.length>=15&&i.length<=30&&r(i,l,!0),qe.test(i)&&i.length>=5&&i.length<=44&&r(i,l,!1)}return n}function Pt(e){let t=vt(e);if(t.length===0)return{};let n=Math.max(...t.map(o=>o.fields.size)),s=t.filter(o=>o.fields.size===n),r={};for(let o of["docNumber","dob6","expiry6"]){let i=new Set(s.map(l=>l.fields.get(o)).filter(l=>l!==void 0));i.size===1&&s.every(l=>l.fields.has(o))&&(r[o]=[...i][0])}return r}function Ut(e){let t=Pt(e),n=t.docNumber,s=t.dob6,r=t.expiry6;return n!==void 0&&s!==void 0&&r!==void 0?{docNumber:n,dob6:s,expiry6:r}:null}function et(e){let t=Gt(e);return t.length===1?t[0]:null}var Ft=e=>JSON.stringify([e.documentNumber,e.nationality,e.dob,e.sex,e.expiry,e.primaryIdentifier,e.secondaryIdentifier,e.optional]);function Gt(e){let t=Qe(e),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(!qe.test(o))continue;let i=o.startsWith("P")?[44]:[30,36];for(let l of i){let a=l===30?3:2,d=t.slice(r,Math.min(t.length,r+a));d.length===a&&d.every(p=>p.length<=l)&&n.push(d.map(p=>p.padEnd(l,"<")).join(`
34
- `));let b="",f=0;for(;f<6&&r+f<t.length&&(b+=t[r+f],b.length===l*a&&n.push(b),!(b.length>=l*a));)f++}}let s=new Map;for(let r of n){let o=Ut(r);if(o===null)continue;let i=r.includes(`
35
- `)?r.split(`
36
- `):r.match(r.length===90?/.{30}/g:r.length===88?/.{44}/g:/.{36}/g)??[],l=i[0]??"",a=i[1]??"",d=i.length===3,b=d?x(l,5,30)+x(a,0,7)+x(a,8,15)+x(a,18,29):x(a,0,10)+x(a,13,20)+x(a,21,a.length-1),f=d?Z(a,29):Z(a,a.length-1);if(!/^[0-9]$/.test(f)||Se(b)!==f)continue;let p=Kt(r);if(p===null||p.primaryIdentifier.length===0&&p.secondaryIdentifier.length===0||!/^[MFX]?$/.test(p.sex))continue;let y={...p,documentNumber:o.docNumber,dob:o.dob6,expiry:o.expiry6};s.set(Ft(y),{fields:y,mrzLines:i})}return[...s.values()]}var P=e=>e.replaceAll("<"," ").replace(/\s+/g," ").trim();function Je(e){let t=e.split("<<");return[P(t[0]??""),P(t.slice(1).join("<<"))]}var je=e=>e.length===0?null:e;function Kt(e){let t=e.split(/\r?\n/).map(s=>s.replace(/\s+$/,"")).filter(s=>s.length>0),n=e.replace(/[\r\n]/g,"");if(t.length===1&&(n.length===90?t=[n.substring(0,30),n.substring(30,60),n.substring(60,90)]:n.length===72?t=[n.substring(0,36),n.substring(36,72)]:n.length===88&&(t=[n.substring(0,44),n.substring(44,88)])),t.length===3){let[s,r,o]=t,i=Z(s,14)==="<"?/^([A-Z0-9]+)</.exec(x(s,15,30))?.[1]:void 0,l=P(x(s,5,14)+(i!==void 0&&i.length>1?i.slice(0,-1):"")),[a,d]=Je(o),b=P(`${x(s,15,30)}<${x(r,18,29)}`);return{documentNumber:l,nationality:P(x(r,15,18)),dob:x(r,0,6),sex:P(x(r,7,8)),expiry:x(r,8,14),primaryIdentifier:a,secondaryIdentifier:d,optional:je(b)}}if(t.length===2){let[s,r]=t,o=s.length>=44,[i,l]=Je(x(s,5,o?44:36));return{documentNumber:P(x(r,0,9)),nationality:P(x(r,10,13)),dob:x(r,13,19),sex:P(x(r,20,21)),expiry:x(r,21,27),primaryIdentifier:i,secondaryIdentifier:l,optional:je(P(o?x(r,28,42):x(r,28,35)))}}return null}function tt(e,t=j.today()){let n=Ve(e,t),s=n.format??null,r=s==="TD1"||s==="TD2"||s==="TD3"?He(e,s):[...e];return{format:s,documentCode:n.documentCode??null,lines:r,valid:n.success&&!n.hardCdFail}}var zt=/^[A-Z0-9<]{25,}$/;function Ht(e){return e.toUpperCase().replaceAll(" ","").replaceAll("\xAB","<").replaceAll("\u2039","<")}var Ie=(e,t,n)=>e.length>=t&&e.length<=n;function nt(e){let t=e.map(Ht).filter(n=>zt.test(n));for(let n=0;n+3<=t.length;n++){let s=t.slice(n,n+3);if(s.every(r=>Ie(r,28,32))&&"IAC".includes(s[0][0]))return s}for(let n=0;n+2<=t.length;n++){let s=t.slice(n,n+2);if(s.every(r=>Ie(r,40,46))&&s[0].startsWith("P")||s.every(r=>Ie(r,34,38))&&"IACPV".includes(s[0][0]))return s}return[]}var ne={SIZE:80,SCRIPT:64,OFFSET:68,STEPS:72},L={DETECTOR:0,LATIN:1,ARABIC:2},U={NONE:0,LATIN:1,ARABIC:2,BOTH:3},de=3;var X=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Ce(e,t,n,s,r){let o=r.now??(()=>performance.now()),i=o(),a=e.read(t,n,s,r.region??[0,0,1,1],1,de,U.LATIN,r.detectorLimit).map(u=>({text:u.latin.text,score:u.latin.score,box:[0,1,2,3].map(R=>({x:u.box[2*R],y:u.box[2*R+1]}))})),d=De([...a].reverse()),b=d.map(u=>u.text),f=[...et(b.join(`
37
- `))?.mrzLines??nt(b)],p=d.map(u=>[X(u.x/n),X(u.y/s),X((u.x2-u.x)/n),X((u.y2-u.y)/s)]),y={kind:"band",ms:0,lineBoxes:p,lineCount:f.length,valid:!1},m=Vt(d.map(u=>u.text),p,f);if(m!==null&&(y.mrzBox=m),f.length>0){let u=tt(f,r.today??j.today());u.format&&(y.format=u.format),u.documentCode&&/^[A-Z<]{1,2}$/.test(u.documentCode)&&(y.documentCode=u.documentCode),u.valid&&(y.valid=!0,y.digest=await Ne(r.salt,u.lines))}return y.ms=Math.round(o()-i),y}var rt=e=>e.toUpperCase().replace(/\s+/g,"");function Wt(e,t){let n=Math.max(e.length,t.length);if(n===0)return 0;let s=0;for(let r=0;r<Math.min(e.length,t.length);r++)e[r]===t[r]&&s++;return s/n}function Vt(e,t,n){if(n.length===0||e.length===0)return null;let s=new Set,r=[];for(let d of n){let b=-1,f=.5;if(e.forEach((p,y)=>{let m=s.has(y)?0:Wt(rt(p),rt(d));m>f&&(f=m,b=y)}),b<0)return null;s.add(b),r.push(t[b])}let o=Math.min(...r.map(d=>d[0])),i=Math.min(...r.map(d=>d[1])),l=Math.max(...r.map(d=>d[0]+d[2])),a=Math.max(...r.map(d=>d[1]+d[3]));return[X(o),X(i),X(l-o),X(a-i)]}var Sn=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function st(e,t,n){let s=r=>Math.round(Math.min(1,Math.max(0,r))*1e4)/1e4;return e.map(r=>{let o=[r[0],r[2],r[4],r[6]],i=[r[1],r[3],r[5],r[7]],l=Math.min(...o),a=Math.min(...i);return[s(l/t),s(a/n),s((Math.max(...o)-l)/t),s((Math.max(...i)-a)/n)]}).sort((r,o)=>r[1]-o[1]||r[0]-o[0])}async function Yt(e={}){var t,n=e,s=import.meta.url,r="",o,i;try{r=new URL(".",s).href}catch{}i=c=>{var h=new XMLHttpRequest;return h.open("GET",c,!1),h.responseType="arraybuffer",h.send(null),new Uint8Array(h.response)},o=async c=>{if(c=await fetch(c,{credentials:"same-origin"}),c.ok)return c.arrayBuffer();throw Error(c.status+" : "+c.url)};var l=console.log.bind(console),a=console.error.bind(console),d=!1,b,f,p,y,m,u=!1;function R(){var c=ae.buffer;new Int8Array(c),new Int16Array(c),n.HEAPU8=p=new Uint8Array(c),new Uint16Array(c),new Int32Array(c),y=new Uint32Array(c),new Float32Array(c),new Float64Array(c),m=new BigInt64Array(c),new BigUint64Array(c)}function S(c){throw c="Aborted("+c+")",a(c),d=!0,c+=". Build with -sASSERTIONS for more info.",u&&Q(),c=new WebAssembly.RuntimeError(c),f?.(c),c}var A;async function w(c){try{var h=await o(c);return new Uint8Array(h)}catch{}if(i)c=i(c);else throw"both async and sync fetching of the wasm failed";return c}async function B(c,h){try{var g=await w(c);return await WebAssembly.instantiate(g,h)}catch(C){a(`failed to asynchronously prepare wasm: ${C}`),S(C)}}async function z(c){var h=A;try{var g=fetch(h,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(g,c)}catch(C){a(`wasm streaming compile failed: ${C}`),a("falling back to ArrayBuffer instantiation")}return B(h,c)}var H={},W=()=>{if(!$){var c={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"},h;for(h in H)H[h]===void 0?delete c[h]:c[h]=H[h];var g=[];for(h in c)g.push(`${h}=${c[h]}`);$=g}return $},$,J=[null,[],[]],ie=globalThis.TextDecoder&&new TextDecoder,Q,ae,ct={i:()=>S(""),b:function(c,h,g){return 0<=c&&3>=c?(m[g>>3]=BigInt(Math.round(1e6*(c===0?Date.now():performance.now()))),0):28},d:()=>1073741824,c:c=>{var h=p.length;if(c>>>=0,1073741824<c)return!1;for(var g=1;4>=g;g*=2){var C=h*(1+.2/g);C=Math.min(C,c+100663296);e:{C=(Math.min(1073741824,65536*Math.ceil(Math.max(c,C)/65536))-ae.buffer.byteLength+65535)/65536|0;try{ae.grow(C),R();var _=1;break e}catch{}_=void 0}if(_)return!0}return!1},f:(c,h)=>{var g=0,C=0,_;for(_ of W()){var M=h+g;y[c+C>>2]=M;for(var q=_,O=p,re=M,F=M+1/0-1,E=0;E<q.length;++E){var N=q.codePointAt(E);if(127>=N){if(M>=F)break;O[M++]=N}else if(2047>=N){if(M+1>=F)break;O[M++]=192|N>>6,O[M++]=128|N&63}else if(65535>=N){if(M+2>=F)break;O[M++]=224|N>>12,O[M++]=128|N>>6&63,O[M++]=128|N&63}else{if(M+3>=F)break;O[M++]=240|N>>18,O[M++]=128|N>>12&63,O[M++]=128|N>>6&63,O[M++]=128|N&63,E++}}O[M]=0,q=M-re,g+=q+1,C+=4}return 0},g:(c,h)=>{var g=W();y[c>>2]=g.length,c=0;for(var C of g){for(var _=g=0;_<C.length;++_){var M=C.charCodeAt(_);127>=M?g++:2047>=M?g+=2:55296<=M&&57343>=M?(g+=4,++_):g+=3}c+=g+1}return y[h>>2]=c,0},j:()=>52,h:()=>52,e:function(){return 70},a:(c,h,g,C)=>{for(var _=0,M=0;M<g;M++){var q=y[h>>2],O=y[h+4>>2];h+=8;for(var re=0;re<O;re++){var F=c,E=p[q+re],N=J[F];if(E===0||E===10){F=F===1?l:a,E=N;for(var V=0,se=E,v=V,T=v+void 0;se[v]&&!(v>=T);)++v;if(se=v,16<se-V&&E.buffer&&ie)E=ie.decode(E.subarray(V,se));else{for(v="";V<se;)if(T=E[V++],T&128){var me=E[V++]&63;if((T&224)==192)v+=String.fromCharCode((T&31)<<6|me);else{var Ee=E[V++]&63;T=(T&240)==224?(T&15)<<12|me<<6|Ee:(T&7)<<18|me<<12|Ee<<6|E[V++]&63,65536>T?v+=String.fromCharCode(T):(T-=65536,v+=String.fromCharCode(55296|T>>10,56320|T&1023))}}else v+=String.fromCharCode(T);E=v}F(E),N.length=0}else N.push(E)}_+=O}return y[C>>2]=_,0}},le;return le=await(async function(){function c(g){return g=le=g.exports,n._skw_engine_id=g.m,n._skw_load=g.n,n._skw_unload=g.o,n._skw_set_detector_limit=g.p,n._skw_read=g.q,n._skw_line_count=g.r,n._skw_lines=g.s,n._skw_best=g.t,n._skw_values=g.u,n._skw_sharpness=g.v,n._free=g.w,n._malloc=g.x,Q=g.y,ae=g.k,R(),le}var h={a:ct};return n.instantiateWasm?new Promise(g=>{n.instantiateWasm(h,(C,_)=>{g(c(C,_))})}):(A??(A=n.locateFile?n.locateFile?n.locateFile("sekyro-ocr.wasm",r):r+"sekyro-ocr.wasm":new URL("sekyro-ocr.wasm",import.meta.url).href),c((await z(h)).instance))})(),n.calledRun=!0,d||(u=!0,le.l(),b?.(n)),u?t=n:t=new Promise((c,h)=>{b=c,f=h}),t}var ot=Yt;function it(e){return e===1||e===5?new I("OCR_IMAGE_INVALID"):e===2?new I("OCR_ASSET_INVALID"):e===4?new I("OCR_CANCELLED"):e===6?new I("OCR_BUSY"):e===7?new I("OCR_UNAVAILABLE"):new I("OCR_INFERENCE_FAILED")}var fe=class{constructor(t){this.m=t;this.px=0;this.pxBytes=0;this.dicts=[null,null,null];this.classes=[0,0,0];this.held=[[],[],[]];this.latinKind="latin"}engineId(){let t=this.m._skw_engine_id(),n="";for(let s=t;this.m.HEAPU8[s]!==0&&s<t+64;s++)n+=String.fromCharCode(this.m.HEAPU8[s]);return n}put(t){let n=this.m._malloc(t.length);if(!n)throw new I("OCR_UNAVAILABLE");return this.m.HEAPU8.set(t,n),n}load(t,n,s,r,o={}){this.unload(t);let i=new Uint8Array(n),l=new Uint8Array(i.byteLength+1);l.set(i);let a=r===void 0?null:Oe(r),d=r===void 0?0:at(r);if(o.mrz===!0){if(t!==L.LATIN||r===void 0||!$t(r))throw new I("OCR_ASSET_INVALID")}else if(t===L.LATIN&&(r===void 0||r.endsWith(`
38
- `)||d!==6625))throw new I("OCR_ASSET_INVALID");if(t===L.ARABIC&&(r===void 0||!r.endsWith(`
39
- `)||d!==163||a[161]!==""))throw new I("OCR_ASSET_INVALID");let b=new Uint8Array(s),f=this.put(l),p=this.put(b);this.held[t]=[f,p];let y=this.m._skw_load(t,f,l.length,p,b.byteLength,d);if(y!==0)throw this.unload(t),it(y);this.dicts[t]=a,this.classes[t]=d,t===L.LATIN&&(this.latinKind=o.mrz===!0?"mrz":"latin")}recognizer(){return this.loaded(L.LATIN)?this.latinKind:null}unload(t){this.held[t].length&&this.m._skw_unload(t);for(let n of this.held[t])this.m._free(n);this.held[t]=[],this.dicts[t]=null}loaded(t){return this.held[t].length>0}pixels(t){if(t.length>this.pxBytes){if(this.px&&this.m._free(this.px),this.px=this.m._malloc(t.length),!this.px)throw new I("OCR_UNAVAILABLE");this.pxBytes=t.length}return this.m.HEAPU8.set(t,this.px),this.px}sharpness(t,n,s){let r=this.m._skw_sharpness(this.pixels(t),n,s);return r>=0&&Number.isFinite(r)?r:null}read(t,n,s,r,o,i,l,a){if(!Zt(l))throw new I("OCR_IMAGE_INVALID");if(l&U.LATIN&&!this.dicts[L.LATIN]||l&U.ARABIC&&!this.dicts[L.ARABIC]||!this.loaded(0))throw new I("OCR_UNAVAILABLE");let d=this.pixels(t);this.m._skw_set_detector_limit(a);let b=this.m._skw_read(d,n,s,r[0],r[1],r[2],r[3],o,i,l);if(b!==0)throw it(b);let f=this.m._skw_line_count(),p=this.m.HEAPU8.buffer,y=new DataView(p,this.m._skw_lines(),f*ne.SIZE),m=new Int32Array(p,this.m._skw_best()),u=new Float32Array(p,this.m._skw_values()),R=[];for(let S=0;S<f;S++){let A=S*ne.SIZE,w=y.getInt32(A+ne.SCRIPT,!0),B=y.getInt32(A+ne.OFFSET,!0),z=y.getInt32(A+ne.STEPS,!0);if(l===U.NONE){R.push({box:Array.from({length:8},(ie,Q)=>y.getFloat64(A+8*Q,!0))});continue}let H=this.dicts[w];if(!H)throw new I("OCR_INFERENCE_FAILED");let W=Le(m.subarray(B,B+z),u.subarray(B,B+z),this.classes[w],H,w===L.ARABIC),$=Array.from({length:8},(ie,Q)=>y.getFloat64(A+8*Q,!0)),J=R[R.length-1];w===L.ARABIC&&J&&J.arabic===void 0&&J.latin!==void 0&&Xt(J.box,$)?J.arabic=W:R.push(w===L.ARABIC?{box:$,arabic:W}:{box:$,latin:W})}return R}heapBytes(){return this.m.HEAPU8.length}dispose(){for(let t of[0,1,2])this.unload(t);this.px&&this.m._free(this.px),this.px=0,this.pxBytes=0}};function at(e){return(e.endsWith(`
34
+ VIRVI VNMVN VUTVU WLFWF WSMWS YEMYE ZAFZA ZMBZM ZWEZW`.match(/[A-Z]{5}/g)??[]).map(e=>[e.slice(0,3),e.slice(3)]),["D","DE"]]),$e={of(e){return Ft.get(e.replaceAll("<",""))??null}};var Ne=e=>fe(e);function tt(e){return e.slice(0,5e4).split(/\r?\n/).slice(0,200).map(t=>t.toUpperCase().replace(/[«‹〈]/g,"<").replace(/[^A-Z0-9<]/g,"")).filter(t=>t.length>0)}var Je=e=>e.replace(/[OQ]/g,"0").replace(/[IL]/g,"1").replaceAll("Z","2").replaceAll("S","5").replaceAll("B","8");function je(e,t){let n=Je(e),r=Je(t);if(!/^\d{6}$/.test(n)||Ne(n)!==r)return null;let i=2e3+Number(n.slice(0,2)),s=Number(n.slice(2,4)),o=Number(n.slice(4,6));return s>=1&&s<=12&&o>=1&&o<=new Date(Date.UTC(i,s,0)).getUTCDate()?n:null}function Ie(e,t){let n=e.replace(/<+$/,"");return/^[A-Z0-9]+$/.test(n)&&Ne(e)===t?n:null}function Ut(e){if(e.length<15)return null;if(e[14]!=="<")return Ie(e.substring(5,14),e[14]);let t=/^([A-Z0-9]+)</.exec(e.substring(15,Math.min(30,e.length)))?.[1];return t===void 0||t.length<2?null:Ie(e.substring(5,14)+t.slice(0,-1),t[t.length-1])}var A=(e,t,n)=>t>=e.length?"":e.substring(t,Math.min(n,e.length)),Z=(e,t)=>t<e.length?e[t]:"",Qe=/^[IAC][A-Z<][A-Z<]{3}/,Gt=/^P[A-Z<][A-Z<]{3}/,nt=/^[PIAC][A-Z<][A-Z<]{3}/;function zt(e){let t=tt(e),n=[],r=[];for(let s=0;s<t.length;s++){let o="",c=0;for(;c<6&&s+c<t.length&&(o+=t[s+c],!(o.length>300));)r.push(o),c++}let i=(s,o,c)=>{if(o.length<(c?15:28))return;let a=new Map,d=c?Ut(s):Ie(A(o,0,9),Z(o,9)),p=je(c?A(o,0,6):A(o,13,19),c?Z(o,6):Z(o,19)),f=je(c?A(o,8,14):A(o,21,27),c?Z(o,14):Z(o,27));d!==null&&a.set("docNumber",d),p!==null&&a.set("dob6",p),f!==null&&a.set("expiry6",f),a.size>0&&n.push({fields:a,country:$e.of(A(s,2,5))})};for(let s of r)Qe.test(s)&&(s.length>=45&&i(s.substring(0,30),s.substring(30),!0),s.length>=64&&i(s.substring(0,36),s.substring(36),!1)),Gt.test(s)&&s.length>=72&&i(s.substring(0,44),s.substring(44),!1);for(let s=0;s<t.length-1;s++){let o=t[s],c=t[s+1];Qe.test(o)&&o.length>=15&&o.length<=30&&i(o,c,!0),nt.test(o)&&o.length>=5&&o.length<=44&&i(o,c,!1)}return n}function Ht(e){let t=zt(e);if(t.length===0)return{};let n=Math.max(...t.map(s=>s.fields.size)),r=t.filter(s=>s.fields.size===n),i={};for(let s of["docNumber","dob6","expiry6"]){let o=new Set(r.map(c=>c.fields.get(s)).filter(c=>c!==void 0));o.size===1&&r.every(c=>c.fields.has(s))&&(i[s]=[...o][0])}return i}function Kt(e){let t=Ht(e),n=t.docNumber,r=t.dob6,i=t.expiry6;return n!==void 0&&r!==void 0&&i!==void 0?{docNumber:n,dob6:r,expiry6:i}:null}function rt(e){let t=Vt(e);return t.length===1?t[0]:null}var Wt=e=>JSON.stringify([e.documentNumber,e.nationality,e.dob,e.sex,e.expiry,e.primaryIdentifier,e.secondaryIdentifier,e.optional]);function Vt(e){let t=tt(e),n=[];for(let i=0;i<t.length;i++){let s=t[i];if(!nt.test(s))continue;let o=s.startsWith("P")?[44]:[30,36];for(let c of o){let a=c===30?3:2,d=t.slice(i,Math.min(t.length,i+a));d.length===a&&d.every(g=>g.length<=c)&&n.push(d.map(g=>g.padEnd(c,"<")).join(`
35
+ `));let p="",f=0;for(;f<6&&i+f<t.length&&(p+=t[i+f],p.length===c*a&&n.push(p),!(p.length>=c*a));)f++}}let r=new Map;for(let i of n){let s=Kt(i);if(s===null)continue;let o=i.includes(`
36
+ `)?i.split(`
37
+ `):i.match(i.length===90?/.{30}/g:i.length===88?/.{44}/g:/.{36}/g)??[],c=o[0]??"",a=o[1]??"",d=o.length===3,p=d?A(c,5,30)+A(a,0,7)+A(a,8,15)+A(a,18,29):A(a,0,10)+A(a,13,20)+A(a,21,a.length-1),f=d?Z(a,29):Z(a,a.length-1);if(!/^[0-9]$/.test(f)||Ne(p)!==f)continue;let g=Yt(i);if(g===null||g.primaryIdentifier.length===0&&g.secondaryIdentifier.length===0||!/^[MFX]?$/.test(g.sex))continue;let b={...g,documentNumber:s.docNumber,dob:s.dob6,expiry:s.expiry6};r.set(Wt(b),{fields:b,mrzLines:o})}return[...r.values()]}var U=e=>e.replaceAll("<"," ").replace(/\s+/g," ").trim();function qe(e){let t=e.split("<<");return[U(t[0]??""),U(t.slice(1).join("<<"))]}var et=e=>e.length===0?null:e;function Yt(e){let t=e.split(/\r?\n/).map(r=>r.replace(/\s+$/,"")).filter(r=>r.length>0),n=e.replace(/[\r\n]/g,"");if(t.length===1&&(n.length===90?t=[n.substring(0,30),n.substring(30,60),n.substring(60,90)]:n.length===72?t=[n.substring(0,36),n.substring(36,72)]:n.length===88&&(t=[n.substring(0,44),n.substring(44,88)])),t.length===3){let[r,i,s]=t,o=Z(r,14)==="<"?/^([A-Z0-9]+)</.exec(A(r,15,30))?.[1]:void 0,c=U(A(r,5,14)+(o!==void 0&&o.length>1?o.slice(0,-1):"")),[a,d]=qe(s),p=U(`${A(r,15,30)}<${A(i,18,29)}`);return{documentNumber:c,nationality:U(A(i,15,18)),dob:A(i,0,6),sex:U(A(i,7,8)),expiry:A(i,8,14),primaryIdentifier:a,secondaryIdentifier:d,optional:et(p)}}if(t.length===2){let[r,i]=t,s=r.length>=44,[o,c]=qe(A(r,5,s?44:36));return{documentNumber:U(A(i,0,9)),nationality:U(A(i,10,13)),dob:A(i,13,19),sex:U(A(i,20,21)),expiry:A(i,21,27),primaryIdentifier:o,secondaryIdentifier:c,optional:et(U(s?A(i,28,42):A(i,28,35)))}}return null}function it(e,t=j.today()){let n=Xe(e,t),r=n.format??null,i=r==="TD1"||r==="TD2"||r==="TD3"?Ye(e,r):[...e];return{format:r,documentCode:n.documentCode??null,lines:i,valid:n.success&&!n.hardCdFail}}var Zt=/^[A-Z0-9<]{25,}$/;function Xt(e){return e.toUpperCase().replaceAll(" ","").replaceAll("\xAB","<").replaceAll("\u2039","<")}var Te=(e,t,n)=>e.length>=t&&e.length<=n;function st(e){let t=e.map(Xt).filter(n=>Zt.test(n));for(let n=0;n+3<=t.length;n++){let r=t.slice(n,n+3);if(r.every(i=>Te(i,28,32))&&"IAC".includes(r[0][0]))return r}for(let n=0;n+2<=t.length;n++){let r=t.slice(n,n+2);if(r.every(i=>Te(i,40,46))&&r[0].startsWith("P")||r.every(i=>Te(i,34,38))&&"IACPV".includes(r[0][0]))return r}return[]}var ne={SIZE:80,SCRIPT:64,OFFSET:68,STEPS:72},C={DETECTOR:0,LATIN:1,ARABIC:2},F={NONE:0,LATIN:1,ARABIC:2,BOTH:3},oe=3;var X=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function at(e,t,n,r,i){let s=i.now??(()=>performance.now()),o=s(),a=e.read(t,n,r,i.region??[0,0,1,1],1,oe,F.LATIN,i.detectorLimit).map(u=>({text:u.latin.text,score:u.latin.score,box:[0,1,2,3].map(S=>({x:u.box[2*S],y:u.box[2*S+1]}))})),d=Be([...a].reverse()),p=d.map(u=>u.text),f=[...rt(p.join(`
38
+ `))?.mrzLines??st(p)],g=d.map(u=>[X(u.x/n),X(u.y/r),X((u.x2-u.x)/n),X((u.y2-u.y)/r)]),b={kind:"band",ms:0,lineBoxes:g,lineCount:f.length,valid:!1},l=Jt(d.map(u=>u.text),g,f);if(l!==null&&(b.mrzBox=l),f.length>0){let u=it(f,i.today??j.today());u.format&&(b.format=u.format),u.documentCode&&/^[A-Z<]{1,2}$/.test(u.documentCode)&&(b.documentCode=u.documentCode),u.valid&&(b.valid=!0,b.digest=await Ce(i.salt,u.lines))}return b.ms=Math.round(s()-o),b}var ot=e=>e.toUpperCase().replace(/\s+/g,"");function $t(e,t){let n=Math.max(e.length,t.length);if(n===0)return 0;let r=0;for(let i=0;i<Math.min(e.length,t.length);i++)e[i]===t[i]&&r++;return r/n}function Jt(e,t,n){if(n.length===0||e.length===0)return null;let r=new Set,i=[];for(let d of n){let p=-1,f=.5;if(e.forEach((g,b)=>{let l=r.has(b)?0:$t(ot(g),ot(d));l>f&&(f=l,p=b)}),p<0)return null;r.add(p),i.push(t[p])}let s=Math.min(...i.map(d=>d[0])),o=Math.min(...i.map(d=>d[1])),c=Math.max(...i.map(d=>d[0]+d[2])),a=Math.max(...i.map(d=>d[1]+d[3]));return[X(s),X(o),X(c-s),X(a-o)]}var wn=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function ct(e,t,n){let r=i=>Math.round(Math.min(1,Math.max(0,i))*1e4)/1e4;return e.map(i=>{let s=[i[0],i[2],i[4],i[6]],o=[i[1],i[3],i[5],i[7]],c=Math.min(...s),a=Math.min(...o);return[r(c/t),r(a/n),r((Math.max(...s)-c)/t),r((Math.max(...o)-a)/n)]}).sort((i,s)=>i[1]-s[1]||i[0]-s[0])}async function jt(e={}){var t,n=e,r=import.meta.url,i="",s,o;try{i=new URL(".",r).href}catch{}o=m=>{var h=new XMLHttpRequest;return h.open("GET",m,!1),h.responseType="arraybuffer",h.send(null),new Uint8Array(h.response)},s=async m=>{if(m=await fetch(m,{credentials:"same-origin"}),m.ok)return m.arrayBuffer();throw Error(m.status+" : "+m.url)};var c=console.log.bind(console),a=console.error.bind(console),d=!1,p,f,g,b,l,u=!1;function S(){var m=ce.buffer;new Int8Array(m),new Int16Array(m),n.HEAPU8=g=new Uint8Array(m),new Uint16Array(m),new Int32Array(m),b=new Uint32Array(m),new Float32Array(m),new Float64Array(m),l=new BigInt64Array(m),new BigUint64Array(m)}function R(m){throw m="Aborted("+m+")",a(m),d=!0,m+=". Build with -sASSERTIONS for more info.",u&&Q(),m=new WebAssembly.RuntimeError(m),f?.(m),m}var x;async function L(m){try{var h=await s(m);return new Uint8Array(h)}catch{}if(o)m=o(m);else throw"both async and sync fetching of the wasm failed";return m}async function w(m,h){try{var y=await L(m);return await WebAssembly.instantiate(y,h)}catch(N){a(`failed to asynchronously prepare wasm: ${N}`),R(N)}}async function K(m){var h=x;try{var y=fetch(h,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(y,m)}catch(N){a(`wasm streaming compile failed: ${N}`),a("falling back to ArrayBuffer instantiation")}return w(h,m)}var W={},V=()=>{if(!$){var m={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"},h;for(h in W)W[h]===void 0?delete m[h]:m[h]=W[h];var y=[];for(h in m)y.push(`${h}=${m[h]}`);$=y}return $},$,J=[null,[],[]],ae=globalThis.TextDecoder&&new TextDecoder,Q,ce,pt={i:()=>R(""),b:function(m,h,y){return 0<=m&&3>=m?(l[y>>3]=BigInt(Math.round(1e6*(m===0?Date.now():performance.now()))),0):28},d:()=>1073741824,c:m=>{var h=g.length;if(m>>>=0,1073741824<m)return!1;for(var y=1;4>=y;y*=2){var N=h*(1+.2/y);N=Math.min(N,m+100663296);e:{N=(Math.min(1073741824,65536*Math.ceil(Math.max(m,N)/65536))-ce.buffer.byteLength+65535)/65536|0;try{ce.grow(N),S();var _=1;break e}catch{}_=void 0}if(_)return!0}return!1},f:(m,h)=>{var y=0,N=0,_;for(_ of V()){var M=h+y;b[m+N>>2]=M;for(var q=_,D=g,re=M,G=M+1/0-1,T=0;T<q.length;++T){var E=q.codePointAt(T);if(127>=E){if(M>=G)break;D[M++]=E}else if(2047>=E){if(M+1>=G)break;D[M++]=192|E>>6,D[M++]=128|E&63}else if(65535>=E){if(M+2>=G)break;D[M++]=224|E>>12,D[M++]=128|E>>6&63,D[M++]=128|E&63}else{if(M+3>=G)break;D[M++]=240|E>>18,D[M++]=128|E>>12&63,D[M++]=128|E>>6&63,D[M++]=128|E&63,T++}}D[M]=0,q=M-re,y+=q+1,N+=4}return 0},g:(m,h)=>{var y=V();b[m>>2]=y.length,m=0;for(var N of y){for(var _=y=0;_<N.length;++_){var M=N.charCodeAt(_);127>=M?y++:2047>=M?y+=2:55296<=M&&57343>=M?(y+=4,++_):y+=3}m+=y+1}return b[h>>2]=m,0},j:()=>52,h:()=>52,e:function(){return 70},a:(m,h,y,N)=>{for(var _=0,M=0;M<y;M++){var q=b[h>>2],D=b[h+4>>2];h+=8;for(var re=0;re<D;re++){var G=m,T=g[q+re],E=J[G];if(T===0||T===10){G=G===1?c:a,T=E;for(var Y=0,ie=T,P=Y,O=P+void 0;ie[P]&&!(P>=O);)++P;if(ie=P,16<ie-Y&&T.buffer&&ae)T=ae.decode(T.subarray(Y,ie));else{for(P="";Y<ie;)if(O=T[Y++],O&128){var pe=T[Y++]&63;if((O&224)==192)P+=String.fromCharCode((O&31)<<6|pe);else{var Ee=T[Y++]&63;O=(O&240)==224?(O&15)<<12|pe<<6|Ee:(O&7)<<18|pe<<12|Ee<<6|T[Y++]&63,65536>O?P+=String.fromCharCode(O):(O-=65536,P+=String.fromCharCode(55296|O>>10,56320|O&1023))}}else P+=String.fromCharCode(O);T=P}G(T),E.length=0}else E.push(T)}_+=D}return b[N>>2]=_,0}},le;return le=await(async function(){function m(y){return y=le=y.exports,n._skw_engine_id=y.m,n._skw_load=y.n,n._skw_unload=y.o,n._skw_set_detector_limit=y.p,n._skw_read=y.q,n._skw_line_count=y.r,n._skw_lines=y.s,n._skw_best=y.t,n._skw_values=y.u,n._skw_sharpness=y.v,n._free=y.w,n._malloc=y.x,Q=y.y,ce=y.k,S(),le}var h={a:pt};return n.instantiateWasm?new Promise(y=>{n.instantiateWasm(h,(N,_)=>{y(m(N,_))})}):(x??(x=n.locateFile?n.locateFile?n.locateFile("sekyro-ocr.wasm",i):i+"sekyro-ocr.wasm":new URL("sekyro-ocr.wasm",import.meta.url).href),m((await K(h)).instance))})(),n.calledRun=!0,d||(u=!0,le.l(),p?.(n)),u?t=n:t=new Promise((m,h)=>{p=m,f=h}),t}var lt=jt;function ut(e){return e===1||e===5?new I("OCR_IMAGE_INVALID"):e===2?new I("OCR_ASSET_INVALID"):e===4?new I("OCR_CANCELLED"):e===6?new I("OCR_BUSY"):e===7?new I("OCR_UNAVAILABLE"):new I("OCR_INFERENCE_FAILED")}var me=class{constructor(t){this.m=t;this.px=0;this.pxBytes=0;this.dicts=[null,null,null];this.classes=[0,0,0];this.held=[[],[],[]];this.latinKind="latin";this.scripts=[null,null,null]}engineId(){let t=this.m._skw_engine_id(),n="";for(let r=t;this.m.HEAPU8[r]!==0&&r<t+64;r++)n+=String.fromCharCode(this.m.HEAPU8[r]);return n}put(t){let n=this.m._malloc(t.length);if(!n)throw new I("OCR_UNAVAILABLE");return this.m.HEAPU8.set(t,n),n}load(t,n,r,i,s={}){this.unload(t);let o=new Uint8Array(n),c=new Uint8Array(o.byteLength+1);c.set(o);let a=null,d=0,p=null;if(s.mrz===!0){if(t!==C.LATIN||i===void 0||!en(i)||s.script!==void 0)throw new I("OCR_ASSET_INVALID");a=ue(i),d=dt(i)}else if(t!==C.DETECTOR){if(p=s.script??(t===C.LATIN?ge:"arabic"),i===void 0||!we(p)||t===C.LATIN!=(p===ge))throw new I("OCR_ASSET_INVALID");d=De(p).classes,a=ve(i,d)}else if(i!==void 0||s.script!==void 0)throw new I("OCR_ASSET_INVALID");let f=new Uint8Array(r),g=this.put(c),b=this.put(f);this.held[t]=[g,b];let l=this.m._skw_load(t,g,c.length,b,f.byteLength,d);if(l!==0)throw this.unload(t),ut(l);this.dicts[t]=a,this.classes[t]=d,this.scripts[t]=p,t===C.LATIN&&(this.latinKind=s.mrz===!0?"mrz":"latin")}recognizer(){return this.loaded(C.LATIN)?this.latinKind:null}secondScript(){return this.loaded(C.ARABIC)?this.scripts[C.ARABIC]:null}unload(t){this.held[t].length&&this.m._skw_unload(t);for(let n of this.held[t])this.m._free(n);this.held[t]=[],this.dicts[t]=null,this.scripts[t]=null}loaded(t){return this.held[t].length>0}pixels(t){if(t.length>this.pxBytes){if(this.px&&this.m._free(this.px),this.px=this.m._malloc(t.length),!this.px)throw new I("OCR_UNAVAILABLE");this.pxBytes=t.length}return this.m.HEAPU8.set(t,this.px),this.px}sharpness(t,n,r){let i=this.m._skw_sharpness(this.pixels(t),n,r);return i>=0&&Number.isFinite(i)?i:null}read(t,n,r,i,s,o,c,a){if(!Qt(c))throw new I("OCR_IMAGE_INVALID");if(c&F.LATIN&&!this.dicts[C.LATIN]||c&F.ARABIC&&!this.dicts[C.ARABIC]||!this.loaded(0))throw new I("OCR_UNAVAILABLE");let d=this.pixels(t);this.m._skw_set_detector_limit(a);let p=this.m._skw_read(d,n,r,i[0],i[1],i[2],i[3],s,o,c);if(p!==0)throw ut(p);let f=this.m._skw_line_count(),g=this.m.HEAPU8.buffer,b=new DataView(g,this.m._skw_lines(),f*ne.SIZE),l=new Int32Array(g,this.m._skw_best()),u=new Float32Array(g,this.m._skw_values()),S=[];for(let R=0;R<f;R++){let x=R*ne.SIZE,L=b.getInt32(x+ne.SCRIPT,!0),w=b.getInt32(x+ne.OFFSET,!0),K=b.getInt32(x+ne.STEPS,!0);if(c===F.NONE){S.push({box:Array.from({length:8},(ae,Q)=>b.getFloat64(x+8*Q,!0))});continue}let W=this.dicts[L];if(!W)throw new I("OCR_INFERENCE_FAILED");let V=Le(l.subarray(w,w+K),u.subarray(w,w+K),this.classes[L],W,!1),$=Array.from({length:8},(ae,Q)=>b.getFloat64(x+8*Q,!0)),J=S[S.length-1];L===C.ARABIC&&J&&J.arabic===void 0&&J.latin!==void 0&&qt(J.box,$)?J.arabic=V:S.push(L===C.ARABIC?{box:$,arabic:V}:{box:$,latin:V})}return S}heapBytes(){return this.m.HEAPU8.length}dispose(){for(let t of[0,1,2])this.unload(t);this.px&&this.m._free(this.px),this.px=0,this.pxBytes=0}};function dt(e){return(e.endsWith(`
40
39
  `)?e.slice(0,-1):e).split(`
41
- `).length+2}var Zt=e=>Number.isInteger(e)&&e>=U.NONE&&e<=U.BOTH,Xt=(e,t)=>e.every((n,s)=>n===t[s]);function $t(e){let t=e.split(`
42
- `);return t.length===37&&new Set(t).size===37&&t.every(n=>/^[0-9A-Z<]$/.test(n))&&at(e)===39}async function lt(e){let t=await ot({instantiateWasm:(n,s)=>(WebAssembly.instantiate(e,n).then(r=>s(r,e)),{})});return new fe(t)}function Jt(){let e=null,t=null;return(n,s)=>{if(typeof OffscreenCanvas!="function"||(e||(e=new OffscreenCanvas(n,s),t=e.getContext("2d",{willReadFrequently:!0})),!t))return null;(e.width!==n||e.height!==s)&&(e.width=n,e.height=s);let r=t;return{draw(o){return r.clearRect(0,0,n,s),r.drawImage(o,0,0),r.getImageData(0,0,n,s).data}}}}function jt(){return{fetch:(...e)=>fetch(...e),now:()=>performance.now(),canvas:Jt(),instantiate:lt}}function Qt(e,t=jt()){let n=null,s="",r=960,o=0,i=!1,l=Promise.resolve(),a=m=>e.postMessage(m);async function d(m){if(t.canvas(1,1)===null)return a({id:m.id,kind:"failed",reason:"unsupported"});s=m.salt,r=m.detectorLimit;try{let u=await Te(m.baseUrl,_e,m.maxDownloadMs,t.fetch,t.now);o=u.downloadMs,i=u.cached;let R=await WebAssembly.compile(u.files.get("sekyro-ocr.wasm")),S=await t.instantiate(R),A=new TextDecoder("utf-8",{fatal:!0}).decode(u.files.get("mrz_dict.txt"));S.load(L.DETECTOR,u.files.get("det.param"),u.files.get("det.bin")),S.load(L.LATIN,u.files.get("mrz-rec.param"),u.files.get("mrz-rec.bin"),A,{mrz:!0}),u.files.clear(),n=S,a({id:m.id,kind:"ready",warmupMs:0,downloadMs:o,cached:i})}catch(u){a({id:m.id,kind:"failed",reason:u instanceof G?u.reason:"error"})}}async function b(m,u,R,S){if(!n)return u.close(),a({id:m,kind:"error",code:"not_ready"});let A=u.width,w=u.height,B=t.canvas(A,w);if(!B)return u.close(),a({id:m,kind:"failed",reason:"unsupported"});let z=B.draw(u);u.close();try{a({id:m,...await Ce(n,z,A,w,{detectorLimit:S,salt:s,region:R,now:t.now})})}catch{a({id:m,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function f(m,u,R){if(!n)return u.close(),a({id:m,kind:"error",code:"not_ready"});let S=u.width,A=u.height,w=t.canvas(S,A);if(!w)return u.close(),a({id:m,kind:"failed",reason:"unsupported"});let B=w.draw(u);u.close();try{let z=t.now(),H=n.read(B,S,A,[0,0,1,1],1,de,U.NONE,R);a({id:m,kind:"layout",ms:Math.round(t.now()-z),lineBoxes:st(H.map(W=>W.box),S,A)})}catch{a({id:m,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function p(m){if(!n)return a({id:m,kind:"error",code:"not_ready"});let u=t.now(),R=960,S=200,A=new Uint8Array(R*S*4).fill(255);try{await Ce(n,A,R,S,{detectorLimit:r,salt:s,now:t.now})}catch{return a({id:m,kind:"error",code:"OCR_INFERENCE_FAILED"})}a({id:m,kind:"ready",warmupMs:Math.round(t.now()-u),downloadMs:o,cached:i})}async function y(m){switch(m.kind){case"init":return d(m);case"warmup":return p(m.id);case"band":return b(m.id,m.bitmap,void 0,m.detectorLimit);case"still":return b(m.id,m.bitmap,m.region,m.detectorLimit);case"layout":return f(m.id,m.bitmap,m.detectorLimit);case"dispose":n?.dispose(),n=null,e.close();return}}e.onmessage=m=>{let u=m.data;l=l.then(()=>y(u)).catch(()=>a({id:u.id,kind:"error",code:"OCR_INFERENCE_FAILED"}))}}typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&Qt(self);export{jt as defaultDeps,Qt as installOcrWorkerHost};
40
+ `).length+2}var Qt=e=>Number.isInteger(e)&&e>=F.NONE&&e<=F.BOTH,qt=(e,t)=>e.every((n,r)=>n===t[r]);function en(e){let t=e.split(`
41
+ `);return t.length===37&&new Set(t).size===37&&t.every(n=>/^[0-9A-Z<]$/.test(n))&&dt(e)===39}async function ft(e){let t=await lt({instantiateWasm:(n,r)=>(WebAssembly.instantiate(e,n).then(i=>r(i,e)),{})});return new me(t)}var Hn=Object.freeze({low:Object.freeze({stride:1,bandWidthPx:960}),mid:Object.freeze({stride:2,bandWidthPx:1280}),high:Object.freeze({stride:1,bandWidthPx:1280})});function mt(){let n=new Uint8Array(1228800).fill(255),r=24301,i=()=>(r=r*1103515245+12345&2147483647,r/2147483647),s=(d,p)=>{let f=(p*960+d)*4;n[f]=20,n[f+1]=20,n[f+2]=20},o=20,c=14,a=28;for(let d of[110,190])for(let p=0;p<44;p++){let f=40+p*o;if(i()<.25){for(let b=0;b<c/2;b++)for(let l=0;l<2;l++)s(f+c/2-b,d+a/2-b+l),s(f+c/2-b,d+a/2+b+l);continue}let g=Math.floor(i()*(c-3));for(let b=0;b<a;b++)for(let l=0;l<3;l++)s(f+g+l,d+b);for(let b of[0,a/2-1,a-3])if(!(i()<.4))for(let l=0;l<c;l++)for(let u=0;u<3;u++)s(f+l,d+b+u)}return{rgba:n,width:960,height:320}}function tn(){let e=null,t=null;return(n,r)=>{if(typeof OffscreenCanvas!="function"||(e||(e=new OffscreenCanvas(n,r),t=e.getContext("2d",{willReadFrequently:!0})),!t))return null;(e.width!==n||e.height!==r)&&(e.width=n,e.height=r);let i=t;return{draw(s){return i.clearRect(0,0,n,r),i.drawImage(s,0,0),i.getImageData(0,0,n,r).data}}}}function nn(){return{fetch:(...e)=>fetch(...e),now:()=>performance.now(),canvas:tn(),instantiate:ft}}function rn(e,t=nn()){let n=null,r="",i=960,s=0,o=!1,c=Promise.resolve(),a=l=>e.postMessage(l);async function d(l){if(t.canvas(1,1)===null)return a({id:l.id,kind:"failed",reason:"unsupported"});r=l.salt,i=l.detectorLimit;try{let u=await Oe(l.baseUrl,_e,l.maxDownloadMs,t.fetch,t.now);s=u.downloadMs,o=u.cached;let S=await WebAssembly.compile(u.files.get("sekyro-ocr.wasm")),R=await t.instantiate(S),x=new TextDecoder("utf-8",{fatal:!0}).decode(u.files.get("mrz_dict.txt"));R.load(C.DETECTOR,u.files.get("det.param"),u.files.get("det.bin")),R.load(C.LATIN,u.files.get("mrz-rec.param"),u.files.get("mrz-rec.bin"),x,{mrz:!0}),u.files.clear(),n=R,a({id:l.id,kind:"ready",warmupMs:0,downloadMs:s,cached:o})}catch(u){a({id:l.id,kind:"failed",reason:u instanceof z?u.reason:"error"})}}async function p(l,u,S,R){if(!n)return u.close(),a({id:l,kind:"error",code:"not_ready"});let x=u.width,L=u.height,w=t.canvas(x,L);if(!w)return u.close(),a({id:l,kind:"failed",reason:"unsupported"});let K=w.draw(u);u.close();try{a({id:l,...await at(n,K,x,L,{detectorLimit:R,salt:r,region:S,now:t.now})})}catch{a({id:l,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function f(l,u,S){if(!n)return u.close(),a({id:l,kind:"error",code:"not_ready"});let R=u.width,x=u.height,L=t.canvas(R,x);if(!L)return u.close(),a({id:l,kind:"failed",reason:"unsupported"});let w=L.draw(u);u.close();try{let K=t.now(),W=n.read(w,R,x,[0,0,1,1],1,oe,F.NONE,S);a({id:l,kind:"layout",ms:Math.round(t.now()-K),lineBoxes:ct(W.map(V=>V.box),R,x)})}catch{a({id:l,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function g(l){if(!n)return a({id:l,kind:"error",code:"not_ready"});let u=mt(),S=()=>n.read(u.rgba,u.width,u.height,[0,0,1,1],1,oe,F.LATIN,960),R,x;try{let L=t.now();S();let w=t.now();S(),R=Math.round(w-L),x=Math.round(t.now()-w)}catch{return a({id:l,kind:"error",code:"OCR_INFERENCE_FAILED"})}a({id:l,kind:"ready",warmupMs:R,benchMs:x,downloadMs:s,cached:o})}async function b(l){switch(l.kind){case"init":return d(l);case"warmup":return g(l.id);case"band":return p(l.id,l.bitmap,void 0,l.detectorLimit);case"still":return p(l.id,l.bitmap,l.region,l.detectorLimit);case"layout":return f(l.id,l.bitmap,l.detectorLimit);case"dispose":n?.dispose(),n=null,e.close();return}}e.onmessage=l=>{let u=l.data;c=c.then(()=>b(u)).catch(()=>a({id:u.id,kind:"error",code:"OCR_INFERENCE_FAILED"}))}}typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&rn(self);export{nn as defaultDeps,rn as installOcrWorkerHost};
@@ -1,6 +1,7 @@
1
- "use strict";var be=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var pt=Object.prototype.hasOwnProperty;var yt=(e,t)=>{for(var n in t)be(e,n,{get:t[n],enumerable:!0})},ht=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of gt(t))!pt.call(e,r)&&r!==n&&be(e,r,{get:()=>t[r],enumerable:!(s=bt(t,r))||s.enumerable});return e};var At=e=>ht(be({},"__esModule",{value:!0}),e);var ln={};yt(ln,{defaultDeps:()=>dt,installOcrWorkerHost:()=>ft});module.exports=At(ln);var Y={fp12:"08390000c48a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro-ocr.wasm":{bytes:3550608,sha256:"c15968a6de3d2225e2fdbf36d71a9214c2910419056c6878444fd2d0567bb748",tier:"live",contentType:"application/wasm"},"sekyro-ocr.mjs":{bytes:4270,sha256:"209a78d96ca53344996a0c2300aed4ff8a5c69e142713216975a2840eec08cac",tier:"bundled",contentType:"text/javascript"},"det.param":{bytes:24252,sha256:"c39ba0b1195e8ad37cfc5bdd7acedcfc1d9cb901e7b8eb1c9c4f6e5a66c04eb3",tier:"live",contentType:"text/plain"},"det.bin":{bytes:4685856,sha256:"652bafe366565109a1a5766caf482bc46f01481f8044d3a785bd9a1be67c63bb",tier:"live",contentType:"application/octet-stream"},"mrz-rec.param":{bytes:3510,sha256:"bc69b1b9683e35f6605b21001fadeb81468063459c00c0fc83c67c139f23df01",tier:"live",contentType:"text/plain"},"mrz-rec.bin":{bytes:494196,sha256:"de93a2aa2f08670cc7dedd17ba378d2f5d7cf6ae409054a9eac863a02c2febae",tier:"live",contentType:"application/octet-stream"},"mrz_dict.txt":{bytes:73,sha256:"b19858a4de2ccbbbdd4b53982188ea2c7664013183bbd1ae9d20ab52c661f97f",tier:"live",contentType:"text/plain"},"latin-rec.param":{bytes:19602,sha256:"2ae30dfdc7ee482c6cbbc0419c16ee125e880e9eaf69053d61953694bb0fcf4c",tier:"lazy",contentType:"text/plain"},"latin-rec.bin":{bytes:10750388,sha256:"f91ebdcf4d6b58c58a87704160e59d07ae56bc2d5021eae09d095c5a20bf7525",tier:"lazy",contentType:"application/octet-stream"},"ppocr_keys_v1.txt":{bytes:26249,sha256:"28b2362ad4ab2dc38769aa72feb535e3a9ddb3fd2a7585a05920e6393b1dc7f7",tier:"lazy",contentType:"text/plain"},"arabic-rec.param":{bytes:9858,sha256:"4e5cc85667dfaaa0c67d3f308400645a578c08bd43f952cab6c55b7bce143ea9",tier:"lazy",contentType:"text/plain"},"arabic-rec.bin":{bytes:8853572,sha256:"5acc3265a1738dc31316258383830d5dbdfa5e8ebc2e710f9001f832ecfbffb0",tier:"lazy",contentType:"application/octet-stream"},"arabic_dict.txt":{bytes:405,sha256:"637c27c88512c22089bef927b34ada08f748dc132ac70facd68d8202384c2726",tier:"lazy",contentType:"text/plain"}}};var xt="sekyro-mrz-1";function Mt(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}async function ge(e){return Mt(await crypto.subtle.digest("SHA-256",e))}function _e(e,t){return ge(new TextEncoder().encode(`${xt}\0${e}\0${t.join(`
2
- `)}`))}var G=class extends Error{constructor(t){super(t),this.name="AssetFailure",this.reason=t}},Te=Object.keys(Y.files).filter(e=>Y.files[e].tier==="live"),bn=Object.keys(Y.files).filter(e=>Y.files[e].tier==="lazy");function Rt(e,t){return`${e.replace(/\/+$/,"")}/${Y.fp12}/${t}`}async function St(e,t,n,s=fetch,r=()=>performance.now()){let o=Y.files[t],i=r(),l=async b=>{try{let f=await s(Rt(e,t),{cache:b,signal:n,credentials:"omit"});if(!f.ok)throw new G("download");return await f.arrayBuffer()}catch(f){throw f instanceof G?f:new G("download")}},a=async b=>b.byteLength===o.bytes&&await ge(b)===o.sha256,d=await l("force-cache");if(!await a(d)&&(d=await l("reload"),!await a(d)))throw new G("integrity");return{bytes:d,ms:r()-i}}async function Oe(e,t,n,s=fetch,r=()=>performance.now()){let o=new AbortController,i=new Map,l=t.reduce((f,p)=>f+Y.files[p].bytes,0),a=r(),d=!0,b=0;for(let f of t){let p=await St(e,f,o.signal,s,r);i.set(f,p.bytes),p.ms>=50&&(d=!1),b+=p.bytes.byteLength;let y=r()-a;if(b<l&&y>0&&y*l/b>n)throw o.abort(),new G("download")}return{files:i,downloadMs:Math.round(r()-a),cached:d}}var I=class extends Error{constructor(t){super(t),this.name="OcrFailure",this.code=t}};function Le(e){return[...e.split(`
3
- `)," "]}function we(e,t,n,s,r){if(n<2||e.length===0||e.length!==t.length||s.length<n-1)throw new I("OCR_INFERENCE_FAILED");let o="",i=-1,l=0,a=0;for(let b=0;b<e.length;b++){let f=e[b];if(!Number.isInteger(f)||f<0||f>=n)throw new I("OCR_INFERENCE_FAILED");f!==0&&f!==i&&(o+=s[f-1],l+=Math.fround(t[b]),a++),i=f}return{text:r?Array.from(o).reverse().join(""):o,score:a===0?0:l/a}}var De=e=>e.reduce((t,n)=>t+n,0)/e.length;function ke(e){let t=e.filter(r=>r.score>=.5);if(t.length===0)return[];if(t.some(r=>r.box.length!==4||!Number.isFinite(r.score)||r.box.some(o=>!Number.isFinite(o.x)||!Number.isFinite(o.y))))throw new I("OCR_INFERENCE_FAILED");let n=De(t.map(r=>r.box[2].y-r.box[0].y)),s=[];for(let r of t){let o=(r.box[0].y+r.box[2].y)/2,i=s.find(l=>Math.abs((l[0].box[0].y+l[0].box[2].y)/2-o)<n/2);i===void 0?s.push([r]):i.push(r)}for(let r of s)r.sort((o,i)=>o.box[0].x-i.box[0].x);return s.sort((r,o)=>r[0].box[0].y-o[0].box[0].y),s.map(r=>{let o=r[0].box,i=r[r.length-1].box,l=[o[0],i[1],i[2],o[3]];return{text:r.map(a=>a.text).join(" "),x:Math.min(...l.map(a=>a.x)),y:Math.min(...l.map(a=>a.y)),x2:Math.max(...l.map(a=>a.x)),y2:Math.max(...l.map(a=>a.y)),score:De(r.map(a=>a.score))}})}var j={of(e,t,n){return!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||t<1||t>12||n<1||n>new Date(Date.UTC(e,t,0)).getUTCDate()?null:{year:e,month:t,day:n}},iso(e){return`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`},parse(e){let[t,n,s]=e.split("-").map(Number);return{year:t,month:n,day:s}},today(){let e=new Date;return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}}},Pe=30,Ue=36,Fe=44,pe="MRT",It=[7,3,1],Ct=/^[0-9]{6}$/,he=/^[0-9]{10}$/,Ge=e=>e!==void 0&&e.length===1&&e>="0"&&e<="9";function Et(e){return e>="0"&&e<="9"?e.charCodeAt(0)-48:e>="A"&&e<="Z"?e.charCodeAt(0)-55:0}function ue(e){let t=0;for(let n=0;n<e.length;n++)t+=Et(e[n])*It[n%3];return String(t%10)}function D(e,t){return t==="<"?null:Ge(t)?ue(e)===t:!1}function ce(e){return e.trim().toUpperCase().replaceAll(" ","")}function Nt(e,t){return(ce(e)+"<".repeat(t)).slice(0,t)}function k(e){return e.replace(/^<+|<+$/g,"")}var _t=new Set(`ABW AFG AGO AIA ALA ALB AND ARE ARG ARM ASM ATA ATF ATG AUS AUT AZE BDI BEL BEN BES BFA BGD BGR BHR
1
+ "use strict";var be=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Mt=Object.prototype.hasOwnProperty;var St=(e,t)=>{for(var n in t)be(e,n,{get:t[n],enumerable:!0})},Rt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of At(t))!Mt.call(e,r)&&r!==n&&be(e,r,{get:()=>t[r],enumerable:!(i=xt(t,r))||i.enumerable});return e};var It=e=>Rt(be({},"__esModule",{value:!0}),e);var mn={};St(mn,{defaultDeps:()=>gt,installOcrWorkerHost:()=>yt});module.exports=It(mn);var k={fp12:"936b9c4ccc4a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro-ocr.wasm":{bytes:3550687,sha256:"00d6b1a4e42da8146e662ab0283b97485397811acc806299046933ce1943fb09",tier:"live",contentType:"application/wasm"},"sekyro-ocr.mjs":{bytes:4270,sha256:"209a78d96ca53344996a0c2300aed4ff8a5c69e142713216975a2840eec08cac",tier:"bundled",contentType:"text/javascript"},"det.param":{bytes:24252,sha256:"c39ba0b1195e8ad37cfc5bdd7acedcfc1d9cb901e7b8eb1c9c4f6e5a66c04eb3",tier:"live",contentType:"text/plain"},"det.bin":{bytes:4685856,sha256:"652bafe366565109a1a5766caf482bc46f01481f8044d3a785bd9a1be67c63bb",tier:"live",contentType:"application/octet-stream"},"mrz-rec.param":{bytes:3510,sha256:"bc69b1b9683e35f6605b21001fadeb81468063459c00c0fc83c67c139f23df01",tier:"live",contentType:"text/plain"},"mrz-rec.bin":{bytes:494196,sha256:"de93a2aa2f08670cc7dedd17ba378d2f5d7cf6ae409054a9eac863a02c2febae",tier:"live",contentType:"application/octet-stream"},"mrz_dict.txt":{bytes:73,sha256:"b19858a4de2ccbbbdd4b53982188ea2c7664013183bbd1ae9d20ab52c661f97f",tier:"live",contentType:"text/plain"},"v5-latin-fp16.param":{bytes:19800,sha256:"843964335e9863681bb17d876c69e7315844e0850e3c04f91b11a3f0c2a57bc6",tier:"lazy",group:"latin",contentType:"text/plain"},"v5-latin-fp16.bin":{bytes:3995900,sha256:"0516474d30cff75a6365869992699d27fbc03f00fcf3d7274c3eed651ee6ea90",tier:"lazy",group:"latin",contentType:"application/octet-stream"},"latin.dict.txt":{bytes:2615,sha256:"c3ab00106e4a4d151a8575b1129b91901a68a35b79a81fd63faab00418b87d75",tier:"lazy",group:"latin",contentType:"text/plain"},"v5-arabic-fp16.param":{bytes:19791,sha256:"1d1e219d277bb1a76909741573f56cfae465f11b61a9be4ca4c29580758c8760",tier:"lazy",group:"arabic",contentType:"text/plain"},"v5-arabic-fp16.bin":{bytes:3974364,sha256:"4ced47b32ab4e7ad16ddebc074f31594eb42b912465a8ed7458bb2842af9efe1",tier:"lazy",group:"arabic",contentType:"application/octet-stream"},"arabic.dict.txt":{bytes:2368,sha256:"8f239c13f6c8b1bdf15f332a65a05002ddd4d99b9286a4bfaf6f0327c36ebbec",tier:"lazy",group:"arabic",contentType:"text/plain"},"v5-cyrillic-fp16.param":{bytes:19806,sha256:"c87b42bfa343509b319dd193dcca4c0e20bb13b1d07bfbf4925a9f5d045966d4",tier:"lazy",group:"cyrillic",contentType:"text/plain"},"v5-cyrillic-fp16.bin":{bytes:3999288,sha256:"97446e221c0d2d84cb76dca6d4217a850efad4d5ec85e3fadc78db353cf97afa",tier:"lazy",group:"cyrillic",contentType:"application/octet-stream"},"cyrillic.dict.txt":{bytes:2780,sha256:"2de016b31edd687acfc1bf72170f4feff9f0c4893edac87cef30b2c5a82443ec",tier:"lazy",group:"cyrillic",contentType:"text/plain"},"v5-greek-fp16.param":{bytes:19815,sha256:"1cc1d47d3aa3fce86d3dbe901a553fd29412f44934a4919d986c155d23f63207",tier:"lazy",group:"greek",contentType:"text/plain"},"v5-greek-fp16.bin":{bytes:3879256,sha256:"04190cd4ee2b023665346d4cd239ee118965f837812108869d3d9894d30c4db3",tier:"lazy",group:"greek",contentType:"application/octet-stream"},"greek.dict.txt":{bytes:1102,sha256:"60e017885fd98fd0fb5c402da86179f1fe24ae229b374b3b96d313f99a09de59",tier:"lazy",group:"greek",contentType:"text/plain"},"v5-devanagari-fp16.param":{bytes:19807,sha256:"c6540a818cbb46c5b511dc4dd20ebfeae9038ec64e5cf175cd2d25f1b9f95c51",tier:"lazy",group:"devanagari",contentType:"text/plain"},"v5-devanagari-fp16.bin":{bytes:3931044,sha256:"d3086391eb2298c4d4e5a6d20a7fc58a8d0f3ce0a12395c88e9d485c5d595828",tier:"lazy",group:"devanagari",contentType:"application/octet-stream"},"devanagari.dict.txt":{bytes:1942,sha256:"c66d17ef6ced6fbfb4413810e75f0f788cfde37d4192bd17af7923fa190066c8",tier:"lazy",group:"devanagari",contentType:"text/plain"},"v5-thai-fp16.param":{bytes:19786,sha256:"4422df9dcc960e42082166adcca42da2aa6df62abebc75daf0c887e89381c039",tier:"lazy",group:"thai",contentType:"text/plain"},"v5-thai-fp16.bin":{bytes:3920396,sha256:"3458d7c5f0a7f88cb804d084c6596dea3f67c5ea99082654938d71a4eb72a079",tier:"lazy",group:"thai",contentType:"application/octet-stream"},"thai.dict.txt":{bytes:1766,sha256:"e0f32101004cc828ed4505bba80126be06e282700c4c79175ed2b21a4d454dfa",tier:"lazy",group:"thai",contentType:"text/plain"},"v5-hangul-fp16.param":{bytes:19804,sha256:"8daec1a4aa09d3bc92a476438330921c910263b8e61d62334d79e2d1dd14247c",tier:"lazy",group:"hangul",contentType:"text/plain"},"v5-hangul-fp16.bin":{bytes:6684280,sha256:"1d38192b59765cf71c1909ea4b972ee3c8588537a53844e6830f57fbf47976a4",tier:"lazy",group:"hangul",contentType:"application/octet-stream"},"hangul.dict.txt":{bytes:47450,sha256:"a7872c929cd25cf615cdfea08579cf800db1943900fe683468df4dcff6f848bb",tier:"lazy",group:"hangul",contentType:"text/plain"}},scripts:{latin:{classes:838,rtl:!1,param:"v5-latin-fp16.param",bin:"v5-latin-fp16.bin",dict:"latin.dict.txt"},arabic:{classes:749,rtl:!0,param:"v5-arabic-fp16.param",bin:"v5-arabic-fp16.bin",dict:"arabic.dict.txt"},cyrillic:{classes:852,rtl:!1,param:"v5-cyrillic-fp16.param",bin:"v5-cyrillic-fp16.bin",dict:"cyrillic.dict.txt"},greek:{classes:356,rtl:!1,param:"v5-greek-fp16.param",bin:"v5-greek-fp16.bin",dict:"greek.dict.txt"},devanagari:{classes:570,rtl:!1,param:"v5-devanagari-fp16.param",bin:"v5-devanagari-fp16.bin",dict:"devanagari.dict.txt"},thai:{classes:526,rtl:!1,param:"v5-thai-fp16.param",bin:"v5-thai-fp16.bin",dict:"thai.dict.txt"},hangul:{classes:11947,rtl:!1,param:"v5-hangul-fp16.param",bin:"v5-hangul-fp16.bin",dict:"hangul.dict.txt"}}};var Nt="sekyro-mrz-1";function Tt(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}async function ge(e){return Tt(await crypto.subtle.digest("SHA-256",e))}function _e(e,t){return ge(new TextEncoder().encode(`${Nt}\0${e}\0${t.join(`
2
+ `)}`))}var z=class extends Error{constructor(t){super(t),this.name="AssetFailure",this.reason=t}},Oe=Object.keys(k.files).filter(e=>k.files[e].tier==="live"),xn=Object.keys(k.files).filter(e=>k.files[e].tier==="lazy");function Et(e,t){return`${e.replace(/\/+$/,"")}/${k.fp12}/${t}`}async function Ct(e,t,n,i=fetch,r=()=>performance.now()){let s=k.files[t],o=r(),c=async p=>{try{let f=await i(Et(e,t),{cache:p,signal:n,credentials:"omit"});if(!f.ok)throw new z("download");return await f.arrayBuffer()}catch(f){throw f instanceof z?f:new z("download")}},a=async p=>p.byteLength===s.bytes&&await ge(p)===s.sha256,d=await c("force-cache");if(!await a(d)&&(d=await c("reload"),!await a(d)))throw new z("integrity");return{bytes:d,ms:r()-o}}async function Le(e,t,n,i=fetch,r=()=>performance.now()){let s=new AbortController,o=new Map,c=t.reduce((f,g)=>f+k.files[g].bytes,0),a=r(),d=!0,p=0;for(let f of t){let g=await Ct(e,f,s.signal,i,r);o.set(f,g.bytes),g.ms>=50&&(d=!1),p+=g.bytes.byteLength;let b=r()-a;if(p<c&&b>0&&b*c/p>n)throw s.abort(),new z("download")}return{files:o,downloadMs:Math.round(r()-a),cached:d}}var I=class extends Error{constructor(t){super(t),this.name="OcrFailure",this.code=t}};function ue(e){return[...e.split(`
3
+ `)," "]}function we(e,t,n,i,r){if(n<2||e.length===0||e.length!==t.length||i.length<n-1)throw new I("OCR_INFERENCE_FAILED");let s="",o=-1,c=0,a=0;for(let p=0;p<e.length;p++){let f=e[p];if(!Number.isInteger(f)||f<0||f>=n)throw new I("OCR_INFERENCE_FAILED");f!==0&&f!==o&&(s+=i[f-1],c+=Math.fround(t[p]),a++),o=f}return{text:r?Array.from(s).reverse().join(""):s,score:a===0?0:c/a}}var ye="latin",In=Object.keys(k.scripts);function De(e){return Object.prototype.hasOwnProperty.call(k.scripts,e)}function ve(e){let t=k.scripts[e];return{script:e,classes:t.classes,rtl:t.rtl,param:t.param,bin:t.bin,dict:t.dict}}function ke(e,t){let n=ue(e);if(e.endsWith(`
4
+ `)||n.length!==t-1)throw new I("OCR_ASSET_INVALID");return n}var Be=e=>e.reduce((t,n)=>t+n,0)/e.length;function Pe(e){let t=e.filter(r=>r.score>=.5);if(t.length===0)return[];if(t.some(r=>r.box.length!==4||!Number.isFinite(r.score)||r.box.some(s=>!Number.isFinite(s.x)||!Number.isFinite(s.y))))throw new I("OCR_INFERENCE_FAILED");let n=Be(t.map(r=>r.box[2].y-r.box[0].y)),i=[];for(let r of t){let s=(r.box[0].y+r.box[2].y)/2,o=i.find(c=>Math.abs((c[0].box[0].y+c[0].box[2].y)/2-s)<n/2);o===void 0?i.push([r]):o.push(r)}for(let r of i)r.sort((s,o)=>s.box[0].x-o.box[0].x);return i.sort((r,s)=>r[0].box[0].y-s[0].box[0].y),i.map(r=>{let s=r[0].box,o=r[r.length-1].box,c=[s[0],o[1],o[2],s[3]];return{text:r.map(a=>a.text).join(" "),x:Math.min(...c.map(a=>a.x)),y:Math.min(...c.map(a=>a.y)),x2:Math.max(...c.map(a=>a.x)),y2:Math.max(...c.map(a=>a.y)),score:Be(r.map(a=>a.score))}})}var j={of(e,t,n){return!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||t<1||t>12||n<1||n>new Date(Date.UTC(e,t,0)).getUTCDate()?null:{year:e,month:t,day:n}},iso(e){return`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`},parse(e){let[t,n,i]=e.split("-").map(Number);return{year:t,month:n,day:i}},today(){let e=new Date;return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}}},Ge=30,ze=36,He=44,he="MRT",_t=[7,3,1],Ot=/^[0-9]{6}$/,Ae=/^[0-9]{10}$/,Ke=e=>e!==void 0&&e.length===1&&e>="0"&&e<="9";function Lt(e){return e>="0"&&e<="9"?e.charCodeAt(0)-48:e>="A"&&e<="Z"?e.charCodeAt(0)-55:0}function fe(e){let t=0;for(let n=0;n<e.length;n++)t+=Lt(e[n])*_t[n%3];return String(t%10)}function v(e,t){return t==="<"?null:Ke(t)?fe(e)===t:!1}function de(e){return e.trim().toUpperCase().replaceAll(" ","")}function wt(e,t){return(de(e)+"<".repeat(t)).slice(0,t)}function B(e){return e.replace(/^<+|<+$/g,"")}var Dt=new Set(`ABW AFG AGO AIA ALA ALB AND ARE ARG ARM ASM ATA ATF ATG AUS AUT AZE BDI BEL BEN BES BFA BGD BGR BHR
4
5
  BHS BIH BLM BLR BLZ BMU BOL BRA BRB BRN BTN BVT BWA CAF CAN CCK CHE CHL CHN CIV CMR COD COG COK COL
5
6
  COM CPV CRI CUB CUW CXR CYM CYP CZE DEU DJI DMA DNK DOM DZA ECU EGY ERI ESH ESP EST ETH FIN FJI FLK
6
7
  FRA FRO FSM GAB GBR GEO GGY GHA GIB GIN GLP GMB GNB GNQ GRC GRD GRL GTM GUF GUM GUY HKG HMD HND HRV
@@ -9,8 +10,8 @@
9
10
  MNP MOZ MRT MSR MTQ MUS MWI MYS MYT NAM NCL NER NFK NGA NIC NIU NLD NOR NPL NRU NZL OMN PAK PAN PCN
10
11
  PER PHL PLW PNG POL PRI PRK PRT PRY PSE PYF QAT REU ROU RUS RWA SAU SDN SEN SGP SGS SHN SJM SLB SLE
11
12
  SLV SMR SOM SPM SRB SSD STP SUR SVK SVN SWE SWZ SXM SYC SYR TCA TCD TGO THA TJK TKL TKM TLS TON TTO
12
- TUN TUR TUV TWN TZA UGA UKR UMI URY USA UZB VAT VCT VEN VGB VIR VNM VUT WLF WSM XKK YEM ZAF ZMB ZWE`.trim().split(/\s+/)),Tt=new Set(`D GBD GBN GBO GBP GBS RKS UNK UNO UNA EUE XBA XIM XCC XCE XCO XDC XEC XES XMP XOM XPO XXA XXB XXC
13
- XXX ANT NTZ UTO`.trim().split(/\s+/));function Ot(e){return _t.has(e)||Tt.has(e)}var Lt="012568",wt="OIZSGB",Dt="OQDILZSGB",kt="000112568";function ye(e){let t=Lt.indexOf(e);return e.length!==1||t<0?e:wt[t]}function Bt(e){let t=Dt.indexOf(e);return e.length!==1||t<0?e:kt[t]}var vt=[["\xAB","<<"],["\u2039","<"],["\uFF1C","<"],["\u3008","<"],["\xD7","X"]],Ke=[`aaccc${"x".repeat(9)}n${"x".repeat(15)}`,`${"n".repeat(7)}x${"n".repeat(7)}ccc${"x".repeat(11)}n`,"a".repeat(30)],ze=[`aaccc${"a".repeat(31)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(7)}n`],He=[`aaccc${"a".repeat(39)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(14)}nn`];function Pt(e,t){let n="",s=0;for(;s<t.length;){let r=t[s];if(r==="c"){let i=e.substring(s,s+3),l=Array.from(i,ye).join("");n+=l!==i&&Ot(l.replaceAll("<",""))?l:i,s+=3;continue}let o=e[s];n+=r==="a"?ye(o):r==="n"?Bt(o):o,s++}return n}function ee(e,t,n){return n.slice(0,e.length).map((s,r)=>{let o=vt.reduce((i,[l,a])=>i.replaceAll(l,a),ce(e[r]));return Pt(Nt(o,t),s)})}function We(e,t){let n=e.filter(s=>s.trim().length>0);return t==="TD1"?ee(n.slice(0,3),Pe,Ke):t==="TD2"?ee(n.slice(0,2),Ue,ze):ee(n.slice(0,2),Fe,He)}function Ae(e){let t=`${e.toUpperCase()}<<`.slice(0,2);return t==="AC"?"unknown":t==="IR"||t==="AR"||t[0]==="A"||t[0]==="C"?"residence_permit":t[0]==="P"?"passport":t[0]==="I"?"carte_identite":"unknown"}function Ut(e){return he.test(e)&&Number(e)%97===1}function Ft(e,t,n){if(!Ct.test(e))return null;let s=Number(e.slice(0,2)),r=t?2e3+s:s>n.year%100?1900+s:2e3+s;return j.of(r,Number(e.slice(2,4)),Number(e.slice(4,6)))}function te(e,t,n){let s=Ft(e,t,n);return s?j.iso(s):""}function xe(e){let t=e.split("<<").filter(n=>k(n).length>0);return[(t[0]??"").replaceAll("<"," ").trim(),(t[1]??"").replaceAll("<"," ").trim()]}var Me=e=>e==="M"||e==="F"?e:"",Gt=e=>e.substring(0,2).replaceAll("<",""),oe=e=>e.substring(2,5).replaceAll("<","");function Ve(e,t,n){if(t==="<"&&k(n).length>0){let s=n.indexOf("<"),r=s<0?n:n.slice(0,s);if(r.length>=2){let o=e+r.slice(0,-1);if(D(o,r[r.length-1])===!0)return{value:k(o),ok:!0,warn:null}}return{value:k(e),ok:!1,warn:"docnum_cd_mismatch"}}return{value:k(e),ok:D(e,t),warn:null}}var K=(e,t)=>({success:!1,error:e,fields:{},checkDigits:{},hardCdFail:!1,warns:[],...t===void 0?{}:{linesCount:t}});function Re(e,t,n,s,r,o,i){return{success:!0,documentType:e,format:t,documentCode:Gt(n),fields:s,checkDigits:r,hardCdFail:o,warns:i}}function Kt(e,t){if(e.length<3)return K("mrz_incomplete");let[n,s,r]=ee(e.slice(0,3),Pe,Ke),o=oe(n)===pe||s.substring(15,18)===pe||Ut(n.substring(15,25)),i=[],l={},a,d,b=!1;if(o){a=k(n.substring(5,14));let A=n[14];Ge(A)?(d=ue(n.substring(5,14))===A,d||i.push("td1_docnum_cd_mismatch")):d=null}else{let A=Ve(n.substring(5,14),n[14],n.substring(15,30));if(A.ok===null)return K("mrz_incomplete");a=A.value,d=A.ok,b=A.ok===!1&&A.warn===null,A.warn!==null&&i.push(A.warn)}l.document_number=d;let f=D(s.substring(0,6),s[6]),p=D(s.substring(8,14),s[14]);if(l.birth_date=f,l.expiry_date=p,f===null||p===null)return K("mrz_incomplete");let y=D(n.substring(5,30)+s.substring(0,7)+s.substring(8,15)+s.substring(18,29),s[29]);l.composite=y,y===!1&&i.push("composite_cd_mismatch");let m=o?n.substring(15,25):"",[u,R]=xe(r),S=f===!1||p===!1||b;return Re(Ae(n.substring(0,2)),"TD1",n,{issuing_state:oe(n),document_number:a,nni:he.test(m)?m:"",birth_date:te(s.substring(0,6),!1,t),expiry_date:te(s.substring(8,14),!0,t),sex:Me(s[7]),nationality:k(s.substring(15,18)),surname:u,given_names:R},l,S,i)}function zt(e,t){if(e.length<2)return K("mrz_incomplete");let[n,s]=ee(e.slice(0,2),Ue,ze),r=[],o=Ve(s.substring(0,9),s[9],s.substring(28,35));o.warn!==null&&r.push(o.warn);let i=D(s.substring(13,19),s[19]),l=D(s.substring(21,27),s[27]),a={document_number:o.ok,birth_date:i,expiry_date:l};if(o.ok===null||i===null||l===null)return K("mrz_incomplete");let d=D(s.substring(0,10)+s.substring(13,20)+s.substring(21,35),s[35]);a.composite=d,d===!1&&r.push("composite_cd_mismatch");let[b,f]=xe(n.substring(5,36)),p=o.ok===!1&&o.warn===null||i===!1||l===!1;return Re(Ae(n.substring(0,2)),"TD2",n,{issuing_state:oe(n),document_number:o.value,nni:"",birth_date:te(s.substring(13,19),!1,t),expiry_date:te(s.substring(21,27),!0,t),sex:Me(s[20]),nationality:k(s.substring(10,13)),surname:b,given_names:f},a,p,r)}function Be(e,t){if(e.length<2)return K("mrz_incomplete");let[n,s]=ee(e.slice(0,2),Fe,He),r=oe(n)===pe,o=[],i={},l=s.substring(0,9),a=D(l,s[9]),d=D(s.substring(13,19),s[19]),b=D(s.substring(21,27),s[27]);if(i.document_number=a,i.birth_date=d,i.expiry_date=b,a===null||d===null||b===null)return K("mrz_incomplete");let f=s.substring(28,42),p="";if(k(f).length>0){let S=D(f,s[42]);i.personal_number=S;let A=k(f);r&&S!==!1&&he.test(A)&&(p=A)}let y=D(s.substring(0,10)+s.substring(13,20)+s.substring(21,43),s[43]);i.composite=y,y===!1&&o.push("composite_cd_mismatch");let[m,u]=xe(n.substring(5,44)),R=a===!1||d===!1||b===!1;return Re(Ae(n.substring(0,2)),"TD3",n,{issuing_state:oe(n),document_number:k(l),nni_candidate:p,birth_date:te(s.substring(13,19),!1,t),expiry_date:te(s.substring(21,27),!0,t),sex:Me(s[20]),nationality:k(s.substring(10,13)),surname:m,given_names:u},i,R,o)}var ve=new Set(["A","C","I"]);function Ye(e,t=j.today()){let n=e.filter(r=>r.trim().length>0);if(n.length===0)return K("mrz_unrecognized",0);let s=Array.from(ce(n[0]).slice(0,1),ye).join("");return n.length===3&&ve.has(s)?Kt(n,t):n.length===2&&s==="P"?Be(n,t):n.length===2&&ve.has(s)?Math.max(...n.map(r=>ce(r).length))>40?Be(n,t):zt(n,t):K("mrz_unrecognized",n.length)}var Ht=new Map([...(`ABWAW AFGAF AGOAO AIAAI ALAAX ALBAL ANDAD AREAE ARGAR ARMAM ASMAS ATAAQ
13
+ TUN TUR TUV TWN TZA UGA UKR UMI URY USA UZB VAT VCT VEN VGB VIR VNM VUT WLF WSM XKK YEM ZAF ZMB ZWE`.trim().split(/\s+/)),vt=new Set(`D GBD GBN GBO GBP GBS RKS UNK UNO UNA EUE XBA XIM XCC XCE XCO XDC XEC XES XMP XOM XPO XXA XXB XXC
14
+ XXX ANT NTZ UTO`.trim().split(/\s+/));function kt(e){return Dt.has(e)||vt.has(e)}var Bt="012568",Pt="OIZSGB",Ft="OQDILZSGB",Ut="000112568";function xe(e){let t=Bt.indexOf(e);return e.length!==1||t<0?e:Pt[t]}function Gt(e){let t=Ft.indexOf(e);return e.length!==1||t<0?e:Ut[t]}var zt=[["\xAB","<<"],["\u2039","<"],["\uFF1C","<"],["\u3008","<"],["\xD7","X"]],We=[`aaccc${"x".repeat(9)}n${"x".repeat(15)}`,`${"n".repeat(7)}x${"n".repeat(7)}ccc${"x".repeat(11)}n`,"a".repeat(30)],Ve=[`aaccc${"a".repeat(31)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(7)}n`],Ye=[`aaccc${"a".repeat(39)}`,`${"x".repeat(9)}nccc${"n".repeat(7)}x${"n".repeat(7)}${"x".repeat(14)}nn`];function Ht(e,t){let n="",i=0;for(;i<t.length;){let r=t[i];if(r==="c"){let o=e.substring(i,i+3),c=Array.from(o,xe).join("");n+=c!==o&&kt(c.replaceAll("<",""))?c:o,i+=3;continue}let s=e[i];n+=r==="a"?xe(s):r==="n"?Gt(s):s,i++}return n}function ee(e,t,n){return n.slice(0,e.length).map((i,r)=>{let s=zt.reduce((o,[c,a])=>o.replaceAll(c,a),de(e[r]));return Ht(wt(s,t),i)})}function Ze(e,t){let n=e.filter(i=>i.trim().length>0);return t==="TD1"?ee(n.slice(0,3),Ge,We):t==="TD2"?ee(n.slice(0,2),ze,Ve):ee(n.slice(0,2),He,Ye)}function Me(e){let t=`${e.toUpperCase()}<<`.slice(0,2);return t==="AC"?"unknown":t==="IR"||t==="AR"||t[0]==="A"||t[0]==="C"?"residence_permit":t[0]==="P"?"passport":t[0]==="I"?"carte_identite":"unknown"}function Kt(e){return Ae.test(e)&&Number(e)%97===1}function Wt(e,t,n){if(!Ot.test(e))return null;let i=Number(e.slice(0,2)),r=t?2e3+i:i>n.year%100?1900+i:2e3+i;return j.of(r,Number(e.slice(2,4)),Number(e.slice(4,6)))}function te(e,t,n){let i=Wt(e,t,n);return i?j.iso(i):""}function Se(e){let t=e.split("<<").filter(n=>B(n).length>0);return[(t[0]??"").replaceAll("<"," ").trim(),(t[1]??"").replaceAll("<"," ").trim()]}var Re=e=>e==="M"||e==="F"?e:"",Vt=e=>e.substring(0,2).replaceAll("<",""),se=e=>e.substring(2,5).replaceAll("<","");function Xe(e,t,n){if(t==="<"&&B(n).length>0){let i=n.indexOf("<"),r=i<0?n:n.slice(0,i);if(r.length>=2){let s=e+r.slice(0,-1);if(v(s,r[r.length-1])===!0)return{value:B(s),ok:!0,warn:null}}return{value:B(e),ok:!1,warn:"docnum_cd_mismatch"}}return{value:B(e),ok:v(e,t),warn:null}}var H=(e,t)=>({success:!1,error:e,fields:{},checkDigits:{},hardCdFail:!1,warns:[],...t===void 0?{}:{linesCount:t}});function Ie(e,t,n,i,r,s,o){return{success:!0,documentType:e,format:t,documentCode:Vt(n),fields:i,checkDigits:r,hardCdFail:s,warns:o}}function Yt(e,t){if(e.length<3)return H("mrz_incomplete");let[n,i,r]=ee(e.slice(0,3),Ge,We),s=se(n)===he||i.substring(15,18)===he||Kt(n.substring(15,25)),o=[],c={},a,d,p=!1;if(s){a=B(n.substring(5,14));let x=n[14];Ke(x)?(d=fe(n.substring(5,14))===x,d||o.push("td1_docnum_cd_mismatch")):d=null}else{let x=Xe(n.substring(5,14),n[14],n.substring(15,30));if(x.ok===null)return H("mrz_incomplete");a=x.value,d=x.ok,p=x.ok===!1&&x.warn===null,x.warn!==null&&o.push(x.warn)}c.document_number=d;let f=v(i.substring(0,6),i[6]),g=v(i.substring(8,14),i[14]);if(c.birth_date=f,c.expiry_date=g,f===null||g===null)return H("mrz_incomplete");let b=v(n.substring(5,30)+i.substring(0,7)+i.substring(8,15)+i.substring(18,29),i[29]);c.composite=b,b===!1&&o.push("composite_cd_mismatch");let l=s?n.substring(15,25):"",[u,S]=Se(r),R=f===!1||g===!1||p;return Ie(Me(n.substring(0,2)),"TD1",n,{issuing_state:se(n),document_number:a,nni:Ae.test(l)?l:"",birth_date:te(i.substring(0,6),!1,t),expiry_date:te(i.substring(8,14),!0,t),sex:Re(i[7]),nationality:B(i.substring(15,18)),surname:u,given_names:S},c,R,o)}function Zt(e,t){if(e.length<2)return H("mrz_incomplete");let[n,i]=ee(e.slice(0,2),ze,Ve),r=[],s=Xe(i.substring(0,9),i[9],i.substring(28,35));s.warn!==null&&r.push(s.warn);let o=v(i.substring(13,19),i[19]),c=v(i.substring(21,27),i[27]),a={document_number:s.ok,birth_date:o,expiry_date:c};if(s.ok===null||o===null||c===null)return H("mrz_incomplete");let d=v(i.substring(0,10)+i.substring(13,20)+i.substring(21,35),i[35]);a.composite=d,d===!1&&r.push("composite_cd_mismatch");let[p,f]=Se(n.substring(5,36)),g=s.ok===!1&&s.warn===null||o===!1||c===!1;return Ie(Me(n.substring(0,2)),"TD2",n,{issuing_state:se(n),document_number:s.value,nni:"",birth_date:te(i.substring(13,19),!1,t),expiry_date:te(i.substring(21,27),!0,t),sex:Re(i[20]),nationality:B(i.substring(10,13)),surname:p,given_names:f},a,g,r)}function Fe(e,t){if(e.length<2)return H("mrz_incomplete");let[n,i]=ee(e.slice(0,2),He,Ye),r=se(n)===he,s=[],o={},c=i.substring(0,9),a=v(c,i[9]),d=v(i.substring(13,19),i[19]),p=v(i.substring(21,27),i[27]);if(o.document_number=a,o.birth_date=d,o.expiry_date=p,a===null||d===null||p===null)return H("mrz_incomplete");let f=i.substring(28,42),g="";if(B(f).length>0){let R=v(f,i[42]);o.personal_number=R;let x=B(f);r&&R!==!1&&Ae.test(x)&&(g=x)}let b=v(i.substring(0,10)+i.substring(13,20)+i.substring(21,43),i[43]);o.composite=b,b===!1&&s.push("composite_cd_mismatch");let[l,u]=Se(n.substring(5,44)),S=a===!1||d===!1||p===!1;return Ie(Me(n.substring(0,2)),"TD3",n,{issuing_state:se(n),document_number:B(c),nni_candidate:g,birth_date:te(i.substring(13,19),!1,t),expiry_date:te(i.substring(21,27),!0,t),sex:Re(i[20]),nationality:B(i.substring(10,13)),surname:l,given_names:u},o,S,s)}var Ue=new Set(["A","C","I"]);function $e(e,t=j.today()){let n=e.filter(r=>r.trim().length>0);if(n.length===0)return H("mrz_unrecognized",0);let i=Array.from(de(n[0]).slice(0,1),xe).join("");return n.length===3&&Ue.has(i)?Yt(n,t):n.length===2&&i==="P"?Fe(n,t):n.length===2&&Ue.has(i)?Math.max(...n.map(r=>de(r).length))>40?Fe(n,t):Zt(n,t):H("mrz_unrecognized",n.length)}var Xt=new Map([...(`ABWAW AFGAF AGOAO AIAAI ALAAX ALBAL ANDAD AREAE ARGAR ARMAM ASMAS ATAAQ
14
15
  ATFTF ATGAG AUSAU AUTAT AZEAZ BDIBI BELBE BENBJ BESBQ BFABF BGDBD BGRBG
15
16
  BHRBH BHSBS BIHBA BLMBL BLRBY BLZBZ BMUBM BOLBO BRABR BRBBB BRNBN BTNBT
16
17
  BVTBV BWABW CAFCF CANCA CCKCC CHECH CHLCL CHNCN CIVCI CMRCM CODCD COGCG
@@ -30,13 +31,11 @@
30
31
  SRBRS SSDSS STPST SURSR SVKSK SVNSI SWESE SWZSZ SXMSX SYCSC SYRSY TCATC
31
32
  TCDTD TGOTG THATH TJKTJ TKLTK TKMTM TLSTL TONTO TTOTT TUNTN TURTR TUVTV
32
33
  TWNTW TZATZ UGAUG UKRUA UMIUM URYUY USAUS UZBUZ VATVA VCTVC VENVE VGBVG
33
- VIRVI VNMVN VUTVU WLFWF WSMWS YEMYE ZAFZA ZMBZM ZWEZW`.match(/[A-Z]{5}/g)??[]).map(e=>[e.slice(0,3),e.slice(3)]),["D","DE"]]),Ze={of(e){return Ht.get(e.replaceAll("<",""))??null}};var Ie=e=>ue(e);function qe(e){return e.slice(0,5e4).split(/\r?\n/).slice(0,200).map(t=>t.toUpperCase().replace(/[«‹〈]/g,"<").replace(/[^A-Z0-9<]/g,"")).filter(t=>t.length>0)}var Xe=e=>e.replace(/[OQ]/g,"0").replace(/[IL]/g,"1").replaceAll("Z","2").replaceAll("S","5").replaceAll("B","8");function $e(e,t){let n=Xe(e),s=Xe(t);if(!/^\d{6}$/.test(n)||Ie(n)!==s)return null;let r=2e3+Number(n.slice(0,2)),o=Number(n.slice(2,4)),i=Number(n.slice(4,6));return o>=1&&o<=12&&i>=1&&i<=new Date(Date.UTC(r,o,0)).getUTCDate()?n:null}function Se(e,t){let n=e.replace(/<+$/,"");return/^[A-Z0-9]+$/.test(n)&&Ie(e)===t?n:null}function Wt(e){if(e.length<15)return null;if(e[14]!=="<")return Se(e.substring(5,14),e[14]);let t=/^([A-Z0-9]+)</.exec(e.substring(15,Math.min(30,e.length)))?.[1];return t===void 0||t.length<2?null:Se(e.substring(5,14)+t.slice(0,-1),t[t.length-1])}var x=(e,t,n)=>t>=e.length?"":e.substring(t,Math.min(n,e.length)),Z=(e,t)=>t<e.length?e[t]:"",Je=/^[IAC][A-Z<][A-Z<]{3}/,Vt=/^P[A-Z<][A-Z<]{3}/,et=/^[PIAC][A-Z<][A-Z<]{3}/;function Yt(e){let t=qe(e),n=[],s=[];for(let o=0;o<t.length;o++){let i="",l=0;for(;l<6&&o+l<t.length&&(i+=t[o+l],!(i.length>300));)s.push(i),l++}let r=(o,i,l)=>{if(i.length<(l?15:28))return;let a=new Map,d=l?Wt(o):Se(x(i,0,9),Z(i,9)),b=$e(l?x(i,0,6):x(i,13,19),l?Z(i,6):Z(i,19)),f=$e(l?x(i,8,14):x(i,21,27),l?Z(i,14):Z(i,27));d!==null&&a.set("docNumber",d),b!==null&&a.set("dob6",b),f!==null&&a.set("expiry6",f),a.size>0&&n.push({fields:a,country:Ze.of(x(o,2,5))})};for(let o of s)Je.test(o)&&(o.length>=45&&r(o.substring(0,30),o.substring(30),!0),o.length>=64&&r(o.substring(0,36),o.substring(36),!1)),Vt.test(o)&&o.length>=72&&r(o.substring(0,44),o.substring(44),!1);for(let o=0;o<t.length-1;o++){let i=t[o],l=t[o+1];Je.test(i)&&i.length>=15&&i.length<=30&&r(i,l,!0),et.test(i)&&i.length>=5&&i.length<=44&&r(i,l,!1)}return n}function Zt(e){let t=Yt(e);if(t.length===0)return{};let n=Math.max(...t.map(o=>o.fields.size)),s=t.filter(o=>o.fields.size===n),r={};for(let o of["docNumber","dob6","expiry6"]){let i=new Set(s.map(l=>l.fields.get(o)).filter(l=>l!==void 0));i.size===1&&s.every(l=>l.fields.has(o))&&(r[o]=[...i][0])}return r}function Xt(e){let t=Zt(e),n=t.docNumber,s=t.dob6,r=t.expiry6;return n!==void 0&&s!==void 0&&r!==void 0?{docNumber:n,dob6:s,expiry6:r}:null}function tt(e){let t=Jt(e);return t.length===1?t[0]:null}var $t=e=>JSON.stringify([e.documentNumber,e.nationality,e.dob,e.sex,e.expiry,e.primaryIdentifier,e.secondaryIdentifier,e.optional]);function Jt(e){let t=qe(e),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(!et.test(o))continue;let i=o.startsWith("P")?[44]:[30,36];for(let l of i){let a=l===30?3:2,d=t.slice(r,Math.min(t.length,r+a));d.length===a&&d.every(p=>p.length<=l)&&n.push(d.map(p=>p.padEnd(l,"<")).join(`
34
- `));let b="",f=0;for(;f<6&&r+f<t.length&&(b+=t[r+f],b.length===l*a&&n.push(b),!(b.length>=l*a));)f++}}let s=new Map;for(let r of n){let o=Xt(r);if(o===null)continue;let i=r.includes(`
34
+ VIRVI VNMVN VUTVU WLFWF WSMWS YEMYE ZAFZA ZMBZM ZWEZW`.match(/[A-Z]{5}/g)??[]).map(e=>[e.slice(0,3),e.slice(3)]),["D","DE"]]),Je={of(e){return Xt.get(e.replaceAll("<",""))??null}};var Te=e=>fe(e);function nt(e){return e.slice(0,5e4).split(/\r?\n/).slice(0,200).map(t=>t.toUpperCase().replace(/[«‹〈]/g,"<").replace(/[^A-Z0-9<]/g,"")).filter(t=>t.length>0)}var je=e=>e.replace(/[OQ]/g,"0").replace(/[IL]/g,"1").replaceAll("Z","2").replaceAll("S","5").replaceAll("B","8");function Qe(e,t){let n=je(e),i=je(t);if(!/^\d{6}$/.test(n)||Te(n)!==i)return null;let r=2e3+Number(n.slice(0,2)),s=Number(n.slice(2,4)),o=Number(n.slice(4,6));return s>=1&&s<=12&&o>=1&&o<=new Date(Date.UTC(r,s,0)).getUTCDate()?n:null}function Ne(e,t){let n=e.replace(/<+$/,"");return/^[A-Z0-9]+$/.test(n)&&Te(e)===t?n:null}function $t(e){if(e.length<15)return null;if(e[14]!=="<")return Ne(e.substring(5,14),e[14]);let t=/^([A-Z0-9]+)</.exec(e.substring(15,Math.min(30,e.length)))?.[1];return t===void 0||t.length<2?null:Ne(e.substring(5,14)+t.slice(0,-1),t[t.length-1])}var A=(e,t,n)=>t>=e.length?"":e.substring(t,Math.min(n,e.length)),Z=(e,t)=>t<e.length?e[t]:"",qe=/^[IAC][A-Z<][A-Z<]{3}/,Jt=/^P[A-Z<][A-Z<]{3}/,rt=/^[PIAC][A-Z<][A-Z<]{3}/;function jt(e){let t=nt(e),n=[],i=[];for(let s=0;s<t.length;s++){let o="",c=0;for(;c<6&&s+c<t.length&&(o+=t[s+c],!(o.length>300));)i.push(o),c++}let r=(s,o,c)=>{if(o.length<(c?15:28))return;let a=new Map,d=c?$t(s):Ne(A(o,0,9),Z(o,9)),p=Qe(c?A(o,0,6):A(o,13,19),c?Z(o,6):Z(o,19)),f=Qe(c?A(o,8,14):A(o,21,27),c?Z(o,14):Z(o,27));d!==null&&a.set("docNumber",d),p!==null&&a.set("dob6",p),f!==null&&a.set("expiry6",f),a.size>0&&n.push({fields:a,country:Je.of(A(s,2,5))})};for(let s of i)qe.test(s)&&(s.length>=45&&r(s.substring(0,30),s.substring(30),!0),s.length>=64&&r(s.substring(0,36),s.substring(36),!1)),Jt.test(s)&&s.length>=72&&r(s.substring(0,44),s.substring(44),!1);for(let s=0;s<t.length-1;s++){let o=t[s],c=t[s+1];qe.test(o)&&o.length>=15&&o.length<=30&&r(o,c,!0),rt.test(o)&&o.length>=5&&o.length<=44&&r(o,c,!1)}return n}function Qt(e){let t=jt(e);if(t.length===0)return{};let n=Math.max(...t.map(s=>s.fields.size)),i=t.filter(s=>s.fields.size===n),r={};for(let s of["docNumber","dob6","expiry6"]){let o=new Set(i.map(c=>c.fields.get(s)).filter(c=>c!==void 0));o.size===1&&i.every(c=>c.fields.has(s))&&(r[s]=[...o][0])}return r}function qt(e){let t=Qt(e),n=t.docNumber,i=t.dob6,r=t.expiry6;return n!==void 0&&i!==void 0&&r!==void 0?{docNumber:n,dob6:i,expiry6:r}:null}function it(e){let t=tn(e);return t.length===1?t[0]:null}var en=e=>JSON.stringify([e.documentNumber,e.nationality,e.dob,e.sex,e.expiry,e.primaryIdentifier,e.secondaryIdentifier,e.optional]);function tn(e){let t=nt(e),n=[];for(let r=0;r<t.length;r++){let s=t[r];if(!rt.test(s))continue;let o=s.startsWith("P")?[44]:[30,36];for(let c of o){let a=c===30?3:2,d=t.slice(r,Math.min(t.length,r+a));d.length===a&&d.every(g=>g.length<=c)&&n.push(d.map(g=>g.padEnd(c,"<")).join(`
35
+ `));let p="",f=0;for(;f<6&&r+f<t.length&&(p+=t[r+f],p.length===c*a&&n.push(p),!(p.length>=c*a));)f++}}let i=new Map;for(let r of n){let s=qt(r);if(s===null)continue;let o=r.includes(`
35
36
  `)?r.split(`
36
- `):r.match(r.length===90?/.{30}/g:r.length===88?/.{44}/g:/.{36}/g)??[],l=i[0]??"",a=i[1]??"",d=i.length===3,b=d?x(l,5,30)+x(a,0,7)+x(a,8,15)+x(a,18,29):x(a,0,10)+x(a,13,20)+x(a,21,a.length-1),f=d?Z(a,29):Z(a,a.length-1);if(!/^[0-9]$/.test(f)||Ie(b)!==f)continue;let p=jt(r);if(p===null||p.primaryIdentifier.length===0&&p.secondaryIdentifier.length===0||!/^[MFX]?$/.test(p.sex))continue;let y={...p,documentNumber:o.docNumber,dob:o.dob6,expiry:o.expiry6};s.set($t(y),{fields:y,mrzLines:i})}return[...s.values()]}var P=e=>e.replaceAll("<"," ").replace(/\s+/g," ").trim();function je(e){let t=e.split("<<");return[P(t[0]??""),P(t.slice(1).join("<<"))]}var Qe=e=>e.length===0?null:e;function jt(e){let t=e.split(/\r?\n/).map(s=>s.replace(/\s+$/,"")).filter(s=>s.length>0),n=e.replace(/[\r\n]/g,"");if(t.length===1&&(n.length===90?t=[n.substring(0,30),n.substring(30,60),n.substring(60,90)]:n.length===72?t=[n.substring(0,36),n.substring(36,72)]:n.length===88&&(t=[n.substring(0,44),n.substring(44,88)])),t.length===3){let[s,r,o]=t,i=Z(s,14)==="<"?/^([A-Z0-9]+)</.exec(x(s,15,30))?.[1]:void 0,l=P(x(s,5,14)+(i!==void 0&&i.length>1?i.slice(0,-1):"")),[a,d]=je(o),b=P(`${x(s,15,30)}<${x(r,18,29)}`);return{documentNumber:l,nationality:P(x(r,15,18)),dob:x(r,0,6),sex:P(x(r,7,8)),expiry:x(r,8,14),primaryIdentifier:a,secondaryIdentifier:d,optional:Qe(b)}}if(t.length===2){let[s,r]=t,o=s.length>=44,[i,l]=je(x(s,5,o?44:36));return{documentNumber:P(x(r,0,9)),nationality:P(x(r,10,13)),dob:x(r,13,19),sex:P(x(r,20,21)),expiry:x(r,21,27),primaryIdentifier:i,secondaryIdentifier:l,optional:Qe(P(o?x(r,28,42):x(r,28,35)))}}return null}function nt(e,t=j.today()){let n=Ye(e,t),s=n.format??null,r=s==="TD1"||s==="TD2"||s==="TD3"?We(e,s):[...e];return{format:s,documentCode:n.documentCode??null,lines:r,valid:n.success&&!n.hardCdFail}}var Qt=/^[A-Z0-9<]{25,}$/;function qt(e){return e.toUpperCase().replaceAll(" ","").replaceAll("\xAB","<").replaceAll("\u2039","<")}var Ce=(e,t,n)=>e.length>=t&&e.length<=n;function rt(e){let t=e.map(qt).filter(n=>Qt.test(n));for(let n=0;n+3<=t.length;n++){let s=t.slice(n,n+3);if(s.every(r=>Ce(r,28,32))&&"IAC".includes(s[0][0]))return s}for(let n=0;n+2<=t.length;n++){let s=t.slice(n,n+2);if(s.every(r=>Ce(r,40,46))&&s[0].startsWith("P")||s.every(r=>Ce(r,34,38))&&"IACPV".includes(s[0][0]))return s}return[]}var ne={SIZE:80,SCRIPT:64,OFFSET:68,STEPS:72},L={DETECTOR:0,LATIN:1,ARABIC:2},U={NONE:0,LATIN:1,ARABIC:2,BOTH:3},de=3;var X=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Ee(e,t,n,s,r){let o=r.now??(()=>performance.now()),i=o(),a=e.read(t,n,s,r.region??[0,0,1,1],1,de,U.LATIN,r.detectorLimit).map(u=>({text:u.latin.text,score:u.latin.score,box:[0,1,2,3].map(R=>({x:u.box[2*R],y:u.box[2*R+1]}))})),d=ke([...a].reverse()),b=d.map(u=>u.text),f=[...tt(b.join(`
37
- `))?.mrzLines??rt(b)],p=d.map(u=>[X(u.x/n),X(u.y/s),X((u.x2-u.x)/n),X((u.y2-u.y)/s)]),y={kind:"band",ms:0,lineBoxes:p,lineCount:f.length,valid:!1},m=tn(d.map(u=>u.text),p,f);if(m!==null&&(y.mrzBox=m),f.length>0){let u=nt(f,r.today??j.today());u.format&&(y.format=u.format),u.documentCode&&/^[A-Z<]{1,2}$/.test(u.documentCode)&&(y.documentCode=u.documentCode),u.valid&&(y.valid=!0,y.digest=await _e(r.salt,u.lines))}return y.ms=Math.round(o()-i),y}var st=e=>e.toUpperCase().replace(/\s+/g,"");function en(e,t){let n=Math.max(e.length,t.length);if(n===0)return 0;let s=0;for(let r=0;r<Math.min(e.length,t.length);r++)e[r]===t[r]&&s++;return s/n}function tn(e,t,n){if(n.length===0||e.length===0)return null;let s=new Set,r=[];for(let d of n){let b=-1,f=.5;if(e.forEach((p,y)=>{let m=s.has(y)?0:en(st(p),st(d));m>f&&(f=m,b=y)}),b<0)return null;s.add(b),r.push(t[b])}let o=Math.min(...r.map(d=>d[0])),i=Math.min(...r.map(d=>d[1])),l=Math.max(...r.map(d=>d[0]+d[2])),a=Math.max(...r.map(d=>d[1]+d[3]));return[X(o),X(i),X(l-o),X(a-i)]}var Dn=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function ot(e,t,n){let s=r=>Math.round(Math.min(1,Math.max(0,r))*1e4)/1e4;return e.map(r=>{let o=[r[0],r[2],r[4],r[6]],i=[r[1],r[3],r[5],r[7]],l=Math.min(...o),a=Math.min(...i);return[s(l/t),s(a/n),s((Math.max(...o)-l)/t),s((Math.max(...i)-a)/n)]}).sort((r,o)=>r[1]-o[1]||r[0]-o[0])}var it={};async function nn(e={}){var t,n=e,s=it.url,r="",o,i;try{r=new URL(".",s).href}catch{}i=c=>{var h=new XMLHttpRequest;return h.open("GET",c,!1),h.responseType="arraybuffer",h.send(null),new Uint8Array(h.response)},o=async c=>{if(c=await fetch(c,{credentials:"same-origin"}),c.ok)return c.arrayBuffer();throw Error(c.status+" : "+c.url)};var l=console.log.bind(console),a=console.error.bind(console),d=!1,b,f,p,y,m,u=!1;function R(){var c=ae.buffer;new Int8Array(c),new Int16Array(c),n.HEAPU8=p=new Uint8Array(c),new Uint16Array(c),new Int32Array(c),y=new Uint32Array(c),new Float32Array(c),new Float64Array(c),m=new BigInt64Array(c),new BigUint64Array(c)}function S(c){throw c="Aborted("+c+")",a(c),d=!0,c+=". Build with -sASSERTIONS for more info.",u&&Q(),c=new WebAssembly.RuntimeError(c),f?.(c),c}var A;async function w(c){try{var h=await o(c);return new Uint8Array(h)}catch{}if(i)c=i(c);else throw"both async and sync fetching of the wasm failed";return c}async function B(c,h){try{var g=await w(c);return await WebAssembly.instantiate(g,h)}catch(C){a(`failed to asynchronously prepare wasm: ${C}`),S(C)}}async function z(c){var h=A;try{var g=fetch(h,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(g,c)}catch(C){a(`wasm streaming compile failed: ${C}`),a("falling back to ArrayBuffer instantiation")}return B(h,c)}var H={},W=()=>{if(!$){var c={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"},h;for(h in H)H[h]===void 0?delete c[h]:c[h]=H[h];var g=[];for(h in c)g.push(`${h}=${c[h]}`);$=g}return $},$,J=[null,[],[]],ie=globalThis.TextDecoder&&new TextDecoder,Q,ae,mt={i:()=>S(""),b:function(c,h,g){return 0<=c&&3>=c?(m[g>>3]=BigInt(Math.round(1e6*(c===0?Date.now():performance.now()))),0):28},d:()=>1073741824,c:c=>{var h=p.length;if(c>>>=0,1073741824<c)return!1;for(var g=1;4>=g;g*=2){var C=h*(1+.2/g);C=Math.min(C,c+100663296);e:{C=(Math.min(1073741824,65536*Math.ceil(Math.max(c,C)/65536))-ae.buffer.byteLength+65535)/65536|0;try{ae.grow(C),R();var _=1;break e}catch{}_=void 0}if(_)return!0}return!1},f:(c,h)=>{var g=0,C=0,_;for(_ of W()){var M=h+g;y[c+C>>2]=M;for(var q=_,O=p,re=M,F=M+1/0-1,E=0;E<q.length;++E){var N=q.codePointAt(E);if(127>=N){if(M>=F)break;O[M++]=N}else if(2047>=N){if(M+1>=F)break;O[M++]=192|N>>6,O[M++]=128|N&63}else if(65535>=N){if(M+2>=F)break;O[M++]=224|N>>12,O[M++]=128|N>>6&63,O[M++]=128|N&63}else{if(M+3>=F)break;O[M++]=240|N>>18,O[M++]=128|N>>12&63,O[M++]=128|N>>6&63,O[M++]=128|N&63,E++}}O[M]=0,q=M-re,g+=q+1,C+=4}return 0},g:(c,h)=>{var g=W();y[c>>2]=g.length,c=0;for(var C of g){for(var _=g=0;_<C.length;++_){var M=C.charCodeAt(_);127>=M?g++:2047>=M?g+=2:55296<=M&&57343>=M?(g+=4,++_):g+=3}c+=g+1}return y[h>>2]=c,0},j:()=>52,h:()=>52,e:function(){return 70},a:(c,h,g,C)=>{for(var _=0,M=0;M<g;M++){var q=y[h>>2],O=y[h+4>>2];h+=8;for(var re=0;re<O;re++){var F=c,E=p[q+re],N=J[F];if(E===0||E===10){F=F===1?l:a,E=N;for(var V=0,se=E,v=V,T=v+void 0;se[v]&&!(v>=T);)++v;if(se=v,16<se-V&&E.buffer&&ie)E=ie.decode(E.subarray(V,se));else{for(v="";V<se;)if(T=E[V++],T&128){var me=E[V++]&63;if((T&224)==192)v+=String.fromCharCode((T&31)<<6|me);else{var Ne=E[V++]&63;T=(T&240)==224?(T&15)<<12|me<<6|Ne:(T&7)<<18|me<<12|Ne<<6|E[V++]&63,65536>T?v+=String.fromCharCode(T):(T-=65536,v+=String.fromCharCode(55296|T>>10,56320|T&1023))}}else v+=String.fromCharCode(T);E=v}F(E),N.length=0}else N.push(E)}_+=O}return y[C>>2]=_,0}},le;return le=await(async function(){function c(g){return g=le=g.exports,n._skw_engine_id=g.m,n._skw_load=g.n,n._skw_unload=g.o,n._skw_set_detector_limit=g.p,n._skw_read=g.q,n._skw_line_count=g.r,n._skw_lines=g.s,n._skw_best=g.t,n._skw_values=g.u,n._skw_sharpness=g.v,n._free=g.w,n._malloc=g.x,Q=g.y,ae=g.k,R(),le}var h={a:mt};return n.instantiateWasm?new Promise(g=>{n.instantiateWasm(h,(C,_)=>{g(c(C,_))})}):(A??(A=n.locateFile?n.locateFile?n.locateFile("sekyro-ocr.wasm",r):r+"sekyro-ocr.wasm":new URL("sekyro-ocr.wasm",it.url).href),c((await z(h)).instance))})(),n.calledRun=!0,d||(u=!0,le.l(),b?.(n)),u?t=n:t=new Promise((c,h)=>{b=c,f=h}),t}var at=nn;function lt(e){return e===1||e===5?new I("OCR_IMAGE_INVALID"):e===2?new I("OCR_ASSET_INVALID"):e===4?new I("OCR_CANCELLED"):e===6?new I("OCR_BUSY"):e===7?new I("OCR_UNAVAILABLE"):new I("OCR_INFERENCE_FAILED")}var fe=class{constructor(t){this.m=t;this.px=0;this.pxBytes=0;this.dicts=[null,null,null];this.classes=[0,0,0];this.held=[[],[],[]];this.latinKind="latin"}engineId(){let t=this.m._skw_engine_id(),n="";for(let s=t;this.m.HEAPU8[s]!==0&&s<t+64;s++)n+=String.fromCharCode(this.m.HEAPU8[s]);return n}put(t){let n=this.m._malloc(t.length);if(!n)throw new I("OCR_UNAVAILABLE");return this.m.HEAPU8.set(t,n),n}load(t,n,s,r,o={}){this.unload(t);let i=new Uint8Array(n),l=new Uint8Array(i.byteLength+1);l.set(i);let a=r===void 0?null:Le(r),d=r===void 0?0:ct(r);if(o.mrz===!0){if(t!==L.LATIN||r===void 0||!on(r))throw new I("OCR_ASSET_INVALID")}else if(t===L.LATIN&&(r===void 0||r.endsWith(`
38
- `)||d!==6625))throw new I("OCR_ASSET_INVALID");if(t===L.ARABIC&&(r===void 0||!r.endsWith(`
39
- `)||d!==163||a[161]!==""))throw new I("OCR_ASSET_INVALID");let b=new Uint8Array(s),f=this.put(l),p=this.put(b);this.held[t]=[f,p];let y=this.m._skw_load(t,f,l.length,p,b.byteLength,d);if(y!==0)throw this.unload(t),lt(y);this.dicts[t]=a,this.classes[t]=d,t===L.LATIN&&(this.latinKind=o.mrz===!0?"mrz":"latin")}recognizer(){return this.loaded(L.LATIN)?this.latinKind:null}unload(t){this.held[t].length&&this.m._skw_unload(t);for(let n of this.held[t])this.m._free(n);this.held[t]=[],this.dicts[t]=null}loaded(t){return this.held[t].length>0}pixels(t){if(t.length>this.pxBytes){if(this.px&&this.m._free(this.px),this.px=this.m._malloc(t.length),!this.px)throw new I("OCR_UNAVAILABLE");this.pxBytes=t.length}return this.m.HEAPU8.set(t,this.px),this.px}sharpness(t,n,s){let r=this.m._skw_sharpness(this.pixels(t),n,s);return r>=0&&Number.isFinite(r)?r:null}read(t,n,s,r,o,i,l,a){if(!rn(l))throw new I("OCR_IMAGE_INVALID");if(l&U.LATIN&&!this.dicts[L.LATIN]||l&U.ARABIC&&!this.dicts[L.ARABIC]||!this.loaded(0))throw new I("OCR_UNAVAILABLE");let d=this.pixels(t);this.m._skw_set_detector_limit(a);let b=this.m._skw_read(d,n,s,r[0],r[1],r[2],r[3],o,i,l);if(b!==0)throw lt(b);let f=this.m._skw_line_count(),p=this.m.HEAPU8.buffer,y=new DataView(p,this.m._skw_lines(),f*ne.SIZE),m=new Int32Array(p,this.m._skw_best()),u=new Float32Array(p,this.m._skw_values()),R=[];for(let S=0;S<f;S++){let A=S*ne.SIZE,w=y.getInt32(A+ne.SCRIPT,!0),B=y.getInt32(A+ne.OFFSET,!0),z=y.getInt32(A+ne.STEPS,!0);if(l===U.NONE){R.push({box:Array.from({length:8},(ie,Q)=>y.getFloat64(A+8*Q,!0))});continue}let H=this.dicts[w];if(!H)throw new I("OCR_INFERENCE_FAILED");let W=we(m.subarray(B,B+z),u.subarray(B,B+z),this.classes[w],H,w===L.ARABIC),$=Array.from({length:8},(ie,Q)=>y.getFloat64(A+8*Q,!0)),J=R[R.length-1];w===L.ARABIC&&J&&J.arabic===void 0&&J.latin!==void 0&&sn(J.box,$)?J.arabic=W:R.push(w===L.ARABIC?{box:$,arabic:W}:{box:$,latin:W})}return R}heapBytes(){return this.m.HEAPU8.length}dispose(){for(let t of[0,1,2])this.unload(t);this.px&&this.m._free(this.px),this.px=0,this.pxBytes=0}};function ct(e){return(e.endsWith(`
37
+ `):r.match(r.length===90?/.{30}/g:r.length===88?/.{44}/g:/.{36}/g)??[],c=o[0]??"",a=o[1]??"",d=o.length===3,p=d?A(c,5,30)+A(a,0,7)+A(a,8,15)+A(a,18,29):A(a,0,10)+A(a,13,20)+A(a,21,a.length-1),f=d?Z(a,29):Z(a,a.length-1);if(!/^[0-9]$/.test(f)||Te(p)!==f)continue;let g=nn(r);if(g===null||g.primaryIdentifier.length===0&&g.secondaryIdentifier.length===0||!/^[MFX]?$/.test(g.sex))continue;let b={...g,documentNumber:s.docNumber,dob:s.dob6,expiry:s.expiry6};i.set(en(b),{fields:b,mrzLines:o})}return[...i.values()]}var U=e=>e.replaceAll("<"," ").replace(/\s+/g," ").trim();function et(e){let t=e.split("<<");return[U(t[0]??""),U(t.slice(1).join("<<"))]}var tt=e=>e.length===0?null:e;function nn(e){let t=e.split(/\r?\n/).map(i=>i.replace(/\s+$/,"")).filter(i=>i.length>0),n=e.replace(/[\r\n]/g,"");if(t.length===1&&(n.length===90?t=[n.substring(0,30),n.substring(30,60),n.substring(60,90)]:n.length===72?t=[n.substring(0,36),n.substring(36,72)]:n.length===88&&(t=[n.substring(0,44),n.substring(44,88)])),t.length===3){let[i,r,s]=t,o=Z(i,14)==="<"?/^([A-Z0-9]+)</.exec(A(i,15,30))?.[1]:void 0,c=U(A(i,5,14)+(o!==void 0&&o.length>1?o.slice(0,-1):"")),[a,d]=et(s),p=U(`${A(i,15,30)}<${A(r,18,29)}`);return{documentNumber:c,nationality:U(A(r,15,18)),dob:A(r,0,6),sex:U(A(r,7,8)),expiry:A(r,8,14),primaryIdentifier:a,secondaryIdentifier:d,optional:tt(p)}}if(t.length===2){let[i,r]=t,s=i.length>=44,[o,c]=et(A(i,5,s?44:36));return{documentNumber:U(A(r,0,9)),nationality:U(A(r,10,13)),dob:A(r,13,19),sex:U(A(r,20,21)),expiry:A(r,21,27),primaryIdentifier:o,secondaryIdentifier:c,optional:tt(U(s?A(r,28,42):A(r,28,35)))}}return null}function st(e,t=j.today()){let n=$e(e,t),i=n.format??null,r=i==="TD1"||i==="TD2"||i==="TD3"?Ze(e,i):[...e];return{format:i,documentCode:n.documentCode??null,lines:r,valid:n.success&&!n.hardCdFail}}var rn=/^[A-Z0-9<]{25,}$/;function sn(e){return e.toUpperCase().replaceAll(" ","").replaceAll("\xAB","<").replaceAll("\u2039","<")}var Ee=(e,t,n)=>e.length>=t&&e.length<=n;function ot(e){let t=e.map(sn).filter(n=>rn.test(n));for(let n=0;n+3<=t.length;n++){let i=t.slice(n,n+3);if(i.every(r=>Ee(r,28,32))&&"IAC".includes(i[0][0]))return i}for(let n=0;n+2<=t.length;n++){let i=t.slice(n,n+2);if(i.every(r=>Ee(r,40,46))&&i[0].startsWith("P")||i.every(r=>Ee(r,34,38))&&"IACPV".includes(i[0][0]))return i}return[]}var ne={SIZE:80,SCRIPT:64,OFFSET:68,STEPS:72},C={DETECTOR:0,LATIN:1,ARABIC:2},F={NONE:0,LATIN:1,ARABIC:2,BOTH:3},oe=3;var X=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function ct(e,t,n,i,r){let s=r.now??(()=>performance.now()),o=s(),a=e.read(t,n,i,r.region??[0,0,1,1],1,oe,F.LATIN,r.detectorLimit).map(u=>({text:u.latin.text,score:u.latin.score,box:[0,1,2,3].map(S=>({x:u.box[2*S],y:u.box[2*S+1]}))})),d=Pe([...a].reverse()),p=d.map(u=>u.text),f=[...it(p.join(`
38
+ `))?.mrzLines??ot(p)],g=d.map(u=>[X(u.x/n),X(u.y/i),X((u.x2-u.x)/n),X((u.y2-u.y)/i)]),b={kind:"band",ms:0,lineBoxes:g,lineCount:f.length,valid:!1},l=an(d.map(u=>u.text),g,f);if(l!==null&&(b.mrzBox=l),f.length>0){let u=st(f,r.today??j.today());u.format&&(b.format=u.format),u.documentCode&&/^[A-Z<]{1,2}$/.test(u.documentCode)&&(b.documentCode=u.documentCode),u.valid&&(b.valid=!0,b.digest=await _e(r.salt,u.lines))}return b.ms=Math.round(s()-o),b}var at=e=>e.toUpperCase().replace(/\s+/g,"");function on(e,t){let n=Math.max(e.length,t.length);if(n===0)return 0;let i=0;for(let r=0;r<Math.min(e.length,t.length);r++)e[r]===t[r]&&i++;return i/n}function an(e,t,n){if(n.length===0||e.length===0)return null;let i=new Set,r=[];for(let d of n){let p=-1,f=.5;if(e.forEach((g,b)=>{let l=i.has(b)?0:on(at(g),at(d));l>f&&(f=l,p=b)}),p<0)return null;i.add(p),r.push(t[p])}let s=Math.min(...r.map(d=>d[0])),o=Math.min(...r.map(d=>d[1])),c=Math.max(...r.map(d=>d[0]+d[2])),a=Math.max(...r.map(d=>d[1]+d[3]));return[X(s),X(o),X(c-s),X(a-o)]}var Hn=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function lt(e,t,n){let i=r=>Math.round(Math.min(1,Math.max(0,r))*1e4)/1e4;return e.map(r=>{let s=[r[0],r[2],r[4],r[6]],o=[r[1],r[3],r[5],r[7]],c=Math.min(...s),a=Math.min(...o);return[i(c/t),i(a/n),i((Math.max(...s)-c)/t),i((Math.max(...o)-a)/n)]}).sort((r,s)=>r[1]-s[1]||r[0]-s[0])}var ut={};async function cn(e={}){var t,n=e,i=ut.url,r="",s,o;try{r=new URL(".",i).href}catch{}o=m=>{var h=new XMLHttpRequest;return h.open("GET",m,!1),h.responseType="arraybuffer",h.send(null),new Uint8Array(h.response)},s=async m=>{if(m=await fetch(m,{credentials:"same-origin"}),m.ok)return m.arrayBuffer();throw Error(m.status+" : "+m.url)};var c=console.log.bind(console),a=console.error.bind(console),d=!1,p,f,g,b,l,u=!1;function S(){var m=ce.buffer;new Int8Array(m),new Int16Array(m),n.HEAPU8=g=new Uint8Array(m),new Uint16Array(m),new Int32Array(m),b=new Uint32Array(m),new Float32Array(m),new Float64Array(m),l=new BigInt64Array(m),new BigUint64Array(m)}function R(m){throw m="Aborted("+m+")",a(m),d=!0,m+=". Build with -sASSERTIONS for more info.",u&&Q(),m=new WebAssembly.RuntimeError(m),f?.(m),m}var x;async function L(m){try{var h=await s(m);return new Uint8Array(h)}catch{}if(o)m=o(m);else throw"both async and sync fetching of the wasm failed";return m}async function w(m,h){try{var y=await L(m);return await WebAssembly.instantiate(y,h)}catch(N){a(`failed to asynchronously prepare wasm: ${N}`),R(N)}}async function K(m){var h=x;try{var y=fetch(h,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(y,m)}catch(N){a(`wasm streaming compile failed: ${N}`),a("falling back to ArrayBuffer instantiation")}return w(h,m)}var W={},V=()=>{if(!$){var m={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"},h;for(h in W)W[h]===void 0?delete m[h]:m[h]=W[h];var y=[];for(h in m)y.push(`${h}=${m[h]}`);$=y}return $},$,J=[null,[],[]],ae=globalThis.TextDecoder&&new TextDecoder,Q,ce,ht={i:()=>R(""),b:function(m,h,y){return 0<=m&&3>=m?(l[y>>3]=BigInt(Math.round(1e6*(m===0?Date.now():performance.now()))),0):28},d:()=>1073741824,c:m=>{var h=g.length;if(m>>>=0,1073741824<m)return!1;for(var y=1;4>=y;y*=2){var N=h*(1+.2/y);N=Math.min(N,m+100663296);e:{N=(Math.min(1073741824,65536*Math.ceil(Math.max(m,N)/65536))-ce.buffer.byteLength+65535)/65536|0;try{ce.grow(N),S();var _=1;break e}catch{}_=void 0}if(_)return!0}return!1},f:(m,h)=>{var y=0,N=0,_;for(_ of V()){var M=h+y;b[m+N>>2]=M;for(var q=_,D=g,re=M,G=M+1/0-1,T=0;T<q.length;++T){var E=q.codePointAt(T);if(127>=E){if(M>=G)break;D[M++]=E}else if(2047>=E){if(M+1>=G)break;D[M++]=192|E>>6,D[M++]=128|E&63}else if(65535>=E){if(M+2>=G)break;D[M++]=224|E>>12,D[M++]=128|E>>6&63,D[M++]=128|E&63}else{if(M+3>=G)break;D[M++]=240|E>>18,D[M++]=128|E>>12&63,D[M++]=128|E>>6&63,D[M++]=128|E&63,T++}}D[M]=0,q=M-re,y+=q+1,N+=4}return 0},g:(m,h)=>{var y=V();b[m>>2]=y.length,m=0;for(var N of y){for(var _=y=0;_<N.length;++_){var M=N.charCodeAt(_);127>=M?y++:2047>=M?y+=2:55296<=M&&57343>=M?(y+=4,++_):y+=3}m+=y+1}return b[h>>2]=m,0},j:()=>52,h:()=>52,e:function(){return 70},a:(m,h,y,N)=>{for(var _=0,M=0;M<y;M++){var q=b[h>>2],D=b[h+4>>2];h+=8;for(var re=0;re<D;re++){var G=m,T=g[q+re],E=J[G];if(T===0||T===10){G=G===1?c:a,T=E;for(var Y=0,ie=T,P=Y,O=P+void 0;ie[P]&&!(P>=O);)++P;if(ie=P,16<ie-Y&&T.buffer&&ae)T=ae.decode(T.subarray(Y,ie));else{for(P="";Y<ie;)if(O=T[Y++],O&128){var pe=T[Y++]&63;if((O&224)==192)P+=String.fromCharCode((O&31)<<6|pe);else{var Ce=T[Y++]&63;O=(O&240)==224?(O&15)<<12|pe<<6|Ce:(O&7)<<18|pe<<12|Ce<<6|T[Y++]&63,65536>O?P+=String.fromCharCode(O):(O-=65536,P+=String.fromCharCode(55296|O>>10,56320|O&1023))}}else P+=String.fromCharCode(O);T=P}G(T),E.length=0}else E.push(T)}_+=D}return b[N>>2]=_,0}},le;return le=await(async function(){function m(y){return y=le=y.exports,n._skw_engine_id=y.m,n._skw_load=y.n,n._skw_unload=y.o,n._skw_set_detector_limit=y.p,n._skw_read=y.q,n._skw_line_count=y.r,n._skw_lines=y.s,n._skw_best=y.t,n._skw_values=y.u,n._skw_sharpness=y.v,n._free=y.w,n._malloc=y.x,Q=y.y,ce=y.k,S(),le}var h={a:ht};return n.instantiateWasm?new Promise(y=>{n.instantiateWasm(h,(N,_)=>{y(m(N,_))})}):(x??(x=n.locateFile?n.locateFile?n.locateFile("sekyro-ocr.wasm",r):r+"sekyro-ocr.wasm":new URL("sekyro-ocr.wasm",ut.url).href),m((await K(h)).instance))})(),n.calledRun=!0,d||(u=!0,le.l(),p?.(n)),u?t=n:t=new Promise((m,h)=>{p=m,f=h}),t}var dt=cn;function ft(e){return e===1||e===5?new I("OCR_IMAGE_INVALID"):e===2?new I("OCR_ASSET_INVALID"):e===4?new I("OCR_CANCELLED"):e===6?new I("OCR_BUSY"):e===7?new I("OCR_UNAVAILABLE"):new I("OCR_INFERENCE_FAILED")}var me=class{constructor(t){this.m=t;this.px=0;this.pxBytes=0;this.dicts=[null,null,null];this.classes=[0,0,0];this.held=[[],[],[]];this.latinKind="latin";this.scripts=[null,null,null]}engineId(){let t=this.m._skw_engine_id(),n="";for(let i=t;this.m.HEAPU8[i]!==0&&i<t+64;i++)n+=String.fromCharCode(this.m.HEAPU8[i]);return n}put(t){let n=this.m._malloc(t.length);if(!n)throw new I("OCR_UNAVAILABLE");return this.m.HEAPU8.set(t,n),n}load(t,n,i,r,s={}){this.unload(t);let o=new Uint8Array(n),c=new Uint8Array(o.byteLength+1);c.set(o);let a=null,d=0,p=null;if(s.mrz===!0){if(t!==C.LATIN||r===void 0||!dn(r)||s.script!==void 0)throw new I("OCR_ASSET_INVALID");a=ue(r),d=mt(r)}else if(t!==C.DETECTOR){if(p=s.script??(t===C.LATIN?ye:"arabic"),r===void 0||!De(p)||t===C.LATIN!=(p===ye))throw new I("OCR_ASSET_INVALID");d=ve(p).classes,a=ke(r,d)}else if(r!==void 0||s.script!==void 0)throw new I("OCR_ASSET_INVALID");let f=new Uint8Array(i),g=this.put(c),b=this.put(f);this.held[t]=[g,b];let l=this.m._skw_load(t,g,c.length,b,f.byteLength,d);if(l!==0)throw this.unload(t),ft(l);this.dicts[t]=a,this.classes[t]=d,this.scripts[t]=p,t===C.LATIN&&(this.latinKind=s.mrz===!0?"mrz":"latin")}recognizer(){return this.loaded(C.LATIN)?this.latinKind:null}secondScript(){return this.loaded(C.ARABIC)?this.scripts[C.ARABIC]:null}unload(t){this.held[t].length&&this.m._skw_unload(t);for(let n of this.held[t])this.m._free(n);this.held[t]=[],this.dicts[t]=null,this.scripts[t]=null}loaded(t){return this.held[t].length>0}pixels(t){if(t.length>this.pxBytes){if(this.px&&this.m._free(this.px),this.px=this.m._malloc(t.length),!this.px)throw new I("OCR_UNAVAILABLE");this.pxBytes=t.length}return this.m.HEAPU8.set(t,this.px),this.px}sharpness(t,n,i){let r=this.m._skw_sharpness(this.pixels(t),n,i);return r>=0&&Number.isFinite(r)?r:null}read(t,n,i,r,s,o,c,a){if(!ln(c))throw new I("OCR_IMAGE_INVALID");if(c&F.LATIN&&!this.dicts[C.LATIN]||c&F.ARABIC&&!this.dicts[C.ARABIC]||!this.loaded(0))throw new I("OCR_UNAVAILABLE");let d=this.pixels(t);this.m._skw_set_detector_limit(a);let p=this.m._skw_read(d,n,i,r[0],r[1],r[2],r[3],s,o,c);if(p!==0)throw ft(p);let f=this.m._skw_line_count(),g=this.m.HEAPU8.buffer,b=new DataView(g,this.m._skw_lines(),f*ne.SIZE),l=new Int32Array(g,this.m._skw_best()),u=new Float32Array(g,this.m._skw_values()),S=[];for(let R=0;R<f;R++){let x=R*ne.SIZE,L=b.getInt32(x+ne.SCRIPT,!0),w=b.getInt32(x+ne.OFFSET,!0),K=b.getInt32(x+ne.STEPS,!0);if(c===F.NONE){S.push({box:Array.from({length:8},(ae,Q)=>b.getFloat64(x+8*Q,!0))});continue}let W=this.dicts[L];if(!W)throw new I("OCR_INFERENCE_FAILED");let V=we(l.subarray(w,w+K),u.subarray(w,w+K),this.classes[L],W,!1),$=Array.from({length:8},(ae,Q)=>b.getFloat64(x+8*Q,!0)),J=S[S.length-1];L===C.ARABIC&&J&&J.arabic===void 0&&J.latin!==void 0&&un(J.box,$)?J.arabic=V:S.push(L===C.ARABIC?{box:$,arabic:V}:{box:$,latin:V})}return S}heapBytes(){return this.m.HEAPU8.length}dispose(){for(let t of[0,1,2])this.unload(t);this.px&&this.m._free(this.px),this.px=0,this.pxBytes=0}};function mt(e){return(e.endsWith(`
40
39
  `)?e.slice(0,-1):e).split(`
41
- `).length+2}var rn=e=>Number.isInteger(e)&&e>=U.NONE&&e<=U.BOTH,sn=(e,t)=>e.every((n,s)=>n===t[s]);function on(e){let t=e.split(`
42
- `);return t.length===37&&new Set(t).size===37&&t.every(n=>/^[0-9A-Z<]$/.test(n))&&ct(e)===39}async function ut(e){let t=await at({instantiateWasm:(n,s)=>(WebAssembly.instantiate(e,n).then(r=>s(r,e)),{})});return new fe(t)}function an(){let e=null,t=null;return(n,s)=>{if(typeof OffscreenCanvas!="function"||(e||(e=new OffscreenCanvas(n,s),t=e.getContext("2d",{willReadFrequently:!0})),!t))return null;(e.width!==n||e.height!==s)&&(e.width=n,e.height=s);let r=t;return{draw(o){return r.clearRect(0,0,n,s),r.drawImage(o,0,0),r.getImageData(0,0,n,s).data}}}}function dt(){return{fetch:(...e)=>fetch(...e),now:()=>performance.now(),canvas:an(),instantiate:ut}}function ft(e,t=dt()){let n=null,s="",r=960,o=0,i=!1,l=Promise.resolve(),a=m=>e.postMessage(m);async function d(m){if(t.canvas(1,1)===null)return a({id:m.id,kind:"failed",reason:"unsupported"});s=m.salt,r=m.detectorLimit;try{let u=await Oe(m.baseUrl,Te,m.maxDownloadMs,t.fetch,t.now);o=u.downloadMs,i=u.cached;let R=await WebAssembly.compile(u.files.get("sekyro-ocr.wasm")),S=await t.instantiate(R),A=new TextDecoder("utf-8",{fatal:!0}).decode(u.files.get("mrz_dict.txt"));S.load(L.DETECTOR,u.files.get("det.param"),u.files.get("det.bin")),S.load(L.LATIN,u.files.get("mrz-rec.param"),u.files.get("mrz-rec.bin"),A,{mrz:!0}),u.files.clear(),n=S,a({id:m.id,kind:"ready",warmupMs:0,downloadMs:o,cached:i})}catch(u){a({id:m.id,kind:"failed",reason:u instanceof G?u.reason:"error"})}}async function b(m,u,R,S){if(!n)return u.close(),a({id:m,kind:"error",code:"not_ready"});let A=u.width,w=u.height,B=t.canvas(A,w);if(!B)return u.close(),a({id:m,kind:"failed",reason:"unsupported"});let z=B.draw(u);u.close();try{a({id:m,...await Ee(n,z,A,w,{detectorLimit:S,salt:s,region:R,now:t.now})})}catch{a({id:m,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function f(m,u,R){if(!n)return u.close(),a({id:m,kind:"error",code:"not_ready"});let S=u.width,A=u.height,w=t.canvas(S,A);if(!w)return u.close(),a({id:m,kind:"failed",reason:"unsupported"});let B=w.draw(u);u.close();try{let z=t.now(),H=n.read(B,S,A,[0,0,1,1],1,de,U.NONE,R);a({id:m,kind:"layout",ms:Math.round(t.now()-z),lineBoxes:ot(H.map(W=>W.box),S,A)})}catch{a({id:m,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function p(m){if(!n)return a({id:m,kind:"error",code:"not_ready"});let u=t.now(),R=960,S=200,A=new Uint8Array(R*S*4).fill(255);try{await Ee(n,A,R,S,{detectorLimit:r,salt:s,now:t.now})}catch{return a({id:m,kind:"error",code:"OCR_INFERENCE_FAILED"})}a({id:m,kind:"ready",warmupMs:Math.round(t.now()-u),downloadMs:o,cached:i})}async function y(m){switch(m.kind){case"init":return d(m);case"warmup":return p(m.id);case"band":return b(m.id,m.bitmap,void 0,m.detectorLimit);case"still":return b(m.id,m.bitmap,m.region,m.detectorLimit);case"layout":return f(m.id,m.bitmap,m.detectorLimit);case"dispose":n?.dispose(),n=null,e.close();return}}e.onmessage=m=>{let u=m.data;l=l.then(()=>y(u)).catch(()=>a({id:u.id,kind:"error",code:"OCR_INFERENCE_FAILED"}))}}typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&ft(self);0&&(module.exports={defaultDeps,installOcrWorkerHost});
40
+ `).length+2}var ln=e=>Number.isInteger(e)&&e>=F.NONE&&e<=F.BOTH,un=(e,t)=>e.every((n,i)=>n===t[i]);function dn(e){let t=e.split(`
41
+ `);return t.length===37&&new Set(t).size===37&&t.every(n=>/^[0-9A-Z<]$/.test(n))&&mt(e)===39}async function pt(e){let t=await dt({instantiateWasm:(n,i)=>(WebAssembly.instantiate(e,n).then(r=>i(r,e)),{})});return new me(t)}var Qn=Object.freeze({low:Object.freeze({stride:1,bandWidthPx:960}),mid:Object.freeze({stride:2,bandWidthPx:1280}),high:Object.freeze({stride:1,bandWidthPx:1280})});function bt(){let n=new Uint8Array(1228800).fill(255),i=24301,r=()=>(i=i*1103515245+12345&2147483647,i/2147483647),s=(d,p)=>{let f=(p*960+d)*4;n[f]=20,n[f+1]=20,n[f+2]=20},o=20,c=14,a=28;for(let d of[110,190])for(let p=0;p<44;p++){let f=40+p*o;if(r()<.25){for(let b=0;b<c/2;b++)for(let l=0;l<2;l++)s(f+c/2-b,d+a/2-b+l),s(f+c/2-b,d+a/2+b+l);continue}let g=Math.floor(r()*(c-3));for(let b=0;b<a;b++)for(let l=0;l<3;l++)s(f+g+l,d+b);for(let b of[0,a/2-1,a-3])if(!(r()<.4))for(let l=0;l<c;l++)for(let u=0;u<3;u++)s(f+l,d+b+u)}return{rgba:n,width:960,height:320}}function fn(){let e=null,t=null;return(n,i)=>{if(typeof OffscreenCanvas!="function"||(e||(e=new OffscreenCanvas(n,i),t=e.getContext("2d",{willReadFrequently:!0})),!t))return null;(e.width!==n||e.height!==i)&&(e.width=n,e.height=i);let r=t;return{draw(s){return r.clearRect(0,0,n,i),r.drawImage(s,0,0),r.getImageData(0,0,n,i).data}}}}function gt(){return{fetch:(...e)=>fetch(...e),now:()=>performance.now(),canvas:fn(),instantiate:pt}}function yt(e,t=gt()){let n=null,i="",r=960,s=0,o=!1,c=Promise.resolve(),a=l=>e.postMessage(l);async function d(l){if(t.canvas(1,1)===null)return a({id:l.id,kind:"failed",reason:"unsupported"});i=l.salt,r=l.detectorLimit;try{let u=await Le(l.baseUrl,Oe,l.maxDownloadMs,t.fetch,t.now);s=u.downloadMs,o=u.cached;let S=await WebAssembly.compile(u.files.get("sekyro-ocr.wasm")),R=await t.instantiate(S),x=new TextDecoder("utf-8",{fatal:!0}).decode(u.files.get("mrz_dict.txt"));R.load(C.DETECTOR,u.files.get("det.param"),u.files.get("det.bin")),R.load(C.LATIN,u.files.get("mrz-rec.param"),u.files.get("mrz-rec.bin"),x,{mrz:!0}),u.files.clear(),n=R,a({id:l.id,kind:"ready",warmupMs:0,downloadMs:s,cached:o})}catch(u){a({id:l.id,kind:"failed",reason:u instanceof z?u.reason:"error"})}}async function p(l,u,S,R){if(!n)return u.close(),a({id:l,kind:"error",code:"not_ready"});let x=u.width,L=u.height,w=t.canvas(x,L);if(!w)return u.close(),a({id:l,kind:"failed",reason:"unsupported"});let K=w.draw(u);u.close();try{a({id:l,...await ct(n,K,x,L,{detectorLimit:R,salt:i,region:S,now:t.now})})}catch{a({id:l,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function f(l,u,S){if(!n)return u.close(),a({id:l,kind:"error",code:"not_ready"});let R=u.width,x=u.height,L=t.canvas(R,x);if(!L)return u.close(),a({id:l,kind:"failed",reason:"unsupported"});let w=L.draw(u);u.close();try{let K=t.now(),W=n.read(w,R,x,[0,0,1,1],1,oe,F.NONE,S);a({id:l,kind:"layout",ms:Math.round(t.now()-K),lineBoxes:lt(W.map(V=>V.box),R,x)})}catch{a({id:l,kind:"error",code:"OCR_INFERENCE_FAILED"})}}async function g(l){if(!n)return a({id:l,kind:"error",code:"not_ready"});let u=bt(),S=()=>n.read(u.rgba,u.width,u.height,[0,0,1,1],1,oe,F.LATIN,960),R,x;try{let L=t.now();S();let w=t.now();S(),R=Math.round(w-L),x=Math.round(t.now()-w)}catch{return a({id:l,kind:"error",code:"OCR_INFERENCE_FAILED"})}a({id:l,kind:"ready",warmupMs:R,benchMs:x,downloadMs:s,cached:o})}async function b(l){switch(l.kind){case"init":return d(l);case"warmup":return g(l.id);case"band":return p(l.id,l.bitmap,void 0,l.detectorLimit);case"still":return p(l.id,l.bitmap,l.region,l.detectorLimit);case"layout":return f(l.id,l.bitmap,l.detectorLimit);case"dispose":n?.dispose(),n=null,e.close();return}}e.onmessage=l=>{let u=l.data;c=c.then(()=>b(u)).catch(()=>a({id:u.id,kind:"error",code:"OCR_INFERENCE_FAILED"}))}}typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&yt(self);0&&(module.exports={defaultDeps,installOcrWorkerHost});