@recogito/text-annotator 3.4.5 → 3.4.6

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.
@@ -1,3 +1,3 @@
1
- (function(B,ke){typeof exports=="object"&&typeof module<"u"?ke(exports):typeof define=="function"&&define.amd?define(["exports"],ke):(B=typeof globalThis<"u"?globalThis:B||self,ke(B.RecogitoJS={}))})(this,(function(B){"use strict";const ke="not-annotatable",Ne=`.${ke}`,We=(e,t)=>{var i;return e.contains(t)?!!(t instanceof HTMLElement?t.closest(Ne):(i=t.parentElement)==null?void 0:i.closest(Ne)):!0},vn=(e,t)=>{const n=t.commonAncestorContainer;return!We(e,n)},An=e=>e.addEventListener("click",t=>{!t.target.closest(Ne)&&!t.target.closest("a")&&t.preventDefault()}),bt=e=>({...e,type:e.type,x:e.x,y:e.y,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,screenX:e.screenX,screenY:e.screenY,isPrimary:e.isPrimary,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,button:e.button,buttons:e.buttons,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,eventPhase:e.eventPhase,pointerId:e.pointerId,pointerType:e.pointerType,timeStamp:e.timeStamp}),je=e=>({...e,type:e.type,key:e.key,code:e.code,location:e.location,repeat:e.repeat,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,timeStamp:e.timeStamp});var Fi="2.0.6",Yi=500,En="user-agent",_e="",Sn="?",$={FUNCTION:"function",OBJECT:"object",STRING:"string",UNDEFINED:"undefined"},ne="browser",we="cpu",ue="device",le="engine",oe="os",Ue="result",v="name",p="type",A="vendor",E="version",te="architecture",$e="major",b="model",ze="console",H="mobile",K="tablet",z="smarttv",fe="wearable",wt="xr",qe="embedded",De="inapp",Dt="brands",Le="formFactors",Ht="fullVersionList",He="platform",Pt="platformVersion",yt="bitness",Se="sec-ch-ua",Ki=Se+"-full-version-list",Wi=Se+"-arch",ji=Se+"-"+yt,$i=Se+"-form-factors",zi=Se+"-"+H,qi=Se+"-"+b,Cn=Se+"-"+He,Gi=Cn+"-version",On=[Dt,Ht,H,b,He,Pt,te,Le,yt],vt="Amazon",Pe="Apple",xn="ASUS",Tn="BlackBerry",Ie="Google",Rn="Huawei",Vt="Lenovo",kn="Honor",At="LG",Xt="Microsoft",Ft="Motorola",Yt="Nvidia",Nn="OnePlus",Kt="OPPO",Ge="Samsung",Ln="Sharp",Je="Sony",Wt="Xiaomi",jt="Zebra",In="Chrome",Mn="Chromium",Ce="Chromecast",Et="Edge",Qe="Firefox",Ze="Opera",$t="Facebook",Bn="Sogou",Ve="Mobile ",et=" Browser",zt="Windows",Ji=typeof window!==$.UNDEFINED,ie=Ji&&window.navigator?window.navigator:void 0,Oe=ie&&ie.userAgentData?ie.userAgentData:void 0,Qi=function(e,t){var n={},i=t;if(!Ct(t)){i={};for(var o in t)for(var r in t[o])i[r]=t[o][r].concat(i[r]?i[r]:[])}for(var s in e)n[s]=i[s]&&i[s].length%2===0?i[s].concat(e[s]):e[s];return n},St=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},qt=function(e,t){if(typeof e===$.OBJECT&&e.length>0){for(var n in e)if(xe(t)==xe(e[n]))return!0;return!1}return tt(e)?xe(t)==xe(e):!1},Ct=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?Ct(e[n]):!1)},tt=function(e){return typeof e===$.STRING},Gt=function(e){if(e){for(var t=[],n=Xe(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var o=Ot(n[i]).split(";v=");t[i]={brand:o[0],version:o[1]}}else t[i]=Ot(n[i]);return t}},xe=function(e){return tt(e)?e.toLowerCase():e},Jt=function(e){return tt(e)?Xe(/[^\d\.]/g,e).split(".")[0]:void 0},ye=function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];typeof n==$.OBJECT&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Xe=function(e,t){return tt(t)?t.replace(e,_e):t},nt=function(e){return Xe(/\\?\"/g,e)},Ot=function(e,t){return e=Xe(/^\s\s*/,String(e)),typeof t===$.UNDEFINED?e:e.substring(0,t)},Qt=function(e,t){if(!(!e||!t))for(var n=0,i,o,r,s,a,l;n<t.length&&!a;){var c=t[n],u=t[n+1];for(i=o=0;i<c.length&&!a&&c[i];)if(a=c[i++].exec(e),a)for(r=0;r<u.length;r++)l=a[++o],s=u[r],typeof s===$.OBJECT&&s.length>0?s.length===2?typeof s[1]==$.FUNCTION?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]===$.FUNCTION&&!(s[1].exec&&s[1].test)?s.length>3?this[s[0]]=l?s[1].apply(this,s.slice(2)):void 0:this[s[0]]=l?s[1].call(this,l,s[2]):void 0:s.length==3?this[s[0]]=l?l.replace(s[1],s[2]):void 0:s.length==4?this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):void 0:s.length>4&&(this[s[0]]=l?s[3].apply(this,[l.replace(s[1],s[2])].concat(s.slice(4))):void 0)):this[s]=l||void 0;n+=2}},he=function(e,t){for(var n in t)if(typeof t[n]===$.OBJECT&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(qt(t[n][i],e))return n===Sn?void 0:n}else if(qt(t[n],e))return n===Sn?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},_n={ME:"4.90","NT 3.51":"3.51","NT 4.0":"4.0",2e3:["5.0","5.01"],XP:["5.1","5.2"],Vista:"6.0",7:"6.1",8:"6.2","8.1":"6.3",10:["6.4","10.0"],NT:""},Un={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},Zi={Chrome:"Google Chrome",Edge:"Microsoft Edge","Edge WebView2":"Microsoft Edge WebView2","Chrome WebView":"Android WebView","Chrome Headless":"HeadlessChrome","Huawei Browser":"HuaweiBrowser","MIUI Browser":"Miui Browser","Opera Mobi":"OperaMobile",Yandex:"YaBrowser"},Dn={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[E,[v,Ve+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[E,[v,Et+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[E,[v,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[v,E],[/opios[\/ ]+([\w\.]+)/i],[E,[v,Ze+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[E,[v,Ze+" GX"]],[/\bopr\/([\w\.]+)/i],[E,[v,Ze]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[E,[v,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[E,[v,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:lg |qute)browser|palemoon)\/([-\w\.]+)/i,/(heytap|ovi|115|surf|qwant)browser\/([\d\.]+)/i,/(qwant)(?:ios|mobile)\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[v,E],[/quark(?:pc)?\/([-\w\.]+)/i],[E,[v,"Quark"]],[/\bddg\/([\w\.]+)/i],[E,[v,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[E,[v,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[E,[v,"WeChat"]],[/konqueror\/([\w\.]+)/i],[E,[v,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[E,[v,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[E,[v,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[E,[v,"Smart "+Vt+et]],[/(avast|avg)\/([\w\.]+)/i],[[v,/(.+)/,"$1 Secure"+et],E],[/\bfocus\/([\w\.]+)/i],[E,[v,Qe+" Focus"]],[/\bopt\/([\w\.]+)/i],[E,[v,Ze+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[E,[v,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[E,[v,"Dolphin"]],[/coast\/([\w\.]+)/i],[E,[v,Ze+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[E,[v,"MIUI"+et]],[/fxios\/([\w\.-]+)/i],[E,[v,Ve+Qe]],[/\bqihoobrowser\/?([\w\.]*)/i],[E,[v,"360"]],[/\b(qq)\/([\w\.]+)/i],[[v,/(.+)/,"$1Browser"],E],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[v,/(.+)/,"$1"+et],E],[/samsungbrowser\/([\w\.]+)/i],[E,[v,Ge+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[E,[v,Bn+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[v,Bn+" Mobile"],E],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[v,E],[/(lbbrowser|rekonq)/i],[v],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[E,v],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[v,$t],E,[p,De]],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(bing)(?:web|sapphire)\/([\w\.]+)/i,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[v,E,[p,De]],[/\bgsa\/([\w\.]+) .*safari\//i],[E,[v,"GSA"],[p,De]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[E,[v,"TikTok"],[p,De]],[/\[(linkedin)app\]/i],[v,[p,De]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[v,/(.+)/,"Zalo"],E,[p,De]],[/(chromium)[\/ ]([-\w\.]+)/i],[v,E],[/headlesschrome(?:\/([\w\.]+)| )/i],[E,[v,In+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[E,[v,Et+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[v,In+" WebView"],E],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[E,[v,"Android"+et]],[/chrome\/([\w\.]+) mobile/i],[E,[v,Ve+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[v,E],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[E,[v,Ve+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[v,Ve+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[E,v],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[v,[E,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[v,E],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[v,Ve+Qe],E],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[v,"Netscape"],E],[/(wolvic|librewolf)\/([\w\.]+)/i],[v,E],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[E,[v,Qe+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+(?= .+rv\:.+gecko\/\d+)|[0-4][\w\.]+(?!.+compatible))/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[v,[E,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[v,[E,/[^\d\.]+./,_e]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[te,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[te,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[te,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[te,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[te,"arm"]],[/ sun4\w[;\)]/i],[[te,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i,/((ppc|powerpc)(64)?)( mac|;|\))/i,/(?:osf1|[freopnt]{3,4}bsd) (alpha)/i],[[te,/ower/,_e,xe]],[/mc680.0/i],[[te,"68k"]],[/winnt.+\[axp/i],[[te,"alpha"]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[b,[A,Ge],[p,K]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,/sec-(sgh\w+)/i],[b,[A,Ge],[p,H]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)[\/\);]/i],[b,[A,Pe],[p,H]],[/\b(?:ios|apple\w+)\/.+[\(\/](ipad)/i,/\b(ipad)[\d,]*[;\] ].+(mac |i(pad)?)os/i],[b,[A,Pe],[p,K]],[/(macintosh);/i],[b,[A,Pe]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[b,[A,Ln],[p,H]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[b,[A,kn],[p,K]],[/honor([-\w ]+)[;\)]/i],[b,[A,kn],[p,H]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[b,[A,Rn],[p,K]],[/(?:huawei) ?([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i],[b,[A,Rn],[p,H]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b(?:xiao)?((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[b,/_/g," "],[A,Wt],[p,K]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note|max|cc)?[_ ]?(?:\d{0,2}\w?)[_ ]?(?:plus|se|lite|pro)?( 5g|lte)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[b,/_/g," "],[A,Wt],[p,H]],[/droid.+; (cph2[3-6]\d[13579]|((gm|hd)19|(ac|be|in|kb)20|(d[en]|eb|le|mt)21|ne22)[0-2]\d|p[g-k]\w[1m]10)\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[b,[A,Nn],[p,H]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[b,[A,Kt],[p,H]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[b,[A,he,{OnePlus:["203","304","403","404","413","415"],"*":Kt}],[p,K]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[b,[A,"BLU"],[p,H]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[b,[A,"Vivo"],[p,H]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[b,[A,"Realme"],[p,H]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[b,[A,Vt],[p,K]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[b,[A,Vt],[p,H]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,/((?:moto(?! 360)[-\w\(\) ]+|xt\d{3,4}[cgkosw\+]?[-\d]*|nexus 6)(?= bui|\)))/i],[b,[A,Ft],[p,H]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[b,[A,Ft],[p,K]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[b,[A,At],[p,K]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,/\blg-?([\d\w]+) bui/i],[b,[A,At],[p,H]],[/(nokia) (t[12][01])/i],[A,b,[p,K]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*?))( bui|\)|;|\/)/i],[[b,/_/g," "],[p,H],[A,"Nokia"]],[/(pixel (c|tablet))\b/i],[b,[A,Ie],[p,K]],[/droid.+;(?: google)? (g(01[13]a|020[aem]|025[jn]|1b60|1f8f|2ybb|4s1m|576d|5nz6|8hhn|8vou|a02099|c15s|d1yq|e2ae|ec77|gh2x|kv4x|p4bc|pj41|r83y|tt9q|ur25|wvk6)|pixel[\d ]*a?( pro)?( xl)?( fold)?( \(5g\))?)( bui|\))/i],[b,[A,Ie],[p,H]],[/(google) (pixelbook( go)?)/i],[A,b],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-\w\w\d\d)(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[b,[A,Je],[p,H]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[b,"Xperia Tablet"],[A,Je],[p,K]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[b,[A,vt],[p,K]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[b,/(.+)/g,"Fire Phone $1"],[A,vt],[p,H]],[/(playbook);[-\w\),; ]+(rim)/i],[b,A,[p,K]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/(?:blackberry|\(bb10;) (\w+)/i],[b,[A,Tn],[p,H]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[b,[A,xn],[p,K]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[b,[A,xn],[p,H]],[/(nexus 9)/i],[b,[A,"HTC"],[p,K]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[A,[b,/_/g," "],[p,H]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[b,[A,"TCL"],[p,K]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[b,[A,"TCL"],[p,H]],[/(itel) ((\w+))/i],[[A,xe],b,[p,he,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[b,[A,"Acer"],[p,K]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[b,[A,"Meizu"],[p,H]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[b,[A,"Ulefone"],[p,H]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[b,[A,"Energizer"],[p,H]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[b,[A,"Cat"],[p,H]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[b,[A,"Smartfren"],[p,H]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[b,[A,"Nothing"],[p,H]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[b,[A,"Archos"],[p,K]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[b,[A,"Archos"],[p,H]],[/; (n159v)/i],[b,[A,"HMD"],[p,H]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[A,b,[p,K]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|hmd|imo|infinix|lava|oneplus|tcl|wiko)[_ ]([\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i,/(hisense) ([ehv][\w ]+)\)/i,/droid[^;]+; (philips)[_ ]([sv-x][\d]{3,4}[xz]?)/i],[A,b,[p,H]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[A,b,[p,K]],[/(surface duo)/i],[b,[A,Xt],[p,K]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[b,[A,"Fairphone"],[p,H]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[b,[A,Yt],[p,K]],[/(sprint) (\w+)/i],[A,b,[p,H]],[/(kin\.[onetw]{3})/i],[[b,/\./g," "],[A,Xt],[p,H]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[b,[A,jt],[p,K]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[b,[A,jt],[p,H]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[A,[p,z]],[/hbbtv.+maple;(\d+)/i],[[b,/^/,"SmartTV"],[A,Ge],[p,z]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[A,b,[p,z]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[A,At],[p,z]],[/(apple) ?tv/i],[A,[b,Pe+" TV"],[p,z]],[/crkey.*devicetype\/chromecast/i],[[b,Ce+" Third Generation"],[A,Ie],[p,z]],[/crkey.*devicetype\/([^/]*)/i],[[b,/^/,"Chromecast "],[A,Ie],[p,z]],[/fuchsia.*crkey/i],[[b,Ce+" Nest Hub"],[A,Ie],[p,z]],[/crkey/i],[[b,Ce],[A,Ie],[p,z]],[/(portaltv)/i],[b,[A,$t],[p,z]],[/droid.+aft(\w+)( bui|\))/i],[b,[A,vt],[p,z]],[/(shield \w+ tv)/i],[b,[A,Yt],[p,z]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[b,[A,Ln],[p,z]],[/(bravia[\w ]+)( bui|\))/i],[b,[A,Je],[p,z]],[/(mi(tv|box)-?\w+) bui/i],[b,[A,Wt],[p,z]],[/Hbbtv.*(technisat) (.*);/i],[A,b,[p,z]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[A,/.+\/(\w+)/,"$1",he,{LG:"lge"}],[b,Ot],[p,z]],[/(playstation \w+)/i],[b,[A,Je],[p,ze]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[b,[A,Xt],[p,ze]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[A,b,[p,ze]],[/droid.+; (shield)( bui|\))/i],[b,[A,Yt],[p,ze]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[b,[A,Ge],[p,fe]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[A,b,[p,fe]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[b,[A,Kt],[p,fe]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[b,[A,Pe],[p,fe]],[/(opwwe\d{3})/i],[b,[A,Nn],[p,fe]],[/(moto 360)/i],[b,[A,Ft],[p,fe]],[/(smartwatch 3)/i],[b,[A,Je],[p,fe]],[/(g watch r)/i],[b,[A,At],[p,fe]],[/droid.+; (wt63?0{2,3})\)/i],[b,[A,jt],[p,fe]],[/droid.+; (glass) \d/i],[b,[A,Ie],[p,wt]],[/(pico) ([\w ]+) os\d/i],[A,b,[p,wt]],[/(quest( \d| pro)?s?).+vr/i],[b,[A,$t],[p,wt]],[/mobile vr; rv.+firefox/i],[[p,wt]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[A,[p,qe]],[/(aeobc)\b/i],[b,[A,vt],[p,qe]],[/(homepod).+mac os/i],[b,[A,Pe],[p,qe]],[/windows iot/i],[[p,qe]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[b,[p,z]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[p,z]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew|; hmsc).+?(mobile|vr|\d) safari/i],[b,[p,he,{mobile:"Mobile",xr:"VR","*":K}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[p,K]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[p,H]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[b,[A,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[E,[v,Et+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[v,E],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[E,[v,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[v,E],[/ladybird\//i],[[v,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[E,v]],os:[[/(windows nt) (6\.[23]); arm/i],[[v,/N/,"R"],[E,he,_n]],[/(windows (?:phone|mobile|iot))(?: os)?[\/ ]?([\d\.]*( se)?)/i,/(windows)[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i],[v,E],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[E,/(;|\))/g,"",he,_n],[v,zt]],[/(windows ce)\/?([\d\.]*)/i],[v,E],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv|ios(?=.+ip(?:ad|hone))|ip(?:ad|hone)(?: |.+i(?:pad)?)os)[\/ ]([\w\.]+)/i,/cfnetwork\/.+darwin/i],[[E,/_/g,"."],[v,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[v,"macOS"],[E,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[E,[v,Ce+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[E,[v,Ce+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[E,[v,Ce+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[E,[v,Ce+" Linux"]],[/crkey\/([\d\.]+)/i],[E,[v,Ce]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[E,v],[/(ubuntu) ([\w\.]+) like android/i],[[v,/(.+)/,"$1 Touch"],E],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[v,E],[/\(bb(10);/i],[E,[v,Tn]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[E,[v,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[E,[v,Qe+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[E,[v,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[E,he,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[v,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[E,[v,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[v,"Chrome OS"],E],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/linux.+(mint)[\/\(\) ]?([\w\.]*)/i,/(mageia|vectorlinux|fuchsia|arcaos|arch(?= ?linux))[;l ]([\d\.]*)/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire|knoppix)(?: gnu[\/ ]linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/\b(aix)[; ]([1-9\.]{0,4})/i,/(hurd|linux|morphos)(?: (?:arm|x86|ppc)\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) ?(r\d)?/i],[v,E],[/(sunos) ?([\d\.]*)/i],[[v,"Solaris"],E],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[v,E]]},xt=(function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return ye.call(e.init,[[ne,[v,E,$e,p]],[we,[te]],[ue,[p,b,A]],[le,[v,E]],[oe,[v,E]]]),ye.call(e.isIgnore,[[ne,[E,$e]],[le,[E]],[oe,[E]]]),ye.call(e.isIgnoreRgx,[[ne,/ ?browser$/i],[oe,/ ?os$/i]]),ye.call(e.toString,[[ne,[v,E]],[we,[te]],[ue,[A,b]],[le,[v,E]],[oe,[v,E]]]),e})(),eo=function(e,t){var n=xt.init[t],i=xt.isIgnore[t]||0,o=xt.isIgnoreRgx[t]||0,r=xt.toString[t]||0;function s(){ye.call(this,n)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Oe?Oe.getHighEntropyValues(On).then(function(a){return e.setCH(new Hn(a,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=Ue&&(s.prototype.is=function(a){var l=!1;for(var c in this)if(this.hasOwnProperty(c)&&!qt(i,c)&&xe(o?Xe(o,this[c]):this[c])==xe(o?Xe(o,a):a)){if(l=!0,a!=$.UNDEFINED)break}else if(a==$.UNDEFINED&&l){l=!l;break}return l},s.prototype.toString=function(){var a=_e;for(var l in r)typeof this[r[l]]!==$.UNDEFINED&&(a+=(a?" ":_e)+this[r[l]]);return a||$.UNDEFINED}),Oe||(s.prototype.then=function(a){var l=this,c=function(){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d])};c.prototype={is:s.prototype.is,toString:s.prototype.toString};var u=new c;return a(u),u}),new s};function Hn(e,t){if(e=e||{},ye.call(this,On),t)ye.call(this,[[Dt,Gt(e[Se])],[Ht,Gt(e[Ki])],[H,/\?1/.test(e[zi])],[b,nt(e[qi])],[He,nt(e[Cn])],[Pt,nt(e[Gi])],[te,nt(e[Wi])],[Le,Gt(e[$i])],[yt,nt(e[ji])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==$.UNDEFINED&&(this[n]=e[n])}function Pn(e,t,n,i){return this.get=function(o){return o?this.data.hasOwnProperty(o)?this.data[o]:void 0:this.data},this.set=function(o,r){return this.data[o]=r,this},this.setCH=function(o){return this.uaCH=o,this},this.detectFeature=function(){if(ie&&ie.userAgent==this.ua)switch(this.itemType){case ne:ie.brave&&typeof ie.brave.isBrave==$.FUNCTION&&this.set(v,"Brave");break;case ue:!this.get(p)&&Oe&&Oe[H]&&this.set(p,H),this.get(b)=="Macintosh"&&ie&&typeof ie.standalone!==$.UNDEFINED&&ie.maxTouchPoints&&ie.maxTouchPoints>2&&this.set(b,"iPad").set(p,K);break;case oe:!this.get(v)&&Oe&&Oe[He]&&this.set(v,Oe[He]);break;case Ue:var o=this.data,r=function(s){return o[s].getItem().detectFeature().get()};this.set(ne,r(ne)).set(we,r(we)).set(ue,r(ue)).set(le,r(le)).set(oe,r(oe))}return this},this.parseUA=function(){switch(this.itemType!=Ue&&Qt.call(this.data,this.ua,this.rgxMap),this.itemType){case ne:this.set($e,Jt(this.get(E)));break;case oe:if(this.get(v)=="iOS"&&this.get(E)=="18.6"){var o=/\) Version\/([\d\.]+)/.exec(this.ua);o&&parseInt(o[1].substring(0,2),10)>=26&&this.set(E,o[1])}break}return this},this.parseCH=function(){var o=this.uaCH,r=this.rgxMap;switch(this.itemType){case ne:case le:var s=o[Ht]||o[Dt],a;if(s)for(var l=0;l<s.length;l++){var c=s[l].brand||s[l],u=s[l].version;this.itemType==ne&&!/not.a.brand/i.test(c)&&(!a||/Chrom/.test(a)&&c!=Mn||a==Et&&/WebView2/.test(c))&&(c=he(c,Zi),a=this.get(v),a&&!/Chrom/.test(a)&&/Chrom/.test(c)||this.set(v,c).set(E,u).set($e,Jt(u)),a=c),this.itemType==le&&c==Mn&&this.set(E,u)}break;case we:var d=o[te];d&&(d&&o[yt]=="64"&&(d+="64"),Qt.call(this.data,d+";",r));break;case ue:if(o[H]&&this.set(p,H),o[b]&&(this.set(b,o[b]),!this.get(p)||!this.get(A))){var w={};Qt.call(w,"droid 9; "+o[b]+")",r),!this.get(p)&&w.type&&this.set(p,w.type),!this.get(A)&&w.vendor&&this.set(A,w.vendor)}if(o[Le]){var m;if(typeof o[Le]!="string")for(var h=0;!m&&h<o[Le].length;)m=he(o[Le][h++],Un);else m=he(o[Le],Un);this.set(p,m)}break;case oe:var y=o[He];if(y){var x=o[Pt];y==zt&&(x=parseInt(Jt(x),10)>=13?"11":"10"),this.set(v,y).set(E,x)}this.get(v)==zt&&o[b]=="Xbox"&&this.set(v,"Xbox").set(E,void 0);break;case Ue:var g=this.data,f=function(M){return g[M].getItem().setCH(o).parseCH().get()};this.set(ne,f(ne)).set(we,f(we)).set(ue,f(ue)).set(le,f(le)).set(oe,f(oe))}return this},ye.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",n],["data",eo(this,e)]]),this}function ve(e,t,n){if(typeof e===$.OBJECT?(Ct(e,!0)?(typeof t===$.OBJECT&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===$.STRING&&!Ct(t,!0)&&(n=t,t=void 0),n)if(typeof n.append===$.FUNCTION){var i={};n.forEach(function(u,d){i[String(d).toLowerCase()]=u}),n=i}else{var o={};for(var r in n)n.hasOwnProperty(r)&&(o[String(r).toLowerCase()]=n[r]);n=o}if(!(this instanceof ve))return new ve(e,t,n).getResult();var s=typeof e===$.STRING?e:n&&n[En]?n[En]:ie&&ie.userAgent?ie.userAgent:_e,a=new Hn(n,!0),l=t?Qi(Dn,t):Dn,c=function(u){return u==Ue?function(){return new Pn(u,s,l,a).set("ua",s).set(ne,this.getBrowser()).set(we,this.getCPU()).set(ue,this.getDevice()).set(le,this.getEngine()).set(oe,this.getOS()).get()}:function(){return new Pn(u,s,l[u],a).parseUA().get()}};return ye.call(this,[["getBrowser",c(ne)],["getCPU",c(we)],["getDevice",c(ue)],["getEngine",c(le)],["getOS",c(oe)],["getResult",c(Ue)],["getUA",function(){return s}],["setUA",function(u){return tt(u)&&(s=Ot(u,Yi)),this}]]).setUA(s),this}ve.VERSION=Fi,ve.BROWSER=St([v,E,$e,p]),ve.CPU=St([te]),ve.DEVICE=St([b,A,p,ze,H,z,K,fe,qe]),ve.ENGINE=ve.OS=St([v,E]);const to=Object.freeze({AIX:"AIX",AMIGA_OS:"Amiga OS",ANDROID:"Android",ANDROID_X86:"Android-x86",ARCAOS:"ArcaOS",ARCH:"Arch",BADA:"Bada",BEOS:"BeOS",BLACKBERRY:"BlackBerry",CENTOS:"CentOS",CHROME_OS:"Chrome OS",CHROMECAST:"Chromecast",CHROMECAST_ANDROID:"Chromecast Android",CHROMECAST_FUCHSIA:"Chromecast Fuchsia",CHROMECAST_LINUX:"Chromecast Linux",CHROMECAST_SMARTSPEAKER:"Chromecast SmartSpeaker",CONTIKI:"Contiki",DEBIAN:"Debian",DEEPIN:"Deepin",DRAGONFLY:"DragonFly",ELEMENTARY_OS:"elementary OS",FEDORA:"Fedora",FIREFOX_OS:"Firefox OS",FREEBSD:"FreeBSD",FUCHSIA:"Fuchsia",GENTOO:"Gentoo",GHOSTBSD:"GhostBSD",GNU:"GNU",HAIKU:"Haiku",HARMONYOS:"HarmonyOS",HP_UX:"HP-UX",HURD:"Hurd",IOS:"iOS",JOLI:"Joli",KAIOS:"KaiOS",KNOPPIX:"Knoppix",KUBUNTU:"Kubuntu",LINPUS:"Linpus",LINSPIRE:"Linspire",LINUX:"Linux",MACOS:"macOS",MAEMO:"Maemo",MAGEIA:"Mageia",MANDRIVA:"Mandriva",MANJARO:"Manjaro",MEEGO:"MeeGo",MINIX:"Minix",MINT:"Mint",MORPH_OS:"Morph OS",NETBSD:"NetBSD",NETRANGE:"NetRange",NETTV:"NetTV",NINTENDO:"Nintendo",OPENHARMONY:"OpenHarmony",OPENBSD:"OpenBSD",OPENVMS:"OpenVMS",OS2:"OS/2",PALM:"Palm",PC_BSD:"PC-BSD",PCLINUXOS:"PCLinuxOS",PICO:"Pico",PLAN9:"Plan9",PLAYSTATION:"PlayStation",QNX:"QNX",RASPBIAN:"Raspbian",REDHAT:"RedHat",RIM_TABLET_OS:"RIM Tablet OS",RISC_OS:"RISC OS",SABAYON:"Sabayon",SAILFISH:"Sailfish",SERENITYOS:"SerenityOS",SERIES40:"Series40",SLACKWARE:"Slackware",SOLARIS:"Solaris",SUSE:"SUSE",SYMBIAN:"Symbian",TIZEN:"Tizen",UBUNTU:"Ubuntu",UBUNTU_TOUCH:"Ubuntu Touch",UNIX:"Unix",VECTORLINUX:"VectorLinux",WATCHOS:"watchOS",WEBOS:"WebOS",WINDOWS:"Windows",WINDOWS_CE:"Windows CE",WINDOWS_IOT:"Windows IoT",WINDOWS_MOBILE:"Windows Mobile",WINDOWS_PHONE:"Windows Phone",WINDOWS_RT:"Windows RT",XBOX:"Xbox",XUBUNTU:"Xubuntu",ZENWALK:"Zenwalk"}),Zt=ve().os.is(to.MACOS),Vn=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},Xn=e=>{const t=[],n=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT);let i;for(;i=n.nextNode();)e.intersectsNode(i)&&t.push(i);if(t.length<2)return Array.from(e.getClientRects());{const o=t[0],r=t[t.length-1],s=document.createRange();if(s.selectNode(o),e.startContainer.nodeType===Node.TEXT_NODE)s.setStart(o,e.startOffset);else{const c=e.startContainer.childNodes[e.startOffset];c?s.setStartBefore(c):s.setStartAfter(e.startContainer)}const a=document.createRange();if(a.selectNode(r),e.endContainer.nodeType===Node.TEXT_NODE)a.setEnd(r,e.endOffset);else{const c=e.endContainer.childNodes[e.endOffset];c?a.setEndBefore(c):a.setEndAfter(e.endContainer)}const l=c=>{const u=document.createRange();return u.selectNode(c),Array.from(u.getClientRects())};return[...Array.from(s.getClientRects()),...t.slice(1,-1).flatMap(l),...Array.from(a.getClientRects())]}},no=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,i=>i instanceof HTMLElement&&i.classList.contains(ke)&&!i.parentElement.closest(Ne)&&e.intersectsNode(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Fn=(e,t)=>{if(!vn(e,t))return[];const n=[];let i=null;for(const o of no(t)){let r;i?(r=document.createRange(),r.setStartAfter(i),r.setEndBefore(o)):(r=t.cloneRange(),r.setEndBefore(o)),r.collapsed||n.push(r),i=o}if(i){const o=t.cloneRange();o.setStartAfter(i),o.collapsed||n.push(o)}return n.length>0?n:[t]},Tt=e=>{const t=e.cloneContents();return t.querySelectorAll(Ne).forEach(n=>n.remove()),t},Yn=(e,t,n=10,i)=>{const o=i?e.startContainer.parentElement.closest(i):t,r=document.createRange();r.setStart(o,0),r.setEnd(e.startContainer,e.startOffset);const s=Tt(r).textContent,a=document.createRange();a.setStart(e.endContainer,e.endOffset),o===document.body?a.setEnd(o,o.childNodes.length):a.setEndAfter(o);const l=Tt(a).textContent;return{prefix:s.substring(s.length-n),suffix:l.substring(0,n)}},ge=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),en=/^\s*$/,Kn=e=>en.test(e.toString()),io=e=>en.test(e.textContent||""),oo=(e,t,n,i)=>{const o=a=>Math.round(a*10)/10,r={top:o(e.top),bottom:o(e.bottom),left:o(e.left),right:o(e.right)},s={top:o(t.top),bottom:o(t.bottom),left:o(t.left),right:o(t.right)};if(Math.abs(r.top-s.top)<i&&Math.abs(r.bottom-s.bottom)<i){if(Math.abs(r.left-s.right)<n||Math.abs(r.right-s.left)<n)return"inline-adjacent";if(r.left>=s.left&&r.right<=s.right)return"inline-is-contained";if(r.left<=s.left&&r.right>=s.right)return"inline-contains"}else if(r.top<=s.top&&r.bottom>=s.bottom){if(r.left<=s.left&&r.right>=s.right)return"block-contains"}else if(r.top>=s.top&&r.bottom<=s.bottom&&r.left>=s.left&&r.right<=s.right)return"block-is-contained"},ro=(e,t)=>{const n=Math.min(e.left,t.left),i=Math.max(e.right,t.right),o=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,o,i-n,r-o)},Wn=(e,t=.5,n=.5)=>e.reduce((i,o)=>{if(o.width===0||o.height===0)return i;let r=[...i],s=!1;for(const a of i){const l=oo(o,a,t,n);if(l==="inline-adjacent"){r=r.map(c=>c===a?ro(o,a):c),s=!0;break}else if(l==="inline-contains"){r=r.map(c=>c===a?o:c),s=!0;break}else if(l==="inline-is-contained"){s=!0;break}else if(l==="block-contains"||l==="block-is-contained"){o.width<a.width&&(r=r.map(c=>c===a?o:c)),o.width===a.width&&o.height<a.width&&(r=r.map(c=>c===a?o:c)),s=!0;break}}return s?r:[...r,o]},[]),so=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),jn=e=>{if(e.length===0)return[];if(e.length===1)return[e[0]];e.sort((o,r)=>{const s=o.compareBoundaryPoints(Range.START_TO_START,r);return s!==0?s:o.compareBoundaryPoints(Range.END_TO_END,r)});const[t,...n]=e,i=n.reduce((o,r)=>o.current.compareBoundaryPoints(Range.START_TO_END,r)>=0?(o.current.compareBoundaryPoints(Range.END_TO_END,r)<0&&o.current.setEnd(r.endContainer,r.endOffset),o):(o.merged.push(o.current),o.current=r.cloneRange(),o),{merged:[],current:t.cloneRange()});return[...i.merged,i.current]},$n=(e,t,n)=>{const i=document.createRange(),o=n?e.startContainer.parentElement.closest(n):t;i.setStart(o,0),i.setEnd(e.startContainer,e.startOffset);const r=Tt(i).textContent,s=e.toString(),a=r.length||0,l=a+s.length;return n?{quote:s,start:a,end:l,range:e,offsetReference:o}:{quote:s,start:a,end:l,range:e}},zn=(e,t)=>{const{left:n,top:i,right:o,bottom:r}=e;return new DOMRect(n-t.left,i-t.top,o-n,r-i)},ao=(e,t)=>{const{left:n,top:i,right:o,bottom:r}=e;return new DOMRect(n+t.left,i+t.top,o-n,r-i)},tn=(e,t)=>{var u,d;const{start:n,end:i}=e,o=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,w=>{var m;return(m=w.parentElement)!=null&&m.closest(Ne)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let s=0;const a=document.createRange();let l=r.nextNode();l===null&&console.error("Could not revive annotation target. Content missing.");let c=!o;for(;l!==null;){if(c||(c=typeof(o==null?void 0:o.contains)=="function"?o.contains(l):!1),c){const w=((u=l.textContent)==null?void 0:u.length)||0;if(s+w>n){a.setStart(l,n-s);break}s+=w}l=r.nextNode()}for(;l!==null;){const w=((d=l.textContent)==null?void 0:d.length)||0;if(s+w>=i){a.setEnd(l,i-s);break}s+=w,l=r.nextNode()}return{...e,range:a}},it=(e,t)=>ge(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:tn(n,t))},Rt=(e,t)=>ge(e.target.selector)?e:{...e,target:it(e.target,t)},qn=(e,t)=>{const n=e.cloneRange();return t.contains(n.startContainer)||n.setStart(t,0),t.contains(n.endContainer)||n.setEnd(t,t.childNodes.length),n},Gn=e=>{if(!e)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:Gn(e.parentElement)},Jn=(e,t,n)=>{const i=n.getBoundingClientRect(),o=n.clientHeight,r=n.clientWidth,s=t.selector[0].range.getBoundingClientRect(),{width:a,height:l}=e.getAnnotationBounds(t.annotation),c=s.top-i.top,u=s.left-i.left,d=n.parentElement?n.scrollTop:0,w=n.parentElement?n.scrollLeft:0,m=c+d-(o-l)/2,h=u+w-(r-a)/2;n.scroll({top:m,left:h,behavior:"smooth"})},Qn=(e,t)=>(n,i)=>{const o=typeof n=="string"?n:n.id,r=i?typeof i=="string"?document.getElementById(i):i:Gn(e);if(!r)return console.warn(`The scroll parent is missing for the annotation: ${o}`,{container:e}),!1;const s=t.getAnnotation(o);if(!s)return console.warn(`The annotation is missing in the store: ${o}`),!1;const{range:a}=s.target.selector[0];if(a&&!a.collapsed)return Jn(t,s.target,r),!0;const l=it(s.target,e),{range:c}=l.selector[0];return c&&!c.collapsed?(Jn(t,l,r),!0):!1};function ot(e,t=100,n={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw new RangeError("`wait` must not be negative.");if(typeof n=="boolean")throw new TypeError("The `options` parameter must be an object, not a boolean. Use `{immediate: true}` instead.");const{immediate:i}=n;let o,r,s,a,l;function c(){const w=o,m=r;return o=void 0,r=void 0,l=e.apply(w,m),l}function u(){const w=Date.now()-a;w<t&&w>=0?s=setTimeout(u,t-w):(s=void 0,i||(l=c()))}const d=function(...w){if(o&&this!==o&&Object.getPrototypeOf(this)===Object.getPrototypeOf(o))throw new Error("Debounced method called with different contexts of the same prototype.");o=this,r=w,a=Date.now();const m=i&&!s;if(s||(s=setTimeout(u,t)),m)return l=c(),l};return Object.defineProperty(d,"isPending",{get(){return s!==void 0}}),d.clear=()=>{s&&(clearTimeout(s),s=void 0,o=void 0,r=void 0)},d.flush=()=>{s&&d.trigger()},d.trigger=()=>{l=c(),d.clear()},d}const pe={fill:"rgb(0, 128, 255)",fillOpacity:.18},rt={fill:"rgb(0, 128, 255)",fillOpacity:.45};var Zn=Object.prototype.hasOwnProperty;function Me(e,t){var n,i;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((i=e.length)===t.length)for(;i--&&Me(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(Zn.call(e,n)&&++i&&!Zn.call(t,n)||!(n in t)||!Me(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}let lo=Symbol("clean"),ce=[],Te=0;const kt=4;let nn=e=>{let t=[],n={get(){return n.lc||n.listen(()=>{})(),n.value},lc:0,listen(i){return n.lc=t.push(i),()=>{for(let r=Te+kt;r<ce.length;)ce[r]===i?ce.splice(r,kt):r+=kt;let o=t.indexOf(i);~o&&(t.splice(o,1),--n.lc||n.off())}},notify(i,o){let r=!ce.length;for(let s of t)ce.push(s,n.value,i,o);if(r){for(Te=0;Te<ce.length;Te+=kt)ce[Te](ce[Te+1],ce[Te+2],ce[Te+3]);ce.length=0}},off(){},set(i){let o=n.value;o!==i&&(n.value=i,n.notify(o))},subscribe(i){let o=n.listen(i);return i(n.value),o},value:e};return process.env.NODE_ENV!=="production"&&(n[lo]=()=>{t=[],n.lc=0,n.off()}),n};const co=e=>{const t=nn(null);return e.observe(({changes:n})=>{const i=t.get();if(i){(n.deleted||[]).some(r=>r.id===i)&&t.set(null);const o=(n.updated||[]).find(({oldValue:r})=>r.id===i);o&&t.set(o.newValue.id)}}),{get current(){return t.get()},subscribe:t.subscribe.bind(t),set:t.set.bind(t)}};var on=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(on||{});const rn={selected:[]},uo=(e,t,n)=>{const i=nn(rn);let o=t;const r=()=>{Me(i.get(),rn)||i.set(rn)},s=()=>{var m;return((m=i.get().selected)==null?void 0:m.length)===0},a=m=>{if(s())return!1;const h=typeof m=="string"?m:m.id;return i.get().selected.some(y=>y.id===h)},l=(m,h)=>{let y;if(Array.isArray(m)){if(y=m.map(g=>e.getAnnotation(g)).filter(Boolean),y.length<m.length){console.warn("Invalid selection: "+m.filter(g=>!y.some(f=>f.id===g)));return}}else{const g=e.getAnnotation(m);if(!g){console.warn("Invalid selection: "+m);return}y=[g]}const x=y.reduce((g,f)=>{const M=w(f);return M==="EDIT"?[...g,{id:f.id,editable:!0}]:M==="SELECT"?[...g,{id:f.id}]:g},[]);i.set({selected:x,event:h})},c=(m,h)=>{const y=Array.isArray(m)?m:[m],x=y.map(g=>e.getAnnotation(g)).filter(g=>!!g);i.set({selected:x.map(g=>{const f=h===void 0?w(g)==="EDIT":h;return{id:g.id,editable:f}})}),x.length!==y.length&&console.warn("Invalid selection",m)},u=m=>{if(s())return!1;const{selected:h}=i.get();h.some(({id:y})=>m.includes(y))&&i.set({selected:h.filter(({id:y})=>!m.includes(y))})},d=m=>{o=m,c(i.get().selected.map(({id:h})=>h))},w=m=>fo(m,o,n);return e.observe(({changes:m})=>u((m.deleted||[]).map(h=>h.id))),{get event(){const m=i.get();return m?m.event:null},get selected(){const m=i.get();return m?[...m.selected]:null},get userSelectAction(){return o},clear:r,evalSelectAction:w,isEmpty:s,isSelected:a,setSelected:c,setUserSelectAction:d,subscribe:i.subscribe.bind(i),userSelect:l}},fo=(e,t,n)=>{const i=n?n.serialize(e):e;return typeof t=="function"?t(i):t||"EDIT"},Q=[];for(let e=0;e<256;++e)Q.push((e+256).toString(16).slice(1));function ho(e,t=0){return(Q[e[t+0]]+Q[e[t+1]]+Q[e[t+2]]+Q[e[t+3]]+"-"+Q[e[t+4]]+Q[e[t+5]]+"-"+Q[e[t+6]]+Q[e[t+7]]+"-"+Q[e[t+8]]+Q[e[t+9]]+"-"+Q[e[t+10]]+Q[e[t+11]]+Q[e[t+12]]+Q[e[t+13]]+Q[e[t+14]]+Q[e[t+15]]).toLowerCase()}let sn;const go=new Uint8Array(16);function po(){if(!sn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");sn=crypto.getRandomValues.bind(crypto)}return sn(go)}const mo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ei={randomUUID:mo};function bo(e,t,n){var i;e=e||{};const o=e.random??((i=e.rng)==null?void 0:i.call(e))??po();if(o.length<16)throw new Error("Random bytes length must be >= 16");return o[6]=o[6]&15|64,o[8]=o[8]&63|128,ho(o)}function ti(e,t,n){return ei.randomUUID&&!e?ei.randomUUID():bo(e)}const an=e=>{const t=n=>{const i={...n};return n.created&&typeof n.created=="string"&&(i.created=new Date(n.created)),n.updated&&typeof n.updated=="string"&&(i.updated=new Date(n.updated)),i};return{...e,bodies:(e.bodies||[]).map(t),target:t(e.target)}},wo=(e,t,n,i)=>({id:ti(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:i,...t}),yo=(e,t)=>{const n=new Set(e.bodies.map(i=>i.id));return t.bodies.filter(i=>!n.has(i.id))},vo=(e,t)=>{const n=new Set(t.bodies.map(i=>i.id));return e.bodies.filter(i=>!n.has(i.id))},Ao=(e,t)=>t.bodies.map(n=>{const i=e.bodies.find(o=>o.id===n.id);return{newBody:n,oldBody:i&&!Me(i,n)?i:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:i})=>({oldBody:n,newBody:i})),Eo=(e,t)=>!Me(e.target,t.target),ni=(e,t)=>{const n=yo(e,t),i=vo(e,t),o=Ao(e,t);return{oldValue:e,newValue:t,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:o.length>0?o:void 0,targetUpdated:Eo(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var X=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e.SILENT="SILENT",e))(X||{});const So=(e,t)=>{var n,i;const{changes:o,origin:r}=t;if(!(e.options.origin?e.options.origin===r:r!=="SILENT"))return!1;if(e.options.ignore){const{ignore:s}=e.options,a=l=>l&&l.length>0;if(!(a(o.created)||a(o.deleted))){const l=(n=o.updated)==null?void 0:n.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),c=(i=o.updated)==null?void 0:i.some(u=>u.targetUpdated);if(s==="BODY_ONLY"&&l&&!c||s==="TARGET_ONLY"&&c&&!l)return!1}}if(e.options.annotations){const s=new Set([...(o.created||[]).map(a=>a.id),...(o.deleted||[]).map(a=>a.id),...(o.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(e.options.annotations)?e.options.annotations:[e.options.annotations]).find(a=>s.has(a))}else return!0},Co=(e,t)=>{const n=new Set((e.created||[]).map(d=>d.id)),i=new Set((e.updated||[]).map(({newValue:d})=>d.id)),o=new Set((t.created||[]).map(d=>d.id)),r=new Set((t.deleted||[]).map(d=>d.id)),s=new Set((t.updated||[]).map(({oldValue:d})=>d.id)),a=new Set((t.updated||[]).filter(({oldValue:d})=>n.has(d.id)||i.has(d.id)).map(({oldValue:d})=>d.id)),l=[...(e.created||[]).filter(d=>!r.has(d.id)).map(d=>s.has(d.id)?t.updated.find(({oldValue:w})=>w.id===d.id).newValue:d),...t.created||[]],c=[...(e.deleted||[]).filter(d=>!o.has(d.id)),...(t.deleted||[]).filter(d=>!n.has(d.id))],u=[...(e.updated||[]).filter(({newValue:d})=>!r.has(d.id)).map(d=>{const{oldValue:w,newValue:m}=d;if(s.has(m.id)){const h=t.updated.find(y=>y.oldValue.id===m.id).newValue;return ni(w,h)}else return d}),...(t.updated||[]).filter(({oldValue:d})=>!a.has(d.id))];return{created:l,deleted:c,updated:u}},Nt=e=>{const t=e.id===void 0?ti():e.id;return{...e,id:t,bodies:e.bodies===void 0?[]:e.bodies.map(n=>({...n,annotation:t})),target:{...e.target,annotation:t}}},Oo=e=>e.id!==void 0,xo=()=>{const e=new Map,t=new Map,n=[],i=(S,C={})=>{n.push({onChange:S,options:C})},o=S=>{const C=n.findIndex(R=>R.onChange==S);C>-1&&n.splice(C,1)},r=(S,C)=>{const R={origin:S,changes:{created:C.created||[],updated:C.updated||[],deleted:C.deleted||[]},state:[...e.values()]};n.forEach(N=>{So(N,R)&&N.onChange(R)})},s=(S,C=X.LOCAL)=>{if(S.id&&e.get(S.id))throw Error(`Cannot add annotation ${S.id} - exists already`);{const R=Nt(S);e.set(R.id,R),R.bodies.forEach(N=>t.set(N.id,R.id)),r(C,{created:[R]})}},a=(S,C)=>{const R=Nt(typeof S=="string"?C:S),N=typeof S=="string"?S:S.id,Y=N&&e.get(N);if(Y){const F=ni(Y,R);return N===R.id?e.set(N,R):(e.delete(N),e.set(R.id,R)),Y.bodies.forEach(O=>t.delete(O.id)),R.bodies.forEach(O=>t.set(O.id,R.id)),F}else console.warn(`Cannot update annotation ${N} - does not exist`)},l=(S,C=X.LOCAL,R=X.LOCAL)=>{const N=Oo(C)?R:C,Y=a(S,C);Y&&r(N,{updated:[Y]})},c=(S,C=X.LOCAL)=>{e.get(S.id)?l(S,C):s(S,C)},u=(S,C=X.LOCAL)=>{const R=S.reduce((N,Y)=>{const F=a(Y);return F?[...N,F]:N},[]);R.length>0&&r(C,{updated:R})},d=(S,C=X.LOCAL)=>{const R=S.map(Nt),{toAdd:N,toUpdate:Y}=R.reduce((O,U)=>e.get(U.id)?{...O,toUpdate:[...O.toUpdate,U]}:{...O,toAdd:[...O.toAdd,U]},{toAdd:[],toUpdate:[]}),F=Y.map(O=>a(O,C)).filter(Boolean);N.forEach(O=>{e.set(O.id,O),O.bodies.forEach(U=>t.set(U.id,O.id))}),r(C,{created:N,updated:F})},w=(S,C=X.LOCAL)=>{const R=e.get(S.annotation);if(R){const N={...R,bodies:[...R.bodies,S]};e.set(R.id,N),t.set(S.id,N.id),r(C,{updated:[{oldValue:R,newValue:N,bodiesCreated:[S]}]})}else console.warn(`Attempt to add body to missing annotation: ${S.annotation}`)},m=()=>[...e.values()],h=(S=X.LOCAL)=>{const C=[...e.values()];e.clear(),t.clear(),r(S,{deleted:C})},y=(S,C=!0,R=X.LOCAL)=>{const N=S.map(Nt);if(C){const Y=[...e.values()];e.clear(),t.clear(),N.forEach(F=>{e.set(F.id,F),F.bodies.forEach(O=>t.set(O.id,F.id))}),r(R,{created:N,deleted:Y})}else{const Y=S.reduce((F,O)=>{const U=O.id&&e.get(O.id);return U?[...F,U]:F},[]);if(Y.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${Y.map(F=>F.id).join(", ")}`);N.forEach(F=>{e.set(F.id,F),F.bodies.forEach(O=>t.set(O.id,F.id))}),r(R,{created:N})}},x=S=>{const C=typeof S=="string"?S:S.id,R=e.get(C);if(R)return e.delete(C),R.bodies.forEach(N=>t.delete(N.id)),R;console.warn(`Attempt to delete missing annotation: ${C}`)},g=(S,C=X.LOCAL)=>{const R=x(S);R&&r(C,{deleted:[R]})},f=(S,C=X.LOCAL)=>{const R=S.reduce((N,Y)=>{const F=x(Y);return F?[...N,F]:N},[]);R.length>0&&r(C,{deleted:R})},M=S=>{const C=e.get(S.annotation);if(C){const R=C.bodies.find(N=>N.id===S.id);if(R){t.delete(R.id);const N={...C,bodies:C.bodies.filter(Y=>Y.id!==S.id)};return e.set(C.id,N),{oldValue:C,newValue:N,bodiesDeleted:[R]}}else console.warn(`Attempt to delete missing body ${S.id} from annotation ${S.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${S.annotation}`)},_=(S,C=X.LOCAL)=>{const R=M(S);R&&r(C,{updated:[R]})},k=(S,C=X.LOCAL)=>{const R=S.map(N=>M(N)).filter(Boolean);R.length>0&&r(C,{updated:R})},T=S=>{const C=e.get(S);return C?{...C}:void 0},I=S=>{const C=t.get(S);if(C){const R=T(C).bodies.find(N=>N.id===S);if(R)return R;console.error(`Store integrity error: body ${S} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${S}`)},L=(S,C)=>{if(S.annotation!==C.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const R=e.get(S.annotation);if(R){const N=R.bodies.find(F=>F.id===S.id),Y={...R,bodies:R.bodies.map(F=>F.id===N.id?C:F)};return e.set(R.id,Y),N.id!==C.id&&(t.delete(N.id),t.set(C.id,Y.id)),{oldValue:R,newValue:Y,bodiesUpdated:[{oldBody:N,newBody:C}]}}else console.warn(`Attempt to add body to missing annotation ${S.annotation}`)},D=(S,C,R=X.LOCAL)=>{const N=L(S,C);N&&r(R,{updated:[N]})},P=(S,C=X.LOCAL)=>{const R=S.map(N=>L({id:N.id,annotation:N.annotation},N)).filter(Boolean);r(C,{updated:R})},V=S=>{const C=e.get(S.annotation);if(C){const R={...C,target:{...C.target,...S}};return e.set(C.id,R),{oldValue:C,newValue:R,targetUpdated:{oldTarget:C.target,newTarget:S}}}else console.warn(`Attempt to update target on missing annotation: ${S.annotation}`)};return{addAnnotation:s,addBody:w,all:m,bulkAddAnnotations:y,bulkDeleteAnnotations:f,bulkDeleteBodies:k,bulkUpdateAnnotations:u,bulkUpdateBodies:P,bulkUpdateTargets:(S,C=X.LOCAL)=>{const R=S.map(N=>V(N)).filter(Boolean);R.length>0&&r(C,{updated:R})},bulkUpsertAnnotations:d,clear:h,deleteAnnotation:g,deleteBody:_,getAnnotation:T,getBody:I,observe:i,unobserve:o,updateAnnotation:l,updateBody:D,updateTarget:(S,C=X.LOCAL)=>{const R=V(S);R&&r(C,{updated:[R]})},upsertAnnotation:c}};let To=()=>({emit(e,...t){for(let n=this.events[e]||[],i=0,o=n.length;i<o;i++)n[i](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var i;this.events[e]=(i=this.events[e])==null?void 0:i.filter(o=>t!==o)}}});const Ro=250,ko=(e,t)=>{const n=To(),i=[];let o=-1,r=!1,s=0;const a=h=>{if(!r){const{changes:y}=h,x=performance.now();if(x-s>Ro)i.splice(o+1),i.push(y),o=i.length-1;else{const g=i.length-1;i[g]=Co(i[g],y)}s=x}r=!1};e.observe(a,{origin:X.LOCAL});const l=h=>h&&h.length>0&&e.bulkDeleteAnnotations(h),c=h=>h&&h.length>0&&e.bulkAddAnnotations(h,!1),u=h=>h&&h.length>0&&e.bulkUpdateAnnotations(h.map(({oldValue:y})=>y)),d=h=>h&&h.length>0&&e.bulkUpdateAnnotations(h.map(({newValue:y})=>y)),w=h=>h&&h.length>0&&e.bulkAddAnnotations(h,!1),m=h=>h&&h.length>0&&e.bulkDeleteAnnotations(h);return{canRedo:()=>i.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(a),getHistory:()=>({changes:[...i],pointer:o}),on:(h,y)=>n.on(h,y),redo:()=>{if(i.length-1>o){r=!0;const{created:h,updated:y,deleted:x}=i[o+1];c(h),d(y),m(x),n.emit("redo",i[o+1]),o+=1}},undo:()=>{if(o>-1){r=!0;const{created:h,updated:y,deleted:x}=i[o];l(h),u(y),w(x),n.emit("undo",i[o]),o-=1}}}},No=()=>{const e=nn([]);return{subscribe:e.subscribe.bind(e),set:e.set.bind(e)}},Lo=(e,t,n,i)=>{const{hover:o,selection:r,store:s,viewport:a}=e,l=new Map;let c=[],u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},w=(y,x)=>{const g=l.get(y);if(g){const f=g.indexOf(x);f!==-1&&g.splice(f,1)}},m=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(f=>{if(n){const M=Array.isArray(x)?x.map(k=>n.serialize(k)):n.serialize(x),_=g?g instanceof PointerEvent?g:n.serialize(g):void 0;f(M,_)}else f(x,g)})},1)};r.subscribe(({selected:y})=>{if(!(c.length===0&&y.length===0)){if(c.length===0&&y.length>0)c=y.map(({id:x})=>s.getAnnotation(x));else if(c.length>0&&y.length===0)c.forEach(x=>{const g=s.getAnnotation(x.id);g&&!Me(g,x)&&m("updateAnnotation",g,x)}),c=[];else{const x=new Set(c.map(f=>f.id)),g=new Set(y.map(({id:f})=>f));c.filter(f=>!g.has(f.id)).forEach(f=>{const M=s.getAnnotation(f.id);M&&!Me(M,f)&&m("updateAnnotation",M,f)}),c=[...c.filter(f=>g.has(f.id)),...y.filter(({id:f})=>!x.has(f)).map(({id:f})=>s.getAnnotation(f))]}m("selectionChanged",c)}}),o.subscribe(y=>{!u&&y?m("mouseEnterAnnotation",s.getAnnotation(y)):u&&!y?m("mouseLeaveAnnotation",s.getAnnotation(u)):u&&y&&(m("mouseLeaveAnnotation",s.getAnnotation(u)),m("mouseEnterAnnotation",s.getAnnotation(y))),u=y}),a==null||a.subscribe(y=>m("viewportIntersect",y.map(x=>s.getAnnotation(x)))),s.observe(y=>{const{created:x,deleted:g}=y.changes;(x||[]).forEach(f=>m("createAnnotation",f)),(g||[]).forEach(f=>m("deleteAnnotation",f)),(y.changes.updated||[]).filter(f=>[...f.bodiesCreated||[],...f.bodiesDeleted||[],...f.bodiesUpdated||[]].length>0).forEach(({oldValue:f,newValue:M})=>{const _=c.find(k=>k.id===f.id)||f;c=c.map(k=>k.id===f.id?M:k),m("updateAnnotation",M,_)})},{origin:X.LOCAL}),s.observe(y=>{if(c){const x=new Set(c.map(f=>f.id)),g=(y.changes.updated||[]).filter(({newValue:f})=>x.has(f.id)).map(({newValue:f})=>f);g.length>0&&(c=c.map(f=>g.find(_=>_.id===f.id)||f))}},{origin:X.REMOTE});const h=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(f=>m("updateAnnotation",f.oldValue,f.newValue)):(g||[]).forEach(f=>m("updateAnnotation",f.newValue,f.oldValue))};return t.on("undo",h(!0)),t.on("redo",h(!1)),{on:d,off:w,emit:m}},Io=e=>t=>t.reduce((n,i)=>{const{parsed:o,error:r}=e.parse(i);return r?{parsed:n.parsed,failed:[...n.failed,i]}:o?{parsed:[...n.parsed,o],failed:n.failed}:{...n}},{parsed:[],failed:[]}),Mo=(e,t,n)=>{const{store:i,selection:o}=e,r=g=>{if(n){const{parsed:f,error:M}=n.parse(g);f?i.addAnnotation(f,X.REMOTE):console.error(M)}else i.addAnnotation(an(g),X.REMOTE)},s=()=>o.clear(),a=()=>i.clear(),l=g=>{const f=i.getAnnotation(g);return n&&f?n.serialize(f):f},c=()=>n?i.all().map(n.serialize):i.all(),u=()=>{var g;const f=(((g=o.selected)==null?void 0:g.map(M=>M.id))||[]).map(M=>i.getAnnotation(M)).filter(Boolean);return n?f.map(n.serialize):f},d=(g,f=!0)=>fetch(g).then(M=>M.json()).then(M=>(m(M,f),M)),w=g=>{if(typeof g=="string"){const f=i.getAnnotation(g);if(i.deleteAnnotation(g),f)return n?n.serialize(f):f}else{const f=n?n.parse(g).parsed:g;if(f)return i.deleteAnnotation(f),g}},m=(g,f=!0)=>{if(n){const M=n.parseAll||Io(n),{parsed:_,failed:k}=M(g);k.length>0&&console.warn(`Discarded ${k.length} invalid annotations`,k),i.bulkAddAnnotations(_,f,X.REMOTE)}else i.bulkAddAnnotations(g.map(an),f,X.REMOTE)},h=(g,f)=>{g?o.setSelected(g,f):o.clear()},y=g=>{o.setUserSelectAction(g)},x=g=>{if(n){const f=n.parse(g).parsed,M=n.serialize(i.getAnnotation(f.id));return i.updateAnnotation(f),M}else{const f=i.getAnnotation(g.id);return i.updateAnnotation(an(g)),f}};return{addAnnotation:r,cancelSelected:s,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:c,getHistory:t.getHistory,getSelected:u,loadAnnotations:d,redo:t.redo,removeAnnotation:w,setAnnotations:m,setSelected:h,setUserSelectAction:y,undo:t.undo,updateAnnotation:x}},Bo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let _o=e=>crypto.getRandomValues(new Uint8Array(e)),Uo=(e,t,n)=>{let i=(2<<Math.log2(e.length-1))-1,o=-~(1.6*i*t/e.length);return(r=t)=>{let s="";for(;;){let a=n(o),l=o|0;for(;l--;)if(s+=e[a[l]&i]||"",s.length>=r)return s}}},Do=(e,t=21)=>Uo(e,t|0,_o),Ho=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Bo[n[e]&63];return t};const Po=()=>({isGuest:!0,id:Do("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Vo=e=>{const t=JSON.stringify(e);let n=0;for(let i=0,o=t.length;i<o;i++){let r=t.charCodeAt(i);n=(n<<5)-n+r,n|=0}return`${n}`},ii=e=>e?typeof e=="object"?{...e}:e:void 0,Xo=(e,t)=>(Array.isArray(e)?e:[e]).map(n=>{const{id:i,type:o,purpose:r,value:s,created:a,modified:l,creator:c,...u}=n;return{id:i||`temp-${Vo(n)}`,annotation:t,type:o,purpose:r,value:s,creator:ii(c),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),Fo=e=>e.map(t=>{var n;const{annotation:i,created:o,updated:r,...s}=t,a={...s,created:o==null?void 0:o.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=a.id)!=null&&n.startsWith("temp-")&&delete a.id,a});Ho();const Yo=e=>{const{top:t,left:n}=e.getBoundingClientRect(),{innerWidth:i,innerHeight:o}=window,r=-n,s=-t,a=i-n,l=o-t;return{top:t,left:n,minX:r,minY:s,maxX:a,maxY:l}},Ko=e=>{let t=new Set;return i=>{const o=i.map(r=>r.id);(t.size!==o.length||o.some(r=>!t.has(r)))&&e.set(o),t=new Set(o)}},Lt=(e,t,n,i)=>{const{store:o,selection:r,hover:s}=t;let a,l,c;const u=Ko(n),d=D=>{const{x:P,y:V}=e.getBoundingClientRect(),S=o.getAt(D.clientX-P,D.clientY-V,!1,l);S&&t.selection.evalSelectAction(S)!==on.NONE?s.current!==S.id&&(e.classList.add("hovered"),s.set(S.id)):s.current&&(e.classList.remove("hovered"),s.set(null))};e.addEventListener("pointermove",d);const w=ot((D=!1)=>requestAnimationFrame(()=>{c&&c.clear();const P=Yo(e),{minX:V,minY:S,maxX:C,maxY:R}=P,N=l?o.getIntersecting(V,S,C,R).filter(({annotation:O})=>l(O)):o.getIntersecting(V,S,C,R),Y=r.selected.map(({id:O})=>O),F=N.map(({annotation:O,rects:U})=>{const G=Y.includes(O.id),Be=O.id===s.current;return{annotation:O,rects:U,state:{selected:G,hovered:Be}}});i.redraw(F,P,a,c,D),setTimeout(()=>u(N.map(({annotation:O})=>O)),1)}),10),m=D=>{c=D,w()},h=D=>{a=D,w()},y=D=>{l=D,w(!1)},x=()=>w();o.observe(x);const g=r.subscribe(()=>w()),f=s.subscribe(()=>w()),M=()=>w(!0);document.addEventListener("scroll",M,{capture:!0,passive:!0});const _=ot(()=>{o.recalculatePositions(),c==null||c.reset(),w()},10);window.addEventListener("resize",_);const k=new ResizeObserver(_);k.observe(e);const T={attributes:!0,childList:!0,subtree:!0},I=new MutationObserver(ot(D=>{D.every(V=>V.target===e||e.contains(V.target))||w(!0)},150));return I.observe(document.body,T),{destroy:()=>{e.removeEventListener("pointermove",d),i.destroy(),o.unobserve(x),g(),f(),document.removeEventListener("scroll",M),_.clear(),window.removeEventListener("resize",_),k.disconnect(),I.disconnect()},redraw:w,setStyle:h,setFilter:y,setPainter:m,setVisible:i.setVisible}},Wo=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},jo=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},$o=e=>{console.warn('WARNING! Canvas renderer is deprecated and will be removed in the next major release. Please use the default "SPANS" renderer instead.'),e.classList.add("r6o-annotatable");const t=Wo(),n=t.getContext("2d");document.body.appendChild(t);const i=(a,l,c,u)=>requestAnimationFrame(()=>{const{width:d,height:w}=t;n.clearRect(-.5,-.5,d+1,w+1),u&&u.clear();const{top:m,left:h}=l;[...a].sort((x,g)=>{const{annotation:{target:{created:f}}}=x,{annotation:{target:{created:M}}}=g;return f.getTime()-M.getTime()}).forEach(x=>{var _;const g=c?typeof c=="function"?c(x.annotation,x.state):c:(_=x.state)!=null&&_.selected?rt:pe,f=u&&u.paint(x,l)||g,M=x.rects.map(({x:k,y:T,width:I,height:L})=>({x:k+h,y:T+m,width:I,height:L}));if(n.fillStyle=f.fill,n.globalAlpha=f.fillOpacity||1,M.forEach(({x:k,y:T,width:I,height:L})=>n.fillRect(k,T,I,L)),f.underlineColor){n.globalAlpha=1,n.strokeStyle=f.underlineColor,n.lineWidth=f.underlineThickness??1;const k=f.underlineOffset??0;M.forEach(({x:T,y:I,width:L,height:D})=>{n.beginPath(),n.moveTo(T,I+D+k),n.lineTo(T+L,I+D+k),n.stroke()})}})}),o=ot(()=>jo(t),10);return window.addEventListener("resize",o),{destroy:()=>{t.remove(),o.clear(),window.removeEventListener("resize",o)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:i}},oi=(e,t,n)=>Lt(e,t,n,$o(e));var zo={grad:.9,turn:360,rad:360/(2*Math.PI)},Ae=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},q=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},re=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},ri=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},si=function(e){return{r:re(e.r,0,255),g:re(e.g,0,255),b:re(e.b,0,255),a:re(e.a)}},ln=function(e){return{r:q(e.r),g:q(e.g),b:q(e.b),a:q(e.a,3)}},qo=/^#([0-9a-f]{3,8})$/i,It=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},ai=function(e){var t=e.r,n=e.g,i=e.b,o=e.a,r=Math.max(t,n,i),s=r-Math.min(t,n,i),a=s?r===t?(n-i)/s:r===n?2+(i-t)/s:4+(t-n)/s:0;return{h:60*(a<0?a+6:a),s:r?s/r*100:0,v:r/255*100,a:o}},li=function(e){var t=e.h,n=e.s,i=e.v,o=e.a;t=t/360*6,n/=100,i/=100;var r=Math.floor(t),s=i*(1-n),a=i*(1-(t-r)*n),l=i*(1-(1-t+r)*n),c=r%6;return{r:255*[i,a,s,s,l,i][c],g:255*[l,i,i,a,s,s][c],b:255*[s,s,l,i,i,a][c],a:o}},ci=function(e){return{h:ri(e.h),s:re(e.s,0,100),l:re(e.l,0,100),a:re(e.a)}},di=function(e){return{h:q(e.h),s:q(e.s),l:q(e.l),a:q(e.a,3)}},ui=function(e){return li((n=(t=e).s,{h:t.h,s:(n*=((i=t.l)<50?i:100-i)/100)>0?2*n/(i+n)*100:0,v:i+n,a:t.a}));var t,n,i},st=function(e){return{h:(t=ai(e)).h,s:(o=(200-(n=t.s))*(i=t.v)/100)>0&&o<200?n*i/100/(o<=100?o:200-o)*100:0,l:o/2,a:t.a};var t,n,i,o},Go=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,fi={string:[[function(e){var t=qo.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?q(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?q(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=Qo.exec(e)||Zo.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:si({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=Go.exec(e)||Jo.exec(e);if(!t)return null;var n,i,o=ci({h:(n=t[1],i=t[2],i===void 0&&(i="deg"),Number(n)*(zo[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ui(o)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,i=e.b,o=e.a,r=o===void 0?1:o;return Ae(t)&&Ae(n)&&Ae(i)?si({r:Number(t),g:Number(n),b:Number(i),a:Number(r)}):null},"rgb"],[function(e){var t=e.h,n=e.s,i=e.l,o=e.a,r=o===void 0?1:o;if(!Ae(t)||!Ae(n)||!Ae(i))return null;var s=ci({h:Number(t),s:Number(n),l:Number(i),a:Number(r)});return ui(s)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,o=e.a,r=o===void 0?1:o;if(!Ae(t)||!Ae(n)||!Ae(i))return null;var s=(function(a){return{h:ri(a.h),s:re(a.s,0,100),v:re(a.v,0,100),a:re(a.a)}})({h:Number(t),s:Number(n),v:Number(i),a:Number(r)});return li(s)},"hsv"]]},hi=function(e,t){for(var n=0;n<t.length;n++){var i=t[n][0](e);if(i)return[i,t[n][1]]}return[null,void 0]},er=function(e){return typeof e=="string"?hi(e.trim(),fi.string):typeof e=="object"&&e!==null?hi(e,fi.object):[null,void 0]},cn=function(e,t){var n=st(e);return{h:n.h,s:re(n.s+100*t,0,100),l:n.l,a:n.a}},dn=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},gi=function(e,t){var n=st(e);return{h:n.h,s:n.s,l:re(n.l+100*t,0,100),a:n.a}},pi=(function(){function e(t){this.parsed=er(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return q(dn(this.rgba),2)},e.prototype.isDark=function(){return dn(this.rgba)<.5},e.prototype.isLight=function(){return dn(this.rgba)>=.5},e.prototype.toHex=function(){return t=ln(this.rgba),n=t.r,i=t.g,o=t.b,s=(r=t.a)<1?It(q(255*r)):"","#"+It(n)+It(i)+It(o)+s;var t,n,i,o,r,s},e.prototype.toRgb=function(){return ln(this.rgba)},e.prototype.toRgbString=function(){return t=ln(this.rgba),n=t.r,i=t.g,o=t.b,(r=t.a)<1?"rgba("+n+", "+i+", "+o+", "+r+")":"rgb("+n+", "+i+", "+o+")";var t,n,i,o,r},e.prototype.toHsl=function(){return di(st(this.rgba))},e.prototype.toHslString=function(){return t=di(st(this.rgba)),n=t.h,i=t.s,o=t.l,(r=t.a)<1?"hsla("+n+", "+i+"%, "+o+"%, "+r+")":"hsl("+n+", "+i+"%, "+o+"%)";var t,n,i,o,r},e.prototype.toHsv=function(){return t=ai(this.rgba),{h:q(t.h),s:q(t.s),v:q(t.v),a:q(t.a,3)};var t},e.prototype.invert=function(){return se({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),se(cn(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),se(cn(this.rgba,-t))},e.prototype.grayscale=function(){return se(cn(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),se(gi(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),se(gi(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?se({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):q(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=st(this.rgba);return typeof t=="number"?se({h:t,s:n.s,l:n.l,a:n.a}):q(n.h)},e.prototype.isEqual=function(t){return this.toHex()===se(t).toHex()},e})(),se=function(e){return e instanceof pi?e:new pi(e)};const tr=e=>[`background-color:${se((e==null?void 0:e.fill)||pe.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?pe.fillOpacity:e.fillOpacity).toHex()}`,e!=null&&e.underlineThickness?"text-decoration:underline":void 0,e!=null&&e.underlineColor?`text-decoration-color:${e.underlineColor}`:void 0,e!=null&&e.underlineOffset?`text-underline-offset:${e.underlineOffset}px`:void 0,e!=null&&e.underlineThickness?`text-decoration-thickness:${e.underlineThickness}px`:void 0].filter(Boolean).join(";"),mi=()=>{const e=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(e);let t=new Set;return{destroy:()=>{CSS.highlights.clear(),e.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,s,a,l)=>{l&&l.clear();const c=new Set(r.map(d=>d.annotation.id));Array.from(t).filter(d=>!c.has(d));const u=r.map(d=>{var h;const w=a?typeof a=="function"?a(d.annotation,d.state):a:(h=d.state)!=null&&h.selected?rt:pe,m=l&&l.paint(d,s)||w;return`::highlight(_${d.annotation.id}) { ${tr(m)} }`});e.innerHTML=u.join(`
2
- `),CSS.highlights.clear(),r.forEach(({annotation:d})=>{const w=d.target.selector.map(h=>h.range),m=new Highlight(...w);CSS.highlights.set(`_${d.id}`,m)}),t=c}}},bi=(e,t,n)=>Lt(e,t,n,mi());var wi=Object.prototype.hasOwnProperty;function un(e,t){var n,i;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((i=e.length)===t.length)for(;i--&&un(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(wi.call(e,n)&&++i&&!wi.call(t,n)||!(n in t)||!un(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}const yi=(e,t,n,i,o)=>{var s,a;const r=n?typeof n=="function"?n(e.annotation,e.state,o)||((s=e.state)!=null&&s.selected?rt:pe):n:(a=e.state)!=null&&a.selected?rt:pe;return i&&i.paint(e,t)||r},nr=e=>(e==null?void 0:e.fillOpacity)!==void 0?se((e==null?void 0:e.fill)||pe.fill).alpha(e.fillOpacity).toHex():e!=null&&e.fill?e.fill:se(pe.fill).alpha(pe.fillOpacity).toHex(),ir=(e,t)=>{const n=(r,s)=>r.x<=s.x+s.width&&r.x+r.width>=s.x&&r.y<=s.y+s.height&&r.y+r.height>=s.y,i=r=>r.rects.reduce((s,a)=>s+a.width,0),o=t.filter(({rects:r})=>r.some(s=>n(e,s)));return o.sort((r,s)=>i(s)-i(r)),o.findIndex(r=>r.rects.includes(e))},or=e=>{e.classList.add("r6o-annotatable");const t=document.createElement("div");t.className="r6o-span-highlight-layer",e.insertBefore(t,e.firstChild);let n=[];return{destroy:()=>{t.remove()},redraw:(s,a,l,c,u)=>{const w=!(un(n,s)&&u);if(!c&&!w)return;w&&(t.innerHTML=""),[...s].sort((h,y)=>{const{annotation:{target:{created:x}}}=h,{annotation:{target:{created:g}}}=y;return x&&g?x.getTime()-g.getTime():0}).forEach(h=>{h.rects.map(y=>{const x=ir(y,s),g=yi(h,a,l,c,x);if(w){const f=document.createElement("span");f.className="r6o-annotation",f.dataset.annotation=h.annotation.id,f.style.left=`${y.x}px`,f.style.top=`${y.y}px`,f.style.width=`${y.width}px`,f.style.height=`${y.height}px`,f.style.backgroundColor=nr(g),g.underlineStyle&&(f.style.borderStyle=g.underlineStyle),g.underlineColor&&(f.style.borderColor=g.underlineColor),g.underlineThickness&&(f.style.borderBottomWidth=`${g.underlineThickness}px`),g.underlineOffset&&(f.style.paddingBottom=`${g.underlineOffset}px`),t.appendChild(f)}})}),n=s},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},vi=(e,t,n)=>Lt(e,t,n,or(e)),Z=[];for(let e=0;e<256;++e)Z.push((e+256).toString(16).slice(1));function rr(e,t=0){return(Z[e[t+0]]+Z[e[t+1]]+Z[e[t+2]]+Z[e[t+3]]+"-"+Z[e[t+4]]+Z[e[t+5]]+"-"+Z[e[t+6]]+Z[e[t+7]]+"-"+Z[e[t+8]]+Z[e[t+9]]+"-"+Z[e[t+10]]+Z[e[t+11]]+Z[e[t+12]]+Z[e[t+13]]+Z[e[t+14]]+Z[e[t+15]]).toLowerCase()}let fn;const sr=new Uint8Array(16);function ar(){if(!fn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fn=crypto.getRandomValues.bind(crypto)}return fn(sr)}const Ai={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function lr(e,t,n){var o;e=e||{};const i=e.random??((o=e.rng)==null?void 0:o.call(e))??ar();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,rr(i)}function Ei(e,t,n){return Ai.randomUUID&&!e?Ai.randomUUID():lr(e)}const cr=(e,t)=>({parse:n=>Si(n),serialize:n=>Ci(n,e,t)}),dr=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,ur=e=>{const{id:t,creator:n,created:i,modified:o,target:r}=e,s=Array.isArray(r)?r:[r];if(s.length===0)return{error:Error(`No targets found for annotation: ${e.id}`)};const a={creator:ii(n),created:i?new Date(i):void 0,updated:o?new Date(o):void 0,annotation:t,selector:[],styleClass:"styleClass"in s[0]?s[0].styleClass:void 0};for(const l of s){const u=(Array.isArray(l.selector)?l.selector:[l.selector]).reduce((d,w)=>{switch(w.type){case"TextQuoteSelector":d.quote=w.exact;break;case"TextPositionSelector":d.start=w.start,d.end=w.end;break}return d},{});if(dr(u))a.selector.push({...u,id:l.id,scope:l.scope});else{const d=[u.start?void 0:"TextPositionSelector",u.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${d.join(" and ")} for annotation: ${e.id}`)}}}return{parsed:a}},Si=e=>{const t=e.id||Ei(),{creator:n,created:i,modified:o,body:r,...s}=e,a=Xo(r,t),l=ur(e);return"error"in l?{error:l.error}:{parsed:{...s,id:t,bodies:a,target:l.parsed}}},Ci=(e,t,n)=>{const{bodies:i,target:o,...r}=e,{selector:s,creator:a,created:l,updated:c,...u}=o,d=s.map(w=>{const{id:m,quote:h,start:y,end:x,range:g}=w,f={type:"TextQuoteSelector",exact:h};if(n){const{prefix:_,suffix:k}=Yn(g,n);f.prefix=_,f.suffix=k}const M={type:"TextPositionSelector",start:y,end:x};return{...u,id:m,scope:"scope"in w?w.scope:void 0,source:t,selector:[f,M]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:Fo(e.bodies),creator:a,created:l==null?void 0:l.toISOString(),modified:c==null?void 0:c.toISOString(),target:d}},fr=()=>{const e=document.createElement("canvas");e.width=2*window.innerWidth,e.height=2*window.innerHeight,e.className="r6o-presence-layer";const t=e.getContext("2d");return t.scale(2,2),t.translate(.5,.5),e},Oi=(e,t={})=>{const n=fr(),i=n.getContext("2d");document.body.appendChild(n);const o=new Map,r=u=>Array.from(o.entries()).filter(([d,w])=>w.presenceKey===u.presenceKey).map(([d,w])=>d);return e.on("selectionChange",(u,d)=>{r(u).forEach(m=>o.delete(m)),d&&d.forEach(m=>o.set(m,u))}),{clear:()=>{const{width:u,height:d}=n;i.clearRect(-.5,-.5,u+1,d+1)},destroy:()=>{n.remove()},paint:(u,d,w)=>{t.font&&(i.font=t.font);const m=o.get(u.annotation.id);if(m){const{height:h}=u.rects[0],y=u.rects[0].x+d.left,x=u.rects[0].y+d.top;i.fillStyle=m.appearance.color,i.fillRect(y-2,x-2.5,2,h+5);const g=i.measureText(m.appearance.label),f=g.width+6,M=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent+8,_=g.fontBoundingBoxAscent?8:6.5;return i.fillRect(y-2,x-2.5-M,f,M),i.fillStyle="#fff",i.fillText(m.appearance.label,y+1,x-_),{fill:m.appearance.color,fillOpacity:w?.45:.18}}},reset:()=>{n.width=2*window.innerWidth,n.height=2*window.innerHeight;const u=n.getContext("2d");u.scale(2,2),u.translate(.5,.5)}}};function xi(e,t,n=0,i=e.length-1,o=hr){for(;i>n;){if(i-n>600){const l=i-n+1,c=t-n+1,u=Math.log(l),d=.5*Math.exp(2*u/3),w=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(t-c*d/l+w)),h=Math.min(i,Math.floor(t+(l-c)*d/l+w));xi(e,t,m,h,o)}const r=e[t];let s=n,a=i;for(at(e,n,t),o(e[i],r)>0&&at(e,n,i);s<a;){for(at(e,s,a),s++,a--;o(e[s],r)<0;)s++;for(;o(e[a],r)>0;)a--}o(e[n],r)===0?at(e,n,a):(a++,at(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function at(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function hr(e,t){return e<t?-1:e>t?1:0}class gr{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const i=[];if(!Bt(t,n))return i;const o=this.toBBox,r=[];for(;n;){for(let s=0;s<n.children.length;s++){const a=n.children[s],l=n.leaf?o(a):a;Bt(t,l)&&(n.leaf?i.push(a):gn(t,l)?this._all(a,i):r.push(a))}n=r.pop()}return i}collides(t){let n=this.data;if(!Bt(t,n))return!1;const i=[];for(;n;){for(let o=0;o<n.children.length;o++){const r=n.children[o],s=n.leaf?this.toBBox(r):r;if(Bt(t,s)){if(n.leaf||gn(t,s))return!0;i.push(r)}}n=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Ye([]),this}remove(t,n){if(!t)return this;let i=this.data;const o=this.toBBox(t),r=[],s=[];let a,l,c;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=s.pop(),c=!0),i.leaf){const u=pr(t,i.children,n);if(u!==-1)return i.children.splice(u,1),r.push(i),this._condense(r),this}!c&&!i.leaf&&gn(i,o)?(r.push(i),s.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],c=!1):i=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const i=[];for(;t;)t.leaf?n.push(...t.children):i.push(...t.children),t=i.pop();return n}_build(t,n,i,o){const r=i-n+1;let s=this._maxEntries,a;if(r<=s)return a=Ye(t.slice(n,i+1)),Fe(a,this.toBBox),a;o||(o=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,o-1))),a=Ye([]),a.leaf=!1,a.height=o;const l=Math.ceil(r/s),c=l*Math.ceil(Math.sqrt(s));Ti(t,n,i,c,this.compareMinX);for(let u=n;u<=i;u+=c){const d=Math.min(u+c-1,i);Ti(t,u,d,l,this.compareMinY);for(let w=u;w<=d;w+=l){const m=Math.min(w+l-1,d);a.children.push(this._build(t,w,m,o-1))}}return Fe(a,this.toBBox),a}_chooseSubtree(t,n,i,o){for(;o.push(n),!(n.leaf||o.length-1===i);){let r=1/0,s=1/0,a;for(let l=0;l<n.children.length;l++){const c=n.children[l],u=hn(c),d=wr(t,c)-u;d<s?(s=d,r=u<r?u:r,a=c):d===s&&u<r&&(r=u,a=c)}n=a||n.children[0]}return n}_insert(t,n,i){const o=i?t:this.toBBox(t),r=[],s=this._chooseSubtree(o,this.data,n,r);for(s.children.push(t),ct(s,o);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(o,r,n)}_split(t,n){const i=t[n],o=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,o);const s=this._chooseSplitIndex(i,r,o),a=Ye(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Fe(i,this.toBBox),Fe(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,n){this.data=Ye([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Fe(this.data,this.toBBox)}_chooseSplitIndex(t,n,i){let o,r=1/0,s=1/0;for(let a=n;a<=i-n;a++){const l=lt(t,0,a,this.toBBox),c=lt(t,a,i,this.toBBox),u=yr(l,c),d=hn(l)+hn(c);u<r?(r=u,o=a,s=d<s?d:s):u===r&&d<s&&(s=d,o=a)}return o||i-n}_chooseSplitAxis(t,n,i){const o=t.leaf?this.compareMinX:mr,r=t.leaf?this.compareMinY:br,s=this._allDistMargin(t,n,i,o),a=this._allDistMargin(t,n,i,r);s<a&&t.children.sort(o)}_allDistMargin(t,n,i,o){t.children.sort(o);const r=this.toBBox,s=lt(t,0,n,r),a=lt(t,i-n,i,r);let l=Mt(s)+Mt(a);for(let c=n;c<i-n;c++){const u=t.children[c];ct(s,t.leaf?r(u):u),l+=Mt(s)}for(let c=i-n-1;c>=n;c--){const u=t.children[c];ct(a,t.leaf?r(u):u),l+=Mt(a)}return l}_adjustParentBBoxes(t,n,i){for(let o=i;o>=0;o--)ct(n[o],t)}_condense(t){for(let n=t.length-1,i;n>=0;n--)t[n].children.length===0?n>0?(i=t[n-1].children,i.splice(i.indexOf(t[n]),1)):this.clear():Fe(t[n],this.toBBox)}}function pr(e,t,n){if(!n)return t.indexOf(e);for(let i=0;i<t.length;i++)if(n(e,t[i]))return i;return-1}function Fe(e,t){lt(e,0,e.children.length,t,e)}function lt(e,t,n,i,o){o||(o=Ye(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let r=t;r<n;r++){const s=e.children[r];ct(o,e.leaf?i(s):s)}return o}function ct(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function mr(e,t){return e.minX-t.minX}function br(e,t){return e.minY-t.minY}function hn(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Mt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function wr(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function yr(e,t){const n=Math.max(e.minX,t.minX),i=Math.max(e.minY,t.minY),o=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,o-n)*Math.max(0,r-i)}function gn(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Bt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Ye(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ti(e,t,n,i,o){const r=[t,n];for(;r.length;){if(n=r.pop(),t=r.pop(),n-t<=i)continue;const s=t+Math.ceil((n-t)/i/2)*i;xi(e,s,t,n,o),r.push(t,s,s,n)}}let vr=()=>({emit(e,...t){for(let n=this.events[e]||[],i=0,o=n.length;i<o;i++)n[i](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var i;this.events[e]=(i=this.events[e])==null?void 0:i.filter(o=>t!==o)}}});const Ar=(e,t,n,i)=>{const o=new gr,r=new Map,s=vr(),a=(k,T)=>{const I=k.selector.flatMap(D=>{const P=ge([D])?D.range:tn(D,t).range;return Xn(P)}),L=Wn(I,n,i).map(D=>zn(D,T));return L.map(D=>{const{x:P,y:V,width:S,height:C}=D;return{minX:P,minY:V,maxX:P+S,maxY:V+C,annotation:{id:k.annotation,rects:L}}})},l=()=>[...r.values()],c=()=>{o.clear(),r.clear()},u=k=>{const T=a(k,t.getBoundingClientRect());T.length!==0&&(T.forEach(I=>o.insert(I)),r.set(k.annotation,T))},d=k=>{const T=r.get(k.annotation);T&&(T.forEach(I=>o.remove(I)),r.delete(k.annotation))},w=k=>{d(k),u(k)},m=(k,T=!0)=>{T&&c();const I=t.getBoundingClientRect(),L=k.map(P=>({target:P,rects:a(P,I)}));L.forEach(({target:P,rects:V})=>{V.length>0&&r.set(P.annotation,V)});const D=L.flatMap(({rects:P})=>P);o.load(D)},h=(k,T,I=!1)=>{const L=o.search({minX:k,minY:T,maxX:k,maxY:T}),D=P=>P.annotation.rects.reduce((V,S)=>V+S.width*S.height,0);return L.length>0?(L.sort((P,V)=>D(P)-D(V)),I?L.map(P=>P.annotation.id):[L[0].annotation.id]):[]},y=k=>{const T=x(k);if(T.length===0)return;let I=T[0].left,L=T[0].top,D=T[0].right,P=T[0].bottom;for(let V=1;V<T.length;V++){const S=T[V];I=Math.min(I,S.left),L=Math.min(L,S.top),D=Math.max(D,S.right),P=Math.max(P,S.bottom)}return new DOMRect(I,L,D-I,P-L)},x=k=>{const T=r.get(k);return T?T[0].annotation.rects:[]};return{all:l,clear:c,getAt:h,getAnnotationBounds:y,getAnnotationRects:x,getIntersecting:(k,T,I,L)=>{const D=o.search({minX:k,minY:T,maxX:I,maxY:L}),P=new Set(D.map(V=>V.annotation.id));return Array.from(P).map(V=>({annotation:e.getAnnotation(V),rects:x(V)})).filter(V=>!!V.annotation)},insert:u,recalculate:()=>{m(e.all().map(k=>k.target),!0),s.emit("recalculate")},remove:d,set:m,size:()=>o.all().length,update:w,on:(k,T)=>s.on(k,T)}},Ri=(e,t)=>{var f,M;const n=xo(),i=Ar(n,e,(f=t.mergeHighlights)==null?void 0:f.horizontalTolerance,(M=t.mergeHighlights)==null?void 0:M.verticalTolerance),o=uo(n,t.userSelectAction,t.adapter),r=co(n),s=No(),a=(_,k=X.LOCAL)=>{const T=Rt(_,e),I=ge(T.target.selector);return I&&n.addAnnotation(T,k),I},l=(_,k=!0,T=X.LOCAL)=>{const I=_.map(D=>Rt(D,e)),L=I.filter(D=>!ge(D.target.selector));return n.bulkAddAnnotations(I,k,T),L},c=(_,k=X.LOCAL)=>{const T=_.map(L=>Rt(L,e)),I=T.filter(L=>!ge(L.target.selector));return T.forEach(L=>{n.getAnnotation(L.id)?n.updateAnnotation(L,k):n.addAnnotation(L,k)}),I},u=(_,k=X.LOCAL)=>{const T=it(_,e);n.updateTarget(T,k)},d=(_,k=X.LOCAL)=>{const T=_.map(I=>it(I,e));n.bulkUpdateTargets(T,k)};function w(_,k,T,I){const L=T||!!I,D=i.getAt(_,k,L).map(V=>n.getAnnotation(V)),P=I?D.filter(I):D;if(P.length!==0)return T?P:P[0]}const m=_=>i.getAnnotationRects(_).length>0?i.getAnnotationBounds(_):void 0,h=(_,k,T,I)=>i.getIntersecting(_,k,T,I),y=_=>i.getAnnotationRects(_),x=()=>i.recalculate(),g=_=>i.on("recalculate",_);return n.observe(({changes:_})=>{const k=(_.deleted||[]).filter(L=>ge(L.target.selector)),T=(_.created||[]).filter(L=>ge(L.target.selector)),I=(_.updated||[]).filter(L=>ge(L.newValue.target.selector));(k==null?void 0:k.length)>0&&k.forEach(L=>i.remove(L.target)),T.length>0&&i.set(T.map(L=>L.target),!1),(I==null?void 0:I.length)>0&&I.forEach(({newValue:L})=>i.update(L.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotations:l,bulkUpdateTargets:d,bulkUpsertAnnotations:c,getAnnotationBounds:m,getAnnotationRects:y,getIntersecting:h,getAt:w,recalculatePositions:x,onRecalculatePositions:g,updateTarget:u},selection:o,hover:r,viewport:s}},pn=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function mn(e,t,n,i){e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on".concat(t),n)}function dt(e,t,n,i){e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on".concat(t),n)}function ki(e,t){const n=t.slice(0,t.length-1);for(let i=0;i<n.length;i++)n[i]=e[n[i].toLowerCase()];return n}function Ni(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function Er(e,t){const n=e.length>=t.length?e:t,i=e.length>=t.length?t:e;let o=!0;for(let r=0;r<n.length;r++)i.indexOf(n[r])===-1&&(o=!1);return o}const ut={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":pn?173:189,"=":pn?61:187,";":pn?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},de={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},ft={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},ee={16:!1,18:!1,17:!1,91:!1},j={};for(let e=1;e<20;e++)ut["f".concat(e)]=111+e;let W=[],ht=null,Li="all";const Ee=new Map,Ke=e=>ut[e.toLowerCase()]||de[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),Sr=e=>Object.keys(ut).find(t=>ut[t]===e),Cr=e=>Object.keys(de).find(t=>de[t]===e);function Ii(e){Li=e||"all"}function gt(){return Li||"all"}function Or(){return W.slice(0)}function xr(){return W.map(e=>Sr(e)||Cr(e)||String.fromCharCode(e))}function Tr(){const e=[];return Object.keys(j).forEach(t=>{j[t].forEach(n=>{let{key:i,scope:o,mods:r,shortcut:s}=n;e.push({scope:o,shortcut:s,mods:r,keys:i.split("+").map(a=>Ke(a))})})}),e}function Rr(e){const t=e.target||e.srcElement,{tagName:n}=t;let i=!0;const o=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(o||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(i=!1),i}function kr(e){return typeof e=="string"&&(e=Ke(e)),W.indexOf(e)!==-1}function Nr(e,t){let n,i;e||(e=gt());for(const o in j)if(Object.prototype.hasOwnProperty.call(j,o))for(n=j[o],i=0;i<n.length;)n[i].scope===e?n.splice(i,1).forEach(s=>{let{element:a}=s;return bn(a)}):i++;gt()===e&&Ii(t||"all")}function Lr(e){let t=e.keyCode||e.which||e.charCode;e.key&&e.key.toLowerCase()==="capslock"&&(t=Ke(e.key));const n=W.indexOf(t);if(n>=0&&W.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&W.splice(0,W.length),(t===93||t===224)&&(t=91),t in ee){ee[t]=!1;for(const i in de)de[i]===t&&(ae[i]=!1)}}function Mi(e){if(typeof e>"u")Object.keys(j).forEach(o=>{Array.isArray(j[o])&&j[o].forEach(r=>_t(r)),delete j[o]}),bn(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&_t(o)});else if(typeof e=="object")e.key&&_t(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];let[o,r]=n;typeof o=="function"&&(r=o,o=""),_t({key:e,scope:o,method:r,splitKey:"+"})}}const _t=e=>{let{key:t,scope:n,method:i,splitKey:o="+"}=e;Ni(t).forEach(s=>{const a=s.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":Ke(c);if(!j[u])return;n||(n=gt());const d=l>1?ki(de,a):[],w=[];j[u]=j[u].filter(m=>{const y=(i?m.method===i:!0)&&m.scope===n&&Er(m.mods,d);return y&&w.push(m.element),!y}),w.forEach(m=>bn(m))})};function Bi(e,t,n,i){if(t.element!==i)return;let o;if(t.scope===n||t.scope==="all"){o=t.mods.length>0;for(const r in ee)Object.prototype.hasOwnProperty.call(ee,r)&&(!ee[r]&&t.mods.indexOf(+r)>-1||ee[r]&&t.mods.indexOf(+r)===-1)&&(o=!1);(t.mods.length===0&&!ee[16]&&!ee[18]&&!ee[17]&&!ee[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(W),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function _i(e,t){const n=j["*"];let i=e.keyCode||e.which||e.charCode;if(e.key&&e.key.toLowerCase()==="capslock"||!ae.filter.call(this,e))return;if((i===93||i===224)&&(i=91),W.indexOf(i)===-1&&i!==229&&W.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=ft[a];e[a]&&W.indexOf(l)===-1?W.push(l):!e[a]&&W.indexOf(l)>-1?W.splice(W.indexOf(l),1):a==="metaKey"&&e[a]&&(W=W.filter(c=>c in ft||c===i))}),i in ee){ee[i]=!0;for(const a in de)if(Object.prototype.hasOwnProperty.call(de,a)){const l=ft[de[a]];ae[a]=e[l]}if(!n)return}for(const a in ee)Object.prototype.hasOwnProperty.call(ee,a)&&(ee[a]=e[ft[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(W.indexOf(17)===-1&&W.push(17),W.indexOf(18)===-1&&W.push(18),ee[17]=!0,ee[18]=!0);const o=gt();if(n)for(let a=0;a<n.length;a++)n[a].scope===o&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&Bi(e,n[a],o,t);if(!(i in j))return;const r=j[i],s=r.length;for(let a=0;a<s;a++)if((e.type==="keydown"&&r[a].keydown||e.type==="keyup"&&r[a].keyup)&&r[a].key){const l=r[a],{splitKey:c}=l,u=l.key.split(c),d=[];for(let w=0;w<u.length;w++)d.push(Ke(u[w]));d.sort().join("")===W.sort().join("")&&Bi(e,l,o,t)}}function ae(e,t,n){W=[];const i=Ni(e);let o=[],r="all",s=document,a=0,l=!1,c=!0,u="+",d=!1,w=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(r=t.scope),t.element&&(s=t.element),t.keyup&&(l=t.keyup),t.keydown!==void 0&&(c=t.keydown),t.capture!==void 0&&(d=t.capture),typeof t.splitKey=="string"&&(u=t.splitKey),t.single===!0&&(w=!0)),typeof t=="string"&&(r=t),w&&Mi(e,r);a<i.length;a++)e=i[a].split(u),o=[],e.length>1&&(o=ki(de,e)),e=e[e.length-1],e=e==="*"?"*":Ke(e),e in j||(j[e]=[]),j[e].push({keyup:l,keydown:c,scope:r,mods:o,shortcut:i[a],method:n,key:i[a],splitKey:u,element:s});if(typeof s<"u"&&window){if(!Ee.has(s)){const m=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return _i(y,s)},h=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;_i(y,s),Lr(y)};Ee.set(s,{keydownListener:m,keyupListenr:h,capture:d}),mn(s,"keydown",m,d),mn(s,"keyup",h,d)}if(!ht){const m=()=>{W=[]};ht={listener:m,capture:d},mn(window,"focus",m,d)}}}function Ir(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(j).forEach(n=>{j[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function bn(e){const t=Object.values(j).flat();if(t.findIndex(i=>{let{element:o}=i;return o===e})<0){const{keydownListener:i,keyupListenr:o,capture:r}=Ee.get(e)||{};i&&o&&(dt(e,"keyup",o,r),dt(e,"keydown",i,r),Ee.delete(e))}if((t.length<=0||Ee.size<=0)&&(Object.keys(Ee).forEach(o=>{const{keydownListener:r,keyupListenr:s,capture:a}=Ee.get(o)||{};r&&s&&(dt(o,"keyup",s,a),dt(o,"keydown",r,a),Ee.delete(o))}),Ee.clear(),Object.keys(j).forEach(o=>delete j[o]),ht)){const{listener:o,capture:r}=ht;dt(window,"focus",o,r),ht=null}}const wn={getPressedKeyString:xr,setScope:Ii,getScope:gt,deleteScope:Nr,getPressedKeyCodes:Or,getAllKeyCodes:Tr,isPressed:kr,filter:Rr,trigger:Ir,unbind:Mi,keyMap:ut,modifier:de,modifierMap:ft};for(const e in wn)Object.prototype.hasOwnProperty.call(wn,e)&&(ae[e]=wn[e]);if(typeof window<"u"){const e=window.hotkeys;ae.noConflict=t=>(t&&window.hotkeys===ae&&(window.hotkeys=e),ae),window.hotkeys=ae}async function Mr(e,t,n=(()=>!1)){do{if(await e(),await n())break;const i=t;await new Promise((o=>setTimeout(o,Math.max(0,i))))}while(!await n())}const Ui=300,Di=["up","down","left","right"],Hi=Zt?"⌘+a":"ctrl+a",Br=[...Di.map(e=>`shift+${e}`),Hi],Pi=(e,t,n,i)=>{const{store:o,selection:r}=t;let s;const{annotatingEnabled:a,offsetReferenceSelector:l,selectionMode:c,dismissOnNotAnnotatable:u="NEVER"}=i;let d,w=a,m="CREATE_NEW",h,y,x,g;const f=O=>{w=O,L.clear(),O||(y=void 0,h=void 0,x=void 0,g=void 0)},M=O=>m=O||"CREATE_NEW",_=O=>d=O,k=O=>s=O,T=O=>{if(m==="ADD_TO_CURRENT")return!0;if(i.allowModifierSelect){const U=O;return Zt?U.metaKey:U.ctrlKey}else return!1},I=()=>{if(!w||x===!1)return;const{selected:O}=r;if(T(g)&&O.length===1&&O[0].editable){const G=o.getAnnotation(O[0].id);if(G!=null&&G.target){y=G.target,h={annotation:G.id,selector:[],created:y.created,creator:y.creator,updated:new Date,updatedBy:s};return}}y=void 0,h={annotation:Ei(),selector:[],created:new Date,creator:s}},L=ot(O=>{if(!w)return;const U=document.getSelection();if(!(U!=null&&U.anchorNode))return;const G=Array.from(Array(U.rangeCount).keys()).map(J=>U.getRangeAt(J));if(!G.some(J=>J.intersectsNode(e))){h=void 0;return}const Be=O.timeStamp-((g==null?void 0:g.timeStamp)||O.timeStamp);if((g==null?void 0:g.type)==="pointerdown"&&(Be<1e3&&!h||U.isCollapsed&&Be<Ui)&&I(),h||I(),U.isCollapsed){o.getAnnotation(h.annotation)&&!T(g)&&(r.clear(),o.deleteAnnotation(h.annotation));return}const me=G.map(J=>qn(J,e));if(me.every(J=>Kn(J)))return;const be=me.flatMap(J=>Fn(e,J.cloneRange()));if(!(be.length>0&&!h||be.length!==h.selector.length||be.some((J,pt)=>{var yn;return J.toString()!==((yn=h.selector[pt])==null?void 0:yn.quote)})))return;const Ut=y?jn([...y.selector.map(J=>J.range),...be]):be;h={...h,selector:Ut.map(J=>$n(J,e,l)),updated:new Date},o.getAnnotation(h.annotation)?o.updateTarget(h,X.LOCAL):T(O)||r.clear()},10),D=O=>{g=bt(O),x=g.button===0},P=async O=>{if(!x)return;const U=bt(O),G=()=>{const{x:me,y:be}=e.getBoundingClientRect();if(We(e,U.target)){(typeof u=="function"?u(U,e):u==="ALWAYS")&&r.clear();return}const Re=U.target instanceof Node&&e.contains(U.target)&&o.getAt(U.clientX-me,U.clientY-be,c==="all",d);if(Re){const{selected:Ut}=r,J=new Set(Ut.map(mt=>mt.id)),pt=Array.isArray(Re)?Re.map(mt=>mt.id):[Re.id];(J.size!==pt.length||!pt.every(mt=>J.has(mt)))&&(n.emit("clickAnnotation",Re),r.userSelect(pt,U))}else r.clear()};if(U.timeStamp-g.timeStamp<Ui){await V();const me=document.getSelection(),be=We(e,g.target),Re=We(e,U.target);if(me!=null&&me.isCollapsed||be&&Re){h=void 0,G();return}}h&&h.selector.length>0&&(Y(),r.userSelect(h.annotation,U))},V=async()=>{const O=document.getSelection();let U=!1,G=O==null?void 0:O.isCollapsed;const Be=()=>G||U,me=1;return setTimeout(()=>U=!0,50),Mr(()=>G=O==null?void 0:O.isCollapsed,me,Be)},S=O=>{const U=document.getSelection();U!=null&&U.isCollapsed||((!h||h.selector.length===0)&&L(O),h&&(Y(),r.userSelect(h.annotation,bt(O))))},C=O=>{w&&O.key==="Shift"&&h&&(document.getSelection().isCollapsed||(Y(),r.userSelect(h.annotation,je(O))))},R=O=>{const U=()=>setTimeout(()=>{(h==null?void 0:h.selector.length)>0&&(r.clear(),o.addAnnotation({id:h.annotation,bodies:[],target:h}),r.userSelect(h.annotation,je(O))),document.removeEventListener("selectionchange",U)},100);document.addEventListener("selectionchange",U),I()};ae(Br.join(","),{element:e,keydown:!0,keyup:!1},O=>{O.repeat||(g=je(O))}),ae(Hi,{keydown:!0,keyup:!1},O=>{g=je(O),R(O)});const N=O=>{O.repeat||O.target!==e&&O.target!==document.body||(h=void 0,r.clear())};ae(Di.join(","),{keydown:!0,keyup:!1},N);const Y=()=>{const O=o.getAnnotation(h.annotation);if(!O){o.addAnnotation({id:h.annotation,bodies:[],target:h});return}const{target:{updated:U}}=O,{updated:G}=h;(!U||!G||U<G)&&o.updateTarget(h)};return document.addEventListener("pointerdown",D),document.addEventListener("pointerup",P),document.addEventListener("contextmenu",S),e.addEventListener("keyup",C),e.addEventListener("selectstart",I),document.addEventListener("selectionchange",L),{destroy:()=>{h=void 0,y=void 0,x=void 0,g=void 0,L.clear(),document.removeEventListener("pointerdown",D),document.removeEventListener("pointerup",P),document.removeEventListener("contextmenu",S),e.removeEventListener("keyup",C),e.removeEventListener("selectstart",I),document.removeEventListener("selectionchange",L),ae.unbind()},setFilter:_,setUser:k,setAnnotatingEnabled:f,setAnnotatingMode:M}},Vi=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),Xi="SPANS",_r=(e,t={})=>{An(e),Vn(e);const n=Vi(t,{annotatingEnabled:!0,user:Po()}),i=Ri(e,n),{selection:o,viewport:r}=i,s=i.store,a=ko(s),l=Lo(i,a,n.adapter);let c=n.user;const u=typeof n.renderer!="function"?n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Xi:n.renderer||Xi:null,d=u===null?n.renderer(e,i,r):u==="SPANS"?vi(e,i,r):u==="CSS_HIGHLIGHTS"?bi(e,i,r):u==="CANVAS"?oi(e,i,r):void 0;if(!d)throw`Unknown renderer implementation: ${n.renderer}`;console.debug(u?`Using ${u} renderer`:"Using custom renderer implementation"),n.style&&d.setStyle(n.style);const w=Pi(e,i,l,n);w.setUser(c);const m=Mo(i,a,n.adapter),h=()=>c,y=T=>{w.setAnnotatingEnabled(T===void 0?!0:T)},x=T=>{w.setAnnotatingMode(T)},g=T=>{d.setFilter(T),w.setFilter(T)},f=T=>{c=T,w.setUser(T)},M=T=>{T&&(d.setPainter(Oi(T,n.presence)),T.on("selectionChange",()=>d.redraw()))},_=T=>{T?o.setSelected(T):o.clear()};return{...m,destroy:()=>{d.destroy(),w.destroy(),a.destroy()},element:e,getUser:h,setAnnotatingEnabled:y,setAnnotatingMode:x,setFilter:g,setStyle:d.setStyle.bind(d),redraw:d.redraw.bind(d),setUser:f,setSelected:_,setPresenceProvider:M,setVisible:d.setVisible.bind(d),on:l.on,off:l.off,scrollIntoView:Qn(e,s),state:i}};B.DEFAULT_SELECTED_STYLE=rt,B.DEFAULT_STYLE=pe,B.NOT_ANNOTATABLE_CLASS=ke,B.NOT_ANNOTATABLE_SELECTOR=Ne,B.Origin=X,B.UserSelectAction=on,B.W3CTextFormat=cr,B.cancelSingleClickEvents=An,B.cloneKeyboardEvent=je,B.clonePointerEvent=bt,B.createBaseRenderer=Lt,B.createBody=wo,B.createCanvasRenderer=oi,B.createHighlightsRenderer=bi,B.createPresencePainter=Oi,B.createRenderer=mi,B.createSelectionHandler=Pi,B.createSpansRenderer=vi,B.createTextAnnotator=_r,B.createTextAnnotatorState=Ri,B.fillDefaults=Vi,B.getHighlightClientRects=Xn,B.getQuoteContext=Yn,B.getRangeAnnotatableContents=Tt,B.isMac=Zt,B.isNodeWhitespaceOrEmpty=io,B.isNotAnnotatable=We,B.isRangeAnnotatable=vn,B.isRangeWhitespaceOrEmpty=Kn,B.isRevived=ge,B.mergeClientRects=Wn,B.mergeRanges=jn,B.paint=yi,B.parseW3CTextAnnotation=Si,B.programmaticallyFocusable=Vn,B.rangeToSelector=$n,B.reviveAnnotation=Rt,B.reviveSelector=tn,B.reviveTarget=it,B.scrollIntoView=Qn,B.serializeW3CTextAnnotation=Ci,B.splitAnnotatableRanges=Fn,B.toDomRectList=so,B.toParentBounds=zn,B.toViewportBounds=ao,B.trimRangeToContainer=qn,B.whitespaceOrEmptyRegex=en,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(I,ke){typeof exports=="object"&&typeof module<"u"?ke(exports):typeof define=="function"&&define.amd?define(["exports"],ke):(I=typeof globalThis<"u"?globalThis:I||self,ke(I.RecogitoJS={}))})(this,(function(I){"use strict";const ke="not-annotatable",Ne=`.${ke}`,We=(e,t)=>e.contains(t)?!!(t instanceof HTMLElement?t.closest(Ne):t.parentElement?.closest(Ne)):!0,yn=(e,t)=>{const n=t.commonAncestorContainer;return!We(e,n)},vn=e=>e.addEventListener("click",t=>{!t.target.closest(Ne)&&!t.target.closest("a")&&t.preventDefault()}),bt=e=>({...e,type:e.type,x:e.x,y:e.y,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,screenX:e.screenX,screenY:e.screenY,isPrimary:e.isPrimary,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,button:e.button,buttons:e.buttons,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,eventPhase:e.eventPhase,pointerId:e.pointerId,pointerType:e.pointerType,timeStamp:e.timeStamp}),je=e=>({...e,type:e.type,key:e.key,code:e.code,location:e.location,repeat:e.repeat,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,timeStamp:e.timeStamp});var Xi="2.0.6",Fi=500,En="user-agent",_e="",An="?",$={FUNCTION:"function",OBJECT:"object",STRING:"string",UNDEFINED:"undefined"},ne="browser",be="cpu",ue="device",le="engine",oe="os",Ue="result",y="name",p="type",v="vendor",E="version",te="architecture",$e="major",b="model",ze="console",B="mobile",K="tablet",z="smarttv",fe="wearable",wt="xr",qe="embedded",De="inapp",Dt="brands",Le="formFactors",Pt="fullVersionList",Pe="platform",Ht="platformVersion",yt="bitness",Ae="sec-ch-ua",Yi=Ae+"-full-version-list",Ki=Ae+"-arch",Wi=Ae+"-"+yt,ji=Ae+"-form-factors",$i=Ae+"-"+B,zi=Ae+"-"+b,Sn=Ae+"-"+Pe,qi=Sn+"-version",Cn=[Dt,Pt,B,b,Pe,Ht,te,Le,yt],vt="Amazon",He="Apple",On="ASUS",xn="BlackBerry",Ie="Google",Tn="Huawei",Vt="Lenovo",Rn="Honor",Et="LG",Xt="Microsoft",Ft="Motorola",Yt="Nvidia",kn="OnePlus",Kt="OPPO",Ge="Samsung",Nn="Sharp",Je="Sony",Wt="Xiaomi",jt="Zebra",Ln="Chrome",In="Chromium",Se="Chromecast",At="Edge",Qe="Firefox",Ze="Opera",$t="Facebook",Mn="Sogou",Ve="Mobile ",et=" Browser",zt="Windows",Gi=typeof window!==$.UNDEFINED,ie=Gi&&window.navigator?window.navigator:void 0,Ce=ie&&ie.userAgentData?ie.userAgentData:void 0,Ji=function(e,t){var n={},i=t;if(!Ct(t)){i={};for(var o in t)for(var r in t[o])i[r]=t[o][r].concat(i[r]?i[r]:[])}for(var s in e)n[s]=i[s]&&i[s].length%2===0?i[s].concat(e[s]):e[s];return n},St=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},qt=function(e,t){if(typeof e===$.OBJECT&&e.length>0){for(var n in e)if(Oe(t)==Oe(e[n]))return!0;return!1}return tt(e)?Oe(t)==Oe(e):!1},Ct=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?Ct(e[n]):!1)},tt=function(e){return typeof e===$.STRING},Gt=function(e){if(e){for(var t=[],n=Xe(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var o=Ot(n[i]).split(";v=");t[i]={brand:o[0],version:o[1]}}else t[i]=Ot(n[i]);return t}},Oe=function(e){return tt(e)?e.toLowerCase():e},Jt=function(e){return tt(e)?Xe(/[^\d\.]/g,e).split(".")[0]:void 0},we=function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];typeof n==$.OBJECT&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Xe=function(e,t){return tt(t)?t.replace(e,_e):t},nt=function(e){return Xe(/\\?\"/g,e)},Ot=function(e,t){return e=Xe(/^\s\s*/,String(e)),typeof t===$.UNDEFINED?e:e.substring(0,t)},Qt=function(e,t){if(!(!e||!t))for(var n=0,i,o,r,s,a,l;n<t.length&&!a;){var c=t[n],f=t[n+1];for(i=o=0;i<c.length&&!a&&c[i];)if(a=c[i++].exec(e),a)for(r=0;r<f.length;r++)l=a[++o],s=f[r],typeof s===$.OBJECT&&s.length>0?s.length===2?typeof s[1]==$.FUNCTION?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]===$.FUNCTION&&!(s[1].exec&&s[1].test)?s.length>3?this[s[0]]=l?s[1].apply(this,s.slice(2)):void 0:this[s[0]]=l?s[1].call(this,l,s[2]):void 0:s.length==3?this[s[0]]=l?l.replace(s[1],s[2]):void 0:s.length==4?this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):void 0:s.length>4&&(this[s[0]]=l?s[3].apply(this,[l.replace(s[1],s[2])].concat(s.slice(4))):void 0)):this[s]=l||void 0;n+=2}},he=function(e,t){for(var n in t)if(typeof t[n]===$.OBJECT&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(qt(t[n][i],e))return n===An?void 0:n}else if(qt(t[n],e))return n===An?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},Bn={ME:"4.90","NT 3.51":"3.51","NT 4.0":"4.0",2e3:["5.0","5.01"],XP:["5.1","5.2"],Vista:"6.0",7:"6.1",8:"6.2","8.1":"6.3",10:["6.4","10.0"],NT:""},_n={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},Qi={Chrome:"Google Chrome",Edge:"Microsoft Edge","Edge WebView2":"Microsoft Edge WebView2","Chrome WebView":"Android WebView","Chrome Headless":"HeadlessChrome","Huawei Browser":"HuaweiBrowser","MIUI Browser":"Miui Browser","Opera Mobi":"OperaMobile",Yandex:"YaBrowser"},Un={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[E,[y,Ve+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[E,[y,At+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[E,[y,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[y,E],[/opios[\/ ]+([\w\.]+)/i],[E,[y,Ze+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[E,[y,Ze+" GX"]],[/\bopr\/([\w\.]+)/i],[E,[y,Ze]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[E,[y,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[E,[y,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:lg |qute)browser|palemoon)\/([-\w\.]+)/i,/(heytap|ovi|115|surf|qwant)browser\/([\d\.]+)/i,/(qwant)(?:ios|mobile)\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[y,E],[/quark(?:pc)?\/([-\w\.]+)/i],[E,[y,"Quark"]],[/\bddg\/([\w\.]+)/i],[E,[y,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[E,[y,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[E,[y,"WeChat"]],[/konqueror\/([\w\.]+)/i],[E,[y,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[E,[y,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[E,[y,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[E,[y,"Smart "+Vt+et]],[/(avast|avg)\/([\w\.]+)/i],[[y,/(.+)/,"$1 Secure"+et],E],[/\bfocus\/([\w\.]+)/i],[E,[y,Qe+" Focus"]],[/\bopt\/([\w\.]+)/i],[E,[y,Ze+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[E,[y,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[E,[y,"Dolphin"]],[/coast\/([\w\.]+)/i],[E,[y,Ze+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[E,[y,"MIUI"+et]],[/fxios\/([\w\.-]+)/i],[E,[y,Ve+Qe]],[/\bqihoobrowser\/?([\w\.]*)/i],[E,[y,"360"]],[/\b(qq)\/([\w\.]+)/i],[[y,/(.+)/,"$1Browser"],E],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[y,/(.+)/,"$1"+et],E],[/samsungbrowser\/([\w\.]+)/i],[E,[y,Ge+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[E,[y,Mn+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[y,Mn+" Mobile"],E],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[y,E],[/(lbbrowser|rekonq)/i],[y],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[E,y],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[y,$t],E,[p,De]],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(bing)(?:web|sapphire)\/([\w\.]+)/i,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[y,E,[p,De]],[/\bgsa\/([\w\.]+) .*safari\//i],[E,[y,"GSA"],[p,De]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[E,[y,"TikTok"],[p,De]],[/\[(linkedin)app\]/i],[y,[p,De]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[y,/(.+)/,"Zalo"],E,[p,De]],[/(chromium)[\/ ]([-\w\.]+)/i],[y,E],[/headlesschrome(?:\/([\w\.]+)| )/i],[E,[y,Ln+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[E,[y,At+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[y,Ln+" WebView"],E],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[E,[y,"Android"+et]],[/chrome\/([\w\.]+) mobile/i],[E,[y,Ve+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[y,E],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[E,[y,Ve+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[y,Ve+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[E,y],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[y,[E,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[y,E],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[y,Ve+Qe],E],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[y,"Netscape"],E],[/(wolvic|librewolf)\/([\w\.]+)/i],[y,E],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[E,[y,Qe+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+(?= .+rv\:.+gecko\/\d+)|[0-4][\w\.]+(?!.+compatible))/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[y,[E,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[y,[E,/[^\d\.]+./,_e]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[te,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[te,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[te,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[te,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[te,"arm"]],[/ sun4\w[;\)]/i],[[te,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i,/((ppc|powerpc)(64)?)( mac|;|\))/i,/(?:osf1|[freopnt]{3,4}bsd) (alpha)/i],[[te,/ower/,_e,Oe]],[/mc680.0/i],[[te,"68k"]],[/winnt.+\[axp/i],[[te,"alpha"]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[b,[v,Ge],[p,K]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,/sec-(sgh\w+)/i],[b,[v,Ge],[p,B]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)[\/\);]/i],[b,[v,He],[p,B]],[/\b(?:ios|apple\w+)\/.+[\(\/](ipad)/i,/\b(ipad)[\d,]*[;\] ].+(mac |i(pad)?)os/i],[b,[v,He],[p,K]],[/(macintosh);/i],[b,[v,He]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[b,[v,Nn],[p,B]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[b,[v,Rn],[p,K]],[/honor([-\w ]+)[;\)]/i],[b,[v,Rn],[p,B]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[b,[v,Tn],[p,K]],[/(?:huawei) ?([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i],[b,[v,Tn],[p,B]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b(?:xiao)?((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[b,/_/g," "],[v,Wt],[p,K]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note|max|cc)?[_ ]?(?:\d{0,2}\w?)[_ ]?(?:plus|se|lite|pro)?( 5g|lte)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[b,/_/g," "],[v,Wt],[p,B]],[/droid.+; (cph2[3-6]\d[13579]|((gm|hd)19|(ac|be|in|kb)20|(d[en]|eb|le|mt)21|ne22)[0-2]\d|p[g-k]\w[1m]10)\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[b,[v,kn],[p,B]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[b,[v,Kt],[p,B]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[b,[v,he,{OnePlus:["203","304","403","404","413","415"],"*":Kt}],[p,K]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[b,[v,"BLU"],[p,B]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[b,[v,"Vivo"],[p,B]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[b,[v,"Realme"],[p,B]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[b,[v,Vt],[p,K]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[b,[v,Vt],[p,B]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,/((?:moto(?! 360)[-\w\(\) ]+|xt\d{3,4}[cgkosw\+]?[-\d]*|nexus 6)(?= bui|\)))/i],[b,[v,Ft],[p,B]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[b,[v,Ft],[p,K]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[b,[v,Et],[p,K]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,/\blg-?([\d\w]+) bui/i],[b,[v,Et],[p,B]],[/(nokia) (t[12][01])/i],[v,b,[p,K]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*?))( bui|\)|;|\/)/i],[[b,/_/g," "],[p,B],[v,"Nokia"]],[/(pixel (c|tablet))\b/i],[b,[v,Ie],[p,K]],[/droid.+;(?: google)? (g(01[13]a|020[aem]|025[jn]|1b60|1f8f|2ybb|4s1m|576d|5nz6|8hhn|8vou|a02099|c15s|d1yq|e2ae|ec77|gh2x|kv4x|p4bc|pj41|r83y|tt9q|ur25|wvk6)|pixel[\d ]*a?( pro)?( xl)?( fold)?( \(5g\))?)( bui|\))/i],[b,[v,Ie],[p,B]],[/(google) (pixelbook( go)?)/i],[v,b],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-\w\w\d\d)(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[b,[v,Je],[p,B]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[b,"Xperia Tablet"],[v,Je],[p,K]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[b,[v,vt],[p,K]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[b,/(.+)/g,"Fire Phone $1"],[v,vt],[p,B]],[/(playbook);[-\w\),; ]+(rim)/i],[b,v,[p,K]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/(?:blackberry|\(bb10;) (\w+)/i],[b,[v,xn],[p,B]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[b,[v,On],[p,K]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[b,[v,On],[p,B]],[/(nexus 9)/i],[b,[v,"HTC"],[p,K]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[v,[b,/_/g," "],[p,B]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[b,[v,"TCL"],[p,K]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[b,[v,"TCL"],[p,B]],[/(itel) ((\w+))/i],[[v,Oe],b,[p,he,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[b,[v,"Acer"],[p,K]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[b,[v,"Meizu"],[p,B]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[b,[v,"Ulefone"],[p,B]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[b,[v,"Energizer"],[p,B]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[b,[v,"Cat"],[p,B]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[b,[v,"Smartfren"],[p,B]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[b,[v,"Nothing"],[p,B]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[b,[v,"Archos"],[p,K]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[b,[v,"Archos"],[p,B]],[/; (n159v)/i],[b,[v,"HMD"],[p,B]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[v,b,[p,K]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|hmd|imo|infinix|lava|oneplus|tcl|wiko)[_ ]([\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i,/(hisense) ([ehv][\w ]+)\)/i,/droid[^;]+; (philips)[_ ]([sv-x][\d]{3,4}[xz]?)/i],[v,b,[p,B]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[v,b,[p,K]],[/(surface duo)/i],[b,[v,Xt],[p,K]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[b,[v,"Fairphone"],[p,B]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[b,[v,Yt],[p,K]],[/(sprint) (\w+)/i],[v,b,[p,B]],[/(kin\.[onetw]{3})/i],[[b,/\./g," "],[v,Xt],[p,B]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[b,[v,jt],[p,K]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[b,[v,jt],[p,B]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[v,[p,z]],[/hbbtv.+maple;(\d+)/i],[[b,/^/,"SmartTV"],[v,Ge],[p,z]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[v,b,[p,z]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[v,Et],[p,z]],[/(apple) ?tv/i],[v,[b,He+" TV"],[p,z]],[/crkey.*devicetype\/chromecast/i],[[b,Se+" Third Generation"],[v,Ie],[p,z]],[/crkey.*devicetype\/([^/]*)/i],[[b,/^/,"Chromecast "],[v,Ie],[p,z]],[/fuchsia.*crkey/i],[[b,Se+" Nest Hub"],[v,Ie],[p,z]],[/crkey/i],[[b,Se],[v,Ie],[p,z]],[/(portaltv)/i],[b,[v,$t],[p,z]],[/droid.+aft(\w+)( bui|\))/i],[b,[v,vt],[p,z]],[/(shield \w+ tv)/i],[b,[v,Yt],[p,z]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[b,[v,Nn],[p,z]],[/(bravia[\w ]+)( bui|\))/i],[b,[v,Je],[p,z]],[/(mi(tv|box)-?\w+) bui/i],[b,[v,Wt],[p,z]],[/Hbbtv.*(technisat) (.*);/i],[v,b,[p,z]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[v,/.+\/(\w+)/,"$1",he,{LG:"lge"}],[b,Ot],[p,z]],[/(playstation \w+)/i],[b,[v,Je],[p,ze]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[b,[v,Xt],[p,ze]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[v,b,[p,ze]],[/droid.+; (shield)( bui|\))/i],[b,[v,Yt],[p,ze]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[b,[v,Ge],[p,fe]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[v,b,[p,fe]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[b,[v,Kt],[p,fe]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[b,[v,He],[p,fe]],[/(opwwe\d{3})/i],[b,[v,kn],[p,fe]],[/(moto 360)/i],[b,[v,Ft],[p,fe]],[/(smartwatch 3)/i],[b,[v,Je],[p,fe]],[/(g watch r)/i],[b,[v,Et],[p,fe]],[/droid.+; (wt63?0{2,3})\)/i],[b,[v,jt],[p,fe]],[/droid.+; (glass) \d/i],[b,[v,Ie],[p,wt]],[/(pico) ([\w ]+) os\d/i],[v,b,[p,wt]],[/(quest( \d| pro)?s?).+vr/i],[b,[v,$t],[p,wt]],[/mobile vr; rv.+firefox/i],[[p,wt]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[v,[p,qe]],[/(aeobc)\b/i],[b,[v,vt],[p,qe]],[/(homepod).+mac os/i],[b,[v,He],[p,qe]],[/windows iot/i],[[p,qe]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[b,[p,z]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[p,z]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew|; hmsc).+?(mobile|vr|\d) safari/i],[b,[p,he,{mobile:"Mobile",xr:"VR","*":K}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[p,K]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[p,B]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[b,[v,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[E,[y,At+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[y,E],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[E,[y,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[y,E],[/ladybird\//i],[[y,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[E,y]],os:[[/(windows nt) (6\.[23]); arm/i],[[y,/N/,"R"],[E,he,Bn]],[/(windows (?:phone|mobile|iot))(?: os)?[\/ ]?([\d\.]*( se)?)/i,/(windows)[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i],[y,E],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[E,/(;|\))/g,"",he,Bn],[y,zt]],[/(windows ce)\/?([\d\.]*)/i],[y,E],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv|ios(?=.+ip(?:ad|hone))|ip(?:ad|hone)(?: |.+i(?:pad)?)os)[\/ ]([\w\.]+)/i,/cfnetwork\/.+darwin/i],[[E,/_/g,"."],[y,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[y,"macOS"],[E,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[E,[y,Se+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[E,[y,Se+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[E,[y,Se+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[E,[y,Se+" Linux"]],[/crkey\/([\d\.]+)/i],[E,[y,Se]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[E,y],[/(ubuntu) ([\w\.]+) like android/i],[[y,/(.+)/,"$1 Touch"],E],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[y,E],[/\(bb(10);/i],[E,[y,xn]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[E,[y,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[E,[y,Qe+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[E,[y,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[E,he,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[y,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[E,[y,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[y,"Chrome OS"],E],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/linux.+(mint)[\/\(\) ]?([\w\.]*)/i,/(mageia|vectorlinux|fuchsia|arcaos|arch(?= ?linux))[;l ]([\d\.]*)/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire|knoppix)(?: gnu[\/ ]linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/\b(aix)[; ]([1-9\.]{0,4})/i,/(hurd|linux|morphos)(?: (?:arm|x86|ppc)\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) ?(r\d)?/i],[y,E],[/(sunos) ?([\d\.]*)/i],[[y,"Solaris"],E],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[y,E]]},xt=(function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return we.call(e.init,[[ne,[y,E,$e,p]],[be,[te]],[ue,[p,b,v]],[le,[y,E]],[oe,[y,E]]]),we.call(e.isIgnore,[[ne,[E,$e]],[le,[E]],[oe,[E]]]),we.call(e.isIgnoreRgx,[[ne,/ ?browser$/i],[oe,/ ?os$/i]]),we.call(e.toString,[[ne,[y,E]],[be,[te]],[ue,[v,b]],[le,[y,E]],[oe,[y,E]]]),e})(),Zi=function(e,t){var n=xt.init[t],i=xt.isIgnore[t]||0,o=xt.isIgnoreRgx[t]||0,r=xt.toString[t]||0;function s(){we.call(this,n)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Ce?Ce.getHighEntropyValues(Cn).then(function(a){return e.setCH(new Dn(a,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=Ue&&(s.prototype.is=function(a){var l=!1;for(var c in this)if(this.hasOwnProperty(c)&&!qt(i,c)&&Oe(o?Xe(o,this[c]):this[c])==Oe(o?Xe(o,a):a)){if(l=!0,a!=$.UNDEFINED)break}else if(a==$.UNDEFINED&&l){l=!l;break}return l},s.prototype.toString=function(){var a=_e;for(var l in r)typeof this[r[l]]!==$.UNDEFINED&&(a+=(a?" ":_e)+this[r[l]]);return a||$.UNDEFINED}),Ce||(s.prototype.then=function(a){var l=this,c=function(){for(var u in l)l.hasOwnProperty(u)&&(this[u]=l[u])};c.prototype={is:s.prototype.is,toString:s.prototype.toString};var f=new c;return a(f),f}),new s};function Dn(e,t){if(e=e||{},we.call(this,Cn),t)we.call(this,[[Dt,Gt(e[Ae])],[Pt,Gt(e[Yi])],[B,/\?1/.test(e[$i])],[b,nt(e[zi])],[Pe,nt(e[Sn])],[Ht,nt(e[qi])],[te,nt(e[Ki])],[Le,Gt(e[ji])],[yt,nt(e[Wi])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==$.UNDEFINED&&(this[n]=e[n])}function Pn(e,t,n,i){return this.get=function(o){return o?this.data.hasOwnProperty(o)?this.data[o]:void 0:this.data},this.set=function(o,r){return this.data[o]=r,this},this.setCH=function(o){return this.uaCH=o,this},this.detectFeature=function(){if(ie&&ie.userAgent==this.ua)switch(this.itemType){case ne:ie.brave&&typeof ie.brave.isBrave==$.FUNCTION&&this.set(y,"Brave");break;case ue:!this.get(p)&&Ce&&Ce[B]&&this.set(p,B),this.get(b)=="Macintosh"&&ie&&typeof ie.standalone!==$.UNDEFINED&&ie.maxTouchPoints&&ie.maxTouchPoints>2&&this.set(b,"iPad").set(p,K);break;case oe:!this.get(y)&&Ce&&Ce[Pe]&&this.set(y,Ce[Pe]);break;case Ue:var o=this.data,r=function(s){return o[s].getItem().detectFeature().get()};this.set(ne,r(ne)).set(be,r(be)).set(ue,r(ue)).set(le,r(le)).set(oe,r(oe))}return this},this.parseUA=function(){switch(this.itemType!=Ue&&Qt.call(this.data,this.ua,this.rgxMap),this.itemType){case ne:this.set($e,Jt(this.get(E)));break;case oe:if(this.get(y)=="iOS"&&this.get(E)=="18.6"){var o=/\) Version\/([\d\.]+)/.exec(this.ua);o&&parseInt(o[1].substring(0,2),10)>=26&&this.set(E,o[1])}break}return this},this.parseCH=function(){var o=this.uaCH,r=this.rgxMap;switch(this.itemType){case ne:case le:var s=o[Pt]||o[Dt],a;if(s)for(var l=0;l<s.length;l++){var c=s[l].brand||s[l],f=s[l].version;this.itemType==ne&&!/not.a.brand/i.test(c)&&(!a||/Chrom/.test(a)&&c!=In||a==At&&/WebView2/.test(c))&&(c=he(c,Qi),a=this.get(y),a&&!/Chrom/.test(a)&&/Chrom/.test(c)||this.set(y,c).set(E,f).set($e,Jt(f)),a=c),this.itemType==le&&c==In&&this.set(E,f)}break;case be:var u=o[te];u&&(u&&o[yt]=="64"&&(u+="64"),Qt.call(this.data,u+";",r));break;case ue:if(o[B]&&this.set(p,B),o[b]&&(this.set(b,o[b]),!this.get(p)||!this.get(v))){var A={};Qt.call(A,"droid 9; "+o[b]+")",r),!this.get(p)&&A.type&&this.set(p,A.type),!this.get(v)&&A.vendor&&this.set(v,A.vendor)}if(o[Le]){var m;if(typeof o[Le]!="string")for(var g=0;!m&&g<o[Le].length;)m=he(o[Le][g++],_n);else m=he(o[Le],_n);this.set(p,m)}break;case oe:var w=o[Pe];if(w){var x=o[Ht];w==zt&&(x=parseInt(Jt(x),10)>=13?"11":"10"),this.set(y,w).set(E,x)}this.get(y)==zt&&o[b]=="Xbox"&&this.set(y,"Xbox").set(E,void 0);break;case Ue:var h=this.data,d=function(N){return h[N].getItem().setCH(o).parseCH().get()};this.set(ne,d(ne)).set(be,d(be)).set(ue,d(ue)).set(le,d(le)).set(oe,d(oe))}return this},we.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",n],["data",Zi(this,e)]]),this}function ye(e,t,n){if(typeof e===$.OBJECT?(Ct(e,!0)?(typeof t===$.OBJECT&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===$.STRING&&!Ct(t,!0)&&(n=t,t=void 0),n)if(typeof n.append===$.FUNCTION){var i={};n.forEach(function(f,u){i[String(u).toLowerCase()]=f}),n=i}else{var o={};for(var r in n)n.hasOwnProperty(r)&&(o[String(r).toLowerCase()]=n[r]);n=o}if(!(this instanceof ye))return new ye(e,t,n).getResult();var s=typeof e===$.STRING?e:n&&n[En]?n[En]:ie&&ie.userAgent?ie.userAgent:_e,a=new Dn(n,!0),l=t?Ji(Un,t):Un,c=function(f){return f==Ue?function(){return new Pn(f,s,l,a).set("ua",s).set(ne,this.getBrowser()).set(be,this.getCPU()).set(ue,this.getDevice()).set(le,this.getEngine()).set(oe,this.getOS()).get()}:function(){return new Pn(f,s,l[f],a).parseUA().get()}};return we.call(this,[["getBrowser",c(ne)],["getCPU",c(be)],["getDevice",c(ue)],["getEngine",c(le)],["getOS",c(oe)],["getResult",c(Ue)],["getUA",function(){return s}],["setUA",function(f){return tt(f)&&(s=Ot(f,Fi)),this}]]).setUA(s),this}ye.VERSION=Xi,ye.BROWSER=St([y,E,$e,p]),ye.CPU=St([te]),ye.DEVICE=St([b,v,p,ze,B,z,K,fe,qe]),ye.ENGINE=ye.OS=St([y,E]);const eo=Object.freeze({AIX:"AIX",AMIGA_OS:"Amiga OS",ANDROID:"Android",ANDROID_X86:"Android-x86",ARCAOS:"ArcaOS",ARCH:"Arch",BADA:"Bada",BEOS:"BeOS",BLACKBERRY:"BlackBerry",CENTOS:"CentOS",CHROME_OS:"Chrome OS",CHROMECAST:"Chromecast",CHROMECAST_ANDROID:"Chromecast Android",CHROMECAST_FUCHSIA:"Chromecast Fuchsia",CHROMECAST_LINUX:"Chromecast Linux",CHROMECAST_SMARTSPEAKER:"Chromecast SmartSpeaker",CONTIKI:"Contiki",DEBIAN:"Debian",DEEPIN:"Deepin",DRAGONFLY:"DragonFly",ELEMENTARY_OS:"elementary OS",FEDORA:"Fedora",FIREFOX_OS:"Firefox OS",FREEBSD:"FreeBSD",FUCHSIA:"Fuchsia",GENTOO:"Gentoo",GHOSTBSD:"GhostBSD",GNU:"GNU",HAIKU:"Haiku",HARMONYOS:"HarmonyOS",HP_UX:"HP-UX",HURD:"Hurd",IOS:"iOS",JOLI:"Joli",KAIOS:"KaiOS",KNOPPIX:"Knoppix",KUBUNTU:"Kubuntu",LINPUS:"Linpus",LINSPIRE:"Linspire",LINUX:"Linux",MACOS:"macOS",MAEMO:"Maemo",MAGEIA:"Mageia",MANDRIVA:"Mandriva",MANJARO:"Manjaro",MEEGO:"MeeGo",MINIX:"Minix",MINT:"Mint",MORPH_OS:"Morph OS",NETBSD:"NetBSD",NETRANGE:"NetRange",NETTV:"NetTV",NINTENDO:"Nintendo",OPENHARMONY:"OpenHarmony",OPENBSD:"OpenBSD",OPENVMS:"OpenVMS",OS2:"OS/2",PALM:"Palm",PC_BSD:"PC-BSD",PCLINUXOS:"PCLinuxOS",PICO:"Pico",PLAN9:"Plan9",PLAYSTATION:"PlayStation",QNX:"QNX",RASPBIAN:"Raspbian",REDHAT:"RedHat",RIM_TABLET_OS:"RIM Tablet OS",RISC_OS:"RISC OS",SABAYON:"Sabayon",SAILFISH:"Sailfish",SERENITYOS:"SerenityOS",SERIES40:"Series40",SLACKWARE:"Slackware",SOLARIS:"Solaris",SUSE:"SUSE",SYMBIAN:"Symbian",TIZEN:"Tizen",UBUNTU:"Ubuntu",UBUNTU_TOUCH:"Ubuntu Touch",UNIX:"Unix",VECTORLINUX:"VectorLinux",WATCHOS:"watchOS",WEBOS:"WebOS",WINDOWS:"Windows",WINDOWS_CE:"Windows CE",WINDOWS_IOT:"Windows IoT",WINDOWS_MOBILE:"Windows Mobile",WINDOWS_PHONE:"Windows Phone",WINDOWS_RT:"Windows RT",XBOX:"Xbox",XUBUNTU:"Xubuntu",ZENWALK:"Zenwalk"}),Zt=ye().os.is(eo.MACOS),Hn=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},Vn=e=>{const t=[],n=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT);let i;for(;i=n.nextNode();)e.intersectsNode(i)&&t.push(i);if(t.length<2)return Array.from(e.getClientRects());{const o=t[0],r=t[t.length-1],s=document.createRange();if(s.selectNode(o),e.startContainer.nodeType===Node.TEXT_NODE)s.setStart(o,e.startOffset);else{const c=e.startContainer.childNodes[e.startOffset];c?s.setStartBefore(c):s.setStartAfter(e.startContainer)}const a=document.createRange();if(a.selectNode(r),e.endContainer.nodeType===Node.TEXT_NODE)a.setEnd(r,e.endOffset);else{const c=e.endContainer.childNodes[e.endOffset];c?a.setEndBefore(c):a.setEndAfter(e.endContainer)}const l=c=>{const f=document.createRange();return f.selectNode(c),Array.from(f.getClientRects())};return[...Array.from(s.getClientRects()),...t.slice(1,-1).flatMap(l),...Array.from(a.getClientRects())]}},to=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,i=>i instanceof HTMLElement&&i.classList.contains(ke)&&!i.parentElement.closest(Ne)&&e.intersectsNode(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Xn=(e,t)=>{if(!yn(e,t))return[];const n=[];let i=null;for(const o of to(t)){let r;i?(r=document.createRange(),r.setStartAfter(i),r.setEndBefore(o)):(r=t.cloneRange(),r.setEndBefore(o)),r.collapsed||n.push(r),i=o}if(i){const o=t.cloneRange();o.setStartAfter(i),o.collapsed||n.push(o)}return n.length>0?n:[t]},Tt=e=>{const t=e.cloneContents();return t.querySelectorAll(Ne).forEach(n=>n.remove()),t},Fn=(e,t,n=10,i)=>{const o=i?e.startContainer.parentElement.closest(i):t,r=document.createRange();r.setStart(o,0),r.setEnd(e.startContainer,e.startOffset);const s=Tt(r).textContent,a=document.createRange();a.setStart(e.endContainer,e.endOffset),o===document.body?a.setEnd(o,o.childNodes.length):a.setEndAfter(o);const l=Tt(a).textContent;return{prefix:s.substring(s.length-n),suffix:l.substring(0,n)}},ge=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),en=/^\s*$/,Yn=e=>en.test(e.toString()),no=e=>en.test(e.textContent||""),io=(e,t,n,i)=>{const o=a=>Math.round(a*10)/10,r={top:o(e.top),bottom:o(e.bottom),left:o(e.left),right:o(e.right)},s={top:o(t.top),bottom:o(t.bottom),left:o(t.left),right:o(t.right)};if(Math.abs(r.top-s.top)<i&&Math.abs(r.bottom-s.bottom)<i){if(Math.abs(r.left-s.right)<n||Math.abs(r.right-s.left)<n)return"inline-adjacent";if(r.left>=s.left&&r.right<=s.right)return"inline-is-contained";if(r.left<=s.left&&r.right>=s.right)return"inline-contains"}else if(r.top<=s.top&&r.bottom>=s.bottom){if(r.left<=s.left&&r.right>=s.right)return"block-contains"}else if(r.top>=s.top&&r.bottom<=s.bottom&&r.left>=s.left&&r.right<=s.right)return"block-is-contained"},oo=(e,t)=>{const n=Math.min(e.left,t.left),i=Math.max(e.right,t.right),o=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,o,i-n,r-o)},Kn=(e,t=.5,n=.5)=>e.reduce((i,o)=>{if(o.width===0||o.height===0)return i;let r=[...i],s=!1;for(const a of i){const l=io(o,a,t,n);if(l==="inline-adjacent"){r=r.map(c=>c===a?oo(o,a):c),s=!0;break}else if(l==="inline-contains"){r=r.map(c=>c===a?o:c),s=!0;break}else if(l==="inline-is-contained"){s=!0;break}else if(l==="block-contains"||l==="block-is-contained"){o.width<a.width&&(r=r.map(c=>c===a?o:c)),o.width===a.width&&o.height<a.width&&(r=r.map(c=>c===a?o:c)),s=!0;break}}return s?r:[...r,o]},[]),ro=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Wn=e=>{if(e.length===0)return[];if(e.length===1)return[e[0]];e.sort((o,r)=>{const s=o.compareBoundaryPoints(Range.START_TO_START,r);return s!==0?s:o.compareBoundaryPoints(Range.END_TO_END,r)});const[t,...n]=e,i=n.reduce((o,r)=>o.current.compareBoundaryPoints(Range.START_TO_END,r)>=0?(o.current.compareBoundaryPoints(Range.END_TO_END,r)<0&&o.current.setEnd(r.endContainer,r.endOffset),o):(o.merged.push(o.current),o.current=r.cloneRange(),o),{merged:[],current:t.cloneRange()});return[...i.merged,i.current]},jn=(e,t,n)=>{const i=document.createRange(),o=n?e.startContainer.parentElement.closest(n):t;i.setStart(o,0),i.setEnd(e.startContainer,e.startOffset);const r=Tt(i).textContent,s=e.toString(),a=r.length||0,l=a+s.length;return n?{quote:s,start:a,end:l,range:e,offsetReference:o}:{quote:s,start:a,end:l,range:e}},$n=(e,t)=>{const{left:n,top:i,right:o,bottom:r}=e;return new DOMRect(n-t.left,i-t.top,o-n,r-i)},so=(e,t)=>{const{left:n,top:i,right:o,bottom:r}=e;return new DOMRect(n+t.left,i+t.top,o-n,r-i)},tn=(e,t)=>{const{start:n,end:i}=e,o=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,f=>f.parentElement?.closest(Ne)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT);let s=0;const a=document.createRange();let l=r.nextNode();l===null&&console.error("Could not revive annotation target. Content missing.");let c=!o;for(;l!==null;){if(c||=typeof o?.contains=="function"?o.contains(l):!1,c){const f=l.textContent?.length||0;if(s+f>n){a.setStart(l,n-s);break}s+=f}l=r.nextNode()}for(;l!==null;){const f=l.textContent?.length||0;if(s+f>=i){a.setEnd(l,i-s);break}s+=f,l=r.nextNode()}return{...e,range:a}},it=(e,t)=>ge(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:tn(n,t))},Rt=(e,t)=>ge(e.target.selector)?e:{...e,target:it(e.target,t)},zn=(e,t)=>{const n=e.cloneRange();return t.contains(n.startContainer)||n.setStart(t,0),t.contains(n.endContainer)||n.setEnd(t,t.childNodes.length),n},qn=e=>{if(!e)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:qn(e.parentElement)},Gn=(e,t,n)=>{const i=n.getBoundingClientRect(),o=n.clientHeight,r=n.clientWidth,s=t.selector[0].range.getBoundingClientRect(),{width:a,height:l}=e.getAnnotationBounds(t.annotation),c=s.top-i.top,f=s.left-i.left,u=n.parentElement?n.scrollTop:0,A=n.parentElement?n.scrollLeft:0,m=c+u-(o-l)/2,g=f+A-(r-a)/2;n.scroll({top:m,left:g,behavior:"smooth"})},Jn=(e,t)=>(n,i)=>{const o=typeof n=="string"?n:n.id,r=i?typeof i=="string"?document.getElementById(i):i:qn(e);if(!r)return console.warn(`The scroll parent is missing for the annotation: ${o}`,{container:e}),!1;const s=t.getAnnotation(o);if(!s)return console.warn(`The annotation is missing in the store: ${o}`),!1;const{range:a}=s.target.selector[0];if(a&&!a.collapsed)return Gn(t,s.target,r),!0;const l=it(s.target,e),{range:c}=l.selector[0];return c&&!c.collapsed?(Gn(t,l,r),!0):!1};function ot(e,t=100,n={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw new RangeError("`wait` must not be negative.");if(typeof n=="boolean")throw new TypeError("The `options` parameter must be an object, not a boolean. Use `{immediate: true}` instead.");const{immediate:i}=n;let o,r,s,a,l;function c(){const A=o,m=r;return o=void 0,r=void 0,l=e.apply(A,m),l}function f(){const A=Date.now()-a;A<t&&A>=0?s=setTimeout(f,t-A):(s=void 0,i||(l=c()))}const u=function(...A){if(o&&this!==o&&Object.getPrototypeOf(this)===Object.getPrototypeOf(o))throw new Error("Debounced method called with different contexts of the same prototype.");o=this,r=A,a=Date.now();const m=i&&!s;if(s||(s=setTimeout(f,t)),m)return l=c(),l};return Object.defineProperty(u,"isPending",{get(){return s!==void 0}}),u.clear=()=>{s&&(clearTimeout(s),s=void 0,o=void 0,r=void 0)},u.flush=()=>{s&&u.trigger()},u.trigger=()=>{l=c(),u.clear()},u}const pe={fill:"rgb(0, 128, 255)",fillOpacity:.18},rt={fill:"rgb(0, 128, 255)",fillOpacity:.45};var Qn=Object.prototype.hasOwnProperty;function Me(e,t){var n,i;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((i=e.length)===t.length)for(;i--&&Me(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(Qn.call(e,n)&&++i&&!Qn.call(t,n)||!(n in t)||!Me(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}let ao=Symbol("clean"),ce=[],xe=0;const kt=4;let nn=e=>{let t=[],n={get(){return n.lc||n.listen(()=>{})(),n.value},lc:0,listen(i){return n.lc=t.push(i),()=>{for(let r=xe+kt;r<ce.length;)ce[r]===i?ce.splice(r,kt):r+=kt;let o=t.indexOf(i);~o&&(t.splice(o,1),--n.lc||n.off())}},notify(i,o){let r=!ce.length;for(let s of t)ce.push(s,n.value,i,o);if(r){for(xe=0;xe<ce.length;xe+=kt)ce[xe](ce[xe+1],ce[xe+2],ce[xe+3]);ce.length=0}},off(){},set(i){let o=n.value;o!==i&&(n.value=i,n.notify(o))},subscribe(i){let o=n.listen(i);return i(n.value),o},value:e};return process.env.NODE_ENV!=="production"&&(n[ao]=()=>{t=[],n.lc=0,n.off()}),n};const lo=e=>{const t=nn(null);return e.observe(({changes:n})=>{const i=t.get();if(i){(n.deleted||[]).some(r=>r.id===i)&&t.set(null);const o=(n.updated||[]).find(({oldValue:r})=>r.id===i);o&&t.set(o.newValue.id)}}),{get current(){return t.get()},subscribe:t.subscribe.bind(t),set:t.set.bind(t)}};var on=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(on||{});const rn={selected:[]},co=(e,t,n)=>{const i=nn(rn);let o=t;const r=()=>{Me(i.get(),rn)||i.set(rn)},s=()=>{var m;return((m=i.get().selected)==null?void 0:m.length)===0},a=m=>{if(s())return!1;const g=typeof m=="string"?m:m.id;return i.get().selected.some(w=>w.id===g)},l=(m,g)=>{let w;if(Array.isArray(m)){if(w=m.map(h=>e.getAnnotation(h)).filter(Boolean),w.length<m.length){console.warn("Invalid selection: "+m.filter(h=>!w.some(d=>d.id===h)));return}}else{const h=e.getAnnotation(m);if(!h){console.warn("Invalid selection: "+m);return}w=[h]}const x=w.reduce((h,d)=>{const N=A(d);return N==="EDIT"?[...h,{id:d.id,editable:!0}]:N==="SELECT"?[...h,{id:d.id}]:h},[]);i.set({selected:x,event:g})},c=(m,g)=>{const w=Array.isArray(m)?m:[m],x=w.map(h=>e.getAnnotation(h)).filter(h=>!!h);i.set({selected:x.map(h=>{const d=g===void 0?A(h)==="EDIT":g;return{id:h.id,editable:d}})}),x.length!==w.length&&console.warn("Invalid selection",m)},f=m=>{if(s())return!1;const{selected:g}=i.get();g.some(({id:w})=>m.includes(w))&&i.set({selected:g.filter(({id:w})=>!m.includes(w))})},u=m=>{o=m,c(i.get().selected.map(({id:g})=>g))},A=m=>uo(m,o,n);return e.observe(({changes:m})=>f((m.deleted||[]).map(g=>g.id))),{get event(){const m=i.get();return m?m.event:null},get selected(){const m=i.get();return m?[...m.selected]:null},get userSelectAction(){return o},clear:r,evalSelectAction:A,isEmpty:s,isSelected:a,setSelected:c,setUserSelectAction:u,subscribe:i.subscribe.bind(i),userSelect:l}},uo=(e,t,n)=>{const i=n?n.serialize(e):e;return typeof t=="function"?t(i):t||"EDIT"},J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));function fo(e,t=0){return(J[e[t+0]]+J[e[t+1]]+J[e[t+2]]+J[e[t+3]]+"-"+J[e[t+4]]+J[e[t+5]]+"-"+J[e[t+6]]+J[e[t+7]]+"-"+J[e[t+8]]+J[e[t+9]]+"-"+J[e[t+10]]+J[e[t+11]]+J[e[t+12]]+J[e[t+13]]+J[e[t+14]]+J[e[t+15]]).toLowerCase()}let sn;const ho=new Uint8Array(16);function go(){if(!sn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");sn=crypto.getRandomValues.bind(crypto)}return sn(ho)}const po=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Zn={randomUUID:po};function mo(e,t,n){var i;e=e||{};const o=e.random??((i=e.rng)==null?void 0:i.call(e))??go();if(o.length<16)throw new Error("Random bytes length must be >= 16");return o[6]=o[6]&15|64,o[8]=o[8]&63|128,fo(o)}function ei(e,t,n){return Zn.randomUUID&&!e?Zn.randomUUID():mo(e)}const an=e=>{const t=n=>{const i={...n};return n.created&&typeof n.created=="string"&&(i.created=new Date(n.created)),n.updated&&typeof n.updated=="string"&&(i.updated=new Date(n.updated)),i};return{...e,bodies:(e.bodies||[]).map(t),target:t(e.target)}},bo=(e,t,n,i)=>({id:ei(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:i,...t}),wo=(e,t)=>{const n=new Set(e.bodies.map(i=>i.id));return t.bodies.filter(i=>!n.has(i.id))},yo=(e,t)=>{const n=new Set(t.bodies.map(i=>i.id));return e.bodies.filter(i=>!n.has(i.id))},vo=(e,t)=>t.bodies.map(n=>{const i=e.bodies.find(o=>o.id===n.id);return{newBody:n,oldBody:i&&!Me(i,n)?i:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:i})=>({oldBody:n,newBody:i})),Eo=(e,t)=>!Me(e.target,t.target),ti=(e,t)=>{const n=wo(e,t),i=yo(e,t),o=vo(e,t);return{oldValue:e,newValue:t,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:o.length>0?o:void 0,targetUpdated:Eo(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var X=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e.SILENT="SILENT",e))(X||{});const Ao=(e,t)=>{var n,i;const{changes:o,origin:r}=t;if(!(e.options.origin?e.options.origin===r:r!=="SILENT"))return!1;if(e.options.ignore){const{ignore:s}=e.options,a=l=>l&&l.length>0;if(!(a(o.created)||a(o.deleted))){const l=(n=o.updated)==null?void 0:n.some(f=>a(f.bodiesCreated)||a(f.bodiesDeleted)||a(f.bodiesUpdated)),c=(i=o.updated)==null?void 0:i.some(f=>f.targetUpdated);if(s==="BODY_ONLY"&&l&&!c||s==="TARGET_ONLY"&&c&&!l)return!1}}if(e.options.annotations){const s=new Set([...(o.created||[]).map(a=>a.id),...(o.deleted||[]).map(a=>a.id),...(o.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(e.options.annotations)?e.options.annotations:[e.options.annotations]).find(a=>s.has(a))}else return!0},So=(e,t)=>{const n=new Set((e.created||[]).map(u=>u.id)),i=new Set((e.updated||[]).map(({newValue:u})=>u.id)),o=new Set((t.created||[]).map(u=>u.id)),r=new Set((t.deleted||[]).map(u=>u.id)),s=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>n.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(e.created||[]).filter(u=>!r.has(u.id)).map(u=>s.has(u.id)?t.updated.find(({oldValue:A})=>A.id===u.id).newValue:u),...t.created||[]],c=[...(e.deleted||[]).filter(u=>!o.has(u.id)),...(t.deleted||[]).filter(u=>!n.has(u.id))],f=[...(e.updated||[]).filter(({newValue:u})=>!r.has(u.id)).map(u=>{const{oldValue:A,newValue:m}=u;if(s.has(m.id)){const g=t.updated.find(w=>w.oldValue.id===m.id).newValue;return ti(A,g)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:c,updated:f}},Nt=e=>{const t=e.id===void 0?ei():e.id;return{...e,id:t,bodies:e.bodies===void 0?[]:e.bodies.map(n=>({...n,annotation:t})),target:{...e.target,annotation:t}}},Co=e=>e.id!==void 0,Oo=()=>{const e=new Map,t=new Map,n=[],i=(S,O={})=>{n.push({onChange:S,options:O})},o=S=>{const O=n.findIndex(T=>T.onChange==S);O>-1&&n.splice(O,1)},r=(S,O)=>{const T={origin:S,changes:{created:O.created||[],updated:O.updated||[],deleted:O.deleted||[]},state:[...e.values()]};n.forEach(L=>{Ao(L,T)&&L.onChange(T)})},s=(S,O=X.LOCAL)=>{if(S.id&&e.get(S.id))throw Error(`Cannot add annotation ${S.id} - exists already`);{const T=Nt(S);e.set(T.id,T),T.bodies.forEach(L=>t.set(L.id,T.id)),r(O,{created:[T]})}},a=(S,O)=>{const T=Nt(typeof S=="string"?O:S),L=typeof S=="string"?S:S.id,Y=L&&e.get(L);if(Y){const F=ti(Y,T);return L===T.id?e.set(L,T):(e.delete(L),e.set(T.id,T)),Y.bodies.forEach(R=>t.delete(R.id)),T.bodies.forEach(R=>t.set(R.id,T.id)),F}else console.warn(`Cannot update annotation ${L} - does not exist`)},l=(S,O=X.LOCAL,T=X.LOCAL)=>{const L=Co(O)?T:O,Y=a(S,O);Y&&r(L,{updated:[Y]})},c=(S,O=X.LOCAL)=>{e.get(S.id)?l(S,O):s(S,O)},f=(S,O=X.LOCAL)=>{const T=S.reduce((L,Y)=>{const F=a(Y);return F?[...L,F]:L},[]);T.length>0&&r(O,{updated:T})},u=(S,O=X.LOCAL)=>{const T=S.map(Nt),{toAdd:L,toUpdate:Y}=T.reduce((R,_)=>e.get(_.id)?{...R,toUpdate:[...R.toUpdate,_]}:{...R,toAdd:[...R.toAdd,_]},{toAdd:[],toUpdate:[]}),F=Y.map(R=>a(R,O)).filter(Boolean);L.forEach(R=>{e.set(R.id,R),R.bodies.forEach(_=>t.set(_.id,R.id))}),r(O,{created:L,updated:F})},A=(S,O=X.LOCAL)=>{const T=e.get(S.annotation);if(T){const L={...T,bodies:[...T.bodies,S]};e.set(T.id,L),t.set(S.id,L.id),r(O,{updated:[{oldValue:T,newValue:L,bodiesCreated:[S]}]})}else console.warn(`Attempt to add body to missing annotation: ${S.annotation}`)},m=()=>[...e.values()],g=(S=X.LOCAL)=>{const O=[...e.values()];e.clear(),t.clear(),r(S,{deleted:O})},w=(S,O=!0,T=X.LOCAL)=>{const L=S.map(Nt);if(O){const Y=[...e.values()];e.clear(),t.clear(),L.forEach(F=>{e.set(F.id,F),F.bodies.forEach(R=>t.set(R.id,F.id))}),r(T,{created:L,deleted:Y})}else{const Y=S.reduce((F,R)=>{const _=R.id&&e.get(R.id);return _?[...F,_]:F},[]);if(Y.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${Y.map(F=>F.id).join(", ")}`);L.forEach(F=>{e.set(F.id,F),F.bodies.forEach(R=>t.set(R.id,F.id))}),r(T,{created:L})}},x=S=>{const O=typeof S=="string"?S:S.id,T=e.get(O);if(T)return e.delete(O),T.bodies.forEach(L=>t.delete(L.id)),T;console.warn(`Attempt to delete missing annotation: ${O}`)},h=(S,O=X.LOCAL)=>{const T=x(S);T&&r(O,{deleted:[T]})},d=(S,O=X.LOCAL)=>{const T=S.reduce((L,Y)=>{const F=x(Y);return F?[...L,F]:L},[]);T.length>0&&r(O,{deleted:T})},N=S=>{const O=e.get(S.annotation);if(O){const T=O.bodies.find(L=>L.id===S.id);if(T){t.delete(T.id);const L={...O,bodies:O.bodies.filter(Y=>Y.id!==S.id)};return e.set(O.id,L),{oldValue:O,newValue:L,bodiesDeleted:[T]}}else console.warn(`Attempt to delete missing body ${S.id} from annotation ${S.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${S.annotation}`)},M=(S,O=X.LOCAL)=>{const T=N(S);T&&r(O,{updated:[T]})},k=(S,O=X.LOCAL)=>{const T=S.map(L=>N(L)).filter(Boolean);T.length>0&&r(O,{updated:T})},C=S=>{const O=e.get(S);return O?{...O}:void 0},U=S=>{const O=t.get(S);if(O){const T=C(O).bodies.find(L=>L.id===S);if(T)return T;console.error(`Store integrity error: body ${S} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${S}`)},P=(S,O)=>{if(S.annotation!==O.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const T=e.get(S.annotation);if(T){const L=T.bodies.find(F=>F.id===S.id),Y={...T,bodies:T.bodies.map(F=>F.id===L.id?O:F)};return e.set(T.id,Y),L.id!==O.id&&(t.delete(L.id),t.set(O.id,Y.id)),{oldValue:T,newValue:Y,bodiesUpdated:[{oldBody:L,newBody:O}]}}else console.warn(`Attempt to add body to missing annotation ${S.annotation}`)},D=(S,O,T=X.LOCAL)=>{const L=P(S,O);L&&r(T,{updated:[L]})},H=(S,O=X.LOCAL)=>{const T=S.map(L=>P({id:L.id,annotation:L.annotation},L)).filter(Boolean);r(O,{updated:T})},V=S=>{const O=e.get(S.annotation);if(O){const T={...O,target:{...O.target,...S}};return e.set(O.id,T),{oldValue:O,newValue:T,targetUpdated:{oldTarget:O.target,newTarget:S}}}else console.warn(`Attempt to update target on missing annotation: ${S.annotation}`)};return{addAnnotation:s,addBody:A,all:m,bulkAddAnnotations:w,bulkDeleteAnnotations:d,bulkDeleteBodies:k,bulkUpdateAnnotations:f,bulkUpdateBodies:H,bulkUpdateTargets:(S,O=X.LOCAL)=>{const T=S.map(L=>V(L)).filter(Boolean);T.length>0&&r(O,{updated:T})},bulkUpsertAnnotations:u,clear:g,deleteAnnotation:h,deleteBody:M,getAnnotation:C,getBody:U,observe:i,unobserve:o,updateAnnotation:l,updateBody:D,updateTarget:(S,O=X.LOCAL)=>{const T=V(S);T&&r(O,{updated:[T]})},upsertAnnotation:c}};let xo=()=>({emit(e,...t){for(let n=this.events[e]||[],i=0,o=n.length;i<o;i++)n[i](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var i;this.events[e]=(i=this.events[e])==null?void 0:i.filter(o=>t!==o)}}});const To=250,Ro=(e,t)=>{const n=xo(),i=[];let o=-1,r=!1,s=0;const a=g=>{if(!r){const{changes:w}=g,x=performance.now();if(x-s>To)i.splice(o+1),i.push(w),o=i.length-1;else{const h=i.length-1;i[h]=So(i[h],w)}s=x}r=!1};e.observe(a,{origin:X.LOCAL});const l=g=>g&&g.length>0&&e.bulkDeleteAnnotations(g),c=g=>g&&g.length>0&&e.bulkAddAnnotations(g,!1),f=g=>g&&g.length>0&&e.bulkUpdateAnnotations(g.map(({oldValue:w})=>w)),u=g=>g&&g.length>0&&e.bulkUpdateAnnotations(g.map(({newValue:w})=>w)),A=g=>g&&g.length>0&&e.bulkAddAnnotations(g,!1),m=g=>g&&g.length>0&&e.bulkDeleteAnnotations(g);return{canRedo:()=>i.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(a),getHistory:()=>({changes:[...i],pointer:o}),on:(g,w)=>n.on(g,w),redo:()=>{if(i.length-1>o){r=!0;const{created:g,updated:w,deleted:x}=i[o+1];c(g),u(w),m(x),n.emit("redo",i[o+1]),o+=1}},undo:()=>{if(o>-1){r=!0;const{created:g,updated:w,deleted:x}=i[o];l(g),f(w),A(x),n.emit("undo",i[o]),o-=1}}}},ko=()=>{const e=nn([]);return{subscribe:e.subscribe.bind(e),set:e.set.bind(e)}},No=(e,t,n,i)=>{const{hover:o,selection:r,store:s,viewport:a}=e,l=new Map;let c=[],f;const u=(w,x)=>{l.has(w)?l.get(w).push(x):l.set(w,[x])},A=(w,x)=>{const h=l.get(w);if(h){const d=h.indexOf(x);d!==-1&&h.splice(d,1)}},m=(w,x,h)=>{l.has(w)&&setTimeout(()=>{l.get(w).forEach(d=>{if(n){const N=Array.isArray(x)?x.map(k=>n.serialize(k)):n.serialize(x),M=h?h instanceof PointerEvent?h:n.serialize(h):void 0;d(N,M)}else d(x,h)})},1)};r.subscribe(({selected:w})=>{if(!(c.length===0&&w.length===0)){if(c.length===0&&w.length>0)c=w.map(({id:x})=>s.getAnnotation(x));else if(c.length>0&&w.length===0)c.forEach(x=>{const h=s.getAnnotation(x.id);h&&!Me(h,x)&&m("updateAnnotation",h,x)}),c=[];else{const x=new Set(c.map(d=>d.id)),h=new Set(w.map(({id:d})=>d));c.filter(d=>!h.has(d.id)).forEach(d=>{const N=s.getAnnotation(d.id);N&&!Me(N,d)&&m("updateAnnotation",N,d)}),c=[...c.filter(d=>h.has(d.id)),...w.filter(({id:d})=>!x.has(d)).map(({id:d})=>s.getAnnotation(d))]}m("selectionChanged",c)}}),o.subscribe(w=>{!f&&w?m("mouseEnterAnnotation",s.getAnnotation(w)):f&&!w?m("mouseLeaveAnnotation",s.getAnnotation(f)):f&&w&&(m("mouseLeaveAnnotation",s.getAnnotation(f)),m("mouseEnterAnnotation",s.getAnnotation(w))),f=w}),a?.subscribe(w=>m("viewportIntersect",w.map(x=>s.getAnnotation(x)))),s.observe(w=>{const{created:x,deleted:h}=w.changes;(x||[]).forEach(d=>m("createAnnotation",d)),(h||[]).forEach(d=>m("deleteAnnotation",d)),(w.changes.updated||[]).filter(d=>[...d.bodiesCreated||[],...d.bodiesDeleted||[],...d.bodiesUpdated||[]].length>0).forEach(({oldValue:d,newValue:N})=>{const M=c.find(k=>k.id===d.id)||d;c=c.map(k=>k.id===d.id?N:k),m("updateAnnotation",N,M)})},{origin:X.LOCAL}),s.observe(w=>{if(c){const x=new Set(c.map(d=>d.id)),h=(w.changes.updated||[]).filter(({newValue:d})=>x.has(d.id)).map(({newValue:d})=>d);h.length>0&&(c=c.map(d=>h.find(M=>M.id===d.id)||d))}},{origin:X.REMOTE});const g=w=>x=>{const{updated:h}=x;w?(h||[]).forEach(d=>m("updateAnnotation",d.oldValue,d.newValue)):(h||[]).forEach(d=>m("updateAnnotation",d.newValue,d.oldValue))};return t.on("undo",g(!0)),t.on("redo",g(!1)),{on:u,off:A,emit:m}},Lo=e=>t=>t.reduce((n,i)=>{const{parsed:o,error:r}=e.parse(i);return r?{parsed:n.parsed,failed:[...n.failed,i]}:o?{parsed:[...n.parsed,o],failed:n.failed}:{...n}},{parsed:[],failed:[]}),Io=(e,t,n)=>{const{store:i,selection:o}=e,r=h=>{if(n){const{parsed:d,error:N}=n.parse(h);d?i.addAnnotation(d,X.REMOTE):console.error(N)}else i.addAnnotation(an(h),X.REMOTE)},s=()=>o.clear(),a=()=>i.clear(),l=h=>{const d=i.getAnnotation(h);return n&&d?n.serialize(d):d},c=()=>n?i.all().map(n.serialize):i.all(),f=()=>{var h;const d=(((h=o.selected)==null?void 0:h.map(N=>N.id))||[]).map(N=>i.getAnnotation(N)).filter(Boolean);return n?d.map(n.serialize):d},u=(h,d=!0)=>fetch(h).then(N=>N.json()).then(N=>(m(N,d),N)),A=h=>{if(typeof h=="string"){const d=i.getAnnotation(h);if(i.deleteAnnotation(h),d)return n?n.serialize(d):d}else{const d=n?n.parse(h).parsed:h;if(d)return i.deleteAnnotation(d),h}},m=(h,d=!0)=>{if(n){const N=n.parseAll||Lo(n),{parsed:M,failed:k}=N(h);k.length>0&&console.warn(`Discarded ${k.length} invalid annotations`,k),i.bulkAddAnnotations(M,d,X.REMOTE)}else i.bulkAddAnnotations(h.map(an),d,X.REMOTE)},g=(h,d)=>{h?o.setSelected(h,d):o.clear()},w=h=>{o.setUserSelectAction(h)},x=h=>{if(n){const d=n.parse(h).parsed,N=n.serialize(i.getAnnotation(d.id));return i.updateAnnotation(d),N}else{const d=i.getAnnotation(h.id);return i.updateAnnotation(an(h)),d}};return{addAnnotation:r,cancelSelected:s,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:c,getHistory:t.getHistory,getSelected:f,loadAnnotations:u,redo:t.redo,removeAnnotation:A,setAnnotations:m,setSelected:g,setUserSelectAction:w,undo:t.undo,updateAnnotation:x}},Mo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Bo=e=>crypto.getRandomValues(new Uint8Array(e)),_o=(e,t,n)=>{let i=(2<<Math.log2(e.length-1))-1,o=-~(1.6*i*t/e.length);return(r=t)=>{let s="";for(;;){let a=n(o),l=o|0;for(;l--;)if(s+=e[a[l]&i]||"",s.length>=r)return s}}},Uo=(e,t=21)=>_o(e,t|0,Bo),Do=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Mo[n[e]&63];return t};const Po=()=>({isGuest:!0,id:Uo("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Ho=e=>{const t=JSON.stringify(e);let n=0;for(let i=0,o=t.length;i<o;i++){let r=t.charCodeAt(i);n=(n<<5)-n+r,n|=0}return`${n}`},ni=e=>e?typeof e=="object"?{...e}:e:void 0,Vo=(e,t)=>(Array.isArray(e)?e:[e]).map(n=>{const{id:i,type:o,purpose:r,value:s,created:a,modified:l,creator:c,...f}=n;return{id:i||`temp-${Ho(n)}`,annotation:t,type:o,purpose:r,value:s,creator:ni(c),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...f}}),Xo=e=>e.map(t=>{var n;const{annotation:i,created:o,updated:r,...s}=t,a={...s,created:o?.toISOString(),modified:r?.toISOString()};return(n=a.id)!=null&&n.startsWith("temp-")&&delete a.id,a});Do();const Fo=e=>{const{top:t,left:n}=e.getBoundingClientRect(),{innerWidth:i,innerHeight:o}=window,r=-n,s=-t,a=i-n,l=o-t;return{top:t,left:n,minX:r,minY:s,maxX:a,maxY:l}},Yo=e=>{let t=new Set;return i=>{const o=i.map(r=>r.id);(t.size!==o.length||o.some(r=>!t.has(r)))&&e.set(o),t=new Set(o)}},Lt=(e,t,n,i)=>{const{store:o,selection:r,hover:s}=t;let a,l,c;const f=Yo(n),u=D=>{const{x:H,y:V}=e.getBoundingClientRect(),S=o.getAt(D.clientX-H,D.clientY-V,!1,l);S&&t.selection.evalSelectAction(S)!==on.NONE?s.current!==S.id&&(e.classList.add("hovered"),s.set(S.id)):s.current&&(e.classList.remove("hovered"),s.set(null))};e.addEventListener("pointermove",u);const A=ot((D=!1)=>requestAnimationFrame(()=>{c&&c.clear();const H=Fo(e),{minX:V,minY:S,maxX:O,maxY:T}=H,L=l?o.getIntersecting(V,S,O,T).filter(({annotation:R})=>l(R)):o.getIntersecting(V,S,O,T),Y=r.selected.map(({id:R})=>R),F=L.map(({annotation:R,rects:_})=>{const ee=Y.includes(R.id),Be=R.id===s.current;return{annotation:R,rects:_,state:{selected:ee,hovered:Be}}});i.redraw(F,H,a,c,D),setTimeout(()=>f(L.map(({annotation:R})=>R)),1)}),10),m=D=>{c=D,A()},g=D=>{a=D,A()},w=D=>{l=D,A(!1)},x=()=>A();o.observe(x);const h=r.subscribe(()=>A()),d=s.subscribe(()=>A()),N=()=>A(!0);document.addEventListener("scroll",N,{capture:!0,passive:!0});const M=ot(()=>{o.recalculatePositions(),c?.reset(),A()},10);window.addEventListener("resize",M);const k=new ResizeObserver(M);k.observe(e);const C={attributes:!0,childList:!0,subtree:!0},U=new MutationObserver(ot(D=>{D.every(V=>V.target===e||e.contains(V.target))||A(!0)},150));return U.observe(document.body,C),{destroy:()=>{e.removeEventListener("pointermove",u),i.destroy(),o.unobserve(x),h(),d(),document.removeEventListener("scroll",N),M.clear(),window.removeEventListener("resize",M),k.disconnect(),U.disconnect()},redraw:A,setStyle:g,setFilter:w,setPainter:m,setVisible:i.setVisible}},Ko=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},Wo=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},jo=e=>{console.warn('WARNING! Canvas renderer is deprecated and will be removed in the next major release. Please use the default "SPANS" renderer instead.'),e.classList.add("r6o-annotatable");const t=Ko(),n=t.getContext("2d");document.body.appendChild(t);const i=(a,l,c,f)=>requestAnimationFrame(()=>{const{width:u,height:A}=t;n.clearRect(-.5,-.5,u+1,A+1),f&&f.clear();const{top:m,left:g}=l;[...a].sort((x,h)=>{const{annotation:{target:{created:d}}}=x,{annotation:{target:{created:N}}}=h;return d.getTime()-N.getTime()}).forEach(x=>{const h=c?typeof c=="function"?c(x.annotation,x.state):c:x.state?.selected?rt:pe,d=f&&f.paint(x,l)||h,N=x.rects.map(({x:M,y:k,width:C,height:U})=>({x:M+g,y:k+m,width:C,height:U}));if(n.fillStyle=d.fill,n.globalAlpha=d.fillOpacity||1,N.forEach(({x:M,y:k,width:C,height:U})=>n.fillRect(M,k,C,U)),d.underlineColor){n.globalAlpha=1,n.strokeStyle=d.underlineColor,n.lineWidth=d.underlineThickness??1;const M=d.underlineOffset??0;N.forEach(({x:k,y:C,width:U,height:P})=>{n.beginPath(),n.moveTo(k,C+P+M),n.lineTo(k+U,C+P+M),n.stroke()})}})}),o=ot(()=>Wo(t),10);return window.addEventListener("resize",o),{destroy:()=>{t.remove(),o.clear(),window.removeEventListener("resize",o)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:i}},ii=(e,t,n)=>Lt(e,t,n,jo(e));var $o={grad:.9,turn:360,rad:360/(2*Math.PI)},ve=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},q=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},re=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},oi=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},ri=function(e){return{r:re(e.r,0,255),g:re(e.g,0,255),b:re(e.b,0,255),a:re(e.a)}},ln=function(e){return{r:q(e.r),g:q(e.g),b:q(e.b),a:q(e.a,3)}},zo=/^#([0-9a-f]{3,8})$/i,It=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},si=function(e){var t=e.r,n=e.g,i=e.b,o=e.a,r=Math.max(t,n,i),s=r-Math.min(t,n,i),a=s?r===t?(n-i)/s:r===n?2+(i-t)/s:4+(t-n)/s:0;return{h:60*(a<0?a+6:a),s:r?s/r*100:0,v:r/255*100,a:o}},ai=function(e){var t=e.h,n=e.s,i=e.v,o=e.a;t=t/360*6,n/=100,i/=100;var r=Math.floor(t),s=i*(1-n),a=i*(1-(t-r)*n),l=i*(1-(1-t+r)*n),c=r%6;return{r:255*[i,a,s,s,l,i][c],g:255*[l,i,i,a,s,s][c],b:255*[s,s,l,i,i,a][c],a:o}},li=function(e){return{h:oi(e.h),s:re(e.s,0,100),l:re(e.l,0,100),a:re(e.a)}},ci=function(e){return{h:q(e.h),s:q(e.s),l:q(e.l),a:q(e.a,3)}},di=function(e){return ai((n=(t=e).s,{h:t.h,s:(n*=((i=t.l)<50?i:100-i)/100)>0?2*n/(i+n)*100:0,v:i+n,a:t.a}));var t,n,i},st=function(e){return{h:(t=si(e)).h,s:(o=(200-(n=t.s))*(i=t.v)/100)>0&&o<200?n*i/100/(o<=100?o:200-o)*100:0,l:o/2,a:t.a};var t,n,i,o},qo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Go=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ui={string:[[function(e){var t=zo.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?q(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?q(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=Jo.exec(e)||Qo.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:ri({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=qo.exec(e)||Go.exec(e);if(!t)return null;var n,i,o=li({h:(n=t[1],i=t[2],i===void 0&&(i="deg"),Number(n)*($o[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return di(o)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,i=e.b,o=e.a,r=o===void 0?1:o;return ve(t)&&ve(n)&&ve(i)?ri({r:Number(t),g:Number(n),b:Number(i),a:Number(r)}):null},"rgb"],[function(e){var t=e.h,n=e.s,i=e.l,o=e.a,r=o===void 0?1:o;if(!ve(t)||!ve(n)||!ve(i))return null;var s=li({h:Number(t),s:Number(n),l:Number(i),a:Number(r)});return di(s)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,o=e.a,r=o===void 0?1:o;if(!ve(t)||!ve(n)||!ve(i))return null;var s=(function(a){return{h:oi(a.h),s:re(a.s,0,100),v:re(a.v,0,100),a:re(a.a)}})({h:Number(t),s:Number(n),v:Number(i),a:Number(r)});return ai(s)},"hsv"]]},fi=function(e,t){for(var n=0;n<t.length;n++){var i=t[n][0](e);if(i)return[i,t[n][1]]}return[null,void 0]},Zo=function(e){return typeof e=="string"?fi(e.trim(),ui.string):typeof e=="object"&&e!==null?fi(e,ui.object):[null,void 0]},cn=function(e,t){var n=st(e);return{h:n.h,s:re(n.s+100*t,0,100),l:n.l,a:n.a}},dn=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},hi=function(e,t){var n=st(e);return{h:n.h,s:n.s,l:re(n.l+100*t,0,100),a:n.a}},gi=(function(){function e(t){this.parsed=Zo(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return q(dn(this.rgba),2)},e.prototype.isDark=function(){return dn(this.rgba)<.5},e.prototype.isLight=function(){return dn(this.rgba)>=.5},e.prototype.toHex=function(){return t=ln(this.rgba),n=t.r,i=t.g,o=t.b,s=(r=t.a)<1?It(q(255*r)):"","#"+It(n)+It(i)+It(o)+s;var t,n,i,o,r,s},e.prototype.toRgb=function(){return ln(this.rgba)},e.prototype.toRgbString=function(){return t=ln(this.rgba),n=t.r,i=t.g,o=t.b,(r=t.a)<1?"rgba("+n+", "+i+", "+o+", "+r+")":"rgb("+n+", "+i+", "+o+")";var t,n,i,o,r},e.prototype.toHsl=function(){return ci(st(this.rgba))},e.prototype.toHslString=function(){return t=ci(st(this.rgba)),n=t.h,i=t.s,o=t.l,(r=t.a)<1?"hsla("+n+", "+i+"%, "+o+"%, "+r+")":"hsl("+n+", "+i+"%, "+o+"%)";var t,n,i,o,r},e.prototype.toHsv=function(){return t=si(this.rgba),{h:q(t.h),s:q(t.s),v:q(t.v),a:q(t.a,3)};var t},e.prototype.invert=function(){return se({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),se(cn(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),se(cn(this.rgba,-t))},e.prototype.grayscale=function(){return se(cn(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),se(hi(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),se(hi(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?se({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):q(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=st(this.rgba);return typeof t=="number"?se({h:t,s:n.s,l:n.l,a:n.a}):q(n.h)},e.prototype.isEqual=function(t){return this.toHex()===se(t).toHex()},e})(),se=function(e){return e instanceof gi?e:new gi(e)};const er=e=>[`background-color:${se(e?.fill||pe.fill).alpha(e?.fillOpacity===void 0?pe.fillOpacity:e.fillOpacity).toHex()}`,e?.underlineThickness?"text-decoration:underline":void 0,e?.underlineColor?`text-decoration-color:${e.underlineColor}`:void 0,e?.underlineOffset?`text-underline-offset:${e.underlineOffset}px`:void 0,e?.underlineThickness?`text-decoration-thickness:${e.underlineThickness}px`:void 0].filter(Boolean).join(";"),pi=()=>{const e=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(e);let t=new Set;return{destroy:()=>{CSS.highlights.clear(),e.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,s,a,l)=>{l&&l.clear();const c=new Set(r.map(u=>u.annotation.id));Array.from(t).filter(u=>!c.has(u));const f=r.map(u=>{const A=a?typeof a=="function"?a(u.annotation,u.state):a:u.state?.selected?rt:pe,m=l&&l.paint(u,s)||A;return`::highlight(_${u.annotation.id}) { ${er(m)} }`});e.innerHTML=f.join(`
2
+ `),CSS.highlights.clear(),r.forEach(({annotation:u})=>{const A=u.target.selector.map(g=>g.range),m=new Highlight(...A);CSS.highlights.set(`_${u.id}`,m)}),t=c}}},mi=(e,t,n)=>Lt(e,t,n,pi());var bi=Object.prototype.hasOwnProperty;function un(e,t){var n,i;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((i=e.length)===t.length)for(;i--&&un(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(bi.call(e,n)&&++i&&!bi.call(t,n)||!(n in t)||!un(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}const wi=(e,t,n,i,o)=>{const r=n?typeof n=="function"?n(e.annotation,e.state,o)||(e.state?.selected?rt:pe):n:e.state?.selected?rt:pe;return i&&i.paint(e,t)||r},tr=e=>e?.fillOpacity!==void 0?se(e?.fill||pe.fill).alpha(e.fillOpacity).toHex():e?.fill?e.fill:se(pe.fill).alpha(pe.fillOpacity).toHex(),nr=(e,t)=>{const n=(r,s)=>r.x<=s.x+s.width&&r.x+r.width>=s.x&&r.y<=s.y+s.height&&r.y+r.height>=s.y,i=r=>r.rects.reduce((s,a)=>s+a.width,0),o=t.filter(({rects:r})=>r.some(s=>n(e,s)));return o.sort((r,s)=>i(s)-i(r)),o.findIndex(r=>r.rects.includes(e))},ir=e=>{e.classList.add("r6o-annotatable");const t=document.createElement("div");t.className="r6o-span-highlight-layer",e.insertBefore(t,e.firstChild);let n=[];return{destroy:()=>{t.remove()},redraw:(s,a,l,c,f)=>{const A=!(un(n,s)&&f);if(!c&&!A)return;A&&(t.innerHTML=""),[...s].sort((g,w)=>{const{annotation:{target:{created:x}}}=g,{annotation:{target:{created:h}}}=w;return x&&h?x.getTime()-h.getTime():0}).forEach(g=>{g.rects.map(w=>{const x=nr(w,s),h=wi(g,a,l,c,x);if(A){const d=document.createElement("span");d.className="r6o-annotation",d.dataset.annotation=g.annotation.id,d.style.left=`${w.x}px`,d.style.top=`${w.y}px`,d.style.width=`${w.width}px`,d.style.height=`${w.height}px`,d.style.backgroundColor=tr(h),h.underlineStyle&&(d.style.borderStyle=h.underlineStyle),h.underlineColor&&(d.style.borderColor=h.underlineColor),h.underlineThickness&&(d.style.borderBottomWidth=`${h.underlineThickness}px`),h.underlineOffset&&(d.style.paddingBottom=`${h.underlineOffset}px`),t.appendChild(d)}})}),n=s},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},yi=(e,t,n)=>Lt(e,t,n,ir(e)),Q=[];for(let e=0;e<256;++e)Q.push((e+256).toString(16).slice(1));function or(e,t=0){return(Q[e[t+0]]+Q[e[t+1]]+Q[e[t+2]]+Q[e[t+3]]+"-"+Q[e[t+4]]+Q[e[t+5]]+"-"+Q[e[t+6]]+Q[e[t+7]]+"-"+Q[e[t+8]]+Q[e[t+9]]+"-"+Q[e[t+10]]+Q[e[t+11]]+Q[e[t+12]]+Q[e[t+13]]+Q[e[t+14]]+Q[e[t+15]]).toLowerCase()}let fn;const rr=new Uint8Array(16);function sr(){if(!fn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fn=crypto.getRandomValues.bind(crypto)}return fn(rr)}const vi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ar(e,t,n){e=e||{};const i=e.random??e.rng?.()??sr();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,or(i)}function Ei(e,t,n){return vi.randomUUID&&!e?vi.randomUUID():ar(e)}const lr=(e,t)=>({parse:n=>Ai(n),serialize:n=>Si(n,e,t)}),cr=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,dr=e=>{const{id:t,creator:n,created:i,modified:o,target:r}=e,s=Array.isArray(r)?r:[r];if(s.length===0)return{error:Error(`No targets found for annotation: ${e.id}`)};const a={creator:ni(n),created:i?new Date(i):void 0,updated:o?new Date(o):void 0,annotation:t,selector:[],styleClass:"styleClass"in s[0]?s[0].styleClass:void 0};for(const l of s){const f=(Array.isArray(l.selector)?l.selector:[l.selector]).reduce((u,A)=>{switch(A.type){case"TextQuoteSelector":u.quote=A.exact;break;case"TextPositionSelector":u.start=A.start,u.end=A.end;break}return u},{});if(cr(f))a.selector.push({...f,id:l.id,scope:l.scope});else{const u=[f.start?void 0:"TextPositionSelector",f.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${u.join(" and ")} for annotation: ${e.id}`)}}}return{parsed:a}},Ai=e=>{const t=e.id||Ei(),{creator:n,created:i,modified:o,body:r,...s}=e,a=Vo(r,t),l=dr(e);return"error"in l?{error:l.error}:{parsed:{...s,id:t,bodies:a,target:l.parsed}}},Si=(e,t,n)=>{const{bodies:i,target:o,...r}=e,{selector:s,creator:a,created:l,updated:c,...f}=o,u=s.map(A=>{const{id:m,quote:g,start:w,end:x,range:h}=A,d={type:"TextQuoteSelector",exact:g};if(n){const{prefix:M,suffix:k}=Fn(h,n);d.prefix=M,d.suffix=k}const N={type:"TextPositionSelector",start:w,end:x};return{...f,id:m,scope:"scope"in A?A.scope:void 0,source:t,selector:[d,N]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:Xo(e.bodies),creator:a,created:l?.toISOString(),modified:c?.toISOString(),target:u}},ur=()=>{const e=document.createElement("canvas");e.width=2*window.innerWidth,e.height=2*window.innerHeight,e.className="r6o-presence-layer";const t=e.getContext("2d");return t.scale(2,2),t.translate(.5,.5),e},Ci=(e,t={})=>{const n=ur(),i=n.getContext("2d");document.body.appendChild(n);const o=new Map,r=f=>Array.from(o.entries()).filter(([u,A])=>A.presenceKey===f.presenceKey).map(([u,A])=>u);return e.on("selectionChange",(f,u)=>{r(f).forEach(m=>o.delete(m)),u&&u.forEach(m=>o.set(m,f))}),{clear:()=>{const{width:f,height:u}=n;i.clearRect(-.5,-.5,f+1,u+1)},destroy:()=>{n.remove()},paint:(f,u,A)=>{t.font&&(i.font=t.font);const m=o.get(f.annotation.id);if(m){const{height:g}=f.rects[0],w=f.rects[0].x+u.left,x=f.rects[0].y+u.top;i.fillStyle=m.appearance.color,i.fillRect(w-2,x-2.5,2,g+5);const h=i.measureText(m.appearance.label),d=h.width+6,N=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent+8,M=h.fontBoundingBoxAscent?8:6.5;return i.fillRect(w-2,x-2.5-N,d,N),i.fillStyle="#fff",i.fillText(m.appearance.label,w+1,x-M),{fill:m.appearance.color,fillOpacity:A?.45:.18}}},reset:()=>{n.width=2*window.innerWidth,n.height=2*window.innerHeight;const f=n.getContext("2d");f.scale(2,2),f.translate(.5,.5)}}};function Oi(e,t,n=0,i=e.length-1,o=fr){for(;i>n;){if(i-n>600){const l=i-n+1,c=t-n+1,f=Math.log(l),u=.5*Math.exp(2*f/3),A=.5*Math.sqrt(f*u*(l-u)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(t-c*u/l+A)),g=Math.min(i,Math.floor(t+(l-c)*u/l+A));Oi(e,t,m,g,o)}const r=e[t];let s=n,a=i;for(at(e,n,t),o(e[i],r)>0&&at(e,n,i);s<a;){for(at(e,s,a),s++,a--;o(e[s],r)<0;)s++;for(;o(e[a],r)>0;)a--}o(e[n],r)===0?at(e,n,a):(a++,at(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function at(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function fr(e,t){return e<t?-1:e>t?1:0}class hr{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const i=[];if(!Bt(t,n))return i;const o=this.toBBox,r=[];for(;n;){for(let s=0;s<n.children.length;s++){const a=n.children[s],l=n.leaf?o(a):a;Bt(t,l)&&(n.leaf?i.push(a):gn(t,l)?this._all(a,i):r.push(a))}n=r.pop()}return i}collides(t){let n=this.data;if(!Bt(t,n))return!1;const i=[];for(;n;){for(let o=0;o<n.children.length;o++){const r=n.children[o],s=n.leaf?this.toBBox(r):r;if(Bt(t,s)){if(n.leaf||gn(t,s))return!0;i.push(r)}}n=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Ye([]),this}remove(t,n){if(!t)return this;let i=this.data;const o=this.toBBox(t),r=[],s=[];let a,l,c;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=s.pop(),c=!0),i.leaf){const f=gr(t,i.children,n);if(f!==-1)return i.children.splice(f,1),r.push(i),this._condense(r),this}!c&&!i.leaf&&gn(i,o)?(r.push(i),s.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],c=!1):i=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const i=[];for(;t;)t.leaf?n.push(...t.children):i.push(...t.children),t=i.pop();return n}_build(t,n,i,o){const r=i-n+1;let s=this._maxEntries,a;if(r<=s)return a=Ye(t.slice(n,i+1)),Fe(a,this.toBBox),a;o||(o=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,o-1))),a=Ye([]),a.leaf=!1,a.height=o;const l=Math.ceil(r/s),c=l*Math.ceil(Math.sqrt(s));xi(t,n,i,c,this.compareMinX);for(let f=n;f<=i;f+=c){const u=Math.min(f+c-1,i);xi(t,f,u,l,this.compareMinY);for(let A=f;A<=u;A+=l){const m=Math.min(A+l-1,u);a.children.push(this._build(t,A,m,o-1))}}return Fe(a,this.toBBox),a}_chooseSubtree(t,n,i,o){for(;o.push(n),!(n.leaf||o.length-1===i);){let r=1/0,s=1/0,a;for(let l=0;l<n.children.length;l++){const c=n.children[l],f=hn(c),u=br(t,c)-f;u<s?(s=u,r=f<r?f:r,a=c):u===s&&f<r&&(r=f,a=c)}n=a||n.children[0]}return n}_insert(t,n,i){const o=i?t:this.toBBox(t),r=[],s=this._chooseSubtree(o,this.data,n,r);for(s.children.push(t),ct(s,o);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(o,r,n)}_split(t,n){const i=t[n],o=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,o);const s=this._chooseSplitIndex(i,r,o),a=Ye(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Fe(i,this.toBBox),Fe(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,n){this.data=Ye([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Fe(this.data,this.toBBox)}_chooseSplitIndex(t,n,i){let o,r=1/0,s=1/0;for(let a=n;a<=i-n;a++){const l=lt(t,0,a,this.toBBox),c=lt(t,a,i,this.toBBox),f=wr(l,c),u=hn(l)+hn(c);f<r?(r=f,o=a,s=u<s?u:s):f===r&&u<s&&(s=u,o=a)}return o||i-n}_chooseSplitAxis(t,n,i){const o=t.leaf?this.compareMinX:pr,r=t.leaf?this.compareMinY:mr,s=this._allDistMargin(t,n,i,o),a=this._allDistMargin(t,n,i,r);s<a&&t.children.sort(o)}_allDistMargin(t,n,i,o){t.children.sort(o);const r=this.toBBox,s=lt(t,0,n,r),a=lt(t,i-n,i,r);let l=Mt(s)+Mt(a);for(let c=n;c<i-n;c++){const f=t.children[c];ct(s,t.leaf?r(f):f),l+=Mt(s)}for(let c=i-n-1;c>=n;c--){const f=t.children[c];ct(a,t.leaf?r(f):f),l+=Mt(a)}return l}_adjustParentBBoxes(t,n,i){for(let o=i;o>=0;o--)ct(n[o],t)}_condense(t){for(let n=t.length-1,i;n>=0;n--)t[n].children.length===0?n>0?(i=t[n-1].children,i.splice(i.indexOf(t[n]),1)):this.clear():Fe(t[n],this.toBBox)}}function gr(e,t,n){if(!n)return t.indexOf(e);for(let i=0;i<t.length;i++)if(n(e,t[i]))return i;return-1}function Fe(e,t){lt(e,0,e.children.length,t,e)}function lt(e,t,n,i,o){o||(o=Ye(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let r=t;r<n;r++){const s=e.children[r];ct(o,e.leaf?i(s):s)}return o}function ct(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function pr(e,t){return e.minX-t.minX}function mr(e,t){return e.minY-t.minY}function hn(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Mt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function br(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function wr(e,t){const n=Math.max(e.minX,t.minX),i=Math.max(e.minY,t.minY),o=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,o-n)*Math.max(0,r-i)}function gn(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Bt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Ye(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function xi(e,t,n,i,o){const r=[t,n];for(;r.length;){if(n=r.pop(),t=r.pop(),n-t<=i)continue;const s=t+Math.ceil((n-t)/i/2)*i;Oi(e,s,t,n,o),r.push(t,s,s,n)}}let yr=()=>({emit(e,...t){for(let n=this.events[e]||[],i=0,o=n.length;i<o;i++)n[i](...t)},events:{},on(e,t){return(this.events[e]||=[]).push(t),()=>{this.events[e]=this.events[e]?.filter(n=>t!==n)}}});const vr=(e,t,n,i)=>{const o=new hr,r=new Map,s=yr(),a=(k,C)=>{const U=k.selector.flatMap(D=>{const H=ge([D])?D.range:tn(D,t).range;return Vn(H)}),P=Kn(U,n,i).map(D=>$n(D,C));return P.map(D=>{const{x:H,y:V,width:S,height:O}=D;return{minX:H,minY:V,maxX:H+S,maxY:V+O,annotation:{id:k.annotation,rects:P}}})},l=()=>[...r.values()],c=()=>{o.clear(),r.clear()},f=k=>{const C=a(k,t.getBoundingClientRect());C.length!==0&&(C.forEach(U=>o.insert(U)),r.set(k.annotation,C))},u=k=>{const C=r.get(k.annotation);C&&(C.forEach(U=>o.remove(U)),r.delete(k.annotation))},A=k=>{u(k),f(k)},m=(k,C=!0)=>{C&&c();const U=t.getBoundingClientRect(),P=k.map(H=>({target:H,rects:a(H,U)}));P.forEach(({target:H,rects:V})=>{V.length>0&&r.set(H.annotation,V)});const D=P.flatMap(({rects:H})=>H);o.load(D)},g=(k,C,U=!1)=>{const P=o.search({minX:k,minY:C,maxX:k,maxY:C}),D=H=>H.annotation.rects.reduce((V,S)=>V+S.width*S.height,0);return P.length>0?(P.sort((H,V)=>D(H)-D(V)),U?P.map(H=>H.annotation.id):[P[0].annotation.id]):[]},w=k=>{const C=x(k);if(C.length===0)return;let U=C[0].left,P=C[0].top,D=C[0].right,H=C[0].bottom;for(let V=1;V<C.length;V++){const S=C[V];U=Math.min(U,S.left),P=Math.min(P,S.top),D=Math.max(D,S.right),H=Math.max(H,S.bottom)}return new DOMRect(U,P,D-U,H-P)},x=k=>{const C=r.get(k);return C?C[0].annotation.rects:[]};return{all:l,clear:c,getAt:g,getAnnotationBounds:w,getAnnotationRects:x,getIntersecting:(k,C,U,P)=>{const D=o.search({minX:k,minY:C,maxX:U,maxY:P}),H=new Set(D.map(V=>V.annotation.id));return Array.from(H).map(V=>({annotation:e.getAnnotation(V),rects:x(V)})).filter(V=>!!V.annotation)},insert:f,recalculate:()=>{m(e.all().map(k=>k.target),!0),s.emit("recalculate")},remove:u,set:m,size:()=>o.all().length,update:A,on:(k,C)=>s.on(k,C)}},Ti=(e,t)=>{const n=Oo(),i=vr(n,e,t.mergeHighlights?.horizontalTolerance,t.mergeHighlights?.verticalTolerance),o=co(n,t.userSelectAction,t.adapter),r=lo(n),s=ko(),a=(d,N=X.LOCAL)=>{const M=Rt(d,e),k=ge(M.target.selector);return k&&n.addAnnotation(M,N),k},l=(d,N=!0,M=X.LOCAL)=>{const k=d.map(U=>Rt(U,e)),C=k.filter(U=>!ge(U.target.selector));return n.bulkAddAnnotations(k,N,M),C},c=(d,N=X.LOCAL)=>{const M=d.map(C=>Rt(C,e)),k=M.filter(C=>!ge(C.target.selector));return M.forEach(C=>{n.getAnnotation(C.id)?n.updateAnnotation(C,N):n.addAnnotation(C,N)}),k},f=(d,N=X.LOCAL)=>{const M=it(d,e);n.updateTarget(M,N)},u=(d,N=X.LOCAL)=>{const M=d.map(k=>it(k,e));n.bulkUpdateTargets(M,N)};function A(d,N,M,k){const C=M||!!k,U=i.getAt(d,N,C).map(D=>n.getAnnotation(D)),P=k?U.filter(k):U;if(P.length!==0)return M?P:P[0]}const m=d=>i.getAnnotationRects(d).length>0?i.getAnnotationBounds(d):void 0,g=(d,N,M,k)=>i.getIntersecting(d,N,M,k),w=d=>i.getAnnotationRects(d),x=()=>i.recalculate(),h=d=>i.on("recalculate",d);return n.observe(({changes:d})=>{const N=(d.deleted||[]).filter(C=>ge(C.target.selector)),M=(d.created||[]).filter(C=>ge(C.target.selector)),k=(d.updated||[]).filter(C=>ge(C.newValue.target.selector));N?.length>0&&N.forEach(C=>i.remove(C.target)),M.length>0&&i.set(M.map(C=>C.target),!1),k?.length>0&&k.forEach(({newValue:C})=>i.update(C.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotations:l,bulkUpdateTargets:u,bulkUpsertAnnotations:c,getAnnotationBounds:m,getAnnotationRects:w,getIntersecting:g,getAt:A,recalculatePositions:x,onRecalculatePositions:h,updateTarget:f},selection:o,hover:r,viewport:s}},pn=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function mn(e,t,n,i){e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on".concat(t),n)}function dt(e,t,n,i){e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Ri(e,t){const n=t.slice(0,t.length-1);for(let i=0;i<n.length;i++)n[i]=e[n[i].toLowerCase()];return n}function ki(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function Er(e,t){const n=e.length>=t.length?e:t,i=e.length>=t.length?t:e;let o=!0;for(let r=0;r<n.length;r++)i.indexOf(n[r])===-1&&(o=!1);return o}const ut={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":pn?173:189,"=":pn?61:187,";":pn?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},de={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},ft={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Z={16:!1,18:!1,17:!1,91:!1},j={};for(let e=1;e<20;e++)ut["f".concat(e)]=111+e;let W=[],ht=null,Ni="all";const Ee=new Map,Ke=e=>ut[e.toLowerCase()]||de[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),Ar=e=>Object.keys(ut).find(t=>ut[t]===e),Sr=e=>Object.keys(de).find(t=>de[t]===e);function Li(e){Ni=e||"all"}function gt(){return Ni||"all"}function Cr(){return W.slice(0)}function Or(){return W.map(e=>Ar(e)||Sr(e)||String.fromCharCode(e))}function xr(){const e=[];return Object.keys(j).forEach(t=>{j[t].forEach(n=>{let{key:i,scope:o,mods:r,shortcut:s}=n;e.push({scope:o,shortcut:s,mods:r,keys:i.split("+").map(a=>Ke(a))})})}),e}function Tr(e){const t=e.target||e.srcElement,{tagName:n}=t;let i=!0;const o=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(o||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(i=!1),i}function Rr(e){return typeof e=="string"&&(e=Ke(e)),W.indexOf(e)!==-1}function kr(e,t){let n,i;e||(e=gt());for(const o in j)if(Object.prototype.hasOwnProperty.call(j,o))for(n=j[o],i=0;i<n.length;)n[i].scope===e?n.splice(i,1).forEach(s=>{let{element:a}=s;return bn(a)}):i++;gt()===e&&Li(t||"all")}function Nr(e){let t=e.keyCode||e.which||e.charCode;e.key&&e.key.toLowerCase()==="capslock"&&(t=Ke(e.key));const n=W.indexOf(t);if(n>=0&&W.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&W.splice(0,W.length),(t===93||t===224)&&(t=91),t in Z){Z[t]=!1;for(const i in de)de[i]===t&&(ae[i]=!1)}}function Ii(e){if(typeof e>"u")Object.keys(j).forEach(o=>{Array.isArray(j[o])&&j[o].forEach(r=>_t(r)),delete j[o]}),bn(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&_t(o)});else if(typeof e=="object")e.key&&_t(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];let[o,r]=n;typeof o=="function"&&(r=o,o=""),_t({key:e,scope:o,method:r,splitKey:"+"})}}const _t=e=>{let{key:t,scope:n,method:i,splitKey:o="+"}=e;ki(t).forEach(s=>{const a=s.split(o),l=a.length,c=a[l-1],f=c==="*"?"*":Ke(c);if(!j[f])return;n||(n=gt());const u=l>1?Ri(de,a):[],A=[];j[f]=j[f].filter(m=>{const w=(i?m.method===i:!0)&&m.scope===n&&Er(m.mods,u);return w&&A.push(m.element),!w}),A.forEach(m=>bn(m))})};function Mi(e,t,n,i){if(t.element!==i)return;let o;if(t.scope===n||t.scope==="all"){o=t.mods.length>0;for(const r in Z)Object.prototype.hasOwnProperty.call(Z,r)&&(!Z[r]&&t.mods.indexOf(+r)>-1||Z[r]&&t.mods.indexOf(+r)===-1)&&(o=!1);(t.mods.length===0&&!Z[16]&&!Z[18]&&!Z[17]&&!Z[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(W),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function Bi(e,t){const n=j["*"];let i=e.keyCode||e.which||e.charCode;if(e.key&&e.key.toLowerCase()==="capslock"||!ae.filter.call(this,e))return;if((i===93||i===224)&&(i=91),W.indexOf(i)===-1&&i!==229&&W.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=ft[a];e[a]&&W.indexOf(l)===-1?W.push(l):!e[a]&&W.indexOf(l)>-1?W.splice(W.indexOf(l),1):a==="metaKey"&&e[a]&&(W=W.filter(c=>c in ft||c===i))}),i in Z){Z[i]=!0;for(const a in de)if(Object.prototype.hasOwnProperty.call(de,a)){const l=ft[de[a]];ae[a]=e[l]}if(!n)return}for(const a in Z)Object.prototype.hasOwnProperty.call(Z,a)&&(Z[a]=e[ft[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(W.indexOf(17)===-1&&W.push(17),W.indexOf(18)===-1&&W.push(18),Z[17]=!0,Z[18]=!0);const o=gt();if(n)for(let a=0;a<n.length;a++)n[a].scope===o&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&Mi(e,n[a],o,t);if(!(i in j))return;const r=j[i],s=r.length;for(let a=0;a<s;a++)if((e.type==="keydown"&&r[a].keydown||e.type==="keyup"&&r[a].keyup)&&r[a].key){const l=r[a],{splitKey:c}=l,f=l.key.split(c),u=[];for(let A=0;A<f.length;A++)u.push(Ke(f[A]));u.sort().join("")===W.sort().join("")&&Mi(e,l,o,t)}}function ae(e,t,n){W=[];const i=ki(e);let o=[],r="all",s=document,a=0,l=!1,c=!0,f="+",u=!1,A=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(r=t.scope),t.element&&(s=t.element),t.keyup&&(l=t.keyup),t.keydown!==void 0&&(c=t.keydown),t.capture!==void 0&&(u=t.capture),typeof t.splitKey=="string"&&(f=t.splitKey),t.single===!0&&(A=!0)),typeof t=="string"&&(r=t),A&&Ii(e,r);a<i.length;a++)e=i[a].split(f),o=[],e.length>1&&(o=Ri(de,e)),e=e[e.length-1],e=e==="*"?"*":Ke(e),e in j||(j[e]=[]),j[e].push({keyup:l,keydown:c,scope:r,mods:o,shortcut:i[a],method:n,key:i[a],splitKey:f,element:s});if(typeof s<"u"&&window){if(!Ee.has(s)){const m=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return Bi(w,s)},g=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;Bi(w,s),Nr(w)};Ee.set(s,{keydownListener:m,keyupListenr:g,capture:u}),mn(s,"keydown",m,u),mn(s,"keyup",g,u)}if(!ht){const m=()=>{W=[]};ht={listener:m,capture:u},mn(window,"focus",m,u)}}}function Lr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(j).forEach(n=>{j[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function bn(e){const t=Object.values(j).flat();if(t.findIndex(i=>{let{element:o}=i;return o===e})<0){const{keydownListener:i,keyupListenr:o,capture:r}=Ee.get(e)||{};i&&o&&(dt(e,"keyup",o,r),dt(e,"keydown",i,r),Ee.delete(e))}if((t.length<=0||Ee.size<=0)&&(Object.keys(Ee).forEach(o=>{const{keydownListener:r,keyupListenr:s,capture:a}=Ee.get(o)||{};r&&s&&(dt(o,"keyup",s,a),dt(o,"keydown",r,a),Ee.delete(o))}),Ee.clear(),Object.keys(j).forEach(o=>delete j[o]),ht)){const{listener:o,capture:r}=ht;dt(window,"focus",o,r),ht=null}}const wn={getPressedKeyString:Or,setScope:Li,getScope:gt,deleteScope:kr,getPressedKeyCodes:Cr,getAllKeyCodes:xr,isPressed:Rr,filter:Tr,trigger:Lr,unbind:Ii,keyMap:ut,modifier:de,modifierMap:ft};for(const e in wn)Object.prototype.hasOwnProperty.call(wn,e)&&(ae[e]=wn[e]);if(typeof window<"u"){const e=window.hotkeys;ae.noConflict=t=>(t&&window.hotkeys===ae&&(window.hotkeys=e),ae),window.hotkeys=ae}async function Ir(e,t,n=(()=>!1)){do{if(await e(),await n())break;const i=t;await new Promise((o=>setTimeout(o,Math.max(0,i))))}while(!await n())}const _i=300,Ui=["up","down","left","right"],Di=Zt?"⌘+a":"ctrl+a",Mr=[...Ui.map(e=>`shift+${e}`),Di],Pi=(e,t,n,i)=>{const{store:o,selection:r}=t;let s;const{annotatingEnabled:a,offsetReferenceSelector:l,selectionMode:c,dismissOnNotAnnotatable:f="NEVER"}=i;let u,A=a,m="CREATE_NEW",g,w,x,h;const d=R=>{A=R,P.clear(),R||(w=void 0,g=void 0,x=void 0,h=void 0)},N=R=>m=R||"CREATE_NEW",M=R=>u=R,k=R=>s=R,C=R=>{if(m==="ADD_TO_CURRENT")return!0;if(i.allowModifierSelect){const _=R;return Zt?_.metaKey:_.ctrlKey}else return!1},U=()=>{if(!A||x===!1)return;const{selected:R}=r;if((C(h)||m==="REPLACE_CURRENT")&&R.length===1&&R[0].editable){const ee=o.getAnnotation(R[0].id);if(ee?.target){w=ee.target,g={annotation:ee.id,selector:[],created:w.created,creator:w.creator,updated:new Date,updatedBy:s};return}}w=void 0,g={annotation:Ei(),selector:[],created:new Date,creator:s}},P=ot(R=>{if(!A)return;const _=document.getSelection();if(!_?.anchorNode)return;const ee=Array.from(Array(_.rangeCount).keys()).map(G=>_.getRangeAt(G));if(!ee.some(G=>G.intersectsNode(e))){g=void 0;return}const Be=R.timeStamp-(h?.timeStamp||R.timeStamp);if(h?.type==="pointerdown"&&(Be<1e3&&!g||_.isCollapsed&&Be<_i)&&U(),g||U(),_.isCollapsed){o.getAnnotation(g.annotation)&&!(C(h)||m==="REPLACE_CURRENT")&&(r.clear(),o.deleteAnnotation(g.annotation));return}const Te=ee.map(G=>zn(G,e));if(Te.every(G=>Yn(G)))return;const me=Te.flatMap(G=>Xn(e,G.cloneRange()));if(!(me.length>0&&!g||me.length!==g.selector.length||me.some((G,pt)=>G.toString()!==g.selector[pt]?.quote)))return;const Ut=C(h)&&w?Wn([...w.selector.map(G=>G.range),...me]):me;g={...g,selector:Ut.map(G=>jn(G,e,l)),updated:new Date},!(C(h)||m==="REPLACE_CURRENT")&&(o.getAnnotation(g.annotation)?o.updateTarget(g,X.LOCAL):r.clear())},10),D=R=>{h=bt(R),x=h.button===0},H=async R=>{if(!x)return;const _=bt(R),ee=()=>{const{x:Te,y:me}=e.getBoundingClientRect();if(We(e,_.target)){(typeof f=="function"?f(_,e):f==="ALWAYS")&&r.clear();return}const Re=_.target instanceof Node&&e.contains(_.target)&&o.getAt(_.clientX-Te,_.clientY-me,c==="all",u);if(Re){const{selected:Ut}=r,G=new Set(Ut.map(mt=>mt.id)),pt=Array.isArray(Re)?Re.map(mt=>mt.id):[Re.id];(G.size!==pt.length||!pt.every(mt=>G.has(mt)))&&(n.emit("clickAnnotation",Re),r.userSelect(pt,_))}else r.clear()};if(_.timeStamp-h.timeStamp<_i){await V();const Te=document.getSelection(),me=We(e,h.target),Re=We(e,_.target);if(Te?.isCollapsed||me&&Re){g=void 0,ee();return}}g&&g.selector.length>0&&(Y(),r.userSelect(g.annotation,_))},V=async()=>{const R=document.getSelection();let _=!1,ee=R?.isCollapsed;const Be=()=>ee||_,Te=1;return setTimeout(()=>_=!0,50),Ir(()=>ee=R?.isCollapsed,Te,Be)},S=R=>{document.getSelection()?.isCollapsed||((!g||g.selector.length===0)&&P(R),g&&(Y(),r.userSelect(g.annotation,bt(R))))},O=R=>{A&&R.key==="Shift"&&g&&(document.getSelection().isCollapsed||(Y(),r.userSelect(g.annotation,je(R))))},T=R=>{const _=()=>setTimeout(()=>{g?.selector.length>0&&(r.clear(),o.addAnnotation({id:g.annotation,bodies:[],target:g}),r.userSelect(g.annotation,je(R))),document.removeEventListener("selectionchange",_)},100);document.addEventListener("selectionchange",_),U()};ae(Mr.join(","),{element:e,keydown:!0,keyup:!1},R=>{R.repeat||(h=je(R))}),ae(Di,{keydown:!0,keyup:!1},R=>{h=je(R),T(R)});const L=R=>{R.repeat||R.target!==e&&R.target!==document.body||(g=void 0,r.clear())};ae(Ui.join(","),{keydown:!0,keyup:!1},L);const Y=()=>{const R=o.getAnnotation(g.annotation);if(!R)o.addAnnotation({id:g.annotation,bodies:[],target:g});else{const{target:{updated:_}}=R,{updated:ee}=g;(!_||!ee||_<ee)&&o.updateTarget(g)}};return document.addEventListener("pointerdown",D),document.addEventListener("pointerup",H),document.addEventListener("contextmenu",S),e.addEventListener("keyup",O),e.addEventListener("selectstart",U),document.addEventListener("selectionchange",P),{destroy:()=>{g=void 0,w=void 0,x=void 0,h=void 0,P.clear(),document.removeEventListener("pointerdown",D),document.removeEventListener("pointerup",H),document.removeEventListener("contextmenu",S),e.removeEventListener("keyup",O),e.removeEventListener("selectstart",U),document.removeEventListener("selectionchange",P),ae.unbind()},setFilter:M,setUser:k,setAnnotatingEnabled:d,setAnnotatingMode:N}},Hi=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),Vi="SPANS",Br=(e,t={})=>{vn(e),Hn(e);const n=Hi(t,{annotatingEnabled:!0,user:Po()}),i=Ti(e,n),{selection:o,viewport:r}=i,s=i.store,a=Ro(s),l=No(i,a,n.adapter);let c=n.user;const f=typeof n.renderer!="function"?n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Vi:n.renderer||Vi:null,u=f===null?n.renderer(e,i,r):f==="SPANS"?yi(e,i,r):f==="CSS_HIGHLIGHTS"?mi(e,i,r):f==="CANVAS"?ii(e,i,r):void 0;if(!u)throw`Unknown renderer implementation: ${n.renderer}`;console.debug(f?`Using ${f} renderer`:"Using custom renderer implementation"),n.style&&u.setStyle(n.style);const A=Pi(e,i,l,n);A.setUser(c);const m=Io(i,a,n.adapter),g=()=>c,w=C=>{A.setAnnotatingEnabled(C===void 0?!0:C)},x=C=>{A.setAnnotatingMode(C)},h=C=>{u.setFilter(C),A.setFilter(C)},d=C=>{c=C,A.setUser(C)},N=C=>{C&&(u.setPainter(Ci(C,n.presence)),C.on("selectionChange",()=>u.redraw()))},M=C=>{C?o.setSelected(C):o.clear()};return{...m,destroy:()=>{u.destroy(),A.destroy(),a.destroy()},element:e,getUser:g,setAnnotatingEnabled:w,setAnnotatingMode:x,setFilter:h,setStyle:u.setStyle.bind(u),redraw:u.redraw.bind(u),setUser:d,setSelected:M,setPresenceProvider:N,setVisible:u.setVisible.bind(u),on:l.on,off:l.off,scrollIntoView:Jn(e,s),state:i}};I.DEFAULT_SELECTED_STYLE=rt,I.DEFAULT_STYLE=pe,I.NOT_ANNOTATABLE_CLASS=ke,I.NOT_ANNOTATABLE_SELECTOR=Ne,I.Origin=X,I.UserSelectAction=on,I.W3CTextFormat=lr,I.cancelSingleClickEvents=vn,I.cloneKeyboardEvent=je,I.clonePointerEvent=bt,I.createBaseRenderer=Lt,I.createBody=bo,I.createCanvasRenderer=ii,I.createHighlightsRenderer=mi,I.createPresencePainter=Ci,I.createRenderer=pi,I.createSelectionHandler=Pi,I.createSpansRenderer=yi,I.createTextAnnotator=Br,I.createTextAnnotatorState=Ti,I.fillDefaults=Hi,I.getHighlightClientRects=Vn,I.getQuoteContext=Fn,I.getRangeAnnotatableContents=Tt,I.isMac=Zt,I.isNodeWhitespaceOrEmpty=no,I.isNotAnnotatable=We,I.isRangeAnnotatable=yn,I.isRangeWhitespaceOrEmpty=Yn,I.isRevived=ge,I.mergeClientRects=Kn,I.mergeRanges=Wn,I.paint=wi,I.parseW3CTextAnnotation=Ai,I.programmaticallyFocusable=Hn,I.rangeToSelector=jn,I.reviveAnnotation=Rt,I.reviveSelector=tn,I.reviveTarget=it,I.scrollIntoView=Jn,I.serializeW3CTextAnnotation=Si,I.splitAnnotatableRanges=Xn,I.toDomRectList=ro,I.toParentBounds=$n,I.toViewportBounds=so,I.trimRangeToContainer=zn,I.whitespaceOrEmptyRegex=en,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
3
3
  //# sourceMappingURL=text-annotator.umd.js.map